From 1bb60c58939a1907ecb60a6567a5a6a4040983c8 Mon Sep 17 00:00:00 2001 From: king2088 Date: Fri, 14 Oct 2022 10:40:57 +0800 Subject: [PATCH] update build files --- dist/style.css | 2 +- dist/types/3dLoader/vue3dLoader.vue.d.ts | 6 +- dist/types/index.d.ts | 4 +- dist/vue-3d-loader.cjs.js | 56 ++++++++--------- dist/vue-3d-loader.esm.js | 78 ++++++++++++++++-------- dist/vue-3d-loader.global.js | 58 +++++++++--------- package.json | 2 +- 7 files changed, 120 insertions(+), 86 deletions(-) diff --git a/dist/style.css b/dist/style.css index c51dbdb..58d6828 100644 --- a/dist/style.css +++ b/dist/style.css @@ -1 +1 @@ -.viewer-container[data-v-07257ca0]{position:relative;width:100%;height:100%;margin:0;border:0;padding:0}.viewer-container div[data-v-07257ca0]{position:absolute!important;left:0px!important;opacity:1!important}.viewer-canvas[data-v-07257ca0]{width:100%;height:100%} +.viewer-container[data-v-04ca652e]{position:relative;width:100%;height:100%;margin:0;border:0;padding:0}.viewer-container div[data-v-04ca652e]{position:absolute!important;left:0px!important;opacity:1!important}.viewer-canvas[data-v-04ca652e]{width:100%;height:100%} diff --git a/dist/types/3dLoader/vue3dLoader.vue.d.ts b/dist/types/3dLoader/vue3dLoader.vue.d.ts index e6f2a72..760dfa7 100644 --- a/dist/types/3dLoader/vue3dLoader.vue.d.ts +++ b/dist/types/3dLoader/vue3dLoader.vue.d.ts @@ -1,4 +1,4 @@ -import { Object3D, Vector2, Scene, Raycaster, WebGLRenderer, PerspectiveCamera, Clock, Light } from "three"; +import { Object3D, Vector2, Scene, Raycaster, WebGLRenderer, PerspectiveCamera, AnimationMixer, Clock, Light } from "three"; import { OrbitControls } from "three/examples/jsm/controls/OrbitControls"; export interface coordinates { x: number; @@ -212,7 +212,7 @@ declare const _default: import("vue").DefineComponent<{ loader: any; requestAnimationId: number; stats: any; - mixer: any; + mixers: AnimationMixer | AnimationMixer[]; textureLoader: any; size: import("vue").Ref<{ width: number; @@ -258,6 +258,8 @@ declare const _default: import("vue").DefineComponent<{ generateCanvas: (text: string, style: any) => HTMLCanvasElement; getObjectIndex: (object: any) => any; playAnimations: () => void; + playSingleModel: (item: Object3D) => void; + playMultipleModels: (obj: Object3D) => void; }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("mousedown" | "mousemove" | "mouseup" | "click" | "dblclick" | "load" | "process" | "error")[], "mousedown" | "mousemove" | "mouseup" | "click" | "dblclick" | "load" | "process" | "error", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly HTMLCanvasElement; getObjectIndex: (object: any) => any; playAnimations: () => void; + playSingleModel: (item: Three.Object3D) => void; + playMultipleModels: (obj: Three.Object3D) => void; }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("mousedown" | "mousemove" | "mouseup" | "click" | "dblclick" | "load" | "process" | "error")[], "mousedown" | "mousemove" | "mouseup" | "click" | "dblclick" | "load" | "process" | "error", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly>8&255]+sn[a>>16&255]+sn[a>>24&255]+"-"+sn[e&255]+sn[e>>8&255]+"-"+sn[e>>16&15|64]+sn[e>>24&255]+"-"+sn[t&63|128]+sn[t>>8&255]+"-"+sn[t>>16&255]+sn[t>>24&255]+sn[n&255]+sn[n>>8&255]+sn[n>>16&255]+sn[n>>24&255]).toLowerCase()}function zt(a,e,t){return Math.max(e,Math.min(t,a))}function Eu(a,e){return(a%e+e)%e}function Ig(a,e,t,n,i){return n+(a-e)*(i-n)/(t-e)}function Pg(a,e,t){return a!==e?(t-a)/(e-a):0}function mo(a,e,t){return(1-t)*a+t*e}function Dg(a,e,t,n){return mo(a,e,1-Math.exp(-t*n))}function Fg(a,e=1){return e-Math.abs(Eu(a,e*2)-e)}function Ng(a,e,t){return a<=e?0:a>=t?1:(a=(a-e)/(t-e),a*a*(3-2*a))}function kg(a,e,t){return a<=e?0:a>=t?1:(a=(a-e)/(t-e),a*a*a*(a*(a*6-15)+10))}function Og(a,e){return a+Math.floor(Math.random()*(e-a+1))}function Bg(a,e){return a+Math.random()*(e-a)}function zg(a){return a*(.5-Math.random())}function Ug(a){a!==void 0&&(vh=a);let e=vh+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Gg(a){return a*Ss}function Vg(a){return a*To}function eu(a){return(a&a-1)===0&&a!==0}function cp(a){return Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function ic(a){return Math.pow(2,Math.floor(Math.log(a)/Math.LN2))}function Hg(a,e,t,n,i){const s=Math.cos,r=Math.sin,o=s(t/2),c=r(t/2),l=s((e+n)/2),u=r((e+n)/2),h=s((e-n)/2),f=r((e-n)/2),d=s((n-e)/2),p=r((n-e)/2);switch(i){case"XYX":a.set(o*u,c*h,c*f,o*l);break;case"YZY":a.set(c*f,o*u,c*h,o*l);break;case"ZXZ":a.set(c*h,c*f,o*u,o*l);break;case"XZX":a.set(o*u,c*p,c*d,o*l);break;case"YXY":a.set(c*d,o*u,c*p,o*l);break;case"ZYZ":a.set(c*p,c*d,o*u,o*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Wg(a,e){switch(e.constructor){case Float32Array:return a;case Uint16Array:return a/65535;case Uint8Array:return a/255;case Int16Array:return Math.max(a/32767,-1);case Int8Array:return Math.max(a/127,-1);default:throw new Error("Invalid component type.")}}function qg(a,e){switch(e.constructor){case Float32Array:return a;case Uint16Array:return Math.round(a*65535);case Uint8Array:return Math.round(a*255);case Int16Array:return Math.round(a*32767);case Int8Array:return Math.round(a*127);default:throw new Error("Invalid component type.")}}var en=Object.freeze({__proto__:null,DEG2RAD:Ss,RAD2DEG:To,generateUUID:Sn,clamp:zt,euclideanModulo:Eu,mapLinear:Ig,inverseLerp:Pg,lerp:mo,damp:Dg,pingpong:Fg,smoothstep:Ng,smootherstep:kg,randInt:Og,randFloat:Bg,randFloatSpread:zg,seededRandom:Ug,degToRad:Gg,radToDeg:Vg,isPowerOfTwo:eu,ceilPowerOfTwo:cp,floorPowerOfTwo:ic,setQuaternionFromProperEuler:Hg,normalize:qg,denormalize:Wg});class fe{constructor(e=0,t=0){fe.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,r=this.y-e.y;return this.x=s*n-r*i+e.x,this.y=s*i+r*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ln{constructor(){ln.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(e,t,n,i,s,r,o,c,l){const u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=t,u[4]=s,u[5]=c,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(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,r=n[0],o=n[3],c=n[6],l=n[1],u=n[4],h=n[7],f=n[2],d=n[5],p=n[8],m=i[0],g=i[3],x=i[6],y=i[1],b=i[4],v=i[7],S=i[2],A=i[5],R=i[8];return s[0]=r*m+o*y+c*S,s[3]=r*g+o*b+c*A,s[6]=r*x+o*v+c*R,s[1]=l*m+u*y+h*S,s[4]=l*g+u*b+h*A,s[7]=l*x+u*v+h*R,s[2]=f*m+d*y+p*S,s[5]=f*g+d*b+p*A,s[8]=f*x+d*v+p*R,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],o=e[5],c=e[6],l=e[7],u=e[8];return t*r*u-t*o*l-n*s*u+n*o*c+i*s*l-i*r*c}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],o=e[5],c=e[6],l=e[7],u=e[8],h=u*r-o*l,f=o*c-u*s,d=l*s-r*c,p=t*h+n*f+i*d;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return e[0]=h*m,e[1]=(i*l-u*n)*m,e[2]=(o*n-i*r)*m,e[3]=f*m,e[4]=(u*t-i*c)*m,e[5]=(i*s-o*t)*m,e[6]=d*m,e[7]=(n*c-l*t)*m,e[8]=(r*t-n*s)*m,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,r,o){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*r+l*o)+r+e,-i*l,i*c,-i*(-l*r+c*o)+o+t,0,0,1),this}scale(e,t){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){const t=Math.cos(e),n=Math.sin(e),i=this.elements,s=i[0],r=i[3],o=i[6],c=i[1],l=i[4],u=i[7];return i[0]=t*s+n*c,i[3]=t*r+n*l,i[6]=t*o+n*u,i[1]=-n*s+t*c,i[4]=-n*r+t*l,i[7]=-n*o+t*u,this}translate(e,t){const n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}function lp(a){for(let e=a.length-1;e>=0;--e)if(a[e]>65535)return!0;return!1}const Xg={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function pr(a,e){return new Xg[a](e)}function Ao(a){return document.createElementNS("http://www.w3.org/1999/xhtml",a)}function Ts(a){return a<.04045?a*.0773993808:Math.pow(a*.9478672986+.0521327014,2.4)}function Ka(a){return a<.0031308?a*12.92:1.055*Math.pow(a,.41666)-.055}const Bc={[Zn]:{[Vi]:Ts},[Vi]:{[Zn]:Ka}},Cn={legacyMode:!0,get workingColorSpace(){return Vi},set workingColorSpace(a){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(a,e,t){if(this.legacyMode||e===t||!e||!t)return a;if(Bc[e]&&Bc[e][t]!==void 0){const n=Bc[e][t];return a.r=n(a.r),a.g=n(a.g),a.b=n(a.b),a}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(a,e){return this.convert(a,this.workingColorSpace,e)},toWorkingColorSpace:function(a,e){return this.convert(a,e,this.workingColorSpace)}},up={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},Zt={r:0,g:0,b:0},Un={h:0,s:0,l:0},na={h:0,s:0,l:0};function zc(a,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?a+(e-a)*6*t:t<1/2?e:t<2/3?a+(e-a)*6*(2/3-t):a}function ia(a,e){return e.r=a.r,e.g=a.g,e.b=a.b,e}class ve{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,t===void 0&&n===void 0?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Zn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Cn.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=Vi){return this.r=e,this.g=t,this.b=n,Cn.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=Vi){if(e=Eu(e,1),t=zt(t,0,1),n=zt(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,r=2*n-s;this.r=zc(r,s,e+1/3),this.g=zc(r,s,e),this.b=zc(r,s,e-1/3)}return Cn.toWorkingColorSpace(this,i),this}setStyle(e,t=Zn){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let s;const 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 this.r=Math.min(255,parseInt(s[1],10))/255,this.g=Math.min(255,parseInt(s[2],10))/255,this.b=Math.min(255,parseInt(s[3],10))/255,Cn.toWorkingColorSpace(this,t),n(s[4]),this;if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(s[1],10))/100,this.g=Math.min(100,parseInt(s[2],10))/100,this.b=Math.min(100,parseInt(s[3],10))/100,Cn.toWorkingColorSpace(this,t),n(s[4]),this;break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)){const c=parseFloat(s[1])/360,l=parseInt(s[2],10)/100,u=parseInt(s[3],10)/100;return n(s[4]),this.setHSL(c,l,u,t)}break}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],r=s.length;if(r===3)return this.r=parseInt(s.charAt(0)+s.charAt(0),16)/255,this.g=parseInt(s.charAt(1)+s.charAt(1),16)/255,this.b=parseInt(s.charAt(2)+s.charAt(2),16)/255,Cn.toWorkingColorSpace(this,t),this;if(r===6)return this.r=parseInt(s.charAt(0)+s.charAt(1),16)/255,this.g=parseInt(s.charAt(2)+s.charAt(3),16)/255,this.b=parseInt(s.charAt(4)+s.charAt(5),16)/255,Cn.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=Zn){const n=up[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ts(e.r),this.g=Ts(e.g),this.b=Ts(e.b),this}copyLinearToSRGB(e){return this.r=Ka(e.r),this.g=Ka(e.g),this.b=Ka(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Zn){return Cn.fromWorkingColorSpace(ia(this,Zt),e),zt(Zt.r*255,0,255)<<16^zt(Zt.g*255,0,255)<<8^zt(Zt.b*255,0,255)<<0}getHexString(e=Zn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Vi){Cn.fromWorkingColorSpace(ia(this,Zt),t);const n=Zt.r,i=Zt.g,s=Zt.b,r=Math.max(n,i,s),o=Math.min(n,i,s);let c,l;const u=(o+r)/2;if(o===r)c=0,l=0;else{const h=r-o;switch(l=u<=.5?h/(r+o):h/(2-r-o),r){case n:c=(i-s)/h+(i2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap){const t=Ao("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let r=0;r1)switch(this.wrapS){case cn:e.x=e.x-Math.floor(e.x);break;case jt:e.x=e.x<0?0:1;break;case _r:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case cn:e.y=e.y-Math.floor(e.y);break;case jt:e.y=e.y<0?0:1;break;case _r:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}}At.DEFAULT_IMAGE=null;At.DEFAULT_MAPPING=pc;class dt{constructor(e=0,t=0,n=0,i=1){dt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=this.w,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i+r[12]*s,this.y=r[1]*t+r[5]*n+r[9]*i+r[13]*s,this.z=r[2]*t+r[6]*n+r[10]*i+r[14]*s,this.w=r[3]*t+r[7]*n+r[11]*i+r[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,s;const c=e.elements,l=c[0],u=c[4],h=c[8],f=c[1],d=c[5],p=c[9],m=c[2],g=c[6],x=c[10];if(Math.abs(u-f)<.01&&Math.abs(h-m)<.01&&Math.abs(p-g)<.01){if(Math.abs(u+f)<.1&&Math.abs(h+m)<.1&&Math.abs(p+g)<.1&&Math.abs(l+d+x-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(l+1)/2,v=(d+1)/2,S=(x+1)/2,A=(u+f)/4,R=(h+m)/4,_=(p+g)/4;return b>v&&b>S?b<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(b),i=A/n,s=R/n):v>S?v<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(v),n=A/i,s=_/i):S<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(S),n=R/s,i=_/s),this.set(n,i,s,t),this}let y=Math.sqrt((g-p)*(g-p)+(h-m)*(h-m)+(f-u)*(f-u));return Math.abs(y)<.001&&(y=1),this.x=(g-p)/y,this.y=(h-m)/y,this.z=(f-u)/y,this.w=Math.acos((l+d+x-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class kn extends ri{constructor(e,t,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new dt(0,0,e,t),this.scissorTest=!1,this.viewport=new dt(0,0,e,t);const i={width:e,height:t,depth:1};this.texture=new At(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.internalFormat=n.internalFormat!==void 0?n.internalFormat:null,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:Rt,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null,this.samples=n.samples!==void 0?n.samples:0}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new _s(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Bo extends At{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Bt,this.minFilter=Bt,this.wrapR=jt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Yg extends kn{constructor(e,t,n){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Bo(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class yc extends At{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Bt,this.minFilter=Bt,this.wrapR=jt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Zg extends kn{constructor(e,t,n){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new yc(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class Kg extends kn{constructor(e,t,n,i={}){super(e,t,i),this.isWebGLMultipleRenderTargets=!0;const s=this.texture;this.texture=[];for(let r=0;r=0?1:-1,b=1-x*x;if(b>Number.EPSILON){const S=Math.sqrt(b),A=Math.atan2(S,x*y);g=Math.sin(g*A)/S,o=Math.sin(o*A)/S}const v=o*y;if(c=c*g+f*v,l=l*g+d*v,u=u*g+p*v,h=h*g+m*v,g===1-o){const S=1/Math.sqrt(c*c+l*l+u*u+h*h);c*=S,l*=S,u*=S,h*=S}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,s,r){const o=n[i],c=n[i+1],l=n[i+2],u=n[i+3],h=s[r],f=s[r+1],d=s[r+2],p=s[r+3];return e[t]=o*p+u*h+c*d-l*f,e[t+1]=c*p+u*f+l*h-o*d,e[t+2]=l*p+u*d+o*f-c*h,e[t+3]=u*p-o*h-c*f-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!(e&&e.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=e._x,i=e._y,s=e._z,r=e._order,o=Math.cos,c=Math.sin,l=o(n/2),u=o(i/2),h=o(s/2),f=c(n/2),d=c(i/2),p=c(s/2);switch(r){case"XYZ":this._x=f*u*h+l*d*p,this._y=l*d*h-f*u*p,this._z=l*u*p+f*d*h,this._w=l*u*h-f*d*p;break;case"YXZ":this._x=f*u*h+l*d*p,this._y=l*d*h-f*u*p,this._z=l*u*p-f*d*h,this._w=l*u*h+f*d*p;break;case"ZXY":this._x=f*u*h-l*d*p,this._y=l*d*h+f*u*p,this._z=l*u*p+f*d*h,this._w=l*u*h-f*d*p;break;case"ZYX":this._x=f*u*h-l*d*p,this._y=l*d*h+f*u*p,this._z=l*u*p-f*d*h,this._w=l*u*h+f*d*p;break;case"YZX":this._x=f*u*h+l*d*p,this._y=l*d*h+f*u*p,this._z=l*u*p-f*d*h,this._w=l*u*h-f*d*p;break;case"XZY":this._x=f*u*h-l*d*p,this._y=l*d*h-f*u*p,this._z=l*u*p+f*d*h,this._w=l*u*h+f*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],s=t[8],r=t[1],o=t[5],c=t[9],l=t[2],u=t[6],h=t[10],f=n+o+h;if(f>0){const d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(u-c)*d,this._y=(s-l)*d,this._z=(r-i)*d}else if(n>o&&n>h){const d=2*Math.sqrt(1+n-o-h);this._w=(u-c)/d,this._x=.25*d,this._y=(i+r)/d,this._z=(s+l)/d}else if(o>h){const d=2*Math.sqrt(1+o-n-h);this._w=(s-l)/d,this._x=(i+r)/d,this._y=.25*d,this._z=(c+u)/d}else{const d=2*Math.sqrt(1+h-n-o);this._w=(r-i)/d,this._x=(s+l)/d,this._y=(c+u)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(zt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,s=e._z,r=e._w,o=t._x,c=t._y,l=t._z,u=t._w;return this._x=n*u+r*o+i*l-s*c,this._y=i*u+r*c+s*o-n*l,this._z=s*u+r*l+n*c-i*o,this._w=r*u-n*o-i*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,r=this._w;let o=r*e._w+n*e._x+i*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=r,this._x=n,this._y=i,this._z=s,this;const c=1-o*o;if(c<=Number.EPSILON){const d=1-t;return this._w=d*r+t*this._w,this._x=d*n+t*this._x,this._y=d*i+t*this._y,this._z=d*s+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(c),u=Math.atan2(l,o),h=Math.sin((1-t)*u)/l,f=Math.sin(t*u)/l;return this._w=r*h+this._w*f,this._x=n*h+this._x*f,this._y=i*h+this._y*f,this._z=s*h+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(s),n*Math.cos(s),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class D{constructor(e=0,t=0,n=0){D.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(_h.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(_h.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=e.elements,r=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*r,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*r,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*r,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,s=e.x,r=e.y,o=e.z,c=e.w,l=c*t+r*i-o*n,u=c*n+o*t-s*i,h=c*i+s*n-r*t,f=-s*t-r*n-o*i;return this.x=l*c+f*-s+u*-o-h*-r,this.y=u*c+f*-r+h*-s-l*-o,this.z=h*c+f*-o+l*-r-u*-s,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,s=e.z,r=t.x,o=t.y,c=t.z;return this.x=i*c-s*o,this.y=s*r-n*c,this.z=n*o-i*r,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Gc.copy(this).projectOnVector(e),this.sub(Gc)}reflect(e){return this.sub(Gc.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(zt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Gc=new D,_h=new Ft;class Ei{constructor(e=new D(1/0,1/0,1/0),t=new D(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,n=1/0,i=1/0,s=-1/0,r=-1/0,o=-1/0;for(let c=0,l=e.length;cs&&(s=u),h>r&&(r=h),f>o&&(o=f)}return this.min.set(t,n,i),this.max.set(s,r,o),this}setFromBufferAttribute(e){let t=1/0,n=1/0,i=1/0,s=-1/0,r=-1/0,o=-1/0;for(let c=0,l=e.count;cs&&(s=u),h>r&&(r=h),f>o&&(o=f)}return this.min.set(t,n,i),this.max.set(s,r,o),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,ss),ss.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(eo),sa.subVectors(this.max,eo),js.subVectors(e.a,eo),Ys.subVectors(e.b,eo),Zs.subVectors(e.c,eo),Ri.subVectors(Ys,js),Ii.subVectors(Zs,Ys),rs.subVectors(js,Zs);let t=[0,-Ri.z,Ri.y,0,-Ii.z,Ii.y,0,-rs.z,rs.y,Ri.z,0,-Ri.x,Ii.z,0,-Ii.x,rs.z,0,-rs.x,-Ri.y,Ri.x,0,-Ii.y,Ii.x,0,-rs.y,rs.x,0];return!Hc(t,js,Ys,Zs,sa)||(t=[1,0,0,0,1,0,0,0,1],!Hc(t,js,Ys,Zs,sa))?!1:(ra.crossVectors(Ri,Ii),t=[ra.x,ra.y,ra.z],Hc(t,js,Ys,Zs,sa))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return ss.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(ss).length()*.5,e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(ci[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ci[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ci[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ci[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ci[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ci[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ci[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ci[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ci),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const ci=[new D,new D,new D,new D,new D,new D,new D,new D],ss=new D,Vc=new Ei,js=new D,Ys=new D,Zs=new D,Ri=new D,Ii=new D,rs=new D,eo=new D,sa=new D,ra=new D,os=new D;function Hc(a,e,t,n,i){for(let s=0,r=a.length-3;s<=r;s+=3){os.fromArray(a,s);const o=i.x*Math.abs(os.x)+i.y*Math.abs(os.y)+i.z*Math.abs(os.z),c=e.dot(os),l=t.dot(os),u=n.dot(os);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>o)return!1}return!0}const Jg=new Ei,bh=new D,oa=new D,Wc=new D;class es{constructor(e=new D,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Jg.setFromPoints(e).getCenter(n);let i=0;for(let s=0,r=e.length;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){Wc.subVectors(e,this.center);const t=Wc.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.add(Wc.multiplyScalar(i/n)),this.radius+=i}return this}union(e){return this.center.equals(e.center)===!0?oa.set(0,0,1).multiplyScalar(e.radius):oa.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(bh.copy(e.center).add(oa)),this.expandByPoint(bh.copy(e.center).sub(oa)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const li=new D,qc=new D,aa=new D,Pi=new D,Xc=new D,ca=new D,jc=new D;class zo{constructor(e=new D,t=new D(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,li)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=li.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(li.copy(this.direction).multiplyScalar(t).add(this.origin),li.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){qc.copy(e).add(t).multiplyScalar(.5),aa.copy(t).sub(e).normalize(),Pi.copy(this.origin).sub(qc);const s=e.distanceTo(t)*.5,r=-this.direction.dot(aa),o=Pi.dot(this.direction),c=-Pi.dot(aa),l=Pi.lengthSq(),u=Math.abs(1-r*r);let h,f,d,p;if(u>0)if(h=r*c-o,f=r*o-c,p=s*u,h>=0)if(f>=-p)if(f<=p){const m=1/u;h*=m,f*=m,d=h*(h+r*f+2*o)+f*(r*h+f+2*c)+l}else f=s,h=Math.max(0,-(r*f+o)),d=-h*h+f*(f+2*c)+l;else f=-s,h=Math.max(0,-(r*f+o)),d=-h*h+f*(f+2*c)+l;else f<=-p?(h=Math.max(0,-(-r*s+o)),f=h>0?-s:Math.min(Math.max(-s,-c),s),d=-h*h+f*(f+2*c)+l):f<=p?(h=0,f=Math.min(Math.max(-s,-c),s),d=f*(f+2*c)+l):(h=Math.max(0,-(r*s+o)),f=h>0?s:Math.min(Math.max(-s,-c),s),d=-h*h+f*(f+2*c)+l);else f=r>0?-s:s,h=Math.max(0,-(r*f+o)),d=-h*h+f*(f+2*c)+l;return n&&n.copy(this.direction).multiplyScalar(h).add(this.origin),i&&i.copy(aa).multiplyScalar(f).add(qc),d}intersectSphere(e,t){li.subVectors(e.center,this.origin);const n=li.dot(this.direction),i=li.dot(li)-n*n,s=e.radius*e.radius;if(i>s)return null;const r=Math.sqrt(s-i),o=n-r,c=n+r;return o<0&&c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,r,o,c;const l=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,f=this.origin;return l>=0?(n=(e.min.x-f.x)*l,i=(e.max.x-f.x)*l):(n=(e.max.x-f.x)*l,i=(e.min.x-f.x)*l),u>=0?(s=(e.min.y-f.y)*u,r=(e.max.y-f.y)*u):(s=(e.max.y-f.y)*u,r=(e.min.y-f.y)*u),n>r||s>i||((s>n||n!==n)&&(n=s),(r=0?(o=(e.min.z-f.z)*h,c=(e.max.z-f.z)*h):(o=(e.max.z-f.z)*h,c=(e.min.z-f.z)*h),n>c||o>i)||((o>n||n!==n)&&(n=o),(c=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,li)!==null}intersectTriangle(e,t,n,i,s){Xc.subVectors(t,e),ca.subVectors(n,e),jc.crossVectors(Xc,ca);let r=this.direction.dot(jc),o;if(r>0){if(i)return null;o=1}else if(r<0)o=-1,r=-r;else return null;Pi.subVectors(this.origin,e);const c=o*this.direction.dot(ca.crossVectors(Pi,ca));if(c<0)return null;const l=o*this.direction.dot(Xc.cross(Pi));if(l<0||c+l>r)return null;const u=-o*Pi.dot(jc);return u<0?null:this.at(u/r,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class De{constructor(){De.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(e,t,n,i,s,r,o,c,l,u,h,f,d,p,m,g){const x=this.elements;return x[0]=e,x[4]=t,x[8]=n,x[12]=i,x[1]=s,x[5]=r,x[9]=o,x[13]=c,x[2]=l,x[6]=u,x[10]=h,x[14]=f,x[3]=d,x[7]=p,x[11]=m,x[15]=g,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 De().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/Ks.setFromMatrixColumn(e,0).length(),s=1/Ks.setFromMatrixColumn(e,1).length(),r=1/Ks.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*r,t[9]=n[9]*r,t[10]=n[10]*r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,s=e.z,r=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const f=r*u,d=r*h,p=o*u,m=o*h;t[0]=c*u,t[4]=-c*h,t[8]=l,t[1]=d+p*l,t[5]=f-m*l,t[9]=-o*c,t[2]=m-f*l,t[6]=p+d*l,t[10]=r*c}else if(e.order==="YXZ"){const f=c*u,d=c*h,p=l*u,m=l*h;t[0]=f+m*o,t[4]=p*o-d,t[8]=r*l,t[1]=r*h,t[5]=r*u,t[9]=-o,t[2]=d*o-p,t[6]=m+f*o,t[10]=r*c}else if(e.order==="ZXY"){const f=c*u,d=c*h,p=l*u,m=l*h;t[0]=f-m*o,t[4]=-r*h,t[8]=p+d*o,t[1]=d+p*o,t[5]=r*u,t[9]=m-f*o,t[2]=-r*l,t[6]=o,t[10]=r*c}else if(e.order==="ZYX"){const f=r*u,d=r*h,p=o*u,m=o*h;t[0]=c*u,t[4]=p*l-d,t[8]=f*l+m,t[1]=c*h,t[5]=m*l+f,t[9]=d*l-p,t[2]=-l,t[6]=o*c,t[10]=r*c}else if(e.order==="YZX"){const f=r*c,d=r*l,p=o*c,m=o*l;t[0]=c*u,t[4]=m-f*h,t[8]=p*h+d,t[1]=h,t[5]=r*u,t[9]=-o*u,t[2]=-l*u,t[6]=d*h+p,t[10]=f-m*h}else if(e.order==="XZY"){const f=r*c,d=r*l,p=o*c,m=o*l;t[0]=c*u,t[4]=-h,t[8]=l*u,t[1]=f*h+m,t[5]=r*u,t[9]=d*h-p,t[2]=p*h-d,t[6]=o*u,t[10]=m*h+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose($g,e,Qg)}lookAt(e,t,n){const i=this.elements;return bn.subVectors(e,t),bn.lengthSq()===0&&(bn.z=1),bn.normalize(),Di.crossVectors(n,bn),Di.lengthSq()===0&&(Math.abs(n.z)===1?bn.x+=1e-4:bn.z+=1e-4,bn.normalize(),Di.crossVectors(n,bn)),Di.normalize(),la.crossVectors(bn,Di),i[0]=Di.x,i[4]=la.x,i[8]=bn.x,i[1]=Di.y,i[5]=la.y,i[9]=bn.y,i[2]=Di.z,i[6]=la.z,i[10]=bn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,r=n[0],o=n[4],c=n[8],l=n[12],u=n[1],h=n[5],f=n[9],d=n[13],p=n[2],m=n[6],g=n[10],x=n[14],y=n[3],b=n[7],v=n[11],S=n[15],A=i[0],R=i[4],_=i[8],L=i[12],N=i[1],B=i[5],W=i[9],K=i[13],z=i[2],q=i[6],O=i[10],Y=i[14],j=i[3],H=i[7],X=i[11],te=i[15];return s[0]=r*A+o*N+c*z+l*j,s[4]=r*R+o*B+c*q+l*H,s[8]=r*_+o*W+c*O+l*X,s[12]=r*L+o*K+c*Y+l*te,s[1]=u*A+h*N+f*z+d*j,s[5]=u*R+h*B+f*q+d*H,s[9]=u*_+h*W+f*O+d*X,s[13]=u*L+h*K+f*Y+d*te,s[2]=p*A+m*N+g*z+x*j,s[6]=p*R+m*B+g*q+x*H,s[10]=p*_+m*W+g*O+x*X,s[14]=p*L+m*K+g*Y+x*te,s[3]=y*A+b*N+v*z+S*j,s[7]=y*R+b*B+v*q+S*H,s[11]=y*_+b*W+v*O+S*X,s[15]=y*L+b*K+v*Y+S*te,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],r=e[1],o=e[5],c=e[9],l=e[13],u=e[2],h=e[6],f=e[10],d=e[14],p=e[3],m=e[7],g=e[11],x=e[15];return p*(+s*c*h-i*l*h-s*o*f+n*l*f+i*o*d-n*c*d)+m*(+t*c*d-t*l*f+s*r*f-i*r*d+i*l*u-s*c*u)+g*(+t*l*h-t*o*d-s*r*h+n*r*d+s*o*u-n*l*u)+x*(-i*o*u-t*c*h+t*o*f+i*r*h-n*r*f+n*c*u)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],o=e[5],c=e[6],l=e[7],u=e[8],h=e[9],f=e[10],d=e[11],p=e[12],m=e[13],g=e[14],x=e[15],y=h*g*l-m*f*l+m*c*d-o*g*d-h*c*x+o*f*x,b=p*f*l-u*g*l-p*c*d+r*g*d+u*c*x-r*f*x,v=u*m*l-p*h*l+p*o*d-r*m*d-u*o*x+r*h*x,S=p*h*c-u*m*c-p*o*f+r*m*f+u*o*g-r*h*g,A=t*y+n*b+i*v+s*S;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const R=1/A;return e[0]=y*R,e[1]=(m*f*s-h*g*s-m*i*d+n*g*d+h*i*x-n*f*x)*R,e[2]=(o*g*s-m*c*s+m*i*l-n*g*l-o*i*x+n*c*x)*R,e[3]=(h*c*s-o*f*s-h*i*l+n*f*l+o*i*d-n*c*d)*R,e[4]=b*R,e[5]=(u*g*s-p*f*s+p*i*d-t*g*d-u*i*x+t*f*x)*R,e[6]=(p*c*s-r*g*s-p*i*l+t*g*l+r*i*x-t*c*x)*R,e[7]=(r*f*s-u*c*s+u*i*l-t*f*l-r*i*d+t*c*d)*R,e[8]=v*R,e[9]=(p*h*s-u*m*s-p*n*d+t*m*d+u*n*x-t*h*x)*R,e[10]=(r*m*s-p*o*s+p*n*l-t*m*l-r*n*x+t*o*x)*R,e[11]=(u*o*s-r*h*s-u*n*l+t*h*l+r*n*d-t*o*d)*R,e[12]=S*R,e[13]=(u*m*i-p*h*i+p*n*f-t*m*f-u*n*g+t*h*g)*R,e[14]=(p*o*i-r*m*i-p*n*c+t*m*c+r*n*g-t*o*g)*R,e[15]=(r*h*i-u*o*i+u*n*c-t*h*c-r*n*f+t*o*f)*R,this}scale(e){const t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),s=1-n,r=e.x,o=e.y,c=e.z,l=s*r,u=s*o;return this.set(l*r+n,l*o-i*c,l*c+i*o,0,l*o+i*c,u*o+n,u*c-i*r,0,l*c-i*o,u*c+i*r,s*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,r){return this.set(1,n,s,0,e,1,r,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,s=t._x,r=t._y,o=t._z,c=t._w,l=s+s,u=r+r,h=o+o,f=s*l,d=s*u,p=s*h,m=r*u,g=r*h,x=o*h,y=c*l,b=c*u,v=c*h,S=n.x,A=n.y,R=n.z;return i[0]=(1-(m+x))*S,i[1]=(d+v)*S,i[2]=(p-b)*S,i[3]=0,i[4]=(d-v)*A,i[5]=(1-(f+x))*A,i[6]=(g+y)*A,i[7]=0,i[8]=(p+b)*R,i[9]=(g-y)*R,i[10]=(1-(f+m))*R,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=Ks.set(i[0],i[1],i[2]).length();const r=Ks.set(i[4],i[5],i[6]).length(),o=Ks.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Gn.copy(this);const l=1/s,u=1/r,h=1/o;return Gn.elements[0]*=l,Gn.elements[1]*=l,Gn.elements[2]*=l,Gn.elements[4]*=u,Gn.elements[5]*=u,Gn.elements[6]*=u,Gn.elements[8]*=h,Gn.elements[9]*=h,Gn.elements[10]*=h,t.setFromRotationMatrix(Gn),n.x=s,n.y=r,n.z=o,this}makePerspective(e,t,n,i,s,r){const o=this.elements,c=2*s/(t-e),l=2*s/(n-i),u=(t+e)/(t-e),h=(n+i)/(n-i),f=-(r+s)/(r-s),d=-2*r*s/(r-s);return o[0]=c,o[4]=0,o[8]=u,o[12]=0,o[1]=0,o[5]=l,o[9]=h,o[13]=0,o[2]=0,o[6]=0,o[10]=f,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,i,s,r){const o=this.elements,c=1/(t-e),l=1/(n-i),u=1/(r-s),h=(t+e)*c,f=(n+i)*l,d=(r+s)*u;return o[0]=2*c,o[4]=0,o[8]=0,o[12]=-h,o[1]=0,o[5]=2*l,o[9]=0,o[13]=-f,o[2]=0,o[6]=0,o[10]=-2*u,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Ks=new D,Gn=new De,$g=new D(0,0,0),Qg=new D(1,1,1),Di=new D,la=new D,bn=new D,wh=new De,Mh=new Ft;class Pn{constructor(e=0,t=0,n=0,i=Pn.DefaultOrder){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,s=i[0],r=i[4],o=i[8],c=i[1],l=i[5],u=i[9],h=i[2],f=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(zt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-r,s)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-zt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(zt(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-r,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-zt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-r,l));break;case"YZX":this._z=Math.asin(zt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-zt(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return wh.makeRotationFromQuaternion(e),this.setFromRotationMatrix(wh,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Mh.setFromEuler(this),this.setFromQuaternion(Mh,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}toVector3(){console.error("THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead")}}Pn.DefaultOrder="XYZ";Pn.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class xc{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0){i.children=[];for(let o=0;o0){i.animations=[];for(let o=0;o0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),f.length>0&&(n.skeletons=f),d.length>0&&(n.animations=d),p.length>0&&(n.nodes=p)}return n.object=i,n;function r(o){const c=[];for(const l in o){const u=o[l];delete u.metadata,c.push(u)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){Vn.subVectors(i,t),hi.subVectors(n,t),Yc.subVectors(e,t);const r=Vn.dot(Vn),o=Vn.dot(hi),c=Vn.dot(Yc),l=hi.dot(hi),u=hi.dot(Yc),h=r*l-o*o;if(h===0)return s.set(-2,-1,-1);const f=1/h,d=(l*c-o*u)*f,p=(r*u-o*c)*f;return s.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,fi),fi.x>=0&&fi.y>=0&&fi.x+fi.y<=1}static getUV(e,t,n,i,s,r,o,c){return this.getBarycoord(e,t,n,i,fi),c.set(0,0),c.addScaledVector(s,fi.x),c.addScaledVector(r,fi.y),c.addScaledVector(o,fi.z),c}static isFrontFacing(e,t,n,i){return Vn.subVectors(n,t),hi.subVectors(e,t),Vn.cross(hi).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Vn.subVectors(this.c,this.b),hi.subVectors(this.a,this.b),Vn.cross(hi).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return In.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return In.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,s){return In.getUV(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return In.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return In.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,s=this.c;let r,o;$s.subVectors(i,n),Qs.subVectors(s,n),Zc.subVectors(e,n);const c=$s.dot(Zc),l=Qs.dot(Zc);if(c<=0&&l<=0)return t.copy(n);Kc.subVectors(e,i);const u=$s.dot(Kc),h=Qs.dot(Kc);if(u>=0&&h<=u)return t.copy(i);const f=c*h-u*l;if(f<=0&&c>=0&&u<=0)return r=c/(c-u),t.copy(n).addScaledVector($s,r);Jc.subVectors(e,s);const d=$s.dot(Jc),p=Qs.dot(Jc);if(p>=0&&d<=p)return t.copy(s);const m=d*l-c*p;if(m<=0&&l>=0&&p<=0)return o=l/(l-p),t.copy(n).addScaledVector(Qs,o);const g=u*p-d*h;if(g<=0&&h-u>=0&&d-p>=0)return Lh.subVectors(s,i),o=(h-u)/(h-u+(d-p)),t.copy(i).addScaledVector(Lh,o);const x=1/(g+m+f);return r=m*x,o=f*x,t.copy(n).addScaledVector($s,r).addScaledVector(Qs,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let s0=0;class Gt extends ri{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:s0++}),this.uuid=Sn(),this.name="",this.type="Material",this.blending=ws,this.side=vi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=bu,this.blendDst=wu,this.blendEquation=gs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=tc,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ap,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Za,this.stencilZFail=Za,this.stencilZPass=Za,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if(t==="shading"){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=n===dd;continue}const i=this[t];if(i===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==ws&&(n.blending=this.blending),this.side!==vi&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=this.flatShading),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData);function i(s){const r=[];for(const o in s){const c=s[o];delete c.metadata,r.push(c)}return r}if(t){const s=i(e.textures),r=i(e.images);s.length>0&&(n.textures=s),r.length>0&&(n.images=r)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class un extends Gt{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ve(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Oo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Xt=new D,ha=new fe;class pt{constructor(e,t,n){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n===!0,this.usage=So,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,s=this.itemSize;i0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const i={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],u=[];for(let h=0,f=l.length;h0&&(i[c]=u,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(e.data.groups=JSON.parse(JSON.stringify(r)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const i=e.attributes;for(const l in i){const u=i[l];this.setAttribute(l,u.clone(t))}const s=e.morphAttributes;for(const l in s){const u=[],h=s[l];for(let f=0,d=h.length;f0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;st.far?null:{distance:l,point:xa.clone(),object:a}}function va(a,e,t,n,i,s,r,o,c,l,u,h){Fi.fromBufferAttribute(i,l),Ni.fromBufferAttribute(i,u),ki.fromBufferAttribute(i,h);const f=a.morphTargetInfluences;if(s&&f){fa.set(0,0,0),da.set(0,0,0),pa.set(0,0,0);for(let p=0,m=s.length;p0?1:-1,u.push(H.x,H.y,H.z),h.push(J/R),h.push(1-X/_),Y+=1}}for(let X=0;X<_;X++)for(let te=0;te>8&255]+sn[a>>16&255]+sn[a>>24&255]+"-"+sn[e&255]+sn[e>>8&255]+"-"+sn[e>>16&15|64]+sn[e>>24&255]+"-"+sn[t&63|128]+sn[t>>8&255]+"-"+sn[t>>16&255]+sn[t>>24&255]+sn[n&255]+sn[n>>8&255]+sn[n>>16&255]+sn[n>>24&255]).toLowerCase()}function zt(a,e,t){return Math.max(e,Math.min(t,a))}function Cu(a,e){return(a%e+e)%e}function Ig(a,e,t,n,i){return n+(a-e)*(i-n)/(t-e)}function Pg(a,e,t){return a!==e?(t-a)/(e-a):0}function mo(a,e,t){return(1-t)*a+t*e}function Dg(a,e,t,n){return mo(a,e,1-Math.exp(-t*n))}function Fg(a,e=1){return e-Math.abs(Cu(a,e*2)-e)}function Ng(a,e,t){return a<=e?0:a>=t?1:(a=(a-e)/(t-e),a*a*(3-2*a))}function kg(a,e,t){return a<=e?0:a>=t?1:(a=(a-e)/(t-e),a*a*a*(a*(a*6-15)+10))}function Og(a,e){return a+Math.floor(Math.random()*(e-a+1))}function Bg(a,e){return a+Math.random()*(e-a)}function zg(a){return a*(.5-Math.random())}function Ug(a){a!==void 0&&(_h=a);let e=_h+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Gg(a){return a*Ss}function Vg(a){return a*To}function tu(a){return(a&a-1)===0&&a!==0}function lp(a){return Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function sc(a){return Math.pow(2,Math.floor(Math.log(a)/Math.LN2))}function Hg(a,e,t,n,i){const s=Math.cos,r=Math.sin,o=s(t/2),c=r(t/2),l=s((e+n)/2),u=r((e+n)/2),h=s((e-n)/2),f=r((e-n)/2),d=s((n-e)/2),p=r((n-e)/2);switch(i){case"XYX":a.set(o*u,c*h,c*f,o*l);break;case"YZY":a.set(c*f,o*u,c*h,o*l);break;case"ZXZ":a.set(c*h,c*f,o*u,o*l);break;case"XZX":a.set(o*u,c*p,c*d,o*l);break;case"YXY":a.set(c*d,o*u,c*p,o*l);break;case"ZYZ":a.set(c*p,c*d,o*u,o*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Wg(a,e){switch(e.constructor){case Float32Array:return a;case Uint16Array:return a/65535;case Uint8Array:return a/255;case Int16Array:return Math.max(a/32767,-1);case Int8Array:return Math.max(a/127,-1);default:throw new Error("Invalid component type.")}}function qg(a,e){switch(e.constructor){case Float32Array:return a;case Uint16Array:return Math.round(a*65535);case Uint8Array:return Math.round(a*255);case Int16Array:return Math.round(a*32767);case Int8Array:return Math.round(a*127);default:throw new Error("Invalid component type.")}}var en=Object.freeze({__proto__:null,DEG2RAD:Ss,RAD2DEG:To,generateUUID:Sn,clamp:zt,euclideanModulo:Cu,mapLinear:Ig,inverseLerp:Pg,lerp:mo,damp:Dg,pingpong:Fg,smoothstep:Ng,smootherstep:kg,randInt:Og,randFloat:Bg,randFloatSpread:zg,seededRandom:Ug,degToRad:Gg,radToDeg:Vg,isPowerOfTwo:tu,ceilPowerOfTwo:lp,floorPowerOfTwo:sc,setQuaternionFromProperEuler:Hg,normalize:qg,denormalize:Wg});class de{constructor(e=0,t=0){de.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,r=this.y-e.y;return this.x=s*n-r*i+e.x,this.y=s*i+r*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ln{constructor(){ln.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(e,t,n,i,s,r,o,c,l){const u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=t,u[4]=s,u[5]=c,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(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,r=n[0],o=n[3],c=n[6],l=n[1],u=n[4],h=n[7],f=n[2],d=n[5],p=n[8],m=i[0],g=i[3],x=i[6],y=i[1],b=i[4],v=i[7],M=i[2],T=i[5],C=i[8];return s[0]=r*m+o*y+c*M,s[3]=r*g+o*b+c*T,s[6]=r*x+o*v+c*C,s[1]=l*m+u*y+h*M,s[4]=l*g+u*b+h*T,s[7]=l*x+u*v+h*C,s[2]=f*m+d*y+p*M,s[5]=f*g+d*b+p*T,s[8]=f*x+d*v+p*C,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],o=e[5],c=e[6],l=e[7],u=e[8];return t*r*u-t*o*l-n*s*u+n*o*c+i*s*l-i*r*c}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],o=e[5],c=e[6],l=e[7],u=e[8],h=u*r-o*l,f=o*c-u*s,d=l*s-r*c,p=t*h+n*f+i*d;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return e[0]=h*m,e[1]=(i*l-u*n)*m,e[2]=(o*n-i*r)*m,e[3]=f*m,e[4]=(u*t-i*c)*m,e[5]=(i*s-o*t)*m,e[6]=d*m,e[7]=(n*c-l*t)*m,e[8]=(r*t-n*s)*m,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,r,o){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*r+l*o)+r+e,-i*l,i*c,-i*(-l*r+c*o)+o+t,0,0,1),this}scale(e,t){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){const t=Math.cos(e),n=Math.sin(e),i=this.elements,s=i[0],r=i[3],o=i[6],c=i[1],l=i[4],u=i[7];return i[0]=t*s+n*c,i[3]=t*r+n*l,i[6]=t*o+n*u,i[1]=-n*s+t*c,i[4]=-n*r+t*l,i[7]=-n*o+t*u,this}translate(e,t){const n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}function up(a){for(let e=a.length-1;e>=0;--e)if(a[e]>65535)return!0;return!1}const Xg={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function pr(a,e){return new Xg[a](e)}function Ao(a){return document.createElementNS("http://www.w3.org/1999/xhtml",a)}function Ts(a){return a<.04045?a*.0773993808:Math.pow(a*.9478672986+.0521327014,2.4)}function Ka(a){return a<.0031308?a*12.92:1.055*Math.pow(a,.41666)-.055}const zc={[Zn]:{[Vi]:Ts},[Vi]:{[Zn]:Ka}},Cn={legacyMode:!0,get workingColorSpace(){return Vi},set workingColorSpace(a){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(a,e,t){if(this.legacyMode||e===t||!e||!t)return a;if(zc[e]&&zc[e][t]!==void 0){const n=zc[e][t];return a.r=n(a.r),a.g=n(a.g),a.b=n(a.b),a}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(a,e){return this.convert(a,this.workingColorSpace,e)},toWorkingColorSpace:function(a,e){return this.convert(a,e,this.workingColorSpace)}},hp={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},Zt={r:0,g:0,b:0},Un={h:0,s:0,l:0},na={h:0,s:0,l:0};function Uc(a,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?a+(e-a)*6*t:t<1/2?e:t<2/3?a+(e-a)*6*(2/3-t):a}function ia(a,e){return e.r=a.r,e.g=a.g,e.b=a.b,e}class be{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,t===void 0&&n===void 0?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Zn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Cn.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=Vi){return this.r=e,this.g=t,this.b=n,Cn.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=Vi){if(e=Cu(e,1),t=zt(t,0,1),n=zt(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,r=2*n-s;this.r=Uc(r,s,e+1/3),this.g=Uc(r,s,e),this.b=Uc(r,s,e-1/3)}return Cn.toWorkingColorSpace(this,i),this}setStyle(e,t=Zn){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let s;const 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 this.r=Math.min(255,parseInt(s[1],10))/255,this.g=Math.min(255,parseInt(s[2],10))/255,this.b=Math.min(255,parseInt(s[3],10))/255,Cn.toWorkingColorSpace(this,t),n(s[4]),this;if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(s[1],10))/100,this.g=Math.min(100,parseInt(s[2],10))/100,this.b=Math.min(100,parseInt(s[3],10))/100,Cn.toWorkingColorSpace(this,t),n(s[4]),this;break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)){const c=parseFloat(s[1])/360,l=parseInt(s[2],10)/100,u=parseInt(s[3],10)/100;return n(s[4]),this.setHSL(c,l,u,t)}break}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],r=s.length;if(r===3)return this.r=parseInt(s.charAt(0)+s.charAt(0),16)/255,this.g=parseInt(s.charAt(1)+s.charAt(1),16)/255,this.b=parseInt(s.charAt(2)+s.charAt(2),16)/255,Cn.toWorkingColorSpace(this,t),this;if(r===6)return this.r=parseInt(s.charAt(0)+s.charAt(1),16)/255,this.g=parseInt(s.charAt(2)+s.charAt(3),16)/255,this.b=parseInt(s.charAt(4)+s.charAt(5),16)/255,Cn.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=Zn){const n=hp[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ts(e.r),this.g=Ts(e.g),this.b=Ts(e.b),this}copyLinearToSRGB(e){return this.r=Ka(e.r),this.g=Ka(e.g),this.b=Ka(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Zn){return Cn.fromWorkingColorSpace(ia(this,Zt),e),zt(Zt.r*255,0,255)<<16^zt(Zt.g*255,0,255)<<8^zt(Zt.b*255,0,255)<<0}getHexString(e=Zn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Vi){Cn.fromWorkingColorSpace(ia(this,Zt),t);const n=Zt.r,i=Zt.g,s=Zt.b,r=Math.max(n,i,s),o=Math.min(n,i,s);let c,l;const u=(o+r)/2;if(o===r)c=0,l=0;else{const h=r-o;switch(l=u<=.5?h/(r+o):h/(2-r-o),r){case n:c=(i-s)/h+(i2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap){const t=Ao("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let r=0;r1)switch(this.wrapS){case cn:e.x=e.x-Math.floor(e.x);break;case jt:e.x=e.x<0?0:1;break;case _r:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case cn:e.y=e.y-Math.floor(e.y);break;case jt:e.y=e.y<0?0:1;break;case _r:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}}At.DEFAULT_IMAGE=null;At.DEFAULT_MAPPING=mc;class dt{constructor(e=0,t=0,n=0,i=1){dt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=this.w,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i+r[12]*s,this.y=r[1]*t+r[5]*n+r[9]*i+r[13]*s,this.z=r[2]*t+r[6]*n+r[10]*i+r[14]*s,this.w=r[3]*t+r[7]*n+r[11]*i+r[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,s;const c=e.elements,l=c[0],u=c[4],h=c[8],f=c[1],d=c[5],p=c[9],m=c[2],g=c[6],x=c[10];if(Math.abs(u-f)<.01&&Math.abs(h-m)<.01&&Math.abs(p-g)<.01){if(Math.abs(u+f)<.1&&Math.abs(h+m)<.1&&Math.abs(p+g)<.1&&Math.abs(l+d+x-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(l+1)/2,v=(d+1)/2,M=(x+1)/2,T=(u+f)/4,C=(h+m)/4,_=(p+g)/4;return b>v&&b>M?b<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(b),i=T/n,s=C/n):v>M?v<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(v),n=T/i,s=_/i):M<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(M),n=C/s,i=_/s),this.set(n,i,s,t),this}let y=Math.sqrt((g-p)*(g-p)+(h-m)*(h-m)+(f-u)*(f-u));return Math.abs(y)<.001&&(y=1),this.x=(g-p)/y,this.y=(h-m)/y,this.z=(f-u)/y,this.w=Math.acos((l+d+x-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class kn extends ri{constructor(e,t,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new dt(0,0,e,t),this.scissorTest=!1,this.viewport=new dt(0,0,e,t);const i={width:e,height:t,depth:1};this.texture=new At(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.internalFormat=n.internalFormat!==void 0?n.internalFormat:null,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:Rt,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null,this.samples=n.samples!==void 0?n.samples:0}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new _s(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Bo extends At{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Bt,this.minFilter=Bt,this.wrapR=jt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Yg extends kn{constructor(e,t,n){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Bo(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class xc extends At{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Bt,this.minFilter=Bt,this.wrapR=jt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Zg extends kn{constructor(e,t,n){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new xc(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class Kg extends kn{constructor(e,t,n,i={}){super(e,t,i),this.isWebGLMultipleRenderTargets=!0;const s=this.texture;this.texture=[];for(let r=0;r=0?1:-1,b=1-x*x;if(b>Number.EPSILON){const M=Math.sqrt(b),T=Math.atan2(M,x*y);g=Math.sin(g*T)/M,o=Math.sin(o*T)/M}const v=o*y;if(c=c*g+f*v,l=l*g+d*v,u=u*g+p*v,h=h*g+m*v,g===1-o){const M=1/Math.sqrt(c*c+l*l+u*u+h*h);c*=M,l*=M,u*=M,h*=M}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,s,r){const o=n[i],c=n[i+1],l=n[i+2],u=n[i+3],h=s[r],f=s[r+1],d=s[r+2],p=s[r+3];return e[t]=o*p+u*h+c*d-l*f,e[t+1]=c*p+u*f+l*h-o*d,e[t+2]=l*p+u*d+o*f-c*h,e[t+3]=u*p-o*h-c*f-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!(e&&e.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=e._x,i=e._y,s=e._z,r=e._order,o=Math.cos,c=Math.sin,l=o(n/2),u=o(i/2),h=o(s/2),f=c(n/2),d=c(i/2),p=c(s/2);switch(r){case"XYZ":this._x=f*u*h+l*d*p,this._y=l*d*h-f*u*p,this._z=l*u*p+f*d*h,this._w=l*u*h-f*d*p;break;case"YXZ":this._x=f*u*h+l*d*p,this._y=l*d*h-f*u*p,this._z=l*u*p-f*d*h,this._w=l*u*h+f*d*p;break;case"ZXY":this._x=f*u*h-l*d*p,this._y=l*d*h+f*u*p,this._z=l*u*p+f*d*h,this._w=l*u*h-f*d*p;break;case"ZYX":this._x=f*u*h-l*d*p,this._y=l*d*h+f*u*p,this._z=l*u*p-f*d*h,this._w=l*u*h+f*d*p;break;case"YZX":this._x=f*u*h+l*d*p,this._y=l*d*h+f*u*p,this._z=l*u*p-f*d*h,this._w=l*u*h-f*d*p;break;case"XZY":this._x=f*u*h-l*d*p,this._y=l*d*h-f*u*p,this._z=l*u*p+f*d*h,this._w=l*u*h+f*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],s=t[8],r=t[1],o=t[5],c=t[9],l=t[2],u=t[6],h=t[10],f=n+o+h;if(f>0){const d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(u-c)*d,this._y=(s-l)*d,this._z=(r-i)*d}else if(n>o&&n>h){const d=2*Math.sqrt(1+n-o-h);this._w=(u-c)/d,this._x=.25*d,this._y=(i+r)/d,this._z=(s+l)/d}else if(o>h){const d=2*Math.sqrt(1+o-n-h);this._w=(s-l)/d,this._x=(i+r)/d,this._y=.25*d,this._z=(c+u)/d}else{const d=2*Math.sqrt(1+h-n-o);this._w=(r-i)/d,this._x=(s+l)/d,this._y=(c+u)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(zt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,s=e._z,r=e._w,o=t._x,c=t._y,l=t._z,u=t._w;return this._x=n*u+r*o+i*l-s*c,this._y=i*u+r*c+s*o-n*l,this._z=s*u+r*l+n*c-i*o,this._w=r*u-n*o-i*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,r=this._w;let o=r*e._w+n*e._x+i*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=r,this._x=n,this._y=i,this._z=s,this;const c=1-o*o;if(c<=Number.EPSILON){const d=1-t;return this._w=d*r+t*this._w,this._x=d*n+t*this._x,this._y=d*i+t*this._y,this._z=d*s+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(c),u=Math.atan2(l,o),h=Math.sin((1-t)*u)/l,f=Math.sin(t*u)/l;return this._w=r*h+this._w*f,this._x=n*h+this._x*f,this._y=i*h+this._y*f,this._z=s*h+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(s),n*Math.cos(s),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class P{constructor(e=0,t=0,n=0){P.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(bh.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(bh.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=e.elements,r=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*r,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*r,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*r,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,s=e.x,r=e.y,o=e.z,c=e.w,l=c*t+r*i-o*n,u=c*n+o*t-s*i,h=c*i+s*n-r*t,f=-s*t-r*n-o*i;return this.x=l*c+f*-s+u*-o-h*-r,this.y=u*c+f*-r+h*-s-l*-o,this.z=h*c+f*-o+l*-r-u*-s,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,s=e.z,r=t.x,o=t.y,c=t.z;return this.x=i*c-s*o,this.y=s*r-n*c,this.z=n*o-i*r,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Vc.copy(this).projectOnVector(e),this.sub(Vc)}reflect(e){return this.sub(Vc.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(zt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Vc=new P,bh=new Ft;class Ei{constructor(e=new P(1/0,1/0,1/0),t=new P(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,n=1/0,i=1/0,s=-1/0,r=-1/0,o=-1/0;for(let c=0,l=e.length;cs&&(s=u),h>r&&(r=h),f>o&&(o=f)}return this.min.set(t,n,i),this.max.set(s,r,o),this}setFromBufferAttribute(e){let t=1/0,n=1/0,i=1/0,s=-1/0,r=-1/0,o=-1/0;for(let c=0,l=e.count;cs&&(s=u),h>r&&(r=h),f>o&&(o=f)}return this.min.set(t,n,i),this.max.set(s,r,o),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,ss),ss.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(eo),sa.subVectors(this.max,eo),js.subVectors(e.a,eo),Ys.subVectors(e.b,eo),Zs.subVectors(e.c,eo),Ri.subVectors(Ys,js),Ii.subVectors(Zs,Ys),rs.subVectors(js,Zs);let t=[0,-Ri.z,Ri.y,0,-Ii.z,Ii.y,0,-rs.z,rs.y,Ri.z,0,-Ri.x,Ii.z,0,-Ii.x,rs.z,0,-rs.x,-Ri.y,Ri.x,0,-Ii.y,Ii.x,0,-rs.y,rs.x,0];return!Wc(t,js,Ys,Zs,sa)||(t=[1,0,0,0,1,0,0,0,1],!Wc(t,js,Ys,Zs,sa))?!1:(ra.crossVectors(Ri,Ii),t=[ra.x,ra.y,ra.z],Wc(t,js,Ys,Zs,sa))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return ss.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(ss).length()*.5,e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(ci[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ci[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ci[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ci[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ci[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ci[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ci[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ci[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ci),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const ci=[new P,new P,new P,new P,new P,new P,new P,new P],ss=new P,Hc=new Ei,js=new P,Ys=new P,Zs=new P,Ri=new P,Ii=new P,rs=new P,eo=new P,sa=new P,ra=new P,os=new P;function Wc(a,e,t,n,i){for(let s=0,r=a.length-3;s<=r;s+=3){os.fromArray(a,s);const o=i.x*Math.abs(os.x)+i.y*Math.abs(os.y)+i.z*Math.abs(os.z),c=e.dot(os),l=t.dot(os),u=n.dot(os);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>o)return!1}return!0}const Jg=new Ei,wh=new P,oa=new P,qc=new P;class es{constructor(e=new P,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Jg.setFromPoints(e).getCenter(n);let i=0;for(let s=0,r=e.length;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){qc.subVectors(e,this.center);const t=qc.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.add(qc.multiplyScalar(i/n)),this.radius+=i}return this}union(e){return this.center.equals(e.center)===!0?oa.set(0,0,1).multiplyScalar(e.radius):oa.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(wh.copy(e.center).add(oa)),this.expandByPoint(wh.copy(e.center).sub(oa)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const li=new P,Xc=new P,aa=new P,Pi=new P,jc=new P,ca=new P,Yc=new P;class zo{constructor(e=new P,t=new P(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,li)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=li.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(li.copy(this.direction).multiplyScalar(t).add(this.origin),li.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Xc.copy(e).add(t).multiplyScalar(.5),aa.copy(t).sub(e).normalize(),Pi.copy(this.origin).sub(Xc);const s=e.distanceTo(t)*.5,r=-this.direction.dot(aa),o=Pi.dot(this.direction),c=-Pi.dot(aa),l=Pi.lengthSq(),u=Math.abs(1-r*r);let h,f,d,p;if(u>0)if(h=r*c-o,f=r*o-c,p=s*u,h>=0)if(f>=-p)if(f<=p){const m=1/u;h*=m,f*=m,d=h*(h+r*f+2*o)+f*(r*h+f+2*c)+l}else f=s,h=Math.max(0,-(r*f+o)),d=-h*h+f*(f+2*c)+l;else f=-s,h=Math.max(0,-(r*f+o)),d=-h*h+f*(f+2*c)+l;else f<=-p?(h=Math.max(0,-(-r*s+o)),f=h>0?-s:Math.min(Math.max(-s,-c),s),d=-h*h+f*(f+2*c)+l):f<=p?(h=0,f=Math.min(Math.max(-s,-c),s),d=f*(f+2*c)+l):(h=Math.max(0,-(r*s+o)),f=h>0?s:Math.min(Math.max(-s,-c),s),d=-h*h+f*(f+2*c)+l);else f=r>0?-s:s,h=Math.max(0,-(r*f+o)),d=-h*h+f*(f+2*c)+l;return n&&n.copy(this.direction).multiplyScalar(h).add(this.origin),i&&i.copy(aa).multiplyScalar(f).add(Xc),d}intersectSphere(e,t){li.subVectors(e.center,this.origin);const n=li.dot(this.direction),i=li.dot(li)-n*n,s=e.radius*e.radius;if(i>s)return null;const r=Math.sqrt(s-i),o=n-r,c=n+r;return o<0&&c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,r,o,c;const l=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,f=this.origin;return l>=0?(n=(e.min.x-f.x)*l,i=(e.max.x-f.x)*l):(n=(e.max.x-f.x)*l,i=(e.min.x-f.x)*l),u>=0?(s=(e.min.y-f.y)*u,r=(e.max.y-f.y)*u):(s=(e.max.y-f.y)*u,r=(e.min.y-f.y)*u),n>r||s>i||((s>n||n!==n)&&(n=s),(r=0?(o=(e.min.z-f.z)*h,c=(e.max.z-f.z)*h):(o=(e.max.z-f.z)*h,c=(e.min.z-f.z)*h),n>c||o>i)||((o>n||n!==n)&&(n=o),(c=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,li)!==null}intersectTriangle(e,t,n,i,s){jc.subVectors(t,e),ca.subVectors(n,e),Yc.crossVectors(jc,ca);let r=this.direction.dot(Yc),o;if(r>0){if(i)return null;o=1}else if(r<0)o=-1,r=-r;else return null;Pi.subVectors(this.origin,e);const c=o*this.direction.dot(ca.crossVectors(Pi,ca));if(c<0)return null;const l=o*this.direction.dot(jc.cross(Pi));if(l<0||c+l>r)return null;const u=-o*Pi.dot(Yc);return u<0?null:this.at(u/r,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class De{constructor(){De.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(e,t,n,i,s,r,o,c,l,u,h,f,d,p,m,g){const x=this.elements;return x[0]=e,x[4]=t,x[8]=n,x[12]=i,x[1]=s,x[5]=r,x[9]=o,x[13]=c,x[2]=l,x[6]=u,x[10]=h,x[14]=f,x[3]=d,x[7]=p,x[11]=m,x[15]=g,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 De().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/Ks.setFromMatrixColumn(e,0).length(),s=1/Ks.setFromMatrixColumn(e,1).length(),r=1/Ks.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*r,t[9]=n[9]*r,t[10]=n[10]*r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,s=e.z,r=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const f=r*u,d=r*h,p=o*u,m=o*h;t[0]=c*u,t[4]=-c*h,t[8]=l,t[1]=d+p*l,t[5]=f-m*l,t[9]=-o*c,t[2]=m-f*l,t[6]=p+d*l,t[10]=r*c}else if(e.order==="YXZ"){const f=c*u,d=c*h,p=l*u,m=l*h;t[0]=f+m*o,t[4]=p*o-d,t[8]=r*l,t[1]=r*h,t[5]=r*u,t[9]=-o,t[2]=d*o-p,t[6]=m+f*o,t[10]=r*c}else if(e.order==="ZXY"){const f=c*u,d=c*h,p=l*u,m=l*h;t[0]=f-m*o,t[4]=-r*h,t[8]=p+d*o,t[1]=d+p*o,t[5]=r*u,t[9]=m-f*o,t[2]=-r*l,t[6]=o,t[10]=r*c}else if(e.order==="ZYX"){const f=r*u,d=r*h,p=o*u,m=o*h;t[0]=c*u,t[4]=p*l-d,t[8]=f*l+m,t[1]=c*h,t[5]=m*l+f,t[9]=d*l-p,t[2]=-l,t[6]=o*c,t[10]=r*c}else if(e.order==="YZX"){const f=r*c,d=r*l,p=o*c,m=o*l;t[0]=c*u,t[4]=m-f*h,t[8]=p*h+d,t[1]=h,t[5]=r*u,t[9]=-o*u,t[2]=-l*u,t[6]=d*h+p,t[10]=f-m*h}else if(e.order==="XZY"){const f=r*c,d=r*l,p=o*c,m=o*l;t[0]=c*u,t[4]=-h,t[8]=l*u,t[1]=f*h+m,t[5]=r*u,t[9]=d*h-p,t[2]=p*h-d,t[6]=o*u,t[10]=m*h+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose($g,e,Qg)}lookAt(e,t,n){const i=this.elements;return bn.subVectors(e,t),bn.lengthSq()===0&&(bn.z=1),bn.normalize(),Di.crossVectors(n,bn),Di.lengthSq()===0&&(Math.abs(n.z)===1?bn.x+=1e-4:bn.z+=1e-4,bn.normalize(),Di.crossVectors(n,bn)),Di.normalize(),la.crossVectors(bn,Di),i[0]=Di.x,i[4]=la.x,i[8]=bn.x,i[1]=Di.y,i[5]=la.y,i[9]=bn.y,i[2]=Di.z,i[6]=la.z,i[10]=bn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,r=n[0],o=n[4],c=n[8],l=n[12],u=n[1],h=n[5],f=n[9],d=n[13],p=n[2],m=n[6],g=n[10],x=n[14],y=n[3],b=n[7],v=n[11],M=n[15],T=i[0],C=i[4],_=i[8],E=i[12],F=i[1],U=i[5],q=i[9],J=i[13],G=i[2],X=i[6],B=i[10],Z=i[14],Y=i[3],W=i[7],j=i[11],ne=i[15];return s[0]=r*T+o*F+c*G+l*Y,s[4]=r*C+o*U+c*X+l*W,s[8]=r*_+o*q+c*B+l*j,s[12]=r*E+o*J+c*Z+l*ne,s[1]=u*T+h*F+f*G+d*Y,s[5]=u*C+h*U+f*X+d*W,s[9]=u*_+h*q+f*B+d*j,s[13]=u*E+h*J+f*Z+d*ne,s[2]=p*T+m*F+g*G+x*Y,s[6]=p*C+m*U+g*X+x*W,s[10]=p*_+m*q+g*B+x*j,s[14]=p*E+m*J+g*Z+x*ne,s[3]=y*T+b*F+v*G+M*Y,s[7]=y*C+b*U+v*X+M*W,s[11]=y*_+b*q+v*B+M*j,s[15]=y*E+b*J+v*Z+M*ne,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],r=e[1],o=e[5],c=e[9],l=e[13],u=e[2],h=e[6],f=e[10],d=e[14],p=e[3],m=e[7],g=e[11],x=e[15];return p*(+s*c*h-i*l*h-s*o*f+n*l*f+i*o*d-n*c*d)+m*(+t*c*d-t*l*f+s*r*f-i*r*d+i*l*u-s*c*u)+g*(+t*l*h-t*o*d-s*r*h+n*r*d+s*o*u-n*l*u)+x*(-i*o*u-t*c*h+t*o*f+i*r*h-n*r*f+n*c*u)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],o=e[5],c=e[6],l=e[7],u=e[8],h=e[9],f=e[10],d=e[11],p=e[12],m=e[13],g=e[14],x=e[15],y=h*g*l-m*f*l+m*c*d-o*g*d-h*c*x+o*f*x,b=p*f*l-u*g*l-p*c*d+r*g*d+u*c*x-r*f*x,v=u*m*l-p*h*l+p*o*d-r*m*d-u*o*x+r*h*x,M=p*h*c-u*m*c-p*o*f+r*m*f+u*o*g-r*h*g,T=t*y+n*b+i*v+s*M;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/T;return e[0]=y*C,e[1]=(m*f*s-h*g*s-m*i*d+n*g*d+h*i*x-n*f*x)*C,e[2]=(o*g*s-m*c*s+m*i*l-n*g*l-o*i*x+n*c*x)*C,e[3]=(h*c*s-o*f*s-h*i*l+n*f*l+o*i*d-n*c*d)*C,e[4]=b*C,e[5]=(u*g*s-p*f*s+p*i*d-t*g*d-u*i*x+t*f*x)*C,e[6]=(p*c*s-r*g*s-p*i*l+t*g*l+r*i*x-t*c*x)*C,e[7]=(r*f*s-u*c*s+u*i*l-t*f*l-r*i*d+t*c*d)*C,e[8]=v*C,e[9]=(p*h*s-u*m*s-p*n*d+t*m*d+u*n*x-t*h*x)*C,e[10]=(r*m*s-p*o*s+p*n*l-t*m*l-r*n*x+t*o*x)*C,e[11]=(u*o*s-r*h*s-u*n*l+t*h*l+r*n*d-t*o*d)*C,e[12]=M*C,e[13]=(u*m*i-p*h*i+p*n*f-t*m*f-u*n*g+t*h*g)*C,e[14]=(p*o*i-r*m*i-p*n*c+t*m*c+r*n*g-t*o*g)*C,e[15]=(r*h*i-u*o*i+u*n*c-t*h*c-r*n*f+t*o*f)*C,this}scale(e){const t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),s=1-n,r=e.x,o=e.y,c=e.z,l=s*r,u=s*o;return this.set(l*r+n,l*o-i*c,l*c+i*o,0,l*o+i*c,u*o+n,u*c-i*r,0,l*c-i*o,u*c+i*r,s*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,r){return this.set(1,n,s,0,e,1,r,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,s=t._x,r=t._y,o=t._z,c=t._w,l=s+s,u=r+r,h=o+o,f=s*l,d=s*u,p=s*h,m=r*u,g=r*h,x=o*h,y=c*l,b=c*u,v=c*h,M=n.x,T=n.y,C=n.z;return i[0]=(1-(m+x))*M,i[1]=(d+v)*M,i[2]=(p-b)*M,i[3]=0,i[4]=(d-v)*T,i[5]=(1-(f+x))*T,i[6]=(g+y)*T,i[7]=0,i[8]=(p+b)*C,i[9]=(g-y)*C,i[10]=(1-(f+m))*C,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=Ks.set(i[0],i[1],i[2]).length();const r=Ks.set(i[4],i[5],i[6]).length(),o=Ks.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Gn.copy(this);const l=1/s,u=1/r,h=1/o;return Gn.elements[0]*=l,Gn.elements[1]*=l,Gn.elements[2]*=l,Gn.elements[4]*=u,Gn.elements[5]*=u,Gn.elements[6]*=u,Gn.elements[8]*=h,Gn.elements[9]*=h,Gn.elements[10]*=h,t.setFromRotationMatrix(Gn),n.x=s,n.y=r,n.z=o,this}makePerspective(e,t,n,i,s,r){const o=this.elements,c=2*s/(t-e),l=2*s/(n-i),u=(t+e)/(t-e),h=(n+i)/(n-i),f=-(r+s)/(r-s),d=-2*r*s/(r-s);return o[0]=c,o[4]=0,o[8]=u,o[12]=0,o[1]=0,o[5]=l,o[9]=h,o[13]=0,o[2]=0,o[6]=0,o[10]=f,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,i,s,r){const o=this.elements,c=1/(t-e),l=1/(n-i),u=1/(r-s),h=(t+e)*c,f=(n+i)*l,d=(r+s)*u;return o[0]=2*c,o[4]=0,o[8]=0,o[12]=-h,o[1]=0,o[5]=2*l,o[9]=0,o[13]=-f,o[2]=0,o[6]=0,o[10]=-2*u,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Ks=new P,Gn=new De,$g=new P(0,0,0),Qg=new P(1,1,1),Di=new P,la=new P,bn=new P,Mh=new De,Sh=new Ft;class Pn{constructor(e=0,t=0,n=0,i=Pn.DefaultOrder){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,s=i[0],r=i[4],o=i[8],c=i[1],l=i[5],u=i[9],h=i[2],f=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(zt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-r,s)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-zt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(zt(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-r,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-zt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-r,l));break;case"YZX":this._z=Math.asin(zt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-zt(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Mh.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Mh,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Sh.setFromEuler(this),this.setFromQuaternion(Sh,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}toVector3(){console.error("THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead")}}Pn.DefaultOrder="XYZ";Pn.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class vc{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0){i.children=[];for(let o=0;o0){i.animations=[];for(let o=0;o0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),f.length>0&&(n.skeletons=f),d.length>0&&(n.animations=d),p.length>0&&(n.nodes=p)}return n.object=i,n;function r(o){const c=[];for(const l in o){const u=o[l];delete u.metadata,c.push(u)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){Vn.subVectors(i,t),hi.subVectors(n,t),Zc.subVectors(e,t);const r=Vn.dot(Vn),o=Vn.dot(hi),c=Vn.dot(Zc),l=hi.dot(hi),u=hi.dot(Zc),h=r*l-o*o;if(h===0)return s.set(-2,-1,-1);const f=1/h,d=(l*c-o*u)*f,p=(r*u-o*c)*f;return s.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,fi),fi.x>=0&&fi.y>=0&&fi.x+fi.y<=1}static getUV(e,t,n,i,s,r,o,c){return this.getBarycoord(e,t,n,i,fi),c.set(0,0),c.addScaledVector(s,fi.x),c.addScaledVector(r,fi.y),c.addScaledVector(o,fi.z),c}static isFrontFacing(e,t,n,i){return Vn.subVectors(n,t),hi.subVectors(e,t),Vn.cross(hi).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Vn.subVectors(this.c,this.b),hi.subVectors(this.a,this.b),Vn.cross(hi).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return In.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return In.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,s){return In.getUV(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return In.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return In.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,s=this.c;let r,o;$s.subVectors(i,n),Qs.subVectors(s,n),Kc.subVectors(e,n);const c=$s.dot(Kc),l=Qs.dot(Kc);if(c<=0&&l<=0)return t.copy(n);Jc.subVectors(e,i);const u=$s.dot(Jc),h=Qs.dot(Jc);if(u>=0&&h<=u)return t.copy(i);const f=c*h-u*l;if(f<=0&&c>=0&&u<=0)return r=c/(c-u),t.copy(n).addScaledVector($s,r);$c.subVectors(e,s);const d=$s.dot($c),p=Qs.dot($c);if(p>=0&&d<=p)return t.copy(s);const m=d*l-c*p;if(m<=0&&l>=0&&p<=0)return o=l/(l-p),t.copy(n).addScaledVector(Qs,o);const g=u*p-d*h;if(g<=0&&h-u>=0&&d-p>=0)return Rh.subVectors(s,i),o=(h-u)/(h-u+(d-p)),t.copy(i).addScaledVector(Rh,o);const x=1/(g+m+f);return r=m*x,o=f*x,t.copy(n).addScaledVector($s,r).addScaledVector(Qs,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let s0=0;class Gt extends ri{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:s0++}),this.uuid=Sn(),this.name="",this.type="Material",this.blending=ws,this.side=vi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=wu,this.blendDst=Mu,this.blendEquation=gs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=nc,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=cp,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Za,this.stencilZFail=Za,this.stencilZPass=Za,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if(t==="shading"){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=n===pd;continue}const i=this[t];if(i===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==ws&&(n.blending=this.blending),this.side!==vi&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=this.flatShading),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData);function i(s){const r=[];for(const o in s){const c=s[o];delete c.metadata,r.push(c)}return r}if(t){const s=i(e.textures),r=i(e.images);s.length>0&&(n.textures=s),r.length>0&&(n.images=r)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class un extends Gt{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new be(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Oo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Xt=new P,ha=new de;class pt{constructor(e,t,n){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n===!0,this.usage=So,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,s=this.itemSize;i0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const i={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],u=[];for(let h=0,f=l.length;h0&&(i[c]=u,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(e.data.groups=JSON.parse(JSON.stringify(r)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const i=e.attributes;for(const l in i){const u=i[l];this.setAttribute(l,u.clone(t))}const s=e.morphAttributes;for(const l in s){const u=[],h=s[l];for(let f=0,d=h.length;f0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;st.far?null:{distance:l,point:xa.clone(),object:a}}function va(a,e,t,n,i,s,r,o,c,l,u,h){Fi.fromBufferAttribute(i,l),Ni.fromBufferAttribute(i,u),ki.fromBufferAttribute(i,h);const f=a.morphTargetInfluences;if(s&&f){fa.set(0,0,0),da.set(0,0,0),pa.set(0,0,0);for(let p=0,m=s.length;p0?1:-1,u.push(W.x,W.y,W.z),h.push($/C),h.push(1-j/_),Z+=1}}for(let j=0;j<_;j++)for(let ne=0;ne0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class _c extends lt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new De,this.projectionMatrix=new De,this.projectionMatrixInverse=new De}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class Dt extends _c{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=To*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ss*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return To*2*Math.atan(Math.tan(Ss*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,s,r){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Ss*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-.5*i;const r=this.view;if(this.view!==null&&this.view.enabled){const c=r.fullWidth,l=r.fullHeight;s+=r.offsetX*i/c,t-=r.offsetY*n/l,i*=r.width/c,n*=r.height/l}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,t,t-n,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const nr=90,ir=1;class fp extends lt{constructor(e,t,n){if(super(),this.type="CubeCamera",n.isWebGLCubeRenderTarget!==!0){console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");return}this.renderTarget=n;const i=new Dt(nr,ir,e,t);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new D(1,0,0)),this.add(i);const s=new Dt(nr,ir,e,t);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new D(-1,0,0)),this.add(s);const r=new Dt(nr,ir,e,t);r.layers=this.layers,r.up.set(0,0,1),r.lookAt(new D(0,1,0)),this.add(r);const o=new Dt(nr,ir,e,t);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new D(0,-1,0)),this.add(o);const c=new Dt(nr,ir,e,t);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new D(0,0,1)),this.add(c);const l=new Dt(nr,ir,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new D(0,0,-1)),this.add(l)}update(e,t){this.parent===null&&this.updateMatrixWorld();const n=this.renderTarget,[i,s,r,o,c,l]=this.children,u=e.getRenderTarget(),h=e.toneMapping,f=e.xr.enabled;e.toneMapping=Jn,e.xr.enabled=!1;const d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,s),e.setRenderTarget(n,2),e.render(t,r),e.setRenderTarget(n,3),e.render(t,o),e.setRenderTarget(n,4),e.render(t,c),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(u),e.toneMapping=h,e.xr.enabled=f,n.texture.needsPMREMUpdate=!0}}class Uo extends At{constructor(e,t,n,i,s,r,o,c,l,u){e=e!==void 0?e:[],t=t!==void 0?t:Xi,super(e,t,n,i,s,r,o,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class dp extends kn{constructor(e,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new Uo(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Rt}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` +}`;class ei extends Gt{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=m0,this.fragmentShader=g0,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&(e.attributes!==void 0&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Mr(e.uniforms),this.uniformsGroups=p0(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const r=this.uniforms[i].value;r&&r.isTexture?t.uniforms[i]={type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[i]={type:"c",value:r.getHex()}:r&&r.isVector2?t.uniforms[i]={type:"v2",value:r.toArray()}:r&&r.isVector3?t.uniforms[i]={type:"v3",value:r.toArray()}:r&&r.isVector4?t.uniforms[i]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?t.uniforms[i]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?t.uniforms[i]={type:"m4",value:r.toArray()}:t.uniforms[i]={value:r}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class bc extends ut{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new De,this.projectionMatrix=new De,this.projectionMatrixInverse=new De}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class Dt extends bc{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=To*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ss*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return To*2*Math.atan(Math.tan(Ss*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,s,r){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Ss*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-.5*i;const r=this.view;if(this.view!==null&&this.view.enabled){const c=r.fullWidth,l=r.fullHeight;s+=r.offsetX*i/c,t-=r.offsetY*n/l,i*=r.width/c,n*=r.height/l}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,t,t-n,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const nr=90,ir=1;class dp extends ut{constructor(e,t,n){if(super(),this.type="CubeCamera",n.isWebGLCubeRenderTarget!==!0){console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");return}this.renderTarget=n;const i=new Dt(nr,ir,e,t);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new P(1,0,0)),this.add(i);const s=new Dt(nr,ir,e,t);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new P(-1,0,0)),this.add(s);const r=new Dt(nr,ir,e,t);r.layers=this.layers,r.up.set(0,0,1),r.lookAt(new P(0,1,0)),this.add(r);const o=new Dt(nr,ir,e,t);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new P(0,-1,0)),this.add(o);const c=new Dt(nr,ir,e,t);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new P(0,0,1)),this.add(c);const l=new Dt(nr,ir,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new P(0,0,-1)),this.add(l)}update(e,t){this.parent===null&&this.updateMatrixWorld();const n=this.renderTarget,[i,s,r,o,c,l]=this.children,u=e.getRenderTarget(),h=e.toneMapping,f=e.xr.enabled;e.toneMapping=Jn,e.xr.enabled=!1;const d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,s),e.setRenderTarget(n,2),e.render(t,r),e.setRenderTarget(n,3),e.render(t,o),e.setRenderTarget(n,4),e.render(t,c),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(u),e.toneMapping=h,e.xr.enabled=f,n.texture.needsPMREMUpdate=!0}}class Uo extends At{constructor(e,t,n,i,s,r,o,c,l,u){e=e!==void 0?e:[],t=t!==void 0?t:Xi,super(e,t,n,i,s,r,o,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class pp extends kn{constructor(e,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new Uo(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Rt}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; @@ -41,7 +41,7 @@ gl_FragColor = texture2D( tEquirect, sampleUV ); } - `},i=new wi(5,5,5),s=new ei({name:"CubemapFromEquirect",uniforms:Mr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Dn,blending:xi});s.uniforms.tEquirect.value=t;const r=new Tt(i,s),o=t.minFilter;return t.minFilter===si&&(t.minFilter=Rt),new fp(1,10,this).update(e,r),t.minFilter=o,r.geometry.dispose(),r.material.dispose(),this}clear(e,t,n,i){const s=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(s)}}const sl=new D,y0=new D,x0=new ln;class Ui{constructor(e=new D(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=sl.subVectors(n,t).cross(y0.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){const n=e.delta(sl),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(n).multiplyScalar(s).add(e.start)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||x0.getNormalMatrix(e),i=this.coplanarPoint(sl).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const sr=new es,_a=new D;class bc{constructor(e=new Ui,t=new Ui,n=new Ui,i=new Ui,s=new Ui,r=new Ui){this.planes=[e,t,n,i,s,r]}set(e,t,n,i,s,r){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(s),o[5].copy(r),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){const t=this.planes,n=e.elements,i=n[0],s=n[1],r=n[2],o=n[3],c=n[4],l=n[5],u=n[6],h=n[7],f=n[8],d=n[9],p=n[10],m=n[11],g=n[12],x=n[13],y=n[14],b=n[15];return t[0].setComponents(o-i,h-c,m-f,b-g).normalize(),t[1].setComponents(o+i,h+c,m+f,b+g).normalize(),t[2].setComponents(o+s,h+l,m+d,b+x).normalize(),t[3].setComponents(o-s,h-l,m-d,b-x).normalize(),t[4].setComponents(o-r,h-u,m-p,b-y).normalize(),t[5].setComponents(o+r,h+u,m+p,b+y).normalize(),this}intersectsObject(e){const t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),sr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(sr)}intersectsSprite(e){return sr.center.set(0,0,0),sr.radius=.7071067811865476,sr.applyMatrix4(e.matrixWorld),this.intersectsSphere(sr)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)0?e.max.x:e.min.x,_a.y=i.normal.y>0?e.max.y:e.min.y,_a.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(_a)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function pp(){let a=null,e=!1,t=null,n=null;function i(s,r){t(s,r),n=a.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=a.requestAnimationFrame(i),e=!0)},stop:function(){a.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){a=s}}}function v0(a,e){const t=e.isWebGL2,n=new WeakMap;function i(l,u){const h=l.array,f=l.usage,d=a.createBuffer();a.bindBuffer(u,d),a.bufferData(u,h,f),l.onUploadCallback();let p;if(h instanceof Float32Array)p=5126;else if(h instanceof Uint16Array)if(l.isFloat16BufferAttribute)if(t)p=5131;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else p=5123;else if(h instanceof Int16Array)p=5122;else if(h instanceof Uint32Array)p=5125;else if(h instanceof Int32Array)p=5124;else if(h instanceof Int8Array)p=5120;else if(h instanceof Uint8Array)p=5121;else if(h instanceof Uint8ClampedArray)p=5121;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:d,type:p,bytesPerElement:h.BYTES_PER_ELEMENT,version:l.version}}function s(l,u,h){const f=u.array,d=u.updateRange;a.bindBuffer(h,l),d.count===-1?a.bufferSubData(h,0,f):(t?a.bufferSubData(h,d.offset*f.BYTES_PER_ELEMENT,f,d.offset,d.count):a.bufferSubData(h,d.offset*f.BYTES_PER_ELEMENT,f.subarray(d.offset,d.offset+d.count)),d.count=-1)}function r(l){return l.isInterleavedBufferAttribute&&(l=l.data),n.get(l)}function o(l){l.isInterleavedBufferAttribute&&(l=l.data);const u=n.get(l);u&&(a.deleteBuffer(u.buffer),n.delete(l))}function c(l,u){if(l.isGLBufferAttribute){const f=n.get(l);(!f||f.version1?null:t.copy(n).multiplyScalar(s).add(e.start)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||x0.getNormalMatrix(e),i=this.coplanarPoint(rl).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const sr=new es,_a=new P;class wc{constructor(e=new Ui,t=new Ui,n=new Ui,i=new Ui,s=new Ui,r=new Ui){this.planes=[e,t,n,i,s,r]}set(e,t,n,i,s,r){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(s),o[5].copy(r),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){const t=this.planes,n=e.elements,i=n[0],s=n[1],r=n[2],o=n[3],c=n[4],l=n[5],u=n[6],h=n[7],f=n[8],d=n[9],p=n[10],m=n[11],g=n[12],x=n[13],y=n[14],b=n[15];return t[0].setComponents(o-i,h-c,m-f,b-g).normalize(),t[1].setComponents(o+i,h+c,m+f,b+g).normalize(),t[2].setComponents(o+s,h+l,m+d,b+x).normalize(),t[3].setComponents(o-s,h-l,m-d,b-x).normalize(),t[4].setComponents(o-r,h-u,m-p,b-y).normalize(),t[5].setComponents(o+r,h+u,m+p,b+y).normalize(),this}intersectsObject(e){const t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),sr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(sr)}intersectsSprite(e){return sr.center.set(0,0,0),sr.radius=.7071067811865476,sr.applyMatrix4(e.matrixWorld),this.intersectsSphere(sr)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)0?e.max.x:e.min.x,_a.y=i.normal.y>0?e.max.y:e.min.y,_a.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(_a)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function mp(){let a=null,e=!1,t=null,n=null;function i(s,r){t(s,r),n=a.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=a.requestAnimationFrame(i),e=!0)},stop:function(){a.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){a=s}}}function v0(a,e){const t=e.isWebGL2,n=new WeakMap;function i(l,u){const h=l.array,f=l.usage,d=a.createBuffer();a.bindBuffer(u,d),a.bufferData(u,h,f),l.onUploadCallback();let p;if(h instanceof Float32Array)p=5126;else if(h instanceof Uint16Array)if(l.isFloat16BufferAttribute)if(t)p=5131;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else p=5123;else if(h instanceof Int16Array)p=5122;else if(h instanceof Uint32Array)p=5125;else if(h instanceof Int32Array)p=5124;else if(h instanceof Int8Array)p=5120;else if(h instanceof Uint8Array)p=5121;else if(h instanceof Uint8ClampedArray)p=5121;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:d,type:p,bytesPerElement:h.BYTES_PER_ELEMENT,version:l.version}}function s(l,u,h){const f=u.array,d=u.updateRange;a.bindBuffer(h,l),d.count===-1?a.bufferSubData(h,0,f):(t?a.bufferSubData(h,d.offset*f.BYTES_PER_ELEMENT,f,d.offset,d.count):a.bufferSubData(h,d.offset*f.BYTES_PER_ELEMENT,f.subarray(d.offset,d.offset+d.count)),d.count=-1)}function r(l){return l.isInterleavedBufferAttribute&&(l=l.data),n.get(l)}function o(l){l.isInterleavedBufferAttribute&&(l=l.data);const u=n.get(l);u&&(a.deleteBuffer(u.buffer),n.delete(l))}function c(l,u){if(l.isGLBufferAttribute){const f=n.get(l);(!f||f.version #include #include -}`,nt={alphamap_fragment:_0,alphamap_pars_fragment:b0,alphatest_fragment:w0,alphatest_pars_fragment:M0,aomap_fragment:S0,aomap_pars_fragment:T0,begin_vertex:A0,beginnormal_vertex:E0,bsdfs:C0,iridescence_fragment:L0,bumpmap_pars_fragment:R0,clipping_planes_fragment:I0,clipping_planes_pars_fragment:P0,clipping_planes_pars_vertex:D0,clipping_planes_vertex:F0,color_fragment:N0,color_pars_fragment:k0,color_pars_vertex:O0,color_vertex:B0,common:z0,cube_uv_reflection_fragment:U0,defaultnormal_vertex:G0,displacementmap_pars_vertex:V0,displacementmap_vertex:H0,emissivemap_fragment:W0,emissivemap_pars_fragment:q0,encodings_fragment:X0,encodings_pars_fragment:j0,envmap_fragment:Y0,envmap_common_pars_fragment:Z0,envmap_pars_fragment:K0,envmap_pars_vertex:J0,envmap_physical_pars_fragment:cy,envmap_vertex:$0,fog_vertex:Q0,fog_pars_vertex:ey,fog_fragment:ty,fog_pars_fragment:ny,gradientmap_pars_fragment:iy,lightmap_fragment:sy,lightmap_pars_fragment:ry,lights_lambert_vertex:oy,lights_pars_begin:ay,lights_toon_fragment:ly,lights_toon_pars_fragment:uy,lights_phong_fragment:hy,lights_phong_pars_fragment:fy,lights_physical_fragment:dy,lights_physical_pars_fragment:py,lights_fragment_begin:my,lights_fragment_maps:gy,lights_fragment_end:yy,logdepthbuf_fragment:xy,logdepthbuf_pars_fragment:vy,logdepthbuf_pars_vertex:_y,logdepthbuf_vertex:by,map_fragment:wy,map_pars_fragment:My,map_particle_fragment:Sy,map_particle_pars_fragment:Ty,metalnessmap_fragment:Ay,metalnessmap_pars_fragment:Ey,morphcolor_vertex:Cy,morphnormal_vertex:Ly,morphtarget_pars_vertex:Ry,morphtarget_vertex:Iy,normal_fragment_begin:Py,normal_fragment_maps:Dy,normal_pars_fragment:Fy,normal_pars_vertex:Ny,normal_vertex:ky,normalmap_pars_fragment:Oy,clearcoat_normal_fragment_begin:By,clearcoat_normal_fragment_maps:zy,clearcoat_pars_fragment:Uy,iridescence_pars_fragment:Gy,output_fragment:Vy,packing:Hy,premultiplied_alpha_fragment:Wy,project_vertex:qy,dithering_fragment:Xy,dithering_pars_fragment:jy,roughnessmap_fragment:Yy,roughnessmap_pars_fragment:Zy,shadowmap_pars_fragment:Ky,shadowmap_pars_vertex:Jy,shadowmap_vertex:$y,shadowmask_pars_fragment:Qy,skinbase_vertex:ex,skinning_pars_vertex:tx,skinning_vertex:nx,skinnormal_vertex:ix,specularmap_fragment:sx,specularmap_pars_fragment:rx,tonemapping_fragment:ox,tonemapping_pars_fragment:ax,transmission_fragment:cx,transmission_pars_fragment:lx,uv_pars_fragment:ux,uv_pars_vertex:hx,uv_vertex:fx,uv2_pars_fragment:dx,uv2_pars_vertex:px,uv2_vertex:mx,worldpos_vertex:gx,background_vert:yx,background_frag:xx,cube_vert:vx,cube_frag:_x,depth_vert:bx,depth_frag:wx,distanceRGBA_vert:Mx,distanceRGBA_frag:Sx,equirect_vert:Tx,equirect_frag:Ax,linedashed_vert:Ex,linedashed_frag:Cx,meshbasic_vert:Lx,meshbasic_frag:Rx,meshlambert_vert:Ix,meshlambert_frag:Px,meshmatcap_vert:Dx,meshmatcap_frag:Fx,meshnormal_vert:Nx,meshnormal_frag:kx,meshphong_vert:Ox,meshphong_frag:Bx,meshphysical_vert:zx,meshphysical_frag:Ux,meshtoon_vert:Gx,meshtoon_frag:Vx,points_vert:Hx,points_frag:Wx,shadow_vert:qx,shadow_frag:Xx,sprite_vert:jx,sprite_frag:Yx},Re={common:{diffuse:{value:new ve(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new ln},uv2Transform:{value:new ln},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new fe(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ve(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new ve(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new ln}},sprite:{diffuse:{value:new ve(16777215)},opacity:{value:1},center:{value:new fe(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new ln}}},Hn={basic:{uniforms:rn([Re.common,Re.specularmap,Re.envmap,Re.aomap,Re.lightmap,Re.fog]),vertexShader:nt.meshbasic_vert,fragmentShader:nt.meshbasic_frag},lambert:{uniforms:rn([Re.common,Re.specularmap,Re.envmap,Re.aomap,Re.lightmap,Re.emissivemap,Re.fog,Re.lights,{emissive:{value:new ve(0)}}]),vertexShader:nt.meshlambert_vert,fragmentShader:nt.meshlambert_frag},phong:{uniforms:rn([Re.common,Re.specularmap,Re.envmap,Re.aomap,Re.lightmap,Re.emissivemap,Re.bumpmap,Re.normalmap,Re.displacementmap,Re.fog,Re.lights,{emissive:{value:new ve(0)},specular:{value:new ve(1118481)},shininess:{value:30}}]),vertexShader:nt.meshphong_vert,fragmentShader:nt.meshphong_frag},standard:{uniforms:rn([Re.common,Re.envmap,Re.aomap,Re.lightmap,Re.emissivemap,Re.bumpmap,Re.normalmap,Re.displacementmap,Re.roughnessmap,Re.metalnessmap,Re.fog,Re.lights,{emissive:{value:new ve(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:nt.meshphysical_vert,fragmentShader:nt.meshphysical_frag},toon:{uniforms:rn([Re.common,Re.aomap,Re.lightmap,Re.emissivemap,Re.bumpmap,Re.normalmap,Re.displacementmap,Re.gradientmap,Re.fog,Re.lights,{emissive:{value:new ve(0)}}]),vertexShader:nt.meshtoon_vert,fragmentShader:nt.meshtoon_frag},matcap:{uniforms:rn([Re.common,Re.bumpmap,Re.normalmap,Re.displacementmap,Re.fog,{matcap:{value:null}}]),vertexShader:nt.meshmatcap_vert,fragmentShader:nt.meshmatcap_frag},points:{uniforms:rn([Re.points,Re.fog]),vertexShader:nt.points_vert,fragmentShader:nt.points_frag},dashed:{uniforms:rn([Re.common,Re.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:nt.linedashed_vert,fragmentShader:nt.linedashed_frag},depth:{uniforms:rn([Re.common,Re.displacementmap]),vertexShader:nt.depth_vert,fragmentShader:nt.depth_frag},normal:{uniforms:rn([Re.common,Re.bumpmap,Re.normalmap,Re.displacementmap,{opacity:{value:1}}]),vertexShader:nt.meshnormal_vert,fragmentShader:nt.meshnormal_frag},sprite:{uniforms:rn([Re.sprite,Re.fog]),vertexShader:nt.sprite_vert,fragmentShader:nt.sprite_frag},background:{uniforms:{uvTransform:{value:new ln},t2D:{value:null}},vertexShader:nt.background_vert,fragmentShader:nt.background_frag},cube:{uniforms:rn([Re.envmap,{opacity:{value:1}}]),vertexShader:nt.cube_vert,fragmentShader:nt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:nt.equirect_vert,fragmentShader:nt.equirect_frag},distanceRGBA:{uniforms:rn([Re.common,Re.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:nt.distanceRGBA_vert,fragmentShader:nt.distanceRGBA_frag},shadow:{uniforms:rn([Re.lights,Re.fog,{color:{value:new ve(0)},opacity:{value:1}}]),vertexShader:nt.shadow_vert,fragmentShader:nt.shadow_frag}};Hn.physical={uniforms:rn([Hn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new fe(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new ve(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new fe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new ve(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new ve(1,1,1)},specularColorMap:{value:null}}]),vertexShader:nt.meshphysical_vert,fragmentShader:nt.meshphysical_frag};function Zx(a,e,t,n,i,s){const r=new ve(0);let o=i===!0?0:1,c,l,u=null,h=0,f=null;function d(m,g){let x=!1,y=g.isScene===!0?g.background:null;y&&y.isTexture&&(y=e.get(y));const b=a.xr,v=b.getSession&&b.getSession();v&&v.environmentBlendMode==="additive"&&(y=null),y===null?p(r,o):y&&y.isColor&&(p(y,1),x=!0),(a.autoClear||x)&&a.clear(a.autoClearColor,a.autoClearDepth,a.autoClearStencil),y&&(y.isCubeTexture||y.mapping===zr)?(l===void 0&&(l=new Tt(new wi(1,1,1),new ei({name:"BackgroundCubeMaterial",uniforms:Mr(Hn.cube.uniforms),vertexShader:Hn.cube.vertexShader,fragmentShader:Hn.cube.fragmentShader,side:Dn,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(S,A,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=y,l.material.uniforms.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,(u!==y||h!==y.version||f!==a.toneMapping)&&(l.material.needsUpdate=!0,u=y,h=y.version,f=a.toneMapping),l.layers.enableAll(),m.unshift(l,l.geometry,l.material,0,0,null)):y&&y.isTexture&&(c===void 0&&(c=new Tt(new Ls(2,2),new ei({name:"BackgroundMaterial",uniforms:Mr(Hn.background.uniforms),vertexShader:Hn.background.vertexShader,fragmentShader:Hn.background.fragmentShader,side:vi,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=y,y.matrixAutoUpdate===!0&&y.updateMatrix(),c.material.uniforms.uvTransform.value.copy(y.matrix),(u!==y||h!==y.version||f!==a.toneMapping)&&(c.material.needsUpdate=!0,u=y,h=y.version,f=a.toneMapping),c.layers.enableAll(),m.unshift(c,c.geometry,c.material,0,0,null))}function p(m,g){t.buffers.color.setClear(m.r,m.g,m.b,g,s)}return{getClearColor:function(){return r},setClearColor:function(m,g=1){r.set(m),o=g,p(r,o)},getClearAlpha:function(){return o},setClearAlpha:function(m){o=m,p(r,o)},render:d}}function Kx(a,e,t,n){const i=a.getParameter(34921),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),r=n.isWebGL2||s!==null,o={},c=g(null);let l=c,u=!1;function h(z,q,O,Y,j){let H=!1;if(r){const X=m(Y,O,q);l!==X&&(l=X,d(l.object)),H=x(z,Y,O,j),H&&y(z,Y,O,j)}else{const X=q.wireframe===!0;(l.geometry!==Y.id||l.program!==O.id||l.wireframe!==X)&&(l.geometry=Y.id,l.program=O.id,l.wireframe=X,H=!0)}j!==null&&t.update(j,34963),(H||u)&&(u=!1,_(z,q,O,Y),j!==null&&a.bindBuffer(34963,t.get(j).buffer))}function f(){return n.isWebGL2?a.createVertexArray():s.createVertexArrayOES()}function d(z){return n.isWebGL2?a.bindVertexArray(z):s.bindVertexArrayOES(z)}function p(z){return n.isWebGL2?a.deleteVertexArray(z):s.deleteVertexArrayOES(z)}function m(z,q,O){const Y=O.wireframe===!0;let j=o[z.id];j===void 0&&(j={},o[z.id]=j);let H=j[q.id];H===void 0&&(H={},j[q.id]=H);let X=H[Y];return X===void 0&&(X=g(f()),H[Y]=X),X}function g(z){const q=[],O=[],Y=[];for(let j=0;j=0){const re=j[J];let se=H[J];if(se===void 0&&(J==="instanceMatrix"&&z.instanceMatrix&&(se=z.instanceMatrix),J==="instanceColor"&&z.instanceColor&&(se=z.instanceColor)),re===void 0||re.attribute!==se||se&&re.data!==se.data)return!0;X++}return l.attributesNum!==X||l.index!==Y}function y(z,q,O,Y){const j={},H=q.attributes;let X=0;const te=O.getAttributes();for(const J in te)if(te[J].location>=0){let re=H[J];re===void 0&&(J==="instanceMatrix"&&z.instanceMatrix&&(re=z.instanceMatrix),J==="instanceColor"&&z.instanceColor&&(re=z.instanceColor));const se={};se.attribute=re,re&&re.data&&(se.data=re.data),j[J]=se,X++}l.attributes=j,l.attributesNum=X,l.index=Y}function b(){const z=l.newAttributes;for(let q=0,O=z.length;q=0){let ne=j[te];if(ne===void 0&&(te==="instanceMatrix"&&z.instanceMatrix&&(ne=z.instanceMatrix),te==="instanceColor"&&z.instanceColor&&(ne=z.instanceColor)),ne!==void 0){const re=ne.normalized,se=ne.itemSize,V=t.get(ne);if(V===void 0)continue;const me=V.buffer,_e=V.type,Ie=V.bytesPerElement;if(ne.isInterleavedBufferAttribute){const ye=ne.data,He=ye.stride,le=ne.offset;if(ye.isInstancedInterleavedBuffer){for(let ce=0;ce0&&a.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";R="mediump"}return R==="mediump"&&a.getShaderPrecisionFormat(35633,36337).precision>0&&a.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const r=typeof WebGL2RenderingContext!="undefined"&&a instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext!="undefined"&&a instanceof WebGL2ComputeRenderingContext;let o=t.precision!==void 0?t.precision:"highp";const c=s(o);c!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",c,"instead."),o=c);const l=r||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,h=a.getParameter(34930),f=a.getParameter(35660),d=a.getParameter(3379),p=a.getParameter(34076),m=a.getParameter(34921),g=a.getParameter(36347),x=a.getParameter(36348),y=a.getParameter(36349),b=f>0,v=r||e.has("OES_texture_float"),S=b&&v,A=r?a.getParameter(36183):0;return{isWebGL2:r,drawBuffers:l,getMaxAnisotropy:i,getMaxPrecision:s,precision:o,logarithmicDepthBuffer:u,maxTextures:h,maxVertexTextures:f,maxTextureSize:d,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:g,maxVaryings:x,maxFragmentUniforms:y,vertexTextures:b,floatFragmentTextures:v,floatVertexTextures:S,maxSamples:A}}function Qx(a){const e=this;let t=null,n=0,i=!1,s=!1;const r=new Ui,o=new ln,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,f,d){const p=h.length!==0||f||n!==0||i;return i=f,t=u(h,d,0),n=h.length,p},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1,l()},this.setState=function(h,f,d){const p=h.clippingPlanes,m=h.clipIntersection,g=h.clipShadows,x=a.get(h);if(!i||p===null||p.length===0||s&&!g)s?u(null):l();else{const y=s?0:n,b=y*4;let v=x.clippingState||null;c.value=v,v=u(p,f,b,d);for(let S=0;S!==b;++S)v[S]=t[S];x.clippingState=v,this.numIntersection=m?this.numPlanes:0,this.numPlanes+=y}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,f,d,p){const m=h!==null?h.length:0;let g=null;if(m!==0){if(g=c.value,p!==!0||g===null){const x=d+m*4,y=f.matrixWorldInverse;o.getNormalMatrix(y),(g===null||g.length0){const l=new dp(c.height/2);return l.fromEquirectangularTexture(a,r),e.set(r,l),r.addEventListener("dispose",i),t(l.texture,r.mapping)}else return null}}return r}function i(r){const o=r.target;o.removeEventListener("dispose",i);const c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}class Bs extends _c{constructor(e=-1,t=1,n=1,i=-1,s=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=s,this.far=r,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,s,r){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-e,r=n+e,o=i+t,c=i-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,r=s+l*this.view.width,o-=u*this.view.offsetY,c=o-u*this.view.height}this.projectionMatrix.makeOrthographic(s,r,o,c,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const mr=4,Ih=[.125,.215,.35,.446,.526,.582],ys=20,rl=new Bs,Ph=new ve;let ol=null;const ps=(1+Math.sqrt(5))/2,rr=1/ps,Dh=[new D(1,1,1),new D(-1,1,1),new D(1,1,-1),new D(-1,1,-1),new D(0,ps,rr),new D(0,ps,-rr),new D(rr,0,ps),new D(-rr,0,ps),new D(ps,rr,0),new D(-ps,rr,0)];class tu{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){ol=this._renderer.getRenderTarget(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=kh(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Nh(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?b:0,b,b),u.setRenderTarget(i),m&&u.render(p,o),u.render(e,o)}p.geometry.dispose(),p.material.dispose(),u.toneMapping=f,u.autoClear=h,e.background=g}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===Xi||e.mapping===ji;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=kh()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Nh());const s=i?this._cubemapMaterial:this._equirectMaterial,r=new Tt(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const c=this._cubeSize;ba(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(r,rl)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;iys&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${ys}`);const x=[];let y=0;for(let R=0;Rb-mr?i-b+mr:0),A=4*(this._cubeSize-v);ba(t,S,A,3*v,2*v),c.setRenderTarget(t),c.render(h,rl)}}function tv(a){const e=[],t=[],n=[];let i=a;const s=a-mr+1+Ih.length;for(let r=0;ra-mr?c=Ih[r-a+mr-1]:r===0&&(c=0),n.push(c);const l=1/(o-2),u=-l,h=1+l,f=[u,u,h,u,h,h,u,u,h,h,u,h],d=6,p=6,m=3,g=2,x=1,y=new Float32Array(m*p*d),b=new Float32Array(g*p*d),v=new Float32Array(x*p*d);for(let A=0;A2?0:-1,L=[R,_,0,R+2/3,_,0,R+2/3,_+1,0,R,_,0,R+2/3,_+1,0,R,_+1,0];y.set(L,m*p*A),b.set(f,g*p*A);const N=[A,A,A,A,A,A];v.set(N,x*p*A)}const S=new Xe;S.setAttribute("position",new pt(y,m)),S.setAttribute("uv",new pt(b,g)),S.setAttribute("faceIndex",new pt(v,x)),e.push(S),i>mr&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Fh(a,e,t){const n=new kn(a,e,t);return n.texture.mapping=zr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function ba(a,e,t,n,i){a.viewport.set(e,t,n,i),a.scissor.set(e,t,n,i)}function nv(a,e,t){const n=new Float32Array(ys),i=new D(0,1,0);return new ei({name:"SphericalGaussianBlur",defines:{n:ys,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${a}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Ru(),fragmentShader:` +}`,it={alphamap_fragment:_0,alphamap_pars_fragment:b0,alphatest_fragment:w0,alphatest_pars_fragment:M0,aomap_fragment:S0,aomap_pars_fragment:T0,begin_vertex:A0,beginnormal_vertex:E0,bsdfs:C0,iridescence_fragment:L0,bumpmap_pars_fragment:R0,clipping_planes_fragment:I0,clipping_planes_pars_fragment:P0,clipping_planes_pars_vertex:D0,clipping_planes_vertex:F0,color_fragment:N0,color_pars_fragment:k0,color_pars_vertex:O0,color_vertex:B0,common:z0,cube_uv_reflection_fragment:U0,defaultnormal_vertex:G0,displacementmap_pars_vertex:V0,displacementmap_vertex:H0,emissivemap_fragment:W0,emissivemap_pars_fragment:q0,encodings_fragment:X0,encodings_pars_fragment:j0,envmap_fragment:Y0,envmap_common_pars_fragment:Z0,envmap_pars_fragment:K0,envmap_pars_vertex:J0,envmap_physical_pars_fragment:cy,envmap_vertex:$0,fog_vertex:Q0,fog_pars_vertex:ey,fog_fragment:ty,fog_pars_fragment:ny,gradientmap_pars_fragment:iy,lightmap_fragment:sy,lightmap_pars_fragment:ry,lights_lambert_vertex:oy,lights_pars_begin:ay,lights_toon_fragment:ly,lights_toon_pars_fragment:uy,lights_phong_fragment:hy,lights_phong_pars_fragment:fy,lights_physical_fragment:dy,lights_physical_pars_fragment:py,lights_fragment_begin:my,lights_fragment_maps:gy,lights_fragment_end:yy,logdepthbuf_fragment:xy,logdepthbuf_pars_fragment:vy,logdepthbuf_pars_vertex:_y,logdepthbuf_vertex:by,map_fragment:wy,map_pars_fragment:My,map_particle_fragment:Sy,map_particle_pars_fragment:Ty,metalnessmap_fragment:Ay,metalnessmap_pars_fragment:Ey,morphcolor_vertex:Cy,morphnormal_vertex:Ly,morphtarget_pars_vertex:Ry,morphtarget_vertex:Iy,normal_fragment_begin:Py,normal_fragment_maps:Dy,normal_pars_fragment:Fy,normal_pars_vertex:Ny,normal_vertex:ky,normalmap_pars_fragment:Oy,clearcoat_normal_fragment_begin:By,clearcoat_normal_fragment_maps:zy,clearcoat_pars_fragment:Uy,iridescence_pars_fragment:Gy,output_fragment:Vy,packing:Hy,premultiplied_alpha_fragment:Wy,project_vertex:qy,dithering_fragment:Xy,dithering_pars_fragment:jy,roughnessmap_fragment:Yy,roughnessmap_pars_fragment:Zy,shadowmap_pars_fragment:Ky,shadowmap_pars_vertex:Jy,shadowmap_vertex:$y,shadowmask_pars_fragment:Qy,skinbase_vertex:ex,skinning_pars_vertex:tx,skinning_vertex:nx,skinnormal_vertex:ix,specularmap_fragment:sx,specularmap_pars_fragment:rx,tonemapping_fragment:ox,tonemapping_pars_fragment:ax,transmission_fragment:cx,transmission_pars_fragment:lx,uv_pars_fragment:ux,uv_pars_vertex:hx,uv_vertex:fx,uv2_pars_fragment:dx,uv2_pars_vertex:px,uv2_vertex:mx,worldpos_vertex:gx,background_vert:yx,background_frag:xx,cube_vert:vx,cube_frag:_x,depth_vert:bx,depth_frag:wx,distanceRGBA_vert:Mx,distanceRGBA_frag:Sx,equirect_vert:Tx,equirect_frag:Ax,linedashed_vert:Ex,linedashed_frag:Cx,meshbasic_vert:Lx,meshbasic_frag:Rx,meshlambert_vert:Ix,meshlambert_frag:Px,meshmatcap_vert:Dx,meshmatcap_frag:Fx,meshnormal_vert:Nx,meshnormal_frag:kx,meshphong_vert:Ox,meshphong_frag:Bx,meshphysical_vert:zx,meshphysical_frag:Ux,meshtoon_vert:Gx,meshtoon_frag:Vx,points_vert:Hx,points_frag:Wx,shadow_vert:qx,shadow_frag:Xx,sprite_vert:jx,sprite_frag:Yx},Ie={common:{diffuse:{value:new be(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new ln},uv2Transform:{value:new ln},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new de(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new be(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new be(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new ln}},sprite:{diffuse:{value:new be(16777215)},opacity:{value:1},center:{value:new de(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new ln}}},Hn={basic:{uniforms:rn([Ie.common,Ie.specularmap,Ie.envmap,Ie.aomap,Ie.lightmap,Ie.fog]),vertexShader:it.meshbasic_vert,fragmentShader:it.meshbasic_frag},lambert:{uniforms:rn([Ie.common,Ie.specularmap,Ie.envmap,Ie.aomap,Ie.lightmap,Ie.emissivemap,Ie.fog,Ie.lights,{emissive:{value:new be(0)}}]),vertexShader:it.meshlambert_vert,fragmentShader:it.meshlambert_frag},phong:{uniforms:rn([Ie.common,Ie.specularmap,Ie.envmap,Ie.aomap,Ie.lightmap,Ie.emissivemap,Ie.bumpmap,Ie.normalmap,Ie.displacementmap,Ie.fog,Ie.lights,{emissive:{value:new be(0)},specular:{value:new be(1118481)},shininess:{value:30}}]),vertexShader:it.meshphong_vert,fragmentShader:it.meshphong_frag},standard:{uniforms:rn([Ie.common,Ie.envmap,Ie.aomap,Ie.lightmap,Ie.emissivemap,Ie.bumpmap,Ie.normalmap,Ie.displacementmap,Ie.roughnessmap,Ie.metalnessmap,Ie.fog,Ie.lights,{emissive:{value:new be(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:it.meshphysical_vert,fragmentShader:it.meshphysical_frag},toon:{uniforms:rn([Ie.common,Ie.aomap,Ie.lightmap,Ie.emissivemap,Ie.bumpmap,Ie.normalmap,Ie.displacementmap,Ie.gradientmap,Ie.fog,Ie.lights,{emissive:{value:new be(0)}}]),vertexShader:it.meshtoon_vert,fragmentShader:it.meshtoon_frag},matcap:{uniforms:rn([Ie.common,Ie.bumpmap,Ie.normalmap,Ie.displacementmap,Ie.fog,{matcap:{value:null}}]),vertexShader:it.meshmatcap_vert,fragmentShader:it.meshmatcap_frag},points:{uniforms:rn([Ie.points,Ie.fog]),vertexShader:it.points_vert,fragmentShader:it.points_frag},dashed:{uniforms:rn([Ie.common,Ie.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:it.linedashed_vert,fragmentShader:it.linedashed_frag},depth:{uniforms:rn([Ie.common,Ie.displacementmap]),vertexShader:it.depth_vert,fragmentShader:it.depth_frag},normal:{uniforms:rn([Ie.common,Ie.bumpmap,Ie.normalmap,Ie.displacementmap,{opacity:{value:1}}]),vertexShader:it.meshnormal_vert,fragmentShader:it.meshnormal_frag},sprite:{uniforms:rn([Ie.sprite,Ie.fog]),vertexShader:it.sprite_vert,fragmentShader:it.sprite_frag},background:{uniforms:{uvTransform:{value:new ln},t2D:{value:null}},vertexShader:it.background_vert,fragmentShader:it.background_frag},cube:{uniforms:rn([Ie.envmap,{opacity:{value:1}}]),vertexShader:it.cube_vert,fragmentShader:it.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:it.equirect_vert,fragmentShader:it.equirect_frag},distanceRGBA:{uniforms:rn([Ie.common,Ie.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:it.distanceRGBA_vert,fragmentShader:it.distanceRGBA_frag},shadow:{uniforms:rn([Ie.lights,Ie.fog,{color:{value:new be(0)},opacity:{value:1}}]),vertexShader:it.shadow_vert,fragmentShader:it.shadow_frag}};Hn.physical={uniforms:rn([Hn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new de(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new be(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new de},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new be(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new be(1,1,1)},specularColorMap:{value:null}}]),vertexShader:it.meshphysical_vert,fragmentShader:it.meshphysical_frag};function Zx(a,e,t,n,i,s){const r=new be(0);let o=i===!0?0:1,c,l,u=null,h=0,f=null;function d(m,g){let x=!1,y=g.isScene===!0?g.background:null;y&&y.isTexture&&(y=e.get(y));const b=a.xr,v=b.getSession&&b.getSession();v&&v.environmentBlendMode==="additive"&&(y=null),y===null?p(r,o):y&&y.isColor&&(p(y,1),x=!0),(a.autoClear||x)&&a.clear(a.autoClearColor,a.autoClearDepth,a.autoClearStencil),y&&(y.isCubeTexture||y.mapping===zr)?(l===void 0&&(l=new Tt(new wi(1,1,1),new ei({name:"BackgroundCubeMaterial",uniforms:Mr(Hn.cube.uniforms),vertexShader:Hn.cube.vertexShader,fragmentShader:Hn.cube.fragmentShader,side:Dn,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(M,T,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=y,l.material.uniforms.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,(u!==y||h!==y.version||f!==a.toneMapping)&&(l.material.needsUpdate=!0,u=y,h=y.version,f=a.toneMapping),l.layers.enableAll(),m.unshift(l,l.geometry,l.material,0,0,null)):y&&y.isTexture&&(c===void 0&&(c=new Tt(new Ls(2,2),new ei({name:"BackgroundMaterial",uniforms:Mr(Hn.background.uniforms),vertexShader:Hn.background.vertexShader,fragmentShader:Hn.background.fragmentShader,side:vi,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=y,y.matrixAutoUpdate===!0&&y.updateMatrix(),c.material.uniforms.uvTransform.value.copy(y.matrix),(u!==y||h!==y.version||f!==a.toneMapping)&&(c.material.needsUpdate=!0,u=y,h=y.version,f=a.toneMapping),c.layers.enableAll(),m.unshift(c,c.geometry,c.material,0,0,null))}function p(m,g){t.buffers.color.setClear(m.r,m.g,m.b,g,s)}return{getClearColor:function(){return r},setClearColor:function(m,g=1){r.set(m),o=g,p(r,o)},getClearAlpha:function(){return o},setClearAlpha:function(m){o=m,p(r,o)},render:d}}function Kx(a,e,t,n){const i=a.getParameter(34921),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),r=n.isWebGL2||s!==null,o={},c=g(null);let l=c,u=!1;function h(G,X,B,Z,Y){let W=!1;if(r){const j=m(Z,B,X);l!==j&&(l=j,d(l.object)),W=x(G,Z,B,Y),W&&y(G,Z,B,Y)}else{const j=X.wireframe===!0;(l.geometry!==Z.id||l.program!==B.id||l.wireframe!==j)&&(l.geometry=Z.id,l.program=B.id,l.wireframe=j,W=!0)}Y!==null&&t.update(Y,34963),(W||u)&&(u=!1,_(G,X,B,Z),Y!==null&&a.bindBuffer(34963,t.get(Y).buffer))}function f(){return n.isWebGL2?a.createVertexArray():s.createVertexArrayOES()}function d(G){return n.isWebGL2?a.bindVertexArray(G):s.bindVertexArrayOES(G)}function p(G){return n.isWebGL2?a.deleteVertexArray(G):s.deleteVertexArrayOES(G)}function m(G,X,B){const Z=B.wireframe===!0;let Y=o[G.id];Y===void 0&&(Y={},o[G.id]=Y);let W=Y[X.id];W===void 0&&(W={},Y[X.id]=W);let j=W[Z];return j===void 0&&(j=g(f()),W[Z]=j),j}function g(G){const X=[],B=[],Z=[];for(let Y=0;Y=0){const ce=Y[$];let oe=W[$];if(oe===void 0&&($==="instanceMatrix"&&G.instanceMatrix&&(oe=G.instanceMatrix),$==="instanceColor"&&G.instanceColor&&(oe=G.instanceColor)),ce===void 0||ce.attribute!==oe||oe&&ce.data!==oe.data)return!0;j++}return l.attributesNum!==j||l.index!==Z}function y(G,X,B,Z){const Y={},W=X.attributes;let j=0;const ne=B.getAttributes();for(const $ in ne)if(ne[$].location>=0){let ce=W[$];ce===void 0&&($==="instanceMatrix"&&G.instanceMatrix&&(ce=G.instanceMatrix),$==="instanceColor"&&G.instanceColor&&(ce=G.instanceColor));const oe={};oe.attribute=ce,ce&&ce.data&&(oe.data=ce.data),Y[$]=oe,j++}l.attributes=Y,l.attributesNum=j,l.index=Z}function b(){const G=l.newAttributes;for(let X=0,B=G.length;X=0){let ie=Y[ne];if(ie===void 0&&(ne==="instanceMatrix"&&G.instanceMatrix&&(ie=G.instanceMatrix),ne==="instanceColor"&&G.instanceColor&&(ie=G.instanceColor)),ie!==void 0){const ce=ie.normalized,oe=ie.itemSize,H=t.get(ie);if(H===void 0)continue;const ye=H.buffer,we=H.type,Pe=H.bytesPerElement;if(ie.isInterleavedBufferAttribute){const xe=ie.data,Ve=xe.stride,he=ie.offset;if(xe.isInstancedInterleavedBuffer){for(let ue=0;ue<$.locationSize;ue++)M($.location+ue,xe.meshPerAttribute);G.isInstancedMesh!==!0&&Z._maxInstanceCount===void 0&&(Z._maxInstanceCount=xe.meshPerAttribute*xe.count)}else for(let ue=0;ue<$.locationSize;ue++)v($.location+ue);a.bindBuffer(34962,ye);for(let ue=0;ue<$.locationSize;ue++)C($.location+ue,oe/$.locationSize,we,ce,Ve*Pe,(he+oe/$.locationSize*ue)*Pe)}else{if(ie.isInstancedBufferAttribute){for(let xe=0;xe<$.locationSize;xe++)M($.location+xe,ie.meshPerAttribute);G.isInstancedMesh!==!0&&Z._maxInstanceCount===void 0&&(Z._maxInstanceCount=ie.meshPerAttribute*ie.count)}else for(let xe=0;xe<$.locationSize;xe++)v($.location+xe);a.bindBuffer(34962,ye);for(let xe=0;xe<$.locationSize;xe++)C($.location+xe,oe/$.locationSize,we,ce,oe*Pe,oe/$.locationSize*xe*Pe)}}else if(j!==void 0){const ce=j[ne];if(ce!==void 0)switch(ce.length){case 2:a.vertexAttrib2fv($.location,ce);break;case 3:a.vertexAttrib3fv($.location,ce);break;case 4:a.vertexAttrib4fv($.location,ce);break;default:a.vertexAttrib1fv($.location,ce)}}}}T()}function E(){q();for(const G in o){const X=o[G];for(const B in X){const Z=X[B];for(const Y in Z)p(Z[Y].object),delete Z[Y];delete X[B]}delete o[G]}}function F(G){if(o[G.id]===void 0)return;const X=o[G.id];for(const B in X){const Z=X[B];for(const Y in Z)p(Z[Y].object),delete Z[Y];delete X[B]}delete o[G.id]}function U(G){for(const X in o){const B=o[X];if(B[G.id]===void 0)continue;const Z=B[G.id];for(const Y in Z)p(Z[Y].object),delete Z[Y];delete B[G.id]}}function q(){J(),u=!0,l!==c&&(l=c,d(l.object))}function J(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:h,reset:q,resetDefaultState:J,dispose:E,releaseStatesOfGeometry:F,releaseStatesOfProgram:U,initAttributes:b,enableAttribute:v,disableUnusedAttributes:T}}function Jx(a,e,t,n){const i=n.isWebGL2;let s;function r(l){s=l}function o(l,u){a.drawArrays(s,l,u),t.update(u,s,1)}function c(l,u,h){if(h===0)return;let f,d;if(i)f=a,d="drawArraysInstanced";else if(f=e.get("ANGLE_instanced_arrays"),d="drawArraysInstancedANGLE",f===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}f[d](s,l,u,h),t.update(u,s,h)}this.setMode=r,this.render=o,this.renderInstances=c}function $x(a,e,t){let n;function i(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");n=a.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function s(C){if(C==="highp"){if(a.getShaderPrecisionFormat(35633,36338).precision>0&&a.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";C="mediump"}return C==="mediump"&&a.getShaderPrecisionFormat(35633,36337).precision>0&&a.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const r=typeof WebGL2RenderingContext!="undefined"&&a instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext!="undefined"&&a instanceof WebGL2ComputeRenderingContext;let o=t.precision!==void 0?t.precision:"highp";const c=s(o);c!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",c,"instead."),o=c);const l=r||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,h=a.getParameter(34930),f=a.getParameter(35660),d=a.getParameter(3379),p=a.getParameter(34076),m=a.getParameter(34921),g=a.getParameter(36347),x=a.getParameter(36348),y=a.getParameter(36349),b=f>0,v=r||e.has("OES_texture_float"),M=b&&v,T=r?a.getParameter(36183):0;return{isWebGL2:r,drawBuffers:l,getMaxAnisotropy:i,getMaxPrecision:s,precision:o,logarithmicDepthBuffer:u,maxTextures:h,maxVertexTextures:f,maxTextureSize:d,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:g,maxVaryings:x,maxFragmentUniforms:y,vertexTextures:b,floatFragmentTextures:v,floatVertexTextures:M,maxSamples:T}}function Qx(a){const e=this;let t=null,n=0,i=!1,s=!1;const r=new Ui,o=new ln,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,f,d){const p=h.length!==0||f||n!==0||i;return i=f,t=u(h,d,0),n=h.length,p},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1,l()},this.setState=function(h,f,d){const p=h.clippingPlanes,m=h.clipIntersection,g=h.clipShadows,x=a.get(h);if(!i||p===null||p.length===0||s&&!g)s?u(null):l();else{const y=s?0:n,b=y*4;let v=x.clippingState||null;c.value=v,v=u(p,f,b,d);for(let M=0;M!==b;++M)v[M]=t[M];x.clippingState=v,this.numIntersection=m?this.numPlanes:0,this.numPlanes+=y}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,f,d,p){const m=h!==null?h.length:0;let g=null;if(m!==0){if(g=c.value,p!==!0||g===null){const x=d+m*4,y=f.matrixWorldInverse;o.getNormalMatrix(y),(g===null||g.length0){const l=new pp(c.height/2);return l.fromEquirectangularTexture(a,r),e.set(r,l),r.addEventListener("dispose",i),t(l.texture,r.mapping)}else return null}}return r}function i(r){const o=r.target;o.removeEventListener("dispose",i);const c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}class Bs extends bc{constructor(e=-1,t=1,n=1,i=-1,s=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=s,this.far=r,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,s,r){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-e,r=n+e,o=i+t,c=i-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,r=s+l*this.view.width,o-=u*this.view.offsetY,c=o-u*this.view.height}this.projectionMatrix.makeOrthographic(s,r,o,c,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const mr=4,Ph=[.125,.215,.35,.446,.526,.582],ys=20,ol=new Bs,Dh=new be;let al=null;const ps=(1+Math.sqrt(5))/2,rr=1/ps,Fh=[new P(1,1,1),new P(-1,1,1),new P(1,1,-1),new P(-1,1,-1),new P(0,ps,rr),new P(0,ps,-rr),new P(rr,0,ps),new P(-rr,0,ps),new P(ps,rr,0),new P(-ps,rr,0)];class nu{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){al=this._renderer.getRenderTarget(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Oh(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=kh(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?b:0,b,b),u.setRenderTarget(i),m&&u.render(p,o),u.render(e,o)}p.geometry.dispose(),p.material.dispose(),u.toneMapping=f,u.autoClear=h,e.background=g}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===Xi||e.mapping===ji;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Oh()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=kh());const s=i?this._cubemapMaterial:this._equirectMaterial,r=new Tt(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const c=this._cubeSize;ba(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(r,ol)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;iys&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${ys}`);const x=[];let y=0;for(let C=0;Cb-mr?i-b+mr:0),T=4*(this._cubeSize-v);ba(t,M,T,3*v,2*v),c.setRenderTarget(t),c.render(h,ol)}}function tv(a){const e=[],t=[],n=[];let i=a;const s=a-mr+1+Ph.length;for(let r=0;ra-mr?c=Ph[r-a+mr-1]:r===0&&(c=0),n.push(c);const l=1/(o-2),u=-l,h=1+l,f=[u,u,h,u,h,h,u,u,h,h,u,h],d=6,p=6,m=3,g=2,x=1,y=new Float32Array(m*p*d),b=new Float32Array(g*p*d),v=new Float32Array(x*p*d);for(let T=0;T2?0:-1,E=[C,_,0,C+2/3,_,0,C+2/3,_+1,0,C,_,0,C+2/3,_+1,0,C,_+1,0];y.set(E,m*p*T),b.set(f,g*p*T);const F=[T,T,T,T,T,T];v.set(F,x*p*T)}const M=new qe;M.setAttribute("position",new pt(y,m)),M.setAttribute("uv",new pt(b,g)),M.setAttribute("faceIndex",new pt(v,x)),e.push(M),i>mr&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Nh(a,e,t){const n=new kn(a,e,t);return n.texture.mapping=zr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function ba(a,e,t,n,i){a.viewport.set(e,t,n,i),a.scissor.set(e,t,n,i)}function nv(a,e,t){const n=new Float32Array(ys),i=new P(0,1,0);return new ei({name:"SphericalGaussianBlur",defines:{n:ys,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${a}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Iu(),fragmentShader:` precision mediump float; precision mediump int; @@ -2990,7 +2990,7 @@ void main() { } } - `,blending:xi,depthTest:!1,depthWrite:!1})}function Nh(){return new ei({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ru(),fragmentShader:` + `,blending:xi,depthTest:!1,depthWrite:!1})}function kh(){return new ei({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Iu(),fragmentShader:` precision mediump float; precision mediump int; @@ -3009,7 +3009,7 @@ void main() { gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } - `,blending:xi,depthTest:!1,depthWrite:!1})}function kh(){return new ei({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ru(),fragmentShader:` + `,blending:xi,depthTest:!1,depthWrite:!1})}function Oh(){return new ei({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Iu(),fragmentShader:` precision mediump float; precision mediump int; @@ -3025,7 +3025,7 @@ void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } - `,blending:xi,depthTest:!1,depthWrite:!1})}function Ru(){return` + `,blending:xi,depthTest:!1,depthWrite:!1})}function Iu(){return` precision mediump float; precision mediump int; @@ -3080,37 +3080,37 @@ void main() { gl_Position = vec4( position, 1.0 ); } - `}function iv(a){let e=new WeakMap,t=null;function n(o){if(o&&o.isTexture){const c=o.mapping,l=c===vr||c===_o,u=c===Xi||c===ji;if(l||u)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let h=e.get(o);return t===null&&(t=new tu(a)),h=l?t.fromEquirectangular(o,h):t.fromCubemap(o,h),e.set(o,h),h.texture}else{if(e.has(o))return e.get(o).texture;{const h=o.image;if(l&&h&&h.height>0||u&&h&&i(h)){t===null&&(t=new tu(a));const f=l?t.fromEquirectangular(o):t.fromCubemap(o);return e.set(o,f),o.addEventListener("dispose",s),f.texture}else return null}}}return o}function i(o){let c=0;const l=6;for(let u=0;ue.maxTextureSize&&(B=Math.ceil(N/e.maxTextureSize),N=e.maxTextureSize);const W=new Float32Array(N*B*4*m),K=new Bo(W,N,B,m);K.type=gi,K.needsUpdate=!0;const z=L*4;for(let O=0;O0)return a;const i=e*t;let s=Oh[i];if(s===void 0&&(s=new Float32Array(i),Oh[i]=s),e!==0){n.toArray(s,0);for(let r=1,o=0;r!==e;++r)o+=t,a[r].toArray(s,o)}return s}function hn(a,e){if(a.length!==e.length)return!1;for(let t=0,n=a.length;t0||u&&h&&i(h)){t===null&&(t=new nu(a));const f=l?t.fromEquirectangular(o):t.fromCubemap(o);return e.set(o,f),o.addEventListener("dispose",s),f.texture}else return null}}}return o}function i(o){let c=0;const l=6;for(let u=0;ue.maxTextureSize&&(U=Math.ceil(F/e.maxTextureSize),F=e.maxTextureSize);const q=new Float32Array(F*U*4*m),J=new Bo(q,F,U,m);J.type=gi,J.needsUpdate=!0;const G=E*4;for(let B=0;B0)return a;const i=e*t;let s=Bh[i];if(s===void 0&&(s=new Float32Array(i),Bh[i]=s),e!==0){n.toArray(s,0);for(let r=1,o=0;r!==e;++r)o+=t,a[r].toArray(s,o)}return s}function hn(a,e){if(a.length!==e.length)return!1;for(let t=0,n=a.length;t":" "} ${o}: ${t[r]}`)}return n.join(` -`)}function s_(a){switch(a){case bi:return["Linear","( value )"];case tt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",a),["Linear","( value )"]}}function Wh(a,e,t){const n=a.getShaderParameter(e,35713),i=a.getShaderInfoLog(e).trim();if(n&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const r=parseInt(s[1]);return t.toUpperCase()+` +`)}function s_(a){switch(a){case bi:return["Linear","( value )"];case nt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",a),["Linear","( value )"]}}function qh(a,e,t){const n=a.getShaderParameter(e,35713),i=a.getShaderInfoLog(e).trim();if(n&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const r=parseInt(s[1]);return t.toUpperCase()+` `+i+` -`+i_(a.getShaderSource(e),r)}else return i}function r_(a,e){const t=s_(e);return"vec4 "+a+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function o_(a,e){let t;switch(e){case Nd:t="Linear";break;case kd:t="Reinhard";break;case Od:t="OptimizedCineon";break;case Bd:t="ACESFilmic";break;case zd:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+a+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function a_(a){return[a.extensionDerivatives||!!a.envMapCubeUVHeight||a.bumpMap||a.tangentSpaceNormalMap||a.clearcoatNormalMap||a.flatShading||a.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(a.extensionFragDepth||a.logarithmicDepthBuffer)&&a.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",a.extensionDrawBuffers&&a.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(a.extensionShaderTextureLOD||a.envMap||a.transmission)&&a.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(uo).join(` +`+i_(a.getShaderSource(e),r)}else return i}function r_(a,e){const t=s_(e);return"vec4 "+a+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function o_(a,e){let t;switch(e){case kd:t="Linear";break;case Od:t="Reinhard";break;case Bd:t="OptimizedCineon";break;case zd:t="ACESFilmic";break;case Ud:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+a+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function a_(a){return[a.extensionDerivatives||!!a.envMapCubeUVHeight||a.bumpMap||a.tangentSpaceNormalMap||a.clearcoatNormalMap||a.flatShading||a.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(a.extensionFragDepth||a.logarithmicDepthBuffer)&&a.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",a.extensionDrawBuffers&&a.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(a.extensionShaderTextureLOD||a.envMap||a.transmission)&&a.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(uo).join(` `)}function c_(a){const e=[];for(const t in a){const n=a[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` -`)}function l_(a,e){const t={},n=a.getProgramParameter(e,35721);for(let i=0;i/gm;function nu(a){return a.replace(u_,h_)}function h_(a,e){const t=nt[e];if(t===void 0)throw new Error("Can not resolve #include <"+e+">");return nu(t)}const f_=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,d_=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function jh(a){return a.replace(d_,vp).replace(f_,p_)}function p_(a,e,t,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),vp(a,e,t,n)}function vp(a,e,t,n){let i="";for(let s=parseInt(e);s/gm;function iu(a){return a.replace(u_,h_)}function h_(a,e){const t=it[e];if(t===void 0)throw new Error("Can not resolve #include <"+e+">");return iu(t)}const f_=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,d_=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Yh(a){return a.replace(d_,_p).replace(f_,p_)}function p_(a,e,t,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),_p(a,e,t,n)}function _p(a,e,t,n){let i="";for(let s=parseInt(e);s0&&(g+=` `),x=[d,p].filter(uo).join(` `),x.length>0&&(x+=` -`)):(g=[Yh(t),"#define SHADER_NAME "+t.shaderName,p,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.supportsVertexTextures?"#define VERTEX_TEXTURES":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.displacementMap&&t.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`)):(g=[Zh(t),"#define SHADER_NAME "+t.shaderName,p,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.supportsVertexTextures?"#define VERTEX_TEXTURES":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.displacementMap&&t.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(uo).join(` -`),x=[d,Yh(t),"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Jn?"#define TONE_MAPPING":"",t.toneMapping!==Jn?nt.tonemapping_pars_fragment:"",t.toneMapping!==Jn?o_("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",nt.encodings_pars_fragment,r_("linearToOutputTexel",t.outputEncoding),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`),x=[d,Zh(t),"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Jn?"#define TONE_MAPPING":"",t.toneMapping!==Jn?it.tonemapping_pars_fragment:"",t.toneMapping!==Jn?o_("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",it.encodings_pars_fragment,r_("linearToOutputTexel",t.outputEncoding),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(uo).join(` -`)),r=nu(r),r=qh(r,t),r=Xh(r,t),o=nu(o),o=qh(o,t),o=Xh(o,t),r=jh(r),o=jh(o),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(y=`#version 300 es +`)),r=iu(r),r=Xh(r,t),r=jh(r,t),o=iu(o),o=Xh(o,t),o=jh(o,t),r=Yh(r),o=Yh(o),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(y=`#version 300 es `,g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` -`+g,x=["#define varying in",t.glslVersion===Ql?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Ql?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`+g,x=["#define varying in",t.glslVersion===eu?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===eu?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` `)+` -`+x);const b=y+g+r,v=y+x+o,S=Hh(i,35633,b),A=Hh(i,35632,v);if(i.attachShader(m,S),i.attachShader(m,A),t.index0AttributeName!==void 0?i.bindAttribLocation(m,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(m,0,"position"),i.linkProgram(m),a.debug.checkShaderErrors){const L=i.getProgramInfoLog(m).trim(),N=i.getShaderInfoLog(S).trim(),B=i.getShaderInfoLog(A).trim();let W=!0,K=!0;if(i.getProgramParameter(m,35714)===!1){W=!1;const z=Wh(i,S,"vertex"),q=Wh(i,A,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(m,35715)+` +`+x);const b=y+g+r,v=y+x+o,M=Wh(i,35633,b),T=Wh(i,35632,v);if(i.attachShader(m,M),i.attachShader(m,T),t.index0AttributeName!==void 0?i.bindAttribLocation(m,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(m,0,"position"),i.linkProgram(m),a.debug.checkShaderErrors){const E=i.getProgramInfoLog(m).trim(),F=i.getShaderInfoLog(M).trim(),U=i.getShaderInfoLog(T).trim();let q=!0,J=!0;if(i.getProgramParameter(m,35714)===!1){q=!1;const G=qh(i,M,"vertex"),X=qh(i,T,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(m,35715)+` -Program Info Log: `+L+` -`+z+` -`+q)}else L!==""?console.warn("THREE.WebGLProgram: Program Info Log:",L):(N===""||B==="")&&(K=!1);K&&(this.diagnostics={runnable:W,programLog:L,vertexShader:{log:N,prefix:g},fragmentShader:{log:B,prefix:x}})}i.deleteShader(S),i.deleteShader(A);let R;this.getUniforms=function(){return R===void 0&&(R=new Ja(i,m)),R};let _;return this.getAttributes=function(){return _===void 0&&(_=l_(i,m)),_},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(m),this.program=void 0},this.name=t.shaderName,this.id=n_++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=S,this.fragmentShader=A,this}let b_=0;class w_{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),r=this._getShaderCacheForMaterial(e);return r.has(i)===!1&&(r.add(i),i.usedTimes++),r.has(s)===!1&&(r.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;return t.has(e)===!1&&t.set(e,new Set),t.get(e)}_getShaderStage(e){const t=this.shaderCache;if(t.has(e)===!1){const n=new M_(e);t.set(e,n)}return t.get(e)}}class M_{constructor(e){this.id=b_++,this.code=e,this.usedTimes=0}}function S_(a,e,t,n,i,s,r){const o=new xc,c=new w_,l=[],u=i.isWebGL2,h=i.logarithmicDepthBuffer,f=i.vertexTextures;let d=i.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(_,L,N,B,W){const K=B.fog,z=W.geometry,q=_.isMeshStandardMaterial?B.environment:null,O=(_.isMeshStandardMaterial?t:e).get(_.envMap||q),Y=!!O&&O.mapping===zr?O.image.height:null,j=p[_.type];_.precision!==null&&(d=i.getMaxPrecision(_.precision),d!==_.precision&&console.warn("THREE.WebGLProgram.getParameters:",_.precision,"not supported, using",d,"instead."));const H=z.morphAttributes.position||z.morphAttributes.normal||z.morphAttributes.color,X=H!==void 0?H.length:0;let te=0;z.morphAttributes.position!==void 0&&(te=1),z.morphAttributes.normal!==void 0&&(te=2),z.morphAttributes.color!==void 0&&(te=3);let J,ne,re,se;if(j){const He=Hn[j];J=He.vertexShader,ne=He.fragmentShader}else J=_.vertexShader,ne=_.fragmentShader,c.update(_),re=c.getVertexShaderID(_),se=c.getFragmentShaderID(_);const V=a.getRenderTarget(),me=_.alphaTest>0,_e=_.clearcoat>0,Ie=_.iridescence>0;return{isWebGL2:u,shaderID:j,shaderName:_.type,vertexShader:J,fragmentShader:ne,defines:_.defines,customVertexShaderID:re,customFragmentShaderID:se,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:d,instancing:W.isInstancedMesh===!0,instancingColor:W.isInstancedMesh===!0&&W.instanceColor!==null,supportsVertexTextures:f,outputEncoding:V===null?a.outputEncoding:V.isXRRenderTarget===!0?V.texture.encoding:bi,map:!!_.map,matcap:!!_.matcap,envMap:!!O,envMapMode:O&&O.mapping,envMapCubeUVHeight:Y,lightMap:!!_.lightMap,aoMap:!!_.aoMap,emissiveMap:!!_.emissiveMap,bumpMap:!!_.bumpMap,normalMap:!!_.normalMap,objectSpaceNormalMap:_.normalMapType===op,tangentSpaceNormalMap:_.normalMapType===Qi,decodeVideoTexture:!!_.map&&_.map.isVideoTexture===!0&&_.map.encoding===tt,clearcoat:_e,clearcoatMap:_e&&!!_.clearcoatMap,clearcoatRoughnessMap:_e&&!!_.clearcoatRoughnessMap,clearcoatNormalMap:_e&&!!_.clearcoatNormalMap,iridescence:Ie,iridescenceMap:Ie&&!!_.iridescenceMap,iridescenceThicknessMap:Ie&&!!_.iridescenceThicknessMap,displacementMap:!!_.displacementMap,roughnessMap:!!_.roughnessMap,metalnessMap:!!_.metalnessMap,specularMap:!!_.specularMap,specularIntensityMap:!!_.specularIntensityMap,specularColorMap:!!_.specularColorMap,opaque:_.transparent===!1&&_.blending===ws,alphaMap:!!_.alphaMap,alphaTest:me,gradientMap:!!_.gradientMap,sheen:_.sheen>0,sheenColorMap:!!_.sheenColorMap,sheenRoughnessMap:!!_.sheenRoughnessMap,transmission:_.transmission>0,transmissionMap:!!_.transmissionMap,thicknessMap:!!_.thicknessMap,combine:_.combine,vertexTangents:!!_.normalMap&&!!z.attributes.tangent,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!z.attributes.color&&z.attributes.color.itemSize===4,vertexUvs:!!_.map||!!_.bumpMap||!!_.normalMap||!!_.specularMap||!!_.alphaMap||!!_.emissiveMap||!!_.roughnessMap||!!_.metalnessMap||!!_.clearcoatMap||!!_.clearcoatRoughnessMap||!!_.clearcoatNormalMap||!!_.iridescenceMap||!!_.iridescenceThicknessMap||!!_.displacementMap||!!_.transmissionMap||!!_.thicknessMap||!!_.specularIntensityMap||!!_.specularColorMap||!!_.sheenColorMap||!!_.sheenRoughnessMap,uvsVertexOnly:!(!!_.map||!!_.bumpMap||!!_.normalMap||!!_.specularMap||!!_.alphaMap||!!_.emissiveMap||!!_.roughnessMap||!!_.metalnessMap||!!_.clearcoatNormalMap||!!_.iridescenceMap||!!_.iridescenceThicknessMap||_.transmission>0||!!_.transmissionMap||!!_.thicknessMap||!!_.specularIntensityMap||!!_.specularColorMap||_.sheen>0||!!_.sheenColorMap||!!_.sheenRoughnessMap)&&!!_.displacementMap,fog:!!K,useFog:_.fog===!0,fogExp2:K&&K.isFogExp2,flatShading:!!_.flatShading,sizeAttenuation:_.sizeAttenuation,logarithmicDepthBuffer:h,skinning:W.isSkinnedMesh===!0,morphTargets:z.morphAttributes.position!==void 0,morphNormals:z.morphAttributes.normal!==void 0,morphColors:z.morphAttributes.color!==void 0,morphTargetsCount:X,morphTextureStride:te,numDirLights:L.directional.length,numPointLights:L.point.length,numSpotLights:L.spot.length,numRectAreaLights:L.rectArea.length,numHemiLights:L.hemi.length,numDirLightShadows:L.directionalShadowMap.length,numPointLightShadows:L.pointShadowMap.length,numSpotLightShadows:L.spotShadowMap.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:_.dithering,shadowMapEnabled:a.shadowMap.enabled&&N.length>0,shadowMapType:a.shadowMap.type,toneMapping:_.toneMapped?a.toneMapping:Jn,physicallyCorrectLights:a.physicallyCorrectLights,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===_i,flipSided:_.side===Dn,useDepthPacking:!!_.depthPacking,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionDerivatives:_.extensions&&_.extensions.derivatives,extensionFragDepth:_.extensions&&_.extensions.fragDepth,extensionDrawBuffers:_.extensions&&_.extensions.drawBuffers,extensionShaderTextureLOD:_.extensions&&_.extensions.shaderTextureLOD,rendererExtensionFragDepth:u||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||n.has("EXT_shader_texture_lod"),customProgramCacheKey:_.customProgramCacheKey()}}function g(_){const L=[];if(_.shaderID?L.push(_.shaderID):(L.push(_.customVertexShaderID),L.push(_.customFragmentShaderID)),_.defines!==void 0)for(const N in _.defines)L.push(N),L.push(_.defines[N]);return _.isRawShaderMaterial===!1&&(x(L,_),y(L,_),L.push(a.outputEncoding)),L.push(_.customProgramCacheKey),L.join()}function x(_,L){_.push(L.precision),_.push(L.outputEncoding),_.push(L.envMapMode),_.push(L.envMapCubeUVHeight),_.push(L.combine),_.push(L.vertexUvs),_.push(L.fogExp2),_.push(L.sizeAttenuation),_.push(L.morphTargetsCount),_.push(L.morphAttributeCount),_.push(L.numDirLights),_.push(L.numPointLights),_.push(L.numSpotLights),_.push(L.numHemiLights),_.push(L.numRectAreaLights),_.push(L.numDirLightShadows),_.push(L.numPointLightShadows),_.push(L.numSpotLightShadows),_.push(L.shadowMapType),_.push(L.toneMapping),_.push(L.numClippingPlanes),_.push(L.numClipIntersection),_.push(L.depthPacking)}function y(_,L){o.disableAll(),L.isWebGL2&&o.enable(0),L.supportsVertexTextures&&o.enable(1),L.instancing&&o.enable(2),L.instancingColor&&o.enable(3),L.map&&o.enable(4),L.matcap&&o.enable(5),L.envMap&&o.enable(6),L.lightMap&&o.enable(7),L.aoMap&&o.enable(8),L.emissiveMap&&o.enable(9),L.bumpMap&&o.enable(10),L.normalMap&&o.enable(11),L.objectSpaceNormalMap&&o.enable(12),L.tangentSpaceNormalMap&&o.enable(13),L.clearcoat&&o.enable(14),L.clearcoatMap&&o.enable(15),L.clearcoatRoughnessMap&&o.enable(16),L.clearcoatNormalMap&&o.enable(17),L.iridescence&&o.enable(18),L.iridescenceMap&&o.enable(19),L.iridescenceThicknessMap&&o.enable(20),L.displacementMap&&o.enable(21),L.specularMap&&o.enable(22),L.roughnessMap&&o.enable(23),L.metalnessMap&&o.enable(24),L.gradientMap&&o.enable(25),L.alphaMap&&o.enable(26),L.alphaTest&&o.enable(27),L.vertexColors&&o.enable(28),L.vertexAlphas&&o.enable(29),L.vertexUvs&&o.enable(30),L.vertexTangents&&o.enable(31),L.uvsVertexOnly&&o.enable(32),L.fog&&o.enable(33),_.push(o.mask),o.disableAll(),L.useFog&&o.enable(0),L.flatShading&&o.enable(1),L.logarithmicDepthBuffer&&o.enable(2),L.skinning&&o.enable(3),L.morphTargets&&o.enable(4),L.morphNormals&&o.enable(5),L.morphColors&&o.enable(6),L.premultipliedAlpha&&o.enable(7),L.shadowMapEnabled&&o.enable(8),L.physicallyCorrectLights&&o.enable(9),L.doubleSided&&o.enable(10),L.flipSided&&o.enable(11),L.useDepthPacking&&o.enable(12),L.dithering&&o.enable(13),L.specularIntensityMap&&o.enable(14),L.specularColorMap&&o.enable(15),L.transmission&&o.enable(16),L.transmissionMap&&o.enable(17),L.thicknessMap&&o.enable(18),L.sheen&&o.enable(19),L.sheenColorMap&&o.enable(20),L.sheenRoughnessMap&&o.enable(21),L.decodeVideoTexture&&o.enable(22),L.opaque&&o.enable(23),_.push(o.mask)}function b(_){const L=p[_.type];let N;if(L){const B=Hn[L];N=hp.clone(B.uniforms)}else N=_.uniforms;return N}function v(_,L){let N;for(let B=0,W=l.length;B0?n.push(x):d.transparent===!0?i.push(x):t.push(x)}function c(h,f,d,p,m,g){const x=r(h,f,d,p,m,g);d.transmission>0?n.unshift(x):d.transparent===!0?i.unshift(x):t.unshift(x)}function l(h,f){t.length>1&&t.sort(h||A_),n.length>1&&n.sort(f||Zh),i.length>1&&i.sort(f||Zh)}function u(){for(let h=e,f=a.length;h=a.get(n).length?(s=new Kh,a.get(n).push(s)):s=a.get(n)[i],s}function t(){a=new WeakMap}return{get:e,dispose:t}}function C_(){const a={};return{get:function(e){if(a[e.id]!==void 0)return a[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new D,color:new ve};break;case"SpotLight":t={position:new D,direction:new D,color:new ve,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new D,color:new ve,distance:0,decay:0};break;case"HemisphereLight":t={direction:new D,skyColor:new ve,groundColor:new ve};break;case"RectAreaLight":t={color:new ve,position:new D,halfWidth:new D,halfHeight:new D};break}return a[e.id]=t,t}}}function L_(){const a={};return{get:function(e){if(a[e.id]!==void 0)return a[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new fe};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new fe};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new fe,shadowCameraNear:1,shadowCameraFar:1e3};break}return a[e.id]=t,t}}}let R_=0;function I_(a,e){return(e.castShadow?1:0)-(a.castShadow?1:0)}function P_(a,e){const t=new C_,n=L_(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let u=0;u<9;u++)i.probe.push(new D);const s=new D,r=new De,o=new De;function c(u,h){let f=0,d=0,p=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let m=0,g=0,x=0,y=0,b=0,v=0,S=0,A=0;u.sort(I_);const R=h!==!0?Math.PI:1;for(let L=0,N=u.length;L0&&(e.isWebGL2||a.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Re.LTC_FLOAT_1,i.rectAreaLTC2=Re.LTC_FLOAT_2):a.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Re.LTC_HALF_1,i.rectAreaLTC2=Re.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=f,i.ambient[1]=d,i.ambient[2]=p;const _=i.hash;(_.directionalLength!==m||_.pointLength!==g||_.spotLength!==x||_.rectAreaLength!==y||_.hemiLength!==b||_.numDirectionalShadows!==v||_.numPointShadows!==S||_.numSpotShadows!==A)&&(i.directional.length=m,i.spot.length=x,i.rectArea.length=y,i.point.length=g,i.hemi.length=b,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.pointShadow.length=S,i.pointShadowMap.length=S,i.spotShadow.length=A,i.spotShadowMap.length=A,i.directionalShadowMatrix.length=v,i.pointShadowMatrix.length=S,i.spotShadowMatrix.length=A,_.directionalLength=m,_.pointLength=g,_.spotLength=x,_.rectAreaLength=y,_.hemiLength=b,_.numDirectionalShadows=v,_.numPointShadows=S,_.numSpotShadows=A,i.version=R_++)}function l(u,h){let f=0,d=0,p=0,m=0,g=0;const x=h.matrixWorldInverse;for(let y=0,b=u.length;y=t.get(s).length?(o=new Jh(a,e),t.get(s).push(o)):o=t.get(s)[r],o}function i(){t=new WeakMap}return{get:n,dispose:i}}class Iu extends Gt{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=sp,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Pu extends Gt{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new D,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const F_=`void main() { +Program Info Log: `+E+` +`+G+` +`+X)}else E!==""?console.warn("THREE.WebGLProgram: Program Info Log:",E):(F===""||U==="")&&(J=!1);J&&(this.diagnostics={runnable:q,programLog:E,vertexShader:{log:F,prefix:g},fragmentShader:{log:U,prefix:x}})}i.deleteShader(M),i.deleteShader(T);let C;this.getUniforms=function(){return C===void 0&&(C=new Ja(i,m)),C};let _;return this.getAttributes=function(){return _===void 0&&(_=l_(i,m)),_},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(m),this.program=void 0},this.name=t.shaderName,this.id=n_++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=M,this.fragmentShader=T,this}let b_=0;class w_{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),r=this._getShaderCacheForMaterial(e);return r.has(i)===!1&&(r.add(i),i.usedTimes++),r.has(s)===!1&&(r.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;return t.has(e)===!1&&t.set(e,new Set),t.get(e)}_getShaderStage(e){const t=this.shaderCache;if(t.has(e)===!1){const n=new M_(e);t.set(e,n)}return t.get(e)}}class M_{constructor(e){this.id=b_++,this.code=e,this.usedTimes=0}}function S_(a,e,t,n,i,s,r){const o=new vc,c=new w_,l=[],u=i.isWebGL2,h=i.logarithmicDepthBuffer,f=i.vertexTextures;let d=i.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(_,E,F,U,q){const J=U.fog,G=q.geometry,X=_.isMeshStandardMaterial?U.environment:null,B=(_.isMeshStandardMaterial?t:e).get(_.envMap||X),Z=!!B&&B.mapping===zr?B.image.height:null,Y=p[_.type];_.precision!==null&&(d=i.getMaxPrecision(_.precision),d!==_.precision&&console.warn("THREE.WebGLProgram.getParameters:",_.precision,"not supported, using",d,"instead."));const W=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,j=W!==void 0?W.length:0;let ne=0;G.morphAttributes.position!==void 0&&(ne=1),G.morphAttributes.normal!==void 0&&(ne=2),G.morphAttributes.color!==void 0&&(ne=3);let $,ie,ce,oe;if(Y){const Ve=Hn[Y];$=Ve.vertexShader,ie=Ve.fragmentShader}else $=_.vertexShader,ie=_.fragmentShader,c.update(_),ce=c.getVertexShaderID(_),oe=c.getFragmentShaderID(_);const H=a.getRenderTarget(),ye=_.alphaTest>0,we=_.clearcoat>0,Pe=_.iridescence>0;return{isWebGL2:u,shaderID:Y,shaderName:_.type,vertexShader:$,fragmentShader:ie,defines:_.defines,customVertexShaderID:ce,customFragmentShaderID:oe,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:d,instancing:q.isInstancedMesh===!0,instancingColor:q.isInstancedMesh===!0&&q.instanceColor!==null,supportsVertexTextures:f,outputEncoding:H===null?a.outputEncoding:H.isXRRenderTarget===!0?H.texture.encoding:bi,map:!!_.map,matcap:!!_.matcap,envMap:!!B,envMapMode:B&&B.mapping,envMapCubeUVHeight:Z,lightMap:!!_.lightMap,aoMap:!!_.aoMap,emissiveMap:!!_.emissiveMap,bumpMap:!!_.bumpMap,normalMap:!!_.normalMap,objectSpaceNormalMap:_.normalMapType===ap,tangentSpaceNormalMap:_.normalMapType===Qi,decodeVideoTexture:!!_.map&&_.map.isVideoTexture===!0&&_.map.encoding===nt,clearcoat:we,clearcoatMap:we&&!!_.clearcoatMap,clearcoatRoughnessMap:we&&!!_.clearcoatRoughnessMap,clearcoatNormalMap:we&&!!_.clearcoatNormalMap,iridescence:Pe,iridescenceMap:Pe&&!!_.iridescenceMap,iridescenceThicknessMap:Pe&&!!_.iridescenceThicknessMap,displacementMap:!!_.displacementMap,roughnessMap:!!_.roughnessMap,metalnessMap:!!_.metalnessMap,specularMap:!!_.specularMap,specularIntensityMap:!!_.specularIntensityMap,specularColorMap:!!_.specularColorMap,opaque:_.transparent===!1&&_.blending===ws,alphaMap:!!_.alphaMap,alphaTest:ye,gradientMap:!!_.gradientMap,sheen:_.sheen>0,sheenColorMap:!!_.sheenColorMap,sheenRoughnessMap:!!_.sheenRoughnessMap,transmission:_.transmission>0,transmissionMap:!!_.transmissionMap,thicknessMap:!!_.thicknessMap,combine:_.combine,vertexTangents:!!_.normalMap&&!!G.attributes.tangent,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,vertexUvs:!!_.map||!!_.bumpMap||!!_.normalMap||!!_.specularMap||!!_.alphaMap||!!_.emissiveMap||!!_.roughnessMap||!!_.metalnessMap||!!_.clearcoatMap||!!_.clearcoatRoughnessMap||!!_.clearcoatNormalMap||!!_.iridescenceMap||!!_.iridescenceThicknessMap||!!_.displacementMap||!!_.transmissionMap||!!_.thicknessMap||!!_.specularIntensityMap||!!_.specularColorMap||!!_.sheenColorMap||!!_.sheenRoughnessMap,uvsVertexOnly:!(!!_.map||!!_.bumpMap||!!_.normalMap||!!_.specularMap||!!_.alphaMap||!!_.emissiveMap||!!_.roughnessMap||!!_.metalnessMap||!!_.clearcoatNormalMap||!!_.iridescenceMap||!!_.iridescenceThicknessMap||_.transmission>0||!!_.transmissionMap||!!_.thicknessMap||!!_.specularIntensityMap||!!_.specularColorMap||_.sheen>0||!!_.sheenColorMap||!!_.sheenRoughnessMap)&&!!_.displacementMap,fog:!!J,useFog:_.fog===!0,fogExp2:J&&J.isFogExp2,flatShading:!!_.flatShading,sizeAttenuation:_.sizeAttenuation,logarithmicDepthBuffer:h,skinning:q.isSkinnedMesh===!0,morphTargets:G.morphAttributes.position!==void 0,morphNormals:G.morphAttributes.normal!==void 0,morphColors:G.morphAttributes.color!==void 0,morphTargetsCount:j,morphTextureStride:ne,numDirLights:E.directional.length,numPointLights:E.point.length,numSpotLights:E.spot.length,numRectAreaLights:E.rectArea.length,numHemiLights:E.hemi.length,numDirLightShadows:E.directionalShadowMap.length,numPointLightShadows:E.pointShadowMap.length,numSpotLightShadows:E.spotShadowMap.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:_.dithering,shadowMapEnabled:a.shadowMap.enabled&&F.length>0,shadowMapType:a.shadowMap.type,toneMapping:_.toneMapped?a.toneMapping:Jn,physicallyCorrectLights:a.physicallyCorrectLights,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===_i,flipSided:_.side===Dn,useDepthPacking:!!_.depthPacking,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionDerivatives:_.extensions&&_.extensions.derivatives,extensionFragDepth:_.extensions&&_.extensions.fragDepth,extensionDrawBuffers:_.extensions&&_.extensions.drawBuffers,extensionShaderTextureLOD:_.extensions&&_.extensions.shaderTextureLOD,rendererExtensionFragDepth:u||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||n.has("EXT_shader_texture_lod"),customProgramCacheKey:_.customProgramCacheKey()}}function g(_){const E=[];if(_.shaderID?E.push(_.shaderID):(E.push(_.customVertexShaderID),E.push(_.customFragmentShaderID)),_.defines!==void 0)for(const F in _.defines)E.push(F),E.push(_.defines[F]);return _.isRawShaderMaterial===!1&&(x(E,_),y(E,_),E.push(a.outputEncoding)),E.push(_.customProgramCacheKey),E.join()}function x(_,E){_.push(E.precision),_.push(E.outputEncoding),_.push(E.envMapMode),_.push(E.envMapCubeUVHeight),_.push(E.combine),_.push(E.vertexUvs),_.push(E.fogExp2),_.push(E.sizeAttenuation),_.push(E.morphTargetsCount),_.push(E.morphAttributeCount),_.push(E.numDirLights),_.push(E.numPointLights),_.push(E.numSpotLights),_.push(E.numHemiLights),_.push(E.numRectAreaLights),_.push(E.numDirLightShadows),_.push(E.numPointLightShadows),_.push(E.numSpotLightShadows),_.push(E.shadowMapType),_.push(E.toneMapping),_.push(E.numClippingPlanes),_.push(E.numClipIntersection),_.push(E.depthPacking)}function y(_,E){o.disableAll(),E.isWebGL2&&o.enable(0),E.supportsVertexTextures&&o.enable(1),E.instancing&&o.enable(2),E.instancingColor&&o.enable(3),E.map&&o.enable(4),E.matcap&&o.enable(5),E.envMap&&o.enable(6),E.lightMap&&o.enable(7),E.aoMap&&o.enable(8),E.emissiveMap&&o.enable(9),E.bumpMap&&o.enable(10),E.normalMap&&o.enable(11),E.objectSpaceNormalMap&&o.enable(12),E.tangentSpaceNormalMap&&o.enable(13),E.clearcoat&&o.enable(14),E.clearcoatMap&&o.enable(15),E.clearcoatRoughnessMap&&o.enable(16),E.clearcoatNormalMap&&o.enable(17),E.iridescence&&o.enable(18),E.iridescenceMap&&o.enable(19),E.iridescenceThicknessMap&&o.enable(20),E.displacementMap&&o.enable(21),E.specularMap&&o.enable(22),E.roughnessMap&&o.enable(23),E.metalnessMap&&o.enable(24),E.gradientMap&&o.enable(25),E.alphaMap&&o.enable(26),E.alphaTest&&o.enable(27),E.vertexColors&&o.enable(28),E.vertexAlphas&&o.enable(29),E.vertexUvs&&o.enable(30),E.vertexTangents&&o.enable(31),E.uvsVertexOnly&&o.enable(32),E.fog&&o.enable(33),_.push(o.mask),o.disableAll(),E.useFog&&o.enable(0),E.flatShading&&o.enable(1),E.logarithmicDepthBuffer&&o.enable(2),E.skinning&&o.enable(3),E.morphTargets&&o.enable(4),E.morphNormals&&o.enable(5),E.morphColors&&o.enable(6),E.premultipliedAlpha&&o.enable(7),E.shadowMapEnabled&&o.enable(8),E.physicallyCorrectLights&&o.enable(9),E.doubleSided&&o.enable(10),E.flipSided&&o.enable(11),E.useDepthPacking&&o.enable(12),E.dithering&&o.enable(13),E.specularIntensityMap&&o.enable(14),E.specularColorMap&&o.enable(15),E.transmission&&o.enable(16),E.transmissionMap&&o.enable(17),E.thicknessMap&&o.enable(18),E.sheen&&o.enable(19),E.sheenColorMap&&o.enable(20),E.sheenRoughnessMap&&o.enable(21),E.decodeVideoTexture&&o.enable(22),E.opaque&&o.enable(23),_.push(o.mask)}function b(_){const E=p[_.type];let F;if(E){const U=Hn[E];F=fp.clone(U.uniforms)}else F=_.uniforms;return F}function v(_,E){let F;for(let U=0,q=l.length;U0?n.push(x):d.transparent===!0?i.push(x):t.push(x)}function c(h,f,d,p,m,g){const x=r(h,f,d,p,m,g);d.transmission>0?n.unshift(x):d.transparent===!0?i.unshift(x):t.unshift(x)}function l(h,f){t.length>1&&t.sort(h||A_),n.length>1&&n.sort(f||Kh),i.length>1&&i.sort(f||Kh)}function u(){for(let h=e,f=a.length;h=a.get(n).length?(s=new Jh,a.get(n).push(s)):s=a.get(n)[i],s}function t(){a=new WeakMap}return{get:e,dispose:t}}function C_(){const a={};return{get:function(e){if(a[e.id]!==void 0)return a[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new P,color:new be};break;case"SpotLight":t={position:new P,direction:new P,color:new be,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new P,color:new be,distance:0,decay:0};break;case"HemisphereLight":t={direction:new P,skyColor:new be,groundColor:new be};break;case"RectAreaLight":t={color:new be,position:new P,halfWidth:new P,halfHeight:new P};break}return a[e.id]=t,t}}}function L_(){const a={};return{get:function(e){if(a[e.id]!==void 0)return a[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new de};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new de};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new de,shadowCameraNear:1,shadowCameraFar:1e3};break}return a[e.id]=t,t}}}let R_=0;function I_(a,e){return(e.castShadow?1:0)-(a.castShadow?1:0)}function P_(a,e){const t=new C_,n=L_(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let u=0;u<9;u++)i.probe.push(new P);const s=new P,r=new De,o=new De;function c(u,h){let f=0,d=0,p=0;for(let E=0;E<9;E++)i.probe[E].set(0,0,0);let m=0,g=0,x=0,y=0,b=0,v=0,M=0,T=0;u.sort(I_);const C=h!==!0?Math.PI:1;for(let E=0,F=u.length;E0&&(e.isWebGL2||a.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ie.LTC_FLOAT_1,i.rectAreaLTC2=Ie.LTC_FLOAT_2):a.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Ie.LTC_HALF_1,i.rectAreaLTC2=Ie.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=f,i.ambient[1]=d,i.ambient[2]=p;const _=i.hash;(_.directionalLength!==m||_.pointLength!==g||_.spotLength!==x||_.rectAreaLength!==y||_.hemiLength!==b||_.numDirectionalShadows!==v||_.numPointShadows!==M||_.numSpotShadows!==T)&&(i.directional.length=m,i.spot.length=x,i.rectArea.length=y,i.point.length=g,i.hemi.length=b,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.pointShadow.length=M,i.pointShadowMap.length=M,i.spotShadow.length=T,i.spotShadowMap.length=T,i.directionalShadowMatrix.length=v,i.pointShadowMatrix.length=M,i.spotShadowMatrix.length=T,_.directionalLength=m,_.pointLength=g,_.spotLength=x,_.rectAreaLength=y,_.hemiLength=b,_.numDirectionalShadows=v,_.numPointShadows=M,_.numSpotShadows=T,i.version=R_++)}function l(u,h){let f=0,d=0,p=0,m=0,g=0;const x=h.matrixWorldInverse;for(let y=0,b=u.length;y=t.get(s).length?(o=new $h(a,e),t.get(s).push(o)):o=t.get(s)[r],o}function i(){t=new WeakMap}return{get:n,dispose:i}}class Pu extends Gt{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=rp,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Du extends Gt{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new P,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const F_=`void main() { gl_Position = vec4( position, 1.0 ); }`,N_=`uniform sampler2D shadow_pass; uniform vec2 resolution; @@ -3138,22 +3138,22 @@ void main() { squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); -}`;function k_(a,e,t){let n=new bc;const i=new fe,s=new fe,r=new dt,o=new Iu({depthPacking:rp}),c=new Pu,l={},u=t.maxTextureSize,h={0:Dn,1:vi,2:_i},f=new ei({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new fe},radius:{value:4}},vertexShader:F_,fragmentShader:N_}),d=f.clone();d.defines.HORIZONTAL_PASS=1;const p=new Xe;p.setAttribute("position",new pt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new Tt(p,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=_u,this.render=function(v,S,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||v.length===0)return;const R=a.getRenderTarget(),_=a.getActiveCubeFace(),L=a.getActiveMipmapLevel(),N=a.state;N.setBlending(xi),N.buffers.color.setClear(1,1,1,1),N.buffers.depth.setTest(!0),N.setScissorTest(!1);for(let B=0,W=v.length;Bu||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/q.x),i.x=s.x*q.x,z.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/q.y),i.y=s.y*q.y,z.mapSize.y=s.y)),z.map===null){const Y=this.type!==dr?{minFilter:Bt,magFilter:Bt}:{};z.map=new kn(i.x,i.y,Y),z.map.texture.name=K.name+".shadowMap",z.camera.updateProjectionMatrix()}a.setRenderTarget(z.map),a.clear();const O=z.getViewportCount();for(let Y=0;Y0){const W=N.uuid,K=S.uuid;let z=l[W];z===void 0&&(z={},l[W]=z);let q=z[K];q===void 0&&(q=N.clone(),z[K]=q),N=q}return N.visible=S.visible,N.wireframe=S.wireframe,L===dr?N.side=S.shadowSide!==null?S.shadowSide:S.side:N.side=S.shadowSide!==null?S.shadowSide:h[S.side],N.alphaMap=S.alphaMap,N.alphaTest=S.alphaTest,N.clipShadows=S.clipShadows,N.clippingPlanes=S.clippingPlanes,N.clipIntersection=S.clipIntersection,N.displacementMap=S.displacementMap,N.displacementScale=S.displacementScale,N.displacementBias=S.displacementBias,N.wireframeLinewidth=S.wireframeLinewidth,N.linewidth=S.linewidth,A.isPointLight===!0&&N.isMeshDistanceMaterial===!0&&(N.referencePosition.setFromMatrixPosition(A.matrixWorld),N.nearDistance=R,N.farDistance=_),N}function b(v,S,A,R,_){if(v.visible===!1)return;if(v.layers.test(S.layers)&&(v.isMesh||v.isLine||v.isPoints)&&(v.castShadow||v.receiveShadow&&_===dr)&&(!v.frustumCulled||n.intersectsObject(v))){v.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,v.matrixWorld);const B=e.update(v),W=v.material;if(Array.isArray(W)){const K=B.groups;for(let z=0,q=K.length;z=1):j.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),O=Y>=2);let H=null,X={};const te=a.getParameter(3088),J=a.getParameter(2978),ne=new dt().fromArray(te),re=new dt().fromArray(J);function se(G,Te,oe){const Ce=new Uint8Array(4),Pe=a.createTexture();a.bindTexture(G,Pe),a.texParameteri(G,10241,9728),a.texParameteri(G,10240,9728);for(let ht=0;htZ||E.height>Z)&&(Q=Z/Math.max(E.width,E.height)),Q<1||w===!0)if(typeof HTMLImageElement!="undefined"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&E instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&E instanceof ImageBitmap){const de=w?ic:Math.floor,Le=de(Q*E.width),F=de(Q*E.height);m===void 0&&(m=y(Le,F));const ue=U?y(Le,F):m;return ue.width=Le,ue.height=F,ue.getContext("2d").drawImage(E,0,0,Le,F),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+E.width+"x"+E.height+") to ("+Le+"x"+F+")."),ue}else return"data"in E&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+E.width+"x"+E.height+")."),E;return E}function v(E){return eu(E.width)&&eu(E.height)}function S(E){return o?!1:E.wrapS!==jt||E.wrapT!==jt||E.minFilter!==Bt&&E.minFilter!==Rt}function A(E,w){return E.generateMipmaps&&w&&E.minFilter!==Bt&&E.minFilter!==Rt}function R(E){a.generateMipmap(E)}function _(E,w,U,Z,Q=!1){if(o===!1)return w;if(E!==null){if(a[E]!==void 0)return a[E];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let de=w;return w===6403&&(U===5126&&(de=33326),U===5131&&(de=33325),U===5121&&(de=33321)),w===33319&&(U===5126&&(de=33328),U===5131&&(de=33327),U===5121&&(de=33323)),w===6408&&(U===5126&&(de=34836),U===5131&&(de=34842),U===5121&&(de=Z===tt&&Q===!1?35907:32856),U===32819&&(de=32854),U===32820&&(de=32855)),(de===33325||de===33326||de===33327||de===33328||de===34842||de===34836)&&e.get("EXT_color_buffer_float"),de}function L(E,w,U){return A(E,U)===!0||E.isFramebufferTexture&&E.minFilter!==Bt&&E.minFilter!==Rt?Math.log2(Math.max(w.width,w.height))+1:E.mipmaps!==void 0&&E.mipmaps.length>0?E.mipmaps.length:E.isCompressedTexture&&Array.isArray(E.image)?w.mipmaps.length:1}function N(E){return E===Bt||E===bo||E===wo?9728:9729}function B(E){const w=E.target;w.removeEventListener("dispose",B),K(w),w.isVideoTexture&&p.delete(w)}function W(E){const w=E.target;w.removeEventListener("dispose",W),q(w)}function K(E){const w=n.get(E);if(w.__webglInit===void 0)return;const U=E.source,Z=g.get(U);if(Z){const Q=Z[w.__cacheKey];Q.usedTimes--,Q.usedTimes===0&&z(E),Object.keys(Z).length===0&&g.delete(U)}n.remove(E)}function z(E){const w=n.get(E);a.deleteTexture(w.__webglTexture);const U=E.source,Z=g.get(U);delete Z[w.__cacheKey],r.memory.textures--}function q(E){const w=E.texture,U=n.get(E),Z=n.get(w);if(Z.__webglTexture!==void 0&&(a.deleteTexture(Z.__webglTexture),r.memory.textures--),E.depthTexture&&E.depthTexture.dispose(),E.isWebGLCubeRenderTarget)for(let Q=0;Q<6;Q++)a.deleteFramebuffer(U.__webglFramebuffer[Q]),U.__webglDepthbuffer&&a.deleteRenderbuffer(U.__webglDepthbuffer[Q]);else{if(a.deleteFramebuffer(U.__webglFramebuffer),U.__webglDepthbuffer&&a.deleteRenderbuffer(U.__webglDepthbuffer),U.__webglMultisampledFramebuffer&&a.deleteFramebuffer(U.__webglMultisampledFramebuffer),U.__webglColorRenderbuffer)for(let Q=0;Q=c&&console.warn("THREE.WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+c),O+=1,E}function H(E){const w=[];return w.push(E.wrapS),w.push(E.wrapT),w.push(E.magFilter),w.push(E.minFilter),w.push(E.anisotropy),w.push(E.internalFormat),w.push(E.format),w.push(E.type),w.push(E.generateMipmaps),w.push(E.premultiplyAlpha),w.push(E.flipY),w.push(E.unpackAlignment),w.push(E.encoding),w.join()}function X(E,w){const U=n.get(E);if(E.isVideoTexture&&ut(E),E.isRenderTargetTexture===!1&&E.version>0&&U.__version!==E.version){const Z=E.image;if(Z===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Z.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{_e(U,E,w);return}}t.activeTexture(33984+w),t.bindTexture(3553,U.__webglTexture)}function te(E,w){const U=n.get(E);if(E.version>0&&U.__version!==E.version){_e(U,E,w);return}t.activeTexture(33984+w),t.bindTexture(35866,U.__webglTexture)}function J(E,w){const U=n.get(E);if(E.version>0&&U.__version!==E.version){_e(U,E,w);return}t.activeTexture(33984+w),t.bindTexture(32879,U.__webglTexture)}function ne(E,w){const U=n.get(E);if(E.version>0&&U.__version!==E.version){Ie(U,E,w);return}t.activeTexture(33984+w),t.bindTexture(34067,U.__webglTexture)}const re={[cn]:10497,[jt]:33071,[_r]:33648},se={[Bt]:9728,[bo]:9984,[wo]:9986,[Rt]:9729,[mc]:9985,[si]:9987};function V(E,w,U){if(U?(a.texParameteri(E,10242,re[w.wrapS]),a.texParameteri(E,10243,re[w.wrapT]),(E===32879||E===35866)&&a.texParameteri(E,32882,re[w.wrapR]),a.texParameteri(E,10240,se[w.magFilter]),a.texParameteri(E,10241,se[w.minFilter])):(a.texParameteri(E,10242,33071),a.texParameteri(E,10243,33071),(E===32879||E===35866)&&a.texParameteri(E,32882,33071),(w.wrapS!==jt||w.wrapT!==jt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),a.texParameteri(E,10240,N(w.magFilter)),a.texParameteri(E,10241,N(w.minFilter)),w.minFilter!==Bt&&w.minFilter!==Rt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){const Z=e.get("EXT_texture_filter_anisotropic");if(w.type===gi&&e.has("OES_texture_float_linear")===!1||o===!1&&w.type===br&&e.has("OES_texture_half_float_linear")===!1)return;(w.anisotropy>1||n.get(w).__currentAnisotropy)&&(a.texParameterf(E,Z.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(w.anisotropy,i.getMaxAnisotropy())),n.get(w).__currentAnisotropy=w.anisotropy)}}function me(E,w){let U=!1;E.__webglInit===void 0&&(E.__webglInit=!0,w.addEventListener("dispose",B));const Z=w.source;let Q=g.get(Z);Q===void 0&&(Q={},g.set(Z,Q));const de=H(w);if(de!==E.__cacheKey){Q[de]===void 0&&(Q[de]={texture:a.createTexture(),usedTimes:0},r.memory.textures++,U=!0),Q[de].usedTimes++;const Le=Q[E.__cacheKey];Le!==void 0&&(Q[E.__cacheKey].usedTimes--,Le.usedTimes===0&&z(w)),E.__cacheKey=de,E.__webglTexture=Q[de].texture}return U}function _e(E,w,U){let Z=3553;w.isDataArrayTexture&&(Z=35866),w.isData3DTexture&&(Z=32879);const Q=me(E,w),de=w.source;if(t.activeTexture(33984+U),t.bindTexture(Z,E.__webglTexture),de.version!==de.__currentVersion||Q===!0){a.pixelStorei(37440,w.flipY),a.pixelStorei(37441,w.premultiplyAlpha),a.pixelStorei(3317,w.unpackAlignment),a.pixelStorei(37443,0);const Le=S(w)&&v(w.image)===!1;let F=b(w.image,Le,!1,u);F=ot(w,F);const ue=v(F)||o,ge=s.convert(w.format,w.encoding);let Ee=s.convert(w.type),Se=_(w.internalFormat,ge,Ee,w.encoding,w.isVideoTexture);V(Z,w,ue);let Oe;const qe=w.mipmaps,$e=o&&w.isVideoTexture!==!0,G=de.__currentVersion===void 0||Q===!0,Te=L(w,F,ue);if(w.isDepthTexture)Se=6402,o?w.type===gi?Se=36012:w.type===Gi?Se=33190:w.type===Ms?Se=35056:Se=33189:w.type===gi&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),w.format===Wi&&Se===6402&&w.type!==Mu&&w.type!==Gi&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),w.type=Gi,Ee=s.convert(w.type)),w.format===Es&&Se===6402&&(Se=34041,w.type!==Ms&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),w.type=Ms,Ee=s.convert(w.type))),G&&($e?t.texStorage2D(3553,1,Se,F.width,F.height):t.texImage2D(3553,0,Se,F.width,F.height,0,ge,Ee,null));else if(w.isDataTexture)if(qe.length>0&&ue){$e&&G&&t.texStorage2D(3553,Te,Se,qe[0].width,qe[0].height);for(let oe=0,Ce=qe.length;oe>=1,Ce>>=1}}else if(qe.length>0&&ue){$e&&G&&t.texStorage2D(3553,Te,Se,qe[0].width,qe[0].height);for(let oe=0,Ce=qe.length;oe0&&G++,t.texStorage2D(34067,G,Oe,F[0].width,F[0].height));for(let oe=0;oe<6;oe++)if(Le){qe?t.texSubImage2D(34069+oe,0,0,0,F[oe].width,F[oe].height,Ee,Se,F[oe].data):t.texImage2D(34069+oe,0,Oe,F[oe].width,F[oe].height,0,Ee,Se,F[oe].data);for(let Ce=0;Ce0&&ze(E)===!1){const F=de?w:[w];U.__webglMultisampledFramebuffer=a.createFramebuffer(),U.__webglColorRenderbuffer=[],t.bindFramebuffer(36160,U.__webglMultisampledFramebuffer);for(let ue=0;ue0&&ze(E)===!1){const w=E.isWebGLMultipleRenderTargets?E.texture:[E.texture],U=E.width,Z=E.height;let Q=16384;const de=[],Le=E.stencilBuffer?33306:36096,F=n.get(E),ue=E.isWebGLMultipleRenderTargets===!0;if(ue)for(let ge=0;ge0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&w.__useRenderToTexture!==!1}function ut(E){const w=r.render.frame;p.get(E)!==w&&(p.set(E,w),E.update())}function ot(E,w){const U=E.encoding,Z=E.format,Q=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||E.format===nc||U!==bi&&(U===tt?o===!1?e.has("EXT_sRGB")===!0&&Z===Mn?(E.format=nc,E.minFilter=Rt,E.generateMipmaps=!1):w=Cu.sRGBToLinear(w):(Z!==Mn||Q!==Yi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",U)),w}this.allocateTextureUnit=j,this.resetTextureUnits=Y,this.setTexture2D=X,this.setTexture2DArray=te,this.setTexture3D=J,this.setTextureCube=ne,this.rebindTextures=xe,this.setupRenderTarget=Fe,this.updateRenderTargetMipmap=Me,this.updateMultisampleRenderTarget=Ye,this.setupDepthRenderbuffer=ce,this.setupFrameBufferTexture=ye,this.useMultisampledRTT=ze}function _p(a,e,t){const n=t.isWebGL2;function i(s,r=null){let o;if(s===Yi)return 5121;if(s===Hd)return 32819;if(s===Wd)return 32820;if(s===Ud)return 5120;if(s===Gd)return 5122;if(s===Mu)return 5123;if(s===Vd)return 5124;if(s===Gi)return 5125;if(s===gi)return 5126;if(s===br)return n?5131:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===qd)return 6406;if(s===Mn)return 6408;if(s===jd)return 6409;if(s===Yd)return 6410;if(s===Wi)return 6402;if(s===Es)return 34041;if(s===Zd)return 6403;if(s===Xd)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(s===nc)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(s===Kd)return 36244;if(s===Jd)return 33319;if(s===$d)return 33320;if(s===Qd)return 36249;if(s===ho||s===ja||s===fo||s===po)if(r===tt)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(s===ho)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===ja)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===fo)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===po)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===ho)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===ja)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===fo)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===po)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Pl||s===Dl||s===Fl||s===Nl)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===Pl)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Dl)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Fl)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Nl)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===Su)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===kl||s===Ol)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(s===kl)return r===tt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(s===Ol)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===Bl||s===zl||s===Ul||s===Gl||s===Vl||s===Hl||s===Wl||s===ql||s===Xl||s===jl||s===Yl||s===Zl||s===Kl||s===Jl)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(s===Bl)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===zl)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===Ul)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===Gl)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Vl)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Hl)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===Wl)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===ql)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===Xl)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===jl)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Yl)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===Zl)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Kl)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===Jl)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===$l)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(s===$l)return r===tt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;return s===Ms?n?34042:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):a[s]!==void 0?a[s]:null}return{convert:i}}class bp extends Dt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class yn extends lt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const z_={type:"move"};class ll{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new yn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new yn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new D,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new D),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new yn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new D,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new D),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,s=null,r=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){r=!0;for(const m of e.hand.values()){const g=t.getJointPose(m,n);if(l.joints[m.jointName]===void 0){const y=new yn;y.matrixAutoUpdate=!1,y.visible=!1,l.joints[m.jointName]=y,l.add(y)}const x=l.joints[m.jointName];g!==null&&(x.matrix.fromArray(g.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.jointRadius=g.radius),x.visible=g!==null}const u=l.joints["index-finger-tip"],h=l.joints["thumb-tip"],f=u.position.distanceTo(h.position),d=.02,p=.005;l.inputState.pinching&&f>d+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&f<=d-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(z_)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=r!==null),this}}class wp extends At{constructor(e,t,n,i,s,r,o,c,l,u){if(u=u!==void 0?u:Wi,u!==Wi&&u!==Es)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&u===Wi&&(n=Gi),n===void 0&&u===Es&&(n=Ms),super(null,i,s,r,o,c,u,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=o!==void 0?o:Bt,this.minFilter=c!==void 0?c:Bt,this.flipY=!1,this.generateMipmaps=!1}}class U_ extends ri{constructor(e,t){super();const n=this;let i=null,s=1,r=null,o="local-floor",c=null,l=null,u=null,h=null,f=null,d=null;const p=t.getContextAttributes();let m=null,g=null;const x=[],y=[],b=new Dt;b.layers.enable(1),b.viewport=new dt;const v=new Dt;v.layers.enable(2),v.viewport=new dt;const S=[b,v],A=new bp;A.layers.enable(1),A.layers.enable(2);let R=null,_=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(H){let X=x[H];return X===void 0&&(X=new ll,x[H]=X),X.getTargetRaySpace()},this.getControllerGrip=function(H){let X=x[H];return X===void 0&&(X=new ll,x[H]=X),X.getGripSpace()},this.getHand=function(H){let X=x[H];return X===void 0&&(X=new ll,x[H]=X),X.getHandSpace()};function L(H){const X=y.indexOf(H.inputSource);if(X===-1)return;const te=x[X];te!==void 0&&te.dispatchEvent({type:H.type,data:H.inputSource})}function N(){i.removeEventListener("select",L),i.removeEventListener("selectstart",L),i.removeEventListener("selectend",L),i.removeEventListener("squeeze",L),i.removeEventListener("squeezestart",L),i.removeEventListener("squeezeend",L),i.removeEventListener("end",N),i.removeEventListener("inputsourceschange",B);for(let H=0;H=0&&(y[J]=null,x[J].dispatchEvent({type:"disconnected",data:te}))}for(let X=0;X=y.length){y.push(te),J=re;break}else if(y[re]===null){y[re]=te,J=re;break}if(J===-1)break}const ne=x[J];ne&&ne.dispatchEvent({type:"connected",data:te})}}const W=new D,K=new D;function z(H,X,te){W.setFromMatrixPosition(X.matrixWorld),K.setFromMatrixPosition(te.matrixWorld);const J=W.distanceTo(K),ne=X.projectionMatrix.elements,re=te.projectionMatrix.elements,se=ne[14]/(ne[10]-1),V=ne[14]/(ne[10]+1),me=(ne[9]+1)/ne[5],_e=(ne[9]-1)/ne[5],Ie=(ne[8]-1)/ne[0],ye=(re[8]+1)/re[0],He=se*Ie,le=se*ye,ce=J/(-Ie+ye),xe=ce*-Ie;X.matrixWorld.decompose(H.position,H.quaternion,H.scale),H.translateX(xe),H.translateZ(ce),H.matrixWorld.compose(H.position,H.quaternion,H.scale),H.matrixWorldInverse.copy(H.matrixWorld).invert();const Fe=se+ce,Me=V+ce,Ye=He-xe,Ue=le+(J-xe),ze=me*V/Me*Fe,ut=_e*V/Me*Fe;H.projectionMatrix.makePerspective(Ye,Ue,ze,ut,Fe,Me)}function q(H,X){X===null?H.matrixWorld.copy(H.matrix):H.matrixWorld.multiplyMatrices(X.matrixWorld,H.matrix),H.matrixWorldInverse.copy(H.matrixWorld).invert()}this.updateCamera=function(H){if(i===null)return;A.near=v.near=b.near=H.near,A.far=v.far=b.far=H.far,(R!==A.near||_!==A.far)&&(i.updateRenderState({depthNear:A.near,depthFar:A.far}),R=A.near,_=A.far);const X=H.parent,te=A.cameras;q(A,X);for(let ne=0;ne0&&(m.alphaTest.value=g.alphaTest);const x=e.get(g).envMap;if(x&&(m.envMap.value=x,m.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap){m.lightMap.value=g.lightMap;const v=a.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*v}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity);let y;g.map?y=g.map:g.specularMap?y=g.specularMap:g.displacementMap?y=g.displacementMap:g.normalMap?y=g.normalMap:g.bumpMap?y=g.bumpMap:g.roughnessMap?y=g.roughnessMap:g.metalnessMap?y=g.metalnessMap:g.alphaMap?y=g.alphaMap:g.emissiveMap?y=g.emissiveMap:g.clearcoatMap?y=g.clearcoatMap:g.clearcoatNormalMap?y=g.clearcoatNormalMap:g.clearcoatRoughnessMap?y=g.clearcoatRoughnessMap:g.iridescenceMap?y=g.iridescenceMap:g.iridescenceThicknessMap?y=g.iridescenceThicknessMap:g.specularIntensityMap?y=g.specularIntensityMap:g.specularColorMap?y=g.specularColorMap:g.transmissionMap?y=g.transmissionMap:g.thicknessMap?y=g.thicknessMap:g.sheenColorMap?y=g.sheenColorMap:g.sheenRoughnessMap&&(y=g.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix));let b;g.aoMap?b=g.aoMap:g.lightMap&&(b=g.lightMap),b!==void 0&&(b.isWebGLRenderTarget&&(b=b.texture),b.matrixAutoUpdate===!0&&b.updateMatrix(),m.uv2Transform.value.copy(b.matrix))}function s(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity}function r(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function o(m,g,x,y){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*x,m.scale.value=y*.5,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let b;g.map?b=g.map:g.alphaMap&&(b=g.alphaMap),b!==void 0&&(b.matrixAutoUpdate===!0&&b.updateMatrix(),m.uvTransform.value.copy(b.matrix))}function c(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uvTransform.value.copy(x.matrix))}function l(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function u(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function h(m,g){m.roughness.value=g.roughness,m.metalness.value=g.metalness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap),e.get(g).envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,x){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),m.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===Dn&&m.clearcoatNormalScale.value.negate())),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=x.texture,m.transmissionSamplerSize.value.set(x.width,x.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap)}function d(m,g){g.matcap&&(m.matcap.value=g.matcap)}function p(m,g){m.referencePosition.value.copy(g.referencePosition),m.nearDistance.value=g.nearDistance,m.farDistance.value=g.farDistance}return{refreshFogUniforms:t,refreshMaterialUniforms:n}}function V_(a,e,t,n){let i={},s={},r=[];const o=t.isWebGL2?a.getParameter(35375):0;function c(y,b){const v=b.program;n.uniformBlockBinding(y,v)}function l(y,b){let v=i[y.id];v===void 0&&(p(y),v=u(y),i[y.id]=v,y.addEventListener("dispose",g));const S=b.program;n.updateUBOMapping(y,S);const A=e.render.frame;s[y.id]!==A&&(f(y),s[y.id]=A)}function u(y){const b=h();y.__bindingPointIndex=b;const v=a.createBuffer(),S=y.__size,A=y.usage;return a.bindBuffer(35345,v),a.bufferData(35345,S,A),a.bindBuffer(35345,null),a.bindBufferBase(35345,b,v),v}function h(){for(let y=0;y0){A=v%S;const B=S-A;A!==0&&B-N.boundary<0&&(v+=S-A,L.__offset=v)}v+=N.storage}return A=v%S,A>0&&(v+=S-A),y.__size=v,y.__cache={},this}function m(y){const b=y.value,v={boundary:0,storage:0};return typeof b=="number"?(v.boundary=4,v.storage=4):b.isVector2?(v.boundary=8,v.storage=8):b.isVector3||b.isColor?(v.boundary=16,v.storage=12):b.isVector4?(v.boundary=16,v.storage=16):b.isMatrix3?(v.boundary=48,v.storage=48):b.isMatrix4?(v.boundary=64,v.storage=64):b.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",b),v}function g(y){const b=y.target;b.removeEventListener("dispose",g);const v=r.indexOf(b.__bindingPointIndex);r.splice(v,1),a.deleteBuffer(i[b.id]),delete i[b.id],delete s[b.id]}function x(){for(const y in i)a.deleteBuffer(i[y]);r=[],i={},s={}}return{bind:c,update:l,dispose:x}}function H_(){const a=Ao("canvas");return a.style.display="block",a}function Du(a={}){this.isWebGLRenderer=!0;const e=a.canvas!==void 0?a.canvas:H_(),t=a.context!==void 0?a.context:null,n=a.depth!==void 0?a.depth:!0,i=a.stencil!==void 0?a.stencil:!0,s=a.antialias!==void 0?a.antialias:!1,r=a.premultipliedAlpha!==void 0?a.premultipliedAlpha:!0,o=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,c=a.powerPreference!==void 0?a.powerPreference:"default",l=a.failIfMajorPerformanceCaveat!==void 0?a.failIfMajorPerformanceCaveat:!1;let u;t!==null?u=t.getContextAttributes().alpha:u=a.alpha!==void 0?a.alpha:!1;let h=null,f=null;const d=[],p=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=bi,this.physicallyCorrectLights=!1,this.toneMapping=Jn,this.toneMappingExposure=1,Object.defineProperties(this,{gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});const m=this;let g=!1,x=0,y=0,b=null,v=-1,S=null;const A=new dt,R=new dt;let _=null,L=e.width,N=e.height,B=1,W=null,K=null;const z=new dt(0,0,L,N),q=new dt(0,0,L,N);let O=!1;const Y=new bc;let j=!1,H=!1,X=null;const te=new De,J=new fe,ne=new D,re={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function se(){return b===null?B:1}let V=t;function me(k,$){for(let ae=0;ae0?f=p[p.length-1]:f=null,d.pop(),d.length>0?h=d[d.length-1]:h=null};function Xn(k,$,ae,ee){if(k.visible===!1)return;if(k.layers.test($.layers)){if(k.isGroup)ae=k.renderOrder;else if(k.isLOD)k.autoUpdate===!0&&k.update($);else if(k.isLight)f.pushLight(k),k.castShadow&&f.pushShadow(k);else if(k.isSprite){if(!k.frustumCulled||Y.intersectsSprite(k)){ee&&ne.setFromMatrixPosition(k.matrixWorld).applyMatrix4(te);const Je=Ue.update(k),et=k.material;et.visible&&h.push(k,Je,et,ae,ne.z,null)}}else if((k.isMesh||k.isLine||k.isPoints)&&(k.isSkinnedMesh&&k.skeleton.frame!==He.render.frame&&(k.skeleton.update(),k.skeleton.frame=He.render.frame),!k.frustumCulled||Y.intersectsObject(k))){ee&&ne.setFromMatrixPosition(k.matrixWorld).applyMatrix4(te);const Je=Ue.update(k),et=k.material;if(Array.isArray(et)){const Qe=Je.groups;for(let xt=0,ct=Qe.length;xt0&&zn(pe,$,ae),ee&&ye.viewport(A.copy(ee)),pe.length>0&&Mt(pe,$,ae),Ke.length>0&&Mt(Ke,$,ae),Je.length>0&&Mt(Je,$,ae),ye.buffers.depth.setTest(!0),ye.buffers.depth.setMask(!0),ye.buffers.color.setMask(!0),ye.setPolygonOffset(!1)}function zn(k,$,ae){const ee=Ie.isWebGL2;X===null&&(X=new kn(1,1,{generateMipmaps:!0,type:_e.has("EXT_color_buffer_half_float")?br:Yi,minFilter:si,samples:ee&&s===!0?4:0})),m.getDrawingBufferSize(J),ee?X.setSize(J.x,J.y):X.setSize(ic(J.x),ic(J.y));const pe=m.getRenderTarget();m.setRenderTarget(X),m.clear();const Ke=m.toneMapping;m.toneMapping=Jn,Mt(k,$,ae),m.toneMapping=Ke,ce.updateMultisampleRenderTarget(X),ce.updateRenderTargetMipmap(X),m.setRenderTarget(pe)}function Mt(k,$,ae){const ee=$.isScene===!0?$.overrideMaterial:null;for(let pe=0,Ke=k.length;pe0&&ce.useMultisampledRTT(k)===!1?pe=le.get(k).__webglMultisampledFramebuffer:pe=xt,A.copy(k.viewport),R.copy(k.scissor),_=k.scissorTest}else A.copy(z).multiplyScalar(B).floor(),R.copy(q).multiplyScalar(B).floor(),_=O;if(ye.bindFramebuffer(36160,pe)&&Ie.drawBuffers&&ee&&ye.drawBuffers(k,pe),ye.viewport(A),ye.scissor(R),ye.setScissorTest(_),Ke){const Qe=le.get(k.texture);V.framebufferTexture2D(36160,36064,34069+$,Qe.__webglTexture,ae)}else if(Je){const Qe=le.get(k.texture),xt=$||0;V.framebufferTextureLayer(36160,36064,Qe.__webglTexture,ae||0,xt)}v=-1},this.readRenderTargetPixels=function(k,$,ae,ee,pe,Ke,Je){if(!(k&&k.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let et=le.get(k).__webglFramebuffer;if(k.isWebGLCubeRenderTarget&&Je!==void 0&&(et=et[Je]),et){ye.bindFramebuffer(36160,et);try{const Qe=k.texture,xt=Qe.format,ct=Qe.type;if(xt!==Mn&&F.convert(xt)!==V.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ft=ct===br&&(_e.has("EXT_color_buffer_half_float")||Ie.isWebGL2&&_e.has("EXT_color_buffer_float"));if(ct!==Yi&&F.convert(ct)!==V.getParameter(35738)&&!(ct===gi&&(Ie.isWebGL2||_e.has("OES_texture_float")||_e.has("WEBGL_color_buffer_float")))&&!ft){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}$>=0&&$<=k.width-ee&&ae>=0&&ae<=k.height-pe&&V.readPixels($,ae,ee,pe,F.convert(xt),F.convert(ct),Ke)}finally{const Qe=b!==null?le.get(b).__webglFramebuffer:null;ye.bindFramebuffer(36160,Qe)}}},this.copyFramebufferToTexture=function(k,$,ae=0){const ee=Math.pow(2,-ae),pe=Math.floor($.image.width*ee),Ke=Math.floor($.image.height*ee);ce.setTexture2D($,0),V.copyTexSubImage2D(3553,ae,0,0,k.x,k.y,pe,Ke),ye.unbindTexture()},this.copyTextureToTexture=function(k,$,ae,ee=0){const pe=$.image.width,Ke=$.image.height,Je=F.convert(ae.format),et=F.convert(ae.type);ce.setTexture2D(ae,0),V.pixelStorei(37440,ae.flipY),V.pixelStorei(37441,ae.premultiplyAlpha),V.pixelStorei(3317,ae.unpackAlignment),$.isDataTexture?V.texSubImage2D(3553,ee,k.x,k.y,pe,Ke,Je,et,$.image.data):$.isCompressedTexture?V.compressedTexSubImage2D(3553,ee,k.x,k.y,$.mipmaps[0].width,$.mipmaps[0].height,Je,$.mipmaps[0].data):V.texSubImage2D(3553,ee,k.x,k.y,Je,et,$.image),ee===0&&ae.generateMipmaps&&V.generateMipmap(3553),ye.unbindTexture()},this.copyTextureToTexture3D=function(k,$,ae,ee,pe=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Ke=k.max.x-k.min.x+1,Je=k.max.y-k.min.y+1,et=k.max.z-k.min.z+1,Qe=F.convert(ee.format),xt=F.convert(ee.type);let ct;if(ee.isData3DTexture)ce.setTexture3D(ee,0),ct=32879;else if(ee.isDataArrayTexture)ce.setTexture2DArray(ee,0),ct=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}V.pixelStorei(37440,ee.flipY),V.pixelStorei(37441,ee.premultiplyAlpha),V.pixelStorei(3317,ee.unpackAlignment);const ft=V.getParameter(3314),St=V.getParameter(32878),oi=V.getParameter(3316),qt=V.getParameter(3315),_n=V.getParameter(32877),dn=ae.isCompressedTexture?ae.mipmaps[0]:ae.image;V.pixelStorei(3314,dn.width),V.pixelStorei(32878,dn.height),V.pixelStorei(3316,k.min.x),V.pixelStorei(3315,k.min.y),V.pixelStorei(32877,k.min.z),ae.isDataTexture||ae.isData3DTexture?V.texSubImage3D(ct,pe,$.x,$.y,$.z,Ke,Je,et,Qe,xt,dn.data):ae.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),V.compressedTexSubImage3D(ct,pe,$.x,$.y,$.z,Ke,Je,et,Qe,dn.data)):V.texSubImage3D(ct,pe,$.x,$.y,$.z,Ke,Je,et,Qe,xt,dn),V.pixelStorei(3314,ft),V.pixelStorei(32878,St),V.pixelStorei(3316,oi),V.pixelStorei(3315,qt),V.pixelStorei(32877,_n),pe===0&&ee.generateMipmaps&&V.generateMipmap(ct),ye.unbindTexture()},this.initTexture=function(k){k.isCubeTexture?ce.setTextureCube(k,0):k.isData3DTexture?ce.setTexture3D(k,0):k.isDataArrayTexture?ce.setTexture2DArray(k,0):ce.setTexture2D(k,0),ye.unbindTexture()},this.resetState=function(){x=0,y=0,b=null,ye.reset(),ue.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class Mp extends Du{}Mp.prototype.isWebGL1Renderer=!0;class Mc{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new ve(e),this.density=t}clone(){return new Mc(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class Sc{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new ve(e),this.near=t,this.far=n}clone(){return new Sc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class Tc extends lt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}}class Go{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=So,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Sn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;ie.far||t.push({distance:c,point:io.clone(),uv:In.getUV(io,wa,ro,Ma,$h,ul,Qh,new fe),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Sa(a,e,t,n,i,s){lr.subVectors(a,t).addScalar(.5).multiply(n),i!==void 0?(so.x=s*lr.x-i*lr.y,so.y=i*lr.x+s*lr.y):so.copy(lr),a.copy(e),a.x+=so.x,a.y+=so.y,a.applyMatrix4(Sp)}const Ta=new D,ef=new D;class Tp extends lt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n0){let n,i;for(n=1,i=t.length;n0){Ta.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Ta);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Ta.setFromMatrixPosition(e.matrixWorld),ef.setFromMatrixPosition(this.matrixWorld);const n=Ta.distanceTo(ef)/e.zoom;t[0].object.visible=!0;let i,s;for(i=1,s=t.length;i=t[i].distance;i++)t[i-1].object.visible=!1,t[i].object.visible=!0;for(this._currentLevel=i-1;ic)continue;f.applyMatrix4(this.matrixWorld);const _=e.ray.origin.distanceTo(f);_e.far||t.push({distance:_,point:h.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}else{const x=Math.max(0,r.start),y=Math.min(g.count,r.start+r.count);for(let b=x,v=y-1;bc)continue;f.applyMatrix4(this.matrixWorld);const A=e.ray.origin.distanceTo(f);Ae.far||t.push({distance:A,point:h.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;s0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;si.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,object:r})}}class X_ extends At{constructor(e,t,n,i,s,r,o,c,l){super(e,t,n,i,s,r,o,c,l),this.isVideoTexture=!0,this.minFilter=r!==void 0?r:Rt,this.magFilter=s!==void 0?s:Rt,this.generateMipmaps=!1;const u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class j_ extends At{constructor(e,t,n){super({width:e,height:t}),this.isFramebufferTexture=!0,this.format=n,this.magFilter=Bt,this.minFilter=Bt,this.generateMipmaps=!1,this.needsUpdate=!0}}class Ep extends At{constructor(e,t,n,i,s,r,o,c,l,u,h,f){super(null,r,o,c,l,u,i,s,h,f),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class Y_ extends At{constructor(e,t,n,i,s,r,o,c,l){super(e,t,n,i,s,r,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Bn{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),s=0;t.push(0);for(let r=1;r<=e;r++)n=this.getPoint(r/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const s=n.length;let r;t?r=t:r=e*n[s-1];let o=0,c=s-1,l;for(;o<=c;)if(i=Math.floor(o+(c-o)/2),l=n[i]-r,l<0)o=i+1;else if(l>0)c=i-1;else{c=i;break}if(i=c,n[i]===r)return i/(s-1);const u=n[i],f=n[i+1]-u,d=(r-u)/f;return(i+d)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const r=this.getPoint(i),o=this.getPoint(s),c=t||(r.isVector2?new fe:new D);return c.copy(o).sub(r).normalize(),c}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new D,i=[],s=[],r=[],o=new D,c=new De;for(let d=0;d<=e;d++){const p=d/e;i[d]=this.getTangentAt(p,new D)}s[0]=new D,r[0]=new D;let l=Number.MAX_VALUE;const u=Math.abs(i[0].x),h=Math.abs(i[0].y),f=Math.abs(i[0].z);u<=l&&(l=u,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),f<=l&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],o),r[0].crossVectors(i[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),r[d]=r[d-1].clone(),o.crossVectors(i[d-1],i[d]),o.length()>Number.EPSILON){o.normalize();const p=Math.acos(zt(i[d-1].dot(i[d]),-1,1));s[d].applyMatrix4(c.makeRotationAxis(o,p))}r[d].crossVectors(i[d],s[d])}if(t===!0){let d=Math.acos(zt(s[0].dot(s[e]),-1,1));d/=e,i[0].dot(o.crossVectors(s[0],s[e]))>0&&(d=-d);for(let p=1;p<=e;p++)s[p].applyMatrix4(c.makeRotationAxis(i[p],d*p)),r[p].crossVectors(i[p],s[p])}return{tangents:i,normals:s,binormals:r}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Ec extends Bn{constructor(e=0,t=0,n=1,i=1,s=0,r=Math.PI*2,o=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=r,this.aClockwise=o,this.aRotation=c}getPoint(e,t){const n=t||new fe,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const r=Math.abs(s)i;)s-=i;s0?0:(Math.floor(Math.abs(o)/s)+1)*s:c===0&&o===s-1&&(o=s-2,c=1);let l,u;this.closed||o>0?l=i[(o-1)%s]:(Ra.subVectors(i[0],i[1]).add(i[0]),l=Ra);const h=i[o%s],f=i[(o+1)%s];if(this.closed||o+2i.length-2?i.length-1:r+1],h=i[r>i.length-3?i.length-1:r+2];return n.set(gf(o,c.x,l.x,u.x,h.x),gf(o,c.y,l.y,u.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const r=i[s]-n,o=this.curves[s],c=o.getLength(),l=c===0?0:1-r/c;return o.getPointAt(l,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);const u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Is extends Xe{constructor(e=[new fe(0,-.5),new fe(.5,0),new fe(0,.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=zt(i,0,Math.PI*2);const s=[],r=[],o=[],c=[],l=[],u=1/t,h=new D,f=new fe,d=new D,p=new D,m=new D;let g=0,x=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:g=e[y+1].x-e[y].x,x=e[y+1].y-e[y].y,d.x=x*1,d.y=-g,d.z=x*0,m.copy(d),d.normalize(),c.push(d.x,d.y,d.z);break;case e.length-1:c.push(m.x,m.y,m.z);break;default:g=e[y+1].x-e[y].x,x=e[y+1].y-e[y].y,d.x=x*1,d.y=-g,d.z=x*0,p.copy(d),d.x+=m.x,d.y+=m.y,d.z+=m.z,d.normalize(),c.push(d.x,d.y,d.z),m.copy(p)}for(let y=0;y<=t;y++){const b=n+y*u*i,v=Math.sin(b),S=Math.cos(b);for(let A=0;A<=e.length-1;A++){h.x=e[A].x*v,h.y=e[A].y,h.z=e[A].x*S,r.push(h.x,h.y,h.z),f.x=y/t,f.y=A/(e.length-1),o.push(f.x,f.y);const R=c[3*A+0]*v,_=c[3*A+1],L=c[3*A+0]*S;l.push(R,_,L)}}for(let y=0;y0&&b(!0),t>0&&b(!1)),this.setIndex(u),this.setAttribute("position",new we(h,3)),this.setAttribute("normal",new we(f,3)),this.setAttribute("uv",new we(d,2));function y(){const v=new D,S=new D;let A=0;const R=(t-e)/n;for(let _=0;_<=s;_++){const L=[],N=_/s,B=N*(t-e)+e;for(let W=0;W<=i;W++){const K=W/i,z=K*c+o,q=Math.sin(z),O=Math.cos(z);S.x=B*q,S.y=-N*n+g,S.z=B*O,h.push(S.x,S.y,S.z),v.set(q,R,O).normalize(),f.push(v.x,v.y,v.z),d.push(K,1-N),L.push(p++)}m.push(L)}for(let _=0;_.9&&R<.1&&(b<.2&&(r[y+0]+=1),v<.2&&(r[y+2]+=1),S<.2&&(r[y+4]+=1))}}function f(y){s.push(y.x,y.y,y.z)}function d(y,b){const v=y*3;b.x=e[v+0],b.y=e[v+1],b.z=e[v+2]}function p(){const y=new D,b=new D,v=new D,S=new D,A=new fe,R=new fe,_=new fe;for(let L=0,N=0;L80*t){o=l=a[0],c=u=a[1];for(let p=t;pl&&(l=h),f>u&&(u=f);d=Math.max(l-o,u-c),d=d!==0?1/d:0}return Co(s,r,t,o,c,d),r}};function Fp(a,e,t,n,i){let s,r;if(i===xb(a,e,t,n)>0)for(s=e;s=e;s-=n)r=yf(s,a[s],a[s+1],r);return r&&Lc(r,r.next)&&(Ro(r),r=r.next),r}function Ji(a,e){if(!a)return a;e||(e=a);let t=a,n;do if(n=!1,!t.steiner&&(Lc(t,t.next)||It(t.prev,t,t.next)===0)){if(Ro(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Co(a,e,t,n,i,s,r){if(!a)return;!r&&s&&fb(a,n,i,s);let o=a,c,l;for(;a.prev!==a.next;){if(c=a.prev,l=a.next,s?sb(a,n,i,s):ib(a)){e.push(c.i/t),e.push(a.i/t),e.push(l.i/t),Ro(a),a=l.next,o=l.next;continue}if(a=l,a===o){r?r===1?(a=rb(Ji(a),e,t),Co(a,e,t,n,i,s,2)):r===2&&ob(a,e,t,n,i,s):Co(Ji(a),e,t,n,i,s,1);break}}}function ib(a){const e=a.prev,t=a,n=a.next;if(It(e,t,n)>=0)return!1;let i=a.next.next;for(;i!==a.prev;){if(gr(e.x,e.y,t.x,t.y,n.x,n.y,i.x,i.y)&&It(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function sb(a,e,t,n){const i=a.prev,s=a,r=a.next;if(It(i,s,r)>=0)return!1;const o=i.xs.x?i.x>r.x?i.x:r.x:s.x>r.x?s.x:r.x,u=i.y>s.y?i.y>r.y?i.y:r.y:s.y>r.y?s.y:r.y,h=su(o,c,e,t,n),f=su(l,u,e,t,n);let d=a.prevZ,p=a.nextZ;for(;d&&d.z>=h&&p&&p.z<=f;){if(d!==a.prev&&d!==a.next&&gr(i.x,i.y,s.x,s.y,r.x,r.y,d.x,d.y)&&It(d.prev,d,d.next)>=0||(d=d.prevZ,p!==a.prev&&p!==a.next&&gr(i.x,i.y,s.x,s.y,r.x,r.y,p.x,p.y)&&It(p.prev,p,p.next)>=0))return!1;p=p.nextZ}for(;d&&d.z>=h;){if(d!==a.prev&&d!==a.next&&gr(i.x,i.y,s.x,s.y,r.x,r.y,d.x,d.y)&&It(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=f;){if(p!==a.prev&&p!==a.next&&gr(i.x,i.y,s.x,s.y,r.x,r.y,p.x,p.y)&&It(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function rb(a,e,t){let n=a;do{const i=n.prev,s=n.next.next;!Lc(i,s)&&Np(i,n,n.next,s)&&Lo(i,s)&&Lo(s,i)&&(e.push(i.i/t),e.push(n.i/t),e.push(s.i/t),Ro(n),Ro(n.next),n=a=s),n=n.next}while(n!==a);return Ji(n)}function ob(a,e,t,n,i,s){let r=a;do{let o=r.next.next;for(;o!==r.prev;){if(r.i!==o.i&&mb(r,o)){let c=kp(r,o);r=Ji(r,r.next),c=Ji(c,c.next),Co(r,e,t,n,i,s),Co(c,e,t,n,i,s);return}o=o.next}r=r.next}while(r!==a)}function ab(a,e,t,n){const i=[];let s,r,o,c,l;for(s=0,r=e.length;s=t.next.y&&t.next.y!==t.y){const f=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=n&&f>s){if(s=f,f===n){if(i===t.y)return t;if(i===t.next.y)return t.next}r=t.x=t.x&&t.x>=c&&n!==t.x&&gr(ir.x||t.x===r.x&&hb(r,t)))&&(r=t,u=h)),t=t.next;while(t!==o);return r}function hb(a,e){return It(a.prev,a,e.prev)<0&&It(e.next,a,a.next)<0}function fb(a,e,t,n){let i=a;do i.z===null&&(i.z=su(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==a);i.prevZ.nextZ=null,i.prevZ=null,db(i)}function db(a){let e,t,n,i,s,r,o,c,l=1;do{for(t=a,a=null,s=null,r=0;t;){for(r++,n=t,o=0,e=0;e0||c>0&&n;)o!==0&&(c===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,o--):(i=n,n=n.nextZ,c--),s?s.nextZ=i:a=i,i.prevZ=s,s=i;t=n}s.nextZ=null,l*=2}while(r>1);return a}function su(a,e,t,n,i){return a=32767*(a-t)*i,e=32767*(e-n)*i,a=(a|a<<8)&16711935,a=(a|a<<4)&252645135,a=(a|a<<2)&858993459,a=(a|a<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,a|e<<1}function pb(a){let e=a,t=a;do(e.x=0&&(a-r)*(n-o)-(t-r)*(e-o)>=0&&(t-r)*(s-o)-(i-r)*(n-o)>=0}function mb(a,e){return a.next.i!==e.i&&a.prev.i!==e.i&&!gb(a,e)&&(Lo(a,e)&&Lo(e,a)&&yb(a,e)&&(It(a.prev,a,e.prev)||It(a,e.prev,e))||Lc(a,e)&&It(a.prev,a,a.next)>0&&It(e.prev,e,e.next)>0)}function It(a,e,t){return(e.y-a.y)*(t.x-e.x)-(e.x-a.x)*(t.y-e.y)}function Lc(a,e){return a.x===e.x&&a.y===e.y}function Np(a,e,t,n){const i=Na(It(a,e,t)),s=Na(It(a,e,n)),r=Na(It(t,n,a)),o=Na(It(t,n,e));return!!(i!==s&&r!==o||i===0&&Fa(a,t,e)||s===0&&Fa(a,n,e)||r===0&&Fa(t,a,n)||o===0&&Fa(t,e,n))}function Fa(a,e,t){return e.x<=Math.max(a.x,t.x)&&e.x>=Math.min(a.x,t.x)&&e.y<=Math.max(a.y,t.y)&&e.y>=Math.min(a.y,t.y)}function Na(a){return a>0?1:a<0?-1:0}function gb(a,e){let t=a;do{if(t.i!==a.i&&t.next.i!==a.i&&t.i!==e.i&&t.next.i!==e.i&&Np(t,t.next,a,e))return!0;t=t.next}while(t!==a);return!1}function Lo(a,e){return It(a.prev,a,a.next)<0?It(a,e,a.next)>=0&&It(a,a.prev,e)>=0:It(a,e,a.prev)<0||It(a,a.next,e)<0}function yb(a,e){let t=a,n=!1;const i=(a.x+e.x)/2,s=(a.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==a);return n}function kp(a,e){const t=new ru(a.i,a.x,a.y),n=new ru(e.i,e.x,e.y),i=a.next,s=e.prev;return a.next=e,e.prev=a,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function yf(a,e,t,n){const i=new ru(a,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Ro(a){a.next.prev=a.prev,a.prev.next=a.next,a.prevZ&&(a.prevZ.nextZ=a.nextZ),a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function ru(a,e,t){this.i=a,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function xb(a,e,t,n){let i=0;for(let s=e,r=t-n;s2&&a[e-1].equals(a[0])&&a.pop()}function vf(a,e){for(let t=0;tNumber.EPSILON){const U=Math.sqrt(E),Z=Math.sqrt(ut*ut+ot*ot),Q=ce.x-ze/U,de=ce.y+Ue/U,Le=xe.x-ot/Z,F=xe.y+ut/Z,ue=((Le-Q)*ot-(F-de)*ut)/(Ue*ot-ze*ut);Fe=Q+Ue*ue-le.x,Me=de+ze*ue-le.y;const ge=Fe*Fe+Me*Me;if(ge<=2)return new fe(Fe,Me);Ye=Math.sqrt(ge/2)}else{let U=!1;Ue>Number.EPSILON?ut>Number.EPSILON&&(U=!0):Ue<-Number.EPSILON?ut<-Number.EPSILON&&(U=!0):Math.sign(ze)===Math.sign(ot)&&(U=!0),U?(Fe=-ze,Me=Ue,Ye=Math.sqrt(E)):(Fe=Ue,Me=ze,Ye=Math.sqrt(E/2))}return new fe(Fe/Ye,Me/Ye)}const H=[];for(let le=0,ce=z.length,xe=ce-1,Fe=le+1;le=0;le--){const ce=le/g,xe=d*Math.cos(ce*Math.PI/2),Fe=p*Math.sin(ce*Math.PI/2)+m;for(let Me=0,Ye=z.length;Me=0;){const Fe=xe;let Me=xe-1;Me<0&&(Me=le.length-1);for(let Ye=0,Ue=u+g*2;Ye0)&&d.push(b,v,A),(x!==n-1||c0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Qn extends Gt{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ve(16777215),this.specular=new ve(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qi,this.normalScale=new fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Oo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Up extends Gt{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ve(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qi,this.normalScale=new fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Gp extends Gt{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qi,this.normalScale=new fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Rc extends Gt{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ve(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Oo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Vp extends Gt{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ve(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qi,this.normalScale=new fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Hp extends Vt{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Rn(a,e,t){return Vu(a)?new a.constructor(a.subarray(e,t!==void 0?t:a.length)):a.slice(e,t)}function bs(a,e,t){return!a||!t&&a.constructor===e?a:typeof e.BYTES_PER_ELEMENT=="number"?new e(a):Array.prototype.slice.call(a)}function Vu(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)}function Wp(a){function e(i,s){return a[i]-a[s]}const t=a.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function ou(a,e,t){const n=a.length,i=new a.constructor(n);for(let s=0,r=0;r!==n;++s){const o=t[s]*e;for(let c=0;c!==e;++c)i[r++]=a[o+c]}return i}function Hu(a,e,t,n){let i=1,s=a[0];for(;s!==void 0&&s[n]===void 0;)s=a[i++];if(s===void 0)return;let r=s[n];if(r!==void 0)if(Array.isArray(r))do r=s[n],r!==void 0&&(e.push(s.time),t.push.apply(t,r)),s=a[i++];while(s!==void 0);else if(r.toArray!==void 0)do r=s[n],r!==void 0&&(e.push(s.time),r.toArray(t,t.length)),s=a[i++];while(s!==void 0);else do r=s[n],r!==void 0&&(e.push(s.time),t.push(r)),s=a[i++];while(s!==void 0)}function wb(a,e,t,n,i=30){const s=a.clone();s.name=e;const r=[];for(let c=0;c=n)){h.push(l.times[d]);for(let m=0;ms.tracks[c].times[0]&&(o=s.tracks[c].times[0]);for(let c=0;c=o.times[p]){const x=p*h+u,y=x+h-u;m=Rn(o.values,x,y)}else{const x=o.createInterpolant(),y=u,b=h-u;x.evaluate(s),m=Rn(x.resultBuffer,y,b)}c==="quaternion"&&new Ft().fromArray(m).normalize().conjugate().toArray(m);const g=l.times.length;for(let x=0;x=s)){const o=t[1];e=s)break t}r=n,n=0;break n}break e}for(;n>>1;et;)--r;if(++r,s!==0||r!==i){s>=r&&(r=Math.max(r,1),s=r-1);const o=this.getValueSize();this.times=Rn(n,s,r),this.values=Rn(this.values,s*o,r*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let r=null;for(let o=0;o!==s;o++){const c=n[o];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(r!==null&&r>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,c,r),e=!1;break}r=c}if(i!==void 0&&Vu(i))for(let o=0,c=i.length;o!==c;++o){const l=i[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){const e=Rn(this.times),t=Rn(this.values),n=this.getValueSize(),i=this.getInterpolation()===Ya,s=e.length-1;let r=1;for(let o=1;o0){e[r]=e[s];for(let o=s*n,c=r*n,l=0;l!==n;++l)t[c+l]=t[o+l];++r}return r!==e.length?(this.times=Rn(e,0,r),this.values=Rn(t,0,r*n)):(this.times=e,this.values=t),this}clone(){const e=Rn(this.times,0),t=Rn(this.values,0),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}qn.prototype.TimeBufferType=Float32Array;qn.prototype.ValueBufferType=Float32Array;qn.prototype.DefaultInterpolation=Cs;class Gs extends qn{}Gs.prototype.ValueTypeName="bool";Gs.prototype.ValueBufferType=Array;Gs.prototype.DefaultInterpolation=wr;Gs.prototype.InterpolantFactoryMethodLinear=void 0;Gs.prototype.InterpolantFactoryMethodSmooth=void 0;class qu extends qn{}qu.prototype.ValueTypeName="color";class Fs extends qn{}Fs.prototype.ValueTypeName="number";class jp extends Gr{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=(n-t)/(i-t);let l=e*o;for(let u=l+o;l!==u;l+=4)Ft.slerpFlat(s,0,r,l-o,r,l,c);return s}}class ni extends qn{InterpolantFactoryMethodLinear(e){return new jp(this.times,this.values,this.getValueSize(),e)}}ni.prototype.ValueTypeName="quaternion";ni.prototype.DefaultInterpolation=Cs;ni.prototype.InterpolantFactoryMethodSmooth=void 0;class Vs extends qn{}Vs.prototype.ValueTypeName="string";Vs.prototype.ValueBufferType=Array;Vs.prototype.DefaultInterpolation=wr;Vs.prototype.InterpolantFactoryMethodLinear=void 0;Vs.prototype.InterpolantFactoryMethodSmooth=void 0;class Mi extends qn{}Mi.prototype.ValueTypeName="vector";class Si{constructor(e,t=-1,n,i=gc){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Sn(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let r=0,o=n.length;r!==o;++r)t.push(Ab(n[r]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,r=n.length;s!==r;++s)t.push(qn.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const s=t.length,r=[];for(let o=0;o1){const h=u[1];let f=i[h];f||(i[h]=f=[]),f.push(l)}}const r=[];for(const o in i)r.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return r}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(h,f,d,p,m){if(d.length!==0){const g=[],x=[];Hu(d,g,x,p),g.length!==0&&m.push(new h(f,g,x))}},i=[],s=e.name||"default",r=e.fps||30,o=e.blendMode;let c=e.length||-1;const l=e.hierarchy||[];for(let h=0;h{t&&t(s),this.manager.itemEnd(e)},0),s;if(di[e]!==void 0){di[e].push({onLoad:t,onProgress:n,onError:i});return}di[e]=[],di[e].push({onLoad:t,onProgress:n,onError:i});const r=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,c=this.responseType;fetch(r).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream=="undefined"||l.body===void 0||l.body.getReader===void 0)return l;const u=di[e],h=l.body.getReader(),f=l.headers.get("Content-Length"),d=f?parseInt(f):0,p=d!==0;let m=0;const g=new ReadableStream({start(x){y();function y(){h.read().then(({done:b,value:v})=>{if(b)x.close();else{m+=v.byteLength;const S=new ProgressEvent("progress",{lengthComputable:p,loaded:m,total:d});for(let A=0,R=u.length;A{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(u=>new DOMParser().parseFromString(u,o));case"json":return l.json();default:if(o===void 0)return l.text();{const h=/charset="?([^;"\s]*)"?/i.exec(o),f=h&&h[1]?h[1].toLowerCase():void 0,d=new TextDecoder(f);return l.arrayBuffer().then(p=>d.decode(p))}}}).then(l=>{Ns.add(e,l);const u=di[e];delete di[e];for(let h=0,f=u.length;h{const u=di[e];if(u===void 0)throw this.manager.itemError(e),l;delete di[e];for(let h=0,f=u.length;h{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Cb extends Ht{constructor(e){super(e)}load(e,t,n,i){const s=this,r=new Kt(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}parse(e){const t=[];for(let n=0;n0:i.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const r=e.uniforms[s];switch(i.uniforms[s]={},r.type){case"t":i.uniforms[s].value=n(r.value);break;case"c":i.uniforms[s].value=new ve().setHex(r.value);break;case"v2":i.uniforms[s].value=new fe().fromArray(r.value);break;case"v3":i.uniforms[s].value=new D().fromArray(r.value);break;case"v4":i.uniforms[s].value=new dt().fromArray(r.value);break;case"m3":i.uniforms[s].value=new ln().fromArray(r.value);break;case"m4":i.uniforms[s].value=new De().fromArray(r.value);break;default:i.uniforms[s].value=r.value}}if(e.defines!==void 0&&(i.defines=e.defines),e.vertexShader!==void 0&&(i.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(i.fragmentShader=e.fragmentShader),e.extensions!==void 0)for(const s in e.extensions)i.extensions[s]=e.extensions[s];if(e.shading!==void 0&&(i.flatShading=e.shading===1),e.size!==void 0&&(i.size=e.size),e.sizeAttenuation!==void 0&&(i.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(i.map=n(e.map)),e.matcap!==void 0&&(i.matcap=n(e.matcap)),e.alphaMap!==void 0&&(i.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(i.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(i.bumpScale=e.bumpScale),e.normalMap!==void 0&&(i.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(i.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),i.normalScale=new fe().fromArray(s)}return e.displacementMap!==void 0&&(i.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(i.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(i.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(i.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(i.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(i.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(i.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(i.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(i.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(i.envMap=n(e.envMap)),e.envMapIntensity!==void 0&&(i.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(i.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(i.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(i.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(i.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(i.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(i.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(i.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(i.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new fe().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(i.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(i.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(i.thicknessMap=n(e.thicknessMap)),e.sheenColorMap!==void 0&&(i.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:Bp,SpriteMaterial:Ac,RawShaderMaterial:zp,ShaderMaterial:ei,PointsMaterial:Hi,MeshPhysicalMaterial:Ci,MeshStandardMaterial:Us,MeshPhongMaterial:Qn,MeshToonMaterial:Up,MeshNormalMaterial:Gp,MeshLambertMaterial:Rc,MeshDepthMaterial:Iu,MeshDistanceMaterial:Pu,MeshBasicMaterial:un,MeshMatcapMaterial:Vp,LineDashedMaterial:Hp,LineBasicMaterial:Vt,Material:Gt};return new t[e]}}class tn{static decodeText(e){if(typeof TextDecoder!="undefined")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n0){const c=new Xu(t);s=new Io(c),s.setCrossOrigin(this.crossOrigin);for(let l=0,u=e.length;l0){i=new Io(this.manager),i.setCrossOrigin(this.crossOrigin);for(let r=0,o=e.length;r0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(n[c]!==n[c+t]){o.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let s=n,r=i;s!==r;++s)t[s]=t[i+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let r=0;r!==s;++r)e[t+r]=e[n+r]}_slerp(e,t,n,i){Ft.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,s){const r=this._workIndex*s;Ft.multiplyQuaternionsFlat(e,r,e,t,e,n),Ft.slerpFlat(e,t,e,t,e,r,i)}_lerp(e,t,n,i,s){const r=1-i;for(let o=0;o!==s;++o){const c=t+o;e[c]=e[c]*r+e[n+o]*i}}_lerpAdditive(e,t,n,i,s){for(let r=0;r!==s;++r){const o=t+r;e[o]=e[o]+e[n+r]*i}}}const $u="\\[\\]\\.:\\/",Hb=new RegExp("["+$u+"]","g"),Qu="[^"+$u+"]",Wb="[^"+$u.replace("\\.","")+"]",qb=/((?:WC+[\/:])*)/.source.replace("WC",Qu),Xb=/(WCOD+)?/.source.replace("WCOD",Wb),jb=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Qu),Yb=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Qu),Zb=new RegExp("^"+qb+Xb+jb+Yb+"$"),Kb=["material","materials","bones"];class Jb{constructor(e,t,n){const i=n||it.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class it{constructor(e,t,n){this.path=t,this.parsedPath=n||it.parseTrackName(t),this.node=it.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new it.Composite(e,t,n):new it(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Hb,"")}static parseTrackName(e){const t=Zb.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);Kb.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: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let r=0;r=s){const h=s++,f=e[h];t[f.uuid]=u,e[u]=f,t[l]=h,e[h]=c;for(let d=0,p=i;d!==p;++d){const m=n[d],g=m[h],x=m[u];m[u]=g,m[h]=x}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_,r=e.length;for(let o=0,c=arguments.length;o!==c;++o){const l=arguments[o],u=l.uuid,h=t[u];if(h!==void 0)if(delete t[u],h0&&(t[d.uuid]=h),e[h]=d,e.pop();for(let p=0,m=i;p!==m;++p){const g=n[p];g[h]=g[f],g.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const s=this._bindings;if(i!==void 0)return s[i];const r=this._paths,o=this._parsedPaths,c=this._objects,l=c.length,u=this.nCachedObjects_,h=new Array(l);i=s.length,n[e]=i,r.push(e),o.push(t),s.push(h);for(let f=u,d=c.length;f!==d;++f){const p=c[f];h[f]=new it(p,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const i=this._paths,s=this._parsedPaths,r=this._bindings,o=r.length-1,c=r[o],l=e[o];t[l]=n,r[n]=c,r.pop(),s[n]=s[o],s.pop(),i[n]=i[o],i.pop()}}}class Qb{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const s=t.tracks,r=s.length,o=new Array(r),c={endingStart:xs,endingEnd:xs};for(let l=0;l!==r;++l){const u=s[l].createInterpolant(null);o[l]=u,u.settings=c}this._interpolantSettings=c,this._interpolants=o,this._propertyBindings=new Array(r),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=tp,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const i=this._clip.duration,s=e._clip.duration,r=s/i,o=i/s;e.warp(1,r,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,s=i.time,r=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);const c=o.parameterPositions,l=o.sampleValues;return c[0]=s,c[1]=s+n,l[0]=e/r,l[1]=t/r,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const c=(e-s)*n;if(c<0||n===0)return;this._startTime=null,t=n*c}t*=this._updateTimeScale(e);const r=this._updateTime(t),o=this._updateWeight(e);if(o>0){const c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case Tu:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(r),l[u].accumulateAdditive(o);break;case gc:default:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(r),l[u].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;n!==null&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,s=this._loopCount;const r=n===np;if(e===0)return s===-1?i:r&&(s&1)===1?t-i:i;if(n===ep){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,r)):this._setEndings(this.repetitions===0,!0,r)),i>=t||i<0){const o=Math.floor(i/t);i-=t*o,s+=Math.abs(o);const c=this.repetitions-s;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){const l=e<0;this._setEndings(l,!l,r)}else this._setEndings(!1,!1,r);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=i;if(r&&(s&1)===1)return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=vs,i.endingEnd=vs):(e?i.endingStart=this.zeroSlopeAtStart?vs:xs:i.endingStart=Mo,t?i.endingEnd=this.zeroSlopeAtEnd?vs:xs:i.endingEnd=Mo)}_scheduleFading(e,t,n){const i=this._mixer,s=i.time;let r=this._weightInterpolant;r===null&&(r=i._lendControlInterpolant(),this._weightInterpolant=r);const o=r.parameterPositions,c=r.sampleValues;return o[0]=s,c[0]=t,o[1]=s+e,c[1]=n,this}}const ew=new Float32Array(1);class sm extends ri{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,s=i.length,r=e._propertyBindings,o=e._interpolants,c=n.uuid,l=this._bindingsByRootAndName;let u=l[c];u===void 0&&(u={},l[c]=u);for(let h=0;h!==s;++h){const f=i[h],d=f.name;let p=u[d];if(p!==void 0)++p.referenceCount,r[h]=p;else{if(p=r[h],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,c,d));continue}const m=t&&t._propertyBindings[h].binding.parsedPath;p=new im(it.create(n,d,m),f.ValueTypeName,f.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,c,d),r[h]=p}o[h].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,i=e._clip.uuid,s=this._actionsByClip[i];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,i,n)}const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,s=Math.sign(e),r=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(i,e,s,r);const o=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)o[l].apply(r);return this}setTime(e){this.time=0;for(let t=0;tthis.max.x||e.ythis.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Ff.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Nf=new D,Oa=new D;class aw{constructor(e=new D,t=new D){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Nf.subVectors(e,this.start),Oa.subVectors(this.end,this.start);const n=Oa.dot(Oa);let s=Oa.dot(Nf)/n;return t&&(s=zt(s,0,1)),s}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const kf=new D;class cw extends lt{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;const n=new Xe,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let r=0,o=1,c=32;r.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Gf.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Gf,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}}class bw extends vn{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Xe;i.setAttribute("position",new we(t,3)),i.setAttribute("color",new we(n,3));const s=new Vt({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,n){const i=new ve,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class ww{constructor(){this.type="ShapePath",this.color=new ve,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Eo,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,s,r){return this.currentPath.bezierCurveTo(e,t,n,i,s,r),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e,t){function n(y){const b=[];for(let v=0,S=y.length;vNumber.EPSILON){if(B<0&&(_=b[R],N=-N,L=b[A],B=-B),y.y<_.y||y.y>L.y)continue;if(y.y===_.y){if(y.x===_.x)return!0}else{const W=B*(y.x-_.x)-N*(y.y-_.y);if(W===0)return!0;if(W<0)continue;S=!S}}else{if(y.y!==_.y)continue;if(L.x<=y.x&&y.x<=_.x||_.x<=y.x&&y.x<=L.x)return!0}}return S}const s=$n.isClockWise,r=this.subPaths;if(r.length===0)return[];if(t===!0)return n(r);let o,c,l;const u=[];if(r.length===1)return c=r[0],l=new As,l.curves=c.curves,u.push(l),u;let h=!s(r[0].getPoints());h=e?!h:h;const f=[],d=[];let p=[],m=0,g;d[m]=void 0,p[m]=[];for(let y=0,b=r.length;y1){let y=!1,b=0;for(let v=0,S=d.length;v0&&y===!1&&(p=f)}let x;for(let y=0,b=d.length;y>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}const s=new Uint32Array(2048),r=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,u=0;for(;(l&8388608)===0;)l<<=1,u-=8388608;l&=-8388609,u+=947912704,s[c]=l|u}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)r[c]=c<<23;r[31]=1199570944,r[32]=2147483648;for(let c=33;c<63;++c)r[c]=2147483648+(c-32<<23);r[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:s,exponentTable:r,offsetTable:o}}function Sw(a){Math.abs(a)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),a=zt(a,-65504,65504),mi.floatView[0]=a;const e=mi.uint32View[0],t=e>>23&511;return mi.baseTable[t]+((e&8388607)>>mi.shiftTable[t])}function Tw(a){const e=a>>10;return mi.uint32View[0]=mi.mantissaTable[mi.offsetTable[e]+(a&1023)]+mi.exponentTable[e],mi.floatView[0]}var Aw=Object.freeze({__proto__:null,toHalfFloat:Sw,fromHalfFloat:Tw});class Ew extends Xe{constructor(){console.error("THREE.ParametricGeometry has been moved to /examples/jsm/geometries/ParametricGeometry.js"),super()}}class Cw extends Xe{constructor(){console.error("THREE.TextGeometry has been moved to /examples/jsm/geometries/TextGeometry.js"),super()}}function Lw(){console.error("THREE.FontLoader has been moved to /examples/jsm/loaders/FontLoader.js")}function Rw(){console.error("THREE.Font has been moved to /examples/jsm/loaders/FontLoader.js")}function Iw(){console.error("THREE.ImmediateRenderObject has been removed.")}class Pw extends kn{constructor(e,t,n){console.error('THREE.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the "samples" property to greater 0 to enable multisampling.'),super(e,t,n),this.samples=4}}class Dw extends Bo{constructor(e,t,n,i){console.warn("THREE.DataTexture2DArray has been renamed to DataArrayTexture."),super(e,t,n,i)}}class Fw extends yc{constructor(e,t,n,i){console.warn("THREE.DataTexture3D has been renamed to Data3DTexture."),super(e,t,n,i)}}typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:dc}}));typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=dc);var Nw=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Bd,AddEquation:gs,AddOperation:Fd,AdditiveAnimationBlendMode:Tu,AdditiveBlending:El,AlphaFormat:qd,AlwaysDepth:Ed,AlwaysStencilFunc:ap,AmbientLight:Wo,AmbientLightProbe:kb,AnimationClip:Si,AnimationLoader:Cb,AnimationMixer:sm,AnimationObjectGroup:$b,AnimationUtils:Sb,ArcCurve:Cp,ArrayCamera:bp,ArrowHelper:_w,Audio:nm,AudioAnalyser:Vb,AudioContext:Ku,AudioListener:zb,AudioLoader:Fb,AxesHelper:bw,BackSide:Dn,BasicDepthPacking:sp,BasicShadowMap:eg,Bone:Rs,BooleanKeyframeTrack:Gs,Box2:ow,Box3:Ei,Box3Helper:xw,BoxBufferGeometry:wi,BoxGeometry:wi,BoxHelper:yw,BufferAttribute:pt,BufferGeometry:Xe,BufferGeometryLoader:Qp,ByteType:Ud,Cache:Ns,Camera:_c,CameraHelper:gw,CanvasTexture:Y_,CapsuleBufferGeometry:Tr,CapsuleGeometry:Tr,CatmullRomCurve3:Lp,CineonToneMapping:Od,CircleBufferGeometry:Ar,CircleGeometry:Ar,ClampToEdgeWrapping:jt,Clock:Ju,Color:ve,ColorKeyframeTrack:qu,ColorManagement:Cn,CompressedTexture:Ep,CompressedTextureLoader:Yp,ConeBufferGeometry:Er,ConeGeometry:Er,CubeCamera:fp,CubeReflectionMapping:Xi,CubeRefractionMapping:ji,CubeTexture:Uo,CubeTextureLoader:Lb,CubeUVReflectionMapping:zr,CubicBezierCurve:Ou,CubicBezierCurve3:Rp,CubicInterpolant:qp,CullFaceBack:Al,CullFaceFront:hd,CullFaceFrontBack:Qm,CullFaceNone:ud,Curve:Bn,CurvePath:Pp,CustomBlending:pd,CustomToneMapping:zd,CylinderBufferGeometry:Ki,CylinderGeometry:Ki,Cylindrical:rw,Data3DTexture:yc,DataArrayTexture:Bo,DataTexture:yr,DataTexture2DArray:Dw,DataTexture3D:Fw,DataTextureLoader:Zp,DataUtils:Aw,DecrementStencilOp:hg,DecrementWrapStencilOp:dg,DefaultLoadingManager:ju,DepthFormat:Wi,DepthStencilFormat:Es,DepthTexture:wp,DirectionalLight:Vr,DirectionalLightHelper:mw,DiscreteInterpolant:Xp,DodecahedronBufferGeometry:Cr,DodecahedronGeometry:Cr,DoubleSide:_i,DstAlphaFactor:bd,DstColorFactor:Md,DynamicCopyUsage:Cg,DynamicDrawUsage:wg,DynamicReadUsage:Tg,EdgesGeometry:Dp,EllipseCurve:Ec,EqualDepth:Ld,EqualStencilFunc:yg,EquirectangularReflectionMapping:vr,EquirectangularRefractionMapping:_o,Euler:Pn,EventDispatcher:ri,ExtrudeBufferGeometry:Lr,ExtrudeGeometry:Lr,FileLoader:Kt,FlatShading:dd,Float16BufferAttribute:u0,Float32BufferAttribute:we,Float64BufferAttribute:h0,FloatType:gi,Fog:Sc,FogExp2:Mc,Font:Rw,FontLoader:Lw,FramebufferTexture:j_,FrontSide:vi,Frustum:bc,GLBufferAttribute:sw,GLSL1:Rg,GLSL3:Ql,GreaterDepth:Id,GreaterEqualDepth:Rd,GreaterEqualStencilFunc:bg,GreaterStencilFunc:vg,GridHelper:dw,Group:yn,HalfFloatType:br,HemisphereLight:Yu,HemisphereLightHelper:fw,HemisphereLightProbe:Nb,IcosahedronBufferGeometry:Rr,IcosahedronGeometry:Rr,ImageBitmapLoader:tm,ImageLoader:Io,ImageUtils:Cu,ImmediateRenderObject:Iw,IncrementStencilOp:ug,IncrementWrapStencilOp:fg,InstancedBufferAttribute:Sr,InstancedBufferGeometry:$p,InstancedInterleavedBuffer:iw,InstancedMesh:Ap,Int16BufferAttribute:c0,Int32BufferAttribute:l0,Int8BufferAttribute:r0,IntType:Vd,InterleavedBuffer:Go,InterleavedBufferAttribute:Zi,Interpolant:Gr,InterpolateDiscrete:wr,InterpolateLinear:Cs,InterpolateSmooth:Ya,InvertStencilOp:pg,KeepStencilOp:Za,KeyframeTrack:qn,LOD:Tp,LatheBufferGeometry:Is,LatheGeometry:Is,Layers:xc,LessDepth:Cd,LessEqualDepth:tc,LessEqualStencilFunc:xg,LessStencilFunc:gg,Light:ts,LightProbe:Ic,Line:Wn,Line3:aw,LineBasicMaterial:Vt,LineCurve:Cc,LineCurve3:Ip,LineDashedMaterial:Hp,LineLoop:Nu,LineSegments:vn,LinearEncoding:bi,LinearFilter:Rt,LinearInterpolant:Wu,LinearMipMapLinearFilter:rg,LinearMipMapNearestFilter:sg,LinearMipmapLinearFilter:si,LinearMipmapNearestFilter:mc,LinearSRGBColorSpace:Vi,LinearToneMapping:Nd,Loader:Ht,LoaderUtils:tn,LoadingManager:Xu,LoopOnce:ep,LoopPingPong:np,LoopRepeat:tp,LuminanceAlphaFormat:Yd,LuminanceFormat:jd,MOUSE:fs,Material:Gt,MaterialLoader:Pc,MathUtils:en,Matrix3:ln,Matrix4:De,MaxEquation:Il,Mesh:Tt,MeshBasicMaterial:un,MeshDepthMaterial:Iu,MeshDistanceMaterial:Pu,MeshLambertMaterial:Rc,MeshMatcapMaterial:Vp,MeshNormalMaterial:Gp,MeshPhongMaterial:Qn,MeshPhysicalMaterial:Ci,MeshStandardMaterial:Us,MeshToonMaterial:Up,MinEquation:Rl,MirroredRepeatWrapping:_r,MixOperation:Dd,MultiplyBlending:Ll,MultiplyOperation:Oo,NearestFilter:Bt,NearestMipMapLinearFilter:ig,NearestMipMapNearestFilter:ng,NearestMipmapLinearFilter:wo,NearestMipmapNearestFilter:bo,NeverDepth:Ad,NeverStencilFunc:mg,NoBlending:xi,NoColorSpace:ag,NoToneMapping:Jn,NormalAnimationBlendMode:gc,NormalBlending:ws,NotEqualDepth:Pd,NotEqualStencilFunc:_g,NumberKeyframeTrack:Fs,Object3D:lt,ObjectLoader:em,ObjectSpaceNormalMap:op,OctahedronBufferGeometry:Ps,OctahedronGeometry:Ps,OneFactor:xd,OneMinusDstAlphaFactor:wd,OneMinusDstColorFactor:Sd,OneMinusSrcAlphaFactor:wu,OneMinusSrcColorFactor:_d,OrthographicCamera:Bs,PCFShadowMap:_u,PCFSoftShadowMap:fd,PMREMGenerator:tu,ParametricGeometry:Ew,Path:Eo,PerspectiveCamera:Dt,Plane:Ui,PlaneBufferGeometry:Ls,PlaneGeometry:Ls,PlaneHelper:vw,PointLight:Os,PointLightHelper:uw,Points:xr,PointsMaterial:Hi,PolarGridHelper:pw,PolyhedronBufferGeometry:ti,PolyhedronGeometry:ti,PositionalAudio:Gb,PropertyBinding:it,PropertyMixer:im,QuadraticBezierCurve:Bu,QuadraticBezierCurve3:zu,Quaternion:Ft,QuaternionKeyframeTrack:ni,QuaternionLinearInterpolant:jp,REVISION:dc,RGBADepthPacking:rp,RGBAFormat:Mn,RGBAIntegerFormat:Qd,RGBA_ASTC_10x10_Format:Zl,RGBA_ASTC_10x5_Format:Xl,RGBA_ASTC_10x6_Format:jl,RGBA_ASTC_10x8_Format:Yl,RGBA_ASTC_12x10_Format:Kl,RGBA_ASTC_12x12_Format:Jl,RGBA_ASTC_4x4_Format:Bl,RGBA_ASTC_5x4_Format:zl,RGBA_ASTC_5x5_Format:Ul,RGBA_ASTC_6x5_Format:Gl,RGBA_ASTC_6x6_Format:Vl,RGBA_ASTC_8x5_Format:Hl,RGBA_ASTC_8x6_Format:Wl,RGBA_ASTC_8x8_Format:ql,RGBA_BPTC_Format:$l,RGBA_ETC2_EAC_Format:Ol,RGBA_PVRTC_2BPPV1_Format:Nl,RGBA_PVRTC_4BPPV1_Format:Fl,RGBA_S3TC_DXT1_Format:ja,RGBA_S3TC_DXT3_Format:fo,RGBA_S3TC_DXT5_Format:po,RGBFormat:Xd,RGB_ETC1_Format:Su,RGB_ETC2_Format:kl,RGB_PVRTC_2BPPV1_Format:Dl,RGB_PVRTC_4BPPV1_Format:Pl,RGB_S3TC_DXT1_Format:ho,RGFormat:Jd,RGIntegerFormat:$d,RawShaderMaterial:zp,Ray:zo,Raycaster:rm,RectAreaLight:Kp,RedFormat:Zd,RedIntegerFormat:Kd,ReinhardToneMapping:kd,RepeatWrapping:cn,ReplaceStencilOp:lg,ReverseSubtractEquation:gd,RingBufferGeometry:Ir,RingGeometry:Ir,SRGBColorSpace:Zn,Scene:Tc,ShaderChunk:nt,ShaderLib:Hn,ShaderMaterial:ei,ShadowMaterial:Bp,Shape:As,ShapeBufferGeometry:Pr,ShapeGeometry:Pr,ShapePath:ww,ShapeUtils:$n,ShortType:Gd,Skeleton:zs,SkeletonHelper:lw,SkinnedMesh:Vo,SmoothShading:tg,Source:_s,Sphere:es,SphereBufferGeometry:Ds,SphereGeometry:Ds,Spherical:cu,SphericalHarmonics3:Jp,SplineCurve:Uu,SpotLight:Ho,SpotLightHelper:cw,Sprite:Fu,SpriteMaterial:Ac,SrcAlphaFactor:bu,SrcAlphaSaturateFactor:Td,SrcColorFactor:vd,StaticCopyUsage:Eg,StaticDrawUsage:So,StaticReadUsage:Sg,StereoCamera:Ob,StreamCopyUsage:Lg,StreamDrawUsage:Mg,StreamReadUsage:Ag,StringKeyframeTrack:Vs,SubtractEquation:md,SubtractiveBlending:Cl,TOUCH:ds,TangentSpaceNormalMap:Qi,TetrahedronBufferGeometry:Dr,TetrahedronGeometry:Dr,TextGeometry:Cw,Texture:At,TextureLoader:ks,TorusBufferGeometry:Fr,TorusGeometry:Fr,TorusKnotBufferGeometry:Nr,TorusKnotGeometry:Nr,Triangle:In,TriangleFanDrawMode:Au,TriangleStripDrawMode:ip,TrianglesDrawMode:og,TubeBufferGeometry:kr,TubeGeometry:kr,UVMapping:pc,Uint16BufferAttribute:vc,Uint32BufferAttribute:Lu,Uint8BufferAttribute:o0,Uint8ClampedBufferAttribute:a0,Uniform:eh,UniformsGroup:nw,UniformsLib:Re,UniformsUtils:hp,UnsignedByteType:Yi,UnsignedInt248Type:Ms,UnsignedIntType:Gi,UnsignedShort4444Type:Hd,UnsignedShort5551Type:Wd,UnsignedShortType:Mu,VSMShadowMap:dr,Vector2:fe,Vector3:D,Vector4:dt,VectorKeyframeTrack:Mi,VideoTexture:X_,WebGL1Renderer:Mp,WebGL3DRenderTarget:Zg,WebGLArrayRenderTarget:Yg,WebGLCubeRenderTarget:dp,WebGLMultipleRenderTargets:Kg,WebGLMultisampleRenderTarget:Pw,WebGLRenderTarget:kn,WebGLRenderer:Du,WebGLUtils:_p,WireframeGeometry:Op,WrapAroundEnding:Mo,ZeroCurvatureEnding:xs,ZeroFactor:yd,ZeroSlopeEnding:vs,ZeroStencilOp:cg,_SRGBAFormat:nc,sRGBEncoding:tt},Symbol.toStringTag,{value:"Module"}));const Vf={type:"change"},vl={type:"start"},Hf={type:"end"};class kw extends ri{constructor(e,t){super(),t===void 0&&console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.'),t===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.object=e,this.domElement=t,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new D,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:fs.ROTATE,MIDDLE:fs.DOLLY,RIGHT:fs.PAN},this.touches={ONE:ds.ROTATE,TWO:ds.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return o.phi},this.getAzimuthalAngle=function(){return o.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(F){F.addEventListener("keydown",ot),this._domElementKeyEvents=F},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(Vf),n.update(),s=i.NONE},this.update=function(){const F=new D,ue=new Ft().setFromUnitVectors(e.up,new D(0,1,0)),ge=ue.clone().invert(),Ee=new D,Se=new Ft,Oe=2*Math.PI;return function(){const $e=n.object.position;F.copy($e).sub(n.target),F.applyQuaternion(ue),o.setFromVector3(F),n.autoRotate&&s===i.NONE&&L(R()),n.enableDamping?(o.theta+=c.theta*n.dampingFactor,o.phi+=c.phi*n.dampingFactor):(o.theta+=c.theta,o.phi+=c.phi);let G=n.minAzimuthAngle,Te=n.maxAzimuthAngle;return isFinite(G)&&isFinite(Te)&&(G<-Math.PI?G+=Oe:G>Math.PI&&(G-=Oe),Te<-Math.PI?Te+=Oe:Te>Math.PI&&(Te-=Oe),G<=Te?o.theta=Math.max(G,Math.min(Te,o.theta)):o.theta=o.theta>(G+Te)/2?Math.max(G,o.theta):Math.min(Te,o.theta)),o.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,o.phi)),o.makeSafe(),o.radius*=l,o.radius=Math.max(n.minDistance,Math.min(n.maxDistance,o.radius)),n.enableDamping===!0?n.target.addScaledVector(u,n.dampingFactor):n.target.add(u),F.setFromSpherical(o),F.applyQuaternion(ge),$e.copy(n.target).add(F),n.object.lookAt(n.target),n.enableDamping===!0?(c.theta*=1-n.dampingFactor,c.phi*=1-n.dampingFactor,u.multiplyScalar(1-n.dampingFactor)):(c.set(0,0,0),u.set(0,0,0)),l=1,h||Ee.distanceToSquared(n.object.position)>r||8*(1-Se.dot(n.object.quaternion))>r?(n.dispatchEvent(Vf),Ee.copy(n.object.position),Se.copy(n.object.quaternion),h=!1,!0):!1}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",U),n.domElement.removeEventListener("pointerdown",xe),n.domElement.removeEventListener("pointercancel",Ye),n.domElement.removeEventListener("wheel",ut),n.domElement.removeEventListener("pointermove",Fe),n.domElement.removeEventListener("pointerup",Me),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",ot)};const n=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=i.NONE;const r=1e-6,o=new cu,c=new cu;let l=1;const u=new D;let h=!1;const f=new fe,d=new fe,p=new fe,m=new fe,g=new fe,x=new fe,y=new fe,b=new fe,v=new fe,S=[],A={};function R(){return 2*Math.PI/60/60*n.autoRotateSpeed}function _(){return Math.pow(.95,n.zoomSpeed)}function L(F){c.theta-=F}function N(F){c.phi-=F}const B=function(){const F=new D;return function(ge,Ee){F.setFromMatrixColumn(Ee,0),F.multiplyScalar(-ge),u.add(F)}}(),W=function(){const F=new D;return function(ge,Ee){n.screenSpacePanning===!0?F.setFromMatrixColumn(Ee,1):(F.setFromMatrixColumn(Ee,0),F.crossVectors(n.object.up,F)),F.multiplyScalar(ge),u.add(F)}}(),K=function(){const F=new D;return function(ge,Ee){const Se=n.domElement;if(n.object.isPerspectiveCamera){const Oe=n.object.position;F.copy(Oe).sub(n.target);let qe=F.length();qe*=Math.tan(n.object.fov/2*Math.PI/180),B(2*ge*qe/Se.clientHeight,n.object.matrix),W(2*Ee*qe/Se.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(B(ge*(n.object.right-n.object.left)/n.object.zoom/Se.clientWidth,n.object.matrix),W(Ee*(n.object.top-n.object.bottom)/n.object.zoom/Se.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function z(F){n.object.isPerspectiveCamera?l/=F:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom*F)),n.object.updateProjectionMatrix(),h=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function q(F){n.object.isPerspectiveCamera?l*=F:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/F)),n.object.updateProjectionMatrix(),h=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function O(F){f.set(F.clientX,F.clientY)}function Y(F){y.set(F.clientX,F.clientY)}function j(F){m.set(F.clientX,F.clientY)}function H(F){d.set(F.clientX,F.clientY),p.subVectors(d,f).multiplyScalar(n.rotateSpeed);const ue=n.domElement;L(2*Math.PI*p.x/ue.clientHeight),N(2*Math.PI*p.y/ue.clientHeight),f.copy(d),n.update()}function X(F){b.set(F.clientX,F.clientY),v.subVectors(b,y),v.y>0?z(_()):v.y<0&&q(_()),y.copy(b),n.update()}function te(F){g.set(F.clientX,F.clientY),x.subVectors(g,m).multiplyScalar(n.panSpeed),K(x.x,x.y),m.copy(g),n.update()}function J(F){F.deltaY<0?q(_()):F.deltaY>0&&z(_()),n.update()}function ne(F){let ue=!1;switch(F.code){case n.keys.UP:K(0,n.keyPanSpeed),ue=!0;break;case n.keys.BOTTOM:K(0,-n.keyPanSpeed),ue=!0;break;case n.keys.LEFT:K(n.keyPanSpeed,0),ue=!0;break;case n.keys.RIGHT:K(-n.keyPanSpeed,0),ue=!0;break}ue&&(F.preventDefault(),n.update())}function re(){if(S.length===1)f.set(S[0].pageX,S[0].pageY);else{const F=.5*(S[0].pageX+S[1].pageX),ue=.5*(S[0].pageY+S[1].pageY);f.set(F,ue)}}function se(){if(S.length===1)m.set(S[0].pageX,S[0].pageY);else{const F=.5*(S[0].pageX+S[1].pageX),ue=.5*(S[0].pageY+S[1].pageY);m.set(F,ue)}}function V(){const F=S[0].pageX-S[1].pageX,ue=S[0].pageY-S[1].pageY,ge=Math.sqrt(F*F+ue*ue);y.set(0,ge)}function me(){n.enableZoom&&V(),n.enablePan&&se()}function _e(){n.enableZoom&&V(),n.enableRotate&&re()}function Ie(F){if(S.length==1)d.set(F.pageX,F.pageY);else{const ge=Le(F),Ee=.5*(F.pageX+ge.x),Se=.5*(F.pageY+ge.y);d.set(Ee,Se)}p.subVectors(d,f).multiplyScalar(n.rotateSpeed);const ue=n.domElement;L(2*Math.PI*p.x/ue.clientHeight),N(2*Math.PI*p.y/ue.clientHeight),f.copy(d)}function ye(F){if(S.length===1)g.set(F.pageX,F.pageY);else{const ue=Le(F),ge=.5*(F.pageX+ue.x),Ee=.5*(F.pageY+ue.y);g.set(ge,Ee)}x.subVectors(g,m).multiplyScalar(n.panSpeed),K(x.x,x.y),m.copy(g)}function He(F){const ue=Le(F),ge=F.pageX-ue.x,Ee=F.pageY-ue.y,Se=Math.sqrt(ge*ge+Ee*Ee);b.set(0,Se),v.set(0,Math.pow(b.y/y.y,n.zoomSpeed)),z(v.y),y.copy(b)}function le(F){n.enableZoom&&He(F),n.enablePan&&ye(F)}function ce(F){n.enableZoom&&He(F),n.enableRotate&&Ie(F)}function xe(F){n.enabled!==!1&&(S.length===0&&(n.domElement.setPointerCapture(F.pointerId),n.domElement.addEventListener("pointermove",Fe),n.domElement.addEventListener("pointerup",Me)),Z(F),F.pointerType==="touch"?E(F):Ue(F))}function Fe(F){n.enabled!==!1&&(F.pointerType==="touch"?w(F):ze(F))}function Me(F){Q(F),S.length===0&&(n.domElement.releasePointerCapture(F.pointerId),n.domElement.removeEventListener("pointermove",Fe),n.domElement.removeEventListener("pointerup",Me)),n.dispatchEvent(Hf),s=i.NONE}function Ye(F){Q(F)}function Ue(F){let ue;switch(F.button){case 0:ue=n.mouseButtons.LEFT;break;case 1:ue=n.mouseButtons.MIDDLE;break;case 2:ue=n.mouseButtons.RIGHT;break;default:ue=-1}switch(ue){case fs.DOLLY:if(n.enableZoom===!1)return;Y(F),s=i.DOLLY;break;case fs.ROTATE:if(F.ctrlKey||F.metaKey||F.shiftKey){if(n.enablePan===!1)return;j(F),s=i.PAN}else{if(n.enableRotate===!1)return;O(F),s=i.ROTATE}break;case fs.PAN:if(F.ctrlKey||F.metaKey||F.shiftKey){if(n.enableRotate===!1)return;O(F),s=i.ROTATE}else{if(n.enablePan===!1)return;j(F),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&n.dispatchEvent(vl)}function ze(F){switch(s){case i.ROTATE:if(n.enableRotate===!1)return;H(F);break;case i.DOLLY:if(n.enableZoom===!1)return;X(F);break;case i.PAN:if(n.enablePan===!1)return;te(F);break}}function ut(F){n.enabled===!1||n.enableZoom===!1||s!==i.NONE||(F.preventDefault(),n.dispatchEvent(vl),J(F),n.dispatchEvent(Hf))}function ot(F){n.enabled===!1||n.enablePan===!1||ne(F)}function E(F){switch(de(F),S.length){case 1:switch(n.touches.ONE){case ds.ROTATE:if(n.enableRotate===!1)return;re(),s=i.TOUCH_ROTATE;break;case ds.PAN:if(n.enablePan===!1)return;se(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(n.touches.TWO){case ds.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;me(),s=i.TOUCH_DOLLY_PAN;break;case ds.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;_e(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&n.dispatchEvent(vl)}function w(F){switch(de(F),s){case i.TOUCH_ROTATE:if(n.enableRotate===!1)return;Ie(F),n.update();break;case i.TOUCH_PAN:if(n.enablePan===!1)return;ye(F),n.update();break;case i.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;le(F),n.update();break;case i.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;ce(F),n.update();break;default:s=i.NONE}}function U(F){n.enabled!==!1&&F.preventDefault()}function Z(F){S.push(F)}function Q(F){delete A[F.pointerId];for(let ue=0;ue=s+1e3&&(o.update(r*1e3/(u-s),100),s=u,r=0,l)){var h=performance.memory;l.update(h.usedJSHeapSize/1048576,h.jsHeapSizeLimit/1048576)}return u},update:function(){i=this.end()},domElement:e,setMode:n}};xo.Panel=function(a,e,t){var n=1/0,i=0,s=Math.round,r=s(window.devicePixelRatio||1),o=80*r,c=48*r,l=3*r,u=2*r,h=3*r,f=15*r,d=74*r,p=30*r,m=document.createElement("canvas");m.width=o,m.height=c,m.style.cssText="width:80px;height:48px";var g=m.getContext("2d");return g.font="bold "+9*r+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=t,g.fillRect(0,0,o,c),g.fillStyle=e,g.fillText(a,l,u),g.fillRect(h,f,d,p),g.fillStyle=t,g.globalAlpha=.9,g.fillRect(h,f,d,p),{dom:m,update:function(x,y){n=Math.min(n,x),i=Math.max(i,x),g.fillStyle=t,g.globalAlpha=1,g.fillRect(0,0,o,f),g.fillStyle=e,g.fillText(s(x)+" "+a+" ("+s(n)+"-"+s(i)+")",l,u),g.drawImage(m,h+r,f,d-r,p,h,f,d-r,p),g.fillRect(h+d-r,f,r,p),g.fillStyle=t,g.globalAlpha=.9,g.fillRect(h+d-r,f,r,s((1-x/y)*p))}}};/*! +}`;function k_(a,e,t){let n=new wc;const i=new de,s=new de,r=new dt,o=new Pu({depthPacking:op}),c=new Du,l={},u=t.maxTextureSize,h={0:Dn,1:vi,2:_i},f=new ei({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new de},radius:{value:4}},vertexShader:F_,fragmentShader:N_}),d=f.clone();d.defines.HORIZONTAL_PASS=1;const p=new qe;p.setAttribute("position",new pt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new Tt(p,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=bu,this.render=function(v,M,T){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||v.length===0)return;const C=a.getRenderTarget(),_=a.getActiveCubeFace(),E=a.getActiveMipmapLevel(),F=a.state;F.setBlending(xi),F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);for(let U=0,q=v.length;Uu||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/X.x),i.x=s.x*X.x,G.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/X.y),i.y=s.y*X.y,G.mapSize.y=s.y)),G.map===null){const Z=this.type!==dr?{minFilter:Bt,magFilter:Bt}:{};G.map=new kn(i.x,i.y,Z),G.map.texture.name=J.name+".shadowMap",G.camera.updateProjectionMatrix()}a.setRenderTarget(G.map),a.clear();const B=G.getViewportCount();for(let Z=0;Z0){const q=F.uuid,J=M.uuid;let G=l[q];G===void 0&&(G={},l[q]=G);let X=G[J];X===void 0&&(X=F.clone(),G[J]=X),F=X}return F.visible=M.visible,F.wireframe=M.wireframe,E===dr?F.side=M.shadowSide!==null?M.shadowSide:M.side:F.side=M.shadowSide!==null?M.shadowSide:h[M.side],F.alphaMap=M.alphaMap,F.alphaTest=M.alphaTest,F.clipShadows=M.clipShadows,F.clippingPlanes=M.clippingPlanes,F.clipIntersection=M.clipIntersection,F.displacementMap=M.displacementMap,F.displacementScale=M.displacementScale,F.displacementBias=M.displacementBias,F.wireframeLinewidth=M.wireframeLinewidth,F.linewidth=M.linewidth,T.isPointLight===!0&&F.isMeshDistanceMaterial===!0&&(F.referencePosition.setFromMatrixPosition(T.matrixWorld),F.nearDistance=C,F.farDistance=_),F}function b(v,M,T,C,_){if(v.visible===!1)return;if(v.layers.test(M.layers)&&(v.isMesh||v.isLine||v.isPoints)&&(v.castShadow||v.receiveShadow&&_===dr)&&(!v.frustumCulled||n.intersectsObject(v))){v.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,v.matrixWorld);const U=e.update(v),q=v.material;if(Array.isArray(q)){const J=U.groups;for(let G=0,X=J.length;G=1):Y.indexOf("OpenGL ES")!==-1&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(Y)[1]),B=Z>=2);let W=null,j={};const ne=a.getParameter(3088),$=a.getParameter(2978),ie=new dt().fromArray(ne),ce=new dt().fromArray($);function oe(V,_e,re){const Re=new Uint8Array(4),Ce=a.createTexture();a.bindTexture(V,Ce),a.texParameteri(V,10241,9728),a.texParameteri(V,10240,9728);for(let Je=0;Jez||O.height>z)&&(K=z/Math.max(O.width,O.height)),K<1||D===!0)if(typeof HTMLImageElement!="undefined"&&O instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&O instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&O instanceof ImageBitmap){const Q=D?sc:Math.floor,me=Q(K*O.width),R=Q(K*O.height);m===void 0&&(m=y(me,R));const ae=k?y(me,R):m;return ae.width=me,ae.height=R,ae.getContext("2d").drawImage(O,0,0,me,R),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+O.width+"x"+O.height+") to ("+me+"x"+R+")."),ae}else return"data"in O&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+O.width+"x"+O.height+")."),O;return O}function v(O){return tu(O.width)&&tu(O.height)}function M(O){return o?!1:O.wrapS!==jt||O.wrapT!==jt||O.minFilter!==Bt&&O.minFilter!==Rt}function T(O,D){return O.generateMipmaps&&D&&O.minFilter!==Bt&&O.minFilter!==Rt}function C(O){a.generateMipmap(O)}function _(O,D,k,z,K=!1){if(o===!1)return D;if(O!==null){if(a[O]!==void 0)return a[O];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+O+"'")}let Q=D;return D===6403&&(k===5126&&(Q=33326),k===5131&&(Q=33325),k===5121&&(Q=33321)),D===33319&&(k===5126&&(Q=33328),k===5131&&(Q=33327),k===5121&&(Q=33323)),D===6408&&(k===5126&&(Q=34836),k===5131&&(Q=34842),k===5121&&(Q=z===nt&&K===!1?35907:32856),k===32819&&(Q=32854),k===32820&&(Q=32855)),(Q===33325||Q===33326||Q===33327||Q===33328||Q===34842||Q===34836)&&e.get("EXT_color_buffer_float"),Q}function E(O,D,k){return T(O,k)===!0||O.isFramebufferTexture&&O.minFilter!==Bt&&O.minFilter!==Rt?Math.log2(Math.max(D.width,D.height))+1:O.mipmaps!==void 0&&O.mipmaps.length>0?O.mipmaps.length:O.isCompressedTexture&&Array.isArray(O.image)?D.mipmaps.length:1}function F(O){return O===Bt||O===bo||O===wo?9728:9729}function U(O){const D=O.target;D.removeEventListener("dispose",U),J(D),D.isVideoTexture&&p.delete(D)}function q(O){const D=O.target;D.removeEventListener("dispose",q),X(D)}function J(O){const D=n.get(O);if(D.__webglInit===void 0)return;const k=O.source,z=g.get(k);if(z){const K=z[D.__cacheKey];K.usedTimes--,K.usedTimes===0&&G(O),Object.keys(z).length===0&&g.delete(k)}n.remove(O)}function G(O){const D=n.get(O);a.deleteTexture(D.__webglTexture);const k=O.source,z=g.get(k);delete z[D.__cacheKey],r.memory.textures--}function X(O){const D=O.texture,k=n.get(O),z=n.get(D);if(z.__webglTexture!==void 0&&(a.deleteTexture(z.__webglTexture),r.memory.textures--),O.depthTexture&&O.depthTexture.dispose(),O.isWebGLCubeRenderTarget)for(let K=0;K<6;K++)a.deleteFramebuffer(k.__webglFramebuffer[K]),k.__webglDepthbuffer&&a.deleteRenderbuffer(k.__webglDepthbuffer[K]);else{if(a.deleteFramebuffer(k.__webglFramebuffer),k.__webglDepthbuffer&&a.deleteRenderbuffer(k.__webglDepthbuffer),k.__webglMultisampledFramebuffer&&a.deleteFramebuffer(k.__webglMultisampledFramebuffer),k.__webglColorRenderbuffer)for(let K=0;K=c&&console.warn("THREE.WebGLTextures: Trying to use "+O+" texture units while this GPU supports only "+c),B+=1,O}function W(O){const D=[];return D.push(O.wrapS),D.push(O.wrapT),D.push(O.magFilter),D.push(O.minFilter),D.push(O.anisotropy),D.push(O.internalFormat),D.push(O.format),D.push(O.type),D.push(O.generateMipmaps),D.push(O.premultiplyAlpha),D.push(O.flipY),D.push(O.unpackAlignment),D.push(O.encoding),D.join()}function j(O,D){const k=n.get(O);if(O.isVideoTexture&&ht(O),O.isRenderTargetTexture===!1&&O.version>0&&k.__version!==O.version){const z=O.image;if(z===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(z.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{we(k,O,D);return}}t.activeTexture(33984+D),t.bindTexture(3553,k.__webglTexture)}function ne(O,D){const k=n.get(O);if(O.version>0&&k.__version!==O.version){we(k,O,D);return}t.activeTexture(33984+D),t.bindTexture(35866,k.__webglTexture)}function $(O,D){const k=n.get(O);if(O.version>0&&k.__version!==O.version){we(k,O,D);return}t.activeTexture(33984+D),t.bindTexture(32879,k.__webglTexture)}function ie(O,D){const k=n.get(O);if(O.version>0&&k.__version!==O.version){Pe(k,O,D);return}t.activeTexture(33984+D),t.bindTexture(34067,k.__webglTexture)}const ce={[cn]:10497,[jt]:33071,[_r]:33648},oe={[Bt]:9728,[bo]:9984,[wo]:9986,[Rt]:9729,[gc]:9985,[si]:9987};function H(O,D,k){if(k?(a.texParameteri(O,10242,ce[D.wrapS]),a.texParameteri(O,10243,ce[D.wrapT]),(O===32879||O===35866)&&a.texParameteri(O,32882,ce[D.wrapR]),a.texParameteri(O,10240,oe[D.magFilter]),a.texParameteri(O,10241,oe[D.minFilter])):(a.texParameteri(O,10242,33071),a.texParameteri(O,10243,33071),(O===32879||O===35866)&&a.texParameteri(O,32882,33071),(D.wrapS!==jt||D.wrapT!==jt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),a.texParameteri(O,10240,F(D.magFilter)),a.texParameteri(O,10241,F(D.minFilter)),D.minFilter!==Bt&&D.minFilter!==Rt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){const z=e.get("EXT_texture_filter_anisotropic");if(D.type===gi&&e.has("OES_texture_float_linear")===!1||o===!1&&D.type===br&&e.has("OES_texture_half_float_linear")===!1)return;(D.anisotropy>1||n.get(D).__currentAnisotropy)&&(a.texParameterf(O,z.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(D.anisotropy,i.getMaxAnisotropy())),n.get(D).__currentAnisotropy=D.anisotropy)}}function ye(O,D){let k=!1;O.__webglInit===void 0&&(O.__webglInit=!0,D.addEventListener("dispose",U));const z=D.source;let K=g.get(z);K===void 0&&(K={},g.set(z,K));const Q=W(D);if(Q!==O.__cacheKey){K[Q]===void 0&&(K[Q]={texture:a.createTexture(),usedTimes:0},r.memory.textures++,k=!0),K[Q].usedTimes++;const me=K[O.__cacheKey];me!==void 0&&(K[O.__cacheKey].usedTimes--,me.usedTimes===0&&G(D)),O.__cacheKey=Q,O.__webglTexture=K[Q].texture}return k}function we(O,D,k){let z=3553;D.isDataArrayTexture&&(z=35866),D.isData3DTexture&&(z=32879);const K=ye(O,D),Q=D.source;if(t.activeTexture(33984+k),t.bindTexture(z,O.__webglTexture),Q.version!==Q.__currentVersion||K===!0){a.pixelStorei(37440,D.flipY),a.pixelStorei(37441,D.premultiplyAlpha),a.pixelStorei(3317,D.unpackAlignment),a.pixelStorei(37443,0);const me=M(D)&&v(D.image)===!1;let R=b(D.image,me,!1,u);R=at(D,R);const ae=v(R)||o,pe=s.convert(D.format,D.encoding);let Se=s.convert(D.type),Te=_(D.internalFormat,pe,Se,D.encoding,D.isVideoTexture);H(z,D,ae);let He;const Ze=D.mipmaps,Qe=o&&D.isVideoTexture!==!0,V=Q.__currentVersion===void 0||K===!0,_e=E(D,R,ae);if(D.isDepthTexture)Te=6402,o?D.type===gi?Te=36012:D.type===Gi?Te=33190:D.type===Ms?Te=35056:Te=33189:D.type===gi&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),D.format===Wi&&Te===6402&&D.type!==Su&&D.type!==Gi&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),D.type=Gi,Se=s.convert(D.type)),D.format===Es&&Te===6402&&(Te=34041,D.type!==Ms&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),D.type=Ms,Se=s.convert(D.type))),V&&(Qe?t.texStorage2D(3553,1,Te,R.width,R.height):t.texImage2D(3553,0,Te,R.width,R.height,0,pe,Se,null));else if(D.isDataTexture)if(Ze.length>0&&ae){Qe&&V&&t.texStorage2D(3553,_e,Te,Ze[0].width,Ze[0].height);for(let re=0,Re=Ze.length;re>=1,Re>>=1}}else if(Ze.length>0&&ae){Qe&&V&&t.texStorage2D(3553,_e,Te,Ze[0].width,Ze[0].height);for(let re=0,Re=Ze.length;re0&&V++,t.texStorage2D(34067,V,He,R[0].width,R[0].height));for(let re=0;re<6;re++)if(me){Ze?t.texSubImage2D(34069+re,0,0,0,R[re].width,R[re].height,Se,Te,R[re].data):t.texImage2D(34069+re,0,He,R[re].width,R[re].height,0,Se,Te,R[re].data);for(let Re=0;Re<_e.length;Re++){const Je=_e[Re].image[re].image;Ze?t.texSubImage2D(34069+re,Re+1,0,0,Je.width,Je.height,Se,Te,Je.data):t.texImage2D(34069+re,Re+1,He,Je.width,Je.height,0,Se,Te,Je.data)}}else{Ze?t.texSubImage2D(34069+re,0,0,0,Se,Te,R[re]):t.texImage2D(34069+re,0,He,Se,Te,R[re]);for(let Re=0;Re<_e.length;Re++){const Ce=_e[Re];Ze?t.texSubImage2D(34069+re,Re+1,0,0,Se,Te,Ce.image[re]):t.texImage2D(34069+re,Re+1,He,Se,Te,Ce.image[re])}}}T(D,pe)&&C(34067),K.__currentVersion=K.version,D.onUpdate&&D.onUpdate(D)}O.__version=D.version}function xe(O,D,k,z,K){const Q=s.convert(k.format,k.encoding),me=s.convert(k.type),R=_(k.internalFormat,Q,me,k.encoding);n.get(D).__hasExternalTextures||(K===32879||K===35866?t.texImage3D(K,0,R,D.width,D.height,D.depth,0,Q,me,null):t.texImage2D(K,0,R,D.width,D.height,0,Q,me,null)),t.bindFramebuffer(36160,O),Be(D)?f.framebufferTexture2DMultisampleEXT(36160,z,K,n.get(k).__webglTexture,0,ze(D)):a.framebufferTexture2D(36160,z,K,n.get(k).__webglTexture,0),t.bindFramebuffer(36160,null)}function Ve(O,D,k){if(a.bindRenderbuffer(36161,O),D.depthBuffer&&!D.stencilBuffer){let z=33189;if(k||Be(D)){const K=D.depthTexture;K&&K.isDepthTexture&&(K.type===gi?z=36012:K.type===Gi&&(z=33190));const Q=ze(D);Be(D)?f.renderbufferStorageMultisampleEXT(36161,Q,z,D.width,D.height):a.renderbufferStorageMultisample(36161,Q,z,D.width,D.height)}else a.renderbufferStorage(36161,z,D.width,D.height);a.framebufferRenderbuffer(36160,36096,36161,O)}else if(D.depthBuffer&&D.stencilBuffer){const z=ze(D);k&&Be(D)===!1?a.renderbufferStorageMultisample(36161,z,35056,D.width,D.height):Be(D)?f.renderbufferStorageMultisampleEXT(36161,z,35056,D.width,D.height):a.renderbufferStorage(36161,34041,D.width,D.height),a.framebufferRenderbuffer(36160,33306,36161,O)}else{const z=D.isWebGLMultipleRenderTargets===!0?D.texture:[D.texture];for(let K=0;K0&&Be(O)===!1){const R=Q?D:[D];k.__webglMultisampledFramebuffer=a.createFramebuffer(),k.__webglColorRenderbuffer=[],t.bindFramebuffer(36160,k.__webglMultisampledFramebuffer);for(let ae=0;ae0&&Be(O)===!1){const D=O.isWebGLMultipleRenderTargets?O.texture:[O.texture],k=O.width,z=O.height;let K=16384;const Q=[],me=O.stencilBuffer?33306:36096,R=n.get(O),ae=O.isWebGLMultipleRenderTargets===!0;if(ae)for(let pe=0;pe0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&D.__useRenderToTexture!==!1}function ht(O){const D=r.render.frame;p.get(O)!==D&&(p.set(O,D),O.update())}function at(O,D){const k=O.encoding,z=O.format,K=O.type;return O.isCompressedTexture===!0||O.isVideoTexture===!0||O.format===ic||k!==bi&&(k===nt?o===!1?e.has("EXT_sRGB")===!0&&z===Mn?(O.format=ic,O.minFilter=Rt,O.generateMipmaps=!1):D=Lu.sRGBToLinear(D):(z!==Mn||K!==Yi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",k)),D}this.allocateTextureUnit=Y,this.resetTextureUnits=Z,this.setTexture2D=j,this.setTexture2DArray=ne,this.setTexture3D=$,this.setTextureCube=ie,this.rebindTextures=ve,this.setupRenderTarget=Fe,this.updateRenderTargetMipmap=Ee,this.updateMultisampleRenderTarget=je,this.setupDepthRenderbuffer=ue,this.setupFrameBufferTexture=xe,this.useMultisampledRTT=Be}function bp(a,e,t){const n=t.isWebGL2;function i(s,r=null){let o;if(s===Yi)return 5121;if(s===Wd)return 32819;if(s===qd)return 32820;if(s===Gd)return 5120;if(s===Vd)return 5122;if(s===Su)return 5123;if(s===Hd)return 5124;if(s===Gi)return 5125;if(s===gi)return 5126;if(s===br)return n?5131:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===Xd)return 6406;if(s===Mn)return 6408;if(s===Yd)return 6409;if(s===Zd)return 6410;if(s===Wi)return 6402;if(s===Es)return 34041;if(s===Kd)return 6403;if(s===jd)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(s===ic)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(s===Jd)return 36244;if(s===$d)return 33319;if(s===Qd)return 33320;if(s===ep)return 36249;if(s===ho||s===ja||s===fo||s===po)if(r===nt)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(s===ho)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===ja)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===fo)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===po)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===ho)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===ja)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===fo)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===po)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Dl||s===Fl||s===Nl||s===kl)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===Dl)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Fl)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Nl)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===kl)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===Tu)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Ol||s===Bl)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(s===Ol)return r===nt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(s===Bl)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===zl||s===Ul||s===Gl||s===Vl||s===Hl||s===Wl||s===ql||s===Xl||s===jl||s===Yl||s===Zl||s===Kl||s===Jl||s===$l)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(s===zl)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===Ul)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===Gl)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===Vl)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Hl)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Wl)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===ql)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===Xl)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===jl)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===Yl)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Zl)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===Kl)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Jl)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===$l)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Ql)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(s===Ql)return r===nt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;return s===Ms?n?34042:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):a[s]!==void 0?a[s]:null}return{convert:i}}class wp extends Dt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class yn extends ut{constructor(){super(),this.isGroup=!0,this.type="Group"}}const z_={type:"move"};class ul{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new yn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new yn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new P),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new yn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new P),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,s=null,r=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){r=!0;for(const m of e.hand.values()){const g=t.getJointPose(m,n);if(l.joints[m.jointName]===void 0){const y=new yn;y.matrixAutoUpdate=!1,y.visible=!1,l.joints[m.jointName]=y,l.add(y)}const x=l.joints[m.jointName];g!==null&&(x.matrix.fromArray(g.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.jointRadius=g.radius),x.visible=g!==null}const u=l.joints["index-finger-tip"],h=l.joints["thumb-tip"],f=u.position.distanceTo(h.position),d=.02,p=.005;l.inputState.pinching&&f>d+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&f<=d-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(z_)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=r!==null),this}}class Mp extends At{constructor(e,t,n,i,s,r,o,c,l,u){if(u=u!==void 0?u:Wi,u!==Wi&&u!==Es)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&u===Wi&&(n=Gi),n===void 0&&u===Es&&(n=Ms),super(null,i,s,r,o,c,u,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=o!==void 0?o:Bt,this.minFilter=c!==void 0?c:Bt,this.flipY=!1,this.generateMipmaps=!1}}class U_ extends ri{constructor(e,t){super();const n=this;let i=null,s=1,r=null,o="local-floor",c=null,l=null,u=null,h=null,f=null,d=null;const p=t.getContextAttributes();let m=null,g=null;const x=[],y=[],b=new Dt;b.layers.enable(1),b.viewport=new dt;const v=new Dt;v.layers.enable(2),v.viewport=new dt;const M=[b,v],T=new wp;T.layers.enable(1),T.layers.enable(2);let C=null,_=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(W){let j=x[W];return j===void 0&&(j=new ul,x[W]=j),j.getTargetRaySpace()},this.getControllerGrip=function(W){let j=x[W];return j===void 0&&(j=new ul,x[W]=j),j.getGripSpace()},this.getHand=function(W){let j=x[W];return j===void 0&&(j=new ul,x[W]=j),j.getHandSpace()};function E(W){const j=y.indexOf(W.inputSource);if(j===-1)return;const ne=x[j];ne!==void 0&&ne.dispatchEvent({type:W.type,data:W.inputSource})}function F(){i.removeEventListener("select",E),i.removeEventListener("selectstart",E),i.removeEventListener("selectend",E),i.removeEventListener("squeeze",E),i.removeEventListener("squeezestart",E),i.removeEventListener("squeezeend",E),i.removeEventListener("end",F),i.removeEventListener("inputsourceschange",U);for(let W=0;W=0&&(y[$]=null,x[$].dispatchEvent({type:"disconnected",data:ne}))}for(let j=0;j=y.length){y.push(ne),$=ce;break}else if(y[ce]===null){y[ce]=ne,$=ce;break}if($===-1)break}const ie=x[$];ie&&ie.dispatchEvent({type:"connected",data:ne})}}const q=new P,J=new P;function G(W,j,ne){q.setFromMatrixPosition(j.matrixWorld),J.setFromMatrixPosition(ne.matrixWorld);const $=q.distanceTo(J),ie=j.projectionMatrix.elements,ce=ne.projectionMatrix.elements,oe=ie[14]/(ie[10]-1),H=ie[14]/(ie[10]+1),ye=(ie[9]+1)/ie[5],we=(ie[9]-1)/ie[5],Pe=(ie[8]-1)/ie[0],xe=(ce[8]+1)/ce[0],Ve=oe*Pe,he=oe*xe,ue=$/(-Pe+xe),ve=ue*-Pe;j.matrixWorld.decompose(W.position,W.quaternion,W.scale),W.translateX(ve),W.translateZ(ue),W.matrixWorld.compose(W.position,W.quaternion,W.scale),W.matrixWorldInverse.copy(W.matrixWorld).invert();const Fe=oe+ue,Ee=H+ue,je=Ve-ve,ze=he+($-ve),Be=ye*H/Ee*Fe,ht=we*H/Ee*Fe;W.projectionMatrix.makePerspective(je,ze,Be,ht,Fe,Ee)}function X(W,j){j===null?W.matrixWorld.copy(W.matrix):W.matrixWorld.multiplyMatrices(j.matrixWorld,W.matrix),W.matrixWorldInverse.copy(W.matrixWorld).invert()}this.updateCamera=function(W){if(i===null)return;T.near=v.near=b.near=W.near,T.far=v.far=b.far=W.far,(C!==T.near||_!==T.far)&&(i.updateRenderState({depthNear:T.near,depthFar:T.far}),C=T.near,_=T.far);const j=W.parent,ne=T.cameras;X(T,j);for(let ie=0;ie0&&(m.alphaTest.value=g.alphaTest);const x=e.get(g).envMap;if(x&&(m.envMap.value=x,m.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap){m.lightMap.value=g.lightMap;const v=a.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*v}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity);let y;g.map?y=g.map:g.specularMap?y=g.specularMap:g.displacementMap?y=g.displacementMap:g.normalMap?y=g.normalMap:g.bumpMap?y=g.bumpMap:g.roughnessMap?y=g.roughnessMap:g.metalnessMap?y=g.metalnessMap:g.alphaMap?y=g.alphaMap:g.emissiveMap?y=g.emissiveMap:g.clearcoatMap?y=g.clearcoatMap:g.clearcoatNormalMap?y=g.clearcoatNormalMap:g.clearcoatRoughnessMap?y=g.clearcoatRoughnessMap:g.iridescenceMap?y=g.iridescenceMap:g.iridescenceThicknessMap?y=g.iridescenceThicknessMap:g.specularIntensityMap?y=g.specularIntensityMap:g.specularColorMap?y=g.specularColorMap:g.transmissionMap?y=g.transmissionMap:g.thicknessMap?y=g.thicknessMap:g.sheenColorMap?y=g.sheenColorMap:g.sheenRoughnessMap&&(y=g.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix));let b;g.aoMap?b=g.aoMap:g.lightMap&&(b=g.lightMap),b!==void 0&&(b.isWebGLRenderTarget&&(b=b.texture),b.matrixAutoUpdate===!0&&b.updateMatrix(),m.uv2Transform.value.copy(b.matrix))}function s(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity}function r(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function o(m,g,x,y){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*x,m.scale.value=y*.5,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let b;g.map?b=g.map:g.alphaMap&&(b=g.alphaMap),b!==void 0&&(b.matrixAutoUpdate===!0&&b.updateMatrix(),m.uvTransform.value.copy(b.matrix))}function c(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uvTransform.value.copy(x.matrix))}function l(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function u(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function h(m,g){m.roughness.value=g.roughness,m.metalness.value=g.metalness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap),e.get(g).envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,x){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),m.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===Dn&&m.clearcoatNormalScale.value.negate())),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=x.texture,m.transmissionSamplerSize.value.set(x.width,x.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap)}function d(m,g){g.matcap&&(m.matcap.value=g.matcap)}function p(m,g){m.referencePosition.value.copy(g.referencePosition),m.nearDistance.value=g.nearDistance,m.farDistance.value=g.farDistance}return{refreshFogUniforms:t,refreshMaterialUniforms:n}}function V_(a,e,t,n){let i={},s={},r=[];const o=t.isWebGL2?a.getParameter(35375):0;function c(y,b){const v=b.program;n.uniformBlockBinding(y,v)}function l(y,b){let v=i[y.id];v===void 0&&(p(y),v=u(y),i[y.id]=v,y.addEventListener("dispose",g));const M=b.program;n.updateUBOMapping(y,M);const T=e.render.frame;s[y.id]!==T&&(f(y),s[y.id]=T)}function u(y){const b=h();y.__bindingPointIndex=b;const v=a.createBuffer(),M=y.__size,T=y.usage;return a.bindBuffer(35345,v),a.bufferData(35345,M,T),a.bindBuffer(35345,null),a.bindBufferBase(35345,b,v),v}function h(){for(let y=0;y0){T=v%M;const U=M-T;T!==0&&U-F.boundary<0&&(v+=M-T,E.__offset=v)}v+=F.storage}return T=v%M,T>0&&(v+=M-T),y.__size=v,y.__cache={},this}function m(y){const b=y.value,v={boundary:0,storage:0};return typeof b=="number"?(v.boundary=4,v.storage=4):b.isVector2?(v.boundary=8,v.storage=8):b.isVector3||b.isColor?(v.boundary=16,v.storage=12):b.isVector4?(v.boundary=16,v.storage=16):b.isMatrix3?(v.boundary=48,v.storage=48):b.isMatrix4?(v.boundary=64,v.storage=64):b.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",b),v}function g(y){const b=y.target;b.removeEventListener("dispose",g);const v=r.indexOf(b.__bindingPointIndex);r.splice(v,1),a.deleteBuffer(i[b.id]),delete i[b.id],delete s[b.id]}function x(){for(const y in i)a.deleteBuffer(i[y]);r=[],i={},s={}}return{bind:c,update:l,dispose:x}}function H_(){const a=Ao("canvas");return a.style.display="block",a}function Fu(a={}){this.isWebGLRenderer=!0;const e=a.canvas!==void 0?a.canvas:H_(),t=a.context!==void 0?a.context:null,n=a.depth!==void 0?a.depth:!0,i=a.stencil!==void 0?a.stencil:!0,s=a.antialias!==void 0?a.antialias:!1,r=a.premultipliedAlpha!==void 0?a.premultipliedAlpha:!0,o=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,c=a.powerPreference!==void 0?a.powerPreference:"default",l=a.failIfMajorPerformanceCaveat!==void 0?a.failIfMajorPerformanceCaveat:!1;let u;t!==null?u=t.getContextAttributes().alpha:u=a.alpha!==void 0?a.alpha:!1;let h=null,f=null;const d=[],p=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=bi,this.physicallyCorrectLights=!1,this.toneMapping=Jn,this.toneMappingExposure=1,Object.defineProperties(this,{gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});const m=this;let g=!1,x=0,y=0,b=null,v=-1,M=null;const T=new dt,C=new dt;let _=null,E=e.width,F=e.height,U=1,q=null,J=null;const G=new dt(0,0,E,F),X=new dt(0,0,E,F);let B=!1;const Z=new wc;let Y=!1,W=!1,j=null;const ne=new De,$=new de,ie=new P,ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function oe(){return b===null?U:1}let H=t;function ye(N,ee){for(let le=0;le0?f=p[p.length-1]:f=null,d.pop(),d.length>0?h=d[d.length-1]:h=null};function Xn(N,ee,le,te){if(N.visible===!1)return;if(N.layers.test(ee.layers)){if(N.isGroup)le=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(ee);else if(N.isLight)f.pushLight(N),N.castShadow&&f.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||Z.intersectsSprite(N)){te&&ie.setFromMatrixPosition(N.matrixWorld).applyMatrix4(ne);const $e=ze.update(N),tt=N.material;tt.visible&&h.push(N,$e,tt,le,ie.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(N.isSkinnedMesh&&N.skeleton.frame!==Ve.render.frame&&(N.skeleton.update(),N.skeleton.frame=Ve.render.frame),!N.frustumCulled||Z.intersectsObject(N))){te&&ie.setFromMatrixPosition(N.matrixWorld).applyMatrix4(ne);const $e=ze.update(N),tt=N.material;if(Array.isArray(tt)){const et=$e.groups;for(let xt=0,lt=et.length;xt0&&zn(ge,ee,le),te&&xe.viewport(T.copy(te)),ge.length>0&&Mt(ge,ee,le),Ke.length>0&&Mt(Ke,ee,le),$e.length>0&&Mt($e,ee,le),xe.buffers.depth.setTest(!0),xe.buffers.depth.setMask(!0),xe.buffers.color.setMask(!0),xe.setPolygonOffset(!1)}function zn(N,ee,le){const te=Pe.isWebGL2;j===null&&(j=new kn(1,1,{generateMipmaps:!0,type:we.has("EXT_color_buffer_half_float")?br:Yi,minFilter:si,samples:te&&s===!0?4:0})),m.getDrawingBufferSize($),te?j.setSize($.x,$.y):j.setSize(sc($.x),sc($.y));const ge=m.getRenderTarget();m.setRenderTarget(j),m.clear();const Ke=m.toneMapping;m.toneMapping=Jn,Mt(N,ee,le),m.toneMapping=Ke,ue.updateMultisampleRenderTarget(j),ue.updateRenderTargetMipmap(j),m.setRenderTarget(ge)}function Mt(N,ee,le){const te=ee.isScene===!0?ee.overrideMaterial:null;for(let ge=0,Ke=N.length;ge0&&ue.useMultisampledRTT(N)===!1?ge=he.get(N).__webglMultisampledFramebuffer:ge=xt,T.copy(N.viewport),C.copy(N.scissor),_=N.scissorTest}else T.copy(G).multiplyScalar(U).floor(),C.copy(X).multiplyScalar(U).floor(),_=B;if(xe.bindFramebuffer(36160,ge)&&Pe.drawBuffers&&te&&xe.drawBuffers(N,ge),xe.viewport(T),xe.scissor(C),xe.setScissorTest(_),Ke){const et=he.get(N.texture);H.framebufferTexture2D(36160,36064,34069+ee,et.__webglTexture,le)}else if($e){const et=he.get(N.texture),xt=ee||0;H.framebufferTextureLayer(36160,36064,et.__webglTexture,le||0,xt)}v=-1},this.readRenderTargetPixels=function(N,ee,le,te,ge,Ke,$e){if(!(N&&N.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let tt=he.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&$e!==void 0&&(tt=tt[$e]),tt){xe.bindFramebuffer(36160,tt);try{const et=N.texture,xt=et.format,lt=et.type;if(xt!==Mn&&R.convert(xt)!==H.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ft=lt===br&&(we.has("EXT_color_buffer_half_float")||Pe.isWebGL2&&we.has("EXT_color_buffer_float"));if(lt!==Yi&&R.convert(lt)!==H.getParameter(35738)&&!(lt===gi&&(Pe.isWebGL2||we.has("OES_texture_float")||we.has("WEBGL_color_buffer_float")))&&!ft){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ee>=0&&ee<=N.width-te&&le>=0&&le<=N.height-ge&&H.readPixels(ee,le,te,ge,R.convert(xt),R.convert(lt),Ke)}finally{const et=b!==null?he.get(b).__webglFramebuffer:null;xe.bindFramebuffer(36160,et)}}},this.copyFramebufferToTexture=function(N,ee,le=0){const te=Math.pow(2,-le),ge=Math.floor(ee.image.width*te),Ke=Math.floor(ee.image.height*te);ue.setTexture2D(ee,0),H.copyTexSubImage2D(3553,le,0,0,N.x,N.y,ge,Ke),xe.unbindTexture()},this.copyTextureToTexture=function(N,ee,le,te=0){const ge=ee.image.width,Ke=ee.image.height,$e=R.convert(le.format),tt=R.convert(le.type);ue.setTexture2D(le,0),H.pixelStorei(37440,le.flipY),H.pixelStorei(37441,le.premultiplyAlpha),H.pixelStorei(3317,le.unpackAlignment),ee.isDataTexture?H.texSubImage2D(3553,te,N.x,N.y,ge,Ke,$e,tt,ee.image.data):ee.isCompressedTexture?H.compressedTexSubImage2D(3553,te,N.x,N.y,ee.mipmaps[0].width,ee.mipmaps[0].height,$e,ee.mipmaps[0].data):H.texSubImage2D(3553,te,N.x,N.y,$e,tt,ee.image),te===0&&le.generateMipmaps&&H.generateMipmap(3553),xe.unbindTexture()},this.copyTextureToTexture3D=function(N,ee,le,te,ge=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Ke=N.max.x-N.min.x+1,$e=N.max.y-N.min.y+1,tt=N.max.z-N.min.z+1,et=R.convert(te.format),xt=R.convert(te.type);let lt;if(te.isData3DTexture)ue.setTexture3D(te,0),lt=32879;else if(te.isDataArrayTexture)ue.setTexture2DArray(te,0),lt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}H.pixelStorei(37440,te.flipY),H.pixelStorei(37441,te.premultiplyAlpha),H.pixelStorei(3317,te.unpackAlignment);const ft=H.getParameter(3314),St=H.getParameter(32878),oi=H.getParameter(3316),qt=H.getParameter(3315),_n=H.getParameter(32877),dn=le.isCompressedTexture?le.mipmaps[0]:le.image;H.pixelStorei(3314,dn.width),H.pixelStorei(32878,dn.height),H.pixelStorei(3316,N.min.x),H.pixelStorei(3315,N.min.y),H.pixelStorei(32877,N.min.z),le.isDataTexture||le.isData3DTexture?H.texSubImage3D(lt,ge,ee.x,ee.y,ee.z,Ke,$e,tt,et,xt,dn.data):le.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),H.compressedTexSubImage3D(lt,ge,ee.x,ee.y,ee.z,Ke,$e,tt,et,dn.data)):H.texSubImage3D(lt,ge,ee.x,ee.y,ee.z,Ke,$e,tt,et,xt,dn),H.pixelStorei(3314,ft),H.pixelStorei(32878,St),H.pixelStorei(3316,oi),H.pixelStorei(3315,qt),H.pixelStorei(32877,_n),ge===0&&te.generateMipmaps&&H.generateMipmap(lt),xe.unbindTexture()},this.initTexture=function(N){N.isCubeTexture?ue.setTextureCube(N,0):N.isData3DTexture?ue.setTexture3D(N,0):N.isDataArrayTexture?ue.setTexture2DArray(N,0):ue.setTexture2D(N,0),xe.unbindTexture()},this.resetState=function(){x=0,y=0,b=null,xe.reset(),ae.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class Sp extends Fu{}Sp.prototype.isWebGL1Renderer=!0;class Sc{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new be(e),this.density=t}clone(){return new Sc(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class Tc{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new be(e),this.near=t,this.far=n}clone(){return new Tc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class Ac extends ut{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}}class Go{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=So,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Sn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;ie.far||t.push({distance:c,point:io.clone(),uv:In.getUV(io,wa,ro,Ma,Qh,hl,ef,new de),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Sa(a,e,t,n,i,s){lr.subVectors(a,t).addScalar(.5).multiply(n),i!==void 0?(so.x=s*lr.x-i*lr.y,so.y=i*lr.x+s*lr.y):so.copy(lr),a.copy(e),a.x+=so.x,a.y+=so.y,a.applyMatrix4(Tp)}const Ta=new P,tf=new P;class Ap extends ut{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n0){let n,i;for(n=1,i=t.length;n0){Ta.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Ta);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Ta.setFromMatrixPosition(e.matrixWorld),tf.setFromMatrixPosition(this.matrixWorld);const n=Ta.distanceTo(tf)/e.zoom;t[0].object.visible=!0;let i,s;for(i=1,s=t.length;i=t[i].distance;i++)t[i-1].object.visible=!1,t[i].object.visible=!0;for(this._currentLevel=i-1;ic)continue;f.applyMatrix4(this.matrixWorld);const _=e.ray.origin.distanceTo(f);_e.far||t.push({distance:_,point:h.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}else{const x=Math.max(0,r.start),y=Math.min(g.count,r.start+r.count);for(let b=x,v=y-1;bc)continue;f.applyMatrix4(this.matrixWorld);const T=e.ray.origin.distanceTo(f);Te.far||t.push({distance:T,point:h.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;s0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;si.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,object:r})}}class X_ extends At{constructor(e,t,n,i,s,r,o,c,l){super(e,t,n,i,s,r,o,c,l),this.isVideoTexture=!0,this.minFilter=r!==void 0?r:Rt,this.magFilter=s!==void 0?s:Rt,this.generateMipmaps=!1;const u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class j_ extends At{constructor(e,t,n){super({width:e,height:t}),this.isFramebufferTexture=!0,this.format=n,this.magFilter=Bt,this.minFilter=Bt,this.generateMipmaps=!1,this.needsUpdate=!0}}class Cp extends At{constructor(e,t,n,i,s,r,o,c,l,u,h,f){super(null,r,o,c,l,u,i,s,h,f),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class Y_ extends At{constructor(e,t,n,i,s,r,o,c,l){super(e,t,n,i,s,r,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Bn{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),s=0;t.push(0);for(let r=1;r<=e;r++)n=this.getPoint(r/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const s=n.length;let r;t?r=t:r=e*n[s-1];let o=0,c=s-1,l;for(;o<=c;)if(i=Math.floor(o+(c-o)/2),l=n[i]-r,l<0)o=i+1;else if(l>0)c=i-1;else{c=i;break}if(i=c,n[i]===r)return i/(s-1);const u=n[i],f=n[i+1]-u,d=(r-u)/f;return(i+d)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const r=this.getPoint(i),o=this.getPoint(s),c=t||(r.isVector2?new de:new P);return c.copy(o).sub(r).normalize(),c}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new P,i=[],s=[],r=[],o=new P,c=new De;for(let d=0;d<=e;d++){const p=d/e;i[d]=this.getTangentAt(p,new P)}s[0]=new P,r[0]=new P;let l=Number.MAX_VALUE;const u=Math.abs(i[0].x),h=Math.abs(i[0].y),f=Math.abs(i[0].z);u<=l&&(l=u,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),f<=l&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],o),r[0].crossVectors(i[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),r[d]=r[d-1].clone(),o.crossVectors(i[d-1],i[d]),o.length()>Number.EPSILON){o.normalize();const p=Math.acos(zt(i[d-1].dot(i[d]),-1,1));s[d].applyMatrix4(c.makeRotationAxis(o,p))}r[d].crossVectors(i[d],s[d])}if(t===!0){let d=Math.acos(zt(s[0].dot(s[e]),-1,1));d/=e,i[0].dot(o.crossVectors(s[0],s[e]))>0&&(d=-d);for(let p=1;p<=e;p++)s[p].applyMatrix4(c.makeRotationAxis(i[p],d*p)),r[p].crossVectors(i[p],s[p])}return{tangents:i,normals:s,binormals:r}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Cc extends Bn{constructor(e=0,t=0,n=1,i=1,s=0,r=Math.PI*2,o=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=r,this.aClockwise=o,this.aRotation=c}getPoint(e,t){const n=t||new de,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const r=Math.abs(s)i;)s-=i;s0?0:(Math.floor(Math.abs(o)/s)+1)*s:c===0&&o===s-1&&(o=s-2,c=1);let l,u;this.closed||o>0?l=i[(o-1)%s]:(Ra.subVectors(i[0],i[1]).add(i[0]),l=Ra);const h=i[o%s],f=i[(o+1)%s];if(this.closed||o+2i.length-2?i.length-1:r+1],h=i[r>i.length-3?i.length-1:r+2];return n.set(yf(o,c.x,l.x,u.x,h.x),yf(o,c.y,l.y,u.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const r=i[s]-n,o=this.curves[s],c=o.getLength(),l=c===0?0:1-r/c;return o.getPointAt(l,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);const u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Is extends qe{constructor(e=[new de(0,-.5),new de(.5,0),new de(0,.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=zt(i,0,Math.PI*2);const s=[],r=[],o=[],c=[],l=[],u=1/t,h=new P,f=new de,d=new P,p=new P,m=new P;let g=0,x=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:g=e[y+1].x-e[y].x,x=e[y+1].y-e[y].y,d.x=x*1,d.y=-g,d.z=x*0,m.copy(d),d.normalize(),c.push(d.x,d.y,d.z);break;case e.length-1:c.push(m.x,m.y,m.z);break;default:g=e[y+1].x-e[y].x,x=e[y+1].y-e[y].y,d.x=x*1,d.y=-g,d.z=x*0,p.copy(d),d.x+=m.x,d.y+=m.y,d.z+=m.z,d.normalize(),c.push(d.x,d.y,d.z),m.copy(p)}for(let y=0;y<=t;y++){const b=n+y*u*i,v=Math.sin(b),M=Math.cos(b);for(let T=0;T<=e.length-1;T++){h.x=e[T].x*v,h.y=e[T].y,h.z=e[T].x*M,r.push(h.x,h.y,h.z),f.x=y/t,f.y=T/(e.length-1),o.push(f.x,f.y);const C=c[3*T+0]*v,_=c[3*T+1],E=c[3*T+0]*M;l.push(C,_,E)}}for(let y=0;y0&&b(!0),t>0&&b(!1)),this.setIndex(u),this.setAttribute("position",new Ae(h,3)),this.setAttribute("normal",new Ae(f,3)),this.setAttribute("uv",new Ae(d,2));function y(){const v=new P,M=new P;let T=0;const C=(t-e)/n;for(let _=0;_<=s;_++){const E=[],F=_/s,U=F*(t-e)+e;for(let q=0;q<=i;q++){const J=q/i,G=J*c+o,X=Math.sin(G),B=Math.cos(G);M.x=U*X,M.y=-F*n+g,M.z=U*B,h.push(M.x,M.y,M.z),v.set(X,C,B).normalize(),f.push(v.x,v.y,v.z),d.push(J,1-F),E.push(p++)}m.push(E)}for(let _=0;_.9&&C<.1&&(b<.2&&(r[y+0]+=1),v<.2&&(r[y+2]+=1),M<.2&&(r[y+4]+=1))}}function f(y){s.push(y.x,y.y,y.z)}function d(y,b){const v=y*3;b.x=e[v+0],b.y=e[v+1],b.z=e[v+2]}function p(){const y=new P,b=new P,v=new P,M=new P,T=new de,C=new de,_=new de;for(let E=0,F=0;E80*t){o=l=a[0],c=u=a[1];for(let p=t;pl&&(l=h),f>u&&(u=f);d=Math.max(l-o,u-c),d=d!==0?1/d:0}return Co(s,r,t,o,c,d),r}};function Np(a,e,t,n,i){let s,r;if(i===xb(a,e,t,n)>0)for(s=e;s=e;s-=n)r=xf(s,a[s],a[s+1],r);return r&&Rc(r,r.next)&&(Ro(r),r=r.next),r}function Ji(a,e){if(!a)return a;e||(e=a);let t=a,n;do if(n=!1,!t.steiner&&(Rc(t,t.next)||It(t.prev,t,t.next)===0)){if(Ro(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Co(a,e,t,n,i,s,r){if(!a)return;!r&&s&&fb(a,n,i,s);let o=a,c,l;for(;a.prev!==a.next;){if(c=a.prev,l=a.next,s?sb(a,n,i,s):ib(a)){e.push(c.i/t),e.push(a.i/t),e.push(l.i/t),Ro(a),a=l.next,o=l.next;continue}if(a=l,a===o){r?r===1?(a=rb(Ji(a),e,t),Co(a,e,t,n,i,s,2)):r===2&&ob(a,e,t,n,i,s):Co(Ji(a),e,t,n,i,s,1);break}}}function ib(a){const e=a.prev,t=a,n=a.next;if(It(e,t,n)>=0)return!1;let i=a.next.next;for(;i!==a.prev;){if(gr(e.x,e.y,t.x,t.y,n.x,n.y,i.x,i.y)&&It(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function sb(a,e,t,n){const i=a.prev,s=a,r=a.next;if(It(i,s,r)>=0)return!1;const o=i.xs.x?i.x>r.x?i.x:r.x:s.x>r.x?s.x:r.x,u=i.y>s.y?i.y>r.y?i.y:r.y:s.y>r.y?s.y:r.y,h=ru(o,c,e,t,n),f=ru(l,u,e,t,n);let d=a.prevZ,p=a.nextZ;for(;d&&d.z>=h&&p&&p.z<=f;){if(d!==a.prev&&d!==a.next&&gr(i.x,i.y,s.x,s.y,r.x,r.y,d.x,d.y)&&It(d.prev,d,d.next)>=0||(d=d.prevZ,p!==a.prev&&p!==a.next&&gr(i.x,i.y,s.x,s.y,r.x,r.y,p.x,p.y)&&It(p.prev,p,p.next)>=0))return!1;p=p.nextZ}for(;d&&d.z>=h;){if(d!==a.prev&&d!==a.next&&gr(i.x,i.y,s.x,s.y,r.x,r.y,d.x,d.y)&&It(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=f;){if(p!==a.prev&&p!==a.next&&gr(i.x,i.y,s.x,s.y,r.x,r.y,p.x,p.y)&&It(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function rb(a,e,t){let n=a;do{const i=n.prev,s=n.next.next;!Rc(i,s)&&kp(i,n,n.next,s)&&Lo(i,s)&&Lo(s,i)&&(e.push(i.i/t),e.push(n.i/t),e.push(s.i/t),Ro(n),Ro(n.next),n=a=s),n=n.next}while(n!==a);return Ji(n)}function ob(a,e,t,n,i,s){let r=a;do{let o=r.next.next;for(;o!==r.prev;){if(r.i!==o.i&&mb(r,o)){let c=Op(r,o);r=Ji(r,r.next),c=Ji(c,c.next),Co(r,e,t,n,i,s),Co(c,e,t,n,i,s);return}o=o.next}r=r.next}while(r!==a)}function ab(a,e,t,n){const i=[];let s,r,o,c,l;for(s=0,r=e.length;s=t.next.y&&t.next.y!==t.y){const f=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=n&&f>s){if(s=f,f===n){if(i===t.y)return t;if(i===t.next.y)return t.next}r=t.x=t.x&&t.x>=c&&n!==t.x&&gr(ir.x||t.x===r.x&&hb(r,t)))&&(r=t,u=h)),t=t.next;while(t!==o);return r}function hb(a,e){return It(a.prev,a,e.prev)<0&&It(e.next,a,a.next)<0}function fb(a,e,t,n){let i=a;do i.z===null&&(i.z=ru(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==a);i.prevZ.nextZ=null,i.prevZ=null,db(i)}function db(a){let e,t,n,i,s,r,o,c,l=1;do{for(t=a,a=null,s=null,r=0;t;){for(r++,n=t,o=0,e=0;e0||c>0&&n;)o!==0&&(c===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,o--):(i=n,n=n.nextZ,c--),s?s.nextZ=i:a=i,i.prevZ=s,s=i;t=n}s.nextZ=null,l*=2}while(r>1);return a}function ru(a,e,t,n,i){return a=32767*(a-t)*i,e=32767*(e-n)*i,a=(a|a<<8)&16711935,a=(a|a<<4)&252645135,a=(a|a<<2)&858993459,a=(a|a<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,a|e<<1}function pb(a){let e=a,t=a;do(e.x=0&&(a-r)*(n-o)-(t-r)*(e-o)>=0&&(t-r)*(s-o)-(i-r)*(n-o)>=0}function mb(a,e){return a.next.i!==e.i&&a.prev.i!==e.i&&!gb(a,e)&&(Lo(a,e)&&Lo(e,a)&&yb(a,e)&&(It(a.prev,a,e.prev)||It(a,e.prev,e))||Rc(a,e)&&It(a.prev,a,a.next)>0&&It(e.prev,e,e.next)>0)}function It(a,e,t){return(e.y-a.y)*(t.x-e.x)-(e.x-a.x)*(t.y-e.y)}function Rc(a,e){return a.x===e.x&&a.y===e.y}function kp(a,e,t,n){const i=Na(It(a,e,t)),s=Na(It(a,e,n)),r=Na(It(t,n,a)),o=Na(It(t,n,e));return!!(i!==s&&r!==o||i===0&&Fa(a,t,e)||s===0&&Fa(a,n,e)||r===0&&Fa(t,a,n)||o===0&&Fa(t,e,n))}function Fa(a,e,t){return e.x<=Math.max(a.x,t.x)&&e.x>=Math.min(a.x,t.x)&&e.y<=Math.max(a.y,t.y)&&e.y>=Math.min(a.y,t.y)}function Na(a){return a>0?1:a<0?-1:0}function gb(a,e){let t=a;do{if(t.i!==a.i&&t.next.i!==a.i&&t.i!==e.i&&t.next.i!==e.i&&kp(t,t.next,a,e))return!0;t=t.next}while(t!==a);return!1}function Lo(a,e){return It(a.prev,a,a.next)<0?It(a,e,a.next)>=0&&It(a,a.prev,e)>=0:It(a,e,a.prev)<0||It(a,a.next,e)<0}function yb(a,e){let t=a,n=!1;const i=(a.x+e.x)/2,s=(a.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==a);return n}function Op(a,e){const t=new ou(a.i,a.x,a.y),n=new ou(e.i,e.x,e.y),i=a.next,s=e.prev;return a.next=e,e.prev=a,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function xf(a,e,t,n){const i=new ou(a,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Ro(a){a.next.prev=a.prev,a.prev.next=a.next,a.prevZ&&(a.prevZ.nextZ=a.nextZ),a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function ou(a,e,t){this.i=a,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function xb(a,e,t,n){let i=0;for(let s=e,r=t-n;s2&&a[e-1].equals(a[0])&&a.pop()}function _f(a,e){for(let t=0;tNumber.EPSILON){const k=Math.sqrt(O),z=Math.sqrt(ht*ht+at*at),K=ue.x-Be/k,Q=ue.y+ze/k,me=ve.x-at/z,R=ve.y+ht/z,ae=((me-K)*at-(R-Q)*ht)/(ze*at-Be*ht);Fe=K+ze*ae-he.x,Ee=Q+Be*ae-he.y;const pe=Fe*Fe+Ee*Ee;if(pe<=2)return new de(Fe,Ee);je=Math.sqrt(pe/2)}else{let k=!1;ze>Number.EPSILON?ht>Number.EPSILON&&(k=!0):ze<-Number.EPSILON?ht<-Number.EPSILON&&(k=!0):Math.sign(Be)===Math.sign(at)&&(k=!0),k?(Fe=-Be,Ee=ze,je=Math.sqrt(O)):(Fe=ze,Ee=Be,je=Math.sqrt(O/2))}return new de(Fe/je,Ee/je)}const W=[];for(let he=0,ue=G.length,ve=ue-1,Fe=he+1;he=0;he--){const ue=he/g,ve=d*Math.cos(ue*Math.PI/2),Fe=p*Math.sin(ue*Math.PI/2)+m;for(let Ee=0,je=G.length;Ee=0;){const Fe=ve;let Ee=ve-1;Ee<0&&(Ee=he.length-1);for(let je=0,ze=u+g*2;je0)&&d.push(b,v,T),(x!==n-1||c0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Qn extends Gt{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new be(16777215),this.specular=new be(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new be(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qi,this.normalScale=new de(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Oo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Gp extends Gt{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new be(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new be(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qi,this.normalScale=new de(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Vp extends Gt{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qi,this.normalScale=new de(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Ic extends Gt{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new be(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new be(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Oo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Hp extends Gt{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new be(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qi,this.normalScale=new de(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Wp extends Vt{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Rn(a,e,t){return Hu(a)?new a.constructor(a.subarray(e,t!==void 0?t:a.length)):a.slice(e,t)}function bs(a,e,t){return!a||!t&&a.constructor===e?a:typeof e.BYTES_PER_ELEMENT=="number"?new e(a):Array.prototype.slice.call(a)}function Hu(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)}function qp(a){function e(i,s){return a[i]-a[s]}const t=a.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function au(a,e,t){const n=a.length,i=new a.constructor(n);for(let s=0,r=0;r!==n;++s){const o=t[s]*e;for(let c=0;c!==e;++c)i[r++]=a[o+c]}return i}function Wu(a,e,t,n){let i=1,s=a[0];for(;s!==void 0&&s[n]===void 0;)s=a[i++];if(s===void 0)return;let r=s[n];if(r!==void 0)if(Array.isArray(r))do r=s[n],r!==void 0&&(e.push(s.time),t.push.apply(t,r)),s=a[i++];while(s!==void 0);else if(r.toArray!==void 0)do r=s[n],r!==void 0&&(e.push(s.time),r.toArray(t,t.length)),s=a[i++];while(s!==void 0);else do r=s[n],r!==void 0&&(e.push(s.time),t.push(r)),s=a[i++];while(s!==void 0)}function wb(a,e,t,n,i=30){const s=a.clone();s.name=e;const r=[];for(let c=0;c=n)){h.push(l.times[d]);for(let m=0;ms.tracks[c].times[0]&&(o=s.tracks[c].times[0]);for(let c=0;c=o.times[p]){const x=p*h+u,y=x+h-u;m=Rn(o.values,x,y)}else{const x=o.createInterpolant(),y=u,b=h-u;x.evaluate(s),m=Rn(x.resultBuffer,y,b)}c==="quaternion"&&new Ft().fromArray(m).normalize().conjugate().toArray(m);const g=l.times.length;for(let x=0;x=s)){const o=t[1];e=s)break t}r=n,n=0;break n}break e}for(;n>>1;et;)--r;if(++r,s!==0||r!==i){s>=r&&(r=Math.max(r,1),s=r-1);const o=this.getValueSize();this.times=Rn(n,s,r),this.values=Rn(this.values,s*o,r*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let r=null;for(let o=0;o!==s;o++){const c=n[o];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(r!==null&&r>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,c,r),e=!1;break}r=c}if(i!==void 0&&Hu(i))for(let o=0,c=i.length;o!==c;++o){const l=i[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){const e=Rn(this.times),t=Rn(this.values),n=this.getValueSize(),i=this.getInterpolation()===Ya,s=e.length-1;let r=1;for(let o=1;o0){e[r]=e[s];for(let o=s*n,c=r*n,l=0;l!==n;++l)t[c+l]=t[o+l];++r}return r!==e.length?(this.times=Rn(e,0,r),this.values=Rn(t,0,r*n)):(this.times=e,this.values=t),this}clone(){const e=Rn(this.times,0),t=Rn(this.values,0),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}qn.prototype.TimeBufferType=Float32Array;qn.prototype.ValueBufferType=Float32Array;qn.prototype.DefaultInterpolation=Cs;class Gs extends qn{}Gs.prototype.ValueTypeName="bool";Gs.prototype.ValueBufferType=Array;Gs.prototype.DefaultInterpolation=wr;Gs.prototype.InterpolantFactoryMethodLinear=void 0;Gs.prototype.InterpolantFactoryMethodSmooth=void 0;class Xu extends qn{}Xu.prototype.ValueTypeName="color";class Fs extends qn{}Fs.prototype.ValueTypeName="number";class Yp extends Gr{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=(n-t)/(i-t);let l=e*o;for(let u=l+o;l!==u;l+=4)Ft.slerpFlat(s,0,r,l-o,r,l,c);return s}}class ni extends qn{InterpolantFactoryMethodLinear(e){return new Yp(this.times,this.values,this.getValueSize(),e)}}ni.prototype.ValueTypeName="quaternion";ni.prototype.DefaultInterpolation=Cs;ni.prototype.InterpolantFactoryMethodSmooth=void 0;class Vs extends qn{}Vs.prototype.ValueTypeName="string";Vs.prototype.ValueBufferType=Array;Vs.prototype.DefaultInterpolation=wr;Vs.prototype.InterpolantFactoryMethodLinear=void 0;Vs.prototype.InterpolantFactoryMethodSmooth=void 0;class Mi extends qn{}Mi.prototype.ValueTypeName="vector";class Si{constructor(e,t=-1,n,i=yc){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Sn(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let r=0,o=n.length;r!==o;++r)t.push(Ab(n[r]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,r=n.length;s!==r;++s)t.push(qn.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const s=t.length,r=[];for(let o=0;o1){const h=u[1];let f=i[h];f||(i[h]=f=[]),f.push(l)}}const r=[];for(const o in i)r.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return r}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(h,f,d,p,m){if(d.length!==0){const g=[],x=[];Wu(d,g,x,p),g.length!==0&&m.push(new h(f,g,x))}},i=[],s=e.name||"default",r=e.fps||30,o=e.blendMode;let c=e.length||-1;const l=e.hierarchy||[];for(let h=0;h{t&&t(s),this.manager.itemEnd(e)},0),s;if(di[e]!==void 0){di[e].push({onLoad:t,onProgress:n,onError:i});return}di[e]=[],di[e].push({onLoad:t,onProgress:n,onError:i});const r=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,c=this.responseType;fetch(r).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream=="undefined"||l.body===void 0||l.body.getReader===void 0)return l;const u=di[e],h=l.body.getReader(),f=l.headers.get("Content-Length"),d=f?parseInt(f):0,p=d!==0;let m=0;const g=new ReadableStream({start(x){y();function y(){h.read().then(({done:b,value:v})=>{if(b)x.close();else{m+=v.byteLength;const M=new ProgressEvent("progress",{lengthComputable:p,loaded:m,total:d});for(let T=0,C=u.length;T{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(u=>new DOMParser().parseFromString(u,o));case"json":return l.json();default:if(o===void 0)return l.text();{const h=/charset="?([^;"\s]*)"?/i.exec(o),f=h&&h[1]?h[1].toLowerCase():void 0,d=new TextDecoder(f);return l.arrayBuffer().then(p=>d.decode(p))}}}).then(l=>{Ns.add(e,l);const u=di[e];delete di[e];for(let h=0,f=u.length;h{const u=di[e];if(u===void 0)throw this.manager.itemError(e),l;delete di[e];for(let h=0,f=u.length;h{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Cb extends Ht{constructor(e){super(e)}load(e,t,n,i){const s=this,r=new Kt(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}parse(e){const t=[];for(let n=0;n0:i.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const r=e.uniforms[s];switch(i.uniforms[s]={},r.type){case"t":i.uniforms[s].value=n(r.value);break;case"c":i.uniforms[s].value=new be().setHex(r.value);break;case"v2":i.uniforms[s].value=new de().fromArray(r.value);break;case"v3":i.uniforms[s].value=new P().fromArray(r.value);break;case"v4":i.uniforms[s].value=new dt().fromArray(r.value);break;case"m3":i.uniforms[s].value=new ln().fromArray(r.value);break;case"m4":i.uniforms[s].value=new De().fromArray(r.value);break;default:i.uniforms[s].value=r.value}}if(e.defines!==void 0&&(i.defines=e.defines),e.vertexShader!==void 0&&(i.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(i.fragmentShader=e.fragmentShader),e.extensions!==void 0)for(const s in e.extensions)i.extensions[s]=e.extensions[s];if(e.shading!==void 0&&(i.flatShading=e.shading===1),e.size!==void 0&&(i.size=e.size),e.sizeAttenuation!==void 0&&(i.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(i.map=n(e.map)),e.matcap!==void 0&&(i.matcap=n(e.matcap)),e.alphaMap!==void 0&&(i.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(i.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(i.bumpScale=e.bumpScale),e.normalMap!==void 0&&(i.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(i.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),i.normalScale=new de().fromArray(s)}return e.displacementMap!==void 0&&(i.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(i.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(i.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(i.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(i.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(i.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(i.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(i.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(i.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(i.envMap=n(e.envMap)),e.envMapIntensity!==void 0&&(i.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(i.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(i.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(i.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(i.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(i.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(i.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(i.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(i.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new de().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(i.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(i.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(i.thicknessMap=n(e.thicknessMap)),e.sheenColorMap!==void 0&&(i.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:zp,SpriteMaterial:Ec,RawShaderMaterial:Up,ShaderMaterial:ei,PointsMaterial:Hi,MeshPhysicalMaterial:Ci,MeshStandardMaterial:Us,MeshPhongMaterial:Qn,MeshToonMaterial:Gp,MeshNormalMaterial:Vp,MeshLambertMaterial:Ic,MeshDepthMaterial:Pu,MeshDistanceMaterial:Du,MeshBasicMaterial:un,MeshMatcapMaterial:Hp,LineDashedMaterial:Wp,LineBasicMaterial:Vt,Material:Gt};return new t[e]}}class tn{static decodeText(e){if(typeof TextDecoder!="undefined")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n0){const c=new ju(t);s=new Io(c),s.setCrossOrigin(this.crossOrigin);for(let l=0,u=e.length;l0){i=new Io(this.manager),i.setCrossOrigin(this.crossOrigin);for(let r=0,o=e.length;r0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(n[c]!==n[c+t]){o.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let s=n,r=i;s!==r;++s)t[s]=t[i+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let r=0;r!==s;++r)e[t+r]=e[n+r]}_slerp(e,t,n,i){Ft.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,s){const r=this._workIndex*s;Ft.multiplyQuaternionsFlat(e,r,e,t,e,n),Ft.slerpFlat(e,t,e,t,e,r,i)}_lerp(e,t,n,i,s){const r=1-i;for(let o=0;o!==s;++o){const c=t+o;e[c]=e[c]*r+e[n+o]*i}}_lerpAdditive(e,t,n,i,s){for(let r=0;r!==s;++r){const o=t+r;e[o]=e[o]+e[n+r]*i}}}const Qu="\\[\\]\\.:\\/",Hb=new RegExp("["+Qu+"]","g"),eh="[^"+Qu+"]",Wb="[^"+Qu.replace("\\.","")+"]",qb=/((?:WC+[\/:])*)/.source.replace("WC",eh),Xb=/(WCOD+)?/.source.replace("WCOD",Wb),jb=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",eh),Yb=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",eh),Zb=new RegExp("^"+qb+Xb+jb+Yb+"$"),Kb=["material","materials","bones"];class Jb{constructor(e,t,n){const i=n||st.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class st{constructor(e,t,n){this.path=t,this.parsedPath=n||st.parseTrackName(t),this.node=st.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new st.Composite(e,t,n):new st(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Hb,"")}static parseTrackName(e){const t=Zb.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);Kb.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: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let r=0;r=s){const h=s++,f=e[h];t[f.uuid]=u,e[u]=f,t[l]=h,e[h]=c;for(let d=0,p=i;d!==p;++d){const m=n[d],g=m[h],x=m[u];m[u]=g,m[h]=x}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_,r=e.length;for(let o=0,c=arguments.length;o!==c;++o){const l=arguments[o],u=l.uuid,h=t[u];if(h!==void 0)if(delete t[u],h0&&(t[d.uuid]=h),e[h]=d,e.pop();for(let p=0,m=i;p!==m;++p){const g=n[p];g[h]=g[f],g.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const s=this._bindings;if(i!==void 0)return s[i];const r=this._paths,o=this._parsedPaths,c=this._objects,l=c.length,u=this.nCachedObjects_,h=new Array(l);i=s.length,n[e]=i,r.push(e),o.push(t),s.push(h);for(let f=u,d=c.length;f!==d;++f){const p=c[f];h[f]=new st(p,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const i=this._paths,s=this._parsedPaths,r=this._bindings,o=r.length-1,c=r[o],l=e[o];t[l]=n,r[n]=c,r.pop(),s[n]=s[o],s.pop(),i[n]=i[o],i.pop()}}}class Qb{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const s=t.tracks,r=s.length,o=new Array(r),c={endingStart:xs,endingEnd:xs};for(let l=0;l!==r;++l){const u=s[l].createInterpolant(null);o[l]=u,u.settings=c}this._interpolantSettings=c,this._interpolants=o,this._propertyBindings=new Array(r),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=np,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const i=this._clip.duration,s=e._clip.duration,r=s/i,o=i/s;e.warp(1,r,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,s=i.time,r=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);const c=o.parameterPositions,l=o.sampleValues;return c[0]=s,c[1]=s+n,l[0]=e/r,l[1]=t/r,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const c=(e-s)*n;if(c<0||n===0)return;this._startTime=null,t=n*c}t*=this._updateTimeScale(e);const r=this._updateTime(t),o=this._updateWeight(e);if(o>0){const c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case Au:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(r),l[u].accumulateAdditive(o);break;case yc:default:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(r),l[u].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;n!==null&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,s=this._loopCount;const r=n===ip;if(e===0)return s===-1?i:r&&(s&1)===1?t-i:i;if(n===tp){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,r)):this._setEndings(this.repetitions===0,!0,r)),i>=t||i<0){const o=Math.floor(i/t);i-=t*o,s+=Math.abs(o);const c=this.repetitions-s;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){const l=e<0;this._setEndings(l,!l,r)}else this._setEndings(!1,!1,r);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=i;if(r&&(s&1)===1)return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=vs,i.endingEnd=vs):(e?i.endingStart=this.zeroSlopeAtStart?vs:xs:i.endingStart=Mo,t?i.endingEnd=this.zeroSlopeAtEnd?vs:xs:i.endingEnd=Mo)}_scheduleFading(e,t,n){const i=this._mixer,s=i.time;let r=this._weightInterpolant;r===null&&(r=i._lendControlInterpolant(),this._weightInterpolant=r);const o=r.parameterPositions,c=r.sampleValues;return o[0]=s,c[0]=t,o[1]=s+e,c[1]=n,this}}const ew=new Float32Array(1);class $a extends ri{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,s=i.length,r=e._propertyBindings,o=e._interpolants,c=n.uuid,l=this._bindingsByRootAndName;let u=l[c];u===void 0&&(u={},l[c]=u);for(let h=0;h!==s;++h){const f=i[h],d=f.name;let p=u[d];if(p!==void 0)++p.referenceCount,r[h]=p;else{if(p=r[h],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,c,d));continue}const m=t&&t._propertyBindings[h].binding.parsedPath;p=new sm(st.create(n,d,m),f.ValueTypeName,f.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,c,d),r[h]=p}o[h].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,i=e._clip.uuid,s=this._actionsByClip[i];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,i,n)}const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,s=Math.sign(e),r=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(i,e,s,r);const o=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)o[l].apply(r);return this}setTime(e){this.time=0;for(let t=0;tthis.max.x||e.ythis.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Nf.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const kf=new P,Oa=new P;class aw{constructor(e=new P,t=new P){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){kf.subVectors(e,this.start),Oa.subVectors(this.end,this.start);const n=Oa.dot(Oa);let s=Oa.dot(kf)/n;return t&&(s=zt(s,0,1)),s}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Of=new P;class cw extends ut{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;const n=new qe,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let r=0,o=1,c=32;r.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Vf.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Vf,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}}class bw extends vn{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new qe;i.setAttribute("position",new Ae(t,3)),i.setAttribute("color",new Ae(n,3));const s=new Vt({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,n){const i=new be,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class ww{constructor(){this.type="ShapePath",this.color=new be,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Eo,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,s,r){return this.currentPath.bezierCurveTo(e,t,n,i,s,r),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e,t){function n(y){const b=[];for(let v=0,M=y.length;vNumber.EPSILON){if(U<0&&(_=b[C],F=-F,E=b[T],U=-U),y.y<_.y||y.y>E.y)continue;if(y.y===_.y){if(y.x===_.x)return!0}else{const q=U*(y.x-_.x)-F*(y.y-_.y);if(q===0)return!0;if(q<0)continue;M=!M}}else{if(y.y!==_.y)continue;if(E.x<=y.x&&y.x<=_.x||_.x<=y.x&&y.x<=E.x)return!0}}return M}const s=$n.isClockWise,r=this.subPaths;if(r.length===0)return[];if(t===!0)return n(r);let o,c,l;const u=[];if(r.length===1)return c=r[0],l=new As,l.curves=c.curves,u.push(l),u;let h=!s(r[0].getPoints());h=e?!h:h;const f=[],d=[];let p=[],m=0,g;d[m]=void 0,p[m]=[];for(let y=0,b=r.length;y1){let y=!1,b=0;for(let v=0,M=d.length;v0&&y===!1&&(p=f)}let x;for(let y=0,b=d.length;y>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}const s=new Uint32Array(2048),r=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,u=0;for(;(l&8388608)===0;)l<<=1,u-=8388608;l&=-8388609,u+=947912704,s[c]=l|u}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)r[c]=c<<23;r[31]=1199570944,r[32]=2147483648;for(let c=33;c<63;++c)r[c]=2147483648+(c-32<<23);r[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:s,exponentTable:r,offsetTable:o}}function Sw(a){Math.abs(a)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),a=zt(a,-65504,65504),mi.floatView[0]=a;const e=mi.uint32View[0],t=e>>23&511;return mi.baseTable[t]+((e&8388607)>>mi.shiftTable[t])}function Tw(a){const e=a>>10;return mi.uint32View[0]=mi.mantissaTable[mi.offsetTable[e]+(a&1023)]+mi.exponentTable[e],mi.floatView[0]}var Aw=Object.freeze({__proto__:null,toHalfFloat:Sw,fromHalfFloat:Tw});class Ew extends qe{constructor(){console.error("THREE.ParametricGeometry has been moved to /examples/jsm/geometries/ParametricGeometry.js"),super()}}class Cw extends qe{constructor(){console.error("THREE.TextGeometry has been moved to /examples/jsm/geometries/TextGeometry.js"),super()}}function Lw(){console.error("THREE.FontLoader has been moved to /examples/jsm/loaders/FontLoader.js")}function Rw(){console.error("THREE.Font has been moved to /examples/jsm/loaders/FontLoader.js")}function Iw(){console.error("THREE.ImmediateRenderObject has been removed.")}class Pw extends kn{constructor(e,t,n){console.error('THREE.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the "samples" property to greater 0 to enable multisampling.'),super(e,t,n),this.samples=4}}class Dw extends Bo{constructor(e,t,n,i){console.warn("THREE.DataTexture2DArray has been renamed to DataArrayTexture."),super(e,t,n,i)}}class Fw extends xc{constructor(e,t,n,i){console.warn("THREE.DataTexture3D has been renamed to Data3DTexture."),super(e,t,n,i)}}typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:pc}}));typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=pc);var Nw=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:zd,AddEquation:gs,AddOperation:Nd,AdditiveAnimationBlendMode:Au,AdditiveBlending:Cl,AlphaFormat:Xd,AlwaysDepth:Cd,AlwaysStencilFunc:cp,AmbientLight:Wo,AmbientLightProbe:kb,AnimationClip:Si,AnimationLoader:Cb,AnimationMixer:$a,AnimationObjectGroup:$b,AnimationUtils:Sb,ArcCurve:Lp,ArrayCamera:wp,ArrowHelper:_w,Audio:im,AudioAnalyser:Vb,AudioContext:Ju,AudioListener:zb,AudioLoader:Fb,AxesHelper:bw,BackSide:Dn,BasicDepthPacking:rp,BasicShadowMap:eg,Bone:Rs,BooleanKeyframeTrack:Gs,Box2:ow,Box3:Ei,Box3Helper:xw,BoxBufferGeometry:wi,BoxGeometry:wi,BoxHelper:yw,BufferAttribute:pt,BufferGeometry:qe,BufferGeometryLoader:em,ByteType:Gd,Cache:Ns,Camera:bc,CameraHelper:gw,CanvasTexture:Y_,CapsuleBufferGeometry:Tr,CapsuleGeometry:Tr,CatmullRomCurve3:Rp,CineonToneMapping:Bd,CircleBufferGeometry:Ar,CircleGeometry:Ar,ClampToEdgeWrapping:jt,Clock:$u,Color:be,ColorKeyframeTrack:Xu,ColorManagement:Cn,CompressedTexture:Cp,CompressedTextureLoader:Zp,ConeBufferGeometry:Er,ConeGeometry:Er,CubeCamera:dp,CubeReflectionMapping:Xi,CubeRefractionMapping:ji,CubeTexture:Uo,CubeTextureLoader:Lb,CubeUVReflectionMapping:zr,CubicBezierCurve:Bu,CubicBezierCurve3:Ip,CubicInterpolant:Xp,CullFaceBack:El,CullFaceFront:fd,CullFaceFrontBack:Qm,CullFaceNone:hd,Curve:Bn,CurvePath:Dp,CustomBlending:md,CustomToneMapping:Ud,CylinderBufferGeometry:Ki,CylinderGeometry:Ki,Cylindrical:rw,Data3DTexture:xc,DataArrayTexture:Bo,DataTexture:yr,DataTexture2DArray:Dw,DataTexture3D:Fw,DataTextureLoader:Kp,DataUtils:Aw,DecrementStencilOp:hg,DecrementWrapStencilOp:dg,DefaultLoadingManager:Yu,DepthFormat:Wi,DepthStencilFormat:Es,DepthTexture:Mp,DirectionalLight:Vr,DirectionalLightHelper:mw,DiscreteInterpolant:jp,DodecahedronBufferGeometry:Cr,DodecahedronGeometry:Cr,DoubleSide:_i,DstAlphaFactor:wd,DstColorFactor:Sd,DynamicCopyUsage:Cg,DynamicDrawUsage:wg,DynamicReadUsage:Tg,EdgesGeometry:Fp,EllipseCurve:Cc,EqualDepth:Rd,EqualStencilFunc:yg,EquirectangularReflectionMapping:vr,EquirectangularRefractionMapping:_o,Euler:Pn,EventDispatcher:ri,ExtrudeBufferGeometry:Lr,ExtrudeGeometry:Lr,FileLoader:Kt,FlatShading:pd,Float16BufferAttribute:u0,Float32BufferAttribute:Ae,Float64BufferAttribute:h0,FloatType:gi,Fog:Tc,FogExp2:Sc,Font:Rw,FontLoader:Lw,FramebufferTexture:j_,FrontSide:vi,Frustum:wc,GLBufferAttribute:sw,GLSL1:Rg,GLSL3:eu,GreaterDepth:Pd,GreaterEqualDepth:Id,GreaterEqualStencilFunc:bg,GreaterStencilFunc:vg,GridHelper:dw,Group:yn,HalfFloatType:br,HemisphereLight:Zu,HemisphereLightHelper:fw,HemisphereLightProbe:Nb,IcosahedronBufferGeometry:Rr,IcosahedronGeometry:Rr,ImageBitmapLoader:nm,ImageLoader:Io,ImageUtils:Lu,ImmediateRenderObject:Iw,IncrementStencilOp:ug,IncrementWrapStencilOp:fg,InstancedBufferAttribute:Sr,InstancedBufferGeometry:Qp,InstancedInterleavedBuffer:iw,InstancedMesh:Ep,Int16BufferAttribute:c0,Int32BufferAttribute:l0,Int8BufferAttribute:r0,IntType:Hd,InterleavedBuffer:Go,InterleavedBufferAttribute:Zi,Interpolant:Gr,InterpolateDiscrete:wr,InterpolateLinear:Cs,InterpolateSmooth:Ya,InvertStencilOp:pg,KeepStencilOp:Za,KeyframeTrack:qn,LOD:Ap,LatheBufferGeometry:Is,LatheGeometry:Is,Layers:vc,LessDepth:Ld,LessEqualDepth:nc,LessEqualStencilFunc:xg,LessStencilFunc:gg,Light:ts,LightProbe:Pc,Line:Wn,Line3:aw,LineBasicMaterial:Vt,LineCurve:Lc,LineCurve3:Pp,LineDashedMaterial:Wp,LineLoop:ku,LineSegments:vn,LinearEncoding:bi,LinearFilter:Rt,LinearInterpolant:qu,LinearMipMapLinearFilter:rg,LinearMipMapNearestFilter:sg,LinearMipmapLinearFilter:si,LinearMipmapNearestFilter:gc,LinearSRGBColorSpace:Vi,LinearToneMapping:kd,Loader:Ht,LoaderUtils:tn,LoadingManager:ju,LoopOnce:tp,LoopPingPong:ip,LoopRepeat:np,LuminanceAlphaFormat:Zd,LuminanceFormat:Yd,MOUSE:fs,Material:Gt,MaterialLoader:Dc,MathUtils:en,Matrix3:ln,Matrix4:De,MaxEquation:Pl,Mesh:Tt,MeshBasicMaterial:un,MeshDepthMaterial:Pu,MeshDistanceMaterial:Du,MeshLambertMaterial:Ic,MeshMatcapMaterial:Hp,MeshNormalMaterial:Vp,MeshPhongMaterial:Qn,MeshPhysicalMaterial:Ci,MeshStandardMaterial:Us,MeshToonMaterial:Gp,MinEquation:Il,MirroredRepeatWrapping:_r,MixOperation:Fd,MultiplyBlending:Rl,MultiplyOperation:Oo,NearestFilter:Bt,NearestMipMapLinearFilter:ig,NearestMipMapNearestFilter:ng,NearestMipmapLinearFilter:wo,NearestMipmapNearestFilter:bo,NeverDepth:Ed,NeverStencilFunc:mg,NoBlending:xi,NoColorSpace:ag,NoToneMapping:Jn,NormalAnimationBlendMode:yc,NormalBlending:ws,NotEqualDepth:Dd,NotEqualStencilFunc:_g,NumberKeyframeTrack:Fs,Object3D:ut,ObjectLoader:tm,ObjectSpaceNormalMap:ap,OctahedronBufferGeometry:Ps,OctahedronGeometry:Ps,OneFactor:vd,OneMinusDstAlphaFactor:Md,OneMinusDstColorFactor:Td,OneMinusSrcAlphaFactor:Mu,OneMinusSrcColorFactor:bd,OrthographicCamera:Bs,PCFShadowMap:bu,PCFSoftShadowMap:dd,PMREMGenerator:nu,ParametricGeometry:Ew,Path:Eo,PerspectiveCamera:Dt,Plane:Ui,PlaneBufferGeometry:Ls,PlaneGeometry:Ls,PlaneHelper:vw,PointLight:Os,PointLightHelper:uw,Points:xr,PointsMaterial:Hi,PolarGridHelper:pw,PolyhedronBufferGeometry:ti,PolyhedronGeometry:ti,PositionalAudio:Gb,PropertyBinding:st,PropertyMixer:sm,QuadraticBezierCurve:zu,QuadraticBezierCurve3:Uu,Quaternion:Ft,QuaternionKeyframeTrack:ni,QuaternionLinearInterpolant:Yp,REVISION:pc,RGBADepthPacking:op,RGBAFormat:Mn,RGBAIntegerFormat:ep,RGBA_ASTC_10x10_Format:Kl,RGBA_ASTC_10x5_Format:jl,RGBA_ASTC_10x6_Format:Yl,RGBA_ASTC_10x8_Format:Zl,RGBA_ASTC_12x10_Format:Jl,RGBA_ASTC_12x12_Format:$l,RGBA_ASTC_4x4_Format:zl,RGBA_ASTC_5x4_Format:Ul,RGBA_ASTC_5x5_Format:Gl,RGBA_ASTC_6x5_Format:Vl,RGBA_ASTC_6x6_Format:Hl,RGBA_ASTC_8x5_Format:Wl,RGBA_ASTC_8x6_Format:ql,RGBA_ASTC_8x8_Format:Xl,RGBA_BPTC_Format:Ql,RGBA_ETC2_EAC_Format:Bl,RGBA_PVRTC_2BPPV1_Format:kl,RGBA_PVRTC_4BPPV1_Format:Nl,RGBA_S3TC_DXT1_Format:ja,RGBA_S3TC_DXT3_Format:fo,RGBA_S3TC_DXT5_Format:po,RGBFormat:jd,RGB_ETC1_Format:Tu,RGB_ETC2_Format:Ol,RGB_PVRTC_2BPPV1_Format:Fl,RGB_PVRTC_4BPPV1_Format:Dl,RGB_S3TC_DXT1_Format:ho,RGFormat:$d,RGIntegerFormat:Qd,RawShaderMaterial:Up,Ray:zo,Raycaster:rm,RectAreaLight:Jp,RedFormat:Kd,RedIntegerFormat:Jd,ReinhardToneMapping:Od,RepeatWrapping:cn,ReplaceStencilOp:lg,ReverseSubtractEquation:yd,RingBufferGeometry:Ir,RingGeometry:Ir,SRGBColorSpace:Zn,Scene:Ac,ShaderChunk:it,ShaderLib:Hn,ShaderMaterial:ei,ShadowMaterial:zp,Shape:As,ShapeBufferGeometry:Pr,ShapeGeometry:Pr,ShapePath:ww,ShapeUtils:$n,ShortType:Vd,Skeleton:zs,SkeletonHelper:lw,SkinnedMesh:Vo,SmoothShading:tg,Source:_s,Sphere:es,SphereBufferGeometry:Ds,SphereGeometry:Ds,Spherical:lu,SphericalHarmonics3:$p,SplineCurve:Gu,SpotLight:Ho,SpotLightHelper:cw,Sprite:Nu,SpriteMaterial:Ec,SrcAlphaFactor:wu,SrcAlphaSaturateFactor:Ad,SrcColorFactor:_d,StaticCopyUsage:Eg,StaticDrawUsage:So,StaticReadUsage:Sg,StereoCamera:Ob,StreamCopyUsage:Lg,StreamDrawUsage:Mg,StreamReadUsage:Ag,StringKeyframeTrack:Vs,SubtractEquation:gd,SubtractiveBlending:Ll,TOUCH:ds,TangentSpaceNormalMap:Qi,TetrahedronBufferGeometry:Dr,TetrahedronGeometry:Dr,TextGeometry:Cw,Texture:At,TextureLoader:ks,TorusBufferGeometry:Fr,TorusGeometry:Fr,TorusKnotBufferGeometry:Nr,TorusKnotGeometry:Nr,Triangle:In,TriangleFanDrawMode:Eu,TriangleStripDrawMode:sp,TrianglesDrawMode:og,TubeBufferGeometry:kr,TubeGeometry:kr,UVMapping:mc,Uint16BufferAttribute:_c,Uint32BufferAttribute:Ru,Uint8BufferAttribute:o0,Uint8ClampedBufferAttribute:a0,Uniform:th,UniformsGroup:nw,UniformsLib:Ie,UniformsUtils:fp,UnsignedByteType:Yi,UnsignedInt248Type:Ms,UnsignedIntType:Gi,UnsignedShort4444Type:Wd,UnsignedShort5551Type:qd,UnsignedShortType:Su,VSMShadowMap:dr,Vector2:de,Vector3:P,Vector4:dt,VectorKeyframeTrack:Mi,VideoTexture:X_,WebGL1Renderer:Sp,WebGL3DRenderTarget:Zg,WebGLArrayRenderTarget:Yg,WebGLCubeRenderTarget:pp,WebGLMultipleRenderTargets:Kg,WebGLMultisampleRenderTarget:Pw,WebGLRenderTarget:kn,WebGLRenderer:Fu,WebGLUtils:bp,WireframeGeometry:Bp,WrapAroundEnding:Mo,ZeroCurvatureEnding:xs,ZeroFactor:xd,ZeroSlopeEnding:vs,ZeroStencilOp:cg,_SRGBAFormat:ic,sRGBEncoding:nt},Symbol.toStringTag,{value:"Module"}));const Hf={type:"change"},_l={type:"start"},Wf={type:"end"};class kw extends ri{constructor(e,t){super(),t===void 0&&console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.'),t===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.object=e,this.domElement=t,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new P,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:fs.ROTATE,MIDDLE:fs.DOLLY,RIGHT:fs.PAN},this.touches={ONE:ds.ROTATE,TWO:ds.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return o.phi},this.getAzimuthalAngle=function(){return o.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(R){R.addEventListener("keydown",at),this._domElementKeyEvents=R},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(Hf),n.update(),s=i.NONE},this.update=function(){const R=new P,ae=new Ft().setFromUnitVectors(e.up,new P(0,1,0)),pe=ae.clone().invert(),Se=new P,Te=new Ft,He=2*Math.PI;return function(){const Qe=n.object.position;R.copy(Qe).sub(n.target),R.applyQuaternion(ae),o.setFromVector3(R),n.autoRotate&&s===i.NONE&&E(C()),n.enableDamping?(o.theta+=c.theta*n.dampingFactor,o.phi+=c.phi*n.dampingFactor):(o.theta+=c.theta,o.phi+=c.phi);let V=n.minAzimuthAngle,_e=n.maxAzimuthAngle;return isFinite(V)&&isFinite(_e)&&(V<-Math.PI?V+=He:V>Math.PI&&(V-=He),_e<-Math.PI?_e+=He:_e>Math.PI&&(_e-=He),V<=_e?o.theta=Math.max(V,Math.min(_e,o.theta)):o.theta=o.theta>(V+_e)/2?Math.max(V,o.theta):Math.min(_e,o.theta)),o.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,o.phi)),o.makeSafe(),o.radius*=l,o.radius=Math.max(n.minDistance,Math.min(n.maxDistance,o.radius)),n.enableDamping===!0?n.target.addScaledVector(u,n.dampingFactor):n.target.add(u),R.setFromSpherical(o),R.applyQuaternion(pe),Qe.copy(n.target).add(R),n.object.lookAt(n.target),n.enableDamping===!0?(c.theta*=1-n.dampingFactor,c.phi*=1-n.dampingFactor,u.multiplyScalar(1-n.dampingFactor)):(c.set(0,0,0),u.set(0,0,0)),l=1,h||Se.distanceToSquared(n.object.position)>r||8*(1-Te.dot(n.object.quaternion))>r?(n.dispatchEvent(Hf),Se.copy(n.object.position),Te.copy(n.object.quaternion),h=!1,!0):!1}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",k),n.domElement.removeEventListener("pointerdown",ve),n.domElement.removeEventListener("pointercancel",je),n.domElement.removeEventListener("wheel",ht),n.domElement.removeEventListener("pointermove",Fe),n.domElement.removeEventListener("pointerup",Ee),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",at)};const n=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=i.NONE;const r=1e-6,o=new lu,c=new lu;let l=1;const u=new P;let h=!1;const f=new de,d=new de,p=new de,m=new de,g=new de,x=new de,y=new de,b=new de,v=new de,M=[],T={};function C(){return 2*Math.PI/60/60*n.autoRotateSpeed}function _(){return Math.pow(.95,n.zoomSpeed)}function E(R){c.theta-=R}function F(R){c.phi-=R}const U=function(){const R=new P;return function(pe,Se){R.setFromMatrixColumn(Se,0),R.multiplyScalar(-pe),u.add(R)}}(),q=function(){const R=new P;return function(pe,Se){n.screenSpacePanning===!0?R.setFromMatrixColumn(Se,1):(R.setFromMatrixColumn(Se,0),R.crossVectors(n.object.up,R)),R.multiplyScalar(pe),u.add(R)}}(),J=function(){const R=new P;return function(pe,Se){const Te=n.domElement;if(n.object.isPerspectiveCamera){const He=n.object.position;R.copy(He).sub(n.target);let Ze=R.length();Ze*=Math.tan(n.object.fov/2*Math.PI/180),U(2*pe*Ze/Te.clientHeight,n.object.matrix),q(2*Se*Ze/Te.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(U(pe*(n.object.right-n.object.left)/n.object.zoom/Te.clientWidth,n.object.matrix),q(Se*(n.object.top-n.object.bottom)/n.object.zoom/Te.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function G(R){n.object.isPerspectiveCamera?l/=R:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom*R)),n.object.updateProjectionMatrix(),h=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function X(R){n.object.isPerspectiveCamera?l*=R:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/R)),n.object.updateProjectionMatrix(),h=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function B(R){f.set(R.clientX,R.clientY)}function Z(R){y.set(R.clientX,R.clientY)}function Y(R){m.set(R.clientX,R.clientY)}function W(R){d.set(R.clientX,R.clientY),p.subVectors(d,f).multiplyScalar(n.rotateSpeed);const ae=n.domElement;E(2*Math.PI*p.x/ae.clientHeight),F(2*Math.PI*p.y/ae.clientHeight),f.copy(d),n.update()}function j(R){b.set(R.clientX,R.clientY),v.subVectors(b,y),v.y>0?G(_()):v.y<0&&X(_()),y.copy(b),n.update()}function ne(R){g.set(R.clientX,R.clientY),x.subVectors(g,m).multiplyScalar(n.panSpeed),J(x.x,x.y),m.copy(g),n.update()}function $(R){R.deltaY<0?X(_()):R.deltaY>0&&G(_()),n.update()}function ie(R){let ae=!1;switch(R.code){case n.keys.UP:J(0,n.keyPanSpeed),ae=!0;break;case n.keys.BOTTOM:J(0,-n.keyPanSpeed),ae=!0;break;case n.keys.LEFT:J(n.keyPanSpeed,0),ae=!0;break;case n.keys.RIGHT:J(-n.keyPanSpeed,0),ae=!0;break}ae&&(R.preventDefault(),n.update())}function ce(){if(M.length===1)f.set(M[0].pageX,M[0].pageY);else{const R=.5*(M[0].pageX+M[1].pageX),ae=.5*(M[0].pageY+M[1].pageY);f.set(R,ae)}}function oe(){if(M.length===1)m.set(M[0].pageX,M[0].pageY);else{const R=.5*(M[0].pageX+M[1].pageX),ae=.5*(M[0].pageY+M[1].pageY);m.set(R,ae)}}function H(){const R=M[0].pageX-M[1].pageX,ae=M[0].pageY-M[1].pageY,pe=Math.sqrt(R*R+ae*ae);y.set(0,pe)}function ye(){n.enableZoom&&H(),n.enablePan&&oe()}function we(){n.enableZoom&&H(),n.enableRotate&&ce()}function Pe(R){if(M.length==1)d.set(R.pageX,R.pageY);else{const pe=me(R),Se=.5*(R.pageX+pe.x),Te=.5*(R.pageY+pe.y);d.set(Se,Te)}p.subVectors(d,f).multiplyScalar(n.rotateSpeed);const ae=n.domElement;E(2*Math.PI*p.x/ae.clientHeight),F(2*Math.PI*p.y/ae.clientHeight),f.copy(d)}function xe(R){if(M.length===1)g.set(R.pageX,R.pageY);else{const ae=me(R),pe=.5*(R.pageX+ae.x),Se=.5*(R.pageY+ae.y);g.set(pe,Se)}x.subVectors(g,m).multiplyScalar(n.panSpeed),J(x.x,x.y),m.copy(g)}function Ve(R){const ae=me(R),pe=R.pageX-ae.x,Se=R.pageY-ae.y,Te=Math.sqrt(pe*pe+Se*Se);b.set(0,Te),v.set(0,Math.pow(b.y/y.y,n.zoomSpeed)),G(v.y),y.copy(b)}function he(R){n.enableZoom&&Ve(R),n.enablePan&&xe(R)}function ue(R){n.enableZoom&&Ve(R),n.enableRotate&&Pe(R)}function ve(R){n.enabled!==!1&&(M.length===0&&(n.domElement.setPointerCapture(R.pointerId),n.domElement.addEventListener("pointermove",Fe),n.domElement.addEventListener("pointerup",Ee)),z(R),R.pointerType==="touch"?O(R):ze(R))}function Fe(R){n.enabled!==!1&&(R.pointerType==="touch"?D(R):Be(R))}function Ee(R){K(R),M.length===0&&(n.domElement.releasePointerCapture(R.pointerId),n.domElement.removeEventListener("pointermove",Fe),n.domElement.removeEventListener("pointerup",Ee)),n.dispatchEvent(Wf),s=i.NONE}function je(R){K(R)}function ze(R){let ae;switch(R.button){case 0:ae=n.mouseButtons.LEFT;break;case 1:ae=n.mouseButtons.MIDDLE;break;case 2:ae=n.mouseButtons.RIGHT;break;default:ae=-1}switch(ae){case fs.DOLLY:if(n.enableZoom===!1)return;Z(R),s=i.DOLLY;break;case fs.ROTATE:if(R.ctrlKey||R.metaKey||R.shiftKey){if(n.enablePan===!1)return;Y(R),s=i.PAN}else{if(n.enableRotate===!1)return;B(R),s=i.ROTATE}break;case fs.PAN:if(R.ctrlKey||R.metaKey||R.shiftKey){if(n.enableRotate===!1)return;B(R),s=i.ROTATE}else{if(n.enablePan===!1)return;Y(R),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&n.dispatchEvent(_l)}function Be(R){switch(s){case i.ROTATE:if(n.enableRotate===!1)return;W(R);break;case i.DOLLY:if(n.enableZoom===!1)return;j(R);break;case i.PAN:if(n.enablePan===!1)return;ne(R);break}}function ht(R){n.enabled===!1||n.enableZoom===!1||s!==i.NONE||(R.preventDefault(),n.dispatchEvent(_l),$(R),n.dispatchEvent(Wf))}function at(R){n.enabled===!1||n.enablePan===!1||ie(R)}function O(R){switch(Q(R),M.length){case 1:switch(n.touches.ONE){case ds.ROTATE:if(n.enableRotate===!1)return;ce(),s=i.TOUCH_ROTATE;break;case ds.PAN:if(n.enablePan===!1)return;oe(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(n.touches.TWO){case ds.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;ye(),s=i.TOUCH_DOLLY_PAN;break;case ds.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;we(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&n.dispatchEvent(_l)}function D(R){switch(Q(R),s){case i.TOUCH_ROTATE:if(n.enableRotate===!1)return;Pe(R),n.update();break;case i.TOUCH_PAN:if(n.enablePan===!1)return;xe(R),n.update();break;case i.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;he(R),n.update();break;case i.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;ue(R),n.update();break;default:s=i.NONE}}function k(R){n.enabled!==!1&&R.preventDefault()}function z(R){M.push(R)}function K(R){delete T[R.pointerId];for(let ae=0;ae=s+1e3&&(o.update(r*1e3/(u-s),100),s=u,r=0,l)){var h=performance.memory;l.update(h.usedJSHeapSize/1048576,h.jsHeapSizeLimit/1048576)}return u},update:function(){i=this.end()},domElement:e,setMode:n}};xo.Panel=function(a,e,t){var n=1/0,i=0,s=Math.round,r=s(window.devicePixelRatio||1),o=80*r,c=48*r,l=3*r,u=2*r,h=3*r,f=15*r,d=74*r,p=30*r,m=document.createElement("canvas");m.width=o,m.height=c,m.style.cssText="width:80px;height:48px";var g=m.getContext("2d");return g.font="bold "+9*r+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=t,g.fillRect(0,0,o,c),g.fillStyle=e,g.fillText(a,l,u),g.fillRect(h,f,d,p),g.fillStyle=t,g.globalAlpha=.9,g.fillRect(h,f,d,p),{dom:m,update:function(x,y){n=Math.min(n,x),i=Math.max(i,x),g.fillStyle=t,g.globalAlpha=1,g.fillRect(0,0,o,f),g.fillStyle=e,g.fillText(s(x)+" "+a+" ("+s(n)+"-"+s(i)+")",l,u),g.drawImage(m,h+r,f,d-r,p,h,f,d-r,p),g.fillRect(h+d-r,f,r,p),g.fillStyle=t,g.globalAlpha=.9,g.fillRect(h+d-r,f,r,s((1-x/y)*p))}}};/*! fflate - fast JavaScript compression/decompression Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE version 0.6.9 -*/var Wf={},lu=function(a){return URL.createObjectURL(new Blob([a],{type:"text/javascript"}))},am=function(a){return new Worker(a)};try{URL.revokeObjectURL(lu(""))}catch{lu=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},am=function(e){return new Worker(e,{type:"module"})}}var Ow=function(a,e,t,n,i){var s=am(Wf[e]||(Wf[e]=lu(a)));return s.onerror=function(r){return i(r.error,null)},s.onmessage=function(r){return i(null,r.data)},s.postMessage(t,n),s},at=Uint8Array,Qt=Uint16Array,Ti=Uint32Array,Hr=new at([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Wr=new at([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Po=new at([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),cm=function(a,e){for(var t=new Qt(31),n=0;n<31;++n)t[n]=e+=1<>>1|(wt&21845)<<1;Bi=(Bi&52428)>>>2|(Bi&13107)<<2,Bi=(Bi&61680)>>>4|(Bi&3855)<<4,Do[wt]=((Bi&65280)>>>8|(Bi&255)<<8)>>>1}var Fn=function(a,e,t){for(var n=a.length,i=0,s=new Qt(e);i>>c]=l}else for(o=new Qt(n),i=0;i>>15-a[i]);return o},Ai=new at(288);for(var wt=0;wt<144;++wt)Ai[wt]=8;for(var wt=144;wt<256;++wt)Ai[wt]=9;for(var wt=256;wt<280;++wt)Ai[wt]=7;for(var wt=280;wt<288;++wt)Ai[wt]=8;var Or=new at(32);for(var wt=0;wt<32;++wt)Or[wt]=5;var fm=Fn(Ai,9,0),dm=Fn(Ai,9,1),pm=Fn(Or,5,0),mm=Fn(Or,5,1),$a=function(a){for(var e=a[0],t=1;te&&(e=a[t]);return e},Ln=function(a,e,t){var n=e/8|0;return(a[n]|a[n+1]<<8)>>(e&7)&t},Qa=function(a,e){var t=e/8|0;return(a[t]|a[t+1]<<8|a[t+2]<<16)>>(e&7)},qo=function(a){return(a/8|0)+(a&7&&1)},Nn=function(a,e,t){(e==null||e<0)&&(e=0),(t==null||t>a.length)&&(t=a.length);var n=new(a instanceof Qt?Qt:a instanceof Ti?Ti:at)(t-e);return n.set(a.subarray(e,t)),n},Xo=function(a,e,t){var n=a.length;if(!n||t&&!t.l&&n<5)return e||new at(0);var i=!e||t,s=!t||t.i;t||(t={}),e||(e=new at(n*3));var r=function(V){var me=e.length;if(V>me){var _e=new at(Math.max(me*2,V));_e.set(e),e=_e}},o=t.f||0,c=t.p||0,l=t.b||0,u=t.l,h=t.d,f=t.m,d=t.n,p=n*8;do{if(!u){t.f=o=Ln(a,c,1);var m=Ln(a,c+1,3);if(c+=3,m)if(m==1)u=dm,h=mm,f=9,d=5;else if(m==2){var b=Ln(a,c,31)+257,v=Ln(a,c+10,15)+4,S=b+Ln(a,c+5,31)+1;c+=14;for(var A=new at(S),R=new at(19),_=0;_>>4;if(g<16)A[_++]=g;else{var K=0,z=0;for(g==16?(z=3+Ln(a,c,3),c+=2,K=A[_-1]):g==17?(z=3+Ln(a,c,7),c+=3):g==18&&(z=11+Ln(a,c,127),c+=7);z--;)A[_++]=K}}var q=A.subarray(0,b),O=A.subarray(b);f=$a(q),d=$a(O),u=Fn(q,f,1),h=Fn(O,d,1)}else throw"invalid block type";else{var g=qo(c)+4,x=a[g-4]|a[g-3]<<8,y=g+x;if(y>n){if(s)throw"unexpected EOF";break}i&&r(l+x),e.set(a.subarray(g,y),l),t.b=l+=x,t.p=c=y*8;continue}if(c>p){if(s)throw"unexpected EOF";break}}i&&r(l+131072);for(var Y=(1<>>4;if(c+=K&15,c>p){if(s)throw"unexpected EOF";break}if(!K)throw"invalid length/literal";if(X<256)e[l++]=X;else if(X==256){H=c,u=null;break}else{var te=X-254;if(X>264){var _=X-257,J=Hr[_];te=Ln(a,c,(1<>>4;if(!ne)throw"invalid distance";c+=ne&15;var O=hm[re];if(re>3){var J=Wr[re];O+=Qa(a,c)&(1<p){if(s)throw"unexpected EOF";break}i&&r(l+131072);for(var se=l+te;l>>8},hr=function(a,e,t){t<<=e&7;var n=e/8|0;a[n]|=t,a[n+1]|=t>>>8,a[n+2]|=t>>>16},ec=function(a,e){for(var t=[],n=0;nf&&(f=s[n].s);var d=new Qt(f+1),p=rc(t[u-1],d,0);if(p>e){var n=0,m=0,g=p-e,x=1<e)m+=x-(1<>>=g;m>0;){var b=s[n].s;d[b]=0&&m;--n){var v=s[n].s;d[v]==e&&(--d[v],++m)}p=e}return[new at(d),p]},rc=function(a,e,t){return a.s==-1?Math.max(rc(a.l,e,t+1),rc(a.r,e,t+1)):e[a.s]=t},hu=function(a){for(var e=a.length;e&&!a[--e];);for(var t=new Qt(++e),n=0,i=a[0],s=1,r=function(c){t[n++]=c},o=1;o<=e;++o)if(a[o]==i&&o!=e)++s;else{if(!i&&s>2){for(;s>138;s-=138)r(32754);s>2&&(r(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(r(i),--s;s>6;s-=6)r(8304);s>2&&(r(s-3<<5|8208),s=0)}for(;s--;)r(i);s=1,i=a[o]}return[t.subarray(0,n),e]},fr=function(a,e){for(var t=0,n=0;n>>8,a[i+2]=a[i]^255,a[i+3]=a[i+1]^255;for(var s=0;s4&&!N[Po[W-1]];--W);var K=l+5<<3,z=fr(i,Ai)+fr(s,Or)+r,q=fr(i,f)+fr(s,m)+r+14+3*W+fr(R,N)+(2*R[16]+3*R[17]+7*R[18]);if(K<=z&&K<=q)return vo(e,u,a.subarray(c,c+l));var O,Y,j,H;if(Yn(e,u,1+(q15&&(Yn(e,u,ne[_]>>>5&127),u+=ne[_]>>>12)}}else O=fm,Y=Ai,j=pm,H=Or;for(var _=0;_255){var re=n[_]>>>18&31;hr(e,u,O[re+257]),u+=Y[re+257],re>7&&(Yn(e,u,n[_]>>>23&31),u+=Hr[re]);var se=n[_]&31;hr(e,u,j[se]),u+=H[se],se>3&&(hr(e,u,n[_]>>>5&8191),u+=Wr[se])}else hr(e,u,O[n[_]]),u+=Y[n[_]];return hr(e,u,O[256]),u+Y[256]},gm=new Ti([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),yi=new at(0),ym=function(a,e,t,n,i,s){var r=a.length,o=new at(n+r+5*(1+Math.ceil(r/7e3))+i),c=o.subarray(n,o.length-i),l=0;if(!e||r<8)for(var u=0;u<=r;u+=65535){var h=u+65535;h>>13,p=f&8191,m=(1<7e3||N>24576)&&O>423){l=fu(a,c,0,S,A,R,L,N,W,u-W,l),N=_=L=0,W=u;for(var Y=0;Y<286;++Y)A[Y]=0;for(var Y=0;Y<30;++Y)R[Y]=0}var j=2,H=0,X=p,te=z-q&32767;if(O>2&&K==v(u-te))for(var J=Math.min(d,O)-1,ne=Math.min(32767,u),re=Math.min(258,O);te<=ne&&--X&&z!=q;){if(a[u+j]==a[u+j-te]){for(var se=0;sej){if(j=se,H=te,se>J)break;for(var V=Math.min(te,se-2),me=0,Y=0;Yme&&(me=ye,q=_e)}}}z=q,q=g[z],te+=z-q+32768&32767}if(H){S[N++]=268435456|sc[j]<<18|uu[H];var He=sc[j]&31,le=uu[H]&31;L+=Hr[He]+Wr[le],++A[257+He],++R[le],B=u+j,++_}else S[N++]=a[u],++A[a[u]]}}l=fu(a,c,s,S,A,R,L,N,W,u-W,l),!s&&l&7&&(l=vo(c,l+1,yi))}return Nn(o,0,n+qo(l)+i)},xm=function(){for(var a=new Ti(256),e=0;e<256;++e){for(var t=e,n=9;--n;)t=(t&1&&3988292384)^t>>>1;a[e]=t}return a}(),qr=function(){var a=-1;return{p:function(e){for(var t=a,n=0;n>>8;a=t},d:function(){return~a}}},nh=function(){var a=1,e=0;return{p:function(t){for(var n=a,i=e,s=t.length,r=0;r!=s;){for(var o=Math.min(r+2655,s);r>16),i=(i&65535)+15*(i>>16)}a=n,e=i},d:function(){return a%=65521,e%=65521,(a&255)<<24|a>>>8<<16|(e&255)<<8|e>>>8}}},Hs=function(a,e,t,n,i){return ym(a,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(a.length)))*1.5):12+e.mem,t,n,!i)},jo=function(a,e){var t={};for(var n in a)t[n]=a[n];for(var n in e)t[n]=e[n];return t},qf=function(a,e,t){for(var n=a(),i=a.toString(),s=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/ /g,"").split(","),r=0;r>>0},_l=function(a,e){return Ut(a,e)+Ut(a,e+4)*4294967296},vt=function(a,e,t){for(;t;++e)a[e]=t,t>>>=8},sh=function(a,e){var t=e.filename;if(a[0]=31,a[1]=139,a[2]=8,a[8]=e.level<2?4:e.level==9?2:0,a[9]=3,e.mtime!=0&&vt(a,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),t){a[3]=8;for(var n=0;n<=t.length;++n)a[n+10]=t.charCodeAt(n)}},rh=function(a){if(a[0]!=31||a[1]!=139||a[2]!=8)throw"invalid gzip data";var e=a[3],t=10;e&4&&(t+=a[10]|(a[11]<<8)+2);for(var n=(e>>3&1)+(e>>4&1);n>0;n-=!a[t++]);return t+(e&2)},Sm=function(a){var e=a.length;return(a[e-4]|a[e-3]<<8|a[e-2]<<16|a[e-1]<<24)>>>0},oh=function(a){return 10+(a.filename&&a.filename.length+1||0)},ah=function(a,e){var t=e.level,n=t==0?0:t<6?1:t==9?3:2;a[0]=120,a[1]=n<<6|(n?32-2*n:1)},Tm=function(a){if((a[0]&15)!=8||a[0]>>>4>7||(a[0]<<8|a[1])%31)throw"invalid zlib data";if(a[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function ch(a,e){return!e&&typeof a=="function"&&(e=a,a={}),this.ondata=e,a}var ii=function(){function a(e,t){!t&&typeof e=="function"&&(t=e,e={}),this.ondata=t,this.o=e||{}}return a.prototype.p=function(e,t){this.ondata(Hs(e,this.o,0,0,!t),t)},a.prototype.push=function(e,t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=t,this.p(e,t||!1)},a}(),Am=function(){function a(e,t){Zr([jr,function(){return[On,ii]}],this,ch.call(this,e,t),function(n){var i=new ii(n.data);onmessage=On(i)},6)}return a}();function Em(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Yr(a,e,[jr],function(n){return ns(Yo(n.data[0],n.data[1]))},0,t)}function Yo(a,e){return Hs(a,e||{},0,0)}var xn=function(){function a(e){this.s={},this.p=new at(0),this.ondata=e}return a.prototype.e=function(e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var t=this.p.length,n=new at(t+e.length);n.set(this.p),n.set(e,t),this.p=n},a.prototype.c=function(e){this.d=this.s.i=e||!1;var t=this.s.b,n=Xo(this.p,this.o,this.s);this.ondata(Nn(n,t,this.s.b),this.d),this.o=Nn(n,this.s.b-32768),this.s.b=this.o.length,this.p=Nn(this.p,this.s.p/8|0),this.s.p&=7},a.prototype.push=function(e,t){this.e(e),this.c(t)},a}(),lh=function(){function a(e){this.ondata=e,Zr([Xr,function(){return[On,xn]}],this,0,function(){var t=new xn;onmessage=On(t)},7)}return a}();function uh(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Yr(a,e,[Xr],function(n){return ns(Kr(n.data[0],ih(n.data[1])))},1,t)}function Kr(a,e){return Xo(a,e)}var oc=function(){function a(e,t){this.c=qr(),this.l=0,this.v=1,ii.call(this,e,t)}return a.prototype.push=function(e,t){ii.prototype.push.call(this,e,t)},a.prototype.p=function(e,t){this.c.p(e),this.l+=e.length;var n=Hs(e,this.o,this.v&&oh(this.o),t&&8,!t);this.v&&(sh(n,this.o),this.v=0),t&&(vt(n,n.length-8,this.c.d()),vt(n,n.length-4,this.l)),this.ondata(n,t)},a}(),Xf=function(){function a(e,t){Zr([jr,_m,function(){return[On,ii,oc]}],this,ch.call(this,e,t),function(n){var i=new oc(n.data);onmessage=On(i)},8)}return a}();function jf(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Yr(a,e,[jr,_m,function(){return[ac]}],function(n){return ns(ac(n.data[0],n.data[1]))},2,t)}function ac(a,e){e||(e={});var t=qr(),n=a.length;t.p(a);var i=Hs(a,e,oh(e),8),s=i.length;return sh(i,e),vt(i,s-8,t.d()),vt(i,s-4,n),i}var cc=function(){function a(e){this.v=1,xn.call(this,e)}return a.prototype.push=function(e,t){if(xn.prototype.e.call(this,e),this.v){var n=this.p.length>3?rh(this.p):4;if(n>=this.p.length&&!t)return;this.p=this.p.subarray(n),this.v=0}if(t){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}xn.prototype.c.call(this,t)},a}(),Cm=function(){function a(e){this.ondata=e,Zr([Xr,bm,function(){return[On,xn,cc]}],this,0,function(){var t=new cc;onmessage=On(t)},9)}return a}();function Lm(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Yr(a,e,[Xr,bm,function(){return[lc]}],function(n){return ns(lc(n.data[0]))},3,t)}function lc(a,e){return Xo(a.subarray(rh(a),-8),e||new at(Sm(a)))}var du=function(){function a(e,t){this.c=nh(),this.v=1,ii.call(this,e,t)}return a.prototype.push=function(e,t){ii.prototype.push.call(this,e,t)},a.prototype.p=function(e,t){this.c.p(e);var n=Hs(e,this.o,this.v&&2,t&&4,!t);this.v&&(ah(n,this.o),this.v=0),t&&vt(n,n.length-4,this.c.d()),this.ondata(n,t)},a}(),zw=function(){function a(e,t){Zr([jr,wm,function(){return[On,ii,du]}],this,ch.call(this,e,t),function(n){var i=new du(n.data);onmessage=On(i)},10)}return a}();function Uw(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Yr(a,e,[jr,wm,function(){return[pu]}],function(n){return ns(pu(n.data[0],n.data[1]))},4,t)}function pu(a,e){e||(e={});var t=nh();t.p(a);var n=Hs(a,e,2,4);return ah(n,e),vt(n,n.length-4,t.d()),n}var uc=function(){function a(e){this.v=1,xn.call(this,e)}return a.prototype.push=function(e,t){if(xn.prototype.e.call(this,e),this.v){if(this.p.length<2&&!t)return;this.p=this.p.subarray(2),this.v=0}if(t){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}xn.prototype.c.call(this,t)},a}(),Rm=function(){function a(e){this.ondata=e,Zr([Xr,Mm,function(){return[On,xn,uc]}],this,0,function(){var t=new uc;onmessage=On(t)},11)}return a}();function Im(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Yr(a,e,[Xr,Mm,function(){return[Fo]}],function(n){return ns(Fo(n.data[0],ih(n.data[1])))},5,t)}function Fo(a,e){return Xo((Tm(a),a.subarray(2,-4)),e)}var Pm=function(){function a(e){this.G=cc,this.I=xn,this.Z=uc,this.ondata=e}return a.prototype.push=function(e,t){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var n=new at(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length)}else this.p=e;if(this.p.length>2){var i=this,s=function(){i.ondata.apply(i,arguments)};this.s=this.p[0]==31&&this.p[1]==139&&this.p[2]==8?new this.G(s):(this.p[0]&15)!=8||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(s):new this.Z(s),this.s.push(this.p,t),this.p=null}}},a}(),Gw=function(){function a(e){this.G=Cm,this.I=lh,this.Z=Rm,this.ondata=e}return a.prototype.push=function(e,t){Pm.prototype.push.call(this,e,t)},a}();function Vw(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return a[0]==31&&a[1]==139&&a[2]==8?Lm(a,e,t):(a[0]&15)!=8||a[0]>>4>7||(a[0]<<8|a[1])%31?uh(a,e,t):Im(a,e,t)}function Hw(a,e){return a[0]==31&&a[1]==139&&a[2]==8?lc(a,e):(a[0]&15)!=8||a[0]>>4>7||(a[0]<<8|a[1])%31?Kr(a,e):Fo(a,e)}var hh=function(a,e,t,n){for(var i in a){var s=a[i],r=e+i;s instanceof at?t[r]=[s,n]:Array.isArray(s)?t[r]=[s[0],jo(n,s[1])]:hh(s,r+"/",t,n)}},Yf=typeof TextEncoder!="undefined"&&new TextEncoder,mu=typeof TextDecoder!="undefined"&&new TextDecoder,Dm=0;try{mu.decode(yi,{stream:!0}),Dm=1}catch{}var Fm=function(a){for(var e="",t=0;;){var n=a[t++],i=(n>127)+(n>223)+(n>239);if(t+i>a.length)return[e,Nn(a,t-1)];i?i==3?(n=((n&15)<<18|(a[t++]&63)<<12|(a[t++]&63)<<6|a[t++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):i&1?e+=String.fromCharCode((n&31)<<6|a[t++]&63):e+=String.fromCharCode((n&15)<<12|(a[t++]&63)<<6|a[t++]&63):e+=String.fromCharCode(n)}},Ww=function(){function a(e){this.ondata=e,Dm?this.t=new TextDecoder:this.p=yi}return a.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(t=!!t,this.t){if(this.ondata(this.t.decode(e,{stream:!0}),t),t){if(this.t.decode().length)throw"invalid utf-8 data";this.t=null}return}if(!this.p)throw"stream finished";var n=new at(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length);var i=Fm(n),s=i[0],r=i[1];if(t){if(r.length)throw"invalid utf-8 data";this.p=null}else this.p=r;this.ondata(s,t)},a}(),qw=function(){function a(e){this.ondata=e}return a.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(this.d)throw"stream finished";this.ondata($i(e),this.d=t||!1)},a}();function $i(a,e){if(e){for(var t=new at(a.length),n=0;n>1)),r=0,o=function(u){s[r++]=u},n=0;ns.length){var c=new at(r+8+(i-n<<1));c.set(s),s=c}var l=a.charCodeAt(n);l<128||e?o(l):l<2048?(o(192|l>>6),o(128|l&63)):l>55295&&l<57344?(l=65536+(l&1023<<10)|a.charCodeAt(++n)&1023,o(240|l>>18),o(128|l>>12&63),o(128|l>>6&63),o(128|l&63)):(o(224|l>>12),o(128|l>>6&63),o(128|l&63))}return Nn(s,0,r)}function fh(a,e){if(e){for(var t="",n=0;n65535)throw"extra field too long";e+=n+4}return e},Br=function(a,e,t,n,i,s,r,o){var c=n.length,l=t.extra,u=o&&o.length,h=qi(l);vt(a,e,r!=null?33639248:67324752),e+=4,r!=null&&(a[e++]=20,a[e++]=t.os),a[e]=20,e+=2,a[e++]=t.flag<<1|(s==null&&8),a[e++]=i&&8,a[e++]=t.compression&255,a[e++]=t.compression>>8;var f=new Date(t.mtime==null?Date.now():t.mtime),d=f.getFullYear()-1980;if(d<0||d>119)throw"date not in range 1980-2099";if(vt(a,e,d<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>>1),e+=4,s!=null&&(vt(a,e,t.crc),vt(a,e+4,s),vt(a,e+8,t.size)),vt(a,e+12,c),vt(a,e+14,h),e+=16,r!=null&&(vt(a,e,u),vt(a,e+6,t.attrs),vt(a,e+10,r),e+=14),a.set(n,e),e+=c,h)for(var p in l){var m=l[p],g=m.length;vt(a,e,+p),vt(a,e+2,g),a.set(m,e+4),e+=4+g}return u&&(a.set(o,e),e+=u),e},dh=function(a,e,t,n,i){vt(a,e,101010256),vt(a,e+8,t),vt(a,e+10,t),vt(a,e+12,n),vt(a,e+16,i)},No=function(){function a(e){this.filename=e,this.c=qr(),this.size=0,this.compression=0}return a.prototype.process=function(e,t){this.ondata(null,e,t)},a.prototype.push=function(e,t){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},a}(),Xw=function(){function a(e,t){var n=this;t||(t={}),No.call(this,e),this.d=new ii(t,function(i,s){n.ondata(null,i,s)}),this.compression=8,this.flag=Nm(t.level)}return a.prototype.process=function(e,t){try{this.d.push(e,t)}catch(n){this.ondata(n,null,t)}},a.prototype.push=function(e,t){No.prototype.push.call(this,e,t)},a}(),jw=function(){function a(e,t){var n=this;t||(t={}),No.call(this,e),this.d=new Am(t,function(i,s,r){n.ondata(i,s,r)}),this.compression=8,this.flag=Nm(t.level),this.terminate=this.d.terminate}return a.prototype.process=function(e,t){this.d.push(e,t)},a.prototype.push=function(e,t){No.prototype.push.call(this,e,t)},a}(),Yw=function(){function a(e){this.ondata=e,this.u=[],this.d=1}return a.prototype.add=function(e){var t=this;if(this.d&2)throw"stream finished";var n=$i(e.filename),i=n.length,s=e.comment,r=s&&$i(s),o=i!=e.filename.length||r&&s.length!=r.length,c=i+qi(e.extra)+30;if(i>65535)throw"filename too long";var l=new at(c);Br(l,0,e,n,o);var u=[l],h=function(){for(var g=0,x=u;g65535&&K("filename too long",null),!W)K(null,y);else if(S<16e4)try{K(null,Yo(y,b))}catch(z){K(z,null)}else u.push(Em(y,b,K))},p=0;p65535)throw"filename too long";var x=u?Yo(c,l):c,y=x.length,b=qr();b.p(c),n.push(jo(l,{size:c.length,crc:b.d(),c:x,f:h,m:p,u:f!=r.length||p&&d.length!=m,o:i,compression:u})),i+=30+f+g+y,s+=76+2*(f+g)+(m||0)+y}for(var v=new at(s+22),S=i,A=s-i,R=0;R0){var i=Math.min(this.c,e.length),s=e.subarray(0,i);if(this.c-=i,this.d?this.d.push(s,!this.c):this.k[0].push(s),e=e.subarray(i),e.length)return this.push(e,t)}else{var r=0,o=0,c=void 0,l=void 0;this.p.length?e.length?(l=new at(this.p.length+e.length),l.set(this.p),l.set(e,this.p.length)):l=this.p:l=e;for(var u=l.length,h=this.c,f=h&&this.d,d=function(){var x,y=Ut(l,o);if(y==67324752){r=1,c=o,p.d=null,p.c=0;var b=an(l,o+6),v=an(l,o+8),S=b&2048,A=b&8,R=an(l,o+26),_=an(l,o+28);if(u>o+30+R+_){var L=[];p.k.unshift(L),r=2;var N=Ut(l,o+18),B=Ut(l,o+22),W=fh(l.subarray(o+30,o+=30+R),!S);N==4294967295?(x=A?[-2]:Bm(l,o),N=x[0],B=x[1]):A&&(N=-1),o+=_,p.c=N;var K,z={name:W,compression:v,start:function(){if(!z.ondata)throw"no callback";if(!N)z.ondata(null,yi,!0);else{var q=n.o[v];if(!q)throw"unknown compression type "+v;K=N<0?new q(W):new q(W,N,B),K.ondata=function(H,X,te){z.ondata(H,X,te)};for(var O=0,Y=L;O=0&&(z.size=N,z.originalSize=B),p.onfile(z)}return"break"}else if(h){if(y==134695760)return c=o+=12+(h==-2&&8),r=3,p.c=0,"break";if(y==33639248)return c=o-=4,r=3,p.c=0,"break"}},p=this;o65558){e("invalid zip file",null);return}var r=an(a,s+8);r||e(null,{});var o=r,c=Ut(a,s+16),l=c==4294967295;if(l){if(s=Ut(a,s-12),Ut(a,s)!=101075792){e("invalid zip file",null);return}o=r=Ut(a,s+32),c=Ut(a,s+48)}for(var u=function(f){var d=Om(a,c,l),p=d[0],m=d[1],g=d[2],x=d[3],y=d[4],b=d[5],v=km(a,b);c=y;var S=function(R,_){R?(n(),e(R,null)):(i[x]=_,--r||e(null,i))};if(!p)S(null,Nn(a,v,v+m));else if(p==8){var A=a.subarray(v,v+m);if(m<32e4)try{S(null,Kr(A,new at(g)))}catch(R){S(R,null)}else t.push(uh(A,{size:g},S))}else S("unknown compression type "+p,null)},h=0;h65558)throw"invalid zip file";var n=an(a,t+8);if(!n)return{};var i=Ut(a,t+16),s=i==4294967295;if(s){if(t=Ut(a,t-12),Ut(a,t)!=101075792)throw"invalid zip file";n=Ut(a,t+32),i=Ut(a,t+48)}for(var r=0;r=t[n])return n-1;if(e<=t[a])return a;let i=a,s=n,r=Math.floor((i+s)/2);for(;e=t[r+1];)e=m&&(p[d][0]=p[f][0]/o[y+1][x],g=p[d][0]*o[x][y]);const b=x>=-1?1:-x,v=h-1<=y?m-1:t-h;for(let A=b;A<=v;++A)p[d][A]=(p[f][A]-p[f][A-1])/o[y+1][x+A],g+=p[d][A]*o[x+A][y];h<=y&&(p[d][m]=-p[f][m-1]/o[y+1][h],g+=p[d][m]*o[h][y]),r[m][h]=g;const S=f;f=d,d=S}}let u=t;for(let h=1;h<=n;++h){for(let f=0;f<=t;++f)r[h][f]*=u;u*=t-h}return r}function oM(a,e,t,n,i){const s=i0,c=typeof s.Content=="string"&&s.Content!=="";if(o||c){const l=this.parseImage(n[i]);t[s.RelativeFilename||s.Filename]=l}}}}for(const n in e){const i=e[n];t[i]!==void 0?e[n]=t[i]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase();let s;switch(i){case"bmp":s="image/bmp";break;case"jpg":case"jpeg":s="image/jpeg";break;case"png":s="image/png";break;case"tif":s="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),s="image/tga";break;default:console.warn('FBXLoader: Image type "'+i+'" is not supported.');return}if(typeof t=="string")return"data:"+s+";base64,"+t;{const r=new Uint8Array(t);return window.URL.createObjectURL(new Blob([r],{type:s}))}}parseTextures(e){const t=new Map;if("Texture"in st.Objects){const n=st.Objects.Texture;for(const i in n){const s=this.parseTexture(n[i],e);t.set(parseInt(i),s)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const i=e.WrapModeU,s=e.WrapModeV,r=i!==void 0?i.value:0,o=s!==void 0?s.value:0;if(n.wrapS=r===0?cn:jt,n.wrapT=o===0?cn:jt,"Scaling"in e){const c=e.Scaling.value;n.repeat.x=c[0],n.repeat.y=c[1]}if("Translation"in e){const c=e.Translation.value;n.offset.x=c[0],n.offset.y=c[1]}return n}loadTexture(e,t){let n;const i=this.textureLoader.path,s=Ot.get(e.id).children;s!==void 0&&s.length>0&&t[s[0].ID]!==void 0&&(n=t[s[0].ID],(n.indexOf("blob:")===0||n.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let r;const o=e.FileName.slice(-3).toLowerCase();if(o==="tga"){const c=this.manager.getHandler(".tga");c===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),r=new At):(c.setPath(this.textureLoader.path),r=c.load(n))}else o==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),r=new At):r=this.textureLoader.load(n);return this.textureLoader.setPath(i),r}parseMaterials(e){const t=new Map;if("Material"in st.Objects){const n=st.Objects.Material;for(const i in n){const s=this.parseMaterial(n[i],e);s!==null&&t.set(parseInt(i),s)}}return t}parseMaterial(e,t){const n=e.id,i=e.attrName;let s=e.ShadingModel;if(typeof s=="object"&&(s=s.value),!Ot.has(n))return null;const r=this.parseParameters(e,t,n);let o;switch(s.toLowerCase()){case"phong":o=new Qn;break;case"lambert":o=new Rc;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),o=new Qn;break}return o.setValues(r),o.name=i,o}parseParameters(e,t,n){const i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=new ve().fromArray(e.Diffuse.value):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(i.color=new ve().fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=new ve().fromArray(e.Emissive.value):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(i.emissive=new ve().fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(i.opacity=parseFloat(e.Opacity.value)),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=new ve().fromArray(e.Specular.value):e.SpecularColor&&e.SpecularColor.type==="Color"&&(i.specular=new ve().fromArray(e.SpecularColor.value));const s=this;return Ot.get(n).children.forEach(function(r){const o=r.relationship;switch(o){case"Bump":i.bumpMap=s.getTexture(t,r.ID);break;case"Maya|TEX_ao_map":i.aoMap=s.getTexture(t,r.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=s.getTexture(t,r.ID),i.map!==void 0&&(i.map.encoding=tt);break;case"DisplacementColor":i.displacementMap=s.getTexture(t,r.ID);break;case"EmissiveColor":i.emissiveMap=s.getTexture(t,r.ID),i.emissiveMap!==void 0&&(i.emissiveMap.encoding=tt);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=s.getTexture(t,r.ID);break;case"ReflectionColor":i.envMap=s.getTexture(t,r.ID),i.envMap!==void 0&&(i.envMap.mapping=vr,i.envMap.encoding=tt);break;case"SpecularColor":i.specularMap=s.getTexture(t,r.ID),i.specularMap!==void 0&&(i.specularMap.encoding=tt);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=s.getTexture(t,r.ID),i.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",o);break}}),i}getTexture(e,t){return"LayeredTexture"in st.Objects&&t in st.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=Ot.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in st.Objects){const n=st.Objects.Deformer;for(const i in n){const s=n[i],r=Ot.get(parseInt(i));if(s.attrType==="Skin"){const o=this.parseSkeleton(r,n);o.ID=i,r.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),o.geometryID=r.parents[0].ID,e[i]=o}else if(s.attrType==="BlendShape"){const o={id:i};o.rawTargets=this.parseMorphTargets(r,n),o.id=i,r.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=o}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(i){const s=t[i.ID];if(s.attrType!=="Cluster")return;const r={ID:i.ID,indices:[],weights:[],transformLink:new De().fromArray(s.TransformLink.a)};"Indexes"in s&&(r.indices=s.Indexes.a,r.weights=s.Weights.a),n.push(r)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let i=0;i1?r=o:o.length>0?r=o[0]:(r=new Qn({color:13421772}),o.push(r)),"color"in s.attributes&&o.forEach(function(c){c.vertexColors=!0}),s.FBX_Deformer?(i=new Vo(s,r),i.normalizeSkinWeights()):i=new Tt(s,r),i}createCurve(e,t){const n=e.children.reduce(function(s,r){return t.has(r.ID)&&(s=t.get(r.ID)),s},null),i=new Vt({color:3342591,linewidth:1});return new Wn(n,i)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=Hm(t.RotationOrder.value):n.eulerOrder="ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&Ot.get(e.ID).children.forEach(function(i){if(i.relationship==="LookAtProperty"){const s=st.Objects.Model[i.ID];if("Lcl_Translation"in s){const r=s.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(r),gn.add(e.target)):e.lookAt(new D().fromArray(r))}}})}bindSkeleton(e,t,n){const i=this.parsePoseNodes();for(const s in e){const r=e[s];Ot.get(parseInt(r.ID)).parents.forEach(function(c){if(t.has(c.ID)){const l=c.ID;Ot.get(l).parents.forEach(function(h){n.has(h.ID)&&n.get(h.ID).bind(new zs(r.bones),i[h.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in st.Objects){const t=st.Objects.Pose;for(const n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){const i=t[n].PoseNode;Array.isArray(i)?i.forEach(function(s){e[s.Node]=new De().fromArray(s.Matrix.a)}):e[i.Node]=new De().fromArray(i.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in st&&"AmbientColor"in st.GlobalSettings){const e=st.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(t!==0||n!==0||i!==0){const s=new ve(t,n,i);gn.add(new Wo(s,1))}}}}class fM{parse(e){const t=new Map;if("Geometry"in st.Objects){const n=st.Objects.Geometry;for(const i in n){const s=Ot.get(parseInt(i)),r=this.parseGeometry(s,n[i],e);t.set(parseInt(i),r)}}return t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const i=n.skeletons,s=[],r=e.parents.map(function(h){return st.Objects.Model[h.ID]});if(r.length===0)return;const o=e.children.reduce(function(h,f){return i[f.ID]!==void 0&&(h=i[f.ID]),h},null);e.children.forEach(function(h){n.morphTargets[h.ID]!==void 0&&s.push(n.morphTargets[h.ID])});const c=r[0],l={};"RotationOrder"in c&&(l.eulerOrder=Hm(c.RotationOrder.value)),"InheritType"in c&&(l.inheritType=parseInt(c.InheritType.value)),"GeometricTranslation"in c&&(l.translation=c.GeometricTranslation.value),"GeometricRotation"in c&&(l.rotation=c.GeometricRotation.value),"GeometricScaling"in c&&(l.scale=c.GeometricScaling.value);const u=Vm(l);return this.genGeometry(t,o,s,u)}genGeometry(e,t,n,i){const s=new Xe;e.attrName&&(s.name=e.attrName);const r=this.parseGeoNode(e,t),o=this.genBuffers(r),c=new we(o.vertex,3);if(c.applyMatrix4(i),s.setAttribute("position",c),o.colors.length>0&&s.setAttribute("color",new we(o.colors,3)),t&&(s.setAttribute("skinIndex",new vc(o.weightsIndices,4)),s.setAttribute("skinWeight",new we(o.vertexWeights,4)),s.FBX_Deformer=t),o.normal.length>0){const l=new ln().getNormalMatrix(i),u=new we(o.normal,3);u.applyNormalMatrix(l),s.setAttribute("normal",u)}if(o.uvs.forEach(function(l,u){let h="uv"+(u+1).toString();u===0&&(h="uv"),s.setAttribute(h,new we(o.uvs[u],2))}),r.material&&r.material.mappingType!=="AllSame"){let l=o.materialIndex[0],u=0;if(o.materialIndex.forEach(function(h,f){h!==l&&(s.addGroup(u,f-u,l),l=h,u=f)}),s.groups.length>0){const h=s.groups[s.groups.length-1],f=h.start+h.count;f!==o.materialIndex.length&&s.addGroup(f,o.materialIndex.length-f,l)}s.groups.length===0&&s.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(s,e,n,i),s}parseGeoNode(e,t){const n={};if(n.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],n.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let i=0;for(;e.LayerElementUV[i];)e.LayerElementUV[i].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[i])),i++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(i,s){i.indices.forEach(function(r,o){n.weightTable[r]===void 0&&(n.weightTable[r]=[]),n.weightTable[r].push({id:s,weight:i.weights[o]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,i=0,s=!1,r=[],o=[],c=[],l=[],u=[],h=[];const f=this;return e.vertexIndices.forEach(function(d,p){let m,g=!1;d<0&&(d=d^-1,g=!0);let x=[],y=[];if(r.push(d*3,d*3+1,d*3+2),e.color){const b=Wa(p,n,d,e.color);c.push(b[0],b[1],b[2])}if(e.skeleton){if(e.weightTable[d]!==void 0&&e.weightTable[d].forEach(function(b){y.push(b.weight),x.push(b.id)}),y.length>4){s||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),s=!0);const b=[0,0,0,0],v=[0,0,0,0];y.forEach(function(S,A){let R=S,_=x[A];v.forEach(function(L,N,B){if(R>L){B[N]=R,R=L;const W=b[N];b[N]=_,_=W}})}),x=b,y=v}for(;y.length<4;)y.push(0),x.push(0);for(let b=0;b<4;++b)u.push(y[b]),h.push(x[b])}if(e.normal){const b=Wa(p,n,d,e.normal);o.push(b[0],b[1],b[2])}e.material&&e.material.mappingType!=="AllSame"&&(m=Wa(p,n,d,e.material)[0]),e.uv&&e.uv.forEach(function(b,v){const S=Wa(p,n,d,b);l[v]===void 0&&(l[v]=[]),l[v].push(S[0]),l[v].push(S[1])}),i++,g&&(f.genFace(t,e,r,m,o,c,l,u,h,i),n++,i=0,r=[],o=[],c=[],l=[],u=[],h=[])}),t}genFace(e,t,n,i,s,r,o,c,l,u){for(let h=2;h1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const r=e.get(s[0].ID);n[i]={name:t[i].attrName,layer:r}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach(function(i){t=t.concat(n.generateTracks(i))}),new Si(e.name,-1,t)}generateTracks(e){const t=[];let n=new D,i=new Ft,s=new D;if(e.transform&&e.transform.decompose(n,i,s),n=n.toArray(),i=new Pn().setFromQuaternion(i,e.eulerOrder).toArray(),s=s.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const r=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");r!==void 0&&t.push(r)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const r=this.generateRotationTrack(e.modelName,e.R.curves,i,e.preRotation,e.postRotation,e.eulerOrder);r!==void 0&&t.push(r)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const r=this.generateVectorTrack(e.modelName,e.S.curves,s,"scale");r!==void 0&&t.push(r)}if(e.DeformPercent!==void 0){const r=this.generateMorphTrack(e);r!==void 0&&t.push(r)}return t}generateVectorTrack(e,t,n,i){const s=this.getTimesForAllAxes(t),r=this.getKeyframeTrackValues(s,t,n);return new Mi(e+"."+i,s,r)}generateRotationTrack(e,t,n,i,s,r){t.x!==void 0&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(en.degToRad)),t.y!==void 0&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(en.degToRad)),t.z!==void 0&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(en.degToRad));const o=this.getTimesForAllAxes(t),c=this.getKeyframeTrackValues(o,t,n);i!==void 0&&(i=i.map(en.degToRad),i.push(r),i=new Pn().fromArray(i),i=new Ft().setFromEuler(i)),s!==void 0&&(s=s.map(en.degToRad),s.push(r),s=new Pn().fromArray(s),s=new Ft().setFromEuler(s).invert());const l=new Ft,u=new Pn,h=[];for(let f=0;f1){let n=1,i=t[0];for(let s=1;s=180){const r=s/180,o=i/r;let c=n+o;const l=e.times[t-1],h=(e.times[t]-l)/r;let f=l+h;const d=[],p=[];for(;f1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}}parseNodeProperty(e,t,n){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),s=t[2].replace(/^"/,"").replace(/"$/,"").trim();i==="Content"&&s===","&&(s=n.replace(/"/g,"").replace(/,$/,"").trim());const r=this.getCurrentNode();if(r.name==="Properties70"){this.parseNodeSpecialProperty(e,i,s);return}if(i==="C"){const c=s.split(",").slice(1),l=parseInt(c[0]),u=parseInt(c[1]);let h=s.split(",").slice(3);h=h.map(function(f){return f.trim().replace(/^"/,"")}),i="connections",s=[l,u],_M(s,h),r[i]===void 0&&(r[i]=[])}i==="Node"&&(r.id=s),i in r&&Array.isArray(r[i])?r[i].push(s):i!=="a"?r[i]=s:r.a=s,this.setCurrentProp(r,i),i==="a"&&s.slice(-1)!==","&&(r.a=wl(s))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=wl(t.a))}parseNodeSpecialProperty(e,t,n){const i=n.split('",').map(function(u){return u.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=i[0],r=i[1],o=i[2],c=i[3];let l=i[4];switch(r){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=wl(l);break}this.getPrevNode()[s]={type:r,type2:o,flag:c,value:l},this.setCurrentProp(this.getPrevNode(),s)}}class mM{parse(e){const t=new Kf(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const i=new Gm;for(;!this.endOfContent(t);){const s=this.parseNode(t,n);s!==null&&i.add(s.name,s)}return i}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},i=t>=7500?e.getUint64():e.getUint32(),s=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const r=e.getUint8(),o=e.getString(r);if(i===0)return null;const c=[];for(let f=0;f0?c[0]:"",u=c.length>1?c[1]:"",h=c.length>2?c[2]:"";for(n.singleProperty=s===1&&e.getOffset()===i;i>e.getOffset();){const f=this.parseNode(e,t);f!==null&&this.parseSubNode(o,n,f)}return n.propertyList=c,typeof l=="number"&&(n.id=l),u!==""&&(n.attrName=u),h!==""&&(n.attrType=h),o!==""&&(n.name=o),n}parseSubNode(e,t,n){if(n.singleProperty===!0){const i=n.propertyList[0];Array.isArray(i)?(t[n.name]=n,n.a=i):t[n.name]=i}else if(e==="Connections"&&n.name==="C"){const i=[];n.propertyList.forEach(function(s,r){r!==0&&i.push(s)}),t.connections===void 0&&(t.connections=[]),t.connections.push(i)}else if(n.name==="Properties70")Object.keys(n).forEach(function(s){t[s]=n[s]});else if(e==="Properties70"&&n.name==="P"){let i=n.propertyList[0],s=n.propertyList[1];const r=n.propertyList[2],o=n.propertyList[3];let c;i.indexOf("Lcl ")===0&&(i=i.replace("Lcl ","Lcl_")),s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),s==="Color"||s==="ColorRGB"||s==="Vector"||s==="Vector3D"||s.indexOf("Lcl_")===0?c=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:c=n.propertyList[4],t[i]={type:s,type2:r,flag:o,value:c}}else t[n.name]===void 0?typeof n.id=="number"?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name==="PoseNode"?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const i=e.getUint32(),s=e.getUint32(),r=e.getUint32();if(s===0)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}typeof nM=="undefined"&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const o=Fo(new Uint8Array(e.getArrayBuffer(r))),c=new Kf(o.buffer);switch(t){case"b":case"c":return c.getBooleanArray(i);case"d":return c.getFloat64Array(i);case"f":return c.getFloat32Array(i);case"i":return c.getInt32Array(i);case"l":return c.getInt64Array(i)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class Kf{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let n=0;n=0&&(t=t.slice(0,n)),tn.decodeText(new Uint8Array(t))}}class Gm{add(e,t){this[e]=t}}function gM(a){const e="Kaydara FBX Binary \0";return a.byteLength>=e.length&&e===Wm(a,0,e.length)}function yM(a){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function n(i){const s=a[i-1];return a=a.slice(t+i),t++,s}for(let i=0;i256||O.colormap_size!==24||O.colormap_type!==1)&&console.error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case d:case p:case g:case x:O.colormap_type&&console.error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case h:console.error("THREE.TGALoader: No data.");default:console.error('THREE.TGALoader: Invalid type "%s".',O.image_type)}(O.width<=0||O.height<=0)&&console.error("THREE.TGALoader: Invalid image size."),O.pixel_size!==8&&O.pixel_size!==16&&O.pixel_size!==24&&O.pixel_size!==32&&console.error('THREE.TGALoader: Invalid pixel size "%s".',O.pixel_size)}function n(O,Y,j,H,X){let te,J;const ne=j.pixel_size>>3,re=j.width*j.height*ne;if(Y&&(J=X.subarray(H,H+=j.colormap_length*(j.colormap_size>>3))),O){te=new Uint8Array(re);let se,V,me,_e=0;const Ie=new Uint8Array(ne);for(;_e>7,O[(V+_e*me)*4+1]=(re&992)>>2,O[(V+_e*me)*4+2]=(re&31)<<3,O[(V+_e*me)*4+3]=re&32768?0:255;return O}function r(O,Y,j,H,X,te,J,ne){let re=0,se,V;const me=N.width;for(V=Y;V!==H;V+=j)for(se=X;se!==J;se+=te,re+=3)O[(se+me*V)*4+3]=255,O[(se+me*V)*4+2]=ne[re+0],O[(se+me*V)*4+1]=ne[re+1],O[(se+me*V)*4+0]=ne[re+2];return O}function o(O,Y,j,H,X,te,J,ne){let re=0,se,V;const me=N.width;for(V=Y;V!==H;V+=j)for(se=X;se!==J;se+=te,re+=4)O[(se+me*V)*4+2]=ne[re+0],O[(se+me*V)*4+1]=ne[re+1],O[(se+me*V)*4+0]=ne[re+2],O[(se+me*V)*4+3]=ne[re+3];return O}function c(O,Y,j,H,X,te,J,ne){let re,se=0,V,me;const _e=N.width;for(me=Y;me!==H;me+=j)for(V=X;V!==J;V+=te,se++)re=ne[se],O[(V+_e*me)*4+0]=re,O[(V+_e*me)*4+1]=re,O[(V+_e*me)*4+2]=re,O[(V+_e*me)*4+3]=255;return O}function l(O,Y,j,H,X,te,J,ne){let re=0,se,V;const me=N.width;for(V=Y;V!==H;V+=j)for(se=X;se!==J;se+=te,re+=2)O[(se+me*V)*4+0]=ne[re+0],O[(se+me*V)*4+1]=ne[re+0],O[(se+me*V)*4+2]=ne[re+0],O[(se+me*V)*4+3]=ne[re+1];return O}function u(O,Y,j,H,X){let te,J,ne,re,se,V;switch((N.flags&y)>>b){default:case A:te=0,ne=1,se=Y,J=0,re=1,V=j;break;case v:te=0,ne=1,se=Y,J=j-1,re=-1,V=-1;break;case R:te=Y-1,ne=-1,se=-1,J=0,re=1,V=j;break;case S:te=Y-1,ne=-1,se=-1,J=j-1,re=-1,V=-1;break}if(K)switch(N.pixel_size){case 8:c(O,J,re,V,te,ne,se,H);break;case 16:l(O,J,re,V,te,ne,se,H);break;default:console.error("THREE.TGALoader: Format not supported.");break}else switch(N.pixel_size){case 8:i(O,J,re,V,te,ne,se,H,X);break;case 16:s(O,J,re,V,te,ne,se,H);break;case 24:r(O,J,re,V,te,ne,se,H);break;case 32:o(O,J,re,V,te,ne,se,H);break;default:console.error("THREE.TGALoader: Format not supported.");break}return O}const h=0,f=1,d=2,p=3,m=9,g=10,x=11,y=48,b=4,v=0,S=1,A=2,R=3;e.length<19&&console.error("THREE.TGALoader: Not enough data to contain header.");let _=0;const L=new Uint8Array(e),N={id_length:L[_++],colormap_type:L[_++],image_type:L[_++],colormap_index:L[_++]|L[_++]<<8,colormap_length:L[_++]|L[_++]<<8,colormap_size:L[_++],origin:[L[_++]|L[_++]<<8,L[_++]|L[_++]<<8],width:L[_++]|L[_++]<<8,height:L[_++]|L[_++]<<8,pixel_size:L[_++],flags:L[_++]};t(N),N.id_length+_>e.length&&console.error("THREE.TGALoader: No data."),_+=N.id_length;let B=!1,W=!1,K=!1;switch(N.image_type){case m:B=!0,W=!0;break;case f:W=!0;break;case g:B=!0;break;case d:break;case x:B=!0,K=!0;break;case p:K=!0;break}const z=new Uint8Array(N.width*N.height*4),q=n(B,W,N,_,L);return u(z,N.width,N.height,q.pixel_data,q.palettes),{data:z,width:N.width,height:N.height,flipY:!0,generateMipmaps:!0,minFilter:si}}}class wM extends Ht{constructor(e){super(e)}load(e,t,n,i){const s=this,r=s.path===""?tn.extractUrlBase(e):s.path,o=new Kt(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(c){try{t(s.parse(c,r))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e,t){function n(T,M){const I=[],C=T.childNodes;for(let P=0,ie=C.length;P0&&M.push(new Mi(C+".position",P,ie)),he.length>0&&M.push(new ni(C+".quaternion",P,he)),Ne.length>0&&M.push(new Mi(C+".scale",P,Ne)),M}function B(T,M,I){let C,P=!0,ie,he;for(ie=0,he=T.length;ie=0;){const C=T[M];if(C.value[I]!==null)return C;M--}return null}function z(T,M,I){for(;M>>0)+2);switch(I=I.toLowerCase(),I){case"tga":M=Oc;break;default:M=gh}return M}function de(T){const M=U(T.url),I=M.profile.technique;let C;switch(I.type){case"phong":case"blinn":C=new Qn;break;case"lambert":C=new Rc;break;default:C=new un;break}C.name=T.name||"";function P(Ae,ke=null){const Ge=M.profile.samplers[Ae.id];let be=null;if(Ge!==void 0){const We=M.profile.surfaces[Ge.source];be=_e(We.init_from)}else console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),be=_e(Ae.id);if(be!==null){const We=Q(be);if(We!==void 0){const Be=We.load(be),je=Ae.extra;if(je!==void 0&&je.technique!==void 0&&l(je.technique)===!1){const Ve=je.technique;Be.wrapS=Ve.wrapU?cn:jt,Be.wrapT=Ve.wrapV?cn:jt,Be.offset.set(Ve.offsetU||0,Ve.offsetV||0),Be.repeat.set(Ve.repeatU||1,Ve.repeatV||1)}else Be.wrapS=cn,Be.wrapT=cn;return ke!==null&&(Be.encoding=ke),Be}else return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",be),null}else return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",Ae.id),null}const ie=I.parameters;for(const Ae in ie){const ke=ie[Ae];switch(Ae){case"diffuse":ke.color&&C.color.fromArray(ke.color),ke.texture&&(C.map=P(ke.texture,tt));break;case"specular":ke.color&&C.specular&&C.specular.fromArray(ke.color),ke.texture&&(C.specularMap=P(ke.texture));break;case"bump":ke.texture&&(C.normalMap=P(ke.texture));break;case"ambient":ke.texture&&(C.lightMap=P(ke.texture,tt));break;case"shininess":ke.float&&C.shininess&&(C.shininess=ke.float);break;case"emission":ke.color&&C.emissive&&C.emissive.fromArray(ke.color),ke.texture&&(C.emissiveMap=P(ke.texture,tt));break}}C.color.convertSRGBToLinear(),C.specular&&C.specular.convertSRGBToLinear(),C.emissive&&C.emissive.convertSRGBToLinear();let he=ie.transparent,Ne=ie.transparency;if(Ne===void 0&&he&&(Ne={float:1}),he===void 0&&Ne&&(he={opaque:"A_ONE",data:{color:[1,1,1,1]}}),he&&Ne)if(he.data.texture)C.transparent=!0;else{const Ae=he.data.color;switch(he.opaque){case"A_ONE":C.opacity=Ae[3]*Ne.float;break;case"RGB_ZERO":C.opacity=1-Ae[0]*Ne.float;break;case"A_ZERO":C.opacity=1-Ae[3]*Ne.float;break;case"RGB_ONE":C.opacity=Ae[0]*Ne.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',he.opaque)}C.opacity<1&&(C.transparent=!0)}if(I.extra!==void 0&&I.extra.technique!==void 0){const Ae=I.extra.technique;for(const ke in Ae){const Ge=Ae[ke];switch(ke){case"double_sided":C.side=Ge===1?_i:vi;break;case"bump":C.normalMap=P(Ge.texture),C.normalScale=new fe(1,1);break}}}return C}function Le(T){return m(Ze.materials[T],de)}function F(T){const M={name:T.getAttribute("name")};for(let I=0,C=T.childNodes.length;I0?he+Ae:he;M.inputs[ke]={id:ie,offset:Ne},M.stride=Math.max(M.stride,Ne+1),he==="TEXCOORD"&&(M.hasUV=!0);break;case"vcount":M.vcount=r(P.textContent);break;case"p":M.p=r(P.textContent);break}}return M}function Et(T){const M={};for(let I=0;I0&&M0&&be.setAttribute("position",new we(P.array,P.stride)),ie.array.length>0&&be.setAttribute("normal",new we(ie.array,ie.stride)),Ae.array.length>0&&be.setAttribute("color",new we(Ae.array,Ae.stride)),he.array.length>0&&be.setAttribute("uv",new we(he.array,he.stride)),Ne.array.length>0&&be.setAttribute("uv2",new we(Ne.array,Ne.stride)),ke.array.length>0&&be.setAttribute("skinIndex",new we(ke.array,ke.stride)),Ge.array.length>0&&be.setAttribute("skinWeight",new we(Ge.array,Ge.stride)),C.data=be,C.type=T[0].type,C.materialKeys=We,C}function Mt(T,M,I,C,P=!1){const ie=T.p,he=T.stride,Ne=T.vcount;function Ae(be){let We=ie[be+I]*Ge;const Be=We+Ge;for(;We4)for(let Ve=1,Lt=je-2;Ve<=Lt;Ve++){const _t=be+he*0,gt=be+he*Ve,yt=be+he*(Ve+1);Ae(_t),Ae(gt),Ae(yt)}be+=he*je}}else for(let be=0,We=ie.length;be=M.limits.max&&(M.static=!0),M.middlePosition=(M.limits.min+M.limits.max)/2,M}function $(T){const M={sid:T.getAttribute("sid"),name:T.getAttribute("name")||"",attachments:[],transforms:[]};for(let I=0;IBe.limits.max||be=2.0 are supported."));return}const l=new JM(c,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u=0&&o[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(r),l.setPlugins(o),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function SM(){let a={};return{get:function(e){return a[e]},add:function(e,t){a[e]=t},remove:function(e){delete a[e]},removeAll:function(){a={}}}}const rt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class TM{constructor(e){this.parser=e,this.name=rt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,r)}}class kM{constructor(e){this.parser=e,this.name=rt.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const r=s.extensions[t],o=i.images[r.source];let c=n.textureLoader;if(o.uri){const l=n.options.manager.getHandler(o.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return n.loadTextureImage(e,r.source,c);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class OM{constructor(e){this.name=rt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([s,r.ready]).then(function(o){const c=i.byteOffset||0,l=i.byteLength||0,u=i.count,h=i.byteStride,f=new ArrayBuffer(u*h),d=new Uint8Array(o[0],c,l);return r.decodeGltfBuffer(new Uint8Array(f),u,h,d,i.mode,i.filter),f})}else return null}}const qm="glTF",co=12,Qf={JSON:1313821514,BIN:5130562};class BM{constructor(e){this.name=rt.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,co);if(this.header={magic:tn.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==qm)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-co,i=new DataView(e,co);let s=0;for(;s>>1|(wt&21845)<<1;Bi=(Bi&52428)>>>2|(Bi&13107)<<2,Bi=(Bi&61680)>>>4|(Bi&3855)<<4,Do[wt]=((Bi&65280)>>>8|(Bi&255)<<8)>>>1}var Fn=function(a,e,t){for(var n=a.length,i=0,s=new Qt(e);i>>c]=l}else for(o=new Qt(n),i=0;i>>15-a[i]);return o},Ai=new ct(288);for(var wt=0;wt<144;++wt)Ai[wt]=8;for(var wt=144;wt<256;++wt)Ai[wt]=9;for(var wt=256;wt<280;++wt)Ai[wt]=7;for(var wt=280;wt<288;++wt)Ai[wt]=8;var Or=new ct(32);for(var wt=0;wt<32;++wt)Or[wt]=5;var fm=Fn(Ai,9,0),dm=Fn(Ai,9,1),pm=Fn(Or,5,0),mm=Fn(Or,5,1),Qa=function(a){for(var e=a[0],t=1;te&&(e=a[t]);return e},Ln=function(a,e,t){var n=e/8|0;return(a[n]|a[n+1]<<8)>>(e&7)&t},ec=function(a,e){var t=e/8|0;return(a[t]|a[t+1]<<8|a[t+2]<<16)>>(e&7)},qo=function(a){return(a/8|0)+(a&7&&1)},Nn=function(a,e,t){(e==null||e<0)&&(e=0),(t==null||t>a.length)&&(t=a.length);var n=new(a instanceof Qt?Qt:a instanceof Ti?Ti:ct)(t-e);return n.set(a.subarray(e,t)),n},Xo=function(a,e,t){var n=a.length;if(!n||t&&!t.l&&n<5)return e||new ct(0);var i=!e||t,s=!t||t.i;t||(t={}),e||(e=new ct(n*3));var r=function(H){var ye=e.length;if(H>ye){var we=new ct(Math.max(ye*2,H));we.set(e),e=we}},o=t.f||0,c=t.p||0,l=t.b||0,u=t.l,h=t.d,f=t.m,d=t.n,p=n*8;do{if(!u){t.f=o=Ln(a,c,1);var m=Ln(a,c+1,3);if(c+=3,m)if(m==1)u=dm,h=mm,f=9,d=5;else if(m==2){var b=Ln(a,c,31)+257,v=Ln(a,c+10,15)+4,M=b+Ln(a,c+5,31)+1;c+=14;for(var T=new ct(M),C=new ct(19),_=0;_>>4;if(g<16)T[_++]=g;else{var J=0,G=0;for(g==16?(G=3+Ln(a,c,3),c+=2,J=T[_-1]):g==17?(G=3+Ln(a,c,7),c+=3):g==18&&(G=11+Ln(a,c,127),c+=7);G--;)T[_++]=J}}var X=T.subarray(0,b),B=T.subarray(b);f=Qa(X),d=Qa(B),u=Fn(X,f,1),h=Fn(B,d,1)}else throw"invalid block type";else{var g=qo(c)+4,x=a[g-4]|a[g-3]<<8,y=g+x;if(y>n){if(s)throw"unexpected EOF";break}i&&r(l+x),e.set(a.subarray(g,y),l),t.b=l+=x,t.p=c=y*8;continue}if(c>p){if(s)throw"unexpected EOF";break}}i&&r(l+131072);for(var Z=(1<>>4;if(c+=J&15,c>p){if(s)throw"unexpected EOF";break}if(!J)throw"invalid length/literal";if(j<256)e[l++]=j;else if(j==256){W=c,u=null;break}else{var ne=j-254;if(j>264){var _=j-257,$=Hr[_];ne=Ln(a,c,(1<<$)-1)+nh[_],c+=$}var ie=h[ec(a,c)&Y],ce=ie>>>4;if(!ie)throw"invalid distance";c+=ie&15;var B=hm[ce];if(ce>3){var $=Wr[ce];B+=ec(a,c)&(1<<$)-1,c+=$}if(c>p){if(s)throw"unexpected EOF";break}i&&r(l+131072);for(var oe=l+ne;l>>8},hr=function(a,e,t){t<<=e&7;var n=e/8|0;a[n]|=t,a[n+1]|=t>>>8,a[n+2]|=t>>>16},tc=function(a,e){for(var t=[],n=0;nf&&(f=s[n].s);var d=new Qt(f+1),p=oc(t[u-1],d,0);if(p>e){var n=0,m=0,g=p-e,x=1<e)m+=x-(1<>>=g;m>0;){var b=s[n].s;d[b]=0&&m;--n){var v=s[n].s;d[v]==e&&(--d[v],++m)}p=e}return[new ct(d),p]},oc=function(a,e,t){return a.s==-1?Math.max(oc(a.l,e,t+1),oc(a.r,e,t+1)):e[a.s]=t},fu=function(a){for(var e=a.length;e&&!a[--e];);for(var t=new Qt(++e),n=0,i=a[0],s=1,r=function(c){t[n++]=c},o=1;o<=e;++o)if(a[o]==i&&o!=e)++s;else{if(!i&&s>2){for(;s>138;s-=138)r(32754);s>2&&(r(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(r(i),--s;s>6;s-=6)r(8304);s>2&&(r(s-3<<5|8208),s=0)}for(;s--;)r(i);s=1,i=a[o]}return[t.subarray(0,n),e]},fr=function(a,e){for(var t=0,n=0;n>>8,a[i+2]=a[i]^255,a[i+3]=a[i+1]^255;for(var s=0;s4&&!F[Po[q-1]];--q);var J=l+5<<3,G=fr(i,Ai)+fr(s,Or)+r,X=fr(i,f)+fr(s,m)+r+14+3*q+fr(C,F)+(2*C[16]+3*C[17]+7*C[18]);if(J<=G&&J<=X)return vo(e,u,a.subarray(c,c+l));var B,Z,Y,W;if(Yn(e,u,1+(X15&&(Yn(e,u,ie[_]>>>5&127),u+=ie[_]>>>12)}}else B=fm,Z=Ai,Y=pm,W=Or;for(var _=0;_255){var ce=n[_]>>>18&31;hr(e,u,B[ce+257]),u+=Z[ce+257],ce>7&&(Yn(e,u,n[_]>>>23&31),u+=Hr[ce]);var oe=n[_]&31;hr(e,u,Y[oe]),u+=W[oe],oe>3&&(hr(e,u,n[_]>>>5&8191),u+=Wr[oe])}else hr(e,u,B[n[_]]),u+=Z[n[_]];return hr(e,u,B[256]),u+Z[256]},gm=new Ti([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),yi=new ct(0),ym=function(a,e,t,n,i,s){var r=a.length,o=new ct(n+r+5*(1+Math.ceil(r/7e3))+i),c=o.subarray(n,o.length-i),l=0;if(!e||r<8)for(var u=0;u<=r;u+=65535){var h=u+65535;h>>13,p=f&8191,m=(1<7e3||F>24576)&&B>423){l=du(a,c,0,M,T,C,E,F,q,u-q,l),F=_=E=0,q=u;for(var Z=0;Z<286;++Z)T[Z]=0;for(var Z=0;Z<30;++Z)C[Z]=0}var Y=2,W=0,j=p,ne=G-X&32767;if(B>2&&J==v(u-ne))for(var $=Math.min(d,B)-1,ie=Math.min(32767,u),ce=Math.min(258,B);ne<=ie&&--j&&G!=X;){if(a[u+Y]==a[u+Y-ne]){for(var oe=0;oeY){if(Y=oe,W=ne,oe>$)break;for(var H=Math.min(ne,oe-2),ye=0,Z=0;Zye&&(ye=xe,X=we)}}}G=X,X=g[G],ne+=G-X+32768&32767}if(W){M[F++]=268435456|rc[Y]<<18|hu[W];var Ve=rc[Y]&31,he=hu[W]&31;E+=Hr[Ve]+Wr[he],++T[257+Ve],++C[he],U=u+Y,++_}else M[F++]=a[u],++T[a[u]]}}l=du(a,c,s,M,T,C,E,F,q,u-q,l),!s&&l&7&&(l=vo(c,l+1,yi))}return Nn(o,0,n+qo(l)+i)},xm=function(){for(var a=new Ti(256),e=0;e<256;++e){for(var t=e,n=9;--n;)t=(t&1&&3988292384)^t>>>1;a[e]=t}return a}(),qr=function(){var a=-1;return{p:function(e){for(var t=a,n=0;n>>8;a=t},d:function(){return~a}}},ih=function(){var a=1,e=0;return{p:function(t){for(var n=a,i=e,s=t.length,r=0;r!=s;){for(var o=Math.min(r+2655,s);r>16),i=(i&65535)+15*(i>>16)}a=n,e=i},d:function(){return a%=65521,e%=65521,(a&255)<<24|a>>>8<<16|(e&255)<<8|e>>>8}}},Hs=function(a,e,t,n,i){return ym(a,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(a.length)))*1.5):12+e.mem,t,n,!i)},jo=function(a,e){var t={};for(var n in a)t[n]=a[n];for(var n in e)t[n]=e[n];return t},Xf=function(a,e,t){for(var n=a(),i=a.toString(),s=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/ /g,"").split(","),r=0;r>>0},bl=function(a,e){return Ut(a,e)+Ut(a,e+4)*4294967296},vt=function(a,e,t){for(;t;++e)a[e]=t,t>>>=8},rh=function(a,e){var t=e.filename;if(a[0]=31,a[1]=139,a[2]=8,a[8]=e.level<2?4:e.level==9?2:0,a[9]=3,e.mtime!=0&&vt(a,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),t){a[3]=8;for(var n=0;n<=t.length;++n)a[n+10]=t.charCodeAt(n)}},oh=function(a){if(a[0]!=31||a[1]!=139||a[2]!=8)throw"invalid gzip data";var e=a[3],t=10;e&4&&(t+=a[10]|(a[11]<<8)+2);for(var n=(e>>3&1)+(e>>4&1);n>0;n-=!a[t++]);return t+(e&2)},Sm=function(a){var e=a.length;return(a[e-4]|a[e-3]<<8|a[e-2]<<16|a[e-1]<<24)>>>0},ah=function(a){return 10+(a.filename&&a.filename.length+1||0)},ch=function(a,e){var t=e.level,n=t==0?0:t<6?1:t==9?3:2;a[0]=120,a[1]=n<<6|(n?32-2*n:1)},Tm=function(a){if((a[0]&15)!=8||a[0]>>>4>7||(a[0]<<8|a[1])%31)throw"invalid zlib data";if(a[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function lh(a,e){return!e&&typeof a=="function"&&(e=a,a={}),this.ondata=e,a}var ii=function(){function a(e,t){!t&&typeof e=="function"&&(t=e,e={}),this.ondata=t,this.o=e||{}}return a.prototype.p=function(e,t){this.ondata(Hs(e,this.o,0,0,!t),t)},a.prototype.push=function(e,t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=t,this.p(e,t||!1)},a}(),Am=function(){function a(e,t){Zr([jr,function(){return[On,ii]}],this,lh.call(this,e,t),function(n){var i=new ii(n.data);onmessage=On(i)},6)}return a}();function Em(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Yr(a,e,[jr],function(n){return ns(Yo(n.data[0],n.data[1]))},0,t)}function Yo(a,e){return Hs(a,e||{},0,0)}var xn=function(){function a(e){this.s={},this.p=new ct(0),this.ondata=e}return a.prototype.e=function(e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var t=this.p.length,n=new ct(t+e.length);n.set(this.p),n.set(e,t),this.p=n},a.prototype.c=function(e){this.d=this.s.i=e||!1;var t=this.s.b,n=Xo(this.p,this.o,this.s);this.ondata(Nn(n,t,this.s.b),this.d),this.o=Nn(n,this.s.b-32768),this.s.b=this.o.length,this.p=Nn(this.p,this.s.p/8|0),this.s.p&=7},a.prototype.push=function(e,t){this.e(e),this.c(t)},a}(),uh=function(){function a(e){this.ondata=e,Zr([Xr,function(){return[On,xn]}],this,0,function(){var t=new xn;onmessage=On(t)},7)}return a}();function hh(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Yr(a,e,[Xr],function(n){return ns(Kr(n.data[0],sh(n.data[1])))},1,t)}function Kr(a,e){return Xo(a,e)}var ac=function(){function a(e,t){this.c=qr(),this.l=0,this.v=1,ii.call(this,e,t)}return a.prototype.push=function(e,t){ii.prototype.push.call(this,e,t)},a.prototype.p=function(e,t){this.c.p(e),this.l+=e.length;var n=Hs(e,this.o,this.v&&ah(this.o),t&&8,!t);this.v&&(rh(n,this.o),this.v=0),t&&(vt(n,n.length-8,this.c.d()),vt(n,n.length-4,this.l)),this.ondata(n,t)},a}(),jf=function(){function a(e,t){Zr([jr,_m,function(){return[On,ii,ac]}],this,lh.call(this,e,t),function(n){var i=new ac(n.data);onmessage=On(i)},8)}return a}();function Yf(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Yr(a,e,[jr,_m,function(){return[cc]}],function(n){return ns(cc(n.data[0],n.data[1]))},2,t)}function cc(a,e){e||(e={});var t=qr(),n=a.length;t.p(a);var i=Hs(a,e,ah(e),8),s=i.length;return rh(i,e),vt(i,s-8,t.d()),vt(i,s-4,n),i}var lc=function(){function a(e){this.v=1,xn.call(this,e)}return a.prototype.push=function(e,t){if(xn.prototype.e.call(this,e),this.v){var n=this.p.length>3?oh(this.p):4;if(n>=this.p.length&&!t)return;this.p=this.p.subarray(n),this.v=0}if(t){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}xn.prototype.c.call(this,t)},a}(),Cm=function(){function a(e){this.ondata=e,Zr([Xr,bm,function(){return[On,xn,lc]}],this,0,function(){var t=new lc;onmessage=On(t)},9)}return a}();function Lm(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Yr(a,e,[Xr,bm,function(){return[uc]}],function(n){return ns(uc(n.data[0]))},3,t)}function uc(a,e){return Xo(a.subarray(oh(a),-8),e||new ct(Sm(a)))}var pu=function(){function a(e,t){this.c=ih(),this.v=1,ii.call(this,e,t)}return a.prototype.push=function(e,t){ii.prototype.push.call(this,e,t)},a.prototype.p=function(e,t){this.c.p(e);var n=Hs(e,this.o,this.v&&2,t&&4,!t);this.v&&(ch(n,this.o),this.v=0),t&&vt(n,n.length-4,this.c.d()),this.ondata(n,t)},a}(),zw=function(){function a(e,t){Zr([jr,wm,function(){return[On,ii,pu]}],this,lh.call(this,e,t),function(n){var i=new pu(n.data);onmessage=On(i)},10)}return a}();function Uw(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Yr(a,e,[jr,wm,function(){return[mu]}],function(n){return ns(mu(n.data[0],n.data[1]))},4,t)}function mu(a,e){e||(e={});var t=ih();t.p(a);var n=Hs(a,e,2,4);return ch(n,e),vt(n,n.length-4,t.d()),n}var hc=function(){function a(e){this.v=1,xn.call(this,e)}return a.prototype.push=function(e,t){if(xn.prototype.e.call(this,e),this.v){if(this.p.length<2&&!t)return;this.p=this.p.subarray(2),this.v=0}if(t){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}xn.prototype.c.call(this,t)},a}(),Rm=function(){function a(e){this.ondata=e,Zr([Xr,Mm,function(){return[On,xn,hc]}],this,0,function(){var t=new hc;onmessage=On(t)},11)}return a}();function Im(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Yr(a,e,[Xr,Mm,function(){return[Fo]}],function(n){return ns(Fo(n.data[0],sh(n.data[1])))},5,t)}function Fo(a,e){return Xo((Tm(a),a.subarray(2,-4)),e)}var Pm=function(){function a(e){this.G=lc,this.I=xn,this.Z=hc,this.ondata=e}return a.prototype.push=function(e,t){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var n=new ct(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length)}else this.p=e;if(this.p.length>2){var i=this,s=function(){i.ondata.apply(i,arguments)};this.s=this.p[0]==31&&this.p[1]==139&&this.p[2]==8?new this.G(s):(this.p[0]&15)!=8||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(s):new this.Z(s),this.s.push(this.p,t),this.p=null}}},a}(),Gw=function(){function a(e){this.G=Cm,this.I=uh,this.Z=Rm,this.ondata=e}return a.prototype.push=function(e,t){Pm.prototype.push.call(this,e,t)},a}();function Vw(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return a[0]==31&&a[1]==139&&a[2]==8?Lm(a,e,t):(a[0]&15)!=8||a[0]>>4>7||(a[0]<<8|a[1])%31?hh(a,e,t):Im(a,e,t)}function Hw(a,e){return a[0]==31&&a[1]==139&&a[2]==8?uc(a,e):(a[0]&15)!=8||a[0]>>4>7||(a[0]<<8|a[1])%31?Kr(a,e):Fo(a,e)}var fh=function(a,e,t,n){for(var i in a){var s=a[i],r=e+i;s instanceof ct?t[r]=[s,n]:Array.isArray(s)?t[r]=[s[0],jo(n,s[1])]:fh(s,r+"/",t,n)}},Zf=typeof TextEncoder!="undefined"&&new TextEncoder,gu=typeof TextDecoder!="undefined"&&new TextDecoder,Dm=0;try{gu.decode(yi,{stream:!0}),Dm=1}catch{}var Fm=function(a){for(var e="",t=0;;){var n=a[t++],i=(n>127)+(n>223)+(n>239);if(t+i>a.length)return[e,Nn(a,t-1)];i?i==3?(n=((n&15)<<18|(a[t++]&63)<<12|(a[t++]&63)<<6|a[t++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):i&1?e+=String.fromCharCode((n&31)<<6|a[t++]&63):e+=String.fromCharCode((n&15)<<12|(a[t++]&63)<<6|a[t++]&63):e+=String.fromCharCode(n)}},Ww=function(){function a(e){this.ondata=e,Dm?this.t=new TextDecoder:this.p=yi}return a.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(t=!!t,this.t){if(this.ondata(this.t.decode(e,{stream:!0}),t),t){if(this.t.decode().length)throw"invalid utf-8 data";this.t=null}return}if(!this.p)throw"stream finished";var n=new ct(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length);var i=Fm(n),s=i[0],r=i[1];if(t){if(r.length)throw"invalid utf-8 data";this.p=null}else this.p=r;this.ondata(s,t)},a}(),qw=function(){function a(e){this.ondata=e}return a.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(this.d)throw"stream finished";this.ondata($i(e),this.d=t||!1)},a}();function $i(a,e){if(e){for(var t=new ct(a.length),n=0;n>1)),r=0,o=function(u){s[r++]=u},n=0;ns.length){var c=new ct(r+8+(i-n<<1));c.set(s),s=c}var l=a.charCodeAt(n);l<128||e?o(l):l<2048?(o(192|l>>6),o(128|l&63)):l>55295&&l<57344?(l=65536+(l&1023<<10)|a.charCodeAt(++n)&1023,o(240|l>>18),o(128|l>>12&63),o(128|l>>6&63),o(128|l&63)):(o(224|l>>12),o(128|l>>6&63),o(128|l&63))}return Nn(s,0,r)}function dh(a,e){if(e){for(var t="",n=0;n65535)throw"extra field too long";e+=n+4}return e},Br=function(a,e,t,n,i,s,r,o){var c=n.length,l=t.extra,u=o&&o.length,h=qi(l);vt(a,e,r!=null?33639248:67324752),e+=4,r!=null&&(a[e++]=20,a[e++]=t.os),a[e]=20,e+=2,a[e++]=t.flag<<1|(s==null&&8),a[e++]=i&&8,a[e++]=t.compression&255,a[e++]=t.compression>>8;var f=new Date(t.mtime==null?Date.now():t.mtime),d=f.getFullYear()-1980;if(d<0||d>119)throw"date not in range 1980-2099";if(vt(a,e,d<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>>1),e+=4,s!=null&&(vt(a,e,t.crc),vt(a,e+4,s),vt(a,e+8,t.size)),vt(a,e+12,c),vt(a,e+14,h),e+=16,r!=null&&(vt(a,e,u),vt(a,e+6,t.attrs),vt(a,e+10,r),e+=14),a.set(n,e),e+=c,h)for(var p in l){var m=l[p],g=m.length;vt(a,e,+p),vt(a,e+2,g),a.set(m,e+4),e+=4+g}return u&&(a.set(o,e),e+=u),e},ph=function(a,e,t,n,i){vt(a,e,101010256),vt(a,e+8,t),vt(a,e+10,t),vt(a,e+12,n),vt(a,e+16,i)},No=function(){function a(e){this.filename=e,this.c=qr(),this.size=0,this.compression=0}return a.prototype.process=function(e,t){this.ondata(null,e,t)},a.prototype.push=function(e,t){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},a}(),Xw=function(){function a(e,t){var n=this;t||(t={}),No.call(this,e),this.d=new ii(t,function(i,s){n.ondata(null,i,s)}),this.compression=8,this.flag=Nm(t.level)}return a.prototype.process=function(e,t){try{this.d.push(e,t)}catch(n){this.ondata(n,null,t)}},a.prototype.push=function(e,t){No.prototype.push.call(this,e,t)},a}(),jw=function(){function a(e,t){var n=this;t||(t={}),No.call(this,e),this.d=new Am(t,function(i,s,r){n.ondata(i,s,r)}),this.compression=8,this.flag=Nm(t.level),this.terminate=this.d.terminate}return a.prototype.process=function(e,t){this.d.push(e,t)},a.prototype.push=function(e,t){No.prototype.push.call(this,e,t)},a}(),Yw=function(){function a(e){this.ondata=e,this.u=[],this.d=1}return a.prototype.add=function(e){var t=this;if(this.d&2)throw"stream finished";var n=$i(e.filename),i=n.length,s=e.comment,r=s&&$i(s),o=i!=e.filename.length||r&&s.length!=r.length,c=i+qi(e.extra)+30;if(i>65535)throw"filename too long";var l=new ct(c);Br(l,0,e,n,o);var u=[l],h=function(){for(var g=0,x=u;g65535&&J("filename too long",null),!q)J(null,y);else if(M<16e4)try{J(null,Yo(y,b))}catch(G){J(G,null)}else u.push(Em(y,b,J))},p=0;p65535)throw"filename too long";var x=u?Yo(c,l):c,y=x.length,b=qr();b.p(c),n.push(jo(l,{size:c.length,crc:b.d(),c:x,f:h,m:p,u:f!=r.length||p&&d.length!=m,o:i,compression:u})),i+=30+f+g+y,s+=76+2*(f+g)+(m||0)+y}for(var v=new ct(s+22),M=i,T=s-i,C=0;C0){var i=Math.min(this.c,e.length),s=e.subarray(0,i);if(this.c-=i,this.d?this.d.push(s,!this.c):this.k[0].push(s),e=e.subarray(i),e.length)return this.push(e,t)}else{var r=0,o=0,c=void 0,l=void 0;this.p.length?e.length?(l=new ct(this.p.length+e.length),l.set(this.p),l.set(e,this.p.length)):l=this.p:l=e;for(var u=l.length,h=this.c,f=h&&this.d,d=function(){var x,y=Ut(l,o);if(y==67324752){r=1,c=o,p.d=null,p.c=0;var b=an(l,o+6),v=an(l,o+8),M=b&2048,T=b&8,C=an(l,o+26),_=an(l,o+28);if(u>o+30+C+_){var E=[];p.k.unshift(E),r=2;var F=Ut(l,o+18),U=Ut(l,o+22),q=dh(l.subarray(o+30,o+=30+C),!M);F==4294967295?(x=T?[-2]:Bm(l,o),F=x[0],U=x[1]):T&&(F=-1),o+=_,p.c=F;var J,G={name:q,compression:v,start:function(){if(!G.ondata)throw"no callback";if(!F)G.ondata(null,yi,!0);else{var X=n.o[v];if(!X)throw"unknown compression type "+v;J=F<0?new X(q):new X(q,F,U),J.ondata=function(W,j,ne){G.ondata(W,j,ne)};for(var B=0,Z=E;B=0&&(G.size=F,G.originalSize=U),p.onfile(G)}return"break"}else if(h){if(y==134695760)return c=o+=12+(h==-2&&8),r=3,p.c=0,"break";if(y==33639248)return c=o-=4,r=3,p.c=0,"break"}},p=this;o65558){e("invalid zip file",null);return}var r=an(a,s+8);r||e(null,{});var o=r,c=Ut(a,s+16),l=c==4294967295;if(l){if(s=Ut(a,s-12),Ut(a,s)!=101075792){e("invalid zip file",null);return}o=r=Ut(a,s+32),c=Ut(a,s+48)}for(var u=function(f){var d=Om(a,c,l),p=d[0],m=d[1],g=d[2],x=d[3],y=d[4],b=d[5],v=km(a,b);c=y;var M=function(C,_){C?(n(),e(C,null)):(i[x]=_,--r||e(null,i))};if(!p)M(null,Nn(a,v,v+m));else if(p==8){var T=a.subarray(v,v+m);if(m<32e4)try{M(null,Kr(T,new ct(g)))}catch(C){M(C,null)}else t.push(hh(T,{size:g},M))}else M("unknown compression type "+p,null)},h=0;h65558)throw"invalid zip file";var n=an(a,t+8);if(!n)return{};var i=Ut(a,t+16),s=i==4294967295;if(s){if(t=Ut(a,t-12),Ut(a,t)!=101075792)throw"invalid zip file";n=Ut(a,t+32),i=Ut(a,t+48)}for(var r=0;r=t[n])return n-1;if(e<=t[a])return a;let i=a,s=n,r=Math.floor((i+s)/2);for(;e=t[r+1];)e=m&&(p[d][0]=p[f][0]/o[y+1][x],g=p[d][0]*o[x][y]);const b=x>=-1?1:-x,v=h-1<=y?m-1:t-h;for(let T=b;T<=v;++T)p[d][T]=(p[f][T]-p[f][T-1])/o[y+1][x+T],g+=p[d][T]*o[x+T][y];h<=y&&(p[d][m]=-p[f][m-1]/o[y+1][h],g+=p[d][m]*o[h][y]),r[m][h]=g;const M=f;f=d,d=M}}let u=t;for(let h=1;h<=n;++h){for(let f=0;f<=t;++f)r[h][f]*=u;u*=t-h}return r}function oM(a,e,t,n,i){const s=i0,c=typeof s.Content=="string"&&s.Content!=="";if(o||c){const l=this.parseImage(n[i]);t[s.RelativeFilename||s.Filename]=l}}}}for(const n in e){const i=e[n];t[i]!==void 0?e[n]=t[i]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase();let s;switch(i){case"bmp":s="image/bmp";break;case"jpg":case"jpeg":s="image/jpeg";break;case"png":s="image/png";break;case"tif":s="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),s="image/tga";break;default:console.warn('FBXLoader: Image type "'+i+'" is not supported.');return}if(typeof t=="string")return"data:"+s+";base64,"+t;{const r=new Uint8Array(t);return window.URL.createObjectURL(new Blob([r],{type:s}))}}parseTextures(e){const t=new Map;if("Texture"in rt.Objects){const n=rt.Objects.Texture;for(const i in n){const s=this.parseTexture(n[i],e);t.set(parseInt(i),s)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const i=e.WrapModeU,s=e.WrapModeV,r=i!==void 0?i.value:0,o=s!==void 0?s.value:0;if(n.wrapS=r===0?cn:jt,n.wrapT=o===0?cn:jt,"Scaling"in e){const c=e.Scaling.value;n.repeat.x=c[0],n.repeat.y=c[1]}if("Translation"in e){const c=e.Translation.value;n.offset.x=c[0],n.offset.y=c[1]}return n}loadTexture(e,t){let n;const i=this.textureLoader.path,s=Ot.get(e.id).children;s!==void 0&&s.length>0&&t[s[0].ID]!==void 0&&(n=t[s[0].ID],(n.indexOf("blob:")===0||n.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let r;const o=e.FileName.slice(-3).toLowerCase();if(o==="tga"){const c=this.manager.getHandler(".tga");c===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),r=new At):(c.setPath(this.textureLoader.path),r=c.load(n))}else o==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),r=new At):r=this.textureLoader.load(n);return this.textureLoader.setPath(i),r}parseMaterials(e){const t=new Map;if("Material"in rt.Objects){const n=rt.Objects.Material;for(const i in n){const s=this.parseMaterial(n[i],e);s!==null&&t.set(parseInt(i),s)}}return t}parseMaterial(e,t){const n=e.id,i=e.attrName;let s=e.ShadingModel;if(typeof s=="object"&&(s=s.value),!Ot.has(n))return null;const r=this.parseParameters(e,t,n);let o;switch(s.toLowerCase()){case"phong":o=new Qn;break;case"lambert":o=new Ic;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),o=new Qn;break}return o.setValues(r),o.name=i,o}parseParameters(e,t,n){const i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=new be().fromArray(e.Diffuse.value):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(i.color=new be().fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=new be().fromArray(e.Emissive.value):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(i.emissive=new be().fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(i.opacity=parseFloat(e.Opacity.value)),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=new be().fromArray(e.Specular.value):e.SpecularColor&&e.SpecularColor.type==="Color"&&(i.specular=new be().fromArray(e.SpecularColor.value));const s=this;return Ot.get(n).children.forEach(function(r){const o=r.relationship;switch(o){case"Bump":i.bumpMap=s.getTexture(t,r.ID);break;case"Maya|TEX_ao_map":i.aoMap=s.getTexture(t,r.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=s.getTexture(t,r.ID),i.map!==void 0&&(i.map.encoding=nt);break;case"DisplacementColor":i.displacementMap=s.getTexture(t,r.ID);break;case"EmissiveColor":i.emissiveMap=s.getTexture(t,r.ID),i.emissiveMap!==void 0&&(i.emissiveMap.encoding=nt);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=s.getTexture(t,r.ID);break;case"ReflectionColor":i.envMap=s.getTexture(t,r.ID),i.envMap!==void 0&&(i.envMap.mapping=vr,i.envMap.encoding=nt);break;case"SpecularColor":i.specularMap=s.getTexture(t,r.ID),i.specularMap!==void 0&&(i.specularMap.encoding=nt);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=s.getTexture(t,r.ID),i.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",o);break}}),i}getTexture(e,t){return"LayeredTexture"in rt.Objects&&t in rt.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=Ot.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in rt.Objects){const n=rt.Objects.Deformer;for(const i in n){const s=n[i],r=Ot.get(parseInt(i));if(s.attrType==="Skin"){const o=this.parseSkeleton(r,n);o.ID=i,r.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),o.geometryID=r.parents[0].ID,e[i]=o}else if(s.attrType==="BlendShape"){const o={id:i};o.rawTargets=this.parseMorphTargets(r,n),o.id=i,r.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=o}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(i){const s=t[i.ID];if(s.attrType!=="Cluster")return;const r={ID:i.ID,indices:[],weights:[],transformLink:new De().fromArray(s.TransformLink.a)};"Indexes"in s&&(r.indices=s.Indexes.a,r.weights=s.Weights.a),n.push(r)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let i=0;i1?r=o:o.length>0?r=o[0]:(r=new Qn({color:13421772}),o.push(r)),"color"in s.attributes&&o.forEach(function(c){c.vertexColors=!0}),s.FBX_Deformer?(i=new Vo(s,r),i.normalizeSkinWeights()):i=new Tt(s,r),i}createCurve(e,t){const n=e.children.reduce(function(s,r){return t.has(r.ID)&&(s=t.get(r.ID)),s},null),i=new Vt({color:3342591,linewidth:1});return new Wn(n,i)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=Hm(t.RotationOrder.value):n.eulerOrder="ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&Ot.get(e.ID).children.forEach(function(i){if(i.relationship==="LookAtProperty"){const s=rt.Objects.Model[i.ID];if("Lcl_Translation"in s){const r=s.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(r),gn.add(e.target)):e.lookAt(new P().fromArray(r))}}})}bindSkeleton(e,t,n){const i=this.parsePoseNodes();for(const s in e){const r=e[s];Ot.get(parseInt(r.ID)).parents.forEach(function(c){if(t.has(c.ID)){const l=c.ID;Ot.get(l).parents.forEach(function(h){n.has(h.ID)&&n.get(h.ID).bind(new zs(r.bones),i[h.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in rt.Objects){const t=rt.Objects.Pose;for(const n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){const i=t[n].PoseNode;Array.isArray(i)?i.forEach(function(s){e[s.Node]=new De().fromArray(s.Matrix.a)}):e[i.Node]=new De().fromArray(i.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in rt&&"AmbientColor"in rt.GlobalSettings){const e=rt.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(t!==0||n!==0||i!==0){const s=new be(t,n,i);gn.add(new Wo(s,1))}}}}class fM{parse(e){const t=new Map;if("Geometry"in rt.Objects){const n=rt.Objects.Geometry;for(const i in n){const s=Ot.get(parseInt(i)),r=this.parseGeometry(s,n[i],e);t.set(parseInt(i),r)}}return t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const i=n.skeletons,s=[],r=e.parents.map(function(h){return rt.Objects.Model[h.ID]});if(r.length===0)return;const o=e.children.reduce(function(h,f){return i[f.ID]!==void 0&&(h=i[f.ID]),h},null);e.children.forEach(function(h){n.morphTargets[h.ID]!==void 0&&s.push(n.morphTargets[h.ID])});const c=r[0],l={};"RotationOrder"in c&&(l.eulerOrder=Hm(c.RotationOrder.value)),"InheritType"in c&&(l.inheritType=parseInt(c.InheritType.value)),"GeometricTranslation"in c&&(l.translation=c.GeometricTranslation.value),"GeometricRotation"in c&&(l.rotation=c.GeometricRotation.value),"GeometricScaling"in c&&(l.scale=c.GeometricScaling.value);const u=Vm(l);return this.genGeometry(t,o,s,u)}genGeometry(e,t,n,i){const s=new qe;e.attrName&&(s.name=e.attrName);const r=this.parseGeoNode(e,t),o=this.genBuffers(r),c=new Ae(o.vertex,3);if(c.applyMatrix4(i),s.setAttribute("position",c),o.colors.length>0&&s.setAttribute("color",new Ae(o.colors,3)),t&&(s.setAttribute("skinIndex",new _c(o.weightsIndices,4)),s.setAttribute("skinWeight",new Ae(o.vertexWeights,4)),s.FBX_Deformer=t),o.normal.length>0){const l=new ln().getNormalMatrix(i),u=new Ae(o.normal,3);u.applyNormalMatrix(l),s.setAttribute("normal",u)}if(o.uvs.forEach(function(l,u){let h="uv"+(u+1).toString();u===0&&(h="uv"),s.setAttribute(h,new Ae(o.uvs[u],2))}),r.material&&r.material.mappingType!=="AllSame"){let l=o.materialIndex[0],u=0;if(o.materialIndex.forEach(function(h,f){h!==l&&(s.addGroup(u,f-u,l),l=h,u=f)}),s.groups.length>0){const h=s.groups[s.groups.length-1],f=h.start+h.count;f!==o.materialIndex.length&&s.addGroup(f,o.materialIndex.length-f,l)}s.groups.length===0&&s.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(s,e,n,i),s}parseGeoNode(e,t){const n={};if(n.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],n.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let i=0;for(;e.LayerElementUV[i];)e.LayerElementUV[i].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[i])),i++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(i,s){i.indices.forEach(function(r,o){n.weightTable[r]===void 0&&(n.weightTable[r]=[]),n.weightTable[r].push({id:s,weight:i.weights[o]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,i=0,s=!1,r=[],o=[],c=[],l=[],u=[],h=[];const f=this;return e.vertexIndices.forEach(function(d,p){let m,g=!1;d<0&&(d=d^-1,g=!0);let x=[],y=[];if(r.push(d*3,d*3+1,d*3+2),e.color){const b=Wa(p,n,d,e.color);c.push(b[0],b[1],b[2])}if(e.skeleton){if(e.weightTable[d]!==void 0&&e.weightTable[d].forEach(function(b){y.push(b.weight),x.push(b.id)}),y.length>4){s||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),s=!0);const b=[0,0,0,0],v=[0,0,0,0];y.forEach(function(M,T){let C=M,_=x[T];v.forEach(function(E,F,U){if(C>E){U[F]=C,C=E;const q=b[F];b[F]=_,_=q}})}),x=b,y=v}for(;y.length<4;)y.push(0),x.push(0);for(let b=0;b<4;++b)u.push(y[b]),h.push(x[b])}if(e.normal){const b=Wa(p,n,d,e.normal);o.push(b[0],b[1],b[2])}e.material&&e.material.mappingType!=="AllSame"&&(m=Wa(p,n,d,e.material)[0]),e.uv&&e.uv.forEach(function(b,v){const M=Wa(p,n,d,b);l[v]===void 0&&(l[v]=[]),l[v].push(M[0]),l[v].push(M[1])}),i++,g&&(f.genFace(t,e,r,m,o,c,l,u,h,i),n++,i=0,r=[],o=[],c=[],l=[],u=[],h=[])}),t}genFace(e,t,n,i,s,r,o,c,l,u){for(let h=2;h1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const r=e.get(s[0].ID);n[i]={name:t[i].attrName,layer:r}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach(function(i){t=t.concat(n.generateTracks(i))}),new Si(e.name,-1,t)}generateTracks(e){const t=[];let n=new P,i=new Ft,s=new P;if(e.transform&&e.transform.decompose(n,i,s),n=n.toArray(),i=new Pn().setFromQuaternion(i,e.eulerOrder).toArray(),s=s.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const r=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");r!==void 0&&t.push(r)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const r=this.generateRotationTrack(e.modelName,e.R.curves,i,e.preRotation,e.postRotation,e.eulerOrder);r!==void 0&&t.push(r)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const r=this.generateVectorTrack(e.modelName,e.S.curves,s,"scale");r!==void 0&&t.push(r)}if(e.DeformPercent!==void 0){const r=this.generateMorphTrack(e);r!==void 0&&t.push(r)}return t}generateVectorTrack(e,t,n,i){const s=this.getTimesForAllAxes(t),r=this.getKeyframeTrackValues(s,t,n);return new Mi(e+"."+i,s,r)}generateRotationTrack(e,t,n,i,s,r){t.x!==void 0&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(en.degToRad)),t.y!==void 0&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(en.degToRad)),t.z!==void 0&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(en.degToRad));const o=this.getTimesForAllAxes(t),c=this.getKeyframeTrackValues(o,t,n);i!==void 0&&(i=i.map(en.degToRad),i.push(r),i=new Pn().fromArray(i),i=new Ft().setFromEuler(i)),s!==void 0&&(s=s.map(en.degToRad),s.push(r),s=new Pn().fromArray(s),s=new Ft().setFromEuler(s).invert());const l=new Ft,u=new Pn,h=[];for(let f=0;f1){let n=1,i=t[0];for(let s=1;s=180){const r=s/180,o=i/r;let c=n+o;const l=e.times[t-1],h=(e.times[t]-l)/r;let f=l+h;const d=[],p=[];for(;f1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}}parseNodeProperty(e,t,n){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),s=t[2].replace(/^"/,"").replace(/"$/,"").trim();i==="Content"&&s===","&&(s=n.replace(/"/g,"").replace(/,$/,"").trim());const r=this.getCurrentNode();if(r.name==="Properties70"){this.parseNodeSpecialProperty(e,i,s);return}if(i==="C"){const c=s.split(",").slice(1),l=parseInt(c[0]),u=parseInt(c[1]);let h=s.split(",").slice(3);h=h.map(function(f){return f.trim().replace(/^"/,"")}),i="connections",s=[l,u],_M(s,h),r[i]===void 0&&(r[i]=[])}i==="Node"&&(r.id=s),i in r&&Array.isArray(r[i])?r[i].push(s):i!=="a"?r[i]=s:r.a=s,this.setCurrentProp(r,i),i==="a"&&s.slice(-1)!==","&&(r.a=Ml(s))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=Ml(t.a))}parseNodeSpecialProperty(e,t,n){const i=n.split('",').map(function(u){return u.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=i[0],r=i[1],o=i[2],c=i[3];let l=i[4];switch(r){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=Ml(l);break}this.getPrevNode()[s]={type:r,type2:o,flag:c,value:l},this.setCurrentProp(this.getPrevNode(),s)}}class mM{parse(e){const t=new Jf(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const i=new Gm;for(;!this.endOfContent(t);){const s=this.parseNode(t,n);s!==null&&i.add(s.name,s)}return i}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},i=t>=7500?e.getUint64():e.getUint32(),s=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const r=e.getUint8(),o=e.getString(r);if(i===0)return null;const c=[];for(let f=0;f0?c[0]:"",u=c.length>1?c[1]:"",h=c.length>2?c[2]:"";for(n.singleProperty=s===1&&e.getOffset()===i;i>e.getOffset();){const f=this.parseNode(e,t);f!==null&&this.parseSubNode(o,n,f)}return n.propertyList=c,typeof l=="number"&&(n.id=l),u!==""&&(n.attrName=u),h!==""&&(n.attrType=h),o!==""&&(n.name=o),n}parseSubNode(e,t,n){if(n.singleProperty===!0){const i=n.propertyList[0];Array.isArray(i)?(t[n.name]=n,n.a=i):t[n.name]=i}else if(e==="Connections"&&n.name==="C"){const i=[];n.propertyList.forEach(function(s,r){r!==0&&i.push(s)}),t.connections===void 0&&(t.connections=[]),t.connections.push(i)}else if(n.name==="Properties70")Object.keys(n).forEach(function(s){t[s]=n[s]});else if(e==="Properties70"&&n.name==="P"){let i=n.propertyList[0],s=n.propertyList[1];const r=n.propertyList[2],o=n.propertyList[3];let c;i.indexOf("Lcl ")===0&&(i=i.replace("Lcl ","Lcl_")),s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),s==="Color"||s==="ColorRGB"||s==="Vector"||s==="Vector3D"||s.indexOf("Lcl_")===0?c=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:c=n.propertyList[4],t[i]={type:s,type2:r,flag:o,value:c}}else t[n.name]===void 0?typeof n.id=="number"?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name==="PoseNode"?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const i=e.getUint32(),s=e.getUint32(),r=e.getUint32();if(s===0)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}typeof nM=="undefined"&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const o=Fo(new Uint8Array(e.getArrayBuffer(r))),c=new Jf(o.buffer);switch(t){case"b":case"c":return c.getBooleanArray(i);case"d":return c.getFloat64Array(i);case"f":return c.getFloat32Array(i);case"i":return c.getInt32Array(i);case"l":return c.getInt64Array(i)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class Jf{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let n=0;n=0&&(t=t.slice(0,n)),tn.decodeText(new Uint8Array(t))}}class Gm{add(e,t){this[e]=t}}function gM(a){const e="Kaydara FBX Binary \0";return a.byteLength>=e.length&&e===Wm(a,0,e.length)}function yM(a){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function n(i){const s=a[i-1];return a=a.slice(t+i),t++,s}for(let i=0;i256||B.colormap_size!==24||B.colormap_type!==1)&&console.error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case d:case p:case g:case x:B.colormap_type&&console.error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case h:console.error("THREE.TGALoader: No data.");default:console.error('THREE.TGALoader: Invalid type "%s".',B.image_type)}(B.width<=0||B.height<=0)&&console.error("THREE.TGALoader: Invalid image size."),B.pixel_size!==8&&B.pixel_size!==16&&B.pixel_size!==24&&B.pixel_size!==32&&console.error('THREE.TGALoader: Invalid pixel size "%s".',B.pixel_size)}function n(B,Z,Y,W,j){let ne,$;const ie=Y.pixel_size>>3,ce=Y.width*Y.height*ie;if(Z&&($=j.subarray(W,W+=Y.colormap_length*(Y.colormap_size>>3))),B){ne=new Uint8Array(ce);let oe,H,ye,we=0;const Pe=new Uint8Array(ie);for(;we>7,B[(H+we*ye)*4+1]=(ce&992)>>2,B[(H+we*ye)*4+2]=(ce&31)<<3,B[(H+we*ye)*4+3]=ce&32768?0:255;return B}function r(B,Z,Y,W,j,ne,$,ie){let ce=0,oe,H;const ye=F.width;for(H=Z;H!==W;H+=Y)for(oe=j;oe!==$;oe+=ne,ce+=3)B[(oe+ye*H)*4+3]=255,B[(oe+ye*H)*4+2]=ie[ce+0],B[(oe+ye*H)*4+1]=ie[ce+1],B[(oe+ye*H)*4+0]=ie[ce+2];return B}function o(B,Z,Y,W,j,ne,$,ie){let ce=0,oe,H;const ye=F.width;for(H=Z;H!==W;H+=Y)for(oe=j;oe!==$;oe+=ne,ce+=4)B[(oe+ye*H)*4+2]=ie[ce+0],B[(oe+ye*H)*4+1]=ie[ce+1],B[(oe+ye*H)*4+0]=ie[ce+2],B[(oe+ye*H)*4+3]=ie[ce+3];return B}function c(B,Z,Y,W,j,ne,$,ie){let ce,oe=0,H,ye;const we=F.width;for(ye=Z;ye!==W;ye+=Y)for(H=j;H!==$;H+=ne,oe++)ce=ie[oe],B[(H+we*ye)*4+0]=ce,B[(H+we*ye)*4+1]=ce,B[(H+we*ye)*4+2]=ce,B[(H+we*ye)*4+3]=255;return B}function l(B,Z,Y,W,j,ne,$,ie){let ce=0,oe,H;const ye=F.width;for(H=Z;H!==W;H+=Y)for(oe=j;oe!==$;oe+=ne,ce+=2)B[(oe+ye*H)*4+0]=ie[ce+0],B[(oe+ye*H)*4+1]=ie[ce+0],B[(oe+ye*H)*4+2]=ie[ce+0],B[(oe+ye*H)*4+3]=ie[ce+1];return B}function u(B,Z,Y,W,j){let ne,$,ie,ce,oe,H;switch((F.flags&y)>>b){default:case T:ne=0,ie=1,oe=Z,$=0,ce=1,H=Y;break;case v:ne=0,ie=1,oe=Z,$=Y-1,ce=-1,H=-1;break;case C:ne=Z-1,ie=-1,oe=-1,$=0,ce=1,H=Y;break;case M:ne=Z-1,ie=-1,oe=-1,$=Y-1,ce=-1,H=-1;break}if(J)switch(F.pixel_size){case 8:c(B,$,ce,H,ne,ie,oe,W);break;case 16:l(B,$,ce,H,ne,ie,oe,W);break;default:console.error("THREE.TGALoader: Format not supported.");break}else switch(F.pixel_size){case 8:i(B,$,ce,H,ne,ie,oe,W,j);break;case 16:s(B,$,ce,H,ne,ie,oe,W);break;case 24:r(B,$,ce,H,ne,ie,oe,W);break;case 32:o(B,$,ce,H,ne,ie,oe,W);break;default:console.error("THREE.TGALoader: Format not supported.");break}return B}const h=0,f=1,d=2,p=3,m=9,g=10,x=11,y=48,b=4,v=0,M=1,T=2,C=3;e.length<19&&console.error("THREE.TGALoader: Not enough data to contain header.");let _=0;const E=new Uint8Array(e),F={id_length:E[_++],colormap_type:E[_++],image_type:E[_++],colormap_index:E[_++]|E[_++]<<8,colormap_length:E[_++]|E[_++]<<8,colormap_size:E[_++],origin:[E[_++]|E[_++]<<8,E[_++]|E[_++]<<8],width:E[_++]|E[_++]<<8,height:E[_++]|E[_++]<<8,pixel_size:E[_++],flags:E[_++]};t(F),F.id_length+_>e.length&&console.error("THREE.TGALoader: No data."),_+=F.id_length;let U=!1,q=!1,J=!1;switch(F.image_type){case m:U=!0,q=!0;break;case f:q=!0;break;case g:U=!0;break;case d:break;case x:U=!0,J=!0;break;case p:J=!0;break}const G=new Uint8Array(F.width*F.height*4),X=n(U,q,F,_,E);return u(G,F.width,F.height,X.pixel_data,X.palettes),{data:G,width:F.width,height:F.height,flipY:!0,generateMipmaps:!0,minFilter:si}}}class wM extends Ht{constructor(e){super(e)}load(e,t,n,i){const s=this,r=s.path===""?tn.extractUrlBase(e):s.path,o=new Kt(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(c){try{t(s.parse(c,r))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e,t){function n(S,w){const L=[],A=S.childNodes;for(let I=0,se=A.length;I0&&w.push(new Mi(A+".position",I,se)),fe.length>0&&w.push(new ni(A+".quaternion",I,fe)),Ne.length>0&&w.push(new Mi(A+".scale",I,Ne)),w}function U(S,w,L){let A,I=!0,se,fe;for(se=0,fe=S.length;se=0;){const A=S[w];if(A.value[L]!==null)return A;w--}return null}function G(S,w,L){for(;w>>0)+2);switch(L=L.toLowerCase(),L){case"tga":w=Bc;break;default:w=yh}return w}function Q(S){const w=k(S.url),L=w.profile.technique;let A;switch(L.type){case"phong":case"blinn":A=new Qn;break;case"lambert":A=new Ic;break;default:A=new un;break}A.name=S.name||"";function I(Le,ke=null){const Ue=w.profile.samplers[Le.id];let Me=null;if(Ue!==void 0){const We=w.profile.surfaces[Ue.source];Me=we(We.init_from)}else console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),Me=we(Le.id);if(Me!==null){const We=K(Me);if(We!==void 0){const Oe=We.load(Me),Xe=Le.extra;if(Xe!==void 0&&Xe.technique!==void 0&&l(Xe.technique)===!1){const Ge=Xe.technique;Oe.wrapS=Ge.wrapU?cn:jt,Oe.wrapT=Ge.wrapV?cn:jt,Oe.offset.set(Ge.offsetU||0,Ge.offsetV||0),Oe.repeat.set(Ge.repeatU||1,Ge.repeatV||1)}else Oe.wrapS=cn,Oe.wrapT=cn;return ke!==null&&(Oe.encoding=ke),Oe}else return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",Me),null}else return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",Le.id),null}const se=L.parameters;for(const Le in se){const ke=se[Le];switch(Le){case"diffuse":ke.color&&A.color.fromArray(ke.color),ke.texture&&(A.map=I(ke.texture,nt));break;case"specular":ke.color&&A.specular&&A.specular.fromArray(ke.color),ke.texture&&(A.specularMap=I(ke.texture));break;case"bump":ke.texture&&(A.normalMap=I(ke.texture));break;case"ambient":ke.texture&&(A.lightMap=I(ke.texture,nt));break;case"shininess":ke.float&&A.shininess&&(A.shininess=ke.float);break;case"emission":ke.color&&A.emissive&&A.emissive.fromArray(ke.color),ke.texture&&(A.emissiveMap=I(ke.texture,nt));break}}A.color.convertSRGBToLinear(),A.specular&&A.specular.convertSRGBToLinear(),A.emissive&&A.emissive.convertSRGBToLinear();let fe=se.transparent,Ne=se.transparency;if(Ne===void 0&&fe&&(Ne={float:1}),fe===void 0&&Ne&&(fe={opaque:"A_ONE",data:{color:[1,1,1,1]}}),fe&&Ne)if(fe.data.texture)A.transparent=!0;else{const Le=fe.data.color;switch(fe.opaque){case"A_ONE":A.opacity=Le[3]*Ne.float;break;case"RGB_ZERO":A.opacity=1-Le[0]*Ne.float;break;case"A_ZERO":A.opacity=1-Le[3]*Ne.float;break;case"RGB_ONE":A.opacity=Le[0]*Ne.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',fe.opaque)}A.opacity<1&&(A.transparent=!0)}if(L.extra!==void 0&&L.extra.technique!==void 0){const Le=L.extra.technique;for(const ke in Le){const Ue=Le[ke];switch(ke){case"double_sided":A.side=Ue===1?_i:vi;break;case"bump":A.normalMap=I(Ue.texture),A.normalScale=new de(1,1);break}}}return A}function me(S){return m(Ye.materials[S],Q)}function R(S){const w={name:S.getAttribute("name")};for(let L=0,A=S.childNodes.length;L0?fe+Le:fe;w.inputs[ke]={id:se,offset:Ne},w.stride=Math.max(w.stride,Ne+1),fe==="TEXCOORD"&&(w.hasUV=!0);break;case"vcount":w.vcount=r(I.textContent);break;case"p":w.p=r(I.textContent);break}}return w}function Et(S){const w={};for(let L=0;L0&&w0&&Me.setAttribute("position",new Ae(I.array,I.stride)),se.array.length>0&&Me.setAttribute("normal",new Ae(se.array,se.stride)),Le.array.length>0&&Me.setAttribute("color",new Ae(Le.array,Le.stride)),fe.array.length>0&&Me.setAttribute("uv",new Ae(fe.array,fe.stride)),Ne.array.length>0&&Me.setAttribute("uv2",new Ae(Ne.array,Ne.stride)),ke.array.length>0&&Me.setAttribute("skinIndex",new Ae(ke.array,ke.stride)),Ue.array.length>0&&Me.setAttribute("skinWeight",new Ae(Ue.array,Ue.stride)),A.data=Me,A.type=S[0].type,A.materialKeys=We,A}function Mt(S,w,L,A,I=!1){const se=S.p,fe=S.stride,Ne=S.vcount;function Le(Me){let We=se[Me+L]*Ue;const Oe=We+Ue;for(;We4)for(let Ge=1,Lt=Xe-2;Ge<=Lt;Ge++){const _t=Me+fe*0,gt=Me+fe*Ge,yt=Me+fe*(Ge+1);Le(_t),Le(gt),Le(yt)}Me+=fe*Xe}}else for(let Me=0,We=se.length;Me=w.limits.max&&(w.static=!0),w.middlePosition=(w.limits.min+w.limits.max)/2,w}function ee(S){const w={sid:S.getAttribute("sid"),name:S.getAttribute("name")||"",attachments:[],transforms:[]};for(let L=0;LOe.limits.max||Me=2.0 are supported."));return}const l=new JM(c,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u=0&&o[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(r),l.setPlugins(o),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function SM(){let a={};return{get:function(e){return a[e]},add:function(e,t){a[e]=t},remove:function(e){delete a[e]},removeAll:function(){a={}}}}const ot={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class TM{constructor(e){this.parser=e,this.name=ot.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,r)}}class kM{constructor(e){this.parser=e,this.name=ot.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const r=s.extensions[t],o=i.images[r.source];let c=n.textureLoader;if(o.uri){const l=n.options.manager.getHandler(o.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return n.loadTextureImage(e,r.source,c);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class OM{constructor(e){this.name=ot.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([s,r.ready]).then(function(o){const c=i.byteOffset||0,l=i.byteLength||0,u=i.count,h=i.byteStride,f=new ArrayBuffer(u*h),d=new Uint8Array(o[0],c,l);return r.decodeGltfBuffer(new Uint8Array(f),u,h,d,i.mode,i.filter),f})}else return null}}const qm="glTF",co=12,ed={JSON:1313821514,BIN:5130562};class BM{constructor(e){this.name=ot.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,co);if(this.header={magic:tn.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==qm)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-co,i=new DataView(e,co);let s=0;for(;s",t).replace("#include ",n).replace("#include ",i).replace("#include ",s).replace("#include ",r)},Object.defineProperties(this,{specular:{get:function(){return o.specular.value},set:function(c){o.specular.value=c}},specularMap:{get:function(){return o.specularMap.value},set:function(c){o.specularMap.value=c,c?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return o.glossiness.value},set:function(c){o.glossiness.value=c}},glossinessMap:{get:function(){return o.glossinessMap.value},set:function(c){o.glossinessMap.value=c,c?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class GM{constructor(){this.name=rt.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return yu}extendParams(e,t,n){const i=t.extensions[this.name];e.color=new ve(1,1,1),e.opacity=1;const s=[];if(Array.isArray(i.diffuseFactor)){const r=i.diffuseFactor;e.color.fromArray(r),e.opacity=r[3]}if(i.diffuseTexture!==void 0&&s.push(n.assignTexture(e,"map",i.diffuseTexture,tt)),e.emissive=new ve(0,0,0),e.glossiness=i.glossinessFactor!==void 0?i.glossinessFactor:1,e.specular=new ve(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),i.specularGlossinessTexture!==void 0){const r=i.specularGlossinessTexture;s.push(n.assignTexture(e,"glossinessMap",r)),s.push(n.assignTexture(e,"specularMap",r,tt))}return Promise.all(s)}createMaterial(e){const t=new yu(e);return t.fog=!0,t.color=e.color,t.map=e.map===void 0?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=e.aoMap===void 0?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=e.emissiveIntensity===void 0?1:e.emissiveIntensity,t.emissiveMap=e.emissiveMap===void 0?null:e.emissiveMap,t.bumpMap=e.bumpMap===void 0?null:e.bumpMap,t.bumpScale=1,t.normalMap=e.normalMap===void 0?null:e.normalMap,t.normalMapType=Qi,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=e.specularMap===void 0?null:e.specularMap,t.specular=e.specular,t.glossinessMap=e.glossinessMap===void 0?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=e.envMap===void 0?null:e.envMap,t.envMapIntensity=1,t}}class VM{constructor(){this.name=rt.KHR_MESH_QUANTIZATION}}class Xm extends Gr{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let r=0;r!==i;r++)t[r]=n[s+r];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=o*2,l=o*3,u=i-t,h=(n-t)/u,f=h*h,d=f*h,p=e*l,m=p-l,g=-2*d+3*f,x=d-f,y=1-g,b=x-f+h;for(let v=0;v!==o;v++){const S=r[m+v+o],A=r[m+v+c]*u,R=r[p+v+o],_=r[p+v]*u;s[v]=y*S+b*A+g*R+x*_}return s}}const HM=new Ft;class WM extends Xm{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return HM.fromArray(s).normalize().toArray(s),s}}const pi={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},ko={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ed={9728:Bt,9729:Rt,9984:bo,9985:mc,9986:wo,9987:si},td={33071:jt,33648:_r,10497:cn},nd={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},xu={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},zi={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},qM={CUBICSPLINE:void 0,LINEAR:Cs,STEP:wr},Ml={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function XM(a){return a.DefaultMaterial===void 0&&(a.DefaultMaterial=new Us({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:vi})),a.DefaultMaterial}function lo(a,e,t){for(const n in t.extensions)a[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function ms(a,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(a.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function jM(a,e,t){let n=!1,i=!1,s=!1;for(let l=0,u=e.length;l0||a.search(/^data\:image\/jpeg/)===0?"image/jpeg":a.search(/\.webp($|\?)/i)>0||a.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}class JM{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new SM,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};const n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,i=navigator.userAgent.indexOf("Firefox")>-1,s=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1;typeof createImageBitmap=="undefined"||n||i&&s<98?this.textureLoader=new ks(this.options.manager):this.textureLoader=new tm(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Kt(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(r){const o={scene:r[0][i.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:i.asset,parser:n,userData:{}};lo(s,o,i),ms(o,i),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(o)})).then(function(){e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i{const c=this.associations.get(r);c!=null&&this.associations.set(o,c);for(const[l,u]of r.children.entries())s(u,o.children[l])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&g.setY(L,A[R*c+1]),c>=3&&g.setZ(L,A[R*c+2]),c>=4&&g.setW(L,A[R*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return g})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,r=t.images[s];let o=this.textureLoader;if(r.uri){const c=n.manager.getHandler(r.uri);c!==null&&(o=c)}return this.loadTextureImage(e,s,o)}loadTextureImage(e,t,n){const i=this,s=this.json,r=s.textures[e],o=s.images[t],c=(o.uri||o.bufferView)+":"+r.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(t,n).then(function(u){u.flipY=!1,r.name&&(u.name=r.name);const f=(s.samplers||{})[r.sampler]||{};return u.magFilter=ed[f.magFilter]||Rt,u.minFilter=ed[f.minFilter]||si,u.wrapS=td[f.wrapS]||cn,u.wrapT=td[f.wrapT]||cn,i.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const r=i.images[e],o=self.URL||self.webkitURL;let c=r.uri||"",l=!1;if(r.bufferView!==void 0)c=n.getDependency("bufferView",r.bufferView).then(function(h){l=!0;const f=new Blob([h],{type:r.mimeType});return c=o.createObjectURL(f),c});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(c).then(function(h){return new Promise(function(f,d){let p=f;t.isImageBitmapLoader===!0&&(p=function(m){const g=new At(m);g.needsUpdate=!0,f(g)}),t.load(tn.resolveURL(h,s.path),p,void 0,d)})}).then(function(h){return l===!0&&o.revokeObjectURL(c),h.userData.mimeType=r.mimeType||KM(r.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),h});return this.sourceCache[e]=u,u}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(r){if(n.texCoord!==void 0&&n.texCoord!=0&&!(t==="aoMap"&&n.texCoord==1)&&console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+t+" not yet supported."),s.extensions[rt.KHR_TEXTURE_TRANSFORM]){const o=n.extensions!==void 0?n.extensions[rt.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const c=s.associations.get(r);r=s.extensions[rt.KHR_TEXTURE_TRANSFORM].extendTexture(r,o),s.associations.set(r,c)}}return i!==void 0&&(r.encoding=i),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+n.uuid;let c=this.cache.get(o);c||(c=new Hi,Gt.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(o,c)),n=c}else if(e.isLine){const o="LineBasicMaterial:"+n.uuid;let c=this.cache.get(o);c||(c=new Vt,Gt.prototype.copy.call(c,n),c.color.copy(n.color),this.cache.add(o,c)),n=c}if(i||s||r){let o="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(o+="specular-glossiness:"),i&&(o+="derivative-tangents:"),s&&(o+="vertex-colors:"),r&&(o+="flat-shading:");let c=this.cache.get(o);c||(c=n.clone(),s&&(c.vertexColors=!0),r&&(c.flatShading=!0),i&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(o,c),this.associations.set(c,this.associations.get(n))),n=c}n.aoMap&&t.attributes.uv2===void 0&&t.attributes.uv!==void 0&&t.setAttribute("uv2",t.attributes.uv),e.material=n}getMaterialType(){return Us}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let r;const o={},c=s.extensions||{},l=[];if(c[rt.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const h=i[rt.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];r=h.getMaterialType(),l.push(h.extendParams(o,s,t))}else if(c[rt.KHR_MATERIALS_UNLIT]){const h=i[rt.KHR_MATERIALS_UNLIT];r=h.getMaterialType(),l.push(h.extendParams(o,s,t))}else{const h=s.pbrMetallicRoughness||{};if(o.color=new ve(1,1,1),o.opacity=1,Array.isArray(h.baseColorFactor)){const f=h.baseColorFactor;o.color.fromArray(f),o.opacity=f[3]}h.baseColorTexture!==void 0&&l.push(t.assignTexture(o,"map",h.baseColorTexture,tt)),o.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,o.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(o,"metalnessMap",h.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",h.metallicRoughnessTexture))),r=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,o)})))}s.doubleSided===!0&&(o.side=_i);const u=s.alphaMode||Ml.OPAQUE;if(u===Ml.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,u===Ml.MASK&&(o.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&r!==un&&(l.push(t.assignTexture(o,"normalMap",s.normalTexture)),o.normalScale=new fe(1,1),s.normalTexture.scale!==void 0)){const h=s.normalTexture.scale;o.normalScale.set(h,h)}return s.occlusionTexture!==void 0&&r!==un&&(l.push(t.assignTexture(o,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&r!==un&&(o.emissive=new ve().fromArray(s.emissiveFactor)),s.emissiveTexture!==void 0&&r!==un&&l.push(t.assignTexture(o,"emissiveMap",s.emissiveTexture,tt)),Promise.all(l).then(function(){let h;return r===yu?h=i[rt.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(o):h=new r(o),s.name&&(h.name=s.name),ms(h,s),t.associations.set(h,{materials:e}),s.extensions&&lo(i,h,s),h})}createUniqueName(e){const t=it.sanitizeNodeName(e||"");let n=t;for(let i=1;this.nodeNamesUsed[n];++i)n=t+"_"+i;return this.nodeNamesUsed[n]=!0,n}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(o){return n[rt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(c){return sd(c,o,t)})}const r=[];for(let o=0,c=e.length;o0&&YM(x,s),x.name=t.createUniqueName(s.name||"mesh_"+e),ms(x,s),g.extensions&&lo(i,x,g),t.assignFinalMaterial(x),h.push(x)}for(let d=0,p=h.length;d1?c=new yn:o.length===1?c=o[0]:c=new lt,c!==o[0])for(let l=0,u=o.length;l{const h=new Map;for(const[f,d]of s.associations)(f instanceof Gt||f instanceof At)&&h.set(f,d);return u.traverse(f=>{const d=s.associations.get(f);d!=null&&h.set(f,d)}),h};return s.associations=l(r),r})}}function jm(a,e,t,n){const i=t.nodes[a];return n.getDependency("node",a).then(function(s){if(i.skin===void 0)return s;let r;return n.getDependency("skin",i.skin).then(function(o){r=o;const c=[];for(let l=0,u=r.joints.length;l0?s[s.length-1]:"",smooth:r!==void 0?r.smooth:this.smooth,groupStart:r!==void 0?r.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(c){const l={index:typeof c=="number"?c:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return l.clone=this.clone.bind(l),l}};return this.materials.push(o),o},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(i){const s=this.currentMaterial();if(s&&s.groupEnd===-1&&(s.groupEnd=this.geometry.vertices.length/3,s.groupCount=s.groupEnd-s.groupStart,s.inherited=!1),i&&this.materials.length>1)for(let r=this.materials.length-1;r>=0;r--)this.materials[r].groupCount<=0&&this.materials.splice(r,1);return i&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),s}},n&&n.name&&typeof n.clone=="function"){const i=n.clone(0);i.inherited=!0,this.object.materials.push(i)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){const i=this.vertices,s=this.object.geometry.vertices;s.push(i[e+0],i[e+1],i[e+2]),s.push(i[t+0],i[t+1],i[t+2]),s.push(i[n+0],i[n+1],i[n+2])},addVertexPoint:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){const i=this.normals,s=this.object.geometry.normals;s.push(i[e+0],i[e+1],i[e+2]),s.push(i[t+0],i[t+1],i[t+2]),s.push(i[n+0],i[n+1],i[n+2])},addFaceNormal:function(e,t,n){const i=this.vertices,s=this.object.geometry.normals;ad.fromArray(i,e),Sl.fromArray(i,t),cd.fromArray(i,n),En.subVectors(cd,Sl),ld.subVectors(ad,Sl),En.cross(ld),En.normalize(),s.push(En.x,En.y,En.z),s.push(En.x,En.y,En.z),s.push(En.x,En.y,En.z)},addColor:function(e,t,n){const i=this.colors,s=this.object.geometry.colors;i[e]!==void 0&&s.push(i[e+0],i[e+1],i[e+2]),i[t]!==void 0&&s.push(i[t+0],i[t+1],i[t+2]),i[n]!==void 0&&s.push(i[n+0],i[n+1],i[n+2])},addUV:function(e,t,n){const i=this.uvs,s=this.object.geometry.uvs;s.push(i[e+0],i[e+1]),s.push(i[t+0],i[t+1]),s.push(i[n+0],i[n+1])},addDefaultUV:function(){const e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){const t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,i,s,r,o,c,l){const u=this.vertices.length;let h=this.parseVertexIndex(e,u),f=this.parseVertexIndex(t,u),d=this.parseVertexIndex(n,u);if(this.addVertex(h,f,d),this.addColor(h,f,d),o!==void 0&&o!==""){const p=this.normals.length;h=this.parseNormalIndex(o,p),f=this.parseNormalIndex(c,p),d=this.parseNormalIndex(l,p),this.addNormal(h,f,d)}else this.addFaceNormal(h,f,d);if(i!==void 0&&i!==""){const p=this.uvs.length;h=this.parseUVIndex(i,p),f=this.parseUVIndex(s,p),d=this.parseUVIndex(r,p),this.addUV(h,f,d),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";const t=this.vertices.length;for(let n=0,i=e.length;n",t).replace("#include ",n).replace("#include ",i).replace("#include ",s).replace("#include ",r)},Object.defineProperties(this,{specular:{get:function(){return o.specular.value},set:function(c){o.specular.value=c}},specularMap:{get:function(){return o.specularMap.value},set:function(c){o.specularMap.value=c,c?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return o.glossiness.value},set:function(c){o.glossiness.value=c}},glossinessMap:{get:function(){return o.glossinessMap.value},set:function(c){o.glossinessMap.value=c,c?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class GM{constructor(){this.name=ot.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return xu}extendParams(e,t,n){const i=t.extensions[this.name];e.color=new be(1,1,1),e.opacity=1;const s=[];if(Array.isArray(i.diffuseFactor)){const r=i.diffuseFactor;e.color.fromArray(r),e.opacity=r[3]}if(i.diffuseTexture!==void 0&&s.push(n.assignTexture(e,"map",i.diffuseTexture,nt)),e.emissive=new be(0,0,0),e.glossiness=i.glossinessFactor!==void 0?i.glossinessFactor:1,e.specular=new be(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),i.specularGlossinessTexture!==void 0){const r=i.specularGlossinessTexture;s.push(n.assignTexture(e,"glossinessMap",r)),s.push(n.assignTexture(e,"specularMap",r,nt))}return Promise.all(s)}createMaterial(e){const t=new xu(e);return t.fog=!0,t.color=e.color,t.map=e.map===void 0?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=e.aoMap===void 0?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=e.emissiveIntensity===void 0?1:e.emissiveIntensity,t.emissiveMap=e.emissiveMap===void 0?null:e.emissiveMap,t.bumpMap=e.bumpMap===void 0?null:e.bumpMap,t.bumpScale=1,t.normalMap=e.normalMap===void 0?null:e.normalMap,t.normalMapType=Qi,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=e.specularMap===void 0?null:e.specularMap,t.specular=e.specular,t.glossinessMap=e.glossinessMap===void 0?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=e.envMap===void 0?null:e.envMap,t.envMapIntensity=1,t}}class VM{constructor(){this.name=ot.KHR_MESH_QUANTIZATION}}class Xm extends Gr{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let r=0;r!==i;r++)t[r]=n[s+r];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=o*2,l=o*3,u=i-t,h=(n-t)/u,f=h*h,d=f*h,p=e*l,m=p-l,g=-2*d+3*f,x=d-f,y=1-g,b=x-f+h;for(let v=0;v!==o;v++){const M=r[m+v+o],T=r[m+v+c]*u,C=r[p+v+o],_=r[p+v]*u;s[v]=y*M+b*T+g*C+x*_}return s}}const HM=new Ft;class WM extends Xm{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return HM.fromArray(s).normalize().toArray(s),s}}const pi={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},ko={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},td={9728:Bt,9729:Rt,9984:bo,9985:gc,9986:wo,9987:si},nd={33071:jt,33648:_r,10497:cn},id={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},vu={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},zi={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},qM={CUBICSPLINE:void 0,LINEAR:Cs,STEP:wr},Sl={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function XM(a){return a.DefaultMaterial===void 0&&(a.DefaultMaterial=new Us({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:vi})),a.DefaultMaterial}function lo(a,e,t){for(const n in t.extensions)a[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function ms(a,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(a.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function jM(a,e,t){let n=!1,i=!1,s=!1;for(let l=0,u=e.length;l0||a.search(/^data\:image\/jpeg/)===0?"image/jpeg":a.search(/\.webp($|\?)/i)>0||a.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}class JM{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new SM,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};const n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,i=navigator.userAgent.indexOf("Firefox")>-1,s=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1;typeof createImageBitmap=="undefined"||n||i&&s<98?this.textureLoader=new ks(this.options.manager):this.textureLoader=new nm(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Kt(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(r){const o={scene:r[0][i.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:i.asset,parser:n,userData:{}};lo(s,o,i),ms(o,i),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(o)})).then(function(){e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i{const c=this.associations.get(r);c!=null&&this.associations.set(o,c);for(const[l,u]of r.children.entries())s(u,o.children[l])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&g.setY(E,T[C*c+1]),c>=3&&g.setZ(E,T[C*c+2]),c>=4&&g.setW(E,T[C*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return g})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,r=t.images[s];let o=this.textureLoader;if(r.uri){const c=n.manager.getHandler(r.uri);c!==null&&(o=c)}return this.loadTextureImage(e,s,o)}loadTextureImage(e,t,n){const i=this,s=this.json,r=s.textures[e],o=s.images[t],c=(o.uri||o.bufferView)+":"+r.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(t,n).then(function(u){u.flipY=!1,r.name&&(u.name=r.name);const f=(s.samplers||{})[r.sampler]||{};return u.magFilter=td[f.magFilter]||Rt,u.minFilter=td[f.minFilter]||si,u.wrapS=nd[f.wrapS]||cn,u.wrapT=nd[f.wrapT]||cn,i.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const r=i.images[e],o=self.URL||self.webkitURL;let c=r.uri||"",l=!1;if(r.bufferView!==void 0)c=n.getDependency("bufferView",r.bufferView).then(function(h){l=!0;const f=new Blob([h],{type:r.mimeType});return c=o.createObjectURL(f),c});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(c).then(function(h){return new Promise(function(f,d){let p=f;t.isImageBitmapLoader===!0&&(p=function(m){const g=new At(m);g.needsUpdate=!0,f(g)}),t.load(tn.resolveURL(h,s.path),p,void 0,d)})}).then(function(h){return l===!0&&o.revokeObjectURL(c),h.userData.mimeType=r.mimeType||KM(r.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),h});return this.sourceCache[e]=u,u}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(r){if(n.texCoord!==void 0&&n.texCoord!=0&&!(t==="aoMap"&&n.texCoord==1)&&console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+t+" not yet supported."),s.extensions[ot.KHR_TEXTURE_TRANSFORM]){const o=n.extensions!==void 0?n.extensions[ot.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const c=s.associations.get(r);r=s.extensions[ot.KHR_TEXTURE_TRANSFORM].extendTexture(r,o),s.associations.set(r,c)}}return i!==void 0&&(r.encoding=i),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+n.uuid;let c=this.cache.get(o);c||(c=new Hi,Gt.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(o,c)),n=c}else if(e.isLine){const o="LineBasicMaterial:"+n.uuid;let c=this.cache.get(o);c||(c=new Vt,Gt.prototype.copy.call(c,n),c.color.copy(n.color),this.cache.add(o,c)),n=c}if(i||s||r){let o="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(o+="specular-glossiness:"),i&&(o+="derivative-tangents:"),s&&(o+="vertex-colors:"),r&&(o+="flat-shading:");let c=this.cache.get(o);c||(c=n.clone(),s&&(c.vertexColors=!0),r&&(c.flatShading=!0),i&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(o,c),this.associations.set(c,this.associations.get(n))),n=c}n.aoMap&&t.attributes.uv2===void 0&&t.attributes.uv!==void 0&&t.setAttribute("uv2",t.attributes.uv),e.material=n}getMaterialType(){return Us}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let r;const o={},c=s.extensions||{},l=[];if(c[ot.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const h=i[ot.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];r=h.getMaterialType(),l.push(h.extendParams(o,s,t))}else if(c[ot.KHR_MATERIALS_UNLIT]){const h=i[ot.KHR_MATERIALS_UNLIT];r=h.getMaterialType(),l.push(h.extendParams(o,s,t))}else{const h=s.pbrMetallicRoughness||{};if(o.color=new be(1,1,1),o.opacity=1,Array.isArray(h.baseColorFactor)){const f=h.baseColorFactor;o.color.fromArray(f),o.opacity=f[3]}h.baseColorTexture!==void 0&&l.push(t.assignTexture(o,"map",h.baseColorTexture,nt)),o.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,o.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(o,"metalnessMap",h.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",h.metallicRoughnessTexture))),r=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,o)})))}s.doubleSided===!0&&(o.side=_i);const u=s.alphaMode||Sl.OPAQUE;if(u===Sl.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,u===Sl.MASK&&(o.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&r!==un&&(l.push(t.assignTexture(o,"normalMap",s.normalTexture)),o.normalScale=new de(1,1),s.normalTexture.scale!==void 0)){const h=s.normalTexture.scale;o.normalScale.set(h,h)}return s.occlusionTexture!==void 0&&r!==un&&(l.push(t.assignTexture(o,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&r!==un&&(o.emissive=new be().fromArray(s.emissiveFactor)),s.emissiveTexture!==void 0&&r!==un&&l.push(t.assignTexture(o,"emissiveMap",s.emissiveTexture,nt)),Promise.all(l).then(function(){let h;return r===xu?h=i[ot.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(o):h=new r(o),s.name&&(h.name=s.name),ms(h,s),t.associations.set(h,{materials:e}),s.extensions&&lo(i,h,s),h})}createUniqueName(e){const t=st.sanitizeNodeName(e||"");let n=t;for(let i=1;this.nodeNamesUsed[n];++i)n=t+"_"+i;return this.nodeNamesUsed[n]=!0,n}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(o){return n[ot.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(c){return rd(c,o,t)})}const r=[];for(let o=0,c=e.length;o0&&YM(x,s),x.name=t.createUniqueName(s.name||"mesh_"+e),ms(x,s),g.extensions&&lo(i,x,g),t.assignFinalMaterial(x),h.push(x)}for(let d=0,p=h.length;d1?c=new yn:o.length===1?c=o[0]:c=new ut,c!==o[0])for(let l=0,u=o.length;l{const h=new Map;for(const[f,d]of s.associations)(f instanceof Gt||f instanceof At)&&h.set(f,d);return u.traverse(f=>{const d=s.associations.get(f);d!=null&&h.set(f,d)}),h};return s.associations=l(r),r})}}function jm(a,e,t,n){const i=t.nodes[a];return n.getDependency("node",a).then(function(s){if(i.skin===void 0)return s;let r;return n.getDependency("skin",i.skin).then(function(o){r=o;const c=[];for(let l=0,u=r.joints.length;l0?s[s.length-1]:"",smooth:r!==void 0?r.smooth:this.smooth,groupStart:r!==void 0?r.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(c){const l={index:typeof c=="number"?c:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return l.clone=this.clone.bind(l),l}};return this.materials.push(o),o},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(i){const s=this.currentMaterial();if(s&&s.groupEnd===-1&&(s.groupEnd=this.geometry.vertices.length/3,s.groupCount=s.groupEnd-s.groupStart,s.inherited=!1),i&&this.materials.length>1)for(let r=this.materials.length-1;r>=0;r--)this.materials[r].groupCount<=0&&this.materials.splice(r,1);return i&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),s}},n&&n.name&&typeof n.clone=="function"){const i=n.clone(0);i.inherited=!0,this.object.materials.push(i)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){const i=this.vertices,s=this.object.geometry.vertices;s.push(i[e+0],i[e+1],i[e+2]),s.push(i[t+0],i[t+1],i[t+2]),s.push(i[n+0],i[n+1],i[n+2])},addVertexPoint:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){const i=this.normals,s=this.object.geometry.normals;s.push(i[e+0],i[e+1],i[e+2]),s.push(i[t+0],i[t+1],i[t+2]),s.push(i[n+0],i[n+1],i[n+2])},addFaceNormal:function(e,t,n){const i=this.vertices,s=this.object.geometry.normals;cd.fromArray(i,e),Tl.fromArray(i,t),ld.fromArray(i,n),En.subVectors(ld,Tl),ud.subVectors(cd,Tl),En.cross(ud),En.normalize(),s.push(En.x,En.y,En.z),s.push(En.x,En.y,En.z),s.push(En.x,En.y,En.z)},addColor:function(e,t,n){const i=this.colors,s=this.object.geometry.colors;i[e]!==void 0&&s.push(i[e+0],i[e+1],i[e+2]),i[t]!==void 0&&s.push(i[t+0],i[t+1],i[t+2]),i[n]!==void 0&&s.push(i[n+0],i[n+1],i[n+2])},addUV:function(e,t,n){const i=this.uvs,s=this.object.geometry.uvs;s.push(i[e+0],i[e+1]),s.push(i[t+0],i[t+1]),s.push(i[n+0],i[n+1])},addDefaultUV:function(){const e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){const t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,i,s,r,o,c,l){const u=this.vertices.length;let h=this.parseVertexIndex(e,u),f=this.parseVertexIndex(t,u),d=this.parseVertexIndex(n,u);if(this.addVertex(h,f,d),this.addColor(h,f,d),o!==void 0&&o!==""){const p=this.normals.length;h=this.parseNormalIndex(o,p),f=this.parseNormalIndex(c,p),d=this.parseNormalIndex(l,p),this.addNormal(h,f,d)}else this.addFaceNormal(h,f,d);if(i!==void 0&&i!==""){const p=this.uvs.length;h=this.parseUVIndex(i,p),f=this.parseUVIndex(s,p),d=this.parseUVIndex(r,p),this.addUV(h,f,d),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";const t=this.vertices.length;for(let n=0,i=e.length;n=7?(qa.setRGB(parseFloat(h[4]),parseFloat(h[5]),parseFloat(h[6])).convertSRGBToLinear(),t.colors.push(qa.r,qa.g,qa.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3]));break;case"vt":t.uvs.push(parseFloat(h[1]),parseFloat(h[2]));break}}else if(u==="f"){const f=l.slice(1).trim().split(od),d=[];for(let m=0,g=f.length;m0){const y=x.split("/");d.push(y)}}const p=d[0];for(let m=1,g=d.length-1;m1){const f=i[1].trim().toLowerCase();t.object.smooth=f!=="0"&&f!=="off"}else t.object.smooth=!0;const h=t.object.currentMaterial();h&&(h.smooth=t.object.smooth)}else{if(l==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+l+'"')}}t.finalize();const s=new yn;if(s.materialLibraries=[].concat(t.materialLibraries),!(t.objects.length===1&&t.objects[0].geometry.vertices.length===0)===!0)for(let o=0,c=t.objects.length;o0&&m.setAttribute("normal",new we(u.normals,3)),u.colors.length>0&&(p=!0,m.setAttribute("color",new we(u.colors,3))),u.hasUVIndices===!0&&m.setAttribute("uv",new we(u.uvs,2));const g=[];for(let y=0,b=h.length;y1){for(let y=0,b=h.length;y0){const o=new Hi({size:1,sizeAttenuation:!1}),c=new Xe;c.setAttribute("position",new we(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(c.setAttribute("color",new we(t.colors,3)),o.vertexColors=!0);const l=new xr(c,o);s.add(l)}return s}}class r1 extends Yp{constructor(e){super(e)}parse(e,t){const n={mipmaps:[],width:0,height:0,format:null,mipmapCount:1},i=542327876,s=131072,r=512,o=1024,c=2048,l=4096,u=8192,h=16384,f=32768;function d(se){return se.charCodeAt(0)+(se.charCodeAt(1)<<8)+(se.charCodeAt(2)<<16)+(se.charCodeAt(3)<<24)}function p(se){return String.fromCharCode(se&255,se>>8&255,se>>16&255,se>>24&255)}function m(se,V,me,_e){const Ie=me*_e*4,ye=new Uint8Array(se,V,Ie),He=new Uint8Array(Ie);let le=0,ce=0;for(let xe=0;xe<_e;xe++)for(let Fe=0;Fe>1,1),me=Math.max(me>>1,1)}}return n}}class o1{constructor(e,t,n){const i=this;let s=!1,r=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,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 c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,h){return l.push(u,h),this},this.removeHandler=function(u){const h=l.indexOf(u);return h!==-1&&l.splice(h,2),this},this.getHandler=function(u){for(let h=0,f=l.length;h=p.elements[v].count&&(v++,S=0);const _=i(p.elements[v].properties,R);o(m,p.elements[v].name,_),S++}return r(m)}function r(d){let p=new Xe;return d.indices.length>0&&p.setIndex(d.indices),p.setAttribute("position",new we(d.vertices,3)),d.normals.length>0&&p.setAttribute("normal",new we(d.normals,3)),d.uvs.length>0&&p.setAttribute("uv",new we(d.uvs,2)),d.colors.length>0&&p.setAttribute("color",new we(d.colors,3)),d.faceVertexUvs.length>0&&(p=p.toNonIndexed(),p.setAttribute("uv",new we(d.faceVertexUvs,2))),p.computeBoundingSphere(),p}function o(d,p,m){function g(W){for(let K=0,z=W.length;K>5&31)/31,p=(q>>10&31)/31):(f=x,d=y,p=b)}for(let q=1;q<=3;q++){const O=B+q*12,Y=N*3*3+(q-1)*3;_[Y]=u.getFloat32(O,!0),_[Y+1]=u.getFloat32(O+4,!0),_[Y+2]=u.getFloat32(O+8,!0),L[Y]=W,L[Y+1]=K,L[Y+2]=z,m&&(g[Y]=f,g[Y+1]=d,g[Y+2]=p)}}return R.setAttribute("position",new pt(_,3)),R.setAttribute("normal",new pt(L,3)),m&&(R.setAttribute("color",new pt(g,3)),R.hasColors=!0,R.alpha=v),R}function s(l){const u=new Xe,h=/solid([\s\S]*?)endsolid/g,f=/facet([\s\S]*?)endfacet/g;let d=0;const p=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,m=new RegExp("vertex"+p+p+p,"g"),g=new RegExp("normal"+p+p+p,"g"),x=[],y=[],b=new D;let v,S=0,A=0,R=0;for(;(v=h.exec(l))!==null;){A=R;const _=v[0];for(;(v=f.exec(_))!==null;){let B=0,W=0;const K=v[0];for(;(v=g.exec(K))!==null;)b.x=parseFloat(v[1]),b.y=parseFloat(v[2]),b.z=parseFloat(v[3]),W++;for(;(v=m.exec(K))!==null;)x.push(parseFloat(v[1]),parseFloat(v[2]),parseFloat(v[3])),y.push(b.x,b.y,b.z),B++,R++;W!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+d),B!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+d),d++}const L=A,N=R-A;u.addGroup(L,N,S),S++}return u.setAttribute("position",new we(x,3)),u.setAttribute("normal",new we(y,3)),u}function r(l){return typeof l!="string"?tn.decodeText(new Uint8Array(l)):l}function o(l){if(typeof l=="string"){const u=new Uint8Array(l.length);for(let h=0;h=0?l.substring(0,u):l;h=h.toLowerCase();let f=u>=0?l.substring(u+1):"";if(f=f.trim(),h==="newmtl")i={name:f},r[f]=i;else if(h==="ka"||h==="kd"||h==="ks"||h==="ke"){const d=f.split(s,3);i[h]=[parseFloat(d[0]),parseFloat(d[1]),parseFloat(d[2])]}else i[h]=f}const o=new u1(this.resourcePath||t,this.materialOptions);return o.setCrossOrigin(this.crossOrigin),o.setManager(this.manager),o.setMaterials(r),o}}class u1{constructor(e="",t={}){this.baseUrl=e,this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.crossOrigin="anonymous",this.side=this.options.side!==void 0?this.options.side:vi,this.wrap=this.options.wrap!==void 0?this.options.wrap:cn}setCrossOrigin(e){return this.crossOrigin=e,this}setManager(e){this.manager=e}setMaterials(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}}convert(e){if(!this.options)return e;const t={};for(const n in e){const i=e[n],s={};t[n]=s;for(const r in i){let o=!0,c=i[r];const l=r.toLowerCase();switch(l){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(c=[c[0]/255,c[1]/255,c[2]/255]),this.options&&this.options.ignoreZeroRGBs&&c[0]===0&&c[1]===0&&c[2]===0&&(o=!1);break}o&&(s[l]=c)}}return t}preload(){for(const e in this.materialsInfo)this.create(e)}getIndex(e){return this.nameLookup[e]}getAsArray(){let e=0;for(const t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray}create(e){return this.materials[e]===void 0&&this.createMaterial_(e),this.materials[e]}createMaterial_(e){const t=this,n=this.materialsInfo[e],i={name:e,side:this.side};function s(o,c){return typeof c!="string"||c===""?"":/^https?:\/\//i.test(c)?c:o+c}function r(o,c){if(i[o])return;const l=t.getTextureParams(c,i),u=t.loadTexture(s(t.baseUrl,l.url));u.repeat.copy(l.scale),u.offset.copy(l.offset),u.wrapS=t.wrap,u.wrapT=t.wrap,(o==="map"||o==="emissiveMap")&&(u.encoding=tt),i[o]=u}for(const o in n){const c=n[o];let l;if(c!=="")switch(o.toLowerCase()){case"kd":i.color=new ve().fromArray(c).convertSRGBToLinear();break;case"ks":i.specular=new ve().fromArray(c).convertSRGBToLinear();break;case"ke":i.emissive=new ve().fromArray(c).convertSRGBToLinear();break;case"map_kd":r("map",c);break;case"map_ks":r("specularMap",c);break;case"map_ke":r("emissiveMap",c);break;case"norm":r("normalMap",c);break;case"map_bump":case"bump":r("bumpMap",c);break;case"map_d":r("alphaMap",c),i.transparent=!0;break;case"ns":i.shininess=parseFloat(c);break;case"d":l=parseFloat(c),l<1&&(i.opacity=l,i.transparent=!0);break;case"tr":l=parseFloat(c),this.options&&this.options.invertTrProperty&&(l=1-l),l>0&&(i.opacity=1-l,i.transparent=!0);break}}return this.materials[e]=new Qn(i),this.materials[e]}getTextureParams(e,t){const n={scale:new fe(1,1),offset:new fe(0,0)},i=e.split(/\s+/);let s;return s=i.indexOf("-bm"),s>=0&&(t.bumpScale=parseFloat(i[s+1]),i.splice(s,2)),s=i.indexOf("-s"),s>=0&&(n.scale.set(parseFloat(i[s+1]),parseFloat(i[s+2])),i.splice(s,4)),s=i.indexOf("-o"),s>=0&&(n.offset.set(parseFloat(i[s+1]),parseFloat(i[s+2])),i.splice(s,4)),n.url=i.join(" ").trim(),n}loadTexture(e,t,n,i,s){const r=this.manager!==void 0?this.manager:ju;let o=r.getHandler(e);o===null&&(o=new ks(r)),o.setCrossOrigin&&o.setCrossOrigin(this.crossOrigin);const c=o.load(e,n,i,s);return t!==void 0&&(c.mapping=t),c}}const Tl=new WeakMap;class h1 extends Ht{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const s=new Kt(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,r=>{const o={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(r,o).then(t).catch(i)},n,i)}decodeDracoFile(e,t,n,i){const s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(const c in t.attributeTypes){const l=t.attributeTypes[c];l.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[c]=l.name)}const n=JSON.stringify(t);if(Tl.has(e)){const c=Tl.get(e);if(c.key===n)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const s=this.workerNextTaskID++,r=e.byteLength,o=this._getWorker(s,r).then(c=>(i=c,new Promise((l,u)=>{i._callbacks[s]={resolve:l,reject:u},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return o.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),Tl.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new Xe;e.index&&t.setIndex(new pt(e.index.array,1));for(let n=0;n{n.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const s=f1.toString(),r=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(` -`);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.lengths._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e{const h=u.draco,f=new h.Decoder,d=new h.DecoderBuffer;d.Init(new Int8Array(c),c.byteLength);try{const p=t(h,f,d,l),m=p.attributes.map(g=>g.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:o.id,error:p.message})}finally{h.destroy(d),h.destroy(f)}});break}};function t(r,o,c,l){const u=l.attributeIDs,h=l.attributeTypes;let f,d;const p=o.GetEncodedGeometryType(c);if(p===r.TRIANGULAR_MESH)f=new r.Mesh,d=o.DecodeBufferToMesh(c,f);else if(p===r.POINT_CLOUD)f=new r.PointCloud,d=o.DecodeBufferToPointCloud(c,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!d.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+d.error_msg());const m={index:null,attributes:[]};for(const g in u){const x=self[h[g]];let y,b;if(l.useUniqueIDs)b=u[g],y=o.GetAttributeByUniqueId(f,b);else{if(b=o.GetAttributeId(f,r[u[g]]),b===-1)continue;y=o.GetAttribute(f,b)}m.attributes.push(i(r,o,f,g,x,y))}return p===r.TRIANGULAR_MESH&&(m.index=n(r,o,f)),r.destroy(f),m}function n(r,o,c){const u=c.num_faces()*3,h=u*4,f=r._malloc(h);o.GetTrianglesUInt32Array(c,h,f);const d=new Uint32Array(r.HEAPF32.buffer,f,u).slice();return r._free(f),{array:d,itemSize:1}}function i(r,o,c,l,u,h){const f=h.num_components(),p=c.num_points()*f,m=p*u.BYTES_PER_ELEMENT,g=s(r,u),x=r._malloc(m);o.GetAttributeDataArrayForAllPoints(c,h,g,m,x);const y=new u(r.HEAPF32.buffer,x,p).slice();return r._free(x),{name:l,array:y,itemSize:f}}function s(r,o){switch(o){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32}}}const hc=new Ei,Kn=new o1;Kn.addHandler(/\.dds$/i,new r1);Kn.addHandler(/\.tga$/i,new gu);function d1(a){return hc.setFromObject(a),hc.getSize(new D)}function p1(a){return hc.setFromObject(a),hc.getCenter(new D)}function m1(a){const e=a.split(".");if(e.length<=1)return"";{let t=e.pop();return t=t.toLowerCase(),t}}function g1(a,e,t,n){let i;e?i=e:i=m1(a),i==="glb"&&(i="gltf");let s={loader:null,getObject:null};switch(i){case"dae":s={loader:new wM(Kn),getObject:r=>r.scene};break;case"fbx":s={loader:new uM(Kn)};break;case"gltf":s={loader:new MM(Kn),getObject:r=>r.scene},x1(t,s,n);break;case"obj":s={loader:new s1(Kn)};break;case"ply":s={loader:new a1(Kn),getObject:r=>(r.computeVertexNormals(),new Tt(r,new Us))};break;case"stl":s={loader:new c1(Kn),getObject:r=>new Tt(r,new Qn)};break;case"json":s={loader:new em(Kn)};break}return s}function y1(){return new l1(Kn)}function x1(a,e,t){if(a){const n=new h1;n.setDecoderPath(t||"assets/draco/gltf/"),n.setDecoderConfig({type:"js"}),e.loader.setDRACOLoader(n)}}var v1=(a,e)=>{const t=a.__vccOpts||a;for(const[n,i]of e)t[n]=i;return t};const _1=kt.defineComponent({name:"vue3dLoader"}),b1=kt.defineComponent({..._1,props:{filePath:null,fileType:null,width:null,height:null,position:null,rotation:null,scale:null,lights:{default:()=>[{type:"AmbientLight",color:11184810},{type:"DirectionalLight",position:{x:1,y:1,z:1},color:16777215,intensity:.8}]},cameraPosition:{default:()=>({x:0,y:0,z:0})},cameraRotation:null,cameraUp:null,cameraLookAt:null,backgroundColor:{default:()=>16777215},backgroundAlpha:{default:()=>1},controlsOptions:null,crossOrigin:{default:"anonymous"},requestHeader:null,outputEncoding:{default:()=>"linear"},webGLRendererOptions:{default:()=>({})},mtlPath:{default:""},showFps:{type:Boolean,default:!1},textureImage:{default:""},clearScene:{type:Boolean,default:!1},parallelLoad:{type:Boolean,default:!1},labels:{default:()=>[]},autoPlay:{type:Boolean,default:!0},enableDraco:{type:Boolean,default:!1},dracoDir:null,intersectRecursive:{type:Boolean,default:!1},enableDamping:{type:Boolean},dampingFactor:null},emits:["mousedown","mousemove","mouseup","click","dblclick","load","process","error"],setup(a,{emit:e}){const t=a;let n=null;const i=new rm,s=new fe,r=new Dt(45,1,1,1e5),o=new Tc,c=new Ju;let l=new lt,u=null,h={},f=[],d=null,p=0,m=null,g=null,x=null;const y=kt.ref({width:t.width||0,height:t.height||0}),b=kt.ref(0),v=kt.ref(!1),S=kt.ref(!1),A=kt.ref(null),R=kt.ref(null);kt.watch([()=>t.filePath,()=>t.fileType,()=>t.clearScene,()=>t.backgroundAlpha,()=>t.backgroundColor],E=>{(E[0]||E[1])&&ne(),E[2]&&xe(),(E[3]||E[4])&&H()}),kt.watch([()=>t.rotation,()=>t.position,()=>t.scale,()=>t.lights],E=>{const w=["rotation","position","scale"];E.forEach((U,Z)=>{Z<3&&U?Fe(w[Z],U):te()})},{deep:!0}),kt.watch([()=>y],()=>{X(!0),H()},{deep:!0}),kt.watch([()=>t.controlsOptions],()=>{J()},{deep:!0}),kt.watch([()=>t.cameraRotation,()=>t.cameraPosition],()=>{X()},{deep:!0}),kt.watch([()=>t.autoPlay],()=>{ot()}),kt.onMounted(()=>{const{filePath:E,outputEncoding:w,webGLRendererOptions:U,showFps:Z,enableDamping:Q,dampingFactor:de}=t;E&&typeof E=="object"&&(S.value=!0);const Le=A.value;_(Le),N();const ue=Object.assign({},{antialias:!0,alpha:!0},U,{canvas:R.value});u=new Du(ue),u.shadowMap.enabled=!0;const ge=w==="linear"?bi:tt;u.outputEncoding=ge,h=new kw(r,Le),Q&&(h.enableDamping=!0,de!=null&&(h.dampingFactor=de)),o.add(l),ne(),Y(),L(!0),Le.addEventListener("mousedown",B,!1),Le.addEventListener("mouseup",K,!1),Le.addEventListener("click",z,!1),Le.addEventListener("dblclick",q,!1),window.addEventListener("resize",N,!1),Z&&(m=xo(),Le.appendChild(m.dom)),Ie()}),kt.onBeforeUnmount(()=>{cancelAnimationFrame(p),u.dispose(),h&&h.dispose();const E=A.value;E.removeEventListener("mousedown",B,!1),E.removeEventListener("mousemove",W,!1),E.removeEventListener("mouseup",K,!1),E.removeEventListener("click",z,!1),E.removeEventListener("dblclick",q,!1),window.removeEventListener("resize",N,!1),n=null,l=null});function _(E){const{width:w,height:U}=t;w&&(E.style.width=`${w}px`),U&&(E.style.height=`${U}px`)}function L(E){const w=A.value;E?w.addEventListener("mousemove",W,!1):w.removeEventListener("mousemove",W,!1)}function N(){const{width:E,height:w}=t;(!E||!w)&&kt.nextTick(()=>{const U=A.value;y.value={width:E||U.offsetWidth,height:w||U.offsetHeight}})}function B(E){L(!1);const w=O(E.clientX,E.clientY);e("mousedown",E,w)}function W(E){const w=O(E.clientX,E.clientY);e("mousemove",E,w)}function K(E){const w=O(E.clientX,E.clientY);e("mouseup",E,w),L(!0)}function z(E){const w=O(E.clientX,E.clientY);e("click",E,w)}function q(E){const w=O(E.clientX,E.clientY);e("dblclick",E,w)}function O(E,w){const U=Me();if(!U||!A.value)return null;const Z=A.value.getBoundingClientRect();E-=Z.left,w-=Z.top,s.x=E/y.value.width*2-1,s.y=-(w/y.value.height)*2+1,i.setFromCamera(s,r);const Q=i.intersectObject(U,t.intersectRecursive);return(Q&&Q.length)>0?Q[0]:null}function Y(){H(),X(),te(),J()}function j(){if(!n)return;const E=S.value?ut(n):null,{position:w,rotation:U,scale:Z}=t;w&&(w instanceof Array?E!=null?n.position.set(w[E].x,w[E].y,w[E].z):n.position.set(0,0,0):n.position.set(w.x,w.y,w.z)),U&&(U instanceof Array?E!=null?n.rotation.set(U[E].x,U[E].y,U[E].z):n.rotation.set(0,0,0):n.rotation.set(U.x,U.y,U.z)),Z&&(Z instanceof Array?E!=null?n.scale.set(Z[E].x,Z[E].y,Z[E].z):n.scale.set(0,0,0):n.scale.set(Z.x,Z.y,Z.z))}function H(){const{backgroundColor:E,backgroundAlpha:w}=t;u.setSize(y.value.width,y.value.height),u.setPixelRatio(window.devicePixelRatio||1),u.setClearColor(new ve(E).getHex()),u.setClearAlpha(w)}function X(E){const{cameraPosition:w,cameraRotation:U,cameraUp:Z,cameraLookAt:Q}=t;if(r.aspect=y.value.width/y.value.height,r.updateProjectionMatrix(),!E)if(!Q||!Z){if(!n)return;const de=d1(n).length();r.position.set(w.x,w.y,w.z),U&&r.rotation.set(U.x,U.y,U.z),w.x===0&&w.y===0&&w.z===0&&(r.position.z=de),r.lookAt(new D)}else r.position.set(w.x,w.y,w.z),U&&r.rotation.set(U.x,U.y,U.z),r.up.set(Z.x,Z.y,Z.z),r.lookAt(new D(Q.x,Q.y,Q.z))}function te(){const{lights:E}=t;o.remove(...f),f=[],E.forEach(w=>{if(!w.type)return;const U=w.type.toLowerCase();let Z=null;if(U==="ambient"||U==="ambientlight"){const Q=w.color===0?w.color:w.color||4210752,de=w.intensity===0?w.intensity:w.intensity||1;Z=new Wo(Q,de)}if(U==="point"||U==="pointlight"){const Q=w.color===0?w.color:w.color||16777215,de=w.intensity===0?w.intensity:w.intensity||1,Le=w.distance||0,F=w.decay===0?w.decay:w.decay||1;Z=new Os(Q,de,Le,F),w.position&&Z.position.copy(w.position)}if(U==="directional"||U==="directionallight"){const Q=w.color===0?w.color:w.color||16777215,de=w.intensity===0?w.intensity:w.intensity||1;Z=new Vr(Q,de),w.position&&Z.position.copy(w.position),w.target&&Z.target.copy(w.target)}if(U==="hemisphere"||U==="hemispherelight"){const Q=w.skyColor===0?w.skyColor:w.skyColor||16777215,de=w.groundColor===0?w.groundColor:w.groundColor||16777215,Le=w.intensity===0?w.intensity:w.intensity||1;Z=new Yu(Q,de,Le),w.position&&Z.position.copy(w.position)}Z&&(f.push(Z),o.add(Z))})}function J(){const{controlsOptions:E}=t;E&&Object.assign(h,E)}function ne(){const{filePath:E,parallelLoad:w}=t;w&&S?E.forEach((U,Z)=>{re(Z)}):re()}function re(E){const{filePath:w,fileType:U,crossOrigin:Z,requestHeader:Q,mtlPath:de,enableDraco:Le,dracoDir:F}=t;if(!w)return;const ue=E||b.value,ge=S.value?w[ue]:w,Ee=typeof U=="string"?U:U?U[ue]:"",Se=g1(ge,Ee,Le,F);d=Se.loader;const Oe=Se.getObject?Se.getObject:me;if(n&&ue===0&&l.remove(n),Q&&d.setRequestHeader(Q),Z&&d.setCrossOrigin(Z),de)if(!(typeof de=="object"))V(ge,Oe,ue);else{if(!de[ue]){se(ge,Oe,ue);return}V(ge,Oe,ue)}else se(ge,Oe,ue)}function se(E,w,U){const{textureImage:Z,parallelLoad:Q}=t;d.load(E,(...de)=>{if(n=w(...de),_e(n,E),Z){const F=typeof Z=="string"?Z:Z[U];F&&ce(n,F)}Ye(),e("load",l)},de=>{Q||le(de);const Le=b.value+1;e("process",de,Le)},de=>{e("error",de)})}function V(E,w,U){const{crossOrigin:Z,requestHeader:Q,mtlPath:de}=t,Le=y1();Z&&Le.setCrossOrigin(Z),Q&&Le.setRequestHeader(Q);const F=typeof de=="string"?de:de[U],ue=/^(.*\/)([^/]*)$/.exec(F),ge=ue[1],Ee=ue[2];Le.setPath(ge).load(Ee,Se=>{Se.preload(),d.setMaterials(Se),se(E,w,U)})}function me(E){return E}function _e(E,w){const U=p1(n);v.value||(l.position.copy(U.negate()),v.value=!0),n=E;let Z=w.split("/");Z=Z[Z.length-1],n.fileName=Z,l.add(n),X(),j(),ot()}function Ie(){p=requestAnimationFrame(Ie),He();const E=c.getDelta();g&&g.update(E),ye()}function ye(){u.render(o,r)}function He(){const{showFps:E}=t;E&&m.update()}function le(E){const{filePath:w}=t;Math.floor(E.loaded/E.total*100)===100&&(S.value&&w.length>b.value?kt.nextTick(()=>{if(b.value++,b.value===w.length){b.value=0;return}re()}):b.value=0)}function ce(E,w){x||(x=new ks),E.traverse(U=>{U.isMesh&&x.load(w,Z=>{U.material.map=Z,U.material.needsUpdate=!0},()=>{},Z=>{e("error",Z)})})}function xe(){l.clear()}function Fe(E,w){const U=Me();if(!!U){if(S.value){U.children.forEach(Z=>{const Q=ut(Z),de=E==="scale"?1:0;w[Q]?Z[E].set(w[Q].x,w[Q].y,w[Q].z):Z[E].set(de,de,de)});return}U[E].set(w.x,w.y,w.z)}}function Me(){return S.value?l:n}function Ye(){const{filePath:E}=t;S.value?b.value===E.length&&Ue():Ue()}function Ue(){const{labels:E}=t;if(!E)return;const w=S.value?l:n,U=Q=>(x||(x=new ks),x.load(Q)),Z=(Q,de)=>{const Le=ze(Q,de),F=new At(Le);return F.needsUpdate=!0,F};E.forEach(Q=>{const de=Q.image?U(Q.image):Z(Q.text,Q.textStyle||{}),Le=new Ac({map:de,color:Q.spriteMaterialColor||16777215}),F=new Fu(Le);Q.scale?F.scale.set(Q.scale.x||1,Q.scale.y||1,Q.scale.z||0):F.scale.set(1,1,0),Q.position&&F.position.set(Q.position.x,Q.position.y,Q.position.z),Q.sid&&(F.sid=Q.sid),w.add(F)})}function ze(E,w){const U=(qe,$e,G,Te,oe,Ce)=>{qe.beginPath(),qe.moveTo($e+Ce,G),qe.lineTo($e+Te-Ce,G),qe.quadraticCurveTo($e+Te,G,$e+Te,G+Ce),qe.lineTo($e+Te,G+oe-Ce),qe.quadraticCurveTo($e+Te,G+oe,$e+Te-Ce,G+oe),qe.lineTo($e+Ce,G+oe),qe.quadraticCurveTo($e,G+oe,$e,G+oe-Ce),qe.lineTo($e,G+Ce),qe.quadraticCurveTo($e,G,$e+Ce,G),qe.closePath(),qe.fill(),qe.stroke()},Z=w.fontFamily||"Arial",Q=w.fontSize===0||w.fontSize?w.fontSize:18,de=w.color||"#ffffff",Le=w.fontWeight||"normal",F=w.borderWidth===0||w.borderWidth?w.borderWidth:4,ue=w.borderColor||"rgba(0,0,0,1)",ge=w.borderRadius===0||w.borderRadius?w.borderRadius:4,Ee=w.backgroundColor||"rgba(255, 255, 255, 1)",Se=document.createElement("canvas"),Oe=Se.getContext("2d");if(Oe){Oe.font=`${Le} ${Q}px ${Z}`;const $e=Oe.measureText(E).width;Oe.fillStyle=Ee,Oe.strokeStyle=ue,Oe.lineWidth=F,U(Oe,F/2,F/2,$e+F,Q*1.4+F,ge),Oe.fillStyle=de,Oe.fillText(E,F,Q+F)}return Se}function ut(E){const{filePath:w}=t;let U;return w instanceof Array&&(U=w.map((Z,Q)=>{if(Z.indexOf(E.fileName)>-1)return Q}).filter(Z=>Z!=null)[0]),U}function ot(){const{autoPlay:E}=t,w=Me();if(!w)return;const U=Z=>{g=new sm(w),Z.animations&&Z.animations.forEach(Q=>{if(Q){const de=g.clipAction(Q);E?de.play():de.stop()}})};if(S.value){w.children.forEach(Z=>{U(Z)});return}U(w)}return(E,w)=>(kt.openBlock(),kt.createElementBlock("div",{ref_key:"containerElement",ref:A,class:"viewer-container"},[kt.createElementVNode("canvas",{ref_key:"canvasElement",ref:R,class:"viewer-canvas"},null,512)],512))}});var fc=v1(b1,[["__scopeId","data-v-07257ca0"]]);const w1=a=>{a.component(fc.name,fc)};var M1={install:w1,vue3dLoader:fc};exports.Three=Nw;exports.default=M1;exports.vue3dLoader=fc; +`);let i=[];for(let o=0,c=n.length;o=7?(qa.setRGB(parseFloat(h[4]),parseFloat(h[5]),parseFloat(h[6])).convertSRGBToLinear(),t.colors.push(qa.r,qa.g,qa.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3]));break;case"vt":t.uvs.push(parseFloat(h[1]),parseFloat(h[2]));break}}else if(u==="f"){const f=l.slice(1).trim().split(ad),d=[];for(let m=0,g=f.length;m0){const y=x.split("/");d.push(y)}}const p=d[0];for(let m=1,g=d.length-1;m1){const f=i[1].trim().toLowerCase();t.object.smooth=f!=="0"&&f!=="off"}else t.object.smooth=!0;const h=t.object.currentMaterial();h&&(h.smooth=t.object.smooth)}else{if(l==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+l+'"')}}t.finalize();const s=new yn;if(s.materialLibraries=[].concat(t.materialLibraries),!(t.objects.length===1&&t.objects[0].geometry.vertices.length===0)===!0)for(let o=0,c=t.objects.length;o0&&m.setAttribute("normal",new Ae(u.normals,3)),u.colors.length>0&&(p=!0,m.setAttribute("color",new Ae(u.colors,3))),u.hasUVIndices===!0&&m.setAttribute("uv",new Ae(u.uvs,2));const g=[];for(let y=0,b=h.length;y1){for(let y=0,b=h.length;y0){const o=new Hi({size:1,sizeAttenuation:!1}),c=new qe;c.setAttribute("position",new Ae(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(c.setAttribute("color",new Ae(t.colors,3)),o.vertexColors=!0);const l=new xr(c,o);s.add(l)}return s}}class r1 extends Zp{constructor(e){super(e)}parse(e,t){const n={mipmaps:[],width:0,height:0,format:null,mipmapCount:1},i=542327876,s=131072,r=512,o=1024,c=2048,l=4096,u=8192,h=16384,f=32768;function d(oe){return oe.charCodeAt(0)+(oe.charCodeAt(1)<<8)+(oe.charCodeAt(2)<<16)+(oe.charCodeAt(3)<<24)}function p(oe){return String.fromCharCode(oe&255,oe>>8&255,oe>>16&255,oe>>24&255)}function m(oe,H,ye,we){const Pe=ye*we*4,xe=new Uint8Array(oe,H,Pe),Ve=new Uint8Array(Pe);let he=0,ue=0;for(let ve=0;ve>1,1),ye=Math.max(ye>>1,1)}}return n}}class o1{constructor(e,t,n){const i=this;let s=!1,r=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,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 c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,h){return l.push(u,h),this},this.removeHandler=function(u){const h=l.indexOf(u);return h!==-1&&l.splice(h,2),this},this.getHandler=function(u){for(let h=0,f=l.length;h=p.elements[v].count&&(v++,M=0);const _=i(p.elements[v].properties,C);o(m,p.elements[v].name,_),M++}return r(m)}function r(d){let p=new qe;return d.indices.length>0&&p.setIndex(d.indices),p.setAttribute("position",new Ae(d.vertices,3)),d.normals.length>0&&p.setAttribute("normal",new Ae(d.normals,3)),d.uvs.length>0&&p.setAttribute("uv",new Ae(d.uvs,2)),d.colors.length>0&&p.setAttribute("color",new Ae(d.colors,3)),d.faceVertexUvs.length>0&&(p=p.toNonIndexed(),p.setAttribute("uv",new Ae(d.faceVertexUvs,2))),p.computeBoundingSphere(),p}function o(d,p,m){function g(q){for(let J=0,G=q.length;J>5&31)/31,p=(X>>10&31)/31):(f=x,d=y,p=b)}for(let X=1;X<=3;X++){const B=U+X*12,Z=F*3*3+(X-1)*3;_[Z]=u.getFloat32(B,!0),_[Z+1]=u.getFloat32(B+4,!0),_[Z+2]=u.getFloat32(B+8,!0),E[Z]=q,E[Z+1]=J,E[Z+2]=G,m&&(g[Z]=f,g[Z+1]=d,g[Z+2]=p)}}return C.setAttribute("position",new pt(_,3)),C.setAttribute("normal",new pt(E,3)),m&&(C.setAttribute("color",new pt(g,3)),C.hasColors=!0,C.alpha=v),C}function s(l){const u=new qe,h=/solid([\s\S]*?)endsolid/g,f=/facet([\s\S]*?)endfacet/g;let d=0;const p=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,m=new RegExp("vertex"+p+p+p,"g"),g=new RegExp("normal"+p+p+p,"g"),x=[],y=[],b=new P;let v,M=0,T=0,C=0;for(;(v=h.exec(l))!==null;){T=C;const _=v[0];for(;(v=f.exec(_))!==null;){let U=0,q=0;const J=v[0];for(;(v=g.exec(J))!==null;)b.x=parseFloat(v[1]),b.y=parseFloat(v[2]),b.z=parseFloat(v[3]),q++;for(;(v=m.exec(J))!==null;)x.push(parseFloat(v[1]),parseFloat(v[2]),parseFloat(v[3])),y.push(b.x,b.y,b.z),U++,C++;q!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+d),U!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+d),d++}const E=T,F=C-T;u.addGroup(E,F,M),M++}return u.setAttribute("position",new Ae(x,3)),u.setAttribute("normal",new Ae(y,3)),u}function r(l){return typeof l!="string"?tn.decodeText(new Uint8Array(l)):l}function o(l){if(typeof l=="string"){const u=new Uint8Array(l.length);for(let h=0;h=0?l.substring(0,u):l;h=h.toLowerCase();let f=u>=0?l.substring(u+1):"";if(f=f.trim(),h==="newmtl")i={name:f},r[f]=i;else if(h==="ka"||h==="kd"||h==="ks"||h==="ke"){const d=f.split(s,3);i[h]=[parseFloat(d[0]),parseFloat(d[1]),parseFloat(d[2])]}else i[h]=f}const o=new u1(this.resourcePath||t,this.materialOptions);return o.setCrossOrigin(this.crossOrigin),o.setManager(this.manager),o.setMaterials(r),o}}class u1{constructor(e="",t={}){this.baseUrl=e,this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.crossOrigin="anonymous",this.side=this.options.side!==void 0?this.options.side:vi,this.wrap=this.options.wrap!==void 0?this.options.wrap:cn}setCrossOrigin(e){return this.crossOrigin=e,this}setManager(e){this.manager=e}setMaterials(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}}convert(e){if(!this.options)return e;const t={};for(const n in e){const i=e[n],s={};t[n]=s;for(const r in i){let o=!0,c=i[r];const l=r.toLowerCase();switch(l){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(c=[c[0]/255,c[1]/255,c[2]/255]),this.options&&this.options.ignoreZeroRGBs&&c[0]===0&&c[1]===0&&c[2]===0&&(o=!1);break}o&&(s[l]=c)}}return t}preload(){for(const e in this.materialsInfo)this.create(e)}getIndex(e){return this.nameLookup[e]}getAsArray(){let e=0;for(const t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray}create(e){return this.materials[e]===void 0&&this.createMaterial_(e),this.materials[e]}createMaterial_(e){const t=this,n=this.materialsInfo[e],i={name:e,side:this.side};function s(o,c){return typeof c!="string"||c===""?"":/^https?:\/\//i.test(c)?c:o+c}function r(o,c){if(i[o])return;const l=t.getTextureParams(c,i),u=t.loadTexture(s(t.baseUrl,l.url));u.repeat.copy(l.scale),u.offset.copy(l.offset),u.wrapS=t.wrap,u.wrapT=t.wrap,(o==="map"||o==="emissiveMap")&&(u.encoding=nt),i[o]=u}for(const o in n){const c=n[o];let l;if(c!=="")switch(o.toLowerCase()){case"kd":i.color=new be().fromArray(c).convertSRGBToLinear();break;case"ks":i.specular=new be().fromArray(c).convertSRGBToLinear();break;case"ke":i.emissive=new be().fromArray(c).convertSRGBToLinear();break;case"map_kd":r("map",c);break;case"map_ks":r("specularMap",c);break;case"map_ke":r("emissiveMap",c);break;case"norm":r("normalMap",c);break;case"map_bump":case"bump":r("bumpMap",c);break;case"map_d":r("alphaMap",c),i.transparent=!0;break;case"ns":i.shininess=parseFloat(c);break;case"d":l=parseFloat(c),l<1&&(i.opacity=l,i.transparent=!0);break;case"tr":l=parseFloat(c),this.options&&this.options.invertTrProperty&&(l=1-l),l>0&&(i.opacity=1-l,i.transparent=!0);break}}return this.materials[e]=new Qn(i),this.materials[e]}getTextureParams(e,t){const n={scale:new de(1,1),offset:new de(0,0)},i=e.split(/\s+/);let s;return s=i.indexOf("-bm"),s>=0&&(t.bumpScale=parseFloat(i[s+1]),i.splice(s,2)),s=i.indexOf("-s"),s>=0&&(n.scale.set(parseFloat(i[s+1]),parseFloat(i[s+2])),i.splice(s,4)),s=i.indexOf("-o"),s>=0&&(n.offset.set(parseFloat(i[s+1]),parseFloat(i[s+2])),i.splice(s,4)),n.url=i.join(" ").trim(),n}loadTexture(e,t,n,i,s){const r=this.manager!==void 0?this.manager:Yu;let o=r.getHandler(e);o===null&&(o=new ks(r)),o.setCrossOrigin&&o.setCrossOrigin(this.crossOrigin);const c=o.load(e,n,i,s);return t!==void 0&&(c.mapping=t),c}}const Al=new WeakMap;class h1 extends Ht{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const s=new Kt(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,r=>{const o={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(r,o).then(t).catch(i)},n,i)}decodeDracoFile(e,t,n,i){const s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(const c in t.attributeTypes){const l=t.attributeTypes[c];l.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[c]=l.name)}const n=JSON.stringify(t);if(Al.has(e)){const c=Al.get(e);if(c.key===n)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const s=this.workerNextTaskID++,r=e.byteLength,o=this._getWorker(s,r).then(c=>(i=c,new Promise((l,u)=>{i._callbacks[s]={resolve:l,reject:u},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return o.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),Al.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new qe;e.index&&t.setIndex(new pt(e.index.array,1));for(let n=0;n{n.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const s=f1.toString(),r=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(` +`);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.lengths._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e{const h=u.draco,f=new h.Decoder,d=new h.DecoderBuffer;d.Init(new Int8Array(c),c.byteLength);try{const p=t(h,f,d,l),m=p.attributes.map(g=>g.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:o.id,error:p.message})}finally{h.destroy(d),h.destroy(f)}});break}};function t(r,o,c,l){const u=l.attributeIDs,h=l.attributeTypes;let f,d;const p=o.GetEncodedGeometryType(c);if(p===r.TRIANGULAR_MESH)f=new r.Mesh,d=o.DecodeBufferToMesh(c,f);else if(p===r.POINT_CLOUD)f=new r.PointCloud,d=o.DecodeBufferToPointCloud(c,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!d.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+d.error_msg());const m={index:null,attributes:[]};for(const g in u){const x=self[h[g]];let y,b;if(l.useUniqueIDs)b=u[g],y=o.GetAttributeByUniqueId(f,b);else{if(b=o.GetAttributeId(f,r[u[g]]),b===-1)continue;y=o.GetAttribute(f,b)}m.attributes.push(i(r,o,f,g,x,y))}return p===r.TRIANGULAR_MESH&&(m.index=n(r,o,f)),r.destroy(f),m}function n(r,o,c){const u=c.num_faces()*3,h=u*4,f=r._malloc(h);o.GetTrianglesUInt32Array(c,h,f);const d=new Uint32Array(r.HEAPF32.buffer,f,u).slice();return r._free(f),{array:d,itemSize:1}}function i(r,o,c,l,u,h){const f=h.num_components(),p=c.num_points()*f,m=p*u.BYTES_PER_ELEMENT,g=s(r,u),x=r._malloc(m);o.GetAttributeDataArrayForAllPoints(c,h,g,m,x);const y=new u(r.HEAPF32.buffer,x,p).slice();return r._free(x),{name:l,array:y,itemSize:f}}function s(r,o){switch(o){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32}}}const fc=new Ei,Kn=new o1;Kn.addHandler(/\.dds$/i,new r1);Kn.addHandler(/\.tga$/i,new yu);function d1(a){return fc.setFromObject(a),fc.getSize(new P)}function p1(a){return fc.setFromObject(a),fc.getCenter(new P)}function m1(a){const e=a.split(".");if(e.length<=1)return"";{let t=e.pop();return t=t.toLowerCase(),t}}function g1(a,e,t,n){let i;e?i=e:i=m1(a),i==="glb"&&(i="gltf");let s={loader:null,getObject:null};switch(i){case"dae":s={loader:new wM(Kn),getObject:r=>r.scene};break;case"fbx":s={loader:new uM(Kn)};break;case"gltf":s={loader:new MM(Kn),getObject:r=>r.scene},x1(t,s,n);break;case"obj":s={loader:new s1(Kn)};break;case"ply":s={loader:new a1(Kn),getObject:r=>(r.computeVertexNormals(),new Tt(r,new Us))};break;case"stl":s={loader:new c1(Kn),getObject:r=>new Tt(r,new Qn)};break;case"json":s={loader:new tm(Kn)};break}return s}function y1(){return new l1(Kn)}function x1(a,e,t){if(a){const n=new h1;n.setDecoderPath(t||"assets/draco/gltf/"),n.setDecoderConfig({type:"js"}),e.loader.setDRACOLoader(n)}}var v1=(a,e)=>{const t=a.__vccOpts||a;for(const[n,i]of e)t[n]=i;return t};const _1=kt.defineComponent({name:"vue3dLoader"}),b1=kt.defineComponent({..._1,props:{filePath:null,fileType:null,width:null,height:null,position:null,rotation:null,scale:null,lights:{default:()=>[{type:"AmbientLight",color:11184810},{type:"DirectionalLight",position:{x:1,y:1,z:1},color:16777215,intensity:.8}]},cameraPosition:{default:()=>({x:0,y:0,z:0})},cameraRotation:null,cameraUp:null,cameraLookAt:null,backgroundColor:{default:()=>16777215},backgroundAlpha:{default:()=>1},controlsOptions:null,crossOrigin:{default:"anonymous"},requestHeader:null,outputEncoding:{default:()=>"linear"},webGLRendererOptions:{default:()=>({})},mtlPath:{default:""},showFps:{type:Boolean,default:!1},textureImage:{default:""},clearScene:{type:Boolean,default:!1},parallelLoad:{type:Boolean,default:!1},labels:{default:()=>[]},autoPlay:{type:Boolean,default:!0},enableDraco:{type:Boolean,default:!1},dracoDir:null,intersectRecursive:{type:Boolean,default:!1},enableDamping:{type:Boolean},dampingFactor:null},emits:["mousedown","mousemove","mouseup","click","dblclick","load","process","error"],setup(a,{emit:e}){const t=a;let n=null;const i=new rm,s=new de,r=new Dt(45,1,1,1e5),o=new Ac,c=new $u;let l=new ut,u=null,h={},f=[],d=null,p=0,m=null,g=null,x=null;const y=kt.ref({width:t.width||0,height:t.height||0}),b=kt.ref(0),v=kt.ref(!1),M=kt.ref(!1),T=kt.ref(null),C=kt.ref(null);kt.watch([()=>t.filePath,()=>t.fileType,()=>t.clearScene,()=>t.backgroundAlpha,()=>t.backgroundColor],k=>{(k[0]||k[1])&&ie(),k[2]&&ve(),(k[3]||k[4])&&W()}),kt.watch([()=>t.rotation,()=>t.position,()=>t.scale,()=>t.lights],k=>{const z=["rotation","position","scale"];k.forEach((K,Q)=>{Q<3&&K?Fe(z[Q],K):ne()})},{deep:!0}),kt.watch([()=>y],()=>{j(!0),W()},{deep:!0}),kt.watch([()=>t.controlsOptions],()=>{$()},{deep:!0}),kt.watch([()=>t.cameraRotation,()=>t.cameraPosition],()=>{j()},{deep:!0}),kt.watch([()=>t.autoPlay],()=>{at()}),kt.onMounted(()=>{const{filePath:k,outputEncoding:z,webGLRendererOptions:K,showFps:Q,enableDamping:me,dampingFactor:R}=t;k&&typeof k=="object"&&(M.value=!0);const ae=T.value;_(ae),F();const Se=Object.assign({},{antialias:!0,alpha:!0},K,{canvas:C.value});u=new Fu(Se),u.shadowMap.enabled=!0;const Te=z==="linear"?bi:nt;u.outputEncoding=Te,h=new kw(r,ae),me&&(h.enableDamping=!0,R!=null&&(h.dampingFactor=R)),o.add(l),ie(),Z(),E(!0),ae.addEventListener("mousedown",U,!1),ae.addEventListener("mouseup",J,!1),ae.addEventListener("click",G,!1),ae.addEventListener("dblclick",X,!1),window.addEventListener("resize",F,!1),Q&&(m=xo(),ae.appendChild(m.dom)),Pe()}),kt.onBeforeUnmount(()=>{cancelAnimationFrame(p),u.dispose(),h&&h.dispose();const k=T.value;k.removeEventListener("mousedown",U,!1),k.removeEventListener("mousemove",q,!1),k.removeEventListener("mouseup",J,!1),k.removeEventListener("click",G,!1),k.removeEventListener("dblclick",X,!1),window.removeEventListener("resize",F,!1),n=null,l=null});function _(k){const{width:z,height:K}=t;z&&(k.style.width=`${z}px`),K&&(k.style.height=`${K}px`)}function E(k){const z=T.value;k?z.addEventListener("mousemove",q,!1):z.removeEventListener("mousemove",q,!1)}function F(){const{width:k,height:z}=t;(!k||!z)&&kt.nextTick(()=>{const K=T.value;y.value={width:k||K.offsetWidth,height:z||K.offsetHeight}})}function U(k){E(!1);const z=B(k.clientX,k.clientY);e("mousedown",k,z)}function q(k){const z=B(k.clientX,k.clientY);e("mousemove",k,z)}function J(k){const z=B(k.clientX,k.clientY);e("mouseup",k,z),E(!0)}function G(k){const z=B(k.clientX,k.clientY);e("click",k,z)}function X(k){const z=B(k.clientX,k.clientY);e("dblclick",k,z)}function B(k,z){const K=Ee();if(!K||!T.value)return null;const Q=T.value.getBoundingClientRect();k-=Q.left,z-=Q.top,s.x=k/y.value.width*2-1,s.y=-(z/y.value.height)*2+1,i.setFromCamera(s,r);const me=i.intersectObject(K,t.intersectRecursive);return(me&&me.length)>0?me[0]:null}function Z(){W(),j(),ne(),$()}function Y(){if(!n)return;const k=M.value?ht(n):null,{position:z,rotation:K,scale:Q}=t;z&&(z instanceof Array?k!=null?n.position.set(z[k].x,z[k].y,z[k].z):n.position.set(0,0,0):n.position.set(z.x,z.y,z.z)),K&&(K instanceof Array?k!=null?n.rotation.set(K[k].x,K[k].y,K[k].z):n.rotation.set(0,0,0):n.rotation.set(K.x,K.y,K.z)),Q&&(Q instanceof Array?k!=null?n.scale.set(Q[k].x,Q[k].y,Q[k].z):n.scale.set(0,0,0):n.scale.set(Q.x,Q.y,Q.z))}function W(){const{backgroundColor:k,backgroundAlpha:z}=t;u.setSize(y.value.width,y.value.height),u.setPixelRatio(window.devicePixelRatio||1),u.setClearColor(new be(k).getHex()),u.setClearAlpha(z)}function j(k){const{cameraPosition:z,cameraRotation:K,cameraUp:Q,cameraLookAt:me}=t;if(r.aspect=y.value.width/y.value.height,r.updateProjectionMatrix(),!k)if(!me||!Q){if(!n)return;const R=d1(n).length();r.position.set(z.x,z.y,z.z),K&&r.rotation.set(K.x,K.y,K.z),z.x===0&&z.y===0&&z.z===0&&(r.position.z=R),r.lookAt(new P)}else r.position.set(z.x,z.y,z.z),K&&r.rotation.set(K.x,K.y,K.z),r.up.set(Q.x,Q.y,Q.z),r.lookAt(new P(me.x,me.y,me.z))}function ne(){const{lights:k}=t;o.remove(...f),f=[],k.forEach(z=>{if(!z.type)return;const K=z.type.toLowerCase();let Q=null;if(K==="ambient"||K==="ambientlight"){const me=z.color===0?z.color:z.color||4210752,R=z.intensity===0?z.intensity:z.intensity||1;Q=new Wo(me,R)}if(K==="point"||K==="pointlight"){const me=z.color===0?z.color:z.color||16777215,R=z.intensity===0?z.intensity:z.intensity||1,ae=z.distance||0,pe=z.decay===0?z.decay:z.decay||1;Q=new Os(me,R,ae,pe),z.position&&Q.position.copy(z.position)}if(K==="directional"||K==="directionallight"){const me=z.color===0?z.color:z.color||16777215,R=z.intensity===0?z.intensity:z.intensity||1;Q=new Vr(me,R),z.position&&Q.position.copy(z.position),z.target&&Q.target.copy(z.target)}if(K==="hemisphere"||K==="hemispherelight"){const me=z.skyColor===0?z.skyColor:z.skyColor||16777215,R=z.groundColor===0?z.groundColor:z.groundColor||16777215,ae=z.intensity===0?z.intensity:z.intensity||1;Q=new Zu(me,R,ae),z.position&&Q.position.copy(z.position)}Q&&(f.push(Q),o.add(Q))})}function $(){const{controlsOptions:k}=t;k&&Object.assign(h,k)}function ie(){const{filePath:k,parallelLoad:z}=t;z&&M?k.forEach((K,Q)=>{ce(Q)}):ce()}function ce(k){const{filePath:z,fileType:K,crossOrigin:Q,requestHeader:me,mtlPath:R,enableDraco:ae,dracoDir:pe}=t;if(!z)return;const Se=k||b.value,Te=M.value?z[Se]:z,He=typeof K=="string"?K:K?K[Se]:"",Ze=g1(Te,He,ae,pe);d=Ze.loader;const Qe=Ze.getObject?Ze.getObject:ye;if(n&&Se===0&&l.remove(n),me&&d.setRequestHeader(me),Q&&d.setCrossOrigin(Q),R)if(!(typeof R=="object"))H(Te,Qe,Se);else{if(!R[Se]){oe(Te,Qe,Se);return}H(Te,Qe,Se)}else oe(Te,Qe,Se)}function oe(k,z,K){const{textureImage:Q,parallelLoad:me}=t;d.load(k,(...R)=>{if(n=z(...R),we(n,k),Q){const pe=typeof Q=="string"?Q:Q[K];pe&&ue(n,pe)}je(),e("load",l)},R=>{me||he(R);const ae=b.value+1;e("process",R,ae)},R=>{e("error",R)})}function H(k,z,K){const{crossOrigin:Q,requestHeader:me,mtlPath:R}=t,ae=y1();Q&&ae.setCrossOrigin(Q),me&&ae.setRequestHeader(me);const pe=typeof R=="string"?R:R[K],Se=/^(.*\/)([^/]*)$/.exec(pe),Te=Se[1],He=Se[2];ae.setPath(Te).load(He,Ze=>{Ze.preload(),d.setMaterials(Ze),oe(k,z,K)})}function ye(k){return k}function we(k,z){const K=p1(n);v.value||(l.position.copy(K.negate()),v.value=!0),n=k;let Q=z.split("/");Q=Q[Q.length-1],n.fileName=Q,l.add(n),j(),Y(),at()}function Pe(){p=requestAnimationFrame(Pe),Ve();const k=c.getDelta();g&&g instanceof $a&&g.update(k),g&&g instanceof Array&&g.forEach(z=>{z.update(k)}),xe()}function xe(){u.render(o,r)}function Ve(){const{showFps:k}=t;k&&m.update()}function he(k){const{filePath:z}=t;Math.floor(k.loaded/k.total*100)===100&&(M.value&&z.length>b.value?kt.nextTick(()=>{if(b.value++,b.value===z.length){b.value=0;return}ce()}):b.value=0)}function ue(k,z){x||(x=new ks),k.traverse(K=>{K.isMesh&&x.load(z,Q=>{K.material.map=Q,K.material.needsUpdate=!0},()=>{},Q=>{e("error",Q)})})}function ve(){l.clear()}function Fe(k,z){const K=Ee();if(!!K){if(M.value){K.children.forEach(Q=>{const me=ht(Q),R=k==="scale"?1:0;z[me]?Q[k].set(z[me].x,z[me].y,z[me].z):Q[k].set(R,R,R)});return}K[k].set(z.x,z.y,z.z)}}function Ee(){return M.value?l:n}function je(){const{filePath:k}=t;M.value?b.value===k.length&&ze():ze()}function ze(){const{labels:k}=t;if(!k)return;const z=M.value?l:n,K=me=>(x||(x=new ks),x.load(me)),Q=(me,R)=>{const ae=Be(me,R),pe=new At(ae);return pe.needsUpdate=!0,pe};k.forEach(me=>{const R=me.image?K(me.image):Q(me.text,me.textStyle||{}),ae=new Ec({map:R,color:me.spriteMaterialColor||16777215}),pe=new Nu(ae);me.scale?pe.scale.set(me.scale.x||1,me.scale.y||1,me.scale.z||0):pe.scale.set(1,1,0),me.position&&pe.position.set(me.position.x,me.position.y,me.position.z),me.sid&&(pe.sid=me.sid),z.add(pe)})}function Be(k,z){const K=(V,_e,re,Re,Ce,Je)=>{V.beginPath(),V.moveTo(_e+Je,re),V.lineTo(_e+Re-Je,re),V.quadraticCurveTo(_e+Re,re,_e+Re,re+Je),V.lineTo(_e+Re,re+Ce-Je),V.quadraticCurveTo(_e+Re,re+Ce,_e+Re-Je,re+Ce),V.lineTo(_e+Je,re+Ce),V.quadraticCurveTo(_e,re+Ce,_e,re+Ce-Je),V.lineTo(_e,re+Je),V.quadraticCurveTo(_e,re,_e+Je,re),V.closePath(),V.fill(),V.stroke()},Q=z.fontFamily||"Arial",me=z.fontSize===0||z.fontSize?z.fontSize:18,R=z.color||"#ffffff",ae=z.fontWeight||"normal",pe=z.borderWidth===0||z.borderWidth?z.borderWidth:4,Se=z.borderColor||"rgba(0,0,0,1)",Te=z.borderRadius===0||z.borderRadius?z.borderRadius:4,He=z.backgroundColor||"rgba(255, 255, 255, 1)",Ze=document.createElement("canvas"),Qe=Ze.getContext("2d");if(Qe){Qe.font=`${ae} ${me}px ${Q}`;const _e=Qe.measureText(k).width;Qe.fillStyle=He,Qe.strokeStyle=Se,Qe.lineWidth=pe,K(Qe,pe/2,pe/2,_e+pe,me*1.4+pe,Te),Qe.fillStyle=R,Qe.fillText(k,pe,me+pe)}return Ze}function ht(k){const{filePath:z}=t;let K;return z instanceof Array&&(K=z.map((Q,me)=>{if(Q.indexOf(k.fileName)>-1)return me}).filter(Q=>Q!=null)[0]),K}function at(){const k=Ee();if(!!k){if(M.value){D(k);return}O(k)}}function O(k){const{autoPlay:z}=t;g=new $a(k),k.animations&&k.animations.length>0&&k.animations.forEach(K=>{if(K){const Q=g.clipAction(K);z?Q.play():Q.stop()}})}function D(k){const{autoPlay:z}=t;g=[],k.children.forEach((K,Q)=>{g.push(new $a(K)),K.animations&&K.animations.length>0&&K.animations.forEach(me=>{if(me){const R=g[Q].clipAction(me);z?R.play():R.stop()}})})}return(k,z)=>(kt.openBlock(),kt.createElementBlock("div",{ref_key:"containerElement",ref:T,class:"viewer-container"},[kt.createElementVNode("canvas",{ref_key:"canvasElement",ref:C,class:"viewer-canvas"},null,512)],512))}});var dc=v1(b1,[["__scopeId","data-v-04ca652e"]]);const w1=a=>{a.component(dc.name,dc)};var M1={install:w1,vue3dLoader:dc};exports.Three=Nw;exports.default=M1;exports.vue3dLoader=dc; diff --git a/dist/vue-3d-loader.esm.js b/dist/vue-3d-loader.esm.js index 3a5a8a2..9f12fd1 100644 --- a/dist/vue-3d-loader.esm.js +++ b/dist/vue-3d-loader.esm.js @@ -40831,7 +40831,7 @@ const _sfc_main = defineComponent({ let loader = null; let requestAnimationId = 0; let stats = null; - let mixer = null; + let mixers = null; let textureLoader = null; const size = ref({ width: props.width || 0, height: props.height || 0 }); const loaderIndex = ref(0); @@ -40885,7 +40885,14 @@ const _sfc_main = defineComponent({ playAnimations(); }); onMounted(() => { - const { filePath, outputEncoding, webGLRendererOptions, showFps, enableDamping, dampingFactor } = props; + const { + filePath, + outputEncoding, + webGLRendererOptions, + showFps, + enableDamping, + dampingFactor + } = props; if (filePath && typeof filePath === "object") { isMultipleModels.value = true; } @@ -41136,9 +41143,9 @@ const _sfc_main = defineComponent({ if (!filePath) return; const index2 = fileIndex || loaderIndex.value; - const filePathStrng = !isMultipleModels.value ? filePath : filePath[index2]; + const filePathString = !isMultipleModels.value ? filePath : filePath[index2]; const fileTypeString = typeof fileType === "string" ? fileType : fileType ? fileType[index2] : ""; - const loaderObject3d = getLoader(filePathStrng, fileTypeString, enableDraco2, dracoDir); + const loaderObject3d = getLoader(filePathString, fileTypeString, enableDraco2, dracoDir); loader = loaderObject3d.loader; const getObjectFun = loaderObject3d.getObject ? loaderObject3d.getObject : getObject; if (object && index2 === 0) { @@ -41153,16 +41160,16 @@ const _sfc_main = defineComponent({ if (mtlPath) { const isMultipleMTL = typeof mtlPath === "object"; if (!isMultipleMTL) { - loadMtl(filePathStrng, getObjectFun, index2); + loadMtl(filePathString, getObjectFun, index2); } else { if (!mtlPath[index2]) { - loadFilePath(filePathStrng, getObjectFun, index2); + loadFilePath(filePathString, getObjectFun, index2); return; } - loadMtl(filePathStrng, getObjectFun, index2); + loadMtl(filePathString, getObjectFun, index2); } } else { - loadFilePath(filePathStrng, getObjectFun, index2); + loadFilePath(filePathString, getObjectFun, index2); } } function loadFilePath(filePath, getObject2, index2) { @@ -41230,8 +41237,14 @@ const _sfc_main = defineComponent({ requestAnimationId = requestAnimationFrame(animate); updateStats(); const delta = clock.getDelta(); - if (mixer) - mixer.update(delta); + if (mixers && mixers instanceof AnimationMixer) { + mixers.update(delta); + } + if (mixers && mixers instanceof Array) { + mixers.forEach((m) => { + m.update(delta); + }); + } render(); } function render() { @@ -41398,16 +41411,40 @@ const _sfc_main = defineComponent({ return objIndex; } function playAnimations() { - const { autoPlay } = props; const obj = getAllObject(); if (!obj) return; - const play = (item) => { - mixer = new AnimationMixer(obj); - if (item.animations) { + if (isMultipleModels.value) { + playMultipleModels(obj); + return; + } + playSingleModel(obj); + } + function playSingleModel(item) { + const { autoPlay } = props; + mixers = new AnimationMixer(item); + if (item.animations && item.animations.length > 0) { + item.animations.forEach((clip) => { + if (clip) { + const action = mixers.clipAction(clip); + if (autoPlay) { + action.play(); + } else { + action.stop(); + } + } + }); + } + } + function playMultipleModels(obj) { + const { autoPlay } = props; + mixers = []; + obj.children.forEach((item, index2) => { + mixers.push(new AnimationMixer(item)); + if (item.animations && item.animations.length > 0) { item.animations.forEach((clip) => { if (clip) { - const action = mixer.clipAction(clip); + const action = mixers[index2].clipAction(clip); if (autoPlay) { action.play(); } else { @@ -41416,14 +41453,7 @@ const _sfc_main = defineComponent({ } }); } - }; - if (isMultipleModels.value) { - obj.children.forEach((item) => { - play(item); - }); - return; - } - play(obj); + }); } return (_ctx, _cache) => { return openBlock(), createElementBlock("div", { @@ -41440,7 +41470,7 @@ const _sfc_main = defineComponent({ }; } }); -var vue3dLoader = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-07257ca0"]]); +var vue3dLoader = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-04ca652e"]]); const install = (app) => { app.component(vue3dLoader.name, vue3dLoader); }; diff --git a/dist/vue-3d-loader.global.js b/dist/vue-3d-loader.global.js index 373cb38..5ba8c77 100644 --- a/dist/vue-3d-loader.global.js +++ b/dist/vue-3d-loader.global.js @@ -2,11 +2,11 @@ var vue3dLoader=function(Jr,Nt){"use strict";/** * @license * Copyright 2010-2022 Three.js Authors * SPDX-License-Identifier: MIT - */const Ko="143",is={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ss={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},mh=0,Fc=1,gh=2,Zm=3,Km=0,Nc=1,yh=2,Ws=3,oi=0,Tn=1,ai=2,xh=1,Jm=2,ci=0,rs=1,kc=2,Oc=3,Bc=4,vh=5,os=100,_h=101,bh=102,zc=103,Uc=104,wh=200,Mh=201,Sh=202,Th=203,Gc=204,Vc=205,Ah=206,Eh=207,Ch=208,Lh=209,Rh=210,Ih=0,Ph=1,Dh=2,Jo=3,Fh=4,Nh=5,kh=6,Oh=7,$r=0,Bh=1,zh=2,Xn=0,Uh=1,Gh=2,Vh=3,Hh=4,Wh=5,$o=300,Li=301,Ri=302,qs=303,Qr=304,Xs=306,on=1e3,Wt=1001,js=1002,kt=1003,eo=1004,$m=1004,to=1005,Qm=1005,Et=1006,Qo=1007,eg=1007,jn=1008,tg=1008,Ii=1009,qh=1010,Xh=1011,Hc=1012,jh=1013,Pi=1014,li=1015,Ys=1016,Yh=1017,Zh=1018,as=1020,Kh=1021,Jh=1022,_n=1023,$h=1024,Qh=1025,Di=1026,cs=1027,ef=1028,tf=1029,nf=1030,sf=1031,rf=1033,no=33776,ea=33777,io=33778,so=33779,Wc=35840,qc=35841,Xc=35842,jc=35843,Yc=36196,Zc=37492,Kc=37496,Jc=37808,$c=37809,Qc=37810,el=37811,tl=37812,nl=37813,il=37814,sl=37815,rl=37816,ol=37817,al=37818,cl=37819,ll=37820,ul=37821,hl=36492,of=2200,af=2201,cf=2202,Zs=2300,ls=2301,ta=2302,us=2400,hs=2401,ro=2402,na=2500,fl=2501,ng=0,lf=1,dl=2,ui=3e3,tt=3001,uf=3200,hf=3201,Fi=0,ff=1,ig="",Yn="srgb",Ni="srgb-linear",sg=0,ia=7680,rg=7681,og=7682,ag=7683,cg=34055,lg=34056,ug=5386,hg=512,fg=513,dg=514,pg=515,mg=516,gg=517,yg=518,df=519,oo=35044,xg=35048,vg=35040,_g=35045,bg=35049,wg=35041,Mg=35046,Sg=35050,Tg=35042,Ag="100",pl="300 es",sa=1035;class Zn{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let s=0,r=i.length;s>8&255]+nn[a>>16&255]+nn[a>>24&255]+"-"+nn[e&255]+nn[e>>8&255]+"-"+nn[e>>16&15|64]+nn[e>>24&255]+"-"+nn[t&63|128]+nn[t>>8&255]+"-"+nn[t>>16&255]+nn[t>>24&255]+nn[n&255]+nn[n>>8&255]+nn[n>>16&255]+nn[n>>24&255]).toLowerCase()}function Ot(a,e,t){return Math.max(e,Math.min(t,a))}function ml(a,e){return(a%e+e)%e}function Eg(a,e,t,n,i){return n+(a-e)*(i-n)/(t-e)}function Cg(a,e,t){return a!==e?(t-a)/(e-a):0}function co(a,e,t){return(1-t)*a+t*e}function Lg(a,e,t,n){return co(a,e,1-Math.exp(-t*n))}function Rg(a,e=1){return e-Math.abs(ml(a,e*2)-e)}function Ig(a,e,t){return a<=e?0:a>=t?1:(a=(a-e)/(t-e),a*a*(3-2*a))}function Pg(a,e,t){return a<=e?0:a>=t?1:(a=(a-e)/(t-e),a*a*a*(a*(a*6-15)+10))}function Dg(a,e){return a+Math.floor(Math.random()*(e-a+1))}function Fg(a,e){return a+Math.random()*(e-a)}function Ng(a){return a*(.5-Math.random())}function kg(a){a!==void 0&&(pf=a);let e=pf+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Og(a){return a*fs}function Bg(a){return a*ao}function gl(a){return(a&a-1)===0&&a!==0}function mf(a){return Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function ra(a){return Math.pow(2,Math.floor(Math.log(a)/Math.LN2))}function zg(a,e,t,n,i){const s=Math.cos,r=Math.sin,o=s(t/2),c=r(t/2),l=s((e+n)/2),u=r((e+n)/2),h=s((e-n)/2),f=r((e-n)/2),d=s((n-e)/2),p=r((n-e)/2);switch(i){case"XYX":a.set(o*u,c*h,c*f,o*l);break;case"YZY":a.set(c*f,o*u,c*h,o*l);break;case"ZXZ":a.set(c*h,c*f,o*u,o*l);break;case"XZX":a.set(o*u,c*p,c*d,o*l);break;case"YXY":a.set(c*d,o*u,c*p,o*l);break;case"ZYZ":a.set(c*p,c*d,o*u,o*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Ug(a,e){switch(e.constructor){case Float32Array:return a;case Uint16Array:return a/65535;case Uint8Array:return a/255;case Int16Array:return Math.max(a/32767,-1);case Int8Array:return Math.max(a/127,-1);default:throw new Error("Invalid component type.")}}function Gg(a,e){switch(e.constructor){case Float32Array:return a;case Uint16Array:return Math.round(a*65535);case Uint8Array:return Math.round(a*255);case Int16Array:return Math.round(a*32767);case Int8Array:return Math.round(a*127);default:throw new Error("Invalid component type.")}}var en=Object.freeze({__proto__:null,DEG2RAD:fs,RAD2DEG:ao,generateUUID:bn,clamp:Ot,euclideanModulo:ml,mapLinear:Eg,inverseLerp:Cg,lerp:co,damp:Lg,pingpong:Rg,smoothstep:Ig,smootherstep:Pg,randInt:Dg,randFloat:Fg,randFloatSpread:Ng,seededRandom:kg,degToRad:Og,radToDeg:Bg,isPowerOfTwo:gl,ceilPowerOfTwo:mf,floorPowerOfTwo:ra,setQuaternionFromProperEuler:zg,normalize:Gg,denormalize:Ug});class he{constructor(e=0,t=0){he.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,r=this.y-e.y;return this.x=s*n-r*i+e.x,this.y=s*i+r*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class an{constructor(){an.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(e,t,n,i,s,r,o,c,l){const u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=t,u[4]=s,u[5]=c,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(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,r=n[0],o=n[3],c=n[6],l=n[1],u=n[4],h=n[7],f=n[2],d=n[5],p=n[8],m=i[0],g=i[3],x=i[6],y=i[1],b=i[4],v=i[7],S=i[2],A=i[5],R=i[8];return s[0]=r*m+o*y+c*S,s[3]=r*g+o*b+c*A,s[6]=r*x+o*v+c*R,s[1]=l*m+u*y+h*S,s[4]=l*g+u*b+h*A,s[7]=l*x+u*v+h*R,s[2]=f*m+d*y+p*S,s[5]=f*g+d*b+p*A,s[8]=f*x+d*v+p*R,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],o=e[5],c=e[6],l=e[7],u=e[8];return t*r*u-t*o*l-n*s*u+n*o*c+i*s*l-i*r*c}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],o=e[5],c=e[6],l=e[7],u=e[8],h=u*r-o*l,f=o*c-u*s,d=l*s-r*c,p=t*h+n*f+i*d;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return e[0]=h*m,e[1]=(i*l-u*n)*m,e[2]=(o*n-i*r)*m,e[3]=f*m,e[4]=(u*t-i*c)*m,e[5]=(i*s-o*t)*m,e[6]=d*m,e[7]=(n*c-l*t)*m,e[8]=(r*t-n*s)*m,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,r,o){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*r+l*o)+r+e,-i*l,i*c,-i*(-l*r+c*o)+o+t,0,0,1),this}scale(e,t){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){const t=Math.cos(e),n=Math.sin(e),i=this.elements,s=i[0],r=i[3],o=i[6],c=i[1],l=i[4],u=i[7];return i[0]=t*s+n*c,i[3]=t*r+n*l,i[6]=t*o+n*u,i[1]=-n*s+t*c,i[4]=-n*r+t*l,i[7]=-n*o+t*u,this}translate(e,t){const n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}function gf(a){for(let e=a.length-1;e>=0;--e)if(a[e]>65535)return!0;return!1}const Vg={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Ks(a,e){return new Vg[a](e)}function lo(a){return document.createElementNS("http://www.w3.org/1999/xhtml",a)}function ds(a){return a<.04045?a*.0773993808:Math.pow(a*.9478672986+.0521327014,2.4)}function oa(a){return a<.0031308?a*12.92:1.055*Math.pow(a,.41666)-.055}const yl={[Yn]:{[Ni]:ds},[Ni]:{[Yn]:oa}},An={legacyMode:!0,get workingColorSpace(){return Ni},set workingColorSpace(a){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(a,e,t){if(this.legacyMode||e===t||!e||!t)return a;if(yl[e]&&yl[e][t]!==void 0){const n=yl[e][t];return a.r=n(a.r),a.g=n(a.g),a.b=n(a.b),a}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(a,e){return this.convert(a,this.workingColorSpace,e)},toWorkingColorSpace:function(a,e){return this.convert(a,e,this.workingColorSpace)}},yf={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},Yt={r:0,g:0,b:0},zn={h:0,s:0,l:0},aa={h:0,s:0,l:0};function xl(a,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<.16666666666666666?a+(e-a)*6*t:t<.5?e:t<.6666666666666666?a+(e-a)*6*(.6666666666666666-t):a}function ca(a,e){return e.r=a.r,e.g=a.g,e.b=a.b,e}class ve{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,t===void 0&&n===void 0?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Yn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,An.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=Ni){return this.r=e,this.g=t,this.b=n,An.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=Ni){if(e=ml(e,1),t=Ot(t,0,1),n=Ot(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,r=2*n-s;this.r=xl(r,s,e+.3333333333333333),this.g=xl(r,s,e),this.b=xl(r,s,e-.3333333333333333)}return An.toWorkingColorSpace(this,i),this}setStyle(e,t=Yn){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let s;const 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 this.r=Math.min(255,parseInt(s[1],10))/255,this.g=Math.min(255,parseInt(s[2],10))/255,this.b=Math.min(255,parseInt(s[3],10))/255,An.toWorkingColorSpace(this,t),n(s[4]),this;if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(s[1],10))/100,this.g=Math.min(100,parseInt(s[2],10))/100,this.b=Math.min(100,parseInt(s[3],10))/100,An.toWorkingColorSpace(this,t),n(s[4]),this;break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)){const c=parseFloat(s[1])/360,l=parseInt(s[2],10)/100,u=parseInt(s[3],10)/100;return n(s[4]),this.setHSL(c,l,u,t)}break}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],r=s.length;if(r===3)return this.r=parseInt(s.charAt(0)+s.charAt(0),16)/255,this.g=parseInt(s.charAt(1)+s.charAt(1),16)/255,this.b=parseInt(s.charAt(2)+s.charAt(2),16)/255,An.toWorkingColorSpace(this,t),this;if(r===6)return this.r=parseInt(s.charAt(0)+s.charAt(1),16)/255,this.g=parseInt(s.charAt(2)+s.charAt(3),16)/255,this.b=parseInt(s.charAt(4)+s.charAt(5),16)/255,An.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=Yn){const n=yf[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ds(e.r),this.g=ds(e.g),this.b=ds(e.b),this}copyLinearToSRGB(e){return this.r=oa(e.r),this.g=oa(e.g),this.b=oa(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Yn){return An.fromWorkingColorSpace(ca(this,Yt),e),Ot(Yt.r*255,0,255)<<16^Ot(Yt.g*255,0,255)<<8^Ot(Yt.b*255,0,255)<<0}getHexString(e=Yn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ni){An.fromWorkingColorSpace(ca(this,Yt),t);const n=Yt.r,i=Yt.g,s=Yt.b,r=Math.max(n,i,s),o=Math.min(n,i,s);let c,l;const u=(o+r)/2;if(o===r)c=0,l=0;else{const h=r-o;switch(l=u<=.5?h/(r+o):h/(2-r-o),r){case n:c=(i-s)/h+(i2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap){const t=lo("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let r=0;r1)switch(this.wrapS){case on:e.x=e.x-Math.floor(e.x);break;case Wt:e.x=e.x<0?0:1;break;case js:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case on:e.y=e.y-Math.floor(e.y);break;case Wt:e.y=e.y<0?0:1;break;case js:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}}Mt.DEFAULT_IMAGE=null,Mt.DEFAULT_MAPPING=$o;class ut{constructor(e=0,t=0,n=0,i=1){ut.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=this.w,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i+r[12]*s,this.y=r[1]*t+r[5]*n+r[9]*i+r[13]*s,this.z=r[2]*t+r[6]*n+r[10]*i+r[14]*s,this.w=r[3]*t+r[7]*n+r[11]*i+r[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,s;const c=e.elements,l=c[0],u=c[4],h=c[8],f=c[1],d=c[5],p=c[9],m=c[2],g=c[6],x=c[10];if(Math.abs(u-f)<.01&&Math.abs(h-m)<.01&&Math.abs(p-g)<.01){if(Math.abs(u+f)<.1&&Math.abs(h+m)<.1&&Math.abs(p+g)<.1&&Math.abs(l+d+x-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(l+1)/2,v=(d+1)/2,S=(x+1)/2,A=(u+f)/4,R=(h+m)/4,_=(p+g)/4;return b>v&&b>S?b<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(b),i=A/n,s=R/n):v>S?v<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(v),n=A/i,s=_/i):S<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(S),n=R/s,i=_/s),this.set(n,i,s,t),this}let y=Math.sqrt((g-p)*(g-p)+(h-m)*(h-m)+(f-u)*(f-u));return Math.abs(y)<.001&&(y=1),this.x=(g-p)/y,this.y=(h-m)/y,this.z=(f-u)/y,this.w=Math.acos((l+d+x-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class En extends Zn{constructor(e,t,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new ut(0,0,e,t),this.scissorTest=!1,this.viewport=new ut(0,0,e,t);const i={width:e,height:t,depth:1};this.texture=new Mt(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.internalFormat=n.internalFormat!==void 0?n.internalFormat:null,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:Et,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null,this.samples=n.samples!==void 0?n.samples:0}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new ps(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class uo extends Mt{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=kt,this.minFilter=kt,this.wrapR=Wt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Wg extends En{constructor(e,t,n){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new uo(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class la extends Mt{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=kt,this.minFilter=kt,this.wrapR=Wt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class qg extends En{constructor(e,t,n){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new la(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class Xg extends En{constructor(e,t,n,i={}){super(e,t,i),this.isWebGLMultipleRenderTargets=!0;const s=this.texture;this.texture=[];for(let r=0;r=0?1:-1,b=1-x*x;if(b>Number.EPSILON){const S=Math.sqrt(b),A=Math.atan2(S,x*y);g=Math.sin(g*A)/S,o=Math.sin(o*A)/S}const v=o*y;if(c=c*g+f*v,l=l*g+d*v,u=u*g+p*v,h=h*g+m*v,g===1-o){const S=1/Math.sqrt(c*c+l*l+u*u+h*h);c*=S,l*=S,u*=S,h*=S}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,s,r){const o=n[i],c=n[i+1],l=n[i+2],u=n[i+3],h=s[r],f=s[r+1],d=s[r+2],p=s[r+3];return e[t]=o*p+u*h+c*d-l*f,e[t+1]=c*p+u*f+l*h-o*d,e[t+2]=l*p+u*d+o*f-c*h,e[t+3]=u*p-o*h-c*f-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!(e&&e.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=e._x,i=e._y,s=e._z,r=e._order,o=Math.cos,c=Math.sin,l=o(n/2),u=o(i/2),h=o(s/2),f=c(n/2),d=c(i/2),p=c(s/2);switch(r){case"XYZ":this._x=f*u*h+l*d*p,this._y=l*d*h-f*u*p,this._z=l*u*p+f*d*h,this._w=l*u*h-f*d*p;break;case"YXZ":this._x=f*u*h+l*d*p,this._y=l*d*h-f*u*p,this._z=l*u*p-f*d*h,this._w=l*u*h+f*d*p;break;case"ZXY":this._x=f*u*h-l*d*p,this._y=l*d*h+f*u*p,this._z=l*u*p+f*d*h,this._w=l*u*h-f*d*p;break;case"ZYX":this._x=f*u*h-l*d*p,this._y=l*d*h+f*u*p,this._z=l*u*p-f*d*h,this._w=l*u*h+f*d*p;break;case"YZX":this._x=f*u*h+l*d*p,this._y=l*d*h+f*u*p,this._z=l*u*p-f*d*h,this._w=l*u*h-f*d*p;break;case"XZY":this._x=f*u*h-l*d*p,this._y=l*d*h-f*u*p,this._z=l*u*p+f*d*h,this._w=l*u*h+f*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],s=t[8],r=t[1],o=t[5],c=t[9],l=t[2],u=t[6],h=t[10],f=n+o+h;if(f>0){const d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(u-c)*d,this._y=(s-l)*d,this._z=(r-i)*d}else if(n>o&&n>h){const d=2*Math.sqrt(1+n-o-h);this._w=(u-c)/d,this._x=.25*d,this._y=(i+r)/d,this._z=(s+l)/d}else if(o>h){const d=2*Math.sqrt(1+o-n-h);this._w=(s-l)/d,this._x=(i+r)/d,this._y=.25*d,this._z=(c+u)/d}else{const d=2*Math.sqrt(1+h-n-o);this._w=(r-i)/d,this._x=(s+l)/d,this._y=(c+u)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ot(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,s=e._z,r=e._w,o=t._x,c=t._y,l=t._z,u=t._w;return this._x=n*u+r*o+i*l-s*c,this._y=i*u+r*c+s*o-n*l,this._z=s*u+r*l+n*c-i*o,this._w=r*u-n*o-i*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,r=this._w;let o=r*e._w+n*e._x+i*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=r,this._x=n,this._y=i,this._z=s,this;const c=1-o*o;if(c<=Number.EPSILON){const d=1-t;return this._w=d*r+t*this._w,this._x=d*n+t*this._x,this._y=d*i+t*this._y,this._z=d*s+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(c),u=Math.atan2(l,o),h=Math.sin((1-t)*u)/l,f=Math.sin(t*u)/l;return this._w=r*h+this._w*f,this._x=n*h+this._x*f,this._y=i*h+this._y*f,this._z=s*h+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(s),n*Math.cos(s),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class D{constructor(e=0,t=0,n=0){D.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(xf.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(xf.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=e.elements,r=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*r,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*r,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*r,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,s=e.x,r=e.y,o=e.z,c=e.w,l=c*t+r*i-o*n,u=c*n+o*t-s*i,h=c*i+s*n-r*t,f=-s*t-r*n-o*i;return this.x=l*c+f*-s+u*-o-h*-r,this.y=u*c+f*-r+h*-s-l*-o,this.z=h*c+f*-o+l*-r-u*-s,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,s=e.z,r=t.x,o=t.y,c=t.z;return this.x=i*c-s*o,this.y=s*r-n*c,this.z=n*o-i*r,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return bl.copy(this).projectOnVector(e),this.sub(bl)}reflect(e){return this.sub(bl.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Ot(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const bl=new D,xf=new Pt;class hi{constructor(e=new D(1/0,1/0,1/0),t=new D(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,n=1/0,i=1/0,s=-1/0,r=-1/0,o=-1/0;for(let c=0,l=e.length;cs&&(s=u),h>r&&(r=h),f>o&&(o=f)}return this.min.set(t,n,i),this.max.set(s,r,o),this}setFromBufferAttribute(e){let t=1/0,n=1/0,i=1/0,s=-1/0,r=-1/0,o=-1/0;for(let c=0,l=e.count;cs&&(s=u),h>r&&(r=h),f>o&&(o=f)}return this.min.set(t,n,i),this.max.set(s,r,o),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,ms),ms.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ho),ua.subVectors(this.max,ho),$s.subVectors(e.a,ho),Qs.subVectors(e.b,ho),er.subVectors(e.c,ho),ki.subVectors(Qs,$s),Oi.subVectors(er,Qs),gs.subVectors($s,er);let t=[0,-ki.z,ki.y,0,-Oi.z,Oi.y,0,-gs.z,gs.y,ki.z,0,-ki.x,Oi.z,0,-Oi.x,gs.z,0,-gs.x,-ki.y,ki.x,0,-Oi.y,Oi.x,0,-gs.y,gs.x,0];return!Ml(t,$s,Qs,er,ua)||(t=[1,0,0,0,1,0,0,0,1],!Ml(t,$s,Qs,er,ua))?!1:(ha.crossVectors(ki,Oi),t=[ha.x,ha.y,ha.z],Ml(t,$s,Qs,er,ua))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return ms.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(ms).length()*.5,e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(fi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),fi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),fi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),fi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),fi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),fi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),fi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),fi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(fi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const fi=[new D,new D,new D,new D,new D,new D,new D,new D],ms=new D,wl=new hi,$s=new D,Qs=new D,er=new D,ki=new D,Oi=new D,gs=new D,ho=new D,ua=new D,ha=new D,ys=new D;function Ml(a,e,t,n,i){for(let s=0,r=a.length-3;s<=r;s+=3){ys.fromArray(a,s);const o=i.x*Math.abs(ys.x)+i.y*Math.abs(ys.y)+i.z*Math.abs(ys.z),c=e.dot(ys),l=t.dot(ys),u=n.dot(ys);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>o)return!1}return!0}const jg=new hi,vf=new D,fa=new D,Sl=new D;class Bi{constructor(e=new D,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):jg.setFromPoints(e).getCenter(n);let i=0;for(let s=0,r=e.length;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){Sl.subVectors(e,this.center);const t=Sl.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.add(Sl.multiplyScalar(i/n)),this.radius+=i}return this}union(e){return this.center.equals(e.center)===!0?fa.set(0,0,1).multiplyScalar(e.radius):fa.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(vf.copy(e.center).add(fa)),this.expandByPoint(vf.copy(e.center).sub(fa)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const di=new D,Tl=new D,da=new D,zi=new D,Al=new D,pa=new D,El=new D;class fo{constructor(e=new D,t=new D(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,di)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=di.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(di.copy(this.direction).multiplyScalar(t).add(this.origin),di.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Tl.copy(e).add(t).multiplyScalar(.5),da.copy(t).sub(e).normalize(),zi.copy(this.origin).sub(Tl);const s=e.distanceTo(t)*.5,r=-this.direction.dot(da),o=zi.dot(this.direction),c=-zi.dot(da),l=zi.lengthSq(),u=Math.abs(1-r*r);let h,f,d,p;if(u>0)if(h=r*c-o,f=r*o-c,p=s*u,h>=0)if(f>=-p)if(f<=p){const m=1/u;h*=m,f*=m,d=h*(h+r*f+2*o)+f*(r*h+f+2*c)+l}else f=s,h=Math.max(0,-(r*f+o)),d=-h*h+f*(f+2*c)+l;else f=-s,h=Math.max(0,-(r*f+o)),d=-h*h+f*(f+2*c)+l;else f<=-p?(h=Math.max(0,-(-r*s+o)),f=h>0?-s:Math.min(Math.max(-s,-c),s),d=-h*h+f*(f+2*c)+l):f<=p?(h=0,f=Math.min(Math.max(-s,-c),s),d=f*(f+2*c)+l):(h=Math.max(0,-(r*s+o)),f=h>0?s:Math.min(Math.max(-s,-c),s),d=-h*h+f*(f+2*c)+l);else f=r>0?-s:s,h=Math.max(0,-(r*f+o)),d=-h*h+f*(f+2*c)+l;return n&&n.copy(this.direction).multiplyScalar(h).add(this.origin),i&&i.copy(da).multiplyScalar(f).add(Tl),d}intersectSphere(e,t){di.subVectors(e.center,this.origin);const n=di.dot(this.direction),i=di.dot(di)-n*n,s=e.radius*e.radius;if(i>s)return null;const r=Math.sqrt(s-i),o=n-r,c=n+r;return o<0&&c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,r,o,c;const l=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,f=this.origin;return l>=0?(n=(e.min.x-f.x)*l,i=(e.max.x-f.x)*l):(n=(e.max.x-f.x)*l,i=(e.min.x-f.x)*l),u>=0?(s=(e.min.y-f.y)*u,r=(e.max.y-f.y)*u):(s=(e.max.y-f.y)*u,r=(e.min.y-f.y)*u),n>r||s>i||((s>n||n!==n)&&(n=s),(r=0?(o=(e.min.z-f.z)*h,c=(e.max.z-f.z)*h):(o=(e.max.z-f.z)*h,c=(e.min.z-f.z)*h),n>c||o>i)||((o>n||n!==n)&&(n=o),(c=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,di)!==null}intersectTriangle(e,t,n,i,s){Al.subVectors(t,e),pa.subVectors(n,e),El.crossVectors(Al,pa);let r=this.direction.dot(El),o;if(r>0){if(i)return null;o=1}else if(r<0)o=-1,r=-r;else return null;zi.subVectors(this.origin,e);const c=o*this.direction.dot(pa.crossVectors(zi,pa));if(c<0)return null;const l=o*this.direction.dot(Al.cross(zi));if(l<0||c+l>r)return null;const u=-o*zi.dot(El);return u<0?null:this.at(u/r,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Ie{constructor(){Ie.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(e,t,n,i,s,r,o,c,l,u,h,f,d,p,m,g){const x=this.elements;return x[0]=e,x[4]=t,x[8]=n,x[12]=i,x[1]=s,x[5]=r,x[9]=o,x[13]=c,x[2]=l,x[6]=u,x[10]=h,x[14]=f,x[3]=d,x[7]=p,x[11]=m,x[15]=g,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 Ie().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/tr.setFromMatrixColumn(e,0).length(),s=1/tr.setFromMatrixColumn(e,1).length(),r=1/tr.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*r,t[9]=n[9]*r,t[10]=n[10]*r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,s=e.z,r=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const f=r*u,d=r*h,p=o*u,m=o*h;t[0]=c*u,t[4]=-c*h,t[8]=l,t[1]=d+p*l,t[5]=f-m*l,t[9]=-o*c,t[2]=m-f*l,t[6]=p+d*l,t[10]=r*c}else if(e.order==="YXZ"){const f=c*u,d=c*h,p=l*u,m=l*h;t[0]=f+m*o,t[4]=p*o-d,t[8]=r*l,t[1]=r*h,t[5]=r*u,t[9]=-o,t[2]=d*o-p,t[6]=m+f*o,t[10]=r*c}else if(e.order==="ZXY"){const f=c*u,d=c*h,p=l*u,m=l*h;t[0]=f-m*o,t[4]=-r*h,t[8]=p+d*o,t[1]=d+p*o,t[5]=r*u,t[9]=m-f*o,t[2]=-r*l,t[6]=o,t[10]=r*c}else if(e.order==="ZYX"){const f=r*u,d=r*h,p=o*u,m=o*h;t[0]=c*u,t[4]=p*l-d,t[8]=f*l+m,t[1]=c*h,t[5]=m*l+f,t[9]=d*l-p,t[2]=-l,t[6]=o*c,t[10]=r*c}else if(e.order==="YZX"){const f=r*c,d=r*l,p=o*c,m=o*l;t[0]=c*u,t[4]=m-f*h,t[8]=p*h+d,t[1]=h,t[5]=r*u,t[9]=-o*u,t[2]=-l*u,t[6]=d*h+p,t[10]=f-m*h}else if(e.order==="XZY"){const f=r*c,d=r*l,p=o*c,m=o*l;t[0]=c*u,t[4]=-h,t[8]=l*u,t[1]=f*h+m,t[5]=r*u,t[9]=d*h-p,t[2]=p*h-d,t[6]=o*u,t[10]=m*h+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Yg,e,Zg)}lookAt(e,t,n){const i=this.elements;return wn.subVectors(e,t),wn.lengthSq()===0&&(wn.z=1),wn.normalize(),Ui.crossVectors(n,wn),Ui.lengthSq()===0&&(Math.abs(n.z)===1?wn.x+=1e-4:wn.z+=1e-4,wn.normalize(),Ui.crossVectors(n,wn)),Ui.normalize(),ma.crossVectors(wn,Ui),i[0]=Ui.x,i[4]=ma.x,i[8]=wn.x,i[1]=Ui.y,i[5]=ma.y,i[9]=wn.y,i[2]=Ui.z,i[6]=ma.z,i[10]=wn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,r=n[0],o=n[4],c=n[8],l=n[12],u=n[1],h=n[5],f=n[9],d=n[13],p=n[2],m=n[6],g=n[10],x=n[14],y=n[3],b=n[7],v=n[11],S=n[15],A=i[0],R=i[4],_=i[8],L=i[12],N=i[1],B=i[5],W=i[9],K=i[13],z=i[2],q=i[6],O=i[10],Y=i[14],j=i[3],H=i[7],X=i[11],te=i[15];return s[0]=r*A+o*N+c*z+l*j,s[4]=r*R+o*B+c*q+l*H,s[8]=r*_+o*W+c*O+l*X,s[12]=r*L+o*K+c*Y+l*te,s[1]=u*A+h*N+f*z+d*j,s[5]=u*R+h*B+f*q+d*H,s[9]=u*_+h*W+f*O+d*X,s[13]=u*L+h*K+f*Y+d*te,s[2]=p*A+m*N+g*z+x*j,s[6]=p*R+m*B+g*q+x*H,s[10]=p*_+m*W+g*O+x*X,s[14]=p*L+m*K+g*Y+x*te,s[3]=y*A+b*N+v*z+S*j,s[7]=y*R+b*B+v*q+S*H,s[11]=y*_+b*W+v*O+S*X,s[15]=y*L+b*K+v*Y+S*te,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],r=e[1],o=e[5],c=e[9],l=e[13],u=e[2],h=e[6],f=e[10],d=e[14],p=e[3],m=e[7],g=e[11],x=e[15];return p*(+s*c*h-i*l*h-s*o*f+n*l*f+i*o*d-n*c*d)+m*(+t*c*d-t*l*f+s*r*f-i*r*d+i*l*u-s*c*u)+g*(+t*l*h-t*o*d-s*r*h+n*r*d+s*o*u-n*l*u)+x*(-i*o*u-t*c*h+t*o*f+i*r*h-n*r*f+n*c*u)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],o=e[5],c=e[6],l=e[7],u=e[8],h=e[9],f=e[10],d=e[11],p=e[12],m=e[13],g=e[14],x=e[15],y=h*g*l-m*f*l+m*c*d-o*g*d-h*c*x+o*f*x,b=p*f*l-u*g*l-p*c*d+r*g*d+u*c*x-r*f*x,v=u*m*l-p*h*l+p*o*d-r*m*d-u*o*x+r*h*x,S=p*h*c-u*m*c-p*o*f+r*m*f+u*o*g-r*h*g,A=t*y+n*b+i*v+s*S;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const R=1/A;return e[0]=y*R,e[1]=(m*f*s-h*g*s-m*i*d+n*g*d+h*i*x-n*f*x)*R,e[2]=(o*g*s-m*c*s+m*i*l-n*g*l-o*i*x+n*c*x)*R,e[3]=(h*c*s-o*f*s-h*i*l+n*f*l+o*i*d-n*c*d)*R,e[4]=b*R,e[5]=(u*g*s-p*f*s+p*i*d-t*g*d-u*i*x+t*f*x)*R,e[6]=(p*c*s-r*g*s-p*i*l+t*g*l+r*i*x-t*c*x)*R,e[7]=(r*f*s-u*c*s+u*i*l-t*f*l-r*i*d+t*c*d)*R,e[8]=v*R,e[9]=(p*h*s-u*m*s-p*n*d+t*m*d+u*n*x-t*h*x)*R,e[10]=(r*m*s-p*o*s+p*n*l-t*m*l-r*n*x+t*o*x)*R,e[11]=(u*o*s-r*h*s-u*n*l+t*h*l+r*n*d-t*o*d)*R,e[12]=S*R,e[13]=(u*m*i-p*h*i+p*n*f-t*m*f-u*n*g+t*h*g)*R,e[14]=(p*o*i-r*m*i-p*n*c+t*m*c+r*n*g-t*o*g)*R,e[15]=(r*h*i-u*o*i+u*n*c-t*h*c-r*n*f+t*o*f)*R,this}scale(e){const t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),s=1-n,r=e.x,o=e.y,c=e.z,l=s*r,u=s*o;return this.set(l*r+n,l*o-i*c,l*c+i*o,0,l*o+i*c,u*o+n,u*c-i*r,0,l*c-i*o,u*c+i*r,s*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,r){return this.set(1,n,s,0,e,1,r,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,s=t._x,r=t._y,o=t._z,c=t._w,l=s+s,u=r+r,h=o+o,f=s*l,d=s*u,p=s*h,m=r*u,g=r*h,x=o*h,y=c*l,b=c*u,v=c*h,S=n.x,A=n.y,R=n.z;return i[0]=(1-(m+x))*S,i[1]=(d+v)*S,i[2]=(p-b)*S,i[3]=0,i[4]=(d-v)*A,i[5]=(1-(f+x))*A,i[6]=(g+y)*A,i[7]=0,i[8]=(p+b)*R,i[9]=(g-y)*R,i[10]=(1-(f+m))*R,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=tr.set(i[0],i[1],i[2]).length();const r=tr.set(i[4],i[5],i[6]).length(),o=tr.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Un.copy(this);const l=1/s,u=1/r,h=1/o;return Un.elements[0]*=l,Un.elements[1]*=l,Un.elements[2]*=l,Un.elements[4]*=u,Un.elements[5]*=u,Un.elements[6]*=u,Un.elements[8]*=h,Un.elements[9]*=h,Un.elements[10]*=h,t.setFromRotationMatrix(Un),n.x=s,n.y=r,n.z=o,this}makePerspective(e,t,n,i,s,r){const o=this.elements,c=2*s/(t-e),l=2*s/(n-i),u=(t+e)/(t-e),h=(n+i)/(n-i),f=-(r+s)/(r-s),d=-2*r*s/(r-s);return o[0]=c,o[4]=0,o[8]=u,o[12]=0,o[1]=0,o[5]=l,o[9]=h,o[13]=0,o[2]=0,o[6]=0,o[10]=f,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,i,s,r){const o=this.elements,c=1/(t-e),l=1/(n-i),u=1/(r-s),h=(t+e)*c,f=(n+i)*l,d=(r+s)*u;return o[0]=2*c,o[4]=0,o[8]=0,o[12]=-h,o[1]=0,o[5]=2*l,o[9]=0,o[13]=-f,o[2]=0,o[6]=0,o[10]=-2*u,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const tr=new D,Un=new Ie,Yg=new D(0,0,0),Zg=new D(1,1,1),Ui=new D,ma=new D,wn=new D,_f=new Ie,bf=new Pt;class Cn{constructor(e=0,t=0,n=0,i=Cn.DefaultOrder){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,s=i[0],r=i[4],o=i[8],c=i[1],l=i[5],u=i[9],h=i[2],f=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(Ot(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-r,s)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ot(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ot(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-r,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Ot(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-r,l));break;case"YZX":this._z=Math.asin(Ot(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-Ot(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return _f.makeRotationFromQuaternion(e),this.setFromRotationMatrix(_f,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return bf.setFromEuler(this),this.setFromQuaternion(bf,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}toVector3(){console.error("THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead")}}Cn.DefaultOrder="XYZ",Cn.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class ga{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0){i.children=[];for(let o=0;o0){i.animations=[];for(let o=0;o0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),f.length>0&&(n.skeletons=f),d.length>0&&(n.animations=d),p.length>0&&(n.nodes=p)}return n.object=i,n;function r(o){const c=[];for(const l in o){const u=o[l];delete u.metadata,c.push(u)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){Gn.subVectors(i,t),mi.subVectors(n,t),Cl.subVectors(e,t);const r=Gn.dot(Gn),o=Gn.dot(mi),c=Gn.dot(Cl),l=mi.dot(mi),u=mi.dot(Cl),h=r*l-o*o;if(h===0)return s.set(-2,-1,-1);const f=1/h,d=(l*c-o*u)*f,p=(r*u-o*c)*f;return s.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,gi),gi.x>=0&&gi.y>=0&&gi.x+gi.y<=1}static getUV(e,t,n,i,s,r,o,c){return this.getBarycoord(e,t,n,i,gi),c.set(0,0),c.addScaledVector(s,gi.x),c.addScaledVector(r,gi.y),c.addScaledVector(o,gi.z),c}static isFrontFacing(e,t,n,i){return Gn.subVectors(n,t),mi.subVectors(e,t),Gn.cross(mi).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Gn.subVectors(this.c,this.b),mi.subVectors(this.a,this.b),Gn.cross(mi).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(.3333333333333333)}getNormal(e){return Ln.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Ln.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,s){return Ln.getUV(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return Ln.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Ln.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,s=this.c;let r,o;ir.subVectors(i,n),sr.subVectors(s,n),Ll.subVectors(e,n);const c=ir.dot(Ll),l=sr.dot(Ll);if(c<=0&&l<=0)return t.copy(n);Rl.subVectors(e,i);const u=ir.dot(Rl),h=sr.dot(Rl);if(u>=0&&h<=u)return t.copy(i);const f=c*h-u*l;if(f<=0&&c>=0&&u<=0)return r=c/(c-u),t.copy(n).addScaledVector(ir,r);Il.subVectors(e,s);const d=ir.dot(Il),p=sr.dot(Il);if(p>=0&&d<=p)return t.copy(s);const m=d*l-c*p;if(m<=0&&l>=0&&p<=0)return o=l/(l-p),t.copy(n).addScaledVector(sr,o);const g=u*p-d*h;if(g<=0&&h-u>=0&&d-p>=0)return Ef.subVectors(s,i),o=(h-u)/(h-u+(d-p)),t.copy(i).addScaledVector(Ef,o);const x=1/(g+m+f);return r=m*x,o=f*x,t.copy(n).addScaledVector(ir,r).addScaledVector(sr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let e0=0;class Bt extends Zn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:e0++}),this.uuid=bn(),this.name="",this.type="Material",this.blending=rs,this.side=oi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=Gc,this.blendDst=Vc,this.blendEquation=os,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Jo,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=df,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ia,this.stencilZFail=ia,this.stencilZPass=ia,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if(t==="shading"){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=n===xh;continue}const i=this[t];if(i===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==rs&&(n.blending=this.blending),this.side!==oi&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=this.flatShading),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData);function i(s){const r=[];for(const o in s){const c=s[o];delete c.metadata,r.push(c)}return r}if(t){const s=i(e.textures),r=i(e.images);s.length>0&&(n.textures=s),r.length>0&&(n.images=r)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class cn extends Bt{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ve(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=$r,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const qt=new D,xa=new he;class ht{constructor(e,t,n){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n===!0,this.usage=oo,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,s=this.itemSize;i0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const i={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],u=[];for(let h=0,f=l.length;h0&&(i[c]=u,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(e.data.groups=JSON.parse(JSON.stringify(r)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const i=e.attributes;for(const l in i){const u=i[l];this.setAttribute(l,u.clone(t))}const s=e.morphAttributes;for(const l in s){const u=[],h=s[l];for(let f=0,d=h.length;f0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;st.far?null:{distance:l,point:Aa.clone(),object:a}}function Ea(a,e,t,n,i,s,r,o,c,l,u,h){Gi.fromBufferAttribute(i,l),Vi.fromBufferAttribute(i,u),Hi.fromBufferAttribute(i,h);const f=a.morphTargetInfluences;if(s&&f){_a.set(0,0,0),ba.set(0,0,0),wa.set(0,0,0);for(let p=0,m=s.length;p0?1:-1,u.push(H.x,H.y,H.z),h.push(J/R),h.push(1-X/_),Y+=1}}for(let X=0;X<_;X++)for(let te=0;te>8&255]+nn[a>>16&255]+nn[a>>24&255]+"-"+nn[e&255]+nn[e>>8&255]+"-"+nn[e>>16&15|64]+nn[e>>24&255]+"-"+nn[t&63|128]+nn[t>>8&255]+"-"+nn[t>>16&255]+nn[t>>24&255]+nn[n&255]+nn[n>>8&255]+nn[n>>16&255]+nn[n>>24&255]).toLowerCase()}function Ot(a,e,t){return Math.max(e,Math.min(t,a))}function gl(a,e){return(a%e+e)%e}function Eg(a,e,t,n,i){return n+(a-e)*(i-n)/(t-e)}function Cg(a,e,t){return a!==e?(t-a)/(e-a):0}function co(a,e,t){return(1-t)*a+t*e}function Lg(a,e,t,n){return co(a,e,1-Math.exp(-t*n))}function Rg(a,e=1){return e-Math.abs(gl(a,e*2)-e)}function Ig(a,e,t){return a<=e?0:a>=t?1:(a=(a-e)/(t-e),a*a*(3-2*a))}function Pg(a,e,t){return a<=e?0:a>=t?1:(a=(a-e)/(t-e),a*a*a*(a*(a*6-15)+10))}function Dg(a,e){return a+Math.floor(Math.random()*(e-a+1))}function Fg(a,e){return a+Math.random()*(e-a)}function Ng(a){return a*(.5-Math.random())}function kg(a){a!==void 0&&(mf=a);let e=mf+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Og(a){return a*fs}function Bg(a){return a*ao}function yl(a){return(a&a-1)===0&&a!==0}function gf(a){return Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function ra(a){return Math.pow(2,Math.floor(Math.log(a)/Math.LN2))}function zg(a,e,t,n,i){const s=Math.cos,r=Math.sin,o=s(t/2),c=r(t/2),l=s((e+n)/2),u=r((e+n)/2),h=s((e-n)/2),f=r((e-n)/2),d=s((n-e)/2),p=r((n-e)/2);switch(i){case"XYX":a.set(o*u,c*h,c*f,o*l);break;case"YZY":a.set(c*f,o*u,c*h,o*l);break;case"ZXZ":a.set(c*h,c*f,o*u,o*l);break;case"XZX":a.set(o*u,c*p,c*d,o*l);break;case"YXY":a.set(c*d,o*u,c*p,o*l);break;case"ZYZ":a.set(c*p,c*d,o*u,o*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Ug(a,e){switch(e.constructor){case Float32Array:return a;case Uint16Array:return a/65535;case Uint8Array:return a/255;case Int16Array:return Math.max(a/32767,-1);case Int8Array:return Math.max(a/127,-1);default:throw new Error("Invalid component type.")}}function Gg(a,e){switch(e.constructor){case Float32Array:return a;case Uint16Array:return Math.round(a*65535);case Uint8Array:return Math.round(a*255);case Int16Array:return Math.round(a*32767);case Int8Array:return Math.round(a*127);default:throw new Error("Invalid component type.")}}var en=Object.freeze({__proto__:null,DEG2RAD:fs,RAD2DEG:ao,generateUUID:bn,clamp:Ot,euclideanModulo:gl,mapLinear:Eg,inverseLerp:Cg,lerp:co,damp:Lg,pingpong:Rg,smoothstep:Ig,smootherstep:Pg,randInt:Dg,randFloat:Fg,randFloatSpread:Ng,seededRandom:kg,degToRad:Og,radToDeg:Bg,isPowerOfTwo:yl,ceilPowerOfTwo:gf,floorPowerOfTwo:ra,setQuaternionFromProperEuler:zg,normalize:Gg,denormalize:Ug});class fe{constructor(e=0,t=0){fe.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,r=this.y-e.y;return this.x=s*n-r*i+e.x,this.y=s*i+r*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class an{constructor(){an.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(e,t,n,i,s,r,o,c,l){const u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=t,u[4]=s,u[5]=c,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(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,r=n[0],o=n[3],c=n[6],l=n[1],u=n[4],h=n[7],f=n[2],d=n[5],p=n[8],m=i[0],g=i[3],x=i[6],y=i[1],b=i[4],v=i[7],M=i[2],T=i[5],C=i[8];return s[0]=r*m+o*y+c*M,s[3]=r*g+o*b+c*T,s[6]=r*x+o*v+c*C,s[1]=l*m+u*y+h*M,s[4]=l*g+u*b+h*T,s[7]=l*x+u*v+h*C,s[2]=f*m+d*y+p*M,s[5]=f*g+d*b+p*T,s[8]=f*x+d*v+p*C,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],o=e[5],c=e[6],l=e[7],u=e[8];return t*r*u-t*o*l-n*s*u+n*o*c+i*s*l-i*r*c}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],o=e[5],c=e[6],l=e[7],u=e[8],h=u*r-o*l,f=o*c-u*s,d=l*s-r*c,p=t*h+n*f+i*d;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return e[0]=h*m,e[1]=(i*l-u*n)*m,e[2]=(o*n-i*r)*m,e[3]=f*m,e[4]=(u*t-i*c)*m,e[5]=(i*s-o*t)*m,e[6]=d*m,e[7]=(n*c-l*t)*m,e[8]=(r*t-n*s)*m,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,r,o){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*r+l*o)+r+e,-i*l,i*c,-i*(-l*r+c*o)+o+t,0,0,1),this}scale(e,t){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){const t=Math.cos(e),n=Math.sin(e),i=this.elements,s=i[0],r=i[3],o=i[6],c=i[1],l=i[4],u=i[7];return i[0]=t*s+n*c,i[3]=t*r+n*l,i[6]=t*o+n*u,i[1]=-n*s+t*c,i[4]=-n*r+t*l,i[7]=-n*o+t*u,this}translate(e,t){const n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}function yf(a){for(let e=a.length-1;e>=0;--e)if(a[e]>65535)return!0;return!1}const Vg={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Ks(a,e){return new Vg[a](e)}function lo(a){return document.createElementNS("http://www.w3.org/1999/xhtml",a)}function ds(a){return a<.04045?a*.0773993808:Math.pow(a*.9478672986+.0521327014,2.4)}function oa(a){return a<.0031308?a*12.92:1.055*Math.pow(a,.41666)-.055}const xl={[Yn]:{[Ni]:ds},[Ni]:{[Yn]:oa}},An={legacyMode:!0,get workingColorSpace(){return Ni},set workingColorSpace(a){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(a,e,t){if(this.legacyMode||e===t||!e||!t)return a;if(xl[e]&&xl[e][t]!==void 0){const n=xl[e][t];return a.r=n(a.r),a.g=n(a.g),a.b=n(a.b),a}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(a,e){return this.convert(a,this.workingColorSpace,e)},toWorkingColorSpace:function(a,e){return this.convert(a,e,this.workingColorSpace)}},xf={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},Yt={r:0,g:0,b:0},zn={h:0,s:0,l:0},aa={h:0,s:0,l:0};function vl(a,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<.16666666666666666?a+(e-a)*6*t:t<.5?e:t<.6666666666666666?a+(e-a)*6*(.6666666666666666-t):a}function ca(a,e){return e.r=a.r,e.g=a.g,e.b=a.b,e}class be{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,t===void 0&&n===void 0?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Yn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,An.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=Ni){return this.r=e,this.g=t,this.b=n,An.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=Ni){if(e=gl(e,1),t=Ot(t,0,1),n=Ot(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,r=2*n-s;this.r=vl(r,s,e+.3333333333333333),this.g=vl(r,s,e),this.b=vl(r,s,e-.3333333333333333)}return An.toWorkingColorSpace(this,i),this}setStyle(e,t=Yn){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let s;const 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 this.r=Math.min(255,parseInt(s[1],10))/255,this.g=Math.min(255,parseInt(s[2],10))/255,this.b=Math.min(255,parseInt(s[3],10))/255,An.toWorkingColorSpace(this,t),n(s[4]),this;if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(s[1],10))/100,this.g=Math.min(100,parseInt(s[2],10))/100,this.b=Math.min(100,parseInt(s[3],10))/100,An.toWorkingColorSpace(this,t),n(s[4]),this;break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)){const c=parseFloat(s[1])/360,l=parseInt(s[2],10)/100,u=parseInt(s[3],10)/100;return n(s[4]),this.setHSL(c,l,u,t)}break}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],r=s.length;if(r===3)return this.r=parseInt(s.charAt(0)+s.charAt(0),16)/255,this.g=parseInt(s.charAt(1)+s.charAt(1),16)/255,this.b=parseInt(s.charAt(2)+s.charAt(2),16)/255,An.toWorkingColorSpace(this,t),this;if(r===6)return this.r=parseInt(s.charAt(0)+s.charAt(1),16)/255,this.g=parseInt(s.charAt(2)+s.charAt(3),16)/255,this.b=parseInt(s.charAt(4)+s.charAt(5),16)/255,An.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=Yn){const n=xf[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ds(e.r),this.g=ds(e.g),this.b=ds(e.b),this}copyLinearToSRGB(e){return this.r=oa(e.r),this.g=oa(e.g),this.b=oa(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Yn){return An.fromWorkingColorSpace(ca(this,Yt),e),Ot(Yt.r*255,0,255)<<16^Ot(Yt.g*255,0,255)<<8^Ot(Yt.b*255,0,255)<<0}getHexString(e=Yn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ni){An.fromWorkingColorSpace(ca(this,Yt),t);const n=Yt.r,i=Yt.g,s=Yt.b,r=Math.max(n,i,s),o=Math.min(n,i,s);let c,l;const u=(o+r)/2;if(o===r)c=0,l=0;else{const h=r-o;switch(l=u<=.5?h/(r+o):h/(2-r-o),r){case n:c=(i-s)/h+(i2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap){const t=lo("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let r=0;r1)switch(this.wrapS){case on:e.x=e.x-Math.floor(e.x);break;case Wt:e.x=e.x<0?0:1;break;case js:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case on:e.y=e.y-Math.floor(e.y);break;case Wt:e.y=e.y<0?0:1;break;case js:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}}Mt.DEFAULT_IMAGE=null,Mt.DEFAULT_MAPPING=$o;class ht{constructor(e=0,t=0,n=0,i=1){ht.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=this.w,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i+r[12]*s,this.y=r[1]*t+r[5]*n+r[9]*i+r[13]*s,this.z=r[2]*t+r[6]*n+r[10]*i+r[14]*s,this.w=r[3]*t+r[7]*n+r[11]*i+r[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,s;const c=e.elements,l=c[0],u=c[4],h=c[8],f=c[1],d=c[5],p=c[9],m=c[2],g=c[6],x=c[10];if(Math.abs(u-f)<.01&&Math.abs(h-m)<.01&&Math.abs(p-g)<.01){if(Math.abs(u+f)<.1&&Math.abs(h+m)<.1&&Math.abs(p+g)<.1&&Math.abs(l+d+x-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(l+1)/2,v=(d+1)/2,M=(x+1)/2,T=(u+f)/4,C=(h+m)/4,_=(p+g)/4;return b>v&&b>M?b<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(b),i=T/n,s=C/n):v>M?v<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(v),n=T/i,s=_/i):M<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(M),n=C/s,i=_/s),this.set(n,i,s,t),this}let y=Math.sqrt((g-p)*(g-p)+(h-m)*(h-m)+(f-u)*(f-u));return Math.abs(y)<.001&&(y=1),this.x=(g-p)/y,this.y=(h-m)/y,this.z=(f-u)/y,this.w=Math.acos((l+d+x-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class En extends Zn{constructor(e,t,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new ht(0,0,e,t),this.scissorTest=!1,this.viewport=new ht(0,0,e,t);const i={width:e,height:t,depth:1};this.texture=new Mt(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.internalFormat=n.internalFormat!==void 0?n.internalFormat:null,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:Et,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null,this.samples=n.samples!==void 0?n.samples:0}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new ps(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class uo extends Mt{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=kt,this.minFilter=kt,this.wrapR=Wt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Wg extends En{constructor(e,t,n){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new uo(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class la extends Mt{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=kt,this.minFilter=kt,this.wrapR=Wt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class qg extends En{constructor(e,t,n){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new la(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class Xg extends En{constructor(e,t,n,i={}){super(e,t,i),this.isWebGLMultipleRenderTargets=!0;const s=this.texture;this.texture=[];for(let r=0;r=0?1:-1,b=1-x*x;if(b>Number.EPSILON){const M=Math.sqrt(b),T=Math.atan2(M,x*y);g=Math.sin(g*T)/M,o=Math.sin(o*T)/M}const v=o*y;if(c=c*g+f*v,l=l*g+d*v,u=u*g+p*v,h=h*g+m*v,g===1-o){const M=1/Math.sqrt(c*c+l*l+u*u+h*h);c*=M,l*=M,u*=M,h*=M}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,s,r){const o=n[i],c=n[i+1],l=n[i+2],u=n[i+3],h=s[r],f=s[r+1],d=s[r+2],p=s[r+3];return e[t]=o*p+u*h+c*d-l*f,e[t+1]=c*p+u*f+l*h-o*d,e[t+2]=l*p+u*d+o*f-c*h,e[t+3]=u*p-o*h-c*f-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!(e&&e.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=e._x,i=e._y,s=e._z,r=e._order,o=Math.cos,c=Math.sin,l=o(n/2),u=o(i/2),h=o(s/2),f=c(n/2),d=c(i/2),p=c(s/2);switch(r){case"XYZ":this._x=f*u*h+l*d*p,this._y=l*d*h-f*u*p,this._z=l*u*p+f*d*h,this._w=l*u*h-f*d*p;break;case"YXZ":this._x=f*u*h+l*d*p,this._y=l*d*h-f*u*p,this._z=l*u*p-f*d*h,this._w=l*u*h+f*d*p;break;case"ZXY":this._x=f*u*h-l*d*p,this._y=l*d*h+f*u*p,this._z=l*u*p+f*d*h,this._w=l*u*h-f*d*p;break;case"ZYX":this._x=f*u*h-l*d*p,this._y=l*d*h+f*u*p,this._z=l*u*p-f*d*h,this._w=l*u*h+f*d*p;break;case"YZX":this._x=f*u*h+l*d*p,this._y=l*d*h+f*u*p,this._z=l*u*p-f*d*h,this._w=l*u*h-f*d*p;break;case"XZY":this._x=f*u*h-l*d*p,this._y=l*d*h-f*u*p,this._z=l*u*p+f*d*h,this._w=l*u*h+f*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],s=t[8],r=t[1],o=t[5],c=t[9],l=t[2],u=t[6],h=t[10],f=n+o+h;if(f>0){const d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(u-c)*d,this._y=(s-l)*d,this._z=(r-i)*d}else if(n>o&&n>h){const d=2*Math.sqrt(1+n-o-h);this._w=(u-c)/d,this._x=.25*d,this._y=(i+r)/d,this._z=(s+l)/d}else if(o>h){const d=2*Math.sqrt(1+o-n-h);this._w=(s-l)/d,this._x=(i+r)/d,this._y=.25*d,this._z=(c+u)/d}else{const d=2*Math.sqrt(1+h-n-o);this._w=(r-i)/d,this._x=(s+l)/d,this._y=(c+u)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ot(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,s=e._z,r=e._w,o=t._x,c=t._y,l=t._z,u=t._w;return this._x=n*u+r*o+i*l-s*c,this._y=i*u+r*c+s*o-n*l,this._z=s*u+r*l+n*c-i*o,this._w=r*u-n*o-i*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,r=this._w;let o=r*e._w+n*e._x+i*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=r,this._x=n,this._y=i,this._z=s,this;const c=1-o*o;if(c<=Number.EPSILON){const d=1-t;return this._w=d*r+t*this._w,this._x=d*n+t*this._x,this._y=d*i+t*this._y,this._z=d*s+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(c),u=Math.atan2(l,o),h=Math.sin((1-t)*u)/l,f=Math.sin(t*u)/l;return this._w=r*h+this._w*f,this._x=n*h+this._x*f,this._y=i*h+this._y*f,this._z=s*h+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(s),n*Math.cos(s),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class P{constructor(e=0,t=0,n=0){P.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(vf.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(vf.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=e.elements,r=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*r,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*r,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*r,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,s=e.x,r=e.y,o=e.z,c=e.w,l=c*t+r*i-o*n,u=c*n+o*t-s*i,h=c*i+s*n-r*t,f=-s*t-r*n-o*i;return this.x=l*c+f*-s+u*-o-h*-r,this.y=u*c+f*-r+h*-s-l*-o,this.z=h*c+f*-o+l*-r-u*-s,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,s=e.z,r=t.x,o=t.y,c=t.z;return this.x=i*c-s*o,this.y=s*r-n*c,this.z=n*o-i*r,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return wl.copy(this).projectOnVector(e),this.sub(wl)}reflect(e){return this.sub(wl.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Ot(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const wl=new P,vf=new Pt;class hi{constructor(e=new P(1/0,1/0,1/0),t=new P(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,n=1/0,i=1/0,s=-1/0,r=-1/0,o=-1/0;for(let c=0,l=e.length;cs&&(s=u),h>r&&(r=h),f>o&&(o=f)}return this.min.set(t,n,i),this.max.set(s,r,o),this}setFromBufferAttribute(e){let t=1/0,n=1/0,i=1/0,s=-1/0,r=-1/0,o=-1/0;for(let c=0,l=e.count;cs&&(s=u),h>r&&(r=h),f>o&&(o=f)}return this.min.set(t,n,i),this.max.set(s,r,o),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,ms),ms.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ho),ua.subVectors(this.max,ho),$s.subVectors(e.a,ho),Qs.subVectors(e.b,ho),er.subVectors(e.c,ho),ki.subVectors(Qs,$s),Oi.subVectors(er,Qs),gs.subVectors($s,er);let t=[0,-ki.z,ki.y,0,-Oi.z,Oi.y,0,-gs.z,gs.y,ki.z,0,-ki.x,Oi.z,0,-Oi.x,gs.z,0,-gs.x,-ki.y,ki.x,0,-Oi.y,Oi.x,0,-gs.y,gs.x,0];return!Sl(t,$s,Qs,er,ua)||(t=[1,0,0,0,1,0,0,0,1],!Sl(t,$s,Qs,er,ua))?!1:(ha.crossVectors(ki,Oi),t=[ha.x,ha.y,ha.z],Sl(t,$s,Qs,er,ua))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return ms.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(ms).length()*.5,e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(fi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),fi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),fi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),fi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),fi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),fi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),fi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),fi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(fi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const fi=[new P,new P,new P,new P,new P,new P,new P,new P],ms=new P,Ml=new hi,$s=new P,Qs=new P,er=new P,ki=new P,Oi=new P,gs=new P,ho=new P,ua=new P,ha=new P,ys=new P;function Sl(a,e,t,n,i){for(let s=0,r=a.length-3;s<=r;s+=3){ys.fromArray(a,s);const o=i.x*Math.abs(ys.x)+i.y*Math.abs(ys.y)+i.z*Math.abs(ys.z),c=e.dot(ys),l=t.dot(ys),u=n.dot(ys);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>o)return!1}return!0}const jg=new hi,_f=new P,fa=new P,Tl=new P;class Bi{constructor(e=new P,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):jg.setFromPoints(e).getCenter(n);let i=0;for(let s=0,r=e.length;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){Tl.subVectors(e,this.center);const t=Tl.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.add(Tl.multiplyScalar(i/n)),this.radius+=i}return this}union(e){return this.center.equals(e.center)===!0?fa.set(0,0,1).multiplyScalar(e.radius):fa.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(_f.copy(e.center).add(fa)),this.expandByPoint(_f.copy(e.center).sub(fa)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const di=new P,Al=new P,da=new P,zi=new P,El=new P,pa=new P,Cl=new P;class fo{constructor(e=new P,t=new P(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,di)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=di.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(di.copy(this.direction).multiplyScalar(t).add(this.origin),di.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Al.copy(e).add(t).multiplyScalar(.5),da.copy(t).sub(e).normalize(),zi.copy(this.origin).sub(Al);const s=e.distanceTo(t)*.5,r=-this.direction.dot(da),o=zi.dot(this.direction),c=-zi.dot(da),l=zi.lengthSq(),u=Math.abs(1-r*r);let h,f,d,p;if(u>0)if(h=r*c-o,f=r*o-c,p=s*u,h>=0)if(f>=-p)if(f<=p){const m=1/u;h*=m,f*=m,d=h*(h+r*f+2*o)+f*(r*h+f+2*c)+l}else f=s,h=Math.max(0,-(r*f+o)),d=-h*h+f*(f+2*c)+l;else f=-s,h=Math.max(0,-(r*f+o)),d=-h*h+f*(f+2*c)+l;else f<=-p?(h=Math.max(0,-(-r*s+o)),f=h>0?-s:Math.min(Math.max(-s,-c),s),d=-h*h+f*(f+2*c)+l):f<=p?(h=0,f=Math.min(Math.max(-s,-c),s),d=f*(f+2*c)+l):(h=Math.max(0,-(r*s+o)),f=h>0?s:Math.min(Math.max(-s,-c),s),d=-h*h+f*(f+2*c)+l);else f=r>0?-s:s,h=Math.max(0,-(r*f+o)),d=-h*h+f*(f+2*c)+l;return n&&n.copy(this.direction).multiplyScalar(h).add(this.origin),i&&i.copy(da).multiplyScalar(f).add(Al),d}intersectSphere(e,t){di.subVectors(e.center,this.origin);const n=di.dot(this.direction),i=di.dot(di)-n*n,s=e.radius*e.radius;if(i>s)return null;const r=Math.sqrt(s-i),o=n-r,c=n+r;return o<0&&c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,r,o,c;const l=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,f=this.origin;return l>=0?(n=(e.min.x-f.x)*l,i=(e.max.x-f.x)*l):(n=(e.max.x-f.x)*l,i=(e.min.x-f.x)*l),u>=0?(s=(e.min.y-f.y)*u,r=(e.max.y-f.y)*u):(s=(e.max.y-f.y)*u,r=(e.min.y-f.y)*u),n>r||s>i||((s>n||n!==n)&&(n=s),(r=0?(o=(e.min.z-f.z)*h,c=(e.max.z-f.z)*h):(o=(e.max.z-f.z)*h,c=(e.min.z-f.z)*h),n>c||o>i)||((o>n||n!==n)&&(n=o),(c=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,di)!==null}intersectTriangle(e,t,n,i,s){El.subVectors(t,e),pa.subVectors(n,e),Cl.crossVectors(El,pa);let r=this.direction.dot(Cl),o;if(r>0){if(i)return null;o=1}else if(r<0)o=-1,r=-r;else return null;zi.subVectors(this.origin,e);const c=o*this.direction.dot(pa.crossVectors(zi,pa));if(c<0)return null;const l=o*this.direction.dot(El.cross(zi));if(l<0||c+l>r)return null;const u=-o*zi.dot(Cl);return u<0?null:this.at(u/r,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Pe{constructor(){Pe.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(e,t,n,i,s,r,o,c,l,u,h,f,d,p,m,g){const x=this.elements;return x[0]=e,x[4]=t,x[8]=n,x[12]=i,x[1]=s,x[5]=r,x[9]=o,x[13]=c,x[2]=l,x[6]=u,x[10]=h,x[14]=f,x[3]=d,x[7]=p,x[11]=m,x[15]=g,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 Pe().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/tr.setFromMatrixColumn(e,0).length(),s=1/tr.setFromMatrixColumn(e,1).length(),r=1/tr.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*r,t[9]=n[9]*r,t[10]=n[10]*r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,s=e.z,r=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const f=r*u,d=r*h,p=o*u,m=o*h;t[0]=c*u,t[4]=-c*h,t[8]=l,t[1]=d+p*l,t[5]=f-m*l,t[9]=-o*c,t[2]=m-f*l,t[6]=p+d*l,t[10]=r*c}else if(e.order==="YXZ"){const f=c*u,d=c*h,p=l*u,m=l*h;t[0]=f+m*o,t[4]=p*o-d,t[8]=r*l,t[1]=r*h,t[5]=r*u,t[9]=-o,t[2]=d*o-p,t[6]=m+f*o,t[10]=r*c}else if(e.order==="ZXY"){const f=c*u,d=c*h,p=l*u,m=l*h;t[0]=f-m*o,t[4]=-r*h,t[8]=p+d*o,t[1]=d+p*o,t[5]=r*u,t[9]=m-f*o,t[2]=-r*l,t[6]=o,t[10]=r*c}else if(e.order==="ZYX"){const f=r*u,d=r*h,p=o*u,m=o*h;t[0]=c*u,t[4]=p*l-d,t[8]=f*l+m,t[1]=c*h,t[5]=m*l+f,t[9]=d*l-p,t[2]=-l,t[6]=o*c,t[10]=r*c}else if(e.order==="YZX"){const f=r*c,d=r*l,p=o*c,m=o*l;t[0]=c*u,t[4]=m-f*h,t[8]=p*h+d,t[1]=h,t[5]=r*u,t[9]=-o*u,t[2]=-l*u,t[6]=d*h+p,t[10]=f-m*h}else if(e.order==="XZY"){const f=r*c,d=r*l,p=o*c,m=o*l;t[0]=c*u,t[4]=-h,t[8]=l*u,t[1]=f*h+m,t[5]=r*u,t[9]=d*h-p,t[2]=p*h-d,t[6]=o*u,t[10]=m*h+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Yg,e,Zg)}lookAt(e,t,n){const i=this.elements;return wn.subVectors(e,t),wn.lengthSq()===0&&(wn.z=1),wn.normalize(),Ui.crossVectors(n,wn),Ui.lengthSq()===0&&(Math.abs(n.z)===1?wn.x+=1e-4:wn.z+=1e-4,wn.normalize(),Ui.crossVectors(n,wn)),Ui.normalize(),ma.crossVectors(wn,Ui),i[0]=Ui.x,i[4]=ma.x,i[8]=wn.x,i[1]=Ui.y,i[5]=ma.y,i[9]=wn.y,i[2]=Ui.z,i[6]=ma.z,i[10]=wn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,r=n[0],o=n[4],c=n[8],l=n[12],u=n[1],h=n[5],f=n[9],d=n[13],p=n[2],m=n[6],g=n[10],x=n[14],y=n[3],b=n[7],v=n[11],M=n[15],T=i[0],C=i[4],_=i[8],E=i[12],F=i[1],U=i[5],q=i[9],J=i[13],G=i[2],X=i[6],B=i[10],Z=i[14],Y=i[3],W=i[7],j=i[11],ne=i[15];return s[0]=r*T+o*F+c*G+l*Y,s[4]=r*C+o*U+c*X+l*W,s[8]=r*_+o*q+c*B+l*j,s[12]=r*E+o*J+c*Z+l*ne,s[1]=u*T+h*F+f*G+d*Y,s[5]=u*C+h*U+f*X+d*W,s[9]=u*_+h*q+f*B+d*j,s[13]=u*E+h*J+f*Z+d*ne,s[2]=p*T+m*F+g*G+x*Y,s[6]=p*C+m*U+g*X+x*W,s[10]=p*_+m*q+g*B+x*j,s[14]=p*E+m*J+g*Z+x*ne,s[3]=y*T+b*F+v*G+M*Y,s[7]=y*C+b*U+v*X+M*W,s[11]=y*_+b*q+v*B+M*j,s[15]=y*E+b*J+v*Z+M*ne,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],r=e[1],o=e[5],c=e[9],l=e[13],u=e[2],h=e[6],f=e[10],d=e[14],p=e[3],m=e[7],g=e[11],x=e[15];return p*(+s*c*h-i*l*h-s*o*f+n*l*f+i*o*d-n*c*d)+m*(+t*c*d-t*l*f+s*r*f-i*r*d+i*l*u-s*c*u)+g*(+t*l*h-t*o*d-s*r*h+n*r*d+s*o*u-n*l*u)+x*(-i*o*u-t*c*h+t*o*f+i*r*h-n*r*f+n*c*u)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],r=e[4],o=e[5],c=e[6],l=e[7],u=e[8],h=e[9],f=e[10],d=e[11],p=e[12],m=e[13],g=e[14],x=e[15],y=h*g*l-m*f*l+m*c*d-o*g*d-h*c*x+o*f*x,b=p*f*l-u*g*l-p*c*d+r*g*d+u*c*x-r*f*x,v=u*m*l-p*h*l+p*o*d-r*m*d-u*o*x+r*h*x,M=p*h*c-u*m*c-p*o*f+r*m*f+u*o*g-r*h*g,T=t*y+n*b+i*v+s*M;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/T;return e[0]=y*C,e[1]=(m*f*s-h*g*s-m*i*d+n*g*d+h*i*x-n*f*x)*C,e[2]=(o*g*s-m*c*s+m*i*l-n*g*l-o*i*x+n*c*x)*C,e[3]=(h*c*s-o*f*s-h*i*l+n*f*l+o*i*d-n*c*d)*C,e[4]=b*C,e[5]=(u*g*s-p*f*s+p*i*d-t*g*d-u*i*x+t*f*x)*C,e[6]=(p*c*s-r*g*s-p*i*l+t*g*l+r*i*x-t*c*x)*C,e[7]=(r*f*s-u*c*s+u*i*l-t*f*l-r*i*d+t*c*d)*C,e[8]=v*C,e[9]=(p*h*s-u*m*s-p*n*d+t*m*d+u*n*x-t*h*x)*C,e[10]=(r*m*s-p*o*s+p*n*l-t*m*l-r*n*x+t*o*x)*C,e[11]=(u*o*s-r*h*s-u*n*l+t*h*l+r*n*d-t*o*d)*C,e[12]=M*C,e[13]=(u*m*i-p*h*i+p*n*f-t*m*f-u*n*g+t*h*g)*C,e[14]=(p*o*i-r*m*i-p*n*c+t*m*c+r*n*g-t*o*g)*C,e[15]=(r*h*i-u*o*i+u*n*c-t*h*c-r*n*f+t*o*f)*C,this}scale(e){const t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),s=1-n,r=e.x,o=e.y,c=e.z,l=s*r,u=s*o;return this.set(l*r+n,l*o-i*c,l*c+i*o,0,l*o+i*c,u*o+n,u*c-i*r,0,l*c-i*o,u*c+i*r,s*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,r){return this.set(1,n,s,0,e,1,r,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,s=t._x,r=t._y,o=t._z,c=t._w,l=s+s,u=r+r,h=o+o,f=s*l,d=s*u,p=s*h,m=r*u,g=r*h,x=o*h,y=c*l,b=c*u,v=c*h,M=n.x,T=n.y,C=n.z;return i[0]=(1-(m+x))*M,i[1]=(d+v)*M,i[2]=(p-b)*M,i[3]=0,i[4]=(d-v)*T,i[5]=(1-(f+x))*T,i[6]=(g+y)*T,i[7]=0,i[8]=(p+b)*C,i[9]=(g-y)*C,i[10]=(1-(f+m))*C,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=tr.set(i[0],i[1],i[2]).length();const r=tr.set(i[4],i[5],i[6]).length(),o=tr.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Un.copy(this);const l=1/s,u=1/r,h=1/o;return Un.elements[0]*=l,Un.elements[1]*=l,Un.elements[2]*=l,Un.elements[4]*=u,Un.elements[5]*=u,Un.elements[6]*=u,Un.elements[8]*=h,Un.elements[9]*=h,Un.elements[10]*=h,t.setFromRotationMatrix(Un),n.x=s,n.y=r,n.z=o,this}makePerspective(e,t,n,i,s,r){const o=this.elements,c=2*s/(t-e),l=2*s/(n-i),u=(t+e)/(t-e),h=(n+i)/(n-i),f=-(r+s)/(r-s),d=-2*r*s/(r-s);return o[0]=c,o[4]=0,o[8]=u,o[12]=0,o[1]=0,o[5]=l,o[9]=h,o[13]=0,o[2]=0,o[6]=0,o[10]=f,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,i,s,r){const o=this.elements,c=1/(t-e),l=1/(n-i),u=1/(r-s),h=(t+e)*c,f=(n+i)*l,d=(r+s)*u;return o[0]=2*c,o[4]=0,o[8]=0,o[12]=-h,o[1]=0,o[5]=2*l,o[9]=0,o[13]=-f,o[2]=0,o[6]=0,o[10]=-2*u,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const tr=new P,Un=new Pe,Yg=new P(0,0,0),Zg=new P(1,1,1),Ui=new P,ma=new P,wn=new P,bf=new Pe,wf=new Pt;class Cn{constructor(e=0,t=0,n=0,i=Cn.DefaultOrder){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,s=i[0],r=i[4],o=i[8],c=i[1],l=i[5],u=i[9],h=i[2],f=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(Ot(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-r,s)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ot(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ot(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-r,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Ot(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-r,l));break;case"YZX":this._z=Math.asin(Ot(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-Ot(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return bf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(bf,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return wf.setFromEuler(this),this.setFromQuaternion(wf,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}toVector3(){console.error("THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead")}}Cn.DefaultOrder="XYZ",Cn.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class ga{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0){i.children=[];for(let o=0;o0){i.animations=[];for(let o=0;o0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),f.length>0&&(n.skeletons=f),d.length>0&&(n.animations=d),p.length>0&&(n.nodes=p)}return n.object=i,n;function r(o){const c=[];for(const l in o){const u=o[l];delete u.metadata,c.push(u)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){Gn.subVectors(i,t),mi.subVectors(n,t),Ll.subVectors(e,t);const r=Gn.dot(Gn),o=Gn.dot(mi),c=Gn.dot(Ll),l=mi.dot(mi),u=mi.dot(Ll),h=r*l-o*o;if(h===0)return s.set(-2,-1,-1);const f=1/h,d=(l*c-o*u)*f,p=(r*u-o*c)*f;return s.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,gi),gi.x>=0&&gi.y>=0&&gi.x+gi.y<=1}static getUV(e,t,n,i,s,r,o,c){return this.getBarycoord(e,t,n,i,gi),c.set(0,0),c.addScaledVector(s,gi.x),c.addScaledVector(r,gi.y),c.addScaledVector(o,gi.z),c}static isFrontFacing(e,t,n,i){return Gn.subVectors(n,t),mi.subVectors(e,t),Gn.cross(mi).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Gn.subVectors(this.c,this.b),mi.subVectors(this.a,this.b),Gn.cross(mi).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(.3333333333333333)}getNormal(e){return Ln.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Ln.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,s){return Ln.getUV(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return Ln.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Ln.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,s=this.c;let r,o;ir.subVectors(i,n),sr.subVectors(s,n),Rl.subVectors(e,n);const c=ir.dot(Rl),l=sr.dot(Rl);if(c<=0&&l<=0)return t.copy(n);Il.subVectors(e,i);const u=ir.dot(Il),h=sr.dot(Il);if(u>=0&&h<=u)return t.copy(i);const f=c*h-u*l;if(f<=0&&c>=0&&u<=0)return r=c/(c-u),t.copy(n).addScaledVector(ir,r);Pl.subVectors(e,s);const d=ir.dot(Pl),p=sr.dot(Pl);if(p>=0&&d<=p)return t.copy(s);const m=d*l-c*p;if(m<=0&&l>=0&&p<=0)return o=l/(l-p),t.copy(n).addScaledVector(sr,o);const g=u*p-d*h;if(g<=0&&h-u>=0&&d-p>=0)return Cf.subVectors(s,i),o=(h-u)/(h-u+(d-p)),t.copy(i).addScaledVector(Cf,o);const x=1/(g+m+f);return r=m*x,o=f*x,t.copy(n).addScaledVector(ir,r).addScaledVector(sr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let e0=0;class Bt extends Zn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:e0++}),this.uuid=bn(),this.name="",this.type="Material",this.blending=rs,this.side=oi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=Vc,this.blendDst=Hc,this.blendEquation=os,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Jo,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=pf,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ia,this.stencilZFail=ia,this.stencilZPass=ia,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if(t==="shading"){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=n===vh;continue}const i=this[t];if(i===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==rs&&(n.blending=this.blending),this.side!==oi&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=this.flatShading),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData);function i(s){const r=[];for(const o in s){const c=s[o];delete c.metadata,r.push(c)}return r}if(t){const s=i(e.textures),r=i(e.images);s.length>0&&(n.textures=s),r.length>0&&(n.images=r)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class cn extends Bt{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new be(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=$r,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const qt=new P,xa=new fe;class ft{constructor(e,t,n){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n===!0,this.usage=oo,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,s=this.itemSize;i0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const i={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],u=[];for(let h=0,f=l.length;h0&&(i[c]=u,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(e.data.groups=JSON.parse(JSON.stringify(r)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const i=e.attributes;for(const l in i){const u=i[l];this.setAttribute(l,u.clone(t))}const s=e.morphAttributes;for(const l in s){const u=[],h=s[l];for(let f=0,d=h.length;f0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;st.far?null:{distance:l,point:Aa.clone(),object:a}}function Ea(a,e,t,n,i,s,r,o,c,l,u,h){Gi.fromBufferAttribute(i,l),Vi.fromBufferAttribute(i,u),Hi.fromBufferAttribute(i,h);const f=a.morphTargetInfluences;if(s&&f){_a.set(0,0,0),ba.set(0,0,0),wa.set(0,0,0);for(let p=0,m=s.length;p0?1:-1,u.push(W.x,W.y,W.z),h.push($/C),h.push(1-j/_),Z+=1}}for(let j=0;j<_;j++)for(let ne=0;ne0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Ca extends ct{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ie,this.projectionMatrix=new Ie,this.projectionMatrixInverse=new Ie}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class Dt extends Ca{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=ao*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(fs*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ao*2*Math.atan(Math.tan(fs*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,s,r){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(fs*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-.5*i;const r=this.view;if(this.view!==null&&this.view.enabled){const c=r.fullWidth,l=r.fullHeight;s+=r.offsetX*i/c,t-=r.offsetY*n/l,i*=r.width/c,n*=r.height/l}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,t,t-n,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const cr=90,lr=1;class Rf extends ct{constructor(e,t,n){if(super(),this.type="CubeCamera",n.isWebGLCubeRenderTarget!==!0){console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");return}this.renderTarget=n;const i=new Dt(cr,lr,e,t);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new D(1,0,0)),this.add(i);const s=new Dt(cr,lr,e,t);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new D(-1,0,0)),this.add(s);const r=new Dt(cr,lr,e,t);r.layers=this.layers,r.up.set(0,0,1),r.lookAt(new D(0,1,0)),this.add(r);const o=new Dt(cr,lr,e,t);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new D(0,-1,0)),this.add(o);const c=new Dt(cr,lr,e,t);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new D(0,0,1)),this.add(c);const l=new Dt(cr,lr,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new D(0,0,-1)),this.add(l)}update(e,t){this.parent===null&&this.updateMatrixWorld();const n=this.renderTarget,[i,s,r,o,c,l]=this.children,u=e.getRenderTarget(),h=e.toneMapping,f=e.xr.enabled;e.toneMapping=Xn,e.xr.enabled=!1;const d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,s),e.setRenderTarget(n,2),e.render(t,r),e.setRenderTarget(n,3),e.render(t,o),e.setRenderTarget(n,4),e.render(t,c),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(u),e.toneMapping=h,e.xr.enabled=f,n.texture.needsPMREMUpdate=!0}}class go extends Mt{constructor(e,t,n,i,s,r,o,c,l,u){e=e!==void 0?e:[],t=t!==void 0?t:Li,super(e,t,n,i,s,r,o,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class If extends En{constructor(e,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new go(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Et}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` +}`;class Kn extends Bt{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=h0,this.fragmentShader=f0,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&(e.attributes!==void 0&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=ar(e.uniforms),this.uniformsGroups=u0(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const r=this.uniforms[i].value;r&&r.isTexture?t.uniforms[i]={type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[i]={type:"c",value:r.getHex()}:r&&r.isVector2?t.uniforms[i]={type:"v2",value:r.toArray()}:r&&r.isVector3?t.uniforms[i]={type:"v3",value:r.toArray()}:r&&r.isVector4?t.uniforms[i]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?t.uniforms[i]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?t.uniforms[i]={type:"m4",value:r.toArray()}:t.uniforms[i]={value:r}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Ca extends lt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Pe,this.projectionMatrix=new Pe,this.projectionMatrixInverse=new Pe}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class Dt extends Ca{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=ao*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(fs*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ao*2*Math.atan(Math.tan(fs*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,s,r){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(fs*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-.5*i;const r=this.view;if(this.view!==null&&this.view.enabled){const c=r.fullWidth,l=r.fullHeight;s+=r.offsetX*i/c,t-=r.offsetY*n/l,i*=r.width/c,n*=r.height/l}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,t,t-n,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const cr=90,lr=1;class If extends lt{constructor(e,t,n){if(super(),this.type="CubeCamera",n.isWebGLCubeRenderTarget!==!0){console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");return}this.renderTarget=n;const i=new Dt(cr,lr,e,t);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new P(1,0,0)),this.add(i);const s=new Dt(cr,lr,e,t);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new P(-1,0,0)),this.add(s);const r=new Dt(cr,lr,e,t);r.layers=this.layers,r.up.set(0,0,1),r.lookAt(new P(0,1,0)),this.add(r);const o=new Dt(cr,lr,e,t);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new P(0,-1,0)),this.add(o);const c=new Dt(cr,lr,e,t);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new P(0,0,1)),this.add(c);const l=new Dt(cr,lr,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new P(0,0,-1)),this.add(l)}update(e,t){this.parent===null&&this.updateMatrixWorld();const n=this.renderTarget,[i,s,r,o,c,l]=this.children,u=e.getRenderTarget(),h=e.toneMapping,f=e.xr.enabled;e.toneMapping=Xn,e.xr.enabled=!1;const d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,s),e.setRenderTarget(n,2),e.render(t,r),e.setRenderTarget(n,3),e.render(t,o),e.setRenderTarget(n,4),e.render(t,c),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(u),e.toneMapping=h,e.xr.enabled=f,n.texture.needsPMREMUpdate=!0}}class go extends Mt{constructor(e,t,n,i,s,r,o,c,l,u){e=e!==void 0?e:[],t=t!==void 0?t:Li,super(e,t,n,i,s,r,o,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Pf extends En{constructor(e,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new go(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Et}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; @@ -41,7 +41,7 @@ var vue3dLoader=function(Jr,Nt){"use strict";/** gl_FragColor = texture2D( tEquirect, sampleUV ); } - `},i=new yi(5,5,5),s=new Kn({name:"CubemapFromEquirect",uniforms:ar(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Tn,blending:ci});s.uniforms.tEquirect.value=t;const r=new St(i,s),o=t.minFilter;return t.minFilter===jn&&(t.minFilter=Et),new Rf(1,10,this).update(e,r),t.minFilter=o,r.geometry.dispose(),r.material.dispose(),this}clear(e,t,n,i){const s=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(s)}}const zl=new D,d0=new D,p0=new an;class Wi{constructor(e=new D(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=zl.subVectors(n,t).cross(d0.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){const n=e.delta(zl),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(n).multiplyScalar(s).add(e.start)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||p0.getNormalMatrix(e),i=this.coplanarPoint(zl).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const ur=new Bi,La=new D;class Ra{constructor(e=new Wi,t=new Wi,n=new Wi,i=new Wi,s=new Wi,r=new Wi){this.planes=[e,t,n,i,s,r]}set(e,t,n,i,s,r){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(s),o[5].copy(r),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){const t=this.planes,n=e.elements,i=n[0],s=n[1],r=n[2],o=n[3],c=n[4],l=n[5],u=n[6],h=n[7],f=n[8],d=n[9],p=n[10],m=n[11],g=n[12],x=n[13],y=n[14],b=n[15];return t[0].setComponents(o-i,h-c,m-f,b-g).normalize(),t[1].setComponents(o+i,h+c,m+f,b+g).normalize(),t[2].setComponents(o+s,h+l,m+d,b+x).normalize(),t[3].setComponents(o-s,h-l,m-d,b-x).normalize(),t[4].setComponents(o-r,h-u,m-p,b-y).normalize(),t[5].setComponents(o+r,h+u,m+p,b+y).normalize(),this}intersectsObject(e){const t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),ur.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(ur)}intersectsSprite(e){return ur.center.set(0,0,0),ur.radius=.7071067811865476,ur.applyMatrix4(e.matrixWorld),this.intersectsSphere(ur)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)0?e.max.x:e.min.x,La.y=i.normal.y>0?e.max.y:e.min.y,La.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(La)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function Pf(){let a=null,e=!1,t=null,n=null;function i(s,r){t(s,r),n=a.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=a.requestAnimationFrame(i),e=!0)},stop:function(){a.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){a=s}}}function m0(a,e){const t=e.isWebGL2,n=new WeakMap;function i(l,u){const h=l.array,f=l.usage,d=a.createBuffer();a.bindBuffer(u,d),a.bufferData(u,h,f),l.onUploadCallback();let p;if(h instanceof Float32Array)p=5126;else if(h instanceof Uint16Array)if(l.isFloat16BufferAttribute)if(t)p=5131;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else p=5123;else if(h instanceof Int16Array)p=5122;else if(h instanceof Uint32Array)p=5125;else if(h instanceof Int32Array)p=5124;else if(h instanceof Int8Array)p=5120;else if(h instanceof Uint8Array)p=5121;else if(h instanceof Uint8ClampedArray)p=5121;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:d,type:p,bytesPerElement:h.BYTES_PER_ELEMENT,version:l.version}}function s(l,u,h){const f=u.array,d=u.updateRange;a.bindBuffer(h,l),d.count===-1?a.bufferSubData(h,0,f):(t?a.bufferSubData(h,d.offset*f.BYTES_PER_ELEMENT,f,d.offset,d.count):a.bufferSubData(h,d.offset*f.BYTES_PER_ELEMENT,f.subarray(d.offset,d.offset+d.count)),d.count=-1)}function r(l){return l.isInterleavedBufferAttribute&&(l=l.data),n.get(l)}function o(l){l.isInterleavedBufferAttribute&&(l=l.data);const u=n.get(l);u&&(a.deleteBuffer(u.buffer),n.delete(l))}function c(l,u){if(l.isGLBufferAttribute){const f=n.get(l);(!f||f.version1?null:t.copy(n).multiplyScalar(s).add(e.start)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||p0.getNormalMatrix(e),i=this.coplanarPoint(Ul).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const ur=new Bi,La=new P;class Ra{constructor(e=new Wi,t=new Wi,n=new Wi,i=new Wi,s=new Wi,r=new Wi){this.planes=[e,t,n,i,s,r]}set(e,t,n,i,s,r){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(s),o[5].copy(r),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){const t=this.planes,n=e.elements,i=n[0],s=n[1],r=n[2],o=n[3],c=n[4],l=n[5],u=n[6],h=n[7],f=n[8],d=n[9],p=n[10],m=n[11],g=n[12],x=n[13],y=n[14],b=n[15];return t[0].setComponents(o-i,h-c,m-f,b-g).normalize(),t[1].setComponents(o+i,h+c,m+f,b+g).normalize(),t[2].setComponents(o+s,h+l,m+d,b+x).normalize(),t[3].setComponents(o-s,h-l,m-d,b-x).normalize(),t[4].setComponents(o-r,h-u,m-p,b-y).normalize(),t[5].setComponents(o+r,h+u,m+p,b+y).normalize(),this}intersectsObject(e){const t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),ur.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(ur)}intersectsSprite(e){return ur.center.set(0,0,0),ur.radius=.7071067811865476,ur.applyMatrix4(e.matrixWorld),this.intersectsSphere(ur)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)0?e.max.x:e.min.x,La.y=i.normal.y>0?e.max.y:e.min.y,La.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(La)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function Df(){let a=null,e=!1,t=null,n=null;function i(s,r){t(s,r),n=a.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=a.requestAnimationFrame(i),e=!0)},stop:function(){a.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){a=s}}}function m0(a,e){const t=e.isWebGL2,n=new WeakMap;function i(l,u){const h=l.array,f=l.usage,d=a.createBuffer();a.bindBuffer(u,d),a.bufferData(u,h,f),l.onUploadCallback();let p;if(h instanceof Float32Array)p=5126;else if(h instanceof Uint16Array)if(l.isFloat16BufferAttribute)if(t)p=5131;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else p=5123;else if(h instanceof Int16Array)p=5122;else if(h instanceof Uint32Array)p=5125;else if(h instanceof Int32Array)p=5124;else if(h instanceof Int8Array)p=5120;else if(h instanceof Uint8Array)p=5121;else if(h instanceof Uint8ClampedArray)p=5121;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:d,type:p,bytesPerElement:h.BYTES_PER_ELEMENT,version:l.version}}function s(l,u,h){const f=u.array,d=u.updateRange;a.bindBuffer(h,l),d.count===-1?a.bufferSubData(h,0,f):(t?a.bufferSubData(h,d.offset*f.BYTES_PER_ELEMENT,f,d.offset,d.count):a.bufferSubData(h,d.offset*f.BYTES_PER_ELEMENT,f.subarray(d.offset,d.offset+d.count)),d.count=-1)}function r(l){return l.isInterleavedBufferAttribute&&(l=l.data),n.get(l)}function o(l){l.isInterleavedBufferAttribute&&(l=l.data);const u=n.get(l);u&&(a.deleteBuffer(u.buffer),n.delete(l))}function c(l,u){if(l.isGLBufferAttribute){const f=n.get(l);(!f||f.version #include #include -}`},Re={common:{diffuse:{value:new ve(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new an},uv2Transform:{value:new an},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new he(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ve(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new ve(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new an}},sprite:{diffuse:{value:new ve(16777215)},opacity:{value:1},center:{value:new he(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new an}}},Vn={basic:{uniforms:sn([Re.common,Re.specularmap,Re.envmap,Re.aomap,Re.lightmap,Re.fog]),vertexShader:nt.meshbasic_vert,fragmentShader:nt.meshbasic_frag},lambert:{uniforms:sn([Re.common,Re.specularmap,Re.envmap,Re.aomap,Re.lightmap,Re.emissivemap,Re.fog,Re.lights,{emissive:{value:new ve(0)}}]),vertexShader:nt.meshlambert_vert,fragmentShader:nt.meshlambert_frag},phong:{uniforms:sn([Re.common,Re.specularmap,Re.envmap,Re.aomap,Re.lightmap,Re.emissivemap,Re.bumpmap,Re.normalmap,Re.displacementmap,Re.fog,Re.lights,{emissive:{value:new ve(0)},specular:{value:new ve(1118481)},shininess:{value:30}}]),vertexShader:nt.meshphong_vert,fragmentShader:nt.meshphong_frag},standard:{uniforms:sn([Re.common,Re.envmap,Re.aomap,Re.lightmap,Re.emissivemap,Re.bumpmap,Re.normalmap,Re.displacementmap,Re.roughnessmap,Re.metalnessmap,Re.fog,Re.lights,{emissive:{value:new ve(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:nt.meshphysical_vert,fragmentShader:nt.meshphysical_frag},toon:{uniforms:sn([Re.common,Re.aomap,Re.lightmap,Re.emissivemap,Re.bumpmap,Re.normalmap,Re.displacementmap,Re.gradientmap,Re.fog,Re.lights,{emissive:{value:new ve(0)}}]),vertexShader:nt.meshtoon_vert,fragmentShader:nt.meshtoon_frag},matcap:{uniforms:sn([Re.common,Re.bumpmap,Re.normalmap,Re.displacementmap,Re.fog,{matcap:{value:null}}]),vertexShader:nt.meshmatcap_vert,fragmentShader:nt.meshmatcap_frag},points:{uniforms:sn([Re.points,Re.fog]),vertexShader:nt.points_vert,fragmentShader:nt.points_frag},dashed:{uniforms:sn([Re.common,Re.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:nt.linedashed_vert,fragmentShader:nt.linedashed_frag},depth:{uniforms:sn([Re.common,Re.displacementmap]),vertexShader:nt.depth_vert,fragmentShader:nt.depth_frag},normal:{uniforms:sn([Re.common,Re.bumpmap,Re.normalmap,Re.displacementmap,{opacity:{value:1}}]),vertexShader:nt.meshnormal_vert,fragmentShader:nt.meshnormal_frag},sprite:{uniforms:sn([Re.sprite,Re.fog]),vertexShader:nt.sprite_vert,fragmentShader:nt.sprite_frag},background:{uniforms:{uvTransform:{value:new an},t2D:{value:null}},vertexShader:nt.background_vert,fragmentShader:nt.background_frag},cube:{uniforms:sn([Re.envmap,{opacity:{value:1}}]),vertexShader:nt.cube_vert,fragmentShader:nt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:nt.equirect_vert,fragmentShader:nt.equirect_frag},distanceRGBA:{uniforms:sn([Re.common,Re.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:nt.distanceRGBA_vert,fragmentShader:nt.distanceRGBA_frag},shadow:{uniforms:sn([Re.lights,Re.fog,{color:{value:new ve(0)},opacity:{value:1}}]),vertexShader:nt.shadow_vert,fragmentShader:nt.shadow_frag}};Vn.physical={uniforms:sn([Vn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new he(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new ve(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new he},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new ve(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new ve(1,1,1)},specularColorMap:{value:null}}]),vertexShader:nt.meshphysical_vert,fragmentShader:nt.meshphysical_frag};function dx(a,e,t,n,i,s){const r=new ve(0);let o=i===!0?0:1,c,l,u=null,h=0,f=null;function d(m,g){let x=!1,y=g.isScene===!0?g.background:null;y&&y.isTexture&&(y=e.get(y));const b=a.xr,v=b.getSession&&b.getSession();v&&v.environmentBlendMode==="additive"&&(y=null),y===null?p(r,o):y&&y.isColor&&(p(y,1),x=!0),(a.autoClear||x)&&a.clear(a.autoClearColor,a.autoClearDepth,a.autoClearStencil),y&&(y.isCubeTexture||y.mapping===Xs)?(l===void 0&&(l=new St(new yi(1,1,1),new Kn({name:"BackgroundCubeMaterial",uniforms:ar(Vn.cube.uniforms),vertexShader:Vn.cube.vertexShader,fragmentShader:Vn.cube.fragmentShader,side:Tn,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(S,A,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=y,l.material.uniforms.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,(u!==y||h!==y.version||f!==a.toneMapping)&&(l.material.needsUpdate=!0,u=y,h=y.version,f=a.toneMapping),l.layers.enableAll(),m.unshift(l,l.geometry,l.material,0,0,null)):y&&y.isTexture&&(c===void 0&&(c=new St(new xs(2,2),new Kn({name:"BackgroundMaterial",uniforms:ar(Vn.background.uniforms),vertexShader:Vn.background.vertexShader,fragmentShader:Vn.background.fragmentShader,side:oi,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=y,y.matrixAutoUpdate===!0&&y.updateMatrix(),c.material.uniforms.uvTransform.value.copy(y.matrix),(u!==y||h!==y.version||f!==a.toneMapping)&&(c.material.needsUpdate=!0,u=y,h=y.version,f=a.toneMapping),c.layers.enableAll(),m.unshift(c,c.geometry,c.material,0,0,null))}function p(m,g){t.buffers.color.setClear(m.r,m.g,m.b,g,s)}return{getClearColor:function(){return r},setClearColor:function(m,g=1){r.set(m),o=g,p(r,o)},getClearAlpha:function(){return o},setClearAlpha:function(m){o=m,p(r,o)},render:d}}function px(a,e,t,n){const i=a.getParameter(34921),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),r=n.isWebGL2||s!==null,o={},c=g(null);let l=c,u=!1;function h(z,q,O,Y,j){let H=!1;if(r){const X=m(Y,O,q);l!==X&&(l=X,d(l.object)),H=x(z,Y,O,j),H&&y(z,Y,O,j)}else{const X=q.wireframe===!0;(l.geometry!==Y.id||l.program!==O.id||l.wireframe!==X)&&(l.geometry=Y.id,l.program=O.id,l.wireframe=X,H=!0)}j!==null&&t.update(j,34963),(H||u)&&(u=!1,_(z,q,O,Y),j!==null&&a.bindBuffer(34963,t.get(j).buffer))}function f(){return n.isWebGL2?a.createVertexArray():s.createVertexArrayOES()}function d(z){return n.isWebGL2?a.bindVertexArray(z):s.bindVertexArrayOES(z)}function p(z){return n.isWebGL2?a.deleteVertexArray(z):s.deleteVertexArrayOES(z)}function m(z,q,O){const Y=O.wireframe===!0;let j=o[z.id];j===void 0&&(j={},o[z.id]=j);let H=j[q.id];H===void 0&&(H={},j[q.id]=H);let X=H[Y];return X===void 0&&(X=g(f()),H[Y]=X),X}function g(z){const q=[],O=[],Y=[];for(let j=0;j=0){const re=j[J];let se=H[J];if(se===void 0&&(J==="instanceMatrix"&&z.instanceMatrix&&(se=z.instanceMatrix),J==="instanceColor"&&z.instanceColor&&(se=z.instanceColor)),re===void 0||re.attribute!==se||se&&re.data!==se.data)return!0;X++}return l.attributesNum!==X||l.index!==Y}function y(z,q,O,Y){const j={},H=q.attributes;let X=0;const te=O.getAttributes();for(const J in te)if(te[J].location>=0){let re=H[J];re===void 0&&(J==="instanceMatrix"&&z.instanceMatrix&&(re=z.instanceMatrix),J==="instanceColor"&&z.instanceColor&&(re=z.instanceColor));const se={};se.attribute=re,re&&re.data&&(se.data=re.data),j[J]=se,X++}l.attributes=j,l.attributesNum=X,l.index=Y}function b(){const z=l.newAttributes;for(let q=0,O=z.length;q=0){let ne=j[te];if(ne===void 0&&(te==="instanceMatrix"&&z.instanceMatrix&&(ne=z.instanceMatrix),te==="instanceColor"&&z.instanceColor&&(ne=z.instanceColor)),ne!==void 0){const re=ne.normalized,se=ne.itemSize,V=t.get(ne);if(V===void 0)continue;const me=V.buffer,_e=V.type,Pe=V.bytesPerElement;if(ne.isInterleavedBufferAttribute){const ye=ne.data,He=ye.stride,le=ne.offset;if(ye.isInstancedInterleavedBuffer){for(let ce=0;ce0&&a.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";R="mediump"}return R==="mediump"&&a.getShaderPrecisionFormat(35633,36337).precision>0&&a.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const r=typeof WebGL2RenderingContext!="undefined"&&a instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext!="undefined"&&a instanceof WebGL2ComputeRenderingContext;let o=t.precision!==void 0?t.precision:"highp";const c=s(o);c!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",c,"instead."),o=c);const l=r||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,h=a.getParameter(34930),f=a.getParameter(35660),d=a.getParameter(3379),p=a.getParameter(34076),m=a.getParameter(34921),g=a.getParameter(36347),x=a.getParameter(36348),y=a.getParameter(36349),b=f>0,v=r||e.has("OES_texture_float"),S=b&&v,A=r?a.getParameter(36183):0;return{isWebGL2:r,drawBuffers:l,getMaxAnisotropy:i,getMaxPrecision:s,precision:o,logarithmicDepthBuffer:u,maxTextures:h,maxVertexTextures:f,maxTextureSize:d,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:g,maxVaryings:x,maxFragmentUniforms:y,vertexTextures:b,floatFragmentTextures:v,floatVertexTextures:S,maxSamples:A}}function yx(a){const e=this;let t=null,n=0,i=!1,s=!1;const r=new Wi,o=new an,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,f,d){const p=h.length!==0||f||n!==0||i;return i=f,t=u(h,d,0),n=h.length,p},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1,l()},this.setState=function(h,f,d){const p=h.clippingPlanes,m=h.clipIntersection,g=h.clipShadows,x=a.get(h);if(!i||p===null||p.length===0||s&&!g)s?u(null):l();else{const y=s?0:n,b=y*4;let v=x.clippingState||null;c.value=v,v=u(p,f,b,d);for(let S=0;S!==b;++S)v[S]=t[S];x.clippingState=v,this.numIntersection=m?this.numPlanes:0,this.numPlanes+=y}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,f,d,p){const m=h!==null?h.length:0;let g=null;if(m!==0){if(g=c.value,p!==!0||g===null){const x=d+m*4,y=f.matrixWorldInverse;o.getNormalMatrix(y),(g===null||g.length0){const l=new If(c.height/2);return l.fromEquirectangularTexture(a,r),e.set(r,l),r.addEventListener("dispose",i),t(l.texture,r.mapping)}else return null}}return r}function i(r){const o=r.target;o.removeEventListener("dispose",i);const c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}class vs extends Ca{constructor(e=-1,t=1,n=1,i=-1,s=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=s,this.far=r,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,s,r){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-e,r=n+e,o=i+t,c=i-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,r=s+l*this.view.width,o-=u*this.view.offsetY,c=o-u*this.view.height}this.projectionMatrix.makeOrthographic(s,r,o,c,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const hr=4,Df=[.125,.215,.35,.446,.526,.582],_s=20,Ul=new vs,Ff=new ve;let Gl=null;const bs=(1+Math.sqrt(5))/2,fr=1/bs,Nf=[new D(1,1,1),new D(-1,1,1),new D(1,1,-1),new D(-1,1,-1),new D(0,bs,fr),new D(0,bs,-fr),new D(fr,0,bs),new D(-fr,0,bs),new D(bs,fr,0),new D(-bs,fr,0)];class Vl{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){Gl=this._renderer.getRenderTarget(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Bf(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Of(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?b:0,b,b),u.setRenderTarget(i),m&&u.render(p,o),u.render(e,o)}p.geometry.dispose(),p.material.dispose(),u.toneMapping=f,u.autoClear=h,e.background=g}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===Li||e.mapping===Ri;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Bf()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Of());const s=i?this._cubemapMaterial:this._equirectMaterial,r=new St(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const c=this._cubeSize;Ia(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(r,Ul)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;i_s&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${_s}`);const x=[];let y=0;for(let R=0;R<_s;++R){const _=R/m,L=Math.exp(-_*_/2);x.push(L),R===0?y+=L:Rb-hr?i-b+hr:0),A=4*(this._cubeSize-v);Ia(t,S,A,3*v,2*v),c.setRenderTarget(t),c.render(h,Ul)}}function vx(a){const e=[],t=[],n=[];let i=a;const s=a-hr+1+Df.length;for(let r=0;ra-hr?c=Df[r-a+hr-1]:r===0&&(c=0),n.push(c);const l=1/(o-2),u=-l,h=1+l,f=[u,u,h,u,h,h,u,u,h,h,u,h],d=6,p=6,m=3,g=2,x=1,y=new Float32Array(m*p*d),b=new Float32Array(g*p*d),v=new Float32Array(x*p*d);for(let A=0;A2?0:-1,L=[R,_,0,R+2/3,_,0,R+2/3,_+1,0,R,_,0,R+2/3,_+1,0,R,_+1,0];y.set(L,m*p*A),b.set(f,g*p*A);const N=[A,A,A,A,A,A];v.set(N,x*p*A)}const S=new qe;S.setAttribute("position",new ht(y,m)),S.setAttribute("uv",new ht(b,g)),S.setAttribute("faceIndex",new ht(v,x)),e.push(S),i>hr&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function kf(a,e,t){const n=new En(a,e,t);return n.texture.mapping=Xs,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ia(a,e,t,n,i){a.viewport.set(e,t,n,i),a.scissor.set(e,t,n,i)}function _x(a,e,t){const n=new Float32Array(_s),i=new D(0,1,0);return new Kn({name:"SphericalGaussianBlur",defines:{n:_s,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${a}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Hl(),fragmentShader:` +}`},Re={common:{diffuse:{value:new be(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new an},uv2Transform:{value:new an},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new fe(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new be(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new be(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new an}},sprite:{diffuse:{value:new be(16777215)},opacity:{value:1},center:{value:new fe(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new an}}},Vn={basic:{uniforms:sn([Re.common,Re.specularmap,Re.envmap,Re.aomap,Re.lightmap,Re.fog]),vertexShader:it.meshbasic_vert,fragmentShader:it.meshbasic_frag},lambert:{uniforms:sn([Re.common,Re.specularmap,Re.envmap,Re.aomap,Re.lightmap,Re.emissivemap,Re.fog,Re.lights,{emissive:{value:new be(0)}}]),vertexShader:it.meshlambert_vert,fragmentShader:it.meshlambert_frag},phong:{uniforms:sn([Re.common,Re.specularmap,Re.envmap,Re.aomap,Re.lightmap,Re.emissivemap,Re.bumpmap,Re.normalmap,Re.displacementmap,Re.fog,Re.lights,{emissive:{value:new be(0)},specular:{value:new be(1118481)},shininess:{value:30}}]),vertexShader:it.meshphong_vert,fragmentShader:it.meshphong_frag},standard:{uniforms:sn([Re.common,Re.envmap,Re.aomap,Re.lightmap,Re.emissivemap,Re.bumpmap,Re.normalmap,Re.displacementmap,Re.roughnessmap,Re.metalnessmap,Re.fog,Re.lights,{emissive:{value:new be(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:it.meshphysical_vert,fragmentShader:it.meshphysical_frag},toon:{uniforms:sn([Re.common,Re.aomap,Re.lightmap,Re.emissivemap,Re.bumpmap,Re.normalmap,Re.displacementmap,Re.gradientmap,Re.fog,Re.lights,{emissive:{value:new be(0)}}]),vertexShader:it.meshtoon_vert,fragmentShader:it.meshtoon_frag},matcap:{uniforms:sn([Re.common,Re.bumpmap,Re.normalmap,Re.displacementmap,Re.fog,{matcap:{value:null}}]),vertexShader:it.meshmatcap_vert,fragmentShader:it.meshmatcap_frag},points:{uniforms:sn([Re.points,Re.fog]),vertexShader:it.points_vert,fragmentShader:it.points_frag},dashed:{uniforms:sn([Re.common,Re.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:it.linedashed_vert,fragmentShader:it.linedashed_frag},depth:{uniforms:sn([Re.common,Re.displacementmap]),vertexShader:it.depth_vert,fragmentShader:it.depth_frag},normal:{uniforms:sn([Re.common,Re.bumpmap,Re.normalmap,Re.displacementmap,{opacity:{value:1}}]),vertexShader:it.meshnormal_vert,fragmentShader:it.meshnormal_frag},sprite:{uniforms:sn([Re.sprite,Re.fog]),vertexShader:it.sprite_vert,fragmentShader:it.sprite_frag},background:{uniforms:{uvTransform:{value:new an},t2D:{value:null}},vertexShader:it.background_vert,fragmentShader:it.background_frag},cube:{uniforms:sn([Re.envmap,{opacity:{value:1}}]),vertexShader:it.cube_vert,fragmentShader:it.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:it.equirect_vert,fragmentShader:it.equirect_frag},distanceRGBA:{uniforms:sn([Re.common,Re.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:it.distanceRGBA_vert,fragmentShader:it.distanceRGBA_frag},shadow:{uniforms:sn([Re.lights,Re.fog,{color:{value:new be(0)},opacity:{value:1}}]),vertexShader:it.shadow_vert,fragmentShader:it.shadow_frag}};Vn.physical={uniforms:sn([Vn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new fe(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new be(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new fe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new be(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new be(1,1,1)},specularColorMap:{value:null}}]),vertexShader:it.meshphysical_vert,fragmentShader:it.meshphysical_frag};function dx(a,e,t,n,i,s){const r=new be(0);let o=i===!0?0:1,c,l,u=null,h=0,f=null;function d(m,g){let x=!1,y=g.isScene===!0?g.background:null;y&&y.isTexture&&(y=e.get(y));const b=a.xr,v=b.getSession&&b.getSession();v&&v.environmentBlendMode==="additive"&&(y=null),y===null?p(r,o):y&&y.isColor&&(p(y,1),x=!0),(a.autoClear||x)&&a.clear(a.autoClearColor,a.autoClearDepth,a.autoClearStencil),y&&(y.isCubeTexture||y.mapping===Xs)?(l===void 0&&(l=new St(new yi(1,1,1),new Kn({name:"BackgroundCubeMaterial",uniforms:ar(Vn.cube.uniforms),vertexShader:Vn.cube.vertexShader,fragmentShader:Vn.cube.fragmentShader,side:Tn,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(M,T,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=y,l.material.uniforms.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,(u!==y||h!==y.version||f!==a.toneMapping)&&(l.material.needsUpdate=!0,u=y,h=y.version,f=a.toneMapping),l.layers.enableAll(),m.unshift(l,l.geometry,l.material,0,0,null)):y&&y.isTexture&&(c===void 0&&(c=new St(new xs(2,2),new Kn({name:"BackgroundMaterial",uniforms:ar(Vn.background.uniforms),vertexShader:Vn.background.vertexShader,fragmentShader:Vn.background.fragmentShader,side:oi,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=y,y.matrixAutoUpdate===!0&&y.updateMatrix(),c.material.uniforms.uvTransform.value.copy(y.matrix),(u!==y||h!==y.version||f!==a.toneMapping)&&(c.material.needsUpdate=!0,u=y,h=y.version,f=a.toneMapping),c.layers.enableAll(),m.unshift(c,c.geometry,c.material,0,0,null))}function p(m,g){t.buffers.color.setClear(m.r,m.g,m.b,g,s)}return{getClearColor:function(){return r},setClearColor:function(m,g=1){r.set(m),o=g,p(r,o)},getClearAlpha:function(){return o},setClearAlpha:function(m){o=m,p(r,o)},render:d}}function px(a,e,t,n){const i=a.getParameter(34921),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),r=n.isWebGL2||s!==null,o={},c=g(null);let l=c,u=!1;function h(G,X,B,Z,Y){let W=!1;if(r){const j=m(Z,B,X);l!==j&&(l=j,d(l.object)),W=x(G,Z,B,Y),W&&y(G,Z,B,Y)}else{const j=X.wireframe===!0;(l.geometry!==Z.id||l.program!==B.id||l.wireframe!==j)&&(l.geometry=Z.id,l.program=B.id,l.wireframe=j,W=!0)}Y!==null&&t.update(Y,34963),(W||u)&&(u=!1,_(G,X,B,Z),Y!==null&&a.bindBuffer(34963,t.get(Y).buffer))}function f(){return n.isWebGL2?a.createVertexArray():s.createVertexArrayOES()}function d(G){return n.isWebGL2?a.bindVertexArray(G):s.bindVertexArrayOES(G)}function p(G){return n.isWebGL2?a.deleteVertexArray(G):s.deleteVertexArrayOES(G)}function m(G,X,B){const Z=B.wireframe===!0;let Y=o[G.id];Y===void 0&&(Y={},o[G.id]=Y);let W=Y[X.id];W===void 0&&(W={},Y[X.id]=W);let j=W[Z];return j===void 0&&(j=g(f()),W[Z]=j),j}function g(G){const X=[],B=[],Z=[];for(let Y=0;Y=0){const ce=Y[$];let oe=W[$];if(oe===void 0&&($==="instanceMatrix"&&G.instanceMatrix&&(oe=G.instanceMatrix),$==="instanceColor"&&G.instanceColor&&(oe=G.instanceColor)),ce===void 0||ce.attribute!==oe||oe&&ce.data!==oe.data)return!0;j++}return l.attributesNum!==j||l.index!==Z}function y(G,X,B,Z){const Y={},W=X.attributes;let j=0;const ne=B.getAttributes();for(const $ in ne)if(ne[$].location>=0){let ce=W[$];ce===void 0&&($==="instanceMatrix"&&G.instanceMatrix&&(ce=G.instanceMatrix),$==="instanceColor"&&G.instanceColor&&(ce=G.instanceColor));const oe={};oe.attribute=ce,ce&&ce.data&&(oe.data=ce.data),Y[$]=oe,j++}l.attributes=Y,l.attributesNum=j,l.index=Z}function b(){const G=l.newAttributes;for(let X=0,B=G.length;X=0){let ie=Y[ne];if(ie===void 0&&(ne==="instanceMatrix"&&G.instanceMatrix&&(ie=G.instanceMatrix),ne==="instanceColor"&&G.instanceColor&&(ie=G.instanceColor)),ie!==void 0){const ce=ie.normalized,oe=ie.itemSize,H=t.get(ie);if(H===void 0)continue;const ye=H.buffer,we=H.type,De=H.bytesPerElement;if(ie.isInterleavedBufferAttribute){const xe=ie.data,Ve=xe.stride,he=ie.offset;if(xe.isInstancedInterleavedBuffer){for(let ue=0;ue<$.locationSize;ue++)M($.location+ue,xe.meshPerAttribute);G.isInstancedMesh!==!0&&Z._maxInstanceCount===void 0&&(Z._maxInstanceCount=xe.meshPerAttribute*xe.count)}else for(let ue=0;ue<$.locationSize;ue++)v($.location+ue);a.bindBuffer(34962,ye);for(let ue=0;ue<$.locationSize;ue++)C($.location+ue,oe/$.locationSize,we,ce,Ve*De,(he+oe/$.locationSize*ue)*De)}else{if(ie.isInstancedBufferAttribute){for(let xe=0;xe<$.locationSize;xe++)M($.location+xe,ie.meshPerAttribute);G.isInstancedMesh!==!0&&Z._maxInstanceCount===void 0&&(Z._maxInstanceCount=ie.meshPerAttribute*ie.count)}else for(let xe=0;xe<$.locationSize;xe++)v($.location+xe);a.bindBuffer(34962,ye);for(let xe=0;xe<$.locationSize;xe++)C($.location+xe,oe/$.locationSize,we,ce,oe*De,oe/$.locationSize*xe*De)}}else if(j!==void 0){const ce=j[ne];if(ce!==void 0)switch(ce.length){case 2:a.vertexAttrib2fv($.location,ce);break;case 3:a.vertexAttrib3fv($.location,ce);break;case 4:a.vertexAttrib4fv($.location,ce);break;default:a.vertexAttrib1fv($.location,ce)}}}}T()}function E(){q();for(const G in o){const X=o[G];for(const B in X){const Z=X[B];for(const Y in Z)p(Z[Y].object),delete Z[Y];delete X[B]}delete o[G]}}function F(G){if(o[G.id]===void 0)return;const X=o[G.id];for(const B in X){const Z=X[B];for(const Y in Z)p(Z[Y].object),delete Z[Y];delete X[B]}delete o[G.id]}function U(G){for(const X in o){const B=o[X];if(B[G.id]===void 0)continue;const Z=B[G.id];for(const Y in Z)p(Z[Y].object),delete Z[Y];delete B[G.id]}}function q(){J(),u=!0,l!==c&&(l=c,d(l.object))}function J(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:h,reset:q,resetDefaultState:J,dispose:E,releaseStatesOfGeometry:F,releaseStatesOfProgram:U,initAttributes:b,enableAttribute:v,disableUnusedAttributes:T}}function mx(a,e,t,n){const i=n.isWebGL2;let s;function r(l){s=l}function o(l,u){a.drawArrays(s,l,u),t.update(u,s,1)}function c(l,u,h){if(h===0)return;let f,d;if(i)f=a,d="drawArraysInstanced";else if(f=e.get("ANGLE_instanced_arrays"),d="drawArraysInstancedANGLE",f===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}f[d](s,l,u,h),t.update(u,s,h)}this.setMode=r,this.render=o,this.renderInstances=c}function gx(a,e,t){let n;function i(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");n=a.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function s(C){if(C==="highp"){if(a.getShaderPrecisionFormat(35633,36338).precision>0&&a.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";C="mediump"}return C==="mediump"&&a.getShaderPrecisionFormat(35633,36337).precision>0&&a.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const r=typeof WebGL2RenderingContext!="undefined"&&a instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext!="undefined"&&a instanceof WebGL2ComputeRenderingContext;let o=t.precision!==void 0?t.precision:"highp";const c=s(o);c!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",c,"instead."),o=c);const l=r||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,h=a.getParameter(34930),f=a.getParameter(35660),d=a.getParameter(3379),p=a.getParameter(34076),m=a.getParameter(34921),g=a.getParameter(36347),x=a.getParameter(36348),y=a.getParameter(36349),b=f>0,v=r||e.has("OES_texture_float"),M=b&&v,T=r?a.getParameter(36183):0;return{isWebGL2:r,drawBuffers:l,getMaxAnisotropy:i,getMaxPrecision:s,precision:o,logarithmicDepthBuffer:u,maxTextures:h,maxVertexTextures:f,maxTextureSize:d,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:g,maxVaryings:x,maxFragmentUniforms:y,vertexTextures:b,floatFragmentTextures:v,floatVertexTextures:M,maxSamples:T}}function yx(a){const e=this;let t=null,n=0,i=!1,s=!1;const r=new Wi,o=new an,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,f,d){const p=h.length!==0||f||n!==0||i;return i=f,t=u(h,d,0),n=h.length,p},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1,l()},this.setState=function(h,f,d){const p=h.clippingPlanes,m=h.clipIntersection,g=h.clipShadows,x=a.get(h);if(!i||p===null||p.length===0||s&&!g)s?u(null):l();else{const y=s?0:n,b=y*4;let v=x.clippingState||null;c.value=v,v=u(p,f,b,d);for(let M=0;M!==b;++M)v[M]=t[M];x.clippingState=v,this.numIntersection=m?this.numPlanes:0,this.numPlanes+=y}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,f,d,p){const m=h!==null?h.length:0;let g=null;if(m!==0){if(g=c.value,p!==!0||g===null){const x=d+m*4,y=f.matrixWorldInverse;o.getNormalMatrix(y),(g===null||g.length0){const l=new Pf(c.height/2);return l.fromEquirectangularTexture(a,r),e.set(r,l),r.addEventListener("dispose",i),t(l.texture,r.mapping)}else return null}}return r}function i(r){const o=r.target;o.removeEventListener("dispose",i);const c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}class vs extends Ca{constructor(e=-1,t=1,n=1,i=-1,s=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=s,this.far=r,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,s,r){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-e,r=n+e,o=i+t,c=i-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,r=s+l*this.view.width,o-=u*this.view.offsetY,c=o-u*this.view.height}this.projectionMatrix.makeOrthographic(s,r,o,c,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const hr=4,Ff=[.125,.215,.35,.446,.526,.582],_s=20,Gl=new vs,Nf=new be;let Vl=null;const bs=(1+Math.sqrt(5))/2,fr=1/bs,kf=[new P(1,1,1),new P(-1,1,1),new P(1,1,-1),new P(-1,1,-1),new P(0,bs,fr),new P(0,bs,-fr),new P(fr,0,bs),new P(-fr,0,bs),new P(bs,fr,0),new P(-bs,fr,0)];class Hl{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){Vl=this._renderer.getRenderTarget(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=zf(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Bf(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?b:0,b,b),u.setRenderTarget(i),m&&u.render(p,o),u.render(e,o)}p.geometry.dispose(),p.material.dispose(),u.toneMapping=f,u.autoClear=h,e.background=g}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===Li||e.mapping===Ri;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=zf()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Bf());const s=i?this._cubemapMaterial:this._equirectMaterial,r=new St(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const c=this._cubeSize;Ia(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(r,Gl)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;i_s&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${_s}`);const x=[];let y=0;for(let C=0;C<_s;++C){const _=C/m,E=Math.exp(-_*_/2);x.push(E),C===0?y+=E:Cb-hr?i-b+hr:0),T=4*(this._cubeSize-v);Ia(t,M,T,3*v,2*v),c.setRenderTarget(t),c.render(h,Gl)}}function vx(a){const e=[],t=[],n=[];let i=a;const s=a-hr+1+Ff.length;for(let r=0;ra-hr?c=Ff[r-a+hr-1]:r===0&&(c=0),n.push(c);const l=1/(o-2),u=-l,h=1+l,f=[u,u,h,u,h,h,u,u,h,h,u,h],d=6,p=6,m=3,g=2,x=1,y=new Float32Array(m*p*d),b=new Float32Array(g*p*d),v=new Float32Array(x*p*d);for(let T=0;T2?0:-1,E=[C,_,0,C+2/3,_,0,C+2/3,_+1,0,C,_,0,C+2/3,_+1,0,C,_+1,0];y.set(E,m*p*T),b.set(f,g*p*T);const F=[T,T,T,T,T,T];v.set(F,x*p*T)}const M=new qe;M.setAttribute("position",new ft(y,m)),M.setAttribute("uv",new ft(b,g)),M.setAttribute("faceIndex",new ft(v,x)),e.push(M),i>hr&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Of(a,e,t){const n=new En(a,e,t);return n.texture.mapping=Xs,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ia(a,e,t,n,i){a.viewport.set(e,t,n,i),a.scissor.set(e,t,n,i)}function _x(a,e,t){const n=new Float32Array(_s),i=new P(0,1,0);return new Kn({name:"SphericalGaussianBlur",defines:{n:_s,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${a}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Wl(),fragmentShader:` precision mediump float; precision mediump int; @@ -2990,7 +2990,7 @@ void main() { } } - `,blending:ci,depthTest:!1,depthWrite:!1})}function Of(){return new Kn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Hl(),fragmentShader:` + `,blending:ci,depthTest:!1,depthWrite:!1})}function Bf(){return new Kn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Wl(),fragmentShader:` precision mediump float; precision mediump int; @@ -3009,7 +3009,7 @@ void main() { gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } - `,blending:ci,depthTest:!1,depthWrite:!1})}function Bf(){return new Kn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Hl(),fragmentShader:` + `,blending:ci,depthTest:!1,depthWrite:!1})}function zf(){return new Kn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Wl(),fragmentShader:` precision mediump float; precision mediump int; @@ -3025,7 +3025,7 @@ void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } - `,blending:ci,depthTest:!1,depthWrite:!1})}function Hl(){return` + `,blending:ci,depthTest:!1,depthWrite:!1})}function Wl(){return` precision mediump float; precision mediump int; @@ -3080,37 +3080,37 @@ void main() { gl_Position = vec4( position, 1.0 ); } - `}function bx(a){let e=new WeakMap,t=null;function n(o){if(o&&o.isTexture){const c=o.mapping,l=c===qs||c===Qr,u=c===Li||c===Ri;if(l||u)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let h=e.get(o);return t===null&&(t=new Vl(a)),h=l?t.fromEquirectangular(o,h):t.fromCubemap(o,h),e.set(o,h),h.texture}else{if(e.has(o))return e.get(o).texture;{const h=o.image;if(l&&h&&h.height>0||u&&h&&i(h)){t===null&&(t=new Vl(a));const f=l?t.fromEquirectangular(o):t.fromCubemap(o);return e.set(o,f),o.addEventListener("dispose",s),f.texture}else return null}}}return o}function i(o){let c=0;const l=6;for(let u=0;ue.maxTextureSize&&(B=Math.ceil(N/e.maxTextureSize),N=e.maxTextureSize);const W=new Float32Array(N*B*4*m),K=new uo(W,N,B,m);K.type=li,K.needsUpdate=!0;const z=L*4;for(let O=0;O0)return a;const i=e*t;let s=Hf[i];if(s===void 0&&(s=new Float32Array(i),Hf[i]=s),e!==0){n.toArray(s,0);for(let r=1,o=0;r!==e;++r)o+=t,a[r].toArray(s,o)}return s}function ln(a,e){if(a.length!==e.length)return!1;for(let t=0,n=a.length;t0||u&&h&&i(h)){t===null&&(t=new Hl(a));const f=l?t.fromEquirectangular(o):t.fromCubemap(o);return e.set(o,f),o.addEventListener("dispose",s),f.texture}else return null}}}return o}function i(o){let c=0;const l=6;for(let u=0;ue.maxTextureSize&&(U=Math.ceil(F/e.maxTextureSize),F=e.maxTextureSize);const q=new Float32Array(F*U*4*m),J=new uo(q,F,U,m);J.type=li,J.needsUpdate=!0;const G=E*4;for(let B=0;B0)return a;const i=e*t;let s=Wf[i];if(s===void 0&&(s=new Float32Array(i),Wf[i]=s),e!==0){n.toArray(s,0);for(let r=1,o=0;r!==e;++r)o+=t,a[r].toArray(s,o)}return s}function ln(a,e){if(a.length!==e.length)return!1;for(let t=0,n=a.length;t":" "} ${o}: ${t[r]}`)}return n.join(` -`)}function wv(a){switch(a){case ui:return["Linear","( value )"];case tt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",a),["Linear","( value )"]}}function Kf(a,e,t){const n=a.getShaderParameter(e,35713),i=a.getShaderInfoLog(e).trim();if(n&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const r=parseInt(s[1]);return t.toUpperCase()+` +`)}function wv(a){switch(a){case ui:return["Linear","( value )"];case nt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",a),["Linear","( value )"]}}function Jf(a,e,t){const n=a.getShaderParameter(e,35713),i=a.getShaderInfoLog(e).trim();if(n&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const r=parseInt(s[1]);return t.toUpperCase()+` `+i+` -`+bv(a.getShaderSource(e),r)}else return i}function Mv(a,e){const t=wv(e);return"vec4 "+a+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function Sv(a,e){let t;switch(e){case Uh:t="Linear";break;case Gh:t="Reinhard";break;case Vh:t="OptimizedCineon";break;case Hh:t="ACESFilmic";break;case Wh:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+a+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function Tv(a){return[a.extensionDerivatives||!!a.envMapCubeUVHeight||a.bumpMap||a.tangentSpaceNormalMap||a.clearcoatNormalMap||a.flatShading||a.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(a.extensionFragDepth||a.logarithmicDepthBuffer)&&a.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",a.extensionDrawBuffers&&a.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(a.extensionShaderTextureLOD||a.envMap||a.transmission)&&a.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(yo).join(` +`+bv(a.getShaderSource(e),r)}else return i}function Mv(a,e){const t=wv(e);return"vec4 "+a+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function Sv(a,e){let t;switch(e){case Gh:t="Linear";break;case Vh:t="Reinhard";break;case Hh:t="OptimizedCineon";break;case Wh:t="ACESFilmic";break;case qh:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+a+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function Tv(a){return[a.extensionDerivatives||!!a.envMapCubeUVHeight||a.bumpMap||a.tangentSpaceNormalMap||a.clearcoatNormalMap||a.flatShading||a.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(a.extensionFragDepth||a.logarithmicDepthBuffer)&&a.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",a.extensionDrawBuffers&&a.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(a.extensionShaderTextureLOD||a.envMap||a.transmission)&&a.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(yo).join(` `)}function Av(a){const e=[];for(const t in a){const n=a[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` -`)}function Ev(a,e){const t={},n=a.getProgramParameter(e,35721);for(let i=0;i/gm;function Xl(a){return a.replace(Cv,Lv)}function Lv(a,e){const t=nt[e];if(t===void 0)throw new Error("Can not resolve #include <"+e+">");return Xl(t)}const Rv=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,Iv=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Qf(a){return a.replace(Iv,ed).replace(Rv,Pv)}function Pv(a,e,t,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),ed(a,e,t,n)}function ed(a,e,t,n){let i="";for(let s=parseInt(e);s/gm;function jl(a){return a.replace(Cv,Lv)}function Lv(a,e){const t=it[e];if(t===void 0)throw new Error("Can not resolve #include <"+e+">");return jl(t)}const Rv=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,Iv=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function ed(a){return a.replace(Iv,td).replace(Rv,Pv)}function Pv(a,e,t,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),td(a,e,t,n)}function td(a,e,t,n){let i="";for(let s=parseInt(e);s0&&(g+=` `),x=[d,p].filter(yo).join(` `),x.length>0&&(x+=` -`)):(g=[td(t),"#define SHADER_NAME "+t.shaderName,p,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.supportsVertexTextures?"#define VERTEX_TEXTURES":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.displacementMap&&t.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`)):(g=[nd(t),"#define SHADER_NAME "+t.shaderName,p,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.supportsVertexTextures?"#define VERTEX_TEXTURES":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.displacementMap&&t.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(yo).join(` -`),x=[d,td(t),"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Xn?"#define TONE_MAPPING":"",t.toneMapping!==Xn?nt.tonemapping_pars_fragment:"",t.toneMapping!==Xn?Sv("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",nt.encodings_pars_fragment,Mv("linearToOutputTexel",t.outputEncoding),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`),x=[d,nd(t),"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Xn?"#define TONE_MAPPING":"",t.toneMapping!==Xn?it.tonemapping_pars_fragment:"",t.toneMapping!==Xn?Sv("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",it.encodings_pars_fragment,Mv("linearToOutputTexel",t.outputEncoding),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(yo).join(` -`)),r=Xl(r),r=Jf(r,t),r=$f(r,t),o=Xl(o),o=Jf(o,t),o=$f(o,t),r=Qf(r),o=Qf(o),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(y=`#version 300 es +`)),r=jl(r),r=$f(r,t),r=Qf(r,t),o=jl(o),o=$f(o,t),o=Qf(o,t),r=ed(r),o=ed(o),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(y=`#version 300 es `,g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` -`+g,x=["#define varying in",t.glslVersion===pl?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===pl?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`+g,x=["#define varying in",t.glslVersion===ml?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===ml?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` `)+` -`+x);const b=y+g+r,v=y+x+o,S=Zf(i,35633,b),A=Zf(i,35632,v);if(i.attachShader(m,S),i.attachShader(m,A),t.index0AttributeName!==void 0?i.bindAttribLocation(m,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(m,0,"position"),i.linkProgram(m),a.debug.checkShaderErrors){const L=i.getProgramInfoLog(m).trim(),N=i.getShaderInfoLog(S).trim(),B=i.getShaderInfoLog(A).trim();let W=!0,K=!0;if(i.getProgramParameter(m,35714)===!1){W=!1;const z=Kf(i,S,"vertex"),q=Kf(i,A,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(m,35715)+` +`+x);const b=y+g+r,v=y+x+o,M=Kf(i,35633,b),T=Kf(i,35632,v);if(i.attachShader(m,M),i.attachShader(m,T),t.index0AttributeName!==void 0?i.bindAttribLocation(m,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(m,0,"position"),i.linkProgram(m),a.debug.checkShaderErrors){const E=i.getProgramInfoLog(m).trim(),F=i.getShaderInfoLog(M).trim(),U=i.getShaderInfoLog(T).trim();let q=!0,J=!0;if(i.getProgramParameter(m,35714)===!1){q=!1;const G=Jf(i,M,"vertex"),X=Jf(i,T,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(m,35715)+` -Program Info Log: `+L+` -`+z+` -`+q)}else L!==""?console.warn("THREE.WebGLProgram: Program Info Log:",L):(N===""||B==="")&&(K=!1);K&&(this.diagnostics={runnable:W,programLog:L,vertexShader:{log:N,prefix:g},fragmentShader:{log:B,prefix:x}})}i.deleteShader(S),i.deleteShader(A);let R;this.getUniforms=function(){return R===void 0&&(R=new Da(i,m)),R};let _;return this.getAttributes=function(){return _===void 0&&(_=Ev(i,m)),_},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(m),this.program=void 0},this.name=t.shaderName,this.id=_v++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=S,this.fragmentShader=A,this}let zv=0;class Uv{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),r=this._getShaderCacheForMaterial(e);return r.has(i)===!1&&(r.add(i),i.usedTimes++),r.has(s)===!1&&(r.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;return t.has(e)===!1&&t.set(e,new Set),t.get(e)}_getShaderStage(e){const t=this.shaderCache;if(t.has(e)===!1){const n=new Gv(e);t.set(e,n)}return t.get(e)}}class Gv{constructor(e){this.id=zv++,this.code=e,this.usedTimes=0}}function Vv(a,e,t,n,i,s,r){const o=new ga,c=new Uv,l=[],u=i.isWebGL2,h=i.logarithmicDepthBuffer,f=i.vertexTextures;let d=i.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(_,L,N,B,W){const K=B.fog,z=W.geometry,q=_.isMeshStandardMaterial?B.environment:null,O=(_.isMeshStandardMaterial?t:e).get(_.envMap||q),Y=!!O&&O.mapping===Xs?O.image.height:null,j=p[_.type];_.precision!==null&&(d=i.getMaxPrecision(_.precision),d!==_.precision&&console.warn("THREE.WebGLProgram.getParameters:",_.precision,"not supported, using",d,"instead."));const H=z.morphAttributes.position||z.morphAttributes.normal||z.morphAttributes.color,X=H!==void 0?H.length:0;let te=0;z.morphAttributes.position!==void 0&&(te=1),z.morphAttributes.normal!==void 0&&(te=2),z.morphAttributes.color!==void 0&&(te=3);let J,ne,re,se;if(j){const He=Vn[j];J=He.vertexShader,ne=He.fragmentShader}else J=_.vertexShader,ne=_.fragmentShader,c.update(_),re=c.getVertexShaderID(_),se=c.getFragmentShaderID(_);const V=a.getRenderTarget(),me=_.alphaTest>0,_e=_.clearcoat>0,Pe=_.iridescence>0;return{isWebGL2:u,shaderID:j,shaderName:_.type,vertexShader:J,fragmentShader:ne,defines:_.defines,customVertexShaderID:re,customFragmentShaderID:se,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:d,instancing:W.isInstancedMesh===!0,instancingColor:W.isInstancedMesh===!0&&W.instanceColor!==null,supportsVertexTextures:f,outputEncoding:V===null?a.outputEncoding:V.isXRRenderTarget===!0?V.texture.encoding:ui,map:!!_.map,matcap:!!_.matcap,envMap:!!O,envMapMode:O&&O.mapping,envMapCubeUVHeight:Y,lightMap:!!_.lightMap,aoMap:!!_.aoMap,emissiveMap:!!_.emissiveMap,bumpMap:!!_.bumpMap,normalMap:!!_.normalMap,objectSpaceNormalMap:_.normalMapType===ff,tangentSpaceNormalMap:_.normalMapType===Fi,decodeVideoTexture:!!_.map&&_.map.isVideoTexture===!0&&_.map.encoding===tt,clearcoat:_e,clearcoatMap:_e&&!!_.clearcoatMap,clearcoatRoughnessMap:_e&&!!_.clearcoatRoughnessMap,clearcoatNormalMap:_e&&!!_.clearcoatNormalMap,iridescence:Pe,iridescenceMap:Pe&&!!_.iridescenceMap,iridescenceThicknessMap:Pe&&!!_.iridescenceThicknessMap,displacementMap:!!_.displacementMap,roughnessMap:!!_.roughnessMap,metalnessMap:!!_.metalnessMap,specularMap:!!_.specularMap,specularIntensityMap:!!_.specularIntensityMap,specularColorMap:!!_.specularColorMap,opaque:_.transparent===!1&&_.blending===rs,alphaMap:!!_.alphaMap,alphaTest:me,gradientMap:!!_.gradientMap,sheen:_.sheen>0,sheenColorMap:!!_.sheenColorMap,sheenRoughnessMap:!!_.sheenRoughnessMap,transmission:_.transmission>0,transmissionMap:!!_.transmissionMap,thicknessMap:!!_.thicknessMap,combine:_.combine,vertexTangents:!!_.normalMap&&!!z.attributes.tangent,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!z.attributes.color&&z.attributes.color.itemSize===4,vertexUvs:!!_.map||!!_.bumpMap||!!_.normalMap||!!_.specularMap||!!_.alphaMap||!!_.emissiveMap||!!_.roughnessMap||!!_.metalnessMap||!!_.clearcoatMap||!!_.clearcoatRoughnessMap||!!_.clearcoatNormalMap||!!_.iridescenceMap||!!_.iridescenceThicknessMap||!!_.displacementMap||!!_.transmissionMap||!!_.thicknessMap||!!_.specularIntensityMap||!!_.specularColorMap||!!_.sheenColorMap||!!_.sheenRoughnessMap,uvsVertexOnly:!(!!_.map||!!_.bumpMap||!!_.normalMap||!!_.specularMap||!!_.alphaMap||!!_.emissiveMap||!!_.roughnessMap||!!_.metalnessMap||!!_.clearcoatNormalMap||!!_.iridescenceMap||!!_.iridescenceThicknessMap||_.transmission>0||!!_.transmissionMap||!!_.thicknessMap||!!_.specularIntensityMap||!!_.specularColorMap||_.sheen>0||!!_.sheenColorMap||!!_.sheenRoughnessMap)&&!!_.displacementMap,fog:!!K,useFog:_.fog===!0,fogExp2:K&&K.isFogExp2,flatShading:!!_.flatShading,sizeAttenuation:_.sizeAttenuation,logarithmicDepthBuffer:h,skinning:W.isSkinnedMesh===!0,morphTargets:z.morphAttributes.position!==void 0,morphNormals:z.morphAttributes.normal!==void 0,morphColors:z.morphAttributes.color!==void 0,morphTargetsCount:X,morphTextureStride:te,numDirLights:L.directional.length,numPointLights:L.point.length,numSpotLights:L.spot.length,numRectAreaLights:L.rectArea.length,numHemiLights:L.hemi.length,numDirLightShadows:L.directionalShadowMap.length,numPointLightShadows:L.pointShadowMap.length,numSpotLightShadows:L.spotShadowMap.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:_.dithering,shadowMapEnabled:a.shadowMap.enabled&&N.length>0,shadowMapType:a.shadowMap.type,toneMapping:_.toneMapped?a.toneMapping:Xn,physicallyCorrectLights:a.physicallyCorrectLights,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===ai,flipSided:_.side===Tn,useDepthPacking:!!_.depthPacking,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionDerivatives:_.extensions&&_.extensions.derivatives,extensionFragDepth:_.extensions&&_.extensions.fragDepth,extensionDrawBuffers:_.extensions&&_.extensions.drawBuffers,extensionShaderTextureLOD:_.extensions&&_.extensions.shaderTextureLOD,rendererExtensionFragDepth:u||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||n.has("EXT_shader_texture_lod"),customProgramCacheKey:_.customProgramCacheKey()}}function g(_){const L=[];if(_.shaderID?L.push(_.shaderID):(L.push(_.customVertexShaderID),L.push(_.customFragmentShaderID)),_.defines!==void 0)for(const N in _.defines)L.push(N),L.push(_.defines[N]);return _.isRawShaderMaterial===!1&&(x(L,_),y(L,_),L.push(a.outputEncoding)),L.push(_.customProgramCacheKey),L.join()}function x(_,L){_.push(L.precision),_.push(L.outputEncoding),_.push(L.envMapMode),_.push(L.envMapCubeUVHeight),_.push(L.combine),_.push(L.vertexUvs),_.push(L.fogExp2),_.push(L.sizeAttenuation),_.push(L.morphTargetsCount),_.push(L.morphAttributeCount),_.push(L.numDirLights),_.push(L.numPointLights),_.push(L.numSpotLights),_.push(L.numHemiLights),_.push(L.numRectAreaLights),_.push(L.numDirLightShadows),_.push(L.numPointLightShadows),_.push(L.numSpotLightShadows),_.push(L.shadowMapType),_.push(L.toneMapping),_.push(L.numClippingPlanes),_.push(L.numClipIntersection),_.push(L.depthPacking)}function y(_,L){o.disableAll(),L.isWebGL2&&o.enable(0),L.supportsVertexTextures&&o.enable(1),L.instancing&&o.enable(2),L.instancingColor&&o.enable(3),L.map&&o.enable(4),L.matcap&&o.enable(5),L.envMap&&o.enable(6),L.lightMap&&o.enable(7),L.aoMap&&o.enable(8),L.emissiveMap&&o.enable(9),L.bumpMap&&o.enable(10),L.normalMap&&o.enable(11),L.objectSpaceNormalMap&&o.enable(12),L.tangentSpaceNormalMap&&o.enable(13),L.clearcoat&&o.enable(14),L.clearcoatMap&&o.enable(15),L.clearcoatRoughnessMap&&o.enable(16),L.clearcoatNormalMap&&o.enable(17),L.iridescence&&o.enable(18),L.iridescenceMap&&o.enable(19),L.iridescenceThicknessMap&&o.enable(20),L.displacementMap&&o.enable(21),L.specularMap&&o.enable(22),L.roughnessMap&&o.enable(23),L.metalnessMap&&o.enable(24),L.gradientMap&&o.enable(25),L.alphaMap&&o.enable(26),L.alphaTest&&o.enable(27),L.vertexColors&&o.enable(28),L.vertexAlphas&&o.enable(29),L.vertexUvs&&o.enable(30),L.vertexTangents&&o.enable(31),L.uvsVertexOnly&&o.enable(32),L.fog&&o.enable(33),_.push(o.mask),o.disableAll(),L.useFog&&o.enable(0),L.flatShading&&o.enable(1),L.logarithmicDepthBuffer&&o.enable(2),L.skinning&&o.enable(3),L.morphTargets&&o.enable(4),L.morphNormals&&o.enable(5),L.morphColors&&o.enable(6),L.premultipliedAlpha&&o.enable(7),L.shadowMapEnabled&&o.enable(8),L.physicallyCorrectLights&&o.enable(9),L.doubleSided&&o.enable(10),L.flipSided&&o.enable(11),L.useDepthPacking&&o.enable(12),L.dithering&&o.enable(13),L.specularIntensityMap&&o.enable(14),L.specularColorMap&&o.enable(15),L.transmission&&o.enable(16),L.transmissionMap&&o.enable(17),L.thicknessMap&&o.enable(18),L.sheen&&o.enable(19),L.sheenColorMap&&o.enable(20),L.sheenRoughnessMap&&o.enable(21),L.decodeVideoTexture&&o.enable(22),L.opaque&&o.enable(23),_.push(o.mask)}function b(_){const L=p[_.type];let N;if(L){const B=Vn[L];N=Lf.clone(B.uniforms)}else N=_.uniforms;return N}function v(_,L){let N;for(let B=0,W=l.length;B0?n.push(x):d.transparent===!0?i.push(x):t.push(x)}function c(h,f,d,p,m,g){const x=r(h,f,d,p,m,g);d.transmission>0?n.unshift(x):d.transparent===!0?i.unshift(x):t.unshift(x)}function l(h,f){t.length>1&&t.sort(h||Wv),n.length>1&&n.sort(f||nd),i.length>1&&i.sort(f||nd)}function u(){for(let h=e,f=a.length;h=a.get(n).length?(s=new id,a.get(n).push(s)):s=a.get(n)[i],s}function t(){a=new WeakMap}return{get:e,dispose:t}}function Xv(){const a={};return{get:function(e){if(a[e.id]!==void 0)return a[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new D,color:new ve};break;case"SpotLight":t={position:new D,direction:new D,color:new ve,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new D,color:new ve,distance:0,decay:0};break;case"HemisphereLight":t={direction:new D,skyColor:new ve,groundColor:new ve};break;case"RectAreaLight":t={color:new ve,position:new D,halfWidth:new D,halfHeight:new D};break}return a[e.id]=t,t}}}function jv(){const a={};return{get:function(e){if(a[e.id]!==void 0)return a[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new he};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new he};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new he,shadowCameraNear:1,shadowCameraFar:1e3};break}return a[e.id]=t,t}}}let Yv=0;function Zv(a,e){return(e.castShadow?1:0)-(a.castShadow?1:0)}function Kv(a,e){const t=new Xv,n=jv(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let u=0;u<9;u++)i.probe.push(new D);const s=new D,r=new Ie,o=new Ie;function c(u,h){let f=0,d=0,p=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let m=0,g=0,x=0,y=0,b=0,v=0,S=0,A=0;u.sort(Zv);const R=h!==!0?Math.PI:1;for(let L=0,N=u.length;L0&&(e.isWebGL2||a.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Re.LTC_FLOAT_1,i.rectAreaLTC2=Re.LTC_FLOAT_2):a.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Re.LTC_HALF_1,i.rectAreaLTC2=Re.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=f,i.ambient[1]=d,i.ambient[2]=p;const _=i.hash;(_.directionalLength!==m||_.pointLength!==g||_.spotLength!==x||_.rectAreaLength!==y||_.hemiLength!==b||_.numDirectionalShadows!==v||_.numPointShadows!==S||_.numSpotShadows!==A)&&(i.directional.length=m,i.spot.length=x,i.rectArea.length=y,i.point.length=g,i.hemi.length=b,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.pointShadow.length=S,i.pointShadowMap.length=S,i.spotShadow.length=A,i.spotShadowMap.length=A,i.directionalShadowMatrix.length=v,i.pointShadowMatrix.length=S,i.spotShadowMatrix.length=A,_.directionalLength=m,_.pointLength=g,_.spotLength=x,_.rectAreaLength=y,_.hemiLength=b,_.numDirectionalShadows=v,_.numPointShadows=S,_.numSpotShadows=A,i.version=Yv++)}function l(u,h){let f=0,d=0,p=0,m=0,g=0;const x=h.matrixWorldInverse;for(let y=0,b=u.length;y=t.get(s).length?(o=new sd(a,e),t.get(s).push(o)):o=t.get(s)[r],o}function i(){t=new WeakMap}return{get:n,dispose:i}}class jl extends Bt{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=uf,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Yl extends Bt{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new D,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const $v=`void main() { +Program Info Log: `+E+` +`+G+` +`+X)}else E!==""?console.warn("THREE.WebGLProgram: Program Info Log:",E):(F===""||U==="")&&(J=!1);J&&(this.diagnostics={runnable:q,programLog:E,vertexShader:{log:F,prefix:g},fragmentShader:{log:U,prefix:x}})}i.deleteShader(M),i.deleteShader(T);let C;this.getUniforms=function(){return C===void 0&&(C=new Da(i,m)),C};let _;return this.getAttributes=function(){return _===void 0&&(_=Ev(i,m)),_},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(m),this.program=void 0},this.name=t.shaderName,this.id=_v++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=M,this.fragmentShader=T,this}let zv=0;class Uv{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),r=this._getShaderCacheForMaterial(e);return r.has(i)===!1&&(r.add(i),i.usedTimes++),r.has(s)===!1&&(r.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;return t.has(e)===!1&&t.set(e,new Set),t.get(e)}_getShaderStage(e){const t=this.shaderCache;if(t.has(e)===!1){const n=new Gv(e);t.set(e,n)}return t.get(e)}}class Gv{constructor(e){this.id=zv++,this.code=e,this.usedTimes=0}}function Vv(a,e,t,n,i,s,r){const o=new ga,c=new Uv,l=[],u=i.isWebGL2,h=i.logarithmicDepthBuffer,f=i.vertexTextures;let d=i.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(_,E,F,U,q){const J=U.fog,G=q.geometry,X=_.isMeshStandardMaterial?U.environment:null,B=(_.isMeshStandardMaterial?t:e).get(_.envMap||X),Z=!!B&&B.mapping===Xs?B.image.height:null,Y=p[_.type];_.precision!==null&&(d=i.getMaxPrecision(_.precision),d!==_.precision&&console.warn("THREE.WebGLProgram.getParameters:",_.precision,"not supported, using",d,"instead."));const W=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,j=W!==void 0?W.length:0;let ne=0;G.morphAttributes.position!==void 0&&(ne=1),G.morphAttributes.normal!==void 0&&(ne=2),G.morphAttributes.color!==void 0&&(ne=3);let $,ie,ce,oe;if(Y){const Ve=Vn[Y];$=Ve.vertexShader,ie=Ve.fragmentShader}else $=_.vertexShader,ie=_.fragmentShader,c.update(_),ce=c.getVertexShaderID(_),oe=c.getFragmentShaderID(_);const H=a.getRenderTarget(),ye=_.alphaTest>0,we=_.clearcoat>0,De=_.iridescence>0;return{isWebGL2:u,shaderID:Y,shaderName:_.type,vertexShader:$,fragmentShader:ie,defines:_.defines,customVertexShaderID:ce,customFragmentShaderID:oe,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:d,instancing:q.isInstancedMesh===!0,instancingColor:q.isInstancedMesh===!0&&q.instanceColor!==null,supportsVertexTextures:f,outputEncoding:H===null?a.outputEncoding:H.isXRRenderTarget===!0?H.texture.encoding:ui,map:!!_.map,matcap:!!_.matcap,envMap:!!B,envMapMode:B&&B.mapping,envMapCubeUVHeight:Z,lightMap:!!_.lightMap,aoMap:!!_.aoMap,emissiveMap:!!_.emissiveMap,bumpMap:!!_.bumpMap,normalMap:!!_.normalMap,objectSpaceNormalMap:_.normalMapType===df,tangentSpaceNormalMap:_.normalMapType===Fi,decodeVideoTexture:!!_.map&&_.map.isVideoTexture===!0&&_.map.encoding===nt,clearcoat:we,clearcoatMap:we&&!!_.clearcoatMap,clearcoatRoughnessMap:we&&!!_.clearcoatRoughnessMap,clearcoatNormalMap:we&&!!_.clearcoatNormalMap,iridescence:De,iridescenceMap:De&&!!_.iridescenceMap,iridescenceThicknessMap:De&&!!_.iridescenceThicknessMap,displacementMap:!!_.displacementMap,roughnessMap:!!_.roughnessMap,metalnessMap:!!_.metalnessMap,specularMap:!!_.specularMap,specularIntensityMap:!!_.specularIntensityMap,specularColorMap:!!_.specularColorMap,opaque:_.transparent===!1&&_.blending===rs,alphaMap:!!_.alphaMap,alphaTest:ye,gradientMap:!!_.gradientMap,sheen:_.sheen>0,sheenColorMap:!!_.sheenColorMap,sheenRoughnessMap:!!_.sheenRoughnessMap,transmission:_.transmission>0,transmissionMap:!!_.transmissionMap,thicknessMap:!!_.thicknessMap,combine:_.combine,vertexTangents:!!_.normalMap&&!!G.attributes.tangent,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,vertexUvs:!!_.map||!!_.bumpMap||!!_.normalMap||!!_.specularMap||!!_.alphaMap||!!_.emissiveMap||!!_.roughnessMap||!!_.metalnessMap||!!_.clearcoatMap||!!_.clearcoatRoughnessMap||!!_.clearcoatNormalMap||!!_.iridescenceMap||!!_.iridescenceThicknessMap||!!_.displacementMap||!!_.transmissionMap||!!_.thicknessMap||!!_.specularIntensityMap||!!_.specularColorMap||!!_.sheenColorMap||!!_.sheenRoughnessMap,uvsVertexOnly:!(!!_.map||!!_.bumpMap||!!_.normalMap||!!_.specularMap||!!_.alphaMap||!!_.emissiveMap||!!_.roughnessMap||!!_.metalnessMap||!!_.clearcoatNormalMap||!!_.iridescenceMap||!!_.iridescenceThicknessMap||_.transmission>0||!!_.transmissionMap||!!_.thicknessMap||!!_.specularIntensityMap||!!_.specularColorMap||_.sheen>0||!!_.sheenColorMap||!!_.sheenRoughnessMap)&&!!_.displacementMap,fog:!!J,useFog:_.fog===!0,fogExp2:J&&J.isFogExp2,flatShading:!!_.flatShading,sizeAttenuation:_.sizeAttenuation,logarithmicDepthBuffer:h,skinning:q.isSkinnedMesh===!0,morphTargets:G.morphAttributes.position!==void 0,morphNormals:G.morphAttributes.normal!==void 0,morphColors:G.morphAttributes.color!==void 0,morphTargetsCount:j,morphTextureStride:ne,numDirLights:E.directional.length,numPointLights:E.point.length,numSpotLights:E.spot.length,numRectAreaLights:E.rectArea.length,numHemiLights:E.hemi.length,numDirLightShadows:E.directionalShadowMap.length,numPointLightShadows:E.pointShadowMap.length,numSpotLightShadows:E.spotShadowMap.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:_.dithering,shadowMapEnabled:a.shadowMap.enabled&&F.length>0,shadowMapType:a.shadowMap.type,toneMapping:_.toneMapped?a.toneMapping:Xn,physicallyCorrectLights:a.physicallyCorrectLights,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===ai,flipSided:_.side===Tn,useDepthPacking:!!_.depthPacking,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionDerivatives:_.extensions&&_.extensions.derivatives,extensionFragDepth:_.extensions&&_.extensions.fragDepth,extensionDrawBuffers:_.extensions&&_.extensions.drawBuffers,extensionShaderTextureLOD:_.extensions&&_.extensions.shaderTextureLOD,rendererExtensionFragDepth:u||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||n.has("EXT_shader_texture_lod"),customProgramCacheKey:_.customProgramCacheKey()}}function g(_){const E=[];if(_.shaderID?E.push(_.shaderID):(E.push(_.customVertexShaderID),E.push(_.customFragmentShaderID)),_.defines!==void 0)for(const F in _.defines)E.push(F),E.push(_.defines[F]);return _.isRawShaderMaterial===!1&&(x(E,_),y(E,_),E.push(a.outputEncoding)),E.push(_.customProgramCacheKey),E.join()}function x(_,E){_.push(E.precision),_.push(E.outputEncoding),_.push(E.envMapMode),_.push(E.envMapCubeUVHeight),_.push(E.combine),_.push(E.vertexUvs),_.push(E.fogExp2),_.push(E.sizeAttenuation),_.push(E.morphTargetsCount),_.push(E.morphAttributeCount),_.push(E.numDirLights),_.push(E.numPointLights),_.push(E.numSpotLights),_.push(E.numHemiLights),_.push(E.numRectAreaLights),_.push(E.numDirLightShadows),_.push(E.numPointLightShadows),_.push(E.numSpotLightShadows),_.push(E.shadowMapType),_.push(E.toneMapping),_.push(E.numClippingPlanes),_.push(E.numClipIntersection),_.push(E.depthPacking)}function y(_,E){o.disableAll(),E.isWebGL2&&o.enable(0),E.supportsVertexTextures&&o.enable(1),E.instancing&&o.enable(2),E.instancingColor&&o.enable(3),E.map&&o.enable(4),E.matcap&&o.enable(5),E.envMap&&o.enable(6),E.lightMap&&o.enable(7),E.aoMap&&o.enable(8),E.emissiveMap&&o.enable(9),E.bumpMap&&o.enable(10),E.normalMap&&o.enable(11),E.objectSpaceNormalMap&&o.enable(12),E.tangentSpaceNormalMap&&o.enable(13),E.clearcoat&&o.enable(14),E.clearcoatMap&&o.enable(15),E.clearcoatRoughnessMap&&o.enable(16),E.clearcoatNormalMap&&o.enable(17),E.iridescence&&o.enable(18),E.iridescenceMap&&o.enable(19),E.iridescenceThicknessMap&&o.enable(20),E.displacementMap&&o.enable(21),E.specularMap&&o.enable(22),E.roughnessMap&&o.enable(23),E.metalnessMap&&o.enable(24),E.gradientMap&&o.enable(25),E.alphaMap&&o.enable(26),E.alphaTest&&o.enable(27),E.vertexColors&&o.enable(28),E.vertexAlphas&&o.enable(29),E.vertexUvs&&o.enable(30),E.vertexTangents&&o.enable(31),E.uvsVertexOnly&&o.enable(32),E.fog&&o.enable(33),_.push(o.mask),o.disableAll(),E.useFog&&o.enable(0),E.flatShading&&o.enable(1),E.logarithmicDepthBuffer&&o.enable(2),E.skinning&&o.enable(3),E.morphTargets&&o.enable(4),E.morphNormals&&o.enable(5),E.morphColors&&o.enable(6),E.premultipliedAlpha&&o.enable(7),E.shadowMapEnabled&&o.enable(8),E.physicallyCorrectLights&&o.enable(9),E.doubleSided&&o.enable(10),E.flipSided&&o.enable(11),E.useDepthPacking&&o.enable(12),E.dithering&&o.enable(13),E.specularIntensityMap&&o.enable(14),E.specularColorMap&&o.enable(15),E.transmission&&o.enable(16),E.transmissionMap&&o.enable(17),E.thicknessMap&&o.enable(18),E.sheen&&o.enable(19),E.sheenColorMap&&o.enable(20),E.sheenRoughnessMap&&o.enable(21),E.decodeVideoTexture&&o.enable(22),E.opaque&&o.enable(23),_.push(o.mask)}function b(_){const E=p[_.type];let F;if(E){const U=Vn[E];F=Rf.clone(U.uniforms)}else F=_.uniforms;return F}function v(_,E){let F;for(let U=0,q=l.length;U0?n.push(x):d.transparent===!0?i.push(x):t.push(x)}function c(h,f,d,p,m,g){const x=r(h,f,d,p,m,g);d.transmission>0?n.unshift(x):d.transparent===!0?i.unshift(x):t.unshift(x)}function l(h,f){t.length>1&&t.sort(h||Wv),n.length>1&&n.sort(f||id),i.length>1&&i.sort(f||id)}function u(){for(let h=e,f=a.length;h=a.get(n).length?(s=new sd,a.get(n).push(s)):s=a.get(n)[i],s}function t(){a=new WeakMap}return{get:e,dispose:t}}function Xv(){const a={};return{get:function(e){if(a[e.id]!==void 0)return a[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new P,color:new be};break;case"SpotLight":t={position:new P,direction:new P,color:new be,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new P,color:new be,distance:0,decay:0};break;case"HemisphereLight":t={direction:new P,skyColor:new be,groundColor:new be};break;case"RectAreaLight":t={color:new be,position:new P,halfWidth:new P,halfHeight:new P};break}return a[e.id]=t,t}}}function jv(){const a={};return{get:function(e){if(a[e.id]!==void 0)return a[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new fe};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new fe};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new fe,shadowCameraNear:1,shadowCameraFar:1e3};break}return a[e.id]=t,t}}}let Yv=0;function Zv(a,e){return(e.castShadow?1:0)-(a.castShadow?1:0)}function Kv(a,e){const t=new Xv,n=jv(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let u=0;u<9;u++)i.probe.push(new P);const s=new P,r=new Pe,o=new Pe;function c(u,h){let f=0,d=0,p=0;for(let E=0;E<9;E++)i.probe[E].set(0,0,0);let m=0,g=0,x=0,y=0,b=0,v=0,M=0,T=0;u.sort(Zv);const C=h!==!0?Math.PI:1;for(let E=0,F=u.length;E0&&(e.isWebGL2||a.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Re.LTC_FLOAT_1,i.rectAreaLTC2=Re.LTC_FLOAT_2):a.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Re.LTC_HALF_1,i.rectAreaLTC2=Re.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=f,i.ambient[1]=d,i.ambient[2]=p;const _=i.hash;(_.directionalLength!==m||_.pointLength!==g||_.spotLength!==x||_.rectAreaLength!==y||_.hemiLength!==b||_.numDirectionalShadows!==v||_.numPointShadows!==M||_.numSpotShadows!==T)&&(i.directional.length=m,i.spot.length=x,i.rectArea.length=y,i.point.length=g,i.hemi.length=b,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.pointShadow.length=M,i.pointShadowMap.length=M,i.spotShadow.length=T,i.spotShadowMap.length=T,i.directionalShadowMatrix.length=v,i.pointShadowMatrix.length=M,i.spotShadowMatrix.length=T,_.directionalLength=m,_.pointLength=g,_.spotLength=x,_.rectAreaLength=y,_.hemiLength=b,_.numDirectionalShadows=v,_.numPointShadows=M,_.numSpotShadows=T,i.version=Yv++)}function l(u,h){let f=0,d=0,p=0,m=0,g=0;const x=h.matrixWorldInverse;for(let y=0,b=u.length;y=t.get(s).length?(o=new rd(a,e),t.get(s).push(o)):o=t.get(s)[r],o}function i(){t=new WeakMap}return{get:n,dispose:i}}class Yl extends Bt{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=hf,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Zl extends Bt{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new P,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const $v=`void main() { gl_Position = vec4( position, 1.0 ); }`,Qv=`uniform sampler2D shadow_pass; uniform vec2 resolution; @@ -3138,22 +3138,22 @@ void main() { squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); -}`;function e_(a,e,t){let n=new Ra;const i=new he,s=new he,r=new ut,o=new jl({depthPacking:hf}),c=new Yl,l={},u=t.maxTextureSize,h={0:Tn,1:oi,2:ai},f=new Kn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new he},radius:{value:4}},vertexShader:$v,fragmentShader:Qv}),d=f.clone();d.defines.HORIZONTAL_PASS=1;const p=new qe;p.setAttribute("position",new ht(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new St(p,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Nc,this.render=function(v,S,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||v.length===0)return;const R=a.getRenderTarget(),_=a.getActiveCubeFace(),L=a.getActiveMipmapLevel(),N=a.state;N.setBlending(ci),N.buffers.color.setClear(1,1,1,1),N.buffers.depth.setTest(!0),N.setScissorTest(!1);for(let B=0,W=v.length;Bu||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/q.x),i.x=s.x*q.x,z.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/q.y),i.y=s.y*q.y,z.mapSize.y=s.y)),z.map===null){const Y=this.type!==Ws?{minFilter:kt,magFilter:kt}:{};z.map=new En(i.x,i.y,Y),z.map.texture.name=K.name+".shadowMap",z.camera.updateProjectionMatrix()}a.setRenderTarget(z.map),a.clear();const O=z.getViewportCount();for(let Y=0;Y0){const W=N.uuid,K=S.uuid;let z=l[W];z===void 0&&(z={},l[W]=z);let q=z[K];q===void 0&&(q=N.clone(),z[K]=q),N=q}return N.visible=S.visible,N.wireframe=S.wireframe,L===Ws?N.side=S.shadowSide!==null?S.shadowSide:S.side:N.side=S.shadowSide!==null?S.shadowSide:h[S.side],N.alphaMap=S.alphaMap,N.alphaTest=S.alphaTest,N.clipShadows=S.clipShadows,N.clippingPlanes=S.clippingPlanes,N.clipIntersection=S.clipIntersection,N.displacementMap=S.displacementMap,N.displacementScale=S.displacementScale,N.displacementBias=S.displacementBias,N.wireframeLinewidth=S.wireframeLinewidth,N.linewidth=S.linewidth,A.isPointLight===!0&&N.isMeshDistanceMaterial===!0&&(N.referencePosition.setFromMatrixPosition(A.matrixWorld),N.nearDistance=R,N.farDistance=_),N}function b(v,S,A,R,_){if(v.visible===!1)return;if(v.layers.test(S.layers)&&(v.isMesh||v.isLine||v.isPoints)&&(v.castShadow||v.receiveShadow&&_===Ws)&&(!v.frustumCulled||n.intersectsObject(v))){v.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,v.matrixWorld);const B=e.update(v),W=v.material;if(Array.isArray(W)){const K=B.groups;for(let z=0,q=K.length;z=1):j.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),O=Y>=2);let H=null,X={};const te=a.getParameter(3088),J=a.getParameter(2978),ne=new ut().fromArray(te),re=new ut().fromArray(J);function se(G,Te,oe){const Ce=new Uint8Array(4),De=a.createTexture();a.bindTexture(G,De),a.texParameteri(G,10241,9728),a.texParameteri(G,10240,9728);for(let dt=0;dtZ||E.height>Z)&&(Q=Z/Math.max(E.width,E.height)),Q<1||w===!0)if(typeof HTMLImageElement!="undefined"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&E instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&E instanceof ImageBitmap){const de=w?ra:Math.floor,Le=de(Q*E.width),F=de(Q*E.height);m===void 0&&(m=y(Le,F));const ue=U?y(Le,F):m;return ue.width=Le,ue.height=F,ue.getContext("2d").drawImage(E,0,0,Le,F),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+E.width+"x"+E.height+") to ("+Le+"x"+F+")."),ue}else return"data"in E&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+E.width+"x"+E.height+")."),E;return E}function v(E){return gl(E.width)&&gl(E.height)}function S(E){return o?!1:E.wrapS!==Wt||E.wrapT!==Wt||E.minFilter!==kt&&E.minFilter!==Et}function A(E,w){return E.generateMipmaps&&w&&E.minFilter!==kt&&E.minFilter!==Et}function R(E){a.generateMipmap(E)}function _(E,w,U,Z,Q=!1){if(o===!1)return w;if(E!==null){if(a[E]!==void 0)return a[E];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let de=w;return w===6403&&(U===5126&&(de=33326),U===5131&&(de=33325),U===5121&&(de=33321)),w===33319&&(U===5126&&(de=33328),U===5131&&(de=33327),U===5121&&(de=33323)),w===6408&&(U===5126&&(de=34836),U===5131&&(de=34842),U===5121&&(de=Z===tt&&Q===!1?35907:32856),U===32819&&(de=32854),U===32820&&(de=32855)),(de===33325||de===33326||de===33327||de===33328||de===34842||de===34836)&&e.get("EXT_color_buffer_float"),de}function L(E,w,U){return A(E,U)===!0||E.isFramebufferTexture&&E.minFilter!==kt&&E.minFilter!==Et?Math.log2(Math.max(w.width,w.height))+1:E.mipmaps!==void 0&&E.mipmaps.length>0?E.mipmaps.length:E.isCompressedTexture&&Array.isArray(E.image)?w.mipmaps.length:1}function N(E){return E===kt||E===eo||E===to?9728:9729}function B(E){const w=E.target;w.removeEventListener("dispose",B),K(w),w.isVideoTexture&&p.delete(w)}function W(E){const w=E.target;w.removeEventListener("dispose",W),q(w)}function K(E){const w=n.get(E);if(w.__webglInit===void 0)return;const U=E.source,Z=g.get(U);if(Z){const Q=Z[w.__cacheKey];Q.usedTimes--,Q.usedTimes===0&&z(E),Object.keys(Z).length===0&&g.delete(U)}n.remove(E)}function z(E){const w=n.get(E);a.deleteTexture(w.__webglTexture);const U=E.source,Z=g.get(U);delete Z[w.__cacheKey],r.memory.textures--}function q(E){const w=E.texture,U=n.get(E),Z=n.get(w);if(Z.__webglTexture!==void 0&&(a.deleteTexture(Z.__webglTexture),r.memory.textures--),E.depthTexture&&E.depthTexture.dispose(),E.isWebGLCubeRenderTarget)for(let Q=0;Q<6;Q++)a.deleteFramebuffer(U.__webglFramebuffer[Q]),U.__webglDepthbuffer&&a.deleteRenderbuffer(U.__webglDepthbuffer[Q]);else{if(a.deleteFramebuffer(U.__webglFramebuffer),U.__webglDepthbuffer&&a.deleteRenderbuffer(U.__webglDepthbuffer),U.__webglMultisampledFramebuffer&&a.deleteFramebuffer(U.__webglMultisampledFramebuffer),U.__webglColorRenderbuffer)for(let Q=0;Q=c&&console.warn("THREE.WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+c),O+=1,E}function H(E){const w=[];return w.push(E.wrapS),w.push(E.wrapT),w.push(E.magFilter),w.push(E.minFilter),w.push(E.anisotropy),w.push(E.internalFormat),w.push(E.format),w.push(E.type),w.push(E.generateMipmaps),w.push(E.premultiplyAlpha),w.push(E.flipY),w.push(E.unpackAlignment),w.push(E.encoding),w.join()}function X(E,w){const U=n.get(E);if(E.isVideoTexture&&ft(E),E.isRenderTargetTexture===!1&&E.version>0&&U.__version!==E.version){const Z=E.image;if(Z===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Z.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{_e(U,E,w);return}}t.activeTexture(33984+w),t.bindTexture(3553,U.__webglTexture)}function te(E,w){const U=n.get(E);if(E.version>0&&U.__version!==E.version){_e(U,E,w);return}t.activeTexture(33984+w),t.bindTexture(35866,U.__webglTexture)}function J(E,w){const U=n.get(E);if(E.version>0&&U.__version!==E.version){_e(U,E,w);return}t.activeTexture(33984+w),t.bindTexture(32879,U.__webglTexture)}function ne(E,w){const U=n.get(E);if(E.version>0&&U.__version!==E.version){Pe(U,E,w);return}t.activeTexture(33984+w),t.bindTexture(34067,U.__webglTexture)}const re={[on]:10497,[Wt]:33071,[js]:33648},se={[kt]:9728,[eo]:9984,[to]:9986,[Et]:9729,[Qo]:9985,[jn]:9987};function V(E,w,U){if(U?(a.texParameteri(E,10242,re[w.wrapS]),a.texParameteri(E,10243,re[w.wrapT]),(E===32879||E===35866)&&a.texParameteri(E,32882,re[w.wrapR]),a.texParameteri(E,10240,se[w.magFilter]),a.texParameteri(E,10241,se[w.minFilter])):(a.texParameteri(E,10242,33071),a.texParameteri(E,10243,33071),(E===32879||E===35866)&&a.texParameteri(E,32882,33071),(w.wrapS!==Wt||w.wrapT!==Wt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),a.texParameteri(E,10240,N(w.magFilter)),a.texParameteri(E,10241,N(w.minFilter)),w.minFilter!==kt&&w.minFilter!==Et&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){const Z=e.get("EXT_texture_filter_anisotropic");if(w.type===li&&e.has("OES_texture_float_linear")===!1||o===!1&&w.type===Ys&&e.has("OES_texture_half_float_linear")===!1)return;(w.anisotropy>1||n.get(w).__currentAnisotropy)&&(a.texParameterf(E,Z.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(w.anisotropy,i.getMaxAnisotropy())),n.get(w).__currentAnisotropy=w.anisotropy)}}function me(E,w){let U=!1;E.__webglInit===void 0&&(E.__webglInit=!0,w.addEventListener("dispose",B));const Z=w.source;let Q=g.get(Z);Q===void 0&&(Q={},g.set(Z,Q));const de=H(w);if(de!==E.__cacheKey){Q[de]===void 0&&(Q[de]={texture:a.createTexture(),usedTimes:0},r.memory.textures++,U=!0),Q[de].usedTimes++;const Le=Q[E.__cacheKey];Le!==void 0&&(Q[E.__cacheKey].usedTimes--,Le.usedTimes===0&&z(w)),E.__cacheKey=de,E.__webglTexture=Q[de].texture}return U}function _e(E,w,U){let Z=3553;w.isDataArrayTexture&&(Z=35866),w.isData3DTexture&&(Z=32879);const Q=me(E,w),de=w.source;if(t.activeTexture(33984+U),t.bindTexture(Z,E.__webglTexture),de.version!==de.__currentVersion||Q===!0){a.pixelStorei(37440,w.flipY),a.pixelStorei(37441,w.premultiplyAlpha),a.pixelStorei(3317,w.unpackAlignment),a.pixelStorei(37443,0);const Le=S(w)&&v(w.image)===!1;let F=b(w.image,Le,!1,u);F=at(w,F);const ue=v(F)||o,ge=s.convert(w.format,w.encoding);let Ee=s.convert(w.type),Se=_(w.internalFormat,ge,Ee,w.encoding,w.isVideoTexture);V(Z,w,ue);let Oe;const Xe=w.mipmaps,$e=o&&w.isVideoTexture!==!0,G=de.__currentVersion===void 0||Q===!0,Te=L(w,F,ue);if(w.isDepthTexture)Se=6402,o?w.type===li?Se=36012:w.type===Pi?Se=33190:w.type===as?Se=35056:Se=33189:w.type===li&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),w.format===Di&&Se===6402&&w.type!==Hc&&w.type!==Pi&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),w.type=Pi,Ee=s.convert(w.type)),w.format===cs&&Se===6402&&(Se=34041,w.type!==as&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),w.type=as,Ee=s.convert(w.type))),G&&($e?t.texStorage2D(3553,1,Se,F.width,F.height):t.texImage2D(3553,0,Se,F.width,F.height,0,ge,Ee,null));else if(w.isDataTexture)if(Xe.length>0&&ue){$e&&G&&t.texStorage2D(3553,Te,Se,Xe[0].width,Xe[0].height);for(let oe=0,Ce=Xe.length;oe>=1,Ce>>=1}}else if(Xe.length>0&&ue){$e&&G&&t.texStorage2D(3553,Te,Se,Xe[0].width,Xe[0].height);for(let oe=0,Ce=Xe.length;oe0&&G++,t.texStorage2D(34067,G,Oe,F[0].width,F[0].height));for(let oe=0;oe<6;oe++)if(Le){Xe?t.texSubImage2D(34069+oe,0,0,0,F[oe].width,F[oe].height,Ee,Se,F[oe].data):t.texImage2D(34069+oe,0,Oe,F[oe].width,F[oe].height,0,Ee,Se,F[oe].data);for(let Ce=0;Ce0&&ze(E)===!1){const F=de?w:[w];U.__webglMultisampledFramebuffer=a.createFramebuffer(),U.__webglColorRenderbuffer=[],t.bindFramebuffer(36160,U.__webglMultisampledFramebuffer);for(let ue=0;ue0&&ze(E)===!1){const w=E.isWebGLMultipleRenderTargets?E.texture:[E.texture],U=E.width,Z=E.height;let Q=16384;const de=[],Le=E.stencilBuffer?33306:36096,F=n.get(E),ue=E.isWebGLMultipleRenderTargets===!0;if(ue)for(let ge=0;ge0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&w.__useRenderToTexture!==!1}function ft(E){const w=r.render.frame;p.get(E)!==w&&(p.set(E,w),E.update())}function at(E,w){const U=E.encoding,Z=E.format,Q=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||E.format===sa||U!==ui&&(U===tt?o===!1?e.has("EXT_sRGB")===!0&&Z===_n?(E.format=sa,E.minFilter=Et,E.generateMipmaps=!1):w=vl.sRGBToLinear(w):(Z!==_n||Q!==Ii)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",U)),w}this.allocateTextureUnit=j,this.resetTextureUnits=Y,this.setTexture2D=X,this.setTexture2DArray=te,this.setTexture3D=J,this.setTextureCube=ne,this.rebindTextures=xe,this.setupRenderTarget=Fe,this.updateRenderTargetMipmap=Me,this.updateMultisampleRenderTarget=Ye,this.setupDepthRenderbuffer=ce,this.setupFrameBufferTexture=ye,this.useMultisampledRTT=ze}function rd(a,e,t){const n=t.isWebGL2;function i(s,r=null){let o;if(s===Ii)return 5121;if(s===Yh)return 32819;if(s===Zh)return 32820;if(s===qh)return 5120;if(s===Xh)return 5122;if(s===Hc)return 5123;if(s===jh)return 5124;if(s===Pi)return 5125;if(s===li)return 5126;if(s===Ys)return n?5131:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===Kh)return 6406;if(s===_n)return 6408;if(s===$h)return 6409;if(s===Qh)return 6410;if(s===Di)return 6402;if(s===cs)return 34041;if(s===ef)return 6403;if(s===Jh)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(s===sa)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(s===tf)return 36244;if(s===nf)return 33319;if(s===sf)return 33320;if(s===rf)return 36249;if(s===no||s===ea||s===io||s===so)if(r===tt)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(s===no)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===ea)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===io)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===so)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===no)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===ea)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===io)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===so)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Wc||s===qc||s===Xc||s===jc)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===Wc)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===qc)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Xc)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===jc)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===Yc)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Zc||s===Kc)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(s===Zc)return r===tt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(s===Kc)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===Jc||s===$c||s===Qc||s===el||s===tl||s===nl||s===il||s===sl||s===rl||s===ol||s===al||s===cl||s===ll||s===ul)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(s===Jc)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===$c)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===Qc)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===el)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===tl)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===nl)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===il)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===sl)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===rl)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===ol)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===al)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===cl)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===ll)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===ul)return r===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===hl)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(s===hl)return r===tt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;return s===as?n?34042:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):a[s]!==void 0?a[s]:null}return{convert:i}}class od extends Dt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class dn extends ct{constructor(){super(),this.isGroup=!0,this.type="Group"}}const i_={type:"move"};class Zl{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new dn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new dn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new D,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new D),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new dn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new D,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new D),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,s=null,r=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){r=!0;for(const m of e.hand.values()){const g=t.getJointPose(m,n);if(l.joints[m.jointName]===void 0){const y=new dn;y.matrixAutoUpdate=!1,y.visible=!1,l.joints[m.jointName]=y,l.add(y)}const x=l.joints[m.jointName];g!==null&&(x.matrix.fromArray(g.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.jointRadius=g.radius),x.visible=g!==null}const u=l.joints["index-finger-tip"],h=l.joints["thumb-tip"],f=u.position.distanceTo(h.position),d=.02,p=.005;l.inputState.pinching&&f>d+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&f<=d-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(i_)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=r!==null),this}}class ad extends Mt{constructor(e,t,n,i,s,r,o,c,l,u){if(u=u!==void 0?u:Di,u!==Di&&u!==cs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&u===Di&&(n=Pi),n===void 0&&u===cs&&(n=as),super(null,i,s,r,o,c,u,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=o!==void 0?o:kt,this.minFilter=c!==void 0?c:kt,this.flipY=!1,this.generateMipmaps=!1}}class s_ extends Zn{constructor(e,t){super();const n=this;let i=null,s=1,r=null,o="local-floor",c=null,l=null,u=null,h=null,f=null,d=null;const p=t.getContextAttributes();let m=null,g=null;const x=[],y=[],b=new Dt;b.layers.enable(1),b.viewport=new ut;const v=new Dt;v.layers.enable(2),v.viewport=new ut;const S=[b,v],A=new od;A.layers.enable(1),A.layers.enable(2);let R=null,_=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(H){let X=x[H];return X===void 0&&(X=new Zl,x[H]=X),X.getTargetRaySpace()},this.getControllerGrip=function(H){let X=x[H];return X===void 0&&(X=new Zl,x[H]=X),X.getGripSpace()},this.getHand=function(H){let X=x[H];return X===void 0&&(X=new Zl,x[H]=X),X.getHandSpace()};function L(H){const X=y.indexOf(H.inputSource);if(X===-1)return;const te=x[X];te!==void 0&&te.dispatchEvent({type:H.type,data:H.inputSource})}function N(){i.removeEventListener("select",L),i.removeEventListener("selectstart",L),i.removeEventListener("selectend",L),i.removeEventListener("squeeze",L),i.removeEventListener("squeezestart",L),i.removeEventListener("squeezeend",L),i.removeEventListener("end",N),i.removeEventListener("inputsourceschange",B);for(let H=0;H=0&&(y[J]=null,x[J].dispatchEvent({type:"disconnected",data:te}))}for(let X=0;X=y.length){y.push(te),J=re;break}else if(y[re]===null){y[re]=te,J=re;break}if(J===-1)break}const ne=x[J];ne&&ne.dispatchEvent({type:"connected",data:te})}}const W=new D,K=new D;function z(H,X,te){W.setFromMatrixPosition(X.matrixWorld),K.setFromMatrixPosition(te.matrixWorld);const J=W.distanceTo(K),ne=X.projectionMatrix.elements,re=te.projectionMatrix.elements,se=ne[14]/(ne[10]-1),V=ne[14]/(ne[10]+1),me=(ne[9]+1)/ne[5],_e=(ne[9]-1)/ne[5],Pe=(ne[8]-1)/ne[0],ye=(re[8]+1)/re[0],He=se*Pe,le=se*ye,ce=J/(-Pe+ye),xe=ce*-Pe;X.matrixWorld.decompose(H.position,H.quaternion,H.scale),H.translateX(xe),H.translateZ(ce),H.matrixWorld.compose(H.position,H.quaternion,H.scale),H.matrixWorldInverse.copy(H.matrixWorld).invert();const Fe=se+ce,Me=V+ce,Ye=He-xe,Ue=le+(J-xe),ze=me*V/Me*Fe,ft=_e*V/Me*Fe;H.projectionMatrix.makePerspective(Ye,Ue,ze,ft,Fe,Me)}function q(H,X){X===null?H.matrixWorld.copy(H.matrix):H.matrixWorld.multiplyMatrices(X.matrixWorld,H.matrix),H.matrixWorldInverse.copy(H.matrixWorld).invert()}this.updateCamera=function(H){if(i===null)return;A.near=v.near=b.near=H.near,A.far=v.far=b.far=H.far,(R!==A.near||_!==A.far)&&(i.updateRenderState({depthNear:A.near,depthFar:A.far}),R=A.near,_=A.far);const X=H.parent,te=A.cameras;q(A,X);for(let ne=0;ne0&&(m.alphaTest.value=g.alphaTest);const x=e.get(g).envMap;if(x&&(m.envMap.value=x,m.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap){m.lightMap.value=g.lightMap;const v=a.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*v}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity);let y;g.map?y=g.map:g.specularMap?y=g.specularMap:g.displacementMap?y=g.displacementMap:g.normalMap?y=g.normalMap:g.bumpMap?y=g.bumpMap:g.roughnessMap?y=g.roughnessMap:g.metalnessMap?y=g.metalnessMap:g.alphaMap?y=g.alphaMap:g.emissiveMap?y=g.emissiveMap:g.clearcoatMap?y=g.clearcoatMap:g.clearcoatNormalMap?y=g.clearcoatNormalMap:g.clearcoatRoughnessMap?y=g.clearcoatRoughnessMap:g.iridescenceMap?y=g.iridescenceMap:g.iridescenceThicknessMap?y=g.iridescenceThicknessMap:g.specularIntensityMap?y=g.specularIntensityMap:g.specularColorMap?y=g.specularColorMap:g.transmissionMap?y=g.transmissionMap:g.thicknessMap?y=g.thicknessMap:g.sheenColorMap?y=g.sheenColorMap:g.sheenRoughnessMap&&(y=g.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix));let b;g.aoMap?b=g.aoMap:g.lightMap&&(b=g.lightMap),b!==void 0&&(b.isWebGLRenderTarget&&(b=b.texture),b.matrixAutoUpdate===!0&&b.updateMatrix(),m.uv2Transform.value.copy(b.matrix))}function s(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity}function r(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function o(m,g,x,y){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*x,m.scale.value=y*.5,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let b;g.map?b=g.map:g.alphaMap&&(b=g.alphaMap),b!==void 0&&(b.matrixAutoUpdate===!0&&b.updateMatrix(),m.uvTransform.value.copy(b.matrix))}function c(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uvTransform.value.copy(x.matrix))}function l(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function u(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function h(m,g){m.roughness.value=g.roughness,m.metalness.value=g.metalness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap),e.get(g).envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,x){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),m.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===Tn&&m.clearcoatNormalScale.value.negate())),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=x.texture,m.transmissionSamplerSize.value.set(x.width,x.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap)}function d(m,g){g.matcap&&(m.matcap.value=g.matcap)}function p(m,g){m.referencePosition.value.copy(g.referencePosition),m.nearDistance.value=g.nearDistance,m.farDistance.value=g.farDistance}return{refreshFogUniforms:t,refreshMaterialUniforms:n}}function o_(a,e,t,n){let i={},s={},r=[];const o=t.isWebGL2?a.getParameter(35375):0;function c(y,b){const v=b.program;n.uniformBlockBinding(y,v)}function l(y,b){let v=i[y.id];v===void 0&&(p(y),v=u(y),i[y.id]=v,y.addEventListener("dispose",g));const S=b.program;n.updateUBOMapping(y,S);const A=e.render.frame;s[y.id]!==A&&(f(y),s[y.id]=A)}function u(y){const b=h();y.__bindingPointIndex=b;const v=a.createBuffer(),S=y.__size,A=y.usage;return a.bindBuffer(35345,v),a.bufferData(35345,S,A),a.bindBuffer(35345,null),a.bindBufferBase(35345,b,v),v}function h(){for(let y=0;y0){A=v%S;const B=S-A;A!==0&&B-N.boundary<0&&(v+=S-A,L.__offset=v)}v+=N.storage}return A=v%S,A>0&&(v+=S-A),y.__size=v,y.__cache={},this}function m(y){const b=y.value,v={boundary:0,storage:0};return typeof b=="number"?(v.boundary=4,v.storage=4):b.isVector2?(v.boundary=8,v.storage=8):b.isVector3||b.isColor?(v.boundary=16,v.storage=12):b.isVector4?(v.boundary=16,v.storage=16):b.isMatrix3?(v.boundary=48,v.storage=48):b.isMatrix4?(v.boundary=64,v.storage=64):b.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",b),v}function g(y){const b=y.target;b.removeEventListener("dispose",g);const v=r.indexOf(b.__bindingPointIndex);r.splice(v,1),a.deleteBuffer(i[b.id]),delete i[b.id],delete s[b.id]}function x(){for(const y in i)a.deleteBuffer(i[y]);r=[],i={},s={}}return{bind:c,update:l,dispose:x}}function a_(){const a=lo("canvas");return a.style.display="block",a}function Kl(a={}){this.isWebGLRenderer=!0;const e=a.canvas!==void 0?a.canvas:a_(),t=a.context!==void 0?a.context:null,n=a.depth!==void 0?a.depth:!0,i=a.stencil!==void 0?a.stencil:!0,s=a.antialias!==void 0?a.antialias:!1,r=a.premultipliedAlpha!==void 0?a.premultipliedAlpha:!0,o=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,c=a.powerPreference!==void 0?a.powerPreference:"default",l=a.failIfMajorPerformanceCaveat!==void 0?a.failIfMajorPerformanceCaveat:!1;let u;t!==null?u=t.getContextAttributes().alpha:u=a.alpha!==void 0?a.alpha:!1;let h=null,f=null;const d=[],p=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=ui,this.physicallyCorrectLights=!1,this.toneMapping=Xn,this.toneMappingExposure=1,Object.defineProperties(this,{gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});const m=this;let g=!1,x=0,y=0,b=null,v=-1,S=null;const A=new ut,R=new ut;let _=null,L=e.width,N=e.height,B=1,W=null,K=null;const z=new ut(0,0,L,N),q=new ut(0,0,L,N);let O=!1;const Y=new Ra;let j=!1,H=!1,X=null;const te=new Ie,J=new he,ne=new D,re={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function se(){return b===null?B:1}let V=t;function me(k,$){for(let ae=0;ae0?f=p[p.length-1]:f=null,d.pop(),d.length>0?h=d[d.length-1]:h=null};function si(k,$,ae,ee){if(k.visible===!1)return;if(k.layers.test($.layers)){if(k.isGroup)ae=k.renderOrder;else if(k.isLOD)k.autoUpdate===!0&&k.update($);else if(k.isLight)f.pushLight(k),k.castShadow&&f.pushShadow(k);else if(k.isSprite){if(!k.frustumCulled||Y.intersectsSprite(k)){ee&&ne.setFromMatrixPosition(k.matrixWorld).applyMatrix4(te);const Je=Ue.update(k),et=k.material;et.visible&&h.push(k,Je,et,ae,ne.z,null)}}else if((k.isMesh||k.isLine||k.isPoints)&&(k.isSkinnedMesh&&k.skeleton.frame!==He.render.frame&&(k.skeleton.update(),k.skeleton.frame=He.render.frame),!k.frustumCulled||Y.intersectsObject(k))){ee&&ne.setFromMatrixPosition(k.matrixWorld).applyMatrix4(te);const Je=Ue.update(k),et=k.material;if(Array.isArray(et)){const Qe=Je.groups;for(let xt=0,lt=Qe.length;xt0&&qn(pe,$,ae),ee&&ye.viewport(A.copy(ee)),pe.length>0&&Tt(pe,$,ae),Ke.length>0&&Tt(Ke,$,ae),Je.length>0&&Tt(Je,$,ae),ye.buffers.depth.setTest(!0),ye.buffers.depth.setMask(!0),ye.buffers.color.setMask(!0),ye.setPolygonOffset(!1)}function qn(k,$,ae){const ee=Pe.isWebGL2;X===null&&(X=new En(1,1,{generateMipmaps:!0,type:_e.has("EXT_color_buffer_half_float")?Ys:Ii,minFilter:jn,samples:ee&&s===!0?4:0})),m.getDrawingBufferSize(J),ee?X.setSize(J.x,J.y):X.setSize(ra(J.x),ra(J.y));const pe=m.getRenderTarget();m.setRenderTarget(X),m.clear();const Ke=m.toneMapping;m.toneMapping=Xn,Tt(k,$,ae),m.toneMapping=Ke,ce.updateMultisampleRenderTarget(X),ce.updateRenderTargetMipmap(X),m.setRenderTarget(pe)}function Tt(k,$,ae){const ee=$.isScene===!0?$.overrideMaterial:null;for(let pe=0,Ke=k.length;pe0&&ce.useMultisampledRTT(k)===!1?pe=le.get(k).__webglMultisampledFramebuffer:pe=xt,A.copy(k.viewport),R.copy(k.scissor),_=k.scissorTest}else A.copy(z).multiplyScalar(B).floor(),R.copy(q).multiplyScalar(B).floor(),_=O;if(ye.bindFramebuffer(36160,pe)&&Pe.drawBuffers&&ee&&ye.drawBuffers(k,pe),ye.viewport(A),ye.scissor(R),ye.setScissorTest(_),Ke){const Qe=le.get(k.texture);V.framebufferTexture2D(36160,36064,34069+$,Qe.__webglTexture,ae)}else if(Je){const Qe=le.get(k.texture),xt=$||0;V.framebufferTextureLayer(36160,36064,Qe.__webglTexture,ae||0,xt)}v=-1},this.readRenderTargetPixels=function(k,$,ae,ee,pe,Ke,Je){if(!(k&&k.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let et=le.get(k).__webglFramebuffer;if(k.isWebGLCubeRenderTarget&&Je!==void 0&&(et=et[Je]),et){ye.bindFramebuffer(36160,et);try{const Qe=k.texture,xt=Qe.format,lt=Qe.type;if(xt!==_n&&F.convert(xt)!==V.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const pt=lt===Ys&&(_e.has("EXT_color_buffer_half_float")||Pe.isWebGL2&&_e.has("EXT_color_buffer_float"));if(lt!==Ii&&F.convert(lt)!==V.getParameter(35738)&&!(lt===li&&(Pe.isWebGL2||_e.has("OES_texture_float")||_e.has("WEBGL_color_buffer_float")))&&!pt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}$>=0&&$<=k.width-ee&&ae>=0&&ae<=k.height-pe&&V.readPixels($,ae,ee,pe,F.convert(xt),F.convert(lt),Ke)}finally{const Qe=b!==null?le.get(b).__webglFramebuffer:null;ye.bindFramebuffer(36160,Qe)}}},this.copyFramebufferToTexture=function(k,$,ae=0){const ee=Math.pow(2,-ae),pe=Math.floor($.image.width*ee),Ke=Math.floor($.image.height*ee);ce.setTexture2D($,0),V.copyTexSubImage2D(3553,ae,0,0,k.x,k.y,pe,Ke),ye.unbindTexture()},this.copyTextureToTexture=function(k,$,ae,ee=0){const pe=$.image.width,Ke=$.image.height,Je=F.convert(ae.format),et=F.convert(ae.type);ce.setTexture2D(ae,0),V.pixelStorei(37440,ae.flipY),V.pixelStorei(37441,ae.premultiplyAlpha),V.pixelStorei(3317,ae.unpackAlignment),$.isDataTexture?V.texSubImage2D(3553,ee,k.x,k.y,pe,Ke,Je,et,$.image.data):$.isCompressedTexture?V.compressedTexSubImage2D(3553,ee,k.x,k.y,$.mipmaps[0].width,$.mipmaps[0].height,Je,$.mipmaps[0].data):V.texSubImage2D(3553,ee,k.x,k.y,Je,et,$.image),ee===0&&ae.generateMipmaps&&V.generateMipmap(3553),ye.unbindTexture()},this.copyTextureToTexture3D=function(k,$,ae,ee,pe=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Ke=k.max.x-k.min.x+1,Je=k.max.y-k.min.y+1,et=k.max.z-k.min.z+1,Qe=F.convert(ee.format),xt=F.convert(ee.type);let lt;if(ee.isData3DTexture)ce.setTexture3D(ee,0),lt=32879;else if(ee.isDataArrayTexture)ce.setTexture2DArray(ee,0),lt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}V.pixelStorei(37440,ee.flipY),V.pixelStorei(37441,ee.premultiplyAlpha),V.pixelStorei(3317,ee.unpackAlignment);const pt=V.getParameter(3314),At=V.getParameter(32878),Ei=V.getParameter(3316),jt=V.getParameter(3315),Sn=V.getParameter(32877),yn=ae.isCompressedTexture?ae.mipmaps[0]:ae.image;V.pixelStorei(3314,yn.width),V.pixelStorei(32878,yn.height),V.pixelStorei(3316,k.min.x),V.pixelStorei(3315,k.min.y),V.pixelStorei(32877,k.min.z),ae.isDataTexture||ae.isData3DTexture?V.texSubImage3D(lt,pe,$.x,$.y,$.z,Ke,Je,et,Qe,xt,yn.data):ae.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),V.compressedTexSubImage3D(lt,pe,$.x,$.y,$.z,Ke,Je,et,Qe,yn.data)):V.texSubImage3D(lt,pe,$.x,$.y,$.z,Ke,Je,et,Qe,xt,yn),V.pixelStorei(3314,pt),V.pixelStorei(32878,At),V.pixelStorei(3316,Ei),V.pixelStorei(3315,jt),V.pixelStorei(32877,Sn),pe===0&&ee.generateMipmaps&&V.generateMipmap(lt),ye.unbindTexture()},this.initTexture=function(k){k.isCubeTexture?ce.setTextureCube(k,0):k.isData3DTexture?ce.setTexture3D(k,0):k.isDataArrayTexture?ce.setTexture2DArray(k,0):ce.setTexture2D(k,0),ye.unbindTexture()},this.resetState=function(){x=0,y=0,b=null,ye.reset(),ue.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class cd extends Kl{}cd.prototype.isWebGL1Renderer=!0;class Fa{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new ve(e),this.density=t}clone(){return new Fa(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class Na{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new ve(e),this.near=t,this.far=n}clone(){return new Na(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class ka extends ct{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}}class xo{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=oo,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=bn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;ie.far||t.push({distance:c,point:vo.clone(),uv:Ln.getUV(vo,Ba,bo,za,ud,Jl,hd,new he),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Ua(a,e,t,n,i,s){yr.subVectors(a,t).addScalar(.5).multiply(n),i!==void 0?(_o.x=s*yr.x-i*yr.y,_o.y=i*yr.x+s*yr.y):_o.copy(yr),a.copy(e),a.x+=_o.x,a.y+=_o.y,a.applyMatrix4(ld)}const Ga=new D,fd=new D;class dd extends ct{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n0){let n,i;for(n=1,i=t.length;n0){Ga.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Ga);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Ga.setFromMatrixPosition(e.matrixWorld),fd.setFromMatrixPosition(this.matrixWorld);const n=Ga.distanceTo(fd)/e.zoom;t[0].object.visible=!0;let i,s;for(i=1,s=t.length;i=t[i].distance;i++)t[i-1].object.visible=!1,t[i].object.visible=!0;for(this._currentLevel=i-1;ic)continue;f.applyMatrix4(this.matrixWorld);const _=e.ray.origin.distanceTo(f);_e.far||t.push({distance:_,point:h.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}else{const x=Math.max(0,r.start),y=Math.min(g.count,r.start+r.count);for(let b=x,v=y-1;bc)continue;f.applyMatrix4(this.matrixWorld);const A=e.ray.origin.distanceTo(f);Ae.far||t.push({distance:A,point:h.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;s0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;si.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,object:r})}}class u_ extends Mt{constructor(e,t,n,i,s,r,o,c,l){super(e,t,n,i,s,r,o,c,l),this.isVideoTexture=!0,this.minFilter=r!==void 0?r:Et,this.magFilter=s!==void 0?s:Et,this.generateMipmaps=!1;const u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class h_ extends Mt{constructor(e,t,n){super({width:e,height:t}),this.isFramebufferTexture=!0,this.format=n,this.magFilter=kt,this.minFilter=kt,this.generateMipmaps=!1,this.needsUpdate=!0}}class Ld extends Mt{constructor(e,t,n,i,s,r,o,c,l,u,h,f){super(null,r,o,c,l,u,i,s,h,f),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class f_ extends Mt{constructor(e,t,n,i,s,r,o,c,l){super(e,t,n,i,s,r,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class In{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),s=0;t.push(0);for(let r=1;r<=e;r++)n=this.getPoint(r/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const s=n.length;let r;t?r=t:r=e*n[s-1];let o=0,c=s-1,l;for(;o<=c;)if(i=Math.floor(o+(c-o)/2),l=n[i]-r,l<0)o=i+1;else if(l>0)c=i-1;else{c=i;break}if(i=c,n[i]===r)return i/(s-1);const u=n[i],f=n[i+1]-u,d=(r-u)/f;return(i+d)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const r=this.getPoint(i),o=this.getPoint(s),c=t||(r.isVector2?new he:new D);return c.copy(o).sub(r).normalize(),c}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new D,i=[],s=[],r=[],o=new D,c=new Ie;for(let d=0;d<=e;d++){const p=d/e;i[d]=this.getTangentAt(p,new D)}s[0]=new D,r[0]=new D;let l=Number.MAX_VALUE;const u=Math.abs(i[0].x),h=Math.abs(i[0].y),f=Math.abs(i[0].z);u<=l&&(l=u,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),f<=l&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],o),r[0].crossVectors(i[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),r[d]=r[d-1].clone(),o.crossVectors(i[d-1],i[d]),o.length()>Number.EPSILON){o.normalize();const p=Math.acos(Ot(i[d-1].dot(i[d]),-1,1));s[d].applyMatrix4(c.makeRotationAxis(o,p))}r[d].crossVectors(i[d],s[d])}if(t===!0){let d=Math.acos(Ot(s[0].dot(s[e]),-1,1));d/=e,i[0].dot(o.crossVectors(s[0],s[e]))>0&&(d=-d);for(let p=1;p<=e;p++)s[p].applyMatrix4(c.makeRotationAxis(i[p],d*p)),r[p].crossVectors(i[p],s[p])}return{tangents:i,normals:s,binormals:r}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Xa extends In{constructor(e=0,t=0,n=1,i=1,s=0,r=Math.PI*2,o=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=r,this.aClockwise=o,this.aRotation=c}getPoint(e,t){const n=t||new he,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const r=Math.abs(s)i;)s-=i;s0?0:(Math.floor(Math.abs(o)/s)+1)*s:c===0&&o===s-1&&(o=s-2,c=1);let l,u;this.closed||o>0?l=i[(o-1)%s]:(ja.subVectors(i[0],i[1]).add(i[0]),l=ja);const h=i[o%s],f=i[(o+1)%s];if(this.closed||o+2i.length-2?i.length-1:r+1],h=i[r>i.length-3?i.length-1:r+2];return n.set(Pd(o,c.x,l.x,u.x,h.x),Pd(o,c.y,l.y,u.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const r=i[s]-n,o=this.curves[s],c=o.getLength(),l=c===0?0:1-r/c;return o.getPointAt(l,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);const u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Ss extends qe{constructor(e=[new he(0,-.5),new he(.5,0),new he(0,.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=Ot(i,0,Math.PI*2);const s=[],r=[],o=[],c=[],l=[],u=1/t,h=new D,f=new he,d=new D,p=new D,m=new D;let g=0,x=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:g=e[y+1].x-e[y].x,x=e[y+1].y-e[y].y,d.x=x*1,d.y=-g,d.z=x*0,m.copy(d),d.normalize(),c.push(d.x,d.y,d.z);break;case e.length-1:c.push(m.x,m.y,m.z);break;default:g=e[y+1].x-e[y].x,x=e[y+1].y-e[y].y,d.x=x*1,d.y=-g,d.z=x*0,p.copy(d),d.x+=m.x,d.y+=m.y,d.z+=m.z,d.normalize(),c.push(d.x,d.y,d.z),m.copy(p)}for(let y=0;y<=t;y++){const b=n+y*u*i,v=Math.sin(b),S=Math.cos(b);for(let A=0;A<=e.length-1;A++){h.x=e[A].x*v,h.y=e[A].y,h.z=e[A].x*S,r.push(h.x,h.y,h.z),f.x=y/t,f.y=A/(e.length-1),o.push(f.x,f.y);const R=c[3*A+0]*v,_=c[3*A+1],L=c[3*A+0]*S;l.push(R,_,L)}}for(let y=0;y0&&b(!0),t>0&&b(!1)),this.setIndex(u),this.setAttribute("position",new we(h,3)),this.setAttribute("normal",new we(f,3)),this.setAttribute("uv",new we(d,2));function y(){const v=new D,S=new D;let A=0;const R=(t-e)/n;for(let _=0;_<=s;_++){const L=[],N=_/s,B=N*(t-e)+e;for(let W=0;W<=i;W++){const K=W/i,z=K*c+o,q=Math.sin(z),O=Math.cos(z);S.x=B*q,S.y=-N*n+g,S.z=B*O,h.push(S.x,S.y,S.z),v.set(q,R,O).normalize(),f.push(v.x,v.y,v.z),d.push(K,1-N),L.push(p++)}m.push(L)}for(let _=0;_.9&&R<.1&&(b<.2&&(r[y+0]+=1),v<.2&&(r[y+2]+=1),S<.2&&(r[y+4]+=1))}}function f(y){s.push(y.x,y.y,y.z)}function d(y,b){const v=y*3;b.x=e[v+0],b.y=e[v+1],b.z=e[v+2]}function p(){const y=new D,b=new D,v=new D,S=new D,A=new he,R=new he,_=new he;for(let L=0,N=0;L80*t){o=l=a[0],c=u=a[1];for(let p=t;pl&&(l=h),f>u&&(u=f);d=Math.max(l-o,u-c),d=d!==0?1/d:0}return Eo(s,r,t,o,c,d),r}};function Od(a,e,t,n,i){let s,r;if(i===k_(a,e,t,n)>0)for(s=e;s=e;s-=n)r=Ud(s,a[s],a[s+1],r);return r&&$a(r,r.next)&&(Lo(r),r=r.next),r}function Yi(a,e){if(!a)return a;e||(e=a);let t=a,n;do if(n=!1,!t.steiner&&($a(t,t.next)||Ct(t.prev,t,t.next)===0)){if(Lo(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Eo(a,e,t,n,i,s,r){if(!a)return;!r&&s&&R_(a,n,i,s);let o=a,c,l;for(;a.prev!==a.next;){if(c=a.prev,l=a.next,s?w_(a,n,i,s):b_(a)){e.push(c.i/t),e.push(a.i/t),e.push(l.i/t),Lo(a),a=l.next,o=l.next;continue}if(a=l,a===o){r?r===1?(a=M_(Yi(a),e,t),Eo(a,e,t,n,i,s,2)):r===2&&S_(a,e,t,n,i,s):Eo(Yi(a),e,t,n,i,s,1);break}}}function b_(a){const e=a.prev,t=a,n=a.next;if(Ct(e,t,n)>=0)return!1;let i=a.next.next;for(;i!==a.prev;){if(Tr(e.x,e.y,t.x,t.y,n.x,n.y,i.x,i.y)&&Ct(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function w_(a,e,t,n){const i=a.prev,s=a,r=a.next;if(Ct(i,s,r)>=0)return!1;const o=i.xs.x?i.x>r.x?i.x:r.x:s.x>r.x?s.x:r.x,u=i.y>s.y?i.y>r.y?i.y:r.y:s.y>r.y?s.y:r.y,h=fu(o,c,e,t,n),f=fu(l,u,e,t,n);let d=a.prevZ,p=a.nextZ;for(;d&&d.z>=h&&p&&p.z<=f;){if(d!==a.prev&&d!==a.next&&Tr(i.x,i.y,s.x,s.y,r.x,r.y,d.x,d.y)&&Ct(d.prev,d,d.next)>=0||(d=d.prevZ,p!==a.prev&&p!==a.next&&Tr(i.x,i.y,s.x,s.y,r.x,r.y,p.x,p.y)&&Ct(p.prev,p,p.next)>=0))return!1;p=p.nextZ}for(;d&&d.z>=h;){if(d!==a.prev&&d!==a.next&&Tr(i.x,i.y,s.x,s.y,r.x,r.y,d.x,d.y)&&Ct(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=f;){if(p!==a.prev&&p!==a.next&&Tr(i.x,i.y,s.x,s.y,r.x,r.y,p.x,p.y)&&Ct(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function M_(a,e,t){let n=a;do{const i=n.prev,s=n.next.next;!$a(i,s)&&Bd(i,n,n.next,s)&&Co(i,s)&&Co(s,i)&&(e.push(i.i/t),e.push(n.i/t),e.push(s.i/t),Lo(n),Lo(n.next),n=a=s),n=n.next}while(n!==a);return Yi(n)}function S_(a,e,t,n,i,s){let r=a;do{let o=r.next.next;for(;o!==r.prev;){if(r.i!==o.i&&D_(r,o)){let c=zd(r,o);r=Yi(r,r.next),c=Yi(c,c.next),Eo(r,e,t,n,i,s),Eo(c,e,t,n,i,s);return}o=o.next}r=r.next}while(r!==a)}function T_(a,e,t,n){const i=[];let s,r,o,c,l;for(s=0,r=e.length;s=t.next.y&&t.next.y!==t.y){const f=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=n&&f>s){if(s=f,f===n){if(i===t.y)return t;if(i===t.next.y)return t.next}r=t.x=t.x&&t.x>=c&&n!==t.x&&Tr(ir.x||t.x===r.x&&L_(r,t)))&&(r=t,u=h)),t=t.next;while(t!==o);return r}function L_(a,e){return Ct(a.prev,a,e.prev)<0&&Ct(e.next,a,a.next)<0}function R_(a,e,t,n){let i=a;do i.z===null&&(i.z=fu(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==a);i.prevZ.nextZ=null,i.prevZ=null,I_(i)}function I_(a){let e,t,n,i,s,r,o,c,l=1;do{for(t=a,a=null,s=null,r=0;t;){for(r++,n=t,o=0,e=0;e0||c>0&&n;)o!==0&&(c===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,o--):(i=n,n=n.nextZ,c--),s?s.nextZ=i:a=i,i.prevZ=s,s=i;t=n}s.nextZ=null,l*=2}while(r>1);return a}function fu(a,e,t,n,i){return a=32767*(a-t)*i,e=32767*(e-n)*i,a=(a|a<<8)&16711935,a=(a|a<<4)&252645135,a=(a|a<<2)&858993459,a=(a|a<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,a|e<<1}function P_(a){let e=a,t=a;do(e.x=0&&(a-r)*(n-o)-(t-r)*(e-o)>=0&&(t-r)*(s-o)-(i-r)*(n-o)>=0}function D_(a,e){return a.next.i!==e.i&&a.prev.i!==e.i&&!F_(a,e)&&(Co(a,e)&&Co(e,a)&&N_(a,e)&&(Ct(a.prev,a,e.prev)||Ct(a,e.prev,e))||$a(a,e)&&Ct(a.prev,a,a.next)>0&&Ct(e.prev,e,e.next)>0)}function Ct(a,e,t){return(e.y-a.y)*(t.x-e.x)-(e.x-a.x)*(t.y-e.y)}function $a(a,e){return a.x===e.x&&a.y===e.y}function Bd(a,e,t,n){const i=ec(Ct(a,e,t)),s=ec(Ct(a,e,n)),r=ec(Ct(t,n,a)),o=ec(Ct(t,n,e));return!!(i!==s&&r!==o||i===0&&Qa(a,t,e)||s===0&&Qa(a,n,e)||r===0&&Qa(t,a,n)||o===0&&Qa(t,e,n))}function Qa(a,e,t){return e.x<=Math.max(a.x,t.x)&&e.x>=Math.min(a.x,t.x)&&e.y<=Math.max(a.y,t.y)&&e.y>=Math.min(a.y,t.y)}function ec(a){return a>0?1:a<0?-1:0}function F_(a,e){let t=a;do{if(t.i!==a.i&&t.next.i!==a.i&&t.i!==e.i&&t.next.i!==e.i&&Bd(t,t.next,a,e))return!0;t=t.next}while(t!==a);return!1}function Co(a,e){return Ct(a.prev,a,a.next)<0?Ct(a,e,a.next)>=0&&Ct(a,a.prev,e)>=0:Ct(a,e,a.prev)<0||Ct(a,a.next,e)<0}function N_(a,e){let t=a,n=!1;const i=(a.x+e.x)/2,s=(a.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==a);return n}function zd(a,e){const t=new du(a.i,a.x,a.y),n=new du(e.i,e.x,e.y),i=a.next,s=e.prev;return a.next=e,e.prev=a,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function Ud(a,e,t,n){const i=new du(a,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Lo(a){a.next.prev=a.prev,a.prev.next=a.next,a.prevZ&&(a.prevZ.nextZ=a.nextZ),a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function du(a,e,t){this.i=a,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function k_(a,e,t,n){let i=0;for(let s=e,r=t-n;s2&&a[e-1].equals(a[0])&&a.pop()}function Vd(a,e){for(let t=0;tNumber.EPSILON){const U=Math.sqrt(E),Z=Math.sqrt(ft*ft+at*at),Q=ce.x-ze/U,de=ce.y+Ue/U,Le=xe.x-at/Z,F=xe.y+ft/Z,ue=((Le-Q)*at-(F-de)*ft)/(Ue*at-ze*ft);Fe=Q+Ue*ue-le.x,Me=de+ze*ue-le.y;const ge=Fe*Fe+Me*Me;if(ge<=2)return new he(Fe,Me);Ye=Math.sqrt(ge/2)}else{let U=!1;Ue>Number.EPSILON?ft>Number.EPSILON&&(U=!0):Ue<-Number.EPSILON?ft<-Number.EPSILON&&(U=!0):Math.sign(ze)===Math.sign(at)&&(U=!0),U?(Fe=-ze,Me=Ue,Ye=Math.sqrt(E)):(Fe=Ue,Me=ze,Ye=Math.sqrt(E/2))}return new he(Fe/Ye,Me/Ye)}const H=[];for(let le=0,ce=z.length,xe=ce-1,Fe=le+1;le=0;le--){const ce=le/g,xe=d*Math.cos(ce*Math.PI/2),Fe=p*Math.sin(ce*Math.PI/2)+m;for(let Me=0,Ye=z.length;Me=0;){const Fe=xe;let Me=xe-1;Me<0&&(Me=le.length-1);for(let Ye=0,Ue=u+g*2;Ye0)&&d.push(b,v,A),(x!==n-1||c0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Qn extends Bt{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ve(16777215),this.specular=new ve(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fi,this.normalScale=new he(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=$r,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Yd extends Bt{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ve(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fi,this.normalScale=new he(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Zd extends Bt{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fi,this.normalScale=new he(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class tc extends Bt{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ve(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=$r,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Kd extends Bt{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ve(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fi,this.normalScale=new he(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Jd extends zt{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Pn(a,e,t){return pu(a)?new a.constructor(a.subarray(e,t!==void 0?t:a.length)):a.slice(e,t)}function Ls(a,e,t){return!a||!t&&a.constructor===e?a:typeof e.BYTES_PER_ELEMENT=="number"?new e(a):Array.prototype.slice.call(a)}function pu(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)}function $d(a){function e(i,s){return a[i]-a[s]}const t=a.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function mu(a,e,t){const n=a.length,i=new a.constructor(n);for(let s=0,r=0;r!==n;++s){const o=t[s]*e;for(let c=0;c!==e;++c)i[r++]=a[o+c]}return i}function gu(a,e,t,n){let i=1,s=a[0];for(;s!==void 0&&s[n]===void 0;)s=a[i++];if(s===void 0)return;let r=s[n];if(r!==void 0)if(Array.isArray(r))do r=s[n],r!==void 0&&(e.push(s.time),t.push.apply(t,r)),s=a[i++];while(s!==void 0);else if(r.toArray!==void 0)do r=s[n],r!==void 0&&(e.push(s.time),r.toArray(t,t.length)),s=a[i++];while(s!==void 0);else do r=s[n],r!==void 0&&(e.push(s.time),t.push(r)),s=a[i++];while(s!==void 0)}function U_(a,e,t,n,i=30){const s=a.clone();s.name=e;const r=[];for(let c=0;c=n)){h.push(l.times[d]);for(let m=0;ms.tracks[c].times[0]&&(o=s.tracks[c].times[0]);for(let c=0;c=o.times[p]){const x=p*h+u,y=x+h-u;m=Pn(o.values,x,y)}else{const x=o.createInterpolant(),y=u,b=h-u;x.evaluate(s),m=Pn(x.resultBuffer,y,b)}c==="quaternion"&&new Pt().fromArray(m).normalize().conjugate().toArray(m);const g=l.times.length;for(let x=0;x=s)){const o=t[1];e=s)break t}r=n,n=0;break n}break e}for(;n>>1;et;)--r;if(++r,s!==0||r!==i){s>=r&&(r=Math.max(r,1),s=r-1);const o=this.getValueSize();this.times=Pn(n,s,r),this.values=Pn(this.values,s*o,r*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let r=null;for(let o=0;o!==s;o++){const c=n[o];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(r!==null&&r>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,c,r),e=!1;break}r=c}if(i!==void 0&&pu(i))for(let o=0,c=i.length;o!==c;++o){const l=i[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){const e=Pn(this.times),t=Pn(this.values),n=this.getValueSize(),i=this.getInterpolation()===ta,s=e.length-1;let r=1;for(let o=1;o0){e[r]=e[s];for(let o=s*n,c=r*n,l=0;l!==n;++l)t[c+l]=t[o+l];++r}return r!==e.length?(this.times=Pn(e,0,r),this.values=Pn(t,0,r*n)):(this.times=e,this.values=t),this}clone(){const e=Pn(this.times,0),t=Pn(this.values,0),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}Wn.prototype.TimeBufferType=Float32Array,Wn.prototype.ValueBufferType=Float32Array,Wn.prototype.DefaultInterpolation=ls;class Rs extends Wn{}Rs.prototype.ValueTypeName="bool",Rs.prototype.ValueBufferType=Array,Rs.prototype.DefaultInterpolation=Zs,Rs.prototype.InterpolantFactoryMethodLinear=void 0,Rs.prototype.InterpolantFactoryMethodSmooth=void 0;class xu extends Wn{}xu.prototype.ValueTypeName="color";class Is extends Wn{}Is.prototype.ValueTypeName="number";class tp extends Fr{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=(n-t)/(i-t);let l=e*o;for(let u=l+o;l!==u;l+=4)Pt.slerpFlat(s,0,r,l-o,r,l,c);return s}}class ei extends Wn{InterpolantFactoryMethodLinear(e){return new tp(this.times,this.values,this.getValueSize(),e)}}ei.prototype.ValueTypeName="quaternion",ei.prototype.DefaultInterpolation=ls,ei.prototype.InterpolantFactoryMethodSmooth=void 0;class Ps extends Wn{}Ps.prototype.ValueTypeName="string",Ps.prototype.ValueBufferType=Array,Ps.prototype.DefaultInterpolation=Zs,Ps.prototype.InterpolantFactoryMethodLinear=void 0,Ps.prototype.InterpolantFactoryMethodSmooth=void 0;class vi extends Wn{}vi.prototype.ValueTypeName="vector";class _i{constructor(e,t=-1,n,i=na){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=bn(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let r=0,o=n.length;r!==o;++r)t.push(W_(n[r]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,r=n.length;s!==r;++s)t.push(Wn.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const s=t.length,r=[];for(let o=0;o1){const h=u[1];let f=i[h];f||(i[h]=f=[]),f.push(l)}}const r=[];for(const o in i)r.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return r}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(h,f,d,p,m){if(d.length!==0){const g=[],x=[];gu(d,g,x,p),g.length!==0&&m.push(new h(f,g,x))}},i=[],s=e.name||"default",r=e.fps||30,o=e.blendMode;let c=e.length||-1;const l=e.hierarchy||[];for(let h=0;h{t&&t(s),this.manager.itemEnd(e)},0),s;if(bi[e]!==void 0){bi[e].push({onLoad:t,onProgress:n,onError:i});return}bi[e]=[],bi[e].push({onLoad:t,onProgress:n,onError:i});const r=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,c=this.responseType;fetch(r).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream=="undefined"||l.body===void 0||l.body.getReader===void 0)return l;const u=bi[e],h=l.body.getReader(),f=l.headers.get("Content-Length"),d=f?parseInt(f):0,p=d!==0;let m=0;const g=new ReadableStream({start(x){y();function y(){h.read().then(({done:b,value:v})=>{if(b)x.close();else{m+=v.byteLength;const S=new ProgressEvent("progress",{lengthComputable:p,loaded:m,total:d});for(let A=0,R=u.length;A{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(u=>new DOMParser().parseFromString(u,o));case"json":return l.json();default:if(o===void 0)return l.text();{const h=/charset="?([^;"\s]*)"?/i.exec(o),f=h&&h[1]?h[1].toLowerCase():void 0,d=new TextDecoder(f);return l.arrayBuffer().then(p=>d.decode(p))}}}).then(l=>{Ds.add(e,l);const u=bi[e];delete bi[e];for(let h=0,f=u.length;h{const u=bi[e];if(u===void 0)throw this.manager.itemError(e),l;delete bi[e];for(let h=0,f=u.length;h{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class X_ extends Ut{constructor(e){super(e)}load(e,t,n,i){const s=this,r=new Zt(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}parse(e){const t=[];for(let n=0;n0:i.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const r=e.uniforms[s];switch(i.uniforms[s]={},r.type){case"t":i.uniforms[s].value=n(r.value);break;case"c":i.uniforms[s].value=new ve().setHex(r.value);break;case"v2":i.uniforms[s].value=new he().fromArray(r.value);break;case"v3":i.uniforms[s].value=new D().fromArray(r.value);break;case"v4":i.uniforms[s].value=new ut().fromArray(r.value);break;case"m3":i.uniforms[s].value=new an().fromArray(r.value);break;case"m4":i.uniforms[s].value=new Ie().fromArray(r.value);break;default:i.uniforms[s].value=r.value}}if(e.defines!==void 0&&(i.defines=e.defines),e.vertexShader!==void 0&&(i.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(i.fragmentShader=e.fragmentShader),e.extensions!==void 0)for(const s in e.extensions)i.extensions[s]=e.extensions[s];if(e.shading!==void 0&&(i.flatShading=e.shading===1),e.size!==void 0&&(i.size=e.size),e.sizeAttenuation!==void 0&&(i.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(i.map=n(e.map)),e.matcap!==void 0&&(i.matcap=n(e.matcap)),e.alphaMap!==void 0&&(i.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(i.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(i.bumpScale=e.bumpScale),e.normalMap!==void 0&&(i.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(i.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),i.normalScale=new he().fromArray(s)}return e.displacementMap!==void 0&&(i.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(i.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(i.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(i.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(i.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(i.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(i.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(i.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(i.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(i.envMap=n(e.envMap)),e.envMapIntensity!==void 0&&(i.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(i.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(i.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(i.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(i.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(i.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(i.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(i.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(i.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new he().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(i.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(i.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(i.thicknessMap=n(e.thicknessMap)),e.sheenColorMap!==void 0&&(i.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:Xd,SpriteMaterial:Oa,RawShaderMaterial:jd,ShaderMaterial:Kn,PointsMaterial:Xi,MeshPhysicalMaterial:xi,MeshStandardMaterial:Cs,MeshPhongMaterial:Qn,MeshToonMaterial:Yd,MeshNormalMaterial:Zd,MeshLambertMaterial:tc,MeshDepthMaterial:jl,MeshDistanceMaterial:Yl,MeshBasicMaterial:cn,MeshMatcapMaterial:Kd,LineDashedMaterial:Jd,LineBasicMaterial:zt,Material:Bt};return new t[e]}}class tn{static decodeText(e){if(typeof TextDecoder!="undefined")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n0){const c=new vu(t);s=new Ro(c),s.setCrossOrigin(this.crossOrigin);for(let l=0,u=e.length;l0){i=new Ro(this.manager),i.setCrossOrigin(this.crossOrigin);for(let r=0,o=e.length;r0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(n[c]!==n[c+t]){o.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let s=n,r=i;s!==r;++s)t[s]=t[i+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let r=0;r!==s;++r)e[t+r]=e[n+r]}_slerp(e,t,n,i){Pt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,s){const r=this._workIndex*s;Pt.multiplyQuaternionsFlat(e,r,e,t,e,n),Pt.slerpFlat(e,t,e,t,e,r,i)}_lerp(e,t,n,i,s){const r=1-i;for(let o=0;o!==s;++o){const c=t+o;e[c]=e[c]*r+e[n+o]*i}}_lerpAdditive(e,t,n,i,s){for(let r=0;r!==s;++r){const o=t+r;e[o]=e[o]+e[n+r]*i}}}const Au="\\[\\]\\.:\\/",ab=new RegExp("["+Au+"]","g"),Eu="[^"+Au+"]",cb="[^"+Au.replace("\\.","")+"]",lb=/((?:WC+[\/:])*)/.source.replace("WC",Eu),ub=/(WCOD+)?/.source.replace("WCOD",cb),hb=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Eu),fb=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Eu),db=new RegExp("^"+lb+ub+hb+fb+"$"),pb=["material","materials","bones"];class mb{constructor(e,t,n){const i=n||it.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class it{constructor(e,t,n){this.path=t,this.parsedPath=n||it.parseTrackName(t),this.node=it.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new it.Composite(e,t,n):new it(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(ab,"")}static parseTrackName(e){const t=db.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);pb.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: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let r=0;r=s){const h=s++,f=e[h];t[f.uuid]=u,e[u]=f,t[l]=h,e[h]=c;for(let d=0,p=i;d!==p;++d){const m=n[d],g=m[h],x=m[u];m[u]=g,m[h]=x}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_,r=e.length;for(let o=0,c=arguments.length;o!==c;++o){const l=arguments[o],u=l.uuid,h=t[u];if(h!==void 0)if(delete t[u],h0&&(t[d.uuid]=h),e[h]=d,e.pop();for(let p=0,m=i;p!==m;++p){const g=n[p];g[h]=g[f],g.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const s=this._bindings;if(i!==void 0)return s[i];const r=this._paths,o=this._parsedPaths,c=this._objects,l=c.length,u=this.nCachedObjects_,h=new Array(l);i=s.length,n[e]=i,r.push(e),o.push(t),s.push(h);for(let f=u,d=c.length;f!==d;++f){const p=c[f];h[f]=new it(p,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const i=this._paths,s=this._parsedPaths,r=this._bindings,o=r.length-1,c=r[o],l=e[o];t[l]=n,r[n]=c,r.pop(),s[n]=s[o],s.pop(),i[n]=i[o],i.pop()}}}class yb{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const s=t.tracks,r=s.length,o=new Array(r),c={endingStart:us,endingEnd:us};for(let l=0;l!==r;++l){const u=s[l].createInterpolant(null);o[l]=u,u.settings=c}this._interpolantSettings=c,this._interpolants=o,this._propertyBindings=new Array(r),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=af,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const i=this._clip.duration,s=e._clip.duration,r=s/i,o=i/s;e.warp(1,r,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,s=i.time,r=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);const c=o.parameterPositions,l=o.sampleValues;return c[0]=s,c[1]=s+n,l[0]=e/r,l[1]=t/r,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const c=(e-s)*n;if(c<0||n===0)return;this._startTime=null,t=n*c}t*=this._updateTimeScale(e);const r=this._updateTime(t),o=this._updateWeight(e);if(o>0){const c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case fl:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(r),l[u].accumulateAdditive(o);break;case na:default:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(r),l[u].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;n!==null&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,s=this._loopCount;const r=n===cf;if(e===0)return s===-1?i:r&&(s&1)===1?t-i:i;if(n===of){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,r)):this._setEndings(this.repetitions===0,!0,r)),i>=t||i<0){const o=Math.floor(i/t);i-=t*o,s+=Math.abs(o);const c=this.repetitions-s;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){const l=e<0;this._setEndings(l,!l,r)}else this._setEndings(!1,!1,r);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=i;if(r&&(s&1)===1)return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=hs,i.endingEnd=hs):(e?i.endingStart=this.zeroSlopeAtStart?hs:us:i.endingStart=ro,t?i.endingEnd=this.zeroSlopeAtEnd?hs:us:i.endingEnd=ro)}_scheduleFading(e,t,n){const i=this._mixer,s=i.time;let r=this._weightInterpolant;r===null&&(r=i._lendControlInterpolant(),this._weightInterpolant=r);const o=r.parameterPositions,c=r.sampleValues;return o[0]=s,c[0]=t,o[1]=s+e,c[1]=n,this}}const xb=new Float32Array(1);class Mp extends Zn{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,s=i.length,r=e._propertyBindings,o=e._interpolants,c=n.uuid,l=this._bindingsByRootAndName;let u=l[c];u===void 0&&(u={},l[c]=u);for(let h=0;h!==s;++h){const f=i[h],d=f.name;let p=u[d];if(p!==void 0)++p.referenceCount,r[h]=p;else{if(p=r[h],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,c,d));continue}const m=t&&t._propertyBindings[h].binding.parsedPath;p=new wp(it.create(n,d,m),f.ValueTypeName,f.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,c,d),r[h]=p}o[h].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,i=e._clip.uuid,s=this._actionsByClip[i];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,i,n)}const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,s=Math.sign(e),r=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(i,e,s,r);const o=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)o[l].apply(r);return this}setTime(e){this.time=0;for(let t=0;tthis.max.x||e.ythis.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Ap.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Ep=new D,rc=new D;class Tb{constructor(e=new D,t=new D){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Ep.subVectors(e,this.start),rc.subVectors(this.end,this.start);const n=rc.dot(rc);let s=rc.dot(Ep)/n;return t&&(s=Ot(s,0,1)),s}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Cp=new D;class Ab extends ct{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;const n=new qe,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let r=0,o=1,c=32;r.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Fp.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Fp,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}}class zb extends pn{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new qe;i.setAttribute("position",new we(t,3)),i.setAttribute("color",new we(n,3));const s=new zt({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,n){const i=new ve,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Ub{constructor(){this.type="ShapePath",this.color=new ve,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Ao,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,s,r){return this.currentPath.bezierCurveTo(e,t,n,i,s,r),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e,t){function n(y){const b=[];for(let v=0,S=y.length;vNumber.EPSILON){if(B<0&&(_=b[R],N=-N,L=b[A],B=-B),y.y<_.y||y.y>L.y)continue;if(y.y===_.y){if(y.x===_.x)return!0}else{const W=B*(y.x-_.x)-N*(y.y-_.y);if(W===0)return!0;if(W<0)continue;S=!S}}else{if(y.y!==_.y)continue;if(L.x<=y.x&&y.x<=_.x||_.x<=y.x&&y.x<=L.x)return!0}}return S}const s=$n.isClockWise,r=this.subPaths;if(r.length===0)return[];if(t===!0)return n(r);let o,c,l;const u=[];if(r.length===1)return c=r[0],l=new Ts,l.curves=c.curves,u.push(l),u;let h=!s(r[0].getPoints());h=e?!h:h;const f=[],d=[];let p=[],m=0,g;d[m]=void 0,p[m]=[];for(let y=0,b=r.length;y1){let y=!1,b=0;for(let v=0,S=d.length;v0&&y===!1&&(p=f)}let x;for(let y=0,b=d.length;y>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}const s=new Uint32Array(2048),r=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,u=0;for(;(l&8388608)===0;)l<<=1,u-=8388608;l&=-8388609,u+=947912704,s[c]=l|u}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)r[c]=c<<23;r[31]=1199570944,r[32]=2147483648;for(let c=33;c<63;++c)r[c]=2147483648+(c-32<<23);r[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:s,exponentTable:r,offsetTable:o}}function Vb(a){Math.abs(a)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),a=Ot(a,-65504,65504),wi.floatView[0]=a;const e=wi.uint32View[0],t=e>>23&511;return wi.baseTable[t]+((e&8388607)>>wi.shiftTable[t])}function Hb(a){const e=a>>10;return wi.uint32View[0]=wi.mantissaTable[wi.offsetTable[e]+(a&1023)]+wi.exponentTable[e],wi.floatView[0]}var Wb=Object.freeze({__proto__:null,toHalfFloat:Vb,fromHalfFloat:Hb});class qb extends qe{constructor(){console.error("THREE.ParametricGeometry has been moved to /examples/jsm/geometries/ParametricGeometry.js"),super()}}class Xb extends qe{constructor(){console.error("THREE.TextGeometry has been moved to /examples/jsm/geometries/TextGeometry.js"),super()}}function jb(){console.error("THREE.FontLoader has been moved to /examples/jsm/loaders/FontLoader.js")}function Yb(){console.error("THREE.Font has been moved to /examples/jsm/loaders/FontLoader.js")}function Zb(){console.error("THREE.ImmediateRenderObject has been removed.")}class Kb extends En{constructor(e,t,n){console.error('THREE.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the "samples" property to greater 0 to enable multisampling.'),super(e,t,n),this.samples=4}}class Jb extends uo{constructor(e,t,n,i){console.warn("THREE.DataTexture2DArray has been renamed to DataArrayTexture."),super(e,t,n,i)}}class $b extends la{constructor(e,t,n,i){console.warn("THREE.DataTexture3D has been renamed to Data3DTexture."),super(e,t,n,i)}}typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ko}})),typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ko);var Qb=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Hh,AddEquation:os,AddOperation:zh,AdditiveAnimationBlendMode:fl,AdditiveBlending:kc,AlphaFormat:Kh,AlwaysDepth:Ph,AlwaysStencilFunc:df,AmbientLight:Do,AmbientLightProbe:eb,AnimationClip:_i,AnimationLoader:X_,AnimationMixer:Mp,AnimationObjectGroup:gb,AnimationUtils:V_,ArcCurve:Rd,ArrayCamera:od,ArrowHelper:Bb,Audio:_p,AudioAnalyser:ob,AudioContext:Su,AudioListener:ib,AudioLoader:$_,AxesHelper:zb,BackSide:Tn,BasicDepthPacking:uf,BasicShadowMap:Km,Bone:ws,BooleanKeyframeTrack:Rs,Box2:Sb,Box3:hi,Box3Helper:kb,BoxBufferGeometry:yi,BoxGeometry:yi,BoxHelper:Nb,BufferAttribute:ht,BufferGeometry:qe,BufferGeometryLoader:hp,ByteType:qh,Cache:Ds,Camera:Ca,CameraHelper:Fb,CanvasTexture:f_,CapsuleBufferGeometry:br,CapsuleGeometry:br,CatmullRomCurve3:Id,CineonToneMapping:Vh,CircleBufferGeometry:wr,CircleGeometry:wr,ClampToEdgeWrapping:Wt,Clock:Tu,Color:ve,ColorKeyframeTrack:xu,ColorManagement:An,CompressedTexture:Ld,CompressedTextureLoader:np,ConeBufferGeometry:Mr,ConeGeometry:Mr,CubeCamera:Rf,CubeReflectionMapping:Li,CubeRefractionMapping:Ri,CubeTexture:go,CubeTextureLoader:j_,CubeUVReflectionMapping:Xs,CubicBezierCurve:ou,CubicBezierCurve3:Dd,CubicInterpolant:Qd,CullFaceBack:Fc,CullFaceFront:gh,CullFaceFrontBack:Zm,CullFaceNone:mh,Curve:In,CurvePath:Nd,CustomBlending:vh,CustomToneMapping:Wh,CylinderBufferGeometry:ji,CylinderGeometry:ji,Cylindrical:Mb,Data3DTexture:la,DataArrayTexture:uo,DataTexture:xr,DataTexture2DArray:Jb,DataTexture3D:$b,DataTextureLoader:ip,DataUtils:Wb,DecrementStencilOp:ag,DecrementWrapStencilOp:lg,DefaultLoadingManager:_u,DepthFormat:Di,DepthStencilFormat:cs,DepthTexture:ad,DirectionalLight:Nr,DirectionalLightHelper:Db,DiscreteInterpolant:ep,DodecahedronBufferGeometry:Sr,DodecahedronGeometry:Sr,DoubleSide:ai,DstAlphaFactor:Ah,DstColorFactor:Ch,DynamicCopyUsage:Sg,DynamicDrawUsage:xg,DynamicReadUsage:bg,EdgesGeometry:kd,EllipseCurve:Xa,EqualDepth:Fh,EqualStencilFunc:dg,EquirectangularReflectionMapping:qs,EquirectangularRefractionMapping:Qr,Euler:Cn,EventDispatcher:Zn,ExtrudeBufferGeometry:Ar,ExtrudeGeometry:Ar,FileLoader:Zt,FlatShading:xh,Float16BufferAttribute:o0,Float32BufferAttribute:we,Float64BufferAttribute:a0,FloatType:li,Fog:Na,FogExp2:Fa,Font:Yb,FontLoader:jb,FramebufferTexture:h_,FrontSide:oi,Frustum:Ra,GLBufferAttribute:wb,GLSL1:Ag,GLSL3:pl,GreaterDepth:kh,GreaterEqualDepth:Nh,GreaterEqualStencilFunc:yg,GreaterStencilFunc:mg,GridHelper:Ib,Group:dn,HalfFloatType:Ys,HemisphereLight:bu,HemisphereLightHelper:Rb,HemisphereLightProbe:Q_,IcosahedronBufferGeometry:Er,IcosahedronGeometry:Er,ImageBitmapLoader:mp,ImageLoader:Ro,ImageUtils:vl,ImmediateRenderObject:Zb,IncrementStencilOp:og,IncrementWrapStencilOp:cg,InstancedBufferAttribute:vr,InstancedBufferGeometry:up,InstancedInterleavedBuffer:bb,InstancedMesh:bd,Int16BufferAttribute:s0,Int32BufferAttribute:r0,Int8BufferAttribute:t0,IntType:jh,InterleavedBuffer:xo,InterleavedBufferAttribute:qi,Interpolant:Fr,InterpolateDiscrete:Zs,InterpolateLinear:ls,InterpolateSmooth:ta,InvertStencilOp:ug,KeepStencilOp:ia,KeyframeTrack:Wn,LOD:dd,LatheBufferGeometry:Ss,LatheGeometry:Ss,Layers:ga,LessDepth:Dh,LessEqualDepth:Jo,LessEqualStencilFunc:pg,LessStencilFunc:fg,Light:Zi,LightProbe:nc,Line:Hn,Line3:Tb,LineBasicMaterial:zt,LineCurve:Ya,LineCurve3:Fd,LineDashedMaterial:Jd,LineLoop:eu,LineSegments:pn,LinearEncoding:ui,LinearFilter:Et,LinearInterpolant:yu,LinearMipMapLinearFilter:tg,LinearMipMapNearestFilter:eg,LinearMipmapLinearFilter:jn,LinearMipmapNearestFilter:Qo,LinearSRGBColorSpace:Ni,LinearToneMapping:Uh,Loader:Ut,LoaderUtils:tn,LoadingManager:vu,LoopOnce:of,LoopPingPong:cf,LoopRepeat:af,LuminanceAlphaFormat:Qh,LuminanceFormat:$h,MOUSE:is,Material:Bt,MaterialLoader:ic,MathUtils:en,Matrix3:an,Matrix4:Ie,MaxEquation:Uc,Mesh:St,MeshBasicMaterial:cn,MeshDepthMaterial:jl,MeshDistanceMaterial:Yl,MeshLambertMaterial:tc,MeshMatcapMaterial:Kd,MeshNormalMaterial:Zd,MeshPhongMaterial:Qn,MeshPhysicalMaterial:xi,MeshStandardMaterial:Cs,MeshToonMaterial:Yd,MinEquation:zc,MirroredRepeatWrapping:js,MixOperation:Bh,MultiplyBlending:Bc,MultiplyOperation:$r,NearestFilter:kt,NearestMipMapLinearFilter:Qm,NearestMipMapNearestFilter:$m,NearestMipmapLinearFilter:to,NearestMipmapNearestFilter:eo,NeverDepth:Ih,NeverStencilFunc:hg,NoBlending:ci,NoColorSpace:ig,NoToneMapping:Xn,NormalAnimationBlendMode:na,NormalBlending:rs,NotEqualDepth:Oh,NotEqualStencilFunc:gg,NumberKeyframeTrack:Is,Object3D:ct,ObjectLoader:fp,ObjectSpaceNormalMap:ff,OctahedronBufferGeometry:As,OctahedronGeometry:As,OneFactor:Mh,OneMinusDstAlphaFactor:Eh,OneMinusDstColorFactor:Lh,OneMinusSrcAlphaFactor:Vc,OneMinusSrcColorFactor:Th,OrthographicCamera:vs,PCFShadowMap:Nc,PCFSoftShadowMap:yh,PMREMGenerator:Vl,ParametricGeometry:qb,Path:Ao,PerspectiveCamera:Dt,Plane:Wi,PlaneBufferGeometry:xs,PlaneGeometry:xs,PlaneHelper:Ob,PointLight:Ns,PointLightHelper:Cb,Points:_r,PointsMaterial:Xi,PolarGridHelper:Pb,PolyhedronBufferGeometry:Jn,PolyhedronGeometry:Jn,PositionalAudio:rb,PropertyBinding:it,PropertyMixer:wp,QuadraticBezierCurve:au,QuadraticBezierCurve3:cu,Quaternion:Pt,QuaternionKeyframeTrack:ei,QuaternionLinearInterpolant:tp,REVISION:Ko,RGBADepthPacking:hf,RGBAFormat:_n,RGBAIntegerFormat:rf,RGBA_ASTC_10x10_Format:cl,RGBA_ASTC_10x5_Format:rl,RGBA_ASTC_10x6_Format:ol,RGBA_ASTC_10x8_Format:al,RGBA_ASTC_12x10_Format:ll,RGBA_ASTC_12x12_Format:ul,RGBA_ASTC_4x4_Format:Jc,RGBA_ASTC_5x4_Format:$c,RGBA_ASTC_5x5_Format:Qc,RGBA_ASTC_6x5_Format:el,RGBA_ASTC_6x6_Format:tl,RGBA_ASTC_8x5_Format:nl,RGBA_ASTC_8x6_Format:il,RGBA_ASTC_8x8_Format:sl,RGBA_BPTC_Format:hl,RGBA_ETC2_EAC_Format:Kc,RGBA_PVRTC_2BPPV1_Format:jc,RGBA_PVRTC_4BPPV1_Format:Xc,RGBA_S3TC_DXT1_Format:ea,RGBA_S3TC_DXT3_Format:io,RGBA_S3TC_DXT5_Format:so,RGBFormat:Jh,RGB_ETC1_Format:Yc,RGB_ETC2_Format:Zc,RGB_PVRTC_2BPPV1_Format:qc,RGB_PVRTC_4BPPV1_Format:Wc,RGB_S3TC_DXT1_Format:no,RGFormat:nf,RGIntegerFormat:sf,RawShaderMaterial:jd,Ray:fo,Raycaster:Sp,RectAreaLight:cp,RedFormat:ef,RedIntegerFormat:tf,ReinhardToneMapping:Gh,RepeatWrapping:on,ReplaceStencilOp:rg,ReverseSubtractEquation:bh,RingBufferGeometry:Cr,RingGeometry:Cr,SRGBColorSpace:Yn,Scene:ka,ShaderChunk:nt,ShaderLib:Vn,ShaderMaterial:Kn,ShadowMaterial:Xd,Shape:Ts,ShapeBufferGeometry:Lr,ShapeGeometry:Lr,ShapePath:Ub,ShapeUtils:$n,ShortType:Xh,Skeleton:Ms,SkeletonHelper:Eb,SkinnedMesh:wo,SmoothShading:Jm,Source:ps,Sphere:Bi,SphereBufferGeometry:Es,SphereGeometry:Es,Spherical:Ru,SphericalHarmonics3:lp,SplineCurve:lu,SpotLight:Io,SpotLightHelper:Ab,Sprite:$l,SpriteMaterial:Oa,SrcAlphaFactor:Gc,SrcAlphaSaturateFactor:Rh,SrcColorFactor:Sh,StaticCopyUsage:Mg,StaticDrawUsage:oo,StaticReadUsage:_g,StereoCamera:tb,StreamCopyUsage:Tg,StreamDrawUsage:vg,StreamReadUsage:wg,StringKeyframeTrack:Ps,SubtractEquation:_h,SubtractiveBlending:Oc,TOUCH:ss,TangentSpaceNormalMap:Fi,TetrahedronBufferGeometry:Rr,TetrahedronGeometry:Rr,TextGeometry:Xb,Texture:Mt,TextureLoader:Fs,TorusBufferGeometry:Ir,TorusGeometry:Ir,TorusKnotBufferGeometry:Pr,TorusKnotGeometry:Pr,Triangle:Ln,TriangleFanDrawMode:dl,TriangleStripDrawMode:lf,TrianglesDrawMode:ng,TubeBufferGeometry:Dr,TubeGeometry:Dr,UVMapping:$o,Uint16BufferAttribute:va,Uint32BufferAttribute:Pl,Uint8BufferAttribute:n0,Uint8ClampedBufferAttribute:i0,Uniform:Cu,UniformsGroup:_b,UniformsLib:Re,UniformsUtils:Lf,UnsignedByteType:Ii,UnsignedInt248Type:as,UnsignedIntType:Pi,UnsignedShort4444Type:Yh,UnsignedShort5551Type:Zh,UnsignedShortType:Hc,VSMShadowMap:Ws,Vector2:he,Vector3:D,Vector4:ut,VectorKeyframeTrack:vi,VideoTexture:u_,WebGL1Renderer:cd,WebGL3DRenderTarget:qg,WebGLArrayRenderTarget:Wg,WebGLCubeRenderTarget:If,WebGLMultipleRenderTargets:Xg,WebGLMultisampleRenderTarget:Kb,WebGLRenderTarget:En,WebGLRenderer:Kl,WebGLUtils:rd,WireframeGeometry:Hd,WrapAroundEnding:ro,ZeroCurvatureEnding:us,ZeroFactor:wh,ZeroSlopeEnding:hs,ZeroStencilOp:sg,_SRGBAFormat:sa,sRGBEncoding:tt},Symbol.toStringTag,{value:"Module"}));const Np={type:"change"},Du={type:"start"},kp={type:"end"};class ew extends Zn{constructor(e,t){super(),t===void 0&&console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.'),t===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.object=e,this.domElement=t,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new D,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:is.ROTATE,MIDDLE:is.DOLLY,RIGHT:is.PAN},this.touches={ONE:ss.ROTATE,TWO:ss.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return o.phi},this.getAzimuthalAngle=function(){return o.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(F){F.addEventListener("keydown",at),this._domElementKeyEvents=F},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(Np),n.update(),s=i.NONE},this.update=function(){const F=new D,ue=new Pt().setFromUnitVectors(e.up,new D(0,1,0)),ge=ue.clone().invert(),Ee=new D,Se=new Pt,Oe=2*Math.PI;return function(){const $e=n.object.position;F.copy($e).sub(n.target),F.applyQuaternion(ue),o.setFromVector3(F),n.autoRotate&&s===i.NONE&&L(R()),n.enableDamping?(o.theta+=c.theta*n.dampingFactor,o.phi+=c.phi*n.dampingFactor):(o.theta+=c.theta,o.phi+=c.phi);let G=n.minAzimuthAngle,Te=n.maxAzimuthAngle;return isFinite(G)&&isFinite(Te)&&(G<-Math.PI?G+=Oe:G>Math.PI&&(G-=Oe),Te<-Math.PI?Te+=Oe:Te>Math.PI&&(Te-=Oe),G<=Te?o.theta=Math.max(G,Math.min(Te,o.theta)):o.theta=o.theta>(G+Te)/2?Math.max(G,o.theta):Math.min(Te,o.theta)),o.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,o.phi)),o.makeSafe(),o.radius*=l,o.radius=Math.max(n.minDistance,Math.min(n.maxDistance,o.radius)),n.enableDamping===!0?n.target.addScaledVector(u,n.dampingFactor):n.target.add(u),F.setFromSpherical(o),F.applyQuaternion(ge),$e.copy(n.target).add(F),n.object.lookAt(n.target),n.enableDamping===!0?(c.theta*=1-n.dampingFactor,c.phi*=1-n.dampingFactor,u.multiplyScalar(1-n.dampingFactor)):(c.set(0,0,0),u.set(0,0,0)),l=1,h||Ee.distanceToSquared(n.object.position)>r||8*(1-Se.dot(n.object.quaternion))>r?(n.dispatchEvent(Np),Ee.copy(n.object.position),Se.copy(n.object.quaternion),h=!1,!0):!1}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",U),n.domElement.removeEventListener("pointerdown",xe),n.domElement.removeEventListener("pointercancel",Ye),n.domElement.removeEventListener("wheel",ft),n.domElement.removeEventListener("pointermove",Fe),n.domElement.removeEventListener("pointerup",Me),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",at)};const n=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=i.NONE;const r=1e-6,o=new Ru,c=new Ru;let l=1;const u=new D;let h=!1;const f=new he,d=new he,p=new he,m=new he,g=new he,x=new he,y=new he,b=new he,v=new he,S=[],A={};function R(){return 2*Math.PI/60/60*n.autoRotateSpeed}function _(){return Math.pow(.95,n.zoomSpeed)}function L(F){c.theta-=F}function N(F){c.phi-=F}const B=function(){const F=new D;return function(ge,Ee){F.setFromMatrixColumn(Ee,0),F.multiplyScalar(-ge),u.add(F)}}(),W=function(){const F=new D;return function(ge,Ee){n.screenSpacePanning===!0?F.setFromMatrixColumn(Ee,1):(F.setFromMatrixColumn(Ee,0),F.crossVectors(n.object.up,F)),F.multiplyScalar(ge),u.add(F)}}(),K=function(){const F=new D;return function(ge,Ee){const Se=n.domElement;if(n.object.isPerspectiveCamera){const Oe=n.object.position;F.copy(Oe).sub(n.target);let Xe=F.length();Xe*=Math.tan(n.object.fov/2*Math.PI/180),B(2*ge*Xe/Se.clientHeight,n.object.matrix),W(2*Ee*Xe/Se.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(B(ge*(n.object.right-n.object.left)/n.object.zoom/Se.clientWidth,n.object.matrix),W(Ee*(n.object.top-n.object.bottom)/n.object.zoom/Se.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function z(F){n.object.isPerspectiveCamera?l/=F:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom*F)),n.object.updateProjectionMatrix(),h=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function q(F){n.object.isPerspectiveCamera?l*=F:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/F)),n.object.updateProjectionMatrix(),h=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function O(F){f.set(F.clientX,F.clientY)}function Y(F){y.set(F.clientX,F.clientY)}function j(F){m.set(F.clientX,F.clientY)}function H(F){d.set(F.clientX,F.clientY),p.subVectors(d,f).multiplyScalar(n.rotateSpeed);const ue=n.domElement;L(2*Math.PI*p.x/ue.clientHeight),N(2*Math.PI*p.y/ue.clientHeight),f.copy(d),n.update()}function X(F){b.set(F.clientX,F.clientY),v.subVectors(b,y),v.y>0?z(_()):v.y<0&&q(_()),y.copy(b),n.update()}function te(F){g.set(F.clientX,F.clientY),x.subVectors(g,m).multiplyScalar(n.panSpeed),K(x.x,x.y),m.copy(g),n.update()}function J(F){F.deltaY<0?q(_()):F.deltaY>0&&z(_()),n.update()}function ne(F){let ue=!1;switch(F.code){case n.keys.UP:K(0,n.keyPanSpeed),ue=!0;break;case n.keys.BOTTOM:K(0,-n.keyPanSpeed),ue=!0;break;case n.keys.LEFT:K(n.keyPanSpeed,0),ue=!0;break;case n.keys.RIGHT:K(-n.keyPanSpeed,0),ue=!0;break}ue&&(F.preventDefault(),n.update())}function re(){if(S.length===1)f.set(S[0].pageX,S[0].pageY);else{const F=.5*(S[0].pageX+S[1].pageX),ue=.5*(S[0].pageY+S[1].pageY);f.set(F,ue)}}function se(){if(S.length===1)m.set(S[0].pageX,S[0].pageY);else{const F=.5*(S[0].pageX+S[1].pageX),ue=.5*(S[0].pageY+S[1].pageY);m.set(F,ue)}}function V(){const F=S[0].pageX-S[1].pageX,ue=S[0].pageY-S[1].pageY,ge=Math.sqrt(F*F+ue*ue);y.set(0,ge)}function me(){n.enableZoom&&V(),n.enablePan&&se()}function _e(){n.enableZoom&&V(),n.enableRotate&&re()}function Pe(F){if(S.length==1)d.set(F.pageX,F.pageY);else{const ge=Le(F),Ee=.5*(F.pageX+ge.x),Se=.5*(F.pageY+ge.y);d.set(Ee,Se)}p.subVectors(d,f).multiplyScalar(n.rotateSpeed);const ue=n.domElement;L(2*Math.PI*p.x/ue.clientHeight),N(2*Math.PI*p.y/ue.clientHeight),f.copy(d)}function ye(F){if(S.length===1)g.set(F.pageX,F.pageY);else{const ue=Le(F),ge=.5*(F.pageX+ue.x),Ee=.5*(F.pageY+ue.y);g.set(ge,Ee)}x.subVectors(g,m).multiplyScalar(n.panSpeed),K(x.x,x.y),m.copy(g)}function He(F){const ue=Le(F),ge=F.pageX-ue.x,Ee=F.pageY-ue.y,Se=Math.sqrt(ge*ge+Ee*Ee);b.set(0,Se),v.set(0,Math.pow(b.y/y.y,n.zoomSpeed)),z(v.y),y.copy(b)}function le(F){n.enableZoom&&He(F),n.enablePan&&ye(F)}function ce(F){n.enableZoom&&He(F),n.enableRotate&&Pe(F)}function xe(F){n.enabled!==!1&&(S.length===0&&(n.domElement.setPointerCapture(F.pointerId),n.domElement.addEventListener("pointermove",Fe),n.domElement.addEventListener("pointerup",Me)),Z(F),F.pointerType==="touch"?E(F):Ue(F))}function Fe(F){n.enabled!==!1&&(F.pointerType==="touch"?w(F):ze(F))}function Me(F){Q(F),S.length===0&&(n.domElement.releasePointerCapture(F.pointerId),n.domElement.removeEventListener("pointermove",Fe),n.domElement.removeEventListener("pointerup",Me)),n.dispatchEvent(kp),s=i.NONE}function Ye(F){Q(F)}function Ue(F){let ue;switch(F.button){case 0:ue=n.mouseButtons.LEFT;break;case 1:ue=n.mouseButtons.MIDDLE;break;case 2:ue=n.mouseButtons.RIGHT;break;default:ue=-1}switch(ue){case is.DOLLY:if(n.enableZoom===!1)return;Y(F),s=i.DOLLY;break;case is.ROTATE:if(F.ctrlKey||F.metaKey||F.shiftKey){if(n.enablePan===!1)return;j(F),s=i.PAN}else{if(n.enableRotate===!1)return;O(F),s=i.ROTATE}break;case is.PAN:if(F.ctrlKey||F.metaKey||F.shiftKey){if(n.enableRotate===!1)return;O(F),s=i.ROTATE}else{if(n.enablePan===!1)return;j(F),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&n.dispatchEvent(Du)}function ze(F){switch(s){case i.ROTATE:if(n.enableRotate===!1)return;H(F);break;case i.DOLLY:if(n.enableZoom===!1)return;X(F);break;case i.PAN:if(n.enablePan===!1)return;te(F);break}}function ft(F){n.enabled===!1||n.enableZoom===!1||s!==i.NONE||(F.preventDefault(),n.dispatchEvent(Du),J(F),n.dispatchEvent(kp))}function at(F){n.enabled===!1||n.enablePan===!1||ne(F)}function E(F){switch(de(F),S.length){case 1:switch(n.touches.ONE){case ss.ROTATE:if(n.enableRotate===!1)return;re(),s=i.TOUCH_ROTATE;break;case ss.PAN:if(n.enablePan===!1)return;se(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(n.touches.TWO){case ss.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;me(),s=i.TOUCH_DOLLY_PAN;break;case ss.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;_e(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&n.dispatchEvent(Du)}function w(F){switch(de(F),s){case i.TOUCH_ROTATE:if(n.enableRotate===!1)return;Pe(F),n.update();break;case i.TOUCH_PAN:if(n.enablePan===!1)return;ye(F),n.update();break;case i.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;le(F),n.update();break;case i.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;ce(F),n.update();break;default:s=i.NONE}}function U(F){n.enabled!==!1&&F.preventDefault()}function Z(F){S.push(F)}function Q(F){delete A[F.pointerId];for(let ue=0;ue=s+1e3&&(o.update(r*1e3/(u-s),100),s=u,r=0,l)){var h=performance.memory;l.update(h.usedJSHeapSize/1048576,h.jsHeapSizeLimit/1048576)}return u},update:function(){i=this.end()},domElement:e,setMode:n}};Fo.Panel=function(a,e,t){var n=1/0,i=0,s=Math.round,r=s(window.devicePixelRatio||1),o=80*r,c=48*r,l=3*r,u=2*r,h=3*r,f=15*r,d=74*r,p=30*r,m=document.createElement("canvas");m.width=o,m.height=c,m.style.cssText="width:80px;height:48px";var g=m.getContext("2d");return g.font="bold "+9*r+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=t,g.fillRect(0,0,o,c),g.fillStyle=e,g.fillText(a,l,u),g.fillRect(h,f,d,p),g.fillStyle=t,g.globalAlpha=.9,g.fillRect(h,f,d,p),{dom:m,update:function(x,y){n=Math.min(n,x),i=Math.max(i,x),g.fillStyle=t,g.globalAlpha=1,g.fillRect(0,0,o,f),g.fillStyle=e,g.fillText(s(x)+" "+a+" ("+s(n)+"-"+s(i)+")",l,u),g.drawImage(m,h+r,f,d-r,p,h,f,d-r,p),g.fillRect(h+d-r,f,r,p),g.fillStyle=t,g.globalAlpha=.9,g.fillRect(h+d-r,f,r,s((1-x/y)*p))}}};/*! +}`;function e_(a,e,t){let n=new Ra;const i=new fe,s=new fe,r=new ht,o=new Yl({depthPacking:ff}),c=new Zl,l={},u=t.maxTextureSize,h={0:Tn,1:oi,2:ai},f=new Kn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new fe},radius:{value:4}},vertexShader:$v,fragmentShader:Qv}),d=f.clone();d.defines.HORIZONTAL_PASS=1;const p=new qe;p.setAttribute("position",new ft(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new St(p,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=kc,this.render=function(v,M,T){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||v.length===0)return;const C=a.getRenderTarget(),_=a.getActiveCubeFace(),E=a.getActiveMipmapLevel(),F=a.state;F.setBlending(ci),F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);for(let U=0,q=v.length;Uu||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/X.x),i.x=s.x*X.x,G.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/X.y),i.y=s.y*X.y,G.mapSize.y=s.y)),G.map===null){const Z=this.type!==Ws?{minFilter:kt,magFilter:kt}:{};G.map=new En(i.x,i.y,Z),G.map.texture.name=J.name+".shadowMap",G.camera.updateProjectionMatrix()}a.setRenderTarget(G.map),a.clear();const B=G.getViewportCount();for(let Z=0;Z0){const q=F.uuid,J=M.uuid;let G=l[q];G===void 0&&(G={},l[q]=G);let X=G[J];X===void 0&&(X=F.clone(),G[J]=X),F=X}return F.visible=M.visible,F.wireframe=M.wireframe,E===Ws?F.side=M.shadowSide!==null?M.shadowSide:M.side:F.side=M.shadowSide!==null?M.shadowSide:h[M.side],F.alphaMap=M.alphaMap,F.alphaTest=M.alphaTest,F.clipShadows=M.clipShadows,F.clippingPlanes=M.clippingPlanes,F.clipIntersection=M.clipIntersection,F.displacementMap=M.displacementMap,F.displacementScale=M.displacementScale,F.displacementBias=M.displacementBias,F.wireframeLinewidth=M.wireframeLinewidth,F.linewidth=M.linewidth,T.isPointLight===!0&&F.isMeshDistanceMaterial===!0&&(F.referencePosition.setFromMatrixPosition(T.matrixWorld),F.nearDistance=C,F.farDistance=_),F}function b(v,M,T,C,_){if(v.visible===!1)return;if(v.layers.test(M.layers)&&(v.isMesh||v.isLine||v.isPoints)&&(v.castShadow||v.receiveShadow&&_===Ws)&&(!v.frustumCulled||n.intersectsObject(v))){v.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,v.matrixWorld);const U=e.update(v),q=v.material;if(Array.isArray(q)){const J=U.groups;for(let G=0,X=J.length;G=1):Y.indexOf("OpenGL ES")!==-1&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(Y)[1]),B=Z>=2);let W=null,j={};const ne=a.getParameter(3088),$=a.getParameter(2978),ie=new ht().fromArray(ne),ce=new ht().fromArray($);function oe(V,_e,re){const Ie=new Uint8Array(4),Ce=a.createTexture();a.bindTexture(V,Ce),a.texParameteri(V,10241,9728),a.texParameteri(V,10240,9728);for(let Je=0;Jez||O.height>z)&&(K=z/Math.max(O.width,O.height)),K<1||D===!0)if(typeof HTMLImageElement!="undefined"&&O instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&O instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&O instanceof ImageBitmap){const Q=D?ra:Math.floor,me=Q(K*O.width),R=Q(K*O.height);m===void 0&&(m=y(me,R));const ae=k?y(me,R):m;return ae.width=me,ae.height=R,ae.getContext("2d").drawImage(O,0,0,me,R),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+O.width+"x"+O.height+") to ("+me+"x"+R+")."),ae}else return"data"in O&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+O.width+"x"+O.height+")."),O;return O}function v(O){return yl(O.width)&&yl(O.height)}function M(O){return o?!1:O.wrapS!==Wt||O.wrapT!==Wt||O.minFilter!==kt&&O.minFilter!==Et}function T(O,D){return O.generateMipmaps&&D&&O.minFilter!==kt&&O.minFilter!==Et}function C(O){a.generateMipmap(O)}function _(O,D,k,z,K=!1){if(o===!1)return D;if(O!==null){if(a[O]!==void 0)return a[O];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+O+"'")}let Q=D;return D===6403&&(k===5126&&(Q=33326),k===5131&&(Q=33325),k===5121&&(Q=33321)),D===33319&&(k===5126&&(Q=33328),k===5131&&(Q=33327),k===5121&&(Q=33323)),D===6408&&(k===5126&&(Q=34836),k===5131&&(Q=34842),k===5121&&(Q=z===nt&&K===!1?35907:32856),k===32819&&(Q=32854),k===32820&&(Q=32855)),(Q===33325||Q===33326||Q===33327||Q===33328||Q===34842||Q===34836)&&e.get("EXT_color_buffer_float"),Q}function E(O,D,k){return T(O,k)===!0||O.isFramebufferTexture&&O.minFilter!==kt&&O.minFilter!==Et?Math.log2(Math.max(D.width,D.height))+1:O.mipmaps!==void 0&&O.mipmaps.length>0?O.mipmaps.length:O.isCompressedTexture&&Array.isArray(O.image)?D.mipmaps.length:1}function F(O){return O===kt||O===eo||O===to?9728:9729}function U(O){const D=O.target;D.removeEventListener("dispose",U),J(D),D.isVideoTexture&&p.delete(D)}function q(O){const D=O.target;D.removeEventListener("dispose",q),X(D)}function J(O){const D=n.get(O);if(D.__webglInit===void 0)return;const k=O.source,z=g.get(k);if(z){const K=z[D.__cacheKey];K.usedTimes--,K.usedTimes===0&&G(O),Object.keys(z).length===0&&g.delete(k)}n.remove(O)}function G(O){const D=n.get(O);a.deleteTexture(D.__webglTexture);const k=O.source,z=g.get(k);delete z[D.__cacheKey],r.memory.textures--}function X(O){const D=O.texture,k=n.get(O),z=n.get(D);if(z.__webglTexture!==void 0&&(a.deleteTexture(z.__webglTexture),r.memory.textures--),O.depthTexture&&O.depthTexture.dispose(),O.isWebGLCubeRenderTarget)for(let K=0;K<6;K++)a.deleteFramebuffer(k.__webglFramebuffer[K]),k.__webglDepthbuffer&&a.deleteRenderbuffer(k.__webglDepthbuffer[K]);else{if(a.deleteFramebuffer(k.__webglFramebuffer),k.__webglDepthbuffer&&a.deleteRenderbuffer(k.__webglDepthbuffer),k.__webglMultisampledFramebuffer&&a.deleteFramebuffer(k.__webglMultisampledFramebuffer),k.__webglColorRenderbuffer)for(let K=0;K=c&&console.warn("THREE.WebGLTextures: Trying to use "+O+" texture units while this GPU supports only "+c),B+=1,O}function W(O){const D=[];return D.push(O.wrapS),D.push(O.wrapT),D.push(O.magFilter),D.push(O.minFilter),D.push(O.anisotropy),D.push(O.internalFormat),D.push(O.format),D.push(O.type),D.push(O.generateMipmaps),D.push(O.premultiplyAlpha),D.push(O.flipY),D.push(O.unpackAlignment),D.push(O.encoding),D.join()}function j(O,D){const k=n.get(O);if(O.isVideoTexture&&dt(O),O.isRenderTargetTexture===!1&&O.version>0&&k.__version!==O.version){const z=O.image;if(z===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(z.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{we(k,O,D);return}}t.activeTexture(33984+D),t.bindTexture(3553,k.__webglTexture)}function ne(O,D){const k=n.get(O);if(O.version>0&&k.__version!==O.version){we(k,O,D);return}t.activeTexture(33984+D),t.bindTexture(35866,k.__webglTexture)}function $(O,D){const k=n.get(O);if(O.version>0&&k.__version!==O.version){we(k,O,D);return}t.activeTexture(33984+D),t.bindTexture(32879,k.__webglTexture)}function ie(O,D){const k=n.get(O);if(O.version>0&&k.__version!==O.version){De(k,O,D);return}t.activeTexture(33984+D),t.bindTexture(34067,k.__webglTexture)}const ce={[on]:10497,[Wt]:33071,[js]:33648},oe={[kt]:9728,[eo]:9984,[to]:9986,[Et]:9729,[Qo]:9985,[jn]:9987};function H(O,D,k){if(k?(a.texParameteri(O,10242,ce[D.wrapS]),a.texParameteri(O,10243,ce[D.wrapT]),(O===32879||O===35866)&&a.texParameteri(O,32882,ce[D.wrapR]),a.texParameteri(O,10240,oe[D.magFilter]),a.texParameteri(O,10241,oe[D.minFilter])):(a.texParameteri(O,10242,33071),a.texParameteri(O,10243,33071),(O===32879||O===35866)&&a.texParameteri(O,32882,33071),(D.wrapS!==Wt||D.wrapT!==Wt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),a.texParameteri(O,10240,F(D.magFilter)),a.texParameteri(O,10241,F(D.minFilter)),D.minFilter!==kt&&D.minFilter!==Et&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){const z=e.get("EXT_texture_filter_anisotropic");if(D.type===li&&e.has("OES_texture_float_linear")===!1||o===!1&&D.type===Ys&&e.has("OES_texture_half_float_linear")===!1)return;(D.anisotropy>1||n.get(D).__currentAnisotropy)&&(a.texParameterf(O,z.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(D.anisotropy,i.getMaxAnisotropy())),n.get(D).__currentAnisotropy=D.anisotropy)}}function ye(O,D){let k=!1;O.__webglInit===void 0&&(O.__webglInit=!0,D.addEventListener("dispose",U));const z=D.source;let K=g.get(z);K===void 0&&(K={},g.set(z,K));const Q=W(D);if(Q!==O.__cacheKey){K[Q]===void 0&&(K[Q]={texture:a.createTexture(),usedTimes:0},r.memory.textures++,k=!0),K[Q].usedTimes++;const me=K[O.__cacheKey];me!==void 0&&(K[O.__cacheKey].usedTimes--,me.usedTimes===0&&G(D)),O.__cacheKey=Q,O.__webglTexture=K[Q].texture}return k}function we(O,D,k){let z=3553;D.isDataArrayTexture&&(z=35866),D.isData3DTexture&&(z=32879);const K=ye(O,D),Q=D.source;if(t.activeTexture(33984+k),t.bindTexture(z,O.__webglTexture),Q.version!==Q.__currentVersion||K===!0){a.pixelStorei(37440,D.flipY),a.pixelStorei(37441,D.premultiplyAlpha),a.pixelStorei(3317,D.unpackAlignment),a.pixelStorei(37443,0);const me=M(D)&&v(D.image)===!1;let R=b(D.image,me,!1,u);R=ct(D,R);const ae=v(R)||o,pe=s.convert(D.format,D.encoding);let Se=s.convert(D.type),Te=_(D.internalFormat,pe,Se,D.encoding,D.isVideoTexture);H(z,D,ae);let He;const Ze=D.mipmaps,Qe=o&&D.isVideoTexture!==!0,V=Q.__currentVersion===void 0||K===!0,_e=E(D,R,ae);if(D.isDepthTexture)Te=6402,o?D.type===li?Te=36012:D.type===Pi?Te=33190:D.type===as?Te=35056:Te=33189:D.type===li&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),D.format===Di&&Te===6402&&D.type!==Wc&&D.type!==Pi&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),D.type=Pi,Se=s.convert(D.type)),D.format===cs&&Te===6402&&(Te=34041,D.type!==as&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),D.type=as,Se=s.convert(D.type))),V&&(Qe?t.texStorage2D(3553,1,Te,R.width,R.height):t.texImage2D(3553,0,Te,R.width,R.height,0,pe,Se,null));else if(D.isDataTexture)if(Ze.length>0&&ae){Qe&&V&&t.texStorage2D(3553,_e,Te,Ze[0].width,Ze[0].height);for(let re=0,Ie=Ze.length;re>=1,Ie>>=1}}else if(Ze.length>0&&ae){Qe&&V&&t.texStorage2D(3553,_e,Te,Ze[0].width,Ze[0].height);for(let re=0,Ie=Ze.length;re0&&V++,t.texStorage2D(34067,V,He,R[0].width,R[0].height));for(let re=0;re<6;re++)if(me){Ze?t.texSubImage2D(34069+re,0,0,0,R[re].width,R[re].height,Se,Te,R[re].data):t.texImage2D(34069+re,0,He,R[re].width,R[re].height,0,Se,Te,R[re].data);for(let Ie=0;Ie<_e.length;Ie++){const Je=_e[Ie].image[re].image;Ze?t.texSubImage2D(34069+re,Ie+1,0,0,Je.width,Je.height,Se,Te,Je.data):t.texImage2D(34069+re,Ie+1,He,Je.width,Je.height,0,Se,Te,Je.data)}}else{Ze?t.texSubImage2D(34069+re,0,0,0,Se,Te,R[re]):t.texImage2D(34069+re,0,He,Se,Te,R[re]);for(let Ie=0;Ie<_e.length;Ie++){const Ce=_e[Ie];Ze?t.texSubImage2D(34069+re,Ie+1,0,0,Se,Te,Ce.image[re]):t.texImage2D(34069+re,Ie+1,He,Se,Te,Ce.image[re])}}}T(D,pe)&&C(34067),K.__currentVersion=K.version,D.onUpdate&&D.onUpdate(D)}O.__version=D.version}function xe(O,D,k,z,K){const Q=s.convert(k.format,k.encoding),me=s.convert(k.type),R=_(k.internalFormat,Q,me,k.encoding);n.get(D).__hasExternalTextures||(K===32879||K===35866?t.texImage3D(K,0,R,D.width,D.height,D.depth,0,Q,me,null):t.texImage2D(K,0,R,D.width,D.height,0,Q,me,null)),t.bindFramebuffer(36160,O),Be(D)?f.framebufferTexture2DMultisampleEXT(36160,z,K,n.get(k).__webglTexture,0,ze(D)):a.framebufferTexture2D(36160,z,K,n.get(k).__webglTexture,0),t.bindFramebuffer(36160,null)}function Ve(O,D,k){if(a.bindRenderbuffer(36161,O),D.depthBuffer&&!D.stencilBuffer){let z=33189;if(k||Be(D)){const K=D.depthTexture;K&&K.isDepthTexture&&(K.type===li?z=36012:K.type===Pi&&(z=33190));const Q=ze(D);Be(D)?f.renderbufferStorageMultisampleEXT(36161,Q,z,D.width,D.height):a.renderbufferStorageMultisample(36161,Q,z,D.width,D.height)}else a.renderbufferStorage(36161,z,D.width,D.height);a.framebufferRenderbuffer(36160,36096,36161,O)}else if(D.depthBuffer&&D.stencilBuffer){const z=ze(D);k&&Be(D)===!1?a.renderbufferStorageMultisample(36161,z,35056,D.width,D.height):Be(D)?f.renderbufferStorageMultisampleEXT(36161,z,35056,D.width,D.height):a.renderbufferStorage(36161,34041,D.width,D.height),a.framebufferRenderbuffer(36160,33306,36161,O)}else{const z=D.isWebGLMultipleRenderTargets===!0?D.texture:[D.texture];for(let K=0;K0&&Be(O)===!1){const R=Q?D:[D];k.__webglMultisampledFramebuffer=a.createFramebuffer(),k.__webglColorRenderbuffer=[],t.bindFramebuffer(36160,k.__webglMultisampledFramebuffer);for(let ae=0;ae0&&Be(O)===!1){const D=O.isWebGLMultipleRenderTargets?O.texture:[O.texture],k=O.width,z=O.height;let K=16384;const Q=[],me=O.stencilBuffer?33306:36096,R=n.get(O),ae=O.isWebGLMultipleRenderTargets===!0;if(ae)for(let pe=0;pe0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&D.__useRenderToTexture!==!1}function dt(O){const D=r.render.frame;p.get(O)!==D&&(p.set(O,D),O.update())}function ct(O,D){const k=O.encoding,z=O.format,K=O.type;return O.isCompressedTexture===!0||O.isVideoTexture===!0||O.format===sa||k!==ui&&(k===nt?o===!1?e.has("EXT_sRGB")===!0&&z===_n?(O.format=sa,O.minFilter=Et,O.generateMipmaps=!1):D=_l.sRGBToLinear(D):(z!==_n||K!==Ii)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",k)),D}this.allocateTextureUnit=Y,this.resetTextureUnits=Z,this.setTexture2D=j,this.setTexture2DArray=ne,this.setTexture3D=$,this.setTextureCube=ie,this.rebindTextures=ve,this.setupRenderTarget=Fe,this.updateRenderTargetMipmap=Ee,this.updateMultisampleRenderTarget=je,this.setupDepthRenderbuffer=ue,this.setupFrameBufferTexture=xe,this.useMultisampledRTT=Be}function od(a,e,t){const n=t.isWebGL2;function i(s,r=null){let o;if(s===Ii)return 5121;if(s===Zh)return 32819;if(s===Kh)return 32820;if(s===Xh)return 5120;if(s===jh)return 5122;if(s===Wc)return 5123;if(s===Yh)return 5124;if(s===Pi)return 5125;if(s===li)return 5126;if(s===Ys)return n?5131:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===Jh)return 6406;if(s===_n)return 6408;if(s===Qh)return 6409;if(s===ef)return 6410;if(s===Di)return 6402;if(s===cs)return 34041;if(s===tf)return 6403;if(s===$h)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(s===sa)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(s===nf)return 36244;if(s===sf)return 33319;if(s===rf)return 33320;if(s===of)return 36249;if(s===no||s===ea||s===io||s===so)if(r===nt)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(s===no)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===ea)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===io)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===so)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===no)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===ea)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===io)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===so)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===qc||s===Xc||s===jc||s===Yc)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===qc)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Xc)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===jc)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Yc)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===Zc)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Kc||s===Jc)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(s===Kc)return r===nt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(s===Jc)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===$c||s===Qc||s===el||s===tl||s===nl||s===il||s===sl||s===rl||s===ol||s===al||s===cl||s===ll||s===ul||s===hl)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(s===$c)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===Qc)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===el)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===tl)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===nl)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===il)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===sl)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===rl)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===ol)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===al)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===cl)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===ll)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===ul)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===hl)return r===nt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===fl)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(s===fl)return r===nt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;return s===as?n?34042:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):a[s]!==void 0?a[s]:null}return{convert:i}}class ad extends Dt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class dn extends lt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const i_={type:"move"};class Kl{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new dn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new dn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new P),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new dn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new P),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,s=null,r=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){r=!0;for(const m of e.hand.values()){const g=t.getJointPose(m,n);if(l.joints[m.jointName]===void 0){const y=new dn;y.matrixAutoUpdate=!1,y.visible=!1,l.joints[m.jointName]=y,l.add(y)}const x=l.joints[m.jointName];g!==null&&(x.matrix.fromArray(g.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.jointRadius=g.radius),x.visible=g!==null}const u=l.joints["index-finger-tip"],h=l.joints["thumb-tip"],f=u.position.distanceTo(h.position),d=.02,p=.005;l.inputState.pinching&&f>d+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&f<=d-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(i_)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=r!==null),this}}class cd extends Mt{constructor(e,t,n,i,s,r,o,c,l,u){if(u=u!==void 0?u:Di,u!==Di&&u!==cs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&u===Di&&(n=Pi),n===void 0&&u===cs&&(n=as),super(null,i,s,r,o,c,u,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=o!==void 0?o:kt,this.minFilter=c!==void 0?c:kt,this.flipY=!1,this.generateMipmaps=!1}}class s_ extends Zn{constructor(e,t){super();const n=this;let i=null,s=1,r=null,o="local-floor",c=null,l=null,u=null,h=null,f=null,d=null;const p=t.getContextAttributes();let m=null,g=null;const x=[],y=[],b=new Dt;b.layers.enable(1),b.viewport=new ht;const v=new Dt;v.layers.enable(2),v.viewport=new ht;const M=[b,v],T=new ad;T.layers.enable(1),T.layers.enable(2);let C=null,_=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(W){let j=x[W];return j===void 0&&(j=new Kl,x[W]=j),j.getTargetRaySpace()},this.getControllerGrip=function(W){let j=x[W];return j===void 0&&(j=new Kl,x[W]=j),j.getGripSpace()},this.getHand=function(W){let j=x[W];return j===void 0&&(j=new Kl,x[W]=j),j.getHandSpace()};function E(W){const j=y.indexOf(W.inputSource);if(j===-1)return;const ne=x[j];ne!==void 0&&ne.dispatchEvent({type:W.type,data:W.inputSource})}function F(){i.removeEventListener("select",E),i.removeEventListener("selectstart",E),i.removeEventListener("selectend",E),i.removeEventListener("squeeze",E),i.removeEventListener("squeezestart",E),i.removeEventListener("squeezeend",E),i.removeEventListener("end",F),i.removeEventListener("inputsourceschange",U);for(let W=0;W=0&&(y[$]=null,x[$].dispatchEvent({type:"disconnected",data:ne}))}for(let j=0;j=y.length){y.push(ne),$=ce;break}else if(y[ce]===null){y[ce]=ne,$=ce;break}if($===-1)break}const ie=x[$];ie&&ie.dispatchEvent({type:"connected",data:ne})}}const q=new P,J=new P;function G(W,j,ne){q.setFromMatrixPosition(j.matrixWorld),J.setFromMatrixPosition(ne.matrixWorld);const $=q.distanceTo(J),ie=j.projectionMatrix.elements,ce=ne.projectionMatrix.elements,oe=ie[14]/(ie[10]-1),H=ie[14]/(ie[10]+1),ye=(ie[9]+1)/ie[5],we=(ie[9]-1)/ie[5],De=(ie[8]-1)/ie[0],xe=(ce[8]+1)/ce[0],Ve=oe*De,he=oe*xe,ue=$/(-De+xe),ve=ue*-De;j.matrixWorld.decompose(W.position,W.quaternion,W.scale),W.translateX(ve),W.translateZ(ue),W.matrixWorld.compose(W.position,W.quaternion,W.scale),W.matrixWorldInverse.copy(W.matrixWorld).invert();const Fe=oe+ue,Ee=H+ue,je=Ve-ve,ze=he+($-ve),Be=ye*H/Ee*Fe,dt=we*H/Ee*Fe;W.projectionMatrix.makePerspective(je,ze,Be,dt,Fe,Ee)}function X(W,j){j===null?W.matrixWorld.copy(W.matrix):W.matrixWorld.multiplyMatrices(j.matrixWorld,W.matrix),W.matrixWorldInverse.copy(W.matrixWorld).invert()}this.updateCamera=function(W){if(i===null)return;T.near=v.near=b.near=W.near,T.far=v.far=b.far=W.far,(C!==T.near||_!==T.far)&&(i.updateRenderState({depthNear:T.near,depthFar:T.far}),C=T.near,_=T.far);const j=W.parent,ne=T.cameras;X(T,j);for(let ie=0;ie0&&(m.alphaTest.value=g.alphaTest);const x=e.get(g).envMap;if(x&&(m.envMap.value=x,m.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap){m.lightMap.value=g.lightMap;const v=a.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*v}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity);let y;g.map?y=g.map:g.specularMap?y=g.specularMap:g.displacementMap?y=g.displacementMap:g.normalMap?y=g.normalMap:g.bumpMap?y=g.bumpMap:g.roughnessMap?y=g.roughnessMap:g.metalnessMap?y=g.metalnessMap:g.alphaMap?y=g.alphaMap:g.emissiveMap?y=g.emissiveMap:g.clearcoatMap?y=g.clearcoatMap:g.clearcoatNormalMap?y=g.clearcoatNormalMap:g.clearcoatRoughnessMap?y=g.clearcoatRoughnessMap:g.iridescenceMap?y=g.iridescenceMap:g.iridescenceThicknessMap?y=g.iridescenceThicknessMap:g.specularIntensityMap?y=g.specularIntensityMap:g.specularColorMap?y=g.specularColorMap:g.transmissionMap?y=g.transmissionMap:g.thicknessMap?y=g.thicknessMap:g.sheenColorMap?y=g.sheenColorMap:g.sheenRoughnessMap&&(y=g.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix));let b;g.aoMap?b=g.aoMap:g.lightMap&&(b=g.lightMap),b!==void 0&&(b.isWebGLRenderTarget&&(b=b.texture),b.matrixAutoUpdate===!0&&b.updateMatrix(),m.uv2Transform.value.copy(b.matrix))}function s(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity}function r(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function o(m,g,x,y){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*x,m.scale.value=y*.5,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let b;g.map?b=g.map:g.alphaMap&&(b=g.alphaMap),b!==void 0&&(b.matrixAutoUpdate===!0&&b.updateMatrix(),m.uvTransform.value.copy(b.matrix))}function c(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uvTransform.value.copy(x.matrix))}function l(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function u(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function h(m,g){m.roughness.value=g.roughness,m.metalness.value=g.metalness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap),e.get(g).envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,x){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),m.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===Tn&&m.clearcoatNormalScale.value.negate())),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=x.texture,m.transmissionSamplerSize.value.set(x.width,x.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap)}function d(m,g){g.matcap&&(m.matcap.value=g.matcap)}function p(m,g){m.referencePosition.value.copy(g.referencePosition),m.nearDistance.value=g.nearDistance,m.farDistance.value=g.farDistance}return{refreshFogUniforms:t,refreshMaterialUniforms:n}}function o_(a,e,t,n){let i={},s={},r=[];const o=t.isWebGL2?a.getParameter(35375):0;function c(y,b){const v=b.program;n.uniformBlockBinding(y,v)}function l(y,b){let v=i[y.id];v===void 0&&(p(y),v=u(y),i[y.id]=v,y.addEventListener("dispose",g));const M=b.program;n.updateUBOMapping(y,M);const T=e.render.frame;s[y.id]!==T&&(f(y),s[y.id]=T)}function u(y){const b=h();y.__bindingPointIndex=b;const v=a.createBuffer(),M=y.__size,T=y.usage;return a.bindBuffer(35345,v),a.bufferData(35345,M,T),a.bindBuffer(35345,null),a.bindBufferBase(35345,b,v),v}function h(){for(let y=0;y0){T=v%M;const U=M-T;T!==0&&U-F.boundary<0&&(v+=M-T,E.__offset=v)}v+=F.storage}return T=v%M,T>0&&(v+=M-T),y.__size=v,y.__cache={},this}function m(y){const b=y.value,v={boundary:0,storage:0};return typeof b=="number"?(v.boundary=4,v.storage=4):b.isVector2?(v.boundary=8,v.storage=8):b.isVector3||b.isColor?(v.boundary=16,v.storage=12):b.isVector4?(v.boundary=16,v.storage=16):b.isMatrix3?(v.boundary=48,v.storage=48):b.isMatrix4?(v.boundary=64,v.storage=64):b.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",b),v}function g(y){const b=y.target;b.removeEventListener("dispose",g);const v=r.indexOf(b.__bindingPointIndex);r.splice(v,1),a.deleteBuffer(i[b.id]),delete i[b.id],delete s[b.id]}function x(){for(const y in i)a.deleteBuffer(i[y]);r=[],i={},s={}}return{bind:c,update:l,dispose:x}}function a_(){const a=lo("canvas");return a.style.display="block",a}function Jl(a={}){this.isWebGLRenderer=!0;const e=a.canvas!==void 0?a.canvas:a_(),t=a.context!==void 0?a.context:null,n=a.depth!==void 0?a.depth:!0,i=a.stencil!==void 0?a.stencil:!0,s=a.antialias!==void 0?a.antialias:!1,r=a.premultipliedAlpha!==void 0?a.premultipliedAlpha:!0,o=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,c=a.powerPreference!==void 0?a.powerPreference:"default",l=a.failIfMajorPerformanceCaveat!==void 0?a.failIfMajorPerformanceCaveat:!1;let u;t!==null?u=t.getContextAttributes().alpha:u=a.alpha!==void 0?a.alpha:!1;let h=null,f=null;const d=[],p=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=ui,this.physicallyCorrectLights=!1,this.toneMapping=Xn,this.toneMappingExposure=1,Object.defineProperties(this,{gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});const m=this;let g=!1,x=0,y=0,b=null,v=-1,M=null;const T=new ht,C=new ht;let _=null,E=e.width,F=e.height,U=1,q=null,J=null;const G=new ht(0,0,E,F),X=new ht(0,0,E,F);let B=!1;const Z=new Ra;let Y=!1,W=!1,j=null;const ne=new Pe,$=new fe,ie=new P,ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function oe(){return b===null?U:1}let H=t;function ye(N,ee){for(let le=0;le0?f=p[p.length-1]:f=null,d.pop(),d.length>0?h=d[d.length-1]:h=null};function si(N,ee,le,te){if(N.visible===!1)return;if(N.layers.test(ee.layers)){if(N.isGroup)le=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(ee);else if(N.isLight)f.pushLight(N),N.castShadow&&f.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||Z.intersectsSprite(N)){te&&ie.setFromMatrixPosition(N.matrixWorld).applyMatrix4(ne);const $e=ze.update(N),tt=N.material;tt.visible&&h.push(N,$e,tt,le,ie.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(N.isSkinnedMesh&&N.skeleton.frame!==Ve.render.frame&&(N.skeleton.update(),N.skeleton.frame=Ve.render.frame),!N.frustumCulled||Z.intersectsObject(N))){te&&ie.setFromMatrixPosition(N.matrixWorld).applyMatrix4(ne);const $e=ze.update(N),tt=N.material;if(Array.isArray(tt)){const et=$e.groups;for(let xt=0,ut=et.length;xt0&&qn(ge,ee,le),te&&xe.viewport(T.copy(te)),ge.length>0&&Tt(ge,ee,le),Ke.length>0&&Tt(Ke,ee,le),$e.length>0&&Tt($e,ee,le),xe.buffers.depth.setTest(!0),xe.buffers.depth.setMask(!0),xe.buffers.color.setMask(!0),xe.setPolygonOffset(!1)}function qn(N,ee,le){const te=De.isWebGL2;j===null&&(j=new En(1,1,{generateMipmaps:!0,type:we.has("EXT_color_buffer_half_float")?Ys:Ii,minFilter:jn,samples:te&&s===!0?4:0})),m.getDrawingBufferSize($),te?j.setSize($.x,$.y):j.setSize(ra($.x),ra($.y));const ge=m.getRenderTarget();m.setRenderTarget(j),m.clear();const Ke=m.toneMapping;m.toneMapping=Xn,Tt(N,ee,le),m.toneMapping=Ke,ue.updateMultisampleRenderTarget(j),ue.updateRenderTargetMipmap(j),m.setRenderTarget(ge)}function Tt(N,ee,le){const te=ee.isScene===!0?ee.overrideMaterial:null;for(let ge=0,Ke=N.length;ge0&&ue.useMultisampledRTT(N)===!1?ge=he.get(N).__webglMultisampledFramebuffer:ge=xt,T.copy(N.viewport),C.copy(N.scissor),_=N.scissorTest}else T.copy(G).multiplyScalar(U).floor(),C.copy(X).multiplyScalar(U).floor(),_=B;if(xe.bindFramebuffer(36160,ge)&&De.drawBuffers&&te&&xe.drawBuffers(N,ge),xe.viewport(T),xe.scissor(C),xe.setScissorTest(_),Ke){const et=he.get(N.texture);H.framebufferTexture2D(36160,36064,34069+ee,et.__webglTexture,le)}else if($e){const et=he.get(N.texture),xt=ee||0;H.framebufferTextureLayer(36160,36064,et.__webglTexture,le||0,xt)}v=-1},this.readRenderTargetPixels=function(N,ee,le,te,ge,Ke,$e){if(!(N&&N.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let tt=he.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&$e!==void 0&&(tt=tt[$e]),tt){xe.bindFramebuffer(36160,tt);try{const et=N.texture,xt=et.format,ut=et.type;if(xt!==_n&&R.convert(xt)!==H.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const pt=ut===Ys&&(we.has("EXT_color_buffer_half_float")||De.isWebGL2&&we.has("EXT_color_buffer_float"));if(ut!==Ii&&R.convert(ut)!==H.getParameter(35738)&&!(ut===li&&(De.isWebGL2||we.has("OES_texture_float")||we.has("WEBGL_color_buffer_float")))&&!pt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ee>=0&&ee<=N.width-te&&le>=0&&le<=N.height-ge&&H.readPixels(ee,le,te,ge,R.convert(xt),R.convert(ut),Ke)}finally{const et=b!==null?he.get(b).__webglFramebuffer:null;xe.bindFramebuffer(36160,et)}}},this.copyFramebufferToTexture=function(N,ee,le=0){const te=Math.pow(2,-le),ge=Math.floor(ee.image.width*te),Ke=Math.floor(ee.image.height*te);ue.setTexture2D(ee,0),H.copyTexSubImage2D(3553,le,0,0,N.x,N.y,ge,Ke),xe.unbindTexture()},this.copyTextureToTexture=function(N,ee,le,te=0){const ge=ee.image.width,Ke=ee.image.height,$e=R.convert(le.format),tt=R.convert(le.type);ue.setTexture2D(le,0),H.pixelStorei(37440,le.flipY),H.pixelStorei(37441,le.premultiplyAlpha),H.pixelStorei(3317,le.unpackAlignment),ee.isDataTexture?H.texSubImage2D(3553,te,N.x,N.y,ge,Ke,$e,tt,ee.image.data):ee.isCompressedTexture?H.compressedTexSubImage2D(3553,te,N.x,N.y,ee.mipmaps[0].width,ee.mipmaps[0].height,$e,ee.mipmaps[0].data):H.texSubImage2D(3553,te,N.x,N.y,$e,tt,ee.image),te===0&&le.generateMipmaps&&H.generateMipmap(3553),xe.unbindTexture()},this.copyTextureToTexture3D=function(N,ee,le,te,ge=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Ke=N.max.x-N.min.x+1,$e=N.max.y-N.min.y+1,tt=N.max.z-N.min.z+1,et=R.convert(te.format),xt=R.convert(te.type);let ut;if(te.isData3DTexture)ue.setTexture3D(te,0),ut=32879;else if(te.isDataArrayTexture)ue.setTexture2DArray(te,0),ut=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}H.pixelStorei(37440,te.flipY),H.pixelStorei(37441,te.premultiplyAlpha),H.pixelStorei(3317,te.unpackAlignment);const pt=H.getParameter(3314),At=H.getParameter(32878),Ei=H.getParameter(3316),jt=H.getParameter(3315),Sn=H.getParameter(32877),yn=le.isCompressedTexture?le.mipmaps[0]:le.image;H.pixelStorei(3314,yn.width),H.pixelStorei(32878,yn.height),H.pixelStorei(3316,N.min.x),H.pixelStorei(3315,N.min.y),H.pixelStorei(32877,N.min.z),le.isDataTexture||le.isData3DTexture?H.texSubImage3D(ut,ge,ee.x,ee.y,ee.z,Ke,$e,tt,et,xt,yn.data):le.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),H.compressedTexSubImage3D(ut,ge,ee.x,ee.y,ee.z,Ke,$e,tt,et,yn.data)):H.texSubImage3D(ut,ge,ee.x,ee.y,ee.z,Ke,$e,tt,et,xt,yn),H.pixelStorei(3314,pt),H.pixelStorei(32878,At),H.pixelStorei(3316,Ei),H.pixelStorei(3315,jt),H.pixelStorei(32877,Sn),ge===0&&te.generateMipmaps&&H.generateMipmap(ut),xe.unbindTexture()},this.initTexture=function(N){N.isCubeTexture?ue.setTextureCube(N,0):N.isData3DTexture?ue.setTexture3D(N,0):N.isDataArrayTexture?ue.setTexture2DArray(N,0):ue.setTexture2D(N,0),xe.unbindTexture()},this.resetState=function(){x=0,y=0,b=null,xe.reset(),ae.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class ld extends Jl{}ld.prototype.isWebGL1Renderer=!0;class Fa{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new be(e),this.density=t}clone(){return new Fa(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class Na{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new be(e),this.near=t,this.far=n}clone(){return new Na(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class ka extends lt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}}class xo{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=oo,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=bn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;ie.far||t.push({distance:c,point:vo.clone(),uv:Ln.getUV(vo,Ba,bo,za,hd,$l,fd,new fe),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Ua(a,e,t,n,i,s){yr.subVectors(a,t).addScalar(.5).multiply(n),i!==void 0?(_o.x=s*yr.x-i*yr.y,_o.y=i*yr.x+s*yr.y):_o.copy(yr),a.copy(e),a.x+=_o.x,a.y+=_o.y,a.applyMatrix4(ud)}const Ga=new P,dd=new P;class pd extends lt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n0){let n,i;for(n=1,i=t.length;n0){Ga.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Ga);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Ga.setFromMatrixPosition(e.matrixWorld),dd.setFromMatrixPosition(this.matrixWorld);const n=Ga.distanceTo(dd)/e.zoom;t[0].object.visible=!0;let i,s;for(i=1,s=t.length;i=t[i].distance;i++)t[i-1].object.visible=!1,t[i].object.visible=!0;for(this._currentLevel=i-1;ic)continue;f.applyMatrix4(this.matrixWorld);const _=e.ray.origin.distanceTo(f);_e.far||t.push({distance:_,point:h.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}else{const x=Math.max(0,r.start),y=Math.min(g.count,r.start+r.count);for(let b=x,v=y-1;bc)continue;f.applyMatrix4(this.matrixWorld);const T=e.ray.origin.distanceTo(f);Te.far||t.push({distance:T,point:h.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;s0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;si.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,object:r})}}class u_ extends Mt{constructor(e,t,n,i,s,r,o,c,l){super(e,t,n,i,s,r,o,c,l),this.isVideoTexture=!0,this.minFilter=r!==void 0?r:Et,this.magFilter=s!==void 0?s:Et,this.generateMipmaps=!1;const u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class h_ extends Mt{constructor(e,t,n){super({width:e,height:t}),this.isFramebufferTexture=!0,this.format=n,this.magFilter=kt,this.minFilter=kt,this.generateMipmaps=!1,this.needsUpdate=!0}}class Rd extends Mt{constructor(e,t,n,i,s,r,o,c,l,u,h,f){super(null,r,o,c,l,u,i,s,h,f),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class f_ extends Mt{constructor(e,t,n,i,s,r,o,c,l){super(e,t,n,i,s,r,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class In{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),s=0;t.push(0);for(let r=1;r<=e;r++)n=this.getPoint(r/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const s=n.length;let r;t?r=t:r=e*n[s-1];let o=0,c=s-1,l;for(;o<=c;)if(i=Math.floor(o+(c-o)/2),l=n[i]-r,l<0)o=i+1;else if(l>0)c=i-1;else{c=i;break}if(i=c,n[i]===r)return i/(s-1);const u=n[i],f=n[i+1]-u,d=(r-u)/f;return(i+d)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const r=this.getPoint(i),o=this.getPoint(s),c=t||(r.isVector2?new fe:new P);return c.copy(o).sub(r).normalize(),c}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new P,i=[],s=[],r=[],o=new P,c=new Pe;for(let d=0;d<=e;d++){const p=d/e;i[d]=this.getTangentAt(p,new P)}s[0]=new P,r[0]=new P;let l=Number.MAX_VALUE;const u=Math.abs(i[0].x),h=Math.abs(i[0].y),f=Math.abs(i[0].z);u<=l&&(l=u,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),f<=l&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],o),r[0].crossVectors(i[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),r[d]=r[d-1].clone(),o.crossVectors(i[d-1],i[d]),o.length()>Number.EPSILON){o.normalize();const p=Math.acos(Ot(i[d-1].dot(i[d]),-1,1));s[d].applyMatrix4(c.makeRotationAxis(o,p))}r[d].crossVectors(i[d],s[d])}if(t===!0){let d=Math.acos(Ot(s[0].dot(s[e]),-1,1));d/=e,i[0].dot(o.crossVectors(s[0],s[e]))>0&&(d=-d);for(let p=1;p<=e;p++)s[p].applyMatrix4(c.makeRotationAxis(i[p],d*p)),r[p].crossVectors(i[p],s[p])}return{tangents:i,normals:s,binormals:r}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Xa extends In{constructor(e=0,t=0,n=1,i=1,s=0,r=Math.PI*2,o=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=r,this.aClockwise=o,this.aRotation=c}getPoint(e,t){const n=t||new fe,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const r=Math.abs(s)i;)s-=i;s0?0:(Math.floor(Math.abs(o)/s)+1)*s:c===0&&o===s-1&&(o=s-2,c=1);let l,u;this.closed||o>0?l=i[(o-1)%s]:(ja.subVectors(i[0],i[1]).add(i[0]),l=ja);const h=i[o%s],f=i[(o+1)%s];if(this.closed||o+2i.length-2?i.length-1:r+1],h=i[r>i.length-3?i.length-1:r+2];return n.set(Dd(o,c.x,l.x,u.x,h.x),Dd(o,c.y,l.y,u.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const r=i[s]-n,o=this.curves[s],c=o.getLength(),l=c===0?0:1-r/c;return o.getPointAt(l,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);const u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Ss extends qe{constructor(e=[new fe(0,-.5),new fe(.5,0),new fe(0,.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=Ot(i,0,Math.PI*2);const s=[],r=[],o=[],c=[],l=[],u=1/t,h=new P,f=new fe,d=new P,p=new P,m=new P;let g=0,x=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:g=e[y+1].x-e[y].x,x=e[y+1].y-e[y].y,d.x=x*1,d.y=-g,d.z=x*0,m.copy(d),d.normalize(),c.push(d.x,d.y,d.z);break;case e.length-1:c.push(m.x,m.y,m.z);break;default:g=e[y+1].x-e[y].x,x=e[y+1].y-e[y].y,d.x=x*1,d.y=-g,d.z=x*0,p.copy(d),d.x+=m.x,d.y+=m.y,d.z+=m.z,d.normalize(),c.push(d.x,d.y,d.z),m.copy(p)}for(let y=0;y<=t;y++){const b=n+y*u*i,v=Math.sin(b),M=Math.cos(b);for(let T=0;T<=e.length-1;T++){h.x=e[T].x*v,h.y=e[T].y,h.z=e[T].x*M,r.push(h.x,h.y,h.z),f.x=y/t,f.y=T/(e.length-1),o.push(f.x,f.y);const C=c[3*T+0]*v,_=c[3*T+1],E=c[3*T+0]*M;l.push(C,_,E)}}for(let y=0;y0&&b(!0),t>0&&b(!1)),this.setIndex(u),this.setAttribute("position",new Ae(h,3)),this.setAttribute("normal",new Ae(f,3)),this.setAttribute("uv",new Ae(d,2));function y(){const v=new P,M=new P;let T=0;const C=(t-e)/n;for(let _=0;_<=s;_++){const E=[],F=_/s,U=F*(t-e)+e;for(let q=0;q<=i;q++){const J=q/i,G=J*c+o,X=Math.sin(G),B=Math.cos(G);M.x=U*X,M.y=-F*n+g,M.z=U*B,h.push(M.x,M.y,M.z),v.set(X,C,B).normalize(),f.push(v.x,v.y,v.z),d.push(J,1-F),E.push(p++)}m.push(E)}for(let _=0;_.9&&C<.1&&(b<.2&&(r[y+0]+=1),v<.2&&(r[y+2]+=1),M<.2&&(r[y+4]+=1))}}function f(y){s.push(y.x,y.y,y.z)}function d(y,b){const v=y*3;b.x=e[v+0],b.y=e[v+1],b.z=e[v+2]}function p(){const y=new P,b=new P,v=new P,M=new P,T=new fe,C=new fe,_=new fe;for(let E=0,F=0;E80*t){o=l=a[0],c=u=a[1];for(let p=t;pl&&(l=h),f>u&&(u=f);d=Math.max(l-o,u-c),d=d!==0?1/d:0}return Eo(s,r,t,o,c,d),r}};function Bd(a,e,t,n,i){let s,r;if(i===k_(a,e,t,n)>0)for(s=e;s=e;s-=n)r=Gd(s,a[s],a[s+1],r);return r&&$a(r,r.next)&&(Lo(r),r=r.next),r}function Yi(a,e){if(!a)return a;e||(e=a);let t=a,n;do if(n=!1,!t.steiner&&($a(t,t.next)||Ct(t.prev,t,t.next)===0)){if(Lo(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Eo(a,e,t,n,i,s,r){if(!a)return;!r&&s&&R_(a,n,i,s);let o=a,c,l;for(;a.prev!==a.next;){if(c=a.prev,l=a.next,s?w_(a,n,i,s):b_(a)){e.push(c.i/t),e.push(a.i/t),e.push(l.i/t),Lo(a),a=l.next,o=l.next;continue}if(a=l,a===o){r?r===1?(a=M_(Yi(a),e,t),Eo(a,e,t,n,i,s,2)):r===2&&S_(a,e,t,n,i,s):Eo(Yi(a),e,t,n,i,s,1);break}}}function b_(a){const e=a.prev,t=a,n=a.next;if(Ct(e,t,n)>=0)return!1;let i=a.next.next;for(;i!==a.prev;){if(Tr(e.x,e.y,t.x,t.y,n.x,n.y,i.x,i.y)&&Ct(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function w_(a,e,t,n){const i=a.prev,s=a,r=a.next;if(Ct(i,s,r)>=0)return!1;const o=i.xs.x?i.x>r.x?i.x:r.x:s.x>r.x?s.x:r.x,u=i.y>s.y?i.y>r.y?i.y:r.y:s.y>r.y?s.y:r.y,h=du(o,c,e,t,n),f=du(l,u,e,t,n);let d=a.prevZ,p=a.nextZ;for(;d&&d.z>=h&&p&&p.z<=f;){if(d!==a.prev&&d!==a.next&&Tr(i.x,i.y,s.x,s.y,r.x,r.y,d.x,d.y)&&Ct(d.prev,d,d.next)>=0||(d=d.prevZ,p!==a.prev&&p!==a.next&&Tr(i.x,i.y,s.x,s.y,r.x,r.y,p.x,p.y)&&Ct(p.prev,p,p.next)>=0))return!1;p=p.nextZ}for(;d&&d.z>=h;){if(d!==a.prev&&d!==a.next&&Tr(i.x,i.y,s.x,s.y,r.x,r.y,d.x,d.y)&&Ct(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=f;){if(p!==a.prev&&p!==a.next&&Tr(i.x,i.y,s.x,s.y,r.x,r.y,p.x,p.y)&&Ct(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function M_(a,e,t){let n=a;do{const i=n.prev,s=n.next.next;!$a(i,s)&&zd(i,n,n.next,s)&&Co(i,s)&&Co(s,i)&&(e.push(i.i/t),e.push(n.i/t),e.push(s.i/t),Lo(n),Lo(n.next),n=a=s),n=n.next}while(n!==a);return Yi(n)}function S_(a,e,t,n,i,s){let r=a;do{let o=r.next.next;for(;o!==r.prev;){if(r.i!==o.i&&D_(r,o)){let c=Ud(r,o);r=Yi(r,r.next),c=Yi(c,c.next),Eo(r,e,t,n,i,s),Eo(c,e,t,n,i,s);return}o=o.next}r=r.next}while(r!==a)}function T_(a,e,t,n){const i=[];let s,r,o,c,l;for(s=0,r=e.length;s=t.next.y&&t.next.y!==t.y){const f=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=n&&f>s){if(s=f,f===n){if(i===t.y)return t;if(i===t.next.y)return t.next}r=t.x=t.x&&t.x>=c&&n!==t.x&&Tr(ir.x||t.x===r.x&&L_(r,t)))&&(r=t,u=h)),t=t.next;while(t!==o);return r}function L_(a,e){return Ct(a.prev,a,e.prev)<0&&Ct(e.next,a,a.next)<0}function R_(a,e,t,n){let i=a;do i.z===null&&(i.z=du(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==a);i.prevZ.nextZ=null,i.prevZ=null,I_(i)}function I_(a){let e,t,n,i,s,r,o,c,l=1;do{for(t=a,a=null,s=null,r=0;t;){for(r++,n=t,o=0,e=0;e0||c>0&&n;)o!==0&&(c===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,o--):(i=n,n=n.nextZ,c--),s?s.nextZ=i:a=i,i.prevZ=s,s=i;t=n}s.nextZ=null,l*=2}while(r>1);return a}function du(a,e,t,n,i){return a=32767*(a-t)*i,e=32767*(e-n)*i,a=(a|a<<8)&16711935,a=(a|a<<4)&252645135,a=(a|a<<2)&858993459,a=(a|a<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,a|e<<1}function P_(a){let e=a,t=a;do(e.x=0&&(a-r)*(n-o)-(t-r)*(e-o)>=0&&(t-r)*(s-o)-(i-r)*(n-o)>=0}function D_(a,e){return a.next.i!==e.i&&a.prev.i!==e.i&&!F_(a,e)&&(Co(a,e)&&Co(e,a)&&N_(a,e)&&(Ct(a.prev,a,e.prev)||Ct(a,e.prev,e))||$a(a,e)&&Ct(a.prev,a,a.next)>0&&Ct(e.prev,e,e.next)>0)}function Ct(a,e,t){return(e.y-a.y)*(t.x-e.x)-(e.x-a.x)*(t.y-e.y)}function $a(a,e){return a.x===e.x&&a.y===e.y}function zd(a,e,t,n){const i=ec(Ct(a,e,t)),s=ec(Ct(a,e,n)),r=ec(Ct(t,n,a)),o=ec(Ct(t,n,e));return!!(i!==s&&r!==o||i===0&&Qa(a,t,e)||s===0&&Qa(a,n,e)||r===0&&Qa(t,a,n)||o===0&&Qa(t,e,n))}function Qa(a,e,t){return e.x<=Math.max(a.x,t.x)&&e.x>=Math.min(a.x,t.x)&&e.y<=Math.max(a.y,t.y)&&e.y>=Math.min(a.y,t.y)}function ec(a){return a>0?1:a<0?-1:0}function F_(a,e){let t=a;do{if(t.i!==a.i&&t.next.i!==a.i&&t.i!==e.i&&t.next.i!==e.i&&zd(t,t.next,a,e))return!0;t=t.next}while(t!==a);return!1}function Co(a,e){return Ct(a.prev,a,a.next)<0?Ct(a,e,a.next)>=0&&Ct(a,a.prev,e)>=0:Ct(a,e,a.prev)<0||Ct(a,a.next,e)<0}function N_(a,e){let t=a,n=!1;const i=(a.x+e.x)/2,s=(a.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==a);return n}function Ud(a,e){const t=new pu(a.i,a.x,a.y),n=new pu(e.i,e.x,e.y),i=a.next,s=e.prev;return a.next=e,e.prev=a,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function Gd(a,e,t,n){const i=new pu(a,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Lo(a){a.next.prev=a.prev,a.prev.next=a.next,a.prevZ&&(a.prevZ.nextZ=a.nextZ),a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function pu(a,e,t){this.i=a,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function k_(a,e,t,n){let i=0;for(let s=e,r=t-n;s2&&a[e-1].equals(a[0])&&a.pop()}function Hd(a,e){for(let t=0;tNumber.EPSILON){const k=Math.sqrt(O),z=Math.sqrt(dt*dt+ct*ct),K=ue.x-Be/k,Q=ue.y+ze/k,me=ve.x-ct/z,R=ve.y+dt/z,ae=((me-K)*ct-(R-Q)*dt)/(ze*ct-Be*dt);Fe=K+ze*ae-he.x,Ee=Q+Be*ae-he.y;const pe=Fe*Fe+Ee*Ee;if(pe<=2)return new fe(Fe,Ee);je=Math.sqrt(pe/2)}else{let k=!1;ze>Number.EPSILON?dt>Number.EPSILON&&(k=!0):ze<-Number.EPSILON?dt<-Number.EPSILON&&(k=!0):Math.sign(Be)===Math.sign(ct)&&(k=!0),k?(Fe=-Be,Ee=ze,je=Math.sqrt(O)):(Fe=ze,Ee=Be,je=Math.sqrt(O/2))}return new fe(Fe/je,Ee/je)}const W=[];for(let he=0,ue=G.length,ve=ue-1,Fe=he+1;he=0;he--){const ue=he/g,ve=d*Math.cos(ue*Math.PI/2),Fe=p*Math.sin(ue*Math.PI/2)+m;for(let Ee=0,je=G.length;Ee=0;){const Fe=ve;let Ee=ve-1;Ee<0&&(Ee=he.length-1);for(let je=0,ze=u+g*2;je0)&&d.push(b,v,T),(x!==n-1||c0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Qn extends Bt{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new be(16777215),this.specular=new be(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new be(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fi,this.normalScale=new fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=$r,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Zd extends Bt{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new be(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new be(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fi,this.normalScale=new fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Kd extends Bt{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fi,this.normalScale=new fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class tc extends Bt{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new be(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new be(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=$r,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Jd extends Bt{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new be(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fi,this.normalScale=new fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class $d extends zt{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Pn(a,e,t){return mu(a)?new a.constructor(a.subarray(e,t!==void 0?t:a.length)):a.slice(e,t)}function Ls(a,e,t){return!a||!t&&a.constructor===e?a:typeof e.BYTES_PER_ELEMENT=="number"?new e(a):Array.prototype.slice.call(a)}function mu(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)}function Qd(a){function e(i,s){return a[i]-a[s]}const t=a.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function gu(a,e,t){const n=a.length,i=new a.constructor(n);for(let s=0,r=0;r!==n;++s){const o=t[s]*e;for(let c=0;c!==e;++c)i[r++]=a[o+c]}return i}function yu(a,e,t,n){let i=1,s=a[0];for(;s!==void 0&&s[n]===void 0;)s=a[i++];if(s===void 0)return;let r=s[n];if(r!==void 0)if(Array.isArray(r))do r=s[n],r!==void 0&&(e.push(s.time),t.push.apply(t,r)),s=a[i++];while(s!==void 0);else if(r.toArray!==void 0)do r=s[n],r!==void 0&&(e.push(s.time),r.toArray(t,t.length)),s=a[i++];while(s!==void 0);else do r=s[n],r!==void 0&&(e.push(s.time),t.push(r)),s=a[i++];while(s!==void 0)}function U_(a,e,t,n,i=30){const s=a.clone();s.name=e;const r=[];for(let c=0;c=n)){h.push(l.times[d]);for(let m=0;ms.tracks[c].times[0]&&(o=s.tracks[c].times[0]);for(let c=0;c=o.times[p]){const x=p*h+u,y=x+h-u;m=Pn(o.values,x,y)}else{const x=o.createInterpolant(),y=u,b=h-u;x.evaluate(s),m=Pn(x.resultBuffer,y,b)}c==="quaternion"&&new Pt().fromArray(m).normalize().conjugate().toArray(m);const g=l.times.length;for(let x=0;x=s)){const o=t[1];e=s)break t}r=n,n=0;break n}break e}for(;n>>1;et;)--r;if(++r,s!==0||r!==i){s>=r&&(r=Math.max(r,1),s=r-1);const o=this.getValueSize();this.times=Pn(n,s,r),this.values=Pn(this.values,s*o,r*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let r=null;for(let o=0;o!==s;o++){const c=n[o];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(r!==null&&r>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,c,r),e=!1;break}r=c}if(i!==void 0&&mu(i))for(let o=0,c=i.length;o!==c;++o){const l=i[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){const e=Pn(this.times),t=Pn(this.values),n=this.getValueSize(),i=this.getInterpolation()===ta,s=e.length-1;let r=1;for(let o=1;o0){e[r]=e[s];for(let o=s*n,c=r*n,l=0;l!==n;++l)t[c+l]=t[o+l];++r}return r!==e.length?(this.times=Pn(e,0,r),this.values=Pn(t,0,r*n)):(this.times=e,this.values=t),this}clone(){const e=Pn(this.times,0),t=Pn(this.values,0),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}Wn.prototype.TimeBufferType=Float32Array,Wn.prototype.ValueBufferType=Float32Array,Wn.prototype.DefaultInterpolation=ls;class Rs extends Wn{}Rs.prototype.ValueTypeName="bool",Rs.prototype.ValueBufferType=Array,Rs.prototype.DefaultInterpolation=Zs,Rs.prototype.InterpolantFactoryMethodLinear=void 0,Rs.prototype.InterpolantFactoryMethodSmooth=void 0;class vu extends Wn{}vu.prototype.ValueTypeName="color";class Is extends Wn{}Is.prototype.ValueTypeName="number";class np extends Fr{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=(n-t)/(i-t);let l=e*o;for(let u=l+o;l!==u;l+=4)Pt.slerpFlat(s,0,r,l-o,r,l,c);return s}}class ei extends Wn{InterpolantFactoryMethodLinear(e){return new np(this.times,this.values,this.getValueSize(),e)}}ei.prototype.ValueTypeName="quaternion",ei.prototype.DefaultInterpolation=ls,ei.prototype.InterpolantFactoryMethodSmooth=void 0;class Ps extends Wn{}Ps.prototype.ValueTypeName="string",Ps.prototype.ValueBufferType=Array,Ps.prototype.DefaultInterpolation=Zs,Ps.prototype.InterpolantFactoryMethodLinear=void 0,Ps.prototype.InterpolantFactoryMethodSmooth=void 0;class vi extends Wn{}vi.prototype.ValueTypeName="vector";class _i{constructor(e,t=-1,n,i=na){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=bn(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let r=0,o=n.length;r!==o;++r)t.push(W_(n[r]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,r=n.length;s!==r;++s)t.push(Wn.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const s=t.length,r=[];for(let o=0;o1){const h=u[1];let f=i[h];f||(i[h]=f=[]),f.push(l)}}const r=[];for(const o in i)r.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return r}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(h,f,d,p,m){if(d.length!==0){const g=[],x=[];yu(d,g,x,p),g.length!==0&&m.push(new h(f,g,x))}},i=[],s=e.name||"default",r=e.fps||30,o=e.blendMode;let c=e.length||-1;const l=e.hierarchy||[];for(let h=0;h{t&&t(s),this.manager.itemEnd(e)},0),s;if(bi[e]!==void 0){bi[e].push({onLoad:t,onProgress:n,onError:i});return}bi[e]=[],bi[e].push({onLoad:t,onProgress:n,onError:i});const r=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,c=this.responseType;fetch(r).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream=="undefined"||l.body===void 0||l.body.getReader===void 0)return l;const u=bi[e],h=l.body.getReader(),f=l.headers.get("Content-Length"),d=f?parseInt(f):0,p=d!==0;let m=0;const g=new ReadableStream({start(x){y();function y(){h.read().then(({done:b,value:v})=>{if(b)x.close();else{m+=v.byteLength;const M=new ProgressEvent("progress",{lengthComputable:p,loaded:m,total:d});for(let T=0,C=u.length;T{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(u=>new DOMParser().parseFromString(u,o));case"json":return l.json();default:if(o===void 0)return l.text();{const h=/charset="?([^;"\s]*)"?/i.exec(o),f=h&&h[1]?h[1].toLowerCase():void 0,d=new TextDecoder(f);return l.arrayBuffer().then(p=>d.decode(p))}}}).then(l=>{Ds.add(e,l);const u=bi[e];delete bi[e];for(let h=0,f=u.length;h{const u=bi[e];if(u===void 0)throw this.manager.itemError(e),l;delete bi[e];for(let h=0,f=u.length;h{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class X_ extends Ut{constructor(e){super(e)}load(e,t,n,i){const s=this,r=new Zt(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}parse(e){const t=[];for(let n=0;n0:i.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const r=e.uniforms[s];switch(i.uniforms[s]={},r.type){case"t":i.uniforms[s].value=n(r.value);break;case"c":i.uniforms[s].value=new be().setHex(r.value);break;case"v2":i.uniforms[s].value=new fe().fromArray(r.value);break;case"v3":i.uniforms[s].value=new P().fromArray(r.value);break;case"v4":i.uniforms[s].value=new ht().fromArray(r.value);break;case"m3":i.uniforms[s].value=new an().fromArray(r.value);break;case"m4":i.uniforms[s].value=new Pe().fromArray(r.value);break;default:i.uniforms[s].value=r.value}}if(e.defines!==void 0&&(i.defines=e.defines),e.vertexShader!==void 0&&(i.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(i.fragmentShader=e.fragmentShader),e.extensions!==void 0)for(const s in e.extensions)i.extensions[s]=e.extensions[s];if(e.shading!==void 0&&(i.flatShading=e.shading===1),e.size!==void 0&&(i.size=e.size),e.sizeAttenuation!==void 0&&(i.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(i.map=n(e.map)),e.matcap!==void 0&&(i.matcap=n(e.matcap)),e.alphaMap!==void 0&&(i.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(i.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(i.bumpScale=e.bumpScale),e.normalMap!==void 0&&(i.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(i.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),i.normalScale=new fe().fromArray(s)}return e.displacementMap!==void 0&&(i.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(i.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(i.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(i.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(i.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(i.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(i.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(i.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(i.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(i.envMap=n(e.envMap)),e.envMapIntensity!==void 0&&(i.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(i.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(i.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(i.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(i.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(i.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(i.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(i.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(i.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new fe().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(i.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(i.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(i.thicknessMap=n(e.thicknessMap)),e.sheenColorMap!==void 0&&(i.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:jd,SpriteMaterial:Oa,RawShaderMaterial:Yd,ShaderMaterial:Kn,PointsMaterial:Xi,MeshPhysicalMaterial:xi,MeshStandardMaterial:Cs,MeshPhongMaterial:Qn,MeshToonMaterial:Zd,MeshNormalMaterial:Kd,MeshLambertMaterial:tc,MeshDepthMaterial:Yl,MeshDistanceMaterial:Zl,MeshBasicMaterial:cn,MeshMatcapMaterial:Jd,LineDashedMaterial:$d,LineBasicMaterial:zt,Material:Bt};return new t[e]}}class tn{static decodeText(e){if(typeof TextDecoder!="undefined")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n0){const c=new _u(t);s=new Ro(c),s.setCrossOrigin(this.crossOrigin);for(let l=0,u=e.length;l0){i=new Ro(this.manager),i.setCrossOrigin(this.crossOrigin);for(let r=0,o=e.length;r0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(n[c]!==n[c+t]){o.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let s=n,r=i;s!==r;++s)t[s]=t[i+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let r=0;r!==s;++r)e[t+r]=e[n+r]}_slerp(e,t,n,i){Pt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,s){const r=this._workIndex*s;Pt.multiplyQuaternionsFlat(e,r,e,t,e,n),Pt.slerpFlat(e,t,e,t,e,r,i)}_lerp(e,t,n,i,s){const r=1-i;for(let o=0;o!==s;++o){const c=t+o;e[c]=e[c]*r+e[n+o]*i}}_lerpAdditive(e,t,n,i,s){for(let r=0;r!==s;++r){const o=t+r;e[o]=e[o]+e[n+r]*i}}}const Eu="\\[\\]\\.:\\/",ab=new RegExp("["+Eu+"]","g"),Cu="[^"+Eu+"]",cb="[^"+Eu.replace("\\.","")+"]",lb=/((?:WC+[\/:])*)/.source.replace("WC",Cu),ub=/(WCOD+)?/.source.replace("WCOD",cb),hb=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Cu),fb=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Cu),db=new RegExp("^"+lb+ub+hb+fb+"$"),pb=["material","materials","bones"];class mb{constructor(e,t,n){const i=n||st.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class st{constructor(e,t,n){this.path=t,this.parsedPath=n||st.parseTrackName(t),this.node=st.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new st.Composite(e,t,n):new st(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(ab,"")}static parseTrackName(e){const t=db.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);pb.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: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let r=0;r=s){const h=s++,f=e[h];t[f.uuid]=u,e[u]=f,t[l]=h,e[h]=c;for(let d=0,p=i;d!==p;++d){const m=n[d],g=m[h],x=m[u];m[u]=g,m[h]=x}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_,r=e.length;for(let o=0,c=arguments.length;o!==c;++o){const l=arguments[o],u=l.uuid,h=t[u];if(h!==void 0)if(delete t[u],h0&&(t[d.uuid]=h),e[h]=d,e.pop();for(let p=0,m=i;p!==m;++p){const g=n[p];g[h]=g[f],g.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const s=this._bindings;if(i!==void 0)return s[i];const r=this._paths,o=this._parsedPaths,c=this._objects,l=c.length,u=this.nCachedObjects_,h=new Array(l);i=s.length,n[e]=i,r.push(e),o.push(t),s.push(h);for(let f=u,d=c.length;f!==d;++f){const p=c[f];h[f]=new st(p,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const i=this._paths,s=this._parsedPaths,r=this._bindings,o=r.length-1,c=r[o],l=e[o];t[l]=n,r[n]=c,r.pop(),s[n]=s[o],s.pop(),i[n]=i[o],i.pop()}}}class yb{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const s=t.tracks,r=s.length,o=new Array(r),c={endingStart:us,endingEnd:us};for(let l=0;l!==r;++l){const u=s[l].createInterpolant(null);o[l]=u,u.settings=c}this._interpolantSettings=c,this._interpolants=o,this._propertyBindings=new Array(r),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=cf,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const i=this._clip.duration,s=e._clip.duration,r=s/i,o=i/s;e.warp(1,r,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,s=i.time,r=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);const c=o.parameterPositions,l=o.sampleValues;return c[0]=s,c[1]=s+n,l[0]=e/r,l[1]=t/r,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const c=(e-s)*n;if(c<0||n===0)return;this._startTime=null,t=n*c}t*=this._updateTimeScale(e);const r=this._updateTime(t),o=this._updateWeight(e);if(o>0){const c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case dl:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(r),l[u].accumulateAdditive(o);break;case na:default:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(r),l[u].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;n!==null&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,s=this._loopCount;const r=n===lf;if(e===0)return s===-1?i:r&&(s&1)===1?t-i:i;if(n===af){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,r)):this._setEndings(this.repetitions===0,!0,r)),i>=t||i<0){const o=Math.floor(i/t);i-=t*o,s+=Math.abs(o);const c=this.repetitions-s;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){const l=e<0;this._setEndings(l,!l,r)}else this._setEndings(!1,!1,r);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=i;if(r&&(s&1)===1)return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=hs,i.endingEnd=hs):(e?i.endingStart=this.zeroSlopeAtStart?hs:us:i.endingStart=ro,t?i.endingEnd=this.zeroSlopeAtEnd?hs:us:i.endingEnd=ro)}_scheduleFading(e,t,n){const i=this._mixer,s=i.time;let r=this._weightInterpolant;r===null&&(r=i._lendControlInterpolant(),this._weightInterpolant=r);const o=r.parameterPositions,c=r.sampleValues;return o[0]=s,c[0]=t,o[1]=s+e,c[1]=n,this}}const xb=new Float32Array(1);class rc extends Zn{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,s=i.length,r=e._propertyBindings,o=e._interpolants,c=n.uuid,l=this._bindingsByRootAndName;let u=l[c];u===void 0&&(u={},l[c]=u);for(let h=0;h!==s;++h){const f=i[h],d=f.name;let p=u[d];if(p!==void 0)++p.referenceCount,r[h]=p;else{if(p=r[h],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,c,d));continue}const m=t&&t._propertyBindings[h].binding.parsedPath;p=new Mp(st.create(n,d,m),f.ValueTypeName,f.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,c,d),r[h]=p}o[h].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,i=e._clip.uuid,s=this._actionsByClip[i];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,i,n)}const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,s=Math.sign(e),r=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(i,e,s,r);const o=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)o[l].apply(r);return this}setTime(e){this.time=0;for(let t=0;tthis.max.x||e.ythis.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Ap.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Ep=new P,oc=new P;class Tb{constructor(e=new P,t=new P){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Ep.subVectors(e,this.start),oc.subVectors(this.end,this.start);const n=oc.dot(oc);let s=oc.dot(Ep)/n;return t&&(s=Ot(s,0,1)),s}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Cp=new P;class Ab extends lt{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;const n=new qe,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let r=0,o=1,c=32;r.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Fp.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Fp,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}}class zb extends pn{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new qe;i.setAttribute("position",new Ae(t,3)),i.setAttribute("color",new Ae(n,3));const s=new zt({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,n){const i=new be,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Ub{constructor(){this.type="ShapePath",this.color=new be,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Ao,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,s,r){return this.currentPath.bezierCurveTo(e,t,n,i,s,r),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e,t){function n(y){const b=[];for(let v=0,M=y.length;vNumber.EPSILON){if(U<0&&(_=b[C],F=-F,E=b[T],U=-U),y.y<_.y||y.y>E.y)continue;if(y.y===_.y){if(y.x===_.x)return!0}else{const q=U*(y.x-_.x)-F*(y.y-_.y);if(q===0)return!0;if(q<0)continue;M=!M}}else{if(y.y!==_.y)continue;if(E.x<=y.x&&y.x<=_.x||_.x<=y.x&&y.x<=E.x)return!0}}return M}const s=$n.isClockWise,r=this.subPaths;if(r.length===0)return[];if(t===!0)return n(r);let o,c,l;const u=[];if(r.length===1)return c=r[0],l=new Ts,l.curves=c.curves,u.push(l),u;let h=!s(r[0].getPoints());h=e?!h:h;const f=[],d=[];let p=[],m=0,g;d[m]=void 0,p[m]=[];for(let y=0,b=r.length;y1){let y=!1,b=0;for(let v=0,M=d.length;v0&&y===!1&&(p=f)}let x;for(let y=0,b=d.length;y>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}const s=new Uint32Array(2048),r=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,u=0;for(;(l&8388608)===0;)l<<=1,u-=8388608;l&=-8388609,u+=947912704,s[c]=l|u}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)r[c]=c<<23;r[31]=1199570944,r[32]=2147483648;for(let c=33;c<63;++c)r[c]=2147483648+(c-32<<23);r[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:s,exponentTable:r,offsetTable:o}}function Vb(a){Math.abs(a)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),a=Ot(a,-65504,65504),wi.floatView[0]=a;const e=wi.uint32View[0],t=e>>23&511;return wi.baseTable[t]+((e&8388607)>>wi.shiftTable[t])}function Hb(a){const e=a>>10;return wi.uint32View[0]=wi.mantissaTable[wi.offsetTable[e]+(a&1023)]+wi.exponentTable[e],wi.floatView[0]}var Wb=Object.freeze({__proto__:null,toHalfFloat:Vb,fromHalfFloat:Hb});class qb extends qe{constructor(){console.error("THREE.ParametricGeometry has been moved to /examples/jsm/geometries/ParametricGeometry.js"),super()}}class Xb extends qe{constructor(){console.error("THREE.TextGeometry has been moved to /examples/jsm/geometries/TextGeometry.js"),super()}}function jb(){console.error("THREE.FontLoader has been moved to /examples/jsm/loaders/FontLoader.js")}function Yb(){console.error("THREE.Font has been moved to /examples/jsm/loaders/FontLoader.js")}function Zb(){console.error("THREE.ImmediateRenderObject has been removed.")}class Kb extends En{constructor(e,t,n){console.error('THREE.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the "samples" property to greater 0 to enable multisampling.'),super(e,t,n),this.samples=4}}class Jb extends uo{constructor(e,t,n,i){console.warn("THREE.DataTexture2DArray has been renamed to DataArrayTexture."),super(e,t,n,i)}}class $b extends la{constructor(e,t,n,i){console.warn("THREE.DataTexture3D has been renamed to Data3DTexture."),super(e,t,n,i)}}typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ko}})),typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ko);var Qb=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Wh,AddEquation:os,AddOperation:Uh,AdditiveAnimationBlendMode:dl,AdditiveBlending:Oc,AlphaFormat:Jh,AlwaysDepth:Dh,AlwaysStencilFunc:pf,AmbientLight:Do,AmbientLightProbe:eb,AnimationClip:_i,AnimationLoader:X_,AnimationMixer:rc,AnimationObjectGroup:gb,AnimationUtils:V_,ArcCurve:Id,ArrayCamera:ad,ArrowHelper:Bb,Audio:bp,AudioAnalyser:ob,AudioContext:Tu,AudioListener:ib,AudioLoader:$_,AxesHelper:zb,BackSide:Tn,BasicDepthPacking:hf,BasicShadowMap:Km,Bone:ws,BooleanKeyframeTrack:Rs,Box2:Sb,Box3:hi,Box3Helper:kb,BoxBufferGeometry:yi,BoxGeometry:yi,BoxHelper:Nb,BufferAttribute:ft,BufferGeometry:qe,BufferGeometryLoader:fp,ByteType:Xh,Cache:Ds,Camera:Ca,CameraHelper:Fb,CanvasTexture:f_,CapsuleBufferGeometry:br,CapsuleGeometry:br,CatmullRomCurve3:Pd,CineonToneMapping:Hh,CircleBufferGeometry:wr,CircleGeometry:wr,ClampToEdgeWrapping:Wt,Clock:Au,Color:be,ColorKeyframeTrack:vu,ColorManagement:An,CompressedTexture:Rd,CompressedTextureLoader:ip,ConeBufferGeometry:Mr,ConeGeometry:Mr,CubeCamera:If,CubeReflectionMapping:Li,CubeRefractionMapping:Ri,CubeTexture:go,CubeTextureLoader:j_,CubeUVReflectionMapping:Xs,CubicBezierCurve:au,CubicBezierCurve3:Fd,CubicInterpolant:ep,CullFaceBack:Nc,CullFaceFront:yh,CullFaceFrontBack:Zm,CullFaceNone:gh,Curve:In,CurvePath:kd,CustomBlending:_h,CustomToneMapping:qh,CylinderBufferGeometry:ji,CylinderGeometry:ji,Cylindrical:Mb,Data3DTexture:la,DataArrayTexture:uo,DataTexture:xr,DataTexture2DArray:Jb,DataTexture3D:$b,DataTextureLoader:sp,DataUtils:Wb,DecrementStencilOp:ag,DecrementWrapStencilOp:lg,DefaultLoadingManager:bu,DepthFormat:Di,DepthStencilFormat:cs,DepthTexture:cd,DirectionalLight:Nr,DirectionalLightHelper:Db,DiscreteInterpolant:tp,DodecahedronBufferGeometry:Sr,DodecahedronGeometry:Sr,DoubleSide:ai,DstAlphaFactor:Eh,DstColorFactor:Lh,DynamicCopyUsage:Sg,DynamicDrawUsage:xg,DynamicReadUsage:bg,EdgesGeometry:Od,EllipseCurve:Xa,EqualDepth:Nh,EqualStencilFunc:dg,EquirectangularReflectionMapping:qs,EquirectangularRefractionMapping:Qr,Euler:Cn,EventDispatcher:Zn,ExtrudeBufferGeometry:Ar,ExtrudeGeometry:Ar,FileLoader:Zt,FlatShading:vh,Float16BufferAttribute:o0,Float32BufferAttribute:Ae,Float64BufferAttribute:a0,FloatType:li,Fog:Na,FogExp2:Fa,Font:Yb,FontLoader:jb,FramebufferTexture:h_,FrontSide:oi,Frustum:Ra,GLBufferAttribute:wb,GLSL1:Ag,GLSL3:ml,GreaterDepth:Oh,GreaterEqualDepth:kh,GreaterEqualStencilFunc:yg,GreaterStencilFunc:mg,GridHelper:Ib,Group:dn,HalfFloatType:Ys,HemisphereLight:wu,HemisphereLightHelper:Rb,HemisphereLightProbe:Q_,IcosahedronBufferGeometry:Er,IcosahedronGeometry:Er,ImageBitmapLoader:gp,ImageLoader:Ro,ImageUtils:_l,ImmediateRenderObject:Zb,IncrementStencilOp:og,IncrementWrapStencilOp:cg,InstancedBufferAttribute:vr,InstancedBufferGeometry:hp,InstancedInterleavedBuffer:bb,InstancedMesh:wd,Int16BufferAttribute:s0,Int32BufferAttribute:r0,Int8BufferAttribute:t0,IntType:Yh,InterleavedBuffer:xo,InterleavedBufferAttribute:qi,Interpolant:Fr,InterpolateDiscrete:Zs,InterpolateLinear:ls,InterpolateSmooth:ta,InvertStencilOp:ug,KeepStencilOp:ia,KeyframeTrack:Wn,LOD:pd,LatheBufferGeometry:Ss,LatheGeometry:Ss,Layers:ga,LessDepth:Fh,LessEqualDepth:Jo,LessEqualStencilFunc:pg,LessStencilFunc:fg,Light:Zi,LightProbe:nc,Line:Hn,Line3:Tb,LineBasicMaterial:zt,LineCurve:Ya,LineCurve3:Nd,LineDashedMaterial:$d,LineLoop:tu,LineSegments:pn,LinearEncoding:ui,LinearFilter:Et,LinearInterpolant:xu,LinearMipMapLinearFilter:tg,LinearMipMapNearestFilter:eg,LinearMipmapLinearFilter:jn,LinearMipmapNearestFilter:Qo,LinearSRGBColorSpace:Ni,LinearToneMapping:Gh,Loader:Ut,LoaderUtils:tn,LoadingManager:_u,LoopOnce:af,LoopPingPong:lf,LoopRepeat:cf,LuminanceAlphaFormat:ef,LuminanceFormat:Qh,MOUSE:is,Material:Bt,MaterialLoader:ic,MathUtils:en,Matrix3:an,Matrix4:Pe,MaxEquation:Gc,Mesh:St,MeshBasicMaterial:cn,MeshDepthMaterial:Yl,MeshDistanceMaterial:Zl,MeshLambertMaterial:tc,MeshMatcapMaterial:Jd,MeshNormalMaterial:Kd,MeshPhongMaterial:Qn,MeshPhysicalMaterial:xi,MeshStandardMaterial:Cs,MeshToonMaterial:Zd,MinEquation:Uc,MirroredRepeatWrapping:js,MixOperation:zh,MultiplyBlending:zc,MultiplyOperation:$r,NearestFilter:kt,NearestMipMapLinearFilter:Qm,NearestMipMapNearestFilter:$m,NearestMipmapLinearFilter:to,NearestMipmapNearestFilter:eo,NeverDepth:Ph,NeverStencilFunc:hg,NoBlending:ci,NoColorSpace:ig,NoToneMapping:Xn,NormalAnimationBlendMode:na,NormalBlending:rs,NotEqualDepth:Bh,NotEqualStencilFunc:gg,NumberKeyframeTrack:Is,Object3D:lt,ObjectLoader:dp,ObjectSpaceNormalMap:df,OctahedronBufferGeometry:As,OctahedronGeometry:As,OneFactor:Sh,OneMinusDstAlphaFactor:Ch,OneMinusDstColorFactor:Rh,OneMinusSrcAlphaFactor:Hc,OneMinusSrcColorFactor:Ah,OrthographicCamera:vs,PCFShadowMap:kc,PCFSoftShadowMap:xh,PMREMGenerator:Hl,ParametricGeometry:qb,Path:Ao,PerspectiveCamera:Dt,Plane:Wi,PlaneBufferGeometry:xs,PlaneGeometry:xs,PlaneHelper:Ob,PointLight:Ns,PointLightHelper:Cb,Points:_r,PointsMaterial:Xi,PolarGridHelper:Pb,PolyhedronBufferGeometry:Jn,PolyhedronGeometry:Jn,PositionalAudio:rb,PropertyBinding:st,PropertyMixer:Mp,QuadraticBezierCurve:cu,QuadraticBezierCurve3:lu,Quaternion:Pt,QuaternionKeyframeTrack:ei,QuaternionLinearInterpolant:np,REVISION:Ko,RGBADepthPacking:ff,RGBAFormat:_n,RGBAIntegerFormat:of,RGBA_ASTC_10x10_Format:ll,RGBA_ASTC_10x5_Format:ol,RGBA_ASTC_10x6_Format:al,RGBA_ASTC_10x8_Format:cl,RGBA_ASTC_12x10_Format:ul,RGBA_ASTC_12x12_Format:hl,RGBA_ASTC_4x4_Format:$c,RGBA_ASTC_5x4_Format:Qc,RGBA_ASTC_5x5_Format:el,RGBA_ASTC_6x5_Format:tl,RGBA_ASTC_6x6_Format:nl,RGBA_ASTC_8x5_Format:il,RGBA_ASTC_8x6_Format:sl,RGBA_ASTC_8x8_Format:rl,RGBA_BPTC_Format:fl,RGBA_ETC2_EAC_Format:Jc,RGBA_PVRTC_2BPPV1_Format:Yc,RGBA_PVRTC_4BPPV1_Format:jc,RGBA_S3TC_DXT1_Format:ea,RGBA_S3TC_DXT3_Format:io,RGBA_S3TC_DXT5_Format:so,RGBFormat:$h,RGB_ETC1_Format:Zc,RGB_ETC2_Format:Kc,RGB_PVRTC_2BPPV1_Format:Xc,RGB_PVRTC_4BPPV1_Format:qc,RGB_S3TC_DXT1_Format:no,RGFormat:sf,RGIntegerFormat:rf,RawShaderMaterial:Yd,Ray:fo,Raycaster:Sp,RectAreaLight:lp,RedFormat:tf,RedIntegerFormat:nf,ReinhardToneMapping:Vh,RepeatWrapping:on,ReplaceStencilOp:rg,ReverseSubtractEquation:wh,RingBufferGeometry:Cr,RingGeometry:Cr,SRGBColorSpace:Yn,Scene:ka,ShaderChunk:it,ShaderLib:Vn,ShaderMaterial:Kn,ShadowMaterial:jd,Shape:Ts,ShapeBufferGeometry:Lr,ShapeGeometry:Lr,ShapePath:Ub,ShapeUtils:$n,ShortType:jh,Skeleton:Ms,SkeletonHelper:Eb,SkinnedMesh:wo,SmoothShading:Jm,Source:ps,Sphere:Bi,SphereBufferGeometry:Es,SphereGeometry:Es,Spherical:Iu,SphericalHarmonics3:up,SplineCurve:uu,SpotLight:Io,SpotLightHelper:Ab,Sprite:Ql,SpriteMaterial:Oa,SrcAlphaFactor:Vc,SrcAlphaSaturateFactor:Ih,SrcColorFactor:Th,StaticCopyUsage:Mg,StaticDrawUsage:oo,StaticReadUsage:_g,StereoCamera:tb,StreamCopyUsage:Tg,StreamDrawUsage:vg,StreamReadUsage:wg,StringKeyframeTrack:Ps,SubtractEquation:bh,SubtractiveBlending:Bc,TOUCH:ss,TangentSpaceNormalMap:Fi,TetrahedronBufferGeometry:Rr,TetrahedronGeometry:Rr,TextGeometry:Xb,Texture:Mt,TextureLoader:Fs,TorusBufferGeometry:Ir,TorusGeometry:Ir,TorusKnotBufferGeometry:Pr,TorusKnotGeometry:Pr,Triangle:Ln,TriangleFanDrawMode:pl,TriangleStripDrawMode:uf,TrianglesDrawMode:ng,TubeBufferGeometry:Dr,TubeGeometry:Dr,UVMapping:$o,Uint16BufferAttribute:va,Uint32BufferAttribute:Dl,Uint8BufferAttribute:n0,Uint8ClampedBufferAttribute:i0,Uniform:Lu,UniformsGroup:_b,UniformsLib:Re,UniformsUtils:Rf,UnsignedByteType:Ii,UnsignedInt248Type:as,UnsignedIntType:Pi,UnsignedShort4444Type:Zh,UnsignedShort5551Type:Kh,UnsignedShortType:Wc,VSMShadowMap:Ws,Vector2:fe,Vector3:P,Vector4:ht,VectorKeyframeTrack:vi,VideoTexture:u_,WebGL1Renderer:ld,WebGL3DRenderTarget:qg,WebGLArrayRenderTarget:Wg,WebGLCubeRenderTarget:Pf,WebGLMultipleRenderTargets:Xg,WebGLMultisampleRenderTarget:Kb,WebGLRenderTarget:En,WebGLRenderer:Jl,WebGLUtils:od,WireframeGeometry:Wd,WrapAroundEnding:ro,ZeroCurvatureEnding:us,ZeroFactor:Mh,ZeroSlopeEnding:hs,ZeroStencilOp:sg,_SRGBAFormat:sa,sRGBEncoding:nt},Symbol.toStringTag,{value:"Module"}));const Np={type:"change"},Fu={type:"start"},kp={type:"end"};class ew extends Zn{constructor(e,t){super(),t===void 0&&console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.'),t===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.object=e,this.domElement=t,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new P,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:is.ROTATE,MIDDLE:is.DOLLY,RIGHT:is.PAN},this.touches={ONE:ss.ROTATE,TWO:ss.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return o.phi},this.getAzimuthalAngle=function(){return o.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(R){R.addEventListener("keydown",ct),this._domElementKeyEvents=R},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(Np),n.update(),s=i.NONE},this.update=function(){const R=new P,ae=new Pt().setFromUnitVectors(e.up,new P(0,1,0)),pe=ae.clone().invert(),Se=new P,Te=new Pt,He=2*Math.PI;return function(){const Qe=n.object.position;R.copy(Qe).sub(n.target),R.applyQuaternion(ae),o.setFromVector3(R),n.autoRotate&&s===i.NONE&&E(C()),n.enableDamping?(o.theta+=c.theta*n.dampingFactor,o.phi+=c.phi*n.dampingFactor):(o.theta+=c.theta,o.phi+=c.phi);let V=n.minAzimuthAngle,_e=n.maxAzimuthAngle;return isFinite(V)&&isFinite(_e)&&(V<-Math.PI?V+=He:V>Math.PI&&(V-=He),_e<-Math.PI?_e+=He:_e>Math.PI&&(_e-=He),V<=_e?o.theta=Math.max(V,Math.min(_e,o.theta)):o.theta=o.theta>(V+_e)/2?Math.max(V,o.theta):Math.min(_e,o.theta)),o.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,o.phi)),o.makeSafe(),o.radius*=l,o.radius=Math.max(n.minDistance,Math.min(n.maxDistance,o.radius)),n.enableDamping===!0?n.target.addScaledVector(u,n.dampingFactor):n.target.add(u),R.setFromSpherical(o),R.applyQuaternion(pe),Qe.copy(n.target).add(R),n.object.lookAt(n.target),n.enableDamping===!0?(c.theta*=1-n.dampingFactor,c.phi*=1-n.dampingFactor,u.multiplyScalar(1-n.dampingFactor)):(c.set(0,0,0),u.set(0,0,0)),l=1,h||Se.distanceToSquared(n.object.position)>r||8*(1-Te.dot(n.object.quaternion))>r?(n.dispatchEvent(Np),Se.copy(n.object.position),Te.copy(n.object.quaternion),h=!1,!0):!1}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",k),n.domElement.removeEventListener("pointerdown",ve),n.domElement.removeEventListener("pointercancel",je),n.domElement.removeEventListener("wheel",dt),n.domElement.removeEventListener("pointermove",Fe),n.domElement.removeEventListener("pointerup",Ee),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",ct)};const n=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=i.NONE;const r=1e-6,o=new Iu,c=new Iu;let l=1;const u=new P;let h=!1;const f=new fe,d=new fe,p=new fe,m=new fe,g=new fe,x=new fe,y=new fe,b=new fe,v=new fe,M=[],T={};function C(){return 2*Math.PI/60/60*n.autoRotateSpeed}function _(){return Math.pow(.95,n.zoomSpeed)}function E(R){c.theta-=R}function F(R){c.phi-=R}const U=function(){const R=new P;return function(pe,Se){R.setFromMatrixColumn(Se,0),R.multiplyScalar(-pe),u.add(R)}}(),q=function(){const R=new P;return function(pe,Se){n.screenSpacePanning===!0?R.setFromMatrixColumn(Se,1):(R.setFromMatrixColumn(Se,0),R.crossVectors(n.object.up,R)),R.multiplyScalar(pe),u.add(R)}}(),J=function(){const R=new P;return function(pe,Se){const Te=n.domElement;if(n.object.isPerspectiveCamera){const He=n.object.position;R.copy(He).sub(n.target);let Ze=R.length();Ze*=Math.tan(n.object.fov/2*Math.PI/180),U(2*pe*Ze/Te.clientHeight,n.object.matrix),q(2*Se*Ze/Te.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(U(pe*(n.object.right-n.object.left)/n.object.zoom/Te.clientWidth,n.object.matrix),q(Se*(n.object.top-n.object.bottom)/n.object.zoom/Te.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function G(R){n.object.isPerspectiveCamera?l/=R:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom*R)),n.object.updateProjectionMatrix(),h=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function X(R){n.object.isPerspectiveCamera?l*=R:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/R)),n.object.updateProjectionMatrix(),h=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function B(R){f.set(R.clientX,R.clientY)}function Z(R){y.set(R.clientX,R.clientY)}function Y(R){m.set(R.clientX,R.clientY)}function W(R){d.set(R.clientX,R.clientY),p.subVectors(d,f).multiplyScalar(n.rotateSpeed);const ae=n.domElement;E(2*Math.PI*p.x/ae.clientHeight),F(2*Math.PI*p.y/ae.clientHeight),f.copy(d),n.update()}function j(R){b.set(R.clientX,R.clientY),v.subVectors(b,y),v.y>0?G(_()):v.y<0&&X(_()),y.copy(b),n.update()}function ne(R){g.set(R.clientX,R.clientY),x.subVectors(g,m).multiplyScalar(n.panSpeed),J(x.x,x.y),m.copy(g),n.update()}function $(R){R.deltaY<0?X(_()):R.deltaY>0&&G(_()),n.update()}function ie(R){let ae=!1;switch(R.code){case n.keys.UP:J(0,n.keyPanSpeed),ae=!0;break;case n.keys.BOTTOM:J(0,-n.keyPanSpeed),ae=!0;break;case n.keys.LEFT:J(n.keyPanSpeed,0),ae=!0;break;case n.keys.RIGHT:J(-n.keyPanSpeed,0),ae=!0;break}ae&&(R.preventDefault(),n.update())}function ce(){if(M.length===1)f.set(M[0].pageX,M[0].pageY);else{const R=.5*(M[0].pageX+M[1].pageX),ae=.5*(M[0].pageY+M[1].pageY);f.set(R,ae)}}function oe(){if(M.length===1)m.set(M[0].pageX,M[0].pageY);else{const R=.5*(M[0].pageX+M[1].pageX),ae=.5*(M[0].pageY+M[1].pageY);m.set(R,ae)}}function H(){const R=M[0].pageX-M[1].pageX,ae=M[0].pageY-M[1].pageY,pe=Math.sqrt(R*R+ae*ae);y.set(0,pe)}function ye(){n.enableZoom&&H(),n.enablePan&&oe()}function we(){n.enableZoom&&H(),n.enableRotate&&ce()}function De(R){if(M.length==1)d.set(R.pageX,R.pageY);else{const pe=me(R),Se=.5*(R.pageX+pe.x),Te=.5*(R.pageY+pe.y);d.set(Se,Te)}p.subVectors(d,f).multiplyScalar(n.rotateSpeed);const ae=n.domElement;E(2*Math.PI*p.x/ae.clientHeight),F(2*Math.PI*p.y/ae.clientHeight),f.copy(d)}function xe(R){if(M.length===1)g.set(R.pageX,R.pageY);else{const ae=me(R),pe=.5*(R.pageX+ae.x),Se=.5*(R.pageY+ae.y);g.set(pe,Se)}x.subVectors(g,m).multiplyScalar(n.panSpeed),J(x.x,x.y),m.copy(g)}function Ve(R){const ae=me(R),pe=R.pageX-ae.x,Se=R.pageY-ae.y,Te=Math.sqrt(pe*pe+Se*Se);b.set(0,Te),v.set(0,Math.pow(b.y/y.y,n.zoomSpeed)),G(v.y),y.copy(b)}function he(R){n.enableZoom&&Ve(R),n.enablePan&&xe(R)}function ue(R){n.enableZoom&&Ve(R),n.enableRotate&&De(R)}function ve(R){n.enabled!==!1&&(M.length===0&&(n.domElement.setPointerCapture(R.pointerId),n.domElement.addEventListener("pointermove",Fe),n.domElement.addEventListener("pointerup",Ee)),z(R),R.pointerType==="touch"?O(R):ze(R))}function Fe(R){n.enabled!==!1&&(R.pointerType==="touch"?D(R):Be(R))}function Ee(R){K(R),M.length===0&&(n.domElement.releasePointerCapture(R.pointerId),n.domElement.removeEventListener("pointermove",Fe),n.domElement.removeEventListener("pointerup",Ee)),n.dispatchEvent(kp),s=i.NONE}function je(R){K(R)}function ze(R){let ae;switch(R.button){case 0:ae=n.mouseButtons.LEFT;break;case 1:ae=n.mouseButtons.MIDDLE;break;case 2:ae=n.mouseButtons.RIGHT;break;default:ae=-1}switch(ae){case is.DOLLY:if(n.enableZoom===!1)return;Z(R),s=i.DOLLY;break;case is.ROTATE:if(R.ctrlKey||R.metaKey||R.shiftKey){if(n.enablePan===!1)return;Y(R),s=i.PAN}else{if(n.enableRotate===!1)return;B(R),s=i.ROTATE}break;case is.PAN:if(R.ctrlKey||R.metaKey||R.shiftKey){if(n.enableRotate===!1)return;B(R),s=i.ROTATE}else{if(n.enablePan===!1)return;Y(R),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&n.dispatchEvent(Fu)}function Be(R){switch(s){case i.ROTATE:if(n.enableRotate===!1)return;W(R);break;case i.DOLLY:if(n.enableZoom===!1)return;j(R);break;case i.PAN:if(n.enablePan===!1)return;ne(R);break}}function dt(R){n.enabled===!1||n.enableZoom===!1||s!==i.NONE||(R.preventDefault(),n.dispatchEvent(Fu),$(R),n.dispatchEvent(kp))}function ct(R){n.enabled===!1||n.enablePan===!1||ie(R)}function O(R){switch(Q(R),M.length){case 1:switch(n.touches.ONE){case ss.ROTATE:if(n.enableRotate===!1)return;ce(),s=i.TOUCH_ROTATE;break;case ss.PAN:if(n.enablePan===!1)return;oe(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(n.touches.TWO){case ss.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;ye(),s=i.TOUCH_DOLLY_PAN;break;case ss.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;we(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&n.dispatchEvent(Fu)}function D(R){switch(Q(R),s){case i.TOUCH_ROTATE:if(n.enableRotate===!1)return;De(R),n.update();break;case i.TOUCH_PAN:if(n.enablePan===!1)return;xe(R),n.update();break;case i.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;he(R),n.update();break;case i.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;ue(R),n.update();break;default:s=i.NONE}}function k(R){n.enabled!==!1&&R.preventDefault()}function z(R){M.push(R)}function K(R){delete T[R.pointerId];for(let ae=0;ae=s+1e3&&(o.update(r*1e3/(u-s),100),s=u,r=0,l)){var h=performance.memory;l.update(h.usedJSHeapSize/1048576,h.jsHeapSizeLimit/1048576)}return u},update:function(){i=this.end()},domElement:e,setMode:n}};Fo.Panel=function(a,e,t){var n=1/0,i=0,s=Math.round,r=s(window.devicePixelRatio||1),o=80*r,c=48*r,l=3*r,u=2*r,h=3*r,f=15*r,d=74*r,p=30*r,m=document.createElement("canvas");m.width=o,m.height=c,m.style.cssText="width:80px;height:48px";var g=m.getContext("2d");return g.font="bold "+9*r+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=t,g.fillRect(0,0,o,c),g.fillStyle=e,g.fillText(a,l,u),g.fillRect(h,f,d,p),g.fillStyle=t,g.globalAlpha=.9,g.fillRect(h,f,d,p),{dom:m,update:function(x,y){n=Math.min(n,x),i=Math.max(i,x),g.fillStyle=t,g.globalAlpha=1,g.fillRect(0,0,o,f),g.fillStyle=e,g.fillText(s(x)+" "+a+" ("+s(n)+"-"+s(i)+")",l,u),g.drawImage(m,h+r,f,d-r,p,h,f,d-r,p),g.fillRect(h+d-r,f,r,p),g.fillStyle=t,g.globalAlpha=.9,g.fillRect(h+d-r,f,r,s((1-x/y)*p))}}};/*! fflate - fast JavaScript compression/decompression Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE version 0.6.9 -*/var Op={},Fu=function(a){return URL.createObjectURL(new Blob([a],{type:"text/javascript"}))},Bp=function(a){return new Worker(a)};try{URL.revokeObjectURL(Fu(""))}catch{Fu=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},Bp=function(e){return new Worker(e,{type:"module"})}}var tw=function(a,e,t,n,i){var s=Bp(Op[e]||(Op[e]=Fu(a)));return s.onerror=function(r){return i(r.error,null)},s.onmessage=function(r){return i(null,r.data)},s.postMessage(t,n),s},ot=Uint8Array,$t=Uint16Array,Mi=Uint32Array,kr=new ot([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Or=new ot([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),No=new ot([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),zp=function(a,e){for(var t=new $t(31),n=0;n<31;++n)t[n]=e+=1<>>1|(bt&21845)<<1;Ji=(Ji&52428)>>>2|(Ji&13107)<<2,Ji=(Ji&61680)>>>4|(Ji&3855)<<4,ko[bt]=((Ji&65280)>>>8|(Ji&255)<<8)>>>1}for(var Dn=function(a,e,t){for(var n=a.length,i=0,s=new $t(e);i>>c]=l}else for(o=new $t(n),i=0;i>>15-a[i]);return o},Si=new ot(288),bt=0;bt<144;++bt)Si[bt]=8;for(var bt=144;bt<256;++bt)Si[bt]=9;for(var bt=256;bt<280;++bt)Si[bt]=7;for(var bt=280;bt<288;++bt)Si[bt]=8;for(var Br=new ot(32),bt=0;bt<32;++bt)Br[bt]=5;var Hp=Dn(Si,9,0),Wp=Dn(Si,9,1),qp=Dn(Br,5,0),Xp=Dn(Br,5,1),fc=function(a){for(var e=a[0],t=1;te&&(e=a[t]);return e},Fn=function(a,e,t){var n=e/8|0;return(a[n]|a[n+1]<<8)>>(e&7)&t},dc=function(a,e){var t=e/8|0;return(a[t]|a[t+1]<<8|a[t+2]<<16)>>(e&7)},Oo=function(a){return(a/8|0)+(a&7&&1)},Nn=function(a,e,t){(e==null||e<0)&&(e=0),(t==null||t>a.length)&&(t=a.length);var n=new(a instanceof $t?$t:a instanceof Mi?Mi:ot)(t-e);return n.set(a.subarray(e,t)),n},Bo=function(a,e,t){var n=a.length;if(!n||t&&!t.l&&n<5)return e||new ot(0);var i=!e||t,s=!t||t.i;t||(t={}),e||(e=new ot(n*3));var r=function(V){var me=e.length;if(V>me){var _e=new ot(Math.max(me*2,V));_e.set(e),e=_e}},o=t.f||0,c=t.p||0,l=t.b||0,u=t.l,h=t.d,f=t.m,d=t.n,p=n*8;do{if(!u){t.f=o=Fn(a,c,1);var m=Fn(a,c+1,3);if(c+=3,m)if(m==1)u=Wp,h=Xp,f=9,d=5;else if(m==2){var b=Fn(a,c,31)+257,v=Fn(a,c+10,15)+4,S=b+Fn(a,c+5,31)+1;c+=14;for(var A=new ot(S),R=new ot(19),_=0;_>>4;if(g<16)A[_++]=g;else{var K=0,z=0;for(g==16?(z=3+Fn(a,c,3),c+=2,K=A[_-1]):g==17?(z=3+Fn(a,c,7),c+=3):g==18&&(z=11+Fn(a,c,127),c+=7);z--;)A[_++]=K}}var q=A.subarray(0,b),O=A.subarray(b);f=fc(q),d=fc(O),u=Dn(q,f,1),h=Dn(O,d,1)}else throw"invalid block type";else{var g=Oo(c)+4,x=a[g-4]|a[g-3]<<8,y=g+x;if(y>n){if(s)throw"unexpected EOF";break}i&&r(l+x),e.set(a.subarray(g,y),l),t.b=l+=x,t.p=c=y*8;continue}if(c>p){if(s)throw"unexpected EOF";break}}i&&r(l+131072);for(var Y=(1<>>4;if(c+=K&15,c>p){if(s)throw"unexpected EOF";break}if(!K)throw"invalid length/literal";if(X<256)e[l++]=X;else if(X==256){H=c,u=null;break}else{var te=X-254;if(X>264){var _=X-257,J=kr[_];te=Fn(a,c,(1<>>4;if(!ne)throw"invalid distance";c+=ne&15;var O=Vp[re];if(re>3){var J=Or[re];O+=dc(a,c)&(1<p){if(s)throw"unexpected EOF";break}i&&r(l+131072);for(var se=l+te;l>>8},zr=function(a,e,t){t<<=e&7;var n=e/8|0;a[n]|=t,a[n+1]|=t>>>8,a[n+2]|=t>>>16},pc=function(a,e){for(var t=[],n=0;nf&&(f=s[n].s);var d=new $t(f+1),p=mc(t[u-1],d,0);if(p>e){var n=0,m=0,g=p-e,x=1<e)m+=x-(1<>>=g;m>0;){var b=s[n].s;d[b]=0&&m;--n){var v=s[n].s;d[v]==e&&(--d[v],++m)}p=e}return[new ot(d),p]},mc=function(a,e,t){return a.s==-1?Math.max(mc(a.l,e,t+1),mc(a.r,e,t+1)):e[a.s]=t},Ou=function(a){for(var e=a.length;e&&!a[--e];);for(var t=new $t(++e),n=0,i=a[0],s=1,r=function(c){t[n++]=c},o=1;o<=e;++o)if(a[o]==i&&o!=e)++s;else{if(!i&&s>2){for(;s>138;s-=138)r(32754);s>2&&(r(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(r(i),--s;s>6;s-=6)r(8304);s>2&&(r(s-3<<5|8208),s=0)}for(;s--;)r(i);s=1,i=a[o]}return[t.subarray(0,n),e]},Ur=function(a,e){for(var t=0,n=0;n>>8,a[i+2]=a[i]^255,a[i+3]=a[i+1]^255;for(var s=0;s4&&!N[No[W-1]];--W);var K=l+5<<3,z=Ur(i,Si)+Ur(s,Br)+r,q=Ur(i,f)+Ur(s,m)+r+14+3*W+Ur(R,N)+(2*R[16]+3*R[17]+7*R[18]);if(K<=z&&K<=q)return zo(e,u,a.subarray(c,c+l));var O,Y,j,H;if(ti(e,u,1+(q15&&(ti(e,u,ne[_]>>>5&127),u+=ne[_]>>>12)}}else O=Hp,Y=Si,j=qp,H=Br;for(var _=0;_255){var re=n[_]>>>18&31;zr(e,u,O[re+257]),u+=Y[re+257],re>7&&(ti(e,u,n[_]>>>23&31),u+=kr[re]);var se=n[_]&31;zr(e,u,j[se]),u+=H[se],se>3&&(zr(e,u,n[_]>>>5&8191),u+=Or[se])}else zr(e,u,O[n[_]]),u+=Y[n[_]];return zr(e,u,O[256]),u+Y[256]},jp=new Mi([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ti=new ot(0),Yp=function(a,e,t,n,i,s){var r=a.length,o=new ot(n+r+5*(1+Math.ceil(r/7e3))+i),c=o.subarray(n,o.length-i),l=0;if(!e||r<8)for(var u=0;u<=r;u+=65535){var h=u+65535;h>>13,p=f&8191,m=(1<7e3||N>24576)&&O>423){l=Bu(a,c,0,S,A,R,L,N,W,u-W,l),N=_=L=0,W=u;for(var Y=0;Y<286;++Y)A[Y]=0;for(var Y=0;Y<30;++Y)R[Y]=0}var j=2,H=0,X=p,te=z-q&32767;if(O>2&&K==v(u-te))for(var J=Math.min(d,O)-1,ne=Math.min(32767,u),re=Math.min(258,O);te<=ne&&--X&&z!=q;){if(a[u+j]==a[u+j-te]){for(var se=0;sej){if(j=se,H=te,se>J)break;for(var V=Math.min(te,se-2),me=0,Y=0;Yme&&(me=ye,q=_e)}}}z=q,q=g[z],te+=z-q+32768&32767}if(H){S[N++]=268435456|hc[j]<<18|ku[H];var He=hc[j]&31,le=ku[H]&31;L+=kr[He]+Or[le],++A[257+He],++R[le],B=u+j,++_}else S[N++]=a[u],++A[a[u]]}}l=Bu(a,c,s,S,A,R,L,N,W,u-W,l),!s&&l&7&&(l=zo(c,l+1,Ti))}return Nn(o,0,n+Oo(l)+i)},Zp=function(){for(var a=new Mi(256),e=0;e<256;++e){for(var t=e,n=9;--n;)t=(t&1&&3988292384)^t>>>1;a[e]=t}return a}(),Gr=function(){var a=-1;return{p:function(e){for(var t=a,n=0;n>>8;a=t},d:function(){return~a}}},zu=function(){var a=1,e=0;return{p:function(t){for(var n=a,i=e,s=t.length,r=0;r!=s;){for(var o=Math.min(r+2655,s);r>16),i=(i&65535)+15*(i>>16)}a=n,e=i},d:function(){return a%=65521,e%=65521,(a&255)<<24|a>>>8<<16|(e&255)<<8|e>>>8}}},Gs=function(a,e,t,n,i){return Yp(a,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(a.length)))*1.5):12+e.mem,t,n,!i)},Uo=function(a,e){var t={};for(var n in a)t[n]=a[n];for(var n in e)t[n]=e[n];return t},Kp=function(a,e,t){for(var n=a(),i=a.toString(),s=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/ /g,"").split(","),r=0;r>>0},Gu=function(a,e){return Vt(a,e)+Vt(a,e+4)*4294967296},vt=function(a,e,t){for(;t;++e)a[e]=t,t>>>=8},Vu=function(a,e){var t=e.filename;if(a[0]=31,a[1]=139,a[2]=8,a[8]=e.level<2?4:e.level==9?2:0,a[9]=3,e.mtime!=0&&vt(a,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),t){a[3]=8;for(var n=0;n<=t.length;++n)a[n+10]=t.charCodeAt(n)}},Hu=function(a){if(a[0]!=31||a[1]!=139||a[2]!=8)throw"invalid gzip data";var e=a[3],t=10;e&4&&(t+=a[10]|(a[11]<<8)+2);for(var n=(e>>3&1)+(e>>4&1);n>0;n-=!a[t++]);return t+(e&2)},nm=function(a){var e=a.length;return(a[e-4]|a[e-3]<<8|a[e-2]<<16|a[e-1]<<24)>>>0},Wu=function(a){return 10+(a.filename&&a.filename.length+1||0)},qu=function(a,e){var t=e.level,n=t==0?0:t<6?1:t==9?3:2;a[0]=120,a[1]=n<<6|(n?32-2*n:1)},im=function(a){if((a[0]&15)!=8||a[0]>>>4>7||(a[0]<<8|a[1])%31)throw"invalid zlib data";if(a[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Xu(a,e){return!e&&typeof a=="function"&&(e=a,a={}),this.ondata=e,a}var ni=function(){function a(e,t){!t&&typeof e=="function"&&(t=e,e={}),this.ondata=t,this.o=e||{}}return a.prototype.p=function(e,t){this.ondata(Gs(e,this.o,0,0,!t),t)},a.prototype.push=function(e,t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=t,this.p(e,t||!1)},a}(),sm=function(){function a(e,t){qr([Hr,function(){return[kn,ni]}],this,Xu.call(this,e,t),function(n){var i=new ni(n.data);onmessage=kn(i)},6)}return a}();function rm(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Wr(a,e,[Hr],function(n){return $i(Go(n.data[0],n.data[1]))},0,t)}function Go(a,e){return Gs(a,e||{},0,0)}var mn=function(){function a(e){this.s={},this.p=new ot(0),this.ondata=e}return a.prototype.e=function(e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var t=this.p.length,n=new ot(t+e.length);n.set(this.p),n.set(e,t),this.p=n},a.prototype.c=function(e){this.d=this.s.i=e||!1;var t=this.s.b,n=Bo(this.p,this.o,this.s);this.ondata(Nn(n,t,this.s.b),this.d),this.o=Nn(n,this.s.b-32768),this.s.b=this.o.length,this.p=Nn(this.p,this.s.p/8|0),this.s.p&=7},a.prototype.push=function(e,t){this.e(e),this.c(t)},a}(),ju=function(){function a(e){this.ondata=e,qr([Vr,function(){return[kn,mn]}],this,0,function(){var t=new mn;onmessage=kn(t)},7)}return a}();function Yu(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Wr(a,e,[Vr],function(n){return $i(Xr(n.data[0],Uu(n.data[1])))},1,t)}function Xr(a,e){return Bo(a,e)}var yc=function(){function a(e,t){this.c=Gr(),this.l=0,this.v=1,ni.call(this,e,t)}return a.prototype.push=function(e,t){ni.prototype.push.call(this,e,t)},a.prototype.p=function(e,t){this.c.p(e),this.l+=e.length;var n=Gs(e,this.o,this.v&&Wu(this.o),t&&8,!t);this.v&&(Vu(n,this.o),this.v=0),t&&(vt(n,n.length-8,this.c.d()),vt(n,n.length-4,this.l)),this.ondata(n,t)},a}(),om=function(){function a(e,t){qr([Hr,$p,function(){return[kn,ni,yc]}],this,Xu.call(this,e,t),function(n){var i=new yc(n.data);onmessage=kn(i)},8)}return a}();function am(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Wr(a,e,[Hr,$p,function(){return[xc]}],function(n){return $i(xc(n.data[0],n.data[1]))},2,t)}function xc(a,e){e||(e={});var t=Gr(),n=a.length;t.p(a);var i=Gs(a,e,Wu(e),8),s=i.length;return Vu(i,e),vt(i,s-8,t.d()),vt(i,s-4,n),i}var vc=function(){function a(e){this.v=1,mn.call(this,e)}return a.prototype.push=function(e,t){if(mn.prototype.e.call(this,e),this.v){var n=this.p.length>3?Hu(this.p):4;if(n>=this.p.length&&!t)return;this.p=this.p.subarray(n),this.v=0}if(t){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}mn.prototype.c.call(this,t)},a}(),cm=function(){function a(e){this.ondata=e,qr([Vr,Qp,function(){return[kn,mn,vc]}],this,0,function(){var t=new vc;onmessage=kn(t)},9)}return a}();function lm(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Wr(a,e,[Vr,Qp,function(){return[_c]}],function(n){return $i(_c(n.data[0]))},3,t)}function _c(a,e){return Bo(a.subarray(Hu(a),-8),e||new ot(nm(a)))}var Zu=function(){function a(e,t){this.c=zu(),this.v=1,ni.call(this,e,t)}return a.prototype.push=function(e,t){ni.prototype.push.call(this,e,t)},a.prototype.p=function(e,t){this.c.p(e);var n=Gs(e,this.o,this.v&&2,t&&4,!t);this.v&&(qu(n,this.o),this.v=0),t&&vt(n,n.length-4,this.c.d()),this.ondata(n,t)},a}(),iw=function(){function a(e,t){qr([Hr,em,function(){return[kn,ni,Zu]}],this,Xu.call(this,e,t),function(n){var i=new Zu(n.data);onmessage=kn(i)},10)}return a}();function sw(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Wr(a,e,[Hr,em,function(){return[Ku]}],function(n){return $i(Ku(n.data[0],n.data[1]))},4,t)}function Ku(a,e){e||(e={});var t=zu();t.p(a);var n=Gs(a,e,2,4);return qu(n,e),vt(n,n.length-4,t.d()),n}var bc=function(){function a(e){this.v=1,mn.call(this,e)}return a.prototype.push=function(e,t){if(mn.prototype.e.call(this,e),this.v){if(this.p.length<2&&!t)return;this.p=this.p.subarray(2),this.v=0}if(t){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}mn.prototype.c.call(this,t)},a}(),um=function(){function a(e){this.ondata=e,qr([Vr,tm,function(){return[kn,mn,bc]}],this,0,function(){var t=new bc;onmessage=kn(t)},11)}return a}();function hm(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Wr(a,e,[Vr,tm,function(){return[Vo]}],function(n){return $i(Vo(n.data[0],Uu(n.data[1])))},5,t)}function Vo(a,e){return Bo((im(a),a.subarray(2,-4)),e)}var fm=function(){function a(e){this.G=vc,this.I=mn,this.Z=bc,this.ondata=e}return a.prototype.push=function(e,t){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var n=new ot(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length)}else this.p=e;if(this.p.length>2){var i=this,s=function(){i.ondata.apply(i,arguments)};this.s=this.p[0]==31&&this.p[1]==139&&this.p[2]==8?new this.G(s):(this.p[0]&15)!=8||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(s):new this.Z(s),this.s.push(this.p,t),this.p=null}}},a}(),rw=function(){function a(e){this.G=cm,this.I=ju,this.Z=um,this.ondata=e}return a.prototype.push=function(e,t){fm.prototype.push.call(this,e,t)},a}();function ow(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return a[0]==31&&a[1]==139&&a[2]==8?lm(a,e,t):(a[0]&15)!=8||a[0]>>4>7||(a[0]<<8|a[1])%31?Yu(a,e,t):hm(a,e,t)}function aw(a,e){return a[0]==31&&a[1]==139&&a[2]==8?_c(a,e):(a[0]&15)!=8||a[0]>>4>7||(a[0]<<8|a[1])%31?Xr(a,e):Vo(a,e)}var Ju=function(a,e,t,n){for(var i in a){var s=a[i],r=e+i;s instanceof ot?t[r]=[s,n]:Array.isArray(s)?t[r]=[s[0],Uo(n,s[1])]:Ju(s,r+"/",t,n)}},dm=typeof TextEncoder!="undefined"&&new TextEncoder,$u=typeof TextDecoder!="undefined"&&new TextDecoder,pm=0;try{$u.decode(Ti,{stream:!0}),pm=1}catch{}var mm=function(a){for(var e="",t=0;;){var n=a[t++],i=(n>127)+(n>223)+(n>239);if(t+i>a.length)return[e,Nn(a,t-1)];i?i==3?(n=((n&15)<<18|(a[t++]&63)<<12|(a[t++]&63)<<6|a[t++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):i&1?e+=String.fromCharCode((n&31)<<6|a[t++]&63):e+=String.fromCharCode((n&15)<<12|(a[t++]&63)<<6|a[t++]&63):e+=String.fromCharCode(n)}},cw=function(){function a(e){this.ondata=e,pm?this.t=new TextDecoder:this.p=Ti}return a.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(t=!!t,this.t){if(this.ondata(this.t.decode(e,{stream:!0}),t),t){if(this.t.decode().length)throw"invalid utf-8 data";this.t=null}return}if(!this.p)throw"stream finished";var n=new ot(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length);var i=mm(n),s=i[0],r=i[1];if(t){if(r.length)throw"invalid utf-8 data";this.p=null}else this.p=r;this.ondata(s,t)},a}(),lw=function(){function a(e){this.ondata=e}return a.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(this.d)throw"stream finished";this.ondata(Qi(e),this.d=t||!1)},a}();function Qi(a,e){if(e){for(var t=new ot(a.length),n=0;n>1)),r=0,o=function(u){s[r++]=u},n=0;ns.length){var c=new ot(r+8+(i-n<<1));c.set(s),s=c}var l=a.charCodeAt(n);l<128||e?o(l):l<2048?(o(192|l>>6),o(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|a.charCodeAt(++n)&1023,o(240|l>>18),o(128|l>>12&63),o(128|l>>6&63),o(128|l&63)):(o(224|l>>12),o(128|l>>6&63),o(128|l&63))}return Nn(s,0,r)}function Qu(a,e){if(e){for(var t="",n=0;n65535)throw"extra field too long";e+=n+4}return e},jr=function(a,e,t,n,i,s,r,o){var c=n.length,l=t.extra,u=o&&o.length,h=es(l);vt(a,e,r!=null?33639248:67324752),e+=4,r!=null&&(a[e++]=20,a[e++]=t.os),a[e]=20,e+=2,a[e++]=t.flag<<1|(s==null&&8),a[e++]=i&&8,a[e++]=t.compression&255,a[e++]=t.compression>>8;var f=new Date(t.mtime==null?Date.now():t.mtime),d=f.getFullYear()-1980;if(d<0||d>119)throw"date not in range 1980-2099";if(vt(a,e,d<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>>1),e+=4,s!=null&&(vt(a,e,t.crc),vt(a,e+4,s),vt(a,e+8,t.size)),vt(a,e+12,c),vt(a,e+14,h),e+=16,r!=null&&(vt(a,e,u),vt(a,e+6,t.attrs),vt(a,e+10,r),e+=14),a.set(n,e),e+=c,h)for(var p in l){var m=l[p],g=m.length;vt(a,e,+p),vt(a,e+2,g),a.set(m,e+4),e+=4+g}return u&&(a.set(o,e),e+=u),e},eh=function(a,e,t,n,i){vt(a,e,101010256),vt(a,e+8,t),vt(a,e+10,t),vt(a,e+12,n),vt(a,e+16,i)},Ho=function(){function a(e){this.filename=e,this.c=Gr(),this.size=0,this.compression=0}return a.prototype.process=function(e,t){this.ondata(null,e,t)},a.prototype.push=function(e,t){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},a}(),uw=function(){function a(e,t){var n=this;t||(t={}),Ho.call(this,e),this.d=new ni(t,function(i,s){n.ondata(null,i,s)}),this.compression=8,this.flag=gm(t.level)}return a.prototype.process=function(e,t){try{this.d.push(e,t)}catch(n){this.ondata(n,null,t)}},a.prototype.push=function(e,t){Ho.prototype.push.call(this,e,t)},a}(),hw=function(){function a(e,t){var n=this;t||(t={}),Ho.call(this,e),this.d=new sm(t,function(i,s,r){n.ondata(i,s,r)}),this.compression=8,this.flag=gm(t.level),this.terminate=this.d.terminate}return a.prototype.process=function(e,t){this.d.push(e,t)},a.prototype.push=function(e,t){Ho.prototype.push.call(this,e,t)},a}(),fw=function(){function a(e){this.ondata=e,this.u=[],this.d=1}return a.prototype.add=function(e){var t=this;if(this.d&2)throw"stream finished";var n=Qi(e.filename),i=n.length,s=e.comment,r=s&&Qi(s),o=i!=e.filename.length||r&&s.length!=r.length,c=i+es(e.extra)+30;if(i>65535)throw"filename too long";var l=new ot(c);jr(l,0,e,n,o);var u=[l],h=function(){for(var g=0,x=u;g65535&&K("filename too long",null),!W)K(null,y);else if(S<16e4)try{K(null,Go(y,b))}catch(z){K(z,null)}else u.push(rm(y,b,K))},p=0;p65535)throw"filename too long";var x=u?Go(c,l):c,y=x.length,b=Gr();b.p(c),n.push(Uo(l,{size:c.length,crc:b.d(),c:x,f:h,m:p,u:f!=r.length||p&&d.length!=m,o:i,compression:u})),i+=30+f+g+y,s+=76+2*(f+g)+(m||0)+y}for(var v=new ot(s+22),S=i,A=s-i,R=0;R0){var i=Math.min(this.c,e.length),s=e.subarray(0,i);if(this.c-=i,this.d?this.d.push(s,!this.c):this.k[0].push(s),e=e.subarray(i),e.length)return this.push(e,t)}else{var r=0,o=0,c=void 0,l=void 0;this.p.length?e.length?(l=new ot(this.p.length+e.length),l.set(this.p),l.set(e,this.p.length)):l=this.p:l=e;for(var u=l.length,h=this.c,f=h&&this.d,d=function(){var x,y=Vt(l,o);if(y==67324752){r=1,c=o,p.d=null,p.c=0;var b=fn(l,o+6),v=fn(l,o+8),S=b&2048,A=b&8,R=fn(l,o+26),_=fn(l,o+28);if(u>o+30+R+_){var L=[];p.k.unshift(L),r=2;var N=Vt(l,o+18),B=Vt(l,o+22),W=Qu(l.subarray(o+30,o+=30+R),!S);N==4294967295?(x=A?[-2]:vm(l,o),N=x[0],B=x[1]):A&&(N=-1),o+=_,p.c=N;var K,z={name:W,compression:v,start:function(){if(!z.ondata)throw"no callback";if(!N)z.ondata(null,Ti,!0);else{var q=n.o[v];if(!q)throw"unknown compression type "+v;K=N<0?new q(W):new q(W,N,B),K.ondata=function(H,X,te){z.ondata(H,X,te)};for(var O=0,Y=L;O=0&&(z.size=N,z.originalSize=B),p.onfile(z)}return"break"}else if(h){if(y==134695760)return c=o+=12+(h==-2&&8),r=3,p.c=0,"break";if(y==33639248)return c=o-=4,r=3,p.c=0,"break"}},p=this;o65558){e("invalid zip file",null);return}var r=fn(a,s+8);r||e(null,{});var o=r,c=Vt(a,s+16),l=c==4294967295;if(l){if(s=Vt(a,s-12),Vt(a,s)!=101075792){e("invalid zip file",null);return}o=r=Vt(a,s+32),c=Vt(a,s+48)}for(var u=function(f){var d=xm(a,c,l),p=d[0],m=d[1],g=d[2],x=d[3],y=d[4],b=d[5],v=ym(a,b);c=y;var S=function(R,_){R?(n(),e(R,null)):(i[x]=_,--r||e(null,i))};if(!p)S(null,Nn(a,v,v+m));else if(p==8){var A=a.subarray(v,v+m);if(m<32e4)try{S(null,Xr(A,new ot(g)))}catch(R){S(R,null)}else t.push(Yu(A,{size:g},S))}else S("unknown compression type "+p,null)},h=0;h65558)throw"invalid zip file";var n=fn(a,t+8);if(!n)return{};var i=Vt(a,t+16),s=i==4294967295;if(s){if(t=Vt(a,t-12),Vt(a,t)!=101075792)throw"invalid zip file";n=Vt(a,t+32),i=Vt(a,t+48)}for(var r=0;r=t[n])return n-1;if(e<=t[a])return a;let i=a,s=n,r=Math.floor((i+s)/2);for(;e=t[r+1];)e=m&&(p[d][0]=p[f][0]/o[y+1][x],g=p[d][0]*o[x][y]);const b=x>=-1?1:-x,v=h-1<=y?m-1:t-h;for(let A=b;A<=v;++A)p[d][A]=(p[f][A]-p[f][A-1])/o[y+1][x+A],g+=p[d][A]*o[x+A][y];h<=y&&(p[d][m]=-p[f][m-1]/o[y+1][h],g+=p[d][m]*o[h][y]),r[m][h]=g;const S=f;f=d,d=S}}let u=t;for(let h=1;h<=n;++h){for(let f=0;f<=t;++f)r[h][f]*=u;u*=t-h}return r}function Sw(a,e,t,n,i){const s=i0,c=typeof s.Content=="string"&&s.Content!=="";if(o||c){const l=this.parseImage(n[i]);t[s.RelativeFilename||s.Filename]=l}}}}for(const n in e){const i=e[n];t[i]!==void 0?e[n]=t[i]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase();let s;switch(i){case"bmp":s="image/bmp";break;case"jpg":case"jpeg":s="image/jpeg";break;case"png":s="image/png";break;case"tif":s="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),s="image/tga";break;default:console.warn('FBXLoader: Image type "'+i+'" is not supported.');return}if(typeof t=="string")return"data:"+s+";base64,"+t;{const r=new Uint8Array(t);return window.URL.createObjectURL(new Blob([r],{type:s}))}}parseTextures(e){const t=new Map;if("Texture"in st.Objects){const n=st.Objects.Texture;for(const i in n){const s=this.parseTexture(n[i],e);t.set(parseInt(i),s)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const i=e.WrapModeU,s=e.WrapModeV,r=i!==void 0?i.value:0,o=s!==void 0?s.value:0;if(n.wrapS=r===0?on:Wt,n.wrapT=o===0?on:Wt,"Scaling"in e){const c=e.Scaling.value;n.repeat.x=c[0],n.repeat.y=c[1]}if("Translation"in e){const c=e.Translation.value;n.offset.x=c[0],n.offset.y=c[1]}return n}loadTexture(e,t){let n;const i=this.textureLoader.path,s=Ht.get(e.id).children;s!==void 0&&s.length>0&&t[s[0].ID]!==void 0&&(n=t[s[0].ID],(n.indexOf("blob:")===0||n.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let r;const o=e.FileName.slice(-3).toLowerCase();if(o==="tga"){const c=this.manager.getHandler(".tga");c===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),r=new Mt):(c.setPath(this.textureLoader.path),r=c.load(n))}else o==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),r=new Mt):r=this.textureLoader.load(n);return this.textureLoader.setPath(i),r}parseMaterials(e){const t=new Map;if("Material"in st.Objects){const n=st.Objects.Material;for(const i in n){const s=this.parseMaterial(n[i],e);s!==null&&t.set(parseInt(i),s)}}return t}parseMaterial(e,t){const n=e.id,i=e.attrName;let s=e.ShadingModel;if(typeof s=="object"&&(s=s.value),!Ht.has(n))return null;const r=this.parseParameters(e,t,n);let o;switch(s.toLowerCase()){case"phong":o=new Qn;break;case"lambert":o=new tc;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),o=new Qn;break}return o.setValues(r),o.name=i,o}parseParameters(e,t,n){const i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=new ve().fromArray(e.Diffuse.value):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(i.color=new ve().fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=new ve().fromArray(e.Emissive.value):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(i.emissive=new ve().fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(i.opacity=parseFloat(e.Opacity.value)),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=new ve().fromArray(e.Specular.value):e.SpecularColor&&e.SpecularColor.type==="Color"&&(i.specular=new ve().fromArray(e.SpecularColor.value));const s=this;return Ht.get(n).children.forEach(function(r){const o=r.relationship;switch(o){case"Bump":i.bumpMap=s.getTexture(t,r.ID);break;case"Maya|TEX_ao_map":i.aoMap=s.getTexture(t,r.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=s.getTexture(t,r.ID),i.map!==void 0&&(i.map.encoding=tt);break;case"DisplacementColor":i.displacementMap=s.getTexture(t,r.ID);break;case"EmissiveColor":i.emissiveMap=s.getTexture(t,r.ID),i.emissiveMap!==void 0&&(i.emissiveMap.encoding=tt);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=s.getTexture(t,r.ID);break;case"ReflectionColor":i.envMap=s.getTexture(t,r.ID),i.envMap!==void 0&&(i.envMap.mapping=qs,i.envMap.encoding=tt);break;case"SpecularColor":i.specularMap=s.getTexture(t,r.ID),i.specularMap!==void 0&&(i.specularMap.encoding=tt);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=s.getTexture(t,r.ID),i.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",o);break}}),i}getTexture(e,t){return"LayeredTexture"in st.Objects&&t in st.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=Ht.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in st.Objects){const n=st.Objects.Deformer;for(const i in n){const s=n[i],r=Ht.get(parseInt(i));if(s.attrType==="Skin"){const o=this.parseSkeleton(r,n);o.ID=i,r.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),o.geometryID=r.parents[0].ID,e[i]=o}else if(s.attrType==="BlendShape"){const o={id:i};o.rawTargets=this.parseMorphTargets(r,n),o.id=i,r.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=o}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(i){const s=t[i.ID];if(s.attrType!=="Cluster")return;const r={ID:i.ID,indices:[],weights:[],transformLink:new Ie().fromArray(s.TransformLink.a)};"Indexes"in s&&(r.indices=s.Indexes.a,r.weights=s.Weights.a),n.push(r)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let i=0;i1?r=o:o.length>0?r=o[0]:(r=new Qn({color:13421772}),o.push(r)),"color"in s.attributes&&o.forEach(function(c){c.vertexColors=!0}),s.FBX_Deformer?(i=new wo(s,r),i.normalizeSkinWeights()):i=new St(s,r),i}createCurve(e,t){const n=e.children.reduce(function(s,r){return t.has(r.ID)&&(s=t.get(r.ID)),s},null),i=new zt({color:3342591,linewidth:1});return new Hn(n,i)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=Em(t.RotationOrder.value):n.eulerOrder="ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&Ht.get(e.ID).children.forEach(function(i){if(i.relationship==="LookAtProperty"){const s=st.Objects.Model[i.ID];if("Lcl_Translation"in s){const r=s.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(r),gn.add(e.target)):e.lookAt(new D().fromArray(r))}}})}bindSkeleton(e,t,n){const i=this.parsePoseNodes();for(const s in e){const r=e[s];Ht.get(parseInt(r.ID)).parents.forEach(function(c){if(t.has(c.ID)){const l=c.ID;Ht.get(l).parents.forEach(function(h){n.has(h.ID)&&n.get(h.ID).bind(new Ms(r.bones),i[h.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in st.Objects){const t=st.Objects.Pose;for(const n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){const i=t[n].PoseNode;Array.isArray(i)?i.forEach(function(s){e[s.Node]=new Ie().fromArray(s.Matrix.a)}):e[i.Node]=new Ie().fromArray(i.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in st&&"AmbientColor"in st.GlobalSettings){const e=st.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(t!==0||n!==0||i!==0){const s=new ve(t,n,i);gn.add(new Do(s,1))}}}}class Rw{parse(e){const t=new Map;if("Geometry"in st.Objects){const n=st.Objects.Geometry;for(const i in n){const s=Ht.get(parseInt(i)),r=this.parseGeometry(s,n[i],e);t.set(parseInt(i),r)}}return t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const i=n.skeletons,s=[],r=e.parents.map(function(h){return st.Objects.Model[h.ID]});if(r.length===0)return;const o=e.children.reduce(function(h,f){return i[f.ID]!==void 0&&(h=i[f.ID]),h},null);e.children.forEach(function(h){n.morphTargets[h.ID]!==void 0&&s.push(n.morphTargets[h.ID])});const c=r[0],l={};"RotationOrder"in c&&(l.eulerOrder=Em(c.RotationOrder.value)),"InheritType"in c&&(l.inheritType=parseInt(c.InheritType.value)),"GeometricTranslation"in c&&(l.translation=c.GeometricTranslation.value),"GeometricRotation"in c&&(l.rotation=c.GeometricRotation.value),"GeometricScaling"in c&&(l.scale=c.GeometricScaling.value);const u=Am(l);return this.genGeometry(t,o,s,u)}genGeometry(e,t,n,i){const s=new qe;e.attrName&&(s.name=e.attrName);const r=this.parseGeoNode(e,t),o=this.genBuffers(r),c=new we(o.vertex,3);if(c.applyMatrix4(i),s.setAttribute("position",c),o.colors.length>0&&s.setAttribute("color",new we(o.colors,3)),t&&(s.setAttribute("skinIndex",new va(o.weightsIndices,4)),s.setAttribute("skinWeight",new we(o.vertexWeights,4)),s.FBX_Deformer=t),o.normal.length>0){const l=new an().getNormalMatrix(i),u=new we(o.normal,3);u.applyNormalMatrix(l),s.setAttribute("normal",u)}if(o.uvs.forEach(function(l,u){let h="uv"+(u+1).toString();u===0&&(h="uv"),s.setAttribute(h,new we(o.uvs[u],2))}),r.material&&r.material.mappingType!=="AllSame"){let l=o.materialIndex[0],u=0;if(o.materialIndex.forEach(function(h,f){h!==l&&(s.addGroup(u,f-u,l),l=h,u=f)}),s.groups.length>0){const h=s.groups[s.groups.length-1],f=h.start+h.count;f!==o.materialIndex.length&&s.addGroup(f,o.materialIndex.length-f,l)}s.groups.length===0&&s.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(s,e,n,i),s}parseGeoNode(e,t){const n={};if(n.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],n.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let i=0;for(;e.LayerElementUV[i];)e.LayerElementUV[i].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[i])),i++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(i,s){i.indices.forEach(function(r,o){n.weightTable[r]===void 0&&(n.weightTable[r]=[]),n.weightTable[r].push({id:s,weight:i.weights[o]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,i=0,s=!1,r=[],o=[],c=[],l=[],u=[],h=[];const f=this;return e.vertexIndices.forEach(function(d,p){let m,g=!1;d<0&&(d=d^-1,g=!0);let x=[],y=[];if(r.push(d*3,d*3+1,d*3+2),e.color){const b=wc(p,n,d,e.color);c.push(b[0],b[1],b[2])}if(e.skeleton){if(e.weightTable[d]!==void 0&&e.weightTable[d].forEach(function(b){y.push(b.weight),x.push(b.id)}),y.length>4){s||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),s=!0);const b=[0,0,0,0],v=[0,0,0,0];y.forEach(function(S,A){let R=S,_=x[A];v.forEach(function(L,N,B){if(R>L){B[N]=R,R=L;const W=b[N];b[N]=_,_=W}})}),x=b,y=v}for(;y.length<4;)y.push(0),x.push(0);for(let b=0;b<4;++b)u.push(y[b]),h.push(x[b])}if(e.normal){const b=wc(p,n,d,e.normal);o.push(b[0],b[1],b[2])}e.material&&e.material.mappingType!=="AllSame"&&(m=wc(p,n,d,e.material)[0]),e.uv&&e.uv.forEach(function(b,v){const S=wc(p,n,d,b);l[v]===void 0&&(l[v]=[]),l[v].push(S[0]),l[v].push(S[1])}),i++,g&&(f.genFace(t,e,r,m,o,c,l,u,h,i),n++,i=0,r=[],o=[],c=[],l=[],u=[],h=[])}),t}genFace(e,t,n,i,s,r,o,c,l,u){for(let h=2;h1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const r=e.get(s[0].ID);n[i]={name:t[i].attrName,layer:r}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach(function(i){t=t.concat(n.generateTracks(i))}),new _i(e.name,-1,t)}generateTracks(e){const t=[];let n=new D,i=new Pt,s=new D;if(e.transform&&e.transform.decompose(n,i,s),n=n.toArray(),i=new Cn().setFromQuaternion(i,e.eulerOrder).toArray(),s=s.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const r=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");r!==void 0&&t.push(r)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const r=this.generateRotationTrack(e.modelName,e.R.curves,i,e.preRotation,e.postRotation,e.eulerOrder);r!==void 0&&t.push(r)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const r=this.generateVectorTrack(e.modelName,e.S.curves,s,"scale");r!==void 0&&t.push(r)}if(e.DeformPercent!==void 0){const r=this.generateMorphTrack(e);r!==void 0&&t.push(r)}return t}generateVectorTrack(e,t,n,i){const s=this.getTimesForAllAxes(t),r=this.getKeyframeTrackValues(s,t,n);return new vi(e+"."+i,s,r)}generateRotationTrack(e,t,n,i,s,r){t.x!==void 0&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(en.degToRad)),t.y!==void 0&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(en.degToRad)),t.z!==void 0&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(en.degToRad));const o=this.getTimesForAllAxes(t),c=this.getKeyframeTrackValues(o,t,n);i!==void 0&&(i=i.map(en.degToRad),i.push(r),i=new Cn().fromArray(i),i=new Pt().setFromEuler(i)),s!==void 0&&(s=s.map(en.degToRad),s.push(r),s=new Cn().fromArray(s),s=new Pt().setFromEuler(s).invert());const l=new Pt,u=new Cn,h=[];for(let f=0;f1){let n=1,i=t[0];for(let s=1;s=180){const r=s/180,o=i/r;let c=n+o;const l=e.times[t-1],h=(e.times[t]-l)/r;let f=l+h;const d=[],p=[];for(;f1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}}parseNodeProperty(e,t,n){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),s=t[2].replace(/^"/,"").replace(/"$/,"").trim();i==="Content"&&s===","&&(s=n.replace(/"/g,"").replace(/,$/,"").trim());const r=this.getCurrentNode();if(r.name==="Properties70"){this.parseNodeSpecialProperty(e,i,s);return}if(i==="C"){const c=s.split(",").slice(1),l=parseInt(c[0]),u=parseInt(c[1]);let h=s.split(",").slice(3);h=h.map(function(f){return f.trim().replace(/^"/,"")}),i="connections",s=[l,u],Bw(s,h),r[i]===void 0&&(r[i]=[])}i==="Node"&&(r.id=s),i in r&&Array.isArray(r[i])?r[i].push(s):i!=="a"?r[i]=s:r.a=s,this.setCurrentProp(r,i),i==="a"&&s.slice(-1)!==","&&(r.a=nh(s))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=nh(t.a))}parseNodeSpecialProperty(e,t,n){const i=n.split('",').map(function(u){return u.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=i[0],r=i[1],o=i[2],c=i[3];let l=i[4];switch(r){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=nh(l);break}this.getPrevNode()[s]={type:r,type2:o,flag:c,value:l},this.setCurrentProp(this.getPrevNode(),s)}}class Dw{parse(e){const t=new Mm(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const i=new Sm;for(;!this.endOfContent(t);){const s=this.parseNode(t,n);s!==null&&i.add(s.name,s)}return i}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},i=t>=7500?e.getUint64():e.getUint32(),s=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const r=e.getUint8(),o=e.getString(r);if(i===0)return null;const c=[];for(let f=0;f0?c[0]:"",u=c.length>1?c[1]:"",h=c.length>2?c[2]:"";for(n.singleProperty=s===1&&e.getOffset()===i;i>e.getOffset();){const f=this.parseNode(e,t);f!==null&&this.parseSubNode(o,n,f)}return n.propertyList=c,typeof l=="number"&&(n.id=l),u!==""&&(n.attrName=u),h!==""&&(n.attrType=h),o!==""&&(n.name=o),n}parseSubNode(e,t,n){if(n.singleProperty===!0){const i=n.propertyList[0];Array.isArray(i)?(t[n.name]=n,n.a=i):t[n.name]=i}else if(e==="Connections"&&n.name==="C"){const i=[];n.propertyList.forEach(function(s,r){r!==0&&i.push(s)}),t.connections===void 0&&(t.connections=[]),t.connections.push(i)}else if(n.name==="Properties70")Object.keys(n).forEach(function(s){t[s]=n[s]});else if(e==="Properties70"&&n.name==="P"){let i=n.propertyList[0],s=n.propertyList[1];const r=n.propertyList[2],o=n.propertyList[3];let c;i.indexOf("Lcl ")===0&&(i=i.replace("Lcl ","Lcl_")),s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),s==="Color"||s==="ColorRGB"||s==="Vector"||s==="Vector3D"||s.indexOf("Lcl_")===0?c=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:c=n.propertyList[4],t[i]={type:s,type2:r,flag:o,value:c}}else t[n.name]===void 0?typeof n.id=="number"?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name==="PoseNode"?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const i=e.getUint32(),s=e.getUint32(),r=e.getUint32();if(s===0)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}typeof _w=="undefined"&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const o=Vo(new Uint8Array(e.getArrayBuffer(r))),c=new Mm(o.buffer);switch(t){case"b":case"c":return c.getBooleanArray(i);case"d":return c.getFloat64Array(i);case"f":return c.getFloat32Array(i);case"i":return c.getInt32Array(i);case"l":return c.getInt64Array(i)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class Mm{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let n=0;n=0&&(t=t.slice(0,n)),tn.decodeText(new Uint8Array(t))}}class Sm{add(e,t){this[e]=t}}function Fw(a){const e="Kaydara FBX Binary \0";return a.byteLength>=e.length&&e===Cm(a,0,e.length)}function Nw(a){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function n(i){const s=a[i-1];return a=a.slice(t+i),t++,s}for(let i=0;i256||O.colormap_size!==24||O.colormap_type!==1)&&console.error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case d:case p:case g:case x:O.colormap_type&&console.error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case h:console.error("THREE.TGALoader: No data.");default:console.error('THREE.TGALoader: Invalid type "%s".',O.image_type)}(O.width<=0||O.height<=0)&&console.error("THREE.TGALoader: Invalid image size."),O.pixel_size!==8&&O.pixel_size!==16&&O.pixel_size!==24&&O.pixel_size!==32&&console.error('THREE.TGALoader: Invalid pixel size "%s".',O.pixel_size)}function n(O,Y,j,H,X){let te,J;const ne=j.pixel_size>>3,re=j.width*j.height*ne;if(Y&&(J=X.subarray(H,H+=j.colormap_length*(j.colormap_size>>3))),O){te=new Uint8Array(re);let se,V,me,_e=0;const Pe=new Uint8Array(ne);for(;_e>7,O[(V+_e*me)*4+1]=(re&992)>>2,O[(V+_e*me)*4+2]=(re&31)<<3,O[(V+_e*me)*4+3]=re&32768?0:255;return O}function r(O,Y,j,H,X,te,J,ne){let re=0,se,V;const me=N.width;for(V=Y;V!==H;V+=j)for(se=X;se!==J;se+=te,re+=3)O[(se+me*V)*4+3]=255,O[(se+me*V)*4+2]=ne[re+0],O[(se+me*V)*4+1]=ne[re+1],O[(se+me*V)*4+0]=ne[re+2];return O}function o(O,Y,j,H,X,te,J,ne){let re=0,se,V;const me=N.width;for(V=Y;V!==H;V+=j)for(se=X;se!==J;se+=te,re+=4)O[(se+me*V)*4+2]=ne[re+0],O[(se+me*V)*4+1]=ne[re+1],O[(se+me*V)*4+0]=ne[re+2],O[(se+me*V)*4+3]=ne[re+3];return O}function c(O,Y,j,H,X,te,J,ne){let re,se=0,V,me;const _e=N.width;for(me=Y;me!==H;me+=j)for(V=X;V!==J;V+=te,se++)re=ne[se],O[(V+_e*me)*4+0]=re,O[(V+_e*me)*4+1]=re,O[(V+_e*me)*4+2]=re,O[(V+_e*me)*4+3]=255;return O}function l(O,Y,j,H,X,te,J,ne){let re=0,se,V;const me=N.width;for(V=Y;V!==H;V+=j)for(se=X;se!==J;se+=te,re+=2)O[(se+me*V)*4+0]=ne[re+0],O[(se+me*V)*4+1]=ne[re+0],O[(se+me*V)*4+2]=ne[re+0],O[(se+me*V)*4+3]=ne[re+1];return O}function u(O,Y,j,H,X){let te,J,ne,re,se,V;switch((N.flags&y)>>b){default:case A:te=0,ne=1,se=Y,J=0,re=1,V=j;break;case v:te=0,ne=1,se=Y,J=j-1,re=-1,V=-1;break;case R:te=Y-1,ne=-1,se=-1,J=0,re=1,V=j;break;case S:te=Y-1,ne=-1,se=-1,J=j-1,re=-1,V=-1;break}if(K)switch(N.pixel_size){case 8:c(O,J,re,V,te,ne,se,H);break;case 16:l(O,J,re,V,te,ne,se,H);break;default:console.error("THREE.TGALoader: Format not supported.");break}else switch(N.pixel_size){case 8:i(O,J,re,V,te,ne,se,H,X);break;case 16:s(O,J,re,V,te,ne,se,H);break;case 24:r(O,J,re,V,te,ne,se,H);break;case 32:o(O,J,re,V,te,ne,se,H);break;default:console.error("THREE.TGALoader: Format not supported.");break}return O}const h=0,f=1,d=2,p=3,m=9,g=10,x=11,y=48,b=4,v=0,S=1,A=2,R=3;e.length<19&&console.error("THREE.TGALoader: Not enough data to contain header.");let _=0;const L=new Uint8Array(e),N={id_length:L[_++],colormap_type:L[_++],image_type:L[_++],colormap_index:L[_++]|L[_++]<<8,colormap_length:L[_++]|L[_++]<<8,colormap_size:L[_++],origin:[L[_++]|L[_++]<<8,L[_++]|L[_++]<<8],width:L[_++]|L[_++]<<8,height:L[_++]|L[_++]<<8,pixel_size:L[_++],flags:L[_++]};t(N),N.id_length+_>e.length&&console.error("THREE.TGALoader: No data."),_+=N.id_length;let B=!1,W=!1,K=!1;switch(N.image_type){case m:B=!0,W=!0;break;case f:W=!0;break;case g:B=!0;break;case d:break;case x:B=!0,K=!0;break;case p:K=!0;break}const z=new Uint8Array(N.width*N.height*4),q=n(B,W,N,_,L);return u(z,N.width,N.height,q.pixel_data,q.palettes),{data:z,width:N.width,height:N.height,flipY:!0,generateMipmaps:!0,minFilter:jn}}}class Uw extends Ut{constructor(e){super(e)}load(e,t,n,i){const s=this,r=s.path===""?tn.extractUrlBase(e):s.path,o=new Zt(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(c){try{t(s.parse(c,r))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e,t){function n(T,M){const I=[],C=T.childNodes;for(let P=0,ie=C.length;P0&&M.push(new vi(C+".position",P,ie)),fe.length>0&&M.push(new ei(C+".quaternion",P,fe)),Ne.length>0&&M.push(new vi(C+".scale",P,Ne)),M}function B(T,M,I){let C,P=!0,ie,fe;for(ie=0,fe=T.length;ie=0;){const C=T[M];if(C.value[I]!==null)return C;M--}return null}function z(T,M,I){for(;M>>0)+2);switch(I=I.toLowerCase(),I){case"tga":M=ph;break;default:M=Xm}return M}function de(T){const M=U(T.url),I=M.profile.technique;let C;switch(I.type){case"phong":case"blinn":C=new Qn;break;case"lambert":C=new tc;break;default:C=new cn;break}C.name=T.name||"";function P(Ae,ke=null){const Ge=M.profile.samplers[Ae.id];let be=null;if(Ge!==void 0){const We=M.profile.surfaces[Ge.source];be=_e(We.init_from)}else console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),be=_e(Ae.id);if(be!==null){const We=Q(be);if(We!==void 0){const Be=We.load(be),je=Ae.extra;if(je!==void 0&&je.technique!==void 0&&l(je.technique)===!1){const Ve=je.technique;Be.wrapS=Ve.wrapU?on:Wt,Be.wrapT=Ve.wrapV?on:Wt,Be.offset.set(Ve.offsetU||0,Ve.offsetV||0),Be.repeat.set(Ve.repeatU||1,Ve.repeatV||1)}else Be.wrapS=on,Be.wrapT=on;return ke!==null&&(Be.encoding=ke),Be}else return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",be),null}else return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",Ae.id),null}const ie=I.parameters;for(const Ae in ie){const ke=ie[Ae];switch(Ae){case"diffuse":ke.color&&C.color.fromArray(ke.color),ke.texture&&(C.map=P(ke.texture,tt));break;case"specular":ke.color&&C.specular&&C.specular.fromArray(ke.color),ke.texture&&(C.specularMap=P(ke.texture));break;case"bump":ke.texture&&(C.normalMap=P(ke.texture));break;case"ambient":ke.texture&&(C.lightMap=P(ke.texture,tt));break;case"shininess":ke.float&&C.shininess&&(C.shininess=ke.float);break;case"emission":ke.color&&C.emissive&&C.emissive.fromArray(ke.color),ke.texture&&(C.emissiveMap=P(ke.texture,tt));break}}C.color.convertSRGBToLinear(),C.specular&&C.specular.convertSRGBToLinear(),C.emissive&&C.emissive.convertSRGBToLinear();let fe=ie.transparent,Ne=ie.transparency;if(Ne===void 0&&fe&&(Ne={float:1}),fe===void 0&&Ne&&(fe={opaque:"A_ONE",data:{color:[1,1,1,1]}}),fe&&Ne)if(fe.data.texture)C.transparent=!0;else{const Ae=fe.data.color;switch(fe.opaque){case"A_ONE":C.opacity=Ae[3]*Ne.float;break;case"RGB_ZERO":C.opacity=1-Ae[0]*Ne.float;break;case"A_ZERO":C.opacity=1-Ae[3]*Ne.float;break;case"RGB_ONE":C.opacity=Ae[0]*Ne.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',fe.opaque)}C.opacity<1&&(C.transparent=!0)}if(I.extra!==void 0&&I.extra.technique!==void 0){const Ae=I.extra.technique;for(const ke in Ae){const Ge=Ae[ke];switch(ke){case"double_sided":C.side=Ge===1?ai:oi;break;case"bump":C.normalMap=P(Ge.texture),C.normalScale=new he(1,1);break}}}return C}function Le(T){return m(Ze.materials[T],de)}function F(T){const M={name:T.getAttribute("name")};for(let I=0,C=T.childNodes.length;I0?fe+Ae:fe;M.inputs[ke]={id:ie,offset:Ne},M.stride=Math.max(M.stride,Ne+1),fe==="TEXCOORD"&&(M.hasUV=!0);break;case"vcount":M.vcount=r(P.textContent);break;case"p":M.p=r(P.textContent);break}}return M}function Lt(T){const M={};for(let I=0;I0&&M0&&be.setAttribute("position",new we(P.array,P.stride)),ie.array.length>0&&be.setAttribute("normal",new we(ie.array,ie.stride)),Ae.array.length>0&&be.setAttribute("color",new we(Ae.array,Ae.stride)),fe.array.length>0&&be.setAttribute("uv",new we(fe.array,fe.stride)),Ne.array.length>0&&be.setAttribute("uv2",new we(Ne.array,Ne.stride)),ke.array.length>0&&be.setAttribute("skinIndex",new we(ke.array,ke.stride)),Ge.array.length>0&&be.setAttribute("skinWeight",new we(Ge.array,Ge.stride)),C.data=be,C.type=T[0].type,C.materialKeys=We,C}function Tt(T,M,I,C,P=!1){const ie=T.p,fe=T.stride,Ne=T.vcount;function Ae(be){let We=ie[be+I]*Ge;const Be=We+Ge;for(;We4)for(let Ve=1,It=je-2;Ve<=It;Ve++){const _t=be+fe*0,gt=be+fe*Ve,yt=be+fe*(Ve+1);Ae(_t),Ae(gt),Ae(yt)}be+=fe*je}}else for(let be=0,We=ie.length;be=M.limits.max&&(M.static=!0),M.middlePosition=(M.limits.min+M.limits.max)/2,M}function $(T){const M={sid:T.getAttribute("sid"),name:T.getAttribute("name")||"",attachments:[],transforms:[]};for(let I=0;IBe.limits.max||be=2.0 are supported."));return}const l=new mM(c,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u=0&&o[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(r),l.setPlugins(o),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function Vw(){let a={};return{get:function(e){return a[e]},add:function(e,t){a[e]=t},remove:function(e){delete a[e]},removeAll:function(){a={}}}}const rt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class Hw{constructor(e){this.parser=e,this.name=rt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,r)}}class eM{constructor(e){this.parser=e,this.name=rt.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const r=s.extensions[t],o=i.images[r.source];let c=n.textureLoader;if(o.uri){const l=n.options.manager.getHandler(o.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return n.loadTextureImage(e,r.source,c);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class tM{constructor(e){this.name=rt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([s,r.ready]).then(function(o){const c=i.byteOffset||0,l=i.byteLength||0,u=i.count,h=i.byteStride,f=new ArrayBuffer(u*h),d=new Uint8Array(o[0],c,l);return r.decodeGltfBuffer(new Uint8Array(f),u,h,d,i.mode,i.filter),f})}else return null}}const Rm="glTF",Wo=12,Im={JSON:1313821514,BIN:5130562};class nM{constructor(e){this.name=rt.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Wo);if(this.header={magic:tn.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Rm)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-Wo,i=new DataView(e,Wo);let s=0;for(;s>>1|(bt&21845)<<1;Ji=(Ji&52428)>>>2|(Ji&13107)<<2,Ji=(Ji&61680)>>>4|(Ji&3855)<<4,ko[bt]=((Ji&65280)>>>8|(Ji&255)<<8)>>>1}for(var Dn=function(a,e,t){for(var n=a.length,i=0,s=new $t(e);i>>c]=l}else for(o=new $t(n),i=0;i>>15-a[i]);return o},Si=new at(288),bt=0;bt<144;++bt)Si[bt]=8;for(var bt=144;bt<256;++bt)Si[bt]=9;for(var bt=256;bt<280;++bt)Si[bt]=7;for(var bt=280;bt<288;++bt)Si[bt]=8;for(var Br=new at(32),bt=0;bt<32;++bt)Br[bt]=5;var Hp=Dn(Si,9,0),Wp=Dn(Si,9,1),qp=Dn(Br,5,0),Xp=Dn(Br,5,1),dc=function(a){for(var e=a[0],t=1;te&&(e=a[t]);return e},Fn=function(a,e,t){var n=e/8|0;return(a[n]|a[n+1]<<8)>>(e&7)&t},pc=function(a,e){var t=e/8|0;return(a[t]|a[t+1]<<8|a[t+2]<<16)>>(e&7)},Oo=function(a){return(a/8|0)+(a&7&&1)},Nn=function(a,e,t){(e==null||e<0)&&(e=0),(t==null||t>a.length)&&(t=a.length);var n=new(a instanceof $t?$t:a instanceof Mi?Mi:at)(t-e);return n.set(a.subarray(e,t)),n},Bo=function(a,e,t){var n=a.length;if(!n||t&&!t.l&&n<5)return e||new at(0);var i=!e||t,s=!t||t.i;t||(t={}),e||(e=new at(n*3));var r=function(H){var ye=e.length;if(H>ye){var we=new at(Math.max(ye*2,H));we.set(e),e=we}},o=t.f||0,c=t.p||0,l=t.b||0,u=t.l,h=t.d,f=t.m,d=t.n,p=n*8;do{if(!u){t.f=o=Fn(a,c,1);var m=Fn(a,c+1,3);if(c+=3,m)if(m==1)u=Wp,h=Xp,f=9,d=5;else if(m==2){var b=Fn(a,c,31)+257,v=Fn(a,c+10,15)+4,M=b+Fn(a,c+5,31)+1;c+=14;for(var T=new at(M),C=new at(19),_=0;_>>4;if(g<16)T[_++]=g;else{var J=0,G=0;for(g==16?(G=3+Fn(a,c,3),c+=2,J=T[_-1]):g==17?(G=3+Fn(a,c,7),c+=3):g==18&&(G=11+Fn(a,c,127),c+=7);G--;)T[_++]=J}}var X=T.subarray(0,b),B=T.subarray(b);f=dc(X),d=dc(B),u=Dn(X,f,1),h=Dn(B,d,1)}else throw"invalid block type";else{var g=Oo(c)+4,x=a[g-4]|a[g-3]<<8,y=g+x;if(y>n){if(s)throw"unexpected EOF";break}i&&r(l+x),e.set(a.subarray(g,y),l),t.b=l+=x,t.p=c=y*8;continue}if(c>p){if(s)throw"unexpected EOF";break}}i&&r(l+131072);for(var Z=(1<>>4;if(c+=J&15,c>p){if(s)throw"unexpected EOF";break}if(!J)throw"invalid length/literal";if(j<256)e[l++]=j;else if(j==256){W=c,u=null;break}else{var ne=j-254;if(j>264){var _=j-257,$=kr[_];ne=Fn(a,c,(1<<$)-1)+ku[_],c+=$}var ie=h[pc(a,c)&Y],ce=ie>>>4;if(!ie)throw"invalid distance";c+=ie&15;var B=Vp[ce];if(ce>3){var $=Or[ce];B+=pc(a,c)&(1<<$)-1,c+=$}if(c>p){if(s)throw"unexpected EOF";break}i&&r(l+131072);for(var oe=l+ne;l>>8},zr=function(a,e,t){t<<=e&7;var n=e/8|0;a[n]|=t,a[n+1]|=t>>>8,a[n+2]|=t>>>16},mc=function(a,e){for(var t=[],n=0;nf&&(f=s[n].s);var d=new $t(f+1),p=gc(t[u-1],d,0);if(p>e){var n=0,m=0,g=p-e,x=1<e)m+=x-(1<>>=g;m>0;){var b=s[n].s;d[b]=0&&m;--n){var v=s[n].s;d[v]==e&&(--d[v],++m)}p=e}return[new at(d),p]},gc=function(a,e,t){return a.s==-1?Math.max(gc(a.l,e,t+1),gc(a.r,e,t+1)):e[a.s]=t},Bu=function(a){for(var e=a.length;e&&!a[--e];);for(var t=new $t(++e),n=0,i=a[0],s=1,r=function(c){t[n++]=c},o=1;o<=e;++o)if(a[o]==i&&o!=e)++s;else{if(!i&&s>2){for(;s>138;s-=138)r(32754);s>2&&(r(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(r(i),--s;s>6;s-=6)r(8304);s>2&&(r(s-3<<5|8208),s=0)}for(;s--;)r(i);s=1,i=a[o]}return[t.subarray(0,n),e]},Ur=function(a,e){for(var t=0,n=0;n>>8,a[i+2]=a[i]^255,a[i+3]=a[i+1]^255;for(var s=0;s4&&!F[No[q-1]];--q);var J=l+5<<3,G=Ur(i,Si)+Ur(s,Br)+r,X=Ur(i,f)+Ur(s,m)+r+14+3*q+Ur(C,F)+(2*C[16]+3*C[17]+7*C[18]);if(J<=G&&J<=X)return zo(e,u,a.subarray(c,c+l));var B,Z,Y,W;if(ti(e,u,1+(X15&&(ti(e,u,ie[_]>>>5&127),u+=ie[_]>>>12)}}else B=Hp,Z=Si,Y=qp,W=Br;for(var _=0;_255){var ce=n[_]>>>18&31;zr(e,u,B[ce+257]),u+=Z[ce+257],ce>7&&(ti(e,u,n[_]>>>23&31),u+=kr[ce]);var oe=n[_]&31;zr(e,u,Y[oe]),u+=W[oe],oe>3&&(zr(e,u,n[_]>>>5&8191),u+=Or[oe])}else zr(e,u,B[n[_]]),u+=Z[n[_]];return zr(e,u,B[256]),u+Z[256]},jp=new Mi([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ti=new at(0),Yp=function(a,e,t,n,i,s){var r=a.length,o=new at(n+r+5*(1+Math.ceil(r/7e3))+i),c=o.subarray(n,o.length-i),l=0;if(!e||r<8)for(var u=0;u<=r;u+=65535){var h=u+65535;h>>13,p=f&8191,m=(1<7e3||F>24576)&&B>423){l=zu(a,c,0,M,T,C,E,F,q,u-q,l),F=_=E=0,q=u;for(var Z=0;Z<286;++Z)T[Z]=0;for(var Z=0;Z<30;++Z)C[Z]=0}var Y=2,W=0,j=p,ne=G-X&32767;if(B>2&&J==v(u-ne))for(var $=Math.min(d,B)-1,ie=Math.min(32767,u),ce=Math.min(258,B);ne<=ie&&--j&&G!=X;){if(a[u+Y]==a[u+Y-ne]){for(var oe=0;oeY){if(Y=oe,W=ne,oe>$)break;for(var H=Math.min(ne,oe-2),ye=0,Z=0;Zye&&(ye=xe,X=we)}}}G=X,X=g[G],ne+=G-X+32768&32767}if(W){M[F++]=268435456|fc[Y]<<18|Ou[W];var Ve=fc[Y]&31,he=Ou[W]&31;E+=kr[Ve]+Or[he],++T[257+Ve],++C[he],U=u+Y,++_}else M[F++]=a[u],++T[a[u]]}}l=zu(a,c,s,M,T,C,E,F,q,u-q,l),!s&&l&7&&(l=zo(c,l+1,Ti))}return Nn(o,0,n+Oo(l)+i)},Zp=function(){for(var a=new Mi(256),e=0;e<256;++e){for(var t=e,n=9;--n;)t=(t&1&&3988292384)^t>>>1;a[e]=t}return a}(),Gr=function(){var a=-1;return{p:function(e){for(var t=a,n=0;n>>8;a=t},d:function(){return~a}}},Uu=function(){var a=1,e=0;return{p:function(t){for(var n=a,i=e,s=t.length,r=0;r!=s;){for(var o=Math.min(r+2655,s);r>16),i=(i&65535)+15*(i>>16)}a=n,e=i},d:function(){return a%=65521,e%=65521,(a&255)<<24|a>>>8<<16|(e&255)<<8|e>>>8}}},Gs=function(a,e,t,n,i){return Yp(a,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(a.length)))*1.5):12+e.mem,t,n,!i)},Uo=function(a,e){var t={};for(var n in a)t[n]=a[n];for(var n in e)t[n]=e[n];return t},Kp=function(a,e,t){for(var n=a(),i=a.toString(),s=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/ /g,"").split(","),r=0;r>>0},Vu=function(a,e){return Vt(a,e)+Vt(a,e+4)*4294967296},vt=function(a,e,t){for(;t;++e)a[e]=t,t>>>=8},Hu=function(a,e){var t=e.filename;if(a[0]=31,a[1]=139,a[2]=8,a[8]=e.level<2?4:e.level==9?2:0,a[9]=3,e.mtime!=0&&vt(a,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),t){a[3]=8;for(var n=0;n<=t.length;++n)a[n+10]=t.charCodeAt(n)}},Wu=function(a){if(a[0]!=31||a[1]!=139||a[2]!=8)throw"invalid gzip data";var e=a[3],t=10;e&4&&(t+=a[10]|(a[11]<<8)+2);for(var n=(e>>3&1)+(e>>4&1);n>0;n-=!a[t++]);return t+(e&2)},nm=function(a){var e=a.length;return(a[e-4]|a[e-3]<<8|a[e-2]<<16|a[e-1]<<24)>>>0},qu=function(a){return 10+(a.filename&&a.filename.length+1||0)},Xu=function(a,e){var t=e.level,n=t==0?0:t<6?1:t==9?3:2;a[0]=120,a[1]=n<<6|(n?32-2*n:1)},im=function(a){if((a[0]&15)!=8||a[0]>>>4>7||(a[0]<<8|a[1])%31)throw"invalid zlib data";if(a[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function ju(a,e){return!e&&typeof a=="function"&&(e=a,a={}),this.ondata=e,a}var ni=function(){function a(e,t){!t&&typeof e=="function"&&(t=e,e={}),this.ondata=t,this.o=e||{}}return a.prototype.p=function(e,t){this.ondata(Gs(e,this.o,0,0,!t),t)},a.prototype.push=function(e,t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=t,this.p(e,t||!1)},a}(),sm=function(){function a(e,t){qr([Hr,function(){return[kn,ni]}],this,ju.call(this,e,t),function(n){var i=new ni(n.data);onmessage=kn(i)},6)}return a}();function rm(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Wr(a,e,[Hr],function(n){return $i(Go(n.data[0],n.data[1]))},0,t)}function Go(a,e){return Gs(a,e||{},0,0)}var mn=function(){function a(e){this.s={},this.p=new at(0),this.ondata=e}return a.prototype.e=function(e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var t=this.p.length,n=new at(t+e.length);n.set(this.p),n.set(e,t),this.p=n},a.prototype.c=function(e){this.d=this.s.i=e||!1;var t=this.s.b,n=Bo(this.p,this.o,this.s);this.ondata(Nn(n,t,this.s.b),this.d),this.o=Nn(n,this.s.b-32768),this.s.b=this.o.length,this.p=Nn(this.p,this.s.p/8|0),this.s.p&=7},a.prototype.push=function(e,t){this.e(e),this.c(t)},a}(),Yu=function(){function a(e){this.ondata=e,qr([Vr,function(){return[kn,mn]}],this,0,function(){var t=new mn;onmessage=kn(t)},7)}return a}();function Zu(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Wr(a,e,[Vr],function(n){return $i(Xr(n.data[0],Gu(n.data[1])))},1,t)}function Xr(a,e){return Bo(a,e)}var xc=function(){function a(e,t){this.c=Gr(),this.l=0,this.v=1,ni.call(this,e,t)}return a.prototype.push=function(e,t){ni.prototype.push.call(this,e,t)},a.prototype.p=function(e,t){this.c.p(e),this.l+=e.length;var n=Gs(e,this.o,this.v&&qu(this.o),t&&8,!t);this.v&&(Hu(n,this.o),this.v=0),t&&(vt(n,n.length-8,this.c.d()),vt(n,n.length-4,this.l)),this.ondata(n,t)},a}(),om=function(){function a(e,t){qr([Hr,$p,function(){return[kn,ni,xc]}],this,ju.call(this,e,t),function(n){var i=new xc(n.data);onmessage=kn(i)},8)}return a}();function am(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Wr(a,e,[Hr,$p,function(){return[vc]}],function(n){return $i(vc(n.data[0],n.data[1]))},2,t)}function vc(a,e){e||(e={});var t=Gr(),n=a.length;t.p(a);var i=Gs(a,e,qu(e),8),s=i.length;return Hu(i,e),vt(i,s-8,t.d()),vt(i,s-4,n),i}var _c=function(){function a(e){this.v=1,mn.call(this,e)}return a.prototype.push=function(e,t){if(mn.prototype.e.call(this,e),this.v){var n=this.p.length>3?Wu(this.p):4;if(n>=this.p.length&&!t)return;this.p=this.p.subarray(n),this.v=0}if(t){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}mn.prototype.c.call(this,t)},a}(),cm=function(){function a(e){this.ondata=e,qr([Vr,Qp,function(){return[kn,mn,_c]}],this,0,function(){var t=new _c;onmessage=kn(t)},9)}return a}();function lm(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Wr(a,e,[Vr,Qp,function(){return[bc]}],function(n){return $i(bc(n.data[0]))},3,t)}function bc(a,e){return Bo(a.subarray(Wu(a),-8),e||new at(nm(a)))}var Ku=function(){function a(e,t){this.c=Uu(),this.v=1,ni.call(this,e,t)}return a.prototype.push=function(e,t){ni.prototype.push.call(this,e,t)},a.prototype.p=function(e,t){this.c.p(e);var n=Gs(e,this.o,this.v&&2,t&&4,!t);this.v&&(Xu(n,this.o),this.v=0),t&&vt(n,n.length-4,this.c.d()),this.ondata(n,t)},a}(),iw=function(){function a(e,t){qr([Hr,em,function(){return[kn,ni,Ku]}],this,ju.call(this,e,t),function(n){var i=new Ku(n.data);onmessage=kn(i)},10)}return a}();function sw(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Wr(a,e,[Hr,em,function(){return[Ju]}],function(n){return $i(Ju(n.data[0],n.data[1]))},4,t)}function Ju(a,e){e||(e={});var t=Uu();t.p(a);var n=Gs(a,e,2,4);return Xu(n,e),vt(n,n.length-4,t.d()),n}var wc=function(){function a(e){this.v=1,mn.call(this,e)}return a.prototype.push=function(e,t){if(mn.prototype.e.call(this,e),this.v){if(this.p.length<2&&!t)return;this.p=this.p.subarray(2),this.v=0}if(t){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}mn.prototype.c.call(this,t)},a}(),um=function(){function a(e){this.ondata=e,qr([Vr,tm,function(){return[kn,mn,wc]}],this,0,function(){var t=new wc;onmessage=kn(t)},11)}return a}();function hm(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return Wr(a,e,[Vr,tm,function(){return[Vo]}],function(n){return $i(Vo(n.data[0],Gu(n.data[1])))},5,t)}function Vo(a,e){return Bo((im(a),a.subarray(2,-4)),e)}var fm=function(){function a(e){this.G=_c,this.I=mn,this.Z=wc,this.ondata=e}return a.prototype.push=function(e,t){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var n=new at(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length)}else this.p=e;if(this.p.length>2){var i=this,s=function(){i.ondata.apply(i,arguments)};this.s=this.p[0]==31&&this.p[1]==139&&this.p[2]==8?new this.G(s):(this.p[0]&15)!=8||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(s):new this.Z(s),this.s.push(this.p,t),this.p=null}}},a}(),rw=function(){function a(e){this.G=cm,this.I=Yu,this.Z=um,this.ondata=e}return a.prototype.push=function(e,t){fm.prototype.push.call(this,e,t)},a}();function ow(a,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return a[0]==31&&a[1]==139&&a[2]==8?lm(a,e,t):(a[0]&15)!=8||a[0]>>4>7||(a[0]<<8|a[1])%31?Zu(a,e,t):hm(a,e,t)}function aw(a,e){return a[0]==31&&a[1]==139&&a[2]==8?bc(a,e):(a[0]&15)!=8||a[0]>>4>7||(a[0]<<8|a[1])%31?Xr(a,e):Vo(a,e)}var $u=function(a,e,t,n){for(var i in a){var s=a[i],r=e+i;s instanceof at?t[r]=[s,n]:Array.isArray(s)?t[r]=[s[0],Uo(n,s[1])]:$u(s,r+"/",t,n)}},dm=typeof TextEncoder!="undefined"&&new TextEncoder,Qu=typeof TextDecoder!="undefined"&&new TextDecoder,pm=0;try{Qu.decode(Ti,{stream:!0}),pm=1}catch{}var mm=function(a){for(var e="",t=0;;){var n=a[t++],i=(n>127)+(n>223)+(n>239);if(t+i>a.length)return[e,Nn(a,t-1)];i?i==3?(n=((n&15)<<18|(a[t++]&63)<<12|(a[t++]&63)<<6|a[t++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):i&1?e+=String.fromCharCode((n&31)<<6|a[t++]&63):e+=String.fromCharCode((n&15)<<12|(a[t++]&63)<<6|a[t++]&63):e+=String.fromCharCode(n)}},cw=function(){function a(e){this.ondata=e,pm?this.t=new TextDecoder:this.p=Ti}return a.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(t=!!t,this.t){if(this.ondata(this.t.decode(e,{stream:!0}),t),t){if(this.t.decode().length)throw"invalid utf-8 data";this.t=null}return}if(!this.p)throw"stream finished";var n=new at(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length);var i=mm(n),s=i[0],r=i[1];if(t){if(r.length)throw"invalid utf-8 data";this.p=null}else this.p=r;this.ondata(s,t)},a}(),lw=function(){function a(e){this.ondata=e}return a.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(this.d)throw"stream finished";this.ondata(Qi(e),this.d=t||!1)},a}();function Qi(a,e){if(e){for(var t=new at(a.length),n=0;n>1)),r=0,o=function(u){s[r++]=u},n=0;ns.length){var c=new at(r+8+(i-n<<1));c.set(s),s=c}var l=a.charCodeAt(n);l<128||e?o(l):l<2048?(o(192|l>>6),o(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|a.charCodeAt(++n)&1023,o(240|l>>18),o(128|l>>12&63),o(128|l>>6&63),o(128|l&63)):(o(224|l>>12),o(128|l>>6&63),o(128|l&63))}return Nn(s,0,r)}function eh(a,e){if(e){for(var t="",n=0;n65535)throw"extra field too long";e+=n+4}return e},jr=function(a,e,t,n,i,s,r,o){var c=n.length,l=t.extra,u=o&&o.length,h=es(l);vt(a,e,r!=null?33639248:67324752),e+=4,r!=null&&(a[e++]=20,a[e++]=t.os),a[e]=20,e+=2,a[e++]=t.flag<<1|(s==null&&8),a[e++]=i&&8,a[e++]=t.compression&255,a[e++]=t.compression>>8;var f=new Date(t.mtime==null?Date.now():t.mtime),d=f.getFullYear()-1980;if(d<0||d>119)throw"date not in range 1980-2099";if(vt(a,e,d<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>>1),e+=4,s!=null&&(vt(a,e,t.crc),vt(a,e+4,s),vt(a,e+8,t.size)),vt(a,e+12,c),vt(a,e+14,h),e+=16,r!=null&&(vt(a,e,u),vt(a,e+6,t.attrs),vt(a,e+10,r),e+=14),a.set(n,e),e+=c,h)for(var p in l){var m=l[p],g=m.length;vt(a,e,+p),vt(a,e+2,g),a.set(m,e+4),e+=4+g}return u&&(a.set(o,e),e+=u),e},th=function(a,e,t,n,i){vt(a,e,101010256),vt(a,e+8,t),vt(a,e+10,t),vt(a,e+12,n),vt(a,e+16,i)},Ho=function(){function a(e){this.filename=e,this.c=Gr(),this.size=0,this.compression=0}return a.prototype.process=function(e,t){this.ondata(null,e,t)},a.prototype.push=function(e,t){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},a}(),uw=function(){function a(e,t){var n=this;t||(t={}),Ho.call(this,e),this.d=new ni(t,function(i,s){n.ondata(null,i,s)}),this.compression=8,this.flag=gm(t.level)}return a.prototype.process=function(e,t){try{this.d.push(e,t)}catch(n){this.ondata(n,null,t)}},a.prototype.push=function(e,t){Ho.prototype.push.call(this,e,t)},a}(),hw=function(){function a(e,t){var n=this;t||(t={}),Ho.call(this,e),this.d=new sm(t,function(i,s,r){n.ondata(i,s,r)}),this.compression=8,this.flag=gm(t.level),this.terminate=this.d.terminate}return a.prototype.process=function(e,t){this.d.push(e,t)},a.prototype.push=function(e,t){Ho.prototype.push.call(this,e,t)},a}(),fw=function(){function a(e){this.ondata=e,this.u=[],this.d=1}return a.prototype.add=function(e){var t=this;if(this.d&2)throw"stream finished";var n=Qi(e.filename),i=n.length,s=e.comment,r=s&&Qi(s),o=i!=e.filename.length||r&&s.length!=r.length,c=i+es(e.extra)+30;if(i>65535)throw"filename too long";var l=new at(c);jr(l,0,e,n,o);var u=[l],h=function(){for(var g=0,x=u;g65535&&J("filename too long",null),!q)J(null,y);else if(M<16e4)try{J(null,Go(y,b))}catch(G){J(G,null)}else u.push(rm(y,b,J))},p=0;p65535)throw"filename too long";var x=u?Go(c,l):c,y=x.length,b=Gr();b.p(c),n.push(Uo(l,{size:c.length,crc:b.d(),c:x,f:h,m:p,u:f!=r.length||p&&d.length!=m,o:i,compression:u})),i+=30+f+g+y,s+=76+2*(f+g)+(m||0)+y}for(var v=new at(s+22),M=i,T=s-i,C=0;C0){var i=Math.min(this.c,e.length),s=e.subarray(0,i);if(this.c-=i,this.d?this.d.push(s,!this.c):this.k[0].push(s),e=e.subarray(i),e.length)return this.push(e,t)}else{var r=0,o=0,c=void 0,l=void 0;this.p.length?e.length?(l=new at(this.p.length+e.length),l.set(this.p),l.set(e,this.p.length)):l=this.p:l=e;for(var u=l.length,h=this.c,f=h&&this.d,d=function(){var x,y=Vt(l,o);if(y==67324752){r=1,c=o,p.d=null,p.c=0;var b=fn(l,o+6),v=fn(l,o+8),M=b&2048,T=b&8,C=fn(l,o+26),_=fn(l,o+28);if(u>o+30+C+_){var E=[];p.k.unshift(E),r=2;var F=Vt(l,o+18),U=Vt(l,o+22),q=eh(l.subarray(o+30,o+=30+C),!M);F==4294967295?(x=T?[-2]:vm(l,o),F=x[0],U=x[1]):T&&(F=-1),o+=_,p.c=F;var J,G={name:q,compression:v,start:function(){if(!G.ondata)throw"no callback";if(!F)G.ondata(null,Ti,!0);else{var X=n.o[v];if(!X)throw"unknown compression type "+v;J=F<0?new X(q):new X(q,F,U),J.ondata=function(W,j,ne){G.ondata(W,j,ne)};for(var B=0,Z=E;B=0&&(G.size=F,G.originalSize=U),p.onfile(G)}return"break"}else if(h){if(y==134695760)return c=o+=12+(h==-2&&8),r=3,p.c=0,"break";if(y==33639248)return c=o-=4,r=3,p.c=0,"break"}},p=this;o65558){e("invalid zip file",null);return}var r=fn(a,s+8);r||e(null,{});var o=r,c=Vt(a,s+16),l=c==4294967295;if(l){if(s=Vt(a,s-12),Vt(a,s)!=101075792){e("invalid zip file",null);return}o=r=Vt(a,s+32),c=Vt(a,s+48)}for(var u=function(f){var d=xm(a,c,l),p=d[0],m=d[1],g=d[2],x=d[3],y=d[4],b=d[5],v=ym(a,b);c=y;var M=function(C,_){C?(n(),e(C,null)):(i[x]=_,--r||e(null,i))};if(!p)M(null,Nn(a,v,v+m));else if(p==8){var T=a.subarray(v,v+m);if(m<32e4)try{M(null,Xr(T,new at(g)))}catch(C){M(C,null)}else t.push(Zu(T,{size:g},M))}else M("unknown compression type "+p,null)},h=0;h65558)throw"invalid zip file";var n=fn(a,t+8);if(!n)return{};var i=Vt(a,t+16),s=i==4294967295;if(s){if(t=Vt(a,t-12),Vt(a,t)!=101075792)throw"invalid zip file";n=Vt(a,t+32),i=Vt(a,t+48)}for(var r=0;r=t[n])return n-1;if(e<=t[a])return a;let i=a,s=n,r=Math.floor((i+s)/2);for(;e=t[r+1];)e=m&&(p[d][0]=p[f][0]/o[y+1][x],g=p[d][0]*o[x][y]);const b=x>=-1?1:-x,v=h-1<=y?m-1:t-h;for(let T=b;T<=v;++T)p[d][T]=(p[f][T]-p[f][T-1])/o[y+1][x+T],g+=p[d][T]*o[x+T][y];h<=y&&(p[d][m]=-p[f][m-1]/o[y+1][h],g+=p[d][m]*o[h][y]),r[m][h]=g;const M=f;f=d,d=M}}let u=t;for(let h=1;h<=n;++h){for(let f=0;f<=t;++f)r[h][f]*=u;u*=t-h}return r}function Sw(a,e,t,n,i){const s=i0,c=typeof s.Content=="string"&&s.Content!=="";if(o||c){const l=this.parseImage(n[i]);t[s.RelativeFilename||s.Filename]=l}}}}for(const n in e){const i=e[n];t[i]!==void 0?e[n]=t[i]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase();let s;switch(i){case"bmp":s="image/bmp";break;case"jpg":case"jpeg":s="image/jpeg";break;case"png":s="image/png";break;case"tif":s="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),s="image/tga";break;default:console.warn('FBXLoader: Image type "'+i+'" is not supported.');return}if(typeof t=="string")return"data:"+s+";base64,"+t;{const r=new Uint8Array(t);return window.URL.createObjectURL(new Blob([r],{type:s}))}}parseTextures(e){const t=new Map;if("Texture"in rt.Objects){const n=rt.Objects.Texture;for(const i in n){const s=this.parseTexture(n[i],e);t.set(parseInt(i),s)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const i=e.WrapModeU,s=e.WrapModeV,r=i!==void 0?i.value:0,o=s!==void 0?s.value:0;if(n.wrapS=r===0?on:Wt,n.wrapT=o===0?on:Wt,"Scaling"in e){const c=e.Scaling.value;n.repeat.x=c[0],n.repeat.y=c[1]}if("Translation"in e){const c=e.Translation.value;n.offset.x=c[0],n.offset.y=c[1]}return n}loadTexture(e,t){let n;const i=this.textureLoader.path,s=Ht.get(e.id).children;s!==void 0&&s.length>0&&t[s[0].ID]!==void 0&&(n=t[s[0].ID],(n.indexOf("blob:")===0||n.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let r;const o=e.FileName.slice(-3).toLowerCase();if(o==="tga"){const c=this.manager.getHandler(".tga");c===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),r=new Mt):(c.setPath(this.textureLoader.path),r=c.load(n))}else o==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),r=new Mt):r=this.textureLoader.load(n);return this.textureLoader.setPath(i),r}parseMaterials(e){const t=new Map;if("Material"in rt.Objects){const n=rt.Objects.Material;for(const i in n){const s=this.parseMaterial(n[i],e);s!==null&&t.set(parseInt(i),s)}}return t}parseMaterial(e,t){const n=e.id,i=e.attrName;let s=e.ShadingModel;if(typeof s=="object"&&(s=s.value),!Ht.has(n))return null;const r=this.parseParameters(e,t,n);let o;switch(s.toLowerCase()){case"phong":o=new Qn;break;case"lambert":o=new tc;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),o=new Qn;break}return o.setValues(r),o.name=i,o}parseParameters(e,t,n){const i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=new be().fromArray(e.Diffuse.value):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(i.color=new be().fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=new be().fromArray(e.Emissive.value):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(i.emissive=new be().fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(i.opacity=parseFloat(e.Opacity.value)),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=new be().fromArray(e.Specular.value):e.SpecularColor&&e.SpecularColor.type==="Color"&&(i.specular=new be().fromArray(e.SpecularColor.value));const s=this;return Ht.get(n).children.forEach(function(r){const o=r.relationship;switch(o){case"Bump":i.bumpMap=s.getTexture(t,r.ID);break;case"Maya|TEX_ao_map":i.aoMap=s.getTexture(t,r.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=s.getTexture(t,r.ID),i.map!==void 0&&(i.map.encoding=nt);break;case"DisplacementColor":i.displacementMap=s.getTexture(t,r.ID);break;case"EmissiveColor":i.emissiveMap=s.getTexture(t,r.ID),i.emissiveMap!==void 0&&(i.emissiveMap.encoding=nt);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=s.getTexture(t,r.ID);break;case"ReflectionColor":i.envMap=s.getTexture(t,r.ID),i.envMap!==void 0&&(i.envMap.mapping=qs,i.envMap.encoding=nt);break;case"SpecularColor":i.specularMap=s.getTexture(t,r.ID),i.specularMap!==void 0&&(i.specularMap.encoding=nt);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=s.getTexture(t,r.ID),i.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",o);break}}),i}getTexture(e,t){return"LayeredTexture"in rt.Objects&&t in rt.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=Ht.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in rt.Objects){const n=rt.Objects.Deformer;for(const i in n){const s=n[i],r=Ht.get(parseInt(i));if(s.attrType==="Skin"){const o=this.parseSkeleton(r,n);o.ID=i,r.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),o.geometryID=r.parents[0].ID,e[i]=o}else if(s.attrType==="BlendShape"){const o={id:i};o.rawTargets=this.parseMorphTargets(r,n),o.id=i,r.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=o}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(i){const s=t[i.ID];if(s.attrType!=="Cluster")return;const r={ID:i.ID,indices:[],weights:[],transformLink:new Pe().fromArray(s.TransformLink.a)};"Indexes"in s&&(r.indices=s.Indexes.a,r.weights=s.Weights.a),n.push(r)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let i=0;i1?r=o:o.length>0?r=o[0]:(r=new Qn({color:13421772}),o.push(r)),"color"in s.attributes&&o.forEach(function(c){c.vertexColors=!0}),s.FBX_Deformer?(i=new wo(s,r),i.normalizeSkinWeights()):i=new St(s,r),i}createCurve(e,t){const n=e.children.reduce(function(s,r){return t.has(r.ID)&&(s=t.get(r.ID)),s},null),i=new zt({color:3342591,linewidth:1});return new Hn(n,i)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=Em(t.RotationOrder.value):n.eulerOrder="ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&Ht.get(e.ID).children.forEach(function(i){if(i.relationship==="LookAtProperty"){const s=rt.Objects.Model[i.ID];if("Lcl_Translation"in s){const r=s.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(r),gn.add(e.target)):e.lookAt(new P().fromArray(r))}}})}bindSkeleton(e,t,n){const i=this.parsePoseNodes();for(const s in e){const r=e[s];Ht.get(parseInt(r.ID)).parents.forEach(function(c){if(t.has(c.ID)){const l=c.ID;Ht.get(l).parents.forEach(function(h){n.has(h.ID)&&n.get(h.ID).bind(new Ms(r.bones),i[h.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in rt.Objects){const t=rt.Objects.Pose;for(const n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){const i=t[n].PoseNode;Array.isArray(i)?i.forEach(function(s){e[s.Node]=new Pe().fromArray(s.Matrix.a)}):e[i.Node]=new Pe().fromArray(i.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in rt&&"AmbientColor"in rt.GlobalSettings){const e=rt.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(t!==0||n!==0||i!==0){const s=new be(t,n,i);gn.add(new Do(s,1))}}}}class Rw{parse(e){const t=new Map;if("Geometry"in rt.Objects){const n=rt.Objects.Geometry;for(const i in n){const s=Ht.get(parseInt(i)),r=this.parseGeometry(s,n[i],e);t.set(parseInt(i),r)}}return t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const i=n.skeletons,s=[],r=e.parents.map(function(h){return rt.Objects.Model[h.ID]});if(r.length===0)return;const o=e.children.reduce(function(h,f){return i[f.ID]!==void 0&&(h=i[f.ID]),h},null);e.children.forEach(function(h){n.morphTargets[h.ID]!==void 0&&s.push(n.morphTargets[h.ID])});const c=r[0],l={};"RotationOrder"in c&&(l.eulerOrder=Em(c.RotationOrder.value)),"InheritType"in c&&(l.inheritType=parseInt(c.InheritType.value)),"GeometricTranslation"in c&&(l.translation=c.GeometricTranslation.value),"GeometricRotation"in c&&(l.rotation=c.GeometricRotation.value),"GeometricScaling"in c&&(l.scale=c.GeometricScaling.value);const u=Am(l);return this.genGeometry(t,o,s,u)}genGeometry(e,t,n,i){const s=new qe;e.attrName&&(s.name=e.attrName);const r=this.parseGeoNode(e,t),o=this.genBuffers(r),c=new Ae(o.vertex,3);if(c.applyMatrix4(i),s.setAttribute("position",c),o.colors.length>0&&s.setAttribute("color",new Ae(o.colors,3)),t&&(s.setAttribute("skinIndex",new va(o.weightsIndices,4)),s.setAttribute("skinWeight",new Ae(o.vertexWeights,4)),s.FBX_Deformer=t),o.normal.length>0){const l=new an().getNormalMatrix(i),u=new Ae(o.normal,3);u.applyNormalMatrix(l),s.setAttribute("normal",u)}if(o.uvs.forEach(function(l,u){let h="uv"+(u+1).toString();u===0&&(h="uv"),s.setAttribute(h,new Ae(o.uvs[u],2))}),r.material&&r.material.mappingType!=="AllSame"){let l=o.materialIndex[0],u=0;if(o.materialIndex.forEach(function(h,f){h!==l&&(s.addGroup(u,f-u,l),l=h,u=f)}),s.groups.length>0){const h=s.groups[s.groups.length-1],f=h.start+h.count;f!==o.materialIndex.length&&s.addGroup(f,o.materialIndex.length-f,l)}s.groups.length===0&&s.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(s,e,n,i),s}parseGeoNode(e,t){const n={};if(n.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],n.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let i=0;for(;e.LayerElementUV[i];)e.LayerElementUV[i].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[i])),i++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(i,s){i.indices.forEach(function(r,o){n.weightTable[r]===void 0&&(n.weightTable[r]=[]),n.weightTable[r].push({id:s,weight:i.weights[o]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,i=0,s=!1,r=[],o=[],c=[],l=[],u=[],h=[];const f=this;return e.vertexIndices.forEach(function(d,p){let m,g=!1;d<0&&(d=d^-1,g=!0);let x=[],y=[];if(r.push(d*3,d*3+1,d*3+2),e.color){const b=Mc(p,n,d,e.color);c.push(b[0],b[1],b[2])}if(e.skeleton){if(e.weightTable[d]!==void 0&&e.weightTable[d].forEach(function(b){y.push(b.weight),x.push(b.id)}),y.length>4){s||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),s=!0);const b=[0,0,0,0],v=[0,0,0,0];y.forEach(function(M,T){let C=M,_=x[T];v.forEach(function(E,F,U){if(C>E){U[F]=C,C=E;const q=b[F];b[F]=_,_=q}})}),x=b,y=v}for(;y.length<4;)y.push(0),x.push(0);for(let b=0;b<4;++b)u.push(y[b]),h.push(x[b])}if(e.normal){const b=Mc(p,n,d,e.normal);o.push(b[0],b[1],b[2])}e.material&&e.material.mappingType!=="AllSame"&&(m=Mc(p,n,d,e.material)[0]),e.uv&&e.uv.forEach(function(b,v){const M=Mc(p,n,d,b);l[v]===void 0&&(l[v]=[]),l[v].push(M[0]),l[v].push(M[1])}),i++,g&&(f.genFace(t,e,r,m,o,c,l,u,h,i),n++,i=0,r=[],o=[],c=[],l=[],u=[],h=[])}),t}genFace(e,t,n,i,s,r,o,c,l,u){for(let h=2;h1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const r=e.get(s[0].ID);n[i]={name:t[i].attrName,layer:r}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach(function(i){t=t.concat(n.generateTracks(i))}),new _i(e.name,-1,t)}generateTracks(e){const t=[];let n=new P,i=new Pt,s=new P;if(e.transform&&e.transform.decompose(n,i,s),n=n.toArray(),i=new Cn().setFromQuaternion(i,e.eulerOrder).toArray(),s=s.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const r=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");r!==void 0&&t.push(r)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const r=this.generateRotationTrack(e.modelName,e.R.curves,i,e.preRotation,e.postRotation,e.eulerOrder);r!==void 0&&t.push(r)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const r=this.generateVectorTrack(e.modelName,e.S.curves,s,"scale");r!==void 0&&t.push(r)}if(e.DeformPercent!==void 0){const r=this.generateMorphTrack(e);r!==void 0&&t.push(r)}return t}generateVectorTrack(e,t,n,i){const s=this.getTimesForAllAxes(t),r=this.getKeyframeTrackValues(s,t,n);return new vi(e+"."+i,s,r)}generateRotationTrack(e,t,n,i,s,r){t.x!==void 0&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(en.degToRad)),t.y!==void 0&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(en.degToRad)),t.z!==void 0&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(en.degToRad));const o=this.getTimesForAllAxes(t),c=this.getKeyframeTrackValues(o,t,n);i!==void 0&&(i=i.map(en.degToRad),i.push(r),i=new Cn().fromArray(i),i=new Pt().setFromEuler(i)),s!==void 0&&(s=s.map(en.degToRad),s.push(r),s=new Cn().fromArray(s),s=new Pt().setFromEuler(s).invert());const l=new Pt,u=new Cn,h=[];for(let f=0;f1){let n=1,i=t[0];for(let s=1;s=180){const r=s/180,o=i/r;let c=n+o;const l=e.times[t-1],h=(e.times[t]-l)/r;let f=l+h;const d=[],p=[];for(;f1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}}parseNodeProperty(e,t,n){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),s=t[2].replace(/^"/,"").replace(/"$/,"").trim();i==="Content"&&s===","&&(s=n.replace(/"/g,"").replace(/,$/,"").trim());const r=this.getCurrentNode();if(r.name==="Properties70"){this.parseNodeSpecialProperty(e,i,s);return}if(i==="C"){const c=s.split(",").slice(1),l=parseInt(c[0]),u=parseInt(c[1]);let h=s.split(",").slice(3);h=h.map(function(f){return f.trim().replace(/^"/,"")}),i="connections",s=[l,u],Bw(s,h),r[i]===void 0&&(r[i]=[])}i==="Node"&&(r.id=s),i in r&&Array.isArray(r[i])?r[i].push(s):i!=="a"?r[i]=s:r.a=s,this.setCurrentProp(r,i),i==="a"&&s.slice(-1)!==","&&(r.a=ih(s))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=ih(t.a))}parseNodeSpecialProperty(e,t,n){const i=n.split('",').map(function(u){return u.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=i[0],r=i[1],o=i[2],c=i[3];let l=i[4];switch(r){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=ih(l);break}this.getPrevNode()[s]={type:r,type2:o,flag:c,value:l},this.setCurrentProp(this.getPrevNode(),s)}}class Dw{parse(e){const t=new Mm(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const i=new Sm;for(;!this.endOfContent(t);){const s=this.parseNode(t,n);s!==null&&i.add(s.name,s)}return i}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},i=t>=7500?e.getUint64():e.getUint32(),s=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const r=e.getUint8(),o=e.getString(r);if(i===0)return null;const c=[];for(let f=0;f0?c[0]:"",u=c.length>1?c[1]:"",h=c.length>2?c[2]:"";for(n.singleProperty=s===1&&e.getOffset()===i;i>e.getOffset();){const f=this.parseNode(e,t);f!==null&&this.parseSubNode(o,n,f)}return n.propertyList=c,typeof l=="number"&&(n.id=l),u!==""&&(n.attrName=u),h!==""&&(n.attrType=h),o!==""&&(n.name=o),n}parseSubNode(e,t,n){if(n.singleProperty===!0){const i=n.propertyList[0];Array.isArray(i)?(t[n.name]=n,n.a=i):t[n.name]=i}else if(e==="Connections"&&n.name==="C"){const i=[];n.propertyList.forEach(function(s,r){r!==0&&i.push(s)}),t.connections===void 0&&(t.connections=[]),t.connections.push(i)}else if(n.name==="Properties70")Object.keys(n).forEach(function(s){t[s]=n[s]});else if(e==="Properties70"&&n.name==="P"){let i=n.propertyList[0],s=n.propertyList[1];const r=n.propertyList[2],o=n.propertyList[3];let c;i.indexOf("Lcl ")===0&&(i=i.replace("Lcl ","Lcl_")),s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),s==="Color"||s==="ColorRGB"||s==="Vector"||s==="Vector3D"||s.indexOf("Lcl_")===0?c=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:c=n.propertyList[4],t[i]={type:s,type2:r,flag:o,value:c}}else t[n.name]===void 0?typeof n.id=="number"?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name==="PoseNode"?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const i=e.getUint32(),s=e.getUint32(),r=e.getUint32();if(s===0)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}typeof _w=="undefined"&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const o=Vo(new Uint8Array(e.getArrayBuffer(r))),c=new Mm(o.buffer);switch(t){case"b":case"c":return c.getBooleanArray(i);case"d":return c.getFloat64Array(i);case"f":return c.getFloat32Array(i);case"i":return c.getInt32Array(i);case"l":return c.getInt64Array(i)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class Mm{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let n=0;n=0&&(t=t.slice(0,n)),tn.decodeText(new Uint8Array(t))}}class Sm{add(e,t){this[e]=t}}function Fw(a){const e="Kaydara FBX Binary \0";return a.byteLength>=e.length&&e===Cm(a,0,e.length)}function Nw(a){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function n(i){const s=a[i-1];return a=a.slice(t+i),t++,s}for(let i=0;i256||B.colormap_size!==24||B.colormap_type!==1)&&console.error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case d:case p:case g:case x:B.colormap_type&&console.error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case h:console.error("THREE.TGALoader: No data.");default:console.error('THREE.TGALoader: Invalid type "%s".',B.image_type)}(B.width<=0||B.height<=0)&&console.error("THREE.TGALoader: Invalid image size."),B.pixel_size!==8&&B.pixel_size!==16&&B.pixel_size!==24&&B.pixel_size!==32&&console.error('THREE.TGALoader: Invalid pixel size "%s".',B.pixel_size)}function n(B,Z,Y,W,j){let ne,$;const ie=Y.pixel_size>>3,ce=Y.width*Y.height*ie;if(Z&&($=j.subarray(W,W+=Y.colormap_length*(Y.colormap_size>>3))),B){ne=new Uint8Array(ce);let oe,H,ye,we=0;const De=new Uint8Array(ie);for(;we>7,B[(H+we*ye)*4+1]=(ce&992)>>2,B[(H+we*ye)*4+2]=(ce&31)<<3,B[(H+we*ye)*4+3]=ce&32768?0:255;return B}function r(B,Z,Y,W,j,ne,$,ie){let ce=0,oe,H;const ye=F.width;for(H=Z;H!==W;H+=Y)for(oe=j;oe!==$;oe+=ne,ce+=3)B[(oe+ye*H)*4+3]=255,B[(oe+ye*H)*4+2]=ie[ce+0],B[(oe+ye*H)*4+1]=ie[ce+1],B[(oe+ye*H)*4+0]=ie[ce+2];return B}function o(B,Z,Y,W,j,ne,$,ie){let ce=0,oe,H;const ye=F.width;for(H=Z;H!==W;H+=Y)for(oe=j;oe!==$;oe+=ne,ce+=4)B[(oe+ye*H)*4+2]=ie[ce+0],B[(oe+ye*H)*4+1]=ie[ce+1],B[(oe+ye*H)*4+0]=ie[ce+2],B[(oe+ye*H)*4+3]=ie[ce+3];return B}function c(B,Z,Y,W,j,ne,$,ie){let ce,oe=0,H,ye;const we=F.width;for(ye=Z;ye!==W;ye+=Y)for(H=j;H!==$;H+=ne,oe++)ce=ie[oe],B[(H+we*ye)*4+0]=ce,B[(H+we*ye)*4+1]=ce,B[(H+we*ye)*4+2]=ce,B[(H+we*ye)*4+3]=255;return B}function l(B,Z,Y,W,j,ne,$,ie){let ce=0,oe,H;const ye=F.width;for(H=Z;H!==W;H+=Y)for(oe=j;oe!==$;oe+=ne,ce+=2)B[(oe+ye*H)*4+0]=ie[ce+0],B[(oe+ye*H)*4+1]=ie[ce+0],B[(oe+ye*H)*4+2]=ie[ce+0],B[(oe+ye*H)*4+3]=ie[ce+1];return B}function u(B,Z,Y,W,j){let ne,$,ie,ce,oe,H;switch((F.flags&y)>>b){default:case T:ne=0,ie=1,oe=Z,$=0,ce=1,H=Y;break;case v:ne=0,ie=1,oe=Z,$=Y-1,ce=-1,H=-1;break;case C:ne=Z-1,ie=-1,oe=-1,$=0,ce=1,H=Y;break;case M:ne=Z-1,ie=-1,oe=-1,$=Y-1,ce=-1,H=-1;break}if(J)switch(F.pixel_size){case 8:c(B,$,ce,H,ne,ie,oe,W);break;case 16:l(B,$,ce,H,ne,ie,oe,W);break;default:console.error("THREE.TGALoader: Format not supported.");break}else switch(F.pixel_size){case 8:i(B,$,ce,H,ne,ie,oe,W,j);break;case 16:s(B,$,ce,H,ne,ie,oe,W);break;case 24:r(B,$,ce,H,ne,ie,oe,W);break;case 32:o(B,$,ce,H,ne,ie,oe,W);break;default:console.error("THREE.TGALoader: Format not supported.");break}return B}const h=0,f=1,d=2,p=3,m=9,g=10,x=11,y=48,b=4,v=0,M=1,T=2,C=3;e.length<19&&console.error("THREE.TGALoader: Not enough data to contain header.");let _=0;const E=new Uint8Array(e),F={id_length:E[_++],colormap_type:E[_++],image_type:E[_++],colormap_index:E[_++]|E[_++]<<8,colormap_length:E[_++]|E[_++]<<8,colormap_size:E[_++],origin:[E[_++]|E[_++]<<8,E[_++]|E[_++]<<8],width:E[_++]|E[_++]<<8,height:E[_++]|E[_++]<<8,pixel_size:E[_++],flags:E[_++]};t(F),F.id_length+_>e.length&&console.error("THREE.TGALoader: No data."),_+=F.id_length;let U=!1,q=!1,J=!1;switch(F.image_type){case m:U=!0,q=!0;break;case f:q=!0;break;case g:U=!0;break;case d:break;case x:U=!0,J=!0;break;case p:J=!0;break}const G=new Uint8Array(F.width*F.height*4),X=n(U,q,F,_,E);return u(G,F.width,F.height,X.pixel_data,X.palettes),{data:G,width:F.width,height:F.height,flipY:!0,generateMipmaps:!0,minFilter:jn}}}class Uw extends Ut{constructor(e){super(e)}load(e,t,n,i){const s=this,r=s.path===""?tn.extractUrlBase(e):s.path,o=new Zt(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(c){try{t(s.parse(c,r))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e,t){function n(S,w){const L=[],A=S.childNodes;for(let I=0,se=A.length;I0&&w.push(new vi(A+".position",I,se)),de.length>0&&w.push(new ei(A+".quaternion",I,de)),Ne.length>0&&w.push(new vi(A+".scale",I,Ne)),w}function U(S,w,L){let A,I=!0,se,de;for(se=0,de=S.length;se=0;){const A=S[w];if(A.value[L]!==null)return A;w--}return null}function G(S,w,L){for(;w>>0)+2);switch(L=L.toLowerCase(),L){case"tga":w=mh;break;default:w=Xm}return w}function Q(S){const w=k(S.url),L=w.profile.technique;let A;switch(L.type){case"phong":case"blinn":A=new Qn;break;case"lambert":A=new tc;break;default:A=new cn;break}A.name=S.name||"";function I(Le,ke=null){const Ue=w.profile.samplers[Le.id];let Me=null;if(Ue!==void 0){const We=w.profile.surfaces[Ue.source];Me=we(We.init_from)}else console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),Me=we(Le.id);if(Me!==null){const We=K(Me);if(We!==void 0){const Oe=We.load(Me),Xe=Le.extra;if(Xe!==void 0&&Xe.technique!==void 0&&l(Xe.technique)===!1){const Ge=Xe.technique;Oe.wrapS=Ge.wrapU?on:Wt,Oe.wrapT=Ge.wrapV?on:Wt,Oe.offset.set(Ge.offsetU||0,Ge.offsetV||0),Oe.repeat.set(Ge.repeatU||1,Ge.repeatV||1)}else Oe.wrapS=on,Oe.wrapT=on;return ke!==null&&(Oe.encoding=ke),Oe}else return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",Me),null}else return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",Le.id),null}const se=L.parameters;for(const Le in se){const ke=se[Le];switch(Le){case"diffuse":ke.color&&A.color.fromArray(ke.color),ke.texture&&(A.map=I(ke.texture,nt));break;case"specular":ke.color&&A.specular&&A.specular.fromArray(ke.color),ke.texture&&(A.specularMap=I(ke.texture));break;case"bump":ke.texture&&(A.normalMap=I(ke.texture));break;case"ambient":ke.texture&&(A.lightMap=I(ke.texture,nt));break;case"shininess":ke.float&&A.shininess&&(A.shininess=ke.float);break;case"emission":ke.color&&A.emissive&&A.emissive.fromArray(ke.color),ke.texture&&(A.emissiveMap=I(ke.texture,nt));break}}A.color.convertSRGBToLinear(),A.specular&&A.specular.convertSRGBToLinear(),A.emissive&&A.emissive.convertSRGBToLinear();let de=se.transparent,Ne=se.transparency;if(Ne===void 0&&de&&(Ne={float:1}),de===void 0&&Ne&&(de={opaque:"A_ONE",data:{color:[1,1,1,1]}}),de&&Ne)if(de.data.texture)A.transparent=!0;else{const Le=de.data.color;switch(de.opaque){case"A_ONE":A.opacity=Le[3]*Ne.float;break;case"RGB_ZERO":A.opacity=1-Le[0]*Ne.float;break;case"A_ZERO":A.opacity=1-Le[3]*Ne.float;break;case"RGB_ONE":A.opacity=Le[0]*Ne.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',de.opaque)}A.opacity<1&&(A.transparent=!0)}if(L.extra!==void 0&&L.extra.technique!==void 0){const Le=L.extra.technique;for(const ke in Le){const Ue=Le[ke];switch(ke){case"double_sided":A.side=Ue===1?ai:oi;break;case"bump":A.normalMap=I(Ue.texture),A.normalScale=new fe(1,1);break}}}return A}function me(S){return m(Ye.materials[S],Q)}function R(S){const w={name:S.getAttribute("name")};for(let L=0,A=S.childNodes.length;L0?de+Le:de;w.inputs[ke]={id:se,offset:Ne},w.stride=Math.max(w.stride,Ne+1),de==="TEXCOORD"&&(w.hasUV=!0);break;case"vcount":w.vcount=r(I.textContent);break;case"p":w.p=r(I.textContent);break}}return w}function Lt(S){const w={};for(let L=0;L0&&w0&&Me.setAttribute("position",new Ae(I.array,I.stride)),se.array.length>0&&Me.setAttribute("normal",new Ae(se.array,se.stride)),Le.array.length>0&&Me.setAttribute("color",new Ae(Le.array,Le.stride)),de.array.length>0&&Me.setAttribute("uv",new Ae(de.array,de.stride)),Ne.array.length>0&&Me.setAttribute("uv2",new Ae(Ne.array,Ne.stride)),ke.array.length>0&&Me.setAttribute("skinIndex",new Ae(ke.array,ke.stride)),Ue.array.length>0&&Me.setAttribute("skinWeight",new Ae(Ue.array,Ue.stride)),A.data=Me,A.type=S[0].type,A.materialKeys=We,A}function Tt(S,w,L,A,I=!1){const se=S.p,de=S.stride,Ne=S.vcount;function Le(Me){let We=se[Me+L]*Ue;const Oe=We+Ue;for(;We4)for(let Ge=1,It=Xe-2;Ge<=It;Ge++){const _t=Me+de*0,gt=Me+de*Ge,yt=Me+de*(Ge+1);Le(_t),Le(gt),Le(yt)}Me+=de*Xe}}else for(let Me=0,We=se.length;Me=w.limits.max&&(w.static=!0),w.middlePosition=(w.limits.min+w.limits.max)/2,w}function ee(S){const w={sid:S.getAttribute("sid"),name:S.getAttribute("name")||"",attachments:[],transforms:[]};for(let L=0;LOe.limits.max||Me=2.0 are supported."));return}const l=new mM(c,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u=0&&o[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(r),l.setPlugins(o),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function Vw(){let a={};return{get:function(e){return a[e]},add:function(e,t){a[e]=t},remove:function(e){delete a[e]},removeAll:function(){a={}}}}const ot={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class Hw{constructor(e){this.parser=e,this.name=ot.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,r)}}class eM{constructor(e){this.parser=e,this.name=ot.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const r=s.extensions[t],o=i.images[r.source];let c=n.textureLoader;if(o.uri){const l=n.options.manager.getHandler(o.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return n.loadTextureImage(e,r.source,c);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class tM{constructor(e){this.name=ot.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([s,r.ready]).then(function(o){const c=i.byteOffset||0,l=i.byteLength||0,u=i.count,h=i.byteStride,f=new ArrayBuffer(u*h),d=new Uint8Array(o[0],c,l);return r.decodeGltfBuffer(new Uint8Array(f),u,h,d,i.mode,i.filter),f})}else return null}}const Rm="glTF",Wo=12,Im={JSON:1313821514,BIN:5130562};class nM{constructor(e){this.name=ot.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Wo);if(this.header={magic:tn.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Rm)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-Wo,i=new DataView(e,Wo);let s=0;for(;s",t).replace("#include ",n).replace("#include ",i).replace("#include ",s).replace("#include ",r)},Object.defineProperties(this,{specular:{get:function(){return o.specular.value},set:function(c){o.specular.value=c}},specularMap:{get:function(){return o.specularMap.value},set:function(c){o.specularMap.value=c,c?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return o.glossiness.value},set:function(c){o.glossiness.value=c}},glossinessMap:{get:function(){return o.glossinessMap.value},set:function(c){o.glossinessMap.value=c,c?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class rM{constructor(){this.name=rt.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return sh}extendParams(e,t,n){const i=t.extensions[this.name];e.color=new ve(1,1,1),e.opacity=1;const s=[];if(Array.isArray(i.diffuseFactor)){const r=i.diffuseFactor;e.color.fromArray(r),e.opacity=r[3]}if(i.diffuseTexture!==void 0&&s.push(n.assignTexture(e,"map",i.diffuseTexture,tt)),e.emissive=new ve(0,0,0),e.glossiness=i.glossinessFactor!==void 0?i.glossinessFactor:1,e.specular=new ve(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),i.specularGlossinessTexture!==void 0){const r=i.specularGlossinessTexture;s.push(n.assignTexture(e,"glossinessMap",r)),s.push(n.assignTexture(e,"specularMap",r,tt))}return Promise.all(s)}createMaterial(e){const t=new sh(e);return t.fog=!0,t.color=e.color,t.map=e.map===void 0?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=e.aoMap===void 0?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=e.emissiveIntensity===void 0?1:e.emissiveIntensity,t.emissiveMap=e.emissiveMap===void 0?null:e.emissiveMap,t.bumpMap=e.bumpMap===void 0?null:e.bumpMap,t.bumpScale=1,t.normalMap=e.normalMap===void 0?null:e.normalMap,t.normalMapType=Fi,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=e.specularMap===void 0?null:e.specularMap,t.specular=e.specular,t.glossinessMap=e.glossinessMap===void 0?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=e.envMap===void 0?null:e.envMap,t.envMapIntensity=1,t}}class oM{constructor(){this.name=rt.KHR_MESH_QUANTIZATION}}class Pm extends Fr{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let r=0;r!==i;r++)t[r]=n[s+r];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=o*2,l=o*3,u=i-t,h=(n-t)/u,f=h*h,d=f*h,p=e*l,m=p-l,g=-2*d+3*f,x=d-f,y=1-g,b=x-f+h;for(let v=0;v!==o;v++){const S=r[m+v+o],A=r[m+v+c]*u,R=r[p+v+o],_=r[p+v]*u;s[v]=y*S+b*A+g*R+x*_}return s}}const aM=new Pt;class cM extends Pm{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return aM.fromArray(s).normalize().toArray(s),s}}const Ai={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},qo={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Dm={9728:kt,9729:Et,9984:eo,9985:Qo,9986:to,9987:jn},Fm={33071:Wt,33648:js,10497:on},Nm={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},rh={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},ts={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},lM={CUBICSPLINE:void 0,LINEAR:ls,STEP:Zs},oh={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function uM(a){return a.DefaultMaterial===void 0&&(a.DefaultMaterial=new Cs({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:oi})),a.DefaultMaterial}function Xo(a,e,t){for(const n in t.extensions)a[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Vs(a,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(a.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function hM(a,e,t){let n=!1,i=!1,s=!1;for(let l=0,u=e.length;l0||a.search(/^data\:image\/jpeg/)===0?"image/jpeg":a.search(/\.webp($|\?)/i)>0||a.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}class mM{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Vw,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};const n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,i=navigator.userAgent.indexOf("Firefox")>-1,s=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1;typeof createImageBitmap=="undefined"||n||i&&s<98?this.textureLoader=new Fs(this.options.manager):this.textureLoader=new mp(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Zt(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(r){const o={scene:r[0][i.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:i.asset,parser:n,userData:{}};Xo(s,o,i),Vs(o,i),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(o)})).then(function(){e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i{const c=this.associations.get(r);c!=null&&this.associations.set(o,c);for(const[l,u]of r.children.entries())s(u,o.children[l])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&g.setY(L,A[R*c+1]),c>=3&&g.setZ(L,A[R*c+2]),c>=4&&g.setW(L,A[R*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return g})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,r=t.images[s];let o=this.textureLoader;if(r.uri){const c=n.manager.getHandler(r.uri);c!==null&&(o=c)}return this.loadTextureImage(e,s,o)}loadTextureImage(e,t,n){const i=this,s=this.json,r=s.textures[e],o=s.images[t],c=(o.uri||o.bufferView)+":"+r.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(t,n).then(function(u){u.flipY=!1,r.name&&(u.name=r.name);const f=(s.samplers||{})[r.sampler]||{};return u.magFilter=Dm[f.magFilter]||Et,u.minFilter=Dm[f.minFilter]||jn,u.wrapS=Fm[f.wrapS]||on,u.wrapT=Fm[f.wrapT]||on,i.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const r=i.images[e],o=self.URL||self.webkitURL;let c=r.uri||"",l=!1;if(r.bufferView!==void 0)c=n.getDependency("bufferView",r.bufferView).then(function(h){l=!0;const f=new Blob([h],{type:r.mimeType});return c=o.createObjectURL(f),c});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(c).then(function(h){return new Promise(function(f,d){let p=f;t.isImageBitmapLoader===!0&&(p=function(m){const g=new Mt(m);g.needsUpdate=!0,f(g)}),t.load(tn.resolveURL(h,s.path),p,void 0,d)})}).then(function(h){return l===!0&&o.revokeObjectURL(c),h.userData.mimeType=r.mimeType||pM(r.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),h});return this.sourceCache[e]=u,u}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(r){if(n.texCoord!==void 0&&n.texCoord!=0&&!(t==="aoMap"&&n.texCoord==1)&&console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+t+" not yet supported."),s.extensions[rt.KHR_TEXTURE_TRANSFORM]){const o=n.extensions!==void 0?n.extensions[rt.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const c=s.associations.get(r);r=s.extensions[rt.KHR_TEXTURE_TRANSFORM].extendTexture(r,o),s.associations.set(r,c)}}return i!==void 0&&(r.encoding=i),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+n.uuid;let c=this.cache.get(o);c||(c=new Xi,Bt.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(o,c)),n=c}else if(e.isLine){const o="LineBasicMaterial:"+n.uuid;let c=this.cache.get(o);c||(c=new zt,Bt.prototype.copy.call(c,n),c.color.copy(n.color),this.cache.add(o,c)),n=c}if(i||s||r){let o="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(o+="specular-glossiness:"),i&&(o+="derivative-tangents:"),s&&(o+="vertex-colors:"),r&&(o+="flat-shading:");let c=this.cache.get(o);c||(c=n.clone(),s&&(c.vertexColors=!0),r&&(c.flatShading=!0),i&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(o,c),this.associations.set(c,this.associations.get(n))),n=c}n.aoMap&&t.attributes.uv2===void 0&&t.attributes.uv!==void 0&&t.setAttribute("uv2",t.attributes.uv),e.material=n}getMaterialType(){return Cs}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let r;const o={},c=s.extensions||{},l=[];if(c[rt.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const h=i[rt.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];r=h.getMaterialType(),l.push(h.extendParams(o,s,t))}else if(c[rt.KHR_MATERIALS_UNLIT]){const h=i[rt.KHR_MATERIALS_UNLIT];r=h.getMaterialType(),l.push(h.extendParams(o,s,t))}else{const h=s.pbrMetallicRoughness||{};if(o.color=new ve(1,1,1),o.opacity=1,Array.isArray(h.baseColorFactor)){const f=h.baseColorFactor;o.color.fromArray(f),o.opacity=f[3]}h.baseColorTexture!==void 0&&l.push(t.assignTexture(o,"map",h.baseColorTexture,tt)),o.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,o.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(o,"metalnessMap",h.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",h.metallicRoughnessTexture))),r=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,o)})))}s.doubleSided===!0&&(o.side=ai);const u=s.alphaMode||oh.OPAQUE;if(u===oh.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,u===oh.MASK&&(o.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&r!==cn&&(l.push(t.assignTexture(o,"normalMap",s.normalTexture)),o.normalScale=new he(1,1),s.normalTexture.scale!==void 0)){const h=s.normalTexture.scale;o.normalScale.set(h,h)}return s.occlusionTexture!==void 0&&r!==cn&&(l.push(t.assignTexture(o,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&r!==cn&&(o.emissive=new ve().fromArray(s.emissiveFactor)),s.emissiveTexture!==void 0&&r!==cn&&l.push(t.assignTexture(o,"emissiveMap",s.emissiveTexture,tt)),Promise.all(l).then(function(){let h;return r===sh?h=i[rt.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(o):h=new r(o),s.name&&(h.name=s.name),Vs(h,s),t.associations.set(h,{materials:e}),s.extensions&&Xo(i,h,s),h})}createUniqueName(e){const t=it.sanitizeNodeName(e||"");let n=t;for(let i=1;this.nodeNamesUsed[n];++i)n=t+"_"+i;return this.nodeNamesUsed[n]=!0,n}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(o){return n[rt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(c){return Bm(c,o,t)})}const r=[];for(let o=0,c=e.length;o0&&fM(x,s),x.name=t.createUniqueName(s.name||"mesh_"+e),Vs(x,s),g.extensions&&Xo(i,x,g),t.assignFinalMaterial(x),h.push(x)}for(let d=0,p=h.length;d1?c=new dn:o.length===1?c=o[0]:c=new ct,c!==o[0])for(let l=0,u=o.length;l{const h=new Map;for(const[f,d]of s.associations)(f instanceof Bt||f instanceof Mt)&&h.set(f,d);return u.traverse(f=>{const d=s.associations.get(f);d!=null&&h.set(f,d)}),h};return s.associations=l(r),r})}}function Om(a,e,t,n){const i=t.nodes[a];return n.getDependency("node",a).then(function(s){if(i.skin===void 0)return s;let r;return n.getDependency("skin",i.skin).then(function(o){r=o;const c=[];for(let l=0,u=r.joints.length;l0?s[s.length-1]:"",smooth:r!==void 0?r.smooth:this.smooth,groupStart:r!==void 0?r.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(c){const l={index:typeof c=="number"?c:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return l.clone=this.clone.bind(l),l}};return this.materials.push(o),o},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(i){const s=this.currentMaterial();if(s&&s.groupEnd===-1&&(s.groupEnd=this.geometry.vertices.length/3,s.groupCount=s.groupEnd-s.groupStart,s.inherited=!1),i&&this.materials.length>1)for(let r=this.materials.length-1;r>=0;r--)this.materials[r].groupCount<=0&&this.materials.splice(r,1);return i&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),s}},n&&n.name&&typeof n.clone=="function"){const i=n.clone(0);i.inherited=!0,this.object.materials.push(i)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){const i=this.vertices,s=this.object.geometry.vertices;s.push(i[e+0],i[e+1],i[e+2]),s.push(i[t+0],i[t+1],i[t+2]),s.push(i[n+0],i[n+1],i[n+2])},addVertexPoint:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){const i=this.normals,s=this.object.geometry.normals;s.push(i[e+0],i[e+1],i[e+2]),s.push(i[t+0],i[t+1],i[t+2]),s.push(i[n+0],i[n+1],i[n+2])},addFaceNormal:function(e,t,n){const i=this.vertices,s=this.object.geometry.normals;Gm.fromArray(i,e),ch.fromArray(i,t),Vm.fromArray(i,n),On.subVectors(Vm,ch),Hm.subVectors(Gm,ch),On.cross(Hm),On.normalize(),s.push(On.x,On.y,On.z),s.push(On.x,On.y,On.z),s.push(On.x,On.y,On.z)},addColor:function(e,t,n){const i=this.colors,s=this.object.geometry.colors;i[e]!==void 0&&s.push(i[e+0],i[e+1],i[e+2]),i[t]!==void 0&&s.push(i[t+0],i[t+1],i[t+2]),i[n]!==void 0&&s.push(i[n+0],i[n+1],i[n+2])},addUV:function(e,t,n){const i=this.uvs,s=this.object.geometry.uvs;s.push(i[e+0],i[e+1]),s.push(i[t+0],i[t+1]),s.push(i[n+0],i[n+1])},addDefaultUV:function(){const e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){const t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,i,s,r,o,c,l){const u=this.vertices.length;let h=this.parseVertexIndex(e,u),f=this.parseVertexIndex(t,u),d=this.parseVertexIndex(n,u);if(this.addVertex(h,f,d),this.addColor(h,f,d),o!==void 0&&o!==""){const p=this.normals.length;h=this.parseNormalIndex(o,p),f=this.parseNormalIndex(c,p),d=this.parseNormalIndex(l,p),this.addNormal(h,f,d)}else this.addFaceNormal(h,f,d);if(i!==void 0&&i!==""){const p=this.uvs.length;h=this.parseUVIndex(i,p),f=this.parseUVIndex(s,p),d=this.parseUVIndex(r,p),this.addUV(h,f,d),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";const t=this.vertices.length;for(let n=0,i=e.length;n",t).replace("#include ",n).replace("#include ",i).replace("#include ",s).replace("#include ",r)},Object.defineProperties(this,{specular:{get:function(){return o.specular.value},set:function(c){o.specular.value=c}},specularMap:{get:function(){return o.specularMap.value},set:function(c){o.specularMap.value=c,c?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return o.glossiness.value},set:function(c){o.glossiness.value=c}},glossinessMap:{get:function(){return o.glossinessMap.value},set:function(c){o.glossinessMap.value=c,c?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class rM{constructor(){this.name=ot.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return rh}extendParams(e,t,n){const i=t.extensions[this.name];e.color=new be(1,1,1),e.opacity=1;const s=[];if(Array.isArray(i.diffuseFactor)){const r=i.diffuseFactor;e.color.fromArray(r),e.opacity=r[3]}if(i.diffuseTexture!==void 0&&s.push(n.assignTexture(e,"map",i.diffuseTexture,nt)),e.emissive=new be(0,0,0),e.glossiness=i.glossinessFactor!==void 0?i.glossinessFactor:1,e.specular=new be(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),i.specularGlossinessTexture!==void 0){const r=i.specularGlossinessTexture;s.push(n.assignTexture(e,"glossinessMap",r)),s.push(n.assignTexture(e,"specularMap",r,nt))}return Promise.all(s)}createMaterial(e){const t=new rh(e);return t.fog=!0,t.color=e.color,t.map=e.map===void 0?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=e.aoMap===void 0?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=e.emissiveIntensity===void 0?1:e.emissiveIntensity,t.emissiveMap=e.emissiveMap===void 0?null:e.emissiveMap,t.bumpMap=e.bumpMap===void 0?null:e.bumpMap,t.bumpScale=1,t.normalMap=e.normalMap===void 0?null:e.normalMap,t.normalMapType=Fi,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=e.specularMap===void 0?null:e.specularMap,t.specular=e.specular,t.glossinessMap=e.glossinessMap===void 0?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=e.envMap===void 0?null:e.envMap,t.envMapIntensity=1,t}}class oM{constructor(){this.name=ot.KHR_MESH_QUANTIZATION}}class Pm extends Fr{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let r=0;r!==i;r++)t[r]=n[s+r];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=o*2,l=o*3,u=i-t,h=(n-t)/u,f=h*h,d=f*h,p=e*l,m=p-l,g=-2*d+3*f,x=d-f,y=1-g,b=x-f+h;for(let v=0;v!==o;v++){const M=r[m+v+o],T=r[m+v+c]*u,C=r[p+v+o],_=r[p+v]*u;s[v]=y*M+b*T+g*C+x*_}return s}}const aM=new Pt;class cM extends Pm{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return aM.fromArray(s).normalize().toArray(s),s}}const Ai={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},qo={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Dm={9728:kt,9729:Et,9984:eo,9985:Qo,9986:to,9987:jn},Fm={33071:Wt,33648:js,10497:on},Nm={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},oh={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},ts={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},lM={CUBICSPLINE:void 0,LINEAR:ls,STEP:Zs},ah={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function uM(a){return a.DefaultMaterial===void 0&&(a.DefaultMaterial=new Cs({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:oi})),a.DefaultMaterial}function Xo(a,e,t){for(const n in t.extensions)a[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Vs(a,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(a.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function hM(a,e,t){let n=!1,i=!1,s=!1;for(let l=0,u=e.length;l0||a.search(/^data\:image\/jpeg/)===0?"image/jpeg":a.search(/\.webp($|\?)/i)>0||a.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}class mM{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Vw,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};const n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,i=navigator.userAgent.indexOf("Firefox")>-1,s=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1;typeof createImageBitmap=="undefined"||n||i&&s<98?this.textureLoader=new Fs(this.options.manager):this.textureLoader=new gp(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Zt(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(r){const o={scene:r[0][i.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:i.asset,parser:n,userData:{}};Xo(s,o,i),Vs(o,i),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(o)})).then(function(){e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i{const c=this.associations.get(r);c!=null&&this.associations.set(o,c);for(const[l,u]of r.children.entries())s(u,o.children[l])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&g.setY(E,T[C*c+1]),c>=3&&g.setZ(E,T[C*c+2]),c>=4&&g.setW(E,T[C*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return g})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,r=t.images[s];let o=this.textureLoader;if(r.uri){const c=n.manager.getHandler(r.uri);c!==null&&(o=c)}return this.loadTextureImage(e,s,o)}loadTextureImage(e,t,n){const i=this,s=this.json,r=s.textures[e],o=s.images[t],c=(o.uri||o.bufferView)+":"+r.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(t,n).then(function(u){u.flipY=!1,r.name&&(u.name=r.name);const f=(s.samplers||{})[r.sampler]||{};return u.magFilter=Dm[f.magFilter]||Et,u.minFilter=Dm[f.minFilter]||jn,u.wrapS=Fm[f.wrapS]||on,u.wrapT=Fm[f.wrapT]||on,i.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const r=i.images[e],o=self.URL||self.webkitURL;let c=r.uri||"",l=!1;if(r.bufferView!==void 0)c=n.getDependency("bufferView",r.bufferView).then(function(h){l=!0;const f=new Blob([h],{type:r.mimeType});return c=o.createObjectURL(f),c});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(c).then(function(h){return new Promise(function(f,d){let p=f;t.isImageBitmapLoader===!0&&(p=function(m){const g=new Mt(m);g.needsUpdate=!0,f(g)}),t.load(tn.resolveURL(h,s.path),p,void 0,d)})}).then(function(h){return l===!0&&o.revokeObjectURL(c),h.userData.mimeType=r.mimeType||pM(r.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),h});return this.sourceCache[e]=u,u}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(r){if(n.texCoord!==void 0&&n.texCoord!=0&&!(t==="aoMap"&&n.texCoord==1)&&console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+t+" not yet supported."),s.extensions[ot.KHR_TEXTURE_TRANSFORM]){const o=n.extensions!==void 0?n.extensions[ot.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const c=s.associations.get(r);r=s.extensions[ot.KHR_TEXTURE_TRANSFORM].extendTexture(r,o),s.associations.set(r,c)}}return i!==void 0&&(r.encoding=i),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+n.uuid;let c=this.cache.get(o);c||(c=new Xi,Bt.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(o,c)),n=c}else if(e.isLine){const o="LineBasicMaterial:"+n.uuid;let c=this.cache.get(o);c||(c=new zt,Bt.prototype.copy.call(c,n),c.color.copy(n.color),this.cache.add(o,c)),n=c}if(i||s||r){let o="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(o+="specular-glossiness:"),i&&(o+="derivative-tangents:"),s&&(o+="vertex-colors:"),r&&(o+="flat-shading:");let c=this.cache.get(o);c||(c=n.clone(),s&&(c.vertexColors=!0),r&&(c.flatShading=!0),i&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(o,c),this.associations.set(c,this.associations.get(n))),n=c}n.aoMap&&t.attributes.uv2===void 0&&t.attributes.uv!==void 0&&t.setAttribute("uv2",t.attributes.uv),e.material=n}getMaterialType(){return Cs}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let r;const o={},c=s.extensions||{},l=[];if(c[ot.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const h=i[ot.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];r=h.getMaterialType(),l.push(h.extendParams(o,s,t))}else if(c[ot.KHR_MATERIALS_UNLIT]){const h=i[ot.KHR_MATERIALS_UNLIT];r=h.getMaterialType(),l.push(h.extendParams(o,s,t))}else{const h=s.pbrMetallicRoughness||{};if(o.color=new be(1,1,1),o.opacity=1,Array.isArray(h.baseColorFactor)){const f=h.baseColorFactor;o.color.fromArray(f),o.opacity=f[3]}h.baseColorTexture!==void 0&&l.push(t.assignTexture(o,"map",h.baseColorTexture,nt)),o.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,o.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(o,"metalnessMap",h.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",h.metallicRoughnessTexture))),r=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,o)})))}s.doubleSided===!0&&(o.side=ai);const u=s.alphaMode||ah.OPAQUE;if(u===ah.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,u===ah.MASK&&(o.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&r!==cn&&(l.push(t.assignTexture(o,"normalMap",s.normalTexture)),o.normalScale=new fe(1,1),s.normalTexture.scale!==void 0)){const h=s.normalTexture.scale;o.normalScale.set(h,h)}return s.occlusionTexture!==void 0&&r!==cn&&(l.push(t.assignTexture(o,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&r!==cn&&(o.emissive=new be().fromArray(s.emissiveFactor)),s.emissiveTexture!==void 0&&r!==cn&&l.push(t.assignTexture(o,"emissiveMap",s.emissiveTexture,nt)),Promise.all(l).then(function(){let h;return r===rh?h=i[ot.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(o):h=new r(o),s.name&&(h.name=s.name),Vs(h,s),t.associations.set(h,{materials:e}),s.extensions&&Xo(i,h,s),h})}createUniqueName(e){const t=st.sanitizeNodeName(e||"");let n=t;for(let i=1;this.nodeNamesUsed[n];++i)n=t+"_"+i;return this.nodeNamesUsed[n]=!0,n}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(o){return n[ot.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(c){return Bm(c,o,t)})}const r=[];for(let o=0,c=e.length;o0&&fM(x,s),x.name=t.createUniqueName(s.name||"mesh_"+e),Vs(x,s),g.extensions&&Xo(i,x,g),t.assignFinalMaterial(x),h.push(x)}for(let d=0,p=h.length;d1?c=new dn:o.length===1?c=o[0]:c=new lt,c!==o[0])for(let l=0,u=o.length;l{const h=new Map;for(const[f,d]of s.associations)(f instanceof Bt||f instanceof Mt)&&h.set(f,d);return u.traverse(f=>{const d=s.associations.get(f);d!=null&&h.set(f,d)}),h};return s.associations=l(r),r})}}function Om(a,e,t,n){const i=t.nodes[a];return n.getDependency("node",a).then(function(s){if(i.skin===void 0)return s;let r;return n.getDependency("skin",i.skin).then(function(o){r=o;const c=[];for(let l=0,u=r.joints.length;l0?s[s.length-1]:"",smooth:r!==void 0?r.smooth:this.smooth,groupStart:r!==void 0?r.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(c){const l={index:typeof c=="number"?c:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return l.clone=this.clone.bind(l),l}};return this.materials.push(o),o},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(i){const s=this.currentMaterial();if(s&&s.groupEnd===-1&&(s.groupEnd=this.geometry.vertices.length/3,s.groupCount=s.groupEnd-s.groupStart,s.inherited=!1),i&&this.materials.length>1)for(let r=this.materials.length-1;r>=0;r--)this.materials[r].groupCount<=0&&this.materials.splice(r,1);return i&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),s}},n&&n.name&&typeof n.clone=="function"){const i=n.clone(0);i.inherited=!0,this.object.materials.push(i)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){const i=this.vertices,s=this.object.geometry.vertices;s.push(i[e+0],i[e+1],i[e+2]),s.push(i[t+0],i[t+1],i[t+2]),s.push(i[n+0],i[n+1],i[n+2])},addVertexPoint:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){const i=this.normals,s=this.object.geometry.normals;s.push(i[e+0],i[e+1],i[e+2]),s.push(i[t+0],i[t+1],i[t+2]),s.push(i[n+0],i[n+1],i[n+2])},addFaceNormal:function(e,t,n){const i=this.vertices,s=this.object.geometry.normals;Gm.fromArray(i,e),lh.fromArray(i,t),Vm.fromArray(i,n),On.subVectors(Vm,lh),Hm.subVectors(Gm,lh),On.cross(Hm),On.normalize(),s.push(On.x,On.y,On.z),s.push(On.x,On.y,On.z),s.push(On.x,On.y,On.z)},addColor:function(e,t,n){const i=this.colors,s=this.object.geometry.colors;i[e]!==void 0&&s.push(i[e+0],i[e+1],i[e+2]),i[t]!==void 0&&s.push(i[t+0],i[t+1],i[t+2]),i[n]!==void 0&&s.push(i[n+0],i[n+1],i[n+2])},addUV:function(e,t,n){const i=this.uvs,s=this.object.geometry.uvs;s.push(i[e+0],i[e+1]),s.push(i[t+0],i[t+1]),s.push(i[n+0],i[n+1])},addDefaultUV:function(){const e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){const t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,i,s,r,o,c,l){const u=this.vertices.length;let h=this.parseVertexIndex(e,u),f=this.parseVertexIndex(t,u),d=this.parseVertexIndex(n,u);if(this.addVertex(h,f,d),this.addColor(h,f,d),o!==void 0&&o!==""){const p=this.normals.length;h=this.parseNormalIndex(o,p),f=this.parseNormalIndex(c,p),d=this.parseNormalIndex(l,p),this.addNormal(h,f,d)}else this.addFaceNormal(h,f,d);if(i!==void 0&&i!==""){const p=this.uvs.length;h=this.parseUVIndex(i,p),f=this.parseUVIndex(s,p),d=this.parseUVIndex(r,p),this.addUV(h,f,d),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";const t=this.vertices.length;for(let n=0,i=e.length;n=7?(Mc.setRGB(parseFloat(h[4]),parseFloat(h[5]),parseFloat(h[6])).convertSRGBToLinear(),t.colors.push(Mc.r,Mc.g,Mc.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3]));break;case"vt":t.uvs.push(parseFloat(h[1]),parseFloat(h[2]));break}}else if(u==="f"){const f=l.slice(1).trim().split(Um),d=[];for(let m=0,g=f.length;m0){const y=x.split("/");d.push(y)}}const p=d[0];for(let m=1,g=d.length-1;m1){const f=i[1].trim().toLowerCase();t.object.smooth=f!=="0"&&f!=="off"}else t.object.smooth=!0;const h=t.object.currentMaterial();h&&(h.smooth=t.object.smooth)}else{if(l==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+l+'"')}}t.finalize();const s=new dn;if(s.materialLibraries=[].concat(t.materialLibraries),!(t.objects.length===1&&t.objects[0].geometry.vertices.length===0)===!0)for(let o=0,c=t.objects.length;o0&&m.setAttribute("normal",new we(u.normals,3)),u.colors.length>0&&(p=!0,m.setAttribute("color",new we(u.colors,3))),u.hasUVIndices===!0&&m.setAttribute("uv",new we(u.uvs,2));const g=[];for(let y=0,b=h.length;y1){for(let y=0,b=h.length;y0){const o=new Xi({size:1,sizeAttenuation:!1}),c=new qe;c.setAttribute("position",new we(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(c.setAttribute("color",new we(t.colors,3)),o.vertexColors=!0);const l=new _r(c,o);s.add(l)}return s}}class MM extends np{constructor(e){super(e)}parse(e,t){const n={mipmaps:[],width:0,height:0,format:null,mipmapCount:1},i=542327876,s=131072,r=512,o=1024,c=2048,l=4096,u=8192,h=16384,f=32768;function d(se){return se.charCodeAt(0)+(se.charCodeAt(1)<<8)+(se.charCodeAt(2)<<16)+(se.charCodeAt(3)<<24)}function p(se){return String.fromCharCode(se&255,se>>8&255,se>>16&255,se>>24&255)}function m(se,V,me,_e){const Pe=me*_e*4,ye=new Uint8Array(se,V,Pe),He=new Uint8Array(Pe);let le=0,ce=0;for(let xe=0;xe<_e;xe++)for(let Fe=0;Fe>1,1),me=Math.max(me>>1,1)}}return n}}class SM{constructor(e,t,n){const i=this;let s=!1,r=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,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 c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,h){return l.push(u,h),this},this.removeHandler=function(u){const h=l.indexOf(u);return h!==-1&&l.splice(h,2),this},this.getHandler=function(u){for(let h=0,f=l.length;h=p.elements[v].count&&(v++,S=0);const _=i(p.elements[v].properties,R);o(m,p.elements[v].name,_),S++}return r(m)}function r(d){let p=new qe;return d.indices.length>0&&p.setIndex(d.indices),p.setAttribute("position",new we(d.vertices,3)),d.normals.length>0&&p.setAttribute("normal",new we(d.normals,3)),d.uvs.length>0&&p.setAttribute("uv",new we(d.uvs,2)),d.colors.length>0&&p.setAttribute("color",new we(d.colors,3)),d.faceVertexUvs.length>0&&(p=p.toNonIndexed(),p.setAttribute("uv",new we(d.faceVertexUvs,2))),p.computeBoundingSphere(),p}function o(d,p,m){function g(W){for(let K=0,z=W.length;K>5&31)/31,p=(q>>10&31)/31):(f=x,d=y,p=b)}for(let q=1;q<=3;q++){const O=B+q*12,Y=N*3*3+(q-1)*3;_[Y]=u.getFloat32(O,!0),_[Y+1]=u.getFloat32(O+4,!0),_[Y+2]=u.getFloat32(O+8,!0),L[Y]=W,L[Y+1]=K,L[Y+2]=z,m&&(g[Y]=f,g[Y+1]=d,g[Y+2]=p)}}return R.setAttribute("position",new ht(_,3)),R.setAttribute("normal",new ht(L,3)),m&&(R.setAttribute("color",new ht(g,3)),R.hasColors=!0,R.alpha=v),R}function s(l){const u=new qe,h=/solid([\s\S]*?)endsolid/g,f=/facet([\s\S]*?)endfacet/g;let d=0;const p=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,m=new RegExp("vertex"+p+p+p,"g"),g=new RegExp("normal"+p+p+p,"g"),x=[],y=[],b=new D;let v,S=0,A=0,R=0;for(;(v=h.exec(l))!==null;){A=R;const _=v[0];for(;(v=f.exec(_))!==null;){let B=0,W=0;const K=v[0];for(;(v=g.exec(K))!==null;)b.x=parseFloat(v[1]),b.y=parseFloat(v[2]),b.z=parseFloat(v[3]),W++;for(;(v=m.exec(K))!==null;)x.push(parseFloat(v[1]),parseFloat(v[2]),parseFloat(v[3])),y.push(b.x,b.y,b.z),B++,R++;W!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+d),B!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+d),d++}const L=A,N=R-A;u.addGroup(L,N,S),S++}return u.setAttribute("position",new we(x,3)),u.setAttribute("normal",new we(y,3)),u}function r(l){return typeof l!="string"?tn.decodeText(new Uint8Array(l)):l}function o(l){if(typeof l=="string"){const u=new Uint8Array(l.length);for(let h=0;h=0?l.substring(0,u):l;h=h.toLowerCase();let f=u>=0?l.substring(u+1):"";if(f=f.trim(),h==="newmtl")i={name:f},r[f]=i;else if(h==="ka"||h==="kd"||h==="ks"||h==="ke"){const d=f.split(s,3);i[h]=[parseFloat(d[0]),parseFloat(d[1]),parseFloat(d[2])]}else i[h]=f}const o=new CM(this.resourcePath||t,this.materialOptions);return o.setCrossOrigin(this.crossOrigin),o.setManager(this.manager),o.setMaterials(r),o}}class CM{constructor(e="",t={}){this.baseUrl=e,this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.crossOrigin="anonymous",this.side=this.options.side!==void 0?this.options.side:oi,this.wrap=this.options.wrap!==void 0?this.options.wrap:on}setCrossOrigin(e){return this.crossOrigin=e,this}setManager(e){this.manager=e}setMaterials(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}}convert(e){if(!this.options)return e;const t={};for(const n in e){const i=e[n],s={};t[n]=s;for(const r in i){let o=!0,c=i[r];const l=r.toLowerCase();switch(l){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(c=[c[0]/255,c[1]/255,c[2]/255]),this.options&&this.options.ignoreZeroRGBs&&c[0]===0&&c[1]===0&&c[2]===0&&(o=!1);break}o&&(s[l]=c)}}return t}preload(){for(const e in this.materialsInfo)this.create(e)}getIndex(e){return this.nameLookup[e]}getAsArray(){let e=0;for(const t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray}create(e){return this.materials[e]===void 0&&this.createMaterial_(e),this.materials[e]}createMaterial_(e){const t=this,n=this.materialsInfo[e],i={name:e,side:this.side};function s(o,c){return typeof c!="string"||c===""?"":/^https?:\/\//i.test(c)?c:o+c}function r(o,c){if(i[o])return;const l=t.getTextureParams(c,i),u=t.loadTexture(s(t.baseUrl,l.url));u.repeat.copy(l.scale),u.offset.copy(l.offset),u.wrapS=t.wrap,u.wrapT=t.wrap,(o==="map"||o==="emissiveMap")&&(u.encoding=tt),i[o]=u}for(const o in n){const c=n[o];let l;if(c!=="")switch(o.toLowerCase()){case"kd":i.color=new ve().fromArray(c).convertSRGBToLinear();break;case"ks":i.specular=new ve().fromArray(c).convertSRGBToLinear();break;case"ke":i.emissive=new ve().fromArray(c).convertSRGBToLinear();break;case"map_kd":r("map",c);break;case"map_ks":r("specularMap",c);break;case"map_ke":r("emissiveMap",c);break;case"norm":r("normalMap",c);break;case"map_bump":case"bump":r("bumpMap",c);break;case"map_d":r("alphaMap",c),i.transparent=!0;break;case"ns":i.shininess=parseFloat(c);break;case"d":l=parseFloat(c),l<1&&(i.opacity=l,i.transparent=!0);break;case"tr":l=parseFloat(c),this.options&&this.options.invertTrProperty&&(l=1-l),l>0&&(i.opacity=1-l,i.transparent=!0);break}}return this.materials[e]=new Qn(i),this.materials[e]}getTextureParams(e,t){const n={scale:new he(1,1),offset:new he(0,0)},i=e.split(/\s+/);let s;return s=i.indexOf("-bm"),s>=0&&(t.bumpScale=parseFloat(i[s+1]),i.splice(s,2)),s=i.indexOf("-s"),s>=0&&(n.scale.set(parseFloat(i[s+1]),parseFloat(i[s+2])),i.splice(s,4)),s=i.indexOf("-o"),s>=0&&(n.offset.set(parseFloat(i[s+1]),parseFloat(i[s+2])),i.splice(s,4)),n.url=i.join(" ").trim(),n}loadTexture(e,t,n,i,s){const r=this.manager!==void 0?this.manager:_u;let o=r.getHandler(e);o===null&&(o=new Fs(r)),o.setCrossOrigin&&o.setCrossOrigin(this.crossOrigin);const c=o.load(e,n,i,s);return t!==void 0&&(c.mapping=t),c}}const lh=new WeakMap;class LM extends Ut{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const s=new Zt(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,r=>{const o={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(r,o).then(t).catch(i)},n,i)}decodeDracoFile(e,t,n,i){const s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(const c in t.attributeTypes){const l=t.attributeTypes[c];l.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[c]=l.name)}const n=JSON.stringify(t);if(lh.has(e)){const c=lh.get(e);if(c.key===n)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const s=this.workerNextTaskID++,r=e.byteLength,o=this._getWorker(s,r).then(c=>(i=c,new Promise((l,u)=>{i._callbacks[s]={resolve:l,reject:u},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return o.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),lh.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new qe;e.index&&t.setIndex(new ht(e.index.array,1));for(let n=0;n{n.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const s=RM.toString(),r=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(` -`);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.lengths._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e{const h=u.draco,f=new h.Decoder,d=new h.DecoderBuffer;d.Init(new Int8Array(c),c.byteLength);try{const p=t(h,f,d,l),m=p.attributes.map(g=>g.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:o.id,error:p.message})}finally{h.destroy(d),h.destroy(f)}});break}};function t(r,o,c,l){const u=l.attributeIDs,h=l.attributeTypes;let f,d;const p=o.GetEncodedGeometryType(c);if(p===r.TRIANGULAR_MESH)f=new r.Mesh,d=o.DecodeBufferToMesh(c,f);else if(p===r.POINT_CLOUD)f=new r.PointCloud,d=o.DecodeBufferToPointCloud(c,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!d.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+d.error_msg());const m={index:null,attributes:[]};for(const g in u){const x=self[h[g]];let y,b;if(l.useUniqueIDs)b=u[g],y=o.GetAttributeByUniqueId(f,b);else{if(b=o.GetAttributeId(f,r[u[g]]),b===-1)continue;y=o.GetAttribute(f,b)}m.attributes.push(i(r,o,f,g,x,y))}return p===r.TRIANGULAR_MESH&&(m.index=n(r,o,f)),r.destroy(f),m}function n(r,o,c){const u=c.num_faces()*3,h=u*4,f=r._malloc(h);o.GetTrianglesUInt32Array(c,h,f);const d=new Uint32Array(r.HEAPF32.buffer,f,u).slice();return r._free(f),{array:d,itemSize:1}}function i(r,o,c,l,u,h){const f=h.num_components(),p=c.num_points()*f,m=p*u.BYTES_PER_ELEMENT,g=s(r,u),x=r._malloc(m);o.GetAttributeDataArrayForAllPoints(c,h,g,m,x);const y=new u(r.HEAPF32.buffer,x,p).slice();return r._free(x),{name:l,array:y,itemSize:f}}function s(r,o){switch(o){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32}}}const Tc=new hi,ii=new SM;ii.addHandler(/\.dds$/i,new MM),ii.addHandler(/\.tga$/i,new ih);function IM(a){return Tc.setFromObject(a),Tc.getSize(new D)}function PM(a){return Tc.setFromObject(a),Tc.getCenter(new D)}function DM(a){const e=a.split(".");if(e.length<=1)return"";{let t=e.pop();return t=t.toLowerCase(),t}}function FM(a,e,t,n){let i;e?i=e:i=DM(a),i==="glb"&&(i="gltf");let s={loader:null,getObject:null};switch(i){case"dae":s={loader:new Uw(ii),getObject:r=>r.scene};break;case"fbx":s={loader:new Cw(ii)};break;case"gltf":s={loader:new Gw(ii),getObject:r=>r.scene},kM(t,s,n);break;case"obj":s={loader:new wM(ii)};break;case"ply":s={loader:new TM(ii),getObject:r=>(r.computeVertexNormals(),new St(r,new Cs))};break;case"stl":s={loader:new AM(ii),getObject:r=>new St(r,new Qn)};break;case"json":s={loader:new fp(ii)};break}return s}function NM(){return new EM(ii)}function kM(a,e,t){if(a){const n=new LM;n.setDecoderPath(t||"assets/draco/gltf/"),n.setDecoderConfig({type:"js"}),e.loader.setDRACOLoader(n)}}var S1="",OM=(a,e)=>{const t=a.__vccOpts||a;for(const[n,i]of e)t[n]=i;return t};const BM=Nt.defineComponent({name:"vue3dLoader"}),zM=Nt.defineComponent({...BM,props:{filePath:null,fileType:null,width:null,height:null,position:null,rotation:null,scale:null,lights:{default:()=>[{type:"AmbientLight",color:11184810},{type:"DirectionalLight",position:{x:1,y:1,z:1},color:16777215,intensity:.8}]},cameraPosition:{default:()=>({x:0,y:0,z:0})},cameraRotation:null,cameraUp:null,cameraLookAt:null,backgroundColor:{default:()=>16777215},backgroundAlpha:{default:()=>1},controlsOptions:null,crossOrigin:{default:"anonymous"},requestHeader:null,outputEncoding:{default:()=>"linear"},webGLRendererOptions:{default:()=>({})},mtlPath:{default:""},showFps:{type:Boolean,default:!1},textureImage:{default:""},clearScene:{type:Boolean,default:!1},parallelLoad:{type:Boolean,default:!1},labels:{default:()=>[]},autoPlay:{type:Boolean,default:!0},enableDraco:{type:Boolean,default:!1},dracoDir:null,intersectRecursive:{type:Boolean,default:!1},enableDamping:{type:Boolean},dampingFactor:null},emits:["mousedown","mousemove","mouseup","click","dblclick","load","process","error"],setup(a,{emit:e}){const t=a;let n=null;const i=new Sp,s=new he,r=new Dt(45,1,1,1e5),o=new ka,c=new Tu;let l=new ct,u=null,h={},f=[],d=null,p=0,m=null,g=null,x=null;const y=Nt.ref({width:t.width||0,height:t.height||0}),b=Nt.ref(0),v=Nt.ref(!1),S=Nt.ref(!1),A=Nt.ref(null),R=Nt.ref(null);Nt.watch([()=>t.filePath,()=>t.fileType,()=>t.clearScene,()=>t.backgroundAlpha,()=>t.backgroundColor],E=>{(E[0]||E[1])&&ne(),E[2]&&xe(),(E[3]||E[4])&&H()}),Nt.watch([()=>t.rotation,()=>t.position,()=>t.scale,()=>t.lights],E=>{const w=["rotation","position","scale"];E.forEach((U,Z)=>{Z<3&&U?Fe(w[Z],U):te()})},{deep:!0}),Nt.watch([()=>y],()=>{X(!0),H()},{deep:!0}),Nt.watch([()=>t.controlsOptions],()=>{J()},{deep:!0}),Nt.watch([()=>t.cameraRotation,()=>t.cameraPosition],()=>{X()},{deep:!0}),Nt.watch([()=>t.autoPlay],()=>{at()}),Nt.onMounted(()=>{const{filePath:E,outputEncoding:w,webGLRendererOptions:U,showFps:Z,enableDamping:Q,dampingFactor:de}=t;E&&typeof E=="object"&&(S.value=!0);const Le=A.value;_(Le),N();const ue=Object.assign({},{antialias:!0,alpha:!0},U,{canvas:R.value});u=new Kl(ue),u.shadowMap.enabled=!0;const ge=w==="linear"?ui:tt;u.outputEncoding=ge,h=new ew(r,Le),Q&&(h.enableDamping=!0,de!=null&&(h.dampingFactor=de)),o.add(l),ne(),Y(),L(!0),Le.addEventListener("mousedown",B,!1),Le.addEventListener("mouseup",K,!1),Le.addEventListener("click",z,!1),Le.addEventListener("dblclick",q,!1),window.addEventListener("resize",N,!1),Z&&(m=Fo(),Le.appendChild(m.dom)),Pe()}),Nt.onBeforeUnmount(()=>{cancelAnimationFrame(p),u.dispose(),h&&h.dispose();const E=A.value;E.removeEventListener("mousedown",B,!1),E.removeEventListener("mousemove",W,!1),E.removeEventListener("mouseup",K,!1),E.removeEventListener("click",z,!1),E.removeEventListener("dblclick",q,!1),window.removeEventListener("resize",N,!1),n=null,l=null});function _(E){const{width:w,height:U}=t;w&&(E.style.width=`${w}px`),U&&(E.style.height=`${U}px`)}function L(E){const w=A.value;E?w.addEventListener("mousemove",W,!1):w.removeEventListener("mousemove",W,!1)}function N(){const{width:E,height:w}=t;(!E||!w)&&Nt.nextTick(()=>{const U=A.value;y.value={width:E||U.offsetWidth,height:w||U.offsetHeight}})}function B(E){L(!1);const w=O(E.clientX,E.clientY);e("mousedown",E,w)}function W(E){const w=O(E.clientX,E.clientY);e("mousemove",E,w)}function K(E){const w=O(E.clientX,E.clientY);e("mouseup",E,w),L(!0)}function z(E){const w=O(E.clientX,E.clientY);e("click",E,w)}function q(E){const w=O(E.clientX,E.clientY);e("dblclick",E,w)}function O(E,w){const U=Me();if(!U||!A.value)return null;const Z=A.value.getBoundingClientRect();E-=Z.left,w-=Z.top,s.x=E/y.value.width*2-1,s.y=-(w/y.value.height)*2+1,i.setFromCamera(s,r);const Q=i.intersectObject(U,t.intersectRecursive);return(Q&&Q.length)>0?Q[0]:null}function Y(){H(),X(),te(),J()}function j(){if(!n)return;const E=S.value?ft(n):null,{position:w,rotation:U,scale:Z}=t;w&&(w instanceof Array?E!=null?n.position.set(w[E].x,w[E].y,w[E].z):n.position.set(0,0,0):n.position.set(w.x,w.y,w.z)),U&&(U instanceof Array?E!=null?n.rotation.set(U[E].x,U[E].y,U[E].z):n.rotation.set(0,0,0):n.rotation.set(U.x,U.y,U.z)),Z&&(Z instanceof Array?E!=null?n.scale.set(Z[E].x,Z[E].y,Z[E].z):n.scale.set(0,0,0):n.scale.set(Z.x,Z.y,Z.z))}function H(){const{backgroundColor:E,backgroundAlpha:w}=t;u.setSize(y.value.width,y.value.height),u.setPixelRatio(window.devicePixelRatio||1),u.setClearColor(new ve(E).getHex()),u.setClearAlpha(w)}function X(E){const{cameraPosition:w,cameraRotation:U,cameraUp:Z,cameraLookAt:Q}=t;if(r.aspect=y.value.width/y.value.height,r.updateProjectionMatrix(),!E)if(!Q||!Z){if(!n)return;const de=IM(n).length();r.position.set(w.x,w.y,w.z),U&&r.rotation.set(U.x,U.y,U.z),w.x===0&&w.y===0&&w.z===0&&(r.position.z=de),r.lookAt(new D)}else r.position.set(w.x,w.y,w.z),U&&r.rotation.set(U.x,U.y,U.z),r.up.set(Z.x,Z.y,Z.z),r.lookAt(new D(Q.x,Q.y,Q.z))}function te(){const{lights:E}=t;o.remove(...f),f=[],E.forEach(w=>{if(!w.type)return;const U=w.type.toLowerCase();let Z=null;if(U==="ambient"||U==="ambientlight"){const Q=w.color===0?w.color:w.color||4210752,de=w.intensity===0?w.intensity:w.intensity||1;Z=new Do(Q,de)}if(U==="point"||U==="pointlight"){const Q=w.color===0?w.color:w.color||16777215,de=w.intensity===0?w.intensity:w.intensity||1,Le=w.distance||0,F=w.decay===0?w.decay:w.decay||1;Z=new Ns(Q,de,Le,F),w.position&&Z.position.copy(w.position)}if(U==="directional"||U==="directionallight"){const Q=w.color===0?w.color:w.color||16777215,de=w.intensity===0?w.intensity:w.intensity||1;Z=new Nr(Q,de),w.position&&Z.position.copy(w.position),w.target&&Z.target.copy(w.target)}if(U==="hemisphere"||U==="hemispherelight"){const Q=w.skyColor===0?w.skyColor:w.skyColor||16777215,de=w.groundColor===0?w.groundColor:w.groundColor||16777215,Le=w.intensity===0?w.intensity:w.intensity||1;Z=new bu(Q,de,Le),w.position&&Z.position.copy(w.position)}Z&&(f.push(Z),o.add(Z))})}function J(){const{controlsOptions:E}=t;E&&Object.assign(h,E)}function ne(){const{filePath:E,parallelLoad:w}=t;w&&S?E.forEach((U,Z)=>{re(Z)}):re()}function re(E){const{filePath:w,fileType:U,crossOrigin:Z,requestHeader:Q,mtlPath:de,enableDraco:Le,dracoDir:F}=t;if(!w)return;const ue=E||b.value,ge=S.value?w[ue]:w,Ee=typeof U=="string"?U:U?U[ue]:"",Se=FM(ge,Ee,Le,F);d=Se.loader;const Oe=Se.getObject?Se.getObject:me;if(n&&ue===0&&l.remove(n),Q&&d.setRequestHeader(Q),Z&&d.setCrossOrigin(Z),de)if(!(typeof de=="object"))V(ge,Oe,ue);else{if(!de[ue]){se(ge,Oe,ue);return}V(ge,Oe,ue)}else se(ge,Oe,ue)}function se(E,w,U){const{textureImage:Z,parallelLoad:Q}=t;d.load(E,(...de)=>{if(n=w(...de),_e(n,E),Z){const F=typeof Z=="string"?Z:Z[U];F&&ce(n,F)}Ye(),e("load",l)},de=>{Q||le(de);const Le=b.value+1;e("process",de,Le)},de=>{e("error",de)})}function V(E,w,U){const{crossOrigin:Z,requestHeader:Q,mtlPath:de}=t,Le=NM();Z&&Le.setCrossOrigin(Z),Q&&Le.setRequestHeader(Q);const F=typeof de=="string"?de:de[U],ue=/^(.*\/)([^/]*)$/.exec(F),ge=ue[1],Ee=ue[2];Le.setPath(ge).load(Ee,Se=>{Se.preload(),d.setMaterials(Se),se(E,w,U)})}function me(E){return E}function _e(E,w){const U=PM(n);v.value||(l.position.copy(U.negate()),v.value=!0),n=E;let Z=w.split("/");Z=Z[Z.length-1],n.fileName=Z,l.add(n),X(),j(),at()}function Pe(){p=requestAnimationFrame(Pe),He();const E=c.getDelta();g&&g.update(E),ye()}function ye(){u.render(o,r)}function He(){const{showFps:E}=t;E&&m.update()}function le(E){const{filePath:w}=t;Math.floor(E.loaded/E.total*100)===100&&(S.value&&w.length>b.value?Nt.nextTick(()=>{if(b.value++,b.value===w.length){b.value=0;return}re()}):b.value=0)}function ce(E,w){x||(x=new Fs),E.traverse(U=>{U.isMesh&&x.load(w,Z=>{U.material.map=Z,U.material.needsUpdate=!0},()=>{},Z=>{e("error",Z)})})}function xe(){l.clear()}function Fe(E,w){const U=Me();if(!!U){if(S.value){U.children.forEach(Z=>{const Q=ft(Z),de=E==="scale"?1:0;w[Q]?Z[E].set(w[Q].x,w[Q].y,w[Q].z):Z[E].set(de,de,de)});return}U[E].set(w.x,w.y,w.z)}}function Me(){return S.value?l:n}function Ye(){const{filePath:E}=t;S.value?b.value===E.length&&Ue():Ue()}function Ue(){const{labels:E}=t;if(!E)return;const w=S.value?l:n,U=Q=>(x||(x=new Fs),x.load(Q)),Z=(Q,de)=>{const Le=ze(Q,de),F=new Mt(Le);return F.needsUpdate=!0,F};E.forEach(Q=>{const de=Q.image?U(Q.image):Z(Q.text,Q.textStyle||{}),Le=new Oa({map:de,color:Q.spriteMaterialColor||16777215}),F=new $l(Le);Q.scale?F.scale.set(Q.scale.x||1,Q.scale.y||1,Q.scale.z||0):F.scale.set(1,1,0),Q.position&&F.position.set(Q.position.x,Q.position.y,Q.position.z),Q.sid&&(F.sid=Q.sid),w.add(F)})}function ze(E,w){const U=(Xe,$e,G,Te,oe,Ce)=>{Xe.beginPath(),Xe.moveTo($e+Ce,G),Xe.lineTo($e+Te-Ce,G),Xe.quadraticCurveTo($e+Te,G,$e+Te,G+Ce),Xe.lineTo($e+Te,G+oe-Ce),Xe.quadraticCurveTo($e+Te,G+oe,$e+Te-Ce,G+oe),Xe.lineTo($e+Ce,G+oe),Xe.quadraticCurveTo($e,G+oe,$e,G+oe-Ce),Xe.lineTo($e,G+Ce),Xe.quadraticCurveTo($e,G,$e+Ce,G),Xe.closePath(),Xe.fill(),Xe.stroke()},Z=w.fontFamily||"Arial",Q=w.fontSize===0||w.fontSize?w.fontSize:18,de=w.color||"#ffffff",Le=w.fontWeight||"normal",F=w.borderWidth===0||w.borderWidth?w.borderWidth:4,ue=w.borderColor||"rgba(0,0,0,1)",ge=w.borderRadius===0||w.borderRadius?w.borderRadius:4,Ee=w.backgroundColor||"rgba(255, 255, 255, 1)",Se=document.createElement("canvas"),Oe=Se.getContext("2d");if(Oe){Oe.font=`${Le} ${Q}px ${Z}`;const $e=Oe.measureText(E).width;Oe.fillStyle=Ee,Oe.strokeStyle=ue,Oe.lineWidth=F,U(Oe,F/2,F/2,$e+F,Q*1.4+F,ge),Oe.fillStyle=de,Oe.fillText(E,F,Q+F)}return Se}function ft(E){const{filePath:w}=t;let U;return w instanceof Array&&(U=w.map((Z,Q)=>{if(Z.indexOf(E.fileName)>-1)return Q}).filter(Z=>Z!=null)[0]),U}function at(){const{autoPlay:E}=t,w=Me();if(!w)return;const U=Z=>{g=new Mp(w),Z.animations&&Z.animations.forEach(Q=>{if(Q){const de=g.clipAction(Q);E?de.play():de.stop()}})};if(S.value){w.children.forEach(Z=>{U(Z)});return}U(w)}return(E,w)=>(Nt.openBlock(),Nt.createElementBlock("div",{ref_key:"containerElement",ref:A,class:"viewer-container"},[Nt.createElementVNode("canvas",{ref_key:"canvasElement",ref:R,class:"viewer-canvas"},null,512)],512))}});var Ac=OM(zM,[["__scopeId","data-v-07257ca0"]]),UM={install:a=>{a.component(Ac.name,Ac)},vue3dLoader:Ac};return Jr.Three=Qb,Jr.default=UM,Jr.vue3dLoader=Ac,Object.defineProperties(Jr,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),Jr}({},Vue); +`);let i=[];for(let o=0,c=n.length;o=7?(Sc.setRGB(parseFloat(h[4]),parseFloat(h[5]),parseFloat(h[6])).convertSRGBToLinear(),t.colors.push(Sc.r,Sc.g,Sc.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3]));break;case"vt":t.uvs.push(parseFloat(h[1]),parseFloat(h[2]));break}}else if(u==="f"){const f=l.slice(1).trim().split(Um),d=[];for(let m=0,g=f.length;m0){const y=x.split("/");d.push(y)}}const p=d[0];for(let m=1,g=d.length-1;m1){const f=i[1].trim().toLowerCase();t.object.smooth=f!=="0"&&f!=="off"}else t.object.smooth=!0;const h=t.object.currentMaterial();h&&(h.smooth=t.object.smooth)}else{if(l==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+l+'"')}}t.finalize();const s=new dn;if(s.materialLibraries=[].concat(t.materialLibraries),!(t.objects.length===1&&t.objects[0].geometry.vertices.length===0)===!0)for(let o=0,c=t.objects.length;o0&&m.setAttribute("normal",new Ae(u.normals,3)),u.colors.length>0&&(p=!0,m.setAttribute("color",new Ae(u.colors,3))),u.hasUVIndices===!0&&m.setAttribute("uv",new Ae(u.uvs,2));const g=[];for(let y=0,b=h.length;y1){for(let y=0,b=h.length;y0){const o=new Xi({size:1,sizeAttenuation:!1}),c=new qe;c.setAttribute("position",new Ae(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(c.setAttribute("color",new Ae(t.colors,3)),o.vertexColors=!0);const l=new _r(c,o);s.add(l)}return s}}class MM extends ip{constructor(e){super(e)}parse(e,t){const n={mipmaps:[],width:0,height:0,format:null,mipmapCount:1},i=542327876,s=131072,r=512,o=1024,c=2048,l=4096,u=8192,h=16384,f=32768;function d(oe){return oe.charCodeAt(0)+(oe.charCodeAt(1)<<8)+(oe.charCodeAt(2)<<16)+(oe.charCodeAt(3)<<24)}function p(oe){return String.fromCharCode(oe&255,oe>>8&255,oe>>16&255,oe>>24&255)}function m(oe,H,ye,we){const De=ye*we*4,xe=new Uint8Array(oe,H,De),Ve=new Uint8Array(De);let he=0,ue=0;for(let ve=0;ve>1,1),ye=Math.max(ye>>1,1)}}return n}}class SM{constructor(e,t,n){const i=this;let s=!1,r=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,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 c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,h){return l.push(u,h),this},this.removeHandler=function(u){const h=l.indexOf(u);return h!==-1&&l.splice(h,2),this},this.getHandler=function(u){for(let h=0,f=l.length;h=p.elements[v].count&&(v++,M=0);const _=i(p.elements[v].properties,C);o(m,p.elements[v].name,_),M++}return r(m)}function r(d){let p=new qe;return d.indices.length>0&&p.setIndex(d.indices),p.setAttribute("position",new Ae(d.vertices,3)),d.normals.length>0&&p.setAttribute("normal",new Ae(d.normals,3)),d.uvs.length>0&&p.setAttribute("uv",new Ae(d.uvs,2)),d.colors.length>0&&p.setAttribute("color",new Ae(d.colors,3)),d.faceVertexUvs.length>0&&(p=p.toNonIndexed(),p.setAttribute("uv",new Ae(d.faceVertexUvs,2))),p.computeBoundingSphere(),p}function o(d,p,m){function g(q){for(let J=0,G=q.length;J>5&31)/31,p=(X>>10&31)/31):(f=x,d=y,p=b)}for(let X=1;X<=3;X++){const B=U+X*12,Z=F*3*3+(X-1)*3;_[Z]=u.getFloat32(B,!0),_[Z+1]=u.getFloat32(B+4,!0),_[Z+2]=u.getFloat32(B+8,!0),E[Z]=q,E[Z+1]=J,E[Z+2]=G,m&&(g[Z]=f,g[Z+1]=d,g[Z+2]=p)}}return C.setAttribute("position",new ft(_,3)),C.setAttribute("normal",new ft(E,3)),m&&(C.setAttribute("color",new ft(g,3)),C.hasColors=!0,C.alpha=v),C}function s(l){const u=new qe,h=/solid([\s\S]*?)endsolid/g,f=/facet([\s\S]*?)endfacet/g;let d=0;const p=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,m=new RegExp("vertex"+p+p+p,"g"),g=new RegExp("normal"+p+p+p,"g"),x=[],y=[],b=new P;let v,M=0,T=0,C=0;for(;(v=h.exec(l))!==null;){T=C;const _=v[0];for(;(v=f.exec(_))!==null;){let U=0,q=0;const J=v[0];for(;(v=g.exec(J))!==null;)b.x=parseFloat(v[1]),b.y=parseFloat(v[2]),b.z=parseFloat(v[3]),q++;for(;(v=m.exec(J))!==null;)x.push(parseFloat(v[1]),parseFloat(v[2]),parseFloat(v[3])),y.push(b.x,b.y,b.z),U++,C++;q!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+d),U!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+d),d++}const E=T,F=C-T;u.addGroup(E,F,M),M++}return u.setAttribute("position",new Ae(x,3)),u.setAttribute("normal",new Ae(y,3)),u}function r(l){return typeof l!="string"?tn.decodeText(new Uint8Array(l)):l}function o(l){if(typeof l=="string"){const u=new Uint8Array(l.length);for(let h=0;h=0?l.substring(0,u):l;h=h.toLowerCase();let f=u>=0?l.substring(u+1):"";if(f=f.trim(),h==="newmtl")i={name:f},r[f]=i;else if(h==="ka"||h==="kd"||h==="ks"||h==="ke"){const d=f.split(s,3);i[h]=[parseFloat(d[0]),parseFloat(d[1]),parseFloat(d[2])]}else i[h]=f}const o=new CM(this.resourcePath||t,this.materialOptions);return o.setCrossOrigin(this.crossOrigin),o.setManager(this.manager),o.setMaterials(r),o}}class CM{constructor(e="",t={}){this.baseUrl=e,this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.crossOrigin="anonymous",this.side=this.options.side!==void 0?this.options.side:oi,this.wrap=this.options.wrap!==void 0?this.options.wrap:on}setCrossOrigin(e){return this.crossOrigin=e,this}setManager(e){this.manager=e}setMaterials(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}}convert(e){if(!this.options)return e;const t={};for(const n in e){const i=e[n],s={};t[n]=s;for(const r in i){let o=!0,c=i[r];const l=r.toLowerCase();switch(l){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(c=[c[0]/255,c[1]/255,c[2]/255]),this.options&&this.options.ignoreZeroRGBs&&c[0]===0&&c[1]===0&&c[2]===0&&(o=!1);break}o&&(s[l]=c)}}return t}preload(){for(const e in this.materialsInfo)this.create(e)}getIndex(e){return this.nameLookup[e]}getAsArray(){let e=0;for(const t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray}create(e){return this.materials[e]===void 0&&this.createMaterial_(e),this.materials[e]}createMaterial_(e){const t=this,n=this.materialsInfo[e],i={name:e,side:this.side};function s(o,c){return typeof c!="string"||c===""?"":/^https?:\/\//i.test(c)?c:o+c}function r(o,c){if(i[o])return;const l=t.getTextureParams(c,i),u=t.loadTexture(s(t.baseUrl,l.url));u.repeat.copy(l.scale),u.offset.copy(l.offset),u.wrapS=t.wrap,u.wrapT=t.wrap,(o==="map"||o==="emissiveMap")&&(u.encoding=nt),i[o]=u}for(const o in n){const c=n[o];let l;if(c!=="")switch(o.toLowerCase()){case"kd":i.color=new be().fromArray(c).convertSRGBToLinear();break;case"ks":i.specular=new be().fromArray(c).convertSRGBToLinear();break;case"ke":i.emissive=new be().fromArray(c).convertSRGBToLinear();break;case"map_kd":r("map",c);break;case"map_ks":r("specularMap",c);break;case"map_ke":r("emissiveMap",c);break;case"norm":r("normalMap",c);break;case"map_bump":case"bump":r("bumpMap",c);break;case"map_d":r("alphaMap",c),i.transparent=!0;break;case"ns":i.shininess=parseFloat(c);break;case"d":l=parseFloat(c),l<1&&(i.opacity=l,i.transparent=!0);break;case"tr":l=parseFloat(c),this.options&&this.options.invertTrProperty&&(l=1-l),l>0&&(i.opacity=1-l,i.transparent=!0);break}}return this.materials[e]=new Qn(i),this.materials[e]}getTextureParams(e,t){const n={scale:new fe(1,1),offset:new fe(0,0)},i=e.split(/\s+/);let s;return s=i.indexOf("-bm"),s>=0&&(t.bumpScale=parseFloat(i[s+1]),i.splice(s,2)),s=i.indexOf("-s"),s>=0&&(n.scale.set(parseFloat(i[s+1]),parseFloat(i[s+2])),i.splice(s,4)),s=i.indexOf("-o"),s>=0&&(n.offset.set(parseFloat(i[s+1]),parseFloat(i[s+2])),i.splice(s,4)),n.url=i.join(" ").trim(),n}loadTexture(e,t,n,i,s){const r=this.manager!==void 0?this.manager:bu;let o=r.getHandler(e);o===null&&(o=new Fs(r)),o.setCrossOrigin&&o.setCrossOrigin(this.crossOrigin);const c=o.load(e,n,i,s);return t!==void 0&&(c.mapping=t),c}}const uh=new WeakMap;class LM extends Ut{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const s=new Zt(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,r=>{const o={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(r,o).then(t).catch(i)},n,i)}decodeDracoFile(e,t,n,i){const s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(const c in t.attributeTypes){const l=t.attributeTypes[c];l.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[c]=l.name)}const n=JSON.stringify(t);if(uh.has(e)){const c=uh.get(e);if(c.key===n)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const s=this.workerNextTaskID++,r=e.byteLength,o=this._getWorker(s,r).then(c=>(i=c,new Promise((l,u)=>{i._callbacks[s]={resolve:l,reject:u},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return o.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),uh.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new qe;e.index&&t.setIndex(new ft(e.index.array,1));for(let n=0;n{n.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const s=RM.toString(),r=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(` +`);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.lengths._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e{const h=u.draco,f=new h.Decoder,d=new h.DecoderBuffer;d.Init(new Int8Array(c),c.byteLength);try{const p=t(h,f,d,l),m=p.attributes.map(g=>g.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:o.id,error:p.message})}finally{h.destroy(d),h.destroy(f)}});break}};function t(r,o,c,l){const u=l.attributeIDs,h=l.attributeTypes;let f,d;const p=o.GetEncodedGeometryType(c);if(p===r.TRIANGULAR_MESH)f=new r.Mesh,d=o.DecodeBufferToMesh(c,f);else if(p===r.POINT_CLOUD)f=new r.PointCloud,d=o.DecodeBufferToPointCloud(c,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!d.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+d.error_msg());const m={index:null,attributes:[]};for(const g in u){const x=self[h[g]];let y,b;if(l.useUniqueIDs)b=u[g],y=o.GetAttributeByUniqueId(f,b);else{if(b=o.GetAttributeId(f,r[u[g]]),b===-1)continue;y=o.GetAttribute(f,b)}m.attributes.push(i(r,o,f,g,x,y))}return p===r.TRIANGULAR_MESH&&(m.index=n(r,o,f)),r.destroy(f),m}function n(r,o,c){const u=c.num_faces()*3,h=u*4,f=r._malloc(h);o.GetTrianglesUInt32Array(c,h,f);const d=new Uint32Array(r.HEAPF32.buffer,f,u).slice();return r._free(f),{array:d,itemSize:1}}function i(r,o,c,l,u,h){const f=h.num_components(),p=c.num_points()*f,m=p*u.BYTES_PER_ELEMENT,g=s(r,u),x=r._malloc(m);o.GetAttributeDataArrayForAllPoints(c,h,g,m,x);const y=new u(r.HEAPF32.buffer,x,p).slice();return r._free(x),{name:l,array:y,itemSize:f}}function s(r,o){switch(o){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32}}}const Ac=new hi,ii=new SM;ii.addHandler(/\.dds$/i,new MM),ii.addHandler(/\.tga$/i,new sh);function IM(a){return Ac.setFromObject(a),Ac.getSize(new P)}function PM(a){return Ac.setFromObject(a),Ac.getCenter(new P)}function DM(a){const e=a.split(".");if(e.length<=1)return"";{let t=e.pop();return t=t.toLowerCase(),t}}function FM(a,e,t,n){let i;e?i=e:i=DM(a),i==="glb"&&(i="gltf");let s={loader:null,getObject:null};switch(i){case"dae":s={loader:new Uw(ii),getObject:r=>r.scene};break;case"fbx":s={loader:new Cw(ii)};break;case"gltf":s={loader:new Gw(ii),getObject:r=>r.scene},kM(t,s,n);break;case"obj":s={loader:new wM(ii)};break;case"ply":s={loader:new TM(ii),getObject:r=>(r.computeVertexNormals(),new St(r,new Cs))};break;case"stl":s={loader:new AM(ii),getObject:r=>new St(r,new Qn)};break;case"json":s={loader:new dp(ii)};break}return s}function NM(){return new EM(ii)}function kM(a,e,t){if(a){const n=new LM;n.setDecoderPath(t||"assets/draco/gltf/"),n.setDecoderConfig({type:"js"}),e.loader.setDRACOLoader(n)}}var S1="",OM=(a,e)=>{const t=a.__vccOpts||a;for(const[n,i]of e)t[n]=i;return t};const BM=Nt.defineComponent({name:"vue3dLoader"}),zM=Nt.defineComponent({...BM,props:{filePath:null,fileType:null,width:null,height:null,position:null,rotation:null,scale:null,lights:{default:()=>[{type:"AmbientLight",color:11184810},{type:"DirectionalLight",position:{x:1,y:1,z:1},color:16777215,intensity:.8}]},cameraPosition:{default:()=>({x:0,y:0,z:0})},cameraRotation:null,cameraUp:null,cameraLookAt:null,backgroundColor:{default:()=>16777215},backgroundAlpha:{default:()=>1},controlsOptions:null,crossOrigin:{default:"anonymous"},requestHeader:null,outputEncoding:{default:()=>"linear"},webGLRendererOptions:{default:()=>({})},mtlPath:{default:""},showFps:{type:Boolean,default:!1},textureImage:{default:""},clearScene:{type:Boolean,default:!1},parallelLoad:{type:Boolean,default:!1},labels:{default:()=>[]},autoPlay:{type:Boolean,default:!0},enableDraco:{type:Boolean,default:!1},dracoDir:null,intersectRecursive:{type:Boolean,default:!1},enableDamping:{type:Boolean},dampingFactor:null},emits:["mousedown","mousemove","mouseup","click","dblclick","load","process","error"],setup(a,{emit:e}){const t=a;let n=null;const i=new Sp,s=new fe,r=new Dt(45,1,1,1e5),o=new ka,c=new Au;let l=new lt,u=null,h={},f=[],d=null,p=0,m=null,g=null,x=null;const y=Nt.ref({width:t.width||0,height:t.height||0}),b=Nt.ref(0),v=Nt.ref(!1),M=Nt.ref(!1),T=Nt.ref(null),C=Nt.ref(null);Nt.watch([()=>t.filePath,()=>t.fileType,()=>t.clearScene,()=>t.backgroundAlpha,()=>t.backgroundColor],k=>{(k[0]||k[1])&&ie(),k[2]&&ve(),(k[3]||k[4])&&W()}),Nt.watch([()=>t.rotation,()=>t.position,()=>t.scale,()=>t.lights],k=>{const z=["rotation","position","scale"];k.forEach((K,Q)=>{Q<3&&K?Fe(z[Q],K):ne()})},{deep:!0}),Nt.watch([()=>y],()=>{j(!0),W()},{deep:!0}),Nt.watch([()=>t.controlsOptions],()=>{$()},{deep:!0}),Nt.watch([()=>t.cameraRotation,()=>t.cameraPosition],()=>{j()},{deep:!0}),Nt.watch([()=>t.autoPlay],()=>{ct()}),Nt.onMounted(()=>{const{filePath:k,outputEncoding:z,webGLRendererOptions:K,showFps:Q,enableDamping:me,dampingFactor:R}=t;k&&typeof k=="object"&&(M.value=!0);const ae=T.value;_(ae),F();const Se=Object.assign({},{antialias:!0,alpha:!0},K,{canvas:C.value});u=new Jl(Se),u.shadowMap.enabled=!0;const Te=z==="linear"?ui:nt;u.outputEncoding=Te,h=new ew(r,ae),me&&(h.enableDamping=!0,R!=null&&(h.dampingFactor=R)),o.add(l),ie(),Z(),E(!0),ae.addEventListener("mousedown",U,!1),ae.addEventListener("mouseup",J,!1),ae.addEventListener("click",G,!1),ae.addEventListener("dblclick",X,!1),window.addEventListener("resize",F,!1),Q&&(m=Fo(),ae.appendChild(m.dom)),De()}),Nt.onBeforeUnmount(()=>{cancelAnimationFrame(p),u.dispose(),h&&h.dispose();const k=T.value;k.removeEventListener("mousedown",U,!1),k.removeEventListener("mousemove",q,!1),k.removeEventListener("mouseup",J,!1),k.removeEventListener("click",G,!1),k.removeEventListener("dblclick",X,!1),window.removeEventListener("resize",F,!1),n=null,l=null});function _(k){const{width:z,height:K}=t;z&&(k.style.width=`${z}px`),K&&(k.style.height=`${K}px`)}function E(k){const z=T.value;k?z.addEventListener("mousemove",q,!1):z.removeEventListener("mousemove",q,!1)}function F(){const{width:k,height:z}=t;(!k||!z)&&Nt.nextTick(()=>{const K=T.value;y.value={width:k||K.offsetWidth,height:z||K.offsetHeight}})}function U(k){E(!1);const z=B(k.clientX,k.clientY);e("mousedown",k,z)}function q(k){const z=B(k.clientX,k.clientY);e("mousemove",k,z)}function J(k){const z=B(k.clientX,k.clientY);e("mouseup",k,z),E(!0)}function G(k){const z=B(k.clientX,k.clientY);e("click",k,z)}function X(k){const z=B(k.clientX,k.clientY);e("dblclick",k,z)}function B(k,z){const K=Ee();if(!K||!T.value)return null;const Q=T.value.getBoundingClientRect();k-=Q.left,z-=Q.top,s.x=k/y.value.width*2-1,s.y=-(z/y.value.height)*2+1,i.setFromCamera(s,r);const me=i.intersectObject(K,t.intersectRecursive);return(me&&me.length)>0?me[0]:null}function Z(){W(),j(),ne(),$()}function Y(){if(!n)return;const k=M.value?dt(n):null,{position:z,rotation:K,scale:Q}=t;z&&(z instanceof Array?k!=null?n.position.set(z[k].x,z[k].y,z[k].z):n.position.set(0,0,0):n.position.set(z.x,z.y,z.z)),K&&(K instanceof Array?k!=null?n.rotation.set(K[k].x,K[k].y,K[k].z):n.rotation.set(0,0,0):n.rotation.set(K.x,K.y,K.z)),Q&&(Q instanceof Array?k!=null?n.scale.set(Q[k].x,Q[k].y,Q[k].z):n.scale.set(0,0,0):n.scale.set(Q.x,Q.y,Q.z))}function W(){const{backgroundColor:k,backgroundAlpha:z}=t;u.setSize(y.value.width,y.value.height),u.setPixelRatio(window.devicePixelRatio||1),u.setClearColor(new be(k).getHex()),u.setClearAlpha(z)}function j(k){const{cameraPosition:z,cameraRotation:K,cameraUp:Q,cameraLookAt:me}=t;if(r.aspect=y.value.width/y.value.height,r.updateProjectionMatrix(),!k)if(!me||!Q){if(!n)return;const R=IM(n).length();r.position.set(z.x,z.y,z.z),K&&r.rotation.set(K.x,K.y,K.z),z.x===0&&z.y===0&&z.z===0&&(r.position.z=R),r.lookAt(new P)}else r.position.set(z.x,z.y,z.z),K&&r.rotation.set(K.x,K.y,K.z),r.up.set(Q.x,Q.y,Q.z),r.lookAt(new P(me.x,me.y,me.z))}function ne(){const{lights:k}=t;o.remove(...f),f=[],k.forEach(z=>{if(!z.type)return;const K=z.type.toLowerCase();let Q=null;if(K==="ambient"||K==="ambientlight"){const me=z.color===0?z.color:z.color||4210752,R=z.intensity===0?z.intensity:z.intensity||1;Q=new Do(me,R)}if(K==="point"||K==="pointlight"){const me=z.color===0?z.color:z.color||16777215,R=z.intensity===0?z.intensity:z.intensity||1,ae=z.distance||0,pe=z.decay===0?z.decay:z.decay||1;Q=new Ns(me,R,ae,pe),z.position&&Q.position.copy(z.position)}if(K==="directional"||K==="directionallight"){const me=z.color===0?z.color:z.color||16777215,R=z.intensity===0?z.intensity:z.intensity||1;Q=new Nr(me,R),z.position&&Q.position.copy(z.position),z.target&&Q.target.copy(z.target)}if(K==="hemisphere"||K==="hemispherelight"){const me=z.skyColor===0?z.skyColor:z.skyColor||16777215,R=z.groundColor===0?z.groundColor:z.groundColor||16777215,ae=z.intensity===0?z.intensity:z.intensity||1;Q=new wu(me,R,ae),z.position&&Q.position.copy(z.position)}Q&&(f.push(Q),o.add(Q))})}function $(){const{controlsOptions:k}=t;k&&Object.assign(h,k)}function ie(){const{filePath:k,parallelLoad:z}=t;z&&M?k.forEach((K,Q)=>{ce(Q)}):ce()}function ce(k){const{filePath:z,fileType:K,crossOrigin:Q,requestHeader:me,mtlPath:R,enableDraco:ae,dracoDir:pe}=t;if(!z)return;const Se=k||b.value,Te=M.value?z[Se]:z,He=typeof K=="string"?K:K?K[Se]:"",Ze=FM(Te,He,ae,pe);d=Ze.loader;const Qe=Ze.getObject?Ze.getObject:ye;if(n&&Se===0&&l.remove(n),me&&d.setRequestHeader(me),Q&&d.setCrossOrigin(Q),R)if(!(typeof R=="object"))H(Te,Qe,Se);else{if(!R[Se]){oe(Te,Qe,Se);return}H(Te,Qe,Se)}else oe(Te,Qe,Se)}function oe(k,z,K){const{textureImage:Q,parallelLoad:me}=t;d.load(k,(...R)=>{if(n=z(...R),we(n,k),Q){const pe=typeof Q=="string"?Q:Q[K];pe&&ue(n,pe)}je(),e("load",l)},R=>{me||he(R);const ae=b.value+1;e("process",R,ae)},R=>{e("error",R)})}function H(k,z,K){const{crossOrigin:Q,requestHeader:me,mtlPath:R}=t,ae=NM();Q&&ae.setCrossOrigin(Q),me&&ae.setRequestHeader(me);const pe=typeof R=="string"?R:R[K],Se=/^(.*\/)([^/]*)$/.exec(pe),Te=Se[1],He=Se[2];ae.setPath(Te).load(He,Ze=>{Ze.preload(),d.setMaterials(Ze),oe(k,z,K)})}function ye(k){return k}function we(k,z){const K=PM(n);v.value||(l.position.copy(K.negate()),v.value=!0),n=k;let Q=z.split("/");Q=Q[Q.length-1],n.fileName=Q,l.add(n),j(),Y(),ct()}function De(){p=requestAnimationFrame(De),Ve();const k=c.getDelta();g&&g instanceof rc&&g.update(k),g&&g instanceof Array&&g.forEach(z=>{z.update(k)}),xe()}function xe(){u.render(o,r)}function Ve(){const{showFps:k}=t;k&&m.update()}function he(k){const{filePath:z}=t;Math.floor(k.loaded/k.total*100)===100&&(M.value&&z.length>b.value?Nt.nextTick(()=>{if(b.value++,b.value===z.length){b.value=0;return}ce()}):b.value=0)}function ue(k,z){x||(x=new Fs),k.traverse(K=>{K.isMesh&&x.load(z,Q=>{K.material.map=Q,K.material.needsUpdate=!0},()=>{},Q=>{e("error",Q)})})}function ve(){l.clear()}function Fe(k,z){const K=Ee();if(!!K){if(M.value){K.children.forEach(Q=>{const me=dt(Q),R=k==="scale"?1:0;z[me]?Q[k].set(z[me].x,z[me].y,z[me].z):Q[k].set(R,R,R)});return}K[k].set(z.x,z.y,z.z)}}function Ee(){return M.value?l:n}function je(){const{filePath:k}=t;M.value?b.value===k.length&&ze():ze()}function ze(){const{labels:k}=t;if(!k)return;const z=M.value?l:n,K=me=>(x||(x=new Fs),x.load(me)),Q=(me,R)=>{const ae=Be(me,R),pe=new Mt(ae);return pe.needsUpdate=!0,pe};k.forEach(me=>{const R=me.image?K(me.image):Q(me.text,me.textStyle||{}),ae=new Oa({map:R,color:me.spriteMaterialColor||16777215}),pe=new Ql(ae);me.scale?pe.scale.set(me.scale.x||1,me.scale.y||1,me.scale.z||0):pe.scale.set(1,1,0),me.position&&pe.position.set(me.position.x,me.position.y,me.position.z),me.sid&&(pe.sid=me.sid),z.add(pe)})}function Be(k,z){const K=(V,_e,re,Ie,Ce,Je)=>{V.beginPath(),V.moveTo(_e+Je,re),V.lineTo(_e+Ie-Je,re),V.quadraticCurveTo(_e+Ie,re,_e+Ie,re+Je),V.lineTo(_e+Ie,re+Ce-Je),V.quadraticCurveTo(_e+Ie,re+Ce,_e+Ie-Je,re+Ce),V.lineTo(_e+Je,re+Ce),V.quadraticCurveTo(_e,re+Ce,_e,re+Ce-Je),V.lineTo(_e,re+Je),V.quadraticCurveTo(_e,re,_e+Je,re),V.closePath(),V.fill(),V.stroke()},Q=z.fontFamily||"Arial",me=z.fontSize===0||z.fontSize?z.fontSize:18,R=z.color||"#ffffff",ae=z.fontWeight||"normal",pe=z.borderWidth===0||z.borderWidth?z.borderWidth:4,Se=z.borderColor||"rgba(0,0,0,1)",Te=z.borderRadius===0||z.borderRadius?z.borderRadius:4,He=z.backgroundColor||"rgba(255, 255, 255, 1)",Ze=document.createElement("canvas"),Qe=Ze.getContext("2d");if(Qe){Qe.font=`${ae} ${me}px ${Q}`;const _e=Qe.measureText(k).width;Qe.fillStyle=He,Qe.strokeStyle=Se,Qe.lineWidth=pe,K(Qe,pe/2,pe/2,_e+pe,me*1.4+pe,Te),Qe.fillStyle=R,Qe.fillText(k,pe,me+pe)}return Ze}function dt(k){const{filePath:z}=t;let K;return z instanceof Array&&(K=z.map((Q,me)=>{if(Q.indexOf(k.fileName)>-1)return me}).filter(Q=>Q!=null)[0]),K}function ct(){const k=Ee();if(!!k){if(M.value){D(k);return}O(k)}}function O(k){const{autoPlay:z}=t;g=new rc(k),k.animations&&k.animations.length>0&&k.animations.forEach(K=>{if(K){const Q=g.clipAction(K);z?Q.play():Q.stop()}})}function D(k){const{autoPlay:z}=t;g=[],k.children.forEach((K,Q)=>{g.push(new rc(K)),K.animations&&K.animations.length>0&&K.animations.forEach(me=>{if(me){const R=g[Q].clipAction(me);z?R.play():R.stop()}})})}return(k,z)=>(Nt.openBlock(),Nt.createElementBlock("div",{ref_key:"containerElement",ref:T,class:"viewer-container"},[Nt.createElementVNode("canvas",{ref_key:"canvasElement",ref:C,class:"viewer-canvas"},null,512)],512))}});var Ec=OM(zM,[["__scopeId","data-v-04ca652e"]]),UM={install:a=>{a.component(Ec.name,Ec)},vue3dLoader:Ec};return Jr.Three=Qb,Jr.default=UM,Jr.vue3dLoader=Ec,Object.defineProperties(Jr,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),Jr}({},Vue); diff --git a/package.json b/package.json index 3a4a6a8..0670dbd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vue-3d-loader", "private": false, - "version": "2.1.0", + "version": "2.1.1", "main": "dist/vue-3d-loader.cjs.js", "module": "dist/vue-3d-loader.esm.js", "types": "dist/types/index.d.ts",