@beeson-group/tycho 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/AUTHORS +7 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +14 -0
  4. package/README.md +38 -0
  5. package/THIRD_PARTY_NOTICES.md +68 -0
  6. package/dist/tycho.esm.js +515 -261
  7. package/dist/tycho.js +515 -261
  8. package/dist/types/container.d.ts +64 -0
  9. package/dist/types/errors.d.ts +10 -0
  10. package/dist/types/evaluate/clock.d.ts +30 -0
  11. package/dist/types/evaluate/frames.d.ts +63 -0
  12. package/dist/types/evaluate/index.d.ts +14 -0
  13. package/dist/types/evaluate/layers.d.ts +47 -0
  14. package/dist/types/evaluate/resolve.d.ts +39 -0
  15. package/dist/types/evaluate/sets.d.ts +49 -0
  16. package/dist/types/evaluate/types.d.ts +36 -0
  17. package/dist/types/index.d.ts +22 -0
  18. package/dist/types/runtime/colormaps.d.ts +10 -0
  19. package/dist/types/runtime/colors.d.ts +94 -0
  20. package/dist/types/runtime/element.d.ts +224 -0
  21. package/dist/types/runtime/export.d.ts +119 -0
  22. package/dist/types/runtime/geometry.d.ts +214 -0
  23. package/dist/types/runtime/icons.d.ts +56 -0
  24. package/dist/types/runtime/layout.d.ts +34 -0
  25. package/dist/types/runtime/overlay.d.ts +33 -0
  26. package/dist/types/runtime/readouts.d.ts +129 -0
  27. package/dist/types/runtime/renderer.d.ts +303 -0
  28. package/dist/types/runtime/state.d.ts +106 -0
  29. package/dist/types/runtime/tiles.d.ts +33 -0
  30. package/dist/types/scene.d.ts +37 -0
  31. package/dist/types/scene.gen.d.ts +440 -0
  32. package/dist/types/validate.d.ts +9 -0
  33. package/package.json +63 -35
  34. package/src/colormaps.ts +0 -42
  35. package/src/container.ts +0 -126
  36. package/src/element.ts +0 -1034
  37. package/src/frames.ts +0 -204
  38. package/src/index.ts +0 -14
  39. package/src/layout.ts +0 -82
  40. package/src/viewer.ts +0 -864
package/dist/tycho.js CHANGED
@@ -1,8 +1,16 @@
1
- "use strict";var tycho=(()=>{var Ha=Object.defineProperty;var Mh=Object.getOwnPropertyDescriptor;var bh=Object.getOwnPropertyNames;var Sh=Object.prototype.hasOwnProperty;var Eh=(i,t)=>{for(var e in t)Ha(i,e,{get:t[e],enumerable:!0})},Th=(i,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of bh(t))!Sh.call(i,s)&&s!==e&&Ha(i,s,{get:()=>t[s],enumerable:!(n=Mh(t,s))||n.enumerable});return i};var wh=i=>Th(Ha({},"__esModule",{value:!0}),i);var Sg={};Eh(Sg,{Container:()=>oi,DARK:()=>ol,FRAMES:()=>hn,OrbitViewer:()=>Gi,TychoViewerElement:()=>Us,bodyPosition:()=>Hn,bodyTrail:()=>$i,colormap:()=>li,colormapCss:()=>Ji,decodeEmbedded:()=>Va,define:()=>Ba,elapsedTime:()=>Yi,loadContainer:()=>Os,rho:()=>Bs,segmentIndex:()=>ks,transformTrajectory:()=>Zi,trueAnomalyFromTime:()=>zs});var oi=class i{constructor(t,e,n){this.header=t,this.body=e,this.bodyOffset=n}static parse(t){let e=new DataView(t);if(e.getUint32(0,!0)!==1145264468)throw new Error("not a Tycho data container");let n=e.getUint32(4,!0);if(n!==1)throw new Error(`unsupported container version ${n}`);let s=e.getUint32(8,!0),r=JSON.parse(new TextDecoder().decode(new Uint8Array(t,12,s))),a=12+s,o=a+(8-a%8)%8;return new i(r,t,o)}get datasets(){return this.header.datasets}viewInfo(t){let e=this.header.views[t];if(!e)throw new Error(`unknown view ${t}`);return e}view(t){let e=this.viewInfo(t),n=this.bodyOffset+e.offset;switch(e.dtype){case"float32":return new Float32Array(this.body,n,e.length/4);case"float64":return new Float64Array(this.body,n,e.length/8);case"int32":return new Int32Array(this.body,n,e.length/4);case"uint8":return new Uint8Array(this.body,n,e.length)}}f32(t){let e=this.view(t);return e instanceof Float32Array?e:Float32Array.from(e)}f64(t){let e=this.view(t);return e instanceof Float64Array?e:Float64Array.from(e)}};function Ah(i){let t=atob(i.replace(/\s+/g,"")),e=new Uint8Array(new ArrayBuffer(t.length));for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}async function Va(i){let t=i.dataset.encoding??"base64",e=Ah(i.textContent??"");if(t==="base64")return e.buffer;if(t==="gzip+base64"){if(typeof DecompressionStream>"u")throw new Error("this browser lacks DecompressionStream; rebuild the page with compress=False");let n=new Blob([e]).stream().pipeThrough(new DecompressionStream("gzip"));return new Response(n).arrayBuffer()}throw new Error(`unknown data encoding ${t}`)}async function Os(i){if(i.startsWith("#")){let e=document.querySelector(i);if(!e)throw new Error(`no element matches ${i}`);return oi.parse(await Va(e))}let t=await fetch(i);if(!t.ok)throw new Error(`failed to fetch ${i}: ${t.status}`);return oi.parse(await t.arrayBuffer())}var hn=[{id:"rotating_pulsating",label:"rotating-pulsating",axes:["x [DU]","y [DU]"],cmap:"viridis"},{id:"rotating",label:"rotating",axes:["x\u0303 [DU]","y\u0303 [DU]"],cmap:"blues"},{id:"barycentric_inertial",label:"barycentric inertial",axes:["\u03BE [DU]","\u03B7 [DU]"],cmap:"plasma"},{id:"inertial_primary",label:"inertial, centred on m\u2081",axes:["\u03BE\u2081 [DU]","\u03B7\u2081 [DU]"],cmap:"reds"},{id:"inertial_secondary",label:"inertial, centred on m\u2082",axes:["\u03BE\u2082 [DU]","\u03B7\u2082 [DU]"],cmap:"cividis"}];function Bs(i,t){return(1-i*i)/(1+i*Math.cos(t))}function Ga(i,t){let e=Math.round(t/(2*Math.PI)),n=t-2*Math.PI*e,s=2*Math.atan2(Math.sqrt(1-i)*Math.sin(n/2),Math.sqrt(1+i)*Math.cos(n/2));return s-i*Math.sin(s)+2*Math.PI*e}function Yi(i,t,e){return Ga(i,e)-Ga(i,t)}function Hn(i,t,e,n,s,r=0){let a=i==="primary"?-t.mu:1-t.mu,o=Bs(t.e,n),c=Math.cos(n),l=Math.sin(n);switch(e){case"rotating_pulsating":s[r]=a,s[r+1]=0;return;case"rotating":s[r]=o*a,s[r+1]=0;return;case"barycentric_inertial":s[r]=o*a*c,s[r+1]=o*a*l;return;case"inertial_primary":{let h=i==="primary"?0:o;s[r]=h*c,s[r+1]=h*l;return}case"inertial_secondary":{let h=i==="secondary"?0:-o;s[r]=h*c,s[r+1]=h*l;return}}}function Zi(i,t,e,n,s){let r=t.length,a=new Float32Array(2);for(let o=0;o<r;o++){let c=i[2*o],l=i[2*o+1],h=e.f0+t[o],f,u;if(n==="rotating_pulsating")f=c,u=l;else{let p=Bs(e.e,h);if(n==="rotating")f=p*c,u=p*l;else{let g=Math.cos(h),_=Math.sin(h);f=p*(c*g-l*_),u=p*(c*_+l*g),n!=="barycentric_inertial"&&(Hn(n==="inertial_primary"?"primary":"secondary",e,"barycentric_inertial",h,a),f-=a[0],u-=a[1])}}s[3*o]=f,s[3*o+1]=u,s[3*o+2]=0}return s}function $i(i,t,e,n,s){let r=new Float32Array(2);for(let a=0;a<t.length;a++)Hn(i,e,n,e.f0+t[a],r),s[3*a]=r[0],s[3*a+1]=r[1],s[3*a+2]=0;return s}function zs(i,t,e){let n=Ga(i,t)+e,s=Math.floor(n/(2*Math.PI)),r=n-2*Math.PI*s,a=i<.8?r:Math.PI;for(let c=0;c<30;c++){let l=(a-i*Math.sin(a)-r)/(1-i*Math.cos(a));if(a-=l,Math.abs(l)<1e-13)break}let o=2*Math.atan2(Math.sqrt(1+i)*Math.sin(a/2),Math.sqrt(1-i)*Math.cos(a/2));return o<0&&(o+=2*Math.PI),o+2*Math.PI*s}function ks(i,t){let e=0,n=i.length-1;if(t<=i[0])return 0;if(t>=i[n])return n-1;for(;n-e>1;){let s=e+n>>1;i[s]<=t?e=s:n=s}return e}var Rh={viridis:[[.267,.005,.329],[.283,.141,.458],[.254,.265,.53],[.207,.372,.553],[.164,.471,.558],[.128,.567,.551],[.135,.659,.518],[.267,.749,.441],[.478,.821,.318],[.741,.873,.15],[.993,.906,.144]],plasma:[[.05,.03,.528],[.294,.012,.615],[.492,.012,.658],[.665,.139,.586],[.798,.28,.47],[.902,.418,.36],[.973,.585,.252],[.993,.771,.155],[.94,.975,.131]],cividis:[[0,.135,.304],[.086,.218,.396],[.243,.301,.42],[.365,.383,.432],[.478,.466,.448],[.588,.55,.437],[.702,.638,.402],[.822,.73,.343],[.945,.827,.244],[.996,.91,.149]],blues:[[.19,.42,.71],[.33,.6,.8],[.53,.76,.87],[.7,.85,.92],[.85,.93,.98]],reds:[[.72,.1,.1],[.89,.27,.2],[.98,.5,.36],[.99,.7,.58],[1,.86,.78]]};function li(i,t,e=[0,0,0]){let n=Rh[i],s=Math.max(0,Math.min(1,t))*(n.length-1),r=Math.min(n.length-2,Math.floor(s)),a=s-r;for(let o=0;o<3;o++)e[o]=n[r][o]+(n[r+1][o]-n[r][o])*a;return e}function Ji(i,t){let[e,n,s]=li(i,t);return`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(s*255)})`}var Se={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Be={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},zl=0,vo=1,kl=2;var Mo=1,Hl=2,rn=3,_n=0,Ee=1,Xe=2,vn=0,xn=1,Es=2,bo=3,So=4,Vl=5,In=100,Gl=101,Wl=102,Xl=103,ql=104,Yl=200,Zl=201,$l=202,Jl=203,hr=204,ur=205,Kl=206,jl=207,Ql=208,tc=209,ec=210,nc=211,ic=212,sc=213,rc=214,Ur=0,Nr=1,Fr=2,Zn=3,Or=4,Br=5,zr=6,kr=7,Eo=0,ac=1,oc=2,Mn=0,lc=1,cc=2,hc=3,uc=4,dc=5,fc=6,pc=7;var To=300,jn=301,Qn=302,Hr=303,Vr=304,Ts=306,dr=1e3,Pn=1001,fr=1002,Ge=1003,mc=1004;var ws=1005;var Ke=1006,Gr=1007;var On=1008;var an=1009,wo=1010,Ao=1011,Ui=1012,Wr=1013,Bn=1014,on=1015,Ni=1016,Xr=1017,qr=1018,Fi=1020,Ro=35902,Co=35899,Po=1021,Io=1022,qe=1023,Si=1026,Oi=1027,Lo=1028,Yr=1029,Do=1030,Zr=1031;var $r=1033,As=33776,Rs=33777,Cs=33778,Ps=33779,Jr=35840,Kr=35841,jr=35842,Qr=35843,ta=36196,ea=37492,na=37496,ia=37808,sa=37809,ra=37810,aa=37811,oa=37812,la=37813,ca=37814,ha=37815,ua=37816,da=37817,fa=37818,pa=37819,ma=37820,ga=37821,_a=36492,xa=36494,ya=36495,va=36283,Ma=36284,ba=36285,Sa=36286;var ss=2300,pr=2301,cr=2302,fo=2400,po=2401,mo=2402;var gc=3200,_c=3201;var xc=0,yc=1,bn="",Fe="srgb",$n="srgb-linear",rs="linear",qt="srgb";var qn=7680;var go=519,vc=512,Mc=513,bc=514,Uo=515,Sc=516,Ec=517,Tc=518,wc=519,_o=35044;var No="300 es",Je=2e3,as=2001;var tn=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){let n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){let n=this._listeners;if(n===void 0)return;let s=n[t];if(s!==void 0){let r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){let e=this._listeners;if(e===void 0)return;let n=e[t.type];if(n!==void 0){t.target=this;let s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,t);t.target=null}}},_e=["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"],ml=1234567,ns=Math.PI/180,Ei=180/Math.PI;function Bi(){let i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(_e[i&255]+_e[i>>8&255]+_e[i>>16&255]+_e[i>>24&255]+"-"+_e[t&255]+_e[t>>8&255]+"-"+_e[t>>16&15|64]+_e[t>>24&255]+"-"+_e[e&63|128]+_e[e>>8&255]+"-"+_e[e>>16&255]+_e[e>>24&255]+_e[n&255]+_e[n>>8&255]+_e[n>>16&255]+_e[n>>24&255]).toLowerCase()}function Ot(i,t,e){return Math.max(t,Math.min(e,i))}function Fo(i,t){return(i%t+t)%t}function Ch(i,t,e,n,s){return n+(i-t)*(s-n)/(e-t)}function Ph(i,t,e){return i!==t?(e-i)/(t-i):0}function is(i,t,e){return(1-e)*i+e*t}function Ih(i,t,e,n){return is(i,t,1-Math.exp(-e*n))}function Lh(i,t=1){return t-Math.abs(Fo(i,t*2)-t)}function Dh(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function Uh(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Nh(i,t){return i+Math.floor(Math.random()*(t-i+1))}function Fh(i,t){return i+Math.random()*(t-i)}function Oh(i){return i*(.5-Math.random())}function Bh(i){i!==void 0&&(ml=i);let t=ml+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function zh(i){return i*ns}function kh(i){return i*Ei}function Hh(i){return(i&i-1)===0&&i!==0}function Vh(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Gh(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Wh(i,t,e,n,s){let r=Math.cos,a=Math.sin,o=r(e/2),c=a(e/2),l=r((t+n)/2),h=a((t+n)/2),f=r((t-n)/2),u=a((t-n)/2),p=r((n-t)/2),g=a((n-t)/2);switch(s){case"XYX":i.set(o*h,c*f,c*u,o*l);break;case"YZY":i.set(c*u,o*h,c*f,o*l);break;case"ZXZ":i.set(c*f,c*u,o*h,o*l);break;case"XZX":i.set(o*h,c*g,c*p,o*l);break;case"YXY":i.set(c*p,o*h,c*g,o*l);break;case"ZYZ":i.set(c*g,c*p,o*h,o*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function Mi(i,t){switch(t.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("Invalid component type.")}}function be(i,t){switch(t.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("Invalid component type.")}}var Oo={DEG2RAD:ns,RAD2DEG:Ei,generateUUID:Bi,clamp:Ot,euclideanModulo:Fo,mapLinear:Ch,inverseLerp:Ph,lerp:is,damp:Ih,pingpong:Lh,smoothstep:Dh,smootherstep:Uh,randInt:Nh,randFloat:Fh,randFloatSpread:Oh,seededRandom:Bh,degToRad:zh,radToDeg:kh,isPowerOfTwo:Hh,ceilPowerOfTwo:Vh,floorPowerOfTwo:Gh,setQuaternionFromProperEuler:Wh,normalize:be,denormalize:Mi},Ut=class i{constructor(t=0,e=0){i.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Ot(this.x,t.x,e.x),this.y=Ot(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Ot(this.x,t,e),this.y=Ot(this.y,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ot(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(Ot(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let n=Math.cos(e),s=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*s+t.x,this.y=r*s+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},We=class{constructor(t=0,e=0,n=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,r,a,o){let c=n[s+0],l=n[s+1],h=n[s+2],f=n[s+3],u=r[a+0],p=r[a+1],g=r[a+2],_=r[a+3];if(o===0){t[e+0]=c,t[e+1]=l,t[e+2]=h,t[e+3]=f;return}if(o===1){t[e+0]=u,t[e+1]=p,t[e+2]=g,t[e+3]=_;return}if(f!==_||c!==u||l!==p||h!==g){let m=1-o,d=c*u+l*p+h*g+f*_,T=d>=0?1:-1,M=1-d*d;if(M>Number.EPSILON){let R=Math.sqrt(M),w=Math.atan2(R,d*T);m=Math.sin(m*w)/R,o=Math.sin(o*w)/R}let v=o*T;if(c=c*m+u*v,l=l*m+p*v,h=h*m+g*v,f=f*m+_*v,m===1-o){let R=1/Math.sqrt(c*c+l*l+h*h+f*f);c*=R,l*=R,h*=R,f*=R}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=f}static multiplyQuaternionsFlat(t,e,n,s,r,a){let o=n[s],c=n[s+1],l=n[s+2],h=n[s+3],f=r[a],u=r[a+1],p=r[a+2],g=r[a+3];return t[e]=o*g+h*f+c*p-l*u,t[e+1]=c*g+h*u+l*f-o*p,t[e+2]=l*g+h*p+o*u-c*f,t[e+3]=h*g-o*f-c*u-l*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,s){return this._x=t,this._y=e,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){let n=t._x,s=t._y,r=t._z,a=t._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(s/2),f=o(r/2),u=c(n/2),p=c(s/2),g=c(r/2);switch(a){case"XYZ":this._x=u*h*f+l*p*g,this._y=l*p*f-u*h*g,this._z=l*h*g+u*p*f,this._w=l*h*f-u*p*g;break;case"YXZ":this._x=u*h*f+l*p*g,this._y=l*p*f-u*h*g,this._z=l*h*g-u*p*f,this._w=l*h*f+u*p*g;break;case"ZXY":this._x=u*h*f-l*p*g,this._y=l*p*f+u*h*g,this._z=l*h*g+u*p*f,this._w=l*h*f-u*p*g;break;case"ZYX":this._x=u*h*f-l*p*g,this._y=l*p*f+u*h*g,this._z=l*h*g-u*p*f,this._w=l*h*f+u*p*g;break;case"YZX":this._x=u*h*f+l*p*g,this._y=l*p*f+u*h*g,this._z=l*h*g-u*p*f,this._w=l*h*f-u*p*g;break;case"XZY":this._x=u*h*f-l*p*g,this._y=l*p*f-u*h*g,this._z=l*h*g+u*p*f,this._w=l*h*f+u*p*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],s=e[4],r=e[8],a=e[1],o=e[5],c=e[9],l=e[2],h=e[6],f=e[10],u=n+o+f;if(u>0){let p=.5/Math.sqrt(u+1);this._w=.25/p,this._x=(h-c)*p,this._y=(r-l)*p,this._z=(a-s)*p}else if(n>o&&n>f){let p=2*Math.sqrt(1+n-o-f);this._w=(h-c)/p,this._x=.25*p,this._y=(s+a)/p,this._z=(r+l)/p}else if(o>f){let p=2*Math.sqrt(1+o-n-f);this._w=(r-l)/p,this._x=(s+a)/p,this._y=.25*p,this._z=(c+h)/p}else{let p=2*Math.sqrt(1+f-n-o);this._w=(a-s)/p,this._x=(r+l)/p,this._y=(c+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Ot(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let s=Math.min(1,e/n);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let n=t._x,s=t._y,r=t._z,a=t._w,o=e._x,c=e._y,l=e._z,h=e._w;return this._x=n*h+a*o+s*l-r*c,this._y=s*h+a*c+r*o-n*l,this._z=r*h+a*l+n*c-s*o,this._w=a*h-n*o-s*c-r*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);let n=this._x,s=this._y,r=this._z,a=this._w,o=a*t._w+n*t._x+s*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=s,this._z=r,this;let c=1-o*o;if(c<=Number.EPSILON){let p=1-e;return this._w=p*a+e*this._w,this._x=p*n+e*this._x,this._y=p*s+e*this._y,this._z=p*r+e*this._z,this.normalize(),this}let l=Math.sqrt(c),h=Math.atan2(l,o),f=Math.sin((1-e)*h)/l,u=Math.sin(e*h)/l;return this._w=a*f+this._w*u,this._x=n*f+this._x*u,this._y=s*f+this._y*u,this._z=r*f+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},N=class i{constructor(t=0,e=0,n=0){i.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(gl.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(gl.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*s,this.y=r[1]*e+r[4]*n+r[7]*s,this.z=r[2]*e+r[5]*n+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(t){let e=this.x,n=this.y,s=this.z,r=t.x,a=t.y,o=t.z,c=t.w,l=2*(a*s-o*n),h=2*(o*e-r*s),f=2*(r*n-a*e);return this.x=e+c*l+a*f-o*h,this.y=n+c*h+o*l-r*f,this.z=s+c*f+r*h-a*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*s,this.y=r[1]*e+r[5]*n+r[9]*s,this.z=r[2]*e+r[6]*n+r[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Ot(this.x,t.x,e.x),this.y=Ot(this.y,t.y,e.y),this.z=Ot(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Ot(this.x,t,e),this.y=Ot(this.y,t,e),this.z=Ot(this.z,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ot(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let n=t.x,s=t.y,r=t.z,a=e.x,o=e.y,c=e.z;return this.x=s*c-r*o,this.y=r*a-n*c,this.z=n*o-s*a,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Wa.copy(this).projectOnVector(t),this.sub(Wa)}reflect(t){return this.sub(Wa.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(Ot(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){let s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Wa=new N,gl=new We,Lt=class i{constructor(t,e,n,s,r,a,o,c,l){i.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,c,l)}set(t,e,n,s,r,a,o,c,l){let h=this.elements;return h[0]=t,h[1]=s,h[2]=o,h[3]=e,h[4]=r,h[5]=c,h[6]=n,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],f=n[7],u=n[2],p=n[5],g=n[8],_=s[0],m=s[3],d=s[6],T=s[1],M=s[4],v=s[7],R=s[2],w=s[5],C=s[8];return r[0]=a*_+o*T+c*R,r[3]=a*m+o*M+c*w,r[6]=a*d+o*v+c*C,r[1]=l*_+h*T+f*R,r[4]=l*m+h*M+f*w,r[7]=l*d+h*v+f*C,r[2]=u*_+p*T+g*R,r[5]=u*m+p*M+g*w,r[8]=u*d+p*v+g*C,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8];return e*a*h-e*o*l-n*r*h+n*o*c+s*r*l-s*a*c}invert(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],f=h*a-o*l,u=o*c-h*r,p=l*r-a*c,g=e*f+n*u+s*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let _=1/g;return t[0]=f*_,t[1]=(s*l-h*n)*_,t[2]=(o*n-s*a)*_,t[3]=u*_,t[4]=(h*e-s*c)*_,t[5]=(s*r-o*e)*_,t[6]=p*_,t[7]=(n*c-l*e)*_,t[8]=(a*e-n*r)*_,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,r,a,o){let c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+t,-s*l,s*c,-s*(-l*a+c*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(Xa.makeScale(t,e)),this}rotate(t){return this.premultiply(Xa.makeRotation(-t)),this}translate(t,e){return this.premultiply(Xa.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}},Xa=new Lt;function Bo(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function os(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Ac(){let i=os("canvas");return i.style.display="block",i}var _l={};function Ti(i){i in _l||(_l[i]=!0,console.warn(i))}function Rc(i,t,e){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}var xl=new Lt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),yl=new Lt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Xh(){let i={enabled:!0,workingColorSpace:$n,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===qt&&(s.r=gn(s.r),s.g=gn(s.g),s.b=gn(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===qt&&(s.r=bi(s.r),s.g=bi(s.g),s.b=bi(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===bn?rs: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("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Ti("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[$n]:{primaries:t,whitePoint:n,transfer:rs,toXYZ:xl,fromXYZ:yl,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Fe},outputColorSpaceConfig:{drawingBufferColorSpace:Fe}},[Fe]:{primaries:t,whitePoint:n,transfer:qt,toXYZ:xl,fromXYZ:yl,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Fe}}}),i}var Vt=Xh();function gn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function bi(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var ci,mr=class{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{ci===void 0&&(ci=os("canvas")),ci.width=t.width,ci.height=t.height;let s=ci.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),n=ci}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=os("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let s=n.getImageData(0,0,t.width,t.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=gn(r[a]/255)*255;return n.putImageData(s,0,0),e}else if(t.data){let e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(gn(e[n]/255)*255):e[n]=gn(e[n]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}},qh=0,wi=class{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:qh++}),this.uuid=Bi(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){let e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];let n={uuid:this.uuid,url:""},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(qa(s[a].image)):r.push(qa(s[a]))}else r=qa(s);n.url=r}return e||(t.images[this.uuid]=n),n}};function qa(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?mr.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var Yh=0,Ya=new N,Re=class i extends tn{constructor(t=i.DEFAULT_IMAGE,e=i.DEFAULT_MAPPING,n=Pn,s=Pn,r=Ke,a=On,o=qe,c=an,l=i.DEFAULT_ANISOTROPY,h=bn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Yh++}),this.uuid=Bi(),this.name="",this.source=new wi(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Ut(0,0),this.repeat=new Ut(1,1),this.center=new Ut(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Lt,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=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Ya).x}get height(){return this.source.getSize(Ya).y}get depth(){return this.source.getSize(Ya).z}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(let e in t){let n=t[e];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){console.warn(`THREE.Texture.setValues(): property '${e}' 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[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==To)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case dr:t.x=t.x-Math.floor(t.x);break;case Pn:t.x=t.x<0?0:1;break;case fr:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case dr:t.y=t.y-Math.floor(t.y);break;case Pn:t.y=t.y<0?0:1;break;case fr:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}};Re.DEFAULT_IMAGE=null;Re.DEFAULT_MAPPING=To;Re.DEFAULT_ANISOTROPY=1;var oe=class i{constructor(t=0,e=0,n=0,s=1){i.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,s){return this.x=t,this.y=e,this.z=n,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*s+a[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,s,r,c=t.elements,l=c[0],h=c[4],f=c[8],u=c[1],p=c[5],g=c[9],_=c[2],m=c[6],d=c[10];if(Math.abs(h-u)<.01&&Math.abs(f-_)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+u)<.1&&Math.abs(f+_)<.1&&Math.abs(g+m)<.1&&Math.abs(l+p+d-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let M=(l+1)/2,v=(p+1)/2,R=(d+1)/2,w=(h+u)/4,C=(f+_)/4,U=(g+m)/4;return M>v&&M>R?M<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(M),s=w/n,r=C/n):v>R?v<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(v),n=w/s,r=U/s):R<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(R),n=C/r,s=U/r),this.set(n,s,r,e),this}let T=Math.sqrt((m-g)*(m-g)+(f-_)*(f-_)+(u-h)*(u-h));return Math.abs(T)<.001&&(T=1),this.x=(m-g)/T,this.y=(f-_)/T,this.z=(u-h)/T,this.w=Math.acos((l+p+d-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Ot(this.x,t.x,e.x),this.y=Ot(this.y,t.y,e.y),this.z=Ot(this.z,t.z,e.z),this.w=Ot(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Ot(this.x,t,e),this.y=Ot(this.y,t,e),this.z=Ot(this.z,t,e),this.w=Ot(this.w,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ot(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},gr=class extends tn{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ke,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new oe(0,0,t,e),this.scissorTest=!1,this.viewport=new oe(0,0,t,e);let s={width:t,height:e,depth:n.depth},r=new Re(s);this.textures=[];let 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}_setTextureOptions(t={}){let e={minFilter:Ke,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=t,this.textures[s].image.height=e,this.textures[s].image.depth=n,this.textures[s].isArrayTexture=this.textures[s].image.depth>1;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;let s=Object.assign({},t.textures[e].image);this.textures[e].source=new wi(s)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},en=class extends gr{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}},ls=class extends Re{constructor(t=null,e=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=Ge,this.minFilter=Ge,this.wrapR=Pn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}};var _r=class extends Re{constructor(t=null,e=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=Ge,this.minFilter=Ge,this.wrapR=Pn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var nn=class{constructor(t=new N(1/0,1/0,1/0),e=new N(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(Ye.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Ye.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=Ye.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);let n=t.geometry;if(n!==void 0){let r=n.getAttribute("position");if(e===!0&&r!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,Ye):Ye.fromBufferAttribute(r,a),Ye.applyMatrix4(t.matrixWorld),this.expandByPoint(Ye);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Hs.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Hs.copy(n.boundingBox)),Hs.applyMatrix4(t.matrixWorld),this.union(Hs)}let s=t.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[r],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Ye),Ye.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ki),Vs.subVectors(this.max,Ki),hi.subVectors(t.a,Ki),ui.subVectors(t.b,Ki),di.subVectors(t.c,Ki),Sn.subVectors(ui,hi),En.subVectors(di,ui),Vn.subVectors(hi,di);let e=[0,-Sn.z,Sn.y,0,-En.z,En.y,0,-Vn.z,Vn.y,Sn.z,0,-Sn.x,En.z,0,-En.x,Vn.z,0,-Vn.x,-Sn.y,Sn.x,0,-En.y,En.x,0,-Vn.y,Vn.x,0];return!Za(e,hi,ui,di,Vs)||(e=[1,0,0,0,1,0,0,0,1],!Za(e,hi,ui,di,Vs))?!1:(Gs.crossVectors(Sn,En),e=[Gs.x,Gs.y,Gs.z],Za(e,hi,ui,di,Vs))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ye).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Ye).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(un[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),un[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),un[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),un[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),un[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),un[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),un[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),un[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(un),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}},un=[new N,new N,new N,new N,new N,new N,new N,new N],Ye=new N,Hs=new nn,hi=new N,ui=new N,di=new N,Sn=new N,En=new N,Vn=new N,Ki=new N,Vs=new N,Gs=new N,Gn=new N;function Za(i,t,e,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){Gn.fromArray(i,r);let o=s.x*Math.abs(Gn.x)+s.y*Math.abs(Gn.y)+s.z*Math.abs(Gn.z),c=t.dot(Gn),l=e.dot(Gn),h=n.dot(Gn);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}var Zh=new nn,ji=new N,$a=new N,Ln=class{constructor(t=new N,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let n=this.center;e!==void 0?n.copy(e):Zh.setFromPoints(t).getCenter(n);let s=0;for(let r=0,a=t.length;r<a;r++)s=Math.max(s,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(s),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){let e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){let n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;ji.subVectors(t,this.center);let e=ji.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(ji,s/n),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):($a.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(ji.copy(t.center).add($a)),this.expandByPoint(ji.copy(t.center).sub($a))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}},dn=new N,Ja=new N,Ws=new N,Tn=new N,Ka=new N,Xs=new N,ja=new N,Dn=class{constructor(t=new N,e=new N(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,dn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=dn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(dn.copy(this.origin).addScaledVector(this.direction,e),dn.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){Ja.copy(t).add(e).multiplyScalar(.5),Ws.copy(e).sub(t).normalize(),Tn.copy(this.origin).sub(Ja);let r=t.distanceTo(e)*.5,a=-this.direction.dot(Ws),o=Tn.dot(this.direction),c=-Tn.dot(Ws),l=Tn.lengthSq(),h=Math.abs(1-a*a),f,u,p,g;if(h>0)if(f=a*c-o,u=a*o-c,g=r*h,f>=0)if(u>=-g)if(u<=g){let _=1/h;f*=_,u*=_,p=f*(f+a*u+2*o)+u*(a*f+u+2*c)+l}else u=r,f=Math.max(0,-(a*u+o)),p=-f*f+u*(u+2*c)+l;else u=-r,f=Math.max(0,-(a*u+o)),p=-f*f+u*(u+2*c)+l;else u<=-g?(f=Math.max(0,-(-a*r+o)),u=f>0?-r:Math.min(Math.max(-r,-c),r),p=-f*f+u*(u+2*c)+l):u<=g?(f=0,u=Math.min(Math.max(-r,-c),r),p=u*(u+2*c)+l):(f=Math.max(0,-(a*r+o)),u=f>0?r:Math.min(Math.max(-r,-c),r),p=-f*f+u*(u+2*c)+l);else u=a>0?-r:r,f=Math.max(0,-(a*u+o)),p=-f*f+u*(u+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,f),s&&s.copy(Ja).addScaledVector(Ws,u),p}intersectSphere(t,e){dn.subVectors(t.center,this.origin);let n=dn.dot(this.direction),s=dn.dot(dn)-n*n,r=t.radius*t.radius;if(s>r)return null;let a=Math.sqrt(r-s),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){let n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,r,a,o,c,l=1/this.direction.x,h=1/this.direction.y,f=1/this.direction.z,u=this.origin;return l>=0?(n=(t.min.x-u.x)*l,s=(t.max.x-u.x)*l):(n=(t.max.x-u.x)*l,s=(t.min.x-u.x)*l),h>=0?(r=(t.min.y-u.y)*h,a=(t.max.y-u.y)*h):(r=(t.max.y-u.y)*h,a=(t.min.y-u.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),f>=0?(o=(t.min.z-u.z)*f,c=(t.max.z-u.z)*f):(o=(t.max.z-u.z)*f,c=(t.min.z-u.z)*f),n>c||o>s)||((o>n||n!==n)&&(n=o),(c<s||s!==s)&&(s=c),s<0)?null:this.at(n>=0?n:s,e)}intersectsBox(t){return this.intersectBox(t,dn)!==null}intersectTriangle(t,e,n,s,r){Ka.subVectors(e,t),Xs.subVectors(n,t),ja.crossVectors(Ka,Xs);let a=this.direction.dot(ja),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Tn.subVectors(this.origin,t);let c=o*this.direction.dot(Xs.crossVectors(Tn,Xs));if(c<0)return null;let l=o*this.direction.dot(Ka.cross(Tn));if(l<0||c+l>a)return null;let h=-o*Tn.dot(ja);return h<0?null:this.at(h/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},ce=class i{constructor(t,e,n,s,r,a,o,c,l,h,f,u,p,g,_,m){i.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,c,l,h,f,u,p,g,_,m)}set(t,e,n,s,r,a,o,c,l,h,f,u,p,g,_,m){let d=this.elements;return d[0]=t,d[4]=e,d[8]=n,d[12]=s,d[1]=r,d[5]=a,d[9]=o,d[13]=c,d[2]=l,d[6]=h,d[10]=f,d[14]=u,d[3]=p,d[7]=g,d[11]=_,d[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(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){let e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,n=t.elements,s=1/fi.setFromMatrixColumn(t,0).length(),r=1/fi.setFromMatrixColumn(t,1).length(),a=1/fi.setFromMatrixColumn(t,2).length();return e[0]=n[0]*s,e[1]=n[1]*s,e[2]=n[2]*s,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,n=t.x,s=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),f=Math.sin(r);if(t.order==="XYZ"){let u=a*h,p=a*f,g=o*h,_=o*f;e[0]=c*h,e[4]=-c*f,e[8]=l,e[1]=p+g*l,e[5]=u-_*l,e[9]=-o*c,e[2]=_-u*l,e[6]=g+p*l,e[10]=a*c}else if(t.order==="YXZ"){let u=c*h,p=c*f,g=l*h,_=l*f;e[0]=u+_*o,e[4]=g*o-p,e[8]=a*l,e[1]=a*f,e[5]=a*h,e[9]=-o,e[2]=p*o-g,e[6]=_+u*o,e[10]=a*c}else if(t.order==="ZXY"){let u=c*h,p=c*f,g=l*h,_=l*f;e[0]=u-_*o,e[4]=-a*f,e[8]=g+p*o,e[1]=p+g*o,e[5]=a*h,e[9]=_-u*o,e[2]=-a*l,e[6]=o,e[10]=a*c}else if(t.order==="ZYX"){let u=a*h,p=a*f,g=o*h,_=o*f;e[0]=c*h,e[4]=g*l-p,e[8]=u*l+_,e[1]=c*f,e[5]=_*l+u,e[9]=p*l-g,e[2]=-l,e[6]=o*c,e[10]=a*c}else if(t.order==="YZX"){let u=a*c,p=a*l,g=o*c,_=o*l;e[0]=c*h,e[4]=_-u*f,e[8]=g*f+p,e[1]=f,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=p*f+g,e[10]=u-_*f}else if(t.order==="XZY"){let u=a*c,p=a*l,g=o*c,_=o*l;e[0]=c*h,e[4]=-f,e[8]=l*h,e[1]=u*f+_,e[5]=a*h,e[9]=p*f-g,e[2]=g*f-p,e[6]=o*h,e[10]=_*f+u}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose($h,t,Jh)}lookAt(t,e,n){let s=this.elements;return Ue.subVectors(t,e),Ue.lengthSq()===0&&(Ue.z=1),Ue.normalize(),wn.crossVectors(n,Ue),wn.lengthSq()===0&&(Math.abs(n.z)===1?Ue.x+=1e-4:Ue.z+=1e-4,Ue.normalize(),wn.crossVectors(n,Ue)),wn.normalize(),qs.crossVectors(Ue,wn),s[0]=wn.x,s[4]=qs.x,s[8]=Ue.x,s[1]=wn.y,s[5]=qs.y,s[9]=Ue.y,s[2]=wn.z,s[6]=qs.z,s[10]=Ue.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],f=n[5],u=n[9],p=n[13],g=n[2],_=n[6],m=n[10],d=n[14],T=n[3],M=n[7],v=n[11],R=n[15],w=s[0],C=s[4],U=s[8],S=s[12],b=s[1],P=s[5],B=s[9],V=s[13],X=s[2],Z=s[6],W=s[10],et=s[14],k=s[3],rt=s[7],ct=s[11],bt=s[15];return r[0]=a*w+o*b+c*X+l*k,r[4]=a*C+o*P+c*Z+l*rt,r[8]=a*U+o*B+c*W+l*ct,r[12]=a*S+o*V+c*et+l*bt,r[1]=h*w+f*b+u*X+p*k,r[5]=h*C+f*P+u*Z+p*rt,r[9]=h*U+f*B+u*W+p*ct,r[13]=h*S+f*V+u*et+p*bt,r[2]=g*w+_*b+m*X+d*k,r[6]=g*C+_*P+m*Z+d*rt,r[10]=g*U+_*B+m*W+d*ct,r[14]=g*S+_*V+m*et+d*bt,r[3]=T*w+M*b+v*X+R*k,r[7]=T*C+M*P+v*Z+R*rt,r[11]=T*U+M*B+v*W+R*ct,r[15]=T*S+M*V+v*et+R*bt,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[4],s=t[8],r=t[12],a=t[1],o=t[5],c=t[9],l=t[13],h=t[2],f=t[6],u=t[10],p=t[14],g=t[3],_=t[7],m=t[11],d=t[15];return g*(+r*c*f-s*l*f-r*o*u+n*l*u+s*o*p-n*c*p)+_*(+e*c*p-e*l*u+r*a*u-s*a*p+s*l*h-r*c*h)+m*(+e*l*f-e*o*p-r*a*f+n*a*p+r*o*h-n*l*h)+d*(-s*o*h-e*c*f+e*o*u+s*a*f-n*a*u+n*c*h)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){let s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=n),this}invert(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],f=t[9],u=t[10],p=t[11],g=t[12],_=t[13],m=t[14],d=t[15],T=f*m*l-_*u*l+_*c*p-o*m*p-f*c*d+o*u*d,M=g*u*l-h*m*l-g*c*p+a*m*p+h*c*d-a*u*d,v=h*_*l-g*f*l+g*o*p-a*_*p-h*o*d+a*f*d,R=g*f*c-h*_*c-g*o*u+a*_*u+h*o*m-a*f*m,w=e*T+n*M+s*v+r*R;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let C=1/w;return t[0]=T*C,t[1]=(_*u*r-f*m*r-_*s*p+n*m*p+f*s*d-n*u*d)*C,t[2]=(o*m*r-_*c*r+_*s*l-n*m*l-o*s*d+n*c*d)*C,t[3]=(f*c*r-o*u*r-f*s*l+n*u*l+o*s*p-n*c*p)*C,t[4]=M*C,t[5]=(h*m*r-g*u*r+g*s*p-e*m*p-h*s*d+e*u*d)*C,t[6]=(g*c*r-a*m*r-g*s*l+e*m*l+a*s*d-e*c*d)*C,t[7]=(a*u*r-h*c*r+h*s*l-e*u*l-a*s*p+e*c*p)*C,t[8]=v*C,t[9]=(g*f*r-h*_*r-g*n*p+e*_*p+h*n*d-e*f*d)*C,t[10]=(a*_*r-g*o*r+g*n*l-e*_*l-a*n*d+e*o*d)*C,t[11]=(h*o*r-a*f*r-h*n*l+e*f*l+a*n*p-e*o*p)*C,t[12]=R*C,t[13]=(h*_*s-g*f*s+g*n*u-e*_*u-h*n*m+e*f*m)*C,t[14]=(g*o*s-a*_*s-g*n*c+e*_*c+a*n*m-e*o*m)*C,t[15]=(a*f*s-h*o*s+h*n*c-e*f*c-a*n*u+e*o*u)*C,this}scale(t){let e=this.elements,n=t.x,s=t.y,r=t.z;return e[0]*=n,e[4]*=s,e[8]*=r,e[1]*=n,e[5]*=s,e[9]*=r,e[2]*=n,e[6]*=s,e[10]*=r,e[3]*=n,e[7]*=s,e[11]*=r,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,s))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let n=Math.cos(e),s=Math.sin(e),r=1-n,a=t.x,o=t.y,c=t.z,l=r*a,h=r*o;return this.set(l*a+n,l*o-s*c,l*c+s*o,0,l*o+s*c,h*o+n,h*c-s*a,0,l*c-s*o,h*c+s*a,r*c*c+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,s,r,a){return this.set(1,n,r,0,t,1,a,0,e,s,1,0,0,0,0,1),this}compose(t,e,n){let s=this.elements,r=e._x,a=e._y,o=e._z,c=e._w,l=r+r,h=a+a,f=o+o,u=r*l,p=r*h,g=r*f,_=a*h,m=a*f,d=o*f,T=c*l,M=c*h,v=c*f,R=n.x,w=n.y,C=n.z;return s[0]=(1-(_+d))*R,s[1]=(p+v)*R,s[2]=(g-M)*R,s[3]=0,s[4]=(p-v)*w,s[5]=(1-(u+d))*w,s[6]=(m+T)*w,s[7]=0,s[8]=(g+M)*C,s[9]=(m-T)*C,s[10]=(1-(u+_))*C,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,n){let s=this.elements,r=fi.set(s[0],s[1],s[2]).length(),a=fi.set(s[4],s[5],s[6]).length(),o=fi.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),t.x=s[12],t.y=s[13],t.z=s[14],Ze.copy(this);let l=1/r,h=1/a,f=1/o;return Ze.elements[0]*=l,Ze.elements[1]*=l,Ze.elements[2]*=l,Ze.elements[4]*=h,Ze.elements[5]*=h,Ze.elements[6]*=h,Ze.elements[8]*=f,Ze.elements[9]*=f,Ze.elements[10]*=f,e.setFromRotationMatrix(Ze),n.x=r,n.y=a,n.z=o,this}makePerspective(t,e,n,s,r,a,o=Je,c=!1){let l=this.elements,h=2*r/(e-t),f=2*r/(n-s),u=(e+t)/(e-t),p=(n+s)/(n-s),g,_;if(c)g=r/(a-r),_=a*r/(a-r);else if(o===Je)g=-(a+r)/(a-r),_=-2*a*r/(a-r);else if(o===as)g=-a/(a-r),_=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=f,l[9]=p,l[13]=0,l[2]=0,l[6]=0,l[10]=g,l[14]=_,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,s,r,a,o=Je,c=!1){let l=this.elements,h=2/(e-t),f=2/(n-s),u=-(e+t)/(e-t),p=-(n+s)/(n-s),g,_;if(c)g=1/(a-r),_=a/(a-r);else if(o===Je)g=-2/(a-r),_=-(a+r)/(a-r);else if(o===as)g=-1/(a-r),_=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=u,l[1]=0,l[5]=f,l[9]=0,l[13]=p,l[2]=0,l[6]=0,l[10]=g,l[14]=_,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){let e=this.elements,n=t.elements;for(let s=0;s<16;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}},fi=new N,Ze=new ce,$h=new N(0,0,0),Jh=new N(1,1,1),wn=new N,qs=new N,Ue=new N,vl=new ce,Ml=new We,sn=class i{constructor(t=0,e=0,n=0,s=i.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,s=this._order){return this._x=t,this._y=e,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){let s=t.elements,r=s[0],a=s[4],o=s[8],c=s[1],l=s[5],h=s[9],f=s[2],u=s[6],p=s[10];switch(e){case"XYZ":this._y=Math.asin(Ot(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ot(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-f,r),this._z=0);break;case"ZXY":this._x=Math.asin(Ot(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-Ot(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(u,p),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Ot(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-f,r)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Ot(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return vl.makeRotationFromQuaternion(t),this.setFromRotationMatrix(vl,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Ml.setFromEuler(this),this.setFromQuaternion(Ml,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};sn.DEFAULT_ORDER="XYZ";var cs=class{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}},Kh=0,bl=new N,pi=new We,fn=new ce,Ys=new N,Qi=new N,jh=new N,Qh=new We,Sl=new N(1,0,0),El=new N(0,1,0),Tl=new N(0,0,1),wl={type:"added"},tu={type:"removed"},mi={type:"childadded",child:null},Qa={type:"childremoved",child:null},Ce=class i extends tn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Kh++}),this.uuid=Bi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=i.DEFAULT_UP.clone();let t=new N,e=new sn,n=new We,s=new N(1,1,1);function r(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new ce},normalMatrix:{value:new Lt}}),this.matrix=new ce,this.matrixWorld=new ce,this.matrixAutoUpdate=i.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new cs,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return pi.setFromAxisAngle(t,e),this.quaternion.multiply(pi),this}rotateOnWorldAxis(t,e){return pi.setFromAxisAngle(t,e),this.quaternion.premultiply(pi),this}rotateX(t){return this.rotateOnAxis(Sl,t)}rotateY(t){return this.rotateOnAxis(El,t)}rotateZ(t){return this.rotateOnAxis(Tl,t)}translateOnAxis(t,e){return bl.copy(t).applyQuaternion(this.quaternion),this.position.add(bl.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Sl,t)}translateY(t){return this.translateOnAxis(El,t)}translateZ(t){return this.translateOnAxis(Tl,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(fn.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Ys.copy(t):Ys.set(t,e,n);let s=this.parent;this.updateWorldMatrix(!0,!1),Qi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?fn.lookAt(Qi,Ys,this.up):fn.lookAt(Ys,Qi,this.up),this.quaternion.setFromRotationMatrix(fn),s&&(fn.extractRotation(s.matrixWorld),pi.setFromRotationMatrix(fn),this.quaternion.premultiply(pi.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(wl),mi.child=t,this.dispatchEvent(mi),mi.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(tu),Qa.child=t,this.dispatchEvent(Qa),Qa.child=null),this}removeFromParent(){let t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),fn.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),fn.multiply(t.parent.matrixWorld)),t.applyMatrix4(fn),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(wl),mi.child=t,this.dispatchEvent(mi),mi.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,s=this.children.length;n<s;n++){let a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);let s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Qi,t,jh),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Qi,Qh,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);let e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);let e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverseVisible(t)}traverseAncestors(t){let e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);let e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){let n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){let s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].updateWorldMatrix(!1,!0)}}toJSON(t){let e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.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(t),s.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){let f=c[l];r(t.shapes,f)}else r(t.shapes,c)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(r(t.materials,this.material[c]));s.material=o}else s.material=r(t.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){let c=this.animations[o];s.animations.push(r(t.animations,c))}}if(e){let o=a(t.geometries),c=a(t.materials),l=a(t.textures),h=a(t.images),f=a(t.shapes),u=a(t.skeletons),p=a(t.animations),g=a(t.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),f.length>0&&(n.shapes=f),u.length>0&&(n.skeletons=u),p.length>0&&(n.animations=p),g.length>0&&(n.nodes=g)}return n.object=s,n;function a(o){let c=[];for(let l in o){let h=o[l];delete h.metadata,c.push(h)}return c}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){let s=t.children[n];this.add(s.clone())}return this}};Ce.DEFAULT_UP=new N(0,1,0);Ce.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ce.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var $e=new N,pn=new N,to=new N,mn=new N,gi=new N,_i=new N,Al=new N,eo=new N,no=new N,io=new N,so=new oe,ro=new oe,ao=new oe,Cn=class i{constructor(t=new N,e=new N,n=new N){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,s){s.subVectors(n,e),$e.subVectors(t,e),s.cross($e);let r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,n,s,r){$e.subVectors(s,e),pn.subVectors(n,e),to.subVectors(t,e);let a=$e.dot($e),o=$e.dot(pn),c=$e.dot(to),l=pn.dot(pn),h=pn.dot(to),f=a*l-o*o;if(f===0)return r.set(0,0,0),null;let u=1/f,p=(l*c-o*h)*u,g=(a*h-o*c)*u;return r.set(1-p-g,g,p)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,mn)===null?!1:mn.x>=0&&mn.y>=0&&mn.x+mn.y<=1}static getInterpolation(t,e,n,s,r,a,o,c){return this.getBarycoord(t,e,n,s,mn)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,mn.x),c.addScaledVector(a,mn.y),c.addScaledVector(o,mn.z),c)}static getInterpolatedAttribute(t,e,n,s,r,a){return so.setScalar(0),ro.setScalar(0),ao.setScalar(0),so.fromBufferAttribute(t,e),ro.fromBufferAttribute(t,n),ao.fromBufferAttribute(t,s),a.setScalar(0),a.addScaledVector(so,r.x),a.addScaledVector(ro,r.y),a.addScaledVector(ao,r.z),a}static isFrontFacing(t,e,n,s){return $e.subVectors(n,e),pn.subVectors(t,e),$e.cross(pn).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return $e.subVectors(this.c,this.b),pn.subVectors(this.a,this.b),$e.cross(pn).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return i.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return i.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,s,r){return i.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}containsPoint(t){return i.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return i.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,s=this.b,r=this.c,a,o;gi.subVectors(s,n),_i.subVectors(r,n),eo.subVectors(t,n);let c=gi.dot(eo),l=_i.dot(eo);if(c<=0&&l<=0)return e.copy(n);no.subVectors(t,s);let h=gi.dot(no),f=_i.dot(no);if(h>=0&&f<=h)return e.copy(s);let u=c*f-h*l;if(u<=0&&c>=0&&h<=0)return a=c/(c-h),e.copy(n).addScaledVector(gi,a);io.subVectors(t,r);let p=gi.dot(io),g=_i.dot(io);if(g>=0&&p<=g)return e.copy(r);let _=p*l-c*g;if(_<=0&&l>=0&&g<=0)return o=l/(l-g),e.copy(n).addScaledVector(_i,o);let m=h*g-p*f;if(m<=0&&f-h>=0&&p-g>=0)return Al.subVectors(r,s),o=(f-h)/(f-h+(p-g)),e.copy(s).addScaledVector(Al,o);let d=1/(m+_+u);return a=_*d,o=u*d,e.copy(n).addScaledVector(gi,a).addScaledVector(_i,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},Cc={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},An={h:0,s:0,l:0},Zs={h:0,s:0,l:0};function oo(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}var zt=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){let s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Fe){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Vt.colorSpaceToWorking(this,e),this}setRGB(t,e,n,s=Vt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Vt.colorSpaceToWorking(this,s),this}setHSL(t,e,n,s=Vt.workingColorSpace){if(t=Fo(t,1),e=Ot(e,0,1),n=Ot(n,0,1),e===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=oo(a,r,t+1/3),this.g=oo(a,r,t),this.b=oo(a,r,t-1/3)}return Vt.colorSpaceToWorking(this,s),this}setStyle(t,e=Fe){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){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,e);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,e);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,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){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,e);if(a===6)return this.setHex(parseInt(r,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Fe){let n=Cc[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=gn(t.r),this.g=gn(t.g),this.b=gn(t.b),this}copyLinearToSRGB(t){return this.r=bi(t.r),this.g=bi(t.g),this.b=bi(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Fe){return Vt.workingToColorSpace(xe.copy(this),t),Math.round(Ot(xe.r*255,0,255))*65536+Math.round(Ot(xe.g*255,0,255))*256+Math.round(Ot(xe.b*255,0,255))}getHexString(t=Fe){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Vt.workingColorSpace){Vt.workingToColorSpace(xe.copy(this),e);let n=xe.r,s=xe.g,r=xe.b,a=Math.max(n,s,r),o=Math.min(n,s,r),c,l,h=(o+a)/2;if(o===a)c=0,l=0;else{let f=a-o;switch(l=h<=.5?f/(a+o):f/(2-a-o),a){case n:c=(s-r)/f+(s<r?6:0);break;case s:c=(r-n)/f+2;break;case r:c=(n-s)/f+4;break}c/=6}return t.h=c,t.s=l,t.l=h,t}getRGB(t,e=Vt.workingColorSpace){return Vt.workingToColorSpace(xe.copy(this),e),t.r=xe.r,t.g=xe.g,t.b=xe.b,t}getStyle(t=Fe){Vt.workingToColorSpace(xe.copy(this),t);let e=xe.r,n=xe.g,s=xe.b;return t!==Fe?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(t,e,n){return this.getHSL(An),this.setHSL(An.h+t,An.s+e,An.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(An),t.getHSL(Zs);let n=is(An.h,Zs.h,e),s=is(An.s,Zs.s,e),r=is(An.l,Zs.l,e);return this.setHSL(n,s,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){let e=this.r,n=this.g,s=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*s,this.g=r[1]*e+r[4]*n+r[7]*s,this.b=r[2]*e+r[5]*n+r[8]*s,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},xe=new zt;zt.NAMES=Cc;var eu=0,yn=class extends tn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:eu++}),this.uuid=Bi(),this.name="",this.type="Material",this.blending=xn,this.side=_n,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=hr,this.blendDst=ur,this.blendEquation=In,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new zt(0,0,0),this.blendAlpha=0,this.depthFunc=Zn,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=go,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=qn,this.stencilZFail=qn,this.stencilZPass=qn,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(let e in t){let n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={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(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).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(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).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(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).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(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).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!==xn&&(n.blending=this.blending),this.side!==_n&&(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!==hr&&(n.blendSrc=this.blendSrc),this.blendDst!==ur&&(n.blendDst=this.blendDst),this.blendEquation!==In&&(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!==Zn&&(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!==go&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==qn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==qn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==qn&&(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.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 c=r[o];delete c.metadata,a.push(c)}return a}if(e){let r=s(t.textures),a=s(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,n=null;if(e!==null){let s=e.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}},Jn=class extends yn{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new zt(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 sn,this.combine=Eo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}};var he=new N,$s=new Ut,nu=0,ae=class{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:nu++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=_o,this.updateRanges=[],this.gpuType=on,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[t+s]=e.array[n+s];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)$s.fromBufferAttribute(this,e),$s.applyMatrix3(t),this.setXY(e,$s.x,$s.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)he.fromBufferAttribute(this,e),he.applyMatrix3(t),this.setXYZ(e,he.x,he.y,he.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)he.fromBufferAttribute(this,e),he.applyMatrix4(t),this.setXYZ(e,he.x,he.y,he.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)he.fromBufferAttribute(this,e),he.applyNormalMatrix(t),this.setXYZ(e,he.x,he.y,he.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)he.fromBufferAttribute(this,e),he.transformDirection(t),this.setXYZ(e,he.x,he.y,he.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=Mi(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=be(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Mi(e,this.array)),e}setX(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Mi(e,this.array)),e}setY(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Mi(e,this.array)),e}setZ(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Mi(e,this.array)),e}setW(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=be(e,this.array),n=be(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,s){return t*=this.itemSize,this.normalized&&(e=be(e,this.array),n=be(n,this.array),s=be(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this}setXYZW(t,e,n,s,r){return t*=this.itemSize,this.normalized&&(e=be(e,this.array),n=be(n,this.array),s=be(s,this.array),r=be(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==_o&&(t.usage=this.usage),t}};var hs=class extends ae{constructor(t,e,n){super(new Uint16Array(t),e,n)}};var us=class extends ae{constructor(t,e,n){super(new Uint32Array(t),e,n)}};var Ae=class extends ae{constructor(t,e,n){super(new Float32Array(t),e,n)}},iu=0,He=new ce,lo=new Ce,xi=new N,Ne=new nn,ts=new nn,me=new N,ye=class i extends tn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:iu++}),this.uuid=Bi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(Bo(t)?us:hs)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new Lt().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return He.makeRotationFromQuaternion(t),this.applyMatrix4(He),this}rotateX(t){return He.makeRotationX(t),this.applyMatrix4(He),this}rotateY(t){return He.makeRotationY(t),this.applyMatrix4(He),this}rotateZ(t){return He.makeRotationZ(t),this.applyMatrix4(He),this}translate(t,e,n){return He.makeTranslation(t,e,n),this.applyMatrix4(He),this}scale(t,e,n){return He.makeScale(t,e,n),this.applyMatrix4(He),this}lookAt(t){return lo.lookAt(t),lo.updateMatrix(),this.applyMatrix4(lo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(xi).negate(),this.translate(xi.x,xi.y,xi.z),this}setFromPoints(t){let e=this.getAttribute("position");if(e===void 0){let n=[];for(let s=0,r=t.length;s<r;s++){let a=t[s];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Ae(n,3))}else{let n=Math.min(t.length,e.count);for(let s=0;s<n;s++){let r=t[s];e.setXYZ(s,r.x,r.y,r.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new nn);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new N(-1/0,-1/0,-1/0),new N(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,s=e.length;n<s;n++){let r=e[n];Ne.setFromBufferAttribute(r),this.morphTargetsRelative?(me.addVectors(this.boundingBox.min,Ne.min),this.boundingBox.expandByPoint(me),me.addVectors(this.boundingBox.max,Ne.max),this.boundingBox.expandByPoint(me)):(this.boundingBox.expandByPoint(Ne.min),this.boundingBox.expandByPoint(Ne.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ln);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new N,1/0);return}if(t){let n=this.boundingSphere.center;if(Ne.setFromBufferAttribute(t),e)for(let r=0,a=e.length;r<a;r++){let o=e[r];ts.setFromBufferAttribute(o),this.morphTargetsRelative?(me.addVectors(Ne.min,ts.min),Ne.expandByPoint(me),me.addVectors(Ne.max,ts.max),Ne.expandByPoint(me)):(Ne.expandByPoint(ts.min),Ne.expandByPoint(ts.max))}Ne.getCenter(n);let s=0;for(let r=0,a=t.count;r<a;r++)me.fromBufferAttribute(t,r),s=Math.max(s,n.distanceToSquared(me));if(e)for(let r=0,a=e.length;r<a;r++){let o=e[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)me.fromBufferAttribute(o,l),c&&(xi.fromBufferAttribute(t,l),me.add(xi)),s=Math.max(s,n.distanceToSquared(me))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=e.position,s=e.normal,r=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ae(new Float32Array(4*n.count),4));let a=this.getAttribute("tangent"),o=[],c=[];for(let U=0;U<n.count;U++)o[U]=new N,c[U]=new N;let l=new N,h=new N,f=new N,u=new Ut,p=new Ut,g=new Ut,_=new N,m=new N;function d(U,S,b){l.fromBufferAttribute(n,U),h.fromBufferAttribute(n,S),f.fromBufferAttribute(n,b),u.fromBufferAttribute(r,U),p.fromBufferAttribute(r,S),g.fromBufferAttribute(r,b),h.sub(l),f.sub(l),p.sub(u),g.sub(u);let P=1/(p.x*g.y-g.x*p.y);isFinite(P)&&(_.copy(h).multiplyScalar(g.y).addScaledVector(f,-p.y).multiplyScalar(P),m.copy(f).multiplyScalar(p.x).addScaledVector(h,-g.x).multiplyScalar(P),o[U].add(_),o[S].add(_),o[b].add(_),c[U].add(m),c[S].add(m),c[b].add(m))}let T=this.groups;T.length===0&&(T=[{start:0,count:t.count}]);for(let U=0,S=T.length;U<S;++U){let b=T[U],P=b.start,B=b.count;for(let V=P,X=P+B;V<X;V+=3)d(t.getX(V+0),t.getX(V+1),t.getX(V+2))}let M=new N,v=new N,R=new N,w=new N;function C(U){R.fromBufferAttribute(s,U),w.copy(R);let S=o[U];M.copy(S),M.sub(R.multiplyScalar(R.dot(S))).normalize(),v.crossVectors(w,S);let P=v.dot(c[U])<0?-1:1;a.setXYZW(U,M.x,M.y,M.z,P)}for(let U=0,S=T.length;U<S;++U){let b=T[U],P=b.start,B=b.count;for(let V=P,X=P+B;V<X;V+=3)C(t.getX(V+0)),C(t.getX(V+1)),C(t.getX(V+2))}}computeVertexNormals(){let t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new ae(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let u=0,p=n.count;u<p;u++)n.setXYZ(u,0,0,0);let s=new N,r=new N,a=new N,o=new N,c=new N,l=new N,h=new N,f=new N;if(t)for(let u=0,p=t.count;u<p;u+=3){let g=t.getX(u+0),_=t.getX(u+1),m=t.getX(u+2);s.fromBufferAttribute(e,g),r.fromBufferAttribute(e,_),a.fromBufferAttribute(e,m),h.subVectors(a,r),f.subVectors(s,r),h.cross(f),o.fromBufferAttribute(n,g),c.fromBufferAttribute(n,_),l.fromBufferAttribute(n,m),o.add(h),c.add(h),l.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(_,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let u=0,p=e.count;u<p;u+=3)s.fromBufferAttribute(e,u+0),r.fromBufferAttribute(e,u+1),a.fromBufferAttribute(e,u+2),h.subVectors(a,r),f.subVectors(s,r),h.cross(f),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 t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)me.fromBufferAttribute(t,e),me.normalize(),t.setXYZ(e,me.x,me.y,me.z)}toNonIndexed(){function t(o,c){let l=o.array,h=o.itemSize,f=o.normalized,u=new l.constructor(c.length*h),p=0,g=0;for(let _=0,m=c.length;_<m;_++){o.isInterleavedBufferAttribute?p=c[_]*o.data.stride+o.offset:p=c[_]*h;for(let d=0;d<h;d++)u[g++]=l[p++]}return new ae(u,h,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let e=new i,n=this.index.array,s=this.attributes;for(let o in s){let c=s[o],l=t(c,n);e.setAttribute(o,l)}let r=this.morphAttributes;for(let o in r){let c=[],l=r[o];for(let h=0,f=l.length;h<f;h++){let u=l[h],p=t(u,n);c.push(p)}e.morphAttributes[o]=c}e.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let o=0,c=a.length;o<c;o++){let l=a[o];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){let t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let n=this.attributes;for(let c in n){let l=n[c];t.data.attributes[c]=l.toJSON(t.data)}let s={},r=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],h=[];for(let f=0,u=l.length;f<u;f++){let p=l[f];h.push(p.toJSON(t.data))}h.length>0&&(s[c]=h,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let n=t.index;n!==null&&this.setIndex(n.clone());let s=t.attributes;for(let l in s){let h=s[l];this.setAttribute(l,h.clone(e))}let r=t.morphAttributes;for(let l in r){let h=[],f=r[l];for(let u=0,p=f.length;u<p;u++)h.push(f[u].clone(e));this.morphAttributes[l]=h}this.morphTargetsRelative=t.morphTargetsRelative;let a=t.groups;for(let l=0,h=a.length;l<h;l++){let f=a[l];this.addGroup(f.start,f.count,f.materialIndex)}let o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());let c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},Rl=new ce,Wn=new Dn,Js=new Ln,Cl=new N,Ks=new N,js=new N,Qs=new N,co=new N,tr=new N,Pl=new N,er=new N,Pe=class extends Ce{constructor(t=new ye,e=new Jn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let s=e[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(t,e){let n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(s,t);let o=this.morphTargetInfluences;if(r&&o){tr.set(0,0,0);for(let c=0,l=r.length;c<l;c++){let h=o[c],f=r[c];h!==0&&(co.fromBufferAttribute(f,t),a?tr.addScaledVector(co,h):tr.addScaledVector(co.sub(e),h))}e.add(tr)}return e}raycast(t,e){let n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Js.copy(n.boundingSphere),Js.applyMatrix4(r),Wn.copy(t.ray).recast(t.near),!(Js.containsPoint(Wn.origin)===!1&&(Wn.intersectSphere(Js,Cl)===null||Wn.origin.distanceToSquared(Cl)>(t.far-t.near)**2))&&(Rl.copy(r).invert(),Wn.copy(t.ray).applyMatrix4(Rl),!(n.boundingBox!==null&&Wn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Wn)))}_computeIntersections(t,e,n){let s,r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,f=r.attributes.normal,u=r.groups,p=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,_=u.length;g<_;g++){let m=u[g],d=a[m.materialIndex],T=Math.max(m.start,p.start),M=Math.min(o.count,Math.min(m.start+m.count,p.start+p.count));for(let v=T,R=M;v<R;v+=3){let w=o.getX(v),C=o.getX(v+1),U=o.getX(v+2);s=nr(this,d,t,n,l,h,f,w,C,U),s&&(s.faceIndex=Math.floor(v/3),s.face.materialIndex=m.materialIndex,e.push(s))}}else{let g=Math.max(0,p.start),_=Math.min(o.count,p.start+p.count);for(let m=g,d=_;m<d;m+=3){let T=o.getX(m),M=o.getX(m+1),v=o.getX(m+2);s=nr(this,a,t,n,l,h,f,T,M,v),s&&(s.faceIndex=Math.floor(m/3),e.push(s))}}else if(c!==void 0)if(Array.isArray(a))for(let g=0,_=u.length;g<_;g++){let m=u[g],d=a[m.materialIndex],T=Math.max(m.start,p.start),M=Math.min(c.count,Math.min(m.start+m.count,p.start+p.count));for(let v=T,R=M;v<R;v+=3){let w=v,C=v+1,U=v+2;s=nr(this,d,t,n,l,h,f,w,C,U),s&&(s.faceIndex=Math.floor(v/3),s.face.materialIndex=m.materialIndex,e.push(s))}}else{let g=Math.max(0,p.start),_=Math.min(c.count,p.start+p.count);for(let m=g,d=_;m<d;m+=3){let T=m,M=m+1,v=m+2;s=nr(this,a,t,n,l,h,f,T,M,v),s&&(s.faceIndex=Math.floor(m/3),e.push(s))}}}};function su(i,t,e,n,s,r,a,o){let c;if(t.side===Ee?c=n.intersectTriangle(a,r,s,!0,o):c=n.intersectTriangle(s,r,a,t.side===_n,o),c===null)return null;er.copy(o),er.applyMatrix4(i.matrixWorld);let l=e.ray.origin.distanceTo(er);return l<e.near||l>e.far?null:{distance:l,point:er.clone(),object:i}}function nr(i,t,e,n,s,r,a,o,c,l){i.getVertexPosition(o,Ks),i.getVertexPosition(c,js),i.getVertexPosition(l,Qs);let h=su(i,t,e,n,Ks,js,Qs,Pl);if(h){let f=new N;Cn.getBarycoord(Pl,Ks,js,Qs,f),s&&(h.uv=Cn.getInterpolatedAttribute(s,o,c,l,f,new Ut)),r&&(h.uv1=Cn.getInterpolatedAttribute(r,o,c,l,f,new Ut)),a&&(h.normal=Cn.getInterpolatedAttribute(a,o,c,l,f,new N),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let u={a:o,b:c,c:l,normal:new N,materialIndex:0};Cn.getNormal(Ks,js,Qs,u.normal),h.face=u,h.barycoord=f}return h}var Ai=class i extends ye{constructor(t=1,e=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};let o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);let c=[],l=[],h=[],f=[],u=0,p=0;g("z","y","x",-1,-1,n,e,t,a,r,0),g("z","y","x",1,-1,n,e,-t,a,r,1),g("x","z","y",1,1,t,n,e,s,a,2),g("x","z","y",1,-1,t,n,-e,s,a,3),g("x","y","z",1,-1,t,e,n,s,r,4),g("x","y","z",-1,-1,t,e,-n,s,r,5),this.setIndex(c),this.setAttribute("position",new Ae(l,3)),this.setAttribute("normal",new Ae(h,3)),this.setAttribute("uv",new Ae(f,2));function g(_,m,d,T,M,v,R,w,C,U,S){let b=v/C,P=R/U,B=v/2,V=R/2,X=w/2,Z=C+1,W=U+1,et=0,k=0,rt=new N;for(let ct=0;ct<W;ct++){let bt=ct*P-V;for(let Bt=0;Bt<Z;Bt++){let Jt=Bt*b-B;rt[_]=Jt*T,rt[m]=bt*M,rt[d]=X,l.push(rt.x,rt.y,rt.z),rt[_]=0,rt[m]=0,rt[d]=w>0?1:-1,h.push(rt.x,rt.y,rt.z),f.push(Bt/C),f.push(1-ct/U),et+=1}}for(let ct=0;ct<U;ct++)for(let bt=0;bt<C;bt++){let Bt=u+bt+Z*ct,Jt=u+bt+Z*(ct+1),te=u+(bt+1)+Z*(ct+1),Wt=u+(bt+1)+Z*ct;c.push(Bt,Jt,Wt),c.push(Jt,te,Wt),k+=6}o.addGroup(p,k,S),p+=k,u+=et}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new i(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}};function ti(i){let t={};for(let e in i){t[e]={};for(let n in i[e]){let s=i[e][n];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=s.clone():Array.isArray(s)?t[e][n]=s.slice():t[e][n]=s}}return t}function ve(i){let t={};for(let e=0;e<i.length;e++){let n=ti(i[e]);for(let s in n)t[s]=n[s]}return t}function ru(i){let t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function zo(i){let t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Vt.workingColorSpace}var Pc={clone:ti,merge:ve},au=`void main() {
1
+ /*! TyCHO runtime 0.2.0, Apache-2.0, https://github.com/beeson-group/tycho
2
+ * This bundle contains:
3
+ * mp4-muxer 5.2.2, MIT, Copyright 2023 Vanilagy, https://github.com/Vanilagy/mp4-muxer
4
+ * three 0.180.0, MIT, Copyright 2010-2025 three.js authors, https://github.com/mrdoob/three.js
5
+ * Full license texts: https://github.com/beeson-group/tycho/blob/main/THIRD_PARTY_NOTICES.md */
6
+ "use strict";var tycho=(()=>{var gc=Object.defineProperty;var Cm=Object.getOwnPropertyDescriptor;var Rm=Object.getOwnPropertyNames;var Pm=Object.prototype.hasOwnProperty;var Im=(n,e)=>{for(var t in e)gc(n,t,{get:e[t],enumerable:!0})},Lm=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Rm(e))!Pm.call(n,r)&&r!==t&&gc(n,r,{get:()=>e[r],enumerable:!(i=Cm(e,r))||i.enumerable});return n};var Dm=n=>Lm(gc({},"__esModule",{value:!0}),n);var zS={};Im(zS,{Container:()=>_r,DATA_VERSION:()=>vr,EXPORT_LIMITS:()=>vs,SCENE_MAJOR:()=>Fi,SCENE_MINOR:()=>Ms,TychoError:()=>tn,TychoViewerElement:()=>wa,colormap:()=>Hi,colormapCss:()=>Ku,decodeEmbedded:()=>Ta,define:()=>fc,evaluate:()=>Ju,exportVideo:()=>BS,formatNumber:()=>rn,sizePreset:()=>xa,validate:()=>Oa});var tn=class extends Error{rule;constructor(e,t){super(`[${e}] ${t}`),this.name="TychoError",this.rule=e}};function I(n,e){throw new tn(n,e)}var vr=1,km=[84,89,67,68],Ss=12,Ou={raw:new Set(["dtype","shape","encoding","offset","length"]),"shuffle-delta-deflate":new Set(["dtype","shape","encoding","chunk_rows","chunks"])},br={int8:Int8Array,uint8:Uint8Array,int16:Int16Array,uint16:Uint16Array,int32:Int32Array,uint32:Uint32Array,float32:Float32Array,float64:Float64Array},Uu=new Uint8Array(new Uint16Array([1]).buffer)[0]===1;function Nm(n){return typeof n=="string"&&Object.hasOwn(br,n)}function xr(n){return br[n].BYTES_PER_ELEMENT}var ws=n=>Number.isSafeInteger(n)&&n>=0,yc=n=>n!==null&&typeof n=="object"&&!Array.isArray(n);function Om(n,e,t,i){let r=new br[i](t),s=xr(i),a={int8:o=>n.getInt8(o),uint8:o=>n.getUint8(o),int16:o=>n.getInt16(o,!0),uint16:o=>n.getUint16(o,!0),int32:o=>n.getInt32(o,!0),uint32:o=>n.getUint32(o,!0),float32:o=>n.getFloat32(o,!0),float64:o=>n.getFloat64(o,!0)}[i];for(let o=0;o<t;o++)r[o]=a(e+o*s);return r}async function Um(n,e,t){let i=e.length,r=new DecompressionStream("deflate"),s=r.writable.getWriter();s.write(n).catch(()=>{}),s.close().catch(()=>{});let a=r.readable.getReader(),o=0;try{for(;;){let{done:l,value:c}=await a.read();if(l)break;o+c.length>i&&(a.cancel().catch(()=>{}),I("D5",`${t} inflates to more than the ${i} bytes of its rows`)),e.set(c,o),o+=c.length}}catch(l){if(l instanceof tn)throw l;let c=l.message;I("D5",`${t} does not inflate${c?`: ${c}`:""}`)}o!==i&&I("D5",`${t} inflates to ${o} bytes, not the ${i} of its rows`)}function Fm(n,e,t,i,r,s){let a=e*t;if(i===1){let o=new Uint8Array(r,s,a);o.set(n.subarray(0,Math.min(t,a)));for(let l=t;l<a;l++)o[l]=n[l]+o[l-t]}else if(i===2){let o=new Uint16Array(r,s,a);for(let l=0;l<a;l++){let c=n[l]|n[a+l]<<8;o[l]=l<t?c:c+o[l-t]}}else if(i===4){let o=new Uint32Array(r,s,a),l=2*a,c=3*a;for(let h=0;h<a;h++){let u=(n[h]|n[a+h]<<8|n[l+h]<<16|n[c+h]<<24)>>>0;o[h]=h<t?u:u+o[h-t]}}else{let o=new Uint32Array(r,s,2*a),l=Uu?0:1,c=1-l;for(let h=0;h<a;h++){let u=(n[h]|n[a+h]<<8|n[2*a+h]<<16|n[3*a+h]<<24)>>>0,d=(n[4*a+h]|n[5*a+h]<<8|n[6*a+h]<<16|n[7*a+h]<<24)>>>0;if(h>=t){let f=2*(h-t);u+=o[f+l],d+=o[f+c]+(u>4294967295?1:0)}o[2*h+l]=u,o[2*h+c]=d}}}function Bm(n){return Math.min(n.chunk_rows,n.shape[0])*n.shape.slice(1).reduce((e,t)=>e*t,1)*xr(n.dtype)}async function zm(n,e,t,i){let r=xr(e.dtype),s=e.shape[0],a=e.shape.slice(1).reduce((l,c)=>l*c,1),o=new ArrayBuffer(s*a*r);for(let[l,[c,h]]of e.chunks.entries()){let u=l*e.chunk_rows,d=Math.min(e.chunk_rows,s-u),f=i.subarray(0,d*a*r);await Um(t.subarray(c,c+h),f,`chunk ${l} of view ${n}`),Fm(f,d,a,r,o,u*a*r)}return new br[e.dtype](o,0,s*a)}function Vm(n,e,t){yc(e)||I("1",`view ${n} is not an object`);let i=typeof e.encoding=="string"&&Object.hasOwn(Ou,e.encoding)?Ou[e.encoding]:null;i===null&&I("D2",`view ${n} has encoding ${JSON.stringify(e.encoding)}, which this reader does not know`);let r=Object.keys(e).filter(h=>!i.has(h));r.length>0&&I("D2",`view ${n} has keys ${r.sort().join(", ")} that this reader does not know`);let s=[...i].filter(h=>!Object.hasOwn(e,h));s.length>0&&I("D2",`view ${n} lacks the keys ${s.join(", ")}`),Nm(e.dtype)||I("D1",`view ${n} has dtype ${JSON.stringify(e.dtype)}, not one of ${Object.keys(br).join(", ")}`);let a=e.shape;(!Array.isArray(a)||a.length===0||!a.every(ws))&&I("D2",`view ${n} has shape ${JSON.stringify(a)}, not a nonempty list of counts`);let o=a.reduce((h,u)=>h*u,1)*xr(e.dtype);if(Number.isSafeInteger(o)||I("D2",`view ${n} has shape [${a.join(", ")}], which is too large`),e.encoding==="raw"){(!ws(e.offset)||!ws(e.length))&&I("D2",`view ${n} has an offset or a length that is not a count`),e.offset%8!==0&&I("D2",`view ${n} starts at byte ${e.offset}, which is not a multiple of 8`),e.length!==o&&I("D2",`view ${n} has length ${e.length}, while shape [${a.join(", ")}] of ${e.dtype} takes ${o} bytes`),e.offset+e.length>t&&I("D2",`view ${n} runs past the end of the file, at bytes ${e.offset} to ${e.offset+e.length} of the payload`);return}let l=e.chunk_rows;(!ws(l)||l<1)&&I("D5",`view ${n} has chunk_rows ${JSON.stringify(l)}, not a positive integer`),Array.isArray(e.chunks)||I("D5",`the chunks of view ${n} are not a list`);let c=Math.ceil(a[0]/l);e.chunks.length!==c&&I("D5",`view ${n} has ${e.chunks.length} chunks, while ${a[0]} rows in chunks of ${l} take ${c}`),e.chunks.forEach((h,u)=>{(!Array.isArray(h)||h.length!==2||!h.every(ws))&&I("D5",`chunk ${u} of view ${n} is not an [offset, length] pair of counts`),h[0]+h[1]>t&&I("D5",`chunk ${u} of view ${n} runs past the end of the file`)})}var _r=class n{header;bytes;payloadStart;cache=new Map;constructor(e,t,i){this.header=e,this.bytes=t,this.payloadStart=i}static async parse(e){let t=ArrayBuffer.isView(e)?new DataView(e.buffer,e.byteOffset,e.byteLength):new DataView(e),i=t.byteLength;(i<Ss||km.some((u,d)=>t.getUint8(d)!==u))&&I("1",'the bytes are not a TyCHO data container, since they lack the 12-byte preamble that starts with the magic "TYCD"');let r=t.getUint32(4,!0);r!==vr&&I("D3",`data container version ${r} is not supported, since this reader reads only version ${vr}`);let s=t.getUint32(8,!0);Ss+s>i&&I("1",`the header length ${s} runs past the end of the file`);let a;try{let u=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode(new Uint8Array(t.buffer,t.byteOffset+Ss,s));a=JSON.parse(u)}catch(u){I("1",`the header is not JSON: ${u.message}`)}(a===null||typeof a!="object")&&I("1","the header is not a JSON object"),a.format!=="tycho-data"&&I("1",`header format is ${JSON.stringify(a.format)}, not "tycho-data"`),a.version!==vr&&I("D3",`header version ${JSON.stringify(a.version)} is not supported, since this reader reads only version ${vr}`),a.generator!==void 0&&typeof a.generator!="string"&&I("1","the header generator is not a string"),a.meta!==void 0&&!yc(a.meta)&&I("1","the header meta is not an object"),yc(a.views)||I("1",'the header lacks a "views" object');let o=Ss+s+(8-(Ss+s)%8)%8,l=Math.max(0,i-o);for(let[u,d]of Object.entries(a.views))Vm(u,d,l);let c=new n(a,t,o),h=Object.entries(a.views).filter(u=>u[1].encoding==="shuffle-delta-deflate");if(h.length>0){typeof DecompressionStream>"u"&&I("D5","this runtime lacks DecompressionStream, which encoded views need");let u=new Uint8Array(t.buffer,t.byteOffset+o,l),d=new Uint8Array(Math.max(...h.map(([,f])=>Bm(f))));for(let[f,g]of h){let y=await zm(f,g,u,d);c.cache.set(f,{name:f,dtype:g.dtype,shape:[...g.shape],data:y})}}return c}has(e){return Object.hasOwn(this.header.views,e)}names(){return Object.keys(this.header.views)}view(e){let t=this.cache.get(e);if(t)return t;this.has(e)||I("2.1",`the data container lacks view ${JSON.stringify(e)}`);let i=this.header.views[e],r=i.length/xr(i.dtype),s=this.bytes.byteOffset+this.payloadStart+i.offset,a=Uu&&s%xr(i.dtype)===0?new br[i.dtype](this.bytes.buffer,s,r):Om(this.bytes,this.payloadStart+i.offset,r,i.dtype),o={name:e,dtype:i.dtype,shape:[...i.shape],data:a};return this.cache.set(e,o),o}};function Hm(n){let e=atob(n.replace(/\s+/g,"")),t=new Uint8Array(new ArrayBuffer(e.length));for(let i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t}function Ta(n,e="base64"){return e!=="base64"&&I("1",`data encoding ${e} is not base64`),Hm(n)}var Fi=0,Ms=2,Fu=new Set,Bu=new Set(["format","version","requires","generator","title","theme","frames","bodies","track_sets","variables","clock","views","controls","readouts","initial"]),Aa=/^[A-Za-z0-9_.-]+$/,yt="@index";function zu(n,e){return Number.isInteger(e)||I("2.6",`the frame index ${String(e)} is not an integer`),(!Number.isInteger(n)||n<1)&&I("2.6",`the clock has steps ${String(n)}, not a count of at least one`),(e%n+n)%n/n}var Bi=class{m;c0;c1;u;constructor(e,t,i){let r=e.count(t);if(this.m=r,this.u=new Float64Array(r),i===yt){this.c0=0,this.c1=r-1;for(let l=0;l<r;l++)this.u[l]=l/(r-1);return}let s=e.channel(i,"C5"),a=e.start(t);this.c0=s[a],this.c1=s[a+r-1];let o=Math.sign(s[a+1]-s[a]);for(let l=0;l<r;l++)(!Number.isFinite(s[a+l])||l>0&&!((s[a+l]-s[a+l-1])*o>0))&&I("T3",`clock channel ${i} of track set ${e.id} is not both finite and strictly monotone along track ${t}`);Number.isFinite(this.c1-this.c0)||I("T3",`clock channel ${i} of track set ${e.id} has an infinite span along track ${t}`);for(let l=0;l<r;l++)this.u[l]=(s[a+l]-this.c0)/(this.c1-this.c0)}at(e){return this.u[e]}reading(e,t){if(e.mode==="fraction")return t;e.range===void 0&&I("C2","the clock is in value mode but does not have a range of two numbers");let[i,r]=e.range;return(i+t*(r-i)-this.c0)/(this.c1-this.c0)}locate(e){let t=0,i=this.m-2;for(;t<i;){let s=t+i+1>>1;this.u[s]<=e?t=s:i=s-1}let r=t;return{k:r,w:(e-this.u[r])/(this.u[r+1]-this.u[r])}}};function Zt(n){return n.laps===void 0?1:(n.mode==="value"&&I("C6","the clock is in value mode but has laps"),(!Number.isInteger(n.laps)||n.laps<1)&&I("C6",`the clock has laps ${String(n.laps)}, not an integer of at least one`),n.laps)}function nn(n,e){let t=Math.min(Math.floor(n),e-1);return{lap:t,u:n-t}}function fi(n,e="clamp",t="clamp"){return n<0?e==="hidden"?null:0:n>1?t==="hidden"?null:1:n}function Sr(n,e){return typeof n=="number"?(Number.isFinite(n)||I("S4",`a scalar is ${n}, not finite`),n):((n===null||typeof n!="object")&&I("2.2",`${JSON.stringify(n)} is not a scalar`),"attr"in n?(n.factor??1)*e.set.attr(n.attr)+(n.offset??0):(n.channel===yt&&I("2.2",`${yt} is not allowed in a frame edge`),e.set.channelAt(n.channel,e.track,e.sample,e.shifted,e.lap??0)))}function vc(n,e){(!Array.isArray(n)||n.length!==3)&&I("F2",`${e} is three scalars, not ${JSON.stringify(n)}`);for(let t of n)t!==null&&typeof t=="object"&&"channel"in t&&I("F2",`${e} takes a number or an attribute, not a channel`);return n}function Vu(n,e,t,i){let r=Math.cos(t),s=i?-Math.sin(t):Math.sin(t),[a,o,l]=n;return e==="z"?[r*a-s*o,s*a+r*o,l]:e==="x"?[a,r*o-s*l,s*o+r*l]:[r*a+s*l,o,-s*a+r*l]}var xc=class{frames;depth=new Map;paths=new Map;root;constructor(e){this.frames=e;let t=Object.keys(e),i=t.filter(s=>e[s].parent===void 0);i.length!==1&&I("2.3",`the frames have ${i.length} roots, not one: ${JSON.stringify(i)}`),this.root=i[0];let r=e[this.root];(r.origin!==void 0||r.rotation!==void 0||r.scale!==void 0)&&I("2.3",`the root frame ${this.root} has an origin, a rotation, or a scale`);for(let s of t){let a=e[s].scale;(a===0||a!==void 0&&typeof a=="object"&&"attr"in a&&(a.factor??1)===0&&(a.offset??0)===0)&&I("F2",`the scale of frame ${s} is zero`)}for(let s of t){let a=0;for(let o=s;o!==this.root;a++){let l=e[o].parent;(l===void 0||!Object.hasOwn(e,l))&&I("2.3",`the parent ${l} of frame ${o} is not declared`),a>t.length&&I("2.3",`the parents of frame ${s} form a cycle`),o=l}this.depth.set(s,a)}}has(e){return this.depth.has(e)}frame(e){return this.has(e)||I("2.3",`frame ${JSON.stringify(e)} is not declared`),this.frames[e]}inSubtree(e,t){for(let i=e;i!==void 0;i=this.frames[i].parent)if(i===t)return!0;return!1}path(e,t){let i=this.paths.get(e),r=i?.get(t);if(r!==void 0)return r;this.frame(e),this.frame(t);let s=[],a=[],o=e,l=t;for(;this.depth.get(o)>this.depth.get(l);)s.push(o),o=this.frames[o].parent;for(;this.depth.get(l)>this.depth.get(o);)a.push(l),l=this.frames[l].parent;for(;o!==l;)s.push(o),a.push(l),o=this.frames[o].parent,l=this.frames[l].parent;let c={up:s,down:a.reverse()};return i===void 0&&this.paths.set(e,i=new Map),i.set(t,c),c}},Ca=(n,e)=>{n===void 0||typeof n=="number"||("attr"in n?e.attrs.add(n.attr):e.channels.add(n.channel))},pi=class{tree;scene;active=new Set;edges=new Map;bodies=new Map;constructor(e){this.scene=e,this.tree=new xc(e.frames);for(let t of Object.keys(e.frames))this.requirements(t,this.tree.root)}body(e){let t=this.bodies.get(e);if(t!==void 0)return t;let i=this.scene.bodies??{};Object.hasOwn(i,e)||I("2.4",`body ${JSON.stringify(e)} is not declared`);let r=i[e];return Object.hasOwn(this.scene.frames,r.frame)||I("2.4",`body ${e} is in frame ${JSON.stringify(r.frame)}, which is not declared`),vc(r.position,`the position of body ${e}`),this.bodies.set(e,r),r}edgeOf(e){let t=this.edges.get(e);if(t===void 0){let i=this.tree.frame(e),r=Array.isArray(i.origin)?vc(i.origin,`the origin of frame ${e}`):i.origin;t={parent:i.parent,origin:r,rotation:i.rotation,scale:i.scale},this.edges.set(e,t)}return t}transform(e,t,i,r){let{up:s,down:a}=this.tree.path(t,i),o=e;for(let l of s)o=this.edge(l,o,r,!0);for(let l of a)o=this.edge(l,o,r,!1);return o}bodyPosition(e,t,i){let r=this.body(e),s=r.position.map(a=>Sr(a,i));return this.transform(s,r.frame,t,i)}edge(e,t,i,r){let s=this.edgeOf(e),a=[0,0,0];if(Array.isArray(s.origin))a=[Sr(s.origin[0],i),Sr(s.origin[1],i),Sr(s.origin[2],i)];else if(s.origin!==void 0){this.active.has(e)&&I("F6",`the origin of frame ${e} depends on itself`),this.active.add(e);try{a=this.bodyPosition(s.origin.body,s.parent,i)}finally{this.active.delete(e)}}let o=s.scale===void 0?1:Sr(s.scale,i);o===0&&I("F2",`the scale of frame ${e} is zero`);let l=s.rotation,c=l===void 0?0:Sr(l.angle,i);if(!r){let u=[t[0]-a[0],t[1]-a[1],t[2]-a[2]];return l!==void 0&&(u=Vu(u,l.axis,c,!1)),[o*u[0],o*u[1],o*u[2]]}let h=[t[0]/o,t[1]/o,t[2]/o];return l!==void 0&&(h=Vu(h,l.axis,c,!0)),[a[0]+h[0],a[1]+h[1],a[2]+h[2]]}requirements(e,t,i={channels:new Set,attrs:new Set}){let{up:r,down:s}=this.tree.path(e,t);for(let a of[...r,...s]){this.active.has(a)&&I("F6",`the origin of frame ${a} depends on itself`),this.active.add(a);try{let o=this.tree.frame(a);Array.isArray(o.origin)?vc(o.origin,`the origin of frame ${a}`).forEach(l=>Ca(l,i)):o.origin!==void 0&&this.bodyRequirements(o.origin.body,o.parent,i),Ca(o.rotation?.angle,i),Ca(o.scale,i)}finally{this.active.delete(a)}}return i}bodyRequirements(e,t,i={channels:new Set,attrs:new Set}){let r=this.body(e);return r.position.forEach(s=>Ca(s,i)),this.requirements(r.frame,t,i)}};function it(n,e){return n.variables!==void 0&&Object.hasOwn(n.variables,e)?n.variables[e]:void 0}function mi(n,e){let t=it(n.scene,e);t===void 0&&I("2.5",`variable ${JSON.stringify(e)} is not declared`);let i=t.scope==="panel"?n.panel.variables:n.state.variables,r=i!==void 0&&Object.hasOwn(i,e)?i[e]:void 0;return r===void 0?t.default:r}function Ra(n,e){return n.kind==="selector"?typeof e=="number"&&Number.isFinite(e):n.kind==="toggle"?typeof e=="boolean":typeof e=="string"&&n.values.includes(e)}function Mr(n,e){n.clock.channels.includes(e.clock.channel)||I("2.6",`the state's clock channel ${JSON.stringify(e.clock.channel)} is not one of the scene's clock channels`);let t=(s,a)=>{for(let[o,l]of Object.entries(s??{})){let c=it(n,o);c!==void 0&&!Ra(c,l)&&I("2.5",`${a}: ${c.kind} ${o} cannot hold ${JSON.stringify(l)}`)}};t(e.variables,"the state");let i=Object.keys(e.panels);i.length===0&&I("2.8","the state does not have a panel");for(let[s,a]of Object.entries(e.panels))Object.hasOwn(n.views,a.view)||I("2.8",`panel ${s} shows ${JSON.stringify(a.view)}, which is not a view`),t(a.variables,`panel ${s}`);let r=wr(e.layout).sort();(r.length!==i.length||r.some((s,a)=>s!==i.slice().sort()[a]))&&I("2.8",`the layout shows the panels ${r.join(", ")}, while the state has the panels ${i.slice().sort().join(", ")}`)}function wr(n,e=[]){return n.kind==="panel"?e.push(n.id):(wr(n.a,e),wr(n.b,e)),e}function Gm(n,e){return typeof e=="string"?e:mi(n,e.var)}function Es(n,e){if("set"in e)return Object.hasOwn(n.scene.track_sets,e.set)||I("V2",`the set query names ${JSON.stringify(e.set)}, which is not a track set`),[e.set];(e.tags===null||typeof e.tags!="object")&&I("V2",`a tags query has tags ${JSON.stringify(e.tags)}, not an object`);let t=Object.entries(e.tags).map(([i,r])=>[i,Gm(n,r)]);return Object.entries(n.scene.track_sets).filter(([,i])=>t.every(([r,s])=>Object.hasOwn(i.tags??{},r)&&i.tags[r]===s)).map(([i])=>i)}function Tn(n,e){let t=Es(n,e);return t.length>1&&I("V2",`the set query ${JSON.stringify(e)} matches the ${t.length} track sets ${t.join(", ")}, where one is needed`),t[0]??null}function Pa(n,e,t){let i=it(n.scene,e.var);(i===void 0||i.kind!=="selector")&&I("V3",`variable ${e.var} is not a selector`);let r=mi(n,e.var);if((typeof r!="number"||!Number.isFinite(r))&&I("2.5",`selector ${e.var} holds ${JSON.stringify(r)}, not a finite number`),(i.by??"nearest")==="index")return Math.min(Math.max(Math.floor(r+.5),0),t.tracks-1);let a=i.parameter;a===void 0&&I("2.5",`selector ${e.var} is by nearest but does not name a parameter`);let o=t.parameter(a,"V3"),l=0;for(let c=1;c<t.tracks;c++)Math.abs(o[c]-r)<Math.abs(o[l]-r)&&(l=c);return l}function Hu(n,e){return(!Number.isInteger(n)||n<0)&&I("V3",`member index ${JSON.stringify(n)} is not a track index`),n>=e.tracks&&I("V3",`member index ${n} is not below the track count ${e.tracks} of track set ${e.id}`),n}function Wm(n,e){(!Number.isInteger(e)||e<1)&&I("V3",`member count ${JSON.stringify(e)} is not an integer of at least one`);let t=e>=n?1:Math.floor(n/e+.5),i=[];for(let r=0;r<n;r+=t)i.push(r);return i[i.length-1]!==n-1&&i.push(n-1),i}function Ia(n,e,t){return e==="all"?Array.from({length:t.tracks},(i,r)=>r):((e===null||typeof e!="object")&&I("V3",`a member reference is "all", {index}, {count}, or {var}, not ${JSON.stringify(e)}`),"index"in e?[Hu(e.index,t)]:"count"in e?Wm(t.tracks,e.count):[Pa(n,e,t)])}function Er(n,e,t){return e==="all"&&I("V3",`the driver's member is "all", but a driver resolves to one track`),(e===null||typeof e!="object")&&I("V3",`the driver's member is {index} or {var}, not ${JSON.stringify(e)}`),"count"in e&&I("V3","the driver's member is a count, but a driver resolves to one track"),"index"in e?Hu(e.index,t):Pa(n,e,t)}function Tr(n,e){let t=typeof e.frame=="string"?e.frame:mi(n,e.frame.var);return(typeof t!="string"||!Object.hasOwn(n.scene.frames,t))&&I("2.7",`the view displays ${JSON.stringify(t)}, which is not a frame`),t}function Ar(n,e){if(e.visible===void 0)return!0;let t=it(n.scene,e.visible.var);(t===void 0||t.kind!=="toggle")&&I("L5",`a layer's visible names ${e.visible.var}, which is not a toggle`);let i=mi(n,e.visible.var);return typeof i!="boolean"&&I("L5",`toggle ${e.visible.var} holds ${JSON.stringify(i)}, not a boolean`),i}function Dt(n,e,t,i=0){let{k:r,w:s}=n.locate(e);return{k:r,w:s,shifted:t,lap:i}}function La(n,e,t,i=0){if(e===t)return[Dt(n,e,!1,i)];let r=[Dt(n,e,!1,i)];for(let s=0;s<n.m;s++){let a=n.at(s);e<a&&a<t&&r.push({sample:s,shifted:!1,lap:i})}return r.push(Dt(n,t,!1,i)),r}function Gu(n,e,t,i){let r=nn(e,i),s=nn(t,i);if(r.lap===s.lap)return La(n,r.u,s.u,r.lap);let a=La(n,r.u,1,r.lap).slice(0,-1);for(let o=r.lap+1;o<s.lap;o++)a.push(...La(n,0,1,o).slice(0,-1));return a.push(...La(n,0,s.u,s.lap)),a}function $m(n,e,t){let i=t?e:1,r=[];for(let s=0;s<i;s++)for(let a=0;a<(s===i-1?n:n-1);a++)r.push({sample:a,shifted:!1,lap:s});return r}function Wu(n,e,t,i,r){let s=e-t*i;return s<0&&!r&&(s=0),Gu(n,s,e,t)}function gi(n){return n.head===!0||typeof n.head=="object"&&n.head!==null}function Da(n,e,t,i){let r=n.lap??0;if("sample"in n)return i({set:e,track:t,sample:n.sample,shifted:n.shifted,lap:r});let s=i({set:e,track:t,sample:n.k,shifted:n.shifted,lap:r}),a=i({set:e,track:t,sample:n.k+1,shifted:n.shifted,lap:r}),o=n.w;return[(1-o)*s[0]+o*a[0],(1-o)*s[1]+o*a[1],(1-o)*s[2]+o*a[2]]}function $u(n,e,t){if(t===null)return{kind:"track",set:null,members:[]};let i=e.reveal??"none";["none","grow","trail"].includes(i)||I("2.7",`a track layer's reveal is ${JSON.stringify(i)}, not none, grow, or trail`);for(let c of["before","after"])e[c]!==void 0&&e[c]!=="clamp"&&e[c]!=="hidden"&&I("C3",`a track layer's ${c} is ${JSON.stringify(e[c])}, not clamp or hidden`);i==="trail"&&_c(e);let r=Zt(n.clock),s=c=>n.frames.transform(t.position(c.track,c.sample),t.def.frame,n.display,c),a=gi(e),o=i!=="none"||a||n.clock.mode==="value"&&(e.before==="hidden"||e.after==="hidden");o&&r>1&&!t.periodic&&I("C6",`a reading is taken on track set ${t.id}, which is not periodic, and the clock has ${r} laps`);let l=[];for(let c of Ia(n.scope,e.members,t)){let h=[],u=null,d=null;o&&(d=new Bi(t,c,n.channel),u=fi(d.reading(n.clock,n.q),e.before,e.after));let f=o&&u===null,g=r*(u??0);f||(i==="none"?h.push(...$m(t.count(c),r,t.periodic)):i==="grow"?h.push(...Gu(d,0,g,r)):h.push(...Wu(d,g,r,_c(e),t.periodic)));let y={index:c,line:h.map(m=>Da(m,t,c,s))};if(a){let m=nn(g,r);y.head=f?null:Da(Dt(d,m.u,!1,m.lap),t,c,s)}l.push(y)}return{kind:"track",set:t.id,members:l}}function _c(n){n.trail===void 0&&I("2.7","a layer draws a trail but lacks a trail fraction");let e=n.trail.fraction;return(typeof e!="number"||!(e>0&&e<=1))&&I("2.7",`the trail fraction ${String(e)} is not in (0, 1]`),e}function Xu(n,e,t){let i={kind:"body",body:e.body,position:null};if(t===null)return e.trail!==void 0&&(i.trail=[]),i;let{set:r,track:s}=t,a=Zt(n.clock),o=new Bi(r,s,n.channel),l=a*fi(o.reading(n.clock,n.q)),c=nn(l,a),h=u=>n.frames.bodyPosition(e.body,n.display,u);return i.position=Da(Dt(o,c.u,!1,c.lap),r,s,h),e.trail!==void 0&&(i.trail=Wu(o,l,a,_c(e),r.periodic).map(u=>Da(u,r,s,h))),i}var bc=class{id;def;tracks;samples;dim;data;offsets;positions;channels=new Map;parameters=new Map;constructor(e,t,i){this.id=e,this.def=t,this.data=i,this.tracks=t.tracks;let r=i.view(t.offsets);(r.dtype!=="uint32"||r.shape.length!==1||r.shape[0]!==t.tracks+1)&&I("2.1",`track set ${e}: offsets view ${t.offsets} is ${r.dtype} of shape (${r.shape.join(", ")}), not uint32 of shape (${t.tracks+1},)`),this.offsets=r.data,this.offsets[0]!==0&&I("2.1",`track set ${e}: offsets[0] is ${this.offsets[0]}, not 0`);for(let l=0;l<t.tracks;l++){let c=this.offsets[l+1]-this.offsets[l];c<2&&I("T1",`track set ${e}: the sample count of track ${l} is ${c}, fewer than two`)}this.samples=this.offsets[t.tracks];let s=i.view(t.positions),[a,o]=s.shape;(s.shape.length!==2||a!==this.samples||o!==2&&o!==3)&&I("2.1",`track set ${e}: positions view ${t.positions} has shape (${s.shape.join(", ")}), not (${this.samples}, 2) or (${this.samples}, 3)`),this.positions=s.data,this.dim=o}get periodic(){return this.def.periodic===!0}start(e){return this.offsets[e]}count(e){return this.offsets[e+1]-this.offsets[e]}position(e,t){let i=(this.offsets[e]+t)*this.dim,r=this.positions;return[r[i],r[i+1],this.dim===3?r[i+2]:0]}hasChannel(e){return e===yt||Object.hasOwn(this.def.channels??{},e)}channel(e,t="F5"){let i=this.channels.get(e);if(i)return i;let r=this.def.channels?.[e];(r===void 0||!Object.hasOwn(this.def.channels??{},e))&&I(t,`track set ${this.id} lacks channel ${JSON.stringify(e)}`);let s=this.data.view(r.view);return(s.shape.length!==1||s.shape[0]!==this.samples)&&I("2.1",`track set ${this.id}: channel ${e} has shape (${s.shape.join(", ")}), not (${this.samples},)`),this.channels.set(e,s.data),s.data}channelAt(e,t,i,r,s=0){let a=this.count(t),o=s-(r?1:0);if(e===yt)return o===0?i:i+o*(a-1);let l=this.channel(e),c=this.offsets[t],h=l[c+i];return o===0?h:h+o*(l[c+a-1]-l[c])}parameter(e,t="2.5"){let i=this.parameters.get(e);if(i)return i;let r=this.def.parameters?.[e];(r===void 0||!Object.hasOwn(this.def.parameters??{},e))&&I(t,`track set ${this.id} lacks parameter ${JSON.stringify(e)}`);let s=this.data.view(r.view);return(s.shape.length!==1||s.shape[0]!==this.tracks)&&I("2.1",`track set ${this.id}: parameter ${e} has shape (${s.shape.join(", ")}), not (${this.tracks},)`),this.parameters.set(e,s.data),s.data}hasAttr(e){return Object.hasOwn(this.def.attrs??{},e)}attr(e){let t=this.def.attrs?.[e];return(t===void 0||!this.hasAttr(e))&&I("F5",`track set ${this.id} lacks attribute ${JSON.stringify(e)}`),t}},yi=class{scene;data;sets=new Map;constructor(e,t){this.scene=e,this.data=t}get(e){let t=this.sets.get(e);if(!t){let i=this.scene.track_sets[e];(i===void 0||!Object.hasOwn(this.scene.track_sets,e))&&I("2.1",`track set ${JSON.stringify(e)} is not declared`),t=new bc(e,i,this.data),this.sets.set(e,t)}return t}};var Xm=["track","body","axes","grid"],qm=["slider","tabs","toggle","transport"],ka=["viridis","plasma","cividis","blues","reds"],Yu=(n,e)=>{Aa.test(n)||I("S3",`${e} ${JSON.stringify(n)} does not match [A-Za-z0-9_.-]+`)},Vi=n=>typeof n=="number"&&Number.isFinite(n),Sc=/^#[0-9a-fA-F]{6}$/;function zi(n,e,t,i){if(!(n===null||typeof n!="object"||Array.isArray(n)))for(let r of Object.keys(n))e.includes(r)||i.push(`${t} has a key ${JSON.stringify(r)} that this reader does not know`)}var Ym=["label","axes","unit","parent","origin","rotation","scale"],jm=["label","frame","position","color"],Zm=["label","frame","tags","attrs","tracks","offsets","positions","channels","parameters","periodic"],Jm=["label","frame","camera","driver","layers"],qu={track:["kind","sets","members","reveal","trail","head","before","after","color","opacity","width","highlight","visible"],body:["kind","body","trail","size","visible"],axes:["kind","span","visible"],grid:["kind","labels","visible"]},Km=["mode","channels","labels","steps","range","laps"],Qm=["background","foreground","grid"];function eg(n){n.format!=="tycho-scene"&&I("2",`the format is ${JSON.stringify(n.format)}, not "tycho-scene"`);let e=[],t=/^([0-9]+)\.([0-9]+)$/.exec(String(n.version));t===null?e.push(`version ${JSON.stringify(n.version)} is not "major.minor"`):Number(t[1])!==0?e.push(`major version ${t[1]} is unknown to this reader, which reads ${0}.x`):Number(t[2])>2&&e.push(`version ${t[1]}.${t[2]} is newer than this reader's ${0}.${2}, and the format is unstable until 1.0`);let i=(n.requires??[]).filter(r=>!Fu.has(r));i.length>0&&e.push(`the required features ${i.join(", ")} are not implemented`),e.length>0&&I("S1",e.join(", and "))}function An(n,e,t,i){let r=it(n,e);r===void 0&&I(i,`variable ${JSON.stringify(e)} is not declared`),t!==null&&r.kind!==t&&I(i,`variable ${e} is a ${r.kind}, not a ${t}`)}function Na(n,e,t){if(n!==void 0){if(typeof n=="number"){Number.isFinite(n)||I("S4",`${e} is ${String(n)}, not finite`);return}if("attr"in n){(!Vi(n.factor??1)||!Vi(n.offset??0))&&I("S4",`${e} has a factor or offset that is not finite`);return}t&&I("F2",`${e} takes a number or an attribute, not a channel`),n.channel===yt&&I("2.2",`${e} reads channel ${yt}, which is not allowed in a frame edge`)}}function wc(n,e){if("set"in e)Object.hasOwn(n.track_sets,e.set)||I("V2",`the set query names ${JSON.stringify(e.set)}, which is not a track set`);else for(let t of Object.values(e.tags))typeof t=="object"&&t!==null&&An(n,t.var,"choice","V2")}var Ts=n=>typeof n=="number"&&n>=0&&n<=1;function ju(n,e){e.fraction>0&&e.fraction<=1||I("2.7",`view ${n}: a trail fraction is ${e.fraction}, not in (0, 1]`),e.taper!==void 0&&!(Ts(e.taper.width??0)&&Ts(e.taper.opacity??0))&&I("2.7",`view ${n}: a trail taper is not in [0, 1]`)}function tg(n,e,t){wc(n,t.sets),typeof t.members=="object"&&"var"in t.members&&An(n,t.members.var,"selector","V3"),typeof t.members=="object"&&"count"in t.members&&!(Number.isInteger(t.members.count)&&t.members.count>=1)&&I("V3",`view ${e}: member count ${JSON.stringify(t.members.count)} is not an integer of at least one`);let i=t.highlight;if(i!==void 0&&(An(n,i.var,"selector","2.7"),i.width!==void 0&&!(i.width>0)&&I("2.7",`view ${e}: a highlight width is ${i.width}, not positive`),i.opacity!==void 0&&!Ts(i.opacity)&&I("2.7",`view ${e}: a highlight opacity is ${i.opacity}, not in [0, 1]`),i.kernel!==void 0)){i.kernel.width>0&&i.kernel.width<=1||I("2.7",`view ${e}: a highlight kernel's width is ${i.kernel.width}, not in (0, 1]`),Ts(i.kernel.opacity)||I("2.7",`view ${e}: a highlight kernel's opacity is ${i.kernel.opacity}, not in [0, 1]`);let s=it(n,i.var);s?.kind==="selector"&&s.by==="index"&&I("2.7",`view ${e}: a highlight kernel needs a selector by nearest, and ${i.var} is by index`)}let r=t.reveal??"none";["none","grow","trail"].includes(r)||I("2.7",`view ${e}: a track layer's reveal is ${JSON.stringify(r)}, not none, grow, or trail`),r==="trail"&&t.trail===void 0&&I("2.7",`view ${e}: a track layer has reveal "trail" but lacks a trail`),t.trail!==void 0&&ju(e,t.trail),t.head!==void 0&&typeof t.head!="boolean"&&((typeof t.head!="object"||t.head===null)&&I("L3",`view ${e}: a track layer's head is ${JSON.stringify(t.head)}, not a boolean or an object`),t.head.color!==void 0&&!Sc.test(t.head.color)&&I("L3",`view ${e}: a head color is ${JSON.stringify(t.head.color)}, not a #rrggbb color`),t.head.size!==void 0&&!(t.head.size>0)&&I("L3",`view ${e}: a head size is ${t.head.size}, not positive`));for(let s of["before","after"])t[s]!==void 0&&t[s]!=="clamp"&&t[s]!=="hidden"&&I("C3",`view ${e}: a track layer's ${s} is ${JSON.stringify(t[s])}, not clamp or hidden`);if(t.opacity!==void 0&&!Ts(t.opacity)&&I("2.7",`view ${e}: a track layer's opacity is ${t.opacity}, not in [0, 1]`),t.width!==void 0&&!(t.width>0)&&I("2.7",`view ${e}: a track layer's width is ${t.width}, not positive`),t.color!==void 0&&typeof t.color=="object"){let s=t.color.colormap;if(typeof s=="object"&&s!==null){An(n,s.var,"choice","2.7");let a=it(n,s.var).values,o=Object.keys(s.map??{}),l=a.filter(h=>!Object.hasOwn(s.map,h)),c=o.filter(h=>!a.includes(h));l.length>0&&I("2.7",`view ${e}: a colormap keyed on ${s.var} does not name a colormap for ${JSON.stringify(l)}`),c.length>0&&I("2.7",`view ${e}: a colormap keyed on ${s.var} maps ${JSON.stringify(c)}, which are not its values`);for(let h of o)ka.includes(s.map[h])||I("2.7",`view ${e}: the colormap ${JSON.stringify(s.map[h])} is not one of ${ka.join(", ")}`)}else ka.includes(s)||I("2.7",`view ${e}: the colormap ${JSON.stringify(s)} is not one of ${ka.join(", ")}`);"parameter"in t.color=="channel"in t.color&&I("2.7",`view ${e}: a colormap color names both or neither of parameter and channel`)}}function Oa(n,e,t){let i=[];eg(n);for(let o of Object.keys(n))Bu.has(o)||i.push(`the scene has a top-level key ${JSON.stringify(o)} that this reader does not know`);zi(n.theme,Qm,"the theme",i);for(let[o,l]of Object.entries(n.theme??{}))(typeof l!="string"||!Sc.test(l))&&I("2",`theme ${o} is ${JSON.stringify(l)}, not a #rrggbb color`);zi(n.clock,Km,"the clock",i);for(let[o,l]of Object.entries(n.frames))zi(l,Ym,`frame ${o}`,i);for(let[o,l]of Object.entries(n.bodies??{}))zi(l,jm,`body ${o}`,i),l.color!==void 0&&!Sc.test(l.color)&&I("2.4",`body ${o} has color ${JSON.stringify(l.color)}, not #rrggbb`);for(let[o,l]of Object.entries(n.track_sets))zi(l,Zm,`track set ${o}`,i);for(let[o,l]of Object.entries(n.views)){zi(l,Jm,`view ${o}`,i);for(let c of l.layers)Object.hasOwn(qu,c.kind)&&zi(c,qu[c.kind],`a ${c.kind} layer of view ${o}`,i)}for(let[o,l]of[["frame",n.frames],["body",n.bodies],["track set",n.track_sets],["variable",n.variables],["view",n.views]])for(let c of Object.keys(l??{}))Yu(c,o);let r=new pi(n),s=o=>r.tree.has(o);for(let[o,l]of Object.entries(n.frames))Array.isArray(l.origin)&&l.origin.forEach(c=>Na(c,`the origin of frame ${o}`,!0)),Na(l.rotation?.angle,`the rotation of frame ${o}`,!1),Na(l.scale,`the scale of frame ${o}`,!1),l.axes!==void 0&&l.axes.length!==3&&I("2.3",`frame ${o} has ${l.axes.length} axis labels, not three`);for(let[o,l]of Object.entries(n.bodies??{}))s(l.frame)||I("2.4",`body ${o} is in frame ${l.frame}, which is not declared`),l.position.forEach(c=>Na(c,`the position of body ${o}`,!0));Object.keys(n.track_sets).length===0&&I("2.1","the scene does not have a track set");for(let[o,l]of Object.entries(n.track_sets)){s(l.frame)||I("2.1",`track set ${o} is in frame ${l.frame}, which is not declared`),(!Number.isInteger(l.tracks)||l.tracks<1)&&I("2.1",`track set ${o} has tracks ${String(l.tracks)}, not a count of at least one`),Object.hasOwn(l.channels??{},yt)&&I("S3",`track set ${o} declares a channel named ${yt}, which is reserved`);for(let[c,h]of Object.entries(l.attrs??{}))Vi(h)||I("S4",`attribute ${c} of track set ${o} is not finite`)}for(let[o,l]of Object.entries(n.variables??{}))if(l.kind==="selector")l.by!=="index"&&l.parameter===void 0&&I("2.5",`selector ${o} is by nearest but does not name a parameter`),Vi(l.default)||I("2.5",`selector ${o} defaults to ${String(l.default)}, not a finite number`);else if(l.kind==="choice")l.values.includes(l.default)||I("2.5",`choice ${o} defaults to ${JSON.stringify(l.default)}, which is not one of its values`),l.labels!==void 0&&l.labels.length!==l.values.length&&I("2.5",`choice ${o} has ${l.labels.length} labels for ${l.values.length} values`);else if(l.kind==="toggle"){let c=l.default;typeof c!="boolean"&&I("2.5",`toggle ${o} defaults to ${JSON.stringify(c)}, not a boolean`)}else I("2.5",`variable ${o} has kind ${JSON.stringify(l.kind)}, not selector, choice, or toggle`);let a=n.clock;a.mode!=="fraction"&&a.mode!=="value"&&I("2.6",`the clock mode is ${JSON.stringify(a.mode)}, not fraction or value`),(!Number.isInteger(a.steps)||a.steps<1)&&I("2.6",`the clock has steps ${String(a.steps)}, not a count of at least one`),a.mode==="value"&&(a.range===void 0&&I("C2","the clock is in value mode but does not have a range of two numbers"),a.range.every(Vi)||I("S4","the clock range is not finite")),a.labels!==void 0&&a.labels.length!==a.channels.length&&I("2.6",`the clock has ${a.labels.length} labels for ${a.channels.length} channels`),Zt(a);for(let[o,l]of Object.entries(n.views)){if(typeof l.frame=="string")s(l.frame)||I("2.7",`view ${o} displays ${l.frame}, which is not a frame`);else{An(n,l.frame.var,"choice","2.7");let c=it(n,l.frame.var);if(c.kind==="choice")for(let h of c.values)s(h)||I("2.7",`the frame of view ${o} can be ${h}, which is not a frame`)}wc(n,l.driver.sets),l.driver.member==="all"&&I("V3",`view ${o}: the driver's member is "all", but a driver resolves to one track`),"count"in l.driver.member&&I("V3",`view ${o}: the driver's member is a count, but a driver resolves to one track`),"var"in l.driver.member&&An(n,l.driver.member.var,"selector","V3"),l.camera!==void 0&&l.camera.kind!=="plane"&&l.camera.kind!=="orbit"&&I("2.7",`view ${o}: a camera kind is ${JSON.stringify(l.camera.kind)}, not plane or orbit`);for(let c of l.layers)Xm.includes(c.kind)||I("S1",`view ${o}: layer kind ${JSON.stringify(c.kind)} is not implemented`),c.visible!==void 0&&An(n,c.visible.var,"toggle","L5"),c.kind==="track"?tg(n,o,c):c.kind==="body"?(Object.hasOwn(n.bodies??{},c.body)||I("L4",`view ${o} draws ${c.body}, which is not a body`),c.trail!==void 0&&ju(o,c.trail),c.size!==void 0&&!(c.size>0)&&I("2.7",`view ${o}: a body layer's size is ${c.size}, not positive`)):c.kind==="axes"?c.span!==void 0&&c.span!=="full"&&c.span!=="positive"&&I("2.7",`view ${o}: an axes layer's span is ${JSON.stringify(c.span)}, not full or positive`):c.labels!==void 0&&typeof c.labels!="boolean"&&I("2.7",`view ${o}: a grid layer's labels is ${JSON.stringify(c.labels)}, not a boolean`)}for(let o of n.controls??[])if(qm.includes(o.kind)||I("S1",`control kind ${JSON.stringify(o.kind)} is not implemented`),o.kind==="slider"){An(n,o.variable,"selector","2.9");let l=it(n,o.variable);l?.kind==="selector"&&l.by==="index"&&I("2.9",`the slider over ${o.variable} needs a selector by nearest, and the selector is by index`),wc(n,o.domain)}else o.kind==="tabs"?An(n,o.variable,"choice","2.9"):o.kind==="toggle"&&An(n,o.variable,"toggle","2.9");for(let o of n.readouts??[]){o.place!=="caption"&&o.place!=="panel"&&I("2.9",`readout place ${JSON.stringify(o.place)} is not caption or panel`);for(let l of o.parts)typeof l!="string"&&("var"in l&&An(n,l.var,null,"2.9"),"channel"in l&&l.channel===yt&&I("2.9",`a readout channel part names ${yt}, which is not allowed in a readout`),"attr"in l&&(!Vi(l.factor??1)||!Vi(l.offset??0))&&I("S4","a readout attr part has a factor or offset that is not finite"),"digits"in l&&l.digits!==void 0&&!(Number.isInteger(l.digits)&&l.digits>=1&&l.digits<=17)&&I("2.9",`readout digits is ${String(l.digits)}, not in 1 to 17`))}if(e!==void 0){let o=new yi(n,e);for(let l of Object.keys(n.track_sets)){let c=o.get(l);for(let h of Object.keys(c.def.channels??{}))c.channel(h);for(let h of Object.keys(c.def.parameters??{})){let u=c.parameter(h);for(let d=0;d<c.tracks;d++)Number.isFinite(u[d])||I("2.1",`parameter ${h} of track set ${l} is not finite at track ${d}`)}for(let h of n.clock.channels){if(h===yt||!c.hasChannel(h))continue;let u=c.channel(h);for(let d=0;d<c.tracks;d++){let f=c.start(d),g=c.count(d),y=Math.sign(u[f+1]-u[f]);for(let m=0;m<g;m++)Number.isFinite(u[f+m])||I("T3",`clock channel ${h} of track set ${l} is not finite along track ${d} at sample ${m}`),m+1<g&&!((u[f+m+1]-u[f+m])*y>0)&&I("T3",`clock channel ${h} of track set ${l} is not strictly monotone along track ${d} at sample ${m}`);Number.isFinite(u[f+g-1]-u[f])||I("T3",`clock channel ${h} of track set ${l} has an infinite span along track ${d}`)}}}}for(let o of t===void 0?[n.initial]:[n.initial,t])ng(n,r,o,i);return i}function ng(n,e,t,i){Mr(n,t);for(let l of wr(t.layout))Yu(l,"panel");let r=l=>{l.kind!=="panel"&&(l.ratio>0&&l.ratio<1||I("2.8",`a split ratio is ${String(l.ratio)}, not in (0, 1)`),r(l.a),r(l.b))};r(t.layout);let s=Zt(n.clock),a=(n.readouts??[]).map(l=>({place:l.place,parts:l.parts.filter(c=>typeof c!="string"&&("member"in c||"attr"in c||"channel"in c))})).filter(l=>l.parts.length>0),o=wr(t.layout)[0];for(let[l,c]of Object.entries(t.panels)){for(let p of Object.keys(c.variables??{})){let M=it(n,p);M!==void 0&&M.scope!=="panel"&&i.push(`panel ${l} sets ${p}, which is scene-scoped and never read there`)}let h=n.views[c.view],u={scene:n,state:t,panel:c},d=Tr(u,h),f=(p,M,S)=>{let x=n.track_sets[p],A=[...M.channels].filter(R=>R!==yt&&!Object.hasOwn(x.channels??{},R)),T=[...M.attrs].filter(R=>!Object.hasOwn(x.attrs??{},R));A.length+T.length>0&&I("F5",`panel ${l}: track set ${p} lacks ${[...A.map(R=>`channel ${R}`),...T.map(R=>`attribute ${R}`)].join(", ")} for ${S} in frame ${d}`);for(let R of Zu(e,n,x.frame,d)){let k=n.frames[R].scale;k!==void 0&&typeof k=="object"&&"attr"in k&&(k.factor??1)*(x.attrs?.[k.attr]??NaN)+(k.offset??0)===0&&I("F2",`panel ${l}: the scale of frame ${R} is zero for track set ${p}`)}},g=(p,M)=>{let S=n.track_sets[p],x=n.clock.channels.filter(A=>A!==yt&&!Object.hasOwn(S.channels??{},A));x.length>0&&I("C5",`panel ${l}: track set ${p}, ${M}, lacks clock channels ${x.join(", ")}`),s>1&&S.periodic!==!0&&I("C6",`panel ${l}: track set ${p}, ${M}, is not periodic, and the clock has ${s} laps`)},y=(p,M)=>{let S=n.track_sets[p];if(M==="all"||"count"in M)return;if("index"in M){M.index>=S.tracks&&I("V3",`panel ${l}: member index ${M.index} is not below the track count ${S.tracks} of track set ${p}`);return}let x=it(n,M.var);x?.kind==="selector"&&x.by!=="index"&&x.parameter!==void 0&&!Object.hasOwn(S.parameters??{},x.parameter)&&I("V3",`panel ${l}: track set ${p} lacks parameter ${x.parameter} for selector ${M.var}`)},m=Tn(u,h.driver.sets);if(m!==null){f(m,e.requirements(n.track_sets[m].frame,d),"the driver"),g(m,"the driver"),y(m,h.driver.member);let p=n.track_sets[m];for(let M of a)if(M.place==="panel"||l===o)for(let S of M.parts)"member"in S&&!Object.hasOwn(p.parameters??{},S.member)&&I("2.9",`the ${M.place} readout through panel ${l} names parameter ${S.member}, which track set ${m} lacks`),"attr"in S&&!Object.hasOwn(p.attrs??{},S.attr)&&I("2.9",`the ${M.place} readout through panel ${l} names attribute ${S.attr}, which track set ${m} lacks`),"channel"in S&&!Object.hasOwn(p.channels??{},S.channel)&&I("2.9",`the ${M.place} readout through panel ${l} names channel ${S.channel}, which track set ${m} lacks`)}for(let p of h.layers)if(Ar(u,p))if(p.kind==="track"){let M=Tn(u,p.sets);if(M===null)continue;f(M,e.requirements(n.track_sets[M].frame,d),"its tracks"),y(M,p.members),p.highlight!==void 0&&y(M,{var:p.highlight.var});let S=n.track_sets[M];p.color!==void 0&&typeof p.color=="object"&&("channel"in p.color&&!Object.hasOwn(S.channels??{},p.color.channel)&&I("2.7",`panel ${l}: track set ${M} lacks channel ${p.color.channel} for a layer's color`),"parameter"in p.color&&!Object.hasOwn(S.parameters??{},p.color.parameter)&&I("2.7",`panel ${l}: track set ${M} lacks parameter ${p.color.parameter} for a layer's color`));let x=n.clock.mode==="value"&&(p.before==="hidden"||p.after==="hidden");((p.reveal??"none")!=="none"||gi(p)||x)&&g(M,"on which a reading is taken")}else p.kind==="body"&&m!==null&&f(m,e.bodyRequirements(p.body,d),`body ${p.body}`);if(l===o)for(let p of n.controls??[]){if(p.kind!=="slider")continue;let M=it(n,p.variable);if(!(M?.kind!=="selector"||M.parameter===void 0))for(let S of Es(u,p.domain))Object.hasOwn(n.track_sets[S].parameters??{},M.parameter)||I("2.9",`the slider over ${p.variable} has track set ${S} in its domain, which lacks parameter ${M.parameter}`)}}}function Zu(n,e,t,i,r=[]){let{up:s,down:a}=n.tree.path(t,i),o=new Set;for(let l of[...s,...a]){if(r.includes(l))continue;o.add(l);let c=e.frames[l].origin;if(c!==void 0&&!Array.isArray(c)){let h=e.bodies[c.body];for(let u of Zu(n,e,h.frame,e.frames[l].parent,[...r,l]))o.add(u)}}return o}function Ju(n,e,t,i){let r=new yi(n,e),s=new pi(n);Mr(n,t);let a=Zt(n.clock),o=t.clock.channel,l=zu(n.clock.steps,i),c=Object.create(null);for(let[h,u]of Object.entries(t.panels)){let d=n.views[u.view],f={scene:n,state:t,panel:u},g=Tr(f,d),y=Tn(f,d.driver.sets),m=y===null?null:{set:r.get(y),track:0};if(m){m.track=Er(f,d.driver.member,m.set);let S=n.clock.channels.filter(x=>x!==yt&&!m.set.hasChannel(x));S.length>0&&I("C5",`the driver's track set ${m.set.id} lacks clock channels ${S.join(", ")}`),a>1&&!m.set.periodic&&I("C6",`the driver's track set ${m.set.id} is not periodic, and the clock has ${a} laps`)}let p={scope:f,frames:s,clock:n.clock,channel:o,q:l,display:g},M=[];for(let S of d.layers)if(["track","body","axes","grid"].includes(S.kind)||I("S1",`layer kind ${JSON.stringify(S.kind)} is not implemented`),!!Ar(f,S))if(S.kind==="track"){let x=Tn(f,S.sets);M.push($u(p,S,x===null?null:r.get(x)))}else S.kind==="body"?M.push(Xu(p,S,m)):M.push({kind:S.kind});c[h]={frame:g,layers:M}}return{panels:c}}var ig={viridis:[[.267,.005,.329],[.283,.141,.458],[.254,.265,.53],[.207,.372,.553],[.164,.471,.558],[.128,.567,.551],[.135,.659,.518],[.267,.749,.441],[.478,.821,.318],[.741,.873,.15],[.993,.906,.144]],plasma:[[.05,.03,.528],[.294,.012,.615],[.492,.012,.658],[.665,.139,.586],[.798,.28,.47],[.902,.418,.36],[.973,.585,.252],[.993,.771,.155],[.94,.975,.131]],cividis:[[0,.135,.304],[.086,.218,.396],[.243,.301,.42],[.365,.383,.432],[.478,.466,.448],[.588,.55,.437],[.702,.638,.402],[.822,.73,.343],[.945,.827,.244],[.996,.91,.149]],blues:[[.19,.42,.71],[.33,.6,.8],[.53,.76,.87],[.7,.85,.92],[.85,.93,.98]],reds:[[.72,.1,.1],[.89,.27,.2],[.98,.5,.36],[.99,.7,.58],[1,.86,.78]]};function Hi(n,e,t=[0,0,0]){let i=ig[n],r=Math.max(0,Math.min(1,e))*(i.length-1),s=Math.min(i.length-2,Math.floor(r)),a=r-s;for(let o=0;o<3;o++)t[o]=i[s][o]+(i[s+1][o]-i[s][o])*a;return t}function Ku(n,e){let[t,i,r]=Hi(n,e);return`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}var rg={background:"#000000",foreground:"#d8d8d8",grid:"#262626"};function Cr(n){return{...rg,...n.theme??{}}}var sg={dark:{background:"#050505",foreground:"#f2f2ef",grid:"#232320"},light:{background:"#faf8f3",foreground:"#141413",grid:"#e3e0d8"}};function Mc(n){let e=n.trim();if(/^#[0-9a-fA-F]{6}$/.test(e))return e.toLowerCase();if(/^#[0-9a-fA-F]{3}$/.test(e))return`#${[...e.slice(1)].map(o=>o+o).join("")}`.toLowerCase();if(e==="")return null;let t=document.createElement("canvas").getContext?.("2d",{willReadFrequently:!0});if(t==null)return null;let i=o=>(t.fillStyle=o,t.fillStyle=e,t.fillStyle);if(i("#000000")!==i("#ffffff"))return null;t.fillRect(0,0,1,1);let[r,s,a]=t.getImageData(0,0,1,1).data;return`#${[r,s,a].map(o=>o.toString(16).padStart(2,"0")).join("")}`}function ed(n,e,t){let i=e==="dark"||e==="light"?sg[e]:n;return{background:Mc(t("--tycho-background"))??i.background,foreground:Mc(t("--tycho-foreground"))??i.foreground,grid:Mc(t("--tycho-grid"))??i.grid}}var Gi={accent:"#f0a050",hover:"#ffb366",press:"#d98a3a",violet:"#c050f0",violetText:"#d98cff",error:"#ff7a7a"};function td(n){let e=kt(n.background,n.background,0),t=kt(n.foreground,n.foreground,0),i=kt(t,e,.95),r=Nt(e).reduce((s,a)=>s+a,0)<1.5;return{"--bg":e,"--fg":t,"--surface":i,"--raised":kt(t,e,.82),"--line":kt(t,e,.8),"--dim":kt(t,e,.287),"--track":kt(t,e,.574),"--gutter":kt(t,e,.9),"--head":`${i}cc`,"--accent":Gi.accent,"--accent-hover":Gi.hover,"--accent-press":Gi.press,"--accent-tint":kt(Gi.accent,i,.84),"--accent-2":Gi.violet,"--accent-2-text":Gi.violetText,"--accent-2-tint":"rgba(192, 80, 240, 0.16)","--error":Gi.error,"--highlight":r?"#ffffff":"#000000"}}function Nt(n){let e=/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/.exec(n);return e===null?[1,1,1]:[parseInt(e[1],16)/255,parseInt(e[2],16)/255,parseInt(e[3],16)/255]}function kt(n,e,t){let i=Nt(n),r=Nt(e),s=a=>Math.round(255*((1-t)*i[a]+t*r[a])).toString(16).padStart(2,"0");return`#${s(0)}${s(1)}${s(2)}`}function Qu(n,e,t=[0,1]){let[i,r]=e,s=r===i?.5:Math.min(1,Math.max(0,(n-i)/(r-i)));return t[0]+s*(t[1]-t[0])}function ag(n){let e=1/0,t=-1/0;for(let i=0;i<n.length;i++){let r=n[i];r<e&&(e=r),r>t&&(t=r)}return e<=t?[e,t]:[0,1]}function og(n,e){if(typeof n=="string")return n;let t=e?.(n.var);return(t!==void 0&&Object.hasOwn(n.map,t)?n.map[t]:void 0)??Object.values(n.map).find(r=>r!==void 0)??"viridis"}function Ec(n,e,t){let i="parameter"in n,r="parameter"in n?n.parameter:n.channel,s="parameter"in n?e.parameter(n.parameter,"2.7"):e.channel(n.channel,"2.7");return{id:og(n.colormap,t),name:r,perTrack:i,values:s,range:n.range??ag(s),clip:n.clip??[0,1]}}function nd(n,e,t,i){if(n===void 0)return{kind:"constant",rgb:t};if(typeof n=="string")return{kind:"constant",rgb:Nt(n)};let r=Ec(n,e,i),s=new Float32Array(3*e.samples),a=[0,0,0];if(r.perTrack)for(let o=0;o<e.tracks;o++){Hi(r.id,Qu(r.values[o],r.range,r.clip),a);for(let l=e.start(o);l<e.start(o)+e.count(o);l++)s.set(a,3*l)}else for(let o=0;o<e.samples;o++)s.set(Hi(r.id,Qu(r.values[o],r.range,r.clip),a),3*o);return{kind:"sample",rgb:s}}function Tc(n,e=12){let t=[],i=[0,0,0];for(let r=0;r<e;r++){let s=r/(e-1);Hi(n.id,n.clip[0]+s*(n.clip[1]-n.clip[0]),i),t.push([s,`rgb(${i.map(a=>Math.round(255*a)).join(",")})`])}return t}function id(n,e=12){return`linear-gradient(to top, ${Tc(n,e).map(([t,i])=>`${i} ${(100*t).toFixed(1)}%`).join(", ")})`}var Uc=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)},P=(n,e,t)=>(Uc(n,e,"read from private field"),t?t.call(n):e.get(n)),Ge=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},Ut=(n,e,t,i)=>(Uc(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),lg=(n,e,t,i)=>({set _(r){Ut(n,e,r,t)},get _(){return P(n,e,i)}}),je=(n,e,t)=>(Uc(n,e,"access private method"),t),Qe=new Uint8Array(8),Gn=new DataView(Qe.buffer),Ct=n=>[(n%256+256)%256],tt=n=>(Gn.setUint16(0,n,!1),[Qe[0],Qe[1]]),cg=n=>(Gn.setInt16(0,n,!1),[Qe[0],Qe[1]]),sd=n=>(Gn.setUint32(0,n,!1),[Qe[1],Qe[2],Qe[3]]),pe=n=>(Gn.setUint32(0,n,!1),[Qe[0],Qe[1],Qe[2],Qe[3]]),hg=n=>(Gn.setInt32(0,n,!1),[Qe[0],Qe[1],Qe[2],Qe[3]]),ji=n=>(Gn.setUint32(0,Math.floor(n/2**32),!1),Gn.setUint32(4,n,!1),[Qe[0],Qe[1],Qe[2],Qe[3],Qe[4],Qe[5],Qe[6],Qe[7]]),Fc=n=>(Gn.setInt16(0,2**8*n,!1),[Qe[0],Qe[1]]),Vn=n=>(Gn.setInt32(0,2**16*n,!1),[Qe[0],Qe[1],Qe[2],Qe[3]]),Ac=n=>(Gn.setInt32(0,2**30*n,!1),[Qe[0],Qe[1],Qe[2],Qe[3]]),vn=(n,e=!1)=>{let t=Array(n.length).fill(null).map((i,r)=>n.charCodeAt(r));return e&&t.push(0),t},Ha=n=>n&&n[n.length-1],Bc=n=>{let e;for(let t of n)(!e||t.presentationTimestamp>e.presentationTimestamp)&&(e=t);return e},Hn=(n,e,t=!0)=>{let i=n*e;return t?Math.round(i):i},ad=n=>{let e=n*(Math.PI/180),t=Math.cos(e),i=Math.sin(e);return[t,i,0,-i,t,0,0,0,1]},od=ad(0),ld=n=>[Vn(n[0]),Vn(n[1]),Ac(n[2]),Vn(n[3]),Vn(n[4]),Ac(n[5]),Vn(n[6]),Vn(n[7]),Ac(n[8])],Rs=n=>!n||typeof n!="object"?n:Array.isArray(n)?n.map(Rs):Object.fromEntries(Object.entries(n).map(([e,t])=>[e,Rs(t)])),Lr=n=>n>=0&&n<2**32,Mt=(n,e,t)=>({type:n,contents:e&&new Uint8Array(e.flat(10)),children:t}),ft=(n,e,t,i,r)=>Mt(n,[Ct(e),sd(t),i??[]],r),ug=n=>{let e=512;return n.fragmented?Mt("ftyp",[vn("iso5"),pe(e),vn("iso5"),vn("iso6"),vn("mp41")]):Mt("ftyp",[vn("isom"),pe(e),vn("isom"),n.holdsAvc?vn("avc1"):[],vn("mp41")])},Cc=n=>({type:"mdat",largeSize:n}),dg=n=>({type:"free",size:n}),Ua=(n,e,t=!1)=>Mt("moov",null,[fg(e,n),...n.map(i=>pg(i,e)),t?$g(n):null]),fg=(n,e)=>{let t=Hn(Math.max(0,...e.filter(a=>a.samples.length>0).map(a=>{let o=Bc(a.samples);return o.presentationTimestamp+o.duration})),Ic),i=Math.max(...e.map(a=>a.id))+1,r=!Lr(n)||!Lr(t),s=r?ji:pe;return ft("mvhd",+r,0,[s(n),s(n),pe(Ic),s(t),Vn(1),Fc(1),Array(10).fill(0),ld(od),Array(24).fill(0),pe(i)])},pg=(n,e)=>Mt("trak",null,[mg(n,e),gg(n,e)]),mg=(n,e)=>{let t=Bc(n.samples),i=Hn(t?t.presentationTimestamp+t.duration:0,Ic),r=!Lr(e)||!Lr(i),s=r?ji:pe,a;return n.info.type==="video"?a=typeof n.info.rotation=="number"?ad(n.info.rotation):n.info.rotation:a=od,ft("tkhd",+r,3,[s(e),s(e),pe(n.id),pe(0),s(i),Array(8).fill(0),tt(0),tt(0),Fc(n.info.type==="audio"?1:0),tt(0),ld(a),Vn(n.info.type==="video"?n.info.width:0),Vn(n.info.type==="video"?n.info.height:0)])},gg=(n,e)=>Mt("mdia",null,[yg(n,e),vg(n.info.type==="video"?"vide":"soun"),xg(n)]),yg=(n,e)=>{let t=Bc(n.samples),i=Hn(t?t.presentationTimestamp+t.duration:0,n.timescale),r=!Lr(e)||!Lr(i),s=r?ji:pe;return ft("mdhd",+r,0,[s(e),s(e),pe(n.timescale),s(i),tt(21956),tt(0)])},vg=n=>ft("hdlr",0,0,[vn("mhlr"),vn(n),pe(0),pe(0),pe(0),vn("mp4-muxer-hdlr",!0)]),xg=n=>Mt("minf",null,[n.info.type==="video"?_g():bg(),Sg(),Eg(n)]),_g=()=>ft("vmhd",0,1,[tt(0),tt(0),tt(0),tt(0)]),bg=()=>ft("smhd",0,0,[tt(0),tt(0)]),Sg=()=>Mt("dinf",null,[wg()]),wg=()=>ft("dref",0,0,[pe(1)],[Mg()]),Mg=()=>ft("url ",0,1),Eg=n=>{let e=n.compositionTimeOffsetTable.length>1||n.compositionTimeOffsetTable.some(t=>t.sampleCompositionTimeOffset!==0);return Mt("stbl",null,[Tg(n),Bg(n),zg(n),Vg(n),Hg(n),Gg(n),e?Wg(n):null])},Tg=n=>ft("stsd",0,0,[pe(1)],[n.info.type==="video"?Ag(ty[n.info.codec],n):Og(iy[n.info.codec],n)]),Ag=(n,e)=>Mt(n,[Array(6).fill(0),tt(1),tt(0),tt(0),Array(12).fill(0),tt(e.info.width),tt(e.info.height),pe(4718592),pe(4718592),pe(0),tt(1),Array(32).fill(0),tt(24),cg(65535)],[ny[e.info.codec](e),e.info.decoderConfig.colorSpace?Ig(e):null]),Cg={bt709:1,bt470bg:5,smpte170m:6},Rg={bt709:1,smpte170m:6,"iec61966-2-1":13},Pg={rgb:0,bt709:1,bt470bg:5,smpte170m:6},Ig=n=>Mt("colr",[vn("nclx"),tt(Cg[n.info.decoderConfig.colorSpace.primaries]),tt(Rg[n.info.decoderConfig.colorSpace.transfer]),tt(Pg[n.info.decoderConfig.colorSpace.matrix]),Ct((n.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),Lg=n=>n.info.decoderConfig&&Mt("avcC",[...new Uint8Array(n.info.decoderConfig.description)]),Dg=n=>n.info.decoderConfig&&Mt("hvcC",[...new Uint8Array(n.info.decoderConfig.description)]),kg=n=>{if(!n.info.decoderConfig)return null;let e=n.info.decoderConfig;if(!e.colorSpace)throw new Error("'colorSpace' is required in the decoder config for VP9.");let t=e.codec.split("."),i=Number(t[1]),r=Number(t[2]),o=(Number(t[3])<<4)+(0<<1)+Number(e.colorSpace.fullRange);return ft("vpcC",1,0,[Ct(i),Ct(r),Ct(o),Ct(2),Ct(2),Ct(2),tt(0)])},Ng=()=>{let t=(1<<7)+1;return Mt("av1C",[t,0,0,0])},Og=(n,e)=>Mt(n,[Array(6).fill(0),tt(1),tt(0),tt(0),pe(0),tt(e.info.numberOfChannels),tt(16),tt(0),tt(0),Vn(e.info.sampleRate)],[ry[e.info.codec](e)]),Ug=n=>{let e=new Uint8Array(n.info.decoderConfig.description);return ft("esds",0,0,[pe(58753152),Ct(32+e.byteLength),tt(1),Ct(0),pe(75530368),Ct(18+e.byteLength),Ct(64),Ct(21),sd(0),pe(130071),pe(130071),pe(92307584),Ct(e.byteLength),...e,pe(109084800),Ct(1),Ct(2)])},Fg=n=>{let e=3840,t=0,i=n.info.decoderConfig?.description;if(i){if(i.byteLength<18)throw new TypeError("Invalid decoder description provided for Opus; must be at least 18 bytes long.");let r=ArrayBuffer.isView(i)?new DataView(i.buffer,i.byteOffset,i.byteLength):new DataView(i);e=r.getUint16(10,!0),t=r.getInt16(14,!0)}return Mt("dOps",[Ct(0),Ct(n.info.numberOfChannels),tt(e),pe(n.info.sampleRate),Fc(t),Ct(0)])},Bg=n=>ft("stts",0,0,[pe(n.timeToSampleTable.length),n.timeToSampleTable.map(e=>[pe(e.sampleCount),pe(e.sampleDelta)])]),zg=n=>{if(n.samples.every(t=>t.type==="key"))return null;let e=[...n.samples.entries()].filter(([,t])=>t.type==="key");return ft("stss",0,0,[pe(e.length),e.map(([t])=>pe(t+1))])},Vg=n=>ft("stsc",0,0,[pe(n.compactlyCodedChunkTable.length),n.compactlyCodedChunkTable.map(e=>[pe(e.firstChunk),pe(e.samplesPerChunk),pe(1)])]),Hg=n=>ft("stsz",0,0,[pe(0),pe(n.samples.length),n.samples.map(e=>pe(e.size))]),Gg=n=>n.finalizedChunks.length>0&&Ha(n.finalizedChunks).offset>=2**32?ft("co64",0,0,[pe(n.finalizedChunks.length),n.finalizedChunks.map(e=>ji(e.offset))]):ft("stco",0,0,[pe(n.finalizedChunks.length),n.finalizedChunks.map(e=>pe(e.offset))]),Wg=n=>ft("ctts",0,0,[pe(n.compositionTimeOffsetTable.length),n.compositionTimeOffsetTable.map(e=>[pe(e.sampleCount),pe(e.sampleCompositionTimeOffset)])]),$g=n=>Mt("mvex",null,n.map(Xg)),Xg=n=>ft("trex",0,0,[pe(n.id),pe(1),pe(0),pe(0),pe(0)]),rd=(n,e)=>Mt("moof",null,[qg(n),...e.map(Yg)]),qg=n=>ft("mfhd",0,0,[pe(n)]),cd=n=>{let e=0,t=0,i=0,r=0,s=n.type==="delta";return t|=+s,s?e|=1:e|=2,e<<24|t<<16|i<<8|r},Yg=n=>Mt("traf",null,[jg(n),Zg(n),Jg(n)]),jg=n=>{let e=0;e|=8,e|=16,e|=32,e|=131072;let t=n.currentChunk.samples[1]??n.currentChunk.samples[0],i={duration:t.timescaleUnitsToNextSample,size:t.size,flags:cd(t)};return ft("tfhd",0,e,[pe(n.id),pe(i.duration),pe(i.size),pe(i.flags)])},Zg=n=>ft("tfdt",1,0,[ji(Hn(n.currentChunk.startTimestamp,n.timescale))]),Jg=n=>{let e=n.currentChunk.samples.map(y=>y.timescaleUnitsToNextSample),t=n.currentChunk.samples.map(y=>y.size),i=n.currentChunk.samples.map(cd),r=n.currentChunk.samples.map(y=>Hn(y.presentationTimestamp-y.decodeTimestamp,n.timescale)),s=new Set(e),a=new Set(t),o=new Set(i),l=new Set(r),c=o.size===2&&i[0]!==i[1],h=s.size>1,u=a.size>1,d=!c&&o.size>1,f=l.size>1||[...l].some(y=>y!==0),g=0;return g|=1,g|=4*+c,g|=256*+h,g|=512*+u,g|=1024*+d,g|=2048*+f,ft("trun",1,g,[pe(n.currentChunk.samples.length),pe(n.currentChunk.offset-n.currentChunk.moofOffset||0),c?pe(i[0]):[],n.currentChunk.samples.map((y,m)=>[h?pe(e[m]):[],u?pe(t[m]):[],d?pe(i[m]):[],f?hg(r[m]):[]])])},Kg=n=>Mt("mfra",null,[...n.map(Qg),ey()]),Qg=(n,e)=>ft("tfra",1,0,[pe(n.id),pe(63),pe(n.finalizedChunks.length),n.finalizedChunks.map(i=>[ji(Hn(i.startTimestamp,n.timescale)),ji(i.moofOffset),pe(e+1),pe(1),pe(1)])]),ey=()=>ft("mfro",0,0,[pe(0)]),ty={avc:"avc1",hevc:"hvc1",vp9:"vp09",av1:"av01"},ny={avc:Lg,hevc:Dg,vp9:kg,av1:Ng},iy={aac:"mp4a",opus:"Opus"},ry={aac:Ug,opus:Fg};var Ya=class{},zc=class extends Ya{constructor(){super(...arguments),this.buffer=null}},hd=class extends Ya{constructor(n){if(super(),this.options=n,typeof n!="object")throw new TypeError("StreamTarget requires an options object to be passed to its constructor.");if(n.onData){if(typeof n.onData!="function")throw new TypeError("options.onData, when provided, must be a function.");if(n.onData.length<2)throw new TypeError("options.onData, when provided, must be a function that takes in at least two arguments (data and position). Ignoring the position argument, which specifies the byte offset at which the data is to be written, can lead to broken outputs.")}if(n.chunked!==void 0&&typeof n.chunked!="boolean")throw new TypeError("options.chunked, when provided, must be a boolean.");if(n.chunkSize!==void 0&&(!Number.isInteger(n.chunkSize)||n.chunkSize<1024))throw new TypeError("options.chunkSize, when provided, must be an integer and not smaller than 1024.")}},sy=class extends Ya{constructor(n,e){if(super(),this.stream=n,this.options=e,!(n instanceof FileSystemWritableFileStream))throw new TypeError("FileSystemWritableFileStreamTarget requires a FileSystemWritableFileStream instance.");if(e!==void 0&&typeof e!="object")throw new TypeError("FileSystemWritableFileStreamTarget's options, when provided, must be an object.");if(e&&e.chunkSize!==void 0&&(!Number.isInteger(e.chunkSize)||e.chunkSize<=0))throw new TypeError("options.chunkSize, when provided, must be a positive integer")}},Wi,Rr,ud=class{constructor(){this.pos=0,Ge(this,Wi,new Uint8Array(8)),Ge(this,Rr,new DataView(P(this,Wi).buffer)),this.offsets=new WeakMap}seek(n){this.pos=n}writeU32(n){P(this,Rr).setUint32(0,n,!1),this.write(P(this,Wi).subarray(0,4))}writeU64(n){P(this,Rr).setUint32(0,Math.floor(n/2**32),!1),P(this,Rr).setUint32(4,n,!1),this.write(P(this,Wi).subarray(0,8))}writeAscii(n){for(let e=0;e<n.length;e++)P(this,Rr).setUint8(e%8,n.charCodeAt(e)),e%8===7&&this.write(P(this,Wi));n.length%8!==0&&this.write(P(this,Wi).subarray(0,n.length%8))}writeBox(n){if(this.offsets.set(n,this.pos),n.contents&&!n.children)this.writeBoxHeader(n,n.size??n.contents.byteLength+8),this.write(n.contents);else{let e=this.pos;if(this.writeBoxHeader(n,0),n.contents&&this.write(n.contents),n.children)for(let r of n.children)r&&this.writeBox(r);let t=this.pos,i=n.size??t-e;this.seek(e),this.writeBoxHeader(n,i),this.seek(t)}}writeBoxHeader(n,e){this.writeU32(n.largeSize?1:e),this.writeAscii(n.type),n.largeSize&&this.writeU64(e)}measureBoxHeader(n){return 8+(n.largeSize?8:0)}patchBox(n){let e=this.pos;this.seek(this.offsets.get(n)),this.writeBox(n),this.seek(e)}measureBox(n){if(n.contents&&!n.children)return this.measureBoxHeader(n)+n.contents.byteLength;{let e=this.measureBoxHeader(n);if(n.contents&&(e+=n.contents.byteLength),n.children)for(let t of n.children)t&&(e+=this.measureBox(t));return e}}};Wi=new WeakMap;Rr=new WeakMap;var Fa,Yi,ks,As,Ba,Rc,ay=class extends ud{constructor(n){super(),Ge(this,Ba),Ge(this,Fa,void 0),Ge(this,Yi,new ArrayBuffer(2**16)),Ge(this,ks,new Uint8Array(P(this,Yi))),Ge(this,As,0),Ut(this,Fa,n)}write(n){je(this,Ba,Rc).call(this,this.pos+n.byteLength),P(this,ks).set(n,this.pos),this.pos+=n.byteLength,Ut(this,As,Math.max(P(this,As),this.pos))}finalize(){je(this,Ba,Rc).call(this,this.pos),P(this,Fa).buffer=P(this,Yi).slice(0,Math.max(P(this,As),this.pos))}};Fa=new WeakMap;Yi=new WeakMap;ks=new WeakMap;As=new WeakMap;Ba=new WeakSet;Rc=function(n){let e=P(this,Yi).byteLength;for(;e<n;)e*=2;if(e===P(this,Yi).byteLength)return;let t=new ArrayBuffer(e),i=new Uint8Array(t);i.set(P(this,ks),0),Ut(this,Yi,t),Ut(this,ks,i)};var oy=2**24,ly=2,Ps,$i,Cs,ei,un,Ga,Pc,Vc,dd,Hc,fd,Is,Wa,Gc=class extends ud{constructor(n){super(),Ge(this,Ga),Ge(this,Vc),Ge(this,Hc),Ge(this,Is),Ge(this,Ps,void 0),Ge(this,$i,[]),Ge(this,Cs,void 0),Ge(this,ei,void 0),Ge(this,un,[]),Ut(this,Ps,n),Ut(this,Cs,n.options?.chunked??!1),Ut(this,ei,n.options?.chunkSize??oy)}write(n){P(this,$i).push({data:n.slice(),start:this.pos}),this.pos+=n.byteLength}flush(){if(P(this,$i).length===0)return;let n=[],e=[...P(this,$i)].sort((t,i)=>t.start-i.start);n.push({start:e[0].start,size:e[0].data.byteLength});for(let t=1;t<e.length;t++){let i=n[n.length-1],r=e[t];r.start<=i.start+i.size?i.size=Math.max(i.size,r.start+r.data.byteLength-i.start):n.push({start:r.start,size:r.data.byteLength})}for(let t of n){t.data=new Uint8Array(t.size);for(let i of P(this,$i))t.start<=i.start&&i.start<t.start+t.size&&t.data.set(i.data,i.start-t.start);P(this,Cs)?(je(this,Ga,Pc).call(this,t.data,t.start),je(this,Is,Wa).call(this)):P(this,Ps).options.onData?.(t.data,t.start)}P(this,$i).length=0}finalize(){P(this,Cs)&&je(this,Is,Wa).call(this,!0)}};Ps=new WeakMap;$i=new WeakMap;Cs=new WeakMap;ei=new WeakMap;un=new WeakMap;Ga=new WeakSet;Pc=function(n,e){let t=P(this,un).findIndex(o=>o.start<=e&&e<o.start+P(this,ei));t===-1&&(t=je(this,Hc,fd).call(this,e));let i=P(this,un)[t],r=e-i.start,s=n.subarray(0,Math.min(P(this,ei)-r,n.byteLength));i.data.set(s,r);let a={start:r,end:r+s.byteLength};if(je(this,Vc,dd).call(this,i,a),i.written[0].start===0&&i.written[0].end===P(this,ei)&&(i.shouldFlush=!0),P(this,un).length>ly){for(let o=0;o<P(this,un).length-1;o++)P(this,un)[o].shouldFlush=!0;je(this,Is,Wa).call(this)}s.byteLength<n.byteLength&&je(this,Ga,Pc).call(this,n.subarray(s.byteLength),e+s.byteLength)};Vc=new WeakSet;dd=function(n,e){let t=0,i=n.written.length-1,r=-1;for(;t<=i;){let s=Math.floor(t+(i-t+1)/2);n.written[s].start<=e.start?(t=s+1,r=s):i=s-1}for(n.written.splice(r+1,0,e),(r===-1||n.written[r].end<e.start)&&r++;r<n.written.length-1&&n.written[r].end>=n.written[r+1].start;)n.written[r].end=Math.max(n.written[r].end,n.written[r+1].end),n.written.splice(r+1,1)};Hc=new WeakSet;fd=function(n){let t={start:Math.floor(n/P(this,ei))*P(this,ei),data:new Uint8Array(P(this,ei)),written:[],shouldFlush:!1};return P(this,un).push(t),P(this,un).sort((i,r)=>i.start-r.start),P(this,un).indexOf(t)};Is=new WeakSet;Wa=function(n=!1){for(let e=0;e<P(this,un).length;e++){let t=P(this,un)[e];if(!(!t.shouldFlush&&!n)){for(let i of t.written)P(this,Ps).options.onData?.(t.data.subarray(i.start,i.end),t.start+i.start);P(this,un).splice(e--,1)}}};var cy=class extends Gc{constructor(n){super(new hd({onData:(e,t)=>n.stream.write({type:"write",data:e,position:t}),chunked:!0,chunkSize:n.options?.chunkSize}))}},Ic=1e3,hy=["avc","hevc","vp9","av1"],uy=["aac","opus"],dy=2082844800,fy=["strict","offset","cross-track-offset"],Ce,De,$a,hn,Vt,Ot,Pr,Ir,Wc,Xi,qi,Ls,Lc,pd,Dc,md,$c,gd,kc,yd,Xc,vd,za,Nc,zn,Qn,qc,xd,Ds,Xa,qa,Yc,Dr,Ns,Va,Oc,_d=class{constructor(n){if(Ge(this,Lc),Ge(this,Dc),Ge(this,$c),Ge(this,kc),Ge(this,Xc),Ge(this,za),Ge(this,zn),Ge(this,qc),Ge(this,Ds),Ge(this,qa),Ge(this,Dr),Ge(this,Va),Ge(this,Ce,void 0),Ge(this,De,void 0),Ge(this,$a,void 0),Ge(this,hn,void 0),Ge(this,Vt,null),Ge(this,Ot,null),Ge(this,Pr,Math.floor(Date.now()/1e3)+dy),Ge(this,Ir,[]),Ge(this,Wc,1),Ge(this,Xi,[]),Ge(this,qi,[]),Ge(this,Ls,!1),je(this,Lc,pd).call(this,n),n.video=Rs(n.video),n.audio=Rs(n.audio),n.fastStart=Rs(n.fastStart),this.target=n.target,Ut(this,Ce,{firstTimestampBehavior:"strict",...n}),n.target instanceof zc)Ut(this,De,new ay(n.target));else if(n.target instanceof hd)Ut(this,De,new Gc(n.target));else if(n.target instanceof sy)Ut(this,De,new cy(n.target));else throw new Error(`Invalid target: ${n.target}`);je(this,kc,yd).call(this),je(this,Dc,md).call(this)}addVideoChunk(n,e,t,i){if(!(n instanceof EncodedVideoChunk))throw new TypeError("addVideoChunk's first argument (sample) must be of type EncodedVideoChunk.");if(e&&typeof e!="object")throw new TypeError("addVideoChunk's second argument (meta), when provided, must be an object.");if(t!==void 0&&(!Number.isFinite(t)||t<0))throw new TypeError("addVideoChunk's third argument (timestamp), when provided, must be a non-negative real number.");if(i!==void 0&&!Number.isFinite(i))throw new TypeError("addVideoChunk's fourth argument (compositionTimeOffset), when provided, must be a real number.");let r=new Uint8Array(n.byteLength);n.copyTo(r),this.addVideoChunkRaw(r,n.type,t??n.timestamp,n.duration,e,i)}addVideoChunkRaw(n,e,t,i,r,s){if(!(n instanceof Uint8Array))throw new TypeError("addVideoChunkRaw's first argument (data) must be an instance of Uint8Array.");if(e!=="key"&&e!=="delta")throw new TypeError("addVideoChunkRaw's second argument (type) must be either 'key' or 'delta'.");if(!Number.isFinite(t)||t<0)throw new TypeError("addVideoChunkRaw's third argument (timestamp) must be a non-negative real number.");if(!Number.isFinite(i)||i<0)throw new TypeError("addVideoChunkRaw's fourth argument (duration) must be a non-negative real number.");if(r&&typeof r!="object")throw new TypeError("addVideoChunkRaw's fifth argument (meta), when provided, must be an object.");if(s!==void 0&&!Number.isFinite(s))throw new TypeError("addVideoChunkRaw's sixth argument (compositionTimeOffset), when provided, must be a real number.");if(je(this,Va,Oc).call(this),!P(this,Ce).video)throw new Error("No video track declared.");if(typeof P(this,Ce).fastStart=="object"&&P(this,Vt).samples.length===P(this,Ce).fastStart.expectedVideoChunks)throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${P(this,Ce).fastStart.expectedVideoChunks}).`);let a=je(this,za,Nc).call(this,P(this,Vt),n,e,t,i,r,s);if(P(this,Ce).fastStart==="fragmented"&&P(this,Ot)){for(;P(this,qi).length>0&&P(this,qi)[0].decodeTimestamp<=a.decodeTimestamp;){let o=P(this,qi).shift();je(this,zn,Qn).call(this,P(this,Ot),o)}a.decodeTimestamp<=P(this,Ot).lastDecodeTimestamp?je(this,zn,Qn).call(this,P(this,Vt),a):P(this,Xi).push(a)}else je(this,zn,Qn).call(this,P(this,Vt),a)}addAudioChunk(n,e,t){if(!(n instanceof EncodedAudioChunk))throw new TypeError("addAudioChunk's first argument (sample) must be of type EncodedAudioChunk.");if(e&&typeof e!="object")throw new TypeError("addAudioChunk's second argument (meta), when provided, must be an object.");if(t!==void 0&&(!Number.isFinite(t)||t<0))throw new TypeError("addAudioChunk's third argument (timestamp), when provided, must be a non-negative real number.");let i=new Uint8Array(n.byteLength);n.copyTo(i),this.addAudioChunkRaw(i,n.type,t??n.timestamp,n.duration,e)}addAudioChunkRaw(n,e,t,i,r){if(!(n instanceof Uint8Array))throw new TypeError("addAudioChunkRaw's first argument (data) must be an instance of Uint8Array.");if(e!=="key"&&e!=="delta")throw new TypeError("addAudioChunkRaw's second argument (type) must be either 'key' or 'delta'.");if(!Number.isFinite(t)||t<0)throw new TypeError("addAudioChunkRaw's third argument (timestamp) must be a non-negative real number.");if(!Number.isFinite(i)||i<0)throw new TypeError("addAudioChunkRaw's fourth argument (duration) must be a non-negative real number.");if(r&&typeof r!="object")throw new TypeError("addAudioChunkRaw's fifth argument (meta), when provided, must be an object.");if(je(this,Va,Oc).call(this),!P(this,Ce).audio)throw new Error("No audio track declared.");if(typeof P(this,Ce).fastStart=="object"&&P(this,Ot).samples.length===P(this,Ce).fastStart.expectedAudioChunks)throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${P(this,Ce).fastStart.expectedAudioChunks}).`);let s=je(this,za,Nc).call(this,P(this,Ot),n,e,t,i,r);if(P(this,Ce).fastStart==="fragmented"&&P(this,Vt)){for(;P(this,Xi).length>0&&P(this,Xi)[0].decodeTimestamp<=s.decodeTimestamp;){let a=P(this,Xi).shift();je(this,zn,Qn).call(this,P(this,Vt),a)}s.decodeTimestamp<=P(this,Vt).lastDecodeTimestamp?je(this,zn,Qn).call(this,P(this,Ot),s):P(this,qi).push(s)}else je(this,zn,Qn).call(this,P(this,Ot),s)}finalize(){if(P(this,Ls))throw new Error("Cannot finalize a muxer more than once.");if(P(this,Ce).fastStart==="fragmented"){for(let e of P(this,Xi))je(this,zn,Qn).call(this,P(this,Vt),e);for(let e of P(this,qi))je(this,zn,Qn).call(this,P(this,Ot),e);je(this,qa,Yc).call(this,!1)}else P(this,Vt)&&je(this,Ds,Xa).call(this,P(this,Vt)),P(this,Ot)&&je(this,Ds,Xa).call(this,P(this,Ot));let n=[P(this,Vt),P(this,Ot)].filter(Boolean);if(P(this,Ce).fastStart==="in-memory"){let e;for(let i=0;i<2;i++){let r=Ua(n,P(this,Pr)),s=P(this,De).measureBox(r);e=P(this,De).measureBox(P(this,hn));let a=P(this,De).pos+s+e;for(let o of P(this,Ir)){o.offset=a;for(let{data:l}of o.samples)a+=l.byteLength,e+=l.byteLength}if(a<2**32)break;e>=2**32&&(P(this,hn).largeSize=!0)}let t=Ua(n,P(this,Pr));P(this,De).writeBox(t),P(this,hn).size=e,P(this,De).writeBox(P(this,hn));for(let i of P(this,Ir))for(let r of i.samples)P(this,De).write(r.data),r.data=null}else if(P(this,Ce).fastStart==="fragmented"){let e=P(this,De).pos,t=Kg(n);P(this,De).writeBox(t);let i=P(this,De).pos-e;P(this,De).seek(P(this,De).pos-4),P(this,De).writeU32(i)}else{let e=P(this,De).offsets.get(P(this,hn)),t=P(this,De).pos-e;P(this,hn).size=t,P(this,hn).largeSize=t>=2**32,P(this,De).patchBox(P(this,hn));let i=Ua(n,P(this,Pr));if(typeof P(this,Ce).fastStart=="object"){P(this,De).seek(P(this,$a)),P(this,De).writeBox(i);let r=e-P(this,De).pos;P(this,De).writeBox(dg(r))}else P(this,De).writeBox(i)}je(this,Dr,Ns).call(this),P(this,De).finalize(),Ut(this,Ls,!0)}};Ce=new WeakMap;De=new WeakMap;$a=new WeakMap;hn=new WeakMap;Vt=new WeakMap;Ot=new WeakMap;Pr=new WeakMap;Ir=new WeakMap;Wc=new WeakMap;Xi=new WeakMap;qi=new WeakMap;Ls=new WeakMap;Lc=new WeakSet;pd=function(n){if(typeof n!="object")throw new TypeError("The muxer requires an options object to be passed to its constructor.");if(!(n.target instanceof Ya))throw new TypeError("The target must be provided and an instance of Target.");if(n.video){if(!hy.includes(n.video.codec))throw new TypeError(`Unsupported video codec: ${n.video.codec}`);if(!Number.isInteger(n.video.width)||n.video.width<=0)throw new TypeError(`Invalid video width: ${n.video.width}. Must be a positive integer.`);if(!Number.isInteger(n.video.height)||n.video.height<=0)throw new TypeError(`Invalid video height: ${n.video.height}. Must be a positive integer.`);let e=n.video.rotation;if(typeof e=="number"&&![0,90,180,270].includes(e))throw new TypeError(`Invalid video rotation: ${e}. Has to be 0, 90, 180 or 270.`);if(Array.isArray(e)&&(e.length!==9||e.some(t=>typeof t!="number")))throw new TypeError(`Invalid video transformation matrix: ${e.join()}`);if(n.video.frameRate!==void 0&&(!Number.isInteger(n.video.frameRate)||n.video.frameRate<=0))throw new TypeError(`Invalid video frame rate: ${n.video.frameRate}. Must be a positive integer.`)}if(n.audio){if(!uy.includes(n.audio.codec))throw new TypeError(`Unsupported audio codec: ${n.audio.codec}`);if(!Number.isInteger(n.audio.numberOfChannels)||n.audio.numberOfChannels<=0)throw new TypeError(`Invalid number of audio channels: ${n.audio.numberOfChannels}. Must be a positive integer.`);if(!Number.isInteger(n.audio.sampleRate)||n.audio.sampleRate<=0)throw new TypeError(`Invalid audio sample rate: ${n.audio.sampleRate}. Must be a positive integer.`)}if(n.firstTimestampBehavior&&!fy.includes(n.firstTimestampBehavior))throw new TypeError(`Invalid first timestamp behavior: ${n.firstTimestampBehavior}`);if(typeof n.fastStart=="object"){if(n.video){if(n.fastStart.expectedVideoChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedVideoChunks'.");if(!Number.isInteger(n.fastStart.expectedVideoChunks)||n.fastStart.expectedVideoChunks<0)throw new TypeError("'expectedVideoChunks' must be a non-negative integer.")}if(n.audio){if(n.fastStart.expectedAudioChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedAudioChunks'.");if(!Number.isInteger(n.fastStart.expectedAudioChunks)||n.fastStart.expectedAudioChunks<0)throw new TypeError("'expectedAudioChunks' must be a non-negative integer.")}}else if(![!1,"in-memory","fragmented"].includes(n.fastStart))throw new TypeError("'fastStart' option must be false, 'in-memory', 'fragmented' or an object.");if(n.minFragmentDuration!==void 0&&(!Number.isFinite(n.minFragmentDuration)||n.minFragmentDuration<0))throw new TypeError("'minFragmentDuration' must be a non-negative number.")};Dc=new WeakSet;md=function(){if(P(this,De).writeBox(ug({holdsAvc:P(this,Ce).video?.codec==="avc",fragmented:P(this,Ce).fastStart==="fragmented"})),Ut(this,$a,P(this,De).pos),P(this,Ce).fastStart==="in-memory")Ut(this,hn,Cc(!1));else if(P(this,Ce).fastStart!=="fragmented"){if(typeof P(this,Ce).fastStart=="object"){let n=je(this,$c,gd).call(this);P(this,De).seek(P(this,De).pos+n)}Ut(this,hn,Cc(!0)),P(this,De).writeBox(P(this,hn))}je(this,Dr,Ns).call(this)};$c=new WeakSet;gd=function(){if(typeof P(this,Ce).fastStart!="object")return;let n=0,e=[P(this,Ce).fastStart.expectedVideoChunks,P(this,Ce).fastStart.expectedAudioChunks];for(let t of e)t&&(n+=8*Math.ceil(2/3*t),n+=4*t,n+=12*Math.ceil(2/3*t),n+=4*t,n+=8*t);return n+=4096,n};kc=new WeakSet;yd=function(){if(P(this,Ce).video&&Ut(this,Vt,{id:1,info:{type:"video",codec:P(this,Ce).video.codec,width:P(this,Ce).video.width,height:P(this,Ce).video.height,rotation:P(this,Ce).video.rotation??0,decoderConfig:null},timescale:P(this,Ce).video.frameRate??57600,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),P(this,Ce).audio&&(Ut(this,Ot,{id:P(this,Ce).video?2:1,info:{type:"audio",codec:P(this,Ce).audio.codec,numberOfChannels:P(this,Ce).audio.numberOfChannels,sampleRate:P(this,Ce).audio.sampleRate,decoderConfig:null},timescale:P(this,Ce).audio.sampleRate,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),P(this,Ce).audio.codec==="aac")){let n=je(this,Xc,vd).call(this,2,P(this,Ce).audio.sampleRate,P(this,Ce).audio.numberOfChannels);P(this,Ot).info.decoderConfig={codec:P(this,Ce).audio.codec,description:n,numberOfChannels:P(this,Ce).audio.numberOfChannels,sampleRate:P(this,Ce).audio.sampleRate}}};Xc=new WeakSet;vd=function(n,e,t){let r=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350].indexOf(e),s=t,a="";a+=n.toString(2).padStart(5,"0"),a+=r.toString(2).padStart(4,"0"),r===15&&(a+=e.toString(2).padStart(24,"0")),a+=s.toString(2).padStart(4,"0");let o=Math.ceil(a.length/8)*8;a=a.padEnd(o,"0");let l=new Uint8Array(a.length/8);for(let c=0;c<a.length;c+=8)l[c/8]=parseInt(a.slice(c,c+8),2);return l};za=new WeakSet;Nc=function(n,e,t,i,r,s,a){let o=i/1e6,l=(i-(a??0))/1e6,c=r/1e6,h=je(this,qc,xd).call(this,o,l,n);return o=h.presentationTimestamp,l=h.decodeTimestamp,s?.decoderConfig&&(n.info.decoderConfig===null?n.info.decoderConfig=s.decoderConfig:Object.assign(n.info.decoderConfig,s.decoderConfig)),{presentationTimestamp:o,decodeTimestamp:l,duration:c,data:e,size:e.byteLength,type:t,timescaleUnitsToNextSample:Hn(c,n.timescale)}};zn=new WeakSet;Qn=function(n,e){P(this,Ce).fastStart!=="fragmented"&&n.samples.push(e);let t=Hn(e.presentationTimestamp-e.decodeTimestamp,n.timescale);if(n.lastTimescaleUnits!==null){let r=Hn(e.decodeTimestamp,n.timescale,!1),s=Math.round(r-n.lastTimescaleUnits);if(n.lastTimescaleUnits+=s,n.lastSample.timescaleUnitsToNextSample=s,P(this,Ce).fastStart!=="fragmented"){let a=Ha(n.timeToSampleTable);a.sampleCount===1?(a.sampleDelta=s,a.sampleCount++):a.sampleDelta===s?a.sampleCount++:(a.sampleCount--,n.timeToSampleTable.push({sampleCount:2,sampleDelta:s}));let o=Ha(n.compositionTimeOffsetTable);o.sampleCompositionTimeOffset===t?o.sampleCount++:n.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t})}}else n.lastTimescaleUnits=0,P(this,Ce).fastStart!=="fragmented"&&(n.timeToSampleTable.push({sampleCount:1,sampleDelta:Hn(e.duration,n.timescale)}),n.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t}));n.lastSample=e;let i=!1;if(!n.currentChunk)i=!0;else{let r=e.presentationTimestamp-n.currentChunk.startTimestamp;if(P(this,Ce).fastStart==="fragmented"){let s=P(this,Vt)??P(this,Ot),a=P(this,Ce).minFragmentDuration??1;n===s&&e.type==="key"&&r>=a&&(i=!0,je(this,qa,Yc).call(this))}else i=r>=.5}i&&(n.currentChunk&&je(this,Ds,Xa).call(this,n),n.currentChunk={startTimestamp:e.presentationTimestamp,samples:[]}),n.currentChunk.samples.push(e)};qc=new WeakSet;xd=function(n,e,t){let i=P(this,Ce).firstTimestampBehavior==="strict",r=t.lastDecodeTimestamp===-1;if(i&&r&&e!==0)throw new Error(`The first chunk for your media track must have a timestamp of 0 (received DTS=${e}).Non-zero first timestamps are often caused by directly piping frames or audio data from a MediaStreamTrack into the encoder. Their timestamps are typically relative to the age of thedocument, which is probably what you want.
7
+
8
+ If you want to offset all timestamps of a track such that the first one is zero, set firstTimestampBehavior: 'offset' in the options.
9
+ `);if(P(this,Ce).firstTimestampBehavior==="offset"||P(this,Ce).firstTimestampBehavior==="cross-track-offset"){t.firstDecodeTimestamp===void 0&&(t.firstDecodeTimestamp=e);let a;P(this,Ce).firstTimestampBehavior==="offset"?a=t.firstDecodeTimestamp:a=Math.min(P(this,Vt)?.firstDecodeTimestamp??1/0,P(this,Ot)?.firstDecodeTimestamp??1/0),e-=a,n-=a}if(e<t.lastDecodeTimestamp)throw new Error(`Timestamps must be monotonically increasing (DTS went from ${t.lastDecodeTimestamp*1e6} to ${e*1e6}).`);return t.lastDecodeTimestamp=e,{presentationTimestamp:n,decodeTimestamp:e}};Ds=new WeakSet;Xa=function(n){if(P(this,Ce).fastStart==="fragmented")throw new Error("Can't finalize individual chunks if 'fastStart' is set to 'fragmented'.");if(n.currentChunk){if(n.finalizedChunks.push(n.currentChunk),P(this,Ir).push(n.currentChunk),(n.compactlyCodedChunkTable.length===0||Ha(n.compactlyCodedChunkTable).samplesPerChunk!==n.currentChunk.samples.length)&&n.compactlyCodedChunkTable.push({firstChunk:n.finalizedChunks.length,samplesPerChunk:n.currentChunk.samples.length}),P(this,Ce).fastStart==="in-memory"){n.currentChunk.offset=0;return}n.currentChunk.offset=P(this,De).pos;for(let e of n.currentChunk.samples)P(this,De).write(e.data),e.data=null;je(this,Dr,Ns).call(this)}};qa=new WeakSet;Yc=function(n=!0){if(P(this,Ce).fastStart!=="fragmented")throw new Error("Can't finalize a fragment unless 'fastStart' is set to 'fragmented'.");let e=[P(this,Vt),P(this,Ot)].filter(o=>o&&o.currentChunk);if(e.length===0)return;let t=lg(this,Wc)._++;if(t===1){let o=Ua(e,P(this,Pr),!0);P(this,De).writeBox(o)}let i=P(this,De).pos,r=rd(t,e);P(this,De).writeBox(r);{let o=Cc(!1),l=0;for(let h of e)for(let u of h.currentChunk.samples)l+=u.size;let c=P(this,De).measureBox(o)+l;c>=2**32&&(o.largeSize=!0,c=P(this,De).measureBox(o)+l),o.size=c,P(this,De).writeBox(o)}for(let o of e){o.currentChunk.offset=P(this,De).pos,o.currentChunk.moofOffset=i;for(let l of o.currentChunk.samples)P(this,De).write(l.data),l.data=null}let s=P(this,De).pos;P(this,De).seek(P(this,De).offsets.get(r));let a=rd(t,e);P(this,De).writeBox(a),P(this,De).seek(s);for(let o of e)o.finalizedChunks.push(o.currentChunk),P(this,Ir).push(o.currentChunk),o.currentChunk=null;n&&je(this,Dr,Ns).call(this)};Dr=new WeakSet;Ns=function(){P(this,De)instanceof Gc&&P(this,De).flush()};Va=new WeakSet;Oc=function(){if(P(this,Ls))throw new Error("Cannot add new video or audio chunks after the file has been finalized.")};function Kc(n){return(n.lap??0)-(n.shifted?1:0)}var jc=class{set;frame;laps;top;invariant;frames;stores=new Map;box=null;constructor(e,t,i,r=1){this.set=e,this.frame=t,this.frames=i,this.laps=e.periodic?r:1,this.top=this.laps-1,this.invariant=i.requirements(e.def.frame,t).channels.size===0}storeLap(e){return this.invariant?0:e}lapKey(e){return this.invariant?e<this.top?"joined":"top":String(e)}store(e){let t=this.storeLap(e),i=this.stores.get(t);return i===void 0&&(i={buf:new Float64Array(3*this.set.samples),done:new Uint8Array(this.set.tracks),all:!1},this.stores.set(t,i)),i}ensure(e,t){let i=py(t),r=this.store(i);if(r.done[e]===1)return r.buf;let s=this.set,a=this.storeLap(i),o=s.start(e);for(let l=0;l<s.count(e);l++)r.buf.set(this.frames.transform(s.position(e,l),s.def.frame,this.frame,{set:s,track:e,sample:l,shifted:!1,lap:a}),3*(o+l));return r.done[e]=1,r.buf}lapPositions(e){let t=this.store(e);if(!t.all){for(let i=0;i<this.set.tracks;i++)this.ensure(i,e);t.all=!0}return t.buf}get positions(){return this.lapPositions(0)}get shifted(){return this.set.periodic?this.lapPositions(-1):null}track(e,t){let i=this.ensure(e,t),r=this.set.start(e);return i.subarray(3*r,3*(r+this.set.count(e)))}gpuSample(e,t,i,r,s=0){let a=i===this.set.count(e)-1&&t<this.top,o=this.ensure(e,a?t+1:t),l=3*(this.set.start(e)+(a?0:i));r[s]=o[l],r[s+1]=o[l+1],r[s+2]=o[l+2]}bounds(e){if(e===void 0&&this.box!==null)return this.box;let t=[1/0,1/0,1/0,-1/0,-1/0,-1/0];for(let i=0;i<=(this.invariant?0:this.top);i++){let r=e===void 0?this.lapPositions(i):this.track(e,i);for(let s=0;s<r.length;s+=3)for(let a=0;a<3;a++){let o=r[s+a];o<t[a]&&(t[a]=o),o>t[a+3]&&(t[a+3]=o)}}return e===void 0&&(this.box=t),t}vertex(e,t,i,r=0){let s=this.ensure(e,Kc(t)),a=this.set.start(e);if("sample"in t){let c=3*(a+t.sample);i[r]=s[c],i[r+1]=s[c+1],i[r+2]=s[c+2];return}let o=3*(a+t.k),l=t.w;for(let c=0;c<3;c++)i[r+c]=(1-l)*s[o+c]+l*s[o+3+c]}},py=n=>n===!0?-1:n===!1?0:n,Zc=class{channel;clocks;u;constructor(e,t){this.channel=t,this.clocks=[],this.u=new Float64Array(e.samples);for(let i=0;i<e.tracks;i++){let r=new Bi(e,i,t),s=e.start(i);for(let a=0;a<r.m;a++)this.u[s+a]=r.at(a);this.clocks.push(r)}}},ja=class{scene;sets;frames;geometries=new Map;readingsBy=new Map;bodyTrails=new Map;constructor(e,t){this.scene=e,this.sets=new yi(e,t),this.frames=new pi(e)}geometry(e,t){let i=`${e}\0${t}`,r=this.geometries.get(i);return r||(r=new jc(this.sets.get(e),t,this.frames,Zt(this.scene.clock)),this.geometries.set(i,r)),r}hasChannel(e,t){return t===yt||this.sets.get(e).hasChannel(t)}readings(e,t){let i=`${e}\0${t}`,r=this.readingsBy.get(i);return r||(r=new Zc(this.sets.get(e),t),this.readingsBy.set(i,r)),r}bodyTrail(e,t,i,r){let s=`${e}\0${t}\0${i}\0${r}`,a=this.bodyTrails.get(s);return a||(a=new Jc(this.frames,e,t,this.sets.get(i),r),this.bodyTrails.set(s,a)),a}};function Sd(n,e,t,i,r,s){let a=Zt(r),o=nn(a*fi(e.reading(r,s)),a),{k:l,w:c}=e.locate(o.u);return(1-c)*n.channelAt(i,t,l,!1,o.lap)+c*n.channelAt(i,t,l+1,!1,o.lap)}var Za=n=>n,bd=1<<20,Os=[bd,0,-bd,0],my=n=>[0,-1,n,2];function Ja(n,e,t,i){let r=0,s=n.m;for(;r<s;){let a=r+s>>1,o=i(n.at(a));o>e||t&&o===e?s=a:r=a+1}return r}function gy(n,e,t,i,r=Za){if(e===t)return{range:[...Os],laps:null,pieces:[]};let s=i-1,a=nn(e,i),o=nn(t,i),l=Dt(n,a.u,!1,a.lap),c=Dt(n,o.u,!1,o.lap),h=a.lap,u=r(a.u),d=o.lap,f=r(o.u);f===0&&(d--,f=1);let g=[h,u,d,f],y=w=>r(n.at(w)),m=w=>w<s?n.m-2:n.m-1,p=(w,b)=>w<d||w===d&&b<f,M=(w,b)=>w>h||w===h&&u<b,S=Ja(n,u,!1,r),x=S<=m(h)?[h,S]:h<s?[h+1,0]:null;x!==null&&!p(x[0],y(x[1]))&&(x=null);let A=Math.min(Ja(n,f,!0,r)-1,m(d)),T=A>=0?[d,A]:null;if(T!==null&&!M(T[0],y(T[1]))&&(T=null),x===null||T===null||x[0]>T[0]||x[0]===T[0]&&x[1]>T[1])return{range:g,laps:null,pieces:[[l,c]]};let R=[[l,{sample:x[1],shifted:!1,lap:x[0]}],[{sample:T[1],shifted:!1,lap:T[0]},c]],k=x[0]===T[0]&&x[1]===T[1];return{range:g,laps:k?null:[x[0],T[1]===0?T[0]-1:T[0]],pieces:R}}function wd(n,e){return(n.reveal??"none")!=="none"||gi(n)||e.mode==="value"&&(n.before==="hidden"||n.after==="hidden")}function Md(n,e,t=1){return{reveal:n.reveal??"none",fraction:n.trail?.fraction??1,before:n.before,after:n.after,head:gi(n),periodic:e,laps:e?t:1}}function Ed(n,e,t,i,r=Za){let s=i.laps,a={range:my(s-1),laps:[0,s-1],pieces:[]};if(n===null)return{hidden:!1,reading:null,loop:null,head:null,...a};let o=fi(n.reading(e,t),i.before,i.after);if(o===null)return{hidden:!0,reading:null,loop:null,head:null,range:[...Os],laps:null,pieces:[]};let l=s*o,c=nn(l,s),h=i.head?Dt(n,c.u,!1,c.lap):null;if(i.reveal==="none")return{hidden:!1,reading:o,loop:l,head:h,...a};let u=i.reveal==="grow"?0:l-s*i.fraction;return u<0&&!i.periodic&&(u=0),{hidden:!1,reading:o,loop:l,head:h,...gy(n,u,l,s,r)}}function Ka(n){return n.samples-n.tracks}function yy(n,e){return n.start(e)-e}function Td(n,e){let t=0;for(let i=0;i<n.tracks;i++){let r=n.start(i),s=n.count(i);for(let a=0;a+1<s;a++)e(t++,r+a)}}function Ad(n,e,t){let i=new Float32Array(2*t*Ka(n));return Td(n,(r,s)=>{for(let a=0;a<t;a++)i[2*t*r+a]=e[t*s+a],i[2*t*r+t+a]=e[t*(s+1)+a]}),i}function Cd(n,e,t,i){let r=new Float32Array(2*e*(i-1));for(let s=0;s+1<i;s++)for(let a=0;a<e;a++)r[2*e*s+a]=n[e*(t+s)+a],r[2*e*s+e+a]=n[e*(t+s+1)+a];return r}function Rd(n,e,t,i,r){let s=n.set.count(e),a=n.track(e,t),o=[0,0,0];t<n.top&&n.gpuSample(e,t,s-1,o);for(let l=0;l+1<s;l++,r++)for(let c=0;c<3;c++)i[6*r+c]=a[3*l+c],i[6*r+3+c]=l+2===s&&t<n.top?o[c]:a[3*(l+1)+c]}function Pd(n,e){let t=new Float32Array(6*Ka(n.set));for(let i=0;i<n.set.tracks;i++)Rd(n,i,e,t,yy(n.set,i));return t}function Id(n,e,t){let i=new Float32Array(6*(n.set.count(e)-1));return Rd(n,e,t,i,0),i}function Ld(n,e){return("sample"in e?n.at(e.sample):(1-e.w)*n.at(e.k)+e.w*n.at(e.k+1))+Kc(e)}function Dd(n,e){let t=new Float32Array(4*Ka(n));return Td(n,(i,r)=>{t[4*i]=t[4*i+2]=e[r],t[4*i+1]=t[4*i+3]=e[r+1]}),t}function kd(n,e,t){let i=new Float32Array(4*(t-1));for(let r=0;r+1<t;r++)i[4*r]=i[4*r+2]=n[e+r],i[4*r+1]=i[4*r+3]=n[e+r+1];return i}function Nd(n){let e=new Float32Array(2*Ka(n)),t=0;for(let i=0;i<n.tracks;i++)for(let r=0;r+1<n.count(i);r++,t++)e[2*t]=e[2*t+1]=i;return e}var Jc=class{constructor(e,t,i,r,s){this.frames=e;this.body=t;this.display=i;this.set=r;this.track=s;this.m=r.count(s),this.invariant=e.bodyRequirements(t,i).channels.size===0}frames;body;display;set;track;m;invariant;laps=new Map;lap(e){let t=this.invariant?0:e,i=this.laps.get(t);if(i===void 0){i=new Float64Array(3*this.m);let{set:r,track:s}=this;for(let a=0;a<this.m;a++)i.set(this.frames.bodyPosition(this.body,this.display,{set:r,track:s,sample:a,shifted:!1,lap:t}),3*a);this.laps.set(t,i)}return i}vertex(e,t,i=0){let r=this.lap(Kc(e));if("sample"in e){let o=3*e.sample;t[i]=r[o],t[i+1]=r[o+1],t[i+2]=r[o+2];return}let s=3*e.k,a=e.w;for(let o=0;o<3;o++)t[i+o]=(1-a)*r[s+o]+a*r[s+3+o]}polyline(e,t,i,r,s){let a=0,o=u=>{this.vertex(u,s,3*a),a++},l=nn(t,r);if(t===i)return o(Dt(e,l.u,!1,l.lap)),a;let c=nn(i,r),h=(u,d,f)=>{let g=Ja(e,d,!1,Za),y=Ja(e,f,!0,Za);y>g&&(s.set(this.lap(u).subarray(3*g,3*y),3*a),a+=y-g)};if(l.lap===c.lap)return o(Dt(e,l.u,!1,l.lap)),h(l.lap,l.u,c.u),o(Dt(e,c.u,!1,c.lap)),a;o(Dt(e,l.u,!1,l.lap)),h(l.lap,l.u,1);for(let u=l.lap+1;u<c.lap;u++)o(Dt(e,0,!1,u)),h(u,0,1);return o(Dt(e,0,!1,c.lap)),c.u===0||(h(c.lap,0,c.u),o(Dt(e,c.u,!1,c.lap))),a}};function Od(n,e,t){return(Math.ceil(e*t)+2)*(n+1)+2}var Ud="\u2212";function rn(n,e){if(!Number.isFinite(n))return Number.isNaN(n)?"NaN":n>0?"\u221E":`${Ud}\u221E`;n===0&&(n=0);let t;if(e!==void 0)t=n.toPrecision(e);else if(Number.isInteger(n)&&Math.abs(n)<1e21)t=String(n);else{t=n.toPrecision(6);let[i,r]=t.split("e"),s=i.includes(".")?i.replace(/0+$/,"").replace(/\.$/,""):i;t=r===void 0?s:`${s}e${r}`}return t.replace("e+","e").replace(/-/g,Ud)}function eo(n,e,t){let i=it(n.scene,t.variable);if(i?.kind!=="selector"||i.parameter===void 0)return[];let r=[];for(let s of Es(n,t.domain)){let a=e.get(s);if(!Object.hasOwn(a.def.parameters??{},i.parameter))continue;let o=a.parameter(i.parameter,"2.9");for(let l=0;l<o.length;l++)r.push(o[l])}return r.sort((s,a)=>s-a),r.filter((s,a)=>a===0||s!==r[a-1])}function Us(n,e){let t=-1;for(let i=0;i<n.length;i++)(t<0||Math.abs(n[i]-e)<Math.abs(n[t]-e))&&(t=i);return t}var to=8;function kr(n){return to*(n.laps??1)}function no(n,e,t,i,r,s){return n+Math.max(0,e)*i*r/(t*s)}function io(n,e){return(Math.floor(n)%e+e)%e}function ro(n,e){let t=(n%e+e)%e/e;return t<1?t:0}function Fd(n,e){return Qc(n,e).join("")}function Qc(n,e){let{scene:t,geometry:i,state:r}=n,s=r.panels[n.panel];if(s===void 0||!Object.hasOwn(r.panels,n.panel))return[];let a={scene:t,state:r,panel:s},o=t.views[s.view],l=t.clock.steps,c=(n.frameIndex%l+l)%l,h=n.progress??c/l,u,d=()=>{if(u===void 0){let g=Tn(a,o.driver.sets);u=g===null?null:{setId:g,track:Er(a,o.driver.member,i.sets.get(g))}}return u},f=[];for(let g of e)if(typeof g=="string")f.push(g);else if("clock"in g)f.push(String(g.clock==="index"?c:l));else if("var"in g){let y=mi(a,g.var),m=it(t,g.var);typeof y=="number"?f.push(rn(y,g.digits)):typeof y=="boolean"?f.push(y?"on":"off"):m?.kind==="choice"&&m.labels!==void 0?f.push(m.labels[m.values.indexOf(y)]??y):f.push(y)}else{let y=d();if(y===null){f.push("\u2014");continue}let m=i.sets.get(y.setId);if("member"in g)f.push(rn(m.parameter(g.member,"2.9")[y.track],g.digits));else if("attr"in g)f.push(rn((g.factor??1)*m.attr(g.attr)+(g.offset??0),g.digits));else{let p=i.readings(y.setId,r.clock.channel).clocks[y.track];m.hasChannel(g.channel)||I("2.9",`track set ${y.setId} lacks channel ${JSON.stringify(g.channel)}`),f.push(rn(Sd(m,p,y.track,g.channel,t.clock,h),g.digits))}}return f}function Bd(n){let e=[""],t=[];if(n.forEach((a,o)=>{typeof a=="string"?e[e.length-1]+=a:(t.push(o),e.push(""))}),t.length===0)return null;let i=a=>a.every(o=>o.trim()===""),r=[];for(let a=0;a<t.length;a++){let o=e[a].split(","),l=e[a+1].split(",");if((a>0?o.length<2||!i(o.slice(1,-1)):!i(o.slice(0,-1)))||a===t.length-1&&!i(l.slice(1)))return null;let c=o[o.length-1].replace(/\s*[=:]\s*$/,"").trim();if(c==="")return null;let h=n[t[a]],u="clock"in h?5:"channel"in h?(h.digits??6)+5:null;r.push({label:c,part:t[a],unit:l[0].trim(),width:u})}let s=a=>"attr"in n[a.part];return[...r.filter(a=>!s(a)),...r.filter(s)]}var Qa=class{times=[];reset(){this.times.length=0}note(e){this.times.push(e);let t=0;for(;t<this.times.length&&this.times[t]<e-1e3;)t++;t>0&&this.times.splice(0,t)}report(e){let t=this.times;if(t.length<2||e-t[0]<900||e-t[t.length-1]>1e3)return null;let i=[];for(let o=1;o<t.length;o++)i.push(t[o]-t[o-1]);let r=[...i].sort((o,l)=>o-l),s=r[Math.floor(r.length/10)],a=i.filter(o=>o>1.5*s).length;return{drawn:t.length,late:a,refresh:s}}};function eh(n){return n===null?"\u2013\u2013 fps":`${n.drawn} fps`}function th(n){if(n===null)return"Frames drawn per second during playback";let e=Math.round(1e3/n.refresh);return`${n.drawn} frames drawn in the last second, ${n.late} late, on a display refreshing about ${e} times a second`}function zd(n,e,t){let i=e?10:1;switch(n){case" ":case"k":case"K":return{kind:"toggle"};case"ArrowRight":case".":return{kind:"step",by:i};case"ArrowLeft":case",":return{kind:"step",by:-i};case">":return{kind:"step",by:10};case"<":return{kind:"step",by:-10};case"Home":return{kind:"seek",frame:0};case"f":case"F":return{kind:"fit"};case"ArrowUp":return{kind:"slider",by:i};case"ArrowDown":return{kind:"slider",by:-i}}return/^[0-9]$/.test(n)?{kind:"seek",frame:Math.round(t*Number(n)/10)%t}:null}function Vd(n,e,t){let i=t.startsWith("Arrow")||t==="Home"||t==="End"||t==="PageUp"||t==="PageDown";return n==="BUTTON"||n==="INPUT"&&e==="checkbox"?t===" "||t==="Enter":n==="INPUT"&&e==="range"?i:n==="SELECT"?i||t==="Enter"||t.length===1:n==="TEXTAREA"||n==="INPUT"}function vy(n,e){let t=new Set([e]);for(let i of Object.values(n.track_sets)){let r=i?.parameters;if(r===void 0||!Object.hasOwn(r,e))continue;let s=r[e],a=s.label??e;t.add(s.unit?`${a}, ${s.unit}`:a)}return t}function Hd(n,e,t){for(let i of e.layers){if(i.kind!=="track"||i.color===void 0||typeof i.color=="string"||!("parameter"in i.color))continue;let r=i.color.parameter;if(vy(n,r).has(t))for(let[s,a]of Object.entries(n.variables??{})){if(a===void 0||a.kind!=="selector"||a.scope==="panel"||a.by==="index"||a.parameter!==r)continue;let o=(n.controls??[]).find(l=>l.kind==="slider"&&l.variable===s);return{variable:s,label:o?.label??s,domain:o?.domain??i.sets}}}return null}function Gd(n,e,t,i){return Us(n,e+Math.min(1,Math.max(0,i))*(t-e))}var wn={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},On={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},gf=0,Ph=1,yf=2;var Ih=1,vf=2,qn=3,li=0,Qt=1,Mn=2,Un=0,tr=1,Lh=2,Dh=3,kh=4,xf=5,Ti=100,_f=101,bf=102,Sf=103,wf=104,Mf=200,Ef=201,Tf=202,Af=203,Ro=204,Po=205,Cf=206,Rf=207,Pf=208,If=209,Lf=210,Df=211,kf=212,Nf=213,Of=214,tl=0,nl=1,il=2,nr=3,rl=4,sl=5,al=6,ol=7,Nh=0,Uf=1,Ff=2,ui=0,Bf=1,zf=2,Vf=3,Hf=4,Gf=5,Wf=6,$f=7;var Oh=300,cr=301,hr=302,ll=303,cl=304,ua=306,Io=1e3,Ei=1001,Lo=1002,Bt=1003,Xf=1004;var da=1005;var kn=1006,hl=1007;var Ii=1008;var Yn=1009,Uh=1010,Fh=1011,rs=1012,ul=1013,Li=1014,En=1015,ss=1016,dl=1017,fl=1018,as=1020,Bh=35902,zh=35899,Vh=1021,Hh=1022,an=1023,Yr=1026,os=1027,Gh=1028,pl=1029,Wh=1030,ml=1031;var gl=1033,fa=33776,pa=33777,ma=33778,ga=33779,yl=35840,vl=35841,xl=35842,_l=35843,bl=36196,Sl=37492,wl=37496,Ml=37808,El=37809,Tl=37810,Al=37811,Cl=37812,Rl=37813,Pl=37814,Il=37815,Ll=37816,Dl=37817,kl=37818,Nl=37819,Ol=37820,Ul=37821,Fl=36492,Bl=36494,zl=36495,Vl=36283,Hl=36284,Gl=36285,Wl=36286;var $s=2300,Do=2301,Co=2302,Mh=2400,Eh=2401,Th=2402;var qf=3200,Yf=3201;var jf=0,Zf=1,di="",pn="srgb",ci="srgb-linear",Xs="linear",at="srgb";var er=7680;var Ah=519,Jf=512,Kf=513,Qf=514,$h=515,ep=516,tp=517,np=518,ip=519,ko=35044,ur=35048;var ya="300 es",Ln=2e3,qs=2001;var Wn=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){let i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){let i=this._listeners;if(i===void 0)return;let r=i[e];if(r!==void 0){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let i=t[e.type];if(i!==void 0){e.target=this;let r=i.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,e);e.target=null}}},Ht=["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"],Wd=1234567,Gs=Math.PI/180,jr=180/Math.PI;function ai(){let n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Ht[n&255]+Ht[n>>8&255]+Ht[n>>16&255]+Ht[n>>24&255]+"-"+Ht[e&255]+Ht[e>>8&255]+"-"+Ht[e>>16&15|64]+Ht[e>>24&255]+"-"+Ht[t&63|128]+Ht[t>>8&255]+"-"+Ht[t>>16&255]+Ht[t>>24&255]+Ht[i&255]+Ht[i>>8&255]+Ht[i>>16&255]+Ht[i>>24&255]).toLowerCase()}function Xe(n,e,t){return Math.max(e,Math.min(t,n))}function Xh(n,e){return(n%e+e)%e}function xy(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function _y(n,e,t){return n!==e?(t-n)/(e-n):0}function Ws(n,e,t){return(1-t)*n+t*e}function by(n,e,t,i){return Ws(n,e,1-Math.exp(-t*i))}function Sy(n,e=1){return e-Math.abs(Xh(n,e*2)-e)}function wy(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function My(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function Ey(n,e){return n+Math.floor(Math.random()*(e-n+1))}function Ty(n,e){return n+Math.random()*(e-n)}function Ay(n){return n*(.5-Math.random())}function Cy(n){n!==void 0&&(Wd=n);let e=Wd+=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 Ry(n){return n*Gs}function Py(n){return n*jr}function Iy(n){return(n&n-1)===0&&n!==0}function Ly(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Dy(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function ky(n,e,t,i,r){let s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+i)/2),h=a((e+i)/2),u=s((e-i)/2),d=a((e-i)/2),f=s((i-e)/2),g=a((i-e)/2);switch(r){case"XYX":n.set(o*h,l*u,l*d,o*c);break;case"YZY":n.set(l*d,o*h,l*u,o*c);break;case"ZXZ":n.set(l*u,l*d,o*h,o*c);break;case"XZX":n.set(o*h,l*g,l*f,o*c);break;case"YXY":n.set(l*f,o*h,l*g,o*c);break;case"ZYZ":n.set(l*g,l*f,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function In(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function st(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}var qh={DEG2RAD:Gs,RAD2DEG:jr,generateUUID:ai,clamp:Xe,euclideanModulo:Xh,mapLinear:xy,inverseLerp:_y,lerp:Ws,damp:by,pingpong:Sy,smoothstep:wy,smootherstep:My,randInt:Ey,randFloat:Ty,randFloatSpread:Ay,seededRandom:Cy,degToRad:Ry,radToDeg:Py,isPowerOfTwo:Iy,ceilPowerOfTwo:Ly,floorPowerOfTwo:Dy,setQuaternionFromProperEuler:ky,normalize:st,denormalize:In},ke=class n{constructor(e=0,t=0){n.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[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=Xe(this.x,e.x,t.x),this.y=Xe(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Xe(this.x,e,t),this.y=Xe(this.y,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Xe(i,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 i=this.dot(e)/t;return Math.acos(Xe(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,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 i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*i-a*r+e.x,this.y=s*r+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},bn=class{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,a,o){let l=i[r+0],c=i[r+1],h=i[r+2],u=i[r+3],d=s[a+0],f=s[a+1],g=s[a+2],y=s[a+3];if(o===0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=g,e[t+3]=y;return}if(u!==y||l!==d||c!==f||h!==g){let m=1-o,p=l*d+c*f+h*g+u*y,M=p>=0?1:-1,S=1-p*p;if(S>Number.EPSILON){let A=Math.sqrt(S),T=Math.atan2(A,p*M);m=Math.sin(m*T)/A,o=Math.sin(o*T)/A}let x=o*M;if(l=l*m+d*x,c=c*m+f*x,h=h*m+g*x,u=u*m+y*x,m===1-o){let A=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=A,c*=A,h*=A,u*=A}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,i,r,s,a){let o=i[r],l=i[r+1],c=i[r+2],h=i[r+3],u=s[a],d=s[a+1],f=s[a+2],g=s[a+3];return e[t]=o*g+h*u+l*f-c*d,e[t+1]=l*g+h*d+c*u-o*f,e[t+2]=c*g+h*f+o*d-l*u,e[t+3]=h*g-o*u-l*d-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,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,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 i=e._x,r=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),h=o(r/2),u=o(s/2),d=l(i/2),f=l(r/2),g=l(s/2);switch(a){case"XYZ":this._x=d*h*u+c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u-d*f*g;break;case"YXZ":this._x=d*h*u+c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u+d*f*g;break;case"ZXY":this._x=d*h*u-c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u-d*f*g;break;case"ZYX":this._x=d*h*u-c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u+d*f*g;break;case"YZX":this._x=d*h*u+c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u-d*f*g;break;case"XZY":this._x=d*h*u-c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u+d*f*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],r=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],u=t[10],d=i+o+u;if(d>0){let f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-l)*f,this._y=(s-c)*f,this._z=(a-r)*f}else if(i>o&&i>u){let f=2*Math.sqrt(1+i-o-u);this._w=(h-l)/f,this._x=.25*f,this._y=(r+a)/f,this._z=(s+c)/f}else if(o>u){let f=2*Math.sqrt(1+o-i-u);this._w=(s-c)/f,this._x=(r+a)/f,this._y=.25*f,this._z=(l+h)/f}else{let f=2*Math.sqrt(1+u-i-o);this._w=(a-r)/f,this._x=(s+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(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=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Xe(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let r=Math.min(1,t/i);return this.slerp(e,r),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 i=e._x,r=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=i*h+a*o+r*c-s*l,this._y=r*h+a*l+s*o-i*c,this._z=s*h+a*c+i*l-r*o,this._w=a*h-i*o-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let i=this._x,r=this._y,s=this._z,a=this._w,o=a*e._w+i*e._x+r*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=i,this._y=r,this._z=s,this;let l=1-o*o;if(l<=Number.EPSILON){let f=1-t;return this._w=f*a+t*this._w,this._x=f*i+t*this._x,this._y=f*r+t*this._y,this._z=f*s+t*this._z,this.normalize(),this}let c=Math.sqrt(l),h=Math.atan2(c,o),u=Math.sin((1-t)*h)/c,d=Math.sin(t*h)/c;return this._w=a*u+this._w*d,this._x=i*u+this._x*d,this._y=r*u+this._y*d,this._z=s*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*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}},N=class n{constructor(e=0,t=0,i=0){n.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion($d.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion($d.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*a,this}applyQuaternion(e){let t=this.x,i=this.y,r=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*r-o*i),h=2*(o*t-s*r),u=2*(s*i-a*t);return this.x=t+l*c+a*u-o*h,this.y=i+l*h+o*c-s*u,this.z=r+l*u+s*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,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,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=Xe(this.x,e.x,t.x),this.y=Xe(this.y,e.y,t.y),this.z=Xe(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Xe(this.x,e,t),this.y=Xe(this.y,e,t),this.z=Xe(this.z,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Xe(i,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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,r=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-s*o,this.y=s*a-i*l,this.z=i*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return nh.copy(this).projectOnVector(e),this.sub(nh)}reflect(e){return this.sub(nh.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 i=this.dot(e)/t;return Math.acos(Xe(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}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,i){let r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,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(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,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,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},nh=new N,$d=new bn,ze=class n{constructor(e,t,i,r,s,a,o,l,c){n.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,a,o,l,c)}set(e,t,i,r,s,a,o,l,c){let h=this.elements;return h[0]=e,h[1]=r,h[2]=o,h[3]=t,h[4]=s,h[5]=l,h[6]=i,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,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.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 i=e.elements,r=t.elements,s=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],h=i[4],u=i[7],d=i[2],f=i[5],g=i[8],y=r[0],m=r[3],p=r[6],M=r[1],S=r[4],x=r[7],A=r[2],T=r[5],R=r[8];return s[0]=a*y+o*M+l*A,s[3]=a*m+o*S+l*T,s[6]=a*p+o*x+l*R,s[1]=c*y+h*M+u*A,s[4]=c*m+h*S+u*T,s[7]=c*p+h*x+u*R,s[2]=d*y+f*M+g*A,s[5]=d*m+f*S+g*T,s[8]=d*p+f*x+g*R,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],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-i*s*h+i*o*l+r*s*c-r*a*l}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=h*a-o*c,d=o*l-h*s,f=c*s-a*l,g=t*u+i*d+r*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let y=1/g;return e[0]=u*y,e[1]=(r*c-h*i)*y,e[2]=(o*i-r*a)*y,e[3]=d*y,e[4]=(h*t-r*l)*y,e[5]=(r*s-o*t)*y,e[6]=f*y,e[7]=(i*l-c*t)*y,e[8]=(a*t-i*s)*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,i,r,s,a,o){let l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-r*c,r*l,-r*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(ih.makeScale(e,t)),this}rotate(e){return this.premultiply(ih.makeRotation(-e)),this}translate(e,t){return this.premultiply(ih.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),i=Math.sin(e);return this.set(t,-i,0,i,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,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}},ih=new ze;function Yh(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Ys(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function rp(){let n=Ys("canvas");return n.style.display="block",n}var Xd={};function Zr(n){n in Xd||(Xd[n]=!0,console.warn(n))}function sp(n,e,t){return new Promise(function(i,r){function s(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:r();break;case n.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:i()}}setTimeout(s,t)})}var qd=new ze().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Yd=new ze().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Ny(){let n={enabled:!0,workingColorSpace:ci,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===at&&(r.r=oi(r.r),r.g=oi(r.g),r.b=oi(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===at&&(r.r=qr(r.r),r.g=qr(r.g),r.b=qr(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===di?Xs:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return Zr("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Zr("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[ci]:{primaries:e,whitePoint:i,transfer:Xs,toXYZ:qd,fromXYZ:Yd,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:pn},outputColorSpaceConfig:{drawingBufferColorSpace:pn}},[pn]:{primaries:e,whitePoint:i,transfer:at,toXYZ:qd,fromXYZ:Yd,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:pn}}}),n}var Ke=Ny();function oi(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function qr(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}var Nr,No=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{Nr===void 0&&(Nr=Ys("canvas")),Nr.width=e.width,Nr.height=e.height;let r=Nr.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=Nr}return i.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 i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=oi(s[a]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(oi(t[i]/255)*255):t[i]=oi(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Oy=0,Jr=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Oy++}),this.uuid=ai(),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):t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,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 i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(rh(r[a].image)):s.push(rh(r[a]))}else s=rh(r);i.url=s}return t||(e.images[this.uuid]=i),i}};function rh(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?No.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var Uy=0,sh=new N,Kt=class n extends Wn{constructor(e=n.DEFAULT_IMAGE,t=n.DEFAULT_MAPPING,i=Ei,r=Ei,s=kn,a=Ii,o=an,l=Yn,c=n.DEFAULT_ANISOTROPY,h=di){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Uy++}),this.uuid=ai(),this.name="",this.source=new Jr(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new ke(0,0),this.repeat=new ke(1,1),this.center=new ke(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ze,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}get width(){return this.source.getSize(sh).x}get height(){return this.source.getSize(sh).y}get depth(){return this.source.getSize(sh).z}get image(){return this.source.data}set image(e=null){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.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 i=e[t];if(i===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let i={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,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Oh)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Io:e.x=e.x-Math.floor(e.x);break;case Ei:e.x=e.x<0?0:1;break;case Lo: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 Io:e.y=e.y-Math.floor(e.y);break;case Ei:e.y=e.y<0?0:1;break;case Lo: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++}};Kt.DEFAULT_IMAGE=null;Kt.DEFAULT_MAPPING=Oh;Kt.DEFAULT_ANISOTROPY=1;var mt=class n{constructor(e=0,t=0,i=0,r=1){n.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}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,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*i+a[11]*r+a[15]*s,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,i,r,s,l=e.elements,c=l[0],h=l[4],u=l[8],d=l[1],f=l[5],g=l[9],y=l[2],m=l[6],p=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-y)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+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 S=(c+1)/2,x=(f+1)/2,A=(p+1)/2,T=(h+d)/4,R=(u+y)/4,k=(g+m)/4;return S>x&&S>A?S<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(S),r=T/i,s=R/i):x>A?x<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(x),i=T/r,s=k/r):A<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(A),i=R/s,r=k/s),this.set(i,r,s,t),this}let M=Math.sqrt((m-g)*(m-g)+(u-y)*(u-y)+(d-h)*(d-h));return Math.abs(M)<.001&&(M=1),this.x=(m-g)/M,this.y=(u-y)/M,this.z=(d-h)/M,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=Xe(this.x,e.x,t.x),this.y=Xe(this.y,e.y,t.y),this.z=Xe(this.z,e.z,t.z),this.w=Xe(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Xe(this.x,e,t),this.y=Xe(this.y,e,t),this.z=Xe(this.z,e,t),this.w=Xe(this.w,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Xe(i,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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,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}},Oo=class extends Wn{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:kn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new mt(0,0,e,t),this.scissorTest=!1,this.viewport=new mt(0,0,e,t);let r={width:e,height:t,depth:i.depth},s=new Kt(r);this.textures=[];let a=i.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(e={}){let t={minFilter:kn,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 i=0;i<this.textures.length;i++)this.textures[i].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,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i,this.textures[r].isArrayTexture=this.textures[r].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,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let r=Object.assign({},e.textures[t].image);this.textures[t].source=new Jr(r)}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}dispose(){this.dispatchEvent({type:"dispose"})}},Sn=class extends Oo{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}},js=class extends Kt{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Bt,this.minFilter=Bt,this.wrapR=Ei,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};var Uo=class extends Kt{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Bt,this.minFilter=Bt,this.wrapR=Ei,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var $n=class{constructor(e=new N(1/0,1/0,1/0),t=new N(-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,i=e.length;t<i;t+=3)this.expandByPoint(Cn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Cn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=Cn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),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 i=e.geometry;if(i!==void 0){let s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Cn):Cn.fromBufferAttribute(s,a),Cn.applyMatrix4(e.matrixWorld),this.expandByPoint(Cn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),so.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),so.copy(i.boundingBox)),so.applyMatrix4(e.matrixWorld),this.union(so)}let r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],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,Cn),Cn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Fs),ao.subVectors(this.max,Fs),Or.subVectors(e.a,Fs),Ur.subVectors(e.b,Fs),Fr.subVectors(e.c,Fs),vi.subVectors(Ur,Or),xi.subVectors(Fr,Ur),Zi.subVectors(Or,Fr);let t=[0,-vi.z,vi.y,0,-xi.z,xi.y,0,-Zi.z,Zi.y,vi.z,0,-vi.x,xi.z,0,-xi.x,Zi.z,0,-Zi.x,-vi.y,vi.x,0,-xi.y,xi.x,0,-Zi.y,Zi.x,0];return!ah(t,Or,Ur,Fr,ao)||(t=[1,0,0,0,1,0,0,0,1],!ah(t,Or,Ur,Fr,ao))?!1:(oo.crossVectors(vi,xi),t=[oo.x,oo.y,oo.z],ah(t,Or,Ur,Fr,ao))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Cn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Cn).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:(ti[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ti[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ti[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ti[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ti[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ti[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ti[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ti[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ti),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}},ti=[new N,new N,new N,new N,new N,new N,new N,new N],Cn=new N,so=new $n,Or=new N,Ur=new N,Fr=new N,vi=new N,xi=new N,Zi=new N,Fs=new N,ao=new N,oo=new N,Ji=new N;function ah(n,e,t,i,r){for(let s=0,a=n.length-3;s<=a;s+=3){Ji.fromArray(n,s);let o=r.x*Math.abs(Ji.x)+r.y*Math.abs(Ji.y)+r.z*Math.abs(Ji.z),l=e.dot(Ji),c=t.dot(Ji),h=i.dot(Ji);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}var Fy=new $n,Bs=new N,oh=new N,Ai=class{constructor(e=new N,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 i=this.center;t!==void 0?i.copy(t):Fy.setFromPoints(e).getCenter(i);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),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 i=this.center.distanceToSquared(e);return t.copy(e),i>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;Bs.subVectors(e,this.center);let t=Bs.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(Bs,r/i),this.radius+=r}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):(oh.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Bs.copy(e.center).add(oh)),this.expandByPoint(Bs.copy(e.center).sub(oh))),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}},ni=new N,lh=new N,lo=new N,_i=new N,ch=new N,co=new N,hh=new N,Ci=class{constructor(e=new N,t=new N(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,ni)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=ni.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ni.copy(this.origin).addScaledVector(this.direction,t),ni.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){lh.copy(e).add(t).multiplyScalar(.5),lo.copy(t).sub(e).normalize(),_i.copy(this.origin).sub(lh);let s=e.distanceTo(t)*.5,a=-this.direction.dot(lo),o=_i.dot(this.direction),l=-_i.dot(lo),c=_i.lengthSq(),h=Math.abs(1-a*a),u,d,f,g;if(h>0)if(u=a*l-o,d=a*o-l,g=s*h,u>=0)if(d>=-g)if(d<=g){let y=1/h;u*=y,d*=y,f=u*(u+a*d+2*o)+d*(a*u+d+2*l)+c}else d=s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d=-s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d<=-g?(u=Math.max(0,-(-a*s+o)),d=u>0?-s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c):d<=g?(u=0,d=Math.min(Math.max(-s,-l),s),f=d*(d+2*l)+c):(u=Math.max(0,-(a*s+o)),d=u>0?s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c);else d=a>0?-s:s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(lh).addScaledVector(lo,d),f}intersectSphere(e,t){ni.subVectors(e.center,this.origin);let i=ni.dot(this.direction),r=ni.dot(ni)-i*i,s=e.radius*e.radius;if(r>s)return null;let a=Math.sqrt(s-r),o=i-a,l=i+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 i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,a,o,l,c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(i=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(i=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),h>=0?(s=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(s=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),i>a||s>r||((s>i||isNaN(i))&&(i=s),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,l=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,l=(e.min.z-d.z)*u),i>l||o>r)||((o>i||i!==i)&&(i=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,ni)!==null}intersectTriangle(e,t,i,r,s){ch.subVectors(t,e),co.subVectors(i,e),hh.crossVectors(ch,co);let a=this.direction.dot(hh),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;_i.subVectors(this.origin,e);let l=o*this.direction.dot(co.crossVectors(_i,co));if(l<0)return null;let c=o*this.direction.dot(ch.cross(_i));if(c<0||l+c>a)return null;let h=-o*_i.dot(hh);return h<0?null:this.at(h/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},St=class n{constructor(e,t,i,r,s,a,o,l,c,h,u,d,f,g,y,m){n.prototype.isMatrix4=!0,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,i,r,s,a,o,l,c,h,u,d,f,g,y,m)}set(e,t,i,r,s,a,o,l,c,h,u,d,f,g,y,m){let p=this.elements;return p[0]=e,p[4]=t,p[8]=i,p[12]=r,p[1]=s,p[5]=a,p[9]=o,p[13]=l,p[2]=c,p[6]=h,p[10]=u,p[14]=d,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 n().fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[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,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,i=e.elements,r=1/Br.setFromMatrixColumn(e,0).length(),s=1/Br.setFromMatrixColumn(e,1).length(),a=1/Br.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,i=e.x,r=e.y,s=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(r),c=Math.sin(r),h=Math.cos(s),u=Math.sin(s);if(e.order==="XYZ"){let d=a*h,f=a*u,g=o*h,y=o*u;t[0]=l*h,t[4]=-l*u,t[8]=c,t[1]=f+g*c,t[5]=d-y*c,t[9]=-o*l,t[2]=y-d*c,t[6]=g+f*c,t[10]=a*l}else if(e.order==="YXZ"){let d=l*h,f=l*u,g=c*h,y=c*u;t[0]=d+y*o,t[4]=g*o-f,t[8]=a*c,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=f*o-g,t[6]=y+d*o,t[10]=a*l}else if(e.order==="ZXY"){let d=l*h,f=l*u,g=c*h,y=c*u;t[0]=d-y*o,t[4]=-a*u,t[8]=g+f*o,t[1]=f+g*o,t[5]=a*h,t[9]=y-d*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){let d=a*h,f=a*u,g=o*h,y=o*u;t[0]=l*h,t[4]=g*c-f,t[8]=d*c+y,t[1]=l*u,t[5]=y*c+d,t[9]=f*c-g,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){let d=a*l,f=a*c,g=o*l,y=o*c;t[0]=l*h,t[4]=y-d*u,t[8]=g*u+f,t[1]=u,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=f*u+g,t[10]=d-y*u}else if(e.order==="XZY"){let d=a*l,f=a*c,g=o*l,y=o*c;t[0]=l*h,t[4]=-u,t[8]=c*h,t[1]=d*u+y,t[5]=a*h,t[9]=f*u-g,t[2]=g*u-f,t[6]=o*h,t[10]=y*u+d}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(By,e,zy)}lookAt(e,t,i){let r=this.elements;return dn.subVectors(e,t),dn.lengthSq()===0&&(dn.z=1),dn.normalize(),bi.crossVectors(i,dn),bi.lengthSq()===0&&(Math.abs(i.z)===1?dn.x+=1e-4:dn.z+=1e-4,dn.normalize(),bi.crossVectors(i,dn)),bi.normalize(),ho.crossVectors(dn,bi),r[0]=bi.x,r[4]=ho.x,r[8]=dn.x,r[1]=bi.y,r[5]=ho.y,r[9]=dn.y,r[2]=bi.z,r[6]=ho.z,r[10]=dn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],h=i[1],u=i[5],d=i[9],f=i[13],g=i[2],y=i[6],m=i[10],p=i[14],M=i[3],S=i[7],x=i[11],A=i[15],T=r[0],R=r[4],k=r[8],w=r[12],b=r[1],D=r[5],V=r[9],W=r[13],Y=r[2],j=r[6],X=r[10],re=r[14],H=r[3],oe=r[7],ee=r[11],Me=r[15];return s[0]=a*T+o*b+l*Y+c*H,s[4]=a*R+o*D+l*j+c*oe,s[8]=a*k+o*V+l*X+c*ee,s[12]=a*w+o*W+l*re+c*Me,s[1]=h*T+u*b+d*Y+f*H,s[5]=h*R+u*D+d*j+f*oe,s[9]=h*k+u*V+d*X+f*ee,s[13]=h*w+u*W+d*re+f*Me,s[2]=g*T+y*b+m*Y+p*H,s[6]=g*R+y*D+m*j+p*oe,s[10]=g*k+y*V+m*X+p*ee,s[14]=g*w+y*W+m*re+p*Me,s[3]=M*T+S*b+x*Y+A*H,s[7]=M*R+S*D+x*j+A*oe,s[11]=M*k+S*V+x*X+A*ee,s[15]=M*w+S*W+x*re+A*Me,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],i=e[4],r=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],u=e[6],d=e[10],f=e[14],g=e[3],y=e[7],m=e[11],p=e[15];return g*(+s*l*u-r*c*u-s*o*d+i*c*d+r*o*f-i*l*f)+y*(+t*l*f-t*c*d+s*a*d-r*a*f+r*c*h-s*l*h)+m*(+t*c*u-t*o*f-s*a*u+i*a*f+s*o*h-i*c*h)+p*(-r*o*h-t*l*u+t*o*d+r*a*u-i*a*d+i*l*h)}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,i){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],f=e[11],g=e[12],y=e[13],m=e[14],p=e[15],M=u*m*c-y*d*c+y*l*f-o*m*f-u*l*p+o*d*p,S=g*d*c-h*m*c-g*l*f+a*m*f+h*l*p-a*d*p,x=h*y*c-g*u*c+g*o*f-a*y*f-h*o*p+a*u*p,A=g*u*l-h*y*l-g*o*d+a*y*d+h*o*m-a*u*m,T=t*M+i*S+r*x+s*A;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let R=1/T;return e[0]=M*R,e[1]=(y*d*s-u*m*s-y*r*f+i*m*f+u*r*p-i*d*p)*R,e[2]=(o*m*s-y*l*s+y*r*c-i*m*c-o*r*p+i*l*p)*R,e[3]=(u*l*s-o*d*s-u*r*c+i*d*c+o*r*f-i*l*f)*R,e[4]=S*R,e[5]=(h*m*s-g*d*s+g*r*f-t*m*f-h*r*p+t*d*p)*R,e[6]=(g*l*s-a*m*s-g*r*c+t*m*c+a*r*p-t*l*p)*R,e[7]=(a*d*s-h*l*s+h*r*c-t*d*c-a*r*f+t*l*f)*R,e[8]=x*R,e[9]=(g*u*s-h*y*s-g*i*f+t*y*f+h*i*p-t*u*p)*R,e[10]=(a*y*s-g*o*s+g*i*c-t*y*c-a*i*p+t*o*p)*R,e[11]=(h*o*s-a*u*s-h*i*c+t*u*c+a*i*f-t*o*f)*R,e[12]=A*R,e[13]=(h*y*r-g*u*r+g*i*d-t*y*d-h*i*m+t*u*m)*R,e[14]=(g*o*r-a*y*r-g*i*l+t*y*l+a*i*m-t*o*m)*R,e[15]=(a*u*r-h*o*r+h*i*l-t*u*l-a*i*d+t*o*d)*R,this}scale(e){let t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){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,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),r=Math.sin(t),s=1-i,a=e.x,o=e.y,l=e.z,c=s*a,h=s*o;return this.set(c*a+i,c*o-r*l,c*l+r*o,0,c*o+r*l,h*o+i,h*l-r*a,0,c*l-r*o,h*l+r*a,s*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,a){return this.set(1,i,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){let r=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,h=a+a,u=o+o,d=s*c,f=s*h,g=s*u,y=a*h,m=a*u,p=o*u,M=l*c,S=l*h,x=l*u,A=i.x,T=i.y,R=i.z;return r[0]=(1-(y+p))*A,r[1]=(f+x)*A,r[2]=(g-S)*A,r[3]=0,r[4]=(f-x)*T,r[5]=(1-(d+p))*T,r[6]=(m+M)*T,r[7]=0,r[8]=(g+S)*R,r[9]=(m-M)*R,r[10]=(1-(d+y))*R,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){let r=this.elements,s=Br.set(r[0],r[1],r[2]).length(),a=Br.set(r[4],r[5],r[6]).length(),o=Br.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Rn.copy(this);let c=1/s,h=1/a,u=1/o;return Rn.elements[0]*=c,Rn.elements[1]*=c,Rn.elements[2]*=c,Rn.elements[4]*=h,Rn.elements[5]*=h,Rn.elements[6]*=h,Rn.elements[8]*=u,Rn.elements[9]*=u,Rn.elements[10]*=u,t.setFromRotationMatrix(Rn),i.x=s,i.y=a,i.z=o,this}makePerspective(e,t,i,r,s,a,o=Ln,l=!1){let c=this.elements,h=2*s/(t-e),u=2*s/(i-r),d=(t+e)/(t-e),f=(i+r)/(i-r),g,y;if(l)g=s/(a-s),y=a*s/(a-s);else if(o===Ln)g=-(a+s)/(a-s),y=-2*a*s/(a-s);else if(o===qs)g=-a/(a-s),y=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,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,i,r,s,a,o=Ln,l=!1){let c=this.elements,h=2/(t-e),u=2/(i-r),d=-(t+e)/(t-e),f=-(i+r)/(i-r),g,y;if(l)g=1/(a-s),y=a/(a-s);else if(o===Ln)g=-2/(a-s),y=-(a+s)/(a-s);else if(o===qs)g=-1/(a-s),y=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,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,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}},Br=new N,Rn=new St,By=new N(0,0,0),zy=new N(1,1,1),bi=new N,ho=new N,dn=new N,jd=new St,Zd=new bn,Xn=class n{constructor(e=0,t=0,i=0,r=n.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}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,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,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,i=!0){let r=e.elements,s=r[0],a=r[4],o=r[8],l=r[1],c=r[5],h=r[9],u=r[2],d=r[6],f=r[10];switch(t){case"XYZ":this._y=Math.asin(Xe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Xe(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(Xe(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Xe(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Xe(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Xe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return jd.makeRotationFromQuaternion(e),this.setFromRotationMatrix(jd,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Zd.setFromEuler(this),this.setFromQuaternion(Zd,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}};Xn.DEFAULT_ORDER="XYZ";var Zs=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}},Vy=0,Jd=new N,zr=new bn,ii=new St,uo=new N,zs=new N,Hy=new N,Gy=new bn,Kd=new N(1,0,0),Qd=new N(0,1,0),ef=new N(0,0,1),tf={type:"added"},Wy={type:"removed"},Vr={type:"childadded",child:null},uh={type:"childremoved",child:null},zt=class n extends Wn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Vy++}),this.uuid=ai(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=n.DEFAULT_UP.clone();let e=new N,t=new Xn,i=new bn,r=new N(1,1,1);function s(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._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:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new St},normalMatrix:{value:new ze}}),this.matrix=new St,this.matrixWorld=new St,this.matrixAutoUpdate=n.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=n.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Zs,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(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 zr.setFromAxisAngle(e,t),this.quaternion.multiply(zr),this}rotateOnWorldAxis(e,t){return zr.setFromAxisAngle(e,t),this.quaternion.premultiply(zr),this}rotateX(e){return this.rotateOnAxis(Kd,e)}rotateY(e){return this.rotateOnAxis(Qd,e)}rotateZ(e){return this.rotateOnAxis(ef,e)}translateOnAxis(e,t){return Jd.copy(e).applyQuaternion(this.quaternion),this.position.add(Jd.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Kd,e)}translateY(e){return this.translateOnAxis(Qd,e)}translateZ(e){return this.translateOnAxis(ef,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ii.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?uo.copy(e):uo.set(e,t,i);let r=this.parent;this.updateWorldMatrix(!0,!1),zs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ii.lookAt(zs,uo,this.up):ii.lookAt(uo,zs,this.up),this.quaternion.setFromRotationMatrix(ii),r&&(ii.extractRotation(r.matrixWorld),zr.setFromRotationMatrix(ii),this.quaternion.premultiply(zr.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.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(tf),Vr.child=e,this.dispatchEvent(Vr),Vr.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Wy),uh.child=e,this.dispatchEvent(uh),uh.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),ii.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ii.multiply(e.parent.matrixWorld)),e.applyMatrix4(ii),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(tf),Vr.child=e,this.dispatchEvent(Vr),Vr.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 i=0,r=this.children.length;i<r;i++){let a=this.children[i].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);let r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(zs,e,Hy),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(zs,Gy,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 i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].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),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 i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){let i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(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 u=l[c];s(e.shapes,u)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.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(s(e.materials,this.material[l]));r.material=o}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){let l=this.animations[o];r.animations.push(s(e.animations,l))}}if(t){let o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),u=a(e.shapes),d=a(e.skeletons),f=a(e.animations),g=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),h.length>0&&(i.images=h),u.length>0&&(i.shapes=u),d.length>0&&(i.skeletons=d),f.length>0&&(i.animations=f),g.length>0&&(i.nodes=g)}return i.object=r,i;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.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.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){let r=e.children[i];this.add(r.clone())}return this}};zt.DEFAULT_UP=new N(0,1,0);zt.DEFAULT_MATRIX_AUTO_UPDATE=!0;zt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Pn=new N,ri=new N,dh=new N,si=new N,Hr=new N,Gr=new N,nf=new N,fh=new N,ph=new N,mh=new N,gh=new mt,yh=new mt,vh=new mt,Mi=class n{constructor(e=new N,t=new N,i=new N){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Pn.subVectors(e,t),r.cross(Pn);let s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){Pn.subVectors(r,t),ri.subVectors(i,t),dh.subVectors(e,t);let a=Pn.dot(Pn),o=Pn.dot(ri),l=Pn.dot(dh),c=ri.dot(ri),h=ri.dot(dh),u=a*c-o*o;if(u===0)return s.set(0,0,0),null;let d=1/u,f=(c*l-o*h)*d,g=(a*h-o*l)*d;return s.set(1-f-g,g,f)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,si)===null?!1:si.x>=0&&si.y>=0&&si.x+si.y<=1}static getInterpolation(e,t,i,r,s,a,o,l){return this.getBarycoord(e,t,i,r,si)===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(s,si.x),l.addScaledVector(a,si.y),l.addScaledVector(o,si.z),l)}static getInterpolatedAttribute(e,t,i,r,s,a){return gh.setScalar(0),yh.setScalar(0),vh.setScalar(0),gh.fromBufferAttribute(e,t),yh.fromBufferAttribute(e,i),vh.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(gh,s.x),a.addScaledVector(yh,s.y),a.addScaledVector(vh,s.z),a}static isFrontFacing(e,t,i,r){return Pn.subVectors(i,t),ri.subVectors(e,t),Pn.cross(ri).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),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 Pn.subVectors(this.c,this.b),ri.subVectors(this.a,this.b),Pn.cross(ri).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return n.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return n.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,s){return n.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return n.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return n.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i=this.a,r=this.b,s=this.c,a,o;Hr.subVectors(r,i),Gr.subVectors(s,i),fh.subVectors(e,i);let l=Hr.dot(fh),c=Gr.dot(fh);if(l<=0&&c<=0)return t.copy(i);ph.subVectors(e,r);let h=Hr.dot(ph),u=Gr.dot(ph);if(h>=0&&u<=h)return t.copy(r);let d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(i).addScaledVector(Hr,a);mh.subVectors(e,s);let f=Hr.dot(mh),g=Gr.dot(mh);if(g>=0&&f<=g)return t.copy(s);let y=f*c-l*g;if(y<=0&&c>=0&&g<=0)return o=c/(c-g),t.copy(i).addScaledVector(Gr,o);let m=h*g-f*u;if(m<=0&&u-h>=0&&f-g>=0)return nf.subVectors(s,r),o=(u-h)/(u-h+(f-g)),t.copy(r).addScaledVector(nf,o);let p=1/(m+y+d);return a=y*p,o=d*p,t.copy(i).addScaledVector(Hr,a).addScaledVector(Gr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},ap={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},Si={h:0,s:0,l:0},fo={h:0,s:0,l:0};function xh(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}var Ze=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){let r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=pn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ke.colorSpaceToWorking(this,t),this}setRGB(e,t,i,r=Ke.workingColorSpace){return this.r=e,this.g=t,this.b=i,Ke.colorSpaceToWorking(this,r),this}setHSL(e,t,i,r=Ke.workingColorSpace){if(e=Xh(e,1),t=Xe(t,0,1),i=Xe(i,0,1),t===0)this.r=this.g=this.b=i;else{let s=i<=.5?i*(1+t):i+t-i*t,a=2*i-s;this.r=xh(a,s,e+1/3),this.g=xh(a,s,e),this.b=xh(a,s,e-1/3)}return Ke.colorSpaceToWorking(this,r),this}setStyle(e,t=pn){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=pn){let i=ap[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=oi(e.r),this.g=oi(e.g),this.b=oi(e.b),this}copyLinearToSRGB(e){return this.r=qr(e.r),this.g=qr(e.g),this.b=qr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=pn){return Ke.workingToColorSpace(Gt.copy(this),e),Math.round(Xe(Gt.r*255,0,255))*65536+Math.round(Xe(Gt.g*255,0,255))*256+Math.round(Xe(Gt.b*255,0,255))}getHexString(e=pn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ke.workingColorSpace){Ke.workingToColorSpace(Gt.copy(this),t);let i=Gt.r,r=Gt.g,s=Gt.b,a=Math.max(i,r,s),o=Math.min(i,r,s),l,c,h=(o+a)/2;if(o===a)l=0,c=0;else{let u=a-o;switch(c=h<=.5?u/(a+o):u/(2-a-o),a){case i:l=(r-s)/u+(r<s?6:0);break;case r:l=(s-i)/u+2;break;case s:l=(i-r)/u+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Ke.workingColorSpace){return Ke.workingToColorSpace(Gt.copy(this),t),e.r=Gt.r,e.g=Gt.g,e.b=Gt.b,e}getStyle(e=pn){Ke.workingToColorSpace(Gt.copy(this),e);let t=Gt.r,i=Gt.g,r=Gt.b;return e!==pn?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(Si),this.setHSL(Si.h+e,Si.s+t,Si.l+i)}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,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(Si),e.getHSL(fo);let i=Ws(Si.h,fo.h,t),r=Ws(Si.s,fo.s,t),s=Ws(Si.l,fo.l,t);return this.setHSL(i,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+s[8]*r,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}},Gt=new Ze;Ze.NAMES=ap;var $y=0,hi=class extends Wn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:$y++}),this.uuid=ai(),this.name="",this.type="Material",this.blending=tr,this.side=li,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Ro,this.blendDst=Po,this.blendEquation=Ti,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ze(0,0,0),this.blendAlpha=0,this.depthFunc=nr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Ah,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=er,this.stencilZFail=er,this.stencilZPass=er,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 i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==tr&&(i.blending=this.blending),this.side!==li&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Ro&&(i.blendSrc=this.blendSrc),this.blendDst!==Po&&(i.blendDst=this.blendDst),this.blendEquation!==Ti&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==nr&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Ah&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==er&&(i.stencilFail=this.stencilFail),this.stencilZFail!==er&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==er&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){let a=[];for(let o in s){let l=s[o];delete l.metadata,a.push(l)}return a}if(t){let s=r(e.textures),a=r(e.images);s.length>0&&(i.textures=s),a.length>0&&(i.images=a)}return i}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,i=null;if(t!==null){let r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,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.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++}},Js=class extends hi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ze(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 Xn,this.combine=Nh,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}};var Et=new N,po=new ke,Xy=0,wt=class{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Xy++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=ko,this.updateRanges=[],this.gpuType=En,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,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)po.fromBufferAttribute(this,t),po.applyMatrix3(e),this.setXY(t,po.x,po.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;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,i=this.count;t<i;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,i=this.count;t<i;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,i=this.count;t<i;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 i=this.array[e*this.itemSize+t];return this.normalized&&(i=In(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=st(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=In(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=In(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=In(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=In(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,i){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),i=st(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),i=st(i,this.array),r=st(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),i=st(i,this.array),r=st(r,this.array),s=st(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,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!==ko&&(e.usage=this.usage),e}};var Ks=class extends wt{constructor(e,t,i){super(new Uint16Array(e),t,i)}};var Qs=class extends wt{constructor(e,t,i){super(new Uint32Array(e),t,i)}};var $t=class extends wt{constructor(e,t,i){super(new Float32Array(e),t,i)}},qy=0,xn=new St,_h=new zt,Wr=new N,fn=new $n,Vs=new $n,Ft=new N,Tt=class n extends Wn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:qy++}),this.uuid=ai(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Yh(e)?Qs:Ks)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,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,i=0){this.groups.push({start:e,count:t,materialIndex:i})}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 i=this.attributes.normal;if(i!==void 0){let s=new ze().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return xn.makeRotationFromQuaternion(e),this.applyMatrix4(xn),this}rotateX(e){return xn.makeRotationX(e),this.applyMatrix4(xn),this}rotateY(e){return xn.makeRotationY(e),this.applyMatrix4(xn),this}rotateZ(e){return xn.makeRotationZ(e),this.applyMatrix4(xn),this}translate(e,t,i){return xn.makeTranslation(e,t,i),this.applyMatrix4(xn),this}scale(e,t,i){return xn.makeScale(e,t,i),this.applyMatrix4(xn),this}lookAt(e){return _h.lookAt(e),_h.updateMatrix(),this.applyMatrix4(_h.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Wr).negate(),this.translate(Wr.x,Wr.y,Wr.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let i=[];for(let r=0,s=e.length;r<s;r++){let a=e[r];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new $t(i,3))}else{let i=Math.min(e.length,t.count);for(let r=0;r<i;r++){let s=e[r];t.setXYZ(r,s.x,s.y,s.z||0)}e.length>t.count&&console.warn("THREE.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 $n);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new N(-1/0,-1/0,-1/0),new N(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){let s=t[i];fn.setFromBufferAttribute(s),this.morphTargetsRelative?(Ft.addVectors(this.boundingBox.min,fn.min),this.boundingBox.expandByPoint(Ft),Ft.addVectors(this.boundingBox.max,fn.max),this.boundingBox.expandByPoint(Ft)):(this.boundingBox.expandByPoint(fn.min),this.boundingBox.expandByPoint(fn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ai);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new N,1/0);return}if(e){let i=this.boundingSphere.center;if(fn.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){let o=t[s];Vs.setFromBufferAttribute(o),this.morphTargetsRelative?(Ft.addVectors(fn.min,Vs.min),fn.expandByPoint(Ft),Ft.addVectors(fn.max,Vs.max),fn.expandByPoint(Ft)):(fn.expandByPoint(Vs.min),fn.expandByPoint(Vs.max))}fn.getCenter(i);let r=0;for(let s=0,a=e.count;s<a;s++)Ft.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(Ft));if(t)for(let s=0,a=t.length;s<a;s++){let o=t[s],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)Ft.fromBufferAttribute(o,c),l&&(Wr.fromBufferAttribute(e,c),Ft.add(Wr)),r=Math.max(r,i.distanceToSquared(Ft))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.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){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let i=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new wt(new Float32Array(4*i.count),4));let a=this.getAttribute("tangent"),o=[],l=[];for(let k=0;k<i.count;k++)o[k]=new N,l[k]=new N;let c=new N,h=new N,u=new N,d=new ke,f=new ke,g=new ke,y=new N,m=new N;function p(k,w,b){c.fromBufferAttribute(i,k),h.fromBufferAttribute(i,w),u.fromBufferAttribute(i,b),d.fromBufferAttribute(s,k),f.fromBufferAttribute(s,w),g.fromBufferAttribute(s,b),h.sub(c),u.sub(c),f.sub(d),g.sub(d);let D=1/(f.x*g.y-g.x*f.y);isFinite(D)&&(y.copy(h).multiplyScalar(g.y).addScaledVector(u,-f.y).multiplyScalar(D),m.copy(u).multiplyScalar(f.x).addScaledVector(h,-g.x).multiplyScalar(D),o[k].add(y),o[w].add(y),o[b].add(y),l[k].add(m),l[w].add(m),l[b].add(m))}let M=this.groups;M.length===0&&(M=[{start:0,count:e.count}]);for(let k=0,w=M.length;k<w;++k){let b=M[k],D=b.start,V=b.count;for(let W=D,Y=D+V;W<Y;W+=3)p(e.getX(W+0),e.getX(W+1),e.getX(W+2))}let S=new N,x=new N,A=new N,T=new N;function R(k){A.fromBufferAttribute(r,k),T.copy(A);let w=o[k];S.copy(w),S.sub(A.multiplyScalar(A.dot(w))).normalize(),x.crossVectors(T,w);let D=x.dot(l[k])<0?-1:1;a.setXYZW(k,S.x,S.y,S.z,D)}for(let k=0,w=M.length;k<w;++k){let b=M[k],D=b.start,V=b.count;for(let W=D,Y=D+V;W<Y;W+=3)R(e.getX(W+0)),R(e.getX(W+1)),R(e.getX(W+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new wt(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let d=0,f=i.count;d<f;d++)i.setXYZ(d,0,0,0);let r=new N,s=new N,a=new N,o=new N,l=new N,c=new N,h=new N,u=new N;if(e)for(let d=0,f=e.count;d<f;d+=3){let g=e.getX(d+0),y=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,y),a.fromBufferAttribute(t,m),h.subVectors(a,s),u.subVectors(r,s),h.cross(u),o.fromBufferAttribute(i,g),l.fromBufferAttribute(i,y),c.fromBufferAttribute(i,m),o.add(h),l.add(h),c.add(h),i.setXYZ(g,o.x,o.y,o.z),i.setXYZ(y,l.x,l.y,l.z),i.setXYZ(m,c.x,c.y,c.z)}else for(let d=0,f=t.count;d<f;d+=3)r.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),h.subVectors(a,s),u.subVectors(r,s),h.cross(u),i.setXYZ(d+0,h.x,h.y,h.z),i.setXYZ(d+1,h.x,h.y,h.z),i.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Ft.fromBufferAttribute(e,t),Ft.normalize(),e.setXYZ(t,Ft.x,Ft.y,Ft.z)}toNonIndexed(){function e(o,l){let c=o.array,h=o.itemSize,u=o.normalized,d=new c.constructor(l.length*h),f=0,g=0;for(let y=0,m=l.length;y<m;y++){o.isInterleavedBufferAttribute?f=l[y]*o.data.stride+o.offset:f=l[y]*h;for(let p=0;p<h;p++)d[g++]=c[f++]}return new wt(d,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new n,i=this.index.array,r=this.attributes;for(let o in r){let l=r[o],c=e(l,i);t.setAttribute(o,c)}let s=this.morphAttributes;for(let o in s){let l=[],c=s[o];for(let h=0,u=c.length;h<u;h++){let d=c[h],f=e(d,i);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.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 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 i=this.attributes;for(let l in i){let c=i[l];e.data.attributes[l]=c.toJSON(e.data)}let r={},s=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){let f=c[u];h.push(f.toJSON(e.data))}h.length>0&&(r[l]=h,s=!0)}s&&(e.data.morphAttributes=r,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 i=e.index;i!==null&&this.setIndex(i.clone());let r=e.attributes;for(let c in r){let h=r[c];this.setAttribute(c,h.clone(t))}let s=e.morphAttributes;for(let c in s){let h=[],u=s[c];for(let d=0,f=u.length;d<f;d++)h.push(u[d].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 u=a[c];this.addGroup(u.start,u.count,u.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}dispose(){this.dispatchEvent({type:"dispose"})}},rf=new St,Ki=new Ci,mo=new Ai,sf=new N,go=new N,yo=new N,vo=new N,bh=new N,xo=new N,af=new N,_o=new N,Xt=class extends zt{constructor(e=new Tt,t=new Js){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,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){let o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){let i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(s&&o){xo.set(0,0,0);for(let l=0,c=s.length;l<c;l++){let h=o[l],u=s[l];h!==0&&(bh.fromBufferAttribute(u,e),a?xo.addScaledVector(bh,h):xo.addScaledVector(bh.sub(t),h))}t.add(xo)}return t}raycast(e,t){let i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),mo.copy(i.boundingSphere),mo.applyMatrix4(s),Ki.copy(e.ray).recast(e.near),!(mo.containsPoint(Ki.origin)===!1&&(Ki.intersectSphere(mo,sf)===null||Ki.origin.distanceToSquared(sf)>(e.far-e.near)**2))&&(rf.copy(s).invert(),Ki.copy(e.ray).applyMatrix4(rf),!(i.boundingBox!==null&&Ki.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Ki)))}_computeIntersections(e,t,i){let r,s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,d=s.groups,f=s.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,y=d.length;g<y;g++){let m=d[g],p=a[m.materialIndex],M=Math.max(m.start,f.start),S=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let x=M,A=S;x<A;x+=3){let T=o.getX(x),R=o.getX(x+1),k=o.getX(x+2);r=bo(this,p,e,i,c,h,u,T,R,k),r&&(r.faceIndex=Math.floor(x/3),r.face.materialIndex=m.materialIndex,t.push(r))}}else{let g=Math.max(0,f.start),y=Math.min(o.count,f.start+f.count);for(let m=g,p=y;m<p;m+=3){let M=o.getX(m),S=o.getX(m+1),x=o.getX(m+2);r=bo(this,a,e,i,c,h,u,M,S,x),r&&(r.faceIndex=Math.floor(m/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let g=0,y=d.length;g<y;g++){let m=d[g],p=a[m.materialIndex],M=Math.max(m.start,f.start),S=Math.min(l.count,Math.min(m.start+m.count,f.start+f.count));for(let x=M,A=S;x<A;x+=3){let T=x,R=x+1,k=x+2;r=bo(this,p,e,i,c,h,u,T,R,k),r&&(r.faceIndex=Math.floor(x/3),r.face.materialIndex=m.materialIndex,t.push(r))}}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 M=m,S=m+1,x=m+2;r=bo(this,a,e,i,c,h,u,M,S,x),r&&(r.faceIndex=Math.floor(m/3),t.push(r))}}}};function Yy(n,e,t,i,r,s,a,o){let l;if(e.side===Qt?l=i.intersectTriangle(a,s,r,!0,o):l=i.intersectTriangle(r,s,a,e.side===li,o),l===null)return null;_o.copy(o),_o.applyMatrix4(n.matrixWorld);let c=t.ray.origin.distanceTo(_o);return c<t.near||c>t.far?null:{distance:c,point:_o.clone(),object:n}}function bo(n,e,t,i,r,s,a,o,l,c){n.getVertexPosition(o,go),n.getVertexPosition(l,yo),n.getVertexPosition(c,vo);let h=Yy(n,e,t,i,go,yo,vo,af);if(h){let u=new N;Mi.getBarycoord(af,go,yo,vo,u),r&&(h.uv=Mi.getInterpolatedAttribute(r,o,l,c,u,new ke)),s&&(h.uv1=Mi.getInterpolatedAttribute(s,o,l,c,u,new ke)),a&&(h.normal=Mi.getInterpolatedAttribute(a,o,l,c,u,new N),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));let d={a:o,b:l,c,normal:new N,materialIndex:0};Mi.getNormal(go,yo,vo,d.normal),h.face=d,h.barycoord=u}return h}var Kr=class n extends Tt{constructor(e=1,t=1,i=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:a};let o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);let l=[],c=[],h=[],u=[],d=0,f=0;g("z","y","x",-1,-1,i,t,e,a,s,0),g("z","y","x",1,-1,i,t,-e,a,s,1),g("x","z","y",1,1,e,i,t,r,a,2),g("x","z","y",1,-1,e,i,-t,r,a,3),g("x","y","z",1,-1,e,t,i,r,s,4),g("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(l),this.setAttribute("position",new $t(c,3)),this.setAttribute("normal",new $t(h,3)),this.setAttribute("uv",new $t(u,2));function g(y,m,p,M,S,x,A,T,R,k,w){let b=x/R,D=A/k,V=x/2,W=A/2,Y=T/2,j=R+1,X=k+1,re=0,H=0,oe=new N;for(let ee=0;ee<X;ee++){let Me=ee*D-W;for(let $e=0;$e<j;$e++){let rt=$e*b-V;oe[y]=rt*M,oe[m]=Me*S,oe[p]=Y,c.push(oe.x,oe.y,oe.z),oe[y]=0,oe[m]=0,oe[p]=T>0?1:-1,h.push(oe.x,oe.y,oe.z),u.push($e/R),u.push(1-ee/k),re+=1}}for(let ee=0;ee<k;ee++)for(let Me=0;Me<R;Me++){let $e=d+Me+j*ee,rt=d+Me+j*(ee+1),Ue=d+(Me+1)+j*(ee+1),qe=d+(Me+1)+j*ee;l.push($e,rt,qe),l.push(rt,Ue,qe),H+=6}o.addGroup(f,H,w),f+=H,d+=re}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function dr(n){let e={};for(let t in n){e[t]={};for(let i in n[t]){let r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function Yt(n){let e={};for(let t=0;t<n.length;t++){let i=dr(n[t]);for(let r in i)e[r]=i[r]}return e}function jy(n){let e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function jh(n){let e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ke.workingColorSpace}var op={clone:dr,merge:Yt},Zy=`void main() {
2
10
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
3
- }`,ou=`void main() {
11
+ }`,Jy=`void main() {
4
12
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
5
- }`,je=class extends yn{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=au,this.fragmentShader=ou,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,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=ti(t.uniforms),this.uniformsGroups=ru(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){let e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(let s in this.uniforms){let a=this.uniforms[s].value;a&&a.isTexture?e.uniforms[s]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[s]={type:"m4",value:a.toArray()}:e.uniforms[s]={value:a}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}},ds=class extends Ce{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ce,this.projectionMatrix=new ce,this.projectionMatrixInverse=new ce,this.coordinateSystem=Je,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},Rn=new N,Il=new Ut,Ll=new Ut,we=class extends ds{constructor(t=50,e=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){let e=.5*this.getFilmHeight()/t;this.fov=Ei*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(ns*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Ei*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(t,e,n){Rn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Rn.x,Rn.y).multiplyScalar(-t/Rn.z),Rn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Rn.x,Rn.y).multiplyScalar(-t/Rn.z)}getViewSize(t,e){return this.getViewBounds(t,Il,Ll),e.subVectors(Ll,Il)}setViewOffset(t,e,n,s,r,a){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=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 t=this.near,e=t*Math.tan(ns*.5*this.fov)/this.zoom,n=2*e,s=this.aspect*n,r=-.5*s,a=this.view;if(this.view!==null&&this.view.enabled){let c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*s/c,e-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}let o=this.filmOffset;o!==0&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,e,e-n,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}},yi=-90,vi=1,xr=class extends Ce{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let s=new we(yi,vi,t,e);s.layers=this.layers,this.add(s);let r=new we(yi,vi,t,e);r.layers=this.layers,this.add(r);let a=new we(yi,vi,t,e);a.layers=this.layers,this.add(a);let o=new we(yi,vi,t,e);o.layers=this.layers,this.add(o);let c=new we(yi,vi,t,e);c.layers=this.layers,this.add(c);let l=new we(yi,vi,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let t=this.coordinateSystem,e=this.children.concat(),[n,s,r,a,o,c]=e;for(let l of e)this.remove(l);if(t===Je)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),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(t===as)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),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(let l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());let[r,a,o,c,l,h]=this.children,f=t.getRenderTarget(),u=t.getActiveCubeFace(),p=t.getActiveMipmapLevel(),g=t.xr.enabled;t.xr.enabled=!1;let _=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,s),t.render(e,r),t.setRenderTarget(n,1,s),t.render(e,a),t.setRenderTarget(n,2,s),t.render(e,o),t.setRenderTarget(n,3,s),t.render(e,c),t.setRenderTarget(n,4,s),t.render(e,l),n.texture.generateMipmaps=_,t.setRenderTarget(n,5,s),t.render(e,h),t.setRenderTarget(f,u,p),t.xr.enabled=g,n.texture.needsPMREMUpdate=!0}},fs=class extends Re{constructor(t=[],e=jn,n,s,r,a,o,c,l,h){super(t,e,n,s,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}},yr=class extends en{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;let n={width:t,height:t,depth:1},s=[n,n,n,n,n,n];this.texture=new fs(s),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
13
+ }`,sn=class extends hi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Zy,this.fragmentShader=Jy,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=dr(e.uniforms),this.uniformsGroups=jy(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let r in this.uniforms){let a=this.uniforms[r].value;a&&a.isTexture?t.uniforms[r]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[r]={type:"m4",value:a.toArray()}:t.uniforms[r]={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 i={};for(let r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}},ea=class extends zt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new St,this.projectionMatrix=new St,this.projectionMatrixInverse=new St,this.coordinateSystem=Ln,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.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},wi=new N,of=new ke,lf=new ke,Wt=class extends ea{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,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=jr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Gs*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return jr*2*Math.atan(Math.tan(Gs*.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,i){wi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(wi.x,wi.y).multiplyScalar(-e/wi.z),wi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(wi.x,wi.y).multiplyScalar(-e/wi.z)}getViewSize(e,t){return this.getViewBounds(e,of,lf),t.subVectors(lf,of)}setViewOffset(e,t,i,r,s,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=i,this.view.offsetY=r,this.view.width=s,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(Gs*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*r/l,t-=a.offsetY*i/c,r*=a.width/l,i*=a.height/c}let o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,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}},$r=-90,Xr=1,Fo=class extends zt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new Wt($r,Xr,e,t);r.layers=this.layers,this.add(r);let s=new Wt($r,Xr,e,t);s.layers=this.layers,this.add(s);let a=new Wt($r,Xr,e,t);a.layers=this.layers,this.add(a);let o=new Wt($r,Xr,e,t);o.layers=this.layers,this.add(o);let l=new Wt($r,Xr,e,t);l.layers=this.layers,this.add(l);let c=new Wt($r,Xr,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[i,r,s,a,o,l]=t;for(let c of t)this.remove(c);if(e===Ln)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.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===qs)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.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:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[s,a,o,l,c,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;let y=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,s),e.setRenderTarget(i,1,r),e.render(t,a),e.setRenderTarget(i,2,r),e.render(t,o),e.setRenderTarget(i,3,r),e.render(t,l),e.setRenderTarget(i,4,r),e.render(t,c),i.texture.generateMipmaps=y,e.setRenderTarget(i,5,r),e.render(t,h),e.setRenderTarget(u,d,f),e.xr.enabled=g,i.texture.needsPMREMUpdate=!0}},ta=class extends Kt{constructor(e=[],t=cr,i,r,s,a,o,l,c,h){super(e,t,i,r,s,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Bo=class extends Sn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new ta(r),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 i={uniforms:{tEquirect:{value:null}},vertexShader:`
6
14
 
7
15
  varying vec3 vWorldDirection;
8
16
 
@@ -37,9 +45,9 @@
37
45
  gl_FragColor = texture2D( tEquirect, sampleUV );
38
46
 
39
47
  }
40
- `},s=new Ai(5,5,5),r=new je({name:"CubemapFromEquirect",uniforms:ti(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ee,blending:vn});r.uniforms.tEquirect.value=e;let a=new Pe(s,r),o=e.minFilter;return e.minFilter===On&&(e.minFilter=Ke),new xr(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e=!0,n=!0,s=!0){let r=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,s);t.setRenderTarget(r)}},Yn=class extends Ce{constructor(){super(),this.isGroup=!0,this.type="Group"}},lu={type:"move"},Ri=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Yn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Yn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new N,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new N),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Yn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new N,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new N),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let s=null,r=null,a=null,o=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){a=!0;for(let _ of t.hand.values()){let m=e.getJointPose(_,n),d=this._getHandJoint(l,_);m!==null&&(d.matrix.fromArray(m.transform.matrix),d.matrix.decompose(d.position,d.rotation,d.scale),d.matrixWorldNeedsUpdate=!0,d.jointRadius=m.radius),d.visible=m!==null}let h=l.joints["index-finger-tip"],f=l.joints["thumb-tip"],u=h.position.distanceTo(f.position),p=.02,g=.005;l.inputState.pinching&&u>p+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&u<=p-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(s=e.getPose(t.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(lu)))}return o!==null&&(o.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new Yn;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}};var ps=class extends Ce{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 sn,this.environmentIntensity=1,this.environmentRotation=new sn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}};var ho=new N,cu=new N,hu=new Lt,Ve=class{constructor(t=new N(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,s){return this.normal.set(t,e,n),this.constant=s,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){let s=ho.subVectors(n,e).cross(cu.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){let n=t.delta(ho),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;let r=-(t.start.dot(this.normal)+this.constant)/s;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){let e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let n=e||hu.getNormalMatrix(t),s=this.coplanarPoint(ho).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}},Xn=new Ln,uu=new Ut(.5,.5),ir=new N,ms=class{constructor(t=new Ve,e=new Ve,n=new Ve,s=new Ve,r=new Ve,a=new Ve){this.planes=[t,e,n,s,r,a]}set(t,e,n,s,r,a){let o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(t){let e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=Je,n=!1){let s=this.planes,r=t.elements,a=r[0],o=r[1],c=r[2],l=r[3],h=r[4],f=r[5],u=r[6],p=r[7],g=r[8],_=r[9],m=r[10],d=r[11],T=r[12],M=r[13],v=r[14],R=r[15];if(s[0].setComponents(l-a,p-h,d-g,R-T).normalize(),s[1].setComponents(l+a,p+h,d+g,R+T).normalize(),s[2].setComponents(l+o,p+f,d+_,R+M).normalize(),s[3].setComponents(l-o,p-f,d-_,R-M).normalize(),n)s[4].setComponents(c,u,m,v).normalize(),s[5].setComponents(l-c,p-u,d-m,R-v).normalize();else if(s[4].setComponents(l-c,p-u,d-m,R-v).normalize(),e===Je)s[5].setComponents(l+c,p+u,d+m,R+v).normalize();else if(e===as)s[5].setComponents(c,u,m,v).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Xn.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{let e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Xn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Xn)}intersectsSprite(t){Xn.center.set(0,0,0);let e=uu.distanceTo(t.center);return Xn.radius=.7071067811865476+e,Xn.applyMatrix4(t.matrixWorld),this.intersectsSphere(Xn)}intersectsSphere(t){let e=this.planes,n=t.center,s=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(t){let e=this.planes;for(let n=0;n<6;n++){let s=e[n];if(ir.x=s.normal.x>0?t.max.x:t.min.x,ir.y=s.normal.y>0?t.max.y:t.min.y,ir.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(ir)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};var Un=class extends yn{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new zt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},vr=new N,Mr=new N,Dl=new ce,es=new Dn,sr=new Ln,uo=new N,Ul=new N,Ci=class extends Ce{constructor(t=new ye,e=new Un){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[0];for(let s=1,r=e.count;s<r;s++)vr.fromBufferAttribute(e,s-1),Mr.fromBufferAttribute(e,s),n[s]=n[s-1],n[s]+=vr.distanceTo(Mr);t.setAttribute("lineDistance",new Ae(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let n=this.geometry,s=this.matrixWorld,r=t.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),sr.copy(n.boundingSphere),sr.applyMatrix4(s),sr.radius+=r,t.ray.intersectsSphere(sr)===!1)return;Dl.copy(s).invert(),es.copy(t.ray).applyMatrix4(Dl);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=n.index,u=n.attributes.position;if(h!==null){let p=Math.max(0,a.start),g=Math.min(h.count,a.start+a.count);for(let _=p,m=g-1;_<m;_+=l){let d=h.getX(_),T=h.getX(_+1),M=rr(this,t,es,c,d,T,_);M&&e.push(M)}if(this.isLineLoop){let _=h.getX(g-1),m=h.getX(p),d=rr(this,t,es,c,_,m,g-1);d&&e.push(d)}}else{let p=Math.max(0,a.start),g=Math.min(u.count,a.start+a.count);for(let _=p,m=g-1;_<m;_+=l){let d=rr(this,t,es,c,_,_+1,_);d&&e.push(d)}if(this.isLineLoop){let _=rr(this,t,es,c,g-1,p,g-1);_&&e.push(_)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let s=e[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 rr(i,t,e,n,s,r,a){let o=i.geometry.attributes.position;if(vr.fromBufferAttribute(o,s),Mr.fromBufferAttribute(o,r),e.distanceSqToSegment(vr,Mr,uo,Ul)>n)return;uo.applyMatrix4(i.matrixWorld);let l=t.ray.origin.distanceTo(uo);if(!(l<t.near||l>t.far))return{distance:l,point:Ul.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}var Nl=new N,Fl=new N,Pi=class extends Ci{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let s=0,r=e.count;s<r;s+=2)Nl.fromBufferAttribute(e,s),Fl.fromBufferAttribute(e,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+Nl.distanceTo(Fl);t.setAttribute("lineDistance",new Ae(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Ii=class extends yn{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new zt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}},Ol=new ce,xo=new Dn,ar=new Ln,or=new N,gs=class extends Ce{constructor(t=new ye,e=new Ii){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){let n=this.geometry,s=this.matrixWorld,r=t.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),ar.copy(n.boundingSphere),ar.applyMatrix4(s),ar.radius+=r,t.ray.intersectsSphere(ar)===!1)return;Ol.copy(s).invert(),xo.copy(t.ray).applyMatrix4(Ol);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=n.index,f=n.attributes.position;if(l!==null){let u=Math.max(0,a.start),p=Math.min(l.count,a.start+a.count);for(let g=u,_=p;g<_;g++){let m=l.getX(g);or.fromBufferAttribute(f,m),Bl(or,m,c,s,t,e,this)}}else{let u=Math.max(0,a.start),p=Math.min(f.count,a.start+a.count);for(let g=u,_=p;g<_;g++)or.fromBufferAttribute(f,g),Bl(or,g,c,s,t,e,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let s=e[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 Bl(i,t,e,n,s,r,a){let o=xo.distanceSqToPoint(i);if(o<e){let c=new N;xo.closestPointToPoint(i,c),c.applyMatrix4(n);let l=s.ray.origin.distanceTo(c);if(l<s.near||l>s.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}var _s=class extends Re{constructor(t,e,n,s,r,a,o,c,l){super(t,e,n,s,r,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},xs=class extends Re{constructor(t,e,n=Bn,s,r,a,o=Ge,c=Ge,l,h=Si,f=1){if(h!==Si&&h!==Oi)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let u={width:t,height:e,depth:f};super(u,s,r,a,o,c,h,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new wi(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}},ys=class extends Re{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}};var vs=class i extends ye{constructor(t=1,e=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:s};let r=t/2,a=e/2,o=Math.floor(n),c=Math.floor(s),l=o+1,h=c+1,f=t/o,u=e/c,p=[],g=[],_=[],m=[];for(let d=0;d<h;d++){let T=d*u-a;for(let M=0;M<l;M++){let v=M*f-r;g.push(v,-T,0),_.push(0,0,1),m.push(M/o),m.push(1-d/c)}}for(let d=0;d<c;d++)for(let T=0;T<o;T++){let M=T+l*d,v=T+l*(d+1),R=T+1+l*(d+1),w=T+1+l*d;p.push(M,v,w),p.push(v,R,w)}this.setIndex(p),this.setAttribute("position",new Ae(g,3)),this.setAttribute("normal",new Ae(_,3)),this.setAttribute("uv",new Ae(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new i(t.width,t.height,t.widthSegments,t.heightSegments)}};var br=class extends yn{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=gc,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}},Sr=class extends yn{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}};function lr(i,t){return!i||i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function du(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}var Kn=class{constructor(t,e,n,s){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,s=e[n],r=e[n-1];n:{t:{let a;e:{i:if(!(t<s)){for(let o=n+2;;){if(s===void 0){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=s,s=e[++n],t<s)break t}a=e.length;break e}if(!(t>=r)){let o=e[1];t<o&&(n=2,r=o);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(s=r,r=e[--n-1],t>=r)break t}a=n,n=0;break e}break n}for(;n<a;){let o=n+a>>>1;t<e[o]?a=o:n=o+1}if(s=e[n],r=e[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,t,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=t*s;for(let a=0;a!==s;++a)e[a]=n[r+a];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Er=class extends Kn{constructor(t,e,n,s){super(t,e,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:fo,endingEnd:fo}}intervalChanged_(t,e,n){let s=this.parameterPositions,r=t-2,a=t+1,o=s[r],c=s[a];if(o===void 0)switch(this.getSettings_().endingStart){case po:r=t,o=2*e-n;break;case mo:r=s.length-2,o=e+s[r]-s[r+1];break;default:r=t,o=n}if(c===void 0)switch(this.getSettings_().endingEnd){case po:a=t,c=2*n-e;break;case mo:a=1,c=n+s[1]-s[0];break;default:a=t-1,c=e}let l=(n-e)*.5,h=this.valueSize;this._weightPrev=l/(e-o),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this._offsetPrev,f=this._offsetNext,u=this._weightPrev,p=this._weightNext,g=(n-e)/(s-e),_=g*g,m=_*g,d=-u*m+2*u*_-u*g,T=(1+u)*m+(-1.5-2*u)*_+(-.5+u)*g+1,M=(-1-p)*m+(1.5+p)*_+.5*g,v=p*m-p*_;for(let R=0;R!==o;++R)r[R]=d*a[h+R]+T*a[l+R]+M*a[c+R]+v*a[f+R];return r}},Tr=class extends Kn{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=(n-e)/(s-e),f=1-h;for(let u=0;u!==o;++u)r[u]=a[l+u]*f+a[c+u]*h;return r}},wr=class extends Kn{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t){return this.copySampleValue_(t-1)}},Oe=class{constructor(t,e,n,s){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=lr(e,this.TimeBufferType),this.values=lr(n,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:lr(t.times,Array),values:lr(t.values,Array)};let s=t.getInterpolation();s!==t.DefaultInterpolation&&(n.interpolation=s)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new wr(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Tr(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Er(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case ss:e=this.InterpolantFactoryMethodDiscrete;break;case pr:e=this.InterpolantFactoryMethodLinear;break;case cr:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return ss;case this.InterpolantFactoryMethodLinear:return pr;case this.InterpolantFactoryMethodSmooth:return cr}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,s=e.length;n!==s;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,s=e.length;n!==s;++n)e[n]*=t}return this}trim(t,e){let n=this.times,s=n.length,r=0,a=s-1;for(;r!==s&&n[r]<t;)++r;for(;a!==-1&&n[a]>e;)--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 t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,s=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==r;o++){let c=n[o];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,c),t=!1;break}if(a!==null&&a>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,c,a),t=!1;break}a=c}if(s!==void 0&&du(s))for(let o=0,c=s.length;o!==c;++o){let l=s[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===cr,r=t.length-1,a=1;for(let o=1;o<r;++o){let c=!1,l=t[o],h=t[o+1];if(l!==h&&(o!==1||l!==t[0]))if(s)c=!0;else{let f=o*n,u=f-n,p=f+n;for(let g=0;g!==n;++g){let _=e[f+g];if(_!==e[u+g]||_!==e[p+g]){c=!0;break}}}if(c){if(o!==a){t[a]=t[o];let f=o*n,u=a*n;for(let p=0;p!==n;++p)e[u+p]=e[f+p]}++a}}if(r>0){t[a]=t[r];for(let o=r*n,c=a*n,l=0;l!==n;++l)e[c+l]=e[o+l];++a}return a!==t.length?(this.times=t.slice(0,a),this.values=e.slice(0,a*n)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),n=this.constructor,s=new n(this.name,t,e);return s.createInterpolant=this.createInterpolant,s}};Oe.prototype.ValueTypeName="";Oe.prototype.TimeBufferType=Float32Array;Oe.prototype.ValueBufferType=Float32Array;Oe.prototype.DefaultInterpolation=pr;var Nn=class extends Oe{constructor(t,e,n){super(t,e,n)}};Nn.prototype.ValueTypeName="bool";Nn.prototype.ValueBufferType=Array;Nn.prototype.DefaultInterpolation=ss;Nn.prototype.InterpolantFactoryMethodLinear=void 0;Nn.prototype.InterpolantFactoryMethodSmooth=void 0;var Ar=class extends Oe{constructor(t,e,n,s){super(t,e,n,s)}};Ar.prototype.ValueTypeName="color";var Rr=class extends Oe{constructor(t,e,n,s){super(t,e,n,s)}};Rr.prototype.ValueTypeName="number";var Cr=class extends Kn{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-e)/(s-e),l=t*o;for(let h=l+o;l!==h;l+=4)We.slerpFlat(r,0,a,l-o,a,l,c);return r}},Ms=class extends Oe{constructor(t,e,n,s){super(t,e,n,s)}InterpolantFactoryMethodLinear(t){return new Cr(this.times,this.values,this.getValueSize(),t)}};Ms.prototype.ValueTypeName="quaternion";Ms.prototype.InterpolantFactoryMethodSmooth=void 0;var Fn=class extends Oe{constructor(t,e,n){super(t,e,n)}};Fn.prototype.ValueTypeName="string";Fn.prototype.ValueBufferType=Array;Fn.prototype.DefaultInterpolation=ss;Fn.prototype.InterpolantFactoryMethodLinear=void 0;Fn.prototype.InterpolantFactoryMethodSmooth=void 0;var Pr=class extends Oe{constructor(t,e,n,s){super(t,e,n,s)}};Pr.prototype.ValueTypeName="vector";var Ir=class{constructor(t,e,n){let s=this,r=!1,a=0,o=0,c,l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.abortController=new AbortController,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 c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,f){return l.push(h,f),this},this.removeHandler=function(h){let f=l.indexOf(h);return f!==-1&&l.splice(f,2),this},this.getHandler=function(h){for(let f=0,u=l.length;f<u;f+=2){let p=l[f],g=l[f+1];if(p.global&&(p.lastIndex=0),p.test(h))return g}return null},this.abort=function(){return this.abortController.abort(),this.abortController=new AbortController,this}}},Ic=new Ir,Lr=class{constructor(t){this.manager=t!==void 0?t:Ic,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise(function(s,r){n.load(t,s,e,r)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}};Lr.DEFAULT_MATERIAL_NAME="__DEFAULT";var Li=class extends ds{constructor(t=-1,e=1,n=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,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=t,this.view.fullHeight=e,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 t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2,r=n-t,a=n+t,o=s+e,c=s-e;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}};var Dr=class extends we{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}};var ko="\\[\\]\\.:\\/",fu=new RegExp("["+ko+"]","g"),Ho="[^"+ko+"]",pu="[^"+ko.replace("\\.","")+"]",mu=/((?:WC+[\/:])*)/.source.replace("WC",Ho),gu=/(WCOD+)?/.source.replace("WCOD",pu),_u=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Ho),xu=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Ho),yu=new RegExp("^"+mu+gu+_u+xu+"$"),vu=["material","materials","bones","map"],yo=class{constructor(t,e,n){let s=n||Qt.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,s)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},Qt=class i{constructor(t,e,n){this.path=e,this.parsedPath=n||i.parseTrackName(e),this.node=i.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new i.Composite(t,e,n):new i(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(fu,"")}static parseTrackName(t){let e=yu.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let r=n.nodeName.substring(s+1);vu.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(r){for(let a=0;a<r.length;a++){let o=r[a];if(o.name===e||o.uuid===e)return o;let c=n(o.children);if(c)return c}return null},s=n(t.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)t[e++]=n[s]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,n=e.objectName,s=e.propertyName,r=e.propertyIndex;if(t||(t=i.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=e.objectIndex;switch(n){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let h=0;h<t.length;h++)if(t[h].name===l){l=h;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(l!==void 0){if(t[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[l]}}let a=t[s];if(a===void 0){let l=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+s+" but it wasn't found.",t);return}let o=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?o=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(s==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[r]!==void 0&&(r=t.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(c=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=s;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Qt.Composite=yo;Qt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Qt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Qt.prototype.GetterByBindingType=[Qt.prototype._getValue_direct,Qt.prototype._getValue_array,Qt.prototype._getValue_arrayElement,Qt.prototype._getValue_toArray];Qt.prototype.SetterByBindingTypeAndVersioning=[[Qt.prototype._setValue_direct,Qt.prototype._setValue_direct_setNeedsUpdate,Qt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Qt.prototype._setValue_array,Qt.prototype._setValue_array_setNeedsUpdate,Qt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Qt.prototype._setValue_arrayElement,Qt.prototype._setValue_arrayElement_setNeedsUpdate,Qt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Qt.prototype._setValue_fromArray,Qt.prototype._setValue_fromArray_setNeedsUpdate,Qt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Rg=new Float32Array(1);var Di=class{constructor(t=1,e=0,n=0){this.radius=t,this.phi=e,this.theta=n}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Ot(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(Ot(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var bs=class extends Pi{constructor(t=10,e=10,n=4473924,s=8947848){n=new zt(n),s=new zt(s);let r=e/2,a=t/e,o=t/2,c=[],l=[];for(let u=0,p=0,g=-o;u<=e;u++,g+=a){c.push(-o,0,g,o,0,g),c.push(g,0,-o,g,0,o);let _=u===r?n:s;_.toArray(l,p),p+=3,_.toArray(l,p),p+=3,_.toArray(l,p),p+=3,_.toArray(l,p),p+=3}let h=new ye;h.setAttribute("position",new Ae(c,3)),h.setAttribute("color",new Ae(l,3));let f=new Un({vertexColors:!0,toneMapped:!1});super(h,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}};var Ss=class extends tn{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(t){if(t===void 0){console.warn("THREE.Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=t}disconnect(){}dispose(){}update(){}};function Vo(i,t,e,n){let s=Mu(n);switch(e){case Po:return i*t;case Lo:return i*t/s.components*s.byteLength;case Yr:return i*t/s.components*s.byteLength;case Do:return i*t*2/s.components*s.byteLength;case Zr:return i*t*2/s.components*s.byteLength;case Io:return i*t*3/s.components*s.byteLength;case qe:return i*t*4/s.components*s.byteLength;case $r:return i*t*4/s.components*s.byteLength;case As:case Rs:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Cs:case Ps:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Kr:case Qr:return Math.max(i,16)*Math.max(t,8)/4;case Jr:case jr:return Math.max(i,8)*Math.max(t,8)/2;case ta:case ea:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case na:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case ia:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case sa:return Math.floor((i+4)/5)*Math.floor((t+3)/4)*16;case ra:return Math.floor((i+4)/5)*Math.floor((t+4)/5)*16;case aa:return Math.floor((i+5)/6)*Math.floor((t+4)/5)*16;case oa:return Math.floor((i+5)/6)*Math.floor((t+5)/6)*16;case la:return Math.floor((i+7)/8)*Math.floor((t+4)/5)*16;case ca:return Math.floor((i+7)/8)*Math.floor((t+5)/6)*16;case ha:return Math.floor((i+7)/8)*Math.floor((t+7)/8)*16;case ua:return Math.floor((i+9)/10)*Math.floor((t+4)/5)*16;case da:return Math.floor((i+9)/10)*Math.floor((t+5)/6)*16;case fa:return Math.floor((i+9)/10)*Math.floor((t+7)/8)*16;case pa:return Math.floor((i+9)/10)*Math.floor((t+9)/10)*16;case ma:return Math.floor((i+11)/12)*Math.floor((t+9)/10)*16;case ga:return Math.floor((i+11)/12)*Math.floor((t+11)/12)*16;case _a:case xa:case ya:return Math.ceil(i/4)*Math.ceil(t/4)*16;case va:case Ma:return Math.ceil(i/4)*Math.ceil(t/4)*8;case ba:case Sa:return Math.ceil(i/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function Mu(i){switch(i){case an:case wo:return{byteLength:1,components:1};case Ui:case Ao:case Ni:return{byteLength:2,components:1};case Xr:case qr:return{byteLength:2,components:4};case Bn:case Wr:case on:return{byteLength:4,components:1};case Ro:case Co:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"180"}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="180");function eh(){let i=null,t=!1,e=null,n=null;function s(r,a){e(r,a),n=i.requestAnimationFrame(s)}return{start:function(){t!==!0&&e!==null&&(n=i.requestAnimationFrame(s),t=!0)},stop:function(){i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){i=r}}}function Su(i){let t=new WeakMap;function e(o,c){let l=o.array,h=o.usage,f=l.byteLength,u=i.createBuffer();i.bindBuffer(c,u),i.bufferData(c,l,h),o.onUploadCallback();let p;if(l instanceof Float32Array)p=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)p=i.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?p=i.HALF_FLOAT:p=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)p=i.SHORT;else if(l instanceof Uint32Array)p=i.UNSIGNED_INT;else if(l instanceof Int32Array)p=i.INT;else if(l instanceof Int8Array)p=i.BYTE;else if(l instanceof Uint8Array)p=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)p=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:u,type:p,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:f}}function n(o,c,l){let h=c.array,f=c.updateRanges;if(i.bindBuffer(l,o),f.length===0)i.bufferSubData(l,0,h);else{f.sort((p,g)=>p.start-g.start);let u=0;for(let p=1;p<f.length;p++){let g=f[u],_=f[p];_.start<=g.start+g.count+1?g.count=Math.max(g.count,_.start+_.count-g.start):(++u,f[u]=_)}f.length=u+1;for(let p=0,g=f.length;p<g;p++){let _=f[p];i.bufferSubData(l,_.start*h.BYTES_PER_ELEMENT,h,_.start,_.count)}c.clearUpdateRanges()}c.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),t.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);let c=t.get(o);c&&(i.deleteBuffer(c.buffer),t.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){let h=t.get(o);(!h||h.version<o.version)&&t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let l=t.get(o);if(l===void 0)t.set(o,e(o,c));else if(l.version<o.version){if(l.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(l.buffer,o,c),l.version=o.version}}return{get:s,remove:r,update:a}}var Eu=`#ifdef USE_ALPHAHASH
48
+ `},r=new Kr(5,5,5),s=new sn({name:"CubemapFromEquirect",uniforms:dr(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Qt,blending:Un});s.uniforms.tEquirect.value=t;let a=new Xt(r,s),o=t.minFilter;return t.minFilter===Ii&&(t.minFilter=kn),new Fo(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,r=!0){let s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,r);e.setRenderTarget(s)}},Dn=class extends zt{constructor(){super(),this.isGroup=!0,this.type="Group"}},Ky={type:"move"},Qr=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Dn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Dn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new N,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new N),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Dn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new N,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new N),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 i of e.hand.values())this._getHandJoint(t,i)}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,i){let r=null,s=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 y of e.hand.values()){let m=t.getJointPose(y,i),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"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,g=.005;c.inputState.pinching&&d>f+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=f-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Ky)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Dn;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}};var ir=class extends zt{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 Xn,this.environmentIntensity=1,this.environmentRotation=new Xn,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}},zo=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=ko,this.updateRanges=[],this.version=0,this.uuid=ai()}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,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];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=ai()),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]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}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=ai()),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}}},Jt=new N,qt=class n{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}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,i=this.data.count;t<i;t++)Jt.fromBufferAttribute(this,t),Jt.applyMatrix4(e),this.setXYZ(t,Jt.x,Jt.y,Jt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Jt.fromBufferAttribute(this,t),Jt.applyNormalMatrix(e),this.setXYZ(t,Jt.x,Jt.y,Jt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Jt.fromBufferAttribute(this,t),Jt.transformDirection(e),this.setXYZ(t,Jt.x,Jt.y,Jt.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=In(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=st(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,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=In(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=In(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=In(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=In(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),i=st(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),i=st(i,this.array),r=st(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),i=st(i,this.array),r=st(r,this.array),s=st(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}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 n(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}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}}};var na=class extends Kt{constructor(e=null,t=1,i=1,r,s,a,o,l,c=Bt,h=Bt,u,d){super(null,a,o,l,c,h,r,s,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Sh=new N,Qy=new N,e0=new ze,_n=class{constructor(e=new N(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,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let r=Sh.subVectors(i,t).cross(Qy.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,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){let i=e.delta(Sh),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<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 i=t||e0.getNormalMatrix(e),r=this.coplanarPoint(Sh).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},Qi=new Ai,t0=new ke(.5,.5),So=new N,ia=class{constructor(e=new _n,t=new _n,i=new _n,r=new _n,s=new _n,a=new _n){this.planes=[e,t,i,r,s,a]}set(e,t,i,r,s,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(r),o[4].copy(s),o[5].copy(a),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Ln,i=!1){let r=this.planes,s=e.elements,a=s[0],o=s[1],l=s[2],c=s[3],h=s[4],u=s[5],d=s[6],f=s[7],g=s[8],y=s[9],m=s[10],p=s[11],M=s[12],S=s[13],x=s[14],A=s[15];if(r[0].setComponents(c-a,f-h,p-g,A-M).normalize(),r[1].setComponents(c+a,f+h,p+g,A+M).normalize(),r[2].setComponents(c+o,f+u,p+y,A+S).normalize(),r[3].setComponents(c-o,f-u,p-y,A-S).normalize(),i)r[4].setComponents(l,d,m,x).normalize(),r[5].setComponents(c-l,f-d,p-m,A-x).normalize();else if(r[4].setComponents(c-l,f-d,p-m,A-x).normalize(),t===Ln)r[5].setComponents(c+l,f+d,p+m,A+x).normalize();else if(t===qs)r[5].setComponents(l,d,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(),Qi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Qi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Qi)}intersectsSprite(e){Qi.center.set(0,0,0);let t=t0.distanceTo(e.center);return Qi.radius=.7071067811865476+t,Qi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Qi)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let r=t[i];if(So.x=r.normal.x>0?e.max.x:e.min.x,So.y=r.normal.y>0?e.max.y:e.min.y,So.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(So)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};var rr=class extends hi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ze(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}},Vo=new N,Ho=new N,cf=new St,Hs=new Ci,wo=new Ai,wh=new N,hf=new N,es=class extends zt{constructor(e=new Tt,t=new rr){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,i=[0];for(let r=1,s=t.count;r<s;r++)Vo.fromBufferAttribute(t,r-1),Ho.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Vo.distanceTo(Ho);e.setAttribute("lineDistance",new $t(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),wo.copy(i.boundingSphere),wo.applyMatrix4(r),wo.radius+=s,e.ray.intersectsSphere(wo)===!1)return;cf.copy(r).invert(),Hs.copy(e.ray).applyMatrix4(cf);let o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=i.index,d=i.attributes.position;if(h!==null){let f=Math.max(0,a.start),g=Math.min(h.count,a.start+a.count);for(let y=f,m=g-1;y<m;y+=c){let p=h.getX(y),M=h.getX(y+1),S=Mo(this,e,Hs,l,p,M,y);S&&t.push(S)}if(this.isLineLoop){let y=h.getX(g-1),m=h.getX(f),p=Mo(this,e,Hs,l,y,m,g-1);p&&t.push(p)}}else{let f=Math.max(0,a.start),g=Math.min(d.count,a.start+a.count);for(let y=f,m=g-1;y<m;y+=c){let p=Mo(this,e,Hs,l,y,y+1,y);p&&t.push(p)}if(this.isLineLoop){let y=Mo(this,e,Hs,l,g-1,f,g-1);y&&t.push(y)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){let o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}};function Mo(n,e,t,i,r,s,a){let o=n.geometry.attributes.position;if(Vo.fromBufferAttribute(o,r),Ho.fromBufferAttribute(o,s),t.distanceSqToSegment(Vo,Ho,wh,hf)>i)return;wh.applyMatrix4(n.matrixWorld);let c=e.ray.origin.distanceTo(wh);if(!(c<e.near||c>e.far))return{distance:c,point:hf.clone().applyMatrix4(n.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:n}}var uf=new N,df=new N,ts=class extends es{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,i=[];for(let r=0,s=t.count;r<s;r+=2)uf.fromBufferAttribute(t,r),df.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+uf.distanceTo(df);e.setAttribute("lineDistance",new $t(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var sr=class extends hi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ze(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!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.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},ff=new St,Ch=new Ci,Eo=new Ai,To=new N,ns=class extends zt{constructor(e=new Tt,t=new sr){super(),this.isPoints=!0,this.type="Points",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}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Eo.copy(i.boundingSphere),Eo.applyMatrix4(r),Eo.radius+=s,e.ray.intersectsSphere(Eo)===!1)return;ff.copy(r).invert(),Ch.copy(e.ray).applyMatrix4(ff);let o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=i.index,u=i.attributes.position;if(c!==null){let d=Math.max(0,a.start),f=Math.min(c.count,a.start+a.count);for(let g=d,y=f;g<y;g++){let m=c.getX(g);To.fromBufferAttribute(u,m),pf(To,m,l,r,e,t,this)}}else{let d=Math.max(0,a.start),f=Math.min(u.count,a.start+a.count);for(let g=d,y=f;g<y;g++)To.fromBufferAttribute(u,g),pf(To,g,l,r,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){let o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}};function pf(n,e,t,i,r,s,a){let o=Ch.distanceSqToPoint(n);if(o<t){let l=new N;Ch.closestPointToPoint(n,l),l.applyMatrix4(i);let c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}var ra=class extends Kt{constructor(e,t,i,r,s,a,o,l,c){super(e,t,i,r,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},sa=class extends Kt{constructor(e,t,i=Li,r,s,a,o=Bt,l=Bt,c,h=Yr,u=1){if(h!==Yr&&h!==os)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:e,height:t,depth:u};super(d,r,s,a,o,l,h,i,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Jr(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}},aa=class extends Kt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}};var ar=class n extends Tt{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};let s=e/2,a=t/2,o=Math.floor(i),l=Math.floor(r),c=o+1,h=l+1,u=e/o,d=t/l,f=[],g=[],y=[],m=[];for(let p=0;p<h;p++){let M=p*d-a;for(let S=0;S<c;S++){let x=S*u-s;g.push(x,-M,0),y.push(0,0,1),m.push(S/o),m.push(1-p/l)}}for(let p=0;p<l;p++)for(let M=0;M<o;M++){let S=M+c*p,x=M+c*(p+1),A=M+1+c*(p+1),T=M+1+c*p;f.push(S,x,T),f.push(x,A,T)}this.setIndex(f),this.setAttribute("position",new $t(g,3)),this.setAttribute("normal",new $t(y,3)),this.setAttribute("uv",new $t(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.widthSegments,e.heightSegments)}};var Go=class extends hi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=qf,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}},Wo=class extends hi{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 Ao(n,e){return!n||n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function n0(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}var or=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];n:{e:{let a;t:{i:if(!(e<r)){for(let o=i+2;;){if(r===void 0){if(e<s)break i;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(s=r,r=t[++i],e<r)break e}a=t.length;break t}if(!(e>=s)){let o=t[1];e<o&&(i=2,s=o);for(let l=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(r=s,s=t[--i-1],e>=s)break e}a=i,i=0;break t}break n}for(;i<a;){let o=i+a>>>1;e<t[o]?a=o:i=o+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let a=0;a!==r;++a)t[a]=i[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},$o=class extends or{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Mh,endingEnd:Mh}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,a=e+1,o=r[s],l=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case Eh:s=e,o=2*t-i;break;case Th:s=r.length-2,o=t+r[s]-r[s+1];break;default:s=e,o=i}if(l===void 0)switch(this.getSettings_().endingEnd){case Eh:a=e,l=2*i-t;break;case Th:a=1,l=i+r[1]-r[0];break;default:a=e-1,l=t}let c=(i-t)*.5,h=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-i),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,g=(i-t)/(r-t),y=g*g,m=y*g,p=-d*m+2*d*y-d*g,M=(1+d)*m+(-1.5-2*d)*y+(-.5+d)*g+1,S=(-1-f)*m+(1.5+f)*y+.5*g,x=f*m-f*y;for(let A=0;A!==o;++A)s[A]=p*a[h+A]+M*a[c+A]+S*a[l+A]+x*a[u+A];return s}},Xo=class extends or{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=(i-t)/(r-t),u=1-h;for(let d=0;d!==o;++d)s[d]=a[c+d]*u+a[l+d]*h;return s}},qo=class extends or{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},mn=class{constructor(e,t,i,r){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=Ao(t,this.TimeBufferType),this.values=Ao(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Ao(e.times,Array),values:Ao(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new qo(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Xo(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new $o(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case $s:t=this.InterpolantFactoryMethodDiscrete;break;case Do:t=this.InterpolantFactoryMethodLinear;break;case Co:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="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(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return $s;case this.InterpolantFactoryMethodLinear:return Do;case this.InterpolantFactoryMethodSmooth:return Co}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,a=r-1;for(;s!==r&&i[s]<e;)++s;for(;a!==-1&&i[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);let o=this.getValueSize();this.times=i.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){let l=i[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(r!==void 0&&n0(r))for(let o=0,l=r.length;o!==l;++o){let c=r[o];if(isNaN(c)){console.error("THREE.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(),i=this.getValueSize(),r=this.getInterpolation()===Co,s=e.length-1,a=1;for(let o=1;o<s;++o){let l=!1,c=e[o],h=e[o+1];if(c!==h&&(o!==1||c!==e[0]))if(r)l=!0;else{let u=o*i,d=u-i,f=u+i;for(let g=0;g!==i;++g){let y=t[u+g];if(y!==t[d+g]||y!==t[f+g]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];let u=o*i,d=a*i;for(let f=0;f!==i;++f)t[d+f]=t[u+f]}++a}}if(s>0){e[a]=e[s];for(let o=s*i,l=a*i,c=0;c!==i;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*i)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};mn.prototype.ValueTypeName="";mn.prototype.TimeBufferType=Float32Array;mn.prototype.ValueBufferType=Float32Array;mn.prototype.DefaultInterpolation=Do;var Ri=class extends mn{constructor(e,t,i){super(e,t,i)}};Ri.prototype.ValueTypeName="bool";Ri.prototype.ValueBufferType=Array;Ri.prototype.DefaultInterpolation=$s;Ri.prototype.InterpolantFactoryMethodLinear=void 0;Ri.prototype.InterpolantFactoryMethodSmooth=void 0;var Yo=class extends mn{constructor(e,t,i,r){super(e,t,i,r)}};Yo.prototype.ValueTypeName="color";var jo=class extends mn{constructor(e,t,i,r){super(e,t,i,r)}};jo.prototype.ValueTypeName="number";var Zo=class extends or{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(i-t)/(r-t),c=e*o;for(let h=c+o;c!==h;c+=4)bn.slerpFlat(s,0,a,c-o,a,c,l);return s}},oa=class extends mn{constructor(e,t,i,r){super(e,t,i,r)}InterpolantFactoryMethodLinear(e){return new Zo(this.times,this.values,this.getValueSize(),e)}};oa.prototype.ValueTypeName="quaternion";oa.prototype.InterpolantFactoryMethodSmooth=void 0;var Pi=class extends mn{constructor(e,t,i){super(e,t,i)}};Pi.prototype.ValueTypeName="string";Pi.prototype.ValueBufferType=Array;Pi.prototype.DefaultInterpolation=$s;Pi.prototype.InterpolantFactoryMethodLinear=void 0;Pi.prototype.InterpolantFactoryMethodSmooth=void 0;var Jo=class extends mn{constructor(e,t,i,r){super(e,t,i,r)}};Jo.prototype.ValueTypeName="vector";var Ko=class{constructor(e,t,i){let r=this,s=!1,a=0,o=0,l,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.abortController=new AbortController,this.itemStart=function(h){o++,s===!1&&r.onStart!==void 0&&r.onStart(h,a,o),s=!0},this.itemEnd=function(h){a++,r.onProgress!==void 0&&r.onProgress(h,a,o),a===o&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){let u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=c.length;u<d;u+=2){let f=c[u],g=c[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return g}return null},this.abort=function(){return this.abortController.abort(),this.abortController=new AbortController,this}}},lp=new Ko,Qo=class{constructor(e){this.manager=e!==void 0?e:lp,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}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}};Qo.DEFAULT_MATERIAL_NAME="__DEFAULT";var Nn=class extends ea{constructor(e=-1,t=1,i=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,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,i,r,s,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=i,this.view.offsetY=r,this.view.width=s,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),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,s=i-e,a=i+e,o=r+t,l=r-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;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,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}};var la=class extends Tt{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}};var el=class extends Wt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}};var Zh="\\[\\]\\.:\\/",i0=new RegExp("["+Zh+"]","g"),Jh="[^"+Zh+"]",r0="[^"+Zh.replace("\\.","")+"]",s0=/((?:WC+[\/:])*)/.source.replace("WC",Jh),a0=/(WCOD+)?/.source.replace("WCOD",r0),o0=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Jh),l0=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Jh),c0=new RegExp("^"+s0+a0+o0+l0+"$"),h0=["material","materials","bones","map"],Rh=class{constructor(e,t,i){let r=i||pt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},pt=class n{constructor(e,t,i){this.path=t,this.parsedPath=i||n.parseTrackName(t),this.node=n.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new n.Composite(e,t,i):new n(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(i0,"")}static parseTrackName(e){let t=c0.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=i.nodeName.substring(r+1);h0.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let a=0;a<s.length;a++){let o=s[a];if(o.name===t||o.uuid===t)return o;let l=i(o.children);if(l)return l}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_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 i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=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,i=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=n.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let c=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.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){console.error("THREE.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){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.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[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let a=e[r];if(a===void 0){let c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+r+" 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(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}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=r;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=Rh;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 Xw=new Float32Array(1);var lr=class extends zo{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}};var is=class{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Xe(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Xe(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var mf=new ke,ca=class{constructor(e=new ke(1/0,1/0),t=new ke(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=mf.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}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=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(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}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,mf).distanceTo(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}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)}};var ha=class extends Wn{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){console.warn("THREE.Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}};function Kh(n,e,t,i){let r=u0(i);switch(t){case Vh:return n*e;case Gh:return n*e/r.components*r.byteLength;case pl:return n*e/r.components*r.byteLength;case Wh:return n*e*2/r.components*r.byteLength;case ml:return n*e*2/r.components*r.byteLength;case Hh:return n*e*3/r.components*r.byteLength;case an:return n*e*4/r.components*r.byteLength;case gl:return n*e*4/r.components*r.byteLength;case fa:case pa:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case ma:case ga:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case vl:case _l:return Math.max(n,16)*Math.max(e,8)/4;case yl:case xl:return Math.max(n,8)*Math.max(e,8)/2;case bl:case Sl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case wl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Ml:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case El:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Tl:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case Al:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Cl:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case Rl:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Pl:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Il:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case Ll:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case Dl:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case kl:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case Nl:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case Ol:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case Ul:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case Fl:case Bl:case zl:return Math.ceil(n/4)*Math.ceil(e/4)*16;case Vl:case Hl:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Gl:case Wl:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function u0(n){switch(n){case Yn:case Uh:return{byteLength:1,components:1};case rs:case Fh:case ss:return{byteLength:2,components:1};case dl:case fl:return{byteLength:2,components:4};case Li:case ul:case En:return{byteLength:4,components:1};case Bh:case zh:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"180"}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="180");function Lp(){let n=null,e=!1,t=null,i=null;function r(s,a){t(s,a),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function f0(n){let e=new WeakMap;function t(o,l){let c=o.array,h=o.usage,u=c.byteLength,d=n.createBuffer();n.bindBuffer(l,d),n.bufferData(l,c,h),o.onUploadCallback();let f;if(c instanceof Float32Array)f=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=n.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=n.HALF_FLOAT:f=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=n.SHORT;else if(c instanceof Uint32Array)f=n.UNSIGNED_INT;else if(c instanceof Int32Array)f=n.INT;else if(c instanceof Int8Array)f=n.BYTE;else if(c instanceof Uint8Array)f=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:u}}function i(o,l,c){let h=l.array,u=l.updateRanges;if(n.bindBuffer(c,o),u.length===0)n.bufferSubData(c,0,h);else{u.sort((f,g)=>f.start-g.start);let d=0;for(let f=1;f<u.length;f++){let g=u[d],y=u[f];y.start<=g.start+g.count+1?g.count=Math.max(g.count,y.start+y.count-g.start):(++d,u[d]=y)}u.length=d+1;for(let f=0,g=u.length;f<g;f++){let y=u[f];n.bufferSubData(c,y.start*h.BYTES_PER_ELEMENT,h,y.start,y.count)}l.clearUpdateRanges()}l.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);let l=e.get(o);l&&(n.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.");i(c.buffer,o,l),c.version=o.version}}return{get:r,remove:s,update:a}}var p0=`#ifdef USE_ALPHAHASH
41
49
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
42
- #endif`,Tu=`#ifdef USE_ALPHAHASH
50
+ #endif`,m0=`#ifdef USE_ALPHAHASH
43
51
  const float ALPHA_HASH_SCALE = 0.05;
44
52
  float hash2D( vec2 value ) {
45
53
  return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -74,20 +82,20 @@
74
82
  : cases.z;
75
83
  return clamp( threshold , 1.0e-6, 1.0 );
76
84
  }
77
- #endif`,wu=`#ifdef USE_ALPHAMAP
85
+ #endif`,g0=`#ifdef USE_ALPHAMAP
78
86
  diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
79
- #endif`,Au=`#ifdef USE_ALPHAMAP
87
+ #endif`,y0=`#ifdef USE_ALPHAMAP
80
88
  uniform sampler2D alphaMap;
81
- #endif`,Ru=`#ifdef USE_ALPHATEST
89
+ #endif`,v0=`#ifdef USE_ALPHATEST
82
90
  #ifdef ALPHA_TO_COVERAGE
83
91
  diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
84
92
  if ( diffuseColor.a == 0.0 ) discard;
85
93
  #else
86
94
  if ( diffuseColor.a < alphaTest ) discard;
87
95
  #endif
88
- #endif`,Cu=`#ifdef USE_ALPHATEST
96
+ #endif`,x0=`#ifdef USE_ALPHATEST
89
97
  uniform float alphaTest;
90
- #endif`,Pu=`#ifdef USE_AOMAP
98
+ #endif`,_0=`#ifdef USE_AOMAP
91
99
  float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
92
100
  reflectedLight.indirectDiffuse *= ambientOcclusion;
93
101
  #if defined( USE_CLEARCOAT )
@@ -100,10 +108,10 @@
100
108
  float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
101
109
  reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
102
110
  #endif
103
- #endif`,Iu=`#ifdef USE_AOMAP
111
+ #endif`,b0=`#ifdef USE_AOMAP
104
112
  uniform sampler2D aoMap;
105
113
  uniform float aoMapIntensity;
106
- #endif`,Lu=`#ifdef USE_BATCHING
114
+ #endif`,S0=`#ifdef USE_BATCHING
107
115
  #if ! defined( GL_ANGLE_multi_draw )
108
116
  #define gl_DrawID _gl_DrawID
109
117
  uniform int _gl_DrawID;
@@ -137,15 +145,15 @@
137
145
  int y = j / size;
138
146
  return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
139
147
  }
140
- #endif`,Du=`#ifdef USE_BATCHING
148
+ #endif`,w0=`#ifdef USE_BATCHING
141
149
  mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
142
- #endif`,Uu=`vec3 transformed = vec3( position );
150
+ #endif`,M0=`vec3 transformed = vec3( position );
143
151
  #ifdef USE_ALPHAHASH
144
152
  vPosition = vec3( position );
145
- #endif`,Nu=`vec3 objectNormal = vec3( normal );
153
+ #endif`,E0=`vec3 objectNormal = vec3( normal );
146
154
  #ifdef USE_TANGENT
147
155
  vec3 objectTangent = vec3( tangent.xyz );
148
- #endif`,Fu=`float G_BlinnPhong_Implicit( ) {
156
+ #endif`,T0=`float G_BlinnPhong_Implicit( ) {
149
157
  return 0.25;
150
158
  }
151
159
  float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -159,7 +167,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
159
167
  float G = G_BlinnPhong_Implicit( );
160
168
  float D = D_BlinnPhong( shininess, dotNH );
161
169
  return F * ( G * D );
162
- } // validated`,Ou=`#ifdef USE_IRIDESCENCE
170
+ } // validated`,A0=`#ifdef USE_IRIDESCENCE
163
171
  const mat3 XYZ_TO_REC709 = mat3(
164
172
  3.2404542, -0.9692660, 0.0556434,
165
173
  -1.5371385, 1.8760108, -0.2040259,
@@ -222,7 +230,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
222
230
  }
223
231
  return max( I, vec3( 0.0 ) );
224
232
  }
225
- #endif`,Bu=`#ifdef USE_BUMPMAP
233
+ #endif`,C0=`#ifdef USE_BUMPMAP
226
234
  uniform sampler2D bumpMap;
227
235
  uniform float bumpScale;
228
236
  vec2 dHdxy_fwd() {
@@ -243,7 +251,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
243
251
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
244
252
  return normalize( abs( fDet ) * surf_norm - vGrad );
245
253
  }
246
- #endif`,zu=`#if NUM_CLIPPING_PLANES > 0
254
+ #endif`,R0=`#if NUM_CLIPPING_PLANES > 0
247
255
  vec4 plane;
248
256
  #ifdef ALPHA_TO_COVERAGE
249
257
  float distanceToPlane, distanceGradient;
@@ -289,26 +297,26 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
289
297
  if ( clipped ) discard;
290
298
  #endif
291
299
  #endif
292
- #endif`,ku=`#if NUM_CLIPPING_PLANES > 0
300
+ #endif`,P0=`#if NUM_CLIPPING_PLANES > 0
293
301
  varying vec3 vClipPosition;
294
302
  uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
295
- #endif`,Hu=`#if NUM_CLIPPING_PLANES > 0
303
+ #endif`,I0=`#if NUM_CLIPPING_PLANES > 0
296
304
  varying vec3 vClipPosition;
297
- #endif`,Vu=`#if NUM_CLIPPING_PLANES > 0
305
+ #endif`,L0=`#if NUM_CLIPPING_PLANES > 0
298
306
  vClipPosition = - mvPosition.xyz;
299
- #endif`,Gu=`#if defined( USE_COLOR_ALPHA )
307
+ #endif`,D0=`#if defined( USE_COLOR_ALPHA )
300
308
  diffuseColor *= vColor;
301
309
  #elif defined( USE_COLOR )
302
310
  diffuseColor.rgb *= vColor;
303
- #endif`,Wu=`#if defined( USE_COLOR_ALPHA )
311
+ #endif`,k0=`#if defined( USE_COLOR_ALPHA )
304
312
  varying vec4 vColor;
305
313
  #elif defined( USE_COLOR )
306
314
  varying vec3 vColor;
307
- #endif`,Xu=`#if defined( USE_COLOR_ALPHA )
315
+ #endif`,N0=`#if defined( USE_COLOR_ALPHA )
308
316
  varying vec4 vColor;
309
317
  #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
310
318
  varying vec3 vColor;
311
- #endif`,qu=`#if defined( USE_COLOR_ALPHA )
319
+ #endif`,O0=`#if defined( USE_COLOR_ALPHA )
312
320
  vColor = vec4( 1.0 );
313
321
  #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
314
322
  vColor = vec3( 1.0 );
@@ -322,7 +330,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
322
330
  #ifdef USE_BATCHING_COLOR
323
331
  vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
324
332
  vColor.xyz *= batchingColor.xyz;
325
- #endif`,Yu=`#define PI 3.141592653589793
333
+ #endif`,U0=`#define PI 3.141592653589793
326
334
  #define PI2 6.283185307179586
327
335
  #define PI_HALF 1.5707963267948966
328
336
  #define RECIPROCAL_PI 0.3183098861837907
@@ -396,7 +404,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
396
404
  float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
397
405
  float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
398
406
  return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
399
- } // validated`,Zu=`#ifdef ENVMAP_TYPE_CUBE_UV
407
+ } // validated`,F0=`#ifdef ENVMAP_TYPE_CUBE_UV
400
408
  #define cubeUV_minMipLevel 4.0
401
409
  #define cubeUV_minTileSize 16.0
402
410
  float getFace( vec3 direction ) {
@@ -489,7 +497,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
489
497
  return vec4( mix( color0, color1, mipF ), 1.0 );
490
498
  }
491
499
  }
492
- #endif`,$u=`vec3 transformedNormal = objectNormal;
500
+ #endif`,B0=`vec3 transformedNormal = objectNormal;
493
501
  #ifdef USE_TANGENT
494
502
  vec3 transformedTangent = objectTangent;
495
503
  #endif
@@ -518,21 +526,21 @@ transformedNormal = normalMatrix * transformedNormal;
518
526
  #ifdef FLIP_SIDED
519
527
  transformedTangent = - transformedTangent;
520
528
  #endif
521
- #endif`,Ju=`#ifdef USE_DISPLACEMENTMAP
529
+ #endif`,z0=`#ifdef USE_DISPLACEMENTMAP
522
530
  uniform sampler2D displacementMap;
523
531
  uniform float displacementScale;
524
532
  uniform float displacementBias;
525
- #endif`,Ku=`#ifdef USE_DISPLACEMENTMAP
533
+ #endif`,V0=`#ifdef USE_DISPLACEMENTMAP
526
534
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
527
- #endif`,ju=`#ifdef USE_EMISSIVEMAP
535
+ #endif`,H0=`#ifdef USE_EMISSIVEMAP
528
536
  vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
529
537
  #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
530
538
  emissiveColor = sRGBTransferEOTF( emissiveColor );
531
539
  #endif
532
540
  totalEmissiveRadiance *= emissiveColor.rgb;
533
- #endif`,Qu=`#ifdef USE_EMISSIVEMAP
541
+ #endif`,G0=`#ifdef USE_EMISSIVEMAP
534
542
  uniform sampler2D emissiveMap;
535
- #endif`,td="gl_FragColor = linearToOutputTexel( gl_FragColor );",ed=`vec4 LinearTransferOETF( in vec4 value ) {
543
+ #endif`,W0="gl_FragColor = linearToOutputTexel( gl_FragColor );",$0=`vec4 LinearTransferOETF( in vec4 value ) {
536
544
  return value;
537
545
  }
538
546
  vec4 sRGBTransferEOTF( in vec4 value ) {
@@ -540,7 +548,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
540
548
  }
541
549
  vec4 sRGBTransferOETF( in vec4 value ) {
542
550
  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 );
543
- }`,nd=`#ifdef USE_ENVMAP
551
+ }`,X0=`#ifdef USE_ENVMAP
544
552
  #ifdef ENV_WORLDPOS
545
553
  vec3 cameraToFrag;
546
554
  if ( isOrthographic ) {
@@ -569,7 +577,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
569
577
  #elif defined( ENVMAP_BLENDING_ADD )
570
578
  outgoingLight += envColor.xyz * specularStrength * reflectivity;
571
579
  #endif
572
- #endif`,id=`#ifdef USE_ENVMAP
580
+ #endif`,q0=`#ifdef USE_ENVMAP
573
581
  uniform float envMapIntensity;
574
582
  uniform float flipEnvMap;
575
583
  uniform mat3 envMapRotation;
@@ -579,7 +587,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
579
587
  uniform sampler2D envMap;
580
588
  #endif
581
589
 
582
- #endif`,sd=`#ifdef USE_ENVMAP
590
+ #endif`,Y0=`#ifdef USE_ENVMAP
583
591
  uniform float reflectivity;
584
592
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
585
593
  #define ENV_WORLDPOS
@@ -590,7 +598,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
590
598
  #else
591
599
  varying vec3 vReflect;
592
600
  #endif
593
- #endif`,rd=`#ifdef USE_ENVMAP
601
+ #endif`,j0=`#ifdef USE_ENVMAP
594
602
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
595
603
  #define ENV_WORLDPOS
596
604
  #endif
@@ -601,7 +609,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
601
609
  varying vec3 vReflect;
602
610
  uniform float refractionRatio;
603
611
  #endif
604
- #endif`,ad=`#ifdef USE_ENVMAP
612
+ #endif`,Z0=`#ifdef USE_ENVMAP
605
613
  #ifdef ENV_WORLDPOS
606
614
  vWorldPosition = worldPosition.xyz;
607
615
  #else
@@ -618,18 +626,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
618
626
  vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
619
627
  #endif
620
628
  #endif
621
- #endif`,od=`#ifdef USE_FOG
629
+ #endif`,J0=`#ifdef USE_FOG
622
630
  vFogDepth = - mvPosition.z;
623
- #endif`,ld=`#ifdef USE_FOG
631
+ #endif`,K0=`#ifdef USE_FOG
624
632
  varying float vFogDepth;
625
- #endif`,cd=`#ifdef USE_FOG
633
+ #endif`,Q0=`#ifdef USE_FOG
626
634
  #ifdef FOG_EXP2
627
635
  float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
628
636
  #else
629
637
  float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
630
638
  #endif
631
639
  gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
632
- #endif`,hd=`#ifdef USE_FOG
640
+ #endif`,ev=`#ifdef USE_FOG
633
641
  uniform vec3 fogColor;
634
642
  varying float vFogDepth;
635
643
  #ifdef FOG_EXP2
@@ -638,7 +646,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
638
646
  uniform float fogNear;
639
647
  uniform float fogFar;
640
648
  #endif
641
- #endif`,ud=`#ifdef USE_GRADIENTMAP
649
+ #endif`,tv=`#ifdef USE_GRADIENTMAP
642
650
  uniform sampler2D gradientMap;
643
651
  #endif
644
652
  vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -650,12 +658,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
650
658
  vec2 fw = fwidth( coord ) * 0.5;
651
659
  return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
652
660
  #endif
653
- }`,dd=`#ifdef USE_LIGHTMAP
661
+ }`,nv=`#ifdef USE_LIGHTMAP
654
662
  uniform sampler2D lightMap;
655
663
  uniform float lightMapIntensity;
656
- #endif`,fd=`LambertMaterial material;
664
+ #endif`,iv=`LambertMaterial material;
657
665
  material.diffuseColor = diffuseColor.rgb;
658
- material.specularStrength = specularStrength;`,pd=`varying vec3 vViewPosition;
666
+ material.specularStrength = specularStrength;`,rv=`varying vec3 vViewPosition;
659
667
  struct LambertMaterial {
660
668
  vec3 diffuseColor;
661
669
  float specularStrength;
@@ -669,7 +677,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
669
677
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
670
678
  }
671
679
  #define RE_Direct RE_Direct_Lambert
672
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,md=`uniform bool receiveShadow;
680
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,sv=`uniform bool receiveShadow;
673
681
  uniform vec3 ambientLightColor;
674
682
  #if defined( USE_LIGHT_PROBES )
675
683
  uniform vec3 lightProbe[ 9 ];
@@ -785,7 +793,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
785
793
  vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
786
794
  return irradiance;
787
795
  }
788
- #endif`,gd=`#ifdef USE_ENVMAP
796
+ #endif`,av=`#ifdef USE_ENVMAP
789
797
  vec3 getIBLIrradiance( const in vec3 normal ) {
790
798
  #ifdef ENVMAP_TYPE_CUBE_UV
791
799
  vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
@@ -818,8 +826,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
818
826
  #endif
819
827
  }
820
828
  #endif
821
- #endif`,_d=`ToonMaterial material;
822
- material.diffuseColor = diffuseColor.rgb;`,xd=`varying vec3 vViewPosition;
829
+ #endif`,ov=`ToonMaterial material;
830
+ material.diffuseColor = diffuseColor.rgb;`,lv=`varying vec3 vViewPosition;
823
831
  struct ToonMaterial {
824
832
  vec3 diffuseColor;
825
833
  };
@@ -831,11 +839,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
831
839
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
832
840
  }
833
841
  #define RE_Direct RE_Direct_Toon
834
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,yd=`BlinnPhongMaterial material;
842
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,cv=`BlinnPhongMaterial material;
835
843
  material.diffuseColor = diffuseColor.rgb;
836
844
  material.specularColor = specular;
837
845
  material.specularShininess = shininess;
838
- material.specularStrength = specularStrength;`,vd=`varying vec3 vViewPosition;
846
+ material.specularStrength = specularStrength;`,hv=`varying vec3 vViewPosition;
839
847
  struct BlinnPhongMaterial {
840
848
  vec3 diffuseColor;
841
849
  vec3 specularColor;
@@ -852,7 +860,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
852
860
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
853
861
  }
854
862
  #define RE_Direct RE_Direct_BlinnPhong
855
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Md=`PhysicalMaterial material;
863
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,uv=`PhysicalMaterial material;
856
864
  material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
857
865
  vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
858
866
  float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
@@ -938,7 +946,7 @@ material.roughness = min( material.roughness, 1.0 );
938
946
  material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
939
947
  material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
940
948
  material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
941
- #endif`,bd=`struct PhysicalMaterial {
949
+ #endif`,dv=`struct PhysicalMaterial {
942
950
  vec3 diffuseColor;
943
951
  float roughness;
944
952
  vec3 specularColor;
@@ -1239,7 +1247,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
1239
1247
  #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1240
1248
  float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1241
1249
  return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1242
- }`,Sd=`
1250
+ }`,fv=`
1243
1251
  vec3 geometryPosition = - vViewPosition;
1244
1252
  vec3 geometryNormal = normal;
1245
1253
  vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1354,7 +1362,7 @@ IncidentLight directLight;
1354
1362
  #if defined( RE_IndirectSpecular )
1355
1363
  vec3 radiance = vec3( 0.0 );
1356
1364
  vec3 clearcoatRadiance = vec3( 0.0 );
1357
- #endif`,Ed=`#if defined( RE_IndirectDiffuse )
1365
+ #endif`,pv=`#if defined( RE_IndirectDiffuse )
1358
1366
  #ifdef USE_LIGHTMAP
1359
1367
  vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1360
1368
  vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1373,32 +1381,32 @@ IncidentLight directLight;
1373
1381
  #ifdef USE_CLEARCOAT
1374
1382
  clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1375
1383
  #endif
1376
- #endif`,Td=`#if defined( RE_IndirectDiffuse )
1384
+ #endif`,mv=`#if defined( RE_IndirectDiffuse )
1377
1385
  RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1378
1386
  #endif
1379
1387
  #if defined( RE_IndirectSpecular )
1380
1388
  RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1381
- #endif`,wd=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1389
+ #endif`,gv=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1382
1390
  gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1383
- #endif`,Ad=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1391
+ #endif`,yv=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1384
1392
  uniform float logDepthBufFC;
1385
1393
  varying float vFragDepth;
1386
1394
  varying float vIsPerspective;
1387
- #endif`,Rd=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1395
+ #endif`,vv=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1388
1396
  varying float vFragDepth;
1389
1397
  varying float vIsPerspective;
1390
- #endif`,Cd=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1398
+ #endif`,xv=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1391
1399
  vFragDepth = 1.0 + gl_Position.w;
1392
1400
  vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1393
- #endif`,Pd=`#ifdef USE_MAP
1401
+ #endif`,_v=`#ifdef USE_MAP
1394
1402
  vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1395
1403
  #ifdef DECODE_VIDEO_TEXTURE
1396
1404
  sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1397
1405
  #endif
1398
1406
  diffuseColor *= sampledDiffuseColor;
1399
- #endif`,Id=`#ifdef USE_MAP
1407
+ #endif`,bv=`#ifdef USE_MAP
1400
1408
  uniform sampler2D map;
1401
- #endif`,Ld=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1409
+ #endif`,Sv=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1402
1410
  #if defined( USE_POINTS_UV )
1403
1411
  vec2 uv = vUv;
1404
1412
  #else
@@ -1410,7 +1418,7 @@ IncidentLight directLight;
1410
1418
  #endif
1411
1419
  #ifdef USE_ALPHAMAP
1412
1420
  diffuseColor.a *= texture2D( alphaMap, uv ).g;
1413
- #endif`,Dd=`#if defined( USE_POINTS_UV )
1421
+ #endif`,wv=`#if defined( USE_POINTS_UV )
1414
1422
  varying vec2 vUv;
1415
1423
  #else
1416
1424
  #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1422,19 +1430,19 @@ IncidentLight directLight;
1422
1430
  #endif
1423
1431
  #ifdef USE_ALPHAMAP
1424
1432
  uniform sampler2D alphaMap;
1425
- #endif`,Ud=`float metalnessFactor = metalness;
1433
+ #endif`,Mv=`float metalnessFactor = metalness;
1426
1434
  #ifdef USE_METALNESSMAP
1427
1435
  vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1428
1436
  metalnessFactor *= texelMetalness.b;
1429
- #endif`,Nd=`#ifdef USE_METALNESSMAP
1437
+ #endif`,Ev=`#ifdef USE_METALNESSMAP
1430
1438
  uniform sampler2D metalnessMap;
1431
- #endif`,Fd=`#ifdef USE_INSTANCING_MORPH
1439
+ #endif`,Tv=`#ifdef USE_INSTANCING_MORPH
1432
1440
  float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1433
1441
  float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1434
1442
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1435
1443
  morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1436
1444
  }
1437
- #endif`,Od=`#if defined( USE_MORPHCOLORS )
1445
+ #endif`,Av=`#if defined( USE_MORPHCOLORS )
1438
1446
  vColor *= morphTargetBaseInfluence;
1439
1447
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1440
1448
  #if defined( USE_COLOR_ALPHA )
@@ -1443,12 +1451,12 @@ IncidentLight directLight;
1443
1451
  if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1444
1452
  #endif
1445
1453
  }
1446
- #endif`,Bd=`#ifdef USE_MORPHNORMALS
1454
+ #endif`,Cv=`#ifdef USE_MORPHNORMALS
1447
1455
  objectNormal *= morphTargetBaseInfluence;
1448
1456
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1449
1457
  if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1450
1458
  }
1451
- #endif`,zd=`#ifdef USE_MORPHTARGETS
1459
+ #endif`,Rv=`#ifdef USE_MORPHTARGETS
1452
1460
  #ifndef USE_INSTANCING_MORPH
1453
1461
  uniform float morphTargetBaseInfluence;
1454
1462
  uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -1462,12 +1470,12 @@ IncidentLight directLight;
1462
1470
  ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1463
1471
  return texelFetch( morphTargetsTexture, morphUV, 0 );
1464
1472
  }
1465
- #endif`,kd=`#ifdef USE_MORPHTARGETS
1473
+ #endif`,Pv=`#ifdef USE_MORPHTARGETS
1466
1474
  transformed *= morphTargetBaseInfluence;
1467
1475
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1468
1476
  if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1469
1477
  }
1470
- #endif`,Hd=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1478
+ #endif`,Iv=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1471
1479
  #ifdef FLAT_SHADED
1472
1480
  vec3 fdx = dFdx( vViewPosition );
1473
1481
  vec3 fdy = dFdy( vViewPosition );
@@ -1508,7 +1516,7 @@ IncidentLight directLight;
1508
1516
  tbn2[1] *= faceDirection;
1509
1517
  #endif
1510
1518
  #endif
1511
- vec3 nonPerturbedNormal = normal;`,Vd=`#ifdef USE_NORMALMAP_OBJECTSPACE
1519
+ vec3 nonPerturbedNormal = normal;`,Lv=`#ifdef USE_NORMALMAP_OBJECTSPACE
1512
1520
  normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1513
1521
  #ifdef FLIP_SIDED
1514
1522
  normal = - normal;
@@ -1523,25 +1531,25 @@ vec3 nonPerturbedNormal = normal;`,Vd=`#ifdef USE_NORMALMAP_OBJECTSPACE
1523
1531
  normal = normalize( tbn * mapN );
1524
1532
  #elif defined( USE_BUMPMAP )
1525
1533
  normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1526
- #endif`,Gd=`#ifndef FLAT_SHADED
1534
+ #endif`,Dv=`#ifndef FLAT_SHADED
1527
1535
  varying vec3 vNormal;
1528
1536
  #ifdef USE_TANGENT
1529
1537
  varying vec3 vTangent;
1530
1538
  varying vec3 vBitangent;
1531
1539
  #endif
1532
- #endif`,Wd=`#ifndef FLAT_SHADED
1540
+ #endif`,kv=`#ifndef FLAT_SHADED
1533
1541
  varying vec3 vNormal;
1534
1542
  #ifdef USE_TANGENT
1535
1543
  varying vec3 vTangent;
1536
1544
  varying vec3 vBitangent;
1537
1545
  #endif
1538
- #endif`,Xd=`#ifndef FLAT_SHADED
1546
+ #endif`,Nv=`#ifndef FLAT_SHADED
1539
1547
  vNormal = normalize( transformedNormal );
1540
1548
  #ifdef USE_TANGENT
1541
1549
  vTangent = normalize( transformedTangent );
1542
1550
  vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1543
1551
  #endif
1544
- #endif`,qd=`#ifdef USE_NORMALMAP
1552
+ #endif`,Ov=`#ifdef USE_NORMALMAP
1545
1553
  uniform sampler2D normalMap;
1546
1554
  uniform vec2 normalScale;
1547
1555
  #endif
@@ -1563,13 +1571,13 @@ vec3 nonPerturbedNormal = normal;`,Vd=`#ifdef USE_NORMALMAP_OBJECTSPACE
1563
1571
  float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1564
1572
  return mat3( T * scale, B * scale, N );
1565
1573
  }
1566
- #endif`,Yd=`#ifdef USE_CLEARCOAT
1574
+ #endif`,Uv=`#ifdef USE_CLEARCOAT
1567
1575
  vec3 clearcoatNormal = nonPerturbedNormal;
1568
- #endif`,Zd=`#ifdef USE_CLEARCOAT_NORMALMAP
1576
+ #endif`,Fv=`#ifdef USE_CLEARCOAT_NORMALMAP
1569
1577
  vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1570
1578
  clearcoatMapN.xy *= clearcoatNormalScale;
1571
1579
  clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1572
- #endif`,$d=`#ifdef USE_CLEARCOATMAP
1580
+ #endif`,Bv=`#ifdef USE_CLEARCOATMAP
1573
1581
  uniform sampler2D clearcoatMap;
1574
1582
  #endif
1575
1583
  #ifdef USE_CLEARCOAT_NORMALMAP
@@ -1578,18 +1586,18 @@ vec3 nonPerturbedNormal = normal;`,Vd=`#ifdef USE_NORMALMAP_OBJECTSPACE
1578
1586
  #endif
1579
1587
  #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1580
1588
  uniform sampler2D clearcoatRoughnessMap;
1581
- #endif`,Jd=`#ifdef USE_IRIDESCENCEMAP
1589
+ #endif`,zv=`#ifdef USE_IRIDESCENCEMAP
1582
1590
  uniform sampler2D iridescenceMap;
1583
1591
  #endif
1584
1592
  #ifdef USE_IRIDESCENCE_THICKNESSMAP
1585
1593
  uniform sampler2D iridescenceThicknessMap;
1586
- #endif`,Kd=`#ifdef OPAQUE
1594
+ #endif`,Vv=`#ifdef OPAQUE
1587
1595
  diffuseColor.a = 1.0;
1588
1596
  #endif
1589
1597
  #ifdef USE_TRANSMISSION
1590
1598
  diffuseColor.a *= material.transmissionAlpha;
1591
1599
  #endif
1592
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,jd=`vec3 packNormalToRGB( const in vec3 normal ) {
1600
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Hv=`vec3 packNormalToRGB( const in vec3 normal ) {
1593
1601
  return normalize( normal ) * 0.5 + 0.5;
1594
1602
  }
1595
1603
  vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -1658,9 +1666,9 @@ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const
1658
1666
  }
1659
1667
  float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
1660
1668
  return ( near * far ) / ( ( far - near ) * depth - far );
1661
- }`,Qd=`#ifdef PREMULTIPLIED_ALPHA
1669
+ }`,Gv=`#ifdef PREMULTIPLIED_ALPHA
1662
1670
  gl_FragColor.rgb *= gl_FragColor.a;
1663
- #endif`,tf=`vec4 mvPosition = vec4( transformed, 1.0 );
1671
+ #endif`,Wv=`vec4 mvPosition = vec4( transformed, 1.0 );
1664
1672
  #ifdef USE_BATCHING
1665
1673
  mvPosition = batchingMatrix * mvPosition;
1666
1674
  #endif
@@ -1668,22 +1676,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1668
1676
  mvPosition = instanceMatrix * mvPosition;
1669
1677
  #endif
1670
1678
  mvPosition = modelViewMatrix * mvPosition;
1671
- gl_Position = projectionMatrix * mvPosition;`,ef=`#ifdef DITHERING
1679
+ gl_Position = projectionMatrix * mvPosition;`,$v=`#ifdef DITHERING
1672
1680
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1673
- #endif`,nf=`#ifdef DITHERING
1681
+ #endif`,Xv=`#ifdef DITHERING
1674
1682
  vec3 dithering( vec3 color ) {
1675
1683
  float grid_position = rand( gl_FragCoord.xy );
1676
1684
  vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1677
1685
  dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1678
1686
  return color + dither_shift_RGB;
1679
1687
  }
1680
- #endif`,sf=`float roughnessFactor = roughness;
1688
+ #endif`,qv=`float roughnessFactor = roughness;
1681
1689
  #ifdef USE_ROUGHNESSMAP
1682
1690
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1683
1691
  roughnessFactor *= texelRoughness.g;
1684
- #endif`,rf=`#ifdef USE_ROUGHNESSMAP
1692
+ #endif`,Yv=`#ifdef USE_ROUGHNESSMAP
1685
1693
  uniform sampler2D roughnessMap;
1686
- #endif`,af=`#if NUM_SPOT_LIGHT_COORDS > 0
1694
+ #endif`,jv=`#if NUM_SPOT_LIGHT_COORDS > 0
1687
1695
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1688
1696
  #endif
1689
1697
  #if NUM_SPOT_LIGHT_MAPS > 0
@@ -1878,7 +1886,7 @@ gl_Position = projectionMatrix * mvPosition;`,ef=`#ifdef DITHERING
1878
1886
  }
1879
1887
  return mix( 1.0, shadow, shadowIntensity );
1880
1888
  }
1881
- #endif`,of=`#if NUM_SPOT_LIGHT_COORDS > 0
1889
+ #endif`,Zv=`#if NUM_SPOT_LIGHT_COORDS > 0
1882
1890
  uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1883
1891
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1884
1892
  #endif
@@ -1919,7 +1927,7 @@ gl_Position = projectionMatrix * mvPosition;`,ef=`#ifdef DITHERING
1919
1927
  };
1920
1928
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1921
1929
  #endif
1922
- #endif`,lf=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1930
+ #endif`,Jv=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1923
1931
  vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
1924
1932
  vec4 shadowWorldPosition;
1925
1933
  #endif
@@ -1951,7 +1959,7 @@ gl_Position = projectionMatrix * mvPosition;`,ef=`#ifdef DITHERING
1951
1959
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1952
1960
  }
1953
1961
  #pragma unroll_loop_end
1954
- #endif`,cf=`float getShadowMask() {
1962
+ #endif`,Kv=`float getShadowMask() {
1955
1963
  float shadow = 1.0;
1956
1964
  #ifdef USE_SHADOWMAP
1957
1965
  #if NUM_DIR_LIGHT_SHADOWS > 0
@@ -1983,12 +1991,12 @@ gl_Position = projectionMatrix * mvPosition;`,ef=`#ifdef DITHERING
1983
1991
  #endif
1984
1992
  #endif
1985
1993
  return shadow;
1986
- }`,hf=`#ifdef USE_SKINNING
1994
+ }`,Qv=`#ifdef USE_SKINNING
1987
1995
  mat4 boneMatX = getBoneMatrix( skinIndex.x );
1988
1996
  mat4 boneMatY = getBoneMatrix( skinIndex.y );
1989
1997
  mat4 boneMatZ = getBoneMatrix( skinIndex.z );
1990
1998
  mat4 boneMatW = getBoneMatrix( skinIndex.w );
1991
- #endif`,uf=`#ifdef USE_SKINNING
1999
+ #endif`,ex=`#ifdef USE_SKINNING
1992
2000
  uniform mat4 bindMatrix;
1993
2001
  uniform mat4 bindMatrixInverse;
1994
2002
  uniform highp sampler2D boneTexture;
@@ -2003,7 +2011,7 @@ gl_Position = projectionMatrix * mvPosition;`,ef=`#ifdef DITHERING
2003
2011
  vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2004
2012
  return mat4( v1, v2, v3, v4 );
2005
2013
  }
2006
- #endif`,df=`#ifdef USE_SKINNING
2014
+ #endif`,tx=`#ifdef USE_SKINNING
2007
2015
  vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2008
2016
  vec4 skinned = vec4( 0.0 );
2009
2017
  skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2011,7 +2019,7 @@ gl_Position = projectionMatrix * mvPosition;`,ef=`#ifdef DITHERING
2011
2019
  skinned += boneMatZ * skinVertex * skinWeight.z;
2012
2020
  skinned += boneMatW * skinVertex * skinWeight.w;
2013
2021
  transformed = ( bindMatrixInverse * skinned ).xyz;
2014
- #endif`,ff=`#ifdef USE_SKINNING
2022
+ #endif`,nx=`#ifdef USE_SKINNING
2015
2023
  mat4 skinMatrix = mat4( 0.0 );
2016
2024
  skinMatrix += skinWeight.x * boneMatX;
2017
2025
  skinMatrix += skinWeight.y * boneMatY;
@@ -2022,17 +2030,17 @@ gl_Position = projectionMatrix * mvPosition;`,ef=`#ifdef DITHERING
2022
2030
  #ifdef USE_TANGENT
2023
2031
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2024
2032
  #endif
2025
- #endif`,pf=`float specularStrength;
2033
+ #endif`,ix=`float specularStrength;
2026
2034
  #ifdef USE_SPECULARMAP
2027
2035
  vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2028
2036
  specularStrength = texelSpecular.r;
2029
2037
  #else
2030
2038
  specularStrength = 1.0;
2031
- #endif`,mf=`#ifdef USE_SPECULARMAP
2039
+ #endif`,rx=`#ifdef USE_SPECULARMAP
2032
2040
  uniform sampler2D specularMap;
2033
- #endif`,gf=`#if defined( TONE_MAPPING )
2041
+ #endif`,sx=`#if defined( TONE_MAPPING )
2034
2042
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2035
- #endif`,_f=`#ifndef saturate
2043
+ #endif`,ax=`#ifndef saturate
2036
2044
  #define saturate( a ) clamp( a, 0.0, 1.0 )
2037
2045
  #endif
2038
2046
  uniform float toneMappingExposure;
@@ -2129,7 +2137,7 @@ vec3 NeutralToneMapping( vec3 color ) {
2129
2137
  float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2130
2138
  return mix( color, vec3( newPeak ), g );
2131
2139
  }
2132
- vec3 CustomToneMapping( vec3 color ) { return color; }`,xf=`#ifdef USE_TRANSMISSION
2140
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,ox=`#ifdef USE_TRANSMISSION
2133
2141
  material.transmission = transmission;
2134
2142
  material.transmissionAlpha = 1.0;
2135
2143
  material.thickness = thickness;
@@ -2150,7 +2158,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,xf=`#ifdef USE_TRANSMISS
2150
2158
  material.attenuationColor, material.attenuationDistance );
2151
2159
  material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2152
2160
  totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2153
- #endif`,yf=`#ifdef USE_TRANSMISSION
2161
+ #endif`,lx=`#ifdef USE_TRANSMISSION
2154
2162
  uniform float transmission;
2155
2163
  uniform float thickness;
2156
2164
  uniform float attenuationDistance;
@@ -2276,7 +2284,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,xf=`#ifdef USE_TRANSMISS
2276
2284
  float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2277
2285
  return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2278
2286
  }
2279
- #endif`,vf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2287
+ #endif`,cx=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2280
2288
  varying vec2 vUv;
2281
2289
  #endif
2282
2290
  #ifdef USE_MAP
@@ -2346,7 +2354,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,xf=`#ifdef USE_TRANSMISS
2346
2354
  #ifdef USE_THICKNESSMAP
2347
2355
  uniform mat3 thicknessMapTransform;
2348
2356
  varying vec2 vThicknessMapUv;
2349
- #endif`,Mf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2357
+ #endif`,hx=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2350
2358
  varying vec2 vUv;
2351
2359
  #endif
2352
2360
  #ifdef USE_MAP
@@ -2440,7 +2448,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,xf=`#ifdef USE_TRANSMISS
2440
2448
  #ifdef USE_THICKNESSMAP
2441
2449
  uniform mat3 thicknessMapTransform;
2442
2450
  varying vec2 vThicknessMapUv;
2443
- #endif`,bf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2451
+ #endif`,ux=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2444
2452
  vUv = vec3( uv, 1 ).xy;
2445
2453
  #endif
2446
2454
  #ifdef USE_MAP
@@ -2511,7 +2519,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,xf=`#ifdef USE_TRANSMISS
2511
2519
  #endif
2512
2520
  #ifdef USE_THICKNESSMAP
2513
2521
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2514
- #endif`,Sf=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2522
+ #endif`,dx=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2515
2523
  vec4 worldPosition = vec4( transformed, 1.0 );
2516
2524
  #ifdef USE_BATCHING
2517
2525
  worldPosition = batchingMatrix * worldPosition;
@@ -2520,12 +2528,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,xf=`#ifdef USE_TRANSMISS
2520
2528
  worldPosition = instanceMatrix * worldPosition;
2521
2529
  #endif
2522
2530
  worldPosition = modelMatrix * worldPosition;
2523
- #endif`,Ef=`varying vec2 vUv;
2531
+ #endif`,fx=`varying vec2 vUv;
2524
2532
  uniform mat3 uvTransform;
2525
2533
  void main() {
2526
2534
  vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2527
2535
  gl_Position = vec4( position.xy, 1.0, 1.0 );
2528
- }`,Tf=`uniform sampler2D t2D;
2536
+ }`,px=`uniform sampler2D t2D;
2529
2537
  uniform float backgroundIntensity;
2530
2538
  varying vec2 vUv;
2531
2539
  void main() {
@@ -2537,14 +2545,14 @@ void main() {
2537
2545
  gl_FragColor = texColor;
2538
2546
  #include <tonemapping_fragment>
2539
2547
  #include <colorspace_fragment>
2540
- }`,wf=`varying vec3 vWorldDirection;
2548
+ }`,mx=`varying vec3 vWorldDirection;
2541
2549
  #include <common>
2542
2550
  void main() {
2543
2551
  vWorldDirection = transformDirection( position, modelMatrix );
2544
2552
  #include <begin_vertex>
2545
2553
  #include <project_vertex>
2546
2554
  gl_Position.z = gl_Position.w;
2547
- }`,Af=`#ifdef ENVMAP_TYPE_CUBE
2555
+ }`,gx=`#ifdef ENVMAP_TYPE_CUBE
2548
2556
  uniform samplerCube envMap;
2549
2557
  #elif defined( ENVMAP_TYPE_CUBE_UV )
2550
2558
  uniform sampler2D envMap;
@@ -2567,14 +2575,14 @@ void main() {
2567
2575
  gl_FragColor = texColor;
2568
2576
  #include <tonemapping_fragment>
2569
2577
  #include <colorspace_fragment>
2570
- }`,Rf=`varying vec3 vWorldDirection;
2578
+ }`,yx=`varying vec3 vWorldDirection;
2571
2579
  #include <common>
2572
2580
  void main() {
2573
2581
  vWorldDirection = transformDirection( position, modelMatrix );
2574
2582
  #include <begin_vertex>
2575
2583
  #include <project_vertex>
2576
2584
  gl_Position.z = gl_Position.w;
2577
- }`,Cf=`uniform samplerCube tCube;
2585
+ }`,vx=`uniform samplerCube tCube;
2578
2586
  uniform float tFlip;
2579
2587
  uniform float opacity;
2580
2588
  varying vec3 vWorldDirection;
@@ -2584,7 +2592,7 @@ void main() {
2584
2592
  gl_FragColor.a *= opacity;
2585
2593
  #include <tonemapping_fragment>
2586
2594
  #include <colorspace_fragment>
2587
- }`,Pf=`#include <common>
2595
+ }`,xx=`#include <common>
2588
2596
  #include <batching_pars_vertex>
2589
2597
  #include <uv_pars_vertex>
2590
2598
  #include <displacementmap_pars_vertex>
@@ -2611,7 +2619,7 @@ void main() {
2611
2619
  #include <logdepthbuf_vertex>
2612
2620
  #include <clipping_planes_vertex>
2613
2621
  vHighPrecisionZW = gl_Position.zw;
2614
- }`,If=`#if DEPTH_PACKING == 3200
2622
+ }`,_x=`#if DEPTH_PACKING == 3200
2615
2623
  uniform float opacity;
2616
2624
  #endif
2617
2625
  #include <common>
@@ -2649,7 +2657,7 @@ void main() {
2649
2657
  #elif DEPTH_PACKING == 3203
2650
2658
  gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
2651
2659
  #endif
2652
- }`,Lf=`#define DISTANCE
2660
+ }`,bx=`#define DISTANCE
2653
2661
  varying vec3 vWorldPosition;
2654
2662
  #include <common>
2655
2663
  #include <batching_pars_vertex>
@@ -2676,7 +2684,7 @@ void main() {
2676
2684
  #include <worldpos_vertex>
2677
2685
  #include <clipping_planes_vertex>
2678
2686
  vWorldPosition = worldPosition.xyz;
2679
- }`,Df=`#define DISTANCE
2687
+ }`,Sx=`#define DISTANCE
2680
2688
  uniform vec3 referencePosition;
2681
2689
  uniform float nearDistance;
2682
2690
  uniform float farDistance;
@@ -2700,13 +2708,13 @@ void main () {
2700
2708
  dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2701
2709
  dist = saturate( dist );
2702
2710
  gl_FragColor = packDepthToRGBA( dist );
2703
- }`,Uf=`varying vec3 vWorldDirection;
2711
+ }`,wx=`varying vec3 vWorldDirection;
2704
2712
  #include <common>
2705
2713
  void main() {
2706
2714
  vWorldDirection = transformDirection( position, modelMatrix );
2707
2715
  #include <begin_vertex>
2708
2716
  #include <project_vertex>
2709
- }`,Nf=`uniform sampler2D tEquirect;
2717
+ }`,Mx=`uniform sampler2D tEquirect;
2710
2718
  varying vec3 vWorldDirection;
2711
2719
  #include <common>
2712
2720
  void main() {
@@ -2715,7 +2723,7 @@ void main() {
2715
2723
  gl_FragColor = texture2D( tEquirect, sampleUV );
2716
2724
  #include <tonemapping_fragment>
2717
2725
  #include <colorspace_fragment>
2718
- }`,Ff=`uniform float scale;
2726
+ }`,Ex=`uniform float scale;
2719
2727
  attribute float lineDistance;
2720
2728
  varying float vLineDistance;
2721
2729
  #include <common>
@@ -2737,7 +2745,7 @@ void main() {
2737
2745
  #include <logdepthbuf_vertex>
2738
2746
  #include <clipping_planes_vertex>
2739
2747
  #include <fog_vertex>
2740
- }`,Of=`uniform vec3 diffuse;
2748
+ }`,Tx=`uniform vec3 diffuse;
2741
2749
  uniform float opacity;
2742
2750
  uniform float dashSize;
2743
2751
  uniform float totalSize;
@@ -2765,7 +2773,7 @@ void main() {
2765
2773
  #include <colorspace_fragment>
2766
2774
  #include <fog_fragment>
2767
2775
  #include <premultiplied_alpha_fragment>
2768
- }`,Bf=`#include <common>
2776
+ }`,Ax=`#include <common>
2769
2777
  #include <batching_pars_vertex>
2770
2778
  #include <uv_pars_vertex>
2771
2779
  #include <envmap_pars_vertex>
@@ -2797,7 +2805,7 @@ void main() {
2797
2805
  #include <worldpos_vertex>
2798
2806
  #include <envmap_vertex>
2799
2807
  #include <fog_vertex>
2800
- }`,zf=`uniform vec3 diffuse;
2808
+ }`,Cx=`uniform vec3 diffuse;
2801
2809
  uniform float opacity;
2802
2810
  #ifndef FLAT_SHADED
2803
2811
  varying vec3 vNormal;
@@ -2845,7 +2853,7 @@ void main() {
2845
2853
  #include <fog_fragment>
2846
2854
  #include <premultiplied_alpha_fragment>
2847
2855
  #include <dithering_fragment>
2848
- }`,kf=`#define LAMBERT
2856
+ }`,Rx=`#define LAMBERT
2849
2857
  varying vec3 vViewPosition;
2850
2858
  #include <common>
2851
2859
  #include <batching_pars_vertex>
@@ -2884,7 +2892,7 @@ void main() {
2884
2892
  #include <envmap_vertex>
2885
2893
  #include <shadowmap_vertex>
2886
2894
  #include <fog_vertex>
2887
- }`,Hf=`#define LAMBERT
2895
+ }`,Px=`#define LAMBERT
2888
2896
  uniform vec3 diffuse;
2889
2897
  uniform vec3 emissive;
2890
2898
  uniform float opacity;
@@ -2941,7 +2949,7 @@ void main() {
2941
2949
  #include <fog_fragment>
2942
2950
  #include <premultiplied_alpha_fragment>
2943
2951
  #include <dithering_fragment>
2944
- }`,Vf=`#define MATCAP
2952
+ }`,Ix=`#define MATCAP
2945
2953
  varying vec3 vViewPosition;
2946
2954
  #include <common>
2947
2955
  #include <batching_pars_vertex>
@@ -2975,7 +2983,7 @@ void main() {
2975
2983
  #include <clipping_planes_vertex>
2976
2984
  #include <fog_vertex>
2977
2985
  vViewPosition = - mvPosition.xyz;
2978
- }`,Gf=`#define MATCAP
2986
+ }`,Lx=`#define MATCAP
2979
2987
  uniform vec3 diffuse;
2980
2988
  uniform float opacity;
2981
2989
  uniform sampler2D matcap;
@@ -3021,7 +3029,7 @@ void main() {
3021
3029
  #include <fog_fragment>
3022
3030
  #include <premultiplied_alpha_fragment>
3023
3031
  #include <dithering_fragment>
3024
- }`,Wf=`#define NORMAL
3032
+ }`,Dx=`#define NORMAL
3025
3033
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3026
3034
  varying vec3 vViewPosition;
3027
3035
  #endif
@@ -3054,7 +3062,7 @@ void main() {
3054
3062
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3055
3063
  vViewPosition = - mvPosition.xyz;
3056
3064
  #endif
3057
- }`,Xf=`#define NORMAL
3065
+ }`,kx=`#define NORMAL
3058
3066
  uniform float opacity;
3059
3067
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3060
3068
  varying vec3 vViewPosition;
@@ -3076,7 +3084,7 @@ void main() {
3076
3084
  #ifdef OPAQUE
3077
3085
  gl_FragColor.a = 1.0;
3078
3086
  #endif
3079
- }`,qf=`#define PHONG
3087
+ }`,Nx=`#define PHONG
3080
3088
  varying vec3 vViewPosition;
3081
3089
  #include <common>
3082
3090
  #include <batching_pars_vertex>
@@ -3115,7 +3123,7 @@ void main() {
3115
3123
  #include <envmap_vertex>
3116
3124
  #include <shadowmap_vertex>
3117
3125
  #include <fog_vertex>
3118
- }`,Yf=`#define PHONG
3126
+ }`,Ox=`#define PHONG
3119
3127
  uniform vec3 diffuse;
3120
3128
  uniform vec3 emissive;
3121
3129
  uniform vec3 specular;
@@ -3174,7 +3182,7 @@ void main() {
3174
3182
  #include <fog_fragment>
3175
3183
  #include <premultiplied_alpha_fragment>
3176
3184
  #include <dithering_fragment>
3177
- }`,Zf=`#define STANDARD
3185
+ }`,Ux=`#define STANDARD
3178
3186
  varying vec3 vViewPosition;
3179
3187
  #ifdef USE_TRANSMISSION
3180
3188
  varying vec3 vWorldPosition;
@@ -3217,7 +3225,7 @@ void main() {
3217
3225
  #ifdef USE_TRANSMISSION
3218
3226
  vWorldPosition = worldPosition.xyz;
3219
3227
  #endif
3220
- }`,$f=`#define STANDARD
3228
+ }`,Fx=`#define STANDARD
3221
3229
  #ifdef PHYSICAL
3222
3230
  #define IOR
3223
3231
  #define USE_SPECULAR
@@ -3342,7 +3350,7 @@ void main() {
3342
3350
  #include <fog_fragment>
3343
3351
  #include <premultiplied_alpha_fragment>
3344
3352
  #include <dithering_fragment>
3345
- }`,Jf=`#define TOON
3353
+ }`,Bx=`#define TOON
3346
3354
  varying vec3 vViewPosition;
3347
3355
  #include <common>
3348
3356
  #include <batching_pars_vertex>
@@ -3379,7 +3387,7 @@ void main() {
3379
3387
  #include <worldpos_vertex>
3380
3388
  #include <shadowmap_vertex>
3381
3389
  #include <fog_vertex>
3382
- }`,Kf=`#define TOON
3390
+ }`,zx=`#define TOON
3383
3391
  uniform vec3 diffuse;
3384
3392
  uniform vec3 emissive;
3385
3393
  uniform float opacity;
@@ -3432,7 +3440,7 @@ void main() {
3432
3440
  #include <fog_fragment>
3433
3441
  #include <premultiplied_alpha_fragment>
3434
3442
  #include <dithering_fragment>
3435
- }`,jf=`uniform float size;
3443
+ }`,Vx=`uniform float size;
3436
3444
  uniform float scale;
3437
3445
  #include <common>
3438
3446
  #include <color_pars_vertex>
@@ -3463,7 +3471,7 @@ void main() {
3463
3471
  #include <clipping_planes_vertex>
3464
3472
  #include <worldpos_vertex>
3465
3473
  #include <fog_vertex>
3466
- }`,Qf=`uniform vec3 diffuse;
3474
+ }`,Hx=`uniform vec3 diffuse;
3467
3475
  uniform float opacity;
3468
3476
  #include <common>
3469
3477
  #include <color_pars_fragment>
@@ -3488,7 +3496,7 @@ void main() {
3488
3496
  #include <colorspace_fragment>
3489
3497
  #include <fog_fragment>
3490
3498
  #include <premultiplied_alpha_fragment>
3491
- }`,tp=`#include <common>
3499
+ }`,Gx=`#include <common>
3492
3500
  #include <batching_pars_vertex>
3493
3501
  #include <fog_pars_vertex>
3494
3502
  #include <morphtarget_pars_vertex>
@@ -3511,7 +3519,7 @@ void main() {
3511
3519
  #include <worldpos_vertex>
3512
3520
  #include <shadowmap_vertex>
3513
3521
  #include <fog_vertex>
3514
- }`,ep=`uniform vec3 color;
3522
+ }`,Wx=`uniform vec3 color;
3515
3523
  uniform float opacity;
3516
3524
  #include <common>
3517
3525
  #include <packing>
@@ -3527,7 +3535,7 @@ void main() {
3527
3535
  #include <tonemapping_fragment>
3528
3536
  #include <colorspace_fragment>
3529
3537
  #include <fog_fragment>
3530
- }`,np=`uniform float rotation;
3538
+ }`,$x=`uniform float rotation;
3531
3539
  uniform vec2 center;
3532
3540
  #include <common>
3533
3541
  #include <uv_pars_vertex>
@@ -3551,7 +3559,7 @@ void main() {
3551
3559
  #include <logdepthbuf_vertex>
3552
3560
  #include <clipping_planes_vertex>
3553
3561
  #include <fog_vertex>
3554
- }`,ip=`uniform vec3 diffuse;
3562
+ }`,Xx=`uniform vec3 diffuse;
3555
3563
  uniform float opacity;
3556
3564
  #include <common>
3557
3565
  #include <uv_pars_fragment>
@@ -3576,7 +3584,7 @@ void main() {
3576
3584
  #include <tonemapping_fragment>
3577
3585
  #include <colorspace_fragment>
3578
3586
  #include <fog_fragment>
3579
- }`,Ft={alphahash_fragment:Eu,alphahash_pars_fragment:Tu,alphamap_fragment:wu,alphamap_pars_fragment:Au,alphatest_fragment:Ru,alphatest_pars_fragment:Cu,aomap_fragment:Pu,aomap_pars_fragment:Iu,batching_pars_vertex:Lu,batching_vertex:Du,begin_vertex:Uu,beginnormal_vertex:Nu,bsdfs:Fu,iridescence_fragment:Ou,bumpmap_pars_fragment:Bu,clipping_planes_fragment:zu,clipping_planes_pars_fragment:ku,clipping_planes_pars_vertex:Hu,clipping_planes_vertex:Vu,color_fragment:Gu,color_pars_fragment:Wu,color_pars_vertex:Xu,color_vertex:qu,common:Yu,cube_uv_reflection_fragment:Zu,defaultnormal_vertex:$u,displacementmap_pars_vertex:Ju,displacementmap_vertex:Ku,emissivemap_fragment:ju,emissivemap_pars_fragment:Qu,colorspace_fragment:td,colorspace_pars_fragment:ed,envmap_fragment:nd,envmap_common_pars_fragment:id,envmap_pars_fragment:sd,envmap_pars_vertex:rd,envmap_physical_pars_fragment:gd,envmap_vertex:ad,fog_vertex:od,fog_pars_vertex:ld,fog_fragment:cd,fog_pars_fragment:hd,gradientmap_pars_fragment:ud,lightmap_pars_fragment:dd,lights_lambert_fragment:fd,lights_lambert_pars_fragment:pd,lights_pars_begin:md,lights_toon_fragment:_d,lights_toon_pars_fragment:xd,lights_phong_fragment:yd,lights_phong_pars_fragment:vd,lights_physical_fragment:Md,lights_physical_pars_fragment:bd,lights_fragment_begin:Sd,lights_fragment_maps:Ed,lights_fragment_end:Td,logdepthbuf_fragment:wd,logdepthbuf_pars_fragment:Ad,logdepthbuf_pars_vertex:Rd,logdepthbuf_vertex:Cd,map_fragment:Pd,map_pars_fragment:Id,map_particle_fragment:Ld,map_particle_pars_fragment:Dd,metalnessmap_fragment:Ud,metalnessmap_pars_fragment:Nd,morphinstance_vertex:Fd,morphcolor_vertex:Od,morphnormal_vertex:Bd,morphtarget_pars_vertex:zd,morphtarget_vertex:kd,normal_fragment_begin:Hd,normal_fragment_maps:Vd,normal_pars_fragment:Gd,normal_pars_vertex:Wd,normal_vertex:Xd,normalmap_pars_fragment:qd,clearcoat_normal_fragment_begin:Yd,clearcoat_normal_fragment_maps:Zd,clearcoat_pars_fragment:$d,iridescence_pars_fragment:Jd,opaque_fragment:Kd,packing:jd,premultiplied_alpha_fragment:Qd,project_vertex:tf,dithering_fragment:ef,dithering_pars_fragment:nf,roughnessmap_fragment:sf,roughnessmap_pars_fragment:rf,shadowmap_pars_fragment:af,shadowmap_pars_vertex:of,shadowmap_vertex:lf,shadowmask_pars_fragment:cf,skinbase_vertex:hf,skinning_pars_vertex:uf,skinning_vertex:df,skinnormal_vertex:ff,specularmap_fragment:pf,specularmap_pars_fragment:mf,tonemapping_fragment:gf,tonemapping_pars_fragment:_f,transmission_fragment:xf,transmission_pars_fragment:yf,uv_pars_fragment:vf,uv_pars_vertex:Mf,uv_vertex:bf,worldpos_vertex:Sf,background_vert:Ef,background_frag:Tf,backgroundCube_vert:wf,backgroundCube_frag:Af,cube_vert:Rf,cube_frag:Cf,depth_vert:Pf,depth_frag:If,distanceRGBA_vert:Lf,distanceRGBA_frag:Df,equirect_vert:Uf,equirect_frag:Nf,linedashed_vert:Ff,linedashed_frag:Of,meshbasic_vert:Bf,meshbasic_frag:zf,meshlambert_vert:kf,meshlambert_frag:Hf,meshmatcap_vert:Vf,meshmatcap_frag:Gf,meshnormal_vert:Wf,meshnormal_frag:Xf,meshphong_vert:qf,meshphong_frag:Yf,meshphysical_vert:Zf,meshphysical_frag:$f,meshtoon_vert:Jf,meshtoon_frag:Kf,points_vert:jf,points_frag:Qf,shadow_vert:tp,shadow_frag:ep,sprite_vert:np,sprite_frag:ip},st={common:{diffuse:{value:new zt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Lt},alphaMap:{value:null},alphaMapTransform:{value:new Lt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Lt}},envmap:{envMap:{value:null},envMapRotation:{value:new Lt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Lt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Lt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Lt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Lt},normalScale:{value:new Ut(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Lt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Lt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Lt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Lt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new zt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new zt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Lt},alphaTest:{value:0},uvTransform:{value:new Lt}},sprite:{diffuse:{value:new zt(16777215)},opacity:{value:1},center:{value:new Ut(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Lt},alphaMap:{value:null},alphaMapTransform:{value:new Lt},alphaTest:{value:0}}},ln={basic:{uniforms:ve([st.common,st.specularmap,st.envmap,st.aomap,st.lightmap,st.fog]),vertexShader:Ft.meshbasic_vert,fragmentShader:Ft.meshbasic_frag},lambert:{uniforms:ve([st.common,st.specularmap,st.envmap,st.aomap,st.lightmap,st.emissivemap,st.bumpmap,st.normalmap,st.displacementmap,st.fog,st.lights,{emissive:{value:new zt(0)}}]),vertexShader:Ft.meshlambert_vert,fragmentShader:Ft.meshlambert_frag},phong:{uniforms:ve([st.common,st.specularmap,st.envmap,st.aomap,st.lightmap,st.emissivemap,st.bumpmap,st.normalmap,st.displacementmap,st.fog,st.lights,{emissive:{value:new zt(0)},specular:{value:new zt(1118481)},shininess:{value:30}}]),vertexShader:Ft.meshphong_vert,fragmentShader:Ft.meshphong_frag},standard:{uniforms:ve([st.common,st.envmap,st.aomap,st.lightmap,st.emissivemap,st.bumpmap,st.normalmap,st.displacementmap,st.roughnessmap,st.metalnessmap,st.fog,st.lights,{emissive:{value:new zt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ft.meshphysical_vert,fragmentShader:Ft.meshphysical_frag},toon:{uniforms:ve([st.common,st.aomap,st.lightmap,st.emissivemap,st.bumpmap,st.normalmap,st.displacementmap,st.gradientmap,st.fog,st.lights,{emissive:{value:new zt(0)}}]),vertexShader:Ft.meshtoon_vert,fragmentShader:Ft.meshtoon_frag},matcap:{uniforms:ve([st.common,st.bumpmap,st.normalmap,st.displacementmap,st.fog,{matcap:{value:null}}]),vertexShader:Ft.meshmatcap_vert,fragmentShader:Ft.meshmatcap_frag},points:{uniforms:ve([st.points,st.fog]),vertexShader:Ft.points_vert,fragmentShader:Ft.points_frag},dashed:{uniforms:ve([st.common,st.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ft.linedashed_vert,fragmentShader:Ft.linedashed_frag},depth:{uniforms:ve([st.common,st.displacementmap]),vertexShader:Ft.depth_vert,fragmentShader:Ft.depth_frag},normal:{uniforms:ve([st.common,st.bumpmap,st.normalmap,st.displacementmap,{opacity:{value:1}}]),vertexShader:Ft.meshnormal_vert,fragmentShader:Ft.meshnormal_frag},sprite:{uniforms:ve([st.sprite,st.fog]),vertexShader:Ft.sprite_vert,fragmentShader:Ft.sprite_frag},background:{uniforms:{uvTransform:{value:new Lt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ft.background_vert,fragmentShader:Ft.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Lt}},vertexShader:Ft.backgroundCube_vert,fragmentShader:Ft.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ft.cube_vert,fragmentShader:Ft.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ft.equirect_vert,fragmentShader:Ft.equirect_frag},distanceRGBA:{uniforms:ve([st.common,st.displacementmap,{referencePosition:{value:new N},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ft.distanceRGBA_vert,fragmentShader:Ft.distanceRGBA_frag},shadow:{uniforms:ve([st.lights,st.fog,{color:{value:new zt(0)},opacity:{value:1}}]),vertexShader:Ft.shadow_vert,fragmentShader:Ft.shadow_frag}};ln.physical={uniforms:ve([ln.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Lt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Lt},clearcoatNormalScale:{value:new Ut(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Lt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Lt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Lt},sheen:{value:0},sheenColor:{value:new zt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Lt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Lt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Lt},transmissionSamplerSize:{value:new Ut},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Lt},attenuationDistance:{value:0},attenuationColor:{value:new zt(0)},specularColor:{value:new zt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Lt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Lt},anisotropyVector:{value:new Ut},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Lt}}]),vertexShader:Ft.meshphysical_vert,fragmentShader:Ft.meshphysical_frag};var Ea={r:0,b:0,g:0},ei=new sn,sp=new ce;function rp(i,t,e,n,s,r,a){let o=new zt(0),c=r===!0?0:1,l,h,f=null,u=0,p=null;function g(M){let v=M.isScene===!0?M.background:null;return v&&v.isTexture&&(v=(M.backgroundBlurriness>0?e:t).get(v)),v}function _(M){let v=!1,R=g(M);R===null?d(o,c):R&&R.isColor&&(d(R,1),v=!0);let w=i.xr.getEnvironmentBlendMode();w==="additive"?n.buffers.color.setClear(0,0,0,1,a):w==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||v)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function m(M,v){let R=g(v);R&&(R.isCubeTexture||R.mapping===Ts)?(h===void 0&&(h=new Pe(new Ai(1,1,1),new je({name:"BackgroundCubeMaterial",uniforms:ti(ln.backgroundCube.uniforms),vertexShader:ln.backgroundCube.vertexShader,fragmentShader:ln.backgroundCube.fragmentShader,side:Ee,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(w,C,U){this.matrixWorld.copyPosition(U.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),ei.copy(v.backgroundRotation),ei.x*=-1,ei.y*=-1,ei.z*=-1,R.isCubeTexture&&R.isRenderTargetTexture===!1&&(ei.y*=-1,ei.z*=-1),h.material.uniforms.envMap.value=R,h.material.uniforms.flipEnvMap.value=R.isCubeTexture&&R.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(sp.makeRotationFromEuler(ei)),h.material.toneMapped=Vt.getTransfer(R.colorSpace)!==qt,(f!==R||u!==R.version||p!==i.toneMapping)&&(h.material.needsUpdate=!0,f=R,u=R.version,p=i.toneMapping),h.layers.enableAll(),M.unshift(h,h.geometry,h.material,0,0,null)):R&&R.isTexture&&(l===void 0&&(l=new Pe(new vs(2,2),new je({name:"BackgroundMaterial",uniforms:ti(ln.background.uniforms),vertexShader:ln.background.vertexShader,fragmentShader:ln.background.fragmentShader,side:_n,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(l)),l.material.uniforms.t2D.value=R,l.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,l.material.toneMapped=Vt.getTransfer(R.colorSpace)!==qt,R.matrixAutoUpdate===!0&&R.updateMatrix(),l.material.uniforms.uvTransform.value.copy(R.matrix),(f!==R||u!==R.version||p!==i.toneMapping)&&(l.material.needsUpdate=!0,f=R,u=R.version,p=i.toneMapping),l.layers.enableAll(),M.unshift(l,l.geometry,l.material,0,0,null))}function d(M,v){M.getRGB(Ea,zo(i)),n.buffers.color.setClear(Ea.r,Ea.g,Ea.b,v,a)}function T(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return o},setClearColor:function(M,v=1){o.set(M),c=v,d(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(M){c=M,d(o,c)},render:_,addToRenderList:m,dispose:T}}function ap(i,t){let e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null),r=s,a=!1;function o(b,P,B,V,X){let Z=!1,W=f(V,B,P);r!==W&&(r=W,l(r.object)),Z=p(b,V,B,X),Z&&g(b,V,B,X),X!==null&&t.update(X,i.ELEMENT_ARRAY_BUFFER),(Z||a)&&(a=!1,v(b,P,B,V),X!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(X).buffer))}function c(){return i.createVertexArray()}function l(b){return i.bindVertexArray(b)}function h(b){return i.deleteVertexArray(b)}function f(b,P,B){let V=B.wireframe===!0,X=n[b.id];X===void 0&&(X={},n[b.id]=X);let Z=X[P.id];Z===void 0&&(Z={},X[P.id]=Z);let W=Z[V];return W===void 0&&(W=u(c()),Z[V]=W),W}function u(b){let P=[],B=[],V=[];for(let X=0;X<e;X++)P[X]=0,B[X]=0,V[X]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:B,attributeDivisors:V,object:b,attributes:{},index:null}}function p(b,P,B,V){let X=r.attributes,Z=P.attributes,W=0,et=B.getAttributes();for(let k in et)if(et[k].location>=0){let ct=X[k],bt=Z[k];if(bt===void 0&&(k==="instanceMatrix"&&b.instanceMatrix&&(bt=b.instanceMatrix),k==="instanceColor"&&b.instanceColor&&(bt=b.instanceColor)),ct===void 0||ct.attribute!==bt||bt&&ct.data!==bt.data)return!0;W++}return r.attributesNum!==W||r.index!==V}function g(b,P,B,V){let X={},Z=P.attributes,W=0,et=B.getAttributes();for(let k in et)if(et[k].location>=0){let ct=Z[k];ct===void 0&&(k==="instanceMatrix"&&b.instanceMatrix&&(ct=b.instanceMatrix),k==="instanceColor"&&b.instanceColor&&(ct=b.instanceColor));let bt={};bt.attribute=ct,ct&&ct.data&&(bt.data=ct.data),X[k]=bt,W++}r.attributes=X,r.attributesNum=W,r.index=V}function _(){let b=r.newAttributes;for(let P=0,B=b.length;P<B;P++)b[P]=0}function m(b){d(b,0)}function d(b,P){let B=r.newAttributes,V=r.enabledAttributes,X=r.attributeDivisors;B[b]=1,V[b]===0&&(i.enableVertexAttribArray(b),V[b]=1),X[b]!==P&&(i.vertexAttribDivisor(b,P),X[b]=P)}function T(){let b=r.newAttributes,P=r.enabledAttributes;for(let B=0,V=P.length;B<V;B++)P[B]!==b[B]&&(i.disableVertexAttribArray(B),P[B]=0)}function M(b,P,B,V,X,Z,W){W===!0?i.vertexAttribIPointer(b,P,B,X,Z):i.vertexAttribPointer(b,P,B,V,X,Z)}function v(b,P,B,V){_();let X=V.attributes,Z=B.getAttributes(),W=P.defaultAttributeValues;for(let et in Z){let k=Z[et];if(k.location>=0){let rt=X[et];if(rt===void 0&&(et==="instanceMatrix"&&b.instanceMatrix&&(rt=b.instanceMatrix),et==="instanceColor"&&b.instanceColor&&(rt=b.instanceColor)),rt!==void 0){let ct=rt.normalized,bt=rt.itemSize,Bt=t.get(rt);if(Bt===void 0)continue;let Jt=Bt.buffer,te=Bt.type,Wt=Bt.bytesPerElement,q=te===i.INT||te===i.UNSIGNED_INT||rt.gpuType===Wr;if(rt.isInterleavedBufferAttribute){let J=rt.data,dt=J.stride,Ct=rt.offset;if(J.isInstancedInterleavedBuffer){for(let Mt=0;Mt<k.locationSize;Mt++)d(k.location+Mt,J.meshPerAttribute);b.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let Mt=0;Mt<k.locationSize;Mt++)m(k.location+Mt);i.bindBuffer(i.ARRAY_BUFFER,Jt);for(let Mt=0;Mt<k.locationSize;Mt++)M(k.location+Mt,bt/k.locationSize,te,ct,dt*Wt,(Ct+bt/k.locationSize*Mt)*Wt,q)}else{if(rt.isInstancedBufferAttribute){for(let J=0;J<k.locationSize;J++)d(k.location+J,rt.meshPerAttribute);b.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=rt.meshPerAttribute*rt.count)}else for(let J=0;J<k.locationSize;J++)m(k.location+J);i.bindBuffer(i.ARRAY_BUFFER,Jt);for(let J=0;J<k.locationSize;J++)M(k.location+J,bt/k.locationSize,te,ct,bt*Wt,bt/k.locationSize*J*Wt,q)}}else if(W!==void 0){let ct=W[et];if(ct!==void 0)switch(ct.length){case 2:i.vertexAttrib2fv(k.location,ct);break;case 3:i.vertexAttrib3fv(k.location,ct);break;case 4:i.vertexAttrib4fv(k.location,ct);break;default:i.vertexAttrib1fv(k.location,ct)}}}}T()}function R(){U();for(let b in n){let P=n[b];for(let B in P){let V=P[B];for(let X in V)h(V[X].object),delete V[X];delete P[B]}delete n[b]}}function w(b){if(n[b.id]===void 0)return;let P=n[b.id];for(let B in P){let V=P[B];for(let X in V)h(V[X].object),delete V[X];delete P[B]}delete n[b.id]}function C(b){for(let P in n){let B=n[P];if(B[b.id]===void 0)continue;let V=B[b.id];for(let X in V)h(V[X].object),delete V[X];delete B[b.id]}}function U(){S(),a=!0,r!==s&&(r=s,l(r.object))}function S(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:U,resetDefaultState:S,dispose:R,releaseStatesOfGeometry:w,releaseStatesOfProgram:C,initAttributes:_,enableAttribute:m,disableUnusedAttributes:T}}function op(i,t,e){let n;function s(l){n=l}function r(l,h){i.drawArrays(n,l,h),e.update(h,n,1)}function a(l,h,f){f!==0&&(i.drawArraysInstanced(n,l,h,f),e.update(h,n,f))}function o(l,h,f){if(f===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,h,0,f);let p=0;for(let g=0;g<f;g++)p+=h[g];e.update(p,n,1)}function c(l,h,f,u){if(f===0)return;let p=t.get("WEBGL_multi_draw");if(p===null)for(let g=0;g<l.length;g++)a(l[g],h[g],u[g]);else{p.multiDrawArraysInstancedWEBGL(n,l,0,h,0,u,0,f);let g=0;for(let _=0;_<f;_++)g+=h[_]*u[_];e.update(g,n,1)}}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=c}function lp(i,t,e,n){let s;function r(){if(s!==void 0)return s;if(t.has("EXT_texture_filter_anisotropic")===!0){let C=t.get("EXT_texture_filter_anisotropic");s=i.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(C){return!(C!==qe&&n.convert(C)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(C){let U=C===Ni&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(C!==an&&n.convert(C)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==on&&!U)}function c(C){if(C==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=e.precision!==void 0?e.precision:"highp",h=c(l);h!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);let f=e.logarithmicDepthBuffer===!0,u=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control"),p=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),d=i.getParameter(i.MAX_VERTEX_ATTRIBS),T=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),M=i.getParameter(i.MAX_VARYING_VECTORS),v=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),R=g>0,w=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:u,maxTextures:p,maxVertexTextures:g,maxTextureSize:_,maxCubemapSize:m,maxAttributes:d,maxVertexUniforms:T,maxVaryings:M,maxFragmentUniforms:v,vertexTextures:R,maxSamples:w}}function cp(i){let t=this,e=null,n=0,s=!1,r=!1,a=new Ve,o=new Lt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,u){let p=f.length!==0||u||n!==0||s;return s=u,n=f.length,p},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(f,u){e=h(f,u,0)},this.setState=function(f,u,p){let g=f.clippingPlanes,_=f.clipIntersection,m=f.clipShadows,d=i.get(f);if(!s||g===null||g.length===0||r&&!m)r?h(null):l();else{let T=r?0:n,M=T*4,v=d.clippingState||null;c.value=v,v=h(g,u,M,p);for(let R=0;R!==M;++R)v[R]=e[R];d.clippingState=v,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=T}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(f,u,p,g){let _=f!==null?f.length:0,m=null;if(_!==0){if(m=c.value,g!==!0||m===null){let d=p+_*4,T=u.matrixWorldInverse;o.getNormalMatrix(T),(m===null||m.length<d)&&(m=new Float32Array(d));for(let M=0,v=p;M!==_;++M,v+=4)a.copy(f[M]).applyMatrix4(T,o),a.normal.toArray(m,v),m[v+3]=a.constant}c.value=m,c.needsUpdate=!0}return t.numPlanes=_,t.numIntersection=0,m}}function hp(i){let t=new WeakMap;function e(a,o){return o===Hr?a.mapping=jn:o===Vr&&(a.mapping=Qn),a}function n(a){if(a&&a.isTexture){let o=a.mapping;if(o===Hr||o===Vr)if(t.has(a)){let c=t.get(a).texture;return e(c,a.mapping)}else{let c=a.image;if(c&&c.height>0){let l=new yr(c.height);return l.fromEquirectangularTexture(i,a),t.set(a,l),a.addEventListener("dispose",s),e(l.texture,a.mapping)}else return null}}return a}function s(a){let o=a.target;o.removeEventListener("dispose",s);let c=t.get(o);c!==void 0&&(t.delete(o),c.dispose())}function r(){t=new WeakMap}return{get:n,dispose:r}}var ki=4,Lc=[.125,.215,.35,.446,.526,.582],si=20,Go=new Li,Dc=new zt,Wo=null,Xo=0,qo=0,Yo=!1,ii=(1+Math.sqrt(5))/2,zi=1/ii,Uc=[new N(-ii,zi,0),new N(ii,zi,0),new N(-zi,0,ii),new N(zi,0,ii),new N(0,ii,-zi),new N(0,ii,zi),new N(-1,1,-1),new N(1,1,-1),new N(-1,1,1),new N(1,1,1)],up=new N,Aa=class{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,s=100,r={}){let{size:a=256,position:o=up}=r;Wo=this._renderer.getRenderTarget(),Xo=this._renderer.getActiveCubeFace(),qo=this._renderer.getActiveMipmapLevel(),Yo=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);let c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(t,n,s,c,o),e>0&&this._blur(c,0,0,e),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Oc(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Fc(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(Wo,Xo,qo),this._renderer.xr.enabled=Yo,t.scissorTest=!1,Ta(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===jn||t.mapping===Qn?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Wo=this._renderer.getRenderTarget(),Xo=this._renderer.getActiveCubeFace(),qo=this._renderer.getActiveMipmapLevel(),Yo=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Ke,minFilter:Ke,generateMipmaps:!1,type:Ni,format:qe,colorSpace:$n,depthBuffer:!1},s=Nc(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Nc(t,e,n);let{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=dp(r)),this._blurMaterial=fp(r,t,e)}return s}_compileMaterial(t){let e=new Pe(this._lodPlanes[0],t);this._renderer.compile(e,Go)}_sceneToCubeUV(t,e,n,s,r){let c=new we(90,1,e,n),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],f=this._renderer,u=f.autoClear,p=f.toneMapping;f.getClearColor(Dc),f.toneMapping=Mn,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(s),f.clearDepth(),f.setRenderTarget(null));let _=new Jn({name:"PMREM.Background",side:Ee,depthWrite:!1,depthTest:!1}),m=new Pe(new Ai,_),d=!1,T=t.background;T?T.isColor&&(_.color.copy(T),t.background=null,d=!0):(_.color.copy(Dc),d=!0);for(let M=0;M<6;M++){let v=M%3;v===0?(c.up.set(0,l[M],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+h[M],r.y,r.z)):v===1?(c.up.set(0,0,l[M]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+h[M],r.z)):(c.up.set(0,l[M],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+h[M]));let R=this._cubeSize;Ta(s,v*R,M>2?R:0,R,R),f.setRenderTarget(s),d&&f.render(m,c),f.render(t,c)}m.geometry.dispose(),m.material.dispose(),f.toneMapping=p,f.autoClear=u,t.background=T}_textureToCubeUV(t,e){let n=this._renderer,s=t.mapping===jn||t.mapping===Qn;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Oc()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Fc());let r=s?this._cubemapMaterial:this._equirectMaterial,a=new Pe(this._lodPlanes[0],r),o=r.uniforms;o.envMap.value=t;let c=this._cubeSize;Ta(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(a,Go)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;let s=this._lodPlanes.length;for(let r=1;r<s;r++){let a=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),o=Uc[(s-r-1)%Uc.length];this._blur(t,r-1,r,a,o)}e.autoClear=n}_blur(t,e,n,s,r){let a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,s,"latitudinal",r),this._halfBlur(a,t,n,n,s,"longitudinal",r)}_halfBlur(t,e,n,s,r,a,o){let c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let h=3,f=new Pe(this._lodPlanes[s],l),u=l.uniforms,p=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*si-1),_=r/g,m=isFinite(r)?1+Math.floor(h*_):si;m>si&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${si}`);let d=[],T=0;for(let C=0;C<si;++C){let U=C/_,S=Math.exp(-U*U/2);d.push(S),C===0?T+=S:C<m&&(T+=2*S)}for(let C=0;C<d.length;C++)d[C]=d[C]/T;u.envMap.value=t.texture,u.samples.value=m,u.weights.value=d,u.latitudinal.value=a==="latitudinal",o&&(u.poleAxis.value=o);let{_lodMax:M}=this;u.dTheta.value=g,u.mipInt.value=M-n;let v=this._sizeLods[s],R=3*v*(s>M-ki?s-M+ki:0),w=4*(this._cubeSize-v);Ta(e,R,w,3*v,2*v),c.setRenderTarget(e),c.render(f,Go)}};function dp(i){let t=[],e=[],n=[],s=i,r=i-ki+1+Lc.length;for(let a=0;a<r;a++){let o=Math.pow(2,s);e.push(o);let c=1/o;a>i-ki?c=Lc[a-i+ki-1]:a===0&&(c=0),n.push(c);let l=1/(o-2),h=-l,f=1+l,u=[h,h,f,h,f,f,h,h,f,f,h,f],p=6,g=6,_=3,m=2,d=1,T=new Float32Array(_*g*p),M=new Float32Array(m*g*p),v=new Float32Array(d*g*p);for(let w=0;w<p;w++){let C=w%3*2/3-1,U=w>2?0:-1,S=[C,U,0,C+2/3,U,0,C+2/3,U+1,0,C,U,0,C+2/3,U+1,0,C,U+1,0];T.set(S,_*g*w),M.set(u,m*g*w);let b=[w,w,w,w,w,w];v.set(b,d*g*w)}let R=new ye;R.setAttribute("position",new ae(T,_)),R.setAttribute("uv",new ae(M,m)),R.setAttribute("faceIndex",new ae(v,d)),t.push(R),s>ki&&s--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function Nc(i,t,e){let n=new en(i,t,e);return n.texture.mapping=Ts,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ta(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function fp(i,t,e){let n=new Float32Array(si),s=new N(0,1,0);return new je({name:"SphericalGaussianBlur",defines:{n:si,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,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:il(),fragmentShader:`
3587
+ }`,We={alphahash_fragment:p0,alphahash_pars_fragment:m0,alphamap_fragment:g0,alphamap_pars_fragment:y0,alphatest_fragment:v0,alphatest_pars_fragment:x0,aomap_fragment:_0,aomap_pars_fragment:b0,batching_pars_vertex:S0,batching_vertex:w0,begin_vertex:M0,beginnormal_vertex:E0,bsdfs:T0,iridescence_fragment:A0,bumpmap_pars_fragment:C0,clipping_planes_fragment:R0,clipping_planes_pars_fragment:P0,clipping_planes_pars_vertex:I0,clipping_planes_vertex:L0,color_fragment:D0,color_pars_fragment:k0,color_pars_vertex:N0,color_vertex:O0,common:U0,cube_uv_reflection_fragment:F0,defaultnormal_vertex:B0,displacementmap_pars_vertex:z0,displacementmap_vertex:V0,emissivemap_fragment:H0,emissivemap_pars_fragment:G0,colorspace_fragment:W0,colorspace_pars_fragment:$0,envmap_fragment:X0,envmap_common_pars_fragment:q0,envmap_pars_fragment:Y0,envmap_pars_vertex:j0,envmap_physical_pars_fragment:av,envmap_vertex:Z0,fog_vertex:J0,fog_pars_vertex:K0,fog_fragment:Q0,fog_pars_fragment:ev,gradientmap_pars_fragment:tv,lightmap_pars_fragment:nv,lights_lambert_fragment:iv,lights_lambert_pars_fragment:rv,lights_pars_begin:sv,lights_toon_fragment:ov,lights_toon_pars_fragment:lv,lights_phong_fragment:cv,lights_phong_pars_fragment:hv,lights_physical_fragment:uv,lights_physical_pars_fragment:dv,lights_fragment_begin:fv,lights_fragment_maps:pv,lights_fragment_end:mv,logdepthbuf_fragment:gv,logdepthbuf_pars_fragment:yv,logdepthbuf_pars_vertex:vv,logdepthbuf_vertex:xv,map_fragment:_v,map_pars_fragment:bv,map_particle_fragment:Sv,map_particle_pars_fragment:wv,metalnessmap_fragment:Mv,metalnessmap_pars_fragment:Ev,morphinstance_vertex:Tv,morphcolor_vertex:Av,morphnormal_vertex:Cv,morphtarget_pars_vertex:Rv,morphtarget_vertex:Pv,normal_fragment_begin:Iv,normal_fragment_maps:Lv,normal_pars_fragment:Dv,normal_pars_vertex:kv,normal_vertex:Nv,normalmap_pars_fragment:Ov,clearcoat_normal_fragment_begin:Uv,clearcoat_normal_fragment_maps:Fv,clearcoat_pars_fragment:Bv,iridescence_pars_fragment:zv,opaque_fragment:Vv,packing:Hv,premultiplied_alpha_fragment:Gv,project_vertex:Wv,dithering_fragment:$v,dithering_pars_fragment:Xv,roughnessmap_fragment:qv,roughnessmap_pars_fragment:Yv,shadowmap_pars_fragment:jv,shadowmap_pars_vertex:Zv,shadowmap_vertex:Jv,shadowmask_pars_fragment:Kv,skinbase_vertex:Qv,skinning_pars_vertex:ex,skinning_vertex:tx,skinnormal_vertex:nx,specularmap_fragment:ix,specularmap_pars_fragment:rx,tonemapping_fragment:sx,tonemapping_pars_fragment:ax,transmission_fragment:ox,transmission_pars_fragment:lx,uv_pars_fragment:cx,uv_pars_vertex:hx,uv_vertex:ux,worldpos_vertex:dx,background_vert:fx,background_frag:px,backgroundCube_vert:mx,backgroundCube_frag:gx,cube_vert:yx,cube_frag:vx,depth_vert:xx,depth_frag:_x,distanceRGBA_vert:bx,distanceRGBA_frag:Sx,equirect_vert:wx,equirect_frag:Mx,linedashed_vert:Ex,linedashed_frag:Tx,meshbasic_vert:Ax,meshbasic_frag:Cx,meshlambert_vert:Rx,meshlambert_frag:Px,meshmatcap_vert:Ix,meshmatcap_frag:Lx,meshnormal_vert:Dx,meshnormal_frag:kx,meshphong_vert:Nx,meshphong_frag:Ox,meshphysical_vert:Ux,meshphysical_frag:Fx,meshtoon_vert:Bx,meshtoon_frag:zx,points_vert:Vx,points_frag:Hx,shadow_vert:Gx,shadow_frag:Wx,sprite_vert:$x,sprite_frag:Xx},ce={common:{diffuse:{value:new Ze(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ze}},envmap:{envMap:{value:null},envMapRotation:{value:new ze},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ze}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ze}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ze},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ze},normalScale:{value:new ke(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ze},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ze}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ze}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ze}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ze(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ze(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0},uvTransform:{value:new ze}},sprite:{diffuse:{value:new Ze(16777215)},opacity:{value:1},center:{value:new ke(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}}},jn={basic:{uniforms:Yt([ce.common,ce.specularmap,ce.envmap,ce.aomap,ce.lightmap,ce.fog]),vertexShader:We.meshbasic_vert,fragmentShader:We.meshbasic_frag},lambert:{uniforms:Yt([ce.common,ce.specularmap,ce.envmap,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.fog,ce.lights,{emissive:{value:new Ze(0)}}]),vertexShader:We.meshlambert_vert,fragmentShader:We.meshlambert_frag},phong:{uniforms:Yt([ce.common,ce.specularmap,ce.envmap,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.fog,ce.lights,{emissive:{value:new Ze(0)},specular:{value:new Ze(1118481)},shininess:{value:30}}]),vertexShader:We.meshphong_vert,fragmentShader:We.meshphong_frag},standard:{uniforms:Yt([ce.common,ce.envmap,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.roughnessmap,ce.metalnessmap,ce.fog,ce.lights,{emissive:{value:new Ze(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:We.meshphysical_vert,fragmentShader:We.meshphysical_frag},toon:{uniforms:Yt([ce.common,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.gradientmap,ce.fog,ce.lights,{emissive:{value:new Ze(0)}}]),vertexShader:We.meshtoon_vert,fragmentShader:We.meshtoon_frag},matcap:{uniforms:Yt([ce.common,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.fog,{matcap:{value:null}}]),vertexShader:We.meshmatcap_vert,fragmentShader:We.meshmatcap_frag},points:{uniforms:Yt([ce.points,ce.fog]),vertexShader:We.points_vert,fragmentShader:We.points_frag},dashed:{uniforms:Yt([ce.common,ce.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:We.linedashed_vert,fragmentShader:We.linedashed_frag},depth:{uniforms:Yt([ce.common,ce.displacementmap]),vertexShader:We.depth_vert,fragmentShader:We.depth_frag},normal:{uniforms:Yt([ce.common,ce.bumpmap,ce.normalmap,ce.displacementmap,{opacity:{value:1}}]),vertexShader:We.meshnormal_vert,fragmentShader:We.meshnormal_frag},sprite:{uniforms:Yt([ce.sprite,ce.fog]),vertexShader:We.sprite_vert,fragmentShader:We.sprite_frag},background:{uniforms:{uvTransform:{value:new ze},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:We.background_vert,fragmentShader:We.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ze}},vertexShader:We.backgroundCube_vert,fragmentShader:We.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:We.cube_vert,fragmentShader:We.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:We.equirect_vert,fragmentShader:We.equirect_frag},distanceRGBA:{uniforms:Yt([ce.common,ce.displacementmap,{referencePosition:{value:new N},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:We.distanceRGBA_vert,fragmentShader:We.distanceRGBA_frag},shadow:{uniforms:Yt([ce.lights,ce.fog,{color:{value:new Ze(0)},opacity:{value:1}}]),vertexShader:We.shadow_vert,fragmentShader:We.shadow_frag}};jn.physical={uniforms:Yt([jn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ze},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ze},clearcoatNormalScale:{value:new ke(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ze},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ze},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ze},sheen:{value:0},sheenColor:{value:new Ze(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ze},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ze},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ze},transmissionSamplerSize:{value:new ke},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ze},attenuationDistance:{value:0},attenuationColor:{value:new Ze(0)},specularColor:{value:new Ze(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ze},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ze},anisotropyVector:{value:new ke},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ze}}]),vertexShader:We.meshphysical_vert,fragmentShader:We.meshphysical_frag};var $l={r:0,b:0,g:0},fr=new Xn,qx=new St;function Yx(n,e,t,i,r,s,a){let o=new Ze(0),l=s===!0?0:1,c,h,u=null,d=0,f=null;function g(S){let x=S.isScene===!0?S.background:null;return x&&x.isTexture&&(x=(S.backgroundBlurriness>0?t:e).get(x)),x}function y(S){let x=!1,A=g(S);A===null?p(o,l):A&&A.isColor&&(p(A,1),x=!0);let T=n.xr.getEnvironmentBlendMode();T==="additive"?i.buffers.color.setClear(0,0,0,1,a):T==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,a),(n.autoClear||x)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function m(S,x){let A=g(x);A&&(A.isCubeTexture||A.mapping===ua)?(h===void 0&&(h=new Xt(new Kr(1,1,1),new sn({name:"BackgroundCubeMaterial",uniforms:dr(jn.backgroundCube.uniforms),vertexShader:jn.backgroundCube.vertexShader,fragmentShader:jn.backgroundCube.fragmentShader,side:Qt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(T,R,k){this.matrixWorld.copyPosition(k.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(h)),fr.copy(x.backgroundRotation),fr.x*=-1,fr.y*=-1,fr.z*=-1,A.isCubeTexture&&A.isRenderTargetTexture===!1&&(fr.y*=-1,fr.z*=-1),h.material.uniforms.envMap.value=A,h.material.uniforms.flipEnvMap.value=A.isCubeTexture&&A.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(qx.makeRotationFromEuler(fr)),h.material.toneMapped=Ke.getTransfer(A.colorSpace)!==at,(u!==A||d!==A.version||f!==n.toneMapping)&&(h.material.needsUpdate=!0,u=A,d=A.version,f=n.toneMapping),h.layers.enableAll(),S.unshift(h,h.geometry,h.material,0,0,null)):A&&A.isTexture&&(c===void 0&&(c=new Xt(new ar(2,2),new sn({name:"BackgroundMaterial",uniforms:dr(jn.background.uniforms),vertexShader:jn.background.vertexShader,fragmentShader:jn.background.fragmentShader,side:li,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=A,c.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,c.material.toneMapped=Ke.getTransfer(A.colorSpace)!==at,A.matrixAutoUpdate===!0&&A.updateMatrix(),c.material.uniforms.uvTransform.value.copy(A.matrix),(u!==A||d!==A.version||f!==n.toneMapping)&&(c.material.needsUpdate=!0,u=A,d=A.version,f=n.toneMapping),c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null))}function p(S,x){S.getRGB($l,jh(n)),i.buffers.color.setClear($l.r,$l.g,$l.b,x,a)}function M(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(S,x=1){o.set(S),l=x,p(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(S){l=S,p(o,l)},render:y,addToRenderList:m,dispose:M}}function jx(n,e){let t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=d(null),s=r,a=!1;function o(b,D,V,W,Y){let j=!1,X=u(W,V,D);s!==X&&(s=X,c(s.object)),j=f(b,W,V,Y),j&&g(b,W,V,Y),Y!==null&&e.update(Y,n.ELEMENT_ARRAY_BUFFER),(j||a)&&(a=!1,x(b,D,V,W),Y!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(Y).buffer))}function l(){return n.createVertexArray()}function c(b){return n.bindVertexArray(b)}function h(b){return n.deleteVertexArray(b)}function u(b,D,V){let W=V.wireframe===!0,Y=i[b.id];Y===void 0&&(Y={},i[b.id]=Y);let j=Y[D.id];j===void 0&&(j={},Y[D.id]=j);let X=j[W];return X===void 0&&(X=d(l()),j[W]=X),X}function d(b){let D=[],V=[],W=[];for(let Y=0;Y<t;Y++)D[Y]=0,V[Y]=0,W[Y]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:D,enabledAttributes:V,attributeDivisors:W,object:b,attributes:{},index:null}}function f(b,D,V,W){let Y=s.attributes,j=D.attributes,X=0,re=V.getAttributes();for(let H in re)if(re[H].location>=0){let ee=Y[H],Me=j[H];if(Me===void 0&&(H==="instanceMatrix"&&b.instanceMatrix&&(Me=b.instanceMatrix),H==="instanceColor"&&b.instanceColor&&(Me=b.instanceColor)),ee===void 0||ee.attribute!==Me||Me&&ee.data!==Me.data)return!0;X++}return s.attributesNum!==X||s.index!==W}function g(b,D,V,W){let Y={},j=D.attributes,X=0,re=V.getAttributes();for(let H in re)if(re[H].location>=0){let ee=j[H];ee===void 0&&(H==="instanceMatrix"&&b.instanceMatrix&&(ee=b.instanceMatrix),H==="instanceColor"&&b.instanceColor&&(ee=b.instanceColor));let Me={};Me.attribute=ee,ee&&ee.data&&(Me.data=ee.data),Y[H]=Me,X++}s.attributes=Y,s.attributesNum=X,s.index=W}function y(){let b=s.newAttributes;for(let D=0,V=b.length;D<V;D++)b[D]=0}function m(b){p(b,0)}function p(b,D){let V=s.newAttributes,W=s.enabledAttributes,Y=s.attributeDivisors;V[b]=1,W[b]===0&&(n.enableVertexAttribArray(b),W[b]=1),Y[b]!==D&&(n.vertexAttribDivisor(b,D),Y[b]=D)}function M(){let b=s.newAttributes,D=s.enabledAttributes;for(let V=0,W=D.length;V<W;V++)D[V]!==b[V]&&(n.disableVertexAttribArray(V),D[V]=0)}function S(b,D,V,W,Y,j,X){X===!0?n.vertexAttribIPointer(b,D,V,Y,j):n.vertexAttribPointer(b,D,V,W,Y,j)}function x(b,D,V,W){y();let Y=W.attributes,j=V.getAttributes(),X=D.defaultAttributeValues;for(let re in j){let H=j[re];if(H.location>=0){let oe=Y[re];if(oe===void 0&&(re==="instanceMatrix"&&b.instanceMatrix&&(oe=b.instanceMatrix),re==="instanceColor"&&b.instanceColor&&(oe=b.instanceColor)),oe!==void 0){let ee=oe.normalized,Me=oe.itemSize,$e=e.get(oe);if($e===void 0)continue;let rt=$e.buffer,Ue=$e.type,qe=$e.bytesPerElement,$=Ue===n.INT||Ue===n.UNSIGNED_INT||oe.gpuType===ul;if(oe.isInterleavedBufferAttribute){let J=oe.data,me=J.stride,ve=oe.offset;if(J.isInstancedInterleavedBuffer){for(let ue=0;ue<H.locationSize;ue++)p(H.location+ue,J.meshPerAttribute);b.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let ue=0;ue<H.locationSize;ue++)m(H.location+ue);n.bindBuffer(n.ARRAY_BUFFER,rt);for(let ue=0;ue<H.locationSize;ue++)S(H.location+ue,Me/H.locationSize,Ue,ee,me*qe,(ve+Me/H.locationSize*ue)*qe,$)}else{if(oe.isInstancedBufferAttribute){for(let J=0;J<H.locationSize;J++)p(H.location+J,oe.meshPerAttribute);b.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=oe.meshPerAttribute*oe.count)}else for(let J=0;J<H.locationSize;J++)m(H.location+J);n.bindBuffer(n.ARRAY_BUFFER,rt);for(let J=0;J<H.locationSize;J++)S(H.location+J,Me/H.locationSize,Ue,ee,Me*qe,Me/H.locationSize*J*qe,$)}}else if(X!==void 0){let ee=X[re];if(ee!==void 0)switch(ee.length){case 2:n.vertexAttrib2fv(H.location,ee);break;case 3:n.vertexAttrib3fv(H.location,ee);break;case 4:n.vertexAttrib4fv(H.location,ee);break;default:n.vertexAttrib1fv(H.location,ee)}}}}M()}function A(){k();for(let b in i){let D=i[b];for(let V in D){let W=D[V];for(let Y in W)h(W[Y].object),delete W[Y];delete D[V]}delete i[b]}}function T(b){if(i[b.id]===void 0)return;let D=i[b.id];for(let V in D){let W=D[V];for(let Y in W)h(W[Y].object),delete W[Y];delete D[V]}delete i[b.id]}function R(b){for(let D in i){let V=i[D];if(V[b.id]===void 0)continue;let W=V[b.id];for(let Y in W)h(W[Y].object),delete W[Y];delete V[b.id]}}function k(){w(),a=!0,s!==r&&(s=r,c(s.object))}function w(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:k,resetDefaultState:w,dispose:A,releaseStatesOfGeometry:T,releaseStatesOfProgram:R,initAttributes:y,enableAttribute:m,disableUnusedAttributes:M}}function Zx(n,e,t){let i;function r(c){i=c}function s(c,h){n.drawArrays(i,c,h),t.update(h,i,1)}function a(c,h,u){u!==0&&(n.drawArraysInstanced(i,c,h,u),t.update(h,i,u))}function o(c,h,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,h,0,u);let f=0;for(let g=0;g<u;g++)f+=h[g];t.update(f,i,1)}function l(c,h,u,d){if(u===0)return;let f=e.get("WEBGL_multi_draw");if(f===null)for(let g=0;g<c.length;g++)a(c[g],h[g],d[g]);else{f.multiDrawArraysInstancedWEBGL(i,c,0,h,0,d,0,u);let g=0;for(let y=0;y<u;y++)g+=h[y]*d[y];t.update(g,i,1)}}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function Jx(n,e,t,i){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){let R=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(R){return!(R!==an&&i.convert(R)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){let k=R===ss&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(R!==Yn&&i.convert(R)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==En&&!k)}function l(R){if(R==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp",h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);let u=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),f=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),g=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=n.getParameter(n.MAX_TEXTURE_SIZE),m=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),p=n.getParameter(n.MAX_VERTEX_ATTRIBS),M=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),S=n.getParameter(n.MAX_VARYING_VECTORS),x=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),A=g>0,T=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:y,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:M,maxVaryings:S,maxFragmentUniforms:x,vertexTextures:A,maxSamples:T}}function Kx(n){let e=this,t=null,i=0,r=!1,s=!1,a=new _n,o=new ze,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){let f=u.length!==0||d||i!==0||r;return r=d,i=u.length,f},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,d){t=h(u,d,0)},this.setState=function(u,d,f){let g=u.clippingPlanes,y=u.clipIntersection,m=u.clipShadows,p=n.get(u);if(!r||g===null||g.length===0||s&&!m)s?h(null):c();else{let M=s?0:i,S=M*4,x=p.clippingState||null;l.value=x,x=h(g,d,S,f);for(let A=0;A!==S;++A)x[A]=t[A];p.clippingState=x,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=M}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(u,d,f,g){let y=u!==null?u.length:0,m=null;if(y!==0){if(m=l.value,g!==!0||m===null){let p=f+y*4,M=d.matrixWorldInverse;o.getNormalMatrix(M),(m===null||m.length<p)&&(m=new Float32Array(p));for(let S=0,x=f;S!==y;++S,x+=4)a.copy(u[S]).applyMatrix4(M,o),a.normal.toArray(m,x),m[x+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,m}}function Qx(n){let e=new WeakMap;function t(a,o){return o===ll?a.mapping=cr:o===cl&&(a.mapping=hr),a}function i(a){if(a&&a.isTexture){let o=a.mapping;if(o===ll||o===cl)if(e.has(a)){let l=e.get(a).texture;return t(l,a.mapping)}else{let l=a.image;if(l&&l.height>0){let c=new Bo(l.height);return c.fromEquirectangularTexture(n,a),e.set(a,c),a.addEventListener("dispose",r),t(c.texture,a.mapping)}else return null}}return a}function r(a){let o=a.target;o.removeEventListener("dispose",r);let l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}var cs=4,cp=[.125,.215,.35,.446,.526,.582],gr=20,Qh=new Nn,hp=new Ze,eu=null,tu=0,nu=0,iu=!1,mr=(1+Math.sqrt(5))/2,ls=1/mr,up=[new N(-mr,ls,0),new N(mr,ls,0),new N(-ls,0,mr),new N(ls,0,mr),new N(0,mr,-ls),new N(0,mr,ls),new N(-1,1,-1),new N(1,1,-1),new N(-1,1,1),new N(1,1,1)],e_=new N,Yl=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,r=100,s={}){let{size:a=256,position:o=e_}=s;eu=this._renderer.getRenderTarget(),tu=this._renderer.getActiveCubeFace(),nu=this._renderer.getActiveMipmapLevel(),iu=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);let l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,r,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=pp(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=fp(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(eu,tu,nu),this._renderer.xr.enabled=iu,e.scissorTest=!1,Xl(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===cr||e.mapping===hr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),eu=this._renderer.getRenderTarget(),tu=this._renderer.getActiveCubeFace(),nu=this._renderer.getActiveMipmapLevel(),iu=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:kn,minFilter:kn,generateMipmaps:!1,type:ss,format:an,colorSpace:ci,depthBuffer:!1},r=dp(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=dp(e,t,i);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=t_(s)),this._blurMaterial=n_(s,e,t)}return r}_compileMaterial(e){let t=new Xt(this._lodPlanes[0],e);this._renderer.compile(t,Qh)}_sceneToCubeUV(e,t,i,r,s){let l=new Wt(90,1,t,i),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(hp),u.toneMapping=ui,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(r),u.clearDepth(),u.setRenderTarget(null));let y=new Js({name:"PMREM.Background",side:Qt,depthWrite:!1,depthTest:!1}),m=new Xt(new Kr,y),p=!1,M=e.background;M?M.isColor&&(y.color.copy(M),e.background=null,p=!0):(y.color.copy(hp),p=!0);for(let S=0;S<6;S++){let x=S%3;x===0?(l.up.set(0,c[S],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+h[S],s.y,s.z)):x===1?(l.up.set(0,0,c[S]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+h[S],s.z)):(l.up.set(0,c[S],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+h[S]));let A=this._cubeSize;Xl(r,x*A,S>2?A:0,A,A),u.setRenderTarget(r),p&&u.render(m,l),u.render(e,l)}m.geometry.dispose(),m.material.dispose(),u.toneMapping=f,u.autoClear=d,e.background=M}_textureToCubeUV(e,t){let i=this._renderer,r=e.mapping===cr||e.mapping===hr;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=pp()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=fp());let s=r?this._cubemapMaterial:this._equirectMaterial,a=new Xt(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;let l=this._cubeSize;Xl(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,Qh)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;let r=this._lodPlanes.length;for(let s=1;s<r;s++){let a=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),o=up[(r-s-1)%up.length];this._blur(e,s-1,s,a,o)}t.autoClear=i}_blur(e,t,i,r,s){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,r,"latitudinal",s),this._halfBlur(a,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,a,o){let l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let h=3,u=new Xt(this._lodPlanes[r],c),d=c.uniforms,f=this._sizeLods[i]-1,g=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*gr-1),y=s/g,m=isFinite(s)?1+Math.floor(h*y):gr;m>gr&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${gr}`);let p=[],M=0;for(let R=0;R<gr;++R){let k=R/y,w=Math.exp(-k*k/2);p.push(w),R===0?M+=w:R<m&&(M+=2*w)}for(let R=0;R<p.length;R++)p[R]=p[R]/M;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=p,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);let{_lodMax:S}=this;d.dTheta.value=g,d.mipInt.value=S-i;let x=this._sizeLods[r],A=3*x*(r>S-cs?r-S+cs:0),T=4*(this._cubeSize-x);Xl(t,A,T,3*x,2*x),l.setRenderTarget(t),l.render(u,Qh)}};function t_(n){let e=[],t=[],i=[],r=n,s=n-cs+1+cp.length;for(let a=0;a<s;a++){let o=Math.pow(2,r);t.push(o);let l=1/o;a>n-cs?l=cp[a-n+cs-1]:a===0&&(l=0),i.push(l);let c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,g=6,y=3,m=2,p=1,M=new Float32Array(y*g*f),S=new Float32Array(m*g*f),x=new Float32Array(p*g*f);for(let T=0;T<f;T++){let R=T%3*2/3-1,k=T>2?0:-1,w=[R,k,0,R+2/3,k,0,R+2/3,k+1,0,R,k,0,R+2/3,k+1,0,R,k+1,0];M.set(w,y*g*T),S.set(d,m*g*T);let b=[T,T,T,T,T,T];x.set(b,p*g*T)}let A=new Tt;A.setAttribute("position",new wt(M,y)),A.setAttribute("uv",new wt(S,m)),A.setAttribute("faceIndex",new wt(x,p)),e.push(A),r>cs&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function dp(n,e,t){let i=new Sn(n,e,t);return i.texture.mapping=ua,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Xl(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function n_(n,e,t){let i=new Float32Array(gr),r=new N(0,1,0);return new sn({name:"SphericalGaussianBlur",defines:{n:gr,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:fu(),fragmentShader:`
3580
3588
 
3581
3589
  precision mediump float;
3582
3590
  precision mediump int;
@@ -3636,7 +3644,7 @@ void main() {
3636
3644
  }
3637
3645
 
3638
3646
  }
3639
- `,blending:vn,depthTest:!1,depthWrite:!1})}function Fc(){return new je({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:il(),fragmentShader:`
3647
+ `,blending:Un,depthTest:!1,depthWrite:!1})}function fp(){return new sn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:fu(),fragmentShader:`
3640
3648
 
3641
3649
  precision mediump float;
3642
3650
  precision mediump int;
@@ -3655,7 +3663,7 @@ void main() {
3655
3663
  gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3656
3664
 
3657
3665
  }
3658
- `,blending:vn,depthTest:!1,depthWrite:!1})}function Oc(){return new je({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:il(),fragmentShader:`
3666
+ `,blending:Un,depthTest:!1,depthWrite:!1})}function pp(){return new sn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:fu(),fragmentShader:`
3659
3667
 
3660
3668
  precision mediump float;
3661
3669
  precision mediump int;
@@ -3671,7 +3679,7 @@ void main() {
3671
3679
  gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
3672
3680
 
3673
3681
  }
3674
- `,blending:vn,depthTest:!1,depthWrite:!1})}function il(){return`
3682
+ `,blending:Un,depthTest:!1,depthWrite:!1})}function fu(){return`
3675
3683
 
3676
3684
  precision mediump float;
3677
3685
  precision mediump int;
@@ -3726,60 +3734,60 @@ void main() {
3726
3734
  gl_Position = vec4( position, 1.0 );
3727
3735
 
3728
3736
  }
3729
- `}function pp(i){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){let c=o.mapping,l=c===Hr||c===Vr,h=c===jn||c===Qn;if(l||h){let f=t.get(o),u=f!==void 0?f.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==u)return e===null&&(e=new Aa(i)),f=l?e.fromEquirectangular(o,f):e.fromCubemap(o,f),f.texture.pmremVersion=o.pmremVersion,t.set(o,f),f.texture;if(f!==void 0)return f.texture;{let p=o.image;return l&&p&&p.height>0||h&&p&&s(p)?(e===null&&(e=new Aa(i)),f=l?e.fromEquirectangular(o):e.fromCubemap(o),f.texture.pmremVersion=o.pmremVersion,t.set(o,f),o.addEventListener("dispose",r),f.texture):null}}}return o}function s(o){let c=0,l=6;for(let h=0;h<l;h++)o[h]!==void 0&&c++;return c===l}function r(o){let c=o.target;c.removeEventListener("dispose",r);let l=t.get(c);l!==void 0&&(t.delete(c),l.dispose())}function a(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:n,dispose:a}}function mp(i){let t={};function e(n){if(t[n]!==void 0)return t[n];let s;switch(n){case"WEBGL_depth_texture":s=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=i.getExtension(n)}return t[n]=s,s}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){let s=e(n);return s===null&&Ti("THREE.WebGLRenderer: "+n+" extension not supported."),s}}}function gp(i,t,e,n){let s={},r=new WeakMap;function a(f){let u=f.target;u.index!==null&&t.remove(u.index);for(let g in u.attributes)t.remove(u.attributes[g]);u.removeEventListener("dispose",a),delete s[u.id];let p=r.get(u);p&&(t.remove(p),r.delete(u)),n.releaseStatesOfGeometry(u),u.isInstancedBufferGeometry===!0&&delete u._maxInstanceCount,e.memory.geometries--}function o(f,u){return s[u.id]===!0||(u.addEventListener("dispose",a),s[u.id]=!0,e.memory.geometries++),u}function c(f){let u=f.attributes;for(let p in u)t.update(u[p],i.ARRAY_BUFFER)}function l(f){let u=[],p=f.index,g=f.attributes.position,_=0;if(p!==null){let T=p.array;_=p.version;for(let M=0,v=T.length;M<v;M+=3){let R=T[M+0],w=T[M+1],C=T[M+2];u.push(R,w,w,C,C,R)}}else if(g!==void 0){let T=g.array;_=g.version;for(let M=0,v=T.length/3-1;M<v;M+=3){let R=M+0,w=M+1,C=M+2;u.push(R,w,w,C,C,R)}}else return;let m=new(Bo(u)?us:hs)(u,1);m.version=_;let d=r.get(f);d&&t.remove(d),r.set(f,m)}function h(f){let u=r.get(f);if(u){let p=f.index;p!==null&&u.version<p.version&&l(f)}else l(f);return r.get(f)}return{get:o,update:c,getWireframeAttribute:h}}function _p(i,t,e){let n;function s(u){n=u}let r,a;function o(u){r=u.type,a=u.bytesPerElement}function c(u,p){i.drawElements(n,p,r,u*a),e.update(p,n,1)}function l(u,p,g){g!==0&&(i.drawElementsInstanced(n,p,r,u*a,g),e.update(p,n,g))}function h(u,p,g){if(g===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,p,0,r,u,0,g);let m=0;for(let d=0;d<g;d++)m+=p[d];e.update(m,n,1)}function f(u,p,g,_){if(g===0)return;let m=t.get("WEBGL_multi_draw");if(m===null)for(let d=0;d<u.length;d++)l(u[d]/a,p[d],_[d]);else{m.multiDrawElementsInstancedWEBGL(n,p,0,r,u,0,_,0,g);let d=0;for(let T=0;T<g;T++)d+=p[T]*_[T];e.update(d,n,1)}}this.setMode=s,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h,this.renderMultiDrawInstances=f}function xp(i){let t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(e.calls++,a){case i.TRIANGLES:e.triangles+=o*(r/3);break;case i.LINES:e.lines+=o*(r/2);break;case i.LINE_STRIP:e.lines+=o*(r-1);break;case i.LINE_LOOP:e.lines+=o*r;break;case i.POINTS:e.points+=o*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function s(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:s,update:n}}function yp(i,t,e){let n=new WeakMap,s=new oe;function r(a,o,c){let l=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,f=h!==void 0?h.length:0,u=n.get(o);if(u===void 0||u.count!==f){let S=function(){C.dispose(),n.delete(o),o.removeEventListener("dispose",S)};u!==void 0&&u.texture.dispose();let p=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,_=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],d=o.morphAttributes.normal||[],T=o.morphAttributes.color||[],M=0;p===!0&&(M=1),g===!0&&(M=2),_===!0&&(M=3);let v=o.attributes.position.count*M,R=1;v>t.maxTextureSize&&(R=Math.ceil(v/t.maxTextureSize),v=t.maxTextureSize);let w=new Float32Array(v*R*4*f),C=new ls(w,v,R,f);C.type=on,C.needsUpdate=!0;let U=M*4;for(let b=0;b<f;b++){let P=m[b],B=d[b],V=T[b],X=v*R*4*b;for(let Z=0;Z<P.count;Z++){let W=Z*U;p===!0&&(s.fromBufferAttribute(P,Z),w[X+W+0]=s.x,w[X+W+1]=s.y,w[X+W+2]=s.z,w[X+W+3]=0),g===!0&&(s.fromBufferAttribute(B,Z),w[X+W+4]=s.x,w[X+W+5]=s.y,w[X+W+6]=s.z,w[X+W+7]=0),_===!0&&(s.fromBufferAttribute(V,Z),w[X+W+8]=s.x,w[X+W+9]=s.y,w[X+W+10]=s.z,w[X+W+11]=V.itemSize===4?s.w:1)}}u={count:f,texture:C,size:new Ut(v,R)},n.set(o,u),o.addEventListener("dispose",S)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",a.morphTexture,e);else{let p=0;for(let _=0;_<l.length;_++)p+=l[_];let g=o.morphTargetsRelative?1:1-p;c.getUniforms().setValue(i,"morphTargetBaseInfluence",g),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",u.texture,e),c.getUniforms().setValue(i,"morphTargetsTextureSize",u.size)}return{update:r}}function vp(i,t,e,n){let s=new WeakMap;function r(c){let l=n.render.frame,h=c.geometry,f=t.get(c,h);if(s.get(f)!==l&&(t.update(f),s.set(f,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",o)===!1&&c.addEventListener("dispose",o),s.get(c)!==l&&(e.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&e.update(c.instanceColor,i.ARRAY_BUFFER),s.set(c,l))),c.isSkinnedMesh){let u=c.skeleton;s.get(u)!==l&&(u.update(),s.set(u,l))}return f}function a(){s=new WeakMap}function o(c){let l=c.target;l.removeEventListener("dispose",o),e.remove(l.instanceMatrix),l.instanceColor!==null&&e.remove(l.instanceColor)}return{update:r,dispose:a}}var nh=new Re,Bc=new xs(1,1),ih=new ls,sh=new _r,rh=new fs,zc=[],kc=[],Hc=new Float32Array(16),Vc=new Float32Array(9),Gc=new Float32Array(4);function Vi(i,t,e){let n=i[0];if(n<=0||n>0)return i;let s=t*e,r=zc[s];if(r===void 0&&(r=new Float32Array(s),zc[s]=r),t!==0){n.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=e,i[a].toArray(r,o)}return r}function ue(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e<n;e++)if(i[e]!==t[e])return!1;return!0}function de(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function Ca(i,t){let e=kc[t];e===void 0&&(e=new Int32Array(t),kc[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function Mp(i,t){let e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function bp(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(ue(e,t))return;i.uniform2fv(this.addr,t),de(e,t)}}function Sp(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(i.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(ue(e,t))return;i.uniform3fv(this.addr,t),de(e,t)}}function Ep(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(ue(e,t))return;i.uniform4fv(this.addr,t),de(e,t)}}function Tp(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(ue(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),de(e,t)}else{if(ue(e,n))return;Gc.set(n),i.uniformMatrix2fv(this.addr,!1,Gc),de(e,n)}}function wp(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(ue(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),de(e,t)}else{if(ue(e,n))return;Vc.set(n),i.uniformMatrix3fv(this.addr,!1,Vc),de(e,n)}}function Ap(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(ue(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),de(e,t)}else{if(ue(e,n))return;Hc.set(n),i.uniformMatrix4fv(this.addr,!1,Hc),de(e,n)}}function Rp(i,t){let e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function Cp(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(ue(e,t))return;i.uniform2iv(this.addr,t),de(e,t)}}function Pp(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(ue(e,t))return;i.uniform3iv(this.addr,t),de(e,t)}}function Ip(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(ue(e,t))return;i.uniform4iv(this.addr,t),de(e,t)}}function Lp(i,t){let e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function Dp(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(ue(e,t))return;i.uniform2uiv(this.addr,t),de(e,t)}}function Up(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(ue(e,t))return;i.uniform3uiv(this.addr,t),de(e,t)}}function Np(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(ue(e,t))return;i.uniform4uiv(this.addr,t),de(e,t)}}function Fp(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?(Bc.compareFunction=Uo,r=Bc):r=nh,e.setTexture2D(t||r,s)}function Op(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture3D(t||sh,s)}function Bp(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTextureCube(t||rh,s)}function zp(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture2DArray(t||ih,s)}function kp(i){switch(i){case 5126:return Mp;case 35664:return bp;case 35665:return Sp;case 35666:return Ep;case 35674:return Tp;case 35675:return wp;case 35676:return Ap;case 5124:case 35670:return Rp;case 35667:case 35671:return Cp;case 35668:case 35672:return Pp;case 35669:case 35673:return Ip;case 5125:return Lp;case 36294:return Dp;case 36295:return Up;case 36296:return Np;case 35678:case 36198:case 36298:case 36306:case 35682:return Fp;case 35679:case 36299:case 36307:return Op;case 35680:case 36300:case 36308:case 36293:return Bp;case 36289:case 36303:case 36311:case 36292:return zp}}function Hp(i,t){i.uniform1fv(this.addr,t)}function Vp(i,t){let e=Vi(t,this.size,2);i.uniform2fv(this.addr,e)}function Gp(i,t){let e=Vi(t,this.size,3);i.uniform3fv(this.addr,e)}function Wp(i,t){let e=Vi(t,this.size,4);i.uniform4fv(this.addr,e)}function Xp(i,t){let e=Vi(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function qp(i,t){let e=Vi(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function Yp(i,t){let e=Vi(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function Zp(i,t){i.uniform1iv(this.addr,t)}function $p(i,t){i.uniform2iv(this.addr,t)}function Jp(i,t){i.uniform3iv(this.addr,t)}function Kp(i,t){i.uniform4iv(this.addr,t)}function jp(i,t){i.uniform1uiv(this.addr,t)}function Qp(i,t){i.uniform2uiv(this.addr,t)}function tm(i,t){i.uniform3uiv(this.addr,t)}function em(i,t){i.uniform4uiv(this.addr,t)}function nm(i,t,e){let n=this.cache,s=t.length,r=Ca(e,s);ue(n,r)||(i.uniform1iv(this.addr,r),de(n,r));for(let a=0;a!==s;++a)e.setTexture2D(t[a]||nh,r[a])}function im(i,t,e){let n=this.cache,s=t.length,r=Ca(e,s);ue(n,r)||(i.uniform1iv(this.addr,r),de(n,r));for(let a=0;a!==s;++a)e.setTexture3D(t[a]||sh,r[a])}function sm(i,t,e){let n=this.cache,s=t.length,r=Ca(e,s);ue(n,r)||(i.uniform1iv(this.addr,r),de(n,r));for(let a=0;a!==s;++a)e.setTextureCube(t[a]||rh,r[a])}function rm(i,t,e){let n=this.cache,s=t.length,r=Ca(e,s);ue(n,r)||(i.uniform1iv(this.addr,r),de(n,r));for(let a=0;a!==s;++a)e.setTexture2DArray(t[a]||ih,r[a])}function am(i){switch(i){case 5126:return Hp;case 35664:return Vp;case 35665:return Gp;case 35666:return Wp;case 35674:return Xp;case 35675:return qp;case 35676:return Yp;case 5124:case 35670:return Zp;case 35667:case 35671:return $p;case 35668:case 35672:return Jp;case 35669:case 35673:return Kp;case 5125:return jp;case 36294:return Qp;case 36295:return tm;case 36296:return em;case 35678:case 36198:case 36298:case 36306:case 35682:return nm;case 35679:case 36299:case 36307:return im;case 35680:case 36300:case 36308:case 36293:return sm;case 36289:case 36303:case 36311:case 36292:return rm}}var $o=class{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=kp(e.type)}},Jo=class{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=am(e.type)}},Ko=class{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){let s=this.seq;for(let r=0,a=s.length;r!==a;++r){let o=s[r];o.setValue(t,e[o.id],n)}}},Zo=/(\w+)(\])?(\[|\.)?/g;function Wc(i,t){i.seq.push(t),i.map[t.id]=t}function om(i,t,e){let n=i.name,s=n.length;for(Zo.lastIndex=0;;){let r=Zo.exec(n),a=Zo.lastIndex,o=r[1],c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===s){Wc(e,l===void 0?new $o(o,i,t):new Jo(o,i,t));break}else{let f=e.map[o];f===void 0&&(f=new Ko(o),Wc(e,f)),e=f}}}var Hi=class{constructor(t,e){this.seq=[],this.map={};let n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let r=t.getActiveUniform(e,s),a=t.getUniformLocation(e,r.name);om(r,a,this)}}setValue(t,e,n,s){let r=this.map[e];r!==void 0&&r.setValue(t,n,s)}setOptional(t,e,n){let s=e[n];s!==void 0&&this.setValue(t,n,s)}static upload(t,e,n,s){for(let r=0,a=e.length;r!==a;++r){let o=e[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(t,c.value,s)}}static seqWithValue(t,e){let n=[];for(let s=0,r=t.length;s!==r;++s){let a=t[s];a.id in e&&n.push(a)}return n}};function Xc(i,t,e){let n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}var lm=37297,cm=0;function hm(i,t){let e=i.split(`
3730
- `),n=[],s=Math.max(t-6,0),r=Math.min(t+6,e.length);for(let a=s;a<r;a++){let o=a+1;n.push(`${o===t?">":" "} ${o}: ${e[a]}`)}return n.join(`
3731
- `)}var qc=new Lt;function um(i){Vt._getMatrix(qc,Vt.workingColorSpace,i);let t=`mat3( ${qc.elements.map(e=>e.toFixed(4))} )`;switch(Vt.getTransfer(i)){case rs:return[t,"LinearTransferOETF"];case qt:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[t,"LinearTransferOETF"]}}function Yc(i,t,e){let n=i.getShaderParameter(t,i.COMPILE_STATUS),r=(i.getShaderInfoLog(t)||"").trim();if(n&&r==="")return"";let a=/ERROR: 0:(\d+)/.exec(r);if(a){let o=parseInt(a[1]);return e.toUpperCase()+`
3732
-
3733
- `+r+`
3734
-
3735
- `+hm(i.getShaderSource(t),o)}else return r}function dm(i,t){let e=um(t);return[`vec4 ${i}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(`
3736
- `)}function fm(i,t){let e;switch(t){case lc:e="Linear";break;case cc:e="Reinhard";break;case hc:e="Cineon";break;case uc:e="ACESFilmic";break;case fc:e="AgX";break;case pc:e="Neutral";break;case dc:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}var wa=new N;function pm(){Vt.getLuminanceCoefficients(wa);let i=wa.x.toFixed(4),t=wa.y.toFixed(4),e=wa.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(`
3737
- `)}function mm(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Is).join(`
3738
- `)}function gm(i){let t=[];for(let e in i){let n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
3739
- `)}function _m(i,t){let e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){let r=i.getActiveAttrib(t,s),a=r.name,o=1;r.type===i.FLOAT_MAT2&&(o=2),r.type===i.FLOAT_MAT3&&(o=3),r.type===i.FLOAT_MAT4&&(o=4),e[a]={type:r.type,location:i.getAttribLocation(t,a),locationSize:o}}return e}function Is(i){return i!==""}function Zc(i,t){let e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,e).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function $c(i,t){return i.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var xm=/^[ \t]*#include +<([\w\d./]+)>/gm;function jo(i){return i.replace(xm,vm)}var ym=new Map;function vm(i,t){let e=Ft[t];if(e===void 0){let n=ym.get(t);if(n!==void 0)e=Ft[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return jo(e)}var Mm=/#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 Jc(i){return i.replace(Mm,bm)}function bm(i,t,e,n){let s="";for(let r=parseInt(t);r<parseInt(e);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function Kc(i){let t=`precision ${i.precision} float;
3740
- precision ${i.precision} int;
3741
- precision ${i.precision} sampler2D;
3742
- precision ${i.precision} samplerCube;
3743
- precision ${i.precision} sampler3D;
3744
- precision ${i.precision} sampler2DArray;
3745
- precision ${i.precision} sampler2DShadow;
3746
- precision ${i.precision} samplerCubeShadow;
3747
- precision ${i.precision} sampler2DArrayShadow;
3748
- precision ${i.precision} isampler2D;
3749
- precision ${i.precision} isampler3D;
3750
- precision ${i.precision} isamplerCube;
3751
- precision ${i.precision} isampler2DArray;
3752
- precision ${i.precision} usampler2D;
3753
- precision ${i.precision} usampler3D;
3754
- precision ${i.precision} usamplerCube;
3755
- precision ${i.precision} usampler2DArray;
3756
- `;return i.precision==="highp"?t+=`
3757
- #define HIGH_PRECISION`:i.precision==="mediump"?t+=`
3758
- #define MEDIUM_PRECISION`:i.precision==="lowp"&&(t+=`
3759
- #define LOW_PRECISION`),t}function Sm(i){let t="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===Mo?t="SHADOWMAP_TYPE_PCF":i.shadowMapType===Hl?t="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===rn&&(t="SHADOWMAP_TYPE_VSM"),t}function Em(i){let t="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case jn:case Qn:t="ENVMAP_TYPE_CUBE";break;case Ts:t="ENVMAP_TYPE_CUBE_UV";break}return t}function Tm(i){let t="ENVMAP_MODE_REFLECTION";return i.envMap&&i.envMapMode===Qn&&(t="ENVMAP_MODE_REFRACTION"),t}function wm(i){let t="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case Eo:t="ENVMAP_BLENDING_MULTIPLY";break;case ac:t="ENVMAP_BLENDING_MIX";break;case oc:t="ENVMAP_BLENDING_ADD";break}return t}function Am(i){let t=i.envMapCubeUVHeight;if(t===null)return null;let e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:n,maxMip:e}}function Rm(i,t,e,n){let s=i.getContext(),r=e.defines,a=e.vertexShader,o=e.fragmentShader,c=Sm(e),l=Em(e),h=Tm(e),f=wm(e),u=Am(e),p=mm(e),g=gm(r),_=s.createProgram(),m,d,T=e.glslVersion?"#version "+e.glslVersion+`
3760
- `:"";e.isRawShaderMaterial?(m=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Is).join(`
3737
+ `}function i_(n){let e=new WeakMap,t=null;function i(o){if(o&&o.isTexture){let l=o.mapping,c=l===ll||l===cl,h=l===cr||l===hr;if(c||h){let u=e.get(o),d=u!==void 0?u.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return t===null&&(t=new Yl(n)),u=c?t.fromEquirectangular(o,u):t.fromCubemap(o,u),u.texture.pmremVersion=o.pmremVersion,e.set(o,u),u.texture;if(u!==void 0)return u.texture;{let f=o.image;return c&&f&&f.height>0||h&&f&&r(f)?(t===null&&(t=new Yl(n)),u=c?t.fromEquirectangular(o):t.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,e.set(o,u),o.addEventListener("dispose",s),u.texture):null}}}return o}function r(o){let l=0,c=6;for(let h=0;h<c;h++)o[h]!==void 0&&l++;return l===c}function s(o){let l=o.target;l.removeEventListener("dispose",s);let c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:a}}function r_(n){let e={};function t(i){if(e[i]!==void 0)return e[i];let r;switch(i){case"WEBGL_depth_texture":r=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=n.getExtension(i)}return e[i]=r,r}return{has:function(i){return t(i)!==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(i){let r=t(i);return r===null&&Zr("THREE.WebGLRenderer: "+i+" extension not supported."),r}}}function s_(n,e,t,i){let r={},s=new WeakMap;function a(u){let d=u.target;d.index!==null&&e.remove(d.index);for(let g in d.attributes)e.remove(d.attributes[g]);d.removeEventListener("dispose",a),delete r[d.id];let f=s.get(d);f&&(e.remove(f),s.delete(d)),i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(u,d){return r[d.id]===!0||(d.addEventListener("dispose",a),r[d.id]=!0,t.memory.geometries++),d}function l(u){let d=u.attributes;for(let f in d)e.update(d[f],n.ARRAY_BUFFER)}function c(u){let d=[],f=u.index,g=u.attributes.position,y=0;if(f!==null){let M=f.array;y=f.version;for(let S=0,x=M.length;S<x;S+=3){let A=M[S+0],T=M[S+1],R=M[S+2];d.push(A,T,T,R,R,A)}}else if(g!==void 0){let M=g.array;y=g.version;for(let S=0,x=M.length/3-1;S<x;S+=3){let A=S+0,T=S+1,R=S+2;d.push(A,T,T,R,R,A)}}else return;let m=new(Yh(d)?Qs:Ks)(d,1);m.version=y;let p=s.get(u);p&&e.remove(p),s.set(u,m)}function h(u){let d=s.get(u);if(d){let f=u.index;f!==null&&d.version<f.version&&c(u)}else c(u);return s.get(u)}return{get:o,update:l,getWireframeAttribute:h}}function a_(n,e,t){let i;function r(d){i=d}let s,a;function o(d){s=d.type,a=d.bytesPerElement}function l(d,f){n.drawElements(i,f,s,d*a),t.update(f,i,1)}function c(d,f,g){g!==0&&(n.drawElementsInstanced(i,f,s,d*a,g),t.update(f,i,g))}function h(d,f,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,f,0,s,d,0,g);let m=0;for(let p=0;p<g;p++)m+=f[p];t.update(m,i,1)}function u(d,f,g,y){if(g===0)return;let m=e.get("WEBGL_multi_draw");if(m===null)for(let p=0;p<d.length;p++)c(d[p]/a,f[p],y[p]);else{m.multiDrawElementsInstancedWEBGL(i,f,0,s,d,0,y,0,g);let p=0;for(let M=0;M<g;M++)p+=f[M]*y[M];t.update(p,i,1)}}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=u}function o_(n){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,a,o){switch(t.calls++,a){case n.TRIANGLES:t.triangles+=o*(s/3);break;case n.LINES:t.lines+=o*(s/2);break;case n.LINE_STRIP:t.lines+=o*(s-1);break;case n.LINE_LOOP:t.lines+=o*s;break;case n.POINTS:t.points+=o*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function l_(n,e,t){let i=new WeakMap,r=new mt;function s(a,o,l){let c=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0,d=i.get(o);if(d===void 0||d.count!==u){let w=function(){R.dispose(),i.delete(o),o.removeEventListener("dispose",w)};d!==void 0&&d.texture.dispose();let f=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,y=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],p=o.morphAttributes.normal||[],M=o.morphAttributes.color||[],S=0;f===!0&&(S=1),g===!0&&(S=2),y===!0&&(S=3);let x=o.attributes.position.count*S,A=1;x>e.maxTextureSize&&(A=Math.ceil(x/e.maxTextureSize),x=e.maxTextureSize);let T=new Float32Array(x*A*4*u),R=new js(T,x,A,u);R.type=En,R.needsUpdate=!0;let k=S*4;for(let b=0;b<u;b++){let D=m[b],V=p[b],W=M[b],Y=x*A*4*b;for(let j=0;j<D.count;j++){let X=j*k;f===!0&&(r.fromBufferAttribute(D,j),T[Y+X+0]=r.x,T[Y+X+1]=r.y,T[Y+X+2]=r.z,T[Y+X+3]=0),g===!0&&(r.fromBufferAttribute(V,j),T[Y+X+4]=r.x,T[Y+X+5]=r.y,T[Y+X+6]=r.z,T[Y+X+7]=0),y===!0&&(r.fromBufferAttribute(W,j),T[Y+X+8]=r.x,T[Y+X+9]=r.y,T[Y+X+10]=r.z,T[Y+X+11]=W.itemSize===4?r.w:1)}}d={count:u,texture:R,size:new ke(x,A)},i.set(o,d),o.addEventListener("dispose",w)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(n,"morphTexture",a.morphTexture,t);else{let f=0;for(let y=0;y<c.length;y++)f+=c[y];let g=o.morphTargetsRelative?1:1-f;l.getUniforms().setValue(n,"morphTargetBaseInfluence",g),l.getUniforms().setValue(n,"morphTargetInfluences",c)}l.getUniforms().setValue(n,"morphTargetsTexture",d.texture,t),l.getUniforms().setValue(n,"morphTargetsTextureSize",d.size)}return{update:s}}function c_(n,e,t,i){let r=new WeakMap;function s(l){let c=i.render.frame,h=l.geometry,u=e.get(l,h);if(r.get(u)!==c&&(e.update(u),r.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),r.get(l)!==c&&(t.update(l.instanceMatrix,n.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,n.ARRAY_BUFFER),r.set(l,c))),l.isSkinnedMesh){let d=l.skeleton;r.get(d)!==c&&(d.update(),r.set(d,c))}return u}function a(){r=new WeakMap}function o(l){let c=l.target;c.removeEventListener("dispose",o),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:a}}var Dp=new Kt,mp=new sa(1,1),kp=new js,Np=new Uo,Op=new ta,gp=[],yp=[],vp=new Float32Array(16),xp=new Float32Array(9),_p=new Float32Array(4);function us(n,e,t){let i=n[0];if(i<=0||i>0)return n;let r=e*t,s=gp[r];if(s===void 0&&(s=new Float32Array(r),gp[r]=s),e!==0){i.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(s,o)}return s}function Rt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function Pt(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function Zl(n,e){let t=yp[e];t===void 0&&(t=new Int32Array(e),yp[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function h_(n,e){let t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function u_(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Rt(t,e))return;n.uniform2fv(this.addr,e),Pt(t,e)}}function d_(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.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)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Rt(t,e))return;n.uniform3fv(this.addr,e),Pt(t,e)}}function f_(n,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)&&(n.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(Rt(t,e))return;n.uniform4fv(this.addr,e),Pt(t,e)}}function p_(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Rt(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),Pt(t,e)}else{if(Rt(t,i))return;_p.set(i),n.uniformMatrix2fv(this.addr,!1,_p),Pt(t,i)}}function m_(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Rt(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),Pt(t,e)}else{if(Rt(t,i))return;xp.set(i),n.uniformMatrix3fv(this.addr,!1,xp),Pt(t,i)}}function g_(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Rt(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),Pt(t,e)}else{if(Rt(t,i))return;vp.set(i),n.uniformMatrix4fv(this.addr,!1,vp),Pt(t,i)}}function y_(n,e){let t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function v_(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Rt(t,e))return;n.uniform2iv(this.addr,e),Pt(t,e)}}function x_(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Rt(t,e))return;n.uniform3iv(this.addr,e),Pt(t,e)}}function __(n,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)&&(n.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(Rt(t,e))return;n.uniform4iv(this.addr,e),Pt(t,e)}}function b_(n,e){let t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function S_(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Rt(t,e))return;n.uniform2uiv(this.addr,e),Pt(t,e)}}function w_(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Rt(t,e))return;n.uniform3uiv(this.addr,e),Pt(t,e)}}function M_(n,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)&&(n.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(Rt(t,e))return;n.uniform4uiv(this.addr,e),Pt(t,e)}}function E_(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let s;this.type===n.SAMPLER_2D_SHADOW?(mp.compareFunction=$h,s=mp):s=Dp,t.setTexture2D(e||s,r)}function T_(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||Np,r)}function A_(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||Op,r)}function C_(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||kp,r)}function R_(n){switch(n){case 5126:return h_;case 35664:return u_;case 35665:return d_;case 35666:return f_;case 35674:return p_;case 35675:return m_;case 35676:return g_;case 5124:case 35670:return y_;case 35667:case 35671:return v_;case 35668:case 35672:return x_;case 35669:case 35673:return __;case 5125:return b_;case 36294:return S_;case 36295:return w_;case 36296:return M_;case 35678:case 36198:case 36298:case 36306:case 35682:return E_;case 35679:case 36299:case 36307:return T_;case 35680:case 36300:case 36308:case 36293:return A_;case 36289:case 36303:case 36311:case 36292:return C_}}function P_(n,e){n.uniform1fv(this.addr,e)}function I_(n,e){let t=us(e,this.size,2);n.uniform2fv(this.addr,t)}function L_(n,e){let t=us(e,this.size,3);n.uniform3fv(this.addr,t)}function D_(n,e){let t=us(e,this.size,4);n.uniform4fv(this.addr,t)}function k_(n,e){let t=us(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function N_(n,e){let t=us(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function O_(n,e){let t=us(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function U_(n,e){n.uniform1iv(this.addr,e)}function F_(n,e){n.uniform2iv(this.addr,e)}function B_(n,e){n.uniform3iv(this.addr,e)}function z_(n,e){n.uniform4iv(this.addr,e)}function V_(n,e){n.uniform1uiv(this.addr,e)}function H_(n,e){n.uniform2uiv(this.addr,e)}function G_(n,e){n.uniform3uiv(this.addr,e)}function W_(n,e){n.uniform4uiv(this.addr,e)}function $_(n,e,t){let i=this.cache,r=e.length,s=Zl(t,r);Rt(i,s)||(n.uniform1iv(this.addr,s),Pt(i,s));for(let a=0;a!==r;++a)t.setTexture2D(e[a]||Dp,s[a])}function X_(n,e,t){let i=this.cache,r=e.length,s=Zl(t,r);Rt(i,s)||(n.uniform1iv(this.addr,s),Pt(i,s));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||Np,s[a])}function q_(n,e,t){let i=this.cache,r=e.length,s=Zl(t,r);Rt(i,s)||(n.uniform1iv(this.addr,s),Pt(i,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||Op,s[a])}function Y_(n,e,t){let i=this.cache,r=e.length,s=Zl(t,r);Rt(i,s)||(n.uniform1iv(this.addr,s),Pt(i,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||kp,s[a])}function j_(n){switch(n){case 5126:return P_;case 35664:return I_;case 35665:return L_;case 35666:return D_;case 35674:return k_;case 35675:return N_;case 35676:return O_;case 5124:case 35670:return U_;case 35667:case 35671:return F_;case 35668:case 35672:return B_;case 35669:case 35673:return z_;case 5125:return V_;case 36294:return H_;case 36295:return G_;case 36296:return W_;case 35678:case 36198:case 36298:case 36306:case 35682:return $_;case 35679:case 36299:case 36307:return X_;case 35680:case 36300:case 36308:case 36293:return q_;case 36289:case 36303:case 36311:case 36292:return Y_}}var su=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=R_(t.type)}},au=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=j_(t.type)}},ou=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){let r=this.seq;for(let s=0,a=r.length;s!==a;++s){let o=r[s];o.setValue(e,t[o.id],i)}}},ru=/(\w+)(\])?(\[|\.)?/g;function bp(n,e){n.seq.push(e),n.map[e.id]=e}function Z_(n,e,t){let i=n.name,r=i.length;for(ru.lastIndex=0;;){let s=ru.exec(i),a=ru.lastIndex,o=s[1],l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===r){bp(t,c===void 0?new su(o,n,e):new au(o,n,e));break}else{let u=t.map[o];u===void 0&&(u=new ou(o),bp(t,u)),t=u}}}var hs=class{constructor(e,t){this.seq=[],this.map={};let i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){let s=e.getActiveUniform(t,r),a=e.getUniformLocation(t,s.name);Z_(s,a,this)}}setValue(e,t,i,r){let s=this.map[t];s!==void 0&&s.setValue(e,i,r)}setOptional(e,t,i){let r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let s=0,a=t.length;s!==a;++s){let o=t[s],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,r)}}static seqWithValue(e,t){let i=[];for(let r=0,s=e.length;r!==s;++r){let a=e[r];a.id in t&&i.push(a)}return i}};function Sp(n,e,t){let i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}var J_=37297,K_=0;function Q_(n,e){let t=n.split(`
3738
+ `),i=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=r;a<s;a++){let o=a+1;i.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return i.join(`
3739
+ `)}var wp=new ze;function eb(n){Ke._getMatrix(wp,Ke.workingColorSpace,n);let e=`mat3( ${wp.elements.map(t=>t.toFixed(4))} )`;switch(Ke.getTransfer(n)){case Xs:return[e,"LinearTransferOETF"];case at:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function Mp(n,e,t){let i=n.getShaderParameter(e,n.COMPILE_STATUS),s=(n.getShaderInfoLog(e)||"").trim();if(i&&s==="")return"";let a=/ERROR: 0:(\d+)/.exec(s);if(a){let o=parseInt(a[1]);return t.toUpperCase()+`
3740
+
3741
+ `+s+`
3742
+
3743
+ `+Q_(n.getShaderSource(e),o)}else return s}function tb(n,e){let t=eb(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
3744
+ `)}function nb(n,e){let t;switch(e){case Bf:t="Linear";break;case zf:t="Reinhard";break;case Vf:t="Cineon";break;case Hf:t="ACESFilmic";break;case Wf:t="AgX";break;case $f:t="Neutral";break;case Gf:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var ql=new N;function ib(){Ke.getLuminanceCoefficients(ql);let n=ql.x.toFixed(4),e=ql.y.toFixed(4),t=ql.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
3745
+ `)}function rb(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(va).join(`
3746
+ `)}function sb(n){let e=[];for(let t in n){let i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
3747
+ `)}function ab(n,e){let t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=n.getActiveAttrib(e,r),a=s.name,o=1;s.type===n.FLOAT_MAT2&&(o=2),s.type===n.FLOAT_MAT3&&(o=3),s.type===n.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:n.getAttribLocation(e,a),locationSize:o}}return t}function va(n){return n!==""}function Ep(n,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.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 Tp(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var ob=/^[ \t]*#include +<([\w\d./]+)>/gm;function lu(n){return n.replace(ob,cb)}var lb=new Map;function cb(n,e){let t=We[e];if(t===void 0){let i=lb.get(e);if(i!==void 0)t=We[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return lu(t)}var hb=/#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 Ap(n){return n.replace(hb,ub)}function ub(n,e,t,i){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Cp(n){let e=`precision ${n.precision} float;
3748
+ precision ${n.precision} int;
3749
+ precision ${n.precision} sampler2D;
3750
+ precision ${n.precision} samplerCube;
3751
+ precision ${n.precision} sampler3D;
3752
+ precision ${n.precision} sampler2DArray;
3753
+ precision ${n.precision} sampler2DShadow;
3754
+ precision ${n.precision} samplerCubeShadow;
3755
+ precision ${n.precision} sampler2DArrayShadow;
3756
+ precision ${n.precision} isampler2D;
3757
+ precision ${n.precision} isampler3D;
3758
+ precision ${n.precision} isamplerCube;
3759
+ precision ${n.precision} isampler2DArray;
3760
+ precision ${n.precision} usampler2D;
3761
+ precision ${n.precision} usampler3D;
3762
+ precision ${n.precision} usamplerCube;
3763
+ precision ${n.precision} usampler2DArray;
3764
+ `;return n.precision==="highp"?e+=`
3765
+ #define HIGH_PRECISION`:n.precision==="mediump"?e+=`
3766
+ #define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=`
3767
+ #define LOW_PRECISION`),e}function db(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===Ih?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===vf?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===qn&&(e="SHADOWMAP_TYPE_VSM"),e}function fb(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case cr:case hr:e="ENVMAP_TYPE_CUBE";break;case ua:e="ENVMAP_TYPE_CUBE_UV";break}return e}function pb(n){let e="ENVMAP_MODE_REFLECTION";return n.envMap&&n.envMapMode===hr&&(e="ENVMAP_MODE_REFRACTION"),e}function mb(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case Nh:e="ENVMAP_BLENDING_MULTIPLY";break;case Uf:e="ENVMAP_BLENDING_MIX";break;case Ff:e="ENVMAP_BLENDING_ADD";break}return e}function gb(n){let e=n.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function yb(n,e,t,i){let r=n.getContext(),s=t.defines,a=t.vertexShader,o=t.fragmentShader,l=db(t),c=fb(t),h=pb(t),u=mb(t),d=gb(t),f=rb(t),g=sb(s),y=r.createProgram(),m,p,M=t.glslVersion?"#version "+t.glslVersion+`
3768
+ `:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(va).join(`
3761
3769
  `),m.length>0&&(m+=`
3762
- `),d=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Is).join(`
3763
- `),d.length>0&&(d+=`
3764
- `)):(m=[Kc(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.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",`
3765
- `].filter(Is).join(`
3766
- `),d=[Kc(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+l:"",e.envMap?"#define "+h:"",e.envMap?"#define "+f:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor||e.batchingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==Mn?"#define TONE_MAPPING":"",e.toneMapping!==Mn?Ft.tonemapping_pars_fragment:"",e.toneMapping!==Mn?fm("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Ft.colorspace_pars_fragment,dm("linearToOutputTexel",e.outputColorSpace),pm(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
3767
- `].filter(Is).join(`
3768
- `)),a=jo(a),a=Zc(a,e),a=$c(a,e),o=jo(o),o=Zc(o,e),o=$c(o,e),a=Jc(a),o=Jc(o),e.isRawShaderMaterial!==!0&&(T=`#version 300 es
3769
- `,m=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3770
+ `),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(va).join(`
3771
+ `),p.length>0&&(p+=`
3772
+ `)):(m=[Cp(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.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",`
3773
+ `].filter(va).join(`
3774
+ `),p=[Cp(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 "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.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.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||t.batchingColor?"#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.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.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!==ui?"#define TONE_MAPPING":"",t.toneMapping!==ui?We.tonemapping_pars_fragment:"",t.toneMapping!==ui?nb("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",We.colorspace_pars_fragment,tb("linearToOutputTexel",t.outputColorSpace),ib(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
3775
+ `].filter(va).join(`
3776
+ `)),a=lu(a),a=Ep(a,t),a=Tp(a,t),o=lu(o),o=Ep(o,t),o=Tp(o,t),a=Ap(a),o=Ap(o),t.isRawShaderMaterial!==!0&&(M=`#version 300 es
3777
+ `,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3770
3778
  `)+`
3771
- `+m,d=["#define varying in",e.glslVersion===No?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===No?"":"#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(`
3779
+ `+m,p=["#define varying in",t.glslVersion===ya?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===ya?"":"#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(`
3772
3780
  `)+`
3773
- `+d);let M=T+m+a,v=T+d+o,R=Xc(s,s.VERTEX_SHADER,M),w=Xc(s,s.FRAGMENT_SHADER,v);s.attachShader(_,R),s.attachShader(_,w),e.index0AttributeName!==void 0?s.bindAttribLocation(_,0,e.index0AttributeName):e.morphTargets===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function C(P){if(i.debug.checkShaderErrors){let B=s.getProgramInfoLog(_)||"",V=s.getShaderInfoLog(R)||"",X=s.getShaderInfoLog(w)||"",Z=B.trim(),W=V.trim(),et=X.trim(),k=!0,rt=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(k=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,_,R,w);else{let ct=Yc(s,R,"vertex"),bt=Yc(s,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+`
3781
+ `+p);let S=M+m+a,x=M+p+o,A=Sp(r,r.VERTEX_SHADER,S),T=Sp(r,r.FRAGMENT_SHADER,x);r.attachShader(y,A),r.attachShader(y,T),t.index0AttributeName!==void 0?r.bindAttribLocation(y,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(y,0,"position"),r.linkProgram(y);function R(D){if(n.debug.checkShaderErrors){let V=r.getProgramInfoLog(y)||"",W=r.getShaderInfoLog(A)||"",Y=r.getShaderInfoLog(T)||"",j=V.trim(),X=W.trim(),re=Y.trim(),H=!0,oe=!0;if(r.getProgramParameter(y,r.LINK_STATUS)===!1)if(H=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,y,A,T);else{let ee=Mp(r,A,"vertex"),Me=Mp(r,T,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(y,r.VALIDATE_STATUS)+`
3774
3782
 
3775
- Material Name: `+P.name+`
3776
- Material Type: `+P.type+`
3783
+ Material Name: `+D.name+`
3784
+ Material Type: `+D.type+`
3777
3785
 
3778
- Program Info Log: `+Z+`
3779
- `+ct+`
3780
- `+bt)}else Z!==""?console.warn("THREE.WebGLProgram: Program Info Log:",Z):(W===""||et==="")&&(rt=!1);rt&&(P.diagnostics={runnable:k,programLog:Z,vertexShader:{log:W,prefix:m},fragmentShader:{log:et,prefix:d}})}s.deleteShader(R),s.deleteShader(w),U=new Hi(s,_),S=_m(s,_)}let U;this.getUniforms=function(){return U===void 0&&C(this),U};let S;this.getAttributes=function(){return S===void 0&&C(this),S};let b=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return b===!1&&(b=s.getProgramParameter(_,lm)),b},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=cm++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=R,this.fragmentShader=w,this}var Cm=0,Qo=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){let e=t.vertexShader,n=t.fragmentShader,s=this._getShaderStage(e),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return a.has(s)===!1&&(a.add(s),s.usedTimes++),a.has(r)===!1&&(a.add(r),r.usedTimes++),this}remove(t){let e=this.materialCache.get(t);for(let n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let e=this.materialCache,n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){let e=this.shaderCache,n=e.get(t);return n===void 0&&(n=new tl(t),e.set(t,n)),n}},tl=class{constructor(t){this.id=Cm++,this.code=t,this.usedTimes=0}};function Pm(i,t,e,n,s,r,a){let o=new cs,c=new Qo,l=new Set,h=[],f=s.logarithmicDepthBuffer,u=s.vertexTextures,p=s.precision,g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function _(S){return l.add(S),S===0?"uv":`uv${S}`}function m(S,b,P,B,V){let X=B.fog,Z=V.geometry,W=S.isMeshStandardMaterial?B.environment:null,et=(S.isMeshStandardMaterial?e:t).get(S.envMap||W),k=et&&et.mapping===Ts?et.image.height:null,rt=g[S.type];S.precision!==null&&(p=s.getMaxPrecision(S.precision),p!==S.precision&&console.warn("THREE.WebGLProgram.getParameters:",S.precision,"not supported, using",p,"instead."));let ct=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,bt=ct!==void 0?ct.length:0,Bt=0;Z.morphAttributes.position!==void 0&&(Bt=1),Z.morphAttributes.normal!==void 0&&(Bt=2),Z.morphAttributes.color!==void 0&&(Bt=3);let Jt,te,Wt,q;if(rt){let Xt=ln[rt];Jt=Xt.vertexShader,te=Xt.fragmentShader}else Jt=S.vertexShader,te=S.fragmentShader,c.update(S),Wt=c.getVertexShaderID(S),q=c.getFragmentShaderID(S);let J=i.getRenderTarget(),dt=i.state.buffers.depth.getReversed(),Ct=V.isInstancedMesh===!0,Mt=V.isBatchedMesh===!0,Ht=!!S.map,ge=!!S.matcap,A=!!et,ee=!!S.aoMap,It=!!S.lightMap,At=!!S.bumpMap,mt=!!S.normalMap,ne=!!S.displacementMap,gt=!!S.emissiveMap,Nt=!!S.metalnessMap,pe=!!S.roughnessMap,le=S.anisotropy>0,E=S.clearcoat>0,x=S.dispersion>0,F=S.iridescence>0,G=S.sheen>0,$=S.transmission>0,H=le&&!!S.anisotropyMap,vt=E&&!!S.clearcoatMap,nt=E&&!!S.clearcoatNormalMap,_t=E&&!!S.clearcoatRoughnessMap,xt=F&&!!S.iridescenceMap,Q=F&&!!S.iridescenceThicknessMap,lt=G&&!!S.sheenColorMap,wt=G&&!!S.sheenRoughnessMap,yt=!!S.specularMap,at=!!S.specularColorMap,Dt=!!S.specularIntensityMap,I=$&&!!S.transmissionMap,tt=$&&!!S.thicknessMap,it=!!S.gradientMap,ut=!!S.alphaMap,K=S.alphaTest>0,Y=!!S.alphaHash,pt=!!S.extensions,Pt=Mn;S.toneMapped&&(J===null||J.isXRRenderTarget===!0)&&(Pt=i.toneMapping);let Kt={shaderID:rt,shaderType:S.type,shaderName:S.name,vertexShader:Jt,fragmentShader:te,defines:S.defines,customVertexShaderID:Wt,customFragmentShaderID:q,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:p,batching:Mt,batchingColor:Mt&&V._colorsTexture!==null,instancing:Ct,instancingColor:Ct&&V.instanceColor!==null,instancingMorph:Ct&&V.morphTexture!==null,supportsVertexTextures:u,outputColorSpace:J===null?i.outputColorSpace:J.isXRRenderTarget===!0?J.texture.colorSpace:$n,alphaToCoverage:!!S.alphaToCoverage,map:Ht,matcap:ge,envMap:A,envMapMode:A&&et.mapping,envMapCubeUVHeight:k,aoMap:ee,lightMap:It,bumpMap:At,normalMap:mt,displacementMap:u&&ne,emissiveMap:gt,normalMapObjectSpace:mt&&S.normalMapType===yc,normalMapTangentSpace:mt&&S.normalMapType===xc,metalnessMap:Nt,roughnessMap:pe,anisotropy:le,anisotropyMap:H,clearcoat:E,clearcoatMap:vt,clearcoatNormalMap:nt,clearcoatRoughnessMap:_t,dispersion:x,iridescence:F,iridescenceMap:xt,iridescenceThicknessMap:Q,sheen:G,sheenColorMap:lt,sheenRoughnessMap:wt,specularMap:yt,specularColorMap:at,specularIntensityMap:Dt,transmission:$,transmissionMap:I,thicknessMap:tt,gradientMap:it,opaque:S.transparent===!1&&S.blending===xn&&S.alphaToCoverage===!1,alphaMap:ut,alphaTest:K,alphaHash:Y,combine:S.combine,mapUv:Ht&&_(S.map.channel),aoMapUv:ee&&_(S.aoMap.channel),lightMapUv:It&&_(S.lightMap.channel),bumpMapUv:At&&_(S.bumpMap.channel),normalMapUv:mt&&_(S.normalMap.channel),displacementMapUv:ne&&_(S.displacementMap.channel),emissiveMapUv:gt&&_(S.emissiveMap.channel),metalnessMapUv:Nt&&_(S.metalnessMap.channel),roughnessMapUv:pe&&_(S.roughnessMap.channel),anisotropyMapUv:H&&_(S.anisotropyMap.channel),clearcoatMapUv:vt&&_(S.clearcoatMap.channel),clearcoatNormalMapUv:nt&&_(S.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:_t&&_(S.clearcoatRoughnessMap.channel),iridescenceMapUv:xt&&_(S.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&_(S.iridescenceThicknessMap.channel),sheenColorMapUv:lt&&_(S.sheenColorMap.channel),sheenRoughnessMapUv:wt&&_(S.sheenRoughnessMap.channel),specularMapUv:yt&&_(S.specularMap.channel),specularColorMapUv:at&&_(S.specularColorMap.channel),specularIntensityMapUv:Dt&&_(S.specularIntensityMap.channel),transmissionMapUv:I&&_(S.transmissionMap.channel),thicknessMapUv:tt&&_(S.thicknessMap.channel),alphaMapUv:ut&&_(S.alphaMap.channel),vertexTangents:!!Z.attributes.tangent&&(mt||le),vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,pointsUvs:V.isPoints===!0&&!!Z.attributes.uv&&(Ht||ut),fog:!!X,useFog:S.fog===!0,fogExp2:!!X&&X.isFogExp2,flatShading:S.flatShading===!0&&S.wireframe===!1,sizeAttenuation:S.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:dt,skinning:V.isSkinnedMesh===!0,morphTargets:Z.morphAttributes.position!==void 0,morphNormals:Z.morphAttributes.normal!==void 0,morphColors:Z.morphAttributes.color!==void 0,morphTargetsCount:bt,morphTextureStride:Bt,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:S.dithering,shadowMapEnabled:i.shadowMap.enabled&&P.length>0,shadowMapType:i.shadowMap.type,toneMapping:Pt,decodeVideoTexture:Ht&&S.map.isVideoTexture===!0&&Vt.getTransfer(S.map.colorSpace)===qt,decodeVideoTextureEmissive:gt&&S.emissiveMap.isVideoTexture===!0&&Vt.getTransfer(S.emissiveMap.colorSpace)===qt,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===Xe,flipSided:S.side===Ee,useDepthPacking:S.depthPacking>=0,depthPacking:S.depthPacking||0,index0AttributeName:S.index0AttributeName,extensionClipCullDistance:pt&&S.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(pt&&S.extensions.multiDraw===!0||Mt)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:S.customProgramCacheKey()};return Kt.vertexUv1s=l.has(1),Kt.vertexUv2s=l.has(2),Kt.vertexUv3s=l.has(3),l.clear(),Kt}function d(S){let b=[];if(S.shaderID?b.push(S.shaderID):(b.push(S.customVertexShaderID),b.push(S.customFragmentShaderID)),S.defines!==void 0)for(let P in S.defines)b.push(P),b.push(S.defines[P]);return S.isRawShaderMaterial===!1&&(T(b,S),M(b,S),b.push(i.outputColorSpace)),b.push(S.customProgramCacheKey),b.join()}function T(S,b){S.push(b.precision),S.push(b.outputColorSpace),S.push(b.envMapMode),S.push(b.envMapCubeUVHeight),S.push(b.mapUv),S.push(b.alphaMapUv),S.push(b.lightMapUv),S.push(b.aoMapUv),S.push(b.bumpMapUv),S.push(b.normalMapUv),S.push(b.displacementMapUv),S.push(b.emissiveMapUv),S.push(b.metalnessMapUv),S.push(b.roughnessMapUv),S.push(b.anisotropyMapUv),S.push(b.clearcoatMapUv),S.push(b.clearcoatNormalMapUv),S.push(b.clearcoatRoughnessMapUv),S.push(b.iridescenceMapUv),S.push(b.iridescenceThicknessMapUv),S.push(b.sheenColorMapUv),S.push(b.sheenRoughnessMapUv),S.push(b.specularMapUv),S.push(b.specularColorMapUv),S.push(b.specularIntensityMapUv),S.push(b.transmissionMapUv),S.push(b.thicknessMapUv),S.push(b.combine),S.push(b.fogExp2),S.push(b.sizeAttenuation),S.push(b.morphTargetsCount),S.push(b.morphAttributeCount),S.push(b.numDirLights),S.push(b.numPointLights),S.push(b.numSpotLights),S.push(b.numSpotLightMaps),S.push(b.numHemiLights),S.push(b.numRectAreaLights),S.push(b.numDirLightShadows),S.push(b.numPointLightShadows),S.push(b.numSpotLightShadows),S.push(b.numSpotLightShadowsWithMaps),S.push(b.numLightProbes),S.push(b.shadowMapType),S.push(b.toneMapping),S.push(b.numClippingPlanes),S.push(b.numClipIntersection),S.push(b.depthPacking)}function M(S,b){o.disableAll(),b.supportsVertexTextures&&o.enable(0),b.instancing&&o.enable(1),b.instancingColor&&o.enable(2),b.instancingMorph&&o.enable(3),b.matcap&&o.enable(4),b.envMap&&o.enable(5),b.normalMapObjectSpace&&o.enable(6),b.normalMapTangentSpace&&o.enable(7),b.clearcoat&&o.enable(8),b.iridescence&&o.enable(9),b.alphaTest&&o.enable(10),b.vertexColors&&o.enable(11),b.vertexAlphas&&o.enable(12),b.vertexUv1s&&o.enable(13),b.vertexUv2s&&o.enable(14),b.vertexUv3s&&o.enable(15),b.vertexTangents&&o.enable(16),b.anisotropy&&o.enable(17),b.alphaHash&&o.enable(18),b.batching&&o.enable(19),b.dispersion&&o.enable(20),b.batchingColor&&o.enable(21),b.gradientMap&&o.enable(22),S.push(o.mask),o.disableAll(),b.fog&&o.enable(0),b.useFog&&o.enable(1),b.flatShading&&o.enable(2),b.logarithmicDepthBuffer&&o.enable(3),b.reversedDepthBuffer&&o.enable(4),b.skinning&&o.enable(5),b.morphTargets&&o.enable(6),b.morphNormals&&o.enable(7),b.morphColors&&o.enable(8),b.premultipliedAlpha&&o.enable(9),b.shadowMapEnabled&&o.enable(10),b.doubleSided&&o.enable(11),b.flipSided&&o.enable(12),b.useDepthPacking&&o.enable(13),b.dithering&&o.enable(14),b.transmission&&o.enable(15),b.sheen&&o.enable(16),b.opaque&&o.enable(17),b.pointsUvs&&o.enable(18),b.decodeVideoTexture&&o.enable(19),b.decodeVideoTextureEmissive&&o.enable(20),b.alphaToCoverage&&o.enable(21),S.push(o.mask)}function v(S){let b=g[S.type],P;if(b){let B=ln[b];P=Pc.clone(B.uniforms)}else P=S.uniforms;return P}function R(S,b){let P;for(let B=0,V=h.length;B<V;B++){let X=h[B];if(X.cacheKey===b){P=X,++P.usedTimes;break}}return P===void 0&&(P=new Rm(i,b,S,r),h.push(P)),P}function w(S){if(--S.usedTimes===0){let b=h.indexOf(S);h[b]=h[h.length-1],h.pop(),S.destroy()}}function C(S){c.remove(S)}function U(){c.dispose()}return{getParameters:m,getProgramCacheKey:d,getUniforms:v,acquireProgram:R,releaseProgram:w,releaseShaderCache:C,programs:h,dispose:U}}function Im(){let i=new WeakMap;function t(a){return i.has(a)}function e(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,c){i.get(a)[o]=c}function r(){i=new WeakMap}return{has:t,get:e,remove:n,update:s,dispose:r}}function Lm(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.z!==t.z?i.z-t.z:i.id-t.id}function jc(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function Qc(){let i=[],t=0,e=[],n=[],s=[];function r(){t=0,e.length=0,n.length=0,s.length=0}function a(f,u,p,g,_,m){let d=i[t];return d===void 0?(d={id:f.id,object:f,geometry:u,material:p,groupOrder:g,renderOrder:f.renderOrder,z:_,group:m},i[t]=d):(d.id=f.id,d.object=f,d.geometry=u,d.material=p,d.groupOrder=g,d.renderOrder=f.renderOrder,d.z=_,d.group=m),t++,d}function o(f,u,p,g,_,m){let d=a(f,u,p,g,_,m);p.transmission>0?n.push(d):p.transparent===!0?s.push(d):e.push(d)}function c(f,u,p,g,_,m){let d=a(f,u,p,g,_,m);p.transmission>0?n.unshift(d):p.transparent===!0?s.unshift(d):e.unshift(d)}function l(f,u){e.length>1&&e.sort(f||Lm),n.length>1&&n.sort(u||jc),s.length>1&&s.sort(u||jc)}function h(){for(let f=t,u=i.length;f<u;f++){let p=i[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:e,transmissive:n,transparent:s,init:r,push:o,unshift:c,finish:h,sort:l}}function Dm(){let i=new WeakMap;function t(n,s){let r=i.get(n),a;return r===void 0?(a=new Qc,i.set(n,[a])):s>=r.length?(a=new Qc,r.push(a)):a=r[s],a}function e(){i=new WeakMap}return{get:t,dispose:e}}function Um(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new N,color:new zt};break;case"SpotLight":e={position:new N,direction:new N,color:new zt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new N,color:new zt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new N,skyColor:new zt,groundColor:new zt};break;case"RectAreaLight":e={color:new zt,position:new N,halfWidth:new N,halfHeight:new N};break}return i[t.id]=e,e}}}function Nm(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ut};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ut};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ut,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}var Fm=0;function Om(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function Bm(i){let t=new Um,e=Nm(),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 l=0;l<9;l++)n.probe.push(new N);let s=new N,r=new ce,a=new ce;function o(l){let h=0,f=0,u=0;for(let S=0;S<9;S++)n.probe[S].set(0,0,0);let p=0,g=0,_=0,m=0,d=0,T=0,M=0,v=0,R=0,w=0,C=0;l.sort(Om);for(let S=0,b=l.length;S<b;S++){let P=l[S],B=P.color,V=P.intensity,X=P.distance,Z=P.shadow&&P.shadow.map?P.shadow.map.texture:null;if(P.isAmbientLight)h+=B.r*V,f+=B.g*V,u+=B.b*V;else if(P.isLightProbe){for(let W=0;W<9;W++)n.probe[W].addScaledVector(P.sh.coefficients[W],V);C++}else if(P.isDirectionalLight){let W=t.get(P);if(W.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){let et=P.shadow,k=e.get(P);k.shadowIntensity=et.intensity,k.shadowBias=et.bias,k.shadowNormalBias=et.normalBias,k.shadowRadius=et.radius,k.shadowMapSize=et.mapSize,n.directionalShadow[p]=k,n.directionalShadowMap[p]=Z,n.directionalShadowMatrix[p]=P.shadow.matrix,T++}n.directional[p]=W,p++}else if(P.isSpotLight){let W=t.get(P);W.position.setFromMatrixPosition(P.matrixWorld),W.color.copy(B).multiplyScalar(V),W.distance=X,W.coneCos=Math.cos(P.angle),W.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),W.decay=P.decay,n.spot[_]=W;let et=P.shadow;if(P.map&&(n.spotLightMap[R]=P.map,R++,et.updateMatrices(P),P.castShadow&&w++),n.spotLightMatrix[_]=et.matrix,P.castShadow){let k=e.get(P);k.shadowIntensity=et.intensity,k.shadowBias=et.bias,k.shadowNormalBias=et.normalBias,k.shadowRadius=et.radius,k.shadowMapSize=et.mapSize,n.spotShadow[_]=k,n.spotShadowMap[_]=Z,v++}_++}else if(P.isRectAreaLight){let W=t.get(P);W.color.copy(B).multiplyScalar(V),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=t.get(P);if(W.color.copy(P.color).multiplyScalar(P.intensity),W.distance=P.distance,W.decay=P.decay,P.castShadow){let et=P.shadow,k=e.get(P);k.shadowIntensity=et.intensity,k.shadowBias=et.bias,k.shadowNormalBias=et.normalBias,k.shadowRadius=et.radius,k.shadowMapSize=et.mapSize,k.shadowCameraNear=et.camera.near,k.shadowCameraFar=et.camera.far,n.pointShadow[g]=k,n.pointShadowMap[g]=Z,n.pointShadowMatrix[g]=P.shadow.matrix,M++}n.point[g]=W,g++}else if(P.isHemisphereLight){let W=t.get(P);W.skyColor.copy(P.color).multiplyScalar(V),W.groundColor.copy(P.groundColor).multiplyScalar(V),n.hemi[d]=W,d++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=st.LTC_FLOAT_1,n.rectAreaLTC2=st.LTC_FLOAT_2):(n.rectAreaLTC1=st.LTC_HALF_1,n.rectAreaLTC2=st.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=f,n.ambient[2]=u;let U=n.hash;(U.directionalLength!==p||U.pointLength!==g||U.spotLength!==_||U.rectAreaLength!==m||U.hemiLength!==d||U.numDirectionalShadows!==T||U.numPointShadows!==M||U.numSpotShadows!==v||U.numSpotMaps!==R||U.numLightProbes!==C)&&(n.directional.length=p,n.spot.length=_,n.rectArea.length=m,n.point.length=g,n.hemi.length=d,n.directionalShadow.length=T,n.directionalShadowMap.length=T,n.pointShadow.length=M,n.pointShadowMap.length=M,n.spotShadow.length=v,n.spotShadowMap.length=v,n.directionalShadowMatrix.length=T,n.pointShadowMatrix.length=M,n.spotLightMatrix.length=v+R-w,n.spotLightMap.length=R,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=C,U.directionalLength=p,U.pointLength=g,U.spotLength=_,U.rectAreaLength=m,U.hemiLength=d,U.numDirectionalShadows=T,U.numPointShadows=M,U.numSpotShadows=v,U.numSpotMaps=R,U.numLightProbes=C,n.version=Fm++)}function c(l,h){let f=0,u=0,p=0,g=0,_=0,m=h.matrixWorldInverse;for(let d=0,T=l.length;d<T;d++){let M=l[d];if(M.isDirectionalLight){let v=n.directional[f];v.direction.setFromMatrixPosition(M.matrixWorld),s.setFromMatrixPosition(M.target.matrixWorld),v.direction.sub(s),v.direction.transformDirection(m),f++}else if(M.isSpotLight){let v=n.spot[p];v.position.setFromMatrixPosition(M.matrixWorld),v.position.applyMatrix4(m),v.direction.setFromMatrixPosition(M.matrixWorld),s.setFromMatrixPosition(M.target.matrixWorld),v.direction.sub(s),v.direction.transformDirection(m),p++}else if(M.isRectAreaLight){let v=n.rectArea[g];v.position.setFromMatrixPosition(M.matrixWorld),v.position.applyMatrix4(m),a.identity(),r.copy(M.matrixWorld),r.premultiply(m),a.extractRotation(r),v.halfWidth.set(M.width*.5,0,0),v.halfHeight.set(0,M.height*.5,0),v.halfWidth.applyMatrix4(a),v.halfHeight.applyMatrix4(a),g++}else if(M.isPointLight){let v=n.point[u];v.position.setFromMatrixPosition(M.matrixWorld),v.position.applyMatrix4(m),u++}else if(M.isHemisphereLight){let v=n.hemi[_];v.direction.setFromMatrixPosition(M.matrixWorld),v.direction.transformDirection(m),_++}}}return{setup:o,setupView:c,state:n}}function th(i){let t=new Bm(i),e=[],n=[];function s(h){l.camera=h,e.length=0,n.length=0}function r(h){e.push(h)}function a(h){n.push(h)}function o(){t.setup(e)}function c(h){t.setupView(e,h)}let l={lightsArray:e,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:s,state:l,setupLights:o,setupLightsView:c,pushLight:r,pushShadow:a}}function zm(i){let t=new WeakMap;function e(s,r=0){let a=t.get(s),o;return a===void 0?(o=new th(i),t.set(s,[o])):r>=a.length?(o=new th(i),a.push(o)):o=a[r],o}function n(){t=new WeakMap}return{get:e,dispose:n}}var km=`void main() {
3786
+ Program Info Log: `+j+`
3787
+ `+ee+`
3788
+ `+Me)}else j!==""?console.warn("THREE.WebGLProgram: Program Info Log:",j):(X===""||re==="")&&(oe=!1);oe&&(D.diagnostics={runnable:H,programLog:j,vertexShader:{log:X,prefix:m},fragmentShader:{log:re,prefix:p}})}r.deleteShader(A),r.deleteShader(T),k=new hs(r,y),w=ab(r,y)}let k;this.getUniforms=function(){return k===void 0&&R(this),k};let w;this.getAttributes=function(){return w===void 0&&R(this),w};let b=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return b===!1&&(b=r.getProgramParameter(y,J_)),b},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=K_++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=A,this.fragmentShader=T,this}var vb=0,cu=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){let t=this.shaderCache,i=t.get(e);return i===void 0&&(i=new hu(e),t.set(e,i)),i}},hu=class{constructor(e){this.id=vb++,this.code=e,this.usedTimes=0}};function xb(n,e,t,i,r,s,a){let o=new Zs,l=new cu,c=new Set,h=[],u=r.logarithmicDepthBuffer,d=r.vertexTextures,f=r.precision,g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(w){return c.add(w),w===0?"uv":`uv${w}`}function m(w,b,D,V,W){let Y=V.fog,j=W.geometry,X=w.isMeshStandardMaterial?V.environment:null,re=(w.isMeshStandardMaterial?t:e).get(w.envMap||X),H=re&&re.mapping===ua?re.image.height:null,oe=g[w.type];w.precision!==null&&(f=r.getMaxPrecision(w.precision),f!==w.precision&&console.warn("THREE.WebGLProgram.getParameters:",w.precision,"not supported, using",f,"instead."));let ee=j.morphAttributes.position||j.morphAttributes.normal||j.morphAttributes.color,Me=ee!==void 0?ee.length:0,$e=0;j.morphAttributes.position!==void 0&&($e=1),j.morphAttributes.normal!==void 0&&($e=2),j.morphAttributes.color!==void 0&&($e=3);let rt,Ue,qe,$;if(oe){let nt=jn[oe];rt=nt.vertexShader,Ue=nt.fragmentShader}else rt=w.vertexShader,Ue=w.fragmentShader,l.update(w),qe=l.getVertexShaderID(w),$=l.getFragmentShaderID(w);let J=n.getRenderTarget(),me=n.state.buffers.depth.getReversed(),ve=W.isInstancedMesh===!0,ue=W.isBatchedMesh===!0,Je=!!w.map,At=!!w.matcap,C=!!re,ht=!!w.aoMap,Be=!!w.lightMap,Ne=!!w.bumpMap,be=!!w.normalMap,gt=!!w.displacementMap,Se=!!w.emissiveMap,He=!!w.metalnessMap,Lt=!!w.roughnessMap,bt=w.anisotropy>0,E=w.clearcoat>0,v=w.dispersion>0,F=w.iridescence>0,q=w.sheen>0,K=w.transmission>0,G=bt&&!!w.anisotropyMap,Ae=E&&!!w.clearcoatMap,ae=E&&!!w.clearcoatNormalMap,we=E&&!!w.clearcoatRoughnessMap,Ee=F&&!!w.iridescenceMap,ne=F&&!!w.iridescenceThicknessMap,fe=q&&!!w.sheenColorMap,Le=q&&!!w.sheenRoughnessMap,Te=!!w.specularMap,he=!!w.specularColorMap,Ve=!!w.specularIntensityMap,L=K&&!!w.transmissionMap,ie=K&&!!w.thicknessMap,le=!!w.gradientMap,ye=!!w.alphaMap,Q=w.alphaTest>0,Z=!!w.alphaHash,_e=!!w.extensions,Fe=ui;w.toneMapped&&(J===null||J.isXRRenderTarget===!0)&&(Fe=n.toneMapping);let ut={shaderID:oe,shaderType:w.type,shaderName:w.name,vertexShader:rt,fragmentShader:Ue,defines:w.defines,customVertexShaderID:qe,customFragmentShaderID:$,isRawShaderMaterial:w.isRawShaderMaterial===!0,glslVersion:w.glslVersion,precision:f,batching:ue,batchingColor:ue&&W._colorsTexture!==null,instancing:ve,instancingColor:ve&&W.instanceColor!==null,instancingMorph:ve&&W.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:J===null?n.outputColorSpace:J.isXRRenderTarget===!0?J.texture.colorSpace:ci,alphaToCoverage:!!w.alphaToCoverage,map:Je,matcap:At,envMap:C,envMapMode:C&&re.mapping,envMapCubeUVHeight:H,aoMap:ht,lightMap:Be,bumpMap:Ne,normalMap:be,displacementMap:d&&gt,emissiveMap:Se,normalMapObjectSpace:be&&w.normalMapType===Zf,normalMapTangentSpace:be&&w.normalMapType===jf,metalnessMap:He,roughnessMap:Lt,anisotropy:bt,anisotropyMap:G,clearcoat:E,clearcoatMap:Ae,clearcoatNormalMap:ae,clearcoatRoughnessMap:we,dispersion:v,iridescence:F,iridescenceMap:Ee,iridescenceThicknessMap:ne,sheen:q,sheenColorMap:fe,sheenRoughnessMap:Le,specularMap:Te,specularColorMap:he,specularIntensityMap:Ve,transmission:K,transmissionMap:L,thicknessMap:ie,gradientMap:le,opaque:w.transparent===!1&&w.blending===tr&&w.alphaToCoverage===!1,alphaMap:ye,alphaTest:Q,alphaHash:Z,combine:w.combine,mapUv:Je&&y(w.map.channel),aoMapUv:ht&&y(w.aoMap.channel),lightMapUv:Be&&y(w.lightMap.channel),bumpMapUv:Ne&&y(w.bumpMap.channel),normalMapUv:be&&y(w.normalMap.channel),displacementMapUv:gt&&y(w.displacementMap.channel),emissiveMapUv:Se&&y(w.emissiveMap.channel),metalnessMapUv:He&&y(w.metalnessMap.channel),roughnessMapUv:Lt&&y(w.roughnessMap.channel),anisotropyMapUv:G&&y(w.anisotropyMap.channel),clearcoatMapUv:Ae&&y(w.clearcoatMap.channel),clearcoatNormalMapUv:ae&&y(w.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:we&&y(w.clearcoatRoughnessMap.channel),iridescenceMapUv:Ee&&y(w.iridescenceMap.channel),iridescenceThicknessMapUv:ne&&y(w.iridescenceThicknessMap.channel),sheenColorMapUv:fe&&y(w.sheenColorMap.channel),sheenRoughnessMapUv:Le&&y(w.sheenRoughnessMap.channel),specularMapUv:Te&&y(w.specularMap.channel),specularColorMapUv:he&&y(w.specularColorMap.channel),specularIntensityMapUv:Ve&&y(w.specularIntensityMap.channel),transmissionMapUv:L&&y(w.transmissionMap.channel),thicknessMapUv:ie&&y(w.thicknessMap.channel),alphaMapUv:ye&&y(w.alphaMap.channel),vertexTangents:!!j.attributes.tangent&&(be||bt),vertexColors:w.vertexColors,vertexAlphas:w.vertexColors===!0&&!!j.attributes.color&&j.attributes.color.itemSize===4,pointsUvs:W.isPoints===!0&&!!j.attributes.uv&&(Je||ye),fog:!!Y,useFog:w.fog===!0,fogExp2:!!Y&&Y.isFogExp2,flatShading:w.flatShading===!0&&w.wireframe===!1,sizeAttenuation:w.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:me,skinning:W.isSkinnedMesh===!0,morphTargets:j.morphAttributes.position!==void 0,morphNormals:j.morphAttributes.normal!==void 0,morphColors:j.morphAttributes.color!==void 0,morphTargetsCount:Me,morphTextureStride:$e,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:w.dithering,shadowMapEnabled:n.shadowMap.enabled&&D.length>0,shadowMapType:n.shadowMap.type,toneMapping:Fe,decodeVideoTexture:Je&&w.map.isVideoTexture===!0&&Ke.getTransfer(w.map.colorSpace)===at,decodeVideoTextureEmissive:Se&&w.emissiveMap.isVideoTexture===!0&&Ke.getTransfer(w.emissiveMap.colorSpace)===at,premultipliedAlpha:w.premultipliedAlpha,doubleSided:w.side===Mn,flipSided:w.side===Qt,useDepthPacking:w.depthPacking>=0,depthPacking:w.depthPacking||0,index0AttributeName:w.index0AttributeName,extensionClipCullDistance:_e&&w.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(_e&&w.extensions.multiDraw===!0||ue)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:w.customProgramCacheKey()};return ut.vertexUv1s=c.has(1),ut.vertexUv2s=c.has(2),ut.vertexUv3s=c.has(3),c.clear(),ut}function p(w){let b=[];if(w.shaderID?b.push(w.shaderID):(b.push(w.customVertexShaderID),b.push(w.customFragmentShaderID)),w.defines!==void 0)for(let D in w.defines)b.push(D),b.push(w.defines[D]);return w.isRawShaderMaterial===!1&&(M(b,w),S(b,w),b.push(n.outputColorSpace)),b.push(w.customProgramCacheKey),b.join()}function M(w,b){w.push(b.precision),w.push(b.outputColorSpace),w.push(b.envMapMode),w.push(b.envMapCubeUVHeight),w.push(b.mapUv),w.push(b.alphaMapUv),w.push(b.lightMapUv),w.push(b.aoMapUv),w.push(b.bumpMapUv),w.push(b.normalMapUv),w.push(b.displacementMapUv),w.push(b.emissiveMapUv),w.push(b.metalnessMapUv),w.push(b.roughnessMapUv),w.push(b.anisotropyMapUv),w.push(b.clearcoatMapUv),w.push(b.clearcoatNormalMapUv),w.push(b.clearcoatRoughnessMapUv),w.push(b.iridescenceMapUv),w.push(b.iridescenceThicknessMapUv),w.push(b.sheenColorMapUv),w.push(b.sheenRoughnessMapUv),w.push(b.specularMapUv),w.push(b.specularColorMapUv),w.push(b.specularIntensityMapUv),w.push(b.transmissionMapUv),w.push(b.thicknessMapUv),w.push(b.combine),w.push(b.fogExp2),w.push(b.sizeAttenuation),w.push(b.morphTargetsCount),w.push(b.morphAttributeCount),w.push(b.numDirLights),w.push(b.numPointLights),w.push(b.numSpotLights),w.push(b.numSpotLightMaps),w.push(b.numHemiLights),w.push(b.numRectAreaLights),w.push(b.numDirLightShadows),w.push(b.numPointLightShadows),w.push(b.numSpotLightShadows),w.push(b.numSpotLightShadowsWithMaps),w.push(b.numLightProbes),w.push(b.shadowMapType),w.push(b.toneMapping),w.push(b.numClippingPlanes),w.push(b.numClipIntersection),w.push(b.depthPacking)}function S(w,b){o.disableAll(),b.supportsVertexTextures&&o.enable(0),b.instancing&&o.enable(1),b.instancingColor&&o.enable(2),b.instancingMorph&&o.enable(3),b.matcap&&o.enable(4),b.envMap&&o.enable(5),b.normalMapObjectSpace&&o.enable(6),b.normalMapTangentSpace&&o.enable(7),b.clearcoat&&o.enable(8),b.iridescence&&o.enable(9),b.alphaTest&&o.enable(10),b.vertexColors&&o.enable(11),b.vertexAlphas&&o.enable(12),b.vertexUv1s&&o.enable(13),b.vertexUv2s&&o.enable(14),b.vertexUv3s&&o.enable(15),b.vertexTangents&&o.enable(16),b.anisotropy&&o.enable(17),b.alphaHash&&o.enable(18),b.batching&&o.enable(19),b.dispersion&&o.enable(20),b.batchingColor&&o.enable(21),b.gradientMap&&o.enable(22),w.push(o.mask),o.disableAll(),b.fog&&o.enable(0),b.useFog&&o.enable(1),b.flatShading&&o.enable(2),b.logarithmicDepthBuffer&&o.enable(3),b.reversedDepthBuffer&&o.enable(4),b.skinning&&o.enable(5),b.morphTargets&&o.enable(6),b.morphNormals&&o.enable(7),b.morphColors&&o.enable(8),b.premultipliedAlpha&&o.enable(9),b.shadowMapEnabled&&o.enable(10),b.doubleSided&&o.enable(11),b.flipSided&&o.enable(12),b.useDepthPacking&&o.enable(13),b.dithering&&o.enable(14),b.transmission&&o.enable(15),b.sheen&&o.enable(16),b.opaque&&o.enable(17),b.pointsUvs&&o.enable(18),b.decodeVideoTexture&&o.enable(19),b.decodeVideoTextureEmissive&&o.enable(20),b.alphaToCoverage&&o.enable(21),w.push(o.mask)}function x(w){let b=g[w.type],D;if(b){let V=jn[b];D=op.clone(V.uniforms)}else D=w.uniforms;return D}function A(w,b){let D;for(let V=0,W=h.length;V<W;V++){let Y=h[V];if(Y.cacheKey===b){D=Y,++D.usedTimes;break}}return D===void 0&&(D=new yb(n,b,w,s),h.push(D)),D}function T(w){if(--w.usedTimes===0){let b=h.indexOf(w);h[b]=h[h.length-1],h.pop(),w.destroy()}}function R(w){l.remove(w)}function k(){l.dispose()}return{getParameters:m,getProgramCacheKey:p,getUniforms:x,acquireProgram:A,releaseProgram:T,releaseShaderCache:R,programs:h,dispose:k}}function _b(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function i(a){n.delete(a)}function r(a,o,l){n.get(a)[o]=l}function s(){n=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:s}}function bb(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function Rp(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function Pp(){let n=[],e=0,t=[],i=[],r=[];function s(){e=0,t.length=0,i.length=0,r.length=0}function a(u,d,f,g,y,m){let p=n[e];return p===void 0?(p={id:u.id,object:u,geometry:d,material:f,groupOrder:g,renderOrder:u.renderOrder,z:y,group:m},n[e]=p):(p.id=u.id,p.object=u,p.geometry=d,p.material=f,p.groupOrder=g,p.renderOrder=u.renderOrder,p.z=y,p.group=m),e++,p}function o(u,d,f,g,y,m){let p=a(u,d,f,g,y,m);f.transmission>0?i.push(p):f.transparent===!0?r.push(p):t.push(p)}function l(u,d,f,g,y,m){let p=a(u,d,f,g,y,m);f.transmission>0?i.unshift(p):f.transparent===!0?r.unshift(p):t.unshift(p)}function c(u,d){t.length>1&&t.sort(u||bb),i.length>1&&i.sort(d||Rp),r.length>1&&r.sort(d||Rp)}function h(){for(let u=e,d=n.length;u<d;u++){let f=n[u];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:i,transparent:r,init:s,push:o,unshift:l,finish:h,sort:c}}function Sb(){let n=new WeakMap;function e(i,r){let s=n.get(i),a;return s===void 0?(a=new Pp,n.set(i,[a])):r>=s.length?(a=new Pp,s.push(a)):a=s[r],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function wb(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new N,color:new Ze};break;case"SpotLight":t={position:new N,direction:new N,color:new Ze,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new N,color:new Ze,distance:0,decay:0};break;case"HemisphereLight":t={direction:new N,skyColor:new Ze,groundColor:new Ze};break;case"RectAreaLight":t={color:new Ze,position:new N,halfWidth:new N,halfHeight:new N};break}return n[e.id]=t,t}}}function Mb(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}var Eb=0;function Tb(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Ab(n){let e=new wb,t=Mb(),i={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++)i.probe.push(new N);let r=new N,s=new St,a=new St;function o(c){let h=0,u=0,d=0;for(let w=0;w<9;w++)i.probe[w].set(0,0,0);let f=0,g=0,y=0,m=0,p=0,M=0,S=0,x=0,A=0,T=0,R=0;c.sort(Tb);for(let w=0,b=c.length;w<b;w++){let D=c[w],V=D.color,W=D.intensity,Y=D.distance,j=D.shadow&&D.shadow.map?D.shadow.map.texture:null;if(D.isAmbientLight)h+=V.r*W,u+=V.g*W,d+=V.b*W;else if(D.isLightProbe){for(let X=0;X<9;X++)i.probe[X].addScaledVector(D.sh.coefficients[X],W);R++}else if(D.isDirectionalLight){let X=e.get(D);if(X.color.copy(D.color).multiplyScalar(D.intensity),D.castShadow){let re=D.shadow,H=t.get(D);H.shadowIntensity=re.intensity,H.shadowBias=re.bias,H.shadowNormalBias=re.normalBias,H.shadowRadius=re.radius,H.shadowMapSize=re.mapSize,i.directionalShadow[f]=H,i.directionalShadowMap[f]=j,i.directionalShadowMatrix[f]=D.shadow.matrix,M++}i.directional[f]=X,f++}else if(D.isSpotLight){let X=e.get(D);X.position.setFromMatrixPosition(D.matrixWorld),X.color.copy(V).multiplyScalar(W),X.distance=Y,X.coneCos=Math.cos(D.angle),X.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),X.decay=D.decay,i.spot[y]=X;let re=D.shadow;if(D.map&&(i.spotLightMap[A]=D.map,A++,re.updateMatrices(D),D.castShadow&&T++),i.spotLightMatrix[y]=re.matrix,D.castShadow){let H=t.get(D);H.shadowIntensity=re.intensity,H.shadowBias=re.bias,H.shadowNormalBias=re.normalBias,H.shadowRadius=re.radius,H.shadowMapSize=re.mapSize,i.spotShadow[y]=H,i.spotShadowMap[y]=j,x++}y++}else if(D.isRectAreaLight){let X=e.get(D);X.color.copy(V).multiplyScalar(W),X.halfWidth.set(D.width*.5,0,0),X.halfHeight.set(0,D.height*.5,0),i.rectArea[m]=X,m++}else if(D.isPointLight){let X=e.get(D);if(X.color.copy(D.color).multiplyScalar(D.intensity),X.distance=D.distance,X.decay=D.decay,D.castShadow){let re=D.shadow,H=t.get(D);H.shadowIntensity=re.intensity,H.shadowBias=re.bias,H.shadowNormalBias=re.normalBias,H.shadowRadius=re.radius,H.shadowMapSize=re.mapSize,H.shadowCameraNear=re.camera.near,H.shadowCameraFar=re.camera.far,i.pointShadow[g]=H,i.pointShadowMap[g]=j,i.pointShadowMatrix[g]=D.shadow.matrix,S++}i.point[g]=X,g++}else if(D.isHemisphereLight){let X=e.get(D);X.skyColor.copy(D.color).multiplyScalar(W),X.groundColor.copy(D.groundColor).multiplyScalar(W),i.hemi[p]=X,p++}}m>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ce.LTC_FLOAT_1,i.rectAreaLTC2=ce.LTC_FLOAT_2):(i.rectAreaLTC1=ce.LTC_HALF_1,i.rectAreaLTC2=ce.LTC_HALF_2)),i.ambient[0]=h,i.ambient[1]=u,i.ambient[2]=d;let k=i.hash;(k.directionalLength!==f||k.pointLength!==g||k.spotLength!==y||k.rectAreaLength!==m||k.hemiLength!==p||k.numDirectionalShadows!==M||k.numPointShadows!==S||k.numSpotShadows!==x||k.numSpotMaps!==A||k.numLightProbes!==R)&&(i.directional.length=f,i.spot.length=y,i.rectArea.length=m,i.point.length=g,i.hemi.length=p,i.directionalShadow.length=M,i.directionalShadowMap.length=M,i.pointShadow.length=S,i.pointShadowMap.length=S,i.spotShadow.length=x,i.spotShadowMap.length=x,i.directionalShadowMatrix.length=M,i.pointShadowMatrix.length=S,i.spotLightMatrix.length=x+A-T,i.spotLightMap.length=A,i.numSpotLightShadowsWithMaps=T,i.numLightProbes=R,k.directionalLength=f,k.pointLength=g,k.spotLength=y,k.rectAreaLength=m,k.hemiLength=p,k.numDirectionalShadows=M,k.numPointShadows=S,k.numSpotShadows=x,k.numSpotMaps=A,k.numLightProbes=R,i.version=Eb++)}function l(c,h){let u=0,d=0,f=0,g=0,y=0,m=h.matrixWorldInverse;for(let p=0,M=c.length;p<M;p++){let S=c[p];if(S.isDirectionalLight){let x=i.directional[u];x.direction.setFromMatrixPosition(S.matrixWorld),r.setFromMatrixPosition(S.target.matrixWorld),x.direction.sub(r),x.direction.transformDirection(m),u++}else if(S.isSpotLight){let x=i.spot[f];x.position.setFromMatrixPosition(S.matrixWorld),x.position.applyMatrix4(m),x.direction.setFromMatrixPosition(S.matrixWorld),r.setFromMatrixPosition(S.target.matrixWorld),x.direction.sub(r),x.direction.transformDirection(m),f++}else if(S.isRectAreaLight){let x=i.rectArea[g];x.position.setFromMatrixPosition(S.matrixWorld),x.position.applyMatrix4(m),a.identity(),s.copy(S.matrixWorld),s.premultiply(m),a.extractRotation(s),x.halfWidth.set(S.width*.5,0,0),x.halfHeight.set(0,S.height*.5,0),x.halfWidth.applyMatrix4(a),x.halfHeight.applyMatrix4(a),g++}else if(S.isPointLight){let x=i.point[d];x.position.setFromMatrixPosition(S.matrixWorld),x.position.applyMatrix4(m),d++}else if(S.isHemisphereLight){let x=i.hemi[y];x.direction.setFromMatrixPosition(S.matrixWorld),x.direction.transformDirection(m),y++}}}return{setup:o,setupView:l,state:i}}function Ip(n){let e=new Ab(n),t=[],i=[];function r(h){c.camera=h,t.length=0,i.length=0}function s(h){t.push(h)}function a(h){i.push(h)}function o(){e.setup(t)}function l(h){e.setupView(t,h)}let c={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function Cb(n){let e=new WeakMap;function t(r,s=0){let a=e.get(r),o;return a===void 0?(o=new Ip(n),e.set(r,[o])):s>=a.length?(o=new Ip(n),a.push(o)):o=a[s],o}function i(){e=new WeakMap}return{get:t,dispose:i}}var Rb=`void main() {
3781
3789
  gl_Position = vec4( position, 1.0 );
3782
- }`,Hm=`uniform sampler2D shadow_pass;
3790
+ }`,Pb=`uniform sampler2D shadow_pass;
3783
3791
  uniform vec2 resolution;
3784
3792
  uniform float radius;
3785
3793
  #include <packing>
@@ -3805,12 +3813,12 @@ void main() {
3805
3813
  squared_mean = squared_mean / samples;
3806
3814
  float std_dev = sqrt( squared_mean - mean * mean );
3807
3815
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3808
- }`;function Vm(i,t,e){let n=new ms,s=new Ut,r=new Ut,a=new oe,o=new br({depthPacking:_c}),c=new Sr,l={},h=e.maxTextureSize,f={[_n]:Ee,[Ee]:_n,[Xe]:Xe},u=new je({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ut},radius:{value:4}},vertexShader:km,fragmentShader:Hm}),p=u.clone();p.defines.HORIZONTAL_PASS=1;let g=new ye;g.setAttribute("position",new ae(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let _=new Pe(g,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Mo;let d=this.type;this.render=function(w,C,U){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||w.length===0)return;let S=i.getRenderTarget(),b=i.getActiveCubeFace(),P=i.getActiveMipmapLevel(),B=i.state;B.setBlending(vn),B.buffers.depth.getReversed()===!0?B.buffers.color.setClear(0,0,0,0):B.buffers.color.setClear(1,1,1,1),B.buffers.depth.setTest(!0),B.setScissorTest(!1);let V=d!==rn&&this.type===rn,X=d===rn&&this.type!==rn;for(let Z=0,W=w.length;Z<W;Z++){let et=w[Z],k=et.shadow;if(k===void 0){console.warn("THREE.WebGLShadowMap:",et,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;s.copy(k.mapSize);let rt=k.getFrameExtents();if(s.multiply(rt),r.copy(k.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/rt.x),s.x=r.x*rt.x,k.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/rt.y),s.y=r.y*rt.y,k.mapSize.y=r.y)),k.map===null||V===!0||X===!0){let bt=this.type!==rn?{minFilter:Ge,magFilter:Ge}:{};k.map!==null&&k.map.dispose(),k.map=new en(s.x,s.y,bt),k.map.texture.name=et.name+".shadowMap",k.camera.updateProjectionMatrix()}i.setRenderTarget(k.map),i.clear();let ct=k.getViewportCount();for(let bt=0;bt<ct;bt++){let Bt=k.getViewport(bt);a.set(r.x*Bt.x,r.y*Bt.y,r.x*Bt.z,r.y*Bt.w),B.viewport(a),k.updateMatrices(et,bt),n=k.getFrustum(),v(C,U,k.camera,et,this.type)}k.isPointLightShadow!==!0&&this.type===rn&&T(k,U),k.needsUpdate=!1}d=this.type,m.needsUpdate=!1,i.setRenderTarget(S,b,P)};function T(w,C){let U=t.update(_);u.defines.VSM_SAMPLES!==w.blurSamples&&(u.defines.VSM_SAMPLES=w.blurSamples,p.defines.VSM_SAMPLES=w.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new en(s.x,s.y)),u.uniforms.shadow_pass.value=w.map.texture,u.uniforms.resolution.value=w.mapSize,u.uniforms.radius.value=w.radius,i.setRenderTarget(w.mapPass),i.clear(),i.renderBufferDirect(C,null,U,u,_,null),p.uniforms.shadow_pass.value=w.mapPass.texture,p.uniforms.resolution.value=w.mapSize,p.uniforms.radius.value=w.radius,i.setRenderTarget(w.map),i.clear(),i.renderBufferDirect(C,null,U,p,_,null)}function M(w,C,U,S){let b=null,P=U.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(P!==void 0)b=P;else if(b=U.isPointLight===!0?c:o,i.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0||C.alphaToCoverage===!0){let B=b.uuid,V=C.uuid,X=l[B];X===void 0&&(X={},l[B]=X);let Z=X[V];Z===void 0&&(Z=b.clone(),X[V]=Z,C.addEventListener("dispose",R)),b=Z}if(b.visible=C.visible,b.wireframe=C.wireframe,S===rn?b.side=C.shadowSide!==null?C.shadowSide:C.side:b.side=C.shadowSide!==null?C.shadowSide:f[C.side],b.alphaMap=C.alphaMap,b.alphaTest=C.alphaToCoverage===!0?.5:C.alphaTest,b.map=C.map,b.clipShadows=C.clipShadows,b.clippingPlanes=C.clippingPlanes,b.clipIntersection=C.clipIntersection,b.displacementMap=C.displacementMap,b.displacementScale=C.displacementScale,b.displacementBias=C.displacementBias,b.wireframeLinewidth=C.wireframeLinewidth,b.linewidth=C.linewidth,U.isPointLight===!0&&b.isMeshDistanceMaterial===!0){let B=i.properties.get(b);B.light=U}return b}function v(w,C,U,S,b){if(w.visible===!1)return;if(w.layers.test(C.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&b===rn)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(U.matrixWorldInverse,w.matrixWorld);let V=t.update(w),X=w.material;if(Array.isArray(X)){let Z=V.groups;for(let W=0,et=Z.length;W<et;W++){let k=Z[W],rt=X[k.materialIndex];if(rt&&rt.visible){let ct=M(w,rt,S,b);w.onBeforeShadow(i,w,C,U,V,ct,k),i.renderBufferDirect(U,null,V,ct,w,k),w.onAfterShadow(i,w,C,U,V,ct,k)}}}else if(X.visible){let Z=M(w,X,S,b);w.onBeforeShadow(i,w,C,U,V,Z,null),i.renderBufferDirect(U,null,V,Z,w,null),w.onAfterShadow(i,w,C,U,V,Z,null)}}let B=w.children;for(let V=0,X=B.length;V<X;V++)v(B[V],C,U,S,b)}function R(w){w.target.removeEventListener("dispose",R);for(let U in l){let S=l[U],b=w.target.uuid;b in S&&(S[b].dispose(),delete S[b])}}}var Gm={[Ur]:Nr,[Fr]:zr,[Or]:kr,[Zn]:Br,[Nr]:Ur,[zr]:Fr,[kr]:Or,[Br]:Zn};function Wm(i,t){function e(){let I=!1,tt=new oe,it=null,ut=new oe(0,0,0,0);return{setMask:function(K){it!==K&&!I&&(i.colorMask(K,K,K,K),it=K)},setLocked:function(K){I=K},setClear:function(K,Y,pt,Pt,Kt){Kt===!0&&(K*=Pt,Y*=Pt,pt*=Pt),tt.set(K,Y,pt,Pt),ut.equals(tt)===!1&&(i.clearColor(K,Y,pt,Pt),ut.copy(tt))},reset:function(){I=!1,it=null,ut.set(-1,0,0,0)}}}function n(){let I=!1,tt=!1,it=null,ut=null,K=null;return{setReversed:function(Y){if(tt!==Y){let pt=t.get("EXT_clip_control");Y?pt.clipControlEXT(pt.LOWER_LEFT_EXT,pt.ZERO_TO_ONE_EXT):pt.clipControlEXT(pt.LOWER_LEFT_EXT,pt.NEGATIVE_ONE_TO_ONE_EXT),tt=Y;let Pt=K;K=null,this.setClear(Pt)}},getReversed:function(){return tt},setTest:function(Y){Y?J(i.DEPTH_TEST):dt(i.DEPTH_TEST)},setMask:function(Y){it!==Y&&!I&&(i.depthMask(Y),it=Y)},setFunc:function(Y){if(tt&&(Y=Gm[Y]),ut!==Y){switch(Y){case Ur:i.depthFunc(i.NEVER);break;case Nr:i.depthFunc(i.ALWAYS);break;case Fr:i.depthFunc(i.LESS);break;case Zn:i.depthFunc(i.LEQUAL);break;case Or:i.depthFunc(i.EQUAL);break;case Br:i.depthFunc(i.GEQUAL);break;case zr:i.depthFunc(i.GREATER);break;case kr:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}ut=Y}},setLocked:function(Y){I=Y},setClear:function(Y){K!==Y&&(tt&&(Y=1-Y),i.clearDepth(Y),K=Y)},reset:function(){I=!1,it=null,ut=null,K=null,tt=!1}}}function s(){let I=!1,tt=null,it=null,ut=null,K=null,Y=null,pt=null,Pt=null,Kt=null;return{setTest:function(Xt){I||(Xt?J(i.STENCIL_TEST):dt(i.STENCIL_TEST))},setMask:function(Xt){tt!==Xt&&!I&&(i.stencilMask(Xt),tt=Xt)},setFunc:function(Xt,cn,Qe){(it!==Xt||ut!==cn||K!==Qe)&&(i.stencilFunc(Xt,cn,Qe),it=Xt,ut=cn,K=Qe)},setOp:function(Xt,cn,Qe){(Y!==Xt||pt!==cn||Pt!==Qe)&&(i.stencilOp(Xt,cn,Qe),Y=Xt,pt=cn,Pt=Qe)},setLocked:function(Xt){I=Xt},setClear:function(Xt){Kt!==Xt&&(i.clearStencil(Xt),Kt=Xt)},reset:function(){I=!1,tt=null,it=null,ut=null,K=null,Y=null,pt=null,Pt=null,Kt=null}}}let r=new e,a=new n,o=new s,c=new WeakMap,l=new WeakMap,h={},f={},u=new WeakMap,p=[],g=null,_=!1,m=null,d=null,T=null,M=null,v=null,R=null,w=null,C=new zt(0,0,0),U=0,S=!1,b=null,P=null,B=null,V=null,X=null,Z=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),W=!1,et=0,k=i.getParameter(i.VERSION);k.indexOf("WebGL")!==-1?(et=parseFloat(/^WebGL (\d)/.exec(k)[1]),W=et>=1):k.indexOf("OpenGL ES")!==-1&&(et=parseFloat(/^OpenGL ES (\d)/.exec(k)[1]),W=et>=2);let rt=null,ct={},bt=i.getParameter(i.SCISSOR_BOX),Bt=i.getParameter(i.VIEWPORT),Jt=new oe().fromArray(bt),te=new oe().fromArray(Bt);function Wt(I,tt,it,ut){let K=new Uint8Array(4),Y=i.createTexture();i.bindTexture(I,Y),i.texParameteri(I,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(I,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let pt=0;pt<it;pt++)I===i.TEXTURE_3D||I===i.TEXTURE_2D_ARRAY?i.texImage3D(tt,0,i.RGBA,1,1,ut,0,i.RGBA,i.UNSIGNED_BYTE,K):i.texImage2D(tt+pt,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,K);return Y}let q={};q[i.TEXTURE_2D]=Wt(i.TEXTURE_2D,i.TEXTURE_2D,1),q[i.TEXTURE_CUBE_MAP]=Wt(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),q[i.TEXTURE_2D_ARRAY]=Wt(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),q[i.TEXTURE_3D]=Wt(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),J(i.DEPTH_TEST),a.setFunc(Zn),At(!1),mt(vo),J(i.CULL_FACE),ee(vn);function J(I){h[I]!==!0&&(i.enable(I),h[I]=!0)}function dt(I){h[I]!==!1&&(i.disable(I),h[I]=!1)}function Ct(I,tt){return f[I]!==tt?(i.bindFramebuffer(I,tt),f[I]=tt,I===i.DRAW_FRAMEBUFFER&&(f[i.FRAMEBUFFER]=tt),I===i.FRAMEBUFFER&&(f[i.DRAW_FRAMEBUFFER]=tt),!0):!1}function Mt(I,tt){let it=p,ut=!1;if(I){it=u.get(tt),it===void 0&&(it=[],u.set(tt,it));let K=I.textures;if(it.length!==K.length||it[0]!==i.COLOR_ATTACHMENT0){for(let Y=0,pt=K.length;Y<pt;Y++)it[Y]=i.COLOR_ATTACHMENT0+Y;it.length=K.length,ut=!0}}else it[0]!==i.BACK&&(it[0]=i.BACK,ut=!0);ut&&i.drawBuffers(it)}function Ht(I){return g!==I?(i.useProgram(I),g=I,!0):!1}let ge={[In]:i.FUNC_ADD,[Gl]:i.FUNC_SUBTRACT,[Wl]:i.FUNC_REVERSE_SUBTRACT};ge[Xl]=i.MIN,ge[ql]=i.MAX;let A={[Yl]:i.ZERO,[Zl]:i.ONE,[$l]:i.SRC_COLOR,[hr]:i.SRC_ALPHA,[ec]:i.SRC_ALPHA_SATURATE,[Ql]:i.DST_COLOR,[Kl]:i.DST_ALPHA,[Jl]:i.ONE_MINUS_SRC_COLOR,[ur]:i.ONE_MINUS_SRC_ALPHA,[tc]:i.ONE_MINUS_DST_COLOR,[jl]:i.ONE_MINUS_DST_ALPHA,[nc]:i.CONSTANT_COLOR,[ic]:i.ONE_MINUS_CONSTANT_COLOR,[sc]:i.CONSTANT_ALPHA,[rc]:i.ONE_MINUS_CONSTANT_ALPHA};function ee(I,tt,it,ut,K,Y,pt,Pt,Kt,Xt){if(I===vn){_===!0&&(dt(i.BLEND),_=!1);return}if(_===!1&&(J(i.BLEND),_=!0),I!==Vl){if(I!==m||Xt!==S){if((d!==In||v!==In)&&(i.blendEquation(i.FUNC_ADD),d=In,v=In),Xt)switch(I){case xn:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Es:i.blendFunc(i.ONE,i.ONE);break;case bo:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case So:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",I);break}else switch(I){case xn:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Es:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case bo:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case So:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",I);break}T=null,M=null,R=null,w=null,C.set(0,0,0),U=0,m=I,S=Xt}return}K=K||tt,Y=Y||it,pt=pt||ut,(tt!==d||K!==v)&&(i.blendEquationSeparate(ge[tt],ge[K]),d=tt,v=K),(it!==T||ut!==M||Y!==R||pt!==w)&&(i.blendFuncSeparate(A[it],A[ut],A[Y],A[pt]),T=it,M=ut,R=Y,w=pt),(Pt.equals(C)===!1||Kt!==U)&&(i.blendColor(Pt.r,Pt.g,Pt.b,Kt),C.copy(Pt),U=Kt),m=I,S=!1}function It(I,tt){I.side===Xe?dt(i.CULL_FACE):J(i.CULL_FACE);let it=I.side===Ee;tt&&(it=!it),At(it),I.blending===xn&&I.transparent===!1?ee(vn):ee(I.blending,I.blendEquation,I.blendSrc,I.blendDst,I.blendEquationAlpha,I.blendSrcAlpha,I.blendDstAlpha,I.blendColor,I.blendAlpha,I.premultipliedAlpha),a.setFunc(I.depthFunc),a.setTest(I.depthTest),a.setMask(I.depthWrite),r.setMask(I.colorWrite);let ut=I.stencilWrite;o.setTest(ut),ut&&(o.setMask(I.stencilWriteMask),o.setFunc(I.stencilFunc,I.stencilRef,I.stencilFuncMask),o.setOp(I.stencilFail,I.stencilZFail,I.stencilZPass)),gt(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),I.alphaToCoverage===!0?J(i.SAMPLE_ALPHA_TO_COVERAGE):dt(i.SAMPLE_ALPHA_TO_COVERAGE)}function At(I){b!==I&&(I?i.frontFace(i.CW):i.frontFace(i.CCW),b=I)}function mt(I){I!==zl?(J(i.CULL_FACE),I!==P&&(I===vo?i.cullFace(i.BACK):I===kl?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):dt(i.CULL_FACE),P=I}function ne(I){I!==B&&(W&&i.lineWidth(I),B=I)}function gt(I,tt,it){I?(J(i.POLYGON_OFFSET_FILL),(V!==tt||X!==it)&&(i.polygonOffset(tt,it),V=tt,X=it)):dt(i.POLYGON_OFFSET_FILL)}function Nt(I){I?J(i.SCISSOR_TEST):dt(i.SCISSOR_TEST)}function pe(I){I===void 0&&(I=i.TEXTURE0+Z-1),rt!==I&&(i.activeTexture(I),rt=I)}function le(I,tt,it){it===void 0&&(rt===null?it=i.TEXTURE0+Z-1:it=rt);let ut=ct[it];ut===void 0&&(ut={type:void 0,texture:void 0},ct[it]=ut),(ut.type!==I||ut.texture!==tt)&&(rt!==it&&(i.activeTexture(it),rt=it),i.bindTexture(I,tt||q[I]),ut.type=I,ut.texture=tt)}function E(){let I=ct[rt];I!==void 0&&I.type!==void 0&&(i.bindTexture(I.type,null),I.type=void 0,I.texture=void 0)}function x(){try{i.compressedTexImage2D(...arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function F(){try{i.compressedTexImage3D(...arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function G(){try{i.texSubImage2D(...arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function $(){try{i.texSubImage3D(...arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function H(){try{i.compressedTexSubImage2D(...arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function vt(){try{i.compressedTexSubImage3D(...arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function nt(){try{i.texStorage2D(...arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function _t(){try{i.texStorage3D(...arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function xt(){try{i.texImage2D(...arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function Q(){try{i.texImage3D(...arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function lt(I){Jt.equals(I)===!1&&(i.scissor(I.x,I.y,I.z,I.w),Jt.copy(I))}function wt(I){te.equals(I)===!1&&(i.viewport(I.x,I.y,I.z,I.w),te.copy(I))}function yt(I,tt){let it=l.get(tt);it===void 0&&(it=new WeakMap,l.set(tt,it));let ut=it.get(I);ut===void 0&&(ut=i.getUniformBlockIndex(tt,I.name),it.set(I,ut))}function at(I,tt){let ut=l.get(tt).get(I);c.get(tt)!==ut&&(i.uniformBlockBinding(tt,ut,I.__bindingPointIndex),c.set(tt,ut))}function Dt(){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),h={},rt=null,ct={},f={},u=new WeakMap,p=[],g=null,_=!1,m=null,d=null,T=null,M=null,v=null,R=null,w=null,C=new zt(0,0,0),U=0,S=!1,b=null,P=null,B=null,V=null,X=null,Jt.set(0,0,i.canvas.width,i.canvas.height),te.set(0,0,i.canvas.width,i.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:J,disable:dt,bindFramebuffer:Ct,drawBuffers:Mt,useProgram:Ht,setBlending:ee,setMaterial:It,setFlipSided:At,setCullFace:mt,setLineWidth:ne,setPolygonOffset:gt,setScissorTest:Nt,activeTexture:pe,bindTexture:le,unbindTexture:E,compressedTexImage2D:x,compressedTexImage3D:F,texImage2D:xt,texImage3D:Q,updateUBOMapping:yt,uniformBlockBinding:at,texStorage2D:nt,texStorage3D:_t,texSubImage2D:G,texSubImage3D:$,compressedTexSubImage2D:H,compressedTexSubImage3D:vt,scissor:lt,viewport:wt,reset:Dt}}function Xm(i,t,e,n,s,r,a){let o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ut,h=new WeakMap,f,u=new WeakMap,p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(E,x){return p?new OffscreenCanvas(E,x):os("canvas")}function _(E,x,F){let G=1,$=le(E);if(($.width>F||$.height>F)&&(G=F/Math.max($.width,$.height)),G<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 H=Math.floor(G*$.width),vt=Math.floor(G*$.height);f===void 0&&(f=g(H,vt));let nt=x?g(H,vt):f;return nt.width=H,nt.height=vt,nt.getContext("2d").drawImage(E,0,0,H,vt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+H+"x"+vt+")."),nt}else return"data"in E&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),E;return E}function m(E){return E.generateMipmaps}function d(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 M(E,x,F,G,$=!1){if(E!==null){if(i[E]!==void 0)return i[E];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let H=x;if(x===i.RED&&(F===i.FLOAT&&(H=i.R32F),F===i.HALF_FLOAT&&(H=i.R16F),F===i.UNSIGNED_BYTE&&(H=i.R8)),x===i.RED_INTEGER&&(F===i.UNSIGNED_BYTE&&(H=i.R8UI),F===i.UNSIGNED_SHORT&&(H=i.R16UI),F===i.UNSIGNED_INT&&(H=i.R32UI),F===i.BYTE&&(H=i.R8I),F===i.SHORT&&(H=i.R16I),F===i.INT&&(H=i.R32I)),x===i.RG&&(F===i.FLOAT&&(H=i.RG32F),F===i.HALF_FLOAT&&(H=i.RG16F),F===i.UNSIGNED_BYTE&&(H=i.RG8)),x===i.RG_INTEGER&&(F===i.UNSIGNED_BYTE&&(H=i.RG8UI),F===i.UNSIGNED_SHORT&&(H=i.RG16UI),F===i.UNSIGNED_INT&&(H=i.RG32UI),F===i.BYTE&&(H=i.RG8I),F===i.SHORT&&(H=i.RG16I),F===i.INT&&(H=i.RG32I)),x===i.RGB_INTEGER&&(F===i.UNSIGNED_BYTE&&(H=i.RGB8UI),F===i.UNSIGNED_SHORT&&(H=i.RGB16UI),F===i.UNSIGNED_INT&&(H=i.RGB32UI),F===i.BYTE&&(H=i.RGB8I),F===i.SHORT&&(H=i.RGB16I),F===i.INT&&(H=i.RGB32I)),x===i.RGBA_INTEGER&&(F===i.UNSIGNED_BYTE&&(H=i.RGBA8UI),F===i.UNSIGNED_SHORT&&(H=i.RGBA16UI),F===i.UNSIGNED_INT&&(H=i.RGBA32UI),F===i.BYTE&&(H=i.RGBA8I),F===i.SHORT&&(H=i.RGBA16I),F===i.INT&&(H=i.RGBA32I)),x===i.RGB&&(F===i.UNSIGNED_INT_5_9_9_9_REV&&(H=i.RGB9_E5),F===i.UNSIGNED_INT_10F_11F_11F_REV&&(H=i.R11F_G11F_B10F)),x===i.RGBA){let vt=$?rs:Vt.getTransfer(G);F===i.FLOAT&&(H=i.RGBA32F),F===i.HALF_FLOAT&&(H=i.RGBA16F),F===i.UNSIGNED_BYTE&&(H=vt===qt?i.SRGB8_ALPHA8:i.RGBA8),F===i.UNSIGNED_SHORT_4_4_4_4&&(H=i.RGBA4),F===i.UNSIGNED_SHORT_5_5_5_1&&(H=i.RGB5_A1)}return(H===i.R16F||H===i.R32F||H===i.RG16F||H===i.RG32F||H===i.RGBA16F||H===i.RGBA32F)&&t.get("EXT_color_buffer_float"),H}function v(E,x){let F;return E?x===null||x===Bn||x===Fi?F=i.DEPTH24_STENCIL8:x===on?F=i.DEPTH32F_STENCIL8:x===Ui&&(F=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===Bn||x===Fi?F=i.DEPTH_COMPONENT24:x===on?F=i.DEPTH_COMPONENT32F:x===Ui&&(F=i.DEPTH_COMPONENT16),F}function R(E,x){return m(E)===!0||E.isFramebufferTexture&&E.minFilter!==Ge&&E.minFilter!==Ke?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 w(E){let x=E.target;x.removeEventListener("dispose",w),U(x),x.isVideoTexture&&h.delete(x)}function C(E){let x=E.target;x.removeEventListener("dispose",C),b(x)}function U(E){let x=n.get(E);if(x.__webglInit===void 0)return;let F=E.source,G=u.get(F);if(G){let $=G[x.__cacheKey];$.usedTimes--,$.usedTimes===0&&S(E),Object.keys(G).length===0&&u.delete(F)}n.remove(E)}function S(E){let x=n.get(E);i.deleteTexture(x.__webglTexture);let F=E.source,G=u.get(F);delete G[x.__cacheKey],a.memory.textures--}function b(E){let x=n.get(E);if(E.depthTexture&&(E.depthTexture.dispose(),n.remove(E.depthTexture)),E.isWebGLCubeRenderTarget)for(let G=0;G<6;G++){if(Array.isArray(x.__webglFramebuffer[G]))for(let $=0;$<x.__webglFramebuffer[G].length;$++)i.deleteFramebuffer(x.__webglFramebuffer[G][$]);else i.deleteFramebuffer(x.__webglFramebuffer[G]);x.__webglDepthbuffer&&i.deleteRenderbuffer(x.__webglDepthbuffer[G])}else{if(Array.isArray(x.__webglFramebuffer))for(let G=0;G<x.__webglFramebuffer.length;G++)i.deleteFramebuffer(x.__webglFramebuffer[G]);else i.deleteFramebuffer(x.__webglFramebuffer);if(x.__webglDepthbuffer&&i.deleteRenderbuffer(x.__webglDepthbuffer),x.__webglMultisampledFramebuffer&&i.deleteFramebuffer(x.__webglMultisampledFramebuffer),x.__webglColorRenderbuffer)for(let G=0;G<x.__webglColorRenderbuffer.length;G++)x.__webglColorRenderbuffer[G]&&i.deleteRenderbuffer(x.__webglColorRenderbuffer[G]);x.__webglDepthRenderbuffer&&i.deleteRenderbuffer(x.__webglDepthRenderbuffer)}let F=E.textures;for(let G=0,$=F.length;G<$;G++){let H=n.get(F[G]);H.__webglTexture&&(i.deleteTexture(H.__webglTexture),a.memory.textures--),n.remove(F[G])}n.remove(E)}let P=0;function B(){P=0}function V(){let E=P;return E>=s.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+s.maxTextures),P+=1,E}function X(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 Z(E,x){let F=n.get(E);if(E.isVideoTexture&&Nt(E),E.isRenderTargetTexture===!1&&E.isExternalTexture!==!0&&E.version>0&&F.__version!==E.version){let G=E.image;if(G===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(G.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{q(F,E,x);return}}else E.isExternalTexture&&(F.__webglTexture=E.sourceTexture?E.sourceTexture:null);e.bindTexture(i.TEXTURE_2D,F.__webglTexture,i.TEXTURE0+x)}function W(E,x){let F=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&F.__version!==E.version){q(F,E,x);return}e.bindTexture(i.TEXTURE_2D_ARRAY,F.__webglTexture,i.TEXTURE0+x)}function et(E,x){let F=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&F.__version!==E.version){q(F,E,x);return}e.bindTexture(i.TEXTURE_3D,F.__webglTexture,i.TEXTURE0+x)}function k(E,x){let F=n.get(E);if(E.version>0&&F.__version!==E.version){J(F,E,x);return}e.bindTexture(i.TEXTURE_CUBE_MAP,F.__webglTexture,i.TEXTURE0+x)}let rt={[dr]:i.REPEAT,[Pn]:i.CLAMP_TO_EDGE,[fr]:i.MIRRORED_REPEAT},ct={[Ge]:i.NEAREST,[mc]:i.NEAREST_MIPMAP_NEAREST,[ws]:i.NEAREST_MIPMAP_LINEAR,[Ke]:i.LINEAR,[Gr]:i.LINEAR_MIPMAP_NEAREST,[On]:i.LINEAR_MIPMAP_LINEAR},bt={[vc]:i.NEVER,[wc]:i.ALWAYS,[Mc]:i.LESS,[Uo]:i.LEQUAL,[bc]:i.EQUAL,[Tc]:i.GEQUAL,[Sc]:i.GREATER,[Ec]:i.NOTEQUAL};function Bt(E,x){if(x.type===on&&t.has("OES_texture_float_linear")===!1&&(x.magFilter===Ke||x.magFilter===Gr||x.magFilter===ws||x.magFilter===On||x.minFilter===Ke||x.minFilter===Gr||x.minFilter===ws||x.minFilter===On)&&console.warn("THREE.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,rt[x.wrapS]),i.texParameteri(E,i.TEXTURE_WRAP_T,rt[x.wrapT]),(E===i.TEXTURE_3D||E===i.TEXTURE_2D_ARRAY)&&i.texParameteri(E,i.TEXTURE_WRAP_R,rt[x.wrapR]),i.texParameteri(E,i.TEXTURE_MAG_FILTER,ct[x.magFilter]),i.texParameteri(E,i.TEXTURE_MIN_FILTER,ct[x.minFilter]),x.compareFunction&&(i.texParameteri(E,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(E,i.TEXTURE_COMPARE_FUNC,bt[x.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===Ge||x.minFilter!==ws&&x.minFilter!==On||x.type===on&&t.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||n.get(x).__currentAnisotropy){let F=t.get("EXT_texture_filter_anisotropic");i.texParameterf(E,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,s.getMaxAnisotropy())),n.get(x).__currentAnisotropy=x.anisotropy}}}function Jt(E,x){let F=!1;E.__webglInit===void 0&&(E.__webglInit=!0,x.addEventListener("dispose",w));let G=x.source,$=u.get(G);$===void 0&&($={},u.set(G,$));let H=X(x);if(H!==E.__cacheKey){$[H]===void 0&&($[H]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,F=!0),$[H].usedTimes++;let vt=$[E.__cacheKey];vt!==void 0&&($[E.__cacheKey].usedTimes--,vt.usedTimes===0&&S(x)),E.__cacheKey=H,E.__webglTexture=$[H].texture}return F}function te(E,x,F){return Math.floor(Math.floor(E/F)/x)}function Wt(E,x,F,G){let H=E.updateRanges;if(H.length===0)e.texSubImage2D(i.TEXTURE_2D,0,0,0,x.width,x.height,F,G,x.data);else{H.sort((Q,lt)=>Q.start-lt.start);let vt=0;for(let Q=1;Q<H.length;Q++){let lt=H[vt],wt=H[Q],yt=lt.start+lt.count,at=te(wt.start,x.width,4),Dt=te(lt.start,x.width,4);wt.start<=yt+1&&at===Dt&&te(wt.start+wt.count-1,x.width,4)===at?lt.count=Math.max(lt.count,wt.start+wt.count-lt.start):(++vt,H[vt]=wt)}H.length=vt+1;let nt=i.getParameter(i.UNPACK_ROW_LENGTH),_t=i.getParameter(i.UNPACK_SKIP_PIXELS),xt=i.getParameter(i.UNPACK_SKIP_ROWS);i.pixelStorei(i.UNPACK_ROW_LENGTH,x.width);for(let Q=0,lt=H.length;Q<lt;Q++){let wt=H[Q],yt=Math.floor(wt.start/4),at=Math.ceil(wt.count/4),Dt=yt%x.width,I=Math.floor(yt/x.width),tt=at,it=1;i.pixelStorei(i.UNPACK_SKIP_PIXELS,Dt),i.pixelStorei(i.UNPACK_SKIP_ROWS,I),e.texSubImage2D(i.TEXTURE_2D,0,Dt,I,tt,it,F,G,x.data)}E.clearUpdateRanges(),i.pixelStorei(i.UNPACK_ROW_LENGTH,nt),i.pixelStorei(i.UNPACK_SKIP_PIXELS,_t),i.pixelStorei(i.UNPACK_SKIP_ROWS,xt)}}function q(E,x,F){let G=i.TEXTURE_2D;(x.isDataArrayTexture||x.isCompressedArrayTexture)&&(G=i.TEXTURE_2D_ARRAY),x.isData3DTexture&&(G=i.TEXTURE_3D);let $=Jt(E,x),H=x.source;e.bindTexture(G,E.__webglTexture,i.TEXTURE0+F);let vt=n.get(H);if(H.version!==vt.__version||$===!0){e.activeTexture(i.TEXTURE0+F);let nt=Vt.getPrimaries(Vt.workingColorSpace),_t=x.colorSpace===bn?null:Vt.getPrimaries(x.colorSpace),xt=x.colorSpace===bn||nt===_t?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,x.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,x.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,xt);let Q=_(x.image,!1,s.maxTextureSize);Q=pe(x,Q);let lt=r.convert(x.format,x.colorSpace),wt=r.convert(x.type),yt=M(x.internalFormat,lt,wt,x.colorSpace,x.isVideoTexture);Bt(G,x);let at,Dt=x.mipmaps,I=x.isVideoTexture!==!0,tt=vt.__version===void 0||$===!0,it=H.dataReady,ut=R(x,Q);if(x.isDepthTexture)yt=v(x.format===Oi,x.type),tt&&(I?e.texStorage2D(i.TEXTURE_2D,1,yt,Q.width,Q.height):e.texImage2D(i.TEXTURE_2D,0,yt,Q.width,Q.height,0,lt,wt,null));else if(x.isDataTexture)if(Dt.length>0){I&&tt&&e.texStorage2D(i.TEXTURE_2D,ut,yt,Dt[0].width,Dt[0].height);for(let K=0,Y=Dt.length;K<Y;K++)at=Dt[K],I?it&&e.texSubImage2D(i.TEXTURE_2D,K,0,0,at.width,at.height,lt,wt,at.data):e.texImage2D(i.TEXTURE_2D,K,yt,at.width,at.height,0,lt,wt,at.data);x.generateMipmaps=!1}else I?(tt&&e.texStorage2D(i.TEXTURE_2D,ut,yt,Q.width,Q.height),it&&Wt(x,Q,lt,wt)):e.texImage2D(i.TEXTURE_2D,0,yt,Q.width,Q.height,0,lt,wt,Q.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){I&&tt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,ut,yt,Dt[0].width,Dt[0].height,Q.depth);for(let K=0,Y=Dt.length;K<Y;K++)if(at=Dt[K],x.format!==qe)if(lt!==null)if(I){if(it)if(x.layerUpdates.size>0){let pt=Vo(at.width,at.height,x.format,x.type);for(let Pt of x.layerUpdates){let Kt=at.data.subarray(Pt*pt/at.data.BYTES_PER_ELEMENT,(Pt+1)*pt/at.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,K,0,0,Pt,at.width,at.height,1,lt,Kt)}x.clearLayerUpdates()}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,K,0,0,0,at.width,at.height,Q.depth,lt,at.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,K,yt,at.width,at.height,Q.depth,0,at.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else I?it&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,K,0,0,0,at.width,at.height,Q.depth,lt,wt,at.data):e.texImage3D(i.TEXTURE_2D_ARRAY,K,yt,at.width,at.height,Q.depth,0,lt,wt,at.data)}else{I&&tt&&e.texStorage2D(i.TEXTURE_2D,ut,yt,Dt[0].width,Dt[0].height);for(let K=0,Y=Dt.length;K<Y;K++)at=Dt[K],x.format!==qe?lt!==null?I?it&&e.compressedTexSubImage2D(i.TEXTURE_2D,K,0,0,at.width,at.height,lt,at.data):e.compressedTexImage2D(i.TEXTURE_2D,K,yt,at.width,at.height,0,at.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):I?it&&e.texSubImage2D(i.TEXTURE_2D,K,0,0,at.width,at.height,lt,wt,at.data):e.texImage2D(i.TEXTURE_2D,K,yt,at.width,at.height,0,lt,wt,at.data)}else if(x.isDataArrayTexture)if(I){if(tt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,ut,yt,Q.width,Q.height,Q.depth),it)if(x.layerUpdates.size>0){let K=Vo(Q.width,Q.height,x.format,x.type);for(let Y of x.layerUpdates){let pt=Q.data.subarray(Y*K/Q.data.BYTES_PER_ELEMENT,(Y+1)*K/Q.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,Y,Q.width,Q.height,1,lt,wt,pt)}x.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,lt,wt,Q.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,yt,Q.width,Q.height,Q.depth,0,lt,wt,Q.data);else if(x.isData3DTexture)I?(tt&&e.texStorage3D(i.TEXTURE_3D,ut,yt,Q.width,Q.height,Q.depth),it&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,lt,wt,Q.data)):e.texImage3D(i.TEXTURE_3D,0,yt,Q.width,Q.height,Q.depth,0,lt,wt,Q.data);else if(x.isFramebufferTexture){if(tt)if(I)e.texStorage2D(i.TEXTURE_2D,ut,yt,Q.width,Q.height);else{let K=Q.width,Y=Q.height;for(let pt=0;pt<ut;pt++)e.texImage2D(i.TEXTURE_2D,pt,yt,K,Y,0,lt,wt,null),K>>=1,Y>>=1}}else if(Dt.length>0){if(I&&tt){let K=le(Dt[0]);e.texStorage2D(i.TEXTURE_2D,ut,yt,K.width,K.height)}for(let K=0,Y=Dt.length;K<Y;K++)at=Dt[K],I?it&&e.texSubImage2D(i.TEXTURE_2D,K,0,0,lt,wt,at):e.texImage2D(i.TEXTURE_2D,K,yt,lt,wt,at);x.generateMipmaps=!1}else if(I){if(tt){let K=le(Q);e.texStorage2D(i.TEXTURE_2D,ut,yt,K.width,K.height)}it&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,lt,wt,Q)}else e.texImage2D(i.TEXTURE_2D,0,yt,lt,wt,Q);m(x)&&d(G),vt.__version=H.version,x.onUpdate&&x.onUpdate(x)}E.__version=x.version}function J(E,x,F){if(x.image.length!==6)return;let G=Jt(E,x),$=x.source;e.bindTexture(i.TEXTURE_CUBE_MAP,E.__webglTexture,i.TEXTURE0+F);let H=n.get($);if($.version!==H.__version||G===!0){e.activeTexture(i.TEXTURE0+F);let vt=Vt.getPrimaries(Vt.workingColorSpace),nt=x.colorSpace===bn?null:Vt.getPrimaries(x.colorSpace),_t=x.colorSpace===bn||vt===nt?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,x.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,x.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,_t);let xt=x.isCompressedTexture||x.image[0].isCompressedTexture,Q=x.image[0]&&x.image[0].isDataTexture,lt=[];for(let Y=0;Y<6;Y++)!xt&&!Q?lt[Y]=_(x.image[Y],!0,s.maxCubemapSize):lt[Y]=Q?x.image[Y].image:x.image[Y],lt[Y]=pe(x,lt[Y]);let wt=lt[0],yt=r.convert(x.format,x.colorSpace),at=r.convert(x.type),Dt=M(x.internalFormat,yt,at,x.colorSpace),I=x.isVideoTexture!==!0,tt=H.__version===void 0||G===!0,it=$.dataReady,ut=R(x,wt);Bt(i.TEXTURE_CUBE_MAP,x);let K;if(xt){I&&tt&&e.texStorage2D(i.TEXTURE_CUBE_MAP,ut,Dt,wt.width,wt.height);for(let Y=0;Y<6;Y++){K=lt[Y].mipmaps;for(let pt=0;pt<K.length;pt++){let Pt=K[pt];x.format!==qe?yt!==null?I?it&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,pt,0,0,Pt.width,Pt.height,yt,Pt.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,pt,Dt,Pt.width,Pt.height,0,Pt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):I?it&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,pt,0,0,Pt.width,Pt.height,yt,at,Pt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,pt,Dt,Pt.width,Pt.height,0,yt,at,Pt.data)}}}else{if(K=x.mipmaps,I&&tt){K.length>0&&ut++;let Y=le(lt[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,ut,Dt,Y.width,Y.height)}for(let Y=0;Y<6;Y++)if(Q){I?it&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,0,0,lt[Y].width,lt[Y].height,yt,at,lt[Y].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,Dt,lt[Y].width,lt[Y].height,0,yt,at,lt[Y].data);for(let pt=0;pt<K.length;pt++){let Kt=K[pt].image[Y].image;I?it&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,pt+1,0,0,Kt.width,Kt.height,yt,at,Kt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,pt+1,Dt,Kt.width,Kt.height,0,yt,at,Kt.data)}}else{I?it&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,0,0,yt,at,lt[Y]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,Dt,yt,at,lt[Y]);for(let pt=0;pt<K.length;pt++){let Pt=K[pt];I?it&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,pt+1,0,0,yt,at,Pt.image[Y]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,pt+1,Dt,yt,at,Pt.image[Y])}}}m(x)&&d(i.TEXTURE_CUBE_MAP),H.__version=$.version,x.onUpdate&&x.onUpdate(x)}E.__version=x.version}function dt(E,x,F,G,$,H){let vt=r.convert(F.format,F.colorSpace),nt=r.convert(F.type),_t=M(F.internalFormat,vt,nt,F.colorSpace),xt=n.get(x),Q=n.get(F);if(Q.__renderTarget=x,!xt.__hasExternalTextures){let lt=Math.max(1,x.width>>H),wt=Math.max(1,x.height>>H);$===i.TEXTURE_3D||$===i.TEXTURE_2D_ARRAY?e.texImage3D($,H,_t,lt,wt,x.depth,0,vt,nt,null):e.texImage2D($,H,_t,lt,wt,0,vt,nt,null)}e.bindFramebuffer(i.FRAMEBUFFER,E),gt(x)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,G,$,Q.__webglTexture,0,ne(x)):($===i.TEXTURE_2D||$>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,G,$,Q.__webglTexture,H),e.bindFramebuffer(i.FRAMEBUFFER,null)}function Ct(E,x,F){if(i.bindRenderbuffer(i.RENDERBUFFER,E),x.depthBuffer){let G=x.depthTexture,$=G&&G.isDepthTexture?G.type:null,H=v(x.stencilBuffer,$),vt=x.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,nt=ne(x);gt(x)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,nt,H,x.width,x.height):F?i.renderbufferStorageMultisample(i.RENDERBUFFER,nt,H,x.width,x.height):i.renderbufferStorage(i.RENDERBUFFER,H,x.width,x.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,vt,i.RENDERBUFFER,E)}else{let G=x.textures;for(let $=0;$<G.length;$++){let H=G[$],vt=r.convert(H.format,H.colorSpace),nt=r.convert(H.type),_t=M(H.internalFormat,vt,nt,H.colorSpace),xt=ne(x);F&&gt(x)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,xt,_t,x.width,x.height):gt(x)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,xt,_t,x.width,x.height):i.renderbufferStorage(i.RENDERBUFFER,_t,x.width,x.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Mt(E,x){if(x&&x.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(i.FRAMEBUFFER,E),!(x.depthTexture&&x.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");let G=n.get(x.depthTexture);G.__renderTarget=x,(!G.__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),Z(x.depthTexture,0);let $=G.__webglTexture,H=ne(x);if(x.depthTexture.format===Si)gt(x)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,$,0,H):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,$,0);else if(x.depthTexture.format===Oi)gt(x)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,$,0,H):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,$,0);else throw new Error("Unknown depthTexture format")}function Ht(E){let x=n.get(E),F=E.isWebGLCubeRenderTarget===!0;if(x.__boundDepthTexture!==E.depthTexture){let G=E.depthTexture;if(x.__depthDisposeCallback&&x.__depthDisposeCallback(),G){let $=()=>{delete x.__boundDepthTexture,delete x.__depthDisposeCallback,G.removeEventListener("dispose",$)};G.addEventListener("dispose",$),x.__depthDisposeCallback=$}x.__boundDepthTexture=G}if(E.depthTexture&&!x.__autoAllocateDepthBuffer){if(F)throw new Error("target.depthTexture not supported in Cube render targets");let G=E.texture.mipmaps;G&&G.length>0?Mt(x.__webglFramebuffer[0],E):Mt(x.__webglFramebuffer,E)}else if(F){x.__webglDepthbuffer=[];for(let G=0;G<6;G++)if(e.bindFramebuffer(i.FRAMEBUFFER,x.__webglFramebuffer[G]),x.__webglDepthbuffer[G]===void 0)x.__webglDepthbuffer[G]=i.createRenderbuffer(),Ct(x.__webglDepthbuffer[G],E,!1);else{let $=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,H=x.__webglDepthbuffer[G];i.bindRenderbuffer(i.RENDERBUFFER,H),i.framebufferRenderbuffer(i.FRAMEBUFFER,$,i.RENDERBUFFER,H)}}else{let G=E.texture.mipmaps;if(G&&G.length>0?e.bindFramebuffer(i.FRAMEBUFFER,x.__webglFramebuffer[0]):e.bindFramebuffer(i.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=i.createRenderbuffer(),Ct(x.__webglDepthbuffer,E,!1);else{let $=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,H=x.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,H),i.framebufferRenderbuffer(i.FRAMEBUFFER,$,i.RENDERBUFFER,H)}}e.bindFramebuffer(i.FRAMEBUFFER,null)}function ge(E,x,F){let G=n.get(E);x!==void 0&&dt(G.__webglFramebuffer,E,E.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),F!==void 0&&Ht(E)}function A(E){let x=E.texture,F=n.get(E),G=n.get(x);E.addEventListener("dispose",C);let $=E.textures,H=E.isWebGLCubeRenderTarget===!0,vt=$.length>1;if(vt||(G.__webglTexture===void 0&&(G.__webglTexture=i.createTexture()),G.__version=x.version,a.memory.textures++),H){F.__webglFramebuffer=[];for(let nt=0;nt<6;nt++)if(x.mipmaps&&x.mipmaps.length>0){F.__webglFramebuffer[nt]=[];for(let _t=0;_t<x.mipmaps.length;_t++)F.__webglFramebuffer[nt][_t]=i.createFramebuffer()}else F.__webglFramebuffer[nt]=i.createFramebuffer()}else{if(x.mipmaps&&x.mipmaps.length>0){F.__webglFramebuffer=[];for(let nt=0;nt<x.mipmaps.length;nt++)F.__webglFramebuffer[nt]=i.createFramebuffer()}else F.__webglFramebuffer=i.createFramebuffer();if(vt)for(let nt=0,_t=$.length;nt<_t;nt++){let xt=n.get($[nt]);xt.__webglTexture===void 0&&(xt.__webglTexture=i.createTexture(),a.memory.textures++)}if(E.samples>0&&gt(E)===!1){F.__webglMultisampledFramebuffer=i.createFramebuffer(),F.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let nt=0;nt<$.length;nt++){let _t=$[nt];F.__webglColorRenderbuffer[nt]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,F.__webglColorRenderbuffer[nt]);let xt=r.convert(_t.format,_t.colorSpace),Q=r.convert(_t.type),lt=M(_t.internalFormat,xt,Q,_t.colorSpace,E.isXRRenderTarget===!0),wt=ne(E);i.renderbufferStorageMultisample(i.RENDERBUFFER,wt,lt,E.width,E.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+nt,i.RENDERBUFFER,F.__webglColorRenderbuffer[nt])}i.bindRenderbuffer(i.RENDERBUFFER,null),E.depthBuffer&&(F.__webglDepthRenderbuffer=i.createRenderbuffer(),Ct(F.__webglDepthRenderbuffer,E,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(H){e.bindTexture(i.TEXTURE_CUBE_MAP,G.__webglTexture),Bt(i.TEXTURE_CUBE_MAP,x);for(let nt=0;nt<6;nt++)if(x.mipmaps&&x.mipmaps.length>0)for(let _t=0;_t<x.mipmaps.length;_t++)dt(F.__webglFramebuffer[nt][_t],E,x,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+nt,_t);else dt(F.__webglFramebuffer[nt],E,x,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+nt,0);m(x)&&d(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(vt){for(let nt=0,_t=$.length;nt<_t;nt++){let xt=$[nt],Q=n.get(xt),lt=i.TEXTURE_2D;(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(lt=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(lt,Q.__webglTexture),Bt(lt,xt),dt(F.__webglFramebuffer,E,xt,i.COLOR_ATTACHMENT0+nt,lt,0),m(xt)&&d(lt)}e.unbindTexture()}else{let nt=i.TEXTURE_2D;if((E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(nt=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(nt,G.__webglTexture),Bt(nt,x),x.mipmaps&&x.mipmaps.length>0)for(let _t=0;_t<x.mipmaps.length;_t++)dt(F.__webglFramebuffer[_t],E,x,i.COLOR_ATTACHMENT0,nt,_t);else dt(F.__webglFramebuffer,E,x,i.COLOR_ATTACHMENT0,nt,0);m(x)&&d(nt),e.unbindTexture()}E.depthBuffer&&Ht(E)}function ee(E){let x=E.textures;for(let F=0,G=x.length;F<G;F++){let $=x[F];if(m($)){let H=T(E),vt=n.get($).__webglTexture;e.bindTexture(H,vt),d(H),e.unbindTexture()}}}let It=[],At=[];function mt(E){if(E.samples>0){if(gt(E)===!1){let x=E.textures,F=E.width,G=E.height,$=i.COLOR_BUFFER_BIT,H=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,vt=n.get(E),nt=x.length>1;if(nt)for(let xt=0;xt<x.length;xt++)e.bindFramebuffer(i.FRAMEBUFFER,vt.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+xt,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,vt.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+xt,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,vt.__webglMultisampledFramebuffer);let _t=E.texture.mipmaps;_t&&_t.length>0?e.bindFramebuffer(i.DRAW_FRAMEBUFFER,vt.__webglFramebuffer[0]):e.bindFramebuffer(i.DRAW_FRAMEBUFFER,vt.__webglFramebuffer);for(let xt=0;xt<x.length;xt++){if(E.resolveDepthBuffer&&(E.depthBuffer&&($|=i.DEPTH_BUFFER_BIT),E.stencilBuffer&&E.resolveStencilBuffer&&($|=i.STENCIL_BUFFER_BIT)),nt){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,vt.__webglColorRenderbuffer[xt]);let Q=n.get(x[xt]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Q,0)}i.blitFramebuffer(0,0,F,G,0,0,F,G,$,i.NEAREST),c===!0&&(It.length=0,At.length=0,It.push(i.COLOR_ATTACHMENT0+xt),E.depthBuffer&&E.resolveDepthBuffer===!1&&(It.push(H),At.push(H),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,At)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,It))}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),nt)for(let xt=0;xt<x.length;xt++){e.bindFramebuffer(i.FRAMEBUFFER,vt.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+xt,i.RENDERBUFFER,vt.__webglColorRenderbuffer[xt]);let Q=n.get(x[xt]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,vt.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+xt,i.TEXTURE_2D,Q,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,vt.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.resolveDepthBuffer===!1&&c){let x=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[x])}}}function ne(E){return Math.min(s.maxSamples,E.samples)}function gt(E){let x=n.get(E);return E.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function Nt(E){let x=a.render.frame;h.get(E)!==x&&(h.set(E,x),E.update())}function pe(E,x){let F=E.colorSpace,G=E.format,$=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||F!==$n&&F!==bn&&(Vt.getTransfer(F)===qt?(G!==qe||$!==an)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",F)),x}function le(E){return typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement?(l.width=E.naturalWidth||E.width,l.height=E.naturalHeight||E.height):typeof VideoFrame<"u"&&E instanceof VideoFrame?(l.width=E.displayWidth,l.height=E.displayHeight):(l.width=E.width,l.height=E.height),l}this.allocateTextureUnit=V,this.resetTextureUnits=B,this.setTexture2D=Z,this.setTexture2DArray=W,this.setTexture3D=et,this.setTextureCube=k,this.rebindTextures=ge,this.setupRenderTarget=A,this.updateRenderTargetMipmap=ee,this.updateMultisampleRenderTarget=mt,this.setupDepthRenderbuffer=Ht,this.setupFrameBufferTexture=dt,this.useMultisampledRTT=gt}function qm(i,t){function e(n,s=bn){let r,a=Vt.getTransfer(s);if(n===an)return i.UNSIGNED_BYTE;if(n===Xr)return i.UNSIGNED_SHORT_4_4_4_4;if(n===qr)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Ro)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Co)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===wo)return i.BYTE;if(n===Ao)return i.SHORT;if(n===Ui)return i.UNSIGNED_SHORT;if(n===Wr)return i.INT;if(n===Bn)return i.UNSIGNED_INT;if(n===on)return i.FLOAT;if(n===Ni)return i.HALF_FLOAT;if(n===Po)return i.ALPHA;if(n===Io)return i.RGB;if(n===qe)return i.RGBA;if(n===Si)return i.DEPTH_COMPONENT;if(n===Oi)return i.DEPTH_STENCIL;if(n===Lo)return i.RED;if(n===Yr)return i.RED_INTEGER;if(n===Do)return i.RG;if(n===Zr)return i.RG_INTEGER;if(n===$r)return i.RGBA_INTEGER;if(n===As||n===Rs||n===Cs||n===Ps)if(a===qt)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===As)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Rs)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Cs)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ps)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===As)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Rs)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Cs)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ps)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Jr||n===Kr||n===jr||n===Qr)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Jr)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Kr)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===jr)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Qr)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ta||n===ea||n===na)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===ta||n===ea)return a===qt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===na)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===ia||n===sa||n===ra||n===aa||n===oa||n===la||n===ca||n===ha||n===ua||n===da||n===fa||n===pa||n===ma||n===ga)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===ia)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===sa)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===ra)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===aa)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===oa)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===la)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===ca)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===ha)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ua)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===da)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===fa)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===pa)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===ma)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ga)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===_a||n===xa||n===ya)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===_a)return a===qt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===xa)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===ya)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===va||n===Ma||n===ba||n===Sa)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===va)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Ma)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===ba)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Sa)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Fi?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}var Ym=`
3816
+ }`;function Ib(n,e,t){let i=new ia,r=new ke,s=new ke,a=new mt,o=new Go({depthPacking:Yf}),l=new Wo,c={},h=t.maxTextureSize,u={[li]:Qt,[Qt]:li,[Mn]:Mn},d=new sn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ke},radius:{value:4}},vertexShader:Rb,fragmentShader:Pb}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let g=new Tt;g.setAttribute("position",new wt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new Xt(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ih;let p=this.type;this.render=function(T,R,k){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||T.length===0)return;let w=n.getRenderTarget(),b=n.getActiveCubeFace(),D=n.getActiveMipmapLevel(),V=n.state;V.setBlending(Un),V.buffers.depth.getReversed()===!0?V.buffers.color.setClear(0,0,0,0):V.buffers.color.setClear(1,1,1,1),V.buffers.depth.setTest(!0),V.setScissorTest(!1);let W=p!==qn&&this.type===qn,Y=p===qn&&this.type!==qn;for(let j=0,X=T.length;j<X;j++){let re=T[j],H=re.shadow;if(H===void 0){console.warn("THREE.WebGLShadowMap:",re,"has no shadow.");continue}if(H.autoUpdate===!1&&H.needsUpdate===!1)continue;r.copy(H.mapSize);let oe=H.getFrameExtents();if(r.multiply(oe),s.copy(H.mapSize),(r.x>h||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/oe.x),r.x=s.x*oe.x,H.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/oe.y),r.y=s.y*oe.y,H.mapSize.y=s.y)),H.map===null||W===!0||Y===!0){let Me=this.type!==qn?{minFilter:Bt,magFilter:Bt}:{};H.map!==null&&H.map.dispose(),H.map=new Sn(r.x,r.y,Me),H.map.texture.name=re.name+".shadowMap",H.camera.updateProjectionMatrix()}n.setRenderTarget(H.map),n.clear();let ee=H.getViewportCount();for(let Me=0;Me<ee;Me++){let $e=H.getViewport(Me);a.set(s.x*$e.x,s.y*$e.y,s.x*$e.z,s.y*$e.w),V.viewport(a),H.updateMatrices(re,Me),i=H.getFrustum(),x(R,k,H.camera,re,this.type)}H.isPointLightShadow!==!0&&this.type===qn&&M(H,k),H.needsUpdate=!1}p=this.type,m.needsUpdate=!1,n.setRenderTarget(w,b,D)};function M(T,R){let k=e.update(y);d.defines.VSM_SAMPLES!==T.blurSamples&&(d.defines.VSM_SAMPLES=T.blurSamples,f.defines.VSM_SAMPLES=T.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new Sn(r.x,r.y)),d.uniforms.shadow_pass.value=T.map.texture,d.uniforms.resolution.value=T.mapSize,d.uniforms.radius.value=T.radius,n.setRenderTarget(T.mapPass),n.clear(),n.renderBufferDirect(R,null,k,d,y,null),f.uniforms.shadow_pass.value=T.mapPass.texture,f.uniforms.resolution.value=T.mapSize,f.uniforms.radius.value=T.radius,n.setRenderTarget(T.map),n.clear(),n.renderBufferDirect(R,null,k,f,y,null)}function S(T,R,k,w){let b=null,D=k.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(D!==void 0)b=D;else if(b=k.isPointLight===!0?l:o,n.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){let V=b.uuid,W=R.uuid,Y=c[V];Y===void 0&&(Y={},c[V]=Y);let j=Y[W];j===void 0&&(j=b.clone(),Y[W]=j,R.addEventListener("dispose",A)),b=j}if(b.visible=R.visible,b.wireframe=R.wireframe,w===qn?b.side=R.shadowSide!==null?R.shadowSide:R.side:b.side=R.shadowSide!==null?R.shadowSide:u[R.side],b.alphaMap=R.alphaMap,b.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,b.map=R.map,b.clipShadows=R.clipShadows,b.clippingPlanes=R.clippingPlanes,b.clipIntersection=R.clipIntersection,b.displacementMap=R.displacementMap,b.displacementScale=R.displacementScale,b.displacementBias=R.displacementBias,b.wireframeLinewidth=R.wireframeLinewidth,b.linewidth=R.linewidth,k.isPointLight===!0&&b.isMeshDistanceMaterial===!0){let V=n.properties.get(b);V.light=k}return b}function x(T,R,k,w,b){if(T.visible===!1)return;if(T.layers.test(R.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&b===qn)&&(!T.frustumCulled||i.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(k.matrixWorldInverse,T.matrixWorld);let W=e.update(T),Y=T.material;if(Array.isArray(Y)){let j=W.groups;for(let X=0,re=j.length;X<re;X++){let H=j[X],oe=Y[H.materialIndex];if(oe&&oe.visible){let ee=S(T,oe,w,b);T.onBeforeShadow(n,T,R,k,W,ee,H),n.renderBufferDirect(k,null,W,ee,T,H),T.onAfterShadow(n,T,R,k,W,ee,H)}}}else if(Y.visible){let j=S(T,Y,w,b);T.onBeforeShadow(n,T,R,k,W,j,null),n.renderBufferDirect(k,null,W,j,T,null),T.onAfterShadow(n,T,R,k,W,j,null)}}let V=T.children;for(let W=0,Y=V.length;W<Y;W++)x(V[W],R,k,w,b)}function A(T){T.target.removeEventListener("dispose",A);for(let k in c){let w=c[k],b=T.target.uuid;b in w&&(w[b].dispose(),delete w[b])}}}var Lb={[tl]:nl,[il]:al,[rl]:ol,[nr]:sl,[nl]:tl,[al]:il,[ol]:rl,[sl]:nr};function Db(n,e){function t(){let L=!1,ie=new mt,le=null,ye=new mt(0,0,0,0);return{setMask:function(Q){le!==Q&&!L&&(n.colorMask(Q,Q,Q,Q),le=Q)},setLocked:function(Q){L=Q},setClear:function(Q,Z,_e,Fe,ut){ut===!0&&(Q*=Fe,Z*=Fe,_e*=Fe),ie.set(Q,Z,_e,Fe),ye.equals(ie)===!1&&(n.clearColor(Q,Z,_e,Fe),ye.copy(ie))},reset:function(){L=!1,le=null,ye.set(-1,0,0,0)}}}function i(){let L=!1,ie=!1,le=null,ye=null,Q=null;return{setReversed:function(Z){if(ie!==Z){let _e=e.get("EXT_clip_control");Z?_e.clipControlEXT(_e.LOWER_LEFT_EXT,_e.ZERO_TO_ONE_EXT):_e.clipControlEXT(_e.LOWER_LEFT_EXT,_e.NEGATIVE_ONE_TO_ONE_EXT),ie=Z;let Fe=Q;Q=null,this.setClear(Fe)}},getReversed:function(){return ie},setTest:function(Z){Z?J(n.DEPTH_TEST):me(n.DEPTH_TEST)},setMask:function(Z){le!==Z&&!L&&(n.depthMask(Z),le=Z)},setFunc:function(Z){if(ie&&(Z=Lb[Z]),ye!==Z){switch(Z){case tl:n.depthFunc(n.NEVER);break;case nl:n.depthFunc(n.ALWAYS);break;case il:n.depthFunc(n.LESS);break;case nr:n.depthFunc(n.LEQUAL);break;case rl:n.depthFunc(n.EQUAL);break;case sl:n.depthFunc(n.GEQUAL);break;case al:n.depthFunc(n.GREATER);break;case ol:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}ye=Z}},setLocked:function(Z){L=Z},setClear:function(Z){Q!==Z&&(ie&&(Z=1-Z),n.clearDepth(Z),Q=Z)},reset:function(){L=!1,le=null,ye=null,Q=null,ie=!1}}}function r(){let L=!1,ie=null,le=null,ye=null,Q=null,Z=null,_e=null,Fe=null,ut=null;return{setTest:function(nt){L||(nt?J(n.STENCIL_TEST):me(n.STENCIL_TEST))},setMask:function(nt){ie!==nt&&!L&&(n.stencilMask(nt),ie=nt)},setFunc:function(nt,Kn,Bn){(le!==nt||ye!==Kn||Q!==Bn)&&(n.stencilFunc(nt,Kn,Bn),le=nt,ye=Kn,Q=Bn)},setOp:function(nt,Kn,Bn){(Z!==nt||_e!==Kn||Fe!==Bn)&&(n.stencilOp(nt,Kn,Bn),Z=nt,_e=Kn,Fe=Bn)},setLocked:function(nt){L=nt},setClear:function(nt){ut!==nt&&(n.clearStencil(nt),ut=nt)},reset:function(){L=!1,ie=null,le=null,ye=null,Q=null,Z=null,_e=null,Fe=null,ut=null}}}let s=new t,a=new i,o=new r,l=new WeakMap,c=new WeakMap,h={},u={},d=new WeakMap,f=[],g=null,y=!1,m=null,p=null,M=null,S=null,x=null,A=null,T=null,R=new Ze(0,0,0),k=0,w=!1,b=null,D=null,V=null,W=null,Y=null,j=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS),X=!1,re=0,H=n.getParameter(n.VERSION);H.indexOf("WebGL")!==-1?(re=parseFloat(/^WebGL (\d)/.exec(H)[1]),X=re>=1):H.indexOf("OpenGL ES")!==-1&&(re=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),X=re>=2);let oe=null,ee={},Me=n.getParameter(n.SCISSOR_BOX),$e=n.getParameter(n.VIEWPORT),rt=new mt().fromArray(Me),Ue=new mt().fromArray($e);function qe(L,ie,le,ye){let Q=new Uint8Array(4),Z=n.createTexture();n.bindTexture(L,Z),n.texParameteri(L,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(L,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let _e=0;_e<le;_e++)L===n.TEXTURE_3D||L===n.TEXTURE_2D_ARRAY?n.texImage3D(ie,0,n.RGBA,1,1,ye,0,n.RGBA,n.UNSIGNED_BYTE,Q):n.texImage2D(ie+_e,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,Q);return Z}let $={};$[n.TEXTURE_2D]=qe(n.TEXTURE_2D,n.TEXTURE_2D,1),$[n.TEXTURE_CUBE_MAP]=qe(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),$[n.TEXTURE_2D_ARRAY]=qe(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),$[n.TEXTURE_3D]=qe(n.TEXTURE_3D,n.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),J(n.DEPTH_TEST),a.setFunc(nr),Ne(!1),be(Ph),J(n.CULL_FACE),ht(Un);function J(L){h[L]!==!0&&(n.enable(L),h[L]=!0)}function me(L){h[L]!==!1&&(n.disable(L),h[L]=!1)}function ve(L,ie){return u[L]!==ie?(n.bindFramebuffer(L,ie),u[L]=ie,L===n.DRAW_FRAMEBUFFER&&(u[n.FRAMEBUFFER]=ie),L===n.FRAMEBUFFER&&(u[n.DRAW_FRAMEBUFFER]=ie),!0):!1}function ue(L,ie){let le=f,ye=!1;if(L){le=d.get(ie),le===void 0&&(le=[],d.set(ie,le));let Q=L.textures;if(le.length!==Q.length||le[0]!==n.COLOR_ATTACHMENT0){for(let Z=0,_e=Q.length;Z<_e;Z++)le[Z]=n.COLOR_ATTACHMENT0+Z;le.length=Q.length,ye=!0}}else le[0]!==n.BACK&&(le[0]=n.BACK,ye=!0);ye&&n.drawBuffers(le)}function Je(L){return g!==L?(n.useProgram(L),g=L,!0):!1}let At={[Ti]:n.FUNC_ADD,[_f]:n.FUNC_SUBTRACT,[bf]:n.FUNC_REVERSE_SUBTRACT};At[Sf]=n.MIN,At[wf]=n.MAX;let C={[Mf]:n.ZERO,[Ef]:n.ONE,[Tf]:n.SRC_COLOR,[Ro]:n.SRC_ALPHA,[Lf]:n.SRC_ALPHA_SATURATE,[Pf]:n.DST_COLOR,[Cf]:n.DST_ALPHA,[Af]:n.ONE_MINUS_SRC_COLOR,[Po]:n.ONE_MINUS_SRC_ALPHA,[If]:n.ONE_MINUS_DST_COLOR,[Rf]:n.ONE_MINUS_DST_ALPHA,[Df]:n.CONSTANT_COLOR,[kf]:n.ONE_MINUS_CONSTANT_COLOR,[Nf]:n.CONSTANT_ALPHA,[Of]:n.ONE_MINUS_CONSTANT_ALPHA};function ht(L,ie,le,ye,Q,Z,_e,Fe,ut,nt){if(L===Un){y===!0&&(me(n.BLEND),y=!1);return}if(y===!1&&(J(n.BLEND),y=!0),L!==xf){if(L!==m||nt!==w){if((p!==Ti||x!==Ti)&&(n.blendEquation(n.FUNC_ADD),p=Ti,x=Ti),nt)switch(L){case tr:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Lh:n.blendFunc(n.ONE,n.ONE);break;case Dh:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case kh:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",L);break}else switch(L){case tr:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Lh:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case Dh:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case kh:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",L);break}M=null,S=null,A=null,T=null,R.set(0,0,0),k=0,m=L,w=nt}return}Q=Q||ie,Z=Z||le,_e=_e||ye,(ie!==p||Q!==x)&&(n.blendEquationSeparate(At[ie],At[Q]),p=ie,x=Q),(le!==M||ye!==S||Z!==A||_e!==T)&&(n.blendFuncSeparate(C[le],C[ye],C[Z],C[_e]),M=le,S=ye,A=Z,T=_e),(Fe.equals(R)===!1||ut!==k)&&(n.blendColor(Fe.r,Fe.g,Fe.b,ut),R.copy(Fe),k=ut),m=L,w=!1}function Be(L,ie){L.side===Mn?me(n.CULL_FACE):J(n.CULL_FACE);let le=L.side===Qt;ie&&(le=!le),Ne(le),L.blending===tr&&L.transparent===!1?ht(Un):ht(L.blending,L.blendEquation,L.blendSrc,L.blendDst,L.blendEquationAlpha,L.blendSrcAlpha,L.blendDstAlpha,L.blendColor,L.blendAlpha,L.premultipliedAlpha),a.setFunc(L.depthFunc),a.setTest(L.depthTest),a.setMask(L.depthWrite),s.setMask(L.colorWrite);let ye=L.stencilWrite;o.setTest(ye),ye&&(o.setMask(L.stencilWriteMask),o.setFunc(L.stencilFunc,L.stencilRef,L.stencilFuncMask),o.setOp(L.stencilFail,L.stencilZFail,L.stencilZPass)),Se(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?J(n.SAMPLE_ALPHA_TO_COVERAGE):me(n.SAMPLE_ALPHA_TO_COVERAGE)}function Ne(L){b!==L&&(L?n.frontFace(n.CW):n.frontFace(n.CCW),b=L)}function be(L){L!==gf?(J(n.CULL_FACE),L!==D&&(L===Ph?n.cullFace(n.BACK):L===yf?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):me(n.CULL_FACE),D=L}function gt(L){L!==V&&(X&&n.lineWidth(L),V=L)}function Se(L,ie,le){L?(J(n.POLYGON_OFFSET_FILL),(W!==ie||Y!==le)&&(n.polygonOffset(ie,le),W=ie,Y=le)):me(n.POLYGON_OFFSET_FILL)}function He(L){L?J(n.SCISSOR_TEST):me(n.SCISSOR_TEST)}function Lt(L){L===void 0&&(L=n.TEXTURE0+j-1),oe!==L&&(n.activeTexture(L),oe=L)}function bt(L,ie,le){le===void 0&&(oe===null?le=n.TEXTURE0+j-1:le=oe);let ye=ee[le];ye===void 0&&(ye={type:void 0,texture:void 0},ee[le]=ye),(ye.type!==L||ye.texture!==ie)&&(oe!==le&&(n.activeTexture(le),oe=le),n.bindTexture(L,ie||$[L]),ye.type=L,ye.texture=ie)}function E(){let L=ee[oe];L!==void 0&&L.type!==void 0&&(n.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function v(){try{n.compressedTexImage2D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function F(){try{n.compressedTexImage3D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function q(){try{n.texSubImage2D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function K(){try{n.texSubImage3D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function G(){try{n.compressedTexSubImage2D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function Ae(){try{n.compressedTexSubImage3D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function ae(){try{n.texStorage2D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function we(){try{n.texStorage3D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function Ee(){try{n.texImage2D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function ne(){try{n.texImage3D(...arguments)}catch(L){console.error("THREE.WebGLState:",L)}}function fe(L){rt.equals(L)===!1&&(n.scissor(L.x,L.y,L.z,L.w),rt.copy(L))}function Le(L){Ue.equals(L)===!1&&(n.viewport(L.x,L.y,L.z,L.w),Ue.copy(L))}function Te(L,ie){let le=c.get(ie);le===void 0&&(le=new WeakMap,c.set(ie,le));let ye=le.get(L);ye===void 0&&(ye=n.getUniformBlockIndex(ie,L.name),le.set(L,ye))}function he(L,ie){let ye=c.get(ie).get(L);l.get(ie)!==ye&&(n.uniformBlockBinding(ie,ye,L.__bindingPointIndex),l.set(ie,ye))}function Ve(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),a.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),h={},oe=null,ee={},u={},d=new WeakMap,f=[],g=null,y=!1,m=null,p=null,M=null,S=null,x=null,A=null,T=null,R=new Ze(0,0,0),k=0,w=!1,b=null,D=null,V=null,W=null,Y=null,rt.set(0,0,n.canvas.width,n.canvas.height),Ue.set(0,0,n.canvas.width,n.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:J,disable:me,bindFramebuffer:ve,drawBuffers:ue,useProgram:Je,setBlending:ht,setMaterial:Be,setFlipSided:Ne,setCullFace:be,setLineWidth:gt,setPolygonOffset:Se,setScissorTest:He,activeTexture:Lt,bindTexture:bt,unbindTexture:E,compressedTexImage2D:v,compressedTexImage3D:F,texImage2D:Ee,texImage3D:ne,updateUBOMapping:Te,uniformBlockBinding:he,texStorage2D:ae,texStorage3D:we,texSubImage2D:q,texSubImage3D:K,compressedTexSubImage2D:G,compressedTexSubImage3D:Ae,scissor:fe,viewport:Le,reset:Ve}}function kb(n,e,t,i,r,s,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 ke,h=new WeakMap,u,d=new WeakMap,f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(E,v){return f?new OffscreenCanvas(E,v):Ys("canvas")}function y(E,v,F){let q=1,K=bt(E);if((K.width>F||K.height>F)&&(q=F/Math.max(K.width,K.height)),q<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 G=Math.floor(q*K.width),Ae=Math.floor(q*K.height);u===void 0&&(u=g(G,Ae));let ae=v?g(G,Ae):u;return ae.width=G,ae.height=Ae,ae.getContext("2d").drawImage(E,0,0,G,Ae),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+G+"x"+Ae+")."),ae}else return"data"in E&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),E;return E}function m(E){return E.generateMipmaps}function p(E){n.generateMipmap(E)}function M(E){return E.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:E.isWebGL3DRenderTarget?n.TEXTURE_3D:E.isWebGLArrayRenderTarget||E.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function S(E,v,F,q,K=!1){if(E!==null){if(n[E]!==void 0)return n[E];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let G=v;if(v===n.RED&&(F===n.FLOAT&&(G=n.R32F),F===n.HALF_FLOAT&&(G=n.R16F),F===n.UNSIGNED_BYTE&&(G=n.R8)),v===n.RED_INTEGER&&(F===n.UNSIGNED_BYTE&&(G=n.R8UI),F===n.UNSIGNED_SHORT&&(G=n.R16UI),F===n.UNSIGNED_INT&&(G=n.R32UI),F===n.BYTE&&(G=n.R8I),F===n.SHORT&&(G=n.R16I),F===n.INT&&(G=n.R32I)),v===n.RG&&(F===n.FLOAT&&(G=n.RG32F),F===n.HALF_FLOAT&&(G=n.RG16F),F===n.UNSIGNED_BYTE&&(G=n.RG8)),v===n.RG_INTEGER&&(F===n.UNSIGNED_BYTE&&(G=n.RG8UI),F===n.UNSIGNED_SHORT&&(G=n.RG16UI),F===n.UNSIGNED_INT&&(G=n.RG32UI),F===n.BYTE&&(G=n.RG8I),F===n.SHORT&&(G=n.RG16I),F===n.INT&&(G=n.RG32I)),v===n.RGB_INTEGER&&(F===n.UNSIGNED_BYTE&&(G=n.RGB8UI),F===n.UNSIGNED_SHORT&&(G=n.RGB16UI),F===n.UNSIGNED_INT&&(G=n.RGB32UI),F===n.BYTE&&(G=n.RGB8I),F===n.SHORT&&(G=n.RGB16I),F===n.INT&&(G=n.RGB32I)),v===n.RGBA_INTEGER&&(F===n.UNSIGNED_BYTE&&(G=n.RGBA8UI),F===n.UNSIGNED_SHORT&&(G=n.RGBA16UI),F===n.UNSIGNED_INT&&(G=n.RGBA32UI),F===n.BYTE&&(G=n.RGBA8I),F===n.SHORT&&(G=n.RGBA16I),F===n.INT&&(G=n.RGBA32I)),v===n.RGB&&(F===n.UNSIGNED_INT_5_9_9_9_REV&&(G=n.RGB9_E5),F===n.UNSIGNED_INT_10F_11F_11F_REV&&(G=n.R11F_G11F_B10F)),v===n.RGBA){let Ae=K?Xs:Ke.getTransfer(q);F===n.FLOAT&&(G=n.RGBA32F),F===n.HALF_FLOAT&&(G=n.RGBA16F),F===n.UNSIGNED_BYTE&&(G=Ae===at?n.SRGB8_ALPHA8:n.RGBA8),F===n.UNSIGNED_SHORT_4_4_4_4&&(G=n.RGBA4),F===n.UNSIGNED_SHORT_5_5_5_1&&(G=n.RGB5_A1)}return(G===n.R16F||G===n.R32F||G===n.RG16F||G===n.RG32F||G===n.RGBA16F||G===n.RGBA32F)&&e.get("EXT_color_buffer_float"),G}function x(E,v){let F;return E?v===null||v===Li||v===as?F=n.DEPTH24_STENCIL8:v===En?F=n.DEPTH32F_STENCIL8:v===rs&&(F=n.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):v===null||v===Li||v===as?F=n.DEPTH_COMPONENT24:v===En?F=n.DEPTH_COMPONENT32F:v===rs&&(F=n.DEPTH_COMPONENT16),F}function A(E,v){return m(E)===!0||E.isFramebufferTexture&&E.minFilter!==Bt&&E.minFilter!==kn?Math.log2(Math.max(v.width,v.height))+1:E.mipmaps!==void 0&&E.mipmaps.length>0?E.mipmaps.length:E.isCompressedTexture&&Array.isArray(E.image)?v.mipmaps.length:1}function T(E){let v=E.target;v.removeEventListener("dispose",T),k(v),v.isVideoTexture&&h.delete(v)}function R(E){let v=E.target;v.removeEventListener("dispose",R),b(v)}function k(E){let v=i.get(E);if(v.__webglInit===void 0)return;let F=E.source,q=d.get(F);if(q){let K=q[v.__cacheKey];K.usedTimes--,K.usedTimes===0&&w(E),Object.keys(q).length===0&&d.delete(F)}i.remove(E)}function w(E){let v=i.get(E);n.deleteTexture(v.__webglTexture);let F=E.source,q=d.get(F);delete q[v.__cacheKey],a.memory.textures--}function b(E){let v=i.get(E);if(E.depthTexture&&(E.depthTexture.dispose(),i.remove(E.depthTexture)),E.isWebGLCubeRenderTarget)for(let q=0;q<6;q++){if(Array.isArray(v.__webglFramebuffer[q]))for(let K=0;K<v.__webglFramebuffer[q].length;K++)n.deleteFramebuffer(v.__webglFramebuffer[q][K]);else n.deleteFramebuffer(v.__webglFramebuffer[q]);v.__webglDepthbuffer&&n.deleteRenderbuffer(v.__webglDepthbuffer[q])}else{if(Array.isArray(v.__webglFramebuffer))for(let q=0;q<v.__webglFramebuffer.length;q++)n.deleteFramebuffer(v.__webglFramebuffer[q]);else n.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer&&n.deleteRenderbuffer(v.__webglDepthbuffer),v.__webglMultisampledFramebuffer&&n.deleteFramebuffer(v.__webglMultisampledFramebuffer),v.__webglColorRenderbuffer)for(let q=0;q<v.__webglColorRenderbuffer.length;q++)v.__webglColorRenderbuffer[q]&&n.deleteRenderbuffer(v.__webglColorRenderbuffer[q]);v.__webglDepthRenderbuffer&&n.deleteRenderbuffer(v.__webglDepthRenderbuffer)}let F=E.textures;for(let q=0,K=F.length;q<K;q++){let G=i.get(F[q]);G.__webglTexture&&(n.deleteTexture(G.__webglTexture),a.memory.textures--),i.remove(F[q])}i.remove(E)}let D=0;function V(){D=0}function W(){let E=D;return E>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+r.maxTextures),D+=1,E}function Y(E){let v=[];return v.push(E.wrapS),v.push(E.wrapT),v.push(E.wrapR||0),v.push(E.magFilter),v.push(E.minFilter),v.push(E.anisotropy),v.push(E.internalFormat),v.push(E.format),v.push(E.type),v.push(E.generateMipmaps),v.push(E.premultiplyAlpha),v.push(E.flipY),v.push(E.unpackAlignment),v.push(E.colorSpace),v.join()}function j(E,v){let F=i.get(E);if(E.isVideoTexture&&He(E),E.isRenderTargetTexture===!1&&E.isExternalTexture!==!0&&E.version>0&&F.__version!==E.version){let q=E.image;if(q===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(q.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{$(F,E,v);return}}else E.isExternalTexture&&(F.__webglTexture=E.sourceTexture?E.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,F.__webglTexture,n.TEXTURE0+v)}function X(E,v){let F=i.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&F.__version!==E.version){$(F,E,v);return}t.bindTexture(n.TEXTURE_2D_ARRAY,F.__webglTexture,n.TEXTURE0+v)}function re(E,v){let F=i.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&F.__version!==E.version){$(F,E,v);return}t.bindTexture(n.TEXTURE_3D,F.__webglTexture,n.TEXTURE0+v)}function H(E,v){let F=i.get(E);if(E.version>0&&F.__version!==E.version){J(F,E,v);return}t.bindTexture(n.TEXTURE_CUBE_MAP,F.__webglTexture,n.TEXTURE0+v)}let oe={[Io]:n.REPEAT,[Ei]:n.CLAMP_TO_EDGE,[Lo]:n.MIRRORED_REPEAT},ee={[Bt]:n.NEAREST,[Xf]:n.NEAREST_MIPMAP_NEAREST,[da]:n.NEAREST_MIPMAP_LINEAR,[kn]:n.LINEAR,[hl]:n.LINEAR_MIPMAP_NEAREST,[Ii]:n.LINEAR_MIPMAP_LINEAR},Me={[Jf]:n.NEVER,[ip]:n.ALWAYS,[Kf]:n.LESS,[$h]:n.LEQUAL,[Qf]:n.EQUAL,[np]:n.GEQUAL,[ep]:n.GREATER,[tp]:n.NOTEQUAL};function $e(E,v){if(v.type===En&&e.has("OES_texture_float_linear")===!1&&(v.magFilter===kn||v.magFilter===hl||v.magFilter===da||v.magFilter===Ii||v.minFilter===kn||v.minFilter===hl||v.minFilter===da||v.minFilter===Ii)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(E,n.TEXTURE_WRAP_S,oe[v.wrapS]),n.texParameteri(E,n.TEXTURE_WRAP_T,oe[v.wrapT]),(E===n.TEXTURE_3D||E===n.TEXTURE_2D_ARRAY)&&n.texParameteri(E,n.TEXTURE_WRAP_R,oe[v.wrapR]),n.texParameteri(E,n.TEXTURE_MAG_FILTER,ee[v.magFilter]),n.texParameteri(E,n.TEXTURE_MIN_FILTER,ee[v.minFilter]),v.compareFunction&&(n.texParameteri(E,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(E,n.TEXTURE_COMPARE_FUNC,Me[v.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===Bt||v.minFilter!==da&&v.minFilter!==Ii||v.type===En&&e.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||i.get(v).__currentAnisotropy){let F=e.get("EXT_texture_filter_anisotropic");n.texParameterf(E,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,r.getMaxAnisotropy())),i.get(v).__currentAnisotropy=v.anisotropy}}}function rt(E,v){let F=!1;E.__webglInit===void 0&&(E.__webglInit=!0,v.addEventListener("dispose",T));let q=v.source,K=d.get(q);K===void 0&&(K={},d.set(q,K));let G=Y(v);if(G!==E.__cacheKey){K[G]===void 0&&(K[G]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,F=!0),K[G].usedTimes++;let Ae=K[E.__cacheKey];Ae!==void 0&&(K[E.__cacheKey].usedTimes--,Ae.usedTimes===0&&w(v)),E.__cacheKey=G,E.__webglTexture=K[G].texture}return F}function Ue(E,v,F){return Math.floor(Math.floor(E/F)/v)}function qe(E,v,F,q){let G=E.updateRanges;if(G.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,v.width,v.height,F,q,v.data);else{G.sort((ne,fe)=>ne.start-fe.start);let Ae=0;for(let ne=1;ne<G.length;ne++){let fe=G[Ae],Le=G[ne],Te=fe.start+fe.count,he=Ue(Le.start,v.width,4),Ve=Ue(fe.start,v.width,4);Le.start<=Te+1&&he===Ve&&Ue(Le.start+Le.count-1,v.width,4)===he?fe.count=Math.max(fe.count,Le.start+Le.count-fe.start):(++Ae,G[Ae]=Le)}G.length=Ae+1;let ae=n.getParameter(n.UNPACK_ROW_LENGTH),we=n.getParameter(n.UNPACK_SKIP_PIXELS),Ee=n.getParameter(n.UNPACK_SKIP_ROWS);n.pixelStorei(n.UNPACK_ROW_LENGTH,v.width);for(let ne=0,fe=G.length;ne<fe;ne++){let Le=G[ne],Te=Math.floor(Le.start/4),he=Math.ceil(Le.count/4),Ve=Te%v.width,L=Math.floor(Te/v.width),ie=he,le=1;n.pixelStorei(n.UNPACK_SKIP_PIXELS,Ve),n.pixelStorei(n.UNPACK_SKIP_ROWS,L),t.texSubImage2D(n.TEXTURE_2D,0,Ve,L,ie,le,F,q,v.data)}E.clearUpdateRanges(),n.pixelStorei(n.UNPACK_ROW_LENGTH,ae),n.pixelStorei(n.UNPACK_SKIP_PIXELS,we),n.pixelStorei(n.UNPACK_SKIP_ROWS,Ee)}}function $(E,v,F){let q=n.TEXTURE_2D;(v.isDataArrayTexture||v.isCompressedArrayTexture)&&(q=n.TEXTURE_2D_ARRAY),v.isData3DTexture&&(q=n.TEXTURE_3D);let K=rt(E,v),G=v.source;t.bindTexture(q,E.__webglTexture,n.TEXTURE0+F);let Ae=i.get(G);if(G.version!==Ae.__version||K===!0){t.activeTexture(n.TEXTURE0+F);let ae=Ke.getPrimaries(Ke.workingColorSpace),we=v.colorSpace===di?null:Ke.getPrimaries(v.colorSpace),Ee=v.colorSpace===di||ae===we?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,v.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ee);let ne=y(v.image,!1,r.maxTextureSize);ne=Lt(v,ne);let fe=s.convert(v.format,v.colorSpace),Le=s.convert(v.type),Te=S(v.internalFormat,fe,Le,v.colorSpace,v.isVideoTexture);$e(q,v);let he,Ve=v.mipmaps,L=v.isVideoTexture!==!0,ie=Ae.__version===void 0||K===!0,le=G.dataReady,ye=A(v,ne);if(v.isDepthTexture)Te=x(v.format===os,v.type),ie&&(L?t.texStorage2D(n.TEXTURE_2D,1,Te,ne.width,ne.height):t.texImage2D(n.TEXTURE_2D,0,Te,ne.width,ne.height,0,fe,Le,null));else if(v.isDataTexture)if(Ve.length>0){L&&ie&&t.texStorage2D(n.TEXTURE_2D,ye,Te,Ve[0].width,Ve[0].height);for(let Q=0,Z=Ve.length;Q<Z;Q++)he=Ve[Q],L?le&&t.texSubImage2D(n.TEXTURE_2D,Q,0,0,he.width,he.height,fe,Le,he.data):t.texImage2D(n.TEXTURE_2D,Q,Te,he.width,he.height,0,fe,Le,he.data);v.generateMipmaps=!1}else L?(ie&&t.texStorage2D(n.TEXTURE_2D,ye,Te,ne.width,ne.height),le&&qe(v,ne,fe,Le)):t.texImage2D(n.TEXTURE_2D,0,Te,ne.width,ne.height,0,fe,Le,ne.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){L&&ie&&t.texStorage3D(n.TEXTURE_2D_ARRAY,ye,Te,Ve[0].width,Ve[0].height,ne.depth);for(let Q=0,Z=Ve.length;Q<Z;Q++)if(he=Ve[Q],v.format!==an)if(fe!==null)if(L){if(le)if(v.layerUpdates.size>0){let _e=Kh(he.width,he.height,v.format,v.type);for(let Fe of v.layerUpdates){let ut=he.data.subarray(Fe*_e/he.data.BYTES_PER_ELEMENT,(Fe+1)*_e/he.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Q,0,0,Fe,he.width,he.height,1,fe,ut)}v.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Q,0,0,0,he.width,he.height,ne.depth,fe,he.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,Q,Te,he.width,he.height,ne.depth,0,he.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else L?le&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,Q,0,0,0,he.width,he.height,ne.depth,fe,Le,he.data):t.texImage3D(n.TEXTURE_2D_ARRAY,Q,Te,he.width,he.height,ne.depth,0,fe,Le,he.data)}else{L&&ie&&t.texStorage2D(n.TEXTURE_2D,ye,Te,Ve[0].width,Ve[0].height);for(let Q=0,Z=Ve.length;Q<Z;Q++)he=Ve[Q],v.format!==an?fe!==null?L?le&&t.compressedTexSubImage2D(n.TEXTURE_2D,Q,0,0,he.width,he.height,fe,he.data):t.compressedTexImage2D(n.TEXTURE_2D,Q,Te,he.width,he.height,0,he.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):L?le&&t.texSubImage2D(n.TEXTURE_2D,Q,0,0,he.width,he.height,fe,Le,he.data):t.texImage2D(n.TEXTURE_2D,Q,Te,he.width,he.height,0,fe,Le,he.data)}else if(v.isDataArrayTexture)if(L){if(ie&&t.texStorage3D(n.TEXTURE_2D_ARRAY,ye,Te,ne.width,ne.height,ne.depth),le)if(v.layerUpdates.size>0){let Q=Kh(ne.width,ne.height,v.format,v.type);for(let Z of v.layerUpdates){let _e=ne.data.subarray(Z*Q/ne.data.BYTES_PER_ELEMENT,(Z+1)*Q/ne.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,Z,ne.width,ne.height,1,fe,Le,_e)}v.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,ne.width,ne.height,ne.depth,fe,Le,ne.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,Te,ne.width,ne.height,ne.depth,0,fe,Le,ne.data);else if(v.isData3DTexture)L?(ie&&t.texStorage3D(n.TEXTURE_3D,ye,Te,ne.width,ne.height,ne.depth),le&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,ne.width,ne.height,ne.depth,fe,Le,ne.data)):t.texImage3D(n.TEXTURE_3D,0,Te,ne.width,ne.height,ne.depth,0,fe,Le,ne.data);else if(v.isFramebufferTexture){if(ie)if(L)t.texStorage2D(n.TEXTURE_2D,ye,Te,ne.width,ne.height);else{let Q=ne.width,Z=ne.height;for(let _e=0;_e<ye;_e++)t.texImage2D(n.TEXTURE_2D,_e,Te,Q,Z,0,fe,Le,null),Q>>=1,Z>>=1}}else if(Ve.length>0){if(L&&ie){let Q=bt(Ve[0]);t.texStorage2D(n.TEXTURE_2D,ye,Te,Q.width,Q.height)}for(let Q=0,Z=Ve.length;Q<Z;Q++)he=Ve[Q],L?le&&t.texSubImage2D(n.TEXTURE_2D,Q,0,0,fe,Le,he):t.texImage2D(n.TEXTURE_2D,Q,Te,fe,Le,he);v.generateMipmaps=!1}else if(L){if(ie){let Q=bt(ne);t.texStorage2D(n.TEXTURE_2D,ye,Te,Q.width,Q.height)}le&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,fe,Le,ne)}else t.texImage2D(n.TEXTURE_2D,0,Te,fe,Le,ne);m(v)&&p(q),Ae.__version=G.version,v.onUpdate&&v.onUpdate(v)}E.__version=v.version}function J(E,v,F){if(v.image.length!==6)return;let q=rt(E,v),K=v.source;t.bindTexture(n.TEXTURE_CUBE_MAP,E.__webglTexture,n.TEXTURE0+F);let G=i.get(K);if(K.version!==G.__version||q===!0){t.activeTexture(n.TEXTURE0+F);let Ae=Ke.getPrimaries(Ke.workingColorSpace),ae=v.colorSpace===di?null:Ke.getPrimaries(v.colorSpace),we=v.colorSpace===di||Ae===ae?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,v.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,we);let Ee=v.isCompressedTexture||v.image[0].isCompressedTexture,ne=v.image[0]&&v.image[0].isDataTexture,fe=[];for(let Z=0;Z<6;Z++)!Ee&&!ne?fe[Z]=y(v.image[Z],!0,r.maxCubemapSize):fe[Z]=ne?v.image[Z].image:v.image[Z],fe[Z]=Lt(v,fe[Z]);let Le=fe[0],Te=s.convert(v.format,v.colorSpace),he=s.convert(v.type),Ve=S(v.internalFormat,Te,he,v.colorSpace),L=v.isVideoTexture!==!0,ie=G.__version===void 0||q===!0,le=K.dataReady,ye=A(v,Le);$e(n.TEXTURE_CUBE_MAP,v);let Q;if(Ee){L&&ie&&t.texStorage2D(n.TEXTURE_CUBE_MAP,ye,Ve,Le.width,Le.height);for(let Z=0;Z<6;Z++){Q=fe[Z].mipmaps;for(let _e=0;_e<Q.length;_e++){let Fe=Q[_e];v.format!==an?Te!==null?L?le&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,_e,0,0,Fe.width,Fe.height,Te,Fe.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,_e,Ve,Fe.width,Fe.height,0,Fe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?le&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,_e,0,0,Fe.width,Fe.height,Te,he,Fe.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,_e,Ve,Fe.width,Fe.height,0,Te,he,Fe.data)}}}else{if(Q=v.mipmaps,L&&ie){Q.length>0&&ye++;let Z=bt(fe[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,ye,Ve,Z.width,Z.height)}for(let Z=0;Z<6;Z++)if(ne){L?le&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,0,0,fe[Z].width,fe[Z].height,Te,he,fe[Z].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,Ve,fe[Z].width,fe[Z].height,0,Te,he,fe[Z].data);for(let _e=0;_e<Q.length;_e++){let ut=Q[_e].image[Z].image;L?le&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,_e+1,0,0,ut.width,ut.height,Te,he,ut.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,_e+1,Ve,ut.width,ut.height,0,Te,he,ut.data)}}else{L?le&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,0,0,Te,he,fe[Z]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,Ve,Te,he,fe[Z]);for(let _e=0;_e<Q.length;_e++){let Fe=Q[_e];L?le&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,_e+1,0,0,Te,he,Fe.image[Z]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,_e+1,Ve,Te,he,Fe.image[Z])}}}m(v)&&p(n.TEXTURE_CUBE_MAP),G.__version=K.version,v.onUpdate&&v.onUpdate(v)}E.__version=v.version}function me(E,v,F,q,K,G){let Ae=s.convert(F.format,F.colorSpace),ae=s.convert(F.type),we=S(F.internalFormat,Ae,ae,F.colorSpace),Ee=i.get(v),ne=i.get(F);if(ne.__renderTarget=v,!Ee.__hasExternalTextures){let fe=Math.max(1,v.width>>G),Le=Math.max(1,v.height>>G);K===n.TEXTURE_3D||K===n.TEXTURE_2D_ARRAY?t.texImage3D(K,G,we,fe,Le,v.depth,0,Ae,ae,null):t.texImage2D(K,G,we,fe,Le,0,Ae,ae,null)}t.bindFramebuffer(n.FRAMEBUFFER,E),Se(v)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,q,K,ne.__webglTexture,0,gt(v)):(K===n.TEXTURE_2D||K>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,q,K,ne.__webglTexture,G),t.bindFramebuffer(n.FRAMEBUFFER,null)}function ve(E,v,F){if(n.bindRenderbuffer(n.RENDERBUFFER,E),v.depthBuffer){let q=v.depthTexture,K=q&&q.isDepthTexture?q.type:null,G=x(v.stencilBuffer,K),Ae=v.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ae=gt(v);Se(v)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ae,G,v.width,v.height):F?n.renderbufferStorageMultisample(n.RENDERBUFFER,ae,G,v.width,v.height):n.renderbufferStorage(n.RENDERBUFFER,G,v.width,v.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,Ae,n.RENDERBUFFER,E)}else{let q=v.textures;for(let K=0;K<q.length;K++){let G=q[K],Ae=s.convert(G.format,G.colorSpace),ae=s.convert(G.type),we=S(G.internalFormat,Ae,ae,G.colorSpace),Ee=gt(v);F&&Se(v)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,Ee,we,v.width,v.height):Se(v)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Ee,we,v.width,v.height):n.renderbufferStorage(n.RENDERBUFFER,we,v.width,v.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function ue(E,v){if(v&&v.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,E),!(v.depthTexture&&v.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");let q=i.get(v.depthTexture);q.__renderTarget=v,(!q.__webglTexture||v.depthTexture.image.width!==v.width||v.depthTexture.image.height!==v.height)&&(v.depthTexture.image.width=v.width,v.depthTexture.image.height=v.height,v.depthTexture.needsUpdate=!0),j(v.depthTexture,0);let K=q.__webglTexture,G=gt(v);if(v.depthTexture.format===Yr)Se(v)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,K,0,G):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,K,0);else if(v.depthTexture.format===os)Se(v)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,K,0,G):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,K,0);else throw new Error("Unknown depthTexture format")}function Je(E){let v=i.get(E),F=E.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==E.depthTexture){let q=E.depthTexture;if(v.__depthDisposeCallback&&v.__depthDisposeCallback(),q){let K=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,q.removeEventListener("dispose",K)};q.addEventListener("dispose",K),v.__depthDisposeCallback=K}v.__boundDepthTexture=q}if(E.depthTexture&&!v.__autoAllocateDepthBuffer){if(F)throw new Error("target.depthTexture not supported in Cube render targets");let q=E.texture.mipmaps;q&&q.length>0?ue(v.__webglFramebuffer[0],E):ue(v.__webglFramebuffer,E)}else if(F){v.__webglDepthbuffer=[];for(let q=0;q<6;q++)if(t.bindFramebuffer(n.FRAMEBUFFER,v.__webglFramebuffer[q]),v.__webglDepthbuffer[q]===void 0)v.__webglDepthbuffer[q]=n.createRenderbuffer(),ve(v.__webglDepthbuffer[q],E,!1);else{let K=E.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,G=v.__webglDepthbuffer[q];n.bindRenderbuffer(n.RENDERBUFFER,G),n.framebufferRenderbuffer(n.FRAMEBUFFER,K,n.RENDERBUFFER,G)}}else{let q=E.texture.mipmaps;if(q&&q.length>0?t.bindFramebuffer(n.FRAMEBUFFER,v.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,v.__webglFramebuffer),v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=n.createRenderbuffer(),ve(v.__webglDepthbuffer,E,!1);else{let K=E.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,G=v.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,G),n.framebufferRenderbuffer(n.FRAMEBUFFER,K,n.RENDERBUFFER,G)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function At(E,v,F){let q=i.get(E);v!==void 0&&me(q.__webglFramebuffer,E,E.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),F!==void 0&&Je(E)}function C(E){let v=E.texture,F=i.get(E),q=i.get(v);E.addEventListener("dispose",R);let K=E.textures,G=E.isWebGLCubeRenderTarget===!0,Ae=K.length>1;if(Ae||(q.__webglTexture===void 0&&(q.__webglTexture=n.createTexture()),q.__version=v.version,a.memory.textures++),G){F.__webglFramebuffer=[];for(let ae=0;ae<6;ae++)if(v.mipmaps&&v.mipmaps.length>0){F.__webglFramebuffer[ae]=[];for(let we=0;we<v.mipmaps.length;we++)F.__webglFramebuffer[ae][we]=n.createFramebuffer()}else F.__webglFramebuffer[ae]=n.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){F.__webglFramebuffer=[];for(let ae=0;ae<v.mipmaps.length;ae++)F.__webglFramebuffer[ae]=n.createFramebuffer()}else F.__webglFramebuffer=n.createFramebuffer();if(Ae)for(let ae=0,we=K.length;ae<we;ae++){let Ee=i.get(K[ae]);Ee.__webglTexture===void 0&&(Ee.__webglTexture=n.createTexture(),a.memory.textures++)}if(E.samples>0&&Se(E)===!1){F.__webglMultisampledFramebuffer=n.createFramebuffer(),F.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let ae=0;ae<K.length;ae++){let we=K[ae];F.__webglColorRenderbuffer[ae]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,F.__webglColorRenderbuffer[ae]);let Ee=s.convert(we.format,we.colorSpace),ne=s.convert(we.type),fe=S(we.internalFormat,Ee,ne,we.colorSpace,E.isXRRenderTarget===!0),Le=gt(E);n.renderbufferStorageMultisample(n.RENDERBUFFER,Le,fe,E.width,E.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+ae,n.RENDERBUFFER,F.__webglColorRenderbuffer[ae])}n.bindRenderbuffer(n.RENDERBUFFER,null),E.depthBuffer&&(F.__webglDepthRenderbuffer=n.createRenderbuffer(),ve(F.__webglDepthRenderbuffer,E,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(G){t.bindTexture(n.TEXTURE_CUBE_MAP,q.__webglTexture),$e(n.TEXTURE_CUBE_MAP,v);for(let ae=0;ae<6;ae++)if(v.mipmaps&&v.mipmaps.length>0)for(let we=0;we<v.mipmaps.length;we++)me(F.__webglFramebuffer[ae][we],E,v,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+ae,we);else me(F.__webglFramebuffer[ae],E,v,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+ae,0);m(v)&&p(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Ae){for(let ae=0,we=K.length;ae<we;ae++){let Ee=K[ae],ne=i.get(Ee),fe=n.TEXTURE_2D;(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(fe=E.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(fe,ne.__webglTexture),$e(fe,Ee),me(F.__webglFramebuffer,E,Ee,n.COLOR_ATTACHMENT0+ae,fe,0),m(Ee)&&p(fe)}t.unbindTexture()}else{let ae=n.TEXTURE_2D;if((E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(ae=E.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(ae,q.__webglTexture),$e(ae,v),v.mipmaps&&v.mipmaps.length>0)for(let we=0;we<v.mipmaps.length;we++)me(F.__webglFramebuffer[we],E,v,n.COLOR_ATTACHMENT0,ae,we);else me(F.__webglFramebuffer,E,v,n.COLOR_ATTACHMENT0,ae,0);m(v)&&p(ae),t.unbindTexture()}E.depthBuffer&&Je(E)}function ht(E){let v=E.textures;for(let F=0,q=v.length;F<q;F++){let K=v[F];if(m(K)){let G=M(E),Ae=i.get(K).__webglTexture;t.bindTexture(G,Ae),p(G),t.unbindTexture()}}}let Be=[],Ne=[];function be(E){if(E.samples>0){if(Se(E)===!1){let v=E.textures,F=E.width,q=E.height,K=n.COLOR_BUFFER_BIT,G=E.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ae=i.get(E),ae=v.length>1;if(ae)for(let Ee=0;Ee<v.length;Ee++)t.bindFramebuffer(n.FRAMEBUFFER,Ae.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ee,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,Ae.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ee,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,Ae.__webglMultisampledFramebuffer);let we=E.texture.mipmaps;we&&we.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ae.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ae.__webglFramebuffer);for(let Ee=0;Ee<v.length;Ee++){if(E.resolveDepthBuffer&&(E.depthBuffer&&(K|=n.DEPTH_BUFFER_BIT),E.stencilBuffer&&E.resolveStencilBuffer&&(K|=n.STENCIL_BUFFER_BIT)),ae){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,Ae.__webglColorRenderbuffer[Ee]);let ne=i.get(v[Ee]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,ne,0)}n.blitFramebuffer(0,0,F,q,0,0,F,q,K,n.NEAREST),l===!0&&(Be.length=0,Ne.length=0,Be.push(n.COLOR_ATTACHMENT0+Ee),E.depthBuffer&&E.resolveDepthBuffer===!1&&(Be.push(G),Ne.push(G),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,Ne)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,Be))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),ae)for(let Ee=0;Ee<v.length;Ee++){t.bindFramebuffer(n.FRAMEBUFFER,Ae.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ee,n.RENDERBUFFER,Ae.__webglColorRenderbuffer[Ee]);let ne=i.get(v[Ee]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,Ae.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ee,n.TEXTURE_2D,ne,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ae.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.resolveDepthBuffer===!1&&l){let v=E.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[v])}}}function gt(E){return Math.min(r.maxSamples,E.samples)}function Se(E){let v=i.get(E);return E.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function He(E){let v=a.render.frame;h.get(E)!==v&&(h.set(E,v),E.update())}function Lt(E,v){let F=E.colorSpace,q=E.format,K=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||F!==ci&&F!==di&&(Ke.getTransfer(F)===at?(q!==an||K!==Yn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",F)),v}function bt(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=V,this.setTexture2D=j,this.setTexture2DArray=X,this.setTexture3D=re,this.setTextureCube=H,this.rebindTextures=At,this.setupRenderTarget=C,this.updateRenderTargetMipmap=ht,this.updateMultisampleRenderTarget=be,this.setupDepthRenderbuffer=Je,this.setupFrameBufferTexture=me,this.useMultisampledRTT=Se}function Nb(n,e){function t(i,r=di){let s,a=Ke.getTransfer(r);if(i===Yn)return n.UNSIGNED_BYTE;if(i===dl)return n.UNSIGNED_SHORT_4_4_4_4;if(i===fl)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Bh)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===zh)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===Uh)return n.BYTE;if(i===Fh)return n.SHORT;if(i===rs)return n.UNSIGNED_SHORT;if(i===ul)return n.INT;if(i===Li)return n.UNSIGNED_INT;if(i===En)return n.FLOAT;if(i===ss)return n.HALF_FLOAT;if(i===Vh)return n.ALPHA;if(i===Hh)return n.RGB;if(i===an)return n.RGBA;if(i===Yr)return n.DEPTH_COMPONENT;if(i===os)return n.DEPTH_STENCIL;if(i===Gh)return n.RED;if(i===pl)return n.RED_INTEGER;if(i===Wh)return n.RG;if(i===ml)return n.RG_INTEGER;if(i===gl)return n.RGBA_INTEGER;if(i===fa||i===pa||i===ma||i===ga)if(a===at)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===fa)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===pa)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===ma)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===ga)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===fa)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===pa)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===ma)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===ga)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===yl||i===vl||i===xl||i===_l)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===yl)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===vl)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===xl)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===_l)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===bl||i===Sl||i===wl)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===bl||i===Sl)return a===at?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===wl)return a===at?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===Ml||i===El||i===Tl||i===Al||i===Cl||i===Rl||i===Pl||i===Il||i===Ll||i===Dl||i===kl||i===Nl||i===Ol||i===Ul)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Ml)return a===at?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===El)return a===at?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Tl)return a===at?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Al)return a===at?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Cl)return a===at?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Rl)return a===at?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Pl)return a===at?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Il)return a===at?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Ll)return a===at?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Dl)return a===at?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===kl)return a===at?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Nl)return a===at?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Ol)return a===at?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Ul)return a===at?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Fl||i===Bl||i===zl)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===Fl)return a===at?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Bl)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===zl)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Vl||i===Hl||i===Gl||i===Wl)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===Vl)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Hl)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Gl)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Wl)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===as?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}var Ob=`
3809
3817
  void main() {
3810
3818
 
3811
3819
  gl_Position = vec4( position, 1.0 );
3812
3820
 
3813
- }`,Zm=`
3821
+ }`,Ub=`
3814
3822
  uniform sampler2DArray depthColor;
3815
3823
  uniform float depthWidth;
3816
3824
  uniform float depthHeight;
@@ -3829,75 +3837,321 @@ void main() {
3829
3837
 
3830
3838
  }
3831
3839
 
3832
- }`,el=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){let n=new ys(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(this.texture!==null&&this.mesh===null){let e=t.cameras[0].viewport,n=new je({vertexShader:Ym,fragmentShader:Zm,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Pe(new vs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},nl=class extends tn{constructor(t,e){super();let n=this,s=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,f=null,u=null,p=null,g=null,_=typeof XRWebGLBinding<"u",m=new el,d={},T=e.getContextAttributes(),M=null,v=null,R=[],w=[],C=new Ut,U=null,S=new we;S.viewport=new oe;let b=new we;b.viewport=new oe;let P=[S,b],B=new Dr,V=null,X=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(q){let J=R[q];return J===void 0&&(J=new Ri,R[q]=J),J.getTargetRaySpace()},this.getControllerGrip=function(q){let J=R[q];return J===void 0&&(J=new Ri,R[q]=J),J.getGripSpace()},this.getHand=function(q){let J=R[q];return J===void 0&&(J=new Ri,R[q]=J),J.getHandSpace()};function Z(q){let J=w.indexOf(q.inputSource);if(J===-1)return;let dt=R[J];dt!==void 0&&(dt.update(q.inputSource,q.frame,l||a),dt.dispatchEvent({type:q.type,data:q.inputSource}))}function W(){s.removeEventListener("select",Z),s.removeEventListener("selectstart",Z),s.removeEventListener("selectend",Z),s.removeEventListener("squeeze",Z),s.removeEventListener("squeezestart",Z),s.removeEventListener("squeezeend",Z),s.removeEventListener("end",W),s.removeEventListener("inputsourceschange",et);for(let q=0;q<R.length;q++){let J=w[q];J!==null&&(w[q]=null,R[q].disconnect(J))}V=null,X=null,m.reset();for(let q in d)delete d[q];t.setRenderTarget(M),p=null,u=null,f=null,s=null,v=null,Wt.stop(),n.isPresenting=!1,t.setPixelRatio(U),t.setSize(C.width,C.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(q){r=q,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(q){o=q,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(q){l=q},this.getBaseLayer=function(){return u!==null?u:p},this.getBinding=function(){return f===null&&_&&(f=new XRWebGLBinding(s,e)),f},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(q){if(s=q,s!==null){if(M=t.getRenderTarget(),s.addEventListener("select",Z),s.addEventListener("selectstart",Z),s.addEventListener("selectend",Z),s.addEventListener("squeeze",Z),s.addEventListener("squeezestart",Z),s.addEventListener("squeezeend",Z),s.addEventListener("end",W),s.addEventListener("inputsourceschange",et),T.xrCompatible!==!0&&await e.makeXRCompatible(),U=t.getPixelRatio(),t.getSize(C),_&&"createProjectionLayer"in XRWebGLBinding.prototype){let dt=null,Ct=null,Mt=null;T.depth&&(Mt=T.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,dt=T.stencil?Oi:Si,Ct=T.stencil?Fi:Bn);let Ht={colorFormat:e.RGBA8,depthFormat:Mt,scaleFactor:r};f=this.getBinding(),u=f.createProjectionLayer(Ht),s.updateRenderState({layers:[u]}),t.setPixelRatio(1),t.setSize(u.textureWidth,u.textureHeight,!1),v=new en(u.textureWidth,u.textureHeight,{format:qe,type:an,depthTexture:new xs(u.textureWidth,u.textureHeight,Ct,void 0,void 0,void 0,void 0,void 0,void 0,dt),stencilBuffer:T.stencil,colorSpace:t.outputColorSpace,samples:T.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{let dt={antialias:T.antialias,alpha:!0,depth:T.depth,stencil:T.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(s,e,dt),s.updateRenderState({baseLayer:p}),t.setPixelRatio(1),t.setSize(p.framebufferWidth,p.framebufferHeight,!1),v=new en(p.framebufferWidth,p.framebufferHeight,{format:qe,type:an,colorSpace:t.outputColorSpace,stencilBuffer:T.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}v.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await s.requestReferenceSpace(o),Wt.setContext(s),Wt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function et(q){for(let J=0;J<q.removed.length;J++){let dt=q.removed[J],Ct=w.indexOf(dt);Ct>=0&&(w[Ct]=null,R[Ct].disconnect(dt))}for(let J=0;J<q.added.length;J++){let dt=q.added[J],Ct=w.indexOf(dt);if(Ct===-1){for(let Ht=0;Ht<R.length;Ht++)if(Ht>=w.length){w.push(dt),Ct=Ht;break}else if(w[Ht]===null){w[Ht]=dt,Ct=Ht;break}if(Ct===-1)break}let Mt=R[Ct];Mt&&Mt.connect(dt)}}let k=new N,rt=new N;function ct(q,J,dt){k.setFromMatrixPosition(J.matrixWorld),rt.setFromMatrixPosition(dt.matrixWorld);let Ct=k.distanceTo(rt),Mt=J.projectionMatrix.elements,Ht=dt.projectionMatrix.elements,ge=Mt[14]/(Mt[10]-1),A=Mt[14]/(Mt[10]+1),ee=(Mt[9]+1)/Mt[5],It=(Mt[9]-1)/Mt[5],At=(Mt[8]-1)/Mt[0],mt=(Ht[8]+1)/Ht[0],ne=ge*At,gt=ge*mt,Nt=Ct/(-At+mt),pe=Nt*-At;if(J.matrixWorld.decompose(q.position,q.quaternion,q.scale),q.translateX(pe),q.translateZ(Nt),q.matrixWorld.compose(q.position,q.quaternion,q.scale),q.matrixWorldInverse.copy(q.matrixWorld).invert(),Mt[10]===-1)q.projectionMatrix.copy(J.projectionMatrix),q.projectionMatrixInverse.copy(J.projectionMatrixInverse);else{let le=ge+Nt,E=A+Nt,x=ne-pe,F=gt+(Ct-pe),G=ee*A/E*le,$=It*A/E*le;q.projectionMatrix.makePerspective(x,F,G,$,le,E),q.projectionMatrixInverse.copy(q.projectionMatrix).invert()}}function bt(q,J){J===null?q.matrixWorld.copy(q.matrix):q.matrixWorld.multiplyMatrices(J.matrixWorld,q.matrix),q.matrixWorldInverse.copy(q.matrixWorld).invert()}this.updateCamera=function(q){if(s===null)return;let J=q.near,dt=q.far;m.texture!==null&&(m.depthNear>0&&(J=m.depthNear),m.depthFar>0&&(dt=m.depthFar)),B.near=b.near=S.near=J,B.far=b.far=S.far=dt,(V!==B.near||X!==B.far)&&(s.updateRenderState({depthNear:B.near,depthFar:B.far}),V=B.near,X=B.far),B.layers.mask=q.layers.mask|6,S.layers.mask=B.layers.mask&3,b.layers.mask=B.layers.mask&5;let Ct=q.parent,Mt=B.cameras;bt(B,Ct);for(let Ht=0;Ht<Mt.length;Ht++)bt(Mt[Ht],Ct);Mt.length===2?ct(B,S,b):B.projectionMatrix.copy(S.projectionMatrix),Bt(q,B,Ct)};function Bt(q,J,dt){dt===null?q.matrix.copy(J.matrixWorld):(q.matrix.copy(dt.matrixWorld),q.matrix.invert(),q.matrix.multiply(J.matrixWorld)),q.matrix.decompose(q.position,q.quaternion,q.scale),q.updateMatrixWorld(!0),q.projectionMatrix.copy(J.projectionMatrix),q.projectionMatrixInverse.copy(J.projectionMatrixInverse),q.isPerspectiveCamera&&(q.fov=Ei*2*Math.atan(1/q.projectionMatrix.elements[5]),q.zoom=1)}this.getCamera=function(){return B},this.getFoveation=function(){if(!(u===null&&p===null))return c},this.setFoveation=function(q){c=q,u!==null&&(u.fixedFoveation=q),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=q)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(B)},this.getCameraTexture=function(q){return d[q]};let Jt=null;function te(q,J){if(h=J.getViewerPose(l||a),g=J,h!==null){let dt=h.views;p!==null&&(t.setRenderTargetFramebuffer(v,p.framebuffer),t.setRenderTarget(v));let Ct=!1;dt.length!==B.cameras.length&&(B.cameras.length=0,Ct=!0);for(let A=0;A<dt.length;A++){let ee=dt[A],It=null;if(p!==null)It=p.getViewport(ee);else{let mt=f.getViewSubImage(u,ee);It=mt.viewport,A===0&&(t.setRenderTargetTextures(v,mt.colorTexture,mt.depthStencilTexture),t.setRenderTarget(v))}let At=P[A];At===void 0&&(At=new we,At.layers.enable(A),At.viewport=new oe,P[A]=At),At.matrix.fromArray(ee.transform.matrix),At.matrix.decompose(At.position,At.quaternion,At.scale),At.projectionMatrix.fromArray(ee.projectionMatrix),At.projectionMatrixInverse.copy(At.projectionMatrix).invert(),At.viewport.set(It.x,It.y,It.width,It.height),A===0&&(B.matrix.copy(At.matrix),B.matrix.decompose(B.position,B.quaternion,B.scale)),Ct===!0&&B.cameras.push(At)}let Mt=s.enabledFeatures;if(Mt&&Mt.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&_){f=n.getBinding();let A=f.getDepthInformation(dt[0]);A&&A.isValid&&A.texture&&m.init(A,s.renderState)}if(Mt&&Mt.includes("camera-access")&&_){t.state.unbindTexture(),f=n.getBinding();for(let A=0;A<dt.length;A++){let ee=dt[A].camera;if(ee){let It=d[ee];It||(It=new ys,d[ee]=It);let At=f.getCameraImage(ee);It.sourceTexture=At}}}}for(let dt=0;dt<R.length;dt++){let Ct=w[dt],Mt=R[dt];Ct!==null&&Mt!==void 0&&Mt.update(Ct,J,l||a)}Jt&&Jt(q,J),J.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:J}),g=null}let Wt=new eh;Wt.setAnimationLoop(te),this.setAnimationLoop=function(q){Jt=q},this.dispose=function(){}}},ni=new sn,$m=new ce;function Jm(i,t){function e(m,d){m.matrixAutoUpdate===!0&&m.updateMatrix(),d.value.copy(m.matrix)}function n(m,d){d.color.getRGB(m.fogColor.value,zo(i)),d.isFog?(m.fogNear.value=d.near,m.fogFar.value=d.far):d.isFogExp2&&(m.fogDensity.value=d.density)}function s(m,d,T,M,v){d.isMeshBasicMaterial||d.isMeshLambertMaterial?r(m,d):d.isMeshToonMaterial?(r(m,d),f(m,d)):d.isMeshPhongMaterial?(r(m,d),h(m,d)):d.isMeshStandardMaterial?(r(m,d),u(m,d),d.isMeshPhysicalMaterial&&p(m,d,v)):d.isMeshMatcapMaterial?(r(m,d),g(m,d)):d.isMeshDepthMaterial?r(m,d):d.isMeshDistanceMaterial?(r(m,d),_(m,d)):d.isMeshNormalMaterial?r(m,d):d.isLineBasicMaterial?(a(m,d),d.isLineDashedMaterial&&o(m,d)):d.isPointsMaterial?c(m,d,T,M):d.isSpriteMaterial?l(m,d):d.isShadowMaterial?(m.color.value.copy(d.color),m.opacity.value=d.opacity):d.isShaderMaterial&&(d.uniformsNeedUpdate=!1)}function r(m,d){m.opacity.value=d.opacity,d.color&&m.diffuse.value.copy(d.color),d.emissive&&m.emissive.value.copy(d.emissive).multiplyScalar(d.emissiveIntensity),d.map&&(m.map.value=d.map,e(d.map,m.mapTransform)),d.alphaMap&&(m.alphaMap.value=d.alphaMap,e(d.alphaMap,m.alphaMapTransform)),d.bumpMap&&(m.bumpMap.value=d.bumpMap,e(d.bumpMap,m.bumpMapTransform),m.bumpScale.value=d.bumpScale,d.side===Ee&&(m.bumpScale.value*=-1)),d.normalMap&&(m.normalMap.value=d.normalMap,e(d.normalMap,m.normalMapTransform),m.normalScale.value.copy(d.normalScale),d.side===Ee&&m.normalScale.value.negate()),d.displacementMap&&(m.displacementMap.value=d.displacementMap,e(d.displacementMap,m.displacementMapTransform),m.displacementScale.value=d.displacementScale,m.displacementBias.value=d.displacementBias),d.emissiveMap&&(m.emissiveMap.value=d.emissiveMap,e(d.emissiveMap,m.emissiveMapTransform)),d.specularMap&&(m.specularMap.value=d.specularMap,e(d.specularMap,m.specularMapTransform)),d.alphaTest>0&&(m.alphaTest.value=d.alphaTest);let T=t.get(d),M=T.envMap,v=T.envMapRotation;M&&(m.envMap.value=M,ni.copy(v),ni.x*=-1,ni.y*=-1,ni.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(ni.y*=-1,ni.z*=-1),m.envMapRotation.value.setFromMatrix4($m.makeRotationFromEuler(ni)),m.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=d.reflectivity,m.ior.value=d.ior,m.refractionRatio.value=d.refractionRatio),d.lightMap&&(m.lightMap.value=d.lightMap,m.lightMapIntensity.value=d.lightMapIntensity,e(d.lightMap,m.lightMapTransform)),d.aoMap&&(m.aoMap.value=d.aoMap,m.aoMapIntensity.value=d.aoMapIntensity,e(d.aoMap,m.aoMapTransform))}function a(m,d){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,d.map&&(m.map.value=d.map,e(d.map,m.mapTransform))}function o(m,d){m.dashSize.value=d.dashSize,m.totalSize.value=d.dashSize+d.gapSize,m.scale.value=d.scale}function c(m,d,T,M){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,m.size.value=d.size*T,m.scale.value=M*.5,d.map&&(m.map.value=d.map,e(d.map,m.uvTransform)),d.alphaMap&&(m.alphaMap.value=d.alphaMap,e(d.alphaMap,m.alphaMapTransform)),d.alphaTest>0&&(m.alphaTest.value=d.alphaTest)}function l(m,d){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,m.rotation.value=d.rotation,d.map&&(m.map.value=d.map,e(d.map,m.mapTransform)),d.alphaMap&&(m.alphaMap.value=d.alphaMap,e(d.alphaMap,m.alphaMapTransform)),d.alphaTest>0&&(m.alphaTest.value=d.alphaTest)}function h(m,d){m.specular.value.copy(d.specular),m.shininess.value=Math.max(d.shininess,1e-4)}function f(m,d){d.gradientMap&&(m.gradientMap.value=d.gradientMap)}function u(m,d){m.metalness.value=d.metalness,d.metalnessMap&&(m.metalnessMap.value=d.metalnessMap,e(d.metalnessMap,m.metalnessMapTransform)),m.roughness.value=d.roughness,d.roughnessMap&&(m.roughnessMap.value=d.roughnessMap,e(d.roughnessMap,m.roughnessMapTransform)),d.envMap&&(m.envMapIntensity.value=d.envMapIntensity)}function p(m,d,T){m.ior.value=d.ior,d.sheen>0&&(m.sheenColor.value.copy(d.sheenColor).multiplyScalar(d.sheen),m.sheenRoughness.value=d.sheenRoughness,d.sheenColorMap&&(m.sheenColorMap.value=d.sheenColorMap,e(d.sheenColorMap,m.sheenColorMapTransform)),d.sheenRoughnessMap&&(m.sheenRoughnessMap.value=d.sheenRoughnessMap,e(d.sheenRoughnessMap,m.sheenRoughnessMapTransform))),d.clearcoat>0&&(m.clearcoat.value=d.clearcoat,m.clearcoatRoughness.value=d.clearcoatRoughness,d.clearcoatMap&&(m.clearcoatMap.value=d.clearcoatMap,e(d.clearcoatMap,m.clearcoatMapTransform)),d.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=d.clearcoatRoughnessMap,e(d.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),d.clearcoatNormalMap&&(m.clearcoatNormalMap.value=d.clearcoatNormalMap,e(d.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(d.clearcoatNormalScale),d.side===Ee&&m.clearcoatNormalScale.value.negate())),d.dispersion>0&&(m.dispersion.value=d.dispersion),d.iridescence>0&&(m.iridescence.value=d.iridescence,m.iridescenceIOR.value=d.iridescenceIOR,m.iridescenceThicknessMinimum.value=d.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=d.iridescenceThicknessRange[1],d.iridescenceMap&&(m.iridescenceMap.value=d.iridescenceMap,e(d.iridescenceMap,m.iridescenceMapTransform)),d.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=d.iridescenceThicknessMap,e(d.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),d.transmission>0&&(m.transmission.value=d.transmission,m.transmissionSamplerMap.value=T.texture,m.transmissionSamplerSize.value.set(T.width,T.height),d.transmissionMap&&(m.transmissionMap.value=d.transmissionMap,e(d.transmissionMap,m.transmissionMapTransform)),m.thickness.value=d.thickness,d.thicknessMap&&(m.thicknessMap.value=d.thicknessMap,e(d.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=d.attenuationDistance,m.attenuationColor.value.copy(d.attenuationColor)),d.anisotropy>0&&(m.anisotropyVector.value.set(d.anisotropy*Math.cos(d.anisotropyRotation),d.anisotropy*Math.sin(d.anisotropyRotation)),d.anisotropyMap&&(m.anisotropyMap.value=d.anisotropyMap,e(d.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=d.specularIntensity,m.specularColor.value.copy(d.specularColor),d.specularColorMap&&(m.specularColorMap.value=d.specularColorMap,e(d.specularColorMap,m.specularColorMapTransform)),d.specularIntensityMap&&(m.specularIntensityMap.value=d.specularIntensityMap,e(d.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,d){d.matcap&&(m.matcap.value=d.matcap)}function _(m,d){let T=t.get(d).light;m.referencePosition.value.setFromMatrixPosition(T.matrixWorld),m.nearDistance.value=T.shadow.camera.near,m.farDistance.value=T.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function Km(i,t,e,n){let s={},r={},a=[],o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(T,M){let v=M.program;n.uniformBlockBinding(T,v)}function l(T,M){let v=s[T.id];v===void 0&&(g(T),v=h(T),s[T.id]=v,T.addEventListener("dispose",m));let R=M.program;n.updateUBOMapping(T,R);let w=t.render.frame;r[T.id]!==w&&(u(T),r[T.id]=w)}function h(T){let M=f();T.__bindingPointIndex=M;let v=i.createBuffer(),R=T.__size,w=T.usage;return i.bindBuffer(i.UNIFORM_BUFFER,v),i.bufferData(i.UNIFORM_BUFFER,R,w),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,M,v),v}function f(){for(let T=0;T<o;T++)if(a.indexOf(T)===-1)return a.push(T),T;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(T){let M=s[T.id],v=T.uniforms,R=T.__cache;i.bindBuffer(i.UNIFORM_BUFFER,M);for(let w=0,C=v.length;w<C;w++){let U=Array.isArray(v[w])?v[w]:[v[w]];for(let S=0,b=U.length;S<b;S++){let P=U[S];if(p(P,w,S,R)===!0){let B=P.__offset,V=Array.isArray(P.value)?P.value:[P.value],X=0;for(let Z=0;Z<V.length;Z++){let W=V[Z],et=_(W);typeof W=="number"||typeof W=="boolean"?(P.__data[0]=W,i.bufferSubData(i.UNIFORM_BUFFER,B+X,P.__data)):W.isMatrix3?(P.__data[0]=W.elements[0],P.__data[1]=W.elements[1],P.__data[2]=W.elements[2],P.__data[3]=0,P.__data[4]=W.elements[3],P.__data[5]=W.elements[4],P.__data[6]=W.elements[5],P.__data[7]=0,P.__data[8]=W.elements[6],P.__data[9]=W.elements[7],P.__data[10]=W.elements[8],P.__data[11]=0):(W.toArray(P.__data,X),X+=et.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,B,P.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function p(T,M,v,R){let w=T.value,C=M+"_"+v;if(R[C]===void 0)return typeof w=="number"||typeof w=="boolean"?R[C]=w:R[C]=w.clone(),!0;{let U=R[C];if(typeof w=="number"||typeof w=="boolean"){if(U!==w)return R[C]=w,!0}else if(U.equals(w)===!1)return U.copy(w),!0}return!1}function g(T){let M=T.uniforms,v=0,R=16;for(let C=0,U=M.length;C<U;C++){let S=Array.isArray(M[C])?M[C]:[M[C]];for(let b=0,P=S.length;b<P;b++){let B=S[b],V=Array.isArray(B.value)?B.value:[B.value];for(let X=0,Z=V.length;X<Z;X++){let W=V[X],et=_(W),k=v%R,rt=k%et.boundary,ct=k+rt;v+=rt,ct!==0&&R-ct<et.storage&&(v+=R-ct),B.__data=new Float32Array(et.storage/Float32Array.BYTES_PER_ELEMENT),B.__offset=v,v+=et.storage}}}let w=v%R;return w>0&&(v+=R-w),T.__size=v,T.__cache={},this}function _(T){let M={boundary:0,storage:0};return typeof T=="number"||typeof T=="boolean"?(M.boundary=4,M.storage=4):T.isVector2?(M.boundary=8,M.storage=8):T.isVector3||T.isColor?(M.boundary=16,M.storage=12):T.isVector4?(M.boundary=16,M.storage=16):T.isMatrix3?(M.boundary=48,M.storage=48):T.isMatrix4?(M.boundary=64,M.storage=64):T.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",T),M}function m(T){let M=T.target;M.removeEventListener("dispose",m);let v=a.indexOf(M.__bindingPointIndex);a.splice(v,1),i.deleteBuffer(s[M.id]),delete s[M.id],delete r[M.id]}function d(){for(let T in s)i.deleteBuffer(s[T]);a=[],s={},r={}}return{bind:c,update:l,dispose:d}}var Ra=class{constructor(t={}){let{canvas:e=Ac(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:u=!1}=t;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=a;let g=new Uint32Array(4),_=new Int32Array(4),m=null,d=null,T=[],M=[];this.domElement=e,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=Mn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let v=this,R=!1;this._outputColorSpace=Fe;let w=0,C=0,U=null,S=-1,b=null,P=new oe,B=new oe,V=null,X=new zt(0),Z=0,W=e.width,et=e.height,k=1,rt=null,ct=null,bt=new oe(0,0,W,et),Bt=new oe(0,0,W,et),Jt=!1,te=new ms,Wt=!1,q=!1,J=new ce,dt=new N,Ct=new oe,Mt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Ht=!1;function ge(){return U===null?k:1}let A=n;function ee(y,L){return e.getContext(y,L)}try{let y={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:f};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${"180"}`),e.addEventListener("webglcontextlost",it,!1),e.addEventListener("webglcontextrestored",ut,!1),e.addEventListener("webglcontextcreationerror",K,!1),A===null){let L="webgl2";if(A=ee(L,y),A===null)throw ee(L)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(y){throw console.error("THREE.WebGLRenderer: "+y.message),y}let It,At,mt,ne,gt,Nt,pe,le,E,x,F,G,$,H,vt,nt,_t,xt,Q,lt,wt,yt,at,Dt;function I(){It=new mp(A),It.init(),yt=new qm(A,It),At=new lp(A,It,t,yt),mt=new Wm(A,It),At.reversedDepthBuffer&&u&&mt.buffers.depth.setReversed(!0),ne=new xp(A),gt=new Im,Nt=new Xm(A,It,mt,gt,At,yt,ne),pe=new hp(v),le=new pp(v),E=new Su(A),at=new ap(A,E),x=new gp(A,E,ne,at),F=new vp(A,x,E,ne),Q=new yp(A,At,Nt),nt=new cp(gt),G=new Pm(v,pe,le,It,At,at,nt),$=new Jm(v,gt),H=new Dm,vt=new zm(It),xt=new rp(v,pe,le,mt,F,p,c),_t=new Vm(v,F,At),Dt=new Km(A,ne,At,mt),lt=new op(A,It,ne),wt=new _p(A,It,ne),ne.programs=G.programs,v.capabilities=At,v.extensions=It,v.properties=gt,v.renderLists=H,v.shadowMap=_t,v.state=mt,v.info=ne}I();let tt=new nl(v,A);this.xr=tt,this.getContext=function(){return A},this.getContextAttributes=function(){return A.getContextAttributes()},this.forceContextLoss=function(){let y=It.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){let y=It.get("WEBGL_lose_context");y&&y.restoreContext()},this.getPixelRatio=function(){return k},this.setPixelRatio=function(y){y!==void 0&&(k=y,this.setSize(W,et,!1))},this.getSize=function(y){return y.set(W,et)},this.setSize=function(y,L,O=!0){if(tt.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=y,et=L,e.width=Math.floor(y*k),e.height=Math.floor(L*k),O===!0&&(e.style.width=y+"px",e.style.height=L+"px"),this.setViewport(0,0,y,L)},this.getDrawingBufferSize=function(y){return y.set(W*k,et*k).floor()},this.setDrawingBufferSize=function(y,L,O){W=y,et=L,k=O,e.width=Math.floor(y*O),e.height=Math.floor(L*O),this.setViewport(0,0,y,L)},this.getCurrentViewport=function(y){return y.copy(P)},this.getViewport=function(y){return y.copy(bt)},this.setViewport=function(y,L,O,z){y.isVector4?bt.set(y.x,y.y,y.z,y.w):bt.set(y,L,O,z),mt.viewport(P.copy(bt).multiplyScalar(k).round())},this.getScissor=function(y){return y.copy(Bt)},this.setScissor=function(y,L,O,z){y.isVector4?Bt.set(y.x,y.y,y.z,y.w):Bt.set(y,L,O,z),mt.scissor(B.copy(Bt).multiplyScalar(k).round())},this.getScissorTest=function(){return Jt},this.setScissorTest=function(y){mt.setScissorTest(Jt=y)},this.setOpaqueSort=function(y){rt=y},this.setTransparentSort=function(y){ct=y},this.getClearColor=function(y){return y.copy(xt.getClearColor())},this.setClearColor=function(){xt.setClearColor(...arguments)},this.getClearAlpha=function(){return xt.getClearAlpha()},this.setClearAlpha=function(){xt.setClearAlpha(...arguments)},this.clear=function(y=!0,L=!0,O=!0){let z=0;if(y){let D=!1;if(U!==null){let j=U.texture.format;D=j===$r||j===Zr||j===Yr}if(D){let j=U.texture.type,ot=j===an||j===Bn||j===Ui||j===Fi||j===Xr||j===qr,ft=xt.getClearColor(),ht=xt.getClearAlpha(),Tt=ft.r,Rt=ft.g,St=ft.b;ot?(g[0]=Tt,g[1]=Rt,g[2]=St,g[3]=ht,A.clearBufferuiv(A.COLOR,0,g)):(_[0]=Tt,_[1]=Rt,_[2]=St,_[3]=ht,A.clearBufferiv(A.COLOR,0,_))}else z|=A.COLOR_BUFFER_BIT}L&&(z|=A.DEPTH_BUFFER_BIT),O&&(z|=A.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),A.clear(z)},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.dispose=function(){e.removeEventListener("webglcontextlost",it,!1),e.removeEventListener("webglcontextrestored",ut,!1),e.removeEventListener("webglcontextcreationerror",K,!1),xt.dispose(),H.dispose(),vt.dispose(),gt.dispose(),pe.dispose(),le.dispose(),F.dispose(),at.dispose(),Dt.dispose(),G.dispose(),tt.dispose(),tt.removeEventListener("sessionstart",Qe),tt.removeEventListener("sessionend",cl),zn.stop()};function it(y){y.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),R=!0}function ut(){console.log("THREE.WebGLRenderer: Context Restored."),R=!1;let y=ne.autoReset,L=_t.enabled,O=_t.autoUpdate,z=_t.needsUpdate,D=_t.type;I(),ne.autoReset=y,_t.enabled=L,_t.autoUpdate=O,_t.needsUpdate=z,_t.type=D}function K(y){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function Y(y){let L=y.target;L.removeEventListener("dispose",Y),pt(L)}function pt(y){Pt(y),gt.remove(y)}function Pt(y){let L=gt.get(y).programs;L!==void 0&&(L.forEach(function(O){G.releaseProgram(O)}),y.isShaderMaterial&&G.releaseShaderCache(y))}this.renderBufferDirect=function(y,L,O,z,D,j){L===null&&(L=Mt);let ot=D.isMesh&&D.matrixWorld.determinant()<0,ft=mh(y,L,O,z,D);mt.setMaterial(z,ot);let ht=O.index,Tt=1;if(z.wireframe===!0){if(ht=x.getWireframeAttribute(O),ht===void 0)return;Tt=2}let Rt=O.drawRange,St=O.attributes.position,kt=Rt.start*Tt,Yt=(Rt.start+Rt.count)*Tt;j!==null&&(kt=Math.max(kt,j.start*Tt),Yt=Math.min(Yt,(j.start+j.count)*Tt)),ht!==null?(kt=Math.max(kt,0),Yt=Math.min(Yt,ht.count)):St!=null&&(kt=Math.max(kt,0),Yt=Math.min(Yt,St.count));let re=Yt-kt;if(re<0||re===1/0)return;at.setup(D,z,ft,O,ht);let jt,$t=lt;if(ht!==null&&(jt=E.get(ht),$t=wt,$t.setIndex(jt)),D.isMesh)z.wireframe===!0?(mt.setLineWidth(z.wireframeLinewidth*ge()),$t.setMode(A.LINES)):$t.setMode(A.TRIANGLES);else if(D.isLine){let Et=z.linewidth;Et===void 0&&(Et=1),mt.setLineWidth(Et*ge()),D.isLineSegments?$t.setMode(A.LINES):D.isLineLoop?$t.setMode(A.LINE_LOOP):$t.setMode(A.LINE_STRIP)}else D.isPoints?$t.setMode(A.POINTS):D.isSprite&&$t.setMode(A.TRIANGLES);if(D.isBatchedMesh)if(D._multiDrawInstances!==null)Ti("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),$t.renderMultiDrawInstances(D._multiDrawStarts,D._multiDrawCounts,D._multiDrawCount,D._multiDrawInstances);else if(It.get("WEBGL_multi_draw"))$t.renderMultiDraw(D._multiDrawStarts,D._multiDrawCounts,D._multiDrawCount);else{let Et=D._multiDrawStarts,ie=D._multiDrawCounts,Gt=D._multiDrawCount,Le=ht?E.get(ht).bytesPerElement:1,ai=gt.get(z).currentProgram.getUniforms();for(let De=0;De<Gt;De++)ai.setValue(A,"_gl_DrawID",De),$t.render(Et[De]/Le,ie[De])}else if(D.isInstancedMesh)$t.renderInstances(kt,re,D.count);else if(O.isInstancedBufferGeometry){let Et=O._maxInstanceCount!==void 0?O._maxInstanceCount:1/0,ie=Math.min(O.instanceCount,Et);$t.renderInstances(kt,re,ie)}else $t.render(kt,re)};function Kt(y,L,O){y.transparent===!0&&y.side===Xe&&y.forceSinglePass===!1?(y.side=Ee,y.needsUpdate=!0,Fs(y,L,O),y.side=_n,y.needsUpdate=!0,Fs(y,L,O),y.side=Xe):Fs(y,L,O)}this.compile=function(y,L,O=null){O===null&&(O=y),d=vt.get(O),d.init(L),M.push(d),O.traverseVisible(function(D){D.isLight&&D.layers.test(L.layers)&&(d.pushLight(D),D.castShadow&&d.pushShadow(D))}),y!==O&&y.traverseVisible(function(D){D.isLight&&D.layers.test(L.layers)&&(d.pushLight(D),D.castShadow&&d.pushShadow(D))}),d.setupLights();let z=new Set;return y.traverse(function(D){if(!(D.isMesh||D.isPoints||D.isLine||D.isSprite))return;let j=D.material;if(j)if(Array.isArray(j))for(let ot=0;ot<j.length;ot++){let ft=j[ot];Kt(ft,O,D),z.add(ft)}else Kt(j,O,D),z.add(j)}),d=M.pop(),z},this.compileAsync=function(y,L,O=null){let z=this.compile(y,L,O);return new Promise(D=>{function j(){if(z.forEach(function(ot){gt.get(ot).currentProgram.isReady()&&z.delete(ot)}),z.size===0){D(y);return}setTimeout(j,10)}It.get("KHR_parallel_shader_compile")!==null?j():setTimeout(j,10)})};let Xt=null;function cn(y){Xt&&Xt(y)}function Qe(){zn.stop()}function cl(){zn.start()}let zn=new eh;zn.setAnimationLoop(cn),typeof self<"u"&&zn.setContext(self),this.setAnimationLoop=function(y){Xt=y,tt.setAnimationLoop(y),y===null?zn.stop():zn.start()},tt.addEventListener("sessionstart",Qe),tt.addEventListener("sessionend",cl),this.render=function(y,L){if(L!==void 0&&L.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(R===!0)return;if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),L.parent===null&&L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),tt.enabled===!0&&tt.isPresenting===!0&&(tt.cameraAutoUpdate===!0&&tt.updateCamera(L),L=tt.getCamera()),y.isScene===!0&&y.onBeforeRender(v,y,L,U),d=vt.get(y,M.length),d.init(L),M.push(d),J.multiplyMatrices(L.projectionMatrix,L.matrixWorldInverse),te.setFromProjectionMatrix(J,Je,L.reversedDepth),q=this.localClippingEnabled,Wt=nt.init(this.clippingPlanes,q),m=H.get(y,T.length),m.init(),T.push(m),tt.enabled===!0&&tt.isPresenting===!0){let j=v.xr.getDepthSensingMesh();j!==null&&za(j,L,-1/0,v.sortObjects)}za(y,L,0,v.sortObjects),m.finish(),v.sortObjects===!0&&m.sort(rt,ct),Ht=tt.enabled===!1||tt.isPresenting===!1||tt.hasDepthSensing()===!1,Ht&&xt.addToRenderList(m,y),this.info.render.frame++,Wt===!0&&nt.beginShadows();let O=d.state.shadowsArray;_t.render(O,y,L),Wt===!0&&nt.endShadows(),this.info.autoReset===!0&&this.info.reset();let z=m.opaque,D=m.transmissive;if(d.setupLights(),L.isArrayCamera){let j=L.cameras;if(D.length>0)for(let ot=0,ft=j.length;ot<ft;ot++){let ht=j[ot];ul(z,D,y,ht)}Ht&&xt.render(y);for(let ot=0,ft=j.length;ot<ft;ot++){let ht=j[ot];hl(m,y,ht,ht.viewport)}}else D.length>0&&ul(z,D,y,L),Ht&&xt.render(y),hl(m,y,L);U!==null&&C===0&&(Nt.updateMultisampleRenderTarget(U),Nt.updateRenderTargetMipmap(U)),y.isScene===!0&&y.onAfterRender(v,y,L),at.resetDefaultState(),S=-1,b=null,M.pop(),M.length>0?(d=M[M.length-1],Wt===!0&&nt.setGlobalState(v.clippingPlanes,d.state.camera)):d=null,T.pop(),T.length>0?m=T[T.length-1]:m=null};function za(y,L,O,z){if(y.visible===!1)return;if(y.layers.test(L.layers)){if(y.isGroup)O=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(L);else if(y.isLight)d.pushLight(y),y.castShadow&&d.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||te.intersectsSprite(y)){z&&Ct.setFromMatrixPosition(y.matrixWorld).applyMatrix4(J);let ot=F.update(y),ft=y.material;ft.visible&&m.push(y,ot,ft,O,Ct.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||te.intersectsObject(y))){let ot=F.update(y),ft=y.material;if(z&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),Ct.copy(y.boundingSphere.center)):(ot.boundingSphere===null&&ot.computeBoundingSphere(),Ct.copy(ot.boundingSphere.center)),Ct.applyMatrix4(y.matrixWorld).applyMatrix4(J)),Array.isArray(ft)){let ht=ot.groups;for(let Tt=0,Rt=ht.length;Tt<Rt;Tt++){let St=ht[Tt],kt=ft[St.materialIndex];kt&&kt.visible&&m.push(y,ot,kt,O,Ct.z,St)}}else ft.visible&&m.push(y,ot,ft,O,Ct.z,null)}}let j=y.children;for(let ot=0,ft=j.length;ot<ft;ot++)za(j[ot],L,O,z)}function hl(y,L,O,z){let D=y.opaque,j=y.transmissive,ot=y.transparent;d.setupLightsView(O),Wt===!0&&nt.setGlobalState(v.clippingPlanes,O),z&&mt.viewport(P.copy(z)),D.length>0&&Ns(D,L,O),j.length>0&&Ns(j,L,O),ot.length>0&&Ns(ot,L,O),mt.buffers.depth.setTest(!0),mt.buffers.depth.setMask(!0),mt.buffers.color.setMask(!0),mt.setPolygonOffset(!1)}function ul(y,L,O,z){if((O.isScene===!0?O.overrideMaterial:null)!==null)return;d.state.transmissionRenderTarget[z.id]===void 0&&(d.state.transmissionRenderTarget[z.id]=new en(1,1,{generateMipmaps:!0,type:It.has("EXT_color_buffer_half_float")||It.has("EXT_color_buffer_float")?Ni:an,minFilter:On,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Vt.workingColorSpace}));let j=d.state.transmissionRenderTarget[z.id],ot=z.viewport||P;j.setSize(ot.z*v.transmissionResolutionScale,ot.w*v.transmissionResolutionScale);let ft=v.getRenderTarget(),ht=v.getActiveCubeFace(),Tt=v.getActiveMipmapLevel();v.setRenderTarget(j),v.getClearColor(X),Z=v.getClearAlpha(),Z<1&&v.setClearColor(16777215,.5),v.clear(),Ht&&xt.render(O);let Rt=v.toneMapping;v.toneMapping=Mn;let St=z.viewport;if(z.viewport!==void 0&&(z.viewport=void 0),d.setupLightsView(z),Wt===!0&&nt.setGlobalState(v.clippingPlanes,z),Ns(y,O,z),Nt.updateMultisampleRenderTarget(j),Nt.updateRenderTargetMipmap(j),It.has("WEBGL_multisampled_render_to_texture")===!1){let kt=!1;for(let Yt=0,re=L.length;Yt<re;Yt++){let jt=L[Yt],$t=jt.object,Et=jt.geometry,ie=jt.material,Gt=jt.group;if(ie.side===Xe&&$t.layers.test(z.layers)){let Le=ie.side;ie.side=Ee,ie.needsUpdate=!0,dl($t,O,z,Et,ie,Gt),ie.side=Le,ie.needsUpdate=!0,kt=!0}}kt===!0&&(Nt.updateMultisampleRenderTarget(j),Nt.updateRenderTargetMipmap(j))}v.setRenderTarget(ft,ht,Tt),v.setClearColor(X,Z),St!==void 0&&(z.viewport=St),v.toneMapping=Rt}function Ns(y,L,O){let z=L.isScene===!0?L.overrideMaterial:null;for(let D=0,j=y.length;D<j;D++){let ot=y[D],ft=ot.object,ht=ot.geometry,Tt=ot.group,Rt=ot.material;Rt.allowOverride===!0&&z!==null&&(Rt=z),ft.layers.test(O.layers)&&dl(ft,L,O,ht,Rt,Tt)}}function dl(y,L,O,z,D,j){y.onBeforeRender(v,L,O,z,D,j),y.modelViewMatrix.multiplyMatrices(O.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),D.onBeforeRender(v,L,O,z,y,j),D.transparent===!0&&D.side===Xe&&D.forceSinglePass===!1?(D.side=Ee,D.needsUpdate=!0,v.renderBufferDirect(O,L,z,D,y,j),D.side=_n,D.needsUpdate=!0,v.renderBufferDirect(O,L,z,D,y,j),D.side=Xe):v.renderBufferDirect(O,L,z,D,y,j),y.onAfterRender(v,L,O,z,D,j)}function Fs(y,L,O){L.isScene!==!0&&(L=Mt);let z=gt.get(y),D=d.state.lights,j=d.state.shadowsArray,ot=D.state.version,ft=G.getParameters(y,D.state,j,L,O),ht=G.getProgramCacheKey(ft),Tt=z.programs;z.environment=y.isMeshStandardMaterial?L.environment:null,z.fog=L.fog,z.envMap=(y.isMeshStandardMaterial?le:pe).get(y.envMap||z.environment),z.envMapRotation=z.environment!==null&&y.envMap===null?L.environmentRotation:y.envMapRotation,Tt===void 0&&(y.addEventListener("dispose",Y),Tt=new Map,z.programs=Tt);let Rt=Tt.get(ht);if(Rt!==void 0){if(z.currentProgram===Rt&&z.lightsStateVersion===ot)return pl(y,ft),Rt}else ft.uniforms=G.getUniforms(y),y.onBeforeCompile(ft,v),Rt=G.acquireProgram(ft,ht),Tt.set(ht,Rt),z.uniforms=ft.uniforms;let St=z.uniforms;return(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)&&(St.clippingPlanes=nt.uniform),pl(y,ft),z.needsLights=_h(y),z.lightsStateVersion=ot,z.needsLights&&(St.ambientLightColor.value=D.state.ambient,St.lightProbe.value=D.state.probe,St.directionalLights.value=D.state.directional,St.directionalLightShadows.value=D.state.directionalShadow,St.spotLights.value=D.state.spot,St.spotLightShadows.value=D.state.spotShadow,St.rectAreaLights.value=D.state.rectArea,St.ltc_1.value=D.state.rectAreaLTC1,St.ltc_2.value=D.state.rectAreaLTC2,St.pointLights.value=D.state.point,St.pointLightShadows.value=D.state.pointShadow,St.hemisphereLights.value=D.state.hemi,St.directionalShadowMap.value=D.state.directionalShadowMap,St.directionalShadowMatrix.value=D.state.directionalShadowMatrix,St.spotShadowMap.value=D.state.spotShadowMap,St.spotLightMatrix.value=D.state.spotLightMatrix,St.spotLightMap.value=D.state.spotLightMap,St.pointShadowMap.value=D.state.pointShadowMap,St.pointShadowMatrix.value=D.state.pointShadowMatrix),z.currentProgram=Rt,z.uniformsList=null,Rt}function fl(y){if(y.uniformsList===null){let L=y.currentProgram.getUniforms();y.uniformsList=Hi.seqWithValue(L.seq,y.uniforms)}return y.uniformsList}function pl(y,L){let O=gt.get(y);O.outputColorSpace=L.outputColorSpace,O.batching=L.batching,O.batchingColor=L.batchingColor,O.instancing=L.instancing,O.instancingColor=L.instancingColor,O.instancingMorph=L.instancingMorph,O.skinning=L.skinning,O.morphTargets=L.morphTargets,O.morphNormals=L.morphNormals,O.morphColors=L.morphColors,O.morphTargetsCount=L.morphTargetsCount,O.numClippingPlanes=L.numClippingPlanes,O.numIntersection=L.numClipIntersection,O.vertexAlphas=L.vertexAlphas,O.vertexTangents=L.vertexTangents,O.toneMapping=L.toneMapping}function mh(y,L,O,z,D){L.isScene!==!0&&(L=Mt),Nt.resetTextureUnits();let j=L.fog,ot=z.isMeshStandardMaterial?L.environment:null,ft=U===null?v.outputColorSpace:U.isXRRenderTarget===!0?U.texture.colorSpace:$n,ht=(z.isMeshStandardMaterial?le:pe).get(z.envMap||ot),Tt=z.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,Rt=!!O.attributes.tangent&&(!!z.normalMap||z.anisotropy>0),St=!!O.morphAttributes.position,kt=!!O.morphAttributes.normal,Yt=!!O.morphAttributes.color,re=Mn;z.toneMapped&&(U===null||U.isXRRenderTarget===!0)&&(re=v.toneMapping);let jt=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,$t=jt!==void 0?jt.length:0,Et=gt.get(z),ie=d.state.lights;if(Wt===!0&&(q===!0||y!==b)){let Me=y===b&&z.id===S;nt.setState(z,y,Me)}let Gt=!1;z.version===Et.__version?(Et.needsLights&&Et.lightsStateVersion!==ie.state.version||Et.outputColorSpace!==ft||D.isBatchedMesh&&Et.batching===!1||!D.isBatchedMesh&&Et.batching===!0||D.isBatchedMesh&&Et.batchingColor===!0&&D.colorTexture===null||D.isBatchedMesh&&Et.batchingColor===!1&&D.colorTexture!==null||D.isInstancedMesh&&Et.instancing===!1||!D.isInstancedMesh&&Et.instancing===!0||D.isSkinnedMesh&&Et.skinning===!1||!D.isSkinnedMesh&&Et.skinning===!0||D.isInstancedMesh&&Et.instancingColor===!0&&D.instanceColor===null||D.isInstancedMesh&&Et.instancingColor===!1&&D.instanceColor!==null||D.isInstancedMesh&&Et.instancingMorph===!0&&D.morphTexture===null||D.isInstancedMesh&&Et.instancingMorph===!1&&D.morphTexture!==null||Et.envMap!==ht||z.fog===!0&&Et.fog!==j||Et.numClippingPlanes!==void 0&&(Et.numClippingPlanes!==nt.numPlanes||Et.numIntersection!==nt.numIntersection)||Et.vertexAlphas!==Tt||Et.vertexTangents!==Rt||Et.morphTargets!==St||Et.morphNormals!==kt||Et.morphColors!==Yt||Et.toneMapping!==re||Et.morphTargetsCount!==$t)&&(Gt=!0):(Gt=!0,Et.__version=z.version);let Le=Et.currentProgram;Gt===!0&&(Le=Fs(z,L,D));let ai=!1,De=!1,qi=!1,se=Le.getUniforms(),ze=Et.uniforms;if(mt.useProgram(Le.program)&&(ai=!0,De=!0,qi=!0),z.id!==S&&(S=z.id,De=!0),ai||b!==y){mt.buffers.depth.getReversed()&&y.reversedDepth!==!0&&(y._reversedDepth=!0,y.updateProjectionMatrix()),se.setValue(A,"projectionMatrix",y.projectionMatrix),se.setValue(A,"viewMatrix",y.matrixWorldInverse);let Te=se.map.cameraPosition;Te!==void 0&&Te.setValue(A,dt.setFromMatrixPosition(y.matrixWorld)),At.logarithmicDepthBuffer&&se.setValue(A,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)&&se.setValue(A,"isOrthographic",y.isOrthographicCamera===!0),b!==y&&(b=y,De=!0,qi=!0)}if(D.isSkinnedMesh){se.setOptional(A,D,"bindMatrix"),se.setOptional(A,D,"bindMatrixInverse");let Me=D.skeleton;Me&&(Me.boneTexture===null&&Me.computeBoneTexture(),se.setValue(A,"boneTexture",Me.boneTexture,Nt))}D.isBatchedMesh&&(se.setOptional(A,D,"batchingTexture"),se.setValue(A,"batchingTexture",D._matricesTexture,Nt),se.setOptional(A,D,"batchingIdTexture"),se.setValue(A,"batchingIdTexture",D._indirectTexture,Nt),se.setOptional(A,D,"batchingColorTexture"),D._colorsTexture!==null&&se.setValue(A,"batchingColorTexture",D._colorsTexture,Nt));let ke=O.morphAttributes;if((ke.position!==void 0||ke.normal!==void 0||ke.color!==void 0)&&Q.update(D,O,Le),(De||Et.receiveShadow!==D.receiveShadow)&&(Et.receiveShadow=D.receiveShadow,se.setValue(A,"receiveShadow",D.receiveShadow)),z.isMeshGouraudMaterial&&z.envMap!==null&&(ze.envMap.value=ht,ze.flipEnvMap.value=ht.isCubeTexture&&ht.isRenderTargetTexture===!1?-1:1),z.isMeshStandardMaterial&&z.envMap===null&&L.environment!==null&&(ze.envMapIntensity.value=L.environmentIntensity),De&&(se.setValue(A,"toneMappingExposure",v.toneMappingExposure),Et.needsLights&&gh(ze,qi),j&&z.fog===!0&&$.refreshFogUniforms(ze,j),$.refreshMaterialUniforms(ze,z,k,et,d.state.transmissionRenderTarget[y.id]),Hi.upload(A,fl(Et),ze,Nt)),z.isShaderMaterial&&z.uniformsNeedUpdate===!0&&(Hi.upload(A,fl(Et),ze,Nt),z.uniformsNeedUpdate=!1),z.isSpriteMaterial&&se.setValue(A,"center",D.center),se.setValue(A,"modelViewMatrix",D.modelViewMatrix),se.setValue(A,"normalMatrix",D.normalMatrix),se.setValue(A,"modelMatrix",D.matrixWorld),z.isShaderMaterial||z.isRawShaderMaterial){let Me=z.uniformsGroups;for(let Te=0,ka=Me.length;Te<ka;Te++){let kn=Me[Te];Dt.update(kn,Le),Dt.bind(kn,Le)}}return Le}function gh(y,L){y.ambientLightColor.needsUpdate=L,y.lightProbe.needsUpdate=L,y.directionalLights.needsUpdate=L,y.directionalLightShadows.needsUpdate=L,y.pointLights.needsUpdate=L,y.pointLightShadows.needsUpdate=L,y.spotLights.needsUpdate=L,y.spotLightShadows.needsUpdate=L,y.rectAreaLights.needsUpdate=L,y.hemisphereLights.needsUpdate=L}function _h(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return U},this.setRenderTargetTextures=function(y,L,O){let z=gt.get(y);z.__autoAllocateDepthBuffer=y.resolveDepthBuffer===!1,z.__autoAllocateDepthBuffer===!1&&(z.__useRenderToTexture=!1),gt.get(y.texture).__webglTexture=L,gt.get(y.depthTexture).__webglTexture=z.__autoAllocateDepthBuffer?void 0:O,z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(y,L){let O=gt.get(y);O.__webglFramebuffer=L,O.__useDefaultFramebuffer=L===void 0};let xh=A.createFramebuffer();this.setRenderTarget=function(y,L=0,O=0){U=y,w=L,C=O;let z=!0,D=null,j=!1,ot=!1;if(y){let ht=gt.get(y);if(ht.__useDefaultFramebuffer!==void 0)mt.bindFramebuffer(A.FRAMEBUFFER,null),z=!1;else if(ht.__webglFramebuffer===void 0)Nt.setupRenderTarget(y);else if(ht.__hasExternalTextures)Nt.rebindTextures(y,gt.get(y.texture).__webglTexture,gt.get(y.depthTexture).__webglTexture);else if(y.depthBuffer){let St=y.depthTexture;if(ht.__boundDepthTexture!==St){if(St!==null&&gt.has(St)&&(y.width!==St.image.width||y.height!==St.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Nt.setupDepthRenderbuffer(y)}}let Tt=y.texture;(Tt.isData3DTexture||Tt.isDataArrayTexture||Tt.isCompressedArrayTexture)&&(ot=!0);let Rt=gt.get(y).__webglFramebuffer;y.isWebGLCubeRenderTarget?(Array.isArray(Rt[L])?D=Rt[L][O]:D=Rt[L],j=!0):y.samples>0&&Nt.useMultisampledRTT(y)===!1?D=gt.get(y).__webglMultisampledFramebuffer:Array.isArray(Rt)?D=Rt[O]:D=Rt,P.copy(y.viewport),B.copy(y.scissor),V=y.scissorTest}else P.copy(bt).multiplyScalar(k).floor(),B.copy(Bt).multiplyScalar(k).floor(),V=Jt;if(O!==0&&(D=xh),mt.bindFramebuffer(A.FRAMEBUFFER,D)&&z&&mt.drawBuffers(y,D),mt.viewport(P),mt.scissor(B),mt.setScissorTest(V),j){let ht=gt.get(y.texture);A.framebufferTexture2D(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_CUBE_MAP_POSITIVE_X+L,ht.__webglTexture,O)}else if(ot){let ht=L;for(let Tt=0;Tt<y.textures.length;Tt++){let Rt=gt.get(y.textures[Tt]);A.framebufferTextureLayer(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0+Tt,Rt.__webglTexture,O,ht)}}else if(y!==null&&O!==0){let ht=gt.get(y.texture);A.framebufferTexture2D(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,ht.__webglTexture,O)}S=-1},this.readRenderTargetPixels=function(y,L,O,z,D,j,ot,ft=0){if(!(y&&y.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ht=gt.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&ot!==void 0&&(ht=ht[ot]),ht){mt.bindFramebuffer(A.FRAMEBUFFER,ht);try{let Tt=y.textures[ft],Rt=Tt.format,St=Tt.type;if(!At.textureFormatReadable(Rt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!At.textureTypeReadable(St)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}L>=0&&L<=y.width-z&&O>=0&&O<=y.height-D&&(y.textures.length>1&&A.readBuffer(A.COLOR_ATTACHMENT0+ft),A.readPixels(L,O,z,D,yt.convert(Rt),yt.convert(St),j))}finally{let Tt=U!==null?gt.get(U).__webglFramebuffer:null;mt.bindFramebuffer(A.FRAMEBUFFER,Tt)}}},this.readRenderTargetPixelsAsync=async function(y,L,O,z,D,j,ot,ft=0){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ht=gt.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&ot!==void 0&&(ht=ht[ot]),ht)if(L>=0&&L<=y.width-z&&O>=0&&O<=y.height-D){mt.bindFramebuffer(A.FRAMEBUFFER,ht);let Tt=y.textures[ft],Rt=Tt.format,St=Tt.type;if(!At.textureFormatReadable(Rt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!At.textureTypeReadable(St))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let kt=A.createBuffer();A.bindBuffer(A.PIXEL_PACK_BUFFER,kt),A.bufferData(A.PIXEL_PACK_BUFFER,j.byteLength,A.STREAM_READ),y.textures.length>1&&A.readBuffer(A.COLOR_ATTACHMENT0+ft),A.readPixels(L,O,z,D,yt.convert(Rt),yt.convert(St),0);let Yt=U!==null?gt.get(U).__webglFramebuffer:null;mt.bindFramebuffer(A.FRAMEBUFFER,Yt);let re=A.fenceSync(A.SYNC_GPU_COMMANDS_COMPLETE,0);return A.flush(),await Rc(A,re,4),A.bindBuffer(A.PIXEL_PACK_BUFFER,kt),A.getBufferSubData(A.PIXEL_PACK_BUFFER,0,j),A.deleteBuffer(kt),A.deleteSync(re),j}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,L=null,O=0){let z=Math.pow(2,-O),D=Math.floor(y.image.width*z),j=Math.floor(y.image.height*z),ot=L!==null?L.x:0,ft=L!==null?L.y:0;Nt.setTexture2D(y,0),A.copyTexSubImage2D(A.TEXTURE_2D,O,0,0,ot,ft,D,j),mt.unbindTexture()};let yh=A.createFramebuffer(),vh=A.createFramebuffer();this.copyTextureToTexture=function(y,L,O=null,z=null,D=0,j=null){j===null&&(D!==0?(Ti("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),j=D,D=0):j=0);let ot,ft,ht,Tt,Rt,St,kt,Yt,re,jt=y.isCompressedTexture?y.mipmaps[j]:y.image;if(O!==null)ot=O.max.x-O.min.x,ft=O.max.y-O.min.y,ht=O.isBox3?O.max.z-O.min.z:1,Tt=O.min.x,Rt=O.min.y,St=O.isBox3?O.min.z:0;else{let ke=Math.pow(2,-D);ot=Math.floor(jt.width*ke),ft=Math.floor(jt.height*ke),y.isDataArrayTexture?ht=jt.depth:y.isData3DTexture?ht=Math.floor(jt.depth*ke):ht=1,Tt=0,Rt=0,St=0}z!==null?(kt=z.x,Yt=z.y,re=z.z):(kt=0,Yt=0,re=0);let $t=yt.convert(L.format),Et=yt.convert(L.type),ie;L.isData3DTexture?(Nt.setTexture3D(L,0),ie=A.TEXTURE_3D):L.isDataArrayTexture||L.isCompressedArrayTexture?(Nt.setTexture2DArray(L,0),ie=A.TEXTURE_2D_ARRAY):(Nt.setTexture2D(L,0),ie=A.TEXTURE_2D),A.pixelStorei(A.UNPACK_FLIP_Y_WEBGL,L.flipY),A.pixelStorei(A.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),A.pixelStorei(A.UNPACK_ALIGNMENT,L.unpackAlignment);let Gt=A.getParameter(A.UNPACK_ROW_LENGTH),Le=A.getParameter(A.UNPACK_IMAGE_HEIGHT),ai=A.getParameter(A.UNPACK_SKIP_PIXELS),De=A.getParameter(A.UNPACK_SKIP_ROWS),qi=A.getParameter(A.UNPACK_SKIP_IMAGES);A.pixelStorei(A.UNPACK_ROW_LENGTH,jt.width),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,jt.height),A.pixelStorei(A.UNPACK_SKIP_PIXELS,Tt),A.pixelStorei(A.UNPACK_SKIP_ROWS,Rt),A.pixelStorei(A.UNPACK_SKIP_IMAGES,St);let se=y.isDataArrayTexture||y.isData3DTexture,ze=L.isDataArrayTexture||L.isData3DTexture;if(y.isDepthTexture){let ke=gt.get(y),Me=gt.get(L),Te=gt.get(ke.__renderTarget),ka=gt.get(Me.__renderTarget);mt.bindFramebuffer(A.READ_FRAMEBUFFER,Te.__webglFramebuffer),mt.bindFramebuffer(A.DRAW_FRAMEBUFFER,ka.__webglFramebuffer);for(let kn=0;kn<ht;kn++)se&&(A.framebufferTextureLayer(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,gt.get(y).__webglTexture,D,St+kn),A.framebufferTextureLayer(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,gt.get(L).__webglTexture,j,re+kn)),A.blitFramebuffer(Tt,Rt,ot,ft,kt,Yt,ot,ft,A.DEPTH_BUFFER_BIT,A.NEAREST);mt.bindFramebuffer(A.READ_FRAMEBUFFER,null),mt.bindFramebuffer(A.DRAW_FRAMEBUFFER,null)}else if(D!==0||y.isRenderTargetTexture||gt.has(y)){let ke=gt.get(y),Me=gt.get(L);mt.bindFramebuffer(A.READ_FRAMEBUFFER,yh),mt.bindFramebuffer(A.DRAW_FRAMEBUFFER,vh);for(let Te=0;Te<ht;Te++)se?A.framebufferTextureLayer(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,ke.__webglTexture,D,St+Te):A.framebufferTexture2D(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,ke.__webglTexture,D),ze?A.framebufferTextureLayer(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,Me.__webglTexture,j,re+Te):A.framebufferTexture2D(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,Me.__webglTexture,j),D!==0?A.blitFramebuffer(Tt,Rt,ot,ft,kt,Yt,ot,ft,A.COLOR_BUFFER_BIT,A.NEAREST):ze?A.copyTexSubImage3D(ie,j,kt,Yt,re+Te,Tt,Rt,ot,ft):A.copyTexSubImage2D(ie,j,kt,Yt,Tt,Rt,ot,ft);mt.bindFramebuffer(A.READ_FRAMEBUFFER,null),mt.bindFramebuffer(A.DRAW_FRAMEBUFFER,null)}else ze?y.isDataTexture||y.isData3DTexture?A.texSubImage3D(ie,j,kt,Yt,re,ot,ft,ht,$t,Et,jt.data):L.isCompressedArrayTexture?A.compressedTexSubImage3D(ie,j,kt,Yt,re,ot,ft,ht,$t,jt.data):A.texSubImage3D(ie,j,kt,Yt,re,ot,ft,ht,$t,Et,jt):y.isDataTexture?A.texSubImage2D(A.TEXTURE_2D,j,kt,Yt,ot,ft,$t,Et,jt.data):y.isCompressedTexture?A.compressedTexSubImage2D(A.TEXTURE_2D,j,kt,Yt,jt.width,jt.height,$t,jt.data):A.texSubImage2D(A.TEXTURE_2D,j,kt,Yt,ot,ft,$t,Et,jt);A.pixelStorei(A.UNPACK_ROW_LENGTH,Gt),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,Le),A.pixelStorei(A.UNPACK_SKIP_PIXELS,ai),A.pixelStorei(A.UNPACK_SKIP_ROWS,De),A.pixelStorei(A.UNPACK_SKIP_IMAGES,qi),j===0&&L.generateMipmaps&&A.generateMipmap(ie),mt.unbindTexture()},this.initRenderTarget=function(y){gt.get(y).__webglFramebuffer===void 0&&Nt.setupRenderTarget(y)},this.initTexture=function(y){y.isCubeTexture?Nt.setTextureCube(y,0):y.isData3DTexture?Nt.setTexture3D(y,0):y.isDataArrayTexture||y.isCompressedArrayTexture?Nt.setTexture2DArray(y,0):Nt.setTexture2D(y,0),mt.unbindTexture()},this.resetState=function(){w=0,C=0,U=null,mt.reset(),at.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Je}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=Vt._getDrawingBufferColorSpace(t),e.unpackColorSpace=Vt._getUnpackColorSpace()}};var ah={type:"change"},rl={type:"start"},lh={type:"end"},Pa=new Dn,oh=new Ve,Qm=Math.cos(70*Oo.DEG2RAD),fe=new N,Ie=2*Math.PI,Zt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},sl=1e-6,Ia=class extends Ss{constructor(t,e=null){super(t,e),this.state=Zt.NONE,this.target=new N,this.cursor=new N,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:Se.ROTATE,MIDDLE:Se.DOLLY,RIGHT:Se.PAN},this.touches={ONE:Be.ROTATE,TWO:Be.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new N,this._lastQuaternion=new We,this._lastTargetPosition=new N,this._quat=new We().setFromUnitVectors(t.up,new N(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Di,this._sphericalDelta=new Di,this._scale=1,this._panOffset=new N,this._rotateStart=new Ut,this._rotateEnd=new Ut,this._rotateDelta=new Ut,this._panStart=new Ut,this._panEnd=new Ut,this._panDelta=new Ut,this._dollyStart=new Ut,this._dollyEnd=new Ut,this._dollyDelta=new Ut,this._dollyDirection=new N,this._mouse=new Ut,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=eg.bind(this),this._onPointerDown=tg.bind(this),this._onPointerUp=ng.bind(this),this._onContextMenu=cg.bind(this),this._onMouseWheel=rg.bind(this),this._onKeyDown=ag.bind(this),this._onTouchStart=og.bind(this),this._onTouchMove=lg.bind(this),this._onMouseDown=ig.bind(this),this._onMouseMove=sg.bind(this),this._interceptControlDown=hg.bind(this),this._interceptControlUp=ug.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(t){super.connect(t),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.removeEventListener("pointermove",this._onPointerMove),this.domElement.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="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}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(ah),this.update(),this.state=Zt.NONE}update(t=null){let e=this.object.position;fe.copy(e).sub(this.target),fe.applyQuaternion(this._quat),this._spherical.setFromVector3(fe),this.autoRotate&&this.state===Zt.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),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+=Ie:n>Math.PI&&(n-=Ie),s<-Math.PI?s+=Ie:s>Math.PI&&(s-=Ie),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(fe.setFromSpherical(this._spherical),fe.applyQuaternion(this._quatInverse),e.copy(this.target).add(fe),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=fe.length();a=this._clampDistance(o*this._scale);let c=o-a;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),r=!!c}else if(this.object.isOrthographicCamera){let o=new N(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=c!==this.object.zoom;let l=new N(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(o),this.object.updateMatrixWorld(),a=fe.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):(Pa.origin.copy(this.object.position),Pa.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Pa.direction))<Qm?this.object.lookAt(this.target):(oh.setFromNormalAndCoplanarPoint(this.object.up,this.target),Pa.intersectPlane(oh,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)>sl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>sl||this._lastTargetPosition.distanceToSquared(this.target)>sl?(this.dispatchEvent(ah),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?Ie/60*this.autoRotateSpeed*t:Ie/60/60*this.autoRotateSpeed}_getZoomScale(t){let e=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){fe.setFromMatrixColumn(e,0),fe.multiplyScalar(-t),this._panOffset.add(fe)}_panUp(t,e){this.screenSpacePanning===!0?fe.setFromMatrixColumn(e,1):(fe.setFromMatrixColumn(e,0),fe.crossVectors(this.object.up,fe)),fe.multiplyScalar(t),this._panOffset.add(fe)}_pan(t,e){let n=this.domElement;if(this.object.isPerspectiveCamera){let s=this.object.position;fe.copy(s).sub(this.target);let r=fe.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*r/n.clientHeight,this.object.matrix),this._panUp(2*e*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(e*(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(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),s=t-n.left,r=e-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(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let e=this.domElement;this._rotateLeft(Ie*this._rotateDelta.x/e.clientHeight),this._rotateUp(Ie*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.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(t){this._panEnd.set(t.clientX,t.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(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(Ie*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(-Ie*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(Ie*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(-Ie*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{let e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{let e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panStart.set(n,s)}}_handleTouchStartDolly(t){let e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{let n=this._getSecondPointerPosition(t),s=.5*(t.pageX+n.x),r=.5*(t.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let e=this.domElement;this._rotateLeft(Ie*this._rotateDelta.x/e.clientHeight),this._rotateUp(Ie*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{let e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.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(t){let e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.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=(t.pageX+e.x)*.5,o=(t.pageY+e.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId){this._pointers.splice(e,1);return}}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(t){let e=this._pointerPositions[t.pointerId];e===void 0&&(e=new Ut,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){let e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){let e=t.deltaMode,n={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function tg(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function eg(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function ng(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(lh),this.state=Zt.NONE;break;case 1:let t=this._pointers[0],e=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:e.x,pageY:e.y});break}}function ig(i){let t;switch(i.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case Se.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=Zt.DOLLY;break;case Se.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Zt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Zt.ROTATE}break;case Se.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Zt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Zt.PAN}break;default:this.state=Zt.NONE}this.state!==Zt.NONE&&this.dispatchEvent(rl)}function sg(i){switch(this.state){case Zt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case Zt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case Zt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function rg(i){this.enabled===!1||this.enableZoom===!1||this.state!==Zt.NONE||(i.preventDefault(),this.dispatchEvent(rl),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(lh))}function ag(i){this.enabled!==!1&&this._handleKeyDown(i)}function og(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case Be.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=Zt.TOUCH_ROTATE;break;case Be.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=Zt.TOUCH_PAN;break;default:this.state=Zt.NONE}break;case 2:switch(this.touches.TWO){case Be.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=Zt.TOUCH_DOLLY_PAN;break;case Be.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=Zt.TOUCH_DOLLY_ROTATE;break;default:this.state=Zt.NONE}break;default:this.state=Zt.NONE}this.state!==Zt.NONE&&this.dispatchEvent(rl)}function lg(i){switch(this._trackPointer(i),this.state){case Zt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case Zt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case Zt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case Zt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=Zt.NONE}}function cg(i){this.enabled!==!1&&i.preventDefault()}function hg(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function ug(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}var ol={background:"#000000",craft:"#F0E442",primary:"#56B4E9",secondary:"#A8A8A8",grid:"#1e1e1e",axis:"#555555",text:"#cfcfcf"},ch=.05,dg=.55,fg=40,pg=.4,mg=.3,La=.07,gg=6,_g=22,xg=60,yg=320;function vg(){let i=document.createElement("canvas");i.width=i.height=64;let t=i.getContext("2d");t.fillStyle="#fff",t.beginPath(),t.arc(32,32,28,0,Math.PI*2),t.fill();let e=new _s(i);return e.needsUpdate=!0,e}function al(i,t,e,n){let s=new ye;s.setAttribute("position",new ae(new Float32Array(3*n),3));let r=new Ii({color:i,size:t,map:e,transparent:!0,alphaTest:.5,sizeAttenuation:!1,depthTest:!1});return new gs(s,r)}function Da(i,t,e){let n=new ye;n.setAttribute("position",new ae(new Float32Array(3*e),3));let s=new Un({color:i,transparent:!0,opacity:t,depthTest:!1});return new Ci(n,s)}function hh(i,t=6){let e=i/t,n=Math.pow(10,Math.floor(Math.log10(e))),s=e/n;return(s<1.5?1:s<3.5?2:s<7.5?5:10)*n}var Gi=class{constructor(t,e="rotating_pulsating"){this.scene=new ps;this.palette=ol;this.frame="rotating_pulsating";this.showGhost=!0;this.showTitle=!1;this.threeD=!1;this.sys={mu:.5,e:0,f0:0};this.xy=new Float32Array(0);this.fRel=new Float32Array(0);this.xyz=new Float32Array(0);this.fNow=0;this.tracks=null;this.familyMode="hidden";this.paramRange=null;this.alphaNow=new Float32Array(0);this.alphaFrom=new Float32Array(0);this.alphaTo=new Float32Array(0);this.baseAlpha=new Float32Array(0);this.written=new Float32Array(0);this.fadeLast=0;this.fadeRaf=0;this.trailPts=new Float32Array(0);this.trailT=new Float32Array(0);this.trailCount=0;this.memberRgb=[1,1,1];this.userMoved=!1;this.host=t,this.frame=e,this.canvas=document.createElement("canvas"),this.overlay=document.createElement("canvas");for(let a of[this.canvas,this.overlay])a.style.position="absolute",a.style.inset="0",a.style.width="100%",a.style.height="100%";this.overlay.style.pointerEvents="none",t.style.position="relative",t.appendChild(this.canvas),t.appendChild(this.overlay),this.renderer=new Ra({canvas:this.canvas,antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.setClearColor(new zt(this.palette.background),1),this.camera=new Li(-1,1,1,-1,-100,100),this.camera.position.set(0,0,10),this.camera.up.set(0,1,0),this.controls=new Ia(this.camera,this.canvas),this.controls.enableDamping=!1,this.controls.screenSpacePanning=!0,this.controls.zoomToCursor=!0,this.controls.addEventListener("change",()=>{this.userMoved=!0,this.render()});let n=vg();this.family=new Pi(new ye,new Un({vertexColors:!0,transparent:!0,opacity:1,depthTest:!1})),this.family.visible=!1,this.ghost=Da("#d0d0d0",.8,2),this.orbit=Da("#ffffff",1,2);let s=a=>new Pe(new ye,new Jn({vertexColors:!0,transparent:!0,depthTest:!1,depthWrite:!1,blending:a,side:Xe}));this.trailGlow=s(Es),this.trailCore=s(xn),this.primaryTrail=Da(this.palette.primary,.3,2),this.secondaryTrail=Da(this.palette.secondary,.3,2),this.craft=al(this.palette.craft,9,n,1),this.primary=al(this.palette.primary,8,n,1),this.secondary=al(this.palette.secondary,6,n,1),this.grid=new bs(4,16,this.palette.axis,this.palette.grid),this.grid.rotation.x=Math.PI/2,this.grid.visible=!1;let r=[this.grid,this.family,this.primaryTrail,this.secondaryTrail,this.ghost,this.trailGlow,this.trailCore,this.orbit,this.primary,this.secondary,this.craft];r.forEach((a,o)=>a.renderOrder=o),this.scene.add(...r),this.setThreeD(!1),this.ro=new ResizeObserver(()=>this.resize()),this.ro.observe(t),this.resize()}dispose(){cancelAnimationFrame(this.fadeRaf),this.ro.disconnect(),this.controls.dispose(),this.renderer.dispose()}get system(){return this.sys}get epoch(){return this.fNow}memberColor(){let t=this.paramRange,e=t&&t[1]>t[0]?(this.sys.e-t[0])/(t[1]-t[0]):.5;return Ji(this.spec().cmap,e)}setTrajectory(t,e,n,s=!1){let r=n.e!==this.sys.e;this.xy=t,this.fRel=e,this.sys=n;let a=e.length;if(this.xyz.length!==3*a){this.xyz=new Float32Array(3*a);for(let l of[this.ghost,this.primaryTrail,this.secondaryTrail])l.geometry.setAttribute("position",new ae(new Float32Array(3*a),3));this.orbit.geometry.setAttribute("position",new ae(new Float32Array(3*(a+1)),3));let o=a+3;this.trailPts=new Float32Array(2*o),this.trailT=new Float32Array(o);let c=[];for(let l=0;l<o-1;l++)c.push(2*l,2*l+1,2*l+2,2*l+1,2*l+3,2*l+2);for(let l of[this.trailCore,this.trailGlow])l.geometry.setAttribute("position",new ae(new Float32Array(6*o),3)),l.geometry.setAttribute("color",new ae(new Float32Array(8*o),4)),l.geometry.setIndex(c),l.frustumCulled=!1}this.recompute(),r&&this.focusFamily(!1),s&&this.fit()}setFamily(t,e){let n=t!==this.tracks;this.tracks=t,this.familyMode=t?e:"hidden",n&&this.rebuildFamily(),this.family.visible=this.familyMode!=="hidden"&&!!t,this.focusFamily(!0),this.recolour(),this.render()}setFrame(t){t!==this.frame&&(this.frame=t,this.recompute(),this.rebuildFamily(),this.fit())}setThreeD(t){this.threeD=t,this.controls.enableRotate=t,this.controls.mouseButtons=t?{LEFT:Se.ROTATE,MIDDLE:Se.DOLLY,RIGHT:Se.PAN}:{LEFT:Se.PAN,MIDDLE:Se.DOLLY,RIGHT:Se.PAN},this.controls.touches=t?{ONE:Be.ROTATE,TWO:Be.DOLLY_PAN}:{ONE:Be.PAN,TWO:Be.DOLLY_PAN},this.grid.visible=t,this.overlay.style.display=t?"none":"",t?this.render():this.fit()}spec(){return hn.find(t=>t.id===this.frame)}rebuildFamily(){let t=this.tracks;if(!t){this.paramRange=null,this.family.visible=!1;return}let e=t.count,n=t.samples,s=1/0,r=-1/0;for(let _=0;_<e;_++)s=Math.min(s,t.params[_]),r=Math.max(r,t.params[_]);this.paramRange=[s,r],this.alphaNow.length!==e&&(this.alphaNow=new Float32Array(e),this.alphaFrom=new Float32Array(e),this.alphaTo=new Float32Array(e),this.baseAlpha=new Float32Array(e),this.written=new Float32Array(e)),this.written.fill(-2);let a=e*(n-1),o=new Float32Array(a*6),c=new Float32Array(a*8),l=new Float32Array(3*n),h=[0,0,0],f=this.spec().cmap,u=0,p=0;for(let _=0;_<e;_++){let m=t.positions.subarray(_*n*2,(_+1)*n*2),d=t.anomalies.subarray(_*n,(_+1)*n);Zi(m,d,{mu:t.mu,e:t.params[_],f0:t.f0},this.frame,l);let T=r>s?(t.params[_]-s)/(r-s):.5;li(f,T,h);let M=0;for(let v=0;v<n-1;v++)o[u]=l[3*v],o[u+1]=l[3*v+1],o[u+2]=0,o[u+3]=l[3*v+3],o[u+4]=l[3*v+4],o[u+5]=0,u+=6,c[p]=c[p+4]=h[0],c[p+1]=c[p+5]=h[1],c[p+2]=c[p+6]=h[2],c[p+3]=c[p+7]=M,p+=8}let g=this.family.geometry;g.setAttribute("position",new ae(o,3)),g.setAttribute("color",new ae(c,4)),g.computeBoundingSphere(),this.family.visible=this.familyMode!=="hidden"}focusFamily(t=!1){let e=this.tracks,n=this.paramRange;if(!e||!n)return;let s=e.count,r=Math.max(1e-9,n[1]-n[0]),a=ch*r,o=Math.max(1,Math.round(s/fg)),c=-1;for(let h=0;h<s;h++)e.params[h]===this.sys.e&&(c=h);for(let h=0;h<s;h++){let f=this.familyMode==="family"&&(h%o===0||h===s-1),u=(e.params[h]-this.sys.e)/a;this.baseAlpha[h]=f&&h!==c?pg:0,this.alphaTo[h]=h===c?0:dg*Math.exp(-u*u)}if(this.familyMode==="hidden"&&(this.alphaTo.fill(0),this.baseAlpha.fill(0)),cancelAnimationFrame(this.fadeRaf),t||this.familyMode==="hidden"){this.alphaNow.set(this.alphaTo),this.writeAlpha();return}this.fadeLast=performance.now();let l=h=>{let f=Math.max(0,h-this.fadeLast);this.fadeLast=h;let u=1-Math.exp(-f/xg),p=1-Math.exp(-f/yg),g=0;for(let _=0;_<s;_++){let m=this.alphaNow[_],d=this.alphaTo[_],T=m+(d-m)*(d>m?u:p);this.alphaNow[_]=T,g=Math.max(g,Math.abs(d-T))}g<.004&&this.alphaNow.set(this.alphaTo),this.writeAlpha(),this.render(),g>=.004&&(this.fadeRaf=requestAnimationFrame(l))};this.fadeRaf=requestAnimationFrame(l)}writeAlpha(){let t=this.tracks,e=this.family.geometry.getAttribute("color");if(!t||!e)return;let n=e.array,s=(t.samples-1)*8,r=!1;for(let a=0;a<t.count;a++){let o=Math.max(this.baseAlpha[a],this.alphaNow[a]);if(this.written[a]===o)continue;let c=a*s;for(let l=c+3;l<c+s;l+=4)n[l]=o;this.written[a]=o,r=!0}r&&(e.needsUpdate=!0)}recolour(){let t=this.memberColor();this.orbit.material.color.set(t),this.ghost.material.color.set(t);let e=this.paramRange,n=e&&e[1]>e[0]?(this.sys.e-e[0])/(e[1]-e[0]):.5;li(this.spec().cmap,n,this.memberRgb)}recompute(){let t=this.fRel.length;if(!t)return;Zi(this.xy,this.fRel,this.sys,this.frame,this.xyz),this.ghost.geometry.getAttribute("position").set(this.xyz).needsUpdate=!0,this.ghost.geometry.setDrawRange(0,t),this.recolour();let e=this.primaryTrail.geometry.getAttribute("position"),n=this.secondaryTrail.geometry.getAttribute("position");$i("primary",this.fRel,this.sys,this.frame,e.array),$i("secondary",this.fRel,this.sys,this.frame,n.array),e.needsUpdate=n.needsUpdate=!0,this.primaryTrail.geometry.setDrawRange(0,t),this.secondaryTrail.geometry.setDrawRange(0,t);for(let s of[this.ghost,this.primaryTrail,this.secondaryTrail])s.geometry.computeBoundingSphere();this.showAt(this.fNow)}showAt(t){let e=this.fRel.length;if(!e)return;let n=this.fRel,s=Math.max(n[0],Math.min(n[e-1],t));this.fNow=s;let r=ks(n,s),a=n[r+1]-n[r],o=a>0?(s-n[r])/a:0,c=this.xyz[3*r]+(this.xyz[3*r+3]-this.xyz[3*r])*o,l=this.xyz[3*r+1]+(this.xyz[3*r+4]-this.xyz[3*r+1])*o,h=n[e-1]-n[0],f=mg*h,u=this.trailPts,p=this.trailT,g=0;u[0]=c,u[1]=l,p[0]=0,g=1;let _=r,m=!1;for(;g<e;){let w=(m?s+h:s)-n[_];if(w>=f){let C=p[g-1]*f,U=(f-C)/Math.max(1e-12,w-C);u[2*g]=u[2*g-2]+(this.xyz[3*_]-u[2*g-2])*U,u[2*g+1]=u[2*g-1]+(this.xyz[3*_+1]-u[2*g-1])*U,p[g]=1,g++;break}if(u[2*g]=this.xyz[3*_],u[2*g+1]=this.xyz[3*_+1],p[g]=w/f,g++,_===0){if(m)break;m=!0,_=e-2}else _--}if(g>=2&&p[1]>La){for(let C=g-1;C>=1;C--)u[2*(C+2)]=u[2*C],u[2*(C+2)+1]=u[2*C+1],p[C+2]=p[C];let w=p[3];for(let C=1;C<=2;C++){let U=La*C/2,S=U/w;u[2*C]=u[0]+(u[6]-u[0])*S,u[2*C+1]=u[1]+(u[7]-u[1])*S,p[C]=U}g+=2}this.trailCount=g;let d=this.orbit.geometry.getAttribute("position"),T=d.array;for(let w=0;w<g;w++)T[3*w]=u[2*w],T[3*w+1]=u[2*w+1],T[3*w+2]=0;d.needsUpdate=!0,this.orbit.geometry.setDrawRange(0,g),this.ghost.visible=this.showGhost;let M=(w,C,U)=>{let S=w.geometry.getAttribute("position");S.setXYZ(0,C,U,0),S.needsUpdate=!0};M(this.craft,c,l);let v=this.sys.f0+s,R=new Float32Array(2);Hn("primary",this.sys,this.frame,v,R),M(this.primary,R[0],R[1]),Hn("secondary",this.sys,this.frame,v,R),M(this.secondary,R[0],R[1]),this.render()}fit(){if(!this.fRel.length)return;let e=new nn;for(let c of[this.ghost,this.primaryTrail,this.secondaryTrail])c.geometry.computeBoundingBox(),c.geometry.boundingBox&&e.union(c.geometry.boundingBox);let n=new N,s=new N;e.getSize(n),e.getCenter(s);let r=Math.max(n.x,1e-6)*1.15,a=Math.max(n.y,1e-6)*1.15,o=this.aspect();this.camera.zoom=Math.min(2*o/r,2/a),this.camera.position.set(s.x,s.y,10),this.camera.up.set(0,1,0),this.controls.target.set(s.x,s.y,0),this.camera.updateProjectionMatrix(),this.controls.update(),this.userMoved=!1,this.render()}aspect(){let t=this.host.getBoundingClientRect();return Math.max(t.width,1)/Math.max(t.height,1)}resize(){let t=this.host.getBoundingClientRect(),e=Math.max(1,Math.floor(t.width)),n=Math.max(1,Math.floor(t.height));this.renderer.setSize(e,n,!1);let s=Math.min(window.devicePixelRatio||1,2);this.overlay.width=Math.floor(e*s),this.overlay.height=Math.floor(n*s);let r=e/n;this.camera.left=-r,this.camera.right=r,this.camera.top=1,this.camera.bottom=-1,this.camera.updateProjectionMatrix(),this.userMoved?this.render():this.fit()}visibleRect(){let t=(this.camera.right-this.camera.left)/(2*this.camera.zoom),e=(this.camera.top-this.camera.bottom)/(2*this.camera.zoom),n=this.camera.position.x,s=this.camera.position.y;return{x0:n-t,x1:n+t,y0:s-e,y1:s+e}}pixelSize(){let t=Math.max(1,this.host.getBoundingClientRect().width);return(this.camera.right-this.camera.left)/(this.camera.zoom*t)}layoutRibbon(){let t=this.trailCount,e=this.pixelSize(),[n,s,r]=this.memberRgb;for(let[a,o,c]of[[this.trailCore,gg,1],[this.trailGlow,_g,.32]]){let l=a.geometry.getAttribute("position"),h=a.geometry.getAttribute("color");if(!l||!h||t<2){a.visible=!1;continue}a.visible=!0;let f=l.array,u=h.array,p=this.trailPts;for(let g=0;g<t;g++){let _=Math.max(0,g-1),m=Math.min(t-1,g+1),d=p[2*m]-p[2*_],T=p[2*m+1]-p[2*_+1],M=Math.hypot(d,T)||1;d/=M,T/=M;let v=this.trailT[g],R=v<La?1-Math.pow(1-v/La,2):1,w=Math.pow(1-v,.8)*R,C=.5*o*e*w,U=-T*C,S=d*C,b=p[2*g],P=p[2*g+1];f[6*g]=b+U,f[6*g+1]=P+S,f[6*g+2]=0,f[6*g+3]=b-U,f[6*g+4]=P-S,f[6*g+5]=0;let B=c*Math.pow(1-v,1.6);u[8*g]=u[8*g+4]=n,u[8*g+1]=u[8*g+5]=s,u[8*g+2]=u[8*g+6]=r,u[8*g+3]=u[8*g+7]=B}l.needsUpdate=h.needsUpdate=!0,a.geometry.setDrawRange(0,(t-1)*6)}}render(){this.layoutRibbon(),this.renderer.render(this.scene,this.camera),this.threeD||this.drawOverlay()}drawOverlay(){let t=this.overlay.getContext("2d");if(!t)return;let e=Math.min(window.devicePixelRatio||1,2),n=this.overlay.width/e,s=this.overlay.height/e;t.setTransform(e,0,0,e,0,0),t.clearRect(0,0,n,s);let{x0:r,x1:a,y0:o,y1:c}=this.visibleRect(),l=M=>(M-r)/(a-r)*n,h=M=>s-(M-o)/(c-o)*s,f='12px "Helvetica Neue", Arial, sans-serif';t.font=f,t.lineWidth=1;let u=hh(a-r,Math.max(3,n/110)),p=hh(c-o,Math.max(3,s/70)),g=M=>Math.max(0,-Math.floor(Math.log10(M))),_=g(u),m=g(p);t.strokeStyle=this.palette.grid,t.fillStyle=this.palette.text,t.textAlign="center",t.textBaseline="top";for(let M=Math.ceil(r/u)*u;M<=a;M+=u){let v=Math.round(l(M))+.5;t.beginPath(),t.moveTo(v,0),t.lineTo(v,s),t.stroke(),v>56&&t.fillText((Math.abs(M)<1e-12?0:M).toFixed(_),v,s-30)}t.textAlign="right",t.textBaseline="middle";for(let M=Math.ceil(o/p)*p;M<=c;M+=p){let v=Math.round(h(M))+.5;t.beginPath(),t.moveTo(0,v),t.lineTo(n,v),t.stroke(),v<s-40&&v>22&&t.fillText((Math.abs(M)<1e-12?0:M).toFixed(m),44,v)}if(t.strokeStyle=this.palette.axis,r<0&&a>0){let M=Math.round(l(0))+.5;t.beginPath(),t.moveTo(M,0),t.lineTo(M,s),t.stroke()}if(o<0&&c>0){let M=Math.round(h(0))+.5;t.beginPath(),t.moveTo(0,M),t.lineTo(n,M),t.stroke()}let d=this.spec(),T=(M,v,R)=>{t.strokeStyle=this.palette.background,t.lineWidth=4,t.lineJoin="round",t.strokeText(M,v,R),t.fillStyle=this.palette.text,t.fillText(M,v,R),t.lineWidth=1};if(t.font='13px "Helvetica Neue", Arial, sans-serif',t.textAlign="center",t.textBaseline="top",this.showTitle&&T(d.label,n/2,8),t.textBaseline="bottom",T(d.axes[0],n/2,s-6),t.save(),t.translate(14,s/2),t.rotate(-Math.PI/2),t.textBaseline="middle",T(d.axes[1],0,0),t.restore(),this.paramRange&&this.tracks){let[M,v]=this.paramRange,R=8,w=Math.min(s*.5,220),C=n-46,U=(s-w)/2,S=t.createLinearGradient(0,U+w,0,U);for(let P=0;P<=10;P++)S.addColorStop(P/10,Ji(d.cmap,P/10));t.fillStyle=S,t.fillRect(C,U,R,w),t.strokeStyle=this.palette.axis,t.strokeRect(C+.5,U+.5,R,w),t.fillStyle=this.palette.text,t.font=f,t.textAlign="left",t.textBaseline="middle";let b=4;for(let P=0;P<=b;P++){let B=M+(v-M)*P/b,V=U+w-w*P/b;t.fillText(B.toFixed(2),C+R+5,V)}if(t.textAlign="center",t.textBaseline="bottom",t.fillText("e",C+R/2,U-4),v>M){let P=U+w-w*(this.sys.e-M)/(v-M);if(this.familyMode!=="hidden"){let B=w*ch*1.5;t.fillStyle="rgba(255,255,255,0.18)",t.fillRect(C-3,P-B,R+6,2*B)}t.fillStyle=this.palette.text,t.beginPath(),t.moveTo(C-2,P),t.lineTo(C-8,P-4),t.lineTo(C-8,P+4),t.closePath(),t.fill()}}}};function Wi(i){return i?i.kind==="panel"?[i.id]:[...Wi(i.a),...Wi(i.b)]:[]}function uh(i,t){return Wi(i).includes(t)}function Xi(i,t,e,n){if(i.kind==="panel"){if(i.id!==t)return i;if(n==="centre")return{kind:"panel",id:e};let s={kind:"panel",id:e},r=n==="left"||n==="right"?"row":"col",a=n==="left"||n==="top";return{kind:"split",dir:r,ratio:.5,a:a?s:i,b:a?i:s}}return{...i,a:Xi(i.a,t,e,n),b:Xi(i.b,t,e,n)}}function ri(i,t){if(i.kind==="panel")return i.id===t?null:i;let e=ri(i.a,t),n=ri(i.b,t);return e?n?{...i,a:e,b:n}:e:n}function Ua(i,t,e){return i===t&&i.kind==="split"?{...i,ratio:e}:i.kind==="panel"?i:{...i,a:Ua(i.a,t,e),b:Ua(i.b,t,e)}}function Na(i,t=1){return i.kind==="panel"?[{id:i.id,area:t}]:[...Na(i.a,t*i.ratio),...Na(i.b,t*(1-i.ratio))]}function dh(i,t,e,n){let s=i/Math.max(1,e),r=t/Math.max(1,n),a=.28,o=[{zone:"left",v:s},{zone:"right",v:1-s},{zone:"top",v:r},{zone:"bottom",v:1-r}].sort((c,l)=>c.v-l.v)[0];return o.v<a?o.zone:"centre"}function Fa(i){if(!i||typeof i!="object")return!1;let t=i;return t.kind==="panel"?typeof t.id=="string":t.kind==="split"?(t.dir==="row"||t.dir==="col")&&typeof t.ratio=="number"&&Fa(t.a)&&Fa(t.b):!1}var Oa=400,Mg=4,fh=8,Ls=["periapsis","apoapsis"],bg=`
3833
- :host { display: block; position: relative; background: #000; color: #d8d8d8;
3834
- font: 13px/1.4 "Helvetica Neue", Arial, sans-serif; overflow: hidden; }
3840
+ }`,uu=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let i=new aa(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,i=new sn({vertexShader:Ob,fragmentShader:Ub,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Xt(new ar(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},du=class extends Wn{constructor(e,t){super();let i=this,r=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,f=null,g=null,y=typeof XRWebGLBinding<"u",m=new uu,p={},M=t.getContextAttributes(),S=null,x=null,A=[],T=[],R=new ke,k=null,w=new Wt;w.viewport=new mt;let b=new Wt;b.viewport=new mt;let D=[w,b],V=new el,W=null,Y=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let J=A[$];return J===void 0&&(J=new Qr,A[$]=J),J.getTargetRaySpace()},this.getControllerGrip=function($){let J=A[$];return J===void 0&&(J=new Qr,A[$]=J),J.getGripSpace()},this.getHand=function($){let J=A[$];return J===void 0&&(J=new Qr,A[$]=J),J.getHandSpace()};function j($){let J=T.indexOf($.inputSource);if(J===-1)return;let me=A[J];me!==void 0&&(me.update($.inputSource,$.frame,c||a),me.dispatchEvent({type:$.type,data:$.inputSource}))}function X(){r.removeEventListener("select",j),r.removeEventListener("selectstart",j),r.removeEventListener("selectend",j),r.removeEventListener("squeeze",j),r.removeEventListener("squeezestart",j),r.removeEventListener("squeezeend",j),r.removeEventListener("end",X),r.removeEventListener("inputsourceschange",re);for(let $=0;$<A.length;$++){let J=T[$];J!==null&&(T[$]=null,A[$].disconnect(J))}W=null,Y=null,m.reset();for(let $ in p)delete p[$];e.setRenderTarget(S),f=null,d=null,u=null,r=null,x=null,qe.stop(),i.isPresenting=!1,e.setPixelRatio(k),e.setSize(R.width,R.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function($){s=$,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function($){o=$,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function($){c=$},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&y&&(u=new XRWebGLBinding(r,t)),u},this.getFrame=function(){return g},this.getSession=function(){return r},this.setSession=async function($){if(r=$,r!==null){if(S=e.getRenderTarget(),r.addEventListener("select",j),r.addEventListener("selectstart",j),r.addEventListener("selectend",j),r.addEventListener("squeeze",j),r.addEventListener("squeezestart",j),r.addEventListener("squeezeend",j),r.addEventListener("end",X),r.addEventListener("inputsourceschange",re),M.xrCompatible!==!0&&await t.makeXRCompatible(),k=e.getPixelRatio(),e.getSize(R),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let me=null,ve=null,ue=null;M.depth&&(ue=M.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,me=M.stencil?os:Yr,ve=M.stencil?as:Li);let Je={colorFormat:t.RGBA8,depthFormat:ue,scaleFactor:s};u=this.getBinding(),d=u.createProjectionLayer(Je),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),x=new Sn(d.textureWidth,d.textureHeight,{format:an,type:Yn,depthTexture:new sa(d.textureWidth,d.textureHeight,ve,void 0,void 0,void 0,void 0,void 0,void 0,me),stencilBuffer:M.stencil,colorSpace:e.outputColorSpace,samples:M.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{let me={antialias:M.antialias,alpha:!0,depth:M.depth,stencil:M.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(r,t,me),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),x=new Sn(f.framebufferWidth,f.framebufferHeight,{format:an,type:Yn,colorSpace:e.outputColorSpace,stencilBuffer:M.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}x.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await r.requestReferenceSpace(o),qe.setContext(r),qe.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function re($){for(let J=0;J<$.removed.length;J++){let me=$.removed[J],ve=T.indexOf(me);ve>=0&&(T[ve]=null,A[ve].disconnect(me))}for(let J=0;J<$.added.length;J++){let me=$.added[J],ve=T.indexOf(me);if(ve===-1){for(let Je=0;Je<A.length;Je++)if(Je>=T.length){T.push(me),ve=Je;break}else if(T[Je]===null){T[Je]=me,ve=Je;break}if(ve===-1)break}let ue=A[ve];ue&&ue.connect(me)}}let H=new N,oe=new N;function ee($,J,me){H.setFromMatrixPosition(J.matrixWorld),oe.setFromMatrixPosition(me.matrixWorld);let ve=H.distanceTo(oe),ue=J.projectionMatrix.elements,Je=me.projectionMatrix.elements,At=ue[14]/(ue[10]-1),C=ue[14]/(ue[10]+1),ht=(ue[9]+1)/ue[5],Be=(ue[9]-1)/ue[5],Ne=(ue[8]-1)/ue[0],be=(Je[8]+1)/Je[0],gt=At*Ne,Se=At*be,He=ve/(-Ne+be),Lt=He*-Ne;if(J.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(Lt),$.translateZ(He),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert(),ue[10]===-1)$.projectionMatrix.copy(J.projectionMatrix),$.projectionMatrixInverse.copy(J.projectionMatrixInverse);else{let bt=At+He,E=C+He,v=gt-Lt,F=Se+(ve-Lt),q=ht*C/E*bt,K=Be*C/E*bt;$.projectionMatrix.makePerspective(v,F,q,K,bt,E),$.projectionMatrixInverse.copy($.projectionMatrix).invert()}}function Me($,J){J===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(J.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(r===null)return;let J=$.near,me=$.far;m.texture!==null&&(m.depthNear>0&&(J=m.depthNear),m.depthFar>0&&(me=m.depthFar)),V.near=b.near=w.near=J,V.far=b.far=w.far=me,(W!==V.near||Y!==V.far)&&(r.updateRenderState({depthNear:V.near,depthFar:V.far}),W=V.near,Y=V.far),V.layers.mask=$.layers.mask|6,w.layers.mask=V.layers.mask&3,b.layers.mask=V.layers.mask&5;let ve=$.parent,ue=V.cameras;Me(V,ve);for(let Je=0;Je<ue.length;Je++)Me(ue[Je],ve);ue.length===2?ee(V,w,b):V.projectionMatrix.copy(w.projectionMatrix),$e($,V,ve)};function $e($,J,me){me===null?$.matrix.copy(J.matrixWorld):($.matrix.copy(me.matrixWorld),$.matrix.invert(),$.matrix.multiply(J.matrixWorld)),$.matrix.decompose($.position,$.quaternion,$.scale),$.updateMatrixWorld(!0),$.projectionMatrix.copy(J.projectionMatrix),$.projectionMatrixInverse.copy(J.projectionMatrixInverse),$.isPerspectiveCamera&&($.fov=jr*2*Math.atan(1/$.projectionMatrix.elements[5]),$.zoom=1)}this.getCamera=function(){return V},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function($){l=$,d!==null&&(d.fixedFoveation=$),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=$)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(V)},this.getCameraTexture=function($){return p[$]};let rt=null;function Ue($,J){if(h=J.getViewerPose(c||a),g=J,h!==null){let me=h.views;f!==null&&(e.setRenderTargetFramebuffer(x,f.framebuffer),e.setRenderTarget(x));let ve=!1;me.length!==V.cameras.length&&(V.cameras.length=0,ve=!0);for(let C=0;C<me.length;C++){let ht=me[C],Be=null;if(f!==null)Be=f.getViewport(ht);else{let be=u.getViewSubImage(d,ht);Be=be.viewport,C===0&&(e.setRenderTargetTextures(x,be.colorTexture,be.depthStencilTexture),e.setRenderTarget(x))}let Ne=D[C];Ne===void 0&&(Ne=new Wt,Ne.layers.enable(C),Ne.viewport=new mt,D[C]=Ne),Ne.matrix.fromArray(ht.transform.matrix),Ne.matrix.decompose(Ne.position,Ne.quaternion,Ne.scale),Ne.projectionMatrix.fromArray(ht.projectionMatrix),Ne.projectionMatrixInverse.copy(Ne.projectionMatrix).invert(),Ne.viewport.set(Be.x,Be.y,Be.width,Be.height),C===0&&(V.matrix.copy(Ne.matrix),V.matrix.decompose(V.position,V.quaternion,V.scale)),ve===!0&&V.cameras.push(Ne)}let ue=r.enabledFeatures;if(ue&&ue.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&y){u=i.getBinding();let C=u.getDepthInformation(me[0]);C&&C.isValid&&C.texture&&m.init(C,r.renderState)}if(ue&&ue.includes("camera-access")&&y){e.state.unbindTexture(),u=i.getBinding();for(let C=0;C<me.length;C++){let ht=me[C].camera;if(ht){let Be=p[ht];Be||(Be=new aa,p[ht]=Be);let Ne=u.getCameraImage(ht);Be.sourceTexture=Ne}}}}for(let me=0;me<A.length;me++){let ve=T[me],ue=A[me];ve!==null&&ue!==void 0&&ue.update(ve,J,c||a)}rt&&rt($,J),J.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:J}),g=null}let qe=new Lp;qe.setAnimationLoop(Ue),this.setAnimationLoop=function($){rt=$},this.dispose=function(){}}},pr=new Xn,Fb=new St;function Bb(n,e){function t(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function i(m,p){p.color.getRGB(m.fogColor.value,jh(n)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function r(m,p,M,S,x){p.isMeshBasicMaterial||p.isMeshLambertMaterial?s(m,p):p.isMeshToonMaterial?(s(m,p),u(m,p)):p.isMeshPhongMaterial?(s(m,p),h(m,p)):p.isMeshStandardMaterial?(s(m,p),d(m,p),p.isMeshPhysicalMaterial&&f(m,p,x)):p.isMeshMatcapMaterial?(s(m,p),g(m,p)):p.isMeshDepthMaterial?s(m,p):p.isMeshDistanceMaterial?(s(m,p),y(m,p)):p.isMeshNormalMaterial?s(m,p):p.isLineBasicMaterial?(a(m,p),p.isLineDashedMaterial&&o(m,p)):p.isPointsMaterial?l(m,p,M,S):p.isSpriteMaterial?c(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function s(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 M=e.get(p),S=M.envMap,x=M.envMapRotation;S&&(m.envMap.value=S,pr.copy(x),pr.x*=-1,pr.y*=-1,pr.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(pr.y*=-1,pr.z*=-1),m.envMapRotation.value.setFromMatrix4(Fb.makeRotationFromEuler(pr)),m.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,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,M,S){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*M,m.scale.value=S*.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 u(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function d(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,M){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=M.texture,m.transmissionSamplerSize.value.set(M.width,M.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 M=e.get(p).light;m.referencePosition.value.setFromMatrixPosition(M.matrixWorld),m.nearDistance.value=M.shadow.camera.near,m.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function zb(n,e,t,i){let r={},s={},a=[],o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(M,S){let x=S.program;i.uniformBlockBinding(M,x)}function c(M,S){let x=r[M.id];x===void 0&&(g(M),x=h(M),r[M.id]=x,M.addEventListener("dispose",m));let A=S.program;i.updateUBOMapping(M,A);let T=e.render.frame;s[M.id]!==T&&(d(M),s[M.id]=T)}function h(M){let S=u();M.__bindingPointIndex=S;let x=n.createBuffer(),A=M.__size,T=M.usage;return n.bindBuffer(n.UNIFORM_BUFFER,x),n.bufferData(n.UNIFORM_BUFFER,A,T),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,S,x),x}function u(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.push(M),M;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(M){let S=r[M.id],x=M.uniforms,A=M.__cache;n.bindBuffer(n.UNIFORM_BUFFER,S);for(let T=0,R=x.length;T<R;T++){let k=Array.isArray(x[T])?x[T]:[x[T]];for(let w=0,b=k.length;w<b;w++){let D=k[w];if(f(D,T,w,A)===!0){let V=D.__offset,W=Array.isArray(D.value)?D.value:[D.value],Y=0;for(let j=0;j<W.length;j++){let X=W[j],re=y(X);typeof X=="number"||typeof X=="boolean"?(D.__data[0]=X,n.bufferSubData(n.UNIFORM_BUFFER,V+Y,D.__data)):X.isMatrix3?(D.__data[0]=X.elements[0],D.__data[1]=X.elements[1],D.__data[2]=X.elements[2],D.__data[3]=0,D.__data[4]=X.elements[3],D.__data[5]=X.elements[4],D.__data[6]=X.elements[5],D.__data[7]=0,D.__data[8]=X.elements[6],D.__data[9]=X.elements[7],D.__data[10]=X.elements[8],D.__data[11]=0):(X.toArray(D.__data,Y),Y+=re.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,V,D.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function f(M,S,x,A){let T=M.value,R=S+"_"+x;if(A[R]===void 0)return typeof T=="number"||typeof T=="boolean"?A[R]=T:A[R]=T.clone(),!0;{let k=A[R];if(typeof T=="number"||typeof T=="boolean"){if(k!==T)return A[R]=T,!0}else if(k.equals(T)===!1)return k.copy(T),!0}return!1}function g(M){let S=M.uniforms,x=0,A=16;for(let R=0,k=S.length;R<k;R++){let w=Array.isArray(S[R])?S[R]:[S[R]];for(let b=0,D=w.length;b<D;b++){let V=w[b],W=Array.isArray(V.value)?V.value:[V.value];for(let Y=0,j=W.length;Y<j;Y++){let X=W[Y],re=y(X),H=x%A,oe=H%re.boundary,ee=H+oe;x+=oe,ee!==0&&A-ee<re.storage&&(x+=A-ee),V.__data=new Float32Array(re.storage/Float32Array.BYTES_PER_ELEMENT),V.__offset=x,x+=re.storage}}}let T=x%A;return T>0&&(x+=A-T),M.__size=x,M.__cache={},this}function y(M){let S={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(S.boundary=4,S.storage=4):M.isVector2?(S.boundary=8,S.storage=8):M.isVector3||M.isColor?(S.boundary=16,S.storage=12):M.isVector4?(S.boundary=16,S.storage=16):M.isMatrix3?(S.boundary=48,S.storage=48):M.isMatrix4?(S.boundary=64,S.storage=64):M.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",M),S}function m(M){let S=M.target;S.removeEventListener("dispose",m);let x=a.indexOf(S.__bindingPointIndex);a.splice(x,1),n.deleteBuffer(r[S.id]),delete r[S.id],delete s[S.id]}function p(){for(let M in r)n.deleteBuffer(r[M]);a=[],r={},s={}}return{bind:l,update:c,dispose:p}}var jl=class{constructor(e={}){let{canvas:t=rp(),context:i=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let f;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=i.getContextAttributes().alpha}else f=a;let g=new Uint32Array(4),y=new Int32Array(4),m=null,p=null,M=[],S=[];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=ui,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let x=this,A=!1;this._outputColorSpace=pn;let T=0,R=0,k=null,w=-1,b=null,D=new mt,V=new mt,W=null,Y=new Ze(0),j=0,X=t.width,re=t.height,H=1,oe=null,ee=null,Me=new mt(0,0,X,re),$e=new mt(0,0,X,re),rt=!1,Ue=new ia,qe=!1,$=!1,J=new St,me=new N,ve=new mt,ue={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Je=!1;function At(){return k===null?H:1}let C=i;function ht(_,O){return t.getContext(_,O)}try{let _={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"180"}`),t.addEventListener("webglcontextlost",le,!1),t.addEventListener("webglcontextrestored",ye,!1),t.addEventListener("webglcontextcreationerror",Q,!1),C===null){let O="webgl2";if(C=ht(O,_),C===null)throw ht(O)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(_){throw console.error("THREE.WebGLRenderer: "+_.message),_}let Be,Ne,be,gt,Se,He,Lt,bt,E,v,F,q,K,G,Ae,ae,we,Ee,ne,fe,Le,Te,he,Ve;function L(){Be=new r_(C),Be.init(),Te=new Nb(C,Be),Ne=new Jx(C,Be,e,Te),be=new Db(C,Be),Ne.reversedDepthBuffer&&d&&be.buffers.depth.setReversed(!0),gt=new o_(C),Se=new _b,He=new kb(C,Be,be,Se,Ne,Te,gt),Lt=new Qx(x),bt=new i_(x),E=new f0(C),he=new jx(C,E),v=new s_(C,E,gt,he),F=new c_(C,v,E,gt),ne=new l_(C,Ne,He),ae=new Kx(Se),q=new xb(x,Lt,bt,Be,Ne,he,ae),K=new Bb(x,Se),G=new Sb,Ae=new Cb(Be),Ee=new Yx(x,Lt,bt,be,F,f,l),we=new Ib(x,F,Ne),Ve=new zb(C,gt,Ne,be),fe=new Zx(C,Be,gt),Le=new a_(C,Be,gt),gt.programs=q.programs,x.capabilities=Ne,x.extensions=Be,x.properties=Se,x.renderLists=G,x.shadowMap=we,x.state=be,x.info=gt}L();let ie=new du(x,C);this.xr=ie,this.getContext=function(){return C},this.getContextAttributes=function(){return C.getContextAttributes()},this.forceContextLoss=function(){let _=Be.get("WEBGL_lose_context");_&&_.loseContext()},this.forceContextRestore=function(){let _=Be.get("WEBGL_lose_context");_&&_.restoreContext()},this.getPixelRatio=function(){return H},this.setPixelRatio=function(_){_!==void 0&&(H=_,this.setSize(X,re,!1))},this.getSize=function(_){return _.set(X,re)},this.setSize=function(_,O,B=!0){if(ie.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}X=_,re=O,t.width=Math.floor(_*H),t.height=Math.floor(O*H),B===!0&&(t.style.width=_+"px",t.style.height=O+"px"),this.setViewport(0,0,_,O)},this.getDrawingBufferSize=function(_){return _.set(X*H,re*H).floor()},this.setDrawingBufferSize=function(_,O,B){X=_,re=O,H=B,t.width=Math.floor(_*B),t.height=Math.floor(O*B),this.setViewport(0,0,_,O)},this.getCurrentViewport=function(_){return _.copy(D)},this.getViewport=function(_){return _.copy(Me)},this.setViewport=function(_,O,B,z){_.isVector4?Me.set(_.x,_.y,_.z,_.w):Me.set(_,O,B,z),be.viewport(D.copy(Me).multiplyScalar(H).round())},this.getScissor=function(_){return _.copy($e)},this.setScissor=function(_,O,B,z){_.isVector4?$e.set(_.x,_.y,_.z,_.w):$e.set(_,O,B,z),be.scissor(V.copy($e).multiplyScalar(H).round())},this.getScissorTest=function(){return rt},this.setScissorTest=function(_){be.setScissorTest(rt=_)},this.setOpaqueSort=function(_){oe=_},this.setTransparentSort=function(_){ee=_},this.getClearColor=function(_){return _.copy(Ee.getClearColor())},this.setClearColor=function(){Ee.setClearColor(...arguments)},this.getClearAlpha=function(){return Ee.getClearAlpha()},this.setClearAlpha=function(){Ee.setClearAlpha(...arguments)},this.clear=function(_=!0,O=!0,B=!0){let z=0;if(_){let U=!1;if(k!==null){let te=k.texture.format;U=te===gl||te===ml||te===pl}if(U){let te=k.texture.type,de=te===Yn||te===Li||te===rs||te===as||te===dl||te===fl,xe=Ee.getClearColor(),ge=Ee.getClearAlpha(),Ie=xe.r,Oe=xe.g,Re=xe.b;de?(g[0]=Ie,g[1]=Oe,g[2]=Re,g[3]=ge,C.clearBufferuiv(C.COLOR,0,g)):(y[0]=Ie,y[1]=Oe,y[2]=Re,y[3]=ge,C.clearBufferiv(C.COLOR,0,y))}else z|=C.COLOR_BUFFER_BIT}O&&(z|=C.DEPTH_BUFFER_BIT),B&&(z|=C.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),C.clear(z)},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.dispose=function(){t.removeEventListener("webglcontextlost",le,!1),t.removeEventListener("webglcontextrestored",ye,!1),t.removeEventListener("webglcontextcreationerror",Q,!1),Ee.dispose(),G.dispose(),Ae.dispose(),Se.dispose(),Lt.dispose(),bt.dispose(),F.dispose(),he.dispose(),Ve.dispose(),q.dispose(),ie.dispose(),ie.removeEventListener("sessionstart",Bn),ie.removeEventListener("sessionend",Pu),Oi.stop()};function le(_){_.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function ye(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;let _=gt.autoReset,O=we.enabled,B=we.autoUpdate,z=we.needsUpdate,U=we.type;L(),gt.autoReset=_,we.enabled=O,we.autoUpdate=B,we.needsUpdate=z,we.type=U}function Q(_){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",_.statusMessage)}function Z(_){let O=_.target;O.removeEventListener("dispose",Z),_e(O)}function _e(_){Fe(_),Se.remove(_)}function Fe(_){let O=Se.get(_).programs;O!==void 0&&(O.forEach(function(B){q.releaseProgram(B)}),_.isShaderMaterial&&q.releaseShaderCache(_))}this.renderBufferDirect=function(_,O,B,z,U,te){O===null&&(O=ue);let de=U.isMesh&&U.matrixWorld.determinant()<0,xe=Sm(_,O,B,z,U);be.setMaterial(z,de);let ge=B.index,Ie=1;if(z.wireframe===!0){if(ge=v.getWireframeAttribute(B),ge===void 0)return;Ie=2}let Oe=B.drawRange,Re=B.attributes.position,Ye=Oe.start*Ie,ot=(Oe.start+Oe.count)*Ie;te!==null&&(Ye=Math.max(Ye,te.start*Ie),ot=Math.min(ot,(te.start+te.count)*Ie)),ge!==null?(Ye=Math.max(Ye,0),ot=Math.min(ot,ge.count)):Re!=null&&(Ye=Math.max(Ye,0),ot=Math.min(ot,Re.count));let _t=ot-Ye;if(_t<0||_t===1/0)return;he.setup(U,z,xe,B,ge);let dt,ct=fe;if(ge!==null&&(dt=E.get(ge),ct=Le,ct.setIndex(dt)),U.isMesh)z.wireframe===!0?(be.setLineWidth(z.wireframeLinewidth*At()),ct.setMode(C.LINES)):ct.setMode(C.TRIANGLES);else if(U.isLine){let Pe=z.linewidth;Pe===void 0&&(Pe=1),be.setLineWidth(Pe*At()),U.isLineSegments?ct.setMode(C.LINES):U.isLineLoop?ct.setMode(C.LINE_LOOP):ct.setMode(C.LINE_STRIP)}else U.isPoints?ct.setMode(C.POINTS):U.isSprite&&ct.setMode(C.TRIANGLES);if(U.isBatchedMesh)if(U._multiDrawInstances!==null)Zr("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),ct.renderMultiDrawInstances(U._multiDrawStarts,U._multiDrawCounts,U._multiDrawCount,U._multiDrawInstances);else if(Be.get("WEBGL_multi_draw"))ct.renderMultiDraw(U._multiDrawStarts,U._multiDrawCounts,U._multiDrawCount);else{let Pe=U._multiDrawStarts,vt=U._multiDrawCounts,et=U._multiDrawCount,ln=ge?E.get(ge).bytesPerElement:1,yr=Se.get(z).currentProgram.getUniforms();for(let cn=0;cn<et;cn++)yr.setValue(C,"_gl_DrawID",cn),ct.render(Pe[cn]/ln,vt[cn])}else if(U.isInstancedMesh)ct.renderInstances(Ye,_t,U.count);else if(B.isInstancedBufferGeometry){let Pe=B._maxInstanceCount!==void 0?B._maxInstanceCount:1/0,vt=Math.min(B.instanceCount,Pe);ct.renderInstances(Ye,_t,vt)}else ct.render(Ye,_t)};function ut(_,O,B){_.transparent===!0&&_.side===Mn&&_.forceSinglePass===!1?(_.side=Qt,_.needsUpdate=!0,Ea(_,O,B),_.side=li,_.needsUpdate=!0,Ea(_,O,B),_.side=Mn):Ea(_,O,B)}this.compile=function(_,O,B=null){B===null&&(B=_),p=Ae.get(B),p.init(O),S.push(p),B.traverseVisible(function(U){U.isLight&&U.layers.test(O.layers)&&(p.pushLight(U),U.castShadow&&p.pushShadow(U))}),_!==B&&_.traverseVisible(function(U){U.isLight&&U.layers.test(O.layers)&&(p.pushLight(U),U.castShadow&&p.pushShadow(U))}),p.setupLights();let z=new Set;return _.traverse(function(U){if(!(U.isMesh||U.isPoints||U.isLine||U.isSprite))return;let te=U.material;if(te)if(Array.isArray(te))for(let de=0;de<te.length;de++){let xe=te[de];ut(xe,B,U),z.add(xe)}else ut(te,B,U),z.add(te)}),p=S.pop(),z},this.compileAsync=function(_,O,B=null){let z=this.compile(_,O,B);return new Promise(U=>{function te(){if(z.forEach(function(de){Se.get(de).currentProgram.isReady()&&z.delete(de)}),z.size===0){U(_);return}setTimeout(te,10)}Be.get("KHR_parallel_shader_compile")!==null?te():setTimeout(te,10)})};let nt=null;function Kn(_){nt&&nt(_)}function Bn(){Oi.stop()}function Pu(){Oi.start()}let Oi=new Lp;Oi.setAnimationLoop(Kn),typeof self<"u"&&Oi.setContext(self),this.setAnimationLoop=function(_){nt=_,ie.setAnimationLoop(_),_===null?Oi.stop():Oi.start()},ie.addEventListener("sessionstart",Bn),ie.addEventListener("sessionend",Pu),this.render=function(_,O){if(O!==void 0&&O.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;if(_.matrixWorldAutoUpdate===!0&&_.updateMatrixWorld(),O.parent===null&&O.matrixWorldAutoUpdate===!0&&O.updateMatrixWorld(),ie.enabled===!0&&ie.isPresenting===!0&&(ie.cameraAutoUpdate===!0&&ie.updateCamera(O),O=ie.getCamera()),_.isScene===!0&&_.onBeforeRender(x,_,O,k),p=Ae.get(_,S.length),p.init(O),S.push(p),J.multiplyMatrices(O.projectionMatrix,O.matrixWorldInverse),Ue.setFromProjectionMatrix(J,Ln,O.reversedDepth),$=this.localClippingEnabled,qe=ae.init(this.clippingPlanes,$),m=G.get(_,M.length),m.init(),M.push(m),ie.enabled===!0&&ie.isPresenting===!0){let te=x.xr.getDepthSensingMesh();te!==null&&pc(te,O,-1/0,x.sortObjects)}pc(_,O,0,x.sortObjects),m.finish(),x.sortObjects===!0&&m.sort(oe,ee),Je=ie.enabled===!1||ie.isPresenting===!1||ie.hasDepthSensing()===!1,Je&&Ee.addToRenderList(m,_),this.info.render.frame++,qe===!0&&ae.beginShadows();let B=p.state.shadowsArray;we.render(B,_,O),qe===!0&&ae.endShadows(),this.info.autoReset===!0&&this.info.reset();let z=m.opaque,U=m.transmissive;if(p.setupLights(),O.isArrayCamera){let te=O.cameras;if(U.length>0)for(let de=0,xe=te.length;de<xe;de++){let ge=te[de];Lu(z,U,_,ge)}Je&&Ee.render(_);for(let de=0,xe=te.length;de<xe;de++){let ge=te[de];Iu(m,_,ge,ge.viewport)}}else U.length>0&&Lu(z,U,_,O),Je&&Ee.render(_),Iu(m,_,O);k!==null&&R===0&&(He.updateMultisampleRenderTarget(k),He.updateRenderTargetMipmap(k)),_.isScene===!0&&_.onAfterRender(x,_,O),he.resetDefaultState(),w=-1,b=null,S.pop(),S.length>0?(p=S[S.length-1],qe===!0&&ae.setGlobalState(x.clippingPlanes,p.state.camera)):p=null,M.pop(),M.length>0?m=M[M.length-1]:m=null};function pc(_,O,B,z){if(_.visible===!1)return;if(_.layers.test(O.layers)){if(_.isGroup)B=_.renderOrder;else if(_.isLOD)_.autoUpdate===!0&&_.update(O);else if(_.isLight)p.pushLight(_),_.castShadow&&p.pushShadow(_);else if(_.isSprite){if(!_.frustumCulled||Ue.intersectsSprite(_)){z&&ve.setFromMatrixPosition(_.matrixWorld).applyMatrix4(J);let de=F.update(_),xe=_.material;xe.visible&&m.push(_,de,xe,B,ve.z,null)}}else if((_.isMesh||_.isLine||_.isPoints)&&(!_.frustumCulled||Ue.intersectsObject(_))){let de=F.update(_),xe=_.material;if(z&&(_.boundingSphere!==void 0?(_.boundingSphere===null&&_.computeBoundingSphere(),ve.copy(_.boundingSphere.center)):(de.boundingSphere===null&&de.computeBoundingSphere(),ve.copy(de.boundingSphere.center)),ve.applyMatrix4(_.matrixWorld).applyMatrix4(J)),Array.isArray(xe)){let ge=de.groups;for(let Ie=0,Oe=ge.length;Ie<Oe;Ie++){let Re=ge[Ie],Ye=xe[Re.materialIndex];Ye&&Ye.visible&&m.push(_,de,Ye,B,ve.z,Re)}}else xe.visible&&m.push(_,de,xe,B,ve.z,null)}}let te=_.children;for(let de=0,xe=te.length;de<xe;de++)pc(te[de],O,B,z)}function Iu(_,O,B,z){let U=_.opaque,te=_.transmissive,de=_.transparent;p.setupLightsView(B),qe===!0&&ae.setGlobalState(x.clippingPlanes,B),z&&be.viewport(D.copy(z)),U.length>0&&Ma(U,O,B),te.length>0&&Ma(te,O,B),de.length>0&&Ma(de,O,B),be.buffers.depth.setTest(!0),be.buffers.depth.setMask(!0),be.buffers.color.setMask(!0),be.setPolygonOffset(!1)}function Lu(_,O,B,z){if((B.isScene===!0?B.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[z.id]===void 0&&(p.state.transmissionRenderTarget[z.id]=new Sn(1,1,{generateMipmaps:!0,type:Be.has("EXT_color_buffer_half_float")||Be.has("EXT_color_buffer_float")?ss:Yn,minFilter:Ii,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ke.workingColorSpace}));let te=p.state.transmissionRenderTarget[z.id],de=z.viewport||D;te.setSize(de.z*x.transmissionResolutionScale,de.w*x.transmissionResolutionScale);let xe=x.getRenderTarget(),ge=x.getActiveCubeFace(),Ie=x.getActiveMipmapLevel();x.setRenderTarget(te),x.getClearColor(Y),j=x.getClearAlpha(),j<1&&x.setClearColor(16777215,.5),x.clear(),Je&&Ee.render(B);let Oe=x.toneMapping;x.toneMapping=ui;let Re=z.viewport;if(z.viewport!==void 0&&(z.viewport=void 0),p.setupLightsView(z),qe===!0&&ae.setGlobalState(x.clippingPlanes,z),Ma(_,B,z),He.updateMultisampleRenderTarget(te),He.updateRenderTargetMipmap(te),Be.has("WEBGL_multisampled_render_to_texture")===!1){let Ye=!1;for(let ot=0,_t=O.length;ot<_t;ot++){let dt=O[ot],ct=dt.object,Pe=dt.geometry,vt=dt.material,et=dt.group;if(vt.side===Mn&&ct.layers.test(z.layers)){let ln=vt.side;vt.side=Qt,vt.needsUpdate=!0,Du(ct,B,z,Pe,vt,et),vt.side=ln,vt.needsUpdate=!0,Ye=!0}}Ye===!0&&(He.updateMultisampleRenderTarget(te),He.updateRenderTargetMipmap(te))}x.setRenderTarget(xe,ge,Ie),x.setClearColor(Y,j),Re!==void 0&&(z.viewport=Re),x.toneMapping=Oe}function Ma(_,O,B){let z=O.isScene===!0?O.overrideMaterial:null;for(let U=0,te=_.length;U<te;U++){let de=_[U],xe=de.object,ge=de.geometry,Ie=de.group,Oe=de.material;Oe.allowOverride===!0&&z!==null&&(Oe=z),xe.layers.test(B.layers)&&Du(xe,O,B,ge,Oe,Ie)}}function Du(_,O,B,z,U,te){_.onBeforeRender(x,O,B,z,U,te),_.modelViewMatrix.multiplyMatrices(B.matrixWorldInverse,_.matrixWorld),_.normalMatrix.getNormalMatrix(_.modelViewMatrix),U.onBeforeRender(x,O,B,z,_,te),U.transparent===!0&&U.side===Mn&&U.forceSinglePass===!1?(U.side=Qt,U.needsUpdate=!0,x.renderBufferDirect(B,O,z,U,_,te),U.side=li,U.needsUpdate=!0,x.renderBufferDirect(B,O,z,U,_,te),U.side=Mn):x.renderBufferDirect(B,O,z,U,_,te),_.onAfterRender(x,O,B,z,U,te)}function Ea(_,O,B){O.isScene!==!0&&(O=ue);let z=Se.get(_),U=p.state.lights,te=p.state.shadowsArray,de=U.state.version,xe=q.getParameters(_,U.state,te,O,B),ge=q.getProgramCacheKey(xe),Ie=z.programs;z.environment=_.isMeshStandardMaterial?O.environment:null,z.fog=O.fog,z.envMap=(_.isMeshStandardMaterial?bt:Lt).get(_.envMap||z.environment),z.envMapRotation=z.environment!==null&&_.envMap===null?O.environmentRotation:_.envMapRotation,Ie===void 0&&(_.addEventListener("dispose",Z),Ie=new Map,z.programs=Ie);let Oe=Ie.get(ge);if(Oe!==void 0){if(z.currentProgram===Oe&&z.lightsStateVersion===de)return Nu(_,xe),Oe}else xe.uniforms=q.getUniforms(_),_.onBeforeCompile(xe,x),Oe=q.acquireProgram(xe,ge),Ie.set(ge,Oe),z.uniforms=xe.uniforms;let Re=z.uniforms;return(!_.isShaderMaterial&&!_.isRawShaderMaterial||_.clipping===!0)&&(Re.clippingPlanes=ae.uniform),Nu(_,xe),z.needsLights=Mm(_),z.lightsStateVersion=de,z.needsLights&&(Re.ambientLightColor.value=U.state.ambient,Re.lightProbe.value=U.state.probe,Re.directionalLights.value=U.state.directional,Re.directionalLightShadows.value=U.state.directionalShadow,Re.spotLights.value=U.state.spot,Re.spotLightShadows.value=U.state.spotShadow,Re.rectAreaLights.value=U.state.rectArea,Re.ltc_1.value=U.state.rectAreaLTC1,Re.ltc_2.value=U.state.rectAreaLTC2,Re.pointLights.value=U.state.point,Re.pointLightShadows.value=U.state.pointShadow,Re.hemisphereLights.value=U.state.hemi,Re.directionalShadowMap.value=U.state.directionalShadowMap,Re.directionalShadowMatrix.value=U.state.directionalShadowMatrix,Re.spotShadowMap.value=U.state.spotShadowMap,Re.spotLightMatrix.value=U.state.spotLightMatrix,Re.spotLightMap.value=U.state.spotLightMap,Re.pointShadowMap.value=U.state.pointShadowMap,Re.pointShadowMatrix.value=U.state.pointShadowMatrix),z.currentProgram=Oe,z.uniformsList=null,Oe}function ku(_){if(_.uniformsList===null){let O=_.currentProgram.getUniforms();_.uniformsList=hs.seqWithValue(O.seq,_.uniforms)}return _.uniformsList}function Nu(_,O){let B=Se.get(_);B.outputColorSpace=O.outputColorSpace,B.batching=O.batching,B.batchingColor=O.batchingColor,B.instancing=O.instancing,B.instancingColor=O.instancingColor,B.instancingMorph=O.instancingMorph,B.skinning=O.skinning,B.morphTargets=O.morphTargets,B.morphNormals=O.morphNormals,B.morphColors=O.morphColors,B.morphTargetsCount=O.morphTargetsCount,B.numClippingPlanes=O.numClippingPlanes,B.numIntersection=O.numClipIntersection,B.vertexAlphas=O.vertexAlphas,B.vertexTangents=O.vertexTangents,B.toneMapping=O.toneMapping}function Sm(_,O,B,z,U){O.isScene!==!0&&(O=ue),He.resetTextureUnits();let te=O.fog,de=z.isMeshStandardMaterial?O.environment:null,xe=k===null?x.outputColorSpace:k.isXRRenderTarget===!0?k.texture.colorSpace:ci,ge=(z.isMeshStandardMaterial?bt:Lt).get(z.envMap||de),Ie=z.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,Oe=!!B.attributes.tangent&&(!!z.normalMap||z.anisotropy>0),Re=!!B.morphAttributes.position,Ye=!!B.morphAttributes.normal,ot=!!B.morphAttributes.color,_t=ui;z.toneMapped&&(k===null||k.isXRRenderTarget===!0)&&(_t=x.toneMapping);let dt=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,ct=dt!==void 0?dt.length:0,Pe=Se.get(z),vt=p.state.lights;if(qe===!0&&($===!0||_!==b)){let jt=_===b&&z.id===w;ae.setState(z,_,jt)}let et=!1;z.version===Pe.__version?(Pe.needsLights&&Pe.lightsStateVersion!==vt.state.version||Pe.outputColorSpace!==xe||U.isBatchedMesh&&Pe.batching===!1||!U.isBatchedMesh&&Pe.batching===!0||U.isBatchedMesh&&Pe.batchingColor===!0&&U.colorTexture===null||U.isBatchedMesh&&Pe.batchingColor===!1&&U.colorTexture!==null||U.isInstancedMesh&&Pe.instancing===!1||!U.isInstancedMesh&&Pe.instancing===!0||U.isSkinnedMesh&&Pe.skinning===!1||!U.isSkinnedMesh&&Pe.skinning===!0||U.isInstancedMesh&&Pe.instancingColor===!0&&U.instanceColor===null||U.isInstancedMesh&&Pe.instancingColor===!1&&U.instanceColor!==null||U.isInstancedMesh&&Pe.instancingMorph===!0&&U.morphTexture===null||U.isInstancedMesh&&Pe.instancingMorph===!1&&U.morphTexture!==null||Pe.envMap!==ge||z.fog===!0&&Pe.fog!==te||Pe.numClippingPlanes!==void 0&&(Pe.numClippingPlanes!==ae.numPlanes||Pe.numIntersection!==ae.numIntersection)||Pe.vertexAlphas!==Ie||Pe.vertexTangents!==Oe||Pe.morphTargets!==Re||Pe.morphNormals!==Ye||Pe.morphColors!==ot||Pe.toneMapping!==_t||Pe.morphTargetsCount!==ct)&&(et=!0):(et=!0,Pe.__version=z.version);let ln=Pe.currentProgram;et===!0&&(ln=Ea(z,O,U));let yr=!1,cn=!1,bs=!1,xt=ln.getUniforms(),gn=Pe.uniforms;if(be.useProgram(ln.program)&&(yr=!0,cn=!0,bs=!0),z.id!==w&&(w=z.id,cn=!0),yr||b!==_){be.buffers.depth.getReversed()&&_.reversedDepth!==!0&&(_._reversedDepth=!0,_.updateProjectionMatrix()),xt.setValue(C,"projectionMatrix",_.projectionMatrix),xt.setValue(C,"viewMatrix",_.matrixWorldInverse);let en=xt.map.cameraPosition;en!==void 0&&en.setValue(C,me.setFromMatrixPosition(_.matrixWorld)),Ne.logarithmicDepthBuffer&&xt.setValue(C,"logDepthBufFC",2/(Math.log(_.far+1)/Math.LN2)),(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)&&xt.setValue(C,"isOrthographic",_.isOrthographicCamera===!0),b!==_&&(b=_,cn=!0,bs=!0)}if(U.isSkinnedMesh){xt.setOptional(C,U,"bindMatrix"),xt.setOptional(C,U,"bindMatrixInverse");let jt=U.skeleton;jt&&(jt.boneTexture===null&&jt.computeBoneTexture(),xt.setValue(C,"boneTexture",jt.boneTexture,He))}U.isBatchedMesh&&(xt.setOptional(C,U,"batchingTexture"),xt.setValue(C,"batchingTexture",U._matricesTexture,He),xt.setOptional(C,U,"batchingIdTexture"),xt.setValue(C,"batchingIdTexture",U._indirectTexture,He),xt.setOptional(C,U,"batchingColorTexture"),U._colorsTexture!==null&&xt.setValue(C,"batchingColorTexture",U._colorsTexture,He));let yn=B.morphAttributes;if((yn.position!==void 0||yn.normal!==void 0||yn.color!==void 0)&&ne.update(U,B,ln),(cn||Pe.receiveShadow!==U.receiveShadow)&&(Pe.receiveShadow=U.receiveShadow,xt.setValue(C,"receiveShadow",U.receiveShadow)),z.isMeshGouraudMaterial&&z.envMap!==null&&(gn.envMap.value=ge,gn.flipEnvMap.value=ge.isCubeTexture&&ge.isRenderTargetTexture===!1?-1:1),z.isMeshStandardMaterial&&z.envMap===null&&O.environment!==null&&(gn.envMapIntensity.value=O.environmentIntensity),cn&&(xt.setValue(C,"toneMappingExposure",x.toneMappingExposure),Pe.needsLights&&wm(gn,bs),te&&z.fog===!0&&K.refreshFogUniforms(gn,te),K.refreshMaterialUniforms(gn,z,H,re,p.state.transmissionRenderTarget[_.id]),hs.upload(C,ku(Pe),gn,He)),z.isShaderMaterial&&z.uniformsNeedUpdate===!0&&(hs.upload(C,ku(Pe),gn,He),z.uniformsNeedUpdate=!1),z.isSpriteMaterial&&xt.setValue(C,"center",U.center),xt.setValue(C,"modelViewMatrix",U.modelViewMatrix),xt.setValue(C,"normalMatrix",U.normalMatrix),xt.setValue(C,"modelMatrix",U.matrixWorld),z.isShaderMaterial||z.isRawShaderMaterial){let jt=z.uniformsGroups;for(let en=0,mc=jt.length;en<mc;en++){let Ui=jt[en];Ve.update(Ui,ln),Ve.bind(Ui,ln)}}return ln}function wm(_,O){_.ambientLightColor.needsUpdate=O,_.lightProbe.needsUpdate=O,_.directionalLights.needsUpdate=O,_.directionalLightShadows.needsUpdate=O,_.pointLights.needsUpdate=O,_.pointLightShadows.needsUpdate=O,_.spotLights.needsUpdate=O,_.spotLightShadows.needsUpdate=O,_.rectAreaLights.needsUpdate=O,_.hemisphereLights.needsUpdate=O}function Mm(_){return _.isMeshLambertMaterial||_.isMeshToonMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isShadowMaterial||_.isShaderMaterial&&_.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return k},this.setRenderTargetTextures=function(_,O,B){let z=Se.get(_);z.__autoAllocateDepthBuffer=_.resolveDepthBuffer===!1,z.__autoAllocateDepthBuffer===!1&&(z.__useRenderToTexture=!1),Se.get(_.texture).__webglTexture=O,Se.get(_.depthTexture).__webglTexture=z.__autoAllocateDepthBuffer?void 0:B,z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(_,O){let B=Se.get(_);B.__webglFramebuffer=O,B.__useDefaultFramebuffer=O===void 0};let Em=C.createFramebuffer();this.setRenderTarget=function(_,O=0,B=0){k=_,T=O,R=B;let z=!0,U=null,te=!1,de=!1;if(_){let ge=Se.get(_);if(ge.__useDefaultFramebuffer!==void 0)be.bindFramebuffer(C.FRAMEBUFFER,null),z=!1;else if(ge.__webglFramebuffer===void 0)He.setupRenderTarget(_);else if(ge.__hasExternalTextures)He.rebindTextures(_,Se.get(_.texture).__webglTexture,Se.get(_.depthTexture).__webglTexture);else if(_.depthBuffer){let Re=_.depthTexture;if(ge.__boundDepthTexture!==Re){if(Re!==null&&Se.has(Re)&&(_.width!==Re.image.width||_.height!==Re.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");He.setupDepthRenderbuffer(_)}}let Ie=_.texture;(Ie.isData3DTexture||Ie.isDataArrayTexture||Ie.isCompressedArrayTexture)&&(de=!0);let Oe=Se.get(_).__webglFramebuffer;_.isWebGLCubeRenderTarget?(Array.isArray(Oe[O])?U=Oe[O][B]:U=Oe[O],te=!0):_.samples>0&&He.useMultisampledRTT(_)===!1?U=Se.get(_).__webglMultisampledFramebuffer:Array.isArray(Oe)?U=Oe[B]:U=Oe,D.copy(_.viewport),V.copy(_.scissor),W=_.scissorTest}else D.copy(Me).multiplyScalar(H).floor(),V.copy($e).multiplyScalar(H).floor(),W=rt;if(B!==0&&(U=Em),be.bindFramebuffer(C.FRAMEBUFFER,U)&&z&&be.drawBuffers(_,U),be.viewport(D),be.scissor(V),be.setScissorTest(W),te){let ge=Se.get(_.texture);C.framebufferTexture2D(C.FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_CUBE_MAP_POSITIVE_X+O,ge.__webglTexture,B)}else if(de){let ge=O;for(let Ie=0;Ie<_.textures.length;Ie++){let Oe=Se.get(_.textures[Ie]);C.framebufferTextureLayer(C.FRAMEBUFFER,C.COLOR_ATTACHMENT0+Ie,Oe.__webglTexture,B,ge)}}else if(_!==null&&B!==0){let ge=Se.get(_.texture);C.framebufferTexture2D(C.FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_2D,ge.__webglTexture,B)}w=-1},this.readRenderTargetPixels=function(_,O,B,z,U,te,de,xe=0){if(!(_&&_.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ge=Se.get(_).__webglFramebuffer;if(_.isWebGLCubeRenderTarget&&de!==void 0&&(ge=ge[de]),ge){be.bindFramebuffer(C.FRAMEBUFFER,ge);try{let Ie=_.textures[xe],Oe=Ie.format,Re=Ie.type;if(!Ne.textureFormatReadable(Oe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ne.textureTypeReadable(Re)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}O>=0&&O<=_.width-z&&B>=0&&B<=_.height-U&&(_.textures.length>1&&C.readBuffer(C.COLOR_ATTACHMENT0+xe),C.readPixels(O,B,z,U,Te.convert(Oe),Te.convert(Re),te))}finally{let Ie=k!==null?Se.get(k).__webglFramebuffer:null;be.bindFramebuffer(C.FRAMEBUFFER,Ie)}}},this.readRenderTargetPixelsAsync=async function(_,O,B,z,U,te,de,xe=0){if(!(_&&_.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ge=Se.get(_).__webglFramebuffer;if(_.isWebGLCubeRenderTarget&&de!==void 0&&(ge=ge[de]),ge)if(O>=0&&O<=_.width-z&&B>=0&&B<=_.height-U){be.bindFramebuffer(C.FRAMEBUFFER,ge);let Ie=_.textures[xe],Oe=Ie.format,Re=Ie.type;if(!Ne.textureFormatReadable(Oe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ne.textureTypeReadable(Re))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let Ye=C.createBuffer();C.bindBuffer(C.PIXEL_PACK_BUFFER,Ye),C.bufferData(C.PIXEL_PACK_BUFFER,te.byteLength,C.STREAM_READ),_.textures.length>1&&C.readBuffer(C.COLOR_ATTACHMENT0+xe),C.readPixels(O,B,z,U,Te.convert(Oe),Te.convert(Re),0);let ot=k!==null?Se.get(k).__webglFramebuffer:null;be.bindFramebuffer(C.FRAMEBUFFER,ot);let _t=C.fenceSync(C.SYNC_GPU_COMMANDS_COMPLETE,0);return C.flush(),await sp(C,_t,4),C.bindBuffer(C.PIXEL_PACK_BUFFER,Ye),C.getBufferSubData(C.PIXEL_PACK_BUFFER,0,te),C.deleteBuffer(Ye),C.deleteSync(_t),te}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(_,O=null,B=0){let z=Math.pow(2,-B),U=Math.floor(_.image.width*z),te=Math.floor(_.image.height*z),de=O!==null?O.x:0,xe=O!==null?O.y:0;He.setTexture2D(_,0),C.copyTexSubImage2D(C.TEXTURE_2D,B,0,0,de,xe,U,te),be.unbindTexture()};let Tm=C.createFramebuffer(),Am=C.createFramebuffer();this.copyTextureToTexture=function(_,O,B=null,z=null,U=0,te=null){te===null&&(U!==0?(Zr("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),te=U,U=0):te=0);let de,xe,ge,Ie,Oe,Re,Ye,ot,_t,dt=_.isCompressedTexture?_.mipmaps[te]:_.image;if(B!==null)de=B.max.x-B.min.x,xe=B.max.y-B.min.y,ge=B.isBox3?B.max.z-B.min.z:1,Ie=B.min.x,Oe=B.min.y,Re=B.isBox3?B.min.z:0;else{let yn=Math.pow(2,-U);de=Math.floor(dt.width*yn),xe=Math.floor(dt.height*yn),_.isDataArrayTexture?ge=dt.depth:_.isData3DTexture?ge=Math.floor(dt.depth*yn):ge=1,Ie=0,Oe=0,Re=0}z!==null?(Ye=z.x,ot=z.y,_t=z.z):(Ye=0,ot=0,_t=0);let ct=Te.convert(O.format),Pe=Te.convert(O.type),vt;O.isData3DTexture?(He.setTexture3D(O,0),vt=C.TEXTURE_3D):O.isDataArrayTexture||O.isCompressedArrayTexture?(He.setTexture2DArray(O,0),vt=C.TEXTURE_2D_ARRAY):(He.setTexture2D(O,0),vt=C.TEXTURE_2D),C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL,O.flipY),C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),C.pixelStorei(C.UNPACK_ALIGNMENT,O.unpackAlignment);let et=C.getParameter(C.UNPACK_ROW_LENGTH),ln=C.getParameter(C.UNPACK_IMAGE_HEIGHT),yr=C.getParameter(C.UNPACK_SKIP_PIXELS),cn=C.getParameter(C.UNPACK_SKIP_ROWS),bs=C.getParameter(C.UNPACK_SKIP_IMAGES);C.pixelStorei(C.UNPACK_ROW_LENGTH,dt.width),C.pixelStorei(C.UNPACK_IMAGE_HEIGHT,dt.height),C.pixelStorei(C.UNPACK_SKIP_PIXELS,Ie),C.pixelStorei(C.UNPACK_SKIP_ROWS,Oe),C.pixelStorei(C.UNPACK_SKIP_IMAGES,Re);let xt=_.isDataArrayTexture||_.isData3DTexture,gn=O.isDataArrayTexture||O.isData3DTexture;if(_.isDepthTexture){let yn=Se.get(_),jt=Se.get(O),en=Se.get(yn.__renderTarget),mc=Se.get(jt.__renderTarget);be.bindFramebuffer(C.READ_FRAMEBUFFER,en.__webglFramebuffer),be.bindFramebuffer(C.DRAW_FRAMEBUFFER,mc.__webglFramebuffer);for(let Ui=0;Ui<ge;Ui++)xt&&(C.framebufferTextureLayer(C.READ_FRAMEBUFFER,C.COLOR_ATTACHMENT0,Se.get(_).__webglTexture,U,Re+Ui),C.framebufferTextureLayer(C.DRAW_FRAMEBUFFER,C.COLOR_ATTACHMENT0,Se.get(O).__webglTexture,te,_t+Ui)),C.blitFramebuffer(Ie,Oe,de,xe,Ye,ot,de,xe,C.DEPTH_BUFFER_BIT,C.NEAREST);be.bindFramebuffer(C.READ_FRAMEBUFFER,null),be.bindFramebuffer(C.DRAW_FRAMEBUFFER,null)}else if(U!==0||_.isRenderTargetTexture||Se.has(_)){let yn=Se.get(_),jt=Se.get(O);be.bindFramebuffer(C.READ_FRAMEBUFFER,Tm),be.bindFramebuffer(C.DRAW_FRAMEBUFFER,Am);for(let en=0;en<ge;en++)xt?C.framebufferTextureLayer(C.READ_FRAMEBUFFER,C.COLOR_ATTACHMENT0,yn.__webglTexture,U,Re+en):C.framebufferTexture2D(C.READ_FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_2D,yn.__webglTexture,U),gn?C.framebufferTextureLayer(C.DRAW_FRAMEBUFFER,C.COLOR_ATTACHMENT0,jt.__webglTexture,te,_t+en):C.framebufferTexture2D(C.DRAW_FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_2D,jt.__webglTexture,te),U!==0?C.blitFramebuffer(Ie,Oe,de,xe,Ye,ot,de,xe,C.COLOR_BUFFER_BIT,C.NEAREST):gn?C.copyTexSubImage3D(vt,te,Ye,ot,_t+en,Ie,Oe,de,xe):C.copyTexSubImage2D(vt,te,Ye,ot,Ie,Oe,de,xe);be.bindFramebuffer(C.READ_FRAMEBUFFER,null),be.bindFramebuffer(C.DRAW_FRAMEBUFFER,null)}else gn?_.isDataTexture||_.isData3DTexture?C.texSubImage3D(vt,te,Ye,ot,_t,de,xe,ge,ct,Pe,dt.data):O.isCompressedArrayTexture?C.compressedTexSubImage3D(vt,te,Ye,ot,_t,de,xe,ge,ct,dt.data):C.texSubImage3D(vt,te,Ye,ot,_t,de,xe,ge,ct,Pe,dt):_.isDataTexture?C.texSubImage2D(C.TEXTURE_2D,te,Ye,ot,de,xe,ct,Pe,dt.data):_.isCompressedTexture?C.compressedTexSubImage2D(C.TEXTURE_2D,te,Ye,ot,dt.width,dt.height,ct,dt.data):C.texSubImage2D(C.TEXTURE_2D,te,Ye,ot,de,xe,ct,Pe,dt);C.pixelStorei(C.UNPACK_ROW_LENGTH,et),C.pixelStorei(C.UNPACK_IMAGE_HEIGHT,ln),C.pixelStorei(C.UNPACK_SKIP_PIXELS,yr),C.pixelStorei(C.UNPACK_SKIP_ROWS,cn),C.pixelStorei(C.UNPACK_SKIP_IMAGES,bs),te===0&&O.generateMipmaps&&C.generateMipmap(vt),be.unbindTexture()},this.initRenderTarget=function(_){Se.get(_).__webglFramebuffer===void 0&&He.setupRenderTarget(_)},this.initTexture=function(_){_.isCubeTexture?He.setTextureCube(_,0):_.isData3DTexture?He.setTexture3D(_,0):_.isDataArrayTexture||_.isCompressedArrayTexture?He.setTexture2DArray(_,0):He.setTexture2D(_,0),be.unbindTexture()},this.resetState=function(){T=0,R=0,k=null,be.reset(),he.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ln}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Ke._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ke._getUnpackColorSpace()}};var Up={type:"change"},mu={type:"start"},Bp={type:"end"},Jl=new Ci,Fp=new _n,Hb=Math.cos(70*qh.DEG2RAD),It=new N,on=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},pu=1e-6,Kl=class extends ha{constructor(e,t=null){super(e,t),this.state=lt.NONE,this.target=new N,this.cursor=new N,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:wn.ROTATE,MIDDLE:wn.DOLLY,RIGHT:wn.PAN},this.touches={ONE:On.ROTATE,TWO:On.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new N,this._lastQuaternion=new bn,this._lastTargetPosition=new N,this._quat=new bn().setFromUnitVectors(e.up,new N(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new is,this._sphericalDelta=new is,this._scale=1,this._panOffset=new N,this._rotateStart=new ke,this._rotateEnd=new ke,this._rotateDelta=new ke,this._panStart=new ke,this._panEnd=new ke,this._panDelta=new ke,this._dollyStart=new ke,this._dollyEnd=new ke,this._dollyDelta=new ke,this._dollyDirection=new N,this._mouse=new ke,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Wb.bind(this),this._onPointerDown=Gb.bind(this),this._onPointerUp=$b.bind(this),this._onContextMenu=Kb.bind(this),this._onMouseWheel=Yb.bind(this),this._onKeyDown=jb.bind(this),this._onTouchStart=Zb.bind(this),this._onTouchMove=Jb.bind(this),this._onMouseDown=Xb.bind(this),this._onMouseMove=qb.bind(this),this._interceptControlDown=Qb.bind(this),this._interceptControlUp=eS.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}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.removeEventListener("pointermove",this._onPointerMove),this.domElement.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="auto"}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(Up),this.update(),this.state=lt.NONE}update(e=null){let t=this.object.position;It.copy(t).sub(this.target),It.applyQuaternion(this._quat),this._spherical.setFromVector3(It),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 i=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(i)&&isFinite(r)&&(i<-Math.PI?i+=on:i>Math.PI&&(i-=on),r<-Math.PI?r+=on:r>Math.PI&&(r-=on),i<=r?this._spherical.theta=Math.max(i,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+r)/2?Math.max(i,this._spherical.theta):Math.min(r,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 s=!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),s=a!=this._spherical.radius}if(It.setFromSpherical(this._spherical),It.applyQuaternion(this._quatInverse),t.copy(this.target).add(It),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=It.length();a=this._clampDistance(o*this._scale);let l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){let o=new N(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(),s=l!==this.object.zoom;let c=new N(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=It.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):(Jl.origin.copy(this.object.position),Jl.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Jl.direction))<Hb?this.object.lookAt(this.target):(Fp.setFromNormalAndCoplanarPoint(this.object.up,this.target),Jl.intersectPlane(Fp,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(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>pu||8*(1-this._lastQuaternion.dot(this.object.quaternion))>pu||this._lastTargetPosition.distanceToSquared(this.target)>pu?(this.dispatchEvent(Up),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?on/60*this.autoRotateSpeed*e:on/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){It.setFromMatrixColumn(t,0),It.multiplyScalar(-e),this._panOffset.add(It)}_panUp(e,t){this.screenSpacePanning===!0?It.setFromMatrixColumn(t,1):(It.setFromMatrixColumn(t,0),It.crossVectors(this.object.up,It)),It.multiplyScalar(e),this._panOffset.add(It)}_pan(e,t){let i=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;It.copy(r).sub(this.target);let s=It.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/i.clientHeight,this.object.matrix),this._panUp(2*t*s/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.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 i=this.domElement.getBoundingClientRect(),r=e-i.left,s=t-i.top,a=i.width,o=i.height;this._mouse.x=r/a*2-1,this._mouse.y=-(s/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(on*this._rotateDelta.x/t.clientHeight),this._rotateUp(on*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(on*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(-on*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(on*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(-on*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),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(i,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(i,r)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),i=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(i*i+r*r);this._dollyStart.set(0,s)}_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 i=this._getSecondPointerPosition(e),r=.5*(e.pageX+i.x),s=.5*(e.pageY+i.y);this._rotateEnd.set(r,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(on*this._rotateDelta.x/t.clientHeight),this._rotateUp(on*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),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(i,r)}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),i=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(i*i+r*r);this._dollyEnd.set(0,s),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 ke,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,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}};function Gb(n){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(n.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(n)&&(this._addPointer(n),n.pointerType==="touch"?this._onTouchStart(n):this._onMouseDown(n)))}function Wb(n){this.enabled!==!1&&(n.pointerType==="touch"?this._onTouchMove(n):this._onMouseMove(n))}function $b(n){switch(this._removePointer(n),this._pointers.length){case 0:this.domElement.releasePointerCapture(n.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Bp),this.state=lt.NONE;break;case 1:let e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function Xb(n){let e;switch(n.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 wn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(n),this.state=lt.DOLLY;break;case wn.ROTATE:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=lt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=lt.ROTATE}break;case wn.PAN:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=lt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=lt.PAN}break;default:this.state=lt.NONE}this.state!==lt.NONE&&this.dispatchEvent(mu)}function qb(n){switch(this.state){case lt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(n);break;case lt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(n);break;case lt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(n);break}}function Yb(n){this.enabled===!1||this.enableZoom===!1||this.state!==lt.NONE||(n.preventDefault(),this.dispatchEvent(mu),this._handleMouseWheel(this._customWheelEvent(n)),this.dispatchEvent(Bp))}function jb(n){this.enabled!==!1&&this._handleKeyDown(n)}function Zb(n){switch(this._trackPointer(n),this._pointers.length){case 1:switch(this.touches.ONE){case On.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(n),this.state=lt.TOUCH_ROTATE;break;case On.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(n),this.state=lt.TOUCH_PAN;break;default:this.state=lt.NONE}break;case 2:switch(this.touches.TWO){case On.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(n),this.state=lt.TOUCH_DOLLY_PAN;break;case On.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(n),this.state=lt.TOUCH_DOLLY_ROTATE;break;default:this.state=lt.NONE}break;default:this.state=lt.NONE}this.state!==lt.NONE&&this.dispatchEvent(mu)}function Jb(n){switch(this._trackPointer(n),this.state){case lt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(n),this.update();break;case lt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(n),this.update();break;case lt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(n),this.update();break;case lt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(n),this.update();break;default:this.state=lt.NONE}}function Kb(n){this.enabled!==!1&&n.preventDefault()}function Qb(n){n.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function eS(n){n.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function zp(n){let e=new Map;for(let t of n){let i=JSON.stringify([t.label,t.gradient,t.lo,t.hi]),r=e.get(i);r===void 0?e.set(i,t):e.set(i,{...r,marker:r.marker??t.marker,band:r.band??t.band})}return[...e.values()]}function ds(n,e,t){let i={panels:new Map,gutters:[]},r=(s,a,o)=>{if(s.kind==="panel"){i.panels.set(s.id,a);return}let l=s.dir==="row",c=Math.max(0,(l?a.w:a.h)-t),h=Math.round(c*s.ratio),u=c-h;l?(r(s.a,{x:a.x,y:a.y,w:h,h:a.h},`${o}a`),i.gutters.push({path:o,dir:s.dir,rect:{x:a.x+h,y:a.y,w:t,h:a.h},outer:a}),r(s.b,{x:a.x+h+t,y:a.y,w:u,h:a.h},`${o}b`)):(r(s.a,{x:a.x,y:a.y,w:a.w,h},`${o}a`),i.gutters.push({path:o,dir:s.dir,rect:{x:a.x,y:a.y+h,w:a.w,h:t},outer:a}),r(s.b,{x:a.x,y:a.y+h+t,w:a.w,h:u},`${o}b`))};return r(n,e,""),i}function Ql(n,e,t){return n.kind==="panel"?n:e===""?{...n,ratio:t}:e[0]==="a"?{...n,a:Ql(n.a,e.slice(1),t)}:{...n,b:Ql(n.b,e.slice(1),t)}}function Vp(n,e,t,i){let r=n.outer,s=n.dir==="row"?e-r.x-i/2:t-r.y-i/2,a=Math.max(1,(n.dir==="row"?r.w:r.h)-i);return Math.min(.9,Math.max(.1,s/a))}var ys=6,Hp=9,tS=8,nS=.25,iS=.35,_u="vec4(2.0, 2.0, 2.0, 1.0)",Jp=`
3841
+ attribute vec2 useg;
3842
+ attribute float track;
3843
+ uniform highp sampler2D uRanges;
3844
+ uniform highp sampler2D uAlphas;
3845
+ uniform int uRangesWidth;
3846
+ uniform int uKernel;
3847
+ uniform float uLap;
3848
+ uniform float uSkip;
3849
+ uniform float uOpacity;
3850
+ uniform float uFraction;
3851
+ uniform float uTaperOpacity;
3852
+ ivec2 texelOf(float tr) {
3853
+ int t = int(tr + 0.5);
3854
+ return ivec2(t % uRangesWidth, t / uRangesWidth);
3855
+ }
3856
+ bool revealed(vec4 r) {
3857
+ bool lo = uLap > r.x || (uLap == r.x && r.y < useg.x);
3858
+ bool hi = uLap < r.z || (uLap == r.z && useg.y < r.w);
3859
+ return lo && hi && !(uSkip >= 0.0 && abs(track - uSkip) < 0.5);
3860
+ }
3861
+ float along(vec4 r, float u) {
3862
+ if (uFraction <= 0.0) return 1.0;
3863
+ return clamp(1.0 - (r.z + r.w - (uLap + u)) / uFraction, 0.0, 1.0);
3864
+ }
3865
+ float alphaOf(float tr) {
3866
+ return uKernel == 1 ? texelFetch(uAlphas, texelOf(tr), 0).x : uOpacity;
3867
+ }
3868
+ `,Kp=`
3869
+ uniform vec2 uResolution;
3870
+ void trimSegment(const in vec4 start, inout vec4 end) {
3871
+ float nearEstimate = -0.5 * projectionMatrix[3][2] / projectionMatrix[2][2];
3872
+ float alpha = (nearEstimate - start.z) / (end.z - start.z);
3873
+ end.xyz = mix(start.xyz, end.xyz, alpha);
3874
+ }
3875
+ vec4 corner(vec3 a, vec3 b, float w) {
3876
+ vec4 va = modelViewMatrix * vec4(a, 1.0);
3877
+ vec4 vb = modelViewMatrix * vec4(b, 1.0);
3878
+ if (projectionMatrix[2][3] == -1.0) {
3879
+ if (va.z >= 0.0 && vb.z >= 0.0) return ${_u};
3880
+ if (va.z < 0.0 && vb.z >= 0.0) trimSegment(va, vb);
3881
+ else if (vb.z < 0.0 && va.z >= 0.0) trimSegment(vb, va);
3882
+ }
3883
+ vec4 ca = projectionMatrix * va;
3884
+ vec4 cb = projectionMatrix * vb;
3885
+ vec2 d = (cb.xy / cb.w - ca.xy / ca.w) * uResolution;
3886
+ float len = length(d);
3887
+ vec2 dir = len > 1e-9 ? d / len : vec2(1.0, 0.0);
3888
+ vec2 nrm = vec2(-dir.y, dir.x);
3889
+ vec4 c = position.y > 0.5 ? cb : ca;
3890
+ c.xy += nrm * position.x * w / uResolution * c.w;
3891
+ return c;
3892
+ }
3893
+ `,rS=Jp+`
3894
+ #ifdef USE_TRACK_COLOR
3895
+ attribute vec3 tcolor;
3896
+ #endif
3897
+ uniform vec3 uColor;
3898
+ varying vec4 vColor;
3899
+ void main() {
3900
+ vec4 r = texelFetch(uRanges, texelOf(track), 0);
3901
+ if (!revealed(r)) {
3902
+ vColor = vec4(0.0);
3903
+ gl_Position = ${_u};
3904
+ return;
3905
+ }
3906
+ float s = along(r, gl_VertexID % 2 == 1 ? useg.y : useg.x);
3907
+ #ifdef USE_TRACK_COLOR
3908
+ vec3 rgb = tcolor;
3909
+ #else
3910
+ vec3 rgb = uColor;
3911
+ #endif
3912
+ vColor = vec4(rgb, alphaOf(track) * mix(uTaperOpacity, 1.0, s));
3913
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
3914
+ }
3915
+ `,sS=Jp+Kp+`
3916
+ attribute vec3 instanceStart;
3917
+ attribute vec3 instanceEnd;
3918
+ #ifdef USE_TRACK_COLOR
3919
+ attribute vec3 colorStart;
3920
+ attribute vec3 colorEnd;
3921
+ #endif
3922
+ uniform vec3 uColor;
3923
+ uniform float uWidth;
3924
+ uniform float uTaperWidth;
3925
+ varying vec4 vColor;
3926
+ void main() {
3927
+ vec4 r = texelFetch(uRanges, texelOf(track), 0);
3928
+ if (!revealed(r)) {
3929
+ vColor = vec4(0.0);
3930
+ gl_Position = ${_u};
3931
+ return;
3932
+ }
3933
+ bool atEnd = position.y > 0.5;
3934
+ float s = along(r, atEnd ? useg.y : useg.x);
3935
+ #ifdef USE_TRACK_COLOR
3936
+ vec3 rgb = atEnd ? colorEnd : colorStart;
3937
+ #else
3938
+ vec3 rgb = uColor;
3939
+ #endif
3940
+ vColor = vec4(rgb, alphaOf(track) * mix(uTaperOpacity, 1.0, s));
3941
+ gl_Position = corner(instanceStart, instanceEnd, uWidth * mix(uTaperWidth, 1.0, s));
3942
+ }
3943
+ `,aS=Kp+`
3944
+ attribute vec3 instanceStart;
3945
+ attribute vec3 instanceEnd;
3946
+ attribute vec4 colorStart;
3947
+ attribute vec4 colorEnd;
3948
+ attribute float widthStart;
3949
+ attribute float widthEnd;
3950
+ varying vec4 vColor;
3951
+ void main() {
3952
+ bool atEnd = position.y > 0.5;
3953
+ vColor = atEnd ? colorEnd : colorStart;
3954
+ gl_Position = corner(instanceStart, instanceEnd, atEnd ? widthEnd : widthStart);
3955
+ }
3956
+ `,oS=`
3957
+ varying vec4 vColor;
3958
+ void main() {
3959
+ gl_FragColor = vColor;
3960
+ }
3961
+ `;function lS(){let n=document.createElement("canvas");n.width=n.height=64;let e=n.getContext("2d");e.fillStyle="#fff",e.beginPath(),e.arc(32,32,28,0,Math.PI*2),e.fill();let t=new ra(n);return t.needsUpdate=!0,t}function ec(n,e=6){if(!(n>0)||!Number.isFinite(n))return 1;let t=n/e,i=Math.pow(10,Math.floor(Math.log10(t))),r=t/i;return(r<1.5?1:r<3.5?2:r<7.5?5:10)*i}function ms(n){let e=(o,l,c)=>new N(o,l,c);if(n.kind==="plane")return n.plane==="xz"?{right:e(1,0,0),up:e(0,0,1),normal:e(0,-1,0)}:n.plane==="yz"?{right:e(0,1,0),up:e(0,0,1),normal:e(1,0,0)}:{right:e(1,0,0),up:e(0,1,0),normal:e(0,0,1)};let[t,i,r]=n.up==="x"?[e(0,1,0),e(0,0,1),e(1,0,0)]:n.up==="y"?[e(0,0,1),e(1,0,0),e(0,1,0)]:[e(1,0,0),e(0,1,0),e(0,0,1)],s=t.clone().addScaledVector(i,-1.6).addScaledVector(r,.9).normalize();return{right:new N().crossVectors(r,s).normalize(),up:r,normal:s}}function cS(n){return n.plane==="xz"?[0,2]:n.plane==="yz"?[1,2]:[0,1]}function Qp(){let n=new la;return n.setAttribute("position",new $t([-1,0,0,1,0,0,-1,1,0,1,1,0],3)),n.setIndex([0,1,2,2,1,3]),n}var em=(n,e,t={})=>new sn({vertexShader:n,fragmentShader:oS,uniforms:e,defines:t,transparent:!0,depthTest:!1,depthWrite:!1,side:Mn}),Gp=n=>Math.min(1,Math.max(0,n)),gu=class{cache=new Map;get(e,t){let i=this.cache.get(e);return i===void 0&&(i=t(),this.cache.set(e,i)),i}};function hS(n,e){if(e===void 0||typeof e=="string"||typeof e.colormap=="string")return e;let t=e.colormap;it(n.scene,t.var)?.kind!=="choice"&&I("2.7",`the colormap is keyed on ${t.var}, which is not a choice`);let i=mi(n,t.var),r=typeof i=="string"&&Object.hasOwn(t.map,i)?t.map[i]:void 0;return r===void 0&&I("2.7",`the colormap keyed on ${t.var} does not name a colormap for ${JSON.stringify(i)}`),{...e,colormap:r}}function uS(n,e,t,i){let r=t.panels[i],s=n.views[r.view],a={scene:n,state:t,panel:r},o=Tr(a,s),l=Zt(n.clock),c=Tn(a,s.driver.sets),h=c===null?null:{set:e.sets.get(c),track:0};h&&(h.track=Er(a,s.driver.member,h.set),l>1&&!h.set.periodic&&I("C6",`the driver's track set ${h.set.id} is not periodic, and the clock has ${l} laps`));let u=[];return s.layers.forEach((d,f)=>{if(Ar(a,d))if(d.kind==="track"){let g=Tn(a,d.sets),y=g===null?null:e.sets.get(g),m=y===null?[]:Ia(a,d.members,y),p=wd(d,n.clock)?t.clock.channel:null;y!==null&&p!==null&&l>1&&!y.periodic&&I("C6",`a reading is taken on track set ${y.id}, which is not periodic, and the clock has ${l} laps`);let M=d.highlight;if(M?.kernel!==void 0){let A=it(n,M.var);(A?.kind!=="selector"||(A.by??"nearest")!=="nearest"||A.parameter===void 0)&&I("2.7",`a highlight kernel needs a selector by nearest, and ${M.var} is not one`)}let S=y!==null&&M!==void 0?Pa(a,{var:M.var},y):null,x=S!==null&&m.includes(S)?S:null;u.push({kind:"track",index:f,layer:d,set:y,members:m,highlight:x,selected:S,channel:p,color:hS(a,d.color)})}else d.kind==="body"?u.push({kind:"body",index:f,layer:d}):u.push({kind:d.kind,index:f,layer:d})}),{viewId:r.view,view:s,display:o,scope:a,driver:h,layers:u}}function dS(n){return[n.viewId,n.display,n.driver?.set.id??"",...n.layers.map(e=>e.kind==="track"?e.set?.id??"":"")].join("\0")}function fS(n,e){let t=null;for(let i of n.layers){if(i.kind!=="track"||i.set===null||i.members.length===0)continue;let r=e.geometry(i.set.id,n.display),s=i.members.length===i.set.tracks?[r.bounds()]:i.members.map(a=>r.bounds(a));for(let a of s)if(t===null)t=[...a];else for(let o=0;o<3;o++)t[o]=Math.min(t[o],a[o]),t[o+3]=Math.max(t[o+3],a[o+3])}return t}function pS(n,e,t){let i=n.getCenter(new N),r=n.getSize(new N),s=Math.max(r.length()/2,1e-9),{right:a,up:o}=ms(e),l=d=>new N(Math.abs(d.x),Math.abs(d.y),Math.abs(d.z)),c=e.kind==="plane"?r.dot(l(a))/2:s,h=e.kind==="plane"?r.dot(l(o))/2:s,u=Math.max(h,c/t)*1.1;return{center:i,halfHeight:u>1e-12?u:Math.max(s,1)}}function mS(n,e,t,i){let r=t>0?i/(e.width*t):0;return Math.max(n,e.opacity*Math.exp(-r*r))}function gS(n,e,t,i){let{right:r,up:s}=ms(e),a=n.position.dot(r),o=n.position.dot(s),l=(n.right-n.left)/(2*n.zoom),c=(n.top-n.bottom)/(2*n.zoom);return{x0:a-l,x1:a+l,y0:o-c,y1:o+c,w:t,h:i,stepX:ec(2*l,Math.max(3,t/110)),stepY:ec(2*c,Math.max(3,i/70))}}function tc(n,e,t){let i=[],r=Math.floor(e/t);for(let s=Math.ceil(n/t);s<=r&&i.length<1e3;s++)i.push(s*t);return i}function Wp(n,e){let t=Math.max(0,-Math.floor(Math.log10(e)));return(Math.abs(n)<e*1e-9?0:n).toFixed(t).replace("-","\u2212")}var yS=n=>7*n.length-3.5*(n.split(".").length-1),$p=160;function vS(n,e,t){let i=[],r=a=>(a-n.x0)/(n.x1-n.x0)*n.w,s=a=>n.h-(a-n.y0)/(n.y1-n.y0)*n.h;if(e){let a=[];for(let l of tc(n.y0,n.y1,n.stepY)){let c=s(l);c>22&&c<n.h-44&&a.push({text:Wp(l,n.stepY),x:0,y:c,align:"end",kind:"tick"})}let o=Math.max(44,22+Math.max(0,...a.map(l=>yS(l.text))));for(let l of tc(n.x0,n.x1,n.stepX)){let c=r(l);c>o+12&&c<n.w-16&&i.push({text:Wp(l,n.stepX),x:c,y:n.h-28,align:"center",kind:"tick"})}for(let l of a)i.push({...l,x:o})}return t!==null&&(t[0]!==""&&n.h>=$p&&i.push({text:t[0],x:n.w/2,y:n.h-10,align:"center",kind:"title"}),t[1]!==""&&n.w>=$p&&i.push({text:t[1],x:10,y:n.h/2,align:"center",rotate:!0,kind:"title"})),i}var yu=class{holder=new zt;mat;spec;src;wide;obj=null;sharedNames=[];shown="";constructor(e,t,i){this.src=e,this.spec=t,this.wide=t.width>1;let r={...i,uLap:{value:t.lap},uSkip:{value:-1},uOpacity:{value:t.opacity},uWidth:{value:t.width},uKernel:{value:e.kernel&&!t.highlight?1:0}},s=e.coloring.kind==="sample"?{USE_TRACK_COLOR:""}:void 0;this.mat=em(this.wide?sS:rS,r,s)}show(e){let t=e===null?"":String(e);if(t===this.shown||(this.clear(),this.shown=t,e===null))return;let i=this.wide?this.quads(e):this.lines(e);this.obj=this.wide?new Xt(i,this.mat):new ts(i,this.mat),this.obj.frustumCulled=!1,this.obj.renderOrder=this.holder.parent?.renderOrder??0,this.holder.add(this.obj)}arrays(e){let{ctx:t,set:i,geo:r,display:s,readings:a,coloring:o,colorKey:l}=this.src,c=this.spec.lap;if(e==="set")return{pos:t.shared.get(`pos\0${i.id}\0${s}\0${r.lapKey(c)}`,()=>Pd(r,c)),u:t.shared.get(`u\0${i.id}\0${a.channel}`,()=>Dd(i,a.u)),tr:t.shared.get(`t\0${i.id}`,()=>Nd(i)),col:o.kind==="sample"?t.shared.get(`c\0${i.id}\0${l}`,()=>Ad(i,o.rgb,3)):null};let h=i.start(e),u=i.count(e);return{pos:Id(r,e,c),u:kd(a.u,h,u),tr:new Float32Array(2*(u-1)).fill(e),col:o.kind==="sample"?Cd(o.rgb,3,h,u):null}}lines(e){let t=this.arrays(e),i=(s,a,o)=>e==="set"?this.src.ctx.shared.get(`gl\0${s}\0${this.src.set.id}\0${qp(a)}`,()=>new wt(a,o)):new wt(a,o),r=new Tt;return r.setAttribute("position",i("position",t.pos,3)),r.setAttribute("useg",i("useg",t.u,2)),r.setAttribute("track",i("track",t.tr,1)),t.col&&r.setAttribute("tcolor",i("tcolor",t.col,3)),this.sharedNames=e==="set"?Object.keys(r.attributes):[],r}quads(e){let t=this.arrays(e),i=(a,o,l)=>e==="set"?this.src.ctx.shared.get(`gpu\0${a}\0${this.src.set.id}\0${qp(o)}`,()=>new lr(o,l)):new lr(o,l),r=Qp(),s=i("pos",t.pos,6);if(r.setAttribute("instanceStart",new qt(s,3,0)),r.setAttribute("instanceEnd",new qt(s,3,3)),r.setAttribute("useg",new qt(i("u",t.u,4),2,0)),r.setAttribute("track",new qt(i("t",t.tr,2),1,0)),t.col){let a=i("c",t.col,6);r.setAttribute("colorStart",new qt(a,3,0)),r.setAttribute("colorEnd",new qt(a,3,3))}return r.instanceCount=t.pos.length/6,this.sharedNames=e==="set"?Object.keys(r.attributes).filter(a=>a!=="position"):[],r}clear(){if(this.obj!==null){this.holder.remove(this.obj);for(let e of this.sharedNames)this.obj.geometry.deleteAttribute(e);this.obj.geometry.dispose(),this.obj=null,this.sharedNames=[]}}dispose(){this.clear(),this.mat.dispose()}},Xp=new WeakMap,xS=0;function qp(n){let e=Xp.get(n);return e===void 0&&(e=xS++,Xp.set(n,e)),e}var vu=class{mesh;buffer;mat;n=0;constructor(e,t){this.mat=em(aS,{uResolution:t}),this.buffer=this.allocate(e),this.mesh=new Xt(this.geometry(),this.mat),this.mesh.frustumCulled=!1}allocate(e){let t=new lr(new Float32Array(16*Math.max(1,e)),16);return t.setUsage(ur),t}geometry(){let e=Qp(),t=this.buffer;return e.setAttribute("instanceStart",new qt(t,3,0)),e.setAttribute("instanceEnd",new qt(t,3,3)),e.setAttribute("colorStart",new qt(t,4,6)),e.setAttribute("colorEnd",new qt(t,4,10)),e.setAttribute("widthStart",new qt(t,1,14)),e.setAttribute("widthEnd",new qt(t,1,15)),e.instanceCount=0,e}begin(e){return 16*e>this.buffer.array.length&&(this.mesh.geometry.dispose(),this.buffer=this.allocate(2*e),this.mesh.geometry=this.geometry()),this.n=0,this.buffer.array}end(){this.mesh.geometry.instanceCount=this.n,this.mesh.visible=this.n>0,this.buffer.clearUpdateRanges(),this.buffer.addUpdateRange(0,16*this.n),this.buffer.needsUpdate=!0}dispose(){this.mesh.geometry.dispose(),this.mat.dispose()}};function _S(n,e,t){let i=e.highlight?.kernel;if(i===void 0)return null;let r=it(n.scene,e.highlight.var);if(r?.kind!=="selector"||r.parameter===void 0)return null;let s=t.parameter(r.parameter,"2.7"),a=1/0,o=-1/0;for(let l=0;l<s.length;l++)a=Math.min(a,s[l]),o=Math.max(o,s[l]);return{parameter:r.parameter,width:i.width,opacity:i.opacity,values:s,extent:o>=a?o-a:0}}function Yp(n){let e=Math.min(Math.max(n,1),2048),t=Math.ceil(Math.max(n,1)/e),i=new Float32Array(4*e*t),r=new na(i,e,t,an,En);return r.minFilter=r.magFilter=Bt,r.generateMipmaps=!1,r.needsUpdate=!0,{data:i,texture:r,width:e}}var fs=class{key;group=new Dn;src;layer;set;geo;clocks;spec;color;width;hiWidth;opacity;hiOpacity;fraction;taperWidth;taperOpacity;kernel;ranges;alphas;resolution={value:new ke(1,1)};uniforms;baseHolder=new zt;hiHolder=new zt;passes=new Map;pieces;heads=null;headSize;headColor;members=[];highlight=null;selected=null;baseWhat=null;skip=-1;filled=!1;constructor(e,t,i,r){this.key=r;let s=t.set,a=t.layer;this.set=s,this.layer=a,this.geo=e.geometry.geometry(s.id,i),this.clocks=t.channel===null?null:e.geometry.readings(s.id,t.channel);let o=this.clocks??e.geometry.readings(s.id,yt);this.spec=Md(a,s.periodic,Zt(e.scene.clock)),this.color=t.color;let l=nd(t.color,s,Nt(e.theme.foreground));this.kernel=_S(e,a,s),this.src={ctx:e,set:s,geo:this.geo,display:i,readings:o,colorKey:JSON.stringify(t.color??null),coloring:l,kernel:this.kernel!==null},this.width=a.width??1,this.hiWidth=a.highlight?.width??this.width,this.opacity=a.opacity??1,this.hiOpacity=a.highlight?.opacity??1,this.fraction=this.spec.reveal==="trail"?this.spec.laps*this.spec.fraction:0,this.taperWidth=a.trail?.taper?.width??nS,this.taperOpacity=a.trail?.taper?.opacity??iS,this.ranges=Yp(s.tracks);for(let h=0;h<s.tracks;h++)this.ranges.data.set(Os,4*h);this.alphas=this.kernel===null?null:Yp(s.tracks),this.uniforms={uRanges:{value:this.ranges.texture},uAlphas:{value:(this.alphas??this.ranges).texture},uRangesWidth:{value:this.ranges.width},uColor:{value:new N(...l.kind==="constant"?l.rgb:[1,1,1])},uResolution:this.resolution,uFraction:{value:this.fraction},uTaperWidth:{value:this.taperWidth},uTaperOpacity:{value:this.fraction>0?this.taperOpacity:1}},this.group.add(this.baseHolder,this.hiHolder),this.pieces=new vu(2*Math.min(s.tracks,64),this.resolution),this.group.add(this.pieces.mesh);let c=a.head;if(this.headSize=typeof c=="object"&&c!==null?c.size??Hp:Hp,this.headColor=typeof c=="object"&&c!==null&&c.color!==void 0?Nt(c.color):null,gi(a)){let h=new sr({size:this.headSize,sizeAttenuation:!1,map:e.disc,alphaTest:.5,vertexColors:!0,transparent:!0,depthTest:!1,depthWrite:!1});this.heads=new ns(new Tt,h),this.heads.frustumCulled=!1,this.growHeads(1),this.group.add(this.heads)}}growHeads(e){let t=this.heads;if(t===null)return;let i=t.geometry.getAttribute("position");if(i!==void 0&&i.count>=e)return;t.geometry.dispose();let r=new Tt;r.setAttribute("position",new wt(new Float32Array(3*e),3).setUsage(ur)),r.setAttribute("color",new wt(new Float32Array(3*e),3).setUsage(ur)),t.geometry=r}resize(e,t){this.resolution.value.set(Math.max(1,e),Math.max(1,t))}colorAt(e,t,i,r){let s=this.src.coloring;if(s.kind==="constant"){i.set(s.rgb,r);return}let a=this.set.start(e);if("sample"in t){for(let o=0;o<3;o++)i[r+o]=s.rgb[3*(a+t.sample)+o];return}for(let o=0;o<3;o++)i[r+o]=(1-t.w)*s.rgb[3*(a+t.k)+o]+t.w*s.rgb[3*(a+t.k+1)+o]}fillKernel(){let e=this.kernel;if(e===null||this.alphas===null)return;let t=this.selected===null?null:e.values[this.selected];for(let i=0;i<this.set.tracks;i++)this.alphas.data[4*i]=t===null?this.opacity:mS(this.opacity,e,e.extent,Math.abs(e.values[i]-t));this.alphas.texture.needsUpdate=!0}showPass(e){e.show(e.spec.highlight?this.highlight:this.baseWhat),e.mat.uniforms.uSkip.value=e.spec.highlight?-1:this.skip}pass(e,t){let i=`${t?"h":"b"}${e}`,r=this.passes.get(i);return r===void 0&&(r=new yu(this.src,{lap:e,highlight:t,width:t?this.hiWidth:this.width,opacity:t?this.hiOpacity:this.opacity},this.uniforms),(t?this.hiHolder:this.baseHolder).add(r.holder),this.passes.set(i,r),this.showPass(r)),r}syncPasses(e,t){for(let i of this.passes.values())i.holder.visible=!1;if(this.baseWhat!==null)for(let i=e[0];i<=e[1];i++)this.pass(i,!1).holder.visible=!0;if(this.highlight!==null)for(let i=t[0];i<=t[1];i++)this.pass(i,!0).holder.visible=!0}get isStatic(){return this.clocks===null}update(e,t,i){let r=e.highlight;if(e.members.length!==this.members.length||e.members.some((d,f)=>d!==this.members[f])||r!==this.highlight||e.selected!==this.selected){let d=e.layer.members!=="all"&&e.members.length===1?e.members[0]:-1;this.members=e.members,this.highlight=r,this.selected=e.selected,this.baseWhat=d>=0?d===r?null:d:e.members.length>0?"set":null,this.skip=d<0&&r!==null?r:-1;for(let f of this.passes.values())this.showPass(f);for(let f=0;f<this.set.tracks;f++)this.ranges.data.set(Os,4*f);this.fillKernel(),this.growHeads(e.members.length),this.filled=!1}if(this.clocks===null&&this.filled)return!1;let a=this.pieces.begin(2*e.members.length),o=this.heads?.geometry.getAttribute("position"),l=this.heads?.geometry.getAttribute("color"),c=0,h=[1/0,-1/0],u=[1/0,-1/0];for(let d of e.members){let f=this.clocks?.clocks[d]??null,g=Ed(f,t.clock,i,this.spec,Math.fround);this.ranges.data.set(g.range,4*d);let y=d===r;if(g.laps!==null){let S=y?u:h;S[0]=Math.min(S[0],g.laps[0]),S[1]=Math.max(S[1],g.laps[1])}let m=y?this.hiWidth:this.width,p=y?this.hiOpacity:this.alphas!==null?this.alphas.data[4*d]:this.opacity,M=this.fraction>0&&g.loop!==null;for(let S of g.pieces){let x=16*this.pieces.n++;S.forEach((A,T)=>{this.geo.vertex(d,A,a,x+3*T),this.colorAt(d,A,a,x+6+4*T);let R=M?Gp(1-(g.loop-Ld(f,A))/this.fraction):1;a[x+9+4*T]=p*(M?this.taperOpacity+(1-this.taperOpacity)*R:1),a[x+14+T]=m>1&&M?m*(this.taperWidth+(1-this.taperWidth)*R):m})}o!==void 0&&l!==void 0&&g.head!==null&&c<o.count&&(this.geo.vertex(d,g.head,o.array,3*c),this.headColor!==null?l.array.set(this.headColor,3*c):this.colorAt(d,g.head,l.array,3*c),c++)}return this.pieces.end(),this.heads!==null&&(o.needsUpdate=l.needsUpdate=!0,this.heads.geometry.setDrawRange(0,c)),this.syncPasses(h,u),this.ranges.texture.needsUpdate=!0,this.filled=!0,!0}extend(){}colorbar(){let e=this.color;if(e===void 0||typeof e=="string")return null;let t=Ec(e,this.set),i=this.set.def.parameters??{},r=t.perTrack&&Object.hasOwn(i,t.name)?i[t.name]:void 0,s=r?.label??t.name,[a,o]=t.range,l=f=>o===a?.5:Gp((f-a)/(o-a)),c=this.highlight??(this.layer.members!=="all"&&this.members.length===1?this.members[0]:null),h=t.perTrack&&c!==null?l(t.values[c]):null,u=this.kernel,d=null;if(u!==null&&t.perTrack&&t.name===u.parameter&&this.selected!==null){let f=t.values[this.selected],g=1.5*u.width*u.extent;d=[l(f-g),l(f+g)]}return{label:r?.unit?`${s}, ${r.unit}`:s,gradient:id(t),stops:Tc(t),lo:a,hi:o,marker:h,band:d}}dispose(){for(let e of this.passes.values())e.dispose();this.ranges.texture.dispose(),this.alphas?.texture.dispose(),this.pieces.dispose(),this.heads&&(this.heads.geometry.dispose(),this.heads.material.dispose())}},ps=class{key;group=new Dn;label;size;at=null;point;trail;geometry;scratch=new Float64Array(3);capacity=0;constructor(e,t,i){this.key=i,this.geometry=e.geometry;let r=e.scene.bodies??{},s=Object.hasOwn(r,t.body)?r[t.body]:void 0;this.label=s?.label??null,this.size=t.size??tS;let a=new Ze(...Nt(s?.color??e.theme.foreground)),o=new Tt;o.setAttribute("position",new wt(new Float32Array(3),3).setUsage(ur)),this.point=new ns(o,new sr({color:a,size:this.size,sizeAttenuation:!1,map:e.disc,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1})),this.point.frustumCulled=!1,this.trail=new es(new Tt,new rr({color:a,transparent:!0,opacity:.6,depthTest:!1,depthWrite:!1})),this.trail.frustumCulled=!1,this.group.add(this.trail,this.point)}update(e,t,i){if(i===null){this.point.visible=!1,this.trail.visible=!1,this.at=null;return}let{set:r,track:s}=i,a=Zt(e.clock),o=this.geometry.readings(r.id,e.channel).clocks[s],l=this.geometry.bodyTrail(t.body,e.display,r.id,s),c=a*fi(o.reading(e.clock,e.q)),h=nn(c,a),u=this.scratch;l.vertex(Dt(o,h.u,!1,h.lap),u),this.point.visible=!0,this.at=new N(u[0],u[1],u[2]);let d=this.point.geometry.getAttribute("position");if(d.setXYZ(0,u[0],u[1],u[2]),d.needsUpdate=!0,t.trail===void 0){this.trail.visible=!1;return}let f=t.trail.fraction,g=c-a*f;g<0&&!r.periodic&&(g=0);let y=Od(l.m,a,f);if(y>this.capacity){this.capacity=y,this.trail.geometry.dispose();let M=new Tt;M.setAttribute("position",new wt(new Float32Array(3*this.capacity),3).setUsage(ur)),this.trail.geometry=M}let m=this.trail.geometry.getAttribute("position"),p=l.polyline(o,g,c,a,m.array);m.clearUpdateRanges(),m.addUpdateRange(0,3*p),m.needsUpdate=!0,this.trail.geometry.setDrawRange(0,p),this.trail.visible=p>1}extend(e){this.at!==null&&e.expandByPoint(this.at)}dispose(){for(let e of[this.point,this.trail])e.geometry.dispose(),e.material.dispose()}},Di=class{key;group=new Dn;kind;follows;full;ticks;theme;lines;shown="";tips=[];constructor(e,t,i,r){this.key=r,this.kind=t.kind,this.theme=e.theme;let s=i.kind==="plane";t.kind==="axes"?(this.full=(t.span??(s?"full":"positive"))==="full",this.ticks=s&&this.full):(this.full=!1,this.ticks=s&&(t.labels??s)),this.follows=this.ticks;let a=new rr({vertexColors:!0,transparent:!0,depthTest:!1,depthWrite:!1});this.lines=new ts(new Tt,a),this.lines.frustumCulled=!1,this.group.add(this.lines)}set(e,t){this.lines.geometry.dispose();let i=new Tt;i.setAttribute("position",new $t(e,3)),i.setAttribute("color",new $t(t,4)),this.lines.geometry=i}layout(e,t){if(this.follows)return;let i=e.getCenter(new N),r=e.getSize(new N),s=Math.max(r.x,r.y,r.z,1e-9),a=[],o=[],l=(c,h,u,d)=>{a.push(c.x,c.y,c.z,h.x,h.y,h.z),o.push(...u,d,...u,d)};if(this.kind==="axes"){let c=ec(s,2),h=Nt(this.theme.foreground);this.tips=[new N(c,0,0),new N(0,c,0),new N(0,0,c)];for(let u of this.tips)l(this.full?u.clone().negate():new N,u,h,.8)}else{let{right:c,up:h,normal:u}=ms(t.kind==="plane"?t:{kind:"plane",plane:t.up==="x"?"yz":t.up==="y"?"xz":"xy"}),d=ec(s,8),f=Nt(this.theme.grid),g=Nt(kt(this.theme.grid,this.theme.foreground,.3)),y=i.dot(c),m=i.dot(h),p=Math.abs(u.x)>.5?"x":Math.abs(u.y)>.5?"y":"z",M=new N;M[p]=1;let S=e.min[p]<=0&&e.max[p]>=0?0:i[p],x=2.5*s,A=Math.floor((y-x)/d),T=Math.ceil((y+x)/d),R=Math.floor((m-x)/d),k=Math.ceil((m+x)/d),w=(b,D)=>c.clone().multiplyScalar(b).addScaledVector(h,D).addScaledVector(M,S);for(let b=A;b<=T;b++)l(w(b*d,R*d),w(b*d,k*d),b===0?g:f,1);for(let b=R;b<=k;b++)l(w(A*d,b*d),w(T*d,b*d),b===0?g:f,1)}this.set(a,o)}follow(e,t){if(!this.follows)return;let i=[e.x0,e.x1,e.y0,e.y1,e.stepX,e.stepY].join(",");if(i===this.shown)return;this.shown=i;let{right:r,up:s}=ms(t),a=[],o=[],l=(c,h,u,d,f,g)=>{let y=r.clone().multiplyScalar(c).addScaledVector(s,h),m=r.clone().multiplyScalar(u).addScaledVector(s,d);a.push(y.x,y.y,y.z,m.x,m.y,m.z),o.push(...f,g,...f,g)};if(this.kind==="axes"){let c=Nt(this.theme.foreground);e.y0<=0&&e.y1>=0&&l(e.x0,0,e.x1,0,c,.5),e.x0<=0&&e.x1>=0&&l(0,e.y0,0,e.y1,c,.5)}else{let c=Nt(this.theme.grid),h=Nt(kt(this.theme.grid,this.theme.foreground,.3));for(let u of tc(e.x0,e.x1,e.stepX))l(u,e.y0,u,e.y1,u===0?h:c,1);for(let u of tc(e.y0,e.y1,e.stepY))l(e.x0,u,e.x1,u,u===0?h:c,1)}this.set(a,o)}extend(){}dispose(){this.lines.geometry.dispose(),this.lines.material.dispose()}},bS=100,SS=150;function jp(n,e,t){return new Sn(n,e,{samples:t,depthBuffer:!1,minFilter:Bt,magFilter:Bt,generateMipmaps:!1})}function wS(){let n=new sn({glslVersion:ya,uniforms:{uUnderlay:{value:null}},vertexShader:"void main() { gl_Position = vec4(position.xy, 0.0, 1.0); }",fragmentShader:"uniform sampler2D uUnderlay; out vec4 color; void main() { color = texelFetch(uUnderlay, ivec2(gl_FragCoord.xy), 0); }",depthTest:!1,depthWrite:!1,blending:Un}),e=new Xt(new ar(2,2),n);e.frustumCulled=!1;let t=new ir;return t.add(e),{scene:t,camera:new Nn,material:n}}function MS(n,e){n.updateMatrixWorld();let t=n.matrixWorld.elements,i=n.projectionMatrix.elements,r=!1;for(let s=0;s<16;s++)e[s]!==t[s]&&(r=!0,e[s]=t[s]),e[16+s]!==i[s]&&(r=!0,e[16+s]=i[s]);return r}var xu=class{id;scene=new ir;staticScene=new ir;underlay=new mt(-1,-1,-1,-1);underlayDirty=!0;staticKey="";rebuiltAt=-1/0;coarse=!1;cameraSeen=new Float64Array(32);camera=new Nn;cameraSpec={kind:"plane",plane:"xy"};controls=null;element=null;labels=null;plan=null;error=null;draws=new Map;rect={x:0,y:0,w:1,h:1};content="";needsFit=!0;userMoved=!1;fitting=!1;halfHeight=1;box=null;view=null;constructor(e){this.id=e}},Zp=n=>JSON.stringify(n),gs=class{canvas;onChange=()=>{};gl;ctx;panels=new Map;lastState=null;size={w:0,h:0,ratio:0};background;cacheStatic;coarseDrags;refineTimer=null;blit;underlay=null;scratch=null;viewport=new mt;buffer=new ke;region=new ca;corner=new ke;constructor(e,t,i,r={}){this.canvas=e,Ke.enabled=!1,this.gl=new jl({canvas:e,antialias:!0,preserveDrawingBuffer:r.preserveDrawingBuffer??!1}),this.cacheStatic=r.cacheStatic??!0,this.coarseDrags=r.coarseDrags??!0,this.blit=wS(),e.addEventListener("webglcontextrestored",()=>{for(let a of this.panels.values())a.underlayDirty=!0}),this.gl.outputColorSpace=ci,this.gl.autoClear=!1;let s=r.theme??Cr(t);this.background=new Ze(...Nt(s.background)),this.ctx={scene:t,geometry:i,shared:new gu,theme:s,disc:lS()}}setTheme(e){this.ctx.theme=e,this.background.setRGB(...Nt(e.background)),this.lastState=null;for(let t of this.panels.values())t.underlayDirty=!0}panel(e){let t=this.panels.get(e);return t||(t=new xu(e),this.panels.set(e,t)),t}bind(e,t){let i=this.panel(e);i.element!==t&&(i.controls?.dispose(),i.controls=null,i.labels?.remove(),i.labels=null,i.element=t,t!==null&&(i.labels=document.createElement("div"),i.labels.className="labels",t.append(i.labels),this.makeControls(i)))}refit(e){let t=this.panels.get(e);t&&(t.needsFit=!0,t.userMoved=!1)}refitAll(){for(let e of this.panels.keys())this.refit(e)}makeControls(e){if(e.controls?.dispose(),e.controls=null,e.element===null)return;let t=new Kl(e.camera,e.element);t.enableDamping=!1,t.screenSpacePanning=!0,e.cameraSpec.kind==="plane"&&(t.enableRotate=!1,t.zoomToCursor=!0,t.mouseButtons={LEFT:wn.PAN,MIDDLE:wn.DOLLY,RIGHT:wn.PAN},t.touches={ONE:On.PAN,TWO:On.DOLLY_PAN}),t.addEventListener("change",()=>{e.fitting||(e.userMoved=!0,this.onChange())}),e.controls=t}setCamera(e,t){e.cameraSpec=t;let i=t.kind==="plane"||t.projection==="orthographic";e.camera=i?new Nn(-1,1,1,-1,-1,1):new Wt(35,1,.01,100),e.needsFit=!0,e.userMoved=!1,this.makeControls(e)}drawStatic(e){if(e.staticScene.children.length===0)return;if(!this.cacheStatic){this.gl.render(e.staticScene,e.camera);return}let t=this.gl.getDrawingBufferSize(this.buffer);if(this.underlay===null||this.underlay.width!==t.x||this.underlay.height!==t.y){this.underlay?.dispose(),this.underlay=jp(t.x,t.y,0),this.gl.initRenderTarget(this.underlay);for(let r of this.panels.values())r.underlayDirty=!0}let i=this.gl.getCurrentViewport(this.viewport);if(i.equals(e.underlay)||(e.underlay.copy(i),e.underlayDirty=!0),MS(e.camera,e.cameraSeen)&&(e.underlayDirty=!0),e.underlayDirty){e.underlayDirty=!1;let r=performance.now();e.coarse=this.coarseDrags&&r-e.rebuiltAt<bS,e.rebuiltAt=r,e.coarse?(this.drawCoarse(e,this.underlay,i),this.scheduleRefine()):this.drawFine(e,this.underlay,i)}this.blit.material.uniforms.uUnderlay.value=this.underlay.texture,this.gl.render(this.blit.scene,this.blit.camera)}drawCoarse(e,t,i){t.viewport.copy(i),t.scissor.copy(i),t.scissorTest=!0,this.gl.setRenderTarget(t),this.gl.clear(!0,!1,!1),this.gl.render(e.staticScene,e.camera),this.gl.setRenderTarget(null)}scheduleRefine(){this.refineTimer!==null&&clearTimeout(this.refineTimer),this.refineTimer=setTimeout(()=>{this.refineTimer=null;for(let e of this.panels.values())e.coarse&&(e.underlayDirty=!0,e.rebuiltAt=-1/0);this.onChange()},SS)}drawFine(e,t,i){let r=this.scratch;(r===null||r.width<i.z||r.height<i.w)&&(r?.dispose(),r=this.scratch=jp(Math.max(i.z,r?.width??0),Math.max(i.w,r?.height??0),4)),r.viewport.set(0,0,i.z,i.w),r.scissor.set(0,0,i.z,i.w),r.scissorTest=!0,this.gl.setRenderTarget(r),this.gl.clear(!0,!1,!1),this.gl.render(e.staticScene,e.camera),this.gl.setRenderTarget(null),this.region.min.set(0,0),this.region.max.set(i.z,i.w),this.gl.copyTextureToTexture(r.texture,t.texture,this.region,this.corner.set(i.x,i.y))}disposePanel(e){for(let t of e.draws.values())t.dispose();e.draws.clear(),e.controls?.dispose(),e.labels?.remove(),this.panels.delete(e.id)}replan(e,t){let i=this.ctx.scene,r;try{r=uS(i,this.ctx.geometry,t,e.id),e.error=null}catch(f){if(!(f instanceof tn))throw f;e.error=f.message,e.plan=null;for(let g of e.draws.values())g.group.visible=!1;return}let s=e.plan,a=r.view.camera??{kind:"plane",plane:"xy"};(s===null||s.viewId!==r.viewId||Zp(a)!==Zp(e.cameraSpec))&&this.setCamera(e,a);let o=dS(r);o!==e.content&&(e.content=o,e.needsFit=!0,e.userMoved=!1),e.plan=r;let l=new Set,c=JSON.stringify(this.ctx.theme);try{for(let f of r.layers){let g;if(f.kind==="track"){if(f.set===null)continue;let M=f.color===void 0?c:JSON.stringify(f.color);g=`track\0${r.viewId}\0${f.index}\0${f.set.id}\0${r.display}\0${f.channel??""}\0${M}`}else g=`${f.kind}\0${r.viewId}\0${f.index}\0${r.display}\0${c}`;l.add(f.index);let y=e.draws.get(f.index);if(y!==void 0&&y.key===g){y.group.visible=!0;continue}y!==void 0&&(y.group.removeFromParent(),y.dispose(),e.draws.delete(f.index));let m=f.kind==="track"?new fs(this.ctx,f,r.display,g):f.kind==="body"?new ps(this.ctx,f.layer,g):new Di(this.ctx,f.layer,e.cameraSpec,g);m.group.renderOrder=f.index;let p=0;for(let M of m.group.children)M.renderOrder=16*f.index+p++;e.draws.set(f.index,m),m instanceof Di&&e.box!==null&&m.layout(e.box,e.cameraSpec)}}catch(f){if(!(f instanceof tn))throw f;e.error=f.message,e.plan=null;for(let g of e.draws.values())g.group.visible=!1;return}for(let[f,g]of[...e.draws])l.has(f)||(g.group.removeFromParent(),g.dispose(),e.draws.delete(f));let h=[],u=!0;for(let f of r.layers){let g=e.draws.get(f.index);g!==void 0&&(u&&=g instanceof fs&&g.isStatic,(u?e.staticScene:e.scene).add(g.group),u&&h.push(g.key))}let d=h.join(`
3962
+ `);d!==e.staticKey&&(e.staticKey=d,e.underlayDirty=!0)}advance(e,t,i){let r=e.plan;if(r===null)return;let s=this.ctx.scene,a={scope:r.scope,frames:this.ctx.geometry.frames,clock:s.clock,channel:t.clock.channel,q:i,display:r.display};e.error=null;try{for(let o of r.layers){let l=e.draws.get(o.index);l instanceof fs&&o.kind==="track"?l.update(o,s,i)&&l.isStatic&&(e.underlayDirty=!0):l instanceof ps&&o.kind==="body"&&l.update(a,o.layer,r.driver)}}catch(o){if(!(o instanceof tn))throw o;e.error=o.message}}fit(e){let t=new $n,i=e.plan===null?null:fS(e.plan,this.ctx.geometry);if(i!==null)t.set(new N(i[0],i[1],i[2]),new N(i[3],i[4],i[5]));else for(let u of e.draws.values())u instanceof ps&&u.group.visible&&u.extend(t);t.isEmpty()&&t.set(new N(-1,-1,-1),new N(1,1,1));let r=t.getCenter(new N),s=t.getSize(new N),a=Math.max(s.length()/2,1e-9),o=e.cameraSpec,{up:l,normal:c}=ms(o),h=e.camera;if(e.fitting=!0,h instanceof Nn){e.halfHeight=pS(t,o,e.rect.w/Math.max(1,e.rect.h)).halfHeight;let u=4*a+1,d=10*(r.length()+u+a);h.near=-d,h.far=d,h.zoom=1,h.position.copy(r).addScaledVector(c,u)}else{let u=a/Math.sin(h.fov*Math.PI/360)*1.08;h.near=u/1e3,h.far=u*1e3+r.length(),h.position.copy(r).addScaledVector(c,u)}h.up.copy(l),h.lookAt(r),this.aspect(e),e.controls&&(e.controls.target.copy(r),e.controls.update());for(let u of e.draws.values())u instanceof Di&&u.layout(t,o);e.box=t,e.fitting=!1,e.needsFit=!1}aspect(e){let t=e.rect.w/Math.max(1,e.rect.h),i=e.camera;i instanceof Nn?(i.top=e.halfHeight,i.bottom=-e.halfHeight,i.left=-e.halfHeight*t,i.right=e.halfHeight*t):i.aspect=t,i.updateProjectionMatrix()}follow(e){let t=e.cameraSpec;if(e.view=t.kind==="plane"&&e.camera instanceof Nn?gS(e.camera,t,e.rect.w,e.rect.h):null,!(e.view===null||t.kind!=="plane"))for(let i of e.draws.values())i instanceof Di&&i.follow(e.view,t)}renderAt(e,t,i,r,s){let a=Math.max(1,Math.floor(i)),o=Math.max(1,Math.floor(r));(a!==this.size.w||o!==this.size.h||s!==this.size.ratio)&&(this.gl.setPixelRatio(s),this.gl.setSize(a,o,!1),this.size={w:a,h:o,ratio:s});let l=ds(e.layout,{x:0,y:0,w:a,h:o},ys);for(let u of[...this.panels.values()])Object.hasOwn(e.panels,u.id)||this.disposePanel(u);let c=e!==this.lastState;this.lastState=e;let h=new Map;this.gl.setScissorTest(!1),this.gl.setClearColor(this.background,1),this.gl.clear(),this.gl.setScissorTest(!0);for(let[u,d]of l.panels){let f=this.panel(u);(c||f.plan===null)&&this.replan(f,e);let y=d.w!==f.rect.w||d.h!==f.rect.h;if(f.rect=d,this.advance(f,e,t),f.needsFit||y&&!f.userMoved?this.fit(f):y&&this.aspect(f),this.follow(f),f.error!==null){h.set(u,f.error);continue}if(d.w<1||d.h<1)continue;for(let p of f.draws.values())p.resize?.(d.w,d.h);let m=o-d.y-d.h;this.gl.setViewport(d.x,m,d.w,d.h),this.gl.setScissor(d.x,m,d.w,d.h),this.drawStatic(f),this.gl.render(f.scene,f.camera),this.placeLabels(f)}return this.gl.setScissorTest(!1),h}labelItems(e){if(e.plan===null)return[];let t=[],i=this.ctx.scene.frames[e.plan.display],r=i?.axes??["x","y","z"],{normal:s}=ms(e.cameraSpec),a=(l,c,h,u)=>{let d=c.clone().project(e.camera),f=(d.x+1)/2*e.rect.w+h,g=(1-d.y)/2*e.rect.h,y=d.z>-1&&d.z<1&&f>=0&&f<=e.rect.w&&g>=0&&g<=e.rect.h;t.push({text:l,x:f,y:g,hidden:u||!y})},o=[...e.draws.values()].filter(l=>l instanceof Di);if(e.view!==null&&e.cameraSpec.kind==="plane"){let[l,c]=cS(e.cameraSpec),h=f=>r[f]&&i?.unit?`${r[f]} [${i.unit}]`:r[f]??"",u=o.some(f=>f.follows&&f.kind==="axes"),d=o.some(f=>f.ticks);for(let f of vS(e.view,d,u?[h(l),h(c)]:null))t.push({...f,hidden:!1})}for(let l of e.draws.values())l instanceof Di&&l.kind==="axes"&&!l.follows?l.tips.forEach((c,h)=>a(r[h]??"",c,4,e.cameraSpec.kind==="plane"&&Math.abs(c.clone().normalize().dot(s))>.99)):l instanceof ps&&l.label!==null&&l.at!==null&&l.group.visible&&a(l.label,l.at,l.size/2+3,!1);return t}labels(e){let t=this.panels.get(e);return t===void 0?[]:this.labelItems(t).filter(i=>!i.hidden).map(({hidden:i,...r})=>r)}colorbars(e){let t=this.panels.get(e),i=[];if(t===void 0)return i;for(let r of t.draws.values()){if(!(r instanceof fs)||!r.group.visible)continue;let s=r.colorbar();s!==null&&i.push(s)}return zp(i)}placeLabels(e){let t=e.labels;if(t===null)return;let i=this.labelItems(e);for(;t.children.length<i.length;)t.appendChild(document.createElement("span"));for(;t.children.length>i.length;)t.lastChild.remove();i.forEach((r,s)=>{let a=t.children[s];a.textContent!==r.text&&(a.textContent=r.text),a.hidden=r.hidden;let o=r.align==="center"?"-50%":r.align==="end"?"-100%":"0";a.style.transformOrigin="0 0",a.style.fontSize=r.kind==="title"?"13px":"",a.style.transform=`translate(${r.x.toFixed(1)}px, ${r.y.toFixed(1)}px)${r.rotate?" rotate(-90deg)":""} translate(${o}, -50%)`})}dispose(){for(let e of[...this.panels.values()])this.disposePanel(e);this.refineTimer!==null&&clearTimeout(this.refineTimer),this.blit.material.dispose(),this.underlay?.dispose(),this.scratch?.dispose(),this.ctx.disc.dispose(),this.gl.dispose(),this.gl.forceContextLoss()}};var vs={frames:2e3,seconds:90},nc=[24,30,60],nm=[1,2,3,4];function ic(n,e,t,i=1,r=0,s=to){let a=Math.round(t*s*e/i),o=l=>no(r,l,e,n,i,s);return{count:a,duration:a/e,index:l=>io(o(l),n),progress:l=>ro(o(l),n)}}function rc(n,e){return n>=1?n>vs.frames?`${n} frames is more than the ${vs.frames} an export may have: lower the frame rate or the loops, or raise the speed`:n/e>vs.seconds?`${(n/e).toFixed(1)} s is longer than the ${vs.seconds} s an export may last: lower the loops or raise the speed`:null:`the frame count of the export is ${n}, not a count of at least one`}function im(n,e,t=to){for(let i of[...nc].reverse())if(rc(ic(n,i,1,e,0,t).count,i)===null)return i;return null}function xa(n,e={w:1280,h:720},t=1,i=30){if(n==="720p")return{width:1280,height:720,pixelRatio:1};if(n==="1080p")return{width:1920,height:1080,pixelRatio:1.5};let r=l=>Math.max(2,2*Math.floor(l/2)),s=r(e.w),a=r(e.h),o={width:s,height:a,pixelRatio:1};for(let l=8*Math.min(2,Math.max(1,Math.round(t)));l>=1;l--){let c=l/8;if(o={width:r(s*c),height:r(a*c),pixelRatio:c},sm(o.width,o.height,i))break}return o}var ES=[[30,1620,40500],[31,3600,108e3],[32,5120,216e3],[40,8192,245760],[42,8704,522240],[50,22080,589824],[51,36864,983040],[52,36864,2073600]],rm=4096;function sm(n,e,t){return n%2===0&&e%2===0&&Math.max(n,e)<=rm&&am(n,e,t)!==null}function am(n,e,t,i="high"){let r=Math.ceil(n/16),s=Math.ceil(e/16),a=r*s,o=ES.find(([,c,h])=>a<=c&&a*t<=h&&Math.max(r,s)<=Math.sqrt(8*c));return o===void 0?null:`avc1.${{high:"6400",main:"4d40",baseline:"42e0"}[i]}${o[0].toString(16).padStart(2,"0")}`}function TS(n,e,t){return Math.round(Math.min(4e7,Math.max(1e6,.08*n*e*t)))}var bu=class{muxer;constructor(e,t,i){if(e%2!==0||t%2!==0)throw new Error(`an MP4 export needs even sides, not ${e} by ${t}`);this.muxer=new _d({target:new zc,video:{codec:"avc",width:e,height:t,frameRate:i},fastStart:"in-memory"})}add(e,t,i,r,s){let a=s?.decoderConfig;if(a!==void 0){if(!a.codec.startsWith("avc1."))throw new Error(`an MP4 export holds H.264 only, not ${a.codec}`);if(a.description===void 0)throw new Error('the H.264 encoder did not give an avcC record. Configure it with avc: { format: "avc" }')}this.muxer.addVideoChunkRaw(e,t?"key":"delta",i,r,s)}finish(){return this.muxer.finalize(),new Uint8Array(this.muxer.target.buffer)}};function Su(){return typeof VideoEncoder>"u"||typeof VideoFrame>"u"?"this browser does not have a WebCodecs video encoder":null}async function AS(n,e,t,i){if(!sm(n,e,t))throw new Error(`${n} by ${e} at ${t} fps is past H.264, which needs even sides, at most ${rm} pixels a side, and a frame size and rate within level 5.2`);for(let r of["high","main","baseline"]){let s={codec:am(n,e,t,r),width:n,height:e,bitrate:i,framerate:t,avc:{format:"avc"}};if((await VideoEncoder.isConfigSupported(s)).supported===!0)return s}throw new Error(`this browser does not have an H.264 encoder for ${n} by ${e} at ${t} fps, and an MP4 that QuickTime opens needs H.264`)}var wu='"Helvetica Neue", Arial, sans-serif';function om(n){return n.kind==="panel"?n.id:om(n.a)}var tm=18;function ki(n,e,t,i,r,s){n.lineJoin="round",n.lineWidth=3,n.strokeStyle=s,n.strokeText(e,t,i),n.fillStyle=r,n.fillText(e,t,i)}function CS(n,e,t,i,r,s,a=wu){n.font=`${e.kind==="title"?13:12}px ${a}`,n.textAlign=e.align==="center"?"center":e.align==="end"?"right":"left",e.rotate?(n.save(),n.translate(t,i),n.rotate(-Math.PI/2),ki(n,e.text,0,0,r,s),n.restore()):ki(n,e.text,t,i,r,s),n.textAlign="left"}function RS(n,e,t,i,r,s,a,o,l=wu){let c=t;n.font=`11px ${l}`;for(let h of[...e].reverse()){let u=rn(h.hi,3),d=rn(h.lo,3),f=Math.max(n.measureText(h.label).width,13+Math.max(n.measureText(u).width,n.measureText(d).width));c-=f,n.textBaseline="top",ki(n,h.label,c,i,s,o);let g=i+16,y=n.createLinearGradient(0,g+120,0,g);for(let[m,p]of h.stops)y.addColorStop(m,p);if(n.fillStyle=y,n.fillRect(c,g,8,120),n.strokeStyle=a,n.lineWidth=1,n.strokeRect(c+.5,g+.5,7,119),h.band!==null){let[m,p,M]=Nt(r).map(S=>Math.round(255*S));n.fillStyle=`rgba(${m}, ${p}, ${M}, 0.18)`,n.fillRect(c-3,g+120*(1-h.band[1]),14,120*(h.band[1]-h.band[0]))}if(ki(n,u,c+13,g,s,o),n.textBaseline="bottom",ki(n,d,c+13,g+120,s,o),h.marker!==null){let m=g+120*(1-h.marker);n.fillStyle=r,n.beginPath(),n.moveTo(c-1,m),n.lineTo(c-7,m-4),n.lineTo(c-7,m+4),n.closePath(),n.fill()}c-=12}}async function lm(n,e={}){let t=Su();if(t!==null)throw new Error(t);let{scene:i,geometry:r}=n,s=structuredClone(n.state),a=e.fps??30,o=typeof e.size=="object"?e.size:xa(e.size??"720p",n.stage,typeof window>"u"?1:window.devicePixelRatio,a),l=ic(i.clock.steps,a,e.loops??1,e.speed??1,e.start??0,kr(i.clock)),c=rc(l.count,a);if(c!==null)throw new Error(c);let{width:h,height:u,pixelRatio:d}=o,f=e.signal,g=()=>new DOMException("the export was canceled","AbortError");if(f?.aborted)throw g();let y=await AS(h,u,a,e.bitrate??TS(h,u,a));e.onConfig?.(y);let m=new bu(h,u,a),p=null,M=new VideoEncoder({output:(Ue,qe)=>{let $=new Uint8Array(Ue.byteLength);Ue.copyTo($);try{m.add($,Ue.type==="key",Ue.timestamp,Ue.duration??Math.round(1e6/a),qe)}catch(J){p??=J}},error:Ue=>p=Ue});M.configure(y);let S=n.theme??Cr(i),x=n.font??wu,A=kt(S.background,S.background,0),T=kt(S.foreground,S.foreground,0),R=kt(S.foreground,S.background,.4),k=kt(S.foreground,S.background,.8),w=kt(S.foreground,S.background,.9),b=(i.readouts??[]).filter(Ue=>Ue.place==="caption"),D=(i.readouts??[]).filter(Ue=>Ue.place==="panel"),V=h/d,W=u/d,Y=b.length>0?10+tm*b.length:0,j=Math.floor(V),X=Math.floor(W-Y),re=document.createElement("canvas"),H=new gs(re,i,r,{preserveDrawingBuffer:!0,coarseDrags:!1,theme:S}),oe=document.createElement("canvas");oe.width=h,oe.height=u;let ee=oe.getContext("2d",{alpha:!1}),Me=ds(s.layout,{x:0,y:0,w:j,h:X},ys),$e=om(s.layout),rt=(Ue,qe,$,J)=>{try{return Fd({scene:i,geometry:r,state:s,panel:Ue,frameIndex:$,progress:J},qe)}catch(me){return me.message}};try{for(let Ue=0;Ue<l.count;Ue++){if(f?.aborted)throw g();if(p!==null)throw p;let qe=l.index(Ue),$=l.progress(Ue),J=H.renderAt(s,$,j,X,d);ee.setTransform(1,0,0,1,0,0),ee.fillStyle=A,ee.fillRect(0,0,h,u),ee.drawImage(re,0,0),ee.setTransform(d,0,0,d,0,0),ee.fillStyle=w;for(let ve of Me.gutters)ee.fillRect(ve.rect.x,ve.rect.y,ve.rect.w,ve.rect.h);for(let[ve,ue]of Me.panels){ee.save(),ee.beginPath(),ee.rect(ue.x,ue.y,ue.w,ue.h),ee.clip(),ee.textBaseline="middle";for(let C of H.labels(ve))CS(ee,C,ue.x+C.x,ue.y+C.y,T,A,x);RS(ee,H.colorbars(ve),ue.x+ue.w-10,ue.y+10,T,R,k,A,x),ee.font=`13px ${x}`,ee.textBaseline="bottom",D.map(C=>rt(ve,C.parts,qe,$)).join(`
3963
+ `).split(`
3964
+ `).reverse().forEach((C,ht)=>ki(ee,C,ue.x+8,ue.y+ue.h-6-17*ht,T,A));let At=J.get(ve);At!==void 0&&(ee.textBaseline="top",ki(ee,At,ue.x+12,ue.y+12,"#e0a24a",A)),ee.restore()}ee.font=`13px ${x}`,ee.textBaseline="alphabetic",b.forEach((ve,ue)=>ki(ee,rt($e,ve.parts,qe,$),14,X+5+tm*(ue+1)-4,T,A));let me=new VideoFrame(oe,{timestamp:Math.round(Ue*1e6/a),duration:Math.round(1e6/a)});for(M.encode(me,{keyFrame:Ue%(2*a)===0}),me.close(),e.onProgress?.(Ue+1,l.count);M.encodeQueueSize>4;)await new Promise(ve=>setTimeout(ve,1));await new Promise(ve=>setTimeout(ve,0))}if(await M.flush(),p!==null)throw p}finally{M.state!=="closed"&&M.close(),H.dispose()}return new Blob([m.finish()],{type:"video/mp4"})}var cm="http://www.w3.org/2000/svg",hm=(n,e)=>`M${n-1} ${e}a1 1 0 1 0 2 0a1 1 0 1 0-2 0`,PS={house:{grid:24,fill:!1,d:["M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8","M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"]},chevronDown:{grid:24,fill:!1,d:["m6 9 6 6 6-6"]},grip:{grid:24,fill:!1,d:[[5,12,19].map(n=>hm(9,n)).join(""),[5,12,19].map(n=>hm(15,n)).join("")]},x:{grid:24,fill:!1,d:["M18 6 6 18","m6 6 12 12"]},rotateCcw:{grid:24,fill:!1,d:["M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8","M3 3v5h5"]},plus:{grid:24,fill:!1,d:["M5 12h14","M12 5v14"]},download:{grid:24,fill:!1,d:["M12 15V3","M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4","m7 10 5 5 5-5"]},play:{grid:16,fill:!0,d:["M5 3.5v9l7.5-4.5z"]},pause:{grid:16,fill:!0,d:["M4.5 3H7v10H4.5zM9 3h2.5v10H9z"]}};function Zn(n,e){let t=PS[n],i=document.createElementNS(cm,"svg"),r={viewBox:`0 0 ${t.grid} ${t.grid}`,"aria-hidden":"true",focusable:"false",fill:t.fill?"currentColor":"none",stroke:t.fill?"none":"currentColor"};t.fill||Object.assign(r,{"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"});for(let[s,a]of Object.entries(r))i.setAttribute(s,a);i.setAttribute("class",e===void 0?`i i-${n}`:`i i-${n} ${e}`);for(let s of t.d){let a=document.createElementNS(cm,"path");a.setAttribute("d",s),i.appendChild(a)}return i}function sc(n){return n?n.kind==="panel"?[n.id]:[...sc(n.a),...sc(n.b)]:[]}function _a(n,e,t,i){if(n.kind==="panel"){if(n.id!==e)return n;if(i==="centre")return{kind:"panel",id:t};let r={kind:"panel",id:t},s=i==="left"||i==="right"?"row":"col",a=i==="left"||i==="top";return{kind:"split",dir:s,ratio:.5,a:a?r:n,b:a?n:r}}return{...n,a:_a(n.a,e,t,i),b:_a(n.b,e,t,i)}}function ba(n,e){if(n.kind==="panel")return n.id===e?null:n;let t=ba(n.a,e),i=ba(n.b,e);return t?i?{...n,a:t,b:i}:t:i}function ac(n,e=1){return n.kind==="panel"?[{id:n.id,area:e}]:[...ac(n.a,e*n.ratio),...ac(n.b,e*(1-n.ratio))]}function um(n,e,t,i){let r=n/Math.max(1,t),s=e/Math.max(1,i),a=.28,o=[{zone:"left",v:r},{zone:"right",v:1-r},{zone:"top",v:s},{zone:"bottom",v:1-s}].sort((l,c)=>l.v-c.v)[0];return o.v<a?o.zone:"centre"}function cc(){return Object.create(null)}function oc(n,e,t){let i=cc();for(let[r,s]of Object.entries(n??{}))r!==e&&s!==void 0&&(i[r]=s);return t!==void 0&&(i[e]=t),i}var IS=(n,e)=>(n%e+e)%e,lc=class{snap;index=0;play=!1;steps;listeners=new Set;constructor(e,t){this.snap=e,this.steps=t}get state(){return this.snap}get frame(){return this.index}get playing(){return this.play}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(e){for(let t of[...this.listeners])t(e)}set(e){e!==this.snap&&(this.snap=e,this.emit("state"))}update(e){this.set(e(this.snap))}setFrame(e){if(!Number.isInteger(e))return;let t=IS(e,this.steps);t!==this.index&&(this.index=t,this.emit("frame"))}setPlaying(e){e!==this.play&&(this.play=e,this.emit("playing"))}};function Ni(n,e,t,i,r){let s=it(n,t);if(s===void 0||!Ra(s,i))return e;if(s.scope==="panel"){if(r===void 0||!Object.hasOwn(e.panels,r))return e;let a=e.panels[r];return a.variables!==void 0&&Object.hasOwn(a.variables,t)&&a.variables[t]===i?e:Mu(e,r,{...a,variables:oc(a.variables,t,i)})}return e.variables!==void 0&&Object.hasOwn(e.variables,t)&&e.variables[t]===i?e:{...e,variables:oc(e.variables,t,i)}}function fm(n,e){return n.clock.channel===e?n:{...n,clock:{channel:e}}}function Mu(n,e,t){return{...n,panels:oc(n.panels,e,t)}}function Sa(n,e){return{...n,layout:e}}function pm(n,e){if(!Object.hasOwn(n.panels,e)||Object.keys(n.panels).length<2)return n;let t=ba(n.layout,e);return t===null?n:{...n,panels:oc(n.panels,e,void 0),layout:t}}function LS(n){for(let e=Object.keys(n.panels).length+1;;e++){let t=`p${e}`;if(!Object.hasOwn(n.panels,t))return t}}function Eu(n,e,t){return n.kind==="panel"?n.id===e?{kind:"panel",id:t}:n.id===t?{kind:"panel",id:e}:n:{...n,a:Eu(n.a,e,t),b:Eu(n.b,e,t)}}function hc(n,e,t,i,r,s=1/0){if(!Object.hasOwn(e.panels,t))return e;let a=e.panels[t];if(r.kind==="panel"){if(r.id===t||!Object.hasOwn(e.panels,r.id))return e;if(i==="centre")return Sa(e,Eu(e.layout,r.id,t));let h=ba(e.layout,r.id);return h===null?e:Sa(e,_a(h,t,r.id,i))}if(i==="centre")return r.kind==="view"?Object.hasOwn(n.views,r.view)?Mu(e,t,{...a,view:r.view}):e:Ni(n,e,r.variable,r.value,t);if(Object.keys(e.panels).length>=s)return e;let o=LS(e),l={view:a.view,variables:Object.assign(cc(),a.variables)};if(r.kind==="view"){if(!Object.hasOwn(n.views,r.view))return e;l.view=r.view}let c=Sa(Mu(e,o,l),_a(e.layout,t,o,i));return r.kind==="value"?Ni(n,c,r.variable,r.value,o):c}function Au(n,e,t,i,r){if(Object.keys(e.panels).length>=i)return e;let s=ac(e.layout).reduce((a,o)=>o.area>a.area?o:a);return hc(n,e,s.id,r(s.id)?"bottom":"right",t,i)}function mm(n,e,t){let i=Object.keys(n.panels).length>=t,r=sc(n.layout),s=r.map(e),a=[{label:"Add panel",placement:{kind:"add"},disabled:i,group:!1}];return r.forEach((o,l)=>{let h=s.filter(u=>u===s[l]).length>1?`${s[l]} (${s.slice(0,l+1).filter(u=>u===s[l]).length})`:s[l];a.push({label:`Split ${h} right`,placement:{kind:"drop",target:o,zone:"right"},disabled:i,group:!0},{label:`Split ${h} below`,placement:{kind:"drop",target:o,zone:"bottom"},disabled:i,group:!1},{label:`Replace ${h}`,placement:{kind:"drop",target:o,zone:"centre"},disabled:!1,group:!1})}),a}function gm(n,e,t,i,r,s){return t.kind==="add"?Au(n,e,i,r,s):hc(n,e,t.target,t.zone,i,r)}function DS(n){let e=new TextEncoder().encode(n),t=2166136261;for(let i of e)t^=i,t=Math.imul(t,16777619)>>>0;return t.toString(16).padStart(8,"0")}function uc(n){return`tycho:state:${DS(n)}:${n.length}`}var xs=n=>n!==null&&typeof n=="object"&&!Array.isArray(n);function dm(n,e,t){let i=cc();if(!xs(e))return i;for(let[r,s]of Object.entries(e)){let a=it(n,r);a===void 0||a.scope==="panel"!=(t==="panel")||!Ra(a,s)||(i[r]=s)}return i}function Tu(n,e,t){if(!xs(n))return;if(n.kind==="panel")return typeof n.id!="string"?void 0:!e(n.id)||t.has(n.id)?null:(t.add(n.id),{kind:"panel",id:n.id});if(n.kind!=="split"||n.dir!=="row"&&n.dir!=="col")return;let i=Tu(n.a,e,t),r=Tu(n.b,e,t);if(i===void 0||r===void 0)return;if(i===null)return r;if(r===null)return i;let s=n.ratio,a=typeof s=="number"&&s>0&&s<1?s:.5;return{kind:"split",dir:n.dir,ratio:a,a:i,b:r}}function ym(n,e){let t=()=>structuredClone(n.initial);if(!xs(e)||!xs(e.clock)||!xs(e.panels))return t();let i=e.clock.channel;if(typeof i!="string"||!n.clock.channels.includes(i))return t();let r=cc();for(let[c,h]of Object.entries(e.panels))!Aa.test(c)||!xs(h)||typeof h.view!="string"||!Object.hasOwn(n.views,h.view)||(r[c]={view:h.view,variables:dm(n,h.variables,"panel")});let s=Tu(e.layout,c=>Object.hasOwn(r,c),new Set);if(s==null)return t();let a=new Set,o=c=>c.kind==="panel"?void a.add(c.id):(o(c.a),o(c.b));o(s);for(let c of Object.keys(r))a.has(c)||delete r[c];if(Object.keys(r).length===0)return t();let l={variables:dm(n,e.variables,"scene"),clock:{channel:i},panels:r,layout:s};try{Mr(n,l)}catch{return t()}return l}var dc=8,kS=[.25,.5,1,2,4],NS=`
3965
+ :host { display: block; position: relative; background: var(--bg); color: var(--fg);
3966
+ font-family: inherit; font-size: 13px; font-style: normal; font-weight: 400; line-height: 1.4; letter-spacing: normal;
3967
+ text-align: left; text-transform: none; overflow: hidden; min-height: 240px; }
3835
3968
  * { box-sizing: border-box; }
3836
3969
  [hidden] { display: none !important; }
3837
- .root { position: absolute; inset: 0; display: grid; grid-template-rows: auto auto 1fr auto; }
3970
+ :focus { outline: none; }
3971
+ :focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
3972
+ button, select, input { font: inherit; color: inherit; margin: 0; }
3973
+ .root { position: absolute; inset: 0; display: grid; grid-template-rows: auto 1fr auto auto; }
3838
3974
  .root.kiosk { grid-template-rows: 1fr; }
3839
- .root.kiosk header, .root.kiosk .controls, .root.kiosk footer, .root.kiosk .phead { display: none; }
3840
- header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; padding: 10px 14px 4px; }
3975
+ .root.kiosk header, .root.kiosk .stats, .root.kiosk footer, .root.kiosk .phead { display: none; }
3976
+ .root.dragging, .root.dragging * { cursor: grabbing !important; }
3977
+
3978
+ header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; padding: 10px 14px 8px; }
3841
3979
  header h1 { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: 0.01em; }
3842
- header .caption { color: #9a9a9a; font-variant-numeric: tabular-nums; }
3843
- .controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 6px 14px 8px; }
3844
- .seg { display: inline-flex; border: 1px solid #333; border-radius: 6px; overflow: hidden; }
3845
- .seg button { background: #0d0d0d; color: #bbb; border: 0; padding: 5px 11px; cursor: pointer; font: inherit; }
3846
- .seg button + button { border-left: 1px solid #333; }
3847
- .seg button[aria-pressed="true"] { background: #2b2b2b; color: #fff; }
3848
- .seg.mini button { padding: 1px 7px; font-size: 11px; }
3849
- .seg button:hover { color: #fff; }
3850
- label.field { display: inline-flex; align-items: center; gap: 8px; }
3851
- label.field span.k { color: #9a9a9a; }
3852
- input[type=range] { accent-color: #E69F00; width: 220px; }
3853
- input[type=range].scrub { flex: 1; min-width: 160px; width: auto; }
3854
- .chips { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
3855
- .chips .k { color: #9a9a9a; margin-right: 2px; }
3856
- .chip { display: inline-flex; align-items: center; gap: 6px; background: #0d0d0d; color: #ccc; border: 1px solid #333;
3857
- border-radius: 6px; padding: 4px 10px 4px 8px; cursor: grab; user-select: none; touch-action: none; }
3858
- .chip:hover { color: #fff; border-color: #666; }
3859
- .chip .grip { color: #555; font-size: 11px; letter-spacing: -2px; }
3860
- .chip .n { min-width: 16px; text-align: center; font-size: 11px; color: #ffd9a8; background: #3a2a14; border-radius: 8px; padding: 0 5px; }
3861
- .chip .n:empty { display: none; }
3862
- .stage { position: relative; min-height: 120px; background: #141414; display: flex; }
3863
- .stage > .split, .stage > .panel { flex: 1 1 0; }
3864
- .split { display: flex; min-width: 0; min-height: 0; }
3865
- .split.row { flex-direction: row; }
3866
- .split.col { flex-direction: column; }
3867
- .gutter { flex: 0 0 6px; background: #141414; touch-action: none; }
3868
- .split.row > .gutter { cursor: col-resize; }
3869
- .split.col > .gutter { cursor: row-resize; }
3870
- .gutter:hover, .gutter.active { background: #3a2a14; }
3871
- .panel { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #000; }
3872
- .phead { display: flex; align-items: center; gap: 8px; padding: 3px 8px; background: #0a0a0a; border-bottom: 1px solid #1a1a1a;
3873
- cursor: grab; user-select: none; touch-action: none; font-size: 12px; white-space: nowrap; min-width: 0; }
3874
- .phead .t { font-weight: 600; color: #ddd; flex: 0 1 auto; min-width: 3em; overflow: hidden; text-overflow: ellipsis; }
3875
- .phead .m { color: #8a8a8a; font-variant-numeric: tabular-nums; flex: 0 10 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
3980
+ .vars { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
3981
+ .vars:empty { display: none; }
3982
+ .add { display: flex; align-items: center; min-width: 0; }
3983
+ .chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
3984
+ .k { color: var(--dim); font-size: 12px; }
3985
+ .chips > .k { margin-right: 2px; }
3986
+ .field { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
3987
+ .field output { font-size: 12px; font-variant-numeric: lining-nums tabular-nums; min-width: 7ch; color: var(--fg); }
3988
+
3989
+ .seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--surface); }
3990
+ .seg button { background: none; color: var(--dim); border: 0; padding: 4px 10px; cursor: pointer; white-space: nowrap; }
3991
+ .seg button + button { border-left: 1px solid var(--line); }
3992
+ .seg button:hover { background: var(--raised); color: var(--fg); }
3993
+ .seg button[aria-pressed="true"] { background: var(--accent-tint); color: var(--fg); box-shadow: inset 0 -2px var(--accent); }
3994
+ .seg button:focus-visible { outline-offset: -2px; }
3995
+ .mini .seg button { padding: 1px 7px; font-size: 11px; }
3996
+ .icon { width: 28px; height: 28px; flex: none; display: inline-grid; place-items: center; padding: 0; border: 0; border-radius: 6px;
3997
+ background: none; color: var(--dim); cursor: pointer; }
3998
+ .icon:hover { background: var(--raised); color: var(--fg); }
3999
+ .icon svg { width: 16px; height: 16px; }
4000
+ .icon.play { color: var(--fg); }
4001
+ .icon.play.on { color: var(--accent); }
4002
+ .btn { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); color: var(--fg); border: 1px solid var(--line);
4003
+ border-radius: 6px; padding: 4px 10px; cursor: pointer; }
4004
+ .btn:hover { background: var(--raised); }
4005
+ .btn svg { width: 14px; height: 14px; }
4006
+ .btn.primary { background: var(--accent); border-color: var(--accent); color: #000; }
4007
+ .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
4008
+ .btn.primary:active { background: var(--accent-press); border-color: var(--accent-press); }
4009
+ .btn:disabled { opacity: 0.45; cursor: default; }
4010
+ .btn[aria-expanded="true"] .chev { transform: rotate(180deg); color: var(--accent-2); }
4011
+ select { background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; cursor: pointer; }
4012
+ select option { background: var(--raised); color: var(--fg); }
4013
+ input[type=checkbox] { accent-color: var(--accent); }
4014
+
4015
+ input[type=range] { -webkit-appearance: none; appearance: none; background: none; width: 200px; height: 18px; cursor: pointer; --p: 0%; }
4016
+ input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px;
4017
+ background: linear-gradient(to right, var(--accent) var(--p), var(--track) var(--p)); }
4018
+ input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 14px; height: 14px; margin-top: -5px;
4019
+ border: 0; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg); }
4020
+ input[type=range]:hover::-webkit-slider-thumb { background: var(--accent-hover); }
4021
+ input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--track); }
4022
+ input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
4023
+ input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg); }
4024
+ input[type=range]:disabled { opacity: 0.4; cursor: default; }
4025
+ .mini input[type=range] { width: 90px; }
4026
+
4027
+ .chip { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
4028
+ color: var(--fg); user-select: none; -webkit-user-select: none; white-space: nowrap; }
4029
+ .chip .body { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px 3px 4px; cursor: grab; touch-action: none; border-radius: 5px; }
4030
+ .chip .body:not(:last-child) { border-radius: 5px 0 0 5px; }
4031
+ .chip .body:hover, .chip .caret:hover { background: var(--raised); }
4032
+ .chip .body:focus-visible { outline-offset: -2px; }
4033
+ .chip .grip { width: 14px; height: 14px; flex: none; color: var(--dim); }
4034
+ .chip .caret { position: relative; display: inline-grid; place-items: center; min-width: 24px; padding: 0 4px; border: 0;
4035
+ border-left: 1px solid var(--line); border-radius: 0 5px 5px 0; background: none; color: var(--dim); cursor: pointer; }
4036
+ .chip .caret svg { width: 14px; height: 14px; transition: transform 0.15s; }
4037
+ .chip .caret[aria-expanded="true"] { color: var(--accent-2); }
4038
+ .chip .caret[aria-expanded="true"] svg { transform: rotate(180deg); }
4039
+ .chip .caret select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
4040
+ .chip .caret:has(select:focus-visible) { outline: 2px solid var(--accent-2); outline-offset: 2px; color: var(--accent-2); }
4041
+ .chip.source { opacity: 0.4; }
4042
+ .ghost { position: fixed; left: 0; top: 0; z-index: 30; pointer-events: none; transform: translate(12px, 12px);
4043
+ border-color: var(--accent-2); background: var(--raised); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5); }
4044
+ .ghost .grip { visibility: visible !important; }
4045
+
4046
+ .menu { position: fixed; z-index: 40; min-width: 180px; max-height: 70vh; overflow: auto; display: flex; flex-direction: column; padding: 4px;
4047
+ background: var(--raised); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55); }
4048
+ .menu button { text-align: left; background: none; border: 0; border-radius: 4px; padding: 5px 10px; color: var(--fg); cursor: pointer; white-space: nowrap; }
4049
+ .menu button:hover:not(:disabled) { background: var(--accent-tint); }
4050
+ .menu button:focus-visible { outline-offset: -2px; }
4051
+ .menu button:disabled { color: var(--dim); cursor: default; }
4052
+ .menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
4053
+
4054
+ .stage { position: relative; min-height: 120px; overflow: hidden; background: var(--gutter); }
4055
+ .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
4056
+ .panels { position: absolute; inset: 0; }
4057
+ .panel { position: absolute; overflow: hidden; }
4058
+ .pbody { position: absolute; inset: 0; }
4059
+ .phead { position: absolute; top: 0; left: 0; right: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px;
4060
+ padding: 3px 3px 3px 6px; background: var(--head); cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none;
4061
+ font-size: 12px; white-space: nowrap; min-width: 0; }
4062
+ .phead .t { font-weight: 600; flex: 0 1 auto; min-width: 2em; overflow: hidden; text-overflow: ellipsis; }
4063
+ .phead .m { color: var(--dim); flex: 0 10 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
4064
+ .phead .pc { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; flex: 0 1 auto; min-width: 0; }
4065
+ .phead select { padding: 0 4px; font-size: 11px; }
3876
4066
  .phead .sp { flex: 1 0 0; }
3877
- .phead .seg, .phead .x { flex: 0 0 auto; }
3878
- .phead .x { background: none; border: 0; color: #777; cursor: pointer; font: inherit; font-size: 14px; padding: 0 4px; }
3879
- .phead .x:hover { color: #fff; }
3880
- .phead .home { display: inline-flex; align-items: center; }
3881
- .pbody { position: relative; flex: 1 1 0; min-height: 0; }
3882
- .drop { position: absolute; inset: 0; background: rgba(230,159,0,0.18); border: 2px solid rgba(230,159,0,0.7); pointer-events: none; z-index: 2; }
3883
- .drop.centre { background: rgba(86,180,233,0.16); border-color: rgba(86,180,233,0.7); }
3884
- .ghostchip { position: fixed; z-index: 10; pointer-events: none; background: #2b2b2b; color: #fff; border: 1px solid #666;
3885
- border-radius: 6px; padding: 4px 10px; font-size: 12px; transform: translate(12px, 12px); }
3886
- .hint { flex: 1; display: grid; place-items: center; color: #777; background: #000; }
3887
- .hint.over { color: #ffd9a8; background: #120d05; }
3888
- footer { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 8px 14px 10px; border-top: 1px solid #1a1a1a; }
3889
- footer button { background: #0d0d0d; color: #ddd; border: 1px solid #333; border-radius: 6px; padding: 5px 12px; cursor: pointer; font: inherit; min-width: 68px; }
3890
- footer button:hover { border-color: #666; color: #fff; }
3891
- .readout { color: #bbb; font-variant-numeric: tabular-nums; white-space: nowrap; }
3892
- .fps { color: #8a8a8a; font-variant-numeric: tabular-nums; min-width: 5.5em; text-align: right; }
3893
- .legend { display: inline-flex; gap: 10px; color: #9a9a9a; }
3894
- .legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
3895
- select { background: #0d0d0d; color: #ddd; border: 1px solid #333; border-radius: 6px; padding: 4px 6px; font: inherit; }
3896
- .check { display: inline-flex; align-items: center; gap: 5px; color: #bbb; cursor: pointer; }
3897
- .check input { accent-color: #E69F00; }
3898
- .status { position: absolute; inset: 0; display: grid; place-items: center; color: #888; }
3899
- .warn { color: #e0a24a; }
3900
- `;function ll(i,t,e="seg"){let n=document.createElement("div");n.className=e;let s=new Map;for(let r of i){let a=document.createElement("button");a.type="button",a.textContent=r.label,a.setAttribute("aria-pressed","false"),a.addEventListener("pointerdown",o=>o.stopPropagation()),a.addEventListener("click",()=>t(r.id)),s.set(r.id,a),n.appendChild(a)}return{el:n,set(r){for(let[a,o]of s)o.setAttribute("aria-pressed",String(a===r))}}}function ph(i,t,e){let n=document.createElement("select");for(let s of i){let r=document.createElement("option");r.value=s.id,r.textContent=s.label,s.id===t&&(r.selected=!0),n.appendChild(r)}return n.addEventListener("change",()=>e(n.value)),n}function Ds(i){return hn.find(t=>t.id===i)?.label??i}var Us=class extends HTMLElement{constructor(){super(...arguments);this.container=null;this.families=[];this.groups=[];this.group="";this.e=0;this.eStep=.005;this.eMax=1;this.playing=!1;this.speed=1;this.spacing="anomaly";this.ghostMode="family";this.progress=0;this.raf=0;this.showGhost=!0;this.threeD=!1;this.fpsEma=0;this.lastTick=0;this.kiosk=!1;this.tree=null;this.panels=new Map;this.nextId=1;this.tracksCache=new Map;this.chips=new Map}connectedCallback(){this.kiosk=this.hasAttribute("kiosk");let e=this.attachShadow({mode:"open"}),n=document.createElement("style");n.textContent=bg,e.appendChild(n),this.root=document.createElement("div"),this.root.className=this.kiosk?"root kiosk":"root",e.appendChild(this.root);let s=document.createElement("header");this.titleEl=document.createElement("h1"),this.titleEl.textContent=this.getAttribute("title")??"",this.captionEl=document.createElement("span"),this.captionEl.className="caption",s.append(this.titleEl,this.captionEl);let r=document.createElement("div");r.className="controls",this.groupSeg=ll([],()=>{});let a=document.createElement("label");a.className="field";let o=document.createElement("span");o.className="k",o.textContent="e",this.slider=document.createElement("input"),this.slider.type="range",this.slider.min="0",this.slider.addEventListener("input",()=>this.setE(Number(this.slider.value))),this.sliderOut=document.createElement("span"),a.append(o,this.slider,this.sliderOut);let c=document.createElement("div");c.className="chips";let l=document.createElement("span");l.className="k",l.textContent="frames",c.appendChild(l);for(let T of hn){let M=document.createElement("span");M.className="chip",M.title="drag onto a panel to split it there or replace it; click to add";let v=document.createElement("span");v.className="grip",v.textContent="\u2807";let R=document.createElement("span");R.className="n",M.append(v,document.createTextNode(T.label),R),M.addEventListener("pointerdown",w=>this.startDrag(w,{kind:"frame",frame:T.id},M)),this.chips.set(T.id,M),c.appendChild(M)}r.append(this.groupSeg.el,a,c),this.stage=document.createElement("div"),this.stage.className="stage",this.statusEl=document.createElement("div"),this.statusEl.className="status",this.statusEl.textContent="loading\u2026",this.hint=document.createElement("div"),this.hint.className="hint",this.hint.textContent="drag a frame here",this.hint.hidden=!0,this.stage.append(this.statusEl,this.hint);let h=document.createElement("footer");this.playBtn=document.createElement("button"),this.playBtn.type="button",this.playBtn.textContent="play",this.playBtn.addEventListener("click",()=>this.togglePlay()),this.scrub=document.createElement("input"),this.scrub.type="range",this.scrub.className="scrub",this.scrub.min="0",this.scrub.max="1000",this.scrub.step="1",this.scrub.addEventListener("input",()=>{this.pause(),this.progress=Number(this.scrub.value)/1e3,this.drawAll()});let f=ph([.25,.5,1,2,4].map(T=>({id:String(T),label:`${T}\xD7`})),"1",T=>this.speed=Number(T)),u=ph([{id:"anomaly",label:"uniform in f"},{id:"time",label:"uniform in \u03C4"},{id:"arclength",label:"uniform in arclength"}],this.spacing,T=>{this.spacing=T,this.drawAll()}),p=this.checkbox("full orbit",!0,T=>{this.showGhost=T;for(let M of this.panels.values())M.viewer.showGhost=T;this.drawAll()}),g=this.checkbox("3D orbit camera",!1,T=>{this.threeD=T;for(let M of this.panels.values())M.viewer.setThreeD(T)}),_=document.createElement("button");_.type="button",_.textContent="reset layout",_.addEventListener("click",()=>{this.forget(),this.applyDefaultLayout()}),this.readout=document.createElement("span"),this.readout.className="readout",this.fpsEl=document.createElement("span"),this.fpsEl.className="fps",this.fpsEl.textContent="\u2014 fps";let m=document.createElement("span");m.className="legend";for(let[T,M]of[["#F0E442","spacecraft"],["#56B4E9","m\u2081"],["#A8A8A8","m\u2082"]]){let v=document.createElement("span"),R=document.createElement("i");R.style.background=T,v.append(R,document.createTextNode(M)),m.appendChild(v)}h.append(this.playBtn,this.scrub,f,u,p,g,_,m,this.readout,this.fpsEl),this.root.append(s,r,this.stage,h),this.tabIndex=0,this.addEventListener("keydown",T=>this.onKey(T));let d=this.getAttribute("data");if(!d){this.statusEl.textContent="no data attribute";return}Os(d).then(T=>{this.container=T,this.statusEl.remove(),this.populate()}).catch(T=>{this.statusEl.textContent=`failed to load data: ${T.message}`})}disconnectedCallback(){this.pause();for(let e of this.panels.values())e.viewer.dispose();this.panels.clear()}checkbox(e,n,s){let r=document.createElement("label");r.className="check";let a=document.createElement("input");return a.type="checkbox",a.checked=n,a.addEventListener("change",()=>s(a.checked)),r.append(a,document.createTextNode(e)),r}populate(){let e=this.container;this.families=e.datasets.filter(o=>o.kind==="periodic_orbit_family"),this.groups=[...new Set(this.families.map(o=>o.group))];let n=ll(this.groups.map(o=>({id:o,label:o})),o=>this.setGroup(o));this.groupSeg.el.replaceWith(n.el),this.groupSeg=n;let s=this.kiosk?null:this.recall(),r=this.parseLayout(this.getAttribute("layout")),a=s??r;a&&this.groups.includes(a.group)?(this.group=a.group,this.groupSeg.set(this.group),this.rangeForGroup(),this.e=Math.min(a.e,this.eMax),this.restore(a)):(this.groups.length&&(this.group=this.groups[0],this.groupSeg.set(this.group),this.rangeForGroup()),this.applyDefaultLayout()),this.kiosk&&this.play()}branchDataset(e){return this.families.find(n=>n.group===this.group&&n.branch===e)}tracksFor(e){let n=this.tracksCache.get(e.id);if(n)return n;let s=this.container,r=s.viewInfo(e.positions.view);return n={count:r.shape[0],samples:r.shape[1],positions:s.f32(e.positions.view),anomalies:s.f32(e.independent_variable.view),params:s.f64(e.parameter.view),mu:e.system.mu,f0:e.system.f0},this.tracksCache.set(e.id,n),n}rangeForGroup(){let e=0,n=1/0;for(let s of this.families.filter(r=>r.group===this.group)){let r=this.tracksFor(s).params;e=Math.max(e,r[r.length-1]);for(let a=1;a<r.length;a++)n=Math.min(n,Math.abs(r[a]-r[a-1]))}this.eMax=e,this.eStep=Number.isFinite(n)&&n>0?n:.005,this.slider.max=String(this.eMax),this.slider.step=String(this.eStep),this.e=Math.min(this.e,this.eMax)}setGroup(e){this.group=e,this.groupSeg.set(e),this.rangeForGroup();for(let n of this.panels.values())this.loadPanel(n,!0);this.drawAll(),this.updateCaption(),this.remember()}setE(e){this.e=Math.max(0,Math.min(this.eMax,e));for(let n of this.panels.values())this.loadPanel(n,!1);this.drawAll(),this.updateCaption(),this.remember()}loadPanel(e,n){let s=this.branchDataset(e.branch);if(!s){e.tracks=null,e.fRel=new Float32Array(0),e.meta.textContent="no data";return}let r=this.tracksFor(s),a=0,o=1/0;for(let u=0;u<r.count;u++){let p=Math.abs(r.params[u]-this.e);p<o&&(o=p,a=u)}let c=r.samples,l=e.tracks!==r;e.tracks=r,e.member=a;let h=r.positions.subarray(a*c*2,(a+1)*c*2);e.fRel=s.independent_variable.per_member?r.anomalies.subarray(a*c,(a+1)*c):r.anomalies.subarray(0,c),e.sys={mu:r.mu,e:r.params[a],f0:r.f0},e.period=e.fRel[c-1],e.tauPeriod=Yi(e.sys.e,e.sys.f0,e.sys.f0+e.period),l&&e.viewer.setFamily(r,this.ghostMode),e.viewer.setTrajectory(h,e.fRel,e.sys,n);let f="";if(s.closure_error){let u=this.container.f32(s.closure_error.view)[a];u>1e-4&&(f=` \xB7 closure ${u.toExponential(1)}`)}e.meta.textContent=`e = ${e.sys.e.toFixed(4)}${f}`,e.meta.classList.toggle("warn",f!=="")}createPanel(e,n,s){let r=s??`p${this.nextId++}`,a=Number(r.slice(1));Number.isFinite(a)&&a>=this.nextId&&(this.nextId=a+1);let o=document.createElement("div");o.className="panel",o.dataset.id=r;let c=document.createElement("div");c.className="phead";let l=document.createElement("span");l.className="t",l.textContent=Ds(e);let h=document.createElement("span");h.className="m";let f=document.createElement("span");f.className="sp";let u=ll([{id:"periapsis",label:"peri"},{id:"apoapsis",label:"apo"}],M=>{let v=this.panels.get(r);v&&(v.branch=M,v.branchSeg.set(M),this.loadPanel(v,!1),this.drawAll(),this.updateCaption(),this.remember())},"seg mini");u.set(n);let p=document.createElement("button");p.className="x home",p.type="button",p.title="reset the view",p.innerHTML='<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M8 2.2 1.8 7.6h1.7V13.5h3.3V9.7h2.4v3.8h3.3V7.6h1.7z" fill="currentColor"/></svg>',p.addEventListener("pointerdown",M=>M.stopPropagation()),p.addEventListener("click",()=>this.panels.get(r)?.viewer.fit());let g=document.createElement("button");g.className="x",g.type="button",g.title="close panel",g.textContent="\xD7",g.addEventListener("pointerdown",M=>M.stopPropagation()),g.addEventListener("click",()=>this.closePanel(r)),c.append(l,h,f,u.el,p,g),c.addEventListener("pointerdown",M=>this.startDrag(M,{kind:"panel",id:r},c));let _=document.createElement("div");_.className="pbody";let m=document.createElement("div");m.className="drop",m.hidden=!0,o.append(c,_);let d=new Gi(_,e);_.appendChild(m),d.showGhost=this.showGhost,d.setThreeD(this.threeD);let T={id:r,frame:e,branch:n,host:o,body:_,title:l,meta:h,branchSeg:u,drop:m,viewer:d,tracks:null,member:0,sys:{mu:.5,e:0,f0:0},fRel:new Float32Array(0),period:0,tauPeriod:0};return this.panels.set(r,T),this.loadPanel(T,!0),T}destroyPanel(e){let n=this.panels.get(e);n&&(n.viewer.dispose(),n.host.remove(),this.panels.delete(e))}closePanel(e){this.tree&&(this.tree=ri(this.tree,e),this.destroyPanel(e),this.renderLayout(),this.remember())}addPanel(e,n){if(this.panels.size>=fh)return;let s=n??this.defaultBranch();if(this.tree){let r=Na(this.tree).sort((l,h)=>h.area-l.area)[0],o=this.panels.get(r.id).host.getBoundingClientRect(),c=this.createPanel(e,s);this.tree=Xi(this.tree,r.id,c.id,o.width>=o.height?"right":"bottom")}else{let r=this.createPanel(e,s);this.tree={kind:"panel",id:r.id}}this.renderLayout(),this.drawAll(),this.remember()}defaultBranch(){return[...this.panels.values()].pop()?.branch??Ls[0]}dropOn(e,n,s){if(this.tree){if(s.kind==="panel"){if(s.id===e)return;if(n==="centre"){let r=this.panels.get(s.id),a=this.panels.get(e);[r.frame,a.frame]=[a.frame,r.frame],[r.branch,a.branch]=[a.branch,r.branch];for(let o of[r,a])o.viewer.setFrame(o.frame),o.title.textContent=Ds(o.frame),o.branchSeg.set(o.branch),this.loadPanel(o,!0)}else this.tree=ri(this.tree,s.id)??this.tree,this.tree=Xi(this.tree,e,s.id,n)}else if(n==="centre"){let r=this.panels.get(e);r.frame=s.frame,r.viewer.setFrame(r.frame),r.title.textContent=Ds(r.frame),this.loadPanel(r,!0)}else{if(this.panels.size>=fh)return;let r=this.createPanel(s.frame,this.panels.get(e).branch);this.tree=Xi(this.tree,e,r.id,n)}this.renderLayout(),this.drawAll(),this.remember()}}renderLayout(){for(let n of[...this.stage.children])n!==this.hint&&n.remove();this.hint.hidden=!!this.tree,this.tree&&this.stage.appendChild(this.build(this.tree));for(let n of this.panels.values())n.viewer.resize();let e=new Map;for(let n of this.panels.values())e.set(n.frame,(e.get(n.frame)??0)+1);for(let[n,s]of this.chips)s.querySelector(".n").textContent=e.get(n)?String(e.get(n)):"";this.updateCaption()}build(e){if(e.kind==="panel"){let o=this.panels.get(e.id);if(!o)throw new Error(`layout references unknown panel ${e.id}`);return o.host.style.flex="",o.host}let n=document.createElement("div");n.className=`split ${e.dir}`;let s=this.build(e.a),r=this.build(e.b);s.style.flex=`${e.ratio} 1 0`,r.style.flex=`${1-e.ratio} 1 0`;let a=document.createElement("div");return a.className="gutter",a.addEventListener("pointerdown",o=>this.startResize(o,e,n,s,r,a)),n.append(s,a,r),n}startResize(e,n,s,r,a,o){if(n.kind!=="split")return;e.preventDefault(),o.classList.add("active"),o.setPointerCapture(e.pointerId);let c=n.ratio,l=f=>{let u=s.getBoundingClientRect();c=n.dir==="row"?(f.clientX-u.left)/Math.max(1,u.width):(f.clientY-u.top)/Math.max(1,u.height),c=Math.max(.1,Math.min(.9,c)),r.style.flex=`${c} 1 0`,a.style.flex=`${1-c} 1 0`},h=()=>{o.classList.remove("active"),o.removeEventListener("pointermove",l),o.removeEventListener("pointerup",h),o.removeEventListener("pointercancel",h),this.tree&&(this.tree=Ua(this.tree,n,c));for(let f of this.panels.values())f.viewer.resize();this.remember()};o.addEventListener("pointermove",l),o.addEventListener("pointerup",h),o.addEventListener("pointercancel",h)}startDrag(e,n,s){if(e.button!==0)return;e.preventDefault();let r=e.clientX,a=e.clientY,o=null,c=null,l=!1,h=this.shadowRoot;s.setPointerCapture(e.pointerId);let f=()=>{for(let g of this.panels.values())g.drop.hidden=!0;this.hint.classList.remove("over")},u=g=>{if(!o){if(Math.hypot(g.clientX-r,g.clientY-a)<4)return;o=document.createElement("div"),o.className="ghostchip",o.textContent=n.kind==="frame"?Ds(n.frame):Ds(this.panels.get(n.id).frame),h.appendChild(o)}o.style.left=`${g.clientX}px`,o.style.top=`${g.clientY}px`,f(),c=null,l=!1;let _=h.elementFromPoint(g.clientX,g.clientY);if(_&&(_===this.hint||this.hint.contains(_))){l=!0,this.hint.classList.add("over");return}let m=_?.closest(".panel");if(!m)return;let d=m.dataset.id;if(n.kind==="panel"&&n.id===d)return;let T=this.panels.get(d),M=T.body.getBoundingClientRect(),v=dh(g.clientX-M.left,g.clientY-M.top,M.width,M.height);c={id:d,zone:v};let R=T.drop;R.hidden=!1,R.classList.toggle("centre",v==="centre"),R.style.inset=v==="left"?"0 50% 0 0":v==="right"?"0 0 0 50%":v==="top"?"0 0 50% 0":v==="bottom"?"50% 0 0 0":"0"},p=()=>{s.removeEventListener("pointermove",u),s.removeEventListener("pointerup",p),s.removeEventListener("pointercancel",p),f();let g=!!o;if(o?.remove(),!g){n.kind==="frame"&&this.addPanel(n.frame);return}l&&n.kind==="frame"&&!this.tree?this.addPanel(n.frame):c&&this.dropOn(c.id,c.zone,n)};s.addEventListener("pointermove",u),s.addEventListener("pointerup",p),s.addEventListener("pointercancel",p)}applyDefaultLayout(){for(let n of[...this.panels.keys()])this.destroyPanel(n);this.tree=null;let e=(this.getAttribute("frames")??"rotating_pulsating").split(/[\s,]+/);for(let n of e)hn.some(s=>s.id===n)&&this.addPanel(n);this.renderLayout(),this.drawAll()}restore(e){for(let s of[...this.panels.keys()])this.destroyPanel(s);this.tree=null;let n=e.tree;for(let[s,r]of Object.entries(e.panels))if(!(!n||!uh(n,s))){if(!hn.some(a=>a.id===r.frame)){n=ri(n,s);continue}this.createPanel(r.frame,Ls.includes(r.branch)?r.branch:Ls[0],s)}for(let s of Wi(n))n&&!this.panels.has(s)&&(n=ri(n,s));if(this.tree=n,!this.tree){this.applyDefaultLayout();return}this.renderLayout(),this.drawAll()}snapshot(){let e={};for(let n of this.panels.values())e[n.id]={frame:n.frame,branch:n.branch};return{version:1,group:this.group,e:this.e,tree:this.tree,panels:e}}get layoutJSON(){return JSON.stringify(this.snapshot())}storageKey(){return`tycho:layout:${this.getAttribute("title")??""}`}remember(){if(!this.kiosk)try{localStorage.setItem(this.storageKey(),this.layoutJSON)}catch{}}forget(){try{localStorage.removeItem(this.storageKey())}catch{}}recall(){try{return this.parseLayout(localStorage.getItem(this.storageKey()))}catch{return null}}parseLayout(e){if(!e)return null;try{let n=JSON.parse(e);return n.version!==1||typeof n.group!="string"||typeof n.e!="number"||n.tree!==null&&!Fa(n.tree)||!n.panels||typeof n.panels!="object"?null:n}catch{return null}}currentF(e){let n=Math.max(0,Math.min(1,this.progress));switch(this.spacing){case"anomaly":return n*e.period;case"time":return zs(e.sys.e,e.sys.f0,n*e.tauPeriod)-e.sys.f0;case"arclength":{let s=e.fRel.length;if(s<2)return 0;let r=n*(s-1),a=Math.min(s-2,Math.floor(r));return e.fRel[a]+(e.fRel[a+1]-e.fRel[a])*(r-a)}}}firstPanel(){let e=Wi(this.tree);return e.length?this.panels.get(e[0]):void 0}drawAll(){for(let e of this.panels.values())e.fRel.length&&e.viewer.showAt(this.currentF(e));this.updateReadout()}updateCaption(){let e=[...new Set([...this.panels.values()].map(s=>s.branch))].join(" and "),n=this.branchDataset(Ls[0])?.system.mu??this.branchDataset(Ls[1])?.system.mu;this.captionEl.textContent=this.group?`${this.group}${e?`, ${e}`:""}, e \u2248 ${this.e.toFixed(3)}${n!==void 0?`, \u03BC = ${n}`:""}`:"",this.slider.value=String(this.e),this.sliderOut.textContent=this.e.toFixed(4)}updateReadout(){let e=this.firstPanel();if(!e||!e.fRel.length){this.readout.textContent="";return}let n=this.currentF(e),s=Yi(e.sys.e,e.sys.f0,e.sys.f0+n),r=Math.round(this.progress*Oa);this.readout.textContent=`f \u2212 f\u2080 = ${n.toFixed(2)} rad\u2003\u03C4 = ${s.toFixed(2)} TU\u2003frame ${r}/${Oa}`,this.scrub.value=String(Math.round(this.progress*1e3))}togglePlay(){this.playing?this.pause():this.play()}play(){if(this.playing)return;this.playing=!0,this.playBtn.textContent="pause",this.lastTick=0,this.fpsEma=0;let e=n=>{if(this.playing){if(this.lastTick){let s=1e3/Math.max(1,n-this.lastTick);this.fpsEma=this.fpsEma?this.fpsEma*.9+s*.1:s,this.fpsEl.textContent=`${this.fpsEma.toFixed(0)} fps`}this.lastTick=n,this.progress+=this.speed/(Oa*Mg),this.progress>=1&&(this.progress-=1),this.drawAll(),this.raf=requestAnimationFrame(e)}};this.raf=requestAnimationFrame(e)}pause(){this.playing=!1,this.playBtn.textContent="play",this.fpsEl.textContent="\u2014 fps",cancelAnimationFrame(this.raf)}onKey(e){let n=(e.shiftKey?10:1)/Oa;switch(e.key){case" ":e.preventDefault(),this.togglePlay();break;case"ArrowRight":e.preventDefault(),this.pause(),this.progress=(this.progress+n)%1,this.drawAll();break;case"ArrowLeft":e.preventDefault(),this.pause(),this.progress=(this.progress-n+1)%1,this.drawAll();break;case"ArrowUp":e.preventDefault(),this.setE(this.e+this.eStep*(e.shiftKey?10:1));break;case"ArrowDown":e.preventDefault(),this.setE(this.e-this.eStep*(e.shiftKey?10:1));break}}};function Ba(i="tycho-viewer"){customElements.get(i)||customElements.define(i,Us)}Ba();return wh(Sg);})();
4067
+ .phead .icon { width: 24px; height: 24px; }
4068
+ .phead .chip { min-width: 0; }
4069
+ .phead .chip .body { padding: 1px 6px 1px 2px; min-width: 0; }
4070
+ .phead .chip .lbl { overflow: hidden; text-overflow: ellipsis; }
4071
+ .phead .chip .grip { visibility: hidden; }
4072
+ .phead .chip:is(:hover, :focus-within) .grip { visibility: visible; }
4073
+ .labels, .preadout, .perror, .drop, .cbars { pointer-events: none; }
4074
+ .labels { position: absolute; inset: 0; z-index: 1; overflow: hidden; }
4075
+ .labels span { position: absolute; left: 0; top: 0; white-space: nowrap; color: var(--fg); font-size: 12px; text-shadow: 0 0 3px var(--bg), 0 0 3px var(--bg); }
4076
+ .cbars { position: absolute; right: 10px; top: 40px; z-index: 1; display: flex; gap: 12px; }
4077
+ .cbar { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; font-size: 11px; color: var(--dim); }
4078
+ .cbar-t { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
4079
+ .cbar-b { display: flex; gap: 5px; height: 120px; }
4080
+ .cbar-g { position: relative; width: 8px; border: 1px solid var(--line); }
4081
+ .cbar-g.live { width: 12px; pointer-events: auto; cursor: ns-resize; touch-action: none; }
4082
+ .cbar-g.live:hover { border-color: var(--dim); }
4083
+ .cbar-k { position: absolute; left: -3px; right: -3px; background: var(--fg); opacity: 0.18; }
4084
+ .cbar-g i { position: absolute; left: -9px; right: 0; bottom: 0; height: 0; }
4085
+ .cbar-g i::before { content: ""; position: absolute; left: 0; top: -4px; border: 4px solid transparent; border-left: 6px solid var(--highlight); border-right: 0; }
4086
+ .cbar-g.live i::after { content: ""; position: absolute; left: 9px; right: 0; top: -1px; height: 2px; background: var(--highlight); box-shadow: 0 0 0 1px var(--bg); }
4087
+ .cbar-n { display: flex; flex-direction: column; justify-content: space-between; font-variant-numeric: tabular-nums; }
4088
+ .preadout { position: absolute; left: 8px; bottom: 6px; z-index: 1; display: flex; flex-direction: column; gap: 6px;
4089
+ text-shadow: 0 0 3px var(--bg), 0 0 3px var(--bg); }
4090
+ .perror { position: absolute; inset: 34px 12px auto 12px; z-index: 1; color: var(--error); white-space: pre-wrap; }
4091
+ .drop { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; background: var(--accent-2-tint); border: 2px solid var(--accent-2); }
4092
+ .drop span { font-size: 11px; color: var(--fg); background: var(--raised); border-radius: 4px; padding: 1px 6px; }
4093
+ .gutter { position: absolute; z-index: 2; touch-action: none; background: var(--gutter); }
4094
+ .gutter.row { cursor: col-resize; }
4095
+ .gutter.col { cursor: row-resize; }
4096
+ .gutter:hover, .gutter.active { background: var(--accent-tint); }
4097
+
4098
+ .stats { display: flex; flex-direction: column; gap: 4px; padding: 8px 14px 0; }
4099
+ .stats:empty { display: none; }
4100
+ .readout dl { display: flex; flex-wrap: wrap; margin: 0; }
4101
+ .wide dl > div { padding: 0 16px; border-left: 1px solid var(--line); }
4102
+ .wide dl > div:first-child { border-left: 0; padding-left: 0; }
4103
+ .stack dl { flex-direction: column; gap: 2px; }
4104
+ .readout dt { font-size: 11px; color: var(--dim); }
4105
+ .readout dd { margin: 0; white-space: nowrap; }
4106
+ .readout b { display: inline-block; font-size: 15px; font-weight: 500; line-height: 1.25; font-variant-numeric: lining-nums tabular-nums; }
4107
+ .stack b { font-size: 13px; }
4108
+ .readout .u { color: var(--dim); font-size: 12px; margin-left: 0.35em; }
4109
+ .readout .line { white-space: pre-wrap; font-variant-numeric: tabular-nums; }
4110
+
4111
+ footer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 8px 14px 10px; }
4112
+ .cap { display: flex; align-items: center; gap: 4px; padding: 3px; min-height: 36px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
4113
+ .cap.playback { flex: 1 1 520px; flex-wrap: wrap; }
4114
+ .cap .scrub { flex: 1 1 160px; min-width: 100px; width: auto; margin: 0 6px; }
4115
+ .cap select { background: none; border-color: transparent; }
4116
+ .cap select:hover { background: var(--raised); }
4117
+ .frame, .fps { color: var(--dim); font-size: 12px; font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; text-align: right; }
4118
+ /* the rate reserves three digits as content, so that the dashes, 9 fps, and 120 fps take one width */
4119
+ .fps { box-sizing: content-box; min-width: 7ch; padding: 0 6px 0 4px; }
4120
+ .speed { font-variant-numeric: tabular-nums; }
4121
+ .why { color: var(--dim); }
4122
+ .disclose { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 0; border-radius: 6px;
4123
+ background: none; color: var(--fg); cursor: pointer; overflow: hidden; }
4124
+ .disclose:hover { background: var(--raised); }
4125
+ .disclose svg { width: 16px; height: 16px; }
4126
+ .disclose .chev { width: 14px; height: 14px; color: var(--dim); transition: transform 0.15s; }
4127
+ .disclose[aria-expanded="true"] { background: var(--accent-tint); box-shadow: inset 0 -2px var(--accent); }
4128
+ .disclose[aria-expanded="true"] .chev { transform: rotate(180deg); }
4129
+ .disclose:disabled { color: var(--dim); cursor: default; background: none; }
4130
+ .disclose .xprog { position: absolute; left: 0; top: 0; height: 2px; width: 0; background: var(--accent); }
4131
+ .exportbar { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 4px 4px 4px 8px;
4132
+ background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
4133
+ .exportbar .info { flex: 1 1 12em; color: var(--dim); font-variant-numeric: tabular-nums; }
4134
+ .exportbar progress { width: 160px; accent-color: var(--accent); }
4135
+ .status { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; color: var(--dim); white-space: pre-wrap; z-index: 5; }
4136
+ .status.error { color: var(--error); }
4137
+ `;function se(n,e,t){let i=document.createElement(n);return e!==void 0&&(i.className=e),t!==void 0&&(i.textContent=t),i}function Fn(n,e){n.textContent!==e&&(n.textContent=e)}var Jn=n=>n.stopPropagation();function _s(n,e,t,i="icon"){let r=se("button",i);return r.type="button",r.setAttribute("aria-label",e),r.title=t,r.appendChild(Zn(n)),r.addEventListener("pointerdown",Jn),r}function Cu(n,e){let t=se("div",e===void 0?"cap":`cap ${e}`);return t.setAttribute("role","group"),t.setAttribute("aria-label",n),t}function vm(n,e,t){let i=se("div","seg");i.setAttribute("role","group"),t!==void 0&&i.setAttribute("aria-label",t);let r=new Map;for(let s of n){let a=se("button",void 0,s.label);a.type="button",a.setAttribute("aria-pressed","false"),a.addEventListener("pointerdown",Jn),a.addEventListener("click",()=>e(s.id)),r.set(s.id,a),i.appendChild(a)}return{el:i,set(s){for(let[a,o]of r)o.setAttribute("aria-pressed",String(a===s))}}}function Ru(n,e){n.value=String(e);let t=Number(n.max)-Number(n.min);n.style.setProperty("--p",`${t>0?100*(Number(n.value)-Number(n.min))/t:0}%`)}function xm(n,e){let t=se("div","chip"),i=se("span","body"),r=se("span","lbl",n);i.append(Zn("grip","grip"),r),t.appendChild(i);let s=null,a=null;if(e==="menu")s=se("button","caret"),s.type="button",s.setAttribute("aria-haspopup","menu"),s.setAttribute("aria-expanded","false"),s.setAttribute("aria-label",`${n}: placement`),s.title="Add, split, or replace a panel",s.appendChild(Zn("chevronDown")),s.addEventListener("pointerdown",Jn),t.appendChild(s);else if(e==="select"){let o=se("span","caret");a=se("select"),o.append(Zn("chevronDown"),a),o.addEventListener("pointerdown",Jn),t.appendChild(o)}return{root:t,body:i,label:r,button:s,select:a}}function _m(n,e){let t=Bd(n),i=se("div",`readout ${e}`),r=se("div","line"),s=null,a=[];if(t!==null){s=se("dl");for(let o of t){let l=se("div"),c=se("dd"),h=se("b");o.width!==null&&(h.style.minWidth=`${o.width}ch`),c.appendChild(h),o.unit!==""&&c.appendChild(se("span","u",o.unit)),l.append(se("dt",void 0,o.label),c),s.appendChild(l),a.push(h)}i.appendChild(s),r.hidden=!0}return i.appendChild(r),{parts:n,tiles:t,root:i,list:s,values:a,line:r}}function bm(n,e){let t=Array.isArray(e);if(t&&n.tiles!==null&&n.list!==null&&e.length>0){n.list.hidden=!1,n.line.hidden=!0,n.tiles.forEach((i,r)=>Fn(n.values[r],e[i.part]??""));return}n.list!==null&&(n.list.hidden=!0),n.line.hidden=!1,Fn(n.line,t?e.join(""):e.error)}function OS(n,e){let t=n.kind==="panel";if(e==="centre")return t?"swap":"replace";let i={left:"left",right:"right",top:"above",bottom:"below"}[e];return`${t?"move":"split"} ${i}`}function US(){return typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}var FS=typeof HTMLElement>"u"?class{}:HTMLElement,wa=class extends FS{static observedAttributes=["theme"];scene=null;sceneText="";geometry=null;store=null;renderer=null;theme=null;kiosk=!1;loading=!1;loads=0;choice=null;root;header;titleEl;varsEl;addEl;stage;panelsEl;statusEl;statsEl;footer;canvas=null;panelDom=new Map;gutterDom=new Map;gutters=[];sceneWidgets=[];captions=[];addChips=[];addButton=null;addGroup=null;transport=null;menu=null;closeExport=null;raf=0;intersecting=!0;shown=!1;viewObserver=null;onVisibility=()=>this.syncShown();dirty=!0;anchor={index:0,time:0};playProgress=null;speed=1;meter=new Qa;stageSize={w:0,h:0};saveTimer=0;resizeObserver=null;onPageHide=()=>this.flushSave();unsubscribe=null;lastPanels=null;lastLayout=null;refreshExport=null;connectedCallback(){if(this.shadowRoot===null&&this.buildShell(),this.scene!==null){this.applyTheme(),this.start();return}this.loading||(this.loading=!0,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{this.loadFromSources()},{once:!0}):this.loadFromSources())}disconnectedCallback(){this.stop()}attributeChangedCallback(){this.applyTheme()}buildShell(){this.kiosk=this.hasAttribute("kiosk");let e=this.attachShadow({mode:"open"}),t=se("style");t.textContent=NS,e.appendChild(t),this.root=se("div",this.kiosk?"root kiosk":"root"),this.header=se("header"),this.titleEl=se("h1"),this.varsEl=se("div","vars"),this.varsEl.setAttribute("role","group"),this.varsEl.setAttribute("aria-label","Scene"),this.addEl=se("div","add"),this.addEl.setAttribute("role","group"),this.addEl.setAttribute("aria-label","Add panel"),this.header.append(this.titleEl,this.varsEl,this.addEl),this.stage=se("div","stage"),this.panelsEl=se("div","panels"),this.statusEl=se("div","status","loading\u2026"),this.stage.append(this.panelsEl,this.statusEl),this.statsEl=se("div","stats"),this.footer=se("footer"),this.root.append(this.header,this.stage,this.statsEl,this.footer),e.appendChild(this.root),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("keydown",i=>this.onKey(i))}fail(e){this.statusEl.hidden=!1,this.statusEl.className="status error",this.statusEl.textContent=e}select(e){let t=this.getRootNode();try{return t.querySelector?.(e)??document.querySelector(e)}catch{return null}}source(e){for(let r of this.children)if(r.tagName==="SCRIPT"&&r.getAttribute("data-tycho")===e)return r;let t=this.getAttribute(e);if(!t)return this.select(`#tycho-${e}`);let i=this.select(t);if(i===null&&t.startsWith("#"))throw new Error(`the ${e} selector ${t} does not match an element`);return i??t}async read(e){if(typeof e!="string")return Ta(e.textContent??"",e.getAttribute("data-encoding")??"base64");let t=await fetch(e);if(!t.ok)throw new Error(`${e} answered ${t.status}`);return new Uint8Array(await t.arrayBuffer())}async loadFromSources(){try{let e=this.source("scene"),t=this.source("data");if(e===null&&t===null){this.loading=!1;return}if(e===null||t===null)throw new Error(`the ${e===null?"scene":"data"} is missing`);let[i,r]=await Promise.all([this.read(e),this.read(t)]);if(this.loads>0)return;await this.load(new TextDecoder("utf-8").decode(i),r)}catch(e){this.fail(`the scene did not load: ${e.message}`)}}async load(e,t){this.shadowRoot===null&&this.buildShell();let i=++this.loads,r,s;try{if(r=JSON.parse(e),s=await _r.parse(t),i!==this.loads)return;for(let a of Oa(r,s))console.warn(`TyCHO: ${a}`)}catch(a){if(i!==this.loads)return;this.stop(),this.fail(a instanceof tn?a.message:`the scene cannot be read: ${a.message}`);return}this.stop(),this.scene=r,this.sceneText=e,this.geometry=new ja(r,s),this.store=new lc(this.recall(),r.clock.steps),this.choice=this.templateChoice(),this.statusEl.hidden=!0,this.applyTheme(),this.titleEl.textContent=r.title??"",this.buildTopBar(),this.buildFooter(),this.start(),(this.kiosk||this.hasAttribute("autoplay"))&&!US()&&this.play()}start(){if(!(this.scene===null||this.store===null||this.renderer!==null||!this.isConnected)){this.canvas=se("canvas"),this.stage.insertBefore(this.canvas,this.panelsEl);try{this.renderer=new gs(this.canvas,this.scene,this.geometry,{theme:this.theme})}catch(e){this.fail(`WebGL is not available: ${e.message}`);return}this.renderer.onChange=()=>this.invalidate(),this.unsubscribe=this.store.subscribe(e=>this.onChange(e)),this.measureStage(),this.resizeObserver=new ResizeObserver(()=>{this.measureStage(),this.layoutDom(),this.fitAddGroup(),this.invalidate()}),this.resizeObserver.observe(this.stage),this.resizeObserver.observe(this.header),window.addEventListener("pagehide",this.onPageHide),document.addEventListener("visibilitychange",this.onVisibility),typeof IntersectionObserver<"u"&&(this.intersecting=!1,this.viewObserver=new IntersectionObserver(e=>{this.intersecting=e[e.length-1].isIntersecting,this.syncShown()},{threshold:0}),this.viewObserver.observe(this)),this.lastPanels=null,this.lastLayout=null;for(let e of[...this.panelDom.keys()])this.removePanelDom(e);this.onChange("state"),this.store.playing&&this.onChange("playing"),this.syncShown()}}stop(){cancelAnimationFrame(this.raf),this.raf=0,this.shown=!1,document.removeEventListener("visibilitychange",this.onVisibility),this.viewObserver?.disconnect(),this.viewObserver=null,this.flushSave(),this.closeMenu(!1),window.removeEventListener("pagehide",this.onPageHide),this.unsubscribe?.(),this.unsubscribe=null,this.resizeObserver?.disconnect(),this.resizeObserver=null,this.renderer?.dispose(),this.renderer=null,this.canvas?.remove(),this.canvas=null}hostProperty(e){return typeof getComputedStyle>"u"?"":getComputedStyle(this).getPropertyValue(e).trim()}applyTheme(){if(this.scene!==null){this.theme=ed(Cr(this.scene),this.getAttribute("theme"),e=>this.hostProperty(e));for(let[e,t]of Object.entries(td(this.theme)))this.style.setProperty(e,t);this.renderer?.setTheme(this.theme),this.invalidate()}}recall(){let e=this.scene;if(this.kiosk)return structuredClone(e.initial);try{let t=localStorage.getItem(uc(this.sceneText));return t===null?structuredClone(e.initial):ym(e,JSON.parse(t))}catch{return structuredClone(e.initial)}}save(){this.kiosk||(window.clearTimeout(this.saveTimer),this.saveTimer=window.setTimeout(()=>this.flushSave(),300))}flushSave(){if(!(this.saveTimer===0||this.store===null)){window.clearTimeout(this.saveTimer),this.saveTimer=0;try{localStorage.setItem(uc(this.sceneText),JSON.stringify(this.store.state))}catch{}}}reset(){if(!(this.scene===null||this.store===null)){try{localStorage.removeItem(uc(this.sceneText))}catch{}this.closeMenu(!1),this.store.set(structuredClone(this.scene.initial));for(let e of this.panelDom.keys())this.renderer?.refit(e)}}get state(){return this.store?.state??null}onChange(e){let t=this.store;if(e==="state"){let i=t.state;i.panels!==this.lastPanels&&this.syncPanels(),(i.layout!==this.lastLayout||i.panels!==this.lastPanels)&&this.layoutDom(),this.lastPanels=i.panels,this.lastLayout=i.layout,this.syncWidgets(),this.save()}else if(e==="playing"){let i=this.transport;if(i!==null){let r=t.playing?"Pause (k)":"Play (k)";i.play.replaceChildren(Zn(t.playing?"pause":"play")),i.play.setAttribute("aria-label",r),i.play.title=r,i.play.classList.toggle("on",t.playing)}this.meter.reset(),this.playProgress=null,i!==null&&this.showRate(null),t.playing&&(this.anchor={index:t.frame,time:performance.now()})}this.invalidate()}invalidate(){this.dirty=!0,this.schedule()}schedule(){this.raf===0&&this.renderer!==null&&this.shown&&(this.raf=requestAnimationFrame(e=>this.tick(e)))}syncShown(){let e=this.intersecting&&!document.hidden;if(e!==this.shown){if(this.shown=e,!e){cancelAnimationFrame(this.raf),this.raf=0;return}this.store?.playing&&(this.meter.reset(),this.anchor={index:this.playPosition(),time:performance.now()}),this.invalidate()}}playPosition(){return this.playProgress===null?this.store.frame:this.playProgress*this.scene.clock.steps}tick(e){this.raf=0;let t=this.store,i=this.scene.clock;if(t.playing){let r=no(this.anchor.index,e-this.anchor.time,1e3,i.steps,this.speed,kr(i));t.setFrame(io(r,i.steps)),this.playProgress=ro(r,i.steps),this.dirty=!0}this.dirty&&(this.dirty=!1,this.draw(),t.playing&&this.countDraw(e)),t.playing&&this.schedule()}countDraw(e){this.meter.note(e),this.showRate(this.meter.report(e))}showRate(e){let t=this.transport;if(t===null)return;Fn(t.fps,eh(e));let i=th(e);t.fps.title!==i&&(t.fps.title=i)}measureStage(){this.stageSize={w:this.stage.clientWidth,h:this.stage.clientHeight}}draw(){let e=this.renderer,t=this.store,i=this.scene;if(e===null)return;let r=t.state,{w:s,h:a}=this.stageSize;if(s<1||a<1)return;let o=t.playing&&this.playProgress!==null?this.playProgress:t.frame/i.clock.steps,l=e.renderAt(r,o,s,a,Math.min(window.devicePixelRatio||1,2));for(let[h,u]of this.panelDom){Fn(u.error,l.get(h)??"");for(let d of u.readouts)bm(d,this.pieces(h,d.parts,o));u.barsFor!==r&&(this.syncBars(h,u),u.barsFor=r)}let c=this.firstPanel();for(let h of this.captions)bm(h,c===null?[]:this.pieces(c,h.parts,o));this.transport&&(Ru(this.transport.scrub,t.frame),Fn(this.transport.frame,`${t.frame} / ${i.clock.steps}`))}pieces(e,t,i){try{let r={scene:this.scene,geometry:this.geometry,state:this.store.state,panel:e,frameIndex:this.store.frame,progress:i};return Qc(r,t)}catch(r){if(r instanceof tn)return{error:r.message};throw r}}firstPanel(){let e=t=>t.kind==="panel"?t.id:e(t.a);return this.store===null?null:e(this.store.state.layout)}hasTransport(){return(this.scene?.controls??[]).some(e=>e.kind==="transport")}get playing(){return this.store?.playing??!1}play(){this.store?.setPlaying(!0)}pause(){this.store?.setPlaying(!1)}step(e){let t=this.store;t!==null&&(this.pause(),t.setFrame(t.frame+e))}seek(e){let t=this.store;t.setFrame(e),this.playProgress=null,t.playing&&(this.anchor={index:t.frame,time:performance.now()})}onKey(e){this.useKey(e)&&e.stopPropagation()}useKey(e){if(this.store===null||e.metaKey||e.ctrlKey||e.altKey)return!1;if(e.key==="Escape"){if(this.menu!==null)this.closeMenu(!0);else if(!this.closeExport?.())return!1;return e.preventDefault(),!0}let t=zd(e.key,e.shiftKey,this.scene.clock.steps),i=e.composedPath()[0];return i!==void 0&&["INPUT","SELECT","BUTTON","TEXTAREA"].includes(i.tagName)?t!==null||Vd(i.tagName,i.type,e.key):t===null?!1:t.kind==="fit"?(e.preventDefault(),this.fitAll(),!0):t.kind==="slider"?this.stepSlider(t.by)?(e.preventDefault(),!0):!1:!this.hasTransport()&&!this.kiosk?!1:(e.preventDefault(),t.kind==="toggle"?this.store.setPlaying(!this.store.playing):t.kind==="step"?this.step(t.by):this.seek(t.frame),!0)}fitAll(){this.renderer?.refitAll(),this.invalidate()}fitPanel(e){this.renderer?.refit(e),this.invalidate()}stepSlider(e){let t=this.scene,i=this.store.state,r=this.firstPanel(),s=(t.controls??[]).find(h=>h.kind==="slider"&&it(t,h.variable)?.scope!=="panel");if(s===void 0||r===null)return!1;let a={scene:t,state:i,panel:i.panels[r]},o=eo(a,this.geometry.sets,s);if(o.length===0)return!1;let l=this.panelValue(a,s.variable),c=Math.min(o.length-1,Math.max(0,Us(o,l)+e));return this.store.update(h=>Ni(t,h,s.variable,o[c])),!0}buildFooter(){let e=this.scene;if(this.footer.replaceChildren(),this.transport=null,this.hasTransport()){let s=Cu("Playback","playback"),a=_s("play","Play (k)","Play (k)","icon play");a.addEventListener("click",()=>this.store.setPlaying(!this.store.playing));let o=se("input","scrub");o.type="range",o.min="0",o.max=String(e.clock.steps-1),o.step="1",o.setAttribute("aria-label","Frame"),o.addEventListener("pointerdown",Jn),o.addEventListener("input",()=>{this.pause(),this.store.setFrame(Number(o.value))});let l=se("span","frame");l.style.minWidth=`${2*String(e.clock.steps).length+3}ch`,l.title="Frame index of the loop. Left and right step, Home goes to 0";let c=se("select","speed");c.setAttribute("aria-label","Playback speed"),c.title="Playback speed";for(let d of kS){let f=se("option",void 0,`${d}\xD7`);f.value=String(d),f.selected=d===this.speed,c.appendChild(f)}c.addEventListener("change",()=>{this.speed=Number(c.value),this.anchor={index:this.playPosition(),time:performance.now()},this.refreshExport?.()}),s.append(a,o,l,c);let h=null;e.clock.channels.length>1&&(h=vm(e.clock.channels.map((d,f)=>({id:d,label:e.clock.labels?.[f]??d})),d=>this.store.update(f=>fm(f,d)),"Clock"),h.el.title="What the frame index runs along",s.append(h.el));let u=se("span","fps",eh(null));u.title=th(null),s.append(u),this.footer.append(s),this.transport={play:a,scrub:o,frame:l,fps:u,channel:h}}let t=Cu("View"),i=_s("house","Reset every view","Reset every view: fit each panel to what it draws (F)");i.addEventListener("click",()=>this.fitAll());let r=_s("rotateCcw","Reset scene","Reset scene: panels, layout, and controls as written");r.addEventListener("click",()=>this.reset()),t.append(i,r),this.footer.append(t),this.buildExport()}exportVideo(e={}){if(this.scene===null||this.store===null||this.geometry===null)return Promise.reject(new Error("the viewer has not loaded a scene"));let t={w:this.stage.clientWidth,h:this.stage.clientHeight},i=this.hostProperty("--tycho-font"),r={...this.theme===null?{}:{theme:this.theme},...i===""?{}:{font:i}};return lm({scene:this.scene,geometry:this.geometry,state:this.store.state,stage:t,...r},{speed:this.speed,...e})}buildExport(){let e=Cu("Export"),t=se("button","disclose");t.type="button",t.append(Zn("download"),se("span",void 0,"Export video"),Zn("chevronDown","chev"));let i=se("div","exportbar");e.appendChild(t),this.footer.appendChild(e),this.closeExport=null;let r=Su();if(r!==null){t.disabled=!0,this.footer.append(se("span","why",`video export is unavailable: ${r}`));return}let s=se("span","xprog");s.hidden=!0,t.appendChild(s),i.id="xbar",i.setAttribute("role","group"),i.setAttribute("aria-label","Export options"),i.hidden=!0,t.setAttribute("aria-expanded","false"),t.setAttribute("aria-controls","xbar");let a=x=>{i.hidden=!x,t.setAttribute("aria-expanded",String(x)),x&&(M(),S())};this.closeExport=()=>i.hidden?!1:(a(!1),t.focus(),!0),t.addEventListener("click",()=>a(i.hidden!==!1));let o=(x,A)=>{let T=se("select");T.setAttribute("aria-label",x),T.title=x;for(let[R,k]of A){let w=se("option",void 0,k);w.value=R,T.appendChild(w)}return T},l=o("Size",[["720p","1280\xD7720"],["1080p","1920\xD71080"],["stage","stage size"]]),c=o("Frame rate",nc.map(x=>[String(x),`${x} fps`]));c.value="30";let h=()=>xa("stage",{w:this.stage.clientWidth,h:this.stage.clientHeight},window.devicePixelRatio||1,Number(c.value)),u=o("Loops",nm.map(x=>[String(x),x===1?"1 loop":`${x} loops`])),d=se("span","info"),f=se("button","btn primary","Start");f.type="button";let g=se("progress");g.hidden=!0;let y=se("button","btn","Cancel");y.type="button",y.hidden=!0;let m=_s("x","Close export options","Close (Esc)");m.addEventListener("click",()=>{a(!1),t.focus()});let p=null,M=()=>{if(p!==null)return;let x=this.scene.clock;u.value="1",c.value=String(im(x.steps,this.speed,kr(x))??nc[0])},S=()=>{if(p!==null)return;let x=l.options[2],A=h();x.textContent=`stage, ${A.width}\xD7${A.height}`;let T=this.scene.clock,R=ic(T.steps,Number(c.value),Number(u.value),this.speed,0,kr(T)),k=rc(R.count,Number(c.value));d.textContent=k??`${R.count} frames, ${R.duration.toFixed(1)} s at ${this.speed}\xD7 speed`,f.disabled=k!==null};for(let x of[l,c,u])x.addEventListener("change",S);this.refreshExport=()=>{i.hidden||(M(),S())},f.addEventListener("click",()=>{let x=new AbortController;p=x,f.disabled=!0,y.hidden=!1,g.hidden=!1,g.value=0,s.hidden=!1,s.style.width="0%";let A=l.value,T=`${(this.scene.title??"tycho").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,60)||"tycho"}.mp4`,R="";this.exportVideo({size:A,fps:Number(c.value),loops:Number(u.value),signal:x.signal,onConfig:k=>R=`${k.width}\xD7${k.height} H.264 ${k.codec}`,onProgress:(k,w)=>{g.max=w,g.value=k,s.style.width=`${w>0?100*k/w:0}%`,d.textContent=`${R}, frame ${k} of ${w}`}}).then(k=>{let w=URL.createObjectURL(k),b=se("a");b.href=w,b.download=T,this.shadowRoot.appendChild(b),b.click(),b.remove(),window.setTimeout(()=>URL.revokeObjectURL(w),6e4),d.textContent=`saved ${T}, ${R}, ${(k.size/1e6).toFixed(2)} MB`}).catch(k=>{d.textContent=k instanceof DOMException&&k.name==="AbortError"?"canceled":`export failed: ${k.message}`}).finally(()=>{p=null,f.disabled=!1,y.hidden=!0,g.hidden=!0,s.hidden=!0})}),y.addEventListener("click",()=>p?.abort()),i.append(l,c,u,d,f,g,y,m),this.footer.append(i)}makeWidget(e,t){let i=this.scene,r=it(i,e.variable);if(r===void 0)return null;let s=l=>this.store.update(c=>Ni(i,c,e.variable,l,t)),a=l=>{let c=r.scope==="panel"?l.panel.variables:l.state.variables;return c!==void 0&&Object.hasOwn(c,e.variable)?c[e.variable]:r.default},o=()=>{let l=se("label","field");return l.appendChild(se("span","k",e.label)),l.addEventListener("pointerdown",Jn),l};if(e.kind==="tabs"&&r.kind==="choice"&&t!==void 0&&r.values.length>3){let l=r,c=se("select");l.values.forEach((u,d)=>{let f=se("option",void 0,l.labels?.[d]??u);f.value=u,c.appendChild(f)}),c.addEventListener("change",()=>s(c.value));let h=o();return h.appendChild(c),{el:h,sync:u=>{c.value=String(a(u))}}}if(e.kind==="tabs"&&r.kind==="choice"){let l=r,c=vm(l.values.map((u,d)=>({id:u,label:l.labels?.[d]??u})),u=>s(u),e.label),h=se("span","field");return h.append(se("span","k",e.label),c.el),h.addEventListener("pointerdown",Jn),{el:h,sync:u=>c.set(String(a(u)))}}if(e.kind==="toggle"&&r.kind==="toggle"){let l=se("input");l.type="checkbox",l.addEventListener("change",()=>s(l.checked));let c=o();return c.prepend(l),{el:c,sync:h=>{l.checked=a(h)===!0}}}if(e.kind==="slider"&&r.kind==="selector"){let l=se("input");l.type="range",l.min="0",l.step="1";let c=se("output"),h=[];l.addEventListener("input",()=>{Ru(l,Number(l.value));let d=h[Number(l.value)];d!==void 0&&s(d)});let u=o();return u.append(l,c),{el:u,sync:d=>{h=eo(d,this.geometry.sets,e),l.disabled=h.length===0,l.max=String(Math.max(0,h.length-1));let f=a(d);Ru(l,Math.max(0,Us(h,f))),c.textContent=rn(f)}}}return null}templateChoice(){let e=this.scene,t=Object.entries(e.variables??{}).filter(([,o])=>o?.kind==="choice"&&o.scope==="panel");if(t.length===0)return null;let i=new Set(Object.values(e.views).map(o=>typeof o.frame=="string"?"":o.frame.var)),[r,s]=t.find(([o])=>i.has(o))??t[0],a=(e.controls??[]).find(o=>o.kind==="tabs"&&o.variable===r);return{id:r,def:s,label:a?.label??r}}templates(){let e=this.scene,t=Object.entries(e.views).map(([r,s])=>({kind:"view",view:r,label:s.label??r})),i=this.choice;return t.length>1||i===null?t:i.def.values.map((r,s)=>({kind:"value",variable:i.id,value:r,label:i.def.labels?.[s]??r}))}buildTopBar(){let e=this.scene;this.varsEl.replaceChildren(),this.sceneWidgets=[];for(let t of e.controls??[]){if(t.kind==="transport"||it(e,t.variable)?.scope==="panel")continue;let i=this.makeWidget(t,void 0);i&&(this.sceneWidgets.push(i),this.varsEl.appendChild(i.el))}this.buildAddGroup(),this.statsEl.replaceChildren(),this.captions=(e.readouts??[]).filter(t=>t.place==="caption").map(t=>_m(t.parts,"wide")),this.statsEl.append(...this.captions.map(t=>t.root))}buildAddGroup(){this.addEl.replaceChildren();let e=this.templates(),t=se("div","chips");t.appendChild(se("span","k","Add panel")),this.addChips=[];for(let r of e){let s=xm(r.label,"menu");s.body.setAttribute("role","button"),s.body.tabIndex=0,s.body.setAttribute("aria-roledescription","draggable"),s.body.title="Drag onto a panel: an edge splits it, the center replaces it. Click to add a panel.",s.body.addEventListener("pointerdown",o=>this.startDrag(o,r,s.body,s.root)),s.body.addEventListener("keydown",o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),o.stopPropagation(),this.addPanel(r))});let a=s.button;a.addEventListener("click",()=>this.openMenu(a,this.chipEntries(r))),t.appendChild(s.root),this.addChips.push(s.root)}let i=se("button","btn");i.type="button",i.setAttribute("aria-haspopup","menu"),i.setAttribute("aria-expanded","false"),i.append(Zn("plus"),se("span",void 0,"Add panel"),Zn("chevronDown","chev")),i.hidden=!0,i.addEventListener("pointerdown",Jn),i.addEventListener("click",()=>this.openMenu(i,e.map(r=>({label:r.label,run:()=>this.addPanel(r)})))),this.addEl.append(t,i),this.addGroup=t,this.addButton=i,this.fitAddGroup()}fitAddGroup(){let e=this.addGroup,t=this.addButton;if(e===null||t===null||this.addChips.length<2)return;let i=this.shadowRoot?.activeElement??null;e.hidden=!1,t.hidden=!0;let r=this.addChips[0],a=this.addChips[this.addChips.length-1].offsetTop>r.offsetTop+r.offsetHeight/2;e.hidden=a,t.hidden=!a,a&&i!==null&&e.contains(i)&&t.focus()}chipEntries(e){let t=this.scene;return mm(this.store.state,i=>this.panelName(i),dc).map(i=>({label:i.label,disabled:i.disabled,group:i.group,run:()=>this.store.update(r=>gm(t,r,i.placement,e,dc,s=>this.isTall(s)))}))}addPanel(e){this.store.update(t=>Au(this.scene,t,e,dc,i=>this.isTall(i)))}isTall(e){let t=this.panelDom.get(e)?.host.getBoundingClientRect();return t!==void 0&&t.width<t.height}panelName(e){let t=this.panelDom.get(e);if(t===void 0)return e;let i=t.chipLabel.textContent??"";return t.title.hidden?i||e:`${t.title.textContent??e}, ${i}`}openMenu(e,t){let i=this.menu?.anchor===e;if(this.closeMenu(!1),i)return;let r=se("div","menu");r.setAttribute("role","menu");let s=[];for(let h of t){if(h.group&&s.length>0){let d=se("hr");d.setAttribute("role","separator"),r.appendChild(d)}let u=se("button",void 0,h.label);u.type="button",u.setAttribute("role","menuitem"),u.tabIndex=-1,u.disabled=h.disabled===!0,u.addEventListener("click",()=>{this.closeMenu(!0),h.run()}),r.appendChild(u),s.push(u)}let a=s.filter(h=>!h.disabled);r.addEventListener("pointerdown",Jn),r.addEventListener("keydown",h=>{let u=a.indexOf(this.shadowRoot.activeElement),d=a.length,f=g=>a[(g%d+d)%d]?.focus();if(h.key==="ArrowDown")f(u+1);else if(h.key==="ArrowUp")f(u-1);else if(h.key==="Home")f(0);else if(h.key==="End")f(d-1);else if(h.key==="Escape")this.closeMenu(!0);else if(h.key==="Tab")this.closeMenu(!1);else return;h.key!=="Tab"&&h.preventDefault(),h.stopPropagation()}),this.root.appendChild(r);let o=e.getBoundingClientRect(),l=o.bottom+4+r.offsetHeight<=window.innerHeight;r.style.left=`${Math.max(4,Math.min(o.left,window.innerWidth-r.offsetWidth-4))}px`,r.style.top=`${l?o.bottom+4:Math.max(4,o.top-r.offsetHeight-4)}px`,e.setAttribute("aria-expanded","true");let c=h=>{let u=h.composedPath();!u.includes(r)&&!u.includes(e)&&this.closeMenu(!1)};window.addEventListener("pointerdown",c,!0),this.menu={anchor:e,close:h=>{r.remove(),e.setAttribute("aria-expanded","false"),window.removeEventListener("pointerdown",c,!0),h&&e.focus()}},a[0]?.focus()}closeMenu(e){let t=this.menu;this.menu=null,t?.close(e)}syncWidgets(){let e=this.store,t=this.scene,i=e.state,r=this.firstPanel();if(r!==null){let o={scene:t,state:i,panel:i.panels[r]};for(let l of this.sceneWidgets)l.sync(o)}let s=Object.keys(t.views).length,a=this.choice;for(let[o,l]of this.panelDom){let c=i.panels[o];if(c===void 0)continue;let h={scene:t,state:i,panel:c};for(let p of l.widgets)p.sync(h);let u=t.views[c.view];l.title.textContent=u.label??c.view,l.title.hidden=s<2;let d=typeof u.frame=="string"?u.frame:String(this.panelValue(h,u.frame.var)),g=(Object.hasOwn(t.frames,d)?t.frames[d]:void 0)?.label??d,y=u.frame,m=typeof y=="string"?null:y.var;if(a!==null&&l.select!==null){let p=String(this.panelValue(h,a.id));l.select.value=p,Fn(l.chipLabel,a.def.labels?.[a.def.values.indexOf(p)]??p),l.meta.textContent=g,l.meta.hidden=m===a.id||m!==null&&(t.controls??[]).some(M=>M.kind!=="transport"&&M.variable===m&&it(t,m)?.scope==="panel")}else Fn(l.chipLabel,g),l.meta.hidden=!0;l.close.hidden=Object.keys(i.panels).length<2}this.transport?.channel?.set(i.clock.channel)}panelValue(e,t){let i=it(e.scene,t);if(i===void 0)return"";let r=i.scope==="panel"?e.panel.variables:e.state.variables;return r!==void 0&&Object.hasOwn(r,t)?r[t]:i.default}syncPanels(){let e=this.store.state;for(let t of[...this.panelDom.keys()])Object.hasOwn(e.panels,t)||this.removePanelDom(t);for(let t of Object.keys(e.panels)){let i=this.panelDom.get(t);i!==void 0&&i.view===e.panels[t].view||(i!==void 0&&this.removePanelDom(t),this.createPanelDom(t,e.panels[t]))}}createPanelDom(e,t){let i=this.scene,r=se("div","panel");r.dataset.id=e;let s=se("div","pbody"),a=(i.readouts??[]).filter(A=>A.place==="panel").map(A=>_m(A.parts,"stack")),o=se("div","preadout");o.append(...a.map(A=>A.root));let l=se("div","perror"),c=se("div","cbars"),h=se("div","drop"),u=se("span");h.appendChild(u),h.hidden=!0,s.append(o,l,c,h),s.addEventListener("dblclick",()=>this.fitPanel(e));let d=se("div","phead"),f=se("span","t"),g=this.choice,y=xm("",g===null?"none":"select");if(y.body.title="Drag to move the panel: onto an edge of another to place it there, onto its center to swap",g!==null&&y.select!==null){let A=y.select;A.setAttribute("aria-label",g.label),g.def.values.forEach((T,R)=>{let k=se("option",void 0,g.def.labels?.[R]??T);k.value=T,A.appendChild(k)}),A.addEventListener("change",()=>this.store.update(T=>Ni(i,T,g.id,A.value,e)))}let m=se("span","m"),p=se("span","pc mini"),M=[];for(let A of i.controls??[]){if(A.kind==="transport"||it(i,A.variable)?.scope!=="panel"||g!==null&&A.kind==="tabs"&&A.variable===g.id)continue;let T=this.makeWidget(A,e);T&&(M.push(T),p.appendChild(T.el))}let S=_s("house","Reset view","Reset view: fit to what this panel draws (F resets every panel)");S.addEventListener("click",()=>this.fitPanel(e));let x=_s("x","Close panel","Close panel");x.addEventListener("click",()=>this.store.update(A=>pm(A,e))),d.append(f,y.root,m,p,se("span","sp"),S,x),d.addEventListener("pointerdown",A=>this.startDrag(A,{kind:"panel",id:e},d,y.root)),r.append(s,d),this.panelsEl.appendChild(r),this.panelDom.set(e,{host:r,body:s,head:d,title:f,chip:y.root,chipLabel:y.label,select:y.select,meta:m,close:x,readouts:a,error:l,drop:h,dropLabel:u,bars:c,barDom:[],barsFor:null,widgets:M,view:t.view}),this.renderer?.bind(e,s)}removePanelDom(e){let t=this.panelDom.get(e);t&&(this.renderer?.bind(e,null),t.host.remove(),this.panelDom.delete(e))}layoutDom(){if(this.store===null)return;let{w:e,h:t}=this.stageSize,i=ds(this.store.state.layout,{x:0,y:0,w:e,h:t},ys);for(let[s,a]of i.panels){let o=this.panelDom.get(s);o&&Object.assign(o.host.style,{left:`${a.x}px`,top:`${a.y}px`,width:`${a.w}px`,height:`${a.h}px`})}this.gutters=i.gutters;let r=new Set;for(let s of i.gutters){r.add(s.path);let a=this.gutterDom.get(s.path);if(!a){a=se("div","gutter");let o=s.path;a.addEventListener("pointerdown",l=>this.startResize(l,o,a)),this.gutterDom.set(s.path,a),this.panelsEl.appendChild(a)}a.className=`gutter ${s.dir}`,Object.assign(a.style,{left:`${s.rect.x}px`,top:`${s.rect.y}px`,width:`${s.rect.w}px`,height:`${s.rect.h}px`})}for(let[s,a]of[...this.gutterDom])r.has(s)||(a.remove(),this.gutterDom.delete(s))}startResize(e,t,i){let r=this.gutters.find(o=>o.path===t);if(!r||e.button!==0)return;e.preventDefault(),i.classList.add("active"),i.setPointerCapture(e.pointerId);let s=o=>{let l=this.stage.getBoundingClientRect(),c=Vp(r,o.clientX-l.left,o.clientY-l.top,ys);this.store.update(h=>Sa(h,Ql(h.layout,t,c)))},a=()=>{i.classList.remove("active"),i.removeEventListener("pointermove",s),i.removeEventListener("pointerup",a),i.removeEventListener("pointercancel",a)};i.addEventListener("pointermove",s),i.addEventListener("pointerup",a),i.addEventListener("pointercancel",a)}syncBars(e,t){let i=this.scene,r=this.renderer.colorbars(e);t.barDom.length!==r.length&&(t.barDom=r.map(()=>this.makeBar(e)),t.bars.replaceChildren(...t.barDom.map(o=>o.root)));let s=this.store.state.panels[e],a=s===void 0?void 0:i.views[s.view];r.forEach((o,l)=>{let c=t.barDom[l];Fn(c.title,o.label),c.gradient!==o.gradient&&(c.gradient=o.gradient,c.grad.style.background=o.gradient),Fn(c.hi,rn(o.hi,3)),Fn(c.lo,rn(o.lo,3)),c.range=[o.lo,o.hi],c.mark.hidden=o.marker===null,o.marker!==null&&(c.mark.style.bottom=`${(100*o.marker).toFixed(2)}%`),c.band.hidden=o.band===null,o.band!==null&&(c.band.style.bottom=`${(100*o.band[0]).toFixed(2)}%`,c.band.style.height=`${(100*(o.band[1]-o.band[0])).toFixed(2)}%`),c.link=this.kiosk||a===void 0?null:Hd(i,a,o.label);let h=c.grad;if(h.classList.toggle("live",c.link!==null),c.link===null){for(let d of["role","tabindex","aria-orientation","aria-label","aria-valuemin","aria-valuemax","aria-valuenow","aria-valuetext","title"])h.removeAttribute(d);return}let u=this.panelValue({scene:i,state:this.store.state,panel:s},c.link.variable);h.setAttribute("role","slider"),h.setAttribute("tabindex","0"),h.setAttribute("aria-orientation","vertical"),h.setAttribute("aria-label",c.link.label),h.setAttribute("aria-valuemin",String(o.lo)),h.setAttribute("aria-valuemax",String(o.hi)),h.setAttribute("aria-valuenow",String(u)),h.setAttribute("aria-valuetext",rn(u)),h.title=`Drag or click to set ${c.link.label}`})}makeBar(e){let t=se("div","cbar"),i=se("div","cbar-t"),r=se("div","cbar-b"),s=se("div","cbar-g"),a=se("span","cbar-k"),o=se("i");s.append(a,o);let l=se("div","cbar-n"),c=se("span"),h=se("span");l.append(c,h),r.append(s,l),t.append(i,r);let u={root:t,title:i,grad:s,band:a,mark:o,hi:c,lo:h,gradient:"",range:[0,1],link:null};return s.addEventListener("pointerdown",d=>{if(u.link===null||d.button!==0)return;d.preventDefault(),d.stopPropagation(),s.focus(),s.setPointerCapture(d.pointerId);let f=y=>{let m=s.getBoundingClientRect();this.setFromBar(e,u,m.height>0?(m.bottom-y.clientY)/m.height:0)},g=()=>{s.removeEventListener("pointermove",f),s.removeEventListener("pointerup",g),s.removeEventListener("pointercancel",g)};f(d),s.addEventListener("pointermove",f),s.addEventListener("pointerup",g),s.addEventListener("pointercancel",g)}),s.addEventListener("dblclick",Jn),s.addEventListener("keydown",d=>{if(u.link===null)return;let f={ArrowUp:1,ArrowRight:1,ArrowDown:-1,ArrowLeft:-1,PageUp:10,PageDown:-10,Home:-1/0,End:1/0};d.key in f&&(d.preventDefault(),d.stopPropagation(),this.stepBar(e,u,f[d.key]))}),u}barStops(e,t){let i=this.store.state,r=i.panels[e];if(r===void 0)return[];let s={kind:"slider",variable:t.variable,label:t.label,domain:t.domain};return eo({scene:this.scene,state:i,panel:r},this.geometry.sets,s)}setFromBar(e,t,i){if(t.link===null)return;let r=this.barStops(e,t.link),s=Gd(r,t.range[0],t.range[1],i),a=t.link.variable;s>=0&&this.store.update(o=>Ni(this.scene,o,a,r[s]))}stepBar(e,t,i){if(t.link===null)return;let r=this.barStops(e,t.link),s=this.store.state;if(r.length===0||s.panels[e]===void 0)return;let a=this.panelValue({scene:this.scene,state:s,panel:s.panels[e]},t.link.variable),o=Math.min(r.length-1,Math.max(0,Us(r,a)+i)),l=t.link.variable;this.store.update(c=>Ni(this.scene,c,l,r[o]))}startDrag(e,t,i,r){if(e.button!==0||this.store===null)return;e.preventDefault(),this.closeMenu(!1);let s=e.clientX,a=e.clientY,o=this.shadowRoot,l=null,c=null;i.setPointerCapture(e.pointerId);let h=()=>{for(let f of this.panelDom.values())f.drop.hidden=!0},u=f=>{if(!l){if(Math.hypot(f.clientX-s,f.clientY-a)<4)return;l=r.cloneNode(!0),l.classList.add("ghost"),this.root.appendChild(l),r.classList.add("source"),this.root.classList.add("dragging")}l.style.left=`${f.clientX}px`,l.style.top=`${f.clientY}px`,h(),c=null;let y=o.elementFromPoint(f.clientX,f.clientY)?.closest(".panel");if(!y)return;let m=y.dataset.id;if(t.kind==="panel"&&t.id===m)return;let p=this.panelDom.get(m);if(!p)return;let M=p.host.getBoundingClientRect(),S=um(f.clientX-M.left,f.clientY-M.top,M.width,M.height);c={id:m,zone:S},p.drop.hidden=!1,p.drop.style.inset=S==="left"?"0 50% 0 0":S==="right"?"0 0 0 50%":S==="top"?"0 0 50% 0":S==="bottom"?"50% 0 0 0":"0",Fn(p.dropLabel,OS(t,S))},d=f=>{i.removeEventListener("pointermove",u),i.removeEventListener("pointerup",d),i.removeEventListener("pointercancel",d),h();let g=l!==null;if(l?.remove(),r.classList.remove("source"),this.root.classList.remove("dragging"),!g){t.kind!=="panel"&&f.type==="pointerup"&&this.addPanel(t);return}c&&this.dropOn(c.id,c.zone,t)};i.addEventListener("pointermove",u),i.addEventListener("pointerup",d),i.addEventListener("pointercancel",d)}dropOn(e,t,i){let r=this.scene;this.store.update(s=>hc(r,s,e,t,i,dc))}};function fc(n="tycho-viewer"){typeof customElements<"u"&&!customElements.get(n)&&customElements.define(n,wa)}function BS(n,e){return n.exportVideo(e)}fc();return Dm(zS);})();
4138
+ /**
4139
+ * @license Lucide, https://lucide.dev, ISC License
4140
+ *
4141
+ * Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2022 as part of Feather (MIT).
4142
+ * All other copyright (c) for Lucide are held by Lucide Contributors 2022.
4143
+ *
4144
+ * Permission to use, copy, modify, and/or distribute this software for any purpose with or
4145
+ * without fee is hereby granted, provided that the above copyright notice and this permission
4146
+ * notice appear in all copies.
4147
+ *
4148
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
4149
+ * SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
4150
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
4151
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
4152
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
4153
+ * OF THIS SOFTWARE.
4154
+ */
3901
4155
  /*! Bundled license information:
3902
4156
 
3903
4157
  three/build/three.core.js: