dsh-cad 0.2.0 → 0.7.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.
- package/README.md +235 -190
- package/README.zh-CN.md +212 -173
- package/lib/client.js +174 -174
- package/lib/client.js.map +3 -3
- package/lib/index.js +6 -2
- package/lib/modeling/ansatz-bridge.js +108 -0
- package/lib/modeling/bin-store.js +15 -1
- package/lib/modeling/constraints.js +85 -0
- package/lib/modeling/document.js +22 -5
- package/lib/modeling/modeling-worker.cjs +350 -235
- package/lib/modeling/occt-adapter.cjs +617 -271
- package/lib/modeling/occt-bridge.cjs +250 -0
- package/lib/modeling/registry.js +219 -0
- package/lib/routes.js +70 -0
- package/lib/tools/cad-constraint.js +335 -0
- package/lib/tools/cad-model.js +595 -58
- package/lib/types/modeling/ansatz-bridge.d.ts +24 -0
- package/lib/types/modeling/bin-store.d.ts +2 -0
- package/lib/types/modeling/client.d.ts +50 -1
- package/lib/types/modeling/constraints.d.ts +63 -0
- package/lib/types/modeling/document.d.ts +11 -1
- package/lib/types/modeling/registry.d.ts +61 -0
- package/lib/types/routes.d.ts +11 -0
- package/lib/types/tools/cad-constraint.d.ts +25 -0
- package/lib/types/tools/cad-model.d.ts +5 -2
- package/package.json +4 -3
- package/cordis.patch.yml +0 -3
- package/lib/modeling/hlr.cjs +0 -328
package/lib/client.js
CHANGED
|
@@ -3,13 +3,13 @@ window.__ModuleLoader__.load({
|
|
|
3
3
|
factory: (require) => {
|
|
4
4
|
var module = { exports: {} };
|
|
5
5
|
var exports = module.exports;
|
|
6
|
-
"use strict";var Kd=Object.create;var Or=Object.defineProperty;var jd=Object.getOwnPropertyDescriptor;var Qd=Object.getOwnPropertyNames;var ef=Object.getPrototypeOf,tf=Object.prototype.hasOwnProperty;var nf=(i,e)=>{for(var t in e)Or(i,t,{get:e[t],enumerable:!0})},lh=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Qd(e))!tf.call(i,s)&&s!==t&&Or(i,s,{get:()=>e[s],enumerable:!(n=jd(e,s))||n.enumerable});return i};var Br=(i,e,t)=>(t=i!=null?Kd(ef(i)):{},lh(e||!i||!i.__esModule?Or(t,"default",{value:i,enumerable:!0}):t,i)),sf=i=>lh(Or({},"__esModule",{value:!0}),i);var my={};nf(my,{apply:()=>py,inject:()=>dy});module.exports=sf(my);var _i=Br(require("react"),1);var It=Br(require("react"),1),St=require("react");var hi={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ui={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Wh=0,$l=1,Xh=2;var xr=1,qh=2,xs=3,Hn=0,qt=1,ln=2,In=0,wi=1,Jl=2,Kl=3,jl=4,Yh=5;var ti=100,Zh=101,$h=102,Jh=103,Kh=104,jh=200,Qh=201,eu=202,tu=203,ga=204,_a=205,nu=206,iu=207,su=208,ru=209,au=210,ou=211,lu=212,cu=213,hu=214,xa=0,ya=1,va=2,Ai=3,ba=4,Ma=5,Sa=6,Ea=7,Ql=0,uu=1,du=2,yn=0,ec=1,tc=2,nc=3,ic=4,sc=5,rc=6,ac=7;var oc=300,di=301,Di=302,ro=303,ao=304,yr=306,Ta=1e3,An=1001,wa=1002,Dt=1003,fu=1004;var vr=1005;var Ft=1006,oo=1007;var fi=1008;var Yt=1009,lc=1010,cc=1011,ys=1012,lo=1013,vn=1014,bn=1015,Ln=1016,co=1017,ho=1018,vs=1020,hc=35902,uc=35899,dc=1021,fc=1022,cn=1023,Rn=1026,pi=1027,pc=1028,uo=1029,mi=1030,fo=1031;var po=1033,br=33776,Mr=33777,Sr=33778,Er=33779,mo=35840,go=35841,_o=35842,xo=35843,yo=36196,vo=37492,bo=37496,Mo=37488,So=37489,Tr=37490,Eo=37491,To=37808,wo=37809,Ao=37810,Co=37811,Ro=37812,Po=37813,Io=37814,Lo=37815,Do=37816,No=37817,Uo=37818,Fo=37819,Oo=37820,Bo=37821,zo=36492,ko=36494,Vo=36495,Ho=36283,Go=36284,wr=36285,Wo=36286;var Ws=2300,Aa=2301,ma=2302,Ul=2303,Fl=2400,Ol=2401,Bl=2402;var pu=3200;var Xo=0,mu=1,Xn="",jt="srgb",Xs="srgb-linear",qs="linear",it="srgb";var Si=7680;var zl=519,gu=512,_u=513,xu=514,qo=515,yu=516,vu=517,Yo=518,bu=519,Ca=35044;var mc="300 es",pn=2e3,ss=2001;function rf(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function af(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function Ys(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Mu(){let i=Ys("canvas");return i.style.display="block",i}var ch={},rs=null;function Zs(...i){let e="THREE."+i.shift();rs?rs("log",e,...i):console.log(e,...i)}function Su(i){let e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){let t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function De(...i){i=Su(i);let e="THREE."+i.shift();if(rs)rs("warn",e,...i);else{let t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function Fe(...i){i=Su(i);let e="THREE."+i.shift();if(rs)rs("error",e,...i);else{let t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function Ti(...i){let e=i.join(" ");e in ch||(ch[e]=!0,De(...i))}function Eu(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}var Tu={[xa]:ya,[va]:Sa,[ba]:Ea,[Ai]:Ma,[ya]:xa,[Sa]:va,[Ea]:ba,[Ma]:Ai},mn=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let s=n[e];if(s!==void 0){let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,e);e.target=null}}},zt=["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"],hh=1234567,ns=Math.PI/180,as=180/Math.PI;function Cn(){let i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(zt[i&255]+zt[i>>8&255]+zt[i>>16&255]+zt[i>>24&255]+"-"+zt[e&255]+zt[e>>8&255]+"-"+zt[e>>16&15|64]+zt[e>>24&255]+"-"+zt[t&63|128]+zt[t>>8&255]+"-"+zt[t>>16&255]+zt[t>>24&255]+zt[n&255]+zt[n>>8&255]+zt[n>>16&255]+zt[n>>24&255]).toLowerCase()}function Ye(i,e,t){return Math.max(e,Math.min(t,i))}function gc(i,e){return(i%e+e)%e}function of(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function lf(i,e,t){return i!==e?(t-i)/(e-i):0}function Vs(i,e,t){return(1-t)*i+t*e}function cf(i,e,t,n){return Vs(i,e,1-Math.exp(-t*n))}function hf(i,e=1){return e-Math.abs(gc(i,e*2)-e)}function uf(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function df(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function ff(i,e){return i+Math.floor(Math.random()*(e-i+1))}function pf(i,e){return i+Math.random()*(e-i)}function mf(i){return i*(.5-Math.random())}function gf(i){i!==void 0&&(hh=i);let e=hh+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function _f(i){return i*ns}function xf(i){return i*as}function yf(i){return(i&i-1)===0&&i!==0}function vf(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function bf(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Mf(i,e,t,n,s){let r=Math.cos,a=Math.sin,o=r(t/2),l=a(t/2),c=r((e+n)/2),h=a((e+n)/2),d=r((e-n)/2),u=a((e-n)/2),f=r((n-e)/2),g=a((n-e)/2);switch(s){case"XYX":i.set(o*h,l*d,l*u,o*c);break;case"YZY":i.set(l*u,o*h,l*d,o*c);break;case"ZXZ":i.set(l*d,l*u,o*h,o*c);break;case"XZX":i.set(o*h,l*g,l*f,o*c);break;case"YXY":i.set(l*f,o*h,l*g,o*c);break;case"ZYZ":i.set(l*g,l*f,o*h,o*c);break;default:De("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function fn(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function st(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}var _c={DEG2RAD:ns,RAD2DEG:as,generateUUID:Cn,clamp:Ye,euclideanModulo:gc,mapLinear:of,inverseLerp:lf,lerp:Vs,damp:cf,pingpong:hf,smoothstep:uf,smootherstep:df,randInt:ff,randFloat:pf,randFloatSpread:mf,seededRandom:gf,degToRad:_f,radToDeg:xf,isPowerOfTwo:yf,ceilPowerOfTwo:vf,floorPowerOfTwo:bf,setQuaternionFromProperEuler:Mf,normalize:st,denormalize:fn},ee=class i{static{i.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Ye(this.x,e.x,t.x),this.y=Ye(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ye(this.x,e,t),this.y=Ye(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ye(n,e,t))}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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Ye(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*s+e.x,this.y=r*s+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ot=class{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,a,o){let l=n[s+0],c=n[s+1],h=n[s+2],d=n[s+3],u=r[a+0],f=r[a+1],g=r[a+2],b=r[a+3];if(d!==b||l!==u||c!==f||h!==g){let m=l*u+c*f+h*g+d*b;m<0&&(u=-u,f=-f,g=-g,b=-b,m=-m);let p=1-o;if(m<.9995){let C=Math.acos(m),w=Math.sin(C);p=Math.sin(p*C)/w,o=Math.sin(o*C)/w,l=l*p+u*o,c=c*p+f*o,h=h*p+g*o,d=d*p+b*o}else{l=l*p+u*o,c=c*p+f*o,h=h*p+g*o,d=d*p+b*o;let C=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=C,c*=C,h*=C,d*=C}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,s,r,a){let o=n[s],l=n[s+1],c=n[s+2],h=n[s+3],d=r[a],u=r[a+1],f=r[a+2],g=r[a+3];return e[t]=o*g+h*d+l*f-c*u,e[t+1]=l*g+h*u+c*d-o*f,e[t+2]=c*g+h*f+o*u-l*d,e[t+3]=h*g-o*d-l*u-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,s){return this._x=e,this._y=t,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(s/2),d=o(r/2),u=l(n/2),f=l(s/2),g=l(r/2);switch(a){case"XYZ":this._x=u*h*d+c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d-u*f*g;break;case"YXZ":this._x=u*h*d+c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d+u*f*g;break;case"ZXY":this._x=u*h*d-c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d-u*f*g;break;case"ZYX":this._x=u*h*d-c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d+u*f*g;break;case"YZX":this._x=u*h*d+c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d-u*f*g;break;case"XZY":this._x=u*h*d-c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d+u*f*g;break;default:De("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],s=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],d=t[10],u=n+o+d;if(u>0){let f=.5/Math.sqrt(u+1);this._w=.25/f,this._x=(h-l)*f,this._y=(r-c)*f,this._z=(a-s)*f}else if(n>o&&n>d){let f=2*Math.sqrt(1+n-o-d);this._w=(h-l)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+c)/f}else if(o>d){let f=2*Math.sqrt(1+o-n-d);this._w=(r-c)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(l+h)/f}else{let f=2*Math.sqrt(1+d-n-o);this._w=(a-s)/f,this._x=(r+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ye(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let s=Math.min(1,t/n);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,s=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+a*o+s*c-r*l,this._y=s*h+a*l+r*o-n*c,this._z=r*h+a*c+n*l-s*o,this._w=a*h-n*o-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){let c=Math.acos(o),h=Math.sin(c);l=Math.sin(l*c)/h,t=Math.sin(t*c)/h,this._x=this._x*l+n*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},R=class i{static{i.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(uh.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(uh.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,s=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*s-o*n),h=2*(o*t-r*s),d=2*(r*n-a*t);return this.x=t+l*c+a*d-o*h,this.y=n+l*h+o*c-r*d,this.z=s+l*d+r*h-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Ye(this.x,e.x,t.x),this.y=Ye(this.y,e.y,t.y),this.z=Ye(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ye(this.x,e,t),this.y=Ye(this.y,e,t),this.z=Ye(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ye(n,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,s=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=s*l-r*o,this.y=r*a-n*l,this.z=n*o-s*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return ol.copy(this).projectOnVector(e),this.sub(ol)}reflect(e){return this.sub(ol.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Ye(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},ol=new R,uh=new Ot,He=class i{static{i.prototype.isMatrix3=!0}constructor(e,t,n,s,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,l,c)}set(e,t,n,s,r,a,o,l,c){let h=this.elements;return h[0]=e,h[1]=s,h[2]=o,h[3]=t,h[4]=r,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],d=n[7],u=n[2],f=n[5],g=n[8],b=s[0],m=s[3],p=s[6],C=s[1],w=s[4],_=s[7],S=s[2],M=s[5],A=s[8];return r[0]=a*b+o*C+l*S,r[3]=a*m+o*w+l*M,r[6]=a*p+o*_+l*A,r[1]=c*b+h*C+d*S,r[4]=c*m+h*w+d*M,r[7]=c*p+h*_+d*A,r[2]=u*b+f*C+g*S,r[5]=u*m+f*w+g*M,r[8]=u*p+f*_+g*A,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-n*r*h+n*o*l+s*r*c-s*a*l}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=h*a-o*c,u=o*l-h*r,f=c*r-a*l,g=t*d+n*u+s*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let b=1/g;return e[0]=d*b,e[1]=(s*c-h*n)*b,e[2]=(o*n-s*a)*b,e[3]=u*b,e[4]=(h*t-s*l)*b,e[5]=(s*r-o*t)*b,e[6]=f*b,e[7]=(n*l-c*t)*b,e[8]=(a*t-n*r)*b,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,s,r,a,o){let l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-s*c,s*l,-s*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return Ti("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(ll.makeScale(e,t)),this}rotate(e){return Ti("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(ll.makeRotation(-e)),this}translate(e,t){return Ti("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(ll.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},ll=new He,dh=new He().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),fh=new He().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Sf(){let i={enabled:!0,workingColorSpace:Xs,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===it&&(s.r=Vn(s.r),s.g=Vn(s.g),s.b=Vn(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===it&&(s.r=is(s.r),s.g=is(s.g),s.b=is(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Xn?qs:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Ti("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Ti("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Xs]:{primaries:e,whitePoint:n,transfer:qs,toXYZ:dh,fromXYZ:fh,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:jt},outputColorSpaceConfig:{drawingBufferColorSpace:jt}},[jt]:{primaries:e,whitePoint:n,transfer:it,toXYZ:dh,fromXYZ:fh,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:jt}}}),i}var je=Sf();function Vn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function is(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var ki,Ra=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{ki===void 0&&(ki=Ys("canvas")),ki.width=e.width,ki.height=e.height;let s=ki.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=ki}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=Ys("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=Vn(r[a]/255)*255;return n.putImageData(s,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Vn(t[n]/255)*255):t[n]=Vn(t[n]);return{data:t,width:e.width,height:e.height}}else return De("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Ef=0,os=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Ef++}),this.uuid=Cn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?r.push(cl(s[a].image)):r.push(cl(s[a]))}else r=cl(s);n.url=r}return t||(e.images[this.uuid]=n),n}};function cl(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?Ra.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(De("Texture: Unable to serialize Texture."),{})}var Tf=0,hl=new R,Xt=class i extends mn{constructor(e=i.DEFAULT_IMAGE,t=i.DEFAULT_MAPPING,n=An,s=An,r=Ft,a=fi,o=cn,l=Yt,c=i.DEFAULT_ANISOTROPY,h=Xn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Tf++}),this.uuid=Cn(),this.name="",this.source=new os(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new ee(0,0),this.repeat=new ee(1,1),this.center=new ee(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new He,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(hl).x}get height(){return this.source.getSize(hl).y}get depth(){return this.source.getSize(hl).z}get image(){return this.source.data}set image(e){this.source.data=e}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(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){De(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){De(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==oc)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ta:e.x=e.x-Math.floor(e.x);break;case An:e.x=e.x<0?0:1;break;case wa:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ta:e.y=e.y-Math.floor(e.y);break;case An:e.y=e.y<0?0:1;break;case wa:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Xt.DEFAULT_IMAGE=null;Xt.DEFAULT_MAPPING=oc;Xt.DEFAULT_ANISOTROPY=1;var gt=class i{static{i.prototype.isVector4=!0}constructor(e=0,t=0,n=0,s=1){this.x=e,this.y=t,this.z=n,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,s,r,l=e.elements,c=l[0],h=l[4],d=l[8],u=l[1],f=l[5],g=l[9],b=l[2],m=l[6],p=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-b)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+b)<.1&&Math.abs(g+m)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let w=(c+1)/2,_=(f+1)/2,S=(p+1)/2,M=(h+u)/4,A=(d+b)/4,y=(g+m)/4;return w>_&&w>S?w<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(w),s=M/n,r=A/n):_>S?_<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(_),n=M/s,r=y/s):S<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(S),n=A/r,s=y/r),this.set(n,s,r,t),this}let C=Math.sqrt((m-g)*(m-g)+(d-b)*(d-b)+(u-h)*(u-h));return Math.abs(C)<.001&&(C=1),this.x=(m-g)/C,this.y=(d-b)/C,this.z=(u-h)/C,this.w=Math.acos((c+f+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Ye(this.x,e.x,t.x),this.y=Ye(this.y,e.y,t.y),this.z=Ye(this.z,e.z,t.z),this.w=Ye(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ye(this.x,e,t),this.y=Ye(this.y,e,t),this.z=Ye(this.z,e,t),this.w=Ye(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ye(n,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Pa=class extends mn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ft,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new gt(0,0,e,t),this.scissorTest=!1,this.viewport=new gt(0,0,e,t),this.textures=[];let s={width:e,height:t,depth:n.depth},r=new Xt(s),a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:Ft,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].image.depth=n,this.textures[s].isData3DTexture!==!0&&(this.textures[s].isArrayTexture=this.textures[s].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let s=Object.assign({},e.textures[t].image);this.textures[t].source=new os(s)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}},Qt=class extends Pa{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},$s=class extends Xt{constructor(e=null,t=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Dt,this.minFilter=Dt,this.wrapR=An,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};var Ia=class extends Xt{constructor(e=null,t=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Dt,this.minFilter=Dt,this.wrapR=An,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var rt=class i{static{i.prototype.isMatrix4=!0}constructor(e,t,n,s,r,a,o,l,c,h,d,u,f,g,b,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,l,c,h,d,u,f,g,b,m)}set(e,t,n,s,r,a,o,l,c,h,d,u,f,g,b,m){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=s,p[1]=r,p[5]=a,p[9]=o,p[13]=l,p[2]=c,p[6]=h,p[10]=d,p[14]=u,p[3]=f,p[7]=g,p[11]=b,p[15]=m,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 i().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,s=1/Vi.setFromMatrixColumn(e,0).length(),r=1/Vi.setFromMatrixColumn(e,1).length(),a=1/Vi.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,s=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),d=Math.sin(r);if(e.order==="XYZ"){let u=a*h,f=a*d,g=o*h,b=o*d;t[0]=l*h,t[4]=-l*d,t[8]=c,t[1]=f+g*c,t[5]=u-b*c,t[9]=-o*l,t[2]=b-u*c,t[6]=g+f*c,t[10]=a*l}else if(e.order==="YXZ"){let u=l*h,f=l*d,g=c*h,b=c*d;t[0]=u+b*o,t[4]=g*o-f,t[8]=a*c,t[1]=a*d,t[5]=a*h,t[9]=-o,t[2]=f*o-g,t[6]=b+u*o,t[10]=a*l}else if(e.order==="ZXY"){let u=l*h,f=l*d,g=c*h,b=c*d;t[0]=u-b*o,t[4]=-a*d,t[8]=g+f*o,t[1]=f+g*o,t[5]=a*h,t[9]=b-u*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){let u=a*h,f=a*d,g=o*h,b=o*d;t[0]=l*h,t[4]=g*c-f,t[8]=u*c+b,t[1]=l*d,t[5]=b*c+u,t[9]=f*c-g,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){let u=a*l,f=a*c,g=o*l,b=o*c;t[0]=l*h,t[4]=b-u*d,t[8]=g*d+f,t[1]=d,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=f*d+g,t[10]=u-b*d}else if(e.order==="XZY"){let u=a*l,f=a*c,g=o*l,b=o*c;t[0]=l*h,t[4]=-d,t[8]=c*h,t[1]=u*d+b,t[5]=a*h,t[9]=f*d-g,t[2]=g*d-f,t[6]=o*h,t[10]=b*d+u}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(wf,e,Af)}lookAt(e,t,n){let s=this.elements;return Jt.subVectors(e,t),Jt.lengthSq()===0&&(Jt.z=1),Jt.normalize(),$n.crossVectors(n,Jt),$n.lengthSq()===0&&(Math.abs(n.z)===1?Jt.x+=1e-4:Jt.z+=1e-4,Jt.normalize(),$n.crossVectors(n,Jt)),$n.normalize(),zr.crossVectors(Jt,$n),s[0]=$n.x,s[4]=zr.x,s[8]=Jt.x,s[1]=$n.y,s[5]=zr.y,s[9]=Jt.y,s[2]=$n.z,s[6]=zr.z,s[10]=Jt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],d=n[5],u=n[9],f=n[13],g=n[2],b=n[6],m=n[10],p=n[14],C=n[3],w=n[7],_=n[11],S=n[15],M=s[0],A=s[4],y=s[8],T=s[12],I=s[1],P=s[5],F=s[9],G=s[13],X=s[2],O=s[6],W=s[10],H=s[14],K=s[3],ie=s[7],ue=s[11],le=s[15];return r[0]=a*M+o*I+l*X+c*K,r[4]=a*A+o*P+l*O+c*ie,r[8]=a*y+o*F+l*W+c*ue,r[12]=a*T+o*G+l*H+c*le,r[1]=h*M+d*I+u*X+f*K,r[5]=h*A+d*P+u*O+f*ie,r[9]=h*y+d*F+u*W+f*ue,r[13]=h*T+d*G+u*H+f*le,r[2]=g*M+b*I+m*X+p*K,r[6]=g*A+b*P+m*O+p*ie,r[10]=g*y+b*F+m*W+p*ue,r[14]=g*T+b*G+m*H+p*le,r[3]=C*M+w*I+_*X+S*K,r[7]=C*A+w*P+_*O+S*ie,r[11]=C*y+w*F+_*W+S*ue,r[15]=C*T+w*G+_*H+S*le,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],s=e[8],r=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],d=e[6],u=e[10],f=e[14],g=e[3],b=e[7],m=e[11],p=e[15],C=l*f-c*u,w=o*f-c*d,_=o*u-l*d,S=a*f-c*h,M=a*u-l*h,A=a*d-o*h;return t*(b*C-m*w+p*_)-n*(g*C-m*S+p*M)+s*(g*w-b*S+p*A)-r*(g*_-b*M+m*A)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],s=e[8],r=e[1],a=e[5],o=e[9],l=e[2],c=e[6],h=e[10];return t*(a*h-o*c)-n*(r*h-o*l)+s*(r*c-a*l)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=e[9],u=e[10],f=e[11],g=e[12],b=e[13],m=e[14],p=e[15],C=t*o-n*a,w=t*l-s*a,_=t*c-r*a,S=n*l-s*o,M=n*c-r*o,A=s*c-r*l,y=h*b-d*g,T=h*m-u*g,I=h*p-f*g,P=d*m-u*b,F=d*p-f*b,G=u*p-f*m,X=C*G-w*F+_*P+S*I-M*T+A*y;if(X===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let O=1/X;return e[0]=(o*G-l*F+c*P)*O,e[1]=(s*F-n*G-r*P)*O,e[2]=(b*A-m*M+p*S)*O,e[3]=(u*M-d*A-f*S)*O,e[4]=(l*I-a*G-c*T)*O,e[5]=(t*G-s*I+r*T)*O,e[6]=(m*_-g*A-p*w)*O,e[7]=(h*A-u*_+f*w)*O,e[8]=(a*F-o*I+c*y)*O,e[9]=(n*I-t*F-r*y)*O,e[10]=(g*M-b*_+p*C)*O,e[11]=(d*_-h*M-f*C)*O,e[12]=(o*T-a*P-l*y)*O,e[13]=(t*P-n*T+s*y)*O,e[14]=(b*w-g*S-m*C)*O,e[15]=(h*S-d*w+u*C)*O,this}scale(e){let t=this.elements,n=e.x,s=e.y,r=e.z;return t[0]*=n,t[4]*=s,t[8]*=r,t[1]*=n,t[5]*=s,t[9]*=r,t[2]*=n,t[6]*=s,t[10]*=r,t[3]*=n,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),s=Math.sin(t),r=1-n,a=e.x,o=e.y,l=e.z,c=r*a,h=r*o;return this.set(c*a+n,c*o-s*l,c*l+s*o,0,c*o+s*l,h*o+n,h*l-s*a,0,c*l-s*o,h*l+s*a,r*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,s,r,a){return this.set(1,n,r,0,e,1,a,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){let s=this.elements,r=t._x,a=t._y,o=t._z,l=t._w,c=r+r,h=a+a,d=o+o,u=r*c,f=r*h,g=r*d,b=a*h,m=a*d,p=o*d,C=l*c,w=l*h,_=l*d,S=n.x,M=n.y,A=n.z;return s[0]=(1-(b+p))*S,s[1]=(f+_)*S,s[2]=(g-w)*S,s[3]=0,s[4]=(f-_)*M,s[5]=(1-(u+p))*M,s[6]=(m+C)*M,s[7]=0,s[8]=(g+w)*A,s[9]=(m-C)*A,s[10]=(1-(u+b))*A,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){let s=this.elements;e.x=s[12],e.y=s[13],e.z=s[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let a=Vi.set(s[0],s[1],s[2]).length(),o=Vi.set(s[4],s[5],s[6]).length(),l=Vi.set(s[8],s[9],s[10]).length();r<0&&(a=-a),hn.copy(this);let c=1/a,h=1/o,d=1/l;return hn.elements[0]*=c,hn.elements[1]*=c,hn.elements[2]*=c,hn.elements[4]*=h,hn.elements[5]*=h,hn.elements[6]*=h,hn.elements[8]*=d,hn.elements[9]*=d,hn.elements[10]*=d,t.setFromRotationMatrix(hn),n.x=a,n.y=o,n.z=l,this}makePerspective(e,t,n,s,r,a,o=pn,l=!1){let c=this.elements,h=2*r/(t-e),d=2*r/(n-s),u=(t+e)/(t-e),f=(n+s)/(n-s),g,b;if(l)g=r/(a-r),b=a*r/(a-r);else if(o===pn)g=-(a+r)/(a-r),b=-2*a*r/(a-r);else if(o===ss)g=-a/(a-r),b=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=d,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=g,c[14]=b,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,s,r,a,o=pn,l=!1){let c=this.elements,h=2/(t-e),d=2/(n-s),u=-(t+e)/(t-e),f=-(n+s)/(n-s),g,b;if(l)g=1/(a-r),b=a/(a-r);else if(o===pn)g=-2/(a-r),b=-(a+r)/(a-r);else if(o===ss)g=-1/(a-r),b=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=u,c[1]=0,c[5]=d,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=g,c[14]=b,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},Vi=new R,hn=new rt,wf=new R(0,0,0),Af=new R(1,1,1),$n=new R,zr=new R,Jt=new R,ph=new rt,mh=new Ot,Gn=class i{constructor(e=0,t=0,n=0,s=i.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let s=e.elements,r=s[0],a=s[4],o=s[8],l=s[1],c=s[5],h=s[9],d=s[2],u=s[6],f=s[10];switch(t){case"XYZ":this._y=Math.asin(Ye(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Ye(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(Ye(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-Ye(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,f),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Ye(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Ye(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,f),this._y=0);break;default:De("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return ph.makeRotationFromQuaternion(e),this.setFromRotationMatrix(ph,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return mh.setFromEuler(this),this.setFromQuaternion(mh,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Gn.DEFAULT_ORDER="XYZ";var ls=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},Cf=0,gh=new R,Hi=new Ot,Fn=new rt,kr=new R,Ls=new R,Rf=new R,Pf=new Ot,_h=new R(1,0,0),xh=new R(0,1,0),yh=new R(0,0,1),vh={type:"added"},If={type:"removed"},Gi={type:"childadded",child:null},ul={type:"childremoved",child:null},Nt=class i extends mn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Cf++}),this.uuid=Cn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=i.DEFAULT_UP.clone();let e=new R,t=new Gn,n=new Ot,s=new R(1,1,1);function r(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new rt},normalMatrix:{value:new He}}),this.matrix=new rt,this.matrixWorld=new rt,this.matrixAutoUpdate=i.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ls,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Hi.setFromAxisAngle(e,t),this.quaternion.multiply(Hi),this}rotateOnWorldAxis(e,t){return Hi.setFromAxisAngle(e,t),this.quaternion.premultiply(Hi),this}rotateX(e){return this.rotateOnAxis(_h,e)}rotateY(e){return this.rotateOnAxis(xh,e)}rotateZ(e){return this.rotateOnAxis(yh,e)}translateOnAxis(e,t){return gh.copy(e).applyQuaternion(this.quaternion),this.position.add(gh.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(_h,e)}translateY(e){return this.translateOnAxis(xh,e)}translateZ(e){return this.translateOnAxis(yh,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Fn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?kr.copy(e):kr.set(e,t,n);let s=this.parent;this.updateWorldMatrix(!0,!1),Ls.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Fn.lookAt(Ls,kr,this.up):Fn.lookAt(kr,Ls,this.up),this.quaternion.setFromRotationMatrix(Fn),s&&(Fn.extractRotation(s.matrixWorld),Hi.setFromRotationMatrix(Fn),this.quaternion.premultiply(Hi.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Fe("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(vh),Gi.child=e,this.dispatchEvent(Gi),Gi.child=null):Fe("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(If),ul.child=e,this.dispatchEvent(ul),ul.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Fn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Fn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Fn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(vh),Gi.child=e,this.dispatchEvent(Gi),Gi.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,s=this.children.length;n<s;n++){let a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ls,e,Rf),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ls,Pf,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,s=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*s,r[13]+=n-r[1]*t-r[5]*n-r[9]*s,r[14]+=s-r[2]*t-r[6]*n-r[10]*s}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let s=this.parent;if(e===!0&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){let r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),this.static!==!1&&(s.static=this.static),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){let d=l[c];r(e.shapes,d)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(r(e.materials,this.material[l]));s.material=o}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){let l=this.animations[o];s.animations.push(r(e.animations,l))}}if(t){let o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),d=a(e.shapes),u=a(e.skeletons),f=a(e.animations),g=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=s,n;function a(o){let l=[];for(let c in o){let h=o[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let s=e.children[n];this.add(s.clone())}return this}};Nt.DEFAULT_UP=new R(0,1,0);Nt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Nt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Ht=class extends Nt{constructor(){super(),this.isGroup=!0,this.type="Group"}},Lf={type:"move"},cs=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ht,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Ht,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new R,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new R),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ht,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new R,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new R,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let s=null,r=null,a=null,o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(let b of e.hand.values()){let m=t.getJointPose(b,n),p=this._getHandJoint(c,b);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==null}let h=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],u=h.position.distanceTo(d.position),f=.02,g=.005;c.inputState.pinching&&u>f+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=f-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Lf)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Ht;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},wu={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},Jn={h:0,s:0,l:0},Vr={h:0,s:0,l:0};function dl(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}var qe=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=jt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,je.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=je.workingColorSpace){return this.r=e,this.g=t,this.b=n,je.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=je.workingColorSpace){if(e=gc(e,1),t=Ye(t,0,1),n=Ye(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=dl(a,r,e+1/3),this.g=dl(a,r,e),this.b=dl(a,r,e-1/3)}return je.colorSpaceToWorking(this,s),this}setStyle(e,t=jt){function n(r){r!==void 0&&parseFloat(r)<1&&De("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:De("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);De("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=jt){let n=wu[e.toLowerCase()];return n!==void 0?this.setHex(n,t):De("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Vn(e.r),this.g=Vn(e.g),this.b=Vn(e.b),this}copyLinearToSRGB(e){return this.r=is(e.r),this.g=is(e.g),this.b=is(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=jt){return je.workingToColorSpace(kt.copy(this),e),Math.round(Ye(kt.r*255,0,255))*65536+Math.round(Ye(kt.g*255,0,255))*256+Math.round(Ye(kt.b*255,0,255))}getHexString(e=jt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=je.workingColorSpace){je.workingToColorSpace(kt.copy(this),t);let n=kt.r,s=kt.g,r=kt.b,a=Math.max(n,s,r),o=Math.min(n,s,r),l,c,h=(o+a)/2;if(o===a)l=0,c=0;else{let d=a-o;switch(c=h<=.5?d/(a+o):d/(2-a-o),a){case n:l=(s-r)/d+(s<r?6:0);break;case s:l=(r-n)/d+2;break;case r:l=(n-s)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=je.workingColorSpace){return je.workingToColorSpace(kt.copy(this),t),e.r=kt.r,e.g=kt.g,e.b=kt.b,e}getStyle(e=jt){je.workingToColorSpace(kt.copy(this),e);let t=kt.r,n=kt.g,s=kt.b;return e!==jt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(Jn),this.setHSL(Jn.h+e,Jn.s+t,Jn.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Jn),e.getHSL(Vr);let n=Vs(Jn.h,Vr.h,t),s=Vs(Jn.s,Vr.s,t),r=Vs(Jn.l,Vr.l,t);return this.setHSL(n,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*s,this.g=r[1]*t+r[4]*n+r[7]*s,this.b=r[2]*t+r[5]*n+r[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},kt=new qe;qe.NAMES=wu;var ni=class extends Nt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Gn,this.environmentIntensity=1,this.environmentRotation=new Gn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},un=new R,On=new R,fl=new R,Bn=new R,Wi=new R,Xi=new R,bh=new R,pl=new R,ml=new R,gl=new R,_l=new gt,xl=new gt,yl=new gt,wn=class i{constructor(e=new R,t=new R,n=new R){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),un.subVectors(e,t),s.cross(un);let r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){un.subVectors(s,t),On.subVectors(n,t),fl.subVectors(e,t);let a=un.dot(un),o=un.dot(On),l=un.dot(fl),c=On.dot(On),h=On.dot(fl),d=a*c-o*o;if(d===0)return r.set(0,0,0),null;let u=1/d,f=(c*l-o*h)*u,g=(a*h-o*l)*u;return r.set(1-f-g,g,f)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,Bn)===null?!1:Bn.x>=0&&Bn.y>=0&&Bn.x+Bn.y<=1}static getInterpolation(e,t,n,s,r,a,o,l){return this.getBarycoord(e,t,n,s,Bn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,Bn.x),l.addScaledVector(a,Bn.y),l.addScaledVector(o,Bn.z),l)}static getInterpolatedAttribute(e,t,n,s,r,a){return _l.setScalar(0),xl.setScalar(0),yl.setScalar(0),_l.fromBufferAttribute(e,t),xl.fromBufferAttribute(e,n),yl.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(_l,r.x),a.addScaledVector(xl,r.y),a.addScaledVector(yl,r.z),a}static isFrontFacing(e,t,n,s){return un.subVectors(n,t),On.subVectors(e,t),un.cross(On).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return un.subVectors(this.c,this.b),On.subVectors(this.a,this.b),un.cross(On).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return i.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return i.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return i.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return i.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return i.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,s=this.b,r=this.c,a,o;Wi.subVectors(s,n),Xi.subVectors(r,n),pl.subVectors(e,n);let l=Wi.dot(pl),c=Xi.dot(pl);if(l<=0&&c<=0)return t.copy(n);ml.subVectors(e,s);let h=Wi.dot(ml),d=Xi.dot(ml);if(h>=0&&d<=h)return t.copy(s);let u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(n).addScaledVector(Wi,a);gl.subVectors(e,r);let f=Wi.dot(gl),g=Xi.dot(gl);if(g>=0&&f<=g)return t.copy(r);let b=f*c-l*g;if(b<=0&&c>=0&&g<=0)return o=c/(c-g),t.copy(n).addScaledVector(Xi,o);let m=h*g-f*d;if(m<=0&&d-h>=0&&f-g>=0)return bh.subVectors(r,s),o=(d-h)/(d-h+(f-g)),t.copy(s).addScaledVector(bh,o);let p=1/(m+b+u);return a=b*p,o=u*p,t.copy(n).addScaledVector(Wi,a).addScaledVector(Xi,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},gn=class{constructor(e=new R(1/0,1/0,1/0),t=new R(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(dn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(dn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=dn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,dn):dn.fromBufferAttribute(r,a),dn.applyMatrix4(e.matrixWorld),this.expandByPoint(dn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Hr.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Hr.copy(n.boundingBox)),Hr.applyMatrix4(e.matrixWorld),this.union(Hr)}let s=e.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,dn),dn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ds),Gr.subVectors(this.max,Ds),qi.subVectors(e.a,Ds),Yi.subVectors(e.b,Ds),Zi.subVectors(e.c,Ds),Kn.subVectors(Yi,qi),jn.subVectors(Zi,Yi),yi.subVectors(qi,Zi);let t=[0,-Kn.z,Kn.y,0,-jn.z,jn.y,0,-yi.z,yi.y,Kn.z,0,-Kn.x,jn.z,0,-jn.x,yi.z,0,-yi.x,-Kn.y,Kn.x,0,-jn.y,jn.x,0,-yi.y,yi.x,0];return!vl(t,qi,Yi,Zi,Gr)||(t=[1,0,0,0,1,0,0,0,1],!vl(t,qi,Yi,Zi,Gr))?!1:(Wr.crossVectors(Kn,jn),t=[Wr.x,Wr.y,Wr.z],vl(t,qi,Yi,Zi,Gr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,dn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(dn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(zn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),zn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),zn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),zn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),zn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),zn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),zn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),zn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(zn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},zn=[new R,new R,new R,new R,new R,new R,new R,new R],dn=new R,Hr=new gn,qi=new R,Yi=new R,Zi=new R,Kn=new R,jn=new R,yi=new R,Ds=new R,Gr=new R,Wr=new R,vi=new R;function vl(i,e,t,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){vi.fromArray(i,r);let o=s.x*Math.abs(vi.x)+s.y*Math.abs(vi.y)+s.z*Math.abs(vi.z),l=e.dot(vi),c=t.dot(vi),h=n.dot(vi);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}var Et=new R,Xr=new ee,Df=0,Tt=class extends mn{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Df++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Ca,this.updateRanges=[],this.gpuType=bn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[e+s]=t.array[n+s];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Xr.fromBufferAttribute(this,t),Xr.applyMatrix3(e),this.setXY(t,Xr.x,Xr.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Et.fromBufferAttribute(this,t),Et.applyMatrix3(e),this.setXYZ(t,Et.x,Et.y,Et.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Et.fromBufferAttribute(this,t),Et.applyMatrix4(e),this.setXYZ(t,Et.x,Et.y,Et.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Et.fromBufferAttribute(this,t),Et.applyNormalMatrix(e),this.setXYZ(t,Et.x,Et.y,Et.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Et.fromBufferAttribute(this,t),Et.transformDirection(e),this.setXYZ(t,Et.x,Et.y,Et.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=fn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=st(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=fn(t,this.array)),t}setX(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=fn(t,this.array)),t}setY(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=fn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=fn(t,this.array)),t}setW(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array),s=st(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array),s=st(s,this.array),r=st(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Ca&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}};var Js=class extends Tt{constructor(e,t,n){super(new Uint16Array(e),t,n)}};var Ks=class extends Tt{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var xt=class extends Tt{constructor(e,t,n){super(new Float32Array(e),t,n)}},Nf=new gn,Ns=new R,bl=new R,Ci=class{constructor(e=new R,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t!==void 0?n.copy(t):Nf.setFromPoints(e).getCenter(n);let s=0;for(let r=0,a=e.length;r<a;r++)s=Math.max(s,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Ns.subVectors(e,this.center);let t=Ns.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(Ns,s/n),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(bl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ns.copy(e.center).add(bl)),this.expandByPoint(Ns.copy(e.center).sub(bl))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Uf=0,rn=new rt,Ml=new Nt,$i=new R,Kt=new gn,Us=new gn,Lt=new R,mt=class i extends mn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Uf++}),this.uuid=Cn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(rf(e)?Ks:Js)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new He().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return rn.makeRotationFromQuaternion(e),this.applyMatrix4(rn),this}rotateX(e){return rn.makeRotationX(e),this.applyMatrix4(rn),this}rotateY(e){return rn.makeRotationY(e),this.applyMatrix4(rn),this}rotateZ(e){return rn.makeRotationZ(e),this.applyMatrix4(rn),this}translate(e,t,n){return rn.makeTranslation(e,t,n),this.applyMatrix4(rn),this}scale(e,t,n){return rn.makeScale(e,t,n),this.applyMatrix4(rn),this}lookAt(e){return Ml.lookAt(e),Ml.updateMatrix(),this.applyMatrix4(Ml.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter($i).negate(),this.translate($i.x,$i.y,$i.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let s=0,r=e.length;s<r;s++){let a=e[s];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new xt(n,3))}else{let n=Math.min(e.length,t.count);for(let s=0;s<n;s++){let r=e[s];t.setXYZ(s,r.x,r.y,r.z||0)}e.length>t.count&&De("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new gn);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Fe("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new R(-1/0,-1/0,-1/0),new R(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n<s;n++){let r=t[n];Kt.setFromBufferAttribute(r),this.morphTargetsRelative?(Lt.addVectors(this.boundingBox.min,Kt.min),this.boundingBox.expandByPoint(Lt),Lt.addVectors(this.boundingBox.max,Kt.max),this.boundingBox.expandByPoint(Lt)):(this.boundingBox.expandByPoint(Kt.min),this.boundingBox.expandByPoint(Kt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Fe('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 Ci);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Fe("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new R,1/0);return}if(e){let n=this.boundingSphere.center;if(Kt.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){let o=t[r];Us.setFromBufferAttribute(o),this.morphTargetsRelative?(Lt.addVectors(Kt.min,Us.min),Kt.expandByPoint(Lt),Lt.addVectors(Kt.max,Us.max),Kt.expandByPoint(Lt)):(Kt.expandByPoint(Us.min),Kt.expandByPoint(Us.max))}Kt.getCenter(n);let s=0;for(let r=0,a=e.count;r<a;r++)Lt.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(Lt));if(t)for(let r=0,a=t.length;r<a;r++){let o=t[r],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)Lt.fromBufferAttribute(o,c),l&&($i.fromBufferAttribute(e,c),Lt.add($i)),s=Math.max(s,n.distanceToSquared(Lt))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&Fe('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Fe("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=t.position,s=t.normal,r=t.uv,a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new Tt(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));let o=[],l=[];for(let y=0;y<n.count;y++)o[y]=new R,l[y]=new R;let c=new R,h=new R,d=new R,u=new ee,f=new ee,g=new ee,b=new R,m=new R;function p(y,T,I){c.fromBufferAttribute(n,y),h.fromBufferAttribute(n,T),d.fromBufferAttribute(n,I),u.fromBufferAttribute(r,y),f.fromBufferAttribute(r,T),g.fromBufferAttribute(r,I),h.sub(c),d.sub(c),f.sub(u),g.sub(u);let P=1/(f.x*g.y-g.x*f.y);isFinite(P)&&(b.copy(h).multiplyScalar(g.y).addScaledVector(d,-f.y).multiplyScalar(P),m.copy(d).multiplyScalar(f.x).addScaledVector(h,-g.x).multiplyScalar(P),o[y].add(b),o[T].add(b),o[I].add(b),l[y].add(m),l[T].add(m),l[I].add(m))}let C=this.groups;C.length===0&&(C=[{start:0,count:e.count}]);for(let y=0,T=C.length;y<T;++y){let I=C[y],P=I.start,F=I.count;for(let G=P,X=P+F;G<X;G+=3)p(e.getX(G+0),e.getX(G+1),e.getX(G+2))}let w=new R,_=new R,S=new R,M=new R;function A(y){S.fromBufferAttribute(s,y),M.copy(S);let T=o[y];w.copy(T),w.sub(S.multiplyScalar(S.dot(T))).normalize(),_.crossVectors(M,T);let P=_.dot(l[y])<0?-1:1;a.setXYZW(y,w.x,w.y,w.z,P)}for(let y=0,T=C.length;y<T;++y){let I=C[y],P=I.start,F=I.count;for(let G=P,X=P+F;G<X;G+=3)A(e.getX(G+0)),A(e.getX(G+1)),A(e.getX(G+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new Tt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let u=0,f=n.count;u<f;u++)n.setXYZ(u,0,0,0);let s=new R,r=new R,a=new R,o=new R,l=new R,c=new R,h=new R,d=new R;if(e)for(let u=0,f=e.count;u<f;u+=3){let g=e.getX(u+0),b=e.getX(u+1),m=e.getX(u+2);s.fromBufferAttribute(t,g),r.fromBufferAttribute(t,b),a.fromBufferAttribute(t,m),h.subVectors(a,r),d.subVectors(s,r),h.cross(d),o.fromBufferAttribute(n,g),l.fromBufferAttribute(n,b),c.fromBufferAttribute(n,m),o.add(h),l.add(h),c.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(b,l.x,l.y,l.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let u=0,f=t.count;u<f;u+=3)s.fromBufferAttribute(t,u+0),r.fromBufferAttribute(t,u+1),a.fromBufferAttribute(t,u+2),h.subVectors(a,r),d.subVectors(s,r),h.cross(d),n.setXYZ(u+0,h.x,h.y,h.z),n.setXYZ(u+1,h.x,h.y,h.z),n.setXYZ(u+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Lt.fromBufferAttribute(e,t),Lt.normalize(),e.setXYZ(t,Lt.x,Lt.y,Lt.z)}toNonIndexed(){function e(o,l){let c=o.array,h=o.itemSize,d=o.normalized,u=new c.constructor(l.length*h),f=0,g=0;for(let b=0,m=l.length;b<m;b++){o.isInterleavedBufferAttribute?f=l[b]*o.data.stride+o.offset:f=l[b]*h;for(let p=0;p<h;p++)u[g++]=c[f++]}return new Tt(u,h,d)}if(this.index===null)return De("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new i,n=this.index.array,s=this.attributes;for(let o in s){let l=s[o],c=e(l,n);t.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let l=[],c=r[o];for(let h=0,d=c.length;h<d;h++){let u=c[h],f=e(u,n);l.push(f)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let o=0,l=a.length;o<l;o++){let c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let l in n){let c=n[l];e.data.attributes[l]=c.toJSON(e.data)}let s={},r=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],h=[];for(let d=0,u=c.length;d<u;d++){let f=c[d];h.push(f.toJSON(e.data))}h.length>0&&(s[l]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let s=e.attributes;for(let c in s){let h=s[c];this.setAttribute(c,h.clone(t))}let r=e.morphAttributes;for(let c in r){let h=[],d=r[c];for(let u=0,f=d.length;u<f;u++)h.push(d[u].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let c=0,h=a.length;c<h;c++){let d=a[c];this.addGroup(d.start,d.count,d.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}},La=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Ca,this.updateRanges=[],this.version=0,this.uuid=Cn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let s=0,r=this.stride;s<r;s++)this.array[e+s]=t.array[n+s];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Cn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Cn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.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}}},Wt=new R,js=class i{constructor(e,t,n,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Wt.fromBufferAttribute(this,t),Wt.applyMatrix4(e),this.setXYZ(t,Wt.x,Wt.y,Wt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Wt.fromBufferAttribute(this,t),Wt.applyNormalMatrix(e),this.setXYZ(t,Wt.x,Wt.y,Wt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Wt.fromBufferAttribute(this,t),Wt.transformDirection(e),this.setXYZ(t,Wt.x,Wt.y,Wt.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=fn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=st(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=fn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=fn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=fn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=fn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),n=st(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),n=st(n,this.array),s=st(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),n=st(n,this.array),s=st(s,this.array),r=st(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Zs("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return new Tt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new i(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Zs("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},Ff=0,Pn=class extends mn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ff++}),this.uuid=Cn(),this.name="",this.type="Material",this.blending=wi,this.side=Hn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ga,this.blendDst=_a,this.blendEquation=ti,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new qe(0,0,0),this.blendAlpha=0,this.depthFunc=Ai,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=zl,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Si,this.stencilZFail=Si,this.stencilZPass=Si,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(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){De(`Material: parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){De(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==wi&&(n.blending=this.blending),this.side!==Hn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==ga&&(n.blendSrc=this.blendSrc),this.blendDst!==_a&&(n.blendDst=this.blendDst),this.blendEquation!==ti&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Ai&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==zl&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Si&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Si&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Si&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){let a=[];for(let o in r){let l=r[o];delete l.metadata,a.push(l)}return a}if(t){let r=s(e.textures),a=s(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new qe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new ee().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new ee().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let s=t.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},hs=class extends Pn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new qe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Ji,Fs=new R,Ki=new R,ji=new R,Qi=new ee,Os=new ee,Au=new rt,qr=new R,Bs=new R,Yr=new R,Mh=new ee,Sl=new ee,Sh=new ee,Qs=class extends Nt{constructor(e=new hs){if(super(),this.isSprite=!0,this.type="Sprite",Ji===void 0){Ji=new mt;let t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new La(t,5);Ji.setIndex([0,1,2,0,2,3]),Ji.setAttribute("position",new js(n,3,0,!1)),Ji.setAttribute("uv",new js(n,2,3,!1))}this.geometry=Ji,this.material=e,this.center=new ee(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Fe('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ki.setFromMatrixScale(this.matrixWorld),Au.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),ji.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ki.multiplyScalar(-ji.z);let n=this.material.rotation,s,r;n!==0&&(r=Math.cos(n),s=Math.sin(n));let a=this.center;Zr(qr.set(-.5,-.5,0),ji,a,Ki,s,r),Zr(Bs.set(.5,-.5,0),ji,a,Ki,s,r),Zr(Yr.set(.5,.5,0),ji,a,Ki,s,r),Mh.set(0,0),Sl.set(1,0),Sh.set(1,1);let o=e.ray.intersectTriangle(qr,Bs,Yr,!1,Fs);if(o===null&&(Zr(Bs.set(-.5,.5,0),ji,a,Ki,s,r),Sl.set(0,1),o=e.ray.intersectTriangle(qr,Yr,Bs,!1,Fs),o===null))return;let l=e.ray.origin.distanceTo(Fs);l<e.near||l>e.far||t.push({distance:l,point:Fs.clone(),uv:wn.getInterpolation(Fs,qr,Bs,Yr,Mh,Sl,Sh,new ee),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};function Zr(i,e,t,n,s,r){Qi.subVectors(i,t).addScalar(.5).multiply(n),s!==void 0?(Os.x=r*Qi.x-s*Qi.y,Os.y=s*Qi.x+r*Qi.y):Os.copy(Qi),i.copy(e),i.x+=Os.x,i.y+=Os.y,i.applyMatrix4(Au)}var kn=new R,El=new R,$r=new R,Qn=new R,Tl=new R,Jr=new R,wl=new R,ii=class{constructor(e=new R,t=new R(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,kn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=kn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(kn.copy(this.origin).addScaledVector(this.direction,t),kn.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){El.copy(e).add(t).multiplyScalar(.5),$r.copy(t).sub(e).normalize(),Qn.copy(this.origin).sub(El);let r=e.distanceTo(t)*.5,a=-this.direction.dot($r),o=Qn.dot(this.direction),l=-Qn.dot($r),c=Qn.lengthSq(),h=Math.abs(1-a*a),d,u,f,g;if(h>0)if(d=a*l-o,u=a*o-l,g=r*h,d>=0)if(u>=-g)if(u<=g){let b=1/h;d*=b,u*=b,f=d*(d+a*u+2*o)+u*(a*d+u+2*l)+c}else u=r,d=Math.max(0,-(a*u+o)),f=-d*d+u*(u+2*l)+c;else u=-r,d=Math.max(0,-(a*u+o)),f=-d*d+u*(u+2*l)+c;else u<=-g?(d=Math.max(0,-(-a*r+o)),u=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+u*(u+2*l)+c):u<=g?(d=0,u=Math.min(Math.max(-r,-l),r),f=u*(u+2*l)+c):(d=Math.max(0,-(a*r+o)),u=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+u*(u+2*l)+c);else u=a>0?-r:r,d=Math.max(0,-(a*u+o)),f=-d*d+u*(u+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(El).addScaledVector($r,u),f}intersectSphere(e,t){kn.subVectors(e.center,this.origin);let n=kn.dot(this.direction),s=kn.dot(kn)-n*n,r=e.radius*e.radius;if(s>r)return null;let a=Math.sqrt(r-s),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,r,a,o,l,c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return c>=0?(n=(e.min.x-u.x)*c,s=(e.max.x-u.x)*c):(n=(e.max.x-u.x)*c,s=(e.min.x-u.x)*c),h>=0?(r=(e.min.y-u.y)*h,a=(e.max.y-u.y)*h):(r=(e.max.y-u.y)*h,a=(e.min.y-u.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),d>=0?(o=(e.min.z-u.z)*d,l=(e.max.z-u.z)*d):(o=(e.max.z-u.z)*d,l=(e.min.z-u.z)*d),n>l||o>s)||((o>n||n!==n)&&(n=o),(l<s||s!==s)&&(s=l),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,kn)!==null}intersectTriangle(e,t,n,s,r){Tl.subVectors(t,e),Jr.subVectors(n,e),wl.crossVectors(Tl,Jr);let a=this.direction.dot(wl),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Qn.subVectors(this.origin,e);let l=o*this.direction.dot(Jr.crossVectors(Qn,Jr));if(l<0)return null;let c=o*this.direction.dot(Tl.cross(Qn));if(c<0||l+c>a)return null;let h=-o*Qn.dot(wl);return h<0?null:this.at(h/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},on=class extends Pn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new qe(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 Gn,this.combine=Ql,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Eh=new rt,bi=new ii,Kr=new Ci,Th=new R,jr=new R,Qr=new R,ea=new R,Al=new R,ta=new R,wh=new R,na=new R,wt=class extends Nt{constructor(e=new mt,t=new on){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){let o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){let n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(s,e);let o=this.morphTargetInfluences;if(r&&o){ta.set(0,0,0);for(let l=0,c=r.length;l<c;l++){let h=o[l],d=r[l];h!==0&&(Al.fromBufferAttribute(d,e),a?ta.addScaledVector(Al,h):ta.addScaledVector(Al.sub(t),h))}t.add(ta)}return t}raycast(e,t){let n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Kr.copy(n.boundingSphere),Kr.applyMatrix4(r),bi.copy(e.ray).recast(e.near),!(Kr.containsPoint(bi.origin)===!1&&(bi.intersectSphere(Kr,Th)===null||bi.origin.distanceToSquared(Th)>(e.far-e.near)**2))&&(Eh.copy(r).invert(),bi.copy(e.ray).applyMatrix4(Eh),!(n.boundingBox!==null&&bi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,bi)))}_computeIntersections(e,t,n){let s,r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,b=u.length;g<b;g++){let m=u[g],p=a[m.materialIndex],C=Math.max(m.start,f.start),w=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let _=C,S=w;_<S;_+=3){let M=o.getX(_),A=o.getX(_+1),y=o.getX(_+2);s=ia(this,p,e,n,c,h,d,M,A,y),s&&(s.faceIndex=Math.floor(_/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{let g=Math.max(0,f.start),b=Math.min(o.count,f.start+f.count);for(let m=g,p=b;m<p;m+=3){let C=o.getX(m),w=o.getX(m+1),_=o.getX(m+2);s=ia(this,a,e,n,c,h,d,C,w,_),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}else if(l!==void 0)if(Array.isArray(a))for(let g=0,b=u.length;g<b;g++){let m=u[g],p=a[m.materialIndex],C=Math.max(m.start,f.start),w=Math.min(l.count,Math.min(m.start+m.count,f.start+f.count));for(let _=C,S=w;_<S;_+=3){let M=_,A=_+1,y=_+2;s=ia(this,p,e,n,c,h,d,M,A,y),s&&(s.faceIndex=Math.floor(_/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{let g=Math.max(0,f.start),b=Math.min(l.count,f.start+f.count);for(let m=g,p=b;m<p;m+=3){let C=m,w=m+1,_=m+2;s=ia(this,a,e,n,c,h,d,C,w,_),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}}};function Of(i,e,t,n,s,r,a,o){let l;if(e.side===qt?l=n.intersectTriangle(a,r,s,!0,o):l=n.intersectTriangle(s,r,a,e.side===Hn,o),l===null)return null;na.copy(o),na.applyMatrix4(i.matrixWorld);let c=t.ray.origin.distanceTo(na);return c<t.near||c>t.far?null:{distance:c,point:na.clone(),object:i}}function ia(i,e,t,n,s,r,a,o,l,c){i.getVertexPosition(o,jr),i.getVertexPosition(l,Qr),i.getVertexPosition(c,ea);let h=Of(i,e,t,n,jr,Qr,ea,wh);if(h){let d=new R;wn.getBarycoord(wh,jr,Qr,ea,d),s&&(h.uv=wn.getInterpolatedAttribute(s,o,l,c,d,new ee)),r&&(h.uv1=wn.getInterpolatedAttribute(r,o,l,c,d,new ee)),a&&(h.normal=wn.getInterpolatedAttribute(a,o,l,c,d,new R),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let u={a:o,b:l,c,normal:new R,materialIndex:0};wn.getNormal(jr,Qr,ea,u.normal),h.face=u,h.barycoord=d}return h}var Da=class extends Xt{constructor(e=null,t=1,n=1,s,r,a,o,l,c=Dt,h=Dt,d,u){super(null,a,o,l,c,h,s,r,d,u),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Cl=new R,Bf=new R,zf=new He,an=class{constructor(e=new R(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let s=Cl.subVectors(n,t).cross(Bf.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let s=e.delta(Cl),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||zf.getNormalMatrix(e),s=this.coplanarPoint(Cl).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},Mi=new Ci,kf=new ee(.5,.5),sa=new R,us=class{constructor(e=new an,t=new an,n=new an,s=new an,r=new an,a=new an){this.planes=[e,t,n,s,r,a]}set(e,t,n,s,r,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=pn,n=!1){let s=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],h=r[4],d=r[5],u=r[6],f=r[7],g=r[8],b=r[9],m=r[10],p=r[11],C=r[12],w=r[13],_=r[14],S=r[15];if(s[0].setComponents(c-a,f-h,p-g,S-C).normalize(),s[1].setComponents(c+a,f+h,p+g,S+C).normalize(),s[2].setComponents(c+o,f+d,p+b,S+w).normalize(),s[3].setComponents(c-o,f-d,p-b,S-w).normalize(),n)s[4].setComponents(l,u,m,_).normalize(),s[5].setComponents(c-l,f-u,p-m,S-_).normalize();else if(s[4].setComponents(c-l,f-u,p-m,S-_).normalize(),t===pn)s[5].setComponents(c+l,f+u,p+m,S+_).normalize();else if(t===ss)s[5].setComponents(l,u,m,_).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Mi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Mi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Mi)}intersectsSprite(e){Mi.center.set(0,0,0);let t=kf.distanceTo(e.center);return Mi.radius=.7071067811865476+t,Mi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Mi)}intersectsSphere(e){let t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let s=t[n];if(sa.x=s.normal.x>0?e.max.x:e.min.x,sa.y=s.normal.y>0?e.max.y:e.min.y,sa.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(sa)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};var _n=class extends Pn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new qe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},Na=new R,Ua=new R,Ah=new rt,zs=new ii,ra=new Ci,Rl=new R,Ch=new R,Fa=class extends Nt{constructor(e=new mt,t=new _n){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let s=1,r=t.count;s<r;s++)Na.fromBufferAttribute(t,s-1),Ua.fromBufferAttribute(t,s),n[s]=n[s-1],n[s]+=Na.distanceTo(Ua);e.setAttribute("lineDistance",new xt(n,1))}else De("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let n=this.geometry,s=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),ra.copy(n.boundingSphere),ra.applyMatrix4(s),ra.radius+=r,e.ray.intersectsSphere(ra)===!1)return;Ah.copy(s).invert(),zs.copy(e.ray).applyMatrix4(Ah);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=n.index,u=n.attributes.position;if(h!==null){let f=Math.max(0,a.start),g=Math.min(h.count,a.start+a.count);for(let b=f,m=g-1;b<m;b+=c){let p=h.getX(b),C=h.getX(b+1),w=aa(this,e,zs,l,p,C,b);w&&t.push(w)}if(this.isLineLoop){let b=h.getX(g-1),m=h.getX(f),p=aa(this,e,zs,l,b,m,g-1);p&&t.push(p)}}else{let f=Math.max(0,a.start),g=Math.min(u.count,a.start+a.count);for(let b=f,m=g-1;b<m;b+=c){let p=aa(this,e,zs,l,b,b+1,b);p&&t.push(p)}if(this.isLineLoop){let b=aa(this,e,zs,l,g-1,f,g-1);b&&t.push(b)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){let o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}};function aa(i,e,t,n,s,r,a){let o=i.geometry.attributes.position;if(Na.fromBufferAttribute(o,s),Ua.fromBufferAttribute(o,r),t.distanceSqToSegment(Na,Ua,Rl,Ch)>n)return;Rl.applyMatrix4(i.matrixWorld);let c=e.ray.origin.distanceTo(Rl);if(!(c<e.near||c>e.far))return{distance:c,point:Ch.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}var Rh=new R,Ph=new R,xn=class extends Fa{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let s=0,r=t.count;s<r;s+=2)Rh.fromBufferAttribute(t,s),Ph.fromBufferAttribute(t,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+Rh.distanceTo(Ph);e.setAttribute("lineDistance",new xt(n,1))}else De("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var er=class extends Xt{constructor(e=[],t=di,n,s,r,a,o,l,c,h){super(e,t,n,s,r,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Ri=class extends Xt{constructor(e,t,n,s,r,a,o,l,c){super(e,t,n,s,r,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}};var Wn=class extends Xt{constructor(e,t,n=vn,s,r,a,o=Dt,l=Dt,c,h=Rn,d=1){if(h!==Rn&&h!==pi)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let u={width:e,height:t,depth:d};super(u,s,r,a,o,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new os(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},Oa=class extends Wn{constructor(e,t=vn,n=di,s,r,a=Dt,o=Dt,l,c=Rn){let h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,t,n,s,r,a,o,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},tr=class extends Xt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},ds=class i extends mt{constructor(e=1,t=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};let o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);let l=[],c=[],h=[],d=[],u=0,f=0;g("z","y","x",-1,-1,n,t,e,a,r,0),g("z","y","x",1,-1,n,t,-e,a,r,1),g("x","z","y",1,1,e,n,t,s,a,2),g("x","z","y",1,-1,e,n,-t,s,a,3),g("x","y","z",1,-1,e,t,n,s,r,4),g("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new xt(c,3)),this.setAttribute("normal",new xt(h,3)),this.setAttribute("uv",new xt(d,2));function g(b,m,p,C,w,_,S,M,A,y,T){let I=_/A,P=S/y,F=_/2,G=S/2,X=M/2,O=A+1,W=y+1,H=0,K=0,ie=new R;for(let ue=0;ue<W;ue++){let le=ue*P-G;for(let Me=0;Me<O;Me++){let $e=Me*I-F;ie[b]=$e*C,ie[m]=le*w,ie[p]=X,c.push(ie.x,ie.y,ie.z),ie[b]=0,ie[m]=0,ie[p]=M>0?1:-1,h.push(ie.x,ie.y,ie.z),d.push(Me/A),d.push(1-ue/y),H+=1}}for(let ue=0;ue<y;ue++)for(let le=0;le<A;le++){let Me=u+le+O*ue,$e=u+le+O*(ue+1),ct=u+(le+1)+O*(ue+1),Qe=u+(le+1)+O*ue;l.push(Me,$e,Qe),l.push($e,ct,Qe),K+=6}o.addGroup(f,K,T),f+=K,u+=H}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};var oa=new R,la=new R,Pl=new R,ca=new wn,nr=class extends mt{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){let s=Math.pow(10,4),r=Math.cos(ns*t),a=e.getIndex(),o=e.getAttribute("position"),l=a?a.count:o.count,c=[0,0,0],h=["a","b","c"],d=new Array(3),u={},f=[];for(let g=0;g<l;g+=3){a?(c[0]=a.getX(g),c[1]=a.getX(g+1),c[2]=a.getX(g+2)):(c[0]=g,c[1]=g+1,c[2]=g+2);let{a:b,b:m,c:p}=ca;if(b.fromBufferAttribute(o,c[0]),m.fromBufferAttribute(o,c[1]),p.fromBufferAttribute(o,c[2]),ca.getNormal(Pl),d[0]=`${Math.round(b.x*s)},${Math.round(b.y*s)},${Math.round(b.z*s)}`,d[1]=`${Math.round(m.x*s)},${Math.round(m.y*s)},${Math.round(m.z*s)}`,d[2]=`${Math.round(p.x*s)},${Math.round(p.y*s)},${Math.round(p.z*s)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let C=0;C<3;C++){let w=(C+1)%3,_=d[C],S=d[w],M=ca[h[C]],A=ca[h[w]],y=`${_}_${S}`,T=`${S}_${_}`;T in u&&u[T]?(Pl.dot(u[T].normal)<=r&&(f.push(M.x,M.y,M.z),f.push(A.x,A.y,A.z)),u[T]=null):y in u||(u[y]={index0:c[C],index1:c[w],normal:Pl.clone()})}}for(let g in u)if(u[g]){let{index0:b,index1:m}=u[g];oa.fromBufferAttribute(o,b),la.fromBufferAttribute(o,m),f.push(oa.x,oa.y,oa.z),f.push(la.x,la.y,la.z)}this.setAttribute("position",new xt(f,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},en=class{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){De("Curve: .getPoint() not implemented.")}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],n,s=this.getPoint(0),r=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),r+=n.distanceTo(s),t.push(r),s=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let n=this.getLengths(),s=0,r=n.length,a;t?a=t:a=e*n[r-1];let o=0,l=r-1,c;for(;o<=l;)if(s=Math.floor(o+(l-o)/2),c=n[s]-a,c<0)o=s+1;else if(c>0)l=s-1;else{l=s;break}if(s=l,n[s]===a)return s/(r-1);let h=n[s],u=n[s+1]-h,f=(a-h)/u;return(s+f)/(r-1)}getTangent(e,t){let s=e-1e-4,r=e+1e-4;s<0&&(s=0),r>1&&(r=1);let a=this.getPoint(s),o=this.getPoint(r),l=t||(a.isVector2?new ee:new R);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new R,s=[],r=[],a=[],o=new R,l=new rt;for(let f=0;f<=e;f++){let g=f/e;s[f]=this.getTangentAt(g,new R)}r[0]=new R,a[0]=new R;let c=Number.MAX_VALUE,h=Math.abs(s[0].x),d=Math.abs(s[0].y),u=Math.abs(s[0].z);h<=c&&(c=h,n.set(1,0,0)),d<=c&&(c=d,n.set(0,1,0)),u<=c&&n.set(0,0,1),o.crossVectors(s[0],n).normalize(),r[0].crossVectors(s[0],o),a[0].crossVectors(s[0],r[0]);for(let f=1;f<=e;f++){if(r[f]=r[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(s[f-1],s[f]),o.length()>Number.EPSILON){o.normalize();let g=Math.acos(Ye(s[f-1].dot(s[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(o,g))}a[f].crossVectors(s[f],r[f])}if(t===!0){let f=Math.acos(Ye(r[0].dot(r[e]),-1,1));f/=e,s[0].dot(o.crossVectors(r[0],r[e]))>0&&(f=-f);for(let g=1;g<=e;g++)r[g].applyMatrix4(l.makeRotationAxis(s[g],f*g)),a[g].crossVectors(s[g],r[g])}return{tangents:s,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},fs=class extends en{constructor(e=0,t=0,n=1,s=1,r=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new ee){let n=t,s=Math.PI*2,r=this.aEndAngle-this.aStartAngle,a=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=s;for(;r>s;)r-=s;r<Number.EPSILON&&(a?r=0:r=s),this.aClockwise===!0&&!a&&(r===s?r=-s:r=r-s);let o=this.aStartAngle+e*r,l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let h=Math.cos(this.aRotation),d=Math.sin(this.aRotation),u=l-this.aX,f=c-this.aY;l=u*h-f*d+this.aX,c=u*d+f*h+this.aY}return n.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},Ba=class extends fs{constructor(e,t,n,s,r,a){super(e,t,n,n,s,r,a),this.isArcCurve=!0,this.type="ArcCurve"}};function xc(){let i=0,e=0,t=0,n=0;function s(r,a,o,l){i=r,e=o,t=-3*r+3*a-2*o-l,n=2*r-2*a+o+l}return{initCatmullRom:function(r,a,o,l,c){s(a,o,c*(o-r),c*(l-a))},initNonuniformCatmullRom:function(r,a,o,l,c,h,d){let u=(a-r)/c-(o-r)/(c+h)+(o-a)/h,f=(o-a)/h-(l-a)/(h+d)+(l-o)/d;u*=h,f*=h,s(a,o,u,f)},calc:function(r){let a=r*r,o=a*r;return i+e*r+t*a+n*o}}}var Ih=new R,Lh=new R,Il=new xc,Ll=new xc,Dl=new xc,za=class extends en{constructor(e=[],t=!1,n="centripetal",s=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=s}getPoint(e,t=new R){let n=t,s=this.points,r=s.length,a=(r-(this.closed?0:1))*e,o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/r)+1)*r:l===0&&o===r-1&&(o=r-2,l=1);let c,h;this.closed||o>0?c=s[(o-1)%r]:(Lh.subVectors(s[0],s[1]).add(s[0]),c=Lh);let d=s[o%r],u=s[(o+1)%r];if(this.closed||o+2<r?h=s[(o+2)%r]:(Ih.subVectors(s[r-1],s[r-2]).add(s[r-1]),h=Ih),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,g=Math.pow(c.distanceToSquared(d),f),b=Math.pow(d.distanceToSquared(u),f),m=Math.pow(u.distanceToSquared(h),f);b<1e-4&&(b=1),g<1e-4&&(g=b),m<1e-4&&(m=b),Il.initNonuniformCatmullRom(c.x,d.x,u.x,h.x,g,b,m),Ll.initNonuniformCatmullRom(c.y,d.y,u.y,h.y,g,b,m),Dl.initNonuniformCatmullRom(c.z,d.z,u.z,h.z,g,b,m)}else this.curveType==="catmullrom"&&(Il.initCatmullRom(c.x,d.x,u.x,h.x,this.tension),Ll.initCatmullRom(c.y,d.y,u.y,h.y,this.tension),Dl.initCatmullRom(c.z,d.z,u.z,h.z,this.tension));return n.set(Il.calc(l),Ll.calc(l),Dl.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let s=e.points[t];this.points.push(s.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let s=this.points[t];e.points.push(s.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let s=e.points[t];this.points.push(new R().fromArray(s))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function Dh(i,e,t,n,s){let r=(n-e)*.5,a=(s-t)*.5,o=i*i,l=i*o;return(2*t-2*n+r+a)*l+(-3*t+3*n-2*r-a)*o+r*i+t}function Vf(i,e){let t=1-i;return t*t*e}function Hf(i,e){return 2*(1-i)*i*e}function Gf(i,e){return i*i*e}function Hs(i,e,t,n){return Vf(i,e)+Hf(i,t)+Gf(i,n)}function Wf(i,e){let t=1-i;return t*t*t*e}function Xf(i,e){let t=1-i;return 3*t*t*i*e}function qf(i,e){return 3*(1-i)*i*i*e}function Yf(i,e){return i*i*i*e}function Gs(i,e,t,n,s){return Wf(i,e)+Xf(i,t)+qf(i,n)+Yf(i,s)}var ir=class extends en{constructor(e=new ee,t=new ee,n=new ee,s=new ee){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=s}getPoint(e,t=new ee){let n=t,s=this.v0,r=this.v1,a=this.v2,o=this.v3;return n.set(Gs(e,s.x,r.x,a.x,o.x),Gs(e,s.y,r.y,a.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ka=class extends en{constructor(e=new R,t=new R,n=new R,s=new R){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=s}getPoint(e,t=new R){let n=t,s=this.v0,r=this.v1,a=this.v2,o=this.v3;return n.set(Gs(e,s.x,r.x,a.x,o.x),Gs(e,s.y,r.y,a.y,o.y),Gs(e,s.z,r.z,a.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},sr=class extends en{constructor(e=new ee,t=new ee){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new ee){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new ee){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Va=class extends en{constructor(e=new R,t=new R){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new R){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new R){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},rr=class extends en{constructor(e=new ee,t=new ee,n=new ee){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new ee){let n=t,s=this.v0,r=this.v1,a=this.v2;return n.set(Hs(e,s.x,r.x,a.x),Hs(e,s.y,r.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Ha=class extends en{constructor(e=new R,t=new R,n=new R){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new R){let n=t,s=this.v0,r=this.v1,a=this.v2;return n.set(Hs(e,s.x,r.x,a.x),Hs(e,s.y,r.y,a.y),Hs(e,s.z,r.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ar=class extends en{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new ee){let n=t,s=this.points,r=(s.length-1)*e,a=Math.floor(r),o=r-a,l=s[a===0?a:a-1],c=s[a],h=s[a>s.length-2?s.length-1:a+1],d=s[a>s.length-3?s.length-1:a+2];return n.set(Dh(o,l.x,c.x,h.x,d.x),Dh(o,l.y,c.y,h.y,d.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let s=e.points[t];this.points.push(s.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let s=this.points[t];e.points.push(s.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let s=e.points[t];this.points.push(new ee().fromArray(s))}return this}},kl=Object.freeze({__proto__:null,ArcCurve:Ba,CatmullRomCurve3:za,CubicBezierCurve:ir,CubicBezierCurve3:ka,EllipseCurve:fs,LineCurve:sr,LineCurve3:Va,QuadraticBezierCurve:rr,QuadraticBezierCurve3:Ha,SplineCurve:ar}),Ga=class extends en{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new kl[n](t,e))}return this}getPoint(e,t){let n=e*this.getLength(),s=this.getCurveLengths(),r=0;for(;r<s.length;){if(s[r]>=n){let a=s[r]-n,o=this.curves[r],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}r++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,s=this.curves.length;n<s;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],n;for(let s=0,r=this.curves;s<r.length;s++){let a=r[s],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,l=a.getPoints(o);for(let c=0;c<l.length;c++){let h=l[c];n&&n.equals(h)||(t.push(h),n=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let s=e.curves[t];this.curves.push(s.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let s=this.curves[t];e.curves.push(s.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let s=e.curves[t];this.curves.push(new kl[s.type]().fromJSON(s))}return this}},Pi=class extends Ga{constructor(e){super(),this.type="Path",this.currentPoint=new ee,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let n=new sr(this.currentPoint.clone(),new ee(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,s){let r=new rr(this.currentPoint.clone(),new ee(e,t),new ee(n,s));return this.curves.push(r),this.currentPoint.set(n,s),this}bezierCurveTo(e,t,n,s,r,a){let o=new ir(this.currentPoint.clone(),new ee(e,t),new ee(n,s),new ee(r,a));return this.curves.push(o),this.currentPoint.set(r,a),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),n=new ar(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,s,r,a){let o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,n,s,r,a),this}absarc(e,t,n,s,r,a){return this.absellipse(e,t,n,n,s,r,a),this}ellipse(e,t,n,s,r,a,o,l){let c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+c,t+h,n,s,r,a,o,l),this}absellipse(e,t,n,s,r,a,o,l){let c=new fs(e,t,n,s,r,a,o,l);if(this.curves.length>0){let d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);let h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},ps=class extends Pi{constructor(e){super(e),this.uuid=Cn(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,s=this.holes.length;n<s;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let s=e.holes[t];this.holes.push(s.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let s=this.holes[t];e.holes.push(s.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let s=e.holes[t];this.holes.push(new Pi().fromJSON(s))}return this}};function Zf(i,e,t=2){let n=e&&e.length,s=n?e[0]*t:i.length,r=Cu(i,0,s,t,!0),a=[];if(!r||r.next===r.prev)return a;let o,l,c;if(n&&(r=Qf(i,e,r,t)),i.length>80*t){o=i[0],l=i[1];let h=o,d=l;for(let u=t;u<s;u+=t){let f=i[u],g=i[u+1];f<o&&(o=f),g<l&&(l=g),f>h&&(h=f),g>d&&(d=g)}c=Math.max(h-o,d-l),c=c!==0?32767/c:0}return or(r,a,t,o,l,c,0),a}function Cu(i,e,t,n,s){let r;if(s===hp(i,e,t,n)>0)for(let a=e;a<t;a+=n)r=Nh(a/n|0,i[a],i[a+1],r);else for(let a=t-n;a>=e;a-=n)r=Nh(a/n|0,i[a],i[a+1],r);return r&&ms(r,r.next)&&(cr(r),r=r.next),r}function Ii(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(ms(t,t.next)||_t(t.prev,t,t.next)===0)){if(cr(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function or(i,e,t,n,s,r,a){if(!i)return;!a&&r&&sp(i,n,s,r);let o=i;for(;i.prev!==i.next;){let l=i.prev,c=i.next;if(r?Jf(i,n,s,r):$f(i)){e.push(l.i,i.i,c.i),cr(i),i=c.next,o=c.next;continue}if(i=c,i===o){a?a===1?(i=Kf(Ii(i),e),or(i,e,t,n,s,r,2)):a===2&&jf(i,e,t,n,s,r):or(Ii(i),e,t,n,s,r,1);break}}}function $f(i){let e=i.prev,t=i,n=i.next;if(_t(e,t,n)>=0)return!1;let s=e.x,r=t.x,a=n.x,o=e.y,l=t.y,c=n.y,h=Math.min(s,r,a),d=Math.min(o,l,c),u=Math.max(s,r,a),f=Math.max(o,l,c),g=n.next;for(;g!==e;){if(g.x>=h&&g.x<=u&&g.y>=d&&g.y<=f&&ks(s,o,r,l,a,c,g.x,g.y)&&_t(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function Jf(i,e,t,n){let s=i.prev,r=i,a=i.next;if(_t(s,r,a)>=0)return!1;let o=s.x,l=r.x,c=a.x,h=s.y,d=r.y,u=a.y,f=Math.min(o,l,c),g=Math.min(h,d,u),b=Math.max(o,l,c),m=Math.max(h,d,u),p=Vl(f,g,e,t,n),C=Vl(b,m,e,t,n),w=i.prevZ,_=i.nextZ;for(;w&&w.z>=p&&_&&_.z<=C;){if(w.x>=f&&w.x<=b&&w.y>=g&&w.y<=m&&w!==s&&w!==a&&ks(o,h,l,d,c,u,w.x,w.y)&&_t(w.prev,w,w.next)>=0||(w=w.prevZ,_.x>=f&&_.x<=b&&_.y>=g&&_.y<=m&&_!==s&&_!==a&&ks(o,h,l,d,c,u,_.x,_.y)&&_t(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;w&&w.z>=p;){if(w.x>=f&&w.x<=b&&w.y>=g&&w.y<=m&&w!==s&&w!==a&&ks(o,h,l,d,c,u,w.x,w.y)&&_t(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;_&&_.z<=C;){if(_.x>=f&&_.x<=b&&_.y>=g&&_.y<=m&&_!==s&&_!==a&&ks(o,h,l,d,c,u,_.x,_.y)&&_t(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function Kf(i,e){let t=i;do{let n=t.prev,s=t.next.next;!ms(n,s)&&Pu(n,t,t.next,s)&&lr(n,s)&&lr(s,n)&&(e.push(n.i,t.i,s.i),cr(t),cr(t.next),t=i=s),t=t.next}while(t!==i);return Ii(t)}function jf(i,e,t,n,s,r){let a=i;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&op(a,o)){let l=Iu(a,o);a=Ii(a,a.next),l=Ii(l,l.next),or(a,e,t,n,s,r,0),or(l,e,t,n,s,r,0);return}o=o.next}a=a.next}while(a!==i)}function Qf(i,e,t,n){let s=[];for(let r=0,a=e.length;r<a;r++){let o=e[r]*n,l=r<a-1?e[r+1]*n:i.length,c=Cu(i,o,l,n,!1);c===c.next&&(c.steiner=!0),s.push(ap(c))}s.sort(ep);for(let r=0;r<s.length;r++)t=tp(s[r],t);return t}function ep(i,e){let t=i.x-e.x;if(t===0&&(t=i.y-e.y,t===0)){let n=(i.next.y-i.y)/(i.next.x-i.x),s=(e.next.y-e.y)/(e.next.x-e.x);t=n-s}return t}function tp(i,e){let t=np(i,e);if(!t)return e;let n=Iu(t,i);return Ii(n,n.next),Ii(t,t.next)}function np(i,e){let t=e,n=i.x,s=i.y,r=-1/0,a;if(ms(i,t))return t;do{if(ms(i,t.next))return t.next;if(s<=t.y&&s>=t.next.y&&t.next.y!==t.y){let d=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=n&&d>r&&(r=d,a=t.x<t.next.x?t:t.next,d===n))return a}t=t.next}while(t!==e);if(!a)return null;let o=a,l=a.x,c=a.y,h=1/0;t=a;do{if(n>=t.x&&t.x>=l&&n!==t.x&&Ru(s<c?n:r,s,l,c,s<c?r:n,s,t.x,t.y)){let d=Math.abs(s-t.y)/(n-t.x);lr(t,i)&&(d<h||d===h&&(t.x>a.x||t.x===a.x&&ip(a,t)))&&(a=t,h=d)}t=t.next}while(t!==o);return a}function ip(i,e){return _t(i.prev,i,e.prev)<0&&_t(e.next,i,i.next)<0}function sp(i,e,t,n){let s=i;do s.z===0&&(s.z=Vl(s.x,s.y,e,t,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i);s.prevZ.nextZ=null,s.prevZ=null,rp(s)}function rp(i){let e,t=1;do{let n=i,s;i=null;let r=null;for(e=0;n;){e++;let a=n,o=0;for(let c=0;c<t&&(o++,a=a.nextZ,!!a);c++);let l=t;for(;o>0||l>0&&a;)o!==0&&(l===0||!a||n.z<=a.z)?(s=n,n=n.nextZ,o--):(s=a,a=a.nextZ,l--),r?r.nextZ=s:i=s,s.prevZ=r,r=s;n=a}r.nextZ=null,t*=2}while(e>1);return i}function Vl(i,e,t,n,s){return i=(i-t)*s|0,e=(e-n)*s|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function ap(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function Ru(i,e,t,n,s,r,a,o){return(s-a)*(e-o)>=(i-a)*(r-o)&&(i-a)*(n-o)>=(t-a)*(e-o)&&(t-a)*(r-o)>=(s-a)*(n-o)}function ks(i,e,t,n,s,r,a,o){return!(i===a&&e===o)&&Ru(i,e,t,n,s,r,a,o)}function op(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!lp(i,e)&&(lr(i,e)&&lr(e,i)&&cp(i,e)&&(_t(i.prev,i,e.prev)||_t(i,e.prev,e))||ms(i,e)&&_t(i.prev,i,i.next)>0&&_t(e.prev,e,e.next)>0)}function _t(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function ms(i,e){return i.x===e.x&&i.y===e.y}function Pu(i,e,t,n){let s=ua(_t(i,e,t)),r=ua(_t(i,e,n)),a=ua(_t(t,n,i)),o=ua(_t(t,n,e));return!!(s!==r&&a!==o||s===0&&ha(i,t,e)||r===0&&ha(i,n,e)||a===0&&ha(t,i,n)||o===0&&ha(t,e,n))}function ha(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function ua(i){return i>0?1:i<0?-1:0}function lp(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&Pu(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function lr(i,e){return _t(i.prev,i,i.next)<0?_t(i,e,i.next)>=0&&_t(i,i.prev,e)>=0:_t(i,e,i.prev)<0||_t(i,i.next,e)<0}function cp(i,e){let t=i,n=!1,s=(i.x+e.x)/2,r=(i.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&s<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function Iu(i,e){let t=Hl(i.i,i.x,i.y),n=Hl(e.i,e.x,e.y),s=i.next,r=e.prev;return i.next=e,e.prev=i,t.next=s,s.prev=t,n.next=t,t.prev=n,r.next=n,n.prev=r,n}function Nh(i,e,t,n){let s=Hl(i,e,t);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function cr(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Hl(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function hp(i,e,t,n){let s=0;for(let r=e,a=t-n;r<t;r+=n)s+=(i[a]-i[r])*(i[r+1]+i[a+1]),a=r;return s}var Gl=class{static triangulate(e,t,n=2){return Zf(e,t,n)}},Ei=class i{static area(e){let t=e.length,n=0;for(let s=t-1,r=0;r<t;s=r++)n+=e[s].x*e[r].y-e[r].x*e[s].y;return n*.5}static isClockWise(e){return i.area(e)<0}static triangulateShape(e,t){let n=[],s=[],r=[];Uh(e),Fh(n,e);let a=e.length;t.forEach(Uh);for(let l=0;l<t.length;l++)s.push(a),a+=t[l].length,Fh(n,t[l]);let o=Gl.triangulate(n,s);for(let l=0;l<o.length;l+=3)r.push(o.slice(l,l+3));return r}};function Uh(i){let e=i.length;e>2&&i[e-1].equals(i[0])&&i.pop()}function Fh(i,e){for(let t=0;t<e.length;t++)i.push(e[t].x),i.push(e[t].y)}var hr=class i extends mt{constructor(e=new ps([new ee(.5,.5),new ee(-.5,.5),new ee(-.5,-.5),new ee(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let n=this,s=[],r=[];for(let o=0,l=e.length;o<l;o++){let c=e[o];a(c)}this.setAttribute("position",new xt(s,3)),this.setAttribute("uv",new xt(r,2)),this.computeVertexNormals();function a(o){let l=[],c=t.curveSegments!==void 0?t.curveSegments:12,h=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1,u=t.bevelEnabled!==void 0?t.bevelEnabled:!0,f=t.bevelThickness!==void 0?t.bevelThickness:.2,g=t.bevelSize!==void 0?t.bevelSize:f-.1,b=t.bevelOffset!==void 0?t.bevelOffset:0,m=t.bevelSegments!==void 0?t.bevelSegments:3,p=t.extrudePath,C=t.UVGenerator!==void 0?t.UVGenerator:up,w,_=!1,S,M,A,y;if(p){w=p.getSpacedPoints(h),_=!0,u=!1;let j=p.isCatmullRomCurve3?p.closed:!1;S=p.computeFrenetFrames(h,j),M=new R,A=new R,y=new R}u||(m=0,f=0,g=0,b=0);let T=o.extractPoints(c),I=T.shape,P=T.holes;if(!Ei.isClockWise(I)){I=I.reverse();for(let j=0,ne=P.length;j<ne;j++){let te=P[j];Ei.isClockWise(te)&&(P[j]=te.reverse())}}function G(j){let te=10000000000000001e-36,xe=j[0];for(let me=1;me<=j.length;me++){let Oe=me%j.length,Ce=j[Oe],ke=Ce.x-xe.x,Ge=Ce.y-xe.y,L=ke*ke+Ge*Ge,at=Math.max(Math.abs(Ce.x),Math.abs(Ce.y),Math.abs(xe.x),Math.abs(xe.y)),Ke=te*at*at;if(L<=Ke){j.splice(Oe,1),me--;continue}xe=Ce}}G(I),P.forEach(G);let X=P.length,O=I;for(let j=0;j<X;j++){let ne=P[j];I=I.concat(ne)}function W(j,ne,te){return ne||Fe("ExtrudeGeometry: vec does not exist"),j.clone().addScaledVector(ne,te)}let H=I.length;function K(j,ne,te){let xe,me,Oe,Ce=j.x-ne.x,ke=j.y-ne.y,Ge=te.x-j.x,L=te.y-j.y,at=Ce*Ce+ke*ke,Ke=Ce*L-ke*Ge;if(Math.abs(Ke)>Number.EPSILON){let E=Math.sqrt(at),x=Math.sqrt(Ge*Ge+L*L),U=ne.x-ke/E,k=ne.y+Ce/E,q=te.x-L/x,ae=te.y+Ge/x,oe=((q-U)*L-(ae-k)*Ge)/(Ce*L-ke*Ge);xe=U+Ce*oe-j.x,me=k+ke*oe-j.y;let Y=xe*xe+me*me;if(Y<=2)return new ee(xe,me);Oe=Math.sqrt(Y/2)}else{let E=!1;Ce>Number.EPSILON?Ge>Number.EPSILON&&(E=!0):Ce<-Number.EPSILON?Ge<-Number.EPSILON&&(E=!0):Math.sign(ke)===Math.sign(L)&&(E=!0),E?(xe=-ke,me=Ce,Oe=Math.sqrt(at)):(xe=Ce,me=ke,Oe=Math.sqrt(at/2))}return new ee(xe/Oe,me/Oe)}let ie=[];for(let j=0,ne=O.length,te=ne-1,xe=j+1;j<ne;j++,te++,xe++)te===ne&&(te=0),xe===ne&&(xe=0),ie[j]=K(O[j],O[te],O[xe]);let ue=[],le,Me=ie.concat();for(let j=0,ne=X;j<ne;j++){let te=P[j];le=[];for(let xe=0,me=te.length,Oe=me-1,Ce=xe+1;xe<me;xe++,Oe++,Ce++)Oe===me&&(Oe=0),Ce===me&&(Ce=0),le[xe]=K(te[xe],te[Oe],te[Ce]);ue.push(le),Me=Me.concat(le)}let $e;if(m===0)$e=Ei.triangulateShape(O,P);else{let j=[],ne=[];for(let te=0;te<m;te++){let xe=te/m,me=f*Math.cos(xe*Math.PI/2),Oe=g*Math.sin(xe*Math.PI/2)+b;for(let Ce=0,ke=O.length;Ce<ke;Ce++){let Ge=W(O[Ce],ie[Ce],Oe);Ie(Ge.x,Ge.y,-me),xe===0&&j.push(Ge)}for(let Ce=0,ke=X;Ce<ke;Ce++){let Ge=P[Ce];le=ue[Ce];let L=[];for(let at=0,Ke=Ge.length;at<Ke;at++){let E=W(Ge[at],le[at],Oe);Ie(E.x,E.y,-me),xe===0&&L.push(E)}xe===0&&ne.push(L)}}$e=Ei.triangulateShape(j,ne)}let ct=$e.length,Qe=g+b;for(let j=0;j<H;j++){let ne=u?W(I[j],Me[j],Qe):I[j];_?(A.copy(S.normals[0]).multiplyScalar(ne.x),M.copy(S.binormals[0]).multiplyScalar(ne.y),y.copy(w[0]).add(A).add(M),Ie(y.x,y.y,y.z)):Ie(ne.x,ne.y,0)}for(let j=1;j<=h;j++)for(let ne=0;ne<H;ne++){let te=u?W(I[ne],Me[ne],Qe):I[ne];_?(A.copy(S.normals[j]).multiplyScalar(te.x),M.copy(S.binormals[j]).multiplyScalar(te.y),y.copy(w[j]).add(A).add(M),Ie(y.x,y.y,y.z)):Ie(te.x,te.y,d/h*j)}for(let j=m-1;j>=0;j--){let ne=j/m,te=f*Math.cos(ne*Math.PI/2),xe=g*Math.sin(ne*Math.PI/2)+b;for(let me=0,Oe=O.length;me<Oe;me++){let Ce=W(O[me],ie[me],xe);Ie(Ce.x,Ce.y,d+te)}for(let me=0,Oe=P.length;me<Oe;me++){let Ce=P[me];le=ue[me];for(let ke=0,Ge=Ce.length;ke<Ge;ke++){let L=W(Ce[ke],le[ke],xe);_?Ie(L.x,L.y+w[h-1].y,w[h-1].x+te):Ie(L.x,L.y,d+te)}}}$(),ce();function $(){let j=s.length/3;if(u){let ne=0,te=H*ne;for(let xe=0;xe<ct;xe++){let me=$e[xe];ze(me[2]+te,me[1]+te,me[0]+te)}ne=h+m*2,te=H*ne;for(let xe=0;xe<ct;xe++){let me=$e[xe];ze(me[0]+te,me[1]+te,me[2]+te)}}else{for(let ne=0;ne<ct;ne++){let te=$e[ne];ze(te[2],te[1],te[0])}for(let ne=0;ne<ct;ne++){let te=$e[ne];ze(te[0]+H*h,te[1]+H*h,te[2]+H*h)}}n.addGroup(j,s.length/3-j,0)}function ce(){let j=s.length/3,ne=0;re(O,ne),ne+=O.length;for(let te=0,xe=P.length;te<xe;te++){let me=P[te];re(me,ne),ne+=me.length}n.addGroup(j,s.length/3-j,1)}function re(j,ne){let te=j.length;for(;--te>=0;){let xe=te,me=te-1;me<0&&(me=j.length-1);for(let Oe=0,Ce=h+m*2;Oe<Ce;Oe++){let ke=H*Oe,Ge=H*(Oe+1),L=ne+xe+ke,at=ne+me+ke,Ke=ne+me+Ge,E=ne+xe+Ge;Ue(L,at,Ke,E)}}}function Ie(j,ne,te){l.push(j),l.push(ne),l.push(te)}function ze(j,ne,te){nt(j),nt(ne),nt(te);let xe=s.length/3,me=C.generateTopUV(n,s,xe-3,xe-2,xe-1);Ve(me[0]),Ve(me[1]),Ve(me[2])}function Ue(j,ne,te,xe){nt(j),nt(ne),nt(xe),nt(ne),nt(te),nt(xe);let me=s.length/3,Oe=C.generateSideWallUV(n,s,me-6,me-3,me-2,me-1);Ve(Oe[0]),Ve(Oe[1]),Ve(Oe[3]),Ve(Oe[1]),Ve(Oe[2]),Ve(Oe[3])}function nt(j){s.push(l[j*3+0]),s.push(l[j*3+1]),s.push(l[j*3+2])}function Ve(j){r.push(j.x),r.push(j.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return dp(t,n,e)}static fromJSON(e,t){let n=[];for(let r=0,a=e.shapes.length;r<a;r++){let o=t[e.shapes[r]];n.push(o)}let s=e.options.extrudePath;return s!==void 0&&(e.options.extrudePath=new kl[s.type]().fromJSON(s)),new i(n,e.options)}},up={generateTopUV:function(i,e,t,n,s){let r=e[t*3],a=e[t*3+1],o=e[n*3],l=e[n*3+1],c=e[s*3],h=e[s*3+1];return[new ee(r,a),new ee(o,l),new ee(c,h)]},generateSideWallUV:function(i,e,t,n,s,r){let a=e[t*3],o=e[t*3+1],l=e[t*3+2],c=e[n*3],h=e[n*3+1],d=e[n*3+2],u=e[s*3],f=e[s*3+1],g=e[s*3+2],b=e[r*3],m=e[r*3+1],p=e[r*3+2];return Math.abs(o-h)<Math.abs(a-c)?[new ee(a,1-l),new ee(c,1-d),new ee(u,1-g),new ee(b,1-p)]:[new ee(o,1-l),new ee(h,1-d),new ee(f,1-g),new ee(m,1-p)]}};function dp(i,e,t){if(t.shapes=[],Array.isArray(i))for(let n=0,s=i.length;n<s;n++){let r=i[n];t.shapes.push(r.uuid)}else t.shapes.push(i.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}var si=class i extends mt{constructor(e=1,t=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:s};let r=e/2,a=t/2,o=Math.floor(n),l=Math.floor(s),c=o+1,h=l+1,d=e/o,u=t/l,f=[],g=[],b=[],m=[];for(let p=0;p<h;p++){let C=p*u-a;for(let w=0;w<c;w++){let _=w*d-r;g.push(_,-C,0),b.push(0,0,1),m.push(w/o),m.push(1-p/l)}}for(let p=0;p<l;p++)for(let C=0;C<o;C++){let w=C+c*p,_=C+c*(p+1),S=C+1+c*(p+1),M=C+1+c*p;f.push(w,_,M),f.push(_,S,M)}this.setIndex(f),this.setAttribute("position",new xt(g,3)),this.setAttribute("normal",new xt(b,3)),this.setAttribute("uv",new xt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.widthSegments,e.heightSegments)}};function Ni(i){let e={};for(let t in i){e[t]={};for(let n in i[t]){let s=i[t][n];if(Oh(s))s.isRenderTargetTexture?(De("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=s.clone();else if(Array.isArray(s))if(Oh(s[0])){let r=[];for(let a=0,o=s.length;a<o;a++)r[a]=s[a].clone();e[t][n]=r}else e[t][n]=s.slice();else e[t][n]=s}}return e}function Gt(i){let e={};for(let t=0;t<i.length;t++){let n=Ni(i[t]);for(let s in n)e[s]=n[s]}return e}function Oh(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function fp(i){let e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function yc(i){let e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:je.workingColorSpace}var Lu={clone:Ni,merge:Gt},pp=`void main() {
|
|
6
|
+
"use strict";var tf=Object.create;var Or=Object.defineProperty;var nf=Object.getOwnPropertyDescriptor;var sf=Object.getOwnPropertyNames;var rf=Object.getPrototypeOf,of=Object.prototype.hasOwnProperty;var af=(i,e)=>{for(var t in e)Or(i,t,{get:e[t],enumerable:!0})},hh=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of sf(e))!of.call(i,s)&&s!==t&&Or(i,s,{get:()=>e[s],enumerable:!(n=nf(e,s))||n.enumerable});return i};var Br=(i,e,t)=>(t=i!=null?tf(rf(i)):{},hh(e||!i||!i.__esModule?Or(t,"default",{value:i,enumerable:!0}):t,i)),lf=i=>hh(Or({},"__esModule",{value:!0}),i);var Sv={};af(Sv,{apply:()=>Mv,inject:()=>yv});module.exports=lf(Sv);var xi=Br(require("react"),1);var Pt=Br(require("react"),1),St=require("react");var ui={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},di={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},qh=0,Jl=1,Yh=2;var _r=1,Zh=2,ys=3,Hn=0,qt=1,ln=2,In=0,Ai=1,Kl=2,jl=3,Ql=4,$h=5;var ni=100,Jh=101,Kh=102,jh=103,Qh=104,eu=200,tu=201,nu=202,iu=203,_o=204,xo=205,su=206,ru=207,ou=208,au=209,lu=210,cu=211,hu=212,uu=213,du=214,vo=0,yo=1,bo=2,Ci=3,Mo=4,So=5,Eo=6,wo=7,ec=0,fu=1,pu=2,vn=0,tc=1,nc=2,ic=3,sc=4,rc=5,oc=6,ac=7;var lc=300,fi=301,Ni=302,oa=303,aa=304,xr=306,To=1e3,An=1001,Ao=1002,Lt=1003,mu=1004;var vr=1005;var Ut=1006,la=1007;var pi=1008;var Yt=1009,cc=1010,hc=1011,bs=1012,ca=1013,yn=1014,bn=1015,Ln=1016,ha=1017,ua=1018,Ms=1020,uc=35902,dc=35899,fc=1021,pc=1022,cn=1023,Rn=1026,mi=1027,mc=1028,da=1029,gi=1030,fa=1031;var pa=1033,yr=33776,br=33777,Mr=33778,Sr=33779,ma=35840,ga=35841,_a=35842,xa=35843,va=36196,ya=37492,ba=37496,Ma=37488,Sa=37489,Er=37490,Ea=37491,wa=37808,Ta=37809,Aa=37810,Ca=37811,Ra=37812,Pa=37813,Ia=37814,La=37815,Da=37816,Na=37817,Ua=37818,Fa=37819,Oa=37820,Ba=37821,za=36492,ka=36494,Va=36495,Ha=36283,Ga=36284,wr=36285,Wa=36286;var Gs=2300,Co=2301,go=2302,Fl=2303,Ol=2400,Bl=2401,zl=2402;var gu=3200;var Xa=0,_u=1,Xn="",jt="srgb",Ws="srgb-linear",Xs="linear",it="srgb";var Ei=7680;var kl=519,xu=512,vu=513,yu=514,qa=515,bu=516,Mu=517,Ya=518,Su=519,Ro=35044;var gc="300 es",pn=2e3,os=2001;function cf(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function hf(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function qs(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Eu(){let i=qs("canvas");return i.style.display="block",i}var uh={},as=null;function Ys(...i){let e="THREE."+i.shift();as?as("log",e,...i):console.log(e,...i)}function wu(i){let e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){let t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function De(...i){i=wu(i);let e="THREE."+i.shift();if(as)as("warn",e,...i);else{let t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function Fe(...i){i=wu(i);let e="THREE."+i.shift();if(as)as("error",e,...i);else{let t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function Ti(...i){let e=i.join(" ");e in uh||(uh[e]=!0,De(...i))}function Tu(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}var Au={[vo]:yo,[bo]:Eo,[Mo]:wo,[Ci]:So,[yo]:vo,[Eo]:bo,[wo]:Mo,[So]:Ci},mn=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let s=n[e];if(s!==void 0){let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let s=n.slice(0);for(let r=0,o=s.length;r<o;r++)s[r].call(this,e);e.target=null}}},Bt=["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"],dh=1234567,ss=Math.PI/180,ls=180/Math.PI;function Cn(){let i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Bt[i&255]+Bt[i>>8&255]+Bt[i>>16&255]+Bt[i>>24&255]+"-"+Bt[e&255]+Bt[e>>8&255]+"-"+Bt[e>>16&15|64]+Bt[e>>24&255]+"-"+Bt[t&63|128]+Bt[t>>8&255]+"-"+Bt[t>>16&255]+Bt[t>>24&255]+Bt[n&255]+Bt[n>>8&255]+Bt[n>>16&255]+Bt[n>>24&255]).toLowerCase()}function Ze(i,e,t){return Math.max(e,Math.min(t,i))}function _c(i,e){return(i%e+e)%e}function uf(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function df(i,e,t){return i!==e?(t-i)/(e-i):0}function ks(i,e,t){return(1-t)*i+t*e}function ff(i,e,t,n){return ks(i,e,1-Math.exp(-t*n))}function pf(i,e=1){return e-Math.abs(_c(i,e*2)-e)}function mf(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function gf(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function _f(i,e){return i+Math.floor(Math.random()*(e-i+1))}function xf(i,e){return i+Math.random()*(e-i)}function vf(i){return i*(.5-Math.random())}function yf(i){i!==void 0&&(dh=i);let e=dh+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function bf(i){return i*ss}function Mf(i){return i*ls}function Sf(i){return(i&i-1)===0&&i!==0}function Ef(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function wf(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Tf(i,e,t,n,s){let r=Math.cos,o=Math.sin,a=r(t/2),l=o(t/2),c=r((e+n)/2),h=o((e+n)/2),d=r((e-n)/2),u=o((e-n)/2),f=r((n-e)/2),g=o((n-e)/2);switch(s){case"XYX":i.set(a*h,l*d,l*u,a*c);break;case"YZY":i.set(l*u,a*h,l*d,a*c);break;case"ZXZ":i.set(l*d,l*u,a*h,a*c);break;case"XZX":i.set(a*h,l*g,l*f,a*c);break;case"YXY":i.set(l*f,a*h,l*g,a*c);break;case"ZYZ":i.set(l*g,l*f,a*h,a*c);break;default:De("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function fn(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function st(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}var xc={DEG2RAD:ss,RAD2DEG:ls,generateUUID:Cn,clamp:Ze,euclideanModulo:_c,mapLinear:uf,inverseLerp:df,lerp:ks,damp:ff,pingpong:pf,smoothstep:mf,smootherstep:gf,randInt:_f,randFloat:xf,randFloatSpread:vf,seededRandom:yf,degToRad:bf,radToDeg:Mf,isPowerOfTwo:Sf,ceilPowerOfTwo:Ef,floorPowerOfTwo:wf,setQuaternionFromProperEuler:Tf,normalize:st,denormalize:fn},te=class i{static{i.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Ze(this.x,e.x,t.x),this.y=Ze(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ze(this.x,e,t),this.y=Ze(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ze(n,e,t))}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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Ze(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*n-o*s+e.x,this.y=r*s+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ft=class{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,o,a){let l=n[s+0],c=n[s+1],h=n[s+2],d=n[s+3],u=r[o+0],f=r[o+1],g=r[o+2],y=r[o+3];if(d!==y||l!==u||c!==f||h!==g){let m=l*u+c*f+h*g+d*y;m<0&&(u=-u,f=-f,g=-g,y=-y,m=-m);let p=1-a;if(m<.9995){let C=Math.acos(m),T=Math.sin(C);p=Math.sin(p*C)/T,a=Math.sin(a*C)/T,l=l*p+u*a,c=c*p+f*a,h=h*p+g*a,d=d*p+y*a}else{l=l*p+u*a,c=c*p+f*a,h=h*p+g*a,d=d*p+y*a;let C=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=C,c*=C,h*=C,d*=C}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,s,r,o){let a=n[s],l=n[s+1],c=n[s+2],h=n[s+3],d=r[o],u=r[o+1],f=r[o+2],g=r[o+3];return e[t]=a*g+h*d+l*f-c*u,e[t+1]=l*g+h*u+c*d-a*f,e[t+2]=c*g+h*f+a*u-l*d,e[t+3]=h*g-a*d-l*u-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,s){return this._x=e,this._y=t,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,s=e._y,r=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),h=a(s/2),d=a(r/2),u=l(n/2),f=l(s/2),g=l(r/2);switch(o){case"XYZ":this._x=u*h*d+c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d-u*f*g;break;case"YXZ":this._x=u*h*d+c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d+u*f*g;break;case"ZXY":this._x=u*h*d-c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d-u*f*g;break;case"ZYX":this._x=u*h*d-c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d+u*f*g;break;case"YZX":this._x=u*h*d+c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d-u*f*g;break;case"XZY":this._x=u*h*d-c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d+u*f*g;break;default:De("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],s=t[4],r=t[8],o=t[1],a=t[5],l=t[9],c=t[2],h=t[6],d=t[10],u=n+a+d;if(u>0){let f=.5/Math.sqrt(u+1);this._w=.25/f,this._x=(h-l)*f,this._y=(r-c)*f,this._z=(o-s)*f}else if(n>a&&n>d){let f=2*Math.sqrt(1+n-a-d);this._w=(h-l)/f,this._x=.25*f,this._y=(s+o)/f,this._z=(r+c)/f}else if(a>d){let f=2*Math.sqrt(1+a-n-d);this._w=(r-c)/f,this._x=(s+o)/f,this._y=.25*f,this._z=(l+h)/f}else{let f=2*Math.sqrt(1+d-n-a);this._w=(o-s)/f,this._x=(r+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ze(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let s=Math.min(1,t/n);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,s=e._y,r=e._z,o=e._w,a=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+o*a+s*c-r*l,this._y=s*h+o*l+r*a-n*c,this._z=r*h+o*c+n*l-s*a,this._w=o*h-n*a-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,s=e._y,r=e._z,o=e._w,a=this.dot(e);a<0&&(n=-n,s=-s,r=-r,o=-o,a=-a);let l=1-t;if(a<.9995){let c=Math.acos(a),h=Math.sin(c);l=Math.sin(l*c)/h,t=Math.sin(t*c)/h,this._x=this._x*l+n*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+o*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+o*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},R=class i{static{i.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(fh.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(fh.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=e.elements,o=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*o,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*o,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,s=this.z,r=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*s-a*n),h=2*(a*t-r*s),d=2*(r*n-o*t);return this.x=t+l*c+o*d-a*h,this.y=n+l*h+a*c-r*d,this.z=s+l*d+r*h-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Ze(this.x,e.x,t.x),this.y=Ze(this.y,e.y,t.y),this.z=Ze(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ze(this.x,e,t),this.y=Ze(this.y,e,t),this.z=Ze(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ze(n,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,s=e.y,r=e.z,o=t.x,a=t.y,l=t.z;return this.x=s*l-r*a,this.y=r*o-n*l,this.z=n*a-s*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return ll.copy(this).projectOnVector(e),this.sub(ll)}reflect(e){return this.sub(ll.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Ze(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},ll=new R,fh=new Ft,Ge=class i{static{i.prototype.isMatrix3=!0}constructor(e,t,n,s,r,o,a,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,o,a,l,c)}set(e,t,n,s,r,o,a,l,c){let h=this.elements;return h[0]=e,h[1]=s,h[2]=a,h[3]=t,h[4]=r,h[5]=l,h[6]=n,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,s=t.elements,r=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],h=n[4],d=n[7],u=n[2],f=n[5],g=n[8],y=s[0],m=s[3],p=s[6],C=s[1],T=s[4],x=s[7],S=s[2],M=s[5],A=s[8];return r[0]=o*y+a*C+l*S,r[3]=o*m+a*T+l*M,r[6]=o*p+a*x+l*A,r[1]=c*y+h*C+d*S,r[4]=c*m+h*T+d*M,r[7]=c*p+h*x+d*A,r[2]=u*y+f*C+g*S,r[5]=u*m+f*T+g*M,r[8]=u*p+f*x+g*A,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8];return t*o*h-t*a*c-n*r*h+n*a*l+s*r*c-s*o*l}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],d=h*o-a*c,u=a*l-h*r,f=c*r-o*l,g=t*d+n*u+s*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let y=1/g;return e[0]=d*y,e[1]=(s*c-h*n)*y,e[2]=(a*n-s*o)*y,e[3]=u*y,e[4]=(h*t-s*l)*y,e[5]=(s*r-a*t)*y,e[6]=f*y,e[7]=(n*l-c*t)*y,e[8]=(o*t-n*r)*y,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,s,r,o,a){let l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*o+c*a)+o+e,-s*c,s*l,-s*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return Ti("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(cl.makeScale(e,t)),this}rotate(e){return Ti("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(cl.makeRotation(-e)),this}translate(e,t){return Ti("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(cl.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},cl=new Ge,ph=new Ge().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),mh=new Ge().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Af(){let i={enabled:!0,workingColorSpace:Ws,spaces:{},convert:function(s,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===it&&(s.r=Vn(s.r),s.g=Vn(s.g),s.b=Vn(s.b)),this.spaces[r].primaries!==this.spaces[o].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===it&&(s.r=rs(s.r),s.g=rs(s.g),s.b=rs(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Xn?Xs:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,o){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Ti("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Ti("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Ws]:{primaries:e,whitePoint:n,transfer:Xs,toXYZ:ph,fromXYZ:mh,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:jt},outputColorSpaceConfig:{drawingBufferColorSpace:jt}},[jt]:{primaries:e,whitePoint:n,transfer:it,toXYZ:ph,fromXYZ:mh,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:jt}}}),i}var Qe=Af();function Vn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function rs(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var Hi,Po=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Hi===void 0&&(Hi=qs("canvas")),Hi.width=e.width,Hi.height=e.height;let s=Hi.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=Hi}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=qs("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let o=0;o<r.length;o++)r[o]=Vn(r[o]/255)*255;return n.putImageData(s,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Vn(t[n]/255)*255):t[n]=Vn(t[n]);return{data:t,width:e.width,height:e.height}}else return De("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Cf=0,cs=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Cf++}),this.uuid=Cn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let o=0,a=s.length;o<a;o++)s[o].isDataTexture?r.push(hl(s[o].image)):r.push(hl(s[o]))}else r=hl(s);n.url=r}return t||(e.images[this.uuid]=n),n}};function hl(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?Po.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(De("Texture: Unable to serialize Texture."),{})}var Rf=0,ul=new R,Xt=class i extends mn{constructor(e=i.DEFAULT_IMAGE,t=i.DEFAULT_MAPPING,n=An,s=An,r=Ut,o=pi,a=cn,l=Yt,c=i.DEFAULT_ANISOTROPY,h=Xn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Rf++}),this.uuid=Cn(),this.name="",this.source=new cs(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new te(0,0),this.repeat=new te(1,1),this.center=new te(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ge,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(ul).x}get height(){return this.source.getSize(ul).y}get depth(){return this.source.getSize(ul).z}get image(){return this.source.data}set image(e){this.source.data=e}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(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){De(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){De(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==lc)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case To:e.x=e.x-Math.floor(e.x);break;case An:e.x=e.x<0?0:1;break;case Ao:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case To:e.y=e.y-Math.floor(e.y);break;case An:e.y=e.y<0?0:1;break;case Ao:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Xt.DEFAULT_IMAGE=null;Xt.DEFAULT_MAPPING=lc;Xt.DEFAULT_ANISOTROPY=1;var gt=class i{static{i.prototype.isVector4=!0}constructor(e=0,t=0,n=0,s=1){this.x=e,this.y=t,this.z=n,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*s+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*s+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*s+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*s+o[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,s,r,l=e.elements,c=l[0],h=l[4],d=l[8],u=l[1],f=l[5],g=l[9],y=l[2],m=l[6],p=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-y)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+y)<.1&&Math.abs(g+m)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let T=(c+1)/2,x=(f+1)/2,S=(p+1)/2,M=(h+u)/4,A=(d+y)/4,v=(g+m)/4;return T>x&&T>S?T<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(T),s=M/n,r=A/n):x>S?x<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(x),n=M/s,r=v/s):S<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(S),n=A/r,s=v/r),this.set(n,s,r,t),this}let C=Math.sqrt((m-g)*(m-g)+(d-y)*(d-y)+(u-h)*(u-h));return Math.abs(C)<.001&&(C=1),this.x=(m-g)/C,this.y=(d-y)/C,this.z=(u-h)/C,this.w=Math.acos((c+f+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Ze(this.x,e.x,t.x),this.y=Ze(this.y,e.y,t.y),this.z=Ze(this.z,e.z,t.z),this.w=Ze(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ze(this.x,e,t),this.y=Ze(this.y,e,t),this.z=Ze(this.z,e,t),this.w=Ze(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ze(n,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Io=class extends mn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ut,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new gt(0,0,e,t),this.scissorTest=!1,this.viewport=new gt(0,0,e,t),this.textures=[];let s={width:e,height:t,depth:n.depth},r=new Xt(s),o=n.count;for(let a=0;a<o;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:Ut,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].image.depth=n,this.textures[s].isData3DTexture!==!0&&(this.textures[s].isArrayTexture=this.textures[s].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let s=Object.assign({},e.textures[t].image);this.textures[t].source=new cs(s)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}},Qt=class extends Io{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},Zs=class extends Xt{constructor(e=null,t=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Lt,this.minFilter=Lt,this.wrapR=An,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};var Lo=class extends Xt{constructor(e=null,t=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Lt,this.minFilter=Lt,this.wrapR=An,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var rt=class i{static{i.prototype.isMatrix4=!0}constructor(e,t,n,s,r,o,a,l,c,h,d,u,f,g,y,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,o,a,l,c,h,d,u,f,g,y,m)}set(e,t,n,s,r,o,a,l,c,h,d,u,f,g,y,m){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=s,p[1]=r,p[5]=o,p[9]=a,p[13]=l,p[2]=c,p[6]=h,p[10]=d,p[14]=u,p[3]=f,p[7]=g,p[11]=y,p[15]=m,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 i().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,s=1/Gi.setFromMatrixColumn(e,0).length(),r=1/Gi.setFromMatrixColumn(e,1).length(),o=1/Gi.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,s=e.y,r=e.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),d=Math.sin(r);if(e.order==="XYZ"){let u=o*h,f=o*d,g=a*h,y=a*d;t[0]=l*h,t[4]=-l*d,t[8]=c,t[1]=f+g*c,t[5]=u-y*c,t[9]=-a*l,t[2]=y-u*c,t[6]=g+f*c,t[10]=o*l}else if(e.order==="YXZ"){let u=l*h,f=l*d,g=c*h,y=c*d;t[0]=u+y*a,t[4]=g*a-f,t[8]=o*c,t[1]=o*d,t[5]=o*h,t[9]=-a,t[2]=f*a-g,t[6]=y+u*a,t[10]=o*l}else if(e.order==="ZXY"){let u=l*h,f=l*d,g=c*h,y=c*d;t[0]=u-y*a,t[4]=-o*d,t[8]=g+f*a,t[1]=f+g*a,t[5]=o*h,t[9]=y-u*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){let u=o*h,f=o*d,g=a*h,y=a*d;t[0]=l*h,t[4]=g*c-f,t[8]=u*c+y,t[1]=l*d,t[5]=y*c+u,t[9]=f*c-g,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){let u=o*l,f=o*c,g=a*l,y=a*c;t[0]=l*h,t[4]=y-u*d,t[8]=g*d+f,t[1]=d,t[5]=o*h,t[9]=-a*h,t[2]=-c*h,t[6]=f*d+g,t[10]=u-y*d}else if(e.order==="XZY"){let u=o*l,f=o*c,g=a*l,y=a*c;t[0]=l*h,t[4]=-d,t[8]=c*h,t[1]=u*d+y,t[5]=o*h,t[9]=f*d-g,t[2]=g*d-f,t[6]=a*h,t[10]=y*d+u}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Pf,e,If)}lookAt(e,t,n){let s=this.elements;return Jt.subVectors(e,t),Jt.lengthSq()===0&&(Jt.z=1),Jt.normalize(),Jn.crossVectors(n,Jt),Jn.lengthSq()===0&&(Math.abs(n.z)===1?Jt.x+=1e-4:Jt.z+=1e-4,Jt.normalize(),Jn.crossVectors(n,Jt)),Jn.normalize(),zr.crossVectors(Jt,Jn),s[0]=Jn.x,s[4]=zr.x,s[8]=Jt.x,s[1]=Jn.y,s[5]=zr.y,s[9]=Jt.y,s[2]=Jn.z,s[6]=zr.z,s[10]=Jt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,s=t.elements,r=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],h=n[1],d=n[5],u=n[9],f=n[13],g=n[2],y=n[6],m=n[10],p=n[14],C=n[3],T=n[7],x=n[11],S=n[15],M=s[0],A=s[4],v=s[8],w=s[12],I=s[1],P=s[5],O=s[9],q=s[13],Y=s[2],U=s[6],G=s[10],H=s[14],j=s[3],se=s[7],ue=s[11],le=s[15];return r[0]=o*M+a*I+l*Y+c*j,r[4]=o*A+a*P+l*U+c*se,r[8]=o*v+a*O+l*G+c*ue,r[12]=o*w+a*q+l*H+c*le,r[1]=h*M+d*I+u*Y+f*j,r[5]=h*A+d*P+u*U+f*se,r[9]=h*v+d*O+u*G+f*ue,r[13]=h*w+d*q+u*H+f*le,r[2]=g*M+y*I+m*Y+p*j,r[6]=g*A+y*P+m*U+p*se,r[10]=g*v+y*O+m*G+p*ue,r[14]=g*w+y*q+m*H+p*le,r[3]=C*M+T*I+x*Y+S*j,r[7]=C*A+T*P+x*U+S*se,r[11]=C*v+T*O+x*G+S*ue,r[15]=C*w+T*q+x*H+S*le,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],s=e[8],r=e[12],o=e[1],a=e[5],l=e[9],c=e[13],h=e[2],d=e[6],u=e[10],f=e[14],g=e[3],y=e[7],m=e[11],p=e[15],C=l*f-c*u,T=a*f-c*d,x=a*u-l*d,S=o*f-c*h,M=o*u-l*h,A=o*d-a*h;return t*(y*C-m*T+p*x)-n*(g*C-m*S+p*M)+s*(g*T-y*S+p*A)-r*(g*x-y*M+m*A)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],s=e[8],r=e[1],o=e[5],a=e[9],l=e[2],c=e[6],h=e[10];return t*(o*h-a*c)-n*(r*h-a*l)+s*(r*c-o*l)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],d=e[9],u=e[10],f=e[11],g=e[12],y=e[13],m=e[14],p=e[15],C=t*a-n*o,T=t*l-s*o,x=t*c-r*o,S=n*l-s*a,M=n*c-r*a,A=s*c-r*l,v=h*y-d*g,w=h*m-u*g,I=h*p-f*g,P=d*m-u*y,O=d*p-f*y,q=u*p-f*m,Y=C*q-T*O+x*P+S*I-M*w+A*v;if(Y===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let U=1/Y;return e[0]=(a*q-l*O+c*P)*U,e[1]=(s*O-n*q-r*P)*U,e[2]=(y*A-m*M+p*S)*U,e[3]=(u*M-d*A-f*S)*U,e[4]=(l*I-o*q-c*w)*U,e[5]=(t*q-s*I+r*w)*U,e[6]=(m*x-g*A-p*T)*U,e[7]=(h*A-u*x+f*T)*U,e[8]=(o*O-a*I+c*v)*U,e[9]=(n*I-t*O-r*v)*U,e[10]=(g*M-y*x+p*C)*U,e[11]=(d*x-h*M-f*C)*U,e[12]=(a*w-o*P-l*v)*U,e[13]=(t*P-n*w+s*v)*U,e[14]=(y*T-g*S-m*C)*U,e[15]=(h*S-d*T+u*C)*U,this}scale(e){let t=this.elements,n=e.x,s=e.y,r=e.z;return t[0]*=n,t[4]*=s,t[8]*=r,t[1]*=n,t[5]*=s,t[9]*=r,t[2]*=n,t[6]*=s,t[10]*=r,t[3]*=n,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),s=Math.sin(t),r=1-n,o=e.x,a=e.y,l=e.z,c=r*o,h=r*a;return this.set(c*o+n,c*a-s*l,c*l+s*a,0,c*a+s*l,h*a+n,h*l-s*o,0,c*l-s*a,h*l+s*o,r*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,s,r,o){return this.set(1,n,r,0,e,1,o,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){let s=this.elements,r=t._x,o=t._y,a=t._z,l=t._w,c=r+r,h=o+o,d=a+a,u=r*c,f=r*h,g=r*d,y=o*h,m=o*d,p=a*d,C=l*c,T=l*h,x=l*d,S=n.x,M=n.y,A=n.z;return s[0]=(1-(y+p))*S,s[1]=(f+x)*S,s[2]=(g-T)*S,s[3]=0,s[4]=(f-x)*M,s[5]=(1-(u+p))*M,s[6]=(m+C)*M,s[7]=0,s[8]=(g+T)*A,s[9]=(m-C)*A,s[10]=(1-(u+y))*A,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){let s=this.elements;e.x=s[12],e.y=s[13],e.z=s[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let o=Gi.set(s[0],s[1],s[2]).length(),a=Gi.set(s[4],s[5],s[6]).length(),l=Gi.set(s[8],s[9],s[10]).length();r<0&&(o=-o),hn.copy(this);let c=1/o,h=1/a,d=1/l;return hn.elements[0]*=c,hn.elements[1]*=c,hn.elements[2]*=c,hn.elements[4]*=h,hn.elements[5]*=h,hn.elements[6]*=h,hn.elements[8]*=d,hn.elements[9]*=d,hn.elements[10]*=d,t.setFromRotationMatrix(hn),n.x=o,n.y=a,n.z=l,this}makePerspective(e,t,n,s,r,o,a=pn,l=!1){let c=this.elements,h=2*r/(t-e),d=2*r/(n-s),u=(t+e)/(t-e),f=(n+s)/(n-s),g,y;if(l)g=r/(o-r),y=o*r/(o-r);else if(a===pn)g=-(o+r)/(o-r),y=-2*o*r/(o-r);else if(a===os)g=-o/(o-r),y=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=d,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=g,c[14]=y,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,s,r,o,a=pn,l=!1){let c=this.elements,h=2/(t-e),d=2/(n-s),u=-(t+e)/(t-e),f=-(n+s)/(n-s),g,y;if(l)g=1/(o-r),y=o/(o-r);else if(a===pn)g=-2/(o-r),y=-(o+r)/(o-r);else if(a===os)g=-1/(o-r),y=-r/(o-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=0,c[12]=u,c[1]=0,c[5]=d,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=g,c[14]=y,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},Gi=new R,hn=new rt,Pf=new R(0,0,0),If=new R(1,1,1),Jn=new R,zr=new R,Jt=new R,gh=new rt,_h=new Ft,Gn=class i{constructor(e=0,t=0,n=0,s=i.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let s=e.elements,r=s[0],o=s[4],a=s[8],l=s[1],c=s[5],h=s[9],d=s[2],u=s[6],f=s[10];switch(t){case"XYZ":this._y=Math.asin(Ze(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Ze(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(Ze(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-Ze(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,f),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Ze(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-Ze(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,f),this._y=0);break;default:De("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return gh.makeRotationFromQuaternion(e),this.setFromRotationMatrix(gh,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return _h.setFromEuler(this),this.setFromQuaternion(_h,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Gn.DEFAULT_ORDER="XYZ";var hs=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},Lf=0,xh=new R,Wi=new Ft,Fn=new rt,kr=new R,Is=new R,Df=new R,Nf=new Ft,vh=new R(1,0,0),yh=new R(0,1,0),bh=new R(0,0,1),Mh={type:"added"},Uf={type:"removed"},Xi={type:"childadded",child:null},dl={type:"childremoved",child:null},Dt=class i extends mn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Lf++}),this.uuid=Cn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=i.DEFAULT_UP.clone();let e=new R,t=new Gn,n=new Ft,s=new R(1,1,1);function r(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new rt},normalMatrix:{value:new Ge}}),this.matrix=new rt,this.matrixWorld=new rt,this.matrixAutoUpdate=i.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new hs,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Wi.setFromAxisAngle(e,t),this.quaternion.multiply(Wi),this}rotateOnWorldAxis(e,t){return Wi.setFromAxisAngle(e,t),this.quaternion.premultiply(Wi),this}rotateX(e){return this.rotateOnAxis(vh,e)}rotateY(e){return this.rotateOnAxis(yh,e)}rotateZ(e){return this.rotateOnAxis(bh,e)}translateOnAxis(e,t){return xh.copy(e).applyQuaternion(this.quaternion),this.position.add(xh.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(vh,e)}translateY(e){return this.translateOnAxis(yh,e)}translateZ(e){return this.translateOnAxis(bh,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Fn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?kr.copy(e):kr.set(e,t,n);let s=this.parent;this.updateWorldMatrix(!0,!1),Is.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Fn.lookAt(Is,kr,this.up):Fn.lookAt(kr,Is,this.up),this.quaternion.setFromRotationMatrix(Fn),s&&(Fn.extractRotation(s.matrixWorld),Wi.setFromRotationMatrix(Fn),this.quaternion.premultiply(Wi.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Fe("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Mh),Xi.child=e,this.dispatchEvent(Xi),Xi.child=null):Fe("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Uf),dl.child=e,this.dispatchEvent(dl),dl.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Fn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Fn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Fn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Mh),Xi.child=e,this.dispatchEvent(Xi),Xi.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,s=this.children.length;n<s;n++){let o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let s=this.children;for(let r=0,o=s.length;r<o;r++)s[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Is,e,Df),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Is,Nf,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,s=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*s,r[13]+=n-r[1]*t-r[5]*n-r[9]*s,r[14]+=s-r[2]*t-r[6]*n-r[10]*s}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let s=this.parent;if(e===!0&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){let r=this.children;for(let o=0,a=r.length;o<a;o++)r[o].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),this.static!==!1&&(s.static=this.static),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(a=>({...a})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){let d=l[c];r(e.shapes,d)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(r(e.materials,this.material[l]));s.material=a}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let a=0;a<this.children.length;a++)s.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let a=0;a<this.animations.length;a++){let l=this.animations[a];s.animations.push(r(e.animations,l))}}if(t){let a=o(e.geometries),l=o(e.materials),c=o(e.textures),h=o(e.images),d=o(e.shapes),u=o(e.skeletons),f=o(e.animations),g=o(e.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=s,n;function o(a){let l=[];for(let c in a){let h=a[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let s=e.children[n];this.add(s.clone())}return this}};Dt.DEFAULT_UP=new R(0,1,0);Dt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Dt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Vt=class extends Dt{constructor(){super(),this.isGroup=!0,this.type="Group"}},Ff={type:"move"},us=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Vt,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Vt,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new R,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new R),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Vt,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new R,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new R,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let s=null,r=null,o=null,a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(let y of e.hand.values()){let m=t.getJointPose(y,n),p=this._getHandJoint(c,y);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==null}let h=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],u=h.position.distanceTo(d.position),f=.02,g=.005;c.inputState.pinching&&u>f+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=f-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));a!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,s.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(s.linearVelocity)):a.hasLinearVelocity=!1,s.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(s.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Ff)))}return a!==null&&(a.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Vt;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Cu={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},Kn={h:0,s:0,l:0},Vr={h:0,s:0,l:0};function fl(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}var Ye=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=jt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Qe.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=Qe.workingColorSpace){return this.r=e,this.g=t,this.b=n,Qe.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=Qe.workingColorSpace){if(e=_c(e,1),t=Ze(t,0,1),n=Ze(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,o=2*n-r;this.r=fl(o,r,e+1/3),this.g=fl(o,r,e),this.b=fl(o,r,e-1/3)}return Qe.colorSpaceToWorking(this,s),this}setStyle(e,t=jt){function n(r){r!==void 0&&parseFloat(r)<1&&De("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,o=s[1],a=s[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:De("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=s[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(r,16),t);De("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=jt){let n=Cu[e.toLowerCase()];return n!==void 0?this.setHex(n,t):De("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Vn(e.r),this.g=Vn(e.g),this.b=Vn(e.b),this}copyLinearToSRGB(e){return this.r=rs(e.r),this.g=rs(e.g),this.b=rs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=jt){return Qe.workingToColorSpace(zt.copy(this),e),Math.round(Ze(zt.r*255,0,255))*65536+Math.round(Ze(zt.g*255,0,255))*256+Math.round(Ze(zt.b*255,0,255))}getHexString(e=jt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Qe.workingColorSpace){Qe.workingToColorSpace(zt.copy(this),t);let n=zt.r,s=zt.g,r=zt.b,o=Math.max(n,s,r),a=Math.min(n,s,r),l,c,h=(a+o)/2;if(a===o)l=0,c=0;else{let d=o-a;switch(c=h<=.5?d/(o+a):d/(2-o-a),o){case n:l=(s-r)/d+(s<r?6:0);break;case s:l=(r-n)/d+2;break;case r:l=(n-s)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Qe.workingColorSpace){return Qe.workingToColorSpace(zt.copy(this),t),e.r=zt.r,e.g=zt.g,e.b=zt.b,e}getStyle(e=jt){Qe.workingToColorSpace(zt.copy(this),e);let t=zt.r,n=zt.g,s=zt.b;return e!==jt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(Kn),this.setHSL(Kn.h+e,Kn.s+t,Kn.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Kn),e.getHSL(Vr);let n=ks(Kn.h,Vr.h,t),s=ks(Kn.s,Vr.s,t),r=ks(Kn.l,Vr.l,t);return this.setHSL(n,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*s,this.g=r[1]*t+r[4]*n+r[7]*s,this.b=r[2]*t+r[5]*n+r[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},zt=new Ye;Ye.NAMES=Cu;var ii=class extends Dt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Gn,this.environmentIntensity=1,this.environmentRotation=new Gn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},un=new R,On=new R,pl=new R,Bn=new R,qi=new R,Yi=new R,Sh=new R,ml=new R,gl=new R,_l=new R,xl=new gt,vl=new gt,yl=new gt,Tn=class i{constructor(e=new R,t=new R,n=new R){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),un.subVectors(e,t),s.cross(un);let r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){un.subVectors(s,t),On.subVectors(n,t),pl.subVectors(e,t);let o=un.dot(un),a=un.dot(On),l=un.dot(pl),c=On.dot(On),h=On.dot(pl),d=o*c-a*a;if(d===0)return r.set(0,0,0),null;let u=1/d,f=(c*l-a*h)*u,g=(o*h-a*l)*u;return r.set(1-f-g,g,f)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,Bn)===null?!1:Bn.x>=0&&Bn.y>=0&&Bn.x+Bn.y<=1}static getInterpolation(e,t,n,s,r,o,a,l){return this.getBarycoord(e,t,n,s,Bn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,Bn.x),l.addScaledVector(o,Bn.y),l.addScaledVector(a,Bn.z),l)}static getInterpolatedAttribute(e,t,n,s,r,o){return xl.setScalar(0),vl.setScalar(0),yl.setScalar(0),xl.fromBufferAttribute(e,t),vl.fromBufferAttribute(e,n),yl.fromBufferAttribute(e,s),o.setScalar(0),o.addScaledVector(xl,r.x),o.addScaledVector(vl,r.y),o.addScaledVector(yl,r.z),o}static isFrontFacing(e,t,n,s){return un.subVectors(n,t),On.subVectors(e,t),un.cross(On).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return un.subVectors(this.c,this.b),On.subVectors(this.a,this.b),un.cross(On).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return i.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return i.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return i.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return i.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return i.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,s=this.b,r=this.c,o,a;qi.subVectors(s,n),Yi.subVectors(r,n),ml.subVectors(e,n);let l=qi.dot(ml),c=Yi.dot(ml);if(l<=0&&c<=0)return t.copy(n);gl.subVectors(e,s);let h=qi.dot(gl),d=Yi.dot(gl);if(h>=0&&d<=h)return t.copy(s);let u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return o=l/(l-h),t.copy(n).addScaledVector(qi,o);_l.subVectors(e,r);let f=qi.dot(_l),g=Yi.dot(_l);if(g>=0&&f<=g)return t.copy(r);let y=f*c-l*g;if(y<=0&&c>=0&&g<=0)return a=c/(c-g),t.copy(n).addScaledVector(Yi,a);let m=h*g-f*d;if(m<=0&&d-h>=0&&f-g>=0)return Sh.subVectors(r,s),a=(d-h)/(d-h+(f-g)),t.copy(s).addScaledVector(Sh,a);let p=1/(m+y+u);return o=y*p,a=u*p,t.copy(n).addScaledVector(qi,o).addScaledVector(Yi,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},gn=class{constructor(e=new R(1/0,1/0,1/0),t=new R(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(dn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(dn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=dn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,dn):dn.fromBufferAttribute(r,o),dn.applyMatrix4(e.matrixWorld),this.expandByPoint(dn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Hr.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Hr.copy(n.boundingBox)),Hr.applyMatrix4(e.matrixWorld),this.union(Hr)}let s=e.children;for(let r=0,o=s.length;r<o;r++)this.expandByObject(s[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,dn),dn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ls),Gr.subVectors(this.max,Ls),Zi.subVectors(e.a,Ls),$i.subVectors(e.b,Ls),Ji.subVectors(e.c,Ls),jn.subVectors($i,Zi),Qn.subVectors(Ji,$i),yi.subVectors(Zi,Ji);let t=[0,-jn.z,jn.y,0,-Qn.z,Qn.y,0,-yi.z,yi.y,jn.z,0,-jn.x,Qn.z,0,-Qn.x,yi.z,0,-yi.x,-jn.y,jn.x,0,-Qn.y,Qn.x,0,-yi.y,yi.x,0];return!bl(t,Zi,$i,Ji,Gr)||(t=[1,0,0,0,1,0,0,0,1],!bl(t,Zi,$i,Ji,Gr))?!1:(Wr.crossVectors(jn,Qn),t=[Wr.x,Wr.y,Wr.z],bl(t,Zi,$i,Ji,Gr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,dn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(dn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(zn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),zn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),zn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),zn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),zn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),zn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),zn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),zn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(zn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},zn=[new R,new R,new R,new R,new R,new R,new R,new R],dn=new R,Hr=new gn,Zi=new R,$i=new R,Ji=new R,jn=new R,Qn=new R,yi=new R,Ls=new R,Gr=new R,Wr=new R,bi=new R;function bl(i,e,t,n,s){for(let r=0,o=i.length-3;r<=o;r+=3){bi.fromArray(i,r);let a=s.x*Math.abs(bi.x)+s.y*Math.abs(bi.y)+s.z*Math.abs(bi.z),l=e.dot(bi),c=t.dot(bi),h=n.dot(bi);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}var Et=new R,Xr=new te,Of=0,wt=class extends mn{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Of++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Ro,this.updateRanges=[],this.gpuType=bn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[e+s]=t.array[n+s];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Xr.fromBufferAttribute(this,t),Xr.applyMatrix3(e),this.setXY(t,Xr.x,Xr.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Et.fromBufferAttribute(this,t),Et.applyMatrix3(e),this.setXYZ(t,Et.x,Et.y,Et.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Et.fromBufferAttribute(this,t),Et.applyMatrix4(e),this.setXYZ(t,Et.x,Et.y,Et.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Et.fromBufferAttribute(this,t),Et.applyNormalMatrix(e),this.setXYZ(t,Et.x,Et.y,Et.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Et.fromBufferAttribute(this,t),Et.transformDirection(e),this.setXYZ(t,Et.x,Et.y,Et.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=fn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=st(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=fn(t,this.array)),t}setX(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=fn(t,this.array)),t}setY(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=fn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=fn(t,this.array)),t}setW(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array),s=st(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array),s=st(s,this.array),r=st(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Ro&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}};var $s=class extends wt{constructor(e,t,n){super(new Uint16Array(e),t,n)}};var Js=class extends wt{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var xt=class extends wt{constructor(e,t,n){super(new Float32Array(e),t,n)}},Bf=new gn,Ds=new R,Ml=new R,Ri=class{constructor(e=new R,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t!==void 0?n.copy(t):Bf.setFromPoints(e).getCenter(n);let s=0;for(let r=0,o=e.length;r<o;r++)s=Math.max(s,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Ds.subVectors(e,this.center);let t=Ds.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(Ds,s/n),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Ml.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ds.copy(e.center).add(Ml)),this.expandByPoint(Ds.copy(e.center).sub(Ml))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},zf=0,rn=new rt,Sl=new Dt,Ki=new R,Kt=new gn,Ns=new gn,It=new R,mt=class i extends mn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:zf++}),this.uuid=Cn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(cf(e)?Js:$s)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new Ge().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return rn.makeRotationFromQuaternion(e),this.applyMatrix4(rn),this}rotateX(e){return rn.makeRotationX(e),this.applyMatrix4(rn),this}rotateY(e){return rn.makeRotationY(e),this.applyMatrix4(rn),this}rotateZ(e){return rn.makeRotationZ(e),this.applyMatrix4(rn),this}translate(e,t,n){return rn.makeTranslation(e,t,n),this.applyMatrix4(rn),this}scale(e,t,n){return rn.makeScale(e,t,n),this.applyMatrix4(rn),this}lookAt(e){return Sl.lookAt(e),Sl.updateMatrix(),this.applyMatrix4(Sl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ki).negate(),this.translate(Ki.x,Ki.y,Ki.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let s=0,r=e.length;s<r;s++){let o=e[s];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new xt(n,3))}else{let n=Math.min(e.length,t.count);for(let s=0;s<n;s++){let r=e[s];t.setXYZ(s,r.x,r.y,r.z||0)}e.length>t.count&&De("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new gn);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Fe("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new R(-1/0,-1/0,-1/0),new R(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n<s;n++){let r=t[n];Kt.setFromBufferAttribute(r),this.morphTargetsRelative?(It.addVectors(this.boundingBox.min,Kt.min),this.boundingBox.expandByPoint(It),It.addVectors(this.boundingBox.max,Kt.max),this.boundingBox.expandByPoint(It)):(this.boundingBox.expandByPoint(Kt.min),this.boundingBox.expandByPoint(Kt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Fe('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 Ri);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Fe("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new R,1/0);return}if(e){let n=this.boundingSphere.center;if(Kt.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){let a=t[r];Ns.setFromBufferAttribute(a),this.morphTargetsRelative?(It.addVectors(Kt.min,Ns.min),Kt.expandByPoint(It),It.addVectors(Kt.max,Ns.max),Kt.expandByPoint(It)):(Kt.expandByPoint(Ns.min),Kt.expandByPoint(Ns.max))}Kt.getCenter(n);let s=0;for(let r=0,o=e.count;r<o;r++)It.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(It));if(t)for(let r=0,o=t.length;r<o;r++){let a=t[r],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)It.fromBufferAttribute(a,c),l&&(Ki.fromBufferAttribute(e,c),It.add(Ki)),s=Math.max(s,n.distanceToSquared(It))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&Fe('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Fe("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=t.position,s=t.normal,r=t.uv,o=this.getAttribute("tangent");(o===void 0||o.count!==n.count)&&(o=new wt(new Float32Array(4*n.count),4),this.setAttribute("tangent",o));let a=[],l=[];for(let v=0;v<n.count;v++)a[v]=new R,l[v]=new R;let c=new R,h=new R,d=new R,u=new te,f=new te,g=new te,y=new R,m=new R;function p(v,w,I){c.fromBufferAttribute(n,v),h.fromBufferAttribute(n,w),d.fromBufferAttribute(n,I),u.fromBufferAttribute(r,v),f.fromBufferAttribute(r,w),g.fromBufferAttribute(r,I),h.sub(c),d.sub(c),f.sub(u),g.sub(u);let P=1/(f.x*g.y-g.x*f.y);isFinite(P)&&(y.copy(h).multiplyScalar(g.y).addScaledVector(d,-f.y).multiplyScalar(P),m.copy(d).multiplyScalar(f.x).addScaledVector(h,-g.x).multiplyScalar(P),a[v].add(y),a[w].add(y),a[I].add(y),l[v].add(m),l[w].add(m),l[I].add(m))}let C=this.groups;C.length===0&&(C=[{start:0,count:e.count}]);for(let v=0,w=C.length;v<w;++v){let I=C[v],P=I.start,O=I.count;for(let q=P,Y=P+O;q<Y;q+=3)p(e.getX(q+0),e.getX(q+1),e.getX(q+2))}let T=new R,x=new R,S=new R,M=new R;function A(v){S.fromBufferAttribute(s,v),M.copy(S);let w=a[v];T.copy(w),T.sub(S.multiplyScalar(S.dot(w))).normalize(),x.crossVectors(M,w);let P=x.dot(l[v])<0?-1:1;o.setXYZW(v,T.x,T.y,T.z,P)}for(let v=0,w=C.length;v<w;++v){let I=C[v],P=I.start,O=I.count;for(let q=P,Y=P+O;q<Y;q+=3)A(e.getX(q+0)),A(e.getX(q+1)),A(e.getX(q+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new wt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let u=0,f=n.count;u<f;u++)n.setXYZ(u,0,0,0);let s=new R,r=new R,o=new R,a=new R,l=new R,c=new R,h=new R,d=new R;if(e)for(let u=0,f=e.count;u<f;u+=3){let g=e.getX(u+0),y=e.getX(u+1),m=e.getX(u+2);s.fromBufferAttribute(t,g),r.fromBufferAttribute(t,y),o.fromBufferAttribute(t,m),h.subVectors(o,r),d.subVectors(s,r),h.cross(d),a.fromBufferAttribute(n,g),l.fromBufferAttribute(n,y),c.fromBufferAttribute(n,m),a.add(h),l.add(h),c.add(h),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(y,l.x,l.y,l.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let u=0,f=t.count;u<f;u+=3)s.fromBufferAttribute(t,u+0),r.fromBufferAttribute(t,u+1),o.fromBufferAttribute(t,u+2),h.subVectors(o,r),d.subVectors(s,r),h.cross(d),n.setXYZ(u+0,h.x,h.y,h.z),n.setXYZ(u+1,h.x,h.y,h.z),n.setXYZ(u+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)It.fromBufferAttribute(e,t),It.normalize(),e.setXYZ(t,It.x,It.y,It.z)}toNonIndexed(){function e(a,l){let c=a.array,h=a.itemSize,d=a.normalized,u=new c.constructor(l.length*h),f=0,g=0;for(let y=0,m=l.length;y<m;y++){a.isInterleavedBufferAttribute?f=l[y]*a.data.stride+a.offset:f=l[y]*h;for(let p=0;p<h;p++)u[g++]=c[f++]}return new wt(u,h,d)}if(this.index===null)return De("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new i,n=this.index.array,s=this.attributes;for(let a in s){let l=s[a],c=e(l,n);t.setAttribute(a,c)}let r=this.morphAttributes;for(let a in r){let l=[],c=r[a];for(let h=0,d=c.length;h<d;h++){let u=c[h],f=e(u,n);l.push(f)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,l=o.length;a<l;a++){let c=o[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let l in n){let c=n[l];e.data.attributes[l]=c.toJSON(e.data)}let s={},r=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],h=[];for(let d=0,u=c.length;d<u;d++){let f=c[d];h.push(f.toJSON(e.data))}h.length>0&&(s[l]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere=a.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let s=e.attributes;for(let c in s){let h=s[c];this.setAttribute(c,h.clone(t))}let r=e.morphAttributes;for(let c in r){let h=[],d=r[c];for(let u=0,f=d.length;u<f;u++)h.push(d[u].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let c=0,h=o.length;c<h;c++){let d=o[c];this.addGroup(d.start,d.count,d.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}},Do=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Ro,this.updateRanges=[],this.version=0,this.uuid=Cn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let s=0,r=this.stride;s<r;s++)this.array[e+s]=t.array[n+s];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Cn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Cn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.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}}},Wt=new R,Ks=class i{constructor(e,t,n,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Wt.fromBufferAttribute(this,t),Wt.applyMatrix4(e),this.setXYZ(t,Wt.x,Wt.y,Wt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Wt.fromBufferAttribute(this,t),Wt.applyNormalMatrix(e),this.setXYZ(t,Wt.x,Wt.y,Wt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Wt.fromBufferAttribute(this,t),Wt.transformDirection(e),this.setXYZ(t,Wt.x,Wt.y,Wt.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=fn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=st(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=fn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=fn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=fn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=fn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),n=st(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),n=st(n,this.array),s=st(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),n=st(n,this.array),s=st(s,this.array),r=st(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Ys("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return new wt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new i(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Ys("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},kf=0,Pn=class extends mn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:kf++}),this.uuid=Cn(),this.name="",this.type="Material",this.blending=Ai,this.side=Hn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=_o,this.blendDst=xo,this.blendEquation=ni,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ye(0,0,0),this.blendAlpha=0,this.depthFunc=Ci,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=kl,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ei,this.stencilZFail=Ei,this.stencilZPass=Ei,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(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){De(`Material: parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){De(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Ai&&(n.blending=this.blending),this.side!==Hn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==_o&&(n.blendSrc=this.blendSrc),this.blendDst!==xo&&(n.blendDst=this.blendDst),this.blendEquation!==ni&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Ci&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==kl&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ei&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ei&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ei&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){let o=[];for(let a in r){let l=r[a];delete l.metadata,o.push(l)}return o}if(t){let r=s(e.textures),o=s(e.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Ye().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new te().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new te().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let s=t.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},ds=class extends Pn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ye(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},ji,Us=new R,Qi=new R,es=new R,ts=new te,Fs=new te,Ru=new rt,qr=new R,Os=new R,Yr=new R,Eh=new te,El=new te,wh=new te,js=class extends Dt{constructor(e=new ds){if(super(),this.isSprite=!0,this.type="Sprite",ji===void 0){ji=new mt;let t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Do(t,5);ji.setIndex([0,1,2,0,2,3]),ji.setAttribute("position",new Ks(n,3,0,!1)),ji.setAttribute("uv",new Ks(n,2,3,!1))}this.geometry=ji,this.material=e,this.center=new te(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Fe('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Qi.setFromMatrixScale(this.matrixWorld),Ru.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),es.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Qi.multiplyScalar(-es.z);let n=this.material.rotation,s,r;n!==0&&(r=Math.cos(n),s=Math.sin(n));let o=this.center;Zr(qr.set(-.5,-.5,0),es,o,Qi,s,r),Zr(Os.set(.5,-.5,0),es,o,Qi,s,r),Zr(Yr.set(.5,.5,0),es,o,Qi,s,r),Eh.set(0,0),El.set(1,0),wh.set(1,1);let a=e.ray.intersectTriangle(qr,Os,Yr,!1,Us);if(a===null&&(Zr(Os.set(-.5,.5,0),es,o,Qi,s,r),El.set(0,1),a=e.ray.intersectTriangle(qr,Yr,Os,!1,Us),a===null))return;let l=e.ray.origin.distanceTo(Us);l<e.near||l>e.far||t.push({distance:l,point:Us.clone(),uv:Tn.getInterpolation(Us,qr,Os,Yr,Eh,El,wh,new te),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};function Zr(i,e,t,n,s,r){ts.subVectors(i,t).addScalar(.5).multiply(n),s!==void 0?(Fs.x=r*ts.x-s*ts.y,Fs.y=s*ts.x+r*ts.y):Fs.copy(ts),i.copy(e),i.x+=Fs.x,i.y+=Fs.y,i.applyMatrix4(Ru)}var kn=new R,wl=new R,$r=new R,ei=new R,Tl=new R,Jr=new R,Al=new R,si=class{constructor(e=new R,t=new R(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,kn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=kn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(kn.copy(this.origin).addScaledVector(this.direction,t),kn.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){wl.copy(e).add(t).multiplyScalar(.5),$r.copy(t).sub(e).normalize(),ei.copy(this.origin).sub(wl);let r=e.distanceTo(t)*.5,o=-this.direction.dot($r),a=ei.dot(this.direction),l=-ei.dot($r),c=ei.lengthSq(),h=Math.abs(1-o*o),d,u,f,g;if(h>0)if(d=o*l-a,u=o*a-l,g=r*h,d>=0)if(u>=-g)if(u<=g){let y=1/h;d*=y,u*=y,f=d*(d+o*u+2*a)+u*(o*d+u+2*l)+c}else u=r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;else u=-r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;else u<=-g?(d=Math.max(0,-(-o*r+a)),u=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+u*(u+2*l)+c):u<=g?(d=0,u=Math.min(Math.max(-r,-l),r),f=u*(u+2*l)+c):(d=Math.max(0,-(o*r+a)),u=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+u*(u+2*l)+c);else u=o>0?-r:r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(wl).addScaledVector($r,u),f}intersectSphere(e,t){kn.subVectors(e.center,this.origin);let n=kn.dot(this.direction),s=kn.dot(kn)-n*n,r=e.radius*e.radius;if(s>r)return null;let o=Math.sqrt(r-s),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,r,o,a,l,c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return c>=0?(n=(e.min.x-u.x)*c,s=(e.max.x-u.x)*c):(n=(e.max.x-u.x)*c,s=(e.min.x-u.x)*c),h>=0?(r=(e.min.y-u.y)*h,o=(e.max.y-u.y)*h):(r=(e.max.y-u.y)*h,o=(e.min.y-u.y)*h),n>o||r>s||((r>n||isNaN(n))&&(n=r),(o<s||isNaN(s))&&(s=o),d>=0?(a=(e.min.z-u.z)*d,l=(e.max.z-u.z)*d):(a=(e.max.z-u.z)*d,l=(e.min.z-u.z)*d),n>l||a>s)||((a>n||n!==n)&&(n=a),(l<s||s!==s)&&(s=l),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,kn)!==null}intersectTriangle(e,t,n,s,r){Tl.subVectors(t,e),Jr.subVectors(n,e),Al.crossVectors(Tl,Jr);let o=this.direction.dot(Al),a;if(o>0){if(s)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ei.subVectors(this.origin,e);let l=a*this.direction.dot(Jr.crossVectors(ei,Jr));if(l<0)return null;let c=a*this.direction.dot(Tl.cross(ei));if(c<0||l+c>o)return null;let h=-a*ei.dot(Al);return h<0?null:this.at(h/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},an=class extends Pn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ye(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 Gn,this.combine=ec,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Th=new rt,Mi=new si,Kr=new Ri,Ah=new R,jr=new R,Qr=new R,eo=new R,Cl=new R,to=new R,Ch=new R,no=new R,Tt=class extends Dt{constructor(e=new mt,t=new an){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){let n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(s,e);let a=this.morphTargetInfluences;if(r&&a){to.set(0,0,0);for(let l=0,c=r.length;l<c;l++){let h=a[l],d=r[l];h!==0&&(Cl.fromBufferAttribute(d,e),o?to.addScaledVector(Cl,h):to.addScaledVector(Cl.sub(t),h))}t.add(to)}return t}raycast(e,t){let n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Kr.copy(n.boundingSphere),Kr.applyMatrix4(r),Mi.copy(e.ray).recast(e.near),!(Kr.containsPoint(Mi.origin)===!1&&(Mi.intersectSphere(Kr,Ah)===null||Mi.origin.distanceToSquared(Ah)>(e.far-e.near)**2))&&(Th.copy(r).invert(),Mi.copy(e.ray).applyMatrix4(Th),!(n.boundingBox!==null&&Mi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Mi)))}_computeIntersections(e,t,n){let s,r=this.geometry,o=this.material,a=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,f=r.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,y=u.length;g<y;g++){let m=u[g],p=o[m.materialIndex],C=Math.max(m.start,f.start),T=Math.min(a.count,Math.min(m.start+m.count,f.start+f.count));for(let x=C,S=T;x<S;x+=3){let M=a.getX(x),A=a.getX(x+1),v=a.getX(x+2);s=io(this,p,e,n,c,h,d,M,A,v),s&&(s.faceIndex=Math.floor(x/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{let g=Math.max(0,f.start),y=Math.min(a.count,f.start+f.count);for(let m=g,p=y;m<p;m+=3){let C=a.getX(m),T=a.getX(m+1),x=a.getX(m+2);s=io(this,o,e,n,c,h,d,C,T,x),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}else if(l!==void 0)if(Array.isArray(o))for(let g=0,y=u.length;g<y;g++){let m=u[g],p=o[m.materialIndex],C=Math.max(m.start,f.start),T=Math.min(l.count,Math.min(m.start+m.count,f.start+f.count));for(let x=C,S=T;x<S;x+=3){let M=x,A=x+1,v=x+2;s=io(this,p,e,n,c,h,d,M,A,v),s&&(s.faceIndex=Math.floor(x/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{let g=Math.max(0,f.start),y=Math.min(l.count,f.start+f.count);for(let m=g,p=y;m<p;m+=3){let C=m,T=m+1,x=m+2;s=io(this,o,e,n,c,h,d,C,T,x),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}}};function Vf(i,e,t,n,s,r,o,a){let l;if(e.side===qt?l=n.intersectTriangle(o,r,s,!0,a):l=n.intersectTriangle(s,r,o,e.side===Hn,a),l===null)return null;no.copy(a),no.applyMatrix4(i.matrixWorld);let c=t.ray.origin.distanceTo(no);return c<t.near||c>t.far?null:{distance:c,point:no.clone(),object:i}}function io(i,e,t,n,s,r,o,a,l,c){i.getVertexPosition(a,jr),i.getVertexPosition(l,Qr),i.getVertexPosition(c,eo);let h=Vf(i,e,t,n,jr,Qr,eo,Ch);if(h){let d=new R;Tn.getBarycoord(Ch,jr,Qr,eo,d),s&&(h.uv=Tn.getInterpolatedAttribute(s,a,l,c,d,new te)),r&&(h.uv1=Tn.getInterpolatedAttribute(r,a,l,c,d,new te)),o&&(h.normal=Tn.getInterpolatedAttribute(o,a,l,c,d,new R),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let u={a,b:l,c,normal:new R,materialIndex:0};Tn.getNormal(jr,Qr,eo,u.normal),h.face=u,h.barycoord=d}return h}var No=class extends Xt{constructor(e=null,t=1,n=1,s,r,o,a,l,c=Lt,h=Lt,d,u){super(null,o,a,l,c,h,s,r,d,u),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Rl=new R,Hf=new R,Gf=new Ge,on=class{constructor(e=new R(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let s=Rl.subVectors(n,t).cross(Hf.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let s=e.delta(Rl),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let o=-(e.start.dot(this.normal)+this.constant)/r;return n===!0&&(o<0||o>1)?null:t.copy(e.start).addScaledVector(s,o)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||Gf.getNormalMatrix(e),s=this.coplanarPoint(Rl).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},Si=new Ri,Wf=new te(.5,.5),so=new R,fs=class{constructor(e=new on,t=new on,n=new on,s=new on,r=new on,o=new on){this.planes=[e,t,n,s,r,o]}set(e,t,n,s,r,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(s),a[4].copy(r),a[5].copy(o),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=pn,n=!1){let s=this.planes,r=e.elements,o=r[0],a=r[1],l=r[2],c=r[3],h=r[4],d=r[5],u=r[6],f=r[7],g=r[8],y=r[9],m=r[10],p=r[11],C=r[12],T=r[13],x=r[14],S=r[15];if(s[0].setComponents(c-o,f-h,p-g,S-C).normalize(),s[1].setComponents(c+o,f+h,p+g,S+C).normalize(),s[2].setComponents(c+a,f+d,p+y,S+T).normalize(),s[3].setComponents(c-a,f-d,p-y,S-T).normalize(),n)s[4].setComponents(l,u,m,x).normalize(),s[5].setComponents(c-l,f-u,p-m,S-x).normalize();else if(s[4].setComponents(c-l,f-u,p-m,S-x).normalize(),t===pn)s[5].setComponents(c+l,f+u,p+m,S+x).normalize();else if(t===os)s[5].setComponents(l,u,m,x).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Si.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Si.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Si)}intersectsSprite(e){Si.center.set(0,0,0);let t=Wf.distanceTo(e.center);return Si.radius=.7071067811865476+t,Si.applyMatrix4(e.matrixWorld),this.intersectsSphere(Si)}intersectsSphere(e){let t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let s=t[n];if(so.x=s.normal.x>0?e.max.x:e.min.x,so.y=s.normal.y>0?e.max.y:e.min.y,so.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(so)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};var _n=class extends Pn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ye(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},Uo=new R,Fo=new R,Rh=new rt,Bs=new si,ro=new Ri,Pl=new R,Ph=new R,Oo=class extends Dt{constructor(e=new mt,t=new _n){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let s=1,r=t.count;s<r;s++)Uo.fromBufferAttribute(t,s-1),Fo.fromBufferAttribute(t,s),n[s]=n[s-1],n[s]+=Uo.distanceTo(Fo);e.setAttribute("lineDistance",new xt(n,1))}else De("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let n=this.geometry,s=this.matrixWorld,r=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),ro.copy(n.boundingSphere),ro.applyMatrix4(s),ro.radius+=r,e.ray.intersectsSphere(ro)===!1)return;Rh.copy(s).invert(),Bs.copy(e.ray).applyMatrix4(Rh);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,h=n.index,u=n.attributes.position;if(h!==null){let f=Math.max(0,o.start),g=Math.min(h.count,o.start+o.count);for(let y=f,m=g-1;y<m;y+=c){let p=h.getX(y),C=h.getX(y+1),T=oo(this,e,Bs,l,p,C,y);T&&t.push(T)}if(this.isLineLoop){let y=h.getX(g-1),m=h.getX(f),p=oo(this,e,Bs,l,y,m,g-1);p&&t.push(p)}}else{let f=Math.max(0,o.start),g=Math.min(u.count,o.start+o.count);for(let y=f,m=g-1;y<m;y+=c){let p=oo(this,e,Bs,l,y,y+1,y);p&&t.push(p)}if(this.isLineLoop){let y=oo(this,e,Bs,l,g-1,f,g-1);y&&t.push(y)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};function oo(i,e,t,n,s,r,o){let a=i.geometry.attributes.position;if(Uo.fromBufferAttribute(a,s),Fo.fromBufferAttribute(a,r),t.distanceSqToSegment(Uo,Fo,Pl,Ph)>n)return;Pl.applyMatrix4(i.matrixWorld);let c=e.ray.origin.distanceTo(Pl);if(!(c<e.near||c>e.far))return{distance:c,point:Ph.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}var Ih=new R,Lh=new R,xn=class extends Oo{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let s=0,r=t.count;s<r;s+=2)Ih.fromBufferAttribute(t,s),Lh.fromBufferAttribute(t,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+Ih.distanceTo(Lh);e.setAttribute("lineDistance",new xt(n,1))}else De("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Qs=class extends Xt{constructor(e=[],t=fi,n,s,r,o,a,l,c,h){super(e,t,n,s,r,o,a,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Pi=class extends Xt{constructor(e,t,n,s,r,o,a,l,c){super(e,t,n,s,r,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}};var Wn=class extends Xt{constructor(e,t,n=yn,s,r,o,a=Lt,l=Lt,c,h=Rn,d=1){if(h!==Rn&&h!==mi)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let u={width:e,height:t,depth:d};super(u,s,r,o,a,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new cs(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},Bo=class extends Wn{constructor(e,t=yn,n=fi,s,r,o=Lt,a=Lt,l,c=Rn){let h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,t,n,s,r,o,a,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},er=class extends Xt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},ps=class i extends mt{constructor(e=1,t=1,n=1,s=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:o};let a=this;s=Math.floor(s),r=Math.floor(r),o=Math.floor(o);let l=[],c=[],h=[],d=[],u=0,f=0;g("z","y","x",-1,-1,n,t,e,o,r,0),g("z","y","x",1,-1,n,t,-e,o,r,1),g("x","z","y",1,1,e,n,t,s,o,2),g("x","z","y",1,-1,e,n,-t,s,o,3),g("x","y","z",1,-1,e,t,n,s,r,4),g("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new xt(c,3)),this.setAttribute("normal",new xt(h,3)),this.setAttribute("uv",new xt(d,2));function g(y,m,p,C,T,x,S,M,A,v,w){let I=x/A,P=S/v,O=x/2,q=S/2,Y=M/2,U=A+1,G=v+1,H=0,j=0,se=new R;for(let ue=0;ue<G;ue++){let le=ue*P-q;for(let Me=0;Me<U;Me++){let Je=Me*I-O;se[y]=Je*C,se[m]=le*T,se[p]=Y,c.push(se.x,se.y,se.z),se[y]=0,se[m]=0,se[p]=M>0?1:-1,h.push(se.x,se.y,se.z),d.push(Me/A),d.push(1-ue/v),H+=1}}for(let ue=0;ue<v;ue++)for(let le=0;le<A;le++){let Me=u+le+U*ue,Je=u+le+U*(ue+1),ct=u+(le+1)+U*(ue+1),et=u+(le+1)+U*ue;l.push(Me,Je,et),l.push(Je,ct,et),j+=6}a.addGroup(f,j,w),f+=j,u+=H}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};var ao=new R,lo=new R,Il=new R,co=new Tn,tr=class extends mt{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){let s=Math.pow(10,4),r=Math.cos(ss*t),o=e.getIndex(),a=e.getAttribute("position"),l=o?o.count:a.count,c=[0,0,0],h=["a","b","c"],d=new Array(3),u={},f=[];for(let g=0;g<l;g+=3){o?(c[0]=o.getX(g),c[1]=o.getX(g+1),c[2]=o.getX(g+2)):(c[0]=g,c[1]=g+1,c[2]=g+2);let{a:y,b:m,c:p}=co;if(y.fromBufferAttribute(a,c[0]),m.fromBufferAttribute(a,c[1]),p.fromBufferAttribute(a,c[2]),co.getNormal(Il),d[0]=`${Math.round(y.x*s)},${Math.round(y.y*s)},${Math.round(y.z*s)}`,d[1]=`${Math.round(m.x*s)},${Math.round(m.y*s)},${Math.round(m.z*s)}`,d[2]=`${Math.round(p.x*s)},${Math.round(p.y*s)},${Math.round(p.z*s)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let C=0;C<3;C++){let T=(C+1)%3,x=d[C],S=d[T],M=co[h[C]],A=co[h[T]],v=`${x}_${S}`,w=`${S}_${x}`;w in u&&u[w]?(Il.dot(u[w].normal)<=r&&(f.push(M.x,M.y,M.z),f.push(A.x,A.y,A.z)),u[w]=null):v in u||(u[v]={index0:c[C],index1:c[T],normal:Il.clone()})}}for(let g in u)if(u[g]){let{index0:y,index1:m}=u[g];ao.fromBufferAttribute(a,y),lo.fromBufferAttribute(a,m),f.push(ao.x,ao.y,ao.z),f.push(lo.x,lo.y,lo.z)}this.setAttribute("position",new xt(f,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},en=class{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){De("Curve: .getPoint() not implemented.")}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],n,s=this.getPoint(0),r=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),r+=n.distanceTo(s),t.push(r),s=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let n=this.getLengths(),s=0,r=n.length,o;t?o=t:o=e*n[r-1];let a=0,l=r-1,c;for(;a<=l;)if(s=Math.floor(a+(l-a)/2),c=n[s]-o,c<0)a=s+1;else if(c>0)l=s-1;else{l=s;break}if(s=l,n[s]===o)return s/(r-1);let h=n[s],u=n[s+1]-h,f=(o-h)/u;return(s+f)/(r-1)}getTangent(e,t){let s=e-1e-4,r=e+1e-4;s<0&&(s=0),r>1&&(r=1);let o=this.getPoint(s),a=this.getPoint(r),l=t||(o.isVector2?new te:new R);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new R,s=[],r=[],o=[],a=new R,l=new rt;for(let f=0;f<=e;f++){let g=f/e;s[f]=this.getTangentAt(g,new R)}r[0]=new R,o[0]=new R;let c=Number.MAX_VALUE,h=Math.abs(s[0].x),d=Math.abs(s[0].y),u=Math.abs(s[0].z);h<=c&&(c=h,n.set(1,0,0)),d<=c&&(c=d,n.set(0,1,0)),u<=c&&n.set(0,0,1),a.crossVectors(s[0],n).normalize(),r[0].crossVectors(s[0],a),o[0].crossVectors(s[0],r[0]);for(let f=1;f<=e;f++){if(r[f]=r[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(s[f-1],s[f]),a.length()>Number.EPSILON){a.normalize();let g=Math.acos(Ze(s[f-1].dot(s[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(a,g))}o[f].crossVectors(s[f],r[f])}if(t===!0){let f=Math.acos(Ze(r[0].dot(r[e]),-1,1));f/=e,s[0].dot(a.crossVectors(r[0],r[e]))>0&&(f=-f);for(let g=1;g<=e;g++)r[g].applyMatrix4(l.makeRotationAxis(s[g],f*g)),o[g].crossVectors(s[g],r[g])}return{tangents:s,normals:r,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},ms=class extends en{constructor(e=0,t=0,n=1,s=1,r=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t=new te){let n=t,s=Math.PI*2,r=this.aEndAngle-this.aStartAngle,o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=s;for(;r>s;)r-=s;r<Number.EPSILON&&(o?r=0:r=s),this.aClockwise===!0&&!o&&(r===s?r=-s:r=r-s);let a=this.aStartAngle+e*r,l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let h=Math.cos(this.aRotation),d=Math.sin(this.aRotation),u=l-this.aX,f=c-this.aY;l=u*h-f*d+this.aX,c=u*d+f*h+this.aY}return n.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},zo=class extends ms{constructor(e,t,n,s,r,o){super(e,t,n,n,s,r,o),this.isArcCurve=!0,this.type="ArcCurve"}};function vc(){let i=0,e=0,t=0,n=0;function s(r,o,a,l){i=r,e=a,t=-3*r+3*o-2*a-l,n=2*r-2*o+a+l}return{initCatmullRom:function(r,o,a,l,c){s(o,a,c*(a-r),c*(l-o))},initNonuniformCatmullRom:function(r,o,a,l,c,h,d){let u=(o-r)/c-(a-r)/(c+h)+(a-o)/h,f=(a-o)/h-(l-o)/(h+d)+(l-a)/d;u*=h,f*=h,s(o,a,u,f)},calc:function(r){let o=r*r,a=o*r;return i+e*r+t*o+n*a}}}var Dh=new R,Nh=new R,Ll=new vc,Dl=new vc,Nl=new vc,ko=class extends en{constructor(e=[],t=!1,n="centripetal",s=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=s}getPoint(e,t=new R){let n=t,s=this.points,r=s.length,o=(r-(this.closed?0:1))*e,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/r)+1)*r:l===0&&a===r-1&&(a=r-2,l=1);let c,h;this.closed||a>0?c=s[(a-1)%r]:(Nh.subVectors(s[0],s[1]).add(s[0]),c=Nh);let d=s[a%r],u=s[(a+1)%r];if(this.closed||a+2<r?h=s[(a+2)%r]:(Dh.subVectors(s[r-1],s[r-2]).add(s[r-1]),h=Dh),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,g=Math.pow(c.distanceToSquared(d),f),y=Math.pow(d.distanceToSquared(u),f),m=Math.pow(u.distanceToSquared(h),f);y<1e-4&&(y=1),g<1e-4&&(g=y),m<1e-4&&(m=y),Ll.initNonuniformCatmullRom(c.x,d.x,u.x,h.x,g,y,m),Dl.initNonuniformCatmullRom(c.y,d.y,u.y,h.y,g,y,m),Nl.initNonuniformCatmullRom(c.z,d.z,u.z,h.z,g,y,m)}else this.curveType==="catmullrom"&&(Ll.initCatmullRom(c.x,d.x,u.x,h.x,this.tension),Dl.initCatmullRom(c.y,d.y,u.y,h.y,this.tension),Nl.initCatmullRom(c.z,d.z,u.z,h.z,this.tension));return n.set(Ll.calc(l),Dl.calc(l),Nl.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let s=e.points[t];this.points.push(s.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let s=this.points[t];e.points.push(s.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let s=e.points[t];this.points.push(new R().fromArray(s))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function Uh(i,e,t,n,s){let r=(n-e)*.5,o=(s-t)*.5,a=i*i,l=i*a;return(2*t-2*n+r+o)*l+(-3*t+3*n-2*r-o)*a+r*i+t}function Xf(i,e){let t=1-i;return t*t*e}function qf(i,e){return 2*(1-i)*i*e}function Yf(i,e){return i*i*e}function Vs(i,e,t,n){return Xf(i,e)+qf(i,t)+Yf(i,n)}function Zf(i,e){let t=1-i;return t*t*t*e}function $f(i,e){let t=1-i;return 3*t*t*i*e}function Jf(i,e){return 3*(1-i)*i*i*e}function Kf(i,e){return i*i*i*e}function Hs(i,e,t,n,s){return Zf(i,e)+$f(i,t)+Jf(i,n)+Kf(i,s)}var nr=class extends en{constructor(e=new te,t=new te,n=new te,s=new te){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=s}getPoint(e,t=new te){let n=t,s=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(Hs(e,s.x,r.x,o.x,a.x),Hs(e,s.y,r.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Vo=class extends en{constructor(e=new R,t=new R,n=new R,s=new R){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=s}getPoint(e,t=new R){let n=t,s=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(Hs(e,s.x,r.x,o.x,a.x),Hs(e,s.y,r.y,o.y,a.y),Hs(e,s.z,r.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ir=class extends en{constructor(e=new te,t=new te){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new te){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new te){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Ho=class extends en{constructor(e=new R,t=new R){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new R){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new R){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},sr=class extends en{constructor(e=new te,t=new te,n=new te){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new te){let n=t,s=this.v0,r=this.v1,o=this.v2;return n.set(Vs(e,s.x,r.x,o.x),Vs(e,s.y,r.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Go=class extends en{constructor(e=new R,t=new R,n=new R){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new R){let n=t,s=this.v0,r=this.v1,o=this.v2;return n.set(Vs(e,s.x,r.x,o.x),Vs(e,s.y,r.y,o.y),Vs(e,s.z,r.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},rr=class extends en{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new te){let n=t,s=this.points,r=(s.length-1)*e,o=Math.floor(r),a=r-o,l=s[o===0?o:o-1],c=s[o],h=s[o>s.length-2?s.length-1:o+1],d=s[o>s.length-3?s.length-1:o+2];return n.set(Uh(a,l.x,c.x,h.x,d.x),Uh(a,l.y,c.y,h.y,d.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let s=e.points[t];this.points.push(s.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let s=this.points[t];e.points.push(s.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let s=e.points[t];this.points.push(new te().fromArray(s))}return this}},Vl=Object.freeze({__proto__:null,ArcCurve:zo,CatmullRomCurve3:ko,CubicBezierCurve:nr,CubicBezierCurve3:Vo,EllipseCurve:ms,LineCurve:ir,LineCurve3:Ho,QuadraticBezierCurve:sr,QuadraticBezierCurve3:Go,SplineCurve:rr}),Wo=class extends en{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Vl[n](t,e))}return this}getPoint(e,t){let n=e*this.getLength(),s=this.getCurveLengths(),r=0;for(;r<s.length;){if(s[r]>=n){let o=s[r]-n,a=this.curves[r],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,t)}r++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,s=this.curves.length;n<s;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],n;for(let s=0,r=this.curves;s<r.length;s++){let o=r[s],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let c=0;c<l.length;c++){let h=l[c];n&&n.equals(h)||(t.push(h),n=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let s=e.curves[t];this.curves.push(s.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let s=this.curves[t];e.curves.push(s.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let s=e.curves[t];this.curves.push(new Vl[s.type]().fromJSON(s))}return this}},Ii=class extends Wo{constructor(e){super(),this.type="Path",this.currentPoint=new te,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let n=new ir(this.currentPoint.clone(),new te(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,s){let r=new sr(this.currentPoint.clone(),new te(e,t),new te(n,s));return this.curves.push(r),this.currentPoint.set(n,s),this}bezierCurveTo(e,t,n,s,r,o){let a=new nr(this.currentPoint.clone(),new te(e,t),new te(n,s),new te(r,o));return this.curves.push(a),this.currentPoint.set(r,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),n=new rr(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,s,r,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,n,s,r,o),this}absarc(e,t,n,s,r,o){return this.absellipse(e,t,n,n,s,r,o),this}ellipse(e,t,n,s,r,o,a,l){let c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+c,t+h,n,s,r,o,a,l),this}absellipse(e,t,n,s,r,o,a,l){let c=new ms(e,t,n,s,r,o,a,l);if(this.curves.length>0){let d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);let h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},gs=class extends Ii{constructor(e){super(e),this.uuid=Cn(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,s=this.holes.length;n<s;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let s=e.holes[t];this.holes.push(s.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let s=this.holes[t];e.holes.push(s.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let s=e.holes[t];this.holes.push(new Ii().fromJSON(s))}return this}};function jf(i,e,t=2){let n=e&&e.length,s=n?e[0]*t:i.length,r=Pu(i,0,s,t,!0),o=[];if(!r||r.next===r.prev)return o;let a,l,c;if(n&&(r=ip(i,e,r,t)),i.length>80*t){a=i[0],l=i[1];let h=a,d=l;for(let u=t;u<s;u+=t){let f=i[u],g=i[u+1];f<a&&(a=f),g<l&&(l=g),f>h&&(h=f),g>d&&(d=g)}c=Math.max(h-a,d-l),c=c!==0?32767/c:0}return or(r,o,t,a,l,c,0),o}function Pu(i,e,t,n,s){let r;if(s===pp(i,e,t,n)>0)for(let o=e;o<t;o+=n)r=Fh(o/n|0,i[o],i[o+1],r);else for(let o=t-n;o>=e;o-=n)r=Fh(o/n|0,i[o],i[o+1],r);return r&&_s(r,r.next)&&(lr(r),r=r.next),r}function Li(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(_s(t,t.next)||_t(t.prev,t,t.next)===0)){if(lr(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function or(i,e,t,n,s,r,o){if(!i)return;!o&&r&&lp(i,n,s,r);let a=i;for(;i.prev!==i.next;){let l=i.prev,c=i.next;if(r?ep(i,n,s,r):Qf(i)){e.push(l.i,i.i,c.i),lr(i),i=c.next,a=c.next;continue}if(i=c,i===a){o?o===1?(i=tp(Li(i),e),or(i,e,t,n,s,r,2)):o===2&&np(i,e,t,n,s,r):or(Li(i),e,t,n,s,r,1);break}}}function Qf(i){let e=i.prev,t=i,n=i.next;if(_t(e,t,n)>=0)return!1;let s=e.x,r=t.x,o=n.x,a=e.y,l=t.y,c=n.y,h=Math.min(s,r,o),d=Math.min(a,l,c),u=Math.max(s,r,o),f=Math.max(a,l,c),g=n.next;for(;g!==e;){if(g.x>=h&&g.x<=u&&g.y>=d&&g.y<=f&&zs(s,a,r,l,o,c,g.x,g.y)&&_t(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function ep(i,e,t,n){let s=i.prev,r=i,o=i.next;if(_t(s,r,o)>=0)return!1;let a=s.x,l=r.x,c=o.x,h=s.y,d=r.y,u=o.y,f=Math.min(a,l,c),g=Math.min(h,d,u),y=Math.max(a,l,c),m=Math.max(h,d,u),p=Hl(f,g,e,t,n),C=Hl(y,m,e,t,n),T=i.prevZ,x=i.nextZ;for(;T&&T.z>=p&&x&&x.z<=C;){if(T.x>=f&&T.x<=y&&T.y>=g&&T.y<=m&&T!==s&&T!==o&&zs(a,h,l,d,c,u,T.x,T.y)&&_t(T.prev,T,T.next)>=0||(T=T.prevZ,x.x>=f&&x.x<=y&&x.y>=g&&x.y<=m&&x!==s&&x!==o&&zs(a,h,l,d,c,u,x.x,x.y)&&_t(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;T&&T.z>=p;){if(T.x>=f&&T.x<=y&&T.y>=g&&T.y<=m&&T!==s&&T!==o&&zs(a,h,l,d,c,u,T.x,T.y)&&_t(T.prev,T,T.next)>=0)return!1;T=T.prevZ}for(;x&&x.z<=C;){if(x.x>=f&&x.x<=y&&x.y>=g&&x.y<=m&&x!==s&&x!==o&&zs(a,h,l,d,c,u,x.x,x.y)&&_t(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function tp(i,e){let t=i;do{let n=t.prev,s=t.next.next;!_s(n,s)&&Lu(n,t,t.next,s)&&ar(n,s)&&ar(s,n)&&(e.push(n.i,t.i,s.i),lr(t),lr(t.next),t=i=s),t=t.next}while(t!==i);return Li(t)}function np(i,e,t,n,s,r){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&up(o,a)){let l=Du(o,a);o=Li(o,o.next),l=Li(l,l.next),or(o,e,t,n,s,r,0),or(l,e,t,n,s,r,0);return}a=a.next}o=o.next}while(o!==i)}function ip(i,e,t,n){let s=[];for(let r=0,o=e.length;r<o;r++){let a=e[r]*n,l=r<o-1?e[r+1]*n:i.length,c=Pu(i,a,l,n,!1);c===c.next&&(c.steiner=!0),s.push(hp(c))}s.sort(sp);for(let r=0;r<s.length;r++)t=rp(s[r],t);return t}function sp(i,e){let t=i.x-e.x;if(t===0&&(t=i.y-e.y,t===0)){let n=(i.next.y-i.y)/(i.next.x-i.x),s=(e.next.y-e.y)/(e.next.x-e.x);t=n-s}return t}function rp(i,e){let t=op(i,e);if(!t)return e;let n=Du(t,i);return Li(n,n.next),Li(t,t.next)}function op(i,e){let t=e,n=i.x,s=i.y,r=-1/0,o;if(_s(i,t))return t;do{if(_s(i,t.next))return t.next;if(s<=t.y&&s>=t.next.y&&t.next.y!==t.y){let d=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=n&&d>r&&(r=d,o=t.x<t.next.x?t:t.next,d===n))return o}t=t.next}while(t!==e);if(!o)return null;let a=o,l=o.x,c=o.y,h=1/0;t=o;do{if(n>=t.x&&t.x>=l&&n!==t.x&&Iu(s<c?n:r,s,l,c,s<c?r:n,s,t.x,t.y)){let d=Math.abs(s-t.y)/(n-t.x);ar(t,i)&&(d<h||d===h&&(t.x>o.x||t.x===o.x&&ap(o,t)))&&(o=t,h=d)}t=t.next}while(t!==a);return o}function ap(i,e){return _t(i.prev,i,e.prev)<0&&_t(e.next,i,i.next)<0}function lp(i,e,t,n){let s=i;do s.z===0&&(s.z=Hl(s.x,s.y,e,t,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i);s.prevZ.nextZ=null,s.prevZ=null,cp(s)}function cp(i){let e,t=1;do{let n=i,s;i=null;let r=null;for(e=0;n;){e++;let o=n,a=0;for(let c=0;c<t&&(a++,o=o.nextZ,!!o);c++);let l=t;for(;a>0||l>0&&o;)a!==0&&(l===0||!o||n.z<=o.z)?(s=n,n=n.nextZ,a--):(s=o,o=o.nextZ,l--),r?r.nextZ=s:i=s,s.prevZ=r,r=s;n=o}r.nextZ=null,t*=2}while(e>1);return i}function Hl(i,e,t,n,s){return i=(i-t)*s|0,e=(e-n)*s|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function hp(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function Iu(i,e,t,n,s,r,o,a){return(s-o)*(e-a)>=(i-o)*(r-a)&&(i-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(r-a)>=(s-o)*(n-a)}function zs(i,e,t,n,s,r,o,a){return!(i===o&&e===a)&&Iu(i,e,t,n,s,r,o,a)}function up(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!dp(i,e)&&(ar(i,e)&&ar(e,i)&&fp(i,e)&&(_t(i.prev,i,e.prev)||_t(i,e.prev,e))||_s(i,e)&&_t(i.prev,i,i.next)>0&&_t(e.prev,e,e.next)>0)}function _t(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function _s(i,e){return i.x===e.x&&i.y===e.y}function Lu(i,e,t,n){let s=uo(_t(i,e,t)),r=uo(_t(i,e,n)),o=uo(_t(t,n,i)),a=uo(_t(t,n,e));return!!(s!==r&&o!==a||s===0&&ho(i,t,e)||r===0&&ho(i,n,e)||o===0&&ho(t,i,n)||a===0&&ho(t,e,n))}function ho(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function uo(i){return i>0?1:i<0?-1:0}function dp(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&Lu(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function ar(i,e){return _t(i.prev,i,i.next)<0?_t(i,e,i.next)>=0&&_t(i,i.prev,e)>=0:_t(i,e,i.prev)<0||_t(i,i.next,e)<0}function fp(i,e){let t=i,n=!1,s=(i.x+e.x)/2,r=(i.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&s<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function Du(i,e){let t=Gl(i.i,i.x,i.y),n=Gl(e.i,e.x,e.y),s=i.next,r=e.prev;return i.next=e,e.prev=i,t.next=s,s.prev=t,n.next=t,t.prev=n,r.next=n,n.prev=r,n}function Fh(i,e,t,n){let s=Gl(i,e,t);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function lr(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Gl(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function pp(i,e,t,n){let s=0;for(let r=e,o=t-n;r<t;r+=n)s+=(i[o]-i[r])*(i[r+1]+i[o+1]),o=r;return s}var Wl=class{static triangulate(e,t,n=2){return jf(e,t,n)}},wi=class i{static area(e){let t=e.length,n=0;for(let s=t-1,r=0;r<t;s=r++)n+=e[s].x*e[r].y-e[r].x*e[s].y;return n*.5}static isClockWise(e){return i.area(e)<0}static triangulateShape(e,t){let n=[],s=[],r=[];Oh(e),Bh(n,e);let o=e.length;t.forEach(Oh);for(let l=0;l<t.length;l++)s.push(o),o+=t[l].length,Bh(n,t[l]);let a=Wl.triangulate(n,s);for(let l=0;l<a.length;l+=3)r.push(a.slice(l,l+3));return r}};function Oh(i){let e=i.length;e>2&&i[e-1].equals(i[0])&&i.pop()}function Bh(i,e){for(let t=0;t<e.length;t++)i.push(e[t].x),i.push(e[t].y)}var cr=class i extends mt{constructor(e=new gs([new te(.5,.5),new te(-.5,.5),new te(-.5,-.5),new te(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let n=this,s=[],r=[];for(let a=0,l=e.length;a<l;a++){let c=e[a];o(c)}this.setAttribute("position",new xt(s,3)),this.setAttribute("uv",new xt(r,2)),this.computeVertexNormals();function o(a){let l=[],c=t.curveSegments!==void 0?t.curveSegments:12,h=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1,u=t.bevelEnabled!==void 0?t.bevelEnabled:!0,f=t.bevelThickness!==void 0?t.bevelThickness:.2,g=t.bevelSize!==void 0?t.bevelSize:f-.1,y=t.bevelOffset!==void 0?t.bevelOffset:0,m=t.bevelSegments!==void 0?t.bevelSegments:3,p=t.extrudePath,C=t.UVGenerator!==void 0?t.UVGenerator:mp,T,x=!1,S,M,A,v;if(p){T=p.getSpacedPoints(h),x=!0,u=!1;let Q=p.isCatmullRomCurve3?p.closed:!1;S=p.computeFrenetFrames(h,Q),M=new R,A=new R,v=new R}u||(m=0,f=0,g=0,y=0);let w=a.extractPoints(c),I=w.shape,P=w.holes;if(!wi.isClockWise(I)){I=I.reverse();for(let Q=0,ie=P.length;Q<ie;Q++){let ne=P[Q];wi.isClockWise(ne)&&(P[Q]=ne.reverse())}}function q(Q){let ne=10000000000000001e-36,xe=Q[0];for(let me=1;me<=Q.length;me++){let Be=me%Q.length,Ce=Q[Be],Ve=Ce.x-xe.x,We=Ce.y-xe.y,L=Ve*Ve+We*We,ot=Math.max(Math.abs(Ce.x),Math.abs(Ce.y),Math.abs(xe.x),Math.abs(xe.y)),je=ne*ot*ot;if(L<=je){Q.splice(Be,1),me--;continue}xe=Ce}}q(I),P.forEach(q);let Y=P.length,U=I;for(let Q=0;Q<Y;Q++){let ie=P[Q];I=I.concat(ie)}function G(Q,ie,ne){return ie||Fe("ExtrudeGeometry: vec does not exist"),Q.clone().addScaledVector(ie,ne)}let H=I.length;function j(Q,ie,ne){let xe,me,Be,Ce=Q.x-ie.x,Ve=Q.y-ie.y,We=ne.x-Q.x,L=ne.y-Q.y,ot=Ce*Ce+Ve*Ve,je=Ce*L-Ve*We;if(Math.abs(je)>Number.EPSILON){let E=Math.sqrt(ot),_=Math.sqrt(We*We+L*L),F=ie.x-Ve/E,k=ie.y+Ce/E,W=ne.x-L/_,oe=ne.y+We/_,ae=((W-F)*L-(oe-k)*We)/(Ce*L-Ve*We);xe=F+Ce*ae-Q.x,me=k+Ve*ae-Q.y;let X=xe*xe+me*me;if(X<=2)return new te(xe,me);Be=Math.sqrt(X/2)}else{let E=!1;Ce>Number.EPSILON?We>Number.EPSILON&&(E=!0):Ce<-Number.EPSILON?We<-Number.EPSILON&&(E=!0):Math.sign(Ve)===Math.sign(L)&&(E=!0),E?(xe=-Ve,me=Ce,Be=Math.sqrt(ot)):(xe=Ce,me=Ve,Be=Math.sqrt(ot/2))}return new te(xe/Be,me/Be)}let se=[];for(let Q=0,ie=U.length,ne=ie-1,xe=Q+1;Q<ie;Q++,ne++,xe++)ne===ie&&(ne=0),xe===ie&&(xe=0),se[Q]=j(U[Q],U[ne],U[xe]);let ue=[],le,Me=se.concat();for(let Q=0,ie=Y;Q<ie;Q++){let ne=P[Q];le=[];for(let xe=0,me=ne.length,Be=me-1,Ce=xe+1;xe<me;xe++,Be++,Ce++)Be===me&&(Be=0),Ce===me&&(Ce=0),le[xe]=j(ne[xe],ne[Be],ne[Ce]);ue.push(le),Me=Me.concat(le)}let Je;if(m===0)Je=wi.triangulateShape(U,P);else{let Q=[],ie=[];for(let ne=0;ne<m;ne++){let xe=ne/m,me=f*Math.cos(xe*Math.PI/2),Be=g*Math.sin(xe*Math.PI/2)+y;for(let Ce=0,Ve=U.length;Ce<Ve;Ce++){let We=G(U[Ce],se[Ce],Be);Ie(We.x,We.y,-me),xe===0&&Q.push(We)}for(let Ce=0,Ve=Y;Ce<Ve;Ce++){let We=P[Ce];le=ue[Ce];let L=[];for(let ot=0,je=We.length;ot<je;ot++){let E=G(We[ot],le[ot],Be);Ie(E.x,E.y,-me),xe===0&&L.push(E)}xe===0&&ie.push(L)}}Je=wi.triangulateShape(Q,ie)}let ct=Je.length,et=g+y;for(let Q=0;Q<H;Q++){let ie=u?G(I[Q],Me[Q],et):I[Q];x?(A.copy(S.normals[0]).multiplyScalar(ie.x),M.copy(S.binormals[0]).multiplyScalar(ie.y),v.copy(T[0]).add(A).add(M),Ie(v.x,v.y,v.z)):Ie(ie.x,ie.y,0)}for(let Q=1;Q<=h;Q++)for(let ie=0;ie<H;ie++){let ne=u?G(I[ie],Me[ie],et):I[ie];x?(A.copy(S.normals[Q]).multiplyScalar(ne.x),M.copy(S.binormals[Q]).multiplyScalar(ne.y),v.copy(T[Q]).add(A).add(M),Ie(v.x,v.y,v.z)):Ie(ne.x,ne.y,d/h*Q)}for(let Q=m-1;Q>=0;Q--){let ie=Q/m,ne=f*Math.cos(ie*Math.PI/2),xe=g*Math.sin(ie*Math.PI/2)+y;for(let me=0,Be=U.length;me<Be;me++){let Ce=G(U[me],se[me],xe);Ie(Ce.x,Ce.y,d+ne)}for(let me=0,Be=P.length;me<Be;me++){let Ce=P[me];le=ue[me];for(let Ve=0,We=Ce.length;Ve<We;Ve++){let L=G(Ce[Ve],le[Ve],xe);x?Ie(L.x,L.y+T[h-1].y,T[h-1].x+ne):Ie(L.x,L.y,d+ne)}}}J(),ce();function J(){let Q=s.length/3;if(u){let ie=0,ne=H*ie;for(let xe=0;xe<ct;xe++){let me=Je[xe];ke(me[2]+ne,me[1]+ne,me[0]+ne)}ie=h+m*2,ne=H*ie;for(let xe=0;xe<ct;xe++){let me=Je[xe];ke(me[0]+ne,me[1]+ne,me[2]+ne)}}else{for(let ie=0;ie<ct;ie++){let ne=Je[ie];ke(ne[2],ne[1],ne[0])}for(let ie=0;ie<ct;ie++){let ne=Je[ie];ke(ne[0]+H*h,ne[1]+H*h,ne[2]+H*h)}}n.addGroup(Q,s.length/3-Q,0)}function ce(){let Q=s.length/3,ie=0;re(U,ie),ie+=U.length;for(let ne=0,xe=P.length;ne<xe;ne++){let me=P[ne];re(me,ie),ie+=me.length}n.addGroup(Q,s.length/3-Q,1)}function re(Q,ie){let ne=Q.length;for(;--ne>=0;){let xe=ne,me=ne-1;me<0&&(me=Q.length-1);for(let Be=0,Ce=h+m*2;Be<Ce;Be++){let Ve=H*Be,We=H*(Be+1),L=ie+xe+Ve,ot=ie+me+Ve,je=ie+me+We,E=ie+xe+We;Ue(L,ot,je,E)}}}function Ie(Q,ie,ne){l.push(Q),l.push(ie),l.push(ne)}function ke(Q,ie,ne){nt(Q),nt(ie),nt(ne);let xe=s.length/3,me=C.generateTopUV(n,s,xe-3,xe-2,xe-1);He(me[0]),He(me[1]),He(me[2])}function Ue(Q,ie,ne,xe){nt(Q),nt(ie),nt(xe),nt(ie),nt(ne),nt(xe);let me=s.length/3,Be=C.generateSideWallUV(n,s,me-6,me-3,me-2,me-1);He(Be[0]),He(Be[1]),He(Be[3]),He(Be[1]),He(Be[2]),He(Be[3])}function nt(Q){s.push(l[Q*3+0]),s.push(l[Q*3+1]),s.push(l[Q*3+2])}function He(Q){r.push(Q.x),r.push(Q.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return gp(t,n,e)}static fromJSON(e,t){let n=[];for(let r=0,o=e.shapes.length;r<o;r++){let a=t[e.shapes[r]];n.push(a)}let s=e.options.extrudePath;return s!==void 0&&(e.options.extrudePath=new Vl[s.type]().fromJSON(s)),new i(n,e.options)}},mp={generateTopUV:function(i,e,t,n,s){let r=e[t*3],o=e[t*3+1],a=e[n*3],l=e[n*3+1],c=e[s*3],h=e[s*3+1];return[new te(r,o),new te(a,l),new te(c,h)]},generateSideWallUV:function(i,e,t,n,s,r){let o=e[t*3],a=e[t*3+1],l=e[t*3+2],c=e[n*3],h=e[n*3+1],d=e[n*3+2],u=e[s*3],f=e[s*3+1],g=e[s*3+2],y=e[r*3],m=e[r*3+1],p=e[r*3+2];return Math.abs(a-h)<Math.abs(o-c)?[new te(o,1-l),new te(c,1-d),new te(u,1-g),new te(y,1-p)]:[new te(a,1-l),new te(h,1-d),new te(f,1-g),new te(m,1-p)]}};function gp(i,e,t){if(t.shapes=[],Array.isArray(i))for(let n=0,s=i.length;n<s;n++){let r=i[n];t.shapes.push(r.uuid)}else t.shapes.push(i.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}var ri=class i extends mt{constructor(e=1,t=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:s};let r=e/2,o=t/2,a=Math.floor(n),l=Math.floor(s),c=a+1,h=l+1,d=e/a,u=t/l,f=[],g=[],y=[],m=[];for(let p=0;p<h;p++){let C=p*u-o;for(let T=0;T<c;T++){let x=T*d-r;g.push(x,-C,0),y.push(0,0,1),m.push(T/a),m.push(1-p/l)}}for(let p=0;p<l;p++)for(let C=0;C<a;C++){let T=C+c*p,x=C+c*(p+1),S=C+1+c*(p+1),M=C+1+c*p;f.push(T,x,M),f.push(x,S,M)}this.setIndex(f),this.setAttribute("position",new xt(g,3)),this.setAttribute("normal",new xt(y,3)),this.setAttribute("uv",new xt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.widthSegments,e.heightSegments)}};function Ui(i){let e={};for(let t in i){e[t]={};for(let n in i[t]){let s=i[t][n];if(zh(s))s.isRenderTargetTexture?(De("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=s.clone();else if(Array.isArray(s))if(zh(s[0])){let r=[];for(let o=0,a=s.length;o<a;o++)r[o]=s[o].clone();e[t][n]=r}else e[t][n]=s.slice();else e[t][n]=s}}return e}function Ht(i){let e={};for(let t=0;t<i.length;t++){let n=Ui(i[t]);for(let s in n)e[s]=n[s]}return e}function zh(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function _p(i){let e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function yc(i){let e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Qe.workingColorSpace}var Nu={clone:Ui,merge:Ht},xp=`void main() {
|
|
7
7
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
8
|
-
}`,
|
|
8
|
+
}`,vp=`void main() {
|
|
9
9
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
10
|
-
}`,tn=class extends Pn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=pp,this.fragmentShader=mp,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Ni(e.uniforms),this.uniformsGroups=fp(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let s in this.uniforms){let a=this.uniforms[s].value;a&&a.isTexture?t.uniforms[s]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[s]={type:"m4",value:a.toArray()}:t.uniforms[s]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let s=e.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=t[s.value]||null;break;case"c":this.uniforms[n].value=new qe().setHex(s.value);break;case"v2":this.uniforms[n].value=new ee().fromArray(s.value);break;case"v3":this.uniforms[n].value=new R().fromArray(s.value);break;case"v4":this.uniforms[n].value=new gt().fromArray(s.value);break;case"m3":this.uniforms[n].value=new He().fromArray(s.value);break;case"m4":this.uniforms[n].value=new rt().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}},Wa=class extends tn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},ur=class extends Pn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new qe(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 qe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xo,this.normalScale=new ee(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 Gn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}};var Xa=class extends Pn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=pu,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},qa=class extends Pn{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};function da(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}var ri=class{constructor(e,t,n,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,s=t[n],r=t[n-1];n:{e:{let a;t:{i:if(!(e<s)){for(let o=n+2;;){if(s===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=s,s=t[++n],e<s)break e}a=t.length;break t}if(!(e>=r)){let o=t[1];e<o&&(n=2,r=o);for(let l=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(s=r,r=t[--n-1],e>=r)break e}a=n,n=0;break t}break n}for(;n<a;){let o=n+a>>>1;e<t[o]?a=o:n=o+1}if(s=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,e,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s;for(let a=0;a!==s;++a)t[a]=n[r+a];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}},Ya=class extends ri{constructor(e,t,n,s){super(e,t,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Fl,endingEnd:Fl}}intervalChanged_(e,t,n){let s=this.parameterPositions,r=e-2,a=e+1,o=s[r],l=s[a];if(o===void 0)switch(this.getSettings_().endingStart){case Ol:r=e,o=2*t-n;break;case Bl:r=s.length-2,o=t+s[r]-s[r+1];break;default:r=e,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Ol:a=e,l=2*n-t;break;case Bl:a=1,l=n+s[1]-s[0];break;default:a=e-1,l=t}let c=(n-t)*.5,h=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(e,t,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this._offsetPrev,d=this._offsetNext,u=this._weightPrev,f=this._weightNext,g=(n-t)/(s-t),b=g*g,m=b*g,p=-u*m+2*u*b-u*g,C=(1+u)*m+(-1.5-2*u)*b+(-.5+u)*g+1,w=(-1-f)*m+(1.5+f)*b+.5*g,_=f*m-f*b;for(let S=0;S!==o;++S)r[S]=p*a[h+S]+C*a[c+S]+w*a[l+S]+_*a[d+S];return r}},Za=class extends ri{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=(n-t)/(s-t),d=1-h;for(let u=0;u!==o;++u)r[u]=a[c+u]*d+a[l+u]*h;return r}},$a=class extends ri{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e){return this.copySampleValue_(e-1)}},Ja=class extends ri{interpolate_(e,t,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this.inTangents,d=this.outTangents;if(!h||!d){let g=(n-t)/(s-t),b=1-g;for(let m=0;m!==o;++m)r[m]=a[c+m]*b+a[l+m]*g;return r}let u=o*2,f=e-1;for(let g=0;g!==o;++g){let b=a[c+g],m=a[l+g],p=f*u+g*2,C=d[p],w=d[p+1],_=e*u+g*2,S=h[_],M=h[_+1],A=(n-t)/(s-t),y,T,I,P,F;for(let G=0;G<8;G++){y=A*A,T=y*A,I=1-A,P=I*I,F=P*I;let O=F*t+3*P*A*C+3*I*y*S+T*s-n;if(Math.abs(O)<1e-10)break;let W=3*P*(C-t)+6*I*A*(S-C)+3*y*(s-S);if(Math.abs(W)<1e-10)break;A=A-O/W,A=Math.max(0,Math.min(1,A))}r[g]=F*b+3*P*A*w+3*I*y*M+T*m}return r}},nn=class{constructor(e,t,n,s){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=da(t,this.TimeBufferType),this.values=da(n,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:da(e.times,Array),values:da(e.values,Array)};let s=e.getInterpolation();s!==e.DefaultInterpolation&&(n.interpolation=s)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new $a(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Za(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Ya(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Ja(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case Ws:t=this.InterpolantFactoryMethodDiscrete;break;case Aa:t=this.InterpolantFactoryMethodLinear;break;case ma:t=this.InterpolantFactoryMethodSmooth;break;case Ul:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return De("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ws;case this.InterpolantFactoryMethodLinear:return Aa;case this.InterpolantFactoryMethodSmooth:return ma;case this.InterpolantFactoryMethodBezier:return Ul}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]*=e}return this}trim(e,t){let n=this.times,s=n.length,r=0,a=s-1;for(;r!==s&&n[r]<e;)++r;for(;a!==-1&&n[a]>t;)--a;if(++a,r!==0||a!==s){r>=a&&(a=Math.max(a,1),r=a-1);let o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(Fe("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,s=this.values,r=n.length;r===0&&(Fe("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){let l=n[o];if(typeof l=="number"&&isNaN(l)){Fe("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){Fe("KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(s!==void 0&&af(s))for(let o=0,l=s.length;o!==l;++o){let c=s[o];if(isNaN(c)){Fe("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===ma,r=e.length-1,a=1;for(let o=1;o<r;++o){let l=!1,c=e[o],h=e[o+1];if(c!==h&&(o!==1||c!==e[0]))if(s)l=!0;else{let d=o*n,u=d-n,f=d+n;for(let g=0;g!==n;++g){let b=t[d+g];if(b!==t[u+g]||b!==t[f+g]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];let d=o*n,u=a*n;for(let f=0;f!==n;++f)t[u+f]=t[d+f]}++a}}if(r>0){e[a]=e[r];for(let o=r*n,l=a*n,c=0;c!==n;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,s}};nn.prototype.ValueTypeName="";nn.prototype.TimeBufferType=Float32Array;nn.prototype.ValueBufferType=Float32Array;nn.prototype.DefaultInterpolation=Aa;var ai=class extends nn{constructor(e,t,n){super(e,t,n)}};ai.prototype.ValueTypeName="bool";ai.prototype.ValueBufferType=Array;ai.prototype.DefaultInterpolation=Ws;ai.prototype.InterpolantFactoryMethodLinear=void 0;ai.prototype.InterpolantFactoryMethodSmooth=void 0;var Ka=class extends nn{constructor(e,t,n,s){super(e,t,n,s)}};Ka.prototype.ValueTypeName="color";var ja=class extends nn{constructor(e,t,n,s){super(e,t,n,s)}};ja.prototype.ValueTypeName="number";var Qa=class extends ri{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-t)/(s-t),c=e*o;for(let h=c+o;c!==h;c+=4)Ot.slerpFlat(r,0,a,c-o,a,c,l);return r}},dr=class extends nn{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new Qa(this.times,this.values,this.getValueSize(),e)}};dr.prototype.ValueTypeName="quaternion";dr.prototype.InterpolantFactoryMethodSmooth=void 0;var oi=class extends nn{constructor(e,t,n){super(e,t,n)}};oi.prototype.ValueTypeName="string";oi.prototype.ValueBufferType=Array;oi.prototype.DefaultInterpolation=Ws;oi.prototype.InterpolantFactoryMethodLinear=void 0;oi.prototype.InterpolantFactoryMethodSmooth=void 0;var eo=class extends nn{constructor(e,t,n,s){super(e,t,n,s)}};eo.prototype.ValueTypeName="vector";var to=class{constructor(e,t,n){let s=this,r=!1,a=0,o=0,l,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(h){o++,r===!1&&s.onStart!==void 0&&s.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,s.onProgress!==void 0&&s.onProgress(h,a,o),a===o&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,d){return c.push(h,d),this},this.removeHandler=function(h){let d=c.indexOf(h);return d!==-1&&c.splice(d,2),this},this.getHandler=function(h){for(let d=0,u=c.length;d<u;d+=2){let f=c[d],g=c[d+1];if(f.global&&(f.lastIndex=0),f.test(h))return g}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},Du=new to,no=class{constructor(e){this.manager=e!==void 0?e:Du,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(s,r){n.load(e,s,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}};no.DEFAULT_MATERIAL_NAME="__DEFAULT";var fr=class extends Nt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new qe(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}},gs=class extends fr{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Nt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new qe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}},Nl=new rt,Bh=new R,zh=new R,Wl=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ee(512,512),this.mapType=Yt,this.map=null,this.mapPass=null,this.matrix=new rt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new us,this._frameExtents=new ee(1,1),this._viewportCount=1,this._viewports=[new gt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;Bh.setFromMatrixPosition(e.matrixWorld),t.position.copy(Bh),zh.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(zh),t.updateMatrixWorld(),Nl.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Nl,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===ss||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Nl)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},fa=new R,pa=new Ot,Tn=new R,pr=class extends Nt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new rt,this.projectionMatrix=new rt,this.projectionMatrixInverse=new rt,this.coordinateSystem=pn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(fa,pa,Tn),Tn.x===1&&Tn.y===1&&Tn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(fa,pa,Tn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(fa,pa,Tn),Tn.x===1&&Tn.y===1&&Tn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(fa,pa,Tn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},ei=new R,kh=new ee,Vh=new ee,Vt=class extends pr{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=as*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(ns*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return as*2*Math.atan(Math.tan(ns*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){ei.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ei.x,ei.y).multiplyScalar(-e/ei.z),ei.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ei.x,ei.y).multiplyScalar(-e/ei.z)}getViewSize(e,t){return this.getViewBounds(e,kh,Vh),t.subVectors(Vh,kh)}setViewOffset(e,t,n,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(ns*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,r=-.5*s,a=this.view;if(this.view!==null&&this.view.enabled){let l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,t-=a.offsetY*n/c,s*=a.width/l,n*=a.height/c}let o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}};var li=class extends pr{constructor(e=-1,t=1,n=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2,r=n-e,a=n+e,o=s+t,l=s-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Xl=class extends Wl{constructor(){super(new li(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},ci=class extends fr{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Nt.DEFAULT_UP),this.updateMatrix(),this.target=new Nt,this.shadow=new Xl}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}};var es=-90,ts=1,io=class extends Nt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let s=new Vt(es,ts,e,t);s.layers=this.layers,this.add(s);let r=new Vt(es,ts,e,t);r.layers=this.layers,this.add(r);let a=new Vt(es,ts,e,t);a.layers=this.layers,this.add(a);let o=new Vt(es,ts,e,t);o.layers=this.layers,this.add(o);let l=new Vt(es,ts,e,t);l.layers=this.layers,this.add(l);let c=new Vt(es,ts,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,s,r,a,o,l]=t;for(let c of t)this.remove(c);if(e===pn)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===ss)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[r,a,o,l,c,h]=this.children,d=e.getRenderTarget(),u=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;let b=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(n,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(n,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=b,e.setRenderTarget(n,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(d,u,f),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}},so=class extends Vt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}};var vc="\\[\\]\\.:\\/",gp=new RegExp("["+vc+"]","g"),bc="[^"+vc+"]",_p="[^"+vc.replace("\\.","")+"]",xp=/((?:WC+[\/:])*)/.source.replace("WC",bc),yp=/(WCOD+)?/.source.replace("WCOD",_p),vp=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",bc),bp=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",bc),Mp=new RegExp("^"+xp+yp+vp+bp+"$"),Sp=["material","materials","bones","map"],ql=class{constructor(e,t,n){let s=n||pt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},pt=class i{constructor(e,t,n){this.path=t,this.parsedPath=n||i.parseTrackName(t),this.node=i.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new i.Composite(e,t,n):new i(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(gp,"")}static parseTrackName(e){let t=Mp.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let r=n.nodeName.substring(s+1);Sp.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let a=0;a<r.length;a++){let o=r[a];if(o.name===t||o.uuid===t)return o;let l=n(o.children);if(l)return l}return null},s=n(e.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)e[t++]=n[s]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,n=t.objectName,s=t.propertyName,r=t.propertyIndex;if(e||(e=i.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){De("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Fe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Fe("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Fe("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===c){c=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Fe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Fe("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){Fe("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Fe("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let a=e[s];if(a===void 0){let c=t.nodeName;Fe("PropertyBinding: Trying to update property for track: "+c+"."+s+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(r!==void 0){if(s==="morphTargetInfluences"){if(!e.geometry){Fe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Fe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=s;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};pt.Composite=ql;pt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};pt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};pt.prototype.GetterByBindingType=[pt.prototype._getValue_direct,pt.prototype._getValue_array,pt.prototype._getValue_arrayElement,pt.prototype._getValue_toArray];pt.prototype.SetterByBindingTypeAndVersioning=[[pt.prototype._setValue_direct,pt.prototype._setValue_direct_setNeedsUpdate,pt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_array,pt.prototype._setValue_array_setNeedsUpdate,pt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_arrayElement,pt.prototype._setValue_arrayElement_setNeedsUpdate,pt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_fromArray,pt.prototype._setValue_fromArray_setNeedsUpdate,pt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var _y=new Float32Array(1);var Hh=new rt,Li=class{constructor(e,t,n=0,s=1/0){this.ray=new ii(e,t),this.near=n,this.far=s,this.camera=null,this.layers=new ls,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):Fe("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Hh.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Hh),this}intersectObject(e,t=!0,n=[]){return Yl(e,this,n,t),n.sort(Gh),n}intersectObjects(e,t=!0,n=[]){for(let s=0,r=e.length;s<r;s++)Yl(e[s],this,n,t);return n.sort(Gh),n}};function Gh(i,e){return i.distance-e.distance}function Yl(i,e,t,n){let s=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(s=!1),s===!0&&n===!0){let r=i.children;for(let a=0,o=r.length;a<o;a++)Yl(r[a],e,t,!0)}}var _s=class{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Ye(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(Ye(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var Zl=class i{static{i.prototype.isMatrix2=!0}constructor(e,t,n,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,s){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=s,this}};var mr=class extends xn{constructor(e=10,t=10,n=4473924,s=8947848){n=new qe(n),s=new qe(s);let r=t/2,a=e/t,o=e/2,l=[],c=[];for(let u=0,f=0,g=-o;u<=t;u++,g+=a){l.push(-o,0,g,o,0,g),l.push(g,0,-o,g,0,o);let b=u===r?n:s;b.toArray(c,f),f+=3,b.toArray(c,f),f+=3,b.toArray(c,f),f+=3,b.toArray(c,f),f+=3}let h=new mt;h.setAttribute("position",new xt(l,3)),h.setAttribute("color",new xt(c,3));let d=new _n({vertexColors:!0,toneMapped:!1});super(h,d),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}};var gr=class extends xn{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],s=new mt;s.setAttribute("position",new xt(t,3)),s.setAttribute("color",new xt(n,3));let r=new _n({vertexColors:!0,toneMapped:!1});super(s,r),this.type="AxesHelper"}setColors(e,t,n){let s=new qe,r=this.geometry.attributes.color.array;return s.set(e),s.toArray(r,0),s.toArray(r,3),s.set(t),s.toArray(r,6),s.toArray(r,9),s.set(n),s.toArray(r,12),s.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};var _r=class extends mn{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){De("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}};function Mc(i,e,t,n){let s=Ep(n);switch(t){case dc:return i*e;case pc:return i*e/s.components*s.byteLength;case uo:return i*e/s.components*s.byteLength;case mi:return i*e*2/s.components*s.byteLength;case fo:return i*e*2/s.components*s.byteLength;case fc:return i*e*3/s.components*s.byteLength;case cn:return i*e*4/s.components*s.byteLength;case po:return i*e*4/s.components*s.byteLength;case br:case Mr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Sr:case Er:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case go:case xo:return Math.max(i,16)*Math.max(e,8)/4;case mo:case _o:return Math.max(i,8)*Math.max(e,8)/2;case yo:case vo:case Mo:case So:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case bo:case Tr:case Eo:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case To:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case wo:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Ao:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Co:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Ro:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Po:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Io:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Lo:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case Do:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case No:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Uo:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case Fo:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Oo:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Bo:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case zo:case ko:case Vo:return Math.ceil(i/4)*Math.ceil(e/4)*16;case Ho:case Go:return Math.ceil(i/4)*Math.ceil(e/4)*8;case wr:case Wo:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Ep(i){switch(i){case Yt:case lc:return{byteLength:1,components:1};case ys:case cc:case Ln:return{byteLength:2,components:1};case co:case ho:return{byteLength:2,components:4};case vn:case lo:case bn:return{byteLength:4,components:1};case hc:case uc:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"185"}}));typeof window<"u"&&(window.__THREE__?De("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="185");function nd(){let i=null,e=!1,t=null,n=null;function s(r,a){t(r,a),n=i.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&i!==null&&(n=i.requestAnimationFrame(s),e=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){i=r}}}function wp(i){let e=new WeakMap;function t(o,l){let c=o.array,h=o.usage,d=c.byteLength,u=i.createBuffer();i.bindBuffer(l,u),i.bufferData(l,c,h),o.onUploadCallback();let f;if(c instanceof Float32Array)f=i.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=i.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=i.HALF_FLOAT:f=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=i.SHORT;else if(c instanceof Uint32Array)f=i.UNSIGNED_INT;else if(c instanceof Int32Array)f=i.INT;else if(c instanceof Int8Array)f=i.BYTE;else if(c instanceof Uint8Array)f=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:u,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function n(o,l,c){let h=l.array,d=l.updateRanges;if(i.bindBuffer(c,o),d.length===0)i.bufferSubData(c,0,h);else{d.sort((f,g)=>f.start-g.start);let u=0;for(let f=1;f<d.length;f++){let g=d[u],b=d[f];b.start<=g.start+g.count+1?g.count=Math.max(g.count,b.start+b.count-g.start):(++u,d[u]=b)}d.length=u+1;for(let f=0,g=d.length;f<g;f++){let b=d[f];i.bufferSubData(c,b.start*h.BYTES_PER_ELEMENT,h,b.start,b.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);let l=e.get(o);l&&(i.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){let h=e.get(o);(!h||h.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,o,l),c.version=o.version}}return{get:s,remove:r,update:a}}var Ap=`#ifdef USE_ALPHAHASH
|
|
10
|
+
}`,tn=class extends Pn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=xp,this.fragmentShader=vp,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Ui(e.uniforms),this.uniformsGroups=_p(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let s in this.uniforms){let o=this.uniforms[s].value;o&&o.isTexture?t.uniforms[s]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[s]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[s]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[s]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[s]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[s]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[s]={type:"m4",value:o.toArray()}:t.uniforms[s]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let s=e.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=t[s.value]||null;break;case"c":this.uniforms[n].value=new Ye().setHex(s.value);break;case"v2":this.uniforms[n].value=new te().fromArray(s.value);break;case"v3":this.uniforms[n].value=new R().fromArray(s.value);break;case"v4":this.uniforms[n].value=new gt().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Ge().fromArray(s.value);break;case"m4":this.uniforms[n].value=new rt().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}},Xo=class extends tn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},hr=class extends Pn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ye(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 Ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xa,this.normalScale=new te(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 Gn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}};var qo=class extends Pn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=gu,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},Yo=class extends Pn{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};function fo(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}var oi=class{constructor(e,t,n,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,s=t[n],r=t[n-1];n:{e:{let o;t:{i:if(!(e<s)){for(let a=n+2;;){if(s===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=s,s=t[++n],e<s)break e}o=t.length;break t}if(!(e>=r)){let a=t[1];e<a&&(n=2,r=a);for(let l=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(s=r,r=t[--n-1],e>=r)break e}o=n,n=0;break t}break n}for(;n<o;){let a=n+o>>>1;e<t[a]?o=a:n=a+1}if(s=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,e,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s;for(let o=0;o!==s;++o)t[o]=n[r+o];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}},Zo=class extends oi{constructor(e,t,n,s){super(e,t,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Ol,endingEnd:Ol}}intervalChanged_(e,t,n){let s=this.parameterPositions,r=e-2,o=e+1,a=s[r],l=s[o];if(a===void 0)switch(this.getSettings_().endingStart){case Bl:r=e,a=2*t-n;break;case zl:r=s.length-2,a=t+s[r]-s[r+1];break;default:r=e,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Bl:o=e,l=2*n-t;break;case zl:o=1,l=n+s[1]-s[0];break;default:o=e-1,l=t}let c=(n-t)*.5,h=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-n),this._offsetPrev=r*h,this._offsetNext=o*h}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=this._offsetPrev,d=this._offsetNext,u=this._weightPrev,f=this._weightNext,g=(n-t)/(s-t),y=g*g,m=y*g,p=-u*m+2*u*y-u*g,C=(1+u)*m+(-1.5-2*u)*y+(-.5+u)*g+1,T=(-1-f)*m+(1.5+f)*y+.5*g,x=f*m-f*y;for(let S=0;S!==a;++S)r[S]=p*o[h+S]+C*o[c+S]+T*o[l+S]+x*o[d+S];return r}},$o=class extends oi{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=(n-t)/(s-t),d=1-h;for(let u=0;u!==a;++u)r[u]=o[c+u]*d+o[l+u]*h;return r}},Jo=class extends oi{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e){return this.copySampleValue_(e-1)}},Ko=class extends oi{interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=this.inTangents,d=this.outTangents;if(!h||!d){let g=(n-t)/(s-t),y=1-g;for(let m=0;m!==a;++m)r[m]=o[c+m]*y+o[l+m]*g;return r}let u=a*2,f=e-1;for(let g=0;g!==a;++g){let y=o[c+g],m=o[l+g],p=f*u+g*2,C=d[p],T=d[p+1],x=e*u+g*2,S=h[x],M=h[x+1],A=(n-t)/(s-t),v,w,I,P,O;for(let q=0;q<8;q++){v=A*A,w=v*A,I=1-A,P=I*I,O=P*I;let U=O*t+3*P*A*C+3*I*v*S+w*s-n;if(Math.abs(U)<1e-10)break;let G=3*P*(C-t)+6*I*A*(S-C)+3*v*(s-S);if(Math.abs(G)<1e-10)break;A=A-U/G,A=Math.max(0,Math.min(1,A))}r[g]=O*y+3*P*A*T+3*I*v*M+w*m}return r}},nn=class{constructor(e,t,n,s){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=fo(t,this.TimeBufferType),this.values=fo(n,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:fo(e.times,Array),values:fo(e.values,Array)};let s=e.getInterpolation();s!==e.DefaultInterpolation&&(n.interpolation=s)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Jo(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new $o(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Zo(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Ko(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case Gs:t=this.InterpolantFactoryMethodDiscrete;break;case Co:t=this.InterpolantFactoryMethodLinear;break;case go:t=this.InterpolantFactoryMethodSmooth;break;case Fl:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return De("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Gs;case this.InterpolantFactoryMethodLinear:return Co;case this.InterpolantFactoryMethodSmooth:return go;case this.InterpolantFactoryMethodBezier:return Fl}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]*=e}return this}trim(e,t){let n=this.times,s=n.length,r=0,o=s-1;for(;r!==s&&n[r]<e;)++r;for(;o!==-1&&n[o]>t;)--o;if(++o,r!==0||o!==s){r>=o&&(o=Math.max(o,1),r=o-1);let a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(Fe("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,s=this.values,r=n.length;r===0&&(Fe("KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){Fe("KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){Fe("KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(s!==void 0&&hf(s))for(let a=0,l=s.length;a!==l;++a){let c=s[a];if(isNaN(c)){Fe("KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===go,r=e.length-1,o=1;for(let a=1;a<r;++a){let l=!1,c=e[a],h=e[a+1];if(c!==h&&(a!==1||c!==e[0]))if(s)l=!0;else{let d=a*n,u=d-n,f=d+n;for(let g=0;g!==n;++g){let y=t[d+g];if(y!==t[u+g]||y!==t[f+g]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];let d=a*n,u=o*n;for(let f=0;f!==n;++f)t[u+f]=t[d+f]}++o}}if(r>0){e[o]=e[r];for(let a=r*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,s}};nn.prototype.ValueTypeName="";nn.prototype.TimeBufferType=Float32Array;nn.prototype.ValueBufferType=Float32Array;nn.prototype.DefaultInterpolation=Co;var ai=class extends nn{constructor(e,t,n){super(e,t,n)}};ai.prototype.ValueTypeName="bool";ai.prototype.ValueBufferType=Array;ai.prototype.DefaultInterpolation=Gs;ai.prototype.InterpolantFactoryMethodLinear=void 0;ai.prototype.InterpolantFactoryMethodSmooth=void 0;var jo=class extends nn{constructor(e,t,n,s){super(e,t,n,s)}};jo.prototype.ValueTypeName="color";var Qo=class extends nn{constructor(e,t,n,s){super(e,t,n,s)}};Qo.prototype.ValueTypeName="number";var ea=class extends oi{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(s-t),c=e*a;for(let h=c+a;c!==h;c+=4)Ft.slerpFlat(r,0,o,c-a,o,c,l);return r}},ur=class extends nn{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new ea(this.times,this.values,this.getValueSize(),e)}};ur.prototype.ValueTypeName="quaternion";ur.prototype.InterpolantFactoryMethodSmooth=void 0;var li=class extends nn{constructor(e,t,n){super(e,t,n)}};li.prototype.ValueTypeName="string";li.prototype.ValueBufferType=Array;li.prototype.DefaultInterpolation=Gs;li.prototype.InterpolantFactoryMethodLinear=void 0;li.prototype.InterpolantFactoryMethodSmooth=void 0;var ta=class extends nn{constructor(e,t,n,s){super(e,t,n,s)}};ta.prototype.ValueTypeName="vector";var na=class{constructor(e,t,n){let s=this,r=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(h){a++,r===!1&&s.onStart!==void 0&&s.onStart(h,o,a),r=!0},this.itemEnd=function(h){o++,s.onProgress!==void 0&&s.onProgress(h,o,a),o===a&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,d){return c.push(h,d),this},this.removeHandler=function(h){let d=c.indexOf(h);return d!==-1&&c.splice(d,2),this},this.getHandler=function(h){for(let d=0,u=c.length;d<u;d+=2){let f=c[d],g=c[d+1];if(f.global&&(f.lastIndex=0),f.test(h))return g}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},Uu=new na,ia=class{constructor(e){this.manager=e!==void 0?e:Uu,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(s,r){n.load(e,s,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}};ia.DEFAULT_MATERIAL_NAME="__DEFAULT";var dr=class extends Dt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ye(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}},xs=class extends dr{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Dt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ye(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}},Ul=new rt,kh=new R,Vh=new R,Xl=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new te(512,512),this.mapType=Yt,this.map=null,this.mapPass=null,this.matrix=new rt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new fs,this._frameExtents=new te(1,1),this._viewportCount=1,this._viewports=[new gt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;kh.setFromMatrixPosition(e.matrixWorld),t.position.copy(kh),Vh.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Vh),t.updateMatrixWorld(),Ul.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ul,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===os||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Ul)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},po=new R,mo=new Ft,wn=new R,fr=class extends Dt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new rt,this.projectionMatrix=new rt,this.projectionMatrixInverse=new rt,this.coordinateSystem=pn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(po,mo,wn),wn.x===1&&wn.y===1&&wn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(po,mo,wn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(po,mo,wn),wn.x===1&&wn.y===1&&wn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(po,mo,wn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},ti=new R,Hh=new te,Gh=new te,kt=class extends fr{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=ls*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(ss*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ls*2*Math.atan(Math.tan(ss*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){ti.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ti.x,ti.y).multiplyScalar(-e/ti.z),ti.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ti.x,ti.y).multiplyScalar(-e/ti.z)}getViewSize(e,t){return this.getViewBounds(e,Hh,Gh),t.subVectors(Gh,Hh)}setViewOffset(e,t,n,s,r,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(ss*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,r=-.5*s,o=this.view;if(this.view!==null&&this.view.enabled){let l=o.fullWidth,c=o.fullHeight;r+=o.offsetX*s/l,t-=o.offsetY*n/c,s*=o.width/l,n*=o.height/c}let a=this.filmOffset;a!==0&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}};var ci=class extends fr{constructor(e=-1,t=1,n=1,s=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=s,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,s,r,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2,r=n-e,o=n+e,a=s+t,l=s-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,o=r+c*this.view.width,a-=h*this.view.offsetY,l=a-h*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},ql=class extends Xl{constructor(){super(new ci(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},hi=class extends dr{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Dt.DEFAULT_UP),this.updateMatrix(),this.target=new Dt,this.shadow=new ql}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}};var ns=-90,is=1,sa=class extends Dt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let s=new kt(ns,is,e,t);s.layers=this.layers,this.add(s);let r=new kt(ns,is,e,t);r.layers=this.layers,this.add(r);let o=new kt(ns,is,e,t);o.layers=this.layers,this.add(o);let a=new kt(ns,is,e,t);a.layers=this.layers,this.add(a);let l=new kt(ns,is,e,t);l.layers=this.layers,this.add(l);let c=new kt(ns,is,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,s,r,o,a,l]=t;for(let c of t)this.remove(c);if(e===pn)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===os)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[r,o,a,l,c,h]=this.children,d=e.getRenderTarget(),u=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;let y=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(n,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(n,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=y,e.setRenderTarget(n,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(d,u,f),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}},ra=class extends kt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}};var bc="\\[\\]\\.:\\/",yp=new RegExp("["+bc+"]","g"),Mc="[^"+bc+"]",bp="[^"+bc.replace("\\.","")+"]",Mp=/((?:WC+[\/:])*)/.source.replace("WC",Mc),Sp=/(WCOD+)?/.source.replace("WCOD",bp),Ep=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Mc),wp=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Mc),Tp=new RegExp("^"+Mp+Sp+Ep+wp+"$"),Ap=["material","materials","bones","map"],Yl=class{constructor(e,t,n){let s=n||pt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},pt=class i{constructor(e,t,n){this.path=t,this.parsedPath=n||i.parseTrackName(t),this.node=i.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new i.Composite(e,t,n):new i(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(yp,"")}static parseTrackName(e){let t=Tp.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let r=n.nodeName.substring(s+1);Ap.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let o=0;o<r.length;o++){let a=r[o];if(a.name===t||a.uuid===t)return a;let l=n(a.children);if(l)return l}return null},s=n(e.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)e[t++]=n[s]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,n=t.objectName,s=t.propertyName,r=t.propertyIndex;if(e||(e=i.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){De("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Fe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Fe("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Fe("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===c){c=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Fe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Fe("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){Fe("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Fe("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let o=e[s];if(o===void 0){let c=t.nodeName;Fe("PropertyBinding: Trying to update property for track: "+c+"."+s+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?a=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(r!==void 0){if(s==="morphTargetInfluences"){if(!e.geometry){Fe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Fe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=s;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};pt.Composite=Yl;pt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};pt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};pt.prototype.GetterByBindingType=[pt.prototype._getValue_direct,pt.prototype._getValue_array,pt.prototype._getValue_arrayElement,pt.prototype._getValue_toArray];pt.prototype.SetterByBindingTypeAndVersioning=[[pt.prototype._setValue_direct,pt.prototype._setValue_direct_setNeedsUpdate,pt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_array,pt.prototype._setValue_array_setNeedsUpdate,pt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_arrayElement,pt.prototype._setValue_arrayElement_setNeedsUpdate,pt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_fromArray,pt.prototype._setValue_fromArray_setNeedsUpdate,pt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var wv=new Float32Array(1);var Wh=new rt,Di=class{constructor(e,t,n=0,s=1/0){this.ray=new si(e,t),this.near=n,this.far=s,this.camera=null,this.layers=new hs,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):Fe("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Wh.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Wh),this}intersectObject(e,t=!0,n=[]){return Zl(e,this,n,t),n.sort(Xh),n}intersectObjects(e,t=!0,n=[]){for(let s=0,r=e.length;s<r;s++)Zl(e[s],this,n,t);return n.sort(Xh),n}};function Xh(i,e){return i.distance-e.distance}function Zl(i,e,t,n){let s=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(s=!1),s===!0&&n===!0){let r=i.children;for(let o=0,a=r.length;o<a;o++)Zl(r[o],e,t,!0)}}var vs=class{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Ze(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(Ze(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var $l=class i{static{i.prototype.isMatrix2=!0}constructor(e,t,n,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,s){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=s,this}};var pr=class extends xn{constructor(e=10,t=10,n=4473924,s=8947848){n=new Ye(n),s=new Ye(s);let r=t/2,o=e/t,a=e/2,l=[],c=[];for(let u=0,f=0,g=-a;u<=t;u++,g+=o){l.push(-a,0,g,a,0,g),l.push(g,0,-a,g,0,a);let y=u===r?n:s;y.toArray(c,f),f+=3,y.toArray(c,f),f+=3,y.toArray(c,f),f+=3,y.toArray(c,f),f+=3}let h=new mt;h.setAttribute("position",new xt(l,3)),h.setAttribute("color",new xt(c,3));let d=new _n({vertexColors:!0,toneMapped:!1});super(h,d),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}};var mr=class extends xn{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],s=new mt;s.setAttribute("position",new xt(t,3)),s.setAttribute("color",new xt(n,3));let r=new _n({vertexColors:!0,toneMapped:!1});super(s,r),this.type="AxesHelper"}setColors(e,t,n){let s=new Ye,r=this.geometry.attributes.color.array;return s.set(e),s.toArray(r,0),s.toArray(r,3),s.set(t),s.toArray(r,6),s.toArray(r,9),s.set(n),s.toArray(r,12),s.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};var gr=class extends mn{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){De("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}};function Sc(i,e,t,n){let s=Cp(n);switch(t){case fc:return i*e;case mc:return i*e/s.components*s.byteLength;case da:return i*e/s.components*s.byteLength;case gi:return i*e*2/s.components*s.byteLength;case fa:return i*e*2/s.components*s.byteLength;case pc:return i*e*3/s.components*s.byteLength;case cn:return i*e*4/s.components*s.byteLength;case pa:return i*e*4/s.components*s.byteLength;case yr:case br:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Mr:case Sr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case ga:case xa:return Math.max(i,16)*Math.max(e,8)/4;case ma:case _a:return Math.max(i,8)*Math.max(e,8)/2;case va:case ya:case Ma:case Sa:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case ba:case Er:case Ea:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case wa:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Ta:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Aa:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Ca:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Ra:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Pa:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Ia:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case La:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case Da:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case Na:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Ua:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case Fa:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Oa:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Ba:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case za:case ka:case Va:return Math.ceil(i/4)*Math.ceil(e/4)*16;case Ha:case Ga:return Math.ceil(i/4)*Math.ceil(e/4)*8;case wr:case Wa:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Cp(i){switch(i){case Yt:case cc:return{byteLength:1,components:1};case bs:case hc:case Ln:return{byteLength:2,components:1};case ha:case ua:return{byteLength:2,components:4};case yn:case ca:case bn:return{byteLength:4,components:1};case uc:case dc:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"185"}}));typeof window<"u"&&(window.__THREE__?De("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="185");function sd(){let i=null,e=!1,t=null,n=null;function s(r,o){t(r,o),n=i.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&i!==null&&(n=i.requestAnimationFrame(s),e=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){i=r}}}function Pp(i){let e=new WeakMap;function t(a,l){let c=a.array,h=a.usage,d=c.byteLength,u=i.createBuffer();i.bindBuffer(l,u),i.bufferData(l,c,h),a.onUploadCallback();let f;if(c instanceof Float32Array)f=i.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=i.HALF_FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?f=i.HALF_FLOAT:f=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=i.SHORT;else if(c instanceof Uint32Array)f=i.UNSIGNED_INT;else if(c instanceof Int32Array)f=i.INT;else if(c instanceof Int8Array)f=i.BYTE;else if(c instanceof Uint8Array)f=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:u,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:d}}function n(a,l,c){let h=l.array,d=l.updateRanges;if(i.bindBuffer(c,a),d.length===0)i.bufferSubData(c,0,h);else{d.sort((f,g)=>f.start-g.start);let u=0;for(let f=1;f<d.length;f++){let g=d[u],y=d[f];y.start<=g.start+g.count+1?g.count=Math.max(g.count,y.start+y.count-g.start):(++u,d[u]=y)}d.length=u+1;for(let f=0,g=d.length;f<g;f++){let y=d[f];i.bufferSubData(c,y.start*h.BYTES_PER_ELEMENT,h,y.start,y.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function r(a){a.isInterleavedBufferAttribute&&(a=a.data);let l=e.get(a);l&&(i.deleteBuffer(l.buffer),e.delete(a))}function o(a,l){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){let h=e.get(a);(!h||h.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let c=e.get(a);if(c===void 0)e.set(a,t(a,l));else if(c.version<a.version){if(c.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,a,l),c.version=a.version}}return{get:s,remove:r,update:o}}var Ip=`#ifdef USE_ALPHAHASH
|
|
11
11
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
12
|
-
#endif`,
|
|
12
|
+
#endif`,Lp=`#ifdef USE_ALPHAHASH
|
|
13
13
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
14
14
|
float hash2D( vec2 value ) {
|
|
15
15
|
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|
@@ -44,20 +44,20 @@ window.__ModuleLoader__.load({
|
|
|
44
44
|
: cases.z;
|
|
45
45
|
return clamp( threshold , 1.0e-6, 1.0 );
|
|
46
46
|
}
|
|
47
|
-
#endif`,
|
|
47
|
+
#endif`,Dp=`#ifdef USE_ALPHAMAP
|
|
48
48
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
49
|
-
#endif`,
|
|
49
|
+
#endif`,Np=`#ifdef USE_ALPHAMAP
|
|
50
50
|
uniform sampler2D alphaMap;
|
|
51
|
-
#endif`,
|
|
51
|
+
#endif`,Up=`#ifdef USE_ALPHATEST
|
|
52
52
|
#ifdef ALPHA_TO_COVERAGE
|
|
53
53
|
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
|
|
54
54
|
if ( diffuseColor.a == 0.0 ) discard;
|
|
55
55
|
#else
|
|
56
56
|
if ( diffuseColor.a < alphaTest ) discard;
|
|
57
57
|
#endif
|
|
58
|
-
#endif`,
|
|
58
|
+
#endif`,Fp=`#ifdef USE_ALPHATEST
|
|
59
59
|
uniform float alphaTest;
|
|
60
|
-
#endif`,
|
|
60
|
+
#endif`,Op=`#ifdef USE_AOMAP
|
|
61
61
|
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
62
62
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
63
63
|
#if defined( USE_CLEARCOAT )
|
|
@@ -70,10 +70,10 @@ window.__ModuleLoader__.load({
|
|
|
70
70
|
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
71
71
|
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
72
72
|
#endif
|
|
73
|
-
#endif`,
|
|
73
|
+
#endif`,Bp=`#ifdef USE_AOMAP
|
|
74
74
|
uniform sampler2D aoMap;
|
|
75
75
|
uniform float aoMapIntensity;
|
|
76
|
-
#endif`,
|
|
76
|
+
#endif`,zp=`#ifdef USE_BATCHING
|
|
77
77
|
#if ! defined( GL_ANGLE_multi_draw )
|
|
78
78
|
#define gl_DrawID _gl_DrawID
|
|
79
79
|
uniform int _gl_DrawID;
|
|
@@ -107,15 +107,15 @@ window.__ModuleLoader__.load({
|
|
|
107
107
|
int y = j / size;
|
|
108
108
|
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
|
|
109
109
|
}
|
|
110
|
-
#endif`,
|
|
110
|
+
#endif`,kp=`#ifdef USE_BATCHING
|
|
111
111
|
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
|
112
|
-
#endif`,
|
|
112
|
+
#endif`,Vp=`vec3 transformed = vec3( position );
|
|
113
113
|
#ifdef USE_ALPHAHASH
|
|
114
114
|
vPosition = vec3( position );
|
|
115
|
-
#endif`,
|
|
115
|
+
#endif`,Hp=`vec3 objectNormal = vec3( normal );
|
|
116
116
|
#ifdef USE_TANGENT
|
|
117
117
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
118
|
-
#endif`,
|
|
118
|
+
#endif`,Gp=`float G_BlinnPhong_Implicit( ) {
|
|
119
119
|
return 0.25;
|
|
120
120
|
}
|
|
121
121
|
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
|
@@ -129,7 +129,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
129
129
|
float G = G_BlinnPhong_Implicit( );
|
|
130
130
|
float D = D_BlinnPhong( shininess, dotNH );
|
|
131
131
|
return F * ( G * D );
|
|
132
|
-
} // validated`,
|
|
132
|
+
} // validated`,Wp=`#ifdef USE_IRIDESCENCE
|
|
133
133
|
const mat3 XYZ_TO_REC709 = mat3(
|
|
134
134
|
3.2404542, -0.9692660, 0.0556434,
|
|
135
135
|
-1.5371385, 1.8760108, -0.2040259,
|
|
@@ -192,7 +192,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
192
192
|
}
|
|
193
193
|
return max( I, vec3( 0.0 ) );
|
|
194
194
|
}
|
|
195
|
-
#endif`,
|
|
195
|
+
#endif`,Xp=`#ifdef USE_BUMPMAP
|
|
196
196
|
uniform sampler2D bumpMap;
|
|
197
197
|
uniform float bumpScale;
|
|
198
198
|
vec2 dHdxy_fwd() {
|
|
@@ -213,7 +213,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
213
213
|
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
214
214
|
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|
215
215
|
}
|
|
216
|
-
#endif`,
|
|
216
|
+
#endif`,qp=`#if NUM_CLIPPING_PLANES > 0
|
|
217
217
|
vec4 plane;
|
|
218
218
|
#ifdef ALPHA_TO_COVERAGE
|
|
219
219
|
float distanceToPlane, distanceGradient;
|
|
@@ -259,20 +259,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
259
259
|
if ( clipped ) discard;
|
|
260
260
|
#endif
|
|
261
261
|
#endif
|
|
262
|
-
#endif`,
|
|
262
|
+
#endif`,Yp=`#if NUM_CLIPPING_PLANES > 0
|
|
263
263
|
varying vec3 vClipPosition;
|
|
264
264
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
265
|
-
#endif`,
|
|
265
|
+
#endif`,Zp=`#if NUM_CLIPPING_PLANES > 0
|
|
266
266
|
varying vec3 vClipPosition;
|
|
267
|
-
#endif
|
|
267
|
+
#endif`,$p=`#if NUM_CLIPPING_PLANES > 0
|
|
268
268
|
vClipPosition = - mvPosition.xyz;
|
|
269
|
-
#endif`,
|
|
269
|
+
#endif`,Jp=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
270
270
|
diffuseColor *= vColor;
|
|
271
|
-
#endif`,
|
|
271
|
+
#endif`,Kp=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
272
272
|
varying vec4 vColor;
|
|
273
|
-
#endif`,
|
|
273
|
+
#endif`,jp=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
274
274
|
varying vec4 vColor;
|
|
275
|
-
#endif
|
|
275
|
+
#endif`,Qp=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
276
276
|
vColor = vec4( 1.0 );
|
|
277
277
|
#endif
|
|
278
278
|
#ifdef USE_COLOR_ALPHA
|
|
@@ -285,7 +285,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
285
285
|
#endif
|
|
286
286
|
#ifdef USE_BATCHING_COLOR
|
|
287
287
|
vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
|
|
288
|
-
#endif`,
|
|
288
|
+
#endif`,em=`#define PI 3.141592653589793
|
|
289
289
|
#define PI2 6.283185307179586
|
|
290
290
|
#define PI_HALF 1.5707963267948966
|
|
291
291
|
#define RECIPROCAL_PI 0.3183098861837907
|
|
@@ -356,7 +356,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
|
|
356
356
|
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
357
357
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
358
358
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
359
|
-
} // validated`,
|
|
359
|
+
} // validated`,tm=`#ifdef ENVMAP_TYPE_CUBE_UV
|
|
360
360
|
#define cubeUV_minMipLevel 4.0
|
|
361
361
|
#define cubeUV_minTileSize 16.0
|
|
362
362
|
float getFace( vec3 direction ) {
|
|
@@ -449,7 +449,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
|
449
449
|
return vec4( mix( color0, color1, mipF ), 1.0 );
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
|
-
#endif`,
|
|
452
|
+
#endif`,nm=`vec3 transformedNormal = objectNormal;
|
|
453
453
|
#ifdef USE_TANGENT
|
|
454
454
|
vec3 transformedTangent = objectTangent;
|
|
455
455
|
#endif
|
|
@@ -475,21 +475,21 @@ transformedNormal = normalMatrix * transformedNormal;
|
|
|
475
475
|
#endif
|
|
476
476
|
#ifdef USE_TANGENT
|
|
477
477
|
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
|
478
|
-
#endif`,
|
|
478
|
+
#endif`,im=`#ifdef USE_DISPLACEMENTMAP
|
|
479
479
|
uniform sampler2D displacementMap;
|
|
480
480
|
uniform float displacementScale;
|
|
481
481
|
uniform float displacementBias;
|
|
482
|
-
#endif`,
|
|
482
|
+
#endif`,sm=`#ifdef USE_DISPLACEMENTMAP
|
|
483
483
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
484
|
-
#endif`,
|
|
484
|
+
#endif`,rm=`#ifdef USE_EMISSIVEMAP
|
|
485
485
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
486
486
|
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
|
487
487
|
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
|
488
488
|
#endif
|
|
489
489
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
490
|
-
#endif`,
|
|
490
|
+
#endif`,om=`#ifdef USE_EMISSIVEMAP
|
|
491
491
|
uniform sampler2D emissiveMap;
|
|
492
|
-
#endif`,
|
|
492
|
+
#endif`,am="gl_FragColor = linearToOutputTexel( gl_FragColor );",lm=`vec4 LinearTransferOETF( in vec4 value ) {
|
|
493
493
|
return value;
|
|
494
494
|
}
|
|
495
495
|
vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
@@ -497,7 +497,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
|
497
497
|
}
|
|
498
498
|
vec4 sRGBTransferOETF( in vec4 value ) {
|
|
499
499
|
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
|
|
500
|
-
}`,
|
|
500
|
+
}`,cm=`#ifdef USE_ENVMAP
|
|
501
501
|
#ifdef ENV_WORLDPOS
|
|
502
502
|
vec3 cameraToFrag;
|
|
503
503
|
if ( isOrthographic ) {
|
|
@@ -524,7 +524,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
524
524
|
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
|
525
525
|
#endif
|
|
526
526
|
#endif
|
|
527
|
-
#endif`,
|
|
527
|
+
#endif`,hm=`#ifdef USE_ENVMAP
|
|
528
528
|
uniform float envMapIntensity;
|
|
529
529
|
uniform mat3 envMapRotation;
|
|
530
530
|
#ifdef ENVMAP_TYPE_CUBE
|
|
@@ -532,7 +532,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
532
532
|
#else
|
|
533
533
|
uniform sampler2D envMap;
|
|
534
534
|
#endif
|
|
535
|
-
#endif`,
|
|
535
|
+
#endif`,um=`#ifdef USE_ENVMAP
|
|
536
536
|
uniform float reflectivity;
|
|
537
537
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
538
538
|
#define ENV_WORLDPOS
|
|
@@ -543,7 +543,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
543
543
|
#else
|
|
544
544
|
varying vec3 vReflect;
|
|
545
545
|
#endif
|
|
546
|
-
#endif`,
|
|
546
|
+
#endif`,dm=`#ifdef USE_ENVMAP
|
|
547
547
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
548
548
|
#define ENV_WORLDPOS
|
|
549
549
|
#endif
|
|
@@ -554,7 +554,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
554
554
|
varying vec3 vReflect;
|
|
555
555
|
uniform float refractionRatio;
|
|
556
556
|
#endif
|
|
557
|
-
#endif`,
|
|
557
|
+
#endif`,fm=`#ifdef USE_ENVMAP
|
|
558
558
|
#ifdef ENV_WORLDPOS
|
|
559
559
|
vWorldPosition = worldPosition.xyz;
|
|
560
560
|
#else
|
|
@@ -571,18 +571,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
571
571
|
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
|
572
572
|
#endif
|
|
573
573
|
#endif
|
|
574
|
-
#endif`,
|
|
574
|
+
#endif`,pm=`#ifdef USE_FOG
|
|
575
575
|
vFogDepth = - mvPosition.z;
|
|
576
|
-
#endif`,
|
|
576
|
+
#endif`,mm=`#ifdef USE_FOG
|
|
577
577
|
varying float vFogDepth;
|
|
578
|
-
#endif`,
|
|
578
|
+
#endif`,gm=`#ifdef USE_FOG
|
|
579
579
|
#ifdef FOG_EXP2
|
|
580
580
|
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
|
581
581
|
#else
|
|
582
582
|
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
|
583
583
|
#endif
|
|
584
584
|
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
|
585
|
-
#endif`,
|
|
585
|
+
#endif`,_m=`#ifdef USE_FOG
|
|
586
586
|
uniform vec3 fogColor;
|
|
587
587
|
varying float vFogDepth;
|
|
588
588
|
#ifdef FOG_EXP2
|
|
@@ -591,7 +591,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
591
591
|
uniform float fogNear;
|
|
592
592
|
uniform float fogFar;
|
|
593
593
|
#endif
|
|
594
|
-
#endif`,
|
|
594
|
+
#endif`,xm=`#ifdef USE_GRADIENTMAP
|
|
595
595
|
uniform sampler2D gradientMap;
|
|
596
596
|
#endif
|
|
597
597
|
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
@@ -603,12 +603,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
|
603
603
|
vec2 fw = fwidth( coord ) * 0.5;
|
|
604
604
|
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
|
605
605
|
#endif
|
|
606
|
-
}`,
|
|
606
|
+
}`,vm=`#ifdef USE_LIGHTMAP
|
|
607
607
|
uniform sampler2D lightMap;
|
|
608
608
|
uniform float lightMapIntensity;
|
|
609
|
-
#endif`,
|
|
609
|
+
#endif`,ym=`LambertMaterial material;
|
|
610
610
|
material.diffuseColor = diffuseColor.rgb;
|
|
611
|
-
material.specularStrength = specularStrength;`,
|
|
611
|
+
material.specularStrength = specularStrength;`,bm=`varying vec3 vViewPosition;
|
|
612
612
|
struct LambertMaterial {
|
|
613
613
|
vec3 diffuseColor;
|
|
614
614
|
float specularStrength;
|
|
@@ -622,7 +622,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
|
|
|
622
622
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
623
623
|
}
|
|
624
624
|
#define RE_Direct RE_Direct_Lambert
|
|
625
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,
|
|
625
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Mm=`uniform bool receiveShadow;
|
|
626
626
|
uniform vec3 ambientLightColor;
|
|
627
627
|
#if defined( USE_LIGHT_PROBES )
|
|
628
628
|
uniform vec3 lightProbe[ 9 ];
|
|
@@ -739,7 +739,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
739
739
|
return irradiance;
|
|
740
740
|
}
|
|
741
741
|
#endif
|
|
742
|
-
#include <lightprobes_pars_fragment>`,
|
|
742
|
+
#include <lightprobes_pars_fragment>`,Sm=`#ifdef USE_ENVMAP
|
|
743
743
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
744
744
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
745
745
|
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
|
|
@@ -772,8 +772,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
772
772
|
#endif
|
|
773
773
|
}
|
|
774
774
|
#endif
|
|
775
|
-
#endif`,
|
|
776
|
-
material.diffuseColor = diffuseColor.rgb;`,
|
|
775
|
+
#endif`,Em=`ToonMaterial material;
|
|
776
|
+
material.diffuseColor = diffuseColor.rgb;`,wm=`varying vec3 vViewPosition;
|
|
777
777
|
struct ToonMaterial {
|
|
778
778
|
vec3 diffuseColor;
|
|
779
779
|
};
|
|
@@ -785,11 +785,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
|
|
|
785
785
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
786
786
|
}
|
|
787
787
|
#define RE_Direct RE_Direct_Toon
|
|
788
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,
|
|
788
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Tm=`BlinnPhongMaterial material;
|
|
789
789
|
material.diffuseColor = diffuseColor.rgb;
|
|
790
790
|
material.specularColor = specular;
|
|
791
791
|
material.specularShininess = shininess;
|
|
792
|
-
material.specularStrength = specularStrength;`,
|
|
792
|
+
material.specularStrength = specularStrength;`,Am=`varying vec3 vViewPosition;
|
|
793
793
|
struct BlinnPhongMaterial {
|
|
794
794
|
vec3 diffuseColor;
|
|
795
795
|
vec3 specularColor;
|
|
@@ -806,7 +806,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
|
|
|
806
806
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
807
807
|
}
|
|
808
808
|
#define RE_Direct RE_Direct_BlinnPhong
|
|
809
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,
|
|
809
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Cm=`PhysicalMaterial material;
|
|
810
810
|
material.diffuseColor = diffuseColor.rgb;
|
|
811
811
|
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
812
812
|
material.metalness = metalnessFactor;
|
|
@@ -896,7 +896,7 @@ material.roughness = min( material.roughness, 1.0 );
|
|
|
896
896
|
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
897
897
|
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
898
898
|
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
899
|
-
#endif`,
|
|
899
|
+
#endif`,Rm=`uniform sampler2D dfgLUT;
|
|
900
900
|
struct PhysicalMaterial {
|
|
901
901
|
vec3 diffuseColor;
|
|
902
902
|
vec3 diffuseContribution;
|
|
@@ -1256,7 +1256,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
|
|
|
1256
1256
|
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|
1257
1257
|
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|
1258
1258
|
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|
1259
|
-
}`,
|
|
1259
|
+
}`,Pm=`
|
|
1260
1260
|
vec3 geometryPosition = - vViewPosition;
|
|
1261
1261
|
vec3 geometryNormal = normal;
|
|
1262
1262
|
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
@@ -1378,7 +1378,7 @@ IncidentLight directLight;
|
|
|
1378
1378
|
#if defined( RE_IndirectSpecular )
|
|
1379
1379
|
vec3 radiance = vec3( 0.0 );
|
|
1380
1380
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
1381
|
-
#endif`,
|
|
1381
|
+
#endif`,Im=`#if defined( RE_IndirectDiffuse )
|
|
1382
1382
|
#ifdef USE_LIGHTMAP
|
|
1383
1383
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
1384
1384
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
@@ -1399,7 +1399,7 @@ IncidentLight directLight;
|
|
|
1399
1399
|
#ifdef USE_CLEARCOAT
|
|
1400
1400
|
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|
1401
1401
|
#endif
|
|
1402
|
-
#endif`,
|
|
1402
|
+
#endif`,Lm=`#if defined( RE_IndirectDiffuse )
|
|
1403
1403
|
#if defined( LAMBERT ) || defined( PHONG )
|
|
1404
1404
|
irradiance += iblIrradiance;
|
|
1405
1405
|
#endif
|
|
@@ -1407,7 +1407,7 @@ IncidentLight directLight;
|
|
|
1407
1407
|
#endif
|
|
1408
1408
|
#if defined( RE_IndirectSpecular )
|
|
1409
1409
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1410
|
-
#endif`,
|
|
1410
|
+
#endif`,Dm=`#ifdef USE_LIGHT_PROBES_GRID
|
|
1411
1411
|
uniform highp sampler3D probesSH;
|
|
1412
1412
|
uniform vec3 probesMin;
|
|
1413
1413
|
uniform vec3 probesMax;
|
|
@@ -1452,27 +1452,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1452
1452
|
result += c8 * 0.429043 * ( x * x - y * y );
|
|
1453
1453
|
return max( result, vec3( 0.0 ) );
|
|
1454
1454
|
}
|
|
1455
|
-
#endif`,
|
|
1455
|
+
#endif`,Nm=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1456
1456
|
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
1457
|
-
#endif`,
|
|
1457
|
+
#endif`,Um=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1458
1458
|
uniform float logDepthBufFC;
|
|
1459
1459
|
varying float vFragDepth;
|
|
1460
1460
|
varying float vIsPerspective;
|
|
1461
|
-
#endif`,
|
|
1461
|
+
#endif`,Fm=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1462
1462
|
varying float vFragDepth;
|
|
1463
1463
|
varying float vIsPerspective;
|
|
1464
|
-
#endif`,
|
|
1464
|
+
#endif`,Om=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1465
1465
|
vFragDepth = 1.0 + gl_Position.w;
|
|
1466
1466
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
1467
|
-
#endif`,
|
|
1467
|
+
#endif`,Bm=`#ifdef USE_MAP
|
|
1468
1468
|
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
1469
1469
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
1470
1470
|
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
|
1471
1471
|
#endif
|
|
1472
1472
|
diffuseColor *= sampledDiffuseColor;
|
|
1473
|
-
#endif`,
|
|
1473
|
+
#endif`,zm=`#ifdef USE_MAP
|
|
1474
1474
|
uniform sampler2D map;
|
|
1475
|
-
#endif`,
|
|
1475
|
+
#endif`,km=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
1476
1476
|
#if defined( USE_POINTS_UV )
|
|
1477
1477
|
vec2 uv = vUv;
|
|
1478
1478
|
#else
|
|
@@ -1484,7 +1484,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1484
1484
|
#endif
|
|
1485
1485
|
#ifdef USE_ALPHAMAP
|
|
1486
1486
|
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|
1487
|
-
#endif`,
|
|
1487
|
+
#endif`,Vm=`#if defined( USE_POINTS_UV )
|
|
1488
1488
|
varying vec2 vUv;
|
|
1489
1489
|
#else
|
|
1490
1490
|
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
@@ -1496,19 +1496,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1496
1496
|
#endif
|
|
1497
1497
|
#ifdef USE_ALPHAMAP
|
|
1498
1498
|
uniform sampler2D alphaMap;
|
|
1499
|
-
#endif`,
|
|
1499
|
+
#endif`,Hm=`float metalnessFactor = metalness;
|
|
1500
1500
|
#ifdef USE_METALNESSMAP
|
|
1501
1501
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
1502
1502
|
metalnessFactor *= texelMetalness.b;
|
|
1503
|
-
#endif`,
|
|
1503
|
+
#endif`,Gm=`#ifdef USE_METALNESSMAP
|
|
1504
1504
|
uniform sampler2D metalnessMap;
|
|
1505
|
-
#endif`,
|
|
1505
|
+
#endif`,Wm=`#ifdef USE_INSTANCING_MORPH
|
|
1506
1506
|
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
1507
1507
|
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
|
|
1508
1508
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1509
1509
|
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
|
|
1510
1510
|
}
|
|
1511
|
-
#endif`,
|
|
1511
|
+
#endif`,Xm=`#if defined( USE_MORPHCOLORS )
|
|
1512
1512
|
vColor *= morphTargetBaseInfluence;
|
|
1513
1513
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1514
1514
|
#if defined( USE_COLOR_ALPHA )
|
|
@@ -1517,12 +1517,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1517
1517
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|
1518
1518
|
#endif
|
|
1519
1519
|
}
|
|
1520
|
-
#endif`,
|
|
1520
|
+
#endif`,qm=`#ifdef USE_MORPHNORMALS
|
|
1521
1521
|
objectNormal *= morphTargetBaseInfluence;
|
|
1522
1522
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1523
1523
|
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
1524
1524
|
}
|
|
1525
|
-
#endif`,
|
|
1525
|
+
#endif`,Ym=`#ifdef USE_MORPHTARGETS
|
|
1526
1526
|
#ifndef USE_INSTANCING_MORPH
|
|
1527
1527
|
uniform float morphTargetBaseInfluence;
|
|
1528
1528
|
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
@@ -1536,12 +1536,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1536
1536
|
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
1537
1537
|
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
1538
1538
|
}
|
|
1539
|
-
#endif`,
|
|
1539
|
+
#endif`,Zm=`#ifdef USE_MORPHTARGETS
|
|
1540
1540
|
transformed *= morphTargetBaseInfluence;
|
|
1541
1541
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1542
1542
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
1543
1543
|
}
|
|
1544
|
-
#endif
|
|
1544
|
+
#endif`,$m=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
1545
1545
|
#ifdef FLAT_SHADED
|
|
1546
1546
|
vec3 fdx = dFdx( vViewPosition );
|
|
1547
1547
|
vec3 fdy = dFdy( vViewPosition );
|
|
@@ -1582,7 +1582,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1582
1582
|
tbn2[1] *= faceDirection;
|
|
1583
1583
|
#endif
|
|
1584
1584
|
#endif
|
|
1585
|
-
vec3 nonPerturbedNormal = normal;`,
|
|
1585
|
+
vec3 nonPerturbedNormal = normal;`,Jm=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
1586
1586
|
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1587
1587
|
#ifdef FLIP_SIDED
|
|
1588
1588
|
normal = - normal;
|
|
@@ -1600,19 +1600,19 @@ vec3 nonPerturbedNormal = normal;`,qm=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1600
1600
|
normal = normalize( tbn * mapN );
|
|
1601
1601
|
#elif defined( USE_BUMPMAP )
|
|
1602
1602
|
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
1603
|
-
#endif`,
|
|
1603
|
+
#endif`,Km=`#ifndef FLAT_SHADED
|
|
1604
1604
|
varying vec3 vNormal;
|
|
1605
1605
|
#ifdef USE_TANGENT
|
|
1606
1606
|
varying vec3 vTangent;
|
|
1607
1607
|
varying vec3 vBitangent;
|
|
1608
1608
|
#endif
|
|
1609
|
-
#endif`,
|
|
1609
|
+
#endif`,jm=`#ifndef FLAT_SHADED
|
|
1610
1610
|
varying vec3 vNormal;
|
|
1611
1611
|
#ifdef USE_TANGENT
|
|
1612
1612
|
varying vec3 vTangent;
|
|
1613
1613
|
varying vec3 vBitangent;
|
|
1614
1614
|
#endif
|
|
1615
|
-
#endif
|
|
1615
|
+
#endif`,Qm=`#ifndef FLAT_SHADED
|
|
1616
1616
|
vNormal = normalize( transformedNormal );
|
|
1617
1617
|
#ifdef USE_TANGENT
|
|
1618
1618
|
vTangent = normalize( transformedTangent );
|
|
@@ -1621,7 +1621,7 @@ vec3 nonPerturbedNormal = normal;`,qm=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1621
1621
|
vBitangent = - vBitangent;
|
|
1622
1622
|
#endif
|
|
1623
1623
|
#endif
|
|
1624
|
-
#endif`,
|
|
1624
|
+
#endif`,eg=`#ifdef USE_NORMALMAP
|
|
1625
1625
|
uniform sampler2D normalMap;
|
|
1626
1626
|
uniform vec2 normalScale;
|
|
1627
1627
|
#endif
|
|
@@ -1643,13 +1643,13 @@ vec3 nonPerturbedNormal = normal;`,qm=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1643
1643
|
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
|
1644
1644
|
return mat3( T * scale, B * scale, N );
|
|
1645
1645
|
}
|
|
1646
|
-
#endif`,
|
|
1646
|
+
#endif`,tg=`#ifdef USE_CLEARCOAT
|
|
1647
1647
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
1648
|
-
#endif`,
|
|
1648
|
+
#endif`,ng=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
1649
1649
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1650
1650
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
1651
1651
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
1652
|
-
#endif`,
|
|
1652
|
+
#endif`,ig=`#ifdef USE_CLEARCOATMAP
|
|
1653
1653
|
uniform sampler2D clearcoatMap;
|
|
1654
1654
|
#endif
|
|
1655
1655
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
@@ -1658,18 +1658,18 @@ vec3 nonPerturbedNormal = normal;`,qm=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1658
1658
|
#endif
|
|
1659
1659
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
1660
1660
|
uniform sampler2D clearcoatRoughnessMap;
|
|
1661
|
-
#endif`,
|
|
1661
|
+
#endif`,sg=`#ifdef USE_IRIDESCENCEMAP
|
|
1662
1662
|
uniform sampler2D iridescenceMap;
|
|
1663
1663
|
#endif
|
|
1664
1664
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
1665
1665
|
uniform sampler2D iridescenceThicknessMap;
|
|
1666
|
-
#endif`,
|
|
1666
|
+
#endif`,rg=`#ifdef OPAQUE
|
|
1667
1667
|
diffuseColor.a = 1.0;
|
|
1668
1668
|
#endif
|
|
1669
1669
|
#ifdef USE_TRANSMISSION
|
|
1670
1670
|
diffuseColor.a *= material.transmissionAlpha;
|
|
1671
1671
|
#endif
|
|
1672
|
-
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,
|
|
1672
|
+
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,og=`vec3 packNormalToRGB( const in vec3 normal ) {
|
|
1673
1673
|
return normalize( normal ) * 0.5 + 0.5;
|
|
1674
1674
|
}
|
|
1675
1675
|
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
|
@@ -1748,9 +1748,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
1748
1748
|
#else
|
|
1749
1749
|
return ( near * far ) / ( ( far - near ) * depth - far );
|
|
1750
1750
|
#endif
|
|
1751
|
-
}`,
|
|
1751
|
+
}`,ag=`#ifdef PREMULTIPLIED_ALPHA
|
|
1752
1752
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
1753
|
-
#endif`,
|
|
1753
|
+
#endif`,lg=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
1754
1754
|
#ifdef USE_BATCHING
|
|
1755
1755
|
mvPosition = batchingMatrix * mvPosition;
|
|
1756
1756
|
#endif
|
|
@@ -1758,22 +1758,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
1758
1758
|
mvPosition = instanceMatrix * mvPosition;
|
|
1759
1759
|
#endif
|
|
1760
1760
|
mvPosition = modelViewMatrix * mvPosition;
|
|
1761
|
-
gl_Position = projectionMatrix * mvPosition;`,
|
|
1761
|
+
gl_Position = projectionMatrix * mvPosition;`,cg=`#ifdef DITHERING
|
|
1762
1762
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
1763
|
-
#endif`,
|
|
1763
|
+
#endif`,hg=`#ifdef DITHERING
|
|
1764
1764
|
vec3 dithering( vec3 color ) {
|
|
1765
1765
|
float grid_position = rand( gl_FragCoord.xy );
|
|
1766
1766
|
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|
1767
1767
|
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|
1768
1768
|
return color + dither_shift_RGB;
|
|
1769
1769
|
}
|
|
1770
|
-
#endif`,
|
|
1770
|
+
#endif`,ug=`float roughnessFactor = roughness;
|
|
1771
1771
|
#ifdef USE_ROUGHNESSMAP
|
|
1772
1772
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
1773
1773
|
roughnessFactor *= texelRoughness.g;
|
|
1774
|
-
#endif`,
|
|
1774
|
+
#endif`,dg=`#ifdef USE_ROUGHNESSMAP
|
|
1775
1775
|
uniform sampler2D roughnessMap;
|
|
1776
|
-
#endif`,
|
|
1776
|
+
#endif`,fg=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
1777
1777
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
1778
1778
|
#endif
|
|
1779
1779
|
#if NUM_SPOT_LIGHT_MAPS > 0
|
|
@@ -1973,7 +1973,7 @@ gl_Position = projectionMatrix * mvPosition;`,rg=`#ifdef DITHERING
|
|
|
1973
1973
|
}
|
|
1974
1974
|
#endif
|
|
1975
1975
|
#endif
|
|
1976
|
-
#endif`,
|
|
1976
|
+
#endif`,pg=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
1977
1977
|
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
|
1978
1978
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
1979
1979
|
#endif
|
|
@@ -2014,7 +2014,7 @@ gl_Position = projectionMatrix * mvPosition;`,rg=`#ifdef DITHERING
|
|
|
2014
2014
|
};
|
|
2015
2015
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
2016
2016
|
#endif
|
|
2017
|
-
#endif`,
|
|
2017
|
+
#endif`,mg=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
2018
2018
|
#ifdef HAS_NORMAL
|
|
2019
2019
|
vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
|
|
2020
2020
|
#else
|
|
@@ -2050,7 +2050,7 @@ gl_Position = projectionMatrix * mvPosition;`,rg=`#ifdef DITHERING
|
|
|
2050
2050
|
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
2051
2051
|
}
|
|
2052
2052
|
#pragma unroll_loop_end
|
|
2053
|
-
#endif`,
|
|
2053
|
+
#endif`,gg=`float getShadowMask() {
|
|
2054
2054
|
float shadow = 1.0;
|
|
2055
2055
|
#ifdef USE_SHADOWMAP
|
|
2056
2056
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
@@ -2082,12 +2082,12 @@ gl_Position = projectionMatrix * mvPosition;`,rg=`#ifdef DITHERING
|
|
|
2082
2082
|
#endif
|
|
2083
2083
|
#endif
|
|
2084
2084
|
return shadow;
|
|
2085
|
-
}`,
|
|
2085
|
+
}`,_g=`#ifdef USE_SKINNING
|
|
2086
2086
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
2087
2087
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
2088
2088
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
2089
2089
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
2090
|
-
#endif`,
|
|
2090
|
+
#endif`,xg=`#ifdef USE_SKINNING
|
|
2091
2091
|
uniform mat4 bindMatrix;
|
|
2092
2092
|
uniform mat4 bindMatrixInverse;
|
|
2093
2093
|
uniform highp sampler2D boneTexture;
|
|
@@ -2102,7 +2102,7 @@ gl_Position = projectionMatrix * mvPosition;`,rg=`#ifdef DITHERING
|
|
|
2102
2102
|
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
2103
2103
|
return mat4( v1, v2, v3, v4 );
|
|
2104
2104
|
}
|
|
2105
|
-
#endif`,
|
|
2105
|
+
#endif`,vg=`#ifdef USE_SKINNING
|
|
2106
2106
|
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
|
2107
2107
|
vec4 skinned = vec4( 0.0 );
|
|
2108
2108
|
skinned += boneMatX * skinVertex * skinWeight.x;
|
|
@@ -2110,7 +2110,7 @@ gl_Position = projectionMatrix * mvPosition;`,rg=`#ifdef DITHERING
|
|
|
2110
2110
|
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|
2111
2111
|
skinned += boneMatW * skinVertex * skinWeight.w;
|
|
2112
2112
|
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|
2113
|
-
#endif`,
|
|
2113
|
+
#endif`,yg=`#ifdef USE_SKINNING
|
|
2114
2114
|
mat4 skinMatrix = mat4( 0.0 );
|
|
2115
2115
|
skinMatrix += skinWeight.x * boneMatX;
|
|
2116
2116
|
skinMatrix += skinWeight.y * boneMatY;
|
|
@@ -2121,17 +2121,17 @@ gl_Position = projectionMatrix * mvPosition;`,rg=`#ifdef DITHERING
|
|
|
2121
2121
|
#ifdef USE_TANGENT
|
|
2122
2122
|
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
2123
2123
|
#endif
|
|
2124
|
-
#endif`,
|
|
2124
|
+
#endif`,bg=`float specularStrength;
|
|
2125
2125
|
#ifdef USE_SPECULARMAP
|
|
2126
2126
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
2127
2127
|
specularStrength = texelSpecular.r;
|
|
2128
2128
|
#else
|
|
2129
2129
|
specularStrength = 1.0;
|
|
2130
|
-
#endif`,
|
|
2130
|
+
#endif`,Mg=`#ifdef USE_SPECULARMAP
|
|
2131
2131
|
uniform sampler2D specularMap;
|
|
2132
|
-
#endif`,
|
|
2132
|
+
#endif`,Sg=`#if defined( TONE_MAPPING )
|
|
2133
2133
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
2134
|
-
#endif`,
|
|
2134
|
+
#endif`,Eg=`#ifndef saturate
|
|
2135
2135
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
2136
2136
|
#endif
|
|
2137
2137
|
uniform float toneMappingExposure;
|
|
@@ -2228,7 +2228,7 @@ vec3 NeutralToneMapping( vec3 color ) {
|
|
|
2228
2228
|
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
|
2229
2229
|
return mix( color, vec3( newPeak ), g );
|
|
2230
2230
|
}
|
|
2231
|
-
vec3 CustomToneMapping( vec3 color ) { return color; }`,
|
|
2231
|
+
vec3 CustomToneMapping( vec3 color ) { return color; }`,wg=`#ifdef USE_TRANSMISSION
|
|
2232
2232
|
material.transmission = transmission;
|
|
2233
2233
|
material.transmissionAlpha = 1.0;
|
|
2234
2234
|
material.thickness = thickness;
|
|
@@ -2249,7 +2249,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,bg=`#ifdef USE_TRANSMISS
|
|
|
2249
2249
|
material.attenuationColor, material.attenuationDistance );
|
|
2250
2250
|
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
2251
2251
|
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
2252
|
-
#endif`,
|
|
2252
|
+
#endif`,Tg=`#ifdef USE_TRANSMISSION
|
|
2253
2253
|
uniform float transmission;
|
|
2254
2254
|
uniform float thickness;
|
|
2255
2255
|
uniform float attenuationDistance;
|
|
@@ -2375,7 +2375,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,bg=`#ifdef USE_TRANSMISS
|
|
|
2375
2375
|
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|
2376
2376
|
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|
2377
2377
|
}
|
|
2378
|
-
#endif`,
|
|
2378
|
+
#endif`,Ag=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2379
2379
|
varying vec2 vUv;
|
|
2380
2380
|
#endif
|
|
2381
2381
|
#ifdef USE_MAP
|
|
@@ -2445,7 +2445,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,bg=`#ifdef USE_TRANSMISS
|
|
|
2445
2445
|
#ifdef USE_THICKNESSMAP
|
|
2446
2446
|
uniform mat3 thicknessMapTransform;
|
|
2447
2447
|
varying vec2 vThicknessMapUv;
|
|
2448
|
-
#endif`,
|
|
2448
|
+
#endif`,Cg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2449
2449
|
varying vec2 vUv;
|
|
2450
2450
|
#endif
|
|
2451
2451
|
#ifdef USE_MAP
|
|
@@ -2539,7 +2539,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,bg=`#ifdef USE_TRANSMISS
|
|
|
2539
2539
|
#ifdef USE_THICKNESSMAP
|
|
2540
2540
|
uniform mat3 thicknessMapTransform;
|
|
2541
2541
|
varying vec2 vThicknessMapUv;
|
|
2542
|
-
#endif`,
|
|
2542
|
+
#endif`,Rg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2543
2543
|
vUv = vec3( uv, 1 ).xy;
|
|
2544
2544
|
#endif
|
|
2545
2545
|
#ifdef USE_MAP
|
|
@@ -2610,7 +2610,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,bg=`#ifdef USE_TRANSMISS
|
|
|
2610
2610
|
#endif
|
|
2611
2611
|
#ifdef USE_THICKNESSMAP
|
|
2612
2612
|
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
2613
|
-
#endif`,
|
|
2613
|
+
#endif`,Pg=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
|
2614
2614
|
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
2615
2615
|
#ifdef USE_BATCHING
|
|
2616
2616
|
worldPosition = batchingMatrix * worldPosition;
|
|
@@ -2619,12 +2619,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,bg=`#ifdef USE_TRANSMISS
|
|
|
2619
2619
|
worldPosition = instanceMatrix * worldPosition;
|
|
2620
2620
|
#endif
|
|
2621
2621
|
worldPosition = modelMatrix * worldPosition;
|
|
2622
|
-
#endif`,
|
|
2622
|
+
#endif`,Ig=`varying vec2 vUv;
|
|
2623
2623
|
uniform mat3 uvTransform;
|
|
2624
2624
|
void main() {
|
|
2625
2625
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
2626
2626
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
2627
|
-
}`,
|
|
2627
|
+
}`,Lg=`uniform sampler2D t2D;
|
|
2628
2628
|
uniform float backgroundIntensity;
|
|
2629
2629
|
varying vec2 vUv;
|
|
2630
2630
|
void main() {
|
|
@@ -2636,14 +2636,14 @@ void main() {
|
|
|
2636
2636
|
gl_FragColor = texColor;
|
|
2637
2637
|
#include <tonemapping_fragment>
|
|
2638
2638
|
#include <colorspace_fragment>
|
|
2639
|
-
}`,
|
|
2639
|
+
}`,Dg=`varying vec3 vWorldDirection;
|
|
2640
2640
|
#include <common>
|
|
2641
2641
|
void main() {
|
|
2642
2642
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2643
2643
|
#include <begin_vertex>
|
|
2644
2644
|
#include <project_vertex>
|
|
2645
2645
|
gl_Position.z = gl_Position.w;
|
|
2646
|
-
}`,
|
|
2646
|
+
}`,Ng=`#ifdef ENVMAP_TYPE_CUBE
|
|
2647
2647
|
uniform samplerCube envMap;
|
|
2648
2648
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
2649
2649
|
uniform sampler2D envMap;
|
|
@@ -2665,14 +2665,14 @@ void main() {
|
|
|
2665
2665
|
gl_FragColor = texColor;
|
|
2666
2666
|
#include <tonemapping_fragment>
|
|
2667
2667
|
#include <colorspace_fragment>
|
|
2668
|
-
}`,
|
|
2668
|
+
}`,Ug=`varying vec3 vWorldDirection;
|
|
2669
2669
|
#include <common>
|
|
2670
2670
|
void main() {
|
|
2671
2671
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2672
2672
|
#include <begin_vertex>
|
|
2673
2673
|
#include <project_vertex>
|
|
2674
2674
|
gl_Position.z = gl_Position.w;
|
|
2675
|
-
}`,
|
|
2675
|
+
}`,Fg=`uniform samplerCube tCube;
|
|
2676
2676
|
uniform float tFlip;
|
|
2677
2677
|
uniform float opacity;
|
|
2678
2678
|
varying vec3 vWorldDirection;
|
|
@@ -2682,7 +2682,7 @@ void main() {
|
|
|
2682
2682
|
gl_FragColor.a *= opacity;
|
|
2683
2683
|
#include <tonemapping_fragment>
|
|
2684
2684
|
#include <colorspace_fragment>
|
|
2685
|
-
}`,
|
|
2685
|
+
}`,Og=`#include <common>
|
|
2686
2686
|
#include <batching_pars_vertex>
|
|
2687
2687
|
#include <uv_pars_vertex>
|
|
2688
2688
|
#include <displacementmap_pars_vertex>
|
|
@@ -2709,7 +2709,7 @@ void main() {
|
|
|
2709
2709
|
#include <logdepthbuf_vertex>
|
|
2710
2710
|
#include <clipping_planes_vertex>
|
|
2711
2711
|
vHighPrecisionZW = gl_Position.zw;
|
|
2712
|
-
}`,
|
|
2712
|
+
}`,Bg=`#if DEPTH_PACKING == 3200
|
|
2713
2713
|
uniform float opacity;
|
|
2714
2714
|
#endif
|
|
2715
2715
|
#include <common>
|
|
@@ -2747,7 +2747,7 @@ void main() {
|
|
|
2747
2747
|
#elif DEPTH_PACKING == 3203
|
|
2748
2748
|
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|
2749
2749
|
#endif
|
|
2750
|
-
}`,
|
|
2750
|
+
}`,zg=`#define DISTANCE
|
|
2751
2751
|
varying vec3 vWorldPosition;
|
|
2752
2752
|
#include <common>
|
|
2753
2753
|
#include <batching_pars_vertex>
|
|
@@ -2774,7 +2774,7 @@ void main() {
|
|
|
2774
2774
|
#include <worldpos_vertex>
|
|
2775
2775
|
#include <clipping_planes_vertex>
|
|
2776
2776
|
vWorldPosition = worldPosition.xyz;
|
|
2777
|
-
}`,
|
|
2777
|
+
}`,kg=`#define DISTANCE
|
|
2778
2778
|
uniform vec3 referencePosition;
|
|
2779
2779
|
uniform float nearDistance;
|
|
2780
2780
|
uniform float farDistance;
|
|
@@ -2797,13 +2797,13 @@ void main() {
|
|
|
2797
2797
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
2798
2798
|
dist = saturate( dist );
|
|
2799
2799
|
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
|
|
2800
|
-
}`,
|
|
2800
|
+
}`,Vg=`varying vec3 vWorldDirection;
|
|
2801
2801
|
#include <common>
|
|
2802
2802
|
void main() {
|
|
2803
2803
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2804
2804
|
#include <begin_vertex>
|
|
2805
2805
|
#include <project_vertex>
|
|
2806
|
-
}`,
|
|
2806
|
+
}`,Hg=`uniform sampler2D tEquirect;
|
|
2807
2807
|
varying vec3 vWorldDirection;
|
|
2808
2808
|
#include <common>
|
|
2809
2809
|
void main() {
|
|
@@ -2812,7 +2812,7 @@ void main() {
|
|
|
2812
2812
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
2813
2813
|
#include <tonemapping_fragment>
|
|
2814
2814
|
#include <colorspace_fragment>
|
|
2815
|
-
}`,
|
|
2815
|
+
}`,Gg=`uniform float scale;
|
|
2816
2816
|
attribute float lineDistance;
|
|
2817
2817
|
varying float vLineDistance;
|
|
2818
2818
|
#include <common>
|
|
@@ -2834,7 +2834,7 @@ void main() {
|
|
|
2834
2834
|
#include <logdepthbuf_vertex>
|
|
2835
2835
|
#include <clipping_planes_vertex>
|
|
2836
2836
|
#include <fog_vertex>
|
|
2837
|
-
}`,
|
|
2837
|
+
}`,Wg=`uniform vec3 diffuse;
|
|
2838
2838
|
uniform float opacity;
|
|
2839
2839
|
uniform float dashSize;
|
|
2840
2840
|
uniform float totalSize;
|
|
@@ -2862,7 +2862,7 @@ void main() {
|
|
|
2862
2862
|
#include <colorspace_fragment>
|
|
2863
2863
|
#include <fog_fragment>
|
|
2864
2864
|
#include <premultiplied_alpha_fragment>
|
|
2865
|
-
}`,
|
|
2865
|
+
}`,Xg=`#include <common>
|
|
2866
2866
|
#include <batching_pars_vertex>
|
|
2867
2867
|
#include <uv_pars_vertex>
|
|
2868
2868
|
#include <envmap_pars_vertex>
|
|
@@ -2894,7 +2894,7 @@ void main() {
|
|
|
2894
2894
|
#include <worldpos_vertex>
|
|
2895
2895
|
#include <envmap_vertex>
|
|
2896
2896
|
#include <fog_vertex>
|
|
2897
|
-
}`,
|
|
2897
|
+
}`,qg=`uniform vec3 diffuse;
|
|
2898
2898
|
uniform float opacity;
|
|
2899
2899
|
#ifndef FLAT_SHADED
|
|
2900
2900
|
varying vec3 vNormal;
|
|
@@ -2942,7 +2942,7 @@ void main() {
|
|
|
2942
2942
|
#include <fog_fragment>
|
|
2943
2943
|
#include <premultiplied_alpha_fragment>
|
|
2944
2944
|
#include <dithering_fragment>
|
|
2945
|
-
}`,
|
|
2945
|
+
}`,Yg=`#define LAMBERT
|
|
2946
2946
|
varying vec3 vViewPosition;
|
|
2947
2947
|
#include <common>
|
|
2948
2948
|
#include <batching_pars_vertex>
|
|
@@ -2981,7 +2981,7 @@ void main() {
|
|
|
2981
2981
|
#include <envmap_vertex>
|
|
2982
2982
|
#include <shadowmap_vertex>
|
|
2983
2983
|
#include <fog_vertex>
|
|
2984
|
-
}`,
|
|
2984
|
+
}`,Zg=`#define LAMBERT
|
|
2985
2985
|
uniform vec3 diffuse;
|
|
2986
2986
|
uniform vec3 emissive;
|
|
2987
2987
|
uniform float opacity;
|
|
@@ -3039,7 +3039,7 @@ void main() {
|
|
|
3039
3039
|
#include <fog_fragment>
|
|
3040
3040
|
#include <premultiplied_alpha_fragment>
|
|
3041
3041
|
#include <dithering_fragment>
|
|
3042
|
-
}
|
|
3042
|
+
}`,$g=`#define MATCAP
|
|
3043
3043
|
varying vec3 vViewPosition;
|
|
3044
3044
|
#include <common>
|
|
3045
3045
|
#include <batching_pars_vertex>
|
|
@@ -3073,7 +3073,7 @@ void main() {
|
|
|
3073
3073
|
#include <clipping_planes_vertex>
|
|
3074
3074
|
#include <fog_vertex>
|
|
3075
3075
|
vViewPosition = - mvPosition.xyz;
|
|
3076
|
-
}`,
|
|
3076
|
+
}`,Jg=`#define MATCAP
|
|
3077
3077
|
uniform vec3 diffuse;
|
|
3078
3078
|
uniform float opacity;
|
|
3079
3079
|
uniform sampler2D matcap;
|
|
@@ -3119,7 +3119,7 @@ void main() {
|
|
|
3119
3119
|
#include <fog_fragment>
|
|
3120
3120
|
#include <premultiplied_alpha_fragment>
|
|
3121
3121
|
#include <dithering_fragment>
|
|
3122
|
-
}`,
|
|
3122
|
+
}`,Kg=`#define NORMAL
|
|
3123
3123
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3124
3124
|
varying vec3 vViewPosition;
|
|
3125
3125
|
#endif
|
|
@@ -3152,7 +3152,7 @@ void main() {
|
|
|
3152
3152
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3153
3153
|
vViewPosition = - mvPosition.xyz;
|
|
3154
3154
|
#endif
|
|
3155
|
-
}`,
|
|
3155
|
+
}`,jg=`#define NORMAL
|
|
3156
3156
|
uniform float opacity;
|
|
3157
3157
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3158
3158
|
varying vec3 vViewPosition;
|
|
@@ -3173,7 +3173,7 @@ void main() {
|
|
|
3173
3173
|
#ifdef OPAQUE
|
|
3174
3174
|
gl_FragColor.a = 1.0;
|
|
3175
3175
|
#endif
|
|
3176
|
-
}
|
|
3176
|
+
}`,Qg=`#define PHONG
|
|
3177
3177
|
varying vec3 vViewPosition;
|
|
3178
3178
|
#include <common>
|
|
3179
3179
|
#include <batching_pars_vertex>
|
|
@@ -3212,7 +3212,7 @@ void main() {
|
|
|
3212
3212
|
#include <envmap_vertex>
|
|
3213
3213
|
#include <shadowmap_vertex>
|
|
3214
3214
|
#include <fog_vertex>
|
|
3215
|
-
}`,
|
|
3215
|
+
}`,e0=`#define PHONG
|
|
3216
3216
|
uniform vec3 diffuse;
|
|
3217
3217
|
uniform vec3 emissive;
|
|
3218
3218
|
uniform vec3 specular;
|
|
@@ -3272,7 +3272,7 @@ void main() {
|
|
|
3272
3272
|
#include <fog_fragment>
|
|
3273
3273
|
#include <premultiplied_alpha_fragment>
|
|
3274
3274
|
#include <dithering_fragment>
|
|
3275
|
-
}`,
|
|
3275
|
+
}`,t0=`#define STANDARD
|
|
3276
3276
|
varying vec3 vViewPosition;
|
|
3277
3277
|
#ifdef USE_TRANSMISSION
|
|
3278
3278
|
varying vec3 vWorldPosition;
|
|
@@ -3315,7 +3315,7 @@ void main() {
|
|
|
3315
3315
|
#ifdef USE_TRANSMISSION
|
|
3316
3316
|
vWorldPosition = worldPosition.xyz;
|
|
3317
3317
|
#endif
|
|
3318
|
-
}`,
|
|
3318
|
+
}`,n0=`#define STANDARD
|
|
3319
3319
|
#ifdef PHYSICAL
|
|
3320
3320
|
#define IOR
|
|
3321
3321
|
#define USE_SPECULAR
|
|
@@ -3440,7 +3440,7 @@ void main() {
|
|
|
3440
3440
|
#include <fog_fragment>
|
|
3441
3441
|
#include <premultiplied_alpha_fragment>
|
|
3442
3442
|
#include <dithering_fragment>
|
|
3443
|
-
}`,
|
|
3443
|
+
}`,i0=`#define TOON
|
|
3444
3444
|
varying vec3 vViewPosition;
|
|
3445
3445
|
#include <common>
|
|
3446
3446
|
#include <batching_pars_vertex>
|
|
@@ -3477,7 +3477,7 @@ void main() {
|
|
|
3477
3477
|
#include <worldpos_vertex>
|
|
3478
3478
|
#include <shadowmap_vertex>
|
|
3479
3479
|
#include <fog_vertex>
|
|
3480
|
-
}`,
|
|
3480
|
+
}`,s0=`#define TOON
|
|
3481
3481
|
uniform vec3 diffuse;
|
|
3482
3482
|
uniform vec3 emissive;
|
|
3483
3483
|
uniform float opacity;
|
|
@@ -3529,7 +3529,7 @@ void main() {
|
|
|
3529
3529
|
#include <fog_fragment>
|
|
3530
3530
|
#include <premultiplied_alpha_fragment>
|
|
3531
3531
|
#include <dithering_fragment>
|
|
3532
|
-
}`,
|
|
3532
|
+
}`,r0=`uniform float size;
|
|
3533
3533
|
uniform float scale;
|
|
3534
3534
|
#include <common>
|
|
3535
3535
|
#include <color_pars_vertex>
|
|
@@ -3560,7 +3560,7 @@ void main() {
|
|
|
3560
3560
|
#include <clipping_planes_vertex>
|
|
3561
3561
|
#include <worldpos_vertex>
|
|
3562
3562
|
#include <fog_vertex>
|
|
3563
|
-
}`,
|
|
3563
|
+
}`,o0=`uniform vec3 diffuse;
|
|
3564
3564
|
uniform float opacity;
|
|
3565
3565
|
#include <common>
|
|
3566
3566
|
#include <color_pars_fragment>
|
|
@@ -3585,7 +3585,7 @@ void main() {
|
|
|
3585
3585
|
#include <colorspace_fragment>
|
|
3586
3586
|
#include <fog_fragment>
|
|
3587
3587
|
#include <premultiplied_alpha_fragment>
|
|
3588
|
-
}`,
|
|
3588
|
+
}`,a0=`#include <common>
|
|
3589
3589
|
#include <batching_pars_vertex>
|
|
3590
3590
|
#include <fog_pars_vertex>
|
|
3591
3591
|
#include <morphtarget_pars_vertex>
|
|
@@ -3608,7 +3608,7 @@ void main() {
|
|
|
3608
3608
|
#include <worldpos_vertex>
|
|
3609
3609
|
#include <shadowmap_vertex>
|
|
3610
3610
|
#include <fog_vertex>
|
|
3611
|
-
}`,
|
|
3611
|
+
}`,l0=`uniform vec3 color;
|
|
3612
3612
|
uniform float opacity;
|
|
3613
3613
|
#include <common>
|
|
3614
3614
|
#include <fog_pars_fragment>
|
|
@@ -3624,7 +3624,7 @@ void main() {
|
|
|
3624
3624
|
#include <colorspace_fragment>
|
|
3625
3625
|
#include <fog_fragment>
|
|
3626
3626
|
#include <premultiplied_alpha_fragment>
|
|
3627
|
-
}`,
|
|
3627
|
+
}`,c0=`uniform float rotation;
|
|
3628
3628
|
uniform vec2 center;
|
|
3629
3629
|
#include <common>
|
|
3630
3630
|
#include <uv_pars_vertex>
|
|
@@ -3648,7 +3648,7 @@ void main() {
|
|
|
3648
3648
|
#include <logdepthbuf_vertex>
|
|
3649
3649
|
#include <clipping_planes_vertex>
|
|
3650
3650
|
#include <fog_vertex>
|
|
3651
|
-
}`,
|
|
3651
|
+
}`,h0=`uniform vec3 diffuse;
|
|
3652
3652
|
uniform float opacity;
|
|
3653
3653
|
#include <common>
|
|
3654
3654
|
#include <uv_pars_fragment>
|
|
@@ -3673,7 +3673,7 @@ void main() {
|
|
|
3673
3673
|
#include <tonemapping_fragment>
|
|
3674
3674
|
#include <colorspace_fragment>
|
|
3675
3675
|
#include <fog_fragment>
|
|
3676
|
-
}`,Ze={alphahash_fragment:Ap,alphahash_pars_fragment:Cp,alphamap_fragment:Rp,alphamap_pars_fragment:Pp,alphatest_fragment:Ip,alphatest_pars_fragment:Lp,aomap_fragment:Dp,aomap_pars_fragment:Np,batching_pars_vertex:Up,batching_vertex:Fp,begin_vertex:Op,beginnormal_vertex:Bp,bsdfs:zp,iridescence_fragment:kp,bumpmap_pars_fragment:Vp,clipping_planes_fragment:Hp,clipping_planes_pars_fragment:Gp,clipping_planes_pars_vertex:Wp,clipping_planes_vertex:Xp,color_fragment:qp,color_pars_fragment:Yp,color_pars_vertex:Zp,color_vertex:$p,common:Jp,cube_uv_reflection_fragment:Kp,defaultnormal_vertex:jp,displacementmap_pars_vertex:Qp,displacementmap_vertex:em,emissivemap_fragment:tm,emissivemap_pars_fragment:nm,colorspace_fragment:im,colorspace_pars_fragment:sm,envmap_fragment:rm,envmap_common_pars_fragment:am,envmap_pars_fragment:om,envmap_pars_vertex:lm,envmap_physical_pars_fragment:ym,envmap_vertex:cm,fog_vertex:hm,fog_pars_vertex:um,fog_fragment:dm,fog_pars_fragment:fm,gradientmap_pars_fragment:pm,lightmap_pars_fragment:mm,lights_lambert_fragment:gm,lights_lambert_pars_fragment:_m,lights_pars_begin:xm,lights_toon_fragment:vm,lights_toon_pars_fragment:bm,lights_phong_fragment:Mm,lights_phong_pars_fragment:Sm,lights_physical_fragment:Em,lights_physical_pars_fragment:Tm,lights_fragment_begin:wm,lights_fragment_maps:Am,lights_fragment_end:Cm,lightprobes_pars_fragment:Rm,logdepthbuf_fragment:Pm,logdepthbuf_pars_fragment:Im,logdepthbuf_pars_vertex:Lm,logdepthbuf_vertex:Dm,map_fragment:Nm,map_pars_fragment:Um,map_particle_fragment:Fm,map_particle_pars_fragment:Om,metalnessmap_fragment:Bm,metalnessmap_pars_fragment:zm,morphinstance_vertex:km,morphcolor_vertex:Vm,morphnormal_vertex:Hm,morphtarget_pars_vertex:Gm,morphtarget_vertex:Wm,normal_fragment_begin:Xm,normal_fragment_maps:qm,normal_pars_fragment:Ym,normal_pars_vertex:Zm,normal_vertex:$m,normalmap_pars_fragment:Jm,clearcoat_normal_fragment_begin:Km,clearcoat_normal_fragment_maps:jm,clearcoat_pars_fragment:Qm,iridescence_pars_fragment:eg,opaque_fragment:tg,packing:ng,premultiplied_alpha_fragment:ig,project_vertex:sg,dithering_fragment:rg,dithering_pars_fragment:ag,roughnessmap_fragment:og,roughnessmap_pars_fragment:lg,shadowmap_pars_fragment:cg,shadowmap_pars_vertex:hg,shadowmap_vertex:ug,shadowmask_pars_fragment:dg,skinbase_vertex:fg,skinning_pars_vertex:pg,skinning_vertex:mg,skinnormal_vertex:gg,specularmap_fragment:_g,specularmap_pars_fragment:xg,tonemapping_fragment:yg,tonemapping_pars_fragment:vg,transmission_fragment:bg,transmission_pars_fragment:Mg,uv_pars_fragment:Sg,uv_pars_vertex:Eg,uv_vertex:Tg,worldpos_vertex:wg,background_vert:Ag,background_frag:Cg,backgroundCube_vert:Rg,backgroundCube_frag:Pg,cube_vert:Ig,cube_frag:Lg,depth_vert:Dg,depth_frag:Ng,distance_vert:Ug,distance_frag:Fg,equirect_vert:Og,equirect_frag:Bg,linedashed_vert:zg,linedashed_frag:kg,meshbasic_vert:Vg,meshbasic_frag:Hg,meshlambert_vert:Gg,meshlambert_frag:Wg,meshmatcap_vert:Xg,meshmatcap_frag:qg,meshnormal_vert:Yg,meshnormal_frag:Zg,meshphong_vert:$g,meshphong_frag:Jg,meshphysical_vert:Kg,meshphysical_frag:jg,meshtoon_vert:Qg,meshtoon_frag:e0,points_vert:t0,points_frag:n0,shadow_vert:i0,shadow_frag:s0,sprite_vert:r0,sprite_frag:a0},_e={common:{diffuse:{value:new qe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new He},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new He}},envmap:{envMap:{value:null},envMapRotation:{value:new He},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new He}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new He}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new He},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new He},normalScale:{value:new ee(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new He},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new He}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new He}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new He}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new qe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new R},probesMax:{value:new R},probesResolution:{value:new R}},points:{diffuse:{value:new qe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0},uvTransform:{value:new He}},sprite:{diffuse:{value:new qe(16777215)},opacity:{value:1},center:{value:new ee(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new He},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0}}},Nn={basic:{uniforms:Gt([_e.common,_e.specularmap,_e.envmap,_e.aomap,_e.lightmap,_e.fog]),vertexShader:Ze.meshbasic_vert,fragmentShader:Ze.meshbasic_frag},lambert:{uniforms:Gt([_e.common,_e.specularmap,_e.envmap,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.fog,_e.lights,{emissive:{value:new qe(0)},envMapIntensity:{value:1}}]),vertexShader:Ze.meshlambert_vert,fragmentShader:Ze.meshlambert_frag},phong:{uniforms:Gt([_e.common,_e.specularmap,_e.envmap,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.fog,_e.lights,{emissive:{value:new qe(0)},specular:{value:new qe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ze.meshphong_vert,fragmentShader:Ze.meshphong_frag},standard:{uniforms:Gt([_e.common,_e.envmap,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.roughnessmap,_e.metalnessmap,_e.fog,_e.lights,{emissive:{value:new qe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ze.meshphysical_vert,fragmentShader:Ze.meshphysical_frag},toon:{uniforms:Gt([_e.common,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.gradientmap,_e.fog,_e.lights,{emissive:{value:new qe(0)}}]),vertexShader:Ze.meshtoon_vert,fragmentShader:Ze.meshtoon_frag},matcap:{uniforms:Gt([_e.common,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.fog,{matcap:{value:null}}]),vertexShader:Ze.meshmatcap_vert,fragmentShader:Ze.meshmatcap_frag},points:{uniforms:Gt([_e.points,_e.fog]),vertexShader:Ze.points_vert,fragmentShader:Ze.points_frag},dashed:{uniforms:Gt([_e.common,_e.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ze.linedashed_vert,fragmentShader:Ze.linedashed_frag},depth:{uniforms:Gt([_e.common,_e.displacementmap]),vertexShader:Ze.depth_vert,fragmentShader:Ze.depth_frag},normal:{uniforms:Gt([_e.common,_e.bumpmap,_e.normalmap,_e.displacementmap,{opacity:{value:1}}]),vertexShader:Ze.meshnormal_vert,fragmentShader:Ze.meshnormal_frag},sprite:{uniforms:Gt([_e.sprite,_e.fog]),vertexShader:Ze.sprite_vert,fragmentShader:Ze.sprite_frag},background:{uniforms:{uvTransform:{value:new He},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ze.background_vert,fragmentShader:Ze.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new He}},vertexShader:Ze.backgroundCube_vert,fragmentShader:Ze.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ze.cube_vert,fragmentShader:Ze.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ze.equirect_vert,fragmentShader:Ze.equirect_frag},distance:{uniforms:Gt([_e.common,_e.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ze.distance_vert,fragmentShader:Ze.distance_frag},shadow:{uniforms:Gt([_e.lights,_e.fog,{color:{value:new qe(0)},opacity:{value:1}}]),vertexShader:Ze.shadow_vert,fragmentShader:Ze.shadow_frag}};Nn.physical={uniforms:Gt([Nn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new He},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new He},clearcoatNormalScale:{value:new ee(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new He},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new He},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new He},sheen:{value:0},sheenColor:{value:new qe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new He},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new He},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new He},transmissionSamplerSize:{value:new ee},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new He},attenuationDistance:{value:0},attenuationColor:{value:new qe(0)},specularColor:{value:new qe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new He},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new He},anisotropyVector:{value:new ee},anisotropyMap:{value:null},anisotropyMapTransform:{value:new He}}]),vertexShader:Ze.meshphysical_vert,fragmentShader:Ze.meshphysical_frag};var Zo={r:0,b:0,g:0},o0=new rt,id=new He;id.set(-1,0,0,0,1,0,0,0,1);function l0(i,e,t,n,s,r){let a=new qe(0),o=s===!0?0:1,l,c,h=null,d=0,u=null;function f(C){let w=C.isScene===!0?C.background:null;if(w&&w.isTexture){let _=C.backgroundBlurriness>0;w=e.get(w,_)}return w}function g(C){let w=!1,_=f(C);_===null?m(a,o):_&&_.isColor&&(m(_,1),w=!0);let S=i.xr.getEnvironmentBlendMode();S==="additive"?t.buffers.color.setClear(0,0,0,1,r):S==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||w)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function b(C,w){let _=f(w);_&&(_.isCubeTexture||_.mapping===yr)?(c===void 0&&(c=new wt(new ds(1,1,1),new tn({name:"BackgroundCubeMaterial",uniforms:Ni(Nn.backgroundCube.uniforms),vertexShader:Nn.backgroundCube.vertexShader,fragmentShader:Nn.backgroundCube.fragmentShader,side:qt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(S,M,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=_,c.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(o0.makeRotationFromEuler(w.backgroundRotation)).transpose(),_.isCubeTexture&&_.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(id),c.material.toneMapped=je.getTransfer(_.colorSpace)!==it,(h!==_||d!==_.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=_,d=_.version,u=i.toneMapping),c.layers.enableAll(),C.unshift(c,c.geometry,c.material,0,0,null)):_&&_.isTexture&&(l===void 0&&(l=new wt(new si(2,2),new tn({name:"BackgroundMaterial",uniforms:Ni(Nn.background.uniforms),vertexShader:Nn.background.vertexShader,fragmentShader:Nn.background.fragmentShader,side:Hn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=_,l.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,l.material.toneMapped=je.getTransfer(_.colorSpace)!==it,_.matrixAutoUpdate===!0&&_.updateMatrix(),l.material.uniforms.uvTransform.value.copy(_.matrix),(h!==_||d!==_.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=_,d=_.version,u=i.toneMapping),l.layers.enableAll(),C.unshift(l,l.geometry,l.material,0,0,null))}function m(C,w){C.getRGB(Zo,yc(i)),t.buffers.color.setClear(Zo.r,Zo.g,Zo.b,w,r)}function p(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(C,w=1){a.set(C),o=w,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(C){o=C,m(a,o)},render:g,addToRenderList:b,dispose:p}}function c0(i,e){let t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null),r=s,a=!1;function o(P,F,G,X,O){let W=!1,H=d(P,X,G,F);r!==H&&(r=H,c(r.object)),W=f(P,X,G,O),W&&g(P,X,G,O),O!==null&&e.update(O,i.ELEMENT_ARRAY_BUFFER),(W||a)&&(a=!1,_(P,F,G,X),O!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(O).buffer))}function l(){return i.createVertexArray()}function c(P){return i.bindVertexArray(P)}function h(P){return i.deleteVertexArray(P)}function d(P,F,G,X){let O=X.wireframe===!0,W=n[F.id];W===void 0&&(W={},n[F.id]=W);let H=P.isInstancedMesh===!0?P.id:0,K=W[H];K===void 0&&(K={},W[H]=K);let ie=K[G.id];ie===void 0&&(ie={},K[G.id]=ie);let ue=ie[O];return ue===void 0&&(ue=u(l()),ie[O]=ue),ue}function u(P){let F=[],G=[],X=[];for(let O=0;O<t;O++)F[O]=0,G[O]=0,X[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:G,attributeDivisors:X,object:P,attributes:{},index:null}}function f(P,F,G,X){let O=r.attributes,W=F.attributes,H=0,K=G.getAttributes();for(let ie in K)if(K[ie].location>=0){let le=O[ie],Me=W[ie];if(Me===void 0&&(ie==="instanceMatrix"&&P.instanceMatrix&&(Me=P.instanceMatrix),ie==="instanceColor"&&P.instanceColor&&(Me=P.instanceColor)),le===void 0||le.attribute!==Me||Me&&le.data!==Me.data)return!0;H++}return r.attributesNum!==H||r.index!==X}function g(P,F,G,X){let O={},W=F.attributes,H=0,K=G.getAttributes();for(let ie in K)if(K[ie].location>=0){let le=W[ie];le===void 0&&(ie==="instanceMatrix"&&P.instanceMatrix&&(le=P.instanceMatrix),ie==="instanceColor"&&P.instanceColor&&(le=P.instanceColor));let Me={};Me.attribute=le,le&&le.data&&(Me.data=le.data),O[ie]=Me,H++}r.attributes=O,r.attributesNum=H,r.index=X}function b(){let P=r.newAttributes;for(let F=0,G=P.length;F<G;F++)P[F]=0}function m(P){p(P,0)}function p(P,F){let G=r.newAttributes,X=r.enabledAttributes,O=r.attributeDivisors;G[P]=1,X[P]===0&&(i.enableVertexAttribArray(P),X[P]=1),O[P]!==F&&(i.vertexAttribDivisor(P,F),O[P]=F)}function C(){let P=r.newAttributes,F=r.enabledAttributes;for(let G=0,X=F.length;G<X;G++)F[G]!==P[G]&&(i.disableVertexAttribArray(G),F[G]=0)}function w(P,F,G,X,O,W,H){H===!0?i.vertexAttribIPointer(P,F,G,O,W):i.vertexAttribPointer(P,F,G,X,O,W)}function _(P,F,G,X){b();let O=X.attributes,W=G.getAttributes(),H=F.defaultAttributeValues;for(let K in W){let ie=W[K];if(ie.location>=0){let ue=O[K];if(ue===void 0&&(K==="instanceMatrix"&&P.instanceMatrix&&(ue=P.instanceMatrix),K==="instanceColor"&&P.instanceColor&&(ue=P.instanceColor)),ue!==void 0){let le=ue.normalized,Me=ue.itemSize,$e=e.get(ue);if($e===void 0)continue;let ct=$e.buffer,Qe=$e.type,$=$e.bytesPerElement,ce=Qe===i.INT||Qe===i.UNSIGNED_INT||ue.gpuType===lo;if(ue.isInterleavedBufferAttribute){let re=ue.data,Ie=re.stride,ze=ue.offset;if(re.isInstancedInterleavedBuffer){for(let Ue=0;Ue<ie.locationSize;Ue++)p(ie.location+Ue,re.meshPerAttribute);P.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let Ue=0;Ue<ie.locationSize;Ue++)m(ie.location+Ue);i.bindBuffer(i.ARRAY_BUFFER,ct);for(let Ue=0;Ue<ie.locationSize;Ue++)w(ie.location+Ue,Me/ie.locationSize,Qe,le,Ie*$,(ze+Me/ie.locationSize*Ue)*$,ce)}else{if(ue.isInstancedBufferAttribute){for(let re=0;re<ie.locationSize;re++)p(ie.location+re,ue.meshPerAttribute);P.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=ue.meshPerAttribute*ue.count)}else for(let re=0;re<ie.locationSize;re++)m(ie.location+re);i.bindBuffer(i.ARRAY_BUFFER,ct);for(let re=0;re<ie.locationSize;re++)w(ie.location+re,Me/ie.locationSize,Qe,le,Me*$,Me/ie.locationSize*re*$,ce)}}else if(H!==void 0){let le=H[K];if(le!==void 0)switch(le.length){case 2:i.vertexAttrib2fv(ie.location,le);break;case 3:i.vertexAttrib3fv(ie.location,le);break;case 4:i.vertexAttrib4fv(ie.location,le);break;default:i.vertexAttrib1fv(ie.location,le)}}}}C()}function S(){T();for(let P in n){let F=n[P];for(let G in F){let X=F[G];for(let O in X){let W=X[O];for(let H in W)h(W[H].object),delete W[H];delete X[O]}}delete n[P]}}function M(P){if(n[P.id]===void 0)return;let F=n[P.id];for(let G in F){let X=F[G];for(let O in X){let W=X[O];for(let H in W)h(W[H].object),delete W[H];delete X[O]}}delete n[P.id]}function A(P){for(let F in n){let G=n[F];for(let X in G){let O=G[X];if(O[P.id]===void 0)continue;let W=O[P.id];for(let H in W)h(W[H].object),delete W[H];delete O[P.id]}}}function y(P){for(let F in n){let G=n[F],X=P.isInstancedMesh===!0?P.id:0,O=G[X];if(O!==void 0){for(let W in O){let H=O[W];for(let K in H)h(H[K].object),delete H[K];delete O[W]}delete G[X],Object.keys(G).length===0&&delete n[F]}}}function T(){I(),a=!0,r!==s&&(r=s,c(r.object))}function I(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:T,resetDefaultState:I,dispose:S,releaseStatesOfGeometry:M,releaseStatesOfObject:y,releaseStatesOfProgram:A,initAttributes:b,enableAttribute:m,disableUnusedAttributes:C}}function h0(i,e,t){let n;function s(l){n=l}function r(l,c){i.drawArrays(n,l,c),t.update(c,n,1)}function a(l,c,h){h!==0&&(i.drawArraysInstanced(n,l,c,h),t.update(c,n,h))}function o(l,c,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,c,0,h);let u=0;for(let f=0;f<h;f++)u+=c[f];t.update(u,n,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function u0(i,e,t,n){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){let A=e.get("EXT_texture_filter_anisotropic");s=i.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(A){return!(A!==cn&&n.convert(A)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(A){let y=A===Ln&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==Yt&&n.convert(A)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==bn&&!y)}function l(A){if(A==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp",h=l(c);h!==c&&(De("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);let d=t.logarithmicDepthBuffer===!0,u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&u===!1&&De("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let f=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),b=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),C=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),w=i.getParameter(i.MAX_VARYING_VECTORS),_=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),S=i.getParameter(i.MAX_SAMPLES),M=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:f,maxVertexTextures:g,maxTextureSize:b,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:C,maxVaryings:w,maxFragmentUniforms:_,maxSamples:S,samples:M}}function d0(i){let e=this,t=null,n=0,s=!1,r=!1,a=new an,o=new He,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){let f=d.length!==0||u||n!==0||s;return s=u,n=d.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){t=h(d,u,0)},this.setState=function(d,u,f){let g=d.clippingPlanes,b=d.clipIntersection,m=d.clipShadows,p=i.get(d);if(!s||g===null||g.length===0||r&&!m)r?h(null):c();else{let C=r?0:n,w=C*4,_=p.clippingState||null;l.value=_,_=h(g,u,w,f);for(let S=0;S!==w;++S)_[S]=t[S];p.clippingState=_,this.numIntersection=b?this.numPlanes:0,this.numPlanes+=C}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(d,u,f,g){let b=d!==null?d.length:0,m=null;if(b!==0){if(m=l.value,g!==!0||m===null){let p=f+b*4,C=u.matrixWorldInverse;o.getNormalMatrix(C),(m===null||m.length<p)&&(m=new Float32Array(p));for(let w=0,_=f;w!==b;++w,_+=4)a.copy(d[w]).applyMatrix4(C,o),a.normal.toArray(m,_),m[_+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=b,e.numIntersection=0,m}}var gi=4,Nu=[.125,.215,.35,.446,.526,.582],Ui=20,f0=256,Ar=new li,Uu=new qe,Sc=null,Ec=0,Tc=0,wc=!1,p0=new R,Jo=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,s=100,r={}){let{size:a=256,position:o=p0}=r;Sc=this._renderer.getRenderTarget(),Ec=this._renderer.getActiveCubeFace(),Tc=this._renderer.getActiveMipmapLevel(),wc=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);let l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,s,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Bu(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ou(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Sc,Ec,Tc),this._renderer.xr.enabled=wc,e.scissorTest=!1,bs(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===di||e.mapping===Di?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Sc=this._renderer.getRenderTarget(),Ec=this._renderer.getActiveCubeFace(),Tc=this._renderer.getActiveMipmapLevel(),wc=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Ft,minFilter:Ft,generateMipmaps:!1,type:Ln,format:cn,colorSpace:Xs,depthBuffer:!1},s=Fu(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Fu(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=m0(r)),this._blurMaterial=_0(r,e,t),this._ggxMaterial=g0(r,e,t)}return s}_compileMaterial(e){let t=new wt(new mt,e);this._renderer.compile(t,Ar)}_sceneToCubeUV(e,t,n,s,r){let l=new Vt(90,1,t,n),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],d=this._renderer,u=d.autoClear,f=d.toneMapping;d.getClearColor(Uu),d.toneMapping=yn,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(s),d.clearDepth(),d.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new wt(new ds,new on({name:"PMREM.Background",side:qt,depthWrite:!1,depthTest:!1})));let b=this._backgroundBox,m=b.material,p=!1,C=e.background;C?C.isColor&&(m.color.copy(C),e.background=null,p=!0):(m.color.copy(Uu),p=!0);for(let w=0;w<6;w++){let _=w%3;_===0?(l.up.set(0,c[w],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x+h[w],r.y,r.z)):_===1?(l.up.set(0,0,c[w]),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y+h[w],r.z)):(l.up.set(0,c[w],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y,r.z+h[w]));let S=this._cubeSize;bs(s,_*S,w>2?S:0,S,S),d.setRenderTarget(s),p&&d.render(b,l),d.render(e,l)}d.toneMapping=f,d.autoClear=u,e.background=C}_textureToCubeUV(e,t){let n=this._renderer,s=e.mapping===di||e.mapping===Di;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Bu()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ou());let r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;let o=r.uniforms;o.envMap.value=e;let l=this._cubeSize;bs(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,Ar)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let s=this._lodMeshes.length;for(let r=1;r<s;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let s=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;let l=a.uniforms,c=n/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),d=Math.sqrt(c*c-h*h),u=0+c*1.25,f=d*u,{_lodMax:g}=this,b=this._sizeLods[n],m=3*b*(n>g-gi?n-g+gi:0),p=4*(this._cubeSize-b);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=g-t,bs(r,m,p,3*b,2*b),s.setRenderTarget(r),s.render(o,Ar),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=g-n,bs(e,m,p,3*b,2*b),s.setRenderTarget(e),s.render(o,Ar)}_blur(e,t,n,s,r){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,s,"latitudinal",r),this._halfBlur(a,e,n,n,s,"longitudinal",r)}_halfBlur(e,t,n,s,r,a,o){let l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Fe("blur direction must be either latitudinal or longitudinal!");let h=3,d=this._lodMeshes[s];d.material=c;let u=c.uniforms,f=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Ui-1),b=r/g,m=isFinite(r)?1+Math.floor(h*b):Ui;m>Ui&&De(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ui}`);let p=[],C=0;for(let A=0;A<Ui;++A){let y=A/b,T=Math.exp(-y*y/2);p.push(T),A===0?C+=T:A<m&&(C+=2*T)}for(let A=0;A<p.length;A++)p[A]=p[A]/C;u.envMap.value=e.texture,u.samples.value=m,u.weights.value=p,u.latitudinal.value=a==="latitudinal",o&&(u.poleAxis.value=o);let{_lodMax:w}=this;u.dTheta.value=g,u.mipInt.value=w-n;let _=this._sizeLods[s],S=3*_*(s>w-gi?s-w+gi:0),M=4*(this._cubeSize-_);bs(t,S,M,3*_,2*_),l.setRenderTarget(t),l.render(d,Ar)}};function m0(i){let e=[],t=[],n=[],s=i,r=i-gi+1+Nu.length;for(let a=0;a<r;a++){let o=Math.pow(2,s);e.push(o);let l=1/o;a>i-gi?l=Nu[a-i+gi-1]:a===0&&(l=0),t.push(l);let c=1/(o-2),h=-c,d=1+c,u=[h,h,d,h,d,d,h,h,d,d,h,d],f=6,g=6,b=3,m=2,p=1,C=new Float32Array(b*g*f),w=new Float32Array(m*g*f),_=new Float32Array(p*g*f);for(let M=0;M<f;M++){let A=M%3*2/3-1,y=M>2?0:-1,T=[A,y,0,A+2/3,y,0,A+2/3,y+1,0,A,y,0,A+2/3,y+1,0,A,y+1,0];C.set(T,b*g*M),w.set(u,m*g*M);let I=[M,M,M,M,M,M];_.set(I,p*g*M)}let S=new mt;S.setAttribute("position",new Tt(C,b)),S.setAttribute("uv",new Tt(w,m)),S.setAttribute("faceIndex",new Tt(_,p)),n.push(new wt(S,null)),s>gi&&s--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Fu(i,e,t){let n=new Qt(i,e,t);return n.texture.mapping=yr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function bs(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function g0(i,e,t){return new tn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:f0,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:jo(),fragmentShader:`
|
|
3676
|
+
}`,$e={alphahash_fragment:Ip,alphahash_pars_fragment:Lp,alphamap_fragment:Dp,alphamap_pars_fragment:Np,alphatest_fragment:Up,alphatest_pars_fragment:Fp,aomap_fragment:Op,aomap_pars_fragment:Bp,batching_pars_vertex:zp,batching_vertex:kp,begin_vertex:Vp,beginnormal_vertex:Hp,bsdfs:Gp,iridescence_fragment:Wp,bumpmap_pars_fragment:Xp,clipping_planes_fragment:qp,clipping_planes_pars_fragment:Yp,clipping_planes_pars_vertex:Zp,clipping_planes_vertex:$p,color_fragment:Jp,color_pars_fragment:Kp,color_pars_vertex:jp,color_vertex:Qp,common:em,cube_uv_reflection_fragment:tm,defaultnormal_vertex:nm,displacementmap_pars_vertex:im,displacementmap_vertex:sm,emissivemap_fragment:rm,emissivemap_pars_fragment:om,colorspace_fragment:am,colorspace_pars_fragment:lm,envmap_fragment:cm,envmap_common_pars_fragment:hm,envmap_pars_fragment:um,envmap_pars_vertex:dm,envmap_physical_pars_fragment:Sm,envmap_vertex:fm,fog_vertex:pm,fog_pars_vertex:mm,fog_fragment:gm,fog_pars_fragment:_m,gradientmap_pars_fragment:xm,lightmap_pars_fragment:vm,lights_lambert_fragment:ym,lights_lambert_pars_fragment:bm,lights_pars_begin:Mm,lights_toon_fragment:Em,lights_toon_pars_fragment:wm,lights_phong_fragment:Tm,lights_phong_pars_fragment:Am,lights_physical_fragment:Cm,lights_physical_pars_fragment:Rm,lights_fragment_begin:Pm,lights_fragment_maps:Im,lights_fragment_end:Lm,lightprobes_pars_fragment:Dm,logdepthbuf_fragment:Nm,logdepthbuf_pars_fragment:Um,logdepthbuf_pars_vertex:Fm,logdepthbuf_vertex:Om,map_fragment:Bm,map_pars_fragment:zm,map_particle_fragment:km,map_particle_pars_fragment:Vm,metalnessmap_fragment:Hm,metalnessmap_pars_fragment:Gm,morphinstance_vertex:Wm,morphcolor_vertex:Xm,morphnormal_vertex:qm,morphtarget_pars_vertex:Ym,morphtarget_vertex:Zm,normal_fragment_begin:$m,normal_fragment_maps:Jm,normal_pars_fragment:Km,normal_pars_vertex:jm,normal_vertex:Qm,normalmap_pars_fragment:eg,clearcoat_normal_fragment_begin:tg,clearcoat_normal_fragment_maps:ng,clearcoat_pars_fragment:ig,iridescence_pars_fragment:sg,opaque_fragment:rg,packing:og,premultiplied_alpha_fragment:ag,project_vertex:lg,dithering_fragment:cg,dithering_pars_fragment:hg,roughnessmap_fragment:ug,roughnessmap_pars_fragment:dg,shadowmap_pars_fragment:fg,shadowmap_pars_vertex:pg,shadowmap_vertex:mg,shadowmask_pars_fragment:gg,skinbase_vertex:_g,skinning_pars_vertex:xg,skinning_vertex:vg,skinnormal_vertex:yg,specularmap_fragment:bg,specularmap_pars_fragment:Mg,tonemapping_fragment:Sg,tonemapping_pars_fragment:Eg,transmission_fragment:wg,transmission_pars_fragment:Tg,uv_pars_fragment:Ag,uv_pars_vertex:Cg,uv_vertex:Rg,worldpos_vertex:Pg,background_vert:Ig,background_frag:Lg,backgroundCube_vert:Dg,backgroundCube_frag:Ng,cube_vert:Ug,cube_frag:Fg,depth_vert:Og,depth_frag:Bg,distance_vert:zg,distance_frag:kg,equirect_vert:Vg,equirect_frag:Hg,linedashed_vert:Gg,linedashed_frag:Wg,meshbasic_vert:Xg,meshbasic_frag:qg,meshlambert_vert:Yg,meshlambert_frag:Zg,meshmatcap_vert:$g,meshmatcap_frag:Jg,meshnormal_vert:Kg,meshnormal_frag:jg,meshphong_vert:Qg,meshphong_frag:e0,meshphysical_vert:t0,meshphysical_frag:n0,meshtoon_vert:i0,meshtoon_frag:s0,points_vert:r0,points_frag:o0,shadow_vert:a0,shadow_frag:l0,sprite_vert:c0,sprite_frag:h0},_e={common:{diffuse:{value:new Ye(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ge},alphaMap:{value:null},alphaMapTransform:{value:new Ge},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ge}},envmap:{envMap:{value:null},envMapRotation:{value:new Ge},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ge}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ge}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ge},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ge},normalScale:{value:new te(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ge},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ge}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ge}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ge}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ye(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new R},probesMax:{value:new R},probesResolution:{value:new R}},points:{diffuse:{value:new Ye(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ge},alphaTest:{value:0},uvTransform:{value:new Ge}},sprite:{diffuse:{value:new Ye(16777215)},opacity:{value:1},center:{value:new te(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ge},alphaMap:{value:null},alphaMapTransform:{value:new Ge},alphaTest:{value:0}}},Nn={basic:{uniforms:Ht([_e.common,_e.specularmap,_e.envmap,_e.aomap,_e.lightmap,_e.fog]),vertexShader:$e.meshbasic_vert,fragmentShader:$e.meshbasic_frag},lambert:{uniforms:Ht([_e.common,_e.specularmap,_e.envmap,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.fog,_e.lights,{emissive:{value:new Ye(0)},envMapIntensity:{value:1}}]),vertexShader:$e.meshlambert_vert,fragmentShader:$e.meshlambert_frag},phong:{uniforms:Ht([_e.common,_e.specularmap,_e.envmap,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.fog,_e.lights,{emissive:{value:new Ye(0)},specular:{value:new Ye(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:$e.meshphong_vert,fragmentShader:$e.meshphong_frag},standard:{uniforms:Ht([_e.common,_e.envmap,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.roughnessmap,_e.metalnessmap,_e.fog,_e.lights,{emissive:{value:new Ye(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag},toon:{uniforms:Ht([_e.common,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.gradientmap,_e.fog,_e.lights,{emissive:{value:new Ye(0)}}]),vertexShader:$e.meshtoon_vert,fragmentShader:$e.meshtoon_frag},matcap:{uniforms:Ht([_e.common,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.fog,{matcap:{value:null}}]),vertexShader:$e.meshmatcap_vert,fragmentShader:$e.meshmatcap_frag},points:{uniforms:Ht([_e.points,_e.fog]),vertexShader:$e.points_vert,fragmentShader:$e.points_frag},dashed:{uniforms:Ht([_e.common,_e.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$e.linedashed_vert,fragmentShader:$e.linedashed_frag},depth:{uniforms:Ht([_e.common,_e.displacementmap]),vertexShader:$e.depth_vert,fragmentShader:$e.depth_frag},normal:{uniforms:Ht([_e.common,_e.bumpmap,_e.normalmap,_e.displacementmap,{opacity:{value:1}}]),vertexShader:$e.meshnormal_vert,fragmentShader:$e.meshnormal_frag},sprite:{uniforms:Ht([_e.sprite,_e.fog]),vertexShader:$e.sprite_vert,fragmentShader:$e.sprite_frag},background:{uniforms:{uvTransform:{value:new Ge},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:$e.background_vert,fragmentShader:$e.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ge}},vertexShader:$e.backgroundCube_vert,fragmentShader:$e.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$e.cube_vert,fragmentShader:$e.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$e.equirect_vert,fragmentShader:$e.equirect_frag},distance:{uniforms:Ht([_e.common,_e.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$e.distance_vert,fragmentShader:$e.distance_frag},shadow:{uniforms:Ht([_e.lights,_e.fog,{color:{value:new Ye(0)},opacity:{value:1}}]),vertexShader:$e.shadow_vert,fragmentShader:$e.shadow_frag}};Nn.physical={uniforms:Ht([Nn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ge},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ge},clearcoatNormalScale:{value:new te(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ge},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ge},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ge},sheen:{value:0},sheenColor:{value:new Ye(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ge},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ge},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ge},transmissionSamplerSize:{value:new te},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ge},attenuationDistance:{value:0},attenuationColor:{value:new Ye(0)},specularColor:{value:new Ye(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ge},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ge},anisotropyVector:{value:new te},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ge}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag};var Za={r:0,b:0,g:0},u0=new rt,rd=new Ge;rd.set(-1,0,0,0,1,0,0,0,1);function d0(i,e,t,n,s,r){let o=new Ye(0),a=s===!0?0:1,l,c,h=null,d=0,u=null;function f(C){let T=C.isScene===!0?C.background:null;if(T&&T.isTexture){let x=C.backgroundBlurriness>0;T=e.get(T,x)}return T}function g(C){let T=!1,x=f(C);x===null?m(o,a):x&&x.isColor&&(m(x,1),T=!0);let S=i.xr.getEnvironmentBlendMode();S==="additive"?t.buffers.color.setClear(0,0,0,1,r):S==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||T)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function y(C,T){let x=f(T);x&&(x.isCubeTexture||x.mapping===xr)?(c===void 0&&(c=new Tt(new ps(1,1,1),new tn({name:"BackgroundCubeMaterial",uniforms:Ui(Nn.backgroundCube.uniforms),vertexShader:Nn.backgroundCube.vertexShader,fragmentShader:Nn.backgroundCube.fragmentShader,side:qt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(S,M,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=x,c.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(u0.makeRotationFromEuler(T.backgroundRotation)).transpose(),x.isCubeTexture&&x.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(rd),c.material.toneMapped=Qe.getTransfer(x.colorSpace)!==it,(h!==x||d!==x.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=x,d=x.version,u=i.toneMapping),c.layers.enableAll(),C.unshift(c,c.geometry,c.material,0,0,null)):x&&x.isTexture&&(l===void 0&&(l=new Tt(new ri(2,2),new tn({name:"BackgroundMaterial",uniforms:Ui(Nn.background.uniforms),vertexShader:Nn.background.vertexShader,fragmentShader:Nn.background.fragmentShader,side:Hn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=x,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.toneMapped=Qe.getTransfer(x.colorSpace)!==it,x.matrixAutoUpdate===!0&&x.updateMatrix(),l.material.uniforms.uvTransform.value.copy(x.matrix),(h!==x||d!==x.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=x,d=x.version,u=i.toneMapping),l.layers.enableAll(),C.unshift(l,l.geometry,l.material,0,0,null))}function m(C,T){C.getRGB(Za,yc(i)),t.buffers.color.setClear(Za.r,Za.g,Za.b,T,r)}function p(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return o},setClearColor:function(C,T=1){o.set(C),a=T,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(C){a=C,m(o,a)},render:g,addToRenderList:y,dispose:p}}function f0(i,e){let t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null),r=s,o=!1;function a(P,O,q,Y,U){let G=!1,H=d(P,Y,q,O);r!==H&&(r=H,c(r.object)),G=f(P,Y,q,U),G&&g(P,Y,q,U),U!==null&&e.update(U,i.ELEMENT_ARRAY_BUFFER),(G||o)&&(o=!1,x(P,O,q,Y),U!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(U).buffer))}function l(){return i.createVertexArray()}function c(P){return i.bindVertexArray(P)}function h(P){return i.deleteVertexArray(P)}function d(P,O,q,Y){let U=Y.wireframe===!0,G=n[O.id];G===void 0&&(G={},n[O.id]=G);let H=P.isInstancedMesh===!0?P.id:0,j=G[H];j===void 0&&(j={},G[H]=j);let se=j[q.id];se===void 0&&(se={},j[q.id]=se);let ue=se[U];return ue===void 0&&(ue=u(l()),se[U]=ue),ue}function u(P){let O=[],q=[],Y=[];for(let U=0;U<t;U++)O[U]=0,q[U]=0,Y[U]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:O,enabledAttributes:q,attributeDivisors:Y,object:P,attributes:{},index:null}}function f(P,O,q,Y){let U=r.attributes,G=O.attributes,H=0,j=q.getAttributes();for(let se in j)if(j[se].location>=0){let le=U[se],Me=G[se];if(Me===void 0&&(se==="instanceMatrix"&&P.instanceMatrix&&(Me=P.instanceMatrix),se==="instanceColor"&&P.instanceColor&&(Me=P.instanceColor)),le===void 0||le.attribute!==Me||Me&&le.data!==Me.data)return!0;H++}return r.attributesNum!==H||r.index!==Y}function g(P,O,q,Y){let U={},G=O.attributes,H=0,j=q.getAttributes();for(let se in j)if(j[se].location>=0){let le=G[se];le===void 0&&(se==="instanceMatrix"&&P.instanceMatrix&&(le=P.instanceMatrix),se==="instanceColor"&&P.instanceColor&&(le=P.instanceColor));let Me={};Me.attribute=le,le&&le.data&&(Me.data=le.data),U[se]=Me,H++}r.attributes=U,r.attributesNum=H,r.index=Y}function y(){let P=r.newAttributes;for(let O=0,q=P.length;O<q;O++)P[O]=0}function m(P){p(P,0)}function p(P,O){let q=r.newAttributes,Y=r.enabledAttributes,U=r.attributeDivisors;q[P]=1,Y[P]===0&&(i.enableVertexAttribArray(P),Y[P]=1),U[P]!==O&&(i.vertexAttribDivisor(P,O),U[P]=O)}function C(){let P=r.newAttributes,O=r.enabledAttributes;for(let q=0,Y=O.length;q<Y;q++)O[q]!==P[q]&&(i.disableVertexAttribArray(q),O[q]=0)}function T(P,O,q,Y,U,G,H){H===!0?i.vertexAttribIPointer(P,O,q,U,G):i.vertexAttribPointer(P,O,q,Y,U,G)}function x(P,O,q,Y){y();let U=Y.attributes,G=q.getAttributes(),H=O.defaultAttributeValues;for(let j in G){let se=G[j];if(se.location>=0){let ue=U[j];if(ue===void 0&&(j==="instanceMatrix"&&P.instanceMatrix&&(ue=P.instanceMatrix),j==="instanceColor"&&P.instanceColor&&(ue=P.instanceColor)),ue!==void 0){let le=ue.normalized,Me=ue.itemSize,Je=e.get(ue);if(Je===void 0)continue;let ct=Je.buffer,et=Je.type,J=Je.bytesPerElement,ce=et===i.INT||et===i.UNSIGNED_INT||ue.gpuType===ca;if(ue.isInterleavedBufferAttribute){let re=ue.data,Ie=re.stride,ke=ue.offset;if(re.isInstancedInterleavedBuffer){for(let Ue=0;Ue<se.locationSize;Ue++)p(se.location+Ue,re.meshPerAttribute);P.isInstancedMesh!==!0&&Y._maxInstanceCount===void 0&&(Y._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let Ue=0;Ue<se.locationSize;Ue++)m(se.location+Ue);i.bindBuffer(i.ARRAY_BUFFER,ct);for(let Ue=0;Ue<se.locationSize;Ue++)T(se.location+Ue,Me/se.locationSize,et,le,Ie*J,(ke+Me/se.locationSize*Ue)*J,ce)}else{if(ue.isInstancedBufferAttribute){for(let re=0;re<se.locationSize;re++)p(se.location+re,ue.meshPerAttribute);P.isInstancedMesh!==!0&&Y._maxInstanceCount===void 0&&(Y._maxInstanceCount=ue.meshPerAttribute*ue.count)}else for(let re=0;re<se.locationSize;re++)m(se.location+re);i.bindBuffer(i.ARRAY_BUFFER,ct);for(let re=0;re<se.locationSize;re++)T(se.location+re,Me/se.locationSize,et,le,Me*J,Me/se.locationSize*re*J,ce)}}else if(H!==void 0){let le=H[j];if(le!==void 0)switch(le.length){case 2:i.vertexAttrib2fv(se.location,le);break;case 3:i.vertexAttrib3fv(se.location,le);break;case 4:i.vertexAttrib4fv(se.location,le);break;default:i.vertexAttrib1fv(se.location,le)}}}}C()}function S(){w();for(let P in n){let O=n[P];for(let q in O){let Y=O[q];for(let U in Y){let G=Y[U];for(let H in G)h(G[H].object),delete G[H];delete Y[U]}}delete n[P]}}function M(P){if(n[P.id]===void 0)return;let O=n[P.id];for(let q in O){let Y=O[q];for(let U in Y){let G=Y[U];for(let H in G)h(G[H].object),delete G[H];delete Y[U]}}delete n[P.id]}function A(P){for(let O in n){let q=n[O];for(let Y in q){let U=q[Y];if(U[P.id]===void 0)continue;let G=U[P.id];for(let H in G)h(G[H].object),delete G[H];delete U[P.id]}}}function v(P){for(let O in n){let q=n[O],Y=P.isInstancedMesh===!0?P.id:0,U=q[Y];if(U!==void 0){for(let G in U){let H=U[G];for(let j in H)h(H[j].object),delete H[j];delete U[G]}delete q[Y],Object.keys(q).length===0&&delete n[O]}}}function w(){I(),o=!0,r!==s&&(r=s,c(r.object))}function I(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:a,reset:w,resetDefaultState:I,dispose:S,releaseStatesOfGeometry:M,releaseStatesOfObject:v,releaseStatesOfProgram:A,initAttributes:y,enableAttribute:m,disableUnusedAttributes:C}}function p0(i,e,t){let n;function s(l){n=l}function r(l,c){i.drawArrays(n,l,c),t.update(c,n,1)}function o(l,c,h){h!==0&&(i.drawArraysInstanced(n,l,c,h),t.update(c,n,h))}function a(l,c,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,c,0,h);let u=0;for(let f=0;f<h;f++)u+=c[f];t.update(u,n,1)}this.setMode=s,this.render=r,this.renderInstances=o,this.renderMultiDraw=a}function m0(i,e,t,n){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){let A=e.get("EXT_texture_filter_anisotropic");s=i.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function o(A){return!(A!==cn&&n.convert(A)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(A){let v=A===Ln&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==Yt&&n.convert(A)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==bn&&!v)}function l(A){if(A==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp",h=l(c);h!==c&&(De("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);let d=t.logarithmicDepthBuffer===!0,u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&u===!1&&De("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let f=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),C=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),T=i.getParameter(i.MAX_VARYING_VECTORS),x=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),S=i.getParameter(i.MAX_SAMPLES),M=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:f,maxVertexTextures:g,maxTextureSize:y,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:C,maxVaryings:T,maxFragmentUniforms:x,maxSamples:S,samples:M}}function g0(i){let e=this,t=null,n=0,s=!1,r=!1,o=new on,a=new Ge,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){let f=d.length!==0||u||n!==0||s;return s=u,n=d.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){t=h(d,u,0)},this.setState=function(d,u,f){let g=d.clippingPlanes,y=d.clipIntersection,m=d.clipShadows,p=i.get(d);if(!s||g===null||g.length===0||r&&!m)r?h(null):c();else{let C=r?0:n,T=C*4,x=p.clippingState||null;l.value=x,x=h(g,u,T,f);for(let S=0;S!==T;++S)x[S]=t[S];p.clippingState=x,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=C}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(d,u,f,g){let y=d!==null?d.length:0,m=null;if(y!==0){if(m=l.value,g!==!0||m===null){let p=f+y*4,C=u.matrixWorldInverse;a.getNormalMatrix(C),(m===null||m.length<p)&&(m=new Float32Array(p));for(let T=0,x=f;T!==y;++T,x+=4)o.copy(d[T]).applyMatrix4(C,a),o.normal.toArray(m,x),m[x+3]=o.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,m}}var _i=4,Fu=[.125,.215,.35,.446,.526,.582],Fi=20,_0=256,Tr=new ci,Ou=new Ye,Ec=null,wc=0,Tc=0,Ac=!1,x0=new R,Ja=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,s=100,r={}){let{size:o=256,position:a=x0}=r;Ec=this._renderer.getRenderTarget(),wc=this._renderer.getActiveCubeFace(),Tc=this._renderer.getActiveMipmapLevel(),Ac=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);let l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,s,l,a),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ku(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=zu(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Ec,wc,Tc),this._renderer.xr.enabled=Ac,e.scissorTest=!1,Ss(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===fi||e.mapping===Ni?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Ec=this._renderer.getRenderTarget(),wc=this._renderer.getActiveCubeFace(),Tc=this._renderer.getActiveMipmapLevel(),Ac=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Ut,minFilter:Ut,generateMipmaps:!1,type:Ln,format:cn,colorSpace:Ws,depthBuffer:!1},s=Bu(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Bu(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=v0(r)),this._blurMaterial=b0(r,e,t),this._ggxMaterial=y0(r,e,t)}return s}_compileMaterial(e){let t=new Tt(new mt,e);this._renderer.compile(t,Tr)}_sceneToCubeUV(e,t,n,s,r){let l=new kt(90,1,t,n),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],d=this._renderer,u=d.autoClear,f=d.toneMapping;d.getClearColor(Ou),d.toneMapping=vn,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(s),d.clearDepth(),d.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Tt(new ps,new an({name:"PMREM.Background",side:qt,depthWrite:!1,depthTest:!1})));let y=this._backgroundBox,m=y.material,p=!1,C=e.background;C?C.isColor&&(m.color.copy(C),e.background=null,p=!0):(m.color.copy(Ou),p=!0);for(let T=0;T<6;T++){let x=T%3;x===0?(l.up.set(0,c[T],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x+h[T],r.y,r.z)):x===1?(l.up.set(0,0,c[T]),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y+h[T],r.z)):(l.up.set(0,c[T],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y,r.z+h[T]));let S=this._cubeSize;Ss(s,x*S,T>2?S:0,S,S),d.setRenderTarget(s),p&&d.render(y,l),d.render(e,l)}d.toneMapping=f,d.autoClear=u,e.background=C}_textureToCubeUV(e,t){let n=this._renderer,s=e.mapping===fi||e.mapping===Ni;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=ku()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=zu());let r=s?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=r;let a=r.uniforms;a.envMap.value=e;let l=this._cubeSize;Ss(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,Tr)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let s=this._lodMeshes.length;for(let r=1;r<s;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let s=this._renderer,r=this._pingPongRenderTarget,o=this._ggxMaterial,a=this._lodMeshes[n];a.material=o;let l=o.uniforms,c=n/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),d=Math.sqrt(c*c-h*h),u=0+c*1.25,f=d*u,{_lodMax:g}=this,y=this._sizeLods[n],m=3*y*(n>g-_i?n-g+_i:0),p=4*(this._cubeSize-y);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=g-t,Ss(r,m,p,3*y,2*y),s.setRenderTarget(r),s.render(a,Tr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=g-n,Ss(e,m,p,3*y,2*y),s.setRenderTarget(e),s.render(a,Tr)}_blur(e,t,n,s,r){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,s,"latitudinal",r),this._halfBlur(o,e,n,n,s,"longitudinal",r)}_halfBlur(e,t,n,s,r,o,a){let l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&Fe("blur direction must be either latitudinal or longitudinal!");let h=3,d=this._lodMeshes[s];d.material=c;let u=c.uniforms,f=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Fi-1),y=r/g,m=isFinite(r)?1+Math.floor(h*y):Fi;m>Fi&&De(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Fi}`);let p=[],C=0;for(let A=0;A<Fi;++A){let v=A/y,w=Math.exp(-v*v/2);p.push(w),A===0?C+=w:A<m&&(C+=2*w)}for(let A=0;A<p.length;A++)p[A]=p[A]/C;u.envMap.value=e.texture,u.samples.value=m,u.weights.value=p,u.latitudinal.value=o==="latitudinal",a&&(u.poleAxis.value=a);let{_lodMax:T}=this;u.dTheta.value=g,u.mipInt.value=T-n;let x=this._sizeLods[s],S=3*x*(s>T-_i?s-T+_i:0),M=4*(this._cubeSize-x);Ss(t,S,M,3*x,2*x),l.setRenderTarget(t),l.render(d,Tr)}};function v0(i){let e=[],t=[],n=[],s=i,r=i-_i+1+Fu.length;for(let o=0;o<r;o++){let a=Math.pow(2,s);e.push(a);let l=1/a;o>i-_i?l=Fu[o-i+_i-1]:o===0&&(l=0),t.push(l);let c=1/(a-2),h=-c,d=1+c,u=[h,h,d,h,d,d,h,h,d,d,h,d],f=6,g=6,y=3,m=2,p=1,C=new Float32Array(y*g*f),T=new Float32Array(m*g*f),x=new Float32Array(p*g*f);for(let M=0;M<f;M++){let A=M%3*2/3-1,v=M>2?0:-1,w=[A,v,0,A+2/3,v,0,A+2/3,v+1,0,A,v,0,A+2/3,v+1,0,A,v+1,0];C.set(w,y*g*M),T.set(u,m*g*M);let I=[M,M,M,M,M,M];x.set(I,p*g*M)}let S=new mt;S.setAttribute("position",new wt(C,y)),S.setAttribute("uv",new wt(T,m)),S.setAttribute("faceIndex",new wt(x,p)),n.push(new Tt(S,null)),s>_i&&s--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Bu(i,e,t){let n=new Qt(i,e,t);return n.texture.mapping=xr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ss(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function y0(i,e,t){return new tn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:_0,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:ja(),fragmentShader:`
|
|
3677
3677
|
|
|
3678
3678
|
precision highp float;
|
|
3679
3679
|
precision highp int;
|
|
@@ -3777,7 +3777,7 @@ void main() {
|
|
|
3777
3777
|
|
|
3778
3778
|
gl_FragColor = vec4(prefilteredColor, 1.0);
|
|
3779
3779
|
}
|
|
3780
|
-
`,blending:In,depthTest:!1,depthWrite:!1})}function
|
|
3780
|
+
`,blending:In,depthTest:!1,depthWrite:!1})}function b0(i,e,t){let n=new Float32Array(Fi),s=new R(0,1,0);return new tn({name:"SphericalGaussianBlur",defines:{n:Fi,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:ja(),fragmentShader:`
|
|
3781
3781
|
|
|
3782
3782
|
precision mediump float;
|
|
3783
3783
|
precision mediump int;
|
|
@@ -3837,7 +3837,7 @@ void main() {
|
|
|
3837
3837
|
}
|
|
3838
3838
|
|
|
3839
3839
|
}
|
|
3840
|
-
`,blending:In,depthTest:!1,depthWrite:!1})}function
|
|
3840
|
+
`,blending:In,depthTest:!1,depthWrite:!1})}function zu(){return new tn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ja(),fragmentShader:`
|
|
3841
3841
|
|
|
3842
3842
|
precision mediump float;
|
|
3843
3843
|
precision mediump int;
|
|
@@ -3856,7 +3856,7 @@ void main() {
|
|
|
3856
3856
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
3857
3857
|
|
|
3858
3858
|
}
|
|
3859
|
-
`,blending:In,depthTest:!1,depthWrite:!1})}function
|
|
3859
|
+
`,blending:In,depthTest:!1,depthWrite:!1})}function ku(){return new tn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ja(),fragmentShader:`
|
|
3860
3860
|
|
|
3861
3861
|
precision mediump float;
|
|
3862
3862
|
precision mediump int;
|
|
@@ -3872,7 +3872,7 @@ void main() {
|
|
|
3872
3872
|
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
|
3873
3873
|
|
|
3874
3874
|
}
|
|
3875
|
-
`,blending:In,depthTest:!1,depthWrite:!1})}function
|
|
3875
|
+
`,blending:In,depthTest:!1,depthWrite:!1})}function ja(){return`
|
|
3876
3876
|
|
|
3877
3877
|
precision mediump float;
|
|
3878
3878
|
precision mediump int;
|
|
@@ -3927,7 +3927,7 @@ void main() {
|
|
|
3927
3927
|
gl_Position = vec4( position, 1.0 );
|
|
3928
3928
|
|
|
3929
3929
|
}
|
|
3930
|
-
`}var
|
|
3930
|
+
`}var Ka=class extends Qt{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new Qs(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
|
|
3931
3931
|
|
|
3932
3932
|
varying vec3 vWorldDirection;
|
|
3933
3933
|
|
|
@@ -3962,7 +3962,7 @@ void main() {
|
|
|
3962
3962
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
3963
3963
|
|
|
3964
3964
|
}
|
|
3965
|
-
`},s=new
|
|
3965
|
+
`},s=new ps(5,5,5),r=new tn({name:"CubemapFromEquirect",uniforms:Ui(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:qt,blending:In});r.uniforms.tEquirect.value=t;let o=new Tt(s,r),a=t.minFilter;return t.minFilter===pi&&(t.minFilter=Ut),new sa(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){let r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,s);e.setRenderTarget(r)}};function M0(i){let e=new WeakMap,t=new WeakMap,n=null;function s(u,f=!1){return u==null?null:f?o(u):r(u)}function r(u){if(u&&u.isTexture){let f=u.mapping;if(f===oa||f===aa)if(e.has(u)){let g=e.get(u).texture;return a(g,u.mapping)}else{let g=u.image;if(g&&g.height>0){let y=new Ka(g.height);return y.fromEquirectangularTexture(i,u),e.set(u,y),u.addEventListener("dispose",c),a(y.texture,u.mapping)}else return null}}return u}function o(u){if(u&&u.isTexture){let f=u.mapping,g=f===oa||f===aa,y=f===fi||f===Ni;if(g||y){let m=t.get(u),p=m!==void 0?m.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==p)return n===null&&(n=new Ja(i)),m=g?n.fromEquirectangular(u,m):n.fromCubemap(u,m),m.texture.pmremVersion=u.pmremVersion,t.set(u,m),m.texture;if(m!==void 0)return m.texture;{let C=u.image;return g&&C&&C.height>0||y&&C&&l(C)?(n===null&&(n=new Ja(i)),m=g?n.fromEquirectangular(u):n.fromCubemap(u),m.texture.pmremVersion=u.pmremVersion,t.set(u,m),u.addEventListener("dispose",h),m.texture):null}}}return u}function a(u,f){return f===oa?u.mapping=fi:f===aa&&(u.mapping=Ni),u}function l(u){let f=0,g=6;for(let y=0;y<g;y++)u[y]!==void 0&&f++;return f===g}function c(u){let f=u.target;f.removeEventListener("dispose",c);let g=e.get(f);g!==void 0&&(e.delete(f),g.dispose())}function h(u){let f=u.target;f.removeEventListener("dispose",h);let g=t.get(f);g!==void 0&&(t.delete(f),g.dispose())}function d(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:s,dispose:d}}function S0(i){let e={};function t(n){if(e[n]!==void 0)return e[n];let s=i.getExtension(n);return e[n]=s,s}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){let s=t(n);return s===null&&Ti("WebGLRenderer: "+n+" extension not supported."),s}}}function E0(i,e,t,n){let s={},r=new WeakMap;function o(d){let u=d.target;u.index!==null&&e.remove(u.index);for(let g in u.attributes)e.remove(u.attributes[g]);u.removeEventListener("dispose",o),delete s[u.id];let f=r.get(u);f&&(e.remove(f),r.delete(u)),n.releaseStatesOfGeometry(u),u.isInstancedBufferGeometry===!0&&delete u._maxInstanceCount,t.memory.geometries--}function a(d,u){return s[u.id]===!0||(u.addEventListener("dispose",o),s[u.id]=!0,t.memory.geometries++),u}function l(d){let u=d.attributes;for(let f in u)e.update(u[f],i.ARRAY_BUFFER)}function c(d){let u=[],f=d.index,g=d.attributes.position,y=0;if(g===void 0)return;if(f!==null){let C=f.array;y=f.version;for(let T=0,x=C.length;T<x;T+=3){let S=C[T+0],M=C[T+1],A=C[T+2];u.push(S,M,M,A,A,S)}}else{let C=g.array;y=g.version;for(let T=0,x=C.length/3-1;T<x;T+=3){let S=T+0,M=T+1,A=T+2;u.push(S,M,M,A,A,S)}}let m=new(g.count>=65535?Js:$s)(u,1);m.version=y;let p=r.get(d);p&&e.remove(p),r.set(d,m)}function h(d){let u=r.get(d);if(u){let f=d.index;f!==null&&u.version<f.version&&c(d)}else c(d);return r.get(d)}return{get:a,update:l,getWireframeAttribute:h}}function w0(i,e,t){let n;function s(d){n=d}let r,o;function a(d){r=d.type,o=d.bytesPerElement}function l(d,u){i.drawElements(n,u,r,d*o),t.update(u,n,1)}function c(d,u,f){f!==0&&(i.drawElementsInstanced(n,u,r,d*o,f),t.update(u,n,f))}function h(d,u,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,u,0,r,d,0,f);let y=0;for(let m=0;m<f;m++)y+=u[m];t.update(y,n,1)}this.setMode=s,this.setIndex=a,this.render=l,this.renderInstances=c,this.renderMultiDraw=h}function T0(i){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,o,a){switch(t.calls++,o){case i.TRIANGLES:t.triangles+=a*(r/3);break;case i.LINES:t.lines+=a*(r/2);break;case i.LINE_STRIP:t.lines+=a*(r-1);break;case i.LINE_LOOP:t.lines+=a*r;break;case i.POINTS:t.points+=a*r;break;default:Fe("WebGLInfo: Unknown draw mode:",o);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:n}}function A0(i,e,t){let n=new WeakMap,s=new gt;function r(o,a,l){let c=o.morphTargetInfluences,h=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,d=h!==void 0?h.length:0,u=n.get(a);if(u===void 0||u.count!==d){let w=function(){A.dispose(),n.delete(a),a.removeEventListener("dispose",w)};u!==void 0&&u.texture.dispose();let f=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,y=a.morphAttributes.color!==void 0,m=a.morphAttributes.position||[],p=a.morphAttributes.normal||[],C=a.morphAttributes.color||[],T=0;f===!0&&(T=1),g===!0&&(T=2),y===!0&&(T=3);let x=a.attributes.position.count*T,S=1;x>e.maxTextureSize&&(S=Math.ceil(x/e.maxTextureSize),x=e.maxTextureSize);let M=new Float32Array(x*S*4*d),A=new Zs(M,x,S,d);A.type=bn,A.needsUpdate=!0;let v=T*4;for(let I=0;I<d;I++){let P=m[I],O=p[I],q=C[I],Y=x*S*4*I;for(let U=0;U<P.count;U++){let G=U*v;f===!0&&(s.fromBufferAttribute(P,U),M[Y+G+0]=s.x,M[Y+G+1]=s.y,M[Y+G+2]=s.z,M[Y+G+3]=0),g===!0&&(s.fromBufferAttribute(O,U),M[Y+G+4]=s.x,M[Y+G+5]=s.y,M[Y+G+6]=s.z,M[Y+G+7]=0),y===!0&&(s.fromBufferAttribute(q,U),M[Y+G+8]=s.x,M[Y+G+9]=s.y,M[Y+G+10]=s.z,M[Y+G+11]=q.itemSize===4?s.w:1)}}u={count:d,texture:A,size:new te(x,S)},n.set(a,u),a.addEventListener("dispose",w)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",o.morphTexture,t);else{let f=0;for(let y=0;y<c.length;y++)f+=c[y];let g=a.morphTargetsRelative?1:1-f;l.getUniforms().setValue(i,"morphTargetBaseInfluence",g),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",u.texture,t),l.getUniforms().setValue(i,"morphTargetsTextureSize",u.size)}return{update:r}}function C0(i,e,t,n,s){let r=new WeakMap;function o(c){let h=s.render.frame,d=c.geometry,u=e.get(c,d);if(r.get(u)!==h&&(e.update(u),r.set(u,h)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),r.get(c)!==h&&(t.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,i.ARRAY_BUFFER),r.set(c,h))),c.isSkinnedMesh){let f=c.skeleton;r.get(f)!==h&&(f.update(),r.set(f,h))}return u}function a(){r=new WeakMap}function l(c){let h=c.target;h.removeEventListener("dispose",l),n.releaseStatesOfObject(h),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:o,dispose:a}}var R0={[tc]:"LINEAR_TONE_MAPPING",[nc]:"REINHARD_TONE_MAPPING",[ic]:"CINEON_TONE_MAPPING",[sc]:"ACES_FILMIC_TONE_MAPPING",[oc]:"AGX_TONE_MAPPING",[ac]:"NEUTRAL_TONE_MAPPING",[rc]:"CUSTOM_TONE_MAPPING"};function P0(i,e,t,n,s,r){let o=new Qt(e,t,{type:i,depthBuffer:s,stencilBuffer:r,samples:n?4:0,depthTexture:s?new Wn(e,t):void 0}),a=new Qt(e,t,{type:Ln,depthBuffer:!1,stencilBuffer:!1}),l=new mt;l.setAttribute("position",new xt([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new xt([0,2,0,0,2,0],2));let c=new Xo({uniforms:{tDiffuse:{value:null}},vertexShader:`
|
|
3966
3966
|
precision highp float;
|
|
3967
3967
|
|
|
3968
3968
|
uniform mat4 modelViewMatrix;
|
|
@@ -4008,17 +4008,17 @@ void main() {
|
|
|
4008
4008
|
#ifdef SRGB_TRANSFER
|
|
4009
4009
|
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
|
4010
4010
|
#endif
|
|
4011
|
-
}`,depthTest:!1,depthWrite:!1}),h=new
|
|
4012
|
-
`),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let
|
|
4013
|
-
`)}var
|
|
4011
|
+
}`,depthTest:!1,depthWrite:!1}),h=new Tt(l,c),d=new ci(-1,1,1,-1,0,1),u=null,f=null,g=!1,y,m=null,p=[],C=!1;this.setSize=function(T,x){o.setSize(T,x),a.setSize(T,x);for(let S=0;S<p.length;S++){let M=p[S];M.setSize&&M.setSize(T,x)}},this.setEffects=function(T){p=T,C=p.length>0&&p[0].isRenderPass===!0;let x=o.width,S=o.height;for(let M=0;M<p.length;M++){let A=p[M];A.setSize&&A.setSize(x,S)}},this.begin=function(T,x){if(g||T.toneMapping===vn&&p.length===0)return!1;if(m=x,x!==null){let S=x.width,M=x.height;(o.width!==S||o.height!==M)&&this.setSize(S,M)}return C===!1&&T.setRenderTarget(o),y=T.toneMapping,T.toneMapping=vn,!0},this.hasRenderPass=function(){return C},this.end=function(T,x){T.toneMapping=y,g=!0;let S=o,M=a;for(let A=0;A<p.length;A++){let v=p[A];if(v.enabled!==!1&&(v.render(T,M,S,x),v.needsSwap!==!1)){let w=S;S=M,M=w}}if(u!==T.outputColorSpace||f!==T.toneMapping){u=T.outputColorSpace,f=T.toneMapping,c.defines={},Qe.getTransfer(u)===it&&(c.defines.SRGB_TRANSFER="");let A=R0[f];A&&(c.defines[A]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=S.texture,T.setRenderTarget(m),T.render(h,d),m=null,g=!1},this.isCompositing=function(){return g},this.dispose=function(){o.depthTexture&&o.depthTexture.dispose(),o.dispose(),a.dispose(),l.dispose(),c.dispose()}}var od=new Xt,Pc=new Wn(1,1),ad=new Zs,ld=new Lo,cd=new Qs,Vu=[],Hu=[],Gu=new Float32Array(16),Wu=new Float32Array(9),Xu=new Float32Array(4);function Ts(i,e,t){let n=i[0];if(n<=0||n>0)return i;let s=e*t,r=Vu[s];if(r===void 0&&(r=new Float32Array(s),Vu[s]=r),e!==0){n.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,i[o].toArray(r,a)}return r}function At(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function Ct(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Qa(i,e){let t=Hu[e];t===void 0&&(t=new Int32Array(e),Hu[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function I0(i,e){let t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function L0(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(At(t,e))return;i.uniform2fv(this.addr,e),Ct(t,e)}}function D0(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(At(t,e))return;i.uniform3fv(this.addr,e),Ct(t,e)}}function N0(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(At(t,e))return;i.uniform4fv(this.addr,e),Ct(t,e)}}function U0(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(At(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),Ct(t,e)}else{if(At(t,n))return;Xu.set(n),i.uniformMatrix2fv(this.addr,!1,Xu),Ct(t,n)}}function F0(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(At(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),Ct(t,e)}else{if(At(t,n))return;Wu.set(n),i.uniformMatrix3fv(this.addr,!1,Wu),Ct(t,n)}}function O0(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(At(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),Ct(t,e)}else{if(At(t,n))return;Gu.set(n),i.uniformMatrix4fv(this.addr,!1,Gu),Ct(t,n)}}function B0(i,e){let t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function z0(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(At(t,e))return;i.uniform2iv(this.addr,e),Ct(t,e)}}function k0(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(At(t,e))return;i.uniform3iv(this.addr,e),Ct(t,e)}}function V0(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(At(t,e))return;i.uniform4iv(this.addr,e),Ct(t,e)}}function H0(i,e){let t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function G0(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(At(t,e))return;i.uniform2uiv(this.addr,e),Ct(t,e)}}function W0(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(At(t,e))return;i.uniform3uiv(this.addr,e),Ct(t,e)}}function X0(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(At(t,e))return;i.uniform4uiv(this.addr,e),Ct(t,e)}}function q0(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?(Pc.compareFunction=t.isReversedDepthBuffer()?Ya:qa,r=Pc):r=od,t.setTexture2D(e||r,s)}function Y0(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||ld,s)}function Z0(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTextureCube(e||cd,s)}function $0(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||ad,s)}function J0(i){switch(i){case 5126:return I0;case 35664:return L0;case 35665:return D0;case 35666:return N0;case 35674:return U0;case 35675:return F0;case 35676:return O0;case 5124:case 35670:return B0;case 35667:case 35671:return z0;case 35668:case 35672:return k0;case 35669:case 35673:return V0;case 5125:return H0;case 36294:return G0;case 36295:return W0;case 36296:return X0;case 35678:case 36198:case 36298:case 36306:case 35682:return q0;case 35679:case 36299:case 36307:return Y0;case 35680:case 36300:case 36308:case 36293:return Z0;case 36289:case 36303:case 36311:case 36292:return $0}}function K0(i,e){i.uniform1fv(this.addr,e)}function j0(i,e){let t=Ts(e,this.size,2);i.uniform2fv(this.addr,t)}function Q0(i,e){let t=Ts(e,this.size,3);i.uniform3fv(this.addr,t)}function e_(i,e){let t=Ts(e,this.size,4);i.uniform4fv(this.addr,t)}function t_(i,e){let t=Ts(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function n_(i,e){let t=Ts(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function i_(i,e){let t=Ts(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function s_(i,e){i.uniform1iv(this.addr,e)}function r_(i,e){i.uniform2iv(this.addr,e)}function o_(i,e){i.uniform3iv(this.addr,e)}function a_(i,e){i.uniform4iv(this.addr,e)}function l_(i,e){i.uniform1uiv(this.addr,e)}function c_(i,e){i.uniform2uiv(this.addr,e)}function h_(i,e){i.uniform3uiv(this.addr,e)}function u_(i,e){i.uniform4uiv(this.addr,e)}function d_(i,e,t){let n=this.cache,s=e.length,r=Qa(t,s);At(n,r)||(i.uniform1iv(this.addr,r),Ct(n,r));let o;this.type===i.SAMPLER_2D_SHADOW?o=Pc:o=od;for(let a=0;a!==s;++a)t.setTexture2D(e[a]||o,r[a])}function f_(i,e,t){let n=this.cache,s=e.length,r=Qa(t,s);At(n,r)||(i.uniform1iv(this.addr,r),Ct(n,r));for(let o=0;o!==s;++o)t.setTexture3D(e[o]||ld,r[o])}function p_(i,e,t){let n=this.cache,s=e.length,r=Qa(t,s);At(n,r)||(i.uniform1iv(this.addr,r),Ct(n,r));for(let o=0;o!==s;++o)t.setTextureCube(e[o]||cd,r[o])}function m_(i,e,t){let n=this.cache,s=e.length,r=Qa(t,s);At(n,r)||(i.uniform1iv(this.addr,r),Ct(n,r));for(let o=0;o!==s;++o)t.setTexture2DArray(e[o]||ad,r[o])}function g_(i){switch(i){case 5126:return K0;case 35664:return j0;case 35665:return Q0;case 35666:return e_;case 35674:return t_;case 35675:return n_;case 35676:return i_;case 5124:case 35670:return s_;case 35667:case 35671:return r_;case 35668:case 35672:return o_;case 35669:case 35673:return a_;case 5125:return l_;case 36294:return c_;case 36295:return h_;case 36296:return u_;case 35678:case 36198:case 36298:case 36306:case 35682:return d_;case 35679:case 36299:case 36307:return f_;case 35680:case 36300:case 36308:case 36293:return p_;case 36289:case 36303:case 36311:case 36292:return m_}}var Ic=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=J0(t.type)}},Lc=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=g_(t.type)}},Dc=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let s=this.seq;for(let r=0,o=s.length;r!==o;++r){let a=s[r];a.setValue(e,t[a.id],n)}}},Cc=/(\w+)(\])?(\[|\.)?/g;function qu(i,e){i.seq.push(e),i.map[e.id]=e}function __(i,e,t){let n=i.name,s=n.length;for(Cc.lastIndex=0;;){let r=Cc.exec(n),o=Cc.lastIndex,a=r[1],l=r[2]==="]",c=r[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===s){qu(t,c===void 0?new Ic(a,i,e):new Lc(a,i,e));break}else{let d=t.map[a];d===void 0&&(d=new Dc(a),qu(t,d)),t=d}}}var Es=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let o=0;o<n;++o){let a=e.getActiveUniform(t,o),l=e.getUniformLocation(t,a.name);__(a,l,this)}let s=[],r=[];for(let o of this.seq)o.type===e.SAMPLER_2D_SHADOW||o.type===e.SAMPLER_CUBE_SHADOW||o.type===e.SAMPLER_2D_ARRAY_SHADOW?s.push(o):r.push(o);s.length>0&&(this.seq=s.concat(r))}setValue(e,t,n,s){let r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){let s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,o=t.length;r!==o;++r){let a=t[r],l=n[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,s)}}static seqWithValue(e,t){let n=[];for(let s=0,r=e.length;s!==r;++s){let o=e[s];o.id in t&&n.push(o)}return n}};function Yu(i,e,t){let n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}var x_=37297,v_=0;function y_(i,e){let t=i.split(`
|
|
4012
|
+
`),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let o=s;o<r;o++){let a=o+1;n.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return n.join(`
|
|
4013
|
+
`)}var Zu=new Ge;function b_(i){Qe._getMatrix(Zu,Qe.workingColorSpace,i);let e=`mat3( ${Zu.elements.map(t=>t.toFixed(4))} )`;switch(Qe.getTransfer(i)){case Xs:return[e,"LinearTransferOETF"];case it:return[e,"sRGBTransferOETF"];default:return De("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function $u(i,e,t){let n=i.getShaderParameter(e,i.COMPILE_STATUS),r=(i.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";let o=/ERROR: 0:(\d+)/.exec(r);if(o){let a=parseInt(o[1]);return t.toUpperCase()+`
|
|
4014
4014
|
|
|
4015
4015
|
`+r+`
|
|
4016
4016
|
|
|
4017
|
-
`+
|
|
4018
|
-
`)}var
|
|
4019
|
-
`)}function
|
|
4020
|
-
`)}function
|
|
4021
|
-
`)}function
|
|
4017
|
+
`+y_(i.getShaderSource(e),a)}else return r}function M_(i,e){let t=b_(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
|
4018
|
+
`)}var S_={[tc]:"Linear",[nc]:"Reinhard",[ic]:"Cineon",[sc]:"ACESFilmic",[oc]:"AgX",[ac]:"Neutral",[rc]:"Custom"};function E_(i,e){let t=S_[e];return t===void 0?(De("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var $a=new R;function w_(){Qe.getLuminanceCoefficients($a);let i=$a.x.toFixed(4),e=$a.y.toFixed(4),t=$a.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
|
4019
|
+
`)}function T_(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Cr).join(`
|
|
4020
|
+
`)}function A_(i){let e=[];for(let t in i){let n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
|
|
4021
|
+
`)}function C_(i,e){let t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){let r=i.getActiveAttrib(e,s),o=r.name,a=1;r.type===i.FLOAT_MAT2&&(a=2),r.type===i.FLOAT_MAT3&&(a=3),r.type===i.FLOAT_MAT4&&(a=4),t[o]={type:r.type,location:i.getAttribLocation(e,o),locationSize:a}}return t}function Cr(i){return i!==""}function Ju(i,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Ku(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var R_=/^[ \t]*#include +<([\w\d./]+)>/gm;function Nc(i){return i.replace(R_,I_)}var P_=new Map;function I_(i,e){let t=$e[e];if(t===void 0){let n=P_.get(e);if(n!==void 0)t=$e[n],De('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Nc(t)}var L_=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function ju(i){return i.replace(L_,D_)}function D_(i,e,t,n){let s="";for(let r=parseInt(e);r<parseInt(t);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function Qu(i){let e=`precision ${i.precision} float;
|
|
4022
4022
|
precision ${i.precision} int;
|
|
4023
4023
|
precision ${i.precision} sampler2D;
|
|
4024
4024
|
precision ${i.precision} samplerCube;
|
|
@@ -4038,30 +4038,30 @@ void main() {
|
|
|
4038
4038
|
`;return i.precision==="highp"?e+=`
|
|
4039
4039
|
#define HIGH_PRECISION`:i.precision==="mediump"?e+=`
|
|
4040
4040
|
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
|
|
4041
|
-
#define LOW_PRECISION`),e}var
|
|
4042
|
-
`:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(
|
|
4041
|
+
#define LOW_PRECISION`),e}var N_={[_r]:"SHADOWMAP_TYPE_PCF",[ys]:"SHADOWMAP_TYPE_VSM"};function U_(i){return N_[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var F_={[fi]:"ENVMAP_TYPE_CUBE",[Ni]:"ENVMAP_TYPE_CUBE",[xr]:"ENVMAP_TYPE_CUBE_UV"};function O_(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":F_[i.envMapMode]||"ENVMAP_TYPE_CUBE"}var B_={[Ni]:"ENVMAP_MODE_REFRACTION"};function z_(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":B_[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}var k_={[ec]:"ENVMAP_BLENDING_MULTIPLY",[fu]:"ENVMAP_BLENDING_MIX",[pu]:"ENVMAP_BLENDING_ADD"};function V_(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":k_[i.combine]||"ENVMAP_BLENDING_NONE"}function H_(i){let e=i.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function G_(i,e,t,n){let s=i.getContext(),r=t.defines,o=t.vertexShader,a=t.fragmentShader,l=U_(t),c=O_(t),h=z_(t),d=V_(t),u=H_(t),f=T_(t),g=A_(r),y=s.createProgram(),m,p,C=t.glslVersion?"#version "+t.glslVersion+`
|
|
4042
|
+
`:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Cr).join(`
|
|
4043
4043
|
`),m.length>0&&(m+=`
|
|
4044
|
-
`),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(
|
|
4044
|
+
`),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Cr).join(`
|
|
4045
4045
|
`),p.length>0&&(p+=`
|
|
4046
|
-
`)):(m=[
|
|
4047
|
-
`].filter(
|
|
4048
|
-
`),p=[
|
|
4049
|
-
`].filter(
|
|
4050
|
-
`)),
|
|
4046
|
+
`)):(m=[Qu(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
|
|
4047
|
+
`].filter(Cr).join(`
|
|
4048
|
+
`),p=[Qu(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==vn?"#define TONE_MAPPING":"",t.toneMapping!==vn?$e.tonemapping_pars_fragment:"",t.toneMapping!==vn?E_("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",$e.colorspace_pars_fragment,M_("linearToOutputTexel",t.outputColorSpace),w_(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
4049
|
+
`].filter(Cr).join(`
|
|
4050
|
+
`)),o=Nc(o),o=Ju(o,t),o=Ku(o,t),a=Nc(a),a=Ju(a,t),a=Ku(a,t),o=ju(o),a=ju(a),t.isRawShaderMaterial!==!0&&(C=`#version 300 es
|
|
4051
4051
|
`,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
4052
4052
|
`)+`
|
|
4053
|
-
`+m,p=["#define varying in",t.glslVersion===
|
|
4053
|
+
`+m,p=["#define varying in",t.glslVersion===gc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===gc?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
|
|
4054
4054
|
`)+`
|
|
4055
|
-
`+p);let
|
|
4055
|
+
`+p);let T=C+m+o,x=C+p+a,S=Yu(s,s.VERTEX_SHADER,T),M=Yu(s,s.FRAGMENT_SHADER,x);s.attachShader(y,S),s.attachShader(y,M),t.index0AttributeName!==void 0?s.bindAttribLocation(y,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(y,0,"position"),s.linkProgram(y);function A(P){if(i.debug.checkShaderErrors){let O=s.getProgramInfoLog(y)||"",q=s.getShaderInfoLog(S)||"",Y=s.getShaderInfoLog(M)||"",U=O.trim(),G=q.trim(),H=Y.trim(),j=!0,se=!0;if(s.getProgramParameter(y,s.LINK_STATUS)===!1)if(j=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,y,S,M);else{let ue=$u(s,S,"vertex"),le=$u(s,M,"fragment");Fe("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(y,s.VALIDATE_STATUS)+`
|
|
4056
4056
|
|
|
4057
4057
|
Material Name: `+P.name+`
|
|
4058
4058
|
Material Type: `+P.type+`
|
|
4059
4059
|
|
|
4060
|
-
Program Info Log: `+
|
|
4060
|
+
Program Info Log: `+U+`
|
|
4061
4061
|
`+ue+`
|
|
4062
|
-
`+le)}else O!==""?De("WebGLProgram: Program Info Log:",O):(W===""||H==="")&&(ie=!1);ie&&(P.diagnostics={runnable:K,programLog:O,vertexShader:{log:W,prefix:m},fragmentShader:{log:H,prefix:p}})}s.deleteShader(S),s.deleteShader(M),y=new Ms(s,b),T=E_(s,b)}let y;this.getUniforms=function(){return y===void 0&&A(this),y};let T;this.getAttributes=function(){return T===void 0&&A(this),T};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=s.getProgramParameter(b,p_)),I},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(b),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=m_++,this.cacheKey=e,this.usedTimes=1,this.program=b,this.vertexShader=S,this.fragmentShader=M,this}var k_=0,Nc=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new Uc(e),t.set(e,n)),n}},Uc=class{constructor(e){this.id=k_++,this.code=e,this.usedTimes=0}};function V_(i){return i===mi||i===Tr||i===wr}function H_(i,e,t,n,s,r){let a=new ls,o=new Nc,l=new Set,c=[],h=new Map,d=n.logarithmicDepthBuffer,u=n.precision,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(y){return l.add(y),y===0?"uv":`uv${y}`}function b(y,T,I,P,F,G){let X=P.fog,O=F.geometry,W=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?P.environment:null,H=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap,K=e.get(y.envMap||W,H),ie=K&&K.mapping===yr?K.image.height:null,ue=f[y.type];y.precision!==null&&(u=n.getMaxPrecision(y.precision),u!==y.precision&&De("WebGLProgram.getParameters:",y.precision,"not supported, using",u,"instead."));let le=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,Me=le!==void 0?le.length:0,$e=0;O.morphAttributes.position!==void 0&&($e=1),O.morphAttributes.normal!==void 0&&($e=2),O.morphAttributes.color!==void 0&&($e=3);let ct,Qe,$,ce;if(ue){let Te=Nn[ue];ct=Te.vertexShader,Qe=Te.fragmentShader}else{ct=y.vertexShader,Qe=y.fragmentShader;let Te=o.getVertexShaderStage(y),yt=o.getFragmentShaderStage(y);o.update(y,Te,yt),$=Te.id,ce=yt.id}let re=i.getRenderTarget(),Ie=i.state.buffers.depth.getReversed(),ze=F.isInstancedMesh===!0,Ue=F.isBatchedMesh===!0,nt=!!y.map,Ve=!!y.matcap,j=!!K,ne=!!y.aoMap,te=!!y.lightMap,xe=!!y.bumpMap&&y.wireframe===!1,me=!!y.normalMap,Oe=!!y.displacementMap,Ce=!!y.emissiveMap,ke=!!y.metalnessMap,Ge=!!y.roughnessMap,L=y.anisotropy>0,at=y.clearcoat>0,Ke=y.dispersion>0,E=y.iridescence>0,x=y.sheen>0,U=y.transmission>0,k=L&&!!y.anisotropyMap,q=at&&!!y.clearcoatMap,ae=at&&!!y.clearcoatNormalMap,oe=at&&!!y.clearcoatRoughnessMap,Y=E&&!!y.iridescenceMap,J=E&&!!y.iridescenceThicknessMap,de=x&&!!y.sheenColorMap,Re=x&&!!y.sheenRoughnessMap,ge=!!y.specularMap,fe=!!y.specularColorMap,Ne=!!y.specularIntensityMap,Be=U&&!!y.transmissionMap,We=U&&!!y.thicknessMap,D=!!y.gradientMap,he=!!y.alphaMap,Z=y.alphaTest>0,pe=!!y.alphaHash,be=!!y.extensions,Q=yn;y.toneMapped&&(re===null||re.isXRRenderTarget===!0)&&(Q=i.toneMapping);let Ae={shaderID:ue,shaderType:y.type,shaderName:y.name,vertexShader:ct,fragmentShader:Qe,defines:y.defines,customVertexShaderID:$,customFragmentShaderID:ce,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:u,batching:Ue,batchingColor:Ue&&F._colorsTexture!==null,instancing:ze,instancingColor:ze&&F.instanceColor!==null,instancingMorph:ze&&F.morphTexture!==null,outputColorSpace:re===null?i.outputColorSpace:re.isXRRenderTarget===!0?re.texture.colorSpace:je.workingColorSpace,alphaToCoverage:!!y.alphaToCoverage,map:nt,matcap:Ve,envMap:j,envMapMode:j&&K.mapping,envMapCubeUVHeight:ie,aoMap:ne,lightMap:te,bumpMap:xe,normalMap:me,displacementMap:Oe,emissiveMap:Ce,normalMapObjectSpace:me&&y.normalMapType===mu,normalMapTangentSpace:me&&y.normalMapType===Xo,packedNormalMap:me&&y.normalMapType===Xo&&V_(y.normalMap.format),metalnessMap:ke,roughnessMap:Ge,anisotropy:L,anisotropyMap:k,clearcoat:at,clearcoatMap:q,clearcoatNormalMap:ae,clearcoatRoughnessMap:oe,dispersion:Ke,iridescence:E,iridescenceMap:Y,iridescenceThicknessMap:J,sheen:x,sheenColorMap:de,sheenRoughnessMap:Re,specularMap:ge,specularColorMap:fe,specularIntensityMap:Ne,transmission:U,transmissionMap:Be,thicknessMap:We,gradientMap:D,opaque:y.transparent===!1&&y.blending===wi&&y.alphaToCoverage===!1,alphaMap:he,alphaTest:Z,alphaHash:pe,combine:y.combine,mapUv:nt&&g(y.map.channel),aoMapUv:ne&&g(y.aoMap.channel),lightMapUv:te&&g(y.lightMap.channel),bumpMapUv:xe&&g(y.bumpMap.channel),normalMapUv:me&&g(y.normalMap.channel),displacementMapUv:Oe&&g(y.displacementMap.channel),emissiveMapUv:Ce&&g(y.emissiveMap.channel),metalnessMapUv:ke&&g(y.metalnessMap.channel),roughnessMapUv:Ge&&g(y.roughnessMap.channel),anisotropyMapUv:k&&g(y.anisotropyMap.channel),clearcoatMapUv:q&&g(y.clearcoatMap.channel),clearcoatNormalMapUv:ae&&g(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:oe&&g(y.clearcoatRoughnessMap.channel),iridescenceMapUv:Y&&g(y.iridescenceMap.channel),iridescenceThicknessMapUv:J&&g(y.iridescenceThicknessMap.channel),sheenColorMapUv:de&&g(y.sheenColorMap.channel),sheenRoughnessMapUv:Re&&g(y.sheenRoughnessMap.channel),specularMapUv:ge&&g(y.specularMap.channel),specularColorMapUv:fe&&g(y.specularColorMap.channel),specularIntensityMapUv:Ne&&g(y.specularIntensityMap.channel),transmissionMapUv:Be&&g(y.transmissionMap.channel),thicknessMapUv:We&&g(y.thicknessMap.channel),alphaMapUv:he&&g(y.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&(me||L),vertexNormals:!!O.attributes.normal,vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,pointsUvs:F.isPoints===!0&&!!O.attributes.uv&&(nt||he),fog:!!X,useFog:y.fog===!0,fogExp2:!!X&&X.isFogExp2,flatShading:y.wireframe===!1&&(y.flatShading===!0||O.attributes.normal===void 0&&me===!1&&(y.isMeshLambertMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isMeshPhysicalMaterial)),sizeAttenuation:y.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:Ie,skinning:F.isSkinnedMesh===!0,hasPositionAttribute:O.attributes.position!==void 0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:Me,morphTextureStride:$e,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numLightProbeGrids:G.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:y.dithering,shadowMapEnabled:i.shadowMap.enabled&&I.length>0,shadowMapType:i.shadowMap.type,toneMapping:Q,decodeVideoTexture:nt&&y.map.isVideoTexture===!0&&je.getTransfer(y.map.colorSpace)===it,decodeVideoTextureEmissive:Ce&&y.emissiveMap.isVideoTexture===!0&&je.getTransfer(y.emissiveMap.colorSpace)===it,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===ln,flipSided:y.side===qt,useDepthPacking:y.depthPacking>=0,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionClipCullDistance:be&&y.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(be&&y.extensions.multiDraw===!0||Ue)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:y.customProgramCacheKey()};return Ae.vertexUv1s=l.has(1),Ae.vertexUv2s=l.has(2),Ae.vertexUv3s=l.has(3),l.clear(),Ae}function m(y){let T=[];if(y.shaderID?T.push(y.shaderID):(T.push(y.customVertexShaderID),T.push(y.customFragmentShaderID)),y.defines!==void 0)for(let I in y.defines)T.push(I),T.push(y.defines[I]);return y.isRawShaderMaterial===!1&&(p(T,y),C(T,y),T.push(i.outputColorSpace)),T.push(y.customProgramCacheKey),T.join()}function p(y,T){y.push(T.precision),y.push(T.outputColorSpace),y.push(T.envMapMode),y.push(T.envMapCubeUVHeight),y.push(T.mapUv),y.push(T.alphaMapUv),y.push(T.lightMapUv),y.push(T.aoMapUv),y.push(T.bumpMapUv),y.push(T.normalMapUv),y.push(T.displacementMapUv),y.push(T.emissiveMapUv),y.push(T.metalnessMapUv),y.push(T.roughnessMapUv),y.push(T.anisotropyMapUv),y.push(T.clearcoatMapUv),y.push(T.clearcoatNormalMapUv),y.push(T.clearcoatRoughnessMapUv),y.push(T.iridescenceMapUv),y.push(T.iridescenceThicknessMapUv),y.push(T.sheenColorMapUv),y.push(T.sheenRoughnessMapUv),y.push(T.specularMapUv),y.push(T.specularColorMapUv),y.push(T.specularIntensityMapUv),y.push(T.transmissionMapUv),y.push(T.thicknessMapUv),y.push(T.combine),y.push(T.fogExp2),y.push(T.sizeAttenuation),y.push(T.morphTargetsCount),y.push(T.morphAttributeCount),y.push(T.numDirLights),y.push(T.numPointLights),y.push(T.numSpotLights),y.push(T.numSpotLightMaps),y.push(T.numHemiLights),y.push(T.numRectAreaLights),y.push(T.numDirLightShadows),y.push(T.numPointLightShadows),y.push(T.numSpotLightShadows),y.push(T.numSpotLightShadowsWithMaps),y.push(T.numLightProbes),y.push(T.shadowMapType),y.push(T.toneMapping),y.push(T.numClippingPlanes),y.push(T.numClipIntersection),y.push(T.depthPacking)}function C(y,T){a.disableAll(),T.instancing&&a.enable(0),T.instancingColor&&a.enable(1),T.instancingMorph&&a.enable(2),T.matcap&&a.enable(3),T.envMap&&a.enable(4),T.normalMapObjectSpace&&a.enable(5),T.normalMapTangentSpace&&a.enable(6),T.clearcoat&&a.enable(7),T.iridescence&&a.enable(8),T.alphaTest&&a.enable(9),T.vertexColors&&a.enable(10),T.vertexAlphas&&a.enable(11),T.vertexUv1s&&a.enable(12),T.vertexUv2s&&a.enable(13),T.vertexUv3s&&a.enable(14),T.vertexTangents&&a.enable(15),T.anisotropy&&a.enable(16),T.alphaHash&&a.enable(17),T.batching&&a.enable(18),T.dispersion&&a.enable(19),T.batchingColor&&a.enable(20),T.gradientMap&&a.enable(21),T.packedNormalMap&&a.enable(22),T.vertexNormals&&a.enable(23),y.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.reversedDepthBuffer&&a.enable(4),T.skinning&&a.enable(5),T.morphTargets&&a.enable(6),T.morphNormals&&a.enable(7),T.morphColors&&a.enable(8),T.premultipliedAlpha&&a.enable(9),T.shadowMapEnabled&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),T.decodeVideoTextureEmissive&&a.enable(20),T.alphaToCoverage&&a.enable(21),T.numLightProbeGrids>0&&a.enable(22),T.hasPositionAttribute&&a.enable(23),y.push(a.mask)}function w(y){let T=f[y.type],I;if(T){let P=Nn[T];I=Lu.clone(P.uniforms)}else I=y.uniforms;return I}function _(y,T){let I=h.get(T);return I!==void 0?++I.usedTimes:(I=new z_(i,T,y,s),c.push(I),h.set(T,I)),I}function S(y){if(--y.usedTimes===0){let T=c.indexOf(y);c[T]=c[c.length-1],c.pop(),h.delete(y.cacheKey),y.destroy()}}function M(y){o.remove(y)}function A(){o.dispose()}return{getParameters:b,getProgramCacheKey:m,getUniforms:w,acquireProgram:_,releaseProgram:S,releaseShaderCache:M,programs:c,dispose:A}}function G_(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,l){i.get(a)[o]=l}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function W_(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function ju(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Qu(){let i=[],e=0,t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function a(u){let f=0;return u.isInstancedMesh&&(f+=2),u.isSkinnedMesh&&(f+=1),f}function o(u,f,g,b,m,p){let C=i[e];return C===void 0?(C={id:u.id,object:u,geometry:f,material:g,materialVariant:a(u),groupOrder:b,renderOrder:u.renderOrder,z:m,group:p},i[e]=C):(C.id=u.id,C.object=u,C.geometry=f,C.material=g,C.materialVariant=a(u),C.groupOrder=b,C.renderOrder=u.renderOrder,C.z=m,C.group=p),e++,C}function l(u,f,g,b,m,p){let C=o(u,f,g,b,m,p);g.transmission>0?n.push(C):g.transparent===!0?s.push(C):t.push(C)}function c(u,f,g,b,m,p){let C=o(u,f,g,b,m,p);g.transmission>0?n.unshift(C):g.transparent===!0?s.unshift(C):t.unshift(C)}function h(u,f,g){t.length>1&&t.sort(u||W_),n.length>1&&n.sort(f||ju),s.length>1&&s.sort(f||ju),g&&(t.reverse(),n.reverse(),s.reverse())}function d(){for(let u=e,f=i.length;u<f;u++){let g=i[u];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:t,transmissive:n,transparent:s,init:r,push:l,unshift:c,finish:d,sort:h}}function X_(){let i=new WeakMap;function e(n,s){let r=i.get(n),a;return r===void 0?(a=new Qu,i.set(n,[a])):s>=r.length?(a=new Qu,r.push(a)):a=r[s],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function q_(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new R,color:new qe};break;case"SpotLight":t={position:new R,direction:new R,color:new qe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new R,color:new qe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new R,skyColor:new qe,groundColor:new qe};break;case"RectAreaLight":t={color:new qe,position:new R,halfWidth:new R,halfHeight:new R};break}return i[e.id]=t,t}}}function Y_(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ee};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ee};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ee,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}var Z_=0;function $_(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function J_(i){let e=new q_,t=Y_(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new R);let s=new R,r=new rt,a=new rt;function o(c){let h=0,d=0,u=0;for(let T=0;T<9;T++)n.probe[T].set(0,0,0);let f=0,g=0,b=0,m=0,p=0,C=0,w=0,_=0,S=0,M=0,A=0;c.sort($_);for(let T=0,I=c.length;T<I;T++){let P=c[T],F=P.color,G=P.intensity,X=P.distance,O=null;if(P.shadow&&P.shadow.map&&(P.shadow.map.texture.format===mi?O=P.shadow.map.texture:O=P.shadow.map.depthTexture||P.shadow.map.texture),P.isAmbientLight)h+=F.r*G,d+=F.g*G,u+=F.b*G;else if(P.isLightProbe){for(let W=0;W<9;W++)n.probe[W].addScaledVector(P.sh.coefficients[W],G);A++}else if(P.isDirectionalLight){let W=e.get(P);if(W.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){let H=P.shadow,K=t.get(P);K.shadowIntensity=H.intensity,K.shadowBias=H.bias,K.shadowNormalBias=H.normalBias,K.shadowRadius=H.radius,K.shadowMapSize=H.mapSize,n.directionalShadow[f]=K,n.directionalShadowMap[f]=O,n.directionalShadowMatrix[f]=P.shadow.matrix,C++}n.directional[f]=W,f++}else if(P.isSpotLight){let W=e.get(P);W.position.setFromMatrixPosition(P.matrixWorld),W.color.copy(F).multiplyScalar(G),W.distance=X,W.coneCos=Math.cos(P.angle),W.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),W.decay=P.decay,n.spot[b]=W;let H=P.shadow;if(P.map&&(n.spotLightMap[S]=P.map,S++,H.updateMatrices(P),P.castShadow&&M++),n.spotLightMatrix[b]=H.matrix,P.castShadow){let K=t.get(P);K.shadowIntensity=H.intensity,K.shadowBias=H.bias,K.shadowNormalBias=H.normalBias,K.shadowRadius=H.radius,K.shadowMapSize=H.mapSize,n.spotShadow[b]=K,n.spotShadowMap[b]=O,_++}b++}else if(P.isRectAreaLight){let W=e.get(P);W.color.copy(F).multiplyScalar(G),W.halfWidth.set(P.width*.5,0,0),W.halfHeight.set(0,P.height*.5,0),n.rectArea[m]=W,m++}else if(P.isPointLight){let W=e.get(P);if(W.color.copy(P.color).multiplyScalar(P.intensity),W.distance=P.distance,W.decay=P.decay,P.castShadow){let H=P.shadow,K=t.get(P);K.shadowIntensity=H.intensity,K.shadowBias=H.bias,K.shadowNormalBias=H.normalBias,K.shadowRadius=H.radius,K.shadowMapSize=H.mapSize,K.shadowCameraNear=H.camera.near,K.shadowCameraFar=H.camera.far,n.pointShadow[g]=K,n.pointShadowMap[g]=O,n.pointShadowMatrix[g]=P.shadow.matrix,w++}n.point[g]=W,g++}else if(P.isHemisphereLight){let W=e.get(P);W.skyColor.copy(P.color).multiplyScalar(G),W.groundColor.copy(P.groundColor).multiplyScalar(G),n.hemi[p]=W,p++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=_e.LTC_FLOAT_1,n.rectAreaLTC2=_e.LTC_FLOAT_2):(n.rectAreaLTC1=_e.LTC_HALF_1,n.rectAreaLTC2=_e.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=u;let y=n.hash;(y.directionalLength!==f||y.pointLength!==g||y.spotLength!==b||y.rectAreaLength!==m||y.hemiLength!==p||y.numDirectionalShadows!==C||y.numPointShadows!==w||y.numSpotShadows!==_||y.numSpotMaps!==S||y.numLightProbes!==A)&&(n.directional.length=f,n.spot.length=b,n.rectArea.length=m,n.point.length=g,n.hemi.length=p,n.directionalShadow.length=C,n.directionalShadowMap.length=C,n.pointShadow.length=w,n.pointShadowMap.length=w,n.spotShadow.length=_,n.spotShadowMap.length=_,n.directionalShadowMatrix.length=C,n.pointShadowMatrix.length=w,n.spotLightMatrix.length=_+S-M,n.spotLightMap.length=S,n.numSpotLightShadowsWithMaps=M,n.numLightProbes=A,y.directionalLength=f,y.pointLength=g,y.spotLength=b,y.rectAreaLength=m,y.hemiLength=p,y.numDirectionalShadows=C,y.numPointShadows=w,y.numSpotShadows=_,y.numSpotMaps=S,y.numLightProbes=A,n.version=Z_++)}function l(c,h){let d=0,u=0,f=0,g=0,b=0,m=h.matrixWorldInverse;for(let p=0,C=c.length;p<C;p++){let w=c[p];if(w.isDirectionalLight){let _=n.directional[d];_.direction.setFromMatrixPosition(w.matrixWorld),s.setFromMatrixPosition(w.target.matrixWorld),_.direction.sub(s),_.direction.transformDirection(m),d++}else if(w.isSpotLight){let _=n.spot[f];_.position.setFromMatrixPosition(w.matrixWorld),_.position.applyMatrix4(m),_.direction.setFromMatrixPosition(w.matrixWorld),s.setFromMatrixPosition(w.target.matrixWorld),_.direction.sub(s),_.direction.transformDirection(m),f++}else if(w.isRectAreaLight){let _=n.rectArea[g];_.position.setFromMatrixPosition(w.matrixWorld),_.position.applyMatrix4(m),a.identity(),r.copy(w.matrixWorld),r.premultiply(m),a.extractRotation(r),_.halfWidth.set(w.width*.5,0,0),_.halfHeight.set(0,w.height*.5,0),_.halfWidth.applyMatrix4(a),_.halfHeight.applyMatrix4(a),g++}else if(w.isPointLight){let _=n.point[u];_.position.setFromMatrixPosition(w.matrixWorld),_.position.applyMatrix4(m),u++}else if(w.isHemisphereLight){let _=n.hemi[b];_.direction.setFromMatrixPosition(w.matrixWorld),_.direction.transformDirection(m),b++}}}return{setup:o,setupView:l,state:n}}function ed(i){let e=new J_(i),t=[],n=[],s=[];function r(u){d.camera=u,t.length=0,n.length=0,s.length=0}function a(u){t.push(u)}function o(u){n.push(u)}function l(u){s.push(u)}function c(){e.setup(t)}function h(u){e.setupView(t,u)}let d={lightsArray:t,shadowsArray:n,lightProbeGridArray:s,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:d,setupLights:c,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:l}}function K_(i){let e=new WeakMap;function t(s,r=0){let a=e.get(s),o;return a===void 0?(o=new ed(i),e.set(s,[o])):r>=a.length?(o=new ed(i),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}var j_=`void main() {
|
|
4062
|
+
`+le)}else U!==""?De("WebGLProgram: Program Info Log:",U):(G===""||H==="")&&(se=!1);se&&(P.diagnostics={runnable:j,programLog:U,vertexShader:{log:G,prefix:m},fragmentShader:{log:H,prefix:p}})}s.deleteShader(S),s.deleteShader(M),v=new Es(s,y),w=C_(s,y)}let v;this.getUniforms=function(){return v===void 0&&A(this),v};let w;this.getAttributes=function(){return w===void 0&&A(this),w};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=s.getProgramParameter(y,x_)),I},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=v_++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=S,this.fragmentShader=M,this}var W_=0,Uc=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new Fc(e),t.set(e,n)),n}},Fc=class{constructor(e){this.id=W_++,this.code=e,this.usedTimes=0}};function X_(i){return i===gi||i===Er||i===wr}function q_(i,e,t,n,s,r){let o=new hs,a=new Uc,l=new Set,c=[],h=new Map,d=n.logarithmicDepthBuffer,u=n.precision,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(v){return l.add(v),v===0?"uv":`uv${v}`}function y(v,w,I,P,O,q){let Y=P.fog,U=O.geometry,G=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?P.environment:null,H=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,j=e.get(v.envMap||G,H),se=j&&j.mapping===xr?j.image.height:null,ue=f[v.type];v.precision!==null&&(u=n.getMaxPrecision(v.precision),u!==v.precision&&De("WebGLProgram.getParameters:",v.precision,"not supported, using",u,"instead."));let le=U.morphAttributes.position||U.morphAttributes.normal||U.morphAttributes.color,Me=le!==void 0?le.length:0,Je=0;U.morphAttributes.position!==void 0&&(Je=1),U.morphAttributes.normal!==void 0&&(Je=2),U.morphAttributes.color!==void 0&&(Je=3);let ct,et,J,ce;if(ue){let we=Nn[ue];ct=we.vertexShader,et=we.fragmentShader}else{ct=v.vertexShader,et=v.fragmentShader;let we=a.getVertexShaderStage(v),vt=a.getFragmentShaderStage(v);a.update(v,we,vt),J=we.id,ce=vt.id}let re=i.getRenderTarget(),Ie=i.state.buffers.depth.getReversed(),ke=O.isInstancedMesh===!0,Ue=O.isBatchedMesh===!0,nt=!!v.map,He=!!v.matcap,Q=!!j,ie=!!v.aoMap,ne=!!v.lightMap,xe=!!v.bumpMap&&v.wireframe===!1,me=!!v.normalMap,Be=!!v.displacementMap,Ce=!!v.emissiveMap,Ve=!!v.metalnessMap,We=!!v.roughnessMap,L=v.anisotropy>0,ot=v.clearcoat>0,je=v.dispersion>0,E=v.iridescence>0,_=v.sheen>0,F=v.transmission>0,k=L&&!!v.anisotropyMap,W=ot&&!!v.clearcoatMap,oe=ot&&!!v.clearcoatNormalMap,ae=ot&&!!v.clearcoatRoughnessMap,X=E&&!!v.iridescenceMap,K=E&&!!v.iridescenceThicknessMap,de=_&&!!v.sheenColorMap,Re=_&&!!v.sheenRoughnessMap,ge=!!v.specularMap,fe=!!v.specularColorMap,Ne=!!v.specularIntensityMap,ze=F&&!!v.transmissionMap,Xe=F&&!!v.thicknessMap,D=!!v.gradientMap,he=!!v.alphaMap,$=v.alphaTest>0,pe=!!v.alphaHash,be=!!v.extensions,ee=vn;v.toneMapped&&(re===null||re.isXRRenderTarget===!0)&&(ee=i.toneMapping);let Ae={shaderID:ue,shaderType:v.type,shaderName:v.name,vertexShader:ct,fragmentShader:et,defines:v.defines,customVertexShaderID:J,customFragmentShaderID:ce,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:u,batching:Ue,batchingColor:Ue&&O._colorsTexture!==null,instancing:ke,instancingColor:ke&&O.instanceColor!==null,instancingMorph:ke&&O.morphTexture!==null,outputColorSpace:re===null?i.outputColorSpace:re.isXRRenderTarget===!0?re.texture.colorSpace:Qe.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:nt,matcap:He,envMap:Q,envMapMode:Q&&j.mapping,envMapCubeUVHeight:se,aoMap:ie,lightMap:ne,bumpMap:xe,normalMap:me,displacementMap:Be,emissiveMap:Ce,normalMapObjectSpace:me&&v.normalMapType===_u,normalMapTangentSpace:me&&v.normalMapType===Xa,packedNormalMap:me&&v.normalMapType===Xa&&X_(v.normalMap.format),metalnessMap:Ve,roughnessMap:We,anisotropy:L,anisotropyMap:k,clearcoat:ot,clearcoatMap:W,clearcoatNormalMap:oe,clearcoatRoughnessMap:ae,dispersion:je,iridescence:E,iridescenceMap:X,iridescenceThicknessMap:K,sheen:_,sheenColorMap:de,sheenRoughnessMap:Re,specularMap:ge,specularColorMap:fe,specularIntensityMap:Ne,transmission:F,transmissionMap:ze,thicknessMap:Xe,gradientMap:D,opaque:v.transparent===!1&&v.blending===Ai&&v.alphaToCoverage===!1,alphaMap:he,alphaTest:$,alphaHash:pe,combine:v.combine,mapUv:nt&&g(v.map.channel),aoMapUv:ie&&g(v.aoMap.channel),lightMapUv:ne&&g(v.lightMap.channel),bumpMapUv:xe&&g(v.bumpMap.channel),normalMapUv:me&&g(v.normalMap.channel),displacementMapUv:Be&&g(v.displacementMap.channel),emissiveMapUv:Ce&&g(v.emissiveMap.channel),metalnessMapUv:Ve&&g(v.metalnessMap.channel),roughnessMapUv:We&&g(v.roughnessMap.channel),anisotropyMapUv:k&&g(v.anisotropyMap.channel),clearcoatMapUv:W&&g(v.clearcoatMap.channel),clearcoatNormalMapUv:oe&&g(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ae&&g(v.clearcoatRoughnessMap.channel),iridescenceMapUv:X&&g(v.iridescenceMap.channel),iridescenceThicknessMapUv:K&&g(v.iridescenceThicknessMap.channel),sheenColorMapUv:de&&g(v.sheenColorMap.channel),sheenRoughnessMapUv:Re&&g(v.sheenRoughnessMap.channel),specularMapUv:ge&&g(v.specularMap.channel),specularColorMapUv:fe&&g(v.specularColorMap.channel),specularIntensityMapUv:Ne&&g(v.specularIntensityMap.channel),transmissionMapUv:ze&&g(v.transmissionMap.channel),thicknessMapUv:Xe&&g(v.thicknessMap.channel),alphaMapUv:he&&g(v.alphaMap.channel),vertexTangents:!!U.attributes.tangent&&(me||L),vertexNormals:!!U.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!U.attributes.color&&U.attributes.color.itemSize===4,pointsUvs:O.isPoints===!0&&!!U.attributes.uv&&(nt||he),fog:!!Y,useFog:v.fog===!0,fogExp2:!!Y&&Y.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||U.attributes.normal===void 0&&me===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:Ie,skinning:O.isSkinnedMesh===!0,hasPositionAttribute:U.attributes.position!==void 0,morphTargets:U.morphAttributes.position!==void 0,morphNormals:U.morphAttributes.normal!==void 0,morphColors:U.morphAttributes.color!==void 0,morphTargetsCount:Me,morphTextureStride:Je,numDirLights:w.directional.length,numPointLights:w.point.length,numSpotLights:w.spot.length,numSpotLightMaps:w.spotLightMap.length,numRectAreaLights:w.rectArea.length,numHemiLights:w.hemi.length,numDirLightShadows:w.directionalShadowMap.length,numPointLightShadows:w.pointShadowMap.length,numSpotLightShadows:w.spotShadowMap.length,numSpotLightShadowsWithMaps:w.numSpotLightShadowsWithMaps,numLightProbes:w.numLightProbes,numLightProbeGrids:q.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:v.dithering,shadowMapEnabled:i.shadowMap.enabled&&I.length>0,shadowMapType:i.shadowMap.type,toneMapping:ee,decodeVideoTexture:nt&&v.map.isVideoTexture===!0&&Qe.getTransfer(v.map.colorSpace)===it,decodeVideoTextureEmissive:Ce&&v.emissiveMap.isVideoTexture===!0&&Qe.getTransfer(v.emissiveMap.colorSpace)===it,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===ln,flipSided:v.side===qt,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:be&&v.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(be&&v.extensions.multiDraw===!0||Ue)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return Ae.vertexUv1s=l.has(1),Ae.vertexUv2s=l.has(2),Ae.vertexUv3s=l.has(3),l.clear(),Ae}function m(v){let w=[];if(v.shaderID?w.push(v.shaderID):(w.push(v.customVertexShaderID),w.push(v.customFragmentShaderID)),v.defines!==void 0)for(let I in v.defines)w.push(I),w.push(v.defines[I]);return v.isRawShaderMaterial===!1&&(p(w,v),C(w,v),w.push(i.outputColorSpace)),w.push(v.customProgramCacheKey),w.join()}function p(v,w){v.push(w.precision),v.push(w.outputColorSpace),v.push(w.envMapMode),v.push(w.envMapCubeUVHeight),v.push(w.mapUv),v.push(w.alphaMapUv),v.push(w.lightMapUv),v.push(w.aoMapUv),v.push(w.bumpMapUv),v.push(w.normalMapUv),v.push(w.displacementMapUv),v.push(w.emissiveMapUv),v.push(w.metalnessMapUv),v.push(w.roughnessMapUv),v.push(w.anisotropyMapUv),v.push(w.clearcoatMapUv),v.push(w.clearcoatNormalMapUv),v.push(w.clearcoatRoughnessMapUv),v.push(w.iridescenceMapUv),v.push(w.iridescenceThicknessMapUv),v.push(w.sheenColorMapUv),v.push(w.sheenRoughnessMapUv),v.push(w.specularMapUv),v.push(w.specularColorMapUv),v.push(w.specularIntensityMapUv),v.push(w.transmissionMapUv),v.push(w.thicknessMapUv),v.push(w.combine),v.push(w.fogExp2),v.push(w.sizeAttenuation),v.push(w.morphTargetsCount),v.push(w.morphAttributeCount),v.push(w.numDirLights),v.push(w.numPointLights),v.push(w.numSpotLights),v.push(w.numSpotLightMaps),v.push(w.numHemiLights),v.push(w.numRectAreaLights),v.push(w.numDirLightShadows),v.push(w.numPointLightShadows),v.push(w.numSpotLightShadows),v.push(w.numSpotLightShadowsWithMaps),v.push(w.numLightProbes),v.push(w.shadowMapType),v.push(w.toneMapping),v.push(w.numClippingPlanes),v.push(w.numClipIntersection),v.push(w.depthPacking)}function C(v,w){o.disableAll(),w.instancing&&o.enable(0),w.instancingColor&&o.enable(1),w.instancingMorph&&o.enable(2),w.matcap&&o.enable(3),w.envMap&&o.enable(4),w.normalMapObjectSpace&&o.enable(5),w.normalMapTangentSpace&&o.enable(6),w.clearcoat&&o.enable(7),w.iridescence&&o.enable(8),w.alphaTest&&o.enable(9),w.vertexColors&&o.enable(10),w.vertexAlphas&&o.enable(11),w.vertexUv1s&&o.enable(12),w.vertexUv2s&&o.enable(13),w.vertexUv3s&&o.enable(14),w.vertexTangents&&o.enable(15),w.anisotropy&&o.enable(16),w.alphaHash&&o.enable(17),w.batching&&o.enable(18),w.dispersion&&o.enable(19),w.batchingColor&&o.enable(20),w.gradientMap&&o.enable(21),w.packedNormalMap&&o.enable(22),w.vertexNormals&&o.enable(23),v.push(o.mask),o.disableAll(),w.fog&&o.enable(0),w.useFog&&o.enable(1),w.flatShading&&o.enable(2),w.logarithmicDepthBuffer&&o.enable(3),w.reversedDepthBuffer&&o.enable(4),w.skinning&&o.enable(5),w.morphTargets&&o.enable(6),w.morphNormals&&o.enable(7),w.morphColors&&o.enable(8),w.premultipliedAlpha&&o.enable(9),w.shadowMapEnabled&&o.enable(10),w.doubleSided&&o.enable(11),w.flipSided&&o.enable(12),w.useDepthPacking&&o.enable(13),w.dithering&&o.enable(14),w.transmission&&o.enable(15),w.sheen&&o.enable(16),w.opaque&&o.enable(17),w.pointsUvs&&o.enable(18),w.decodeVideoTexture&&o.enable(19),w.decodeVideoTextureEmissive&&o.enable(20),w.alphaToCoverage&&o.enable(21),w.numLightProbeGrids>0&&o.enable(22),w.hasPositionAttribute&&o.enable(23),v.push(o.mask)}function T(v){let w=f[v.type],I;if(w){let P=Nn[w];I=Nu.clone(P.uniforms)}else I=v.uniforms;return I}function x(v,w){let I=h.get(w);return I!==void 0?++I.usedTimes:(I=new G_(i,w,v,s),c.push(I),h.set(w,I)),I}function S(v){if(--v.usedTimes===0){let w=c.indexOf(v);c[w]=c[c.length-1],c.pop(),h.delete(v.cacheKey),v.destroy()}}function M(v){a.remove(v)}function A(){a.dispose()}return{getParameters:y,getProgramCacheKey:m,getUniforms:T,acquireProgram:x,releaseProgram:S,releaseShaderCache:M,programs:c,dispose:A}}function Y_(){let i=new WeakMap;function e(o){return i.has(o)}function t(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function n(o){i.delete(o)}function s(o,a,l){i.get(o)[a]=l}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function Z_(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function ed(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function td(){let i=[],e=0,t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function o(u){let f=0;return u.isInstancedMesh&&(f+=2),u.isSkinnedMesh&&(f+=1),f}function a(u,f,g,y,m,p){let C=i[e];return C===void 0?(C={id:u.id,object:u,geometry:f,material:g,materialVariant:o(u),groupOrder:y,renderOrder:u.renderOrder,z:m,group:p},i[e]=C):(C.id=u.id,C.object=u,C.geometry=f,C.material=g,C.materialVariant=o(u),C.groupOrder=y,C.renderOrder=u.renderOrder,C.z=m,C.group=p),e++,C}function l(u,f,g,y,m,p){let C=a(u,f,g,y,m,p);g.transmission>0?n.push(C):g.transparent===!0?s.push(C):t.push(C)}function c(u,f,g,y,m,p){let C=a(u,f,g,y,m,p);g.transmission>0?n.unshift(C):g.transparent===!0?s.unshift(C):t.unshift(C)}function h(u,f,g){t.length>1&&t.sort(u||Z_),n.length>1&&n.sort(f||ed),s.length>1&&s.sort(f||ed),g&&(t.reverse(),n.reverse(),s.reverse())}function d(){for(let u=e,f=i.length;u<f;u++){let g=i[u];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:t,transmissive:n,transparent:s,init:r,push:l,unshift:c,finish:d,sort:h}}function $_(){let i=new WeakMap;function e(n,s){let r=i.get(n),o;return r===void 0?(o=new td,i.set(n,[o])):s>=r.length?(o=new td,r.push(o)):o=r[s],o}function t(){i=new WeakMap}return{get:e,dispose:t}}function J_(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new R,color:new Ye};break;case"SpotLight":t={position:new R,direction:new R,color:new Ye,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new R,color:new Ye,distance:0,decay:0};break;case"HemisphereLight":t={direction:new R,skyColor:new Ye,groundColor:new Ye};break;case"RectAreaLight":t={color:new Ye,position:new R,halfWidth:new R,halfHeight:new R};break}return i[e.id]=t,t}}}function K_(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new te};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new te};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new te,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}var j_=0;function Q_(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function ex(i){let e=new J_,t=K_(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new R);let s=new R,r=new rt,o=new rt;function a(c){let h=0,d=0,u=0;for(let w=0;w<9;w++)n.probe[w].set(0,0,0);let f=0,g=0,y=0,m=0,p=0,C=0,T=0,x=0,S=0,M=0,A=0;c.sort(Q_);for(let w=0,I=c.length;w<I;w++){let P=c[w],O=P.color,q=P.intensity,Y=P.distance,U=null;if(P.shadow&&P.shadow.map&&(P.shadow.map.texture.format===gi?U=P.shadow.map.texture:U=P.shadow.map.depthTexture||P.shadow.map.texture),P.isAmbientLight)h+=O.r*q,d+=O.g*q,u+=O.b*q;else if(P.isLightProbe){for(let G=0;G<9;G++)n.probe[G].addScaledVector(P.sh.coefficients[G],q);A++}else if(P.isDirectionalLight){let G=e.get(P);if(G.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){let H=P.shadow,j=t.get(P);j.shadowIntensity=H.intensity,j.shadowBias=H.bias,j.shadowNormalBias=H.normalBias,j.shadowRadius=H.radius,j.shadowMapSize=H.mapSize,n.directionalShadow[f]=j,n.directionalShadowMap[f]=U,n.directionalShadowMatrix[f]=P.shadow.matrix,C++}n.directional[f]=G,f++}else if(P.isSpotLight){let G=e.get(P);G.position.setFromMatrixPosition(P.matrixWorld),G.color.copy(O).multiplyScalar(q),G.distance=Y,G.coneCos=Math.cos(P.angle),G.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),G.decay=P.decay,n.spot[y]=G;let H=P.shadow;if(P.map&&(n.spotLightMap[S]=P.map,S++,H.updateMatrices(P),P.castShadow&&M++),n.spotLightMatrix[y]=H.matrix,P.castShadow){let j=t.get(P);j.shadowIntensity=H.intensity,j.shadowBias=H.bias,j.shadowNormalBias=H.normalBias,j.shadowRadius=H.radius,j.shadowMapSize=H.mapSize,n.spotShadow[y]=j,n.spotShadowMap[y]=U,x++}y++}else if(P.isRectAreaLight){let G=e.get(P);G.color.copy(O).multiplyScalar(q),G.halfWidth.set(P.width*.5,0,0),G.halfHeight.set(0,P.height*.5,0),n.rectArea[m]=G,m++}else if(P.isPointLight){let G=e.get(P);if(G.color.copy(P.color).multiplyScalar(P.intensity),G.distance=P.distance,G.decay=P.decay,P.castShadow){let H=P.shadow,j=t.get(P);j.shadowIntensity=H.intensity,j.shadowBias=H.bias,j.shadowNormalBias=H.normalBias,j.shadowRadius=H.radius,j.shadowMapSize=H.mapSize,j.shadowCameraNear=H.camera.near,j.shadowCameraFar=H.camera.far,n.pointShadow[g]=j,n.pointShadowMap[g]=U,n.pointShadowMatrix[g]=P.shadow.matrix,T++}n.point[g]=G,g++}else if(P.isHemisphereLight){let G=e.get(P);G.skyColor.copy(P.color).multiplyScalar(q),G.groundColor.copy(P.groundColor).multiplyScalar(q),n.hemi[p]=G,p++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=_e.LTC_FLOAT_1,n.rectAreaLTC2=_e.LTC_FLOAT_2):(n.rectAreaLTC1=_e.LTC_HALF_1,n.rectAreaLTC2=_e.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=u;let v=n.hash;(v.directionalLength!==f||v.pointLength!==g||v.spotLength!==y||v.rectAreaLength!==m||v.hemiLength!==p||v.numDirectionalShadows!==C||v.numPointShadows!==T||v.numSpotShadows!==x||v.numSpotMaps!==S||v.numLightProbes!==A)&&(n.directional.length=f,n.spot.length=y,n.rectArea.length=m,n.point.length=g,n.hemi.length=p,n.directionalShadow.length=C,n.directionalShadowMap.length=C,n.pointShadow.length=T,n.pointShadowMap.length=T,n.spotShadow.length=x,n.spotShadowMap.length=x,n.directionalShadowMatrix.length=C,n.pointShadowMatrix.length=T,n.spotLightMatrix.length=x+S-M,n.spotLightMap.length=S,n.numSpotLightShadowsWithMaps=M,n.numLightProbes=A,v.directionalLength=f,v.pointLength=g,v.spotLength=y,v.rectAreaLength=m,v.hemiLength=p,v.numDirectionalShadows=C,v.numPointShadows=T,v.numSpotShadows=x,v.numSpotMaps=S,v.numLightProbes=A,n.version=j_++)}function l(c,h){let d=0,u=0,f=0,g=0,y=0,m=h.matrixWorldInverse;for(let p=0,C=c.length;p<C;p++){let T=c[p];if(T.isDirectionalLight){let x=n.directional[d];x.direction.setFromMatrixPosition(T.matrixWorld),s.setFromMatrixPosition(T.target.matrixWorld),x.direction.sub(s),x.direction.transformDirection(m),d++}else if(T.isSpotLight){let x=n.spot[f];x.position.setFromMatrixPosition(T.matrixWorld),x.position.applyMatrix4(m),x.direction.setFromMatrixPosition(T.matrixWorld),s.setFromMatrixPosition(T.target.matrixWorld),x.direction.sub(s),x.direction.transformDirection(m),f++}else if(T.isRectAreaLight){let x=n.rectArea[g];x.position.setFromMatrixPosition(T.matrixWorld),x.position.applyMatrix4(m),o.identity(),r.copy(T.matrixWorld),r.premultiply(m),o.extractRotation(r),x.halfWidth.set(T.width*.5,0,0),x.halfHeight.set(0,T.height*.5,0),x.halfWidth.applyMatrix4(o),x.halfHeight.applyMatrix4(o),g++}else if(T.isPointLight){let x=n.point[u];x.position.setFromMatrixPosition(T.matrixWorld),x.position.applyMatrix4(m),u++}else if(T.isHemisphereLight){let x=n.hemi[y];x.direction.setFromMatrixPosition(T.matrixWorld),x.direction.transformDirection(m),y++}}}return{setup:a,setupView:l,state:n}}function nd(i){let e=new ex(i),t=[],n=[],s=[];function r(u){d.camera=u,t.length=0,n.length=0,s.length=0}function o(u){t.push(u)}function a(u){n.push(u)}function l(u){s.push(u)}function c(){e.setup(t)}function h(u){e.setupView(t,u)}let d={lightsArray:t,shadowsArray:n,lightProbeGridArray:s,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:d,setupLights:c,setupLightsView:h,pushLight:o,pushShadow:a,pushLightProbeGrid:l}}function tx(i){let e=new WeakMap;function t(s,r=0){let o=e.get(s),a;return o===void 0?(a=new nd(i),e.set(s,[a])):r>=o.length?(a=new nd(i),o.push(a)):a=o[r],a}function n(){e=new WeakMap}return{get:t,dispose:n}}var nx=`void main() {
|
|
4063
4063
|
gl_Position = vec4( position, 1.0 );
|
|
4064
|
-
}`,
|
|
4064
|
+
}`,ix=`uniform sampler2D shadow_pass;
|
|
4065
4065
|
uniform vec2 resolution;
|
|
4066
4066
|
uniform float radius;
|
|
4067
4067
|
void main() {
|
|
@@ -4086,12 +4086,12 @@ void main() {
|
|
|
4086
4086
|
squared_mean = squared_mean / samples;
|
|
4087
4087
|
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
|
|
4088
4088
|
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
|
|
4089
|
-
}`,ex=[new R(1,0,0),new R(-1,0,0),new R(0,1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1)],tx=[new R(0,-1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1),new R(0,-1,0),new R(0,-1,0)],td=new rt,Cr=new R,Cc=new R;function nx(i,e,t){let n=new us,s=new ee,r=new ee,a=new gt,o=new Xa,l=new qa,c={},h=t.maxTextureSize,d={[Hn]:qt,[qt]:Hn,[ln]:ln},u=new tn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ee},radius:{value:4}},vertexShader:j_,fragmentShader:Q_}),f=u.clone();f.defines.HORIZONTAL_PASS=1;let g=new mt;g.setAttribute("position",new Tt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let b=new wt(g,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=xr;let p=this.type;this.render=function(M,A,y){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||M.length===0)return;this.type===qh&&(De("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=xr);let T=i.getRenderTarget(),I=i.getActiveCubeFace(),P=i.getActiveMipmapLevel(),F=i.state;F.setBlending(In),F.buffers.depth.getReversed()===!0?F.buffers.color.setClear(0,0,0,0):F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);let G=p!==this.type;G&&A.traverse(function(X){X.material&&(Array.isArray(X.material)?X.material.forEach(O=>O.needsUpdate=!0):X.material.needsUpdate=!0)});for(let X=0,O=M.length;X<O;X++){let W=M[X],H=W.shadow;if(H===void 0){De("WebGLShadowMap:",W,"has no shadow.");continue}if(H.autoUpdate===!1&&H.needsUpdate===!1)continue;s.copy(H.mapSize);let K=H.getFrameExtents();s.multiply(K),r.copy(H.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/K.x),s.x=r.x*K.x,H.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/K.y),s.y=r.y*K.y,H.mapSize.y=r.y));let ie=i.state.buffers.depth.getReversed();if(H.camera._reversedDepth=ie,H.map===null||G===!0){if(H.map!==null&&(H.map.depthTexture!==null&&(H.map.depthTexture.dispose(),H.map.depthTexture=null),H.map.dispose()),this.type===xs){if(W.isPointLight){De("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}H.map=new Qt(s.x,s.y,{format:mi,type:Ln,minFilter:Ft,magFilter:Ft,generateMipmaps:!1}),H.map.texture.name=W.name+".shadowMap",H.map.depthTexture=new Wn(s.x,s.y,bn),H.map.depthTexture.name=W.name+".shadowMapDepth",H.map.depthTexture.format=Rn,H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=Dt,H.map.depthTexture.magFilter=Dt}else W.isPointLight?(H.map=new Ko(s.x),H.map.depthTexture=new Oa(s.x,vn)):(H.map=new Qt(s.x,s.y),H.map.depthTexture=new Wn(s.x,s.y,vn)),H.map.depthTexture.name=W.name+".shadowMap",H.map.depthTexture.format=Rn,this.type===xr?(H.map.depthTexture.compareFunction=ie?Yo:qo,H.map.depthTexture.minFilter=Ft,H.map.depthTexture.magFilter=Ft):(H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=Dt,H.map.depthTexture.magFilter=Dt);H.camera.updateProjectionMatrix()}let ue=H.map.isWebGLCubeRenderTarget?6:1;for(let le=0;le<ue;le++){if(H.map.isWebGLCubeRenderTarget)i.setRenderTarget(H.map,le),i.clear();else{le===0&&(i.setRenderTarget(H.map),i.clear());let Me=H.getViewport(le);a.set(r.x*Me.x,r.y*Me.y,r.x*Me.z,r.y*Me.w),F.viewport(a)}if(W.isPointLight){let Me=H.camera,$e=H.matrix,ct=W.distance||Me.far;ct!==Me.far&&(Me.far=ct,Me.updateProjectionMatrix()),Cr.setFromMatrixPosition(W.matrixWorld),Me.position.copy(Cr),Cc.copy(Me.position),Cc.add(ex[le]),Me.up.copy(tx[le]),Me.lookAt(Cc),Me.updateMatrixWorld(),$e.makeTranslation(-Cr.x,-Cr.y,-Cr.z),td.multiplyMatrices(Me.projectionMatrix,Me.matrixWorldInverse),H._frustum.setFromProjectionMatrix(td,Me.coordinateSystem,Me.reversedDepth)}else H.updateMatrices(W);n=H.getFrustum(),_(A,y,H.camera,W,this.type)}H.isPointLightShadow!==!0&&this.type===xs&&C(H,y),H.needsUpdate=!1}p=this.type,m.needsUpdate=!1,i.setRenderTarget(T,I,P)};function C(M,A){let y=e.update(b);u.defines.VSM_SAMPLES!==M.blurSamples&&(u.defines.VSM_SAMPLES=M.blurSamples,f.defines.VSM_SAMPLES=M.blurSamples,u.needsUpdate=!0,f.needsUpdate=!0),M.mapPass===null&&(M.mapPass=new Qt(s.x,s.y,{format:mi,type:Ln})),u.uniforms.shadow_pass.value=M.map.depthTexture,u.uniforms.resolution.value=M.mapSize,u.uniforms.radius.value=M.radius,i.setRenderTarget(M.mapPass),i.clear(),i.renderBufferDirect(A,null,y,u,b,null),f.uniforms.shadow_pass.value=M.mapPass.texture,f.uniforms.resolution.value=M.mapSize,f.uniforms.radius.value=M.radius,i.setRenderTarget(M.map),i.clear(),i.renderBufferDirect(A,null,y,f,b,null)}function w(M,A,y,T){let I=null,P=y.isPointLight===!0?M.customDistanceMaterial:M.customDepthMaterial;if(P!==void 0)I=P;else if(I=y.isPointLight===!0?l:o,i.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let F=I.uuid,G=A.uuid,X=c[F];X===void 0&&(X={},c[F]=X);let O=X[G];O===void 0&&(O=I.clone(),X[G]=O,A.addEventListener("dispose",S)),I=O}if(I.visible=A.visible,I.wireframe=A.wireframe,T===xs?I.side=A.shadowSide!==null?A.shadowSide:A.side:I.side=A.shadowSide!==null?A.shadowSide:d[A.side],I.alphaMap=A.alphaMap,I.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,I.map=A.map,I.clipShadows=A.clipShadows,I.clippingPlanes=A.clippingPlanes,I.clipIntersection=A.clipIntersection,I.displacementMap=A.displacementMap,I.displacementScale=A.displacementScale,I.displacementBias=A.displacementBias,I.wireframeLinewidth=A.wireframeLinewidth,I.linewidth=A.linewidth,y.isPointLight===!0&&I.isMeshDistanceMaterial===!0){let F=i.properties.get(I);F.light=y}return I}function _(M,A,y,T,I){if(M.visible===!1)return;if(M.layers.test(A.layers)&&(M.isMesh||M.isLine||M.isPoints)&&(M.castShadow||M.receiveShadow&&I===xs)&&(!M.frustumCulled||n.intersectsObject(M))){M.modelViewMatrix.multiplyMatrices(y.matrixWorldInverse,M.matrixWorld);let G=e.update(M),X=M.material;if(Array.isArray(X)){let O=G.groups;for(let W=0,H=O.length;W<H;W++){let K=O[W],ie=X[K.materialIndex];if(ie&&ie.visible){let ue=w(M,ie,T,I);M.onBeforeShadow(i,M,A,y,G,ue,K),i.renderBufferDirect(y,null,G,ue,M,K),M.onAfterShadow(i,M,A,y,G,ue,K)}}}else if(X.visible){let O=w(M,X,T,I);M.onBeforeShadow(i,M,A,y,G,O,null),i.renderBufferDirect(y,null,G,O,M,null),M.onAfterShadow(i,M,A,y,G,O,null)}}let F=M.children;for(let G=0,X=F.length;G<X;G++)_(F[G],A,y,T,I)}function S(M){M.target.removeEventListener("dispose",S);for(let y in c){let T=c[y],I=M.target.uuid;I in T&&(T[I].dispose(),delete T[I])}}}function ix(i,e){function t(){let D=!1,he=new gt,Z=null,pe=new gt(0,0,0,0);return{setMask:function(be){Z!==be&&!D&&(i.colorMask(be,be,be,be),Z=be)},setLocked:function(be){D=be},setClear:function(be,Q,Ae,Te,yt){yt===!0&&(be*=Te,Q*=Te,Ae*=Te),he.set(be,Q,Ae,Te),pe.equals(he)===!1&&(i.clearColor(be,Q,Ae,Te),pe.copy(he))},reset:function(){D=!1,Z=null,pe.set(-1,0,0,0)}}}function n(){let D=!1,he=!1,Z=null,pe=null,be=null;return{setReversed:function(Q){if(he!==Q){let Ae=e.get("EXT_clip_control");Q?Ae.clipControlEXT(Ae.LOWER_LEFT_EXT,Ae.ZERO_TO_ONE_EXT):Ae.clipControlEXT(Ae.LOWER_LEFT_EXT,Ae.NEGATIVE_ONE_TO_ONE_EXT),he=Q;let Te=be;be=null,this.setClear(Te)}},getReversed:function(){return he},setTest:function(Q){Q?re(i.DEPTH_TEST):Ie(i.DEPTH_TEST)},setMask:function(Q){Z!==Q&&!D&&(i.depthMask(Q),Z=Q)},setFunc:function(Q){if(he&&(Q=Tu[Q]),pe!==Q){switch(Q){case xa:i.depthFunc(i.NEVER);break;case ya:i.depthFunc(i.ALWAYS);break;case va:i.depthFunc(i.LESS);break;case Ai:i.depthFunc(i.LEQUAL);break;case ba:i.depthFunc(i.EQUAL);break;case Ma:i.depthFunc(i.GEQUAL);break;case Sa:i.depthFunc(i.GREATER);break;case Ea:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}pe=Q}},setLocked:function(Q){D=Q},setClear:function(Q){be!==Q&&(be=Q,he&&(Q=1-Q),i.clearDepth(Q))},reset:function(){D=!1,Z=null,pe=null,be=null,he=!1}}}function s(){let D=!1,he=null,Z=null,pe=null,be=null,Q=null,Ae=null,Te=null,yt=null;return{setTest:function(dt){D||(dt?re(i.STENCIL_TEST):Ie(i.STENCIL_TEST))},setMask:function(dt){he!==dt&&!D&&(i.stencilMask(dt),he=dt)},setFunc:function(dt,Mn,Sn){(Z!==dt||pe!==Mn||be!==Sn)&&(i.stencilFunc(dt,Mn,Sn),Z=dt,pe=Mn,be=Sn)},setOp:function(dt,Mn,Sn){(Q!==dt||Ae!==Mn||Te!==Sn)&&(i.stencilOp(dt,Mn,Sn),Q=dt,Ae=Mn,Te=Sn)},setLocked:function(dt){D=dt},setClear:function(dt){yt!==dt&&(i.clearStencil(dt),yt=dt)},reset:function(){D=!1,he=null,Z=null,pe=null,be=null,Q=null,Ae=null,Te=null,yt=null}}}let r=new t,a=new n,o=new s,l=new WeakMap,c=new WeakMap,h={},d={},u={},f=new WeakMap,g=[],b=null,m=!1,p=null,C=null,w=null,_=null,S=null,M=null,A=null,y=new qe(0,0,0),T=0,I=!1,P=null,F=null,G=null,X=null,O=null,W=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),H=!1,K=0,ie=i.getParameter(i.VERSION);ie.indexOf("WebGL")!==-1?(K=parseFloat(/^WebGL (\d)/.exec(ie)[1]),H=K>=1):ie.indexOf("OpenGL ES")!==-1&&(K=parseFloat(/^OpenGL ES (\d)/.exec(ie)[1]),H=K>=2);let ue=null,le={},Me=i.getParameter(i.SCISSOR_BOX),$e=i.getParameter(i.VIEWPORT),ct=new gt().fromArray(Me),Qe=new gt().fromArray($e);function $(D,he,Z,pe){let be=new Uint8Array(4),Q=i.createTexture();i.bindTexture(D,Q),i.texParameteri(D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(D,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Ae=0;Ae<Z;Ae++)D===i.TEXTURE_3D||D===i.TEXTURE_2D_ARRAY?i.texImage3D(he,0,i.RGBA,1,1,pe,0,i.RGBA,i.UNSIGNED_BYTE,be):i.texImage2D(he+Ae,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,be);return Q}let ce={};ce[i.TEXTURE_2D]=$(i.TEXTURE_2D,i.TEXTURE_2D,1),ce[i.TEXTURE_CUBE_MAP]=$(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),ce[i.TEXTURE_2D_ARRAY]=$(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),ce[i.TEXTURE_3D]=$(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),re(i.DEPTH_TEST),a.setFunc(Ai),xe(!1),me($l),re(i.CULL_FACE),ne(In);function re(D){h[D]!==!0&&(i.enable(D),h[D]=!0)}function Ie(D){h[D]!==!1&&(i.disable(D),h[D]=!1)}function ze(D,he){return u[D]!==he?(i.bindFramebuffer(D,he),u[D]=he,D===i.DRAW_FRAMEBUFFER&&(u[i.FRAMEBUFFER]=he),D===i.FRAMEBUFFER&&(u[i.DRAW_FRAMEBUFFER]=he),!0):!1}function Ue(D,he){let Z=g,pe=!1;if(D){Z=f.get(he),Z===void 0&&(Z=[],f.set(he,Z));let be=D.textures;if(Z.length!==be.length||Z[0]!==i.COLOR_ATTACHMENT0){for(let Q=0,Ae=be.length;Q<Ae;Q++)Z[Q]=i.COLOR_ATTACHMENT0+Q;Z.length=be.length,pe=!0}}else Z[0]!==i.BACK&&(Z[0]=i.BACK,pe=!0);pe&&i.drawBuffers(Z)}function nt(D){return b!==D?(i.useProgram(D),b=D,!0):!1}let Ve={[ti]:i.FUNC_ADD,[Zh]:i.FUNC_SUBTRACT,[$h]:i.FUNC_REVERSE_SUBTRACT};Ve[Jh]=i.MIN,Ve[Kh]=i.MAX;let j={[jh]:i.ZERO,[Qh]:i.ONE,[eu]:i.SRC_COLOR,[ga]:i.SRC_ALPHA,[au]:i.SRC_ALPHA_SATURATE,[su]:i.DST_COLOR,[nu]:i.DST_ALPHA,[tu]:i.ONE_MINUS_SRC_COLOR,[_a]:i.ONE_MINUS_SRC_ALPHA,[ru]:i.ONE_MINUS_DST_COLOR,[iu]:i.ONE_MINUS_DST_ALPHA,[ou]:i.CONSTANT_COLOR,[lu]:i.ONE_MINUS_CONSTANT_COLOR,[cu]:i.CONSTANT_ALPHA,[hu]:i.ONE_MINUS_CONSTANT_ALPHA};function ne(D,he,Z,pe,be,Q,Ae,Te,yt,dt){if(D===In){m===!0&&(Ie(i.BLEND),m=!1);return}if(m===!1&&(re(i.BLEND),m=!0),D!==Yh){if(D!==p||dt!==I){if((C!==ti||S!==ti)&&(i.blendEquation(i.FUNC_ADD),C=ti,S=ti),dt)switch(D){case wi:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Jl:i.blendFunc(i.ONE,i.ONE);break;case Kl:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case jl:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Fe("WebGLState: Invalid blending: ",D);break}else switch(D){case wi:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Jl:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case Kl:Fe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case jl:Fe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Fe("WebGLState: Invalid blending: ",D);break}w=null,_=null,M=null,A=null,y.set(0,0,0),T=0,p=D,I=dt}return}be=be||he,Q=Q||Z,Ae=Ae||pe,(he!==C||be!==S)&&(i.blendEquationSeparate(Ve[he],Ve[be]),C=he,S=be),(Z!==w||pe!==_||Q!==M||Ae!==A)&&(i.blendFuncSeparate(j[Z],j[pe],j[Q],j[Ae]),w=Z,_=pe,M=Q,A=Ae),(Te.equals(y)===!1||yt!==T)&&(i.blendColor(Te.r,Te.g,Te.b,yt),y.copy(Te),T=yt),p=D,I=!1}function te(D,he){D.side===ln?Ie(i.CULL_FACE):re(i.CULL_FACE);let Z=D.side===qt;he&&(Z=!Z),xe(Z),D.blending===wi&&D.transparent===!1?ne(In):ne(D.blending,D.blendEquation,D.blendSrc,D.blendDst,D.blendEquationAlpha,D.blendSrcAlpha,D.blendDstAlpha,D.blendColor,D.blendAlpha,D.premultipliedAlpha),a.setFunc(D.depthFunc),a.setTest(D.depthTest),a.setMask(D.depthWrite),r.setMask(D.colorWrite);let pe=D.stencilWrite;o.setTest(pe),pe&&(o.setMask(D.stencilWriteMask),o.setFunc(D.stencilFunc,D.stencilRef,D.stencilFuncMask),o.setOp(D.stencilFail,D.stencilZFail,D.stencilZPass)),Ce(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),D.alphaToCoverage===!0?re(i.SAMPLE_ALPHA_TO_COVERAGE):Ie(i.SAMPLE_ALPHA_TO_COVERAGE)}function xe(D){P!==D&&(D?i.frontFace(i.CW):i.frontFace(i.CCW),P=D)}function me(D){D!==Wh?(re(i.CULL_FACE),D!==F&&(D===$l?i.cullFace(i.BACK):D===Xh?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Ie(i.CULL_FACE),F=D}function Oe(D){D!==G&&(H&&i.lineWidth(D),G=D)}function Ce(D,he,Z){D?(re(i.POLYGON_OFFSET_FILL),(X!==he||O!==Z)&&(X=he,O=Z,a.getReversed()&&(he=-he),i.polygonOffset(he,Z))):Ie(i.POLYGON_OFFSET_FILL)}function ke(D){D?re(i.SCISSOR_TEST):Ie(i.SCISSOR_TEST)}function Ge(D){D===void 0&&(D=i.TEXTURE0+W-1),ue!==D&&(i.activeTexture(D),ue=D)}function L(D,he,Z){Z===void 0&&(ue===null?Z=i.TEXTURE0+W-1:Z=ue);let pe=le[Z];pe===void 0&&(pe={type:void 0,texture:void 0},le[Z]=pe),(pe.type!==D||pe.texture!==he)&&(ue!==Z&&(i.activeTexture(Z),ue=Z),i.bindTexture(D,he||ce[D]),pe.type=D,pe.texture=he)}function at(){let D=le[ue];D!==void 0&&D.type!==void 0&&(i.bindTexture(D.type,null),D.type=void 0,D.texture=void 0)}function Ke(){try{i.compressedTexImage2D(...arguments)}catch(D){Fe("WebGLState:",D)}}function E(){try{i.compressedTexImage3D(...arguments)}catch(D){Fe("WebGLState:",D)}}function x(){try{i.texSubImage2D(...arguments)}catch(D){Fe("WebGLState:",D)}}function U(){try{i.texSubImage3D(...arguments)}catch(D){Fe("WebGLState:",D)}}function k(){try{i.compressedTexSubImage2D(...arguments)}catch(D){Fe("WebGLState:",D)}}function q(){try{i.compressedTexSubImage3D(...arguments)}catch(D){Fe("WebGLState:",D)}}function ae(){try{i.texStorage2D(...arguments)}catch(D){Fe("WebGLState:",D)}}function oe(){try{i.texStorage3D(...arguments)}catch(D){Fe("WebGLState:",D)}}function Y(){try{i.texImage2D(...arguments)}catch(D){Fe("WebGLState:",D)}}function J(){try{i.texImage3D(...arguments)}catch(D){Fe("WebGLState:",D)}}function de(D){return d[D]!==void 0?d[D]:i.getParameter(D)}function Re(D,he){d[D]!==he&&(i.pixelStorei(D,he),d[D]=he)}function ge(D){ct.equals(D)===!1&&(i.scissor(D.x,D.y,D.z,D.w),ct.copy(D))}function fe(D){Qe.equals(D)===!1&&(i.viewport(D.x,D.y,D.z,D.w),Qe.copy(D))}function Ne(D,he){let Z=c.get(he);Z===void 0&&(Z=new WeakMap,c.set(he,Z));let pe=Z.get(D);pe===void 0&&(pe=i.getUniformBlockIndex(he,D.name),Z.set(D,pe))}function Be(D,he){let pe=c.get(he).get(D);l.get(he)!==pe&&(i.uniformBlockBinding(he,pe,D.__bindingPointIndex),l.set(he,pe))}function We(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),i.pixelStorei(i.PACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),i.pixelStorei(i.PACK_ROW_LENGTH,0),i.pixelStorei(i.PACK_SKIP_PIXELS,0),i.pixelStorei(i.PACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_ROW_LENGTH,0),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,0),i.pixelStorei(i.UNPACK_SKIP_PIXELS,0),i.pixelStorei(i.UNPACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_SKIP_IMAGES,0),h={},d={},ue=null,le={},u={},f=new WeakMap,g=[],b=null,m=!1,p=null,C=null,w=null,_=null,S=null,M=null,A=null,y=new qe(0,0,0),T=0,I=!1,P=null,F=null,G=null,X=null,O=null,ct.set(0,0,i.canvas.width,i.canvas.height),Qe.set(0,0,i.canvas.width,i.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:re,disable:Ie,bindFramebuffer:ze,drawBuffers:Ue,useProgram:nt,setBlending:ne,setMaterial:te,setFlipSided:xe,setCullFace:me,setLineWidth:Oe,setPolygonOffset:Ce,setScissorTest:ke,activeTexture:Ge,bindTexture:L,unbindTexture:at,compressedTexImage2D:Ke,compressedTexImage3D:E,texImage2D:Y,texImage3D:J,pixelStorei:Re,getParameter:de,updateUBOMapping:Ne,uniformBlockBinding:Be,texStorage2D:ae,texStorage3D:oe,texSubImage2D:x,texSubImage3D:U,compressedTexSubImage2D:k,compressedTexSubImage3D:q,scissor:ge,viewport:fe,reset:We}}function sx(i,e,t,n,s,r,a){let o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new ee,h=new WeakMap,d=new Set,u,f=new WeakMap,g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function b(E,x){return g?new OffscreenCanvas(E,x):Ys("canvas")}function m(E,x,U){let k=1,q=Ke(E);if((q.width>U||q.height>U)&&(k=U/Math.max(q.width,q.height)),k<1)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){let ae=Math.floor(k*q.width),oe=Math.floor(k*q.height);u===void 0&&(u=b(ae,oe));let Y=x?b(ae,oe):u;return Y.width=ae,Y.height=oe,Y.getContext("2d").drawImage(E,0,0,ae,oe),De("WebGLRenderer: Texture has been resized from ("+q.width+"x"+q.height+") to ("+ae+"x"+oe+")."),Y}else return"data"in E&&De("WebGLRenderer: Image in DataTexture is too big ("+q.width+"x"+q.height+")."),E;return E}function p(E){return E.generateMipmaps}function C(E){i.generateMipmap(E)}function w(E){return E.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:E.isWebGL3DRenderTarget?i.TEXTURE_3D:E.isWebGLArrayRenderTarget||E.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function _(E,x,U,k,q,ae=!1){if(E!==null){if(i[E]!==void 0)return i[E];De("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let oe;k&&(oe=e.get("EXT_texture_norm16"),oe||De("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Y=x;if(x===i.RED&&(U===i.FLOAT&&(Y=i.R32F),U===i.HALF_FLOAT&&(Y=i.R16F),U===i.UNSIGNED_BYTE&&(Y=i.R8),U===i.UNSIGNED_SHORT&&oe&&(Y=oe.R16_EXT),U===i.SHORT&&oe&&(Y=oe.R16_SNORM_EXT)),x===i.RED_INTEGER&&(U===i.UNSIGNED_BYTE&&(Y=i.R8UI),U===i.UNSIGNED_SHORT&&(Y=i.R16UI),U===i.UNSIGNED_INT&&(Y=i.R32UI),U===i.BYTE&&(Y=i.R8I),U===i.SHORT&&(Y=i.R16I),U===i.INT&&(Y=i.R32I)),x===i.RG&&(U===i.FLOAT&&(Y=i.RG32F),U===i.HALF_FLOAT&&(Y=i.RG16F),U===i.UNSIGNED_BYTE&&(Y=i.RG8),U===i.UNSIGNED_SHORT&&oe&&(Y=oe.RG16_EXT),U===i.SHORT&&oe&&(Y=oe.RG16_SNORM_EXT)),x===i.RG_INTEGER&&(U===i.UNSIGNED_BYTE&&(Y=i.RG8UI),U===i.UNSIGNED_SHORT&&(Y=i.RG16UI),U===i.UNSIGNED_INT&&(Y=i.RG32UI),U===i.BYTE&&(Y=i.RG8I),U===i.SHORT&&(Y=i.RG16I),U===i.INT&&(Y=i.RG32I)),x===i.RGB_INTEGER&&(U===i.UNSIGNED_BYTE&&(Y=i.RGB8UI),U===i.UNSIGNED_SHORT&&(Y=i.RGB16UI),U===i.UNSIGNED_INT&&(Y=i.RGB32UI),U===i.BYTE&&(Y=i.RGB8I),U===i.SHORT&&(Y=i.RGB16I),U===i.INT&&(Y=i.RGB32I)),x===i.RGBA_INTEGER&&(U===i.UNSIGNED_BYTE&&(Y=i.RGBA8UI),U===i.UNSIGNED_SHORT&&(Y=i.RGBA16UI),U===i.UNSIGNED_INT&&(Y=i.RGBA32UI),U===i.BYTE&&(Y=i.RGBA8I),U===i.SHORT&&(Y=i.RGBA16I),U===i.INT&&(Y=i.RGBA32I)),x===i.RGB&&(U===i.UNSIGNED_SHORT&&oe&&(Y=oe.RGB16_EXT),U===i.SHORT&&oe&&(Y=oe.RGB16_SNORM_EXT),U===i.UNSIGNED_INT_5_9_9_9_REV&&(Y=i.RGB9_E5),U===i.UNSIGNED_INT_10F_11F_11F_REV&&(Y=i.R11F_G11F_B10F)),x===i.RGBA){let J=ae?qs:je.getTransfer(q);U===i.FLOAT&&(Y=i.RGBA32F),U===i.HALF_FLOAT&&(Y=i.RGBA16F),U===i.UNSIGNED_BYTE&&(Y=J===it?i.SRGB8_ALPHA8:i.RGBA8),U===i.UNSIGNED_SHORT&&oe&&(Y=oe.RGBA16_EXT),U===i.SHORT&&oe&&(Y=oe.RGBA16_SNORM_EXT),U===i.UNSIGNED_SHORT_4_4_4_4&&(Y=i.RGBA4),U===i.UNSIGNED_SHORT_5_5_5_1&&(Y=i.RGB5_A1)}return(Y===i.R16F||Y===i.R32F||Y===i.RG16F||Y===i.RG32F||Y===i.RGBA16F||Y===i.RGBA32F)&&e.get("EXT_color_buffer_float"),Y}function S(E,x){let U;return E?x===null||x===vn||x===vs?U=i.DEPTH24_STENCIL8:x===bn?U=i.DEPTH32F_STENCIL8:x===ys&&(U=i.DEPTH24_STENCIL8,De("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===vn||x===vs?U=i.DEPTH_COMPONENT24:x===bn?U=i.DEPTH_COMPONENT32F:x===ys&&(U=i.DEPTH_COMPONENT16),U}function M(E,x){return p(E)===!0||E.isFramebufferTexture&&E.minFilter!==Dt&&E.minFilter!==Ft?Math.log2(Math.max(x.width,x.height))+1:E.mipmaps!==void 0&&E.mipmaps.length>0?E.mipmaps.length:E.isCompressedTexture&&Array.isArray(E.image)?x.mipmaps.length:1}function A(E){let x=E.target;x.removeEventListener("dispose",A),T(x),x.isVideoTexture&&h.delete(x),x.isHTMLTexture&&d.delete(x)}function y(E){let x=E.target;x.removeEventListener("dispose",y),P(x)}function T(E){let x=n.get(E);if(x.__webglInit===void 0)return;let U=E.source,k=f.get(U);if(k){let q=k[x.__cacheKey];q.usedTimes--,q.usedTimes===0&&I(E),Object.keys(k).length===0&&f.delete(U)}n.remove(E)}function I(E){let x=n.get(E);i.deleteTexture(x.__webglTexture);let U=E.source,k=f.get(U);delete k[x.__cacheKey],a.memory.textures--}function P(E){let x=n.get(E);if(E.depthTexture&&(E.depthTexture.dispose(),n.remove(E.depthTexture)),E.isWebGLCubeRenderTarget)for(let k=0;k<6;k++){if(Array.isArray(x.__webglFramebuffer[k]))for(let q=0;q<x.__webglFramebuffer[k].length;q++)i.deleteFramebuffer(x.__webglFramebuffer[k][q]);else i.deleteFramebuffer(x.__webglFramebuffer[k]);x.__webglDepthbuffer&&i.deleteRenderbuffer(x.__webglDepthbuffer[k])}else{if(Array.isArray(x.__webglFramebuffer))for(let k=0;k<x.__webglFramebuffer.length;k++)i.deleteFramebuffer(x.__webglFramebuffer[k]);else i.deleteFramebuffer(x.__webglFramebuffer);if(x.__webglDepthbuffer&&i.deleteRenderbuffer(x.__webglDepthbuffer),x.__webglMultisampledFramebuffer&&i.deleteFramebuffer(x.__webglMultisampledFramebuffer),x.__webglColorRenderbuffer)for(let k=0;k<x.__webglColorRenderbuffer.length;k++)x.__webglColorRenderbuffer[k]&&i.deleteRenderbuffer(x.__webglColorRenderbuffer[k]);x.__webglDepthRenderbuffer&&i.deleteRenderbuffer(x.__webglDepthRenderbuffer)}let U=E.textures;for(let k=0,q=U.length;k<q;k++){let ae=n.get(U[k]);ae.__webglTexture&&(i.deleteTexture(ae.__webglTexture),a.memory.textures--),n.remove(U[k])}n.remove(E)}let F=0;function G(){F=0}function X(){return F}function O(E){F=E}function W(){let E=F;return E>=s.maxTextures&&De("WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+s.maxTextures),F+=1,E}function H(E){let x=[];return x.push(E.wrapS),x.push(E.wrapT),x.push(E.wrapR||0),x.push(E.magFilter),x.push(E.minFilter),x.push(E.anisotropy),x.push(E.internalFormat),x.push(E.format),x.push(E.type),x.push(E.generateMipmaps),x.push(E.premultiplyAlpha),x.push(E.flipY),x.push(E.unpackAlignment),x.push(E.colorSpace),x.join()}function K(E,x){let U=n.get(E);if(E.isVideoTexture&&L(E),E.isRenderTargetTexture===!1&&E.isExternalTexture!==!0&&E.version>0&&U.__version!==E.version){let k=E.image;if(k===null)De("WebGLRenderer: Texture marked for update but no image data found.");else if(k.complete===!1)De("WebGLRenderer: Texture marked for update but image is incomplete");else{Ie(U,E,x);return}}else E.isExternalTexture&&(U.__webglTexture=E.sourceTexture?E.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,U.__webglTexture,i.TEXTURE0+x)}function ie(E,x){let U=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&U.__version!==E.version){Ie(U,E,x);return}else E.isExternalTexture&&(U.__webglTexture=E.sourceTexture?E.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,U.__webglTexture,i.TEXTURE0+x)}function ue(E,x){let U=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&U.__version!==E.version){Ie(U,E,x);return}t.bindTexture(i.TEXTURE_3D,U.__webglTexture,i.TEXTURE0+x)}function le(E,x){let U=n.get(E);if(E.isCubeDepthTexture!==!0&&E.version>0&&U.__version!==E.version){ze(U,E,x);return}t.bindTexture(i.TEXTURE_CUBE_MAP,U.__webglTexture,i.TEXTURE0+x)}let Me={[Ta]:i.REPEAT,[An]:i.CLAMP_TO_EDGE,[wa]:i.MIRRORED_REPEAT},$e={[Dt]:i.NEAREST,[fu]:i.NEAREST_MIPMAP_NEAREST,[vr]:i.NEAREST_MIPMAP_LINEAR,[Ft]:i.LINEAR,[oo]:i.LINEAR_MIPMAP_NEAREST,[fi]:i.LINEAR_MIPMAP_LINEAR},ct={[gu]:i.NEVER,[bu]:i.ALWAYS,[_u]:i.LESS,[qo]:i.LEQUAL,[xu]:i.EQUAL,[Yo]:i.GEQUAL,[yu]:i.GREATER,[vu]:i.NOTEQUAL};function Qe(E,x){if(x.type===bn&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===Ft||x.magFilter===oo||x.magFilter===vr||x.magFilter===fi||x.minFilter===Ft||x.minFilter===oo||x.minFilter===vr||x.minFilter===fi)&&De("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(E,i.TEXTURE_WRAP_S,Me[x.wrapS]),i.texParameteri(E,i.TEXTURE_WRAP_T,Me[x.wrapT]),(E===i.TEXTURE_3D||E===i.TEXTURE_2D_ARRAY)&&i.texParameteri(E,i.TEXTURE_WRAP_R,Me[x.wrapR]),i.texParameteri(E,i.TEXTURE_MAG_FILTER,$e[x.magFilter]),i.texParameteri(E,i.TEXTURE_MIN_FILTER,$e[x.minFilter]),x.compareFunction&&(i.texParameteri(E,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(E,i.TEXTURE_COMPARE_FUNC,ct[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===Dt||x.minFilter!==vr&&x.minFilter!==fi||x.type===bn&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||n.get(x).__currentAnisotropy){let U=e.get("EXT_texture_filter_anisotropic");i.texParameterf(E,U.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,s.getMaxAnisotropy())),n.get(x).__currentAnisotropy=x.anisotropy}}}function $(E,x){let U=!1;E.__webglInit===void 0&&(E.__webglInit=!0,x.addEventListener("dispose",A));let k=x.source,q=f.get(k);q===void 0&&(q={},f.set(k,q));let ae=H(x);if(ae!==E.__cacheKey){q[ae]===void 0&&(q[ae]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,U=!0),q[ae].usedTimes++;let oe=q[E.__cacheKey];oe!==void 0&&(q[E.__cacheKey].usedTimes--,oe.usedTimes===0&&I(x)),E.__cacheKey=ae,E.__webglTexture=q[ae].texture}return U}function ce(E,x,U){return Math.floor(Math.floor(E/U)/x)}function re(E,x,U,k){let ae=E.updateRanges;if(ae.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,x.width,x.height,U,k,x.data);else{ae.sort((Re,ge)=>Re.start-ge.start);let oe=0;for(let Re=1;Re<ae.length;Re++){let ge=ae[oe],fe=ae[Re],Ne=ge.start+ge.count,Be=ce(fe.start,x.width,4),We=ce(ge.start,x.width,4);fe.start<=Ne+1&&Be===We&&ce(fe.start+fe.count-1,x.width,4)===Be?ge.count=Math.max(ge.count,fe.start+fe.count-ge.start):(++oe,ae[oe]=fe)}ae.length=oe+1;let Y=t.getParameter(i.UNPACK_ROW_LENGTH),J=t.getParameter(i.UNPACK_SKIP_PIXELS),de=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,x.width);for(let Re=0,ge=ae.length;Re<ge;Re++){let fe=ae[Re],Ne=Math.floor(fe.start/4),Be=Math.ceil(fe.count/4),We=Ne%x.width,D=Math.floor(Ne/x.width),he=Be,Z=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,We),t.pixelStorei(i.UNPACK_SKIP_ROWS,D),t.texSubImage2D(i.TEXTURE_2D,0,We,D,he,Z,U,k,x.data)}E.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,Y),t.pixelStorei(i.UNPACK_SKIP_PIXELS,J),t.pixelStorei(i.UNPACK_SKIP_ROWS,de)}}function Ie(E,x,U){let k=i.TEXTURE_2D;(x.isDataArrayTexture||x.isCompressedArrayTexture)&&(k=i.TEXTURE_2D_ARRAY),x.isData3DTexture&&(k=i.TEXTURE_3D);let q=$(E,x),ae=x.source;t.bindTexture(k,E.__webglTexture,i.TEXTURE0+U);let oe=n.get(ae);if(ae.version!==oe.__version||q===!0){if(t.activeTexture(i.TEXTURE0+U),(typeof ImageBitmap<"u"&&x.image instanceof ImageBitmap)===!1){let Z=je.getPrimaries(je.workingColorSpace),pe=x.colorSpace===Xn?null:je.getPrimaries(x.colorSpace),be=x.colorSpace===Xn||Z===pe?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,x.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,be)}t.pixelStorei(i.UNPACK_ALIGNMENT,x.unpackAlignment);let J=m(x.image,!1,s.maxTextureSize);J=at(x,J);let de=r.convert(x.format,x.colorSpace),Re=r.convert(x.type),ge=_(x.internalFormat,de,Re,x.normalized,x.colorSpace,x.isVideoTexture);Qe(k,x);let fe,Ne=x.mipmaps,Be=x.isVideoTexture!==!0,We=oe.__version===void 0||q===!0,D=ae.dataReady,he=M(x,J);if(x.isDepthTexture)ge=S(x.format===pi,x.type),We&&(Be?t.texStorage2D(i.TEXTURE_2D,1,ge,J.width,J.height):t.texImage2D(i.TEXTURE_2D,0,ge,J.width,J.height,0,de,Re,null));else if(x.isDataTexture)if(Ne.length>0){Be&&We&&t.texStorage2D(i.TEXTURE_2D,he,ge,Ne[0].width,Ne[0].height);for(let Z=0,pe=Ne.length;Z<pe;Z++)fe=Ne[Z],Be?D&&t.texSubImage2D(i.TEXTURE_2D,Z,0,0,fe.width,fe.height,de,Re,fe.data):t.texImage2D(i.TEXTURE_2D,Z,ge,fe.width,fe.height,0,de,Re,fe.data);x.generateMipmaps=!1}else Be?(We&&t.texStorage2D(i.TEXTURE_2D,he,ge,J.width,J.height),D&&re(x,J,de,Re)):t.texImage2D(i.TEXTURE_2D,0,ge,J.width,J.height,0,de,Re,J.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){Be&&We&&t.texStorage3D(i.TEXTURE_2D_ARRAY,he,ge,Ne[0].width,Ne[0].height,J.depth);for(let Z=0,pe=Ne.length;Z<pe;Z++)if(fe=Ne[Z],x.format!==cn)if(de!==null)if(Be){if(D)if(x.layerUpdates.size>0){let be=Mc(fe.width,fe.height,x.format,x.type);for(let Q of x.layerUpdates){let Ae=fe.data.subarray(Q*be/fe.data.BYTES_PER_ELEMENT,(Q+1)*be/fe.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Z,0,0,Q,fe.width,fe.height,1,de,Ae)}x.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Z,0,0,0,fe.width,fe.height,J.depth,de,fe.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,Z,ge,fe.width,fe.height,J.depth,0,fe.data,0,0);else De("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Be?D&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,Z,0,0,0,fe.width,fe.height,J.depth,de,Re,fe.data):t.texImage3D(i.TEXTURE_2D_ARRAY,Z,ge,fe.width,fe.height,J.depth,0,de,Re,fe.data)}else{Be&&We&&t.texStorage2D(i.TEXTURE_2D,he,ge,Ne[0].width,Ne[0].height);for(let Z=0,pe=Ne.length;Z<pe;Z++)fe=Ne[Z],x.format!==cn?de!==null?Be?D&&t.compressedTexSubImage2D(i.TEXTURE_2D,Z,0,0,fe.width,fe.height,de,fe.data):t.compressedTexImage2D(i.TEXTURE_2D,Z,ge,fe.width,fe.height,0,fe.data):De("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Be?D&&t.texSubImage2D(i.TEXTURE_2D,Z,0,0,fe.width,fe.height,de,Re,fe.data):t.texImage2D(i.TEXTURE_2D,Z,ge,fe.width,fe.height,0,de,Re,fe.data)}else if(x.isDataArrayTexture)if(Be){if(We&&t.texStorage3D(i.TEXTURE_2D_ARRAY,he,ge,J.width,J.height,J.depth),D)if(x.layerUpdates.size>0){let Z=Mc(J.width,J.height,x.format,x.type);for(let pe of x.layerUpdates){let be=J.data.subarray(pe*Z/J.data.BYTES_PER_ELEMENT,(pe+1)*Z/J.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,pe,J.width,J.height,1,de,Re,be)}x.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,J.width,J.height,J.depth,de,Re,J.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,ge,J.width,J.height,J.depth,0,de,Re,J.data);else if(x.isData3DTexture)Be?(We&&t.texStorage3D(i.TEXTURE_3D,he,ge,J.width,J.height,J.depth),D&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,J.width,J.height,J.depth,de,Re,J.data)):t.texImage3D(i.TEXTURE_3D,0,ge,J.width,J.height,J.depth,0,de,Re,J.data);else if(x.isFramebufferTexture){if(We)if(Be)t.texStorage2D(i.TEXTURE_2D,he,ge,J.width,J.height);else{let Z=J.width,pe=J.height;for(let be=0;be<he;be++)t.texImage2D(i.TEXTURE_2D,be,ge,Z,pe,0,de,Re,null),Z>>=1,pe>>=1}}else if(x.isHTMLTexture){if("texElementImage2D"in i){let Z=i.canvas;if(Z.hasAttribute("layoutsubtree")||Z.setAttribute("layoutsubtree","true"),J.parentNode!==Z){Z.appendChild(J),d.add(x),Z.onpaint=pe=>{let be=pe.changedElements;for(let Q of d)be.includes(Q.image)&&(Q.needsUpdate=!0)},Z.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,J);else{let be=i.RGBA,Q=i.RGBA,Ae=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,be,Q,Ae,J)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(Ne.length>0){if(Be&&We){let Z=Ke(Ne[0]);t.texStorage2D(i.TEXTURE_2D,he,ge,Z.width,Z.height)}for(let Z=0,pe=Ne.length;Z<pe;Z++)fe=Ne[Z],Be?D&&t.texSubImage2D(i.TEXTURE_2D,Z,0,0,de,Re,fe):t.texImage2D(i.TEXTURE_2D,Z,ge,de,Re,fe);x.generateMipmaps=!1}else if(Be){if(We){let Z=Ke(J);t.texStorage2D(i.TEXTURE_2D,he,ge,Z.width,Z.height)}D&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,de,Re,J)}else t.texImage2D(i.TEXTURE_2D,0,ge,de,Re,J);p(x)&&C(k),oe.__version=ae.version,x.onUpdate&&x.onUpdate(x)}E.__version=x.version}function ze(E,x,U){if(x.image.length!==6)return;let k=$(E,x),q=x.source;t.bindTexture(i.TEXTURE_CUBE_MAP,E.__webglTexture,i.TEXTURE0+U);let ae=n.get(q);if(q.version!==ae.__version||k===!0){t.activeTexture(i.TEXTURE0+U);let oe=je.getPrimaries(je.workingColorSpace),Y=x.colorSpace===Xn?null:je.getPrimaries(x.colorSpace),J=x.colorSpace===Xn||oe===Y?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,x.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),t.pixelStorei(i.UNPACK_ALIGNMENT,x.unpackAlignment),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,J);let de=x.isCompressedTexture||x.image[0].isCompressedTexture,Re=x.image[0]&&x.image[0].isDataTexture,ge=[];for(let Q=0;Q<6;Q++)!de&&!Re?ge[Q]=m(x.image[Q],!0,s.maxCubemapSize):ge[Q]=Re?x.image[Q].image:x.image[Q],ge[Q]=at(x,ge[Q]);let fe=ge[0],Ne=r.convert(x.format,x.colorSpace),Be=r.convert(x.type),We=_(x.internalFormat,Ne,Be,x.normalized,x.colorSpace),D=x.isVideoTexture!==!0,he=ae.__version===void 0||k===!0,Z=q.dataReady,pe=M(x,fe);Qe(i.TEXTURE_CUBE_MAP,x);let be;if(de){D&&he&&t.texStorage2D(i.TEXTURE_CUBE_MAP,pe,We,fe.width,fe.height);for(let Q=0;Q<6;Q++){be=ge[Q].mipmaps;for(let Ae=0;Ae<be.length;Ae++){let Te=be[Ae];x.format!==cn?Ne!==null?D?Z&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Ae,0,0,Te.width,Te.height,Ne,Te.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Ae,We,Te.width,Te.height,0,Te.data):De("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):D?Z&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Ae,0,0,Te.width,Te.height,Ne,Be,Te.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Ae,We,Te.width,Te.height,0,Ne,Be,Te.data)}}}else{if(be=x.mipmaps,D&&he){be.length>0&&pe++;let Q=Ke(ge[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,pe,We,Q.width,Q.height)}for(let Q=0;Q<6;Q++)if(Re){D?Z&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,0,0,ge[Q].width,ge[Q].height,Ne,Be,ge[Q].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,We,ge[Q].width,ge[Q].height,0,Ne,Be,ge[Q].data);for(let Ae=0;Ae<be.length;Ae++){let yt=be[Ae].image[Q].image;D?Z&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Ae+1,0,0,yt.width,yt.height,Ne,Be,yt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Ae+1,We,yt.width,yt.height,0,Ne,Be,yt.data)}}else{D?Z&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,0,0,Ne,Be,ge[Q]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,We,Ne,Be,ge[Q]);for(let Ae=0;Ae<be.length;Ae++){let Te=be[Ae];D?Z&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Ae+1,0,0,Ne,Be,Te.image[Q]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Ae+1,We,Ne,Be,Te.image[Q])}}}p(x)&&C(i.TEXTURE_CUBE_MAP),ae.__version=q.version,x.onUpdate&&x.onUpdate(x)}E.__version=x.version}function Ue(E,x,U,k,q,ae){let oe=r.convert(U.format,U.colorSpace),Y=r.convert(U.type),J=_(U.internalFormat,oe,Y,U.normalized,U.colorSpace),de=n.get(x),Re=n.get(U);if(Re.__renderTarget=x,!de.__hasExternalTextures){let ge=Math.max(1,x.width>>ae),fe=Math.max(1,x.height>>ae);q===i.TEXTURE_3D||q===i.TEXTURE_2D_ARRAY?t.texImage3D(q,ae,J,ge,fe,x.depth,0,oe,Y,null):t.texImage2D(q,ae,J,ge,fe,0,oe,Y,null)}t.bindFramebuffer(i.FRAMEBUFFER,E),Ge(x)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,k,q,Re.__webglTexture,0,ke(x)):(q===i.TEXTURE_2D||q>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&q<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,k,q,Re.__webglTexture,ae),t.bindFramebuffer(i.FRAMEBUFFER,null)}function nt(E,x,U){if(i.bindRenderbuffer(i.RENDERBUFFER,E),x.depthBuffer){let k=x.depthTexture,q=k&&k.isDepthTexture?k.type:null,ae=S(x.stencilBuffer,q),oe=x.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;Ge(x)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ke(x),ae,x.width,x.height):U?i.renderbufferStorageMultisample(i.RENDERBUFFER,ke(x),ae,x.width,x.height):i.renderbufferStorage(i.RENDERBUFFER,ae,x.width,x.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,oe,i.RENDERBUFFER,E)}else{let k=x.textures;for(let q=0;q<k.length;q++){let ae=k[q],oe=r.convert(ae.format,ae.colorSpace),Y=r.convert(ae.type),J=_(ae.internalFormat,oe,Y,ae.normalized,ae.colorSpace);Ge(x)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ke(x),J,x.width,x.height):U?i.renderbufferStorageMultisample(i.RENDERBUFFER,ke(x),J,x.width,x.height):i.renderbufferStorage(i.RENDERBUFFER,J,x.width,x.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Ve(E,x,U){let k=x.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,E),!(x.depthTexture&&x.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let q=n.get(x.depthTexture);if(q.__renderTarget=x,(!q.__webglTexture||x.depthTexture.image.width!==x.width||x.depthTexture.image.height!==x.height)&&(x.depthTexture.image.width=x.width,x.depthTexture.image.height=x.height,x.depthTexture.needsUpdate=!0),k){if(q.__webglInit===void 0&&(q.__webglInit=!0,x.depthTexture.addEventListener("dispose",A)),q.__webglTexture===void 0){q.__webglTexture=i.createTexture(),t.bindTexture(i.TEXTURE_CUBE_MAP,q.__webglTexture),Qe(i.TEXTURE_CUBE_MAP,x.depthTexture);let de=r.convert(x.depthTexture.format),Re=r.convert(x.depthTexture.type),ge;x.depthTexture.format===Rn?ge=i.DEPTH_COMPONENT24:x.depthTexture.format===pi&&(ge=i.DEPTH24_STENCIL8);for(let fe=0;fe<6;fe++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,ge,x.width,x.height,0,de,Re,null)}}else K(x.depthTexture,0);let ae=q.__webglTexture,oe=ke(x),Y=k?i.TEXTURE_CUBE_MAP_POSITIVE_X+U:i.TEXTURE_2D,J=x.depthTexture.format===pi?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(x.depthTexture.format===Rn)Ge(x)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,J,Y,ae,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,J,Y,ae,0);else if(x.depthTexture.format===pi)Ge(x)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,J,Y,ae,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,J,Y,ae,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function j(E){let x=n.get(E),U=E.isWebGLCubeRenderTarget===!0;if(x.__boundDepthTexture!==E.depthTexture){let k=E.depthTexture;if(x.__depthDisposeCallback&&x.__depthDisposeCallback(),k){let q=()=>{delete x.__boundDepthTexture,delete x.__depthDisposeCallback,k.removeEventListener("dispose",q)};k.addEventListener("dispose",q),x.__depthDisposeCallback=q}x.__boundDepthTexture=k}if(E.depthTexture&&!x.__autoAllocateDepthBuffer)if(U)for(let k=0;k<6;k++)Ve(x.__webglFramebuffer[k],E,k);else{let k=E.texture.mipmaps;k&&k.length>0?Ve(x.__webglFramebuffer[0],E,0):Ve(x.__webglFramebuffer,E,0)}else if(U){x.__webglDepthbuffer=[];for(let k=0;k<6;k++)if(t.bindFramebuffer(i.FRAMEBUFFER,x.__webglFramebuffer[k]),x.__webglDepthbuffer[k]===void 0)x.__webglDepthbuffer[k]=i.createRenderbuffer(),nt(x.__webglDepthbuffer[k],E,!1);else{let q=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ae=x.__webglDepthbuffer[k];i.bindRenderbuffer(i.RENDERBUFFER,ae),i.framebufferRenderbuffer(i.FRAMEBUFFER,q,i.RENDERBUFFER,ae)}}else{let k=E.texture.mipmaps;if(k&&k.length>0?t.bindFramebuffer(i.FRAMEBUFFER,x.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=i.createRenderbuffer(),nt(x.__webglDepthbuffer,E,!1);else{let q=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ae=x.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,ae),i.framebufferRenderbuffer(i.FRAMEBUFFER,q,i.RENDERBUFFER,ae)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function ne(E,x,U){let k=n.get(E);x!==void 0&&Ue(k.__webglFramebuffer,E,E.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),U!==void 0&&j(E)}function te(E){let x=E.texture,U=n.get(E),k=n.get(x);E.addEventListener("dispose",y);let q=E.textures,ae=E.isWebGLCubeRenderTarget===!0,oe=q.length>1;if(oe||(k.__webglTexture===void 0&&(k.__webglTexture=i.createTexture()),k.__version=x.version,a.memory.textures++),ae){U.__webglFramebuffer=[];for(let Y=0;Y<6;Y++)if(x.mipmaps&&x.mipmaps.length>0){U.__webglFramebuffer[Y]=[];for(let J=0;J<x.mipmaps.length;J++)U.__webglFramebuffer[Y][J]=i.createFramebuffer()}else U.__webglFramebuffer[Y]=i.createFramebuffer()}else{if(x.mipmaps&&x.mipmaps.length>0){U.__webglFramebuffer=[];for(let Y=0;Y<x.mipmaps.length;Y++)U.__webglFramebuffer[Y]=i.createFramebuffer()}else U.__webglFramebuffer=i.createFramebuffer();if(oe)for(let Y=0,J=q.length;Y<J;Y++){let de=n.get(q[Y]);de.__webglTexture===void 0&&(de.__webglTexture=i.createTexture(),a.memory.textures++)}if(E.samples>0&&Ge(E)===!1){U.__webglMultisampledFramebuffer=i.createFramebuffer(),U.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,U.__webglMultisampledFramebuffer);for(let Y=0;Y<q.length;Y++){let J=q[Y];U.__webglColorRenderbuffer[Y]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,U.__webglColorRenderbuffer[Y]);let de=r.convert(J.format,J.colorSpace),Re=r.convert(J.type),ge=_(J.internalFormat,de,Re,J.normalized,J.colorSpace,E.isXRRenderTarget===!0),fe=ke(E);i.renderbufferStorageMultisample(i.RENDERBUFFER,fe,ge,E.width,E.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Y,i.RENDERBUFFER,U.__webglColorRenderbuffer[Y])}i.bindRenderbuffer(i.RENDERBUFFER,null),E.depthBuffer&&(U.__webglDepthRenderbuffer=i.createRenderbuffer(),nt(U.__webglDepthRenderbuffer,E,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(ae){t.bindTexture(i.TEXTURE_CUBE_MAP,k.__webglTexture),Qe(i.TEXTURE_CUBE_MAP,x);for(let Y=0;Y<6;Y++)if(x.mipmaps&&x.mipmaps.length>0)for(let J=0;J<x.mipmaps.length;J++)Ue(U.__webglFramebuffer[Y][J],E,x,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,J);else Ue(U.__webglFramebuffer[Y],E,x,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0);p(x)&&C(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(oe){for(let Y=0,J=q.length;Y<J;Y++){let de=q[Y],Re=n.get(de),ge=i.TEXTURE_2D;(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(ge=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(ge,Re.__webglTexture),Qe(ge,de),Ue(U.__webglFramebuffer,E,de,i.COLOR_ATTACHMENT0+Y,ge,0),p(de)&&C(ge)}t.unbindTexture()}else{let Y=i.TEXTURE_2D;if((E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(Y=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(Y,k.__webglTexture),Qe(Y,x),x.mipmaps&&x.mipmaps.length>0)for(let J=0;J<x.mipmaps.length;J++)Ue(U.__webglFramebuffer[J],E,x,i.COLOR_ATTACHMENT0,Y,J);else Ue(U.__webglFramebuffer,E,x,i.COLOR_ATTACHMENT0,Y,0);p(x)&&C(Y),t.unbindTexture()}E.depthBuffer&&j(E)}function xe(E){let x=E.textures;for(let U=0,k=x.length;U<k;U++){let q=x[U];if(p(q)){let ae=w(E),oe=n.get(q).__webglTexture;t.bindTexture(ae,oe),C(ae),t.unbindTexture()}}}let me=[],Oe=[];function Ce(E){if(E.samples>0){if(Ge(E)===!1){let x=E.textures,U=E.width,k=E.height,q=i.COLOR_BUFFER_BIT,ae=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,oe=n.get(E),Y=x.length>1;if(Y)for(let de=0;de<x.length;de++)t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+de,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+de,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,oe.__webglMultisampledFramebuffer);let J=E.texture.mipmaps;J&&J.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglFramebuffer);for(let de=0;de<x.length;de++){if(E.resolveDepthBuffer&&(E.depthBuffer&&(q|=i.DEPTH_BUFFER_BIT),E.stencilBuffer&&E.resolveStencilBuffer&&(q|=i.STENCIL_BUFFER_BIT)),Y){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,oe.__webglColorRenderbuffer[de]);let Re=n.get(x[de]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Re,0)}i.blitFramebuffer(0,0,U,k,0,0,U,k,q,i.NEAREST),l===!0&&(me.length=0,Oe.length=0,me.push(i.COLOR_ATTACHMENT0+de),E.depthBuffer&&E.resolveDepthBuffer===!1&&(me.push(ae),Oe.push(ae),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,Oe)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,me))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),Y)for(let de=0;de<x.length;de++){t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+de,i.RENDERBUFFER,oe.__webglColorRenderbuffer[de]);let Re=n.get(x[de]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+de,i.TEXTURE_2D,Re,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.resolveDepthBuffer===!1&&l){let x=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[x])}}}function ke(E){return Math.min(s.maxSamples,E.samples)}function Ge(E){let x=n.get(E);return E.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function L(E){let x=a.render.frame;h.get(E)!==x&&(h.set(E,x),E.update())}function at(E,x){let U=E.colorSpace,k=E.format,q=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||U!==Xs&&U!==Xn&&(je.getTransfer(U)===it?(k!==cn||q!==Yt)&&De("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Fe("WebGLTextures: Unsupported texture color space:",U)),x}function Ke(E){return typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement?(c.width=E.naturalWidth||E.width,c.height=E.naturalHeight||E.height):typeof VideoFrame<"u"&&E instanceof VideoFrame?(c.width=E.displayWidth,c.height=E.displayHeight):(c.width=E.width,c.height=E.height),c}this.allocateTextureUnit=W,this.resetTextureUnits=G,this.getTextureUnits=X,this.setTextureUnits=O,this.setTexture2D=K,this.setTexture2DArray=ie,this.setTexture3D=ue,this.setTextureCube=le,this.rebindTextures=ne,this.setupRenderTarget=te,this.updateRenderTargetMipmap=xe,this.updateMultisampleRenderTarget=Ce,this.setupDepthRenderbuffer=j,this.setupFrameBufferTexture=Ue,this.useMultisampledRTT=Ge,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function rx(i,e){function t(n,s=Xn){let r,a=je.getTransfer(s);if(n===Yt)return i.UNSIGNED_BYTE;if(n===co)return i.UNSIGNED_SHORT_4_4_4_4;if(n===ho)return i.UNSIGNED_SHORT_5_5_5_1;if(n===hc)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===uc)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===lc)return i.BYTE;if(n===cc)return i.SHORT;if(n===ys)return i.UNSIGNED_SHORT;if(n===lo)return i.INT;if(n===vn)return i.UNSIGNED_INT;if(n===bn)return i.FLOAT;if(n===Ln)return i.HALF_FLOAT;if(n===dc)return i.ALPHA;if(n===fc)return i.RGB;if(n===cn)return i.RGBA;if(n===Rn)return i.DEPTH_COMPONENT;if(n===pi)return i.DEPTH_STENCIL;if(n===pc)return i.RED;if(n===uo)return i.RED_INTEGER;if(n===mi)return i.RG;if(n===fo)return i.RG_INTEGER;if(n===po)return i.RGBA_INTEGER;if(n===br||n===Mr||n===Sr||n===Er)if(a===it)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===br)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Mr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Sr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Er)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===br)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Mr)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Sr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Er)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===mo||n===go||n===_o||n===xo)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===mo)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===go)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===_o)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===xo)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===yo||n===vo||n===bo||n===Mo||n===So||n===Tr||n===Eo)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===yo||n===vo)return a===it?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===bo)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Mo)return r.COMPRESSED_R11_EAC;if(n===So)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Tr)return r.COMPRESSED_RG11_EAC;if(n===Eo)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===To||n===wo||n===Ao||n===Co||n===Ro||n===Po||n===Io||n===Lo||n===Do||n===No||n===Uo||n===Fo||n===Oo||n===Bo)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===To)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===wo)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Ao)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Co)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Ro)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Po)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Io)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Lo)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Do)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===No)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Uo)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Fo)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Oo)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Bo)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===zo||n===ko||n===Vo)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===zo)return a===it?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ko)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Vo)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Ho||n===Go||n===wr||n===Wo)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===Ho)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Go)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===wr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Wo)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===vs?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}var ax=`
|
|
4089
|
+
}`,sx=[new R(1,0,0),new R(-1,0,0),new R(0,1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1)],rx=[new R(0,-1,0),new R(0,-1,0),new R(0,0,1),new R(0,0,-1),new R(0,-1,0),new R(0,-1,0)],id=new rt,Ar=new R,Rc=new R;function ox(i,e,t){let n=new fs,s=new te,r=new te,o=new gt,a=new qo,l=new Yo,c={},h=t.maxTextureSize,d={[Hn]:qt,[qt]:Hn,[ln]:ln},u=new tn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new te},radius:{value:4}},vertexShader:nx,fragmentShader:ix}),f=u.clone();f.defines.HORIZONTAL_PASS=1;let g=new mt;g.setAttribute("position",new wt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new Tt(g,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=_r;let p=this.type;this.render=function(M,A,v){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||M.length===0)return;this.type===Zh&&(De("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=_r);let w=i.getRenderTarget(),I=i.getActiveCubeFace(),P=i.getActiveMipmapLevel(),O=i.state;O.setBlending(In),O.buffers.depth.getReversed()===!0?O.buffers.color.setClear(0,0,0,0):O.buffers.color.setClear(1,1,1,1),O.buffers.depth.setTest(!0),O.setScissorTest(!1);let q=p!==this.type;q&&A.traverse(function(Y){Y.material&&(Array.isArray(Y.material)?Y.material.forEach(U=>U.needsUpdate=!0):Y.material.needsUpdate=!0)});for(let Y=0,U=M.length;Y<U;Y++){let G=M[Y],H=G.shadow;if(H===void 0){De("WebGLShadowMap:",G,"has no shadow.");continue}if(H.autoUpdate===!1&&H.needsUpdate===!1)continue;s.copy(H.mapSize);let j=H.getFrameExtents();s.multiply(j),r.copy(H.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/j.x),s.x=r.x*j.x,H.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/j.y),s.y=r.y*j.y,H.mapSize.y=r.y));let se=i.state.buffers.depth.getReversed();if(H.camera._reversedDepth=se,H.map===null||q===!0){if(H.map!==null&&(H.map.depthTexture!==null&&(H.map.depthTexture.dispose(),H.map.depthTexture=null),H.map.dispose()),this.type===ys){if(G.isPointLight){De("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}H.map=new Qt(s.x,s.y,{format:gi,type:Ln,minFilter:Ut,magFilter:Ut,generateMipmaps:!1}),H.map.texture.name=G.name+".shadowMap",H.map.depthTexture=new Wn(s.x,s.y,bn),H.map.depthTexture.name=G.name+".shadowMapDepth",H.map.depthTexture.format=Rn,H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=Lt,H.map.depthTexture.magFilter=Lt}else G.isPointLight?(H.map=new Ka(s.x),H.map.depthTexture=new Bo(s.x,yn)):(H.map=new Qt(s.x,s.y),H.map.depthTexture=new Wn(s.x,s.y,yn)),H.map.depthTexture.name=G.name+".shadowMap",H.map.depthTexture.format=Rn,this.type===_r?(H.map.depthTexture.compareFunction=se?Ya:qa,H.map.depthTexture.minFilter=Ut,H.map.depthTexture.magFilter=Ut):(H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=Lt,H.map.depthTexture.magFilter=Lt);H.camera.updateProjectionMatrix()}let ue=H.map.isWebGLCubeRenderTarget?6:1;for(let le=0;le<ue;le++){if(H.map.isWebGLCubeRenderTarget)i.setRenderTarget(H.map,le),i.clear();else{le===0&&(i.setRenderTarget(H.map),i.clear());let Me=H.getViewport(le);o.set(r.x*Me.x,r.y*Me.y,r.x*Me.z,r.y*Me.w),O.viewport(o)}if(G.isPointLight){let Me=H.camera,Je=H.matrix,ct=G.distance||Me.far;ct!==Me.far&&(Me.far=ct,Me.updateProjectionMatrix()),Ar.setFromMatrixPosition(G.matrixWorld),Me.position.copy(Ar),Rc.copy(Me.position),Rc.add(sx[le]),Me.up.copy(rx[le]),Me.lookAt(Rc),Me.updateMatrixWorld(),Je.makeTranslation(-Ar.x,-Ar.y,-Ar.z),id.multiplyMatrices(Me.projectionMatrix,Me.matrixWorldInverse),H._frustum.setFromProjectionMatrix(id,Me.coordinateSystem,Me.reversedDepth)}else H.updateMatrices(G);n=H.getFrustum(),x(A,v,H.camera,G,this.type)}H.isPointLightShadow!==!0&&this.type===ys&&C(H,v),H.needsUpdate=!1}p=this.type,m.needsUpdate=!1,i.setRenderTarget(w,I,P)};function C(M,A){let v=e.update(y);u.defines.VSM_SAMPLES!==M.blurSamples&&(u.defines.VSM_SAMPLES=M.blurSamples,f.defines.VSM_SAMPLES=M.blurSamples,u.needsUpdate=!0,f.needsUpdate=!0),M.mapPass===null&&(M.mapPass=new Qt(s.x,s.y,{format:gi,type:Ln})),u.uniforms.shadow_pass.value=M.map.depthTexture,u.uniforms.resolution.value=M.mapSize,u.uniforms.radius.value=M.radius,i.setRenderTarget(M.mapPass),i.clear(),i.renderBufferDirect(A,null,v,u,y,null),f.uniforms.shadow_pass.value=M.mapPass.texture,f.uniforms.resolution.value=M.mapSize,f.uniforms.radius.value=M.radius,i.setRenderTarget(M.map),i.clear(),i.renderBufferDirect(A,null,v,f,y,null)}function T(M,A,v,w){let I=null,P=v.isPointLight===!0?M.customDistanceMaterial:M.customDepthMaterial;if(P!==void 0)I=P;else if(I=v.isPointLight===!0?l:a,i.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let O=I.uuid,q=A.uuid,Y=c[O];Y===void 0&&(Y={},c[O]=Y);let U=Y[q];U===void 0&&(U=I.clone(),Y[q]=U,A.addEventListener("dispose",S)),I=U}if(I.visible=A.visible,I.wireframe=A.wireframe,w===ys?I.side=A.shadowSide!==null?A.shadowSide:A.side:I.side=A.shadowSide!==null?A.shadowSide:d[A.side],I.alphaMap=A.alphaMap,I.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,I.map=A.map,I.clipShadows=A.clipShadows,I.clippingPlanes=A.clippingPlanes,I.clipIntersection=A.clipIntersection,I.displacementMap=A.displacementMap,I.displacementScale=A.displacementScale,I.displacementBias=A.displacementBias,I.wireframeLinewidth=A.wireframeLinewidth,I.linewidth=A.linewidth,v.isPointLight===!0&&I.isMeshDistanceMaterial===!0){let O=i.properties.get(I);O.light=v}return I}function x(M,A,v,w,I){if(M.visible===!1)return;if(M.layers.test(A.layers)&&(M.isMesh||M.isLine||M.isPoints)&&(M.castShadow||M.receiveShadow&&I===ys)&&(!M.frustumCulled||n.intersectsObject(M))){M.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,M.matrixWorld);let q=e.update(M),Y=M.material;if(Array.isArray(Y)){let U=q.groups;for(let G=0,H=U.length;G<H;G++){let j=U[G],se=Y[j.materialIndex];if(se&&se.visible){let ue=T(M,se,w,I);M.onBeforeShadow(i,M,A,v,q,ue,j),i.renderBufferDirect(v,null,q,ue,M,j),M.onAfterShadow(i,M,A,v,q,ue,j)}}}else if(Y.visible){let U=T(M,Y,w,I);M.onBeforeShadow(i,M,A,v,q,U,null),i.renderBufferDirect(v,null,q,U,M,null),M.onAfterShadow(i,M,A,v,q,U,null)}}let O=M.children;for(let q=0,Y=O.length;q<Y;q++)x(O[q],A,v,w,I)}function S(M){M.target.removeEventListener("dispose",S);for(let v in c){let w=c[v],I=M.target.uuid;I in w&&(w[I].dispose(),delete w[I])}}}function ax(i,e){function t(){let D=!1,he=new gt,$=null,pe=new gt(0,0,0,0);return{setMask:function(be){$!==be&&!D&&(i.colorMask(be,be,be,be),$=be)},setLocked:function(be){D=be},setClear:function(be,ee,Ae,we,vt){vt===!0&&(be*=we,ee*=we,Ae*=we),he.set(be,ee,Ae,we),pe.equals(he)===!1&&(i.clearColor(be,ee,Ae,we),pe.copy(he))},reset:function(){D=!1,$=null,pe.set(-1,0,0,0)}}}function n(){let D=!1,he=!1,$=null,pe=null,be=null;return{setReversed:function(ee){if(he!==ee){let Ae=e.get("EXT_clip_control");ee?Ae.clipControlEXT(Ae.LOWER_LEFT_EXT,Ae.ZERO_TO_ONE_EXT):Ae.clipControlEXT(Ae.LOWER_LEFT_EXT,Ae.NEGATIVE_ONE_TO_ONE_EXT),he=ee;let we=be;be=null,this.setClear(we)}},getReversed:function(){return he},setTest:function(ee){ee?re(i.DEPTH_TEST):Ie(i.DEPTH_TEST)},setMask:function(ee){$!==ee&&!D&&(i.depthMask(ee),$=ee)},setFunc:function(ee){if(he&&(ee=Au[ee]),pe!==ee){switch(ee){case vo:i.depthFunc(i.NEVER);break;case yo:i.depthFunc(i.ALWAYS);break;case bo:i.depthFunc(i.LESS);break;case Ci:i.depthFunc(i.LEQUAL);break;case Mo:i.depthFunc(i.EQUAL);break;case So:i.depthFunc(i.GEQUAL);break;case Eo:i.depthFunc(i.GREATER);break;case wo:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}pe=ee}},setLocked:function(ee){D=ee},setClear:function(ee){be!==ee&&(be=ee,he&&(ee=1-ee),i.clearDepth(ee))},reset:function(){D=!1,$=null,pe=null,be=null,he=!1}}}function s(){let D=!1,he=null,$=null,pe=null,be=null,ee=null,Ae=null,we=null,vt=null;return{setTest:function(dt){D||(dt?re(i.STENCIL_TEST):Ie(i.STENCIL_TEST))},setMask:function(dt){he!==dt&&!D&&(i.stencilMask(dt),he=dt)},setFunc:function(dt,Mn,Sn){($!==dt||pe!==Mn||be!==Sn)&&(i.stencilFunc(dt,Mn,Sn),$=dt,pe=Mn,be=Sn)},setOp:function(dt,Mn,Sn){(ee!==dt||Ae!==Mn||we!==Sn)&&(i.stencilOp(dt,Mn,Sn),ee=dt,Ae=Mn,we=Sn)},setLocked:function(dt){D=dt},setClear:function(dt){vt!==dt&&(i.clearStencil(dt),vt=dt)},reset:function(){D=!1,he=null,$=null,pe=null,be=null,ee=null,Ae=null,we=null,vt=null}}}let r=new t,o=new n,a=new s,l=new WeakMap,c=new WeakMap,h={},d={},u={},f=new WeakMap,g=[],y=null,m=!1,p=null,C=null,T=null,x=null,S=null,M=null,A=null,v=new Ye(0,0,0),w=0,I=!1,P=null,O=null,q=null,Y=null,U=null,G=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),H=!1,j=0,se=i.getParameter(i.VERSION);se.indexOf("WebGL")!==-1?(j=parseFloat(/^WebGL (\d)/.exec(se)[1]),H=j>=1):se.indexOf("OpenGL ES")!==-1&&(j=parseFloat(/^OpenGL ES (\d)/.exec(se)[1]),H=j>=2);let ue=null,le={},Me=i.getParameter(i.SCISSOR_BOX),Je=i.getParameter(i.VIEWPORT),ct=new gt().fromArray(Me),et=new gt().fromArray(Je);function J(D,he,$,pe){let be=new Uint8Array(4),ee=i.createTexture();i.bindTexture(D,ee),i.texParameteri(D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(D,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Ae=0;Ae<$;Ae++)D===i.TEXTURE_3D||D===i.TEXTURE_2D_ARRAY?i.texImage3D(he,0,i.RGBA,1,1,pe,0,i.RGBA,i.UNSIGNED_BYTE,be):i.texImage2D(he+Ae,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,be);return ee}let ce={};ce[i.TEXTURE_2D]=J(i.TEXTURE_2D,i.TEXTURE_2D,1),ce[i.TEXTURE_CUBE_MAP]=J(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),ce[i.TEXTURE_2D_ARRAY]=J(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),ce[i.TEXTURE_3D]=J(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),o.setClear(1),a.setClear(0),re(i.DEPTH_TEST),o.setFunc(Ci),xe(!1),me(Jl),re(i.CULL_FACE),ie(In);function re(D){h[D]!==!0&&(i.enable(D),h[D]=!0)}function Ie(D){h[D]!==!1&&(i.disable(D),h[D]=!1)}function ke(D,he){return u[D]!==he?(i.bindFramebuffer(D,he),u[D]=he,D===i.DRAW_FRAMEBUFFER&&(u[i.FRAMEBUFFER]=he),D===i.FRAMEBUFFER&&(u[i.DRAW_FRAMEBUFFER]=he),!0):!1}function Ue(D,he){let $=g,pe=!1;if(D){$=f.get(he),$===void 0&&($=[],f.set(he,$));let be=D.textures;if($.length!==be.length||$[0]!==i.COLOR_ATTACHMENT0){for(let ee=0,Ae=be.length;ee<Ae;ee++)$[ee]=i.COLOR_ATTACHMENT0+ee;$.length=be.length,pe=!0}}else $[0]!==i.BACK&&($[0]=i.BACK,pe=!0);pe&&i.drawBuffers($)}function nt(D){return y!==D?(i.useProgram(D),y=D,!0):!1}let He={[ni]:i.FUNC_ADD,[Jh]:i.FUNC_SUBTRACT,[Kh]:i.FUNC_REVERSE_SUBTRACT};He[jh]=i.MIN,He[Qh]=i.MAX;let Q={[eu]:i.ZERO,[tu]:i.ONE,[nu]:i.SRC_COLOR,[_o]:i.SRC_ALPHA,[lu]:i.SRC_ALPHA_SATURATE,[ou]:i.DST_COLOR,[su]:i.DST_ALPHA,[iu]:i.ONE_MINUS_SRC_COLOR,[xo]:i.ONE_MINUS_SRC_ALPHA,[au]:i.ONE_MINUS_DST_COLOR,[ru]:i.ONE_MINUS_DST_ALPHA,[cu]:i.CONSTANT_COLOR,[hu]:i.ONE_MINUS_CONSTANT_COLOR,[uu]:i.CONSTANT_ALPHA,[du]:i.ONE_MINUS_CONSTANT_ALPHA};function ie(D,he,$,pe,be,ee,Ae,we,vt,dt){if(D===In){m===!0&&(Ie(i.BLEND),m=!1);return}if(m===!1&&(re(i.BLEND),m=!0),D!==$h){if(D!==p||dt!==I){if((C!==ni||S!==ni)&&(i.blendEquation(i.FUNC_ADD),C=ni,S=ni),dt)switch(D){case Ai:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Kl:i.blendFunc(i.ONE,i.ONE);break;case jl:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Ql:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Fe("WebGLState: Invalid blending: ",D);break}else switch(D){case Ai:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Kl:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case jl:Fe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Ql:Fe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Fe("WebGLState: Invalid blending: ",D);break}T=null,x=null,M=null,A=null,v.set(0,0,0),w=0,p=D,I=dt}return}be=be||he,ee=ee||$,Ae=Ae||pe,(he!==C||be!==S)&&(i.blendEquationSeparate(He[he],He[be]),C=he,S=be),($!==T||pe!==x||ee!==M||Ae!==A)&&(i.blendFuncSeparate(Q[$],Q[pe],Q[ee],Q[Ae]),T=$,x=pe,M=ee,A=Ae),(we.equals(v)===!1||vt!==w)&&(i.blendColor(we.r,we.g,we.b,vt),v.copy(we),w=vt),p=D,I=!1}function ne(D,he){D.side===ln?Ie(i.CULL_FACE):re(i.CULL_FACE);let $=D.side===qt;he&&($=!$),xe($),D.blending===Ai&&D.transparent===!1?ie(In):ie(D.blending,D.blendEquation,D.blendSrc,D.blendDst,D.blendEquationAlpha,D.blendSrcAlpha,D.blendDstAlpha,D.blendColor,D.blendAlpha,D.premultipliedAlpha),o.setFunc(D.depthFunc),o.setTest(D.depthTest),o.setMask(D.depthWrite),r.setMask(D.colorWrite);let pe=D.stencilWrite;a.setTest(pe),pe&&(a.setMask(D.stencilWriteMask),a.setFunc(D.stencilFunc,D.stencilRef,D.stencilFuncMask),a.setOp(D.stencilFail,D.stencilZFail,D.stencilZPass)),Ce(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),D.alphaToCoverage===!0?re(i.SAMPLE_ALPHA_TO_COVERAGE):Ie(i.SAMPLE_ALPHA_TO_COVERAGE)}function xe(D){P!==D&&(D?i.frontFace(i.CW):i.frontFace(i.CCW),P=D)}function me(D){D!==qh?(re(i.CULL_FACE),D!==O&&(D===Jl?i.cullFace(i.BACK):D===Yh?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Ie(i.CULL_FACE),O=D}function Be(D){D!==q&&(H&&i.lineWidth(D),q=D)}function Ce(D,he,$){D?(re(i.POLYGON_OFFSET_FILL),(Y!==he||U!==$)&&(Y=he,U=$,o.getReversed()&&(he=-he),i.polygonOffset(he,$))):Ie(i.POLYGON_OFFSET_FILL)}function Ve(D){D?re(i.SCISSOR_TEST):Ie(i.SCISSOR_TEST)}function We(D){D===void 0&&(D=i.TEXTURE0+G-1),ue!==D&&(i.activeTexture(D),ue=D)}function L(D,he,$){$===void 0&&(ue===null?$=i.TEXTURE0+G-1:$=ue);let pe=le[$];pe===void 0&&(pe={type:void 0,texture:void 0},le[$]=pe),(pe.type!==D||pe.texture!==he)&&(ue!==$&&(i.activeTexture($),ue=$),i.bindTexture(D,he||ce[D]),pe.type=D,pe.texture=he)}function ot(){let D=le[ue];D!==void 0&&D.type!==void 0&&(i.bindTexture(D.type,null),D.type=void 0,D.texture=void 0)}function je(){try{i.compressedTexImage2D(...arguments)}catch(D){Fe("WebGLState:",D)}}function E(){try{i.compressedTexImage3D(...arguments)}catch(D){Fe("WebGLState:",D)}}function _(){try{i.texSubImage2D(...arguments)}catch(D){Fe("WebGLState:",D)}}function F(){try{i.texSubImage3D(...arguments)}catch(D){Fe("WebGLState:",D)}}function k(){try{i.compressedTexSubImage2D(...arguments)}catch(D){Fe("WebGLState:",D)}}function W(){try{i.compressedTexSubImage3D(...arguments)}catch(D){Fe("WebGLState:",D)}}function oe(){try{i.texStorage2D(...arguments)}catch(D){Fe("WebGLState:",D)}}function ae(){try{i.texStorage3D(...arguments)}catch(D){Fe("WebGLState:",D)}}function X(){try{i.texImage2D(...arguments)}catch(D){Fe("WebGLState:",D)}}function K(){try{i.texImage3D(...arguments)}catch(D){Fe("WebGLState:",D)}}function de(D){return d[D]!==void 0?d[D]:i.getParameter(D)}function Re(D,he){d[D]!==he&&(i.pixelStorei(D,he),d[D]=he)}function ge(D){ct.equals(D)===!1&&(i.scissor(D.x,D.y,D.z,D.w),ct.copy(D))}function fe(D){et.equals(D)===!1&&(i.viewport(D.x,D.y,D.z,D.w),et.copy(D))}function Ne(D,he){let $=c.get(he);$===void 0&&($=new WeakMap,c.set(he,$));let pe=$.get(D);pe===void 0&&(pe=i.getUniformBlockIndex(he,D.name),$.set(D,pe))}function ze(D,he){let pe=c.get(he).get(D);l.get(he)!==pe&&(i.uniformBlockBinding(he,pe,D.__bindingPointIndex),l.set(he,pe))}function Xe(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),o.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),i.pixelStorei(i.PACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),i.pixelStorei(i.PACK_ROW_LENGTH,0),i.pixelStorei(i.PACK_SKIP_PIXELS,0),i.pixelStorei(i.PACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_ROW_LENGTH,0),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,0),i.pixelStorei(i.UNPACK_SKIP_PIXELS,0),i.pixelStorei(i.UNPACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_SKIP_IMAGES,0),h={},d={},ue=null,le={},u={},f=new WeakMap,g=[],y=null,m=!1,p=null,C=null,T=null,x=null,S=null,M=null,A=null,v=new Ye(0,0,0),w=0,I=!1,P=null,O=null,q=null,Y=null,U=null,ct.set(0,0,i.canvas.width,i.canvas.height),et.set(0,0,i.canvas.width,i.canvas.height),r.reset(),o.reset(),a.reset()}return{buffers:{color:r,depth:o,stencil:a},enable:re,disable:Ie,bindFramebuffer:ke,drawBuffers:Ue,useProgram:nt,setBlending:ie,setMaterial:ne,setFlipSided:xe,setCullFace:me,setLineWidth:Be,setPolygonOffset:Ce,setScissorTest:Ve,activeTexture:We,bindTexture:L,unbindTexture:ot,compressedTexImage2D:je,compressedTexImage3D:E,texImage2D:X,texImage3D:K,pixelStorei:Re,getParameter:de,updateUBOMapping:Ne,uniformBlockBinding:ze,texStorage2D:oe,texStorage3D:ae,texSubImage2D:_,texSubImage3D:F,compressedTexSubImage2D:k,compressedTexSubImage3D:W,scissor:ge,viewport:fe,reset:Xe}}function lx(i,e,t,n,s,r,o){let a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new te,h=new WeakMap,d=new Set,u,f=new WeakMap,g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(E,_){return g?new OffscreenCanvas(E,_):qs("canvas")}function m(E,_,F){let k=1,W=je(E);if((W.width>F||W.height>F)&&(k=F/Math.max(W.width,W.height)),k<1)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){let oe=Math.floor(k*W.width),ae=Math.floor(k*W.height);u===void 0&&(u=y(oe,ae));let X=_?y(oe,ae):u;return X.width=oe,X.height=ae,X.getContext("2d").drawImage(E,0,0,oe,ae),De("WebGLRenderer: Texture has been resized from ("+W.width+"x"+W.height+") to ("+oe+"x"+ae+")."),X}else return"data"in E&&De("WebGLRenderer: Image in DataTexture is too big ("+W.width+"x"+W.height+")."),E;return E}function p(E){return E.generateMipmaps}function C(E){i.generateMipmap(E)}function T(E){return E.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:E.isWebGL3DRenderTarget?i.TEXTURE_3D:E.isWebGLArrayRenderTarget||E.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function x(E,_,F,k,W,oe=!1){if(E!==null){if(i[E]!==void 0)return i[E];De("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let ae;k&&(ae=e.get("EXT_texture_norm16"),ae||De("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let X=_;if(_===i.RED&&(F===i.FLOAT&&(X=i.R32F),F===i.HALF_FLOAT&&(X=i.R16F),F===i.UNSIGNED_BYTE&&(X=i.R8),F===i.UNSIGNED_SHORT&&ae&&(X=ae.R16_EXT),F===i.SHORT&&ae&&(X=ae.R16_SNORM_EXT)),_===i.RED_INTEGER&&(F===i.UNSIGNED_BYTE&&(X=i.R8UI),F===i.UNSIGNED_SHORT&&(X=i.R16UI),F===i.UNSIGNED_INT&&(X=i.R32UI),F===i.BYTE&&(X=i.R8I),F===i.SHORT&&(X=i.R16I),F===i.INT&&(X=i.R32I)),_===i.RG&&(F===i.FLOAT&&(X=i.RG32F),F===i.HALF_FLOAT&&(X=i.RG16F),F===i.UNSIGNED_BYTE&&(X=i.RG8),F===i.UNSIGNED_SHORT&&ae&&(X=ae.RG16_EXT),F===i.SHORT&&ae&&(X=ae.RG16_SNORM_EXT)),_===i.RG_INTEGER&&(F===i.UNSIGNED_BYTE&&(X=i.RG8UI),F===i.UNSIGNED_SHORT&&(X=i.RG16UI),F===i.UNSIGNED_INT&&(X=i.RG32UI),F===i.BYTE&&(X=i.RG8I),F===i.SHORT&&(X=i.RG16I),F===i.INT&&(X=i.RG32I)),_===i.RGB_INTEGER&&(F===i.UNSIGNED_BYTE&&(X=i.RGB8UI),F===i.UNSIGNED_SHORT&&(X=i.RGB16UI),F===i.UNSIGNED_INT&&(X=i.RGB32UI),F===i.BYTE&&(X=i.RGB8I),F===i.SHORT&&(X=i.RGB16I),F===i.INT&&(X=i.RGB32I)),_===i.RGBA_INTEGER&&(F===i.UNSIGNED_BYTE&&(X=i.RGBA8UI),F===i.UNSIGNED_SHORT&&(X=i.RGBA16UI),F===i.UNSIGNED_INT&&(X=i.RGBA32UI),F===i.BYTE&&(X=i.RGBA8I),F===i.SHORT&&(X=i.RGBA16I),F===i.INT&&(X=i.RGBA32I)),_===i.RGB&&(F===i.UNSIGNED_SHORT&&ae&&(X=ae.RGB16_EXT),F===i.SHORT&&ae&&(X=ae.RGB16_SNORM_EXT),F===i.UNSIGNED_INT_5_9_9_9_REV&&(X=i.RGB9_E5),F===i.UNSIGNED_INT_10F_11F_11F_REV&&(X=i.R11F_G11F_B10F)),_===i.RGBA){let K=oe?Xs:Qe.getTransfer(W);F===i.FLOAT&&(X=i.RGBA32F),F===i.HALF_FLOAT&&(X=i.RGBA16F),F===i.UNSIGNED_BYTE&&(X=K===it?i.SRGB8_ALPHA8:i.RGBA8),F===i.UNSIGNED_SHORT&&ae&&(X=ae.RGBA16_EXT),F===i.SHORT&&ae&&(X=ae.RGBA16_SNORM_EXT),F===i.UNSIGNED_SHORT_4_4_4_4&&(X=i.RGBA4),F===i.UNSIGNED_SHORT_5_5_5_1&&(X=i.RGB5_A1)}return(X===i.R16F||X===i.R32F||X===i.RG16F||X===i.RG32F||X===i.RGBA16F||X===i.RGBA32F)&&e.get("EXT_color_buffer_float"),X}function S(E,_){let F;return E?_===null||_===yn||_===Ms?F=i.DEPTH24_STENCIL8:_===bn?F=i.DEPTH32F_STENCIL8:_===bs&&(F=i.DEPTH24_STENCIL8,De("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===yn||_===Ms?F=i.DEPTH_COMPONENT24:_===bn?F=i.DEPTH_COMPONENT32F:_===bs&&(F=i.DEPTH_COMPONENT16),F}function M(E,_){return p(E)===!0||E.isFramebufferTexture&&E.minFilter!==Lt&&E.minFilter!==Ut?Math.log2(Math.max(_.width,_.height))+1:E.mipmaps!==void 0&&E.mipmaps.length>0?E.mipmaps.length:E.isCompressedTexture&&Array.isArray(E.image)?_.mipmaps.length:1}function A(E){let _=E.target;_.removeEventListener("dispose",A),w(_),_.isVideoTexture&&h.delete(_),_.isHTMLTexture&&d.delete(_)}function v(E){let _=E.target;_.removeEventListener("dispose",v),P(_)}function w(E){let _=n.get(E);if(_.__webglInit===void 0)return;let F=E.source,k=f.get(F);if(k){let W=k[_.__cacheKey];W.usedTimes--,W.usedTimes===0&&I(E),Object.keys(k).length===0&&f.delete(F)}n.remove(E)}function I(E){let _=n.get(E);i.deleteTexture(_.__webglTexture);let F=E.source,k=f.get(F);delete k[_.__cacheKey],o.memory.textures--}function P(E){let _=n.get(E);if(E.depthTexture&&(E.depthTexture.dispose(),n.remove(E.depthTexture)),E.isWebGLCubeRenderTarget)for(let k=0;k<6;k++){if(Array.isArray(_.__webglFramebuffer[k]))for(let W=0;W<_.__webglFramebuffer[k].length;W++)i.deleteFramebuffer(_.__webglFramebuffer[k][W]);else i.deleteFramebuffer(_.__webglFramebuffer[k]);_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer[k])}else{if(Array.isArray(_.__webglFramebuffer))for(let k=0;k<_.__webglFramebuffer.length;k++)i.deleteFramebuffer(_.__webglFramebuffer[k]);else i.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&i.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let k=0;k<_.__webglColorRenderbuffer.length;k++)_.__webglColorRenderbuffer[k]&&i.deleteRenderbuffer(_.__webglColorRenderbuffer[k]);_.__webglDepthRenderbuffer&&i.deleteRenderbuffer(_.__webglDepthRenderbuffer)}let F=E.textures;for(let k=0,W=F.length;k<W;k++){let oe=n.get(F[k]);oe.__webglTexture&&(i.deleteTexture(oe.__webglTexture),o.memory.textures--),n.remove(F[k])}n.remove(E)}let O=0;function q(){O=0}function Y(){return O}function U(E){O=E}function G(){let E=O;return E>=s.maxTextures&&De("WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+s.maxTextures),O+=1,E}function H(E){let _=[];return _.push(E.wrapS),_.push(E.wrapT),_.push(E.wrapR||0),_.push(E.magFilter),_.push(E.minFilter),_.push(E.anisotropy),_.push(E.internalFormat),_.push(E.format),_.push(E.type),_.push(E.generateMipmaps),_.push(E.premultiplyAlpha),_.push(E.flipY),_.push(E.unpackAlignment),_.push(E.colorSpace),_.join()}function j(E,_){let F=n.get(E);if(E.isVideoTexture&&L(E),E.isRenderTargetTexture===!1&&E.isExternalTexture!==!0&&E.version>0&&F.__version!==E.version){let k=E.image;if(k===null)De("WebGLRenderer: Texture marked for update but no image data found.");else if(k.complete===!1)De("WebGLRenderer: Texture marked for update but image is incomplete");else{Ie(F,E,_);return}}else E.isExternalTexture&&(F.__webglTexture=E.sourceTexture?E.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,F.__webglTexture,i.TEXTURE0+_)}function se(E,_){let F=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&F.__version!==E.version){Ie(F,E,_);return}else E.isExternalTexture&&(F.__webglTexture=E.sourceTexture?E.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,F.__webglTexture,i.TEXTURE0+_)}function ue(E,_){let F=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&F.__version!==E.version){Ie(F,E,_);return}t.bindTexture(i.TEXTURE_3D,F.__webglTexture,i.TEXTURE0+_)}function le(E,_){let F=n.get(E);if(E.isCubeDepthTexture!==!0&&E.version>0&&F.__version!==E.version){ke(F,E,_);return}t.bindTexture(i.TEXTURE_CUBE_MAP,F.__webglTexture,i.TEXTURE0+_)}let Me={[To]:i.REPEAT,[An]:i.CLAMP_TO_EDGE,[Ao]:i.MIRRORED_REPEAT},Je={[Lt]:i.NEAREST,[mu]:i.NEAREST_MIPMAP_NEAREST,[vr]:i.NEAREST_MIPMAP_LINEAR,[Ut]:i.LINEAR,[la]:i.LINEAR_MIPMAP_NEAREST,[pi]:i.LINEAR_MIPMAP_LINEAR},ct={[xu]:i.NEVER,[Su]:i.ALWAYS,[vu]:i.LESS,[qa]:i.LEQUAL,[yu]:i.EQUAL,[Ya]:i.GEQUAL,[bu]:i.GREATER,[Mu]:i.NOTEQUAL};function et(E,_){if(_.type===bn&&e.has("OES_texture_float_linear")===!1&&(_.magFilter===Ut||_.magFilter===la||_.magFilter===vr||_.magFilter===pi||_.minFilter===Ut||_.minFilter===la||_.minFilter===vr||_.minFilter===pi)&&De("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(E,i.TEXTURE_WRAP_S,Me[_.wrapS]),i.texParameteri(E,i.TEXTURE_WRAP_T,Me[_.wrapT]),(E===i.TEXTURE_3D||E===i.TEXTURE_2D_ARRAY)&&i.texParameteri(E,i.TEXTURE_WRAP_R,Me[_.wrapR]),i.texParameteri(E,i.TEXTURE_MAG_FILTER,Je[_.magFilter]),i.texParameteri(E,i.TEXTURE_MIN_FILTER,Je[_.minFilter]),_.compareFunction&&(i.texParameteri(E,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(E,i.TEXTURE_COMPARE_FUNC,ct[_.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===Lt||_.minFilter!==vr&&_.minFilter!==pi||_.type===bn&&e.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||n.get(_).__currentAnisotropy){let F=e.get("EXT_texture_filter_anisotropic");i.texParameterf(E,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,s.getMaxAnisotropy())),n.get(_).__currentAnisotropy=_.anisotropy}}}function J(E,_){let F=!1;E.__webglInit===void 0&&(E.__webglInit=!0,_.addEventListener("dispose",A));let k=_.source,W=f.get(k);W===void 0&&(W={},f.set(k,W));let oe=H(_);if(oe!==E.__cacheKey){W[oe]===void 0&&(W[oe]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,F=!0),W[oe].usedTimes++;let ae=W[E.__cacheKey];ae!==void 0&&(W[E.__cacheKey].usedTimes--,ae.usedTimes===0&&I(_)),E.__cacheKey=oe,E.__webglTexture=W[oe].texture}return F}function ce(E,_,F){return Math.floor(Math.floor(E/F)/_)}function re(E,_,F,k){let oe=E.updateRanges;if(oe.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,_.width,_.height,F,k,_.data);else{oe.sort((Re,ge)=>Re.start-ge.start);let ae=0;for(let Re=1;Re<oe.length;Re++){let ge=oe[ae],fe=oe[Re],Ne=ge.start+ge.count,ze=ce(fe.start,_.width,4),Xe=ce(ge.start,_.width,4);fe.start<=Ne+1&&ze===Xe&&ce(fe.start+fe.count-1,_.width,4)===ze?ge.count=Math.max(ge.count,fe.start+fe.count-ge.start):(++ae,oe[ae]=fe)}oe.length=ae+1;let X=t.getParameter(i.UNPACK_ROW_LENGTH),K=t.getParameter(i.UNPACK_SKIP_PIXELS),de=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,_.width);for(let Re=0,ge=oe.length;Re<ge;Re++){let fe=oe[Re],Ne=Math.floor(fe.start/4),ze=Math.ceil(fe.count/4),Xe=Ne%_.width,D=Math.floor(Ne/_.width),he=ze,$=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,Xe),t.pixelStorei(i.UNPACK_SKIP_ROWS,D),t.texSubImage2D(i.TEXTURE_2D,0,Xe,D,he,$,F,k,_.data)}E.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,X),t.pixelStorei(i.UNPACK_SKIP_PIXELS,K),t.pixelStorei(i.UNPACK_SKIP_ROWS,de)}}function Ie(E,_,F){let k=i.TEXTURE_2D;(_.isDataArrayTexture||_.isCompressedArrayTexture)&&(k=i.TEXTURE_2D_ARRAY),_.isData3DTexture&&(k=i.TEXTURE_3D);let W=J(E,_),oe=_.source;t.bindTexture(k,E.__webglTexture,i.TEXTURE0+F);let ae=n.get(oe);if(oe.version!==ae.__version||W===!0){if(t.activeTexture(i.TEXTURE0+F),(typeof ImageBitmap<"u"&&_.image instanceof ImageBitmap)===!1){let $=Qe.getPrimaries(Qe.workingColorSpace),pe=_.colorSpace===Xn?null:Qe.getPrimaries(_.colorSpace),be=_.colorSpace===Xn||$===pe?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,be)}t.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment);let K=m(_.image,!1,s.maxTextureSize);K=ot(_,K);let de=r.convert(_.format,_.colorSpace),Re=r.convert(_.type),ge=x(_.internalFormat,de,Re,_.normalized,_.colorSpace,_.isVideoTexture);et(k,_);let fe,Ne=_.mipmaps,ze=_.isVideoTexture!==!0,Xe=ae.__version===void 0||W===!0,D=oe.dataReady,he=M(_,K);if(_.isDepthTexture)ge=S(_.format===mi,_.type),Xe&&(ze?t.texStorage2D(i.TEXTURE_2D,1,ge,K.width,K.height):t.texImage2D(i.TEXTURE_2D,0,ge,K.width,K.height,0,de,Re,null));else if(_.isDataTexture)if(Ne.length>0){ze&&Xe&&t.texStorage2D(i.TEXTURE_2D,he,ge,Ne[0].width,Ne[0].height);for(let $=0,pe=Ne.length;$<pe;$++)fe=Ne[$],ze?D&&t.texSubImage2D(i.TEXTURE_2D,$,0,0,fe.width,fe.height,de,Re,fe.data):t.texImage2D(i.TEXTURE_2D,$,ge,fe.width,fe.height,0,de,Re,fe.data);_.generateMipmaps=!1}else ze?(Xe&&t.texStorage2D(i.TEXTURE_2D,he,ge,K.width,K.height),D&&re(_,K,de,Re)):t.texImage2D(i.TEXTURE_2D,0,ge,K.width,K.height,0,de,Re,K.data);else if(_.isCompressedTexture)if(_.isCompressedArrayTexture){ze&&Xe&&t.texStorage3D(i.TEXTURE_2D_ARRAY,he,ge,Ne[0].width,Ne[0].height,K.depth);for(let $=0,pe=Ne.length;$<pe;$++)if(fe=Ne[$],_.format!==cn)if(de!==null)if(ze){if(D)if(_.layerUpdates.size>0){let be=Sc(fe.width,fe.height,_.format,_.type);for(let ee of _.layerUpdates){let Ae=fe.data.subarray(ee*be/fe.data.BYTES_PER_ELEMENT,(ee+1)*be/fe.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,ee,fe.width,fe.height,1,de,Ae)}_.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,0,fe.width,fe.height,K.depth,de,fe.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,$,ge,fe.width,fe.height,K.depth,0,fe.data,0,0);else De("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ze?D&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,0,fe.width,fe.height,K.depth,de,Re,fe.data):t.texImage3D(i.TEXTURE_2D_ARRAY,$,ge,fe.width,fe.height,K.depth,0,de,Re,fe.data)}else{ze&&Xe&&t.texStorage2D(i.TEXTURE_2D,he,ge,Ne[0].width,Ne[0].height);for(let $=0,pe=Ne.length;$<pe;$++)fe=Ne[$],_.format!==cn?de!==null?ze?D&&t.compressedTexSubImage2D(i.TEXTURE_2D,$,0,0,fe.width,fe.height,de,fe.data):t.compressedTexImage2D(i.TEXTURE_2D,$,ge,fe.width,fe.height,0,fe.data):De("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ze?D&&t.texSubImage2D(i.TEXTURE_2D,$,0,0,fe.width,fe.height,de,Re,fe.data):t.texImage2D(i.TEXTURE_2D,$,ge,fe.width,fe.height,0,de,Re,fe.data)}else if(_.isDataArrayTexture)if(ze){if(Xe&&t.texStorage3D(i.TEXTURE_2D_ARRAY,he,ge,K.width,K.height,K.depth),D)if(_.layerUpdates.size>0){let $=Sc(K.width,K.height,_.format,_.type);for(let pe of _.layerUpdates){let be=K.data.subarray(pe*$/K.data.BYTES_PER_ELEMENT,(pe+1)*$/K.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,pe,K.width,K.height,1,de,Re,be)}_.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,K.width,K.height,K.depth,de,Re,K.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,ge,K.width,K.height,K.depth,0,de,Re,K.data);else if(_.isData3DTexture)ze?(Xe&&t.texStorage3D(i.TEXTURE_3D,he,ge,K.width,K.height,K.depth),D&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,K.width,K.height,K.depth,de,Re,K.data)):t.texImage3D(i.TEXTURE_3D,0,ge,K.width,K.height,K.depth,0,de,Re,K.data);else if(_.isFramebufferTexture){if(Xe)if(ze)t.texStorage2D(i.TEXTURE_2D,he,ge,K.width,K.height);else{let $=K.width,pe=K.height;for(let be=0;be<he;be++)t.texImage2D(i.TEXTURE_2D,be,ge,$,pe,0,de,Re,null),$>>=1,pe>>=1}}else if(_.isHTMLTexture){if("texElementImage2D"in i){let $=i.canvas;if($.hasAttribute("layoutsubtree")||$.setAttribute("layoutsubtree","true"),K.parentNode!==$){$.appendChild(K),d.add(_),$.onpaint=pe=>{let be=pe.changedElements;for(let ee of d)be.includes(ee.image)&&(ee.needsUpdate=!0)},$.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,K);else{let be=i.RGBA,ee=i.RGBA,Ae=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,be,ee,Ae,K)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(Ne.length>0){if(ze&&Xe){let $=je(Ne[0]);t.texStorage2D(i.TEXTURE_2D,he,ge,$.width,$.height)}for(let $=0,pe=Ne.length;$<pe;$++)fe=Ne[$],ze?D&&t.texSubImage2D(i.TEXTURE_2D,$,0,0,de,Re,fe):t.texImage2D(i.TEXTURE_2D,$,ge,de,Re,fe);_.generateMipmaps=!1}else if(ze){if(Xe){let $=je(K);t.texStorage2D(i.TEXTURE_2D,he,ge,$.width,$.height)}D&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,de,Re,K)}else t.texImage2D(i.TEXTURE_2D,0,ge,de,Re,K);p(_)&&C(k),ae.__version=oe.version,_.onUpdate&&_.onUpdate(_)}E.__version=_.version}function ke(E,_,F){if(_.image.length!==6)return;let k=J(E,_),W=_.source;t.bindTexture(i.TEXTURE_CUBE_MAP,E.__webglTexture,i.TEXTURE0+F);let oe=n.get(W);if(W.version!==oe.__version||k===!0){t.activeTexture(i.TEXTURE0+F);let ae=Qe.getPrimaries(Qe.workingColorSpace),X=_.colorSpace===Xn?null:Qe.getPrimaries(_.colorSpace),K=_.colorSpace===Xn||ae===X?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),t.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,K);let de=_.isCompressedTexture||_.image[0].isCompressedTexture,Re=_.image[0]&&_.image[0].isDataTexture,ge=[];for(let ee=0;ee<6;ee++)!de&&!Re?ge[ee]=m(_.image[ee],!0,s.maxCubemapSize):ge[ee]=Re?_.image[ee].image:_.image[ee],ge[ee]=ot(_,ge[ee]);let fe=ge[0],Ne=r.convert(_.format,_.colorSpace),ze=r.convert(_.type),Xe=x(_.internalFormat,Ne,ze,_.normalized,_.colorSpace),D=_.isVideoTexture!==!0,he=oe.__version===void 0||k===!0,$=W.dataReady,pe=M(_,fe);et(i.TEXTURE_CUBE_MAP,_);let be;if(de){D&&he&&t.texStorage2D(i.TEXTURE_CUBE_MAP,pe,Xe,fe.width,fe.height);for(let ee=0;ee<6;ee++){be=ge[ee].mipmaps;for(let Ae=0;Ae<be.length;Ae++){let we=be[Ae];_.format!==cn?Ne!==null?D?$&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Ae,0,0,we.width,we.height,Ne,we.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Ae,Xe,we.width,we.height,0,we.data):De("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):D?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Ae,0,0,we.width,we.height,Ne,ze,we.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Ae,Xe,we.width,we.height,0,Ne,ze,we.data)}}}else{if(be=_.mipmaps,D&&he){be.length>0&&pe++;let ee=je(ge[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,pe,Xe,ee.width,ee.height)}for(let ee=0;ee<6;ee++)if(Re){D?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,ge[ee].width,ge[ee].height,Ne,ze,ge[ee].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,Xe,ge[ee].width,ge[ee].height,0,Ne,ze,ge[ee].data);for(let Ae=0;Ae<be.length;Ae++){let vt=be[Ae].image[ee].image;D?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Ae+1,0,0,vt.width,vt.height,Ne,ze,vt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Ae+1,Xe,vt.width,vt.height,0,Ne,ze,vt.data)}}else{D?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,Ne,ze,ge[ee]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,Xe,Ne,ze,ge[ee]);for(let Ae=0;Ae<be.length;Ae++){let we=be[Ae];D?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Ae+1,0,0,Ne,ze,we.image[ee]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,Ae+1,Xe,Ne,ze,we.image[ee])}}}p(_)&&C(i.TEXTURE_CUBE_MAP),oe.__version=W.version,_.onUpdate&&_.onUpdate(_)}E.__version=_.version}function Ue(E,_,F,k,W,oe){let ae=r.convert(F.format,F.colorSpace),X=r.convert(F.type),K=x(F.internalFormat,ae,X,F.normalized,F.colorSpace),de=n.get(_),Re=n.get(F);if(Re.__renderTarget=_,!de.__hasExternalTextures){let ge=Math.max(1,_.width>>oe),fe=Math.max(1,_.height>>oe);W===i.TEXTURE_3D||W===i.TEXTURE_2D_ARRAY?t.texImage3D(W,oe,K,ge,fe,_.depth,0,ae,X,null):t.texImage2D(W,oe,K,ge,fe,0,ae,X,null)}t.bindFramebuffer(i.FRAMEBUFFER,E),We(_)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,k,W,Re.__webglTexture,0,Ve(_)):(W===i.TEXTURE_2D||W>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&W<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,k,W,Re.__webglTexture,oe),t.bindFramebuffer(i.FRAMEBUFFER,null)}function nt(E,_,F){if(i.bindRenderbuffer(i.RENDERBUFFER,E),_.depthBuffer){let k=_.depthTexture,W=k&&k.isDepthTexture?k.type:null,oe=S(_.stencilBuffer,W),ae=_.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;We(_)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Ve(_),oe,_.width,_.height):F?i.renderbufferStorageMultisample(i.RENDERBUFFER,Ve(_),oe,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,oe,_.width,_.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ae,i.RENDERBUFFER,E)}else{let k=_.textures;for(let W=0;W<k.length;W++){let oe=k[W],ae=r.convert(oe.format,oe.colorSpace),X=r.convert(oe.type),K=x(oe.internalFormat,ae,X,oe.normalized,oe.colorSpace);We(_)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Ve(_),K,_.width,_.height):F?i.renderbufferStorageMultisample(i.RENDERBUFFER,Ve(_),K,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,K,_.width,_.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function He(E,_,F){let k=_.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,E),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let W=n.get(_.depthTexture);if(W.__renderTarget=_,(!W.__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)&&(_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0),k){if(W.__webglInit===void 0&&(W.__webglInit=!0,_.depthTexture.addEventListener("dispose",A)),W.__webglTexture===void 0){W.__webglTexture=i.createTexture(),t.bindTexture(i.TEXTURE_CUBE_MAP,W.__webglTexture),et(i.TEXTURE_CUBE_MAP,_.depthTexture);let de=r.convert(_.depthTexture.format),Re=r.convert(_.depthTexture.type),ge;_.depthTexture.format===Rn?ge=i.DEPTH_COMPONENT24:_.depthTexture.format===mi&&(ge=i.DEPTH24_STENCIL8);for(let fe=0;fe<6;fe++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,ge,_.width,_.height,0,de,Re,null)}}else j(_.depthTexture,0);let oe=W.__webglTexture,ae=Ve(_),X=k?i.TEXTURE_CUBE_MAP_POSITIVE_X+F:i.TEXTURE_2D,K=_.depthTexture.format===mi?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(_.depthTexture.format===Rn)We(_)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,K,X,oe,0,ae):i.framebufferTexture2D(i.FRAMEBUFFER,K,X,oe,0);else if(_.depthTexture.format===mi)We(_)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,K,X,oe,0,ae):i.framebufferTexture2D(i.FRAMEBUFFER,K,X,oe,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Q(E){let _=n.get(E),F=E.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==E.depthTexture){let k=E.depthTexture;if(_.__depthDisposeCallback&&_.__depthDisposeCallback(),k){let W=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,k.removeEventListener("dispose",W)};k.addEventListener("dispose",W),_.__depthDisposeCallback=W}_.__boundDepthTexture=k}if(E.depthTexture&&!_.__autoAllocateDepthBuffer)if(F)for(let k=0;k<6;k++)He(_.__webglFramebuffer[k],E,k);else{let k=E.texture.mipmaps;k&&k.length>0?He(_.__webglFramebuffer[0],E,0):He(_.__webglFramebuffer,E,0)}else if(F){_.__webglDepthbuffer=[];for(let k=0;k<6;k++)if(t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[k]),_.__webglDepthbuffer[k]===void 0)_.__webglDepthbuffer[k]=i.createRenderbuffer(),nt(_.__webglDepthbuffer[k],E,!1);else{let W=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,oe=_.__webglDepthbuffer[k];i.bindRenderbuffer(i.RENDERBUFFER,oe),i.framebufferRenderbuffer(i.FRAMEBUFFER,W,i.RENDERBUFFER,oe)}}else{let k=E.texture.mipmaps;if(k&&k.length>0?t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=i.createRenderbuffer(),nt(_.__webglDepthbuffer,E,!1);else{let W=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,oe=_.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,oe),i.framebufferRenderbuffer(i.FRAMEBUFFER,W,i.RENDERBUFFER,oe)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function ie(E,_,F){let k=n.get(E);_!==void 0&&Ue(k.__webglFramebuffer,E,E.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),F!==void 0&&Q(E)}function ne(E){let _=E.texture,F=n.get(E),k=n.get(_);E.addEventListener("dispose",v);let W=E.textures,oe=E.isWebGLCubeRenderTarget===!0,ae=W.length>1;if(ae||(k.__webglTexture===void 0&&(k.__webglTexture=i.createTexture()),k.__version=_.version,o.memory.textures++),oe){F.__webglFramebuffer=[];for(let X=0;X<6;X++)if(_.mipmaps&&_.mipmaps.length>0){F.__webglFramebuffer[X]=[];for(let K=0;K<_.mipmaps.length;K++)F.__webglFramebuffer[X][K]=i.createFramebuffer()}else F.__webglFramebuffer[X]=i.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){F.__webglFramebuffer=[];for(let X=0;X<_.mipmaps.length;X++)F.__webglFramebuffer[X]=i.createFramebuffer()}else F.__webglFramebuffer=i.createFramebuffer();if(ae)for(let X=0,K=W.length;X<K;X++){let de=n.get(W[X]);de.__webglTexture===void 0&&(de.__webglTexture=i.createTexture(),o.memory.textures++)}if(E.samples>0&&We(E)===!1){F.__webglMultisampledFramebuffer=i.createFramebuffer(),F.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let X=0;X<W.length;X++){let K=W[X];F.__webglColorRenderbuffer[X]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,F.__webglColorRenderbuffer[X]);let de=r.convert(K.format,K.colorSpace),Re=r.convert(K.type),ge=x(K.internalFormat,de,Re,K.normalized,K.colorSpace,E.isXRRenderTarget===!0),fe=Ve(E);i.renderbufferStorageMultisample(i.RENDERBUFFER,fe,ge,E.width,E.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+X,i.RENDERBUFFER,F.__webglColorRenderbuffer[X])}i.bindRenderbuffer(i.RENDERBUFFER,null),E.depthBuffer&&(F.__webglDepthRenderbuffer=i.createRenderbuffer(),nt(F.__webglDepthRenderbuffer,E,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(oe){t.bindTexture(i.TEXTURE_CUBE_MAP,k.__webglTexture),et(i.TEXTURE_CUBE_MAP,_);for(let X=0;X<6;X++)if(_.mipmaps&&_.mipmaps.length>0)for(let K=0;K<_.mipmaps.length;K++)Ue(F.__webglFramebuffer[X][K],E,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+X,K);else Ue(F.__webglFramebuffer[X],E,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+X,0);p(_)&&C(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ae){for(let X=0,K=W.length;X<K;X++){let de=W[X],Re=n.get(de),ge=i.TEXTURE_2D;(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(ge=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(ge,Re.__webglTexture),et(ge,de),Ue(F.__webglFramebuffer,E,de,i.COLOR_ATTACHMENT0+X,ge,0),p(de)&&C(ge)}t.unbindTexture()}else{let X=i.TEXTURE_2D;if((E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(X=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(X,k.__webglTexture),et(X,_),_.mipmaps&&_.mipmaps.length>0)for(let K=0;K<_.mipmaps.length;K++)Ue(F.__webglFramebuffer[K],E,_,i.COLOR_ATTACHMENT0,X,K);else Ue(F.__webglFramebuffer,E,_,i.COLOR_ATTACHMENT0,X,0);p(_)&&C(X),t.unbindTexture()}E.depthBuffer&&Q(E)}function xe(E){let _=E.textures;for(let F=0,k=_.length;F<k;F++){let W=_[F];if(p(W)){let oe=T(E),ae=n.get(W).__webglTexture;t.bindTexture(oe,ae),C(oe),t.unbindTexture()}}}let me=[],Be=[];function Ce(E){if(E.samples>0){if(We(E)===!1){let _=E.textures,F=E.width,k=E.height,W=i.COLOR_BUFFER_BIT,oe=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ae=n.get(E),X=_.length>1;if(X)for(let de=0;de<_.length;de++)t.bindFramebuffer(i.FRAMEBUFFER,ae.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+de,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,ae.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+de,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,ae.__webglMultisampledFramebuffer);let K=E.texture.mipmaps;K&&K.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ae.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ae.__webglFramebuffer);for(let de=0;de<_.length;de++){if(E.resolveDepthBuffer&&(E.depthBuffer&&(W|=i.DEPTH_BUFFER_BIT),E.stencilBuffer&&E.resolveStencilBuffer&&(W|=i.STENCIL_BUFFER_BIT)),X){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,ae.__webglColorRenderbuffer[de]);let Re=n.get(_[de]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Re,0)}i.blitFramebuffer(0,0,F,k,0,0,F,k,W,i.NEAREST),l===!0&&(me.length=0,Be.length=0,me.push(i.COLOR_ATTACHMENT0+de),E.depthBuffer&&E.resolveDepthBuffer===!1&&(me.push(oe),Be.push(oe),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,Be)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,me))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),X)for(let de=0;de<_.length;de++){t.bindFramebuffer(i.FRAMEBUFFER,ae.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+de,i.RENDERBUFFER,ae.__webglColorRenderbuffer[de]);let Re=n.get(_[de]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,ae.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+de,i.TEXTURE_2D,Re,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ae.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.resolveDepthBuffer===!1&&l){let _=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[_])}}}function Ve(E){return Math.min(s.maxSamples,E.samples)}function We(E){let _=n.get(E);return E.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function L(E){let _=o.render.frame;h.get(E)!==_&&(h.set(E,_),E.update())}function ot(E,_){let F=E.colorSpace,k=E.format,W=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||F!==Ws&&F!==Xn&&(Qe.getTransfer(F)===it?(k!==cn||W!==Yt)&&De("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Fe("WebGLTextures: Unsupported texture color space:",F)),_}function je(E){return typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement?(c.width=E.naturalWidth||E.width,c.height=E.naturalHeight||E.height):typeof VideoFrame<"u"&&E instanceof VideoFrame?(c.width=E.displayWidth,c.height=E.displayHeight):(c.width=E.width,c.height=E.height),c}this.allocateTextureUnit=G,this.resetTextureUnits=q,this.getTextureUnits=Y,this.setTextureUnits=U,this.setTexture2D=j,this.setTexture2DArray=se,this.setTexture3D=ue,this.setTextureCube=le,this.rebindTextures=ie,this.setupRenderTarget=ne,this.updateRenderTargetMipmap=xe,this.updateMultisampleRenderTarget=Ce,this.setupDepthRenderbuffer=Q,this.setupFrameBufferTexture=Ue,this.useMultisampledRTT=We,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function cx(i,e){function t(n,s=Xn){let r,o=Qe.getTransfer(s);if(n===Yt)return i.UNSIGNED_BYTE;if(n===ha)return i.UNSIGNED_SHORT_4_4_4_4;if(n===ua)return i.UNSIGNED_SHORT_5_5_5_1;if(n===uc)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===dc)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===cc)return i.BYTE;if(n===hc)return i.SHORT;if(n===bs)return i.UNSIGNED_SHORT;if(n===ca)return i.INT;if(n===yn)return i.UNSIGNED_INT;if(n===bn)return i.FLOAT;if(n===Ln)return i.HALF_FLOAT;if(n===fc)return i.ALPHA;if(n===pc)return i.RGB;if(n===cn)return i.RGBA;if(n===Rn)return i.DEPTH_COMPONENT;if(n===mi)return i.DEPTH_STENCIL;if(n===mc)return i.RED;if(n===da)return i.RED_INTEGER;if(n===gi)return i.RG;if(n===fa)return i.RG_INTEGER;if(n===pa)return i.RGBA_INTEGER;if(n===yr||n===br||n===Mr||n===Sr)if(o===it)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===yr)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===br)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Mr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Sr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===yr)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===br)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Mr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Sr)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===ma||n===ga||n===_a||n===xa)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===ma)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ga)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===_a)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===xa)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===va||n===ya||n===ba||n===Ma||n===Sa||n===Er||n===Ea)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===va||n===ya)return o===it?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===ba)return o===it?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Ma)return r.COMPRESSED_R11_EAC;if(n===Sa)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Er)return r.COMPRESSED_RG11_EAC;if(n===Ea)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===wa||n===Ta||n===Aa||n===Ca||n===Ra||n===Pa||n===Ia||n===La||n===Da||n===Na||n===Ua||n===Fa||n===Oa||n===Ba)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===wa)return o===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Ta)return o===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Aa)return o===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Ca)return o===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Ra)return o===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Pa)return o===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Ia)return o===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===La)return o===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Da)return o===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Na)return o===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Ua)return o===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Fa)return o===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Oa)return o===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Ba)return o===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===za||n===ka||n===Va)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===za)return o===it?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ka)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Va)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Ha||n===Ga||n===wr||n===Wa)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===Ha)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Ga)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===wr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Wa)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ms?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}var hx=`
|
|
4090
4090
|
void main() {
|
|
4091
4091
|
|
|
4092
4092
|
gl_Position = vec4( position, 1.0 );
|
|
4093
4093
|
|
|
4094
|
-
}`,
|
|
4094
|
+
}`,ux=`
|
|
4095
4095
|
uniform sampler2DArray depthColor;
|
|
4096
4096
|
uniform float depthWidth;
|
|
4097
4097
|
uniform float depthHeight;
|
|
@@ -4110,7 +4110,7 @@ void main() {
|
|
|
4110
4110
|
|
|
4111
4111
|
}
|
|
4112
4112
|
|
|
4113
|
-
}`,Fc=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new tr(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new tn({vertexShader:ax,fragmentShader:ox,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new wt(new si(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Oc=class extends mn{constructor(e,t){super();let n=this,s=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,d=null,u=null,f=null,g=null,b=typeof XRWebGLBinding<"u",m=new Fc,p={},C=t.getContextAttributes(),w=null,_=null,S=[],M=[],A=new ee,y=null,T=new Vt;T.viewport=new gt;let I=new Vt;I.viewport=new gt;let P=[T,I],F=new so,G=null,X=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let ce=S[$];return ce===void 0&&(ce=new cs,S[$]=ce),ce.getTargetRaySpace()},this.getControllerGrip=function($){let ce=S[$];return ce===void 0&&(ce=new cs,S[$]=ce),ce.getGripSpace()},this.getHand=function($){let ce=S[$];return ce===void 0&&(ce=new cs,S[$]=ce),ce.getHandSpace()};function O($){let ce=M.indexOf($.inputSource);if(ce===-1)return;let re=S[ce];re!==void 0&&(re.update($.inputSource,$.frame,c||a),re.dispatchEvent({type:$.type,data:$.inputSource}))}function W(){s.removeEventListener("select",O),s.removeEventListener("selectstart",O),s.removeEventListener("selectend",O),s.removeEventListener("squeeze",O),s.removeEventListener("squeezestart",O),s.removeEventListener("squeezeend",O),s.removeEventListener("end",W),s.removeEventListener("inputsourceschange",H);for(let $=0;$<S.length;$++){let ce=M[$];ce!==null&&(M[$]=null,S[$].disconnect(ce))}G=null,X=null,m.reset();for(let $ in p)delete p[$];e.setRenderTarget(w),f=null,u=null,d=null,s=null,_=null,Qe.stop(),n.isPresenting=!1,e.setPixelRatio(y),e.setSize(A.width,A.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function($){r=$,n.isPresenting===!0&&De("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function($){o=$,n.isPresenting===!0&&De("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function($){c=$},this.getBaseLayer=function(){return u!==null?u:f},this.getBinding=function(){return d===null&&b&&(d=new XRWebGLBinding(s,t)),d},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function($){if(s=$,s!==null){if(w=e.getRenderTarget(),s.addEventListener("select",O),s.addEventListener("selectstart",O),s.addEventListener("selectend",O),s.addEventListener("squeeze",O),s.addEventListener("squeezestart",O),s.addEventListener("squeezeend",O),s.addEventListener("end",W),s.addEventListener("inputsourceschange",H),C.xrCompatible!==!0&&await t.makeXRCompatible(),y=e.getPixelRatio(),e.getSize(A),b&&"createProjectionLayer"in XRWebGLBinding.prototype){let re=null,Ie=null,ze=null;C.depth&&(ze=C.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,re=C.stencil?pi:Rn,Ie=C.stencil?vs:vn);let Ue={colorFormat:t.RGBA8,depthFormat:ze,scaleFactor:r};d=this.getBinding(),u=d.createProjectionLayer(Ue),s.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),_=new Qt(u.textureWidth,u.textureHeight,{format:cn,type:Yt,depthTexture:new Wn(u.textureWidth,u.textureHeight,Ie,void 0,void 0,void 0,void 0,void 0,void 0,re),stencilBuffer:C.stencil,colorSpace:e.outputColorSpace,samples:C.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{let re={antialias:C.antialias,alpha:!0,depth:C.depth,stencil:C.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(s,t,re),s.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),_=new Qt(f.framebufferWidth,f.framebufferHeight,{format:cn,type:Yt,colorSpace:e.outputColorSpace,stencilBuffer:C.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await s.requestReferenceSpace(o),Qe.setContext(s),Qe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function H($){for(let ce=0;ce<$.removed.length;ce++){let re=$.removed[ce],Ie=M.indexOf(re);Ie>=0&&(M[Ie]=null,S[Ie].disconnect(re))}for(let ce=0;ce<$.added.length;ce++){let re=$.added[ce],Ie=M.indexOf(re);if(Ie===-1){for(let Ue=0;Ue<S.length;Ue++)if(Ue>=M.length){M.push(re),Ie=Ue;break}else if(M[Ue]===null){M[Ue]=re,Ie=Ue;break}if(Ie===-1)break}let ze=S[Ie];ze&&ze.connect(re)}}let K=new R,ie=new R;function ue($,ce,re){K.setFromMatrixPosition(ce.matrixWorld),ie.setFromMatrixPosition(re.matrixWorld);let Ie=K.distanceTo(ie),ze=ce.projectionMatrix.elements,Ue=re.projectionMatrix.elements,nt=ze[14]/(ze[10]-1),Ve=ze[14]/(ze[10]+1),j=(ze[9]+1)/ze[5],ne=(ze[9]-1)/ze[5],te=(ze[8]-1)/ze[0],xe=(Ue[8]+1)/Ue[0],me=nt*te,Oe=nt*xe,Ce=Ie/(-te+xe),ke=Ce*-te;if(ce.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(ke),$.translateZ(Ce),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert(),ze[10]===-1)$.projectionMatrix.copy(ce.projectionMatrix),$.projectionMatrixInverse.copy(ce.projectionMatrixInverse);else{let Ge=nt+Ce,L=Ve+Ce,at=me-ke,Ke=Oe+(Ie-ke),E=j*Ve/L*Ge,x=ne*Ve/L*Ge;$.projectionMatrix.makePerspective(at,Ke,E,x,Ge,L),$.projectionMatrixInverse.copy($.projectionMatrix).invert()}}function le($,ce){ce===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(ce.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(s===null)return;let ce=$.near,re=$.far;m.texture!==null&&(m.depthNear>0&&(ce=m.depthNear),m.depthFar>0&&(re=m.depthFar)),F.near=I.near=T.near=ce,F.far=I.far=T.far=re,(G!==F.near||X!==F.far)&&(s.updateRenderState({depthNear:F.near,depthFar:F.far}),G=F.near,X=F.far),F.layers.mask=$.layers.mask|6,T.layers.mask=F.layers.mask&-5,I.layers.mask=F.layers.mask&-3;let Ie=$.parent,ze=F.cameras;le(F,Ie);for(let Ue=0;Ue<ze.length;Ue++)le(ze[Ue],Ie);ze.length===2?ue(F,T,I):F.projectionMatrix.copy(T.projectionMatrix),Me($,F,Ie)};function Me($,ce,re){re===null?$.matrix.copy(ce.matrixWorld):($.matrix.copy(re.matrixWorld),$.matrix.invert(),$.matrix.multiply(ce.matrixWorld)),$.matrix.decompose($.position,$.quaternion,$.scale),$.updateMatrixWorld(!0),$.projectionMatrix.copy(ce.projectionMatrix),$.projectionMatrixInverse.copy(ce.projectionMatrixInverse),$.isPerspectiveCamera&&($.fov=as*2*Math.atan(1/$.projectionMatrix.elements[5]),$.zoom=1)}this.getCamera=function(){return F},this.getFoveation=function(){if(!(u===null&&f===null))return l},this.setFoveation=function($){l=$,u!==null&&(u.fixedFoveation=$),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=$)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(F)},this.getCameraTexture=function($){return p[$]};let $e=null;function ct($,ce){if(h=ce.getViewerPose(c||a),g=ce,h!==null){let re=h.views;f!==null&&(e.setRenderTargetFramebuffer(_,f.framebuffer),e.setRenderTarget(_));let Ie=!1;re.length!==F.cameras.length&&(F.cameras.length=0,Ie=!0);for(let Ve=0;Ve<re.length;Ve++){let j=re[Ve],ne=null;if(f!==null)ne=f.getViewport(j);else{let xe=d.getViewSubImage(u,j);ne=xe.viewport,Ve===0&&(e.setRenderTargetTextures(_,xe.colorTexture,xe.depthStencilTexture),e.setRenderTarget(_))}let te=P[Ve];te===void 0&&(te=new Vt,te.layers.enable(Ve),te.viewport=new gt,P[Ve]=te),te.matrix.fromArray(j.transform.matrix),te.matrix.decompose(te.position,te.quaternion,te.scale),te.projectionMatrix.fromArray(j.projectionMatrix),te.projectionMatrixInverse.copy(te.projectionMatrix).invert(),te.viewport.set(ne.x,ne.y,ne.width,ne.height),Ve===0&&(F.matrix.copy(te.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale)),Ie===!0&&F.cameras.push(te)}let ze=s.enabledFeatures;if(ze&&ze.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&b){d=n.getBinding();let Ve=d.getDepthInformation(re[0]);Ve&&Ve.isValid&&Ve.texture&&m.init(Ve,s.renderState)}if(ze&&ze.includes("camera-access")&&b){e.state.unbindTexture(),d=n.getBinding();for(let Ve=0;Ve<re.length;Ve++){let j=re[Ve].camera;if(j){let ne=p[j];ne||(ne=new tr,p[j]=ne);let te=d.getCameraImage(j);ne.sourceTexture=te}}}}for(let re=0;re<S.length;re++){let Ie=M[re],ze=S[re];Ie!==null&&ze!==void 0&&ze.update(Ie,ce,c||a)}$e&&$e($,ce),ce.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ce}),g=null}let Qe=new nd;Qe.setAnimationLoop(ct),this.setAnimationLoop=function($){$e=$},this.dispose=function(){}}},lx=new rt,ld=new He;ld.set(-1,0,0,0,1,0,0,0,1);function cx(i,e){function t(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,yc(i)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function s(m,p,C,w,_){p.isNodeMaterial?p.uniformsNeedUpdate=!1:p.isMeshBasicMaterial?r(m,p):p.isMeshLambertMaterial?(r(m,p),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)):p.isMeshToonMaterial?(r(m,p),d(m,p)):p.isMeshPhongMaterial?(r(m,p),h(m,p),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)):p.isMeshStandardMaterial?(r(m,p),u(m,p),p.isMeshPhysicalMaterial&&f(m,p,_)):p.isMeshMatcapMaterial?(r(m,p),g(m,p)):p.isMeshDepthMaterial?r(m,p):p.isMeshDistanceMaterial?(r(m,p),b(m,p)):p.isMeshNormalMaterial?r(m,p):p.isLineBasicMaterial?(a(m,p),p.isLineDashedMaterial&&o(m,p)):p.isPointsMaterial?l(m,p,C,w):p.isSpriteMaterial?c(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,t(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===qt&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,t(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===qt&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,t(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,t(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);let C=e.get(p),w=C.envMap,_=C.envMapRotation;w&&(m.envMap.value=w,m.envMapRotation.value.setFromMatrix4(lx.makeRotationFromEuler(_)).transpose(),w.isCubeTexture&&w.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(ld),m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,m.aoMapTransform))}function a(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform))}function o(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function l(m,p,C,w){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*C,m.scale.value=w*.5,p.map&&(m.map.value=p.map,t(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function c(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function h(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function d(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function u(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,C){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===qt&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=C.texture,m.transmissionSamplerSize.value.set(C.width,C.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function b(m,p){let C=e.get(p).light;m.referencePosition.value.setFromMatrixPosition(C.matrixWorld),m.nearDistance.value=C.shadow.camera.near,m.farDistance.value=C.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function hx(i,e,t,n){let s={},r={},a=[],o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(_,S){let M=S.program;n.uniformBlockBinding(_,M)}function c(_,S){let M=s[_.id];M===void 0&&(m(_),M=h(_),s[_.id]=M,_.addEventListener("dispose",C));let A=S.program;n.updateUBOMapping(_,A);let y=e.render.frame;r[_.id]!==y&&(u(_),r[_.id]=y)}function h(_){let S=d();_.__bindingPointIndex=S;let M=i.createBuffer(),A=_.__size,y=_.usage;return i.bindBuffer(i.UNIFORM_BUFFER,M),i.bufferData(i.UNIFORM_BUFFER,A,y),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,S,M),M}function d(){for(let _=0;_<o;_++)if(a.indexOf(_)===-1)return a.push(_),_;return Fe("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(_){let S=s[_.id],M=_.uniforms,A=_.__cache;i.bindBuffer(i.UNIFORM_BUFFER,S);for(let y=0,T=M.length;y<T;y++){let I=M[y];if(Array.isArray(I))for(let P=0,F=I.length;P<F;P++)f(I[P],y,P,A);else f(I,y,0,A)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function f(_,S,M,A){if(b(_,S,M,A)===!0){let y=_.__offset,T=_.value;if(Array.isArray(T)){let I=0;for(let P=0;P<T.length;P++){let F=T[P],G=p(F);g(F,_.__data,I),typeof F!="number"&&typeof F!="boolean"&&!F.isMatrix3&&!ArrayBuffer.isView(F)&&(I+=G.storage/Float32Array.BYTES_PER_ELEMENT)}}else g(T,_.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,y,_.__data)}}function g(_,S,M){typeof _=="number"||typeof _=="boolean"?S[0]=_:_.isMatrix3?(S[0]=_.elements[0],S[1]=_.elements[1],S[2]=_.elements[2],S[3]=0,S[4]=_.elements[3],S[5]=_.elements[4],S[6]=_.elements[5],S[7]=0,S[8]=_.elements[6],S[9]=_.elements[7],S[10]=_.elements[8],S[11]=0):ArrayBuffer.isView(_)?S.set(new _.constructor(_.buffer,_.byteOffset,S.length)):_.toArray(S,M)}function b(_,S,M,A){let y=_.value,T=S+"_"+M;if(A[T]===void 0)return typeof y=="number"||typeof y=="boolean"?A[T]=y:ArrayBuffer.isView(y)?A[T]=y.slice():A[T]=y.clone(),!0;{let I=A[T];if(typeof y=="number"||typeof y=="boolean"){if(I!==y)return A[T]=y,!0}else{if(ArrayBuffer.isView(y))return!0;if(I.equals(y)===!1)return I.copy(y),!0}}return!1}function m(_){let S=_.uniforms,M=0,A=16;for(let T=0,I=S.length;T<I;T++){let P=Array.isArray(S[T])?S[T]:[S[T]];for(let F=0,G=P.length;F<G;F++){let X=P[F],O=Array.isArray(X.value)?X.value:[X.value];for(let W=0,H=O.length;W<H;W++){let K=O[W],ie=p(K),ue=M%A,le=ue%ie.boundary,Me=ue+le;M+=le,Me!==0&&A-Me<ie.storage&&(M+=A-Me),X.__data=new Float32Array(ie.storage/Float32Array.BYTES_PER_ELEMENT),X.__offset=M,M+=ie.storage}}}let y=M%A;return y>0&&(M+=A-y),_.__size=M,_.__cache={},this}function p(_){let S={boundary:0,storage:0};return typeof _=="number"||typeof _=="boolean"?(S.boundary=4,S.storage=4):_.isVector2?(S.boundary=8,S.storage=8):_.isVector3||_.isColor?(S.boundary=16,S.storage=12):_.isVector4?(S.boundary=16,S.storage=16):_.isMatrix3?(S.boundary=48,S.storage=48):_.isMatrix4?(S.boundary=64,S.storage=64):_.isTexture?De("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(_)?(S.boundary=16,S.storage=_.byteLength):De("WebGLRenderer: Unsupported uniform value type.",_),S}function C(_){let S=_.target;S.removeEventListener("dispose",C);let M=a.indexOf(S.__bindingPointIndex);a.splice(M,1),i.deleteBuffer(s[S.id]),delete s[S.id],delete r[S.id]}function w(){for(let _ in s)i.deleteBuffer(s[_]);a=[],s={},r={}}return{bind:l,update:c,dispose:w}}var ux=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Dn=null;function dx(){return Dn===null&&(Dn=new Da(ux,16,16,mi,Ln),Dn.name="DFG_LUT",Dn.minFilter=Ft,Dn.magFilter=Ft,Dn.wrapS=An,Dn.wrapT=An,Dn.generateMipmaps=!1,Dn.needsUpdate=!0),Dn}var Ss=class{constructor(e={}){let{canvas:t=Mu(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:f=Yt}=e;this.isWebGLRenderer=!0;let g;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=n.getContextAttributes().alpha}else g=a;let b=f,m=new Set([po,fo,uo]),p=new Set([Yt,vn,ys,vs,co,ho]),C=new Uint32Array(4),w=new Int32Array(4),_=new R,S=null,M=null,A=[],y=[],T=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=yn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let I=this,P=!1,F=null,G=null,X=null,O=null;this._outputColorSpace=jt;let W=0,H=0,K=null,ie=-1,ue=null,le=new gt,Me=new gt,$e=null,ct=new qe(0),Qe=0,$=t.width,ce=t.height,re=1,Ie=null,ze=null,Ue=new gt(0,0,$,ce),nt=new gt(0,0,$,ce),Ve=!1,j=new us,ne=!1,te=!1,xe=new rt,me=new R,Oe=new gt,Ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},ke=!1;function Ge(){return K===null?re:1}let L=n;function at(v,N){return t.getContext(v,N)}try{let v={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"185"}`),t.addEventListener("webglcontextlost",yt,!1),t.addEventListener("webglcontextrestored",dt,!1),t.addEventListener("webglcontextcreationerror",Mn,!1),L===null){let N="webgl2";if(L=at(N,v),L===null)throw at(N)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(v){throw Fe("WebGLRenderer: "+v.message),v}let Ke,E,x,U,k,q,ae,oe,Y,J,de,Re,ge,fe,Ne,Be,We,D,he,Z,pe,be,Q;function Ae(){Ke=new y0(L),Ke.init(),pe=new rx(L,Ke),E=new u0(L,Ke,e,pe),x=new ix(L,Ke),E.reversedDepthBuffer&&u&&x.buffers.depth.setReversed(!0),G=L.createFramebuffer(),X=L.createFramebuffer(),O=L.createFramebuffer(),U=new M0(L),k=new G_,q=new sx(L,Ke,x,k,E,pe,U),ae=new x0(I),oe=new wp(L),be=new c0(L,oe),Y=new v0(L,oe,U,be),J=new E0(L,Y,oe,be,U),D=new S0(L,E,q),Ne=new d0(k),de=new H_(I,ae,Ke,E,be,Ne),Re=new cx(I,k),ge=new X_,fe=new K_(Ke),We=new l0(I,ae,x,J,g,l),Be=new nx(I,J,E),Q=new hx(L,U,E,x),he=new h0(L,Ke,U),Z=new b0(L,Ke,U),U.programs=de.programs,I.capabilities=E,I.extensions=Ke,I.properties=k,I.renderLists=ge,I.shadowMap=Be,I.state=x,I.info=U}Ae(),b!==Yt&&(T=new w0(b,t.width,t.height,o,s,r));let Te=new Oc(I,L);this.xr=Te,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){let v=Ke.get("WEBGL_lose_context");v&&v.loseContext()},this.forceContextRestore=function(){let v=Ke.get("WEBGL_lose_context");v&&v.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(v){v!==void 0&&(re=v,this.setSize($,ce,!1))},this.getSize=function(v){return v.set($,ce)},this.setSize=function(v,N,V=!0){if(Te.isPresenting){De("WebGLRenderer: Can't change size while VR device is presenting.");return}$=v,ce=N,t.width=Math.floor(v*re),t.height=Math.floor(N*re),V===!0&&(t.style.width=v+"px",t.style.height=N+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,v,N)},this.getDrawingBufferSize=function(v){return v.set($*re,ce*re).floor()},this.setDrawingBufferSize=function(v,N,V){$=v,ce=N,re=V,t.width=Math.floor(v*V),t.height=Math.floor(N*V),this.setViewport(0,0,v,N)},this.setEffects=function(v){if(b===Yt){Fe("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(v){for(let N=0;N<v.length;N++)if(v[N].isOutputPass===!0){De("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}T.setEffects(v||[])},this.getCurrentViewport=function(v){return v.copy(le)},this.getViewport=function(v){return v.copy(Ue)},this.setViewport=function(v,N,V,B){v.isVector4?Ue.set(v.x,v.y,v.z,v.w):Ue.set(v,N,V,B),x.viewport(le.copy(Ue).multiplyScalar(re).round())},this.getScissor=function(v){return v.copy(nt)},this.setScissor=function(v,N,V,B){v.isVector4?nt.set(v.x,v.y,v.z,v.w):nt.set(v,N,V,B),x.scissor(Me.copy(nt).multiplyScalar(re).round())},this.getScissorTest=function(){return Ve},this.setScissorTest=function(v){x.setScissorTest(Ve=v)},this.setOpaqueSort=function(v){Ie=v},this.setTransparentSort=function(v){ze=v},this.getClearColor=function(v){return v.copy(We.getClearColor())},this.setClearColor=function(){We.setClearColor(...arguments)},this.getClearAlpha=function(){return We.getClearAlpha()},this.setClearAlpha=function(){We.setClearAlpha(...arguments)},this.clear=function(v=!0,N=!0,V=!0){let B=0;if(v){let z=!1;if(K!==null){let ve=K.texture.format;z=m.has(ve)}if(z){let ve=K.texture.type,Ee=p.has(ve),ye=We.getClearColor(),we=We.getClearAlpha(),Pe=ye.r,Xe=ye.g,Je=ye.b;Ee?(C[0]=Pe,C[1]=Xe,C[2]=Je,C[3]=we,L.clearBufferuiv(L.COLOR,0,C)):(w[0]=Pe,w[1]=Xe,w[2]=Je,w[3]=we,L.clearBufferiv(L.COLOR,0,w))}else B|=L.COLOR_BUFFER_BIT}N&&(B|=L.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),V&&(B|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B!==0&&L.clear(B)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(v){v.setRenderer(this),F=v},this.dispose=function(){t.removeEventListener("webglcontextlost",yt,!1),t.removeEventListener("webglcontextrestored",dt,!1),t.removeEventListener("webglcontextcreationerror",Mn,!1),We.dispose(),ge.dispose(),fe.dispose(),k.dispose(),ae.dispose(),J.dispose(),be.dispose(),Q.dispose(),de.dispose(),Te.dispose(),Te.removeEventListener("sessionstart",eh),Te.removeEventListener("sessionend",th),xi.stop()};function yt(v){v.preventDefault(),Zs("WebGLRenderer: Context Lost."),P=!0}function dt(){Zs("WebGLRenderer: Context Restored."),P=!1;let v=U.autoReset,N=Be.enabled,V=Be.autoUpdate,B=Be.needsUpdate,z=Be.type;Ae(),U.autoReset=v,Be.enabled=N,Be.autoUpdate=V,Be.needsUpdate=B,Be.type=z}function Mn(v){Fe("WebGLRenderer: A WebGL context could not be created. Reason: ",v.statusMessage)}function Sn(v){let N=v.target;N.removeEventListener("dispose",Sn),Wd(N)}function Wd(v){Xd(v),k.remove(v)}function Xd(v){let N=k.get(v).programs;N!==void 0&&(N.forEach(function(V){de.releaseProgram(V)}),v.isShaderMaterial&&de.releaseShaderCache(v))}this.renderBufferDirect=function(v,N,V,B,z,ve){N===null&&(N=Ce);let Ee=z.isMesh&&z.matrixWorld.determinantAffine()<0,ye=Zd(v,N,V,B,z);x.setMaterial(B,Ee);let we=V.index,Pe=1;if(B.wireframe===!0){if(we=Y.getWireframeAttribute(V),we===void 0)return;Pe=2}let Xe=V.drawRange,Je=V.attributes.position,Le=Xe.start*Pe,ot=(Xe.start+Xe.count)*Pe;ve!==null&&(Le=Math.max(Le,ve.start*Pe),ot=Math.min(ot,(ve.start+ve.count)*Pe)),we!==null?(Le=Math.max(Le,0),ot=Math.min(ot,we.count)):Je!=null&&(Le=Math.max(Le,0),ot=Math.min(ot,Je.count));let bt=ot-Le;if(bt<0||bt===1/0)return;be.setup(z,B,ye,V,we);let vt,ht=he;if(we!==null&&(vt=oe.get(we),ht=Z,ht.setIndex(vt)),z.isMesh)B.wireframe===!0?(x.setLineWidth(B.wireframeLinewidth*Ge()),ht.setMode(L.LINES)):ht.setMode(L.TRIANGLES);else if(z.isLine){let Bt=B.linewidth;Bt===void 0&&(Bt=1),x.setLineWidth(Bt*Ge()),z.isLineSegments?ht.setMode(L.LINES):z.isLineLoop?ht.setMode(L.LINE_LOOP):ht.setMode(L.LINE_STRIP)}else z.isPoints?ht.setMode(L.POINTS):z.isSprite&&ht.setMode(L.TRIANGLES);if(z.isBatchedMesh)if(Ke.get("WEBGL_multi_draw"))ht.renderMultiDraw(z._multiDrawStarts,z._multiDrawCounts,z._multiDrawCount);else{let Bt=z._multiDrawStarts,Se=z._multiDrawCounts,$t=z._multiDrawCount,et=we?oe.get(we).bytesPerElement:1,sn=k.get(B).currentProgram.getUniforms();for(let En=0;En<$t;En++)sn.setValue(L,"_gl_DrawID",En),ht.render(Bt[En]/et,Se[En])}else if(z.isInstancedMesh)ht.renderInstances(Le,bt,z.count);else if(V.isInstancedBufferGeometry){let Bt=V._maxInstanceCount!==void 0?V._maxInstanceCount:1/0,Se=Math.min(V.instanceCount,Bt);ht.renderInstances(Le,bt,Se)}else ht.render(Le,bt)};function Qc(v,N,V){v.transparent===!0&&v.side===ln&&v.forceSinglePass===!1?(v.side=qt,v.needsUpdate=!0,Fr(v,N,V),v.side=Hn,v.needsUpdate=!0,Fr(v,N,V),v.side=ln):Fr(v,N,V)}this.compile=function(v,N,V=null){V===null&&(V=v),M=fe.get(V),M.init(N),y.push(M),V.traverseVisible(function(z){z.isLight&&z.layers.test(N.layers)&&(M.pushLight(z),z.castShadow&&M.pushShadow(z))}),v!==V&&v.traverseVisible(function(z){z.isLight&&z.layers.test(N.layers)&&(M.pushLight(z),z.castShadow&&M.pushShadow(z))}),M.setupLights();let B=new Set;return v.traverse(function(z){if(!(z.isMesh||z.isPoints||z.isLine||z.isSprite))return;let ve=z.material;if(ve)if(Array.isArray(ve))for(let Ee=0;Ee<ve.length;Ee++){let ye=ve[Ee];Qc(ye,V,z),B.add(ye)}else Qc(ve,V,z),B.add(ve)}),M=y.pop(),B},this.compileAsync=function(v,N,V=null){let B=this.compile(v,N,V);return new Promise(z=>{function ve(){if(B.forEach(function(Ee){k.get(Ee).currentProgram.isReady()&&B.delete(Ee)}),B.size===0){z(v);return}setTimeout(ve,10)}Ke.get("KHR_parallel_shader_compile")!==null?ve():setTimeout(ve,10)})};let rl=null;function qd(v){rl&&rl(v)}function eh(){xi.stop()}function th(){xi.start()}let xi=new nd;xi.setAnimationLoop(qd),typeof self<"u"&&xi.setContext(self),this.setAnimationLoop=function(v){rl=v,Te.setAnimationLoop(v),v===null?xi.stop():xi.start()},Te.addEventListener("sessionstart",eh),Te.addEventListener("sessionend",th),this.render=function(v,N){if(N!==void 0&&N.isCamera!==!0){Fe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;F!==null&&F.renderStart(v,N);let V=Te.enabled===!0&&Te.isPresenting===!0,B=T!==null&&(K===null||V)&&T.begin(I,K);if(v.matrixWorldAutoUpdate===!0&&v.updateMatrixWorld(),N.parent===null&&N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),Te.enabled===!0&&Te.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(Te.cameraAutoUpdate===!0&&Te.updateCamera(N),N=Te.getCamera()),v.isScene===!0&&v.onBeforeRender(I,v,N,K),M=fe.get(v,y.length),M.init(N),M.state.textureUnits=q.getTextureUnits(),y.push(M),xe.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),j.setFromProjectionMatrix(xe,pn,N.reversedDepth),te=this.localClippingEnabled,ne=Ne.init(this.clippingPlanes,te),S=ge.get(v,A.length),S.init(),A.push(S),Te.enabled===!0&&Te.isPresenting===!0){let Ee=I.xr.getDepthSensingMesh();Ee!==null&&al(Ee,N,-1/0,I.sortObjects)}al(v,N,0,I.sortObjects),S.finish(),I.sortObjects===!0&&S.sort(Ie,ze,N.reversedDepth),ke=Te.enabled===!1||Te.isPresenting===!1||Te.hasDepthSensing()===!1,ke&&We.addToRenderList(S,v),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),ne===!0&&Ne.beginShadows();let z=M.state.shadowsArray;if(Be.render(z,v,N),ne===!0&&Ne.endShadows(),(B&&T.hasRenderPass())===!1){let Ee=S.opaque,ye=S.transmissive;if(M.setupLights(),N.isArrayCamera){let we=N.cameras;if(ye.length>0)for(let Pe=0,Xe=we.length;Pe<Xe;Pe++){let Je=we[Pe];ih(Ee,ye,v,Je)}ke&&We.render(v);for(let Pe=0,Xe=we.length;Pe<Xe;Pe++){let Je=we[Pe];nh(S,v,Je,Je.viewport)}}else ye.length>0&&ih(Ee,ye,v,N),ke&&We.render(v),nh(S,v,N)}K!==null&&H===0&&(q.updateMultisampleRenderTarget(K),q.updateRenderTargetMipmap(K)),B&&T.end(I),v.isScene===!0&&v.onAfterRender(I,v,N),be.resetDefaultState(),ie=-1,ue=null,y.pop(),y.length>0?(M=y[y.length-1],q.setTextureUnits(M.state.textureUnits),ne===!0&&Ne.setGlobalState(I.clippingPlanes,M.state.camera)):M=null,A.pop(),A.length>0?S=A[A.length-1]:S=null,F!==null&&F.renderEnd()};function al(v,N,V,B){if(v.visible===!1)return;if(v.layers.test(N.layers)){if(v.isGroup)V=v.renderOrder;else if(v.isLOD)v.autoUpdate===!0&&v.update(N);else if(v.isLightProbeGrid)M.pushLightProbeGrid(v);else if(v.isLight)M.pushLight(v),v.castShadow&&M.pushShadow(v);else if(v.isSprite){if(!v.frustumCulled||j.intersectsSprite(v)){B&&Oe.setFromMatrixPosition(v.matrixWorld).applyMatrix4(xe);let Ee=J.update(v),ye=v.material;ye.visible&&S.push(v,Ee,ye,V,Oe.z,null)}}else if((v.isMesh||v.isLine||v.isPoints)&&(!v.frustumCulled||j.intersectsObject(v))){let Ee=J.update(v),ye=v.material;if(B&&(v.boundingSphere!==void 0?(v.boundingSphere===null&&v.computeBoundingSphere(),Oe.copy(v.boundingSphere.center)):(Ee.boundingSphere===null&&Ee.computeBoundingSphere(),Oe.copy(Ee.boundingSphere.center)),Oe.applyMatrix4(v.matrixWorld).applyMatrix4(xe)),Array.isArray(ye)){let we=Ee.groups;for(let Pe=0,Xe=we.length;Pe<Xe;Pe++){let Je=we[Pe],Le=ye[Je.materialIndex];Le&&Le.visible&&S.push(v,Ee,Le,V,Oe.z,Je)}}else ye.visible&&S.push(v,Ee,ye,V,Oe.z,null)}}let ve=v.children;for(let Ee=0,ye=ve.length;Ee<ye;Ee++)al(ve[Ee],N,V,B)}function nh(v,N,V,B){let{opaque:z,transmissive:ve,transparent:Ee}=v;M.setupLightsView(V),ne===!0&&Ne.setGlobalState(I.clippingPlanes,V),B&&x.viewport(le.copy(B)),z.length>0&&Ur(z,N,V),ve.length>0&&Ur(ve,N,V),Ee.length>0&&Ur(Ee,N,V),x.buffers.depth.setTest(!0),x.buffers.depth.setMask(!0),x.buffers.color.setMask(!0),x.setPolygonOffset(!1)}function ih(v,N,V,B){if((V.isScene===!0?V.overrideMaterial:null)!==null)return;if(M.state.transmissionRenderTarget[B.id]===void 0){let Le=Ke.has("EXT_color_buffer_half_float")||Ke.has("EXT_color_buffer_float");M.state.transmissionRenderTarget[B.id]=new Qt(1,1,{generateMipmaps:!0,type:Le?Ln:Yt,minFilter:fi,samples:Math.max(4,E.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:je.workingColorSpace})}let ve=M.state.transmissionRenderTarget[B.id],Ee=B.viewport||le;ve.setSize(Ee.z*I.transmissionResolutionScale,Ee.w*I.transmissionResolutionScale);let ye=I.getRenderTarget(),we=I.getActiveCubeFace(),Pe=I.getActiveMipmapLevel();I.setRenderTarget(ve),I.getClearColor(ct),Qe=I.getClearAlpha(),Qe<1&&I.setClearColor(16777215,.5),I.clear(),ke&&We.render(V);let Xe=I.toneMapping;I.toneMapping=yn;let Je=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),M.setupLightsView(B),ne===!0&&Ne.setGlobalState(I.clippingPlanes,B),Ur(v,V,B),q.updateMultisampleRenderTarget(ve),q.updateRenderTargetMipmap(ve),Ke.has("WEBGL_multisampled_render_to_texture")===!1){let Le=!1;for(let ot=0,bt=N.length;ot<bt;ot++){let vt=N[ot],{object:ht,geometry:Bt,material:Se,group:$t}=vt;if(Se.side===ln&&ht.layers.test(B.layers)){let et=Se.side;Se.side=qt,Se.needsUpdate=!0,sh(ht,V,B,Bt,Se,$t),Se.side=et,Se.needsUpdate=!0,Le=!0}}Le===!0&&(q.updateMultisampleRenderTarget(ve),q.updateRenderTargetMipmap(ve))}I.setRenderTarget(ye,we,Pe),I.setClearColor(ct,Qe),Je!==void 0&&(B.viewport=Je),I.toneMapping=Xe}function Ur(v,N,V){let B=N.isScene===!0?N.overrideMaterial:null;for(let z=0,ve=v.length;z<ve;z++){let Ee=v[z],{object:ye,geometry:we,group:Pe}=Ee,Xe=Ee.material;Xe.allowOverride===!0&&B!==null&&(Xe=B),ye.layers.test(V.layers)&&sh(ye,N,V,we,Xe,Pe)}}function sh(v,N,V,B,z,ve){v.onBeforeRender(I,N,V,B,z,ve),v.modelViewMatrix.multiplyMatrices(V.matrixWorldInverse,v.matrixWorld),v.normalMatrix.getNormalMatrix(v.modelViewMatrix),z.onBeforeRender(I,N,V,B,v,ve),z.transparent===!0&&z.side===ln&&z.forceSinglePass===!1?(z.side=qt,z.needsUpdate=!0,I.renderBufferDirect(V,N,B,z,v,ve),z.side=Hn,z.needsUpdate=!0,I.renderBufferDirect(V,N,B,z,v,ve),z.side=ln):I.renderBufferDirect(V,N,B,z,v,ve),v.onAfterRender(I,N,V,B,z,ve)}function Fr(v,N,V){N.isScene!==!0&&(N=Ce);let B=k.get(v),z=M.state.lights,ve=M.state.shadowsArray,Ee=z.state.version,ye=de.getParameters(v,z.state,ve,N,V,M.state.lightProbeGridArray),we=de.getProgramCacheKey(ye),Pe=B.programs;B.environment=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?N.environment:null,B.fog=N.fog;let Xe=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap;B.envMap=ae.get(v.envMap||B.environment,Xe),B.envMapRotation=B.environment!==null&&v.envMap===null?N.environmentRotation:v.envMapRotation,Pe===void 0&&(v.addEventListener("dispose",Sn),Pe=new Map,B.programs=Pe);let Je=Pe.get(we);if(Je!==void 0){if(B.currentProgram===Je&&B.lightsStateVersion===Ee)return ah(v,ye),Je}else ye.uniforms=de.getUniforms(v),F!==null&&v.isNodeMaterial&&F.build(v,V,ye),v.onBeforeCompile(ye,I),Je=de.acquireProgram(ye,we),Pe.set(we,Je),B.uniforms=ye.uniforms;let Le=B.uniforms;return(!v.isShaderMaterial&&!v.isRawShaderMaterial||v.clipping===!0)&&(Le.clippingPlanes=Ne.uniform),ah(v,ye),B.needsLights=Jd(v),B.lightsStateVersion=Ee,B.needsLights&&(Le.ambientLightColor.value=z.state.ambient,Le.lightProbe.value=z.state.probe,Le.directionalLights.value=z.state.directional,Le.directionalLightShadows.value=z.state.directionalShadow,Le.spotLights.value=z.state.spot,Le.spotLightShadows.value=z.state.spotShadow,Le.rectAreaLights.value=z.state.rectArea,Le.ltc_1.value=z.state.rectAreaLTC1,Le.ltc_2.value=z.state.rectAreaLTC2,Le.pointLights.value=z.state.point,Le.pointLightShadows.value=z.state.pointShadow,Le.hemisphereLights.value=z.state.hemi,Le.directionalShadowMatrix.value=z.state.directionalShadowMatrix,Le.spotLightMatrix.value=z.state.spotLightMatrix,Le.spotLightMap.value=z.state.spotLightMap,Le.pointShadowMatrix.value=z.state.pointShadowMatrix),B.lightProbeGrid=M.state.lightProbeGridArray.length>0,B.currentProgram=Je,B.uniformsList=null,Je}function rh(v){if(v.uniformsList===null){let N=v.currentProgram.getUniforms();v.uniformsList=Ms.seqWithValue(N.seq,v.uniforms)}return v.uniformsList}function ah(v,N){let V=k.get(v);V.outputColorSpace=N.outputColorSpace,V.batching=N.batching,V.batchingColor=N.batchingColor,V.instancing=N.instancing,V.instancingColor=N.instancingColor,V.instancingMorph=N.instancingMorph,V.skinning=N.skinning,V.morphTargets=N.morphTargets,V.morphNormals=N.morphNormals,V.morphColors=N.morphColors,V.morphTargetsCount=N.morphTargetsCount,V.numClippingPlanes=N.numClippingPlanes,V.numIntersection=N.numClipIntersection,V.vertexAlphas=N.vertexAlphas,V.vertexTangents=N.vertexTangents,V.toneMapping=N.toneMapping}function Yd(v,N){if(v.length===0)return null;if(v.length===1)return v[0].texture!==null?v[0]:null;_.setFromMatrixPosition(N.matrixWorld);for(let V=0,B=v.length;V<B;V++){let z=v[V];if(z.texture!==null&&z.boundingBox.containsPoint(_))return z}return null}function Zd(v,N,V,B,z){N.isScene!==!0&&(N=Ce),q.resetTextureUnits();let ve=N.fog,Ee=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?N.environment:null,ye=K===null?I.outputColorSpace:K.isXRRenderTarget===!0?K.texture.colorSpace:je.workingColorSpace,we=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Pe=ae.get(B.envMap||Ee,we),Xe=B.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,Je=!!V.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Le=!!V.morphAttributes.position,ot=!!V.morphAttributes.normal,bt=!!V.morphAttributes.color,vt=yn;B.toneMapped&&(K===null||K.isXRRenderTarget===!0)&&(vt=I.toneMapping);let ht=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,Bt=ht!==void 0?ht.length:0,Se=k.get(B),$t=M.state.lights;if(ne===!0&&(te===!0||v!==ue)){let ft=v===ue&&B.id===ie;Ne.setState(B,v,ft)}let et=!1;B.version===Se.__version?(Se.needsLights&&Se.lightsStateVersion!==$t.state.version||Se.outputColorSpace!==ye||z.isBatchedMesh&&Se.batching===!1||!z.isBatchedMesh&&Se.batching===!0||z.isBatchedMesh&&Se.batchingColor===!0&&z.colorTexture===null||z.isBatchedMesh&&Se.batchingColor===!1&&z.colorTexture!==null||z.isInstancedMesh&&Se.instancing===!1||!z.isInstancedMesh&&Se.instancing===!0||z.isSkinnedMesh&&Se.skinning===!1||!z.isSkinnedMesh&&Se.skinning===!0||z.isInstancedMesh&&Se.instancingColor===!0&&z.instanceColor===null||z.isInstancedMesh&&Se.instancingColor===!1&&z.instanceColor!==null||z.isInstancedMesh&&Se.instancingMorph===!0&&z.morphTexture===null||z.isInstancedMesh&&Se.instancingMorph===!1&&z.morphTexture!==null||Se.envMap!==Pe||B.fog===!0&&Se.fog!==ve||Se.numClippingPlanes!==void 0&&(Se.numClippingPlanes!==Ne.numPlanes||Se.numIntersection!==Ne.numIntersection)||Se.vertexAlphas!==Xe||Se.vertexTangents!==Je||Se.morphTargets!==Le||Se.morphNormals!==ot||Se.morphColors!==bt||Se.toneMapping!==vt||Se.morphTargetsCount!==Bt||!!Se.lightProbeGrid!=M.state.lightProbeGridArray.length>0)&&(et=!0):(et=!0,Se.__version=B.version);let sn=Se.currentProgram;et===!0&&(sn=Fr(B,N,z),F&&B.isNodeMaterial&&F.onUpdateProgram(B,sn,Se));let En=!1,qn=!1,Bi=!1,ut=sn.getUniforms(),Mt=Se.uniforms;if(x.useProgram(sn.program)&&(En=!0,qn=!0,Bi=!0),B.id!==ie&&(ie=B.id,qn=!0),Se.needsLights){let ft=Yd(M.state.lightProbeGridArray,z);Se.lightProbeGrid!==ft&&(Se.lightProbeGrid=ft,qn=!0)}if(En||ue!==v){x.buffers.depth.getReversed()&&v.reversedDepth!==!0&&(v._reversedDepth=!0,v.updateProjectionMatrix()),ut.setValue(L,"projectionMatrix",v.projectionMatrix),ut.setValue(L,"viewMatrix",v.matrixWorldInverse);let Zn=ut.map.cameraPosition;Zn!==void 0&&Zn.setValue(L,me.setFromMatrixPosition(v.matrixWorld)),E.logarithmicDepthBuffer&&ut.setValue(L,"logDepthBufFC",2/(Math.log(v.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&ut.setValue(L,"isOrthographic",v.isOrthographicCamera===!0),ue!==v&&(ue=v,qn=!0,Bi=!0)}if(Se.needsLights&&($t.state.directionalShadowMap.length>0&&ut.setValue(L,"directionalShadowMap",$t.state.directionalShadowMap,q),$t.state.spotShadowMap.length>0&&ut.setValue(L,"spotShadowMap",$t.state.spotShadowMap,q),$t.state.pointShadowMap.length>0&&ut.setValue(L,"pointShadowMap",$t.state.pointShadowMap,q)),z.isSkinnedMesh){ut.setOptional(L,z,"bindMatrix"),ut.setOptional(L,z,"bindMatrixInverse");let ft=z.skeleton;ft&&(ft.boneTexture===null&&ft.computeBoneTexture(),ut.setValue(L,"boneTexture",ft.boneTexture,q))}z.isBatchedMesh&&(ut.setOptional(L,z,"batchingTexture"),ut.setValue(L,"batchingTexture",z._matricesTexture,q),ut.setOptional(L,z,"batchingIdTexture"),ut.setValue(L,"batchingIdTexture",z._indirectTexture,q),ut.setOptional(L,z,"batchingColorTexture"),z._colorsTexture!==null&&ut.setValue(L,"batchingColorTexture",z._colorsTexture,q));let Yn=V.morphAttributes;if((Yn.position!==void 0||Yn.normal!==void 0||Yn.color!==void 0)&&D.update(z,V,sn),(qn||Se.receiveShadow!==z.receiveShadow)&&(Se.receiveShadow=z.receiveShadow,ut.setValue(L,"receiveShadow",z.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&N.environment!==null&&(Mt.envMapIntensity.value=N.environmentIntensity),Mt.dfgLUT!==void 0&&(Mt.dfgLUT.value=dx()),qn){if(ut.setValue(L,"toneMappingExposure",I.toneMappingExposure),Se.needsLights&&$d(Mt,Bi),ve&&B.fog===!0&&Re.refreshFogUniforms(Mt,ve),Re.refreshMaterialUniforms(Mt,B,re,ce,M.state.transmissionRenderTarget[v.id]),Se.needsLights&&Se.lightProbeGrid){let ft=Se.lightProbeGrid;Mt.probesSH.value=ft.texture,Mt.probesMin.value.copy(ft.boundingBox.min),Mt.probesMax.value.copy(ft.boundingBox.max),Mt.probesResolution.value.copy(ft.resolution)}Ms.upload(L,rh(Se),Mt,q)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(Ms.upload(L,rh(Se),Mt,q),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&ut.setValue(L,"center",z.center),ut.setValue(L,"modelViewMatrix",z.modelViewMatrix),ut.setValue(L,"normalMatrix",z.normalMatrix),ut.setValue(L,"modelMatrix",z.matrixWorld),B.uniformsGroups!==void 0){let ft=B.uniformsGroups;for(let Zn=0,zi=ft.length;Zn<zi;Zn++){let oh=ft[Zn];Q.update(oh,sn),Q.bind(oh,sn)}}return sn}function $d(v,N){v.ambientLightColor.needsUpdate=N,v.lightProbe.needsUpdate=N,v.directionalLights.needsUpdate=N,v.directionalLightShadows.needsUpdate=N,v.pointLights.needsUpdate=N,v.pointLightShadows.needsUpdate=N,v.spotLights.needsUpdate=N,v.spotLightShadows.needsUpdate=N,v.rectAreaLights.needsUpdate=N,v.hemisphereLights.needsUpdate=N}function Jd(v){return v.isMeshLambertMaterial||v.isMeshToonMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isShadowMaterial||v.isShaderMaterial&&v.lights===!0}this.getActiveCubeFace=function(){return W},this.getActiveMipmapLevel=function(){return H},this.getRenderTarget=function(){return K},this.setRenderTargetTextures=function(v,N,V){let B=k.get(v);B.__autoAllocateDepthBuffer=v.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),k.get(v.texture).__webglTexture=N,k.get(v.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:V,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(v,N){let V=k.get(v);V.__webglFramebuffer=N,V.__useDefaultFramebuffer=N===void 0},this.setRenderTarget=function(v,N=0,V=0){K=v,W=N,H=V;let B=null,z=!1,ve=!1;if(v){let ye=k.get(v);if(ye.__useDefaultFramebuffer!==void 0){x.bindFramebuffer(L.FRAMEBUFFER,ye.__webglFramebuffer),le.copy(v.viewport),Me.copy(v.scissor),$e=v.scissorTest,x.viewport(le),x.scissor(Me),x.setScissorTest($e),ie=-1;return}else if(ye.__webglFramebuffer===void 0)q.setupRenderTarget(v);else if(ye.__hasExternalTextures)q.rebindTextures(v,k.get(v.texture).__webglTexture,k.get(v.depthTexture).__webglTexture);else if(v.depthBuffer){let Xe=v.depthTexture;if(ye.__boundDepthTexture!==Xe){if(Xe!==null&&k.has(Xe)&&(v.width!==Xe.image.width||v.height!==Xe.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");q.setupDepthRenderbuffer(v)}}let we=v.texture;(we.isData3DTexture||we.isDataArrayTexture||we.isCompressedArrayTexture)&&(ve=!0);let Pe=k.get(v).__webglFramebuffer;v.isWebGLCubeRenderTarget?(Array.isArray(Pe[N])?B=Pe[N][V]:B=Pe[N],z=!0):v.samples>0&&q.useMultisampledRTT(v)===!1?B=k.get(v).__webglMultisampledFramebuffer:Array.isArray(Pe)?B=Pe[V]:B=Pe,le.copy(v.viewport),Me.copy(v.scissor),$e=v.scissorTest}else le.copy(Ue).multiplyScalar(re).floor(),Me.copy(nt).multiplyScalar(re).floor(),$e=Ve;if(V!==0&&(B=G),x.bindFramebuffer(L.FRAMEBUFFER,B)&&x.drawBuffers(v,B),x.viewport(le),x.scissor(Me),x.setScissorTest($e),z){let ye=k.get(v.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+N,ye.__webglTexture,V)}else if(ve){let ye=N;for(let we=0;we<v.textures.length;we++){let Pe=k.get(v.textures[we]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+we,Pe.__webglTexture,V,ye)}}else if(v!==null&&V!==0){let ye=k.get(v.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,ye.__webglTexture,V)}ie=-1},this.readRenderTargetPixels=function(v,N,V,B,z,ve,Ee,ye=0){if(!(v&&v.isWebGLRenderTarget)){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let we=k.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&Ee!==void 0&&(we=we[Ee]),we){x.bindFramebuffer(L.FRAMEBUFFER,we);try{let Pe=v.textures[ye],Xe=Pe.format,Je=Pe.type;if(v.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+ye),!E.textureFormatReadable(Xe)){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!E.textureTypeReadable(Je)){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}N>=0&&N<=v.width-B&&V>=0&&V<=v.height-z&&L.readPixels(N,V,B,z,pe.convert(Xe),pe.convert(Je),ve)}finally{let Pe=K!==null?k.get(K).__webglFramebuffer:null;x.bindFramebuffer(L.FRAMEBUFFER,Pe)}}},this.readRenderTargetPixelsAsync=async function(v,N,V,B,z,ve,Ee,ye=0){if(!(v&&v.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let we=k.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&Ee!==void 0&&(we=we[Ee]),we)if(N>=0&&N<=v.width-B&&V>=0&&V<=v.height-z){x.bindFramebuffer(L.FRAMEBUFFER,we);let Pe=v.textures[ye],Xe=Pe.format,Je=Pe.type;if(v.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+ye),!E.textureFormatReadable(Xe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!E.textureTypeReadable(Je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let Le=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,Le),L.bufferData(L.PIXEL_PACK_BUFFER,ve.byteLength,L.STREAM_READ),L.readPixels(N,V,B,z,pe.convert(Xe),pe.convert(Je),0);let ot=K!==null?k.get(K).__webglFramebuffer:null;x.bindFramebuffer(L.FRAMEBUFFER,ot);let bt=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await Eu(L,bt,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,Le),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,ve),L.deleteBuffer(Le),L.deleteSync(bt),ve}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(v,N=null,V=0){let B=Math.pow(2,-V),z=Math.floor(v.image.width*B),ve=Math.floor(v.image.height*B),Ee=N!==null?N.x:0,ye=N!==null?N.y:0;q.setTexture2D(v,0),L.copyTexSubImage2D(L.TEXTURE_2D,V,0,0,Ee,ye,z,ve),x.unbindTexture()},this.copyTextureToTexture=function(v,N,V=null,B=null,z=0,ve=0){let Ee,ye,we,Pe,Xe,Je,Le,ot,bt,vt=v.isCompressedTexture?v.mipmaps[ve]:v.image;if(V!==null)Ee=V.max.x-V.min.x,ye=V.max.y-V.min.y,we=V.isBox3?V.max.z-V.min.z:1,Pe=V.min.x,Xe=V.min.y,Je=V.isBox3?V.min.z:0;else{let Mt=Math.pow(2,-z);Ee=Math.floor(vt.width*Mt),ye=Math.floor(vt.height*Mt),v.isDataArrayTexture?we=vt.depth:v.isData3DTexture?we=Math.floor(vt.depth*Mt):we=1,Pe=0,Xe=0,Je=0}B!==null?(Le=B.x,ot=B.y,bt=B.z):(Le=0,ot=0,bt=0);let ht=pe.convert(N.format),Bt=pe.convert(N.type),Se;N.isData3DTexture?(q.setTexture3D(N,0),Se=L.TEXTURE_3D):N.isDataArrayTexture||N.isCompressedArrayTexture?(q.setTexture2DArray(N,0),Se=L.TEXTURE_2D_ARRAY):(q.setTexture2D(N,0),Se=L.TEXTURE_2D),x.activeTexture(L.TEXTURE0),x.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,N.flipY),x.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),x.pixelStorei(L.UNPACK_ALIGNMENT,N.unpackAlignment);let $t=x.getParameter(L.UNPACK_ROW_LENGTH),et=x.getParameter(L.UNPACK_IMAGE_HEIGHT),sn=x.getParameter(L.UNPACK_SKIP_PIXELS),En=x.getParameter(L.UNPACK_SKIP_ROWS),qn=x.getParameter(L.UNPACK_SKIP_IMAGES);x.pixelStorei(L.UNPACK_ROW_LENGTH,vt.width),x.pixelStorei(L.UNPACK_IMAGE_HEIGHT,vt.height),x.pixelStorei(L.UNPACK_SKIP_PIXELS,Pe),x.pixelStorei(L.UNPACK_SKIP_ROWS,Xe),x.pixelStorei(L.UNPACK_SKIP_IMAGES,Je);let Bi=v.isDataArrayTexture||v.isData3DTexture,ut=N.isDataArrayTexture||N.isData3DTexture;if(v.isDepthTexture){let Mt=k.get(v),Yn=k.get(N),ft=k.get(Mt.__renderTarget),Zn=k.get(Yn.__renderTarget);x.bindFramebuffer(L.READ_FRAMEBUFFER,ft.__webglFramebuffer),x.bindFramebuffer(L.DRAW_FRAMEBUFFER,Zn.__webglFramebuffer);for(let zi=0;zi<we;zi++)Bi&&(L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,k.get(v).__webglTexture,z,Je+zi),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,k.get(N).__webglTexture,ve,bt+zi)),L.blitFramebuffer(Pe,Xe,Ee,ye,Le,ot,Ee,ye,L.DEPTH_BUFFER_BIT,L.NEAREST);x.bindFramebuffer(L.READ_FRAMEBUFFER,null),x.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(z!==0||v.isRenderTargetTexture||k.has(v)){let Mt=k.get(v),Yn=k.get(N);x.bindFramebuffer(L.READ_FRAMEBUFFER,X),x.bindFramebuffer(L.DRAW_FRAMEBUFFER,O);for(let ft=0;ft<we;ft++)Bi?L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Mt.__webglTexture,z,Je+ft):L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Mt.__webglTexture,z),ut?L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Yn.__webglTexture,ve,bt+ft):L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Yn.__webglTexture,ve),z!==0?L.blitFramebuffer(Pe,Xe,Ee,ye,Le,ot,Ee,ye,L.COLOR_BUFFER_BIT,L.NEAREST):ut?L.copyTexSubImage3D(Se,ve,Le,ot,bt+ft,Pe,Xe,Ee,ye):L.copyTexSubImage2D(Se,ve,Le,ot,Pe,Xe,Ee,ye);x.bindFramebuffer(L.READ_FRAMEBUFFER,null),x.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else ut?v.isDataTexture||v.isData3DTexture?L.texSubImage3D(Se,ve,Le,ot,bt,Ee,ye,we,ht,Bt,vt.data):N.isCompressedArrayTexture?L.compressedTexSubImage3D(Se,ve,Le,ot,bt,Ee,ye,we,ht,vt.data):L.texSubImage3D(Se,ve,Le,ot,bt,Ee,ye,we,ht,Bt,vt):v.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,ve,Le,ot,Ee,ye,ht,Bt,vt.data):v.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,ve,Le,ot,vt.width,vt.height,ht,vt.data):L.texSubImage2D(L.TEXTURE_2D,ve,Le,ot,Ee,ye,ht,Bt,vt);x.pixelStorei(L.UNPACK_ROW_LENGTH,$t),x.pixelStorei(L.UNPACK_IMAGE_HEIGHT,et),x.pixelStorei(L.UNPACK_SKIP_PIXELS,sn),x.pixelStorei(L.UNPACK_SKIP_ROWS,En),x.pixelStorei(L.UNPACK_SKIP_IMAGES,qn),ve===0&&N.generateMipmaps&&L.generateMipmap(Se),x.unbindTexture()},this.initRenderTarget=function(v){k.get(v).__webglFramebuffer===void 0&&q.setupRenderTarget(v)},this.initTexture=function(v){v.isCubeTexture?q.setTextureCube(v,0):v.isData3DTexture?q.setTexture3D(v,0):v.isDataArrayTexture||v.isCompressedArrayTexture?q.setTexture2DArray(v,0):q.setTexture2D(v,0),x.unbindTexture()},this.resetState=function(){W=0,H=0,K=null,x.reset(),be.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return pn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=je._getDrawingBufferColorSpace(e),t.unpackColorSpace=je._getUnpackColorSpace()}};var cd={type:"change"},zc={type:"start"},ud={type:"end"},tl=new ii,hd=new an,fx=Math.cos(70*_c.DEG2RAD),Pt=new R,Zt=2*Math.PI,lt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Bc=1e-6,nl=class extends _r{constructor(e,t=null){super(e,t),this.state=lt.NONE,this.target=new R,this.cursor=new R,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:hi.ROTATE,MIDDLE:hi.DOLLY,RIGHT:hi.PAN},this.touches={ONE:ui.ROTATE,TWO:ui.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new R,this._lastQuaternion=new Ot,this._lastTargetPosition=new R,this._quat=new Ot().setFromUnitVectors(e.up,new R(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new _s,this._sphericalDelta=new _s,this._scale=1,this._panOffset=new R,this._rotateStart=new ee,this._rotateEnd=new ee,this._rotateDelta=new ee,this._panStart=new ee,this._panEnd=new ee,this._panDelta=new ee,this._dollyStart=new ee,this._dollyEnd=new ee,this._dollyDelta=new ee,this._dollyDirection=new R,this._mouse=new ee,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=mx.bind(this),this._onPointerDown=px.bind(this),this._onPointerUp=gx.bind(this),this._onContextMenu=Sx.bind(this),this._onMouseWheel=yx.bind(this),this._onKeyDown=vx.bind(this),this._onTouchStart=bx.bind(this),this._onTouchMove=Mx.bind(this),this._onMouseDown=_x.bind(this),this._onMouseMove=xx.bind(this),this._interceptControlDown=Ex.bind(this),this._interceptControlUp=Tx.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=""}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(cd),this.update(),this.state=lt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;Pt.copy(t).sub(this.target),Pt.applyQuaternion(this._quat),this._spherical.setFromVector3(Pt),this.autoRotate&&this.state===lt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=Zt:n>Math.PI&&(n-=Zt),s<-Math.PI?s+=Zt:s>Math.PI&&(s-=Zt),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(Pt.setFromSpherical(this._spherical),Pt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Pt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){let o=Pt.length();a=this._clampDistance(o*this._scale);let l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){let o=new R(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;let c=new R(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Pt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(tl.origin.copy(this.object.position),tl.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(tl.direction))<fx?this.object.lookAt(this.target):(hd.setFromNormalAndCoplanarPoint(this.object.up,this.target),tl.intersectPlane(hd,this.target))))}else if(this.object.isOrthographicCamera){let a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Bc||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Bc||this._lastTargetPosition.distanceToSquared(this.target)>Bc?(this.dispatchEvent(cd),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Zt/60*this.autoRotateSpeed*e:Zt/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Pt.setFromMatrixColumn(t,0),Pt.multiplyScalar(-e),this._panOffset.add(Pt)}_panUp(e,t){this.screenSpacePanning===!0?Pt.setFromMatrixColumn(t,1):(Pt.setFromMatrixColumn(t,0),Pt.crossVectors(this.object.up,Pt)),Pt.multiplyScalar(e),this._panOffset.add(Pt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let s=this.object.position;Pt.copy(s).sub(this.target);let r=Pt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),s=e-n.left,r=t-n.top,a=n.width,o=n.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Zt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Zt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Zt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Zt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Zt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Zt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Zt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Zt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new ee,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function px(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function mx(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function gx(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(ud),this.state=lt.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:let e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function _x(i){let e;switch(i.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case hi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=lt.DOLLY;break;case hi.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=lt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=lt.ROTATE}break;case hi.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=lt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=lt.PAN}break;default:this.state=lt.NONE}this.state!==lt.NONE&&this.dispatchEvent(zc)}function xx(i){switch(this.state){case lt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case lt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case lt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function yx(i){this.enabled===!1||this.enableZoom===!1||this.state!==lt.NONE||(i.preventDefault(),this.dispatchEvent(zc),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(ud))}function vx(i){this.enabled!==!1&&this._handleKeyDown(i)}function bx(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case ui.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=lt.TOUCH_ROTATE;break;case ui.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=lt.TOUCH_PAN;break;default:this.state=lt.NONE}break;case 2:switch(this.touches.TWO){case ui.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=lt.TOUCH_DOLLY_PAN;break;case ui.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=lt.TOUCH_DOLLY_ROTATE;break;default:this.state=lt.NONE}break;default:this.state=lt.NONE}this.state!==lt.NONE&&this.dispatchEvent(zc)}function Mx(i){switch(this._trackPointer(i),this.state){case lt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case lt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case lt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case lt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=lt.NONE}}function Sx(i){this.enabled!==!1&&i.preventDefault()}function Ex(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Tx(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function kc(i){let e=fd(i);return new Float32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function dd(i){let e=fd(i);return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function fd(i){let e=atob(i),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}var Pr=.85,Vc=3,wx=400,Ut=(i,e,t)=>new R(i,e,t),pd=[["TOP",Ut(0,0,1)],["BOTTOM",Ut(0,0,-1)],["FRONT",Ut(0,-1,0)],["BACK",Ut(0,1,0)],["RIGHT",Ut(1,0,0)],["LEFT",Ut(-1,0,0)]],Ax=[{name:"TOP",normal:Ut(0,0,1),up:Ut(0,1,0)},{name:"BOTTOM",normal:Ut(0,0,-1),up:Ut(0,1,0)},{name:"FRONT",normal:Ut(0,-1,0),up:Ut(0,0,1)},{name:"BACK",normal:Ut(0,1,0),up:Ut(0,0,1)},{name:"RIGHT",normal:Ut(1,0,0),up:Ut(0,0,1)},{name:"LEFT",normal:Ut(-1,0,0),up:Ut(0,0,1)}];function Cx(i){let e=[],t=i.length();for(let[n,s]of pd)i.dot(s)/t>.5&&e.push(n);return e.sort().join("-")}function Rx(i){let e=document.createElement("canvas");e.width=128,e.height=128;let t=e.getContext("2d");t!==null&&(t.fillStyle="rgba(246, 248, 251, 0.96)",t.fillRect(0,0,128,128),t.strokeStyle="rgba(148, 158, 172, 0.9)",t.lineWidth=3,t.strokeRect(1.5,1.5,125,125),t.fillStyle="#5b6472",t.font=`600 ${i.length>2?24:28}px -apple-system, "Segoe UI", sans-serif`,t.textAlign="center",t.textBaseline="middle",t.fillText(i,64,66));let n=new Ri(e);return n.anisotropy=4,n}var Ir=class{constructor(e){this.options=e;let{container:t,camera:n,controls:s}=e;this.camera=n,this.controls=s;let r=e.size??96;getComputedStyle(t).position==="static"&&(t.style.position="relative"),this.overlay=document.createElement("div"),this.overlay.style.cssText=`position:absolute;top:8px;right:8px;width:${r}px;display:flex;flex-direction:column;align-items:center;gap:3px;z-index:5;user-select:none;`,t.appendChild(this.overlay);let a=document.createElement("div");a.style.cssText=`width:${r}px;height:${r}px;cursor:grab;`,this.overlay.appendChild(a),this.caption=document.createElement("div"),this.caption.style.cssText='min-height:14px;font:500 10px/14px -apple-system,"Segoe UI",sans-serif;color:var(--dsw-alias-label-secondary,#374151);background:var(--dsw-alias-bg-base,rgba(255,255,255,0.85));border-radius:7px;padding:0 7px;opacity:0;transition:opacity 120ms;text-align:center;white-space:nowrap;',this.overlay.appendChild(this.caption);let o=document.createElement("button");o.type="button",o.title="Reset view",o.setAttribute("aria-label","Reset view"),o.style.cssText="width:22px;height:22px;border-radius:50%;border:1px solid var(--dsw-alias-border-l2,#c4c9d0);background:var(--dsw-alias-bg-base,#fff);color:var(--dsw-alias-label-secondary,#374151);font-size:12px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0;",o.textContent="\u2302",o.addEventListener("click",()=>{e.onHome?.()}),this.overlay.appendChild(o),this.renderer=new Ss({antialias:!0,alpha:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(r,r),this.renderer.domElement.style.cssText="width:100%;height:100%;display:block;touch-action:none;",a.appendChild(this.renderer.domElement),this.overlayCamera.position.set(0,0,4),this.overlayCamera.lookAt(0,0,0),new ni().add(this.root),this.buildCube();let c=d=>{let u=this.renderer.domElement.getBoundingClientRect(),f=new ee((d.clientX-u.left)/u.width*2-1,-((d.clientY-u.top)/u.height)*2+1);this.raycaster.setFromCamera(f,this.overlayCamera);let g=this.raycaster.intersectObjects(this.cells,!1)[0];return g===void 0?{zone:null,point:null}:{zone:g.object.userData.zone,point:g.point}},h=this.renderer.domElement;h.addEventListener("pointermove",d=>{let{zone:u}=c(d);this.setHover(u),h.style.cursor=u===null?"grab":"pointer"}),h.addEventListener("pointerleave",()=>{this.setHover(null)}),h.addEventListener("click",d=>{let{zone:u}=c(d);if(u===null)return;let f=Px(u);f!==null&&this.animateTo(f)})}options;camera;controls;renderer;overlayCamera=new li(-1.35,1.35,1.35,-1.35,.1,10);root=new Ht;cells=[];zoneCells=new Map;hiddenMaterial=new on({visible:!1});highlightMaterial=new on({color:5073918,transparent:!0,opacity:.55,depthWrite:!1});disposables=[this.hiddenMaterial,this.highlightMaterial];raycaster=new Li;overlay;caption;hovered=null;tweenId=0;disposed=!1;buildCube(){let e=2*Pr/Vc;for(let t of Ax){let n=t.up.clone().cross(t.normal),s=new rt().makeBasis(n,t.up,t.normal),r=new Ht;r.quaternion.setFromRotationMatrix(s);let a=Rx(t.name);this.disposables.push(a);let o=new on({map:a,transparent:!0});this.disposables.push(o);let l=new wt(new si(2*Pr,2*Pr),o);l.position.set(0,0,Pr),r.add(l),this.disposables.push(l.geometry);let c=new si(e*1.02,e*1.02);this.disposables.push(c);for(let h=0;h<Vc;h++)for(let d=0;d<Vc;d++){let u=new wt(c,this.hiddenMaterial);u.position.set((h-1)*e,(d-1)*e,Pr+.004);let f=t.normal.clone().addScaledVector(n,h-1).addScaledVector(t.up,d-1),g=Cx(f);u.userData.zone=g,r.add(u),this.cells.push(u);let b=this.zoneCells.get(g);b===void 0?this.zoneCells.set(g,[u]):b.push(u)}this.root.add(r)}}setHover(e){if(e!==this.hovered){for(let t of this.hovered===null?[]:this.zoneCells.get(this.hovered)??[])t.material=this.hiddenMaterial;this.hovered=e;for(let t of e===null?[]:this.zoneCells.get(e)??[])t.material=this.highlightMaterial;this.caption.textContent=e,this.caption.style.opacity=e===null?"0":"1"}}animateTo(e){let t=this.camera,n=this.controls,s=t.position.distanceTo(n.target),r=t.position.clone().sub(n.target).normalize(),a=e.clone().normalize();if(r.dot(a)>.9999)return;let o=new Ot().setFromUnitVectors(r,a),l=new Ot;n.enabled=!1,cancelAnimationFrame(this.tweenId);let c=performance.now(),h=()=>{if(this.disposed)return;let d=Math.min(1,(performance.now()-c)/wx),u=1-Math.pow(1-d,3),f=new Ot().slerpQuaternions(l,o,u);t.position.copy(r).applyQuaternion(f).multiplyScalar(s).add(n.target),t.lookAt(n.target),d<1?this.tweenId=requestAnimationFrame(h):(n.enabled=!0,n.update())};this.tweenId=requestAnimationFrame(h)}update(){this.disposed||(this.root.quaternion.copy(this.camera.quaternion).invert(),this.renderer.render(this.root.parent,this.overlayCamera))}dispose(){if(!this.disposed){this.disposed=!0,cancelAnimationFrame(this.tweenId),this.controls.enabled=!0;for(let e of this.disposables)e.dispose();this.renderer.dispose(),this.overlay.remove()}}};function Px(i){let e=i.split("-"),t=new R,n=0;for(let[s,r]of pd)e.includes(s)&&(t.add(r),n++);return n===0||t.lengthSq()===0?null:t.normalize()}var Ix=25,md=5073918,gd=16751165,Lx=6;function Ts(i,e,t){return`${Math.round(i*1e5)},${Math.round(e*1e5)},${Math.round(t*1e5)}`}var il=class{parent;constructor(e){this.parent=new Int32Array(e);for(let t=0;t<e;t++)this.parent[t]=t}find(e){for(;this.parent[e]!==e;)this.parent[e]=this.parent[this.parent[e]],e=this.parent[e];return e}union(e,t){let n=this.find(e),s=this.find(t);n!==s&&(this.parent[s]=n)}};function Dx(i){let e=i.geometry,t=e.getAttribute("position"),n=e.getIndex(),s=t.array,r=Math.floor((n!==null?n.count:t.count)/3),a=(_,S)=>n!==null?n.getX(_*3+S):_*3+S,o=[],l=new Float64Array(r),c=new R,h=new R,d=new R,u=new R,f=new R;for(let _=0;_<r;_++){c.fromArray(s,a(_,0)*3),h.fromArray(s,a(_,1)*3),d.fromArray(s,a(_,2)*3),u.subVectors(h,c),f.subVectors(d,c);let S=new R().crossVectors(u,f);l[_]=S.length()/2,o.push(S.normalize())}let g=new Map;for(let _=0;_<r;_++)for(let S=0;S<3;S++){let M=a(_,S)*3,A=a(_,(S+1)%3)*3,y=Ts(s[M],s[M+1],s[M+2]),T=Ts(s[A],s[A+1],s[A+2]),I=y<T?`${y}|${T}`:`${T}|${y}`,P=g.get(I);P===void 0?g.set(I,[{tri:_,ka:y,kb:T}]):P.push({tri:_,ka:y,kb:T})}let b=Math.cos(Ix*Math.PI/180),m=new il(r);for(let _ of g.values())for(let S=0;S<_.length;S++)for(let M=S+1;M<_.length;M++){let A=_[S],y=_[M];A===void 0||y===void 0||A.ka===y.ka&&A.kb===y.kb||o[A.tri].dot(o[y.tri])>=b&&m.union(A.tri,y.tri)}let p=new Map,C=new Uint32Array(r),w=[];for(let _=0;_<r;_++){let S=m.find(_),M=p.get(S);M===void 0&&(M=w.length,p.set(S,M),w.push({triangles:[],area:0})),C[_]=M;let A=w[M];A!==void 0&&(A.triangles.push(_),A.area+=l[_])}return{regionOf:C,regions:w}}function Nx(i,e,t){let n=i.geometry,s=n.getAttribute("position"),r=n.getIndex(),a=s.array,o=Math.floor((r!==null?r.count:s.count)/3),l=(_,S)=>r!==null?r.getX(_*3+S):_*3+S,c=new Map;for(let _=0;_<o;_++){let S=e.regionOf[_];for(let M=0;M<3;M++){let A=l(_,M)*3,y=l(_,(M+1)%3)*3,T=Ts(a[A],a[A+1],a[A+2]),I=Ts(a[y],a[y+1],a[y+2]),P=T<I?`${T}|${I}`:`${I}|${T}`,F=c.get(P);F===void 0?c.set(P,[S]):F.includes(S)||F.push(S)}}let h=t.length/6,d=new il(h),u=new Map,f=[];for(let _=0;_<h;_++){let S=t[_*6],M=t[_*6+1],A=t[_*6+2],y=t[_*6+3],T=t[_*6+4],I=t[_*6+5],P=Ts(S,M,A),F=Ts(y,T,I);f.push([P,F]);let G=u.get(P);G===void 0?u.set(P,[_]):G.push(_);let X=u.get(F);X===void 0?u.set(F,[_]):X.push(_)}let g=_=>{let[S,M]=f[_]??["",""],A=S<M?`${S}|${M}`:`${M}|${S}`;return(c.get(A)??[]).slice().sort((y,T)=>y-T).join(",")},b=[];for(let _=0;_<h;_++)b.push(g(_));for(let _=0;_<h;_++){let[S,M]=f[_]??["",""];for(let A of[S,M]){let y=u.get(A)??[];for(let T of y)T<=_||b[_]===b[T]&&d.union(_,T)}}let m=new Map,p=new Uint32Array(h),C=[];for(let _=0;_<h;_++){let S=d.find(_),M=m.get(S);M===void 0&&(M=C.length,m.set(S,M),C.push({length:0,closed:!0})),p[_]=M;let A=C[M];if(A!==void 0){let y=t[_*6+3]-t[_*6],T=t[_*6+4]-t[_*6+1],I=t[_*6+5]-t[_*6+2];A.length+=Math.sqrt(y*y+T*T+I*I)}}let w=new Map;for(let _=0;_<h;_++){let[S,M]=f[_]??["",""],A=p[_];w.set(`${A}:${S}`,(w.get(`${A}:${S}`)??0)+1),w.set(`${A}:${M}`,(w.get(`${A}:${M}`)??0)+1)}for(let _=0;_<C.length;_++){let S=!0,M=!1;for(let y=0;y<h;y++){if(p[y]!==_)continue;M=!0;let[T,I]=f[y]??["",""];((w.get(`${_}:${T}`)??0)!==2||(w.get(`${_}:${I}`)??0)!==2)&&(S=!1)}let A=C[_];A!==void 0&&(A.closed=M&&S)}return{groupOf:p,groups:C}}var Lr=class{constructor(e){this.options=e;let{domElement:t,cad:n}=e;for(let r of[this.hoverFaceMesh,this.selectFaceMesh,this.hoverEdgeLines,this.selectEdgeLines])r.raycast=()=>{},r.renderOrder=r instanceof xn?3:2,r.visible=!1;this.disposables.push(this.hoverFaceMesh.material,this.hoverFaceMesh.geometry,this.selectFaceMesh.material,this.selectFaceMesh.geometry,this.hoverEdgeLines.material,this.hoverEdgeLines.geometry,this.selectEdgeLines.material,this.selectEdgeLines.geometry);let s=new gn().setFromObject(n).getSize(new R);this.center=new gn().setFromObject(n).getCenter(new R),this.label=document.createElement("div"),this.label.style.cssText='position:absolute;left:8px;bottom:8px;z-index:5;pointer-events:none;font:500 11px/16px -apple-system,"Segoe UI",sans-serif;color:var(--dsw-alias-label-secondary,#374151);background:var(--dsw-alias-bg-base,rgba(255,255,255,0.88));border:1px solid var(--dsw-alias-border-l1,rgba(215,219,224,0.7));border-radius:8px;padding:2px 8px;opacity:0;transition:opacity 120ms;white-space:nowrap;',t.addEventListener("pointermove",this.onPointerMove),t.addEventListener("pointerleave",this.onPointerLeave),t.addEventListener("pointerdown",this.onPointerDown),t.addEventListener("pointerup",this.onPointerUp)}options;raycaster=new Li;meshes=[];faceCache=new Map;edgeCache=new Map;label;hover=null;selection=null;down=null;disposed=!1;center;disposables=[];hoverFaceMesh=new wt(new mt,new on({color:md,transparent:!0,opacity:.35,depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2}));selectFaceMesh=new wt(new mt,new on({color:gd,transparent:!0,opacity:.45,depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-3,polygonOffsetUnits:-3}));hoverEdgeLines=new xn(new mt,new _n({color:md,depthTest:!1,transparent:!0,opacity:.95}));selectEdgeLines=new xn(new mt,new _n({color:gd,depthTest:!1,transparent:!0,opacity:1}));meshesOf(){return this.meshes.length=0,this.options.cad.traverse(e=>{e.isMesh&&this.meshes.push(e)}),this.meshes}facesOf(e){let t=this.faceCache.get(e);return t===void 0&&(t=Dx(e),this.faceCache.set(e,t)),t}edgesOf(e){let t=e.userData.edges;if(t===void 0)return null;let n=this.edgeCache.get(e);if(n===void 0){let r=t.geometry.getAttribute("position").array;n=Nx(e,this.facesOf(e),r),this.edgeCache.set(e,n)}let s=t.geometry.getAttribute("position").array;return{groups:n,segments:s}}pick(e){let{domElement:t,camera:n}=this.options,s=t.getBoundingClientRect(),r=new ee((e.clientX-s.left)/s.width*2-1,-((e.clientY-s.top)/s.height)*2+1);this.raycaster.setFromCamera(r,n);let a=this.meshesOf(),o=this.raycaster.intersectObjects(a,!1)[0],c=2*(o?.distance??n.position.distanceTo(this.center))*Math.tan(n.fov*Math.PI/180/2)/Math.max(s.height,1),h=Lx*c;this.raycaster.params.Line.threshold=h;let d=null;for(let f of a){let g=f.userData.edges;if(g===void 0)continue;let m=this.raycaster.intersectObject(g,!1)[0];if(m!==void 0&&(d===null||m.distance<d.distance)){let p=Math.floor((m.index??0)/2);d={mesh:f,distance:m.distance,segment:p}}}if(d!==null&&(o===void 0||d.distance<=o.distance+h)){let f=this.edgesOf(d.mesh);if(f!==null)return{kind:"edge",mesh:d.mesh,group:f.groups.groupOf[d.segment]??0}}if(o===void 0||o.face===void 0)return null;let u=this.facesOf(o.object).regionOf[o.faceIndex??0]??0;return{kind:"face",mesh:o.object,region:u}}onPointerMove=e=>{if(!this.disposed){if(e.buttons!==0){this.setHover(null);return}this.setHover(this.pick(e))}};onPointerLeave=()=>{this.setHover(null)};onPointerDown=e=>{e.button===0&&(this.down={x:e.clientX,y:e.clientY,at:performance.now()})};onPointerUp=e=>{if(this.disposed)return;let t=this.down;if(this.down=null,t===null||e.button!==0||Math.hypot(e.clientX-t.x,e.clientY-t.y)>5||performance.now()-t.at>600)return;let s=this.pick(e);this.setSelection(s)};setHover(e){_d(e,this.hover)||(this.hover=e,this.refresh())}invalidate(){this.faceCache.clear(),this.edgeCache.clear(),this.selection=null,this.hover=null,this.refresh()}setSelection(e){this.selection=e,this.refresh()}refresh(){let e=(l,c,h)=>{let u=this.facesOf(l).regions[c];if(u===void 0){h.visible=!1;return}let f=l.geometry,g=f.getAttribute("position"),b=f.getIndex(),m=g.array,p=new Float32Array(u.triangles.length*9),C=0;for(let w of u.triangles)for(let _=0;_<3;_++){let S=(b!==null?b.getX(w*3+_):w*3+_)*3;p[C++]=m[S],p[C++]=m[S+1],p[C++]=m[S+2]}h.geometry.dispose(),h.geometry=new mt,h.geometry.setAttribute("position",new Tt(p,3)),l!==h.parent&&l.add(h),h.visible=!0},t=(l,c,h)=>{let d=this.edgesOf(l);if(d===null){h.visible=!1;return}let{groups:u,segments:f}=d,g=[];for(let b=0;b<u.groupOf.length;b++)if(u.groupOf[b]===c)for(let m=0;m<6;m++)g.push(f[b*6+m]);h.geometry.dispose(),h.geometry=new mt,h.geometry.setAttribute("position",new xt(g,3)),l!==h.parent&&l.add(h),h.visible=!0},n=(...l)=>{for(let c of l)c.visible=!1},s=_d(this.hover,this.selection)?null:this.hover,r=this.selection;s!==null&&s.kind==="face"?e(s.mesh,s.region,this.hoverFaceMesh):n(this.hoverFaceMesh),s!==null&&s.kind==="edge"?t(s.mesh,s.group,this.hoverEdgeLines):n(this.hoverEdgeLines),r!==null&&r.kind==="face"?e(r.mesh,r.region,this.selectFaceMesh):n(this.selectFaceMesh),r!==null&&r.kind==="edge"?t(r.mesh,r.group,this.selectEdgeLines):n(this.selectEdgeLines);let a=this.hover??r,o=this.options.domElement.parentElement;if(a!==null){let l=a.mesh.name.length>0?`${a.mesh.name} \xB7 `:"";if(a.kind==="face"){let c=this.facesOf(a.mesh).regions[a.region]?.area??0;this.label.textContent=`${l}face \xB7 ${c.toLocaleString(void 0,{maximumFractionDigits:1})} mm\xB2`}else{let c=this.edgesOf(a.mesh)?.groups.groups[a.group],h=c?.length??0;this.label.textContent=`${l}edge \xB7 ${h.toLocaleString(void 0,{maximumFractionDigits:1})} mm${c?.closed===!0?" \xB7 closed":""}`}this.label.style.opacity="1",this.label.parentElement!==o&&o!==null&&o.appendChild(this.label)}else this.label.style.opacity="0",this.label.textContent="";this.options.domElement.style.cursor=a===null?"grab":"pointer"}dispose(){if(this.disposed)return;this.disposed=!0;let{domElement:e}=this.options;e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerleave",this.onPointerLeave),e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointerup",this.onPointerUp);for(let t of[this.hoverFaceMesh,this.selectFaceMesh,this.hoverEdgeLines,this.selectEdgeLines])t.removeFromParent();for(let t of this.disposables)t.dispose();this.label.remove()}};function _d(i,e){return i===null||e===null?i===e:i.kind===e.kind&&i.mesh===e.mesh&&(i.kind==="face"?i.region===e.region:i.group===e.group)}function xd(){let i=new ps;i.moveTo(0,0),i.lineTo(60,0),i.lineTo(60,12),i.lineTo(12,12),i.lineTo(12,60),i.lineTo(0,60),i.closePath();let e=new Pi;e.absarc(36,6,5,0,Math.PI*2,!0),i.holes.push(e);let t=new hr(i,{depth:100,bevelEnabled:!1,curveSegments:32});return t.translate(-30,-30,0),t}var yd={min:{x:-30,y:-30,z:0},max:{x:30,y:30,z:100}};var Ux=25,Hc={x:13777723,y:3055172,z:2846678};function Gc(i,e){let t=document.createElement("canvas");t.width=64,t.height=64;let n=t.getContext("2d");n!==null&&(n.font='bold 44px -apple-system, "Segoe UI", sans-serif',n.textAlign="center",n.textBaseline="middle",n.fillStyle=`#${e.toString(16).padStart(6,"0")}`,n.fillText(i,32,34));let s=new Ri(t);s.needsUpdate=!0;let r=new hs({map:s,transparent:!0}),a=new Qs(r);return a.scale.set(1,1,1),a}function vd(i,e={}){let t=new Ss({antialias:!0,alpha:!0});t.setPixelRatio(window.devicePixelRatio),t.setSize(i.clientWidth||360,i.clientHeight||300),i.appendChild(t.domElement),t.domElement.style.width="100%",t.domElement.style.height="100%",t.domElement.style.display="block";let n=new Vt(45,1,.01,1e4);n.up.set(0,0,1);let s=new nl(n,t.domElement);s.enableDamping=!0,s.dampingFactor=.12,e.autoRotate===!0&&(s.autoRotate=!0,s.autoRotateSpeed=.8);let r=()=>{let o=i.clientWidth,l=i.clientHeight;o===0||l===0||(t.setSize(o,l,!1),n.aspect=o/l,n.updateProjectionMatrix(),e.onResize?.(o,l))},a=new ResizeObserver(r);return a.observe(i),{renderer:t,camera:n,controls:s,dispose(){a.disconnect(),s.dispose(),t.dispose(),t.domElement.parentNode===i&&i.removeChild(t.domElement)}}}function bd(i,e){let t=new Ht,n=new mr(e*2,20,9081244,4869976);n.rotation.x=Math.PI/2,t.add(n);let s=new gr(e);t.add(s);let r=e*1.12,a=e*.14,o=Gc("X",Hc.x);o.position.set(r,0,0),o.scale.set(a,a,a),t.add(o);let l=Gc("Y",Hc.y);l.position.set(0,r,0),l.scale.set(a,a,a),t.add(l);let c=Gc("Z",Hc.z);return c.position.set(0,0,r),c.scale.set(a,a,a),t.add(c),i.add(t),[t,n,s,o,l,c]}function Wc(i){for(let e of i)e.traverse(t=>{let n=t;if(n.isMesh){n.geometry?.dispose();let a=n.material;Array.isArray(a)?a.forEach(o=>o.dispose()):a?.dispose()}let s=t;s.isLineSegments&&(s.geometry?.dispose(),s.material?.dispose());let r=t;r.isSprite&&(r.material.map?.dispose(),r.material.dispose())})}function Fx(i){let e=i.userData.edges;if(e!==void 0)return e;let t=i.geometry;if(t===void 0)return;let n=i.material;n.polygonOffset=!0,n.polygonOffsetFactor=1,n.polygonOffsetUnits=1;let s=new xn(new nr(t,Ux),new _n({color:3358799,transparent:!0,opacity:.9}));return i.add(s),i.userData.edges=s,s}function sl(i,e){i.traverse(t=>{let n=t;if(!n.isMesh)return;let s=n.material;s.wireframe=e==="wireframe";let r=e==="shaded-edges"?Fx(n):n.userData.edges;r!==void 0&&(r.visible=e==="shaded-edges")})}function Xc(i){let e="geometry"in i?i.geometry:(()=>{let s=new mt,r=typeof i.positions=="string"?kc(i.positions):i.positions;if(s.setAttribute("position",new Tt(r,3)),i.normals!==void 0){let o=typeof i.normals=="string"?kc(i.normals):i.normals;s.setAttribute("normal",new Tt(o,3))}else s.computeVertexNormals();let a=typeof i.indices=="string"?dd(i.indices):i.indices;return s.setIndex(new Tt(a,1)),s})(),t=i.color===void 0?10466503:i.color,n=new ur({color:t,metalness:.15,roughness:.55,flatShading:i.normals===void 0,side:ln});return new wt(e,n)}function Md(i,e={}){let t=vd(i,{onResize:()=>{w||p()}}),n=new ni,s=new Ht;n.add(s);let r=new Ht;r.add(Xc({name:"demo-bracket",geometry:xd()})),s.add(r);let a={...yd},o=new R(a.max.x-a.min.x,a.max.y-a.min.y,a.max.z-a.min.z),l=new R((a.max.x+a.min.x)/2,(a.max.y+a.min.y)/2,(a.max.z+a.min.z)/2),c=Math.max(o.x,o.y,o.z,1e-6);n.add(r);let h=new gs(16777215,5857131,1.1);n.add(h);let d=new ci(16777215,1.6);n.add(d);let u=new ci(16777215,.5);n.add(u);let f=()=>{d.position.set(l.x+c,l.y+c*1.4,l.z+c*.8),u.position.set(l.x-c,l.y+c*.4,l.z-c*.6)};f();let g=bd(n,c),b=g[1],m="shaded-edges",p=()=>{let G=Sd(c,t.camera.aspect,t.camera.fov);t.camera.position.set(l.x+G*.7,l.y+G*.55,l.z+G*.6),t.controls.target.copy(l),t.controls.update()},C=()=>{b.position.set(l.x,l.y,a.min.z),t.camera.near=c/100,t.camera.far=c*40,sl(s,m),f(),p()};C();let w=!1,_=()=>{w=!0};t.renderer.domElement.addEventListener("pointerdown",_,{passive:!0}),t.renderer.domElement.addEventListener("wheel",_,{passive:!0});let S=new Ir({container:i,camera:t.camera,controls:t.controls,onHome:p}),M=new Lr({domElement:t.renderer.domElement,camera:t.camera,cad:s}),A=!1,y=G=>{if(!A){s.remove(r),Wc([r]),M.invalidate(),r=new Ht;for(let X of G.meshes)r.add(Xc(X));s.add(r),a=G.bounds,o=new R(a.max.x-a.min.x,a.max.y-a.min.y,a.max.z-a.min.z),l=new R((a.max.x+a.min.x)/2,(a.max.y+a.min.y)/2,(a.max.z+a.min.z)/2),c=Math.max(o.x,o.y,o.z,1e-6),C()}},T=!1,I=G=>{fetch(`/dsh-cad/demo-scene?part=${G}`).then(X=>X.ok?X.json():Promise.reject(new Error(`HTTP ${X.status}`))).then(X=>{A||(y(X),T=!0,e.onSource?.("brep"))}).catch(()=>{A||e.onSource?.(T?"brep":"fallback")})};I(e.part??"bracket");let P=()=>{F=requestAnimationFrame(P),t.controls.update(),t.renderer.render(n,t.camera),S.update()},F=requestAnimationFrame(P);return{setWireframe(G){this.setRenderMode(G?"wireframe":"shaded-edges")},setRenderMode(G){m=G,sl(s,m)},loadPart:I,resetView:p,dispose(){A=!0,cancelAnimationFrame(F),M.dispose(),S.dispose(),Wc([s,...g,h,d,u]),t.dispose()}}}function Sd(i,e,t){let n=t*Math.PI/180,s=2*Math.atan(Math.tan(n/2)*(Number.isFinite(e)&&e>0?e:1)),r=Math.min(n,s);return i/2/Math.tan(r/2)*1.5}function Ed(i,e){let t=vd(i,{onResize:()=>{b||g()}}),n=new ni,s=new Ht;for(let M of e.meshes)s.add(Xc(M));let r=e.bounds,a=new R(r.max.x-r.min.x,r.max.y-r.min.y,r.max.z-r.min.z),o=new R((r.max.x+r.min.x)/2,(r.max.y+r.min.y)/2,(r.max.z+r.min.z)/2),l=Math.max(a.x,a.y,a.z,1e-6);n.add(s);let c=new gs(16777215,5857131,1.1);n.add(c);let h=new ci(16777215,1.6);h.position.set(o.x+l,o.y+l*1.4,o.z+l*.8),n.add(h);let d=new ci(16777215,.5);d.position.set(o.x-l,o.y+l*.4,o.z-l*.6),n.add(d);let u=bd(n,l);u[1].position.set(o.x,o.y,r.min.z),t.camera.near=l/100,t.camera.far=l*40;let g=()=>{let M=Sd(l,t.camera.aspect,t.camera.fov);t.camera.position.set(o.x+M*.7,o.y+M*.55,o.z+M*.6),t.controls.target.copy(o),t.controls.update()};g();let b=!1,m=()=>{b=!0};t.renderer.domElement.addEventListener("pointerdown",m,{passive:!0}),t.renderer.domElement.addEventListener("wheel",m,{passive:!0});let p=new Ir({container:i,camera:t.camera,controls:t.controls,onHome:g});sl(s,"shaded-edges");let w=new Lr({domElement:t.renderer.domElement,camera:t.camera,cad:s}),_=()=>{S=requestAnimationFrame(_),t.controls.update(),t.renderer.render(n,t.camera),p.update()},S=requestAnimationFrame(_);return{setWireframe(M){this.setRenderMode(M?"wireframe":"shaded-edges")},setRenderMode(M){sl(s,M)},resetView:g,dispose(){cancelAnimationFrame(S),w.dispose(),p.dispose(),Wc([s,...u,c,h,d]),t.dispose()}}}var Fi=Br(require("react"),1);function qc(i){let{min:e,max:t}=i.bounds,n=Math.max(t.x-e.x,1e-6),s=Math.max(t.y-e.y,1e-6),r=Math.max(n,s)*.05;return{x:e.x-r,y:-t.y-r,width:n+r*2,height:s+r*2}}function Td(i){return i.color===void 0?"var(--dsh-cad-stroke, #4c5561)":`#${i.color.toString(16).padStart(6,"0")}`}function Ox(i){let e=[];for(let t=0;t+1<i.length;t+=2)e.push(`${i[t].toFixed(3)},${i[t+1].toFixed(3)}`);return e.join(" ")}function Bx(i,e,t,n,s){let r=n*(Math.PI/180),a=s*(Math.PI/180),o=i+t*Math.cos(r),l=e+t*Math.sin(r),c=i+t*Math.cos(a),h=e+t*Math.sin(a),d=((a-r)%(Math.PI*2)+Math.PI*2)%(Math.PI*2)>Math.PI?1:0;return`M ${o.toFixed(4)} ${l.toFixed(4)} A ${t.toFixed(4)} ${t.toFixed(4)} 0 ${d} 1 ${c.toFixed(4)} ${h.toFixed(4)}`}function wd(i){return i.entities.map((e,t)=>{let n=`e${t}`,s=e.layer==="hidden",r=e.layer==="paper"||e.layer==="dim",a={stroke:Td(e),fill:"none",strokeWidth:s||r?1:1.6,vectorEffect:"non-scaling-stroke",...s?{strokeDasharray:"6 4"}:{}};switch(e.type){case"line":return Fi.default.createElement("line",{key:n,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,style:a});case"circle":return Fi.default.createElement("circle",{key:n,cx:e.cx,cy:e.cy,r:e.r,style:a});case"arc":return Fi.default.createElement("path",{key:n,d:Bx(e.cx,e.cy,e.r,e.startAngle,e.endAngle),style:a});case"polyline":return Fi.default.createElement("polyline",{key:n,points:Ox(e.points),fill:"none",style:a});case"text":return Fi.default.createElement("g",{key:n,transform:`translate(${e.x} ${e.y}) scale(1 -1) rotate(${(e.rotation??0)*-1})`},Fi.default.createElement("text",{x:0,y:0,fontSize:e.height,fill:Td(e),style:{userSelect:"none"}},e.text))}})}var Oi=["shaded-edges","shaded","wireframe"],Zc={"shaded-edges":"Faces+Edges",shaded:"Faces",wireframe:"Wireframe"},Ad=null,Yc=new Set,Cd={part:null,assembly:null,drawing:null};function Rd(i){Ad={meta:i,at:Date.now()};let e=i.doc??"part";Cd[e]={meta:i,at:Date.now()};for(let t of Yc)t()}function Pd(){return Ad}function Dr(i){return Cd[i]}function Id(i){return Yc.add(i),()=>{Yc.delete(i)}}function Ld(i){let e=i.meta;if(e===null||typeof e!="object")return null;let t=e;return typeof t.viewId=="string"&&(t.kind==="3d"||t.kind==="2d")?t:null}function zx(i){let e=new DataView(i);if(e.getUint32(0,!0)!==826426180)throw new Error("bad scene magic");let n=e.getUint32(4,!0),s=new TextDecoder().decode(new Uint8Array(i,8,n)).replace(/\u0000+$/,""),r=JSON.parse(s),a=8+n;return{kind:"3d",format:"model",meshes:r.meshes.map(l=>({name:l.name,...l.color===void 0?{}:{color:l.color},positions:new Float32Array(i,a+l.posOffset,l.posBytes/4),...l.nrmOffset===void 0?{}:{normals:new Float32Array(i,a+l.nrmOffset,(l.nrmBytes??0)/4)},indices:new Uint32Array(i,a+l.idxOffset,l.idxBytes/4),vertexCount:l.vertexCount,triangleCount:l.triangleCount})),bounds:{min:{x:r.bounds.min[0],y:r.bounds.min[1],z:r.bounds.min[2]},max:{x:r.bounds.max[0],y:r.bounds.max[1],z:r.bounds.max[2]}},units:r.units}}function As(i){let[e,t]=(0,St.useState)(null),[n,s]=(0,St.useState)(null);return(0,St.useEffect)(()=>{if(i===void 0)return;let r=!1;t(null),s(null);let a=i.includes("/dsh-cad/bin/");return fetch(i).then(async o=>{if(!o.ok)throw new Error(`scene fetch failed: HTTP ${o.status}`);return a?zx(await o.arrayBuffer()):await o.json()}).then(o=>{r||t(o)}).catch(o=>{r||s(o instanceof Error?o.message:String(o))}),()=>{r=!0}},[i]),{scene:e,error:n}}function Cs({scene:i,error:e,height:t,fill:n}){return e!==null?It.default.createElement("div",{style:At.error},e):i===null?It.default.createElement("div",{style:At.placeholder},"loading\u2026"):i.kind==="3d"?It.default.createElement(kx,{scene:i,height:t,fill:n}):It.default.createElement(Vx,{scene:i,height:t,fill:n})}function kx({scene:i,height:e,fill:t}){let n=(0,St.useRef)(null),s=(0,St.useRef)(null),[r,a]=(0,St.useState)("shaded-edges");(0,St.useEffect)(()=>{let c=n.current;if(c===null)return;let h=Ed(c,i);return s.current=h,h.setRenderMode(r),()=>{h.dispose(),s.current=null}},[i]),(0,St.useEffect)(()=>{s.current?.setRenderMode(r)},[r]);let o=(0,St.useCallback)(()=>{a(c=>Oi[(Oi.indexOf(c)+1)%Oi.length])},[]),l=(0,St.useCallback)(()=>{s.current?.resetView()},[]);return It.default.createElement("div",{style:t===!0?ws.wrap:At.viewportWrap},It.default.createElement("div",{ref:n,style:t===!0?ws.viewport:{...At.viewport,height:e??360}}),It.default.createElement("div",{style:At.toolbar},It.default.createElement("button",{type:"button",style:At.button,onClick:o,"aria-pressed":r==="wireframe"},Zc[r]),It.default.createElement("button",{type:"button",style:At.button,onClick:l},"Reset view")))}function Vx({scene:i,height:e,fill:t}){let[n,s]=(0,St.useState)(()=>qc(i)),r=(0,St.useRef)(null),a=(0,St.useCallback)(()=>s(qc(i)),[i]),o=(0,St.useCallback)(d=>{d.preventDefault();let f=d.currentTarget.getBoundingClientRect(),g=n.x+(d.clientX-f.left)/f.width*n.width,b=n.y+(d.clientY-f.top)/f.height*n.height,m=d.deltaY<0?.85:1.18;s({x:g-(g-n.x)*m,y:b-(b-n.y)*m,width:n.width*m,height:n.height*m})},[n]),l=(0,St.useCallback)(d=>{r.current={x:d.clientX,y:d.clientY,viewBox:n},d.currentTarget.setPointerCapture(d.pointerId)},[n]),c=(0,St.useCallback)(d=>{let u=r.current;if(u===null)return;let g=d.currentTarget.getBoundingClientRect(),b=u.viewBox.width/g.width,m=u.viewBox.height/g.height;s({...u.viewBox,x:u.viewBox.x-(d.clientX-u.x)*b,y:u.viewBox.y-(d.clientY-u.y)*m})},[]),h=(0,St.useCallback)(()=>{r.current=null},[]);if(i.format==="svg"&&i.svgText!==void 0){let d=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(i.svgText)))}`;return It.default.createElement("div",{style:t===!0?ws.wrap:At.viewportWrap},It.default.createElement("div",{style:{...t===!0?ws.viewport:{...At.viewport,height:e??360},display:"flex",alignItems:"center",justifyContent:"center",background:"#ffffff"}},It.default.createElement("img",{src:d,alt:i.format,style:{maxWidth:"100%",maxHeight:"100%"}})),It.default.createElement("div",{style:At.toolbar}))}return It.default.createElement("div",{style:t===!0?ws.wrap:At.viewportWrap},It.default.createElement("svg",{viewBox:`${n.x} ${n.y} ${n.width} ${n.height}`,style:{...t===!0?ws.viewport:{...At.viewport,height:e??360},cursor:r.current===null?"default":"grabbing",touchAction:"none"},onWheel:o,onPointerDown:l,onPointerMove:c,onPointerUp:h,onPointerLeave:h},It.default.createElement("g",{transform:"scale(1 -1)"},wd(i))),It.default.createElement("div",{style:At.toolbar},It.default.createElement("button",{type:"button",style:At.button,onClick:a},"Fit")))}var At={viewportWrap:{position:"relative"},viewport:{width:"100%",background:"var(--dsh-cad-bg, linear-gradient(#f5f6f8, #e9ecf0))",display:"block"},toolbar:{position:"absolute",top:8,left:8,display:"flex",gap:6,zIndex:5},button:{border:"1px solid var(--dsw-alias-border-l2, #c4c9d0)",borderRadius:999,background:"var(--dsw-alias-bg-base, #fff)",color:"var(--dsw-alias-label-secondary, #374151)",fontSize:11,lineHeight:"16px",padding:"3px 10px",cursor:"pointer"},placeholder:{color:"var(--dsw-alias-label-tertiary, #6b7280)",fontSize:12,padding:"10px 12px"},error:{color:"var(--dsw-alias-state-error-primary, #b91c1c)",fontSize:12,padding:"10px 12px"}},ws={wrap:{position:"relative",flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column"},viewport:{flex:"1 1 auto",minHeight:0,width:"100%",background:"var(--dsh-cad-bg, linear-gradient(#f5f6f8, #e9ecf0))",display:"block"}};var Hx=360;function Dd({block:i}){let e=i.kind==="tool-call",t=e?void 0:Ld(i)??void 0,{scene:n,error:s}=As(t?.sceneUrl);return t!==void 0&&Rd(t),t===void 0?_i.default.createElement("div",{style:At.placeholder},e?"Converting CAD\u2026":"CAD result"):_i.default.createElement("div",{style:Nr.card},_i.default.createElement("div",{style:Nr.header},_i.default.createElement("span",{style:Nr.title},t.title),_i.default.createElement("span",{style:Nr.stats},Gx(t))),_i.default.createElement(Cs,{scene:n,error:s,height:Hx}),_i.default.createElement("div",{style:Nr.footer},n===null?t.sceneUrl===void 0?"headless composition: viewer unavailable, see summary above":"loading geometry\u2026":Wx(n)))}function Gx(i){if(i.kind==="3d"){let e=[];return i.stats.meshes!==void 0&&e.push(`${i.stats.meshes} part${i.stats.meshes===1?"":"s"}`),i.stats.triangles!==void 0&&e.push(`${i.stats.triangles.toLocaleString()} triangles`),e.join(" \xB7 ")}return i.stats.entities!==void 0?`${i.stats.entities.toLocaleString()} entities`:""}function Wx(i){if(i===null)return"";if(i.kind==="3d"){let s=i.bounds;return`size ${[s.max.x-s.min.x,s.max.y-s.min.y,s.max.z-s.min.z].map(a=>a.toFixed(2)).join(" \xD7 ")} ${i.units==="unitless"?"":i.units}`.trim()}let e=i.bounds,t=[(e.max.x-e.min.x).toFixed(2),(e.max.y-e.min.y).toFixed(2)],n=i.layers.length>0?` \xB7 ${i.layers.length} layers`:"";return`extent ${t.join(" \xD7 ")}${n}`}var Nr={card:{border:"1px solid var(--dsw-alias-border-l1, #d7dbe0)",borderRadius:10,margin:"6px 0",overflow:"hidden",display:"flex",flexDirection:"column",maxWidth:720,background:"var(--dsw-alias-bg-base, #fff)"},header:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,padding:"8px 12px"},title:{fontWeight:600,fontSize:13},stats:{fontSize:12,color:"var(--dsw-alias-label-tertiary, #6b7280)"},footer:{borderTop:"1px solid var(--dsw-alias-border-l1, #e5e7eb)",color:"var(--dsw-alias-label-tertiary, #6b7280)",fontSize:11,padding:"5px 12px"}};var se=Br(require("react"),1);function Xx(i){let e={part:void 0,assembly:void 0,drawing:void 0},t=i?.nodes??[];for(let n=t.length-1;n>=0;n--){let s=t[n];if(s===void 0)continue;let r=s.meta;if(s.kind==="tool-result"&&typeof r?.viewId=="string"&&(r.kind==="3d"||r.kind==="2d")){let a=r.doc??"part";e[a]===void 0&&(e[a]=r)}}return e}var qx=()=>()=>{},$c={part:void 0,assembly:void 0,drawing:void 0},Rs=$c;function Yx(i,e){let t=i?.(l=>l.current),n=(0,se.useMemo)(()=>{if(!(e===void 0||t===void 0))return e.binding?.(t)?.session},[e,t]),s=(0,se.useMemo)(()=>n===void 0?qx:l=>n.subscribe(l),[n]),r=(0,se.useMemo)(()=>n===void 0?()=>$c:()=>{let l=Xx(n.getSnapshot());return Rs!==$c&&Rs.part===l.part&&Rs.assembly===l.assembly&&Rs.drawing===l.drawing?Rs:(Rs=l,l)},[n]),a=(0,se.useSyncExternalStore)(s,r),[,o]=(0,se.useReducer)(l=>l+1,0);return(0,se.useEffect)(()=>Id(()=>{o()}),[]),e!==void 0?{part:a.part??null,assembly:a.assembly??Dr("assembly")?.meta??null,drawing:a.drawing??Dr("drawing")?.meta??null}:{part:Pd()?.meta??null,assembly:Dr("assembly")?.meta??null,drawing:Dr("drawing")?.meta??null}}var Nd={part:"Part Studio",assembly:"\u88C5\u914D\u4F53",drawing:"\u5DE5\u7A0B\u56FE"},Un=[{id:"part"}],Ps="part",Jc={tabs:Un,active:Ps},Kc=new Set;function jc(){Jc={tabs:Un,active:Ps};for(let i of Kc)i()}function Zx(i){Un.some(e=>e.id===i)||(Un=[...Un,{id:i}]),Ps=i,jc()}function $x(i){let e=Un.findIndex(t=>t.id===i);e!==-1&&(Un=Un.filter(t=>t.id!==i),Ps===i&&(Ps=(Un[e-1]??Un[e])?.id??null),jc())}function Ud(i){Ps=i,jc()}function Jx(){return(0,se.useSyncExternalStore)(i=>(Kc.add(i),()=>{Kc.delete(i)}),()=>Jc,()=>Jc)}var Is="currentColor";function Kx(){return se.default.createElement("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0},se.default.createElement("path",{d:"M8 1.5 14 5v6L8 14.5 2 11V5l6-3.5Z",stroke:Is,strokeWidth:"1.3",strokeLinejoin:"round"}),se.default.createElement("path",{d:"M2 5l6 3.5L14 5M8 8.5v6",stroke:Is,strokeWidth:"1.3",strokeLinejoin:"round"}))}function Bd(){return se.default.createElement("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0},se.default.createElement("path",{d:"M5.5 1.5 10 4v4L5.5 10.5 1 8V4l4.5-2.5Z",stroke:Is,strokeWidth:"1.2",strokeLinejoin:"round",opacity:"0.75"}),se.default.createElement("path",{d:"M10.5 5.5 15 8v4l-4.5 2.5L6 12V8l4.5-2.5Z",stroke:Is,strokeWidth:"1.2",strokeLinejoin:"round"}))}function zd(){return se.default.createElement("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0},se.default.createElement("path",{d:"M3 1.5h7l3 3V14.5H3V1.5Z",stroke:Is,strokeWidth:"1.3",strokeLinejoin:"round"}),se.default.createElement("path",{d:"M5.5 7h5M5.5 9.5h5M5.5 12h3",stroke:Is,strokeWidth:"1.2",strokeLinecap:"round"}))}function kd({kind:i}){return i==="assembly"?se.default.createElement(Bd,null):i==="drawing"?se.default.createElement(zd,null):se.default.createElement(Kx,null)}function Vd(i){let e=i.closest("[data-shell-overlay]");if(!(e instanceof HTMLElement))return{frame:null,detailsCol:null,centerCol:null};let t=e.parentElement instanceof HTMLElement?e.parentElement:null,n=e.previousElementSibling instanceof HTMLElement?e.previousElementSibling:null,s=n?.previousElementSibling instanceof HTMLElement?n.previousElementSibling:null;return{frame:t,detailsCol:n,centerCol:s}}function jx({frame:i,detailsCol:e,centerCol:t}){if(e!==null&&t!==null)return{right:e.getBoundingClientRect().width,centerWidth:t.getBoundingClientRect().width};if(i!==null){let n=getComputedStyle(i).gridTemplateColumns.trim().split(/\s+/).map(Number.parseFloat),s=n[1],r=n[2];if(Number.isFinite(s)&&Number.isFinite(r))return{right:r,centerWidth:s}}return{right:0,centerWidth:0}}function Qx(i){let[e,t]=(0,se.useState)({right:0,centerWidth:0});return(0,se.useLayoutEffect)(()=>{let n=i.current;if(n===null)return;let s=Vd(n),r=0,a=()=>{r=0;let c=jx(s);t(h=>Math.abs(h.right-c.right)<.5&&Math.abs(h.centerWidth-c.centerWidth)<.5?h:c)},o=()=>{r===0&&(r=requestAnimationFrame(a))},l=new ResizeObserver(o);for(let c of[s.frame,s.detailsCol,s.centerCol])c!==null&&l.observe(c);return window.addEventListener("resize",o),a(),()=>{l.disconnect(),window.removeEventListener("resize",o),r!==0&&cancelAnimationFrame(r)}},[i]),e}var Fd=280,Od=720,ey=460,ty=20,ny=.42,iy=[{kind:"part",label:"\u96F6\u4EF6",hint:"Part Studio \xB7 \u4E09\u7EF4\u5EFA\u6A21"},{kind:"assembly",label:"\u88C5\u914D\u4F53",hint:"Assembly \xB7 \u5B9E\u4F8B\u88C5\u914D"},{kind:"drawing",label:"\u5DE5\u7A0B\u56FE",hint:"Drawing \xB7 \u56FE\u7EB8\u8F93\u51FA"}];function sy({onPick:i,onClose:e}){let t=(0,se.useRef)(null);return(0,se.useEffect)(()=>{let n=r=>{t.current!==null&&r.target instanceof Node&&t.current.contains(r.target)||e()},s=r=>{r.key==="Escape"&&e()};return document.addEventListener("pointerdown",n,!0),document.addEventListener("keydown",s),()=>{document.removeEventListener("pointerdown",n,!0),document.removeEventListener("keydown",s)}},[e]),se.default.createElement("div",{ref:t,style:tt.menu,role:"menu","aria-label":"\u65B0\u5EFA\u6587\u6863"},iy.map(n=>se.default.createElement("button",{key:n.kind,type:"button",role:"menuitem",style:tt.menuItem,onClick:()=>{i(n.kind)}},se.default.createElement("span",{style:tt.menuIcon},se.default.createElement(kd,{kind:n.kind})),se.default.createElement("span",{style:tt.menuLabel},n.label),se.default.createElement("span",{style:tt.menuHint},n.hint))))}function Hd(i){return function(t){let n=(0,se.useRef)(null),[s,r]=(0,se.useState)(!0),[a,o]=(0,se.useState)(ey),[l,c]=(0,se.useState)(!1),h=Qx(n),d=Yx(t.useSessions,i),{tabs:u,active:f}=Jx(),g=(0,se.useMemo)(()=>{let _=h.centerWidth>0?Math.max(Fd,h.centerWidth*ny):Od;return Math.round(Math.min(a,_))},[a,h.centerWidth]);ry(n,s,g);let b=(0,se.useRef)(null),m=_=>{_.preventDefault(),b.current={startX:_.clientX,startWidth:g},_.currentTarget.setPointerCapture(_.pointerId)},p=_=>{let S=b.current;if(S===null)return;let M=S.startWidth+(S.startX-_.clientX);o(Math.round(Math.min(Od,Math.max(Fd,M))))},C=()=>{b.current=null},w=f===null?null:d[f];return se.default.createElement("div",{ref:n,"data-cad-side-panel":"",style:tt.root},s?se.default.createElement("div",{style:{...tt.panel,right:h.right,width:g}},se.default.createElement("div",{style:tt.resizer,onPointerDown:m,onPointerMove:p,onPointerUp:C,onPointerCancel:C,role:"separator","aria-orientation":"vertical","aria-label":"\u8C03\u6574 CAD \u9762\u677F\u5BBD\u5EA6"}),se.default.createElement("div",{style:tt.tabStripRow},se.default.createElement("div",{style:tt.tabStrip,role:"tablist","aria-label":"CAD \u6587\u6863"},u.map(_=>{let S=_.id===f;return se.default.createElement("div",{key:_.id,role:"tab","aria-selected":S,tabIndex:0,style:{...tt.tab,...S?tt.tabActive:{}},onClick:()=>{Ud(_.id)},onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&Ud(_.id)}},se.default.createElement("span",{style:S?tt.tabIconActive:tt.tabIcon},se.default.createElement(kd,{kind:_.id})),se.default.createElement("span",{style:tt.tabLabel},Nd[_.id]),se.default.createElement("button",{type:"button",style:tt.tabClose,"aria-label":`\u5173\u95ED ${Nd[_.id]}`,title:"\u5173\u95ED",onClick:M=>{M.stopPropagation(),$x(_.id)}},"\xD7"))}),se.default.createElement("button",{type:"button",style:tt.addTab,"aria-label":"\u65B0\u5EFA\u6587\u6863",title:"\u65B0\u5EFA\uFF1A\u96F6\u4EF6 / \u88C5\u914D\u4F53 / \u5DE5\u7A0B\u56FE",onClick:()=>{c(_=>!_)}},"+")),se.default.createElement("span",{style:tt.headerStats},w===null?"":cy(w)),se.default.createElement("button",{type:"button",style:tt.iconButton,onClick:()=>{r(!1)},"aria-label":"\u6536\u8D77 CAD \u9762\u677F",title:"\u6536\u8D77"},"\xBB")),l?se.default.createElement(sy,{onPick:_=>{c(!1),Zx(_)},onClose:()=>{c(!1)}}):null,se.default.createElement("div",{style:tt.body},f==="part"?se.default.createElement(ay,{meta:d.part}):null,f==="assembly"?se.default.createElement(oy,{meta:d.assembly}):null,f==="drawing"?se.default.createElement(ly,{meta:d.drawing}):null)):se.default.createElement("button",{type:"button",style:{...tt.rail,right:h.right+10},onClick:()=>{r(!0)},"aria-label":"\u5C55\u5F00 CAD \u9762\u677F",title:"\u5C55\u5F00 CAD \u89C6\u56FE"},"\xAB\xA0\xA0CAD"))}}function ry(i,e,t){(0,se.useLayoutEffect)(()=>{let n=i.current;if(n===null)return;let s=Vd(n).centerCol;if(s!==null)return s.style.paddingRight=e?`${ty+t}px`:"",()=>{s.style.paddingRight=""}},[i,e,t])}function ay({meta:i}){let{scene:e,error:t}=As(i?.sceneUrl);return i===null?se.default.createElement(uy,null):se.default.createElement("div",{key:i.sceneUrl??i.viewId,style:tt.sceneFill},se.default.createElement(Cs,{scene:e,error:t,fill:!0}))}function oy({meta:i}){let{scene:e,error:t}=As(i?.sceneUrl);return i===null?se.default.createElement(Gd,{icon:se.default.createElement(Bd,null),title:"\u88C5\u914D\u4F53\u4E3A\u7A7A",hint:"\u5728\u5BF9\u8BDD\u4E2D\u8BF4\u300C\u628A b1 \u548C b2 \u88C5\u914D\u8D77\u6765\uFF0Cb2 \u653E\u5230 (60, 0, 0)\u300D\uFF0C\u6216\u4F7F\u7528 cad_assembly_insert \u5DE5\u5177\u63D2\u5165\u5B9E\u4F8B"}):se.default.createElement("div",{key:i.sceneUrl??i.viewId,style:tt.sceneFill},se.default.createElement(Cs,{scene:e,error:t,fill:!0}))}function ly({meta:i}){let{scene:e,error:t}=As(i?.sceneUrl);return i===null?se.default.createElement(Gd,{icon:se.default.createElement(zd,null),title:"\u8FD8\u6CA1\u6709\u5DE5\u7A0B\u56FE",hint:"\u5728\u5BF9\u8BDD\u4E2D\u8BF4\u300C\u7ED9 b1 \u51FA\u4E00\u5F20 A3 \u5DE5\u7A0B\u56FE\u300D\uFF0C\u6216\u4F7F\u7528 cad_drawing \u5DE5\u5177\u751F\u6210\u4E09\u89C6\u56FE + \u8F74\u6D4B\u56FE"}):se.default.createElement("div",{key:i.sceneUrl??i.viewId,style:{...tt.sceneFill,background:"#fff"}},se.default.createElement(Cs,{scene:e,error:t,fill:!0}))}function Gd({icon:i,title:e,hint:t}){return se.default.createElement("div",{style:tt.emptyState},se.default.createElement("div",{style:tt.emptyIcon},i),se.default.createElement("div",{style:tt.emptyTitle},e),se.default.createElement("div",{style:tt.emptyHint},t))}function cy(i){let e=[];if(i.kind==="3d"){let t=i.doc==="assembly"?" \u5B9E\u4F8B":" \u4F53";i.stats.meshes!==void 0&&e.push(`${i.stats.meshes}${t}`),i.stats.triangles!==void 0&&e.push(`${i.stats.triangles.toLocaleString()} \u4E09\u89D2\u9762`)}else i.stats.entities!==void 0&&e.push(`${i.stats.entities.toLocaleString()} \u5B9E\u4F53`);return e.join(" \xB7 ")}var hy=[{id:"bracket",label:"Bracket"},{id:"flange",label:"Flange"},{id:"shaft",label:"Shaft"}];function uy(){let i=(0,se.useRef)(null),e=(0,se.useRef)(null),[t,n]=(0,se.useState)("shaded-edges"),[s,r]=(0,se.useState)("loading"),[a,o]=(0,se.useState)("bracket");(0,se.useEffect)(()=>{let h=i.current;if(h===null)return;let d=Md(h,{onSource:r,part:"bracket"});return e.current=d,()=>{d.dispose(),e.current=null}},[]),(0,se.useEffect)(()=>{e.current?.setRenderMode(t)},[t]);let l=h=>{h!==a&&(o(h),r("loading"),e.current?.loadPart(h))},c=(0,se.useCallback)(()=>{n(h=>Oi[(Oi.indexOf(h)+1)%Oi.length])},[]);return se.default.createElement("div",{style:tt.demoRoot},se.default.createElement("div",{style:tt.demoCaption},"CAD editor",s==="brep"?` \xB7 demo-${a}.brep`:s==="fallback"?" \xB7 \u672C\u5730\u515C\u5E95":" \xB7 \u52A0\u8F7D\u4E2D\u2026"),se.default.createElement("div",{style:tt.demoViewport},se.default.createElement("div",{ref:i,style:{width:"100%",height:"100%"}}),se.default.createElement("div",{style:At.toolbar},hy.map(h=>se.default.createElement("button",{key:h.id,type:"button",style:{...At.button,...a===h.id?{background:"var(--dsw-alias-label-primary,#4d6bfe)",color:"#fff",borderColor:"transparent"}:{}},onClick:()=>{l(h.id)},"aria-pressed":a===h.id},h.label)),se.default.createElement("button",{type:"button",style:At.button,onClick:c,"aria-pressed":t==="wireframe"},Zc[t]))),se.default.createElement("div",{style:tt.demoHint},"\u793A\u4F8B\u4EF6\uFF08\u652F\u67B6 / \u6CD5\u5170 / \u8F74\uFF09\u7531\u672C\u5730 .brep \u7ECF OCCT \u89E3\u6790\uFF0C\u53EF\u5207\u6362\uFF1B\u60AC\u505C/\u70B9\u9009\u9762\u4E0E\u8FB9\u67E5\u770B\u6D4B\u91CF\uFF1B\u5BF9\u8BDD\u4E2D\u5EFA\u6A21\u540E\u6B64\u9875\u7B7E\u81EA\u52A8\u8DDF\u8E2A\u6700\u65B0\u6A21\u578B"))}var tt={root:{position:"absolute",inset:0,pointerEvents:"none"},panel:{position:"absolute",top:0,bottom:0,pointerEvents:"auto",display:"flex",flexDirection:"column",minWidth:0,background:"var(--dsw-alias-bg-base, #fff)",borderLeft:"1px solid var(--dsw-alias-border-l2, #c4c9d0)",boxShadow:"-16px 0 28px -20px rgba(16,24,40,0.18)"},resizer:{position:"absolute",top:0,bottom:0,left:0,width:7,marginLeft:-3,cursor:"col-resize",zIndex:6,touchAction:"none"},tabStripRow:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px 6px 12px",flex:"none",borderBottom:"1px solid var(--dsw-alias-border-l1, #eceff3)",background:"var(--dsw-alias-bg-subtle, #f7f8fa)",position:"relative"},tabStrip:{display:"flex",alignItems:"center",gap:4,flex:"1 1 auto",minWidth:0,overflow:"hidden"},tab:{display:"flex",alignItems:"center",gap:5,padding:"4px 6px 4px 9px",borderRadius:7,border:"1px solid transparent",color:"var(--dsw-alias-label-tertiary, #6b7280)",cursor:"pointer",userSelect:"none",flex:"none",maxWidth:150,lineHeight:"18px"},tabActive:{background:"var(--dsw-alias-bg-base, #fff)",borderColor:"var(--dsw-alias-border-l1, #e2e5ea)",color:"var(--dsw-alias-label-primary, #1f2937)",boxShadow:"0 1px 2px rgba(16,24,40,0.06)"},tabIcon:{display:"flex",alignItems:"center",opacity:.75,flex:"none"},tabIconActive:{display:"flex",alignItems:"center",color:"var(--dsw-alias-label-primary, #4d6bfe)",flex:"none"},tabLabel:{fontSize:12,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},tabClose:{border:"none",background:"transparent",color:"var(--dsw-alias-label-tertiary, #9ca3af)",fontSize:13,lineHeight:"16px",width:16,height:16,borderRadius:4,cursor:"pointer",padding:0,flex:"none",textAlign:"center"},addTab:{flex:"none",width:24,height:24,marginLeft:2,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--dsw-alias-border-l1, #e2e5ea)",borderRadius:7,background:"var(--dsw-alias-bg-base, #fff)",color:"var(--dsw-alias-label-secondary, #374151)",fontSize:15,lineHeight:"18px",cursor:"pointer",padding:0},menu:{position:"absolute",top:40,left:12,zIndex:20,minWidth:230,padding:5,background:"var(--dsw-alias-bg-base, #fff)",border:"1px solid var(--dsw-alias-border-l1, #e2e5ea)",borderRadius:10,boxShadow:"0 12px 32px -12px rgba(16,24,40,0.24)",display:"flex",flexDirection:"column",gap:1},menuItem:{display:"flex",alignItems:"center",gap:8,padding:"7px 9px",border:"none",borderRadius:7,background:"transparent",color:"var(--dsw-alias-label-primary, #1f2937)",cursor:"pointer",textAlign:"left",font:"inherit",fontSize:12.5},menuIcon:{display:"flex",alignItems:"center",color:"var(--dsw-alias-label-secondary, #374151)",flex:"none"},menuLabel:{fontWeight:600,flex:"none"},menuHint:{color:"var(--dsw-alias-label-tertiary, #9ca3af)",fontSize:11,marginLeft:"auto",whiteSpace:"nowrap"},headerStats:{flex:"none",fontSize:11,color:"var(--dsw-alias-label-tertiary, #6b7280)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"30%"},iconButton:{flex:"none",border:"none",background:"transparent",color:"var(--dsw-alias-label-tertiary, #6b7280)",fontSize:15,lineHeight:"20px",width:26,height:26,borderRadius:6,cursor:"pointer",padding:0},body:{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column"},sceneFill:{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column"},emptyState:{flex:"1 1 auto",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,padding:24,color:"var(--dsw-alias-label-tertiary, #9ca3af)",textAlign:"center"},emptyIcon:{display:"flex",color:"var(--dsw-alias-label-tertiary, #c0c6cf)",transform:"scale(2)",marginBottom:6},emptyTitle:{fontSize:13,fontWeight:600,color:"var(--dsw-alias-label-secondary, #6b7280)"},emptyHint:{fontSize:11.5,lineHeight:"18px",maxWidth:300},demoRoot:{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column",gap:6,padding:"10px 10px 12px"},demoCaption:{color:"var(--dsw-alias-label-tertiary, #6b7280)",fontSize:11,textTransform:"uppercase",letterSpacing:"0.05em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:"none"},demoViewport:{position:"relative",flex:"1 1 auto",minHeight:0,borderRadius:10,overflow:"hidden",background:"var(--dsh-cad-bg, linear-gradient(#f5f6f8, #e9ecf0))"},demoHint:{flex:"none",color:"var(--dsw-alias-label-tertiary, #9ca3af)",fontSize:11,lineHeight:"17px",textAlign:"center"},rail:{position:"absolute",top:72,pointerEvents:"auto",writingMode:"vertical-rl",padding:"12px 6px",borderRadius:10,border:"1px solid var(--dsw-alias-border-l2, #c4c9d0)",background:"var(--dsw-alias-bg-base, #fff)",color:"var(--dsw-alias-label-secondary, #374151)",fontSize:11,letterSpacing:"0.08em",cursor:"pointer",boxShadow:"4px 4px 12px -6px rgba(16,24,40,0.2)"}};var dy=["slots"],fy=["cad_view","cad_create_prim","cad_extrude_profile","cad_boolean","cad_fillet","cad_transform","cad_export","cad_delete","cad_volume","cad_freecad","cad_image_profile","cad_drawing","cad_assembly_insert","cad_assembly_move","cad_assembly_remove"];function py(i){i.slots.onEntryError?.((n,s,r,a)=>{try{document.documentElement.setAttribute("data-cad-slot-crash",`${n}:${String(r instanceof Error?r.message:r).slice(0,160)}:abd=${String(a.abdicated)}`)}catch{}});for(let n of fy)i.slots.inject("tool.call.toolview",()=>i.slots.register({name:"tool.call.toolview",key:n,locale:"conversation"},Dd));let t=i.get?.("sessions");i.slots.inject("shell.overlay",()=>i.slots.register({name:"shell.overlay",id:"cad-side-panel",order:100,label:"CAD"},Hd(t)))}
|
|
4113
|
+
}`,Oc=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new er(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new tn({vertexShader:hx,fragmentShader:ux,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Tt(new ri(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Bc=class extends mn{constructor(e,t){super();let n=this,s=null,r=1,o=null,a="local-floor",l=1,c=null,h=null,d=null,u=null,f=null,g=null,y=typeof XRWebGLBinding<"u",m=new Oc,p={},C=t.getContextAttributes(),T=null,x=null,S=[],M=[],A=new te,v=null,w=new kt;w.viewport=new gt;let I=new kt;I.viewport=new gt;let P=[w,I],O=new ra,q=null,Y=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(J){let ce=S[J];return ce===void 0&&(ce=new us,S[J]=ce),ce.getTargetRaySpace()},this.getControllerGrip=function(J){let ce=S[J];return ce===void 0&&(ce=new us,S[J]=ce),ce.getGripSpace()},this.getHand=function(J){let ce=S[J];return ce===void 0&&(ce=new us,S[J]=ce),ce.getHandSpace()};function U(J){let ce=M.indexOf(J.inputSource);if(ce===-1)return;let re=S[ce];re!==void 0&&(re.update(J.inputSource,J.frame,c||o),re.dispatchEvent({type:J.type,data:J.inputSource}))}function G(){s.removeEventListener("select",U),s.removeEventListener("selectstart",U),s.removeEventListener("selectend",U),s.removeEventListener("squeeze",U),s.removeEventListener("squeezestart",U),s.removeEventListener("squeezeend",U),s.removeEventListener("end",G),s.removeEventListener("inputsourceschange",H);for(let J=0;J<S.length;J++){let ce=M[J];ce!==null&&(M[J]=null,S[J].disconnect(ce))}q=null,Y=null,m.reset();for(let J in p)delete p[J];e.setRenderTarget(T),f=null,u=null,d=null,s=null,x=null,et.stop(),n.isPresenting=!1,e.setPixelRatio(v),e.setSize(A.width,A.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(J){r=J,n.isPresenting===!0&&De("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(J){a=J,n.isPresenting===!0&&De("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(J){c=J},this.getBaseLayer=function(){return u!==null?u:f},this.getBinding=function(){return d===null&&y&&(d=new XRWebGLBinding(s,t)),d},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(J){if(s=J,s!==null){if(T=e.getRenderTarget(),s.addEventListener("select",U),s.addEventListener("selectstart",U),s.addEventListener("selectend",U),s.addEventListener("squeeze",U),s.addEventListener("squeezestart",U),s.addEventListener("squeezeend",U),s.addEventListener("end",G),s.addEventListener("inputsourceschange",H),C.xrCompatible!==!0&&await t.makeXRCompatible(),v=e.getPixelRatio(),e.getSize(A),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let re=null,Ie=null,ke=null;C.depth&&(ke=C.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,re=C.stencil?mi:Rn,Ie=C.stencil?Ms:yn);let Ue={colorFormat:t.RGBA8,depthFormat:ke,scaleFactor:r};d=this.getBinding(),u=d.createProjectionLayer(Ue),s.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),x=new Qt(u.textureWidth,u.textureHeight,{format:cn,type:Yt,depthTexture:new Wn(u.textureWidth,u.textureHeight,Ie,void 0,void 0,void 0,void 0,void 0,void 0,re),stencilBuffer:C.stencil,colorSpace:e.outputColorSpace,samples:C.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{let re={antialias:C.antialias,alpha:!0,depth:C.depth,stencil:C.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(s,t,re),s.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),x=new Qt(f.framebufferWidth,f.framebufferHeight,{format:cn,type:Yt,colorSpace:e.outputColorSpace,stencilBuffer:C.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}x.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await s.requestReferenceSpace(a),et.setContext(s),et.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function H(J){for(let ce=0;ce<J.removed.length;ce++){let re=J.removed[ce],Ie=M.indexOf(re);Ie>=0&&(M[Ie]=null,S[Ie].disconnect(re))}for(let ce=0;ce<J.added.length;ce++){let re=J.added[ce],Ie=M.indexOf(re);if(Ie===-1){for(let Ue=0;Ue<S.length;Ue++)if(Ue>=M.length){M.push(re),Ie=Ue;break}else if(M[Ue]===null){M[Ue]=re,Ie=Ue;break}if(Ie===-1)break}let ke=S[Ie];ke&&ke.connect(re)}}let j=new R,se=new R;function ue(J,ce,re){j.setFromMatrixPosition(ce.matrixWorld),se.setFromMatrixPosition(re.matrixWorld);let Ie=j.distanceTo(se),ke=ce.projectionMatrix.elements,Ue=re.projectionMatrix.elements,nt=ke[14]/(ke[10]-1),He=ke[14]/(ke[10]+1),Q=(ke[9]+1)/ke[5],ie=(ke[9]-1)/ke[5],ne=(ke[8]-1)/ke[0],xe=(Ue[8]+1)/Ue[0],me=nt*ne,Be=nt*xe,Ce=Ie/(-ne+xe),Ve=Ce*-ne;if(ce.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(Ve),J.translateZ(Ce),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert(),ke[10]===-1)J.projectionMatrix.copy(ce.projectionMatrix),J.projectionMatrixInverse.copy(ce.projectionMatrixInverse);else{let We=nt+Ce,L=He+Ce,ot=me-Ve,je=Be+(Ie-Ve),E=Q*He/L*We,_=ie*He/L*We;J.projectionMatrix.makePerspective(ot,je,E,_,We,L),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}}function le(J,ce){ce===null?J.matrixWorld.copy(J.matrix):J.matrixWorld.multiplyMatrices(ce.matrixWorld,J.matrix),J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(s===null)return;let ce=J.near,re=J.far;m.texture!==null&&(m.depthNear>0&&(ce=m.depthNear),m.depthFar>0&&(re=m.depthFar)),O.near=I.near=w.near=ce,O.far=I.far=w.far=re,(q!==O.near||Y!==O.far)&&(s.updateRenderState({depthNear:O.near,depthFar:O.far}),q=O.near,Y=O.far),O.layers.mask=J.layers.mask|6,w.layers.mask=O.layers.mask&-5,I.layers.mask=O.layers.mask&-3;let Ie=J.parent,ke=O.cameras;le(O,Ie);for(let Ue=0;Ue<ke.length;Ue++)le(ke[Ue],Ie);ke.length===2?ue(O,w,I):O.projectionMatrix.copy(w.projectionMatrix),Me(J,O,Ie)};function Me(J,ce,re){re===null?J.matrix.copy(ce.matrixWorld):(J.matrix.copy(re.matrixWorld),J.matrix.invert(),J.matrix.multiply(ce.matrixWorld)),J.matrix.decompose(J.position,J.quaternion,J.scale),J.updateMatrixWorld(!0),J.projectionMatrix.copy(ce.projectionMatrix),J.projectionMatrixInverse.copy(ce.projectionMatrixInverse),J.isPerspectiveCamera&&(J.fov=ls*2*Math.atan(1/J.projectionMatrix.elements[5]),J.zoom=1)}this.getCamera=function(){return O},this.getFoveation=function(){if(!(u===null&&f===null))return l},this.setFoveation=function(J){l=J,u!==null&&(u.fixedFoveation=J),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=J)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(O)},this.getCameraTexture=function(J){return p[J]};let Je=null;function ct(J,ce){if(h=ce.getViewerPose(c||o),g=ce,h!==null){let re=h.views;f!==null&&(e.setRenderTargetFramebuffer(x,f.framebuffer),e.setRenderTarget(x));let Ie=!1;re.length!==O.cameras.length&&(O.cameras.length=0,Ie=!0);for(let He=0;He<re.length;He++){let Q=re[He],ie=null;if(f!==null)ie=f.getViewport(Q);else{let xe=d.getViewSubImage(u,Q);ie=xe.viewport,He===0&&(e.setRenderTargetTextures(x,xe.colorTexture,xe.depthStencilTexture),e.setRenderTarget(x))}let ne=P[He];ne===void 0&&(ne=new kt,ne.layers.enable(He),ne.viewport=new gt,P[He]=ne),ne.matrix.fromArray(Q.transform.matrix),ne.matrix.decompose(ne.position,ne.quaternion,ne.scale),ne.projectionMatrix.fromArray(Q.projectionMatrix),ne.projectionMatrixInverse.copy(ne.projectionMatrix).invert(),ne.viewport.set(ie.x,ie.y,ie.width,ie.height),He===0&&(O.matrix.copy(ne.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale)),Ie===!0&&O.cameras.push(ne)}let ke=s.enabledFeatures;if(ke&&ke.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&y){d=n.getBinding();let He=d.getDepthInformation(re[0]);He&&He.isValid&&He.texture&&m.init(He,s.renderState)}if(ke&&ke.includes("camera-access")&&y){e.state.unbindTexture(),d=n.getBinding();for(let He=0;He<re.length;He++){let Q=re[He].camera;if(Q){let ie=p[Q];ie||(ie=new er,p[Q]=ie);let ne=d.getCameraImage(Q);ie.sourceTexture=ne}}}}for(let re=0;re<S.length;re++){let Ie=M[re],ke=S[re];Ie!==null&&ke!==void 0&&ke.update(Ie,ce,c||o)}Je&&Je(J,ce),ce.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ce}),g=null}let et=new sd;et.setAnimationLoop(ct),this.setAnimationLoop=function(J){Je=J},this.dispose=function(){}}},dx=new rt,hd=new Ge;hd.set(-1,0,0,0,1,0,0,0,1);function fx(i,e){function t(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,yc(i)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function s(m,p,C,T,x){p.isNodeMaterial?p.uniformsNeedUpdate=!1:p.isMeshBasicMaterial?r(m,p):p.isMeshLambertMaterial?(r(m,p),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)):p.isMeshToonMaterial?(r(m,p),d(m,p)):p.isMeshPhongMaterial?(r(m,p),h(m,p),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)):p.isMeshStandardMaterial?(r(m,p),u(m,p),p.isMeshPhysicalMaterial&&f(m,p,x)):p.isMeshMatcapMaterial?(r(m,p),g(m,p)):p.isMeshDepthMaterial?r(m,p):p.isMeshDistanceMaterial?(r(m,p),y(m,p)):p.isMeshNormalMaterial?r(m,p):p.isLineBasicMaterial?(o(m,p),p.isLineDashedMaterial&&a(m,p)):p.isPointsMaterial?l(m,p,C,T):p.isSpriteMaterial?c(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,t(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===qt&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,t(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===qt&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,t(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,t(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);let C=e.get(p),T=C.envMap,x=C.envMapRotation;T&&(m.envMap.value=T,m.envMapRotation.value.setFromMatrix4(dx.makeRotationFromEuler(x)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(hd),m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,m.aoMapTransform))}function o(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform))}function a(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function l(m,p,C,T){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*C,m.scale.value=T*.5,p.map&&(m.map.value=p.map,t(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function c(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function h(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function d(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function u(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,C){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===qt&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=C.texture,m.transmissionSamplerSize.value.set(C.width,C.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function y(m,p){let C=e.get(p).light;m.referencePosition.value.setFromMatrixPosition(C.matrixWorld),m.nearDistance.value=C.shadow.camera.near,m.farDistance.value=C.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function px(i,e,t,n){let s={},r={},o=[],a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(x,S){let M=S.program;n.uniformBlockBinding(x,M)}function c(x,S){let M=s[x.id];M===void 0&&(m(x),M=h(x),s[x.id]=M,x.addEventListener("dispose",C));let A=S.program;n.updateUBOMapping(x,A);let v=e.render.frame;r[x.id]!==v&&(u(x),r[x.id]=v)}function h(x){let S=d();x.__bindingPointIndex=S;let M=i.createBuffer(),A=x.__size,v=x.usage;return i.bindBuffer(i.UNIFORM_BUFFER,M),i.bufferData(i.UNIFORM_BUFFER,A,v),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,S,M),M}function d(){for(let x=0;x<a;x++)if(o.indexOf(x)===-1)return o.push(x),x;return Fe("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(x){let S=s[x.id],M=x.uniforms,A=x.__cache;i.bindBuffer(i.UNIFORM_BUFFER,S);for(let v=0,w=M.length;v<w;v++){let I=M[v];if(Array.isArray(I))for(let P=0,O=I.length;P<O;P++)f(I[P],v,P,A);else f(I,v,0,A)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function f(x,S,M,A){if(y(x,S,M,A)===!0){let v=x.__offset,w=x.value;if(Array.isArray(w)){let I=0;for(let P=0;P<w.length;P++){let O=w[P],q=p(O);g(O,x.__data,I),typeof O!="number"&&typeof O!="boolean"&&!O.isMatrix3&&!ArrayBuffer.isView(O)&&(I+=q.storage/Float32Array.BYTES_PER_ELEMENT)}}else g(w,x.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,v,x.__data)}}function g(x,S,M){typeof x=="number"||typeof x=="boolean"?S[0]=x:x.isMatrix3?(S[0]=x.elements[0],S[1]=x.elements[1],S[2]=x.elements[2],S[3]=0,S[4]=x.elements[3],S[5]=x.elements[4],S[6]=x.elements[5],S[7]=0,S[8]=x.elements[6],S[9]=x.elements[7],S[10]=x.elements[8],S[11]=0):ArrayBuffer.isView(x)?S.set(new x.constructor(x.buffer,x.byteOffset,S.length)):x.toArray(S,M)}function y(x,S,M,A){let v=x.value,w=S+"_"+M;if(A[w]===void 0)return typeof v=="number"||typeof v=="boolean"?A[w]=v:ArrayBuffer.isView(v)?A[w]=v.slice():A[w]=v.clone(),!0;{let I=A[w];if(typeof v=="number"||typeof v=="boolean"){if(I!==v)return A[w]=v,!0}else{if(ArrayBuffer.isView(v))return!0;if(I.equals(v)===!1)return I.copy(v),!0}}return!1}function m(x){let S=x.uniforms,M=0,A=16;for(let w=0,I=S.length;w<I;w++){let P=Array.isArray(S[w])?S[w]:[S[w]];for(let O=0,q=P.length;O<q;O++){let Y=P[O],U=Array.isArray(Y.value)?Y.value:[Y.value];for(let G=0,H=U.length;G<H;G++){let j=U[G],se=p(j),ue=M%A,le=ue%se.boundary,Me=ue+le;M+=le,Me!==0&&A-Me<se.storage&&(M+=A-Me),Y.__data=new Float32Array(se.storage/Float32Array.BYTES_PER_ELEMENT),Y.__offset=M,M+=se.storage}}}let v=M%A;return v>0&&(M+=A-v),x.__size=M,x.__cache={},this}function p(x){let S={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(S.boundary=4,S.storage=4):x.isVector2?(S.boundary=8,S.storage=8):x.isVector3||x.isColor?(S.boundary=16,S.storage=12):x.isVector4?(S.boundary=16,S.storage=16):x.isMatrix3?(S.boundary=48,S.storage=48):x.isMatrix4?(S.boundary=64,S.storage=64):x.isTexture?De("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(x)?(S.boundary=16,S.storage=x.byteLength):De("WebGLRenderer: Unsupported uniform value type.",x),S}function C(x){let S=x.target;S.removeEventListener("dispose",C);let M=o.indexOf(S.__bindingPointIndex);o.splice(M,1),i.deleteBuffer(s[S.id]),delete s[S.id],delete r[S.id]}function T(){for(let x in s)i.deleteBuffer(s[x]);o=[],s={},r={}}return{bind:l,update:c,dispose:T}}var mx=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Dn=null;function gx(){return Dn===null&&(Dn=new No(mx,16,16,gi,Ln),Dn.name="DFG_LUT",Dn.minFilter=Ut,Dn.magFilter=Ut,Dn.wrapS=An,Dn.wrapT=An,Dn.generateMipmaps=!1,Dn.needsUpdate=!0),Dn}var ws=class{constructor(e={}){let{canvas:t=Eu(),context:n=null,depth:s=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:f=Yt}=e;this.isWebGLRenderer=!0;let g;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=n.getContextAttributes().alpha}else g=o;let y=f,m=new Set([pa,fa,da]),p=new Set([Yt,yn,bs,Ms,ha,ua]),C=new Uint32Array(4),T=new Int32Array(4),x=new R,S=null,M=null,A=[],v=[],w=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=vn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let I=this,P=!1,O=null,q=null,Y=null,U=null;this._outputColorSpace=jt;let G=0,H=0,j=null,se=-1,ue=null,le=new gt,Me=new gt,Je=null,ct=new Ye(0),et=0,J=t.width,ce=t.height,re=1,Ie=null,ke=null,Ue=new gt(0,0,J,ce),nt=new gt(0,0,J,ce),He=!1,Q=new fs,ie=!1,ne=!1,xe=new rt,me=new R,Be=new gt,Ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Ve=!1;function We(){return j===null?re:1}let L=n;function ot(b,N){return t.getContext(b,N)}try{let b={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"185"}`),t.addEventListener("webglcontextlost",vt,!1),t.addEventListener("webglcontextrestored",dt,!1),t.addEventListener("webglcontextcreationerror",Mn,!1),L===null){let N="webgl2";if(L=ot(N,b),L===null)throw ot(N)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(b){throw Fe("WebGLRenderer: "+b.message),b}let je,E,_,F,k,W,oe,ae,X,K,de,Re,ge,fe,Ne,ze,Xe,D,he,$,pe,be,ee;function Ae(){je=new S0(L),je.init(),pe=new cx(L,je),E=new m0(L,je,e,pe),_=new ax(L,je),E.reversedDepthBuffer&&u&&_.buffers.depth.setReversed(!0),q=L.createFramebuffer(),Y=L.createFramebuffer(),U=L.createFramebuffer(),F=new T0(L),k=new Y_,W=new lx(L,je,_,k,E,pe,F),oe=new M0(I),ae=new Pp(L),be=new f0(L,ae),X=new E0(L,ae,F,be),K=new C0(L,X,ae,be,F),D=new A0(L,E,W),Ne=new g0(k),de=new q_(I,oe,je,E,be,Ne),Re=new fx(I,k),ge=new $_,fe=new tx(je),Xe=new d0(I,oe,_,K,g,l),ze=new ox(I,K,E),ee=new px(L,F,E,_),he=new p0(L,je,F),$=new w0(L,je,F),F.programs=de.programs,I.capabilities=E,I.extensions=je,I.properties=k,I.renderLists=ge,I.shadowMap=ze,I.state=_,I.info=F}Ae(),y!==Yt&&(w=new P0(y,t.width,t.height,a,s,r));let we=new Bc(I,L);this.xr=we,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){let b=je.get("WEBGL_lose_context");b&&b.loseContext()},this.forceContextRestore=function(){let b=je.get("WEBGL_lose_context");b&&b.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(b){b!==void 0&&(re=b,this.setSize(J,ce,!1))},this.getSize=function(b){return b.set(J,ce)},this.setSize=function(b,N,V=!0){if(we.isPresenting){De("WebGLRenderer: Can't change size while VR device is presenting.");return}J=b,ce=N,t.width=Math.floor(b*re),t.height=Math.floor(N*re),V===!0&&(t.style.width=b+"px",t.style.height=N+"px"),w!==null&&w.setSize(t.width,t.height),this.setViewport(0,0,b,N)},this.getDrawingBufferSize=function(b){return b.set(J*re,ce*re).floor()},this.setDrawingBufferSize=function(b,N,V){J=b,ce=N,re=V,t.width=Math.floor(b*V),t.height=Math.floor(N*V),this.setViewport(0,0,b,N)},this.setEffects=function(b){if(y===Yt){Fe("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let N=0;N<b.length;N++)if(b[N].isOutputPass===!0){De("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}w.setEffects(b||[])},this.getCurrentViewport=function(b){return b.copy(le)},this.getViewport=function(b){return b.copy(Ue)},this.setViewport=function(b,N,V,B){b.isVector4?Ue.set(b.x,b.y,b.z,b.w):Ue.set(b,N,V,B),_.viewport(le.copy(Ue).multiplyScalar(re).round())},this.getScissor=function(b){return b.copy(nt)},this.setScissor=function(b,N,V,B){b.isVector4?nt.set(b.x,b.y,b.z,b.w):nt.set(b,N,V,B),_.scissor(Me.copy(nt).multiplyScalar(re).round())},this.getScissorTest=function(){return He},this.setScissorTest=function(b){_.setScissorTest(He=b)},this.setOpaqueSort=function(b){Ie=b},this.setTransparentSort=function(b){ke=b},this.getClearColor=function(b){return b.copy(Xe.getClearColor())},this.setClearColor=function(){Xe.setClearColor(...arguments)},this.getClearAlpha=function(){return Xe.getClearAlpha()},this.setClearAlpha=function(){Xe.setClearAlpha(...arguments)},this.clear=function(b=!0,N=!0,V=!0){let B=0;if(b){let z=!1;if(j!==null){let ye=j.texture.format;z=m.has(ye)}if(z){let ye=j.texture.type,Ee=p.has(ye),ve=Xe.getClearColor(),Te=Xe.getClearAlpha(),Pe=ve.r,qe=ve.g,Ke=ve.b;Ee?(C[0]=Pe,C[1]=qe,C[2]=Ke,C[3]=Te,L.clearBufferuiv(L.COLOR,0,C)):(T[0]=Pe,T[1]=qe,T[2]=Ke,T[3]=Te,L.clearBufferiv(L.COLOR,0,T))}else B|=L.COLOR_BUFFER_BIT}N&&(B|=L.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),V&&(B|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B!==0&&L.clear(B)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(b){b.setRenderer(this),O=b},this.dispose=function(){t.removeEventListener("webglcontextlost",vt,!1),t.removeEventListener("webglcontextrestored",dt,!1),t.removeEventListener("webglcontextcreationerror",Mn,!1),Xe.dispose(),ge.dispose(),fe.dispose(),k.dispose(),oe.dispose(),K.dispose(),be.dispose(),ee.dispose(),de.dispose(),we.dispose(),we.removeEventListener("sessionstart",nh),we.removeEventListener("sessionend",ih),vi.stop()};function vt(b){b.preventDefault(),Ys("WebGLRenderer: Context Lost."),P=!0}function dt(){Ys("WebGLRenderer: Context Restored."),P=!1;let b=F.autoReset,N=ze.enabled,V=ze.autoUpdate,B=ze.needsUpdate,z=ze.type;Ae(),F.autoReset=b,ze.enabled=N,ze.autoUpdate=V,ze.needsUpdate=B,ze.type=z}function Mn(b){Fe("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function Sn(b){let N=b.target;N.removeEventListener("dispose",Sn),Zd(N)}function Zd(b){$d(b),k.remove(b)}function $d(b){let N=k.get(b).programs;N!==void 0&&(N.forEach(function(V){de.releaseProgram(V)}),b.isShaderMaterial&&de.releaseShaderCache(b))}this.renderBufferDirect=function(b,N,V,B,z,ye){N===null&&(N=Ce);let Ee=z.isMesh&&z.matrixWorld.determinantAffine()<0,ve=jd(b,N,V,B,z);_.setMaterial(B,Ee);let Te=V.index,Pe=1;if(B.wireframe===!0){if(Te=X.getWireframeAttribute(V),Te===void 0)return;Pe=2}let qe=V.drawRange,Ke=V.attributes.position,Le=qe.start*Pe,at=(qe.start+qe.count)*Pe;ye!==null&&(Le=Math.max(Le,ye.start*Pe),at=Math.min(at,(ye.start+ye.count)*Pe)),Te!==null?(Le=Math.max(Le,0),at=Math.min(at,Te.count)):Ke!=null&&(Le=Math.max(Le,0),at=Math.min(at,Ke.count));let bt=at-Le;if(bt<0||bt===1/0)return;be.setup(z,B,ve,V,Te);let yt,ht=he;if(Te!==null&&(yt=ae.get(Te),ht=$,ht.setIndex(yt)),z.isMesh)B.wireframe===!0?(_.setLineWidth(B.wireframeLinewidth*We()),ht.setMode(L.LINES)):ht.setMode(L.TRIANGLES);else if(z.isLine){let Ot=B.linewidth;Ot===void 0&&(Ot=1),_.setLineWidth(Ot*We()),z.isLineSegments?ht.setMode(L.LINES):z.isLineLoop?ht.setMode(L.LINE_LOOP):ht.setMode(L.LINE_STRIP)}else z.isPoints?ht.setMode(L.POINTS):z.isSprite&&ht.setMode(L.TRIANGLES);if(z.isBatchedMesh)if(je.get("WEBGL_multi_draw"))ht.renderMultiDraw(z._multiDrawStarts,z._multiDrawCounts,z._multiDrawCount);else{let Ot=z._multiDrawStarts,Se=z._multiDrawCounts,$t=z._multiDrawCount,tt=Te?ae.get(Te).bytesPerElement:1,sn=k.get(B).currentProgram.getUniforms();for(let En=0;En<$t;En++)sn.setValue(L,"_gl_DrawID",En),ht.render(Ot[En]/tt,Se[En])}else if(z.isInstancedMesh)ht.renderInstances(Le,bt,z.count);else if(V.isInstancedBufferGeometry){let Ot=V._maxInstanceCount!==void 0?V._maxInstanceCount:1/0,Se=Math.min(V.instanceCount,Ot);ht.renderInstances(Le,bt,Se)}else ht.render(Le,bt)};function th(b,N,V){b.transparent===!0&&b.side===ln&&b.forceSinglePass===!1?(b.side=qt,b.needsUpdate=!0,Fr(b,N,V),b.side=Hn,b.needsUpdate=!0,Fr(b,N,V),b.side=ln):Fr(b,N,V)}this.compile=function(b,N,V=null){V===null&&(V=b),M=fe.get(V),M.init(N),v.push(M),V.traverseVisible(function(z){z.isLight&&z.layers.test(N.layers)&&(M.pushLight(z),z.castShadow&&M.pushShadow(z))}),b!==V&&b.traverseVisible(function(z){z.isLight&&z.layers.test(N.layers)&&(M.pushLight(z),z.castShadow&&M.pushShadow(z))}),M.setupLights();let B=new Set;return b.traverse(function(z){if(!(z.isMesh||z.isPoints||z.isLine||z.isSprite))return;let ye=z.material;if(ye)if(Array.isArray(ye))for(let Ee=0;Ee<ye.length;Ee++){let ve=ye[Ee];th(ve,V,z),B.add(ve)}else th(ye,V,z),B.add(ye)}),M=v.pop(),B},this.compileAsync=function(b,N,V=null){let B=this.compile(b,N,V);return new Promise(z=>{function ye(){if(B.forEach(function(Ee){k.get(Ee).currentProgram.isReady()&&B.delete(Ee)}),B.size===0){z(b);return}setTimeout(ye,10)}je.get("KHR_parallel_shader_compile")!==null?ye():setTimeout(ye,10)})};let ol=null;function Jd(b){ol&&ol(b)}function nh(){vi.stop()}function ih(){vi.start()}let vi=new sd;vi.setAnimationLoop(Jd),typeof self<"u"&&vi.setContext(self),this.setAnimationLoop=function(b){ol=b,we.setAnimationLoop(b),b===null?vi.stop():vi.start()},we.addEventListener("sessionstart",nh),we.addEventListener("sessionend",ih),this.render=function(b,N){if(N!==void 0&&N.isCamera!==!0){Fe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;O!==null&&O.renderStart(b,N);let V=we.enabled===!0&&we.isPresenting===!0,B=w!==null&&(j===null||V)&&w.begin(I,j);if(b.matrixWorldAutoUpdate===!0&&b.updateMatrixWorld(),N.parent===null&&N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),we.enabled===!0&&we.isPresenting===!0&&(w===null||w.isCompositing()===!1)&&(we.cameraAutoUpdate===!0&&we.updateCamera(N),N=we.getCamera()),b.isScene===!0&&b.onBeforeRender(I,b,N,j),M=fe.get(b,v.length),M.init(N),M.state.textureUnits=W.getTextureUnits(),v.push(M),xe.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),Q.setFromProjectionMatrix(xe,pn,N.reversedDepth),ne=this.localClippingEnabled,ie=Ne.init(this.clippingPlanes,ne),S=ge.get(b,A.length),S.init(),A.push(S),we.enabled===!0&&we.isPresenting===!0){let Ee=I.xr.getDepthSensingMesh();Ee!==null&&al(Ee,N,-1/0,I.sortObjects)}al(b,N,0,I.sortObjects),S.finish(),I.sortObjects===!0&&S.sort(Ie,ke,N.reversedDepth),Ve=we.enabled===!1||we.isPresenting===!1||we.hasDepthSensing()===!1,Ve&&Xe.addToRenderList(S,b),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),ie===!0&&Ne.beginShadows();let z=M.state.shadowsArray;if(ze.render(z,b,N),ie===!0&&Ne.endShadows(),(B&&w.hasRenderPass())===!1){let Ee=S.opaque,ve=S.transmissive;if(M.setupLights(),N.isArrayCamera){let Te=N.cameras;if(ve.length>0)for(let Pe=0,qe=Te.length;Pe<qe;Pe++){let Ke=Te[Pe];rh(Ee,ve,b,Ke)}Ve&&Xe.render(b);for(let Pe=0,qe=Te.length;Pe<qe;Pe++){let Ke=Te[Pe];sh(S,b,Ke,Ke.viewport)}}else ve.length>0&&rh(Ee,ve,b,N),Ve&&Xe.render(b),sh(S,b,N)}j!==null&&H===0&&(W.updateMultisampleRenderTarget(j),W.updateRenderTargetMipmap(j)),B&&w.end(I),b.isScene===!0&&b.onAfterRender(I,b,N),be.resetDefaultState(),se=-1,ue=null,v.pop(),v.length>0?(M=v[v.length-1],W.setTextureUnits(M.state.textureUnits),ie===!0&&Ne.setGlobalState(I.clippingPlanes,M.state.camera)):M=null,A.pop(),A.length>0?S=A[A.length-1]:S=null,O!==null&&O.renderEnd()};function al(b,N,V,B){if(b.visible===!1)return;if(b.layers.test(N.layers)){if(b.isGroup)V=b.renderOrder;else if(b.isLOD)b.autoUpdate===!0&&b.update(N);else if(b.isLightProbeGrid)M.pushLightProbeGrid(b);else if(b.isLight)M.pushLight(b),b.castShadow&&M.pushShadow(b);else if(b.isSprite){if(!b.frustumCulled||Q.intersectsSprite(b)){B&&Be.setFromMatrixPosition(b.matrixWorld).applyMatrix4(xe);let Ee=K.update(b),ve=b.material;ve.visible&&S.push(b,Ee,ve,V,Be.z,null)}}else if((b.isMesh||b.isLine||b.isPoints)&&(!b.frustumCulled||Q.intersectsObject(b))){let Ee=K.update(b),ve=b.material;if(B&&(b.boundingSphere!==void 0?(b.boundingSphere===null&&b.computeBoundingSphere(),Be.copy(b.boundingSphere.center)):(Ee.boundingSphere===null&&Ee.computeBoundingSphere(),Be.copy(Ee.boundingSphere.center)),Be.applyMatrix4(b.matrixWorld).applyMatrix4(xe)),Array.isArray(ve)){let Te=Ee.groups;for(let Pe=0,qe=Te.length;Pe<qe;Pe++){let Ke=Te[Pe],Le=ve[Ke.materialIndex];Le&&Le.visible&&S.push(b,Ee,Le,V,Be.z,Ke)}}else ve.visible&&S.push(b,Ee,ve,V,Be.z,null)}}let ye=b.children;for(let Ee=0,ve=ye.length;Ee<ve;Ee++)al(ye[Ee],N,V,B)}function sh(b,N,V,B){let{opaque:z,transmissive:ye,transparent:Ee}=b;M.setupLightsView(V),ie===!0&&Ne.setGlobalState(I.clippingPlanes,V),B&&_.viewport(le.copy(B)),z.length>0&&Ur(z,N,V),ye.length>0&&Ur(ye,N,V),Ee.length>0&&Ur(Ee,N,V),_.buffers.depth.setTest(!0),_.buffers.depth.setMask(!0),_.buffers.color.setMask(!0),_.setPolygonOffset(!1)}function rh(b,N,V,B){if((V.isScene===!0?V.overrideMaterial:null)!==null)return;if(M.state.transmissionRenderTarget[B.id]===void 0){let Le=je.has("EXT_color_buffer_half_float")||je.has("EXT_color_buffer_float");M.state.transmissionRenderTarget[B.id]=new Qt(1,1,{generateMipmaps:!0,type:Le?Ln:Yt,minFilter:pi,samples:Math.max(4,E.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Qe.workingColorSpace})}let ye=M.state.transmissionRenderTarget[B.id],Ee=B.viewport||le;ye.setSize(Ee.z*I.transmissionResolutionScale,Ee.w*I.transmissionResolutionScale);let ve=I.getRenderTarget(),Te=I.getActiveCubeFace(),Pe=I.getActiveMipmapLevel();I.setRenderTarget(ye),I.getClearColor(ct),et=I.getClearAlpha(),et<1&&I.setClearColor(16777215,.5),I.clear(),Ve&&Xe.render(V);let qe=I.toneMapping;I.toneMapping=vn;let Ke=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),M.setupLightsView(B),ie===!0&&Ne.setGlobalState(I.clippingPlanes,B),Ur(b,V,B),W.updateMultisampleRenderTarget(ye),W.updateRenderTargetMipmap(ye),je.has("WEBGL_multisampled_render_to_texture")===!1){let Le=!1;for(let at=0,bt=N.length;at<bt;at++){let yt=N[at],{object:ht,geometry:Ot,material:Se,group:$t}=yt;if(Se.side===ln&&ht.layers.test(B.layers)){let tt=Se.side;Se.side=qt,Se.needsUpdate=!0,oh(ht,V,B,Ot,Se,$t),Se.side=tt,Se.needsUpdate=!0,Le=!0}}Le===!0&&(W.updateMultisampleRenderTarget(ye),W.updateRenderTargetMipmap(ye))}I.setRenderTarget(ve,Te,Pe),I.setClearColor(ct,et),Ke!==void 0&&(B.viewport=Ke),I.toneMapping=qe}function Ur(b,N,V){let B=N.isScene===!0?N.overrideMaterial:null;for(let z=0,ye=b.length;z<ye;z++){let Ee=b[z],{object:ve,geometry:Te,group:Pe}=Ee,qe=Ee.material;qe.allowOverride===!0&&B!==null&&(qe=B),ve.layers.test(V.layers)&&oh(ve,N,V,Te,qe,Pe)}}function oh(b,N,V,B,z,ye){b.onBeforeRender(I,N,V,B,z,ye),b.modelViewMatrix.multiplyMatrices(V.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),z.onBeforeRender(I,N,V,B,b,ye),z.transparent===!0&&z.side===ln&&z.forceSinglePass===!1?(z.side=qt,z.needsUpdate=!0,I.renderBufferDirect(V,N,B,z,b,ye),z.side=Hn,z.needsUpdate=!0,I.renderBufferDirect(V,N,B,z,b,ye),z.side=ln):I.renderBufferDirect(V,N,B,z,b,ye),b.onAfterRender(I,N,V,B,z,ye)}function Fr(b,N,V){N.isScene!==!0&&(N=Ce);let B=k.get(b),z=M.state.lights,ye=M.state.shadowsArray,Ee=z.state.version,ve=de.getParameters(b,z.state,ye,N,V,M.state.lightProbeGridArray),Te=de.getProgramCacheKey(ve),Pe=B.programs;B.environment=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?N.environment:null,B.fog=N.fog;let qe=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap;B.envMap=oe.get(b.envMap||B.environment,qe),B.envMapRotation=B.environment!==null&&b.envMap===null?N.environmentRotation:b.envMapRotation,Pe===void 0&&(b.addEventListener("dispose",Sn),Pe=new Map,B.programs=Pe);let Ke=Pe.get(Te);if(Ke!==void 0){if(B.currentProgram===Ke&&B.lightsStateVersion===Ee)return lh(b,ve),Ke}else ve.uniforms=de.getUniforms(b),O!==null&&b.isNodeMaterial&&O.build(b,V,ve),b.onBeforeCompile(ve,I),Ke=de.acquireProgram(ve,Te),Pe.set(Te,Ke),B.uniforms=ve.uniforms;let Le=B.uniforms;return(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)&&(Le.clippingPlanes=Ne.uniform),lh(b,ve),B.needsLights=ef(b),B.lightsStateVersion=Ee,B.needsLights&&(Le.ambientLightColor.value=z.state.ambient,Le.lightProbe.value=z.state.probe,Le.directionalLights.value=z.state.directional,Le.directionalLightShadows.value=z.state.directionalShadow,Le.spotLights.value=z.state.spot,Le.spotLightShadows.value=z.state.spotShadow,Le.rectAreaLights.value=z.state.rectArea,Le.ltc_1.value=z.state.rectAreaLTC1,Le.ltc_2.value=z.state.rectAreaLTC2,Le.pointLights.value=z.state.point,Le.pointLightShadows.value=z.state.pointShadow,Le.hemisphereLights.value=z.state.hemi,Le.directionalShadowMatrix.value=z.state.directionalShadowMatrix,Le.spotLightMatrix.value=z.state.spotLightMatrix,Le.spotLightMap.value=z.state.spotLightMap,Le.pointShadowMatrix.value=z.state.pointShadowMatrix),B.lightProbeGrid=M.state.lightProbeGridArray.length>0,B.currentProgram=Ke,B.uniformsList=null,Ke}function ah(b){if(b.uniformsList===null){let N=b.currentProgram.getUniforms();b.uniformsList=Es.seqWithValue(N.seq,b.uniforms)}return b.uniformsList}function lh(b,N){let V=k.get(b);V.outputColorSpace=N.outputColorSpace,V.batching=N.batching,V.batchingColor=N.batchingColor,V.instancing=N.instancing,V.instancingColor=N.instancingColor,V.instancingMorph=N.instancingMorph,V.skinning=N.skinning,V.morphTargets=N.morphTargets,V.morphNormals=N.morphNormals,V.morphColors=N.morphColors,V.morphTargetsCount=N.morphTargetsCount,V.numClippingPlanes=N.numClippingPlanes,V.numIntersection=N.numClipIntersection,V.vertexAlphas=N.vertexAlphas,V.vertexTangents=N.vertexTangents,V.toneMapping=N.toneMapping}function Kd(b,N){if(b.length===0)return null;if(b.length===1)return b[0].texture!==null?b[0]:null;x.setFromMatrixPosition(N.matrixWorld);for(let V=0,B=b.length;V<B;V++){let z=b[V];if(z.texture!==null&&z.boundingBox.containsPoint(x))return z}return null}function jd(b,N,V,B,z){N.isScene!==!0&&(N=Ce),W.resetTextureUnits();let ye=N.fog,Ee=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?N.environment:null,ve=j===null?I.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:Qe.workingColorSpace,Te=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Pe=oe.get(B.envMap||Ee,Te),qe=B.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,Ke=!!V.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Le=!!V.morphAttributes.position,at=!!V.morphAttributes.normal,bt=!!V.morphAttributes.color,yt=vn;B.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(yt=I.toneMapping);let ht=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,Ot=ht!==void 0?ht.length:0,Se=k.get(B),$t=M.state.lights;if(ie===!0&&(ne===!0||b!==ue)){let ft=b===ue&&B.id===se;Ne.setState(B,b,ft)}let tt=!1;B.version===Se.__version?(Se.needsLights&&Se.lightsStateVersion!==$t.state.version||Se.outputColorSpace!==ve||z.isBatchedMesh&&Se.batching===!1||!z.isBatchedMesh&&Se.batching===!0||z.isBatchedMesh&&Se.batchingColor===!0&&z.colorTexture===null||z.isBatchedMesh&&Se.batchingColor===!1&&z.colorTexture!==null||z.isInstancedMesh&&Se.instancing===!1||!z.isInstancedMesh&&Se.instancing===!0||z.isSkinnedMesh&&Se.skinning===!1||!z.isSkinnedMesh&&Se.skinning===!0||z.isInstancedMesh&&Se.instancingColor===!0&&z.instanceColor===null||z.isInstancedMesh&&Se.instancingColor===!1&&z.instanceColor!==null||z.isInstancedMesh&&Se.instancingMorph===!0&&z.morphTexture===null||z.isInstancedMesh&&Se.instancingMorph===!1&&z.morphTexture!==null||Se.envMap!==Pe||B.fog===!0&&Se.fog!==ye||Se.numClippingPlanes!==void 0&&(Se.numClippingPlanes!==Ne.numPlanes||Se.numIntersection!==Ne.numIntersection)||Se.vertexAlphas!==qe||Se.vertexTangents!==Ke||Se.morphTargets!==Le||Se.morphNormals!==at||Se.morphColors!==bt||Se.toneMapping!==yt||Se.morphTargetsCount!==Ot||!!Se.lightProbeGrid!=M.state.lightProbeGridArray.length>0)&&(tt=!0):(tt=!0,Se.__version=B.version);let sn=Se.currentProgram;tt===!0&&(sn=Fr(B,N,z),O&&B.isNodeMaterial&&O.onUpdateProgram(B,sn,Se));let En=!1,Yn=!1,ki=!1,ut=sn.getUniforms(),Mt=Se.uniforms;if(_.useProgram(sn.program)&&(En=!0,Yn=!0,ki=!0),B.id!==se&&(se=B.id,Yn=!0),Se.needsLights){let ft=Kd(M.state.lightProbeGridArray,z);Se.lightProbeGrid!==ft&&(Se.lightProbeGrid=ft,Yn=!0)}if(En||ue!==b){_.buffers.depth.getReversed()&&b.reversedDepth!==!0&&(b._reversedDepth=!0,b.updateProjectionMatrix()),ut.setValue(L,"projectionMatrix",b.projectionMatrix),ut.setValue(L,"viewMatrix",b.matrixWorldInverse);let $n=ut.map.cameraPosition;$n!==void 0&&$n.setValue(L,me.setFromMatrixPosition(b.matrixWorld)),E.logarithmicDepthBuffer&&ut.setValue(L,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&ut.setValue(L,"isOrthographic",b.isOrthographicCamera===!0),ue!==b&&(ue=b,Yn=!0,ki=!0)}if(Se.needsLights&&($t.state.directionalShadowMap.length>0&&ut.setValue(L,"directionalShadowMap",$t.state.directionalShadowMap,W),$t.state.spotShadowMap.length>0&&ut.setValue(L,"spotShadowMap",$t.state.spotShadowMap,W),$t.state.pointShadowMap.length>0&&ut.setValue(L,"pointShadowMap",$t.state.pointShadowMap,W)),z.isSkinnedMesh){ut.setOptional(L,z,"bindMatrix"),ut.setOptional(L,z,"bindMatrixInverse");let ft=z.skeleton;ft&&(ft.boneTexture===null&&ft.computeBoneTexture(),ut.setValue(L,"boneTexture",ft.boneTexture,W))}z.isBatchedMesh&&(ut.setOptional(L,z,"batchingTexture"),ut.setValue(L,"batchingTexture",z._matricesTexture,W),ut.setOptional(L,z,"batchingIdTexture"),ut.setValue(L,"batchingIdTexture",z._indirectTexture,W),ut.setOptional(L,z,"batchingColorTexture"),z._colorsTexture!==null&&ut.setValue(L,"batchingColorTexture",z._colorsTexture,W));let Zn=V.morphAttributes;if((Zn.position!==void 0||Zn.normal!==void 0||Zn.color!==void 0)&&D.update(z,V,sn),(Yn||Se.receiveShadow!==z.receiveShadow)&&(Se.receiveShadow=z.receiveShadow,ut.setValue(L,"receiveShadow",z.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&N.environment!==null&&(Mt.envMapIntensity.value=N.environmentIntensity),Mt.dfgLUT!==void 0&&(Mt.dfgLUT.value=gx()),Yn){if(ut.setValue(L,"toneMappingExposure",I.toneMappingExposure),Se.needsLights&&Qd(Mt,ki),ye&&B.fog===!0&&Re.refreshFogUniforms(Mt,ye),Re.refreshMaterialUniforms(Mt,B,re,ce,M.state.transmissionRenderTarget[b.id]),Se.needsLights&&Se.lightProbeGrid){let ft=Se.lightProbeGrid;Mt.probesSH.value=ft.texture,Mt.probesMin.value.copy(ft.boundingBox.min),Mt.probesMax.value.copy(ft.boundingBox.max),Mt.probesResolution.value.copy(ft.resolution)}Es.upload(L,ah(Se),Mt,W)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(Es.upload(L,ah(Se),Mt,W),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&ut.setValue(L,"center",z.center),ut.setValue(L,"modelViewMatrix",z.modelViewMatrix),ut.setValue(L,"normalMatrix",z.normalMatrix),ut.setValue(L,"modelMatrix",z.matrixWorld),B.uniformsGroups!==void 0){let ft=B.uniformsGroups;for(let $n=0,Vi=ft.length;$n<Vi;$n++){let ch=ft[$n];ee.update(ch,sn),ee.bind(ch,sn)}}return sn}function Qd(b,N){b.ambientLightColor.needsUpdate=N,b.lightProbe.needsUpdate=N,b.directionalLights.needsUpdate=N,b.directionalLightShadows.needsUpdate=N,b.pointLights.needsUpdate=N,b.pointLightShadows.needsUpdate=N,b.spotLights.needsUpdate=N,b.spotLightShadows.needsUpdate=N,b.rectAreaLights.needsUpdate=N,b.hemisphereLights.needsUpdate=N}function ef(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return G},this.getActiveMipmapLevel=function(){return H},this.getRenderTarget=function(){return j},this.setRenderTargetTextures=function(b,N,V){let B=k.get(b);B.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),k.get(b.texture).__webglTexture=N,k.get(b.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:V,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,N){let V=k.get(b);V.__webglFramebuffer=N,V.__useDefaultFramebuffer=N===void 0},this.setRenderTarget=function(b,N=0,V=0){j=b,G=N,H=V;let B=null,z=!1,ye=!1;if(b){let ve=k.get(b);if(ve.__useDefaultFramebuffer!==void 0){_.bindFramebuffer(L.FRAMEBUFFER,ve.__webglFramebuffer),le.copy(b.viewport),Me.copy(b.scissor),Je=b.scissorTest,_.viewport(le),_.scissor(Me),_.setScissorTest(Je),se=-1;return}else if(ve.__webglFramebuffer===void 0)W.setupRenderTarget(b);else if(ve.__hasExternalTextures)W.rebindTextures(b,k.get(b.texture).__webglTexture,k.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){let qe=b.depthTexture;if(ve.__boundDepthTexture!==qe){if(qe!==null&&k.has(qe)&&(b.width!==qe.image.width||b.height!==qe.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");W.setupDepthRenderbuffer(b)}}let Te=b.texture;(Te.isData3DTexture||Te.isDataArrayTexture||Te.isCompressedArrayTexture)&&(ye=!0);let Pe=k.get(b).__webglFramebuffer;b.isWebGLCubeRenderTarget?(Array.isArray(Pe[N])?B=Pe[N][V]:B=Pe[N],z=!0):b.samples>0&&W.useMultisampledRTT(b)===!1?B=k.get(b).__webglMultisampledFramebuffer:Array.isArray(Pe)?B=Pe[V]:B=Pe,le.copy(b.viewport),Me.copy(b.scissor),Je=b.scissorTest}else le.copy(Ue).multiplyScalar(re).floor(),Me.copy(nt).multiplyScalar(re).floor(),Je=He;if(V!==0&&(B=q),_.bindFramebuffer(L.FRAMEBUFFER,B)&&_.drawBuffers(b,B),_.viewport(le),_.scissor(Me),_.setScissorTest(Je),z){let ve=k.get(b.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+N,ve.__webglTexture,V)}else if(ye){let ve=N;for(let Te=0;Te<b.textures.length;Te++){let Pe=k.get(b.textures[Te]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+Te,Pe.__webglTexture,V,ve)}}else if(b!==null&&V!==0){let ve=k.get(b.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,ve.__webglTexture,V)}se=-1},this.readRenderTargetPixels=function(b,N,V,B,z,ye,Ee,ve=0){if(!(b&&b.isWebGLRenderTarget)){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Te=k.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Ee!==void 0&&(Te=Te[Ee]),Te){_.bindFramebuffer(L.FRAMEBUFFER,Te);try{let Pe=b.textures[ve],qe=Pe.format,Ke=Pe.type;if(b.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+ve),!E.textureFormatReadable(qe)){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!E.textureTypeReadable(Ke)){Fe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}N>=0&&N<=b.width-B&&V>=0&&V<=b.height-z&&L.readPixels(N,V,B,z,pe.convert(qe),pe.convert(Ke),ye)}finally{let Pe=j!==null?k.get(j).__webglFramebuffer:null;_.bindFramebuffer(L.FRAMEBUFFER,Pe)}}},this.readRenderTargetPixelsAsync=async function(b,N,V,B,z,ye,Ee,ve=0){if(!(b&&b.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Te=k.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Ee!==void 0&&(Te=Te[Ee]),Te)if(N>=0&&N<=b.width-B&&V>=0&&V<=b.height-z){_.bindFramebuffer(L.FRAMEBUFFER,Te);let Pe=b.textures[ve],qe=Pe.format,Ke=Pe.type;if(b.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+ve),!E.textureFormatReadable(qe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!E.textureTypeReadable(Ke))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let Le=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,Le),L.bufferData(L.PIXEL_PACK_BUFFER,ye.byteLength,L.STREAM_READ),L.readPixels(N,V,B,z,pe.convert(qe),pe.convert(Ke),0);let at=j!==null?k.get(j).__webglFramebuffer:null;_.bindFramebuffer(L.FRAMEBUFFER,at);let bt=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await Tu(L,bt,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,Le),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,ye),L.deleteBuffer(Le),L.deleteSync(bt),ye}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,N=null,V=0){let B=Math.pow(2,-V),z=Math.floor(b.image.width*B),ye=Math.floor(b.image.height*B),Ee=N!==null?N.x:0,ve=N!==null?N.y:0;W.setTexture2D(b,0),L.copyTexSubImage2D(L.TEXTURE_2D,V,0,0,Ee,ve,z,ye),_.unbindTexture()},this.copyTextureToTexture=function(b,N,V=null,B=null,z=0,ye=0){let Ee,ve,Te,Pe,qe,Ke,Le,at,bt,yt=b.isCompressedTexture?b.mipmaps[ye]:b.image;if(V!==null)Ee=V.max.x-V.min.x,ve=V.max.y-V.min.y,Te=V.isBox3?V.max.z-V.min.z:1,Pe=V.min.x,qe=V.min.y,Ke=V.isBox3?V.min.z:0;else{let Mt=Math.pow(2,-z);Ee=Math.floor(yt.width*Mt),ve=Math.floor(yt.height*Mt),b.isDataArrayTexture?Te=yt.depth:b.isData3DTexture?Te=Math.floor(yt.depth*Mt):Te=1,Pe=0,qe=0,Ke=0}B!==null?(Le=B.x,at=B.y,bt=B.z):(Le=0,at=0,bt=0);let ht=pe.convert(N.format),Ot=pe.convert(N.type),Se;N.isData3DTexture?(W.setTexture3D(N,0),Se=L.TEXTURE_3D):N.isDataArrayTexture||N.isCompressedArrayTexture?(W.setTexture2DArray(N,0),Se=L.TEXTURE_2D_ARRAY):(W.setTexture2D(N,0),Se=L.TEXTURE_2D),_.activeTexture(L.TEXTURE0),_.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,N.flipY),_.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),_.pixelStorei(L.UNPACK_ALIGNMENT,N.unpackAlignment);let $t=_.getParameter(L.UNPACK_ROW_LENGTH),tt=_.getParameter(L.UNPACK_IMAGE_HEIGHT),sn=_.getParameter(L.UNPACK_SKIP_PIXELS),En=_.getParameter(L.UNPACK_SKIP_ROWS),Yn=_.getParameter(L.UNPACK_SKIP_IMAGES);_.pixelStorei(L.UNPACK_ROW_LENGTH,yt.width),_.pixelStorei(L.UNPACK_IMAGE_HEIGHT,yt.height),_.pixelStorei(L.UNPACK_SKIP_PIXELS,Pe),_.pixelStorei(L.UNPACK_SKIP_ROWS,qe),_.pixelStorei(L.UNPACK_SKIP_IMAGES,Ke);let ki=b.isDataArrayTexture||b.isData3DTexture,ut=N.isDataArrayTexture||N.isData3DTexture;if(b.isDepthTexture){let Mt=k.get(b),Zn=k.get(N),ft=k.get(Mt.__renderTarget),$n=k.get(Zn.__renderTarget);_.bindFramebuffer(L.READ_FRAMEBUFFER,ft.__webglFramebuffer),_.bindFramebuffer(L.DRAW_FRAMEBUFFER,$n.__webglFramebuffer);for(let Vi=0;Vi<Te;Vi++)ki&&(L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,k.get(b).__webglTexture,z,Ke+Vi),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,k.get(N).__webglTexture,ye,bt+Vi)),L.blitFramebuffer(Pe,qe,Ee,ve,Le,at,Ee,ve,L.DEPTH_BUFFER_BIT,L.NEAREST);_.bindFramebuffer(L.READ_FRAMEBUFFER,null),_.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(z!==0||b.isRenderTargetTexture||k.has(b)){let Mt=k.get(b),Zn=k.get(N);_.bindFramebuffer(L.READ_FRAMEBUFFER,Y),_.bindFramebuffer(L.DRAW_FRAMEBUFFER,U);for(let ft=0;ft<Te;ft++)ki?L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Mt.__webglTexture,z,Ke+ft):L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Mt.__webglTexture,z),ut?L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Zn.__webglTexture,ye,bt+ft):L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Zn.__webglTexture,ye),z!==0?L.blitFramebuffer(Pe,qe,Ee,ve,Le,at,Ee,ve,L.COLOR_BUFFER_BIT,L.NEAREST):ut?L.copyTexSubImage3D(Se,ye,Le,at,bt+ft,Pe,qe,Ee,ve):L.copyTexSubImage2D(Se,ye,Le,at,Pe,qe,Ee,ve);_.bindFramebuffer(L.READ_FRAMEBUFFER,null),_.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else ut?b.isDataTexture||b.isData3DTexture?L.texSubImage3D(Se,ye,Le,at,bt,Ee,ve,Te,ht,Ot,yt.data):N.isCompressedArrayTexture?L.compressedTexSubImage3D(Se,ye,Le,at,bt,Ee,ve,Te,ht,yt.data):L.texSubImage3D(Se,ye,Le,at,bt,Ee,ve,Te,ht,Ot,yt):b.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,ye,Le,at,Ee,ve,ht,Ot,yt.data):b.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,ye,Le,at,yt.width,yt.height,ht,yt.data):L.texSubImage2D(L.TEXTURE_2D,ye,Le,at,Ee,ve,ht,Ot,yt);_.pixelStorei(L.UNPACK_ROW_LENGTH,$t),_.pixelStorei(L.UNPACK_IMAGE_HEIGHT,tt),_.pixelStorei(L.UNPACK_SKIP_PIXELS,sn),_.pixelStorei(L.UNPACK_SKIP_ROWS,En),_.pixelStorei(L.UNPACK_SKIP_IMAGES,Yn),ye===0&&N.generateMipmaps&&L.generateMipmap(Se),_.unbindTexture()},this.initRenderTarget=function(b){k.get(b).__webglFramebuffer===void 0&&W.setupRenderTarget(b)},this.initTexture=function(b){b.isCubeTexture?W.setTextureCube(b,0):b.isData3DTexture?W.setTexture3D(b,0):b.isDataArrayTexture||b.isCompressedArrayTexture?W.setTexture2DArray(b,0):W.setTexture2D(b,0),_.unbindTexture()},this.resetState=function(){G=0,H=0,j=null,_.reset(),be.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return pn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Qe._getDrawingBufferColorSpace(e),t.unpackColorSpace=Qe._getUnpackColorSpace()}};var ud={type:"change"},kc={type:"start"},fd={type:"end"},tl=new si,dd=new on,_x=Math.cos(70*xc.DEG2RAD),Rt=new R,Zt=2*Math.PI,lt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},zc=1e-6,nl=class extends gr{constructor(e,t=null){super(e,t),this.state=lt.NONE,this.target=new R,this.cursor=new R,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:ui.ROTATE,MIDDLE:ui.DOLLY,RIGHT:ui.PAN},this.touches={ONE:di.ROTATE,TWO:di.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new R,this._lastQuaternion=new Ft,this._lastTargetPosition=new R,this._quat=new Ft().setFromUnitVectors(e.up,new R(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new vs,this._sphericalDelta=new vs,this._scale=1,this._panOffset=new R,this._rotateStart=new te,this._rotateEnd=new te,this._rotateDelta=new te,this._panStart=new te,this._panEnd=new te,this._panDelta=new te,this._dollyStart=new te,this._dollyEnd=new te,this._dollyDelta=new te,this._dollyDirection=new R,this._mouse=new te,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=vx.bind(this),this._onPointerDown=xx.bind(this),this._onPointerUp=yx.bind(this),this._onContextMenu=Ax.bind(this),this._onMouseWheel=Sx.bind(this),this._onKeyDown=Ex.bind(this),this._onTouchStart=wx.bind(this),this._onTouchMove=Tx.bind(this),this._onMouseDown=bx.bind(this),this._onMouseMove=Mx.bind(this),this._interceptControlDown=Cx.bind(this),this._interceptControlUp=Rx.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=""}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(ud),this.update(),this.state=lt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;Rt.copy(t).sub(this.target),Rt.applyQuaternion(this._quat),this._spherical.setFromVector3(Rt),this.autoRotate&&this.state===lt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=Zt:n>Math.PI&&(n-=Zt),s<-Math.PI?s+=Zt:s>Math.PI&&(s-=Zt),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(Rt.setFromSpherical(this._spherical),Rt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Rt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){let a=Rt.length();o=this._clampDistance(a*this._scale);let l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){let a=new R(this._mouse.x,this._mouse.y,0);a.unproject(this.object);let l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;let c=new R(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=Rt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(tl.origin.copy(this.object.position),tl.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(tl.direction))<_x?this.object.lookAt(this.target):(dd.setFromNormalAndCoplanarPoint(this.object.up,this.target),tl.intersectPlane(dd,this.target))))}else if(this.object.isOrthographicCamera){let o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>zc||8*(1-this._lastQuaternion.dot(this.object.quaternion))>zc||this._lastTargetPosition.distanceToSquared(this.target)>zc?(this.dispatchEvent(ud),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Zt/60*this.autoRotateSpeed*e:Zt/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Rt.setFromMatrixColumn(t,0),Rt.multiplyScalar(-e),this._panOffset.add(Rt)}_panUp(e,t){this.screenSpacePanning===!0?Rt.setFromMatrixColumn(t,1):(Rt.setFromMatrixColumn(t,0),Rt.crossVectors(this.object.up,Rt)),Rt.multiplyScalar(e),this._panOffset.add(Rt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let s=this.object.position;Rt.copy(s).sub(this.target);let r=Rt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),s=e-n.left,r=t-n.top,o=n.width,a=n.height;this._mouse.x=s/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Zt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Zt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Zt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Zt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Zt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Zt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Zt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Zt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new te,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function xx(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function vx(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function yx(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(fd),this.state=lt.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:let e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function bx(i){let e;switch(i.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case ui.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=lt.DOLLY;break;case ui.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=lt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=lt.ROTATE}break;case ui.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=lt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=lt.PAN}break;default:this.state=lt.NONE}this.state!==lt.NONE&&this.dispatchEvent(kc)}function Mx(i){switch(this.state){case lt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case lt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case lt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function Sx(i){this.enabled===!1||this.enableZoom===!1||this.state!==lt.NONE||(i.preventDefault(),this.dispatchEvent(kc),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(fd))}function Ex(i){this.enabled!==!1&&this._handleKeyDown(i)}function wx(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case di.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=lt.TOUCH_ROTATE;break;case di.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=lt.TOUCH_PAN;break;default:this.state=lt.NONE}break;case 2:switch(this.touches.TWO){case di.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=lt.TOUCH_DOLLY_PAN;break;case di.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=lt.TOUCH_DOLLY_ROTATE;break;default:this.state=lt.NONE}break;default:this.state=lt.NONE}this.state!==lt.NONE&&this.dispatchEvent(kc)}function Tx(i){switch(this._trackPointer(i),this.state){case lt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case lt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case lt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case lt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=lt.NONE}}function Ax(i){this.enabled!==!1&&i.preventDefault()}function Cx(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Rx(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Vc(i){let e=md(i);return new Float32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function pd(i){let e=md(i);return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function md(i){let e=atob(i),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}var Rr=.85,Hc=3,Px=400,Nt=(i,e,t)=>new R(i,e,t),gd=[["TOP",Nt(0,0,1)],["BOTTOM",Nt(0,0,-1)],["FRONT",Nt(0,-1,0)],["BACK",Nt(0,1,0)],["RIGHT",Nt(1,0,0)],["LEFT",Nt(-1,0,0)]],Ix=[{name:"TOP",normal:Nt(0,0,1),up:Nt(0,1,0)},{name:"BOTTOM",normal:Nt(0,0,-1),up:Nt(0,1,0)},{name:"FRONT",normal:Nt(0,-1,0),up:Nt(0,0,1)},{name:"BACK",normal:Nt(0,1,0),up:Nt(0,0,1)},{name:"RIGHT",normal:Nt(1,0,0),up:Nt(0,0,1)},{name:"LEFT",normal:Nt(-1,0,0),up:Nt(0,0,1)}];function Lx(i){let e=[],t=i.length();for(let[n,s]of gd)i.dot(s)/t>.5&&e.push(n);return e.sort().join("-")}function Dx(i){let e=document.createElement("canvas");e.width=128,e.height=128;let t=e.getContext("2d");t!==null&&(t.fillStyle="rgba(246, 248, 251, 0.96)",t.fillRect(0,0,128,128),t.strokeStyle="rgba(148, 158, 172, 0.9)",t.lineWidth=3,t.strokeRect(1.5,1.5,125,125),t.fillStyle="#5b6472",t.font=`600 ${i.length>2?24:28}px -apple-system, "Segoe UI", sans-serif`,t.textAlign="center",t.textBaseline="middle",t.fillText(i,64,66));let n=new Pi(e);return n.anisotropy=4,n}var Pr=class{constructor(e){this.options=e;let{container:t,camera:n,controls:s}=e;this.camera=n,this.controls=s;let r=e.size??96;getComputedStyle(t).position==="static"&&(t.style.position="relative"),this.overlay=document.createElement("div"),this.overlay.style.cssText=`position:absolute;top:8px;right:8px;width:${r}px;display:flex;flex-direction:column;align-items:center;gap:3px;z-index:5;user-select:none;`,t.appendChild(this.overlay);let o=document.createElement("div");o.style.cssText=`width:${r}px;height:${r}px;cursor:grab;`,this.overlay.appendChild(o),this.caption=document.createElement("div"),this.caption.style.cssText='min-height:14px;font:500 10px/14px -apple-system,"Segoe UI",sans-serif;color:var(--dsw-alias-label-secondary,#374151);background:var(--dsw-alias-bg-base,rgba(255,255,255,0.85));border-radius:7px;padding:0 7px;opacity:0;transition:opacity 120ms;text-align:center;white-space:nowrap;',this.overlay.appendChild(this.caption);let a=document.createElement("button");a.type="button",a.title="Reset view",a.setAttribute("aria-label","Reset view"),a.style.cssText="width:22px;height:22px;border-radius:50%;border:1px solid var(--dsw-alias-border-l2,#c4c9d0);background:var(--dsw-alias-bg-base,#fff);color:var(--dsw-alias-label-secondary,#374151);font-size:12px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0;",a.textContent="\u2302",a.addEventListener("click",()=>{e.onHome?.()}),this.overlay.appendChild(a),this.renderer=new ws({antialias:!0,alpha:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(r,r),this.renderer.domElement.style.cssText="width:100%;height:100%;display:block;touch-action:none;",o.appendChild(this.renderer.domElement),this.overlayCamera.position.set(0,0,4),this.overlayCamera.lookAt(0,0,0),new ii().add(this.root),this.buildCube();let c=d=>{let u=this.renderer.domElement.getBoundingClientRect(),f=new te((d.clientX-u.left)/u.width*2-1,-((d.clientY-u.top)/u.height)*2+1);this.raycaster.setFromCamera(f,this.overlayCamera);let g=this.raycaster.intersectObjects(this.cells,!1)[0];return g===void 0?{zone:null,point:null}:{zone:g.object.userData.zone,point:g.point}},h=this.renderer.domElement;h.addEventListener("pointermove",d=>{let{zone:u}=c(d);this.setHover(u),h.style.cursor=u===null?"grab":"pointer"}),h.addEventListener("pointerleave",()=>{this.setHover(null)}),h.addEventListener("click",d=>{let{zone:u}=c(d);if(u===null)return;let f=Nx(u);f!==null&&this.animateTo(f)})}options;camera;controls;renderer;overlayCamera=new ci(-1.35,1.35,1.35,-1.35,.1,10);root=new Vt;cells=[];zoneCells=new Map;hiddenMaterial=new an({visible:!1});highlightMaterial=new an({color:5073918,transparent:!0,opacity:.55,depthWrite:!1});disposables=[this.hiddenMaterial,this.highlightMaterial];raycaster=new Di;overlay;caption;hovered=null;tweenId=0;disposed=!1;buildCube(){let e=2*Rr/Hc;for(let t of Ix){let n=t.up.clone().cross(t.normal),s=new rt().makeBasis(n,t.up,t.normal),r=new Vt;r.quaternion.setFromRotationMatrix(s);let o=Dx(t.name);this.disposables.push(o);let a=new an({map:o,transparent:!0});this.disposables.push(a);let l=new Tt(new ri(2*Rr,2*Rr),a);l.position.set(0,0,Rr),r.add(l),this.disposables.push(l.geometry);let c=new ri(e*1.02,e*1.02);this.disposables.push(c);for(let h=0;h<Hc;h++)for(let d=0;d<Hc;d++){let u=new Tt(c,this.hiddenMaterial);u.position.set((h-1)*e,(d-1)*e,Rr+.004);let f=t.normal.clone().addScaledVector(n,h-1).addScaledVector(t.up,d-1),g=Lx(f);u.userData.zone=g,r.add(u),this.cells.push(u);let y=this.zoneCells.get(g);y===void 0?this.zoneCells.set(g,[u]):y.push(u)}this.root.add(r)}}setHover(e){if(e!==this.hovered){for(let t of this.hovered===null?[]:this.zoneCells.get(this.hovered)??[])t.material=this.hiddenMaterial;this.hovered=e;for(let t of e===null?[]:this.zoneCells.get(e)??[])t.material=this.highlightMaterial;this.caption.textContent=e,this.caption.style.opacity=e===null?"0":"1"}}animateTo(e){let t=this.camera,n=this.controls,s=t.position.distanceTo(n.target),r=t.position.clone().sub(n.target).normalize(),o=e.clone().normalize();if(r.dot(o)>.9999)return;let a=new Ft().setFromUnitVectors(r,o),l=new Ft;n.enabled=!1,cancelAnimationFrame(this.tweenId);let c=performance.now(),h=()=>{if(this.disposed)return;let d=Math.min(1,(performance.now()-c)/Px),u=1-Math.pow(1-d,3),f=new Ft().slerpQuaternions(l,a,u);t.position.copy(r).applyQuaternion(f).multiplyScalar(s).add(n.target),t.lookAt(n.target),d<1?this.tweenId=requestAnimationFrame(h):(n.enabled=!0,n.update())};this.tweenId=requestAnimationFrame(h)}update(){this.disposed||(this.root.quaternion.copy(this.camera.quaternion).invert(),this.renderer.render(this.root.parent,this.overlayCamera))}dispose(){if(!this.disposed){this.disposed=!0,cancelAnimationFrame(this.tweenId),this.controls.enabled=!0;for(let e of this.disposables)e.dispose();this.renderer.dispose(),this.overlay.remove()}}};function Nx(i){let e=i.split("-"),t=new R,n=0;for(let[s,r]of gd)e.includes(s)&&(t.add(r),n++);return n===0||t.lengthSq()===0?null:t.normalize()}var Ux=25,_d=5073918,xd=16751165,Fx=6;function As(i,e,t){return`${Math.round(i*1e5)},${Math.round(e*1e5)},${Math.round(t*1e5)}`}var il=class{parent;constructor(e){this.parent=new Int32Array(e);for(let t=0;t<e;t++)this.parent[t]=t}find(e){for(;this.parent[e]!==e;)this.parent[e]=this.parent[this.parent[e]],e=this.parent[e];return e}union(e,t){let n=this.find(e),s=this.find(t);n!==s&&(this.parent[s]=n)}};function Ox(i){let e=i.geometry,t=e.getAttribute("position"),n=e.getIndex(),s=t.array,r=Math.floor((n!==null?n.count:t.count)/3),o=(x,S)=>n!==null?n.getX(x*3+S):x*3+S,a=[],l=new Float64Array(r),c=new R,h=new R,d=new R,u=new R,f=new R;for(let x=0;x<r;x++){c.fromArray(s,o(x,0)*3),h.fromArray(s,o(x,1)*3),d.fromArray(s,o(x,2)*3),u.subVectors(h,c),f.subVectors(d,c);let S=new R().crossVectors(u,f);l[x]=S.length()/2,a.push(S.normalize())}let g=new Map;for(let x=0;x<r;x++)for(let S=0;S<3;S++){let M=o(x,S)*3,A=o(x,(S+1)%3)*3,v=As(s[M],s[M+1],s[M+2]),w=As(s[A],s[A+1],s[A+2]),I=v<w?`${v}|${w}`:`${w}|${v}`,P=g.get(I);P===void 0?g.set(I,[{tri:x,ka:v,kb:w}]):P.push({tri:x,ka:v,kb:w})}let y=Math.cos(Ux*Math.PI/180),m=new il(r);for(let x of g.values())for(let S=0;S<x.length;S++)for(let M=S+1;M<x.length;M++){let A=x[S],v=x[M];A===void 0||v===void 0||A.ka===v.ka&&A.kb===v.kb||a[A.tri].dot(a[v.tri])>=y&&m.union(A.tri,v.tri)}let p=new Map,C=new Uint32Array(r),T=[];for(let x=0;x<r;x++){let S=m.find(x),M=p.get(S);M===void 0&&(M=T.length,p.set(S,M),T.push({triangles:[],area:0})),C[x]=M;let A=T[M];A!==void 0&&(A.triangles.push(x),A.area+=l[x])}return{regionOf:C,regions:T}}function Bx(i,e,t){let n=i.geometry,s=n.getAttribute("position"),r=n.getIndex(),o=s.array,a=Math.floor((r!==null?r.count:s.count)/3),l=(x,S)=>r!==null?r.getX(x*3+S):x*3+S,c=new Map;for(let x=0;x<a;x++){let S=e.regionOf[x];for(let M=0;M<3;M++){let A=l(x,M)*3,v=l(x,(M+1)%3)*3,w=As(o[A],o[A+1],o[A+2]),I=As(o[v],o[v+1],o[v+2]),P=w<I?`${w}|${I}`:`${I}|${w}`,O=c.get(P);O===void 0?c.set(P,[S]):O.includes(S)||O.push(S)}}let h=t.length/6,d=new il(h),u=new Map,f=[];for(let x=0;x<h;x++){let S=t[x*6],M=t[x*6+1],A=t[x*6+2],v=t[x*6+3],w=t[x*6+4],I=t[x*6+5],P=As(S,M,A),O=As(v,w,I);f.push([P,O]);let q=u.get(P);q===void 0?u.set(P,[x]):q.push(x);let Y=u.get(O);Y===void 0?u.set(O,[x]):Y.push(x)}let g=x=>{let[S,M]=f[x]??["",""],A=S<M?`${S}|${M}`:`${M}|${S}`;return(c.get(A)??[]).slice().sort((v,w)=>v-w).join(",")},y=[];for(let x=0;x<h;x++)y.push(g(x));for(let x=0;x<h;x++){let[S,M]=f[x]??["",""];for(let A of[S,M]){let v=u.get(A)??[];for(let w of v)w<=x||y[x]===y[w]&&d.union(x,w)}}let m=new Map,p=new Uint32Array(h),C=[];for(let x=0;x<h;x++){let S=d.find(x),M=m.get(S);M===void 0&&(M=C.length,m.set(S,M),C.push({length:0,closed:!0})),p[x]=M;let A=C[M];if(A!==void 0){let v=t[x*6+3]-t[x*6],w=t[x*6+4]-t[x*6+1],I=t[x*6+5]-t[x*6+2];A.length+=Math.sqrt(v*v+w*w+I*I)}}let T=new Map;for(let x=0;x<h;x++){let[S,M]=f[x]??["",""],A=p[x];T.set(`${A}:${S}`,(T.get(`${A}:${S}`)??0)+1),T.set(`${A}:${M}`,(T.get(`${A}:${M}`)??0)+1)}for(let x=0;x<C.length;x++){let S=!0,M=!1;for(let v=0;v<h;v++){if(p[v]!==x)continue;M=!0;let[w,I]=f[v]??["",""];((T.get(`${x}:${w}`)??0)!==2||(T.get(`${x}:${I}`)??0)!==2)&&(S=!1)}let A=C[x];A!==void 0&&(A.closed=M&&S)}return{groupOf:p,groups:C}}var Ir=class{constructor(e){this.options=e;let{domElement:t,cad:n}=e;for(let r of[this.hoverFaceMesh,this.selectFaceMesh,this.hoverEdgeLines,this.selectEdgeLines])r.raycast=()=>{},r.renderOrder=r instanceof xn?3:2,r.visible=!1;this.disposables.push(this.hoverFaceMesh.material,this.hoverFaceMesh.geometry,this.selectFaceMesh.material,this.selectFaceMesh.geometry,this.hoverEdgeLines.material,this.hoverEdgeLines.geometry,this.selectEdgeLines.material,this.selectEdgeLines.geometry);let s=new gn().setFromObject(n).getSize(new R);this.center=new gn().setFromObject(n).getCenter(new R),this.label=document.createElement("div"),this.label.style.cssText='position:absolute;left:8px;bottom:8px;z-index:5;pointer-events:none;font:500 11px/16px -apple-system,"Segoe UI",sans-serif;color:var(--dsw-alias-label-secondary,#374151);background:var(--dsw-alias-bg-base,rgba(255,255,255,0.88));border:1px solid var(--dsw-alias-border-l1,rgba(215,219,224,0.7));border-radius:8px;padding:2px 8px;opacity:0;transition:opacity 120ms;white-space:nowrap;',t.addEventListener("pointermove",this.onPointerMove),t.addEventListener("pointerleave",this.onPointerLeave),t.addEventListener("pointerdown",this.onPointerDown),t.addEventListener("pointerup",this.onPointerUp)}options;raycaster=new Di;meshes=[];faceCache=new Map;edgeCache=new Map;label;hover=null;selection=null;down=null;disposed=!1;center;disposables=[];hoverFaceMesh=new Tt(new mt,new an({color:_d,transparent:!0,opacity:.35,depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2}));selectFaceMesh=new Tt(new mt,new an({color:xd,transparent:!0,opacity:.45,depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-3,polygonOffsetUnits:-3}));hoverEdgeLines=new xn(new mt,new _n({color:_d,depthTest:!1,transparent:!0,opacity:.95}));selectEdgeLines=new xn(new mt,new _n({color:xd,depthTest:!1,transparent:!0,opacity:1}));meshesOf(){return this.meshes.length=0,this.options.cad.traverse(e=>{e.isMesh&&this.meshes.push(e)}),this.meshes}facesOf(e){let t=this.faceCache.get(e);return t===void 0&&(t=Ox(e),this.faceCache.set(e,t)),t}edgesOf(e){let t=e.userData.edges;if(t===void 0)return null;let n=this.edgeCache.get(e);if(n===void 0){let r=t.geometry.getAttribute("position").array;n=Bx(e,this.facesOf(e),r),this.edgeCache.set(e,n)}let s=t.geometry.getAttribute("position").array;return{groups:n,segments:s}}pick(e){let{domElement:t,camera:n}=this.options,s=t.getBoundingClientRect(),r=new te((e.clientX-s.left)/s.width*2-1,-((e.clientY-s.top)/s.height)*2+1);this.raycaster.setFromCamera(r,n);let o=this.meshesOf(),a=this.raycaster.intersectObjects(o,!1)[0],c=2*(a?.distance??n.position.distanceTo(this.center))*Math.tan(n.fov*Math.PI/180/2)/Math.max(s.height,1),h=Fx*c;this.raycaster.params.Line.threshold=h;let d=null;for(let f of o){let g=f.userData.edges;if(g===void 0)continue;let m=this.raycaster.intersectObject(g,!1)[0];if(m!==void 0&&(d===null||m.distance<d.distance)){let p=Math.floor((m.index??0)/2);d={mesh:f,distance:m.distance,segment:p}}}if(d!==null&&(a===void 0||d.distance<=a.distance+h)){let f=this.edgesOf(d.mesh);if(f!==null)return{kind:"edge",mesh:d.mesh,group:f.groups.groupOf[d.segment]??0}}if(a===void 0||a.face===void 0)return null;let u=this.facesOf(a.object).regionOf[a.faceIndex??0]??0;return{kind:"face",mesh:a.object,region:u}}onPointerMove=e=>{if(!this.disposed){if(e.buttons!==0){this.setHover(null);return}this.setHover(this.pick(e))}};onPointerLeave=()=>{this.setHover(null)};onPointerDown=e=>{e.button===0&&(this.down={x:e.clientX,y:e.clientY,at:performance.now()})};onPointerUp=e=>{if(this.disposed)return;let t=this.down;if(this.down=null,t===null||e.button!==0||Math.hypot(e.clientX-t.x,e.clientY-t.y)>5||performance.now()-t.at>600)return;let s=this.pick(e);this.setSelection(s)};setHover(e){vd(e,this.hover)||(this.hover=e,this.refresh())}invalidate(){this.faceCache.clear(),this.edgeCache.clear(),this.selection=null,this.hover=null,this.refresh()}setSelection(e){this.selection=e,this.refresh()}refresh(){let e=(l,c,h)=>{let u=this.facesOf(l).regions[c];if(u===void 0){h.visible=!1;return}let f=l.geometry,g=f.getAttribute("position"),y=f.getIndex(),m=g.array,p=new Float32Array(u.triangles.length*9),C=0;for(let T of u.triangles)for(let x=0;x<3;x++){let S=(y!==null?y.getX(T*3+x):T*3+x)*3;p[C++]=m[S],p[C++]=m[S+1],p[C++]=m[S+2]}h.geometry.dispose(),h.geometry=new mt,h.geometry.setAttribute("position",new wt(p,3)),l!==h.parent&&l.add(h),h.visible=!0},t=(l,c,h)=>{let d=this.edgesOf(l);if(d===null){h.visible=!1;return}let{groups:u,segments:f}=d,g=[];for(let y=0;y<u.groupOf.length;y++)if(u.groupOf[y]===c)for(let m=0;m<6;m++)g.push(f[y*6+m]);h.geometry.dispose(),h.geometry=new mt,h.geometry.setAttribute("position",new xt(g,3)),l!==h.parent&&l.add(h),h.visible=!0},n=(...l)=>{for(let c of l)c.visible=!1},s=vd(this.hover,this.selection)?null:this.hover,r=this.selection;s!==null&&s.kind==="face"?e(s.mesh,s.region,this.hoverFaceMesh):n(this.hoverFaceMesh),s!==null&&s.kind==="edge"?t(s.mesh,s.group,this.hoverEdgeLines):n(this.hoverEdgeLines),r!==null&&r.kind==="face"?e(r.mesh,r.region,this.selectFaceMesh):n(this.selectFaceMesh),r!==null&&r.kind==="edge"?t(r.mesh,r.group,this.selectEdgeLines):n(this.selectEdgeLines);let o=this.hover??r,a=this.options.domElement.parentElement;if(o!==null){let l=o.mesh.name.length>0?`${o.mesh.name} \xB7 `:"";if(o.kind==="face"){let c=this.facesOf(o.mesh).regions[o.region]?.area??0;this.label.textContent=`${l}face \xB7 ${c.toLocaleString(void 0,{maximumFractionDigits:1})} mm\xB2`}else{let c=this.edgesOf(o.mesh)?.groups.groups[o.group],h=c?.length??0;this.label.textContent=`${l}edge \xB7 ${h.toLocaleString(void 0,{maximumFractionDigits:1})} mm${c?.closed===!0?" \xB7 closed":""}`}this.label.style.opacity="1",this.label.parentElement!==a&&a!==null&&a.appendChild(this.label)}else this.label.style.opacity="0",this.label.textContent="";this.options.domElement.style.cursor=o===null?"grab":"pointer"}dispose(){if(this.disposed)return;this.disposed=!0;let{domElement:e}=this.options;e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerleave",this.onPointerLeave),e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointerup",this.onPointerUp);for(let t of[this.hoverFaceMesh,this.selectFaceMesh,this.hoverEdgeLines,this.selectEdgeLines])t.removeFromParent();for(let t of this.disposables)t.dispose();this.label.remove()}};function vd(i,e){return i===null||e===null?i===e:i.kind===e.kind&&i.mesh===e.mesh&&(i.kind==="face"?i.region===e.region:i.group===e.group)}function yd(){let i=new gs;i.moveTo(0,0),i.lineTo(60,0),i.lineTo(60,12),i.lineTo(12,12),i.lineTo(12,60),i.lineTo(0,60),i.closePath();let e=new Ii;e.absarc(36,6,5,0,Math.PI*2,!0),i.holes.push(e);let t=new cr(i,{depth:100,bevelEnabled:!1,curveSegments:32});return t.translate(-30,-30,0),t}var bd={min:{x:-30,y:-30,z:0},max:{x:30,y:30,z:100}};var zx=25,Gc={x:13777723,y:3055172,z:2846678};function Wc(i,e){let t=document.createElement("canvas");t.width=64,t.height=64;let n=t.getContext("2d");n!==null&&(n.font='bold 44px -apple-system, "Segoe UI", sans-serif',n.textAlign="center",n.textBaseline="middle",n.fillStyle=`#${e.toString(16).padStart(6,"0")}`,n.fillText(i,32,34));let s=new Pi(t);s.needsUpdate=!0;let r=new ds({map:s,transparent:!0}),o=new js(r);return o.scale.set(1,1,1),o}function Md(i,e={}){let t=new ws({antialias:!0,alpha:!0});t.setPixelRatio(window.devicePixelRatio),t.setSize(i.clientWidth||360,i.clientHeight||300),i.appendChild(t.domElement),t.domElement.style.width="100%",t.domElement.style.height="100%",t.domElement.style.display="block";let n=new kt(45,1,.01,1e4);n.up.set(0,0,1);let s=new nl(n,t.domElement);s.enableDamping=!0,s.dampingFactor=.12,e.autoRotate===!0&&(s.autoRotate=!0,s.autoRotateSpeed=.8);let r=()=>{let a=i.clientWidth,l=i.clientHeight;a===0||l===0||(t.setSize(a,l,!1),n.aspect=a/l,n.updateProjectionMatrix(),e.onResize?.(a,l))},o=new ResizeObserver(r);return o.observe(i),{renderer:t,camera:n,controls:s,dispose(){o.disconnect(),s.dispose(),t.dispose(),t.domElement.parentNode===i&&i.removeChild(t.domElement)}}}function Sd(i,e){let t=new Vt,n=new pr(e*2,20,9081244,4869976);n.rotation.x=Math.PI/2,t.add(n);let s=new mr(e);t.add(s);let r=e*1.12,o=e*.14,a=Wc("X",Gc.x);a.position.set(r,0,0),a.scale.set(o,o,o),t.add(a);let l=Wc("Y",Gc.y);l.position.set(0,r,0),l.scale.set(o,o,o),t.add(l);let c=Wc("Z",Gc.z);return c.position.set(0,0,r),c.scale.set(o,o,o),t.add(c),i.add(t),[t,n,s,a,l,c]}function Xc(i){for(let e of i)e.traverse(t=>{let n=t;if(n.isMesh){n.geometry?.dispose();let o=n.material;Array.isArray(o)?o.forEach(a=>a.dispose()):o?.dispose()}let s=t;s.isLineSegments&&(s.geometry?.dispose(),s.material?.dispose());let r=t;r.isSprite&&(r.material.map?.dispose(),r.material.dispose())})}function kx(i){let e=i.userData.edges;if(e!==void 0)return e;let t=i.geometry;if(t===void 0)return;let n=i.material;n.polygonOffset=!0,n.polygonOffsetFactor=1,n.polygonOffsetUnits=1;let s=new xn(new tr(t,zx),new _n({color:3358799,transparent:!0,opacity:.9}));return i.add(s),i.userData.edges=s,s}function sl(i,e){i.traverse(t=>{let n=t;if(!n.isMesh)return;let s=n.material;s.wireframe=e==="wireframe";let r=e==="shaded-edges"?kx(n):n.userData.edges;r!==void 0&&(r.visible=e==="shaded-edges")})}function qc(i){let e="geometry"in i?i.geometry:(()=>{let s=new mt,r=typeof i.positions=="string"?Vc(i.positions):i.positions;if(s.setAttribute("position",new wt(r,3)),i.normals!==void 0){let a=typeof i.normals=="string"?Vc(i.normals):i.normals;s.setAttribute("normal",new wt(a,3))}else s.computeVertexNormals();let o=typeof i.indices=="string"?pd(i.indices):i.indices;return s.setIndex(new wt(o,1)),s})(),t=i.color===void 0?10466503:i.color,n=new hr({color:t,metalness:.15,roughness:.55,flatShading:i.normals===void 0,side:ln});return new Tt(e,n)}function Ed(i,e={}){let t=Md(i,{onResize:()=>{S||T()}}),n=new ii,s=e.part===null,r=new Vt;n.add(r);let o=new Vt;s||o.add(qc({name:"demo-bracket",geometry:yd()})),r.add(o);let l=s?{min:{x:-100,y:-100,z:0},max:{x:100,y:100,z:100}}:{...bd},c=new R(l.max.x-l.min.x,l.max.y-l.min.y,l.max.z-l.min.z),h=new R((l.max.x+l.min.x)/2,(l.max.y+l.min.y)/2,(l.max.z+l.min.z)/2),d=Math.max(c.x,c.y,c.z,1e-6);n.add(o);let u=new xs(16777215,5857131,1.1);n.add(u);let f=new hi(16777215,1.6);n.add(f);let g=new hi(16777215,.5);n.add(g);let y=()=>{f.position.set(h.x+d,h.y+d*1.4,h.z+d*.8),g.position.set(h.x-d,h.y+d*.4,h.z-d*.6)};y();let m=Sd(n,d),p=m[1],C="shaded-edges",T=()=>{let U=wd(d,t.camera.aspect,t.camera.fov);t.camera.position.set(h.x+U*.7,h.y+U*.55,h.z+U*.6),t.controls.target.copy(h),t.controls.update()},x=()=>{p.position.set(h.x,h.y,l.min.z),t.camera.near=d/100,t.camera.far=d*40,sl(r,C),y(),T()};x();let S=!1,M=()=>{S=!0};t.renderer.domElement.addEventListener("pointerdown",M,{passive:!0}),t.renderer.domElement.addEventListener("wheel",M,{passive:!0});let A=new Pr({container:i,camera:t.camera,controls:t.controls,onHome:T}),v=new Ir({domElement:t.renderer.domElement,camera:t.camera,cad:r}),w=!1,I=U=>{if(!w){r.remove(o),Xc([o]),v.invalidate(),o=new Vt;for(let G of U.meshes)o.add(qc(G));r.add(o),l=U.bounds,c=new R(l.max.x-l.min.x,l.max.y-l.min.y,l.max.z-l.min.z),h=new R((l.max.x+l.min.x)/2,(l.max.y+l.min.y)/2,(l.max.z+l.min.z)/2),d=Math.max(c.x,c.y,c.z,1e-6),x()}},P=!1,O=U=>{fetch(`/dsh-cad/demo-scene?part=${U}`).then(G=>G.ok?G.json():Promise.reject(new Error(`HTTP ${G.status}`))).then(G=>{w||(I(G),P=!0,e.onSource?.("brep"))}).catch(()=>{w||e.onSource?.(P?"brep":"fallback")})};s||O(e.part??"bracket");let q=()=>{Y=requestAnimationFrame(q),t.controls.update(),t.renderer.render(n,t.camera),A.update()},Y=requestAnimationFrame(q);return{setWireframe(U){this.setRenderMode(U?"wireframe":"shaded-edges")},setRenderMode(U){C=U,sl(r,C)},loadPart:O,resetView:T,dispose(){w=!0,cancelAnimationFrame(Y),v.dispose(),A.dispose(),Xc([r,...m,u,f,g]),t.dispose()}}}function wd(i,e,t){let n=t*Math.PI/180,s=2*Math.atan(Math.tan(n/2)*(Number.isFinite(e)&&e>0?e:1)),r=Math.min(n,s);return i/2/Math.tan(r/2)*1.5}function Td(i,e){let t=Md(i,{onResize:()=>{y||g()}}),n=new ii,s=new Vt;for(let M of e.meshes)s.add(qc(M));let r=e.bounds,o=new R(r.max.x-r.min.x,r.max.y-r.min.y,r.max.z-r.min.z),a=new R((r.max.x+r.min.x)/2,(r.max.y+r.min.y)/2,(r.max.z+r.min.z)/2),l=Math.max(o.x,o.y,o.z,1e-6);n.add(s);let c=new xs(16777215,5857131,1.1);n.add(c);let h=new hi(16777215,1.6);h.position.set(a.x+l,a.y+l*1.4,a.z+l*.8),n.add(h);let d=new hi(16777215,.5);d.position.set(a.x-l,a.y+l*.4,a.z-l*.6),n.add(d);let u=Sd(n,l);u[1].position.set(a.x,a.y,r.min.z),t.camera.near=l/100,t.camera.far=l*40;let g=()=>{let M=wd(l,t.camera.aspect,t.camera.fov);t.camera.position.set(a.x+M*.7,a.y+M*.55,a.z+M*.6),t.controls.target.copy(a),t.controls.update()};g();let y=!1,m=()=>{y=!0};t.renderer.domElement.addEventListener("pointerdown",m,{passive:!0}),t.renderer.domElement.addEventListener("wheel",m,{passive:!0});let p=new Pr({container:i,camera:t.camera,controls:t.controls,onHome:g});sl(s,"shaded-edges");let T=new Ir({domElement:t.renderer.domElement,camera:t.camera,cad:s}),x=()=>{S=requestAnimationFrame(x),t.controls.update(),t.renderer.render(n,t.camera),p.update()},S=requestAnimationFrame(x);return{setWireframe(M){this.setRenderMode(M?"wireframe":"shaded-edges")},setRenderMode(M){sl(s,M)},resetView:g,dispose(){cancelAnimationFrame(S),T.dispose(),p.dispose(),Xc([s,...u,c,h,d]),t.dispose()}}}var Oi=Br(require("react"),1);function Yc(i){let{min:e,max:t}=i.bounds,n=Math.max(t.x-e.x,1e-6),s=Math.max(t.y-e.y,1e-6),r=Math.max(n,s)*.05;return{x:e.x-r,y:-t.y-r,width:n+r*2,height:s+r*2}}function Ad(i){return i.color===void 0?"var(--dsh-cad-stroke, #4c5561)":`#${i.color.toString(16).padStart(6,"0")}`}function Vx(i){let e=[];for(let t=0;t+1<i.length;t+=2)e.push(`${i[t].toFixed(3)},${i[t+1].toFixed(3)}`);return e.join(" ")}function Hx(i,e,t,n,s){let r=n*(Math.PI/180),o=s*(Math.PI/180),a=i+t*Math.cos(r),l=e+t*Math.sin(r),c=i+t*Math.cos(o),h=e+t*Math.sin(o),d=((o-r)%(Math.PI*2)+Math.PI*2)%(Math.PI*2)>Math.PI?1:0;return`M ${a.toFixed(4)} ${l.toFixed(4)} A ${t.toFixed(4)} ${t.toFixed(4)} 0 ${d} 1 ${c.toFixed(4)} ${h.toFixed(4)}`}function Cd(i){return i.entities.map((e,t)=>{let n=`e${t}`,s=e.layer==="hidden",r=e.layer==="paper"||e.layer==="dim",o={stroke:Ad(e),fill:"none",strokeWidth:s||r?1:1.6,vectorEffect:"non-scaling-stroke",...s?{strokeDasharray:"6 4"}:{}};switch(e.type){case"line":return Oi.default.createElement("line",{key:n,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,style:o});case"circle":return Oi.default.createElement("circle",{key:n,cx:e.cx,cy:e.cy,r:e.r,style:o});case"arc":return Oi.default.createElement("path",{key:n,d:Hx(e.cx,e.cy,e.r,e.startAngle,e.endAngle),style:o});case"polyline":return Oi.default.createElement("polyline",{key:n,points:Vx(e.points),fill:"none",style:o});case"text":return Oi.default.createElement("g",{key:n,transform:`translate(${e.x} ${e.y}) scale(1 -1) rotate(${(e.rotation??0)*-1})`},Oi.default.createElement("text",{x:0,y:0,fontSize:e.height,fill:Ad(e),style:{userSelect:"none"}},e.text))}})}var Zc=["shaded-edges","shaded","wireframe"],Gx={"shaded-edges":"Faces+Edges",shaded:"Faces",wireframe:"Wireframe"},Rd=null,$c=new Set,Pd={part:null,assembly:null,drawing:null};function Id(i){Rd={meta:i,at:Date.now()};let e=i.doc??"part";Pd[e]={meta:i,at:Date.now()};for(let t of $c)t()}function Ld(){return Rd}function Lr(i){return Pd[i]}function Dd(i){return $c.add(i),()=>{$c.delete(i)}}function Nd(i){let e=i.meta;if(e===null||typeof e!="object")return null;let t=e;return typeof t.viewId=="string"&&(t.kind==="3d"||t.kind==="2d")?t:null}function Wx(i){let e=new DataView(i);if(e.getUint32(0,!0)!==826426180)throw new Error("bad scene magic");let n=e.getUint32(4,!0),s=new TextDecoder().decode(new Uint8Array(i,8,n)).replace(/\u0000+$/,""),r=JSON.parse(s),o=8+n;return{kind:"3d",format:"model",meshes:r.meshes.map(l=>({name:l.name,...l.color===void 0?{}:{color:l.color},positions:new Float32Array(i,o+l.posOffset,l.posBytes/4),...l.nrmOffset===void 0?{}:{normals:new Float32Array(i,o+l.nrmOffset,(l.nrmBytes??0)/4)},indices:new Uint32Array(i,o+l.idxOffset,l.idxBytes/4),vertexCount:l.vertexCount,triangleCount:l.triangleCount})),bounds:{min:{x:r.bounds.min[0],y:r.bounds.min[1],z:r.bounds.min[2]},max:{x:r.bounds.max[0],y:r.bounds.max[1],z:r.bounds.max[2]}},units:r.units}}function Bi(i){let[e,t]=(0,St.useState)(null),[n,s]=(0,St.useState)(null);return(0,St.useEffect)(()=>{if(i===void 0)return;let r=!1;t(null),s(null);let o=i.includes("/dsh-cad/bin/");return fetch(i).then(async a=>{if(!a.ok)throw new Error(`scene fetch failed: HTTP ${a.status}`);return o?Wx(await a.arrayBuffer()):await a.json()}).then(a=>{r||t(a)}).catch(a=>{r||s(a instanceof Error?a.message:String(a))}),()=>{r=!0}},[i]),{scene:e,error:n}}function zi({scene:i,error:e,height:t,fill:n}){return e!==null?Pt.default.createElement("div",{style:Gt.error},e):i===null?Pt.default.createElement("div",{style:Gt.placeholder},"loading\u2026"):i.kind==="3d"?Pt.default.createElement(Xx,{scene:i,height:t,fill:n}):Pt.default.createElement(qx,{scene:i,height:t,fill:n})}function Xx({scene:i,height:e,fill:t}){let n=(0,St.useRef)(null),s=(0,St.useRef)(null),[r,o]=(0,St.useState)("shaded-edges");(0,St.useEffect)(()=>{let c=n.current;if(c===null)return;let h=Td(c,i);return s.current=h,h.setRenderMode(r),()=>{h.dispose(),s.current=null}},[i]),(0,St.useEffect)(()=>{s.current?.setRenderMode(r)},[r]);let a=(0,St.useCallback)(()=>{o(c=>Zc[(Zc.indexOf(c)+1)%Zc.length])},[]),l=(0,St.useCallback)(()=>{s.current?.resetView()},[]);return Pt.default.createElement("div",{style:t===!0?Cs.wrap:Gt.viewportWrap},Pt.default.createElement("div",{ref:n,style:t===!0?Cs.viewport:{...Gt.viewport,height:e??360}}),Pt.default.createElement("div",{style:Gt.toolbar},Pt.default.createElement("button",{type:"button",style:Gt.button,onClick:a,"aria-pressed":r==="wireframe"},Gx[r]),Pt.default.createElement("button",{type:"button",style:Gt.button,onClick:l},"Reset view")))}function qx({scene:i,height:e,fill:t}){let[n,s]=(0,St.useState)(()=>Yc(i)),r=(0,St.useRef)(null),o=(0,St.useCallback)(()=>s(Yc(i)),[i]),a=(0,St.useCallback)(d=>{d.preventDefault();let f=d.currentTarget.getBoundingClientRect(),g=n.x+(d.clientX-f.left)/f.width*n.width,y=n.y+(d.clientY-f.top)/f.height*n.height,m=d.deltaY<0?.85:1.18;s({x:g-(g-n.x)*m,y:y-(y-n.y)*m,width:n.width*m,height:n.height*m})},[n]),l=(0,St.useCallback)(d=>{r.current={x:d.clientX,y:d.clientY,viewBox:n},d.currentTarget.setPointerCapture(d.pointerId)},[n]),c=(0,St.useCallback)(d=>{let u=r.current;if(u===null)return;let g=d.currentTarget.getBoundingClientRect(),y=u.viewBox.width/g.width,m=u.viewBox.height/g.height;s({...u.viewBox,x:u.viewBox.x-(d.clientX-u.x)*y,y:u.viewBox.y-(d.clientY-u.y)*m})},[]),h=(0,St.useCallback)(()=>{r.current=null},[]);if(i.format==="svg"&&i.svgText!==void 0){let d=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(i.svgText)))}`;return Pt.default.createElement("div",{style:t===!0?Cs.wrap:Gt.viewportWrap},Pt.default.createElement("div",{style:{...t===!0?Cs.viewport:{...Gt.viewport,height:e??360},display:"flex",alignItems:"center",justifyContent:"center",background:"#ffffff"}},Pt.default.createElement("img",{src:d,alt:i.format,style:{maxWidth:"100%",maxHeight:"100%"}})),Pt.default.createElement("div",{style:Gt.toolbar}))}return Pt.default.createElement("div",{style:t===!0?Cs.wrap:Gt.viewportWrap},Pt.default.createElement("svg",{viewBox:`${n.x} ${n.y} ${n.width} ${n.height}`,style:{...t===!0?Cs.viewport:{...Gt.viewport,height:e??360},cursor:r.current===null?"default":"grabbing",touchAction:"none"},onWheel:a,onPointerDown:l,onPointerMove:c,onPointerUp:h,onPointerLeave:h},Pt.default.createElement("g",{transform:"scale(1 -1)"},Cd(i))),Pt.default.createElement("div",{style:Gt.toolbar},Pt.default.createElement("button",{type:"button",style:Gt.button,onClick:o},"Fit")))}var Gt={viewportWrap:{position:"relative"},viewport:{width:"100%",background:"var(--dsh-cad-bg, linear-gradient(#f5f6f8, #e9ecf0))",display:"block"},toolbar:{position:"absolute",top:8,left:8,display:"flex",gap:6,zIndex:5},button:{border:"1px solid var(--dsw-alias-border-l2, #c4c9d0)",borderRadius:999,background:"var(--dsw-alias-bg-base, #fff)",color:"var(--dsw-alias-label-secondary, #374151)",fontSize:11,lineHeight:"16px",padding:"3px 10px",cursor:"pointer"},placeholder:{color:"var(--dsw-alias-label-tertiary, #6b7280)",fontSize:12,padding:"10px 12px"},error:{color:"var(--dsw-alias-state-error-primary, #b91c1c)",fontSize:12,padding:"10px 12px"}},Cs={wrap:{position:"relative",flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column"},viewport:{flex:"1 1 auto",minHeight:0,width:"100%",background:"var(--dsh-cad-bg, linear-gradient(#f5f6f8, #e9ecf0))",display:"block"}};var Yx=360;function Ud({block:i}){let e=i.kind==="tool-call",t=e?void 0:Nd(i)??void 0,{scene:n,error:s}=Bi(t?.sceneUrl);return t!==void 0&&Id(t),t===void 0?xi.default.createElement("div",{style:Gt.placeholder},e?"Converting CAD\u2026":"CAD result"):xi.default.createElement("div",{style:Dr.card},xi.default.createElement("div",{style:Dr.header},xi.default.createElement("span",{style:Dr.title},t.title),xi.default.createElement("span",{style:Dr.stats},Zx(t))),xi.default.createElement(zi,{scene:n,error:s,height:Yx}),xi.default.createElement("div",{style:Dr.footer},n===null?t.sceneUrl===void 0?"headless composition: viewer unavailable, see summary above":"loading geometry\u2026":$x(n)))}function Zx(i){if(i.kind==="3d"){let e=[];return i.stats.meshes!==void 0&&e.push(`${i.stats.meshes} part${i.stats.meshes===1?"":"s"}`),i.stats.triangles!==void 0&&e.push(`${i.stats.triangles.toLocaleString()} triangles`),e.join(" \xB7 ")}return i.stats.entities!==void 0?`${i.stats.entities.toLocaleString()} entities`:""}function $x(i){if(i===null)return"";if(i.kind==="3d"){let s=i.bounds;return`size ${[s.max.x-s.min.x,s.max.y-s.min.y,s.max.z-s.min.z].map(o=>o.toFixed(2)).join(" \xD7 ")} ${i.units==="unitless"?"":i.units}`.trim()}let e=i.bounds,t=[(e.max.x-e.min.x).toFixed(2),(e.max.y-e.min.y).toFixed(2)],n=i.layers.length>0?` \xB7 ${i.layers.length} layers`:"";return`extent ${t.join(" \xD7 ")}${n}`}var Dr={card:{border:"1px solid var(--dsw-alias-border-l1, #d7dbe0)",borderRadius:10,margin:"6px 0",overflow:"hidden",display:"flex",flexDirection:"column",maxWidth:720,background:"var(--dsw-alias-bg-base, #fff)"},header:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,padding:"8px 12px"},title:{fontWeight:600,fontSize:13},stats:{fontSize:12,color:"var(--dsw-alias-label-tertiary, #6b7280)"},footer:{borderTop:"1px solid var(--dsw-alias-border-l1, #e5e7eb)",color:"var(--dsw-alias-label-tertiary, #6b7280)",fontSize:11,padding:"5px 12px"}};var Z=Br(require("react"),1);function Jx(i){let e={part:void 0,assembly:void 0,drawing:void 0},t=i?.nodes??[];for(let n=t.length-1;n>=0;n--){let s=t[n];if(s===void 0)continue;let r=s.meta;if(s.kind==="tool-result"&&typeof r?.viewId=="string"&&(r.kind==="3d"||r.kind==="2d")){let o=r.doc??"part";e[o]===void 0&&(e[o]=r)}}return e}var Kx=()=>()=>{},Jc={part:void 0,assembly:void 0,drawing:void 0},Rs=Jc;function jx(i,e){let t=i?.(l=>l.current),n=(0,Z.useMemo)(()=>{if(!(e===void 0||t===void 0))return e.binding?.(t)?.session},[e,t]),s=(0,Z.useMemo)(()=>n===void 0?Kx:l=>n.subscribe(l),[n]),r=(0,Z.useMemo)(()=>n===void 0?()=>Jc:()=>{let l=Jx(n.getSnapshot());return Rs!==Jc&&Rs.part===l.part&&Rs.assembly===l.assembly&&Rs.drawing===l.drawing?Rs:(Rs=l,l)},[n]),o=(0,Z.useSyncExternalStore)(s,r),[,a]=(0,Z.useReducer)(l=>l+1,0);return(0,Z.useEffect)(()=>Dd(()=>{a()}),[]),e!==void 0?{part:o.part??null,assembly:o.assembly??Lr("assembly")?.meta??null,drawing:o.drawing??Lr("drawing")?.meta??null}:{part:Ld()?.meta??null,assembly:Lr("assembly")?.meta??null,drawing:Lr("drawing")?.meta??null}}var Fd={part:"Part Studio",assembly:"\u88C5\u914D\u4F53",drawing:"\u5DE5\u7A0B\u56FE"},Un=[{id:"part"}],Ps="part",Kc={tabs:Un,active:Ps},jc=new Set;function eh(){Kc={tabs:Un,active:Ps};for(let i of jc)i()}function kd(i){Un.some(e=>e.id===i)||(Un=[...Un,{id:i}]),Ps=i,eh()}function Qx(i){let e=Un.findIndex(t=>t.id===i);e!==-1&&(Un=Un.filter(t=>t.id!==i),Ps===i&&(Ps=(Un[e-1]??Un[e])?.id??null),eh())}function Od(i){Ps=i,eh()}function ev(){return(0,Z.useSyncExternalStore)(i=>(jc.add(i),()=>{jc.delete(i)}),()=>Kc,()=>Kc)}var Vd=null,Nr=Vd,Qc=new Set;function rl(i){Vd=i,Nr=i;for(let e of Qc)e()}function tv(){return(0,Z.useSyncExternalStore)(i=>(Qc.add(i),()=>{Qc.delete(i)}),()=>Nr,()=>Nr)}var qn="currentColor";function nv(){return Z.default.createElement("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0},Z.default.createElement("path",{d:"M8 1.5 14 5v6L8 14.5 2 11V5l6-3.5Z",stroke:qn,strokeWidth:"1.3",strokeLinejoin:"round"}),Z.default.createElement("path",{d:"M2 5l6 3.5L14 5M8 8.5v6",stroke:qn,strokeWidth:"1.3",strokeLinejoin:"round"}))}function Hd(){return Z.default.createElement("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0},Z.default.createElement("path",{d:"M5.5 1.5 10 4v4L5.5 10.5 1 8V4l4.5-2.5Z",stroke:qn,strokeWidth:"1.2",strokeLinejoin:"round",opacity:"0.75"}),Z.default.createElement("path",{d:"M10.5 5.5 15 8v4l-4.5 2.5L6 12V8l4.5-2.5Z",stroke:qn,strokeWidth:"1.2",strokeLinejoin:"round"}))}function Gd(){return Z.default.createElement("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0},Z.default.createElement("path",{d:"M3 1.5h7l3 3V14.5H3V1.5Z",stroke:qn,strokeWidth:"1.3",strokeLinejoin:"round"}),Z.default.createElement("path",{d:"M5.5 7h5M5.5 9.5h5M5.5 12h3",stroke:qn,strokeWidth:"1.2",strokeLinecap:"round"}))}function Wd({kind:i}){return i==="assembly"?Z.default.createElement(Hd,null):i==="drawing"?Z.default.createElement(Gd,null):Z.default.createElement(nv,null)}function iv(){return Z.default.createElement("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0},Z.default.createElement("path",{d:"M1.5 4.5A1 1 0 0 1 2.5 3.5h3.2l1.4 1.8h6.4a1 1 0 0 1 1 1v6.2a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1V4.5Z",stroke:qn,strokeWidth:"1.3",strokeLinejoin:"round"}))}function sv(){return Z.default.createElement("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0},Z.default.createElement("path",{d:"M4 1.5h5l3 3v10H4v-13Z",stroke:qn,strokeWidth:"1.2",strokeLinejoin:"round"}),Z.default.createElement("path",{d:"M9 1.5v3h3",stroke:qn,strokeWidth:"1.2",strokeLinejoin:"round"}))}function Xd(i){let e=i.closest("[data-shell-overlay]");if(!(e instanceof HTMLElement))return{frame:null,detailsCol:null,centerCol:null};let t=e.parentElement instanceof HTMLElement?e.parentElement:null,n=e.previousElementSibling instanceof HTMLElement?e.previousElementSibling:null,s=n?.previousElementSibling instanceof HTMLElement?n.previousElementSibling:null;return{frame:t,detailsCol:n,centerCol:s}}function rv({frame:i,detailsCol:e,centerCol:t}){if(e!==null&&t!==null)return{right:e.getBoundingClientRect().width,centerWidth:t.getBoundingClientRect().width};if(i!==null){let n=getComputedStyle(i).gridTemplateColumns.trim().split(/\s+/).map(Number.parseFloat),s=n[1],r=n[2];if(Number.isFinite(s)&&Number.isFinite(r))return{right:r,centerWidth:s}}return{right:0,centerWidth:0}}function ov(i){let[e,t]=(0,Z.useState)({right:0,centerWidth:0});return(0,Z.useLayoutEffect)(()=>{let n=i.current;if(n===null)return;let s=Xd(n),r=0,o=()=>{r=0;let c=rv(s);t(h=>Math.abs(h.right-c.right)<.5&&Math.abs(h.centerWidth-c.centerWidth)<.5?h:c)},a=()=>{r===0&&(r=requestAnimationFrame(o))},l=new ResizeObserver(a);for(let c of[s.frame,s.detailsCol,s.centerCol])c!==null&&l.observe(c);return window.addEventListener("resize",a),o(),()=>{l.disconnect(),window.removeEventListener("resize",a),r!==0&&cancelAnimationFrame(r)}},[i]),e}var Bd=280,zd=720,av=460,lv=20,cv=.42,hv=[{kind:"part",label:"\u96F6\u4EF6",hint:"Part Studio \xB7 \u4E09\u7EF4\u5EFA\u6A21"},{kind:"assembly",label:"\u88C5\u914D\u4F53",hint:"Assembly \xB7 \u5B9E\u4F8B\u88C5\u914D"},{kind:"drawing",label:"\u5DE5\u7A0B\u56FE",hint:"Drawing \xB7 \u56FE\u7EB8\u8F93\u51FA"}];function uv({onPick:i,onClose:e}){let t=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{let n=r=>{t.current!==null&&r.target instanceof Node&&t.current.contains(r.target)||e()},s=r=>{r.key==="Escape"&&e()};return document.addEventListener("pointerdown",n,!0),document.addEventListener("keydown",s),()=>{document.removeEventListener("pointerdown",n,!0),document.removeEventListener("keydown",s)}},[e]),Z.default.createElement("div",{ref:t,style:Oe.menu,role:"menu","aria-label":"\u65B0\u5EFA\u6587\u6863"},hv.map(n=>Z.default.createElement("button",{key:n.kind,type:"button",role:"menuitem",style:Oe.menuItem,onClick:()=>{i(n.kind)}},Z.default.createElement("span",{style:Oe.menuIcon},Z.default.createElement(Wd,{kind:n.kind})),Z.default.createElement("span",{style:Oe.menuLabel},n.label),Z.default.createElement("span",{style:Oe.menuHint},n.hint))))}function dv(i){let e=Date.now()-Date.parse(i);if(!Number.isFinite(e))return"";let t=Math.floor(e/6e4);if(t<1)return"\u521A\u521A";if(t<60)return`${t} \u5206\u949F\u524D`;let n=Math.floor(t/60);return n<24?`${n} \u5C0F\u65F6\u524D`:`${Math.floor(n/24)} \u5929\u524D`}function fv({activeDocId:i,onClose:e}){let t=(0,Z.useRef)(null),[n,s]=(0,Z.useState)(null),[r,o]=(0,Z.useState)(null),[a,l]=(0,Z.useState)(null),[c,h]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{let f=y=>{t.current!==null&&y.target instanceof Node&&t.current.contains(y.target)||e()},g=y=>{y.key==="Escape"&&e()};return document.addEventListener("pointerdown",f,!0),document.addEventListener("keydown",g),()=>{document.removeEventListener("pointerdown",f,!0),document.removeEventListener("keydown",g)}},[e]);let d=(0,Z.useCallback)(()=>{s(null),o(null),fetch("/dsh-cad/docs").then(f=>f.ok?f.json():Promise.reject(new Error(`HTTP ${f.status}`))).then(f=>{s(f.docs??[])}).catch(f=>{o(f instanceof Error?f.message:String(f))})},[]);(0,Z.useEffect)(()=>{d()},[d]);let u=f=>{h(f),fetch(`/dsh-cad/docs/delete?id=${encodeURIComponent(f)}`,{method:"POST"}).then(()=>{l(null),Nr?.docId===f&&rl(null),d()}).catch(g=>{o(g instanceof Error?g.message:String(g))}).finally(()=>{h(null)})};return Z.default.createElement("div",{ref:t,style:Oe.menu,role:"menu","aria-label":"\u6587\u6863\u5217\u8868"},Z.default.createElement("div",{style:Oe.docsHeader},"\u5DE5\u4F5C\u533A\u6587\u6863"),r!==null?Z.default.createElement("div",{style:Oe.docsError},r):null,n===null&&r===null?Z.default.createElement("div",{style:Oe.docsHintRow},"\u52A0\u8F7D\u4E2D\u2026"):null,n!==null&&n.length===0?Z.default.createElement("div",{style:Oe.docsHintRow},"\u8FD8\u6CA1\u6709\u5EFA\u6A21\u6587\u6863 \u2014 \u5728\u5BF9\u8BDD\u4E2D\u5EFA\u6A21\u540E\u4F1A\u51FA\u73B0\u5728\u8FD9\u91CC"):null,n?.map(f=>{let g=f.id===i;return Z.default.createElement("div",{key:f.id,style:Oe.docRow},Z.default.createElement("button",{type:"button",role:"menuitem",style:Oe.docRowMain,onClick:()=>{f.sceneUrl!==void 0&&(rl({docId:f.id,name:f.name,sceneUrl:f.sceneUrl}),kd("part"),e())},title:f.sceneUrl===void 0?"\u7A7A\u6587\u6863\uFF08\u65E0\u573A\u666F\uFF09":"\u70B9\u51FB\u9884\u89C8"},Z.default.createElement("span",{style:Oe.menuIcon},Z.default.createElement(sv,null)),Z.default.createElement("span",{style:{...Oe.menuLabel,...g?{color:"var(--dsw-alias-label-primary,#4d6bfe)",fontWeight:600}:{}}},f.name,g?" \xB7 \u5F53\u524D":""),Z.default.createElement("span",{style:Oe.menuHint},f.bodies," \u4F53 \xB7 ",dv(f.updatedAt))),a===f.id?Z.default.createElement("span",{style:Oe.docConfirm},Z.default.createElement("button",{type:"button",style:Oe.docConfirmYes,disabled:c===f.id,onClick:()=>{u(f.id)}},"\u5220\u9664"),Z.default.createElement("button",{type:"button",style:Oe.docConfirmNo,onClick:()=>{l(null)}},"\u53D6\u6D88")):Z.default.createElement("button",{type:"button",style:Oe.docDelete,"aria-label":`\u5220\u9664\u6587\u6863 ${f.name}`,title:"\u5220\u9664\u6587\u6863",onClick:()=>{l(f.id)}},"\xD7"))}),Z.default.createElement("div",{style:Oe.docsFooter},"\u70B9\u51FB\u9884\u89C8 \xB7 \u5207\u6362\u5EFA\u6A21\u76EE\u6807\u8BF7\u5728\u5BF9\u8BDD\u4E2D\u8BF4\u300C\u6253\u5F00 xx \u6587\u6863\u300D"))}function qd(i){return function(t){let n=(0,Z.useRef)(null),[s,r]=(0,Z.useState)(!0),[o,a]=(0,Z.useState)(av),[l,c]=(0,Z.useState)(!1),[h,d]=(0,Z.useState)(!1),u=ov(n),f=jx(t.useSessions,i),{tabs:g,active:y}=ev(),m=(0,Z.useMemo)(()=>{let M=u.centerWidth>0?Math.max(Bd,u.centerWidth*cv):zd;return Math.round(Math.min(o,M))},[o,u.centerWidth]);pv(n,s,m);let p=(0,Z.useRef)(null),C=M=>{M.preventDefault(),p.current={startX:M.clientX,startWidth:m},M.currentTarget.setPointerCapture(M.pointerId)},T=M=>{let A=p.current;if(A===null)return;let v=A.startWidth+(A.startX-M.clientX);a(Math.round(Math.min(zd,Math.max(Bd,v))))},x=()=>{p.current=null},S=y===null?null:f[y];return Z.default.createElement("div",{ref:n,"data-cad-side-panel":"",style:Oe.root},s?Z.default.createElement("div",{style:{...Oe.panel,right:u.right,width:m}},Z.default.createElement("div",{style:Oe.resizer,onPointerDown:C,onPointerMove:T,onPointerUp:x,onPointerCancel:x,role:"separator","aria-orientation":"vertical","aria-label":"\u8C03\u6574 CAD \u9762\u677F\u5BBD\u5EA6"}),Z.default.createElement("div",{style:Oe.tabStripRow},Z.default.createElement("div",{style:Oe.tabStrip,role:"tablist","aria-label":"CAD \u6587\u6863"},g.map(M=>{let A=M.id===y;return Z.default.createElement("div",{key:M.id,role:"tab","aria-selected":A,tabIndex:0,style:{...Oe.tab,...A?Oe.tabActive:{}},onClick:()=>{Od(M.id)},onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&Od(M.id)}},Z.default.createElement("span",{style:A?Oe.tabIconActive:Oe.tabIcon},Z.default.createElement(Wd,{kind:M.id})),Z.default.createElement("span",{style:Oe.tabLabel},Fd[M.id]),Z.default.createElement("button",{type:"button",style:Oe.tabClose,"aria-label":`\u5173\u95ED ${Fd[M.id]}`,title:"\u5173\u95ED",onClick:v=>{v.stopPropagation(),Qx(M.id)}},"\xD7"))}),Z.default.createElement("button",{type:"button",style:Oe.addTab,"aria-label":"\u65B0\u5EFA\u6587\u6863",title:"\u65B0\u5EFA\uFF1A\u96F6\u4EF6 / \u88C5\u914D\u4F53 / \u5DE5\u7A0B\u56FE",onClick:()=>{d(!1),c(M=>!M)}},"+")),Z.default.createElement("button",{type:"button",style:Oe.fileButton,"aria-label":"\u6587\u6863\u5217\u8868","aria-expanded":h,title:"\u5DE5\u4F5C\u533A\u6587\u6863\u5217\u8868\uFF08\u9884\u89C8 / \u5220\u9664\uFF09",onClick:()=>{c(!1),d(M=>!M)}},Z.default.createElement(iv,null)),Z.default.createElement("span",{style:Oe.headerStats},S===null?"":xv(S)),Z.default.createElement("button",{type:"button",style:Oe.iconButton,onClick:()=>{r(!1)},"aria-label":"\u6536\u8D77 CAD \u9762\u677F",title:"\u6536\u8D77"},"\xBB")),l?Z.default.createElement(uv,{onPick:M=>{c(!1),kd(M)},onClose:()=>{c(!1)}}):null,h?Z.default.createElement(fv,{activeDocId:f.part?.viewId??null,onClose:()=>{d(!1)}}):null,Z.default.createElement("div",{style:Oe.body},y==="part"?Z.default.createElement(mv,{meta:f.part}):null,y==="assembly"?Z.default.createElement(gv,{meta:f.assembly}):null,y==="drawing"?Z.default.createElement(_v,{meta:f.drawing}):null)):Z.default.createElement("button",{type:"button",style:{...Oe.rail,right:u.right+10},onClick:()=>{r(!0)},"aria-label":"\u5C55\u5F00 CAD \u9762\u677F",title:"\u5C55\u5F00 CAD \u89C6\u56FE"},"\xAB\xA0\xA0CAD"))}}function pv(i,e,t){(0,Z.useLayoutEffect)(()=>{let n=i.current;if(n===null)return;let s=Xd(n).centerCol;if(s!==null)return s.style.paddingRight=e?`${lv+t}px`:"",()=>{s.style.paddingRight=""}},[i,e,t])}function mv({meta:i}){let e=tv(),t=Bi(i?.sceneUrl),n=Bi(e?.sceneUrl);return(0,Z.useEffect)(()=>{i!==null&&Nr!==null&&rl(null)},[i?.sceneUrl]),e!==null?Z.default.createElement("div",{style:Oe.sceneFill},Z.default.createElement("div",{style:Oe.previewBar},Z.default.createElement("span",{style:Oe.previewLabel},"\u9884\u89C8: ",e.name),Z.default.createElement("button",{type:"button",style:Oe.previewBack,onClick:()=>{rl(null)}},"\u8FD4\u56DE\u8DDF\u8E2A")),Z.default.createElement(zi,{scene:n.scene,error:n.error,fill:!0})):i===null?Z.default.createElement(vv,null):Z.default.createElement("div",{key:i.sceneUrl??i.viewId,style:Oe.sceneFill},Z.default.createElement(zi,{scene:t.scene,error:t.error,fill:!0}))}function gv({meta:i}){let{scene:e,error:t}=Bi(i?.sceneUrl);return i===null?Z.default.createElement(Yd,{icon:Z.default.createElement(Hd,null),title:"\u88C5\u914D\u4F53\u4E3A\u7A7A",hint:"\u5728\u5BF9\u8BDD\u4E2D\u8BF4\u300C\u628A b1 \u548C b2 \u88C5\u914D\u8D77\u6765\uFF0Cb2 \u653E\u5230 (60, 0, 0)\u300D\uFF0C\u6216\u4F7F\u7528 cad_assembly_insert \u5DE5\u5177\u63D2\u5165\u5B9E\u4F8B"}):Z.default.createElement("div",{key:i.sceneUrl??i.viewId,style:Oe.sceneFill},Z.default.createElement(zi,{scene:e,error:t,fill:!0}))}function _v({meta:i}){let{scene:e,error:t}=Bi(i?.sceneUrl);return i===null?Z.default.createElement(Yd,{icon:Z.default.createElement(Gd,null),title:"\u8FD8\u6CA1\u6709\u5DE5\u7A0B\u56FE",hint:"\u5728\u5BF9\u8BDD\u4E2D\u8BF4\u300C\u7ED9 b1 \u51FA\u4E00\u5F20 A3 \u5DE5\u7A0B\u56FE\u300D\uFF0C\u6216\u4F7F\u7528 cad_drawing \u5DE5\u5177\u751F\u6210\u4E09\u89C6\u56FE + \u8F74\u6D4B\u56FE"}):Z.default.createElement("div",{key:i.sceneUrl??i.viewId,style:{...Oe.sceneFill,background:"#fff"}},Z.default.createElement(zi,{scene:e,error:t,fill:!0}))}function Yd({icon:i,title:e,hint:t}){return Z.default.createElement("div",{style:Oe.emptyState},Z.default.createElement("div",{style:Oe.emptyIcon},i),Z.default.createElement("div",{style:Oe.emptyTitle},e),Z.default.createElement("div",{style:Oe.emptyHint},t))}function xv(i){let e=[];if(i.kind==="3d"){let t=i.doc==="assembly"?" \u5B9E\u4F8B":" \u4F53";i.stats.meshes!==void 0&&e.push(`${i.stats.meshes}${t}`),i.stats.triangles!==void 0&&e.push(`${i.stats.triangles.toLocaleString()} \u4E09\u89D2\u9762`)}else i.stats.entities!==void 0&&e.push(`${i.stats.entities.toLocaleString()} \u5B9E\u4F53`);return e.join(" \xB7 ")}function vv(){let i=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{let e=i.current;if(e===null)return;let t=Ed(e,{part:null});return()=>{t.dispose()}},[]),Z.default.createElement("div",{style:Oe.demoRoot},Z.default.createElement("div",{style:Oe.demoCaption},"Part Studio"),Z.default.createElement("div",{style:Oe.demoViewport},Z.default.createElement("div",{ref:i,style:{width:"100%",height:"100%"}})),Z.default.createElement("div",{style:Oe.demoHint},"\u5EFA\u6A21\u533A\u4E3A\u7A7A \xB7 \u5728\u5BF9\u8BDD\u4E2D\u63CF\u8FF0\u96F6\u4EF6\uFF08\u5982\u300C\u5EFA\u4E00\u4E2A 100\xD760\xD710 \u7684\u677F\uFF0C\u4E2D\u95F4\u6253 \u230020 \u5B54\u300D\uFF09\uFF0C\u5EFA\u6A21\u540E\u6B64\u9875\u7B7E\u5B9E\u65F6\u8DDF\u8E2A\u6700\u65B0\u6A21\u578B"))}var Oe={root:{position:"absolute",inset:0,pointerEvents:"none"},panel:{position:"absolute",top:0,bottom:0,pointerEvents:"auto",display:"flex",flexDirection:"column",minWidth:0,background:"var(--dsw-alias-bg-base, #fff)",borderLeft:"1px solid var(--dsw-alias-border-l2, #c4c9d0)",boxShadow:"-16px 0 28px -20px rgba(16,24,40,0.18)"},resizer:{position:"absolute",top:0,bottom:0,left:0,width:7,marginLeft:-3,cursor:"col-resize",zIndex:6,touchAction:"none"},tabStripRow:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px 6px 12px",flex:"none",borderBottom:"1px solid var(--dsw-alias-border-l1, #eceff3)",background:"var(--dsw-alias-bg-subtle, #f7f8fa)",position:"relative"},tabStrip:{display:"flex",alignItems:"center",gap:4,flex:"1 1 auto",minWidth:0,overflow:"hidden"},tab:{display:"flex",alignItems:"center",gap:5,padding:"4px 6px 4px 9px",borderRadius:7,border:"1px solid transparent",color:"var(--dsw-alias-label-tertiary, #6b7280)",cursor:"pointer",userSelect:"none",flex:"none",maxWidth:150,lineHeight:"18px"},tabActive:{background:"var(--dsw-alias-bg-base, #fff)",borderColor:"var(--dsw-alias-border-l1, #e2e5ea)",color:"var(--dsw-alias-label-primary, #1f2937)",boxShadow:"0 1px 2px rgba(16,24,40,0.06)"},tabIcon:{display:"flex",alignItems:"center",opacity:.75,flex:"none"},tabIconActive:{display:"flex",alignItems:"center",color:"var(--dsw-alias-label-primary, #4d6bfe)",flex:"none"},tabLabel:{fontSize:12,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},tabClose:{border:"none",background:"transparent",color:"var(--dsw-alias-label-tertiary, #9ca3af)",fontSize:13,lineHeight:"16px",width:16,height:16,borderRadius:4,cursor:"pointer",padding:0,flex:"none",textAlign:"center"},addTab:{flex:"none",width:24,height:24,marginLeft:2,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--dsw-alias-border-l1, #e2e5ea)",borderRadius:7,background:"var(--dsw-alias-bg-base, #fff)",color:"var(--dsw-alias-label-secondary, #374151)",fontSize:15,lineHeight:"18px",cursor:"pointer",padding:0},menu:{position:"absolute",top:40,left:12,zIndex:20,minWidth:230,padding:5,background:"var(--dsw-alias-bg-base, #fff)",border:"1px solid var(--dsw-alias-border-l1, #e2e5ea)",borderRadius:10,boxShadow:"0 12px 32px -12px rgba(16,24,40,0.24)",display:"flex",flexDirection:"column",gap:1},menuItem:{display:"flex",alignItems:"center",gap:8,padding:"7px 9px",border:"none",borderRadius:7,background:"transparent",color:"var(--dsw-alias-label-primary, #1f2937)",cursor:"pointer",textAlign:"left",font:"inherit",fontSize:12.5},menuIcon:{display:"flex",alignItems:"center",color:"var(--dsw-alias-label-secondary, #374151)",flex:"none"},menuLabel:{fontWeight:600,flex:"none"},menuHint:{color:"var(--dsw-alias-label-tertiary, #9ca3af)",fontSize:11,marginLeft:"auto",whiteSpace:"nowrap"},fileButton:{flex:"none",display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,marginLeft:4,border:"1px solid var(--dsw-alias-border-l2, #c4c9d0)",borderRadius:6,background:"transparent",color:"var(--dsw-alias-label-secondary, #374151)",cursor:"pointer",padding:0},docsHeader:{fontSize:11,fontWeight:600,color:"var(--dsw-alias-label-tertiary, #6b7280)",padding:"5px 9px 3px",letterSpacing:"0.02em"},docsHintRow:{fontSize:12,color:"var(--dsw-alias-label-tertiary, #6b7280)",padding:"8px 9px"},docsError:{fontSize:12,color:"var(--dsw-alias-state-error-primary, #d92d20)",padding:"4px 9px"},docsFooter:{fontSize:11,color:"var(--dsw-alias-label-tertiary, #9ca3af)",padding:"5px 9px 3px",borderTop:"1px solid var(--dsw-alias-border-l1, #e2e5ea)",marginTop:3},docRow:{display:"flex",alignItems:"center",gap:2},docRowMain:{display:"flex",alignItems:"center",gap:8,flex:"1 1 auto",minWidth:0,padding:"7px 9px",border:"none",borderRadius:7,background:"transparent",color:"var(--dsw-alias-label-primary, #1f2937)",cursor:"pointer",textAlign:"left",font:"inherit",fontSize:12.5},docDelete:{flex:"none",width:22,height:22,border:"none",borderRadius:6,background:"transparent",color:"var(--dsw-alias-label-tertiary, #9ca3af)",fontSize:14,lineHeight:"20px",cursor:"pointer",padding:0},docConfirm:{display:"flex",alignItems:"center",gap:4,flex:"none",padding:"0 4px 0 0"},docConfirmYes:{border:"none",borderRadius:6,background:"var(--dsw-alias-state-error-primary, #d92d20)",color:"#fff",fontSize:11,padding:"3px 8px",cursor:"pointer"},docConfirmNo:{border:"1px solid var(--dsw-alias-border-l2, #c4c9d0)",borderRadius:6,background:"transparent",color:"var(--dsw-alias-label-secondary, #374151)",fontSize:11,padding:"3px 8px",cursor:"pointer"},previewBar:{flex:"none",display:"flex",alignItems:"center",gap:8,padding:"5px 10px",borderBottom:"1px solid var(--dsw-alias-border-l1, #e2e5ea)",background:"var(--dsw-alias-bg-subtle, #f5f6f8)"},previewLabel:{flex:"1 1 auto",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12,color:"var(--dsw-alias-label-primary, #1f2937)",fontWeight:600},previewBack:{flex:"none",border:"1px solid var(--dsw-alias-border-l2, #c4c9d0)",borderRadius:6,background:"transparent",color:"var(--dsw-alias-label-secondary, #374151)",fontSize:11,padding:"2px 8px",cursor:"pointer"},headerStats:{flex:"none",fontSize:11,color:"var(--dsw-alias-label-tertiary, #6b7280)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"30%"},iconButton:{flex:"none",border:"none",background:"transparent",color:"var(--dsw-alias-label-tertiary, #6b7280)",fontSize:15,lineHeight:"20px",width:26,height:26,borderRadius:6,cursor:"pointer",padding:0},body:{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column"},sceneFill:{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column"},emptyState:{flex:"1 1 auto",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,padding:24,color:"var(--dsw-alias-label-tertiary, #9ca3af)",textAlign:"center"},emptyIcon:{display:"flex",color:"var(--dsw-alias-label-tertiary, #c0c6cf)",transform:"scale(2)",marginBottom:6},emptyTitle:{fontSize:13,fontWeight:600,color:"var(--dsw-alias-label-secondary, #6b7280)"},emptyHint:{fontSize:11.5,lineHeight:"18px",maxWidth:300},demoRoot:{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column",gap:6,padding:"10px 10px 12px"},demoCaption:{color:"var(--dsw-alias-label-tertiary, #6b7280)",fontSize:11,textTransform:"uppercase",letterSpacing:"0.05em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:"none"},demoViewport:{position:"relative",flex:"1 1 auto",minHeight:0,borderRadius:10,overflow:"hidden",background:"var(--dsh-cad-bg, linear-gradient(#f5f6f8, #e9ecf0))"},demoHint:{flex:"none",color:"var(--dsw-alias-label-tertiary, #9ca3af)",fontSize:11,lineHeight:"17px",textAlign:"center"},rail:{position:"absolute",top:72,pointerEvents:"auto",writingMode:"vertical-rl",padding:"12px 6px",borderRadius:10,border:"1px solid var(--dsw-alias-border-l2, #c4c9d0)",background:"var(--dsw-alias-bg-base, #fff)",color:"var(--dsw-alias-label-secondary, #374151)",fontSize:11,letterSpacing:"0.08em",cursor:"pointer",boxShadow:"4px 4px 12px -6px rgba(16,24,40,0.2)"}};var yv=["slots"],bv=["cad_view","cad_create_prim","cad_extrude_profile","cad_revolve","cad_chamfer","cad_pattern","cad_loft","cad_sweep","cad_boolean","cad_fillet","cad_transform","cad_export","cad_delete","cad_volume","cad_freecad","cad_image_profile","cad_drawing","cad_assembly_insert","cad_assembly_move","cad_assembly_remove","cad_doc_open","cad_constraint","cad_solve","cad_motion"];function Mv(i){i.slots.onEntryError?.((n,s,r,o)=>{try{document.documentElement.setAttribute("data-cad-slot-crash",`${n}:${String(r instanceof Error?r.message:r).slice(0,160)}:abd=${String(o.abdicated)}`)}catch{}});for(let n of bv)i.slots.inject("tool.call.toolview",()=>i.slots.register({name:"tool.call.toolview",key:n,locale:"conversation"},Ud));let t=i.get?.("sessions");i.slots.inject("shell.overlay",()=>i.slots.register({name:"shell.overlay",id:"cad-side-panel",order:100,label:"CAD"},qd(t)))}
|
|
4114
4114
|
return module.exports;
|
|
4115
4115
|
}
|
|
4116
4116
|
});
|