@ridp/threejs 1.3.3 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ (function(){"use strict";/**
2
+ * @license
3
+ * Copyright 2010-2025 Three.js Authors
4
+ * SPDX-License-Identifier: MIT
5
+ */const ti="178",ei="attached",an="detached",si="",P="srgb",K="srgb-linear",ii="linear",is="srgb";class Me{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){const s=this._listeners;return s===void 0?!1:s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){const s=this._listeners;if(s===void 0)return;const i=s[t];if(i!==void 0){const n=i.indexOf(e);n!==-1&&i.splice(n,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const s=e[t.type];if(s!==void 0){t.target=this;const i=s.slice(0);for(let n=0,r=i.length;n<r;n++)i[n].call(this,t);t.target=null}}}const D=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let ni=1234567;const oe=Math.PI/180,ae=180/Math.PI;function $(){const d=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(D[d&255]+D[d>>8&255]+D[d>>16&255]+D[d>>24&255]+"-"+D[t&255]+D[t>>8&255]+"-"+D[t>>16&15|64]+D[t>>24&255]+"-"+D[e&63|128]+D[e>>8&255]+"-"+D[e>>16&255]+D[e>>24&255]+D[s&255]+D[s>>8&255]+D[s>>16&255]+D[s>>24&255]).toLowerCase()}function E(d,t,e){return Math.max(t,Math.min(e,d))}function ns(d,t){return(d%t+t)%t}function hn(d,t,e,s,i){return s+(d-t)*(i-s)/(e-t)}function cn(d,t,e){return d!==t?(e-d)/(t-d):0}function he(d,t,e){return(1-e)*d+e*t}function ln(d,t,e,s){return he(d,t,1-Math.exp(-e*s))}function un(d,t=1){return t-Math.abs(ns(d,t*2)-t)}function dn(d,t,e){return d<=t?0:d>=e?1:(d=(d-t)/(e-t),d*d*(3-2*d))}function pn(d,t,e){return d<=t?0:d>=e?1:(d=(d-t)/(e-t),d*d*d*(d*(d*6-15)+10))}function fn(d,t){return d+Math.floor(Math.random()*(t-d+1))}function mn(d,t){return d+Math.random()*(t-d)}function yn(d){return d*(.5-Math.random())}function gn(d){d!==void 0&&(ni=d);let t=ni+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function xn(d){return d*oe}function bn(d){return d*ae}function Mn(d){return(d&d-1)===0&&d!==0}function wn(d){return Math.pow(2,Math.ceil(Math.log(d)/Math.LN2))}function _n(d){return Math.pow(2,Math.floor(Math.log(d)/Math.LN2))}function Tn(d,t,e,s,i){const n=Math.cos,r=Math.sin,o=n(e/2),a=r(e/2),h=n((t+s)/2),c=r((t+s)/2),l=n((t-s)/2),u=r((t-s)/2),p=n((s-t)/2),f=r((s-t)/2);switch(i){case"XYX":d.set(o*c,a*l,a*u,o*h);break;case"YZY":d.set(a*u,o*c,a*l,o*h);break;case"ZXZ":d.set(a*l,a*u,o*c,o*h);break;case"XZX":d.set(o*c,a*f,a*p,o*h);break;case"YXY":d.set(a*p,o*c,a*f,o*h);break;case"ZYZ":d.set(a*f,a*p,o*c,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Q(d,t){switch(t.constructor){case Float32Array:return d;case Uint32Array:return d/4294967295;case Uint16Array:return d/65535;case Uint8Array:return d/255;case Int32Array:return Math.max(d/2147483647,-1);case Int16Array:return Math.max(d/32767,-1);case Int8Array:return Math.max(d/127,-1);default:throw new Error("Invalid component type.")}}function I(d,t){switch(t.constructor){case Float32Array:return d;case Uint32Array:return Math.round(d*4294967295);case Uint16Array:return Math.round(d*65535);case Uint8Array:return Math.round(d*255);case Int32Array:return Math.round(d*2147483647);case Int16Array:return Math.round(d*32767);case Int8Array:return Math.round(d*127);default:throw new Error("Invalid component type.")}}const Sn={DEG2RAD:oe,RAD2DEG:ae,generateUUID:$,clamp:E,euclideanModulo:ns,mapLinear:hn,inverseLerp:cn,lerp:he,damp:ln,pingpong:un,smoothstep:dn,smootherstep:pn,randInt:fn,randFloat:mn,randFloatSpread:yn,seededRandom:gn,degToRad:xn,radToDeg:bn,isPowerOfTwo:Mn,ceilPowerOfTwo:wn,floorPowerOfTwo:_n,setQuaternionFromProperEuler:Tn,normalize:I,denormalize:Q};class k{constructor(t=0,e=0){k.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,s=this.y,i=t.elements;return this.x=i[0]*e+i[3]*s+i[6],this.y=i[1]*e+i[4]*s+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=E(this.x,t.x,e.x),this.y=E(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=E(this.x,t,e),this.y=E(this.y,t,e),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(E(s,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(E(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const s=Math.cos(e),i=Math.sin(e),n=this.x-t.x,r=this.y-t.y;return this.x=n*s-r*i+t.x,this.y=n*i+r*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class bt{constructor(t=0,e=0,s=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=s,this._w=i}static slerpFlat(t,e,s,i,n,r,o){let a=s[i+0],h=s[i+1],c=s[i+2],l=s[i+3];const u=n[r+0],p=n[r+1],f=n[r+2],m=n[r+3];if(o===0){t[e+0]=a,t[e+1]=h,t[e+2]=c,t[e+3]=l;return}if(o===1){t[e+0]=u,t[e+1]=p,t[e+2]=f,t[e+3]=m;return}if(l!==m||a!==u||h!==p||c!==f){let y=1-o;const x=a*u+h*p+c*f+l*m,M=x>=0?1:-1,w=1-x*x;if(w>Number.EPSILON){const _=Math.sqrt(w),A=Math.atan2(_,x*M);y=Math.sin(y*A)/_,o=Math.sin(o*A)/_}const b=o*M;if(a=a*y+u*b,h=h*y+p*b,c=c*y+f*b,l=l*y+m*b,y===1-o){const _=1/Math.sqrt(a*a+h*h+c*c+l*l);a*=_,h*=_,c*=_,l*=_}}t[e]=a,t[e+1]=h,t[e+2]=c,t[e+3]=l}static multiplyQuaternionsFlat(t,e,s,i,n,r){const o=s[i],a=s[i+1],h=s[i+2],c=s[i+3],l=n[r],u=n[r+1],p=n[r+2],f=n[r+3];return t[e]=o*f+c*l+a*p-h*u,t[e+1]=a*f+c*u+h*l-o*p,t[e+2]=h*f+c*p+o*u-a*l,t[e+3]=c*f-o*l-a*u-h*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,s,i){return this._x=t,this._y=e,this._z=s,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const s=t._x,i=t._y,n=t._z,r=t._order,o=Math.cos,a=Math.sin,h=o(s/2),c=o(i/2),l=o(n/2),u=a(s/2),p=a(i/2),f=a(n/2);switch(r){case"XYZ":this._x=u*c*l+h*p*f,this._y=h*p*l-u*c*f,this._z=h*c*f+u*p*l,this._w=h*c*l-u*p*f;break;case"YXZ":this._x=u*c*l+h*p*f,this._y=h*p*l-u*c*f,this._z=h*c*f-u*p*l,this._w=h*c*l+u*p*f;break;case"ZXY":this._x=u*c*l-h*p*f,this._y=h*p*l+u*c*f,this._z=h*c*f+u*p*l,this._w=h*c*l-u*p*f;break;case"ZYX":this._x=u*c*l-h*p*f,this._y=h*p*l+u*c*f,this._z=h*c*f-u*p*l,this._w=h*c*l+u*p*f;break;case"YZX":this._x=u*c*l+h*p*f,this._y=h*p*l+u*c*f,this._z=h*c*f-u*p*l,this._w=h*c*l-u*p*f;break;case"XZY":this._x=u*c*l-h*p*f,this._y=h*p*l-u*c*f,this._z=h*c*f+u*p*l,this._w=h*c*l+u*p*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,i=Math.sin(s);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,s=e[0],i=e[4],n=e[8],r=e[1],o=e[5],a=e[9],h=e[2],c=e[6],l=e[10],u=s+o+l;if(u>0){const p=.5/Math.sqrt(u+1);this._w=.25/p,this._x=(c-a)*p,this._y=(n-h)*p,this._z=(r-i)*p}else if(s>o&&s>l){const p=2*Math.sqrt(1+s-o-l);this._w=(c-a)/p,this._x=.25*p,this._y=(i+r)/p,this._z=(n+h)/p}else if(o>l){const p=2*Math.sqrt(1+o-s-l);this._w=(n-h)/p,this._x=(i+r)/p,this._y=.25*p,this._z=(a+c)/p}else{const p=2*Math.sqrt(1+l-s-o);this._w=(r-i)/p,this._x=(n+h)/p,this._y=(a+c)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return s<1e-8?(s=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(E(this.dot(t),-1,1)))}rotateTowards(t,e){const s=this.angleTo(t);if(s===0)return this;const i=Math.min(1,e/s);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const s=t._x,i=t._y,n=t._z,r=t._w,o=e._x,a=e._y,h=e._z,c=e._w;return this._x=s*c+r*o+i*h-n*a,this._y=i*c+r*a+n*o-s*h,this._z=n*c+r*h+s*a-i*o,this._w=r*c-s*o-i*a-n*h,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const s=this._x,i=this._y,n=this._z,r=this._w;let o=r*t._w+s*t._x+i*t._y+n*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=r,this._x=s,this._y=i,this._z=n,this;const a=1-o*o;if(a<=Number.EPSILON){const p=1-e;return this._w=p*r+e*this._w,this._x=p*s+e*this._x,this._y=p*i+e*this._y,this._z=p*n+e*this._z,this.normalize(),this}const h=Math.sqrt(a),c=Math.atan2(h,o),l=Math.sin((1-e)*c)/h,u=Math.sin(e*c)/h;return this._w=r*l+this._w*u,this._x=s*l+this._x*u,this._y=i*l+this._y*u,this._z=n*l+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,s){return this.copy(t).slerp(e,s)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),s=Math.random(),i=Math.sqrt(1-s),n=Math.sqrt(s);return this.set(i*Math.sin(t),i*Math.cos(t),n*Math.sin(e),n*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class g{constructor(t=0,e=0,s=0){g.prototype.isVector3=!0,this.x=t,this.y=e,this.z=s}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(ri.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(ri.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[3]*s+n[6]*i,this.y=n[1]*e+n[4]*s+n[7]*i,this.z=n[2]*e+n[5]*s+n[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,s=this.y,i=this.z,n=t.elements,r=1/(n[3]*e+n[7]*s+n[11]*i+n[15]);return this.x=(n[0]*e+n[4]*s+n[8]*i+n[12])*r,this.y=(n[1]*e+n[5]*s+n[9]*i+n[13])*r,this.z=(n[2]*e+n[6]*s+n[10]*i+n[14])*r,this}applyQuaternion(t){const e=this.x,s=this.y,i=this.z,n=t.x,r=t.y,o=t.z,a=t.w,h=2*(r*i-o*s),c=2*(o*e-n*i),l=2*(n*s-r*e);return this.x=e+a*h+r*l-o*c,this.y=s+a*c+o*h-n*l,this.z=i+a*l+n*c-r*h,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[4]*s+n[8]*i,this.y=n[1]*e+n[5]*s+n[9]*i,this.z=n[2]*e+n[6]*s+n[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=E(this.x,t.x,e.x),this.y=E(this.y,t.y,e.y),this.z=E(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=E(this.x,t,e),this.y=E(this.y,t,e),this.z=E(this.z,t,e),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(E(s,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const s=t.x,i=t.y,n=t.z,r=e.x,o=e.y,a=e.z;return this.x=i*a-n*o,this.y=n*r-s*a,this.z=s*o-i*r,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return rs.copy(this).projectOnVector(t),this.sub(rs)}reflect(t){return this.sub(rs.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(E(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y,i=this.z-t.z;return e*e+s*s+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,s){const i=Math.sin(e)*t;return this.x=i*Math.sin(s),this.y=Math.cos(e)*t,this.z=i*Math.cos(s),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,s){return this.x=t*Math.sin(e),this.y=s,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const rs=new g,ri=new bt;class ht{constructor(t,e,s,i,n,r,o,a,h){ht.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,r,o,a,h)}set(t,e,s,i,n,r,o,a,h){const c=this.elements;return c[0]=t,c[1]=i,c[2]=o,c[3]=e,c[4]=n,c[5]=a,c[6]=s,c[7]=r,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,i=e.elements,n=this.elements,r=s[0],o=s[3],a=s[6],h=s[1],c=s[4],l=s[7],u=s[2],p=s[5],f=s[8],m=i[0],y=i[3],x=i[6],M=i[1],w=i[4],b=i[7],_=i[2],A=i[5],T=i[8];return n[0]=r*m+o*M+a*_,n[3]=r*y+o*w+a*A,n[6]=r*x+o*b+a*T,n[1]=h*m+c*M+l*_,n[4]=h*y+c*w+l*A,n[7]=h*x+c*b+l*T,n[2]=u*m+p*M+f*_,n[5]=u*y+p*w+f*A,n[8]=u*x+p*b+f*T,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],c=t[8];return e*r*c-e*o*h-s*n*c+s*o*a+i*n*h-i*r*a}invert(){const t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],c=t[8],l=c*r-o*h,u=o*a-c*n,p=h*n-r*a,f=e*l+s*u+i*p;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/f;return t[0]=l*m,t[1]=(i*h-c*s)*m,t[2]=(o*s-i*r)*m,t[3]=u*m,t[4]=(c*e-i*a)*m,t[5]=(i*n-o*e)*m,t[6]=p*m,t[7]=(s*a-h*e)*m,t[8]=(r*e-s*n)*m,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,s,i,n,r,o){const a=Math.cos(n),h=Math.sin(n);return this.set(s*a,s*h,-s*(a*r+h*o)+r+t,-i*h,i*a,-i*(-h*r+a*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(os.makeScale(t,e)),this}rotate(t){return this.premultiply(os.makeRotation(-t)),this}translate(t,e){return this.premultiply(os.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,s=t.elements;for(let i=0;i<9;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const os=new ht;function An(d){for(let t=d.length-1;t>=0;--t)if(d[t]>=65535)return!0;return!1}function as(d){return document.createElementNS("http://www.w3.org/1999/xhtml",d)}const oi={};function ai(d){d in oi||(oi[d]=!0,console.warn(d))}const hi=new ht().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ci=new ht().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function En(){const d={enabled:!0,workingColorSpace:K,spaces:{},convert:function(i,n,r){return this.enabled===!1||n===r||!n||!r||(this.spaces[n].transfer===is&&(i.r=ct(i.r),i.g=ct(i.g),i.b=ct(i.b)),this.spaces[n].primaries!==this.spaces[r].primaries&&(i.applyMatrix3(this.spaces[n].toXYZ),i.applyMatrix3(this.spaces[r].fromXYZ)),this.spaces[r].transfer===is&&(i.r=Ot(i.r),i.g=Ot(i.g),i.b=Ot(i.b))),i},workingToColorSpace:function(i,n){return this.convert(i,this.workingColorSpace,n)},colorSpaceToWorking:function(i,n){return this.convert(i,n,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===si?ii:this.spaces[i].transfer},getLuminanceCoefficients:function(i,n=this.workingColorSpace){return i.fromArray(this.spaces[n].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,n,r){return i.copy(this.spaces[n].toXYZ).multiply(this.spaces[r].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,n){return ai("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),d.workingToColorSpace(i,n)},toWorkingColorSpace:function(i,n){return ai("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),d.colorSpaceToWorking(i,n)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],s=[.3127,.329];return d.define({[K]:{primaries:t,whitePoint:s,transfer:ii,toXYZ:hi,fromXYZ:ci,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:P},outputColorSpaceConfig:{drawingBufferColorSpace:P}},[P]:{primaries:t,whitePoint:s,transfer:is,toXYZ:hi,fromXYZ:ci,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:P}}}),d}const G=En();function ct(d){return d<.04045?d*.0773993808:Math.pow(d*.9478672986+.0521327014,2.4)}function Ot(d){return d<.0031308?d*12.92:1.055*Math.pow(d,.41666)-.055}let Dt;class Rn{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let s;if(t instanceof HTMLCanvasElement)s=t;else{Dt===void 0&&(Dt=as("canvas")),Dt.width=t.width,Dt.height=t.height;const i=Dt.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),s=Dt}return s.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=as("canvas");e.width=t.width,e.height=t.height;const s=e.getContext("2d");s.drawImage(t,0,0,t.width,t.height);const i=s.getImageData(0,0,t.width,t.height),n=i.data;for(let r=0;r<n.length;r++)n[r]=ct(n[r]/255)*255;return s.putImageData(i,0,0),e}else if(t.data){const e=t.data.slice(0);for(let s=0;s<e.length;s++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[s]=Math.floor(ct(e[s]/255)*255):e[s]=ct(e[s]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let zn=0;class In{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:zn++}),this.uuid=$(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const s={uuid:this.uuid,url:""},i=this.data;if(i!==null){let n;if(Array.isArray(i)){n=[];for(let r=0,o=i.length;r<o;r++)i[r].isDataTexture?n.push(hs(i[r].image)):n.push(hs(i[r]))}else n=hs(i);s.url=n}return e||(t.images[this.uuid]=s),s}}function hs(d){return typeof HTMLImageElement<"u"&&d instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&d instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&d instanceof ImageBitmap?Rn.getDataURL(d):d.data?{data:Array.from(d.data),width:d.width,height:d.height,type:d.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Cn=0;const cs=new g;class tt extends Me{constructor(t=tt.DEFAULT_IMAGE,e=tt.DEFAULT_MAPPING,s=1001,i=1001,n=1006,r=1008,o=1023,a=1009,h=tt.DEFAULT_ANISOTROPY,c=si){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Cn++}),this.uuid=$(),this.name="",this.source=new In(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=s,this.wrapT=i,this.magFilter=n,this.minFilter=r,this.anisotropy=h,this.format=o,this.internalFormat=null,this.type=a,this.offset=new k(0,0),this.repeat=new k(1,1),this.center=new k(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ht,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(cs).x}get height(){return this.source.getSize(cs).y}get depth(){return this.source.getSize(cs).z}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const s=t[e];if(s===void 0){console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){console.warn(`THREE.Texture.setValues(): property '${e}' does not exist.`);continue}i&&s&&i.isVector2&&s.isVector2||i&&s&&i.isVector3&&s.isVector3||i&&s&&i.isMatrix3&&s.isMatrix3?i.copy(s):this[e]=s}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const s={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(s.userData=this.userData),e||(t.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==300)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case 1e3:t.x=t.x-Math.floor(t.x);break;case 1001:t.x=t.x<0?0:1;break;case 1002:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case 1e3:t.y=t.y-Math.floor(t.y);break;case 1001:t.y=t.y<0?0:1;break;case 1002:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}tt.DEFAULT_IMAGE=null,tt.DEFAULT_MAPPING=300,tt.DEFAULT_ANISOTROPY=1;class W{constructor(t=0,e=0,s=0,i=1){W.prototype.isVector4=!0,this.x=t,this.y=e,this.z=s,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,s,i){return this.x=t,this.y=e,this.z=s,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,s=this.y,i=this.z,n=this.w,r=t.elements;return this.x=r[0]*e+r[4]*s+r[8]*i+r[12]*n,this.y=r[1]*e+r[5]*s+r[9]*i+r[13]*n,this.z=r[2]*e+r[6]*s+r[10]*i+r[14]*n,this.w=r[3]*e+r[7]*s+r[11]*i+r[15]*n,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,s,i,n;const a=t.elements,h=a[0],c=a[4],l=a[8],u=a[1],p=a[5],f=a[9],m=a[2],y=a[6],x=a[10];if(Math.abs(c-u)<.01&&Math.abs(l-m)<.01&&Math.abs(f-y)<.01){if(Math.abs(c+u)<.1&&Math.abs(l+m)<.1&&Math.abs(f+y)<.1&&Math.abs(h+p+x-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const w=(h+1)/2,b=(p+1)/2,_=(x+1)/2,A=(c+u)/4,T=(l+m)/4,S=(f+y)/4;return w>b&&w>_?w<.01?(s=0,i=.707106781,n=.707106781):(s=Math.sqrt(w),i=A/s,n=T/s):b>_?b<.01?(s=.707106781,i=0,n=.707106781):(i=Math.sqrt(b),s=A/i,n=S/i):_<.01?(s=.707106781,i=.707106781,n=0):(n=Math.sqrt(_),s=T/n,i=S/n),this.set(s,i,n,e),this}let M=Math.sqrt((y-f)*(y-f)+(l-m)*(l-m)+(u-c)*(u-c));return Math.abs(M)<.001&&(M=1),this.x=(y-f)/M,this.y=(l-m)/M,this.z=(u-c)/M,this.w=Math.acos((h+p+x-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=E(this.x,t.x,e.x),this.y=E(this.y,t.y,e.y),this.z=E(this.z,t.z,e.z),this.w=E(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=E(this.x,t,e),this.y=E(this.y,t,e),this.z=E(this.z,t,e),this.w=E(this.w,t,e),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(E(s,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this.w=t.w+(e.w-t.w)*s,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class lt{constructor(t=new g(1/0,1/0,1/0),e=new g(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e+=3)this.expandByPoint(et.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,s=t.count;e<s;e++)this.expandByPoint(et.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=et.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const s=t.geometry;if(s!==void 0){const n=s.getAttribute("position");if(e===!0&&n!==void 0&&t.isInstancedMesh!==!0)for(let r=0,o=n.count;r<o;r++)t.isMesh===!0?t.getVertexPosition(r,et):et.fromBufferAttribute(n,r),et.applyMatrix4(t.matrixWorld),this.expandByPoint(et);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),we.copy(t.boundingBox)):(s.boundingBox===null&&s.computeBoundingBox(),we.copy(s.boundingBox)),we.applyMatrix4(t.matrixWorld),this.union(we)}const i=t.children;for(let n=0,r=i.length;n<r;n++)this.expandByObject(i[n],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,et),et.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,s;return t.normal.x>0?(e=t.normal.x*this.min.x,s=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,s=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,s+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,s+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,s+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,s+=t.normal.z*this.min.z),e<=-t.constant&&s>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(ce),_e.subVectors(this.max,ce),Ut.subVectors(t.a,ce),Vt.subVectors(t.b,ce),Ht.subVectors(t.c,ce),Mt.subVectors(Vt,Ut),wt.subVectors(Ht,Vt),It.subVectors(Ut,Ht);let e=[0,-Mt.z,Mt.y,0,-wt.z,wt.y,0,-It.z,It.y,Mt.z,0,-Mt.x,wt.z,0,-wt.x,It.z,0,-It.x,-Mt.y,Mt.x,0,-wt.y,wt.x,0,-It.y,It.x,0];return!ls(e,Ut,Vt,Ht,_e)||(e=[1,0,0,0,1,0,0,0,1],!ls(e,Ut,Vt,Ht,_e))?!1:(Te.crossVectors(Mt,wt),e=[Te.x,Te.y,Te.z],ls(e,Ut,Vt,Ht,_e))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,et).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(et).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(ut[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ut[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ut[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ut[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ut[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ut[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ut[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ut[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ut),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const ut=[new g,new g,new g,new g,new g,new g,new g,new g],et=new g,we=new lt,Ut=new g,Vt=new g,Ht=new g,Mt=new g,wt=new g,It=new g,ce=new g,_e=new g,Te=new g,Ct=new g;function ls(d,t,e,s,i){for(let n=0,r=d.length-3;n<=r;n+=3){Ct.fromArray(d,n);const o=i.x*Math.abs(Ct.x)+i.y*Math.abs(Ct.y)+i.z*Math.abs(Ct.z),a=t.dot(Ct),h=e.dot(Ct),c=s.dot(Ct);if(Math.max(-Math.max(a,h,c),Math.min(a,h,c))>o)return!1}return!0}const Fn=new lt,le=new g,us=new g;class ot{constructor(t=new g,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const s=this.center;e!==void 0?s.copy(e):Fn.setFromPoints(t).getCenter(s);let i=0;for(let n=0,r=t.length;n<r;n++)i=Math.max(i,s.distanceToSquared(t[n]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const s=this.center.distanceToSquared(t);return e.copy(t),s>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;le.subVectors(t,this.center);const e=le.lengthSq();if(e>this.radius*this.radius){const s=Math.sqrt(e),i=(s-this.radius)*.5;this.center.addScaledVector(le,i/s),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(us.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(le.copy(t.center).add(us)),this.expandByPoint(le.copy(t.center).sub(us))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}const dt=new g,ds=new g,Se=new g,_t=new g,ps=new g,Ae=new g,fs=new g;class Ee{constructor(t=new g,e=new g(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,dt)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const s=e.dot(this.direction);return s<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,s)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=dt.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(dt.copy(this.origin).addScaledVector(this.direction,e),dt.distanceToSquared(t))}distanceSqToSegment(t,e,s,i){ds.copy(t).add(e).multiplyScalar(.5),Se.copy(e).sub(t).normalize(),_t.copy(this.origin).sub(ds);const n=t.distanceTo(e)*.5,r=-this.direction.dot(Se),o=_t.dot(this.direction),a=-_t.dot(Se),h=_t.lengthSq(),c=Math.abs(1-r*r);let l,u,p,f;if(c>0)if(l=r*a-o,u=r*o-a,f=n*c,l>=0)if(u>=-f)if(u<=f){const m=1/c;l*=m,u*=m,p=l*(l+r*u+2*o)+u*(r*l+u+2*a)+h}else u=n,l=Math.max(0,-(r*u+o)),p=-l*l+u*(u+2*a)+h;else u=-n,l=Math.max(0,-(r*u+o)),p=-l*l+u*(u+2*a)+h;else u<=-f?(l=Math.max(0,-(-r*n+o)),u=l>0?-n:Math.min(Math.max(-n,-a),n),p=-l*l+u*(u+2*a)+h):u<=f?(l=0,u=Math.min(Math.max(-n,-a),n),p=u*(u+2*a)+h):(l=Math.max(0,-(r*n+o)),u=l>0?n:Math.min(Math.max(-n,-a),n),p=-l*l+u*(u+2*a)+h);else u=r>0?-n:n,l=Math.max(0,-(r*u+o)),p=-l*l+u*(u+2*a)+h;return s&&s.copy(this.origin).addScaledVector(this.direction,l),i&&i.copy(ds).addScaledVector(Se,u),p}intersectSphere(t,e){dt.subVectors(t.center,this.origin);const s=dt.dot(this.direction),i=dt.dot(dt)-s*s,n=t.radius*t.radius;if(i>n)return null;const r=Math.sqrt(n-i),o=s-r,a=s+r;return a<0?null:o<0?this.at(a,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const s=-(this.origin.dot(t.normal)+t.constant)/e;return s>=0?s:null}intersectPlane(t,e){const s=this.distanceToPlane(t);return s===null?null:this.at(s,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let s,i,n,r,o,a;const h=1/this.direction.x,c=1/this.direction.y,l=1/this.direction.z,u=this.origin;return h>=0?(s=(t.min.x-u.x)*h,i=(t.max.x-u.x)*h):(s=(t.max.x-u.x)*h,i=(t.min.x-u.x)*h),c>=0?(n=(t.min.y-u.y)*c,r=(t.max.y-u.y)*c):(n=(t.max.y-u.y)*c,r=(t.min.y-u.y)*c),s>r||n>i||((n>s||isNaN(s))&&(s=n),(r<i||isNaN(i))&&(i=r),l>=0?(o=(t.min.z-u.z)*l,a=(t.max.z-u.z)*l):(o=(t.max.z-u.z)*l,a=(t.min.z-u.z)*l),s>a||o>i)||((o>s||s!==s)&&(s=o),(a<i||i!==i)&&(i=a),i<0)?null:this.at(s>=0?s:i,e)}intersectsBox(t){return this.intersectBox(t,dt)!==null}intersectTriangle(t,e,s,i,n){ps.subVectors(e,t),Ae.subVectors(s,t),fs.crossVectors(ps,Ae);let r=this.direction.dot(fs),o;if(r>0){if(i)return null;o=1}else if(r<0)o=-1,r=-r;else return null;_t.subVectors(this.origin,t);const a=o*this.direction.dot(Ae.crossVectors(_t,Ae));if(a<0)return null;const h=o*this.direction.dot(ps.cross(_t));if(h<0||a+h>r)return null;const c=-o*_t.dot(fs);return c<0?null:this.at(c/r,n)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class z{constructor(t,e,s,i,n,r,o,a,h,c,l,u,p,f,m,y){z.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,r,o,a,h,c,l,u,p,f,m,y)}set(t,e,s,i,n,r,o,a,h,c,l,u,p,f,m,y){const x=this.elements;return x[0]=t,x[4]=e,x[8]=s,x[12]=i,x[1]=n,x[5]=r,x[9]=o,x[13]=a,x[2]=h,x[6]=c,x[10]=l,x[14]=u,x[3]=p,x[7]=f,x[11]=m,x[15]=y,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 z().fromArray(this.elements)}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){const e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,s=t.elements,i=1/Wt.setFromMatrixColumn(t,0).length(),n=1/Wt.setFromMatrixColumn(t,1).length(),r=1/Wt.setFromMatrixColumn(t,2).length();return e[0]=s[0]*i,e[1]=s[1]*i,e[2]=s[2]*i,e[3]=0,e[4]=s[4]*n,e[5]=s[5]*n,e[6]=s[6]*n,e[7]=0,e[8]=s[8]*r,e[9]=s[9]*r,e[10]=s[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,s=t.x,i=t.y,n=t.z,r=Math.cos(s),o=Math.sin(s),a=Math.cos(i),h=Math.sin(i),c=Math.cos(n),l=Math.sin(n);if(t.order==="XYZ"){const u=r*c,p=r*l,f=o*c,m=o*l;e[0]=a*c,e[4]=-a*l,e[8]=h,e[1]=p+f*h,e[5]=u-m*h,e[9]=-o*a,e[2]=m-u*h,e[6]=f+p*h,e[10]=r*a}else if(t.order==="YXZ"){const u=a*c,p=a*l,f=h*c,m=h*l;e[0]=u+m*o,e[4]=f*o-p,e[8]=r*h,e[1]=r*l,e[5]=r*c,e[9]=-o,e[2]=p*o-f,e[6]=m+u*o,e[10]=r*a}else if(t.order==="ZXY"){const u=a*c,p=a*l,f=h*c,m=h*l;e[0]=u-m*o,e[4]=-r*l,e[8]=f+p*o,e[1]=p+f*o,e[5]=r*c,e[9]=m-u*o,e[2]=-r*h,e[6]=o,e[10]=r*a}else if(t.order==="ZYX"){const u=r*c,p=r*l,f=o*c,m=o*l;e[0]=a*c,e[4]=f*h-p,e[8]=u*h+m,e[1]=a*l,e[5]=m*h+u,e[9]=p*h-f,e[2]=-h,e[6]=o*a,e[10]=r*a}else if(t.order==="YZX"){const u=r*a,p=r*h,f=o*a,m=o*h;e[0]=a*c,e[4]=m-u*l,e[8]=f*l+p,e[1]=l,e[5]=r*c,e[9]=-o*c,e[2]=-h*c,e[6]=p*l+f,e[10]=u-m*l}else if(t.order==="XZY"){const u=r*a,p=r*h,f=o*a,m=o*h;e[0]=a*c,e[4]=-l,e[8]=h*c,e[1]=u*l+m,e[5]=r*c,e[9]=p*l-f,e[2]=f*l-p,e[6]=o*c,e[10]=m*l+u}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(kn,t,Ln)}lookAt(t,e,s){const i=this.elements;return q.subVectors(t,e),q.lengthSq()===0&&(q.z=1),q.normalize(),Tt.crossVectors(s,q),Tt.lengthSq()===0&&(Math.abs(s.z)===1?q.x+=1e-4:q.z+=1e-4,q.normalize(),Tt.crossVectors(s,q)),Tt.normalize(),Re.crossVectors(q,Tt),i[0]=Tt.x,i[4]=Re.x,i[8]=q.x,i[1]=Tt.y,i[5]=Re.y,i[9]=q.y,i[2]=Tt.z,i[6]=Re.z,i[10]=q.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,i=e.elements,n=this.elements,r=s[0],o=s[4],a=s[8],h=s[12],c=s[1],l=s[5],u=s[9],p=s[13],f=s[2],m=s[6],y=s[10],x=s[14],M=s[3],w=s[7],b=s[11],_=s[15],A=i[0],T=i[4],S=i[8],F=i[12],v=i[1],V=i[5],Rt=i[9],H=i[13],zt=i[2],Je=i[6],Ze=i[10],$e=i[14],Qe=i[3],ts=i[7],es=i[11],ss=i[15];return n[0]=r*A+o*v+a*zt+h*Qe,n[4]=r*T+o*V+a*Je+h*ts,n[8]=r*S+o*Rt+a*Ze+h*es,n[12]=r*F+o*H+a*$e+h*ss,n[1]=c*A+l*v+u*zt+p*Qe,n[5]=c*T+l*V+u*Je+p*ts,n[9]=c*S+l*Rt+u*Ze+p*es,n[13]=c*F+l*H+u*$e+p*ss,n[2]=f*A+m*v+y*zt+x*Qe,n[6]=f*T+m*V+y*Je+x*ts,n[10]=f*S+m*Rt+y*Ze+x*es,n[14]=f*F+m*H+y*$e+x*ss,n[3]=M*A+w*v+b*zt+_*Qe,n[7]=M*T+w*V+b*Je+_*ts,n[11]=M*S+w*Rt+b*Ze+_*es,n[15]=M*F+w*H+b*$e+_*ss,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[4],i=t[8],n=t[12],r=t[1],o=t[5],a=t[9],h=t[13],c=t[2],l=t[6],u=t[10],p=t[14],f=t[3],m=t[7],y=t[11],x=t[15];return f*(+n*a*l-i*h*l-n*o*u+s*h*u+i*o*p-s*a*p)+m*(+e*a*p-e*h*u+n*r*u-i*r*p+i*h*c-n*a*c)+y*(+e*h*l-e*o*p-n*r*l+s*r*p+n*o*c-s*h*c)+x*(-i*o*c-e*a*l+e*o*u+i*r*l-s*r*u+s*a*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=s),this}invert(){const t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],c=t[8],l=t[9],u=t[10],p=t[11],f=t[12],m=t[13],y=t[14],x=t[15],M=l*y*h-m*u*h+m*a*p-o*y*p-l*a*x+o*u*x,w=f*u*h-c*y*h-f*a*p+r*y*p+c*a*x-r*u*x,b=c*m*h-f*l*h+f*o*p-r*m*p-c*o*x+r*l*x,_=f*l*a-c*m*a-f*o*u+r*m*u+c*o*y-r*l*y,A=e*M+s*w+i*b+n*_;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/A;return t[0]=M*T,t[1]=(m*u*n-l*y*n-m*i*p+s*y*p+l*i*x-s*u*x)*T,t[2]=(o*y*n-m*a*n+m*i*h-s*y*h-o*i*x+s*a*x)*T,t[3]=(l*a*n-o*u*n-l*i*h+s*u*h+o*i*p-s*a*p)*T,t[4]=w*T,t[5]=(c*y*n-f*u*n+f*i*p-e*y*p-c*i*x+e*u*x)*T,t[6]=(f*a*n-r*y*n-f*i*h+e*y*h+r*i*x-e*a*x)*T,t[7]=(r*u*n-c*a*n+c*i*h-e*u*h-r*i*p+e*a*p)*T,t[8]=b*T,t[9]=(f*l*n-c*m*n-f*s*p+e*m*p+c*s*x-e*l*x)*T,t[10]=(r*m*n-f*o*n+f*s*h-e*m*h-r*s*x+e*o*x)*T,t[11]=(c*o*n-r*l*n-c*s*h+e*l*h+r*s*p-e*o*p)*T,t[12]=_*T,t[13]=(c*m*i-f*l*i+f*s*u-e*m*u-c*s*y+e*l*y)*T,t[14]=(f*o*i-r*m*i-f*s*a+e*m*a+r*s*y-e*o*y)*T,t[15]=(r*l*i-c*o*i+c*s*a-e*l*a-r*s*u+e*o*u)*T,this}scale(t){const e=this.elements,s=t.x,i=t.y,n=t.z;return e[0]*=s,e[4]*=i,e[8]*=n,e[1]*=s,e[5]*=i,e[9]*=n,e[2]*=s,e[6]*=i,e[10]*=n,e[3]*=s,e[7]*=i,e[11]*=n,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,i))}makeTranslation(t,e,s){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const s=Math.cos(e),i=Math.sin(e),n=1-s,r=t.x,o=t.y,a=t.z,h=n*r,c=n*o;return this.set(h*r+s,h*o-i*a,h*a+i*o,0,h*o+i*a,c*o+s,c*a-i*r,0,h*a-i*o,c*a+i*r,n*a*a+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,i,n,r){return this.set(1,s,n,0,t,1,r,0,e,i,1,0,0,0,0,1),this}compose(t,e,s){const i=this.elements,n=e._x,r=e._y,o=e._z,a=e._w,h=n+n,c=r+r,l=o+o,u=n*h,p=n*c,f=n*l,m=r*c,y=r*l,x=o*l,M=a*h,w=a*c,b=a*l,_=s.x,A=s.y,T=s.z;return i[0]=(1-(m+x))*_,i[1]=(p+b)*_,i[2]=(f-w)*_,i[3]=0,i[4]=(p-b)*A,i[5]=(1-(u+x))*A,i[6]=(y+M)*A,i[7]=0,i[8]=(f+w)*T,i[9]=(y-M)*T,i[10]=(1-(u+m))*T,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,s){const i=this.elements;let n=Wt.set(i[0],i[1],i[2]).length();const r=Wt.set(i[4],i[5],i[6]).length(),o=Wt.set(i[8],i[9],i[10]).length();this.determinant()<0&&(n=-n),t.x=i[12],t.y=i[13],t.z=i[14],st.copy(this);const h=1/n,c=1/r,l=1/o;return st.elements[0]*=h,st.elements[1]*=h,st.elements[2]*=h,st.elements[4]*=c,st.elements[5]*=c,st.elements[6]*=c,st.elements[8]*=l,st.elements[9]*=l,st.elements[10]*=l,e.setFromRotationMatrix(st),s.x=n,s.y=r,s.z=o,this}makePerspective(t,e,s,i,n,r,o=2e3){const a=this.elements,h=2*n/(e-t),c=2*n/(s-i),l=(e+t)/(e-t),u=(s+i)/(s-i);let p,f;if(o===2e3)p=-(r+n)/(r-n),f=-2*r*n/(r-n);else if(o===2001)p=-r/(r-n),f=-r*n/(r-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return a[0]=h,a[4]=0,a[8]=l,a[12]=0,a[1]=0,a[5]=c,a[9]=u,a[13]=0,a[2]=0,a[6]=0,a[10]=p,a[14]=f,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,e,s,i,n,r,o=2e3){const a=this.elements,h=1/(e-t),c=1/(s-i),l=1/(r-n),u=(e+t)*h,p=(s+i)*c;let f,m;if(o===2e3)f=(r+n)*l,m=-2*l;else if(o===2001)f=n*l,m=-1*l;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return a[0]=2*h,a[4]=0,a[8]=0,a[12]=-u,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-p,a[2]=0,a[6]=0,a[10]=m,a[14]=-f,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){const e=this.elements,s=t.elements;for(let i=0;i<16;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}}const Wt=new g,st=new z,kn=new g(0,0,0),Ln=new g(1,1,1),Tt=new g,Re=new g,q=new g,li=new z,ui=new bt;class jt{constructor(t=0,e=0,s=0,i=jt.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=s,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,s,i=this._order){return this._x=t,this._y=e,this._z=s,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,s=!0){const i=t.elements,n=i[0],r=i[4],o=i[8],a=i[1],h=i[5],c=i[9],l=i[2],u=i[6],p=i[10];switch(e){case"XYZ":this._y=Math.asin(E(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,p),this._z=Math.atan2(-r,n)):(this._x=Math.atan2(u,h),this._z=0);break;case"YXZ":this._x=Math.asin(-E(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(a,h)):(this._y=Math.atan2(-l,n),this._z=0);break;case"ZXY":this._x=Math.asin(E(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-l,p),this._z=Math.atan2(-r,h)):(this._y=0,this._z=Math.atan2(a,n));break;case"ZYX":this._y=Math.asin(-E(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(u,p),this._z=Math.atan2(a,n)):(this._x=0,this._z=Math.atan2(-r,h));break;case"YZX":this._z=Math.asin(E(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,h),this._y=Math.atan2(-l,n)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-E(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(u,h),this._y=Math.atan2(o,n)):(this._x=Math.atan2(-c,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,s===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,s){return li.makeRotationFromQuaternion(t),this.setFromRotationMatrix(li,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return ui.setFromEuler(this),this.setFromQuaternion(ui,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}jt.DEFAULT_ORDER="XYZ";class Nn{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let Bn=0;const di=new g,Gt=new bt,pt=new z,ze=new g,ue=new g,vn=new g,Pn=new bt,pi=new g(1,0,0),fi=new g(0,1,0),mi=new g(0,0,1),yi={type:"added"},On={type:"removed"},qt={type:"childadded",child:null},ms={type:"childremoved",child:null};class L extends Me{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Bn++}),this.uuid=$(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=L.DEFAULT_UP.clone();const t=new g,e=new jt,s=new bt,i=new g(1,1,1);function n(){s.setFromEuler(e,!1)}function r(){e.setFromQuaternion(s,void 0,!1)}e._onChange(n),s._onChange(r),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:s},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new z},normalMatrix:{value:new ht}}),this.matrix=new z,this.matrixWorld=new z,this.matrixAutoUpdate=L.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=L.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Nn,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Gt.setFromAxisAngle(t,e),this.quaternion.multiply(Gt),this}rotateOnWorldAxis(t,e){return Gt.setFromAxisAngle(t,e),this.quaternion.premultiply(Gt),this}rotateX(t){return this.rotateOnAxis(pi,t)}rotateY(t){return this.rotateOnAxis(fi,t)}rotateZ(t){return this.rotateOnAxis(mi,t)}translateOnAxis(t,e){return di.copy(t).applyQuaternion(this.quaternion),this.position.add(di.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(pi,t)}translateY(t){return this.translateOnAxis(fi,t)}translateZ(t){return this.translateOnAxis(mi,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(pt.copy(this.matrixWorld).invert())}lookAt(t,e,s){t.isVector3?ze.copy(t):ze.set(t,e,s);const i=this.parent;this.updateWorldMatrix(!0,!1),ue.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?pt.lookAt(ue,ze,this.up):pt.lookAt(ze,ue,this.up),this.quaternion.setFromRotationMatrix(pt),i&&(pt.extractRotation(i.matrixWorld),Gt.setFromRotationMatrix(pt),this.quaternion.premultiply(Gt.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(yi),qt.child=t,this.dispatchEvent(qt),qt.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let s=0;s<arguments.length;s++)this.remove(arguments[s]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(On),ms.child=t,this.dispatchEvent(ms),ms.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),pt.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),pt.multiply(t.parent.matrixWorld)),t.applyMatrix4(pt),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(yi),qt.child=t,this.dispatchEvent(qt),qt.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let s=0,i=this.children.length;s<i;s++){const r=this.children[s].getObjectByProperty(t,e);if(r!==void 0)return r}}getObjectsByProperty(t,e,s=[]){this[t]===e&&s.push(this);const i=this.children;for(let n=0,r=i.length;n<r;n++)i[n].getObjectsByProperty(t,e,s);return s}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ue,t,vn),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ue,Pn,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let s=0,i=e.length;s<i;s++)e[s].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let s=0,i=e.length;s<i;s++)e[s].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let s=0,i=e.length;s<i;s++)e[s].updateMatrixWorld(t)}updateWorldMatrix(t,e){const s=this.parent;if(t===!0&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const i=this.children;for(let n=0,r=i.length;n<r;n++)i[n].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",s={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},s.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function n(o,a){return o[a.uuid]===void 0&&(o[a.uuid]=a.toJSON(t)),a.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=n(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const a=o.shapes;if(Array.isArray(a))for(let h=0,c=a.length;h<c;h++){const l=a[h];n(t.shapes,l)}else n(t.shapes,a)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(n(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let a=0,h=this.material.length;a<h;a++)o.push(n(t.materials,this.material[a]));i.material=o}else i.material=n(t.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const a=this.animations[o];i.animations.push(n(t.animations,a))}}if(e){const o=r(t.geometries),a=r(t.materials),h=r(t.textures),c=r(t.images),l=r(t.shapes),u=r(t.skeletons),p=r(t.animations),f=r(t.nodes);o.length>0&&(s.geometries=o),a.length>0&&(s.materials=a),h.length>0&&(s.textures=h),c.length>0&&(s.images=c),l.length>0&&(s.shapes=l),u.length>0&&(s.skeletons=u),p.length>0&&(s.animations=p),f.length>0&&(s.nodes=f)}return s.object=i,s;function r(o){const a=[];for(const h in o){const c=o[h];delete c.metadata,a.push(c)}return a}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let s=0;s<t.children.length;s++){const i=t.children[s];this.add(i.clone())}return this}}L.DEFAULT_UP=new g(0,1,0),L.DEFAULT_MATRIX_AUTO_UPDATE=!0,L.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const it=new g,ft=new g,ys=new g,mt=new g,Xt=new g,Yt=new g,gi=new g,gs=new g,xs=new g,bs=new g,Ms=new W,ws=new W,_s=new W;class nt{constructor(t=new g,e=new g,s=new g){this.a=t,this.b=e,this.c=s}static getNormal(t,e,s,i){i.subVectors(s,e),it.subVectors(t,e),i.cross(it);const n=i.lengthSq();return n>0?i.multiplyScalar(1/Math.sqrt(n)):i.set(0,0,0)}static getBarycoord(t,e,s,i,n){it.subVectors(i,e),ft.subVectors(s,e),ys.subVectors(t,e);const r=it.dot(it),o=it.dot(ft),a=it.dot(ys),h=ft.dot(ft),c=ft.dot(ys),l=r*h-o*o;if(l===0)return n.set(0,0,0),null;const u=1/l,p=(h*a-o*c)*u,f=(r*c-o*a)*u;return n.set(1-p-f,f,p)}static containsPoint(t,e,s,i){return this.getBarycoord(t,e,s,i,mt)===null?!1:mt.x>=0&&mt.y>=0&&mt.x+mt.y<=1}static getInterpolation(t,e,s,i,n,r,o,a){return this.getBarycoord(t,e,s,i,mt)===null?(a.x=0,a.y=0,"z"in a&&(a.z=0),"w"in a&&(a.w=0),null):(a.setScalar(0),a.addScaledVector(n,mt.x),a.addScaledVector(r,mt.y),a.addScaledVector(o,mt.z),a)}static getInterpolatedAttribute(t,e,s,i,n,r){return Ms.setScalar(0),ws.setScalar(0),_s.setScalar(0),Ms.fromBufferAttribute(t,e),ws.fromBufferAttribute(t,s),_s.fromBufferAttribute(t,i),r.setScalar(0),r.addScaledVector(Ms,n.x),r.addScaledVector(ws,n.y),r.addScaledVector(_s,n.z),r}static isFrontFacing(t,e,s,i){return it.subVectors(s,e),ft.subVectors(t,e),it.cross(ft).dot(i)<0}set(t,e,s){return this.a.copy(t),this.b.copy(e),this.c.copy(s),this}setFromPointsAndIndices(t,e,s,i){return this.a.copy(t[e]),this.b.copy(t[s]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,s,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,s),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return it.subVectors(this.c,this.b),ft.subVectors(this.a,this.b),it.cross(ft).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return nt.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return nt.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,s,i,n){return nt.getInterpolation(t,this.a,this.b,this.c,e,s,i,n)}containsPoint(t){return nt.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return nt.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const s=this.a,i=this.b,n=this.c;let r,o;Xt.subVectors(i,s),Yt.subVectors(n,s),gs.subVectors(t,s);const a=Xt.dot(gs),h=Yt.dot(gs);if(a<=0&&h<=0)return e.copy(s);xs.subVectors(t,i);const c=Xt.dot(xs),l=Yt.dot(xs);if(c>=0&&l<=c)return e.copy(i);const u=a*l-c*h;if(u<=0&&a>=0&&c<=0)return r=a/(a-c),e.copy(s).addScaledVector(Xt,r);bs.subVectors(t,n);const p=Xt.dot(bs),f=Yt.dot(bs);if(f>=0&&p<=f)return e.copy(n);const m=p*h-a*f;if(m<=0&&h>=0&&f<=0)return o=h/(h-f),e.copy(s).addScaledVector(Yt,o);const y=c*f-p*l;if(y<=0&&l-c>=0&&p-f>=0)return gi.subVectors(n,i),o=(l-c)/(l-c+(p-f)),e.copy(i).addScaledVector(gi,o);const x=1/(y+m+u);return r=m*x,o=u*x,e.copy(s).addScaledVector(Xt,r).addScaledVector(Yt,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const xi={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},St={h:0,s:0,l:0},Ie={h:0,s:0,l:0};function Ts(d,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?d+(t-d)*6*e:e<1/2?t:e<2/3?d+(t-d)*6*(2/3-e):d}class N{constructor(t,e,s){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,s)}set(t,e,s){if(e===void 0&&s===void 0){const i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,s);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=P){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,G.colorSpaceToWorking(this,e),this}setRGB(t,e,s,i=G.workingColorSpace){return this.r=t,this.g=e,this.b=s,G.colorSpaceToWorking(this,i),this}setHSL(t,e,s,i=G.workingColorSpace){if(t=ns(t,1),e=E(e,0,1),s=E(s,0,1),e===0)this.r=this.g=this.b=s;else{const n=s<=.5?s*(1+e):s+e-s*e,r=2*s-n;this.r=Ts(r,n,t+1/3),this.g=Ts(r,n,t),this.b=Ts(r,n,t-1/3)}return G.colorSpaceToWorking(this,i),this}setStyle(t,e=P){function s(n){n!==void 0&&parseFloat(n)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let n;const r=i[1],o=i[2];switch(r){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(n[4]),this.setRGB(Math.min(255,parseInt(n[1],10))/255,Math.min(255,parseInt(n[2],10))/255,Math.min(255,parseInt(n[3],10))/255,e);if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(n[4]),this.setRGB(Math.min(100,parseInt(n[1],10))/100,Math.min(100,parseInt(n[2],10))/100,Math.min(100,parseInt(n[3],10))/100,e);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(n[4]),this.setHSL(parseFloat(n[1])/360,parseFloat(n[2])/100,parseFloat(n[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=i[1],r=n.length;if(r===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(r===6)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=P){const s=xi[t.toLowerCase()];return s!==void 0?this.setHex(s,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=ct(t.r),this.g=ct(t.g),this.b=ct(t.b),this}copyLinearToSRGB(t){return this.r=Ot(t.r),this.g=Ot(t.g),this.b=Ot(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=P){return G.workingToColorSpace(U.copy(this),t),Math.round(E(U.r*255,0,255))*65536+Math.round(E(U.g*255,0,255))*256+Math.round(E(U.b*255,0,255))}getHexString(t=P){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=G.workingColorSpace){G.workingToColorSpace(U.copy(this),e);const s=U.r,i=U.g,n=U.b,r=Math.max(s,i,n),o=Math.min(s,i,n);let a,h;const c=(o+r)/2;if(o===r)a=0,h=0;else{const l=r-o;switch(h=c<=.5?l/(r+o):l/(2-r-o),r){case s:a=(i-n)/l+(i<n?6:0);break;case i:a=(n-s)/l+2;break;case n:a=(s-i)/l+4;break}a/=6}return t.h=a,t.s=h,t.l=c,t}getRGB(t,e=G.workingColorSpace){return G.workingToColorSpace(U.copy(this),e),t.r=U.r,t.g=U.g,t.b=U.b,t}getStyle(t=P){G.workingToColorSpace(U.copy(this),t);const e=U.r,s=U.g,i=U.b;return t!==P?`color(${t} ${e.toFixed(3)} ${s.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(s*255)},${Math.round(i*255)})`}offsetHSL(t,e,s){return this.getHSL(St),this.setHSL(St.h+t,St.s+e,St.l+s)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,s){return this.r=t.r+(e.r-t.r)*s,this.g=t.g+(e.g-t.g)*s,this.b=t.b+(e.b-t.b)*s,this}lerpHSL(t,e){this.getHSL(St),t.getHSL(Ie);const s=he(St.h,Ie.h,e),i=he(St.s,Ie.s,e),n=he(St.l,Ie.l,e);return this.setHSL(s,i,n),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,s=this.g,i=this.b,n=t.elements;return this.r=n[0]*e+n[3]*s+n[6]*i,this.g=n[1]*e+n[4]*s+n[7]*i,this.b=n[2]*e+n[5]*s+n[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const U=new N;N.NAMES=xi;let Dn=0;class Ft extends Me{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Dn++}),this.uuid=$(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new N(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const s=t[e];if(s===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(s):i&&i.isVector3&&s&&s.isVector3?i.copy(s):this[e]=s}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const s={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.color&&this.color.isColor&&(s.color=this.color.getHex()),this.roughness!==void 0&&(s.roughness=this.roughness),this.metalness!==void 0&&(s.metalness=this.metalness),this.sheen!==void 0&&(s.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(s.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(s.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(s.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(s.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(s.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(s.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(s.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(s.shininess=this.shininess),this.clearcoat!==void 0&&(s.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(s.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(s.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(s.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(s.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,s.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(s.dispersion=this.dispersion),this.iridescence!==void 0&&(s.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(s.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(s.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(s.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(s.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(s.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(s.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(s.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(s.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(s.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(s.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(s.lightMap=this.lightMap.toJSON(t).uuid,s.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(s.aoMap=this.aoMap.toJSON(t).uuid,s.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(s.bumpMap=this.bumpMap.toJSON(t).uuid,s.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(s.normalMap=this.normalMap.toJSON(t).uuid,s.normalMapType=this.normalMapType,s.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(s.displacementMap=this.displacementMap.toJSON(t).uuid,s.displacementScale=this.displacementScale,s.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(s.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(s.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(s.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(s.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(s.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(s.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(s.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(s.combine=this.combine)),this.envMapRotation!==void 0&&(s.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(s.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(s.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(s.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(s.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(s.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(s.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(s.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(s.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(s.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(s.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(s.size=this.size),this.shadowSide!==null&&(s.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(s.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(s.blending=this.blending),this.side!==0&&(s.side=this.side),this.vertexColors===!0&&(s.vertexColors=!0),this.opacity<1&&(s.opacity=this.opacity),this.transparent===!0&&(s.transparent=!0),this.blendSrc!==204&&(s.blendSrc=this.blendSrc),this.blendDst!==205&&(s.blendDst=this.blendDst),this.blendEquation!==100&&(s.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(s.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(s.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(s.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(s.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(s.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(s.depthFunc=this.depthFunc),this.depthTest===!1&&(s.depthTest=this.depthTest),this.depthWrite===!1&&(s.depthWrite=this.depthWrite),this.colorWrite===!1&&(s.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(s.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(s.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(s.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(s.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(s.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(s.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(s.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(s.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(s.rotation=this.rotation),this.polygonOffset===!0&&(s.polygonOffset=!0),this.polygonOffsetFactor!==0&&(s.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(s.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(s.linewidth=this.linewidth),this.dashSize!==void 0&&(s.dashSize=this.dashSize),this.gapSize!==void 0&&(s.gapSize=this.gapSize),this.scale!==void 0&&(s.scale=this.scale),this.dithering===!0&&(s.dithering=!0),this.alphaTest>0&&(s.alphaTest=this.alphaTest),this.alphaHash===!0&&(s.alphaHash=!0),this.alphaToCoverage===!0&&(s.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(s.premultipliedAlpha=!0),this.forceSinglePass===!0&&(s.forceSinglePass=!0),this.wireframe===!0&&(s.wireframe=!0),this.wireframeLinewidth>1&&(s.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(s.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(s.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(s.flatShading=!0),this.visible===!1&&(s.visible=!1),this.toneMapped===!1&&(s.toneMapped=!1),this.fog===!1&&(s.fog=!1),Object.keys(this.userData).length>0&&(s.userData=this.userData);function i(n){const r=[];for(const o in n){const a=n[o];delete a.metadata,r.push(a)}return r}if(e){const n=i(t.textures),r=i(t.images);n.length>0&&(s.textures=n),r.length>0&&(s.images=r)}return s}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let s=null;if(e!==null){const i=e.length;s=new Array(i);for(let n=0;n!==i;++n)s[n]=e[n].clone()}return this.clippingPlanes=s,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class Kt extends Ft{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new N(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new jt,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const B=new g,Ce=new k;let Un=0;class X{constructor(t,e,s=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Un++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=s,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,s){t*=this.itemSize,s*=e.itemSize;for(let i=0,n=this.itemSize;i<n;i++)this.array[t+i]=e.array[s+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,s=this.count;e<s;e++)Ce.fromBufferAttribute(this,e),Ce.applyMatrix3(t),this.setXY(e,Ce.x,Ce.y);else if(this.itemSize===3)for(let e=0,s=this.count;e<s;e++)B.fromBufferAttribute(this,e),B.applyMatrix3(t),this.setXYZ(e,B.x,B.y,B.z);return this}applyMatrix4(t){for(let e=0,s=this.count;e<s;e++)B.fromBufferAttribute(this,e),B.applyMatrix4(t),this.setXYZ(e,B.x,B.y,B.z);return this}applyNormalMatrix(t){for(let e=0,s=this.count;e<s;e++)B.fromBufferAttribute(this,e),B.applyNormalMatrix(t),this.setXYZ(e,B.x,B.y,B.z);return this}transformDirection(t){for(let e=0,s=this.count;e<s;e++)B.fromBufferAttribute(this,e),B.transformDirection(t),this.setXYZ(e,B.x,B.y,B.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let s=this.array[t*this.itemSize+e];return this.normalized&&(s=Q(s,this.array)),s}setComponent(t,e,s){return this.normalized&&(s=I(s,this.array)),this.array[t*this.itemSize+e]=s,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Q(e,this.array)),e}setX(t,e){return this.normalized&&(e=I(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Q(e,this.array)),e}setY(t,e){return this.normalized&&(e=I(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Q(e,this.array)),e}setZ(t,e){return this.normalized&&(e=I(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Q(e,this.array)),e}setW(t,e){return this.normalized&&(e=I(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,s){return t*=this.itemSize,this.normalized&&(e=I(e,this.array),s=I(s,this.array)),this.array[t+0]=e,this.array[t+1]=s,this}setXYZ(t,e,s,i){return t*=this.itemSize,this.normalized&&(e=I(e,this.array),s=I(s,this.array),i=I(i,this.array)),this.array[t+0]=e,this.array[t+1]=s,this.array[t+2]=i,this}setXYZW(t,e,s,i,n){return t*=this.itemSize,this.normalized&&(e=I(e,this.array),s=I(s,this.array),i=I(i,this.array),n=I(n,this.array)),this.array[t+0]=e,this.array[t+1]=s,this.array[t+2]=i,this.array[t+3]=n,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==35044&&(t.usage=this.usage),t}}class Vn extends X{constructor(t,e,s){super(new Uint16Array(t),e,s)}}class Hn extends X{constructor(t,e,s){super(new Uint32Array(t),e,s)}}class Ss extends X{constructor(t,e,s){super(new Float32Array(t),e,s)}}let Wn=0;const J=new z,As=new L,Jt=new g,Y=new lt,de=new lt,O=new g;class kt extends Me{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Wn++}),this.uuid=$(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(An(t)?Hn:Vn)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,s=0){this.groups.push({start:t,count:e,materialIndex:s})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const s=this.attributes.normal;if(s!==void 0){const n=new ht().getNormalMatrix(t);s.applyNormalMatrix(n),s.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return J.makeRotationFromQuaternion(t),this.applyMatrix4(J),this}rotateX(t){return J.makeRotationX(t),this.applyMatrix4(J),this}rotateY(t){return J.makeRotationY(t),this.applyMatrix4(J),this}rotateZ(t){return J.makeRotationZ(t),this.applyMatrix4(J),this}translate(t,e,s){return J.makeTranslation(t,e,s),this.applyMatrix4(J),this}scale(t,e,s){return J.makeScale(t,e,s),this.applyMatrix4(J),this}lookAt(t){return As.lookAt(t),As.updateMatrix(),this.applyMatrix4(As.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Jt).negate(),this.translate(Jt.x,Jt.y,Jt.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const s=[];for(let i=0,n=t.length;i<n;i++){const r=t[i];s.push(r.x,r.y,r.z||0)}this.setAttribute("position",new Ss(s,3))}else{const s=Math.min(t.length,e.count);for(let i=0;i<s;i++){const n=t[i];e.setXYZ(i,n.x,n.y,n.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new lt);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new g(-1/0,-1/0,-1/0),new g(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let s=0,i=e.length;s<i;s++){const n=e[s];Y.setFromBufferAttribute(n),this.morphTargetsRelative?(O.addVectors(this.boundingBox.min,Y.min),this.boundingBox.expandByPoint(O),O.addVectors(this.boundingBox.max,Y.max),this.boundingBox.expandByPoint(O)):(this.boundingBox.expandByPoint(Y.min),this.boundingBox.expandByPoint(Y.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ot);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new g,1/0);return}if(t){const s=this.boundingSphere.center;if(Y.setFromBufferAttribute(t),e)for(let n=0,r=e.length;n<r;n++){const o=e[n];de.setFromBufferAttribute(o),this.morphTargetsRelative?(O.addVectors(Y.min,de.min),Y.expandByPoint(O),O.addVectors(Y.max,de.max),Y.expandByPoint(O)):(Y.expandByPoint(de.min),Y.expandByPoint(de.max))}Y.getCenter(s);let i=0;for(let n=0,r=t.count;n<r;n++)O.fromBufferAttribute(t,n),i=Math.max(i,s.distanceToSquared(O));if(e)for(let n=0,r=e.length;n<r;n++){const o=e[n],a=this.morphTargetsRelative;for(let h=0,c=o.count;h<c;h++)O.fromBufferAttribute(o,h),a&&(Jt.fromBufferAttribute(t,h),O.add(Jt)),i=Math.max(i,s.distanceToSquared(O))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const s=e.position,i=e.normal,n=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new X(new Float32Array(4*s.count),4));const r=this.getAttribute("tangent"),o=[],a=[];for(let S=0;S<s.count;S++)o[S]=new g,a[S]=new g;const h=new g,c=new g,l=new g,u=new k,p=new k,f=new k,m=new g,y=new g;function x(S,F,v){h.fromBufferAttribute(s,S),c.fromBufferAttribute(s,F),l.fromBufferAttribute(s,v),u.fromBufferAttribute(n,S),p.fromBufferAttribute(n,F),f.fromBufferAttribute(n,v),c.sub(h),l.sub(h),p.sub(u),f.sub(u);const V=1/(p.x*f.y-f.x*p.y);isFinite(V)&&(m.copy(c).multiplyScalar(f.y).addScaledVector(l,-p.y).multiplyScalar(V),y.copy(l).multiplyScalar(p.x).addScaledVector(c,-f.x).multiplyScalar(V),o[S].add(m),o[F].add(m),o[v].add(m),a[S].add(y),a[F].add(y),a[v].add(y))}let M=this.groups;M.length===0&&(M=[{start:0,count:t.count}]);for(let S=0,F=M.length;S<F;++S){const v=M[S],V=v.start,Rt=v.count;for(let H=V,zt=V+Rt;H<zt;H+=3)x(t.getX(H+0),t.getX(H+1),t.getX(H+2))}const w=new g,b=new g,_=new g,A=new g;function T(S){_.fromBufferAttribute(i,S),A.copy(_);const F=o[S];w.copy(F),w.sub(_.multiplyScalar(_.dot(F))).normalize(),b.crossVectors(A,F);const V=b.dot(a[S])<0?-1:1;r.setXYZW(S,w.x,w.y,w.z,V)}for(let S=0,F=M.length;S<F;++S){const v=M[S],V=v.start,Rt=v.count;for(let H=V,zt=V+Rt;H<zt;H+=3)T(t.getX(H+0)),T(t.getX(H+1)),T(t.getX(H+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let s=this.getAttribute("normal");if(s===void 0)s=new X(new Float32Array(e.count*3),3),this.setAttribute("normal",s);else for(let u=0,p=s.count;u<p;u++)s.setXYZ(u,0,0,0);const i=new g,n=new g,r=new g,o=new g,a=new g,h=new g,c=new g,l=new g;if(t)for(let u=0,p=t.count;u<p;u+=3){const f=t.getX(u+0),m=t.getX(u+1),y=t.getX(u+2);i.fromBufferAttribute(e,f),n.fromBufferAttribute(e,m),r.fromBufferAttribute(e,y),c.subVectors(r,n),l.subVectors(i,n),c.cross(l),o.fromBufferAttribute(s,f),a.fromBufferAttribute(s,m),h.fromBufferAttribute(s,y),o.add(c),a.add(c),h.add(c),s.setXYZ(f,o.x,o.y,o.z),s.setXYZ(m,a.x,a.y,a.z),s.setXYZ(y,h.x,h.y,h.z)}else for(let u=0,p=e.count;u<p;u+=3)i.fromBufferAttribute(e,u+0),n.fromBufferAttribute(e,u+1),r.fromBufferAttribute(e,u+2),c.subVectors(r,n),l.subVectors(i,n),c.cross(l),s.setXYZ(u+0,c.x,c.y,c.z),s.setXYZ(u+1,c.x,c.y,c.z),s.setXYZ(u+2,c.x,c.y,c.z);this.normalizeNormals(),s.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,s=t.count;e<s;e++)O.fromBufferAttribute(t,e),O.normalize(),t.setXYZ(e,O.x,O.y,O.z)}toNonIndexed(){function t(o,a){const h=o.array,c=o.itemSize,l=o.normalized,u=new h.constructor(a.length*c);let p=0,f=0;for(let m=0,y=a.length;m<y;m++){o.isInterleavedBufferAttribute?p=a[m]*o.data.stride+o.offset:p=a[m]*c;for(let x=0;x<c;x++)u[f++]=h[p++]}return new X(u,c,l)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new kt,s=this.index.array,i=this.attributes;for(const o in i){const a=i[o],h=t(a,s);e.setAttribute(o,h)}const n=this.morphAttributes;for(const o in n){const a=[],h=n[o];for(let c=0,l=h.length;c<l;c++){const u=h[c],p=t(u,s);a.push(p)}e.morphAttributes[o]=a}e.morphTargetsRelative=this.morphTargetsRelative;const r=this.groups;for(let o=0,a=r.length;o<a;o++){const h=r[o];e.addGroup(h.start,h.count,h.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const a=this.parameters;for(const h in a)a[h]!==void 0&&(t[h]=a[h]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const s=this.attributes;for(const a in s){const h=s[a];t.data.attributes[a]=h.toJSON(t.data)}const i={};let n=!1;for(const a in this.morphAttributes){const h=this.morphAttributes[a],c=[];for(let l=0,u=h.length;l<u;l++){const p=h[l];c.push(p.toJSON(t.data))}c.length>0&&(i[a]=c,n=!0)}n&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const s=t.index;s!==null&&this.setIndex(s.clone());const i=t.attributes;for(const h in i){const c=i[h];this.setAttribute(h,c.clone(e))}const n=t.morphAttributes;for(const h in n){const c=[],l=n[h];for(let u=0,p=l.length;u<p;u++)c.push(l[u].clone(e));this.morphAttributes[h]=c}this.morphTargetsRelative=t.morphTargetsRelative;const r=t.groups;for(let h=0,c=r.length;h<c;h++){const l=r[h];this.addGroup(l.start,l.count,l.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const a=t.boundingSphere;return a!==null&&(this.boundingSphere=a.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const bi=new z,Lt=new Ee,Fe=new ot,Mi=new g,ke=new g,Le=new g,Ne=new g,Es=new g,Be=new g,wi=new g,ve=new g;class Pe extends L{constructor(t=new kt,e=new Kt){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,s=Object.keys(e);if(s.length>0){const i=e[s[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=i.length;n<r;n++){const o=i[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=n}}}}getVertexPosition(t,e){const s=this.geometry,i=s.attributes.position,n=s.morphAttributes.position,r=s.morphTargetsRelative;e.fromBufferAttribute(i,t);const o=this.morphTargetInfluences;if(n&&o){Be.set(0,0,0);for(let a=0,h=n.length;a<h;a++){const c=o[a],l=n[a];c!==0&&(Es.fromBufferAttribute(l,t),r?Be.addScaledVector(Es,c):Be.addScaledVector(Es.sub(e),c))}e.add(Be)}return e}raycast(t,e){const s=this.geometry,i=this.material,n=this.matrixWorld;i!==void 0&&(s.boundingSphere===null&&s.computeBoundingSphere(),Fe.copy(s.boundingSphere),Fe.applyMatrix4(n),Lt.copy(t.ray).recast(t.near),!(Fe.containsPoint(Lt.origin)===!1&&(Lt.intersectSphere(Fe,Mi)===null||Lt.origin.distanceToSquared(Mi)>(t.far-t.near)**2))&&(bi.copy(n).invert(),Lt.copy(t.ray).applyMatrix4(bi),!(s.boundingBox!==null&&Lt.intersectsBox(s.boundingBox)===!1)&&this._computeIntersections(t,e,Lt)))}_computeIntersections(t,e,s){let i;const n=this.geometry,r=this.material,o=n.index,a=n.attributes.position,h=n.attributes.uv,c=n.attributes.uv1,l=n.attributes.normal,u=n.groups,p=n.drawRange;if(o!==null)if(Array.isArray(r))for(let f=0,m=u.length;f<m;f++){const y=u[f],x=r[y.materialIndex],M=Math.max(y.start,p.start),w=Math.min(o.count,Math.min(y.start+y.count,p.start+p.count));for(let b=M,_=w;b<_;b+=3){const A=o.getX(b),T=o.getX(b+1),S=o.getX(b+2);i=Oe(this,x,t,s,h,c,l,A,T,S),i&&(i.faceIndex=Math.floor(b/3),i.face.materialIndex=y.materialIndex,e.push(i))}}else{const f=Math.max(0,p.start),m=Math.min(o.count,p.start+p.count);for(let y=f,x=m;y<x;y+=3){const M=o.getX(y),w=o.getX(y+1),b=o.getX(y+2);i=Oe(this,r,t,s,h,c,l,M,w,b),i&&(i.faceIndex=Math.floor(y/3),e.push(i))}}else if(a!==void 0)if(Array.isArray(r))for(let f=0,m=u.length;f<m;f++){const y=u[f],x=r[y.materialIndex],M=Math.max(y.start,p.start),w=Math.min(a.count,Math.min(y.start+y.count,p.start+p.count));for(let b=M,_=w;b<_;b+=3){const A=b,T=b+1,S=b+2;i=Oe(this,x,t,s,h,c,l,A,T,S),i&&(i.faceIndex=Math.floor(b/3),i.face.materialIndex=y.materialIndex,e.push(i))}}else{const f=Math.max(0,p.start),m=Math.min(a.count,p.start+p.count);for(let y=f,x=m;y<x;y+=3){const M=y,w=y+1,b=y+2;i=Oe(this,r,t,s,h,c,l,M,w,b),i&&(i.faceIndex=Math.floor(y/3),e.push(i))}}}}function jn(d,t,e,s,i,n,r,o){let a;if(t.side===1?a=s.intersectTriangle(r,n,i,!0,o):a=s.intersectTriangle(i,n,r,t.side===0,o),a===null)return null;ve.copy(o),ve.applyMatrix4(d.matrixWorld);const h=e.ray.origin.distanceTo(ve);return h<e.near||h>e.far?null:{distance:h,point:ve.clone(),object:d}}function Oe(d,t,e,s,i,n,r,o,a,h){d.getVertexPosition(o,ke),d.getVertexPosition(a,Le),d.getVertexPosition(h,Ne);const c=jn(d,t,e,s,ke,Le,Ne,wi);if(c){const l=new g;nt.getBarycoord(wi,ke,Le,Ne,l),i&&(c.uv=nt.getInterpolatedAttribute(i,o,a,h,l,new k)),n&&(c.uv1=nt.getInterpolatedAttribute(n,o,a,h,l,new k)),r&&(c.normal=nt.getInterpolatedAttribute(r,o,a,h,l,new g),c.normal.dot(s.direction)>0&&c.normal.multiplyScalar(-1));const u={a:o,b:a,c:h,normal:new g,materialIndex:0};nt.getNormal(ke,Le,Ne,u.normal),c.face=u,c.barycoord=l}return c}class _i extends L{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new z,this.projectionMatrix=new z,this.projectionMatrixInverse=new z,this.coordinateSystem=2e3}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const At=new g,Ti=new k,Si=new k;class Rs extends _i{constructor(t=50,e=1,s=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=s,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=ae*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(oe*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return ae*2*Math.atan(Math.tan(oe*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,s){At.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(At.x,At.y).multiplyScalar(-t/At.z),At.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),s.set(At.x,At.y).multiplyScalar(-t/At.z)}getViewSize(t,e){return this.getViewBounds(t,Ti,Si),e.subVectors(Si,Ti)}setViewOffset(t,e,s,i,n,r){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=s,this.view.offsetY=i,this.view.width=n,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(oe*.5*this.fov)/this.zoom,s=2*e,i=this.aspect*s,n=-.5*i;const r=this.view;if(this.view!==null&&this.view.enabled){const a=r.fullWidth,h=r.fullHeight;n+=r.offsetX*i/a,e-=r.offsetY*s/h,i*=r.width/a,s*=r.height/h}const o=this.filmOffset;o!==0&&(n+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+i,e,e-s,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}class zs extends L{constructor(){super(),this.isGroup=!0,this.type="Group"}}class Gn{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=$()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,s){t*=this.stride,s*=e.stride;for(let i=0,n=this.stride;i<n;i++)this.array[t+i]=e.array[s+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=$()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),s=new this.constructor(e,this.stride);return s.setUsage(this.usage),s}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=$()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const j=new g;class Is{constructor(t,e,s,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=s,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,s=this.data.count;e<s;e++)j.fromBufferAttribute(this,e),j.applyMatrix4(t),this.setXYZ(e,j.x,j.y,j.z);return this}applyNormalMatrix(t){for(let e=0,s=this.count;e<s;e++)j.fromBufferAttribute(this,e),j.applyNormalMatrix(t),this.setXYZ(e,j.x,j.y,j.z);return this}transformDirection(t){for(let e=0,s=this.count;e<s;e++)j.fromBufferAttribute(this,e),j.transformDirection(t),this.setXYZ(e,j.x,j.y,j.z);return this}getComponent(t,e){let s=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(s=Q(s,this.array)),s}setComponent(t,e,s){return this.normalized&&(s=I(s,this.array)),this.data.array[t*this.data.stride+this.offset+e]=s,this}setX(t,e){return this.normalized&&(e=I(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=I(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=I(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=I(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Q(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Q(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Q(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Q(e,this.array)),e}setXY(t,e,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=I(e,this.array),s=I(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this}setXYZ(t,e,s,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=I(e,this.array),s=I(s,this.array),i=I(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this.data.array[t+2]=i,this}setXYZW(t,e,s,i,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=I(e,this.array),s=I(s,this.array),i=I(i,this.array),n=I(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this.data.array[t+2]=i,this.data.array[t+3]=n,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let s=0;s<this.count;s++){const i=s*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)e.push(this.data.array[i+n])}return new X(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Is(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let s=0;s<this.count;s++){const i=s*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)e.push(this.data.array[i+n])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}const Ai=new g,Ei=new W,Ri=new W,qn=new g,zi=new z,De=new g,Cs=new ot,Ii=new z,Fs=new Ee;class Xn extends Pe{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=ei,this.bindMatrix=new z,this.bindMatrixInverse=new z,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;this.boundingBox===null&&(this.boundingBox=new lt),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let s=0;s<e.count;s++)this.getVertexPosition(s,De),this.boundingBox.expandByPoint(De)}computeBoundingSphere(){const t=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new ot),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let s=0;s<e.count;s++)this.getVertexPosition(s,De),this.boundingSphere.expandByPoint(De)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const s=this.material,i=this.matrixWorld;s!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Cs.copy(this.boundingSphere),Cs.applyMatrix4(i),t.ray.intersectsSphere(Cs)!==!1&&(Ii.copy(i).invert(),Fs.copy(t.ray).applyMatrix4(Ii),!(this.boundingBox!==null&&Fs.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(t,e,Fs)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new W,e=this.geometry.attributes.skinWeight;for(let s=0,i=e.count;s<i;s++){t.fromBufferAttribute(e,s);const n=1/t.manhattanLength();n!==1/0?t.multiplyScalar(n):t.set(1,0,0,0),e.setXYZW(s,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===ei?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===an?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const s=this.skeleton,i=this.geometry;Ei.fromBufferAttribute(i.attributes.skinIndex,t),Ri.fromBufferAttribute(i.attributes.skinWeight,t),Ai.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let n=0;n<4;n++){const r=Ri.getComponent(n);if(r!==0){const o=Ei.getComponent(n);zi.multiplyMatrices(s.bones[o].matrixWorld,s.boneInverses[o]),e.addScaledVector(qn.copy(Ai).applyMatrix4(zi),r)}}return e.applyMatrix4(this.bindMatrixInverse)}}class Ci extends L{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Fi extends tt{constructor(t=null,e=1,s=1,i,n,r,o,a,h=1003,c=1003,l,u){super(null,r,o,a,h,c,i,n,l,u),this.isDataTexture=!0,this.image={data:t,width:e,height:s},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const ki=new z,Yn=new z;class ks{constructor(t=[],e=[]){this.uuid=$(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let s=0,i=this.bones.length;s<i;s++)this.boneInverses.push(new z)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const s=new z;this.bones[t]&&s.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(s)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const s=this.bones[t];s&&s.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const s=this.bones[t];s&&(s.parent&&s.parent.isBone?(s.matrix.copy(s.parent.matrixWorld).invert(),s.matrix.multiply(s.matrixWorld)):s.matrix.copy(s.matrixWorld),s.matrix.decompose(s.position,s.quaternion,s.scale))}}update(){const t=this.bones,e=this.boneInverses,s=this.boneMatrices,i=this.boneTexture;for(let n=0,r=t.length;n<r;n++){const o=t[n]?t[n].matrixWorld:Yn;ki.multiplyMatrices(o,e[n]),ki.toArray(s,n*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new ks(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const s=new Fi(e,t,t,1023,1015);return s.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=s,this}getBoneByName(t){for(let e=0,s=this.bones.length;e<s;e++){const i=this.bones[e];if(i.name===t)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let s=0,i=t.bones.length;s<i;s++){const n=t.bones[s];let r=e[n];r===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",n),r=new Ci),this.bones.push(r),this.boneInverses.push(new z().fromArray(t.boneInverses[s]))}return this.init(),this}toJSON(){const t={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,s=this.boneInverses;for(let i=0,n=e.length;i<n;i++){const r=e[i];t.bones.push(r.uuid);const o=s[i];t.boneInverses.push(o.toArray())}return t}}class Ls extends X{constructor(t,e,s,i=1){super(t,e,s),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const Zt=new z,Li=new z,Ue=[],Ni=new lt,Kn=new z,pe=new Pe,fe=new ot;class Jn extends Pe{constructor(t,e,s){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new Ls(new Float32Array(s*16),16),this.instanceColor=null,this.morphTexture=null,this.count=s,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<s;i++)this.setMatrixAt(i,Kn)}computeBoundingBox(){const t=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new lt),t.boundingBox===null&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let s=0;s<e;s++)this.getMatrixAt(s,Zt),Ni.copy(t.boundingBox).applyMatrix4(Zt),this.boundingBox.union(Ni)}computeBoundingSphere(){const t=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new ot),t.boundingSphere===null&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let s=0;s<e;s++)this.getMatrixAt(s,Zt),fe.copy(t.boundingSphere).applyMatrix4(Zt),this.boundingSphere.union(fe)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.morphTexture!==null&&(this.morphTexture=t.morphTexture.clone()),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,t*16)}getMorphAt(t,e){const s=e.morphTargetInfluences,i=this.morphTexture.source.data.data,n=s.length+1,r=t*n+1;for(let o=0;o<s.length;o++)s[o]=i[r+o]}raycast(t,e){const s=this.matrixWorld,i=this.count;if(pe.geometry=this.geometry,pe.material=this.material,pe.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),fe.copy(this.boundingSphere),fe.applyMatrix4(s),t.ray.intersectsSphere(fe)!==!1))for(let n=0;n<i;n++){this.getMatrixAt(n,Zt),Li.multiplyMatrices(s,Zt),pe.matrixWorld=Li,pe.raycast(t,Ue);for(let r=0,o=Ue.length;r<o;r++){const a=Ue[r];a.instanceId=n,a.object=this,e.push(a)}Ue.length=0}}setColorAt(t,e){this.instanceColor===null&&(this.instanceColor=new Ls(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),e.toArray(this.instanceColor.array,t*3)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,t*16)}setMorphAt(t,e){const s=e.morphTargetInfluences,i=s.length+1;this.morphTexture===null&&(this.morphTexture=new Fi(new Float32Array(i*this.count),i,this.count,1028,1015));const n=this.morphTexture.source.data.data;let r=0;for(let h=0;h<s.length;h++)r+=s[h];const o=this.geometry.morphTargetsRelative?1:1-r,a=i*t;n[a]=o,n.set(s,a+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Ns=new g,Zn=new g,$n=new ht;class $t{constructor(t=new g(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,s,i){return this.normal.set(t,e,s),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,s){const i=Ns.subVectors(s,e).cross(Zn.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const s=t.delta(Ns),i=this.normal.dot(s);if(i===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const n=-(t.start.dot(this.normal)+this.constant)/i;return n<0||n>1?null:e.copy(t.start).addScaledVector(s,n)}intersectsLine(t){const e=this.distanceToPoint(t.start),s=this.distanceToPoint(t.end);return e<0&&s>0||s<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const s=e||$n.getNormalMatrix(t),i=this.coplanarPoint(Ns).applyMatrix4(t),n=this.normal.applyMatrix3(s).normalize();return this.constant=-i.dot(n),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Nt=new ot,Qn=new k(.5,.5),Ve=new g;class tr{constructor(t=new $t,e=new $t,s=new $t,i=new $t,n=new $t,r=new $t){this.planes=[t,e,s,i,n,r]}set(t,e,s,i,n,r){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(s),o[3].copy(i),o[4].copy(n),o[5].copy(r),this}copy(t){const e=this.planes;for(let s=0;s<6;s++)e[s].copy(t.planes[s]);return this}setFromProjectionMatrix(t,e=2e3){const s=this.planes,i=t.elements,n=i[0],r=i[1],o=i[2],a=i[3],h=i[4],c=i[5],l=i[6],u=i[7],p=i[8],f=i[9],m=i[10],y=i[11],x=i[12],M=i[13],w=i[14],b=i[15];if(s[0].setComponents(a-n,u-h,y-p,b-x).normalize(),s[1].setComponents(a+n,u+h,y+p,b+x).normalize(),s[2].setComponents(a+r,u+c,y+f,b+M).normalize(),s[3].setComponents(a-r,u-c,y-f,b-M).normalize(),s[4].setComponents(a-o,u-l,y-m,b-w).normalize(),e===2e3)s[5].setComponents(a+o,u+l,y+m,b+w).normalize();else if(e===2001)s[5].setComponents(o,l,m,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Nt.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Nt.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Nt)}intersectsSprite(t){Nt.center.set(0,0,0);const e=Qn.distanceTo(t.center);return Nt.radius=.7071067811865476+e,Nt.applyMatrix4(t.matrixWorld),this.intersectsSphere(Nt)}intersectsSphere(t){const e=this.planes,s=t.center,i=-t.radius;for(let n=0;n<6;n++)if(e[n].distanceToPoint(s)<i)return!1;return!0}intersectsBox(t){const e=this.planes;for(let s=0;s<6;s++){const i=e[s];if(Ve.x=i.normal.x>0?t.max.x:t.min.x,Ve.y=i.normal.y>0?t.max.y:t.min.y,Ve.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(Ve)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let s=0;s<6;s++)if(e[s].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Bi extends Ft{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new N(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const He=new g,We=new g,vi=new z,me=new Ee,je=new ot,Bs=new g,Pi=new g;class vs extends L{constructor(t=new kt,e=new Bi){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,s=[0];for(let i=1,n=e.count;i<n;i++)He.fromBufferAttribute(e,i-1),We.fromBufferAttribute(e,i),s[i]=s[i-1],s[i]+=He.distanceTo(We);t.setAttribute("lineDistance",new Ss(s,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const s=this.geometry,i=this.matrixWorld,n=t.params.Line.threshold,r=s.drawRange;if(s.boundingSphere===null&&s.computeBoundingSphere(),je.copy(s.boundingSphere),je.applyMatrix4(i),je.radius+=n,t.ray.intersectsSphere(je)===!1)return;vi.copy(i).invert(),me.copy(t.ray).applyMatrix4(vi);const o=n/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,h=this.isLineSegments?2:1,c=s.index,u=s.attributes.position;if(c!==null){const p=Math.max(0,r.start),f=Math.min(c.count,r.start+r.count);for(let m=p,y=f-1;m<y;m+=h){const x=c.getX(m),M=c.getX(m+1),w=Ge(this,t,me,a,x,M,m);w&&e.push(w)}if(this.isLineLoop){const m=c.getX(f-1),y=c.getX(p),x=Ge(this,t,me,a,m,y,f-1);x&&e.push(x)}}else{const p=Math.max(0,r.start),f=Math.min(u.count,r.start+r.count);for(let m=p,y=f-1;m<y;m+=h){const x=Ge(this,t,me,a,m,m+1,m);x&&e.push(x)}if(this.isLineLoop){const m=Ge(this,t,me,a,f-1,p,f-1);m&&e.push(m)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,s=Object.keys(e);if(s.length>0){const i=e[s[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=i.length;n<r;n++){const o=i[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=n}}}}}function Ge(d,t,e,s,i,n,r){const o=d.geometry.attributes.position;if(He.fromBufferAttribute(o,i),We.fromBufferAttribute(o,n),e.distanceSqToSegment(He,We,Bs,Pi)>s)return;Bs.applyMatrix4(d.matrixWorld);const h=t.ray.origin.distanceTo(Bs);if(!(h<t.near||h>t.far))return{distance:h,point:Pi.clone().applyMatrix4(d.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:d}}const Oi=new g,Di=new g;class er extends vs{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,s=[];for(let i=0,n=e.count;i<n;i+=2)Oi.fromBufferAttribute(e,i),Di.fromBufferAttribute(e,i+1),s[i]=i===0?0:s[i-1],s[i+1]=s[i]+Oi.distanceTo(Di);t.setAttribute("lineDistance",new Ss(s,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class sr extends vs{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class Ui extends Ft{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new N(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const Vi=new z,Ps=new Ee,qe=new ot,Xe=new g;class ir extends L{constructor(t=new kt,e=new Ui){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const s=this.geometry,i=this.matrixWorld,n=t.params.Points.threshold,r=s.drawRange;if(s.boundingSphere===null&&s.computeBoundingSphere(),qe.copy(s.boundingSphere),qe.applyMatrix4(i),qe.radius+=n,t.ray.intersectsSphere(qe)===!1)return;Vi.copy(i).invert(),Ps.copy(t.ray).applyMatrix4(Vi);const o=n/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,h=s.index,l=s.attributes.position;if(h!==null){const u=Math.max(0,r.start),p=Math.min(h.count,r.start+r.count);for(let f=u,m=p;f<m;f++){const y=h.getX(f);Xe.fromBufferAttribute(l,y),Hi(Xe,y,a,i,t,e,this)}}else{const u=Math.max(0,r.start),p=Math.min(l.count,r.start+r.count);for(let f=u,m=p;f<m;f++)Xe.fromBufferAttribute(l,f),Hi(Xe,f,a,i,t,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,s=Object.keys(e);if(s.length>0){const i=e[s[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=i.length;n<r;n++){const o=i[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=n}}}}}function Hi(d,t,e,s,i,n,r){const o=Ps.distanceSqToPoint(d);if(o<e){const a=new g;Ps.closestPointToPoint(d,a),a.applyMatrix4(s);const h=i.ray.origin.distanceTo(a);if(h<i.near||h>i.far)return;n.push({distance:h,distanceToRay:Math.sqrt(o),point:a,index:t,face:null,faceIndex:null,barycoord:null,object:r})}}class Os extends Ft{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new N(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new N(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new k(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new jt,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class at extends Os{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new k(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return E(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new N(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new N(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new N(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}function Ye(d,t){return!d||d.constructor===t?d:typeof t.BYTES_PER_ELEMENT=="number"?new t(d):Array.prototype.slice.call(d)}function nr(d){return ArrayBuffer.isView(d)&&!(d instanceof DataView)}function rr(d){function t(i,n){return d[i]-d[n]}const e=d.length,s=new Array(e);for(let i=0;i!==e;++i)s[i]=i;return s.sort(t),s}function Wi(d,t,e){const s=d.length,i=new d.constructor(s);for(let n=0,r=0;r!==s;++n){const o=e[n]*t;for(let a=0;a!==t;++a)i[r++]=d[o+a]}return i}function ji(d,t,e,s){let i=1,n=d[0];for(;n!==void 0&&n[s]===void 0;)n=d[i++];if(n===void 0)return;let r=n[s];if(r!==void 0)if(Array.isArray(r))do r=n[s],r!==void 0&&(t.push(n.time),e.push(...r)),n=d[i++];while(n!==void 0);else if(r.toArray!==void 0)do r=n[s],r!==void 0&&(t.push(n.time),r.toArray(e,e.length)),n=d[i++];while(n!==void 0);else do r=n[s],r!==void 0&&(t.push(n.time),e.push(r)),n=d[i++];while(n!==void 0)}class ye{constructor(t,e,s,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(s),this.sampleValues=e,this.valueSize=s,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let s=this._cachedIndex,i=e[s],n=e[s-1];s:{t:{let r;e:{i:if(!(t<i)){for(let o=s+2;;){if(i===void 0){if(t<n)break i;return s=e.length,this._cachedIndex=s,this.copySampleValue_(s-1)}if(s===o)break;if(n=i,i=e[++s],t<i)break t}r=e.length;break e}if(!(t>=n)){const o=e[1];t<o&&(s=2,n=o);for(let a=s-2;;){if(n===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===a)break;if(i=n,n=e[--s-1],t>=n)break t}r=s,s=0;break e}break s}for(;s<r;){const o=s+r>>>1;t<e[o]?r=o:s=o+1}if(i=e[s],n=e[s-1],n===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return s=e.length,this._cachedIndex=s,this.copySampleValue_(s-1)}this._cachedIndex=s,this.intervalChanged_(s,n,i)}return this.interpolate_(s,n,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,s=this.sampleValues,i=this.valueSize,n=t*i;for(let r=0;r!==i;++r)e[r]=s[n+r];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class or extends ye{constructor(t,e,s,i){super(t,e,s,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(t,e,s){const i=this.parameterPositions;let n=t-2,r=t+1,o=i[n],a=i[r];if(o===void 0)switch(this.getSettings_().endingStart){case 2401:n=t,o=2*e-s;break;case 2402:n=i.length-2,o=e+i[n]-i[n+1];break;default:n=t,o=s}if(a===void 0)switch(this.getSettings_().endingEnd){case 2401:r=t,a=2*s-e;break;case 2402:r=1,a=s+i[1]-i[0];break;default:r=t-1,a=e}const h=(s-e)*.5,c=this.valueSize;this._weightPrev=h/(e-o),this._weightNext=h/(a-s),this._offsetPrev=n*c,this._offsetNext=r*c}interpolate_(t,e,s,i){const n=this.resultBuffer,r=this.sampleValues,o=this.valueSize,a=t*o,h=a-o,c=this._offsetPrev,l=this._offsetNext,u=this._weightPrev,p=this._weightNext,f=(s-e)/(i-e),m=f*f,y=m*f,x=-u*y+2*u*m-u*f,M=(1+u)*y+(-1.5-2*u)*m+(-.5+u)*f+1,w=(-1-p)*y+(1.5+p)*m+.5*f,b=p*y-p*m;for(let _=0;_!==o;++_)n[_]=x*r[c+_]+M*r[h+_]+w*r[a+_]+b*r[l+_];return n}}class ar extends ye{constructor(t,e,s,i){super(t,e,s,i)}interpolate_(t,e,s,i){const n=this.resultBuffer,r=this.sampleValues,o=this.valueSize,a=t*o,h=a-o,c=(s-e)/(i-e),l=1-c;for(let u=0;u!==o;++u)n[u]=r[h+u]*l+r[a+u]*c;return n}}class hr extends ye{constructor(t,e,s,i){super(t,e,s,i)}interpolate_(t){return this.copySampleValue_(t-1)}}class rt{constructor(t,e,s,i){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Ye(e,this.TimeBufferType),this.values=Ye(s,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let s;if(e.toJSON!==this.toJSON)s=e.toJSON(t);else{s={name:t.name,times:Ye(t.times,Array),values:Ye(t.values,Array)};const i=t.getInterpolation();i!==t.DefaultInterpolation&&(s.interpolation=i)}return s.type=t.ValueTypeName,s}InterpolantFactoryMethodDiscrete(t){return new hr(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new ar(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new or(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case 2300:e=this.InterpolantFactoryMethodDiscrete;break;case 2301:e=this.InterpolantFactoryMethodLinear;break;case 2302:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){const s="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(s);return console.warn("THREE.KeyframeTrack:",s),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){const e=this.times;for(let s=0,i=e.length;s!==i;++s)e[s]+=t}return this}scale(t){if(t!==1){const e=this.times;for(let s=0,i=e.length;s!==i;++s)e[s]*=t}return this}trim(t,e){const s=this.times,i=s.length;let n=0,r=i-1;for(;n!==i&&s[n]<t;)++n;for(;r!==-1&&s[r]>e;)--r;if(++r,n!==0||r!==i){n>=r&&(r=Math.max(r,1),n=r-1);const o=this.getValueSize();this.times=s.slice(n,r),this.values=this.values.slice(n*o,r*o)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const s=this.times,i=this.values,n=s.length;n===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let r=null;for(let o=0;o!==n;o++){const a=s[o];if(typeof a=="number"&&isNaN(a)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,a),t=!1;break}if(r!==null&&r>a){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,a,r),t=!1;break}r=a}if(i!==void 0&&nr(i))for(let o=0,a=i.length;o!==a;++o){const h=i[o];if(isNaN(h)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,h),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),s=this.getValueSize(),i=this.getInterpolation()===2302,n=t.length-1;let r=1;for(let o=1;o<n;++o){let a=!1;const h=t[o],c=t[o+1];if(h!==c&&(o!==1||h!==t[0]))if(i)a=!0;else{const l=o*s,u=l-s,p=l+s;for(let f=0;f!==s;++f){const m=e[l+f];if(m!==e[u+f]||m!==e[p+f]){a=!0;break}}}if(a){if(o!==r){t[r]=t[o];const l=o*s,u=r*s;for(let p=0;p!==s;++p)e[u+p]=e[l+p]}++r}}if(n>0){t[r]=t[n];for(let o=n*s,a=r*s,h=0;h!==s;++h)e[a+h]=e[o+h];++r}return r!==t.length?(this.times=t.slice(0,r),this.values=e.slice(0,r*s)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),s=this.constructor,i=new s(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}rt.prototype.ValueTypeName="",rt.prototype.TimeBufferType=Float32Array,rt.prototype.ValueBufferType=Float32Array,rt.prototype.DefaultInterpolation=2301;class Qt extends rt{constructor(t,e,s){super(t,e,s)}}Qt.prototype.ValueTypeName="bool",Qt.prototype.ValueBufferType=Array,Qt.prototype.DefaultInterpolation=2300,Qt.prototype.InterpolantFactoryMethodLinear=void 0,Qt.prototype.InterpolantFactoryMethodSmooth=void 0;class Gi extends rt{constructor(t,e,s,i){super(t,e,s,i)}}Gi.prototype.ValueTypeName="color";class te extends rt{constructor(t,e,s,i){super(t,e,s,i)}}te.prototype.ValueTypeName="number";class cr extends ye{constructor(t,e,s,i){super(t,e,s,i)}interpolate_(t,e,s,i){const n=this.resultBuffer,r=this.sampleValues,o=this.valueSize,a=(s-e)/(i-e);let h=t*o;for(let c=h+o;h!==c;h+=4)bt.slerpFlat(n,0,r,h-o,r,h,a);return n}}class ee extends rt{constructor(t,e,s,i){super(t,e,s,i)}InterpolantFactoryMethodLinear(t){return new cr(this.times,this.values,this.getValueSize(),t)}}ee.prototype.ValueTypeName="quaternion",ee.prototype.InterpolantFactoryMethodSmooth=void 0;class se extends rt{constructor(t,e,s){super(t,e,s)}}se.prototype.ValueTypeName="string",se.prototype.ValueBufferType=Array,se.prototype.DefaultInterpolation=2300,se.prototype.InterpolantFactoryMethodLinear=void 0,se.prototype.InterpolantFactoryMethodSmooth=void 0;class ie extends rt{constructor(t,e,s,i){super(t,e,s,i)}}ie.prototype.ValueTypeName="vector";class lr{constructor(t="",e=-1,s=[],i=2500){this.name=t,this.tracks=s,this.duration=e,this.blendMode=i,this.uuid=$(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],s=t.tracks,i=1/(t.fps||1);for(let r=0,o=s.length;r!==o;++r)e.push(dr(s[r]).scale(i));const n=new this(t.name,t.duration,e,t.blendMode);return n.uuid=t.uuid,n}static toJSON(t){const e=[],s=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let n=0,r=s.length;n!==r;++n)e.push(rt.toJSON(s[n]));return i}static CreateFromMorphTargetSequence(t,e,s,i){const n=e.length,r=[];for(let o=0;o<n;o++){let a=[],h=[];a.push((o+n-1)%n,o,(o+1)%n),h.push(0,1,0);const c=rr(a);a=Wi(a,1,c),h=Wi(h,1,c),!i&&a[0]===0&&(a.push(n),h.push(h[0])),r.push(new te(".morphTargetInfluences["+e[o].name+"]",a,h).scale(1/s))}return new this(t,-1,r)}static findByName(t,e){let s=t;if(!Array.isArray(t)){const i=t;s=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<s.length;i++)if(s[i].name===e)return s[i];return null}static CreateClipsFromMorphTargetSequences(t,e,s){const i={},n=/^([\w-]*?)([\d]+)$/;for(let o=0,a=t.length;o<a;o++){const h=t[o],c=h.name.match(n);if(c&&c.length>1){const l=c[1];let u=i[l];u||(i[l]=u=[]),u.push(h)}}const r=[];for(const o in i)r.push(this.CreateFromMorphTargetSequence(o,i[o],e,s));return r}static parseAnimation(t,e){if(console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const s=function(l,u,p,f,m){if(p.length!==0){const y=[],x=[];ji(p,y,x,f),y.length!==0&&m.push(new l(u,y,x))}},i=[],n=t.name||"default",r=t.fps||30,o=t.blendMode;let a=t.length||-1;const h=t.hierarchy||[];for(let l=0;l<h.length;l++){const u=h[l].keys;if(!(!u||u.length===0))if(u[0].morphTargets){const p={};let f;for(f=0;f<u.length;f++)if(u[f].morphTargets)for(let m=0;m<u[f].morphTargets.length;m++)p[u[f].morphTargets[m]]=-1;for(const m in p){const y=[],x=[];for(let M=0;M!==u[f].morphTargets.length;++M){const w=u[f];y.push(w.time),x.push(w.morphTarget===m?1:0)}i.push(new te(".morphTargetInfluence["+m+"]",y,x))}a=p.length*r}else{const p=".bones["+e[l].name+"]";s(ie,p+".position",u,"pos",i),s(ee,p+".quaternion",u,"rot",i),s(ie,p+".scale",u,"scl",i)}}return i.length===0?null:new this(n,a,i,o)}resetDuration(){const t=this.tracks;let e=0;for(let s=0,i=t.length;s!==i;++s){const n=this.tracks[s];e=Math.max(e,n.times[n.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function ur(d){switch(d.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return te;case"vector":case"vector2":case"vector3":case"vector4":return ie;case"color":return Gi;case"quaternion":return ee;case"bool":case"boolean":return Qt;case"string":return se}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+d)}function dr(d){if(d.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=ur(d.type);if(d.times===void 0){const e=[],s=[];ji(d.keys,e,s,"value"),d.times=e,d.values=s}return t.parse!==void 0?t.parse(d):new t(d.name,d.times,d.values,d.interpolation)}const yt={enabled:!1,files:{},add:function(d,t){this.enabled!==!1&&(this.files[d]=t)},get:function(d){if(this.enabled!==!1)return this.files[d]},remove:function(d){delete this.files[d]},clear:function(){this.files={}}};class pr{constructor(t,e,s){const i=this;let n=!1,r=0,o=0,a;const h=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=s,this.itemStart=function(c){o++,n===!1&&i.onStart!==void 0&&i.onStart(c,r,o),n=!0},this.itemEnd=function(c){r++,i.onProgress!==void 0&&i.onProgress(c,r,o),r===o&&(n=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(c){i.onError!==void 0&&i.onError(c)},this.resolveURL=function(c){return a?a(c):c},this.setURLModifier=function(c){return a=c,this},this.addHandler=function(c,l){return h.push(c,l),this},this.removeHandler=function(c){const l=h.indexOf(c);return l!==-1&&h.splice(l,2),this},this.getHandler=function(c){for(let l=0,u=h.length;l<u;l+=2){const p=h[l],f=h[l+1];if(p.global&&(p.lastIndex=0),p.test(c))return f}return null}}}const fr=new pr;class Bt{constructor(t){this.manager=t!==void 0?t:fr,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const s=this;return new Promise(function(i,n){s.load(t,i,e,n)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}Bt.DEFAULT_MATERIAL_NAME="__DEFAULT";const gt={};class mr extends Error{constructor(t,e){super(t),this.response=e}}class Ke extends Bt{constructor(t){super(t),this.mimeType="",this.responseType=""}load(t,e,s,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const n=yt.get(`file:${t}`);if(n!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(n),this.manager.itemEnd(t)},0),n;if(gt[t]!==void 0){gt[t].push({onLoad:e,onProgress:s,onError:i});return}gt[t]=[],gt[t].push({onLoad:e,onProgress:s,onError:i});const r=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,a=this.responseType;fetch(r).then(h=>{if(h.status===200||h.status===0){if(h.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||h.body===void 0||h.body.getReader===void 0)return h;const c=gt[t],l=h.body.getReader(),u=h.headers.get("X-File-Size")||h.headers.get("Content-Length"),p=u?parseInt(u):0,f=p!==0;let m=0;const y=new ReadableStream({start(x){M();function M(){l.read().then(({done:w,value:b})=>{if(w)x.close();else{m+=b.byteLength;const _=new ProgressEvent("progress",{lengthComputable:f,loaded:m,total:p});for(let A=0,T=c.length;A<T;A++){const S=c[A];S.onProgress&&S.onProgress(_)}x.enqueue(b),M()}},w=>{x.error(w)})}}});return new Response(y)}else throw new mr(`fetch for "${h.url}" responded with ${h.status}: ${h.statusText}`,h)}).then(h=>{switch(a){case"arraybuffer":return h.arrayBuffer();case"blob":return h.blob();case"document":return h.text().then(c=>new DOMParser().parseFromString(c,o));case"json":return h.json();default:if(o==="")return h.text();{const l=/charset="?([^;"\s]*)"?/i.exec(o),u=l&&l[1]?l[1].toLowerCase():void 0,p=new TextDecoder(u);return h.arrayBuffer().then(f=>p.decode(f))}}}).then(h=>{yt.add(`file:${t}`,h);const c=gt[t];delete gt[t];for(let l=0,u=c.length;l<u;l++){const p=c[l];p.onLoad&&p.onLoad(h)}}).catch(h=>{const c=gt[t];if(c===void 0)throw this.manager.itemError(t),h;delete gt[t];for(let l=0,u=c.length;l<u;l++){const p=c[l];p.onError&&p.onError(h)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}const ne=new WeakMap;class yr extends Bt{constructor(t){super(t)}load(t,e,s,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const n=this,r=yt.get(`image:${t}`);if(r!==void 0){if(r.complete===!0)n.manager.itemStart(t),setTimeout(function(){e&&e(r),n.manager.itemEnd(t)},0);else{let l=ne.get(r);l===void 0&&(l=[],ne.set(r,l)),l.push({onLoad:e,onError:i})}return r}const o=as("img");function a(){c(),e&&e(this);const l=ne.get(this)||[];for(let u=0;u<l.length;u++){const p=l[u];p.onLoad&&p.onLoad(this)}ne.delete(this),n.manager.itemEnd(t)}function h(l){c(),i&&i(l),yt.remove(`image:${t}`);const u=ne.get(this)||[];for(let p=0;p<u.length;p++){const f=u[p];f.onError&&f.onError(l)}ne.delete(this),n.manager.itemError(t),n.manager.itemEnd(t)}function c(){o.removeEventListener("load",a,!1),o.removeEventListener("error",h,!1)}return o.addEventListener("load",a,!1),o.addEventListener("error",h,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),yt.add(`image:${t}`,o),n.manager.itemStart(t),o.src=t,o}}class gr extends Bt{constructor(t){super(t)}load(t,e,s,i){const n=new tt,r=new yr(this.manager);return r.setCrossOrigin(this.crossOrigin),r.setPath(this.path),r.load(t,function(o){n.image=o,n.needsUpdate=!0,e!==void 0&&e(n)},s,i),n}}class Ds extends L{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new N(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(e.object.target=this.target.uuid),e}}const Us=new z,qi=new g,Xi=new g;class Vs{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new k(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new z,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new tr,this._frameExtents=new k(1,1),this._viewportCount=1,this._viewports=[new W(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,s=this.matrix;qi.setFromMatrixPosition(t.matrixWorld),e.position.copy(qi),Xi.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(Xi),e.updateMatrixWorld(),Us.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Us),s.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),s.multiply(Us)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class xr extends Vs{constructor(){super(new Rs(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){const e=this.camera,s=ae*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,n=t.distance||e.far;(s!==e.fov||i!==e.aspect||n!==e.far)&&(e.fov=s,e.aspect=i,e.far=n,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class br extends Ds{constructor(t,e,s=0,i=Math.PI/3,n=0,r=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(L.DEFAULT_UP),this.updateMatrix(),this.target=new L,this.distance=s,this.angle=i,this.penumbra=n,this.decay=r,this.map=null,this.shadow=new xr}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}const Yi=new z,ge=new g,Hs=new g;class Mr extends Vs{constructor(){super(new Rs(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new k(4,2),this._viewportCount=6,this._viewports=[new W(2,1,1,1),new W(0,1,1,1),new W(3,1,1,1),new W(1,1,1,1),new W(3,0,1,1),new W(1,0,1,1)],this._cubeDirections=[new g(1,0,0),new g(-1,0,0),new g(0,0,1),new g(0,0,-1),new g(0,1,0),new g(0,-1,0)],this._cubeUps=[new g(0,1,0),new g(0,1,0),new g(0,1,0),new g(0,1,0),new g(0,0,1),new g(0,0,-1)]}updateMatrices(t,e=0){const s=this.camera,i=this.matrix,n=t.distance||s.far;n!==s.far&&(s.far=n,s.updateProjectionMatrix()),ge.setFromMatrixPosition(t.matrixWorld),s.position.copy(ge),Hs.copy(s.position),Hs.add(this._cubeDirections[e]),s.up.copy(this._cubeUps[e]),s.lookAt(Hs),s.updateMatrixWorld(),i.makeTranslation(-ge.x,-ge.y,-ge.z),Yi.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Yi)}}class wr extends Ds{constructor(t,e,s=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=s,this.decay=i,this.shadow=new Mr}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class Ki extends _i{constructor(t=-1,e=1,s=1,i=-1,n=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=s,this.bottom=i,this.near=n,this.far=r,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,s,i,n,r){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=s,this.view.offsetY=i,this.view.width=n,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),s=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let n=s-t,r=s+t,o=i+e,a=i-e;if(this.view!==null&&this.view.enabled){const h=(this.right-this.left)/this.view.fullWidth/this.zoom,c=(this.top-this.bottom)/this.view.fullHeight/this.zoom;n+=h*this.view.offsetX,r=n+h*this.view.width,o-=c*this.view.offsetY,a=o-c*this.view.height}this.projectionMatrix.makeOrthographic(n,r,o,a,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class _r extends Vs{constructor(){super(new Ki(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Tr extends Ds{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(L.DEFAULT_UP),this.updateMatrix(),this.target=new L,this.shadow=new _r}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class xe{static extractUrlBase(t){const e=t.lastIndexOf("/");return e===-1?"./":t.slice(0,e+1)}static resolveURL(t,e){return typeof t!="string"||t===""?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}const Ws=new WeakMap;class Sr extends Bt{constructor(t){super(t),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,s,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const n=this,r=yt.get(`image-bitmap:${t}`);if(r!==void 0){if(n.manager.itemStart(t),r.then){r.then(h=>{if(Ws.has(r)===!0)i&&i(Ws.get(r)),n.manager.itemError(t),n.manager.itemEnd(t);else return e&&e(h),n.manager.itemEnd(t),h});return}return setTimeout(function(){e&&e(r),n.manager.itemEnd(t)},0),r}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const a=fetch(t,o).then(function(h){return h.blob()}).then(function(h){return createImageBitmap(h,Object.assign(n.options,{colorSpaceConversion:"none"}))}).then(function(h){return yt.add(`image-bitmap:${t}`,h),e&&e(h),n.manager.itemEnd(t),h}).catch(function(h){i&&i(h),Ws.set(a,h),yt.remove(`image-bitmap:${t}`),n.manager.itemError(t),n.manager.itemEnd(t)});yt.add(`image-bitmap:${t}`,a),n.manager.itemStart(t)}}const js="\\[\\]\\.:\\/",Ar=new RegExp("["+js+"]","g"),Gs="[^"+js+"]",Er="[^"+js.replace("\\.","")+"]",Rr=/((?:WC+[\/:])*)/.source.replace("WC",Gs),zr=/(WCOD+)?/.source.replace("WCOD",Er),Ir=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Gs),Cr=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Gs),Fr=new RegExp("^"+Rr+zr+Ir+Cr+"$"),kr=["material","materials","bones","map"];class Lr{constructor(t,e,s){const i=s||C.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();const s=this._targetGroup.nCachedObjects_,i=this._bindings[s];i!==void 0&&i.getValue(t,e)}setValue(t,e){const s=this._bindings;for(let i=this._targetGroup.nCachedObjects_,n=s.length;i!==n;++i)s[i].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,s=t.length;e!==s;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,s=t.length;e!==s;++e)t[e].unbind()}}class C{constructor(t,e,s){this.path=e,this.parsedPath=s||C.parseTrackName(e),this.node=C.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,s){return t&&t.isAnimationObjectGroup?new C.Composite(t,e,s):new C(t,e,s)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Ar,"")}static parseTrackName(t){const e=Fr.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const s={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=s.nodeName&&s.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const n=s.nodeName.substring(i+1);kr.indexOf(n)!==-1&&(s.nodeName=s.nodeName.substring(0,i),s.objectName=n)}if(s.propertyName===null||s.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return s}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){const s=t.skeleton.getBoneByName(e);if(s!==void 0)return s}if(t.children){const s=function(n){for(let r=0;r<n.length;r++){const o=n[r];if(o.name===e||o.uuid===e)return o;const a=s(o.children);if(a)return a}return null},i=s(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const s=this.resolvedProperty;for(let i=0,n=s.length;i!==n;++i)t[e++]=s[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const s=this.resolvedProperty;for(let i=0,n=s.length;i!==n;++i)s[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const s=this.resolvedProperty;for(let i=0,n=s.length;i!==n;++i)s[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const s=this.resolvedProperty;for(let i=0,n=s.length;i!==n;++i)s[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,s=e.objectName,i=e.propertyName;let n=e.propertyIndex;if(t||(t=C.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(s){let h=e.objectIndex;switch(s){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let c=0;c<t.length;c++)if(t[c].name===h){h=c;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[s]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[s]}if(h!==void 0){if(t[h]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[h]}}const r=t[i];if(r===void 0){const h=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+h+"."+i+" but it wasn't found.",t);return}let o=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?o=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let a=this.BindingType.Direct;if(n!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[n]!==void 0&&(n=t.morphTargetDictionary[n])}a=this.BindingType.ArrayElement,this.resolvedProperty=r,this.propertyIndex=n}else r.fromArray!==void 0&&r.toArray!==void 0?(a=this.BindingType.HasFromToArray,this.resolvedProperty=r):Array.isArray(r)?(a=this.BindingType.EntireArray,this.resolvedProperty=r):this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}C.Composite=Lr,C.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},C.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},C.prototype.GetterByBindingType=[C.prototype._getValue_direct,C.prototype._getValue_array,C.prototype._getValue_arrayElement,C.prototype._getValue_toArray],C.prototype.SetterByBindingTypeAndVersioning=[[C.prototype._setValue_direct,C.prototype._setValue_direct_setNeedsUpdate,C.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[C.prototype._setValue_array,C.prototype._setValue_array_setNeedsUpdate,C.prototype._setValue_array_setMatrixWorldNeedsUpdate],[C.prototype._setValue_arrayElement,C.prototype._setValue_arrayElement_setNeedsUpdate,C.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[C.prototype._setValue_fromArray,C.prototype._setValue_fromArray_setNeedsUpdate,C.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]],typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ti}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ti);function Ji(d,t){if(t===0)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),d;if(t===2||t===1){let e=d.getIndex();if(e===null){const r=[],o=d.getAttribute("position");if(o!==void 0){for(let a=0;a<o.count;a++)r.push(a);d.setIndex(r),e=d.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),d}const s=e.count-2,i=[];if(t===2)for(let r=1;r<=s;r++)i.push(e.getX(0)),i.push(e.getX(r)),i.push(e.getX(r+1));else for(let r=0;r<s;r++)r%2===0?(i.push(e.getX(r)),i.push(e.getX(r+1)),i.push(e.getX(r+2))):(i.push(e.getX(r+2)),i.push(e.getX(r+1)),i.push(e.getX(r)));i.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const n=d.clone();return n.setIndex(i),n.clearGroups(),n}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),d}class Nr extends Bt{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new Dr(e)}),this.register(function(e){return new Ur(e)}),this.register(function(e){return new Kr(e)}),this.register(function(e){return new Jr(e)}),this.register(function(e){return new Zr(e)}),this.register(function(e){return new Hr(e)}),this.register(function(e){return new Wr(e)}),this.register(function(e){return new jr(e)}),this.register(function(e){return new Gr(e)}),this.register(function(e){return new Or(e)}),this.register(function(e){return new qr(e)}),this.register(function(e){return new Vr(e)}),this.register(function(e){return new Yr(e)}),this.register(function(e){return new Xr(e)}),this.register(function(e){return new vr(e)}),this.register(function(e){return new $r(e)}),this.register(function(e){return new Qr(e)})}load(t,e,s,i){const n=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const h=xe.extractUrlBase(t);r=xe.resolveURL(h,this.path)}else r=xe.extractUrlBase(t);this.manager.itemStart(t);const o=function(h){i?i(h):console.error(h),n.manager.itemError(t),n.manager.itemEnd(t)},a=new Ke(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(h){try{n.parse(h,r,function(c){e(c),n.manager.itemEnd(t)},o)}catch(c){o(c)}},s,o)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,s,i){let n;const r={},o={},a=new TextDecoder;if(typeof t=="string")n=JSON.parse(t);else if(t instanceof ArrayBuffer)if(a.decode(new Uint8Array(t,0,4))===Zi){try{r[R.KHR_BINARY_GLTF]=new to(t)}catch(l){i&&i(l);return}n=JSON.parse(r[R.KHR_BINARY_GLTF].content)}else n=JSON.parse(a.decode(t));else n=t;if(n.asset===void 0||n.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const h=new fo(n,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let c=0;c<this.pluginCallbacks.length;c++){const l=this.pluginCallbacks[c](h);l.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[l.name]=l,r[l.name]=!0}if(n.extensionsUsed)for(let c=0;c<n.extensionsUsed.length;++c){const l=n.extensionsUsed[c],u=n.extensionsRequired||[];switch(l){case R.KHR_MATERIALS_UNLIT:r[l]=new Pr;break;case R.KHR_DRACO_MESH_COMPRESSION:r[l]=new eo(n,this.dracoLoader);break;case R.KHR_TEXTURE_TRANSFORM:r[l]=new so;break;case R.KHR_MESH_QUANTIZATION:r[l]=new io;break;default:u.indexOf(l)>=0&&o[l]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+l+'".')}}h.setExtensions(r),h.setPlugins(o),h.parse(s,i)}parseAsync(t,e){const s=this;return new Promise(function(i,n){s.parse(t,e,i,n)})}}function Br(){let d={};return{get:function(t){return d[t]},add:function(t,e){d[t]=e},remove:function(t){delete d[t]},removeAll:function(){d={}}}}const R={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_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",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_ANISOTROPY:"KHR_materials_anisotropy",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_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class vr{constructor(t){this.parser=t,this.name=R.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let s=0,i=e.length;s<i;s++){const n=e[s];n.extensions&&n.extensions[this.name]&&n.extensions[this.name].light!==void 0&&t._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(t){const e=this.parser,s="light:"+t;let i=e.cache.get(s);if(i)return i;const n=e.json,a=((n.extensions&&n.extensions[this.name]||{}).lights||[])[t];let h;const c=new N(16777215);a.color!==void 0&&c.setRGB(a.color[0],a.color[1],a.color[2],K);const l=a.range!==void 0?a.range:0;switch(a.type){case"directional":h=new Tr(c),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new wr(c),h.distance=l;break;case"spot":h=new br(c),h.distance=l,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,h.angle=a.spot.outerConeAngle,h.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return h.position.set(0,0,0),xt(h,a),a.intensity!==void 0&&(h.intensity=a.intensity),h.name=e.createUniqueName(a.name||"light_"+t),i=Promise.resolve(h),e.cache.add(s,i),i}getDependency(t,e){if(t==="light")return this._loadLight(e)}createNodeAttachment(t){const e=this,s=this.parser,n=s.json.nodes[t],o=(n.extensions&&n.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(a){return s._getNodeRef(e.cache,o,a)})}}class Pr{constructor(){this.name=R.KHR_MATERIALS_UNLIT}getMaterialType(){return Kt}extendParams(t,e,s){const i=[];t.color=new N(1,1,1),t.opacity=1;const n=e.pbrMetallicRoughness;if(n){if(Array.isArray(n.baseColorFactor)){const r=n.baseColorFactor;t.color.setRGB(r[0],r[1],r[2],K),t.opacity=r[3]}n.baseColorTexture!==void 0&&i.push(s.assignTexture(t,"map",n.baseColorTexture,P))}return Promise.all(i)}}class Or{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name].emissiveStrength;return n!==void 0&&(e.emissiveIntensity=n),Promise.resolve()}}class Dr{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:at}extendMaterialParams(t,e){const s=this.parser,i=s.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];if(r.clearcoatFactor!==void 0&&(e.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&n.push(s.assignTexture(e,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&n.push(s.assignTexture(e,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(n.push(s.assignTexture(e,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const o=r.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new k(o,o)}return Promise.all(n)}}class Ur{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_DISPERSION}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:at}extendMaterialParams(t,e){const i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name];return e.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class Vr{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:at}extendMaterialParams(t,e){const s=this.parser,i=s.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];return r.iridescenceFactor!==void 0&&(e.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&n.push(s.assignTexture(e,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(e.iridescenceIOR=r.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&n.push(s.assignTexture(e,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(n)}}class Hr{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_SHEEN}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:at}extendMaterialParams(t,e){const s=this.parser,i=s.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[];e.sheenColor=new N(0,0,0),e.sheenRoughness=0,e.sheen=1;const r=i.extensions[this.name];if(r.sheenColorFactor!==void 0){const o=r.sheenColorFactor;e.sheenColor.setRGB(o[0],o[1],o[2],K)}return r.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&n.push(s.assignTexture(e,"sheenColorMap",r.sheenColorTexture,P)),r.sheenRoughnessTexture!==void 0&&n.push(s.assignTexture(e,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(n)}}class Wr{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:at}extendMaterialParams(t,e){const s=this.parser,i=s.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];return r.transmissionFactor!==void 0&&(e.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&n.push(s.assignTexture(e,"transmissionMap",r.transmissionTexture)),Promise.all(n)}}class jr{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_VOLUME}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:at}extendMaterialParams(t,e){const s=this.parser,i=s.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];e.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&n.push(s.assignTexture(e,"thicknessMap",r.thicknessTexture)),e.attenuationDistance=r.attenuationDistance||1/0;const o=r.attenuationColor||[1,1,1];return e.attenuationColor=new N().setRGB(o[0],o[1],o[2],K),Promise.all(n)}}class Gr{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_IOR}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:at}extendMaterialParams(t,e){const i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name];return e.ior=n.ior!==void 0?n.ior:1.5,Promise.resolve()}}class qr{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_SPECULAR}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:at}extendMaterialParams(t,e){const s=this.parser,i=s.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];e.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&n.push(s.assignTexture(e,"specularIntensityMap",r.specularTexture));const o=r.specularColorFactor||[1,1,1];return e.specularColor=new N().setRGB(o[0],o[1],o[2],K),r.specularColorTexture!==void 0&&n.push(s.assignTexture(e,"specularColorMap",r.specularColorTexture,P)),Promise.all(n)}}class Xr{constructor(t){this.parser=t,this.name=R.EXT_MATERIALS_BUMP}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:at}extendMaterialParams(t,e){const s=this.parser,i=s.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];return e.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&n.push(s.assignTexture(e,"bumpMap",r.bumpTexture)),Promise.all(n)}}class Yr{constructor(t){this.parser=t,this.name=R.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:at}extendMaterialParams(t,e){const s=this.parser,i=s.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];return r.anisotropyStrength!==void 0&&(e.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(e.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&n.push(s.assignTexture(e,"anisotropyMap",r.anisotropyTexture)),Promise.all(n)}}class Kr{constructor(t){this.parser=t,this.name=R.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,s=e.json,i=s.textures[t];if(!i.extensions||!i.extensions[this.name])return null;const n=i.extensions[this.name],r=e.options.ktx2Loader;if(!r){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,n.source,r)}}class Jr{constructor(t){this.parser=t,this.name=R.EXT_TEXTURE_WEBP}loadTexture(t){const e=this.name,s=this.parser,i=s.json,n=i.textures[t];if(!n.extensions||!n.extensions[e])return null;const r=n.extensions[e],o=i.images[r.source];let a=s.textureLoader;if(o.uri){const h=s.options.manager.getHandler(o.uri);h!==null&&(a=h)}return s.loadTextureImage(t,r.source,a)}}class Zr{constructor(t){this.parser=t,this.name=R.EXT_TEXTURE_AVIF}loadTexture(t){const e=this.name,s=this.parser,i=s.json,n=i.textures[t];if(!n.extensions||!n.extensions[e])return null;const r=n.extensions[e],o=i.images[r.source];let a=s.textureLoader;if(o.uri){const h=s.options.manager.getHandler(o.uri);h!==null&&(a=h)}return s.loadTextureImage(t,r.source,a)}}class $r{constructor(t){this.name=R.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,s=e.bufferViews[t];if(s.extensions&&s.extensions[this.name]){const i=s.extensions[this.name],n=this.parser.getDependency("buffer",i.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return n.then(function(o){const a=i.byteOffset||0,h=i.byteLength||0,c=i.count,l=i.byteStride,u=new Uint8Array(o,a,h);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(c,l,u,i.mode,i.filter).then(function(p){return p.buffer}):r.ready.then(function(){const p=new ArrayBuffer(c*l);return r.decodeGltfBuffer(new Uint8Array(p),c,l,u,i.mode,i.filter),p})})}else return null}}class Qr{constructor(t){this.name=R.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,s=e.nodes[t];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const i=e.meshes[s.mesh];for(const h of i.primitives)if(h.mode!==Z.TRIANGLES&&h.mode!==Z.TRIANGLE_STRIP&&h.mode!==Z.TRIANGLE_FAN&&h.mode!==void 0)return null;const r=s.extensions[this.name].attributes,o=[],a={};for(const h in r)o.push(this.parser.getDependency("accessor",r[h]).then(c=>(a[h]=c,a[h])));return o.length<1?null:(o.push(this.parser.createNodeMesh(t)),Promise.all(o).then(h=>{const c=h.pop(),l=c.isGroup?c.children:[c],u=h[0].count,p=[];for(const f of l){const m=new z,y=new g,x=new bt,M=new g(1,1,1),w=new Jn(f.geometry,f.material,u);for(let b=0;b<u;b++)a.TRANSLATION&&y.fromBufferAttribute(a.TRANSLATION,b),a.ROTATION&&x.fromBufferAttribute(a.ROTATION,b),a.SCALE&&M.fromBufferAttribute(a.SCALE,b),w.setMatrixAt(b,m.compose(y,x,M));for(const b in a)if(b==="_COLOR_0"){const _=a[b];w.instanceColor=new Ls(_.array,_.itemSize,_.normalized)}else b!=="TRANSLATION"&&b!=="ROTATION"&&b!=="SCALE"&&f.geometry.setAttribute(b,a[b]);L.prototype.copy.call(w,f),this.parser.assignFinalMaterial(w),p.push(w)}return c.isGroup?(c.clear(),c.add(...p),c):p[0]}))}}const Zi="glTF",be=12,$i={JSON:1313821514,BIN:5130562};class to{constructor(t){this.name=R.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,be),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==Zi)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-be,n=new DataView(t,be);let r=0;for(;r<i;){const o=n.getUint32(r,!0);r+=4;const a=n.getUint32(r,!0);if(r+=4,a===$i.JSON){const h=new Uint8Array(t,be+r,o);this.content=s.decode(h)}else if(a===$i.BIN){const h=be+r;this.body=t.slice(h,h+o)}r+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class eo{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=R.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const s=this.json,i=this.dracoLoader,n=t.extensions[this.name].bufferView,r=t.extensions[this.name].attributes,o={},a={},h={};for(const c in r){const l=Xs[c]||c.toLowerCase();o[l]=r[c]}for(const c in t.attributes){const l=Xs[c]||c.toLowerCase();if(r[c]!==void 0){const u=s.accessors[t.attributes[c]],p=re[u.componentType];h[l]=p.name,a[l]=u.normalized===!0}}return e.getDependency("bufferView",n).then(function(c){return new Promise(function(l,u){i.decodeDracoFile(c,function(p){for(const f in p.attributes){const m=p.attributes[f],y=a[f];y!==void 0&&(m.normalized=y)}l(p)},o,h,K,u)})})}}class so{constructor(){this.name=R.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return(e.texCoord===void 0||e.texCoord===t.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(t=t.clone(),e.texCoord!==void 0&&(t.channel=e.texCoord),e.offset!==void 0&&t.offset.fromArray(e.offset),e.rotation!==void 0&&(t.rotation=e.rotation),e.scale!==void 0&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class io{constructor(){this.name=R.KHR_MESH_QUANTIZATION}}class Qi extends ye{constructor(t,e,s,i){super(t,e,s,i)}copySampleValue_(t){const e=this.resultBuffer,s=this.sampleValues,i=this.valueSize,n=t*i*3+i;for(let r=0;r!==i;r++)e[r]=s[n+r];return e}interpolate_(t,e,s,i){const n=this.resultBuffer,r=this.sampleValues,o=this.valueSize,a=o*2,h=o*3,c=i-e,l=(s-e)/c,u=l*l,p=u*l,f=t*h,m=f-h,y=-2*p+3*u,x=p-u,M=1-y,w=x-u+l;for(let b=0;b!==o;b++){const _=r[m+b+o],A=r[m+b+a]*c,T=r[f+b+o],S=r[f+b]*c;n[b]=M*_+w*A+y*T+x*S}return n}}const no=new bt;class ro extends Qi{interpolate_(t,e,s,i){const n=super.interpolate_(t,e,s,i);return no.fromArray(n).normalize().toArray(n),n}}const Z={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},re={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},tn={9728:1003,9729:1006,9984:1004,9985:1007,9986:1005,9987:1008},en={33071:1001,33648:1002,10497:1e3},qs={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Xs={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Et={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},oo={CUBICSPLINE:void 0,LINEAR:2301,STEP:2300},Ys={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function ao(d){return d.DefaultMaterial===void 0&&(d.DefaultMaterial=new Os({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),d.DefaultMaterial}function vt(d,t,e){for(const s in e.extensions)d[s]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[s]=e.extensions[s])}function xt(d,t){t.extras!==void 0&&(typeof t.extras=="object"?Object.assign(d.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function ho(d,t,e){let s=!1,i=!1,n=!1;for(let h=0,c=t.length;h<c;h++){const l=t[h];if(l.POSITION!==void 0&&(s=!0),l.NORMAL!==void 0&&(i=!0),l.COLOR_0!==void 0&&(n=!0),s&&i&&n)break}if(!s&&!i&&!n)return Promise.resolve(d);const r=[],o=[],a=[];for(let h=0,c=t.length;h<c;h++){const l=t[h];if(s){const u=l.POSITION!==void 0?e.getDependency("accessor",l.POSITION):d.attributes.position;r.push(u)}if(i){const u=l.NORMAL!==void 0?e.getDependency("accessor",l.NORMAL):d.attributes.normal;o.push(u)}if(n){const u=l.COLOR_0!==void 0?e.getDependency("accessor",l.COLOR_0):d.attributes.color;a.push(u)}}return Promise.all([Promise.all(r),Promise.all(o),Promise.all(a)]).then(function(h){const c=h[0],l=h[1],u=h[2];return s&&(d.morphAttributes.position=c),i&&(d.morphAttributes.normal=l),n&&(d.morphAttributes.color=u),d.morphTargetsRelative=!0,d})}function co(d,t){if(d.updateMorphTargets(),t.weights!==void 0)for(let e=0,s=t.weights.length;e<s;e++)d.morphTargetInfluences[e]=t.weights[e];if(t.extras&&Array.isArray(t.extras.targetNames)){const e=t.extras.targetNames;if(d.morphTargetInfluences.length===e.length){d.morphTargetDictionary={};for(let s=0,i=e.length;s<i;s++)d.morphTargetDictionary[e[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function lo(d){let t;const e=d.extensions&&d.extensions[R.KHR_DRACO_MESH_COMPRESSION];if(e?t="draco:"+e.bufferView+":"+e.indices+":"+Ks(e.attributes):t=d.indices+":"+Ks(d.attributes)+":"+d.mode,d.targets!==void 0)for(let s=0,i=d.targets.length;s<i;s++)t+=":"+Ks(d.targets[s]);return t}function Ks(d){let t="";const e=Object.keys(d).sort();for(let s=0,i=e.length;s<i;s++)t+=e[s]+":"+d[e[s]]+";";return t}function Js(d){switch(d){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function uo(d){return d.search(/\.jpe?g($|\?)/i)>0||d.search(/^data\:image\/jpeg/)===0?"image/jpeg":d.search(/\.webp($|\?)/i)>0||d.search(/^data\:image\/webp/)===0?"image/webp":d.search(/\.ktx2($|\?)/i)>0||d.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const po=new z;class fo{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new Br,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,i=-1,n=!1,r=-1;if(typeof navigator<"u"){const o=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(o)===!0;const a=o.match(/Version\/(\d+)/);i=s&&a?parseInt(a[1],10):-1,n=o.indexOf("Firefox")>-1,r=n?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&i<17||n&&r<98?this.textureLoader=new gr(this.options.manager):this.textureLoader=new Sr(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ke(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const s=this,i=this.json,n=this.extensions;this.cache.removeAll(),this.nodeCache={},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([s.getDependencies("scene"),s.getDependencies("animation"),s.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:s,userData:{}};return vt(n,o,i),xt(o,i),Promise.all(s._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(const a of o.scenes)a.updateMatrixWorld();t(o)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],s=this.json.meshes||[];for(let i=0,n=e.length;i<n;i++){const r=e[i].joints;for(let o=0,a=r.length;o<a;o++)t[r[o]].isBone=!0}for(let i=0,n=t.length;i<n;i++){const r=t[i];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(s[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(t,e){e!==void 0&&(t.refs[e]===void 0&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,s){if(t.refs[e]<=1)return s;const i=s.clone(),n=(r,o)=>{const a=this.associations.get(r);a!=null&&this.associations.set(o,a);for(const[h,c]of r.children.entries())n(c,o.children[h])};return n(s,i),i.name+="_instance_"+t.uses[e]++,i}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let s=0;s<e.length;s++){const i=t(e[s]);if(i)return i}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const s=[];for(let i=0;i<e.length;i++){const n=t(e[i]);n&&s.push(n)}return s}getDependency(t,e){const s=t+":"+e;let i=this.cache.get(s);if(!i){switch(t){case"scene":i=this.loadScene(e);break;case"node":i=this._invokeOne(function(n){return n.loadNode&&n.loadNode(e)});break;case"mesh":i=this._invokeOne(function(n){return n.loadMesh&&n.loadMesh(e)});break;case"accessor":i=this.loadAccessor(e);break;case"bufferView":i=this._invokeOne(function(n){return n.loadBufferView&&n.loadBufferView(e)});break;case"buffer":i=this.loadBuffer(e);break;case"material":i=this._invokeOne(function(n){return n.loadMaterial&&n.loadMaterial(e)});break;case"texture":i=this._invokeOne(function(n){return n.loadTexture&&n.loadTexture(e)});break;case"skin":i=this.loadSkin(e);break;case"animation":i=this._invokeOne(function(n){return n.loadAnimation&&n.loadAnimation(e)});break;case"camera":i=this.loadCamera(e);break;default:if(i=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(t,e)}),!i)throw new Error("Unknown type: "+t);break}this.cache.add(s,i)}return i}getDependencies(t){let e=this.cache.get(t);if(!e){const s=this,i=this.json[t+(t==="mesh"?"es":"s")]||[];e=Promise.all(i.map(function(n,r){return s.getDependency(t,r)})),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],s=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&t===0)return Promise.resolve(this.extensions[R.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(n,r){s.load(xe.resolveURL(e.uri,i.path),n,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(s){const i=e.byteLength||0,n=e.byteOffset||0;return s.slice(n,n+i)})}loadAccessor(t){const e=this,s=this.json,i=this.json.accessors[t];if(i.bufferView===void 0&&i.sparse===void 0){const r=qs[i.type],o=re[i.componentType],a=i.normalized===!0,h=new o(i.count*r);return Promise.resolve(new X(h,r,a))}const n=[];return i.bufferView!==void 0?n.push(this.getDependency("bufferView",i.bufferView)):n.push(null),i.sparse!==void 0&&(n.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),n.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(n).then(function(r){const o=r[0],a=qs[i.type],h=re[i.componentType],c=h.BYTES_PER_ELEMENT,l=c*a,u=i.byteOffset||0,p=i.bufferView!==void 0?s.bufferViews[i.bufferView].byteStride:void 0,f=i.normalized===!0;let m,y;if(p&&p!==l){const x=Math.floor(u/p),M="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+x+":"+i.count;let w=e.cache.get(M);w||(m=new h(o,x*p,i.count*p/c),w=new Gn(m,p/c),e.cache.add(M,w)),y=new Is(w,a,u%p/c,f)}else o===null?m=new h(i.count*a):m=new h(o,u,i.count*a),y=new X(m,a,f);if(i.sparse!==void 0){const x=qs.SCALAR,M=re[i.sparse.indices.componentType],w=i.sparse.indices.byteOffset||0,b=i.sparse.values.byteOffset||0,_=new M(r[1],w,i.sparse.count*x),A=new h(r[2],b,i.sparse.count*a);o!==null&&(y=new X(y.array.slice(),y.itemSize,y.normalized)),y.normalized=!1;for(let T=0,S=_.length;T<S;T++){const F=_[T];if(y.setX(F,A[T*a]),a>=2&&y.setY(F,A[T*a+1]),a>=3&&y.setZ(F,A[T*a+2]),a>=4&&y.setW(F,A[T*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}y.normalized=f}return y})}loadTexture(t){const e=this.json,s=this.options,n=e.textures[t].source,r=e.images[n];let o=this.textureLoader;if(r.uri){const a=s.manager.getHandler(r.uri);a!==null&&(o=a)}return this.loadTextureImage(t,n,o)}loadTextureImage(t,e,s){const i=this,n=this.json,r=n.textures[t],o=n.images[e],a=(o.uri||o.bufferView)+":"+r.sampler;if(this.textureCache[a])return this.textureCache[a];const h=this.loadImageSource(e,s).then(function(c){c.flipY=!1,c.name=r.name||o.name||"",c.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(c.name=o.uri);const u=(n.samplers||{})[r.sampler]||{};return c.magFilter=tn[u.magFilter]||1006,c.minFilter=tn[u.minFilter]||1008,c.wrapS=en[u.wrapS]||1e3,c.wrapT=en[u.wrapT]||1e3,c.generateMipmaps=!c.isCompressedTexture&&c.minFilter!==1003&&c.minFilter!==1006,i.associations.set(c,{textures:t}),c}).catch(function(){return null});return this.textureCache[a]=h,h}loadImageSource(t,e){const s=this,i=this.json,n=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(l=>l.clone());const r=i.images[t],o=self.URL||self.webkitURL;let a=r.uri||"",h=!1;if(r.bufferView!==void 0)a=s.getDependency("bufferView",r.bufferView).then(function(l){h=!0;const u=new Blob([l],{type:r.mimeType});return a=o.createObjectURL(u),a});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const c=Promise.resolve(a).then(function(l){return new Promise(function(u,p){let f=u;e.isImageBitmapLoader===!0&&(f=function(m){const y=new tt(m);y.needsUpdate=!0,u(y)}),e.load(xe.resolveURL(l,n.path),f,void 0,p)})}).then(function(l){return h===!0&&o.revokeObjectURL(a),xt(l,r),l.userData.mimeType=r.mimeType||uo(r.uri),l}).catch(function(l){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),l});return this.sourceCache[t]=c,c}assignTexture(t,e,s,i){const n=this;return this.getDependency("texture",s.index).then(function(r){if(!r)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(r=r.clone(),r.channel=s.texCoord),n.extensions[R.KHR_TEXTURE_TRANSFORM]){const o=s.extensions!==void 0?s.extensions[R.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const a=n.associations.get(r);r=n.extensions[R.KHR_TEXTURE_TRANSFORM].extendTexture(r,o),n.associations.set(r,a)}}return i!==void 0&&(r.colorSpace=i),t[e]=r,r})}assignFinalMaterial(t){const e=t.geometry;let s=t.material;const i=e.attributes.tangent===void 0,n=e.attributes.color!==void 0,r=e.attributes.normal===void 0;if(t.isPoints){const o="PointsMaterial:"+s.uuid;let a=this.cache.get(o);a||(a=new Ui,Ft.prototype.copy.call(a,s),a.color.copy(s.color),a.map=s.map,a.sizeAttenuation=!1,this.cache.add(o,a)),s=a}else if(t.isLine){const o="LineBasicMaterial:"+s.uuid;let a=this.cache.get(o);a||(a=new Bi,Ft.prototype.copy.call(a,s),a.color.copy(s.color),a.map=s.map,this.cache.add(o,a)),s=a}if(i||n||r){let o="ClonedMaterial:"+s.uuid+":";i&&(o+="derivative-tangents:"),n&&(o+="vertex-colors:"),r&&(o+="flat-shading:");let a=this.cache.get(o);a||(a=s.clone(),n&&(a.vertexColors=!0),r&&(a.flatShading=!0),i&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(o,a),this.associations.set(a,this.associations.get(s))),s=a}t.material=s}getMaterialType(){return Os}loadMaterial(t){const e=this,s=this.json,i=this.extensions,n=s.materials[t];let r;const o={},a=n.extensions||{},h=[];if(a[R.KHR_MATERIALS_UNLIT]){const l=i[R.KHR_MATERIALS_UNLIT];r=l.getMaterialType(),h.push(l.extendParams(o,n,e))}else{const l=n.pbrMetallicRoughness||{};if(o.color=new N(1,1,1),o.opacity=1,Array.isArray(l.baseColorFactor)){const u=l.baseColorFactor;o.color.setRGB(u[0],u[1],u[2],K),o.opacity=u[3]}l.baseColorTexture!==void 0&&h.push(e.assignTexture(o,"map",l.baseColorTexture,P)),o.metalness=l.metallicFactor!==void 0?l.metallicFactor:1,o.roughness=l.roughnessFactor!==void 0?l.roughnessFactor:1,l.metallicRoughnessTexture!==void 0&&(h.push(e.assignTexture(o,"metalnessMap",l.metallicRoughnessTexture)),h.push(e.assignTexture(o,"roughnessMap",l.metallicRoughnessTexture))),r=this._invokeOne(function(u){return u.getMaterialType&&u.getMaterialType(t)}),h.push(Promise.all(this._invokeAll(function(u){return u.extendMaterialParams&&u.extendMaterialParams(t,o)})))}n.doubleSided===!0&&(o.side=2);const c=n.alphaMode||Ys.OPAQUE;if(c===Ys.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,c===Ys.MASK&&(o.alphaTest=n.alphaCutoff!==void 0?n.alphaCutoff:.5)),n.normalTexture!==void 0&&r!==Kt&&(h.push(e.assignTexture(o,"normalMap",n.normalTexture)),o.normalScale=new k(1,1),n.normalTexture.scale!==void 0)){const l=n.normalTexture.scale;o.normalScale.set(l,l)}if(n.occlusionTexture!==void 0&&r!==Kt&&(h.push(e.assignTexture(o,"aoMap",n.occlusionTexture)),n.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=n.occlusionTexture.strength)),n.emissiveFactor!==void 0&&r!==Kt){const l=n.emissiveFactor;o.emissive=new N().setRGB(l[0],l[1],l[2],K)}return n.emissiveTexture!==void 0&&r!==Kt&&h.push(e.assignTexture(o,"emissiveMap",n.emissiveTexture,P)),Promise.all(h).then(function(){const l=new r(o);return n.name&&(l.name=n.name),xt(l,n),e.associations.set(l,{materials:t}),n.extensions&&vt(i,l,n),l})}createUniqueName(t){const e=C.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,s=this.extensions,i=this.primitiveCache;function n(o){return s[R.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,e).then(function(a){return sn(a,o,e)})}const r=[];for(let o=0,a=t.length;o<a;o++){const h=t[o],c=lo(h),l=i[c];if(l)r.push(l.promise);else{let u;h.extensions&&h.extensions[R.KHR_DRACO_MESH_COMPRESSION]?u=n(h):u=sn(new kt,h,e),i[c]={primitive:h,promise:u},r.push(u)}}return Promise.all(r)}loadMesh(t){const e=this,s=this.json,i=this.extensions,n=s.meshes[t],r=n.primitives,o=[];for(let a=0,h=r.length;a<h;a++){const c=r[a].material===void 0?ao(this.cache):this.getDependency("material",r[a].material);o.push(c)}return o.push(e.loadGeometries(r)),Promise.all(o).then(function(a){const h=a.slice(0,a.length-1),c=a[a.length-1],l=[];for(let p=0,f=c.length;p<f;p++){const m=c[p],y=r[p];let x;const M=h[p];if(y.mode===Z.TRIANGLES||y.mode===Z.TRIANGLE_STRIP||y.mode===Z.TRIANGLE_FAN||y.mode===void 0)x=n.isSkinnedMesh===!0?new Xn(m,M):new Pe(m,M),x.isSkinnedMesh===!0&&x.normalizeSkinWeights(),y.mode===Z.TRIANGLE_STRIP?x.geometry=Ji(x.geometry,1):y.mode===Z.TRIANGLE_FAN&&(x.geometry=Ji(x.geometry,2));else if(y.mode===Z.LINES)x=new er(m,M);else if(y.mode===Z.LINE_STRIP)x=new vs(m,M);else if(y.mode===Z.LINE_LOOP)x=new sr(m,M);else if(y.mode===Z.POINTS)x=new ir(m,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+y.mode);Object.keys(x.geometry.morphAttributes).length>0&&co(x,n),x.name=e.createUniqueName(n.name||"mesh_"+t),xt(x,n),y.extensions&&vt(i,x,y),e.assignFinalMaterial(x),l.push(x)}for(let p=0,f=l.length;p<f;p++)e.associations.set(l[p],{meshes:t,primitives:p});if(l.length===1)return n.extensions&&vt(i,l[0],n),l[0];const u=new zs;n.extensions&&vt(i,u,n),e.associations.set(u,{meshes:t});for(let p=0,f=l.length;p<f;p++)u.add(l[p]);return u})}loadCamera(t){let e;const s=this.json.cameras[t],i=s[s.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?e=new Rs(Sn.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):s.type==="orthographic"&&(e=new Ki(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),s.name&&(e.name=this.createUniqueName(s.name)),xt(e,s),Promise.resolve(e)}loadSkin(t){const e=this.json.skins[t],s=[];for(let i=0,n=e.joints.length;i<n;i++)s.push(this._loadNodeShallow(e.joints[i]));return e.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",e.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(i){const n=i.pop(),r=i,o=[],a=[];for(let h=0,c=r.length;h<c;h++){const l=r[h];if(l){o.push(l);const u=new z;n!==null&&u.fromArray(n.array,h*16),a.push(u)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[h])}return new ks(o,a)})}loadAnimation(t){const e=this.json,s=this,i=e.animations[t],n=i.name?i.name:"animation_"+t,r=[],o=[],a=[],h=[],c=[];for(let l=0,u=i.channels.length;l<u;l++){const p=i.channels[l],f=i.samplers[p.sampler],m=p.target,y=m.node,x=i.parameters!==void 0?i.parameters[f.input]:f.input,M=i.parameters!==void 0?i.parameters[f.output]:f.output;m.node!==void 0&&(r.push(this.getDependency("node",y)),o.push(this.getDependency("accessor",x)),a.push(this.getDependency("accessor",M)),h.push(f),c.push(m))}return Promise.all([Promise.all(r),Promise.all(o),Promise.all(a),Promise.all(h),Promise.all(c)]).then(function(l){const u=l[0],p=l[1],f=l[2],m=l[3],y=l[4],x=[];for(let M=0,w=u.length;M<w;M++){const b=u[M],_=p[M],A=f[M],T=m[M],S=y[M];if(b===void 0)continue;b.updateMatrix&&b.updateMatrix();const F=s._createAnimationTracks(b,_,A,T,S);if(F)for(let v=0;v<F.length;v++)x.push(F[v])}return new lr(n,void 0,x)})}createNodeMesh(t){const e=this.json,s=this,i=e.nodes[t];return i.mesh===void 0?null:s.getDependency("mesh",i.mesh).then(function(n){const r=s._getNodeRef(s.meshCache,i.mesh,n);return i.weights!==void 0&&r.traverse(function(o){if(o.isMesh)for(let a=0,h=i.weights.length;a<h;a++)o.morphTargetInfluences[a]=i.weights[a]}),r})}loadNode(t){const e=this.json,s=this,i=e.nodes[t],n=s._loadNodeShallow(t),r=[],o=i.children||[];for(let h=0,c=o.length;h<c;h++)r.push(s.getDependency("node",o[h]));const a=i.skin===void 0?Promise.resolve(null):s.getDependency("skin",i.skin);return Promise.all([n,Promise.all(r),a]).then(function(h){const c=h[0],l=h[1],u=h[2];u!==null&&c.traverse(function(p){p.isSkinnedMesh&&p.bind(u,po)});for(let p=0,f=l.length;p<f;p++)c.add(l[p]);return c})}_loadNodeShallow(t){const e=this.json,s=this.extensions,i=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];const n=e.nodes[t],r=n.name?i.createUniqueName(n.name):"",o=[],a=i._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(t)});return a&&o.push(a),n.camera!==void 0&&o.push(i.getDependency("camera",n.camera).then(function(h){return i._getNodeRef(i.cameraCache,n.camera,h)})),i._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(t)}).forEach(function(h){o.push(h)}),this.nodeCache[t]=Promise.all(o).then(function(h){let c;if(n.isBone===!0?c=new Ci:h.length>1?c=new zs:h.length===1?c=h[0]:c=new L,c!==h[0])for(let l=0,u=h.length;l<u;l++)c.add(h[l]);if(n.name&&(c.userData.name=n.name,c.name=r),xt(c,n),n.extensions&&vt(s,c,n),n.matrix!==void 0){const l=new z;l.fromArray(n.matrix),c.applyMatrix4(l)}else n.translation!==void 0&&c.position.fromArray(n.translation),n.rotation!==void 0&&c.quaternion.fromArray(n.rotation),n.scale!==void 0&&c.scale.fromArray(n.scale);if(!i.associations.has(c))i.associations.set(c,{});else if(n.mesh!==void 0&&i.meshCache.refs[n.mesh]>1){const l=i.associations.get(c);i.associations.set(c,{...l})}return i.associations.get(c).nodes=t,c}),this.nodeCache[t]}loadScene(t){const e=this.extensions,s=this.json.scenes[t],i=this,n=new zs;s.name&&(n.name=i.createUniqueName(s.name)),xt(n,s),s.extensions&&vt(e,n,s);const r=s.nodes||[],o=[];for(let a=0,h=r.length;a<h;a++)o.push(i.getDependency("node",r[a]));return Promise.all(o).then(function(a){for(let c=0,l=a.length;c<l;c++)n.add(a[c]);const h=c=>{const l=new Map;for(const[u,p]of i.associations)(u instanceof Ft||u instanceof tt)&&l.set(u,p);return c.traverse(u=>{const p=i.associations.get(u);p!=null&&l.set(u,p)}),l};return i.associations=h(n),n})}_createAnimationTracks(t,e,s,i,n){const r=[],o=t.name?t.name:t.uuid,a=[];Et[n.path]===Et.weights?t.traverse(function(u){u.morphTargetInfluences&&a.push(u.name?u.name:u.uuid)}):a.push(o);let h;switch(Et[n.path]){case Et.weights:h=te;break;case Et.rotation:h=ee;break;case Et.translation:case Et.scale:h=ie;break;default:switch(s.itemSize){case 1:h=te;break;case 2:case 3:default:h=ie;break}break}const c=i.interpolation!==void 0?oo[i.interpolation]:2301,l=this._getArrayFromAccessor(s);for(let u=0,p=a.length;u<p;u++){const f=new h(a[u]+"."+Et[n.path],e.array,l,c);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(f),r.push(f)}return r}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const s=Js(e.constructor),i=new Float32Array(e.length);for(let n=0,r=e.length;n<r;n++)i[n]=e[n]*s;e=i}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(s){const i=this instanceof ee?ro:Qi;return new i(this.times,this.values,this.getValueSize()/3,s)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function mo(d,t,e){const s=t.attributes,i=new lt;if(s.POSITION!==void 0){const o=e.json.accessors[s.POSITION],a=o.min,h=o.max;if(a!==void 0&&h!==void 0){if(i.set(new g(a[0],a[1],a[2]),new g(h[0],h[1],h[2])),o.normalized){const c=Js(re[o.componentType]);i.min.multiplyScalar(c),i.max.multiplyScalar(c)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const n=t.targets;if(n!==void 0){const o=new g,a=new g;for(let h=0,c=n.length;h<c;h++){const l=n[h];if(l.POSITION!==void 0){const u=e.json.accessors[l.POSITION],p=u.min,f=u.max;if(p!==void 0&&f!==void 0){if(a.setX(Math.max(Math.abs(p[0]),Math.abs(f[0]))),a.setY(Math.max(Math.abs(p[1]),Math.abs(f[1]))),a.setZ(Math.max(Math.abs(p[2]),Math.abs(f[2]))),u.normalized){const m=Js(re[u.componentType]);a.multiplyScalar(m)}o.max(a)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(o)}d.boundingBox=i;const r=new ot;i.getCenter(r.center),r.radius=i.min.distanceTo(i.max)/2,d.boundingSphere=r}function sn(d,t,e){const s=t.attributes,i=[];function n(r,o){return e.getDependency("accessor",r).then(function(a){d.setAttribute(o,a)})}for(const r in s){const o=Xs[r]||r.toLowerCase();o in d.attributes||i.push(n(s[r],o))}if(t.indices!==void 0&&!d.index){const r=e.getDependency("accessor",t.indices).then(function(o){d.setIndex(o)});i.push(r)}return G.workingColorSpace!==K&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${G.workingColorSpace}" not supported.`),xt(d,t),mo(d,t,e),Promise.all(i).then(function(){return t.targets!==void 0?ho(d,t.targets,e):d})}const Zs=new WeakMap;class yo extends Bt{constructor(t){super(t),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(t){return this.decoderPath=t,this}setDecoderConfig(t){return this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,s,i){const n=new Ke(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(t,r=>{this.parse(r,e,i)},s,i)}parse(t,e,s=()=>{}){this.decodeDracoFile(t,e,null,null,P,s).catch(s)}decodeDracoFile(t,e,s,i,n=K,r=()=>{}){const o={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!s,vertexColorSpace:n};return this.decodeGeometry(t,o).then(e).catch(r)}decodeGeometry(t,e){const s=JSON.stringify(e);if(Zs.has(t)){const a=Zs.get(t);if(a.key===s)return a.promise;if(t.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const n=this.workerNextTaskID++,r=t.byteLength,o=this._getWorker(n,r).then(a=>(i=a,new Promise((h,c)=>{i._callbacks[n]={resolve:h,reject:c},i.postMessage({type:"decode",id:n,taskConfig:e,buffer:t},[t])}))).then(a=>this._createGeometry(a.geometry));return o.catch(()=>!0).then(()=>{i&&n&&this._releaseTask(i,n)}),Zs.set(t,{key:s,promise:o}),o}_createGeometry(t){const e=new kt;t.index&&e.setIndex(new X(t.index.array,1));for(let s=0;s<t.attributes.length;s++){const i=t.attributes[s],n=i.name,r=i.array,o=i.itemSize,a=new X(r,o);n==="color"&&(this._assignVertexColorSpace(a,i.vertexColorSpace),a.normalized=!(r instanceof Float32Array)),e.setAttribute(n,a)}return e}_assignVertexColorSpace(t,e){if(e!==P)return;const s=new N;for(let i=0,n=t.count;i<n;i++)s.fromBufferAttribute(t,i),G.colorSpaceToWorking(s,P),t.setXYZ(i,s.r,s.g,s.b)}_loadLibrary(t,e){const s=new Ke(this.manager);return s.setPath(this.decoderPath),s.setResponseType(e),s.setWithCredentials(this.withCredentials),new Promise((i,n)=>{s.load(t,i,void 0,n)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const t=typeof WebAssembly!="object"||this.decoderConfig.type==="js",e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then(s=>{const i=s[0];t||(this.decoderConfig.wasmBinary=s[1]);const n=go.toString(),r=["/* draco decoder */",i,"","/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join(`
6
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(n){const r=n.data;switch(r.type){case"decode":i._callbacks[r.id].resolve(r);break;case"error":i._callbacks[r.id].reject(r);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+r.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,n){return i._taskLoad>n._taskLoad?-1:1});const s=this.workerPool[this.workerPool.length-1];return s._taskCosts[t]=e,s._taskLoad+=e,s})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function go(){let d,t;onmessage=function(r){const o=r.data;switch(o.type){case"init":d=o.decoderConfig,t=new Promise(function(c){d.onModuleLoaded=function(l){c({draco:l})},DracoDecoderModule(d)});break;case"decode":const a=o.buffer,h=o.taskConfig;t.then(c=>{const l=c.draco,u=new l.Decoder;try{const p=e(l,u,new Int8Array(a),h),f=p.attributes.map(m=>m.array.buffer);p.index&&f.push(p.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:p},f)}catch(p){console.error(p),self.postMessage({type:"error",id:o.id,error:p.message})}finally{l.destroy(u)}});break}};function e(r,o,a,h){const c=h.attributeIDs,l=h.attributeTypes;let u,p;const f=o.GetEncodedGeometryType(a);if(f===r.TRIANGULAR_MESH)u=new r.Mesh,p=o.DecodeArrayToMesh(a,a.byteLength,u);else if(f===r.POINT_CLOUD)u=new r.PointCloud,p=o.DecodeArrayToPointCloud(a,a.byteLength,u);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||u.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const m={index:null,attributes:[]};for(const y in c){const x=self[l[y]];let M,w;if(h.useUniqueIDs)w=c[y],M=o.GetAttributeByUniqueId(u,w);else{if(w=o.GetAttributeId(u,r[c[y]]),w===-1)continue;M=o.GetAttribute(u,w)}const b=i(r,o,u,y,x,M);y==="color"&&(b.vertexColorSpace=h.vertexColorSpace),m.attributes.push(b)}return f===r.TRIANGULAR_MESH&&(m.index=s(r,o,u)),r.destroy(u),m}function s(r,o,a){const c=a.num_faces()*3,l=c*4,u=r._malloc(l);o.GetTrianglesUInt32Array(a,l,u);const p=new Uint32Array(r.HEAPF32.buffer,u,c).slice();return r._free(u),{array:p,itemSize:1}}function i(r,o,a,h,c,l){const u=l.num_components(),f=a.num_points()*u,m=f*c.BYTES_PER_ELEMENT,y=n(r,c),x=r._malloc(m);o.GetAttributeDataArrayForAllPoints(a,l,y,m,x);const M=new c(r.HEAPF32.buffer,x,f).slice();return r._free(x),{name:h,array:M,itemSize:u}}function n(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 nn=new Nr,$s=new yo;let Pt="/draco/";const Qs=d=>{const t=typeof d=="string"&&d.length?d:Pt;if(t===Pt){$s.setDecoderPath(Pt);return}Pt=t,$s.setDecoderPath(Pt)};Qs(Pt),nn.setDRACOLoader($s);const rn=d=>new Promise((t,e)=>{nn.parse(d,"",t,e)}),on=d=>{const t=[],e=[],s=[],i=[],n=new Map,r=new Map;let o=0,a=0;const h=(c,l=null)=>{const u={id:i.length,parentId:l,type:c.type,name:c.name,position:c.position.toArray(),rotation:c.rotation.toArray(),scale:c.scale.toArray(),visible:c.visible,geometryIndex:-1,materialIndex:-1,children:[]};if(c.geometry&&c.geometry.isBufferGeometry){let p=n.get(c.geometry.uuid);if(p===void 0){const f=xo(c.geometry);t.push(f),p=o++,n.set(c.geometry.uuid,p)}u.geometryIndex=p}if(c.material){let p=r.get(c.material.uuid);if(p===void 0){const f=bo(c.material);e.push(f),p=a++,r.set(c.material.uuid,p)}u.materialIndex=p}i.push(u),c.children.forEach(p=>{h(p,u.id)})};return h(d),{geometries:t,materials:e,textures:s,hierarchy:i}},xo=d=>{const t={uuid:d.uuid,type:d.type,attributes:{},index:null,attributeTypes:{},indexType:null};for(const e in d.attributes){const s=d.attributes[e],i=new s.array.constructor(s.array.buffer,s.array.byteOffset,s.array.length);t.attributes[e]={array:i,itemSize:s.itemSize,count:s.count,normalized:s.normalized},t.attributeTypes[e]=s.array.constructor.name}if(d.index){const e=new d.index.array.constructor(d.index.array.buffer,d.index.array.byteOffset,d.index.array.length);t.index={array:e,itemSize:d.index.itemSize,count:d.index.count},t.indexType=d.index.array.constructor.name}return t},bo=d=>{var e,s,i,n,r,o,a,h;const t={uuid:d.uuid,type:d.type,color:(e=d.color)==null?void 0:e.getHex(),emissive:(s=d.emissive)==null?void 0:s.getHex(),emissiveIntensity:d.emissiveIntensity,roughness:d.roughness,metalness:d.metalness,opacity:d.opacity,transparent:d.transparent,alphaTest:d.alphaTest,side:d.side,depthTest:d.depthTest,depthWrite:d.depthWrite,wireframe:d.wireframe,vertexColors:d.vertexColors,map:(i=d.map)==null?void 0:i.uuid,normalMap:(n=d.normalMap)==null?void 0:n.uuid,roughnessMap:(r=d.roughnessMap)==null?void 0:r.uuid,metalnessMap:(o=d.metalnessMap)==null?void 0:o.uuid,emissiveMap:(a=d.emissiveMap)==null?void 0:a.uuid};return d.type==="MeshPhongMaterial"&&(t.shininess=d.shininess,t.specular=(h=d.specular)==null?void 0:h.getHex()),d.type,t},Mo=async(d,t)=>{try{Qs(Pt);const e=await rn(d),s={type:"basic",scene:{name:e.scene.name,children:e.scene.children.map(r=>({type:r.type,name:r.name}))}};self.postMessage({type:"progress",data:s});const i=on(e.scene),n=[];i.geometries.forEach(r=>{Object.values(r.attributes).forEach(o=>{o.array&&o.array.buffer&&o.array.buffer.byteLength>0&&n.push(o.array.buffer)}),r.index&&r.index.array&&r.index.array.buffer&&r.index.array.buffer.byteLength>0&&n.push(r.index.array.buffer)}),self.postMessage({type:"complete",data:i},n)}catch(e){self.postMessage({type:"error",error:(e==null?void 0:e.message)||String(e)})}};self.onmessage=async d=>{const{id:t,arrayBuffer:e,dracoPath:s,mode:i}=d.data||{};if(t){if(!e){self.postMessage({id:t,error:"Missing arrayBuffer"});return}try{if(i==="progressive")await Mo(e,n=>{self.postMessage({id:t,type:"progress",progress:n})}),self.postMessage({id:t,type:"done"});else{Qs(s);const n=await rn(e),r=on(n.scene),o=[];r.geometries.forEach(a=>{Object.values(a.attributes).forEach(h=>{h.array&&h.array.buffer&&h.array.buffer.byteLength>0&&o.push(h.array.buffer)}),a.index&&a.index.array&&a.index.array.buffer&&a.index.array.buffer.byteLength>0&&o.push(a.index.array.buffer)}),self.postMessage({id:t,data:r},o)}}catch(n){self.postMessage({id:t,error:(n==null?void 0:n.message)||String(n)})}}}})();
package/dist/hooks.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useGLTFLoader-D01iU8lB.cjs");exports.intersectColor=e.intersectColor;exports.obbObjects=e.obbObjects;exports.useGLTFLoader=e.useGLTFLoader;exports.useObb=e.useObb;exports.useRaycaster=e.useRaycaster;exports.useThreeJs=e.useThreeJs;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useBatchGLTFLoader-CDNvTMtt.cjs"),r=require("./PredictiveLoader-CpRi-ULa.cjs");exports.intersectColor=e.intersectColor;exports.obbObjects=e.obbObjects;exports.useBatchGLTFLoader=e.useBatchGLTFLoader;exports.useObb=e.useObb;exports.useRaycaster=e.useRaycaster;exports.useThreeJs=e.useThreeJs;exports.useGLTFLoader=r.useGLTFLoader;