@rr0/ufoathome 0.31.0 → 0.32.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.
@@ -1,4 +1,4 @@
1
- const uf=`
1
+ const vf=`
2
2
  <div class="stage" id="stage">
3
3
  <div class="frame" id="frame">
4
4
  <canvas id="scene-canvas"></canvas>
@@ -6,7 +6,7 @@ const uf=`
6
6
  <div id="ufo-slot"></div>
7
7
  <div id="hover-tooltip" class="hover-tooltip" hidden></div>
8
8
  </div>
9
- `,df=`
9
+ `,xf=`
10
10
  :host {
11
11
  display: block;
12
12
  }
@@ -79,7 +79,7 @@ const uf=`
79
79
  pointer-events: none;
80
80
  white-space: nowrap;
81
81
  }
82
- `,ff=`
82
+ `,Mf=`
83
83
  <div class="stage" id="stage">
84
84
  <div class="frame" id="frame">
85
85
  <canvas id="canvas" width="640" height="360"></canvas>
@@ -94,7 +94,7 @@ const uf=`
94
94
  <button id="loop" type="button" title="Auto-replay" aria-label="Auto-replay" aria-pressed="true">↻</button>
95
95
  </div>
96
96
  </div>
97
- `,pf=`
97
+ `,Sf=`
98
98
  :host {
99
99
  display: block;
100
100
  font-family: sans-serif;
@@ -297,21 +297,21 @@ input[type=range] {
297
297
  pointer-events: none;
298
298
  white-space: nowrap;
299
299
  }
300
- `;class Je{static MOON_ANGULAR_WIDTH_DEG=.5237;static CANVAS_WIDTH_PX=640;static CANVAS_HEIGHT_PX=360;static angularWidthDeg(t){return 2*Math.atan(t.sizeM/(2*t.distanceM))*180/Math.PI}static inMoons(t){return t/Je.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(t,e,n){if(!(!t||!e))return{widthDeg:t.widthDeg+(e.widthDeg-t.widthDeg)*n,heightDeg:t.heightDeg+(e.heightDeg-t.heightDeg)*n}}static sizeMAt(t,e){return 2*t*Math.tan(e*Math.PI/360)}static distanceMAt(t,e){return t/(2*Math.tan(e*Math.PI/360))}}function mf(i,t,e){const{bounds:n}=i;return t>=n.x&&t<=n.x+n.width&&e>=n.y&&e<=n.y+n.height}function hn(i,t,e){return i+(t-i)*e}function ch(i){const t=/^#([0-9a-f]{6})$/i.exec(i);if(!t)return;const e=parseInt(t[1],16);return[e>>16&255,e>>8&255,e&255]}function gf(i){return`#${i.map(t=>Math.round(t).toString(16).padStart(2,"0")).join("")}`}function _f(i,t,e){const n=ch(i),s=ch(t);return!n||!s?e<1?i:t:gf([hn(n[0],s[0],e),hn(n[1],s[1],e),hn(n[2],s[2],e)])}function vf(i,t,e){const n={x:hn(i.bounds.x,t.bounds.x,e),y:hn(i.bounds.y,t.bounds.y,e),width:hn(i.bounds.width,t.bounds.width,e),height:hn(i.bounds.height,t.bounds.height,e)},s=hn(i.angle,t.angle,e),r=hn(i.transparency,t.transparency,e),a=hn(i.haloScale,t.haloScale,e),o=_f(i.color,t.color,e),c=Je.lerpAngular(i.angular,t.angular,e);return i.kind==="polygon"&&t.kind==="polygon"&&i.points.length===t.points.length?{...i,bounds:n,angle:s,transparency:r,haloScale:a,color:o,angular:c,behindCloud:e<1?i.behindCloud:t.behindCloud,points:i.points.map((l,h)=>({x:hn(l.x,t.points[h].x,e),y:hn(l.y,t.points[h].y,e)}))}:{...e<1?i:t,bounds:n,angle:s,transparency:r,haloScale:a,color:o,angular:c}}class Ha{keyframes=[];order=[];groups=[];addKeyframe(t,e){const n=this.findInsertIndex(t);if(this.keyframes[n]?.t===t){const s=new Set(e.map(r=>r.sourceId));this.keyframes[n]={t,shapes:[...this.keyframes[n].shapes.filter(r=>!s.has(r.sourceId)),...e]}}else this.keyframes.splice(n,0,{t,shapes:[...e]});for(const s of e)this.order.includes(s.sourceId)||this.order.push(s.sourceId)}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const s=e+n>>>1;this.keyframes[s].t<t?e=s+1:n=s}return e}getKeyframeAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e];return n?.t===t?n:void 0}getShapeAt(t,e){return this.getKeyframeAt(t)?.shapes.find(n=>n.sourceId===e)?.shape}getLatestShapeAt(t,e){let n=this.findInsertIndex(t);for(this.keyframes[n]?.t!==t&&(n-=1);n>=0;n--){const s=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(s)return s.shape}}getInterpolatedShapeAt(t,e){const n=this.findShapeAtOrBefore(t,e);if(n?.t===t)return n.shape;const s=this.findShapeAtOrAfter(t,e);return n?s?vf(n.shape,s.shape,(t-n.t)/(s.t-n.t)):n.shape:s?.shape}findShapeAtOrBefore(t,e){let n=this.findInsertIndex(t);for(this.keyframes[n]?.t!==t&&(n-=1);n>=0;n--){const s=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(s)return{t:this.keyframes[n].t,shape:s.shape}}}findShapeAtOrAfter(t,e){for(let n=this.findInsertIndex(t);n<this.keyframes.length;n++){const s=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(s)return{t:this.keyframes[n].t,shape:s.shape}}}hitTest(t,e,n,s){const r=this.sourceIds;for(let a=r.length-1;a>=0;a--){if(s?.has(r[a]))continue;const o=this.getInterpolatedShapeAt(t,r[a]);if(o&&mf(o,e,n))return{sourceId:r[a],shape:o}}}removeSource(t){for(let e=this.keyframes.length-1;e>=0;e--){const n=this.keyframes[e].shapes.filter(s=>s.sourceId!==t);n.length===0?this.keyframes.splice(e,1):n.length!==this.keyframes[e].shapes.length&&(this.keyframes[e]={t:this.keyframes[e].t,shapes:n})}this.order=this.order.filter(e=>e!==t),this.removeFromGroup(t)}group(t){if(!(t.length<2)){for(const e of t)this.removeFromGroup(e);this.groups.push([...t])}}ungroup(t){const e=this.groups.findIndex(n=>n.includes(t));e!==-1&&this.groups.splice(e,1)}groupMembers(t){return this.groups.find(e=>e.includes(t))}removeFromGroup(t){const e=this.groups.findIndex(s=>s.includes(t));if(e===-1)return;const n=this.groups[e].filter(s=>s!==t);n.length<2?this.groups.splice(e,1):this.groups[e]=n}bringToFront(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.push(t))}sendToBack(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.unshift(t))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get sourceIds(){return[...this.order]}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes,order:this.order,groups:this.groups}}static fromJSON(t){const e=new Ha;for(const n of t.keyframes)e.addKeyframe(n.t,n.shapes);if(t.order){const n=e.order.filter(s=>!t.order.includes(s));e.order=[...t.order,...n]}return t.groups&&(e.groups=t.groups.map(n=>n.filter(s=>e.order.includes(s))).filter(n=>n.length>=2)),e}}function xf(i,t,e){return Math.max(t,Math.min(e,i))}function Mf(i,t,e){const n=((t-i)%360+540)%360-180;return((i+n*e)%360+360)%360}function Vs(i,t,e){return i+(t-i)*e}function Sf(i,t,e){return{lat:i.lat===void 0||t.lat===void 0?void 0:Vs(i.lat,t.lat,e),lng:i.lng===void 0||t.lng===void 0?void 0:Vs(i.lng,t.lng,e),elevationM:Vs(i.elevationM,t.elevationM,e),headingDeg:i.headingDeg===void 0||t.headingDeg===void 0?void 0:Mf(i.headingDeg,t.headingDeg,e),pitchDeg:Vs(i.pitchDeg,t.pitchDeg,e),fovDeg:Vs(i.fovDeg,t.fovDeg,e)}}class dr{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);this.keyframes[n]?.t===t?this.keyframes[n]={t,pose:e}:this.keyframes.splice(n,0,{t,pose:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const s=e+n>>>1;this.keyframes[s].t<t?e=s+1:n=s}return e}getLatestPoseAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].pose:void 0}getInterpolatedPoseAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(n?.t===t)return n.pose;const s=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return n?s?Sf(n.pose,s.pose,xf((t-n.t)/(s.t-n.t),0,1)):n.pose:s?.pose}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new dr;for(const n of t.keyframes)e.addKeyframe(n.t,n.pose);return e}}function oi(i,t,e){return i+(t-i)*e}function yf(i,t,e){const n=((t-i)%360+540)%360-180;return((i+n*e)%360+360)%360}function Ef(i,t,e){return Math.max(t,Math.min(e,i))}function bf(i,t,e){return{cloudCover:oi(i.cloudCover,t.cloudCover,e),cloudDarkness:oi(i.cloudDarkness,t.cloudDarkness,e),highCloudCover:i.highCloudCover===void 0||t.highCloudCover===void 0?void 0:oi(i.highCloudCover,t.highCloudCover,e),iceCrystalAlignment:i.iceCrystalAlignment===void 0||t.iceCrystalAlignment===void 0?void 0:oi(i.iceCrystalAlignment,t.iceCrystalAlignment,e),lowerCloudCover:i.lowerCloudCover===void 0||t.lowerCloudCover===void 0?void 0:oi(i.lowerCloudCover,t.lowerCloudCover,e),cloudBaseM:i.cloudBaseM===void 0||t.cloudBaseM===void 0?void 0:oi(i.cloudBaseM,t.cloudBaseM,e),precipitationType:e<1?i.precipitationType:t.precipitationType,precipitationIntensity:oi(i.precipitationIntensity,t.precipitationIntensity,e),windDirectionDeg:yf(i.windDirectionDeg,t.windDirectionDeg,e),windSpeed:oi(i.windSpeed,t.windSpeed,e),storm:e<1?i.storm:t.storm}}class fr{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);this.keyframes[n]?.t===t?this.keyframes[n]={t,weather:e}:this.keyframes.splice(n,0,{t,weather:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const s=e+n>>>1;this.keyframes[s].t<t?e=s+1:n=s}return e}getLatestWeatherAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].weather:void 0}getInterpolatedWeatherAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(n?.t===t)return n.weather;const s=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return n?s?bf(n.weather,s.weather,Ef((t-n.t)/(s.t-n.t),0,1)):n.weather:s?.weather}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new fr;for(const n of t.keyframes)e.addKeyframe(n.t,n.weather);return e}}class pr{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);this.keyframes[n]?.t===t?this.keyframes[n]={t,sound:e}:this.keyframes.splice(n,0,{t,sound:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}getLatestSoundAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].sound:void 0}getInterpolatedSoundAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(n?.t===t)return n.sound;const s=this.keyframes[e]?.t===t?void 0:this.keyframes[e];if(!n)return s?.sound;if(!s)return n.sound;const r=(t-n.t)/(s.t-n.t);return this.lerp(n.sound,s.sound,Math.max(0,Math.min(1,r)))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new pr;for(const n of t.keyframes)e.addKeyframe(n.t,n.sound);return e}lerp(t,e,n){return{kind:n<1?t.kind:e.kind,volume:t.volume+(e.volume-t.volume)*n,pitchHz:t.pitchHz+(e.pitchHz-t.pitchHz)*n,src:n<1?t.src:e.src}}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const s=e+n>>>1;this.keyframes[s].t<t?e=s+1:n=s}return e}}const T0=1e3,Af=.65,w0={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,storm:!1},Tf=100,wf={kind:"none",volume:0,pitchHz:Tf},lh=[{id:"eye",name:"Naked eye",projection:"equidistant"},{id:"rectilinear-lens",name:"Camera, rectilinear lens",projection:"rectilinear",apertureBlades:6}];class R0{static get default(){return lh[0]}static byId(t){return lh.find(e=>e.id===t)??this.default}static starPointsOf(t){const e=t.apertureBlades;return e===void 0||e<3?0:e%2===0?e:e*2}}function rc(i){if(i.year!==void 0)return Date.UTC(i.year,(i.month??1)-1,i.day??1,i.hour??0,i.minute??0,i.second??0)}function hh(i){return(((i.day??0)*24+(i.hour??0))*60+(i.minute??0))*6e4+(i.second??0)*1e3}const Rf=["year","month","day","hour","minute"],Cf=["day","hour","minute"];function uh(i,t){return t.filter(e=>i[e]!==void 0).join(",")}function Df(i){if(i.durationSeconds!==void 0)return i.durationSeconds*1e3;if(!i.time||!i.endTime)return;const t=i.time.year!==void 0&&i.endTime.year!==void 0,e=t?Rf:Cf,n=uh(i.time,e);if(!(n===""||n!==uh(i.endTime,e)))return t?rc(i.endTime)-rc(i.time):hh(i.endTime)-hh(i.time)}class Va{constructor(t,e,n,s,r,a,o,c,l=[],h,u){this.event=t,this.timeline=e,this.witnessTrack=n,this.weatherTrack=s,this.soundTrack=r,this.witness=a,this.caseId=o,this.weather=c,this.decor=l,this.weatherSource=h,this.instrumentId=u}get instrument(){return R0.byId(this.instrumentId)}static create(t,e,n){return new Va({eventType:"sighting",time:t,place:e},new Ha,new dr,new fr,new pr,n)}}const Pf=0,If=0,Lf=60;function hr(i,t){const e=i.witnessTrack.getInterpolatedPoseAt(t);if(e)return e;const n=i.event.place?.[0];if(n)return{lat:n.lat,lng:n.lng,elevationM:Pf,headingDeg:void 0,pitchDeg:If,fovDeg:Lf}}function dh(i,t){return i.weatherTrack.getInterpolatedWeatherAt(t)??i.weather??w0}function Nf(i,t){return i.soundTrack.getInterpolatedSoundAt(t)??wf}class Uf{constructor(t,e){this.timeline=t,this.onFrame=e}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;durationOverrideMs=0;get seekableDuration(){return Math.max(this.timeline.duration,this.durationOverrideMs)}play(){if(this.state==="playing")return;this.currentT>=this.seekableDuration&&(this.currentT=0,this.resolveFrame(0)),this.state="playing",this.lastWallTime=performance.now();const t=()=>{if(this.state!=="playing")return;const e=performance.now();if(this.currentT+=(e-this.lastWallTime)*this.playbackRate,this.lastWallTime=e,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT);return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}pause(){this.state==="playing"&&(this.state="paused",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null))}stop(){this.state="stopped",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}seek(t){this.currentT=Math.max(0,Math.min(t,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(t){const e=new Map;for(const n of this.timeline.sourceIds){const s=this.timeline.getInterpolatedShapeAt(t,n);s&&e.set(n,s)}this.onFrame(t,e)}}const C0=["nw","n","ne","e","se","s","sw","w"],Ff=24,br=8,Of=3,zf=8;function Ar(i,t,e){const n=i.x-t.x,s=i.y-t.y,r=Math.cos(e),a=Math.sin(e);return{x:t.x+n*r-s*a,y:t.y+n*a+s*r}}function Ws(i){return{x:i.x+i.width/2,y:i.y+i.height/2}}const Bf={nw:{left:!0,top:!0},n:{top:!0},ne:{right:!0,top:!0},e:{right:!0},se:{right:!0,bottom:!0},s:{bottom:!0},sw:{left:!0,bottom:!0},w:{left:!0}};class nn{static handlePointsFor(t){const{x:e,y:n,width:s,height:r}=t.bounds,a={nw:{x:e,y:n},n:{x:e+s/2,y:n},ne:{x:e+s,y:n},e:{x:e+s,y:n+r/2},se:{x:e+s,y:n+r},s:{x:e+s/2,y:n+r},sw:{x:e,y:n+r},w:{x:e,y:n+r/2},rotate:{x:e+s/2,y:n-Ff}},o=Ws(t.bounds),c={};for(const l of Object.keys(a))c[l]=Ar(a[l],o,t.angle);return c}static hitTestHandle(t,e,n=8,s=[...C0,"rotate"]){const r=nn.handlePointsFor(t);for(const a of s)if(Math.hypot(e.x-r[a].x,e.y-r[a].y)<=n)return a}static HANDLE_DIRECTION_DEG={e:0,se:45,s:90,sw:135,w:180,nw:225,n:270,ne:315};static resizeAxisFor(t,e){const s=((nn.HANDLE_DIRECTION_DEG[t]+e*180/Math.PI)%180+180)%180/45,r=["ew","nwse","ns","nesw"];return r[Math.round(s)%r.length]}static resizeBounds(t,e,n,s){const r=Ws(t),a=Ar(s,r,-e),{x:o,y:c,width:l,height:h}=t,u=Bf[n];let d=o,p=c,g=o+l,x=c+h;return u.left&&(d=Math.min(a.x,g-br)),u.right&&(g=Math.max(a.x,d+br)),u.top&&(p=Math.min(a.y,x-br)),u.bottom&&(x=Math.max(a.y,p+br)),{x:d,y:p,width:g-d,height:x-p}}static resizeShape(t,e,n){if(e==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:s,height:r}=t.bounds,a=nn.resizeBounds(t.bounds,t.angle,e,n);if(t.kind==="oval")return{...t,bounds:a};const o=s===0?1:a.width/s,c=r===0?1:a.height/r;return{...t,bounds:a,points:t.points.map(l=>({x:l.x*o,y:l.y*c}))}}static rotateShape(t,e){const n=Ws(t.bounds),s=Math.atan2(e.y-n.y,e.x-n.x)+Math.PI/2;return{...t,angle:s}}static groupBoundsFor(t){const e=Math.min(...t.map(a=>a.x)),n=Math.min(...t.map(a=>a.y)),s=Math.max(...t.map(a=>a.x+a.width)),r=Math.max(...t.map(a=>a.y+a.height));return{x:e,y:n,width:s-e,height:r-n}}static vertexPointsFor(t){const e=Ws(t.bounds);return t.points.map(n=>Ar({x:t.bounds.x+n.x,y:t.bounds.y+n.y},e,t.angle))}static hitTestVertex(t,e,n=zf){const s=nn.vertexPointsFor(t);let r,a=n;return s.forEach((o,c)=>{const l=Math.hypot(e.x-o.x,e.y-o.y);l<=a&&(a=l,r=c)}),r}static toLocalPoint(t,e){const n=Ws(t.bounds),s=Ar(e,n,-t.angle);return{x:s.x-t.bounds.x,y:s.y-t.bounds.y}}static moveVertex(t,e,n){const s=t.points.map((u,d)=>d===e?nn.toLocalPoint(t,n):u),r=Math.min(...s.map(u=>u.x)),a=Math.min(...s.map(u=>u.y)),o=Math.max(...s.map(u=>u.x)),c=Math.max(...s.map(u=>u.y)),l={x:t.bounds.x+r,y:t.bounds.y+a,width:o-r,height:c-a},h=s.map(u=>({x:u.x-r,y:u.y-a}));return{...t,bounds:l,points:h}}static insertVertexNear(t,e){const n=nn.toLocalPoint(t,e),{points:s}=t;let r=s.length-1,a=1/0;for(let c=0;c<s.length;c++){const l=s[c],h=s[(c+1)%s.length],u=nn.distanceToSegment(n,l,h);u<a&&(a=u,r=c)}const o=[...s.slice(0,r+1),n,...s.slice(r+1)];return{...t,points:o}}static distanceToSegment(t,e,n){const s=n.x-e.x,r=n.y-e.y,a=s*s+r*r,o=a===0?0:Math.max(0,Math.min(1,((t.x-e.x)*s+(t.y-e.y)*r)/a)),c=e.x+o*s,l=e.y+o*r;return Math.hypot(t.x-c,t.y-l)}static deleteVertex(t,e){return t.points.length<=Of?t:{...t,points:t.points.filter((n,s)=>s!==e)}}}const ac=6,Tr=ac/2,kf=20,fh=4;class Gf{constructor(t){this.ctx=t}clear(t,e){this.ctx.clearRect(0,0,t,e)}paintShape(t){this.ctx.save(),this.ctx.globalAlpha=1-t.transparency,t.haloScale>0&&this.paintHalo(t),this.paintBase(t),this.ctx.restore(),t.selected&&this.paintSelectionHandles(t)}paintBase(t){if(this.ctx.fillStyle=t.color,this.ctx.beginPath(),t.kind==="oval"){const{x:e,y:n,width:s,height:r}=t.bounds,a=s/2,o=r/2;this.ctx.ellipse(e+a,n+o,a,o,t.angle,0,2*Math.PI)}else{const{x:e,y:n,width:s,height:r}=t.bounds;this.ctx.save(),this.ctx.translate(e+s/2,n+r/2),this.ctx.rotate(t.angle),this.ctx.translate(-s/2,-r/2),t.points.forEach((a,o)=>{o===0?this.ctx.moveTo(a.x,a.y):this.ctx.lineTo(a.x,a.y)}),this.ctx.closePath(),this.ctx.restore()}this.ctx.fill()}paintHalo(t){this.ctx.save(),this.ctx.shadowColor=t.color,this.ctx.shadowBlur=kf*t.haloScale,this.paintBase(t),this.ctx.restore()}paintSelectionHandles(t){this.paintHandleFrame(nn.handlePointsFor(t),{includeRotate:!0}),t.kind==="polygon"&&this.paintVertexHandles(t)}paintVertexHandles(t){this.ctx.fillStyle="#39f";for(const e of nn.vertexPointsFor(t))this.ctx.beginPath(),this.ctx.ellipse(e.x,e.y,fh,fh,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(t){this.paintOutline(nn.handlePointsFor(t))}paintGroupHandles(t){this.paintHandleFrame(nn.handlePointsFor({bounds:t,angle:0}),{includeRotate:!0})}paintOutline(t){this.ctx.strokeStyle="lightgray",this.ctx.beginPath(),this.ctx.moveTo(t.nw.x,t.nw.y),this.ctx.lineTo(t.ne.x,t.ne.y),this.ctx.lineTo(t.se.x,t.se.y),this.ctx.lineTo(t.sw.x,t.sw.y),this.ctx.closePath(),this.ctx.stroke()}paintHandleFrame(t,{includeRotate:e}){this.paintOutline(t),this.ctx.fillStyle="lightgray";for(const n of C0){const s=t[n];this.ctx.fillRect(s.x-Tr,s.y-Tr,ac,ac)}e&&(this.ctx.beginPath(),this.ctx.moveTo(t.n.x,t.n.y),this.ctx.lineTo(t.rotate.x,t.rotate.y),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.ellipse(t.rotate.x,t.rotate.y,Tr+1,Tr+1,0,0,2*Math.PI),this.ctx.fill())}}const ph=.05,mh=.08,gh=2,_h=3,Hf=14,Vf=.02;class Wf{context;voice;voiceToken=0;buffers=new Map;noiseBuffer;crackleBuffer;requested;resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("SightingAudio: Web Audio unavailable, the sighting stays silent:",t);return}}this.context.state==="suspended"&&this.context.resume()}setSound(t){if(this.requested=t,!this.context)return;const e=this.keyFor(t);if(!e){this.silence();return}if(this.voice?.key!==e){this.stopVoice();const n=++this.voiceToken;e.startsWith("src:")?this.buildRecordedVoice(t.src,e,n):this.voice=this.buildSynthesizedVoice(t,e)}this.applyTo(this.voice,t)}silence(){this.voiceToken++,this.stopVoice()}dispose(){this.silence(),this.context?.close(),this.context=void 0,this.buffers.clear(),this.noiseBuffer=void 0,this.crackleBuffer=void 0}keyFor(t){if(!(t.volume<=0))return t.src?`src:${t.src}`:t.kind==="none"?void 0:t.kind}applyTo(t,e){const n=this.context;if(!t||!n)return;const s=n.currentTime;t.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,e.volume))*t.gainScale,s,ph);for(const{param:r,ratio:a}of t.pitch)r.setTargetAtTime(Math.min(e.pitchHz*a,n.sampleRate/2-1),s,ph)}buildSynthesizedVoice(t,e){const n=this.context;if(n)switch(t.kind){case"hum":return this.buildHum(n,e);case"whistle":return this.buildWhistle(n,e);case"rumble":return this.buildRumble(n,e);case"crackle":return this.buildCrackle(n,e);default:return}}buildHum(t,e){const n=t.createOscillator();n.type="sawtooth";const s=t.createOscillator();s.type="sawtooth";const r=t.createBiquadFilter();r.type="lowpass",r.Q.value=1;const a=t.createGain();return a.gain.value=0,n.connect(r),s.connect(r),r.connect(a).connect(t.destination),n.start(),s.start(),{key:e,nodes:[r,a],sources:[n,s],volumeParam:a.gain,gainScale:.16,pitch:[{param:n.frequency,ratio:1},{param:s.frequency,ratio:1.006},{param:r.frequency,ratio:6}]}}buildWhistle(t,e){const n=t.createOscillator();n.type="sine";const s=t.createOscillator();s.type="sine",s.frequency.value=5;const r=t.createGain(),a=t.createGain();return a.gain.value=0,s.connect(r).connect(n.frequency),n.connect(a).connect(t.destination),n.start(),s.start(),{key:e,nodes:[r,a],sources:[n,s],volumeParam:a.gain,gainScale:.22,pitch:[{param:n.frequency,ratio:1},{param:r.gain,ratio:.012}]}}buildRumble(t,e){const n=t.createBufferSource();n.buffer=this.brownNoise(t),n.loop=!0;const s=t.createBiquadFilter();s.type="lowpass",s.Q.value=.8;const r=t.createGain();return r.gain.value=0,n.connect(s).connect(r).connect(t.destination),n.start(),{key:e,nodes:[s,r],sources:[n],volumeParam:r.gain,gainScale:1.4,pitch:[{param:s.frequency,ratio:1}]}}buildCrackle(t,e){const n=t.createBufferSource();n.buffer=this.whiteNoise(t),n.loop=!0;const s=t.createBiquadFilter();s.type="bandpass",s.Q.value=1.2;const r=t.createGain();r.gain.value=0;const a=t.createBufferSource();a.buffer=this.crackleEnvelope(t),a.loop=!0;const o=t.createGain();return o.gain.value=0,a.connect(o).connect(r.gain),n.connect(s).connect(r).connect(t.destination),n.start(),a.start(),{key:e,nodes:[s,r,o],sources:[n,a],volumeParam:o.gain,gainScale:.9,pitch:[{param:s.frequency,ratio:4}]}}async buildRecordedVoice(t,e,n){const s=this.context;if(!s)return;let r;try{r=await this.getBuffer(t)}catch(c){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",c);return}if(n!==this.voiceToken||!this.context)return;const a=s.createBufferSource();a.buffer=r,a.loop=!0;const o=s.createGain();o.gain.value=0,a.connect(o).connect(s.destination),a.start(),this.voice={key:e,nodes:[o],sources:[a],volumeParam:o.gain,gainScale:1,pitch:[]},this.requested&&this.applyTo(this.voice,this.requested)}async getBuffer(t){const e=this.context;if(!e)throw new Error("SightingAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(t);return n||(n=fetch(t).then(s=>{if(!s.ok)throw new Error(`Audio fetch failed (${s.status}): ${t}`);return s.arrayBuffer()}).then(s=>e.decodeAudioData(s)),this.buffers.set(t,n)),n}whiteNoise(t){if(!this.noiseBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*gh),t.sampleRate),n=e.getChannelData(0);for(let s=0;s<n.length;s++)n[s]=Math.random()*2-1;this.noiseBuffer=e}return this.noiseBuffer}brownNoise(t){const e=t.createBuffer(1,Math.floor(t.sampleRate*gh),t.sampleRate),n=e.getChannelData(0);let s=0,r=0;for(let a=0;a<n.length;a++)s=(s+.02*(Math.random()*2-1))/1.02,n[a]=s,r=Math.max(r,Math.abs(s));if(r>0)for(let a=0;a<n.length;a++)n[a]/=r;return e}crackleEnvelope(t){if(!this.crackleBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*_h),t.sampleRate),n=e.getChannelData(0),s=Math.max(1,Math.floor(Vf*t.sampleRate)),r=Math.round(_h*Hf);for(let a=0;a<r;a++){const o=Math.floor(Math.random()*n.length),c=.4+Math.random()*.6;for(let l=0;l<s&&o+l<n.length;l++)n[o+l]=Math.max(n[o+l],c*(1-l/s))}this.crackleBuffer=e}return this.crackleBuffer}stopVoice(){const t=this.voice,e=this.context;if(this.voice=void 0,!t||!e)return;const n=e.currentTime;t.volumeParam.cancelScheduledValues(n),t.volumeParam.setTargetAtTime(0,n,mh/3);const s=n+mh;for(const r of t.sources){r.onended=()=>{r.disconnect();for(const a of t.nodes)a.disconnect()};try{r.stop(s)}catch{r.disconnect();for(const a of t.nodes)a.disconnect()}}}}const eo=Math.PI/180,wr=180/Math.PI;class Rs{constructor(t,e,n){this.kind=t,this.canvasHeightPx=e,this.fovDeg=n;const s=n*eo/2;this.focalPx=t==="equidistant"?e/2/s:e/2/Math.tan(s)}focalPx;static of(t,e,n){return new Rs(t.projection,e,n)}degToPx(t){const e=t*eo;return this.kind==="equidistant"?this.focalPx*e:2*this.focalPx*Math.tan(e/2)}pxToDeg(t){return this.kind==="equidistant"?t/this.focalPx*wr:2*Math.atan(t/(2*this.focalPx))*wr}angleDegToRadiusPx(t){const e=t*eo;return this.kind==="equidistant"?this.focalPx*e:this.focalPx*Math.tan(e)}radiusPxToAngleDeg(t){return this.kind==="equidistant"?t/this.focalPx*wr:Math.atan(t/this.focalPx)*wr}ofBounds(t){return{widthDeg:this.pxToDeg(t.width),heightDeg:this.pxToDeg(t.height)}}toBoundsSize(t){return{width:this.degToPx(t.widthDeg),height:this.degToPx(t.heightDeg)}}widthPx(t){return this.degToPx(Je.angularWidthDeg(t))}}class Tl{static DEFAULT_FOV_DEG=60;static toAngular(t){this.eachKeyframe(t,(e,n)=>({...e,angular:n.ofBounds(e.bounds)}))}static toBounds(t){this.eachKeyframe(t,(e,n)=>{if(!e.angular)return e;const{width:s,height:r}=n.toBoundsSize(e.angular),a={x:e.bounds.x+(e.bounds.width-s)/2,y:e.bounds.y+(e.bounds.height-r)/2,width:s,height:r};if(e.kind!=="polygon")return{...e,bounds:a};const o=e.bounds.width===0?1:s/e.bounds.width,c=e.bounds.height===0?1:r/e.bounds.height;return{...e,bounds:a,points:e.points.map(l=>({x:l.x*o,y:l.y*c}))}})}static reproject(t,e){const n=Je.CANVAS_WIDTH_PX/2,s=Je.CANVAS_HEIGHT_PX/2;for(const r of[...t.timeline.allKeyframes]){const a=hr(t,r.t)?.fovDeg??this.DEFAULT_FOV_DEG,o=Rs.of(e,Je.CANVAS_HEIGHT_PX,a),c=Rs.of(t.instrument,Je.CANVAS_HEIGHT_PX,a);t.timeline.addKeyframe(r.t,r.shapes.map(l=>{const{bounds:h}=l.shape,u=h.x+h.width/2-n,d=h.y+h.height/2-s,p=Math.hypot(u,d);if(p===0)return l;const g=c.angleDegToRadiusPx(o.radiusPxToAngleDeg(p))/p,x={...h,x:n+u*g-h.width/2,y:s+d*g-h.height/2};return{...l,shape:{...l.shape,bounds:x}}}))}this.toBounds(t)}static eachKeyframe(t,e){const{timeline:n}=t;for(const s of[...n.allKeyframes]){const r=hr(t,s.t)?.fovDeg??this.DEFAULT_FOV_DEG,a=Rs.of(t.instrument,Je.CANVAS_HEIGHT_PX,r);n.addKeyframe(s.t,s.shapes.map(o=>({...o,shape:e(o.shape,a)})))}}}function Xf(i){return Tl.toAngular(i),{version:1,time:i.event.time,endTime:i.event.endTime,durationSeconds:i.event.durationSeconds,utcOffsetHours:i.event.utcOffsetHours,timeZone:i.event.timeZone,place:i.event.place,witness:i.witness,caseId:i.caseId,description:i.event.description,tags:i.event.tags,timeline:i.timeline.toJSON(),witnessTrack:i.witnessTrack.toJSON(),weatherTrack:i.weatherTrack.toJSON(),soundTrack:i.soundTrack.toJSON(),weather:i.weather,decor:i.decor,weatherSource:i.weatherSource,instrument:i.instrumentId}}function qf(i){const t=new Va({eventType:"sighting",time:i.time,endTime:i.endTime,durationSeconds:i.durationSeconds,utcOffsetHours:i.utcOffsetHours,timeZone:i.timeZone,place:i.place,description:i.description,tags:i.tags},Ha.fromJSON(i.timeline),i.witnessTrack?dr.fromJSON(i.witnessTrack):new dr,i.weatherTrack?fr.fromJSON(i.weatherTrack):new fr,i.soundTrack?pr.fromJSON(i.soundTrack):new pr,i.witness,i.caseId,i.weather,i.decor??[],i.weatherSource,i.instrument);return Tl.toBounds(t),t}function wl(i,t){for(const e of i){const n=e.toLowerCase().split("-")[0];if(t.includes(n))return n}return"en"}const Yf="modulepreload",Kf=function(i,t){return new URL(i,t).href},vh={},xh=function(t,e,n){let s=Promise.resolve();if(e&&e.length>0){let a=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};const o=document.getElementsByTagName("link"),c=document.querySelector("meta[property=csp-nonce]"),l=c?.nonce||c?.getAttribute("nonce");s=a(e.map(h=>{if(h=Kf(h,n),h in vh)return;vh[h]=!0;const u=h.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(!!n)for(let x=o.length-1;x>=0;x--){const m=o[x];if(m.href===h&&(!u||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${d}`))return;const g=document.createElement("link");if(g.rel=u?"stylesheet":Yf,u||(g.as="script"),g.crossOrigin="",g.href=h,l&&g.setAttribute("nonce",l),document.head.appendChild(g),u)return new Promise((x,m)=>{g.addEventListener("load",x),g.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${h}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return t().catch(r)})},Zf=["en","fr"],$f={en:()=>xh(()=>Promise.resolve().then(()=>Qf),void 0,import.meta.url).then(i=>i.ufoMessages_en),fr:()=>xh(()=>import("./UfoMessages_fr-Hq24iVzT.js"),[],import.meta.url).then(i=>i.ufoMessages_fr)};function Jf(i){return $f[i]()}const D0={play:"Play",pause:"Pause",noDuration:"No observation duration",autoReplay:"Auto-replay",currentPosition:"Current position",duration:"Duration",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen"},Qf=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:D0},Symbol.toStringTag,{value:"Module"})),Mh=new Set;class jf extends HTMLElement{static get observedAttributes(){return["src"]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;loopButton;fullscreenButton;seekInput;timeStartLabel;timeEndLabel;currentSighting=Va.create();sightingAudio=new Wf;soundPreview;player;loopEnabled=!0;highlightedSourceIds=new Set;occludedSourceIds=Mh;enableClickToPlay=!0;fullscreenTarget;messages=D0;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>this.updateFullscreenButton();handlePointerMove=t=>{const e=this.canvasPointFromEvent(t),n=e&&this.currentSighting.timeline.hitTest(this.currentTime,e.x,e.y,this.occludedSourceIds);if(!n?.shape.title){this.tooltip.hidden=!0;return}this.tooltip.textContent=n.shape.title,this.tooltip.hidden=!1;const s=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-s.left+12}px`,this.tooltip.style.top=`${t.clientY-s.top+12}px`};handlePointerLeave=()=>{this.tooltip.hidden=!0};constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${pf}</style>${ff}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Gf(this.canvas.getContext("2d")),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.playPauseButton=this.shadow.getElementById("play-pause"),this.loopButton=this.shadow.getElementById("loop"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.seekInput=this.shadow.getElementById("seek"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end");for(const e of[this.timeStartLabel,this.timeEndLabel])e.addEventListener("click",()=>this.toggleTimeDisplay()),e.addEventListener("keydown",n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),this.toggleTimeDisplay())});this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.loopButton.addEventListener("click",()=>this.toggleLoop()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.seekInput.addEventListener("input",()=>this.player.seek(Number(this.seekInput.value))),this.canvas.addEventListener("click",()=>{this.enableClickToPlay&&this.togglePlayPause()}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.refresh(),this.loadLocaleMessages()}connectedCallback(){const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sightingAudio.dispose()}attributeChangedCallback(t,e,n){t==="src"&&n&&n!==e&&this.isConnected&&this.loadFromSrc(n)}async loadFromSrc(t){const e=await fetch(t);this.sightingData=await e.json()}get sightingData(){return Xf(this.currentSighting)}set sightingData(t){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=qf(t),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh()}get sighting(){return this.currentSighting}previewSound(t){this.soundPreview=t,this.sightingAudio.resume(),this.sightingAudio.setSound(t)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(t){this.player.seek(t)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}get positionLabel(){return this.timeStartLabel.textContent??""}get durationLabel(){return this.timeEndLabel.textContent??""}get showingClockTime(){return this.canShowClockTime}get canSwitchTimeDisplay(){return this.realStartMs!==void 0}toggleTimeDisplay(){this.canSwitchTimeDisplay&&(this.showClockTime=!this.showClockTime,this.updateTimeLabels(),this.updateTimeLabelTitles(),this.dispatchEvent(new CustomEvent("timedisplaychange",{bubbles:!0,composed:!0})))}get canShowClockTime(){return this.realStartMs!==void 0&&this.showClockTime}set showToolbar(t){this.toolbar.classList.toggle("hidden",!t)}get playbackState(){return this.player.playbackState}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(t){this.currentSighting.event.durationSeconds=t,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(t){const e=new Set(t);e.size===this.highlightedSourceIds.size&&[...e].every(s=>this.highlightedSourceIds.has(s))||(this.highlightedSourceIds=e,this.refresh())}setOccludedSourceIds(t){t.size===this.occludedSourceIds.size&&[...t].every(n=>this.occludedSourceIds.has(n))||(this.occludedSourceIds=t,this.refresh())}hasVisibleShapeAt(t,e){return this.currentSighting.timeline.hitTest(this.currentTime,t,e,this.occludedSourceIds)!==void 0}refresh(){this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.player.seek(this.player.time)}canvasPointFromEvent(t){const e=this.canvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return{x:(t.clientX-e.left)/e.width*this.canvas.width,y:(t.clientY-e.top)/e.height*this.canvas.height}}onFrame(t,e){this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const n=this.playbackState!=="playing"?this.highlightedSourceIds:Mh;for(const[s,r]of e){if(this.occludedSourceIds.has(s))continue;const a=n.has(s);a&&n.size===1?this.canvasRenderer.paintShape({...r,selected:!0}):(this.canvasRenderer.paintShape(r),a&&this.canvasRenderer.paintMemberOutline(r))}if(n.size>1){const s=nn.groupBoundsFor([...e].filter(([r])=>n.has(r)).map(([,r])=>r.bounds));this.canvasRenderer.paintGroupHandles(s)}this.seekInput.value=String(t),this.timeStartLabel.textContent=this.formatPosition(t),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(Nf(this.currentSighting,t))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:t}}))}createPlayer(){const t=new Uf(this.currentSighting.timeline,(e,n)=>this.onFrame(e,n));return t.loop=this.loopEnabled,t}togglePlayPause(){this.player.seekableDuration<=0||(this.player.playbackState==="playing"?(this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh()):(this.sightingAudio.resume(),this.player.play()),this.updatePlayPauseButton())}updatePlayPauseButton(){const t=this.player.playbackState==="playing";this.playPauseButton.textContent=t?"⏸":"▶";const e=this.player.seekableDuration>0;this.playPauseButton.disabled=!e;const n=e?t?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=n,this.playPauseButton.setAttribute("aria-label",n),this.toolbar.classList.toggle("auto-hide",t),this.fullscreenButton.classList.toggle("auto-hide",t)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.loopButton.setAttribute("aria-pressed",String(this.loopEnabled)),this.player.loop=this.loopEnabled}toggleFullscreen(){document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(t=>{console.error("<rr0-ufo>: requestFullscreen() failed —",t)})}updateFullscreenButton(){const t=document.fullscreenElement===this.fullscreenTarget;this.fullscreenButton.title=t?this.messages.exitFullscreen:this.messages.fullscreen,this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}async loadLocaleMessages(){const t=wl(navigator.languages,Zf);t!=="en"&&this.applyMessages(await Jf(t))}updateTimeLabelTitles(){const t=this.showClockTime?this.messages.switchToElapsed:this.messages.switchToClockTime,e=this.canSwitchTimeDisplay?` — ${t}`:"";this.timeStartLabel.title=this.messages.currentPosition+e,this.timeEndLabel.title=this.messages.duration+e;for(const n of[this.timeStartLabel,this.timeEndLabel])n.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(n.setAttribute("role","button"),n.setAttribute("tabindex","0")):(n.removeAttribute("role"),n.removeAttribute("tabindex"))}applyMessages(t){this.messages=t,this.updateTimeLabelTitles(),this.loopButton.title=t.autoReplay,this.loopButton.setAttribute("aria-label",t.autoReplay),this.updatePlayPauseButton(),this.updateFullscreenButton()}updateTimeLabels(){const t=this.currentSighting.event,e=Df(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?rc(t.time):void 0;const n=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&n>0?n/this.realDurationMs:1,this.player.durationOverrideMs=n>0?0:this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time),this.updateTimeLabelTitles()}formatPosition(t){if(this.realDurationMs===void 0)return Rr(t);const e=this.currentSighting.timeline.duration,n=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?yh(Sh(this.realStartMs+n)):Rr(n)}formatEndOfTimeline(){return this.realDurationMs===void 0?Rr(this.currentSighting.timeline.duration):this.canShowClockTime?yh(Sh(this.realStartMs+this.realDurationMs)):Rr(this.realDurationMs)}}function Sh(i){const t=new Date(i);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function yh(i){if(i.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return i.second?`${t(i.hour)}:${t(i.minute??0)}:${t(i.second)}`:`${t(i.hour)}:${t(i.minute??0)}`}function Rr(i){const t=Math.round(i/1e3),e=Math.floor(t/60),n=t%60;return`${e}:${String(n).padStart(2,"0")}`}const oc="rr0-ufo";function P0(){customElements.get(oc)||customElements.define(oc,jf)}/**
300
+ `;class tn{static MOON_ANGULAR_WIDTH_DEG=.5237;static CANVAS_WIDTH_PX=640;static CANVAS_HEIGHT_PX=360;static angularWidthDeg(t){return 2*Math.atan(t.sizeM/(2*t.distanceM))*180/Math.PI}static inMoons(t){return t/tn.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(t,e,n){if(!(!t||!e))return{widthDeg:t.widthDeg+(e.widthDeg-t.widthDeg)*n,heightDeg:t.heightDeg+(e.heightDeg-t.heightDeg)*n}}static sizeMAt(t,e){return 2*t*Math.tan(e*Math.PI/360)}static distanceMAt(t,e){return t/(2*Math.tan(e*Math.PI/360))}}function yf(i,t,e){const{bounds:n}=i;return t>=n.x&&t<=n.x+n.width&&e>=n.y&&e<=n.y+n.height}function gn(i,t,e){return i+(t-i)*e}function gh(i){const t=/^#([0-9a-f]{6})$/i.exec(i);if(!t)return;const e=parseInt(t[1],16);return[e>>16&255,e>>8&255,e&255]}function Ef(i){return`#${i.map(t=>Math.round(t).toString(16).padStart(2,"0")).join("")}`}function bf(i,t,e){const n=gh(i),s=gh(t);return!n||!s?e<1?i:t:Ef([gn(n[0],s[0],e),gn(n[1],s[1],e),gn(n[2],s[2],e)])}function Af(i,t,e){const n={x:gn(i.bounds.x,t.bounds.x,e),y:gn(i.bounds.y,t.bounds.y,e),width:gn(i.bounds.width,t.bounds.width,e),height:gn(i.bounds.height,t.bounds.height,e)},s=gn(i.angle,t.angle,e),r=gn(i.transparency,t.transparency,e),a=gn(i.haloScale,t.haloScale,e),o=bf(i.color,t.color,e),c=tn.lerpAngular(i.angular,t.angular,e);return i.kind==="polygon"&&t.kind==="polygon"&&i.points.length===t.points.length?{...i,bounds:n,angle:s,transparency:r,haloScale:a,color:o,angular:c,behindCloud:e<1?i.behindCloud:t.behindCloud,points:i.points.map((l,h)=>({x:gn(l.x,t.points[h].x,e),y:gn(l.y,t.points[h].y,e)}))}:{...e<1?i:t,bounds:n,angle:s,transparency:r,haloScale:a,color:o,angular:c}}class $a{keyframes=[];order=[];groups=[];addKeyframe(t,e){const n=this.findInsertIndex(t);if(this.keyframes[n]?.t===t){const s=new Set(e.map(r=>r.sourceId));this.keyframes[n]={t,shapes:[...this.keyframes[n].shapes.filter(r=>!s.has(r.sourceId)),...e]}}else this.keyframes.splice(n,0,{t,shapes:[...e]});for(const s of e)this.order.includes(s.sourceId)||this.order.push(s.sourceId)}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const s=e+n>>>1;this.keyframes[s].t<t?e=s+1:n=s}return e}getKeyframeAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e];return n?.t===t?n:void 0}getShapeAt(t,e){return this.getKeyframeAt(t)?.shapes.find(n=>n.sourceId===e)?.shape}getLatestShapeAt(t,e){let n=this.findInsertIndex(t);for(this.keyframes[n]?.t!==t&&(n-=1);n>=0;n--){const s=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(s)return s.shape}}getInterpolatedShapeAt(t,e){const n=this.findShapeAtOrBefore(t,e);if(n?.t===t)return n.shape;const s=this.findShapeAtOrAfter(t,e);return n?s?Af(n.shape,s.shape,(t-n.t)/(s.t-n.t)):n.shape:s?.shape}findShapeAtOrBefore(t,e){let n=this.findInsertIndex(t);for(this.keyframes[n]?.t!==t&&(n-=1);n>=0;n--){const s=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(s)return{t:this.keyframes[n].t,shape:s.shape}}}findShapeAtOrAfter(t,e){for(let n=this.findInsertIndex(t);n<this.keyframes.length;n++){const s=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(s)return{t:this.keyframes[n].t,shape:s.shape}}}hitTest(t,e,n,s){const r=this.sourceIds;for(let a=r.length-1;a>=0;a--){if(s?.has(r[a]))continue;const o=this.getInterpolatedShapeAt(t,r[a]);if(o&&yf(o,e,n))return{sourceId:r[a],shape:o}}}removeSource(t){for(let e=this.keyframes.length-1;e>=0;e--){const n=this.keyframes[e].shapes.filter(s=>s.sourceId!==t);n.length===0?this.keyframes.splice(e,1):n.length!==this.keyframes[e].shapes.length&&(this.keyframes[e]={t:this.keyframes[e].t,shapes:n})}this.order=this.order.filter(e=>e!==t),this.removeFromGroup(t)}group(t){if(!(t.length<2)){for(const e of t)this.removeFromGroup(e);this.groups.push([...t])}}ungroup(t){const e=this.groups.findIndex(n=>n.includes(t));e!==-1&&this.groups.splice(e,1)}groupMembers(t){return this.groups.find(e=>e.includes(t))}removeFromGroup(t){const e=this.groups.findIndex(s=>s.includes(t));if(e===-1)return;const n=this.groups[e].filter(s=>s!==t);n.length<2?this.groups.splice(e,1):this.groups[e]=n}bringToFront(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.push(t))}sendToBack(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.unshift(t))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get sourceIds(){return[...this.order]}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes,order:this.order,groups:this.groups}}static fromJSON(t){const e=new $a;for(const n of t.keyframes)e.addKeyframe(n.t,n.shapes);if(t.order){const n=e.order.filter(s=>!t.order.includes(s));e.order=[...t.order,...n]}return t.groups&&(e.groups=t.groups.map(n=>n.filter(s=>e.order.includes(s))).filter(n=>n.length>=2)),e}}function Tf(i,t,e){return Math.max(t,Math.min(e,i))}function wf(i,t,e){const n=((t-i)%360+540)%360-180;return((i+n*e)%360+360)%360}function Ks(i,t,e){return i+(t-i)*e}function Rf(i,t,e){return{lat:i.lat===void 0||t.lat===void 0?void 0:Ks(i.lat,t.lat,e),lng:i.lng===void 0||t.lng===void 0?void 0:Ks(i.lng,t.lng,e),elevationM:Ks(i.elevationM,t.elevationM,e),headingDeg:i.headingDeg===void 0||t.headingDeg===void 0?void 0:wf(i.headingDeg,t.headingDeg,e),pitchDeg:Ks(i.pitchDeg,t.pitchDeg,e),fovDeg:Ks(i.fovDeg,t.fovDeg,e)}}class vr{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);this.keyframes[n]?.t===t?this.keyframes[n]={t,pose:e}:this.keyframes.splice(n,0,{t,pose:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const s=e+n>>>1;this.keyframes[s].t<t?e=s+1:n=s}return e}getLatestPoseAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].pose:void 0}getInterpolatedPoseAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(n?.t===t)return n.pose;const s=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return n?s?Rf(n.pose,s.pose,Tf((t-n.t)/(s.t-n.t),0,1)):n.pose:s?.pose}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new vr;for(const n of t.keyframes)e.addKeyframe(n.t,n.pose);return e}}function ui(i,t,e){return i+(t-i)*e}function Cf(i,t,e){const n=((t-i)%360+540)%360-180;return((i+n*e)%360+360)%360}function Df(i,t,e){return Math.max(t,Math.min(e,i))}function Pf(i,t,e){return{cloudCover:ui(i.cloudCover,t.cloudCover,e),cloudDarkness:ui(i.cloudDarkness,t.cloudDarkness,e),highCloudCover:i.highCloudCover===void 0||t.highCloudCover===void 0?void 0:ui(i.highCloudCover,t.highCloudCover,e),iceCrystalAlignment:i.iceCrystalAlignment===void 0||t.iceCrystalAlignment===void 0?void 0:ui(i.iceCrystalAlignment,t.iceCrystalAlignment,e),lowerCloudCover:i.lowerCloudCover===void 0||t.lowerCloudCover===void 0?void 0:ui(i.lowerCloudCover,t.lowerCloudCover,e),cloudBaseM:i.cloudBaseM===void 0||t.cloudBaseM===void 0?void 0:ui(i.cloudBaseM,t.cloudBaseM,e),precipitationType:e<1?i.precipitationType:t.precipitationType,precipitationIntensity:ui(i.precipitationIntensity,t.precipitationIntensity,e),windDirectionDeg:Cf(i.windDirectionDeg,t.windDirectionDeg,e),windSpeed:ui(i.windSpeed,t.windSpeed,e),storm:e<1?i.storm:t.storm}}class xr{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);this.keyframes[n]?.t===t?this.keyframes[n]={t,weather:e}:this.keyframes.splice(n,0,{t,weather:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const s=e+n>>>1;this.keyframes[s].t<t?e=s+1:n=s}return e}getLatestWeatherAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].weather:void 0}getInterpolatedWeatherAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(n?.t===t)return n.weather;const s=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return n?s?Pf(n.weather,s.weather,Df((t-n.t)/(s.t-n.t),0,1)):n.weather:s?.weather}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new xr;for(const n of t.keyframes)e.addKeyframe(n.t,n.weather);return e}}class Mr{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);this.keyframes[n]?.t===t?this.keyframes[n]={t,sound:e}:this.keyframes.splice(n,0,{t,sound:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}getLatestSoundAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].sound:void 0}getInterpolatedSoundAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(n?.t===t)return n.sound;const s=this.keyframes[e]?.t===t?void 0:this.keyframes[e];if(!n)return s?.sound;if(!s)return n.sound;const r=(t-n.t)/(s.t-n.t);return this.lerp(n.sound,s.sound,Math.max(0,Math.min(1,r)))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new Mr;for(const n of t.keyframes)e.addKeyframe(n.t,n.sound);return e}lerp(t,e,n){return{kind:n<1?t.kind:e.kind,volume:t.volume+(e.volume-t.volume)*n,pitchHz:t.pitchHz+(e.pitchHz-t.pitchHz)*n,src:n<1?t.src:e.src}}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const s=e+n>>>1;this.keyframes[s].t<t?e=s+1:n=s}return e}}const N0=1e3,If=.65,U0={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,storm:!1},Lf=100,Nf={kind:"none",volume:0,pitchHz:Lf},_h=[{id:"eye",name:"Naked eye",projection:"equidistant"},{id:"rectilinear-lens",name:"Camera, rectilinear lens",projection:"rectilinear",apertureBlades:6}];class F0{static get default(){return _h[0]}static byId(t){return _h.find(e=>e.id===t)??this.default}static starPointsOf(t){const e=t.apertureBlades;return e===void 0||e<3?0:e%2===0?e:e*2}}function dc(i){if(i.year!==void 0)return Date.UTC(i.year,(i.month??1)-1,i.day??1,i.hour??0,i.minute??0,i.second??0)}function vh(i){return(((i.day??0)*24+(i.hour??0))*60+(i.minute??0))*6e4+(i.second??0)*1e3}const Uf=["year","month","day","hour","minute"],Ff=["day","hour","minute"];function xh(i,t){return t.filter(e=>i[e]!==void 0).join(",")}function Of(i){if(i.durationSeconds!==void 0)return i.durationSeconds*1e3;if(!i.time||!i.endTime)return;const t=i.time.year!==void 0&&i.endTime.year!==void 0,e=t?Uf:Ff,n=xh(i.time,e);if(!(n===""||n!==xh(i.endTime,e)))return t?dc(i.endTime)-dc(i.time):vh(i.endTime)-vh(i.time)}class Ja{constructor(t,e,n,s,r,a,o,c,l=[],h,u){this.event=t,this.timeline=e,this.witnessTrack=n,this.weatherTrack=s,this.soundTrack=r,this.witness=a,this.caseId=o,this.weather=c,this.decor=l,this.weatherSource=h,this.instrumentId=u}get instrument(){return F0.byId(this.instrumentId)}static create(t,e,n){return new Ja({eventType:"sighting",time:t,place:e},new $a,new vr,new xr,new Mr,n)}}const zf=0,Bf=0,kf=60;function mr(i,t){const e=i.witnessTrack.getInterpolatedPoseAt(t);if(e)return e;const n=i.event.place?.[0];if(n)return{lat:n.lat,lng:n.lng,elevationM:zf,headingDeg:void 0,pitchDeg:Bf,fovDeg:kf}}function Mh(i,t){return i.weatherTrack.getInterpolatedWeatherAt(t)??i.weather??U0}function Gf(i,t){return i.soundTrack.getInterpolatedSoundAt(t)??Nf}class Hf{constructor(t,e){this.timeline=t,this.onFrame=e}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;durationOverrideMs=0;get seekableDuration(){return Math.max(this.timeline.duration,this.durationOverrideMs)}play(){if(this.state==="playing")return;this.currentT>=this.seekableDuration&&(this.currentT=0,this.resolveFrame(0)),this.state="playing",this.lastWallTime=performance.now();const t=()=>{if(this.state!=="playing")return;const e=performance.now();if(this.currentT+=(e-this.lastWallTime)*this.playbackRate,this.lastWallTime=e,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT);return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}pause(){this.state==="playing"&&(this.state="paused",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null))}stop(){this.state="stopped",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}seek(t){this.currentT=Math.max(0,Math.min(t,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(t){const e=new Map;for(const n of this.timeline.sourceIds){const s=this.timeline.getInterpolatedShapeAt(t,n);s&&e.set(n,s)}this.onFrame(t,e)}}const O0=["nw","n","ne","e","se","s","sw","w"],Vf=24,Pr=8,Wf=3,Xf=8;function Ir(i,t,e){const n=i.x-t.x,s=i.y-t.y,r=Math.cos(e),a=Math.sin(e);return{x:t.x+n*r-s*a,y:t.y+n*a+s*r}}function Zs(i){return{x:i.x+i.width/2,y:i.y+i.height/2}}const qf={nw:{left:!0,top:!0},n:{top:!0},ne:{right:!0,top:!0},e:{right:!0},se:{right:!0,bottom:!0},s:{bottom:!0},sw:{left:!0,bottom:!0},w:{left:!0}};class on{static handlePointsFor(t){const{x:e,y:n,width:s,height:r}=t.bounds,a={nw:{x:e,y:n},n:{x:e+s/2,y:n},ne:{x:e+s,y:n},e:{x:e+s,y:n+r/2},se:{x:e+s,y:n+r},s:{x:e+s/2,y:n+r},sw:{x:e,y:n+r},w:{x:e,y:n+r/2},rotate:{x:e+s/2,y:n-Vf}},o=Zs(t.bounds),c={};for(const l of Object.keys(a))c[l]=Ir(a[l],o,t.angle);return c}static hitTestHandle(t,e,n=8,s=[...O0,"rotate"]){const r=on.handlePointsFor(t);for(const a of s)if(Math.hypot(e.x-r[a].x,e.y-r[a].y)<=n)return a}static HANDLE_DIRECTION_DEG={e:0,se:45,s:90,sw:135,w:180,nw:225,n:270,ne:315};static resizeAxisFor(t,e){const s=((on.HANDLE_DIRECTION_DEG[t]+e*180/Math.PI)%180+180)%180/45,r=["ew","nwse","ns","nesw"];return r[Math.round(s)%r.length]}static resizeBounds(t,e,n,s){const r=Zs(t),a=Ir(s,r,-e),{x:o,y:c,width:l,height:h}=t,u=qf[n];let d=o,f=c,g=o+l,x=c+h;return u.left&&(d=Math.min(a.x,g-Pr)),u.right&&(g=Math.max(a.x,d+Pr)),u.top&&(f=Math.min(a.y,x-Pr)),u.bottom&&(x=Math.max(a.y,f+Pr)),{x:d,y:f,width:g-d,height:x-f}}static resizeShape(t,e,n){if(e==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:s,height:r}=t.bounds,a=on.resizeBounds(t.bounds,t.angle,e,n);if(t.kind==="oval")return{...t,bounds:a};const o=s===0?1:a.width/s,c=r===0?1:a.height/r;return{...t,bounds:a,points:t.points.map(l=>({x:l.x*o,y:l.y*c}))}}static rotateShape(t,e){const n=Zs(t.bounds),s=Math.atan2(e.y-n.y,e.x-n.x)+Math.PI/2;return{...t,angle:s}}static groupBoundsFor(t){const e=Math.min(...t.map(a=>a.x)),n=Math.min(...t.map(a=>a.y)),s=Math.max(...t.map(a=>a.x+a.width)),r=Math.max(...t.map(a=>a.y+a.height));return{x:e,y:n,width:s-e,height:r-n}}static vertexPointsFor(t){const e=Zs(t.bounds);return t.points.map(n=>Ir({x:t.bounds.x+n.x,y:t.bounds.y+n.y},e,t.angle))}static hitTestVertex(t,e,n=Xf){const s=on.vertexPointsFor(t);let r,a=n;return s.forEach((o,c)=>{const l=Math.hypot(e.x-o.x,e.y-o.y);l<=a&&(a=l,r=c)}),r}static toLocalPoint(t,e){const n=Zs(t.bounds),s=Ir(e,n,-t.angle);return{x:s.x-t.bounds.x,y:s.y-t.bounds.y}}static moveVertex(t,e,n){const s=t.points.map((u,d)=>d===e?on.toLocalPoint(t,n):u),r=Math.min(...s.map(u=>u.x)),a=Math.min(...s.map(u=>u.y)),o=Math.max(...s.map(u=>u.x)),c=Math.max(...s.map(u=>u.y)),l={x:t.bounds.x+r,y:t.bounds.y+a,width:o-r,height:c-a},h=s.map(u=>({x:u.x-r,y:u.y-a}));return{...t,bounds:l,points:h}}static insertVertexNear(t,e){const n=on.toLocalPoint(t,e),{points:s}=t;let r=s.length-1,a=1/0;for(let c=0;c<s.length;c++){const l=s[c],h=s[(c+1)%s.length],u=on.distanceToSegment(n,l,h);u<a&&(a=u,r=c)}const o=[...s.slice(0,r+1),n,...s.slice(r+1)];return{...t,points:o}}static distanceToSegment(t,e,n){const s=n.x-e.x,r=n.y-e.y,a=s*s+r*r,o=a===0?0:Math.max(0,Math.min(1,((t.x-e.x)*s+(t.y-e.y)*r)/a)),c=e.x+o*s,l=e.y+o*r;return Math.hypot(t.x-c,t.y-l)}static deleteVertex(t,e){return t.points.length<=Wf?t:{...t,points:t.points.filter((n,s)=>s!==e)}}}const fc=6,Lr=fc/2,Yf=20,Sh=4;class Kf{constructor(t){this.ctx=t}clear(t,e){this.ctx.clearRect(0,0,t,e)}paintShape(t){this.ctx.save(),this.ctx.globalAlpha=1-t.transparency,t.haloScale>0&&this.paintHalo(t),this.paintBase(t),this.ctx.restore(),t.selected&&this.paintSelectionHandles(t)}paintBase(t){if(this.ctx.fillStyle=t.color,this.ctx.beginPath(),t.kind==="oval"){const{x:e,y:n,width:s,height:r}=t.bounds,a=s/2,o=r/2;this.ctx.ellipse(e+a,n+o,a,o,t.angle,0,2*Math.PI)}else{const{x:e,y:n,width:s,height:r}=t.bounds;this.ctx.save(),this.ctx.translate(e+s/2,n+r/2),this.ctx.rotate(t.angle),this.ctx.translate(-s/2,-r/2),t.points.forEach((a,o)=>{o===0?this.ctx.moveTo(a.x,a.y):this.ctx.lineTo(a.x,a.y)}),this.ctx.closePath(),this.ctx.restore()}this.ctx.fill()}paintHalo(t){this.ctx.save(),this.ctx.shadowColor=t.color,this.ctx.shadowBlur=Yf*t.haloScale,this.paintBase(t),this.ctx.restore()}paintSelectionHandles(t){this.paintHandleFrame(on.handlePointsFor(t),{includeRotate:!0}),t.kind==="polygon"&&this.paintVertexHandles(t)}paintVertexHandles(t){this.ctx.fillStyle="#39f";for(const e of on.vertexPointsFor(t))this.ctx.beginPath(),this.ctx.ellipse(e.x,e.y,Sh,Sh,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(t){this.paintOutline(on.handlePointsFor(t))}paintGroupHandles(t){this.paintHandleFrame(on.handlePointsFor({bounds:t,angle:0}),{includeRotate:!0})}paintOutline(t){this.ctx.strokeStyle="lightgray",this.ctx.beginPath(),this.ctx.moveTo(t.nw.x,t.nw.y),this.ctx.lineTo(t.ne.x,t.ne.y),this.ctx.lineTo(t.se.x,t.se.y),this.ctx.lineTo(t.sw.x,t.sw.y),this.ctx.closePath(),this.ctx.stroke()}paintHandleFrame(t,{includeRotate:e}){this.paintOutline(t),this.ctx.fillStyle="lightgray";for(const n of O0){const s=t[n];this.ctx.fillRect(s.x-Lr,s.y-Lr,fc,fc)}e&&(this.ctx.beginPath(),this.ctx.moveTo(t.n.x,t.n.y),this.ctx.lineTo(t.rotate.x,t.rotate.y),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.ellipse(t.rotate.x,t.rotate.y,Lr+1,Lr+1,0,0,2*Math.PI),this.ctx.fill())}}const yh=.05,Eh=.08,bh=2,Ah=3,Zf=14,$f=.02;class Jf{context;voice;voiceToken=0;buffers=new Map;noiseBuffer;crackleBuffer;requested;resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("SightingAudio: Web Audio unavailable, the sighting stays silent:",t);return}}this.context.state==="suspended"&&this.context.resume()}setSound(t){if(this.requested=t,!this.context)return;const e=this.keyFor(t);if(!e){this.silence();return}if(this.voice?.key!==e){this.stopVoice();const n=++this.voiceToken;e.startsWith("src:")?this.buildRecordedVoice(t.src,e,n):this.voice=this.buildSynthesizedVoice(t,e)}this.applyTo(this.voice,t)}silence(){this.voiceToken++,this.stopVoice()}dispose(){this.silence(),this.context?.close(),this.context=void 0,this.buffers.clear(),this.noiseBuffer=void 0,this.crackleBuffer=void 0}keyFor(t){if(!(t.volume<=0))return t.src?`src:${t.src}`:t.kind==="none"?void 0:t.kind}applyTo(t,e){const n=this.context;if(!t||!n)return;const s=n.currentTime;t.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,e.volume))*t.gainScale,s,yh);for(const{param:r,ratio:a}of t.pitch)r.setTargetAtTime(Math.min(e.pitchHz*a,n.sampleRate/2-1),s,yh)}buildSynthesizedVoice(t,e){const n=this.context;if(n)switch(t.kind){case"hum":return this.buildHum(n,e);case"whistle":return this.buildWhistle(n,e);case"rumble":return this.buildRumble(n,e);case"crackle":return this.buildCrackle(n,e);default:return}}buildHum(t,e){const n=t.createOscillator();n.type="sawtooth";const s=t.createOscillator();s.type="sawtooth";const r=t.createBiquadFilter();r.type="lowpass",r.Q.value=1;const a=t.createGain();return a.gain.value=0,n.connect(r),s.connect(r),r.connect(a).connect(t.destination),n.start(),s.start(),{key:e,nodes:[r,a],sources:[n,s],volumeParam:a.gain,gainScale:.16,pitch:[{param:n.frequency,ratio:1},{param:s.frequency,ratio:1.006},{param:r.frequency,ratio:6}]}}buildWhistle(t,e){const n=t.createOscillator();n.type="sine";const s=t.createOscillator();s.type="sine",s.frequency.value=5;const r=t.createGain(),a=t.createGain();return a.gain.value=0,s.connect(r).connect(n.frequency),n.connect(a).connect(t.destination),n.start(),s.start(),{key:e,nodes:[r,a],sources:[n,s],volumeParam:a.gain,gainScale:.22,pitch:[{param:n.frequency,ratio:1},{param:r.gain,ratio:.012}]}}buildRumble(t,e){const n=t.createBufferSource();n.buffer=this.brownNoise(t),n.loop=!0;const s=t.createBiquadFilter();s.type="lowpass",s.Q.value=.8;const r=t.createGain();return r.gain.value=0,n.connect(s).connect(r).connect(t.destination),n.start(),{key:e,nodes:[s,r],sources:[n],volumeParam:r.gain,gainScale:1.4,pitch:[{param:s.frequency,ratio:1}]}}buildCrackle(t,e){const n=t.createBufferSource();n.buffer=this.whiteNoise(t),n.loop=!0;const s=t.createBiquadFilter();s.type="bandpass",s.Q.value=1.2;const r=t.createGain();r.gain.value=0;const a=t.createBufferSource();a.buffer=this.crackleEnvelope(t),a.loop=!0;const o=t.createGain();return o.gain.value=0,a.connect(o).connect(r.gain),n.connect(s).connect(r).connect(t.destination),n.start(),a.start(),{key:e,nodes:[s,r,o],sources:[n,a],volumeParam:o.gain,gainScale:.9,pitch:[{param:s.frequency,ratio:4}]}}async buildRecordedVoice(t,e,n){const s=this.context;if(!s)return;let r;try{r=await this.getBuffer(t)}catch(c){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",c);return}if(n!==this.voiceToken||!this.context)return;const a=s.createBufferSource();a.buffer=r,a.loop=!0;const o=s.createGain();o.gain.value=0,a.connect(o).connect(s.destination),a.start(),this.voice={key:e,nodes:[o],sources:[a],volumeParam:o.gain,gainScale:1,pitch:[]},this.requested&&this.applyTo(this.voice,this.requested)}async getBuffer(t){const e=this.context;if(!e)throw new Error("SightingAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(t);return n||(n=fetch(t).then(s=>{if(!s.ok)throw new Error(`Audio fetch failed (${s.status}): ${t}`);return s.arrayBuffer()}).then(s=>e.decodeAudioData(s)),this.buffers.set(t,n)),n}whiteNoise(t){if(!this.noiseBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*bh),t.sampleRate),n=e.getChannelData(0);for(let s=0;s<n.length;s++)n[s]=Math.random()*2-1;this.noiseBuffer=e}return this.noiseBuffer}brownNoise(t){const e=t.createBuffer(1,Math.floor(t.sampleRate*bh),t.sampleRate),n=e.getChannelData(0);let s=0,r=0;for(let a=0;a<n.length;a++)s=(s+.02*(Math.random()*2-1))/1.02,n[a]=s,r=Math.max(r,Math.abs(s));if(r>0)for(let a=0;a<n.length;a++)n[a]/=r;return e}crackleEnvelope(t){if(!this.crackleBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*Ah),t.sampleRate),n=e.getChannelData(0),s=Math.max(1,Math.floor($f*t.sampleRate)),r=Math.round(Ah*Zf);for(let a=0;a<r;a++){const o=Math.floor(Math.random()*n.length),c=.4+Math.random()*.6;for(let l=0;l<s&&o+l<n.length;l++)n[o+l]=Math.max(n[o+l],c*(1-l/s))}this.crackleBuffer=e}return this.crackleBuffer}stopVoice(){const t=this.voice,e=this.context;if(this.voice=void 0,!t||!e)return;const n=e.currentTime;t.volumeParam.cancelScheduledValues(n),t.volumeParam.setTargetAtTime(0,n,Eh/3);const s=n+Eh;for(const r of t.sources){r.onended=()=>{r.disconnect();for(const a of t.nodes)a.disconnect()};try{r.stop(s)}catch{r.disconnect();for(const a of t.nodes)a.disconnect()}}}}const lo=Math.PI/180,Nr=180/Math.PI;class Ps{constructor(t,e,n){this.kind=t,this.canvasHeightPx=e,this.fovDeg=n;const s=n*lo/2;this.focalPx=t==="equidistant"?e/2/s:e/2/Math.tan(s)}focalPx;static of(t,e,n){return new Ps(t.projection,e,n)}degToPx(t){const e=t*lo;return this.kind==="equidistant"?this.focalPx*e:2*this.focalPx*Math.tan(e/2)}pxToDeg(t){return this.kind==="equidistant"?t/this.focalPx*Nr:2*Math.atan(t/(2*this.focalPx))*Nr}angleDegToRadiusPx(t){const e=t*lo;return this.kind==="equidistant"?this.focalPx*e:this.focalPx*Math.tan(e)}radiusPxToAngleDeg(t){return this.kind==="equidistant"?t/this.focalPx*Nr:Math.atan(t/this.focalPx)*Nr}ofBounds(t){return{widthDeg:this.pxToDeg(t.width),heightDeg:this.pxToDeg(t.height)}}toBoundsSize(t){return{width:this.degToPx(t.widthDeg),height:this.degToPx(t.heightDeg)}}widthPx(t){return this.degToPx(tn.angularWidthDeg(t))}}class Ll{static DEFAULT_FOV_DEG=60;static toAngular(t){this.eachKeyframe(t,(e,n)=>({...e,angular:n.ofBounds(e.bounds)}))}static toBounds(t){this.eachKeyframe(t,(e,n)=>{if(!e.angular)return e;const{width:s,height:r}=n.toBoundsSize(e.angular),a={x:e.bounds.x+(e.bounds.width-s)/2,y:e.bounds.y+(e.bounds.height-r)/2,width:s,height:r};if(e.kind!=="polygon")return{...e,bounds:a};const o=e.bounds.width===0?1:s/e.bounds.width,c=e.bounds.height===0?1:r/e.bounds.height;return{...e,bounds:a,points:e.points.map(l=>({x:l.x*o,y:l.y*c}))}})}static reproject(t,e){const n=tn.CANVAS_WIDTH_PX/2,s=tn.CANVAS_HEIGHT_PX/2;for(const r of[...t.timeline.allKeyframes]){const a=mr(t,r.t)?.fovDeg??this.DEFAULT_FOV_DEG,o=Ps.of(e,tn.CANVAS_HEIGHT_PX,a),c=Ps.of(t.instrument,tn.CANVAS_HEIGHT_PX,a);t.timeline.addKeyframe(r.t,r.shapes.map(l=>{const{bounds:h}=l.shape,u=h.x+h.width/2-n,d=h.y+h.height/2-s,f=Math.hypot(u,d);if(f===0)return l;const g=c.angleDegToRadiusPx(o.radiusPxToAngleDeg(f))/f,x={...h,x:n+u*g-h.width/2,y:s+d*g-h.height/2};return{...l,shape:{...l.shape,bounds:x}}}))}this.toBounds(t)}static eachKeyframe(t,e){const{timeline:n}=t;for(const s of[...n.allKeyframes]){const r=mr(t,s.t)?.fovDeg??this.DEFAULT_FOV_DEG,a=Ps.of(t.instrument,tn.CANVAS_HEIGHT_PX,r);n.addKeyframe(s.t,s.shapes.map(o=>({...o,shape:e(o.shape,a)})))}}}function Qf(i){return Ll.toAngular(i),{version:1,time:i.event.time,endTime:i.event.endTime,durationSeconds:i.event.durationSeconds,utcOffsetHours:i.event.utcOffsetHours,timeZone:i.event.timeZone,place:i.event.place,witness:i.witness,caseId:i.caseId,description:i.event.description,tags:i.event.tags,timeline:i.timeline.toJSON(),witnessTrack:i.witnessTrack.toJSON(),weatherTrack:i.weatherTrack.toJSON(),soundTrack:i.soundTrack.toJSON(),weather:i.weather,decor:i.decor,weatherSource:i.weatherSource,instrument:i.instrumentId}}function jf(i){const t=new Ja({eventType:"sighting",time:i.time,endTime:i.endTime,durationSeconds:i.durationSeconds,utcOffsetHours:i.utcOffsetHours,timeZone:i.timeZone,place:i.place,description:i.description,tags:i.tags},$a.fromJSON(i.timeline),i.witnessTrack?vr.fromJSON(i.witnessTrack):new vr,i.weatherTrack?xr.fromJSON(i.weatherTrack):new xr,i.soundTrack?Mr.fromJSON(i.soundTrack):new Mr,i.witness,i.caseId,i.weather,i.decor??[],i.weatherSource,i.instrument);return Ll.toBounds(t),t}function Nl(i,t){for(const e of i){const n=e.toLowerCase().split("-")[0];if(t.includes(n))return n}return"en"}const tp="modulepreload",ep=function(i,t){return new URL(i,t).href},Th={},wh=function(t,e,n){let s=Promise.resolve();if(e&&e.length>0){let a=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};const o=document.getElementsByTagName("link"),c=document.querySelector("meta[property=csp-nonce]"),l=c?.nonce||c?.getAttribute("nonce");s=a(e.map(h=>{if(h=ep(h,n),h in Th)return;Th[h]=!0;const u=h.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(!!n)for(let x=o.length-1;x>=0;x--){const m=o[x];if(m.href===h&&(!u||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${d}`))return;const g=document.createElement("link");if(g.rel=u?"stylesheet":tp,u||(g.as="script"),g.crossOrigin="",g.href=h,l&&g.setAttribute("nonce",l),document.head.appendChild(g),u)return new Promise((x,m)=>{g.addEventListener("load",x),g.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${h}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return t().catch(r)})},np=["en","fr"],ip={en:()=>wh(()=>Promise.resolve().then(()=>rp),void 0,import.meta.url).then(i=>i.ufoMessages_en),fr:()=>wh(()=>import("./UfoMessages_fr-Hq24iVzT.js"),[],import.meta.url).then(i=>i.ufoMessages_fr)};function sp(i){return ip[i]()}const z0={play:"Play",pause:"Pause",noDuration:"No observation duration",autoReplay:"Auto-replay",currentPosition:"Current position",duration:"Duration",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen"},rp=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:z0},Symbol.toStringTag,{value:"Module"})),Rh=new Set;class ap extends HTMLElement{static get observedAttributes(){return["src"]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;loopButton;fullscreenButton;seekInput;timeStartLabel;timeEndLabel;currentSighting=Ja.create();sightingAudio=new Jf;soundPreview;player;loopEnabled=!0;highlightedSourceIds=new Set;occludedSourceIds=Rh;enableClickToPlay=!0;fullscreenTarget;messages=z0;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>this.updateFullscreenButton();handlePointerMove=t=>{const e=this.canvasPointFromEvent(t),n=e&&this.currentSighting.timeline.hitTest(this.currentTime,e.x,e.y,this.occludedSourceIds);if(!n?.shape.title){this.tooltip.hidden=!0;return}this.tooltip.textContent=n.shape.title,this.tooltip.hidden=!1;const s=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-s.left+12}px`,this.tooltip.style.top=`${t.clientY-s.top+12}px`};handlePointerLeave=()=>{this.tooltip.hidden=!0};constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${Sf}</style>${Mf}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Kf(this.canvas.getContext("2d")),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.playPauseButton=this.shadow.getElementById("play-pause"),this.loopButton=this.shadow.getElementById("loop"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.seekInput=this.shadow.getElementById("seek"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end");for(const e of[this.timeStartLabel,this.timeEndLabel])e.addEventListener("click",()=>this.toggleTimeDisplay()),e.addEventListener("keydown",n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),this.toggleTimeDisplay())});this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.loopButton.addEventListener("click",()=>this.toggleLoop()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.seekInput.addEventListener("input",()=>this.player.seek(Number(this.seekInput.value))),this.canvas.addEventListener("click",()=>{this.enableClickToPlay&&this.togglePlayPause()}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.refresh(),this.loadLocaleMessages()}connectedCallback(){const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sightingAudio.dispose()}attributeChangedCallback(t,e,n){t==="src"&&n&&n!==e&&this.isConnected&&this.loadFromSrc(n)}async loadFromSrc(t){const e=await fetch(t);this.sightingData=await e.json()}get sightingData(){return Qf(this.currentSighting)}set sightingData(t){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=jf(t),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh()}get sighting(){return this.currentSighting}previewSound(t){this.soundPreview=t,this.sightingAudio.resume(),this.sightingAudio.setSound(t)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(t){this.player.seek(t)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}get positionLabel(){return this.timeStartLabel.textContent??""}get durationLabel(){return this.timeEndLabel.textContent??""}get showingClockTime(){return this.canShowClockTime}get canSwitchTimeDisplay(){return this.realStartMs!==void 0}toggleTimeDisplay(){this.canSwitchTimeDisplay&&(this.showClockTime=!this.showClockTime,this.updateTimeLabels(),this.updateTimeLabelTitles(),this.dispatchEvent(new CustomEvent("timedisplaychange",{bubbles:!0,composed:!0})))}get canShowClockTime(){return this.realStartMs!==void 0&&this.showClockTime}set showToolbar(t){this.toolbar.classList.toggle("hidden",!t)}get playbackState(){return this.player.playbackState}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(t){this.currentSighting.event.durationSeconds=t,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(t){const e=new Set(t);e.size===this.highlightedSourceIds.size&&[...e].every(s=>this.highlightedSourceIds.has(s))||(this.highlightedSourceIds=e,this.refresh())}setOccludedSourceIds(t){t.size===this.occludedSourceIds.size&&[...t].every(n=>this.occludedSourceIds.has(n))||(this.occludedSourceIds=t,this.refresh())}hasVisibleShapeAt(t,e){return this.currentSighting.timeline.hitTest(this.currentTime,t,e,this.occludedSourceIds)!==void 0}refresh(){this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.player.seek(this.player.time)}canvasPointFromEvent(t){const e=this.canvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return{x:(t.clientX-e.left)/e.width*this.canvas.width,y:(t.clientY-e.top)/e.height*this.canvas.height}}onFrame(t,e){this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const n=this.playbackState!=="playing"?this.highlightedSourceIds:Rh;for(const[s,r]of e){if(this.occludedSourceIds.has(s))continue;const a=n.has(s);a&&n.size===1?this.canvasRenderer.paintShape({...r,selected:!0}):(this.canvasRenderer.paintShape(r),a&&this.canvasRenderer.paintMemberOutline(r))}if(n.size>1){const s=on.groupBoundsFor([...e].filter(([r])=>n.has(r)).map(([,r])=>r.bounds));this.canvasRenderer.paintGroupHandles(s)}this.seekInput.value=String(t),this.timeStartLabel.textContent=this.formatPosition(t),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(Gf(this.currentSighting,t))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:t}}))}createPlayer(){const t=new Hf(this.currentSighting.timeline,(e,n)=>this.onFrame(e,n));return t.loop=this.loopEnabled,t}togglePlayPause(){this.player.seekableDuration<=0||(this.player.playbackState==="playing"?(this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh()):(this.sightingAudio.resume(),this.player.play()),this.updatePlayPauseButton())}updatePlayPauseButton(){const t=this.player.playbackState==="playing";this.playPauseButton.textContent=t?"⏸":"▶";const e=this.player.seekableDuration>0;this.playPauseButton.disabled=!e;const n=e?t?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=n,this.playPauseButton.setAttribute("aria-label",n),this.toolbar.classList.toggle("auto-hide",t),this.fullscreenButton.classList.toggle("auto-hide",t)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.loopButton.setAttribute("aria-pressed",String(this.loopEnabled)),this.player.loop=this.loopEnabled}toggleFullscreen(){document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(t=>{console.error("<rr0-ufo>: requestFullscreen() failed —",t)})}updateFullscreenButton(){const t=document.fullscreenElement===this.fullscreenTarget;this.fullscreenButton.title=t?this.messages.exitFullscreen:this.messages.fullscreen,this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}async loadLocaleMessages(){const t=Nl(navigator.languages,np);t!=="en"&&this.applyMessages(await sp(t))}updateTimeLabelTitles(){const t=this.showClockTime?this.messages.switchToElapsed:this.messages.switchToClockTime,e=this.canSwitchTimeDisplay?` — ${t}`:"";this.timeStartLabel.title=this.messages.currentPosition+e,this.timeEndLabel.title=this.messages.duration+e;for(const n of[this.timeStartLabel,this.timeEndLabel])n.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(n.setAttribute("role","button"),n.setAttribute("tabindex","0")):(n.removeAttribute("role"),n.removeAttribute("tabindex"))}applyMessages(t){this.messages=t,this.updateTimeLabelTitles(),this.loopButton.title=t.autoReplay,this.loopButton.setAttribute("aria-label",t.autoReplay),this.updatePlayPauseButton(),this.updateFullscreenButton()}updateTimeLabels(){const t=this.currentSighting.event,e=Of(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?dc(t.time):void 0;const n=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&n>0?n/this.realDurationMs:1,this.player.durationOverrideMs=n>0?0:this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time),this.updateTimeLabelTitles()}formatPosition(t){if(this.realDurationMs===void 0)return Ur(t);const e=this.currentSighting.timeline.duration,n=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?Dh(Ch(this.realStartMs+n)):Ur(n)}formatEndOfTimeline(){return this.realDurationMs===void 0?Ur(this.currentSighting.timeline.duration):this.canShowClockTime?Dh(Ch(this.realStartMs+this.realDurationMs)):Ur(this.realDurationMs)}}function Ch(i){const t=new Date(i);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function Dh(i){if(i.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return i.second?`${t(i.hour)}:${t(i.minute??0)}:${t(i.second)}`:`${t(i.hour)}:${t(i.minute??0)}`}function Ur(i){const t=Math.round(i/1e3),e=Math.floor(t/60),n=t%60;return`${e}:${String(n).padStart(2,"0")}`}const pc="rr0-ufo";function B0(){customElements.get(pc)||customElements.define(pc,ap)}/**
301
301
  * @license
302
302
  * Copyright 2010-2026 Three.js Authors
303
303
  * SPDX-License-Identifier: MIT
304
- */const Rl="185",tp=0,Eh=1,ep=2,ur=1,np=2,sr=3,Ei=0,Fe=1,Mn=2,ti=0,Cs=1,Xi=2,bh=3,Ah=4,ip=5,Fi=100,sp=101,rp=102,ap=103,op=104,cp=200,lp=201,hp=202,up=203,cc=204,lc=205,dp=206,fp=207,pp=208,mp=209,gp=210,_p=211,vp=212,xp=213,Mp=214,hc=0,uc=1,dc=2,Us=3,fc=4,pc=5,mc=6,gc=7,Cl=0,Sp=1,yp=2,Gn=0,I0=1,L0=2,N0=3,U0=4,F0=5,O0=6,z0=7,B0=300,qi=301,Fs=302,no=303,io=304,Wa=306,_c=1e3,Sn=1001,vc=1002,ze=1003,Ep=1004,Cr=1005,Ne=1006,so=1007,ki=1008,rn=1009,k0=1010,G0=1011,mr=1012,Dl=1013,Vn=1014,zn=1015,bn=1016,Pl=1017,Il=1018,gr=1020,H0=35902,V0=35899,W0=1021,X0=1022,pn=1023,ni=1026,Gi=1027,q0=1028,Ll=1029,Yi=1030,Nl=1031,Ul=1033,Ma=33776,Sa=33777,ya=33778,Ea=33779,xc=35840,Mc=35841,Sc=35842,yc=35843,Ec=36196,bc=37492,Ac=37496,Tc=37488,wc=37489,Ra=37490,Rc=37491,Cc=37808,Dc=37809,Pc=37810,Ic=37811,Lc=37812,Nc=37813,Uc=37814,Fc=37815,Oc=37816,zc=37817,Bc=37818,kc=37819,Gc=37820,Hc=37821,Vc=36492,Wc=36494,Xc=36495,qc=36283,Yc=36284,Ca=36285,Kc=36286,bp=3200,Zc=0,Ap=1,vi="",dn="srgb",Da="srgb-linear",Pa="linear",ee="srgb",es=7680,Th=519,Tp=512,wp=513,Rp=514,Fl=515,Cp=516,Dp=517,Ol=518,Pp=519,$c=35044,wh="300 es",Bn=2e3,_r=2001;function Ip(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function Ia(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Lp(){const i=Ia("canvas");return i.style.display="block",i}const Rh={};function La(...i){const t="THREE."+i.shift();console.log(t,...i)}function Y0(i){const t=i[0];if(typeof t=="string"&&t.startsWith("TSL:")){const e=i[1];e&&e.isStackTrace?i[0]+=" "+e.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Ot(...i){i=Y0(i);const t="THREE."+i.shift();{const e=i[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...i)}}function Yt(...i){i=Y0(i);const t="THREE."+i.shift();{const e=i[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...i)}}function Ds(...i){const t=i.join(" ");t in Rh||(Rh[t]=!0,Ot(...i))}function Np(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)})}const Up={[hc]:uc,[dc]:mc,[fc]:gc,[Us]:pc,[uc]:hc,[mc]:dc,[gc]:fc,[pc]:Us};class Ji{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){const n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){const n=this._listeners;if(n===void 0)return;const s=n[t];if(s!==void 0){const r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const n=e[t.type];if(n!==void 0){t.target=this;const s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,t);t.target=null}}}const Ge=["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"],ro=Math.PI/180,Jc=180/Math.PI;function Si(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Ge[i&255]+Ge[i>>8&255]+Ge[i>>16&255]+Ge[i>>24&255]+"-"+Ge[t&255]+Ge[t>>8&255]+"-"+Ge[t>>16&15|64]+Ge[t>>24&255]+"-"+Ge[e&63|128]+Ge[e>>8&255]+"-"+Ge[e>>16&255]+Ge[e>>24&255]+Ge[n&255]+Ge[n>>8&255]+Ge[n>>16&255]+Ge[n>>24&255]).toLowerCase()}function Xt(i,t,e){return Math.max(t,Math.min(e,i))}function Fp(i,t){return(i%t+t)%t}function ao(i,t,e){return(1-e)*i+e*t}function On(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("THREE.MathUtils: Invalid component type.")}}function se(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("THREE.MathUtils: Invalid component type.")}}class Ft{static{Ft.prototype.isVector2=!0}constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("THREE.Vector2: 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("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,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=Xt(this.x,t.x,e.x),this.y=Xt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Xt(this.x,t,e),this.y=Xt(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Xt(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){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Xt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const 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){const 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}}class ks{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],u=n[s+3],d=r[a+0],p=r[a+1],g=r[a+2],x=r[a+3];if(u!==x||c!==d||l!==p||h!==g){let m=c*d+l*p+h*g+u*x;m<0&&(d=-d,p=-p,g=-g,x=-x,m=-m);let f=1-o;if(m<.9995){const A=Math.acos(m),T=Math.sin(A);f=Math.sin(f*A)/T,o=Math.sin(o*A)/T,c=c*f+d*o,l=l*f+p*o,h=h*f+g*o,u=u*f+x*o}else{c=c*f+d*o,l=l*f+p*o,h=h*f+g*o,u=u*f+x*o;const A=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=A,l*=A,h*=A,u*=A}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,s,r,a){const o=n[s],c=n[s+1],l=n[s+2],h=n[s+3],u=r[a],d=r[a+1],p=r[a+2],g=r[a+3];return t[e]=o*g+h*u+c*p-l*d,t[e+1]=c*g+h*d+l*u-o*p,t[e+2]=l*g+h*p+o*d-c*u,t[e+3]=h*g-o*u-c*d-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){const 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),u=o(r/2),d=c(n/2),p=c(s/2),g=c(r/2);switch(a){case"XYZ":this._x=d*h*u+l*p*g,this._y=l*p*u-d*h*g,this._z=l*h*g+d*p*u,this._w=l*h*u-d*p*g;break;case"YXZ":this._x=d*h*u+l*p*g,this._y=l*p*u-d*h*g,this._z=l*h*g-d*p*u,this._w=l*h*u+d*p*g;break;case"ZXY":this._x=d*h*u-l*p*g,this._y=l*p*u+d*h*g,this._z=l*h*g+d*p*u,this._w=l*h*u-d*p*g;break;case"ZYX":this._x=d*h*u-l*p*g,this._y=l*p*u+d*h*g,this._z=l*h*g-d*p*u,this._w=l*h*u+d*p*g;break;case"YZX":this._x=d*h*u+l*p*g,this._y=l*p*u+d*h*g,this._z=l*h*g-d*p*u,this._w=l*h*u-d*p*g;break;case"XZY":this._x=d*h*u-l*p*g,this._y=l*p*u-d*h*g,this._z=l*h*g+d*p*u,this._w=l*h*u+d*p*g;break;default:Ot("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const 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){const 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],u=e[10],d=n+o+u;if(d>0){const p=.5/Math.sqrt(d+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>u){const p=2*Math.sqrt(1+n-o-u);this._w=(h-c)/p,this._x=.25*p,this._y=(s+a)/p,this._z=(r+l)/p}else if(o>u){const p=2*Math.sqrt(1+o-n-u);this._w=(r-l)/p,this._x=(s+a)/p,this._y=.25*p,this._z=(c+h)/p}else{const p=2*Math.sqrt(1+u-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(Xt(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const 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){const 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){let n=t._x,s=t._y,r=t._z,a=t._w,o=this.dot(t);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let c=1-e;if(o<.9995){const l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,e=Math.sin(e*l)/h,this._x=this._x*c+n*e,this._y=this._y*c+s*e,this._z=this._z*c+r*e,this._w=this._w*c+a*e,this._onChangeCallback()}else this._x=this._x*c+n*e,this._y=this._y*c+s*e,this._z=this._z*c+r*e,this._w=this._w*c+a*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const 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}}class F{static{F.prototype.isVector3=!0}constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("THREE.Vector3: 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("THREE.Vector3: 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(Ch.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Ch.setFromAxisAngle(t,e))}applyMatrix3(t){const 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){const 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){const 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),u=2*(r*n-a*e);return this.x=e+c*l+a*u-o*h,this.y=n+c*h+o*l-r*u,this.z=s+c*u+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){const 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=Xt(this.x,t.x,e.x),this.y=Xt(this.y,t.y,e.y),this.z=Xt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Xt(this.x,t,e),this.y=Xt(this.y,t,e),this.z=Xt(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Xt(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){const 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){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return oo.copy(this).projectOnVector(t),this.sub(oo)}reflect(t){return this.sub(oo.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Xt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const 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){const 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){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),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(){const 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}}const oo=new F,Ch=new ks;class zt{static{zt.prototype.isMatrix3=!0}constructor(t,e,n,s,r,a,o,c,l){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){const 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){const 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){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],u=n[7],d=n[2],p=n[5],g=n[8],x=s[0],m=s[3],f=s[6],A=s[1],T=s[4],M=s[7],y=s[2],b=s[5],R=s[8];return r[0]=a*x+o*A+c*y,r[3]=a*m+o*T+c*b,r[6]=a*f+o*M+c*R,r[1]=l*x+h*A+u*y,r[4]=l*m+h*T+u*b,r[7]=l*f+h*M+u*R,r[2]=d*x+p*A+g*y,r[5]=d*m+p*T+g*b,r[8]=d*f+p*M+g*R,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],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(){const 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],u=h*a-o*l,d=o*c-h*r,p=l*r-a*c,g=e*u+n*d+s*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/g;return t[0]=u*x,t[1]=(s*l-h*n)*x,t[2]=(o*n-s*a)*x,t[3]=d*x,t[4]=(h*e-s*c)*x,t[5]=(s*r-o*e)*x,t[6]=p*x,t[7]=(n*c-l*e)*x,t[8]=(a*e-n*r)*x,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,r,a,o){const 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 Ds("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(co.makeScale(t,e)),this}rotate(t){return Ds("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(co.makeRotation(-t)),this}translate(t,e){return Ds("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(co.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),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){const 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){const 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)}}const co=new zt,Dh=new zt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Ph=new zt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Op(){const i={enabled:!0,workingColorSpace:Da,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===ee&&(s.r=ei(s.r),s.g=ei(s.g),s.b=ei(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===ee&&(s.r=Ps(s.r),s.g=Ps(s.g),s.b=Ps(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===vi?Pa: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 Ds("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Ds("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({[Da]:{primaries:t,whitePoint:n,transfer:Pa,toXYZ:Dh,fromXYZ:Ph,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:dn},outputColorSpaceConfig:{drawingBufferColorSpace:dn}},[dn]:{primaries:t,whitePoint:n,transfer:ee,toXYZ:Dh,fromXYZ:Ph,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:dn}}}),i}const Kt=Op();function ei(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Ps(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let ns;class zp{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{ns===void 0&&(ns=Ia("canvas")),ns.width=t.width,ns.height=t.height;const s=ns.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),n=ns}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){const e=Ia("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const s=n.getImageData(0,0,t.width,t.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=ei(r[a]/255)*255;return n.putImageData(s,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(ei(e[n]/255)*255):e[n]=ei(e[n]);return{data:e,width:t.width,height:t.height}}else return Ot("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let Bp=0;class zl{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Bp++}),this.uuid=Si(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?t.set(e.displayWidth,e.displayHeight,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const 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(lo(s[a].image)):r.push(lo(s[a]))}else r=lo(s);n.url=r}return e||(t.images[this.uuid]=n),n}}function lo(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?zp.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Ot("Texture: Unable to serialize Texture."),{})}let kp=0;const ho=new F;class Xe extends Ji{constructor(t=Xe.DEFAULT_IMAGE,e=Xe.DEFAULT_MAPPING,n=Sn,s=Sn,r=Ne,a=ki,o=pn,c=rn,l=Xe.DEFAULT_ANISOTROPY,h=vi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:kp++}),this.uuid=Si(),this.name="",this.source=new zl(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 Ft(0,0),this.repeat=new Ft(1,1),this.center=new Ft(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new zt,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,this.normalized=!1}get width(){return this.source.getSize(ho).x}get height(){return this.source.getSize(ho).y}get depth(){return this.source.getSize(ho).z}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.normalized=t.normalized,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const n=t[e];if(n===void 0){Ot(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const s=this[e];if(s===void 0){Ot(`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){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==B0)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case _c:t.x=t.x-Math.floor(t.x);break;case Sn:t.x=t.x<0?0:1;break;case vc: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 _c:t.y=t.y-Math.floor(t.y);break;case Sn:t.y=t.y<0?0:1;break;case vc: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++}}Xe.DEFAULT_IMAGE=null;Xe.DEFAULT_MAPPING=B0;Xe.DEFAULT_ANISOTROPY=1;class pe{static{pe.prototype.isVector4=!0}constructor(t=0,e=0,n=0,s=1){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("THREE.Vector4: 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("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,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);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,s,r;const c=t.elements,l=c[0],h=c[4],u=c[8],d=c[1],p=c[5],g=c[9],x=c[2],m=c[6],f=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-x)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+x)<.1&&Math.abs(g+m)<.1&&Math.abs(l+p+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const T=(l+1)/2,M=(p+1)/2,y=(f+1)/2,b=(h+d)/4,R=(u+x)/4,v=(g+m)/4;return T>M&&T>y?T<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(T),s=b/n,r=R/n):M>y?M<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(M),n=b/s,r=v/s):y<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(y),n=R/r,s=v/r),this.set(n,s,r,e),this}let A=Math.sqrt((m-g)*(m-g)+(u-x)*(u-x)+(d-h)*(d-h));return Math.abs(A)<.001&&(A=1),this.x=(m-g)/A,this.y=(u-x)/A,this.z=(d-h)/A,this.w=Math.acos((l+p+f-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Xt(this.x,t.x,e.x),this.y=Xt(this.y,t.y,e.y),this.z=Xt(this.z,t.z,e.z),this.w=Xt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Xt(this.x,t,e),this.y=Xt(this.y,t,e),this.z=Xt(this.z,t,e),this.w=Xt(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Xt(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}}class Gp extends Ji{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ne,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new pe(0,0,t,e),this.scissorTest=!1,this.viewport=new pe(0,0,t,e),this.textures=[];const s={width:t,height:e,depth:n.depth},r=new Xe(s),a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(t={}){const e={minFilter:Ne,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].isData3DTexture!==!0&&(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;const s=Object.assign({},t.textures[e].image);this.textures[e].source=new zl(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.multiview=t.multiview,this.useArrayDepthTexture=t.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class En extends Gp{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class K0 extends Xe{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=ze,this.minFilter=ze,this.wrapR=Sn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Hp extends Xe{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=ze,this.minFilter=ze,this.wrapR=Sn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ue{static{ue.prototype.isMatrix4=!0}constructor(t,e,n,s,r,a,o,c,l,h,u,d,p,g,x,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,c,l,h,u,d,p,g,x,m)}set(t,e,n,s,r,a,o,c,l,h,u,d,p,g,x,m){const f=this.elements;return f[0]=t,f[4]=e,f[8]=n,f[12]=s,f[1]=r,f[5]=a,f[9]=o,f[13]=c,f[2]=l,f[6]=h,f[10]=u,f[14]=d,f[3]=p,f[7]=g,f[11]=x,f[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 ue().fromArray(this.elements)}copy(t){const 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){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return this.determinantAffine()===0?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(t.determinantAffine()===0)return this.identity();const e=this.elements,n=t.elements,s=1/is.setFromMatrixColumn(t,0).length(),r=1/is.setFromMatrixColumn(t,1).length(),a=1/is.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){const 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),u=Math.sin(r);if(t.order==="XYZ"){const d=a*h,p=a*u,g=o*h,x=o*u;e[0]=c*h,e[4]=-c*u,e[8]=l,e[1]=p+g*l,e[5]=d-x*l,e[9]=-o*c,e[2]=x-d*l,e[6]=g+p*l,e[10]=a*c}else if(t.order==="YXZ"){const d=c*h,p=c*u,g=l*h,x=l*u;e[0]=d+x*o,e[4]=g*o-p,e[8]=a*l,e[1]=a*u,e[5]=a*h,e[9]=-o,e[2]=p*o-g,e[6]=x+d*o,e[10]=a*c}else if(t.order==="ZXY"){const d=c*h,p=c*u,g=l*h,x=l*u;e[0]=d-x*o,e[4]=-a*u,e[8]=g+p*o,e[1]=p+g*o,e[5]=a*h,e[9]=x-d*o,e[2]=-a*l,e[6]=o,e[10]=a*c}else if(t.order==="ZYX"){const d=a*h,p=a*u,g=o*h,x=o*u;e[0]=c*h,e[4]=g*l-p,e[8]=d*l+x,e[1]=c*u,e[5]=x*l+d,e[9]=p*l-g,e[2]=-l,e[6]=o*c,e[10]=a*c}else if(t.order==="YZX"){const d=a*c,p=a*l,g=o*c,x=o*l;e[0]=c*h,e[4]=x-d*u,e[8]=g*u+p,e[1]=u,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=p*u+g,e[10]=d-x*u}else if(t.order==="XZY"){const d=a*c,p=a*l,g=o*c,x=o*l;e[0]=c*h,e[4]=-u,e[8]=l*h,e[1]=d*u+x,e[5]=a*h,e[9]=p*u-g,e[2]=g*u-p,e[6]=o*h,e[10]=x*u+d}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(Vp,t,Wp)}lookAt(t,e,n){const s=this.elements;return je.subVectors(t,e),je.lengthSq()===0&&(je.z=1),je.normalize(),ci.crossVectors(n,je),ci.lengthSq()===0&&(Math.abs(n.z)===1?je.x+=1e-4:je.z+=1e-4,je.normalize(),ci.crossVectors(n,je)),ci.normalize(),Dr.crossVectors(je,ci),s[0]=ci.x,s[4]=Dr.x,s[8]=je.x,s[1]=ci.y,s[5]=Dr.y,s[9]=je.y,s[2]=ci.z,s[6]=Dr.z,s[10]=je.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],u=n[5],d=n[9],p=n[13],g=n[2],x=n[6],m=n[10],f=n[14],A=n[3],T=n[7],M=n[11],y=n[15],b=s[0],R=s[4],v=s[8],E=s[12],D=s[1],C=s[5],I=s[9],W=s[13],X=s[2],U=s[6],q=s[10],H=s[14],$=s[3],et=s[7],j=s[11],it=s[15];return r[0]=a*b+o*D+c*X+l*$,r[4]=a*R+o*C+c*U+l*et,r[8]=a*v+o*I+c*q+l*j,r[12]=a*E+o*W+c*H+l*it,r[1]=h*b+u*D+d*X+p*$,r[5]=h*R+u*C+d*U+p*et,r[9]=h*v+u*I+d*q+p*j,r[13]=h*E+u*W+d*H+p*it,r[2]=g*b+x*D+m*X+f*$,r[6]=g*R+x*C+m*U+f*et,r[10]=g*v+x*I+m*q+f*j,r[14]=g*E+x*W+m*H+f*it,r[3]=A*b+T*D+M*X+y*$,r[7]=A*R+T*C+M*U+y*et,r[11]=A*v+T*I+M*q+y*j,r[15]=A*E+T*W+M*H+y*it,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],s=t[8],r=t[12],a=t[1],o=t[5],c=t[9],l=t[13],h=t[2],u=t[6],d=t[10],p=t[14],g=t[3],x=t[7],m=t[11],f=t[15],A=c*p-l*d,T=o*p-l*u,M=o*d-c*u,y=a*p-l*h,b=a*d-c*h,R=a*u-o*h;return e*(x*A-m*T+f*M)-n*(g*A-m*y+f*b)+s*(g*T-x*y+f*R)-r*(g*M-x*b+m*R)}determinantAffine(){const t=this.elements,e=t[0],n=t[4],s=t[8],r=t[1],a=t[5],o=t[9],c=t[2],l=t[6],h=t[10];return e*(a*h-o*l)-n*(r*h-o*c)+s*(r*l-a*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const 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(){const 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],u=t[9],d=t[10],p=t[11],g=t[12],x=t[13],m=t[14],f=t[15],A=e*o-n*a,T=e*c-s*a,M=e*l-r*a,y=n*c-s*o,b=n*l-r*o,R=s*l-r*c,v=h*x-u*g,E=h*m-d*g,D=h*f-p*g,C=u*m-d*x,I=u*f-p*x,W=d*f-p*m,X=A*W-T*I+M*C+y*D-b*E+R*v;if(X===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const U=1/X;return t[0]=(o*W-c*I+l*C)*U,t[1]=(s*I-n*W-r*C)*U,t[2]=(x*R-m*b+f*y)*U,t[3]=(d*b-u*R-p*y)*U,t[4]=(c*D-a*W-l*E)*U,t[5]=(e*W-s*D+r*E)*U,t[6]=(m*M-g*R-f*T)*U,t[7]=(h*R-d*M+p*T)*U,t[8]=(a*I-o*D+l*v)*U,t[9]=(n*D-e*I-r*v)*U,t[10]=(g*b-x*M+f*A)*U,t[11]=(u*M-h*b-p*A)*U,t[12]=(o*E-a*C-c*v)*U,t[13]=(e*C-n*E+s*v)*U,t[14]=(x*T-g*y-m*A)*U,t[15]=(h*y-u*T+d*A)*U,this}scale(t){const 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(){const 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){const 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){const 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){const 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){const 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){const s=this.elements,r=e._x,a=e._y,o=e._z,c=e._w,l=r+r,h=a+a,u=o+o,d=r*l,p=r*h,g=r*u,x=a*h,m=a*u,f=o*u,A=c*l,T=c*h,M=c*u,y=n.x,b=n.y,R=n.z;return s[0]=(1-(x+f))*y,s[1]=(p+M)*y,s[2]=(g-T)*y,s[3]=0,s[4]=(p-M)*b,s[5]=(1-(d+f))*b,s[6]=(m+A)*b,s[7]=0,s[8]=(g+T)*R,s[9]=(m-A)*R,s[10]=(1-(d+x))*R,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,n){const s=this.elements;t.x=s[12],t.y=s[13],t.z=s[14];const r=this.determinantAffine();if(r===0)return n.set(1,1,1),e.identity(),this;let a=is.set(s[0],s[1],s[2]).length();const o=is.set(s[4],s[5],s[6]).length(),c=is.set(s[8],s[9],s[10]).length();r<0&&(a=-a),gn.copy(this);const l=1/a,h=1/o,u=1/c;return gn.elements[0]*=l,gn.elements[1]*=l,gn.elements[2]*=l,gn.elements[4]*=h,gn.elements[5]*=h,gn.elements[6]*=h,gn.elements[8]*=u,gn.elements[9]*=u,gn.elements[10]*=u,e.setFromRotationMatrix(gn),n.x=a,n.y=o,n.z=c,this}makePerspective(t,e,n,s,r,a,o=Bn,c=!1){const l=this.elements,h=2*r/(e-t),u=2*r/(n-s),d=(e+t)/(e-t),p=(n+s)/(n-s);let g,x;if(c)g=r/(a-r),x=a*r/(a-r);else if(o===Bn)g=-(a+r)/(a-r),x=-2*a*r/(a-r);else if(o===_r)g=-a/(a-r),x=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=p,l[13]=0,l[2]=0,l[6]=0,l[10]=g,l[14]=x,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,s,r,a,o=Bn,c=!1){const l=this.elements,h=2/(e-t),u=2/(n-s),d=-(e+t)/(e-t),p=-(n+s)/(n-s);let g,x;if(c)g=1/(a-r),x=a/(a-r);else if(o===Bn)g=-2/(a-r),x=-(a+r)/(a-r);else if(o===_r)g=-1/(a-r),x=-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]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=p,l[2]=0,l[6]=0,l[10]=g,l[14]=x,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const 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){const 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}}const is=new F,gn=new ue,Vp=new F(0,0,0),Wp=new F(1,1,1),ci=new F,Dr=new F,je=new F,Ih=new ue,Lh=new ks;class bi{constructor(t=0,e=0,n=0,s=bi.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){const s=t.elements,r=s[0],a=s[4],o=s[8],c=s[1],l=s[5],h=s[9],u=s[2],d=s[6],p=s[10];switch(e){case"XYZ":this._y=Math.asin(Xt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Xt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(Xt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-Xt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Xt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Xt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,p),this._y=0);break;default:Ot("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Ih.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Ih,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Lh.setFromEuler(this),this.setFromQuaternion(Lh,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}}bi.DEFAULT_ORDER="XYZ";class Bl{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let Xp=0;const Nh=new F,ss=new ks,Xn=new ue,Pr=new F,Xs=new F,qp=new F,Yp=new ks,Uh=new F(1,0,0),Fh=new F(0,1,0),Oh=new F(0,0,1),zh={type:"added"},Kp={type:"removed"},rs={type:"childadded",child:null},uo={type:"childremoved",child:null};class Te extends Ji{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Xp++}),this.uuid=Si(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Te.DEFAULT_UP.clone();const t=new F,e=new bi,n=new ks,s=new F(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 ue},normalMatrix:{value:new zt}}),this.matrix=new ue,this.matrixWorld=new ue,this.matrixAutoUpdate=Te.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Te.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Bl,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return ss.setFromAxisAngle(t,e),this.quaternion.multiply(ss),this}rotateOnWorldAxis(t,e){return ss.setFromAxisAngle(t,e),this.quaternion.premultiply(ss),this}rotateX(t){return this.rotateOnAxis(Uh,t)}rotateY(t){return this.rotateOnAxis(Fh,t)}rotateZ(t){return this.rotateOnAxis(Oh,t)}translateOnAxis(t,e){return Nh.copy(t).applyQuaternion(this.quaternion),this.position.add(Nh.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Uh,t)}translateY(t){return this.translateOnAxis(Fh,t)}translateZ(t){return this.translateOnAxis(Oh,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Xn.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Pr.copy(t):Pr.set(t,e,n);const s=this.parent;this.updateWorldMatrix(!0,!1),Xs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Xn.lookAt(Xs,Pr,this.up):Xn.lookAt(Pr,Xs,this.up),this.quaternion.setFromRotationMatrix(Xn),s&&(Xn.extractRotation(s.matrixWorld),ss.setFromRotationMatrix(Xn),this.quaternion.premultiply(ss.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(Yt("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(zh),rs.child=t,this.dispatchEvent(rs),rs.child=null):Yt("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}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Kp),uo.child=t,this.dispatchEvent(uo),uo.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Xn.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Xn.multiply(t.parent.matrixWorld)),t.applyMatrix4(Xn),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(zh),rs.child=t,this.dispatchEvent(rs),rs.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++){const a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const 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(Xs,t,qp),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Xs,Yp,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(t!==null){const e=t.x,n=t.y,s=t.z,r=this.matrix.elements;r[12]+=e-r[0]*e-r[4]*n-r[8]*s,r[13]+=n-r[1]*e-r[5]*n-r[9]*s,r[14]+=s-r[2]*e-r[6]*n-r[10]*s}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e,n=!1){const s=this.parent;if(t===!0&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),e===!0){const r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,n)}}toJSON(t){const 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"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),this.static!==!1&&(s.static=this.static),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(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);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const u=c[l];r(t.shapes,u)}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)){const 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++){const c=this.animations[o];s.animations.push(r(t.animations,c))}}if(e){const o=a(t.geometries),c=a(t.materials),l=a(t.textures),h=a(t.images),u=a(t.shapes),d=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),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),p.length>0&&(n.animations=p),g.length>0&&(n.nodes=g)}return n.object=s,n;function a(o){const c=[];for(const l in o){const 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.pivot=t.pivot!==null?t.pivot.clone():null,this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const s=t.children[n];this.add(s.clone())}return this}}Te.DEFAULT_UP=new F(0,1,0);Te.DEFAULT_MATRIX_AUTO_UPDATE=!0;Te.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class yn extends Te{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Zp={type:"move"};class fo{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 F,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new F),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 F,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new F,this._grip.eventsEnabled=!1),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){const e=this._hand;if(e)for(const 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;const o=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){a=!0;for(const x of t.hand.values()){const m=e.getJointPose(x,n),f=this._getHandJoint(l,x);m!==null&&(f.matrix.fromArray(m.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=m.radius),f.visible=m!==null}const h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),p=.02,g=.005;l.inputState.pinching&&d>p+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&d<=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,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:t,target:this})));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(Zp)))}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){const n=new yn;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const Z0={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},li={h:0,s:0,l:0},Ir={h:0,s:0,l:0};function po(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}class Mt{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){const 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=dn){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Kt.colorSpaceToWorking(this,e),this}setRGB(t,e,n,s=Kt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Kt.colorSpaceToWorking(this,s),this}setHSL(t,e,n,s=Kt.workingColorSpace){if(t=Fp(t,1),e=Xt(e,0,1),n=Xt(n,0,1),e===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=po(a,r,t+1/3),this.g=po(a,r,t),this.b=po(a,r,t-1/3)}return Kt.colorSpaceToWorking(this,s),this}setStyle(t,e=dn){function n(r){r!==void 0&&parseFloat(r)<1&&Ot("Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const 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:Ot("Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const 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);Ot("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=dn){const n=Z0[t.toLowerCase()];return n!==void 0?this.setHex(n,e):Ot("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=ei(t.r),this.g=ei(t.g),this.b=ei(t.b),this}copyLinearToSRGB(t){return this.r=Ps(t.r),this.g=Ps(t.g),this.b=Ps(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=dn){return Kt.workingToColorSpace(He.copy(this),t),Math.round(Xt(He.r*255,0,255))*65536+Math.round(Xt(He.g*255,0,255))*256+Math.round(Xt(He.b*255,0,255))}getHexString(t=dn){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Kt.workingColorSpace){Kt.workingToColorSpace(He.copy(this),e);const n=He.r,s=He.g,r=He.b,a=Math.max(n,s,r),o=Math.min(n,s,r);let c,l;const h=(o+a)/2;if(o===a)c=0,l=0;else{const u=a-o;switch(l=h<=.5?u/(a+o):u/(2-a-o),a){case n:c=(s-r)/u+(s<r?6:0);break;case s:c=(r-n)/u+2;break;case r:c=(n-s)/u+4;break}c/=6}return t.h=c,t.s=l,t.l=h,t}getRGB(t,e=Kt.workingColorSpace){return Kt.workingToColorSpace(He.copy(this),e),t.r=He.r,t.g=He.g,t.b=He.b,t}getStyle(t=dn){Kt.workingToColorSpace(He.copy(this),t);const e=He.r,n=He.g,s=He.b;return t!==dn?`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(li),this.setHSL(li.h+t,li.s+e,li.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(li),t.getHSL(Ir);const n=ao(li.h,Ir.h,e),s=ao(li.s,Ir.s,e),r=ao(li.l,Ir.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){const 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}}const He=new Mt;Mt.NAMES=Z0;class kl{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Mt(t),this.near=e,this.far=n}clone(){return new kl(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class $0 extends Te{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 bi,this.environmentIntensity=1,this.environmentRotation=new bi,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){const 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}}const _n=new F,qn=new F,mo=new F,Yn=new F,as=new F,os=new F,Bh=new F,go=new F,_o=new F,vo=new F,xo=new pe,Mo=new pe,So=new pe;class fn{constructor(t=new F,e=new F,n=new F){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,s){s.subVectors(n,e),_n.subVectors(t,e),s.cross(_n);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,n,s,r){_n.subVectors(s,e),qn.subVectors(n,e),mo.subVectors(t,e);const a=_n.dot(_n),o=_n.dot(qn),c=_n.dot(mo),l=qn.dot(qn),h=qn.dot(mo),u=a*l-o*o;if(u===0)return r.set(0,0,0),null;const d=1/u,p=(l*c-o*h)*d,g=(a*h-o*c)*d;return r.set(1-p-g,g,p)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,Yn)===null?!1:Yn.x>=0&&Yn.y>=0&&Yn.x+Yn.y<=1}static getInterpolation(t,e,n,s,r,a,o,c){return this.getBarycoord(t,e,n,s,Yn)===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,Yn.x),c.addScaledVector(a,Yn.y),c.addScaledVector(o,Yn.z),c)}static getInterpolatedAttribute(t,e,n,s,r,a){return xo.setScalar(0),Mo.setScalar(0),So.setScalar(0),xo.fromBufferAttribute(t,e),Mo.fromBufferAttribute(t,n),So.fromBufferAttribute(t,s),a.setScalar(0),a.addScaledVector(xo,r.x),a.addScaledVector(Mo,r.y),a.addScaledVector(So,r.z),a}static isFrontFacing(t,e,n,s){return _n.subVectors(n,e),qn.subVectors(t,e),_n.cross(qn).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 _n.subVectors(this.c,this.b),qn.subVectors(this.a,this.b),_n.cross(qn).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return fn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return fn.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,s,r){return fn.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}containsPoint(t){return fn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return fn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,s=this.b,r=this.c;let a,o;as.subVectors(s,n),os.subVectors(r,n),go.subVectors(t,n);const c=as.dot(go),l=os.dot(go);if(c<=0&&l<=0)return e.copy(n);_o.subVectors(t,s);const h=as.dot(_o),u=os.dot(_o);if(h>=0&&u<=h)return e.copy(s);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),e.copy(n).addScaledVector(as,a);vo.subVectors(t,r);const p=as.dot(vo),g=os.dot(vo);if(g>=0&&p<=g)return e.copy(r);const x=p*l-c*g;if(x<=0&&l>=0&&g<=0)return o=l/(l-g),e.copy(n).addScaledVector(os,o);const m=h*g-p*u;if(m<=0&&u-h>=0&&p-g>=0)return Bh.subVectors(r,s),o=(u-h)/(u-h+(p-g)),e.copy(s).addScaledVector(Bh,o);const f=1/(m+x+d);return a=x*f,o=d*f,e.copy(n).addScaledVector(as,a).addScaledVector(os,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class vr{constructor(t=new F(1/0,1/0,1/0),e=new F(-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(vn.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(vn.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){const n=vn.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);const n=t.geometry;if(n!==void 0){const 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,vn):vn.fromBufferAttribute(r,a),vn.applyMatrix4(t.matrixWorld),this.expandByPoint(vn);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Lr.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Lr.copy(n.boundingBox)),Lr.applyMatrix4(t.matrixWorld),this.union(Lr)}const 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,vn),vn.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(qs),Nr.subVectors(this.max,qs),cs.subVectors(t.a,qs),ls.subVectors(t.b,qs),hs.subVectors(t.c,qs),hi.subVectors(ls,cs),ui.subVectors(hs,ls),Ri.subVectors(cs,hs);let e=[0,-hi.z,hi.y,0,-ui.z,ui.y,0,-Ri.z,Ri.y,hi.z,0,-hi.x,ui.z,0,-ui.x,Ri.z,0,-Ri.x,-hi.y,hi.x,0,-ui.y,ui.x,0,-Ri.y,Ri.x,0];return!yo(e,cs,ls,hs,Nr)||(e=[1,0,0,0,1,0,0,0,1],!yo(e,cs,ls,hs,Nr))?!1:(Ur.crossVectors(hi,ui),e=[Ur.x,Ur.y,Ur.z],yo(e,cs,ls,hs,Nr))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,vn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(vn).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:(Kn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Kn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Kn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Kn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Kn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Kn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Kn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Kn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Kn),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const Kn=[new F,new F,new F,new F,new F,new F,new F,new F],vn=new F,Lr=new vr,cs=new F,ls=new F,hs=new F,hi=new F,ui=new F,Ri=new F,qs=new F,Nr=new F,Ur=new F,Ci=new F;function yo(i,t,e,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){Ci.fromArray(i,r);const o=s.x*Math.abs(Ci.x)+s.y*Math.abs(Ci.y)+s.z*Math.abs(Ci.z),c=t.dot(Ci),l=e.dot(Ci),h=n.dot(Ci);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const jn=$p();function $p(){const i=new ArrayBuffer(4),t=new Float32Array(i),e=new Uint32Array(i),n=new Uint32Array(512),s=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(n[c]=0,n[c|256]=32768,s[c]=24,s[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,s[c]=-l-1,s[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,s[c]=13,s[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,s[c]=24,s[c|256]=24):(n[c]=31744,n[c|256]=64512,s[c]=13,s[c|256]=13)}const r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,r[c]=l|h}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)a[c]=c<<23;a[31]=1199570944,a[32]=2147483648;for(let c=33;c<63;++c)a[c]=2147483648+(c-32<<23);a[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:t,uint32View:e,baseTable:n,shiftTable:s,mantissaTable:r,exponentTable:a,offsetTable:o}}function Jp(i){Math.abs(i)>65504&&Ot("DataUtils.toHalfFloat(): Value out of range."),i=Xt(i,-65504,65504),jn.floatView[0]=i;const t=jn.uint32View[0],e=t>>23&511;return jn.baseTable[e]+((t&8388607)>>jn.shiftTable[e])}function Qp(i){const t=i>>10;return jn.uint32View[0]=jn.mantissaTable[jn.offsetTable[t]+(i&1023)]+jn.exponentTable[t],jn.floatView[0]}class Eo{static toHalfFloat(t){return Jp(t)}static fromHalfFloat(t){return Qp(t)}}const be=new F,Fr=new Ft;let jp=0;class he extends Ji{constructor(t,e,n=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:jp++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=$c,this.updateRanges=[],this.gpuType=zn,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++)Fr.fromBufferAttribute(this,e),Fr.applyMatrix3(t),this.setXY(e,Fr.x,Fr.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)be.fromBufferAttribute(this,e),be.applyMatrix3(t),this.setXYZ(e,be.x,be.y,be.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)be.fromBufferAttribute(this,e),be.applyMatrix4(t),this.setXYZ(e,be.x,be.y,be.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)be.fromBufferAttribute(this,e),be.applyNormalMatrix(t),this.setXYZ(e,be.x,be.y,be.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)be.fromBufferAttribute(this,e),be.transformDirection(t),this.setXYZ(e,be.x,be.y,be.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=On(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=se(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=On(e,this.array)),e}setX(t,e){return this.normalized&&(e=se(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=On(e,this.array)),e}setY(t,e){return this.normalized&&(e=se(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=On(e,this.array)),e}setZ(t,e){return this.normalized&&(e=se(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=On(e,this.array)),e}setW(t,e){return this.normalized&&(e=se(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=se(e,this.array),n=se(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=se(e,this.array),n=se(n,this.array),s=se(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=se(e,this.array),n=se(n,this.array),s=se(s,this.array),r=se(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(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==$c&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}}class J0 extends he{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class Q0 extends he{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class we extends he{constructor(t,e,n){super(new Float32Array(t),e,n)}}const tm=new vr,Ys=new F,bo=new F;class Xa{constructor(t=new F,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;e!==void 0?n.copy(e):tm.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){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const 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;Ys.subVectors(t,this.center);const e=Ys.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Ys,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):(bo.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Ys.copy(t.center).add(bo)),this.expandByPoint(Ys.copy(t.center).sub(bo))),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}}let em=0;const on=new ue,Ao=new Te,us=new F,tn=new vr,Ks=new vr,Pe=new F;class ye extends Ji{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:em++}),this.uuid=Si(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(Ip(t)?Q0:J0)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new zt().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}const 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._transformed=!0,this}applyQuaternion(t){return on.makeRotationFromQuaternion(t),this.applyMatrix4(on),this}rotateX(t){return on.makeRotationX(t),this.applyMatrix4(on),this}rotateY(t){return on.makeRotationY(t),this.applyMatrix4(on),this}rotateZ(t){return on.makeRotationZ(t),this.applyMatrix4(on),this}translate(t,e,n){return on.makeTranslation(t,e,n),this.applyMatrix4(on),this}scale(t,e,n){return on.makeScale(t,e,n),this.applyMatrix4(on),this}lookAt(t){return Ao.lookAt(t),Ao.updateMatrix(),this.applyMatrix4(Ao.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(us).negate(),this.translate(us.x,us.y,us.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const n=[];for(let s=0,r=t.length;s<r;s++){const a=t[s];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new we(n,3))}else{const n=Math.min(t.length,e.count);for(let s=0;s<n;s++){const r=t[s];e.setXYZ(s,r.x,r.y,r.z||0)}t.length>e.count&&Ot("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 vr);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Yt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new F(-1/0,-1/0,-1/0),new F(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++){const r=e[n];tn.setFromBufferAttribute(r),this.morphTargetsRelative?(Pe.addVectors(this.boundingBox.min,tn.min),this.boundingBox.expandByPoint(Pe),Pe.addVectors(this.boundingBox.max,tn.max),this.boundingBox.expandByPoint(Pe)):(this.boundingBox.expandByPoint(tn.min),this.boundingBox.expandByPoint(tn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Yt('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 Xa);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Yt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new F,1/0);return}if(t){const n=this.boundingSphere.center;if(tn.setFromBufferAttribute(t),e)for(let r=0,a=e.length;r<a;r++){const o=e[r];Ks.setFromBufferAttribute(o),this.morphTargetsRelative?(Pe.addVectors(tn.min,Ks.min),tn.expandByPoint(Pe),Pe.addVectors(tn.max,Ks.max),tn.expandByPoint(Pe)):(tn.expandByPoint(Ks.min),tn.expandByPoint(Ks.max))}tn.getCenter(n);let s=0;for(let r=0,a=t.count;r<a;r++)Pe.fromBufferAttribute(t,r),s=Math.max(s,n.distanceToSquared(Pe));if(e)for(let r=0,a=e.length;r<a;r++){const o=e[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)Pe.fromBufferAttribute(o,l),c&&(us.fromBufferAttribute(t,l),Pe.add(us)),s=Math.max(s,n.distanceToSquared(Pe))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&Yt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){Yt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,s=e.normal,r=e.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new he(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],c=[];for(let v=0;v<n.count;v++)o[v]=new F,c[v]=new F;const l=new F,h=new F,u=new F,d=new Ft,p=new Ft,g=new Ft,x=new F,m=new F;function f(v,E,D){l.fromBufferAttribute(n,v),h.fromBufferAttribute(n,E),u.fromBufferAttribute(n,D),d.fromBufferAttribute(r,v),p.fromBufferAttribute(r,E),g.fromBufferAttribute(r,D),h.sub(l),u.sub(l),p.sub(d),g.sub(d);const C=1/(p.x*g.y-g.x*p.y);isFinite(C)&&(x.copy(h).multiplyScalar(g.y).addScaledVector(u,-p.y).multiplyScalar(C),m.copy(u).multiplyScalar(p.x).addScaledVector(h,-g.x).multiplyScalar(C),o[v].add(x),o[E].add(x),o[D].add(x),c[v].add(m),c[E].add(m),c[D].add(m))}let A=this.groups;A.length===0&&(A=[{start:0,count:t.count}]);for(let v=0,E=A.length;v<E;++v){const D=A[v],C=D.start,I=D.count;for(let W=C,X=C+I;W<X;W+=3)f(t.getX(W+0),t.getX(W+1),t.getX(W+2))}const T=new F,M=new F,y=new F,b=new F;function R(v){y.fromBufferAttribute(s,v),b.copy(y);const E=o[v];T.copy(E),T.sub(y.multiplyScalar(y.dot(E))).normalize(),M.crossVectors(b,E);const C=M.dot(c[v])<0?-1:1;a.setXYZW(v,T.x,T.y,T.z,C)}for(let v=0,E=A.length;v<E;++v){const D=A[v],C=D.start,I=D.count;for(let W=C,X=C+I;W<X;W+=3)R(t.getX(W+0)),R(t.getX(W+1)),R(t.getX(W+2))}this._transformed=!0}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==e.count)n=new he(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let d=0,p=n.count;d<p;d++)n.setXYZ(d,0,0,0);const s=new F,r=new F,a=new F,o=new F,c=new F,l=new F,h=new F,u=new F;if(t)for(let d=0,p=t.count;d<p;d+=3){const g=t.getX(d+0),x=t.getX(d+1),m=t.getX(d+2);s.fromBufferAttribute(e,g),r.fromBufferAttribute(e,x),a.fromBufferAttribute(e,m),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),o.fromBufferAttribute(n,g),c.fromBufferAttribute(n,x),l.fromBufferAttribute(n,m),o.add(h),c.add(h),l.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(x,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let d=0,p=e.count;d<p;d+=3)s.fromBufferAttribute(e,d+0),r.fromBufferAttribute(e,d+1),a.fromBufferAttribute(e,d+2),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)Pe.fromBufferAttribute(t,e),Pe.normalize(),t.setXYZ(e,Pe.x,Pe.y,Pe.z)}toNonIndexed(){function t(o,c){const l=o.array,h=o.itemSize,u=o.normalized,d=new l.constructor(c.length*h);let p=0,g=0;for(let x=0,m=c.length;x<m;x++){o.isInterleavedBufferAttribute?p=c[x]*o.data.stride+o.offset:p=c[x]*h;for(let f=0;f<h;f++)d[g++]=l[p++]}return new he(d,h,u)}if(this.index===null)return Ot("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new ye,n=this.index.array,s=this.attributes;for(const o in s){const c=s[o],l=t(c,n);e.setAttribute(o,l)}const r=this.morphAttributes;for(const o in r){const c=[],l=r[o];for(let h=0,u=l.length;h<u;h++){const d=l[h],p=t(d,n);c.push(p)}e.morphAttributes[o]=c}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const c in n){const l=n[c];t.data.attributes[c]=l.toJSON(t.data)}const s={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){const p=l[u];h.push(p.toJSON(t.data))}h.length>0&&(s[c]=h,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone());const s=t.attributes;for(const l in s){const h=s[l];this.setAttribute(l,h.clone(e))}const r=t.morphAttributes;for(const l in r){const h=[],u=r[l];for(let d=0,p=u.length;d<p;d++)h.push(u[d].clone(e));this.morphAttributes[l]=h}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let l=0,h=a.length;l<h;l++){const u=a[l];this.addGroup(u.start,u.count,u.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const 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._transformed=t._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class nm{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=$c,this.updateRanges=[],this.version=0,this.uuid=Si()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let s=0,r=this.stride;s<r;s++)this.array[t+s]=e.array[n+s];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Si()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Si()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const qe=new F;class Na{constructor(t,e,n,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)qe.fromBufferAttribute(this,e),qe.applyMatrix4(t),this.setXYZ(e,qe.x,qe.y,qe.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)qe.fromBufferAttribute(this,e),qe.applyNormalMatrix(t),this.setXYZ(e,qe.x,qe.y,qe.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)qe.fromBufferAttribute(this,e),qe.transformDirection(t),this.setXYZ(e,qe.x,qe.y,qe.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=On(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=se(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=se(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=se(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=se(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=se(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=On(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=On(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=On(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=On(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=se(e,this.array),n=se(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=se(e,this.array),n=se(n,this.array),s=se(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=s,this}setXYZW(t,e,n,s,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=se(e,this.array),n=se(n,this.array),s=se(s,this.array),r=se(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=s,this.data.array[t+3]=r,this}clone(t){if(t===void 0){La("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[s+r])}return new he(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Na(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){La("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[s+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let im=0;class Qi extends Ji{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:im++}),this.uuid=Si(),this.name="",this.type="Material",this.blending=Cs,this.side=Ei,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=cc,this.blendDst=lc,this.blendEquation=Fi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Mt(0,0,0),this.blendAlpha=0,this.depthFunc=Us,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Th,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=es,this.stencilZFail=es,this.stencilZPass=es,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){Ot(`Material: parameter '${e}' has value of undefined.`);continue}const s=this[e];if(s===void 0){Ot(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const 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!==Cs&&(n.blending=this.blending),this.side!==Ei&&(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!==cc&&(n.blendSrc=this.blendSrc),this.blendDst!==lc&&(n.blendDst=this.blendDst),this.blendEquation!==Fi&&(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!==Us&&(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!==Th&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==es&&(n.stencilFail=this.stencilFail),this.stencilZFail!==es&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==es&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){const a=[];for(const o in r){const c=r[o];delete c.metadata,a.push(c)}return a}if(e){const r=s(t.textures),a=s(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(t,e){if(t.uuid!==void 0&&(this.uuid=t.uuid),t.name!==void 0&&(this.name=t.name),t.color!==void 0&&this.color!==void 0&&this.color.setHex(t.color),t.roughness!==void 0&&(this.roughness=t.roughness),t.metalness!==void 0&&(this.metalness=t.metalness),t.sheen!==void 0&&(this.sheen=t.sheen),t.sheenColor!==void 0&&(this.sheenColor=new Mt().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(this.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(t.emissive),t.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(t.specular),t.specularIntensity!==void 0&&(this.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(this.shininess=t.shininess),t.clearcoat!==void 0&&(this.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(this.dispersion=t.dispersion),t.iridescence!==void 0&&(this.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(this.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(this.transmission=t.transmission),t.thickness!==void 0&&(this.thickness=t.thickness),t.attenuationDistance!==void 0&&(this.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(this.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(this.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(this.fog=t.fog),t.flatShading!==void 0&&(this.flatShading=t.flatShading),t.blending!==void 0&&(this.blending=t.blending),t.combine!==void 0&&(this.combine=t.combine),t.side!==void 0&&(this.side=t.side),t.shadowSide!==void 0&&(this.shadowSide=t.shadowSide),t.opacity!==void 0&&(this.opacity=t.opacity),t.transparent!==void 0&&(this.transparent=t.transparent),t.alphaTest!==void 0&&(this.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(this.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(this.depthFunc=t.depthFunc),t.depthTest!==void 0&&(this.depthTest=t.depthTest),t.depthWrite!==void 0&&(this.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(this.colorWrite=t.colorWrite),t.blendSrc!==void 0&&(this.blendSrc=t.blendSrc),t.blendDst!==void 0&&(this.blendDst=t.blendDst),t.blendEquation!==void 0&&(this.blendEquation=t.blendEquation),t.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=t.blendSrcAlpha),t.blendDstAlpha!==void 0&&(this.blendDstAlpha=t.blendDstAlpha),t.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=t.blendEquationAlpha),t.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(t.blendColor),t.blendAlpha!==void 0&&(this.blendAlpha=t.blendAlpha),t.stencilWriteMask!==void 0&&(this.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(this.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(this.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(this.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(this.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(this.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(this.stencilZPass=t.stencilZPass),t.stencilWrite!==void 0&&(this.stencilWrite=t.stencilWrite),t.wireframe!==void 0&&(this.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(this.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(this.rotation=t.rotation),t.linewidth!==void 0&&(this.linewidth=t.linewidth),t.dashSize!==void 0&&(this.dashSize=t.dashSize),t.gapSize!==void 0&&(this.gapSize=t.gapSize),t.scale!==void 0&&(this.scale=t.scale),t.polygonOffset!==void 0&&(this.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=t.polygonOffsetUnits),t.dithering!==void 0&&(this.dithering=t.dithering),t.alphaToCoverage!==void 0&&(this.alphaToCoverage=t.alphaToCoverage),t.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=t.premultipliedAlpha),t.forceSinglePass!==void 0&&(this.forceSinglePass=t.forceSinglePass),t.allowOverride!==void 0&&(this.allowOverride=t.allowOverride),t.visible!==void 0&&(this.visible=t.visible),t.toneMapped!==void 0&&(this.toneMapped=t.toneMapped),t.userData!==void 0&&(this.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?this.vertexColors=t.vertexColors>0:this.vertexColors=t.vertexColors),t.size!==void 0&&(this.size=t.size),t.sizeAttenuation!==void 0&&(this.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(this.map=e[t.map]||null),t.matcap!==void 0&&(this.matcap=e[t.matcap]||null),t.alphaMap!==void 0&&(this.alphaMap=e[t.alphaMap]||null),t.bumpMap!==void 0&&(this.bumpMap=e[t.bumpMap]||null),t.bumpScale!==void 0&&(this.bumpScale=t.bumpScale),t.normalMap!==void 0&&(this.normalMap=e[t.normalMap]||null),t.normalMapType!==void 0&&(this.normalMapType=t.normalMapType),t.normalScale!==void 0){let n=t.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Ft().fromArray(n)}return t.displacementMap!==void 0&&(this.displacementMap=e[t.displacementMap]||null),t.displacementScale!==void 0&&(this.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(this.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(this.roughnessMap=e[t.roughnessMap]||null),t.metalnessMap!==void 0&&(this.metalnessMap=e[t.metalnessMap]||null),t.emissiveMap!==void 0&&(this.emissiveMap=e[t.emissiveMap]||null),t.emissiveIntensity!==void 0&&(this.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(this.specularMap=e[t.specularMap]||null),t.specularIntensityMap!==void 0&&(this.specularIntensityMap=e[t.specularIntensityMap]||null),t.specularColorMap!==void 0&&(this.specularColorMap=e[t.specularColorMap]||null),t.envMap!==void 0&&(this.envMap=e[t.envMap]||null),t.envMapRotation!==void 0&&this.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(this.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(this.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(this.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(this.lightMap=e[t.lightMap]||null),t.lightMapIntensity!==void 0&&(this.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(this.aoMap=e[t.aoMap]||null),t.aoMapIntensity!==void 0&&(this.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(this.gradientMap=e[t.gradientMap]||null),t.clearcoatMap!==void 0&&(this.clearcoatMap=e[t.clearcoatMap]||null),t.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=e[t.clearcoatRoughnessMap]||null),t.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=e[t.clearcoatNormalMap]||null),t.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Ft().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(this.iridescenceMap=e[t.iridescenceMap]||null),t.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=e[t.iridescenceThicknessMap]||null),t.transmissionMap!==void 0&&(this.transmissionMap=e[t.transmissionMap]||null),t.thicknessMap!==void 0&&(this.thicknessMap=e[t.thicknessMap]||null),t.anisotropyMap!==void 0&&(this.anisotropyMap=e[t.anisotropyMap]||null),t.sheenColorMap!==void 0&&(this.sheenColorMap=e[t.sheenColorMap]||null),t.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=e[t.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const 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.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class rr extends Qi{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Mt(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!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.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let ds;const Zs=new F,fs=new F,ps=new F,ms=new Ft,$s=new Ft,j0=new ue,Or=new F,Js=new F,zr=new F,kh=new Ft,To=new Ft,Gh=new Ft;class Br extends Te{constructor(t=new rr){if(super(),this.isSprite=!0,this.type="Sprite",ds===void 0){ds=new ye;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new nm(e,5);ds.setIndex([0,1,2,0,2,3]),ds.setAttribute("position",new Na(n,3,0,!1)),ds.setAttribute("uv",new Na(n,2,3,!1))}this.geometry=ds,this.material=t,this.center=new Ft(.5,.5),this.count=1}raycast(t,e){t.camera===null&&Yt('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),fs.setFromMatrixScale(this.matrixWorld),j0.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),ps.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&fs.multiplyScalar(-ps.z);const n=this.material.rotation;let s,r;n!==0&&(r=Math.cos(n),s=Math.sin(n));const a=this.center;kr(Or.set(-.5,-.5,0),ps,a,fs,s,r),kr(Js.set(.5,-.5,0),ps,a,fs,s,r),kr(zr.set(.5,.5,0),ps,a,fs,s,r),kh.set(0,0),To.set(1,0),Gh.set(1,1);let o=t.ray.intersectTriangle(Or,Js,zr,!1,Zs);if(o===null&&(kr(Js.set(-.5,.5,0),ps,a,fs,s,r),To.set(0,1),o=t.ray.intersectTriangle(Or,zr,Js,!1,Zs),o===null))return;const c=t.ray.origin.distanceTo(Zs);c<t.near||c>t.far||e.push({distance:c,point:Zs.clone(),uv:fn.getInterpolation(Zs,Or,Js,zr,kh,To,Gh,new Ft),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}}function kr(i,t,e,n,s,r){ms.subVectors(i,e).addScalar(.5).multiply(n),s!==void 0?($s.x=r*ms.x-s*ms.y,$s.y=s*ms.x+r*ms.y):$s.copy(ms),i.copy(t),i.x+=$s.x,i.y+=$s.y,i.applyMatrix4(j0)}const Zn=new F,wo=new F,Gr=new F,di=new F,Ro=new F,Hr=new F,Co=new F;class Gl{constructor(t=new F,e=new F(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,Zn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const 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){const e=Zn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Zn.copy(this.origin).addScaledVector(this.direction,e),Zn.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){wo.copy(t).add(e).multiplyScalar(.5),Gr.copy(e).sub(t).normalize(),di.copy(this.origin).sub(wo);const r=t.distanceTo(e)*.5,a=-this.direction.dot(Gr),o=di.dot(this.direction),c=-di.dot(Gr),l=di.lengthSq(),h=Math.abs(1-a*a);let u,d,p,g;if(h>0)if(u=a*c-o,d=a*o-c,g=r*h,u>=0)if(d>=-g)if(d<=g){const x=1/h;u*=x,d*=x,p=u*(u+a*d+2*o)+d*(a*u+d+2*c)+l}else d=r,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*c)+l;else d=-r,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*c)+l;else d<=-g?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-c),r),p=-u*u+d*(d+2*c)+l):d<=g?(u=0,d=Math.min(Math.max(-r,-c),r),p=d*(d+2*c)+l):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-c),r),p=-u*u+d*(d+2*c)+l);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(wo).addScaledVector(Gr,d),p}intersectSphere(t,e){Zn.subVectors(t.center,this.origin);const n=Zn.dot(this.direction),s=Zn.dot(Zn)-n*n,r=t.radius*t.radius;if(s>r)return null;const 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){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const 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;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(t.min.x-d.x)*l,s=(t.max.x-d.x)*l):(n=(t.max.x-d.x)*l,s=(t.min.x-d.x)*l),h>=0?(r=(t.min.y-d.y)*h,a=(t.max.y-d.y)*h):(r=(t.max.y-d.y)*h,a=(t.min.y-d.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),u>=0?(o=(t.min.z-d.z)*u,c=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,c=(t.min.z-d.z)*u),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,Zn)!==null}intersectTriangle(t,e,n,s,r){Ro.subVectors(e,t),Hr.subVectors(n,t),Co.crossVectors(Ro,Hr);let a=this.direction.dot(Co),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;di.subVectors(this.origin,t);const c=o*this.direction.dot(Hr.crossVectors(di,Hr));if(c<0)return null;const l=o*this.direction.dot(Ro.cross(di));if(l<0||c+l>a)return null;const h=-o*di.dot(Co);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)}}class Ki extends Qi{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Mt(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 bi,this.combine=Cl,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const Hh=new ue,Di=new Gl,Vr=new Xa,Vh=new F,Wr=new F,Xr=new F,qr=new F,Do=new F,Yr=new F,Wh=new F,Kr=new F;class oe extends Te{constructor(t=new ye,e=new Ki){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(t,e){const n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(s,t);const o=this.morphTargetInfluences;if(r&&o){Yr.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const h=o[c],u=r[c];h!==0&&(Do.fromBufferAttribute(u,t),a?Yr.addScaledVector(Do,h):Yr.addScaledVector(Do.sub(e),h))}e.add(Yr)}return e}raycast(t,e){const n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Vr.copy(n.boundingSphere),Vr.applyMatrix4(r),Di.copy(t.ray).recast(t.near),!(Vr.containsPoint(Di.origin)===!1&&(Di.intersectSphere(Vr,Vh)===null||Di.origin.distanceToSquared(Vh)>(t.far-t.near)**2))&&(Hh.copy(r).invert(),Di.copy(t.ray).applyMatrix4(Hh),!(n.boundingBox!==null&&Di.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Di)))}_computeIntersections(t,e,n){let s;const r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,p=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,x=d.length;g<x;g++){const m=d[g],f=a[m.materialIndex],A=Math.max(m.start,p.start),T=Math.min(o.count,Math.min(m.start+m.count,p.start+p.count));for(let M=A,y=T;M<y;M+=3){const b=o.getX(M),R=o.getX(M+1),v=o.getX(M+2);s=Zr(this,f,t,n,l,h,u,b,R,v),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=m.materialIndex,e.push(s))}}else{const g=Math.max(0,p.start),x=Math.min(o.count,p.start+p.count);for(let m=g,f=x;m<f;m+=3){const A=o.getX(m),T=o.getX(m+1),M=o.getX(m+2);s=Zr(this,a,t,n,l,h,u,A,T,M),s&&(s.faceIndex=Math.floor(m/3),e.push(s))}}else if(c!==void 0)if(Array.isArray(a))for(let g=0,x=d.length;g<x;g++){const m=d[g],f=a[m.materialIndex],A=Math.max(m.start,p.start),T=Math.min(c.count,Math.min(m.start+m.count,p.start+p.count));for(let M=A,y=T;M<y;M+=3){const b=M,R=M+1,v=M+2;s=Zr(this,f,t,n,l,h,u,b,R,v),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=m.materialIndex,e.push(s))}}else{const g=Math.max(0,p.start),x=Math.min(c.count,p.start+p.count);for(let m=g,f=x;m<f;m+=3){const A=m,T=m+1,M=m+2;s=Zr(this,a,t,n,l,h,u,A,T,M),s&&(s.faceIndex=Math.floor(m/3),e.push(s))}}}}function sm(i,t,e,n,s,r,a,o){let c;if(t.side===Fe?c=n.intersectTriangle(a,r,s,!0,o):c=n.intersectTriangle(s,r,a,t.side===Ei,o),c===null)return null;Kr.copy(o),Kr.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(Kr);return l<e.near||l>e.far?null:{distance:l,point:Kr.clone(),object:i}}function Zr(i,t,e,n,s,r,a,o,c,l){i.getVertexPosition(o,Wr),i.getVertexPosition(c,Xr),i.getVertexPosition(l,qr);const h=sm(i,t,e,n,Wr,Xr,qr,Wh);if(h){const u=new F;fn.getBarycoord(Wh,Wr,Xr,qr,u),s&&(h.uv=fn.getInterpolatedAttribute(s,o,c,l,u,new Ft)),r&&(h.uv1=fn.getInterpolatedAttribute(r,o,c,l,u,new Ft)),a&&(h.normal=fn.getInterpolatedAttribute(a,o,c,l,u,new F),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new F,materialIndex:0};fn.getNormal(Wr,Xr,qr,d.normal),h.face=d,h.barycoord=u}return h}class td extends Xe{constructor(t=null,e=1,n=1,s,r,a,o,c,l=ze,h=ze,u,d){super(null,a,o,c,l,h,s,r,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Po=new F,rm=new F,am=new zt;class Ui{constructor(t=new F(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){const s=Po.subVectors(n,e).cross(rm.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e,n=!0){const s=t.delta(Po),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const a=-(t.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:e.copy(t.start).addScaledVector(s,a)}intersectsLine(t){const 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){const n=e||am.getNormalMatrix(t),s=this.coplanarPoint(Po).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)}}const Pi=new Xa,om=new Ft(.5,.5),$r=new F;class Hl{constructor(t=new Ui,e=new Ui,n=new Ui,s=new Ui,r=new Ui,a=new Ui){this.planes=[t,e,n,s,r,a]}set(t,e,n,s,r,a){const 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){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=Bn,n=!1){const s=this.planes,r=t.elements,a=r[0],o=r[1],c=r[2],l=r[3],h=r[4],u=r[5],d=r[6],p=r[7],g=r[8],x=r[9],m=r[10],f=r[11],A=r[12],T=r[13],M=r[14],y=r[15];if(s[0].setComponents(l-a,p-h,f-g,y-A).normalize(),s[1].setComponents(l+a,p+h,f+g,y+A).normalize(),s[2].setComponents(l+o,p+u,f+x,y+T).normalize(),s[3].setComponents(l-o,p-u,f-x,y-T).normalize(),n)s[4].setComponents(c,d,m,M).normalize(),s[5].setComponents(l-c,p-d,f-m,y-M).normalize();else if(s[4].setComponents(l-c,p-d,f-m,y-M).normalize(),e===Bn)s[5].setComponents(l+c,p+d,f+m,y+M).normalize();else if(e===_r)s[5].setComponents(c,d,m,M).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(),Pi.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Pi.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Pi)}intersectsSprite(t){Pi.center.set(0,0,0);const e=om.distanceTo(t.center);return Pi.radius=.7071067811865476+e,Pi.applyMatrix4(t.matrixWorld),this.intersectsSphere(Pi)}intersectsSphere(t){const 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){const e=this.planes;for(let n=0;n<6;n++){const s=e[n];if($r.x=s.normal.x>0?t.max.x:t.min.x,$r.y=s.normal.y>0?t.max.y:t.min.y,$r.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint($r)<0)return!1}return!0}containsPoint(t){const 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)}}class ed extends Qi{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Mt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const Xh=new ue,Qc=new Gl,Jr=new Xa,Qr=new F;class ba extends Te{constructor(t=new ye,e=new ed){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const n=this.geometry,s=this.matrixWorld,r=t.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Jr.copy(n.boundingSphere),Jr.applyMatrix4(s),Jr.radius+=r,t.ray.intersectsSphere(Jr)===!1)return;Xh.copy(s).invert(),Qc.copy(t.ray).applyMatrix4(Xh);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=n.index,u=n.attributes.position;if(l!==null){const d=Math.max(0,a.start),p=Math.min(l.count,a.start+a.count);for(let g=d,x=p;g<x;g++){const m=l.getX(g);Qr.fromBufferAttribute(u,m),qh(Qr,m,c,s,t,e,this)}}else{const d=Math.max(0,a.start),p=Math.min(u.count,a.start+a.count);for(let g=d,x=p;g<x;g++)Qr.fromBufferAttribute(u,g),qh(Qr,g,c,s,t,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function qh(i,t,e,n,s,r,a){const o=Qc.distanceSqToPoint(i);if(o<e){const c=new F;Qc.closestPointToPoint(i,c),c.applyMatrix4(n);const 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})}}class nd extends Xe{constructor(t=[],e=qi,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}}class ii extends Xe{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}}class Os extends Xe{constructor(t,e,n=Vn,s,r,a,o=ze,c=ze,l,h=ni,u=1){if(h!==ni&&h!==Gi)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:t,height:e,depth:u};super(d,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 zl(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}class cm extends Os{constructor(t,e=Vn,n=qi,s,r,a=ze,o=ze,c,l=ni){const h={width:t,height:t,depth:1},u=[h,h,h,h,h,h];super(t,t,e,n,s,r,a,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}class id extends Xe{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class mn 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};const o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);const c=[],l=[],h=[],u=[];let d=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 we(l,3)),this.setAttribute("normal",new we(h,3)),this.setAttribute("uv",new we(u,2));function g(x,m,f,A,T,M,y,b,R,v,E){const D=M/R,C=y/v,I=M/2,W=y/2,X=b/2,U=R+1,q=v+1;let H=0,$=0;const et=new F;for(let j=0;j<q;j++){const it=j*C-W;for(let ut=0;ut<U;ut++){const kt=ut*D-I;et[x]=kt*A,et[m]=it*T,et[f]=X,l.push(et.x,et.y,et.z),et[x]=0,et[m]=0,et[f]=b>0?1:-1,h.push(et.x,et.y,et.z),u.push(ut/R),u.push(1-j/v),H+=1}}for(let j=0;j<v;j++)for(let it=0;it<R;it++){const ut=d+it+U*j,kt=d+it+U*(j+1),qt=d+(it+1)+U*(j+1),Bt=d+(it+1)+U*j;c.push(ut,kt,Bt),c.push(kt,qt,Bt),$+=6}o.addGroup(p,$,E),p+=$,d+=H}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new mn(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class Vl extends ye{constructor(t=1,e=32,n=0,s=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:s},e=Math.max(3,e);const r=[],a=[],o=[],c=[],l=new F,h=new Ft;a.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let u=0,d=3;u<=e;u++,d+=3){const p=n+u/e*s;l.x=t*Math.cos(p),l.y=t*Math.sin(p),a.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(a[d]/t+1)/2,h.y=(a[d+1]/t+1)/2,c.push(h.x,h.y)}for(let u=1;u<=e;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new we(a,3)),this.setAttribute("normal",new we(o,3)),this.setAttribute("uv",new we(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Vl(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Ti extends ye{constructor(t=1,e=1,n=1,s=32,r=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:s,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:c};const l=this;s=Math.floor(s),r=Math.floor(r);const h=[],u=[],d=[],p=[];let g=0;const x=[],m=n/2;let f=0;A(),a===!1&&(t>0&&T(!0),e>0&&T(!1)),this.setIndex(h),this.setAttribute("position",new we(u,3)),this.setAttribute("normal",new we(d,3)),this.setAttribute("uv",new we(p,2));function A(){const M=new F,y=new F;let b=0;const R=(e-t)/n;for(let v=0;v<=r;v++){const E=[],D=v/r,C=D*(e-t)+t;for(let I=0;I<=s;I++){const W=I/s,X=W*c+o,U=Math.sin(X),q=Math.cos(X);y.x=C*U,y.y=-D*n+m,y.z=C*q,u.push(y.x,y.y,y.z),M.set(U,R,q).normalize(),d.push(M.x,M.y,M.z),p.push(W,1-D),E.push(g++)}x.push(E)}for(let v=0;v<s;v++)for(let E=0;E<r;E++){const D=x[E][v],C=x[E+1][v],I=x[E+1][v+1],W=x[E][v+1];(t>0||E!==0)&&(h.push(D,C,W),b+=3),(e>0||E!==r-1)&&(h.push(C,I,W),b+=3)}l.addGroup(f,b,0),f+=b}function T(M){const y=g,b=new Ft,R=new F;let v=0;const E=M===!0?t:e,D=M===!0?1:-1;for(let I=1;I<=s;I++)u.push(0,m*D,0),d.push(0,D,0),p.push(.5,.5),g++;const C=g;for(let I=0;I<=s;I++){const X=I/s*c+o,U=Math.cos(X),q=Math.sin(X);R.x=E*q,R.y=m*D,R.z=E*U,u.push(R.x,R.y,R.z),d.push(0,D,0),b.x=U*.5+.5,b.y=q*.5*D+.5,p.push(b.x,b.y),g++}for(let I=0;I<s;I++){const W=y+I,X=C+I;M===!0?h.push(X,X+1,W):h.push(X+1,X,W),v+=3}l.addGroup(f,v,M===!0?1:2),f+=v}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ti(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class qa extends Ti{constructor(t=1,e=1,n=32,s=1,r=!1,a=0,o=Math.PI*2){super(0,t,e,n,s,r,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:s,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(t){return new qa(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Gs 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};const r=t/2,a=e/2,o=Math.floor(n),c=Math.floor(s),l=o+1,h=c+1,u=t/o,d=e/c,p=[],g=[],x=[],m=[];for(let f=0;f<h;f++){const A=f*d-a;for(let T=0;T<l;T++){const M=T*u-r;g.push(M,-A,0),x.push(0,0,1),m.push(T/o),m.push(1-f/c)}}for(let f=0;f<c;f++)for(let A=0;A<o;A++){const T=A+l*f,M=A+l*(f+1),y=A+1+l*(f+1),b=A+1+l*f;p.push(T,M,b),p.push(M,y,b)}this.setIndex(p),this.setAttribute("position",new we(g,3)),this.setAttribute("normal",new we(x,3)),this.setAttribute("uv",new we(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Gs(t.width,t.height,t.widthSegments,t.heightSegments)}}class Wn extends ye{constructor(t=1,e=32,n=16,s=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:s,phiLength:r,thetaStart:a,thetaLength:o},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const c=Math.min(a+o,Math.PI);let l=0;const h=[],u=new F,d=new F,p=[],g=[],x=[],m=[];for(let f=0;f<=n;f++){const A=[],T=f/n,M=a+T*o,y=t*Math.cos(M),b=Math.sqrt(t*t-y*y);let R=0;f===0&&a===0?R=.5/e:f===n&&c===Math.PI&&(R=-.5/e);for(let v=0;v<=e;v++){const E=v/e,D=s+E*r;u.x=-b*Math.cos(D),u.y=y,u.z=b*Math.sin(D),g.push(u.x,u.y,u.z),d.copy(u).normalize(),x.push(d.x,d.y,d.z),m.push(E+R,1-T),A.push(l++)}h.push(A)}for(let f=0;f<n;f++)for(let A=0;A<e;A++){const T=h[f][A+1],M=h[f][A],y=h[f+1][A],b=h[f+1][A+1];(f!==0||a>0)&&p.push(T,M,b),(f!==n-1||c<Math.PI)&&p.push(M,y,b)}this.setIndex(p),this.setAttribute("position",new we(g,3)),this.setAttribute("normal",new we(x,3)),this.setAttribute("uv",new we(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Wn(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}function zs(i){const t={};for(const e in i){t[e]={};for(const n in i[e]){const s=i[e][n];if(Yh(s))s.isRenderTargetTexture?(Ot("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=s.clone();else if(Array.isArray(s))if(Yh(s[0])){const r=[];for(let a=0,o=s.length;a<o;a++)r[a]=s[a].clone();t[e][n]=r}else t[e][n]=s.slice();else t[e][n]=s}}return t}function Ye(i){const t={};for(let e=0;e<i.length;e++){const n=zs(i[e]);for(const s in n)t[s]=n[s]}return t}function Yh(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function lm(i){const t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function sd(i){const t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Kt.workingColorSpace}const hm={clone:zs,merge:Ye};var um=`void main() {
304
+ */const Ul="185",op=0,Ph=1,cp=2,gr=1,lp=2,lr=3,wi=0,Ce=1,An=2,si=0,Is=1,Ri=2,Ih=3,Lh=4,hp=5,Gi=100,up=101,dp=102,fp=103,pp=104,mp=200,gp=201,_p=202,vp=203,mc=204,gc=205,xp=206,Mp=207,Sp=208,yp=209,Ep=210,bp=211,Ap=212,Tp=213,wp=214,_c=0,vc=1,xc=2,ks=3,Mc=4,Sc=5,yc=6,Ec=7,Fl=0,Rp=1,Cp=2,qn=0,k0=1,G0=2,H0=3,V0=4,W0=5,X0=6,q0=7,Y0=300,Zi=301,Gs=302,ho=303,uo=304,Qa=306,bc=1e3,hn=1001,Ac=1002,ke=1003,Dp=1004,Fr=1005,we=1006,fo=1007,Xi=1008,ln=1009,K0=1010,Z0=1011,Sr=1012,Ol=1013,Kn=1014,Vn=1015,xn=1016,zl=1017,Bl=1018,yr=1020,$0=35902,J0=35899,Q0=1021,j0=1022,un=1023,ai=1026,qi=1027,td=1028,kl=1029,$i=1030,Gl=1031,Hl=1033,wa=33776,Ra=33777,Ca=33778,Da=33779,Tc=35840,wc=35841,Rc=35842,Cc=35843,Dc=36196,Pc=37492,Ic=37496,Lc=37488,Nc=37489,Ua=37490,Uc=37491,Fc=37808,Oc=37809,zc=37810,Bc=37811,kc=37812,Gc=37813,Hc=37814,Vc=37815,Wc=37816,Xc=37817,qc=37818,Yc=37819,Kc=37820,Zc=37821,$c=36492,Jc=36494,Qc=36495,jc=36283,tl=36284,Fa=36285,el=36286,Pp=3200,nl=0,Ip=1,yi="",_n="srgb",Oa="srgb-linear",za="linear",te="srgb",ss=7680,Nh=519,Lp=512,Np=513,Up=514,Vl=515,Fp=516,Op=517,Wl=518,zp=519,il=35044,Uh="300 es",Wn=2e3,Er=2001;function Bp(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function Ba(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function kp(){const i=Ba("canvas");return i.style.display="block",i}const Fh={};function ka(...i){const t="THREE."+i.shift();console.log(t,...i)}function ed(i){const t=i[0];if(typeof t=="string"&&t.startsWith("TSL:")){const e=i[1];e&&e.isStackTrace?i[0]+=" "+e.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Ot(...i){i=ed(i);const t="THREE."+i.shift();{const e=i[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...i)}}function Yt(...i){i=ed(i);const t="THREE."+i.shift();{const e=i[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...i)}}function Ls(...i){const t=i.join(" ");t in Fh||(Fh[t]=!0,Ot(...i))}function Gp(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)})}const Hp={[_c]:vc,[xc]:yc,[Mc]:Ec,[ks]:Sc,[vc]:_c,[yc]:xc,[Ec]:Mc,[Sc]:ks};class ts{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){const n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){const n=this._listeners;if(n===void 0)return;const s=n[t];if(s!==void 0){const r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const n=e[t.type];if(n!==void 0){t.target=this;const s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,t);t.target=null}}}const He=["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"],po=Math.PI/180,sl=180/Math.PI;function Ai(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(He[i&255]+He[i>>8&255]+He[i>>16&255]+He[i>>24&255]+"-"+He[t&255]+He[t>>8&255]+"-"+He[t>>16&15|64]+He[t>>24&255]+"-"+He[e&63|128]+He[e>>8&255]+"-"+He[e>>16&255]+He[e>>24&255]+He[n&255]+He[n>>8&255]+He[n>>16&255]+He[n>>24&255]).toLowerCase()}function Xt(i,t,e){return Math.max(t,Math.min(e,i))}function Vp(i,t){return(i%t+t)%t}function mo(i,t,e){return(1-e)*i+e*t}function Hn(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("THREE.MathUtils: Invalid component type.")}}function ie(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("THREE.MathUtils: Invalid component type.")}}class Ft{static{Ft.prototype.isVector2=!0}constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("THREE.Vector2: 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("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,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=Xt(this.x,t.x,e.x),this.y=Xt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Xt(this.x,t,e),this.y=Xt(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Xt(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){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Xt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const 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){const 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}}class Xs{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],u=n[s+3],d=r[a+0],f=r[a+1],g=r[a+2],x=r[a+3];if(u!==x||c!==d||l!==f||h!==g){let m=c*d+l*f+h*g+u*x;m<0&&(d=-d,f=-f,g=-g,x=-x,m=-m);let p=1-o;if(m<.9995){const A=Math.acos(m),T=Math.sin(A);p=Math.sin(p*A)/T,o=Math.sin(o*A)/T,c=c*p+d*o,l=l*p+f*o,h=h*p+g*o,u=u*p+x*o}else{c=c*p+d*o,l=l*p+f*o,h=h*p+g*o,u=u*p+x*o;const A=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=A,l*=A,h*=A,u*=A}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,s,r,a){const o=n[s],c=n[s+1],l=n[s+2],h=n[s+3],u=r[a],d=r[a+1],f=r[a+2],g=r[a+3];return t[e]=o*g+h*u+c*f-l*d,t[e+1]=c*g+h*d+l*u-o*f,t[e+2]=l*g+h*f+o*d-c*u,t[e+3]=h*g-o*u-c*d-l*f,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){const 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),u=o(r/2),d=c(n/2),f=c(s/2),g=c(r/2);switch(a){case"XYZ":this._x=d*h*u+l*f*g,this._y=l*f*u-d*h*g,this._z=l*h*g+d*f*u,this._w=l*h*u-d*f*g;break;case"YXZ":this._x=d*h*u+l*f*g,this._y=l*f*u-d*h*g,this._z=l*h*g-d*f*u,this._w=l*h*u+d*f*g;break;case"ZXY":this._x=d*h*u-l*f*g,this._y=l*f*u+d*h*g,this._z=l*h*g+d*f*u,this._w=l*h*u-d*f*g;break;case"ZYX":this._x=d*h*u-l*f*g,this._y=l*f*u+d*h*g,this._z=l*h*g-d*f*u,this._w=l*h*u+d*f*g;break;case"YZX":this._x=d*h*u+l*f*g,this._y=l*f*u+d*h*g,this._z=l*h*g-d*f*u,this._w=l*h*u-d*f*g;break;case"XZY":this._x=d*h*u-l*f*g,this._y=l*f*u-d*h*g,this._z=l*h*g+d*f*u,this._w=l*h*u+d*f*g;break;default:Ot("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const 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){const 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],u=e[10],d=n+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(r-l)*f,this._z=(a-s)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-c)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+l)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(r-l)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(a-s)/f,this._x=(r+l)/f,this._y=(c+h)/f,this._z=.25*f}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(Xt(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const 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){const 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){let n=t._x,s=t._y,r=t._z,a=t._w,o=this.dot(t);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let c=1-e;if(o<.9995){const l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,e=Math.sin(e*l)/h,this._x=this._x*c+n*e,this._y=this._y*c+s*e,this._z=this._z*c+r*e,this._w=this._w*c+a*e,this._onChangeCallback()}else this._x=this._x*c+n*e,this._y=this._y*c+s*e,this._z=this._z*c+r*e,this._w=this._w*c+a*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const 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}}class F{static{F.prototype.isVector3=!0}constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("THREE.Vector3: 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("THREE.Vector3: 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(Oh.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Oh.setFromAxisAngle(t,e))}applyMatrix3(t){const 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){const 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){const 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),u=2*(r*n-a*e);return this.x=e+c*l+a*u-o*h,this.y=n+c*h+o*l-r*u,this.z=s+c*u+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){const 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=Xt(this.x,t.x,e.x),this.y=Xt(this.y,t.y,e.y),this.z=Xt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Xt(this.x,t,e),this.y=Xt(this.y,t,e),this.z=Xt(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Xt(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){const 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){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return go.copy(this).projectOnVector(t),this.sub(go)}reflect(t){return this.sub(go.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Xt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const 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){const 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){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),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(){const 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}}const go=new F,Oh=new Xs;class zt{static{zt.prototype.isMatrix3=!0}constructor(t,e,n,s,r,a,o,c,l){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){const 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){const 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){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],u=n[7],d=n[2],f=n[5],g=n[8],x=s[0],m=s[3],p=s[6],A=s[1],T=s[4],M=s[7],y=s[2],b=s[5],R=s[8];return r[0]=a*x+o*A+c*y,r[3]=a*m+o*T+c*b,r[6]=a*p+o*M+c*R,r[1]=l*x+h*A+u*y,r[4]=l*m+h*T+u*b,r[7]=l*p+h*M+u*R,r[2]=d*x+f*A+g*y,r[5]=d*m+f*T+g*b,r[8]=d*p+f*M+g*R,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],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(){const 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],u=h*a-o*l,d=o*c-h*r,f=l*r-a*c,g=e*u+n*d+s*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/g;return t[0]=u*x,t[1]=(s*l-h*n)*x,t[2]=(o*n-s*a)*x,t[3]=d*x,t[4]=(h*e-s*c)*x,t[5]=(s*r-o*e)*x,t[6]=f*x,t[7]=(n*c-l*e)*x,t[8]=(a*e-n*r)*x,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,r,a,o){const 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 Ls("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(_o.makeScale(t,e)),this}rotate(t){return Ls("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(_o.makeRotation(-t)),this}translate(t,e){return Ls("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(_o.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),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){const 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){const 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)}}const _o=new zt,zh=new zt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Bh=new zt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Wp(){const i={enabled:!0,workingColorSpace:Oa,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===te&&(s.r=ri(s.r),s.g=ri(s.g),s.b=ri(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===te&&(s.r=Ns(s.r),s.g=Ns(s.g),s.b=Ns(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===yi?za: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 Ls("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Ls("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({[Oa]:{primaries:t,whitePoint:n,transfer:za,toXYZ:zh,fromXYZ:Bh,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:_n},outputColorSpaceConfig:{drawingBufferColorSpace:_n}},[_n]:{primaries:t,whitePoint:n,transfer:te,toXYZ:zh,fromXYZ:Bh,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:_n}}}),i}const Kt=Wp();function ri(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Ns(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let rs;class Xp{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{rs===void 0&&(rs=Ba("canvas")),rs.width=t.width,rs.height=t.height;const s=rs.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),n=rs}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){const e=Ba("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const s=n.getImageData(0,0,t.width,t.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=ri(r[a]/255)*255;return n.putImageData(s,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(ri(e[n]/255)*255):e[n]=ri(e[n]);return{data:e,width:t.width,height:t.height}}else return Ot("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let qp=0;class Xl{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:qp++}),this.uuid=Ai(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?t.set(e.displayWidth,e.displayHeight,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const 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(vo(s[a].image)):r.push(vo(s[a]))}else r=vo(s);n.url=r}return e||(t.images[this.uuid]=n),n}}function vo(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?Xp.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Ot("Texture: Unable to serialize Texture."),{})}let Yp=0;const xo=new F;class qe extends ts{constructor(t=qe.DEFAULT_IMAGE,e=qe.DEFAULT_MAPPING,n=hn,s=hn,r=we,a=Xi,o=un,c=ln,l=qe.DEFAULT_ANISOTROPY,h=yi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Yp++}),this.uuid=Ai(),this.name="",this.source=new Xl(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 Ft(0,0),this.repeat=new Ft(1,1),this.center=new Ft(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new zt,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,this.normalized=!1}get width(){return this.source.getSize(xo).x}get height(){return this.source.getSize(xo).y}get depth(){return this.source.getSize(xo).z}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.normalized=t.normalized,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const n=t[e];if(n===void 0){Ot(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const s=this[e];if(s===void 0){Ot(`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){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Y0)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case bc:t.x=t.x-Math.floor(t.x);break;case hn:t.x=t.x<0?0:1;break;case Ac: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 bc:t.y=t.y-Math.floor(t.y);break;case hn:t.y=t.y<0?0:1;break;case Ac: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++}}qe.DEFAULT_IMAGE=null;qe.DEFAULT_MAPPING=Y0;qe.DEFAULT_ANISOTROPY=1;class pe{static{pe.prototype.isVector4=!0}constructor(t=0,e=0,n=0,s=1){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("THREE.Vector4: 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("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,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);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,s,r;const c=t.elements,l=c[0],h=c[4],u=c[8],d=c[1],f=c[5],g=c[9],x=c[2],m=c[6],p=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-x)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+x)<.1&&Math.abs(g+m)<.1&&Math.abs(l+f+p-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const T=(l+1)/2,M=(f+1)/2,y=(p+1)/2,b=(h+d)/4,R=(u+x)/4,v=(g+m)/4;return T>M&&T>y?T<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(T),s=b/n,r=R/n):M>y?M<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(M),n=b/s,r=v/s):y<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(y),n=R/r,s=v/r),this.set(n,s,r,e),this}let A=Math.sqrt((m-g)*(m-g)+(u-x)*(u-x)+(d-h)*(d-h));return Math.abs(A)<.001&&(A=1),this.x=(m-g)/A,this.y=(u-x)/A,this.z=(d-h)/A,this.w=Math.acos((l+f+p-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Xt(this.x,t.x,e.x),this.y=Xt(this.y,t.y,e.y),this.z=Xt(this.z,t.z,e.z),this.w=Xt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Xt(this.x,t,e),this.y=Xt(this.y,t,e),this.z=Xt(this.z,t,e),this.w=Xt(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Xt(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}}class Kp extends ts{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:we,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new pe(0,0,t,e),this.scissorTest=!1,this.viewport=new pe(0,0,t,e),this.textures=[];const s={width:t,height:e,depth:n.depth},r=new qe(s),a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(t={}){const e={minFilter:we,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].isData3DTexture!==!0&&(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;const s=Object.assign({},t.textures[e].image);this.textures[e].source=new Xl(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.multiview=t.multiview,this.useArrayDepthTexture=t.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Rn extends Kp{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class nd extends qe{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=ke,this.minFilter=ke,this.wrapR=hn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Zp extends qe{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=ke,this.minFilter=ke,this.wrapR=hn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class he{static{he.prototype.isMatrix4=!0}constructor(t,e,n,s,r,a,o,c,l,h,u,d,f,g,x,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,c,l,h,u,d,f,g,x,m)}set(t,e,n,s,r,a,o,c,l,h,u,d,f,g,x,m){const p=this.elements;return p[0]=t,p[4]=e,p[8]=n,p[12]=s,p[1]=r,p[5]=a,p[9]=o,p[13]=c,p[2]=l,p[6]=h,p[10]=u,p[14]=d,p[3]=f,p[7]=g,p[11]=x,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 he().fromArray(this.elements)}copy(t){const 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){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return this.determinantAffine()===0?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(t.determinantAffine()===0)return this.identity();const e=this.elements,n=t.elements,s=1/as.setFromMatrixColumn(t,0).length(),r=1/as.setFromMatrixColumn(t,1).length(),a=1/as.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){const 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),u=Math.sin(r);if(t.order==="XYZ"){const d=a*h,f=a*u,g=o*h,x=o*u;e[0]=c*h,e[4]=-c*u,e[8]=l,e[1]=f+g*l,e[5]=d-x*l,e[9]=-o*c,e[2]=x-d*l,e[6]=g+f*l,e[10]=a*c}else if(t.order==="YXZ"){const d=c*h,f=c*u,g=l*h,x=l*u;e[0]=d+x*o,e[4]=g*o-f,e[8]=a*l,e[1]=a*u,e[5]=a*h,e[9]=-o,e[2]=f*o-g,e[6]=x+d*o,e[10]=a*c}else if(t.order==="ZXY"){const d=c*h,f=c*u,g=l*h,x=l*u;e[0]=d-x*o,e[4]=-a*u,e[8]=g+f*o,e[1]=f+g*o,e[5]=a*h,e[9]=x-d*o,e[2]=-a*l,e[6]=o,e[10]=a*c}else if(t.order==="ZYX"){const d=a*h,f=a*u,g=o*h,x=o*u;e[0]=c*h,e[4]=g*l-f,e[8]=d*l+x,e[1]=c*u,e[5]=x*l+d,e[9]=f*l-g,e[2]=-l,e[6]=o*c,e[10]=a*c}else if(t.order==="YZX"){const d=a*c,f=a*l,g=o*c,x=o*l;e[0]=c*h,e[4]=x-d*u,e[8]=g*u+f,e[1]=u,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=f*u+g,e[10]=d-x*u}else if(t.order==="XZY"){const d=a*c,f=a*l,g=o*c,x=o*l;e[0]=c*h,e[4]=-u,e[8]=l*h,e[1]=d*u+x,e[5]=a*h,e[9]=f*u-g,e[2]=g*u-f,e[6]=o*h,e[10]=x*u+d}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($p,t,Jp)}lookAt(t,e,n){const s=this.elements;return nn.subVectors(t,e),nn.lengthSq()===0&&(nn.z=1),nn.normalize(),di.crossVectors(n,nn),di.lengthSq()===0&&(Math.abs(n.z)===1?nn.x+=1e-4:nn.z+=1e-4,nn.normalize(),di.crossVectors(n,nn)),di.normalize(),Or.crossVectors(nn,di),s[0]=di.x,s[4]=Or.x,s[8]=nn.x,s[1]=di.y,s[5]=Or.y,s[9]=nn.y,s[2]=di.z,s[6]=Or.z,s[10]=nn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],u=n[5],d=n[9],f=n[13],g=n[2],x=n[6],m=n[10],p=n[14],A=n[3],T=n[7],M=n[11],y=n[15],b=s[0],R=s[4],v=s[8],E=s[12],D=s[1],C=s[5],I=s[9],W=s[13],X=s[2],U=s[6],q=s[10],H=s[14],$=s[3],et=s[7],j=s[11],it=s[15];return r[0]=a*b+o*D+c*X+l*$,r[4]=a*R+o*C+c*U+l*et,r[8]=a*v+o*I+c*q+l*j,r[12]=a*E+o*W+c*H+l*it,r[1]=h*b+u*D+d*X+f*$,r[5]=h*R+u*C+d*U+f*et,r[9]=h*v+u*I+d*q+f*j,r[13]=h*E+u*W+d*H+f*it,r[2]=g*b+x*D+m*X+p*$,r[6]=g*R+x*C+m*U+p*et,r[10]=g*v+x*I+m*q+p*j,r[14]=g*E+x*W+m*H+p*it,r[3]=A*b+T*D+M*X+y*$,r[7]=A*R+T*C+M*U+y*et,r[11]=A*v+T*I+M*q+y*j,r[15]=A*E+T*W+M*H+y*it,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],s=t[8],r=t[12],a=t[1],o=t[5],c=t[9],l=t[13],h=t[2],u=t[6],d=t[10],f=t[14],g=t[3],x=t[7],m=t[11],p=t[15],A=c*f-l*d,T=o*f-l*u,M=o*d-c*u,y=a*f-l*h,b=a*d-c*h,R=a*u-o*h;return e*(x*A-m*T+p*M)-n*(g*A-m*y+p*b)+s*(g*T-x*y+p*R)-r*(g*M-x*b+m*R)}determinantAffine(){const t=this.elements,e=t[0],n=t[4],s=t[8],r=t[1],a=t[5],o=t[9],c=t[2],l=t[6],h=t[10];return e*(a*h-o*l)-n*(r*h-o*c)+s*(r*l-a*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const 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(){const 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],u=t[9],d=t[10],f=t[11],g=t[12],x=t[13],m=t[14],p=t[15],A=e*o-n*a,T=e*c-s*a,M=e*l-r*a,y=n*c-s*o,b=n*l-r*o,R=s*l-r*c,v=h*x-u*g,E=h*m-d*g,D=h*p-f*g,C=u*m-d*x,I=u*p-f*x,W=d*p-f*m,X=A*W-T*I+M*C+y*D-b*E+R*v;if(X===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const U=1/X;return t[0]=(o*W-c*I+l*C)*U,t[1]=(s*I-n*W-r*C)*U,t[2]=(x*R-m*b+p*y)*U,t[3]=(d*b-u*R-f*y)*U,t[4]=(c*D-a*W-l*E)*U,t[5]=(e*W-s*D+r*E)*U,t[6]=(m*M-g*R-p*T)*U,t[7]=(h*R-d*M+f*T)*U,t[8]=(a*I-o*D+l*v)*U,t[9]=(n*D-e*I-r*v)*U,t[10]=(g*b-x*M+p*A)*U,t[11]=(u*M-h*b-f*A)*U,t[12]=(o*E-a*C-c*v)*U,t[13]=(e*C-n*E+s*v)*U,t[14]=(x*T-g*y-m*A)*U,t[15]=(h*y-u*T+d*A)*U,this}scale(t){const 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(){const 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){const 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){const 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){const 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){const 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){const s=this.elements,r=e._x,a=e._y,o=e._z,c=e._w,l=r+r,h=a+a,u=o+o,d=r*l,f=r*h,g=r*u,x=a*h,m=a*u,p=o*u,A=c*l,T=c*h,M=c*u,y=n.x,b=n.y,R=n.z;return s[0]=(1-(x+p))*y,s[1]=(f+M)*y,s[2]=(g-T)*y,s[3]=0,s[4]=(f-M)*b,s[5]=(1-(d+p))*b,s[6]=(m+A)*b,s[7]=0,s[8]=(g+T)*R,s[9]=(m-A)*R,s[10]=(1-(d+x))*R,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,n){const s=this.elements;t.x=s[12],t.y=s[13],t.z=s[14];const r=this.determinantAffine();if(r===0)return n.set(1,1,1),e.identity(),this;let a=as.set(s[0],s[1],s[2]).length();const o=as.set(s[4],s[5],s[6]).length(),c=as.set(s[8],s[9],s[10]).length();r<0&&(a=-a),Sn.copy(this);const l=1/a,h=1/o,u=1/c;return Sn.elements[0]*=l,Sn.elements[1]*=l,Sn.elements[2]*=l,Sn.elements[4]*=h,Sn.elements[5]*=h,Sn.elements[6]*=h,Sn.elements[8]*=u,Sn.elements[9]*=u,Sn.elements[10]*=u,e.setFromRotationMatrix(Sn),n.x=a,n.y=o,n.z=c,this}makePerspective(t,e,n,s,r,a,o=Wn,c=!1){const l=this.elements,h=2*r/(e-t),u=2*r/(n-s),d=(e+t)/(e-t),f=(n+s)/(n-s);let g,x;if(c)g=r/(a-r),x=a*r/(a-r);else if(o===Wn)g=-(a+r)/(a-r),x=-2*a*r/(a-r);else if(o===Er)g=-a/(a-r),x=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=g,l[14]=x,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,s,r,a,o=Wn,c=!1){const l=this.elements,h=2/(e-t),u=2/(n-s),d=-(e+t)/(e-t),f=-(n+s)/(n-s);let g,x;if(c)g=1/(a-r),x=a/(a-r);else if(o===Wn)g=-2/(a-r),x=-(a+r)/(a-r);else if(o===Er)g=-1/(a-r),x=-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]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=f,l[2]=0,l[6]=0,l[10]=g,l[14]=x,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const 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){const 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}}const as=new F,Sn=new he,$p=new F(0,0,0),Jp=new F(1,1,1),di=new F,Or=new F,nn=new F,kh=new he,Gh=new Xs;class Ci{constructor(t=0,e=0,n=0,s=Ci.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){const s=t.elements,r=s[0],a=s[4],o=s[8],c=s[1],l=s[5],h=s[9],u=s[2],d=s[6],f=s[10];switch(e){case"XYZ":this._y=Math.asin(Xt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Xt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(Xt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-Xt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Xt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Xt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,f),this._y=0);break;default:Ot("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return kh.makeRotationFromQuaternion(t),this.setFromRotationMatrix(kh,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Gh.setFromEuler(this),this.setFromQuaternion(Gh,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}}Ci.DEFAULT_ORDER="XYZ";class ql{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let Qp=0;const Hh=new F,os=new Xs,Zn=new he,zr=new F,$s=new F,jp=new F,tm=new Xs,Vh=new F(1,0,0),Wh=new F(0,1,0),Xh=new F(0,0,1),qh={type:"added"},em={type:"removed"},cs={type:"childadded",child:null},Mo={type:"childremoved",child:null};class Re extends ts{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Qp++}),this.uuid=Ai(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Re.DEFAULT_UP.clone();const t=new F,e=new Ci,n=new Xs,s=new F(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 he},normalMatrix:{value:new zt}}),this.matrix=new he,this.matrixWorld=new he,this.matrixAutoUpdate=Re.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Re.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ql,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return os.setFromAxisAngle(t,e),this.quaternion.multiply(os),this}rotateOnWorldAxis(t,e){return os.setFromAxisAngle(t,e),this.quaternion.premultiply(os),this}rotateX(t){return this.rotateOnAxis(Vh,t)}rotateY(t){return this.rotateOnAxis(Wh,t)}rotateZ(t){return this.rotateOnAxis(Xh,t)}translateOnAxis(t,e){return Hh.copy(t).applyQuaternion(this.quaternion),this.position.add(Hh.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Vh,t)}translateY(t){return this.translateOnAxis(Wh,t)}translateZ(t){return this.translateOnAxis(Xh,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Zn.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?zr.copy(t):zr.set(t,e,n);const s=this.parent;this.updateWorldMatrix(!0,!1),$s.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Zn.lookAt($s,zr,this.up):Zn.lookAt(zr,$s,this.up),this.quaternion.setFromRotationMatrix(Zn),s&&(Zn.extractRotation(s.matrixWorld),os.setFromRotationMatrix(Zn),this.quaternion.premultiply(os.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(Yt("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(qh),cs.child=t,this.dispatchEvent(cs),cs.child=null):Yt("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}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(em),Mo.child=t,this.dispatchEvent(Mo),Mo.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Zn.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Zn.multiply(t.parent.matrixWorld)),t.applyMatrix4(Zn),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(qh),cs.child=t,this.dispatchEvent(cs),cs.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++){const a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const 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($s,t,jp),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose($s,tm,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(t!==null){const e=t.x,n=t.y,s=t.z,r=this.matrix.elements;r[12]+=e-r[0]*e-r[4]*n-r[8]*s,r[13]+=n-r[1]*e-r[5]*n-r[9]*s,r[14]+=s-r[2]*e-r[6]*n-r[10]*s}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e,n=!1){const s=this.parent;if(t===!0&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),e===!0){const r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,n)}}toJSON(t){const 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"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),this.static!==!1&&(s.static=this.static),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(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);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const u=c[l];r(t.shapes,u)}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)){const 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++){const c=this.animations[o];s.animations.push(r(t.animations,c))}}if(e){const o=a(t.geometries),c=a(t.materials),l=a(t.textures),h=a(t.images),u=a(t.shapes),d=a(t.skeletons),f=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),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=s,n;function a(o){const c=[];for(const l in o){const 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.pivot=t.pivot!==null?t.pivot.clone():null,this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const s=t.children[n];this.add(s.clone())}return this}}Re.DEFAULT_UP=new F(0,1,0);Re.DEFAULT_MATRIX_AUTO_UPDATE=!0;Re.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class wn extends Re{constructor(){super(),this.isGroup=!0,this.type="Group"}}const nm={type:"move"};class So{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new wn,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 wn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new F,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new F),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new wn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new F,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new F,this._grip.eventsEnabled=!1),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){const e=this._hand;if(e)for(const 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;const o=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){a=!0;for(const x of t.hand.values()){const m=e.getJointPose(x,n),p=this._getHandJoint(l,x);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}const h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,g=.005;l.inputState.pinching&&d>f+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&d<=f-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,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:t,target:this})));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(nm)))}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){const n=new wn;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const id={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},fi={h:0,s:0,l:0},Br={h:0,s:0,l:0};function yo(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}class Mt{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){const 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=_n){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Kt.colorSpaceToWorking(this,e),this}setRGB(t,e,n,s=Kt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Kt.colorSpaceToWorking(this,s),this}setHSL(t,e,n,s=Kt.workingColorSpace){if(t=Vp(t,1),e=Xt(e,0,1),n=Xt(n,0,1),e===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=yo(a,r,t+1/3),this.g=yo(a,r,t),this.b=yo(a,r,t-1/3)}return Kt.colorSpaceToWorking(this,s),this}setStyle(t,e=_n){function n(r){r!==void 0&&parseFloat(r)<1&&Ot("Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const 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:Ot("Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const 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);Ot("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=_n){const n=id[t.toLowerCase()];return n!==void 0?this.setHex(n,e):Ot("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=ri(t.r),this.g=ri(t.g),this.b=ri(t.b),this}copyLinearToSRGB(t){return this.r=Ns(t.r),this.g=Ns(t.g),this.b=Ns(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=_n){return Kt.workingToColorSpace(Ve.copy(this),t),Math.round(Xt(Ve.r*255,0,255))*65536+Math.round(Xt(Ve.g*255,0,255))*256+Math.round(Xt(Ve.b*255,0,255))}getHexString(t=_n){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Kt.workingColorSpace){Kt.workingToColorSpace(Ve.copy(this),e);const n=Ve.r,s=Ve.g,r=Ve.b,a=Math.max(n,s,r),o=Math.min(n,s,r);let c,l;const h=(o+a)/2;if(o===a)c=0,l=0;else{const u=a-o;switch(l=h<=.5?u/(a+o):u/(2-a-o),a){case n:c=(s-r)/u+(s<r?6:0);break;case s:c=(r-n)/u+2;break;case r:c=(n-s)/u+4;break}c/=6}return t.h=c,t.s=l,t.l=h,t}getRGB(t,e=Kt.workingColorSpace){return Kt.workingToColorSpace(Ve.copy(this),e),t.r=Ve.r,t.g=Ve.g,t.b=Ve.b,t}getStyle(t=_n){Kt.workingToColorSpace(Ve.copy(this),t);const e=Ve.r,n=Ve.g,s=Ve.b;return t!==_n?`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(fi),this.setHSL(fi.h+t,fi.s+e,fi.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(fi),t.getHSL(Br);const n=mo(fi.h,Br.h,e),s=mo(fi.s,Br.s,e),r=mo(fi.l,Br.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){const 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}}const Ve=new Mt;Mt.NAMES=id;class Yl{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Mt(t),this.near=e,this.far=n}clone(){return new Yl(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class sd extends Re{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 Ci,this.environmentIntensity=1,this.environmentRotation=new Ci,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){const 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}}const yn=new F,$n=new F,Eo=new F,Jn=new F,ls=new F,hs=new F,Yh=new F,bo=new F,Ao=new F,To=new F,wo=new pe,Ro=new pe,Co=new pe;class vn{constructor(t=new F,e=new F,n=new F){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,s){s.subVectors(n,e),yn.subVectors(t,e),s.cross(yn);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,n,s,r){yn.subVectors(s,e),$n.subVectors(n,e),Eo.subVectors(t,e);const a=yn.dot(yn),o=yn.dot($n),c=yn.dot(Eo),l=$n.dot($n),h=$n.dot(Eo),u=a*l-o*o;if(u===0)return r.set(0,0,0),null;const d=1/u,f=(l*c-o*h)*d,g=(a*h-o*c)*d;return r.set(1-f-g,g,f)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,Jn)===null?!1:Jn.x>=0&&Jn.y>=0&&Jn.x+Jn.y<=1}static getInterpolation(t,e,n,s,r,a,o,c){return this.getBarycoord(t,e,n,s,Jn)===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,Jn.x),c.addScaledVector(a,Jn.y),c.addScaledVector(o,Jn.z),c)}static getInterpolatedAttribute(t,e,n,s,r,a){return wo.setScalar(0),Ro.setScalar(0),Co.setScalar(0),wo.fromBufferAttribute(t,e),Ro.fromBufferAttribute(t,n),Co.fromBufferAttribute(t,s),a.setScalar(0),a.addScaledVector(wo,r.x),a.addScaledVector(Ro,r.y),a.addScaledVector(Co,r.z),a}static isFrontFacing(t,e,n,s){return yn.subVectors(n,e),$n.subVectors(t,e),yn.cross($n).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 yn.subVectors(this.c,this.b),$n.subVectors(this.a,this.b),yn.cross($n).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return vn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return vn.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,s,r){return vn.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}containsPoint(t){return vn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return vn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,s=this.b,r=this.c;let a,o;ls.subVectors(s,n),hs.subVectors(r,n),bo.subVectors(t,n);const c=ls.dot(bo),l=hs.dot(bo);if(c<=0&&l<=0)return e.copy(n);Ao.subVectors(t,s);const h=ls.dot(Ao),u=hs.dot(Ao);if(h>=0&&u<=h)return e.copy(s);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),e.copy(n).addScaledVector(ls,a);To.subVectors(t,r);const f=ls.dot(To),g=hs.dot(To);if(g>=0&&f<=g)return e.copy(r);const x=f*l-c*g;if(x<=0&&l>=0&&g<=0)return o=l/(l-g),e.copy(n).addScaledVector(hs,o);const m=h*g-f*u;if(m<=0&&u-h>=0&&f-g>=0)return Yh.subVectors(r,s),o=(u-h)/(u-h+(f-g)),e.copy(s).addScaledVector(Yh,o);const p=1/(m+x+d);return a=x*p,o=d*p,e.copy(n).addScaledVector(ls,a).addScaledVector(hs,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class Ar{constructor(t=new F(1/0,1/0,1/0),e=new F(-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(En.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(En.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){const n=En.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);const n=t.geometry;if(n!==void 0){const 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,En):En.fromBufferAttribute(r,a),En.applyMatrix4(t.matrixWorld),this.expandByPoint(En);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),kr.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),kr.copy(n.boundingBox)),kr.applyMatrix4(t.matrixWorld),this.union(kr)}const 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,En),En.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(Js),Gr.subVectors(this.max,Js),us.subVectors(t.a,Js),ds.subVectors(t.b,Js),fs.subVectors(t.c,Js),pi.subVectors(ds,us),mi.subVectors(fs,ds),Li.subVectors(us,fs);let e=[0,-pi.z,pi.y,0,-mi.z,mi.y,0,-Li.z,Li.y,pi.z,0,-pi.x,mi.z,0,-mi.x,Li.z,0,-Li.x,-pi.y,pi.x,0,-mi.y,mi.x,0,-Li.y,Li.x,0];return!Do(e,us,ds,fs,Gr)||(e=[1,0,0,0,1,0,0,0,1],!Do(e,us,ds,fs,Gr))?!1:(Hr.crossVectors(pi,mi),e=[Hr.x,Hr.y,Hr.z],Do(e,us,ds,fs,Gr))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,En).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(En).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:(Qn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Qn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Qn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Qn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Qn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Qn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Qn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Qn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Qn),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const Qn=[new F,new F,new F,new F,new F,new F,new F,new F],En=new F,kr=new Ar,us=new F,ds=new F,fs=new F,pi=new F,mi=new F,Li=new F,Js=new F,Gr=new F,Hr=new F,Ni=new F;function Do(i,t,e,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){Ni.fromArray(i,r);const o=s.x*Math.abs(Ni.x)+s.y*Math.abs(Ni.y)+s.z*Math.abs(Ni.z),c=t.dot(Ni),l=e.dot(Ni),h=n.dot(Ni);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const ii=im();function im(){const i=new ArrayBuffer(4),t=new Float32Array(i),e=new Uint32Array(i),n=new Uint32Array(512),s=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(n[c]=0,n[c|256]=32768,s[c]=24,s[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,s[c]=-l-1,s[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,s[c]=13,s[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,s[c]=24,s[c|256]=24):(n[c]=31744,n[c|256]=64512,s[c]=13,s[c|256]=13)}const r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,r[c]=l|h}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)a[c]=c<<23;a[31]=1199570944,a[32]=2147483648;for(let c=33;c<63;++c)a[c]=2147483648+(c-32<<23);a[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:t,uint32View:e,baseTable:n,shiftTable:s,mantissaTable:r,exponentTable:a,offsetTable:o}}function sm(i){Math.abs(i)>65504&&Ot("DataUtils.toHalfFloat(): Value out of range."),i=Xt(i,-65504,65504),ii.floatView[0]=i;const t=ii.uint32View[0],e=t>>23&511;return ii.baseTable[e]+((t&8388607)>>ii.shiftTable[e])}function rm(i){const t=i>>10;return ii.uint32View[0]=ii.mantissaTable[ii.offsetTable[t]+(i&1023)]+ii.exponentTable[t],ii.floatView[0]}class Us{static toHalfFloat(t){return sm(t)}static fromHalfFloat(t){return rm(t)}}const Ae=new F,Vr=new Ft;let am=0;class le extends ts{constructor(t,e,n=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:am++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=il,this.updateRanges=[],this.gpuType=Vn,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++)Vr.fromBufferAttribute(this,e),Vr.applyMatrix3(t),this.setXY(e,Vr.x,Vr.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)Ae.fromBufferAttribute(this,e),Ae.applyMatrix3(t),this.setXYZ(e,Ae.x,Ae.y,Ae.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)Ae.fromBufferAttribute(this,e),Ae.applyMatrix4(t),this.setXYZ(e,Ae.x,Ae.y,Ae.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Ae.fromBufferAttribute(this,e),Ae.applyNormalMatrix(t),this.setXYZ(e,Ae.x,Ae.y,Ae.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Ae.fromBufferAttribute(this,e),Ae.transformDirection(t),this.setXYZ(e,Ae.x,Ae.y,Ae.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=Hn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=ie(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Hn(e,this.array)),e}setX(t,e){return this.normalized&&(e=ie(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Hn(e,this.array)),e}setY(t,e){return this.normalized&&(e=ie(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=Hn(e,this.array)),e}setZ(t,e){return this.normalized&&(e=ie(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=Hn(e,this.array)),e}setW(t,e){return this.normalized&&(e=ie(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=ie(e,this.array),n=ie(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=ie(e,this.array),n=ie(n,this.array),s=ie(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=ie(e,this.array),n=ie(n,this.array),s=ie(s,this.array),r=ie(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(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==il&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}}class rd extends le{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class ad extends le{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class De extends le{constructor(t,e,n){super(new Float32Array(t),e,n)}}const om=new Ar,Qs=new F,Po=new F;class ja{constructor(t=new F,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;e!==void 0?n.copy(e):om.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){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const 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;Qs.subVectors(t,this.center);const e=Qs.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Qs,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):(Po.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Qs.copy(t.center).add(Po)),this.expandByPoint(Qs.copy(t.center).sub(Po))),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}}let cm=0;const fn=new he,Io=new Re,ps=new F,sn=new Ar,js=new Ar,Ne=new F;class Ee extends ts{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:cm++}),this.uuid=Ai(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(Bp(t)?ad:rd)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new zt().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}const 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._transformed=!0,this}applyQuaternion(t){return fn.makeRotationFromQuaternion(t),this.applyMatrix4(fn),this}rotateX(t){return fn.makeRotationX(t),this.applyMatrix4(fn),this}rotateY(t){return fn.makeRotationY(t),this.applyMatrix4(fn),this}rotateZ(t){return fn.makeRotationZ(t),this.applyMatrix4(fn),this}translate(t,e,n){return fn.makeTranslation(t,e,n),this.applyMatrix4(fn),this}scale(t,e,n){return fn.makeScale(t,e,n),this.applyMatrix4(fn),this}lookAt(t){return Io.lookAt(t),Io.updateMatrix(),this.applyMatrix4(Io.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ps).negate(),this.translate(ps.x,ps.y,ps.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const n=[];for(let s=0,r=t.length;s<r;s++){const a=t[s];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new De(n,3))}else{const n=Math.min(t.length,e.count);for(let s=0;s<n;s++){const r=t[s];e.setXYZ(s,r.x,r.y,r.z||0)}t.length>e.count&&Ot("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 Ar);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Yt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new F(-1/0,-1/0,-1/0),new F(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++){const r=e[n];sn.setFromBufferAttribute(r),this.morphTargetsRelative?(Ne.addVectors(this.boundingBox.min,sn.min),this.boundingBox.expandByPoint(Ne),Ne.addVectors(this.boundingBox.max,sn.max),this.boundingBox.expandByPoint(Ne)):(this.boundingBox.expandByPoint(sn.min),this.boundingBox.expandByPoint(sn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Yt('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 ja);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Yt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new F,1/0);return}if(t){const n=this.boundingSphere.center;if(sn.setFromBufferAttribute(t),e)for(let r=0,a=e.length;r<a;r++){const o=e[r];js.setFromBufferAttribute(o),this.morphTargetsRelative?(Ne.addVectors(sn.min,js.min),sn.expandByPoint(Ne),Ne.addVectors(sn.max,js.max),sn.expandByPoint(Ne)):(sn.expandByPoint(js.min),sn.expandByPoint(js.max))}sn.getCenter(n);let s=0;for(let r=0,a=t.count;r<a;r++)Ne.fromBufferAttribute(t,r),s=Math.max(s,n.distanceToSquared(Ne));if(e)for(let r=0,a=e.length;r<a;r++){const o=e[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)Ne.fromBufferAttribute(o,l),c&&(ps.fromBufferAttribute(t,l),Ne.add(ps)),s=Math.max(s,n.distanceToSquared(Ne))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&Yt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){Yt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,s=e.normal,r=e.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new le(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],c=[];for(let v=0;v<n.count;v++)o[v]=new F,c[v]=new F;const l=new F,h=new F,u=new F,d=new Ft,f=new Ft,g=new Ft,x=new F,m=new F;function p(v,E,D){l.fromBufferAttribute(n,v),h.fromBufferAttribute(n,E),u.fromBufferAttribute(n,D),d.fromBufferAttribute(r,v),f.fromBufferAttribute(r,E),g.fromBufferAttribute(r,D),h.sub(l),u.sub(l),f.sub(d),g.sub(d);const C=1/(f.x*g.y-g.x*f.y);isFinite(C)&&(x.copy(h).multiplyScalar(g.y).addScaledVector(u,-f.y).multiplyScalar(C),m.copy(u).multiplyScalar(f.x).addScaledVector(h,-g.x).multiplyScalar(C),o[v].add(x),o[E].add(x),o[D].add(x),c[v].add(m),c[E].add(m),c[D].add(m))}let A=this.groups;A.length===0&&(A=[{start:0,count:t.count}]);for(let v=0,E=A.length;v<E;++v){const D=A[v],C=D.start,I=D.count;for(let W=C,X=C+I;W<X;W+=3)p(t.getX(W+0),t.getX(W+1),t.getX(W+2))}const T=new F,M=new F,y=new F,b=new F;function R(v){y.fromBufferAttribute(s,v),b.copy(y);const E=o[v];T.copy(E),T.sub(y.multiplyScalar(y.dot(E))).normalize(),M.crossVectors(b,E);const C=M.dot(c[v])<0?-1:1;a.setXYZW(v,T.x,T.y,T.z,C)}for(let v=0,E=A.length;v<E;++v){const D=A[v],C=D.start,I=D.count;for(let W=C,X=C+I;W<X;W+=3)R(t.getX(W+0)),R(t.getX(W+1)),R(t.getX(W+2))}this._transformed=!0}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==e.count)n=new le(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const s=new F,r=new F,a=new F,o=new F,c=new F,l=new F,h=new F,u=new F;if(t)for(let d=0,f=t.count;d<f;d+=3){const g=t.getX(d+0),x=t.getX(d+1),m=t.getX(d+2);s.fromBufferAttribute(e,g),r.fromBufferAttribute(e,x),a.fromBufferAttribute(e,m),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),o.fromBufferAttribute(n,g),c.fromBufferAttribute(n,x),l.fromBufferAttribute(n,m),o.add(h),c.add(h),l.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(x,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let d=0,f=e.count;d<f;d+=3)s.fromBufferAttribute(e,d+0),r.fromBufferAttribute(e,d+1),a.fromBufferAttribute(e,d+2),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)Ne.fromBufferAttribute(t,e),Ne.normalize(),t.setXYZ(e,Ne.x,Ne.y,Ne.z)}toNonIndexed(){function t(o,c){const l=o.array,h=o.itemSize,u=o.normalized,d=new l.constructor(c.length*h);let f=0,g=0;for(let x=0,m=c.length;x<m;x++){o.isInterleavedBufferAttribute?f=c[x]*o.data.stride+o.offset:f=c[x]*h;for(let p=0;p<h;p++)d[g++]=l[f++]}return new le(d,h,u)}if(this.index===null)return Ot("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Ee,n=this.index.array,s=this.attributes;for(const o in s){const c=s[o],l=t(c,n);e.setAttribute(o,l)}const r=this.morphAttributes;for(const o in r){const c=[],l=r[o];for(let h=0,u=l.length;h<u;h++){const d=l[h],f=t(d,n);c.push(f)}e.morphAttributes[o]=c}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const c in n){const l=n[c];t.data.attributes[c]=l.toJSON(t.data)}const s={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){const f=l[u];h.push(f.toJSON(t.data))}h.length>0&&(s[c]=h,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone());const s=t.attributes;for(const l in s){const h=s[l];this.setAttribute(l,h.clone(e))}const r=t.morphAttributes;for(const l in r){const h=[],u=r[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(e));this.morphAttributes[l]=h}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let l=0,h=a.length;l<h;l++){const u=a[l];this.addGroup(u.start,u.count,u.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const 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._transformed=t._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class lm{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=il,this.updateRanges=[],this.version=0,this.uuid=Ai()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let s=0,r=this.stride;s<r;s++)this.array[t+s]=e.array[n+s];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ai()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ai()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Ye=new F;class Ga{constructor(t,e,n,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)Ye.fromBufferAttribute(this,e),Ye.applyMatrix4(t),this.setXYZ(e,Ye.x,Ye.y,Ye.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Ye.fromBufferAttribute(this,e),Ye.applyNormalMatrix(t),this.setXYZ(e,Ye.x,Ye.y,Ye.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Ye.fromBufferAttribute(this,e),Ye.transformDirection(t),this.setXYZ(e,Ye.x,Ye.y,Ye.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=Hn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=ie(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=ie(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=ie(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=ie(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=ie(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Hn(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Hn(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Hn(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Hn(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=ie(e,this.array),n=ie(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=ie(e,this.array),n=ie(n,this.array),s=ie(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=s,this}setXYZW(t,e,n,s,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=ie(e,this.array),n=ie(n,this.array),s=ie(s,this.array),r=ie(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=s,this.data.array[t+3]=r,this}clone(t){if(t===void 0){ka("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[s+r])}return new le(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Ga(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){ka("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[s+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let hm=0;class es extends ts{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:hm++}),this.uuid=Ai(),this.name="",this.type="Material",this.blending=Is,this.side=wi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=mc,this.blendDst=gc,this.blendEquation=Gi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Mt(0,0,0),this.blendAlpha=0,this.depthFunc=ks,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Nh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ss,this.stencilZFail=ss,this.stencilZPass=ss,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){Ot(`Material: parameter '${e}' has value of undefined.`);continue}const s=this[e];if(s===void 0){Ot(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const 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!==Is&&(n.blending=this.blending),this.side!==wi&&(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!==mc&&(n.blendSrc=this.blendSrc),this.blendDst!==gc&&(n.blendDst=this.blendDst),this.blendEquation!==Gi&&(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!==ks&&(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!==Nh&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ss&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ss&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ss&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){const a=[];for(const o in r){const c=r[o];delete c.metadata,a.push(c)}return a}if(e){const r=s(t.textures),a=s(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(t,e){if(t.uuid!==void 0&&(this.uuid=t.uuid),t.name!==void 0&&(this.name=t.name),t.color!==void 0&&this.color!==void 0&&this.color.setHex(t.color),t.roughness!==void 0&&(this.roughness=t.roughness),t.metalness!==void 0&&(this.metalness=t.metalness),t.sheen!==void 0&&(this.sheen=t.sheen),t.sheenColor!==void 0&&(this.sheenColor=new Mt().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(this.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(t.emissive),t.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(t.specular),t.specularIntensity!==void 0&&(this.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(this.shininess=t.shininess),t.clearcoat!==void 0&&(this.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(this.dispersion=t.dispersion),t.iridescence!==void 0&&(this.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(this.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(this.transmission=t.transmission),t.thickness!==void 0&&(this.thickness=t.thickness),t.attenuationDistance!==void 0&&(this.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(this.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(this.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(this.fog=t.fog),t.flatShading!==void 0&&(this.flatShading=t.flatShading),t.blending!==void 0&&(this.blending=t.blending),t.combine!==void 0&&(this.combine=t.combine),t.side!==void 0&&(this.side=t.side),t.shadowSide!==void 0&&(this.shadowSide=t.shadowSide),t.opacity!==void 0&&(this.opacity=t.opacity),t.transparent!==void 0&&(this.transparent=t.transparent),t.alphaTest!==void 0&&(this.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(this.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(this.depthFunc=t.depthFunc),t.depthTest!==void 0&&(this.depthTest=t.depthTest),t.depthWrite!==void 0&&(this.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(this.colorWrite=t.colorWrite),t.blendSrc!==void 0&&(this.blendSrc=t.blendSrc),t.blendDst!==void 0&&(this.blendDst=t.blendDst),t.blendEquation!==void 0&&(this.blendEquation=t.blendEquation),t.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=t.blendSrcAlpha),t.blendDstAlpha!==void 0&&(this.blendDstAlpha=t.blendDstAlpha),t.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=t.blendEquationAlpha),t.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(t.blendColor),t.blendAlpha!==void 0&&(this.blendAlpha=t.blendAlpha),t.stencilWriteMask!==void 0&&(this.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(this.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(this.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(this.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(this.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(this.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(this.stencilZPass=t.stencilZPass),t.stencilWrite!==void 0&&(this.stencilWrite=t.stencilWrite),t.wireframe!==void 0&&(this.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(this.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(this.rotation=t.rotation),t.linewidth!==void 0&&(this.linewidth=t.linewidth),t.dashSize!==void 0&&(this.dashSize=t.dashSize),t.gapSize!==void 0&&(this.gapSize=t.gapSize),t.scale!==void 0&&(this.scale=t.scale),t.polygonOffset!==void 0&&(this.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=t.polygonOffsetUnits),t.dithering!==void 0&&(this.dithering=t.dithering),t.alphaToCoverage!==void 0&&(this.alphaToCoverage=t.alphaToCoverage),t.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=t.premultipliedAlpha),t.forceSinglePass!==void 0&&(this.forceSinglePass=t.forceSinglePass),t.allowOverride!==void 0&&(this.allowOverride=t.allowOverride),t.visible!==void 0&&(this.visible=t.visible),t.toneMapped!==void 0&&(this.toneMapped=t.toneMapped),t.userData!==void 0&&(this.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?this.vertexColors=t.vertexColors>0:this.vertexColors=t.vertexColors),t.size!==void 0&&(this.size=t.size),t.sizeAttenuation!==void 0&&(this.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(this.map=e[t.map]||null),t.matcap!==void 0&&(this.matcap=e[t.matcap]||null),t.alphaMap!==void 0&&(this.alphaMap=e[t.alphaMap]||null),t.bumpMap!==void 0&&(this.bumpMap=e[t.bumpMap]||null),t.bumpScale!==void 0&&(this.bumpScale=t.bumpScale),t.normalMap!==void 0&&(this.normalMap=e[t.normalMap]||null),t.normalMapType!==void 0&&(this.normalMapType=t.normalMapType),t.normalScale!==void 0){let n=t.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Ft().fromArray(n)}return t.displacementMap!==void 0&&(this.displacementMap=e[t.displacementMap]||null),t.displacementScale!==void 0&&(this.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(this.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(this.roughnessMap=e[t.roughnessMap]||null),t.metalnessMap!==void 0&&(this.metalnessMap=e[t.metalnessMap]||null),t.emissiveMap!==void 0&&(this.emissiveMap=e[t.emissiveMap]||null),t.emissiveIntensity!==void 0&&(this.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(this.specularMap=e[t.specularMap]||null),t.specularIntensityMap!==void 0&&(this.specularIntensityMap=e[t.specularIntensityMap]||null),t.specularColorMap!==void 0&&(this.specularColorMap=e[t.specularColorMap]||null),t.envMap!==void 0&&(this.envMap=e[t.envMap]||null),t.envMapRotation!==void 0&&this.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(this.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(this.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(this.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(this.lightMap=e[t.lightMap]||null),t.lightMapIntensity!==void 0&&(this.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(this.aoMap=e[t.aoMap]||null),t.aoMapIntensity!==void 0&&(this.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(this.gradientMap=e[t.gradientMap]||null),t.clearcoatMap!==void 0&&(this.clearcoatMap=e[t.clearcoatMap]||null),t.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=e[t.clearcoatRoughnessMap]||null),t.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=e[t.clearcoatNormalMap]||null),t.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Ft().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(this.iridescenceMap=e[t.iridescenceMap]||null),t.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=e[t.iridescenceThicknessMap]||null),t.transmissionMap!==void 0&&(this.transmissionMap=e[t.transmissionMap]||null),t.thicknessMap!==void 0&&(this.thicknessMap=e[t.thicknessMap]||null),t.anisotropyMap!==void 0&&(this.anisotropyMap=e[t.anisotropyMap]||null),t.sheenColorMap!==void 0&&(this.sheenColorMap=e[t.sheenColorMap]||null),t.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=e[t.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const 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.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class hr extends es{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Mt(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!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.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let ms;const tr=new F,gs=new F,_s=new F,vs=new Ft,er=new Ft,od=new he,Wr=new F,nr=new F,Xr=new F,Kh=new Ft,Lo=new Ft,Zh=new Ft;class qr extends Re{constructor(t=new hr){if(super(),this.isSprite=!0,this.type="Sprite",ms===void 0){ms=new Ee;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new lm(e,5);ms.setIndex([0,1,2,0,2,3]),ms.setAttribute("position",new Ga(n,3,0,!1)),ms.setAttribute("uv",new Ga(n,2,3,!1))}this.geometry=ms,this.material=t,this.center=new Ft(.5,.5),this.count=1}raycast(t,e){t.camera===null&&Yt('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),gs.setFromMatrixScale(this.matrixWorld),od.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),_s.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&gs.multiplyScalar(-_s.z);const n=this.material.rotation;let s,r;n!==0&&(r=Math.cos(n),s=Math.sin(n));const a=this.center;Yr(Wr.set(-.5,-.5,0),_s,a,gs,s,r),Yr(nr.set(.5,-.5,0),_s,a,gs,s,r),Yr(Xr.set(.5,.5,0),_s,a,gs,s,r),Kh.set(0,0),Lo.set(1,0),Zh.set(1,1);let o=t.ray.intersectTriangle(Wr,nr,Xr,!1,tr);if(o===null&&(Yr(nr.set(-.5,.5,0),_s,a,gs,s,r),Lo.set(0,1),o=t.ray.intersectTriangle(Wr,Xr,nr,!1,tr),o===null))return;const c=t.ray.origin.distanceTo(tr);c<t.near||c>t.far||e.push({distance:c,point:tr.clone(),uv:vn.getInterpolation(tr,Wr,nr,Xr,Kh,Lo,Zh,new Ft),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}}function Yr(i,t,e,n,s,r){vs.subVectors(i,e).addScalar(.5).multiply(n),s!==void 0?(er.x=r*vs.x-s*vs.y,er.y=s*vs.x+r*vs.y):er.copy(vs),i.copy(t),i.x+=er.x,i.y+=er.y,i.applyMatrix4(od)}const jn=new F,No=new F,Kr=new F,gi=new F,Uo=new F,Zr=new F,Fo=new F;class Kl{constructor(t=new F,e=new F(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,jn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const 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){const e=jn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(jn.copy(this.origin).addScaledVector(this.direction,e),jn.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){No.copy(t).add(e).multiplyScalar(.5),Kr.copy(e).sub(t).normalize(),gi.copy(this.origin).sub(No);const r=t.distanceTo(e)*.5,a=-this.direction.dot(Kr),o=gi.dot(this.direction),c=-gi.dot(Kr),l=gi.lengthSq(),h=Math.abs(1-a*a);let u,d,f,g;if(h>0)if(u=a*c-o,d=a*o-c,g=r*h,u>=0)if(d>=-g)if(d<=g){const x=1/h;u*=x,d*=x,f=u*(u+a*d+2*o)+d*(a*u+d+2*c)+l}else d=r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d=-r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d<=-g?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l):d<=g?(u=0,d=Math.min(Math.max(-r,-c),r),f=d*(d+2*c)+l):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(No).addScaledVector(Kr,d),f}intersectSphere(t,e){jn.subVectors(t.center,this.origin);const n=jn.dot(this.direction),s=jn.dot(jn)-n*n,r=t.radius*t.radius;if(s>r)return null;const 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){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const 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;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(t.min.x-d.x)*l,s=(t.max.x-d.x)*l):(n=(t.max.x-d.x)*l,s=(t.min.x-d.x)*l),h>=0?(r=(t.min.y-d.y)*h,a=(t.max.y-d.y)*h):(r=(t.max.y-d.y)*h,a=(t.min.y-d.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),u>=0?(o=(t.min.z-d.z)*u,c=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,c=(t.min.z-d.z)*u),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,jn)!==null}intersectTriangle(t,e,n,s,r){Uo.subVectors(e,t),Zr.subVectors(n,t),Fo.crossVectors(Uo,Zr);let a=this.direction.dot(Fo),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;gi.subVectors(this.origin,t);const c=o*this.direction.dot(Zr.crossVectors(gi,Zr));if(c<0)return null;const l=o*this.direction.dot(Uo.cross(gi));if(l<0||c+l>a)return null;const h=-o*gi.dot(Fo);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)}}class Ji extends es{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Mt(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 Ci,this.combine=Fl,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const $h=new he,Ui=new Kl,$r=new ja,Jh=new F,Jr=new F,Qr=new F,jr=new F,Oo=new F,ta=new F,Qh=new F,ea=new F;class se extends Re{constructor(t=new Ee,e=new Ji){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(t,e){const n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(s,t);const o=this.morphTargetInfluences;if(r&&o){ta.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const h=o[c],u=r[c];h!==0&&(Oo.fromBufferAttribute(u,t),a?ta.addScaledVector(Oo,h):ta.addScaledVector(Oo.sub(e),h))}e.add(ta)}return e}raycast(t,e){const n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),$r.copy(n.boundingSphere),$r.applyMatrix4(r),Ui.copy(t.ray).recast(t.near),!($r.containsPoint(Ui.origin)===!1&&(Ui.intersectSphere($r,Jh)===null||Ui.origin.distanceToSquared(Jh)>(t.far-t.near)**2))&&($h.copy(r).invert(),Ui.copy(t.ray).applyMatrix4($h),!(n.boundingBox!==null&&Ui.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Ui)))}_computeIntersections(t,e,n){let s;const r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,x=d.length;g<x;g++){const m=d[g],p=a[m.materialIndex],A=Math.max(m.start,f.start),T=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let M=A,y=T;M<y;M+=3){const b=o.getX(M),R=o.getX(M+1),v=o.getX(M+2);s=na(this,p,t,n,l,h,u,b,R,v),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=m.materialIndex,e.push(s))}}else{const g=Math.max(0,f.start),x=Math.min(o.count,f.start+f.count);for(let m=g,p=x;m<p;m+=3){const A=o.getX(m),T=o.getX(m+1),M=o.getX(m+2);s=na(this,a,t,n,l,h,u,A,T,M),s&&(s.faceIndex=Math.floor(m/3),e.push(s))}}else if(c!==void 0)if(Array.isArray(a))for(let g=0,x=d.length;g<x;g++){const m=d[g],p=a[m.materialIndex],A=Math.max(m.start,f.start),T=Math.min(c.count,Math.min(m.start+m.count,f.start+f.count));for(let M=A,y=T;M<y;M+=3){const b=M,R=M+1,v=M+2;s=na(this,p,t,n,l,h,u,b,R,v),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=m.materialIndex,e.push(s))}}else{const g=Math.max(0,f.start),x=Math.min(c.count,f.start+f.count);for(let m=g,p=x;m<p;m+=3){const A=m,T=m+1,M=m+2;s=na(this,a,t,n,l,h,u,A,T,M),s&&(s.faceIndex=Math.floor(m/3),e.push(s))}}}}function um(i,t,e,n,s,r,a,o){let c;if(t.side===Ce?c=n.intersectTriangle(a,r,s,!0,o):c=n.intersectTriangle(s,r,a,t.side===wi,o),c===null)return null;ea.copy(o),ea.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(ea);return l<e.near||l>e.far?null:{distance:l,point:ea.clone(),object:i}}function na(i,t,e,n,s,r,a,o,c,l){i.getVertexPosition(o,Jr),i.getVertexPosition(c,Qr),i.getVertexPosition(l,jr);const h=um(i,t,e,n,Jr,Qr,jr,Qh);if(h){const u=new F;vn.getBarycoord(Qh,Jr,Qr,jr,u),s&&(h.uv=vn.getInterpolatedAttribute(s,o,c,l,u,new Ft)),r&&(h.uv1=vn.getInterpolatedAttribute(r,o,c,l,u,new Ft)),a&&(h.normal=vn.getInterpolatedAttribute(a,o,c,l,u,new F),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new F,materialIndex:0};vn.getNormal(Jr,Qr,jr,d.normal),h.face=d,h.barycoord=u}return h}class Zl extends qe{constructor(t=null,e=1,n=1,s,r,a,o,c,l=ke,h=ke,u,d){super(null,a,o,c,l,h,s,r,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const zo=new F,dm=new F,fm=new zt;class ki{constructor(t=new F(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){const s=zo.subVectors(n,e).cross(dm.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e,n=!0){const s=t.delta(zo),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const a=-(t.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:e.copy(t.start).addScaledVector(s,a)}intersectsLine(t){const 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){const n=e||fm.getNormalMatrix(t),s=this.coplanarPoint(zo).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)}}const Fi=new ja,pm=new Ft(.5,.5),ia=new F;class $l{constructor(t=new ki,e=new ki,n=new ki,s=new ki,r=new ki,a=new ki){this.planes=[t,e,n,s,r,a]}set(t,e,n,s,r,a){const 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){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=Wn,n=!1){const s=this.planes,r=t.elements,a=r[0],o=r[1],c=r[2],l=r[3],h=r[4],u=r[5],d=r[6],f=r[7],g=r[8],x=r[9],m=r[10],p=r[11],A=r[12],T=r[13],M=r[14],y=r[15];if(s[0].setComponents(l-a,f-h,p-g,y-A).normalize(),s[1].setComponents(l+a,f+h,p+g,y+A).normalize(),s[2].setComponents(l+o,f+u,p+x,y+T).normalize(),s[3].setComponents(l-o,f-u,p-x,y-T).normalize(),n)s[4].setComponents(c,d,m,M).normalize(),s[5].setComponents(l-c,f-d,p-m,y-M).normalize();else if(s[4].setComponents(l-c,f-d,p-m,y-M).normalize(),e===Wn)s[5].setComponents(l+c,f+d,p+m,y+M).normalize();else if(e===Er)s[5].setComponents(c,d,m,M).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(),Fi.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Fi.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Fi)}intersectsSprite(t){Fi.center.set(0,0,0);const e=pm.distanceTo(t.center);return Fi.radius=.7071067811865476+e,Fi.applyMatrix4(t.matrixWorld),this.intersectsSphere(Fi)}intersectsSphere(t){const 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){const e=this.planes;for(let n=0;n<6;n++){const s=e[n];if(ia.x=s.normal.x>0?t.max.x:t.min.x,ia.y=s.normal.y>0?t.max.y:t.min.y,ia.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(ia)<0)return!1}return!0}containsPoint(t){const 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)}}class cd extends es{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Mt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const jh=new he,rl=new Kl,sa=new ja,ra=new F;class Pa extends Re{constructor(t=new Ee,e=new cd){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const n=this.geometry,s=this.matrixWorld,r=t.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),sa.copy(n.boundingSphere),sa.applyMatrix4(s),sa.radius+=r,t.ray.intersectsSphere(sa)===!1)return;jh.copy(s).invert(),rl.copy(t.ray).applyMatrix4(jh);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=n.index,u=n.attributes.position;if(l!==null){const d=Math.max(0,a.start),f=Math.min(l.count,a.start+a.count);for(let g=d,x=f;g<x;g++){const m=l.getX(g);ra.fromBufferAttribute(u,m),tu(ra,m,c,s,t,e,this)}}else{const d=Math.max(0,a.start),f=Math.min(u.count,a.start+a.count);for(let g=d,x=f;g<x;g++)ra.fromBufferAttribute(u,g),tu(ra,g,c,s,t,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function tu(i,t,e,n,s,r,a){const o=rl.distanceSqToPoint(i);if(o<e){const c=new F;rl.closestPointToPoint(i,c),c.applyMatrix4(n);const 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})}}class ld extends qe{constructor(t=[],e=Zi,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}}class oi extends qe{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}}class Hs extends qe{constructor(t,e,n=Kn,s,r,a,o=ke,c=ke,l,h=ai,u=1){if(h!==ai&&h!==qi)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:t,height:e,depth:u};super(d,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 Xl(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}class mm extends Hs{constructor(t,e=Kn,n=Zi,s,r,a=ke,o=ke,c,l=ai){const h={width:t,height:t,depth:1},u=[h,h,h,h,h,h];super(t,t,e,n,s,r,a,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}class hd extends qe{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class Mn extends Ee{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};const o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);const c=[],l=[],h=[],u=[];let d=0,f=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 De(l,3)),this.setAttribute("normal",new De(h,3)),this.setAttribute("uv",new De(u,2));function g(x,m,p,A,T,M,y,b,R,v,E){const D=M/R,C=y/v,I=M/2,W=y/2,X=b/2,U=R+1,q=v+1;let H=0,$=0;const et=new F;for(let j=0;j<q;j++){const it=j*C-W;for(let ut=0;ut<U;ut++){const kt=ut*D-I;et[x]=kt*A,et[m]=it*T,et[p]=X,l.push(et.x,et.y,et.z),et[x]=0,et[m]=0,et[p]=b>0?1:-1,h.push(et.x,et.y,et.z),u.push(ut/R),u.push(1-j/v),H+=1}}for(let j=0;j<v;j++)for(let it=0;it<R;it++){const ut=d+it+U*j,kt=d+it+U*(j+1),qt=d+(it+1)+U*(j+1),Bt=d+(it+1)+U*j;c.push(ut,kt,Bt),c.push(kt,qt,Bt),$+=6}o.addGroup(f,$,E),f+=$,d+=H}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Mn(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class Jl extends Ee{constructor(t=1,e=32,n=0,s=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:s},e=Math.max(3,e);const r=[],a=[],o=[],c=[],l=new F,h=new Ft;a.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let u=0,d=3;u<=e;u++,d+=3){const f=n+u/e*s;l.x=t*Math.cos(f),l.y=t*Math.sin(f),a.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(a[d]/t+1)/2,h.y=(a[d+1]/t+1)/2,c.push(h.x,h.y)}for(let u=1;u<=e;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new De(a,3)),this.setAttribute("normal",new De(o,3)),this.setAttribute("uv",new De(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Jl(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Pi extends Ee{constructor(t=1,e=1,n=1,s=32,r=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:s,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:c};const l=this;s=Math.floor(s),r=Math.floor(r);const h=[],u=[],d=[],f=[];let g=0;const x=[],m=n/2;let p=0;A(),a===!1&&(t>0&&T(!0),e>0&&T(!1)),this.setIndex(h),this.setAttribute("position",new De(u,3)),this.setAttribute("normal",new De(d,3)),this.setAttribute("uv",new De(f,2));function A(){const M=new F,y=new F;let b=0;const R=(e-t)/n;for(let v=0;v<=r;v++){const E=[],D=v/r,C=D*(e-t)+t;for(let I=0;I<=s;I++){const W=I/s,X=W*c+o,U=Math.sin(X),q=Math.cos(X);y.x=C*U,y.y=-D*n+m,y.z=C*q,u.push(y.x,y.y,y.z),M.set(U,R,q).normalize(),d.push(M.x,M.y,M.z),f.push(W,1-D),E.push(g++)}x.push(E)}for(let v=0;v<s;v++)for(let E=0;E<r;E++){const D=x[E][v],C=x[E+1][v],I=x[E+1][v+1],W=x[E][v+1];(t>0||E!==0)&&(h.push(D,C,W),b+=3),(e>0||E!==r-1)&&(h.push(C,I,W),b+=3)}l.addGroup(p,b,0),p+=b}function T(M){const y=g,b=new Ft,R=new F;let v=0;const E=M===!0?t:e,D=M===!0?1:-1;for(let I=1;I<=s;I++)u.push(0,m*D,0),d.push(0,D,0),f.push(.5,.5),g++;const C=g;for(let I=0;I<=s;I++){const X=I/s*c+o,U=Math.cos(X),q=Math.sin(X);R.x=E*q,R.y=m*D,R.z=E*U,u.push(R.x,R.y,R.z),d.push(0,D,0),b.x=U*.5+.5,b.y=q*.5*D+.5,f.push(b.x,b.y),g++}for(let I=0;I<s;I++){const W=y+I,X=C+I;M===!0?h.push(X,X+1,W):h.push(X+1,X,W),v+=3}l.addGroup(p,v,M===!0?1:2),p+=v}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Pi(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class to extends Pi{constructor(t=1,e=1,n=32,s=1,r=!1,a=0,o=Math.PI*2){super(0,t,e,n,s,r,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:s,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(t){return new to(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class qs extends Ee{constructor(t=1,e=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:s};const r=t/2,a=e/2,o=Math.floor(n),c=Math.floor(s),l=o+1,h=c+1,u=t/o,d=e/c,f=[],g=[],x=[],m=[];for(let p=0;p<h;p++){const A=p*d-a;for(let T=0;T<l;T++){const M=T*u-r;g.push(M,-A,0),x.push(0,0,1),m.push(T/o),m.push(1-p/c)}}for(let p=0;p<c;p++)for(let A=0;A<o;A++){const T=A+l*p,M=A+l*(p+1),y=A+1+l*(p+1),b=A+1+l*p;f.push(T,M,b),f.push(M,y,b)}this.setIndex(f),this.setAttribute("position",new De(g,3)),this.setAttribute("normal",new De(x,3)),this.setAttribute("uv",new De(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new qs(t.width,t.height,t.widthSegments,t.heightSegments)}}class Cn extends Ee{constructor(t=1,e=32,n=16,s=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:s,phiLength:r,thetaStart:a,thetaLength:o},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const c=Math.min(a+o,Math.PI);let l=0;const h=[],u=new F,d=new F,f=[],g=[],x=[],m=[];for(let p=0;p<=n;p++){const A=[],T=p/n,M=a+T*o,y=t*Math.cos(M),b=Math.sqrt(t*t-y*y);let R=0;p===0&&a===0?R=.5/e:p===n&&c===Math.PI&&(R=-.5/e);for(let v=0;v<=e;v++){const E=v/e,D=s+E*r;u.x=-b*Math.cos(D),u.y=y,u.z=b*Math.sin(D),g.push(u.x,u.y,u.z),d.copy(u).normalize(),x.push(d.x,d.y,d.z),m.push(E+R,1-T),A.push(l++)}h.push(A)}for(let p=0;p<n;p++)for(let A=0;A<e;A++){const T=h[p][A+1],M=h[p][A],y=h[p+1][A],b=h[p+1][A+1];(p!==0||a>0)&&f.push(T,M,b),(p!==n-1||c<Math.PI)&&f.push(M,y,b)}this.setIndex(f),this.setAttribute("position",new De(g,3)),this.setAttribute("normal",new De(x,3)),this.setAttribute("uv",new De(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Cn(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}function Vs(i){const t={};for(const e in i){t[e]={};for(const n in i[e]){const s=i[e][n];if(eu(s))s.isRenderTargetTexture?(Ot("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=s.clone();else if(Array.isArray(s))if(eu(s[0])){const r=[];for(let a=0,o=s.length;a<o;a++)r[a]=s[a].clone();t[e][n]=r}else t[e][n]=s.slice();else t[e][n]=s}}return t}function Ke(i){const t={};for(let e=0;e<i.length;e++){const n=Vs(i[e]);for(const s in n)t[s]=n[s]}return t}function eu(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function gm(i){const t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function ud(i){const t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Kt.workingColorSpace}const _m={clone:Vs,merge:Ke};var vm=`void main() {
305
305
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
306
- }`,dm=`void main() {
306
+ }`,xm=`void main() {
307
307
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
308
- }`;class Be extends Qi{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=um,this.fragmentShader=dm,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=zs(t.uniforms),this.uniformsGroups=lm(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.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const s in this.uniforms){const 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;const n={};for(const s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(const n in t.uniforms){const s=t.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=e[s.value]||null;break;case"c":this.uniforms[n].value=new Mt().setHex(s.value);break;case"v2":this.uniforms[n].value=new Ft().fromArray(s.value);break;case"v3":this.uniforms[n].value=new F().fromArray(s.value);break;case"v4":this.uniforms[n].value=new pe().fromArray(s.value);break;case"m3":this.uniforms[n].value=new zt().fromArray(s.value);break;case"m4":this.uniforms[n].value=new ue().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(t.defines!==void 0&&(this.defines=t.defines),t.vertexShader!==void 0&&(this.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(this.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(this.glslVersion=t.glslVersion),t.extensions!==void 0)for(const n in t.extensions)this.extensions[n]=t.extensions[n];return t.lights!==void 0&&(this.lights=t.lights),t.clipping!==void 0&&(this.clipping=t.clipping),this}}class fm extends Be{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class xr extends Qi{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Mt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Mt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Zc,this.normalScale=new Ft(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new bi,this.combine=Cl,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.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.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.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.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class pm extends Qi{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=bp,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}}class mm extends Qi{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}}class Wl extends Te{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Mt(t),this.intensity=e}dispose(){this.dispatchEvent({type:"dispose"})}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}}class gm extends Wl{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Te.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Mt(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}toJSON(t){const e=super.toJSON(t);return e.object.groundColor=this.groundColor.getHex(),e}}const Io=new ue,Kh=new F,Zh=new F;class rd{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ft(512,512),this.mapType=rn,this.map=null,this.mapPass=null,this.matrix=new ue,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Hl,this._frameExtents=new Ft(1,1),this._viewportCount=1,this._viewports=[new pe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;Kh.setFromMatrixPosition(t.matrixWorld),e.position.copy(Kh),Zh.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(Zh),e.updateMatrixWorld(),Io.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Io,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===_r||e.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Io)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this.biasNode=t.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}const jr=new F,ta=new ks,Rn=new F;class ad extends Te{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ue,this.projectionMatrix=new ue,this.projectionMatrixInverse=new ue,this.coordinateSystem=Bn,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.matrixWorld.decompose(jr,ta,Rn),Rn.x===1&&Rn.y===1&&Rn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(jr,ta,Rn.set(1,1,1)).invert()}updateWorldMatrix(t,e,n=!1){super.updateWorldMatrix(t,e,n),this.matrixWorld.decompose(jr,ta,Rn),Rn.x===1&&Rn.y===1&&Rn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(jr,ta,Rn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const fi=new F,$h=new Ft,Jh=new Ft;class sn extends ad{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){const e=.5*this.getFilmHeight()/t;this.fov=Jc*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(ro*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Jc*2*Math.atan(Math.tan(ro*.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){fi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(fi.x,fi.y).multiplyScalar(-t/fi.z),fi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(fi.x,fi.y).multiplyScalar(-t/fi.z)}getViewSize(t,e){return this.getViewBounds(t,$h,Jh),e.subVectors(Jh,$h)}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(){const t=this.near;let e=t*Math.tan(ro*.5*this.fov)/this.zoom,n=2*e,s=this.aspect*n,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*s/c,e-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}const 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){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}class _m extends rd{constructor(){super(new sn(90,1,.5,500)),this.isPointLightShadow=!0}}class vm extends Wl{constructor(t,e,n=0,s=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=s,this.shadow=new _m}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.decay=this.decay,e.object.shadow=this.shadow.toJSON(),e}}class Ya extends ad{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(){const 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;let r=n-t,a=n+t,o=s+e,c=s-e;if(this.view!==null&&this.view.enabled){const 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){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class xm extends rd{constructor(){super(new Ya(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Mm extends Wl{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Te.DEFAULT_UP),this.updateMatrix(),this.target=new Te,this.shadow=new xm}dispose(){super.dispose(),this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.shadow=this.shadow.toJSON(),e.object.target=this.target.uuid,e}}const gs=-90,_s=1;class Sm extends Te{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new sn(gs,_s,t,e);s.layers=this.layers,this.add(s);const r=new sn(gs,_s,t,e);r.layers=this.layers,this.add(r);const a=new sn(gs,_s,t,e);a.layers=this.layers,this.add(a);const o=new sn(gs,_s,t,e);o.layers=this.layers,this.add(o);const c=new sn(gs,_s,t,e);c.layers=this.layers,this.add(c);const l=new sn(gs,_s,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,s,r,a,o,c]=e;for(const l of e)this.remove(l);if(t===Bn)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===_r)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(const l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,c,l,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),p=t.getActiveMipmapLevel(),g=t.xr.enabled;t.xr.enabled=!1;const x=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;t.isWebGLRenderer===!0?m=t.state.buffers.depth.getReversed():m=t.reversedDepthBuffer,t.setRenderTarget(n,0,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,r),t.setRenderTarget(n,1,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,a),t.setRenderTarget(n,2,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,o),t.setRenderTarget(n,3,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,c),t.setRenderTarget(n,4,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,l),n.texture.generateMipmaps=x,t.setRenderTarget(n,5,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,h),t.setRenderTarget(u,d,p),t.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class ym extends sn{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}const Qh=new ue;class Lo{constructor(t,e,n=0,s=1/0){this.ray=new Gl(t,e),this.near=n,this.far=s,this.camera=null,this.layers=new Bl,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,e.projectionMatrix.elements[14]).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):Yt("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return Qh.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Qh),this}intersectObject(t,e=!0,n=[]){return jc(t,this,n,e),n.sort(jh),n}intersectObjects(t,e=!0,n=[]){for(let s=0,r=t.length;s<r;s++)jc(t[s],this,n,e);return n.sort(jh),n}}function jh(i,t){return i.distance-t.distance}function jc(i,t,e,n){let s=!0;if(i.layers.test(t.layers)&&i.raycast(t,e)===!1&&(s=!1),s===!0&&n===!0){const r=i.children;for(let a=0,o=r.length;a<o;a++)jc(r[a],t,e,!0)}}class od{static{od.prototype.isMatrix2=!0}constructor(t,e,n,s){this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,n,s)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,s){const r=this.elements;return r[0]=t,r[2]=e,r[1]=n,r[3]=s,this}}function tu(i,t,e,n){const s=Em(n);switch(e){case W0:return i*t;case q0:return i*t/s.components*s.byteLength;case Ll:return i*t/s.components*s.byteLength;case Yi:return i*t*2/s.components*s.byteLength;case Nl:return i*t*2/s.components*s.byteLength;case X0:return i*t*3/s.components*s.byteLength;case pn:return i*t*4/s.components*s.byteLength;case Ul:return i*t*4/s.components*s.byteLength;case Ma:case Sa:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case ya:case Ea:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Mc:case yc:return Math.max(i,16)*Math.max(t,8)/4;case xc:case Sc:return Math.max(i,8)*Math.max(t,8)/2;case Ec:case bc:case Tc:case wc:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Ac:case Ra:case Rc:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Cc:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Dc:return Math.floor((i+4)/5)*Math.floor((t+3)/4)*16;case Pc:return Math.floor((i+4)/5)*Math.floor((t+4)/5)*16;case Ic:return Math.floor((i+5)/6)*Math.floor((t+4)/5)*16;case Lc:return Math.floor((i+5)/6)*Math.floor((t+5)/6)*16;case Nc:return Math.floor((i+7)/8)*Math.floor((t+4)/5)*16;case Uc:return Math.floor((i+7)/8)*Math.floor((t+5)/6)*16;case Fc:return Math.floor((i+7)/8)*Math.floor((t+7)/8)*16;case Oc:return Math.floor((i+9)/10)*Math.floor((t+4)/5)*16;case zc:return Math.floor((i+9)/10)*Math.floor((t+5)/6)*16;case Bc:return Math.floor((i+9)/10)*Math.floor((t+7)/8)*16;case kc:return Math.floor((i+9)/10)*Math.floor((t+9)/10)*16;case Gc:return Math.floor((i+11)/12)*Math.floor((t+9)/10)*16;case Hc:return Math.floor((i+11)/12)*Math.floor((t+11)/12)*16;case Vc:case Wc:case Xc:return Math.ceil(i/4)*Math.ceil(t/4)*16;case qc:case Yc:return Math.ceil(i/4)*Math.ceil(t/4)*8;case Ca:case Kc:return Math.ceil(i/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function Em(i){switch(i){case rn:case k0:return{byteLength:1,components:1};case mr:case G0:case bn:return{byteLength:2,components:1};case Pl:case Il:return{byteLength:2,components:4};case Vn:case Dl:case zn:return{byteLength:4,components:1};case H0:case V0:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Rl}}));typeof window<"u"&&(window.__THREE__?Ot("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Rl);/**
308
+ }`;class Be extends es{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=vm,this.fragmentShader=xm,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=Vs(t.uniforms),this.uniformsGroups=gm(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.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const s in this.uniforms){const 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;const n={};for(const s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(const n in t.uniforms){const s=t.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=e[s.value]||null;break;case"c":this.uniforms[n].value=new Mt().setHex(s.value);break;case"v2":this.uniforms[n].value=new Ft().fromArray(s.value);break;case"v3":this.uniforms[n].value=new F().fromArray(s.value);break;case"v4":this.uniforms[n].value=new pe().fromArray(s.value);break;case"m3":this.uniforms[n].value=new zt().fromArray(s.value);break;case"m4":this.uniforms[n].value=new he().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(t.defines!==void 0&&(this.defines=t.defines),t.vertexShader!==void 0&&(this.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(this.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(this.glslVersion=t.glslVersion),t.extensions!==void 0)for(const n in t.extensions)this.extensions[n]=t.extensions[n];return t.lights!==void 0&&(this.lights=t.lights),t.clipping!==void 0&&(this.clipping=t.clipping),this}}class Mm extends Be{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Tr extends es{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Mt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Mt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=nl,this.normalScale=new Ft(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ci,this.combine=Fl,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.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.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.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.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Sm extends es{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Pp,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}}class ym extends es{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}}class Ql extends Re{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Mt(t),this.intensity=e}dispose(){this.dispatchEvent({type:"dispose"})}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}}class Em extends Ql{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Re.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Mt(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}toJSON(t){const e=super.toJSON(t);return e.object.groundColor=this.groundColor.getHex(),e}}const Bo=new he,nu=new F,iu=new F;class dd{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ft(512,512),this.mapType=ln,this.map=null,this.mapPass=null,this.matrix=new he,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new $l,this._frameExtents=new Ft(1,1),this._viewportCount=1,this._viewports=[new pe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;nu.setFromMatrixPosition(t.matrixWorld),e.position.copy(nu),iu.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(iu),e.updateMatrixWorld(),Bo.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Bo,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===Er||e.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Bo)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this.biasNode=t.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}const aa=new F,oa=new Xs,Ln=new F;class fd extends Re{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new he,this.projectionMatrix=new he,this.projectionMatrixInverse=new he,this.coordinateSystem=Wn,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.matrixWorld.decompose(aa,oa,Ln),Ln.x===1&&Ln.y===1&&Ln.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(aa,oa,Ln.set(1,1,1)).invert()}updateWorldMatrix(t,e,n=!1){super.updateWorldMatrix(t,e,n),this.matrixWorld.decompose(aa,oa,Ln),Ln.x===1&&Ln.y===1&&Ln.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(aa,oa,Ln.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const _i=new F,su=new Ft,ru=new Ft;class cn extends fd{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){const e=.5*this.getFilmHeight()/t;this.fov=sl*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(po*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return sl*2*Math.atan(Math.tan(po*.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){_i.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(_i.x,_i.y).multiplyScalar(-t/_i.z),_i.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(_i.x,_i.y).multiplyScalar(-t/_i.z)}getViewSize(t,e){return this.getViewBounds(t,su,ru),e.subVectors(ru,su)}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(){const t=this.near;let e=t*Math.tan(po*.5*this.fov)/this.zoom,n=2*e,s=this.aspect*n,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*s/c,e-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}const 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){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}class bm extends dd{constructor(){super(new cn(90,1,.5,500)),this.isPointLightShadow=!0}}class Am extends Ql{constructor(t,e,n=0,s=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=s,this.shadow=new bm}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.decay=this.decay,e.object.shadow=this.shadow.toJSON(),e}}class eo extends fd{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(){const 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;let r=n-t,a=n+t,o=s+e,c=s-e;if(this.view!==null&&this.view.enabled){const 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){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class Tm extends dd{constructor(){super(new eo(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class wm extends Ql{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Re.DEFAULT_UP),this.updateMatrix(),this.target=new Re,this.shadow=new Tm}dispose(){super.dispose(),this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.shadow=this.shadow.toJSON(),e.object.target=this.target.uuid,e}}const xs=-90,Ms=1;class Rm extends Re{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new cn(xs,Ms,t,e);s.layers=this.layers,this.add(s);const r=new cn(xs,Ms,t,e);r.layers=this.layers,this.add(r);const a=new cn(xs,Ms,t,e);a.layers=this.layers,this.add(a);const o=new cn(xs,Ms,t,e);o.layers=this.layers,this.add(o);const c=new cn(xs,Ms,t,e);c.layers=this.layers,this.add(c);const l=new cn(xs,Ms,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,s,r,a,o,c]=e;for(const l of e)this.remove(l);if(t===Wn)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===Er)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(const l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,c,l,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),f=t.getActiveMipmapLevel(),g=t.xr.enabled;t.xr.enabled=!1;const x=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;t.isWebGLRenderer===!0?m=t.state.buffers.depth.getReversed():m=t.reversedDepthBuffer,t.setRenderTarget(n,0,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,r),t.setRenderTarget(n,1,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,a),t.setRenderTarget(n,2,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,o),t.setRenderTarget(n,3,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,c),t.setRenderTarget(n,4,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,l),n.texture.generateMipmaps=x,t.setRenderTarget(n,5,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,h),t.setRenderTarget(u,d,f),t.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class Cm extends cn{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}const au=new he;class ko{constructor(t,e,n=0,s=1/0){this.ray=new Kl(t,e),this.near=n,this.far=s,this.camera=null,this.layers=new ql,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,e.projectionMatrix.elements[14]).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):Yt("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return au.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(au),this}intersectObject(t,e=!0,n=[]){return al(t,this,n,e),n.sort(ou),n}intersectObjects(t,e=!0,n=[]){for(let s=0,r=t.length;s<r;s++)al(t[s],this,n,e);return n.sort(ou),n}}function ou(i,t){return i.distance-t.distance}function al(i,t,e,n){let s=!0;if(i.layers.test(t.layers)&&i.raycast(t,e)===!1&&(s=!1),s===!0&&n===!0){const r=i.children;for(let a=0,o=r.length;a<o;a++)al(r[a],t,e,!0)}}class pd{static{pd.prototype.isMatrix2=!0}constructor(t,e,n,s){this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,n,s)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,s){const r=this.elements;return r[0]=t,r[2]=e,r[1]=n,r[3]=s,this}}function cu(i,t,e,n){const s=Dm(n);switch(e){case Q0:return i*t;case td:return i*t/s.components*s.byteLength;case kl:return i*t/s.components*s.byteLength;case $i:return i*t*2/s.components*s.byteLength;case Gl:return i*t*2/s.components*s.byteLength;case j0:return i*t*3/s.components*s.byteLength;case un:return i*t*4/s.components*s.byteLength;case Hl:return i*t*4/s.components*s.byteLength;case wa:case Ra:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Ca:case Da:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case wc:case Cc:return Math.max(i,16)*Math.max(t,8)/4;case Tc:case Rc:return Math.max(i,8)*Math.max(t,8)/2;case Dc:case Pc:case Lc:case Nc:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Ic:case Ua:case Uc:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Fc:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Oc:return Math.floor((i+4)/5)*Math.floor((t+3)/4)*16;case zc:return Math.floor((i+4)/5)*Math.floor((t+4)/5)*16;case Bc:return Math.floor((i+5)/6)*Math.floor((t+4)/5)*16;case kc:return Math.floor((i+5)/6)*Math.floor((t+5)/6)*16;case Gc:return Math.floor((i+7)/8)*Math.floor((t+4)/5)*16;case Hc:return Math.floor((i+7)/8)*Math.floor((t+5)/6)*16;case Vc:return Math.floor((i+7)/8)*Math.floor((t+7)/8)*16;case Wc:return Math.floor((i+9)/10)*Math.floor((t+4)/5)*16;case Xc:return Math.floor((i+9)/10)*Math.floor((t+5)/6)*16;case qc:return Math.floor((i+9)/10)*Math.floor((t+7)/8)*16;case Yc:return Math.floor((i+9)/10)*Math.floor((t+9)/10)*16;case Kc:return Math.floor((i+11)/12)*Math.floor((t+9)/10)*16;case Zc:return Math.floor((i+11)/12)*Math.floor((t+11)/12)*16;case $c:case Jc:case Qc:return Math.ceil(i/4)*Math.ceil(t/4)*16;case jc:case tl:return Math.ceil(i/4)*Math.ceil(t/4)*8;case Fa:case el:return Math.ceil(i/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function Dm(i){switch(i){case ln:case K0:return{byteLength:1,components:1};case Sr:case Z0:case xn:return{byteLength:2,components:1};case zl:case Bl:return{byteLength:2,components:4};case Kn:case Ol:case Vn:return{byteLength:4,components:1};case $0:case J0:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ul}}));typeof window<"u"&&(window.__THREE__?Ot("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ul);/**
309
309
  * @license
310
310
  * Copyright 2010-2026 Three.js Authors
311
311
  * SPDX-License-Identifier: MIT
312
- */function cd(){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&&i!==null&&(n=i.requestAnimationFrame(s),t=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){i=r}}}function bm(i){const t=new WeakMap;function e(o,c){const l=o.array,h=o.usage,u=l.byteLength,d=i.createBuffer();i.bindBuffer(c,d),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:d,type:p,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,c,l){const h=c.array,u=c.updateRanges;if(i.bindBuffer(l,o),u.length===0)i.bufferSubData(l,0,h);else{u.sort((p,g)=>p.start-g.start);let d=0;for(let p=1;p<u.length;p++){const g=u[d],x=u[p];x.start<=g.start+g.count+1?g.count=Math.max(g.count,x.start+x.count-g.start):(++d,u[d]=x)}u.length=d+1;for(let p=0,g=u.length;p<g;p++){const x=u[p];i.bufferSubData(l,x.start*h.BYTES_PER_ELEMENT,h,x.start,x.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);const c=t.get(o);c&&(i.deleteBuffer(c.buffer),t.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const 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}const 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 Am=`#ifdef USE_ALPHAHASH
312
+ */function md(){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&&i!==null&&(n=i.requestAnimationFrame(s),t=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){i=r}}}function Pm(i){const t=new WeakMap;function e(o,c){const l=o.array,h=o.usage,u=l.byteLength,d=i.createBuffer();i.bindBuffer(c,d),i.bufferData(c,l,h),o.onUploadCallback();let f;if(l instanceof Float32Array)f=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)f=i.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?f=i.HALF_FLOAT:f=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=i.SHORT;else if(l instanceof Uint32Array)f=i.UNSIGNED_INT;else if(l instanceof Int32Array)f=i.INT;else if(l instanceof Int8Array)f=i.BYTE;else if(l instanceof Uint8Array)f=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,c,l){const h=c.array,u=c.updateRanges;if(i.bindBuffer(l,o),u.length===0)i.bufferSubData(l,0,h);else{u.sort((f,g)=>f.start-g.start);let d=0;for(let f=1;f<u.length;f++){const g=u[d],x=u[f];x.start<=g.start+g.count+1?g.count=Math.max(g.count,x.start+x.count-g.start):(++d,u[d]=x)}u.length=d+1;for(let f=0,g=u.length;f<g;f++){const x=u[f];i.bufferSubData(l,x.start*h.BYTES_PER_ELEMENT,h,x.start,x.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);const c=t.get(o);c&&(i.deleteBuffer(c.buffer),t.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const 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}const 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 Im=`#ifdef USE_ALPHAHASH
313
313
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
314
- #endif`,Tm=`#ifdef USE_ALPHAHASH
314
+ #endif`,Lm=`#ifdef USE_ALPHAHASH
315
315
  const float ALPHA_HASH_SCALE = 0.05;
316
316
  float hash2D( vec2 value ) {
317
317
  return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -346,20 +346,20 @@ input[type=range] {
346
346
  : cases.z;
347
347
  return clamp( threshold , 1.0e-6, 1.0 );
348
348
  }
349
- #endif`,wm=`#ifdef USE_ALPHAMAP
349
+ #endif`,Nm=`#ifdef USE_ALPHAMAP
350
350
  diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
351
- #endif`,Rm=`#ifdef USE_ALPHAMAP
351
+ #endif`,Um=`#ifdef USE_ALPHAMAP
352
352
  uniform sampler2D alphaMap;
353
- #endif`,Cm=`#ifdef USE_ALPHATEST
353
+ #endif`,Fm=`#ifdef USE_ALPHATEST
354
354
  #ifdef ALPHA_TO_COVERAGE
355
355
  diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
356
356
  if ( diffuseColor.a == 0.0 ) discard;
357
357
  #else
358
358
  if ( diffuseColor.a < alphaTest ) discard;
359
359
  #endif
360
- #endif`,Dm=`#ifdef USE_ALPHATEST
360
+ #endif`,Om=`#ifdef USE_ALPHATEST
361
361
  uniform float alphaTest;
362
- #endif`,Pm=`#ifdef USE_AOMAP
362
+ #endif`,zm=`#ifdef USE_AOMAP
363
363
  float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
364
364
  reflectedLight.indirectDiffuse *= ambientOcclusion;
365
365
  #if defined( USE_CLEARCOAT )
@@ -372,10 +372,10 @@ input[type=range] {
372
372
  float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
373
373
  reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
374
374
  #endif
375
- #endif`,Im=`#ifdef USE_AOMAP
375
+ #endif`,Bm=`#ifdef USE_AOMAP
376
376
  uniform sampler2D aoMap;
377
377
  uniform float aoMapIntensity;
378
- #endif`,Lm=`#ifdef USE_BATCHING
378
+ #endif`,km=`#ifdef USE_BATCHING
379
379
  #if ! defined( GL_ANGLE_multi_draw )
380
380
  #define gl_DrawID _gl_DrawID
381
381
  uniform int _gl_DrawID;
@@ -409,15 +409,15 @@ input[type=range] {
409
409
  int y = j / size;
410
410
  return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
411
411
  }
412
- #endif`,Nm=`#ifdef USE_BATCHING
412
+ #endif`,Gm=`#ifdef USE_BATCHING
413
413
  mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
414
- #endif`,Um=`vec3 transformed = vec3( position );
414
+ #endif`,Hm=`vec3 transformed = vec3( position );
415
415
  #ifdef USE_ALPHAHASH
416
416
  vPosition = vec3( position );
417
- #endif`,Fm=`vec3 objectNormal = vec3( normal );
417
+ #endif`,Vm=`vec3 objectNormal = vec3( normal );
418
418
  #ifdef USE_TANGENT
419
419
  vec3 objectTangent = vec3( tangent.xyz );
420
- #endif`,Om=`float G_BlinnPhong_Implicit( ) {
420
+ #endif`,Wm=`float G_BlinnPhong_Implicit( ) {
421
421
  return 0.25;
422
422
  }
423
423
  float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -431,7 +431,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
431
431
  float G = G_BlinnPhong_Implicit( );
432
432
  float D = D_BlinnPhong( shininess, dotNH );
433
433
  return F * ( G * D );
434
- } // validated`,zm=`#ifdef USE_IRIDESCENCE
434
+ } // validated`,Xm=`#ifdef USE_IRIDESCENCE
435
435
  const mat3 XYZ_TO_REC709 = mat3(
436
436
  3.2404542, -0.9692660, 0.0556434,
437
437
  -1.5371385, 1.8760108, -0.2040259,
@@ -494,7 +494,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
494
494
  }
495
495
  return max( I, vec3( 0.0 ) );
496
496
  }
497
- #endif`,Bm=`#ifdef USE_BUMPMAP
497
+ #endif`,qm=`#ifdef USE_BUMPMAP
498
498
  uniform sampler2D bumpMap;
499
499
  uniform float bumpScale;
500
500
  vec2 dHdxy_fwd() {
@@ -515,7 +515,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
515
515
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
516
516
  return normalize( abs( fDet ) * surf_norm - vGrad );
517
517
  }
518
- #endif`,km=`#if NUM_CLIPPING_PLANES > 0
518
+ #endif`,Ym=`#if NUM_CLIPPING_PLANES > 0
519
519
  vec4 plane;
520
520
  #ifdef ALPHA_TO_COVERAGE
521
521
  float distanceToPlane, distanceGradient;
@@ -561,20 +561,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
561
561
  if ( clipped ) discard;
562
562
  #endif
563
563
  #endif
564
- #endif`,Gm=`#if NUM_CLIPPING_PLANES > 0
564
+ #endif`,Km=`#if NUM_CLIPPING_PLANES > 0
565
565
  varying vec3 vClipPosition;
566
566
  uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
567
- #endif`,Hm=`#if NUM_CLIPPING_PLANES > 0
567
+ #endif`,Zm=`#if NUM_CLIPPING_PLANES > 0
568
568
  varying vec3 vClipPosition;
569
- #endif`,Vm=`#if NUM_CLIPPING_PLANES > 0
569
+ #endif`,$m=`#if NUM_CLIPPING_PLANES > 0
570
570
  vClipPosition = - mvPosition.xyz;
571
- #endif`,Wm=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
571
+ #endif`,Jm=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
572
572
  diffuseColor *= vColor;
573
- #endif`,Xm=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
573
+ #endif`,Qm=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
574
574
  varying vec4 vColor;
575
- #endif`,qm=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
575
+ #endif`,jm=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
576
576
  varying vec4 vColor;
577
- #endif`,Ym=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
577
+ #endif`,tg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
578
578
  vColor = vec4( 1.0 );
579
579
  #endif
580
580
  #ifdef USE_COLOR_ALPHA
@@ -587,7 +587,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
587
587
  #endif
588
588
  #ifdef USE_BATCHING_COLOR
589
589
  vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
590
- #endif`,Km=`#define PI 3.141592653589793
590
+ #endif`,eg=`#define PI 3.141592653589793
591
591
  #define PI2 6.283185307179586
592
592
  #define PI_HALF 1.5707963267948966
593
593
  #define RECIPROCAL_PI 0.3183098861837907
@@ -658,7 +658,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
658
658
  float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
659
659
  float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
660
660
  return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
661
- } // validated`,Zm=`#ifdef ENVMAP_TYPE_CUBE_UV
661
+ } // validated`,ng=`#ifdef ENVMAP_TYPE_CUBE_UV
662
662
  #define cubeUV_minMipLevel 4.0
663
663
  #define cubeUV_minTileSize 16.0
664
664
  float getFace( vec3 direction ) {
@@ -751,7 +751,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
751
751
  return vec4( mix( color0, color1, mipF ), 1.0 );
752
752
  }
753
753
  }
754
- #endif`,$m=`vec3 transformedNormal = objectNormal;
754
+ #endif`,ig=`vec3 transformedNormal = objectNormal;
755
755
  #ifdef USE_TANGENT
756
756
  vec3 transformedTangent = objectTangent;
757
757
  #endif
@@ -777,21 +777,21 @@ transformedNormal = normalMatrix * transformedNormal;
777
777
  #endif
778
778
  #ifdef USE_TANGENT
779
779
  transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
780
- #endif`,Jm=`#ifdef USE_DISPLACEMENTMAP
780
+ #endif`,sg=`#ifdef USE_DISPLACEMENTMAP
781
781
  uniform sampler2D displacementMap;
782
782
  uniform float displacementScale;
783
783
  uniform float displacementBias;
784
- #endif`,Qm=`#ifdef USE_DISPLACEMENTMAP
784
+ #endif`,rg=`#ifdef USE_DISPLACEMENTMAP
785
785
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
786
- #endif`,jm=`#ifdef USE_EMISSIVEMAP
786
+ #endif`,ag=`#ifdef USE_EMISSIVEMAP
787
787
  vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
788
788
  #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
789
789
  emissiveColor = sRGBTransferEOTF( emissiveColor );
790
790
  #endif
791
791
  totalEmissiveRadiance *= emissiveColor.rgb;
792
- #endif`,tg=`#ifdef USE_EMISSIVEMAP
792
+ #endif`,og=`#ifdef USE_EMISSIVEMAP
793
793
  uniform sampler2D emissiveMap;
794
- #endif`,eg="gl_FragColor = linearToOutputTexel( gl_FragColor );",ng=`vec4 LinearTransferOETF( in vec4 value ) {
794
+ #endif`,cg="gl_FragColor = linearToOutputTexel( gl_FragColor );",lg=`vec4 LinearTransferOETF( in vec4 value ) {
795
795
  return value;
796
796
  }
797
797
  vec4 sRGBTransferEOTF( in vec4 value ) {
@@ -799,7 +799,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
799
799
  }
800
800
  vec4 sRGBTransferOETF( in vec4 value ) {
801
801
  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 );
802
- }`,ig=`#ifdef USE_ENVMAP
802
+ }`,hg=`#ifdef USE_ENVMAP
803
803
  #ifdef ENV_WORLDPOS
804
804
  vec3 cameraToFrag;
805
805
  if ( isOrthographic ) {
@@ -826,7 +826,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
826
826
  outgoingLight += envColor.xyz * specularStrength * reflectivity;
827
827
  #endif
828
828
  #endif
829
- #endif`,sg=`#ifdef USE_ENVMAP
829
+ #endif`,ug=`#ifdef USE_ENVMAP
830
830
  uniform float envMapIntensity;
831
831
  uniform mat3 envMapRotation;
832
832
  #ifdef ENVMAP_TYPE_CUBE
@@ -834,7 +834,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
834
834
  #else
835
835
  uniform sampler2D envMap;
836
836
  #endif
837
- #endif`,rg=`#ifdef USE_ENVMAP
837
+ #endif`,dg=`#ifdef USE_ENVMAP
838
838
  uniform float reflectivity;
839
839
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
840
840
  #define ENV_WORLDPOS
@@ -845,7 +845,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
845
845
  #else
846
846
  varying vec3 vReflect;
847
847
  #endif
848
- #endif`,ag=`#ifdef USE_ENVMAP
848
+ #endif`,fg=`#ifdef USE_ENVMAP
849
849
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
850
850
  #define ENV_WORLDPOS
851
851
  #endif
@@ -856,7 +856,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
856
856
  varying vec3 vReflect;
857
857
  uniform float refractionRatio;
858
858
  #endif
859
- #endif`,og=`#ifdef USE_ENVMAP
859
+ #endif`,pg=`#ifdef USE_ENVMAP
860
860
  #ifdef ENV_WORLDPOS
861
861
  vWorldPosition = worldPosition.xyz;
862
862
  #else
@@ -873,18 +873,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
873
873
  vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
874
874
  #endif
875
875
  #endif
876
- #endif`,cg=`#ifdef USE_FOG
876
+ #endif`,mg=`#ifdef USE_FOG
877
877
  vFogDepth = - mvPosition.z;
878
- #endif`,lg=`#ifdef USE_FOG
878
+ #endif`,gg=`#ifdef USE_FOG
879
879
  varying float vFogDepth;
880
- #endif`,hg=`#ifdef USE_FOG
880
+ #endif`,_g=`#ifdef USE_FOG
881
881
  #ifdef FOG_EXP2
882
882
  float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
883
883
  #else
884
884
  float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
885
885
  #endif
886
886
  gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
887
- #endif`,ug=`#ifdef USE_FOG
887
+ #endif`,vg=`#ifdef USE_FOG
888
888
  uniform vec3 fogColor;
889
889
  varying float vFogDepth;
890
890
  #ifdef FOG_EXP2
@@ -893,7 +893,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
893
893
  uniform float fogNear;
894
894
  uniform float fogFar;
895
895
  #endif
896
- #endif`,dg=`#ifdef USE_GRADIENTMAP
896
+ #endif`,xg=`#ifdef USE_GRADIENTMAP
897
897
  uniform sampler2D gradientMap;
898
898
  #endif
899
899
  vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -905,12 +905,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
905
905
  vec2 fw = fwidth( coord ) * 0.5;
906
906
  return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
907
907
  #endif
908
- }`,fg=`#ifdef USE_LIGHTMAP
908
+ }`,Mg=`#ifdef USE_LIGHTMAP
909
909
  uniform sampler2D lightMap;
910
910
  uniform float lightMapIntensity;
911
- #endif`,pg=`LambertMaterial material;
911
+ #endif`,Sg=`LambertMaterial material;
912
912
  material.diffuseColor = diffuseColor.rgb;
913
- material.specularStrength = specularStrength;`,mg=`varying vec3 vViewPosition;
913
+ material.specularStrength = specularStrength;`,yg=`varying vec3 vViewPosition;
914
914
  struct LambertMaterial {
915
915
  vec3 diffuseColor;
916
916
  float specularStrength;
@@ -924,7 +924,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
924
924
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
925
925
  }
926
926
  #define RE_Direct RE_Direct_Lambert
927
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,gg=`uniform bool receiveShadow;
927
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Eg=`uniform bool receiveShadow;
928
928
  uniform vec3 ambientLightColor;
929
929
  #if defined( USE_LIGHT_PROBES )
930
930
  uniform vec3 lightProbe[ 9 ];
@@ -1041,7 +1041,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
1041
1041
  return irradiance;
1042
1042
  }
1043
1043
  #endif
1044
- #include <lightprobes_pars_fragment>`,_g=`#ifdef USE_ENVMAP
1044
+ #include <lightprobes_pars_fragment>`,bg=`#ifdef USE_ENVMAP
1045
1045
  vec3 getIBLIrradiance( const in vec3 normal ) {
1046
1046
  #ifdef ENVMAP_TYPE_CUBE_UV
1047
1047
  vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
@@ -1074,8 +1074,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
1074
1074
  #endif
1075
1075
  }
1076
1076
  #endif
1077
- #endif`,vg=`ToonMaterial material;
1078
- material.diffuseColor = diffuseColor.rgb;`,xg=`varying vec3 vViewPosition;
1077
+ #endif`,Ag=`ToonMaterial material;
1078
+ material.diffuseColor = diffuseColor.rgb;`,Tg=`varying vec3 vViewPosition;
1079
1079
  struct ToonMaterial {
1080
1080
  vec3 diffuseColor;
1081
1081
  };
@@ -1087,11 +1087,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
1087
1087
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1088
1088
  }
1089
1089
  #define RE_Direct RE_Direct_Toon
1090
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Mg=`BlinnPhongMaterial material;
1090
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,wg=`BlinnPhongMaterial material;
1091
1091
  material.diffuseColor = diffuseColor.rgb;
1092
1092
  material.specularColor = specular;
1093
1093
  material.specularShininess = shininess;
1094
- material.specularStrength = specularStrength;`,Sg=`varying vec3 vViewPosition;
1094
+ material.specularStrength = specularStrength;`,Rg=`varying vec3 vViewPosition;
1095
1095
  struct BlinnPhongMaterial {
1096
1096
  vec3 diffuseColor;
1097
1097
  vec3 specularColor;
@@ -1108,7 +1108,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
1108
1108
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1109
1109
  }
1110
1110
  #define RE_Direct RE_Direct_BlinnPhong
1111
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,yg=`PhysicalMaterial material;
1111
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Cg=`PhysicalMaterial material;
1112
1112
  material.diffuseColor = diffuseColor.rgb;
1113
1113
  material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
1114
1114
  material.metalness = metalnessFactor;
@@ -1198,7 +1198,7 @@ material.roughness = min( material.roughness, 1.0 );
1198
1198
  material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
1199
1199
  material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
1200
1200
  material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
1201
- #endif`,Eg=`uniform sampler2D dfgLUT;
1201
+ #endif`,Dg=`uniform sampler2D dfgLUT;
1202
1202
  struct PhysicalMaterial {
1203
1203
  vec3 diffuseColor;
1204
1204
  vec3 diffuseContribution;
@@ -1558,7 +1558,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
1558
1558
  #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1559
1559
  float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1560
1560
  return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1561
- }`,bg=`
1561
+ }`,Pg=`
1562
1562
  vec3 geometryPosition = - vViewPosition;
1563
1563
  vec3 geometryNormal = normal;
1564
1564
  vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1680,7 +1680,7 @@ IncidentLight directLight;
1680
1680
  #if defined( RE_IndirectSpecular )
1681
1681
  vec3 radiance = vec3( 0.0 );
1682
1682
  vec3 clearcoatRadiance = vec3( 0.0 );
1683
- #endif`,Ag=`#if defined( RE_IndirectDiffuse )
1683
+ #endif`,Ig=`#if defined( RE_IndirectDiffuse )
1684
1684
  #ifdef USE_LIGHTMAP
1685
1685
  vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1686
1686
  vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1701,7 +1701,7 @@ IncidentLight directLight;
1701
1701
  #ifdef USE_CLEARCOAT
1702
1702
  clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1703
1703
  #endif
1704
- #endif`,Tg=`#if defined( RE_IndirectDiffuse )
1704
+ #endif`,Lg=`#if defined( RE_IndirectDiffuse )
1705
1705
  #if defined( LAMBERT ) || defined( PHONG )
1706
1706
  irradiance += iblIrradiance;
1707
1707
  #endif
@@ -1709,7 +1709,7 @@ IncidentLight directLight;
1709
1709
  #endif
1710
1710
  #if defined( RE_IndirectSpecular )
1711
1711
  RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1712
- #endif`,wg=`#ifdef USE_LIGHT_PROBES_GRID
1712
+ #endif`,Ng=`#ifdef USE_LIGHT_PROBES_GRID
1713
1713
  uniform highp sampler3D probesSH;
1714
1714
  uniform vec3 probesMin;
1715
1715
  uniform vec3 probesMax;
@@ -1754,27 +1754,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1754
1754
  result += c8 * 0.429043 * ( x * x - y * y );
1755
1755
  return max( result, vec3( 0.0 ) );
1756
1756
  }
1757
- #endif`,Rg=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1757
+ #endif`,Ug=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1758
1758
  gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1759
- #endif`,Cg=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1759
+ #endif`,Fg=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1760
1760
  uniform float logDepthBufFC;
1761
1761
  varying float vFragDepth;
1762
1762
  varying float vIsPerspective;
1763
- #endif`,Dg=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1763
+ #endif`,Og=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1764
1764
  varying float vFragDepth;
1765
1765
  varying float vIsPerspective;
1766
- #endif`,Pg=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1766
+ #endif`,zg=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1767
1767
  vFragDepth = 1.0 + gl_Position.w;
1768
1768
  vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1769
- #endif`,Ig=`#ifdef USE_MAP
1769
+ #endif`,Bg=`#ifdef USE_MAP
1770
1770
  vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1771
1771
  #ifdef DECODE_VIDEO_TEXTURE
1772
1772
  sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1773
1773
  #endif
1774
1774
  diffuseColor *= sampledDiffuseColor;
1775
- #endif`,Lg=`#ifdef USE_MAP
1775
+ #endif`,kg=`#ifdef USE_MAP
1776
1776
  uniform sampler2D map;
1777
- #endif`,Ng=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1777
+ #endif`,Gg=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1778
1778
  #if defined( USE_POINTS_UV )
1779
1779
  vec2 uv = vUv;
1780
1780
  #else
@@ -1786,7 +1786,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1786
1786
  #endif
1787
1787
  #ifdef USE_ALPHAMAP
1788
1788
  diffuseColor.a *= texture2D( alphaMap, uv ).g;
1789
- #endif`,Ug=`#if defined( USE_POINTS_UV )
1789
+ #endif`,Hg=`#if defined( USE_POINTS_UV )
1790
1790
  varying vec2 vUv;
1791
1791
  #else
1792
1792
  #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1798,19 +1798,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1798
1798
  #endif
1799
1799
  #ifdef USE_ALPHAMAP
1800
1800
  uniform sampler2D alphaMap;
1801
- #endif`,Fg=`float metalnessFactor = metalness;
1801
+ #endif`,Vg=`float metalnessFactor = metalness;
1802
1802
  #ifdef USE_METALNESSMAP
1803
1803
  vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1804
1804
  metalnessFactor *= texelMetalness.b;
1805
- #endif`,Og=`#ifdef USE_METALNESSMAP
1805
+ #endif`,Wg=`#ifdef USE_METALNESSMAP
1806
1806
  uniform sampler2D metalnessMap;
1807
- #endif`,zg=`#ifdef USE_INSTANCING_MORPH
1807
+ #endif`,Xg=`#ifdef USE_INSTANCING_MORPH
1808
1808
  float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1809
1809
  float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1810
1810
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1811
1811
  morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1812
1812
  }
1813
- #endif`,Bg=`#if defined( USE_MORPHCOLORS )
1813
+ #endif`,qg=`#if defined( USE_MORPHCOLORS )
1814
1814
  vColor *= morphTargetBaseInfluence;
1815
1815
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1816
1816
  #if defined( USE_COLOR_ALPHA )
@@ -1819,12 +1819,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1819
1819
  if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1820
1820
  #endif
1821
1821
  }
1822
- #endif`,kg=`#ifdef USE_MORPHNORMALS
1822
+ #endif`,Yg=`#ifdef USE_MORPHNORMALS
1823
1823
  objectNormal *= morphTargetBaseInfluence;
1824
1824
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1825
1825
  if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1826
1826
  }
1827
- #endif`,Gg=`#ifdef USE_MORPHTARGETS
1827
+ #endif`,Kg=`#ifdef USE_MORPHTARGETS
1828
1828
  #ifndef USE_INSTANCING_MORPH
1829
1829
  uniform float morphTargetBaseInfluence;
1830
1830
  uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -1838,12 +1838,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1838
1838
  ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1839
1839
  return texelFetch( morphTargetsTexture, morphUV, 0 );
1840
1840
  }
1841
- #endif`,Hg=`#ifdef USE_MORPHTARGETS
1841
+ #endif`,Zg=`#ifdef USE_MORPHTARGETS
1842
1842
  transformed *= morphTargetBaseInfluence;
1843
1843
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1844
1844
  if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1845
1845
  }
1846
- #endif`,Vg=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1846
+ #endif`,$g=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1847
1847
  #ifdef FLAT_SHADED
1848
1848
  vec3 fdx = dFdx( vViewPosition );
1849
1849
  vec3 fdy = dFdy( vViewPosition );
@@ -1884,7 +1884,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1884
1884
  tbn2[1] *= faceDirection;
1885
1885
  #endif
1886
1886
  #endif
1887
- vec3 nonPerturbedNormal = normal;`,Wg=`#ifdef USE_NORMALMAP_OBJECTSPACE
1887
+ vec3 nonPerturbedNormal = normal;`,Jg=`#ifdef USE_NORMALMAP_OBJECTSPACE
1888
1888
  normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1889
1889
  #ifdef FLIP_SIDED
1890
1890
  normal = - normal;
@@ -1902,19 +1902,19 @@ vec3 nonPerturbedNormal = normal;`,Wg=`#ifdef USE_NORMALMAP_OBJECTSPACE
1902
1902
  normal = normalize( tbn * mapN );
1903
1903
  #elif defined( USE_BUMPMAP )
1904
1904
  normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1905
- #endif`,Xg=`#ifndef FLAT_SHADED
1905
+ #endif`,Qg=`#ifndef FLAT_SHADED
1906
1906
  varying vec3 vNormal;
1907
1907
  #ifdef USE_TANGENT
1908
1908
  varying vec3 vTangent;
1909
1909
  varying vec3 vBitangent;
1910
1910
  #endif
1911
- #endif`,qg=`#ifndef FLAT_SHADED
1911
+ #endif`,jg=`#ifndef FLAT_SHADED
1912
1912
  varying vec3 vNormal;
1913
1913
  #ifdef USE_TANGENT
1914
1914
  varying vec3 vTangent;
1915
1915
  varying vec3 vBitangent;
1916
1916
  #endif
1917
- #endif`,Yg=`#ifndef FLAT_SHADED
1917
+ #endif`,t1=`#ifndef FLAT_SHADED
1918
1918
  vNormal = normalize( transformedNormal );
1919
1919
  #ifdef USE_TANGENT
1920
1920
  vTangent = normalize( transformedTangent );
@@ -1923,7 +1923,7 @@ vec3 nonPerturbedNormal = normal;`,Wg=`#ifdef USE_NORMALMAP_OBJECTSPACE
1923
1923
  vBitangent = - vBitangent;
1924
1924
  #endif
1925
1925
  #endif
1926
- #endif`,Kg=`#ifdef USE_NORMALMAP
1926
+ #endif`,e1=`#ifdef USE_NORMALMAP
1927
1927
  uniform sampler2D normalMap;
1928
1928
  uniform vec2 normalScale;
1929
1929
  #endif
@@ -1945,13 +1945,13 @@ vec3 nonPerturbedNormal = normal;`,Wg=`#ifdef USE_NORMALMAP_OBJECTSPACE
1945
1945
  float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1946
1946
  return mat3( T * scale, B * scale, N );
1947
1947
  }
1948
- #endif`,Zg=`#ifdef USE_CLEARCOAT
1948
+ #endif`,n1=`#ifdef USE_CLEARCOAT
1949
1949
  vec3 clearcoatNormal = nonPerturbedNormal;
1950
- #endif`,$g=`#ifdef USE_CLEARCOAT_NORMALMAP
1950
+ #endif`,i1=`#ifdef USE_CLEARCOAT_NORMALMAP
1951
1951
  vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1952
1952
  clearcoatMapN.xy *= clearcoatNormalScale;
1953
1953
  clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1954
- #endif`,Jg=`#ifdef USE_CLEARCOATMAP
1954
+ #endif`,s1=`#ifdef USE_CLEARCOATMAP
1955
1955
  uniform sampler2D clearcoatMap;
1956
1956
  #endif
1957
1957
  #ifdef USE_CLEARCOAT_NORMALMAP
@@ -1960,18 +1960,18 @@ vec3 nonPerturbedNormal = normal;`,Wg=`#ifdef USE_NORMALMAP_OBJECTSPACE
1960
1960
  #endif
1961
1961
  #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1962
1962
  uniform sampler2D clearcoatRoughnessMap;
1963
- #endif`,Qg=`#ifdef USE_IRIDESCENCEMAP
1963
+ #endif`,r1=`#ifdef USE_IRIDESCENCEMAP
1964
1964
  uniform sampler2D iridescenceMap;
1965
1965
  #endif
1966
1966
  #ifdef USE_IRIDESCENCE_THICKNESSMAP
1967
1967
  uniform sampler2D iridescenceThicknessMap;
1968
- #endif`,jg=`#ifdef OPAQUE
1968
+ #endif`,a1=`#ifdef OPAQUE
1969
1969
  diffuseColor.a = 1.0;
1970
1970
  #endif
1971
1971
  #ifdef USE_TRANSMISSION
1972
1972
  diffuseColor.a *= material.transmissionAlpha;
1973
1973
  #endif
1974
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,t1=`vec3 packNormalToRGB( const in vec3 normal ) {
1974
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,o1=`vec3 packNormalToRGB( const in vec3 normal ) {
1975
1975
  return normalize( normal ) * 0.5 + 0.5;
1976
1976
  }
1977
1977
  vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -2050,9 +2050,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
2050
2050
  #else
2051
2051
  return ( near * far ) / ( ( far - near ) * depth - far );
2052
2052
  #endif
2053
- }`,e1=`#ifdef PREMULTIPLIED_ALPHA
2053
+ }`,c1=`#ifdef PREMULTIPLIED_ALPHA
2054
2054
  gl_FragColor.rgb *= gl_FragColor.a;
2055
- #endif`,n1=`vec4 mvPosition = vec4( transformed, 1.0 );
2055
+ #endif`,l1=`vec4 mvPosition = vec4( transformed, 1.0 );
2056
2056
  #ifdef USE_BATCHING
2057
2057
  mvPosition = batchingMatrix * mvPosition;
2058
2058
  #endif
@@ -2060,22 +2060,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
2060
2060
  mvPosition = instanceMatrix * mvPosition;
2061
2061
  #endif
2062
2062
  mvPosition = modelViewMatrix * mvPosition;
2063
- gl_Position = projectionMatrix * mvPosition;`,i1=`#ifdef DITHERING
2063
+ gl_Position = projectionMatrix * mvPosition;`,h1=`#ifdef DITHERING
2064
2064
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
2065
- #endif`,s1=`#ifdef DITHERING
2065
+ #endif`,u1=`#ifdef DITHERING
2066
2066
  vec3 dithering( vec3 color ) {
2067
2067
  float grid_position = rand( gl_FragCoord.xy );
2068
2068
  vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
2069
2069
  dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
2070
2070
  return color + dither_shift_RGB;
2071
2071
  }
2072
- #endif`,r1=`float roughnessFactor = roughness;
2072
+ #endif`,d1=`float roughnessFactor = roughness;
2073
2073
  #ifdef USE_ROUGHNESSMAP
2074
2074
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
2075
2075
  roughnessFactor *= texelRoughness.g;
2076
- #endif`,a1=`#ifdef USE_ROUGHNESSMAP
2076
+ #endif`,f1=`#ifdef USE_ROUGHNESSMAP
2077
2077
  uniform sampler2D roughnessMap;
2078
- #endif`,o1=`#if NUM_SPOT_LIGHT_COORDS > 0
2078
+ #endif`,p1=`#if NUM_SPOT_LIGHT_COORDS > 0
2079
2079
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
2080
2080
  #endif
2081
2081
  #if NUM_SPOT_LIGHT_MAPS > 0
@@ -2275,7 +2275,7 @@ gl_Position = projectionMatrix * mvPosition;`,i1=`#ifdef DITHERING
2275
2275
  }
2276
2276
  #endif
2277
2277
  #endif
2278
- #endif`,c1=`#if NUM_SPOT_LIGHT_COORDS > 0
2278
+ #endif`,m1=`#if NUM_SPOT_LIGHT_COORDS > 0
2279
2279
  uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
2280
2280
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
2281
2281
  #endif
@@ -2316,7 +2316,7 @@ gl_Position = projectionMatrix * mvPosition;`,i1=`#ifdef DITHERING
2316
2316
  };
2317
2317
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
2318
2318
  #endif
2319
- #endif`,l1=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2319
+ #endif`,g1=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2320
2320
  #ifdef HAS_NORMAL
2321
2321
  vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
2322
2322
  #else
@@ -2352,7 +2352,7 @@ gl_Position = projectionMatrix * mvPosition;`,i1=`#ifdef DITHERING
2352
2352
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
2353
2353
  }
2354
2354
  #pragma unroll_loop_end
2355
- #endif`,h1=`float getShadowMask() {
2355
+ #endif`,_1=`float getShadowMask() {
2356
2356
  float shadow = 1.0;
2357
2357
  #ifdef USE_SHADOWMAP
2358
2358
  #if NUM_DIR_LIGHT_SHADOWS > 0
@@ -2384,12 +2384,12 @@ gl_Position = projectionMatrix * mvPosition;`,i1=`#ifdef DITHERING
2384
2384
  #endif
2385
2385
  #endif
2386
2386
  return shadow;
2387
- }`,u1=`#ifdef USE_SKINNING
2387
+ }`,v1=`#ifdef USE_SKINNING
2388
2388
  mat4 boneMatX = getBoneMatrix( skinIndex.x );
2389
2389
  mat4 boneMatY = getBoneMatrix( skinIndex.y );
2390
2390
  mat4 boneMatZ = getBoneMatrix( skinIndex.z );
2391
2391
  mat4 boneMatW = getBoneMatrix( skinIndex.w );
2392
- #endif`,d1=`#ifdef USE_SKINNING
2392
+ #endif`,x1=`#ifdef USE_SKINNING
2393
2393
  uniform mat4 bindMatrix;
2394
2394
  uniform mat4 bindMatrixInverse;
2395
2395
  uniform highp sampler2D boneTexture;
@@ -2404,7 +2404,7 @@ gl_Position = projectionMatrix * mvPosition;`,i1=`#ifdef DITHERING
2404
2404
  vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2405
2405
  return mat4( v1, v2, v3, v4 );
2406
2406
  }
2407
- #endif`,f1=`#ifdef USE_SKINNING
2407
+ #endif`,M1=`#ifdef USE_SKINNING
2408
2408
  vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2409
2409
  vec4 skinned = vec4( 0.0 );
2410
2410
  skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2412,7 +2412,7 @@ gl_Position = projectionMatrix * mvPosition;`,i1=`#ifdef DITHERING
2412
2412
  skinned += boneMatZ * skinVertex * skinWeight.z;
2413
2413
  skinned += boneMatW * skinVertex * skinWeight.w;
2414
2414
  transformed = ( bindMatrixInverse * skinned ).xyz;
2415
- #endif`,p1=`#ifdef USE_SKINNING
2415
+ #endif`,S1=`#ifdef USE_SKINNING
2416
2416
  mat4 skinMatrix = mat4( 0.0 );
2417
2417
  skinMatrix += skinWeight.x * boneMatX;
2418
2418
  skinMatrix += skinWeight.y * boneMatY;
@@ -2423,17 +2423,17 @@ gl_Position = projectionMatrix * mvPosition;`,i1=`#ifdef DITHERING
2423
2423
  #ifdef USE_TANGENT
2424
2424
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2425
2425
  #endif
2426
- #endif`,m1=`float specularStrength;
2426
+ #endif`,y1=`float specularStrength;
2427
2427
  #ifdef USE_SPECULARMAP
2428
2428
  vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2429
2429
  specularStrength = texelSpecular.r;
2430
2430
  #else
2431
2431
  specularStrength = 1.0;
2432
- #endif`,g1=`#ifdef USE_SPECULARMAP
2432
+ #endif`,E1=`#ifdef USE_SPECULARMAP
2433
2433
  uniform sampler2D specularMap;
2434
- #endif`,_1=`#if defined( TONE_MAPPING )
2434
+ #endif`,b1=`#if defined( TONE_MAPPING )
2435
2435
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2436
- #endif`,v1=`#ifndef saturate
2436
+ #endif`,A1=`#ifndef saturate
2437
2437
  #define saturate( a ) clamp( a, 0.0, 1.0 )
2438
2438
  #endif
2439
2439
  uniform float toneMappingExposure;
@@ -2530,7 +2530,7 @@ vec3 NeutralToneMapping( vec3 color ) {
2530
2530
  float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2531
2531
  return mix( color, vec3( newPeak ), g );
2532
2532
  }
2533
- vec3 CustomToneMapping( vec3 color ) { return color; }`,x1=`#ifdef USE_TRANSMISSION
2533
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,T1=`#ifdef USE_TRANSMISSION
2534
2534
  material.transmission = transmission;
2535
2535
  material.transmissionAlpha = 1.0;
2536
2536
  material.thickness = thickness;
@@ -2551,7 +2551,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,x1=`#ifdef USE_TRANSMISS
2551
2551
  material.attenuationColor, material.attenuationDistance );
2552
2552
  material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2553
2553
  totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2554
- #endif`,M1=`#ifdef USE_TRANSMISSION
2554
+ #endif`,w1=`#ifdef USE_TRANSMISSION
2555
2555
  uniform float transmission;
2556
2556
  uniform float thickness;
2557
2557
  uniform float attenuationDistance;
@@ -2677,7 +2677,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,x1=`#ifdef USE_TRANSMISS
2677
2677
  float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2678
2678
  return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2679
2679
  }
2680
- #endif`,S1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2680
+ #endif`,R1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2681
2681
  varying vec2 vUv;
2682
2682
  #endif
2683
2683
  #ifdef USE_MAP
@@ -2747,7 +2747,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,x1=`#ifdef USE_TRANSMISS
2747
2747
  #ifdef USE_THICKNESSMAP
2748
2748
  uniform mat3 thicknessMapTransform;
2749
2749
  varying vec2 vThicknessMapUv;
2750
- #endif`,y1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2750
+ #endif`,C1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2751
2751
  varying vec2 vUv;
2752
2752
  #endif
2753
2753
  #ifdef USE_MAP
@@ -2841,7 +2841,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,x1=`#ifdef USE_TRANSMISS
2841
2841
  #ifdef USE_THICKNESSMAP
2842
2842
  uniform mat3 thicknessMapTransform;
2843
2843
  varying vec2 vThicknessMapUv;
2844
- #endif`,E1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2844
+ #endif`,D1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2845
2845
  vUv = vec3( uv, 1 ).xy;
2846
2846
  #endif
2847
2847
  #ifdef USE_MAP
@@ -2912,7 +2912,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,x1=`#ifdef USE_TRANSMISS
2912
2912
  #endif
2913
2913
  #ifdef USE_THICKNESSMAP
2914
2914
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2915
- #endif`,b1=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2915
+ #endif`,P1=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2916
2916
  vec4 worldPosition = vec4( transformed, 1.0 );
2917
2917
  #ifdef USE_BATCHING
2918
2918
  worldPosition = batchingMatrix * worldPosition;
@@ -2921,12 +2921,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,x1=`#ifdef USE_TRANSMISS
2921
2921
  worldPosition = instanceMatrix * worldPosition;
2922
2922
  #endif
2923
2923
  worldPosition = modelMatrix * worldPosition;
2924
- #endif`;const A1=`varying vec2 vUv;
2924
+ #endif`;const I1=`varying vec2 vUv;
2925
2925
  uniform mat3 uvTransform;
2926
2926
  void main() {
2927
2927
  vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2928
2928
  gl_Position = vec4( position.xy, 1.0, 1.0 );
2929
- }`,T1=`uniform sampler2D t2D;
2929
+ }`,L1=`uniform sampler2D t2D;
2930
2930
  uniform float backgroundIntensity;
2931
2931
  varying vec2 vUv;
2932
2932
  void main() {
@@ -2938,14 +2938,14 @@ void main() {
2938
2938
  gl_FragColor = texColor;
2939
2939
  #include <tonemapping_fragment>
2940
2940
  #include <colorspace_fragment>
2941
- }`,w1=`varying vec3 vWorldDirection;
2941
+ }`,N1=`varying vec3 vWorldDirection;
2942
2942
  #include <common>
2943
2943
  void main() {
2944
2944
  vWorldDirection = transformDirection( position, modelMatrix );
2945
2945
  #include <begin_vertex>
2946
2946
  #include <project_vertex>
2947
2947
  gl_Position.z = gl_Position.w;
2948
- }`,R1=`#ifdef ENVMAP_TYPE_CUBE
2948
+ }`,U1=`#ifdef ENVMAP_TYPE_CUBE
2949
2949
  uniform samplerCube envMap;
2950
2950
  #elif defined( ENVMAP_TYPE_CUBE_UV )
2951
2951
  uniform sampler2D envMap;
@@ -2967,14 +2967,14 @@ void main() {
2967
2967
  gl_FragColor = texColor;
2968
2968
  #include <tonemapping_fragment>
2969
2969
  #include <colorspace_fragment>
2970
- }`,C1=`varying vec3 vWorldDirection;
2970
+ }`,F1=`varying vec3 vWorldDirection;
2971
2971
  #include <common>
2972
2972
  void main() {
2973
2973
  vWorldDirection = transformDirection( position, modelMatrix );
2974
2974
  #include <begin_vertex>
2975
2975
  #include <project_vertex>
2976
2976
  gl_Position.z = gl_Position.w;
2977
- }`,D1=`uniform samplerCube tCube;
2977
+ }`,O1=`uniform samplerCube tCube;
2978
2978
  uniform float tFlip;
2979
2979
  uniform float opacity;
2980
2980
  varying vec3 vWorldDirection;
@@ -2984,7 +2984,7 @@ void main() {
2984
2984
  gl_FragColor.a *= opacity;
2985
2985
  #include <tonemapping_fragment>
2986
2986
  #include <colorspace_fragment>
2987
- }`,P1=`#include <common>
2987
+ }`,z1=`#include <common>
2988
2988
  #include <batching_pars_vertex>
2989
2989
  #include <uv_pars_vertex>
2990
2990
  #include <displacementmap_pars_vertex>
@@ -3011,7 +3011,7 @@ void main() {
3011
3011
  #include <logdepthbuf_vertex>
3012
3012
  #include <clipping_planes_vertex>
3013
3013
  vHighPrecisionZW = gl_Position.zw;
3014
- }`,I1=`#if DEPTH_PACKING == 3200
3014
+ }`,B1=`#if DEPTH_PACKING == 3200
3015
3015
  uniform float opacity;
3016
3016
  #endif
3017
3017
  #include <common>
@@ -3049,7 +3049,7 @@ void main() {
3049
3049
  #elif DEPTH_PACKING == 3203
3050
3050
  gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
3051
3051
  #endif
3052
- }`,L1=`#define DISTANCE
3052
+ }`,k1=`#define DISTANCE
3053
3053
  varying vec3 vWorldPosition;
3054
3054
  #include <common>
3055
3055
  #include <batching_pars_vertex>
@@ -3076,7 +3076,7 @@ void main() {
3076
3076
  #include <worldpos_vertex>
3077
3077
  #include <clipping_planes_vertex>
3078
3078
  vWorldPosition = worldPosition.xyz;
3079
- }`,N1=`#define DISTANCE
3079
+ }`,G1=`#define DISTANCE
3080
3080
  uniform vec3 referencePosition;
3081
3081
  uniform float nearDistance;
3082
3082
  uniform float farDistance;
@@ -3099,13 +3099,13 @@ void main() {
3099
3099
  dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
3100
3100
  dist = saturate( dist );
3101
3101
  gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
3102
- }`,U1=`varying vec3 vWorldDirection;
3102
+ }`,H1=`varying vec3 vWorldDirection;
3103
3103
  #include <common>
3104
3104
  void main() {
3105
3105
  vWorldDirection = transformDirection( position, modelMatrix );
3106
3106
  #include <begin_vertex>
3107
3107
  #include <project_vertex>
3108
- }`,F1=`uniform sampler2D tEquirect;
3108
+ }`,V1=`uniform sampler2D tEquirect;
3109
3109
  varying vec3 vWorldDirection;
3110
3110
  #include <common>
3111
3111
  void main() {
@@ -3114,7 +3114,7 @@ void main() {
3114
3114
  gl_FragColor = texture2D( tEquirect, sampleUV );
3115
3115
  #include <tonemapping_fragment>
3116
3116
  #include <colorspace_fragment>
3117
- }`,O1=`uniform float scale;
3117
+ }`,W1=`uniform float scale;
3118
3118
  attribute float lineDistance;
3119
3119
  varying float vLineDistance;
3120
3120
  #include <common>
@@ -3136,7 +3136,7 @@ void main() {
3136
3136
  #include <logdepthbuf_vertex>
3137
3137
  #include <clipping_planes_vertex>
3138
3138
  #include <fog_vertex>
3139
- }`,z1=`uniform vec3 diffuse;
3139
+ }`,X1=`uniform vec3 diffuse;
3140
3140
  uniform float opacity;
3141
3141
  uniform float dashSize;
3142
3142
  uniform float totalSize;
@@ -3164,7 +3164,7 @@ void main() {
3164
3164
  #include <colorspace_fragment>
3165
3165
  #include <fog_fragment>
3166
3166
  #include <premultiplied_alpha_fragment>
3167
- }`,B1=`#include <common>
3167
+ }`,q1=`#include <common>
3168
3168
  #include <batching_pars_vertex>
3169
3169
  #include <uv_pars_vertex>
3170
3170
  #include <envmap_pars_vertex>
@@ -3196,7 +3196,7 @@ void main() {
3196
3196
  #include <worldpos_vertex>
3197
3197
  #include <envmap_vertex>
3198
3198
  #include <fog_vertex>
3199
- }`,k1=`uniform vec3 diffuse;
3199
+ }`,Y1=`uniform vec3 diffuse;
3200
3200
  uniform float opacity;
3201
3201
  #ifndef FLAT_SHADED
3202
3202
  varying vec3 vNormal;
@@ -3244,7 +3244,7 @@ void main() {
3244
3244
  #include <fog_fragment>
3245
3245
  #include <premultiplied_alpha_fragment>
3246
3246
  #include <dithering_fragment>
3247
- }`,G1=`#define LAMBERT
3247
+ }`,K1=`#define LAMBERT
3248
3248
  varying vec3 vViewPosition;
3249
3249
  #include <common>
3250
3250
  #include <batching_pars_vertex>
@@ -3283,7 +3283,7 @@ void main() {
3283
3283
  #include <envmap_vertex>
3284
3284
  #include <shadowmap_vertex>
3285
3285
  #include <fog_vertex>
3286
- }`,H1=`#define LAMBERT
3286
+ }`,Z1=`#define LAMBERT
3287
3287
  uniform vec3 diffuse;
3288
3288
  uniform vec3 emissive;
3289
3289
  uniform float opacity;
@@ -3341,7 +3341,7 @@ void main() {
3341
3341
  #include <fog_fragment>
3342
3342
  #include <premultiplied_alpha_fragment>
3343
3343
  #include <dithering_fragment>
3344
- }`,V1=`#define MATCAP
3344
+ }`,$1=`#define MATCAP
3345
3345
  varying vec3 vViewPosition;
3346
3346
  #include <common>
3347
3347
  #include <batching_pars_vertex>
@@ -3375,7 +3375,7 @@ void main() {
3375
3375
  #include <clipping_planes_vertex>
3376
3376
  #include <fog_vertex>
3377
3377
  vViewPosition = - mvPosition.xyz;
3378
- }`,W1=`#define MATCAP
3378
+ }`,J1=`#define MATCAP
3379
3379
  uniform vec3 diffuse;
3380
3380
  uniform float opacity;
3381
3381
  uniform sampler2D matcap;
@@ -3421,7 +3421,7 @@ void main() {
3421
3421
  #include <fog_fragment>
3422
3422
  #include <premultiplied_alpha_fragment>
3423
3423
  #include <dithering_fragment>
3424
- }`,X1=`#define NORMAL
3424
+ }`,Q1=`#define NORMAL
3425
3425
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3426
3426
  varying vec3 vViewPosition;
3427
3427
  #endif
@@ -3454,7 +3454,7 @@ void main() {
3454
3454
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3455
3455
  vViewPosition = - mvPosition.xyz;
3456
3456
  #endif
3457
- }`,q1=`#define NORMAL
3457
+ }`,j1=`#define NORMAL
3458
3458
  uniform float opacity;
3459
3459
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3460
3460
  varying vec3 vViewPosition;
@@ -3475,7 +3475,7 @@ void main() {
3475
3475
  #ifdef OPAQUE
3476
3476
  gl_FragColor.a = 1.0;
3477
3477
  #endif
3478
- }`,Y1=`#define PHONG
3478
+ }`,t2=`#define PHONG
3479
3479
  varying vec3 vViewPosition;
3480
3480
  #include <common>
3481
3481
  #include <batching_pars_vertex>
@@ -3514,7 +3514,7 @@ void main() {
3514
3514
  #include <envmap_vertex>
3515
3515
  #include <shadowmap_vertex>
3516
3516
  #include <fog_vertex>
3517
- }`,K1=`#define PHONG
3517
+ }`,e2=`#define PHONG
3518
3518
  uniform vec3 diffuse;
3519
3519
  uniform vec3 emissive;
3520
3520
  uniform vec3 specular;
@@ -3574,7 +3574,7 @@ void main() {
3574
3574
  #include <fog_fragment>
3575
3575
  #include <premultiplied_alpha_fragment>
3576
3576
  #include <dithering_fragment>
3577
- }`,Z1=`#define STANDARD
3577
+ }`,n2=`#define STANDARD
3578
3578
  varying vec3 vViewPosition;
3579
3579
  #ifdef USE_TRANSMISSION
3580
3580
  varying vec3 vWorldPosition;
@@ -3617,7 +3617,7 @@ void main() {
3617
3617
  #ifdef USE_TRANSMISSION
3618
3618
  vWorldPosition = worldPosition.xyz;
3619
3619
  #endif
3620
- }`,$1=`#define STANDARD
3620
+ }`,i2=`#define STANDARD
3621
3621
  #ifdef PHYSICAL
3622
3622
  #define IOR
3623
3623
  #define USE_SPECULAR
@@ -3742,7 +3742,7 @@ void main() {
3742
3742
  #include <fog_fragment>
3743
3743
  #include <premultiplied_alpha_fragment>
3744
3744
  #include <dithering_fragment>
3745
- }`,J1=`#define TOON
3745
+ }`,s2=`#define TOON
3746
3746
  varying vec3 vViewPosition;
3747
3747
  #include <common>
3748
3748
  #include <batching_pars_vertex>
@@ -3779,7 +3779,7 @@ void main() {
3779
3779
  #include <worldpos_vertex>
3780
3780
  #include <shadowmap_vertex>
3781
3781
  #include <fog_vertex>
3782
- }`,Q1=`#define TOON
3782
+ }`,r2=`#define TOON
3783
3783
  uniform vec3 diffuse;
3784
3784
  uniform vec3 emissive;
3785
3785
  uniform float opacity;
@@ -3831,7 +3831,7 @@ void main() {
3831
3831
  #include <fog_fragment>
3832
3832
  #include <premultiplied_alpha_fragment>
3833
3833
  #include <dithering_fragment>
3834
- }`,j1=`uniform float size;
3834
+ }`,a2=`uniform float size;
3835
3835
  uniform float scale;
3836
3836
  #include <common>
3837
3837
  #include <color_pars_vertex>
@@ -3862,7 +3862,7 @@ void main() {
3862
3862
  #include <clipping_planes_vertex>
3863
3863
  #include <worldpos_vertex>
3864
3864
  #include <fog_vertex>
3865
- }`,t2=`uniform vec3 diffuse;
3865
+ }`,o2=`uniform vec3 diffuse;
3866
3866
  uniform float opacity;
3867
3867
  #include <common>
3868
3868
  #include <color_pars_fragment>
@@ -3887,7 +3887,7 @@ void main() {
3887
3887
  #include <colorspace_fragment>
3888
3888
  #include <fog_fragment>
3889
3889
  #include <premultiplied_alpha_fragment>
3890
- }`,e2=`#include <common>
3890
+ }`,c2=`#include <common>
3891
3891
  #include <batching_pars_vertex>
3892
3892
  #include <fog_pars_vertex>
3893
3893
  #include <morphtarget_pars_vertex>
@@ -3910,7 +3910,7 @@ void main() {
3910
3910
  #include <worldpos_vertex>
3911
3911
  #include <shadowmap_vertex>
3912
3912
  #include <fog_vertex>
3913
- }`,n2=`uniform vec3 color;
3913
+ }`,l2=`uniform vec3 color;
3914
3914
  uniform float opacity;
3915
3915
  #include <common>
3916
3916
  #include <fog_pars_fragment>
@@ -3926,7 +3926,7 @@ void main() {
3926
3926
  #include <colorspace_fragment>
3927
3927
  #include <fog_fragment>
3928
3928
  #include <premultiplied_alpha_fragment>
3929
- }`,i2=`uniform float rotation;
3929
+ }`,h2=`uniform float rotation;
3930
3930
  uniform vec2 center;
3931
3931
  #include <common>
3932
3932
  #include <uv_pars_vertex>
@@ -3950,7 +3950,7 @@ void main() {
3950
3950
  #include <logdepthbuf_vertex>
3951
3951
  #include <clipping_planes_vertex>
3952
3952
  #include <fog_vertex>
3953
- }`,s2=`uniform vec3 diffuse;
3953
+ }`,u2=`uniform vec3 diffuse;
3954
3954
  uniform float opacity;
3955
3955
  #include <common>
3956
3956
  #include <uv_pars_fragment>
@@ -3975,7 +3975,7 @@ void main() {
3975
3975
  #include <tonemapping_fragment>
3976
3976
  #include <colorspace_fragment>
3977
3977
  #include <fog_fragment>
3978
- }`,Vt={alphahash_fragment:Am,alphahash_pars_fragment:Tm,alphamap_fragment:wm,alphamap_pars_fragment:Rm,alphatest_fragment:Cm,alphatest_pars_fragment:Dm,aomap_fragment:Pm,aomap_pars_fragment:Im,batching_pars_vertex:Lm,batching_vertex:Nm,begin_vertex:Um,beginnormal_vertex:Fm,bsdfs:Om,iridescence_fragment:zm,bumpmap_pars_fragment:Bm,clipping_planes_fragment:km,clipping_planes_pars_fragment:Gm,clipping_planes_pars_vertex:Hm,clipping_planes_vertex:Vm,color_fragment:Wm,color_pars_fragment:Xm,color_pars_vertex:qm,color_vertex:Ym,common:Km,cube_uv_reflection_fragment:Zm,defaultnormal_vertex:$m,displacementmap_pars_vertex:Jm,displacementmap_vertex:Qm,emissivemap_fragment:jm,emissivemap_pars_fragment:tg,colorspace_fragment:eg,colorspace_pars_fragment:ng,envmap_fragment:ig,envmap_common_pars_fragment:sg,envmap_pars_fragment:rg,envmap_pars_vertex:ag,envmap_physical_pars_fragment:_g,envmap_vertex:og,fog_vertex:cg,fog_pars_vertex:lg,fog_fragment:hg,fog_pars_fragment:ug,gradientmap_pars_fragment:dg,lightmap_pars_fragment:fg,lights_lambert_fragment:pg,lights_lambert_pars_fragment:mg,lights_pars_begin:gg,lights_toon_fragment:vg,lights_toon_pars_fragment:xg,lights_phong_fragment:Mg,lights_phong_pars_fragment:Sg,lights_physical_fragment:yg,lights_physical_pars_fragment:Eg,lights_fragment_begin:bg,lights_fragment_maps:Ag,lights_fragment_end:Tg,lightprobes_pars_fragment:wg,logdepthbuf_fragment:Rg,logdepthbuf_pars_fragment:Cg,logdepthbuf_pars_vertex:Dg,logdepthbuf_vertex:Pg,map_fragment:Ig,map_pars_fragment:Lg,map_particle_fragment:Ng,map_particle_pars_fragment:Ug,metalnessmap_fragment:Fg,metalnessmap_pars_fragment:Og,morphinstance_vertex:zg,morphcolor_vertex:Bg,morphnormal_vertex:kg,morphtarget_pars_vertex:Gg,morphtarget_vertex:Hg,normal_fragment_begin:Vg,normal_fragment_maps:Wg,normal_pars_fragment:Xg,normal_pars_vertex:qg,normal_vertex:Yg,normalmap_pars_fragment:Kg,clearcoat_normal_fragment_begin:Zg,clearcoat_normal_fragment_maps:$g,clearcoat_pars_fragment:Jg,iridescence_pars_fragment:Qg,opaque_fragment:jg,packing:t1,premultiplied_alpha_fragment:e1,project_vertex:n1,dithering_fragment:i1,dithering_pars_fragment:s1,roughnessmap_fragment:r1,roughnessmap_pars_fragment:a1,shadowmap_pars_fragment:o1,shadowmap_pars_vertex:c1,shadowmap_vertex:l1,shadowmask_pars_fragment:h1,skinbase_vertex:u1,skinning_pars_vertex:d1,skinning_vertex:f1,skinnormal_vertex:p1,specularmap_fragment:m1,specularmap_pars_fragment:g1,tonemapping_fragment:_1,tonemapping_pars_fragment:v1,transmission_fragment:x1,transmission_pars_fragment:M1,uv_pars_fragment:S1,uv_pars_vertex:y1,uv_vertex:E1,worldpos_vertex:b1,background_vert:A1,background_frag:T1,backgroundCube_vert:w1,backgroundCube_frag:R1,cube_vert:C1,cube_frag:D1,depth_vert:P1,depth_frag:I1,distance_vert:L1,distance_frag:N1,equirect_vert:U1,equirect_frag:F1,linedashed_vert:O1,linedashed_frag:z1,meshbasic_vert:B1,meshbasic_frag:k1,meshlambert_vert:G1,meshlambert_frag:H1,meshmatcap_vert:V1,meshmatcap_frag:W1,meshnormal_vert:X1,meshnormal_frag:q1,meshphong_vert:Y1,meshphong_frag:K1,meshphysical_vert:Z1,meshphysical_frag:$1,meshtoon_vert:J1,meshtoon_frag:Q1,points_vert:j1,points_frag:t2,shadow_vert:e2,shadow_frag:n2,sprite_vert:i2,sprite_frag:s2},ft={common:{diffuse:{value:new Mt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new zt},alphaMap:{value:null},alphaMapTransform:{value:new zt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new zt}},envmap:{envMap:{value:null},envMapRotation:{value:new zt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new zt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new zt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new zt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new zt},normalScale:{value:new Ft(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new zt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new zt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new zt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new zt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Mt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new F},probesMax:{value:new F},probesResolution:{value:new F}},points:{diffuse:{value:new Mt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new zt},alphaTest:{value:0},uvTransform:{value:new zt}},sprite:{diffuse:{value:new Mt(16777215)},opacity:{value:1},center:{value:new Ft(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new zt},alphaMap:{value:null},alphaMapTransform:{value:new zt},alphaTest:{value:0}}},In={basic:{uniforms:Ye([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.fog]),vertexShader:Vt.meshbasic_vert,fragmentShader:Vt.meshbasic_frag},lambert:{uniforms:Ye([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,ft.lights,{emissive:{value:new Mt(0)},envMapIntensity:{value:1}}]),vertexShader:Vt.meshlambert_vert,fragmentShader:Vt.meshlambert_frag},phong:{uniforms:Ye([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,ft.lights,{emissive:{value:new Mt(0)},specular:{value:new Mt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Vt.meshphong_vert,fragmentShader:Vt.meshphong_frag},standard:{uniforms:Ye([ft.common,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.roughnessmap,ft.metalnessmap,ft.fog,ft.lights,{emissive:{value:new Mt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Vt.meshphysical_vert,fragmentShader:Vt.meshphysical_frag},toon:{uniforms:Ye([ft.common,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.gradientmap,ft.fog,ft.lights,{emissive:{value:new Mt(0)}}]),vertexShader:Vt.meshtoon_vert,fragmentShader:Vt.meshtoon_frag},matcap:{uniforms:Ye([ft.common,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,{matcap:{value:null}}]),vertexShader:Vt.meshmatcap_vert,fragmentShader:Vt.meshmatcap_frag},points:{uniforms:Ye([ft.points,ft.fog]),vertexShader:Vt.points_vert,fragmentShader:Vt.points_frag},dashed:{uniforms:Ye([ft.common,ft.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Vt.linedashed_vert,fragmentShader:Vt.linedashed_frag},depth:{uniforms:Ye([ft.common,ft.displacementmap]),vertexShader:Vt.depth_vert,fragmentShader:Vt.depth_frag},normal:{uniforms:Ye([ft.common,ft.bumpmap,ft.normalmap,ft.displacementmap,{opacity:{value:1}}]),vertexShader:Vt.meshnormal_vert,fragmentShader:Vt.meshnormal_frag},sprite:{uniforms:Ye([ft.sprite,ft.fog]),vertexShader:Vt.sprite_vert,fragmentShader:Vt.sprite_frag},background:{uniforms:{uvTransform:{value:new zt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Vt.background_vert,fragmentShader:Vt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new zt}},vertexShader:Vt.backgroundCube_vert,fragmentShader:Vt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Vt.cube_vert,fragmentShader:Vt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Vt.equirect_vert,fragmentShader:Vt.equirect_frag},distance:{uniforms:Ye([ft.common,ft.displacementmap,{referencePosition:{value:new F},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Vt.distance_vert,fragmentShader:Vt.distance_frag},shadow:{uniforms:Ye([ft.lights,ft.fog,{color:{value:new Mt(0)},opacity:{value:1}}]),vertexShader:Vt.shadow_vert,fragmentShader:Vt.shadow_frag}};In.physical={uniforms:Ye([In.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new zt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new zt},clearcoatNormalScale:{value:new Ft(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new zt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new zt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new zt},sheen:{value:0},sheenColor:{value:new Mt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new zt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new zt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new zt},transmissionSamplerSize:{value:new Ft},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new zt},attenuationDistance:{value:0},attenuationColor:{value:new Mt(0)},specularColor:{value:new Mt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new zt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new zt},anisotropyVector:{value:new Ft},anisotropyMap:{value:null},anisotropyMapTransform:{value:new zt}}]),vertexShader:Vt.meshphysical_vert,fragmentShader:Vt.meshphysical_frag};const ea={r:0,b:0,g:0},r2=new ue,ld=new zt;ld.set(-1,0,0,0,1,0,0,0,1);function a2(i,t,e,n,s,r){const a=new Mt(0);let o=s===!0?0:1,c,l,h=null,u=0,d=null;function p(A){let T=A.isScene===!0?A.background:null;if(T&&T.isTexture){const M=A.backgroundBlurriness>0;T=t.get(T,M)}return T}function g(A){let T=!1;const M=p(A);M===null?m(a,o):M&&M.isColor&&(m(M,1),T=!0);const y=i.xr.getEnvironmentBlendMode();y==="additive"?e.buffers.color.setClear(0,0,0,1,r):y==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,r),(i.autoClear||T)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function x(A,T){const M=p(T);M&&(M.isCubeTexture||M.mapping===Wa)?(l===void 0&&(l=new oe(new mn(1,1,1),new Be({name:"BackgroundCubeMaterial",uniforms:zs(In.backgroundCube.uniforms),vertexShader:In.backgroundCube.vertexShader,fragmentShader:In.backgroundCube.fragmentShader,side:Fe,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(y,b,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=M,l.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(r2.makeRotationFromEuler(T.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(ld),l.material.toneMapped=Kt.getTransfer(M.colorSpace)!==ee,(h!==M||u!==M.version||d!==i.toneMapping)&&(l.material.needsUpdate=!0,h=M,u=M.version,d=i.toneMapping),l.layers.enableAll(),A.unshift(l,l.geometry,l.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new oe(new Gs(2,2),new Be({name:"BackgroundMaterial",uniforms:zs(In.background.uniforms),vertexShader:In.background.vertexShader,fragmentShader:In.background.fragmentShader,side:Ei,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=M,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.toneMapped=Kt.getTransfer(M.colorSpace)!==ee,M.matrixAutoUpdate===!0&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||u!==M.version||d!==i.toneMapping)&&(c.material.needsUpdate=!0,h=M,u=M.version,d=i.toneMapping),c.layers.enableAll(),A.unshift(c,c.geometry,c.material,0,0,null))}function m(A,T){A.getRGB(ea,sd(i)),e.buffers.color.setClear(ea.r,ea.g,ea.b,T,r)}function f(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(A,T=1){a.set(A),o=T,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(A){o=A,m(a,o)},render:g,addToRenderList:x,dispose:f}}function o2(i,t){const e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=d(null);let r=s,a=!1;function o(C,I,W,X,U){let q=!1;const H=u(C,X,W,I);r!==H&&(r=H,l(r.object)),q=p(C,X,W,U),q&&g(C,X,W,U),U!==null&&t.update(U,i.ELEMENT_ARRAY_BUFFER),(q||a)&&(a=!1,M(C,I,W,X),U!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(U).buffer))}function c(){return i.createVertexArray()}function l(C){return i.bindVertexArray(C)}function h(C){return i.deleteVertexArray(C)}function u(C,I,W,X){const U=X.wireframe===!0;let q=n[I.id];q===void 0&&(q={},n[I.id]=q);const H=C.isInstancedMesh===!0?C.id:0;let $=q[H];$===void 0&&($={},q[H]=$);let et=$[W.id];et===void 0&&(et={},$[W.id]=et);let j=et[U];return j===void 0&&(j=d(c()),et[U]=j),j}function d(C){const I=[],W=[],X=[];for(let U=0;U<e;U++)I[U]=0,W[U]=0,X[U]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:W,attributeDivisors:X,object:C,attributes:{},index:null}}function p(C,I,W,X){const U=r.attributes,q=I.attributes;let H=0;const $=W.getAttributes();for(const et in $)if($[et].location>=0){const it=U[et];let ut=q[et];if(ut===void 0&&(et==="instanceMatrix"&&C.instanceMatrix&&(ut=C.instanceMatrix),et==="instanceColor"&&C.instanceColor&&(ut=C.instanceColor)),it===void 0||it.attribute!==ut||ut&&it.data!==ut.data)return!0;H++}return r.attributesNum!==H||r.index!==X}function g(C,I,W,X){const U={},q=I.attributes;let H=0;const $=W.getAttributes();for(const et in $)if($[et].location>=0){let it=q[et];it===void 0&&(et==="instanceMatrix"&&C.instanceMatrix&&(it=C.instanceMatrix),et==="instanceColor"&&C.instanceColor&&(it=C.instanceColor));const ut={};ut.attribute=it,it&&it.data&&(ut.data=it.data),U[et]=ut,H++}r.attributes=U,r.attributesNum=H,r.index=X}function x(){const C=r.newAttributes;for(let I=0,W=C.length;I<W;I++)C[I]=0}function m(C){f(C,0)}function f(C,I){const W=r.newAttributes,X=r.enabledAttributes,U=r.attributeDivisors;W[C]=1,X[C]===0&&(i.enableVertexAttribArray(C),X[C]=1),U[C]!==I&&(i.vertexAttribDivisor(C,I),U[C]=I)}function A(){const C=r.newAttributes,I=r.enabledAttributes;for(let W=0,X=I.length;W<X;W++)I[W]!==C[W]&&(i.disableVertexAttribArray(W),I[W]=0)}function T(C,I,W,X,U,q,H){H===!0?i.vertexAttribIPointer(C,I,W,U,q):i.vertexAttribPointer(C,I,W,X,U,q)}function M(C,I,W,X){x();const U=X.attributes,q=W.getAttributes(),H=I.defaultAttributeValues;for(const $ in q){const et=q[$];if(et.location>=0){let j=U[$];if(j===void 0&&($==="instanceMatrix"&&C.instanceMatrix&&(j=C.instanceMatrix),$==="instanceColor"&&C.instanceColor&&(j=C.instanceColor)),j!==void 0){const it=j.normalized,ut=j.itemSize,kt=t.get(j);if(kt===void 0)continue;const qt=kt.buffer,Bt=kt.type,Y=kt.bytesPerElement,rt=Bt===i.INT||Bt===i.UNSIGNED_INT||j.gpuType===Dl;if(j.isInterleavedBufferAttribute){const nt=j.data,z=nt.stride,bt=j.offset;if(nt.isInstancedInterleavedBuffer){for(let Dt=0;Dt<et.locationSize;Dt++)f(et.location+Dt,nt.meshPerAttribute);C.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=nt.meshPerAttribute*nt.count)}else for(let Dt=0;Dt<et.locationSize;Dt++)m(et.location+Dt);i.bindBuffer(i.ARRAY_BUFFER,qt);for(let Dt=0;Dt<et.locationSize;Dt++)T(et.location+Dt,ut/et.locationSize,Bt,it,z*Y,(bt+ut/et.locationSize*Dt)*Y,rt)}else{if(j.isInstancedBufferAttribute){for(let nt=0;nt<et.locationSize;nt++)f(et.location+nt,j.meshPerAttribute);C.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=j.meshPerAttribute*j.count)}else for(let nt=0;nt<et.locationSize;nt++)m(et.location+nt);i.bindBuffer(i.ARRAY_BUFFER,qt);for(let nt=0;nt<et.locationSize;nt++)T(et.location+nt,ut/et.locationSize,Bt,it,ut*Y,ut/et.locationSize*nt*Y,rt)}}else if(H!==void 0){const it=H[$];if(it!==void 0)switch(it.length){case 2:i.vertexAttrib2fv(et.location,it);break;case 3:i.vertexAttrib3fv(et.location,it);break;case 4:i.vertexAttrib4fv(et.location,it);break;default:i.vertexAttrib1fv(et.location,it)}}}}A()}function y(){E();for(const C in n){const I=n[C];for(const W in I){const X=I[W];for(const U in X){const q=X[U];for(const H in q)h(q[H].object),delete q[H];delete X[U]}}delete n[C]}}function b(C){if(n[C.id]===void 0)return;const I=n[C.id];for(const W in I){const X=I[W];for(const U in X){const q=X[U];for(const H in q)h(q[H].object),delete q[H];delete X[U]}}delete n[C.id]}function R(C){for(const I in n){const W=n[I];for(const X in W){const U=W[X];if(U[C.id]===void 0)continue;const q=U[C.id];for(const H in q)h(q[H].object),delete q[H];delete U[C.id]}}}function v(C){for(const I in n){const W=n[I],X=C.isInstancedMesh===!0?C.id:0,U=W[X];if(U!==void 0){for(const q in U){const H=U[q];for(const $ in H)h(H[$].object),delete H[$];delete U[q]}delete W[X],Object.keys(W).length===0&&delete n[I]}}}function E(){D(),a=!0,r!==s&&(r=s,l(r.object))}function D(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:E,resetDefaultState:D,dispose:y,releaseStatesOfGeometry:b,releaseStatesOfObject:v,releaseStatesOfProgram:R,initAttributes:x,enableAttribute:m,disableUnusedAttributes:A}}function c2(i,t,e){let n;function s(c){n=c}function r(c,l){i.drawArrays(n,c,l),e.update(l,n,1)}function a(c,l,h){h!==0&&(i.drawArraysInstanced(n,c,l,h),e.update(l,n,h))}function o(c,l,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,h);let d=0;for(let p=0;p<h;p++)d+=l[p];e.update(d,n,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function l2(i,t,e,n){let s;function r(){if(s!==void 0)return s;if(t.has("EXT_texture_filter_anisotropic")===!0){const R=t.get("EXT_texture_filter_anisotropic");s=i.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(R){return!(R!==pn&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const v=R===bn&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(R!==rn&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==zn&&!v)}function c(R){if(R==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="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";const h=c(l);h!==l&&(Ot("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const u=e.logarithmicDepthBuffer===!0,d=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control");e.reversedDepthBuffer===!0&&d===!1&&Ot("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const p=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),f=i.getParameter(i.MAX_VERTEX_ATTRIBS),A=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),T=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),y=i.getParameter(i.MAX_SAMPLES),b=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:p,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:A,maxVaryings:T,maxFragmentUniforms:M,maxSamples:y,samples:b}}function h2(i){const t=this;let e=null,n=0,s=!1,r=!1;const a=new Ui,o=new zt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const p=u.length!==0||d||n!==0||s;return s=d,n=u.length,p},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,p){const g=u.clippingPlanes,x=u.clipIntersection,m=u.clipShadows,f=i.get(u);if(!s||g===null||g.length===0||r&&!m)r?h(null):l();else{const A=r?0:n,T=A*4;let M=f.clippingState||null;c.value=M,M=h(g,d,T,p);for(let y=0;y!==T;++y)M[y]=e[y];f.clippingState=M,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=A}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,p,g){const x=u!==null?u.length:0;let m=null;if(x!==0){if(m=c.value,g!==!0||m===null){const f=p+x*4,A=d.matrixWorldInverse;o.getNormalMatrix(A),(m===null||m.length<f)&&(m=new Float32Array(f));for(let T=0,M=p;T!==x;++T,M+=4)a.copy(u[T]).applyMatrix4(A,o),a.normal.toArray(m,M),m[M+3]=a.constant}c.value=m,c.needsUpdate=!0}return t.numPlanes=x,t.numIntersection=0,m}}const xi=4,eu=[.125,.215,.35,.446,.526,.582],Oi=20,u2=256,Qs=new Ya,nu=new Mt;let No=null,Uo=0,Fo=0,Oo=!1;const d2=new F;class iu{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,n=.1,s=100,r={}){const{size:a=256,position:o=d2}=r;No=this._renderer.getRenderTarget(),Uo=this._renderer.getActiveCubeFace(),Fo=this._renderer.getActiveMipmapLevel(),Oo=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const 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=au(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ru(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(No,Uo,Fo),this._renderer.xr.enabled=Oo,t.scissorTest=!1,vs(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===qi||t.mapping===Fs?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),No=this._renderer.getRenderTarget(),Uo=this._renderer.getActiveCubeFace(),Fo=this._renderer.getActiveMipmapLevel(),Oo=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Ne,minFilter:Ne,generateMipmaps:!1,type:bn,format:pn,colorSpace:Da,depthBuffer:!1},s=su(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=su(t,e,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=f2(r)),this._blurMaterial=m2(r,t,e),this._ggxMaterial=p2(r,t,e)}return s}_compileMaterial(t){const e=new oe(new ye,t);this._renderer.compile(e,Qs)}_sceneToCubeUV(t,e,n,s,r){const c=new sn(90,1,e,n),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,p=u.toneMapping;u.getClearColor(nu),u.toneMapping=Gn,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(s),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new oe(new mn,new Ki({name:"PMREM.Background",side:Fe,depthWrite:!1,depthTest:!1})));const x=this._backgroundBox,m=x.material;let f=!1;const A=t.background;A?A.isColor&&(m.color.copy(A),t.background=null,f=!0):(m.color.copy(nu),f=!0);for(let T=0;T<6;T++){const M=T%3;M===0?(c.up.set(0,l[T],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+h[T],r.y,r.z)):M===1?(c.up.set(0,0,l[T]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+h[T],r.z)):(c.up.set(0,l[T],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+h[T]));const y=this._cubeSize;vs(s,M*y,T>2?y:0,y,y),u.setRenderTarget(s),f&&u.render(x,c),u.render(t,c)}u.toneMapping=p,u.autoClear=d,t.background=A}_textureToCubeUV(t,e){const n=this._renderer,s=t.mapping===qi||t.mapping===Fs;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=au()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=ru());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=t;const c=this._cubeSize;vs(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(a,Qs)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;r<s;r++)this._applyGGXFilter(t,r-1,r);e.autoClear=n}_applyGGXFilter(t,e,n){const s=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const c=a.uniforms,l=n/(this._lodMeshes.length-1),h=e/(this._lodMeshes.length-1),u=Math.sqrt(l*l-h*h),d=0+l*1.25,p=u*d,{_lodMax:g}=this,x=this._sizeLods[n],m=3*x*(n>g-xi?n-g+xi:0),f=4*(this._cubeSize-x);c.envMap.value=t.texture,c.roughness.value=p,c.mipInt.value=g-e,vs(r,m,f,3*x,2*x),s.setRenderTarget(r),s.render(o,Qs),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=g-n,vs(t,m,f,3*x,2*x),s.setRenderTarget(t),s.render(o,Qs)}_blur(t,e,n,s,r){const 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){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Yt("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[s];u.material=l;const d=l.uniforms,p=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*Oi-1),x=r/g,m=isFinite(r)?1+Math.floor(h*x):Oi;m>Oi&&Ot(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Oi}`);const f=[];let A=0;for(let R=0;R<Oi;++R){const v=R/x,E=Math.exp(-v*v/2);f.push(E),R===0?A+=E:R<m&&(A+=2*E)}for(let R=0;R<f.length;R++)f[R]=f[R]/A;d.envMap.value=t.texture,d.samples.value=m,d.weights.value=f,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:T}=this;d.dTheta.value=g,d.mipInt.value=T-n;const M=this._sizeLods[s],y=3*M*(s>T-xi?s-T+xi:0),b=4*(this._cubeSize-M);vs(e,y,b,3*M,2*M),c.setRenderTarget(e),c.render(u,Qs)}}function f2(i){const t=[],e=[],n=[];let s=i;const r=i-xi+1+eu.length;for(let a=0;a<r;a++){const o=Math.pow(2,s);t.push(o);let c=1/o;a>i-xi?c=eu[a-i+xi-1]:a===0&&(c=0),e.push(c);const l=1/(o-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],p=6,g=6,x=3,m=2,f=1,A=new Float32Array(x*g*p),T=new Float32Array(m*g*p),M=new Float32Array(f*g*p);for(let b=0;b<p;b++){const R=b%3*2/3-1,v=b>2?0:-1,E=[R,v,0,R+2/3,v,0,R+2/3,v+1,0,R,v,0,R+2/3,v+1,0,R,v+1,0];A.set(E,x*g*b),T.set(d,m*g*b);const D=[b,b,b,b,b,b];M.set(D,f*g*b)}const y=new ye;y.setAttribute("position",new he(A,x)),y.setAttribute("uv",new he(T,m)),y.setAttribute("faceIndex",new he(M,f)),n.push(new oe(y,null)),s>xi&&s--}return{lodMeshes:n,sizeLods:t,sigmas:e}}function su(i,t,e){const n=new En(i,t,e);return n.texture.mapping=Wa,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function vs(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function p2(i,t,e){return new Be({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:u2,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Ka(),fragmentShader:`
3978
+ }`,Vt={alphahash_fragment:Im,alphahash_pars_fragment:Lm,alphamap_fragment:Nm,alphamap_pars_fragment:Um,alphatest_fragment:Fm,alphatest_pars_fragment:Om,aomap_fragment:zm,aomap_pars_fragment:Bm,batching_pars_vertex:km,batching_vertex:Gm,begin_vertex:Hm,beginnormal_vertex:Vm,bsdfs:Wm,iridescence_fragment:Xm,bumpmap_pars_fragment:qm,clipping_planes_fragment:Ym,clipping_planes_pars_fragment:Km,clipping_planes_pars_vertex:Zm,clipping_planes_vertex:$m,color_fragment:Jm,color_pars_fragment:Qm,color_pars_vertex:jm,color_vertex:tg,common:eg,cube_uv_reflection_fragment:ng,defaultnormal_vertex:ig,displacementmap_pars_vertex:sg,displacementmap_vertex:rg,emissivemap_fragment:ag,emissivemap_pars_fragment:og,colorspace_fragment:cg,colorspace_pars_fragment:lg,envmap_fragment:hg,envmap_common_pars_fragment:ug,envmap_pars_fragment:dg,envmap_pars_vertex:fg,envmap_physical_pars_fragment:bg,envmap_vertex:pg,fog_vertex:mg,fog_pars_vertex:gg,fog_fragment:_g,fog_pars_fragment:vg,gradientmap_pars_fragment:xg,lightmap_pars_fragment:Mg,lights_lambert_fragment:Sg,lights_lambert_pars_fragment:yg,lights_pars_begin:Eg,lights_toon_fragment:Ag,lights_toon_pars_fragment:Tg,lights_phong_fragment:wg,lights_phong_pars_fragment:Rg,lights_physical_fragment:Cg,lights_physical_pars_fragment:Dg,lights_fragment_begin:Pg,lights_fragment_maps:Ig,lights_fragment_end:Lg,lightprobes_pars_fragment:Ng,logdepthbuf_fragment:Ug,logdepthbuf_pars_fragment:Fg,logdepthbuf_pars_vertex:Og,logdepthbuf_vertex:zg,map_fragment:Bg,map_pars_fragment:kg,map_particle_fragment:Gg,map_particle_pars_fragment:Hg,metalnessmap_fragment:Vg,metalnessmap_pars_fragment:Wg,morphinstance_vertex:Xg,morphcolor_vertex:qg,morphnormal_vertex:Yg,morphtarget_pars_vertex:Kg,morphtarget_vertex:Zg,normal_fragment_begin:$g,normal_fragment_maps:Jg,normal_pars_fragment:Qg,normal_pars_vertex:jg,normal_vertex:t1,normalmap_pars_fragment:e1,clearcoat_normal_fragment_begin:n1,clearcoat_normal_fragment_maps:i1,clearcoat_pars_fragment:s1,iridescence_pars_fragment:r1,opaque_fragment:a1,packing:o1,premultiplied_alpha_fragment:c1,project_vertex:l1,dithering_fragment:h1,dithering_pars_fragment:u1,roughnessmap_fragment:d1,roughnessmap_pars_fragment:f1,shadowmap_pars_fragment:p1,shadowmap_pars_vertex:m1,shadowmap_vertex:g1,shadowmask_pars_fragment:_1,skinbase_vertex:v1,skinning_pars_vertex:x1,skinning_vertex:M1,skinnormal_vertex:S1,specularmap_fragment:y1,specularmap_pars_fragment:E1,tonemapping_fragment:b1,tonemapping_pars_fragment:A1,transmission_fragment:T1,transmission_pars_fragment:w1,uv_pars_fragment:R1,uv_pars_vertex:C1,uv_vertex:D1,worldpos_vertex:P1,background_vert:I1,background_frag:L1,backgroundCube_vert:N1,backgroundCube_frag:U1,cube_vert:F1,cube_frag:O1,depth_vert:z1,depth_frag:B1,distance_vert:k1,distance_frag:G1,equirect_vert:H1,equirect_frag:V1,linedashed_vert:W1,linedashed_frag:X1,meshbasic_vert:q1,meshbasic_frag:Y1,meshlambert_vert:K1,meshlambert_frag:Z1,meshmatcap_vert:$1,meshmatcap_frag:J1,meshnormal_vert:Q1,meshnormal_frag:j1,meshphong_vert:t2,meshphong_frag:e2,meshphysical_vert:n2,meshphysical_frag:i2,meshtoon_vert:s2,meshtoon_frag:r2,points_vert:a2,points_frag:o2,shadow_vert:c2,shadow_frag:l2,sprite_vert:h2,sprite_frag:u2},ft={common:{diffuse:{value:new Mt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new zt},alphaMap:{value:null},alphaMapTransform:{value:new zt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new zt}},envmap:{envMap:{value:null},envMapRotation:{value:new zt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new zt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new zt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new zt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new zt},normalScale:{value:new Ft(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new zt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new zt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new zt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new zt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Mt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new F},probesMax:{value:new F},probesResolution:{value:new F}},points:{diffuse:{value:new Mt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new zt},alphaTest:{value:0},uvTransform:{value:new zt}},sprite:{diffuse:{value:new Mt(16777215)},opacity:{value:1},center:{value:new Ft(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new zt},alphaMap:{value:null},alphaMapTransform:{value:new zt},alphaTest:{value:0}}},On={basic:{uniforms:Ke([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.fog]),vertexShader:Vt.meshbasic_vert,fragmentShader:Vt.meshbasic_frag},lambert:{uniforms:Ke([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,ft.lights,{emissive:{value:new Mt(0)},envMapIntensity:{value:1}}]),vertexShader:Vt.meshlambert_vert,fragmentShader:Vt.meshlambert_frag},phong:{uniforms:Ke([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,ft.lights,{emissive:{value:new Mt(0)},specular:{value:new Mt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Vt.meshphong_vert,fragmentShader:Vt.meshphong_frag},standard:{uniforms:Ke([ft.common,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.roughnessmap,ft.metalnessmap,ft.fog,ft.lights,{emissive:{value:new Mt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Vt.meshphysical_vert,fragmentShader:Vt.meshphysical_frag},toon:{uniforms:Ke([ft.common,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.gradientmap,ft.fog,ft.lights,{emissive:{value:new Mt(0)}}]),vertexShader:Vt.meshtoon_vert,fragmentShader:Vt.meshtoon_frag},matcap:{uniforms:Ke([ft.common,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,{matcap:{value:null}}]),vertexShader:Vt.meshmatcap_vert,fragmentShader:Vt.meshmatcap_frag},points:{uniforms:Ke([ft.points,ft.fog]),vertexShader:Vt.points_vert,fragmentShader:Vt.points_frag},dashed:{uniforms:Ke([ft.common,ft.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Vt.linedashed_vert,fragmentShader:Vt.linedashed_frag},depth:{uniforms:Ke([ft.common,ft.displacementmap]),vertexShader:Vt.depth_vert,fragmentShader:Vt.depth_frag},normal:{uniforms:Ke([ft.common,ft.bumpmap,ft.normalmap,ft.displacementmap,{opacity:{value:1}}]),vertexShader:Vt.meshnormal_vert,fragmentShader:Vt.meshnormal_frag},sprite:{uniforms:Ke([ft.sprite,ft.fog]),vertexShader:Vt.sprite_vert,fragmentShader:Vt.sprite_frag},background:{uniforms:{uvTransform:{value:new zt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Vt.background_vert,fragmentShader:Vt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new zt}},vertexShader:Vt.backgroundCube_vert,fragmentShader:Vt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Vt.cube_vert,fragmentShader:Vt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Vt.equirect_vert,fragmentShader:Vt.equirect_frag},distance:{uniforms:Ke([ft.common,ft.displacementmap,{referencePosition:{value:new F},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Vt.distance_vert,fragmentShader:Vt.distance_frag},shadow:{uniforms:Ke([ft.lights,ft.fog,{color:{value:new Mt(0)},opacity:{value:1}}]),vertexShader:Vt.shadow_vert,fragmentShader:Vt.shadow_frag}};On.physical={uniforms:Ke([On.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new zt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new zt},clearcoatNormalScale:{value:new Ft(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new zt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new zt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new zt},sheen:{value:0},sheenColor:{value:new Mt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new zt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new zt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new zt},transmissionSamplerSize:{value:new Ft},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new zt},attenuationDistance:{value:0},attenuationColor:{value:new Mt(0)},specularColor:{value:new Mt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new zt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new zt},anisotropyVector:{value:new Ft},anisotropyMap:{value:null},anisotropyMapTransform:{value:new zt}}]),vertexShader:Vt.meshphysical_vert,fragmentShader:Vt.meshphysical_frag};const ca={r:0,b:0,g:0},d2=new he,gd=new zt;gd.set(-1,0,0,0,1,0,0,0,1);function f2(i,t,e,n,s,r){const a=new Mt(0);let o=s===!0?0:1,c,l,h=null,u=0,d=null;function f(A){let T=A.isScene===!0?A.background:null;if(T&&T.isTexture){const M=A.backgroundBlurriness>0;T=t.get(T,M)}return T}function g(A){let T=!1;const M=f(A);M===null?m(a,o):M&&M.isColor&&(m(M,1),T=!0);const y=i.xr.getEnvironmentBlendMode();y==="additive"?e.buffers.color.setClear(0,0,0,1,r):y==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,r),(i.autoClear||T)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function x(A,T){const M=f(T);M&&(M.isCubeTexture||M.mapping===Qa)?(l===void 0&&(l=new se(new Mn(1,1,1),new Be({name:"BackgroundCubeMaterial",uniforms:Vs(On.backgroundCube.uniforms),vertexShader:On.backgroundCube.vertexShader,fragmentShader:On.backgroundCube.fragmentShader,side:Ce,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(y,b,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=M,l.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(d2.makeRotationFromEuler(T.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(gd),l.material.toneMapped=Kt.getTransfer(M.colorSpace)!==te,(h!==M||u!==M.version||d!==i.toneMapping)&&(l.material.needsUpdate=!0,h=M,u=M.version,d=i.toneMapping),l.layers.enableAll(),A.unshift(l,l.geometry,l.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new se(new qs(2,2),new Be({name:"BackgroundMaterial",uniforms:Vs(On.background.uniforms),vertexShader:On.background.vertexShader,fragmentShader:On.background.fragmentShader,side:wi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=M,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.toneMapped=Kt.getTransfer(M.colorSpace)!==te,M.matrixAutoUpdate===!0&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||u!==M.version||d!==i.toneMapping)&&(c.material.needsUpdate=!0,h=M,u=M.version,d=i.toneMapping),c.layers.enableAll(),A.unshift(c,c.geometry,c.material,0,0,null))}function m(A,T){A.getRGB(ca,ud(i)),e.buffers.color.setClear(ca.r,ca.g,ca.b,T,r)}function p(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(A,T=1){a.set(A),o=T,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(A){o=A,m(a,o)},render:g,addToRenderList:x,dispose:p}}function p2(i,t){const e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=d(null);let r=s,a=!1;function o(C,I,W,X,U){let q=!1;const H=u(C,X,W,I);r!==H&&(r=H,l(r.object)),q=f(C,X,W,U),q&&g(C,X,W,U),U!==null&&t.update(U,i.ELEMENT_ARRAY_BUFFER),(q||a)&&(a=!1,M(C,I,W,X),U!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(U).buffer))}function c(){return i.createVertexArray()}function l(C){return i.bindVertexArray(C)}function h(C){return i.deleteVertexArray(C)}function u(C,I,W,X){const U=X.wireframe===!0;let q=n[I.id];q===void 0&&(q={},n[I.id]=q);const H=C.isInstancedMesh===!0?C.id:0;let $=q[H];$===void 0&&($={},q[H]=$);let et=$[W.id];et===void 0&&(et={},$[W.id]=et);let j=et[U];return j===void 0&&(j=d(c()),et[U]=j),j}function d(C){const I=[],W=[],X=[];for(let U=0;U<e;U++)I[U]=0,W[U]=0,X[U]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:W,attributeDivisors:X,object:C,attributes:{},index:null}}function f(C,I,W,X){const U=r.attributes,q=I.attributes;let H=0;const $=W.getAttributes();for(const et in $)if($[et].location>=0){const it=U[et];let ut=q[et];if(ut===void 0&&(et==="instanceMatrix"&&C.instanceMatrix&&(ut=C.instanceMatrix),et==="instanceColor"&&C.instanceColor&&(ut=C.instanceColor)),it===void 0||it.attribute!==ut||ut&&it.data!==ut.data)return!0;H++}return r.attributesNum!==H||r.index!==X}function g(C,I,W,X){const U={},q=I.attributes;let H=0;const $=W.getAttributes();for(const et in $)if($[et].location>=0){let it=q[et];it===void 0&&(et==="instanceMatrix"&&C.instanceMatrix&&(it=C.instanceMatrix),et==="instanceColor"&&C.instanceColor&&(it=C.instanceColor));const ut={};ut.attribute=it,it&&it.data&&(ut.data=it.data),U[et]=ut,H++}r.attributes=U,r.attributesNum=H,r.index=X}function x(){const C=r.newAttributes;for(let I=0,W=C.length;I<W;I++)C[I]=0}function m(C){p(C,0)}function p(C,I){const W=r.newAttributes,X=r.enabledAttributes,U=r.attributeDivisors;W[C]=1,X[C]===0&&(i.enableVertexAttribArray(C),X[C]=1),U[C]!==I&&(i.vertexAttribDivisor(C,I),U[C]=I)}function A(){const C=r.newAttributes,I=r.enabledAttributes;for(let W=0,X=I.length;W<X;W++)I[W]!==C[W]&&(i.disableVertexAttribArray(W),I[W]=0)}function T(C,I,W,X,U,q,H){H===!0?i.vertexAttribIPointer(C,I,W,U,q):i.vertexAttribPointer(C,I,W,X,U,q)}function M(C,I,W,X){x();const U=X.attributes,q=W.getAttributes(),H=I.defaultAttributeValues;for(const $ in q){const et=q[$];if(et.location>=0){let j=U[$];if(j===void 0&&($==="instanceMatrix"&&C.instanceMatrix&&(j=C.instanceMatrix),$==="instanceColor"&&C.instanceColor&&(j=C.instanceColor)),j!==void 0){const it=j.normalized,ut=j.itemSize,kt=t.get(j);if(kt===void 0)continue;const qt=kt.buffer,Bt=kt.type,Y=kt.bytesPerElement,rt=Bt===i.INT||Bt===i.UNSIGNED_INT||j.gpuType===Ol;if(j.isInterleavedBufferAttribute){const nt=j.data,z=nt.stride,bt=j.offset;if(nt.isInstancedInterleavedBuffer){for(let Dt=0;Dt<et.locationSize;Dt++)p(et.location+Dt,nt.meshPerAttribute);C.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=nt.meshPerAttribute*nt.count)}else for(let Dt=0;Dt<et.locationSize;Dt++)m(et.location+Dt);i.bindBuffer(i.ARRAY_BUFFER,qt);for(let Dt=0;Dt<et.locationSize;Dt++)T(et.location+Dt,ut/et.locationSize,Bt,it,z*Y,(bt+ut/et.locationSize*Dt)*Y,rt)}else{if(j.isInstancedBufferAttribute){for(let nt=0;nt<et.locationSize;nt++)p(et.location+nt,j.meshPerAttribute);C.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=j.meshPerAttribute*j.count)}else for(let nt=0;nt<et.locationSize;nt++)m(et.location+nt);i.bindBuffer(i.ARRAY_BUFFER,qt);for(let nt=0;nt<et.locationSize;nt++)T(et.location+nt,ut/et.locationSize,Bt,it,ut*Y,ut/et.locationSize*nt*Y,rt)}}else if(H!==void 0){const it=H[$];if(it!==void 0)switch(it.length){case 2:i.vertexAttrib2fv(et.location,it);break;case 3:i.vertexAttrib3fv(et.location,it);break;case 4:i.vertexAttrib4fv(et.location,it);break;default:i.vertexAttrib1fv(et.location,it)}}}}A()}function y(){E();for(const C in n){const I=n[C];for(const W in I){const X=I[W];for(const U in X){const q=X[U];for(const H in q)h(q[H].object),delete q[H];delete X[U]}}delete n[C]}}function b(C){if(n[C.id]===void 0)return;const I=n[C.id];for(const W in I){const X=I[W];for(const U in X){const q=X[U];for(const H in q)h(q[H].object),delete q[H];delete X[U]}}delete n[C.id]}function R(C){for(const I in n){const W=n[I];for(const X in W){const U=W[X];if(U[C.id]===void 0)continue;const q=U[C.id];for(const H in q)h(q[H].object),delete q[H];delete U[C.id]}}}function v(C){for(const I in n){const W=n[I],X=C.isInstancedMesh===!0?C.id:0,U=W[X];if(U!==void 0){for(const q in U){const H=U[q];for(const $ in H)h(H[$].object),delete H[$];delete U[q]}delete W[X],Object.keys(W).length===0&&delete n[I]}}}function E(){D(),a=!0,r!==s&&(r=s,l(r.object))}function D(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:E,resetDefaultState:D,dispose:y,releaseStatesOfGeometry:b,releaseStatesOfObject:v,releaseStatesOfProgram:R,initAttributes:x,enableAttribute:m,disableUnusedAttributes:A}}function m2(i,t,e){let n;function s(c){n=c}function r(c,l){i.drawArrays(n,c,l),e.update(l,n,1)}function a(c,l,h){h!==0&&(i.drawArraysInstanced(n,c,l,h),e.update(l,n,h))}function o(c,l,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,h);let d=0;for(let f=0;f<h;f++)d+=l[f];e.update(d,n,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function g2(i,t,e,n){let s;function r(){if(s!==void 0)return s;if(t.has("EXT_texture_filter_anisotropic")===!0){const R=t.get("EXT_texture_filter_anisotropic");s=i.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(R){return!(R!==un&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const v=R===xn&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(R!==ln&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==Vn&&!v)}function c(R){if(R==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="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";const h=c(l);h!==l&&(Ot("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const u=e.logarithmicDepthBuffer===!0,d=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control");e.reversedDepthBuffer===!0&&d===!1&&Ot("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),A=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),T=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),y=i.getParameter(i.MAX_SAMPLES),b=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:A,maxVaryings:T,maxFragmentUniforms:M,maxSamples:y,samples:b}}function _2(i){const t=this;let e=null,n=0,s=!1,r=!1;const a=new ki,o=new zt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||n!==0||s;return s=d,n=u.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const g=u.clippingPlanes,x=u.clipIntersection,m=u.clipShadows,p=i.get(u);if(!s||g===null||g.length===0||r&&!m)r?h(null):l();else{const A=r?0:n,T=A*4;let M=p.clippingState||null;c.value=M,M=h(g,d,T,f);for(let y=0;y!==T;++y)M[y]=e[y];p.clippingState=M,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=A}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,g){const x=u!==null?u.length:0;let m=null;if(x!==0){if(m=c.value,g!==!0||m===null){const p=f+x*4,A=d.matrixWorldInverse;o.getNormalMatrix(A),(m===null||m.length<p)&&(m=new Float32Array(p));for(let T=0,M=f;T!==x;++T,M+=4)a.copy(u[T]).applyMatrix4(A,o),a.normal.toArray(m,M),m[M+3]=a.constant}c.value=m,c.needsUpdate=!0}return t.numPlanes=x,t.numIntersection=0,m}}const Ei=4,lu=[.125,.215,.35,.446,.526,.582],Hi=20,v2=256,ir=new eo,hu=new Mt;let Go=null,Ho=0,Vo=0,Wo=!1;const x2=new F;class uu{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,n=.1,s=100,r={}){const{size:a=256,position:o=x2}=r;Go=this._renderer.getRenderTarget(),Ho=this._renderer.getActiveCubeFace(),Vo=this._renderer.getActiveMipmapLevel(),Wo=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const 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=pu(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=fu(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(Go,Ho,Vo),this._renderer.xr.enabled=Wo,t.scissorTest=!1,Ss(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Zi||t.mapping===Gs?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Go=this._renderer.getRenderTarget(),Ho=this._renderer.getActiveCubeFace(),Vo=this._renderer.getActiveMipmapLevel(),Wo=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:we,minFilter:we,generateMipmaps:!1,type:xn,format:un,colorSpace:Oa,depthBuffer:!1},s=du(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=du(t,e,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=M2(r)),this._blurMaterial=y2(r,t,e),this._ggxMaterial=S2(r,t,e)}return s}_compileMaterial(t){const e=new se(new Ee,t);this._renderer.compile(e,ir)}_sceneToCubeUV(t,e,n,s,r){const c=new cn(90,1,e,n),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(hu),u.toneMapping=qn,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(s),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new se(new Mn,new Ji({name:"PMREM.Background",side:Ce,depthWrite:!1,depthTest:!1})));const x=this._backgroundBox,m=x.material;let p=!1;const A=t.background;A?A.isColor&&(m.color.copy(A),t.background=null,p=!0):(m.color.copy(hu),p=!0);for(let T=0;T<6;T++){const M=T%3;M===0?(c.up.set(0,l[T],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+h[T],r.y,r.z)):M===1?(c.up.set(0,0,l[T]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+h[T],r.z)):(c.up.set(0,l[T],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+h[T]));const y=this._cubeSize;Ss(s,M*y,T>2?y:0,y,y),u.setRenderTarget(s),p&&u.render(x,c),u.render(t,c)}u.toneMapping=f,u.autoClear=d,t.background=A}_textureToCubeUV(t,e){const n=this._renderer,s=t.mapping===Zi||t.mapping===Gs;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=pu()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=fu());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=t;const c=this._cubeSize;Ss(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(a,ir)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;r<s;r++)this._applyGGXFilter(t,r-1,r);e.autoClear=n}_applyGGXFilter(t,e,n){const s=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const c=a.uniforms,l=n/(this._lodMeshes.length-1),h=e/(this._lodMeshes.length-1),u=Math.sqrt(l*l-h*h),d=0+l*1.25,f=u*d,{_lodMax:g}=this,x=this._sizeLods[n],m=3*x*(n>g-Ei?n-g+Ei:0),p=4*(this._cubeSize-x);c.envMap.value=t.texture,c.roughness.value=f,c.mipInt.value=g-e,Ss(r,m,p,3*x,2*x),s.setRenderTarget(r),s.render(o,ir),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=g-n,Ss(t,m,p,3*x,2*x),s.setRenderTarget(t),s.render(o,ir)}_blur(t,e,n,s,r){const 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){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Yt("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[s];u.material=l;const d=l.uniforms,f=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Hi-1),x=r/g,m=isFinite(r)?1+Math.floor(h*x):Hi;m>Hi&&Ot(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Hi}`);const p=[];let A=0;for(let R=0;R<Hi;++R){const v=R/x,E=Math.exp(-v*v/2);p.push(E),R===0?A+=E:R<m&&(A+=2*E)}for(let R=0;R<p.length;R++)p[R]=p[R]/A;d.envMap.value=t.texture,d.samples.value=m,d.weights.value=p,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:T}=this;d.dTheta.value=g,d.mipInt.value=T-n;const M=this._sizeLods[s],y=3*M*(s>T-Ei?s-T+Ei:0),b=4*(this._cubeSize-M);Ss(e,y,b,3*M,2*M),c.setRenderTarget(e),c.render(u,ir)}}function M2(i){const t=[],e=[],n=[];let s=i;const r=i-Ei+1+lu.length;for(let a=0;a<r;a++){const o=Math.pow(2,s);t.push(o);let c=1/o;a>i-Ei?c=lu[a-i+Ei-1]:a===0&&(c=0),e.push(c);const l=1/(o-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,g=6,x=3,m=2,p=1,A=new Float32Array(x*g*f),T=new Float32Array(m*g*f),M=new Float32Array(p*g*f);for(let b=0;b<f;b++){const R=b%3*2/3-1,v=b>2?0:-1,E=[R,v,0,R+2/3,v,0,R+2/3,v+1,0,R,v,0,R+2/3,v+1,0,R,v+1,0];A.set(E,x*g*b),T.set(d,m*g*b);const D=[b,b,b,b,b,b];M.set(D,p*g*b)}const y=new Ee;y.setAttribute("position",new le(A,x)),y.setAttribute("uv",new le(T,m)),y.setAttribute("faceIndex",new le(M,p)),n.push(new se(y,null)),s>Ei&&s--}return{lodMeshes:n,sizeLods:t,sigmas:e}}function du(i,t,e){const n=new Rn(i,t,e);return n.texture.mapping=Qa,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ss(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function S2(i,t,e){return new Be({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:v2,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:no(),fragmentShader:`
3979
3979
 
3980
3980
  precision highp float;
3981
3981
  precision highp int;
@@ -4079,7 +4079,7 @@ void main() {
4079
4079
 
4080
4080
  gl_FragColor = vec4(prefilteredColor, 1.0);
4081
4081
  }
4082
- `,blending:ti,depthTest:!1,depthWrite:!1})}function m2(i,t,e){const n=new Float32Array(Oi),s=new F(0,1,0);return new Be({name:"SphericalGaussianBlur",defines:{n:Oi,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:Ka(),fragmentShader:`
4082
+ `,blending:si,depthTest:!1,depthWrite:!1})}function y2(i,t,e){const n=new Float32Array(Hi),s=new F(0,1,0);return new Be({name:"SphericalGaussianBlur",defines:{n:Hi,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:no(),fragmentShader:`
4083
4083
 
4084
4084
  precision mediump float;
4085
4085
  precision mediump int;
@@ -4139,7 +4139,7 @@ void main() {
4139
4139
  }
4140
4140
 
4141
4141
  }
4142
- `,blending:ti,depthTest:!1,depthWrite:!1})}function ru(){return new Be({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ka(),fragmentShader:`
4142
+ `,blending:si,depthTest:!1,depthWrite:!1})}function fu(){return new Be({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:no(),fragmentShader:`
4143
4143
 
4144
4144
  precision mediump float;
4145
4145
  precision mediump int;
@@ -4158,7 +4158,7 @@ void main() {
4158
4158
  gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
4159
4159
 
4160
4160
  }
4161
- `,blending:ti,depthTest:!1,depthWrite:!1})}function au(){return new Be({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ka(),fragmentShader:`
4161
+ `,blending:si,depthTest:!1,depthWrite:!1})}function pu(){return new Be({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:no(),fragmentShader:`
4162
4162
 
4163
4163
  precision mediump float;
4164
4164
  precision mediump int;
@@ -4174,7 +4174,7 @@ void main() {
4174
4174
  gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
4175
4175
 
4176
4176
  }
4177
- `,blending:ti,depthTest:!1,depthWrite:!1})}function Ka(){return`
4177
+ `,blending:si,depthTest:!1,depthWrite:!1})}function no(){return`
4178
4178
 
4179
4179
  precision mediump float;
4180
4180
  precision mediump int;
@@ -4229,7 +4229,7 @@ void main() {
4229
4229
  gl_Position = vec4( position, 1.0 );
4230
4230
 
4231
4231
  }
4232
- `}class hd extends En{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},s=[n,n,n,n,n,n];this.texture=new nd(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;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
4232
+ `}class _d extends Rn{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},s=[n,n,n,n,n,n];this.texture=new ld(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;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
4233
4233
 
4234
4234
  varying vec3 vWorldDirection;
4235
4235
 
@@ -4264,7 +4264,7 @@ void main() {
4264
4264
  gl_FragColor = texture2D( tEquirect, sampleUV );
4265
4265
 
4266
4266
  }
4267
- `},s=new mn(5,5,5),r=new Be({name:"CubemapFromEquirect",uniforms:zs(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Fe,blending:ti});r.uniforms.tEquirect.value=e;const a=new oe(s,r),o=e.minFilter;return e.minFilter===ki&&(e.minFilter=Ne),new Sm(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e=!0,n=!0,s=!0){const r=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,s);t.setRenderTarget(r)}}function g2(i){let t=new WeakMap,e=new WeakMap,n=null;function s(d,p=!1){return d==null?null:p?a(d):r(d)}function r(d){if(d&&d.isTexture){const p=d.mapping;if(p===no||p===io)if(t.has(d)){const g=t.get(d).texture;return o(g,d.mapping)}else{const g=d.image;if(g&&g.height>0){const x=new hd(g.height);return x.fromEquirectangularTexture(i,d),t.set(d,x),d.addEventListener("dispose",l),o(x.texture,d.mapping)}else return null}}return d}function a(d){if(d&&d.isTexture){const p=d.mapping,g=p===no||p===io,x=p===qi||p===Fs;if(g||x){let m=e.get(d);const f=m!==void 0?m.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==f)return n===null&&(n=new iu(i)),m=g?n.fromEquirectangular(d,m):n.fromCubemap(d,m),m.texture.pmremVersion=d.pmremVersion,e.set(d,m),m.texture;if(m!==void 0)return m.texture;{const A=d.image;return g&&A&&A.height>0||x&&A&&c(A)?(n===null&&(n=new iu(i)),m=g?n.fromEquirectangular(d):n.fromCubemap(d),m.texture.pmremVersion=d.pmremVersion,e.set(d,m),d.addEventListener("dispose",h),m.texture):null}}}return d}function o(d,p){return p===no?d.mapping=qi:p===io&&(d.mapping=Fs),d}function c(d){let p=0;const g=6;for(let x=0;x<g;x++)d[x]!==void 0&&p++;return p===g}function l(d){const p=d.target;p.removeEventListener("dispose",l);const g=t.get(p);g!==void 0&&(t.delete(p),g.dispose())}function h(d){const p=d.target;p.removeEventListener("dispose",h);const g=e.get(p);g!==void 0&&(e.delete(p),g.dispose())}function u(){t=new WeakMap,e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:s,dispose:u}}function _2(i){const t={};function e(n){if(t[n]!==void 0)return t[n];const 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){const s=e(n);return s===null&&Ds("WebGLRenderer: "+n+" extension not supported."),s}}}function v2(i,t,e,n){const s={},r=new WeakMap;function a(u){const d=u.target;d.index!==null&&t.remove(d.index);for(const g in d.attributes)t.remove(d.attributes[g]);d.removeEventListener("dispose",a),delete s[d.id];const p=r.get(d);p&&(t.remove(p),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,e.memory.geometries--}function o(u,d){return s[d.id]===!0||(d.addEventListener("dispose",a),s[d.id]=!0,e.memory.geometries++),d}function c(u){const d=u.attributes;for(const p in d)t.update(d[p],i.ARRAY_BUFFER)}function l(u){const d=[],p=u.index,g=u.attributes.position;let x=0;if(g===void 0)return;if(p!==null){const A=p.array;x=p.version;for(let T=0,M=A.length;T<M;T+=3){const y=A[T+0],b=A[T+1],R=A[T+2];d.push(y,b,b,R,R,y)}}else{const A=g.array;x=g.version;for(let T=0,M=A.length/3-1;T<M;T+=3){const y=T+0,b=T+1,R=T+2;d.push(y,b,b,R,R,y)}}const m=new(g.count>=65535?Q0:J0)(d,1);m.version=x;const f=r.get(u);f&&t.remove(f),r.set(u,m)}function h(u){const d=r.get(u);if(d){const p=u.index;p!==null&&d.version<p.version&&l(u)}else l(u);return r.get(u)}return{get:o,update:c,getWireframeAttribute:h}}function x2(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,d){i.drawElements(n,d,r,u*a),e.update(d,n,1)}function l(u,d,p){p!==0&&(i.drawElementsInstanced(n,d,r,u*a,p),e.update(d,n,p))}function h(u,d,p){if(p===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,d,0,r,u,0,p);let x=0;for(let m=0;m<p;m++)x+=d[m];e.update(x,n,1)}this.setMode=s,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h}function M2(i){const 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:Yt("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 S2(i,t,e){const n=new WeakMap,s=new pe;function r(a,o,c){const l=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=n.get(o);if(d===void 0||d.count!==u){let E=function(){R.dispose(),n.delete(o),o.removeEventListener("dispose",E)};d!==void 0&&d.texture.dispose();const p=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,x=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],f=o.morphAttributes.normal||[],A=o.morphAttributes.color||[];let T=0;p===!0&&(T=1),g===!0&&(T=2),x===!0&&(T=3);let M=o.attributes.position.count*T,y=1;M>t.maxTextureSize&&(y=Math.ceil(M/t.maxTextureSize),M=t.maxTextureSize);const b=new Float32Array(M*y*4*u),R=new K0(b,M,y,u);R.type=zn,R.needsUpdate=!0;const v=T*4;for(let D=0;D<u;D++){const C=m[D],I=f[D],W=A[D],X=M*y*4*D;for(let U=0;U<C.count;U++){const q=U*v;p===!0&&(s.fromBufferAttribute(C,U),b[X+q+0]=s.x,b[X+q+1]=s.y,b[X+q+2]=s.z,b[X+q+3]=0),g===!0&&(s.fromBufferAttribute(I,U),b[X+q+4]=s.x,b[X+q+5]=s.y,b[X+q+6]=s.z,b[X+q+7]=0),x===!0&&(s.fromBufferAttribute(W,U),b[X+q+8]=s.x,b[X+q+9]=s.y,b[X+q+10]=s.z,b[X+q+11]=W.itemSize===4?s.w:1)}}d={count:u,texture:R,size:new Ft(M,y)},n.set(o,d),o.addEventListener("dispose",E)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",a.morphTexture,e);else{let p=0;for(let x=0;x<l.length;x++)p+=l[x];const g=o.morphTargetsRelative?1:1-p;c.getUniforms().setValue(i,"morphTargetBaseInfluence",g),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",d.texture,e),c.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:r}}function y2(i,t,e,n,s){let r=new WeakMap;function a(l){const h=s.render.frame,u=l.geometry,d=t.get(l,u);if(r.get(d)!==h&&(t.update(d),r.set(d,h)),l.isInstancedMesh&&(l.hasEventListener("dispose",c)===!1&&l.addEventListener("dispose",c),r.get(l)!==h&&(e.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&e.update(l.instanceColor,i.ARRAY_BUFFER),r.set(l,h))),l.isSkinnedMesh){const p=l.skeleton;r.get(p)!==h&&(p.update(),r.set(p,h))}return d}function o(){r=new WeakMap}function c(l){const h=l.target;h.removeEventListener("dispose",c),n.releaseStatesOfObject(h),e.remove(h.instanceMatrix),h.instanceColor!==null&&e.remove(h.instanceColor)}return{update:a,dispose:o}}const E2={[I0]:"LINEAR_TONE_MAPPING",[L0]:"REINHARD_TONE_MAPPING",[N0]:"CINEON_TONE_MAPPING",[U0]:"ACES_FILMIC_TONE_MAPPING",[O0]:"AGX_TONE_MAPPING",[z0]:"NEUTRAL_TONE_MAPPING",[F0]:"CUSTOM_TONE_MAPPING"};function b2(i,t,e,n,s,r){const a=new En(t,e,{type:i,depthBuffer:s,stencilBuffer:r,samples:n?4:0,depthTexture:s?new Os(t,e):void 0}),o=new En(t,e,{type:bn,depthBuffer:!1,stencilBuffer:!1}),c=new ye;c.setAttribute("position",new we([-1,3,0,-1,-1,0,3,-1,0],3)),c.setAttribute("uv",new we([0,2,0,0,2,0],2));const l=new fm({uniforms:{tDiffuse:{value:null}},vertexShader:`
4267
+ `},s=new Mn(5,5,5),r=new Be({name:"CubemapFromEquirect",uniforms:Vs(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ce,blending:si});r.uniforms.tEquirect.value=e;const a=new se(s,r),o=e.minFilter;return e.minFilter===Xi&&(e.minFilter=we),new Rm(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e=!0,n=!0,s=!0){const r=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,s);t.setRenderTarget(r)}}function E2(i){let t=new WeakMap,e=new WeakMap,n=null;function s(d,f=!1){return d==null?null:f?a(d):r(d)}function r(d){if(d&&d.isTexture){const f=d.mapping;if(f===ho||f===uo)if(t.has(d)){const g=t.get(d).texture;return o(g,d.mapping)}else{const g=d.image;if(g&&g.height>0){const x=new _d(g.height);return x.fromEquirectangularTexture(i,d),t.set(d,x),d.addEventListener("dispose",l),o(x.texture,d.mapping)}else return null}}return d}function a(d){if(d&&d.isTexture){const f=d.mapping,g=f===ho||f===uo,x=f===Zi||f===Gs;if(g||x){let m=e.get(d);const p=m!==void 0?m.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==p)return n===null&&(n=new uu(i)),m=g?n.fromEquirectangular(d,m):n.fromCubemap(d,m),m.texture.pmremVersion=d.pmremVersion,e.set(d,m),m.texture;if(m!==void 0)return m.texture;{const A=d.image;return g&&A&&A.height>0||x&&A&&c(A)?(n===null&&(n=new uu(i)),m=g?n.fromEquirectangular(d):n.fromCubemap(d),m.texture.pmremVersion=d.pmremVersion,e.set(d,m),d.addEventListener("dispose",h),m.texture):null}}}return d}function o(d,f){return f===ho?d.mapping=Zi:f===uo&&(d.mapping=Gs),d}function c(d){let f=0;const g=6;for(let x=0;x<g;x++)d[x]!==void 0&&f++;return f===g}function l(d){const f=d.target;f.removeEventListener("dispose",l);const g=t.get(f);g!==void 0&&(t.delete(f),g.dispose())}function h(d){const f=d.target;f.removeEventListener("dispose",h);const g=e.get(f);g!==void 0&&(e.delete(f),g.dispose())}function u(){t=new WeakMap,e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:s,dispose:u}}function b2(i){const t={};function e(n){if(t[n]!==void 0)return t[n];const 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){const s=e(n);return s===null&&Ls("WebGLRenderer: "+n+" extension not supported."),s}}}function A2(i,t,e,n){const s={},r=new WeakMap;function a(u){const d=u.target;d.index!==null&&t.remove(d.index);for(const g in d.attributes)t.remove(d.attributes[g]);d.removeEventListener("dispose",a),delete s[d.id];const f=r.get(d);f&&(t.remove(f),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,e.memory.geometries--}function o(u,d){return s[d.id]===!0||(d.addEventListener("dispose",a),s[d.id]=!0,e.memory.geometries++),d}function c(u){const d=u.attributes;for(const f in d)t.update(d[f],i.ARRAY_BUFFER)}function l(u){const d=[],f=u.index,g=u.attributes.position;let x=0;if(g===void 0)return;if(f!==null){const A=f.array;x=f.version;for(let T=0,M=A.length;T<M;T+=3){const y=A[T+0],b=A[T+1],R=A[T+2];d.push(y,b,b,R,R,y)}}else{const A=g.array;x=g.version;for(let T=0,M=A.length/3-1;T<M;T+=3){const y=T+0,b=T+1,R=T+2;d.push(y,b,b,R,R,y)}}const m=new(g.count>=65535?ad:rd)(d,1);m.version=x;const p=r.get(u);p&&t.remove(p),r.set(u,m)}function h(u){const d=r.get(u);if(d){const f=u.index;f!==null&&d.version<f.version&&l(u)}else l(u);return r.get(u)}return{get:o,update:c,getWireframeAttribute:h}}function T2(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,d){i.drawElements(n,d,r,u*a),e.update(d,n,1)}function l(u,d,f){f!==0&&(i.drawElementsInstanced(n,d,r,u*a,f),e.update(d,n,f))}function h(u,d,f){if(f===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,d,0,r,u,0,f);let x=0;for(let m=0;m<f;m++)x+=d[m];e.update(x,n,1)}this.setMode=s,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h}function w2(i){const 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:Yt("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 R2(i,t,e){const n=new WeakMap,s=new pe;function r(a,o,c){const l=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=n.get(o);if(d===void 0||d.count!==u){let E=function(){R.dispose(),n.delete(o),o.removeEventListener("dispose",E)};d!==void 0&&d.texture.dispose();const f=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,x=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],p=o.morphAttributes.normal||[],A=o.morphAttributes.color||[];let T=0;f===!0&&(T=1),g===!0&&(T=2),x===!0&&(T=3);let M=o.attributes.position.count*T,y=1;M>t.maxTextureSize&&(y=Math.ceil(M/t.maxTextureSize),M=t.maxTextureSize);const b=new Float32Array(M*y*4*u),R=new nd(b,M,y,u);R.type=Vn,R.needsUpdate=!0;const v=T*4;for(let D=0;D<u;D++){const C=m[D],I=p[D],W=A[D],X=M*y*4*D;for(let U=0;U<C.count;U++){const q=U*v;f===!0&&(s.fromBufferAttribute(C,U),b[X+q+0]=s.x,b[X+q+1]=s.y,b[X+q+2]=s.z,b[X+q+3]=0),g===!0&&(s.fromBufferAttribute(I,U),b[X+q+4]=s.x,b[X+q+5]=s.y,b[X+q+6]=s.z,b[X+q+7]=0),x===!0&&(s.fromBufferAttribute(W,U),b[X+q+8]=s.x,b[X+q+9]=s.y,b[X+q+10]=s.z,b[X+q+11]=W.itemSize===4?s.w:1)}}d={count:u,texture:R,size:new Ft(M,y)},n.set(o,d),o.addEventListener("dispose",E)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",a.morphTexture,e);else{let f=0;for(let x=0;x<l.length;x++)f+=l[x];const g=o.morphTargetsRelative?1:1-f;c.getUniforms().setValue(i,"morphTargetBaseInfluence",g),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",d.texture,e),c.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:r}}function C2(i,t,e,n,s){let r=new WeakMap;function a(l){const h=s.render.frame,u=l.geometry,d=t.get(l,u);if(r.get(d)!==h&&(t.update(d),r.set(d,h)),l.isInstancedMesh&&(l.hasEventListener("dispose",c)===!1&&l.addEventListener("dispose",c),r.get(l)!==h&&(e.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&e.update(l.instanceColor,i.ARRAY_BUFFER),r.set(l,h))),l.isSkinnedMesh){const f=l.skeleton;r.get(f)!==h&&(f.update(),r.set(f,h))}return d}function o(){r=new WeakMap}function c(l){const h=l.target;h.removeEventListener("dispose",c),n.releaseStatesOfObject(h),e.remove(h.instanceMatrix),h.instanceColor!==null&&e.remove(h.instanceColor)}return{update:a,dispose:o}}const D2={[k0]:"LINEAR_TONE_MAPPING",[G0]:"REINHARD_TONE_MAPPING",[H0]:"CINEON_TONE_MAPPING",[V0]:"ACES_FILMIC_TONE_MAPPING",[X0]:"AGX_TONE_MAPPING",[q0]:"NEUTRAL_TONE_MAPPING",[W0]:"CUSTOM_TONE_MAPPING"};function P2(i,t,e,n,s,r){const a=new Rn(t,e,{type:i,depthBuffer:s,stencilBuffer:r,samples:n?4:0,depthTexture:s?new Hs(t,e):void 0}),o=new Rn(t,e,{type:xn,depthBuffer:!1,stencilBuffer:!1}),c=new Ee;c.setAttribute("position",new De([-1,3,0,-1,-1,0,3,-1,0],3)),c.setAttribute("uv",new De([0,2,0,0,2,0],2));const l=new Mm({uniforms:{tDiffuse:{value:null}},vertexShader:`
4268
4268
  precision highp float;
4269
4269
 
4270
4270
  uniform mat4 modelViewMatrix;
@@ -4310,17 +4310,17 @@ void main() {
4310
4310
  #ifdef SRGB_TRANSFER
4311
4311
  gl_FragColor = sRGBTransferOETF( gl_FragColor );
4312
4312
  #endif
4313
- }`,depthTest:!1,depthWrite:!1}),h=new oe(c,l),u=new Ya(-1,1,1,-1,0,1);let d=null,p=null,g=!1,x,m=null,f=[],A=!1;this.setSize=function(T,M){a.setSize(T,M),o.setSize(T,M);for(let y=0;y<f.length;y++){const b=f[y];b.setSize&&b.setSize(T,M)}},this.setEffects=function(T){f=T,A=f.length>0&&f[0].isRenderPass===!0;const M=a.width,y=a.height;for(let b=0;b<f.length;b++){const R=f[b];R.setSize&&R.setSize(M,y)}},this.begin=function(T,M){if(g||T.toneMapping===Gn&&f.length===0)return!1;if(m=M,M!==null){const y=M.width,b=M.height;(a.width!==y||a.height!==b)&&this.setSize(y,b)}return A===!1&&T.setRenderTarget(a),x=T.toneMapping,T.toneMapping=Gn,!0},this.hasRenderPass=function(){return A},this.end=function(T,M){T.toneMapping=x,g=!0;let y=a,b=o;for(let R=0;R<f.length;R++){const v=f[R];if(v.enabled!==!1&&(v.render(T,b,y,M),v.needsSwap!==!1)){const E=y;y=b,b=E}}if(d!==T.outputColorSpace||p!==T.toneMapping){d=T.outputColorSpace,p=T.toneMapping,l.defines={},Kt.getTransfer(d)===ee&&(l.defines.SRGB_TRANSFER="");const R=E2[p];R&&(l.defines[R]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=y.texture,T.setRenderTarget(m),T.render(h,u),m=null,g=!1},this.isCompositing=function(){return g},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),c.dispose(),l.dispose()}}const ud=new Xe,tl=new Os(1,1),dd=new K0,fd=new Hp,pd=new nd,ou=[],cu=[],lu=new Float32Array(16),hu=new Float32Array(9),uu=new Float32Array(4);function Hs(i,t,e){const n=i[0];if(n<=0||n>0)return i;const s=t*e;let r=ou[s];if(r===void 0&&(r=new Float32Array(s),ou[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 Re(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 Ce(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function Za(i,t){let e=cu[t];e===void 0&&(e=new Int32Array(t),cu[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function A2(i,t){const e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function T2(i,t){const 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(Re(e,t))return;i.uniform2fv(this.addr,t),Ce(e,t)}}function w2(i,t){const 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(Re(e,t))return;i.uniform3fv(this.addr,t),Ce(e,t)}}function R2(i,t){const 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(Re(e,t))return;i.uniform4fv(this.addr,t),Ce(e,t)}}function C2(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Re(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),Ce(e,t)}else{if(Re(e,n))return;uu.set(n),i.uniformMatrix2fv(this.addr,!1,uu),Ce(e,n)}}function D2(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Re(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),Ce(e,t)}else{if(Re(e,n))return;hu.set(n),i.uniformMatrix3fv(this.addr,!1,hu),Ce(e,n)}}function P2(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Re(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),Ce(e,t)}else{if(Re(e,n))return;lu.set(n),i.uniformMatrix4fv(this.addr,!1,lu),Ce(e,n)}}function I2(i,t){const e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function L2(i,t){const 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(Re(e,t))return;i.uniform2iv(this.addr,t),Ce(e,t)}}function N2(i,t){const 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(Re(e,t))return;i.uniform3iv(this.addr,t),Ce(e,t)}}function U2(i,t){const 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(Re(e,t))return;i.uniform4iv(this.addr,t),Ce(e,t)}}function F2(i,t){const e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function O2(i,t){const 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(Re(e,t))return;i.uniform2uiv(this.addr,t),Ce(e,t)}}function z2(i,t){const 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(Re(e,t))return;i.uniform3uiv(this.addr,t),Ce(e,t)}}function B2(i,t){const 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(Re(e,t))return;i.uniform4uiv(this.addr,t),Ce(e,t)}}function k2(i,t,e){const 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?(tl.compareFunction=e.isReversedDepthBuffer()?Ol:Fl,r=tl):r=ud,e.setTexture2D(t||r,s)}function G2(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture3D(t||fd,s)}function H2(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTextureCube(t||pd,s)}function V2(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture2DArray(t||dd,s)}function W2(i){switch(i){case 5126:return A2;case 35664:return T2;case 35665:return w2;case 35666:return R2;case 35674:return C2;case 35675:return D2;case 35676:return P2;case 5124:case 35670:return I2;case 35667:case 35671:return L2;case 35668:case 35672:return N2;case 35669:case 35673:return U2;case 5125:return F2;case 36294:return O2;case 36295:return z2;case 36296:return B2;case 35678:case 36198:case 36298:case 36306:case 35682:return k2;case 35679:case 36299:case 36307:return G2;case 35680:case 36300:case 36308:case 36293:return H2;case 36289:case 36303:case 36311:case 36292:return V2}}function X2(i,t){i.uniform1fv(this.addr,t)}function q2(i,t){const e=Hs(t,this.size,2);i.uniform2fv(this.addr,e)}function Y2(i,t){const e=Hs(t,this.size,3);i.uniform3fv(this.addr,e)}function K2(i,t){const e=Hs(t,this.size,4);i.uniform4fv(this.addr,e)}function Z2(i,t){const e=Hs(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function $2(i,t){const e=Hs(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function J2(i,t){const e=Hs(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function Q2(i,t){i.uniform1iv(this.addr,t)}function j2(i,t){i.uniform2iv(this.addr,t)}function t_(i,t){i.uniform3iv(this.addr,t)}function e_(i,t){i.uniform4iv(this.addr,t)}function n_(i,t){i.uniform1uiv(this.addr,t)}function i_(i,t){i.uniform2uiv(this.addr,t)}function s_(i,t){i.uniform3uiv(this.addr,t)}function r_(i,t){i.uniform4uiv(this.addr,t)}function a_(i,t,e){const n=this.cache,s=t.length,r=Za(e,s);Re(n,r)||(i.uniform1iv(this.addr,r),Ce(n,r));let a;this.type===i.SAMPLER_2D_SHADOW?a=tl:a=ud;for(let o=0;o!==s;++o)e.setTexture2D(t[o]||a,r[o])}function o_(i,t,e){const n=this.cache,s=t.length,r=Za(e,s);Re(n,r)||(i.uniform1iv(this.addr,r),Ce(n,r));for(let a=0;a!==s;++a)e.setTexture3D(t[a]||fd,r[a])}function c_(i,t,e){const n=this.cache,s=t.length,r=Za(e,s);Re(n,r)||(i.uniform1iv(this.addr,r),Ce(n,r));for(let a=0;a!==s;++a)e.setTextureCube(t[a]||pd,r[a])}function l_(i,t,e){const n=this.cache,s=t.length,r=Za(e,s);Re(n,r)||(i.uniform1iv(this.addr,r),Ce(n,r));for(let a=0;a!==s;++a)e.setTexture2DArray(t[a]||dd,r[a])}function h_(i){switch(i){case 5126:return X2;case 35664:return q2;case 35665:return Y2;case 35666:return K2;case 35674:return Z2;case 35675:return $2;case 35676:return J2;case 5124:case 35670:return Q2;case 35667:case 35671:return j2;case 35668:case 35672:return t_;case 35669:case 35673:return e_;case 5125:return n_;case 36294:return i_;case 36295:return s_;case 36296:return r_;case 35678:case 36198:case 36298:case 36306:case 35682:return a_;case 35679:case 36299:case 36307:return o_;case 35680:case 36300:case 36308:case 36293:return c_;case 36289:case 36303:case 36311:case 36292:return l_}}class u_{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=W2(e.type)}}class d_{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=h_(e.type)}}class f_{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const s=this.seq;for(let r=0,a=s.length;r!==a;++r){const o=s[r];o.setValue(t,e[o.id],n)}}}const zo=/(\w+)(\])?(\[|\.)?/g;function du(i,t){i.seq.push(t),i.map[t.id]=t}function p_(i,t,e){const n=i.name,s=n.length;for(zo.lastIndex=0;;){const r=zo.exec(n),a=zo.lastIndex;let o=r[1];const c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===s){du(e,l===void 0?new u_(o,i,t):new d_(o,i,t));break}else{let u=e.map[o];u===void 0&&(u=new f_(o),du(e,u)),e=u}}}class Aa{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){const o=t.getActiveUniform(e,a),c=t.getUniformLocation(e,o.name);p_(o,c,this)}const s=[],r=[];for(const a of this.seq)a.type===t.SAMPLER_2D_SHADOW||a.type===t.SAMPLER_CUBE_SHADOW||a.type===t.SAMPLER_2D_ARRAY_SHADOW?s.push(a):r.push(a);s.length>0&&(this.seq=s.concat(r))}setValue(t,e,n,s){const r=this.map[e];r!==void 0&&r.setValue(t,n,s)}setOptional(t,e,n){const 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){const o=e[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(t,c.value,s)}}static seqWithValue(t,e){const n=[];for(let s=0,r=t.length;s!==r;++s){const a=t[s];a.id in e&&n.push(a)}return n}}function fu(i,t,e){const n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}const m_=37297;let g_=0;function __(i,t){const e=i.split(`
4313
+ }`,depthTest:!1,depthWrite:!1}),h=new se(c,l),u=new eo(-1,1,1,-1,0,1);let d=null,f=null,g=!1,x,m=null,p=[],A=!1;this.setSize=function(T,M){a.setSize(T,M),o.setSize(T,M);for(let y=0;y<p.length;y++){const b=p[y];b.setSize&&b.setSize(T,M)}},this.setEffects=function(T){p=T,A=p.length>0&&p[0].isRenderPass===!0;const M=a.width,y=a.height;for(let b=0;b<p.length;b++){const R=p[b];R.setSize&&R.setSize(M,y)}},this.begin=function(T,M){if(g||T.toneMapping===qn&&p.length===0)return!1;if(m=M,M!==null){const y=M.width,b=M.height;(a.width!==y||a.height!==b)&&this.setSize(y,b)}return A===!1&&T.setRenderTarget(a),x=T.toneMapping,T.toneMapping=qn,!0},this.hasRenderPass=function(){return A},this.end=function(T,M){T.toneMapping=x,g=!0;let y=a,b=o;for(let R=0;R<p.length;R++){const v=p[R];if(v.enabled!==!1&&(v.render(T,b,y,M),v.needsSwap!==!1)){const E=y;y=b,b=E}}if(d!==T.outputColorSpace||f!==T.toneMapping){d=T.outputColorSpace,f=T.toneMapping,l.defines={},Kt.getTransfer(d)===te&&(l.defines.SRGB_TRANSFER="");const R=D2[f];R&&(l.defines[R]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=y.texture,T.setRenderTarget(m),T.render(h,u),m=null,g=!1},this.isCompositing=function(){return g},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),c.dispose(),l.dispose()}}const vd=new qe,ol=new Hs(1,1),xd=new nd,Md=new Zp,Sd=new ld,mu=[],gu=[],_u=new Float32Array(16),vu=new Float32Array(9),xu=new Float32Array(4);function Ys(i,t,e){const n=i[0];if(n<=0||n>0)return i;const s=t*e;let r=mu[s];if(r===void 0&&(r=new Float32Array(s),mu[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 Pe(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 Ie(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function io(i,t){let e=gu[t];e===void 0&&(e=new Int32Array(t),gu[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function I2(i,t){const e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function L2(i,t){const 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(Pe(e,t))return;i.uniform2fv(this.addr,t),Ie(e,t)}}function N2(i,t){const 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(Pe(e,t))return;i.uniform3fv(this.addr,t),Ie(e,t)}}function U2(i,t){const 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(Pe(e,t))return;i.uniform4fv(this.addr,t),Ie(e,t)}}function F2(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Pe(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),Ie(e,t)}else{if(Pe(e,n))return;xu.set(n),i.uniformMatrix2fv(this.addr,!1,xu),Ie(e,n)}}function O2(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Pe(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),Ie(e,t)}else{if(Pe(e,n))return;vu.set(n),i.uniformMatrix3fv(this.addr,!1,vu),Ie(e,n)}}function z2(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Pe(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),Ie(e,t)}else{if(Pe(e,n))return;_u.set(n),i.uniformMatrix4fv(this.addr,!1,_u),Ie(e,n)}}function B2(i,t){const e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function k2(i,t){const 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(Pe(e,t))return;i.uniform2iv(this.addr,t),Ie(e,t)}}function G2(i,t){const 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(Pe(e,t))return;i.uniform3iv(this.addr,t),Ie(e,t)}}function H2(i,t){const 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(Pe(e,t))return;i.uniform4iv(this.addr,t),Ie(e,t)}}function V2(i,t){const e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function W2(i,t){const 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(Pe(e,t))return;i.uniform2uiv(this.addr,t),Ie(e,t)}}function X2(i,t){const 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(Pe(e,t))return;i.uniform3uiv(this.addr,t),Ie(e,t)}}function q2(i,t){const 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(Pe(e,t))return;i.uniform4uiv(this.addr,t),Ie(e,t)}}function Y2(i,t,e){const 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?(ol.compareFunction=e.isReversedDepthBuffer()?Wl:Vl,r=ol):r=vd,e.setTexture2D(t||r,s)}function K2(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture3D(t||Md,s)}function Z2(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTextureCube(t||Sd,s)}function $2(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture2DArray(t||xd,s)}function J2(i){switch(i){case 5126:return I2;case 35664:return L2;case 35665:return N2;case 35666:return U2;case 35674:return F2;case 35675:return O2;case 35676:return z2;case 5124:case 35670:return B2;case 35667:case 35671:return k2;case 35668:case 35672:return G2;case 35669:case 35673:return H2;case 5125:return V2;case 36294:return W2;case 36295:return X2;case 36296:return q2;case 35678:case 36198:case 36298:case 36306:case 35682:return Y2;case 35679:case 36299:case 36307:return K2;case 35680:case 36300:case 36308:case 36293:return Z2;case 36289:case 36303:case 36311:case 36292:return $2}}function Q2(i,t){i.uniform1fv(this.addr,t)}function j2(i,t){const e=Ys(t,this.size,2);i.uniform2fv(this.addr,e)}function t_(i,t){const e=Ys(t,this.size,3);i.uniform3fv(this.addr,e)}function e_(i,t){const e=Ys(t,this.size,4);i.uniform4fv(this.addr,e)}function n_(i,t){const e=Ys(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function i_(i,t){const e=Ys(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function s_(i,t){const e=Ys(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function r_(i,t){i.uniform1iv(this.addr,t)}function a_(i,t){i.uniform2iv(this.addr,t)}function o_(i,t){i.uniform3iv(this.addr,t)}function c_(i,t){i.uniform4iv(this.addr,t)}function l_(i,t){i.uniform1uiv(this.addr,t)}function h_(i,t){i.uniform2uiv(this.addr,t)}function u_(i,t){i.uniform3uiv(this.addr,t)}function d_(i,t){i.uniform4uiv(this.addr,t)}function f_(i,t,e){const n=this.cache,s=t.length,r=io(e,s);Pe(n,r)||(i.uniform1iv(this.addr,r),Ie(n,r));let a;this.type===i.SAMPLER_2D_SHADOW?a=ol:a=vd;for(let o=0;o!==s;++o)e.setTexture2D(t[o]||a,r[o])}function p_(i,t,e){const n=this.cache,s=t.length,r=io(e,s);Pe(n,r)||(i.uniform1iv(this.addr,r),Ie(n,r));for(let a=0;a!==s;++a)e.setTexture3D(t[a]||Md,r[a])}function m_(i,t,e){const n=this.cache,s=t.length,r=io(e,s);Pe(n,r)||(i.uniform1iv(this.addr,r),Ie(n,r));for(let a=0;a!==s;++a)e.setTextureCube(t[a]||Sd,r[a])}function g_(i,t,e){const n=this.cache,s=t.length,r=io(e,s);Pe(n,r)||(i.uniform1iv(this.addr,r),Ie(n,r));for(let a=0;a!==s;++a)e.setTexture2DArray(t[a]||xd,r[a])}function __(i){switch(i){case 5126:return Q2;case 35664:return j2;case 35665:return t_;case 35666:return e_;case 35674:return n_;case 35675:return i_;case 35676:return s_;case 5124:case 35670:return r_;case 35667:case 35671:return a_;case 35668:case 35672:return o_;case 35669:case 35673:return c_;case 5125:return l_;case 36294:return h_;case 36295:return u_;case 36296:return d_;case 35678:case 36198:case 36298:case 36306:case 35682:return f_;case 35679:case 36299:case 36307:return p_;case 35680:case 36300:case 36308:case 36293:return m_;case 36289:case 36303:case 36311:case 36292:return g_}}class v_{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=J2(e.type)}}class x_{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=__(e.type)}}class M_{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const s=this.seq;for(let r=0,a=s.length;r!==a;++r){const o=s[r];o.setValue(t,e[o.id],n)}}}const Xo=/(\w+)(\])?(\[|\.)?/g;function Mu(i,t){i.seq.push(t),i.map[t.id]=t}function S_(i,t,e){const n=i.name,s=n.length;for(Xo.lastIndex=0;;){const r=Xo.exec(n),a=Xo.lastIndex;let o=r[1];const c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===s){Mu(e,l===void 0?new v_(o,i,t):new x_(o,i,t));break}else{let u=e.map[o];u===void 0&&(u=new M_(o),Mu(e,u)),e=u}}}class Ia{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){const o=t.getActiveUniform(e,a),c=t.getUniformLocation(e,o.name);S_(o,c,this)}const s=[],r=[];for(const a of this.seq)a.type===t.SAMPLER_2D_SHADOW||a.type===t.SAMPLER_CUBE_SHADOW||a.type===t.SAMPLER_2D_ARRAY_SHADOW?s.push(a):r.push(a);s.length>0&&(this.seq=s.concat(r))}setValue(t,e,n,s){const r=this.map[e];r!==void 0&&r.setValue(t,n,s)}setOptional(t,e,n){const 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){const o=e[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(t,c.value,s)}}static seqWithValue(t,e){const n=[];for(let s=0,r=t.length;s!==r;++s){const a=t[s];a.id in e&&n.push(a)}return n}}function Su(i,t,e){const n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}const y_=37297;let E_=0;function b_(i,t){const e=i.split(`
4314
4314
  `),n=[],s=Math.max(t-6,0),r=Math.min(t+6,e.length);for(let a=s;a<r;a++){const o=a+1;n.push(`${o===t?">":" "} ${o}: ${e[a]}`)}return n.join(`
4315
- `)}const pu=new zt;function v_(i){Kt._getMatrix(pu,Kt.workingColorSpace,i);const t=`mat3( ${pu.elements.map(e=>e.toFixed(4))} )`;switch(Kt.getTransfer(i)){case Pa:return[t,"LinearTransferOETF"];case ee:return[t,"sRGBTransferOETF"];default:return Ot("WebGLProgram: Unsupported color space: ",i),[t,"LinearTransferOETF"]}}function mu(i,t,e){const n=i.getShaderParameter(t,i.COMPILE_STATUS),r=(i.getShaderInfoLog(t)||"").trim();if(n&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return e.toUpperCase()+`
4315
+ `)}const yu=new zt;function A_(i){Kt._getMatrix(yu,Kt.workingColorSpace,i);const t=`mat3( ${yu.elements.map(e=>e.toFixed(4))} )`;switch(Kt.getTransfer(i)){case za:return[t,"LinearTransferOETF"];case te:return[t,"sRGBTransferOETF"];default:return Ot("WebGLProgram: Unsupported color space: ",i),[t,"LinearTransferOETF"]}}function Eu(i,t,e){const n=i.getShaderParameter(t,i.COMPILE_STATUS),r=(i.getShaderInfoLog(t)||"").trim();if(n&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return e.toUpperCase()+`
4316
4316
 
4317
4317
  `+r+`
4318
4318
 
4319
- `+__(i.getShaderSource(t),o)}else return r}function x_(i,t){const e=v_(t);return[`vec4 ${i}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(`
4320
- `)}const M_={[I0]:"Linear",[L0]:"Reinhard",[N0]:"Cineon",[U0]:"ACESFilmic",[O0]:"AgX",[z0]:"Neutral",[F0]:"Custom"};function S_(i,t){const e=M_[t];return e===void 0?(Ot("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}const na=new F;function y_(){Kt.getLuminanceCoefficients(na);const i=na.x.toFixed(4),t=na.y.toFixed(4),e=na.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(`
4321
- `)}function E_(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ar).join(`
4322
- `)}function b_(i){const t=[];for(const e in i){const n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
4323
- `)}function A_(i,t){const e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){const r=i.getActiveAttrib(t,s),a=r.name;let 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 ar(i){return i!==""}function gu(i,t){const 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 _u(i,t){return i.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const T_=/^[ \t]*#include +<([\w\d./]+)>/gm;function el(i){return i.replace(T_,R_)}const w_=new Map;function R_(i,t){let e=Vt[t];if(e===void 0){const n=w_.get(t);if(n!==void 0)e=Vt[n],Ot('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return el(e)}const C_=/#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 vu(i){return i.replace(C_,D_)}function D_(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 xu(i){let t=`precision ${i.precision} float;
4319
+ `+b_(i.getShaderSource(t),o)}else return r}function T_(i,t){const e=A_(t);return[`vec4 ${i}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(`
4320
+ `)}const w_={[k0]:"Linear",[G0]:"Reinhard",[H0]:"Cineon",[V0]:"ACESFilmic",[X0]:"AgX",[q0]:"Neutral",[W0]:"Custom"};function R_(i,t){const e=w_[t];return e===void 0?(Ot("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}const la=new F;function C_(){Kt.getLuminanceCoefficients(la);const i=la.x.toFixed(4),t=la.y.toFixed(4),e=la.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(`
4321
+ `)}function D_(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ur).join(`
4322
+ `)}function P_(i){const t=[];for(const e in i){const n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
4323
+ `)}function I_(i,t){const e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){const r=i.getActiveAttrib(t,s),a=r.name;let 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 ur(i){return i!==""}function bu(i,t){const 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 Au(i,t){return i.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const L_=/^[ \t]*#include +<([\w\d./]+)>/gm;function cl(i){return i.replace(L_,U_)}const N_=new Map;function U_(i,t){let e=Vt[t];if(e===void 0){const n=N_.get(t);if(n!==void 0)e=Vt[n],Ot('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return cl(e)}const F_=/#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 Tu(i){return i.replace(F_,O_)}function O_(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 wu(i){let t=`precision ${i.precision} float;
4324
4324
  precision ${i.precision} int;
4325
4325
  precision ${i.precision} sampler2D;
4326
4326
  precision ${i.precision} samplerCube;
@@ -4340,30 +4340,30 @@ void main() {
4340
4340
  `;return i.precision==="highp"?t+=`
4341
4341
  #define HIGH_PRECISION`:i.precision==="mediump"?t+=`
4342
4342
  #define MEDIUM_PRECISION`:i.precision==="lowp"&&(t+=`
4343
- #define LOW_PRECISION`),t}const P_={[ur]:"SHADOWMAP_TYPE_PCF",[sr]:"SHADOWMAP_TYPE_VSM"};function I_(i){return P_[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const L_={[qi]:"ENVMAP_TYPE_CUBE",[Fs]:"ENVMAP_TYPE_CUBE",[Wa]:"ENVMAP_TYPE_CUBE_UV"};function N_(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":L_[i.envMapMode]||"ENVMAP_TYPE_CUBE"}const U_={[Fs]:"ENVMAP_MODE_REFRACTION"};function F_(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":U_[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}const O_={[Cl]:"ENVMAP_BLENDING_MULTIPLY",[Sp]:"ENVMAP_BLENDING_MIX",[yp]:"ENVMAP_BLENDING_ADD"};function z_(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":O_[i.combine]||"ENVMAP_BLENDING_NONE"}function B_(i){const t=i.envMapCubeUVHeight;if(t===null)return null;const e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:n,maxMip:e}}function k_(i,t,e,n){const s=i.getContext(),r=e.defines;let a=e.vertexShader,o=e.fragmentShader;const c=I_(e),l=N_(e),h=F_(e),u=z_(e),d=B_(e),p=E_(e),g=b_(r),x=s.createProgram();let m,f,A=e.glslVersion?"#version "+e.glslVersion+`
4344
- `:"";e.isRawShaderMaterial?(m=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(ar).join(`
4343
+ #define LOW_PRECISION`),t}const z_={[gr]:"SHADOWMAP_TYPE_PCF",[lr]:"SHADOWMAP_TYPE_VSM"};function B_(i){return z_[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const k_={[Zi]:"ENVMAP_TYPE_CUBE",[Gs]:"ENVMAP_TYPE_CUBE",[Qa]:"ENVMAP_TYPE_CUBE_UV"};function G_(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":k_[i.envMapMode]||"ENVMAP_TYPE_CUBE"}const H_={[Gs]:"ENVMAP_MODE_REFRACTION"};function V_(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":H_[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}const W_={[Fl]:"ENVMAP_BLENDING_MULTIPLY",[Rp]:"ENVMAP_BLENDING_MIX",[Cp]:"ENVMAP_BLENDING_ADD"};function X_(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":W_[i.combine]||"ENVMAP_BLENDING_NONE"}function q_(i){const t=i.envMapCubeUVHeight;if(t===null)return null;const e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:n,maxMip:e}}function Y_(i,t,e,n){const s=i.getContext(),r=e.defines;let a=e.vertexShader,o=e.fragmentShader;const c=B_(e),l=G_(e),h=V_(e),u=X_(e),d=q_(e),f=D_(e),g=P_(r),x=s.createProgram();let m,p,A=e.glslVersion?"#version "+e.glslVersion+`
4344
+ `:"";e.isRawShaderMaterial?(m=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(ur).join(`
4345
4345
  `),m.length>0&&(m+=`
4346
- `),f=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(ar).join(`
4347
- `),f.length>0&&(f+=`
4348
- `)):(m=[xu(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.vertexNormals?"#define HAS_NORMAL":"",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",`
4349
- `].filter(ar).join(`
4350
- `),f=[xu(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 "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.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.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",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?"#define USE_COLOR":"",e.vertexAlphas||e.batchingColor?"#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.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",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!==Gn?"#define TONE_MAPPING":"",e.toneMapping!==Gn?Vt.tonemapping_pars_fragment:"",e.toneMapping!==Gn?S_("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Vt.colorspace_pars_fragment,x_("linearToOutputTexel",e.outputColorSpace),y_(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
4351
- `].filter(ar).join(`
4352
- `)),a=el(a),a=gu(a,e),a=_u(a,e),o=el(o),o=gu(o,e),o=_u(o,e),a=vu(a),o=vu(o),e.isRawShaderMaterial!==!0&&(A=`#version 300 es
4353
- `,m=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
4346
+ `),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(ur).join(`
4347
+ `),p.length>0&&(p+=`
4348
+ `)):(m=[wu(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.vertexNormals?"#define HAS_NORMAL":"",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",`
4349
+ `].filter(ur).join(`
4350
+ `),p=[wu(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 "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.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.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",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?"#define USE_COLOR":"",e.vertexAlphas||e.batchingColor?"#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.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",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!==qn?"#define TONE_MAPPING":"",e.toneMapping!==qn?Vt.tonemapping_pars_fragment:"",e.toneMapping!==qn?R_("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Vt.colorspace_pars_fragment,T_("linearToOutputTexel",e.outputColorSpace),C_(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
4351
+ `].filter(ur).join(`
4352
+ `)),a=cl(a),a=bu(a,e),a=Au(a,e),o=cl(o),o=bu(o,e),o=Au(o,e),a=Tu(a),o=Tu(o),e.isRawShaderMaterial!==!0&&(A=`#version 300 es
4353
+ `,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
4354
4354
  `)+`
4355
- `+m,f=["#define varying in",e.glslVersion===wh?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===wh?"":"#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(`
4355
+ `+m,p=["#define varying in",e.glslVersion===Uh?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Uh?"":"#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(`
4356
4356
  `)+`
4357
- `+f);const T=A+m+a,M=A+f+o,y=fu(s,s.VERTEX_SHADER,T),b=fu(s,s.FRAGMENT_SHADER,M);s.attachShader(x,y),s.attachShader(x,b),e.index0AttributeName!==void 0?s.bindAttribLocation(x,0,e.index0AttributeName):e.hasPositionAttribute===!0&&s.bindAttribLocation(x,0,"position"),s.linkProgram(x);function R(C){if(i.debug.checkShaderErrors){const I=s.getProgramInfoLog(x)||"",W=s.getShaderInfoLog(y)||"",X=s.getShaderInfoLog(b)||"",U=I.trim(),q=W.trim(),H=X.trim();let $=!0,et=!0;if(s.getProgramParameter(x,s.LINK_STATUS)===!1)if($=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,x,y,b);else{const j=mu(s,y,"vertex"),it=mu(s,b,"fragment");Yt("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(x,s.VALIDATE_STATUS)+`
4357
+ `+p);const T=A+m+a,M=A+p+o,y=Su(s,s.VERTEX_SHADER,T),b=Su(s,s.FRAGMENT_SHADER,M);s.attachShader(x,y),s.attachShader(x,b),e.index0AttributeName!==void 0?s.bindAttribLocation(x,0,e.index0AttributeName):e.hasPositionAttribute===!0&&s.bindAttribLocation(x,0,"position"),s.linkProgram(x);function R(C){if(i.debug.checkShaderErrors){const I=s.getProgramInfoLog(x)||"",W=s.getShaderInfoLog(y)||"",X=s.getShaderInfoLog(b)||"",U=I.trim(),q=W.trim(),H=X.trim();let $=!0,et=!0;if(s.getProgramParameter(x,s.LINK_STATUS)===!1)if($=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,x,y,b);else{const j=Eu(s,y,"vertex"),it=Eu(s,b,"fragment");Yt("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(x,s.VALIDATE_STATUS)+`
4358
4358
 
4359
4359
  Material Name: `+C.name+`
4360
4360
  Material Type: `+C.type+`
4361
4361
 
4362
4362
  Program Info Log: `+U+`
4363
4363
  `+j+`
4364
- `+it)}else U!==""?Ot("WebGLProgram: Program Info Log:",U):(q===""||H==="")&&(et=!1);et&&(C.diagnostics={runnable:$,programLog:U,vertexShader:{log:q,prefix:m},fragmentShader:{log:H,prefix:f}})}s.deleteShader(y),s.deleteShader(b),v=new Aa(s,x),E=A_(s,x)}let v;this.getUniforms=function(){return v===void 0&&R(this),v};let E;this.getAttributes=function(){return E===void 0&&R(this),E};let D=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=s.getProgramParameter(x,m_)),D},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(x),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=g_++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=y,this.fragmentShader=b,this}let G_=0;class H_{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,n){const s=this._getShaderCacheForMaterial(t);return s.has(e)===!1&&(s.add(e),e.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderStage(t){return this._getShaderStage(t.vertexShader)}getFragmentShaderStage(t){return this._getShaderStage(t.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new V_(t),e.set(t,n)),n}}class V_{constructor(t){this.id=G_++,this.code=t,this.usedTimes=0}}function W_(i){return i===Yi||i===Ra||i===Ca}function X_(i,t,e,n,s,r){const a=new Bl,o=new H_,c=new Set,l=[],h=new Map,u=n.logarithmicDepthBuffer;let d=n.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(v){return c.add(v),v===0?"uv":`uv${v}`}function x(v,E,D,C,I,W){const X=C.fog,U=I.geometry,q=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?C.environment:null,H=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,$=t.get(v.envMap||q,H),et=$&&$.mapping===Wa?$.image.height:null,j=p[v.type];v.precision!==null&&(d=n.getMaxPrecision(v.precision),d!==v.precision&&Ot("WebGLProgram.getParameters:",v.precision,"not supported, using",d,"instead."));const it=U.morphAttributes.position||U.morphAttributes.normal||U.morphAttributes.color,ut=it!==void 0?it.length:0;let kt=0;U.morphAttributes.position!==void 0&&(kt=1),U.morphAttributes.normal!==void 0&&(kt=2),U.morphAttributes.color!==void 0&&(kt=3);let qt,Bt,Y,rt;if(j){const St=In[j];qt=St.vertexShader,Bt=St.fragmentShader}else{qt=v.vertexShader,Bt=v.fragmentShader;const St=o.getVertexShaderStage(v),_e=o.getFragmentShaderStage(v);o.update(v,St,_e),Y=St.id,rt=_e.id}const nt=i.getRenderTarget(),z=i.state.buffers.depth.getReversed(),bt=I.isInstancedMesh===!0,Dt=I.isBatchedMesh===!0,Tt=!!v.map,vt=!!v.matcap,It=!!$,Lt=!!v.aoMap,Nt=!!v.lightMap,Jt=!!v.bumpMap&&v.wireframe===!1,Qt=!!v.normalMap,me=!!v.displacementMap,fe=!!v.emissiveMap,ge=!!v.metalnessMap,Ee=!!v.roughnessMap,L=v.anisotropy>0,$e=v.clearcoat>0,jt=v.dispersion>0,w=v.iridescence>0,_=v.sheen>0,O=v.transmission>0,G=L&&!!v.anisotropyMap,K=$e&&!!v.clearcoatMap,st=$e&&!!v.clearcoatNormalMap,ot=$e&&!!v.clearcoatRoughnessMap,Z=w&&!!v.iridescenceMap,Q=w&&!!v.iridescenceThicknessMap,ct=_&&!!v.sheenColorMap,wt=_&&!!v.sheenRoughnessMap,dt=!!v.specularMap,lt=!!v.specularColorMap,Pt=!!v.specularIntensityMap,Ut=O&&!!v.transmissionMap,Gt=O&&!!v.thicknessMap,P=!!v.gradientMap,at=!!v.alphaMap,J=v.alphaTest>0,ht=!!v.alphaHash,gt=!!v.extensions;let tt=Gn;v.toneMapped&&(nt===null||nt.isXRRenderTarget===!0)&&(tt=i.toneMapping);const At={shaderID:j,shaderType:v.type,shaderName:v.name,vertexShader:qt,fragmentShader:Bt,defines:v.defines,customVertexShaderID:Y,customFragmentShaderID:rt,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:d,batching:Dt,batchingColor:Dt&&I._colorsTexture!==null,instancing:bt,instancingColor:bt&&I.instanceColor!==null,instancingMorph:bt&&I.morphTexture!==null,outputColorSpace:nt===null?i.outputColorSpace:nt.isXRRenderTarget===!0?nt.texture.colorSpace:Kt.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:Tt,matcap:vt,envMap:It,envMapMode:It&&$.mapping,envMapCubeUVHeight:et,aoMap:Lt,lightMap:Nt,bumpMap:Jt,normalMap:Qt,displacementMap:me,emissiveMap:fe,normalMapObjectSpace:Qt&&v.normalMapType===Ap,normalMapTangentSpace:Qt&&v.normalMapType===Zc,packedNormalMap:Qt&&v.normalMapType===Zc&&W_(v.normalMap.format),metalnessMap:ge,roughnessMap:Ee,anisotropy:L,anisotropyMap:G,clearcoat:$e,clearcoatMap:K,clearcoatNormalMap:st,clearcoatRoughnessMap:ot,dispersion:jt,iridescence:w,iridescenceMap:Z,iridescenceThicknessMap:Q,sheen:_,sheenColorMap:ct,sheenRoughnessMap:wt,specularMap:dt,specularColorMap:lt,specularIntensityMap:Pt,transmission:O,transmissionMap:Ut,thicknessMap:Gt,gradientMap:P,opaque:v.transparent===!1&&v.blending===Cs&&v.alphaToCoverage===!1,alphaMap:at,alphaTest:J,alphaHash:ht,combine:v.combine,mapUv:Tt&&g(v.map.channel),aoMapUv:Lt&&g(v.aoMap.channel),lightMapUv:Nt&&g(v.lightMap.channel),bumpMapUv:Jt&&g(v.bumpMap.channel),normalMapUv:Qt&&g(v.normalMap.channel),displacementMapUv:me&&g(v.displacementMap.channel),emissiveMapUv:fe&&g(v.emissiveMap.channel),metalnessMapUv:ge&&g(v.metalnessMap.channel),roughnessMapUv:Ee&&g(v.roughnessMap.channel),anisotropyMapUv:G&&g(v.anisotropyMap.channel),clearcoatMapUv:K&&g(v.clearcoatMap.channel),clearcoatNormalMapUv:st&&g(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ot&&g(v.clearcoatRoughnessMap.channel),iridescenceMapUv:Z&&g(v.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&g(v.iridescenceThicknessMap.channel),sheenColorMapUv:ct&&g(v.sheenColorMap.channel),sheenRoughnessMapUv:wt&&g(v.sheenRoughnessMap.channel),specularMapUv:dt&&g(v.specularMap.channel),specularColorMapUv:lt&&g(v.specularColorMap.channel),specularIntensityMapUv:Pt&&g(v.specularIntensityMap.channel),transmissionMapUv:Ut&&g(v.transmissionMap.channel),thicknessMapUv:Gt&&g(v.thicknessMap.channel),alphaMapUv:at&&g(v.alphaMap.channel),vertexTangents:!!U.attributes.tangent&&(Qt||L),vertexNormals:!!U.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!U.attributes.color&&U.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!U.attributes.uv&&(Tt||at),fog:!!X,useFog:v.fog===!0,fogExp2:!!X&&X.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||U.attributes.normal===void 0&&Qt===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:z,skinning:I.isSkinnedMesh===!0,hasPositionAttribute:U.attributes.position!==void 0,morphTargets:U.morphAttributes.position!==void 0,morphNormals:U.morphAttributes.normal!==void 0,morphColors:U.morphAttributes.color!==void 0,morphTargetsCount:ut,morphTextureStride:kt,numDirLights:E.directional.length,numPointLights:E.point.length,numSpotLights:E.spot.length,numSpotLightMaps:E.spotLightMap.length,numRectAreaLights:E.rectArea.length,numHemiLights:E.hemi.length,numDirLightShadows:E.directionalShadowMap.length,numPointLightShadows:E.pointShadowMap.length,numSpotLightShadows:E.spotShadowMap.length,numSpotLightShadowsWithMaps:E.numSpotLightShadowsWithMaps,numLightProbes:E.numLightProbes,numLightProbeGrids:W.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:v.dithering,shadowMapEnabled:i.shadowMap.enabled&&D.length>0,shadowMapType:i.shadowMap.type,toneMapping:tt,decodeVideoTexture:Tt&&v.map.isVideoTexture===!0&&Kt.getTransfer(v.map.colorSpace)===ee,decodeVideoTextureEmissive:fe&&v.emissiveMap.isVideoTexture===!0&&Kt.getTransfer(v.emissiveMap.colorSpace)===ee,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===Mn,flipSided:v.side===Fe,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:gt&&v.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(gt&&v.extensions.multiDraw===!0||Dt)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return At.vertexUv1s=c.has(1),At.vertexUv2s=c.has(2),At.vertexUv3s=c.has(3),c.clear(),At}function m(v){const E=[];if(v.shaderID?E.push(v.shaderID):(E.push(v.customVertexShaderID),E.push(v.customFragmentShaderID)),v.defines!==void 0)for(const D in v.defines)E.push(D),E.push(v.defines[D]);return v.isRawShaderMaterial===!1&&(f(E,v),A(E,v),E.push(i.outputColorSpace)),E.push(v.customProgramCacheKey),E.join()}function f(v,E){v.push(E.precision),v.push(E.outputColorSpace),v.push(E.envMapMode),v.push(E.envMapCubeUVHeight),v.push(E.mapUv),v.push(E.alphaMapUv),v.push(E.lightMapUv),v.push(E.aoMapUv),v.push(E.bumpMapUv),v.push(E.normalMapUv),v.push(E.displacementMapUv),v.push(E.emissiveMapUv),v.push(E.metalnessMapUv),v.push(E.roughnessMapUv),v.push(E.anisotropyMapUv),v.push(E.clearcoatMapUv),v.push(E.clearcoatNormalMapUv),v.push(E.clearcoatRoughnessMapUv),v.push(E.iridescenceMapUv),v.push(E.iridescenceThicknessMapUv),v.push(E.sheenColorMapUv),v.push(E.sheenRoughnessMapUv),v.push(E.specularMapUv),v.push(E.specularColorMapUv),v.push(E.specularIntensityMapUv),v.push(E.transmissionMapUv),v.push(E.thicknessMapUv),v.push(E.combine),v.push(E.fogExp2),v.push(E.sizeAttenuation),v.push(E.morphTargetsCount),v.push(E.morphAttributeCount),v.push(E.numDirLights),v.push(E.numPointLights),v.push(E.numSpotLights),v.push(E.numSpotLightMaps),v.push(E.numHemiLights),v.push(E.numRectAreaLights),v.push(E.numDirLightShadows),v.push(E.numPointLightShadows),v.push(E.numSpotLightShadows),v.push(E.numSpotLightShadowsWithMaps),v.push(E.numLightProbes),v.push(E.shadowMapType),v.push(E.toneMapping),v.push(E.numClippingPlanes),v.push(E.numClipIntersection),v.push(E.depthPacking)}function A(v,E){a.disableAll(),E.instancing&&a.enable(0),E.instancingColor&&a.enable(1),E.instancingMorph&&a.enable(2),E.matcap&&a.enable(3),E.envMap&&a.enable(4),E.normalMapObjectSpace&&a.enable(5),E.normalMapTangentSpace&&a.enable(6),E.clearcoat&&a.enable(7),E.iridescence&&a.enable(8),E.alphaTest&&a.enable(9),E.vertexColors&&a.enable(10),E.vertexAlphas&&a.enable(11),E.vertexUv1s&&a.enable(12),E.vertexUv2s&&a.enable(13),E.vertexUv3s&&a.enable(14),E.vertexTangents&&a.enable(15),E.anisotropy&&a.enable(16),E.alphaHash&&a.enable(17),E.batching&&a.enable(18),E.dispersion&&a.enable(19),E.batchingColor&&a.enable(20),E.gradientMap&&a.enable(21),E.packedNormalMap&&a.enable(22),E.vertexNormals&&a.enable(23),v.push(a.mask),a.disableAll(),E.fog&&a.enable(0),E.useFog&&a.enable(1),E.flatShading&&a.enable(2),E.logarithmicDepthBuffer&&a.enable(3),E.reversedDepthBuffer&&a.enable(4),E.skinning&&a.enable(5),E.morphTargets&&a.enable(6),E.morphNormals&&a.enable(7),E.morphColors&&a.enable(8),E.premultipliedAlpha&&a.enable(9),E.shadowMapEnabled&&a.enable(10),E.doubleSided&&a.enable(11),E.flipSided&&a.enable(12),E.useDepthPacking&&a.enable(13),E.dithering&&a.enable(14),E.transmission&&a.enable(15),E.sheen&&a.enable(16),E.opaque&&a.enable(17),E.pointsUvs&&a.enable(18),E.decodeVideoTexture&&a.enable(19),E.decodeVideoTextureEmissive&&a.enable(20),E.alphaToCoverage&&a.enable(21),E.numLightProbeGrids>0&&a.enable(22),E.hasPositionAttribute&&a.enable(23),v.push(a.mask)}function T(v){const E=p[v.type];let D;if(E){const C=In[E];D=hm.clone(C.uniforms)}else D=v.uniforms;return D}function M(v,E){let D=h.get(E);return D!==void 0?++D.usedTimes:(D=new k_(i,E,v,s),l.push(D),h.set(E,D)),D}function y(v){if(--v.usedTimes===0){const E=l.indexOf(v);l[E]=l[l.length-1],l.pop(),h.delete(v.cacheKey),v.destroy()}}function b(v){o.remove(v)}function R(){o.dispose()}return{getParameters:x,getProgramCacheKey:m,getUniforms:T,acquireProgram:M,releaseProgram:y,releaseShaderCache:b,programs:l,dispose:R}}function q_(){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 Y_(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.materialVariant!==t.materialVariant?i.materialVariant-t.materialVariant:i.z!==t.z?i.z-t.z:i.id-t.id}function Mu(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 Su(){const i=[];let t=0;const e=[],n=[],s=[];function r(){t=0,e.length=0,n.length=0,s.length=0}function a(d){let p=0;return d.isInstancedMesh&&(p+=2),d.isSkinnedMesh&&(p+=1),p}function o(d,p,g,x,m,f){let A=i[t];return A===void 0?(A={id:d.id,object:d,geometry:p,material:g,materialVariant:a(d),groupOrder:x,renderOrder:d.renderOrder,z:m,group:f},i[t]=A):(A.id=d.id,A.object=d,A.geometry=p,A.material=g,A.materialVariant=a(d),A.groupOrder=x,A.renderOrder=d.renderOrder,A.z=m,A.group=f),t++,A}function c(d,p,g,x,m,f){const A=o(d,p,g,x,m,f);g.transmission>0?n.push(A):g.transparent===!0?s.push(A):e.push(A)}function l(d,p,g,x,m,f){const A=o(d,p,g,x,m,f);g.transmission>0?n.unshift(A):g.transparent===!0?s.unshift(A):e.unshift(A)}function h(d,p,g){e.length>1&&e.sort(d||Y_),n.length>1&&n.sort(p||Mu),s.length>1&&s.sort(p||Mu),g&&(e.reverse(),n.reverse(),s.reverse())}function u(){for(let d=t,p=i.length;d<p;d++){const g=i[d];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:e,transmissive:n,transparent:s,init:r,push:c,unshift:l,finish:u,sort:h}}function K_(){let i=new WeakMap;function t(n,s){const r=i.get(n);let a;return r===void 0?(a=new Su,i.set(n,[a])):s>=r.length?(a=new Su,r.push(a)):a=r[s],a}function e(){i=new WeakMap}return{get:t,dispose:e}}function Z_(){const 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 F,color:new Mt};break;case"SpotLight":e={position:new F,direction:new F,color:new Mt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new F,color:new Mt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new F,skyColor:new Mt,groundColor:new Mt};break;case"RectAreaLight":e={color:new Mt,position:new F,halfWidth:new F,halfHeight:new F};break}return i[t.id]=e,e}}}function $_(){const 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 Ft};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ft};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ft,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}let J_=0;function Q_(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function j_(i){const t=new Z_,e=$_(),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 F);const s=new F,r=new ue,a=new ue;function o(l){let h=0,u=0,d=0;for(let E=0;E<9;E++)n.probe[E].set(0,0,0);let p=0,g=0,x=0,m=0,f=0,A=0,T=0,M=0,y=0,b=0,R=0;l.sort(Q_);for(let E=0,D=l.length;E<D;E++){const C=l[E],I=C.color,W=C.intensity,X=C.distance;let U=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===Yi?U=C.shadow.map.texture:U=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)h+=I.r*W,u+=I.g*W,d+=I.b*W;else if(C.isLightProbe){for(let q=0;q<9;q++)n.probe[q].addScaledVector(C.sh.coefficients[q],W);R++}else if(C.isDirectionalLight){const q=t.get(C);if(q.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){const H=C.shadow,$=e.get(C);$.shadowIntensity=H.intensity,$.shadowBias=H.bias,$.shadowNormalBias=H.normalBias,$.shadowRadius=H.radius,$.shadowMapSize=H.mapSize,n.directionalShadow[p]=$,n.directionalShadowMap[p]=U,n.directionalShadowMatrix[p]=C.shadow.matrix,A++}n.directional[p]=q,p++}else if(C.isSpotLight){const q=t.get(C);q.position.setFromMatrixPosition(C.matrixWorld),q.color.copy(I).multiplyScalar(W),q.distance=X,q.coneCos=Math.cos(C.angle),q.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),q.decay=C.decay,n.spot[x]=q;const H=C.shadow;if(C.map&&(n.spotLightMap[y]=C.map,y++,H.updateMatrices(C),C.castShadow&&b++),n.spotLightMatrix[x]=H.matrix,C.castShadow){const $=e.get(C);$.shadowIntensity=H.intensity,$.shadowBias=H.bias,$.shadowNormalBias=H.normalBias,$.shadowRadius=H.radius,$.shadowMapSize=H.mapSize,n.spotShadow[x]=$,n.spotShadowMap[x]=U,M++}x++}else if(C.isRectAreaLight){const q=t.get(C);q.color.copy(I).multiplyScalar(W),q.halfWidth.set(C.width*.5,0,0),q.halfHeight.set(0,C.height*.5,0),n.rectArea[m]=q,m++}else if(C.isPointLight){const q=t.get(C);if(q.color.copy(C.color).multiplyScalar(C.intensity),q.distance=C.distance,q.decay=C.decay,C.castShadow){const H=C.shadow,$=e.get(C);$.shadowIntensity=H.intensity,$.shadowBias=H.bias,$.shadowNormalBias=H.normalBias,$.shadowRadius=H.radius,$.shadowMapSize=H.mapSize,$.shadowCameraNear=H.camera.near,$.shadowCameraFar=H.camera.far,n.pointShadow[g]=$,n.pointShadowMap[g]=U,n.pointShadowMatrix[g]=C.shadow.matrix,T++}n.point[g]=q,g++}else if(C.isHemisphereLight){const q=t.get(C);q.skyColor.copy(C.color).multiplyScalar(W),q.groundColor.copy(C.groundColor).multiplyScalar(W),n.hemi[f]=q,f++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ft.LTC_FLOAT_1,n.rectAreaLTC2=ft.LTC_FLOAT_2):(n.rectAreaLTC1=ft.LTC_HALF_1,n.rectAreaLTC2=ft.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const v=n.hash;(v.directionalLength!==p||v.pointLength!==g||v.spotLength!==x||v.rectAreaLength!==m||v.hemiLength!==f||v.numDirectionalShadows!==A||v.numPointShadows!==T||v.numSpotShadows!==M||v.numSpotMaps!==y||v.numLightProbes!==R)&&(n.directional.length=p,n.spot.length=x,n.rectArea.length=m,n.point.length=g,n.hemi.length=f,n.directionalShadow.length=A,n.directionalShadowMap.length=A,n.pointShadow.length=T,n.pointShadowMap.length=T,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=A,n.pointShadowMatrix.length=T,n.spotLightMatrix.length=M+y-b,n.spotLightMap.length=y,n.numSpotLightShadowsWithMaps=b,n.numLightProbes=R,v.directionalLength=p,v.pointLength=g,v.spotLength=x,v.rectAreaLength=m,v.hemiLength=f,v.numDirectionalShadows=A,v.numPointShadows=T,v.numSpotShadows=M,v.numSpotMaps=y,v.numLightProbes=R,n.version=J_++)}function c(l,h){let u=0,d=0,p=0,g=0,x=0;const m=h.matrixWorldInverse;for(let f=0,A=l.length;f<A;f++){const T=l[f];if(T.isDirectionalLight){const M=n.directional[u];M.direction.setFromMatrixPosition(T.matrixWorld),s.setFromMatrixPosition(T.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),u++}else if(T.isSpotLight){const M=n.spot[p];M.position.setFromMatrixPosition(T.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(T.matrixWorld),s.setFromMatrixPosition(T.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),p++}else if(T.isRectAreaLight){const M=n.rectArea[g];M.position.setFromMatrixPosition(T.matrixWorld),M.position.applyMatrix4(m),a.identity(),r.copy(T.matrixWorld),r.premultiply(m),a.extractRotation(r),M.halfWidth.set(T.width*.5,0,0),M.halfHeight.set(0,T.height*.5,0),M.halfWidth.applyMatrix4(a),M.halfHeight.applyMatrix4(a),g++}else if(T.isPointLight){const M=n.point[d];M.position.setFromMatrixPosition(T.matrixWorld),M.position.applyMatrix4(m),d++}else if(T.isHemisphereLight){const M=n.hemi[x];M.direction.setFromMatrixPosition(T.matrixWorld),M.direction.transformDirection(m),x++}}}return{setup:o,setupView:c,state:n}}function yu(i){const t=new j_(i),e=[],n=[],s=[];function r(d){u.camera=d,e.length=0,n.length=0,s.length=0}function a(d){e.push(d)}function o(d){n.push(d)}function c(d){s.push(d)}function l(){t.setup(e)}function h(d){t.setupView(e,d)}const u={lightsArray:e,shadowsArray:n,lightProbeGridArray:s,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:u,setupLights:l,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function tv(i){let t=new WeakMap;function e(s,r=0){const a=t.get(s);let o;return a===void 0?(o=new yu(i),t.set(s,[o])):r>=a.length?(o=new yu(i),a.push(o)):o=a[r],o}function n(){t=new WeakMap}return{get:e,dispose:n}}const ev=`void main() {
4364
+ `+it)}else U!==""?Ot("WebGLProgram: Program Info Log:",U):(q===""||H==="")&&(et=!1);et&&(C.diagnostics={runnable:$,programLog:U,vertexShader:{log:q,prefix:m},fragmentShader:{log:H,prefix:p}})}s.deleteShader(y),s.deleteShader(b),v=new Ia(s,x),E=I_(s,x)}let v;this.getUniforms=function(){return v===void 0&&R(this),v};let E;this.getAttributes=function(){return E===void 0&&R(this),E};let D=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=s.getProgramParameter(x,y_)),D},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(x),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=E_++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=y,this.fragmentShader=b,this}let K_=0;class Z_{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,n){const s=this._getShaderCacheForMaterial(t);return s.has(e)===!1&&(s.add(e),e.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderStage(t){return this._getShaderStage(t.vertexShader)}getFragmentShaderStage(t){return this._getShaderStage(t.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new $_(t),e.set(t,n)),n}}class $_{constructor(t){this.id=K_++,this.code=t,this.usedTimes=0}}function J_(i){return i===$i||i===Ua||i===Fa}function Q_(i,t,e,n,s,r){const a=new ql,o=new Z_,c=new Set,l=[],h=new Map,u=n.logarithmicDepthBuffer;let d=n.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(v){return c.add(v),v===0?"uv":`uv${v}`}function x(v,E,D,C,I,W){const X=C.fog,U=I.geometry,q=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?C.environment:null,H=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,$=t.get(v.envMap||q,H),et=$&&$.mapping===Qa?$.image.height:null,j=f[v.type];v.precision!==null&&(d=n.getMaxPrecision(v.precision),d!==v.precision&&Ot("WebGLProgram.getParameters:",v.precision,"not supported, using",d,"instead."));const it=U.morphAttributes.position||U.morphAttributes.normal||U.morphAttributes.color,ut=it!==void 0?it.length:0;let kt=0;U.morphAttributes.position!==void 0&&(kt=1),U.morphAttributes.normal!==void 0&&(kt=2),U.morphAttributes.color!==void 0&&(kt=3);let qt,Bt,Y,rt;if(j){const St=On[j];qt=St.vertexShader,Bt=St.fragmentShader}else{qt=v.vertexShader,Bt=v.fragmentShader;const St=o.getVertexShaderStage(v),_e=o.getFragmentShaderStage(v);o.update(v,St,_e),Y=St.id,rt=_e.id}const nt=i.getRenderTarget(),z=i.state.buffers.depth.getReversed(),bt=I.isInstancedMesh===!0,Dt=I.isBatchedMesh===!0,Tt=!!v.map,vt=!!v.matcap,It=!!$,Lt=!!v.aoMap,Nt=!!v.lightMap,Jt=!!v.bumpMap&&v.wireframe===!1,Qt=!!v.normalMap,me=!!v.displacementMap,de=!!v.emissiveMap,ge=!!v.metalnessMap,be=!!v.roughnessMap,L=v.anisotropy>0,Je=v.clearcoat>0,jt=v.dispersion>0,w=v.iridescence>0,_=v.sheen>0,O=v.transmission>0,G=L&&!!v.anisotropyMap,K=Je&&!!v.clearcoatMap,st=Je&&!!v.clearcoatNormalMap,ot=Je&&!!v.clearcoatRoughnessMap,Z=w&&!!v.iridescenceMap,Q=w&&!!v.iridescenceThicknessMap,ct=_&&!!v.sheenColorMap,wt=_&&!!v.sheenRoughnessMap,dt=!!v.specularMap,lt=!!v.specularColorMap,Pt=!!v.specularIntensityMap,Ut=O&&!!v.transmissionMap,Gt=O&&!!v.thicknessMap,P=!!v.gradientMap,at=!!v.alphaMap,J=v.alphaTest>0,ht=!!v.alphaHash,gt=!!v.extensions;let tt=qn;v.toneMapped&&(nt===null||nt.isXRRenderTarget===!0)&&(tt=i.toneMapping);const At={shaderID:j,shaderType:v.type,shaderName:v.name,vertexShader:qt,fragmentShader:Bt,defines:v.defines,customVertexShaderID:Y,customFragmentShaderID:rt,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:d,batching:Dt,batchingColor:Dt&&I._colorsTexture!==null,instancing:bt,instancingColor:bt&&I.instanceColor!==null,instancingMorph:bt&&I.morphTexture!==null,outputColorSpace:nt===null?i.outputColorSpace:nt.isXRRenderTarget===!0?nt.texture.colorSpace:Kt.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:Tt,matcap:vt,envMap:It,envMapMode:It&&$.mapping,envMapCubeUVHeight:et,aoMap:Lt,lightMap:Nt,bumpMap:Jt,normalMap:Qt,displacementMap:me,emissiveMap:de,normalMapObjectSpace:Qt&&v.normalMapType===Ip,normalMapTangentSpace:Qt&&v.normalMapType===nl,packedNormalMap:Qt&&v.normalMapType===nl&&J_(v.normalMap.format),metalnessMap:ge,roughnessMap:be,anisotropy:L,anisotropyMap:G,clearcoat:Je,clearcoatMap:K,clearcoatNormalMap:st,clearcoatRoughnessMap:ot,dispersion:jt,iridescence:w,iridescenceMap:Z,iridescenceThicknessMap:Q,sheen:_,sheenColorMap:ct,sheenRoughnessMap:wt,specularMap:dt,specularColorMap:lt,specularIntensityMap:Pt,transmission:O,transmissionMap:Ut,thicknessMap:Gt,gradientMap:P,opaque:v.transparent===!1&&v.blending===Is&&v.alphaToCoverage===!1,alphaMap:at,alphaTest:J,alphaHash:ht,combine:v.combine,mapUv:Tt&&g(v.map.channel),aoMapUv:Lt&&g(v.aoMap.channel),lightMapUv:Nt&&g(v.lightMap.channel),bumpMapUv:Jt&&g(v.bumpMap.channel),normalMapUv:Qt&&g(v.normalMap.channel),displacementMapUv:me&&g(v.displacementMap.channel),emissiveMapUv:de&&g(v.emissiveMap.channel),metalnessMapUv:ge&&g(v.metalnessMap.channel),roughnessMapUv:be&&g(v.roughnessMap.channel),anisotropyMapUv:G&&g(v.anisotropyMap.channel),clearcoatMapUv:K&&g(v.clearcoatMap.channel),clearcoatNormalMapUv:st&&g(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ot&&g(v.clearcoatRoughnessMap.channel),iridescenceMapUv:Z&&g(v.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&g(v.iridescenceThicknessMap.channel),sheenColorMapUv:ct&&g(v.sheenColorMap.channel),sheenRoughnessMapUv:wt&&g(v.sheenRoughnessMap.channel),specularMapUv:dt&&g(v.specularMap.channel),specularColorMapUv:lt&&g(v.specularColorMap.channel),specularIntensityMapUv:Pt&&g(v.specularIntensityMap.channel),transmissionMapUv:Ut&&g(v.transmissionMap.channel),thicknessMapUv:Gt&&g(v.thicknessMap.channel),alphaMapUv:at&&g(v.alphaMap.channel),vertexTangents:!!U.attributes.tangent&&(Qt||L),vertexNormals:!!U.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!U.attributes.color&&U.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!U.attributes.uv&&(Tt||at),fog:!!X,useFog:v.fog===!0,fogExp2:!!X&&X.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||U.attributes.normal===void 0&&Qt===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:z,skinning:I.isSkinnedMesh===!0,hasPositionAttribute:U.attributes.position!==void 0,morphTargets:U.morphAttributes.position!==void 0,morphNormals:U.morphAttributes.normal!==void 0,morphColors:U.morphAttributes.color!==void 0,morphTargetsCount:ut,morphTextureStride:kt,numDirLights:E.directional.length,numPointLights:E.point.length,numSpotLights:E.spot.length,numSpotLightMaps:E.spotLightMap.length,numRectAreaLights:E.rectArea.length,numHemiLights:E.hemi.length,numDirLightShadows:E.directionalShadowMap.length,numPointLightShadows:E.pointShadowMap.length,numSpotLightShadows:E.spotShadowMap.length,numSpotLightShadowsWithMaps:E.numSpotLightShadowsWithMaps,numLightProbes:E.numLightProbes,numLightProbeGrids:W.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:v.dithering,shadowMapEnabled:i.shadowMap.enabled&&D.length>0,shadowMapType:i.shadowMap.type,toneMapping:tt,decodeVideoTexture:Tt&&v.map.isVideoTexture===!0&&Kt.getTransfer(v.map.colorSpace)===te,decodeVideoTextureEmissive:de&&v.emissiveMap.isVideoTexture===!0&&Kt.getTransfer(v.emissiveMap.colorSpace)===te,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===An,flipSided:v.side===Ce,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:gt&&v.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(gt&&v.extensions.multiDraw===!0||Dt)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return At.vertexUv1s=c.has(1),At.vertexUv2s=c.has(2),At.vertexUv3s=c.has(3),c.clear(),At}function m(v){const E=[];if(v.shaderID?E.push(v.shaderID):(E.push(v.customVertexShaderID),E.push(v.customFragmentShaderID)),v.defines!==void 0)for(const D in v.defines)E.push(D),E.push(v.defines[D]);return v.isRawShaderMaterial===!1&&(p(E,v),A(E,v),E.push(i.outputColorSpace)),E.push(v.customProgramCacheKey),E.join()}function p(v,E){v.push(E.precision),v.push(E.outputColorSpace),v.push(E.envMapMode),v.push(E.envMapCubeUVHeight),v.push(E.mapUv),v.push(E.alphaMapUv),v.push(E.lightMapUv),v.push(E.aoMapUv),v.push(E.bumpMapUv),v.push(E.normalMapUv),v.push(E.displacementMapUv),v.push(E.emissiveMapUv),v.push(E.metalnessMapUv),v.push(E.roughnessMapUv),v.push(E.anisotropyMapUv),v.push(E.clearcoatMapUv),v.push(E.clearcoatNormalMapUv),v.push(E.clearcoatRoughnessMapUv),v.push(E.iridescenceMapUv),v.push(E.iridescenceThicknessMapUv),v.push(E.sheenColorMapUv),v.push(E.sheenRoughnessMapUv),v.push(E.specularMapUv),v.push(E.specularColorMapUv),v.push(E.specularIntensityMapUv),v.push(E.transmissionMapUv),v.push(E.thicknessMapUv),v.push(E.combine),v.push(E.fogExp2),v.push(E.sizeAttenuation),v.push(E.morphTargetsCount),v.push(E.morphAttributeCount),v.push(E.numDirLights),v.push(E.numPointLights),v.push(E.numSpotLights),v.push(E.numSpotLightMaps),v.push(E.numHemiLights),v.push(E.numRectAreaLights),v.push(E.numDirLightShadows),v.push(E.numPointLightShadows),v.push(E.numSpotLightShadows),v.push(E.numSpotLightShadowsWithMaps),v.push(E.numLightProbes),v.push(E.shadowMapType),v.push(E.toneMapping),v.push(E.numClippingPlanes),v.push(E.numClipIntersection),v.push(E.depthPacking)}function A(v,E){a.disableAll(),E.instancing&&a.enable(0),E.instancingColor&&a.enable(1),E.instancingMorph&&a.enable(2),E.matcap&&a.enable(3),E.envMap&&a.enable(4),E.normalMapObjectSpace&&a.enable(5),E.normalMapTangentSpace&&a.enable(6),E.clearcoat&&a.enable(7),E.iridescence&&a.enable(8),E.alphaTest&&a.enable(9),E.vertexColors&&a.enable(10),E.vertexAlphas&&a.enable(11),E.vertexUv1s&&a.enable(12),E.vertexUv2s&&a.enable(13),E.vertexUv3s&&a.enable(14),E.vertexTangents&&a.enable(15),E.anisotropy&&a.enable(16),E.alphaHash&&a.enable(17),E.batching&&a.enable(18),E.dispersion&&a.enable(19),E.batchingColor&&a.enable(20),E.gradientMap&&a.enable(21),E.packedNormalMap&&a.enable(22),E.vertexNormals&&a.enable(23),v.push(a.mask),a.disableAll(),E.fog&&a.enable(0),E.useFog&&a.enable(1),E.flatShading&&a.enable(2),E.logarithmicDepthBuffer&&a.enable(3),E.reversedDepthBuffer&&a.enable(4),E.skinning&&a.enable(5),E.morphTargets&&a.enable(6),E.morphNormals&&a.enable(7),E.morphColors&&a.enable(8),E.premultipliedAlpha&&a.enable(9),E.shadowMapEnabled&&a.enable(10),E.doubleSided&&a.enable(11),E.flipSided&&a.enable(12),E.useDepthPacking&&a.enable(13),E.dithering&&a.enable(14),E.transmission&&a.enable(15),E.sheen&&a.enable(16),E.opaque&&a.enable(17),E.pointsUvs&&a.enable(18),E.decodeVideoTexture&&a.enable(19),E.decodeVideoTextureEmissive&&a.enable(20),E.alphaToCoverage&&a.enable(21),E.numLightProbeGrids>0&&a.enable(22),E.hasPositionAttribute&&a.enable(23),v.push(a.mask)}function T(v){const E=f[v.type];let D;if(E){const C=On[E];D=_m.clone(C.uniforms)}else D=v.uniforms;return D}function M(v,E){let D=h.get(E);return D!==void 0?++D.usedTimes:(D=new Y_(i,E,v,s),l.push(D),h.set(E,D)),D}function y(v){if(--v.usedTimes===0){const E=l.indexOf(v);l[E]=l[l.length-1],l.pop(),h.delete(v.cacheKey),v.destroy()}}function b(v){o.remove(v)}function R(){o.dispose()}return{getParameters:x,getProgramCacheKey:m,getUniforms:T,acquireProgram:M,releaseProgram:y,releaseShaderCache:b,programs:l,dispose:R}}function j_(){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 tv(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.materialVariant!==t.materialVariant?i.materialVariant-t.materialVariant:i.z!==t.z?i.z-t.z:i.id-t.id}function Ru(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 Cu(){const i=[];let t=0;const e=[],n=[],s=[];function r(){t=0,e.length=0,n.length=0,s.length=0}function a(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function o(d,f,g,x,m,p){let A=i[t];return A===void 0?(A={id:d.id,object:d,geometry:f,material:g,materialVariant:a(d),groupOrder:x,renderOrder:d.renderOrder,z:m,group:p},i[t]=A):(A.id=d.id,A.object=d,A.geometry=f,A.material=g,A.materialVariant=a(d),A.groupOrder=x,A.renderOrder=d.renderOrder,A.z=m,A.group=p),t++,A}function c(d,f,g,x,m,p){const A=o(d,f,g,x,m,p);g.transmission>0?n.push(A):g.transparent===!0?s.push(A):e.push(A)}function l(d,f,g,x,m,p){const A=o(d,f,g,x,m,p);g.transmission>0?n.unshift(A):g.transparent===!0?s.unshift(A):e.unshift(A)}function h(d,f,g){e.length>1&&e.sort(d||tv),n.length>1&&n.sort(f||Ru),s.length>1&&s.sort(f||Ru),g&&(e.reverse(),n.reverse(),s.reverse())}function u(){for(let d=t,f=i.length;d<f;d++){const g=i[d];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:e,transmissive:n,transparent:s,init:r,push:c,unshift:l,finish:u,sort:h}}function ev(){let i=new WeakMap;function t(n,s){const r=i.get(n);let a;return r===void 0?(a=new Cu,i.set(n,[a])):s>=r.length?(a=new Cu,r.push(a)):a=r[s],a}function e(){i=new WeakMap}return{get:t,dispose:e}}function nv(){const 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 F,color:new Mt};break;case"SpotLight":e={position:new F,direction:new F,color:new Mt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new F,color:new Mt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new F,skyColor:new Mt,groundColor:new Mt};break;case"RectAreaLight":e={color:new Mt,position:new F,halfWidth:new F,halfHeight:new F};break}return i[t.id]=e,e}}}function iv(){const 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 Ft};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ft};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ft,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}let sv=0;function rv(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function av(i){const t=new nv,e=iv(),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 F);const s=new F,r=new he,a=new he;function o(l){let h=0,u=0,d=0;for(let E=0;E<9;E++)n.probe[E].set(0,0,0);let f=0,g=0,x=0,m=0,p=0,A=0,T=0,M=0,y=0,b=0,R=0;l.sort(rv);for(let E=0,D=l.length;E<D;E++){const C=l[E],I=C.color,W=C.intensity,X=C.distance;let U=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===$i?U=C.shadow.map.texture:U=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)h+=I.r*W,u+=I.g*W,d+=I.b*W;else if(C.isLightProbe){for(let q=0;q<9;q++)n.probe[q].addScaledVector(C.sh.coefficients[q],W);R++}else if(C.isDirectionalLight){const q=t.get(C);if(q.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){const H=C.shadow,$=e.get(C);$.shadowIntensity=H.intensity,$.shadowBias=H.bias,$.shadowNormalBias=H.normalBias,$.shadowRadius=H.radius,$.shadowMapSize=H.mapSize,n.directionalShadow[f]=$,n.directionalShadowMap[f]=U,n.directionalShadowMatrix[f]=C.shadow.matrix,A++}n.directional[f]=q,f++}else if(C.isSpotLight){const q=t.get(C);q.position.setFromMatrixPosition(C.matrixWorld),q.color.copy(I).multiplyScalar(W),q.distance=X,q.coneCos=Math.cos(C.angle),q.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),q.decay=C.decay,n.spot[x]=q;const H=C.shadow;if(C.map&&(n.spotLightMap[y]=C.map,y++,H.updateMatrices(C),C.castShadow&&b++),n.spotLightMatrix[x]=H.matrix,C.castShadow){const $=e.get(C);$.shadowIntensity=H.intensity,$.shadowBias=H.bias,$.shadowNormalBias=H.normalBias,$.shadowRadius=H.radius,$.shadowMapSize=H.mapSize,n.spotShadow[x]=$,n.spotShadowMap[x]=U,M++}x++}else if(C.isRectAreaLight){const q=t.get(C);q.color.copy(I).multiplyScalar(W),q.halfWidth.set(C.width*.5,0,0),q.halfHeight.set(0,C.height*.5,0),n.rectArea[m]=q,m++}else if(C.isPointLight){const q=t.get(C);if(q.color.copy(C.color).multiplyScalar(C.intensity),q.distance=C.distance,q.decay=C.decay,C.castShadow){const H=C.shadow,$=e.get(C);$.shadowIntensity=H.intensity,$.shadowBias=H.bias,$.shadowNormalBias=H.normalBias,$.shadowRadius=H.radius,$.shadowMapSize=H.mapSize,$.shadowCameraNear=H.camera.near,$.shadowCameraFar=H.camera.far,n.pointShadow[g]=$,n.pointShadowMap[g]=U,n.pointShadowMatrix[g]=C.shadow.matrix,T++}n.point[g]=q,g++}else if(C.isHemisphereLight){const q=t.get(C);q.skyColor.copy(C.color).multiplyScalar(W),q.groundColor.copy(C.groundColor).multiplyScalar(W),n.hemi[p]=q,p++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ft.LTC_FLOAT_1,n.rectAreaLTC2=ft.LTC_FLOAT_2):(n.rectAreaLTC1=ft.LTC_HALF_1,n.rectAreaLTC2=ft.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const v=n.hash;(v.directionalLength!==f||v.pointLength!==g||v.spotLength!==x||v.rectAreaLength!==m||v.hemiLength!==p||v.numDirectionalShadows!==A||v.numPointShadows!==T||v.numSpotShadows!==M||v.numSpotMaps!==y||v.numLightProbes!==R)&&(n.directional.length=f,n.spot.length=x,n.rectArea.length=m,n.point.length=g,n.hemi.length=p,n.directionalShadow.length=A,n.directionalShadowMap.length=A,n.pointShadow.length=T,n.pointShadowMap.length=T,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=A,n.pointShadowMatrix.length=T,n.spotLightMatrix.length=M+y-b,n.spotLightMap.length=y,n.numSpotLightShadowsWithMaps=b,n.numLightProbes=R,v.directionalLength=f,v.pointLength=g,v.spotLength=x,v.rectAreaLength=m,v.hemiLength=p,v.numDirectionalShadows=A,v.numPointShadows=T,v.numSpotShadows=M,v.numSpotMaps=y,v.numLightProbes=R,n.version=sv++)}function c(l,h){let u=0,d=0,f=0,g=0,x=0;const m=h.matrixWorldInverse;for(let p=0,A=l.length;p<A;p++){const T=l[p];if(T.isDirectionalLight){const M=n.directional[u];M.direction.setFromMatrixPosition(T.matrixWorld),s.setFromMatrixPosition(T.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),u++}else if(T.isSpotLight){const M=n.spot[f];M.position.setFromMatrixPosition(T.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(T.matrixWorld),s.setFromMatrixPosition(T.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),f++}else if(T.isRectAreaLight){const M=n.rectArea[g];M.position.setFromMatrixPosition(T.matrixWorld),M.position.applyMatrix4(m),a.identity(),r.copy(T.matrixWorld),r.premultiply(m),a.extractRotation(r),M.halfWidth.set(T.width*.5,0,0),M.halfHeight.set(0,T.height*.5,0),M.halfWidth.applyMatrix4(a),M.halfHeight.applyMatrix4(a),g++}else if(T.isPointLight){const M=n.point[d];M.position.setFromMatrixPosition(T.matrixWorld),M.position.applyMatrix4(m),d++}else if(T.isHemisphereLight){const M=n.hemi[x];M.direction.setFromMatrixPosition(T.matrixWorld),M.direction.transformDirection(m),x++}}}return{setup:o,setupView:c,state:n}}function Du(i){const t=new av(i),e=[],n=[],s=[];function r(d){u.camera=d,e.length=0,n.length=0,s.length=0}function a(d){e.push(d)}function o(d){n.push(d)}function c(d){s.push(d)}function l(){t.setup(e)}function h(d){t.setupView(e,d)}const u={lightsArray:e,shadowsArray:n,lightProbeGridArray:s,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:u,setupLights:l,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function ov(i){let t=new WeakMap;function e(s,r=0){const a=t.get(s);let o;return a===void 0?(o=new Du(i),t.set(s,[o])):r>=a.length?(o=new Du(i),a.push(o)):o=a[r],o}function n(){t=new WeakMap}return{get:e,dispose:n}}const cv=`void main() {
4365
4365
  gl_Position = vec4( position, 1.0 );
4366
- }`,nv=`uniform sampler2D shadow_pass;
4366
+ }`,lv=`uniform sampler2D shadow_pass;
4367
4367
  uniform vec2 resolution;
4368
4368
  uniform float radius;
4369
4369
  void main() {
@@ -4388,12 +4388,12 @@ void main() {
4388
4388
  squared_mean = squared_mean / samples;
4389
4389
  float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
4390
4390
  gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
4391
- }`,iv=[new F(1,0,0),new F(-1,0,0),new F(0,1,0),new F(0,-1,0),new F(0,0,1),new F(0,0,-1)],sv=[new F(0,-1,0),new F(0,-1,0),new F(0,0,1),new F(0,0,-1),new F(0,-1,0),new F(0,-1,0)],Eu=new ue,js=new F,Bo=new F;function rv(i,t,e){let n=new Hl;const s=new Ft,r=new Ft,a=new pe,o=new pm,c=new mm,l={},h=e.maxTextureSize,u={[Ei]:Fe,[Fe]:Ei,[Mn]:Mn},d=new Be({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ft},radius:{value:4}},vertexShader:ev,fragmentShader:nv}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const g=new ye;g.setAttribute("position",new he(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new oe(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ur;let f=this.type;this.render=function(b,R,v){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;this.type===np&&(Ot("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=ur);const E=i.getRenderTarget(),D=i.getActiveCubeFace(),C=i.getActiveMipmapLevel(),I=i.state;I.setBlending(ti),I.buffers.depth.getReversed()===!0?I.buffers.color.setClear(0,0,0,0):I.buffers.color.setClear(1,1,1,1),I.buffers.depth.setTest(!0),I.setScissorTest(!1);const W=f!==this.type;W&&R.traverse(function(X){X.material&&(Array.isArray(X.material)?X.material.forEach(U=>U.needsUpdate=!0):X.material.needsUpdate=!0)});for(let X=0,U=b.length;X<U;X++){const q=b[X],H=q.shadow;if(H===void 0){Ot("WebGLShadowMap:",q,"has no shadow.");continue}if(H.autoUpdate===!1&&H.needsUpdate===!1)continue;s.copy(H.mapSize);const $=H.getFrameExtents();s.multiply($),r.copy(H.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/$.x),s.x=r.x*$.x,H.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/$.y),s.y=r.y*$.y,H.mapSize.y=r.y));const et=i.state.buffers.depth.getReversed();if(H.camera._reversedDepth=et,H.map===null||W===!0){if(H.map!==null&&(H.map.depthTexture!==null&&(H.map.depthTexture.dispose(),H.map.depthTexture=null),H.map.dispose()),this.type===sr){if(q.isPointLight){Ot("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}H.map=new En(s.x,s.y,{format:Yi,type:bn,minFilter:Ne,magFilter:Ne,generateMipmaps:!1}),H.map.texture.name=q.name+".shadowMap",H.map.depthTexture=new Os(s.x,s.y,zn),H.map.depthTexture.name=q.name+".shadowMapDepth",H.map.depthTexture.format=ni,H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=ze,H.map.depthTexture.magFilter=ze}else q.isPointLight?(H.map=new hd(s.x),H.map.depthTexture=new cm(s.x,Vn)):(H.map=new En(s.x,s.y),H.map.depthTexture=new Os(s.x,s.y,Vn)),H.map.depthTexture.name=q.name+".shadowMap",H.map.depthTexture.format=ni,this.type===ur?(H.map.depthTexture.compareFunction=et?Ol:Fl,H.map.depthTexture.minFilter=Ne,H.map.depthTexture.magFilter=Ne):(H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=ze,H.map.depthTexture.magFilter=ze);H.camera.updateProjectionMatrix()}const j=H.map.isWebGLCubeRenderTarget?6:1;for(let it=0;it<j;it++){if(H.map.isWebGLCubeRenderTarget)i.setRenderTarget(H.map,it),i.clear();else{it===0&&(i.setRenderTarget(H.map),i.clear());const ut=H.getViewport(it);a.set(r.x*ut.x,r.y*ut.y,r.x*ut.z,r.y*ut.w),I.viewport(a)}if(q.isPointLight){const ut=H.camera,kt=H.matrix,qt=q.distance||ut.far;qt!==ut.far&&(ut.far=qt,ut.updateProjectionMatrix()),js.setFromMatrixPosition(q.matrixWorld),ut.position.copy(js),Bo.copy(ut.position),Bo.add(iv[it]),ut.up.copy(sv[it]),ut.lookAt(Bo),ut.updateMatrixWorld(),kt.makeTranslation(-js.x,-js.y,-js.z),Eu.multiplyMatrices(ut.projectionMatrix,ut.matrixWorldInverse),H._frustum.setFromProjectionMatrix(Eu,ut.coordinateSystem,ut.reversedDepth)}else H.updateMatrices(q);n=H.getFrustum(),M(R,v,H.camera,q,this.type)}H.isPointLightShadow!==!0&&this.type===sr&&A(H,v),H.needsUpdate=!1}f=this.type,m.needsUpdate=!1,i.setRenderTarget(E,D,C)};function A(b,R){const v=t.update(x);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,p.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new En(s.x,s.y,{format:Yi,type:bn})),d.uniforms.shadow_pass.value=b.map.depthTexture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,i.setRenderTarget(b.mapPass),i.clear(),i.renderBufferDirect(R,null,v,d,x,null),p.uniforms.shadow_pass.value=b.mapPass.texture,p.uniforms.resolution.value=b.mapSize,p.uniforms.radius.value=b.radius,i.setRenderTarget(b.map),i.clear(),i.renderBufferDirect(R,null,v,p,x,null)}function T(b,R,v,E){let D=null;const C=v.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0)D=C;else if(D=v.isPointLight===!0?c:o,i.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){const I=D.uuid,W=R.uuid;let X=l[I];X===void 0&&(X={},l[I]=X);let U=X[W];U===void 0&&(U=D.clone(),X[W]=U,R.addEventListener("dispose",y)),D=U}if(D.visible=R.visible,D.wireframe=R.wireframe,E===sr?D.side=R.shadowSide!==null?R.shadowSide:R.side:D.side=R.shadowSide!==null?R.shadowSide:u[R.side],D.alphaMap=R.alphaMap,D.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,D.map=R.map,D.clipShadows=R.clipShadows,D.clippingPlanes=R.clippingPlanes,D.clipIntersection=R.clipIntersection,D.displacementMap=R.displacementMap,D.displacementScale=R.displacementScale,D.displacementBias=R.displacementBias,D.wireframeLinewidth=R.wireframeLinewidth,D.linewidth=R.linewidth,v.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const I=i.properties.get(D);I.light=v}return D}function M(b,R,v,E,D){if(b.visible===!1)return;if(b.layers.test(R.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&D===sr)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,b.matrixWorld);const W=t.update(b),X=b.material;if(Array.isArray(X)){const U=W.groups;for(let q=0,H=U.length;q<H;q++){const $=U[q],et=X[$.materialIndex];if(et&&et.visible){const j=T(b,et,E,D);b.onBeforeShadow(i,b,R,v,W,j,$),i.renderBufferDirect(v,null,W,j,b,$),b.onAfterShadow(i,b,R,v,W,j,$)}}}else if(X.visible){const U=T(b,X,E,D);b.onBeforeShadow(i,b,R,v,W,U,null),i.renderBufferDirect(v,null,W,U,b,null),b.onAfterShadow(i,b,R,v,W,U,null)}}const I=b.children;for(let W=0,X=I.length;W<X;W++)M(I[W],R,v,E,D)}function y(b){b.target.removeEventListener("dispose",y);for(const v in l){const E=l[v],D=b.target.uuid;D in E&&(E[D].dispose(),delete E[D])}}}function av(i,t){function e(){let P=!1;const at=new pe;let J=null;const ht=new pe(0,0,0,0);return{setMask:function(gt){J!==gt&&!P&&(i.colorMask(gt,gt,gt,gt),J=gt)},setLocked:function(gt){P=gt},setClear:function(gt,tt,At,St,_e){_e===!0&&(gt*=St,tt*=St,At*=St),at.set(gt,tt,At,St),ht.equals(at)===!1&&(i.clearColor(gt,tt,At,St),ht.copy(at))},reset:function(){P=!1,J=null,ht.set(-1,0,0,0)}}}function n(){let P=!1,at=!1,J=null,ht=null,gt=null;return{setReversed:function(tt){if(at!==tt){const At=t.get("EXT_clip_control");tt?At.clipControlEXT(At.LOWER_LEFT_EXT,At.ZERO_TO_ONE_EXT):At.clipControlEXT(At.LOWER_LEFT_EXT,At.NEGATIVE_ONE_TO_ONE_EXT),at=tt;const St=gt;gt=null,this.setClear(St)}},getReversed:function(){return at},setTest:function(tt){tt?nt(i.DEPTH_TEST):z(i.DEPTH_TEST)},setMask:function(tt){J!==tt&&!P&&(i.depthMask(tt),J=tt)},setFunc:function(tt){if(at&&(tt=Up[tt]),ht!==tt){switch(tt){case hc:i.depthFunc(i.NEVER);break;case uc:i.depthFunc(i.ALWAYS);break;case dc:i.depthFunc(i.LESS);break;case Us:i.depthFunc(i.LEQUAL);break;case fc:i.depthFunc(i.EQUAL);break;case pc:i.depthFunc(i.GEQUAL);break;case mc:i.depthFunc(i.GREATER);break;case gc:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}ht=tt}},setLocked:function(tt){P=tt},setClear:function(tt){gt!==tt&&(gt=tt,at&&(tt=1-tt),i.clearDepth(tt))},reset:function(){P=!1,J=null,ht=null,gt=null,at=!1}}}function s(){let P=!1,at=null,J=null,ht=null,gt=null,tt=null,At=null,St=null,_e=null;return{setTest:function(ce){P||(ce?nt(i.STENCIL_TEST):z(i.STENCIL_TEST))},setMask:function(ce){at!==ce&&!P&&(i.stencilMask(ce),at=ce)},setFunc:function(ce,An,Tn){(J!==ce||ht!==An||gt!==Tn)&&(i.stencilFunc(ce,An,Tn),J=ce,ht=An,gt=Tn)},setOp:function(ce,An,Tn){(tt!==ce||At!==An||St!==Tn)&&(i.stencilOp(ce,An,Tn),tt=ce,At=An,St=Tn)},setLocked:function(ce){P=ce},setClear:function(ce){_e!==ce&&(i.clearStencil(ce),_e=ce)},reset:function(){P=!1,at=null,J=null,ht=null,gt=null,tt=null,At=null,St=null,_e=null}}}const r=new e,a=new n,o=new s,c=new WeakMap,l=new WeakMap;let h={},u={},d={},p=new WeakMap,g=[],x=null,m=!1,f=null,A=null,T=null,M=null,y=null,b=null,R=null,v=new Mt(0,0,0),E=0,D=!1,C=null,I=null,W=null,X=null,U=null;const q=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let H=!1,$=0;const et=i.getParameter(i.VERSION);et.indexOf("WebGL")!==-1?($=parseFloat(/^WebGL (\d)/.exec(et)[1]),H=$>=1):et.indexOf("OpenGL ES")!==-1&&($=parseFloat(/^OpenGL ES (\d)/.exec(et)[1]),H=$>=2);let j=null,it={};const ut=i.getParameter(i.SCISSOR_BOX),kt=i.getParameter(i.VIEWPORT),qt=new pe().fromArray(ut),Bt=new pe().fromArray(kt);function Y(P,at,J,ht){const gt=new Uint8Array(4),tt=i.createTexture();i.bindTexture(P,tt),i.texParameteri(P,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(P,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let At=0;At<J;At++)P===i.TEXTURE_3D||P===i.TEXTURE_2D_ARRAY?i.texImage3D(at,0,i.RGBA,1,1,ht,0,i.RGBA,i.UNSIGNED_BYTE,gt):i.texImage2D(at+At,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,gt);return tt}const rt={};rt[i.TEXTURE_2D]=Y(i.TEXTURE_2D,i.TEXTURE_2D,1),rt[i.TEXTURE_CUBE_MAP]=Y(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),rt[i.TEXTURE_2D_ARRAY]=Y(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),rt[i.TEXTURE_3D]=Y(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),nt(i.DEPTH_TEST),a.setFunc(Us),Jt(!1),Qt(Eh),nt(i.CULL_FACE),Lt(ti);function nt(P){h[P]!==!0&&(i.enable(P),h[P]=!0)}function z(P){h[P]!==!1&&(i.disable(P),h[P]=!1)}function bt(P,at){return d[P]!==at?(i.bindFramebuffer(P,at),d[P]=at,P===i.DRAW_FRAMEBUFFER&&(d[i.FRAMEBUFFER]=at),P===i.FRAMEBUFFER&&(d[i.DRAW_FRAMEBUFFER]=at),!0):!1}function Dt(P,at){let J=g,ht=!1;if(P){J=p.get(at),J===void 0&&(J=[],p.set(at,J));const gt=P.textures;if(J.length!==gt.length||J[0]!==i.COLOR_ATTACHMENT0){for(let tt=0,At=gt.length;tt<At;tt++)J[tt]=i.COLOR_ATTACHMENT0+tt;J.length=gt.length,ht=!0}}else J[0]!==i.BACK&&(J[0]=i.BACK,ht=!0);ht&&i.drawBuffers(J)}function Tt(P){return x!==P?(i.useProgram(P),x=P,!0):!1}const vt={[Fi]:i.FUNC_ADD,[sp]:i.FUNC_SUBTRACT,[rp]:i.FUNC_REVERSE_SUBTRACT};vt[ap]=i.MIN,vt[op]=i.MAX;const It={[cp]:i.ZERO,[lp]:i.ONE,[hp]:i.SRC_COLOR,[cc]:i.SRC_ALPHA,[gp]:i.SRC_ALPHA_SATURATE,[pp]:i.DST_COLOR,[dp]:i.DST_ALPHA,[up]:i.ONE_MINUS_SRC_COLOR,[lc]:i.ONE_MINUS_SRC_ALPHA,[mp]:i.ONE_MINUS_DST_COLOR,[fp]:i.ONE_MINUS_DST_ALPHA,[_p]:i.CONSTANT_COLOR,[vp]:i.ONE_MINUS_CONSTANT_COLOR,[xp]:i.CONSTANT_ALPHA,[Mp]:i.ONE_MINUS_CONSTANT_ALPHA};function Lt(P,at,J,ht,gt,tt,At,St,_e,ce){if(P===ti){m===!0&&(z(i.BLEND),m=!1);return}if(m===!1&&(nt(i.BLEND),m=!0),P!==ip){if(P!==f||ce!==D){if((A!==Fi||y!==Fi)&&(i.blendEquation(i.FUNC_ADD),A=Fi,y=Fi),ce)switch(P){case Cs:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Xi:i.blendFunc(i.ONE,i.ONE);break;case bh:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Ah:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Yt("WebGLState: Invalid blending: ",P);break}else switch(P){case Cs:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Xi:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case bh:Yt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Ah:Yt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Yt("WebGLState: Invalid blending: ",P);break}T=null,M=null,b=null,R=null,v.set(0,0,0),E=0,f=P,D=ce}return}gt=gt||at,tt=tt||J,At=At||ht,(at!==A||gt!==y)&&(i.blendEquationSeparate(vt[at],vt[gt]),A=at,y=gt),(J!==T||ht!==M||tt!==b||At!==R)&&(i.blendFuncSeparate(It[J],It[ht],It[tt],It[At]),T=J,M=ht,b=tt,R=At),(St.equals(v)===!1||_e!==E)&&(i.blendColor(St.r,St.g,St.b,_e),v.copy(St),E=_e),f=P,D=!1}function Nt(P,at){P.side===Mn?z(i.CULL_FACE):nt(i.CULL_FACE);let J=P.side===Fe;at&&(J=!J),Jt(J),P.blending===Cs&&P.transparent===!1?Lt(ti):Lt(P.blending,P.blendEquation,P.blendSrc,P.blendDst,P.blendEquationAlpha,P.blendSrcAlpha,P.blendDstAlpha,P.blendColor,P.blendAlpha,P.premultipliedAlpha),a.setFunc(P.depthFunc),a.setTest(P.depthTest),a.setMask(P.depthWrite),r.setMask(P.colorWrite);const ht=P.stencilWrite;o.setTest(ht),ht&&(o.setMask(P.stencilWriteMask),o.setFunc(P.stencilFunc,P.stencilRef,P.stencilFuncMask),o.setOp(P.stencilFail,P.stencilZFail,P.stencilZPass)),fe(P.polygonOffset,P.polygonOffsetFactor,P.polygonOffsetUnits),P.alphaToCoverage===!0?nt(i.SAMPLE_ALPHA_TO_COVERAGE):z(i.SAMPLE_ALPHA_TO_COVERAGE)}function Jt(P){C!==P&&(P?i.frontFace(i.CW):i.frontFace(i.CCW),C=P)}function Qt(P){P!==tp?(nt(i.CULL_FACE),P!==I&&(P===Eh?i.cullFace(i.BACK):P===ep?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):z(i.CULL_FACE),I=P}function me(P){P!==W&&(H&&i.lineWidth(P),W=P)}function fe(P,at,J){P?(nt(i.POLYGON_OFFSET_FILL),(X!==at||U!==J)&&(X=at,U=J,a.getReversed()&&(at=-at),i.polygonOffset(at,J))):z(i.POLYGON_OFFSET_FILL)}function ge(P){P?nt(i.SCISSOR_TEST):z(i.SCISSOR_TEST)}function Ee(P){P===void 0&&(P=i.TEXTURE0+q-1),j!==P&&(i.activeTexture(P),j=P)}function L(P,at,J){J===void 0&&(j===null?J=i.TEXTURE0+q-1:J=j);let ht=it[J];ht===void 0&&(ht={type:void 0,texture:void 0},it[J]=ht),(ht.type!==P||ht.texture!==at)&&(j!==J&&(i.activeTexture(J),j=J),i.bindTexture(P,at||rt[P]),ht.type=P,ht.texture=at)}function $e(){const P=it[j];P!==void 0&&P.type!==void 0&&(i.bindTexture(P.type,null),P.type=void 0,P.texture=void 0)}function jt(){try{i.compressedTexImage2D(...arguments)}catch(P){Yt("WebGLState:",P)}}function w(){try{i.compressedTexImage3D(...arguments)}catch(P){Yt("WebGLState:",P)}}function _(){try{i.texSubImage2D(...arguments)}catch(P){Yt("WebGLState:",P)}}function O(){try{i.texSubImage3D(...arguments)}catch(P){Yt("WebGLState:",P)}}function G(){try{i.compressedTexSubImage2D(...arguments)}catch(P){Yt("WebGLState:",P)}}function K(){try{i.compressedTexSubImage3D(...arguments)}catch(P){Yt("WebGLState:",P)}}function st(){try{i.texStorage2D(...arguments)}catch(P){Yt("WebGLState:",P)}}function ot(){try{i.texStorage3D(...arguments)}catch(P){Yt("WebGLState:",P)}}function Z(){try{i.texImage2D(...arguments)}catch(P){Yt("WebGLState:",P)}}function Q(){try{i.texImage3D(...arguments)}catch(P){Yt("WebGLState:",P)}}function ct(P){return u[P]!==void 0?u[P]:i.getParameter(P)}function wt(P,at){u[P]!==at&&(i.pixelStorei(P,at),u[P]=at)}function dt(P){qt.equals(P)===!1&&(i.scissor(P.x,P.y,P.z,P.w),qt.copy(P))}function lt(P){Bt.equals(P)===!1&&(i.viewport(P.x,P.y,P.z,P.w),Bt.copy(P))}function Pt(P,at){let J=l.get(at);J===void 0&&(J=new WeakMap,l.set(at,J));let ht=J.get(P);ht===void 0&&(ht=i.getUniformBlockIndex(at,P.name),J.set(P,ht))}function Ut(P,at){const ht=l.get(at).get(P);c.get(at)!==ht&&(i.uniformBlockBinding(at,ht,P.__bindingPointIndex),c.set(at,ht))}function Gt(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),i.pixelStorei(i.PACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),i.pixelStorei(i.PACK_ROW_LENGTH,0),i.pixelStorei(i.PACK_SKIP_PIXELS,0),i.pixelStorei(i.PACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_ROW_LENGTH,0),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,0),i.pixelStorei(i.UNPACK_SKIP_PIXELS,0),i.pixelStorei(i.UNPACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_SKIP_IMAGES,0),h={},u={},j=null,it={},d={},p=new WeakMap,g=[],x=null,m=!1,f=null,A=null,T=null,M=null,y=null,b=null,R=null,v=new Mt(0,0,0),E=0,D=!1,C=null,I=null,W=null,X=null,U=null,qt.set(0,0,i.canvas.width,i.canvas.height),Bt.set(0,0,i.canvas.width,i.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:nt,disable:z,bindFramebuffer:bt,drawBuffers:Dt,useProgram:Tt,setBlending:Lt,setMaterial:Nt,setFlipSided:Jt,setCullFace:Qt,setLineWidth:me,setPolygonOffset:fe,setScissorTest:ge,activeTexture:Ee,bindTexture:L,unbindTexture:$e,compressedTexImage2D:jt,compressedTexImage3D:w,texImage2D:Z,texImage3D:Q,pixelStorei:wt,getParameter:ct,updateUBOMapping:Pt,uniformBlockBinding:Ut,texStorage2D:st,texStorage3D:ot,texSubImage2D:_,texSubImage3D:O,compressedTexSubImage2D:G,compressedTexSubImage3D:K,scissor:dt,viewport:lt,reset:Gt}}function ov(i,t,e,n,s,r,a){const 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 Ft,h=new WeakMap,u=new Set;let d;const p=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(w,_){return g?new OffscreenCanvas(w,_):Ia("canvas")}function m(w,_,O){let G=1;const K=jt(w);if((K.width>O||K.height>O)&&(G=O/Math.max(K.width,K.height)),G<1)if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&w instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&w instanceof ImageBitmap||typeof VideoFrame<"u"&&w instanceof VideoFrame){const st=Math.floor(G*K.width),ot=Math.floor(G*K.height);d===void 0&&(d=x(st,ot));const Z=_?x(st,ot):d;return Z.width=st,Z.height=ot,Z.getContext("2d").drawImage(w,0,0,st,ot),Ot("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+st+"x"+ot+")."),Z}else return"data"in w&&Ot("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),w;return w}function f(w){return w.generateMipmaps}function A(w){i.generateMipmap(w)}function T(w){return w.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:w.isWebGL3DRenderTarget?i.TEXTURE_3D:w.isWebGLArrayRenderTarget||w.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function M(w,_,O,G,K,st=!1){if(w!==null){if(i[w]!==void 0)return i[w];Ot("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+w+"'")}let ot;G&&(ot=t.get("EXT_texture_norm16"),ot||Ot("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Z=_;if(_===i.RED&&(O===i.FLOAT&&(Z=i.R32F),O===i.HALF_FLOAT&&(Z=i.R16F),O===i.UNSIGNED_BYTE&&(Z=i.R8),O===i.UNSIGNED_SHORT&&ot&&(Z=ot.R16_EXT),O===i.SHORT&&ot&&(Z=ot.R16_SNORM_EXT)),_===i.RED_INTEGER&&(O===i.UNSIGNED_BYTE&&(Z=i.R8UI),O===i.UNSIGNED_SHORT&&(Z=i.R16UI),O===i.UNSIGNED_INT&&(Z=i.R32UI),O===i.BYTE&&(Z=i.R8I),O===i.SHORT&&(Z=i.R16I),O===i.INT&&(Z=i.R32I)),_===i.RG&&(O===i.FLOAT&&(Z=i.RG32F),O===i.HALF_FLOAT&&(Z=i.RG16F),O===i.UNSIGNED_BYTE&&(Z=i.RG8),O===i.UNSIGNED_SHORT&&ot&&(Z=ot.RG16_EXT),O===i.SHORT&&ot&&(Z=ot.RG16_SNORM_EXT)),_===i.RG_INTEGER&&(O===i.UNSIGNED_BYTE&&(Z=i.RG8UI),O===i.UNSIGNED_SHORT&&(Z=i.RG16UI),O===i.UNSIGNED_INT&&(Z=i.RG32UI),O===i.BYTE&&(Z=i.RG8I),O===i.SHORT&&(Z=i.RG16I),O===i.INT&&(Z=i.RG32I)),_===i.RGB_INTEGER&&(O===i.UNSIGNED_BYTE&&(Z=i.RGB8UI),O===i.UNSIGNED_SHORT&&(Z=i.RGB16UI),O===i.UNSIGNED_INT&&(Z=i.RGB32UI),O===i.BYTE&&(Z=i.RGB8I),O===i.SHORT&&(Z=i.RGB16I),O===i.INT&&(Z=i.RGB32I)),_===i.RGBA_INTEGER&&(O===i.UNSIGNED_BYTE&&(Z=i.RGBA8UI),O===i.UNSIGNED_SHORT&&(Z=i.RGBA16UI),O===i.UNSIGNED_INT&&(Z=i.RGBA32UI),O===i.BYTE&&(Z=i.RGBA8I),O===i.SHORT&&(Z=i.RGBA16I),O===i.INT&&(Z=i.RGBA32I)),_===i.RGB&&(O===i.UNSIGNED_SHORT&&ot&&(Z=ot.RGB16_EXT),O===i.SHORT&&ot&&(Z=ot.RGB16_SNORM_EXT),O===i.UNSIGNED_INT_5_9_9_9_REV&&(Z=i.RGB9_E5),O===i.UNSIGNED_INT_10F_11F_11F_REV&&(Z=i.R11F_G11F_B10F)),_===i.RGBA){const Q=st?Pa:Kt.getTransfer(K);O===i.FLOAT&&(Z=i.RGBA32F),O===i.HALF_FLOAT&&(Z=i.RGBA16F),O===i.UNSIGNED_BYTE&&(Z=Q===ee?i.SRGB8_ALPHA8:i.RGBA8),O===i.UNSIGNED_SHORT&&ot&&(Z=ot.RGBA16_EXT),O===i.SHORT&&ot&&(Z=ot.RGBA16_SNORM_EXT),O===i.UNSIGNED_SHORT_4_4_4_4&&(Z=i.RGBA4),O===i.UNSIGNED_SHORT_5_5_5_1&&(Z=i.RGB5_A1)}return(Z===i.R16F||Z===i.R32F||Z===i.RG16F||Z===i.RG32F||Z===i.RGBA16F||Z===i.RGBA32F)&&t.get("EXT_color_buffer_float"),Z}function y(w,_){let O;return w?_===null||_===Vn||_===gr?O=i.DEPTH24_STENCIL8:_===zn?O=i.DEPTH32F_STENCIL8:_===mr&&(O=i.DEPTH24_STENCIL8,Ot("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===Vn||_===gr?O=i.DEPTH_COMPONENT24:_===zn?O=i.DEPTH_COMPONENT32F:_===mr&&(O=i.DEPTH_COMPONENT16),O}function b(w,_){return f(w)===!0||w.isFramebufferTexture&&w.minFilter!==ze&&w.minFilter!==Ne?Math.log2(Math.max(_.width,_.height))+1:w.mipmaps!==void 0&&w.mipmaps.length>0?w.mipmaps.length:w.isCompressedTexture&&Array.isArray(w.image)?_.mipmaps.length:1}function R(w){const _=w.target;_.removeEventListener("dispose",R),E(_),_.isVideoTexture&&h.delete(_),_.isHTMLTexture&&u.delete(_)}function v(w){const _=w.target;_.removeEventListener("dispose",v),C(_)}function E(w){const _=n.get(w);if(_.__webglInit===void 0)return;const O=w.source,G=p.get(O);if(G){const K=G[_.__cacheKey];K.usedTimes--,K.usedTimes===0&&D(w),Object.keys(G).length===0&&p.delete(O)}n.remove(w)}function D(w){const _=n.get(w);i.deleteTexture(_.__webglTexture);const O=w.source,G=p.get(O);delete G[_.__cacheKey],a.memory.textures--}function C(w){const _=n.get(w);if(w.depthTexture&&(w.depthTexture.dispose(),n.remove(w.depthTexture)),w.isWebGLCubeRenderTarget)for(let G=0;G<6;G++){if(Array.isArray(_.__webglFramebuffer[G]))for(let K=0;K<_.__webglFramebuffer[G].length;K++)i.deleteFramebuffer(_.__webglFramebuffer[G][K]);else i.deleteFramebuffer(_.__webglFramebuffer[G]);_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer[G])}else{if(Array.isArray(_.__webglFramebuffer))for(let G=0;G<_.__webglFramebuffer.length;G++)i.deleteFramebuffer(_.__webglFramebuffer[G]);else i.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&i.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let G=0;G<_.__webglColorRenderbuffer.length;G++)_.__webglColorRenderbuffer[G]&&i.deleteRenderbuffer(_.__webglColorRenderbuffer[G]);_.__webglDepthRenderbuffer&&i.deleteRenderbuffer(_.__webglDepthRenderbuffer)}const O=w.textures;for(let G=0,K=O.length;G<K;G++){const st=n.get(O[G]);st.__webglTexture&&(i.deleteTexture(st.__webglTexture),a.memory.textures--),n.remove(O[G])}n.remove(w)}let I=0;function W(){I=0}function X(){return I}function U(w){I=w}function q(){const w=I;return w>=s.maxTextures&&Ot("WebGLTextures: Trying to use "+w+" texture units while this GPU supports only "+s.maxTextures),I+=1,w}function H(w){const _=[];return _.push(w.wrapS),_.push(w.wrapT),_.push(w.wrapR||0),_.push(w.magFilter),_.push(w.minFilter),_.push(w.anisotropy),_.push(w.internalFormat),_.push(w.format),_.push(w.type),_.push(w.generateMipmaps),_.push(w.premultiplyAlpha),_.push(w.flipY),_.push(w.unpackAlignment),_.push(w.colorSpace),_.join()}function $(w,_){const O=n.get(w);if(w.isVideoTexture&&L(w),w.isRenderTargetTexture===!1&&w.isExternalTexture!==!0&&w.version>0&&O.__version!==w.version){const G=w.image;if(G===null)Ot("WebGLRenderer: Texture marked for update but no image data found.");else if(G.complete===!1)Ot("WebGLRenderer: Texture marked for update but image is incomplete");else{z(O,w,_);return}}else w.isExternalTexture&&(O.__webglTexture=w.sourceTexture?w.sourceTexture:null);e.bindTexture(i.TEXTURE_2D,O.__webglTexture,i.TEXTURE0+_)}function et(w,_){const O=n.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&O.__version!==w.version){z(O,w,_);return}else w.isExternalTexture&&(O.__webglTexture=w.sourceTexture?w.sourceTexture:null);e.bindTexture(i.TEXTURE_2D_ARRAY,O.__webglTexture,i.TEXTURE0+_)}function j(w,_){const O=n.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&O.__version!==w.version){z(O,w,_);return}e.bindTexture(i.TEXTURE_3D,O.__webglTexture,i.TEXTURE0+_)}function it(w,_){const O=n.get(w);if(w.isCubeDepthTexture!==!0&&w.version>0&&O.__version!==w.version){bt(O,w,_);return}e.bindTexture(i.TEXTURE_CUBE_MAP,O.__webglTexture,i.TEXTURE0+_)}const ut={[_c]:i.REPEAT,[Sn]:i.CLAMP_TO_EDGE,[vc]:i.MIRRORED_REPEAT},kt={[ze]:i.NEAREST,[Ep]:i.NEAREST_MIPMAP_NEAREST,[Cr]:i.NEAREST_MIPMAP_LINEAR,[Ne]:i.LINEAR,[so]:i.LINEAR_MIPMAP_NEAREST,[ki]:i.LINEAR_MIPMAP_LINEAR},qt={[Tp]:i.NEVER,[Pp]:i.ALWAYS,[wp]:i.LESS,[Fl]:i.LEQUAL,[Rp]:i.EQUAL,[Ol]:i.GEQUAL,[Cp]:i.GREATER,[Dp]:i.NOTEQUAL};function Bt(w,_){if(_.type===zn&&t.has("OES_texture_float_linear")===!1&&(_.magFilter===Ne||_.magFilter===so||_.magFilter===Cr||_.magFilter===ki||_.minFilter===Ne||_.minFilter===so||_.minFilter===Cr||_.minFilter===ki)&&Ot("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(w,i.TEXTURE_WRAP_S,ut[_.wrapS]),i.texParameteri(w,i.TEXTURE_WRAP_T,ut[_.wrapT]),(w===i.TEXTURE_3D||w===i.TEXTURE_2D_ARRAY)&&i.texParameteri(w,i.TEXTURE_WRAP_R,ut[_.wrapR]),i.texParameteri(w,i.TEXTURE_MAG_FILTER,kt[_.magFilter]),i.texParameteri(w,i.TEXTURE_MIN_FILTER,kt[_.minFilter]),_.compareFunction&&(i.texParameteri(w,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(w,i.TEXTURE_COMPARE_FUNC,qt[_.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===ze||_.minFilter!==Cr&&_.minFilter!==ki||_.type===zn&&t.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||n.get(_).__currentAnisotropy){const O=t.get("EXT_texture_filter_anisotropic");i.texParameterf(w,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,s.getMaxAnisotropy())),n.get(_).__currentAnisotropy=_.anisotropy}}}function Y(w,_){let O=!1;w.__webglInit===void 0&&(w.__webglInit=!0,_.addEventListener("dispose",R));const G=_.source;let K=p.get(G);K===void 0&&(K={},p.set(G,K));const st=H(_);if(st!==w.__cacheKey){K[st]===void 0&&(K[st]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,O=!0),K[st].usedTimes++;const ot=K[w.__cacheKey];ot!==void 0&&(K[w.__cacheKey].usedTimes--,ot.usedTimes===0&&D(_)),w.__cacheKey=st,w.__webglTexture=K[st].texture}return O}function rt(w,_,O){return Math.floor(Math.floor(w/O)/_)}function nt(w,_,O,G){const st=w.updateRanges;if(st.length===0)e.texSubImage2D(i.TEXTURE_2D,0,0,0,_.width,_.height,O,G,_.data);else{st.sort((wt,dt)=>wt.start-dt.start);let ot=0;for(let wt=1;wt<st.length;wt++){const dt=st[ot],lt=st[wt],Pt=dt.start+dt.count,Ut=rt(lt.start,_.width,4),Gt=rt(dt.start,_.width,4);lt.start<=Pt+1&&Ut===Gt&&rt(lt.start+lt.count-1,_.width,4)===Ut?dt.count=Math.max(dt.count,lt.start+lt.count-dt.start):(++ot,st[ot]=lt)}st.length=ot+1;const Z=e.getParameter(i.UNPACK_ROW_LENGTH),Q=e.getParameter(i.UNPACK_SKIP_PIXELS),ct=e.getParameter(i.UNPACK_SKIP_ROWS);e.pixelStorei(i.UNPACK_ROW_LENGTH,_.width);for(let wt=0,dt=st.length;wt<dt;wt++){const lt=st[wt],Pt=Math.floor(lt.start/4),Ut=Math.ceil(lt.count/4),Gt=Pt%_.width,P=Math.floor(Pt/_.width),at=Ut,J=1;e.pixelStorei(i.UNPACK_SKIP_PIXELS,Gt),e.pixelStorei(i.UNPACK_SKIP_ROWS,P),e.texSubImage2D(i.TEXTURE_2D,0,Gt,P,at,J,O,G,_.data)}w.clearUpdateRanges(),e.pixelStorei(i.UNPACK_ROW_LENGTH,Z),e.pixelStorei(i.UNPACK_SKIP_PIXELS,Q),e.pixelStorei(i.UNPACK_SKIP_ROWS,ct)}}function z(w,_,O){let G=i.TEXTURE_2D;(_.isDataArrayTexture||_.isCompressedArrayTexture)&&(G=i.TEXTURE_2D_ARRAY),_.isData3DTexture&&(G=i.TEXTURE_3D);const K=Y(w,_),st=_.source;e.bindTexture(G,w.__webglTexture,i.TEXTURE0+O);const ot=n.get(st);if(st.version!==ot.__version||K===!0){if(e.activeTexture(i.TEXTURE0+O),(typeof ImageBitmap<"u"&&_.image instanceof ImageBitmap)===!1){const J=Kt.getPrimaries(Kt.workingColorSpace),ht=_.colorSpace===vi?null:Kt.getPrimaries(_.colorSpace),gt=_.colorSpace===vi||J===ht?i.NONE:i.BROWSER_DEFAULT_WEBGL;e.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),e.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),e.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,gt)}e.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment);let Q=m(_.image,!1,s.maxTextureSize);Q=$e(_,Q);const ct=r.convert(_.format,_.colorSpace),wt=r.convert(_.type);let dt=M(_.internalFormat,ct,wt,_.normalized,_.colorSpace,_.isVideoTexture);Bt(G,_);let lt;const Pt=_.mipmaps,Ut=_.isVideoTexture!==!0,Gt=ot.__version===void 0||K===!0,P=st.dataReady,at=b(_,Q);if(_.isDepthTexture)dt=y(_.format===Gi,_.type),Gt&&(Ut?e.texStorage2D(i.TEXTURE_2D,1,dt,Q.width,Q.height):e.texImage2D(i.TEXTURE_2D,0,dt,Q.width,Q.height,0,ct,wt,null));else if(_.isDataTexture)if(Pt.length>0){Ut&&Gt&&e.texStorage2D(i.TEXTURE_2D,at,dt,Pt[0].width,Pt[0].height);for(let J=0,ht=Pt.length;J<ht;J++)lt=Pt[J],Ut?P&&e.texSubImage2D(i.TEXTURE_2D,J,0,0,lt.width,lt.height,ct,wt,lt.data):e.texImage2D(i.TEXTURE_2D,J,dt,lt.width,lt.height,0,ct,wt,lt.data);_.generateMipmaps=!1}else Ut?(Gt&&e.texStorage2D(i.TEXTURE_2D,at,dt,Q.width,Q.height),P&&nt(_,Q,ct,wt)):e.texImage2D(i.TEXTURE_2D,0,dt,Q.width,Q.height,0,ct,wt,Q.data);else if(_.isCompressedTexture)if(_.isCompressedArrayTexture){Ut&&Gt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,at,dt,Pt[0].width,Pt[0].height,Q.depth);for(let J=0,ht=Pt.length;J<ht;J++)if(lt=Pt[J],_.format!==pn)if(ct!==null)if(Ut){if(P)if(_.layerUpdates.size>0){const gt=tu(lt.width,lt.height,_.format,_.type);for(const tt of _.layerUpdates){const At=lt.data.subarray(tt*gt/lt.data.BYTES_PER_ELEMENT,(tt+1)*gt/lt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,tt,lt.width,lt.height,1,ct,At)}_.clearLayerUpdates()}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,lt.width,lt.height,Q.depth,ct,lt.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,J,dt,lt.width,lt.height,Q.depth,0,lt.data,0,0);else Ot("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ut?P&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,lt.width,lt.height,Q.depth,ct,wt,lt.data):e.texImage3D(i.TEXTURE_2D_ARRAY,J,dt,lt.width,lt.height,Q.depth,0,ct,wt,lt.data)}else{Ut&&Gt&&e.texStorage2D(i.TEXTURE_2D,at,dt,Pt[0].width,Pt[0].height);for(let J=0,ht=Pt.length;J<ht;J++)lt=Pt[J],_.format!==pn?ct!==null?Ut?P&&e.compressedTexSubImage2D(i.TEXTURE_2D,J,0,0,lt.width,lt.height,ct,lt.data):e.compressedTexImage2D(i.TEXTURE_2D,J,dt,lt.width,lt.height,0,lt.data):Ot("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ut?P&&e.texSubImage2D(i.TEXTURE_2D,J,0,0,lt.width,lt.height,ct,wt,lt.data):e.texImage2D(i.TEXTURE_2D,J,dt,lt.width,lt.height,0,ct,wt,lt.data)}else if(_.isDataArrayTexture)if(Ut){if(Gt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,at,dt,Q.width,Q.height,Q.depth),P)if(_.layerUpdates.size>0){const J=tu(Q.width,Q.height,_.format,_.type);for(const ht of _.layerUpdates){const gt=Q.data.subarray(ht*J/Q.data.BYTES_PER_ELEMENT,(ht+1)*J/Q.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,ht,Q.width,Q.height,1,ct,wt,gt)}_.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,ct,wt,Q.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,dt,Q.width,Q.height,Q.depth,0,ct,wt,Q.data);else if(_.isData3DTexture)Ut?(Gt&&e.texStorage3D(i.TEXTURE_3D,at,dt,Q.width,Q.height,Q.depth),P&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,ct,wt,Q.data)):e.texImage3D(i.TEXTURE_3D,0,dt,Q.width,Q.height,Q.depth,0,ct,wt,Q.data);else if(_.isFramebufferTexture){if(Gt)if(Ut)e.texStorage2D(i.TEXTURE_2D,at,dt,Q.width,Q.height);else{let J=Q.width,ht=Q.height;for(let gt=0;gt<at;gt++)e.texImage2D(i.TEXTURE_2D,gt,dt,J,ht,0,ct,wt,null),J>>=1,ht>>=1}}else if(_.isHTMLTexture){if("texElementImage2D"in i){const J=i.canvas;if(J.hasAttribute("layoutsubtree")||J.setAttribute("layoutsubtree","true"),Q.parentNode!==J){J.appendChild(Q),u.add(_),J.onpaint=ht=>{const gt=ht.changedElements;for(const tt of u)gt.includes(tt.image)&&(tt.needsUpdate=!0)},J.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,Q);else{const gt=i.RGBA,tt=i.RGBA,At=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,gt,tt,At,Q)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(Pt.length>0){if(Ut&&Gt){const J=jt(Pt[0]);e.texStorage2D(i.TEXTURE_2D,at,dt,J.width,J.height)}for(let J=0,ht=Pt.length;J<ht;J++)lt=Pt[J],Ut?P&&e.texSubImage2D(i.TEXTURE_2D,J,0,0,ct,wt,lt):e.texImage2D(i.TEXTURE_2D,J,dt,ct,wt,lt);_.generateMipmaps=!1}else if(Ut){if(Gt){const J=jt(Q);e.texStorage2D(i.TEXTURE_2D,at,dt,J.width,J.height)}P&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,ct,wt,Q)}else e.texImage2D(i.TEXTURE_2D,0,dt,ct,wt,Q);f(_)&&A(G),ot.__version=st.version,_.onUpdate&&_.onUpdate(_)}w.__version=_.version}function bt(w,_,O){if(_.image.length!==6)return;const G=Y(w,_),K=_.source;e.bindTexture(i.TEXTURE_CUBE_MAP,w.__webglTexture,i.TEXTURE0+O);const st=n.get(K);if(K.version!==st.__version||G===!0){e.activeTexture(i.TEXTURE0+O);const ot=Kt.getPrimaries(Kt.workingColorSpace),Z=_.colorSpace===vi?null:Kt.getPrimaries(_.colorSpace),Q=_.colorSpace===vi||ot===Z?i.NONE:i.BROWSER_DEFAULT_WEBGL;e.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),e.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),e.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),e.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);const ct=_.isCompressedTexture||_.image[0].isCompressedTexture,wt=_.image[0]&&_.image[0].isDataTexture,dt=[];for(let tt=0;tt<6;tt++)!ct&&!wt?dt[tt]=m(_.image[tt],!0,s.maxCubemapSize):dt[tt]=wt?_.image[tt].image:_.image[tt],dt[tt]=$e(_,dt[tt]);const lt=dt[0],Pt=r.convert(_.format,_.colorSpace),Ut=r.convert(_.type),Gt=M(_.internalFormat,Pt,Ut,_.normalized,_.colorSpace),P=_.isVideoTexture!==!0,at=st.__version===void 0||G===!0,J=K.dataReady;let ht=b(_,lt);Bt(i.TEXTURE_CUBE_MAP,_);let gt;if(ct){P&&at&&e.texStorage2D(i.TEXTURE_CUBE_MAP,ht,Gt,lt.width,lt.height);for(let tt=0;tt<6;tt++){gt=dt[tt].mipmaps;for(let At=0;At<gt.length;At++){const St=gt[At];_.format!==pn?Pt!==null?P?J&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At,0,0,St.width,St.height,Pt,St.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At,Gt,St.width,St.height,0,St.data):Ot("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):P?J&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At,0,0,St.width,St.height,Pt,Ut,St.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At,Gt,St.width,St.height,0,Pt,Ut,St.data)}}}else{if(gt=_.mipmaps,P&&at){gt.length>0&&ht++;const tt=jt(dt[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,ht,Gt,tt.width,tt.height)}for(let tt=0;tt<6;tt++)if(wt){P?J&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,0,0,dt[tt].width,dt[tt].height,Pt,Ut,dt[tt].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,Gt,dt[tt].width,dt[tt].height,0,Pt,Ut,dt[tt].data);for(let At=0;At<gt.length;At++){const _e=gt[At].image[tt].image;P?J&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At+1,0,0,_e.width,_e.height,Pt,Ut,_e.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At+1,Gt,_e.width,_e.height,0,Pt,Ut,_e.data)}}else{P?J&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,0,0,Pt,Ut,dt[tt]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,Gt,Pt,Ut,dt[tt]);for(let At=0;At<gt.length;At++){const St=gt[At];P?J&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At+1,0,0,Pt,Ut,St.image[tt]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At+1,Gt,Pt,Ut,St.image[tt])}}}f(_)&&A(i.TEXTURE_CUBE_MAP),st.__version=K.version,_.onUpdate&&_.onUpdate(_)}w.__version=_.version}function Dt(w,_,O,G,K,st){const ot=r.convert(O.format,O.colorSpace),Z=r.convert(O.type),Q=M(O.internalFormat,ot,Z,O.normalized,O.colorSpace),ct=n.get(_),wt=n.get(O);if(wt.__renderTarget=_,!ct.__hasExternalTextures){const dt=Math.max(1,_.width>>st),lt=Math.max(1,_.height>>st);K===i.TEXTURE_3D||K===i.TEXTURE_2D_ARRAY?e.texImage3D(K,st,Q,dt,lt,_.depth,0,ot,Z,null):e.texImage2D(K,st,Q,dt,lt,0,ot,Z,null)}e.bindFramebuffer(i.FRAMEBUFFER,w),Ee(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,G,K,wt.__webglTexture,0,ge(_)):(K===i.TEXTURE_2D||K>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,G,K,wt.__webglTexture,st),e.bindFramebuffer(i.FRAMEBUFFER,null)}function Tt(w,_,O){if(i.bindRenderbuffer(i.RENDERBUFFER,w),_.depthBuffer){const G=_.depthTexture,K=G&&G.isDepthTexture?G.type:null,st=y(_.stencilBuffer,K),ot=_.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;Ee(_)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ge(_),st,_.width,_.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,ge(_),st,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,st,_.width,_.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ot,i.RENDERBUFFER,w)}else{const G=_.textures;for(let K=0;K<G.length;K++){const st=G[K],ot=r.convert(st.format,st.colorSpace),Z=r.convert(st.type),Q=M(st.internalFormat,ot,Z,st.normalized,st.colorSpace);Ee(_)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ge(_),Q,_.width,_.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,ge(_),Q,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,Q,_.width,_.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function vt(w,_,O){const G=_.isWebGLCubeRenderTarget===!0;if(e.bindFramebuffer(i.FRAMEBUFFER,w),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const K=n.get(_.depthTexture);if(K.__renderTarget=_,(!K.__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)&&(_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0),G){if(K.__webglInit===void 0&&(K.__webglInit=!0,_.depthTexture.addEventListener("dispose",R)),K.__webglTexture===void 0){K.__webglTexture=i.createTexture(),e.bindTexture(i.TEXTURE_CUBE_MAP,K.__webglTexture),Bt(i.TEXTURE_CUBE_MAP,_.depthTexture);const ct=r.convert(_.depthTexture.format),wt=r.convert(_.depthTexture.type);let dt;_.depthTexture.format===ni?dt=i.DEPTH_COMPONENT24:_.depthTexture.format===Gi&&(dt=i.DEPTH24_STENCIL8);for(let lt=0;lt<6;lt++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+lt,0,dt,_.width,_.height,0,ct,wt,null)}}else $(_.depthTexture,0);const st=K.__webglTexture,ot=ge(_),Z=G?i.TEXTURE_CUBE_MAP_POSITIVE_X+O:i.TEXTURE_2D,Q=_.depthTexture.format===Gi?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(_.depthTexture.format===ni)Ee(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Q,Z,st,0,ot):i.framebufferTexture2D(i.FRAMEBUFFER,Q,Z,st,0);else if(_.depthTexture.format===Gi)Ee(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Q,Z,st,0,ot):i.framebufferTexture2D(i.FRAMEBUFFER,Q,Z,st,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function It(w){const _=n.get(w),O=w.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==w.depthTexture){const G=w.depthTexture;if(_.__depthDisposeCallback&&_.__depthDisposeCallback(),G){const K=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,G.removeEventListener("dispose",K)};G.addEventListener("dispose",K),_.__depthDisposeCallback=K}_.__boundDepthTexture=G}if(w.depthTexture&&!_.__autoAllocateDepthBuffer)if(O)for(let G=0;G<6;G++)vt(_.__webglFramebuffer[G],w,G);else{const G=w.texture.mipmaps;G&&G.length>0?vt(_.__webglFramebuffer[0],w,0):vt(_.__webglFramebuffer,w,0)}else if(O){_.__webglDepthbuffer=[];for(let G=0;G<6;G++)if(e.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[G]),_.__webglDepthbuffer[G]===void 0)_.__webglDepthbuffer[G]=i.createRenderbuffer(),Tt(_.__webglDepthbuffer[G],w,!1);else{const K=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,st=_.__webglDepthbuffer[G];i.bindRenderbuffer(i.RENDERBUFFER,st),i.framebufferRenderbuffer(i.FRAMEBUFFER,K,i.RENDERBUFFER,st)}}else{const G=w.texture.mipmaps;if(G&&G.length>0?e.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[0]):e.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=i.createRenderbuffer(),Tt(_.__webglDepthbuffer,w,!1);else{const K=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,st=_.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,st),i.framebufferRenderbuffer(i.FRAMEBUFFER,K,i.RENDERBUFFER,st)}}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Lt(w,_,O){const G=n.get(w);_!==void 0&&Dt(G.__webglFramebuffer,w,w.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),O!==void 0&&It(w)}function Nt(w){const _=w.texture,O=n.get(w),G=n.get(_);w.addEventListener("dispose",v);const K=w.textures,st=w.isWebGLCubeRenderTarget===!0,ot=K.length>1;if(ot||(G.__webglTexture===void 0&&(G.__webglTexture=i.createTexture()),G.__version=_.version,a.memory.textures++),st){O.__webglFramebuffer=[];for(let Z=0;Z<6;Z++)if(_.mipmaps&&_.mipmaps.length>0){O.__webglFramebuffer[Z]=[];for(let Q=0;Q<_.mipmaps.length;Q++)O.__webglFramebuffer[Z][Q]=i.createFramebuffer()}else O.__webglFramebuffer[Z]=i.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){O.__webglFramebuffer=[];for(let Z=0;Z<_.mipmaps.length;Z++)O.__webglFramebuffer[Z]=i.createFramebuffer()}else O.__webglFramebuffer=i.createFramebuffer();if(ot)for(let Z=0,Q=K.length;Z<Q;Z++){const ct=n.get(K[Z]);ct.__webglTexture===void 0&&(ct.__webglTexture=i.createTexture(),a.memory.textures++)}if(w.samples>0&&Ee(w)===!1){O.__webglMultisampledFramebuffer=i.createFramebuffer(),O.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let Z=0;Z<K.length;Z++){const Q=K[Z];O.__webglColorRenderbuffer[Z]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,O.__webglColorRenderbuffer[Z]);const ct=r.convert(Q.format,Q.colorSpace),wt=r.convert(Q.type),dt=M(Q.internalFormat,ct,wt,Q.normalized,Q.colorSpace,w.isXRRenderTarget===!0),lt=ge(w);i.renderbufferStorageMultisample(i.RENDERBUFFER,lt,dt,w.width,w.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Z,i.RENDERBUFFER,O.__webglColorRenderbuffer[Z])}i.bindRenderbuffer(i.RENDERBUFFER,null),w.depthBuffer&&(O.__webglDepthRenderbuffer=i.createRenderbuffer(),Tt(O.__webglDepthRenderbuffer,w,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(st){e.bindTexture(i.TEXTURE_CUBE_MAP,G.__webglTexture),Bt(i.TEXTURE_CUBE_MAP,_);for(let Z=0;Z<6;Z++)if(_.mipmaps&&_.mipmaps.length>0)for(let Q=0;Q<_.mipmaps.length;Q++)Dt(O.__webglFramebuffer[Z][Q],w,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Q);else Dt(O.__webglFramebuffer[Z],w,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0);f(_)&&A(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(ot){for(let Z=0,Q=K.length;Z<Q;Z++){const ct=K[Z],wt=n.get(ct);let dt=i.TEXTURE_2D;(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)&&(dt=w.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(dt,wt.__webglTexture),Bt(dt,ct),Dt(O.__webglFramebuffer,w,ct,i.COLOR_ATTACHMENT0+Z,dt,0),f(ct)&&A(dt)}e.unbindTexture()}else{let Z=i.TEXTURE_2D;if((w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)&&(Z=w.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(Z,G.__webglTexture),Bt(Z,_),_.mipmaps&&_.mipmaps.length>0)for(let Q=0;Q<_.mipmaps.length;Q++)Dt(O.__webglFramebuffer[Q],w,_,i.COLOR_ATTACHMENT0,Z,Q);else Dt(O.__webglFramebuffer,w,_,i.COLOR_ATTACHMENT0,Z,0);f(_)&&A(Z),e.unbindTexture()}w.depthBuffer&&It(w)}function Jt(w){const _=w.textures;for(let O=0,G=_.length;O<G;O++){const K=_[O];if(f(K)){const st=T(w),ot=n.get(K).__webglTexture;e.bindTexture(st,ot),A(st),e.unbindTexture()}}}const Qt=[],me=[];function fe(w){if(w.samples>0){if(Ee(w)===!1){const _=w.textures,O=w.width,G=w.height;let K=i.COLOR_BUFFER_BIT;const st=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ot=n.get(w),Z=_.length>1;if(Z)for(let ct=0;ct<_.length;ct++)e.bindFramebuffer(i.FRAMEBUFFER,ot.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ct,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,ot.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ct,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,ot.__webglMultisampledFramebuffer);const Q=w.texture.mipmaps;Q&&Q.length>0?e.bindFramebuffer(i.DRAW_FRAMEBUFFER,ot.__webglFramebuffer[0]):e.bindFramebuffer(i.DRAW_FRAMEBUFFER,ot.__webglFramebuffer);for(let ct=0;ct<_.length;ct++){if(w.resolveDepthBuffer&&(w.depthBuffer&&(K|=i.DEPTH_BUFFER_BIT),w.stencilBuffer&&w.resolveStencilBuffer&&(K|=i.STENCIL_BUFFER_BIT)),Z){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,ot.__webglColorRenderbuffer[ct]);const wt=n.get(_[ct]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,wt,0)}i.blitFramebuffer(0,0,O,G,0,0,O,G,K,i.NEAREST),c===!0&&(Qt.length=0,me.length=0,Qt.push(i.COLOR_ATTACHMENT0+ct),w.depthBuffer&&w.resolveDepthBuffer===!1&&(Qt.push(st),me.push(st),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,me)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,Qt))}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),Z)for(let ct=0;ct<_.length;ct++){e.bindFramebuffer(i.FRAMEBUFFER,ot.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ct,i.RENDERBUFFER,ot.__webglColorRenderbuffer[ct]);const wt=n.get(_[ct]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,ot.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ct,i.TEXTURE_2D,wt,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,ot.__webglMultisampledFramebuffer)}else if(w.depthBuffer&&w.resolveDepthBuffer===!1&&c){const _=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[_])}}}function ge(w){return Math.min(s.maxSamples,w.samples)}function Ee(w){const _=n.get(w);return w.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function L(w){const _=a.render.frame;h.get(w)!==_&&(h.set(w,_),w.update())}function $e(w,_){const O=w.colorSpace,G=w.format,K=w.type;return w.isCompressedTexture===!0||w.isVideoTexture===!0||O!==Da&&O!==vi&&(Kt.getTransfer(O)===ee?(G!==pn||K!==rn)&&Ot("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Yt("WebGLTextures: Unsupported texture color space:",O)),_}function jt(w){return typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement?(l.width=w.naturalWidth||w.width,l.height=w.naturalHeight||w.height):typeof VideoFrame<"u"&&w instanceof VideoFrame?(l.width=w.displayWidth,l.height=w.displayHeight):(l.width=w.width,l.height=w.height),l}this.allocateTextureUnit=q,this.resetTextureUnits=W,this.getTextureUnits=X,this.setTextureUnits=U,this.setTexture2D=$,this.setTexture2DArray=et,this.setTexture3D=j,this.setTextureCube=it,this.rebindTextures=Lt,this.setupRenderTarget=Nt,this.updateRenderTargetMipmap=Jt,this.updateMultisampleRenderTarget=fe,this.setupDepthRenderbuffer=It,this.setupFrameBufferTexture=Dt,this.useMultisampledRTT=Ee,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function cv(i,t){function e(n,s=vi){let r;const a=Kt.getTransfer(s);if(n===rn)return i.UNSIGNED_BYTE;if(n===Pl)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Il)return i.UNSIGNED_SHORT_5_5_5_1;if(n===H0)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===V0)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===k0)return i.BYTE;if(n===G0)return i.SHORT;if(n===mr)return i.UNSIGNED_SHORT;if(n===Dl)return i.INT;if(n===Vn)return i.UNSIGNED_INT;if(n===zn)return i.FLOAT;if(n===bn)return i.HALF_FLOAT;if(n===W0)return i.ALPHA;if(n===X0)return i.RGB;if(n===pn)return i.RGBA;if(n===ni)return i.DEPTH_COMPONENT;if(n===Gi)return i.DEPTH_STENCIL;if(n===q0)return i.RED;if(n===Ll)return i.RED_INTEGER;if(n===Yi)return i.RG;if(n===Nl)return i.RG_INTEGER;if(n===Ul)return i.RGBA_INTEGER;if(n===Ma||n===Sa||n===ya||n===Ea)if(a===ee)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Ma)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Sa)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===ya)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ea)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Ma)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Sa)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===ya)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ea)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===xc||n===Mc||n===Sc||n===yc)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===xc)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Mc)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Sc)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===yc)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ec||n===bc||n===Ac||n===Tc||n===wc||n===Ra||n===Rc)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Ec||n===bc)return a===ee?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Ac)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Tc)return r.COMPRESSED_R11_EAC;if(n===wc)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Ra)return r.COMPRESSED_RG11_EAC;if(n===Rc)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Cc||n===Dc||n===Pc||n===Ic||n===Lc||n===Nc||n===Uc||n===Fc||n===Oc||n===zc||n===Bc||n===kc||n===Gc||n===Hc)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Cc)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Dc)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Pc)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Ic)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Lc)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Nc)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Uc)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Fc)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Oc)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===zc)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Bc)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===kc)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Gc)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Hc)return a===ee?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Vc||n===Wc||n===Xc)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===Vc)return a===ee?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Wc)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Xc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===qc||n===Yc||n===Ca||n===Kc)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===qc)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Yc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ca)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Kc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===gr?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}const lv=`
4391
+ }`,hv=[new F(1,0,0),new F(-1,0,0),new F(0,1,0),new F(0,-1,0),new F(0,0,1),new F(0,0,-1)],uv=[new F(0,-1,0),new F(0,-1,0),new F(0,0,1),new F(0,0,-1),new F(0,-1,0),new F(0,-1,0)],Pu=new he,sr=new F,qo=new F;function dv(i,t,e){let n=new $l;const s=new Ft,r=new Ft,a=new pe,o=new Sm,c=new ym,l={},h=e.maxTextureSize,u={[wi]:Ce,[Ce]:wi,[An]:An},d=new Be({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ft},radius:{value:4}},vertexShader:cv,fragmentShader:lv}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const g=new Ee;g.setAttribute("position",new le(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new se(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=gr;let p=this.type;this.render=function(b,R,v){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;this.type===lp&&(Ot("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=gr);const E=i.getRenderTarget(),D=i.getActiveCubeFace(),C=i.getActiveMipmapLevel(),I=i.state;I.setBlending(si),I.buffers.depth.getReversed()===!0?I.buffers.color.setClear(0,0,0,0):I.buffers.color.setClear(1,1,1,1),I.buffers.depth.setTest(!0),I.setScissorTest(!1);const W=p!==this.type;W&&R.traverse(function(X){X.material&&(Array.isArray(X.material)?X.material.forEach(U=>U.needsUpdate=!0):X.material.needsUpdate=!0)});for(let X=0,U=b.length;X<U;X++){const q=b[X],H=q.shadow;if(H===void 0){Ot("WebGLShadowMap:",q,"has no shadow.");continue}if(H.autoUpdate===!1&&H.needsUpdate===!1)continue;s.copy(H.mapSize);const $=H.getFrameExtents();s.multiply($),r.copy(H.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/$.x),s.x=r.x*$.x,H.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/$.y),s.y=r.y*$.y,H.mapSize.y=r.y));const et=i.state.buffers.depth.getReversed();if(H.camera._reversedDepth=et,H.map===null||W===!0){if(H.map!==null&&(H.map.depthTexture!==null&&(H.map.depthTexture.dispose(),H.map.depthTexture=null),H.map.dispose()),this.type===lr){if(q.isPointLight){Ot("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}H.map=new Rn(s.x,s.y,{format:$i,type:xn,minFilter:we,magFilter:we,generateMipmaps:!1}),H.map.texture.name=q.name+".shadowMap",H.map.depthTexture=new Hs(s.x,s.y,Vn),H.map.depthTexture.name=q.name+".shadowMapDepth",H.map.depthTexture.format=ai,H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=ke,H.map.depthTexture.magFilter=ke}else q.isPointLight?(H.map=new _d(s.x),H.map.depthTexture=new mm(s.x,Kn)):(H.map=new Rn(s.x,s.y),H.map.depthTexture=new Hs(s.x,s.y,Kn)),H.map.depthTexture.name=q.name+".shadowMap",H.map.depthTexture.format=ai,this.type===gr?(H.map.depthTexture.compareFunction=et?Wl:Vl,H.map.depthTexture.minFilter=we,H.map.depthTexture.magFilter=we):(H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=ke,H.map.depthTexture.magFilter=ke);H.camera.updateProjectionMatrix()}const j=H.map.isWebGLCubeRenderTarget?6:1;for(let it=0;it<j;it++){if(H.map.isWebGLCubeRenderTarget)i.setRenderTarget(H.map,it),i.clear();else{it===0&&(i.setRenderTarget(H.map),i.clear());const ut=H.getViewport(it);a.set(r.x*ut.x,r.y*ut.y,r.x*ut.z,r.y*ut.w),I.viewport(a)}if(q.isPointLight){const ut=H.camera,kt=H.matrix,qt=q.distance||ut.far;qt!==ut.far&&(ut.far=qt,ut.updateProjectionMatrix()),sr.setFromMatrixPosition(q.matrixWorld),ut.position.copy(sr),qo.copy(ut.position),qo.add(hv[it]),ut.up.copy(uv[it]),ut.lookAt(qo),ut.updateMatrixWorld(),kt.makeTranslation(-sr.x,-sr.y,-sr.z),Pu.multiplyMatrices(ut.projectionMatrix,ut.matrixWorldInverse),H._frustum.setFromProjectionMatrix(Pu,ut.coordinateSystem,ut.reversedDepth)}else H.updateMatrices(q);n=H.getFrustum(),M(R,v,H.camera,q,this.type)}H.isPointLightShadow!==!0&&this.type===lr&&A(H,v),H.needsUpdate=!1}p=this.type,m.needsUpdate=!1,i.setRenderTarget(E,D,C)};function A(b,R){const v=t.update(x);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,f.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new Rn(s.x,s.y,{format:$i,type:xn})),d.uniforms.shadow_pass.value=b.map.depthTexture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,i.setRenderTarget(b.mapPass),i.clear(),i.renderBufferDirect(R,null,v,d,x,null),f.uniforms.shadow_pass.value=b.mapPass.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,i.setRenderTarget(b.map),i.clear(),i.renderBufferDirect(R,null,v,f,x,null)}function T(b,R,v,E){let D=null;const C=v.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0)D=C;else if(D=v.isPointLight===!0?c:o,i.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){const I=D.uuid,W=R.uuid;let X=l[I];X===void 0&&(X={},l[I]=X);let U=X[W];U===void 0&&(U=D.clone(),X[W]=U,R.addEventListener("dispose",y)),D=U}if(D.visible=R.visible,D.wireframe=R.wireframe,E===lr?D.side=R.shadowSide!==null?R.shadowSide:R.side:D.side=R.shadowSide!==null?R.shadowSide:u[R.side],D.alphaMap=R.alphaMap,D.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,D.map=R.map,D.clipShadows=R.clipShadows,D.clippingPlanes=R.clippingPlanes,D.clipIntersection=R.clipIntersection,D.displacementMap=R.displacementMap,D.displacementScale=R.displacementScale,D.displacementBias=R.displacementBias,D.wireframeLinewidth=R.wireframeLinewidth,D.linewidth=R.linewidth,v.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const I=i.properties.get(D);I.light=v}return D}function M(b,R,v,E,D){if(b.visible===!1)return;if(b.layers.test(R.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&D===lr)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,b.matrixWorld);const W=t.update(b),X=b.material;if(Array.isArray(X)){const U=W.groups;for(let q=0,H=U.length;q<H;q++){const $=U[q],et=X[$.materialIndex];if(et&&et.visible){const j=T(b,et,E,D);b.onBeforeShadow(i,b,R,v,W,j,$),i.renderBufferDirect(v,null,W,j,b,$),b.onAfterShadow(i,b,R,v,W,j,$)}}}else if(X.visible){const U=T(b,X,E,D);b.onBeforeShadow(i,b,R,v,W,U,null),i.renderBufferDirect(v,null,W,U,b,null),b.onAfterShadow(i,b,R,v,W,U,null)}}const I=b.children;for(let W=0,X=I.length;W<X;W++)M(I[W],R,v,E,D)}function y(b){b.target.removeEventListener("dispose",y);for(const v in l){const E=l[v],D=b.target.uuid;D in E&&(E[D].dispose(),delete E[D])}}}function fv(i,t){function e(){let P=!1;const at=new pe;let J=null;const ht=new pe(0,0,0,0);return{setMask:function(gt){J!==gt&&!P&&(i.colorMask(gt,gt,gt,gt),J=gt)},setLocked:function(gt){P=gt},setClear:function(gt,tt,At,St,_e){_e===!0&&(gt*=St,tt*=St,At*=St),at.set(gt,tt,At,St),ht.equals(at)===!1&&(i.clearColor(gt,tt,At,St),ht.copy(at))},reset:function(){P=!1,J=null,ht.set(-1,0,0,0)}}}function n(){let P=!1,at=!1,J=null,ht=null,gt=null;return{setReversed:function(tt){if(at!==tt){const At=t.get("EXT_clip_control");tt?At.clipControlEXT(At.LOWER_LEFT_EXT,At.ZERO_TO_ONE_EXT):At.clipControlEXT(At.LOWER_LEFT_EXT,At.NEGATIVE_ONE_TO_ONE_EXT),at=tt;const St=gt;gt=null,this.setClear(St)}},getReversed:function(){return at},setTest:function(tt){tt?nt(i.DEPTH_TEST):z(i.DEPTH_TEST)},setMask:function(tt){J!==tt&&!P&&(i.depthMask(tt),J=tt)},setFunc:function(tt){if(at&&(tt=Hp[tt]),ht!==tt){switch(tt){case _c:i.depthFunc(i.NEVER);break;case vc:i.depthFunc(i.ALWAYS);break;case xc:i.depthFunc(i.LESS);break;case ks:i.depthFunc(i.LEQUAL);break;case Mc:i.depthFunc(i.EQUAL);break;case Sc:i.depthFunc(i.GEQUAL);break;case yc:i.depthFunc(i.GREATER);break;case Ec:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}ht=tt}},setLocked:function(tt){P=tt},setClear:function(tt){gt!==tt&&(gt=tt,at&&(tt=1-tt),i.clearDepth(tt))},reset:function(){P=!1,J=null,ht=null,gt=null,at=!1}}}function s(){let P=!1,at=null,J=null,ht=null,gt=null,tt=null,At=null,St=null,_e=null;return{setTest:function(oe){P||(oe?nt(i.STENCIL_TEST):z(i.STENCIL_TEST))},setMask:function(oe){at!==oe&&!P&&(i.stencilMask(oe),at=oe)},setFunc:function(oe,Dn,Pn){(J!==oe||ht!==Dn||gt!==Pn)&&(i.stencilFunc(oe,Dn,Pn),J=oe,ht=Dn,gt=Pn)},setOp:function(oe,Dn,Pn){(tt!==oe||At!==Dn||St!==Pn)&&(i.stencilOp(oe,Dn,Pn),tt=oe,At=Dn,St=Pn)},setLocked:function(oe){P=oe},setClear:function(oe){_e!==oe&&(i.clearStencil(oe),_e=oe)},reset:function(){P=!1,at=null,J=null,ht=null,gt=null,tt=null,At=null,St=null,_e=null}}}const r=new e,a=new n,o=new s,c=new WeakMap,l=new WeakMap;let h={},u={},d={},f=new WeakMap,g=[],x=null,m=!1,p=null,A=null,T=null,M=null,y=null,b=null,R=null,v=new Mt(0,0,0),E=0,D=!1,C=null,I=null,W=null,X=null,U=null;const q=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let H=!1,$=0;const et=i.getParameter(i.VERSION);et.indexOf("WebGL")!==-1?($=parseFloat(/^WebGL (\d)/.exec(et)[1]),H=$>=1):et.indexOf("OpenGL ES")!==-1&&($=parseFloat(/^OpenGL ES (\d)/.exec(et)[1]),H=$>=2);let j=null,it={};const ut=i.getParameter(i.SCISSOR_BOX),kt=i.getParameter(i.VIEWPORT),qt=new pe().fromArray(ut),Bt=new pe().fromArray(kt);function Y(P,at,J,ht){const gt=new Uint8Array(4),tt=i.createTexture();i.bindTexture(P,tt),i.texParameteri(P,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(P,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let At=0;At<J;At++)P===i.TEXTURE_3D||P===i.TEXTURE_2D_ARRAY?i.texImage3D(at,0,i.RGBA,1,1,ht,0,i.RGBA,i.UNSIGNED_BYTE,gt):i.texImage2D(at+At,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,gt);return tt}const rt={};rt[i.TEXTURE_2D]=Y(i.TEXTURE_2D,i.TEXTURE_2D,1),rt[i.TEXTURE_CUBE_MAP]=Y(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),rt[i.TEXTURE_2D_ARRAY]=Y(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),rt[i.TEXTURE_3D]=Y(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),nt(i.DEPTH_TEST),a.setFunc(ks),Jt(!1),Qt(Ph),nt(i.CULL_FACE),Lt(si);function nt(P){h[P]!==!0&&(i.enable(P),h[P]=!0)}function z(P){h[P]!==!1&&(i.disable(P),h[P]=!1)}function bt(P,at){return d[P]!==at?(i.bindFramebuffer(P,at),d[P]=at,P===i.DRAW_FRAMEBUFFER&&(d[i.FRAMEBUFFER]=at),P===i.FRAMEBUFFER&&(d[i.DRAW_FRAMEBUFFER]=at),!0):!1}function Dt(P,at){let J=g,ht=!1;if(P){J=f.get(at),J===void 0&&(J=[],f.set(at,J));const gt=P.textures;if(J.length!==gt.length||J[0]!==i.COLOR_ATTACHMENT0){for(let tt=0,At=gt.length;tt<At;tt++)J[tt]=i.COLOR_ATTACHMENT0+tt;J.length=gt.length,ht=!0}}else J[0]!==i.BACK&&(J[0]=i.BACK,ht=!0);ht&&i.drawBuffers(J)}function Tt(P){return x!==P?(i.useProgram(P),x=P,!0):!1}const vt={[Gi]:i.FUNC_ADD,[up]:i.FUNC_SUBTRACT,[dp]:i.FUNC_REVERSE_SUBTRACT};vt[fp]=i.MIN,vt[pp]=i.MAX;const It={[mp]:i.ZERO,[gp]:i.ONE,[_p]:i.SRC_COLOR,[mc]:i.SRC_ALPHA,[Ep]:i.SRC_ALPHA_SATURATE,[Sp]:i.DST_COLOR,[xp]:i.DST_ALPHA,[vp]:i.ONE_MINUS_SRC_COLOR,[gc]:i.ONE_MINUS_SRC_ALPHA,[yp]:i.ONE_MINUS_DST_COLOR,[Mp]:i.ONE_MINUS_DST_ALPHA,[bp]:i.CONSTANT_COLOR,[Ap]:i.ONE_MINUS_CONSTANT_COLOR,[Tp]:i.CONSTANT_ALPHA,[wp]:i.ONE_MINUS_CONSTANT_ALPHA};function Lt(P,at,J,ht,gt,tt,At,St,_e,oe){if(P===si){m===!0&&(z(i.BLEND),m=!1);return}if(m===!1&&(nt(i.BLEND),m=!0),P!==hp){if(P!==p||oe!==D){if((A!==Gi||y!==Gi)&&(i.blendEquation(i.FUNC_ADD),A=Gi,y=Gi),oe)switch(P){case Is:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Ri:i.blendFunc(i.ONE,i.ONE);break;case Ih:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Lh:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Yt("WebGLState: Invalid blending: ",P);break}else switch(P){case Is:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Ri:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case Ih:Yt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Lh:Yt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Yt("WebGLState: Invalid blending: ",P);break}T=null,M=null,b=null,R=null,v.set(0,0,0),E=0,p=P,D=oe}return}gt=gt||at,tt=tt||J,At=At||ht,(at!==A||gt!==y)&&(i.blendEquationSeparate(vt[at],vt[gt]),A=at,y=gt),(J!==T||ht!==M||tt!==b||At!==R)&&(i.blendFuncSeparate(It[J],It[ht],It[tt],It[At]),T=J,M=ht,b=tt,R=At),(St.equals(v)===!1||_e!==E)&&(i.blendColor(St.r,St.g,St.b,_e),v.copy(St),E=_e),p=P,D=!1}function Nt(P,at){P.side===An?z(i.CULL_FACE):nt(i.CULL_FACE);let J=P.side===Ce;at&&(J=!J),Jt(J),P.blending===Is&&P.transparent===!1?Lt(si):Lt(P.blending,P.blendEquation,P.blendSrc,P.blendDst,P.blendEquationAlpha,P.blendSrcAlpha,P.blendDstAlpha,P.blendColor,P.blendAlpha,P.premultipliedAlpha),a.setFunc(P.depthFunc),a.setTest(P.depthTest),a.setMask(P.depthWrite),r.setMask(P.colorWrite);const ht=P.stencilWrite;o.setTest(ht),ht&&(o.setMask(P.stencilWriteMask),o.setFunc(P.stencilFunc,P.stencilRef,P.stencilFuncMask),o.setOp(P.stencilFail,P.stencilZFail,P.stencilZPass)),de(P.polygonOffset,P.polygonOffsetFactor,P.polygonOffsetUnits),P.alphaToCoverage===!0?nt(i.SAMPLE_ALPHA_TO_COVERAGE):z(i.SAMPLE_ALPHA_TO_COVERAGE)}function Jt(P){C!==P&&(P?i.frontFace(i.CW):i.frontFace(i.CCW),C=P)}function Qt(P){P!==op?(nt(i.CULL_FACE),P!==I&&(P===Ph?i.cullFace(i.BACK):P===cp?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):z(i.CULL_FACE),I=P}function me(P){P!==W&&(H&&i.lineWidth(P),W=P)}function de(P,at,J){P?(nt(i.POLYGON_OFFSET_FILL),(X!==at||U!==J)&&(X=at,U=J,a.getReversed()&&(at=-at),i.polygonOffset(at,J))):z(i.POLYGON_OFFSET_FILL)}function ge(P){P?nt(i.SCISSOR_TEST):z(i.SCISSOR_TEST)}function be(P){P===void 0&&(P=i.TEXTURE0+q-1),j!==P&&(i.activeTexture(P),j=P)}function L(P,at,J){J===void 0&&(j===null?J=i.TEXTURE0+q-1:J=j);let ht=it[J];ht===void 0&&(ht={type:void 0,texture:void 0},it[J]=ht),(ht.type!==P||ht.texture!==at)&&(j!==J&&(i.activeTexture(J),j=J),i.bindTexture(P,at||rt[P]),ht.type=P,ht.texture=at)}function Je(){const P=it[j];P!==void 0&&P.type!==void 0&&(i.bindTexture(P.type,null),P.type=void 0,P.texture=void 0)}function jt(){try{i.compressedTexImage2D(...arguments)}catch(P){Yt("WebGLState:",P)}}function w(){try{i.compressedTexImage3D(...arguments)}catch(P){Yt("WebGLState:",P)}}function _(){try{i.texSubImage2D(...arguments)}catch(P){Yt("WebGLState:",P)}}function O(){try{i.texSubImage3D(...arguments)}catch(P){Yt("WebGLState:",P)}}function G(){try{i.compressedTexSubImage2D(...arguments)}catch(P){Yt("WebGLState:",P)}}function K(){try{i.compressedTexSubImage3D(...arguments)}catch(P){Yt("WebGLState:",P)}}function st(){try{i.texStorage2D(...arguments)}catch(P){Yt("WebGLState:",P)}}function ot(){try{i.texStorage3D(...arguments)}catch(P){Yt("WebGLState:",P)}}function Z(){try{i.texImage2D(...arguments)}catch(P){Yt("WebGLState:",P)}}function Q(){try{i.texImage3D(...arguments)}catch(P){Yt("WebGLState:",P)}}function ct(P){return u[P]!==void 0?u[P]:i.getParameter(P)}function wt(P,at){u[P]!==at&&(i.pixelStorei(P,at),u[P]=at)}function dt(P){qt.equals(P)===!1&&(i.scissor(P.x,P.y,P.z,P.w),qt.copy(P))}function lt(P){Bt.equals(P)===!1&&(i.viewport(P.x,P.y,P.z,P.w),Bt.copy(P))}function Pt(P,at){let J=l.get(at);J===void 0&&(J=new WeakMap,l.set(at,J));let ht=J.get(P);ht===void 0&&(ht=i.getUniformBlockIndex(at,P.name),J.set(P,ht))}function Ut(P,at){const ht=l.get(at).get(P);c.get(at)!==ht&&(i.uniformBlockBinding(at,ht,P.__bindingPointIndex),c.set(at,ht))}function Gt(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),i.pixelStorei(i.PACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),i.pixelStorei(i.PACK_ROW_LENGTH,0),i.pixelStorei(i.PACK_SKIP_PIXELS,0),i.pixelStorei(i.PACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_ROW_LENGTH,0),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,0),i.pixelStorei(i.UNPACK_SKIP_PIXELS,0),i.pixelStorei(i.UNPACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_SKIP_IMAGES,0),h={},u={},j=null,it={},d={},f=new WeakMap,g=[],x=null,m=!1,p=null,A=null,T=null,M=null,y=null,b=null,R=null,v=new Mt(0,0,0),E=0,D=!1,C=null,I=null,W=null,X=null,U=null,qt.set(0,0,i.canvas.width,i.canvas.height),Bt.set(0,0,i.canvas.width,i.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:nt,disable:z,bindFramebuffer:bt,drawBuffers:Dt,useProgram:Tt,setBlending:Lt,setMaterial:Nt,setFlipSided:Jt,setCullFace:Qt,setLineWidth:me,setPolygonOffset:de,setScissorTest:ge,activeTexture:be,bindTexture:L,unbindTexture:Je,compressedTexImage2D:jt,compressedTexImage3D:w,texImage2D:Z,texImage3D:Q,pixelStorei:wt,getParameter:ct,updateUBOMapping:Pt,uniformBlockBinding:Ut,texStorage2D:st,texStorage3D:ot,texSubImage2D:_,texSubImage3D:O,compressedTexSubImage2D:G,compressedTexSubImage3D:K,scissor:dt,viewport:lt,reset:Gt}}function pv(i,t,e,n,s,r,a){const 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 Ft,h=new WeakMap,u=new Set;let d;const f=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(w,_){return g?new OffscreenCanvas(w,_):Ba("canvas")}function m(w,_,O){let G=1;const K=jt(w);if((K.width>O||K.height>O)&&(G=O/Math.max(K.width,K.height)),G<1)if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&w instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&w instanceof ImageBitmap||typeof VideoFrame<"u"&&w instanceof VideoFrame){const st=Math.floor(G*K.width),ot=Math.floor(G*K.height);d===void 0&&(d=x(st,ot));const Z=_?x(st,ot):d;return Z.width=st,Z.height=ot,Z.getContext("2d").drawImage(w,0,0,st,ot),Ot("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+st+"x"+ot+")."),Z}else return"data"in w&&Ot("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),w;return w}function p(w){return w.generateMipmaps}function A(w){i.generateMipmap(w)}function T(w){return w.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:w.isWebGL3DRenderTarget?i.TEXTURE_3D:w.isWebGLArrayRenderTarget||w.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function M(w,_,O,G,K,st=!1){if(w!==null){if(i[w]!==void 0)return i[w];Ot("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+w+"'")}let ot;G&&(ot=t.get("EXT_texture_norm16"),ot||Ot("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Z=_;if(_===i.RED&&(O===i.FLOAT&&(Z=i.R32F),O===i.HALF_FLOAT&&(Z=i.R16F),O===i.UNSIGNED_BYTE&&(Z=i.R8),O===i.UNSIGNED_SHORT&&ot&&(Z=ot.R16_EXT),O===i.SHORT&&ot&&(Z=ot.R16_SNORM_EXT)),_===i.RED_INTEGER&&(O===i.UNSIGNED_BYTE&&(Z=i.R8UI),O===i.UNSIGNED_SHORT&&(Z=i.R16UI),O===i.UNSIGNED_INT&&(Z=i.R32UI),O===i.BYTE&&(Z=i.R8I),O===i.SHORT&&(Z=i.R16I),O===i.INT&&(Z=i.R32I)),_===i.RG&&(O===i.FLOAT&&(Z=i.RG32F),O===i.HALF_FLOAT&&(Z=i.RG16F),O===i.UNSIGNED_BYTE&&(Z=i.RG8),O===i.UNSIGNED_SHORT&&ot&&(Z=ot.RG16_EXT),O===i.SHORT&&ot&&(Z=ot.RG16_SNORM_EXT)),_===i.RG_INTEGER&&(O===i.UNSIGNED_BYTE&&(Z=i.RG8UI),O===i.UNSIGNED_SHORT&&(Z=i.RG16UI),O===i.UNSIGNED_INT&&(Z=i.RG32UI),O===i.BYTE&&(Z=i.RG8I),O===i.SHORT&&(Z=i.RG16I),O===i.INT&&(Z=i.RG32I)),_===i.RGB_INTEGER&&(O===i.UNSIGNED_BYTE&&(Z=i.RGB8UI),O===i.UNSIGNED_SHORT&&(Z=i.RGB16UI),O===i.UNSIGNED_INT&&(Z=i.RGB32UI),O===i.BYTE&&(Z=i.RGB8I),O===i.SHORT&&(Z=i.RGB16I),O===i.INT&&(Z=i.RGB32I)),_===i.RGBA_INTEGER&&(O===i.UNSIGNED_BYTE&&(Z=i.RGBA8UI),O===i.UNSIGNED_SHORT&&(Z=i.RGBA16UI),O===i.UNSIGNED_INT&&(Z=i.RGBA32UI),O===i.BYTE&&(Z=i.RGBA8I),O===i.SHORT&&(Z=i.RGBA16I),O===i.INT&&(Z=i.RGBA32I)),_===i.RGB&&(O===i.UNSIGNED_SHORT&&ot&&(Z=ot.RGB16_EXT),O===i.SHORT&&ot&&(Z=ot.RGB16_SNORM_EXT),O===i.UNSIGNED_INT_5_9_9_9_REV&&(Z=i.RGB9_E5),O===i.UNSIGNED_INT_10F_11F_11F_REV&&(Z=i.R11F_G11F_B10F)),_===i.RGBA){const Q=st?za:Kt.getTransfer(K);O===i.FLOAT&&(Z=i.RGBA32F),O===i.HALF_FLOAT&&(Z=i.RGBA16F),O===i.UNSIGNED_BYTE&&(Z=Q===te?i.SRGB8_ALPHA8:i.RGBA8),O===i.UNSIGNED_SHORT&&ot&&(Z=ot.RGBA16_EXT),O===i.SHORT&&ot&&(Z=ot.RGBA16_SNORM_EXT),O===i.UNSIGNED_SHORT_4_4_4_4&&(Z=i.RGBA4),O===i.UNSIGNED_SHORT_5_5_5_1&&(Z=i.RGB5_A1)}return(Z===i.R16F||Z===i.R32F||Z===i.RG16F||Z===i.RG32F||Z===i.RGBA16F||Z===i.RGBA32F)&&t.get("EXT_color_buffer_float"),Z}function y(w,_){let O;return w?_===null||_===Kn||_===yr?O=i.DEPTH24_STENCIL8:_===Vn?O=i.DEPTH32F_STENCIL8:_===Sr&&(O=i.DEPTH24_STENCIL8,Ot("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===Kn||_===yr?O=i.DEPTH_COMPONENT24:_===Vn?O=i.DEPTH_COMPONENT32F:_===Sr&&(O=i.DEPTH_COMPONENT16),O}function b(w,_){return p(w)===!0||w.isFramebufferTexture&&w.minFilter!==ke&&w.minFilter!==we?Math.log2(Math.max(_.width,_.height))+1:w.mipmaps!==void 0&&w.mipmaps.length>0?w.mipmaps.length:w.isCompressedTexture&&Array.isArray(w.image)?_.mipmaps.length:1}function R(w){const _=w.target;_.removeEventListener("dispose",R),E(_),_.isVideoTexture&&h.delete(_),_.isHTMLTexture&&u.delete(_)}function v(w){const _=w.target;_.removeEventListener("dispose",v),C(_)}function E(w){const _=n.get(w);if(_.__webglInit===void 0)return;const O=w.source,G=f.get(O);if(G){const K=G[_.__cacheKey];K.usedTimes--,K.usedTimes===0&&D(w),Object.keys(G).length===0&&f.delete(O)}n.remove(w)}function D(w){const _=n.get(w);i.deleteTexture(_.__webglTexture);const O=w.source,G=f.get(O);delete G[_.__cacheKey],a.memory.textures--}function C(w){const _=n.get(w);if(w.depthTexture&&(w.depthTexture.dispose(),n.remove(w.depthTexture)),w.isWebGLCubeRenderTarget)for(let G=0;G<6;G++){if(Array.isArray(_.__webglFramebuffer[G]))for(let K=0;K<_.__webglFramebuffer[G].length;K++)i.deleteFramebuffer(_.__webglFramebuffer[G][K]);else i.deleteFramebuffer(_.__webglFramebuffer[G]);_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer[G])}else{if(Array.isArray(_.__webglFramebuffer))for(let G=0;G<_.__webglFramebuffer.length;G++)i.deleteFramebuffer(_.__webglFramebuffer[G]);else i.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&i.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let G=0;G<_.__webglColorRenderbuffer.length;G++)_.__webglColorRenderbuffer[G]&&i.deleteRenderbuffer(_.__webglColorRenderbuffer[G]);_.__webglDepthRenderbuffer&&i.deleteRenderbuffer(_.__webglDepthRenderbuffer)}const O=w.textures;for(let G=0,K=O.length;G<K;G++){const st=n.get(O[G]);st.__webglTexture&&(i.deleteTexture(st.__webglTexture),a.memory.textures--),n.remove(O[G])}n.remove(w)}let I=0;function W(){I=0}function X(){return I}function U(w){I=w}function q(){const w=I;return w>=s.maxTextures&&Ot("WebGLTextures: Trying to use "+w+" texture units while this GPU supports only "+s.maxTextures),I+=1,w}function H(w){const _=[];return _.push(w.wrapS),_.push(w.wrapT),_.push(w.wrapR||0),_.push(w.magFilter),_.push(w.minFilter),_.push(w.anisotropy),_.push(w.internalFormat),_.push(w.format),_.push(w.type),_.push(w.generateMipmaps),_.push(w.premultiplyAlpha),_.push(w.flipY),_.push(w.unpackAlignment),_.push(w.colorSpace),_.join()}function $(w,_){const O=n.get(w);if(w.isVideoTexture&&L(w),w.isRenderTargetTexture===!1&&w.isExternalTexture!==!0&&w.version>0&&O.__version!==w.version){const G=w.image;if(G===null)Ot("WebGLRenderer: Texture marked for update but no image data found.");else if(G.complete===!1)Ot("WebGLRenderer: Texture marked for update but image is incomplete");else{z(O,w,_);return}}else w.isExternalTexture&&(O.__webglTexture=w.sourceTexture?w.sourceTexture:null);e.bindTexture(i.TEXTURE_2D,O.__webglTexture,i.TEXTURE0+_)}function et(w,_){const O=n.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&O.__version!==w.version){z(O,w,_);return}else w.isExternalTexture&&(O.__webglTexture=w.sourceTexture?w.sourceTexture:null);e.bindTexture(i.TEXTURE_2D_ARRAY,O.__webglTexture,i.TEXTURE0+_)}function j(w,_){const O=n.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&O.__version!==w.version){z(O,w,_);return}e.bindTexture(i.TEXTURE_3D,O.__webglTexture,i.TEXTURE0+_)}function it(w,_){const O=n.get(w);if(w.isCubeDepthTexture!==!0&&w.version>0&&O.__version!==w.version){bt(O,w,_);return}e.bindTexture(i.TEXTURE_CUBE_MAP,O.__webglTexture,i.TEXTURE0+_)}const ut={[bc]:i.REPEAT,[hn]:i.CLAMP_TO_EDGE,[Ac]:i.MIRRORED_REPEAT},kt={[ke]:i.NEAREST,[Dp]:i.NEAREST_MIPMAP_NEAREST,[Fr]:i.NEAREST_MIPMAP_LINEAR,[we]:i.LINEAR,[fo]:i.LINEAR_MIPMAP_NEAREST,[Xi]:i.LINEAR_MIPMAP_LINEAR},qt={[Lp]:i.NEVER,[zp]:i.ALWAYS,[Np]:i.LESS,[Vl]:i.LEQUAL,[Up]:i.EQUAL,[Wl]:i.GEQUAL,[Fp]:i.GREATER,[Op]:i.NOTEQUAL};function Bt(w,_){if(_.type===Vn&&t.has("OES_texture_float_linear")===!1&&(_.magFilter===we||_.magFilter===fo||_.magFilter===Fr||_.magFilter===Xi||_.minFilter===we||_.minFilter===fo||_.minFilter===Fr||_.minFilter===Xi)&&Ot("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(w,i.TEXTURE_WRAP_S,ut[_.wrapS]),i.texParameteri(w,i.TEXTURE_WRAP_T,ut[_.wrapT]),(w===i.TEXTURE_3D||w===i.TEXTURE_2D_ARRAY)&&i.texParameteri(w,i.TEXTURE_WRAP_R,ut[_.wrapR]),i.texParameteri(w,i.TEXTURE_MAG_FILTER,kt[_.magFilter]),i.texParameteri(w,i.TEXTURE_MIN_FILTER,kt[_.minFilter]),_.compareFunction&&(i.texParameteri(w,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(w,i.TEXTURE_COMPARE_FUNC,qt[_.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===ke||_.minFilter!==Fr&&_.minFilter!==Xi||_.type===Vn&&t.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||n.get(_).__currentAnisotropy){const O=t.get("EXT_texture_filter_anisotropic");i.texParameterf(w,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,s.getMaxAnisotropy())),n.get(_).__currentAnisotropy=_.anisotropy}}}function Y(w,_){let O=!1;w.__webglInit===void 0&&(w.__webglInit=!0,_.addEventListener("dispose",R));const G=_.source;let K=f.get(G);K===void 0&&(K={},f.set(G,K));const st=H(_);if(st!==w.__cacheKey){K[st]===void 0&&(K[st]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,O=!0),K[st].usedTimes++;const ot=K[w.__cacheKey];ot!==void 0&&(K[w.__cacheKey].usedTimes--,ot.usedTimes===0&&D(_)),w.__cacheKey=st,w.__webglTexture=K[st].texture}return O}function rt(w,_,O){return Math.floor(Math.floor(w/O)/_)}function nt(w,_,O,G){const st=w.updateRanges;if(st.length===0)e.texSubImage2D(i.TEXTURE_2D,0,0,0,_.width,_.height,O,G,_.data);else{st.sort((wt,dt)=>wt.start-dt.start);let ot=0;for(let wt=1;wt<st.length;wt++){const dt=st[ot],lt=st[wt],Pt=dt.start+dt.count,Ut=rt(lt.start,_.width,4),Gt=rt(dt.start,_.width,4);lt.start<=Pt+1&&Ut===Gt&&rt(lt.start+lt.count-1,_.width,4)===Ut?dt.count=Math.max(dt.count,lt.start+lt.count-dt.start):(++ot,st[ot]=lt)}st.length=ot+1;const Z=e.getParameter(i.UNPACK_ROW_LENGTH),Q=e.getParameter(i.UNPACK_SKIP_PIXELS),ct=e.getParameter(i.UNPACK_SKIP_ROWS);e.pixelStorei(i.UNPACK_ROW_LENGTH,_.width);for(let wt=0,dt=st.length;wt<dt;wt++){const lt=st[wt],Pt=Math.floor(lt.start/4),Ut=Math.ceil(lt.count/4),Gt=Pt%_.width,P=Math.floor(Pt/_.width),at=Ut,J=1;e.pixelStorei(i.UNPACK_SKIP_PIXELS,Gt),e.pixelStorei(i.UNPACK_SKIP_ROWS,P),e.texSubImage2D(i.TEXTURE_2D,0,Gt,P,at,J,O,G,_.data)}w.clearUpdateRanges(),e.pixelStorei(i.UNPACK_ROW_LENGTH,Z),e.pixelStorei(i.UNPACK_SKIP_PIXELS,Q),e.pixelStorei(i.UNPACK_SKIP_ROWS,ct)}}function z(w,_,O){let G=i.TEXTURE_2D;(_.isDataArrayTexture||_.isCompressedArrayTexture)&&(G=i.TEXTURE_2D_ARRAY),_.isData3DTexture&&(G=i.TEXTURE_3D);const K=Y(w,_),st=_.source;e.bindTexture(G,w.__webglTexture,i.TEXTURE0+O);const ot=n.get(st);if(st.version!==ot.__version||K===!0){if(e.activeTexture(i.TEXTURE0+O),(typeof ImageBitmap<"u"&&_.image instanceof ImageBitmap)===!1){const J=Kt.getPrimaries(Kt.workingColorSpace),ht=_.colorSpace===yi?null:Kt.getPrimaries(_.colorSpace),gt=_.colorSpace===yi||J===ht?i.NONE:i.BROWSER_DEFAULT_WEBGL;e.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),e.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),e.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,gt)}e.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment);let Q=m(_.image,!1,s.maxTextureSize);Q=Je(_,Q);const ct=r.convert(_.format,_.colorSpace),wt=r.convert(_.type);let dt=M(_.internalFormat,ct,wt,_.normalized,_.colorSpace,_.isVideoTexture);Bt(G,_);let lt;const Pt=_.mipmaps,Ut=_.isVideoTexture!==!0,Gt=ot.__version===void 0||K===!0,P=st.dataReady,at=b(_,Q);if(_.isDepthTexture)dt=y(_.format===qi,_.type),Gt&&(Ut?e.texStorage2D(i.TEXTURE_2D,1,dt,Q.width,Q.height):e.texImage2D(i.TEXTURE_2D,0,dt,Q.width,Q.height,0,ct,wt,null));else if(_.isDataTexture)if(Pt.length>0){Ut&&Gt&&e.texStorage2D(i.TEXTURE_2D,at,dt,Pt[0].width,Pt[0].height);for(let J=0,ht=Pt.length;J<ht;J++)lt=Pt[J],Ut?P&&e.texSubImage2D(i.TEXTURE_2D,J,0,0,lt.width,lt.height,ct,wt,lt.data):e.texImage2D(i.TEXTURE_2D,J,dt,lt.width,lt.height,0,ct,wt,lt.data);_.generateMipmaps=!1}else Ut?(Gt&&e.texStorage2D(i.TEXTURE_2D,at,dt,Q.width,Q.height),P&&nt(_,Q,ct,wt)):e.texImage2D(i.TEXTURE_2D,0,dt,Q.width,Q.height,0,ct,wt,Q.data);else if(_.isCompressedTexture)if(_.isCompressedArrayTexture){Ut&&Gt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,at,dt,Pt[0].width,Pt[0].height,Q.depth);for(let J=0,ht=Pt.length;J<ht;J++)if(lt=Pt[J],_.format!==un)if(ct!==null)if(Ut){if(P)if(_.layerUpdates.size>0){const gt=cu(lt.width,lt.height,_.format,_.type);for(const tt of _.layerUpdates){const At=lt.data.subarray(tt*gt/lt.data.BYTES_PER_ELEMENT,(tt+1)*gt/lt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,tt,lt.width,lt.height,1,ct,At)}_.clearLayerUpdates()}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,lt.width,lt.height,Q.depth,ct,lt.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,J,dt,lt.width,lt.height,Q.depth,0,lt.data,0,0);else Ot("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ut?P&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,lt.width,lt.height,Q.depth,ct,wt,lt.data):e.texImage3D(i.TEXTURE_2D_ARRAY,J,dt,lt.width,lt.height,Q.depth,0,ct,wt,lt.data)}else{Ut&&Gt&&e.texStorage2D(i.TEXTURE_2D,at,dt,Pt[0].width,Pt[0].height);for(let J=0,ht=Pt.length;J<ht;J++)lt=Pt[J],_.format!==un?ct!==null?Ut?P&&e.compressedTexSubImage2D(i.TEXTURE_2D,J,0,0,lt.width,lt.height,ct,lt.data):e.compressedTexImage2D(i.TEXTURE_2D,J,dt,lt.width,lt.height,0,lt.data):Ot("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ut?P&&e.texSubImage2D(i.TEXTURE_2D,J,0,0,lt.width,lt.height,ct,wt,lt.data):e.texImage2D(i.TEXTURE_2D,J,dt,lt.width,lt.height,0,ct,wt,lt.data)}else if(_.isDataArrayTexture)if(Ut){if(Gt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,at,dt,Q.width,Q.height,Q.depth),P)if(_.layerUpdates.size>0){const J=cu(Q.width,Q.height,_.format,_.type);for(const ht of _.layerUpdates){const gt=Q.data.subarray(ht*J/Q.data.BYTES_PER_ELEMENT,(ht+1)*J/Q.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,ht,Q.width,Q.height,1,ct,wt,gt)}_.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,ct,wt,Q.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,dt,Q.width,Q.height,Q.depth,0,ct,wt,Q.data);else if(_.isData3DTexture)Ut?(Gt&&e.texStorage3D(i.TEXTURE_3D,at,dt,Q.width,Q.height,Q.depth),P&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,ct,wt,Q.data)):e.texImage3D(i.TEXTURE_3D,0,dt,Q.width,Q.height,Q.depth,0,ct,wt,Q.data);else if(_.isFramebufferTexture){if(Gt)if(Ut)e.texStorage2D(i.TEXTURE_2D,at,dt,Q.width,Q.height);else{let J=Q.width,ht=Q.height;for(let gt=0;gt<at;gt++)e.texImage2D(i.TEXTURE_2D,gt,dt,J,ht,0,ct,wt,null),J>>=1,ht>>=1}}else if(_.isHTMLTexture){if("texElementImage2D"in i){const J=i.canvas;if(J.hasAttribute("layoutsubtree")||J.setAttribute("layoutsubtree","true"),Q.parentNode!==J){J.appendChild(Q),u.add(_),J.onpaint=ht=>{const gt=ht.changedElements;for(const tt of u)gt.includes(tt.image)&&(tt.needsUpdate=!0)},J.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,Q);else{const gt=i.RGBA,tt=i.RGBA,At=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,gt,tt,At,Q)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(Pt.length>0){if(Ut&&Gt){const J=jt(Pt[0]);e.texStorage2D(i.TEXTURE_2D,at,dt,J.width,J.height)}for(let J=0,ht=Pt.length;J<ht;J++)lt=Pt[J],Ut?P&&e.texSubImage2D(i.TEXTURE_2D,J,0,0,ct,wt,lt):e.texImage2D(i.TEXTURE_2D,J,dt,ct,wt,lt);_.generateMipmaps=!1}else if(Ut){if(Gt){const J=jt(Q);e.texStorage2D(i.TEXTURE_2D,at,dt,J.width,J.height)}P&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,ct,wt,Q)}else e.texImage2D(i.TEXTURE_2D,0,dt,ct,wt,Q);p(_)&&A(G),ot.__version=st.version,_.onUpdate&&_.onUpdate(_)}w.__version=_.version}function bt(w,_,O){if(_.image.length!==6)return;const G=Y(w,_),K=_.source;e.bindTexture(i.TEXTURE_CUBE_MAP,w.__webglTexture,i.TEXTURE0+O);const st=n.get(K);if(K.version!==st.__version||G===!0){e.activeTexture(i.TEXTURE0+O);const ot=Kt.getPrimaries(Kt.workingColorSpace),Z=_.colorSpace===yi?null:Kt.getPrimaries(_.colorSpace),Q=_.colorSpace===yi||ot===Z?i.NONE:i.BROWSER_DEFAULT_WEBGL;e.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),e.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),e.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),e.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);const ct=_.isCompressedTexture||_.image[0].isCompressedTexture,wt=_.image[0]&&_.image[0].isDataTexture,dt=[];for(let tt=0;tt<6;tt++)!ct&&!wt?dt[tt]=m(_.image[tt],!0,s.maxCubemapSize):dt[tt]=wt?_.image[tt].image:_.image[tt],dt[tt]=Je(_,dt[tt]);const lt=dt[0],Pt=r.convert(_.format,_.colorSpace),Ut=r.convert(_.type),Gt=M(_.internalFormat,Pt,Ut,_.normalized,_.colorSpace),P=_.isVideoTexture!==!0,at=st.__version===void 0||G===!0,J=K.dataReady;let ht=b(_,lt);Bt(i.TEXTURE_CUBE_MAP,_);let gt;if(ct){P&&at&&e.texStorage2D(i.TEXTURE_CUBE_MAP,ht,Gt,lt.width,lt.height);for(let tt=0;tt<6;tt++){gt=dt[tt].mipmaps;for(let At=0;At<gt.length;At++){const St=gt[At];_.format!==un?Pt!==null?P?J&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At,0,0,St.width,St.height,Pt,St.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At,Gt,St.width,St.height,0,St.data):Ot("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):P?J&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At,0,0,St.width,St.height,Pt,Ut,St.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At,Gt,St.width,St.height,0,Pt,Ut,St.data)}}}else{if(gt=_.mipmaps,P&&at){gt.length>0&&ht++;const tt=jt(dt[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,ht,Gt,tt.width,tt.height)}for(let tt=0;tt<6;tt++)if(wt){P?J&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,0,0,dt[tt].width,dt[tt].height,Pt,Ut,dt[tt].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,Gt,dt[tt].width,dt[tt].height,0,Pt,Ut,dt[tt].data);for(let At=0;At<gt.length;At++){const _e=gt[At].image[tt].image;P?J&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At+1,0,0,_e.width,_e.height,Pt,Ut,_e.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At+1,Gt,_e.width,_e.height,0,Pt,Ut,_e.data)}}else{P?J&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,0,0,Pt,Ut,dt[tt]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,Gt,Pt,Ut,dt[tt]);for(let At=0;At<gt.length;At++){const St=gt[At];P?J&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At+1,0,0,Pt,Ut,St.image[tt]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At+1,Gt,Pt,Ut,St.image[tt])}}}p(_)&&A(i.TEXTURE_CUBE_MAP),st.__version=K.version,_.onUpdate&&_.onUpdate(_)}w.__version=_.version}function Dt(w,_,O,G,K,st){const ot=r.convert(O.format,O.colorSpace),Z=r.convert(O.type),Q=M(O.internalFormat,ot,Z,O.normalized,O.colorSpace),ct=n.get(_),wt=n.get(O);if(wt.__renderTarget=_,!ct.__hasExternalTextures){const dt=Math.max(1,_.width>>st),lt=Math.max(1,_.height>>st);K===i.TEXTURE_3D||K===i.TEXTURE_2D_ARRAY?e.texImage3D(K,st,Q,dt,lt,_.depth,0,ot,Z,null):e.texImage2D(K,st,Q,dt,lt,0,ot,Z,null)}e.bindFramebuffer(i.FRAMEBUFFER,w),be(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,G,K,wt.__webglTexture,0,ge(_)):(K===i.TEXTURE_2D||K>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,G,K,wt.__webglTexture,st),e.bindFramebuffer(i.FRAMEBUFFER,null)}function Tt(w,_,O){if(i.bindRenderbuffer(i.RENDERBUFFER,w),_.depthBuffer){const G=_.depthTexture,K=G&&G.isDepthTexture?G.type:null,st=y(_.stencilBuffer,K),ot=_.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;be(_)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ge(_),st,_.width,_.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,ge(_),st,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,st,_.width,_.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ot,i.RENDERBUFFER,w)}else{const G=_.textures;for(let K=0;K<G.length;K++){const st=G[K],ot=r.convert(st.format,st.colorSpace),Z=r.convert(st.type),Q=M(st.internalFormat,ot,Z,st.normalized,st.colorSpace);be(_)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ge(_),Q,_.width,_.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,ge(_),Q,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,Q,_.width,_.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function vt(w,_,O){const G=_.isWebGLCubeRenderTarget===!0;if(e.bindFramebuffer(i.FRAMEBUFFER,w),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const K=n.get(_.depthTexture);if(K.__renderTarget=_,(!K.__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)&&(_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0),G){if(K.__webglInit===void 0&&(K.__webglInit=!0,_.depthTexture.addEventListener("dispose",R)),K.__webglTexture===void 0){K.__webglTexture=i.createTexture(),e.bindTexture(i.TEXTURE_CUBE_MAP,K.__webglTexture),Bt(i.TEXTURE_CUBE_MAP,_.depthTexture);const ct=r.convert(_.depthTexture.format),wt=r.convert(_.depthTexture.type);let dt;_.depthTexture.format===ai?dt=i.DEPTH_COMPONENT24:_.depthTexture.format===qi&&(dt=i.DEPTH24_STENCIL8);for(let lt=0;lt<6;lt++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+lt,0,dt,_.width,_.height,0,ct,wt,null)}}else $(_.depthTexture,0);const st=K.__webglTexture,ot=ge(_),Z=G?i.TEXTURE_CUBE_MAP_POSITIVE_X+O:i.TEXTURE_2D,Q=_.depthTexture.format===qi?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(_.depthTexture.format===ai)be(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Q,Z,st,0,ot):i.framebufferTexture2D(i.FRAMEBUFFER,Q,Z,st,0);else if(_.depthTexture.format===qi)be(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Q,Z,st,0,ot):i.framebufferTexture2D(i.FRAMEBUFFER,Q,Z,st,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function It(w){const _=n.get(w),O=w.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==w.depthTexture){const G=w.depthTexture;if(_.__depthDisposeCallback&&_.__depthDisposeCallback(),G){const K=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,G.removeEventListener("dispose",K)};G.addEventListener("dispose",K),_.__depthDisposeCallback=K}_.__boundDepthTexture=G}if(w.depthTexture&&!_.__autoAllocateDepthBuffer)if(O)for(let G=0;G<6;G++)vt(_.__webglFramebuffer[G],w,G);else{const G=w.texture.mipmaps;G&&G.length>0?vt(_.__webglFramebuffer[0],w,0):vt(_.__webglFramebuffer,w,0)}else if(O){_.__webglDepthbuffer=[];for(let G=0;G<6;G++)if(e.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[G]),_.__webglDepthbuffer[G]===void 0)_.__webglDepthbuffer[G]=i.createRenderbuffer(),Tt(_.__webglDepthbuffer[G],w,!1);else{const K=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,st=_.__webglDepthbuffer[G];i.bindRenderbuffer(i.RENDERBUFFER,st),i.framebufferRenderbuffer(i.FRAMEBUFFER,K,i.RENDERBUFFER,st)}}else{const G=w.texture.mipmaps;if(G&&G.length>0?e.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[0]):e.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=i.createRenderbuffer(),Tt(_.__webglDepthbuffer,w,!1);else{const K=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,st=_.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,st),i.framebufferRenderbuffer(i.FRAMEBUFFER,K,i.RENDERBUFFER,st)}}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Lt(w,_,O){const G=n.get(w);_!==void 0&&Dt(G.__webglFramebuffer,w,w.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),O!==void 0&&It(w)}function Nt(w){const _=w.texture,O=n.get(w),G=n.get(_);w.addEventListener("dispose",v);const K=w.textures,st=w.isWebGLCubeRenderTarget===!0,ot=K.length>1;if(ot||(G.__webglTexture===void 0&&(G.__webglTexture=i.createTexture()),G.__version=_.version,a.memory.textures++),st){O.__webglFramebuffer=[];for(let Z=0;Z<6;Z++)if(_.mipmaps&&_.mipmaps.length>0){O.__webglFramebuffer[Z]=[];for(let Q=0;Q<_.mipmaps.length;Q++)O.__webglFramebuffer[Z][Q]=i.createFramebuffer()}else O.__webglFramebuffer[Z]=i.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){O.__webglFramebuffer=[];for(let Z=0;Z<_.mipmaps.length;Z++)O.__webglFramebuffer[Z]=i.createFramebuffer()}else O.__webglFramebuffer=i.createFramebuffer();if(ot)for(let Z=0,Q=K.length;Z<Q;Z++){const ct=n.get(K[Z]);ct.__webglTexture===void 0&&(ct.__webglTexture=i.createTexture(),a.memory.textures++)}if(w.samples>0&&be(w)===!1){O.__webglMultisampledFramebuffer=i.createFramebuffer(),O.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let Z=0;Z<K.length;Z++){const Q=K[Z];O.__webglColorRenderbuffer[Z]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,O.__webglColorRenderbuffer[Z]);const ct=r.convert(Q.format,Q.colorSpace),wt=r.convert(Q.type),dt=M(Q.internalFormat,ct,wt,Q.normalized,Q.colorSpace,w.isXRRenderTarget===!0),lt=ge(w);i.renderbufferStorageMultisample(i.RENDERBUFFER,lt,dt,w.width,w.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Z,i.RENDERBUFFER,O.__webglColorRenderbuffer[Z])}i.bindRenderbuffer(i.RENDERBUFFER,null),w.depthBuffer&&(O.__webglDepthRenderbuffer=i.createRenderbuffer(),Tt(O.__webglDepthRenderbuffer,w,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(st){e.bindTexture(i.TEXTURE_CUBE_MAP,G.__webglTexture),Bt(i.TEXTURE_CUBE_MAP,_);for(let Z=0;Z<6;Z++)if(_.mipmaps&&_.mipmaps.length>0)for(let Q=0;Q<_.mipmaps.length;Q++)Dt(O.__webglFramebuffer[Z][Q],w,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Q);else Dt(O.__webglFramebuffer[Z],w,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0);p(_)&&A(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(ot){for(let Z=0,Q=K.length;Z<Q;Z++){const ct=K[Z],wt=n.get(ct);let dt=i.TEXTURE_2D;(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)&&(dt=w.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(dt,wt.__webglTexture),Bt(dt,ct),Dt(O.__webglFramebuffer,w,ct,i.COLOR_ATTACHMENT0+Z,dt,0),p(ct)&&A(dt)}e.unbindTexture()}else{let Z=i.TEXTURE_2D;if((w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)&&(Z=w.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(Z,G.__webglTexture),Bt(Z,_),_.mipmaps&&_.mipmaps.length>0)for(let Q=0;Q<_.mipmaps.length;Q++)Dt(O.__webglFramebuffer[Q],w,_,i.COLOR_ATTACHMENT0,Z,Q);else Dt(O.__webglFramebuffer,w,_,i.COLOR_ATTACHMENT0,Z,0);p(_)&&A(Z),e.unbindTexture()}w.depthBuffer&&It(w)}function Jt(w){const _=w.textures;for(let O=0,G=_.length;O<G;O++){const K=_[O];if(p(K)){const st=T(w),ot=n.get(K).__webglTexture;e.bindTexture(st,ot),A(st),e.unbindTexture()}}}const Qt=[],me=[];function de(w){if(w.samples>0){if(be(w)===!1){const _=w.textures,O=w.width,G=w.height;let K=i.COLOR_BUFFER_BIT;const st=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ot=n.get(w),Z=_.length>1;if(Z)for(let ct=0;ct<_.length;ct++)e.bindFramebuffer(i.FRAMEBUFFER,ot.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ct,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,ot.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ct,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,ot.__webglMultisampledFramebuffer);const Q=w.texture.mipmaps;Q&&Q.length>0?e.bindFramebuffer(i.DRAW_FRAMEBUFFER,ot.__webglFramebuffer[0]):e.bindFramebuffer(i.DRAW_FRAMEBUFFER,ot.__webglFramebuffer);for(let ct=0;ct<_.length;ct++){if(w.resolveDepthBuffer&&(w.depthBuffer&&(K|=i.DEPTH_BUFFER_BIT),w.stencilBuffer&&w.resolveStencilBuffer&&(K|=i.STENCIL_BUFFER_BIT)),Z){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,ot.__webglColorRenderbuffer[ct]);const wt=n.get(_[ct]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,wt,0)}i.blitFramebuffer(0,0,O,G,0,0,O,G,K,i.NEAREST),c===!0&&(Qt.length=0,me.length=0,Qt.push(i.COLOR_ATTACHMENT0+ct),w.depthBuffer&&w.resolveDepthBuffer===!1&&(Qt.push(st),me.push(st),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,me)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,Qt))}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),Z)for(let ct=0;ct<_.length;ct++){e.bindFramebuffer(i.FRAMEBUFFER,ot.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ct,i.RENDERBUFFER,ot.__webglColorRenderbuffer[ct]);const wt=n.get(_[ct]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,ot.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ct,i.TEXTURE_2D,wt,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,ot.__webglMultisampledFramebuffer)}else if(w.depthBuffer&&w.resolveDepthBuffer===!1&&c){const _=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[_])}}}function ge(w){return Math.min(s.maxSamples,w.samples)}function be(w){const _=n.get(w);return w.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function L(w){const _=a.render.frame;h.get(w)!==_&&(h.set(w,_),w.update())}function Je(w,_){const O=w.colorSpace,G=w.format,K=w.type;return w.isCompressedTexture===!0||w.isVideoTexture===!0||O!==Oa&&O!==yi&&(Kt.getTransfer(O)===te?(G!==un||K!==ln)&&Ot("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Yt("WebGLTextures: Unsupported texture color space:",O)),_}function jt(w){return typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement?(l.width=w.naturalWidth||w.width,l.height=w.naturalHeight||w.height):typeof VideoFrame<"u"&&w instanceof VideoFrame?(l.width=w.displayWidth,l.height=w.displayHeight):(l.width=w.width,l.height=w.height),l}this.allocateTextureUnit=q,this.resetTextureUnits=W,this.getTextureUnits=X,this.setTextureUnits=U,this.setTexture2D=$,this.setTexture2DArray=et,this.setTexture3D=j,this.setTextureCube=it,this.rebindTextures=Lt,this.setupRenderTarget=Nt,this.updateRenderTargetMipmap=Jt,this.updateMultisampleRenderTarget=de,this.setupDepthRenderbuffer=It,this.setupFrameBufferTexture=Dt,this.useMultisampledRTT=be,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function mv(i,t){function e(n,s=yi){let r;const a=Kt.getTransfer(s);if(n===ln)return i.UNSIGNED_BYTE;if(n===zl)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Bl)return i.UNSIGNED_SHORT_5_5_5_1;if(n===$0)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===J0)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===K0)return i.BYTE;if(n===Z0)return i.SHORT;if(n===Sr)return i.UNSIGNED_SHORT;if(n===Ol)return i.INT;if(n===Kn)return i.UNSIGNED_INT;if(n===Vn)return i.FLOAT;if(n===xn)return i.HALF_FLOAT;if(n===Q0)return i.ALPHA;if(n===j0)return i.RGB;if(n===un)return i.RGBA;if(n===ai)return i.DEPTH_COMPONENT;if(n===qi)return i.DEPTH_STENCIL;if(n===td)return i.RED;if(n===kl)return i.RED_INTEGER;if(n===$i)return i.RG;if(n===Gl)return i.RG_INTEGER;if(n===Hl)return i.RGBA_INTEGER;if(n===wa||n===Ra||n===Ca||n===Da)if(a===te)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===wa)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ra)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Ca)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Da)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===wa)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ra)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Ca)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Da)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Tc||n===wc||n===Rc||n===Cc)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Tc)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===wc)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Rc)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Cc)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Dc||n===Pc||n===Ic||n===Lc||n===Nc||n===Ua||n===Uc)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Dc||n===Pc)return a===te?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Ic)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Lc)return r.COMPRESSED_R11_EAC;if(n===Nc)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Ua)return r.COMPRESSED_RG11_EAC;if(n===Uc)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Fc||n===Oc||n===zc||n===Bc||n===kc||n===Gc||n===Hc||n===Vc||n===Wc||n===Xc||n===qc||n===Yc||n===Kc||n===Zc)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Fc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Oc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===zc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Bc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===kc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Gc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Hc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Vc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Wc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Xc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===qc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Yc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Kc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Zc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===$c||n===Jc||n===Qc)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===$c)return a===te?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Jc)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Qc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===jc||n===tl||n===Fa||n===el)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===jc)return r.COMPRESSED_RED_RGTC1_EXT;if(n===tl)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Fa)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===el)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===yr?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}const gv=`
4392
4392
  void main() {
4393
4393
 
4394
4394
  gl_Position = vec4( position, 1.0 );
4395
4395
 
4396
- }`,hv=`
4396
+ }`,_v=`
4397
4397
  uniform sampler2DArray depthColor;
4398
4398
  uniform float depthWidth;
4399
4399
  uniform float depthHeight;
@@ -4412,7 +4412,7 @@ void main() {
4412
4412
 
4413
4413
  }
4414
4414
 
4415
- }`;class uv{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const n=new id(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){const e=t.cameras[0].viewport,n=new Be({vertexShader:lv,fragmentShader:hv,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new oe(new Gs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class dv extends Ji{constructor(t,e){super();const n=this;let s=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,u=null,d=null,p=null,g=null;const x=typeof XRWebGLBinding<"u",m=new uv,f={},A=e.getContextAttributes();let T=null,M=null;const y=[],b=[],R=new Ft;let v=null;const E=new sn;E.viewport=new pe;const D=new sn;D.viewport=new pe;const C=[E,D],I=new ym;let W=null,X=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let rt=y[Y];return rt===void 0&&(rt=new fo,y[Y]=rt),rt.getTargetRaySpace()},this.getControllerGrip=function(Y){let rt=y[Y];return rt===void 0&&(rt=new fo,y[Y]=rt),rt.getGripSpace()},this.getHand=function(Y){let rt=y[Y];return rt===void 0&&(rt=new fo,y[Y]=rt),rt.getHandSpace()};function U(Y){const rt=b.indexOf(Y.inputSource);if(rt===-1)return;const nt=y[rt];nt!==void 0&&(nt.update(Y.inputSource,Y.frame,l||a),nt.dispatchEvent({type:Y.type,data:Y.inputSource}))}function q(){s.removeEventListener("select",U),s.removeEventListener("selectstart",U),s.removeEventListener("selectend",U),s.removeEventListener("squeeze",U),s.removeEventListener("squeezestart",U),s.removeEventListener("squeezeend",U),s.removeEventListener("end",q),s.removeEventListener("inputsourceschange",H);for(let Y=0;Y<y.length;Y++){const rt=b[Y];rt!==null&&(b[Y]=null,y[Y].disconnect(rt))}W=null,X=null,m.reset();for(const Y in f)delete f[Y];t.setRenderTarget(T),p=null,d=null,u=null,s=null,M=null,Bt.stop(),n.isPresenting=!1,t.setPixelRatio(v),t.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){r=Y,n.isPresenting===!0&&Ot("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,n.isPresenting===!0&&Ot("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return u===null&&x&&(u=new XRWebGLBinding(s,e)),u},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(Y){if(s=Y,s!==null){if(T=t.getRenderTarget(),s.addEventListener("select",U),s.addEventListener("selectstart",U),s.addEventListener("selectend",U),s.addEventListener("squeeze",U),s.addEventListener("squeezestart",U),s.addEventListener("squeezeend",U),s.addEventListener("end",q),s.addEventListener("inputsourceschange",H),A.xrCompatible!==!0&&await e.makeXRCompatible(),v=t.getPixelRatio(),t.getSize(R),x&&"createProjectionLayer"in XRWebGLBinding.prototype){let nt=null,z=null,bt=null;A.depth&&(bt=A.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,nt=A.stencil?Gi:ni,z=A.stencil?gr:Vn);const Dt={colorFormat:e.RGBA8,depthFormat:bt,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(Dt),s.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),M=new En(d.textureWidth,d.textureHeight,{format:pn,type:rn,depthTexture:new Os(d.textureWidth,d.textureHeight,z,void 0,void 0,void 0,void 0,void 0,void 0,nt),stencilBuffer:A.stencil,colorSpace:t.outputColorSpace,samples:A.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const nt={antialias:A.antialias,alpha:!0,depth:A.depth,stencil:A.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(s,e,nt),s.updateRenderState({baseLayer:p}),t.setPixelRatio(1),t.setSize(p.framebufferWidth,p.framebufferHeight,!1),M=new En(p.framebufferWidth,p.framebufferHeight,{format:pn,type:rn,colorSpace:t.outputColorSpace,stencilBuffer:A.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await s.requestReferenceSpace(o),Bt.setContext(s),Bt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function H(Y){for(let rt=0;rt<Y.removed.length;rt++){const nt=Y.removed[rt],z=b.indexOf(nt);z>=0&&(b[z]=null,y[z].disconnect(nt))}for(let rt=0;rt<Y.added.length;rt++){const nt=Y.added[rt];let z=b.indexOf(nt);if(z===-1){for(let Dt=0;Dt<y.length;Dt++)if(Dt>=b.length){b.push(nt),z=Dt;break}else if(b[Dt]===null){b[Dt]=nt,z=Dt;break}if(z===-1)break}const bt=y[z];bt&&bt.connect(nt)}}const $=new F,et=new F;function j(Y,rt,nt){$.setFromMatrixPosition(rt.matrixWorld),et.setFromMatrixPosition(nt.matrixWorld);const z=$.distanceTo(et),bt=rt.projectionMatrix.elements,Dt=nt.projectionMatrix.elements,Tt=bt[14]/(bt[10]-1),vt=bt[14]/(bt[10]+1),It=(bt[9]+1)/bt[5],Lt=(bt[9]-1)/bt[5],Nt=(bt[8]-1)/bt[0],Jt=(Dt[8]+1)/Dt[0],Qt=Tt*Nt,me=Tt*Jt,fe=z/(-Nt+Jt),ge=fe*-Nt;if(rt.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(ge),Y.translateZ(fe),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),bt[10]===-1)Y.projectionMatrix.copy(rt.projectionMatrix),Y.projectionMatrixInverse.copy(rt.projectionMatrixInverse);else{const Ee=Tt+fe,L=vt+fe,$e=Qt-ge,jt=me+(z-ge),w=It*vt/L*Ee,_=Lt*vt/L*Ee;Y.projectionMatrix.makePerspective($e,jt,w,_,Ee,L),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function it(Y,rt){rt===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(rt.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(s===null)return;let rt=Y.near,nt=Y.far;m.texture!==null&&(m.depthNear>0&&(rt=m.depthNear),m.depthFar>0&&(nt=m.depthFar)),I.near=D.near=E.near=rt,I.far=D.far=E.far=nt,(W!==I.near||X!==I.far)&&(s.updateRenderState({depthNear:I.near,depthFar:I.far}),W=I.near,X=I.far),I.layers.mask=Y.layers.mask|6,E.layers.mask=I.layers.mask&-5,D.layers.mask=I.layers.mask&-3;const z=Y.parent,bt=I.cameras;it(I,z);for(let Dt=0;Dt<bt.length;Dt++)it(bt[Dt],z);bt.length===2?j(I,E,D):I.projectionMatrix.copy(E.projectionMatrix),ut(Y,I,z)};function ut(Y,rt,nt){nt===null?Y.matrix.copy(rt.matrixWorld):(Y.matrix.copy(nt.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(rt.matrixWorld)),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(rt.projectionMatrix),Y.projectionMatrixInverse.copy(rt.projectionMatrixInverse),Y.isPerspectiveCamera&&(Y.fov=Jc*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return I},this.getFoveation=function(){if(!(d===null&&p===null))return c},this.setFoveation=function(Y){c=Y,d!==null&&(d.fixedFoveation=Y),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=Y)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(I)},this.getCameraTexture=function(Y){return f[Y]};let kt=null;function qt(Y,rt){if(h=rt.getViewerPose(l||a),g=rt,h!==null){const nt=h.views;p!==null&&(t.setRenderTargetFramebuffer(M,p.framebuffer),t.setRenderTarget(M));let z=!1;nt.length!==I.cameras.length&&(I.cameras.length=0,z=!0);for(let vt=0;vt<nt.length;vt++){const It=nt[vt];let Lt=null;if(p!==null)Lt=p.getViewport(It);else{const Jt=u.getViewSubImage(d,It);Lt=Jt.viewport,vt===0&&(t.setRenderTargetTextures(M,Jt.colorTexture,Jt.depthStencilTexture),t.setRenderTarget(M))}let Nt=C[vt];Nt===void 0&&(Nt=new sn,Nt.layers.enable(vt),Nt.viewport=new pe,C[vt]=Nt),Nt.matrix.fromArray(It.transform.matrix),Nt.matrix.decompose(Nt.position,Nt.quaternion,Nt.scale),Nt.projectionMatrix.fromArray(It.projectionMatrix),Nt.projectionMatrixInverse.copy(Nt.projectionMatrix).invert(),Nt.viewport.set(Lt.x,Lt.y,Lt.width,Lt.height),vt===0&&(I.matrix.copy(Nt.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),z===!0&&I.cameras.push(Nt)}const bt=s.enabledFeatures;if(bt&&bt.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&x){u=n.getBinding();const vt=u.getDepthInformation(nt[0]);vt&&vt.isValid&&vt.texture&&m.init(vt,s.renderState)}if(bt&&bt.includes("camera-access")&&x){t.state.unbindTexture(),u=n.getBinding();for(let vt=0;vt<nt.length;vt++){const It=nt[vt].camera;if(It){let Lt=f[It];Lt||(Lt=new id,f[It]=Lt);const Nt=u.getCameraImage(It);Lt.sourceTexture=Nt}}}}for(let nt=0;nt<y.length;nt++){const z=b[nt],bt=y[nt];z!==null&&bt!==void 0&&bt.update(z,rt,l||a)}kt&&kt(Y,rt),rt.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:rt}),g=null}const Bt=new cd;Bt.setAnimationLoop(qt),this.setAnimationLoop=function(Y){kt=Y},this.dispose=function(){}}}const fv=new ue,md=new zt;md.set(-1,0,0,0,1,0,0,0,1);function pv(i,t){function e(m,f){m.matrixAutoUpdate===!0&&m.updateMatrix(),f.value.copy(m.matrix)}function n(m,f){f.color.getRGB(m.fogColor.value,sd(i)),f.isFog?(m.fogNear.value=f.near,m.fogFar.value=f.far):f.isFogExp2&&(m.fogDensity.value=f.density)}function s(m,f,A,T,M){f.isNodeMaterial?f.uniformsNeedUpdate=!1:f.isMeshBasicMaterial?r(m,f):f.isMeshLambertMaterial?(r(m,f),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)):f.isMeshToonMaterial?(r(m,f),u(m,f)):f.isMeshPhongMaterial?(r(m,f),h(m,f),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(r(m,f),d(m,f),f.isMeshPhysicalMaterial&&p(m,f,M)):f.isMeshMatcapMaterial?(r(m,f),g(m,f)):f.isMeshDepthMaterial?r(m,f):f.isMeshDistanceMaterial?(r(m,f),x(m,f)):f.isMeshNormalMaterial?r(m,f):f.isLineBasicMaterial?(a(m,f),f.isLineDashedMaterial&&o(m,f)):f.isPointsMaterial?c(m,f,A,T):f.isSpriteMaterial?l(m,f):f.isShadowMaterial?(m.color.value.copy(f.color),m.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function r(m,f){m.opacity.value=f.opacity,f.color&&m.diffuse.value.copy(f.color),f.emissive&&m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(m.map.value=f.map,e(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,e(f.alphaMap,m.alphaMapTransform)),f.bumpMap&&(m.bumpMap.value=f.bumpMap,e(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===Fe&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,e(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===Fe&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,e(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias),f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap,e(f.emissiveMap,m.emissiveMapTransform)),f.specularMap&&(m.specularMap.value=f.specularMap,e(f.specularMap,m.specularMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest);const A=t.get(f),T=A.envMap,M=A.envMapRotation;T&&(m.envMap.value=T,m.envMapRotation.value.setFromMatrix4(fv.makeRotationFromEuler(M)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(md),m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio),f.lightMap&&(m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,e(f.lightMap,m.lightMapTransform)),f.aoMap&&(m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,e(f.aoMap,m.aoMapTransform))}function a(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map&&(m.map.value=f.map,e(f.map,m.mapTransform))}function o(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function c(m,f,A,T){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*A,m.scale.value=T*.5,f.map&&(m.map.value=f.map,e(f.map,m.uvTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,e(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function l(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map&&(m.map.value=f.map,e(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,e(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function h(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,1e-4)}function u(m,f){f.gradientMap&&(m.gradientMap.value=f.gradientMap)}function d(m,f){m.metalness.value=f.metalness,f.metalnessMap&&(m.metalnessMap.value=f.metalnessMap,e(f.metalnessMap,m.metalnessMapTransform)),m.roughness.value=f.roughness,f.roughnessMap&&(m.roughnessMap.value=f.roughnessMap,e(f.roughnessMap,m.roughnessMapTransform)),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)}function p(m,f,A){m.ior.value=f.ior,f.sheen>0&&(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(m.sheenColorMap.value=f.sheenColorMap,e(f.sheenColorMap,m.sheenColorMapTransform)),f.sheenRoughnessMap&&(m.sheenRoughnessMap.value=f.sheenRoughnessMap,e(f.sheenRoughnessMap,m.sheenRoughnessMapTransform))),f.clearcoat>0&&(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(m.clearcoatMap.value=f.clearcoatMap,e(f.clearcoatMap,m.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,e(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(m.clearcoatNormalMap.value=f.clearcoatNormalMap,e(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Fe&&m.clearcoatNormalScale.value.negate())),f.dispersion>0&&(m.dispersion.value=f.dispersion),f.iridescence>0&&(m.iridescence.value=f.iridescence,m.iridescenceIOR.value=f.iridescenceIOR,m.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(m.iridescenceMap.value=f.iridescenceMap,e(f.iridescenceMap,m.iridescenceMapTransform)),f.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,e(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),f.transmission>0&&(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=A.texture,m.transmissionSamplerSize.value.set(A.width,A.height),f.transmissionMap&&(m.transmissionMap.value=f.transmissionMap,e(f.transmissionMap,m.transmissionMapTransform)),m.thickness.value=f.thickness,f.thicknessMap&&(m.thicknessMap.value=f.thicknessMap,e(f.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(m.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(m.anisotropyMap.value=f.anisotropyMap,e(f.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap&&(m.specularColorMap.value=f.specularColorMap,e(f.specularColorMap,m.specularColorMapTransform)),f.specularIntensityMap&&(m.specularIntensityMap.value=f.specularIntensityMap,e(f.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,f){f.matcap&&(m.matcap.value=f.matcap)}function x(m,f){const A=t.get(f).light;m.referencePosition.value.setFromMatrixPosition(A.matrixWorld),m.nearDistance.value=A.shadow.camera.near,m.farDistance.value=A.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function mv(i,t,e,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,y){const b=y.program;n.uniformBlockBinding(M,b)}function l(M,y){let b=s[M.id];b===void 0&&(m(M),b=h(M),s[M.id]=b,M.addEventListener("dispose",A));const R=y.program;n.updateUBOMapping(M,R);const v=t.render.frame;r[M.id]!==v&&(d(M),r[M.id]=v)}function h(M){const y=u();M.__bindingPointIndex=y;const b=i.createBuffer(),R=M.__size,v=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,R,v),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,y,b),b}function u(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.push(M),M;return Yt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(M){const y=s[M.id],b=M.uniforms,R=M.__cache;i.bindBuffer(i.UNIFORM_BUFFER,y);for(let v=0,E=b.length;v<E;v++){const D=b[v];if(Array.isArray(D))for(let C=0,I=D.length;C<I;C++)p(D[C],v,C,R);else p(D,v,0,R)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function p(M,y,b,R){if(x(M,y,b,R)===!0){const v=M.__offset,E=M.value;if(Array.isArray(E)){let D=0;for(let C=0;C<E.length;C++){const I=E[C],W=f(I);g(I,M.__data,D),typeof I!="number"&&typeof I!="boolean"&&!I.isMatrix3&&!ArrayBuffer.isView(I)&&(D+=W.storage/Float32Array.BYTES_PER_ELEMENT)}}else g(E,M.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,v,M.__data)}}function g(M,y,b){typeof M=="number"||typeof M=="boolean"?y[0]=M:M.isMatrix3?(y[0]=M.elements[0],y[1]=M.elements[1],y[2]=M.elements[2],y[3]=0,y[4]=M.elements[3],y[5]=M.elements[4],y[6]=M.elements[5],y[7]=0,y[8]=M.elements[6],y[9]=M.elements[7],y[10]=M.elements[8],y[11]=0):ArrayBuffer.isView(M)?y.set(new M.constructor(M.buffer,M.byteOffset,y.length)):M.toArray(y,b)}function x(M,y,b,R){const v=M.value,E=y+"_"+b;if(R[E]===void 0)return typeof v=="number"||typeof v=="boolean"?R[E]=v:ArrayBuffer.isView(v)?R[E]=v.slice():R[E]=v.clone(),!0;{const D=R[E];if(typeof v=="number"||typeof v=="boolean"){if(D!==v)return R[E]=v,!0}else{if(ArrayBuffer.isView(v))return!0;if(D.equals(v)===!1)return D.copy(v),!0}}return!1}function m(M){const y=M.uniforms;let b=0;const R=16;for(let E=0,D=y.length;E<D;E++){const C=Array.isArray(y[E])?y[E]:[y[E]];for(let I=0,W=C.length;I<W;I++){const X=C[I],U=Array.isArray(X.value)?X.value:[X.value];for(let q=0,H=U.length;q<H;q++){const $=U[q],et=f($),j=b%R,it=j%et.boundary,ut=j+it;b+=it,ut!==0&&R-ut<et.storage&&(b+=R-ut),X.__data=new Float32Array(et.storage/Float32Array.BYTES_PER_ELEMENT),X.__offset=b,b+=et.storage}}}const v=b%R;return v>0&&(b+=R-v),M.__size=b,M.__cache={},this}function f(M){const y={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(y.boundary=4,y.storage=4):M.isVector2?(y.boundary=8,y.storage=8):M.isVector3||M.isColor?(y.boundary=16,y.storage=12):M.isVector4?(y.boundary=16,y.storage=16):M.isMatrix3?(y.boundary=48,y.storage=48):M.isMatrix4?(y.boundary=64,y.storage=64):M.isTexture?Ot("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(y.boundary=16,y.storage=M.byteLength):Ot("WebGLRenderer: Unsupported uniform value type.",M),y}function A(M){const y=M.target;y.removeEventListener("dispose",A);const b=a.indexOf(y.__bindingPointIndex);a.splice(b,1),i.deleteBuffer(s[y.id]),delete s[y.id],delete r[y.id]}function T(){for(const M in s)i.deleteBuffer(s[M]);a=[],s={},r={}}return{bind:c,update:l,dispose:T}}const gv=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Cn=null;function _v(){return Cn===null&&(Cn=new td(gv,16,16,Yi,bn),Cn.name="DFG_LUT",Cn.minFilter=Ne,Cn.magFilter=Ne,Cn.wrapS=Sn,Cn.wrapT=Sn,Cn.generateMipmaps=!1,Cn.needsUpdate=!0),Cn}class vv{constructor(t={}){const{canvas:e=Lp(),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:u=!1,reversedDepthBuffer:d=!1,outputBufferType:p=rn}=t;this.isWebGLRenderer=!0;let g;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=n.getContextAttributes().alpha}else g=a;const x=p,m=new Set([Ul,Nl,Ll]),f=new Set([rn,Vn,mr,gr,Pl,Il]),A=new Uint32Array(4),T=new Int32Array(4),M=new F;let y=null,b=null;const R=[],v=[];let E=null;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=Gn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const D=this;let C=!1,I=null,W=null,X=null,U=null;this._outputColorSpace=dn;let q=0,H=0,$=null,et=-1,j=null;const it=new pe,ut=new pe;let kt=null;const qt=new Mt(0);let Bt=0,Y=e.width,rt=e.height,nt=1,z=null,bt=null;const Dt=new pe(0,0,Y,rt),Tt=new pe(0,0,Y,rt);let vt=!1;const It=new Hl;let Lt=!1,Nt=!1;const Jt=new ue,Qt=new F,me=new pe,fe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ge=!1;function Ee(){return $===null?nt:1}let L=n;function $e(S,N){return e.getContext(S,N)}try{const S={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Rl}`),e.addEventListener("webglcontextlost",_e,!1),e.addEventListener("webglcontextrestored",ce,!1),e.addEventListener("webglcontextcreationerror",An,!1),L===null){const N="webgl2";if(L=$e(N,S),L===null)throw $e(N)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(S){throw Yt("WebGLRenderer: "+S.message),S}let jt,w,_,O,G,K,st,ot,Z,Q,ct,wt,dt,lt,Pt,Ut,Gt,P,at,J,ht,gt,tt;function At(){jt=new _2(L),jt.init(),ht=new cv(L,jt),w=new l2(L,jt,t,ht),_=new av(L,jt),w.reversedDepthBuffer&&d&&_.buffers.depth.setReversed(!0),W=L.createFramebuffer(),X=L.createFramebuffer(),U=L.createFramebuffer(),O=new M2(L),G=new q_,K=new ov(L,jt,_,G,w,ht,O),st=new g2(D),ot=new bm(L),gt=new o2(L,ot),Z=new v2(L,ot,O,gt),Q=new y2(L,Z,ot,gt,O),P=new S2(L,w,K),Pt=new h2(G),ct=new X_(D,st,jt,w,gt,Pt),wt=new pv(D,G),dt=new K_,lt=new tv(jt),Gt=new a2(D,st,_,Q,g,c),Ut=new rv(D,Q,w),tt=new mv(L,O,w,_),at=new c2(L,jt,O),J=new x2(L,jt,O),O.programs=ct.programs,D.capabilities=w,D.extensions=jt,D.properties=G,D.renderLists=dt,D.shadowMap=Ut,D.state=_,D.info=O}At(),x!==rn&&(E=new b2(x,e.width,e.height,o,s,r));const St=new dv(D,L);this.xr=St,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){const S=jt.get("WEBGL_lose_context");S&&S.loseContext()},this.forceContextRestore=function(){const S=jt.get("WEBGL_lose_context");S&&S.restoreContext()},this.getPixelRatio=function(){return nt},this.setPixelRatio=function(S){S!==void 0&&(nt=S,this.setSize(Y,rt,!1))},this.getSize=function(S){return S.set(Y,rt)},this.setSize=function(S,N,V=!0){if(St.isPresenting){Ot("WebGLRenderer: Can't change size while VR device is presenting.");return}Y=S,rt=N,e.width=Math.floor(S*nt),e.height=Math.floor(N*nt),V===!0&&(e.style.width=S+"px",e.style.height=N+"px"),E!==null&&E.setSize(e.width,e.height),this.setViewport(0,0,S,N)},this.getDrawingBufferSize=function(S){return S.set(Y*nt,rt*nt).floor()},this.setDrawingBufferSize=function(S,N,V){Y=S,rt=N,nt=V,e.width=Math.floor(S*V),e.height=Math.floor(N*V),this.setViewport(0,0,S,N)},this.setEffects=function(S){if(x===rn){Yt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(S){for(let N=0;N<S.length;N++)if(S[N].isOutputPass===!0){Ot("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}E.setEffects(S||[])},this.getCurrentViewport=function(S){return S.copy(it)},this.getViewport=function(S){return S.copy(Dt)},this.setViewport=function(S,N,V,B){S.isVector4?Dt.set(S.x,S.y,S.z,S.w):Dt.set(S,N,V,B),_.viewport(it.copy(Dt).multiplyScalar(nt).round())},this.getScissor=function(S){return S.copy(Tt)},this.setScissor=function(S,N,V,B){S.isVector4?Tt.set(S.x,S.y,S.z,S.w):Tt.set(S,N,V,B),_.scissor(ut.copy(Tt).multiplyScalar(nt).round())},this.getScissorTest=function(){return vt},this.setScissorTest=function(S){_.setScissorTest(vt=S)},this.setOpaqueSort=function(S){z=S},this.setTransparentSort=function(S){bt=S},this.getClearColor=function(S){return S.copy(Gt.getClearColor())},this.setClearColor=function(){Gt.setClearColor(...arguments)},this.getClearAlpha=function(){return Gt.getClearAlpha()},this.setClearAlpha=function(){Gt.setClearAlpha(...arguments)},this.clear=function(S=!0,N=!0,V=!0){let B=0;if(S){let k=!1;if($!==null){const mt=$.texture.format;k=m.has(mt)}if(k){const mt=$.texture.type,xt=f.has(mt),pt=Gt.getClearColor(),Et=Gt.getClearAlpha(),Rt=pt.r,Ht=pt.g,Wt=pt.b;xt?(A[0]=Rt,A[1]=Ht,A[2]=Wt,A[3]=Et,L.clearBufferuiv(L.COLOR,0,A)):(T[0]=Rt,T[1]=Ht,T[2]=Wt,T[3]=Et,L.clearBufferiv(L.COLOR,0,T))}else B|=L.COLOR_BUFFER_BIT}N&&(B|=L.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),V&&(B|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B!==0&&L.clear(B)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(S){S.setRenderer(this),I=S},this.dispose=function(){e.removeEventListener("webglcontextlost",_e,!1),e.removeEventListener("webglcontextrestored",ce,!1),e.removeEventListener("webglcontextcreationerror",An,!1),Gt.dispose(),dt.dispose(),lt.dispose(),G.dispose(),st.dispose(),Q.dispose(),gt.dispose(),tt.dispose(),ct.dispose(),St.dispose(),St.removeEventListener("sessionstart",th),St.removeEventListener("sessionend",eh),wi.stop()};function _e(S){S.preventDefault(),La("WebGLRenderer: Context Lost."),C=!0}function ce(){La("WebGLRenderer: Context Restored."),C=!1;const S=O.autoReset,N=Ut.enabled,V=Ut.autoUpdate,B=Ut.needsUpdate,k=Ut.type;At(),O.autoReset=S,Ut.enabled=N,Ut.autoUpdate=V,Ut.needsUpdate=B,Ut.type=k}function An(S){Yt("WebGLRenderer: A WebGL context could not be created. Reason: ",S.statusMessage)}function Tn(S){const N=S.target;N.removeEventListener("dispose",Tn),sf(N)}function sf(S){rf(S),G.remove(S)}function rf(S){const N=G.get(S).programs;N!==void 0&&(N.forEach(function(V){ct.releaseProgram(V)}),S.isShaderMaterial&&ct.releaseShaderCache(S))}this.renderBufferDirect=function(S,N,V,B,k,mt){N===null&&(N=fe);const xt=k.isMesh&&k.matrixWorld.determinantAffine()<0,pt=cf(S,N,V,B,k);_.setMaterial(B,xt);let Et=V.index,Rt=1;if(B.wireframe===!0){if(Et=Z.getWireframeAttribute(V),Et===void 0)return;Rt=2}const Ht=V.drawRange,Wt=V.attributes.position;let Ct=Ht.start*Rt,ie=(Ht.start+Ht.count)*Rt;mt!==null&&(Ct=Math.max(Ct,mt.start*Rt),ie=Math.min(ie,(mt.start+mt.count)*Rt)),Et!==null?(Ct=Math.max(Ct,0),ie=Math.min(ie,Et.count)):Wt!=null&&(Ct=Math.max(Ct,0),ie=Math.min(ie,Wt.count));const Me=ie-Ct;if(Me<0||Me===1/0)return;gt.setup(k,B,pt,V,Et);let ve,re=at;if(Et!==null&&(ve=ot.get(Et),re=J,re.setIndex(ve)),k.isMesh)B.wireframe===!0?(_.setLineWidth(B.wireframeLinewidth*Ee()),re.setMode(L.LINES)):re.setMode(L.TRIANGLES);else if(k.isLine){let ke=B.linewidth;ke===void 0&&(ke=1),_.setLineWidth(ke*Ee()),k.isLineSegments?re.setMode(L.LINES):k.isLineLoop?re.setMode(L.LINE_LOOP):re.setMode(L.LINE_STRIP)}else k.isPoints?re.setMode(L.POINTS):k.isSprite&&re.setMode(L.TRIANGLES);if(k.isBatchedMesh)if(jt.get("WEBGL_multi_draw"))re.renderMultiDraw(k._multiDrawStarts,k._multiDrawCounts,k._multiDrawCount);else{const ke=k._multiDrawStarts,_t=k._multiDrawCounts,Qe=k._multiDrawCount,Zt=Et?ot.get(Et).bytesPerElement:1,an=G.get(B).currentProgram.getUniforms();for(let wn=0;wn<Qe;wn++)an.setValue(L,"_gl_DrawID",wn),re.render(ke[wn]/Zt,_t[wn])}else if(k.isInstancedMesh)re.renderInstances(Ct,Me,k.count);else if(V.isInstancedBufferGeometry){const ke=V._maxInstanceCount!==void 0?V._maxInstanceCount:1/0,_t=Math.min(V.instanceCount,ke);re.renderInstances(Ct,Me,_t)}else re.render(Ct,Me)};function jl(S,N,V){S.transparent===!0&&S.side===Mn&&S.forceSinglePass===!1?(S.side=Fe,S.needsUpdate=!0,Er(S,N,V),S.side=Ei,S.needsUpdate=!0,Er(S,N,V),S.side=Mn):Er(S,N,V)}this.compile=function(S,N,V=null){V===null&&(V=S),b=lt.get(V),b.init(N),v.push(b),V.traverseVisible(function(k){k.isLight&&k.layers.test(N.layers)&&(b.pushLight(k),k.castShadow&&b.pushShadow(k))}),S!==V&&S.traverseVisible(function(k){k.isLight&&k.layers.test(N.layers)&&(b.pushLight(k),k.castShadow&&b.pushShadow(k))}),b.setupLights();const B=new Set;return S.traverse(function(k){if(!(k.isMesh||k.isPoints||k.isLine||k.isSprite))return;const mt=k.material;if(mt)if(Array.isArray(mt))for(let xt=0;xt<mt.length;xt++){const pt=mt[xt];jl(pt,V,k),B.add(pt)}else jl(mt,V,k),B.add(mt)}),b=v.pop(),B},this.compileAsync=function(S,N,V=null){const B=this.compile(S,N,V);return new Promise(k=>{function mt(){if(B.forEach(function(xt){G.get(xt).currentProgram.isReady()&&B.delete(xt)}),B.size===0){k(S);return}setTimeout(mt,10)}jt.get("KHR_parallel_shader_compile")!==null?mt():setTimeout(mt,10)})};let ja=null;function af(S){ja&&ja(S)}function th(){wi.stop()}function eh(){wi.start()}const wi=new cd;wi.setAnimationLoop(af),typeof self<"u"&&wi.setContext(self),this.setAnimationLoop=function(S){ja=S,St.setAnimationLoop(S),S===null?wi.stop():wi.start()},St.addEventListener("sessionstart",th),St.addEventListener("sessionend",eh),this.render=function(S,N){if(N!==void 0&&N.isCamera!==!0){Yt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;I!==null&&I.renderStart(S,N);const V=St.enabled===!0&&St.isPresenting===!0,B=E!==null&&($===null||V)&&E.begin(D,$);if(S.matrixWorldAutoUpdate===!0&&S.updateMatrixWorld(),N.parent===null&&N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),St.enabled===!0&&St.isPresenting===!0&&(E===null||E.isCompositing()===!1)&&(St.cameraAutoUpdate===!0&&St.updateCamera(N),N=St.getCamera()),S.isScene===!0&&S.onBeforeRender(D,S,N,$),b=lt.get(S,v.length),b.init(N),b.state.textureUnits=K.getTextureUnits(),v.push(b),Jt.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),It.setFromProjectionMatrix(Jt,Bn,N.reversedDepth),Nt=this.localClippingEnabled,Lt=Pt.init(this.clippingPlanes,Nt),y=dt.get(S,R.length),y.init(),R.push(y),St.enabled===!0&&St.isPresenting===!0){const xt=D.xr.getDepthSensingMesh();xt!==null&&to(xt,N,-1/0,D.sortObjects)}to(S,N,0,D.sortObjects),y.finish(),D.sortObjects===!0&&y.sort(z,bt,N.reversedDepth),ge=St.enabled===!1||St.isPresenting===!1||St.hasDepthSensing()===!1,ge&&Gt.addToRenderList(y,S),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Lt===!0&&Pt.beginShadows();const k=b.state.shadowsArray;if(Ut.render(k,S,N),Lt===!0&&Pt.endShadows(),(B&&E.hasRenderPass())===!1){const xt=y.opaque,pt=y.transmissive;if(b.setupLights(),N.isArrayCamera){const Et=N.cameras;if(pt.length>0)for(let Rt=0,Ht=Et.length;Rt<Ht;Rt++){const Wt=Et[Rt];ih(xt,pt,S,Wt)}ge&&Gt.render(S);for(let Rt=0,Ht=Et.length;Rt<Ht;Rt++){const Wt=Et[Rt];nh(y,S,Wt,Wt.viewport)}}else pt.length>0&&ih(xt,pt,S,N),ge&&Gt.render(S),nh(y,S,N)}$!==null&&H===0&&(K.updateMultisampleRenderTarget($),K.updateRenderTargetMipmap($)),B&&E.end(D),S.isScene===!0&&S.onAfterRender(D,S,N),gt.resetDefaultState(),et=-1,j=null,v.pop(),v.length>0?(b=v[v.length-1],K.setTextureUnits(b.state.textureUnits),Lt===!0&&Pt.setGlobalState(D.clippingPlanes,b.state.camera)):b=null,R.pop(),R.length>0?y=R[R.length-1]:y=null,I!==null&&I.renderEnd()};function to(S,N,V,B){if(S.visible===!1)return;if(S.layers.test(N.layers)){if(S.isGroup)V=S.renderOrder;else if(S.isLOD)S.autoUpdate===!0&&S.update(N);else if(S.isLightProbeGrid)b.pushLightProbeGrid(S);else if(S.isLight)b.pushLight(S),S.castShadow&&b.pushShadow(S);else if(S.isSprite){if(!S.frustumCulled||It.intersectsSprite(S)){B&&me.setFromMatrixPosition(S.matrixWorld).applyMatrix4(Jt);const xt=Q.update(S),pt=S.material;pt.visible&&y.push(S,xt,pt,V,me.z,null)}}else if((S.isMesh||S.isLine||S.isPoints)&&(!S.frustumCulled||It.intersectsObject(S))){const xt=Q.update(S),pt=S.material;if(B&&(S.boundingSphere!==void 0?(S.boundingSphere===null&&S.computeBoundingSphere(),me.copy(S.boundingSphere.center)):(xt.boundingSphere===null&&xt.computeBoundingSphere(),me.copy(xt.boundingSphere.center)),me.applyMatrix4(S.matrixWorld).applyMatrix4(Jt)),Array.isArray(pt)){const Et=xt.groups;for(let Rt=0,Ht=Et.length;Rt<Ht;Rt++){const Wt=Et[Rt],Ct=pt[Wt.materialIndex];Ct&&Ct.visible&&y.push(S,xt,Ct,V,me.z,Wt)}}else pt.visible&&y.push(S,xt,pt,V,me.z,null)}}const mt=S.children;for(let xt=0,pt=mt.length;xt<pt;xt++)to(mt[xt],N,V,B)}function nh(S,N,V,B){const{opaque:k,transmissive:mt,transparent:xt}=S;b.setupLightsView(V),Lt===!0&&Pt.setGlobalState(D.clippingPlanes,V),B&&_.viewport(it.copy(B)),k.length>0&&yr(k,N,V),mt.length>0&&yr(mt,N,V),xt.length>0&&yr(xt,N,V),_.buffers.depth.setTest(!0),_.buffers.depth.setMask(!0),_.buffers.color.setMask(!0),_.setPolygonOffset(!1)}function ih(S,N,V,B){if((V.isScene===!0?V.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[B.id]===void 0){const Ct=jt.has("EXT_color_buffer_half_float")||jt.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[B.id]=new En(1,1,{generateMipmaps:!0,type:Ct?bn:rn,minFilter:ki,samples:Math.max(4,w.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Kt.workingColorSpace})}const mt=b.state.transmissionRenderTarget[B.id],xt=B.viewport||it;mt.setSize(xt.z*D.transmissionResolutionScale,xt.w*D.transmissionResolutionScale);const pt=D.getRenderTarget(),Et=D.getActiveCubeFace(),Rt=D.getActiveMipmapLevel();D.setRenderTarget(mt),D.getClearColor(qt),Bt=D.getClearAlpha(),Bt<1&&D.setClearColor(16777215,.5),D.clear(),ge&&Gt.render(V);const Ht=D.toneMapping;D.toneMapping=Gn;const Wt=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),b.setupLightsView(B),Lt===!0&&Pt.setGlobalState(D.clippingPlanes,B),yr(S,V,B),K.updateMultisampleRenderTarget(mt),K.updateRenderTargetMipmap(mt),jt.has("WEBGL_multisampled_render_to_texture")===!1){let Ct=!1;for(let ie=0,Me=N.length;ie<Me;ie++){const ve=N[ie],{object:re,geometry:ke,material:_t,group:Qe}=ve;if(_t.side===Mn&&re.layers.test(B.layers)){const Zt=_t.side;_t.side=Fe,_t.needsUpdate=!0,sh(re,V,B,ke,_t,Qe),_t.side=Zt,_t.needsUpdate=!0,Ct=!0}}Ct===!0&&(K.updateMultisampleRenderTarget(mt),K.updateRenderTargetMipmap(mt))}D.setRenderTarget(pt,Et,Rt),D.setClearColor(qt,Bt),Wt!==void 0&&(B.viewport=Wt),D.toneMapping=Ht}function yr(S,N,V){const B=N.isScene===!0?N.overrideMaterial:null;for(let k=0,mt=S.length;k<mt;k++){const xt=S[k],{object:pt,geometry:Et,group:Rt}=xt;let Ht=xt.material;Ht.allowOverride===!0&&B!==null&&(Ht=B),pt.layers.test(V.layers)&&sh(pt,N,V,Et,Ht,Rt)}}function sh(S,N,V,B,k,mt){S.onBeforeRender(D,N,V,B,k,mt),S.modelViewMatrix.multiplyMatrices(V.matrixWorldInverse,S.matrixWorld),S.normalMatrix.getNormalMatrix(S.modelViewMatrix),k.onBeforeRender(D,N,V,B,S,mt),k.transparent===!0&&k.side===Mn&&k.forceSinglePass===!1?(k.side=Fe,k.needsUpdate=!0,D.renderBufferDirect(V,N,B,k,S,mt),k.side=Ei,k.needsUpdate=!0,D.renderBufferDirect(V,N,B,k,S,mt),k.side=Mn):D.renderBufferDirect(V,N,B,k,S,mt),S.onAfterRender(D,N,V,B,k,mt)}function Er(S,N,V){N.isScene!==!0&&(N=fe);const B=G.get(S),k=b.state.lights,mt=b.state.shadowsArray,xt=k.state.version,pt=ct.getParameters(S,k.state,mt,N,V,b.state.lightProbeGridArray),Et=ct.getProgramCacheKey(pt);let Rt=B.programs;B.environment=S.isMeshStandardMaterial||S.isMeshLambertMaterial||S.isMeshPhongMaterial?N.environment:null,B.fog=N.fog;const Ht=S.isMeshStandardMaterial||S.isMeshLambertMaterial&&!S.envMap||S.isMeshPhongMaterial&&!S.envMap;B.envMap=st.get(S.envMap||B.environment,Ht),B.envMapRotation=B.environment!==null&&S.envMap===null?N.environmentRotation:S.envMapRotation,Rt===void 0&&(S.addEventListener("dispose",Tn),Rt=new Map,B.programs=Rt);let Wt=Rt.get(Et);if(Wt!==void 0){if(B.currentProgram===Wt&&B.lightsStateVersion===xt)return ah(S,pt),Wt}else pt.uniforms=ct.getUniforms(S),I!==null&&S.isNodeMaterial&&I.build(S,V,pt),S.onBeforeCompile(pt,D),Wt=ct.acquireProgram(pt,Et),Rt.set(Et,Wt),B.uniforms=pt.uniforms;const Ct=B.uniforms;return(!S.isShaderMaterial&&!S.isRawShaderMaterial||S.clipping===!0)&&(Ct.clippingPlanes=Pt.uniform),ah(S,pt),B.needsLights=hf(S),B.lightsStateVersion=xt,B.needsLights&&(Ct.ambientLightColor.value=k.state.ambient,Ct.lightProbe.value=k.state.probe,Ct.directionalLights.value=k.state.directional,Ct.directionalLightShadows.value=k.state.directionalShadow,Ct.spotLights.value=k.state.spot,Ct.spotLightShadows.value=k.state.spotShadow,Ct.rectAreaLights.value=k.state.rectArea,Ct.ltc_1.value=k.state.rectAreaLTC1,Ct.ltc_2.value=k.state.rectAreaLTC2,Ct.pointLights.value=k.state.point,Ct.pointLightShadows.value=k.state.pointShadow,Ct.hemisphereLights.value=k.state.hemi,Ct.directionalShadowMatrix.value=k.state.directionalShadowMatrix,Ct.spotLightMatrix.value=k.state.spotLightMatrix,Ct.spotLightMap.value=k.state.spotLightMap,Ct.pointShadowMatrix.value=k.state.pointShadowMatrix),B.lightProbeGrid=b.state.lightProbeGridArray.length>0,B.currentProgram=Wt,B.uniformsList=null,Wt}function rh(S){if(S.uniformsList===null){const N=S.currentProgram.getUniforms();S.uniformsList=Aa.seqWithValue(N.seq,S.uniforms)}return S.uniformsList}function ah(S,N){const V=G.get(S);V.outputColorSpace=N.outputColorSpace,V.batching=N.batching,V.batchingColor=N.batchingColor,V.instancing=N.instancing,V.instancingColor=N.instancingColor,V.instancingMorph=N.instancingMorph,V.skinning=N.skinning,V.morphTargets=N.morphTargets,V.morphNormals=N.morphNormals,V.morphColors=N.morphColors,V.morphTargetsCount=N.morphTargetsCount,V.numClippingPlanes=N.numClippingPlanes,V.numIntersection=N.numClipIntersection,V.vertexAlphas=N.vertexAlphas,V.vertexTangents=N.vertexTangents,V.toneMapping=N.toneMapping}function of(S,N){if(S.length===0)return null;if(S.length===1)return S[0].texture!==null?S[0]:null;M.setFromMatrixPosition(N.matrixWorld);for(let V=0,B=S.length;V<B;V++){const k=S[V];if(k.texture!==null&&k.boundingBox.containsPoint(M))return k}return null}function cf(S,N,V,B,k){N.isScene!==!0&&(N=fe),K.resetTextureUnits();const mt=N.fog,xt=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?N.environment:null,pt=$===null?D.outputColorSpace:$.isXRRenderTarget===!0?$.texture.colorSpace:Kt.workingColorSpace,Et=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Rt=st.get(B.envMap||xt,Et),Ht=B.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,Wt=!!V.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Ct=!!V.morphAttributes.position,ie=!!V.morphAttributes.normal,Me=!!V.morphAttributes.color;let ve=Gn;B.toneMapped&&($===null||$.isXRRenderTarget===!0)&&(ve=D.toneMapping);const re=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,ke=re!==void 0?re.length:0,_t=G.get(B),Qe=b.state.lights;if(Lt===!0&&(Nt===!0||S!==j)){const le=S===j&&B.id===et;Pt.setState(B,S,le)}let Zt=!1;B.version===_t.__version?(_t.needsLights&&_t.lightsStateVersion!==Qe.state.version||_t.outputColorSpace!==pt||k.isBatchedMesh&&_t.batching===!1||!k.isBatchedMesh&&_t.batching===!0||k.isBatchedMesh&&_t.batchingColor===!0&&k.colorTexture===null||k.isBatchedMesh&&_t.batchingColor===!1&&k.colorTexture!==null||k.isInstancedMesh&&_t.instancing===!1||!k.isInstancedMesh&&_t.instancing===!0||k.isSkinnedMesh&&_t.skinning===!1||!k.isSkinnedMesh&&_t.skinning===!0||k.isInstancedMesh&&_t.instancingColor===!0&&k.instanceColor===null||k.isInstancedMesh&&_t.instancingColor===!1&&k.instanceColor!==null||k.isInstancedMesh&&_t.instancingMorph===!0&&k.morphTexture===null||k.isInstancedMesh&&_t.instancingMorph===!1&&k.morphTexture!==null||_t.envMap!==Rt||B.fog===!0&&_t.fog!==mt||_t.numClippingPlanes!==void 0&&(_t.numClippingPlanes!==Pt.numPlanes||_t.numIntersection!==Pt.numIntersection)||_t.vertexAlphas!==Ht||_t.vertexTangents!==Wt||_t.morphTargets!==Ct||_t.morphNormals!==ie||_t.morphColors!==Me||_t.toneMapping!==ve||_t.morphTargetsCount!==ke||!!_t.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(Zt=!0):(Zt=!0,_t.__version=B.version);let an=_t.currentProgram;Zt===!0&&(an=Er(B,N,k),I&&B.isNodeMaterial&&I.onUpdateProgram(B,an,_t));let wn=!1,si=!1,ji=!1;const ae=an.getUniforms(),Se=_t.uniforms;if(_.useProgram(an.program)&&(wn=!0,si=!0,ji=!0),B.id!==et&&(et=B.id,si=!0),_t.needsLights){const le=of(b.state.lightProbeGridArray,k);_t.lightProbeGrid!==le&&(_t.lightProbeGrid=le,si=!0)}if(wn||j!==S){_.buffers.depth.getReversed()&&S.reversedDepth!==!0&&(S._reversedDepth=!0,S.updateProjectionMatrix()),ae.setValue(L,"projectionMatrix",S.projectionMatrix),ae.setValue(L,"viewMatrix",S.matrixWorldInverse);const ai=ae.map.cameraPosition;ai!==void 0&&ai.setValue(L,Qt.setFromMatrixPosition(S.matrixWorld)),w.logarithmicDepthBuffer&&ae.setValue(L,"logDepthBufFC",2/(Math.log(S.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&ae.setValue(L,"isOrthographic",S.isOrthographicCamera===!0),j!==S&&(j=S,si=!0,ji=!0)}if(_t.needsLights&&(Qe.state.directionalShadowMap.length>0&&ae.setValue(L,"directionalShadowMap",Qe.state.directionalShadowMap,K),Qe.state.spotShadowMap.length>0&&ae.setValue(L,"spotShadowMap",Qe.state.spotShadowMap,K),Qe.state.pointShadowMap.length>0&&ae.setValue(L,"pointShadowMap",Qe.state.pointShadowMap,K)),k.isSkinnedMesh){ae.setOptional(L,k,"bindMatrix"),ae.setOptional(L,k,"bindMatrixInverse");const le=k.skeleton;le&&(le.boneTexture===null&&le.computeBoneTexture(),ae.setValue(L,"boneTexture",le.boneTexture,K))}k.isBatchedMesh&&(ae.setOptional(L,k,"batchingTexture"),ae.setValue(L,"batchingTexture",k._matricesTexture,K),ae.setOptional(L,k,"batchingIdTexture"),ae.setValue(L,"batchingIdTexture",k._indirectTexture,K),ae.setOptional(L,k,"batchingColorTexture"),k._colorsTexture!==null&&ae.setValue(L,"batchingColorTexture",k._colorsTexture,K));const ri=V.morphAttributes;if((ri.position!==void 0||ri.normal!==void 0||ri.color!==void 0)&&P.update(k,V,an),(si||_t.receiveShadow!==k.receiveShadow)&&(_t.receiveShadow=k.receiveShadow,ae.setValue(L,"receiveShadow",k.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&N.environment!==null&&(Se.envMapIntensity.value=N.environmentIntensity),Se.dfgLUT!==void 0&&(Se.dfgLUT.value=_v()),si){if(ae.setValue(L,"toneMappingExposure",D.toneMappingExposure),_t.needsLights&&lf(Se,ji),mt&&B.fog===!0&&wt.refreshFogUniforms(Se,mt),wt.refreshMaterialUniforms(Se,B,nt,rt,b.state.transmissionRenderTarget[S.id]),_t.needsLights&&_t.lightProbeGrid){const le=_t.lightProbeGrid;Se.probesSH.value=le.texture,Se.probesMin.value.copy(le.boundingBox.min),Se.probesMax.value.copy(le.boundingBox.max),Se.probesResolution.value.copy(le.resolution)}Aa.upload(L,rh(_t),Se,K)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(Aa.upload(L,rh(_t),Se,K),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&ae.setValue(L,"center",k.center),ae.setValue(L,"modelViewMatrix",k.modelViewMatrix),ae.setValue(L,"normalMatrix",k.normalMatrix),ae.setValue(L,"modelMatrix",k.matrixWorld),B.uniformsGroups!==void 0){const le=B.uniformsGroups;for(let ai=0,ts=le.length;ai<ts;ai++){const oh=le[ai];tt.update(oh,an),tt.bind(oh,an)}}return an}function lf(S,N){S.ambientLightColor.needsUpdate=N,S.lightProbe.needsUpdate=N,S.directionalLights.needsUpdate=N,S.directionalLightShadows.needsUpdate=N,S.pointLights.needsUpdate=N,S.pointLightShadows.needsUpdate=N,S.spotLights.needsUpdate=N,S.spotLightShadows.needsUpdate=N,S.rectAreaLights.needsUpdate=N,S.hemisphereLights.needsUpdate=N}function hf(S){return S.isMeshLambertMaterial||S.isMeshToonMaterial||S.isMeshPhongMaterial||S.isMeshStandardMaterial||S.isShadowMaterial||S.isShaderMaterial&&S.lights===!0}this.getActiveCubeFace=function(){return q},this.getActiveMipmapLevel=function(){return H},this.getRenderTarget=function(){return $},this.setRenderTargetTextures=function(S,N,V){const B=G.get(S);B.__autoAllocateDepthBuffer=S.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),G.get(S.texture).__webglTexture=N,G.get(S.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:V,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(S,N){const V=G.get(S);V.__webglFramebuffer=N,V.__useDefaultFramebuffer=N===void 0},this.setRenderTarget=function(S,N=0,V=0){$=S,q=N,H=V;let B=null,k=!1,mt=!1;if(S){const pt=G.get(S);if(pt.__useDefaultFramebuffer!==void 0){_.bindFramebuffer(L.FRAMEBUFFER,pt.__webglFramebuffer),it.copy(S.viewport),ut.copy(S.scissor),kt=S.scissorTest,_.viewport(it),_.scissor(ut),_.setScissorTest(kt),et=-1;return}else if(pt.__webglFramebuffer===void 0)K.setupRenderTarget(S);else if(pt.__hasExternalTextures)K.rebindTextures(S,G.get(S.texture).__webglTexture,G.get(S.depthTexture).__webglTexture);else if(S.depthBuffer){const Ht=S.depthTexture;if(pt.__boundDepthTexture!==Ht){if(Ht!==null&&G.has(Ht)&&(S.width!==Ht.image.width||S.height!==Ht.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");K.setupDepthRenderbuffer(S)}}const Et=S.texture;(Et.isData3DTexture||Et.isDataArrayTexture||Et.isCompressedArrayTexture)&&(mt=!0);const Rt=G.get(S).__webglFramebuffer;S.isWebGLCubeRenderTarget?(Array.isArray(Rt[N])?B=Rt[N][V]:B=Rt[N],k=!0):S.samples>0&&K.useMultisampledRTT(S)===!1?B=G.get(S).__webglMultisampledFramebuffer:Array.isArray(Rt)?B=Rt[V]:B=Rt,it.copy(S.viewport),ut.copy(S.scissor),kt=S.scissorTest}else it.copy(Dt).multiplyScalar(nt).floor(),ut.copy(Tt).multiplyScalar(nt).floor(),kt=vt;if(V!==0&&(B=W),_.bindFramebuffer(L.FRAMEBUFFER,B)&&_.drawBuffers(S,B),_.viewport(it),_.scissor(ut),_.setScissorTest(kt),k){const pt=G.get(S.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+N,pt.__webglTexture,V)}else if(mt){const pt=N;for(let Et=0;Et<S.textures.length;Et++){const Rt=G.get(S.textures[Et]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+Et,Rt.__webglTexture,V,pt)}}else if(S!==null&&V!==0){const pt=G.get(S.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,pt.__webglTexture,V)}et=-1},this.readRenderTargetPixels=function(S,N,V,B,k,mt,xt,pt=0){if(!(S&&S.isWebGLRenderTarget)){Yt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Et=G.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&xt!==void 0&&(Et=Et[xt]),Et){_.bindFramebuffer(L.FRAMEBUFFER,Et);try{const Rt=S.textures[pt],Ht=Rt.format,Wt=Rt.type;if(S.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+pt),!w.textureFormatReadable(Ht)){Yt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!w.textureTypeReadable(Wt)){Yt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}N>=0&&N<=S.width-B&&V>=0&&V<=S.height-k&&L.readPixels(N,V,B,k,ht.convert(Ht),ht.convert(Wt),mt)}finally{const Rt=$!==null?G.get($).__webglFramebuffer:null;_.bindFramebuffer(L.FRAMEBUFFER,Rt)}}},this.readRenderTargetPixelsAsync=async function(S,N,V,B,k,mt,xt,pt=0){if(!(S&&S.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Et=G.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&xt!==void 0&&(Et=Et[xt]),Et)if(N>=0&&N<=S.width-B&&V>=0&&V<=S.height-k){_.bindFramebuffer(L.FRAMEBUFFER,Et);const Rt=S.textures[pt],Ht=Rt.format,Wt=Rt.type;if(S.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+pt),!w.textureFormatReadable(Ht))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!w.textureTypeReadable(Wt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ct=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,Ct),L.bufferData(L.PIXEL_PACK_BUFFER,mt.byteLength,L.STREAM_READ),L.readPixels(N,V,B,k,ht.convert(Ht),ht.convert(Wt),0);const ie=$!==null?G.get($).__webglFramebuffer:null;_.bindFramebuffer(L.FRAMEBUFFER,ie);const Me=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await Np(L,Me,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,Ct),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,mt),L.deleteBuffer(Ct),L.deleteSync(Me),mt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(S,N=null,V=0){const B=Math.pow(2,-V),k=Math.floor(S.image.width*B),mt=Math.floor(S.image.height*B),xt=N!==null?N.x:0,pt=N!==null?N.y:0;K.setTexture2D(S,0),L.copyTexSubImage2D(L.TEXTURE_2D,V,0,0,xt,pt,k,mt),_.unbindTexture()},this.copyTextureToTexture=function(S,N,V=null,B=null,k=0,mt=0){let xt,pt,Et,Rt,Ht,Wt,Ct,ie,Me;const ve=S.isCompressedTexture?S.mipmaps[mt]:S.image;if(V!==null)xt=V.max.x-V.min.x,pt=V.max.y-V.min.y,Et=V.isBox3?V.max.z-V.min.z:1,Rt=V.min.x,Ht=V.min.y,Wt=V.isBox3?V.min.z:0;else{const Se=Math.pow(2,-k);xt=Math.floor(ve.width*Se),pt=Math.floor(ve.height*Se),S.isDataArrayTexture?Et=ve.depth:S.isData3DTexture?Et=Math.floor(ve.depth*Se):Et=1,Rt=0,Ht=0,Wt=0}B!==null?(Ct=B.x,ie=B.y,Me=B.z):(Ct=0,ie=0,Me=0);const re=ht.convert(N.format),ke=ht.convert(N.type);let _t;N.isData3DTexture?(K.setTexture3D(N,0),_t=L.TEXTURE_3D):N.isDataArrayTexture||N.isCompressedArrayTexture?(K.setTexture2DArray(N,0),_t=L.TEXTURE_2D_ARRAY):(K.setTexture2D(N,0),_t=L.TEXTURE_2D),_.activeTexture(L.TEXTURE0),_.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,N.flipY),_.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),_.pixelStorei(L.UNPACK_ALIGNMENT,N.unpackAlignment);const Qe=_.getParameter(L.UNPACK_ROW_LENGTH),Zt=_.getParameter(L.UNPACK_IMAGE_HEIGHT),an=_.getParameter(L.UNPACK_SKIP_PIXELS),wn=_.getParameter(L.UNPACK_SKIP_ROWS),si=_.getParameter(L.UNPACK_SKIP_IMAGES);_.pixelStorei(L.UNPACK_ROW_LENGTH,ve.width),_.pixelStorei(L.UNPACK_IMAGE_HEIGHT,ve.height),_.pixelStorei(L.UNPACK_SKIP_PIXELS,Rt),_.pixelStorei(L.UNPACK_SKIP_ROWS,Ht),_.pixelStorei(L.UNPACK_SKIP_IMAGES,Wt);const ji=S.isDataArrayTexture||S.isData3DTexture,ae=N.isDataArrayTexture||N.isData3DTexture;if(S.isDepthTexture){const Se=G.get(S),ri=G.get(N),le=G.get(Se.__renderTarget),ai=G.get(ri.__renderTarget);_.bindFramebuffer(L.READ_FRAMEBUFFER,le.__webglFramebuffer),_.bindFramebuffer(L.DRAW_FRAMEBUFFER,ai.__webglFramebuffer);for(let ts=0;ts<Et;ts++)ji&&(L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,G.get(S).__webglTexture,k,Wt+ts),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,G.get(N).__webglTexture,mt,Me+ts)),L.blitFramebuffer(Rt,Ht,xt,pt,Ct,ie,xt,pt,L.DEPTH_BUFFER_BIT,L.NEAREST);_.bindFramebuffer(L.READ_FRAMEBUFFER,null),_.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(k!==0||S.isRenderTargetTexture||G.has(S)){const Se=G.get(S),ri=G.get(N);_.bindFramebuffer(L.READ_FRAMEBUFFER,X),_.bindFramebuffer(L.DRAW_FRAMEBUFFER,U);for(let le=0;le<Et;le++)ji?L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Se.__webglTexture,k,Wt+le):L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Se.__webglTexture,k),ae?L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,ri.__webglTexture,mt,Me+le):L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,ri.__webglTexture,mt),k!==0?L.blitFramebuffer(Rt,Ht,xt,pt,Ct,ie,xt,pt,L.COLOR_BUFFER_BIT,L.NEAREST):ae?L.copyTexSubImage3D(_t,mt,Ct,ie,Me+le,Rt,Ht,xt,pt):L.copyTexSubImage2D(_t,mt,Ct,ie,Rt,Ht,xt,pt);_.bindFramebuffer(L.READ_FRAMEBUFFER,null),_.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else ae?S.isDataTexture||S.isData3DTexture?L.texSubImage3D(_t,mt,Ct,ie,Me,xt,pt,Et,re,ke,ve.data):N.isCompressedArrayTexture?L.compressedTexSubImage3D(_t,mt,Ct,ie,Me,xt,pt,Et,re,ve.data):L.texSubImage3D(_t,mt,Ct,ie,Me,xt,pt,Et,re,ke,ve):S.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,mt,Ct,ie,xt,pt,re,ke,ve.data):S.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,mt,Ct,ie,ve.width,ve.height,re,ve.data):L.texSubImage2D(L.TEXTURE_2D,mt,Ct,ie,xt,pt,re,ke,ve);_.pixelStorei(L.UNPACK_ROW_LENGTH,Qe),_.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Zt),_.pixelStorei(L.UNPACK_SKIP_PIXELS,an),_.pixelStorei(L.UNPACK_SKIP_ROWS,wn),_.pixelStorei(L.UNPACK_SKIP_IMAGES,si),mt===0&&N.generateMipmaps&&L.generateMipmap(_t),_.unbindTexture()},this.initRenderTarget=function(S){G.get(S).__webglFramebuffer===void 0&&K.setupRenderTarget(S)},this.initTexture=function(S){S.isCubeTexture?K.setTextureCube(S,0):S.isData3DTexture?K.setTexture3D(S,0):S.isDataArrayTexture||S.isCompressedArrayTexture?K.setTexture2DArray(S,0):K.setTexture2D(S,0),_.unbindTexture()},this.resetState=function(){q=0,H=0,$=null,_.reset(),gt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Bn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=Kt._getDrawingBufferColorSpace(t),e.unpackColorSpace=Kt._getUnpackColorSpace()}}const nl=Math.PI/180,bu=180/Math.PI;function Mr(i,t,e){return Math.max(t,Math.min(e,i))}const pi=[{altitudeDeg:-90,zenith:[0,0,.02],horizon:[.01,.01,.03]},{altitudeDeg:-18,zenith:[.01,.01,.05],horizon:[.03,.02,.08]},{altitudeDeg:-6,zenith:[.02,.03,.12],horizon:[.25,.12,.15]},{altitudeDeg:0,zenith:[.05,.1,.35],horizon:[.9,.55,.35]},{altitudeDeg:8,zenith:[.1,.22,.55],horizon:[.82,.6,.45]},{altitudeDeg:25,zenith:[.15,.38,.78],horizon:[.76,.82,.91]},{altitudeDeg:90,zenith:[.15,.45,.9],horizon:[.7,.8,.95]}];function ko(i,t,e){return i+(t-i)*e}function Ua(i,t,e){return[ko(i[0],t[0],e),ko(i[1],t[1],e),ko(i[2],t[2],e)]}function il(i){const t=Math.max(pi[0].altitudeDeg,Math.min(pi[pi.length-1].altitudeDeg,i));for(let n=0;n<pi.length-1;n++){const s=pi[n],r=pi[n+1];if(t>=s.altitudeDeg&&t<=r.altitudeDeg){const a=(t-s.altitudeDeg)/(r.altitudeDeg-s.altitudeDeg);return{zenith:Ua(s.zenith,r.zenith,a),horizon:Ua(s.horizon,r.horizon,a)}}}const e=pi[pi.length-1];return{zenith:e.zenith,horizon:e.horizon}}const Au=-18,Tu=-4,xv=1.8;function wu(i){if(i<=Au)return Ta;if(i>=0)return Tu;const t=i/Au;return Ta-(Ta-Tu)*(1-t)**xv}const Mv=-1.5,Ta=6.5,Ru=Ta,Sv=1.6;function Go(i){const t=(Ru-i)/(Ru-Mv);return Mr(t,0,1)**Sv}function un(i,t,e){const n=i*nl,s=t*nl,r=e*Math.cos(n);return{x:r*Math.sin(s),y:e*Math.sin(n),z:-r*Math.cos(s)}}function yv(i,t,e){const n=Math.sqrt(i*i+t*t+e*e),s=n===0?0:Math.asin(Mr(t/n,-1,1))*bu,r=(Math.atan2(i,-e)*bu+360)%360;return{altitudeDeg:s,azimuthDeg:r}}function Ev(i,t){const e=Math.abs(i-t)%360;return e>180?360-e:e}function bv(i,t,e,n){const s=Math.max(0,1-Ev(i,e)/Av),r=Math.exp(-Math.max(0,t)/Tv),a=n>0?Math.max(0,1-n/wv):Math.max(0,1-Math.abs(n+Rv)/Cv);return s*r*a}const Av=90,Tv=12,wv=8,Rv=2,Cv=12;function Dv(i,t,e,n){const{zenith:s,horizon:r}=il(n),a=Mr((i+90)/180,0,1),o=Ua(r,s,a),c=bv(t,i,e,n);if(c<=0)return o;const l=il(n+Pv).horizon,h=[Math.max(r[0],l[0]),Math.max(r[1],l[1]),Math.max(r[2],l[2])];return Ua(o,h,c)}const Pv=6;function Ho(i){return .12+.88*i}const Iv=-4;function Lv(i){return Math.max(0,Iv-i)}const Nv=6,Uv=60;function Fv(i){return Math.min(Uv,Nv*Math.sqrt(i))}const Ov=3,zv=.55;function Bv(i){return zv*Mr(i/Ov,0,1)}function gd(i){const t=Math.max(i,-4),e=Math.sin(t*nl)+.50572*Math.pow(t+6.07995,-1.6364);return Mr(1/e,1,40)}function Ii(i){const t=gd(i)-1;return[1,Math.exp(-.022*t),Math.exp(-.062*t)]}function kv(i){return Hv*(gd(Math.max(i,0))-1)}function Gv(i){return Math.pow(10,-.4*kv(i))}const Hv=5/37,_d=[{maxBrightness:.35,size:1.2},{maxBrightness:.7,size:2},{maxBrightness:1/0,size:3.2}];function Vv(i){return _d.findIndex(t=>i<=t.maxBrightness)}const Wv=.25,Cu=.3,Xv=2.2;function qv(i,{phase:t,speedFactor:e},n){const r=1+Wv*(Cu+(1-Cu)*i)*Math.sin(n*Xv*e+t);return Math.min(1,Math.max(0,r))}/**
4415
+ }`;class vv{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const n=new hd(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){const e=t.cameras[0].viewport,n=new Be({vertexShader:gv,fragmentShader:_v,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new se(new qs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class xv extends ts{constructor(t,e){super();const n=this;let s=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,g=null;const x=typeof XRWebGLBinding<"u",m=new vv,p={},A=e.getContextAttributes();let T=null,M=null;const y=[],b=[],R=new Ft;let v=null;const E=new cn;E.viewport=new pe;const D=new cn;D.viewport=new pe;const C=[E,D],I=new Cm;let W=null,X=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let rt=y[Y];return rt===void 0&&(rt=new So,y[Y]=rt),rt.getTargetRaySpace()},this.getControllerGrip=function(Y){let rt=y[Y];return rt===void 0&&(rt=new So,y[Y]=rt),rt.getGripSpace()},this.getHand=function(Y){let rt=y[Y];return rt===void 0&&(rt=new So,y[Y]=rt),rt.getHandSpace()};function U(Y){const rt=b.indexOf(Y.inputSource);if(rt===-1)return;const nt=y[rt];nt!==void 0&&(nt.update(Y.inputSource,Y.frame,l||a),nt.dispatchEvent({type:Y.type,data:Y.inputSource}))}function q(){s.removeEventListener("select",U),s.removeEventListener("selectstart",U),s.removeEventListener("selectend",U),s.removeEventListener("squeeze",U),s.removeEventListener("squeezestart",U),s.removeEventListener("squeezeend",U),s.removeEventListener("end",q),s.removeEventListener("inputsourceschange",H);for(let Y=0;Y<y.length;Y++){const rt=b[Y];rt!==null&&(b[Y]=null,y[Y].disconnect(rt))}W=null,X=null,m.reset();for(const Y in p)delete p[Y];t.setRenderTarget(T),f=null,d=null,u=null,s=null,M=null,Bt.stop(),n.isPresenting=!1,t.setPixelRatio(v),t.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){r=Y,n.isPresenting===!0&&Ot("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,n.isPresenting===!0&&Ot("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&x&&(u=new XRWebGLBinding(s,e)),u},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(Y){if(s=Y,s!==null){if(T=t.getRenderTarget(),s.addEventListener("select",U),s.addEventListener("selectstart",U),s.addEventListener("selectend",U),s.addEventListener("squeeze",U),s.addEventListener("squeezestart",U),s.addEventListener("squeezeend",U),s.addEventListener("end",q),s.addEventListener("inputsourceschange",H),A.xrCompatible!==!0&&await e.makeXRCompatible(),v=t.getPixelRatio(),t.getSize(R),x&&"createProjectionLayer"in XRWebGLBinding.prototype){let nt=null,z=null,bt=null;A.depth&&(bt=A.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,nt=A.stencil?qi:ai,z=A.stencil?yr:Kn);const Dt={colorFormat:e.RGBA8,depthFormat:bt,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(Dt),s.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),M=new Rn(d.textureWidth,d.textureHeight,{format:un,type:ln,depthTexture:new Hs(d.textureWidth,d.textureHeight,z,void 0,void 0,void 0,void 0,void 0,void 0,nt),stencilBuffer:A.stencil,colorSpace:t.outputColorSpace,samples:A.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const nt={antialias:A.antialias,alpha:!0,depth:A.depth,stencil:A.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(s,e,nt),s.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),M=new Rn(f.framebufferWidth,f.framebufferHeight,{format:un,type:ln,colorSpace:t.outputColorSpace,stencilBuffer:A.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await s.requestReferenceSpace(o),Bt.setContext(s),Bt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function H(Y){for(let rt=0;rt<Y.removed.length;rt++){const nt=Y.removed[rt],z=b.indexOf(nt);z>=0&&(b[z]=null,y[z].disconnect(nt))}for(let rt=0;rt<Y.added.length;rt++){const nt=Y.added[rt];let z=b.indexOf(nt);if(z===-1){for(let Dt=0;Dt<y.length;Dt++)if(Dt>=b.length){b.push(nt),z=Dt;break}else if(b[Dt]===null){b[Dt]=nt,z=Dt;break}if(z===-1)break}const bt=y[z];bt&&bt.connect(nt)}}const $=new F,et=new F;function j(Y,rt,nt){$.setFromMatrixPosition(rt.matrixWorld),et.setFromMatrixPosition(nt.matrixWorld);const z=$.distanceTo(et),bt=rt.projectionMatrix.elements,Dt=nt.projectionMatrix.elements,Tt=bt[14]/(bt[10]-1),vt=bt[14]/(bt[10]+1),It=(bt[9]+1)/bt[5],Lt=(bt[9]-1)/bt[5],Nt=(bt[8]-1)/bt[0],Jt=(Dt[8]+1)/Dt[0],Qt=Tt*Nt,me=Tt*Jt,de=z/(-Nt+Jt),ge=de*-Nt;if(rt.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(ge),Y.translateZ(de),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),bt[10]===-1)Y.projectionMatrix.copy(rt.projectionMatrix),Y.projectionMatrixInverse.copy(rt.projectionMatrixInverse);else{const be=Tt+de,L=vt+de,Je=Qt-ge,jt=me+(z-ge),w=It*vt/L*be,_=Lt*vt/L*be;Y.projectionMatrix.makePerspective(Je,jt,w,_,be,L),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function it(Y,rt){rt===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(rt.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(s===null)return;let rt=Y.near,nt=Y.far;m.texture!==null&&(m.depthNear>0&&(rt=m.depthNear),m.depthFar>0&&(nt=m.depthFar)),I.near=D.near=E.near=rt,I.far=D.far=E.far=nt,(W!==I.near||X!==I.far)&&(s.updateRenderState({depthNear:I.near,depthFar:I.far}),W=I.near,X=I.far),I.layers.mask=Y.layers.mask|6,E.layers.mask=I.layers.mask&-5,D.layers.mask=I.layers.mask&-3;const z=Y.parent,bt=I.cameras;it(I,z);for(let Dt=0;Dt<bt.length;Dt++)it(bt[Dt],z);bt.length===2?j(I,E,D):I.projectionMatrix.copy(E.projectionMatrix),ut(Y,I,z)};function ut(Y,rt,nt){nt===null?Y.matrix.copy(rt.matrixWorld):(Y.matrix.copy(nt.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(rt.matrixWorld)),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(rt.projectionMatrix),Y.projectionMatrixInverse.copy(rt.projectionMatrixInverse),Y.isPerspectiveCamera&&(Y.fov=sl*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return I},this.getFoveation=function(){if(!(d===null&&f===null))return c},this.setFoveation=function(Y){c=Y,d!==null&&(d.fixedFoveation=Y),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=Y)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(I)},this.getCameraTexture=function(Y){return p[Y]};let kt=null;function qt(Y,rt){if(h=rt.getViewerPose(l||a),g=rt,h!==null){const nt=h.views;f!==null&&(t.setRenderTargetFramebuffer(M,f.framebuffer),t.setRenderTarget(M));let z=!1;nt.length!==I.cameras.length&&(I.cameras.length=0,z=!0);for(let vt=0;vt<nt.length;vt++){const It=nt[vt];let Lt=null;if(f!==null)Lt=f.getViewport(It);else{const Jt=u.getViewSubImage(d,It);Lt=Jt.viewport,vt===0&&(t.setRenderTargetTextures(M,Jt.colorTexture,Jt.depthStencilTexture),t.setRenderTarget(M))}let Nt=C[vt];Nt===void 0&&(Nt=new cn,Nt.layers.enable(vt),Nt.viewport=new pe,C[vt]=Nt),Nt.matrix.fromArray(It.transform.matrix),Nt.matrix.decompose(Nt.position,Nt.quaternion,Nt.scale),Nt.projectionMatrix.fromArray(It.projectionMatrix),Nt.projectionMatrixInverse.copy(Nt.projectionMatrix).invert(),Nt.viewport.set(Lt.x,Lt.y,Lt.width,Lt.height),vt===0&&(I.matrix.copy(Nt.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),z===!0&&I.cameras.push(Nt)}const bt=s.enabledFeatures;if(bt&&bt.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&x){u=n.getBinding();const vt=u.getDepthInformation(nt[0]);vt&&vt.isValid&&vt.texture&&m.init(vt,s.renderState)}if(bt&&bt.includes("camera-access")&&x){t.state.unbindTexture(),u=n.getBinding();for(let vt=0;vt<nt.length;vt++){const It=nt[vt].camera;if(It){let Lt=p[It];Lt||(Lt=new hd,p[It]=Lt);const Nt=u.getCameraImage(It);Lt.sourceTexture=Nt}}}}for(let nt=0;nt<y.length;nt++){const z=b[nt],bt=y[nt];z!==null&&bt!==void 0&&bt.update(z,rt,l||a)}kt&&kt(Y,rt),rt.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:rt}),g=null}const Bt=new md;Bt.setAnimationLoop(qt),this.setAnimationLoop=function(Y){kt=Y},this.dispose=function(){}}}const Mv=new he,yd=new zt;yd.set(-1,0,0,0,1,0,0,0,1);function Sv(i,t){function e(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,ud(i)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function s(m,p,A,T,M){p.isNodeMaterial?p.uniformsNeedUpdate=!1:p.isMeshBasicMaterial?r(m,p):p.isMeshLambertMaterial?(r(m,p),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)):p.isMeshToonMaterial?(r(m,p),u(m,p)):p.isMeshPhongMaterial?(r(m,p),h(m,p),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)):p.isMeshStandardMaterial?(r(m,p),d(m,p),p.isMeshPhysicalMaterial&&f(m,p,M)):p.isMeshMatcapMaterial?(r(m,p),g(m,p)):p.isMeshDepthMaterial?r(m,p):p.isMeshDistanceMaterial?(r(m,p),x(m,p)):p.isMeshNormalMaterial?r(m,p):p.isLineBasicMaterial?(a(m,p),p.isLineDashedMaterial&&o(m,p)):p.isPointsMaterial?c(m,p,A,T):p.isSpriteMaterial?l(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,e(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,e(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===Ce&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,e(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===Ce&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,e(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,e(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,e(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);const A=t.get(p),T=A.envMap,M=A.envMapRotation;T&&(m.envMap.value=T,m.envMapRotation.value.setFromMatrix4(Mv.makeRotationFromEuler(M)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(yd),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,e(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,e(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,e(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 c(m,p,A,T){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*A,m.scale.value=T*.5,p.map&&(m.map.value=p.map,e(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function l(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,e(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(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,e(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,A){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,e(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===Ce&&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,e(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=A.texture,m.transmissionSamplerSize.value.set(A.width,A.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,e(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,e(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function x(m,p){const A=t.get(p).light;m.referencePosition.value.setFromMatrixPosition(A.matrixWorld),m.nearDistance.value=A.shadow.camera.near,m.farDistance.value=A.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function yv(i,t,e,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,y){const b=y.program;n.uniformBlockBinding(M,b)}function l(M,y){let b=s[M.id];b===void 0&&(m(M),b=h(M),s[M.id]=b,M.addEventListener("dispose",A));const R=y.program;n.updateUBOMapping(M,R);const v=t.render.frame;r[M.id]!==v&&(d(M),r[M.id]=v)}function h(M){const y=u();M.__bindingPointIndex=y;const b=i.createBuffer(),R=M.__size,v=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,R,v),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,y,b),b}function u(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.push(M),M;return Yt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(M){const y=s[M.id],b=M.uniforms,R=M.__cache;i.bindBuffer(i.UNIFORM_BUFFER,y);for(let v=0,E=b.length;v<E;v++){const D=b[v];if(Array.isArray(D))for(let C=0,I=D.length;C<I;C++)f(D[C],v,C,R);else f(D,v,0,R)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function f(M,y,b,R){if(x(M,y,b,R)===!0){const v=M.__offset,E=M.value;if(Array.isArray(E)){let D=0;for(let C=0;C<E.length;C++){const I=E[C],W=p(I);g(I,M.__data,D),typeof I!="number"&&typeof I!="boolean"&&!I.isMatrix3&&!ArrayBuffer.isView(I)&&(D+=W.storage/Float32Array.BYTES_PER_ELEMENT)}}else g(E,M.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,v,M.__data)}}function g(M,y,b){typeof M=="number"||typeof M=="boolean"?y[0]=M:M.isMatrix3?(y[0]=M.elements[0],y[1]=M.elements[1],y[2]=M.elements[2],y[3]=0,y[4]=M.elements[3],y[5]=M.elements[4],y[6]=M.elements[5],y[7]=0,y[8]=M.elements[6],y[9]=M.elements[7],y[10]=M.elements[8],y[11]=0):ArrayBuffer.isView(M)?y.set(new M.constructor(M.buffer,M.byteOffset,y.length)):M.toArray(y,b)}function x(M,y,b,R){const v=M.value,E=y+"_"+b;if(R[E]===void 0)return typeof v=="number"||typeof v=="boolean"?R[E]=v:ArrayBuffer.isView(v)?R[E]=v.slice():R[E]=v.clone(),!0;{const D=R[E];if(typeof v=="number"||typeof v=="boolean"){if(D!==v)return R[E]=v,!0}else{if(ArrayBuffer.isView(v))return!0;if(D.equals(v)===!1)return D.copy(v),!0}}return!1}function m(M){const y=M.uniforms;let b=0;const R=16;for(let E=0,D=y.length;E<D;E++){const C=Array.isArray(y[E])?y[E]:[y[E]];for(let I=0,W=C.length;I<W;I++){const X=C[I],U=Array.isArray(X.value)?X.value:[X.value];for(let q=0,H=U.length;q<H;q++){const $=U[q],et=p($),j=b%R,it=j%et.boundary,ut=j+it;b+=it,ut!==0&&R-ut<et.storage&&(b+=R-ut),X.__data=new Float32Array(et.storage/Float32Array.BYTES_PER_ELEMENT),X.__offset=b,b+=et.storage}}}const v=b%R;return v>0&&(b+=R-v),M.__size=b,M.__cache={},this}function p(M){const y={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(y.boundary=4,y.storage=4):M.isVector2?(y.boundary=8,y.storage=8):M.isVector3||M.isColor?(y.boundary=16,y.storage=12):M.isVector4?(y.boundary=16,y.storage=16):M.isMatrix3?(y.boundary=48,y.storage=48):M.isMatrix4?(y.boundary=64,y.storage=64):M.isTexture?Ot("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(y.boundary=16,y.storage=M.byteLength):Ot("WebGLRenderer: Unsupported uniform value type.",M),y}function A(M){const y=M.target;y.removeEventListener("dispose",A);const b=a.indexOf(y.__bindingPointIndex);a.splice(b,1),i.deleteBuffer(s[y.id]),delete s[y.id],delete r[y.id]}function T(){for(const M in s)i.deleteBuffer(s[M]);a=[],s={},r={}}return{bind:c,update:l,dispose:T}}const Ev=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Nn=null;function bv(){return Nn===null&&(Nn=new Zl(Ev,16,16,$i,xn),Nn.name="DFG_LUT",Nn.minFilter=we,Nn.magFilter=we,Nn.wrapS=hn,Nn.wrapT=hn,Nn.generateMipmaps=!1,Nn.needsUpdate=!0),Nn}class Av{constructor(t={}){const{canvas:e=kp(),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:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=ln}=t;this.isWebGLRenderer=!0;let g;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=n.getContextAttributes().alpha}else g=a;const x=f,m=new Set([Hl,Gl,kl]),p=new Set([ln,Kn,Sr,yr,zl,Bl]),A=new Uint32Array(4),T=new Int32Array(4),M=new F;let y=null,b=null;const R=[],v=[];let E=null;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=qn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const D=this;let C=!1,I=null,W=null,X=null,U=null;this._outputColorSpace=_n;let q=0,H=0,$=null,et=-1,j=null;const it=new pe,ut=new pe;let kt=null;const qt=new Mt(0);let Bt=0,Y=e.width,rt=e.height,nt=1,z=null,bt=null;const Dt=new pe(0,0,Y,rt),Tt=new pe(0,0,Y,rt);let vt=!1;const It=new $l;let Lt=!1,Nt=!1;const Jt=new he,Qt=new F,me=new pe,de={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ge=!1;function be(){return $===null?nt:1}let L=n;function Je(S,N){return e.getContext(S,N)}try{const S={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Ul}`),e.addEventListener("webglcontextlost",_e,!1),e.addEventListener("webglcontextrestored",oe,!1),e.addEventListener("webglcontextcreationerror",Dn,!1),L===null){const N="webgl2";if(L=Je(N,S),L===null)throw Je(N)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(S){throw Yt("WebGLRenderer: "+S.message),S}let jt,w,_,O,G,K,st,ot,Z,Q,ct,wt,dt,lt,Pt,Ut,Gt,P,at,J,ht,gt,tt;function At(){jt=new b2(L),jt.init(),ht=new mv(L,jt),w=new g2(L,jt,t,ht),_=new fv(L,jt),w.reversedDepthBuffer&&d&&_.buffers.depth.setReversed(!0),W=L.createFramebuffer(),X=L.createFramebuffer(),U=L.createFramebuffer(),O=new w2(L),G=new j_,K=new pv(L,jt,_,G,w,ht,O),st=new E2(D),ot=new Pm(L),gt=new p2(L,ot),Z=new A2(L,ot,O,gt),Q=new C2(L,Z,ot,gt,O),P=new R2(L,w,K),Pt=new _2(G),ct=new Q_(D,st,jt,w,gt,Pt),wt=new Sv(D,G),dt=new ev,lt=new ov(jt),Gt=new f2(D,st,_,Q,g,c),Ut=new dv(D,Q,w),tt=new yv(L,O,w,_),at=new m2(L,jt,O),J=new T2(L,jt,O),O.programs=ct.programs,D.capabilities=w,D.extensions=jt,D.properties=G,D.renderLists=dt,D.shadowMap=Ut,D.state=_,D.info=O}At(),x!==ln&&(E=new P2(x,e.width,e.height,o,s,r));const St=new xv(D,L);this.xr=St,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){const S=jt.get("WEBGL_lose_context");S&&S.loseContext()},this.forceContextRestore=function(){const S=jt.get("WEBGL_lose_context");S&&S.restoreContext()},this.getPixelRatio=function(){return nt},this.setPixelRatio=function(S){S!==void 0&&(nt=S,this.setSize(Y,rt,!1))},this.getSize=function(S){return S.set(Y,rt)},this.setSize=function(S,N,V=!0){if(St.isPresenting){Ot("WebGLRenderer: Can't change size while VR device is presenting.");return}Y=S,rt=N,e.width=Math.floor(S*nt),e.height=Math.floor(N*nt),V===!0&&(e.style.width=S+"px",e.style.height=N+"px"),E!==null&&E.setSize(e.width,e.height),this.setViewport(0,0,S,N)},this.getDrawingBufferSize=function(S){return S.set(Y*nt,rt*nt).floor()},this.setDrawingBufferSize=function(S,N,V){Y=S,rt=N,nt=V,e.width=Math.floor(S*V),e.height=Math.floor(N*V),this.setViewport(0,0,S,N)},this.setEffects=function(S){if(x===ln){Yt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(S){for(let N=0;N<S.length;N++)if(S[N].isOutputPass===!0){Ot("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}E.setEffects(S||[])},this.getCurrentViewport=function(S){return S.copy(it)},this.getViewport=function(S){return S.copy(Dt)},this.setViewport=function(S,N,V,B){S.isVector4?Dt.set(S.x,S.y,S.z,S.w):Dt.set(S,N,V,B),_.viewport(it.copy(Dt).multiplyScalar(nt).round())},this.getScissor=function(S){return S.copy(Tt)},this.setScissor=function(S,N,V,B){S.isVector4?Tt.set(S.x,S.y,S.z,S.w):Tt.set(S,N,V,B),_.scissor(ut.copy(Tt).multiplyScalar(nt).round())},this.getScissorTest=function(){return vt},this.setScissorTest=function(S){_.setScissorTest(vt=S)},this.setOpaqueSort=function(S){z=S},this.setTransparentSort=function(S){bt=S},this.getClearColor=function(S){return S.copy(Gt.getClearColor())},this.setClearColor=function(){Gt.setClearColor(...arguments)},this.getClearAlpha=function(){return Gt.getClearAlpha()},this.setClearAlpha=function(){Gt.setClearAlpha(...arguments)},this.clear=function(S=!0,N=!0,V=!0){let B=0;if(S){let k=!1;if($!==null){const mt=$.texture.format;k=m.has(mt)}if(k){const mt=$.texture.type,xt=p.has(mt),pt=Gt.getClearColor(),Et=Gt.getClearAlpha(),Rt=pt.r,Ht=pt.g,Wt=pt.b;xt?(A[0]=Rt,A[1]=Ht,A[2]=Wt,A[3]=Et,L.clearBufferuiv(L.COLOR,0,A)):(T[0]=Rt,T[1]=Ht,T[2]=Wt,T[3]=Et,L.clearBufferiv(L.COLOR,0,T))}else B|=L.COLOR_BUFFER_BIT}N&&(B|=L.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),V&&(B|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B!==0&&L.clear(B)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(S){S.setRenderer(this),I=S},this.dispose=function(){e.removeEventListener("webglcontextlost",_e,!1),e.removeEventListener("webglcontextrestored",oe,!1),e.removeEventListener("webglcontextcreationerror",Dn,!1),Gt.dispose(),dt.dispose(),lt.dispose(),G.dispose(),st.dispose(),Q.dispose(),gt.dispose(),tt.dispose(),ct.dispose(),St.dispose(),St.removeEventListener("sessionstart",ch),St.removeEventListener("sessionend",lh),Ii.stop()};function _e(S){S.preventDefault(),ka("WebGLRenderer: Context Lost."),C=!0}function oe(){ka("WebGLRenderer: Context Restored."),C=!1;const S=O.autoReset,N=Ut.enabled,V=Ut.autoUpdate,B=Ut.needsUpdate,k=Ut.type;At(),O.autoReset=S,Ut.enabled=N,Ut.autoUpdate=V,Ut.needsUpdate=B,Ut.type=k}function Dn(S){Yt("WebGLRenderer: A WebGL context could not be created. Reason: ",S.statusMessage)}function Pn(S){const N=S.target;N.removeEventListener("dispose",Pn),uf(N)}function uf(S){df(S),G.remove(S)}function df(S){const N=G.get(S).programs;N!==void 0&&(N.forEach(function(V){ct.releaseProgram(V)}),S.isShaderMaterial&&ct.releaseShaderCache(S))}this.renderBufferDirect=function(S,N,V,B,k,mt){N===null&&(N=de);const xt=k.isMesh&&k.matrixWorld.determinantAffine()<0,pt=mf(S,N,V,B,k);_.setMaterial(B,xt);let Et=V.index,Rt=1;if(B.wireframe===!0){if(Et=Z.getWireframeAttribute(V),Et===void 0)return;Rt=2}const Ht=V.drawRange,Wt=V.attributes.position;let Ct=Ht.start*Rt,ne=(Ht.start+Ht.count)*Rt;mt!==null&&(Ct=Math.max(Ct,mt.start*Rt),ne=Math.min(ne,(mt.start+mt.count)*Rt)),Et!==null?(Ct=Math.max(Ct,0),ne=Math.min(ne,Et.count)):Wt!=null&&(Ct=Math.max(Ct,0),ne=Math.min(ne,Wt.count));const Me=ne-Ct;if(Me<0||Me===1/0)return;gt.setup(k,B,pt,V,Et);let ve,re=at;if(Et!==null&&(ve=ot.get(Et),re=J,re.setIndex(ve)),k.isMesh)B.wireframe===!0?(_.setLineWidth(B.wireframeLinewidth*be()),re.setMode(L.LINES)):re.setMode(L.TRIANGLES);else if(k.isLine){let Ge=B.linewidth;Ge===void 0&&(Ge=1),_.setLineWidth(Ge*be()),k.isLineSegments?re.setMode(L.LINES):k.isLineLoop?re.setMode(L.LINE_LOOP):re.setMode(L.LINE_STRIP)}else k.isPoints?re.setMode(L.POINTS):k.isSprite&&re.setMode(L.TRIANGLES);if(k.isBatchedMesh)if(jt.get("WEBGL_multi_draw"))re.renderMultiDraw(k._multiDrawStarts,k._multiDrawCounts,k._multiDrawCount);else{const Ge=k._multiDrawStarts,_t=k._multiDrawCounts,en=k._multiDrawCount,Zt=Et?ot.get(Et).bytesPerElement:1,dn=G.get(B).currentProgram.getUniforms();for(let In=0;In<en;In++)dn.setValue(L,"_gl_DrawID",In),re.render(Ge[In]/Zt,_t[In])}else if(k.isInstancedMesh)re.renderInstances(Ct,Me,k.count);else if(V.isInstancedBufferGeometry){const Ge=V._maxInstanceCount!==void 0?V._maxInstanceCount:1/0,_t=Math.min(V.instanceCount,Ge);re.renderInstances(Ct,Me,_t)}else re.render(Ct,Me)};function oh(S,N,V){S.transparent===!0&&S.side===An&&S.forceSinglePass===!1?(S.side=Ce,S.needsUpdate=!0,Dr(S,N,V),S.side=wi,S.needsUpdate=!0,Dr(S,N,V),S.side=An):Dr(S,N,V)}this.compile=function(S,N,V=null){V===null&&(V=S),b=lt.get(V),b.init(N),v.push(b),V.traverseVisible(function(k){k.isLight&&k.layers.test(N.layers)&&(b.pushLight(k),k.castShadow&&b.pushShadow(k))}),S!==V&&S.traverseVisible(function(k){k.isLight&&k.layers.test(N.layers)&&(b.pushLight(k),k.castShadow&&b.pushShadow(k))}),b.setupLights();const B=new Set;return S.traverse(function(k){if(!(k.isMesh||k.isPoints||k.isLine||k.isSprite))return;const mt=k.material;if(mt)if(Array.isArray(mt))for(let xt=0;xt<mt.length;xt++){const pt=mt[xt];oh(pt,V,k),B.add(pt)}else oh(mt,V,k),B.add(mt)}),b=v.pop(),B},this.compileAsync=function(S,N,V=null){const B=this.compile(S,N,V);return new Promise(k=>{function mt(){if(B.forEach(function(xt){G.get(xt).currentProgram.isReady()&&B.delete(xt)}),B.size===0){k(S);return}setTimeout(mt,10)}jt.get("KHR_parallel_shader_compile")!==null?mt():setTimeout(mt,10)})};let oo=null;function ff(S){oo&&oo(S)}function ch(){Ii.stop()}function lh(){Ii.start()}const Ii=new md;Ii.setAnimationLoop(ff),typeof self<"u"&&Ii.setContext(self),this.setAnimationLoop=function(S){oo=S,St.setAnimationLoop(S),S===null?Ii.stop():Ii.start()},St.addEventListener("sessionstart",ch),St.addEventListener("sessionend",lh),this.render=function(S,N){if(N!==void 0&&N.isCamera!==!0){Yt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;I!==null&&I.renderStart(S,N);const V=St.enabled===!0&&St.isPresenting===!0,B=E!==null&&($===null||V)&&E.begin(D,$);if(S.matrixWorldAutoUpdate===!0&&S.updateMatrixWorld(),N.parent===null&&N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),St.enabled===!0&&St.isPresenting===!0&&(E===null||E.isCompositing()===!1)&&(St.cameraAutoUpdate===!0&&St.updateCamera(N),N=St.getCamera()),S.isScene===!0&&S.onBeforeRender(D,S,N,$),b=lt.get(S,v.length),b.init(N),b.state.textureUnits=K.getTextureUnits(),v.push(b),Jt.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),It.setFromProjectionMatrix(Jt,Wn,N.reversedDepth),Nt=this.localClippingEnabled,Lt=Pt.init(this.clippingPlanes,Nt),y=dt.get(S,R.length),y.init(),R.push(y),St.enabled===!0&&St.isPresenting===!0){const xt=D.xr.getDepthSensingMesh();xt!==null&&co(xt,N,-1/0,D.sortObjects)}co(S,N,0,D.sortObjects),y.finish(),D.sortObjects===!0&&y.sort(z,bt,N.reversedDepth),ge=St.enabled===!1||St.isPresenting===!1||St.hasDepthSensing()===!1,ge&&Gt.addToRenderList(y,S),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Lt===!0&&Pt.beginShadows();const k=b.state.shadowsArray;if(Ut.render(k,S,N),Lt===!0&&Pt.endShadows(),(B&&E.hasRenderPass())===!1){const xt=y.opaque,pt=y.transmissive;if(b.setupLights(),N.isArrayCamera){const Et=N.cameras;if(pt.length>0)for(let Rt=0,Ht=Et.length;Rt<Ht;Rt++){const Wt=Et[Rt];uh(xt,pt,S,Wt)}ge&&Gt.render(S);for(let Rt=0,Ht=Et.length;Rt<Ht;Rt++){const Wt=Et[Rt];hh(y,S,Wt,Wt.viewport)}}else pt.length>0&&uh(xt,pt,S,N),ge&&Gt.render(S),hh(y,S,N)}$!==null&&H===0&&(K.updateMultisampleRenderTarget($),K.updateRenderTargetMipmap($)),B&&E.end(D),S.isScene===!0&&S.onAfterRender(D,S,N),gt.resetDefaultState(),et=-1,j=null,v.pop(),v.length>0?(b=v[v.length-1],K.setTextureUnits(b.state.textureUnits),Lt===!0&&Pt.setGlobalState(D.clippingPlanes,b.state.camera)):b=null,R.pop(),R.length>0?y=R[R.length-1]:y=null,I!==null&&I.renderEnd()};function co(S,N,V,B){if(S.visible===!1)return;if(S.layers.test(N.layers)){if(S.isGroup)V=S.renderOrder;else if(S.isLOD)S.autoUpdate===!0&&S.update(N);else if(S.isLightProbeGrid)b.pushLightProbeGrid(S);else if(S.isLight)b.pushLight(S),S.castShadow&&b.pushShadow(S);else if(S.isSprite){if(!S.frustumCulled||It.intersectsSprite(S)){B&&me.setFromMatrixPosition(S.matrixWorld).applyMatrix4(Jt);const xt=Q.update(S),pt=S.material;pt.visible&&y.push(S,xt,pt,V,me.z,null)}}else if((S.isMesh||S.isLine||S.isPoints)&&(!S.frustumCulled||It.intersectsObject(S))){const xt=Q.update(S),pt=S.material;if(B&&(S.boundingSphere!==void 0?(S.boundingSphere===null&&S.computeBoundingSphere(),me.copy(S.boundingSphere.center)):(xt.boundingSphere===null&&xt.computeBoundingSphere(),me.copy(xt.boundingSphere.center)),me.applyMatrix4(S.matrixWorld).applyMatrix4(Jt)),Array.isArray(pt)){const Et=xt.groups;for(let Rt=0,Ht=Et.length;Rt<Ht;Rt++){const Wt=Et[Rt],Ct=pt[Wt.materialIndex];Ct&&Ct.visible&&y.push(S,xt,Ct,V,me.z,Wt)}}else pt.visible&&y.push(S,xt,pt,V,me.z,null)}}const mt=S.children;for(let xt=0,pt=mt.length;xt<pt;xt++)co(mt[xt],N,V,B)}function hh(S,N,V,B){const{opaque:k,transmissive:mt,transparent:xt}=S;b.setupLightsView(V),Lt===!0&&Pt.setGlobalState(D.clippingPlanes,V),B&&_.viewport(it.copy(B)),k.length>0&&Cr(k,N,V),mt.length>0&&Cr(mt,N,V),xt.length>0&&Cr(xt,N,V),_.buffers.depth.setTest(!0),_.buffers.depth.setMask(!0),_.buffers.color.setMask(!0),_.setPolygonOffset(!1)}function uh(S,N,V,B){if((V.isScene===!0?V.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[B.id]===void 0){const Ct=jt.has("EXT_color_buffer_half_float")||jt.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[B.id]=new Rn(1,1,{generateMipmaps:!0,type:Ct?xn:ln,minFilter:Xi,samples:Math.max(4,w.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Kt.workingColorSpace})}const mt=b.state.transmissionRenderTarget[B.id],xt=B.viewport||it;mt.setSize(xt.z*D.transmissionResolutionScale,xt.w*D.transmissionResolutionScale);const pt=D.getRenderTarget(),Et=D.getActiveCubeFace(),Rt=D.getActiveMipmapLevel();D.setRenderTarget(mt),D.getClearColor(qt),Bt=D.getClearAlpha(),Bt<1&&D.setClearColor(16777215,.5),D.clear(),ge&&Gt.render(V);const Ht=D.toneMapping;D.toneMapping=qn;const Wt=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),b.setupLightsView(B),Lt===!0&&Pt.setGlobalState(D.clippingPlanes,B),Cr(S,V,B),K.updateMultisampleRenderTarget(mt),K.updateRenderTargetMipmap(mt),jt.has("WEBGL_multisampled_render_to_texture")===!1){let Ct=!1;for(let ne=0,Me=N.length;ne<Me;ne++){const ve=N[ne],{object:re,geometry:Ge,material:_t,group:en}=ve;if(_t.side===An&&re.layers.test(B.layers)){const Zt=_t.side;_t.side=Ce,_t.needsUpdate=!0,dh(re,V,B,Ge,_t,en),_t.side=Zt,_t.needsUpdate=!0,Ct=!0}}Ct===!0&&(K.updateMultisampleRenderTarget(mt),K.updateRenderTargetMipmap(mt))}D.setRenderTarget(pt,Et,Rt),D.setClearColor(qt,Bt),Wt!==void 0&&(B.viewport=Wt),D.toneMapping=Ht}function Cr(S,N,V){const B=N.isScene===!0?N.overrideMaterial:null;for(let k=0,mt=S.length;k<mt;k++){const xt=S[k],{object:pt,geometry:Et,group:Rt}=xt;let Ht=xt.material;Ht.allowOverride===!0&&B!==null&&(Ht=B),pt.layers.test(V.layers)&&dh(pt,N,V,Et,Ht,Rt)}}function dh(S,N,V,B,k,mt){S.onBeforeRender(D,N,V,B,k,mt),S.modelViewMatrix.multiplyMatrices(V.matrixWorldInverse,S.matrixWorld),S.normalMatrix.getNormalMatrix(S.modelViewMatrix),k.onBeforeRender(D,N,V,B,S,mt),k.transparent===!0&&k.side===An&&k.forceSinglePass===!1?(k.side=Ce,k.needsUpdate=!0,D.renderBufferDirect(V,N,B,k,S,mt),k.side=wi,k.needsUpdate=!0,D.renderBufferDirect(V,N,B,k,S,mt),k.side=An):D.renderBufferDirect(V,N,B,k,S,mt),S.onAfterRender(D,N,V,B,k,mt)}function Dr(S,N,V){N.isScene!==!0&&(N=de);const B=G.get(S),k=b.state.lights,mt=b.state.shadowsArray,xt=k.state.version,pt=ct.getParameters(S,k.state,mt,N,V,b.state.lightProbeGridArray),Et=ct.getProgramCacheKey(pt);let Rt=B.programs;B.environment=S.isMeshStandardMaterial||S.isMeshLambertMaterial||S.isMeshPhongMaterial?N.environment:null,B.fog=N.fog;const Ht=S.isMeshStandardMaterial||S.isMeshLambertMaterial&&!S.envMap||S.isMeshPhongMaterial&&!S.envMap;B.envMap=st.get(S.envMap||B.environment,Ht),B.envMapRotation=B.environment!==null&&S.envMap===null?N.environmentRotation:S.envMapRotation,Rt===void 0&&(S.addEventListener("dispose",Pn),Rt=new Map,B.programs=Rt);let Wt=Rt.get(Et);if(Wt!==void 0){if(B.currentProgram===Wt&&B.lightsStateVersion===xt)return ph(S,pt),Wt}else pt.uniforms=ct.getUniforms(S),I!==null&&S.isNodeMaterial&&I.build(S,V,pt),S.onBeforeCompile(pt,D),Wt=ct.acquireProgram(pt,Et),Rt.set(Et,Wt),B.uniforms=pt.uniforms;const Ct=B.uniforms;return(!S.isShaderMaterial&&!S.isRawShaderMaterial||S.clipping===!0)&&(Ct.clippingPlanes=Pt.uniform),ph(S,pt),B.needsLights=_f(S),B.lightsStateVersion=xt,B.needsLights&&(Ct.ambientLightColor.value=k.state.ambient,Ct.lightProbe.value=k.state.probe,Ct.directionalLights.value=k.state.directional,Ct.directionalLightShadows.value=k.state.directionalShadow,Ct.spotLights.value=k.state.spot,Ct.spotLightShadows.value=k.state.spotShadow,Ct.rectAreaLights.value=k.state.rectArea,Ct.ltc_1.value=k.state.rectAreaLTC1,Ct.ltc_2.value=k.state.rectAreaLTC2,Ct.pointLights.value=k.state.point,Ct.pointLightShadows.value=k.state.pointShadow,Ct.hemisphereLights.value=k.state.hemi,Ct.directionalShadowMatrix.value=k.state.directionalShadowMatrix,Ct.spotLightMatrix.value=k.state.spotLightMatrix,Ct.spotLightMap.value=k.state.spotLightMap,Ct.pointShadowMatrix.value=k.state.pointShadowMatrix),B.lightProbeGrid=b.state.lightProbeGridArray.length>0,B.currentProgram=Wt,B.uniformsList=null,Wt}function fh(S){if(S.uniformsList===null){const N=S.currentProgram.getUniforms();S.uniformsList=Ia.seqWithValue(N.seq,S.uniforms)}return S.uniformsList}function ph(S,N){const V=G.get(S);V.outputColorSpace=N.outputColorSpace,V.batching=N.batching,V.batchingColor=N.batchingColor,V.instancing=N.instancing,V.instancingColor=N.instancingColor,V.instancingMorph=N.instancingMorph,V.skinning=N.skinning,V.morphTargets=N.morphTargets,V.morphNormals=N.morphNormals,V.morphColors=N.morphColors,V.morphTargetsCount=N.morphTargetsCount,V.numClippingPlanes=N.numClippingPlanes,V.numIntersection=N.numClipIntersection,V.vertexAlphas=N.vertexAlphas,V.vertexTangents=N.vertexTangents,V.toneMapping=N.toneMapping}function pf(S,N){if(S.length===0)return null;if(S.length===1)return S[0].texture!==null?S[0]:null;M.setFromMatrixPosition(N.matrixWorld);for(let V=0,B=S.length;V<B;V++){const k=S[V];if(k.texture!==null&&k.boundingBox.containsPoint(M))return k}return null}function mf(S,N,V,B,k){N.isScene!==!0&&(N=de),K.resetTextureUnits();const mt=N.fog,xt=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?N.environment:null,pt=$===null?D.outputColorSpace:$.isXRRenderTarget===!0?$.texture.colorSpace:Kt.workingColorSpace,Et=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Rt=st.get(B.envMap||xt,Et),Ht=B.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,Wt=!!V.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Ct=!!V.morphAttributes.position,ne=!!V.morphAttributes.normal,Me=!!V.morphAttributes.color;let ve=qn;B.toneMapped&&($===null||$.isXRRenderTarget===!0)&&(ve=D.toneMapping);const re=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,Ge=re!==void 0?re.length:0,_t=G.get(B),en=b.state.lights;if(Lt===!0&&(Nt===!0||S!==j)){const ce=S===j&&B.id===et;Pt.setState(B,S,ce)}let Zt=!1;B.version===_t.__version?(_t.needsLights&&_t.lightsStateVersion!==en.state.version||_t.outputColorSpace!==pt||k.isBatchedMesh&&_t.batching===!1||!k.isBatchedMesh&&_t.batching===!0||k.isBatchedMesh&&_t.batchingColor===!0&&k.colorTexture===null||k.isBatchedMesh&&_t.batchingColor===!1&&k.colorTexture!==null||k.isInstancedMesh&&_t.instancing===!1||!k.isInstancedMesh&&_t.instancing===!0||k.isSkinnedMesh&&_t.skinning===!1||!k.isSkinnedMesh&&_t.skinning===!0||k.isInstancedMesh&&_t.instancingColor===!0&&k.instanceColor===null||k.isInstancedMesh&&_t.instancingColor===!1&&k.instanceColor!==null||k.isInstancedMesh&&_t.instancingMorph===!0&&k.morphTexture===null||k.isInstancedMesh&&_t.instancingMorph===!1&&k.morphTexture!==null||_t.envMap!==Rt||B.fog===!0&&_t.fog!==mt||_t.numClippingPlanes!==void 0&&(_t.numClippingPlanes!==Pt.numPlanes||_t.numIntersection!==Pt.numIntersection)||_t.vertexAlphas!==Ht||_t.vertexTangents!==Wt||_t.morphTargets!==Ct||_t.morphNormals!==ne||_t.morphColors!==Me||_t.toneMapping!==ve||_t.morphTargetsCount!==Ge||!!_t.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(Zt=!0):(Zt=!0,_t.__version=B.version);let dn=_t.currentProgram;Zt===!0&&(dn=Dr(B,N,k),I&&B.isNodeMaterial&&I.onUpdateProgram(B,dn,_t));let In=!1,ci=!1,ns=!1;const ae=dn.getUniforms(),Se=_t.uniforms;if(_.useProgram(dn.program)&&(In=!0,ci=!0,ns=!0),B.id!==et&&(et=B.id,ci=!0),_t.needsLights){const ce=pf(b.state.lightProbeGridArray,k);_t.lightProbeGrid!==ce&&(_t.lightProbeGrid=ce,ci=!0)}if(In||j!==S){_.buffers.depth.getReversed()&&S.reversedDepth!==!0&&(S._reversedDepth=!0,S.updateProjectionMatrix()),ae.setValue(L,"projectionMatrix",S.projectionMatrix),ae.setValue(L,"viewMatrix",S.matrixWorldInverse);const hi=ae.map.cameraPosition;hi!==void 0&&hi.setValue(L,Qt.setFromMatrixPosition(S.matrixWorld)),w.logarithmicDepthBuffer&&ae.setValue(L,"logDepthBufFC",2/(Math.log(S.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&ae.setValue(L,"isOrthographic",S.isOrthographicCamera===!0),j!==S&&(j=S,ci=!0,ns=!0)}if(_t.needsLights&&(en.state.directionalShadowMap.length>0&&ae.setValue(L,"directionalShadowMap",en.state.directionalShadowMap,K),en.state.spotShadowMap.length>0&&ae.setValue(L,"spotShadowMap",en.state.spotShadowMap,K),en.state.pointShadowMap.length>0&&ae.setValue(L,"pointShadowMap",en.state.pointShadowMap,K)),k.isSkinnedMesh){ae.setOptional(L,k,"bindMatrix"),ae.setOptional(L,k,"bindMatrixInverse");const ce=k.skeleton;ce&&(ce.boneTexture===null&&ce.computeBoneTexture(),ae.setValue(L,"boneTexture",ce.boneTexture,K))}k.isBatchedMesh&&(ae.setOptional(L,k,"batchingTexture"),ae.setValue(L,"batchingTexture",k._matricesTexture,K),ae.setOptional(L,k,"batchingIdTexture"),ae.setValue(L,"batchingIdTexture",k._indirectTexture,K),ae.setOptional(L,k,"batchingColorTexture"),k._colorsTexture!==null&&ae.setValue(L,"batchingColorTexture",k._colorsTexture,K));const li=V.morphAttributes;if((li.position!==void 0||li.normal!==void 0||li.color!==void 0)&&P.update(k,V,dn),(ci||_t.receiveShadow!==k.receiveShadow)&&(_t.receiveShadow=k.receiveShadow,ae.setValue(L,"receiveShadow",k.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&N.environment!==null&&(Se.envMapIntensity.value=N.environmentIntensity),Se.dfgLUT!==void 0&&(Se.dfgLUT.value=bv()),ci){if(ae.setValue(L,"toneMappingExposure",D.toneMappingExposure),_t.needsLights&&gf(Se,ns),mt&&B.fog===!0&&wt.refreshFogUniforms(Se,mt),wt.refreshMaterialUniforms(Se,B,nt,rt,b.state.transmissionRenderTarget[S.id]),_t.needsLights&&_t.lightProbeGrid){const ce=_t.lightProbeGrid;Se.probesSH.value=ce.texture,Se.probesMin.value.copy(ce.boundingBox.min),Se.probesMax.value.copy(ce.boundingBox.max),Se.probesResolution.value.copy(ce.resolution)}Ia.upload(L,fh(_t),Se,K)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(Ia.upload(L,fh(_t),Se,K),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&ae.setValue(L,"center",k.center),ae.setValue(L,"modelViewMatrix",k.modelViewMatrix),ae.setValue(L,"normalMatrix",k.normalMatrix),ae.setValue(L,"modelMatrix",k.matrixWorld),B.uniformsGroups!==void 0){const ce=B.uniformsGroups;for(let hi=0,is=ce.length;hi<is;hi++){const mh=ce[hi];tt.update(mh,dn),tt.bind(mh,dn)}}return dn}function gf(S,N){S.ambientLightColor.needsUpdate=N,S.lightProbe.needsUpdate=N,S.directionalLights.needsUpdate=N,S.directionalLightShadows.needsUpdate=N,S.pointLights.needsUpdate=N,S.pointLightShadows.needsUpdate=N,S.spotLights.needsUpdate=N,S.spotLightShadows.needsUpdate=N,S.rectAreaLights.needsUpdate=N,S.hemisphereLights.needsUpdate=N}function _f(S){return S.isMeshLambertMaterial||S.isMeshToonMaterial||S.isMeshPhongMaterial||S.isMeshStandardMaterial||S.isShadowMaterial||S.isShaderMaterial&&S.lights===!0}this.getActiveCubeFace=function(){return q},this.getActiveMipmapLevel=function(){return H},this.getRenderTarget=function(){return $},this.setRenderTargetTextures=function(S,N,V){const B=G.get(S);B.__autoAllocateDepthBuffer=S.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),G.get(S.texture).__webglTexture=N,G.get(S.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:V,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(S,N){const V=G.get(S);V.__webglFramebuffer=N,V.__useDefaultFramebuffer=N===void 0},this.setRenderTarget=function(S,N=0,V=0){$=S,q=N,H=V;let B=null,k=!1,mt=!1;if(S){const pt=G.get(S);if(pt.__useDefaultFramebuffer!==void 0){_.bindFramebuffer(L.FRAMEBUFFER,pt.__webglFramebuffer),it.copy(S.viewport),ut.copy(S.scissor),kt=S.scissorTest,_.viewport(it),_.scissor(ut),_.setScissorTest(kt),et=-1;return}else if(pt.__webglFramebuffer===void 0)K.setupRenderTarget(S);else if(pt.__hasExternalTextures)K.rebindTextures(S,G.get(S.texture).__webglTexture,G.get(S.depthTexture).__webglTexture);else if(S.depthBuffer){const Ht=S.depthTexture;if(pt.__boundDepthTexture!==Ht){if(Ht!==null&&G.has(Ht)&&(S.width!==Ht.image.width||S.height!==Ht.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");K.setupDepthRenderbuffer(S)}}const Et=S.texture;(Et.isData3DTexture||Et.isDataArrayTexture||Et.isCompressedArrayTexture)&&(mt=!0);const Rt=G.get(S).__webglFramebuffer;S.isWebGLCubeRenderTarget?(Array.isArray(Rt[N])?B=Rt[N][V]:B=Rt[N],k=!0):S.samples>0&&K.useMultisampledRTT(S)===!1?B=G.get(S).__webglMultisampledFramebuffer:Array.isArray(Rt)?B=Rt[V]:B=Rt,it.copy(S.viewport),ut.copy(S.scissor),kt=S.scissorTest}else it.copy(Dt).multiplyScalar(nt).floor(),ut.copy(Tt).multiplyScalar(nt).floor(),kt=vt;if(V!==0&&(B=W),_.bindFramebuffer(L.FRAMEBUFFER,B)&&_.drawBuffers(S,B),_.viewport(it),_.scissor(ut),_.setScissorTest(kt),k){const pt=G.get(S.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+N,pt.__webglTexture,V)}else if(mt){const pt=N;for(let Et=0;Et<S.textures.length;Et++){const Rt=G.get(S.textures[Et]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+Et,Rt.__webglTexture,V,pt)}}else if(S!==null&&V!==0){const pt=G.get(S.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,pt.__webglTexture,V)}et=-1},this.readRenderTargetPixels=function(S,N,V,B,k,mt,xt,pt=0){if(!(S&&S.isWebGLRenderTarget)){Yt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Et=G.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&xt!==void 0&&(Et=Et[xt]),Et){_.bindFramebuffer(L.FRAMEBUFFER,Et);try{const Rt=S.textures[pt],Ht=Rt.format,Wt=Rt.type;if(S.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+pt),!w.textureFormatReadable(Ht)){Yt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!w.textureTypeReadable(Wt)){Yt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}N>=0&&N<=S.width-B&&V>=0&&V<=S.height-k&&L.readPixels(N,V,B,k,ht.convert(Ht),ht.convert(Wt),mt)}finally{const Rt=$!==null?G.get($).__webglFramebuffer:null;_.bindFramebuffer(L.FRAMEBUFFER,Rt)}}},this.readRenderTargetPixelsAsync=async function(S,N,V,B,k,mt,xt,pt=0){if(!(S&&S.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Et=G.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&xt!==void 0&&(Et=Et[xt]),Et)if(N>=0&&N<=S.width-B&&V>=0&&V<=S.height-k){_.bindFramebuffer(L.FRAMEBUFFER,Et);const Rt=S.textures[pt],Ht=Rt.format,Wt=Rt.type;if(S.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+pt),!w.textureFormatReadable(Ht))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!w.textureTypeReadable(Wt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ct=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,Ct),L.bufferData(L.PIXEL_PACK_BUFFER,mt.byteLength,L.STREAM_READ),L.readPixels(N,V,B,k,ht.convert(Ht),ht.convert(Wt),0);const ne=$!==null?G.get($).__webglFramebuffer:null;_.bindFramebuffer(L.FRAMEBUFFER,ne);const Me=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await Gp(L,Me,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,Ct),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,mt),L.deleteBuffer(Ct),L.deleteSync(Me),mt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(S,N=null,V=0){const B=Math.pow(2,-V),k=Math.floor(S.image.width*B),mt=Math.floor(S.image.height*B),xt=N!==null?N.x:0,pt=N!==null?N.y:0;K.setTexture2D(S,0),L.copyTexSubImage2D(L.TEXTURE_2D,V,0,0,xt,pt,k,mt),_.unbindTexture()},this.copyTextureToTexture=function(S,N,V=null,B=null,k=0,mt=0){let xt,pt,Et,Rt,Ht,Wt,Ct,ne,Me;const ve=S.isCompressedTexture?S.mipmaps[mt]:S.image;if(V!==null)xt=V.max.x-V.min.x,pt=V.max.y-V.min.y,Et=V.isBox3?V.max.z-V.min.z:1,Rt=V.min.x,Ht=V.min.y,Wt=V.isBox3?V.min.z:0;else{const Se=Math.pow(2,-k);xt=Math.floor(ve.width*Se),pt=Math.floor(ve.height*Se),S.isDataArrayTexture?Et=ve.depth:S.isData3DTexture?Et=Math.floor(ve.depth*Se):Et=1,Rt=0,Ht=0,Wt=0}B!==null?(Ct=B.x,ne=B.y,Me=B.z):(Ct=0,ne=0,Me=0);const re=ht.convert(N.format),Ge=ht.convert(N.type);let _t;N.isData3DTexture?(K.setTexture3D(N,0),_t=L.TEXTURE_3D):N.isDataArrayTexture||N.isCompressedArrayTexture?(K.setTexture2DArray(N,0),_t=L.TEXTURE_2D_ARRAY):(K.setTexture2D(N,0),_t=L.TEXTURE_2D),_.activeTexture(L.TEXTURE0),_.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,N.flipY),_.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),_.pixelStorei(L.UNPACK_ALIGNMENT,N.unpackAlignment);const en=_.getParameter(L.UNPACK_ROW_LENGTH),Zt=_.getParameter(L.UNPACK_IMAGE_HEIGHT),dn=_.getParameter(L.UNPACK_SKIP_PIXELS),In=_.getParameter(L.UNPACK_SKIP_ROWS),ci=_.getParameter(L.UNPACK_SKIP_IMAGES);_.pixelStorei(L.UNPACK_ROW_LENGTH,ve.width),_.pixelStorei(L.UNPACK_IMAGE_HEIGHT,ve.height),_.pixelStorei(L.UNPACK_SKIP_PIXELS,Rt),_.pixelStorei(L.UNPACK_SKIP_ROWS,Ht),_.pixelStorei(L.UNPACK_SKIP_IMAGES,Wt);const ns=S.isDataArrayTexture||S.isData3DTexture,ae=N.isDataArrayTexture||N.isData3DTexture;if(S.isDepthTexture){const Se=G.get(S),li=G.get(N),ce=G.get(Se.__renderTarget),hi=G.get(li.__renderTarget);_.bindFramebuffer(L.READ_FRAMEBUFFER,ce.__webglFramebuffer),_.bindFramebuffer(L.DRAW_FRAMEBUFFER,hi.__webglFramebuffer);for(let is=0;is<Et;is++)ns&&(L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,G.get(S).__webglTexture,k,Wt+is),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,G.get(N).__webglTexture,mt,Me+is)),L.blitFramebuffer(Rt,Ht,xt,pt,Ct,ne,xt,pt,L.DEPTH_BUFFER_BIT,L.NEAREST);_.bindFramebuffer(L.READ_FRAMEBUFFER,null),_.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(k!==0||S.isRenderTargetTexture||G.has(S)){const Se=G.get(S),li=G.get(N);_.bindFramebuffer(L.READ_FRAMEBUFFER,X),_.bindFramebuffer(L.DRAW_FRAMEBUFFER,U);for(let ce=0;ce<Et;ce++)ns?L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Se.__webglTexture,k,Wt+ce):L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Se.__webglTexture,k),ae?L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,li.__webglTexture,mt,Me+ce):L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,li.__webglTexture,mt),k!==0?L.blitFramebuffer(Rt,Ht,xt,pt,Ct,ne,xt,pt,L.COLOR_BUFFER_BIT,L.NEAREST):ae?L.copyTexSubImage3D(_t,mt,Ct,ne,Me+ce,Rt,Ht,xt,pt):L.copyTexSubImage2D(_t,mt,Ct,ne,Rt,Ht,xt,pt);_.bindFramebuffer(L.READ_FRAMEBUFFER,null),_.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else ae?S.isDataTexture||S.isData3DTexture?L.texSubImage3D(_t,mt,Ct,ne,Me,xt,pt,Et,re,Ge,ve.data):N.isCompressedArrayTexture?L.compressedTexSubImage3D(_t,mt,Ct,ne,Me,xt,pt,Et,re,ve.data):L.texSubImage3D(_t,mt,Ct,ne,Me,xt,pt,Et,re,Ge,ve):S.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,mt,Ct,ne,xt,pt,re,Ge,ve.data):S.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,mt,Ct,ne,ve.width,ve.height,re,ve.data):L.texSubImage2D(L.TEXTURE_2D,mt,Ct,ne,xt,pt,re,Ge,ve);_.pixelStorei(L.UNPACK_ROW_LENGTH,en),_.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Zt),_.pixelStorei(L.UNPACK_SKIP_PIXELS,dn),_.pixelStorei(L.UNPACK_SKIP_ROWS,In),_.pixelStorei(L.UNPACK_SKIP_IMAGES,ci),mt===0&&N.generateMipmaps&&L.generateMipmap(_t),_.unbindTexture()},this.initRenderTarget=function(S){G.get(S).__webglFramebuffer===void 0&&K.setupRenderTarget(S)},this.initTexture=function(S){S.isCubeTexture?K.setTextureCube(S,0):S.isData3DTexture?K.setTexture3D(S,0):S.isDataArrayTexture||S.isCompressedArrayTexture?K.setTexture2DArray(S,0):K.setTexture2D(S,0),_.unbindTexture()},this.resetState=function(){q=0,H=0,$=null,_.reset(),gt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Wn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=Kt._getDrawingBufferColorSpace(t),e.unpackColorSpace=Kt._getUnpackColorSpace()}}const ll=Math.PI/180,Iu=180/Math.PI;function wr(i,t,e){return Math.max(t,Math.min(e,i))}const vi=[{altitudeDeg:-90,zenith:[0,0,.02],horizon:[.01,.01,.03]},{altitudeDeg:-18,zenith:[.01,.01,.05],horizon:[.03,.02,.08]},{altitudeDeg:-6,zenith:[.02,.03,.12],horizon:[.25,.12,.15]},{altitudeDeg:0,zenith:[.05,.1,.35],horizon:[.9,.55,.35]},{altitudeDeg:8,zenith:[.1,.22,.55],horizon:[.82,.6,.45]},{altitudeDeg:25,zenith:[.15,.38,.78],horizon:[.76,.82,.91]},{altitudeDeg:90,zenith:[.15,.45,.9],horizon:[.7,.8,.95]}];function Yo(i,t,e){return i+(t-i)*e}function Ha(i,t,e){return[Yo(i[0],t[0],e),Yo(i[1],t[1],e),Yo(i[2],t[2],e)]}function hl(i){const t=Math.max(vi[0].altitudeDeg,Math.min(vi[vi.length-1].altitudeDeg,i));for(let n=0;n<vi.length-1;n++){const s=vi[n],r=vi[n+1];if(t>=s.altitudeDeg&&t<=r.altitudeDeg){const a=(t-s.altitudeDeg)/(r.altitudeDeg-s.altitudeDeg);return{zenith:Ha(s.zenith,r.zenith,a),horizon:Ha(s.horizon,r.horizon,a)}}}const e=vi[vi.length-1];return{zenith:e.zenith,horizon:e.horizon}}const Lu=-18,Nu=-4,Tv=1.8;function Uu(i){if(i<=Lu)return La;if(i>=0)return Nu;const t=i/Lu;return La-(La-Nu)*(1-t)**Tv}const wv=-1.5,La=6.5,Fu=La,Rv=1.6;function Ko(i){const t=(Fu-i)/(Fu-wv);return wr(t,0,1)**Rv}function an(i,t,e){const n=i*ll,s=t*ll,r=e*Math.cos(n);return{x:r*Math.sin(s),y:e*Math.sin(n),z:-r*Math.cos(s)}}function Cv(i,t,e){const n=Math.sqrt(i*i+t*t+e*e),s=n===0?0:Math.asin(wr(t/n,-1,1))*Iu,r=(Math.atan2(i,-e)*Iu+360)%360;return{altitudeDeg:s,azimuthDeg:r}}function Dv(i,t){const e=Math.abs(i-t)%360;return e>180?360-e:e}function Pv(i,t,e,n){const s=Math.max(0,1-Dv(i,e)/Iv),r=Math.exp(-Math.max(0,t)/Lv),a=n>0?Math.max(0,1-n/Nv):Math.max(0,1-Math.abs(n+Uv)/Fv);return s*r*a}const Iv=90,Lv=12,Nv=8,Uv=2,Fv=12;function Ov(i,t,e,n){const{zenith:s,horizon:r}=hl(n),a=wr((i+90)/180,0,1),o=Ha(r,s,a),c=Pv(t,i,e,n);if(c<=0)return o;const l=hl(n+zv).horizon,h=[Math.max(r[0],l[0]),Math.max(r[1],l[1]),Math.max(r[2],l[2])];return Ha(o,h,c)}const zv=6;function Zo(i){return .12+.88*i}const Bv=-4;function kv(i){return Math.max(0,Bv-i)}const Gv=6,Hv=60;function Vv(i){return Math.min(Hv,Gv*Math.sqrt(i))}const Wv=3,Xv=.55;function qv(i){return Xv*wr(i/Wv,0,1)}function Ed(i){const t=Math.max(i,-4),e=Math.sin(t*ll)+.50572*Math.pow(t+6.07995,-1.6364);return wr(1/e,1,40)}function Oi(i){const t=Ed(i)-1;return[1,Math.exp(-.022*t),Math.exp(-.062*t)]}function Yv(i){return Zv*(Ed(Math.max(i,0))-1)}function Kv(i){return Math.pow(10,-.4*Yv(i))}const Zv=5/37,bd=[{maxBrightness:.35,size:1.2},{maxBrightness:.7,size:2},{maxBrightness:1/0,size:3.2}];function $v(i){return bd.findIndex(t=>i<=t.maxBrightness)}const Jv=.25,Ou=.3,Qv=2.2;function jv(i,{phase:t,speedFactor:e},n){const r=1+Jv*(Ou+(1-Ou)*i)*Math.sin(n*Qv*e+t);return Math.min(1,Math.max(0,r))}/**
4416
4416
  @preserve
4417
4417
 
4418
4418
  Astronomy library for JavaScript (browser and Node.js).
@@ -4443,11 +4443,11 @@ void main() {
4443
4443
  * @fileoverview Astronomy calculation library for browser scripting and Node.js.
4444
4444
  * @author Don Cross <cosinekitty@gmail.com>
4445
4445
  * @license MIT
4446
- */const Xl=173.1446326846693,zi=14959787069098932e-8,ne=.017453292519943295,Du=.26179938779914946,Hn=57.29577951308232,vd=3.819718634205488,Yv=365.24217,Pu=new Date("2000-01-01T12:00:00Z"),$n=2*Math.PI,mi=3600*(180/Math.PI),As=484813681109536e-20,xd=10800*60,Kv=2*xd,Iu=7292115e-11,Zv=xd/Math.PI,$v=-.17-5*Math.log10(Zv),sl=.996647180302104,Jv=sl*sl,rl=6378.1366,Qv=rl/zi,Md=81.30056,ql=.0002959122082855911,al=2825345909524226e-22,ol=8459715185680659e-23,cl=1292024916781969e-23,ll=1524358900784276e-23;function Fa(i){if(i!==!0&&i!==!1)throw console.trace(),`Value is not boolean: ${i}`;return i}function Ue(i){if(!Number.isFinite(i))throw console.trace(),`Value is not a finite number: ${i}`;return i}function xs(i){return i-Math.floor(i)}function jv(i,t){const e=i.x*i.x+i.y*i.y+i.z*i.z;if(Math.abs(e)<1e-8)throw"AngleBetween: first vector is too short.";const n=t.x*t.x+t.y*t.y+t.z*t.z;if(Math.abs(n)<1e-8)throw"AngleBetween: second vector is too short.";const s=(i.x*t.x+i.y*t.y+i.z*t.z)/Math.sqrt(e*n);return s<=-1?180:s>=1?0:Hn*Math.acos(s)}var yt;(function(i){i.Sun="Sun",i.Moon="Moon",i.Mercury="Mercury",i.Venus="Venus",i.Earth="Earth",i.Mars="Mars",i.Jupiter="Jupiter",i.Saturn="Saturn",i.Uranus="Uranus",i.Neptune="Neptune",i.Pluto="Pluto",i.SSB="SSB",i.EMB="EMB",i.Star1="Star1",i.Star2="Star2",i.Star3="Star3",i.Star4="Star4",i.Star5="Star5",i.Star6="Star6",i.Star7="Star7",i.Star8="Star8"})(yt||(yt={}));const tx=[yt.Star1,yt.Star2,yt.Star3,yt.Star4,yt.Star5,yt.Star6,yt.Star7,yt.Star8],ex=[{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0}];function nx(i){const t=tx.indexOf(i);return t>=0?ex[t]:null}function Yl(i){const t=nx(i);return t&&t.dist>0?t:null}var Ze;(function(i){i[i.From2000=0]="From2000",i[i.Into2000=1]="Into2000"})(Ze||(Ze={}));const kn={Mercury:[[[[4.40250710144,0,0],[.40989414977,1.48302034195,26087.9031415742],[.050462942,4.47785489551,52175.8062831484],[.00855346844,1.16520322459,78263.70942472259],[.00165590362,4.11969163423,104351.61256629678],[.00034561897,.77930768443,130439.51570787099],[7583476e-11,3.71348404924,156527.41884944518]],[[26087.90313685529,0,0],[.01131199811,6.21874197797,26087.9031415742],[.00292242298,3.04449355541,52175.8062831484],[.00075775081,6.08568821653,78263.70942472259],[.00019676525,2.80965111777,104351.61256629678]]],[[[.11737528961,1.98357498767,26087.9031415742],[.02388076996,5.03738959686,52175.8062831484],[.01222839532,3.14159265359,0],[.0054325181,1.79644363964,78263.70942472259],[.0012977877,4.83232503958,104351.61256629678],[.00031866927,1.58088495658,130439.51570787099],[7963301e-11,4.60972126127,156527.41884944518]],[[.00274646065,3.95008450011,26087.9031415742],[.00099737713,3.14159265359,0]]],[[[.39528271651,0,0],[.07834131818,6.19233722598,26087.9031415742],[.00795525558,2.95989690104,52175.8062831484],[.00121281764,6.01064153797,78263.70942472259],[.00021921969,2.77820093972,104351.61256629678],[4354065e-11,5.82894543774,130439.51570787099]],[[.0021734774,4.65617158665,26087.9031415742],[.00044141826,1.42385544001,52175.8062831484]]]],Venus:[[[[3.17614666774,0,0],[.01353968419,5.59313319619,10213.285546211],[.00089891645,5.30650047764,20426.571092422],[5477194e-11,4.41630661466,7860.4193924392],[3455741e-11,2.6996444782,11790.6290886588],[2372061e-11,2.99377542079,3930.2096962196],[1317168e-11,5.18668228402,26.2983197998],[1664146e-11,4.25018630147,1577.3435424478],[1438387e-11,4.15745084182,9683.5945811164],[1200521e-11,6.15357116043,30639.856638633]],[[10213.28554621638,0,0],[.00095617813,2.4640651111,10213.285546211],[7787201e-11,.6247848222,20426.571092422]]],[[[.05923638472,.26702775812,10213.285546211],[.00040107978,1.14737178112,20426.571092422],[.00032814918,3.14159265359,0]],[[.00287821243,1.88964962838,10213.285546211]]],[[[.72334820891,0,0],[.00489824182,4.02151831717,10213.285546211],[1658058e-11,4.90206728031,20426.571092422],[1378043e-11,1.12846591367,11790.6290886588],[1632096e-11,2.84548795207,7860.4193924392],[498395e-11,2.58682193892,9683.5945811164],[221985e-11,2.01346696541,19367.1891622328],[237454e-11,2.55136053886,15720.8387848784]],[[.00034551041,.89198706276,10213.285546211]]]],Earth:[[[[1.75347045673,0,0],[.03341656453,4.66925680415,6283.0758499914],[.00034894275,4.62610242189,12566.1516999828],[3417572e-11,2.82886579754,3.523118349],[3497056e-11,2.74411783405,5753.3848848968],[3135899e-11,3.62767041756,77713.7714681205],[2676218e-11,4.41808345438,7860.4193924392],[2342691e-11,6.13516214446,3930.2096962196],[1273165e-11,2.03709657878,529.6909650946],[1324294e-11,.74246341673,11506.7697697936],[901854e-11,2.04505446477,26.2983197998],[1199167e-11,1.10962946234,1577.3435424478],[857223e-11,3.50849152283,398.1490034082],[779786e-11,1.17882681962,5223.6939198022],[99025e-10,5.23268072088,5884.9268465832],[753141e-11,2.53339052847,5507.5532386674],[505267e-11,4.58292599973,18849.2275499742],[492392e-11,4.20505711826,775.522611324],[356672e-11,2.91954114478,.0673103028],[284125e-11,1.89869240932,796.2980068164],[242879e-11,.34481445893,5486.777843175],[317087e-11,5.84901948512,11790.6290886588],[271112e-11,.31486255375,10977.078804699],[206217e-11,4.80646631478,2544.3144198834],[205478e-11,1.86953770281,5573.1428014331],[202318e-11,2.45767790232,6069.7767545534],[126225e-11,1.08295459501,20.7753954924],[155516e-11,.83306084617,213.299095438]],[[6283.0758499914,0,0],[.00206058863,2.67823455808,6283.0758499914],[4303419e-11,2.63512233481,12566.1516999828]],[[8721859e-11,1.07253635559,6283.0758499914]]],[[],[[.00227777722,3.4137662053,6283.0758499914],[3805678e-11,3.37063423795,12566.1516999828]]],[[[1.00013988784,0,0],[.01670699632,3.09846350258,6283.0758499914],[.00013956024,3.05524609456,12566.1516999828],[308372e-10,5.19846674381,77713.7714681205],[1628463e-11,1.17387558054,5753.3848848968],[1575572e-11,2.84685214877,7860.4193924392],[924799e-11,5.45292236722,11506.7697697936],[542439e-11,4.56409151453,3930.2096962196],[47211e-10,3.66100022149,5884.9268465832],[85831e-11,1.27079125277,161000.6857376741],[57056e-11,2.01374292245,83996.84731811189],[55736e-11,5.2415979917,71430.69561812909],[174844e-11,3.01193636733,18849.2275499742],[243181e-11,4.2734953079,11790.6290886588]],[[.00103018607,1.10748968172,6283.0758499914],[1721238e-11,1.06442300386,12566.1516999828]],[[4359385e-11,5.78455133808,6283.0758499914]]]],Mars:[[[[6.20347711581,0,0],[.18656368093,5.0503710027,3340.6124266998],[.01108216816,5.40099836344,6681.2248533996],[.00091798406,5.75478744667,10021.8372800994],[.00027744987,5.97049513147,3.523118349],[.00010610235,2.93958560338,2281.2304965106],[.00012315897,.84956094002,2810.9214616052],[8926784e-11,4.15697846427,.0172536522],[8715691e-11,6.11005153139,13362.4497067992],[6797556e-11,.36462229657,398.1490034082],[7774872e-11,3.33968761376,5621.8429232104],[3575078e-11,1.6618650571,2544.3144198834],[4161108e-11,.22814971327,2942.4634232916],[3075252e-11,.85696614132,191.4482661116],[2628117e-11,.64806124465,3337.0893083508],[2937546e-11,6.07893711402,.0673103028],[2389414e-11,5.03896442664,796.2980068164],[2579844e-11,.02996736156,3344.1355450488],[1528141e-11,1.14979301996,6151.533888305],[1798806e-11,.65634057445,529.6909650946],[1264357e-11,3.62275122593,5092.1519581158],[1286228e-11,3.06796065034,2146.1654164752],[1546404e-11,2.91579701718,1751.539531416],[1024902e-11,3.69334099279,8962.4553499102],[891566e-11,.18293837498,16703.062133499],[858759e-11,2.4009381194,2914.0142358238],[832715e-11,2.46418619474,3340.5951730476],[83272e-10,4.49495782139,3340.629680352],[712902e-11,3.66335473479,1059.3819301892],[748723e-11,3.82248614017,155.4203994342],[723861e-11,.67497311481,3738.761430108],[635548e-11,2.92182225127,8432.7643848156],[655162e-11,.48864064125,3127.3133312618],[550474e-11,3.81001042328,.9803210682],[55275e-10,4.47479317037,1748.016413067],[425966e-11,.55364317304,6283.0758499914],[415131e-11,.49662285038,213.299095438],[472167e-11,3.62547124025,1194.4470102246],[306551e-11,.38052848348,6684.7479717486],[312141e-11,.99853944405,6677.7017350506],[293198e-11,4.22131299634,20.7753954924],[302375e-11,4.48618007156,3532.0606928114],[274027e-11,.54222167059,3340.545116397],[281079e-11,5.88163521788,1349.8674096588],[231183e-11,1.28242156993,3870.3033917944],[283602e-11,5.7688543494,3149.1641605882],[236117e-11,5.75503217933,3333.498879699],[274033e-11,.13372524985,3340.6797370026],[299395e-11,2.78323740866,6254.6266625236]],[[3340.61242700512,0,0],[.01457554523,3.60433733236,3340.6124266998],[.00168414711,3.92318567804,6681.2248533996],[.00020622975,4.26108844583,10021.8372800994],[3452392e-11,4.7321039319,3.523118349],[2586332e-11,4.60670058555,13362.4497067992],[841535e-11,4.45864030426,2281.2304965106]],[[.00058152577,2.04961712429,3340.6124266998],[.00013459579,2.45738706163,6681.2248533996]]],[[[.03197134986,3.76832042431,3340.6124266998],[.00298033234,4.10616996305,6681.2248533996],[.00289104742,0,0],[.00031365539,4.4465105309,10021.8372800994],[34841e-9,4.7881254926,13362.4497067992]],[[.00217310991,6.04472194776,3340.6124266998],[.00020976948,3.14159265359,0],[.00012834709,1.60810667915,6681.2248533996]]],[[[1.53033488271,0,0],[.1418495316,3.47971283528,3340.6124266998],[.00660776362,3.81783443019,6681.2248533996],[.00046179117,4.15595316782,10021.8372800994],[8109733e-11,5.55958416318,2810.9214616052],[7485318e-11,1.77239078402,5621.8429232104],[5523191e-11,1.3643630377,2281.2304965106],[382516e-10,4.49407183687,13362.4497067992],[2306537e-11,.09081579001,2544.3144198834],[1999396e-11,5.36059617709,3337.0893083508],[2484394e-11,4.9254563992,2942.4634232916],[1960195e-11,4.74249437639,3344.1355450488],[1167119e-11,2.11260868341,5092.1519581158],[1102816e-11,5.00908403998,398.1490034082],[899066e-11,4.40791133207,529.6909650946],[992252e-11,5.83861961952,6151.533888305],[807354e-11,2.10217065501,1059.3819301892],[797915e-11,3.44839203899,796.2980068164],[740975e-11,1.49906336885,2146.1654164752]],[[.01107433345,2.03250524857,3340.6124266998],[.00103175887,2.37071847807,6681.2248533996],[128772e-9,0,0],[.0001081588,2.70888095665,10021.8372800994]],[[.00044242249,.47930604954,3340.6124266998],[8138042e-11,.86998389204,6681.2248533996]]]],Jupiter:[[[[.59954691494,0,0],[.09695898719,5.06191793158,529.6909650946],[.00573610142,1.44406205629,7.1135470008],[.00306389205,5.41734730184,1059.3819301892],[.00097178296,4.14264726552,632.7837393132],[.00072903078,3.64042916389,522.5774180938],[.00064263975,3.41145165351,103.0927742186],[.00039806064,2.29376740788,419.4846438752],[.00038857767,1.27231755835,316.3918696566],[.00027964629,1.7845459182,536.8045120954],[.0001358973,5.7748104079,1589.0728952838],[8246349e-11,3.5822792584,206.1855484372],[8768704e-11,3.63000308199,949.1756089698],[7368042e-11,5.0810119427,735.8765135318],[626315e-10,.02497628807,213.299095438],[6114062e-11,4.51319998626,1162.4747044078],[4905396e-11,1.32084470588,110.2063212194],[5305285e-11,1.30671216791,14.2270940016],[5305441e-11,4.18625634012,1052.2683831884],[4647248e-11,4.69958103684,3.9321532631],[3045023e-11,4.31676431084,426.598190876],[2609999e-11,1.56667394063,846.0828347512],[2028191e-11,1.06376530715,3.1813937377],[1764763e-11,2.14148655117,1066.49547719],[1722972e-11,3.88036268267,1265.5674786264],[1920945e-11,.97168196472,639.897286314],[1633223e-11,3.58201833555,515.463871093],[1431999e-11,4.29685556046,625.6701923124],[973272e-11,4.09764549134,95.9792272178]],[[529.69096508814,0,0],[.00489503243,4.2208293947,529.6909650946],[.00228917222,6.02646855621,7.1135470008],[.00030099479,4.54540782858,1059.3819301892],[.0002072092,5.45943156902,522.5774180938],[.00012103653,.16994816098,536.8045120954],[6067987e-11,4.42422292017,103.0927742186],[5433968e-11,3.98480737746,419.4846438752],[4237744e-11,5.89008707199,14.2270940016]],[[.00047233601,4.32148536482,7.1135470008],[.00030649436,2.929777887,529.6909650946],[.00014837605,3.14159265359,0]]],[[[.02268615702,3.55852606721,529.6909650946],[.00109971634,3.90809347197,1059.3819301892],[.00110090358,0,0],[8101428e-11,3.60509572885,522.5774180938],[6043996e-11,4.25883108339,1589.0728952838],[6437782e-11,.30627119215,536.8045120954]],[[.00078203446,1.52377859742,529.6909650946]]],[[[5.20887429326,0,0],[.25209327119,3.49108639871,529.6909650946],[.00610599976,3.84115365948,1059.3819301892],[.00282029458,2.57419881293,632.7837393132],[.00187647346,2.07590383214,522.5774180938],[.00086792905,.71001145545,419.4846438752],[.00072062974,.21465724607,536.8045120954],[.00065517248,5.9799588479,316.3918696566],[.00029134542,1.67759379655,103.0927742186],[.00030135335,2.16132003734,949.1756089698],[.00023453271,3.54023522184,735.8765135318],[.00022283743,4.19362594399,1589.0728952838],[.00023947298,.2745803748,7.1135470008],[.00013032614,2.96042965363,1162.4747044078],[970336e-10,1.90669633585,206.1855484372],[.00012749023,2.71550286592,1052.2683831884],[7057931e-11,2.18184839926,1265.5674786264],[6137703e-11,6.26418240033,846.0828347512],[2616976e-11,2.00994012876,1581.959348283]],[[.0127180152,2.64937512894,529.6909650946],[.00061661816,3.00076460387,1059.3819301892],[.00053443713,3.89717383175,522.5774180938],[.00031185171,4.88276958012,536.8045120954],[.00041390269,0,0]]]],Saturn:[[[[.87401354025,0,0],[.11107659762,3.96205090159,213.299095438],[.01414150957,4.58581516874,7.1135470008],[.00398379389,.52112032699,206.1855484372],[.00350769243,3.30329907896,426.598190876],[.00206816305,.24658372002,103.0927742186],[792713e-9,3.84007056878,220.4126424388],[.00023990355,4.66976924553,110.2063212194],[.00016573588,.43719228296,419.4846438752],[.00014906995,5.76903183869,316.3918696566],[.0001582029,.93809155235,632.7837393132],[.00014609559,1.56518472,3.9321532631],[.00013160301,4.44891291899,14.2270940016],[.00015053543,2.71669915667,639.897286314],[.00013005299,5.98119023644,11.0457002639],[.00010725067,3.12939523827,202.2533951741],[5863206e-11,.23656938524,529.6909650946],[5227757e-11,4.20783365759,3.1813937377],[6126317e-11,1.76328667907,277.0349937414],[5019687e-11,3.17787728405,433.7117378768],[459255e-10,.61977744975,199.0720014364],[4005867e-11,2.24479718502,63.7358983034],[2953796e-11,.98280366998,95.9792272178],[387367e-10,3.22283226966,138.5174968707],[2461186e-11,2.03163875071,735.8765135318],[3269484e-11,.77492638211,949.1756089698],[1758145e-11,3.2658010994,522.5774180938],[1640172e-11,5.5050445305,846.0828347512],[1391327e-11,4.02333150505,323.5054166574],[1580648e-11,4.37265307169,309.2783226558],[1123498e-11,2.83726798446,415.5524906121],[1017275e-11,3.71700135395,227.5261894396],[848642e-11,3.1915017083,209.3669421749]],[[213.2990952169,0,0],[.01297370862,1.82834923978,213.299095438],[.00564345393,2.88499717272,7.1135470008],[.00093734369,1.06311793502,426.598190876],[.00107674962,2.27769131009,206.1855484372],[.00040244455,2.04108104671,220.4126424388],[.00019941774,1.2795439047,103.0927742186],[.00010511678,2.7488034213,14.2270940016],[6416106e-11,.38238295041,639.897286314],[4848994e-11,2.43037610229,419.4846438752],[4056892e-11,2.92133209468,110.2063212194],[3768635e-11,3.6496533078,3.9321532631]],[[.0011644133,1.17988132879,7.1135470008],[.00091841837,.0732519584,213.299095438],[.00036661728,0,0],[.00015274496,4.06493179167,206.1855484372]]],[[[.04330678039,3.60284428399,213.299095438],[.00240348302,2.85238489373,426.598190876],[.00084745939,0,0],[.00030863357,3.48441504555,220.4126424388],[.00034116062,.57297307557,206.1855484372],[.0001473407,2.11846596715,639.897286314],[9916667e-11,5.79003188904,419.4846438752],[6993564e-11,4.7360468972,7.1135470008],[4807588e-11,5.43305312061,316.3918696566]],[[.00198927992,4.93901017903,213.299095438],[.00036947916,3.14159265359,0],[.00017966989,.5197943111,426.598190876]]],[[[9.55758135486,0,0],[.52921382865,2.39226219573,213.299095438],[.01873679867,5.2354960466,206.1855484372],[.01464663929,1.64763042902,426.598190876],[.00821891141,5.93520042303,316.3918696566],[.00547506923,5.0153261898,103.0927742186],[.0037168465,2.27114821115,220.4126424388],[.00361778765,3.13904301847,7.1135470008],[.00140617506,5.70406606781,632.7837393132],[.00108974848,3.29313390175,110.2063212194],[.00069006962,5.94099540992,419.4846438752],[.00061053367,.94037691801,639.897286314],[.00048913294,1.55733638681,202.2533951741],[.00034143772,.19519102597,277.0349937414],[.00032401773,5.47084567016,949.1756089698],[.00020936596,.46349251129,735.8765135318],[9796004e-11,5.20477537945,1265.5674786264],[.00011993338,5.98050967385,846.0828347512],[208393e-9,1.52102476129,433.7117378768],[.00015298404,3.0594381494,529.6909650946],[6465823e-11,.17732249942,1052.2683831884],[.00011380257,1.7310542704,522.5774180938],[3419618e-11,4.94550542171,1581.959348283]],[[.0618298134,.2584351148,213.299095438],[.00506577242,.71114625261,206.1855484372],[.00341394029,5.79635741658,426.598190876],[.00188491195,.47215589652,220.4126424388],[.00186261486,3.14159265359,0],[.00143891146,1.40744822888,7.1135470008]],[[.00436902572,4.78671677509,213.299095438]]]],Uranus:[[[[5.48129294297,0,0],[.09260408234,.89106421507,74.7815985673],[.01504247898,3.6271926092,1.4844727083],[.00365981674,1.89962179044,73.297125859],[.00272328168,3.35823706307,149.5631971346],[.00070328461,5.39254450063,63.7358983034],[.00068892678,6.09292483287,76.2660712756],[.00061998615,2.26952066061,2.9689454166],[.00061950719,2.85098872691,11.0457002639],[.0002646877,3.14152083966,71.8126531507],[.00025710476,6.11379840493,454.9093665273],[.0002107885,4.36059339067,148.0787244263],[.00017818647,1.74436930289,36.6485629295],[.00014613507,4.73732166022,3.9321532631],[.00011162509,5.8268179635,224.3447957019],[.0001099791,.48865004018,138.5174968707],[9527478e-11,2.95516862826,35.1640902212],[7545601e-11,5.236265824,109.9456887885],[4220241e-11,3.23328220918,70.8494453042],[40519e-9,2.277550173,151.0476698429],[3354596e-11,1.0654900738,4.4534181249],[2926718e-11,4.62903718891,9.5612275556],[349034e-10,5.48306144511,146.594251718],[3144069e-11,4.75199570434,77.7505439839],[2922333e-11,5.35235361027,85.8272988312],[2272788e-11,4.36600400036,70.3281804424],[2051219e-11,1.51773566586,.1118745846],[2148602e-11,.60745949945,38.1330356378],[1991643e-11,4.92437588682,277.0349937414],[1376226e-11,2.04283539351,65.2203710117],[1666902e-11,3.62744066769,380.12776796],[1284107e-11,3.11347961505,202.2533951741],[1150429e-11,.93343589092,3.1813937377],[1533221e-11,2.58594681212,52.6901980395],[1281604e-11,.54271272721,222.8603229936],[1372139e-11,4.19641530878,111.4301614968],[1221029e-11,.1990065003,108.4612160802],[946181e-11,1.19253165736,127.4717966068],[1150989e-11,4.17898916639,33.6796175129]],[[74.7815986091,0,0],[.00154332863,5.24158770553,74.7815985673],[.00024456474,1.71260334156,1.4844727083],[9258442e-11,.4282973235,11.0457002639],[8265977e-11,1.50218091379,63.7358983034],[915016e-10,1.41213765216,149.5631971346]]],[[[.01346277648,2.61877810547,74.7815985673],[623414e-9,5.08111189648,149.5631971346],[.00061601196,3.14159265359,0],[9963722e-11,1.61603805646,76.2660712756],[992616e-10,.57630380333,73.297125859]],[[.00034101978,.01321929936,74.7815985673]]],[[[19.21264847206,0,0],[.88784984413,5.60377527014,74.7815985673],[.03440836062,.32836099706,73.297125859],[.0205565386,1.7829515933,149.5631971346],[.0064932241,4.52247285911,76.2660712756],[.00602247865,3.86003823674,63.7358983034],[.00496404167,1.40139935333,454.9093665273],[.00338525369,1.58002770318,138.5174968707],[.00243509114,1.57086606044,71.8126531507],[.00190522303,1.99809394714,1.4844727083],[.00161858838,2.79137786799,148.0787244263],[.00143706183,1.38368544947,11.0457002639],[.00093192405,.17437220467,36.6485629295],[.00071424548,4.24509236074,224.3447957019],[.00089806014,3.66105364565,109.9456887885],[.00039009723,1.66971401684,70.8494453042],[.00046677296,1.39976401694,35.1640902212],[.00039025624,3.36234773834,277.0349937414],[.00036755274,3.88649278513,146.594251718],[.00030348723,.70100838798,151.0476698429],[.00029156413,3.180563367,77.7505439839],[.00022637073,.72518687029,529.6909650946],[.00011959076,1.7504339214,984.6003316219],[.00025620756,5.25656086672,380.12776796]],[[.01479896629,3.67205697578,74.7815985673]]]],Neptune:[[[[5.31188633046,0,0],[.0179847553,2.9010127389,38.1330356378],[.01019727652,.48580922867,1.4844727083],[.00124531845,4.83008090676,36.6485629295],[.00042064466,5.41054993053,2.9689454166],[.00037714584,6.09221808686,35.1640902212],[.00033784738,1.24488874087,76.2660712756],[.00016482741,7727998e-11,491.5579294568],[9198584e-11,4.93747051954,39.6175083461],[899425e-10,.27462171806,175.1660598002]],[[38.13303563957,0,0],[.00016604172,4.86323329249,1.4844727083],[.00015744045,2.27887427527,38.1330356378]]],[[[.03088622933,1.44104372644,38.1330356378],[.00027780087,5.91271884599,76.2660712756],[.00027623609,0,0],[.00015355489,2.52123799551,36.6485629295],[.00015448133,3.50877079215,39.6175083461]]],[[[30.07013205828,0,0],[.27062259632,1.32999459377,38.1330356378],[.01691764014,3.25186135653,36.6485629295],[.00807830553,5.18592878704,1.4844727083],[.0053776051,4.52113935896,35.1640902212],[.00495725141,1.5710564165,491.5579294568],[.00274571975,1.84552258866,175.1660598002],[.0001201232,1.92059384991,1021.2488945514],[.00121801746,5.79754470298,76.2660712756],[.00100896068,.3770272493,73.297125859],[.00135134092,3.37220609835,39.6175083461],[7571796e-11,1.07149207335,388.4651552382]]]]};function ix(i){var t,e,n,s,r,a,o;const c=2e3+(i-14)/Yv;return c<-500?(t=(c-1820)/100,-20+32*t*t):c<500?(t=c/100,e=t*t,n=t*e,s=e*e,r=e*n,a=n*n,10583.6-1014.41*t+33.78311*e-5.952053*n-.1798452*s+.022174192*r+.0090316521*a):c<1600?(t=(c-1e3)/100,e=t*t,n=t*e,s=e*e,r=e*n,a=n*n,1574.2-556.01*t+71.23472*e+.319781*n-.8503463*s-.005050998*r+.0083572073*a):c<1700?(t=c-1600,e=t*t,n=t*e,120-.9808*t-.01532*e+n/7129):c<1800?(t=c-1700,e=t*t,n=t*e,s=e*e,8.83+.1603*t-.0059285*e+13336e-8*n-s/1174e3):c<1860?(t=c-1800,e=t*t,n=t*e,s=e*e,r=e*n,a=n*n,o=n*s,13.72-.332447*t+.0068612*e+.0041116*n-37436e-8*s+121272e-10*r-1699e-10*a+875e-12*o):c<1900?(t=c-1860,e=t*t,n=t*e,s=e*e,r=e*n,7.62+.5737*t-.251754*e+.01680668*n-.0004473624*s+r/233174):c<1920?(t=c-1900,e=t*t,n=t*e,s=e*e,-2.79+1.494119*t-.0598939*e+.0061966*n-197e-6*s):c<1941?(t=c-1920,e=t*t,n=t*e,21.2+.84493*t-.0761*e+.0020936*n):c<1961?(t=c-1950,e=t*t,n=t*e,29.07+.407*t-e/233+n/2547):c<1986?(t=c-1975,e=t*t,n=t*e,45.45+1.067*t-e/260-n/718):c<2005?(t=c-2e3,e=t*t,n=t*e,s=e*e,r=e*n,63.86+.3345*t-.060374*e+.0017275*n+651814e-9*s+2373599e-11*r):c<2050?(t=c-2e3,62.92+.32217*t+.005589*t*t):c<2150?(t=(c-1820)/100,-20+32*t*t-.5628*(2150-c)):(t=(c-1820)/100,-20+32*t*t)}let sx=ix;function Lu(i){return i+sx(i)/86400}class Is{constructor(t){if(t instanceof Is){this.date=t.date,this.ut=t.ut,this.tt=t.tt;return}const e=1e3*3600*24;if(t instanceof Date&&Number.isFinite(t.getTime())){this.date=t,this.ut=(t.getTime()-Pu.getTime())/e,this.tt=Lu(this.ut);return}if(Number.isFinite(t)){this.date=new Date(Pu.getTime()+t*e),this.ut=t,this.tt=Lu(this.ut);return}throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(t){let e=new Is(t);for(;;){const n=t-e.tt;if(Math.abs(n)<1e-12)return e;e=e.AddDays(n)}}toString(){return this.date.toISOString()}AddDays(t){return new Is(this.ut+t)}}function De(i){return i instanceof Is?i:new Is(i)}function rx(i){function t(d){return d%Kv*As}const e=i.tt/36525,n=t(128710479305e-5+e*1295965810481e-4),s=t(335779.526232+e*17395272628478e-4),r=t(107226070369e-5+e*1602961601209e-3),a=t(450160.398036-e*69628905431e-4);let o=Math.sin(a),c=Math.cos(a),l=(-172064161-174666*e)*o+33386*c,h=(92052331+9086*e)*c+15377*o,u=2*(s-r+a);return o=Math.sin(u),c=Math.cos(u),l+=(-13170906-1675*e)*o-13696*c,h+=(5730336-3015*e)*c-4587*o,u=2*(s+a),o=Math.sin(u),c=Math.cos(u),l+=(-2276413-234*e)*o+2796*c,h+=(978459-485*e)*c+1374*o,u=2*a,o=Math.sin(u),c=Math.cos(u),l+=(2074554+207*e)*o-698*c,h+=(-897492+470*e)*c-291*o,o=Math.sin(n),c=Math.cos(n),l+=(1475877-3633*e)*o+11817*c,h+=(73871-184*e)*c-1924*o,{dpsi:-135e-6+l*1e-7,deps:388e-6+h*1e-7}}function Sd(i){var t=i.tt/36525,e=((((-434e-10*t-576e-9)*t+.0020034)*t-1831e-7)*t-46.836769)*t+84381.406;return e/3600}var ia;function Sr(i){if(!ia||Math.abs(ia.tt-i.tt)>1e-6){const t=rx(i),e=Sd(i),n=e+t.deps/3600;ia={tt:i.tt,dpsi:t.dpsi,deps:t.deps,ee:t.dpsi*Math.cos(e*ne)/15,mobl:e,tobl:n}}return ia}function ax(i,t){const e=i*ne,n=Math.cos(e),s=Math.sin(e);return[t[0],t[1]*n-t[2]*s,t[1]*s+t[2]*n]}function ox(i,t){return ax(Sd(i),t)}function cx(i){const t=i.tt/36525;function e(Tt,vt){const It=[];let Lt;for(Lt=0;Lt<=vt-Tt;++Lt)It.push(0);return{min:Tt,array:It}}function n(Tt,vt,It,Lt){const Nt=[];for(let Jt=0;Jt<=vt-Tt;++Jt)Nt.push(e(It,Lt));return{min:Tt,array:Nt}}function s(Tt,vt,It){const Lt=Tt.array[vt-Tt.min];return Lt.array[It-Lt.min]}function r(Tt,vt,It,Lt){const Nt=Tt.array[vt-Tt.min];Nt.array[It-Nt.min]=Lt}let a,o,c,l,h,u,d,p,g,x,m,f,A,T,M,y,b,R,v,E,D,C,I,W=n(-6,6,1,4),X=n(-6,6,1,4);function U(Tt,vt){return s(W,Tt,vt)}function q(Tt,vt){return s(X,Tt,vt)}function H(Tt,vt,It){return r(W,Tt,vt,It)}function $(Tt,vt,It){return r(X,Tt,vt,It)}function et(Tt,vt,It,Lt,Nt){Nt(Tt*It-vt*Lt,vt*It+Tt*Lt)}function j(Tt){return Math.sin($n*Tt)}d=t*t,g=0,I=0,m=0,f=3422.7;var it=j(.19833+.05611*t),ut=j(.27869+.04508*t),kt=j(.16827-.36903*t),qt=j(.34734-5.37261*t),Bt=j(.10498-5.37899*t),Y=j(.42681-.41855*t),rt=j(.14943-5.37511*t);for(R=.84*it+.31*ut+14.27*kt+7.26*qt+.28*Bt+.24*Y,v=2.94*it+.31*ut+14.27*kt+9.34*qt+1.12*Bt+.83*Y,E=-6.4*it-1.89*Y,D=.21*it+.31*ut+14.27*kt-88.7*qt-15.3*Bt+.24*Y-1.86*rt,C=R-E,p=-3332e-9*j(.59734-5.37261*t)-539e-9*j(.35498-5.37899*t)-64e-9*j(.39943-5.37511*t),A=$n*xs(.60643382+1336.85522467*t-313e-8*d)+R/mi,T=$n*xs(.37489701+1325.55240982*t+2565e-8*d)+v/mi,M=$n*xs(.99312619+99.99735956*t-44e-8*d)+E/mi,y=$n*xs(.25909118+1342.2278298*t-892e-8*d)+D/mi,b=$n*xs(.82736186+1236.85308708*t-397e-8*d)+C/mi,h=1;h<=4;++h){switch(h){case 1:c=T,o=4,l=1.000002208;break;case 2:c=M,o=3,l=.997504612-.002495388*t;break;case 3:c=y,o=4,l=1.000002708+139.978*p;break;case 4:c=b,o=6,l=1;break;default:throw`Internal error: I = ${h}`}for(H(0,h,1),H(1,h,Math.cos(c)*l),$(0,h,0),$(1,h,Math.sin(c)*l),u=2;u<=o;++u)et(U(u-1,h),q(u-1,h),U(1,h),q(1,h),(Tt,vt)=>(H(u,h,Tt),$(u,h,vt)));for(u=1;u<=o;++u)H(-u,h,U(u,h)),$(-u,h,-q(u,h))}function nt(Tt,vt,It,Lt){for(var Nt={x:1,y:0},Jt=[0,Tt,vt,It,Lt],Qt=1;Qt<=4;++Qt)Jt[Qt]!==0&&et(Nt.x,Nt.y,U(Jt[Qt],Qt),q(Jt[Qt],Qt),(me,fe)=>(Nt.x=me,Nt.y=fe));return Nt}function z(Tt,vt,It,Lt,Nt,Jt,Qt,me){var fe=nt(Nt,Jt,Qt,me);g+=Tt*fe.y,I+=vt*fe.y,m+=It*fe.x,f+=Lt*fe.x}z(13.902,14.06,-.001,.2607,0,0,0,4),z(.403,-4.01,.394,.0023,0,0,0,3),z(2369.912,2373.36,.601,28.2333,0,0,0,2),z(-125.154,-112.79,-.725,-.9781,0,0,0,1),z(1.979,6.98,-.445,.0433,1,0,0,4),z(191.953,192.72,.029,3.0861,1,0,0,2),z(-8.466,-13.51,.455,-.1093,1,0,0,1),z(22639.5,22609.07,.079,186.5398,1,0,0,0),z(18.609,3.59,-.094,.0118,1,0,0,-1),z(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),z(3.215,5.44,.192,-.0386,1,0,0,-3),z(-38.428,-38.64,.001,.6008,1,0,0,-4),z(-.393,-1.43,-.092,.0086,1,0,0,-6),z(-.289,-1.59,.123,-.0053,0,1,0,4),z(-24.42,-25.1,.04,-.3,0,1,0,2),z(18.023,17.93,.007,.1494,0,1,0,1),z(-668.146,-126.98,-1.302,-.3997,0,1,0,0),z(.56,.32,-.001,-.0037,0,1,0,-1),z(-165.145,-165.06,.054,1.9178,0,1,0,-2),z(-1.877,-6.46,-.416,.0339,0,1,0,-4),z(.213,1.02,-.074,.0054,2,0,0,4),z(14.387,14.78,-.017,.2833,2,0,0,2),z(-.586,-1.2,.054,-.01,2,0,0,1),z(769.016,767.96,.107,10.1657,2,0,0,0),z(1.75,2.01,-.018,.0155,2,0,0,-1),z(-211.656,-152.53,5.679,-.3039,2,0,0,-2),z(1.225,.91,-.03,-.0088,2,0,0,-3),z(-30.773,-34.07,-.308,.3722,2,0,0,-4),z(-.57,-1.4,-.074,.0109,2,0,0,-6),z(-2.921,-11.75,.787,-.0484,1,1,0,2),z(1.267,1.52,-.022,.0164,1,1,0,1),z(-109.673,-115.18,.461,-.949,1,1,0,0),z(-205.962,-182.36,2.056,1.4437,1,1,0,-2),z(.233,.36,.012,-.0025,1,1,0,-3),z(-4.391,-9.66,-.471,.0673,1,1,0,-4),z(.283,1.53,-.111,.006,1,-1,0,4),z(14.577,31.7,-1.54,.2302,1,-1,0,2),z(147.687,138.76,.679,1.1528,1,-1,0,0),z(-1.089,.55,.021,0,1,-1,0,-1),z(28.475,23.59,-.443,-.2257,1,-1,0,-2),z(-.276,-.38,-.006,-.0036,1,-1,0,-3),z(.636,2.27,.146,-.0102,1,-1,0,-4),z(-.189,-1.68,.131,-.0028,0,2,0,2),z(-7.486,-.66,-.037,-.0086,0,2,0,0),z(-8.096,-16.35,-.74,.0918,0,2,0,-2),z(-5.741,-.04,0,-9e-4,0,0,2,2),z(.255,0,0,0,0,0,2,1),z(-411.608,-.2,0,-.0124,0,0,2,0),z(.584,.84,0,.0071,0,0,2,-1),z(-55.173,-52.14,0,-.1052,0,0,2,-2),z(.254,.25,0,-.0017,0,0,2,-3),z(.025,-1.67,0,.0031,0,0,2,-4),z(1.06,2.96,-.166,.0243,3,0,0,2),z(36.124,50.64,-1.3,.6215,3,0,0,0),z(-13.193,-16.4,.258,-.1187,3,0,0,-2),z(-1.187,-.74,.042,.0074,3,0,0,-4),z(-.293,-.31,-.002,.0046,3,0,0,-6),z(-.29,-1.45,.116,-.0051,2,1,0,2),z(-7.649,-10.56,.259,-.1038,2,1,0,0),z(-8.627,-7.59,.078,-.0192,2,1,0,-2),z(-2.74,-2.54,.022,.0324,2,1,0,-4),z(1.181,3.32,-.212,.0213,2,-1,0,2),z(9.703,11.67,-.151,.1268,2,-1,0,0),z(-.352,-.37,.001,-.0028,2,-1,0,-1),z(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),z(.36,.2,-.012,-.0043,2,-1,0,-4),z(-1.167,-1.25,.008,-.0106,1,2,0,0),z(-7.412,-6.12,.117,.0484,1,2,0,-2),z(-.311,-.65,-.032,.0044,1,2,0,-4),z(.757,1.82,-.105,.0112,1,-2,0,2),z(2.58,2.32,.027,.0196,1,-2,0,0),z(2.533,2.4,-.014,-.0212,1,-2,0,-2),z(-.344,-.57,-.025,.0036,0,3,0,-2),z(-.992,-.02,0,0,1,0,2,2),z(-45.099,-.02,0,-.001,1,0,2,0),z(-.179,-9.52,0,-.0833,1,0,2,-2),z(-.301,-.33,0,.0014,1,0,2,-4),z(-6.382,-3.37,0,-.0481,1,0,-2,2),z(39.528,85.13,0,-.7136,1,0,-2,0),z(9.366,.71,0,-.0112,1,0,-2,-2),z(.202,.02,0,0,1,0,-2,-4),z(.415,.1,0,.0013,0,1,2,0),z(-2.152,-2.26,0,-.0066,0,1,2,-2),z(-1.44,-1.3,0,.0014,0,1,-2,2),z(.384,-.04,0,0,0,1,-2,-2),z(1.938,3.6,-.145,.0401,4,0,0,0),z(-.952,-1.58,.052,-.013,4,0,0,-2),z(-.551,-.94,.032,-.0097,3,1,0,0),z(-.482,-.57,.005,-.0045,3,1,0,-2),z(.681,.96,-.026,.0115,3,-1,0,0),z(-.297,-.27,.002,-9e-4,2,2,0,-2),z(.254,.21,-.003,0,2,-2,0,-2),z(-.25,-.22,.004,.0014,1,3,0,-2),z(-3.996,0,0,4e-4,2,0,2,0),z(.557,-.75,0,-.009,2,0,2,-2),z(-.459,-.38,0,-.0053,2,0,-2,2),z(-1.298,.74,0,4e-4,2,0,-2,0),z(.538,1.14,0,-.0141,2,0,-2,-2),z(.263,.02,0,0,1,1,2,0),z(.426,.07,0,-6e-4,1,1,-2,-2),z(-.304,.03,0,3e-4,1,-1,2,0),z(-.372,-.19,0,-.0027,1,-1,-2,2),z(.418,0,0,0,0,0,4,0),z(-.33,-.04,0,0,3,0,2,0);function bt(Tt,vt,It,Lt,Nt){return Tt*nt(vt,It,Lt,Nt).y}x=0,x+=bt(-526.069,0,0,1,-2),x+=bt(-3.352,0,0,1,-4),x+=bt(44.297,1,0,1,-2),x+=bt(-6,1,0,1,-4),x+=bt(20.599,-1,0,1,0),x+=bt(-30.598,-1,0,1,-2),x+=bt(-24.649,-2,0,1,0),x+=bt(-2,-2,0,1,-2),x+=bt(-22.571,0,1,1,-2),x+=bt(10.985,0,-1,1,-2),g+=.82*j(.7736-62.5512*t)+.31*j(.0466-125.1025*t)+.35*j(.5785-25.1042*t)+.66*j(.4591+1335.8075*t)+.64*j(.313-91.568*t)+1.14*j(.148+1331.2898*t)+.21*j(.5918+1056.5859*t)+.44*j(.5784+1322.8595*t)+.24*j(.2275-5.7374*t)+.28*j(.2965+2.6929*t)+.33*j(.3132+6.3368*t),a=y+I/mi;let Dt=(1.000002708+139.978*p)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+x;return{geo_eclip_lon:$n*xs((A+g/mi)/$n),geo_eclip_lat:Math.PI/(180*3600)*Dt,distance_au:mi*Qv/(.999953253*f)}}function yd(i,t){return[i.rot[0][0]*t[0]+i.rot[1][0]*t[1]+i.rot[2][0]*t[2],i.rot[0][1]*t[0]+i.rot[1][1]*t[1]+i.rot[2][1]*t[2],i.rot[0][2]*t[0]+i.rot[1][2]*t[1]+i.rot[2][2]*t[2]]}function Oa(i,t,e){const n=Ed(t,e);return yd(n,i)}function Ed(i,t){const e=i.tt/36525;let n=84381.406,s=((((-951e-10*e+132851e-9)*e-.00114045)*e-1.0790069)*e+5038.481507)*e,r=((((3337e-10*e-467e-9)*e-.00772503)*e+.0512623)*e-.025754)*e+n,a=((((-56e-9*e+170663e-9)*e-.00121197)*e-2.3814292)*e+10.556403)*e;n*=As,s*=As,r*=As,a*=As;const o=Math.sin(n),c=Math.cos(n),l=Math.sin(-s),h=Math.cos(-s),u=Math.sin(-r),d=Math.cos(-r),p=Math.sin(a),g=Math.cos(a),x=g*h-l*p*d,m=g*l*c+p*d*h*c-o*p*u,f=g*l*o+p*d*h*o+c*p*u,A=-p*h-l*g*d,T=-p*l*c+g*d*h*c-o*g*u,M=-p*l*o+g*d*h*o+c*g*u,y=l*u,b=-u*h*c-o*d,R=-u*h*o+d*c;if(t===Ze.Into2000)return new Ai([[x,m,f],[A,T,M],[y,b,R]]);if(t===Ze.From2000)return new Ai([[x,A,y],[m,T,b],[f,M,R]]);throw"Invalid precess direction"}function lx(i){const t=.779057273264+.00273781191135448*i.ut,e=i.ut%1;let n=360*((t+e)%1);return n<0&&(n+=360),n}let sa;function Kl(i){if(!sa||sa.tt!==i.tt){const t=i.tt/36525;let e=15*Sr(i).ee;const n=lx(i);let r=((e+.014506+((((-368e-10*t-29956e-9)*t-44e-8)*t+1.3915817)*t+4612.156534)*t)/3600+n)%360/15;r<0&&(r+=24),sa={tt:i.tt,st:r}}return sa.st}function bd(i,t){const e=i.latitude*ne,n=Math.sin(e),s=Math.cos(e),r=1/Math.hypot(s,sl*n),a=Jv*r,o=i.height/1e3,c=rl*r+o,l=rl*a+o,h=(15*t+i.longitude)*ne,u=Math.sin(h),d=Math.cos(h);return{pos:[c*s*d/zi,c*s*u/zi,l*n/zi],vel:[-Iu*c*s*u*86400/zi,Iu*c*s*d*86400/zi,0]}}function hl(i,t,e){const n=Ad(t,e);return yd(n,i)}function Ad(i,t){const e=Sr(i),n=e.mobl*ne,s=e.tobl*ne,r=e.dpsi*As,a=Math.cos(n),o=Math.sin(n),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),u=Math.sin(r),d=h,p=-u*a,g=-u*o,x=u*c,m=h*a*c+o*l,f=h*o*c-a*l,A=u*l,T=h*a*l-o*c,M=h*o*l+a*c;if(t===Ze.From2000)return new Ai([[d,x,A],[p,m,T],[g,f,M]]);if(t===Ze.Into2000)return new Ai([[d,p,g],[x,m,f],[A,T,M]]);throw"Invalid precess direction"}function Zl(i,t,e){return e===Ze.Into2000?Oa(hl(i,t,e),t,e):hl(Oa(i,t,e),t,e)}function hx(i,t){const e=Kl(i),n=bd(t,e).pos;return Zl(n,i,Ze.Into2000)}class de{constructor(t,e,n,s){this.x=t,this.y=e,this.z=n,this.t=s}Length(){return Math.hypot(this.x,this.y,this.z)}}class Mi{constructor(t,e,n,s,r,a,o){this.x=t,this.y=e,this.z=n,this.vx=s,this.vy=r,this.vz=a,this.t=o}}class $l{constructor(t,e,n){this.lat=Ue(t),this.lon=Ue(e),this.dist=Ue(n)}}class ul{constructor(t,e,n,s){this.ra=Ue(t),this.dec=Ue(e),this.dist=Ue(n),this.vec=s}}class Ai{constructor(t){this.rot=t}}class ux{constructor(t,e,n,s){this.azimuth=Ue(t),this.altitude=Ue(e),this.ra=Ue(n),this.dec=Ue(s)}}class dx{constructor(t,e,n){this.vec=t,this.elat=Ue(e),this.elon=Ue(n)}}function Td(i,t){return new de(i[0],i[1],i[2],t)}function fx(i,t){const e=Td(i,t),n=e.x*e.x+e.y*e.y,s=Math.sqrt(n+e.z*e.z);if(n===0){if(e.z===0)throw"Indeterminate sky coordinates";return new ul(0,e.z<0?-90:90,s,e)}let r=vd*Math.atan2(e.y,e.x);r<0&&(r+=24);const a=Hn*Math.atan2(i[2],Math.sqrt(n));return new ul(r,a,s,e)}function Vo(i,t){const e=i*ne,n=Math.cos(e),s=Math.sin(e);return[n*t[0]+s*t[1],n*t[1]-s*t[0],t[2]]}function wd(i,t,e,n,s){let r=De(i);Jl(t),Ue(e),Ue(n);const a=Math.sin(t.latitude*ne),o=Math.cos(t.latitude*ne),c=Math.sin(t.longitude*ne),l=Math.cos(t.longitude*ne),h=Math.sin(n*ne),u=Math.cos(n*ne),d=Math.sin(e*Du),p=Math.cos(e*Du);let g=[o*l,o*c,a],x=[-a*l,-a*c,o],m=[c,-l,0];const f=-15*Kl(r);let A=Vo(f,g),T=Vo(f,x),M=Vo(f,m),y=[u*p,u*d,h];const b=y[0]*A[0]+y[1]*A[1]+y[2]*A[2],R=y[0]*T[0]+y[1]*T[1]+y[2]*T[2],v=y[0]*M[0]+y[1]*M[1]+y[2]*M[2];let E=Math.hypot(R,v),D;E>0?(D=-Hn*Math.atan2(v,R),D<0&&(D+=360)):D=0;let C=Hn*Math.atan2(E,b),I=e,W=n;{let X=C,U=Ox(s,90-C);if(C-=U,U>0&&C>3e-4){const q=Math.sin(C*ne),H=Math.cos(C*ne),$=Math.sin(X*ne),et=Math.cos(X*ne),j=[];for(let it=0;it<3;++it)j.push((y[it]-et*A[it])/$*q+A[it]*H);E=Math.hypot(j[0],j[1]),E>0?(I=vd*Math.atan2(j[1],j[0]),I<0&&(I+=24)):I=0,W=Hn*Math.atan2(j[2],E)}}return new ux(D,90-C,I,W)}function Jl(i){if(!(i instanceof Ql))throw`Not an instance of the Observer class: ${i}`;if(Ue(i.latitude),Ue(i.longitude),Ue(i.height),i.latitude<-90||i.latitude>90)throw`Latitude ${i.latitude} is out of range. Must be -90..+90.`;return i}class Ql{constructor(t,e,n){this.latitude=t,this.longitude=e,this.height=n,Jl(this)}}function px(i){const t=De(i).AddDays(-1/Xl),e=Ns(kn.Earth,t),n=[-e.x,-e.y,-e.z],[s,r,a]=Zl(n,t,Ze.From2000),o=ne*Sr(t).tobl,c=Math.cos(o),l=Math.sin(o),h=new de(s,r,a,t);return Rd(h,c,l)}function mx(i,t,e,n,s){Jl(e),Fa(n),Fa(s);const r=De(t),a=hx(r,e),o=Sl(i,r,s),c=[o.x-a[0],o.y-a[1],o.z-a[2]],l=Zl(c,r,Ze.From2000);return fx(l,r)}function gx(i,t,e){const n=De(i),s=Kl(n);let r=bd(t,s).pos;return Td(r,n)}function Rd(i,t,e){const n=i.x,s=i.y*t+i.z*e,r=-i.y*e+i.z*t,a=Math.hypot(n,s);let o=0;a>0&&(o=Hn*Math.atan2(s,n),o<0&&(o+=360));let c=Hn*Math.atan2(r,a),l=new de(n,s,r,i.t);return new dx(l,c,o)}function dl(i){const t=Sr(i.t),e=[i.x,i.y,i.z],n=Oa(e,i.t,Ze.From2000),[s,r,a]=hl(n,i.t,Ze.From2000),o=new de(s,r,a,i.t),c=t.tobl*ne;return Rd(o,Math.cos(c),Math.sin(c))}function Bs(i){const t=De(i),e=cx(t),n=e.distance_au*Math.cos(e.geo_eclip_lat),s=[n*Math.cos(e.geo_eclip_lon),n*Math.sin(e.geo_eclip_lon),e.distance_au*Math.sin(e.geo_eclip_lat)],r=ox(t,s),a=Oa(r,t,Ze.Into2000);return new de(a[0],a[1],a[2],t)}function Cd(i){const t=De(i),e=1e-5,n=t.AddDays(-e),s=t.AddDays(+e),r=Bs(n),a=Bs(s);return new Mi((r.x+a.x)/2,(r.y+a.y)/2,(r.z+a.z)/2,(a.x-r.x)/(2*e),(a.y-r.y)/(2*e),(a.z-r.z)/(2*e),t)}function _x(i){const t=De(i),e=Cd(t),n=1+Md;return new Mi(e.x/n,e.y/n,e.z/n,e.vx/n,e.vy/n,e.vz/n,t)}function Ls(i,t,e){let n=1,s=0;for(let r of i){let a=0;for(let[c,l,h]of r)a+=c*Math.cos(l+t*h);let o=n*a;e&&(o%=$n),s+=o,n*=t}return s}function Wo(i,t){let e=1,n=0,s=0,r=0;for(let a of i){let o=0,c=0;for(let[l,h,u]of a){let d=h+t*u;o+=l*u*Math.sin(d),r>0&&(c+=l*Math.cos(d))}s+=r*n*c-e*o,n=e,e*=t,++r}return s}const or=365250,fl=0,pl=1,ml=2;function gl(i){return new Ve(i[0]+44036e-11*i[1]-190919e-12*i[2],-479966e-12*i[0]+.917482137087*i[1]-.397776982902*i[2],.397776982902*i[1]+.917482137087*i[2])}function Dd(i,t,e){const n=e*Math.cos(t),s=Math.cos(i),r=Math.sin(i);return[n*s,n*r,e*Math.sin(t)]}function Ns(i,t){const e=t.tt/or,n=Ls(i[fl],e,!0),s=Ls(i[pl],e,!1),r=Ls(i[ml],e,!1),a=Dd(n,s,r);return gl(a).ToAstroVector(t)}function _l(i,t){const e=t/or,n=Ls(i[fl],e,!0),s=Ls(i[pl],e,!1),r=Ls(i[ml],e,!1),a=Wo(i[fl],e),o=Wo(i[pl],e),c=Wo(i[ml],e),l=Math.cos(n),h=Math.sin(n),u=Math.cos(s),d=Math.sin(s),p=+(c*u*l)-r*d*l*o-r*u*h*a,g=+(c*u*h)-r*d*h*o+r*u*l*a,x=+(c*d)+r*u*o,m=Dd(n,s,r),f=[p/or,g/or,x/or],A=gl(m),T=gl(f);return new Zi(t,A,T)}function ra(i,t,e,n){const s=n/(n+ql),r=Ns(kn[e],t);i.x+=s*r.x,i.y+=s*r.y,i.z+=s*r.z}function vx(i){const t=new de(0,0,0,i);return ra(t,i,yt.Jupiter,al),ra(t,i,yt.Saturn,ol),ra(t,i,yt.Uranus,cl),ra(t,i,yt.Neptune,ll),t}const vl=51,xx=29200,Ts=146,Jn=201,Hi=[[-73e4,[-26.118207232108,-14.376168177825,3.384402515299],[.0016339372163656,-.0027861699588508,-.0013585880229445]],[-700800,[41.974905202127,-.448502952929,-12.770351505989],[.00073458569351457,.0022785014891658,.00048619778602049]],[-671600,[14.706930780744,44.269110540027,9.353698474772],[-.00210001479998,.00022295915939915,.00070143443551414]],[-642400,[-29.441003929957,-6.43016153057,6.858481011305],[.00084495803960544,-.0030783914758711,-.0012106305981192]],[-613200,[39.444396946234,-6.557989760571,-13.913760296463],[.0011480029005873,.0022400006880665,.00035168075922288]],[-584e3,[20.2303809507,43.266966657189,7.382966091923],[-.0019754081700585,.00053457141292226,.00075929169129793]],[-554800,[-30.65832536462,2.093818874552,9.880531138071],[61010603013347e-18,-.0031326500935382,-.00099346125151067]],[-525600,[35.737703251673,-12.587706024764,-14.677847247563],[.0015802939375649,.0021347678412429,.00019074436384343]],[-496400,[25.466295188546,41.367478338417,5.216476873382],[-.0018054401046468,.0008328308359951,.00080260156912107]],[-467200,[-29.847174904071,10.636426313081,12.297904180106],[-.00063257063052907,-.0029969577578221,-.00074476074151596]],[-438e3,[30.774692107687,-18.236637015304,-14.945535879896],[.0020113162005465,.0019353827024189,-20937793168297e-19]],[-408800,[30.243153324028,38.656267888503,2.938501750218],[-.0016052508674468,.0011183495337525,.00083333973416824]],[-379600,[-27.288984772533,18.643162147874,14.023633623329],[-.0011856388898191,-.0027170609282181,-.00049015526126399]],[-350400,[24.519605196774,-23.245756064727,-14.626862367368],[.0024322321483154,.0016062008146048,-.00023369181613312]],[-321200,[34.505274805875,35.125338586954,.557361475637],[-.0013824391637782,.0013833397561817,.00084823598806262]],[-292e3,[-23.275363915119,25.818514298769,15.055381588598],[-.0016062295460975,-.0023395961498533,-.00024377362639479]],[-262800,[17.050384798092,-27.180376290126,-13.608963321694],[.0028175521080578,.0011358749093955,-.00049548725258825]],[-233600,[38.093671910285,30.880588383337,-1.843688067413],[-.0011317697153459,.0016128814698472,.00084177586176055]],[-204400,[-18.197852930878,31.932869934309,15.438294826279],[-.0019117272501813,-.0019146495909842,-19657304369835e-18]],[-175200,[8.528924039997,-29.618422200048,-11.805400994258],[.0031034370787005,.0005139363329243,-.00077293066202546]],[-146e3,[40.94685725864,25.904973592021,-4.256336240499],[-.00083652705194051,.0018129497136404,.0008156422827306]],[-116800,[-12.326958895325,36.881883446292,15.217158258711],[-.0021166103705038,-.001481442003599,.00017401209844705]],[-87600,[-.633258375909,-30.018759794709,-9.17193287495],[.0032016994581737,-.00025279858672148,-.0010411088271861]],[-58400,[42.936048423883,20.344685584452,-6.588027007912],[-.00050525450073192,.0019910074335507,.00077440196540269]],[-29200,[-5.975910552974,40.61180995846,14.470131723673],[-.0022184202156107,-.0010562361130164,.00033652250216211]],[0,[-9.875369580774,-27.978926224737,-5.753711824704],[.0030287533248818,-.0011276087003636,-.0012651326732361]],[29200,[43.958831986165,14.214147973292,-8.808306227163],[-.00014717608981871,.0021404187242141,.00071486567806614]],[58400,[.67813676352,43.094461639362,13.243238780721],[-.0022358226110718,-.00063233636090933,.00047664798895648]],[87600,[-18.282602096834,-23.30503958666,-1.766620508028],[.0025567245263557,-.0019902940754171,-.0013943491701082]],[116800,[43.873338744526,7.700705617215,-10.814273666425],[.00023174803055677,.0022402163127924,.00062988756452032]],[146e3,[7.392949027906,44.382678951534,11.629500214854],[-.002193281545383,-.00021751799585364,.00059556516201114]],[175200,[-24.981690229261,-16.204012851426,2.466457544298],[.001819398914958,-.0026765419531201,-.0013848283502247]],[204400,[42.530187039511,.845935508021,-12.554907527683],[.00065059779150669,.0022725657282262,.00051133743202822]],[233600,[13.999526486822,44.462363044894,9.669418486465],[-.0021079296569252,.00017533423831993,.00069128485798076]],[262800,[-29.184024803031,-7.371243995762,6.493275957928],[.00093581363109681,-.0030610357109184,-.0012364201089345]],[292e3,[39.831980671753,-6.078405766765,-13.909815358656],[.0011117769689167,.0022362097830152,.00036230548231153]],[321200,[20.294955108476,43.417190420251,7.450091985932],[-.0019742157451535,.00053102050468554,.00075938408813008]],[350400,[-30.66999230216,2.318743558955,9.973480913858],[45605107450676e-18,-.0031308219926928,-.00099066533301924]],[379600,[35.626122155983,-12.897647509224,-14.777586508444],[.0016015684949743,.0021171931182284,.00018002516202204]],[408800,[26.133186148561,41.232139187599,5.00640132622],[-.0017857704419579,.00086046232702817,.00080614690298954]],[438e3,[-29.57674022923,11.863535943587,12.631323039872],[-.00072292830060955,-.0029587820140709,-.000708242964503]],[467200,[29.910805787391,-19.159019294,-15.013363865194],[.0020871080437997,.0018848372554514,-38528655083926e-18]],[496400,[31.375957451819,38.050372720763,2.433138343754],[-.0015546055556611,.0011699815465629,.00083565439266001]],[525600,[-26.360071336928,20.662505904952,14.414696258958],[-.0013142373118349,-.0026236647854842,-.00042542017598193]],[554800,[22.599441488648,-24.508879898306,-14.484045731468],[.0025454108304806,.0014917058755191,-.00030243665086079]],[584e3,[35.877864013014,33.894226366071,-.224524636277],[-.0012941245730845,.0014560427668319,.00084762160640137]],[613200,[-21.538149762417,28.204068269761,15.321973799534],[-.001731211740901,-.0021939631314577,-.0001631691327518]],[642400,[13.971521374415,-28.339941764789,-13.083792871886],[.0029334630526035,.00091860931752944,-.00059939422488627]],[671600,[39.526942044143,28.93989736011,-2.872799527539],[-.0010068481658095,.001702113288809,.00083578230511981]],[700800,[-15.576200701394,34.399412961275,15.466033737854],[-.0020098814612884,-.0017191109825989,70414782780416e-18]],[73e4,[4.24325283709,-30.118201690825,-10.707441231349],[.0031725847067411,.0001609846120227,-.00090672150593868]]];class Ve{constructor(t,e,n){this.x=t,this.y=e,this.z=n}clone(){return new Ve(this.x,this.y,this.z)}ToAstroVector(t){return new de(this.x,this.y,this.z,t)}static zero(){return new Ve(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(t){return new Ve(this.x+t.x,this.y+t.y,this.z+t.z)}sub(t){return new Ve(this.x-t.x,this.y-t.y,this.z-t.z)}incr(t){this.x+=t.x,this.y+=t.y,this.z+=t.z}decr(t){this.x-=t.x,this.y-=t.y,this.z-=t.z}mul(t){return new Ve(t*this.x,t*this.y,t*this.z)}div(t){return new Ve(this.x/t,this.y/t,this.z/t)}mean(t){return new Ve((this.x+t.x)/2,(this.y+t.y)/2,(this.z+t.z)/2)}neg(){return new Ve(-this.x,-this.y,-this.z)}}class Zi{constructor(t,e,n){this.tt=t,this.r=e,this.v=n}clone(){return new Zi(this.tt,this.r,this.v)}sub(t){return new Zi(this.tt,this.r.sub(t.r),this.v.sub(t.v))}}function Mx(i){let[t,[e,n,s],[r,a,o]]=i;return new Zi(t,new Ve(e,n,s),new Ve(r,a,o))}function aa(i,t,e,n){const s=n/(n+ql),r=_l(kn[e],t);return i.r.incr(r.r.mul(s)),i.v.incr(r.v.mul(s)),r}function tr(i,t,e){const n=e.sub(i),s=n.quadrature();return n.mul(t/(s*Math.sqrt(s)))}class $a{constructor(t){let e=new Zi(t,new Ve(0,0,0),new Ve(0,0,0));this.Jupiter=aa(e,t,yt.Jupiter,al),this.Saturn=aa(e,t,yt.Saturn,ol),this.Uranus=aa(e,t,yt.Uranus,cl),this.Neptune=aa(e,t,yt.Neptune,ll),this.Jupiter.r.decr(e.r),this.Jupiter.v.decr(e.v),this.Saturn.r.decr(e.r),this.Saturn.v.decr(e.v),this.Uranus.r.decr(e.r),this.Uranus.v.decr(e.v),this.Neptune.r.decr(e.r),this.Neptune.v.decr(e.v),this.Sun=new Zi(t,e.r.mul(-1),e.v.mul(-1))}Acceleration(t){let e=tr(t,ql,this.Sun.r);return e.incr(tr(t,al,this.Jupiter.r)),e.incr(tr(t,ol,this.Saturn.r)),e.incr(tr(t,cl,this.Uranus.r)),e.incr(tr(t,ll,this.Neptune.r)),e}}class Ja{constructor(t,e,n,s){this.tt=t,this.r=e,this.v=n,this.a=s}clone(){return new Ja(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class Pd{constructor(t,e){this.bary=t,this.grav=e}}function za(i,t,e,n){return new Ve(t.x+i*(e.x+i*n.x/2),t.y+i*(e.y+i*n.y/2),t.z+i*(e.z+i*n.z/2))}function Nu(i,t,e){return new Ve(t.x+i*e.x,t.y+i*e.y,t.z+i*e.z)}function xl(i,t){const e=i-t.tt,n=new $a(i),s=za(e,t.r,t.v,t.a),r=n.Acceleration(s).mean(t.a),a=za(e,t.r,t.v,r),o=t.v.add(r.mul(e)),c=n.Acceleration(a),l=new Ja(i,a,o,c);return new Pd(n,l)}const Sx=[];function Id(i,t){const e=Math.floor(i);return e<0?0:e>=t?t-1:e}function Ml(i){const t=Mx(i),e=new $a(t.tt),n=t.r.add(e.Sun.r),s=t.v.add(e.Sun.v),r=e.Acceleration(n),a=new Ja(t.tt,n,s,r);return new Pd(e,a)}function yx(i,t){const e=Hi[0][0];if(t<e||t>Hi[vl-1][0])return null;const n=Id((t-e)/xx,vl-1);if(!i[n]){const r=i[n]=[];r[0]=Ml(Hi[n]).grav,r[Jn-1]=Ml(Hi[n+1]).grav;let a,o=r[0].tt;for(a=1;a<Jn-1;++a)r[a]=xl(o+=Ts,r[a-1]).grav;o=r[Jn-1].tt;var s=[];for(s[Jn-1]=r[Jn-1],a=Jn-2;a>0;--a)s[a]=xl(o-=Ts,s[a+1]).grav;for(a=Jn-2;a>0;--a){const c=a/(Jn-1);r[a].r=r[a].r.mul(1-c).add(s[a].r.mul(c)),r[a].v=r[a].v.mul(1-c).add(s[a].v.mul(c)),r[a].a=r[a].a.mul(1-c).add(s[a].a.mul(c))}}return i[n]}function Uu(i,t,e){let n=Ml(i);const s=Math.ceil((t-n.grav.tt)/e);for(let r=0;r<s;++r)n=xl(r+1===s?t:n.grav.tt+e,n.grav);return n}function Ld(i,t){let e,n,s;const r=yx(Sx,i.tt);if(r){const a=Id((i.tt-r[0].tt)/Ts,Jn-1),o=r[a],c=r[a+1],l=o.a.mean(c.a),h=za(i.tt-o.tt,o.r,o.v,l),u=Nu(i.tt-o.tt,o.v,l),d=za(i.tt-c.tt,c.r,c.v,l),p=Nu(i.tt-c.tt,c.v,l),g=(i.tt-o.tt)/Ts;e=h.mul(1-g).add(d.mul(g)),n=u.mul(1-g).add(p.mul(g))}else{let a;i.tt<Hi[0][0]?a=Uu(Hi[0],i.tt,-Ts):a=Uu(Hi[vl-1],i.tt,+Ts),e=a.grav.r,n=a.grav.v,s=a.bary}return s||(s=new $a(i.tt)),e=e.sub(s.Sun.r),n=n.sub(s.Sun.v),new Mi(e.x,e.y,e.z,n.x,n.y,n.z,i)}function yi(i,t){var e=De(t);if(i in kn)return Ns(kn[i],e);if(i===yt.Pluto){const a=Ld(e);return new de(a.x,a.y,a.z,e)}if(i===yt.Sun)return new de(0,0,0,e);if(i===yt.Moon){var n=Ns(kn.Earth,e),s=Bs(e);return new de(n.x+s.x,n.y+s.y,n.z+s.z,e)}if(i===yt.EMB){const a=Ns(kn.Earth,e),o=Bs(e),c=1+Md;return new de(a.x+o.x/c,a.y+o.y/c,a.z+o.z/c,e)}if(i===yt.SSB)return vx(e);const r=Yl(i);if(r){const a=new $l(r.dec,15*r.ra,r.dist);return Ud(a,e)}throw`HelioVector: Unknown body "${i}"`}function Ex(i,t){let e=t,n=0;for(let s=0;s<10;++s){const r=i(e),a=r.Length()/Xl;if(a>1)throw"Object is too distant for light-travel solver.";const o=t.AddDays(-a);if(n=Math.abs(o.tt-e.tt),n<1e-9)return r;e=o}throw`Light-travel time solver did not converge: dt = ${n}`}class bx{constructor(t,e,n,s){this.observerBody=t,this.targetBody=e,this.aberration=n,this.observerPos=s}Position(t){this.aberration&&(this.observerPos=yi(this.observerBody,t));const e=yi(this.targetBody,t);return new de(e.x-this.observerPos.x,e.y-this.observerPos.y,e.z-this.observerPos.z,t)}}function Ax(i,t,e,n){Fa(n);const s=De(i);if(Yl(e)){const o=yi(e,s);if(n){const l=wx(t,s),h=new de(o.x-l.x,o.y-l.y,o.z-l.z,s),u=Xl/h.Length();return new de(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,s)}const c=yi(t,s);return new de(o.x-c.x,o.y-c.y,o.z-c.z,s)}let r;n?r=new de(0,0,0,s):r=yi(t,s);const a=new bx(t,e,n,r);return Ex(o=>a.Position(o),s)}function Sl(i,t,e){Fa(e);const n=De(t);switch(i){case yt.Earth:return new de(0,0,0,n);case yt.Moon:return Bs(n);default:const s=Ax(n,yt.Earth,i,e);return s.t=n,s}}function Tx(i,t){return new Mi(i.r.x,i.r.y,i.r.z,i.v.x,i.v.y,i.v.z,t)}function wx(i,t){const e=De(t);switch(i){case yt.Sun:return new Mi(0,0,0,0,0,0,e);case yt.SSB:const n=new $a(e.tt);return new Mi(-n.Sun.r.x,-n.Sun.r.y,-n.Sun.r.z,-n.Sun.v.x,-n.Sun.v.y,-n.Sun.v.z,e);case yt.Mercury:case yt.Venus:case yt.Earth:case yt.Mars:case yt.Jupiter:case yt.Saturn:case yt.Uranus:case yt.Neptune:const s=_l(kn[i],e.tt);return Tx(s,e);case yt.Pluto:return Ld(e);case yt.Moon:case yt.EMB:const r=_l(kn.Earth,e.tt),a=i==yt.Moon?Cd(e):_x(e);return new Mi(a.x+r.r.x,a.y+r.r.y,a.z+r.r.z,a.vx+r.v.x,a.vy+r.v.y,a.vz+r.v.z,e);default:if(Yl(i)){const o=yi(i,e);return new Mi(o.x,o.y,o.z,0,0,0,e)}throw`HelioState: Unsupported body "${i}"`}}function Rx(i){for(;i<0;)i+=360;for(;i>=360;)i-=360;return i}function Cx(i,t,e){if(i===yt.Earth||t===yt.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=De(e),s=Sl(i,n,!1),r=dl(s),a=Sl(t,n,!1),o=dl(a);return Rx(r.elon-o.elon)}function Dx(i,t,e,n){let s,r=0,a=0,o=0;switch(i){case yt.Mercury:s=-.6,r=4.98,a=-4.88,o=3.02;break;case yt.Venus:t<163.6?(s=-4.47,r=1.03,a=.57,o=.13):(s=.98,r=-1.02);break;case yt.Mars:s=-1.52,r=1.6;break;case yt.Jupiter:s=-9.4,r=.5;break;case yt.Uranus:s=-7.19,r=.25;break;case yt.Neptune:s=-6.87;break;case yt.Pluto:s=-1,r=4;break;default:throw`VisualMagnitude: unsupported body ${i}`}const c=t/100;let l=s+c*(r+c*(a+c*o));return l+=5*Math.log10(e*n),l}function Px(i,t,e,n,s){const r=dl(n),a=ne*28.06,o=ne*(169.51+382e-7*s.tt),c=ne*r.elat,l=ne*r.elon,h=Math.asin(Math.sin(c)*Math.cos(a)-Math.cos(c)*Math.sin(a)*Math.sin(l-o)),u=Math.sin(Math.abs(h));let d=-9+.044*i;return d+=u*(-2.6+1.2*u),d+=5*Math.log10(t*e),{mag:d,ring_tilt:Hn*h}}function Ix(i,t,e){let n=i*ne,s=n*n,r=s*s,a=-12.717+1.49*Math.abs(n)+.0431*r;const o=385000.6/zi;let c=e/o;return a+=5*Math.log10(t*c),a}class Lx{constructor(t,e,n,s,r,a,o,c){this.time=t,this.mag=e,this.phase_angle=n,this.helio_dist=s,this.geo_dist=r,this.gc=a,this.hc=o,this.ring_tilt=c,this.phase_fraction=(1+Math.cos(ne*n))/2}}function Nd(i,t){if(i===yt.Earth)throw"The illumination of the Earth is not defined.";const e=De(t),n=Ns(kn.Earth,e);let s,r,a,o;i===yt.Sun?(a=new de(-n.x,-n.y,-n.z,e),r=new de(0,0,0,e),s=0):(i===yt.Moon?(a=Bs(e),r=new de(n.x+a.x,n.y+a.y,n.z+a.z,e)):(r=yi(i,t),a=new de(r.x-n.x,r.y-n.y,r.z-n.z,e)),s=jv(a,r));let c=a.Length(),l=r.Length(),h;if(i===yt.Sun)o=$v+5*Math.log10(c);else if(i===yt.Moon)o=Ix(s,l,c);else if(i===yt.Saturn){const u=Px(s,l,c,a,e);o=u.mag,h=u.ring_tilt}else o=Dx(i,s,l,c);return new Lx(e,o,s,l,c,a,r,h)}function Nx(i){return Cx(yt.Moon,yt.Sun,i)}var Fu;(function(i){i[i.Pericenter=0]="Pericenter",i[i.Apocenter=1]="Apocenter"})(Fu||(Fu={}));function Ux(i,t){return new Ai([[t.rot[0][0]*i.rot[0][0]+t.rot[1][0]*i.rot[0][1]+t.rot[2][0]*i.rot[0][2],t.rot[0][1]*i.rot[0][0]+t.rot[1][1]*i.rot[0][1]+t.rot[2][1]*i.rot[0][2],t.rot[0][2]*i.rot[0][0]+t.rot[1][2]*i.rot[0][1]+t.rot[2][2]*i.rot[0][2]],[t.rot[0][0]*i.rot[1][0]+t.rot[1][0]*i.rot[1][1]+t.rot[2][0]*i.rot[1][2],t.rot[0][1]*i.rot[1][0]+t.rot[1][1]*i.rot[1][1]+t.rot[2][1]*i.rot[1][2],t.rot[0][2]*i.rot[1][0]+t.rot[1][2]*i.rot[1][1]+t.rot[2][2]*i.rot[1][2]],[t.rot[0][0]*i.rot[2][0]+t.rot[1][0]*i.rot[2][1]+t.rot[2][0]*i.rot[2][2],t.rot[0][1]*i.rot[2][0]+t.rot[1][1]*i.rot[2][1]+t.rot[2][1]*i.rot[2][2],t.rot[0][2]*i.rot[2][0]+t.rot[1][2]*i.rot[2][1]+t.rot[2][2]*i.rot[2][2]]])}function Ud(i,t){t=De(t);const e=i.lat*ne,n=i.lon*ne,s=i.dist*Math.cos(e);return new de(s*Math.cos(n),s*Math.sin(n),i.dist*Math.sin(e),t)}function Fd(i){const t=Fx(i);return new ul(t.lon/15,t.lat,t.dist,i)}function Fx(i){const t=i.x*i.x+i.y*i.y,e=Math.sqrt(t+i.z*i.z);let n,s;if(t===0){if(i.z===0)throw"Zero-length vector not allowed.";s=0,n=i.z<0?-90:90}else s=Hn*Math.atan2(i.y,i.x),s<0&&(s+=360),n=Hn*Math.atan2(i.z,Math.sqrt(t));return new $l(n,s,e)}function Ox(i,t){let e;if(Ue(t),t<-90||t>90)return 0;{let n=t;n<-1&&(n=-1),e=1.02/Math.tan((n+10.3/(n+5.11))*ne)/60,t<-1&&(e*=(t+90)/89)}return e}function wa(i,t){return new de(i.rot[0][0]*t.x+i.rot[1][0]*t.y+i.rot[2][0]*t.z,i.rot[0][1]*t.x+i.rot[1][1]*t.y+i.rot[2][1]*t.z,i.rot[0][2]*t.x+i.rot[1][2]*t.y+i.rot[2][2]*t.z,t.t)}function zx(){return new Ai([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function Bx(){return new Ai([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function kx(i){i=De(i);const t=Ed(i,Ze.From2000),e=Ad(i,Ze.From2000);return Ux(t,e)}function Gx(i){const e=Sr(De(i)).tobl*ne,n=Math.cos(e),s=Math.sin(e);return new Ai([[1,0,0],[0,+n,+s],[0,-s,+n]])}var Ou;(function(i){i.Penumbral="penumbral",i.Partial="partial",i.Annular="annular",i.Total="total"})(Ou||(Ou={}));var zu;(function(i){i[i.Invalid=0]="Invalid",i[i.Ascending=1]="Ascending",i[i.Descending=-1]="Descending"})(zu||(zu={}));const Hx=["Venus","Mars","Jupiter","Saturn"];function Od(i){return new Ql(i.lat,i.lng,i.elevationM)}function Qa(i,t,e,n){const s=wd(e,Od(n),i,t,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function Xo(i,t,e){const n=Od(e),s=mx(yt[i],t,n,!0,!0),r=wd(t,n,s.ra,s.dec,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function qo(i,t){return Nd(yt[i],t).mag}function Vx(i){const t=Nx(i),e=Nd(yt.Moon,i);return{phaseFraction:t/360,illuminatedFraction:e.phase_fraction}}const Wx=2e3,Xx=3,qx=20;function Bu(i,t,e){if(i.year===void 0&&i.month===void 0&&i.day===void 0&&i.hour===void 0)return;const n=i.year!==void 0,s=i.year??Wx,r=i.month??(n?1:Xx),a=i.day??(n?1:qx),o=e??Math.round(t/15);return new Date(Date.UTC(s,r-1,a,(i.hour??12)-o,i.minute??0,i.second??0))}class Bi{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static apply(t){t.transparent=!0,t.depthWrite=!1,t.onBeforeCompile=e=>{e.fragmentShader=Bi.patch(e.fragmentShader)}}static patch(t){return t.replace(Bi.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
4446
+ */const jl=173.1446326846693,Vi=14959787069098932e-8,ee=.017453292519943295,zu=.26179938779914946,Yn=57.29577951308232,Ad=3.819718634205488,tx=365.24217,Bu=new Date("2000-01-01T12:00:00Z"),ti=2*Math.PI,xi=3600*(180/Math.PI),Rs=484813681109536e-20,Td=10800*60,ex=2*Td,ku=7292115e-11,nx=Td/Math.PI,ix=-.17-5*Math.log10(nx),ul=.996647180302104,sx=ul*ul,dl=6378.1366,rx=dl/Vi,wd=81.30056,th=.0002959122082855911,fl=2825345909524226e-22,pl=8459715185680659e-23,ml=1292024916781969e-23,gl=1524358900784276e-23;function Va(i){if(i!==!0&&i!==!1)throw console.trace(),`Value is not boolean: ${i}`;return i}function ze(i){if(!Number.isFinite(i))throw console.trace(),`Value is not a finite number: ${i}`;return i}function ys(i){return i-Math.floor(i)}function ax(i,t){const e=i.x*i.x+i.y*i.y+i.z*i.z;if(Math.abs(e)<1e-8)throw"AngleBetween: first vector is too short.";const n=t.x*t.x+t.y*t.y+t.z*t.z;if(Math.abs(n)<1e-8)throw"AngleBetween: second vector is too short.";const s=(i.x*t.x+i.y*t.y+i.z*t.z)/Math.sqrt(e*n);return s<=-1?180:s>=1?0:Yn*Math.acos(s)}var yt;(function(i){i.Sun="Sun",i.Moon="Moon",i.Mercury="Mercury",i.Venus="Venus",i.Earth="Earth",i.Mars="Mars",i.Jupiter="Jupiter",i.Saturn="Saturn",i.Uranus="Uranus",i.Neptune="Neptune",i.Pluto="Pluto",i.SSB="SSB",i.EMB="EMB",i.Star1="Star1",i.Star2="Star2",i.Star3="Star3",i.Star4="Star4",i.Star5="Star5",i.Star6="Star6",i.Star7="Star7",i.Star8="Star8"})(yt||(yt={}));const ox=[yt.Star1,yt.Star2,yt.Star3,yt.Star4,yt.Star5,yt.Star6,yt.Star7,yt.Star8],cx=[{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0}];function lx(i){const t=ox.indexOf(i);return t>=0?cx[t]:null}function eh(i){const t=lx(i);return t&&t.dist>0?t:null}var $e;(function(i){i[i.From2000=0]="From2000",i[i.Into2000=1]="Into2000"})($e||($e={}));const Xn={Mercury:[[[[4.40250710144,0,0],[.40989414977,1.48302034195,26087.9031415742],[.050462942,4.47785489551,52175.8062831484],[.00855346844,1.16520322459,78263.70942472259],[.00165590362,4.11969163423,104351.61256629678],[.00034561897,.77930768443,130439.51570787099],[7583476e-11,3.71348404924,156527.41884944518]],[[26087.90313685529,0,0],[.01131199811,6.21874197797,26087.9031415742],[.00292242298,3.04449355541,52175.8062831484],[.00075775081,6.08568821653,78263.70942472259],[.00019676525,2.80965111777,104351.61256629678]]],[[[.11737528961,1.98357498767,26087.9031415742],[.02388076996,5.03738959686,52175.8062831484],[.01222839532,3.14159265359,0],[.0054325181,1.79644363964,78263.70942472259],[.0012977877,4.83232503958,104351.61256629678],[.00031866927,1.58088495658,130439.51570787099],[7963301e-11,4.60972126127,156527.41884944518]],[[.00274646065,3.95008450011,26087.9031415742],[.00099737713,3.14159265359,0]]],[[[.39528271651,0,0],[.07834131818,6.19233722598,26087.9031415742],[.00795525558,2.95989690104,52175.8062831484],[.00121281764,6.01064153797,78263.70942472259],[.00021921969,2.77820093972,104351.61256629678],[4354065e-11,5.82894543774,130439.51570787099]],[[.0021734774,4.65617158665,26087.9031415742],[.00044141826,1.42385544001,52175.8062831484]]]],Venus:[[[[3.17614666774,0,0],[.01353968419,5.59313319619,10213.285546211],[.00089891645,5.30650047764,20426.571092422],[5477194e-11,4.41630661466,7860.4193924392],[3455741e-11,2.6996444782,11790.6290886588],[2372061e-11,2.99377542079,3930.2096962196],[1317168e-11,5.18668228402,26.2983197998],[1664146e-11,4.25018630147,1577.3435424478],[1438387e-11,4.15745084182,9683.5945811164],[1200521e-11,6.15357116043,30639.856638633]],[[10213.28554621638,0,0],[.00095617813,2.4640651111,10213.285546211],[7787201e-11,.6247848222,20426.571092422]]],[[[.05923638472,.26702775812,10213.285546211],[.00040107978,1.14737178112,20426.571092422],[.00032814918,3.14159265359,0]],[[.00287821243,1.88964962838,10213.285546211]]],[[[.72334820891,0,0],[.00489824182,4.02151831717,10213.285546211],[1658058e-11,4.90206728031,20426.571092422],[1378043e-11,1.12846591367,11790.6290886588],[1632096e-11,2.84548795207,7860.4193924392],[498395e-11,2.58682193892,9683.5945811164],[221985e-11,2.01346696541,19367.1891622328],[237454e-11,2.55136053886,15720.8387848784]],[[.00034551041,.89198706276,10213.285546211]]]],Earth:[[[[1.75347045673,0,0],[.03341656453,4.66925680415,6283.0758499914],[.00034894275,4.62610242189,12566.1516999828],[3417572e-11,2.82886579754,3.523118349],[3497056e-11,2.74411783405,5753.3848848968],[3135899e-11,3.62767041756,77713.7714681205],[2676218e-11,4.41808345438,7860.4193924392],[2342691e-11,6.13516214446,3930.2096962196],[1273165e-11,2.03709657878,529.6909650946],[1324294e-11,.74246341673,11506.7697697936],[901854e-11,2.04505446477,26.2983197998],[1199167e-11,1.10962946234,1577.3435424478],[857223e-11,3.50849152283,398.1490034082],[779786e-11,1.17882681962,5223.6939198022],[99025e-10,5.23268072088,5884.9268465832],[753141e-11,2.53339052847,5507.5532386674],[505267e-11,4.58292599973,18849.2275499742],[492392e-11,4.20505711826,775.522611324],[356672e-11,2.91954114478,.0673103028],[284125e-11,1.89869240932,796.2980068164],[242879e-11,.34481445893,5486.777843175],[317087e-11,5.84901948512,11790.6290886588],[271112e-11,.31486255375,10977.078804699],[206217e-11,4.80646631478,2544.3144198834],[205478e-11,1.86953770281,5573.1428014331],[202318e-11,2.45767790232,6069.7767545534],[126225e-11,1.08295459501,20.7753954924],[155516e-11,.83306084617,213.299095438]],[[6283.0758499914,0,0],[.00206058863,2.67823455808,6283.0758499914],[4303419e-11,2.63512233481,12566.1516999828]],[[8721859e-11,1.07253635559,6283.0758499914]]],[[],[[.00227777722,3.4137662053,6283.0758499914],[3805678e-11,3.37063423795,12566.1516999828]]],[[[1.00013988784,0,0],[.01670699632,3.09846350258,6283.0758499914],[.00013956024,3.05524609456,12566.1516999828],[308372e-10,5.19846674381,77713.7714681205],[1628463e-11,1.17387558054,5753.3848848968],[1575572e-11,2.84685214877,7860.4193924392],[924799e-11,5.45292236722,11506.7697697936],[542439e-11,4.56409151453,3930.2096962196],[47211e-10,3.66100022149,5884.9268465832],[85831e-11,1.27079125277,161000.6857376741],[57056e-11,2.01374292245,83996.84731811189],[55736e-11,5.2415979917,71430.69561812909],[174844e-11,3.01193636733,18849.2275499742],[243181e-11,4.2734953079,11790.6290886588]],[[.00103018607,1.10748968172,6283.0758499914],[1721238e-11,1.06442300386,12566.1516999828]],[[4359385e-11,5.78455133808,6283.0758499914]]]],Mars:[[[[6.20347711581,0,0],[.18656368093,5.0503710027,3340.6124266998],[.01108216816,5.40099836344,6681.2248533996],[.00091798406,5.75478744667,10021.8372800994],[.00027744987,5.97049513147,3.523118349],[.00010610235,2.93958560338,2281.2304965106],[.00012315897,.84956094002,2810.9214616052],[8926784e-11,4.15697846427,.0172536522],[8715691e-11,6.11005153139,13362.4497067992],[6797556e-11,.36462229657,398.1490034082],[7774872e-11,3.33968761376,5621.8429232104],[3575078e-11,1.6618650571,2544.3144198834],[4161108e-11,.22814971327,2942.4634232916],[3075252e-11,.85696614132,191.4482661116],[2628117e-11,.64806124465,3337.0893083508],[2937546e-11,6.07893711402,.0673103028],[2389414e-11,5.03896442664,796.2980068164],[2579844e-11,.02996736156,3344.1355450488],[1528141e-11,1.14979301996,6151.533888305],[1798806e-11,.65634057445,529.6909650946],[1264357e-11,3.62275122593,5092.1519581158],[1286228e-11,3.06796065034,2146.1654164752],[1546404e-11,2.91579701718,1751.539531416],[1024902e-11,3.69334099279,8962.4553499102],[891566e-11,.18293837498,16703.062133499],[858759e-11,2.4009381194,2914.0142358238],[832715e-11,2.46418619474,3340.5951730476],[83272e-10,4.49495782139,3340.629680352],[712902e-11,3.66335473479,1059.3819301892],[748723e-11,3.82248614017,155.4203994342],[723861e-11,.67497311481,3738.761430108],[635548e-11,2.92182225127,8432.7643848156],[655162e-11,.48864064125,3127.3133312618],[550474e-11,3.81001042328,.9803210682],[55275e-10,4.47479317037,1748.016413067],[425966e-11,.55364317304,6283.0758499914],[415131e-11,.49662285038,213.299095438],[472167e-11,3.62547124025,1194.4470102246],[306551e-11,.38052848348,6684.7479717486],[312141e-11,.99853944405,6677.7017350506],[293198e-11,4.22131299634,20.7753954924],[302375e-11,4.48618007156,3532.0606928114],[274027e-11,.54222167059,3340.545116397],[281079e-11,5.88163521788,1349.8674096588],[231183e-11,1.28242156993,3870.3033917944],[283602e-11,5.7688543494,3149.1641605882],[236117e-11,5.75503217933,3333.498879699],[274033e-11,.13372524985,3340.6797370026],[299395e-11,2.78323740866,6254.6266625236]],[[3340.61242700512,0,0],[.01457554523,3.60433733236,3340.6124266998],[.00168414711,3.92318567804,6681.2248533996],[.00020622975,4.26108844583,10021.8372800994],[3452392e-11,4.7321039319,3.523118349],[2586332e-11,4.60670058555,13362.4497067992],[841535e-11,4.45864030426,2281.2304965106]],[[.00058152577,2.04961712429,3340.6124266998],[.00013459579,2.45738706163,6681.2248533996]]],[[[.03197134986,3.76832042431,3340.6124266998],[.00298033234,4.10616996305,6681.2248533996],[.00289104742,0,0],[.00031365539,4.4465105309,10021.8372800994],[34841e-9,4.7881254926,13362.4497067992]],[[.00217310991,6.04472194776,3340.6124266998],[.00020976948,3.14159265359,0],[.00012834709,1.60810667915,6681.2248533996]]],[[[1.53033488271,0,0],[.1418495316,3.47971283528,3340.6124266998],[.00660776362,3.81783443019,6681.2248533996],[.00046179117,4.15595316782,10021.8372800994],[8109733e-11,5.55958416318,2810.9214616052],[7485318e-11,1.77239078402,5621.8429232104],[5523191e-11,1.3643630377,2281.2304965106],[382516e-10,4.49407183687,13362.4497067992],[2306537e-11,.09081579001,2544.3144198834],[1999396e-11,5.36059617709,3337.0893083508],[2484394e-11,4.9254563992,2942.4634232916],[1960195e-11,4.74249437639,3344.1355450488],[1167119e-11,2.11260868341,5092.1519581158],[1102816e-11,5.00908403998,398.1490034082],[899066e-11,4.40791133207,529.6909650946],[992252e-11,5.83861961952,6151.533888305],[807354e-11,2.10217065501,1059.3819301892],[797915e-11,3.44839203899,796.2980068164],[740975e-11,1.49906336885,2146.1654164752]],[[.01107433345,2.03250524857,3340.6124266998],[.00103175887,2.37071847807,6681.2248533996],[128772e-9,0,0],[.0001081588,2.70888095665,10021.8372800994]],[[.00044242249,.47930604954,3340.6124266998],[8138042e-11,.86998389204,6681.2248533996]]]],Jupiter:[[[[.59954691494,0,0],[.09695898719,5.06191793158,529.6909650946],[.00573610142,1.44406205629,7.1135470008],[.00306389205,5.41734730184,1059.3819301892],[.00097178296,4.14264726552,632.7837393132],[.00072903078,3.64042916389,522.5774180938],[.00064263975,3.41145165351,103.0927742186],[.00039806064,2.29376740788,419.4846438752],[.00038857767,1.27231755835,316.3918696566],[.00027964629,1.7845459182,536.8045120954],[.0001358973,5.7748104079,1589.0728952838],[8246349e-11,3.5822792584,206.1855484372],[8768704e-11,3.63000308199,949.1756089698],[7368042e-11,5.0810119427,735.8765135318],[626315e-10,.02497628807,213.299095438],[6114062e-11,4.51319998626,1162.4747044078],[4905396e-11,1.32084470588,110.2063212194],[5305285e-11,1.30671216791,14.2270940016],[5305441e-11,4.18625634012,1052.2683831884],[4647248e-11,4.69958103684,3.9321532631],[3045023e-11,4.31676431084,426.598190876],[2609999e-11,1.56667394063,846.0828347512],[2028191e-11,1.06376530715,3.1813937377],[1764763e-11,2.14148655117,1066.49547719],[1722972e-11,3.88036268267,1265.5674786264],[1920945e-11,.97168196472,639.897286314],[1633223e-11,3.58201833555,515.463871093],[1431999e-11,4.29685556046,625.6701923124],[973272e-11,4.09764549134,95.9792272178]],[[529.69096508814,0,0],[.00489503243,4.2208293947,529.6909650946],[.00228917222,6.02646855621,7.1135470008],[.00030099479,4.54540782858,1059.3819301892],[.0002072092,5.45943156902,522.5774180938],[.00012103653,.16994816098,536.8045120954],[6067987e-11,4.42422292017,103.0927742186],[5433968e-11,3.98480737746,419.4846438752],[4237744e-11,5.89008707199,14.2270940016]],[[.00047233601,4.32148536482,7.1135470008],[.00030649436,2.929777887,529.6909650946],[.00014837605,3.14159265359,0]]],[[[.02268615702,3.55852606721,529.6909650946],[.00109971634,3.90809347197,1059.3819301892],[.00110090358,0,0],[8101428e-11,3.60509572885,522.5774180938],[6043996e-11,4.25883108339,1589.0728952838],[6437782e-11,.30627119215,536.8045120954]],[[.00078203446,1.52377859742,529.6909650946]]],[[[5.20887429326,0,0],[.25209327119,3.49108639871,529.6909650946],[.00610599976,3.84115365948,1059.3819301892],[.00282029458,2.57419881293,632.7837393132],[.00187647346,2.07590383214,522.5774180938],[.00086792905,.71001145545,419.4846438752],[.00072062974,.21465724607,536.8045120954],[.00065517248,5.9799588479,316.3918696566],[.00029134542,1.67759379655,103.0927742186],[.00030135335,2.16132003734,949.1756089698],[.00023453271,3.54023522184,735.8765135318],[.00022283743,4.19362594399,1589.0728952838],[.00023947298,.2745803748,7.1135470008],[.00013032614,2.96042965363,1162.4747044078],[970336e-10,1.90669633585,206.1855484372],[.00012749023,2.71550286592,1052.2683831884],[7057931e-11,2.18184839926,1265.5674786264],[6137703e-11,6.26418240033,846.0828347512],[2616976e-11,2.00994012876,1581.959348283]],[[.0127180152,2.64937512894,529.6909650946],[.00061661816,3.00076460387,1059.3819301892],[.00053443713,3.89717383175,522.5774180938],[.00031185171,4.88276958012,536.8045120954],[.00041390269,0,0]]]],Saturn:[[[[.87401354025,0,0],[.11107659762,3.96205090159,213.299095438],[.01414150957,4.58581516874,7.1135470008],[.00398379389,.52112032699,206.1855484372],[.00350769243,3.30329907896,426.598190876],[.00206816305,.24658372002,103.0927742186],[792713e-9,3.84007056878,220.4126424388],[.00023990355,4.66976924553,110.2063212194],[.00016573588,.43719228296,419.4846438752],[.00014906995,5.76903183869,316.3918696566],[.0001582029,.93809155235,632.7837393132],[.00014609559,1.56518472,3.9321532631],[.00013160301,4.44891291899,14.2270940016],[.00015053543,2.71669915667,639.897286314],[.00013005299,5.98119023644,11.0457002639],[.00010725067,3.12939523827,202.2533951741],[5863206e-11,.23656938524,529.6909650946],[5227757e-11,4.20783365759,3.1813937377],[6126317e-11,1.76328667907,277.0349937414],[5019687e-11,3.17787728405,433.7117378768],[459255e-10,.61977744975,199.0720014364],[4005867e-11,2.24479718502,63.7358983034],[2953796e-11,.98280366998,95.9792272178],[387367e-10,3.22283226966,138.5174968707],[2461186e-11,2.03163875071,735.8765135318],[3269484e-11,.77492638211,949.1756089698],[1758145e-11,3.2658010994,522.5774180938],[1640172e-11,5.5050445305,846.0828347512],[1391327e-11,4.02333150505,323.5054166574],[1580648e-11,4.37265307169,309.2783226558],[1123498e-11,2.83726798446,415.5524906121],[1017275e-11,3.71700135395,227.5261894396],[848642e-11,3.1915017083,209.3669421749]],[[213.2990952169,0,0],[.01297370862,1.82834923978,213.299095438],[.00564345393,2.88499717272,7.1135470008],[.00093734369,1.06311793502,426.598190876],[.00107674962,2.27769131009,206.1855484372],[.00040244455,2.04108104671,220.4126424388],[.00019941774,1.2795439047,103.0927742186],[.00010511678,2.7488034213,14.2270940016],[6416106e-11,.38238295041,639.897286314],[4848994e-11,2.43037610229,419.4846438752],[4056892e-11,2.92133209468,110.2063212194],[3768635e-11,3.6496533078,3.9321532631]],[[.0011644133,1.17988132879,7.1135470008],[.00091841837,.0732519584,213.299095438],[.00036661728,0,0],[.00015274496,4.06493179167,206.1855484372]]],[[[.04330678039,3.60284428399,213.299095438],[.00240348302,2.85238489373,426.598190876],[.00084745939,0,0],[.00030863357,3.48441504555,220.4126424388],[.00034116062,.57297307557,206.1855484372],[.0001473407,2.11846596715,639.897286314],[9916667e-11,5.79003188904,419.4846438752],[6993564e-11,4.7360468972,7.1135470008],[4807588e-11,5.43305312061,316.3918696566]],[[.00198927992,4.93901017903,213.299095438],[.00036947916,3.14159265359,0],[.00017966989,.5197943111,426.598190876]]],[[[9.55758135486,0,0],[.52921382865,2.39226219573,213.299095438],[.01873679867,5.2354960466,206.1855484372],[.01464663929,1.64763042902,426.598190876],[.00821891141,5.93520042303,316.3918696566],[.00547506923,5.0153261898,103.0927742186],[.0037168465,2.27114821115,220.4126424388],[.00361778765,3.13904301847,7.1135470008],[.00140617506,5.70406606781,632.7837393132],[.00108974848,3.29313390175,110.2063212194],[.00069006962,5.94099540992,419.4846438752],[.00061053367,.94037691801,639.897286314],[.00048913294,1.55733638681,202.2533951741],[.00034143772,.19519102597,277.0349937414],[.00032401773,5.47084567016,949.1756089698],[.00020936596,.46349251129,735.8765135318],[9796004e-11,5.20477537945,1265.5674786264],[.00011993338,5.98050967385,846.0828347512],[208393e-9,1.52102476129,433.7117378768],[.00015298404,3.0594381494,529.6909650946],[6465823e-11,.17732249942,1052.2683831884],[.00011380257,1.7310542704,522.5774180938],[3419618e-11,4.94550542171,1581.959348283]],[[.0618298134,.2584351148,213.299095438],[.00506577242,.71114625261,206.1855484372],[.00341394029,5.79635741658,426.598190876],[.00188491195,.47215589652,220.4126424388],[.00186261486,3.14159265359,0],[.00143891146,1.40744822888,7.1135470008]],[[.00436902572,4.78671677509,213.299095438]]]],Uranus:[[[[5.48129294297,0,0],[.09260408234,.89106421507,74.7815985673],[.01504247898,3.6271926092,1.4844727083],[.00365981674,1.89962179044,73.297125859],[.00272328168,3.35823706307,149.5631971346],[.00070328461,5.39254450063,63.7358983034],[.00068892678,6.09292483287,76.2660712756],[.00061998615,2.26952066061,2.9689454166],[.00061950719,2.85098872691,11.0457002639],[.0002646877,3.14152083966,71.8126531507],[.00025710476,6.11379840493,454.9093665273],[.0002107885,4.36059339067,148.0787244263],[.00017818647,1.74436930289,36.6485629295],[.00014613507,4.73732166022,3.9321532631],[.00011162509,5.8268179635,224.3447957019],[.0001099791,.48865004018,138.5174968707],[9527478e-11,2.95516862826,35.1640902212],[7545601e-11,5.236265824,109.9456887885],[4220241e-11,3.23328220918,70.8494453042],[40519e-9,2.277550173,151.0476698429],[3354596e-11,1.0654900738,4.4534181249],[2926718e-11,4.62903718891,9.5612275556],[349034e-10,5.48306144511,146.594251718],[3144069e-11,4.75199570434,77.7505439839],[2922333e-11,5.35235361027,85.8272988312],[2272788e-11,4.36600400036,70.3281804424],[2051219e-11,1.51773566586,.1118745846],[2148602e-11,.60745949945,38.1330356378],[1991643e-11,4.92437588682,277.0349937414],[1376226e-11,2.04283539351,65.2203710117],[1666902e-11,3.62744066769,380.12776796],[1284107e-11,3.11347961505,202.2533951741],[1150429e-11,.93343589092,3.1813937377],[1533221e-11,2.58594681212,52.6901980395],[1281604e-11,.54271272721,222.8603229936],[1372139e-11,4.19641530878,111.4301614968],[1221029e-11,.1990065003,108.4612160802],[946181e-11,1.19253165736,127.4717966068],[1150989e-11,4.17898916639,33.6796175129]],[[74.7815986091,0,0],[.00154332863,5.24158770553,74.7815985673],[.00024456474,1.71260334156,1.4844727083],[9258442e-11,.4282973235,11.0457002639],[8265977e-11,1.50218091379,63.7358983034],[915016e-10,1.41213765216,149.5631971346]]],[[[.01346277648,2.61877810547,74.7815985673],[623414e-9,5.08111189648,149.5631971346],[.00061601196,3.14159265359,0],[9963722e-11,1.61603805646,76.2660712756],[992616e-10,.57630380333,73.297125859]],[[.00034101978,.01321929936,74.7815985673]]],[[[19.21264847206,0,0],[.88784984413,5.60377527014,74.7815985673],[.03440836062,.32836099706,73.297125859],[.0205565386,1.7829515933,149.5631971346],[.0064932241,4.52247285911,76.2660712756],[.00602247865,3.86003823674,63.7358983034],[.00496404167,1.40139935333,454.9093665273],[.00338525369,1.58002770318,138.5174968707],[.00243509114,1.57086606044,71.8126531507],[.00190522303,1.99809394714,1.4844727083],[.00161858838,2.79137786799,148.0787244263],[.00143706183,1.38368544947,11.0457002639],[.00093192405,.17437220467,36.6485629295],[.00071424548,4.24509236074,224.3447957019],[.00089806014,3.66105364565,109.9456887885],[.00039009723,1.66971401684,70.8494453042],[.00046677296,1.39976401694,35.1640902212],[.00039025624,3.36234773834,277.0349937414],[.00036755274,3.88649278513,146.594251718],[.00030348723,.70100838798,151.0476698429],[.00029156413,3.180563367,77.7505439839],[.00022637073,.72518687029,529.6909650946],[.00011959076,1.7504339214,984.6003316219],[.00025620756,5.25656086672,380.12776796]],[[.01479896629,3.67205697578,74.7815985673]]]],Neptune:[[[[5.31188633046,0,0],[.0179847553,2.9010127389,38.1330356378],[.01019727652,.48580922867,1.4844727083],[.00124531845,4.83008090676,36.6485629295],[.00042064466,5.41054993053,2.9689454166],[.00037714584,6.09221808686,35.1640902212],[.00033784738,1.24488874087,76.2660712756],[.00016482741,7727998e-11,491.5579294568],[9198584e-11,4.93747051954,39.6175083461],[899425e-10,.27462171806,175.1660598002]],[[38.13303563957,0,0],[.00016604172,4.86323329249,1.4844727083],[.00015744045,2.27887427527,38.1330356378]]],[[[.03088622933,1.44104372644,38.1330356378],[.00027780087,5.91271884599,76.2660712756],[.00027623609,0,0],[.00015355489,2.52123799551,36.6485629295],[.00015448133,3.50877079215,39.6175083461]]],[[[30.07013205828,0,0],[.27062259632,1.32999459377,38.1330356378],[.01691764014,3.25186135653,36.6485629295],[.00807830553,5.18592878704,1.4844727083],[.0053776051,4.52113935896,35.1640902212],[.00495725141,1.5710564165,491.5579294568],[.00274571975,1.84552258866,175.1660598002],[.0001201232,1.92059384991,1021.2488945514],[.00121801746,5.79754470298,76.2660712756],[.00100896068,.3770272493,73.297125859],[.00135134092,3.37220609835,39.6175083461],[7571796e-11,1.07149207335,388.4651552382]]]]};function hx(i){var t,e,n,s,r,a,o;const c=2e3+(i-14)/tx;return c<-500?(t=(c-1820)/100,-20+32*t*t):c<500?(t=c/100,e=t*t,n=t*e,s=e*e,r=e*n,a=n*n,10583.6-1014.41*t+33.78311*e-5.952053*n-.1798452*s+.022174192*r+.0090316521*a):c<1600?(t=(c-1e3)/100,e=t*t,n=t*e,s=e*e,r=e*n,a=n*n,1574.2-556.01*t+71.23472*e+.319781*n-.8503463*s-.005050998*r+.0083572073*a):c<1700?(t=c-1600,e=t*t,n=t*e,120-.9808*t-.01532*e+n/7129):c<1800?(t=c-1700,e=t*t,n=t*e,s=e*e,8.83+.1603*t-.0059285*e+13336e-8*n-s/1174e3):c<1860?(t=c-1800,e=t*t,n=t*e,s=e*e,r=e*n,a=n*n,o=n*s,13.72-.332447*t+.0068612*e+.0041116*n-37436e-8*s+121272e-10*r-1699e-10*a+875e-12*o):c<1900?(t=c-1860,e=t*t,n=t*e,s=e*e,r=e*n,7.62+.5737*t-.251754*e+.01680668*n-.0004473624*s+r/233174):c<1920?(t=c-1900,e=t*t,n=t*e,s=e*e,-2.79+1.494119*t-.0598939*e+.0061966*n-197e-6*s):c<1941?(t=c-1920,e=t*t,n=t*e,21.2+.84493*t-.0761*e+.0020936*n):c<1961?(t=c-1950,e=t*t,n=t*e,29.07+.407*t-e/233+n/2547):c<1986?(t=c-1975,e=t*t,n=t*e,45.45+1.067*t-e/260-n/718):c<2005?(t=c-2e3,e=t*t,n=t*e,s=e*e,r=e*n,63.86+.3345*t-.060374*e+.0017275*n+651814e-9*s+2373599e-11*r):c<2050?(t=c-2e3,62.92+.32217*t+.005589*t*t):c<2150?(t=(c-1820)/100,-20+32*t*t-.5628*(2150-c)):(t=(c-1820)/100,-20+32*t*t)}let ux=hx;function Gu(i){return i+ux(i)/86400}class Fs{constructor(t){if(t instanceof Fs){this.date=t.date,this.ut=t.ut,this.tt=t.tt;return}const e=1e3*3600*24;if(t instanceof Date&&Number.isFinite(t.getTime())){this.date=t,this.ut=(t.getTime()-Bu.getTime())/e,this.tt=Gu(this.ut);return}if(Number.isFinite(t)){this.date=new Date(Bu.getTime()+t*e),this.ut=t,this.tt=Gu(this.ut);return}throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(t){let e=new Fs(t);for(;;){const n=t-e.tt;if(Math.abs(n)<1e-12)return e;e=e.AddDays(n)}}toString(){return this.date.toISOString()}AddDays(t){return new Fs(this.ut+t)}}function Le(i){return i instanceof Fs?i:new Fs(i)}function dx(i){function t(d){return d%ex*Rs}const e=i.tt/36525,n=t(128710479305e-5+e*1295965810481e-4),s=t(335779.526232+e*17395272628478e-4),r=t(107226070369e-5+e*1602961601209e-3),a=t(450160.398036-e*69628905431e-4);let o=Math.sin(a),c=Math.cos(a),l=(-172064161-174666*e)*o+33386*c,h=(92052331+9086*e)*c+15377*o,u=2*(s-r+a);return o=Math.sin(u),c=Math.cos(u),l+=(-13170906-1675*e)*o-13696*c,h+=(5730336-3015*e)*c-4587*o,u=2*(s+a),o=Math.sin(u),c=Math.cos(u),l+=(-2276413-234*e)*o+2796*c,h+=(978459-485*e)*c+1374*o,u=2*a,o=Math.sin(u),c=Math.cos(u),l+=(2074554+207*e)*o-698*c,h+=(-897492+470*e)*c-291*o,o=Math.sin(n),c=Math.cos(n),l+=(1475877-3633*e)*o+11817*c,h+=(73871-184*e)*c-1924*o,{dpsi:-135e-6+l*1e-7,deps:388e-6+h*1e-7}}function Rd(i){var t=i.tt/36525,e=((((-434e-10*t-576e-9)*t+.0020034)*t-1831e-7)*t-46.836769)*t+84381.406;return e/3600}var ha;function Rr(i){if(!ha||Math.abs(ha.tt-i.tt)>1e-6){const t=dx(i),e=Rd(i),n=e+t.deps/3600;ha={tt:i.tt,dpsi:t.dpsi,deps:t.deps,ee:t.dpsi*Math.cos(e*ee)/15,mobl:e,tobl:n}}return ha}function fx(i,t){const e=i*ee,n=Math.cos(e),s=Math.sin(e);return[t[0],t[1]*n-t[2]*s,t[1]*s+t[2]*n]}function px(i,t){return fx(Rd(i),t)}function mx(i){const t=i.tt/36525;function e(Tt,vt){const It=[];let Lt;for(Lt=0;Lt<=vt-Tt;++Lt)It.push(0);return{min:Tt,array:It}}function n(Tt,vt,It,Lt){const Nt=[];for(let Jt=0;Jt<=vt-Tt;++Jt)Nt.push(e(It,Lt));return{min:Tt,array:Nt}}function s(Tt,vt,It){const Lt=Tt.array[vt-Tt.min];return Lt.array[It-Lt.min]}function r(Tt,vt,It,Lt){const Nt=Tt.array[vt-Tt.min];Nt.array[It-Nt.min]=Lt}let a,o,c,l,h,u,d,f,g,x,m,p,A,T,M,y,b,R,v,E,D,C,I,W=n(-6,6,1,4),X=n(-6,6,1,4);function U(Tt,vt){return s(W,Tt,vt)}function q(Tt,vt){return s(X,Tt,vt)}function H(Tt,vt,It){return r(W,Tt,vt,It)}function $(Tt,vt,It){return r(X,Tt,vt,It)}function et(Tt,vt,It,Lt,Nt){Nt(Tt*It-vt*Lt,vt*It+Tt*Lt)}function j(Tt){return Math.sin(ti*Tt)}d=t*t,g=0,I=0,m=0,p=3422.7;var it=j(.19833+.05611*t),ut=j(.27869+.04508*t),kt=j(.16827-.36903*t),qt=j(.34734-5.37261*t),Bt=j(.10498-5.37899*t),Y=j(.42681-.41855*t),rt=j(.14943-5.37511*t);for(R=.84*it+.31*ut+14.27*kt+7.26*qt+.28*Bt+.24*Y,v=2.94*it+.31*ut+14.27*kt+9.34*qt+1.12*Bt+.83*Y,E=-6.4*it-1.89*Y,D=.21*it+.31*ut+14.27*kt-88.7*qt-15.3*Bt+.24*Y-1.86*rt,C=R-E,f=-3332e-9*j(.59734-5.37261*t)-539e-9*j(.35498-5.37899*t)-64e-9*j(.39943-5.37511*t),A=ti*ys(.60643382+1336.85522467*t-313e-8*d)+R/xi,T=ti*ys(.37489701+1325.55240982*t+2565e-8*d)+v/xi,M=ti*ys(.99312619+99.99735956*t-44e-8*d)+E/xi,y=ti*ys(.25909118+1342.2278298*t-892e-8*d)+D/xi,b=ti*ys(.82736186+1236.85308708*t-397e-8*d)+C/xi,h=1;h<=4;++h){switch(h){case 1:c=T,o=4,l=1.000002208;break;case 2:c=M,o=3,l=.997504612-.002495388*t;break;case 3:c=y,o=4,l=1.000002708+139.978*f;break;case 4:c=b,o=6,l=1;break;default:throw`Internal error: I = ${h}`}for(H(0,h,1),H(1,h,Math.cos(c)*l),$(0,h,0),$(1,h,Math.sin(c)*l),u=2;u<=o;++u)et(U(u-1,h),q(u-1,h),U(1,h),q(1,h),(Tt,vt)=>(H(u,h,Tt),$(u,h,vt)));for(u=1;u<=o;++u)H(-u,h,U(u,h)),$(-u,h,-q(u,h))}function nt(Tt,vt,It,Lt){for(var Nt={x:1,y:0},Jt=[0,Tt,vt,It,Lt],Qt=1;Qt<=4;++Qt)Jt[Qt]!==0&&et(Nt.x,Nt.y,U(Jt[Qt],Qt),q(Jt[Qt],Qt),(me,de)=>(Nt.x=me,Nt.y=de));return Nt}function z(Tt,vt,It,Lt,Nt,Jt,Qt,me){var de=nt(Nt,Jt,Qt,me);g+=Tt*de.y,I+=vt*de.y,m+=It*de.x,p+=Lt*de.x}z(13.902,14.06,-.001,.2607,0,0,0,4),z(.403,-4.01,.394,.0023,0,0,0,3),z(2369.912,2373.36,.601,28.2333,0,0,0,2),z(-125.154,-112.79,-.725,-.9781,0,0,0,1),z(1.979,6.98,-.445,.0433,1,0,0,4),z(191.953,192.72,.029,3.0861,1,0,0,2),z(-8.466,-13.51,.455,-.1093,1,0,0,1),z(22639.5,22609.07,.079,186.5398,1,0,0,0),z(18.609,3.59,-.094,.0118,1,0,0,-1),z(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),z(3.215,5.44,.192,-.0386,1,0,0,-3),z(-38.428,-38.64,.001,.6008,1,0,0,-4),z(-.393,-1.43,-.092,.0086,1,0,0,-6),z(-.289,-1.59,.123,-.0053,0,1,0,4),z(-24.42,-25.1,.04,-.3,0,1,0,2),z(18.023,17.93,.007,.1494,0,1,0,1),z(-668.146,-126.98,-1.302,-.3997,0,1,0,0),z(.56,.32,-.001,-.0037,0,1,0,-1),z(-165.145,-165.06,.054,1.9178,0,1,0,-2),z(-1.877,-6.46,-.416,.0339,0,1,0,-4),z(.213,1.02,-.074,.0054,2,0,0,4),z(14.387,14.78,-.017,.2833,2,0,0,2),z(-.586,-1.2,.054,-.01,2,0,0,1),z(769.016,767.96,.107,10.1657,2,0,0,0),z(1.75,2.01,-.018,.0155,2,0,0,-1),z(-211.656,-152.53,5.679,-.3039,2,0,0,-2),z(1.225,.91,-.03,-.0088,2,0,0,-3),z(-30.773,-34.07,-.308,.3722,2,0,0,-4),z(-.57,-1.4,-.074,.0109,2,0,0,-6),z(-2.921,-11.75,.787,-.0484,1,1,0,2),z(1.267,1.52,-.022,.0164,1,1,0,1),z(-109.673,-115.18,.461,-.949,1,1,0,0),z(-205.962,-182.36,2.056,1.4437,1,1,0,-2),z(.233,.36,.012,-.0025,1,1,0,-3),z(-4.391,-9.66,-.471,.0673,1,1,0,-4),z(.283,1.53,-.111,.006,1,-1,0,4),z(14.577,31.7,-1.54,.2302,1,-1,0,2),z(147.687,138.76,.679,1.1528,1,-1,0,0),z(-1.089,.55,.021,0,1,-1,0,-1),z(28.475,23.59,-.443,-.2257,1,-1,0,-2),z(-.276,-.38,-.006,-.0036,1,-1,0,-3),z(.636,2.27,.146,-.0102,1,-1,0,-4),z(-.189,-1.68,.131,-.0028,0,2,0,2),z(-7.486,-.66,-.037,-.0086,0,2,0,0),z(-8.096,-16.35,-.74,.0918,0,2,0,-2),z(-5.741,-.04,0,-9e-4,0,0,2,2),z(.255,0,0,0,0,0,2,1),z(-411.608,-.2,0,-.0124,0,0,2,0),z(.584,.84,0,.0071,0,0,2,-1),z(-55.173,-52.14,0,-.1052,0,0,2,-2),z(.254,.25,0,-.0017,0,0,2,-3),z(.025,-1.67,0,.0031,0,0,2,-4),z(1.06,2.96,-.166,.0243,3,0,0,2),z(36.124,50.64,-1.3,.6215,3,0,0,0),z(-13.193,-16.4,.258,-.1187,3,0,0,-2),z(-1.187,-.74,.042,.0074,3,0,0,-4),z(-.293,-.31,-.002,.0046,3,0,0,-6),z(-.29,-1.45,.116,-.0051,2,1,0,2),z(-7.649,-10.56,.259,-.1038,2,1,0,0),z(-8.627,-7.59,.078,-.0192,2,1,0,-2),z(-2.74,-2.54,.022,.0324,2,1,0,-4),z(1.181,3.32,-.212,.0213,2,-1,0,2),z(9.703,11.67,-.151,.1268,2,-1,0,0),z(-.352,-.37,.001,-.0028,2,-1,0,-1),z(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),z(.36,.2,-.012,-.0043,2,-1,0,-4),z(-1.167,-1.25,.008,-.0106,1,2,0,0),z(-7.412,-6.12,.117,.0484,1,2,0,-2),z(-.311,-.65,-.032,.0044,1,2,0,-4),z(.757,1.82,-.105,.0112,1,-2,0,2),z(2.58,2.32,.027,.0196,1,-2,0,0),z(2.533,2.4,-.014,-.0212,1,-2,0,-2),z(-.344,-.57,-.025,.0036,0,3,0,-2),z(-.992,-.02,0,0,1,0,2,2),z(-45.099,-.02,0,-.001,1,0,2,0),z(-.179,-9.52,0,-.0833,1,0,2,-2),z(-.301,-.33,0,.0014,1,0,2,-4),z(-6.382,-3.37,0,-.0481,1,0,-2,2),z(39.528,85.13,0,-.7136,1,0,-2,0),z(9.366,.71,0,-.0112,1,0,-2,-2),z(.202,.02,0,0,1,0,-2,-4),z(.415,.1,0,.0013,0,1,2,0),z(-2.152,-2.26,0,-.0066,0,1,2,-2),z(-1.44,-1.3,0,.0014,0,1,-2,2),z(.384,-.04,0,0,0,1,-2,-2),z(1.938,3.6,-.145,.0401,4,0,0,0),z(-.952,-1.58,.052,-.013,4,0,0,-2),z(-.551,-.94,.032,-.0097,3,1,0,0),z(-.482,-.57,.005,-.0045,3,1,0,-2),z(.681,.96,-.026,.0115,3,-1,0,0),z(-.297,-.27,.002,-9e-4,2,2,0,-2),z(.254,.21,-.003,0,2,-2,0,-2),z(-.25,-.22,.004,.0014,1,3,0,-2),z(-3.996,0,0,4e-4,2,0,2,0),z(.557,-.75,0,-.009,2,0,2,-2),z(-.459,-.38,0,-.0053,2,0,-2,2),z(-1.298,.74,0,4e-4,2,0,-2,0),z(.538,1.14,0,-.0141,2,0,-2,-2),z(.263,.02,0,0,1,1,2,0),z(.426,.07,0,-6e-4,1,1,-2,-2),z(-.304,.03,0,3e-4,1,-1,2,0),z(-.372,-.19,0,-.0027,1,-1,-2,2),z(.418,0,0,0,0,0,4,0),z(-.33,-.04,0,0,3,0,2,0);function bt(Tt,vt,It,Lt,Nt){return Tt*nt(vt,It,Lt,Nt).y}x=0,x+=bt(-526.069,0,0,1,-2),x+=bt(-3.352,0,0,1,-4),x+=bt(44.297,1,0,1,-2),x+=bt(-6,1,0,1,-4),x+=bt(20.599,-1,0,1,0),x+=bt(-30.598,-1,0,1,-2),x+=bt(-24.649,-2,0,1,0),x+=bt(-2,-2,0,1,-2),x+=bt(-22.571,0,1,1,-2),x+=bt(10.985,0,-1,1,-2),g+=.82*j(.7736-62.5512*t)+.31*j(.0466-125.1025*t)+.35*j(.5785-25.1042*t)+.66*j(.4591+1335.8075*t)+.64*j(.313-91.568*t)+1.14*j(.148+1331.2898*t)+.21*j(.5918+1056.5859*t)+.44*j(.5784+1322.8595*t)+.24*j(.2275-5.7374*t)+.28*j(.2965+2.6929*t)+.33*j(.3132+6.3368*t),a=y+I/xi;let Dt=(1.000002708+139.978*f)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+x;return{geo_eclip_lon:ti*ys((A+g/xi)/ti),geo_eclip_lat:Math.PI/(180*3600)*Dt,distance_au:xi*rx/(.999953253*p)}}function Cd(i,t){return[i.rot[0][0]*t[0]+i.rot[1][0]*t[1]+i.rot[2][0]*t[2],i.rot[0][1]*t[0]+i.rot[1][1]*t[1]+i.rot[2][1]*t[2],i.rot[0][2]*t[0]+i.rot[1][2]*t[1]+i.rot[2][2]*t[2]]}function Wa(i,t,e){const n=Dd(t,e);return Cd(n,i)}function Dd(i,t){const e=i.tt/36525;let n=84381.406,s=((((-951e-10*e+132851e-9)*e-.00114045)*e-1.0790069)*e+5038.481507)*e,r=((((3337e-10*e-467e-9)*e-.00772503)*e+.0512623)*e-.025754)*e+n,a=((((-56e-9*e+170663e-9)*e-.00121197)*e-2.3814292)*e+10.556403)*e;n*=Rs,s*=Rs,r*=Rs,a*=Rs;const o=Math.sin(n),c=Math.cos(n),l=Math.sin(-s),h=Math.cos(-s),u=Math.sin(-r),d=Math.cos(-r),f=Math.sin(a),g=Math.cos(a),x=g*h-l*f*d,m=g*l*c+f*d*h*c-o*f*u,p=g*l*o+f*d*h*o+c*f*u,A=-f*h-l*g*d,T=-f*l*c+g*d*h*c-o*g*u,M=-f*l*o+g*d*h*o+c*g*u,y=l*u,b=-u*h*c-o*d,R=-u*h*o+d*c;if(t===$e.Into2000)return new Di([[x,m,p],[A,T,M],[y,b,R]]);if(t===$e.From2000)return new Di([[x,A,y],[m,T,b],[p,M,R]]);throw"Invalid precess direction"}function gx(i){const t=.779057273264+.00273781191135448*i.ut,e=i.ut%1;let n=360*((t+e)%1);return n<0&&(n+=360),n}let ua;function nh(i){if(!ua||ua.tt!==i.tt){const t=i.tt/36525;let e=15*Rr(i).ee;const n=gx(i);let r=((e+.014506+((((-368e-10*t-29956e-9)*t-44e-8)*t+1.3915817)*t+4612.156534)*t)/3600+n)%360/15;r<0&&(r+=24),ua={tt:i.tt,st:r}}return ua.st}function Pd(i,t){const e=i.latitude*ee,n=Math.sin(e),s=Math.cos(e),r=1/Math.hypot(s,ul*n),a=sx*r,o=i.height/1e3,c=dl*r+o,l=dl*a+o,h=(15*t+i.longitude)*ee,u=Math.sin(h),d=Math.cos(h);return{pos:[c*s*d/Vi,c*s*u/Vi,l*n/Vi],vel:[-ku*c*s*u*86400/Vi,ku*c*s*d*86400/Vi,0]}}function _l(i,t,e){const n=Id(t,e);return Cd(n,i)}function Id(i,t){const e=Rr(i),n=e.mobl*ee,s=e.tobl*ee,r=e.dpsi*Rs,a=Math.cos(n),o=Math.sin(n),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),u=Math.sin(r),d=h,f=-u*a,g=-u*o,x=u*c,m=h*a*c+o*l,p=h*o*c-a*l,A=u*l,T=h*a*l-o*c,M=h*o*l+a*c;if(t===$e.From2000)return new Di([[d,x,A],[f,m,T],[g,p,M]]);if(t===$e.Into2000)return new Di([[d,f,g],[x,m,p],[A,T,M]]);throw"Invalid precess direction"}function ih(i,t,e){return e===$e.Into2000?Wa(_l(i,t,e),t,e):_l(Wa(i,t,e),t,e)}function _x(i,t){const e=nh(i),n=Pd(t,e).pos;return ih(n,i,$e.Into2000)}class ue{constructor(t,e,n,s){this.x=t,this.y=e,this.z=n,this.t=s}Length(){return Math.hypot(this.x,this.y,this.z)}}class bi{constructor(t,e,n,s,r,a,o){this.x=t,this.y=e,this.z=n,this.vx=s,this.vy=r,this.vz=a,this.t=o}}class sh{constructor(t,e,n){this.lat=ze(t),this.lon=ze(e),this.dist=ze(n)}}class vl{constructor(t,e,n,s){this.ra=ze(t),this.dec=ze(e),this.dist=ze(n),this.vec=s}}class Di{constructor(t){this.rot=t}}class vx{constructor(t,e,n,s){this.azimuth=ze(t),this.altitude=ze(e),this.ra=ze(n),this.dec=ze(s)}}class xx{constructor(t,e,n){this.vec=t,this.elat=ze(e),this.elon=ze(n)}}function Ld(i,t){return new ue(i[0],i[1],i[2],t)}function Mx(i,t){const e=Ld(i,t),n=e.x*e.x+e.y*e.y,s=Math.sqrt(n+e.z*e.z);if(n===0){if(e.z===0)throw"Indeterminate sky coordinates";return new vl(0,e.z<0?-90:90,s,e)}let r=Ad*Math.atan2(e.y,e.x);r<0&&(r+=24);const a=Yn*Math.atan2(i[2],Math.sqrt(n));return new vl(r,a,s,e)}function $o(i,t){const e=i*ee,n=Math.cos(e),s=Math.sin(e);return[n*t[0]+s*t[1],n*t[1]-s*t[0],t[2]]}function Nd(i,t,e,n,s){let r=Le(i);rh(t),ze(e),ze(n);const a=Math.sin(t.latitude*ee),o=Math.cos(t.latitude*ee),c=Math.sin(t.longitude*ee),l=Math.cos(t.longitude*ee),h=Math.sin(n*ee),u=Math.cos(n*ee),d=Math.sin(e*zu),f=Math.cos(e*zu);let g=[o*l,o*c,a],x=[-a*l,-a*c,o],m=[c,-l,0];const p=-15*nh(r);let A=$o(p,g),T=$o(p,x),M=$o(p,m),y=[u*f,u*d,h];const b=y[0]*A[0]+y[1]*A[1]+y[2]*A[2],R=y[0]*T[0]+y[1]*T[1]+y[2]*T[2],v=y[0]*M[0]+y[1]*M[1]+y[2]*M[2];let E=Math.hypot(R,v),D;E>0?(D=-Yn*Math.atan2(v,R),D<0&&(D+=360)):D=0;let C=Yn*Math.atan2(E,b),I=e,W=n;{let X=C,U=Wx(s,90-C);if(C-=U,U>0&&C>3e-4){const q=Math.sin(C*ee),H=Math.cos(C*ee),$=Math.sin(X*ee),et=Math.cos(X*ee),j=[];for(let it=0;it<3;++it)j.push((y[it]-et*A[it])/$*q+A[it]*H);E=Math.hypot(j[0],j[1]),E>0?(I=Ad*Math.atan2(j[1],j[0]),I<0&&(I+=24)):I=0,W=Yn*Math.atan2(j[2],E)}}return new vx(D,90-C,I,W)}function rh(i){if(!(i instanceof ah))throw`Not an instance of the Observer class: ${i}`;if(ze(i.latitude),ze(i.longitude),ze(i.height),i.latitude<-90||i.latitude>90)throw`Latitude ${i.latitude} is out of range. Must be -90..+90.`;return i}class ah{constructor(t,e,n){this.latitude=t,this.longitude=e,this.height=n,rh(this)}}function Sx(i){const t=Le(i).AddDays(-1/jl),e=zs(Xn.Earth,t),n=[-e.x,-e.y,-e.z],[s,r,a]=ih(n,t,$e.From2000),o=ee*Rr(t).tobl,c=Math.cos(o),l=Math.sin(o),h=new ue(s,r,a,t);return Ud(h,c,l)}function yx(i,t,e,n,s){rh(e),Va(n),Va(s);const r=Le(t),a=_x(r,e),o=Rl(i,r,s),c=[o.x-a[0],o.y-a[1],o.z-a[2]],l=ih(c,r,$e.From2000);return Mx(l,r)}function Ex(i,t,e){const n=Le(i),s=nh(n);let r=Pd(t,s).pos;return Ld(r,n)}function Ud(i,t,e){const n=i.x,s=i.y*t+i.z*e,r=-i.y*e+i.z*t,a=Math.hypot(n,s);let o=0;a>0&&(o=Yn*Math.atan2(s,n),o<0&&(o+=360));let c=Yn*Math.atan2(r,a),l=new ue(n,s,r,i.t);return new xx(l,c,o)}function xl(i){const t=Rr(i.t),e=[i.x,i.y,i.z],n=Wa(e,i.t,$e.From2000),[s,r,a]=_l(n,i.t,$e.From2000),o=new ue(s,r,a,i.t),c=t.tobl*ee;return Ud(o,Math.cos(c),Math.sin(c))}function Ws(i){const t=Le(i),e=mx(t),n=e.distance_au*Math.cos(e.geo_eclip_lat),s=[n*Math.cos(e.geo_eclip_lon),n*Math.sin(e.geo_eclip_lon),e.distance_au*Math.sin(e.geo_eclip_lat)],r=px(t,s),a=Wa(r,t,$e.Into2000);return new ue(a[0],a[1],a[2],t)}function Fd(i){const t=Le(i),e=1e-5,n=t.AddDays(-e),s=t.AddDays(+e),r=Ws(n),a=Ws(s);return new bi((r.x+a.x)/2,(r.y+a.y)/2,(r.z+a.z)/2,(a.x-r.x)/(2*e),(a.y-r.y)/(2*e),(a.z-r.z)/(2*e),t)}function bx(i){const t=Le(i),e=Fd(t),n=1+wd;return new bi(e.x/n,e.y/n,e.z/n,e.vx/n,e.vy/n,e.vz/n,t)}function Os(i,t,e){let n=1,s=0;for(let r of i){let a=0;for(let[c,l,h]of r)a+=c*Math.cos(l+t*h);let o=n*a;e&&(o%=ti),s+=o,n*=t}return s}function Jo(i,t){let e=1,n=0,s=0,r=0;for(let a of i){let o=0,c=0;for(let[l,h,u]of a){let d=h+t*u;o+=l*u*Math.sin(d),r>0&&(c+=l*Math.cos(d))}s+=r*n*c-e*o,n=e,e*=t,++r}return s}const dr=365250,Ml=0,Sl=1,yl=2;function El(i){return new We(i[0]+44036e-11*i[1]-190919e-12*i[2],-479966e-12*i[0]+.917482137087*i[1]-.397776982902*i[2],.397776982902*i[1]+.917482137087*i[2])}function Od(i,t,e){const n=e*Math.cos(t),s=Math.cos(i),r=Math.sin(i);return[n*s,n*r,e*Math.sin(t)]}function zs(i,t){const e=t.tt/dr,n=Os(i[Ml],e,!0),s=Os(i[Sl],e,!1),r=Os(i[yl],e,!1),a=Od(n,s,r);return El(a).ToAstroVector(t)}function bl(i,t){const e=t/dr,n=Os(i[Ml],e,!0),s=Os(i[Sl],e,!1),r=Os(i[yl],e,!1),a=Jo(i[Ml],e),o=Jo(i[Sl],e),c=Jo(i[yl],e),l=Math.cos(n),h=Math.sin(n),u=Math.cos(s),d=Math.sin(s),f=+(c*u*l)-r*d*l*o-r*u*h*a,g=+(c*u*h)-r*d*h*o+r*u*l*a,x=+(c*d)+r*u*o,m=Od(n,s,r),p=[f/dr,g/dr,x/dr],A=El(m),T=El(p);return new Qi(t,A,T)}function da(i,t,e,n){const s=n/(n+th),r=zs(Xn[e],t);i.x+=s*r.x,i.y+=s*r.y,i.z+=s*r.z}function Ax(i){const t=new ue(0,0,0,i);return da(t,i,yt.Jupiter,fl),da(t,i,yt.Saturn,pl),da(t,i,yt.Uranus,ml),da(t,i,yt.Neptune,gl),t}const Al=51,Tx=29200,Cs=146,ei=201,Yi=[[-73e4,[-26.118207232108,-14.376168177825,3.384402515299],[.0016339372163656,-.0027861699588508,-.0013585880229445]],[-700800,[41.974905202127,-.448502952929,-12.770351505989],[.00073458569351457,.0022785014891658,.00048619778602049]],[-671600,[14.706930780744,44.269110540027,9.353698474772],[-.00210001479998,.00022295915939915,.00070143443551414]],[-642400,[-29.441003929957,-6.43016153057,6.858481011305],[.00084495803960544,-.0030783914758711,-.0012106305981192]],[-613200,[39.444396946234,-6.557989760571,-13.913760296463],[.0011480029005873,.0022400006880665,.00035168075922288]],[-584e3,[20.2303809507,43.266966657189,7.382966091923],[-.0019754081700585,.00053457141292226,.00075929169129793]],[-554800,[-30.65832536462,2.093818874552,9.880531138071],[61010603013347e-18,-.0031326500935382,-.00099346125151067]],[-525600,[35.737703251673,-12.587706024764,-14.677847247563],[.0015802939375649,.0021347678412429,.00019074436384343]],[-496400,[25.466295188546,41.367478338417,5.216476873382],[-.0018054401046468,.0008328308359951,.00080260156912107]],[-467200,[-29.847174904071,10.636426313081,12.297904180106],[-.00063257063052907,-.0029969577578221,-.00074476074151596]],[-438e3,[30.774692107687,-18.236637015304,-14.945535879896],[.0020113162005465,.0019353827024189,-20937793168297e-19]],[-408800,[30.243153324028,38.656267888503,2.938501750218],[-.0016052508674468,.0011183495337525,.00083333973416824]],[-379600,[-27.288984772533,18.643162147874,14.023633623329],[-.0011856388898191,-.0027170609282181,-.00049015526126399]],[-350400,[24.519605196774,-23.245756064727,-14.626862367368],[.0024322321483154,.0016062008146048,-.00023369181613312]],[-321200,[34.505274805875,35.125338586954,.557361475637],[-.0013824391637782,.0013833397561817,.00084823598806262]],[-292e3,[-23.275363915119,25.818514298769,15.055381588598],[-.0016062295460975,-.0023395961498533,-.00024377362639479]],[-262800,[17.050384798092,-27.180376290126,-13.608963321694],[.0028175521080578,.0011358749093955,-.00049548725258825]],[-233600,[38.093671910285,30.880588383337,-1.843688067413],[-.0011317697153459,.0016128814698472,.00084177586176055]],[-204400,[-18.197852930878,31.932869934309,15.438294826279],[-.0019117272501813,-.0019146495909842,-19657304369835e-18]],[-175200,[8.528924039997,-29.618422200048,-11.805400994258],[.0031034370787005,.0005139363329243,-.00077293066202546]],[-146e3,[40.94685725864,25.904973592021,-4.256336240499],[-.00083652705194051,.0018129497136404,.0008156422827306]],[-116800,[-12.326958895325,36.881883446292,15.217158258711],[-.0021166103705038,-.001481442003599,.00017401209844705]],[-87600,[-.633258375909,-30.018759794709,-9.17193287495],[.0032016994581737,-.00025279858672148,-.0010411088271861]],[-58400,[42.936048423883,20.344685584452,-6.588027007912],[-.00050525450073192,.0019910074335507,.00077440196540269]],[-29200,[-5.975910552974,40.61180995846,14.470131723673],[-.0022184202156107,-.0010562361130164,.00033652250216211]],[0,[-9.875369580774,-27.978926224737,-5.753711824704],[.0030287533248818,-.0011276087003636,-.0012651326732361]],[29200,[43.958831986165,14.214147973292,-8.808306227163],[-.00014717608981871,.0021404187242141,.00071486567806614]],[58400,[.67813676352,43.094461639362,13.243238780721],[-.0022358226110718,-.00063233636090933,.00047664798895648]],[87600,[-18.282602096834,-23.30503958666,-1.766620508028],[.0025567245263557,-.0019902940754171,-.0013943491701082]],[116800,[43.873338744526,7.700705617215,-10.814273666425],[.00023174803055677,.0022402163127924,.00062988756452032]],[146e3,[7.392949027906,44.382678951534,11.629500214854],[-.002193281545383,-.00021751799585364,.00059556516201114]],[175200,[-24.981690229261,-16.204012851426,2.466457544298],[.001819398914958,-.0026765419531201,-.0013848283502247]],[204400,[42.530187039511,.845935508021,-12.554907527683],[.00065059779150669,.0022725657282262,.00051133743202822]],[233600,[13.999526486822,44.462363044894,9.669418486465],[-.0021079296569252,.00017533423831993,.00069128485798076]],[262800,[-29.184024803031,-7.371243995762,6.493275957928],[.00093581363109681,-.0030610357109184,-.0012364201089345]],[292e3,[39.831980671753,-6.078405766765,-13.909815358656],[.0011117769689167,.0022362097830152,.00036230548231153]],[321200,[20.294955108476,43.417190420251,7.450091985932],[-.0019742157451535,.00053102050468554,.00075938408813008]],[350400,[-30.66999230216,2.318743558955,9.973480913858],[45605107450676e-18,-.0031308219926928,-.00099066533301924]],[379600,[35.626122155983,-12.897647509224,-14.777586508444],[.0016015684949743,.0021171931182284,.00018002516202204]],[408800,[26.133186148561,41.232139187599,5.00640132622],[-.0017857704419579,.00086046232702817,.00080614690298954]],[438e3,[-29.57674022923,11.863535943587,12.631323039872],[-.00072292830060955,-.0029587820140709,-.000708242964503]],[467200,[29.910805787391,-19.159019294,-15.013363865194],[.0020871080437997,.0018848372554514,-38528655083926e-18]],[496400,[31.375957451819,38.050372720763,2.433138343754],[-.0015546055556611,.0011699815465629,.00083565439266001]],[525600,[-26.360071336928,20.662505904952,14.414696258958],[-.0013142373118349,-.0026236647854842,-.00042542017598193]],[554800,[22.599441488648,-24.508879898306,-14.484045731468],[.0025454108304806,.0014917058755191,-.00030243665086079]],[584e3,[35.877864013014,33.894226366071,-.224524636277],[-.0012941245730845,.0014560427668319,.00084762160640137]],[613200,[-21.538149762417,28.204068269761,15.321973799534],[-.001731211740901,-.0021939631314577,-.0001631691327518]],[642400,[13.971521374415,-28.339941764789,-13.083792871886],[.0029334630526035,.00091860931752944,-.00059939422488627]],[671600,[39.526942044143,28.93989736011,-2.872799527539],[-.0010068481658095,.001702113288809,.00083578230511981]],[700800,[-15.576200701394,34.399412961275,15.466033737854],[-.0020098814612884,-.0017191109825989,70414782780416e-18]],[73e4,[4.24325283709,-30.118201690825,-10.707441231349],[.0031725847067411,.0001609846120227,-.00090672150593868]]];class We{constructor(t,e,n){this.x=t,this.y=e,this.z=n}clone(){return new We(this.x,this.y,this.z)}ToAstroVector(t){return new ue(this.x,this.y,this.z,t)}static zero(){return new We(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(t){return new We(this.x+t.x,this.y+t.y,this.z+t.z)}sub(t){return new We(this.x-t.x,this.y-t.y,this.z-t.z)}incr(t){this.x+=t.x,this.y+=t.y,this.z+=t.z}decr(t){this.x-=t.x,this.y-=t.y,this.z-=t.z}mul(t){return new We(t*this.x,t*this.y,t*this.z)}div(t){return new We(this.x/t,this.y/t,this.z/t)}mean(t){return new We((this.x+t.x)/2,(this.y+t.y)/2,(this.z+t.z)/2)}neg(){return new We(-this.x,-this.y,-this.z)}}class Qi{constructor(t,e,n){this.tt=t,this.r=e,this.v=n}clone(){return new Qi(this.tt,this.r,this.v)}sub(t){return new Qi(this.tt,this.r.sub(t.r),this.v.sub(t.v))}}function wx(i){let[t,[e,n,s],[r,a,o]]=i;return new Qi(t,new We(e,n,s),new We(r,a,o))}function fa(i,t,e,n){const s=n/(n+th),r=bl(Xn[e],t);return i.r.incr(r.r.mul(s)),i.v.incr(r.v.mul(s)),r}function rr(i,t,e){const n=e.sub(i),s=n.quadrature();return n.mul(t/(s*Math.sqrt(s)))}class so{constructor(t){let e=new Qi(t,new We(0,0,0),new We(0,0,0));this.Jupiter=fa(e,t,yt.Jupiter,fl),this.Saturn=fa(e,t,yt.Saturn,pl),this.Uranus=fa(e,t,yt.Uranus,ml),this.Neptune=fa(e,t,yt.Neptune,gl),this.Jupiter.r.decr(e.r),this.Jupiter.v.decr(e.v),this.Saturn.r.decr(e.r),this.Saturn.v.decr(e.v),this.Uranus.r.decr(e.r),this.Uranus.v.decr(e.v),this.Neptune.r.decr(e.r),this.Neptune.v.decr(e.v),this.Sun=new Qi(t,e.r.mul(-1),e.v.mul(-1))}Acceleration(t){let e=rr(t,th,this.Sun.r);return e.incr(rr(t,fl,this.Jupiter.r)),e.incr(rr(t,pl,this.Saturn.r)),e.incr(rr(t,ml,this.Uranus.r)),e.incr(rr(t,gl,this.Neptune.r)),e}}class ro{constructor(t,e,n,s){this.tt=t,this.r=e,this.v=n,this.a=s}clone(){return new ro(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class zd{constructor(t,e){this.bary=t,this.grav=e}}function Xa(i,t,e,n){return new We(t.x+i*(e.x+i*n.x/2),t.y+i*(e.y+i*n.y/2),t.z+i*(e.z+i*n.z/2))}function Hu(i,t,e){return new We(t.x+i*e.x,t.y+i*e.y,t.z+i*e.z)}function Tl(i,t){const e=i-t.tt,n=new so(i),s=Xa(e,t.r,t.v,t.a),r=n.Acceleration(s).mean(t.a),a=Xa(e,t.r,t.v,r),o=t.v.add(r.mul(e)),c=n.Acceleration(a),l=new ro(i,a,o,c);return new zd(n,l)}const Rx=[];function Bd(i,t){const e=Math.floor(i);return e<0?0:e>=t?t-1:e}function wl(i){const t=wx(i),e=new so(t.tt),n=t.r.add(e.Sun.r),s=t.v.add(e.Sun.v),r=e.Acceleration(n),a=new ro(t.tt,n,s,r);return new zd(e,a)}function Cx(i,t){const e=Yi[0][0];if(t<e||t>Yi[Al-1][0])return null;const n=Bd((t-e)/Tx,Al-1);if(!i[n]){const r=i[n]=[];r[0]=wl(Yi[n]).grav,r[ei-1]=wl(Yi[n+1]).grav;let a,o=r[0].tt;for(a=1;a<ei-1;++a)r[a]=Tl(o+=Cs,r[a-1]).grav;o=r[ei-1].tt;var s=[];for(s[ei-1]=r[ei-1],a=ei-2;a>0;--a)s[a]=Tl(o-=Cs,s[a+1]).grav;for(a=ei-2;a>0;--a){const c=a/(ei-1);r[a].r=r[a].r.mul(1-c).add(s[a].r.mul(c)),r[a].v=r[a].v.mul(1-c).add(s[a].v.mul(c)),r[a].a=r[a].a.mul(1-c).add(s[a].a.mul(c))}}return i[n]}function Vu(i,t,e){let n=wl(i);const s=Math.ceil((t-n.grav.tt)/e);for(let r=0;r<s;++r)n=Tl(r+1===s?t:n.grav.tt+e,n.grav);return n}function kd(i,t){let e,n,s;const r=Cx(Rx,i.tt);if(r){const a=Bd((i.tt-r[0].tt)/Cs,ei-1),o=r[a],c=r[a+1],l=o.a.mean(c.a),h=Xa(i.tt-o.tt,o.r,o.v,l),u=Hu(i.tt-o.tt,o.v,l),d=Xa(i.tt-c.tt,c.r,c.v,l),f=Hu(i.tt-c.tt,c.v,l),g=(i.tt-o.tt)/Cs;e=h.mul(1-g).add(d.mul(g)),n=u.mul(1-g).add(f.mul(g))}else{let a;i.tt<Yi[0][0]?a=Vu(Yi[0],i.tt,-Cs):a=Vu(Yi[Al-1],i.tt,+Cs),e=a.grav.r,n=a.grav.v,s=a.bary}return s||(s=new so(i.tt)),e=e.sub(s.Sun.r),n=n.sub(s.Sun.v),new bi(e.x,e.y,e.z,n.x,n.y,n.z,i)}function Ti(i,t){var e=Le(t);if(i in Xn)return zs(Xn[i],e);if(i===yt.Pluto){const a=kd(e);return new ue(a.x,a.y,a.z,e)}if(i===yt.Sun)return new ue(0,0,0,e);if(i===yt.Moon){var n=zs(Xn.Earth,e),s=Ws(e);return new ue(n.x+s.x,n.y+s.y,n.z+s.z,e)}if(i===yt.EMB){const a=zs(Xn.Earth,e),o=Ws(e),c=1+wd;return new ue(a.x+o.x/c,a.y+o.y/c,a.z+o.z/c,e)}if(i===yt.SSB)return Ax(e);const r=eh(i);if(r){const a=new sh(r.dec,15*r.ra,r.dist);return Hd(a,e)}throw`HelioVector: Unknown body "${i}"`}function Dx(i,t){let e=t,n=0;for(let s=0;s<10;++s){const r=i(e),a=r.Length()/jl;if(a>1)throw"Object is too distant for light-travel solver.";const o=t.AddDays(-a);if(n=Math.abs(o.tt-e.tt),n<1e-9)return r;e=o}throw`Light-travel time solver did not converge: dt = ${n}`}class Px{constructor(t,e,n,s){this.observerBody=t,this.targetBody=e,this.aberration=n,this.observerPos=s}Position(t){this.aberration&&(this.observerPos=Ti(this.observerBody,t));const e=Ti(this.targetBody,t);return new ue(e.x-this.observerPos.x,e.y-this.observerPos.y,e.z-this.observerPos.z,t)}}function Ix(i,t,e,n){Va(n);const s=Le(i);if(eh(e)){const o=Ti(e,s);if(n){const l=Nx(t,s),h=new ue(o.x-l.x,o.y-l.y,o.z-l.z,s),u=jl/h.Length();return new ue(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,s)}const c=Ti(t,s);return new ue(o.x-c.x,o.y-c.y,o.z-c.z,s)}let r;n?r=new ue(0,0,0,s):r=Ti(t,s);const a=new Px(t,e,n,r);return Dx(o=>a.Position(o),s)}function Rl(i,t,e){Va(e);const n=Le(t);switch(i){case yt.Earth:return new ue(0,0,0,n);case yt.Moon:return Ws(n);default:const s=Ix(n,yt.Earth,i,e);return s.t=n,s}}function Lx(i,t){return new bi(i.r.x,i.r.y,i.r.z,i.v.x,i.v.y,i.v.z,t)}function Nx(i,t){const e=Le(t);switch(i){case yt.Sun:return new bi(0,0,0,0,0,0,e);case yt.SSB:const n=new so(e.tt);return new bi(-n.Sun.r.x,-n.Sun.r.y,-n.Sun.r.z,-n.Sun.v.x,-n.Sun.v.y,-n.Sun.v.z,e);case yt.Mercury:case yt.Venus:case yt.Earth:case yt.Mars:case yt.Jupiter:case yt.Saturn:case yt.Uranus:case yt.Neptune:const s=bl(Xn[i],e.tt);return Lx(s,e);case yt.Pluto:return kd(e);case yt.Moon:case yt.EMB:const r=bl(Xn.Earth,e.tt),a=i==yt.Moon?Fd(e):bx(e);return new bi(a.x+r.r.x,a.y+r.r.y,a.z+r.r.z,a.vx+r.v.x,a.vy+r.v.y,a.vz+r.v.z,e);default:if(eh(i)){const o=Ti(i,e);return new bi(o.x,o.y,o.z,0,0,0,e)}throw`HelioState: Unsupported body "${i}"`}}function Ux(i){for(;i<0;)i+=360;for(;i>=360;)i-=360;return i}function Fx(i,t,e){if(i===yt.Earth||t===yt.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=Le(e),s=Rl(i,n,!1),r=xl(s),a=Rl(t,n,!1),o=xl(a);return Ux(r.elon-o.elon)}function Ox(i,t,e,n){let s,r=0,a=0,o=0;switch(i){case yt.Mercury:s=-.6,r=4.98,a=-4.88,o=3.02;break;case yt.Venus:t<163.6?(s=-4.47,r=1.03,a=.57,o=.13):(s=.98,r=-1.02);break;case yt.Mars:s=-1.52,r=1.6;break;case yt.Jupiter:s=-9.4,r=.5;break;case yt.Uranus:s=-7.19,r=.25;break;case yt.Neptune:s=-6.87;break;case yt.Pluto:s=-1,r=4;break;default:throw`VisualMagnitude: unsupported body ${i}`}const c=t/100;let l=s+c*(r+c*(a+c*o));return l+=5*Math.log10(e*n),l}function zx(i,t,e,n,s){const r=xl(n),a=ee*28.06,o=ee*(169.51+382e-7*s.tt),c=ee*r.elat,l=ee*r.elon,h=Math.asin(Math.sin(c)*Math.cos(a)-Math.cos(c)*Math.sin(a)*Math.sin(l-o)),u=Math.sin(Math.abs(h));let d=-9+.044*i;return d+=u*(-2.6+1.2*u),d+=5*Math.log10(t*e),{mag:d,ring_tilt:Yn*h}}function Bx(i,t,e){let n=i*ee,s=n*n,r=s*s,a=-12.717+1.49*Math.abs(n)+.0431*r;const o=385000.6/Vi;let c=e/o;return a+=5*Math.log10(t*c),a}class kx{constructor(t,e,n,s,r,a,o,c){this.time=t,this.mag=e,this.phase_angle=n,this.helio_dist=s,this.geo_dist=r,this.gc=a,this.hc=o,this.ring_tilt=c,this.phase_fraction=(1+Math.cos(ee*n))/2}}function Gd(i,t){if(i===yt.Earth)throw"The illumination of the Earth is not defined.";const e=Le(t),n=zs(Xn.Earth,e);let s,r,a,o;i===yt.Sun?(a=new ue(-n.x,-n.y,-n.z,e),r=new ue(0,0,0,e),s=0):(i===yt.Moon?(a=Ws(e),r=new ue(n.x+a.x,n.y+a.y,n.z+a.z,e)):(r=Ti(i,t),a=new ue(r.x-n.x,r.y-n.y,r.z-n.z,e)),s=ax(a,r));let c=a.Length(),l=r.Length(),h;if(i===yt.Sun)o=ix+5*Math.log10(c);else if(i===yt.Moon)o=Bx(s,l,c);else if(i===yt.Saturn){const u=zx(s,l,c,a,e);o=u.mag,h=u.ring_tilt}else o=Ox(i,s,l,c);return new kx(e,o,s,l,c,a,r,h)}function Gx(i){return Fx(yt.Moon,yt.Sun,i)}var Wu;(function(i){i[i.Pericenter=0]="Pericenter",i[i.Apocenter=1]="Apocenter"})(Wu||(Wu={}));function Hx(i,t){return new Di([[t.rot[0][0]*i.rot[0][0]+t.rot[1][0]*i.rot[0][1]+t.rot[2][0]*i.rot[0][2],t.rot[0][1]*i.rot[0][0]+t.rot[1][1]*i.rot[0][1]+t.rot[2][1]*i.rot[0][2],t.rot[0][2]*i.rot[0][0]+t.rot[1][2]*i.rot[0][1]+t.rot[2][2]*i.rot[0][2]],[t.rot[0][0]*i.rot[1][0]+t.rot[1][0]*i.rot[1][1]+t.rot[2][0]*i.rot[1][2],t.rot[0][1]*i.rot[1][0]+t.rot[1][1]*i.rot[1][1]+t.rot[2][1]*i.rot[1][2],t.rot[0][2]*i.rot[1][0]+t.rot[1][2]*i.rot[1][1]+t.rot[2][2]*i.rot[1][2]],[t.rot[0][0]*i.rot[2][0]+t.rot[1][0]*i.rot[2][1]+t.rot[2][0]*i.rot[2][2],t.rot[0][1]*i.rot[2][0]+t.rot[1][1]*i.rot[2][1]+t.rot[2][1]*i.rot[2][2],t.rot[0][2]*i.rot[2][0]+t.rot[1][2]*i.rot[2][1]+t.rot[2][2]*i.rot[2][2]]])}function Hd(i,t){t=Le(t);const e=i.lat*ee,n=i.lon*ee,s=i.dist*Math.cos(e);return new ue(s*Math.cos(n),s*Math.sin(n),i.dist*Math.sin(e),t)}function Vd(i){const t=Vx(i);return new vl(t.lon/15,t.lat,t.dist,i)}function Vx(i){const t=i.x*i.x+i.y*i.y,e=Math.sqrt(t+i.z*i.z);let n,s;if(t===0){if(i.z===0)throw"Zero-length vector not allowed.";s=0,n=i.z<0?-90:90}else s=Yn*Math.atan2(i.y,i.x),s<0&&(s+=360),n=Yn*Math.atan2(i.z,Math.sqrt(t));return new sh(n,s,e)}function Wx(i,t){let e;if(ze(t),t<-90||t>90)return 0;{let n=t;n<-1&&(n=-1),e=1.02/Math.tan((n+10.3/(n+5.11))*ee)/60,t<-1&&(e*=(t+90)/89)}return e}function Na(i,t){return new ue(i.rot[0][0]*t.x+i.rot[1][0]*t.y+i.rot[2][0]*t.z,i.rot[0][1]*t.x+i.rot[1][1]*t.y+i.rot[2][1]*t.z,i.rot[0][2]*t.x+i.rot[1][2]*t.y+i.rot[2][2]*t.z,t.t)}function Xx(){return new Di([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function qx(){return new Di([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function Yx(i){i=Le(i);const t=Dd(i,$e.From2000),e=Id(i,$e.From2000);return Hx(t,e)}function Kx(i){const e=Rr(Le(i)).tobl*ee,n=Math.cos(e),s=Math.sin(e);return new Di([[1,0,0],[0,+n,+s],[0,-s,+n]])}var Xu;(function(i){i.Penumbral="penumbral",i.Partial="partial",i.Annular="annular",i.Total="total"})(Xu||(Xu={}));var qu;(function(i){i[i.Invalid=0]="Invalid",i[i.Ascending=1]="Ascending",i[i.Descending=-1]="Descending"})(qu||(qu={}));const Zx=["Venus","Mars","Jupiter","Saturn"];function Wd(i){return new ah(i.lat,i.lng,i.elevationM)}function ao(i,t,e,n){const s=Nd(e,Wd(n),i,t,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function Qo(i,t,e){const n=Wd(e),s=yx(yt[i],t,n,!0,!0),r=Nd(t,n,s.ra,s.dec,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function jo(i,t){return Gd(yt[i],t).mag}function $x(i){const t=Gx(i),e=Gd(yt.Moon,i);return{phaseFraction:t/360,illuminatedFraction:e.phase_fraction}}const Jx=2e3,Qx=3,jx=20;function Yu(i,t,e){if(i.year===void 0&&i.month===void 0&&i.day===void 0&&i.hour===void 0)return;const n=i.year!==void 0,s=i.year??Jx,r=i.month??(n?1:Qx),a=i.day??(n?1:jx),o=e??Math.round(t/15);return new Date(Date.UTC(s,r-1,a,(i.hour??12)-o,i.minute??0,i.second??0))}class Wi{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static apply(t){t.transparent=!0,t.depthWrite=!1,t.onBeforeCompile=e=>{e.fragmentShader=Wi.patch(e.fragmentShader)}}static patch(t){return t.replace(Wi.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
4447
4447
  // Outside the inscribed circle there is no star at all — this is what kills the corners.
4448
- if ( distanceFromCentre > ${Bi.RIM.toFixed(2)} ) discard;
4449
- float glare = 1.0 - smoothstep( ${Bi.CORE.toFixed(2)}, ${Bi.RIM.toFixed(2)}, distanceFromCentre );
4450
- vec4 diffuseColor = vec4( diffuse, opacity * glare );`)}}const zd=Math.PI/180,Yx=180/Math.PI,Kx=256,Zx=19;function $x(i,t){return 156543.03392*Math.cos(i*zd)/2**t}function Jx(i,t){return $x(i,t)*Kx}function Bd(i,t){let e=0;for(;e<Zx&&Jx(i,e+1)>=t;)e++;return e}function kd(i,t,e){const n=2**e,s=(i+180)/360*n,r=t*zd,a=(1-Math.log(Math.tan(r)+1/Math.cos(r))/Math.PI)/2*n;return{x:s,y:a}}function Qx(i,t,e){const{x:n,y:s}=kd(i,t,e);return{x:Math.floor(n),y:Math.floor(s),z:e}}function jx(i){const t=2**i.z,e=i.x/t*360-180,n=(i.x+1)/t*360-180,s=ku(i.y,t);return{south:ku(i.y+1,t),north:s,west:e,east:n}}function ku(i,t){const e=i/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*Yx}function Gd(i,t,e,n){const s=Qx(i,t,e),r=Math.floor(n/2),a=[];for(let l=-r;l<=r;l++)for(let h=-r;h<=r;h++)a.push({x:s.x+h,y:s.y+l,z:e});const o=a.map(jx),c={south:Math.min(...o.map(l=>l.south)),north:Math.max(...o.map(l=>l.north)),west:Math.min(...o.map(l=>l.west)),east:Math.max(...o.map(l=>l.east))};return{tiles:a,bounds:c}}const Hd=Math.PI/180,Ba=111320;function $i(i,t,e,n){const s=Ba*Math.cos(e*Hd),r=(i-e)*Ba;return{x:(t-n)*s,z:-r}}function oa(i,t,e,n){const s=Ba*Math.cos(e*Hd),r=-t,a=i;return{lat:e+r/Ba,lng:n+a/s}}const cn=256,Gu=3,t3=32768;class e3{fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"}async getElevationGrid(t,e){const n=(t.south+t.north)/2,s=(t.west+t.east)/2,r=Math.abs($i(n,t.east,n,t.west).x),a=Math.abs($i(t.north,s,t.south,s).z),o=Bd(n,Math.max(r,a)),{tiles:c}=Gd(s,n,o,Gu),l=Gu*cn,h=new Float32Array(l*l),u=c[0];await Promise.all(c.map(p=>this.decodeTileInto(p,u,h,l)));const d=new Float32Array(e.width*e.height);for(let p=0;p<e.height;p++){const g=t.north+(t.south-t.north)*(p/(e.height-1));for(let x=0;x<e.width;x++){const m=t.west+(t.east-t.west)*(x/(e.width-1));d[p*e.width+x]=this.sampleAt(g,m,o,u,h,l)}}return{heights:d,width:e.width,height:e.height,bounds:t}}async decodeTileInto(t,e,n,s){const r=this.tileUrlTemplate.replace("{z}",String(t.z)).replace("{x}",String(t.x)).replace("{y}",String(t.y)),a=await this.fetchImpl(r);if(!a.ok)throw new Error(`Elevation tile fetch failed (${a.status}): ${r}`);const o=await createImageBitmap(await a.blob()),c=document.createElement("canvas");c.width=cn,c.height=cn;const l=c.getContext("2d");if(!l)throw new Error("2D canvas context unavailable");l.drawImage(o,0,0);const{data:h}=l.getImageData(0,0,cn,cn),u=(t.x-e.x)*cn,d=(t.y-e.y)*cn;for(let p=0;p<cn;p++)for(let g=0;g<cn;g++){const x=(p*cn+g)*4,m=h[x]*256+h[x+1]+h[x+2]/256-t3,f=u+g,A=d+p;n[A*s+f]=m}}sampleAt(t,e,n,s,r,a){const{x:o,y:c}=kd(e,t,n),l=(o-s.x)*cn,h=(c-s.y)*cn,u=Math.max(0,Math.min(a-1,Math.floor(l))),d=Math.max(0,Math.min(a-1,Math.floor(h))),p=Math.min(a-1,u+1),g=Math.min(a-1,d+1),x=l-u,m=h-d,f=r[d*a+u],A=r[d*a+p],T=r[g*a+u],M=r[g*a+p],y=f+(A-f)*x,b=T+(M-T)*x;return y+(b-y)*m}}const Yo=256,Hu=3;async function n3(i,t,e,n){const s=(i.south+i.north)/2,r=(i.west+i.east)/2,a=Math.abs($i(s,i.east,s,i.west).x),o=Math.abs($i(i.north,r,i.south,r).z),c=Bd(s,Math.max(a,o)),{tiles:l}=Gd(r,s,c,Hu),h=Hu*Yo,u=document.createElement("canvas");u.width=h,u.height=h;const d=u.getContext("2d");if(!d)throw new Error("2D canvas context unavailable");const p=l[0];await Promise.all(l.map(async m=>{const f=e(m),A=await n(f);if(!A.ok)throw new Error(`Imagery tile fetch failed (${A.status}): ${f}`);const T=await createImageBitmap(await A.blob());d.drawImage(T,(m.x-p.x)*Yo,(m.y-p.y)*Yo)}));const g=document.createElement("canvas");g.width=t.width,g.height=t.height;const x=g.getContext("2d");if(!x)throw new Error("2D canvas context unavailable");return x.drawImage(u,0,0,h,h,0,0,t.width,t.height),g}class i3{attribution="Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community";fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"}async getImageryTexture(t,e){return{source:await n3(t,e,s=>this.tileUrlTemplate.replace("{z}",String(s.z)).replace("{y}",String(s.y)).replace("{x}",String(s.x)),this.fetchImpl),width:e.width,height:e.height}}}function s3(){return{elevation:new e3,imagery:new i3}}const cr=64,Ie=cr+1,Vu=512,r3=900,a3=700/900,o3=0,c3=.01;function l3(i,t,e){return{north:oa(0,-e,i,t).lat,south:oa(0,e,i,t).lat,east:oa(e,0,i,t).lng,west:oa(-e,0,i,t).lng}}async function h3(i,t,e,n=r3){const s=n,r=n*a3,a=l3(i,t,s),o={width:Ie,height:Ie},[c,l]=await Promise.all([e.elevation.getElevationGrid(a,o),e.imagery.getImageryTexture(a,{width:Vu,height:Vu})]),h=Math.floor(Ie/2),u=c.heights[h*Ie+h],d=new Float32Array(Ie*Ie*3),p=new Float32Array(Ie*Ie*2),g=new Float32Array(Ie*Ie*4);for(let y=0;y<Ie;y++){const b=y/(Ie-1),R=a.north+(a.south-a.north)*b;for(let v=0;v<Ie;v++){const E=v/(Ie-1),D=a.west+(a.east-a.west)*E,{x:C,z:I}=$i(R,D,i,t),W=c.heights[y*Ie+v],X=o3+c3+(W-u),U=y*Ie+v;d[U*3]=C,d[U*3+1]=X,d[U*3+2]=I,p[U*2]=E,p[U*2+1]=b;const q=Math.max(Math.abs(C),Math.abs(I)),H=1-u3((q-r)/(s-r),0,1);g[U*4]=1,g[U*4+1]=1,g[U*4+2]=1,g[U*4+3]=H}}const x=new Uint16Array(cr*cr*6);let m=0;for(let y=0;y<cr;y++)for(let b=0;b<cr;b++){const R=y*Ie+b,v=R+1,E=R+Ie,D=E+1;x[m++]=R,x[m++]=E,x[m++]=v,x[m++]=v,x[m++]=E,x[m++]=D}const f=new ye;f.setAttribute("position",new he(d,3)),f.setAttribute("uv",new he(p,2)),f.setAttribute("color",new he(g,4)),f.setIndex(new he(x,1)),f.computeVertexNormals();const A=new ii(l.source);A.flipY=!1;const T=new xr({map:A,color:new Mt(1,1,1),vertexColors:!0,transparent:!0,fog:!0,depthTest:!1}),M=new oe(f,T);return M.receiveShadow=!0,M.castShadow=!0,{mesh:M,attribution:e.imagery.attribution}}function u3(i,t,e){return Math.max(t,Math.min(e,i))}const d3=18,f3=.55,p3=.5,m3=`
4448
+ if ( distanceFromCentre > ${Wi.RIM.toFixed(2)} ) discard;
4449
+ float glare = 1.0 - smoothstep( ${Wi.CORE.toFixed(2)}, ${Wi.RIM.toFixed(2)}, distanceFromCentre );
4450
+ vec4 diffuseColor = vec4( diffuse, opacity * glare );`)}}const Xd=Math.PI/180,t3=180/Math.PI,e3=256,n3=19;function i3(i,t){return 156543.03392*Math.cos(i*Xd)/2**t}function s3(i,t){return i3(i,t)*e3}function qd(i,t){let e=0;for(;e<n3&&s3(i,e+1)>=t;)e++;return e}function Yd(i,t,e){const n=2**e,s=(i+180)/360*n,r=t*Xd,a=(1-Math.log(Math.tan(r)+1/Math.cos(r))/Math.PI)/2*n;return{x:s,y:a}}function r3(i,t,e){const{x:n,y:s}=Yd(i,t,e);return{x:Math.floor(n),y:Math.floor(s),z:e}}function a3(i){const t=2**i.z,e=i.x/t*360-180,n=(i.x+1)/t*360-180,s=Ku(i.y,t);return{south:Ku(i.y+1,t),north:s,west:e,east:n}}function Ku(i,t){const e=i/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*t3}function Kd(i,t,e,n){const s=r3(i,t,e),r=Math.floor(n/2),a=[];for(let l=-r;l<=r;l++)for(let h=-r;h<=r;h++)a.push({x:s.x+h,y:s.y+l,z:e});const o=a.map(a3),c={south:Math.min(...o.map(l=>l.south)),north:Math.max(...o.map(l=>l.north)),west:Math.min(...o.map(l=>l.west)),east:Math.max(...o.map(l=>l.east))};return{tiles:a,bounds:c}}const Zd=Math.PI/180,qa=111320;function ji(i,t,e,n){const s=qa*Math.cos(e*Zd),r=(i-e)*qa;return{x:(t-n)*s,z:-r}}function pa(i,t,e,n){const s=qa*Math.cos(e*Zd),r=-t,a=i;return{lat:e+r/qa,lng:n+a/s}}const pn=256,Zu=3,o3=32768;class c3{fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"}async getElevationGrid(t,e){const n=(t.south+t.north)/2,s=(t.west+t.east)/2,r=Math.abs(ji(n,t.east,n,t.west).x),a=Math.abs(ji(t.north,s,t.south,s).z),o=qd(n,Math.max(r,a)),{tiles:c}=Kd(s,n,o,Zu),l=Zu*pn,h=new Float32Array(l*l),u=c[0];await Promise.all(c.map(f=>this.decodeTileInto(f,u,h,l)));const d=new Float32Array(e.width*e.height);for(let f=0;f<e.height;f++){const g=t.north+(t.south-t.north)*(f/(e.height-1));for(let x=0;x<e.width;x++){const m=t.west+(t.east-t.west)*(x/(e.width-1));d[f*e.width+x]=this.sampleAt(g,m,o,u,h,l)}}return{heights:d,width:e.width,height:e.height,bounds:t}}async decodeTileInto(t,e,n,s){const r=this.tileUrlTemplate.replace("{z}",String(t.z)).replace("{x}",String(t.x)).replace("{y}",String(t.y)),a=await this.fetchImpl(r);if(!a.ok)throw new Error(`Elevation tile fetch failed (${a.status}): ${r}`);const o=await createImageBitmap(await a.blob()),c=document.createElement("canvas");c.width=pn,c.height=pn;const l=c.getContext("2d");if(!l)throw new Error("2D canvas context unavailable");l.drawImage(o,0,0);const{data:h}=l.getImageData(0,0,pn,pn),u=(t.x-e.x)*pn,d=(t.y-e.y)*pn;for(let f=0;f<pn;f++)for(let g=0;g<pn;g++){const x=(f*pn+g)*4,m=h[x]*256+h[x+1]+h[x+2]/256-o3,p=u+g,A=d+f;n[A*s+p]=m}}sampleAt(t,e,n,s,r,a){const{x:o,y:c}=Yd(e,t,n),l=(o-s.x)*pn,h=(c-s.y)*pn,u=Math.max(0,Math.min(a-1,Math.floor(l))),d=Math.max(0,Math.min(a-1,Math.floor(h))),f=Math.min(a-1,u+1),g=Math.min(a-1,d+1),x=l-u,m=h-d,p=r[d*a+u],A=r[d*a+f],T=r[g*a+u],M=r[g*a+f],y=p+(A-p)*x,b=T+(M-T)*x;return y+(b-y)*m}}const tc=256,$u=3;async function l3(i,t,e,n){const s=(i.south+i.north)/2,r=(i.west+i.east)/2,a=Math.abs(ji(s,i.east,s,i.west).x),o=Math.abs(ji(i.north,r,i.south,r).z),c=qd(s,Math.max(a,o)),{tiles:l}=Kd(r,s,c,$u),h=$u*tc,u=document.createElement("canvas");u.width=h,u.height=h;const d=u.getContext("2d");if(!d)throw new Error("2D canvas context unavailable");const f=l[0];await Promise.all(l.map(async m=>{const p=e(m),A=await n(p);if(!A.ok)throw new Error(`Imagery tile fetch failed (${A.status}): ${p}`);const T=await createImageBitmap(await A.blob());d.drawImage(T,(m.x-f.x)*tc,(m.y-f.y)*tc)}));const g=document.createElement("canvas");g.width=t.width,g.height=t.height;const x=g.getContext("2d");if(!x)throw new Error("2D canvas context unavailable");return x.drawImage(u,0,0,h,h,0,0,t.width,t.height),g}class h3{attribution="Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community";fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"}async getImageryTexture(t,e){return{source:await l3(t,e,s=>this.tileUrlTemplate.replace("{z}",String(s.z)).replace("{y}",String(s.y)).replace("{x}",String(s.x)),this.fetchImpl),width:e.width,height:e.height}}}function u3(){return{elevation:new c3,imagery:new h3}}const fr=64,Ue=fr+1,Ju=512,d3=900,f3=700/900,p3=0,m3=.01;function g3(i,t,e){return{north:pa(0,-e,i,t).lat,south:pa(0,e,i,t).lat,east:pa(e,0,i,t).lng,west:pa(-e,0,i,t).lng}}async function _3(i,t,e,n=d3){const s=n,r=n*f3,a=g3(i,t,s),o={width:Ue,height:Ue},[c,l]=await Promise.all([e.elevation.getElevationGrid(a,o),e.imagery.getImageryTexture(a,{width:Ju,height:Ju})]),h=Math.floor(Ue/2),u=c.heights[h*Ue+h],d=new Float32Array(Ue*Ue*3),f=new Float32Array(Ue*Ue*2),g=new Float32Array(Ue*Ue*4);for(let y=0;y<Ue;y++){const b=y/(Ue-1),R=a.north+(a.south-a.north)*b;for(let v=0;v<Ue;v++){const E=v/(Ue-1),D=a.west+(a.east-a.west)*E,{x:C,z:I}=ji(R,D,i,t),W=c.heights[y*Ue+v],X=p3+m3+(W-u),U=y*Ue+v;d[U*3]=C,d[U*3+1]=X,d[U*3+2]=I,f[U*2]=E,f[U*2+1]=b;const q=Math.max(Math.abs(C),Math.abs(I)),H=1-v3((q-r)/(s-r),0,1);g[U*4]=1,g[U*4+1]=1,g[U*4+2]=1,g[U*4+3]=H}}const x=new Uint16Array(fr*fr*6);let m=0;for(let y=0;y<fr;y++)for(let b=0;b<fr;b++){const R=y*Ue+b,v=R+1,E=R+Ue,D=E+1;x[m++]=R,x[m++]=E,x[m++]=v,x[m++]=v,x[m++]=E,x[m++]=D}const p=new Ee;p.setAttribute("position",new le(d,3)),p.setAttribute("uv",new le(f,2)),p.setAttribute("color",new le(g,4)),p.setIndex(new le(x,1)),p.computeVertexNormals();const A=new oi(l.source);A.flipY=!1;const T=new Tr({map:A,color:new Mt(1,1,1),vertexColors:!0,transparent:!0,fog:!0,depthTest:!1}),M=new se(p,T);return M.receiveShadow=!0,M.castShadow=!0,{mesh:M,attribution:e.imagery.attribution}}function v3(i,t,e){return Math.max(t,Math.min(e,i))}const x3=18,M3=.55,S3=.5,y3=`
4451
4451
  attribute float aSpeed;
4452
4452
  uniform float uTime;
4453
4453
  uniform float uOverallSpeed;
@@ -4484,9 +4484,9 @@ void main() {
4484
4484
  // a real, caught bug (a user directly noticed "darker/farther streaks equal-or-bigger than
4485
4485
  // lighter/closer ones"), not just a stylistic overcorrection.
4486
4486
  vHaze = clamp(dist / uHazeDistance, 0.0, 1.0);
4487
- gl_PointSize = uPixelSize / dist + vNearBlur * ${d3.toFixed(1)};
4487
+ gl_PointSize = uPixelSize / dist + vNearBlur * ${x3.toFixed(1)};
4488
4488
  }
4489
- `,g3=`
4489
+ `,E3=`
4490
4490
  precision mediump float;
4491
4491
  uniform sampler2D uTexture;
4492
4492
  uniform vec3 uColor;
@@ -4514,18 +4514,18 @@ void main() {
4514
4514
  // defocus doesn't change color, only spreads+dims (see vertex shader's own gl_PointSize term) —
4515
4515
  // both dim the alpha so a maximally blurred/hazy drop doesn't stay as visually "solid" as a sharp
4516
4516
  // one right in the middle distance.
4517
- vec3 color = mix(uColor, uHazeColor, vHaze * ${f3.toFixed(2)});
4517
+ vec3 color = mix(uColor, uHazeColor, vHaze * ${M3.toFixed(2)});
4518
4518
  float blur = max(vNearBlur, vHaze);
4519
- gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${p3.toFixed(2)}));
4519
+ gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${S3.toFixed(2)}));
4520
4520
  }
4521
- `;function _3(i){let t=i;return function(){t|=0,t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}let ca;function v3(){if(ca)return ca;const i=128,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=e.createLinearGradient(0,0,i,0);n.addColorStop(0,"rgba(255,255,255,0)"),n.addColorStop(.42,"rgba(255,255,255,0)"),n.addColorStop(.47,"rgba(255,255,255,0.85)"),n.addColorStop(.5,"rgba(255,255,255,1)"),n.addColorStop(.53,"rgba(255,255,255,0.85)"),n.addColorStop(.58,"rgba(255,255,255,0)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,i,i);const s=e.createLinearGradient(0,0,0,i);return s.addColorStop(0,"rgba(0,0,0,1)"),s.addColorStop(.1,"rgba(0,0,0,0)"),s.addColorStop(.9,"rgba(0,0,0,0)"),s.addColorStop(1,"rgba(0,0,0,1)"),e.globalCompositeOperation="destination-out",e.fillStyle=s,e.fillRect(0,0,i,i),e.globalCompositeOperation="source-over",ca=new ii(t),ca}function x3(i){const t=_3(i.seed),e=new Float32Array(i.count*3),n=new Float32Array(i.count),s=i.radiusM;for(let l=0;l<i.count;l++){const h=t()*Math.PI*2,u=Math.sqrt(t())*i.radiusM;e[l*3]=Math.cos(h)*u,e[l*3+1]=t()*i.heightM,e[l*3+2]=Math.sin(h)*u,n[l]=.85+t()*.3}const r=new ye;r.setAttribute("position",new he(e,3)),r.setAttribute("aSpeed",new he(n,1)),r.setDrawRange(0,i.visibleCount);const a={uTime:{value:0},uOverallSpeed:{value:i.overallSpeed},uPixelSize:{value:i.pixelSize},uOpacity:{value:i.opacity},uColor:{value:i.color},uUvSquash:{value:1},uSpeedStreak:{value:i.speedStreak},uWindOffset:{value:new Ft(0,0)},uHeight:{value:i.heightM},uBottomY:{value:i.bottomYM},uHalfWidth:{value:s},uTexture:{value:v3()},uNearFocusDistance:{value:i.nearFocusDistanceM},uHazeDistance:{value:i.hazeDistanceM},uHazeColor:{value:i.hazeColor}},o=new Be({uniforms:a,vertexShader:m3,fragmentShader:g3,transparent:!0,depthWrite:!1,depthTest:!0}),c=new ba(r,o);return c.frustumCulled=!1,{points:c,uniforms:a}}const M3=`
4521
+ `;function b3(i){let t=i;return function(){t|=0,t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}let ma;function A3(){if(ma)return ma;const i=128,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=e.createLinearGradient(0,0,i,0);n.addColorStop(0,"rgba(255,255,255,0)"),n.addColorStop(.42,"rgba(255,255,255,0)"),n.addColorStop(.47,"rgba(255,255,255,0.85)"),n.addColorStop(.5,"rgba(255,255,255,1)"),n.addColorStop(.53,"rgba(255,255,255,0.85)"),n.addColorStop(.58,"rgba(255,255,255,0)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,i,i);const s=e.createLinearGradient(0,0,0,i);return s.addColorStop(0,"rgba(0,0,0,1)"),s.addColorStop(.1,"rgba(0,0,0,0)"),s.addColorStop(.9,"rgba(0,0,0,0)"),s.addColorStop(1,"rgba(0,0,0,1)"),e.globalCompositeOperation="destination-out",e.fillStyle=s,e.fillRect(0,0,i,i),e.globalCompositeOperation="source-over",ma=new oi(t),ma}function T3(i){const t=b3(i.seed),e=new Float32Array(i.count*3),n=new Float32Array(i.count),s=i.radiusM;for(let l=0;l<i.count;l++){const h=t()*Math.PI*2,u=Math.sqrt(t())*i.radiusM;e[l*3]=Math.cos(h)*u,e[l*3+1]=t()*i.heightM,e[l*3+2]=Math.sin(h)*u,n[l]=.85+t()*.3}const r=new Ee;r.setAttribute("position",new le(e,3)),r.setAttribute("aSpeed",new le(n,1)),r.setDrawRange(0,i.visibleCount);const a={uTime:{value:0},uOverallSpeed:{value:i.overallSpeed},uPixelSize:{value:i.pixelSize},uOpacity:{value:i.opacity},uColor:{value:i.color},uUvSquash:{value:1},uSpeedStreak:{value:i.speedStreak},uWindOffset:{value:new Ft(0,0)},uHeight:{value:i.heightM},uBottomY:{value:i.bottomYM},uHalfWidth:{value:s},uTexture:{value:A3()},uNearFocusDistance:{value:i.nearFocusDistanceM},uHazeDistance:{value:i.hazeDistanceM},uHazeColor:{value:i.hazeColor}},o=new Be({uniforms:a,vertexShader:y3,fragmentShader:E3,transparent:!0,depthWrite:!1,depthTest:!0}),c=new Pa(r,o);return c.frustumCulled=!1,{points:c,uniforms:a}}const w3=`
4522
4522
  varying vec3 vDir;
4523
4523
 
4524
4524
  void main() {
4525
4525
  vDir = normalize(position);
4526
4526
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
4527
4527
  }
4528
- `,Vd=`vec3 hash3(vec3 p) {
4528
+ `,$d=`vec3 hash3(vec3 p) {
4529
4529
  p = vec3(dot(p, vec3(127.1, 311.7, 74.7)), dot(p, vec3(269.5, 183.3, 246.1)), dot(p, vec3(113.5, 271.9, 124.6)));
4530
4530
  return fract(sin(p) * 43758.5453) * 2.0 - 1.0;
4531
4531
  }
@@ -4553,7 +4553,7 @@ float fbm(vec3 p) {
4553
4553
  amp *= 0.55;
4554
4554
  }
4555
4555
  return sum;
4556
- }`,S3=`
4556
+ }`,R3=`
4557
4557
  float cirrusCoverAt(vec3 dir, float layerHeight, float coverage) {
4558
4558
  if (coverage <= 0.0 || dir.y <= 0.02) return 0.0;
4559
4559
  vec3 planePos = dir * (layerHeight / max(dir.y, 0.04));
@@ -4573,7 +4573,7 @@ float cirrusCoverAt(vec3 dir, float layerHeight, float coverage) {
4573
4573
  // is what makes a halo brighter along one arc than another even under total cover.
4574
4574
  return present * (0.30 + 0.70 * smoothstep(0.25, 0.85, shape));
4575
4575
  }
4576
- `,y3=`
4576
+ `,C3=`
4577
4577
  precision highp float;
4578
4578
  uniform vec3 sunDir;
4579
4579
  uniform vec3 sunColor;
@@ -4591,7 +4591,7 @@ varying vec3 vDir;
4591
4591
  uniform float layerHeight;
4592
4592
  uniform float fibrous;
4593
4593
 
4594
- ${Vd}
4594
+ ${$d}
4595
4595
 
4596
4596
  // Cellular (Worley) noise — distance to the nearest of 27 randomly-jittered cell points. Unlike
4597
4597
  // fbm's smooth interpolated blobs, this has genuinely sharp valleys between cells, reading as
@@ -4695,13 +4695,13 @@ void main() {
4695
4695
 
4696
4696
  gl_FragColor = vec4(color, alpha);
4697
4697
  }
4698
- `;function Wu(i,t,e,n=0){const s={sunDir:{value:new F(0,1,0)},sunColor:{value:new Mt(1,1,1)},ambientColor:{value:new Mt(.5,.5,.5)},baseColor:{value:i},coverage:{value:t},layerHeight:{value:e},fibrous:{value:n}};return{material:new Be({uniforms:s,vertexShader:M3,fragmentShader:y3,transparent:!0,depthWrite:!1,depthTest:!1,side:Fe}),uniforms:s}}const E3=1.5;function Xu(i){const t=Math.PI/2-E3*Math.PI/180;return new Wn(i,48,24,0,Math.PI*2,0,t)}class Ae{static OCTAVES=4;static GAIN=.55;static LACUNARITY=2.03;static fract(t){return t-Math.floor(t)}static hash3(t,e,n){const s=t*127.1+e*311.7+n*74.7,r=t*269.5+e*183.3+n*246.1,a=t*113.5+e*271.9+n*124.6;return[Ae.fract(Math.sin(s)*43758.5453)*2-1,Ae.fract(Math.sin(r)*43758.5453)*2-1,Ae.fract(Math.sin(a)*43758.5453)*2-1]}static noise3D(t,e,n){const s=Math.floor(t),r=Math.floor(e),a=Math.floor(n),o=t-s,c=e-r,l=n-a,h=o*o*(3-2*o),u=c*c*(3-2*c),d=l*l*(3-2*l),p=(x,m,f)=>{const[A,T,M]=Ae.hash3(s+x,r+m,a+f);return A*(o-x)+T*(c-m)+M*(l-f)},g=(x,m,f)=>x+(m-x)*f;return g(g(g(p(0,0,0),p(1,0,0),h),g(p(0,1,0),p(1,1,0),h),u),g(g(p(0,0,1),p(1,0,1),h),g(p(0,1,1),p(1,1,1),h),u),d)}static fbm(t,e,n){let s=0,r=Ae.GAIN;for(let a=0;a<Ae.OCTAVES;a++)s+=Ae.noise3D(t,e,n)*r,t*=Ae.LACUNARITY,e*=Ae.LACUNARITY,n*=Ae.LACUNARITY,r*=Ae.GAIN;return s}static worley(t,e,n){const s=Math.floor(t),r=Math.floor(e),a=Math.floor(n),o=t-s,c=e-r,l=n-a;let h=1/0;for(let u=-1;u<=1;u++)for(let d=-1;d<=1;d++)for(let p=-1;p<=1;p++){const[g,x,m]=Ae.hash3(s+u,r+d,a+p),f=u+(g*.5+.5)-o,A=d+(x*.5+.5)-c,T=p+(m*.5+.5)-l;h=Math.min(h,f*f+A*A+T*T)}return Math.sqrt(h)}static alphaAt(t,e,n){if(n<=0)return 0;const s=Math.abs(t.y);if(s<.026)return 0;const r=e/Math.max(s,.04),a=t.x*r,o=t.y*r,c=t.z*r,l=a*.006,h=o*.006,u=c*.006,d=a+Ae.fbm(l+12.3,h+12.3,u+12.3)*40,p=o+Ae.fbm(l+47.1,h+47.1,u+47.1)*40,g=c+Ae.fbm(l+91.7,h+91.7,u+91.7)*40,x=Ae.fbm(d*.014,p*.014,g*.014)*.5+.5,m=1-Ae.worley(d*.011,p*.011,g*.011),f=x+(m-x)*.4,A=1-n,T=(y,b,R)=>{const v=Math.min(1,Math.max(0,(R-y)/(b-y)));return v*v*(3-2*v)},M=T(A-.08,A+.08,f);return M+(1-M)*T(.82,1,n)}}const b3=`
4698
+ `;function Qu(i,t,e,n=0){const s={sunDir:{value:new F(0,1,0)},sunColor:{value:new Mt(1,1,1)},ambientColor:{value:new Mt(.5,.5,.5)},baseColor:{value:i},coverage:{value:t},layerHeight:{value:e},fibrous:{value:n}};return{material:new Be({uniforms:s,vertexShader:w3,fragmentShader:C3,transparent:!0,depthWrite:!1,depthTest:!1,side:Ce}),uniforms:s}}const D3=1.5;function ju(i){const t=Math.PI/2-D3*Math.PI/180;return new Cn(i,48,24,0,Math.PI*2,0,t)}class Te{static OCTAVES=4;static GAIN=.55;static LACUNARITY=2.03;static fract(t){return t-Math.floor(t)}static hash3(t,e,n){const s=t*127.1+e*311.7+n*74.7,r=t*269.5+e*183.3+n*246.1,a=t*113.5+e*271.9+n*124.6;return[Te.fract(Math.sin(s)*43758.5453)*2-1,Te.fract(Math.sin(r)*43758.5453)*2-1,Te.fract(Math.sin(a)*43758.5453)*2-1]}static noise3D(t,e,n){const s=Math.floor(t),r=Math.floor(e),a=Math.floor(n),o=t-s,c=e-r,l=n-a,h=o*o*(3-2*o),u=c*c*(3-2*c),d=l*l*(3-2*l),f=(x,m,p)=>{const[A,T,M]=Te.hash3(s+x,r+m,a+p);return A*(o-x)+T*(c-m)+M*(l-p)},g=(x,m,p)=>x+(m-x)*p;return g(g(g(f(0,0,0),f(1,0,0),h),g(f(0,1,0),f(1,1,0),h),u),g(g(f(0,0,1),f(1,0,1),h),g(f(0,1,1),f(1,1,1),h),u),d)}static fbm(t,e,n){let s=0,r=Te.GAIN;for(let a=0;a<Te.OCTAVES;a++)s+=Te.noise3D(t,e,n)*r,t*=Te.LACUNARITY,e*=Te.LACUNARITY,n*=Te.LACUNARITY,r*=Te.GAIN;return s}static worley(t,e,n){const s=Math.floor(t),r=Math.floor(e),a=Math.floor(n),o=t-s,c=e-r,l=n-a;let h=1/0;for(let u=-1;u<=1;u++)for(let d=-1;d<=1;d++)for(let f=-1;f<=1;f++){const[g,x,m]=Te.hash3(s+u,r+d,a+f),p=u+(g*.5+.5)-o,A=d+(x*.5+.5)-c,T=f+(m*.5+.5)-l;h=Math.min(h,p*p+A*A+T*T)}return Math.sqrt(h)}static alphaAt(t,e,n){if(n<=0)return 0;const s=Math.abs(t.y);if(s<.026)return 0;const r=e/Math.max(s,.04),a=t.x*r,o=t.y*r,c=t.z*r,l=a*.006,h=o*.006,u=c*.006,d=a+Te.fbm(l+12.3,h+12.3,u+12.3)*40,f=o+Te.fbm(l+47.1,h+47.1,u+47.1)*40,g=c+Te.fbm(l+91.7,h+91.7,u+91.7)*40,x=Te.fbm(d*.014,f*.014,g*.014)*.5+.5,m=1-Te.worley(d*.011,f*.011,g*.011),p=x+(m-x)*.4,A=1-n,T=(y,b,R)=>{const v=Math.min(1,Math.max(0,(R-y)/(b-y)));return v*v*(3-2*v)},M=T(A-.08,A+.08,p);return M+(1-M)*T(.82,1,n)}}const P3=`
4699
4699
  varying vec2 vUv;
4700
4700
  void main() {
4701
4701
  vUv = uv;
4702
4702
  gl_Position = vec4(position, 1.0);
4703
4703
  }
4704
- `,A3=`
4704
+ `,I3=`
4705
4705
  // Based on https://www.shadertoy.com/view/4sX3Rs
4706
4706
  uniform float uTime;
4707
4707
  uniform vec2 uLensPosition;
@@ -5131,7 +5131,7 @@ void main()
5131
5131
  // stays what it always was for the optional artifacts.
5132
5132
  gl_FragColor = vec4(dazzle + artifactsContribution * uOpacity, 1.0);
5133
5133
  }
5134
- `;let la;function T3(){if(la)return la;const i=256,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d");e.fillStyle="rgba(60,60,60,1)",e.fillRect(0,0,i,i);const n=[[.3,.35,.22,.5],[.7,.6,.16,.35],[.55,.8,.3,.4],[.15,.7,.12,.3],[.85,.2,.18,.3]];for(const[s,r,a,o]of n){const c=e.createRadialGradient(s*i,r*i,0,s*i,r*i,a*i);c.addColorStop(0,`rgba(200,200,200,${o})`),c.addColorStop(1,"rgba(200,200,200,0)"),e.fillStyle=c,e.fillRect(0,0,i,i)}return la=new ii(t),la}function w3(){const i={uTime:{value:0},uResolution:{value:new Ft(1,1)},uLensPosition:{value:new Ft(0,0)},uColorGain:{value:new Mt(55,55,51)},uOpacity:{value:.5},uFlareIntensity:{value:0},uStarPoints:{value:0},uTanHalfFov:{value:Math.tan(Math.PI/6)},uSourceRadiusDeg:{value:.265},uVeilStrength:{value:0},uDazzleColour:{value:new Mt(1,1,1)},uFlareSize:{value:.0025},uFlareSpeed:{value:.4},uFlareShape:{value:1.2},uHaloScale:{value:.5},uGhostScale:{value:.3},uAnimated:{value:!1},uAnamorphic:{value:!1},uSecondaryGhosts:{value:!0},uStarBurst:{value:!0},uAdditionalStreaks:{value:!0},uLensDirtTexture:{value:T3()}},t=new Be({uniforms:i,vertexShader:b3,fragmentShader:A3,transparent:!0,depthWrite:!1,depthTest:!1,blending:Xi,fog:!1,name:"LensFlareShader"}),e=new oe(new Gs(2,2),t);return e.frustumCulled=!1,e.renderOrder=20,{mesh:e,uniforms:i}}class ka{static MAX_HALF_ANGLE_DEG=80;target;quadScene=new $0;quadCamera=new Ya(-1,1,1,-1,0,1);material;width;height;constructor(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e),this.target=new En(this.width,this.height,{type:bn}),this.material=new Be({uniforms:{uSource:{value:this.target.texture},uHalfFovRad:{value:.5236},uAspect:{value:this.width/this.height},uSrcTanHalfFovY:{value:1},uResolution:{value:new Ft(this.width,this.height)}},vertexShader:`
5134
+ `;let ga;function L3(){if(ga)return ga;const i=256,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d");e.fillStyle="rgba(60,60,60,1)",e.fillRect(0,0,i,i);const n=[[.3,.35,.22,.5],[.7,.6,.16,.35],[.55,.8,.3,.4],[.15,.7,.12,.3],[.85,.2,.18,.3]];for(const[s,r,a,o]of n){const c=e.createRadialGradient(s*i,r*i,0,s*i,r*i,a*i);c.addColorStop(0,`rgba(200,200,200,${o})`),c.addColorStop(1,"rgba(200,200,200,0)"),e.fillStyle=c,e.fillRect(0,0,i,i)}return ga=new oi(t),ga}function N3(){const i={uTime:{value:0},uResolution:{value:new Ft(1,1)},uLensPosition:{value:new Ft(0,0)},uColorGain:{value:new Mt(55,55,51)},uOpacity:{value:.5},uFlareIntensity:{value:0},uStarPoints:{value:0},uTanHalfFov:{value:Math.tan(Math.PI/6)},uSourceRadiusDeg:{value:.265},uVeilStrength:{value:0},uDazzleColour:{value:new Mt(1,1,1)},uFlareSize:{value:.0025},uFlareSpeed:{value:.4},uFlareShape:{value:1.2},uHaloScale:{value:.5},uGhostScale:{value:.3},uAnimated:{value:!1},uAnamorphic:{value:!1},uSecondaryGhosts:{value:!0},uStarBurst:{value:!0},uAdditionalStreaks:{value:!0},uLensDirtTexture:{value:L3()}},t=new Be({uniforms:i,vertexShader:P3,fragmentShader:I3,transparent:!0,depthWrite:!1,depthTest:!1,blending:Ri,fog:!1,name:"LensFlareShader"}),e=new se(new qs(2,2),t);return e.frustumCulled=!1,e.renderOrder=20,{mesh:e,uniforms:i}}class Ya{static MAX_HALF_ANGLE_DEG=80;target;quadScene=new sd;quadCamera=new eo(-1,1,1,-1,0,1);material;width;height;constructor(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e),this.target=new Rn(this.width,this.height,{type:xn}),this.material=new Be({uniforms:{uSource:{value:this.target.texture},uHalfFovRad:{value:.5236},uAspect:{value:this.width/this.height},uSrcTanHalfFovY:{value:1},uResolution:{value:new Ft(this.width,this.height)}},vertexShader:`
5135
5135
  varying vec2 vNdc;
5136
5136
  void main() {
5137
5137
  vNdc = position.xy;
@@ -5165,7 +5165,7 @@ void main()
5165
5165
  if (any(greaterThan(abs(src), vec2(1.0)))) { gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); return; }
5166
5166
  gl_FragColor = texture2D(uSource, src * 0.5 + 0.5);
5167
5167
  }
5168
- `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new oe(new Gs(2,2),this.material))}directionFor(t,e,n){const s=this.width/this.height,r=n/2*Math.PI/180,a=t*s*r,o=e*r,c=Math.hypot(a,o);if(c<1e-6)return{x:0,y:0,z:-1};const l=Math.sin(c);return{x:a/c*l,y:o/c*l,z:-Math.cos(c)}}static cornerHalfAngleDeg(t,e){return t/2*Math.hypot(e,1)}static supports(t,e){return this.cornerHalfAngleDeg(t,e)<=this.MAX_HALF_ANGLE_DEG}resize(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height),this.material.uniforms.uAspect.value=this.width/this.height}render(t,e,n,s,r){const a=this.width/this.height;this.material.uniforms.uHalfFovRad.value=s/2*Math.PI/180,this.material.uniforms.uSrcTanHalfFovY.value=this.sourceTanHalfFovY(s,a);const o=n.fov;n.fov=this.sourceFovDeg(s,a),n.updateProjectionMatrix(),r?.();const c=t.getRenderTarget();t.setRenderTarget(this.target),t.render(e,n),t.setRenderTarget(c),n.fov=o,n.updateProjectionMatrix(),t.render(this.quadScene,this.quadCamera)}sourceFovDeg(t,e){return Math.atan(this.sourceTanHalfFovY(t,e))*360/Math.PI}sourceTanHalfFovY(t,e){const n=ka.cornerHalfAngleDeg(t,e)*Math.PI/180;return Math.tan(n)/Math.hypot(e,1)}dispose(){this.target.dispose(),this.material.dispose(),this.quadScene.clear()}}class $t{static ICE_INDEX_RED=1.3067;static ICE_INDEX_BLUE=1.317;static SIDE_PRISM_ANGLE_DEG=60;static END_PRISM_ANGLE_DEG=90;static get PARHELIA_MAX_SUN_ALTITUDE_DEG(){const t=$t.ICE_INDEX_RED,e=Math.sqrt((4-t*t)/3);return Math.asin(Math.min(1,e))*180/Math.PI}static minimumDeviationDeg(t,e){const n=t*Math.PI/180,s=e*Math.sin(n/2);return s>1?Number.NaN:(2*Math.asin(s)-n)*180/Math.PI}static effectiveIndex(t,e){const n=e*Math.PI/180,s=Math.cos(n);return s<=0?Number.POSITIVE_INFINITY:Math.sqrt(t*t-Math.sin(n)**2)/s}static parheliaAzimuthDeg(t,e=$t.ICE_INDEX_RED){const n=$t.minimumDeviationDeg($t.SIDE_PRISM_ANGLE_DEG,$t.effectiveIndex(e,t));return Number.isFinite(n)?n:void 0}static parheliaDistanceDeg(t,e=$t.ICE_INDEX_RED){const n=$t.parheliaAzimuthDeg(t,e);if(n===void 0)return;const s=t*Math.PI/180,r=Math.sin(s)**2,a=Math.cos(s)**2*Math.cos(n*Math.PI/180);return Math.acos(Math.max(-1,Math.min(1,r+a)))*180/Math.PI}static get PLATE_END_FACE_LIMIT_DEG(){const t=$t.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(t*t-1)))*180/Math.PI}static circumzenithalAltitudeDeg(t,e=$t.ICE_INDEX_RED){if(t<0||t>90-$t.PLATE_END_FACE_LIMIT_DEG)return;const n=Math.cos(t*Math.PI/180),s=Math.sqrt(e*e-n*n);if(!(s>=1))return Math.asin(s)*180/Math.PI}static DECK_HEIGHT_M=8e3;static deckLitUntilDeg(t){return Math.acos(6371e3/(6371e3+Math.max(0,t)))*180/Math.PI}static halo22(){return $t.ringOf("halo22",$t.SIDE_PRISM_ANGLE_DEG)}static halo46(){return $t.ringOf("halo46",$t.END_PRISM_ANGLE_DEG)}static ringOf(t,e){const n=$t.minimumDeviationDeg(e,$t.ICE_INDEX_RED),s=$t.minimumDeviationDeg(e,$t.ICE_INDEX_BLUE);return{id:t,angleDeg:(n+s)/2,redAngleDeg:n,blueAngleDeg:s}}static strength(t,e,n=90,s=0){const r=Math.max(0,Math.min(1,t)),a=Math.max(0,1-Math.max(0,Math.min(1,e))),o=n>=0?1:s<=0?0:Math.max(0,1+n/s);return r*a*o}static formsAt(t,e=0){if(t<=-e)return[];const n=[$t.halo22(),$t.halo46()],s=t>0?$t.parheliaDistanceDeg(t):void 0;s!==void 0&&n.push({id:"parhelia",angleDeg:s,redAngleDeg:s,blueAngleDeg:$t.parheliaDistanceDeg(t,$t.ICE_INDEX_BLUE)}),n.push({id:"tangentArc",angleDeg:$t.halo22().angleDeg}),t>0&&n.push({id:"parhelicCircle",angleDeg:t});const r=$t.circumzenithalAltitudeDeg(t);return r!==void 0&&n.push({id:"circumzenithal",angleDeg:r}),t>$t.PLATE_END_FACE_LIMIT_DEG&&n.push({id:"circumhorizontal"}),t<$t.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&n.push({id:"pillar"}),n}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class en{constructor(t){this.radius=t;const e=en.SEGMENTS*en.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const n=new ye;n.setAttribute("position",new he(this.positions,3)),n.setAttribute("color",new he(this.colors,3)),n.setDrawRange(0,0),this.object=new oe(n,new Ki({vertexColors:!0,transparent:!0,blending:Xi,depthWrite:!1,fog:!1,side:Mn})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=en.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(en.ACROSS-1)*6;static HEAD_HALF_WIDTH_DEG=.15;static SPREAD_FRACTION=.05;static FADE_POWER=1.8;object;positions;colors;head;tip;brightness=0;set(t,e,n){this.head=t&&un(t.altitudeDeg,t.azimuthDeg,1),this.tip=e&&un(e.altitudeDeg,e.azimuthDeg,1),this.brightness=n,this.rebuild()}rebuild(){const t=this.object.geometry,e=this.head,n=this.tip;if(!e||!n||this.brightness<=0){t.setDrawRange(0,0);return}const s=this.angleBetween(e,n);if(s<=0){t.setDrawRange(0,0);return}const r=s*en.SPREAD_FRACTION*Math.PI/180,a=h=>this.scale(this.slerp(e,n,h),this.radius),o=h=>this.radius*(en.HEAD_HALF_WIDTH_DEG*Math.PI/180+r*h),c=h=>this.brightness*(1-h)**en.FADE_POWER;let l=0;for(let h=1;h<en.POINTS;h++){const u=(h-1)/en.SEGMENTS,d=h/en.SEGMENTS;l=this.pushBand(l,a(u),a(d),o(u),o(d),c(u),c(d))}t.setDrawRange(0,l),t.getAttribute("position").needsUpdate=!0,t.getAttribute("color").needsUpdate=!0}pushBand(t,e,n,s,r,a,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(n,e))));for(let l=0;l<en.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,s,h),p=this.across(n,c,r,h),g=this.across(e,c,s,u),x=this.across(n,c,r,u),m=(f,A)=>f===0?A:0;t=this.push(t,d,m(h,a)),t=this.push(t,p,m(h,o)),t=this.push(t,g,m(u,a)),t=this.push(t,p,m(h,o)),t=this.push(t,x,m(u,o)),t=this.push(t,g,m(u,a))}return t}across(t,e,n,s){return{x:t.x+e.x*n*s,y:t.y+e.y*n*s,z:t.z+e.z*n*s}}push(t,e,n){const s=t*3;this.positions[s]=e.x,this.positions[s+1]=e.y,this.positions[s+2]=e.z;const r=Math.max(0,Math.min(1,n));return this.colors[s]=r*.55,this.colors[s+1]=r*.75,this.colors[s+2]=r,t+1}slerp(t,e,n){const s=this.angleBetweenRadians(t,e);if(s<1e-9)return t;const r=Math.sin(s),a=Math.sin((1-n)*s)/r,o=Math.sin(n*s)/r;return{x:t.x*a+e.x*o,y:t.y*a+e.y*o,z:t.z*a+e.z*o}}angleBetween(t,e){return this.angleBetweenRadians(t,e)*180/Math.PI}angleBetweenRadians(t,e){const n=t.x*e.x+t.y*e.y+t.z*e.z;return Math.acos(Math.min(1,Math.max(-1,n)))}scale(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}class Oe{static RED_NM=656.3;static BLUE_NM=435.8;static VIOLET_NM=400;static DEEP_RED_NM=700;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(Oe.ANCHOR_BLUE-Oe.ANCHOR_RED)/(1/(Oe.BLUE_NM*Oe.BLUE_NM)-1/(Oe.RED_NM*Oe.RED_NM));static A=Oe.ANCHOR_RED-Oe.B/(Oe.RED_NM*Oe.RED_NM);static indexAt(t){return Oe.A+Oe.B/(t*t)}}class Vi{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(t,e,n,s,r,a){let o=0,c=0,l=0;Math.abs(n)<.9?(o=-e,c=t,l=0):(o=0,c=-n,l=e);const h=Math.hypot(o,c,l)||1;o/=h,c/=h,l/=h;const u=e*l-n*c,d=n*o-t*l,p=t*c-e*o,g=r/2,x=a/2;for(let m=0;m<6;m++){const f=s+m*Math.PI/3,A=Math.cos(f),T=Math.sin(f);this.normals[m*3]=o*A+u*T,this.normals[m*3+1]=c*A+d*T,this.normals[m*3+2]=l*A+p*T,this.offsets[m]=g}this.normals[18]=t,this.normals[19]=e,this.normals[20]=n,this.offsets[6]=x,this.normals[21]=-t,this.normals[22]=-e,this.normals[23]=-n,this.offsets[7]=x,this.radius=Math.hypot(g,x)}get aimRadius(){return this.radius}trace(t,e,n,s,r,a,o){let c=-e,l=t,h=0,u=Math.hypot(c,l,h);u<1e-6&&(c=1,l=0,h=0,u=1),c/=u,l/=u,h/=u;const d=e*h-n*l,p=n*c-t*h,g=t*l-e*c,x=c*s+d*r-t*this.radius*2,m=l*s+p*r-e*this.radius*2,f=h*s+g*r-n*this.radius*2;let A=-1,T=-1/0,M=1/0;for(let j=0;j<8;j++){const it=this.normals[j*3],ut=this.normals[j*3+1],kt=this.normals[j*3+2],qt=it*t+ut*e+kt*n,Bt=this.offsets[j]-(it*x+ut*m+kt*f);if(qt>1e-9){const Y=Bt/qt;Y<M&&(M=Y)}else if(qt<-1e-9){const Y=Bt/qt;Y>T&&(T=Y,A=j)}else if(Bt<0)return 0}if(A<0||T>=M)return 0;let y=0;const b=this.normals[A*3],R=this.normals[A*3+1],v=this.normals[A*3+2],E=-(b*t+R*e+v*n),D=Vi.reflectance(E,1,a);o[y].x=t+2*E*b,o[y].y=e+2*E*R,o[y].z=n+2*E*v,o[y].weight=D,y++;const C=1/a,I=Math.sqrt(Math.max(0,1-C*C*(1-E*E)));let W=C*t+(C*E-I)*b,X=C*e+(C*E-I)*R,U=C*n+(C*E-I)*v,q=x+t*T,H=m+e*T,$=f+n*T,et=1-D;for(let j=0;j<Vi.MAX_BOUNCES&&et>Vi.MIN_WEIGHT;j++){let it=-1,ut=1/0;for(let z=0;z<8;z++){const bt=this.normals[z*3],Dt=this.normals[z*3+1],Tt=this.normals[z*3+2],vt=bt*W+Dt*X+Tt*U;if(vt<=1e-9)continue;const It=(this.offsets[z]-(bt*q+Dt*H+Tt*$))/vt;It>1e-9&&It<ut&&(ut=It,it=z)}if(it<0)break;const kt=this.normals[it*3],qt=this.normals[it*3+1],Bt=this.normals[it*3+2],Y=kt*W+qt*X+Bt*U,rt=a*Math.sqrt(Math.max(0,1-Y*Y));if(q+=W*ut,H+=X*ut,$+=U*ut,rt<1){const z=Math.sqrt(Math.max(0,1-rt*rt)),bt=Vi.reflectance(Y,a,1);if(o[y].x=a*W-(a*Y-z)*kt,o[y].y=a*X-(a*Y-z)*qt,o[y].z=a*U-(a*Y-z)*Bt,o[y].weight=et*(1-bt),y++,y>=o.length)return y;et*=bt}const nt=2*Y;W-=nt*kt,X-=nt*qt,U-=nt*Bt}return y}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4;static reflectance(t,e,n){const r=e/n*Math.sqrt(Math.max(0,1-t*t));if(r>=1)return 1;const a=Math.sqrt(Math.max(0,1-r*r)),o=(n*t-e*a)/(n*t+e*a),c=(e*t-n*a)/(e*t+n*a);return(o*o+c*c)/2}}class te{static AZIMUTH_BINS=512;static ALTITUDE_BINS=512;static POPULATIONS=[{orientation:"tumbling",widthMicrons:50,lengthMicrons:50,share:.52},{orientation:"plate",widthMicrons:100,lengthMicrons:15,share:.27},{orientation:"column",widthMicrons:40,lengthMicrons:120,share:.19},{orientation:"parry",widthMicrons:40,lengthMicrons:120,share:.02}];static WORST_TILT_DEG=180;static BEST_TILT_DEG=.5;static SOURCE_RADIUS_DEG=.265;static UNDEVIATED_DEG=.6;crystal=new Vi;emergent=Array.from({length:Vi.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(te.AZIMUTH_BINS*te.ALTITUDE_BINS*3);radiance=new Float32Array(te.AZIMUTH_BINS*te.ALTITUDE_BINS*3);scratch=new Float32Array(te.AZIMUTH_BINS*te.ALTITUDE_BINS*3);seed=1;spare=0;hasSpare=!1;altitude=0;tilt=0;alignment=0;traced=0;begin(t,e,n=2654435769){this.seed=n>>>0||1,this.hasSpare=!1,this.tally.fill(0),this.traced=0,this.altitude=t*Math.PI/180,this.alignment=Math.min(1,Math.max(0,e));const s=te.WORST_TILT_DEG*(te.BEST_TILT_DEG/te.WORST_TILT_DEG)**this.alignment;this.tilt=s*Math.PI/180}trace(t){const e=te.AZIMUTH_BINS,n=te.ALTITUDE_BINS,s=this.tally,r=te.SOURCE_RADIUS_DEG*Math.PI/180,a=Math.cos(te.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let c=0;c<t;c++){const l=this.pickPopulation();this.orient(l,this.tilt);const h=this.random()*2*Math.PI,u=r*Math.sqrt(this.random()),d=o+u*Math.sin(h),p=u*Math.cos(h)/Math.max(.05,Math.cos(o)),g=-Math.cos(d)*Math.cos(p),x=-Math.cos(d)*Math.sin(p),m=-Math.sin(d),f=this.crystal.aimRadius,A=(this.random()*2-1)*f,T=(this.random()*2-1)*f,M=4*f*f,y=te.SPECTRUM[this.random()*te.SPECTRUM.length|0],b=this.crystal.trace(g,x,m,A,T,Oe.indexAt(y.wavelengthNm),this.emergent);for(let R=0;R<b;R++){const v=this.emergent[R],E=Math.hypot(v.x,v.y,v.z);if(E<1e-9||v.weight<=0)continue;const D=v.x/E,C=v.y/E,I=v.z/E;if(D*g+C*x+I*m>a)continue;const W=Math.asin(Math.max(-1,Math.min(1,-I))),X=Math.abs(Math.atan2(-C,-D)),U=Math.min(e-1,X/Math.PI*e|0),H=(Math.min(n-1,(W+Math.PI/2)/Math.PI*n|0)*e+U)*3,$=v.weight*M*te.SPECTRUM.length;s[H]+=$*y.r,s[H+1]+=$*y.g,s[H+2]+=$*y.b}}this.traced+=t}get tracedRays(){return this.traced}harvest(){const t=te.AZIMUTH_BINS,e=te.ALTITUDE_BINS;return this.toRadiance(t,e),this.smooth(t,e),{width:t,height:e,data:this.radiance,sourceAltitudeDeg:this.altitude*180/Math.PI,alignment:this.alignment,rays:this.traced}}compute(t,e,n,s){return this.begin(t,e,s),this.trace(n),this.harvest()}toRadiance(t,e){const n=2*Math.PI/t,s=Math.max(1,this.traced),r=4*te.REFERENCE_MICRONS*te.REFERENCE_MICRONS;for(let a=0;a<e;a++){const o=Math.sin(a/e*Math.PI-Math.PI/2),c=Math.sin((a+1)/e*Math.PI-Math.PI/2),l=1/(n*(c-o)*s*r);for(let h=0;h<t;h++){const u=(a*t+h)*3;this.radiance[u]=this.tally[u]*l,this.radiance[u+1]=this.tally[u+1]*l,this.radiance[u+2]=this.tally[u+2]*l}}}static REFERENCE_MICRONS=50;smooth(t,e){const n=this.scratch,s=this.radiance;n.set(s);for(let a=0;a<e;a++){const o=a*t*3;for(let c=0;c<3;c++){let l=n[o+c];for(let h=0;h<t;h++){const u=o+h*3+c,d=h+1<t?n[u+3]:n[u];s[u]=(l+2*n[u]+d)/4,l=n[u]}}}n.set(s);const r=t*3;for(let a=0;a<e;a++){const o=a>0?-r:0,c=a+1<e?r:0,l=a*r;for(let h=l;h<l+r;h++)s[h]=(n[h+o]+2*n[h]+n[h+c])/4}}pickPopulation(){const t=this.random();let e=0;for(const n of te.POPULATIONS)if(e+=n.share,t<=e)return n;return te.POPULATIONS[te.POPULATIONS.length-1]}orient(t,e){const n=this.random()*2*Math.PI;let s=this.random()*2*Math.PI,r=0,a=0,o=1;switch(t.orientation){case"tumbling":{o=this.random()*2-1;const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n);break}case"plate":{o=this.spreadAboutAnAxis(e);const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n);break}case"column":case"parry":{o=this.spreadAboutAPlane(e);const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n),t.orientation==="parry"&&(s=Math.PI/2+this.gaussian()*e);break}}this.crystal.set(r,a,o,s,t.widthMicrons,t.lengthMicrons)}random(){this.seed=this.seed+1831565813>>>0;let t=this.seed;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}spreadAboutAnAxis(t){const e=1/Math.max(1e-6,t*t),n=Math.max(1e-12,this.random()),s=1+Math.log(n+(1-n)*Math.exp(-2*e))/e;return Math.max(-1,Math.min(1,s))}spreadAboutAPlane(t){for(let e=0;e<8;e++){const n=this.gaussian()*t;if(n>=-1&&n<=1)return n}return this.random()*2-1}gaussian(){if(this.hasSpare)return this.hasSpare=!1,this.spare;const t=Math.sqrt(-2*Math.log(Math.max(1e-12,this.random()))),e=2*Math.PI*this.random();return this.spare=t*Math.sin(e),this.hasSpare=!0,t*Math.cos(e)}static SPECTRUM=te.buildSpectrum(24);static buildSpectrum(t){const e=[];let n=0,s=0,r=0;for(let a=0;a<t;a++){const o=Oe.VIOLET_NM+(a+.5)/t*(Oe.DEEP_RED_NM-Oe.VIOLET_NM),[c,l,h]=te.colourMatching(o),u={wavelengthNm:o,r:Math.max(0,3.2406*c-1.5372*l-.4986*h),g:Math.max(0,-.9689*c+1.8758*l+.0415*h),b:Math.max(0,.0557*c-.204*l+1.057*h)};n+=u.r,s+=u.g,r+=u.b,e.push(u)}for(const a of e)a.r/=n,a.g/=s,a.b/=r;return e}static colourMatching(t){const e=(n,s,r)=>{const a=(t-n)/(t<n?s:r);return Math.exp(-.5*a*a)};return[1.056*e(599.8,37.9,31)+.362*e(442,16,26.7)-.065*e(501.1,20.4,26.2),.821*e(568.8,46.9,40.5)+.286*e(530.9,16.3,31.1),1.217*e(437,11.8,36)+.681*e(459,26,13.8)]}}class Pn{static RADIUS=880;static RAYS=9e5;static RAYS_PER_FRAME=4e3;static FIRST_GLIMPSE_RAYS=5e4;static ALTITUDE_STEP_DEG=1;static GAIN=.55;object;material;sky=new te;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;refining=!0;nextGlimpse=Pn.FIRST_GLIMPSE_RAYS;workHandle;onRepaint;constructor(){const t=te.AZIMUTH_BINS,e=te.ALTITUDE_BINS;this.texels=new Uint16Array(t*e*4),this.texture=new td(this.texels,t,e,pn,bn),this.texture.minFilter=Ne,this.texture.magFilter=Ne,this.texture.wrapS=Sn,this.texture.wrapT=Sn,this.texture.needsUpdate=!0,this.material=new Be({uniforms:{uSource:{value:new F(0,1,0)},uUp:{value:new F(0,1,0)},uStrength:{value:0},uTint:{value:new F(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uMap:{value:this.texture},uGain:{value:Pn.GAIN}},vertexShader:`
5168
+ `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new se(new qs(2,2),this.material))}directionFor(t,e,n){const s=this.width/this.height,r=n/2*Math.PI/180,a=t*s*r,o=e*r,c=Math.hypot(a,o);if(c<1e-6)return{x:0,y:0,z:-1};const l=Math.sin(c);return{x:a/c*l,y:o/c*l,z:-Math.cos(c)}}static cornerHalfAngleDeg(t,e){return t/2*Math.hypot(e,1)}static supports(t,e){return this.cornerHalfAngleDeg(t,e)<=this.MAX_HALF_ANGLE_DEG}resize(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height),this.material.uniforms.uAspect.value=this.width/this.height}render(t,e,n,s,r){const a=this.width/this.height;this.material.uniforms.uHalfFovRad.value=s/2*Math.PI/180,this.material.uniforms.uSrcTanHalfFovY.value=this.sourceTanHalfFovY(s,a);const o=n.fov;n.fov=this.sourceFovDeg(s,a),n.updateProjectionMatrix(),r?.();const c=t.getRenderTarget();t.setRenderTarget(this.target),t.render(e,n),t.setRenderTarget(c),n.fov=o,n.updateProjectionMatrix(),t.render(this.quadScene,this.quadCamera)}sourceFovDeg(t,e){return Math.atan(this.sourceTanHalfFovY(t,e))*360/Math.PI}sourceTanHalfFovY(t,e){const n=Ya.cornerHalfAngleDeg(t,e)*Math.PI/180;return Math.tan(n)/Math.hypot(e,1)}dispose(){this.target.dispose(),this.material.dispose(),this.quadScene.clear()}}class $t{static ICE_INDEX_RED=1.3067;static ICE_INDEX_BLUE=1.317;static SIDE_PRISM_ANGLE_DEG=60;static END_PRISM_ANGLE_DEG=90;static get PARHELIA_MAX_SUN_ALTITUDE_DEG(){const t=$t.ICE_INDEX_RED,e=Math.sqrt((4-t*t)/3);return Math.asin(Math.min(1,e))*180/Math.PI}static minimumDeviationDeg(t,e){const n=t*Math.PI/180,s=e*Math.sin(n/2);return s>1?Number.NaN:(2*Math.asin(s)-n)*180/Math.PI}static effectiveIndex(t,e){const n=e*Math.PI/180,s=Math.cos(n);return s<=0?Number.POSITIVE_INFINITY:Math.sqrt(t*t-Math.sin(n)**2)/s}static parheliaAzimuthDeg(t,e=$t.ICE_INDEX_RED){const n=$t.minimumDeviationDeg($t.SIDE_PRISM_ANGLE_DEG,$t.effectiveIndex(e,t));return Number.isFinite(n)?n:void 0}static parheliaDistanceDeg(t,e=$t.ICE_INDEX_RED){const n=$t.parheliaAzimuthDeg(t,e);if(n===void 0)return;const s=t*Math.PI/180,r=Math.sin(s)**2,a=Math.cos(s)**2*Math.cos(n*Math.PI/180);return Math.acos(Math.max(-1,Math.min(1,r+a)))*180/Math.PI}static get PLATE_END_FACE_LIMIT_DEG(){const t=$t.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(t*t-1)))*180/Math.PI}static circumzenithalAltitudeDeg(t,e=$t.ICE_INDEX_RED){if(t<0||t>90-$t.PLATE_END_FACE_LIMIT_DEG)return;const n=Math.cos(t*Math.PI/180),s=Math.sqrt(e*e-n*n);if(!(s>=1))return Math.asin(s)*180/Math.PI}static DECK_HEIGHT_M=8e3;static deckLitUntilDeg(t){return Math.acos(6371e3/(6371e3+Math.max(0,t)))*180/Math.PI}static halo22(){return $t.ringOf("halo22",$t.SIDE_PRISM_ANGLE_DEG)}static halo46(){return $t.ringOf("halo46",$t.END_PRISM_ANGLE_DEG)}static ringOf(t,e){const n=$t.minimumDeviationDeg(e,$t.ICE_INDEX_RED),s=$t.minimumDeviationDeg(e,$t.ICE_INDEX_BLUE);return{id:t,angleDeg:(n+s)/2,redAngleDeg:n,blueAngleDeg:s}}static strength(t,e,n=90,s=0){const r=Math.max(0,Math.min(1,t)),a=Math.max(0,1-Math.max(0,Math.min(1,e))),o=n>=0?1:s<=0?0:Math.max(0,1+n/s);return r*a*o}static formsAt(t,e=0){if(t<=-e)return[];const n=[$t.halo22(),$t.halo46()],s=t>0?$t.parheliaDistanceDeg(t):void 0;s!==void 0&&n.push({id:"parhelia",angleDeg:s,redAngleDeg:s,blueAngleDeg:$t.parheliaDistanceDeg(t,$t.ICE_INDEX_BLUE)}),n.push({id:"tangentArc",angleDeg:$t.halo22().angleDeg}),t>0&&n.push({id:"parhelicCircle",angleDeg:t});const r=$t.circumzenithalAltitudeDeg(t);return r!==void 0&&n.push({id:"circumzenithal",angleDeg:r}),t>$t.PLATE_END_FACE_LIMIT_DEG&&n.push({id:"circumhorizontal"}),t<$t.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&n.push({id:"pillar"}),n}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class Ka{static reflectance(t,e,n){const r=e/n*Math.sqrt(Math.max(0,1-t*t));if(r>=1)return 1;const a=Math.sqrt(Math.max(0,1-r*r)),o=(n*t-e*a)/(n*t+e*a),c=(e*t-n*a)/(e*t+n*a);return(o*o+c*c)/2}}class Oe{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(Oe.ANCHOR_BLUE-Oe.ANCHOR_RED)/(1/(Oe.BLUE_NM*Oe.BLUE_NM)-1/(Oe.RED_NM*Oe.RED_NM));static A=Oe.ANCHOR_RED-Oe.B/(Oe.RED_NM*Oe.RED_NM);static indexAt(t){return Oe.A+Oe.B/(t*t)}}class Bs{static MAX_CHORDS=4;index=1.333;set refractiveIndex(t){this.index=t}trace(t,e){const n=Math.min(1,Math.max(0,t)),s=Math.sqrt(Math.max(0,1-n*n)),r=n/this.index,a=Math.sqrt(Math.max(0,1-r*r)),o=Math.asin(n),c=Math.asin(r),l=Ka.reflectance(s,1,this.index);let h=0;e[h].chords=0,e[h].scatteringAngle=Bs.folded(Math.PI-2*o),e[h].weight=l,h++;const u=Ka.reflectance(a,this.index,1);let d=1-l;for(let f=1;f<=Bs.MAX_CHORDS&&h<e.length;f++){const g=2*(o-c)+(f-1)*(Math.PI-2*c);e[h].chords=f,e[h].scatteringAngle=Bs.folded(g),e[h].weight=d*(1-u),h++,d*=u}return h}static folded(t){const e=2*Math.PI;let n=t%e;return n<0&&(n+=e),n>Math.PI?e-n:n}}class je{static get WATER_INDEX_RED(){return Oe.indexAt(Oe.RED_NM)}static get WATER_INDEX_BLUE(){return Oe.indexAt(Oe.BLUE_NM)}static radiusDeg(t,e){const n=(e*e-1)/(t*t-1);if(n<0||n>1)return Number.NaN;const s=Math.acos(Math.sqrt(n)),r=Math.asin(Math.sin(s)/e),a=2*(s-r)+(t-1)*(Math.PI-2*r),o=2*Math.PI;let c=a%o;return c<0&&(c+=o),c>Math.PI&&(c=o-c),180-c*180/Math.PI}static primary(){return je.bowOf("primary",2,0)}static secondary(){return je.bowOf("secondary",3,0)}static bowOf(t,e,n){const s=je.radiusDeg(e,je.WATER_INDEX_RED),r=je.radiusDeg(e,je.WATER_INDEX_BLUE),a=(s+r)/2;return{id:t,radiusDeg:a,redRadiusDeg:s,violetRadiusDeg:r,topAltitudeDeg:a-n}}static alexandersBandDeg(){return{fromDeg:je.primary().redRadiusDeg,toDeg:je.secondary().redRadiusDeg}}static formsAt(t){return t<0?[]:[je.bowOf("primary",2,t),je.bowOf("secondary",3,t)].filter(e=>e.topAltitudeDeg>0)}static FULL_MOON_MAGNITUDE=-12.7;static moonlightShare(t){return Math.min(1,10**(-.4*(t-je.FULL_MOON_MAGNITUDE)))}static strength(t,e,n){if(n<=0)return 0;const s=Math.max(0,Math.min(1,t)),r=Math.max(0,1-Math.max(0,Math.min(1,e)));return s*r}}class rn{constructor(t){this.radius=t;const e=rn.SEGMENTS*rn.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const n=new Ee;n.setAttribute("position",new le(this.positions,3)),n.setAttribute("color",new le(this.colors,3)),n.setDrawRange(0,0),this.object=new se(n,new Ji({vertexColors:!0,transparent:!0,blending:Ri,depthWrite:!1,fog:!1,side:An})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=rn.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(rn.ACROSS-1)*6;static HEAD_HALF_WIDTH_DEG=.15;static SPREAD_FRACTION=.05;static FADE_POWER=1.8;object;positions;colors;head;tip;brightness=0;set(t,e,n){this.head=t&&an(t.altitudeDeg,t.azimuthDeg,1),this.tip=e&&an(e.altitudeDeg,e.azimuthDeg,1),this.brightness=n,this.rebuild()}rebuild(){const t=this.object.geometry,e=this.head,n=this.tip;if(!e||!n||this.brightness<=0){t.setDrawRange(0,0);return}const s=this.angleBetween(e,n);if(s<=0){t.setDrawRange(0,0);return}const r=s*rn.SPREAD_FRACTION*Math.PI/180,a=h=>this.scale(this.slerp(e,n,h),this.radius),o=h=>this.radius*(rn.HEAD_HALF_WIDTH_DEG*Math.PI/180+r*h),c=h=>this.brightness*(1-h)**rn.FADE_POWER;let l=0;for(let h=1;h<rn.POINTS;h++){const u=(h-1)/rn.SEGMENTS,d=h/rn.SEGMENTS;l=this.pushBand(l,a(u),a(d),o(u),o(d),c(u),c(d))}t.setDrawRange(0,l),t.getAttribute("position").needsUpdate=!0,t.getAttribute("color").needsUpdate=!0}pushBand(t,e,n,s,r,a,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(n,e))));for(let l=0;l<rn.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,s,h),f=this.across(n,c,r,h),g=this.across(e,c,s,u),x=this.across(n,c,r,u),m=(p,A)=>p===0?A:0;t=this.push(t,d,m(h,a)),t=this.push(t,f,m(h,o)),t=this.push(t,g,m(u,a)),t=this.push(t,f,m(h,o)),t=this.push(t,x,m(u,o)),t=this.push(t,g,m(u,a))}return t}across(t,e,n,s){return{x:t.x+e.x*n*s,y:t.y+e.y*n*s,z:t.z+e.z*n*s}}push(t,e,n){const s=t*3;this.positions[s]=e.x,this.positions[s+1]=e.y,this.positions[s+2]=e.z;const r=Math.max(0,Math.min(1,n));return this.colors[s]=r*.55,this.colors[s+1]=r*.75,this.colors[s+2]=r,t+1}slerp(t,e,n){const s=this.angleBetweenRadians(t,e);if(s<1e-9)return t;const r=Math.sin(s),a=Math.sin((1-n)*s)/r,o=Math.sin(n*s)/r;return{x:t.x*a+e.x*o,y:t.y*a+e.y*o,z:t.z*a+e.z*o}}angleBetween(t,e){return this.angleBetweenRadians(t,e)*180/Math.PI}angleBetweenRadians(t,e){const n=t.x*e.x+t.y*e.y+t.z*e.z;return Math.acos(Math.min(1,Math.max(-1,n)))}scale(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}class Qe{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(Qe.ANCHOR_BLUE-Qe.ANCHOR_RED)/(1/(Qe.BLUE_NM*Qe.BLUE_NM)-1/(Qe.RED_NM*Qe.RED_NM));static A=Qe.ANCHOR_RED-Qe.B/(Qe.RED_NM*Qe.RED_NM);static indexAt(t){return Qe.A+Qe.B/(t*t)}}class br{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(t,e,n,s,r,a){let o=0,c=0,l=0;Math.abs(n)<.9?(o=-e,c=t,l=0):(o=0,c=-n,l=e);const h=Math.hypot(o,c,l)||1;o/=h,c/=h,l/=h;const u=e*l-n*c,d=n*o-t*l,f=t*c-e*o,g=r/2,x=a/2;for(let m=0;m<6;m++){const p=s+m*Math.PI/3,A=Math.cos(p),T=Math.sin(p);this.normals[m*3]=o*A+u*T,this.normals[m*3+1]=c*A+d*T,this.normals[m*3+2]=l*A+f*T,this.offsets[m]=g}this.normals[18]=t,this.normals[19]=e,this.normals[20]=n,this.offsets[6]=x,this.normals[21]=-t,this.normals[22]=-e,this.normals[23]=-n,this.offsets[7]=x,this.radius=Math.hypot(g,x)}get aimRadius(){return this.radius}trace(t,e,n,s,r,a,o){let c=-e,l=t,h=0,u=Math.hypot(c,l,h);u<1e-6&&(c=1,l=0,h=0,u=1),c/=u,l/=u,h/=u;const d=e*h-n*l,f=n*c-t*h,g=t*l-e*c,x=c*s+d*r-t*this.radius*2,m=l*s+f*r-e*this.radius*2,p=h*s+g*r-n*this.radius*2;let A=-1,T=-1/0,M=1/0;for(let j=0;j<8;j++){const it=this.normals[j*3],ut=this.normals[j*3+1],kt=this.normals[j*3+2],qt=it*t+ut*e+kt*n,Bt=this.offsets[j]-(it*x+ut*m+kt*p);if(qt>1e-9){const Y=Bt/qt;Y<M&&(M=Y)}else if(qt<-1e-9){const Y=Bt/qt;Y>T&&(T=Y,A=j)}else if(Bt<0)return 0}if(A<0||T>=M)return 0;let y=0;const b=this.normals[A*3],R=this.normals[A*3+1],v=this.normals[A*3+2],E=-(b*t+R*e+v*n),D=Ka.reflectance(E,1,a);o[y].x=t+2*E*b,o[y].y=e+2*E*R,o[y].z=n+2*E*v,o[y].weight=D,y++;const C=1/a,I=Math.sqrt(Math.max(0,1-C*C*(1-E*E)));let W=C*t+(C*E-I)*b,X=C*e+(C*E-I)*R,U=C*n+(C*E-I)*v,q=x+t*T,H=m+e*T,$=p+n*T,et=1-D;for(let j=0;j<br.MAX_BOUNCES&&et>br.MIN_WEIGHT;j++){let it=-1,ut=1/0;for(let z=0;z<8;z++){const bt=this.normals[z*3],Dt=this.normals[z*3+1],Tt=this.normals[z*3+2],vt=bt*W+Dt*X+Tt*U;if(vt<=1e-9)continue;const It=(this.offsets[z]-(bt*q+Dt*H+Tt*$))/vt;It>1e-9&&It<ut&&(ut=It,it=z)}if(it<0)break;const kt=this.normals[it*3],qt=this.normals[it*3+1],Bt=this.normals[it*3+2],Y=kt*W+qt*X+Bt*U,rt=a*Math.sqrt(Math.max(0,1-Y*Y));if(q+=W*ut,H+=X*ut,$+=U*ut,rt<1){const z=Math.sqrt(Math.max(0,1-rt*rt)),bt=Ka.reflectance(Y,a,1);if(o[y].x=a*W-(a*Y-z)*kt,o[y].y=a*X-(a*Y-z)*qt,o[y].z=a*U-(a*Y-z)*Bt,o[y].weight=et*(1-bt),y++,y>=o.length)return y;et*=bt}const nt=2*Y;W-=nt*kt,X-=nt*qt,U-=nt*Bt}return y}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class Tn{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=Tn.build(24);static build(t){const e=[];let n=0,s=0,r=0;for(let a=0;a<t;a++){const o=Tn.VIOLET_NM+(a+.5)/t*(Tn.DEEP_RED_NM-Tn.VIOLET_NM),[c,l,h]=Tn.colourMatching(o),u={wavelengthNm:o,r:Math.max(0,3.2406*c-1.5372*l-.4986*h),g:Math.max(0,-.9689*c+1.8758*l+.0415*h),b:Math.max(0,.0557*c-.204*l+1.057*h)};n+=u.r,s+=u.g,r+=u.b,e.push(u)}for(const a of e)a.r/=n,a.g/=s,a.b/=r;return e}static colourMatching(t){const e=(n,s,r)=>{const a=(t-n)/(t<n?s:r);return Math.exp(-.5*a*a)};return[1.056*e(599.8,37.9,31)+.362*e(442,16,26.7)-.065*e(501.1,20.4,26.2),.821*e(568.8,46.9,40.5)+.286*e(530.9,16.3,31.1),1.217*e(437,11.8,36)+.681*e(459,26,13.8)]}}class fe{static AZIMUTH_BINS=512;static ALTITUDE_BINS=512;static POPULATIONS=[{orientation:"tumbling",widthMicrons:50,lengthMicrons:50,share:.52},{orientation:"plate",widthMicrons:100,lengthMicrons:15,share:.27},{orientation:"column",widthMicrons:40,lengthMicrons:120,share:.19},{orientation:"parry",widthMicrons:40,lengthMicrons:120,share:.02}];static WORST_TILT_DEG=180;static BEST_TILT_DEG=.5;static SOURCE_RADIUS_DEG=.265;static UNDEVIATED_DEG=.6;crystal=new br;emergent=Array.from({length:br.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(fe.AZIMUTH_BINS*fe.ALTITUDE_BINS*3);radiance=new Float32Array(fe.AZIMUTH_BINS*fe.ALTITUDE_BINS*3);scratch=new Float32Array(fe.AZIMUTH_BINS*fe.ALTITUDE_BINS*3);seed=1;spare=0;hasSpare=!1;altitude=0;tilt=0;alignment=0;traced=0;begin(t,e,n=2654435769){this.seed=n>>>0||1,this.hasSpare=!1,this.tally.fill(0),this.traced=0,this.altitude=t*Math.PI/180,this.alignment=Math.min(1,Math.max(0,e));const s=fe.WORST_TILT_DEG*(fe.BEST_TILT_DEG/fe.WORST_TILT_DEG)**this.alignment;this.tilt=s*Math.PI/180}trace(t){const e=fe.AZIMUTH_BINS,n=fe.ALTITUDE_BINS,s=this.tally,r=fe.SOURCE_RADIUS_DEG*Math.PI/180,a=Math.cos(fe.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let c=0;c<t;c++){const l=this.pickPopulation();this.orient(l,this.tilt);const h=this.random()*2*Math.PI,u=r*Math.sqrt(this.random()),d=o+u*Math.sin(h),f=u*Math.cos(h)/Math.max(.05,Math.cos(o)),g=-Math.cos(d)*Math.cos(f),x=-Math.cos(d)*Math.sin(f),m=-Math.sin(d),p=this.crystal.aimRadius,A=(this.random()*2-1)*p,T=(this.random()*2-1)*p,M=4*p*p,y=Tn.SAMPLES[this.random()*Tn.SAMPLES.length|0],b=this.crystal.trace(g,x,m,A,T,Qe.indexAt(y.wavelengthNm),this.emergent);for(let R=0;R<b;R++){const v=this.emergent[R],E=Math.hypot(v.x,v.y,v.z);if(E<1e-9||v.weight<=0)continue;const D=v.x/E,C=v.y/E,I=v.z/E;if(D*g+C*x+I*m>a)continue;const W=Math.asin(Math.max(-1,Math.min(1,-I))),X=Math.abs(Math.atan2(-C,-D)),U=Math.min(e-1,X/Math.PI*e|0),H=(Math.min(n-1,(W+Math.PI/2)/Math.PI*n|0)*e+U)*3,$=v.weight*M*Tn.SAMPLES.length;s[H]+=$*y.r,s[H+1]+=$*y.g,s[H+2]+=$*y.b}}this.traced+=t}get tracedRays(){return this.traced}harvest(){const t=fe.AZIMUTH_BINS,e=fe.ALTITUDE_BINS;return this.toRadiance(t,e),this.smooth(t,e),{width:t,height:e,data:this.radiance,sourceAltitudeDeg:this.altitude*180/Math.PI,alignment:this.alignment,rays:this.traced}}compute(t,e,n,s){return this.begin(t,e,s),this.trace(n),this.harvest()}toRadiance(t,e){const n=2*Math.PI/t,s=Math.max(1,this.traced),r=4*fe.REFERENCE_MICRONS*fe.REFERENCE_MICRONS;for(let a=0;a<e;a++){const o=Math.sin(a/e*Math.PI-Math.PI/2),c=Math.sin((a+1)/e*Math.PI-Math.PI/2),l=1/(n*(c-o)*s*r);for(let h=0;h<t;h++){const u=(a*t+h)*3;this.radiance[u]=this.tally[u]*l,this.radiance[u+1]=this.tally[u+1]*l,this.radiance[u+2]=this.tally[u+2]*l}}}static REFERENCE_MICRONS=50;smooth(t,e){const n=this.scratch,s=this.radiance;n.set(s);for(let a=0;a<e;a++){const o=a*t*3;for(let c=0;c<3;c++){let l=n[o+c];for(let h=0;h<t;h++){const u=o+h*3+c,d=h+1<t?n[u+3]:n[u];s[u]=(l+2*n[u]+d)/4,l=n[u]}}}n.set(s);const r=t*3;for(let a=0;a<e;a++){const o=a>0?-r:0,c=a+1<e?r:0,l=a*r;for(let h=l;h<l+r;h++)s[h]=(n[h+o]+2*n[h]+n[h+c])/4}}pickPopulation(){const t=this.random();let e=0;for(const n of fe.POPULATIONS)if(e+=n.share,t<=e)return n;return fe.POPULATIONS[fe.POPULATIONS.length-1]}orient(t,e){const n=this.random()*2*Math.PI;let s=this.random()*2*Math.PI,r=0,a=0,o=1;switch(t.orientation){case"tumbling":{o=this.random()*2-1;const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n);break}case"plate":{o=this.spreadAboutAnAxis(e);const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n);break}case"column":case"parry":{o=this.spreadAboutAPlane(e);const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n),t.orientation==="parry"&&(s=Math.PI/2+this.gaussian()*e);break}}this.crystal.set(r,a,o,s,t.widthMicrons,t.lengthMicrons)}random(){this.seed=this.seed+1831565813>>>0;let t=this.seed;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}spreadAboutAnAxis(t){const e=1/Math.max(1e-6,t*t),n=Math.max(1e-12,this.random()),s=1+Math.log(n+(1-n)*Math.exp(-2*e))/e;return Math.max(-1,Math.min(1,s))}spreadAboutAPlane(t){for(let e=0;e<8;e++){const n=this.gaussian()*t;if(n>=-1&&n<=1)return n}return this.random()*2-1}gaussian(){if(this.hasSpare)return this.hasSpare=!1,this.spare;const t=Math.sqrt(-2*Math.log(Math.max(1e-12,this.random()))),e=2*Math.PI*this.random();return this.spare=t*Math.sin(e),this.hasSpare=!0,t*Math.cos(e)}}class Fn{static RADIUS=880;static RAYS=9e5;static RAYS_PER_FRAME=4e3;static FIRST_GLIMPSE_RAYS=5e4;static ALTITUDE_STEP_DEG=1;static GAIN=.55;object;material;sky=new fe;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;refining=!0;nextGlimpse=Fn.FIRST_GLIMPSE_RAYS;workHandle;onRepaint;constructor(){const t=fe.AZIMUTH_BINS,e=fe.ALTITUDE_BINS;this.texels=new Uint16Array(t*e*4),this.texture=new Zl(this.texels,t,e,un,xn),this.texture.minFilter=we,this.texture.magFilter=we,this.texture.wrapS=hn,this.texture.wrapT=hn,this.texture.needsUpdate=!0,this.material=new Be({uniforms:{uSource:{value:new F(0,1,0)},uUp:{value:new F(0,1,0)},uStrength:{value:0},uTint:{value:new F(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uMap:{value:this.texture},uGain:{value:Fn.GAIN}},vertexShader:`
5169
5169
  varying vec3 vDirection;
5170
5170
  void main() {
5171
5171
  vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
@@ -5173,8 +5173,8 @@ void main()
5173
5173
  }
5174
5174
  `,fragmentShader:`
5175
5175
  precision highp float;
5176
- ${Vd}
5177
- ${S3}
5176
+ ${$d}
5177
+ ${R3}
5178
5178
  varying vec3 vDirection;
5179
5179
  uniform vec3 uSource;
5180
5180
  uniform vec3 uUp;
@@ -5215,7 +5215,35 @@ void main()
5215
5215
  // display fades at the edge of a fibre instead of ending on a cut line.
5216
5216
  gl_FragColor = vec4(light * uStrength * (0.25 + 0.75 * ice), 1.0);
5217
5217
  }
5218
- `,transparent:!0,blending:Xi,depthWrite:!1,side:Fe,fog:!1}),this.object=new oe(new Wn(Pn.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}set onReady(t){this.onRepaint=t}update(t,e,n,s,r,a){const o=this.material.uniforms;if(n<=0){o.uStrength.value=0,this.object.visible=!1,this.stopWork();return}o.uSource.value.set(t.x,t.y,t.z).normalize(),o.uStrength.value=n,o.uTint.value.set(s[0],s[1],s[2]),o.uIceCover.value=r.cover,o.uIceHeight.value=r.layerHeight,this.object.visible=this.everDisplayed,this.requestMap(e,a)}requestMap(t,e){!(!(Math.abs(t-this.mappedAltitudeDeg)<Pn.ALTITUDE_STEP_DEG)||e!==this.mappedAlignment)||this.tracingFor(t,e)||(this.pendingAltitudeDeg=t,this.pendingAlignment=e,this.sky.begin(t,e),this.tracing=!0,this.nextGlimpse=Pn.FIRST_GLIMPSE_RAYS,this.scheduleWork())}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;tracingFor(t,e){return this.tracing&&Math.abs(t-this.pendingAltitudeDeg)<Pn.ALTITUDE_STEP_DEG&&e===this.pendingAlignment}scheduleWork(){if(this.workHandle!==void 0)return;const t=()=>{if(this.workHandle=void 0,!this.tracing)return;this.sky.trace(Pn.RAYS_PER_FRAME);const e=this.sky.tracedRays>=Pn.RAYS,n=this.refining&&this.sky.tracedRays>=this.nextGlimpse;if(n&&(this.nextGlimpse*=2),(e||n)&&this.publish(),e){this.tracing=!1,this.refining=!1,this.mappedAltitudeDeg=this.pendingAltitudeDeg,this.mappedAlignment=this.pendingAlignment;return}this.workHandle=requestAnimationFrame(t)};this.workHandle=requestAnimationFrame(t)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0,this.tracing=!1}publish(){const e=this.sky.harvest().data;for(let n=0,s=0;s<e.length;n+=4,s+=3)this.texels[n]=Eo.toHalfFloat(e[s]),this.texels[n+1]=Eo.toHalfFloat(e[s+1]),this.texels[n+2]=Eo.toHalfFloat(e[s+2]),this.texels[n+3]=1;this.texture.needsUpdate=!0,this.everDisplayed=!0,this.object.visible=this.material.uniforms.uStrength.value>0,this.onRepaint?.()}dispose(){this.stopWork(),this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class Wd{constructor(t){this.state=t}next(){this.state=this.state+1831565813|0;let t=this.state;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}between(t,e){return t+this.next()*(e-t)}}class Wi{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(t){const{ratePerHour:e,durationMs:n,velocityKmS:s,seed:r}=t;if(e<=0||n<=0)return[];const a=e*n/36e5,o=new Wd(r),c=Math.floor(a),l=c+(o.next()<a-c?1:0),h=[];for(let u=0;u<l;u++){const d=Math.min(1,Math.max(0,(s-20)/52)),p=Wi.MAX_DURATION_MS-d*(Wi.MAX_DURATION_MS-Wi.MIN_DURATION_MS),g=o.between(5,70);h.push({t:o.between(0,n),durationMs:p*o.between(.7,1.3),fromRadiantDeg:g,bearingDeg:o.between(0,360),lengthDeg:Math.sin(g*Math.PI/180)*o.between(8,40)*(.6+d),brightness:o.next()**3}),h.sort((x,m)=>x.t-m.t)}return h}static aliveAt(t,e){return t.filter(n=>e>=n.t&&e<=n.t+n.durationMs).map(n=>({meteor:n,progress:(e-n.t)/n.durationMs}))}}class Le{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=Le.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(Le.ACROSS-1)*6;static RADIUS=840;static MIN_HALF_WIDTH_DEG=.05;static BRIGHT_HALF_WIDTH_DEG=.22;object;positions;colors;meteors=[];radiantAltitudeDeg=0;radiantAzimuthDeg=0;constructor(){const t=Le.MAX_CONCURRENT*Le.SEGMENTS*Le.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const e=new ye;e.setAttribute("position",new he(this.positions,3)),e.setAttribute("color",new he(this.colors,3)),e.setDrawRange(0,0),this.object=new oe(e,new Ki({vertexColors:!0,transparent:!0,blending:Xi,depthWrite:!1,fog:!1,side:Mn})),this.object.frustumCulled=!1}get schedule(){return this.meteors}setShower(t,e,n){this.meteors=t,this.radiantAltitudeDeg=e,this.radiantAzimuthDeg=n}update(t){const e=this.object.geometry;if(this.meteors.length===0){e.setDrawRange(0,0);return}const n=Wi.aliveAt(this.meteors,t).slice(0,Le.MAX_CONCURRENT);let s=0;for(const{meteor:r,progress:a}of n){const o=this.radiantOf(r);if(!o)continue;const c=un(o.altitudeDeg,o.azimuthDeg,1),[l,h]=this.basisAround(c),u=r.fromRadiantDeg+a*r.lengthDeg,d=Math.max(r.fromRadiantDeg,u-r.lengthDeg*.6),p=Math.min(1,(1-a)*2.5),g=this.turn(l,h,r.bearingDeg),x=(.15+.85*r.brightness)*p,m=T=>x*T**1.6,f=T=>this.onSphere(c,g,d+(u-d)*T),A=T=>Le.RADIUS*((Le.MIN_HALF_WIDTH_DEG+Le.BRIGHT_HALF_WIDTH_DEG*r.brightness*T)*Math.PI/180);for(let T=1;T<Le.POINTS;T++){const M=(T-1)/Le.SEGMENTS,y=T/Le.SEGMENTS;s=this.pushRibbon(s,f(M),f(y),A(M),A(y),m(M),m(y))}}e.setDrawRange(0,s),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}midpointOf(t){const e=this.radiantOf(t);if(!e)return;const n=un(e.altitudeDeg,e.azimuthDeg,1),[s,r]=this.basisAround(n),a=this.turn(s,r,t.bearingDeg),o=this.onSphere(n,a,t.fromRadiantDeg+t.lengthDeg/2),c=Math.hypot(o.x,o.y,o.z)||1;return{altitudeDeg:Math.asin(o.y/c)*180/Math.PI,azimuthDeg:(Math.atan2(o.x,-o.z)*180/Math.PI+360)%360}}radiantOf(t){return t.radiant?t.radiant:this.radiantAltitudeDeg>0?{altitudeDeg:this.radiantAltitudeDeg,azimuthDeg:this.radiantAzimuthDeg}:void 0}pushRibbon(t,e,n,s,r,a,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(n,e))));for(let l=0;l<Le.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,s,h),p=this.across(n,c,r,h),g=this.across(e,c,s,u),x=this.across(n,c,r,u),m=(f,A)=>f===0?A:0;t=this.push(t,d,m(h,a)),t=this.push(t,p,m(h,o)),t=this.push(t,g,m(u,a)),t=this.push(t,p,m(h,o)),t=this.push(t,x,m(u,o)),t=this.push(t,g,m(u,a))}return t}across(t,e,n,s){return{x:t.x+e.x*n*s,y:t.y+e.y*n*s,z:t.z+e.z*n*s}}push(t,e,n){const s=t*3;this.positions[s]=e.x,this.positions[s+1]=e.y,this.positions[s+2]=e.z;const r=Math.max(0,Math.min(1,n));return this.colors[s]=r*.9,this.colors[s+1]=r*.95,this.colors[s+2]=r,t+1}turn(t,e,n){const s=n*Math.PI/180,r=Math.cos(s),a=Math.sin(s);return{x:t.x*r+e.x*a,y:t.y*r+e.y*a,z:t.z*r+e.z*a}}onSphere(t,e,n){const s=n*Math.PI/180,r=Math.cos(s),a=Math.sin(s);return{x:(t.x*r+e.x*a)*Le.RADIUS,y:(t.y*r+e.y*a)*Le.RADIUS,z:(t.z*r+e.z*a)*Le.RADIUS}}basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=this.normalise(this.cross(t,e));return[n,this.normalise(this.cross(t,n))]}subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}const R3=2;function C3(i){return i==="building"||i==="vehicle"}function D3(i,t){const e=i.litKeyframes;if(!e||e.length===0)return i.lit??!1;let n=e[0];for(const s of e){if(s.t>t)break;n=s}return n.lit}function P3(i,t){return i.pattern.kind==="steady"?!0:I3(i,t,t+1)>.5}function I3(i,t,e){if(i.pattern.kind==="steady")return 1;const{perMinute:n,dutyCycle:s,phase:r=0}=i.pattern,a=Math.min(Math.max(s,0),1);if(a===0||n<=0)return 0;const o=6e4/n,c=t/o+r,l=e/o+r;if(l<=c)return Math.min(Math.max(c-Math.floor(c),0),a)<a?1:0;const h=u=>Math.floor(u)*a+Math.min(u-Math.floor(u),a);return(h(l)-h(c))/(l-c)}function L3(i,t){const e=i.track,n={eastM:i.eastM,northM:i.northM,altitudeM:0,headingDeg:i.headingDeg};if(!e||e.length===0)return n;if(e.length===1||t<=e[0].t)return qu(e[0],i);const s=e[e.length-1];if(t>=s.t)return qu(s,i);for(let r=0;r<e.length-1;r++){const a=e[r],o=e[r+1];if(t<a.t||t>o.t)continue;const c=o.t-a.t,l=c===0?0:(t-a.t)/c;return{eastM:a.eastM+(o.eastM-a.eastM)*l,northM:a.northM+(o.northM-a.northM)*l,altitudeM:(a.altitudeM??0)+((o.altitudeM??0)-(a.altitudeM??0))*l,headingDeg:a.headingDeg??i.headingDeg}}return n}function qu(i,t){return{eastM:i.eastM,northM:i.northM,altitudeM:i.altitudeM??0,headingDeg:i.headingDeg??t.headingDeg}}const Yu=Math.PI/180;function We(i,t,e,n,s=!1){const r=s?new Ki({color:new Mt(...e)}):new xr({color:new Mt(...e)}),a=new oe(t,r);return a.position.y=n,a.userData={emissive:s},a.castShadow=!s,a.receiveShadow=!s,i.add(a),a}const Ku=.25,N3=.002;function U3(i){const t=/^#([0-9a-f]{6})$/i.exec(i);if(!t)return[1,1,1];const e=parseInt(t[1],16);return[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]}const Xd=[.32,.32,.3],qd=[1,.85,.5],Yd=[.25,.25,.25],Kd=[1,.97,.85],F3=[.55,.68,.72],Ln=.03,Nn=.05,Zd={front:0,behind:Math.PI,left:Math.PI/2,right:-Math.PI/2,"front-left":Math.PI/2,"behind-left":Math.PI/2,"front-right":-Math.PI/2,"behind-right":-Math.PI/2};function Ke(i,t){return i?.[t]}function Un(i,t,e,n,s,r,a,o){if(o===void 0)return;const c=new xr({color:new Mt(...F3),transparent:!0,opacity:o/100}),l=new oe(new mn(t,e,n),c);l.position.set(s,r,a),i.add(l)}const ln=.05,Ko=[.6,.58,.53],Zu=[.5,.5,.48];function ws(i,t,e,n,s,r,a,o){const c=new xr({color:new Mt(...o),side:Fe}),l=new oe(new mn(t,e,n),c);l.position.set(s,r,a),i.add(l)}function O3(i,t,e,n,s,r,a,o,c){const l=(n-r)/2,h=(g,x,m,f)=>{g<=0||(t?ws(i,g,x,ln,m,o+f,a,c):ws(i,ln,x,g,a,o+f,m,c))};h(e,l,0,n/2-l/2),h(e,l,0,-(n/2-l/2));const u=[...s].sort((g,x)=>g.center-x.center);let d=-e/2;for(const g of u){const m=g.center-g.main/2-d;h(m,r,d+m/2,0),d=g.center+g.main/2}const p=e/2-d;h(p,r,d+p/2,0)}function $d(i,t,e,n,s,r,a,o,c,l){const h=(n+s)/2,u=s-n,d=(p,g,x,m)=>{p.length===0?g?ws(i,x,u,ln,0,h,m,Ko):ws(i,ln,u,x,m,h,0,Ko):O3(i,g,x,u,p,r,m,h,Ko)};d(a,!0,t*2,-e+ln),d(o,!0,t*2,e-ln),d(c,!1,e*2,-t+ln),d(l,!1,e*2,t-ln),ws(i,t*2,ln,e*2,0,n+ln,0,Zu),ws(i,t*2,ln,e*2,0,s-ln,0,Zu)}function yl(i,t,e,n){switch(i){case"front":return{x:0,z:-(e-n)};case"behind":return{x:0,z:e-n};case"left":return{x:-(t-n),z:0};case"right":return{x:t-n,z:0};case"front-left":return{x:-(t-n),z:-Fn};case"front-right":return{x:t-n,z:-Fn};case"behind-left":return{x:-(t-n),z:Fn};case"behind-right":return{x:t-n,z:Fn}}}function Jd(i,t,e,n,s,r,a){const o=tf();o.scale.setScalar(n),o.rotation.y=Zd[t];const{x:c,z:l}=yl(t,s,r,a);o.position.set(c,e,l),i.add(o)}const El=6,bl=6,_i=3,er=1.4,nr=_i*.5,Qd=1.2,jd=.35,z3=.75,B3=1.6;function k3(i,t,e,n){const s=new yn,r=Math.max(1,i+1),a=r*_i;We(s,new mn(El,a,bl),[.55,.54,.5],a/2);const o=El/2,c=bl/2;for(let l=0;l<r;l++){const h=l*_i+_i/2;Un(s,er,nr,Nn,0,h,-c-Ln,Ke(t,"front")),Un(s,er,nr,Nn,0,h,c+Ln,Ke(t,"behind")),Un(s,Nn,nr,er,-o-Ln,h,0,Ke(t,"left")),Un(s,Nn,nr,er,o+Ln,h,0,Ke(t,"right"))}if(e){const l=Math.min(Math.max(n??0,0),r-1);Jd(s,e,l*_i,.72,o,c,Qd);const h=u=>Ke(t,u)!==void 0?[{main:er,center:0}]:[];$d(s,o,c,l*_i,(l+1)*_i,nr,h("front"),h("behind"),h("left"),h("right"))}return s}function G3(){const i=new yn;return We(i,new Ti(.15,.22,2,8),[.32,.22,.14],1),We(i,new qa(1.4,3,8),[.16,.32,.14],3.5),i}function H3(i){const t=new yn;return We(t,new Ti(.05,.08,5,8),[.28,.28,.3],2.5),We(t,new Wn(.25,12,8),i?qd:Xd,5.1,!0),t}const V3=[.08,.08,.08],gi=.8,Es=1,Dn=1.7,Zo=.6,Li=.4,ha=1.2,Ms=.7,Fn=.5,W3=Dn;function X3(i,t,e){const n=new yn;We(n,new mn(1.8,1.4,4.2),[.45,.14,.14],.7),We(n,new mn(gi*2,Zo,Es*2),[.4,.12,.12],Dn);for(const r of[-1.4,1.4])for(const a of[-.95,.95]){const o=We(n,new Ti(.4,.4,.3,12),V3,.4);o.rotation.z=Math.PI/2,o.position.x=a,o.position.z=r}const s=i?Kd:Yd;for(const r of[-.7,.7])We(n,new Wn(.15,8,6),s,.7,!0).position.set(r,.7,-2.1);if(Un(n,ha,Li,Nn,0,Dn,-Es-Ln,Ke(t,"front")),Un(n,ha,Li,Nn,0,Dn,Es+Ln,Ke(t,"behind")),Un(n,Nn,Li,Ms,-gi-Ln,Dn,-Fn,Ke(t,"front-left")),Un(n,Nn,Li,Ms,-gi-Ln,Dn,Fn,Ke(t,"behind-left")),Un(n,Nn,Li,Ms,gi+Ln,Dn,-Fn,Ke(t,"front-right")),Un(n,Nn,Li,Ms,gi+Ln,Dn,Fn,Ke(t,"behind-right")),e){Jd(n,e,z3,.5,gi,Es,jd);const r=(c,l)=>{const h=[];return Ke(t,c)!==void 0&&h.push({main:Ms,center:-Fn}),Ke(t,l)!==void 0&&h.push({main:Ms,center:Fn}),h},a=Ke(t,"front")!==void 0?[{main:ha,center:0}]:[],o=Ke(t,"behind")!==void 0?[{main:ha,center:0}]:[];$d(n,gi,Es,Dn-Zo/2,Dn+Zo/2,Li,a,o,r("front-left","behind-left"),r("front-right","behind-right"))}return n}const q3=[.95,.9,.82];function tf(){const i=new yn;We(i,new Ti(.25,.3,1.5,10),[.3,.3,.35],.75),We(i,new Wn(.22,10,8),[.62,.52,.46],1.72);const t=We(i,new qa(.07,.16,8),q3,1.72);return t.rotation.x=-Math.PI/2,t.position.z=-.2,i}const Y3=17,$u=18.5,$o=[.16,.16,.18];function K3(){const i=new yn,t=We(i,new Ti(1.8,1.8,$u*2,10),$o,0);t.rotation.x=Math.PI/2,We(i,new mn(Y3*2,.5,4.5),$o,0);const e=We(i,new mn(.4,5.5,4),$o,3);return e.position.z=-$u+2,i}class Ss{static occupantView(t){const e=t.witnessSide;if(!e)throw new Error("occupantView requires object.witnessSide to be set");const{x:n,z:s}=t.kind==="vehicle"?yl(e,gi,Es,jd):yl(e,El/2,bl/2,Qd),r=t.kind==="vehicle"?W3:(t.occupiedFloor??0)*_i+B3,a=(t.headingDeg??0)-Zd[e]/Yu;return{x:n,z:s,eyeY:r,headingDeg:a}}static build(t,e){const n=t.kind==="building"?k3(t.floors??R3,t.windows,t.witnessSide,t.occupiedFloor):t.kind==="tree"?G3():t.kind==="streetlight"?H3(e):t.kind==="vehicle"?X3(e,t.windows,t.witnessSide):t.kind==="aircraft"?K3():tf();return t.headingDeg!==void 0&&(n.rotation.y=-t.headingDeg*Yu),this.addLights(n,t.lights),t.kind==="aircraft"&&this.exemptFromFog(n),n}static exemptFromFog(t){for(const e of t.children){if(!(e instanceof oe))continue;const n=e.material;n.fog=!1,n.needsUpdate=!0}}static addLights(t,e){for(const n of e??[]){const s=We(t,new Wn(Ku,8,6),U3(n.color),n.offsetM.y,!0);s.position.set(n.offsetM.x,n.offsetM.y,n.offsetM.z),s.userData={emissive:!0,lightId:n.id},s.visible=!1}}static setLights(t,e,n,s){if(!e||e.length===0)return;const r=new Map(e.map(o=>[o.id,o])),a=Math.max(1,s*N3/Ku);for(const o of t.children){if(!(o instanceof oe))continue;const c=o.userData.lightId;if(!c)continue;const l=r.get(c);l&&(o.visible=P3(l,n),o.scale.setScalar(a*(l.intensity??1)**.5))}}static setLit(t,e,n){const s=e==="streetlight"?n?qd:Xd:n?Kd:Yd;for(const r of t.children){const a=r.userData;!(r instanceof oe)||!a.emissive||a.lightId||r.material.color.setRGB(...s)}}static dispose(t){for(const e of t.children)e instanceof oe&&(e.geometry.dispose(),e.material.dispose())}}function Z3(i,t){return i.cloudCover===t.cloudCover&&i.cloudDarkness===t.cloudDarkness&&i.cloudBaseM===t.cloudBaseM&&i.highCloudCover===t.highCloudCover&&i.iceCrystalAlignment===t.iceCrystalAlignment&&i.lowerCloudCover===t.lowerCloudCover&&i.precipitationType===t.precipitationType&&i.precipitationIntensity===t.precipitationIntensity&&i.windDirectionDeg===t.windDirectionDeg&&i.windSpeed===t.windSpeed&&i.storm===t.storm}const ua=900,Ju=.5,lr=900,$3=6371e3,J3=3e4;function Qu(i){const t=Math.sqrt(2*$3*Math.max(i,0));return Math.max(lr,Math.min(t,J3))}const Jo=.5,Q3=850,da=850,Qo=4,ju=1.5,j3=-1,tM=6,Al=-4,eM=.2,fa=2600,nM=.97,iM=.38,t0=Al,sM=3,rM=.15,aM=.6,oM=40,cM=30,lM=[0,45,90,135,180,225,270,315],hM={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},uM=["en","fr"],dM=880,e0=40,fM=10,pM=1,mM=150,gM=55,n0=.5,_M=2.2,i0=.265,s0=[[0,0],...Array.from({length:8},(i,t)=>{const e=t*Math.PI/4;return[Math.cos(e)*i0,Math.sin(e)*i0]})],r0=700,vM=250/T0,xM=12,a0=5,jo=6,Ni=[.92,.92,.95],tc=[.15,.15,.19],o0={snow:{fallSpeedMPerS:2,size:.3,color:new Mt(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new Mt(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},bs=0,MM=0,c0=3e3,ir=20,SM=15,l0=bs,yM=40,h0=1,EM=9;function bM(i){return h0+(EM-h0)*i}const AM=new Mt(.75,.82,.92),TM=10,wM=.5;function RM(i){return ef(i/TM,wM,1)}const ys=200,u0=.18,d0=.32,CM=.35,DM=new Mt(.85,.9,.98),f0=5,p0=.85,m0=.01;function ec(i,t){return Math.round(i*(m0+(1-m0)*t))}const g0=230,_0=.7,v0=.05,PM=.6,IM=.7,LM=.15,x0=.35,NM=3,UM=1/12,FM=.5,M0=8,S0=25,y0=.12,OM={Venus:new Mt(1,.96,.85),Mars:new Mt(1,.55,.4),Jupiter:new Mt(.95,.87,.72),Saturn:new Mt(.92,.86,.68)};class zM{renderer;scene=new $0;camera;celestialGroup=new yn;skyMesh;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;celestialLight=new Mm(16777215,0);celestialLightTarget=new Te;skyLight=new gm(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;raycaster=new Lo;weather=w0;observerElevationM=0;groundRadius=lr;terrainRadius=lr;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new F;rainLastVerticalFacing=-1;lightningArmed=!1;nextLightningAtS=null;lightningFlashRemainingS=0;baseFogColor=[0,0,0];lastSunPosition;lensFlare;dazzleIntensity=1;sunCloudTransmission=1;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new F;sunVisible=!1;lensFlareScratch=new F;sunOcclusionRaycaster=new Lo;sunOcclusionDirectionScratch=new F;sunOcclusionRightScratch=new F;sunOcclusionUpScratch=new F;ufoOcclusionRaycaster=new Lo;projectionKind="rectilinear";starPoints=0;equidistantPass;meteorSystem;cometTail;iceHalos;cometKey;onLightningFlash;constructor(t,e=s3(),n){this.renderer=new vv({canvas:t,antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=ur,this.camera=new sn(60,t.width/Math.max(t.height,1),.1,ua*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=e,this.onLightningFlash=n,this.celestialLight.shadow.mapSize.set(1024,1024),this.celestialLight.shadow.camera.left=-120,this.celestialLight.shadow.camera.right=120,this.celestialLight.shadow.camera.top=120,this.celestialLight.shadow.camera.bottom=-120,this.celestialLight.shadow.camera.near=1,this.celestialLight.shadow.camera.far=1e3,this.celestialLight.shadow.bias=-.0015,this.celestialLight.target=this.celestialLightTarget,this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight),this.scene.add(this.celestialGroup)}get currentTerrainAttribution(){return this.terrainAttribution}resize(t,e){this.renderer.setSize(t,e,!1),this.camera.aspect=t/Math.max(e,1),this.camera.updateProjectionMatrix(),this.render()}setObserverPose(t){t.headingDeg!==void 0?this.camera.rotation.set(t.pitchDeg*xn,-t.headingDeg*xn,0,"YXZ"):this.camera.rotation.set(t.pitchDeg*xn,this.camera.rotation.y,0,"YXZ"),t.elevationM!==this.observerElevationM&&(this.observerElevationM=t.elevationM,this.syncCloudLayer(),Math.abs(Qu(t.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/lr),this.camera.far=Math.max(ua*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.camera.position.y=1.6+t.elevationM,this.celestialGroup.position.y=this.camera.position.y,this.camera.fov!==t.fovDeg&&(this.camera.fov=t.fovDeg,this.camera.updateProjectionMatrix())}setTerrainProviders(t){this.terrainProviders=t,this.disposeMesh(this.terrainMesh),this.terrainMesh=void 0,this.terrainOrigin=void 0,this.terrainAttribution=void 0,this.terrainBuildToken++}setTerrainOrigin(t,e,n){if(t===void 0||e===void 0)return;const s=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-s)<s*.1){const{x:a,z:o}=$i(t,e,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(a*a+o*o)<mM*(s/lr))return}this.terrainOrigin={lat:t,lng:e},this.terrainRadius=s;const r=++this.terrainBuildToken;h3(t,e,this.terrainProviders,s).then(({mesh:a,attribution:o})=>{r===this.terrainBuildToken&&(this.disposeMesh(this.terrainMesh),a.renderOrder=pM,this.terrainMesh=a,this.terrainAttribution=o,this.scene.add(a),this.render(),n?.())}).catch(a=>{console.warn("Terrain build failed, keeping the flat ground fallback:",a),n?.()})}setShowCompass(t){this.showCompass!==t&&(this.showCompass=t,this.disposeCompassLabels(),t&&this.buildCompassLabels(),this.render())}setDazzleIntensity(t){this.dazzleIntensity!==t&&(this.dazzleIntensity=t,this.lensFlare&&(this.lensFlare.uniforms.uOpacity.value=n0*t,this.lastSunPosition&&this.applyLensFlareTint(Ii(this.lastSunPosition.altitudeDeg))),this.render())}setLensFlareArtifactIntensity(t){this.lensFlareArtifactIntensity!==t&&(this.lensFlareArtifactIntensity=t,this.lensFlare&&(this.lensFlare.uniforms.uFlareIntensity.value=t),this.render())}applyLensFlareTint(t){if(!this.lensFlare)return;const e=gM*this.dazzleIntensity*this.sunCloudTransmission;this.lensFlare.uniforms.uColorGain.value.setRGB(e*t[0],e*t[1],e*t[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const t=this.lastSunPosition?.altitudeDeg??-90,e=Gv(t)*this.sunCloudTransmission*this.dazzleIntensity*this.sunUnhiddenFraction,n=Ii(t);this.lensFlare.uniforms.uDazzleColour.value.setRGB(n[0],n[1],n[2]),this.lensFlare.uniforms.uVeilStrength.value=_M**2*Math.max(0,e)}setCompassHovered(t){this.compassHovered!==t&&(this.compassHovered=t,this.updateCompassVisibility())}setCompassForced(t){this.compassForced!==t&&(this.compassForced=t,this.updateCompassVisibility())}updateCompassVisibility(){const t=this.compassHovered||this.compassForced;for(const e of this.compassSprites)e.visible=t;this.render()}setWeather(t){Z3(this.weather,t)||(this.weather=t,this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lightningArmed=t.storm&&t.cloudDarkness>=FM,this.lightningArmed||(this.nextLightningAtS=null,this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),this.render())}setDecor(t){if(this.decorObjects!==t){this.decorObjects=t;for(const e of this.decorGroups.values())e.removeFromParent(),Ss.dispose(e);this.decorGroups.clear(),this.streetlightLights.clear();for(const e of t){const n=Ss.build(e,e.lit??!1);this.scene.add(n),this.decorGroups.set(e.id,n),e.kind==="streetlight"&&this.addStreetlightLight(e.id,n)}this.celestialLight.castShadow=this.decorGroups.size>0}}updateDecorAnchoring(t,e,n=0){const s=t?.lat!==void 0&&t.lng!==void 0&&e?.lat!==void 0&&e?.lng!==void 0?$i(t.lat,t.lng,e.lat,e.lng):{x:0,z:0},r=this.decorObjects.find(l=>l.witnessSide!==void 0&&C3(l.kind)),a={x:0,z:0};let o=0;if(r){const l=Ss.occupantView(r),h=-(r.headingDeg??0)*xn,u=l.x*Math.cos(h)+l.z*Math.sin(h),d=-l.x*Math.sin(h)+l.z*Math.cos(h),p=r.eastM+s.x,g=-r.northM+s.z;a.x=-(p+u),a.z=-(g+d),this.camera.position.y=l.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*xn,-(l.headingDeg+this.indoorLookYawDeg)*xn,0,"YXZ")}for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=L3(l,n);h.position.set(u.eastM+s.x+a.x,MM+u.altitudeM,-u.northM+s.z+a.z),u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*xn),o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(ua*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-c)>1&&(this.camera.far=c,this.camera.updateProjectionMatrix())}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(t,e){this.indoorLookYawDeg=t,this.indoorLookPitchDeg=e}updateDecorLitState(t){for(const e of this.decorObjects){const n=this.decorGroups.get(e.id);if(n&&e.lights?.length&&Ss.setLights(n,e.lights,t,n.position.distanceTo(this.camera.position)),e.kind!=="streetlight"&&e.kind!=="vehicle")continue;const s=this.decorGroups.get(e.id);if(!s)continue;const r=D3(e,t);Ss.setLit(s,e.kind,r);const a=this.streetlightLights.get(e.id);a&&(a.visible=r)}}addStreetlightLight(t,e){const n=e.children.find(r=>r.userData.emissive);if(!n)return;const s=new vm(16764006,oM,cM);s.position.copy(n.position),s.castShadow=!0,s.shadow.mapSize.set(512,512),s.shadow.bias=-.002,e.add(s),this.streetlightLights.set(t,s)}setAstronomy(t){const e=il(t.sun.altitudeDeg),n=e.horizon;this.baseFogColor=n,this.lastSunPosition=t.sun,this.buildSky(t.sun),this.buildGround(),this.updateCloudLighting(t.sun,n),this.updateCelestialLight(t,e.zenith,n),this.buildStars(t.stars,t.sun.altitudeDeg);const s=wu(t.sun.altitudeDeg);this.setBodyMesh("sun",t.sun,Qo,new Mt(1,.96,.88),t.sun.magnitude),this.setMoonMesh(t.moon,s),this.buildPlanets(t.planets,s),this.buildComet(t.comet,s),this.buildIceHalos(t.sun,t.moon),this.scene.fog=new kl(new Mt(...n),this.groundRadius*.2,this.groundRadius),this.syncAnimationLoop(),this.render()}updateCelestialLight(t,e,n){this.skyLight.color.setRGB(e[0],e[1],e[2]),this.skyLight.groundColor.setRGB(n[0],n[1],n[2]),this.skyLight.intensity=aM;const s=t.sun.altitudeDeg>=t0,r=!s&&t.moon.altitudeDeg>=t0;if(!s&&!r){this.celestialLight.intensity=0;return}const a=s?t.sun:t.moon,{x:o,y:c,z:l}=un(a.altitudeDeg,a.azimuthDeg,da);this.celestialLight.position.set(o,c,l);const h=Ii(a.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const u=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*xn));this.celestialLight.intensity=(s?sM:rM)*u,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(t,e,n){this.meteorSystem||(this.meteorSystem=new Le,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(t,e,n)}get meteorSchedule(){return this.meteorSystem?.schedule??[]}meteorMidpoint(t){return this.meteorSystem?.midpointOf(t)}updateMeteors(t){this.meteorSystem?.update(t)}setInstrument(t){this.projectionKind=t.projection;const e=R0.starPointsOf(t);e!==this.starPoints&&(this.starPoints=e,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=e))}render(){const t=this.usableEquidistantPass();if(!t){this.updateLensFlarePosition(),this.renderer.render(this.scene,this.camera);return}t.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition())}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const t=this.renderer.getDrawingBufferSize(new Ft);if(ka.supports(this.camera.fov,t.x/Math.max(t.y,1)))return this.equidistantPass?this.equidistantPass.resize(t.x,t.y):this.equidistantPass=new ka(t.x,t.y),this.equidistantPass}aimAtScreenPoint(t,e,n){const s=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!s){t.setFromCamera(new Ft(e,n),this.camera);return}const r=s.directionFor(e,n,this.camera.fov);this.camera.updateMatrixWorld(),t.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),t.ray.direction.set(r.x,r.y,r.z).applyQuaternion(this.camera.quaternion).normalize(),t.camera=this.camera}updateLensFlarePosition(){const t=this.lensFlare;if(!t)return;if(!this.sunVisible){t.mesh.visible=!1;return}if(this.camera.updateMatrixWorld(),this.lensFlareScratch.copy(this.sunWorldPosition).applyMatrix4(this.camera.matrixWorldInverse),this.lensFlareScratch.z>0){t.mesh.visible=!1;return}const e=this.sunVisibleFraction();if(e<=0){t.mesh.visible=!1;return}t.mesh.visible=!0,this.sunUnhiddenFraction=e,this.applyDazzleStrength();const n=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);t.uniforms.uLensPosition.value.set(n.x,n.y);const s=this.renderer.domElement.width,r=this.renderer.domElement.height;t.uniforms.uResolution.value.set(s,r),t.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}sunVisibleFraction(){let t=0;for(const e of s0)this.isSunOccluded(e[0],e[1])||t++;return t/s0.length}isSunOccluded(t=0,e=0){this.scene.updateMatrixWorld();const n=[];this.groundMesh&&n.push(this.groundMesh),this.terrainMesh&&n.push(this.terrainMesh);for(const o of this.decorGroups.values())n.push(o);if(n.length===0)return!1;const s=this.sunOcclusionDirectionScratch.copy(this.sunWorldPosition).sub(this.camera.position),r=s.length();if(s.normalize(),t!==0||e!==0){const o=Math.PI/180,c=this.sunOcclusionRightScratch.set(s.z,0,-s.x);c.lengthSq()<1e-9&&c.set(1,0,0),c.normalize();const l=this.sunOcclusionUpScratch.crossVectors(c,s).normalize();s.addScaledVector(c,t*o).addScaledVector(l,e*o).normalize()}this.sunOcclusionRaycaster.set(this.camera.position,s);const a=this.sunOcclusionRaycaster.intersectObjects(n,!0)[0];return a!==void 0&&a.distance<r}isScreenPointOccluded(t,e,n,s){if(s&&this.cloudMesh&&this.lowerCloudCover()>0)return!0;const r=[];for(const a of this.decorObjects){if(!a.occludesSourceIds?.includes(n))continue;const o=this.decorGroups.get(a.id);o&&r.push(o)}return r.length===0?!1:(this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),this.ufoOcclusionRaycaster.near=Ju,this.ufoOcclusionRaycaster.intersectObjects(r,!0).length>0)}decorDistancesAt(t,e,n){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),this.ufoOcclusionRaycaster.near=Ju;let s,r;for(const a of this.decorObjects){const o=this.decorGroups.get(a.id);if(!o)continue;const c=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];c&&(a.occludesSourceIds?.includes(n)?s=s===void 0?c.distance:Math.max(s,c.distance):r=r===void 0?c.distance:Math.min(r,c.distance))}return{behindM:s,inFrontM:r}}pickBodyAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const n=[...this.hitAreas.entries()],s=this.raycaster.intersectObjects(n.map(([,r])=>r))[0];if(s)return n.find(([,r])=>r===s.object)?.[0]}pickDecorAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const n=[...this.decorGroups.entries()],s=this.raycaster.intersectObjects(n.map(([,a])=>a),!0)[0];if(!s)return;let r=s.object;for(;r&&!n.some(([,a])=>a===r);)r=r.parent;return n.find(([,a])=>a===r)?.[0]}dispose(){this.stopTwinkle(),this.terrainBuildToken++,this.disposeMesh(this.skyMesh),this.disposeMesh(this.groundMesh),this.disposeMesh(this.terrainMesh),this.disposeCloudSystem(),this.disposeCirrus(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers(),this.meteorSystem?.dispose(),this.meteorSystem=void 0,this.iceHalos?.dispose(),this.iceHalos=void 0,this.cometTail?.dispose(),this.cometTail=void 0;for(const t of this.bodyMeshes.values())this.disposeMesh(t);this.bodyMeshes.clear();for(const t of[...this.hitAreas.keys()])this.disposeHitArea(t);for(const t of[...this.glareSprites.keys()])this.disposeGlare(t);this.disposeCompassLabels();for(const t of this.decorGroups.values())Ss.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear(),this.lensFlare&&(this.lensFlare.mesh.removeFromParent(),this.lensFlare.mesh.geometry.dispose(),this.lensFlare.mesh.material.dispose(),this.lensFlare=void 0),this.renderer.dispose()}animationsRunning=!1;startTwinkle(){if(this.animationFrameId!==null||!this.needsAnimationLoop())return;let t;const e=n=>{const s=t===void 0?0:Math.min((n-t)/1e3,UM);t=n,this.updateTwinkle(n/1e3),this.updatePrecipitation(n/1e3,s),this.updateRain(s),this.updateLightning(n/1e3,s),this.lensFlare&&(this.lensFlare.uniforms.uTime.value=n/1e3),this.render(),this.animationFrameId=requestAnimationFrame(e)};this.animationFrameId=requestAnimationFrame(e)}setAnimationsRunning(t){t!==this.animationsRunning&&(this.animationsRunning=t,t?this.nextLightningAtS=null:this.lightningFlashRemainingS>0&&(this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),t||this.render())}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}restoreFogColor(){this.scene.fog&&this.scene.fog.color.setRGB(...this.baseFogColor)}needsAnimationLoop(){return this.animationsRunning&&(this.starTiers.length>0||this.precipitationPoints!==void 0||this.rainSystem!==void 0||this.lightningArmed||this.lensFlare!==void 0&&this.sunVisible)}syncAnimationLoop(){this.needsAnimationLoop()?this.startTwinkle():this.stopTwinkle()}buildSky(t){this.disposeMesh(this.skyMesh);const e=new Wn(ua,32,16),n=e.attributes.position,s=[];for(let a=0;a<n.count;a++){const{altitudeDeg:o,azimuthDeg:c}=yv(n.getX(a),n.getY(a),n.getZ(a)),l=Dv(o,c,t.azimuthDeg,t.altitudeDeg);s.push(l[0],l[1],l[2])}e.setAttribute("color",new we(s,3));const r=new Ki({vertexColors:!0,side:Fe,fog:!1,depthWrite:!1});this.skyMesh=new oe(e,r),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){this.disposeMesh(this.groundMesh),this.groundRadius=Qu(this.observerElevationM);const t=new Vl(this.groundRadius,48),e=new xr({color:new Mt(Jo,Jo,Jo),fog:!0});this.groundMesh=new oe(t,e),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh)}cloudTransmission(t){const e=un(t.altitudeDeg,t.azimuthDeg,1);let n=1;const s=this.lowerCloudCover();s>0&&(n*=1-Ae.alphaAt(e,Math.abs(this.cloudLayerOffset()),s)*nM);const r=this.weather.highCloudCover??0;return r>0&&(n*=1-Ae.alphaAt(e,fa,r)*iM),Math.max(0,Math.min(1,n))}setBodyMesh(t,e,n,s,r){if(this.disposeMesh(this.bodyMeshes.get(t)),this.disposeHitArea(t),this.disposeGlare(t),e.altitudeDeg<Al){this.bodyMeshes.delete(t),t==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:c}=un(e.altitudeDeg,e.azimuthDeg,da),l=Ii(e.altitudeDeg),h=this.cloudTransmission(e),u=new Mt(s.r*l[0]*h,s.g*l[1]*h,s.b*l[2]*h),d=new Wn(n,16,16),p=new Ki({color:u,fog:!1}),g=new oe(d,p);g.position.set(a,o,c),this.celestialGroup.add(g),this.bodyMeshes.set(t,g),this.setHitArea(t,a,o,c,n);const x=r-2.5*Math.log10(Math.max(h,.001));if(t==="sun"&&(this.sunCloudTransmission=h),t!=="sun"&&this.setGlare(t,a,o,c,x,u),t==="sun"){this.sunVisible=!0;const m=this.celestialGroup.scale.x;this.sunWorldPosition.set(a*m,o*m+this.celestialGroup.position.y,c*m),this.lensFlare||(this.lensFlare=w3(),this.lensFlare.uniforms.uOpacity.value=n0*this.dazzleIntensity,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(l)}}setMoonMesh(t,e){const n="moon";if(this.disposeMesh(this.bodyMeshes.get(n)),this.disposeHitArea(n),this.disposeGlare(n),t.magnitude>e||t.altitudeDeg<Al){this.bodyMeshes.delete(n);return}const{x:s,y:r,z:a}=un(t.altitudeDeg,t.azimuthDeg,da),o=Ii(t.altitudeDeg),c=new Mt(o[0],o[1],o[2]),l=new rr({map:KM(t.phase),color:c,fog:!1}),h=new Br(l);h.position.set(s,r,a);const u=Qo*2;h.scale.set(u,u,1),this.celestialGroup.add(h),this.bodyMeshes.set(n,h),this.setHitArea(n,s,r,a,Qo),this.setGlare(n,s,r,a,t.magnitude,c)}setHitArea(t,e,n,s,r){const a=new rr({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1}),o=new Br(a);o.position.set(e,n,s);const c=r*tM;o.scale.set(c,c,1),this.celestialGroup.add(o),this.hitAreas.set(t,o)}disposeHitArea(t){const e=this.hitAreas.get(t);e&&(e.removeFromParent(),e.material.dispose(),this.hitAreas.delete(t))}setGlare(t,e,n,s,r,a){const o=Lv(r);if(o<=0){this.disposeGlare(t);return}const c=Fv(o),l=this.glareSprites.get(t),h=l??new Br(new rr({map:YM(),transparent:!0,blending:Xi,depthWrite:!1,fog:!1}));h.material.color.copy(a),h.material.opacity=Bv(o),h.position.set(e,n,s),h.scale.set(c*2,c*2,1),l||(this.celestialGroup.add(h),this.glareSprites.set(t,h))}disposeGlare(t){const e=this.glareSprites.get(t);e&&(e.removeFromParent(),e.material.dispose(),this.glareSprites.delete(t))}buildComet(t,e){const n=t&&`comet:${t.id}`;if(!t||!n||t.magnitude>e){this.disposeComet();return}this.cometKey&&this.cometKey!==n&&this.disposeComet();const s=Go(t.magnitude),r=Ho(s);this.cometKey=n,this.setBodyMesh(n,t.position,ju*(.5+.5*s),new Mt(r,r,r),t.magnitude),this.cometTail||(this.cometTail=new en(da),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(t.position,t.tailEnd,s)}buildIceHalos(t,e){this.iceHalos||(this.iceHalos=new Pn,this.iceHalos.onReady=()=>this.render(),this.celestialGroup.add(this.iceHalos.object));const n=this.weather.highCloudCover;if(n===void 0){this.iceHalos.update({x:0,y:1,z:0},-1,0,[1,1,1],{cover:0,layerHeight:fa},0);return}const s=this.weather.lowerCloudCover??this.weather.cloudCover,r=$t.deckLitUntilDeg($t.DECK_HEIGHT_M),a=t.altitudeDeg>-r?t:e,o=$t.strength(n,s,a.altitudeDeg,r)*(a===t?1:eM),{x:c,y:l,z:h}=un(a.altitudeDeg,a.azimuthDeg,1),u=Ii(a.altitudeDeg);this.iceHalos.update({x:c,y:l,z:h},a.altitudeDeg,o,[u[0],u[1],u[2]],{cover:n,layerHeight:fa},this.weather.iceCrystalAlignment??Af)}disposeComet(){this.cometTail?.set(void 0,void 0,0),this.cometKey&&(this.disposeMesh(this.bodyMeshes.get(this.cometKey)),this.bodyMeshes.delete(this.cometKey),this.disposeHitArea(this.cometKey),this.disposeGlare(this.cometKey),this.cometKey=void 0)}buildPlanets(t,e){const n=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[]]);for(const s of t){if(s.magnitude>e)continue;n.add(s.body);const r=Go(s.magnitude),a=Ho(r),o=OM[s.body]??new Mt(1,1,1),c=new Mt(o.r*a,o.g*a,o.b*a),l=ju*(.5+.5*r);this.setBodyMesh(s.body,s.position,l,c,s.magnitude)}for(const s of[...this.bodyMeshes.keys()])n.has(s)||(this.disposeMesh(this.bodyMeshes.get(s)),this.bodyMeshes.delete(s),this.disposeHitArea(s),this.disposeGlare(s))}buildStars(t,e){if(this.disposeStarTiers(),!t||t.catalog.count===0){this.syncAnimationLoop();return}const{catalog:n,date:s,observer:r}=t,a=wu(e),o=nc(1337),c=[];for(let l=0;l<n.count;l++){const h=n.mag[l];if(h>a)continue;const{altitudeDeg:u,azimuthDeg:d}=Qa(n.ra[l],n.dec[l],s,r);if(u<j3)continue;const{x:p,y:g,z:x}=un(u,d,Q3);c.push({x:p,y:g,z:x,brightness:Go(h),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}this.starTiers=_d.map((l,h)=>{const u=c.filter(M=>Vv(M.brightness)===h),d=new Float32Array(u.length*3),p=new Float32Array(u.length),g=new Float32Array(u.length),x=new Float32Array(u.length);u.forEach((M,y)=>{d[y*3]=M.x,d[y*3+1]=M.y,d[y*3+2]=M.z,p[y]=M.brightness,g[y]=M.phase,x[y]=M.speedFactor});const m=new ye;m.setAttribute("position",new he(d,3));const f=new he(new Float32Array(u.length*3),3);m.setAttribute("color",f);const A=new ed({vertexColors:!0,size:l.size,sizeAttenuation:!1,fog:!1});Bi.apply(A);const T=new ba(m,A);return this.celestialGroup.add(T),{points:T,colorAttribute:f,brightness:p,phase:g,speedFactor:x}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(t){for(const e of this.starTiers){const n=e.colorAttribute.array;for(let s=0;s<e.brightness.length;s++){const r=qv(e.brightness[s],{phase:e.phase[s],speedFactor:e.speedFactor[s]},t),a=Ho(e.brightness[s])*r;n[s*3]=a,n[s*3+1]=a,n[s*3+2]=a}e.colorAttribute.needsUpdate=!0}}buildClouds(){this.disposeCloudSystem();const t=this.lowerCloudCover();if(t<=0)return;const e=this.weather.cloudDarkness,n=new Mt(Ni[0]+(tc[0]-Ni[0])*e,Ni[1]+(tc[1]-Ni[1])*e,Ni[2]+(tc[2]-Ni[2])*e),{material:s,uniforms:r}=Wu(n,t,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=s,this.cloudUniforms=r,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const a=Xu(r0);this.cloudMesh=new oe(a,s),this.cloudLayerOffset()<0&&(this.cloudMesh.scale.y=-1),this.cloudMesh.renderOrder=a0,this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.lowerCloudCover??this.weather.cloudCover}buildCirrus(){this.disposeCirrus();const t=this.weather.highCloudCover??0;if(t<=0)return;const{material:e,uniforms:n}=Wu(new Mt(...Ni),t,fa,1);this.cirrusMaterial=e,this.cirrusUniforms=n,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new oe(Xu(r0*1.04),e),this.cirrusMesh.renderOrder=a0-1,this.celestialGroup.add(this.cirrusMesh)}disposeCirrus(){this.cirrusMesh&&(this.cirrusMesh.removeFromParent(),this.cirrusMesh.geometry.dispose()),this.cirrusMaterial?.dispose(),this.cirrusMesh=void 0,this.cirrusMaterial=void 0,this.cirrusUniforms=void 0}syncCloudLayer(){const t=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(t)),this.cloudMesh&&(this.cloudMesh.scale.y=t<0?-1:1)}cloudLayerOffset(){const e=((this.weather.cloudBaseM??T0)-this.observerElevationM)*vM;return Math.sign(e||1)*Math.max(Math.abs(e),xM)}updateCloudLighting(t,e){const n=[this.cloudUniforms,this.cirrusUniforms].filter(l=>l!==void 0);if(n.length===0)return;const{x:s,y:r,z:a}=un(t.altitudeDeg,t.azimuthDeg,1),o=Ii(t.altitudeDeg),c=Math.max(0,Math.sin(Math.max(t.altitudeDeg,0)*xn));for(const l of n)l.sunDir.value.set(s,r,a),l.sunColor.value.setRGB(o[0]*c,.96*o[1]*c,.88*o[2]*c),l.ambientColor.value.setRGB(e[0],e[1],e[2])}disposeCloudSystem(){this.cloudMesh&&(this.cloudMesh.removeFromParent(),this.cloudMesh.geometry.dispose()),this.cloudMaterial?.dispose(),this.cloudMesh=void 0,this.cloudMaterial=void 0,this.cloudUniforms=void 0}disposePrecipitationPoints(){this.precipitationPoints&&(this.precipitationPoints.removeFromParent(),this.precipitationPoints.geometry.dispose(),this.precipitationPoints.material.dispose()),this.precipitationPoints=void 0,this.precipitationPositions=void 0,this.precipitationPhase=void 0,this.precipitationSpeedJitter=void 0,this.precipitationWobbleFreqJitter=void 0,this.precipitationWobbleAmpJitter=void 0,this.precipitationBounceRemaining=void 0,this.precipitationBounceHeight=void 0,this.precipitationBounceDuration=void 0,this.precipitationBounceVelX=void 0,this.precipitationBounceVelZ=void 0,this.precipitationUniforms=void 0}buildPrecipitation(){this.disposePrecipitationPoints(),this.disposeRain();const t=this.weather.precipitationType;if(t==="none")return;if(t==="rain"){this.buildRain();return}const e=o0[t],n=e.poolSize,s=nc(9001),r=new Float32Array(n*3),a=new Float32Array(n),o=new Float32Array(n),c=new Float32Array(n),l=new Float32Array(n),h=new Float32Array(n),u=new Float32Array(n),d=new Float32Array(n),p=new Float32Array(n),g=new Float32Array(n);for(let T=0;T<n;T++){const M=s()*Math.PI*2,y=s()*e.radiusM;r[T*3]=Math.cos(M)*y,r[T*3+1]=bs+s()*(e.topYM-bs),r[T*3+2]=Math.sin(M)*y,a[T]=s()*Math.PI*2,o[T]=.7+s()*.6,c[T]=.6+s()*.8,l[T]=.4+s()*1.2}const x=new ye;x.setAttribute("position",new he(r,3)),x.setDrawRange(0,ec(n,this.weather.precipitationIntensity));const m={uSize:{value:e.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:e.opacity},uColor:{value:e.color},uHazeColor:{value:new Mt(...this.baseFogColor)},uTexture:{value:BM(t)},uNearFocusDistance:{value:f0},uHazeDistance:{value:e.radiusM*p0}},f=new Be({uniforms:m,vertexShader:XM,fragmentShader:qM,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const A=new ba(x,f);A.renderOrder=jo,this.scene.add(A),this.precipitationPoints=A,this.precipitationPositions=r,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=c,this.precipitationWobbleAmpJitter=l,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=u,this.precipitationBounceDuration=d,this.precipitationBounceVelX=p,this.precipitationBounceVelZ=g}updatePrecipitation(t,e){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter||(this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor),e<=0))return;const n=this.weather.precipitationType;if(n==="none"||n==="rain")return;const s=o0[n],r=this.weather.windDirectionDeg*xn,a=Math.sin(r)*this.weather.windSpeed*s.driftSensitivity,o=-Math.cos(r)*this.weather.windSpeed*s.driftSensitivity,c=this.precipitationPositions,l=this.precipitationPhase,h=this.precipitationSpeedJitter,u=this.precipitationWobbleFreqJitter,d=this.precipitationWobbleAmpJitter,p=this.precipitationBounceRemaining,g=this.precipitationBounceHeight,x=this.precipitationBounceDuration,m=this.precipitationBounceVelX,f=this.precipitationBounceVelZ,A=n==="snow"&&u&&d,T=n==="hail"&&p&&g&&x&&m&&f;for(let M=0,y=0;M<c.length;M+=3,y++){if(T&&p[y]>0){if(p[y]-=e,p[y]<=0){const v=Math.random()*Math.PI*2,E=Math.sqrt(Math.random())*s.radiusM;c[M]=Math.cos(v)*E,c[M+1]=s.topYM,c[M+2]=Math.sin(v)*E,p[y]=0}else{const v=1-p[y]/x[y];c[M+1]=bs+Math.sin(Math.PI*v)*g[y],c[M]=ma(c[M]+(a+m[y])*e,s.radiusM),c[M+2]=ma(c[M+2]+(o+f[y])*e,s.radiusM)}continue}let b=0,R=0;if(A){const v=PM*u[y],E=IM*d[y];b=Math.sin(t*v*Math.PI*2+l[y])*E,R=Math.sin(t*v*Math.PI*2+l[y]+Math.PI/2)*E}if(c[M]+=(a+b)*e,c[M+1]-=s.fallSpeedMPerS*h[y]*e,c[M+2]+=(o+R)*e,c[M]=ma(c[M],s.radiusM),c[M+2]=ma(c[M+2],s.radiusM),c[M+1]<bs){if(T){g[y]=x0*(.2+Math.random()*1.6),x[y]=LM*(.5+Math.random()),p[y]=x[y];const D=Math.random()*Math.PI*2,C=NM*(g[y]/x0);m[y]=Math.cos(D)*C,f[y]=Math.sin(D)*C,c[M+1]=bs;continue}const v=Math.random()*Math.PI*2,E=Math.sqrt(Math.random())*s.radiusM;c[M]=Math.cos(v)*E,c[M+1]=s.topYM,c[M+2]=Math.sin(v)*E}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const t=bM(this.weather.precipitationIntensity);this.rainSystem=x3({count:c0,radiusM:ir,heightM:SM,bottomYM:l0,overallSpeed:yM,color:AM,opacity:.85,visibleCount:ec(c0,this.weather.precipitationIntensity),speedStreak:RM(t),pixelSize:g0,seed:9001,nearFocusDistanceM:f0,hazeDistanceM:ir*p0,hazeColor:new Mt(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.rainSystem.points.renderOrder=jo,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const t=nc(4242),e=new Float32Array(ys*3),n=new Float32Array(ys),s=new Float32Array(ys),r=new Float32Array(ys);for(let h=0;h<ys;h++){const u=t()*Math.PI*2,d=Math.sqrt(t())*ir;e[h*3]=Math.cos(u)*d,e[h*3+1]=l0,e[h*3+2]=Math.sin(u)*d,s[h]=pa(u0,d0),n[h]=t()*s[h],r[h]=n[h]/s[h]}const a=new ye;a.setAttribute("position",new he(e,3));const o=new he(r,1);a.setAttribute("aLife",o),a.setDrawRange(0,ec(ys,this.weather.precipitationIntensity));const c=new Be({uniforms:{uMaxSize:{value:CM},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:DM},uTexture:{value:HM()}},vertexShader:VM,fragmentShader:WM,transparent:!0,depthWrite:!1}),l=new ba(a,c);l.renderOrder=jo,this.scene.add(l),this.rainSplashSystem={points:l,positions:e,life:n,duration:s,lifeAttribute:o}}disposeRain(){this.rainSystem&&(this.rainSystem.points.removeFromParent(),this.rainSystem.points.geometry.dispose(),this.rainSystem.points.material.dispose()),this.rainSystem=void 0,this.disposeRainSplashes()}disposeRainSplashes(){this.rainSplashSystem&&(this.rainSplashSystem.points.removeFromParent(),this.rainSplashSystem.points.geometry.dispose(),this.rainSplashSystem.points.material.dispose()),this.rainSplashSystem=void 0}updateRain(t){const e=this.rainSystem;if(!e)return;e.uniforms.uTime.value+=t,e.uniforms.uHazeColor.value.setRGB(...this.baseFogColor);const n=this.weather.windDirectionDeg*xn,s=Math.sin(n)*this.weather.windSpeed,r=-Math.cos(n)*this.weather.windSpeed,a=ir,o=l=>(l%(a*2)+a*3)%(a*2)-a;e.uniforms.uWindOffset.value.set(o(e.uniforms.uWindOffset.value.x+s*t),o(e.uniforms.uWindOffset.value.y+r*t)),this.camera.getWorldDirection(this.rainCameraDirection);const c=Math.abs(this.rainCameraDirection.y);if(Math.abs(c-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=c;const l=_0+(1-_0)*(1-c),h=v0+(1-v0)*(1-c);e.uniforms.uUvSquash.value=h,e.uniforms.uPixelSize.value=g0*l*(.5+.5*h)}this.updateRainSplashes(t)}updateRainSplashes(t){const e=this.rainSplashSystem;if(!e||t<=0)return;const{positions:n,life:s,duration:r,lifeAttribute:a}=e,o=a.array;for(let c=0,l=0;c<n.length;c+=3,l++){if(s[l]+=t,s[l]>=r[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*ir;n[c]=Math.cos(h)*u,n[c+2]=Math.sin(h)*u,r[l]=pa(u0,d0),s[l]=0}o[l]=s[l]/r[l]}e.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}updateLightning(t,e){if(this.lightningArmed){if(this.lightningFlashRemainingS>0){this.lightningFlashRemainingS=Math.max(0,this.lightningFlashRemainingS-e);const n=this.lightningFlashRemainingS/y0;this.scene.fog&&this.scene.fog.color.setRGB(this.baseFogColor[0]+(1-this.baseFogColor[0])*n,this.baseFogColor[1]+(1-this.baseFogColor[1])*n,this.baseFogColor[2]+(1-this.baseFogColor[2])*n);return}if(this.nextLightningAtS===null){this.nextLightningAtS=t+pa(M0,S0);return}t>=this.nextLightningAtS&&(this.lightningFlashRemainingS=y0,this.nextLightningAtS=t+pa(M0,S0),this.onLightningFlash?.())}}buildCompassLabels(){const t=wl(navigator.languages,uM),e=hM[t];this.compassSprites=lM.map((n,s)=>{const r=e[s],a=new rr({map:ZM(r),depthTest:!1,fog:!1}),o=new Br(a),{x:c,y:l,z:h}=un(0,n,dM);return o.position.set(c,l,h),o.scale.set(e0,e0,1),o.renderOrder=fM,o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o})}disposeCompassLabels(){for(const t of this.compassSprites)t.removeFromParent(),t.material.map?.dispose(),t.material.dispose();this.compassSprites=[]}disposeStarTiers(){for(const t of this.starTiers)this.disposeMesh(t.points);this.starTiers=[]}disposeMesh(t){if(!t)return;t.removeFromParent(),"geometry"in t&&t.geometry.dispose();const e=t.material;for(const n of Array.isArray(e)?e:[e]){const s=n.map;s&&s.dispose(),n.dispose()}}}const xn=Math.PI/180;function ef(i,t,e){return Math.max(t,Math.min(e,i))}function pa(i,t){return i+Math.random()*(t-i)}function ma(i,t){return(i%(t*2)+t*3)%(t*2)-t}let ga,_a;function BM(i){switch(i){case"snow":return kM();case"hail":return GM()}}function kM(){if(ga)return ga;const i=64,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=e.createRadialGradient(i/2,i/2,0,i/2,i/2,i/2);return n.addColorStop(0,"rgba(255,255,255,0.95)"),n.addColorStop(.5,"rgba(255,255,255,0.55)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,i,i),ga=new ii(t),ga}function GM(){if(_a)return _a;const i=64,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=e.createRadialGradient(i/2,i/2,0,i/2,i/2,i/2);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.55,"rgba(255,255,255,0.95)"),n.addColorStop(.8,"rgba(255,255,255,0.4)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,i,i),_a=new ii(t),_a}let va;function HM(){if(va)return va;const i=64,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=e.createRadialGradient(i/2,i/2,0,i/2,i/2,i/2);return n.addColorStop(0,"rgba(255,255,255,0)"),n.addColorStop(.4,"rgba(255,255,255,0)"),n.addColorStop(.6,"rgba(255,255,255,0.9)"),n.addColorStop(.8,"rgba(255,255,255,0.25)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,i,i),va=new ii(t),va}const VM=`
5218
+ `,transparent:!0,blending:Ri,depthWrite:!1,side:Ce,fog:!1}),this.object=new se(new Cn(Fn.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}set onReady(t){this.onRepaint=t}update(t,e,n,s,r,a){const o=this.material.uniforms;if(n<=0){o.uStrength.value=0,this.object.visible=!1,this.stopWork();return}o.uSource.value.set(t.x,t.y,t.z).normalize(),o.uStrength.value=n,o.uTint.value.set(s[0],s[1],s[2]),o.uIceCover.value=r.cover,o.uIceHeight.value=r.layerHeight,this.object.visible=this.everDisplayed,this.requestMap(e,a)}requestMap(t,e){!(!(Math.abs(t-this.mappedAltitudeDeg)<Fn.ALTITUDE_STEP_DEG)||e!==this.mappedAlignment)||this.tracingFor(t,e)||(this.pendingAltitudeDeg=t,this.pendingAlignment=e,this.sky.begin(t,e),this.tracing=!0,this.nextGlimpse=Fn.FIRST_GLIMPSE_RAYS,this.scheduleWork())}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;tracingFor(t,e){return this.tracing&&Math.abs(t-this.pendingAltitudeDeg)<Fn.ALTITUDE_STEP_DEG&&e===this.pendingAlignment}scheduleWork(){if(this.workHandle!==void 0)return;const t=()=>{if(this.workHandle=void 0,!this.tracing)return;this.sky.trace(Fn.RAYS_PER_FRAME);const e=this.sky.tracedRays>=Fn.RAYS,n=this.refining&&this.sky.tracedRays>=this.nextGlimpse;if(n&&(this.nextGlimpse*=2),(e||n)&&this.publish(),e){this.tracing=!1,this.refining=!1,this.mappedAltitudeDeg=this.pendingAltitudeDeg,this.mappedAlignment=this.pendingAlignment;return}this.workHandle=requestAnimationFrame(t)};this.workHandle=requestAnimationFrame(t)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0,this.tracing=!1}publish(){const e=this.sky.harvest().data;for(let n=0,s=0;s<e.length;n+=4,s+=3)this.texels[n]=Us.toHalfFloat(e[s]),this.texels[n+1]=Us.toHalfFloat(e[s+1]),this.texels[n+2]=Us.toHalfFloat(e[s+2]),this.texels[n+3]=1;this.texture.needsUpdate=!0,this.everDisplayed=!0,this.object.visible=this.material.uniforms.uStrength.value>0,this.onRepaint?.()}dispose(){this.stopWork(),this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class ye{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new Bs;previous=ye.emergences();current=ye.emergences();tally=new Float32Array(ye.BINS*3);radiance=new Float32Array(ye.BINS*3);scratch=new Float32Array(ye.BINS*3);static emergences(){return Array.from({length:Bs.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const t of Tn.SAMPLES)this.sweep(t);return this.toRadiance(),this.blurBySourceDisc(),{bins:ye.BINS,data:this.radiance,binDeg:180/ye.BINS}}sweep(t){this.drop.refractiveIndex=Oe.indexAt(t.wavelengthNm);const e=ye.IMPACT_STEPS;let n=this.drop.trace(0,this.previous);const s=1/e;for(let r=1;r<=e;r++){const a=this.drop.trace(Math.sqrt(r/e),this.current);for(let o=0;o<Math.min(a,n);o++){const c=this.previous[o],l=this.current[o];c.chords===l.chords&&this.deposit(c.scatteringAngle,l.scatteringAngle,(c.weight+l.weight)/2*s,t)}n=a,this.copyInto(this.current,this.previous)}}copyInto(t,e){for(let n=0;n<t.length;n++)e[n].chords=t[n].chords,e[n].scatteringAngle=t[n].scatteringAngle,e[n].weight=t[n].weight}deposit(t,e,n,s){if(n<=0)return;const r=ye.BINS,a=Math.PI/r,o=Math.min(t,e),c=Math.max(t,e),l=c-o,h=Math.min(r-1,Math.max(0,Math.floor(o/a))),u=Math.min(r-1,Math.max(0,Math.floor(c/a)));if(l<=0||h===u){this.add(h,n,s);return}for(let d=h;d<=u;d++){const f=Math.min(c,(d+1)*a)-Math.max(o,d*a);f>0&&this.add(d,n*f/l,s)}}add(t,e,n){const s=t*3,r=e*Tn.SAMPLES.length;this.tally[s]+=r*n.r,this.tally[s+1]+=r*n.g,this.tally[s+2]+=r*n.b}toRadiance(){const t=ye.BINS,e=Math.PI/t;for(let n=0;n<t;n++){const s=2*Math.PI*(Math.cos(n*e)-Math.cos((n+1)*e)),r=s>0?this.backwardShare((n+.5)*(180/t))/s:0,a=n*3;this.radiance[a]=this.tally[a]*r,this.radiance[a+1]=this.tally[a+1]*r,this.radiance[a+2]=this.tally[a+2]*r}}backwardShare(t){const e=180-t;if(e<=ye.FULL_UNTIL_DEG)return 1;if(e>=ye.FADED_BY_DEG)return 0;const n=(e-ye.FULL_UNTIL_DEG)/(ye.FADED_BY_DEG-ye.FULL_UNTIL_DEG);return Math.cos(n*Math.PI/2)**2}blurBySourceDisc(){const t=ye.BINS,e=ye.SOURCE_RADIUS_DEG*t/180,n=Math.max(1,Math.ceil(e)),s=[];let r=0;for(let a=-n;a<=n;a++){const o=Math.max(0,e*e-a*a),c=Math.sqrt(o);s.push(c),r+=c}if(!(r<=0)){this.scratch.set(this.radiance);for(let a=0;a<t;a++){let o=0,c=0,l=0;for(let u=-n;u<=n;u++){const d=Math.min(t-1,Math.max(0,a+u))*3,f=s[u+n];o+=this.scratch[d]*f,c+=this.scratch[d+1]*f,l+=this.scratch[d+2]*f}const h=a*3;this.radiance[h]=o/r,this.radiance[h+1]=c/r,this.radiance[h+2]=l/r}}}}class _r{static RADIUS=880;static GAIN=.15;static MOON_SATURATION=.15;object;material;sky=new ye;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(ye.BINS*4),this.texture=new Zl(this.texels,ye.BINS,1,un,xn),this.texture.minFilter=we,this.texture.magFilter=we,this.texture.wrapS=hn,this.texture.wrapT=hn,this.texture.needsUpdate=!0,this.material=new Be({uniforms:{uSource:{value:new F(0,1,0)},uStrength:{value:0},uTint:{value:new F(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:_r.GAIN}},vertexShader:`
5219
+ varying vec3 vDirection;
5220
+ void main() {
5221
+ vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
5222
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
5223
+ }
5224
+ `,fragmentShader:`
5225
+ precision highp float;
5226
+ varying vec3 vDirection;
5227
+ uniform vec3 uSource;
5228
+ uniform float uStrength;
5229
+ uniform vec3 uTint;
5230
+ uniform float uSaturation;
5231
+ uniform sampler2D uProfile;
5232
+ uniform float uGain;
5233
+
5234
+ void main() {
5235
+ vec3 dir = normalize(vDirection);
5236
+ // How far round from the source this line of sight is, which is the only thing a drop
5237
+ // cares about. Zero is straight at the source and half a turn is straight away from it —
5238
+ // the antisolar point, the centre every bow is drawn around.
5239
+ float scattering = acos(clamp(dot(dir, normalize(uSource)), -1.0, 1.0));
5240
+ vec3 light = texture2D(uProfile, vec2(scattering / 3.14159265, 0.5)).rgb * uGain * uTint;
5241
+ // Colour that the eye could not have resolved is taken back out — see MOON_SATURATION.
5242
+ float grey = dot(light, vec3(0.2126, 0.7152, 0.0722));
5243
+ light = mix(vec3(grey), light, uSaturation);
5244
+ gl_FragColor = vec4(light * uStrength, 1.0);
5245
+ }
5246
+ `,transparent:!0,blending:Ri,depthWrite:!1,side:Ce,fog:!1}),this.object=new se(new Cn(_r.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}update(t,e,n,s){const r=this.material.uniforms;if(e<=0){r.uStrength.value=0,this.object.visible=!1;return}this.computed||this.publish(),r.uSource.value.set(t.x,t.y,t.z).normalize(),r.uStrength.value=e,r.uTint.value.set(n[0],n[1],n[2]),r.uSaturation.value=s?1:_r.MOON_SATURATION,this.object.visible=!0}publish(){const e=this.sky.compute().data;for(let n=0,s=0;s<e.length;n+=4,s+=3)this.texels[n]=Us.toHalfFloat(e[s]),this.texels[n+1]=Us.toHalfFloat(e[s+1]),this.texels[n+2]=Us.toHalfFloat(e[s+2]),this.texels[n+3]=1;this.texture.needsUpdate=!0,this.computed=!0}dispose(){this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class Jd{constructor(t){this.state=t}next(){this.state=this.state+1831565813|0;let t=this.state;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}between(t,e){return t+this.next()*(e-t)}}class Ki{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(t){const{ratePerHour:e,durationMs:n,velocityKmS:s,seed:r}=t;if(e<=0||n<=0)return[];const a=e*n/36e5,o=new Jd(r),c=Math.floor(a),l=c+(o.next()<a-c?1:0),h=[];for(let u=0;u<l;u++){const d=Math.min(1,Math.max(0,(s-20)/52)),f=Ki.MAX_DURATION_MS-d*(Ki.MAX_DURATION_MS-Ki.MIN_DURATION_MS),g=o.between(5,70);h.push({t:o.between(0,n),durationMs:f*o.between(.7,1.3),fromRadiantDeg:g,bearingDeg:o.between(0,360),lengthDeg:Math.sin(g*Math.PI/180)*o.between(8,40)*(.6+d),brightness:o.next()**3}),h.sort((x,m)=>x.t-m.t)}return h}static aliveAt(t,e){return t.filter(n=>e>=n.t&&e<=n.t+n.durationMs).map(n=>({meteor:n,progress:(e-n.t)/n.durationMs}))}}class Fe{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=Fe.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(Fe.ACROSS-1)*6;static RADIUS=840;static MIN_HALF_WIDTH_DEG=.05;static BRIGHT_HALF_WIDTH_DEG=.22;object;positions;colors;meteors=[];radiantAltitudeDeg=0;radiantAzimuthDeg=0;constructor(){const t=Fe.MAX_CONCURRENT*Fe.SEGMENTS*Fe.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const e=new Ee;e.setAttribute("position",new le(this.positions,3)),e.setAttribute("color",new le(this.colors,3)),e.setDrawRange(0,0),this.object=new se(e,new Ji({vertexColors:!0,transparent:!0,blending:Ri,depthWrite:!1,fog:!1,side:An})),this.object.frustumCulled=!1}get schedule(){return this.meteors}setShower(t,e,n){this.meteors=t,this.radiantAltitudeDeg=e,this.radiantAzimuthDeg=n}update(t){const e=this.object.geometry;if(this.meteors.length===0){e.setDrawRange(0,0);return}const n=Ki.aliveAt(this.meteors,t).slice(0,Fe.MAX_CONCURRENT);let s=0;for(const{meteor:r,progress:a}of n){const o=this.radiantOf(r);if(!o)continue;const c=an(o.altitudeDeg,o.azimuthDeg,1),[l,h]=this.basisAround(c),u=r.fromRadiantDeg+a*r.lengthDeg,d=Math.max(r.fromRadiantDeg,u-r.lengthDeg*.6),f=Math.min(1,(1-a)*2.5),g=this.turn(l,h,r.bearingDeg),x=(.15+.85*r.brightness)*f,m=T=>x*T**1.6,p=T=>this.onSphere(c,g,d+(u-d)*T),A=T=>Fe.RADIUS*((Fe.MIN_HALF_WIDTH_DEG+Fe.BRIGHT_HALF_WIDTH_DEG*r.brightness*T)*Math.PI/180);for(let T=1;T<Fe.POINTS;T++){const M=(T-1)/Fe.SEGMENTS,y=T/Fe.SEGMENTS;s=this.pushRibbon(s,p(M),p(y),A(M),A(y),m(M),m(y))}}e.setDrawRange(0,s),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}midpointOf(t){const e=this.radiantOf(t);if(!e)return;const n=an(e.altitudeDeg,e.azimuthDeg,1),[s,r]=this.basisAround(n),a=this.turn(s,r,t.bearingDeg),o=this.onSphere(n,a,t.fromRadiantDeg+t.lengthDeg/2),c=Math.hypot(o.x,o.y,o.z)||1;return{altitudeDeg:Math.asin(o.y/c)*180/Math.PI,azimuthDeg:(Math.atan2(o.x,-o.z)*180/Math.PI+360)%360}}radiantOf(t){return t.radiant?t.radiant:this.radiantAltitudeDeg>0?{altitudeDeg:this.radiantAltitudeDeg,azimuthDeg:this.radiantAzimuthDeg}:void 0}pushRibbon(t,e,n,s,r,a,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(n,e))));for(let l=0;l<Fe.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,s,h),f=this.across(n,c,r,h),g=this.across(e,c,s,u),x=this.across(n,c,r,u),m=(p,A)=>p===0?A:0;t=this.push(t,d,m(h,a)),t=this.push(t,f,m(h,o)),t=this.push(t,g,m(u,a)),t=this.push(t,f,m(h,o)),t=this.push(t,x,m(u,o)),t=this.push(t,g,m(u,a))}return t}across(t,e,n,s){return{x:t.x+e.x*n*s,y:t.y+e.y*n*s,z:t.z+e.z*n*s}}push(t,e,n){const s=t*3;this.positions[s]=e.x,this.positions[s+1]=e.y,this.positions[s+2]=e.z;const r=Math.max(0,Math.min(1,n));return this.colors[s]=r*.9,this.colors[s+1]=r*.95,this.colors[s+2]=r,t+1}turn(t,e,n){const s=n*Math.PI/180,r=Math.cos(s),a=Math.sin(s);return{x:t.x*r+e.x*a,y:t.y*r+e.y*a,z:t.z*r+e.z*a}}onSphere(t,e,n){const s=n*Math.PI/180,r=Math.cos(s),a=Math.sin(s);return{x:(t.x*r+e.x*a)*Fe.RADIUS,y:(t.y*r+e.y*a)*Fe.RADIUS,z:(t.z*r+e.z*a)*Fe.RADIUS}}basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=this.normalise(this.cross(t,e));return[n,this.normalise(this.cross(t,n))]}subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}const U3=2;function F3(i){return i==="building"||i==="vehicle"}function O3(i,t){const e=i.litKeyframes;if(!e||e.length===0)return i.lit??!1;let n=e[0];for(const s of e){if(s.t>t)break;n=s}return n.lit}function z3(i,t){return i.pattern.kind==="steady"?!0:B3(i,t,t+1)>.5}function B3(i,t,e){if(i.pattern.kind==="steady")return 1;const{perMinute:n,dutyCycle:s,phase:r=0}=i.pattern,a=Math.min(Math.max(s,0),1);if(a===0||n<=0)return 0;const o=6e4/n,c=t/o+r,l=e/o+r;if(l<=c)return Math.min(Math.max(c-Math.floor(c),0),a)<a?1:0;const h=u=>Math.floor(u)*a+Math.min(u-Math.floor(u),a);return(h(l)-h(c))/(l-c)}function k3(i,t){const e=i.track,n={eastM:i.eastM,northM:i.northM,altitudeM:0,headingDeg:i.headingDeg};if(!e||e.length===0)return n;if(e.length===1||t<=e[0].t)return t0(e[0],i);const s=e[e.length-1];if(t>=s.t)return t0(s,i);for(let r=0;r<e.length-1;r++){const a=e[r],o=e[r+1];if(t<a.t||t>o.t)continue;const c=o.t-a.t,l=c===0?0:(t-a.t)/c;return{eastM:a.eastM+(o.eastM-a.eastM)*l,northM:a.northM+(o.northM-a.northM)*l,altitudeM:(a.altitudeM??0)+((o.altitudeM??0)-(a.altitudeM??0))*l,headingDeg:a.headingDeg??i.headingDeg}}return n}function t0(i,t){return{eastM:i.eastM,northM:i.northM,altitudeM:i.altitudeM??0,headingDeg:i.headingDeg??t.headingDeg}}const e0=Math.PI/180;function Xe(i,t,e,n,s=!1){const r=s?new Ji({color:new Mt(...e)}):new Tr({color:new Mt(...e)}),a=new se(t,r);return a.position.y=n,a.userData={emissive:s},a.castShadow=!s,a.receiveShadow=!s,i.add(a),a}const n0=.25,G3=.002;function H3(i){const t=/^#([0-9a-f]{6})$/i.exec(i);if(!t)return[1,1,1];const e=parseInt(t[1],16);return[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]}const Qd=[.32,.32,.3],jd=[1,.85,.5],tf=[.25,.25,.25],ef=[1,.97,.85],V3=[.55,.68,.72],zn=.03,Bn=.05,nf={front:0,behind:Math.PI,left:Math.PI/2,right:-Math.PI/2,"front-left":Math.PI/2,"behind-left":Math.PI/2,"front-right":-Math.PI/2,"behind-right":-Math.PI/2};function Ze(i,t){return i?.[t]}function kn(i,t,e,n,s,r,a,o){if(o===void 0)return;const c=new Tr({color:new Mt(...V3),transparent:!0,opacity:o/100}),l=new se(new Mn(t,e,n),c);l.position.set(s,r,a),i.add(l)}const mn=.05,ec=[.6,.58,.53],i0=[.5,.5,.48];function Ds(i,t,e,n,s,r,a,o){const c=new Tr({color:new Mt(...o),side:Ce}),l=new se(new Mn(t,e,n),c);l.position.set(s,r,a),i.add(l)}function W3(i,t,e,n,s,r,a,o,c){const l=(n-r)/2,h=(g,x,m,p)=>{g<=0||(t?Ds(i,g,x,mn,m,o+p,a,c):Ds(i,mn,x,g,a,o+p,m,c))};h(e,l,0,n/2-l/2),h(e,l,0,-(n/2-l/2));const u=[...s].sort((g,x)=>g.center-x.center);let d=-e/2;for(const g of u){const m=g.center-g.main/2-d;h(m,r,d+m/2,0),d=g.center+g.main/2}const f=e/2-d;h(f,r,d+f/2,0)}function sf(i,t,e,n,s,r,a,o,c,l){const h=(n+s)/2,u=s-n,d=(f,g,x,m)=>{f.length===0?g?Ds(i,x,u,mn,0,h,m,ec):Ds(i,mn,u,x,m,h,0,ec):W3(i,g,x,u,f,r,m,h,ec)};d(a,!0,t*2,-e+mn),d(o,!0,t*2,e-mn),d(c,!1,e*2,-t+mn),d(l,!1,e*2,t-mn),Ds(i,t*2,mn,e*2,0,n+mn,0,i0),Ds(i,t*2,mn,e*2,0,s-mn,0,i0)}function Cl(i,t,e,n){switch(i){case"front":return{x:0,z:-(e-n)};case"behind":return{x:0,z:e-n};case"left":return{x:-(t-n),z:0};case"right":return{x:t-n,z:0};case"front-left":return{x:-(t-n),z:-Gn};case"front-right":return{x:t-n,z:-Gn};case"behind-left":return{x:-(t-n),z:Gn};case"behind-right":return{x:t-n,z:Gn}}}function rf(i,t,e,n,s,r,a){const o=cf();o.scale.setScalar(n),o.rotation.y=nf[t];const{x:c,z:l}=Cl(t,s,r,a);o.position.set(c,e,l),i.add(o)}const Dl=6,Pl=6,Si=3,ar=1.4,or=Si*.5,af=1.2,of=.35,X3=.75,q3=1.6;function Y3(i,t,e,n){const s=new wn,r=Math.max(1,i+1),a=r*Si;Xe(s,new Mn(Dl,a,Pl),[.55,.54,.5],a/2);const o=Dl/2,c=Pl/2;for(let l=0;l<r;l++){const h=l*Si+Si/2;kn(s,ar,or,Bn,0,h,-c-zn,Ze(t,"front")),kn(s,ar,or,Bn,0,h,c+zn,Ze(t,"behind")),kn(s,Bn,or,ar,-o-zn,h,0,Ze(t,"left")),kn(s,Bn,or,ar,o+zn,h,0,Ze(t,"right"))}if(e){const l=Math.min(Math.max(n??0,0),r-1);rf(s,e,l*Si,.72,o,c,af);const h=u=>Ze(t,u)!==void 0?[{main:ar,center:0}]:[];sf(s,o,c,l*Si,(l+1)*Si,or,h("front"),h("behind"),h("left"),h("right"))}return s}function K3(){const i=new wn;return Xe(i,new Pi(.15,.22,2,8),[.32,.22,.14],1),Xe(i,new to(1.4,3,8),[.16,.32,.14],3.5),i}function Z3(i){const t=new wn;return Xe(t,new Pi(.05,.08,5,8),[.28,.28,.3],2.5),Xe(t,new Cn(.25,12,8),i?jd:Qd,5.1,!0),t}const $3=[.08,.08,.08],Mi=.8,Ts=1,Un=1.7,nc=.6,zi=.4,_a=1.2,Es=.7,Gn=.5,J3=Un;function Q3(i,t,e){const n=new wn;Xe(n,new Mn(1.8,1.4,4.2),[.45,.14,.14],.7),Xe(n,new Mn(Mi*2,nc,Ts*2),[.4,.12,.12],Un);for(const r of[-1.4,1.4])for(const a of[-.95,.95]){const o=Xe(n,new Pi(.4,.4,.3,12),$3,.4);o.rotation.z=Math.PI/2,o.position.x=a,o.position.z=r}const s=i?ef:tf;for(const r of[-.7,.7])Xe(n,new Cn(.15,8,6),s,.7,!0).position.set(r,.7,-2.1);if(kn(n,_a,zi,Bn,0,Un,-Ts-zn,Ze(t,"front")),kn(n,_a,zi,Bn,0,Un,Ts+zn,Ze(t,"behind")),kn(n,Bn,zi,Es,-Mi-zn,Un,-Gn,Ze(t,"front-left")),kn(n,Bn,zi,Es,-Mi-zn,Un,Gn,Ze(t,"behind-left")),kn(n,Bn,zi,Es,Mi+zn,Un,-Gn,Ze(t,"front-right")),kn(n,Bn,zi,Es,Mi+zn,Un,Gn,Ze(t,"behind-right")),e){rf(n,e,X3,.5,Mi,Ts,of);const r=(c,l)=>{const h=[];return Ze(t,c)!==void 0&&h.push({main:Es,center:-Gn}),Ze(t,l)!==void 0&&h.push({main:Es,center:Gn}),h},a=Ze(t,"front")!==void 0?[{main:_a,center:0}]:[],o=Ze(t,"behind")!==void 0?[{main:_a,center:0}]:[];sf(n,Mi,Ts,Un-nc/2,Un+nc/2,zi,a,o,r("front-left","behind-left"),r("front-right","behind-right"))}return n}const j3=[.95,.9,.82];function cf(){const i=new wn;Xe(i,new Pi(.25,.3,1.5,10),[.3,.3,.35],.75),Xe(i,new Cn(.22,10,8),[.62,.52,.46],1.72);const t=Xe(i,new to(.07,.16,8),j3,1.72);return t.rotation.x=-Math.PI/2,t.position.z=-.2,i}const tM=17,s0=18.5,ic=[.16,.16,.18];function eM(){const i=new wn,t=Xe(i,new Pi(1.8,1.8,s0*2,10),ic,0);t.rotation.x=Math.PI/2,Xe(i,new Mn(tM*2,.5,4.5),ic,0);const e=Xe(i,new Mn(.4,5.5,4),ic,3);return e.position.z=-s0+2,i}class bs{static occupantView(t){const e=t.witnessSide;if(!e)throw new Error("occupantView requires object.witnessSide to be set");const{x:n,z:s}=t.kind==="vehicle"?Cl(e,Mi,Ts,of):Cl(e,Dl/2,Pl/2,af),r=t.kind==="vehicle"?J3:(t.occupiedFloor??0)*Si+q3,a=(t.headingDeg??0)-nf[e]/e0;return{x:n,z:s,eyeY:r,headingDeg:a}}static build(t,e){const n=t.kind==="building"?Y3(t.floors??U3,t.windows,t.witnessSide,t.occupiedFloor):t.kind==="tree"?K3():t.kind==="streetlight"?Z3(e):t.kind==="vehicle"?Q3(e,t.windows,t.witnessSide):t.kind==="aircraft"?eM():cf();return t.headingDeg!==void 0&&(n.rotation.y=-t.headingDeg*e0),this.addLights(n,t.lights),t.kind==="aircraft"&&this.exemptFromFog(n),n}static exemptFromFog(t){for(const e of t.children){if(!(e instanceof se))continue;const n=e.material;n.fog=!1,n.needsUpdate=!0}}static addLights(t,e){for(const n of e??[]){const s=Xe(t,new Cn(n0,8,6),H3(n.color),n.offsetM.y,!0);s.position.set(n.offsetM.x,n.offsetM.y,n.offsetM.z),s.userData={emissive:!0,lightId:n.id},s.visible=!1}}static setLights(t,e,n,s){if(!e||e.length===0)return;const r=new Map(e.map(o=>[o.id,o])),a=Math.max(1,s*G3/n0);for(const o of t.children){if(!(o instanceof se))continue;const c=o.userData.lightId;if(!c)continue;const l=r.get(c);l&&(o.visible=z3(l,n),o.scale.setScalar(a*(l.intensity??1)**.5))}}static setLit(t,e,n){const s=e==="streetlight"?n?jd:Qd:n?ef:tf;for(const r of t.children){const a=r.userData;!(r instanceof se)||!a.emissive||a.lightId||r.material.color.setRGB(...s)}}static dispose(t){for(const e of t.children)e instanceof se&&(e.geometry.dispose(),e.material.dispose())}}function nM(i,t){return i.cloudCover===t.cloudCover&&i.cloudDarkness===t.cloudDarkness&&i.cloudBaseM===t.cloudBaseM&&i.highCloudCover===t.highCloudCover&&i.iceCrystalAlignment===t.iceCrystalAlignment&&i.lowerCloudCover===t.lowerCloudCover&&i.precipitationType===t.precipitationType&&i.precipitationIntensity===t.precipitationIntensity&&i.windDirectionDeg===t.windDirectionDeg&&i.windSpeed===t.windSpeed&&i.storm===t.storm}const va=900,r0=.5,pr=900,iM=6371e3,sM=3e4;function a0(i){const t=Math.sqrt(2*iM*Math.max(i,0));return Math.max(pr,Math.min(t,sM))}const sc=.5,rM=850,xa=850,rc=4,o0=1.5,aM=-1,oM=6,Il=-4,c0=.2,Ma=2600,cM=.97,lM=.38,l0=Il,hM=3,uM=.15,dM=.6,fM=40,pM=30,mM=[0,45,90,135,180,225,270,315],gM={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},_M=["en","fr"],vM=880,h0=40,xM=10,MM=1,SM=150,yM=55,EM=.5,bM=2.05,u0=.265,d0=[[0,0],...Array.from({length:8},(i,t)=>{const e=t*Math.PI/4;return[Math.cos(e)*u0,Math.sin(e)*u0]})],f0=700,AM=250/N0,TM=12,p0=5,ac=6,Bi=[.92,.92,.95],oc=[.15,.15,.19],m0={snow:{fallSpeedMPerS:2,size:.3,color:new Mt(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new Mt(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},ws=0,wM=0,g0=3e3,cr=20,RM=15,_0=ws,CM=40,v0=1,DM=9;function PM(i){return v0+(DM-v0)*i}const IM=new Mt(.75,.82,.92),LM=10,NM=.5;function UM(i){return lf(i/LM,NM,1)}const As=200,x0=.18,M0=.32,FM=.35,OM=new Mt(.85,.9,.98),S0=5,y0=.85,E0=.01;function cc(i,t){return Math.round(i*(E0+(1-E0)*t))}const b0=230,A0=.7,T0=.05,zM=.6,BM=.7,kM=.15,w0=.35,GM=3,HM=1/12,VM=.5,R0=8,C0=25,D0=.12,WM={Venus:new Mt(1,.96,.85),Mars:new Mt(1,.55,.4),Jupiter:new Mt(.95,.87,.72),Saturn:new Mt(.92,.86,.68)};class XM{renderer;scene=new sd;camera;celestialGroup=new wn;skyMesh;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;celestialLight=new wm(16777215,0);celestialLightTarget=new Re;skyLight=new Em(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;raycaster=new ko;weather=U0;observerElevationM=0;groundRadius=pr;terrainRadius=pr;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new F;rainLastVerticalFacing=-1;lightningArmed=!1;nextLightningAtS=null;lightningFlashRemainingS=0;baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunCloudTransmission=1;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new F;sunVisible=!1;lensFlareScratch=new F;sunOcclusionRaycaster=new ko;sunOcclusionDirectionScratch=new F;sunOcclusionRightScratch=new F;sunOcclusionUpScratch=new F;ufoOcclusionRaycaster=new ko;projectionKind="rectilinear";starPoints=0;equidistantPass;meteorSystem;cometTail;iceHalos;rainbow;cometKey;onLightningFlash;constructor(t,e=u3(),n){this.renderer=new Av({canvas:t,antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=gr,this.camera=new cn(60,t.width/Math.max(t.height,1),.1,va*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=e,this.onLightningFlash=n,this.celestialLight.shadow.mapSize.set(1024,1024),this.celestialLight.shadow.camera.left=-120,this.celestialLight.shadow.camera.right=120,this.celestialLight.shadow.camera.top=120,this.celestialLight.shadow.camera.bottom=-120,this.celestialLight.shadow.camera.near=1,this.celestialLight.shadow.camera.far=1e3,this.celestialLight.shadow.bias=-.0015,this.celestialLight.target=this.celestialLightTarget,this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight),this.scene.add(this.celestialGroup)}get currentTerrainAttribution(){return this.terrainAttribution}resize(t,e){this.renderer.setSize(t,e,!1),this.camera.aspect=t/Math.max(e,1),this.camera.updateProjectionMatrix(),this.render()}setObserverPose(t){t.headingDeg!==void 0?this.camera.rotation.set(t.pitchDeg*bn,-t.headingDeg*bn,0,"YXZ"):this.camera.rotation.set(t.pitchDeg*bn,this.camera.rotation.y,0,"YXZ"),t.elevationM!==this.observerElevationM&&(this.observerElevationM=t.elevationM,this.syncCloudLayer(),Math.abs(a0(t.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/pr),this.camera.far=Math.max(va*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.camera.position.y=1.6+t.elevationM,this.celestialGroup.position.y=this.camera.position.y,this.camera.fov!==t.fovDeg&&(this.camera.fov=t.fovDeg,this.camera.updateProjectionMatrix())}setTerrainProviders(t){this.terrainProviders=t,this.disposeMesh(this.terrainMesh),this.terrainMesh=void 0,this.terrainOrigin=void 0,this.terrainAttribution=void 0,this.terrainBuildToken++}setTerrainOrigin(t,e,n){if(t===void 0||e===void 0)return;const s=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-s)<s*.1){const{x:a,z:o}=ji(t,e,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(a*a+o*o)<SM*(s/pr))return}this.terrainOrigin={lat:t,lng:e},this.terrainRadius=s;const r=++this.terrainBuildToken;_3(t,e,this.terrainProviders,s).then(({mesh:a,attribution:o})=>{r===this.terrainBuildToken&&(this.disposeMesh(this.terrainMesh),a.renderOrder=MM,this.terrainMesh=a,this.terrainAttribution=o,this.scene.add(a),this.render(),n?.())}).catch(a=>{console.warn("Terrain build failed, keeping the flat ground fallback:",a),n?.()})}setShowCompass(t){this.showCompass!==t&&(this.showCompass=t,this.disposeCompassLabels(),t&&this.buildCompassLabels(),this.render())}setLensFlareArtifactIntensity(t){this.lensFlareArtifactIntensity!==t&&(this.lensFlareArtifactIntensity=t,this.lensFlare&&(this.lensFlare.uniforms.uFlareIntensity.value=t),this.render())}applyLensFlareTint(t){if(!this.lensFlare)return;const e=yM*this.sunCloudTransmission;this.lensFlare.uniforms.uColorGain.value.setRGB(e*t[0],e*t[1],e*t[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const t=this.lastSunPosition?.altitudeDeg??-90,e=Kv(t)*this.sunCloudTransmission*this.sunUnhiddenFraction,n=Oi(t);this.lensFlare.uniforms.uDazzleColour.value.setRGB(n[0],n[1],n[2]),this.lensFlare.uniforms.uVeilStrength.value=bM**2*Math.max(0,e)}setCompassHovered(t){this.compassHovered!==t&&(this.compassHovered=t,this.updateCompassVisibility())}setCompassForced(t){this.compassForced!==t&&(this.compassForced=t,this.updateCompassVisibility())}updateCompassVisibility(){const t=this.compassHovered||this.compassForced;for(const e of this.compassSprites)e.visible=t;this.render()}setWeather(t){nM(this.weather,t)||(this.weather=t,this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lightningArmed=t.storm&&t.cloudDarkness>=VM,this.lightningArmed||(this.nextLightningAtS=null,this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),this.render())}setDecor(t){if(this.decorObjects!==t){this.decorObjects=t;for(const e of this.decorGroups.values())e.removeFromParent(),bs.dispose(e);this.decorGroups.clear(),this.streetlightLights.clear();for(const e of t){const n=bs.build(e,e.lit??!1);this.scene.add(n),this.decorGroups.set(e.id,n),e.kind==="streetlight"&&this.addStreetlightLight(e.id,n)}this.celestialLight.castShadow=this.decorGroups.size>0}}updateDecorAnchoring(t,e,n=0){const s=t?.lat!==void 0&&t.lng!==void 0&&e?.lat!==void 0&&e?.lng!==void 0?ji(t.lat,t.lng,e.lat,e.lng):{x:0,z:0},r=this.decorObjects.find(l=>l.witnessSide!==void 0&&F3(l.kind)),a={x:0,z:0};let o=0;if(r){const l=bs.occupantView(r),h=-(r.headingDeg??0)*bn,u=l.x*Math.cos(h)+l.z*Math.sin(h),d=-l.x*Math.sin(h)+l.z*Math.cos(h),f=r.eastM+s.x,g=-r.northM+s.z;a.x=-(f+u),a.z=-(g+d),this.camera.position.y=l.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*bn,-(l.headingDeg+this.indoorLookYawDeg)*bn,0,"YXZ")}for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=k3(l,n);h.position.set(u.eastM+s.x+a.x,wM+u.altitudeM,-u.northM+s.z+a.z),u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*bn),o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(va*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-c)>1&&(this.camera.far=c,this.camera.updateProjectionMatrix())}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(t,e){this.indoorLookYawDeg=t,this.indoorLookPitchDeg=e}updateDecorLitState(t){for(const e of this.decorObjects){const n=this.decorGroups.get(e.id);if(n&&e.lights?.length&&bs.setLights(n,e.lights,t,n.position.distanceTo(this.camera.position)),e.kind!=="streetlight"&&e.kind!=="vehicle")continue;const s=this.decorGroups.get(e.id);if(!s)continue;const r=O3(e,t);bs.setLit(s,e.kind,r);const a=this.streetlightLights.get(e.id);a&&(a.visible=r)}}addStreetlightLight(t,e){const n=e.children.find(r=>r.userData.emissive);if(!n)return;const s=new Am(16764006,fM,pM);s.position.copy(n.position),s.castShadow=!0,s.shadow.mapSize.set(512,512),s.shadow.bias=-.002,e.add(s),this.streetlightLights.set(t,s)}setAstronomy(t){const e=hl(t.sun.altitudeDeg),n=e.horizon;this.baseFogColor=n,this.lastSunPosition=t.sun,this.buildSky(t.sun),this.buildGround(),this.updateCloudLighting(t.sun,n),this.updateCelestialLight(t,e.zenith,n),this.buildStars(t.stars,t.sun.altitudeDeg);const s=Uu(t.sun.altitudeDeg);this.setBodyMesh("sun",t.sun,rc,new Mt(1,.96,.88),t.sun.magnitude),this.setMoonMesh(t.moon,s),this.buildPlanets(t.planets,s),this.buildComet(t.comet,s),this.buildIceHalos(t.sun,t.moon),this.buildRainbow(t.sun,t.moon),this.scene.fog=new Yl(new Mt(...n),this.groundRadius*.2,this.groundRadius),this.syncAnimationLoop(),this.render()}updateCelestialLight(t,e,n){this.skyLight.color.setRGB(e[0],e[1],e[2]),this.skyLight.groundColor.setRGB(n[0],n[1],n[2]),this.skyLight.intensity=dM;const s=t.sun.altitudeDeg>=l0,r=!s&&t.moon.altitudeDeg>=l0;if(!s&&!r){this.celestialLight.intensity=0;return}const a=s?t.sun:t.moon,{x:o,y:c,z:l}=an(a.altitudeDeg,a.azimuthDeg,xa);this.celestialLight.position.set(o,c,l);const h=Oi(a.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const u=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*bn));this.celestialLight.intensity=(s?hM:uM)*u,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(t,e,n){this.meteorSystem||(this.meteorSystem=new Fe,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(t,e,n)}get meteorSchedule(){return this.meteorSystem?.schedule??[]}meteorMidpoint(t){return this.meteorSystem?.midpointOf(t)}updateMeteors(t){this.meteorSystem?.update(t)}setInstrument(t){this.projectionKind=t.projection;const e=F0.starPointsOf(t);e!==this.starPoints&&(this.starPoints=e,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=e))}render(){const t=this.usableEquidistantPass();if(!t){this.updateLensFlarePosition(),this.renderer.render(this.scene,this.camera);return}t.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition())}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const t=this.renderer.getDrawingBufferSize(new Ft);if(Ya.supports(this.camera.fov,t.x/Math.max(t.y,1)))return this.equidistantPass?this.equidistantPass.resize(t.x,t.y):this.equidistantPass=new Ya(t.x,t.y),this.equidistantPass}aimAtScreenPoint(t,e,n){const s=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!s){t.setFromCamera(new Ft(e,n),this.camera);return}const r=s.directionFor(e,n,this.camera.fov);this.camera.updateMatrixWorld(),t.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),t.ray.direction.set(r.x,r.y,r.z).applyQuaternion(this.camera.quaternion).normalize(),t.camera=this.camera}updateLensFlarePosition(){const t=this.lensFlare;if(!t)return;if(!this.sunVisible){t.mesh.visible=!1;return}if(this.camera.updateMatrixWorld(),this.lensFlareScratch.copy(this.sunWorldPosition).applyMatrix4(this.camera.matrixWorldInverse),this.lensFlareScratch.z>0){t.mesh.visible=!1;return}const e=this.sunVisibleFraction();if(e<=0){t.mesh.visible=!1;return}t.mesh.visible=!0,this.sunUnhiddenFraction=e,this.applyDazzleStrength();const n=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);t.uniforms.uLensPosition.value.set(n.x,n.y);const s=this.renderer.domElement.width,r=this.renderer.domElement.height;t.uniforms.uResolution.value.set(s,r),t.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}sunVisibleFraction(){let t=0;for(const e of d0)this.isSunOccluded(e[0],e[1])||t++;return t/d0.length}isSunOccluded(t=0,e=0){this.scene.updateMatrixWorld();const n=[];this.groundMesh&&n.push(this.groundMesh),this.terrainMesh&&n.push(this.terrainMesh);for(const o of this.decorGroups.values())n.push(o);if(n.length===0)return!1;const s=this.sunOcclusionDirectionScratch.copy(this.sunWorldPosition).sub(this.camera.position),r=s.length();if(s.normalize(),t!==0||e!==0){const o=Math.PI/180,c=this.sunOcclusionRightScratch.set(s.z,0,-s.x);c.lengthSq()<1e-9&&c.set(1,0,0),c.normalize();const l=this.sunOcclusionUpScratch.crossVectors(c,s).normalize();s.addScaledVector(c,t*o).addScaledVector(l,e*o).normalize()}this.sunOcclusionRaycaster.set(this.camera.position,s);const a=this.sunOcclusionRaycaster.intersectObjects(n,!0)[0];return a!==void 0&&a.distance<r}isScreenPointOccluded(t,e,n,s){if(s&&this.cloudMesh&&this.lowerCloudCover()>0)return!0;const r=[];for(const a of this.decorObjects){if(!a.occludesSourceIds?.includes(n))continue;const o=this.decorGroups.get(a.id);o&&r.push(o)}return r.length===0?!1:(this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),this.ufoOcclusionRaycaster.near=r0,this.ufoOcclusionRaycaster.intersectObjects(r,!0).length>0)}decorDistancesAt(t,e,n){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),this.ufoOcclusionRaycaster.near=r0;let s,r;for(const a of this.decorObjects){const o=this.decorGroups.get(a.id);if(!o)continue;const c=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];c&&(a.occludesSourceIds?.includes(n)?s=s===void 0?c.distance:Math.max(s,c.distance):r=r===void 0?c.distance:Math.min(r,c.distance))}return{behindM:s,inFrontM:r}}pickBodyAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const n=[...this.hitAreas.entries()],s=this.raycaster.intersectObjects(n.map(([,r])=>r))[0];if(s)return n.find(([,r])=>r===s.object)?.[0]}pickDecorAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const n=[...this.decorGroups.entries()],s=this.raycaster.intersectObjects(n.map(([,a])=>a),!0)[0];if(!s)return;let r=s.object;for(;r&&!n.some(([,a])=>a===r);)r=r.parent;return n.find(([,a])=>a===r)?.[0]}dispose(){this.stopTwinkle(),this.terrainBuildToken++,this.disposeMesh(this.skyMesh),this.disposeMesh(this.groundMesh),this.disposeMesh(this.terrainMesh),this.disposeCloudSystem(),this.disposeCirrus(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers(),this.meteorSystem?.dispose(),this.meteorSystem=void 0,this.iceHalos?.dispose(),this.iceHalos=void 0,this.rainbow?.dispose(),this.rainbow=void 0,this.cometTail?.dispose(),this.cometTail=void 0;for(const t of this.bodyMeshes.values())this.disposeMesh(t);this.bodyMeshes.clear();for(const t of[...this.hitAreas.keys()])this.disposeHitArea(t);for(const t of[...this.glareSprites.keys()])this.disposeGlare(t);this.disposeCompassLabels();for(const t of this.decorGroups.values())bs.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear(),this.lensFlare&&(this.lensFlare.mesh.removeFromParent(),this.lensFlare.mesh.geometry.dispose(),this.lensFlare.mesh.material.dispose(),this.lensFlare=void 0),this.renderer.dispose()}animationsRunning=!1;startTwinkle(){if(this.animationFrameId!==null||!this.needsAnimationLoop())return;let t;const e=n=>{const s=t===void 0?0:Math.min((n-t)/1e3,HM);t=n,this.updateTwinkle(n/1e3),this.updatePrecipitation(n/1e3,s),this.updateRain(s),this.updateLightning(n/1e3,s),this.lensFlare&&(this.lensFlare.uniforms.uTime.value=n/1e3),this.render(),this.animationFrameId=requestAnimationFrame(e)};this.animationFrameId=requestAnimationFrame(e)}setAnimationsRunning(t){t!==this.animationsRunning&&(this.animationsRunning=t,t?this.nextLightningAtS=null:this.lightningFlashRemainingS>0&&(this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),t||this.render())}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}restoreFogColor(){this.scene.fog&&this.scene.fog.color.setRGB(...this.baseFogColor)}needsAnimationLoop(){return this.animationsRunning&&(this.starTiers.length>0||this.precipitationPoints!==void 0||this.rainSystem!==void 0||this.lightningArmed||this.lensFlare!==void 0&&this.sunVisible)}syncAnimationLoop(){this.needsAnimationLoop()?this.startTwinkle():this.stopTwinkle()}buildSky(t){this.disposeMesh(this.skyMesh);const e=new Cn(va,32,16),n=e.attributes.position,s=[];for(let a=0;a<n.count;a++){const{altitudeDeg:o,azimuthDeg:c}=Cv(n.getX(a),n.getY(a),n.getZ(a)),l=Ov(o,c,t.azimuthDeg,t.altitudeDeg);s.push(l[0],l[1],l[2])}e.setAttribute("color",new De(s,3));const r=new Ji({vertexColors:!0,side:Ce,fog:!1,depthWrite:!1});this.skyMesh=new se(e,r),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){this.disposeMesh(this.groundMesh),this.groundRadius=a0(this.observerElevationM);const t=new Jl(this.groundRadius,48),e=new Tr({color:new Mt(sc,sc,sc),fog:!0});this.groundMesh=new se(t,e),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh)}cloudTransmission(t){const e=an(t.altitudeDeg,t.azimuthDeg,1);let n=1;const s=this.lowerCloudCover();s>0&&(n*=1-Te.alphaAt(e,Math.abs(this.cloudLayerOffset()),s)*cM);const r=this.weather.highCloudCover??0;return r>0&&(n*=1-Te.alphaAt(e,Ma,r)*lM),Math.max(0,Math.min(1,n))}setBodyMesh(t,e,n,s,r){if(this.disposeMesh(this.bodyMeshes.get(t)),this.disposeHitArea(t),this.disposeGlare(t),e.altitudeDeg<Il){this.bodyMeshes.delete(t),t==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:c}=an(e.altitudeDeg,e.azimuthDeg,xa),l=Oi(e.altitudeDeg),h=this.cloudTransmission(e),u=new Mt(s.r*l[0]*h,s.g*l[1]*h,s.b*l[2]*h),d=new Cn(n,16,16),f=new Ji({color:u,fog:!1}),g=new se(d,f);g.position.set(a,o,c),this.celestialGroup.add(g),this.bodyMeshes.set(t,g),this.setHitArea(t,a,o,c,n);const x=r-2.5*Math.log10(Math.max(h,.001));if(t==="sun"&&(this.sunCloudTransmission=h),t!=="sun"&&this.setGlare(t,a,o,c,x,u),t==="sun"){this.sunVisible=!0;const m=this.celestialGroup.scale.x;this.sunWorldPosition.set(a*m,o*m+this.celestialGroup.position.y,c*m),this.lensFlare||(this.lensFlare=N3(),this.lensFlare.uniforms.uOpacity.value=EM,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(l)}}setMoonMesh(t,e){const n="moon";if(this.disposeMesh(this.bodyMeshes.get(n)),this.disposeHitArea(n),this.disposeGlare(n),t.magnitude>e||t.altitudeDeg<Il){this.bodyMeshes.delete(n);return}const{x:s,y:r,z:a}=an(t.altitudeDeg,t.azimuthDeg,xa),o=Oi(t.altitudeDeg),c=new Mt(o[0],o[1],o[2]),l=new hr({map:eS(t.phase),color:c,fog:!1}),h=new qr(l);h.position.set(s,r,a);const u=rc*2;h.scale.set(u,u,1),this.celestialGroup.add(h),this.bodyMeshes.set(n,h),this.setHitArea(n,s,r,a,rc),this.setGlare(n,s,r,a,t.magnitude,c)}setHitArea(t,e,n,s,r){const a=new hr({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1}),o=new qr(a);o.position.set(e,n,s);const c=r*oM;o.scale.set(c,c,1),this.celestialGroup.add(o),this.hitAreas.set(t,o)}disposeHitArea(t){const e=this.hitAreas.get(t);e&&(e.removeFromParent(),e.material.dispose(),this.hitAreas.delete(t))}setGlare(t,e,n,s,r,a){const o=kv(r);if(o<=0){this.disposeGlare(t);return}const c=Vv(o),l=this.glareSprites.get(t),h=l??new qr(new hr({map:tS(),transparent:!0,blending:Ri,depthWrite:!1,fog:!1}));h.material.color.copy(a),h.material.opacity=qv(o),h.position.set(e,n,s),h.scale.set(c*2,c*2,1),l||(this.celestialGroup.add(h),this.glareSprites.set(t,h))}disposeGlare(t){const e=this.glareSprites.get(t);e&&(e.removeFromParent(),e.material.dispose(),this.glareSprites.delete(t))}buildComet(t,e){const n=t&&`comet:${t.id}`;if(!t||!n||t.magnitude>e){this.disposeComet();return}this.cometKey&&this.cometKey!==n&&this.disposeComet();const s=Ko(t.magnitude),r=Zo(s);this.cometKey=n,this.setBodyMesh(n,t.position,o0*(.5+.5*s),new Mt(r,r,r),t.magnitude),this.cometTail||(this.cometTail=new rn(xa),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(t.position,t.tailEnd,s)}buildIceHalos(t,e){this.iceHalos||(this.iceHalos=new Fn,this.iceHalos.onReady=()=>this.render(),this.celestialGroup.add(this.iceHalos.object));const n=this.weather.highCloudCover;if(n===void 0){this.iceHalos.update({x:0,y:1,z:0},-1,0,[1,1,1],{cover:0,layerHeight:Ma},0);return}const s=this.weather.lowerCloudCover??this.weather.cloudCover,r=$t.deckLitUntilDeg($t.DECK_HEIGHT_M),a=t.altitudeDeg>-r?t:e,o=$t.strength(n,s,a.altitudeDeg,r)*(a===t?1:c0),{x:c,y:l,z:h}=an(a.altitudeDeg,a.azimuthDeg,1),u=Oi(a.altitudeDeg);this.iceHalos.update({x:c,y:l,z:h},a.altitudeDeg,o,[u[0],u[1],u[2]],{cover:n,layerHeight:Ma},this.weather.iceCrystalAlignment??If)}buildRainbow(t,e){this.rainbow||(this.rainbow=new _r,this.celestialGroup.add(this.rainbow.object));const n=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity:0,s=t.altitudeDeg>0,r=s?t:e,a=this.weather.lowerCloudCover??this.weather.cloudCover,o=c0*je.moonlightShare(e.magnitude),c=je.strength(n,a,r.altitudeDeg)*(s?1:o);if(c<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:l,y:h,z:u}=an(r.altitudeDeg,r.azimuthDeg,1),d=Oi(r.altitudeDeg);this.rainbow.update({x:l,y:h,z:u},c,[d[0],d[1],d[2]],s)}disposeComet(){this.cometTail?.set(void 0,void 0,0),this.cometKey&&(this.disposeMesh(this.bodyMeshes.get(this.cometKey)),this.bodyMeshes.delete(this.cometKey),this.disposeHitArea(this.cometKey),this.disposeGlare(this.cometKey),this.cometKey=void 0)}buildPlanets(t,e){const n=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[]]);for(const s of t){if(s.magnitude>e)continue;n.add(s.body);const r=Ko(s.magnitude),a=Zo(r),o=WM[s.body]??new Mt(1,1,1),c=new Mt(o.r*a,o.g*a,o.b*a),l=o0*(.5+.5*r);this.setBodyMesh(s.body,s.position,l,c,s.magnitude)}for(const s of[...this.bodyMeshes.keys()])n.has(s)||(this.disposeMesh(this.bodyMeshes.get(s)),this.bodyMeshes.delete(s),this.disposeHitArea(s),this.disposeGlare(s))}buildStars(t,e){if(this.disposeStarTiers(),!t||t.catalog.count===0){this.syncAnimationLoop();return}const{catalog:n,date:s,observer:r}=t,a=Uu(e),o=lc(1337),c=[];for(let l=0;l<n.count;l++){const h=n.mag[l];if(h>a)continue;const{altitudeDeg:u,azimuthDeg:d}=ao(n.ra[l],n.dec[l],s,r);if(u<aM)continue;const{x:f,y:g,z:x}=an(u,d,rM);c.push({x:f,y:g,z:x,brightness:Ko(h),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}this.starTiers=bd.map((l,h)=>{const u=c.filter(M=>$v(M.brightness)===h),d=new Float32Array(u.length*3),f=new Float32Array(u.length),g=new Float32Array(u.length),x=new Float32Array(u.length);u.forEach((M,y)=>{d[y*3]=M.x,d[y*3+1]=M.y,d[y*3+2]=M.z,f[y]=M.brightness,g[y]=M.phase,x[y]=M.speedFactor});const m=new Ee;m.setAttribute("position",new le(d,3));const p=new le(new Float32Array(u.length*3),3);m.setAttribute("color",p);const A=new cd({vertexColors:!0,size:l.size,sizeAttenuation:!1,fog:!1});Wi.apply(A);const T=new Pa(m,A);return this.celestialGroup.add(T),{points:T,colorAttribute:p,brightness:f,phase:g,speedFactor:x}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(t){for(const e of this.starTiers){const n=e.colorAttribute.array;for(let s=0;s<e.brightness.length;s++){const r=jv(e.brightness[s],{phase:e.phase[s],speedFactor:e.speedFactor[s]},t),a=Zo(e.brightness[s])*r;n[s*3]=a,n[s*3+1]=a,n[s*3+2]=a}e.colorAttribute.needsUpdate=!0}}buildClouds(){this.disposeCloudSystem();const t=this.lowerCloudCover();if(t<=0)return;const e=this.weather.cloudDarkness,n=new Mt(Bi[0]+(oc[0]-Bi[0])*e,Bi[1]+(oc[1]-Bi[1])*e,Bi[2]+(oc[2]-Bi[2])*e),{material:s,uniforms:r}=Qu(n,t,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=s,this.cloudUniforms=r,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const a=ju(f0);this.cloudMesh=new se(a,s),this.cloudLayerOffset()<0&&(this.cloudMesh.scale.y=-1),this.cloudMesh.renderOrder=p0,this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.lowerCloudCover??this.weather.cloudCover}buildCirrus(){this.disposeCirrus();const t=this.weather.highCloudCover??0;if(t<=0)return;const{material:e,uniforms:n}=Qu(new Mt(...Bi),t,Ma,1);this.cirrusMaterial=e,this.cirrusUniforms=n,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new se(ju(f0*1.04),e),this.cirrusMesh.renderOrder=p0-1,this.celestialGroup.add(this.cirrusMesh)}disposeCirrus(){this.cirrusMesh&&(this.cirrusMesh.removeFromParent(),this.cirrusMesh.geometry.dispose()),this.cirrusMaterial?.dispose(),this.cirrusMesh=void 0,this.cirrusMaterial=void 0,this.cirrusUniforms=void 0}syncCloudLayer(){const t=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(t)),this.cloudMesh&&(this.cloudMesh.scale.y=t<0?-1:1)}cloudLayerOffset(){const e=((this.weather.cloudBaseM??N0)-this.observerElevationM)*AM;return Math.sign(e||1)*Math.max(Math.abs(e),TM)}updateCloudLighting(t,e){const n=[this.cloudUniforms,this.cirrusUniforms].filter(l=>l!==void 0);if(n.length===0)return;const{x:s,y:r,z:a}=an(t.altitudeDeg,t.azimuthDeg,1),o=Oi(t.altitudeDeg),c=Math.max(0,Math.sin(Math.max(t.altitudeDeg,0)*bn));for(const l of n)l.sunDir.value.set(s,r,a),l.sunColor.value.setRGB(o[0]*c,.96*o[1]*c,.88*o[2]*c),l.ambientColor.value.setRGB(e[0],e[1],e[2])}disposeCloudSystem(){this.cloudMesh&&(this.cloudMesh.removeFromParent(),this.cloudMesh.geometry.dispose()),this.cloudMaterial?.dispose(),this.cloudMesh=void 0,this.cloudMaterial=void 0,this.cloudUniforms=void 0}disposePrecipitationPoints(){this.precipitationPoints&&(this.precipitationPoints.removeFromParent(),this.precipitationPoints.geometry.dispose(),this.precipitationPoints.material.dispose()),this.precipitationPoints=void 0,this.precipitationPositions=void 0,this.precipitationPhase=void 0,this.precipitationSpeedJitter=void 0,this.precipitationWobbleFreqJitter=void 0,this.precipitationWobbleAmpJitter=void 0,this.precipitationBounceRemaining=void 0,this.precipitationBounceHeight=void 0,this.precipitationBounceDuration=void 0,this.precipitationBounceVelX=void 0,this.precipitationBounceVelZ=void 0,this.precipitationUniforms=void 0}buildPrecipitation(){this.disposePrecipitationPoints(),this.disposeRain();const t=this.weather.precipitationType;if(t==="none")return;if(t==="rain"){this.buildRain();return}const e=m0[t],n=e.poolSize,s=lc(9001),r=new Float32Array(n*3),a=new Float32Array(n),o=new Float32Array(n),c=new Float32Array(n),l=new Float32Array(n),h=new Float32Array(n),u=new Float32Array(n),d=new Float32Array(n),f=new Float32Array(n),g=new Float32Array(n);for(let T=0;T<n;T++){const M=s()*Math.PI*2,y=s()*e.radiusM;r[T*3]=Math.cos(M)*y,r[T*3+1]=ws+s()*(e.topYM-ws),r[T*3+2]=Math.sin(M)*y,a[T]=s()*Math.PI*2,o[T]=.7+s()*.6,c[T]=.6+s()*.8,l[T]=.4+s()*1.2}const x=new Ee;x.setAttribute("position",new le(r,3)),x.setDrawRange(0,cc(n,this.weather.precipitationIntensity));const m={uSize:{value:e.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:e.opacity},uColor:{value:e.color},uHazeColor:{value:new Mt(...this.baseFogColor)},uTexture:{value:qM(t)},uNearFocusDistance:{value:S0},uHazeDistance:{value:e.radiusM*y0}},p=new Be({uniforms:m,vertexShader:QM,fragmentShader:jM,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const A=new Pa(x,p);A.renderOrder=ac,this.scene.add(A),this.precipitationPoints=A,this.precipitationPositions=r,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=c,this.precipitationWobbleAmpJitter=l,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=u,this.precipitationBounceDuration=d,this.precipitationBounceVelX=f,this.precipitationBounceVelZ=g}updatePrecipitation(t,e){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter||(this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor),e<=0))return;const n=this.weather.precipitationType;if(n==="none"||n==="rain")return;const s=m0[n],r=this.weather.windDirectionDeg*bn,a=Math.sin(r)*this.weather.windSpeed*s.driftSensitivity,o=-Math.cos(r)*this.weather.windSpeed*s.driftSensitivity,c=this.precipitationPositions,l=this.precipitationPhase,h=this.precipitationSpeedJitter,u=this.precipitationWobbleFreqJitter,d=this.precipitationWobbleAmpJitter,f=this.precipitationBounceRemaining,g=this.precipitationBounceHeight,x=this.precipitationBounceDuration,m=this.precipitationBounceVelX,p=this.precipitationBounceVelZ,A=n==="snow"&&u&&d,T=n==="hail"&&f&&g&&x&&m&&p;for(let M=0,y=0;M<c.length;M+=3,y++){if(T&&f[y]>0){if(f[y]-=e,f[y]<=0){const v=Math.random()*Math.PI*2,E=Math.sqrt(Math.random())*s.radiusM;c[M]=Math.cos(v)*E,c[M+1]=s.topYM,c[M+2]=Math.sin(v)*E,f[y]=0}else{const v=1-f[y]/x[y];c[M+1]=ws+Math.sin(Math.PI*v)*g[y],c[M]=ya(c[M]+(a+m[y])*e,s.radiusM),c[M+2]=ya(c[M+2]+(o+p[y])*e,s.radiusM)}continue}let b=0,R=0;if(A){const v=zM*u[y],E=BM*d[y];b=Math.sin(t*v*Math.PI*2+l[y])*E,R=Math.sin(t*v*Math.PI*2+l[y]+Math.PI/2)*E}if(c[M]+=(a+b)*e,c[M+1]-=s.fallSpeedMPerS*h[y]*e,c[M+2]+=(o+R)*e,c[M]=ya(c[M],s.radiusM),c[M+2]=ya(c[M+2],s.radiusM),c[M+1]<ws){if(T){g[y]=w0*(.2+Math.random()*1.6),x[y]=kM*(.5+Math.random()),f[y]=x[y];const D=Math.random()*Math.PI*2,C=GM*(g[y]/w0);m[y]=Math.cos(D)*C,p[y]=Math.sin(D)*C,c[M+1]=ws;continue}const v=Math.random()*Math.PI*2,E=Math.sqrt(Math.random())*s.radiusM;c[M]=Math.cos(v)*E,c[M+1]=s.topYM,c[M+2]=Math.sin(v)*E}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const t=PM(this.weather.precipitationIntensity);this.rainSystem=T3({count:g0,radiusM:cr,heightM:RM,bottomYM:_0,overallSpeed:CM,color:IM,opacity:.85,visibleCount:cc(g0,this.weather.precipitationIntensity),speedStreak:UM(t),pixelSize:b0,seed:9001,nearFocusDistanceM:S0,hazeDistanceM:cr*y0,hazeColor:new Mt(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.rainSystem.points.renderOrder=ac,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const t=lc(4242),e=new Float32Array(As*3),n=new Float32Array(As),s=new Float32Array(As),r=new Float32Array(As);for(let h=0;h<As;h++){const u=t()*Math.PI*2,d=Math.sqrt(t())*cr;e[h*3]=Math.cos(u)*d,e[h*3+1]=_0,e[h*3+2]=Math.sin(u)*d,s[h]=Sa(x0,M0),n[h]=t()*s[h],r[h]=n[h]/s[h]}const a=new Ee;a.setAttribute("position",new le(e,3));const o=new le(r,1);a.setAttribute("aLife",o),a.setDrawRange(0,cc(As,this.weather.precipitationIntensity));const c=new Be({uniforms:{uMaxSize:{value:FM},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:OM},uTexture:{value:ZM()}},vertexShader:$M,fragmentShader:JM,transparent:!0,depthWrite:!1}),l=new Pa(a,c);l.renderOrder=ac,this.scene.add(l),this.rainSplashSystem={points:l,positions:e,life:n,duration:s,lifeAttribute:o}}disposeRain(){this.rainSystem&&(this.rainSystem.points.removeFromParent(),this.rainSystem.points.geometry.dispose(),this.rainSystem.points.material.dispose()),this.rainSystem=void 0,this.disposeRainSplashes()}disposeRainSplashes(){this.rainSplashSystem&&(this.rainSplashSystem.points.removeFromParent(),this.rainSplashSystem.points.geometry.dispose(),this.rainSplashSystem.points.material.dispose()),this.rainSplashSystem=void 0}updateRain(t){const e=this.rainSystem;if(!e)return;e.uniforms.uTime.value+=t,e.uniforms.uHazeColor.value.setRGB(...this.baseFogColor);const n=this.weather.windDirectionDeg*bn,s=Math.sin(n)*this.weather.windSpeed,r=-Math.cos(n)*this.weather.windSpeed,a=cr,o=l=>(l%(a*2)+a*3)%(a*2)-a;e.uniforms.uWindOffset.value.set(o(e.uniforms.uWindOffset.value.x+s*t),o(e.uniforms.uWindOffset.value.y+r*t)),this.camera.getWorldDirection(this.rainCameraDirection);const c=Math.abs(this.rainCameraDirection.y);if(Math.abs(c-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=c;const l=A0+(1-A0)*(1-c),h=T0+(1-T0)*(1-c);e.uniforms.uUvSquash.value=h,e.uniforms.uPixelSize.value=b0*l*(.5+.5*h)}this.updateRainSplashes(t)}updateRainSplashes(t){const e=this.rainSplashSystem;if(!e||t<=0)return;const{positions:n,life:s,duration:r,lifeAttribute:a}=e,o=a.array;for(let c=0,l=0;c<n.length;c+=3,l++){if(s[l]+=t,s[l]>=r[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*cr;n[c]=Math.cos(h)*u,n[c+2]=Math.sin(h)*u,r[l]=Sa(x0,M0),s[l]=0}o[l]=s[l]/r[l]}e.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}updateLightning(t,e){if(this.lightningArmed){if(this.lightningFlashRemainingS>0){this.lightningFlashRemainingS=Math.max(0,this.lightningFlashRemainingS-e);const n=this.lightningFlashRemainingS/D0;this.scene.fog&&this.scene.fog.color.setRGB(this.baseFogColor[0]+(1-this.baseFogColor[0])*n,this.baseFogColor[1]+(1-this.baseFogColor[1])*n,this.baseFogColor[2]+(1-this.baseFogColor[2])*n);return}if(this.nextLightningAtS===null){this.nextLightningAtS=t+Sa(R0,C0);return}t>=this.nextLightningAtS&&(this.lightningFlashRemainingS=D0,this.nextLightningAtS=t+Sa(R0,C0),this.onLightningFlash?.())}}buildCompassLabels(){const t=Nl(navigator.languages,_M),e=gM[t];this.compassSprites=mM.map((n,s)=>{const r=e[s],a=new hr({map:nS(r),depthTest:!1,fog:!1}),o=new qr(a),{x:c,y:l,z:h}=an(0,n,vM);return o.position.set(c,l,h),o.scale.set(h0,h0,1),o.renderOrder=xM,o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o})}disposeCompassLabels(){for(const t of this.compassSprites)t.removeFromParent(),t.material.map?.dispose(),t.material.dispose();this.compassSprites=[]}disposeStarTiers(){for(const t of this.starTiers)this.disposeMesh(t.points);this.starTiers=[]}disposeMesh(t){if(!t)return;t.removeFromParent(),"geometry"in t&&t.geometry.dispose();const e=t.material;for(const n of Array.isArray(e)?e:[e]){const s=n.map;s&&s.dispose(),n.dispose()}}}const bn=Math.PI/180;function lf(i,t,e){return Math.max(t,Math.min(e,i))}function Sa(i,t){return i+Math.random()*(t-i)}function ya(i,t){return(i%(t*2)+t*3)%(t*2)-t}let Ea,ba;function qM(i){switch(i){case"snow":return YM();case"hail":return KM()}}function YM(){if(Ea)return Ea;const i=64,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=e.createRadialGradient(i/2,i/2,0,i/2,i/2,i/2);return n.addColorStop(0,"rgba(255,255,255,0.95)"),n.addColorStop(.5,"rgba(255,255,255,0.55)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,i,i),Ea=new oi(t),Ea}function KM(){if(ba)return ba;const i=64,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=e.createRadialGradient(i/2,i/2,0,i/2,i/2,i/2);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.55,"rgba(255,255,255,0.95)"),n.addColorStop(.8,"rgba(255,255,255,0.4)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,i,i),ba=new oi(t),ba}let Aa;function ZM(){if(Aa)return Aa;const i=64,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=e.createRadialGradient(i/2,i/2,0,i/2,i/2,i/2);return n.addColorStop(0,"rgba(255,255,255,0)"),n.addColorStop(.4,"rgba(255,255,255,0)"),n.addColorStop(.6,"rgba(255,255,255,0.9)"),n.addColorStop(.8,"rgba(255,255,255,0.25)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,i,i),Aa=new oi(t),Aa}const $M=`
5219
5247
  uniform float uMaxSize;
5220
5248
  uniform float uScale;
5221
5249
  attribute float aLife;
@@ -5228,7 +5256,7 @@ void main() {
5228
5256
  vOpacity = 1.0 - aLife;
5229
5257
  gl_Position = projectionMatrix * mvPosition;
5230
5258
  }
5231
- `,WM=`
5259
+ `,JM=`
5232
5260
  uniform vec3 uColor;
5233
5261
  uniform sampler2D uTexture;
5234
5262
  varying float vOpacity;
@@ -5239,7 +5267,7 @@ void main() {
5239
5267
  if (alpha < 0.01) discard;
5240
5268
  gl_FragColor = vec4(uColor, alpha);
5241
5269
  }
5242
- `,XM=`
5270
+ `,QM=`
5243
5271
  uniform float uSize;
5244
5272
  uniform float uScale;
5245
5273
  uniform float uNearFocusDistance;
@@ -5265,7 +5293,7 @@ void main() {
5265
5293
  gl_PointSize = max(1.0, uSize * uScale / dist + vNearBlur * 12.0);
5266
5294
  gl_Position = projectionMatrix * mvPosition;
5267
5295
  }
5268
- `,qM=`
5296
+ `,jM=`
5269
5297
  precision mediump float;
5270
5298
  uniform sampler2D uTexture;
5271
5299
  uniform vec3 uColor;
@@ -5280,4 +5308,4 @@ void main() {
5280
5308
  float blur = max(vNearBlur, vHaze);
5281
5309
  gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * 0.5));
5282
5310
  }
5283
- `;let xa;function YM(){if(xa)return xa;const i=128,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=e.createRadialGradient(i/2,i/2,0,i/2,i/2,i/2);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.4,"rgba(255,255,255,0.35)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,i,i),xa=new ii(t),xa}function KM(i){const e=document.createElement("canvas");e.width=128,e.height=128;const n=e.getContext("2d"),s=128/2-2,r=128/2,a=128/2,o="#2e2b26",c="#f4f1e2";n.fillStyle=o,n.beginPath(),n.arc(r,a,s,0,Math.PI*2),n.fill();const l=ef(i.illuminatedFraction,0,1),h=i.phaseFraction<.5,u=s*Math.abs(1-2*l),d=l<.5;return n.save(),n.beginPath(),n.arc(r,a,s,0,Math.PI*2),n.clip(),n.fillStyle=c,n.beginPath(),h?(n.arc(r,a,s,-Math.PI/2,Math.PI/2,!1),n.ellipse(r,a,u,s,0,Math.PI/2,-Math.PI/2,d)):(n.arc(r,a,s,Math.PI/2,-Math.PI/2,!1),n.ellipse(r,a,u,s,0,-Math.PI/2,Math.PI/2,d)),n.fill(),n.restore(),new ii(e)}function ZM(i){const t=document.createElement("canvas");t.width=128,t.height=128;const e=t.getContext("2d");return e.fillStyle="rgba(0, 0, 0, 0.55)",e.beginPath(),e.arc(64,64,60,0,Math.PI*2),e.fill(),e.fillStyle="#ffffff",e.font="bold 52px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(i,64,68),new ii(t)}function nc(i){let t=i;return function(){t|=0,t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const E0=new Map;function $M(i){const t=i.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),e=t,n=e*Float32Array.BYTES_PER_ELEMENT;return{count:t,ra:new Float32Array(i,0*n,e),dec:new Float32Array(i,1*n,e),mag:new Float32Array(i,2*n,e),ci:new Float32Array(i,3*n,e)}}function JM(i){let t=E0.get(i);return t||(t=fetch(i).then(e=>e.arrayBuffer()).then($M),E0.set(i,t)),t}const QM=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,jM=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,tS=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,eS=20,nS=1;class iS{context;buffers=new Map;ambientSource;ambientGain;ambientKey="none";ambientToken=0;ambientVolume=0;windSource;windGain;windActive=!1;windToken=0;windVolume=0;paused=!0;requested={type:"none",intensity:0,windSpeed:0};resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",t);return}}this.context.state==="suspended"&&this.context.resume()}setAmbient(t,e,n){if(this.requested={type:t,intensity:e,windSpeed:n},!this.context)return;this.paused&&(t="none",e=0,n=0);const s=t==="rain"||t==="hail"?t:"none";if(this.ambientVolume=s==="hail"?Math.min(1,e*1.3+.2):s==="rain"?e:0,s!==this.ambientKey){this.ambientKey=s;const a=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,s!=="none"&&this.startLoop(QM,this.ambientVolume).then(o=>this.applyIfCurrent(o,a,()=>this.ambientToken,c=>{this.ambientSource=c?.source,this.ambientGain=c?.gain,c&&(c.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(n/eS,1);const r=n>nS;if(r!==this.windActive){this.windActive=r;const a=++this.windToken;this.stopSource(this.windSource,this.windGain),this.windSource=void 0,this.windGain=void 0,r&&this.startLoop(jM,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,c=>{this.windSource=c?.source,this.windGain=c?.gain,c&&(c.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(t){if(t===this.paused)return;this.paused=t;const{type:e,intensity:n,windSpeed:s}=this.requested;this.setAmbient(e,n,s)}playThunder(){!this.context||this.paused||this.playOneShot(tS,.9)}dispose(){this.ambientToken++,this.windToken++,this.stopSource(this.ambientSource,this.ambientGain),this.stopSource(this.windSource,this.windGain),this.ambientSource=void 0,this.ambientGain=void 0,this.windSource=void 0,this.windGain=void 0,this.context?.close(),this.context=void 0,this.buffers.clear()}applyIfCurrent(t,e,n,s){if(e!==n()){t?.source.stop();return}s(t)}async startLoop(t,e){const n=this.context;if(n)try{const s=await this.getBuffer(t),r=n.createBufferSource();r.buffer=s,r.loop=!0;const a=n.createGain();return a.gain.value=e,r.connect(a).connect(n.destination),r.start(),{source:r,gain:a}}catch(s){console.warn("Weather ambient sound failed to load, staying silent:",s);return}}async playOneShot(t,e){const n=this.context;if(n)try{const s=await this.getBuffer(t),r=n.createBufferSource();r.buffer=s;const a=n.createGain();a.gain.value=e,r.connect(a).connect(n.destination),r.start()}catch(s){console.warn("Thunder sound failed to load:",s)}}async getBuffer(t){const e=this.context;if(!e)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(t);return n||(n=fetch(t).then(s=>{if(!s.ok)throw new Error(`Audio fetch failed (${s.status}): ${t}`);return s.arrayBuffer()}).then(s=>e.decodeAudioData(s)),this.buffers.set(t,n)),n}stopSource(t,e){try{t?.stop()}catch{}t?.disconnect(),e?.disconnect()}}class Qn{constructor(t){this.elements=t;const{eccentricity:e,perihelionAu:n}=t,[s,r]=this.perifocalAxes(),a=Math.sqrt(Qn.SUN_GM_AU3_PER_DAY2*(1+e)/n);this.perihelionPosition=this.scale(s,n),this.perihelionVelocity=this.scale(r,a),this.inverseSemiMajorAxis=(1-e)/n}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(t){const e=t-this.elements.perihelionJd,n=this.universalAnomaly(e),s=this.inverseSemiMajorAxis*n*n,r=this.elements.perihelionAu,a=1-n*n/r*Qn.stumpffC(s),o=e-n*n*n/Math.sqrt(Qn.SUN_GM_AU3_PER_DAY2)*Qn.stumpffS(s);return{x:a*this.perihelionPosition.x+o*this.perihelionVelocity.x,y:a*this.perihelionPosition.y+o*this.perihelionVelocity.y,z:a*this.perihelionPosition.z+o*this.perihelionVelocity.z}}heliocentricDistanceAt(t){const e=this.positionAt(t);return Math.hypot(e.x,e.y,e.z)}universalAnomaly(t){if(t===0)return 0;const e=Math.sign(t),n=Math.sqrt(Qn.SUN_GM_AU3_PER_DAY2)*Math.abs(t),s=o=>{const c=this.inverseSemiMajorAxis*o*o,l=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*l)*o*o*o*Qn.stumpffS(c)+l*o};let r=Math.max(1,n/this.elements.perihelionAu);for(;s(r)<n;)r*=2;let a=0;for(let o=0;o<Qn.MAX_ITERATIONS&&r-a>1e-13*Math.max(1,r);o++){const c=(a+r)/2;s(c)<n?a=c:r=c}return e*(a+r)/2}perifocalAxes(){const t=this.elements.ascendingNodeDeg*Math.PI/180,e=this.elements.argumentOfPerihelionDeg*Math.PI/180,n=this.elements.inclinationDeg*Math.PI/180,s=Math.cos(t),r=Math.sin(t),a=Math.cos(e),o=Math.sin(e),c=Math.cos(n),l=Math.sin(n);return[{x:s*a-r*o*c,y:r*a+s*o*c,z:o*l},{x:-s*o-r*a*c,y:-r*o+s*a*c,z:a*l}]}scale(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}static stumpffC(t){if(Math.abs(t)<1e-6)return 1/2-t/24+t*t/720;if(t>0)return(1-Math.cos(Math.sqrt(t)))/t;const e=Math.sqrt(-t);return(Math.cosh(e)-1)/-t}static stumpffS(t){if(Math.abs(t)<1e-6)return 1/6-t/120+t*t/5040;if(t>0){const n=Math.sqrt(t);return(n-Math.sin(n))/(n*n*n)}const e=Math.sqrt(-t);return(Math.sinh(e)-e)/(e*e*e)}}const nf=[{id:"halley-1910",designation:"1P/Halley",name:{en:"Halley's Comet",fr:"comète de Halley"},orbit:{eccentricity:.9672960498922706,perihelionAu:.5872100477652511,inclinationDeg:162.218798367122,ascendingNodeDeg:58.56208298700436,argumentOfPerihelionDeg:111.7366940639061,perihelionJd:2.4187816784171113e6},peakMagnitude:0,peakOn:"1910-05-20",absoluteMagnitude:4.72,activityExponent:4,tailLengthDeg:100,tailLengthAu:.1638,note:"Passed 0.15 au from Earth on 20 May 1910, and the Earth crossed the outer tail the day before — the apparition that produced a genuine public panic."},{id:"brooks-1911",designation:"C/1911 O1",name:{en:"Comet Brooks",fr:"comète Brooks"},orbit:{eccentricity:.9876404970138669,perihelionAu:.4898172916113738,inclinationDeg:33.34043866978714,ascendingNodeDeg:293.7022074981857,argumentOfPerihelionDeg:153.5578007321686,perihelionJd:2.4193378856140426e6},peakMagnitude:2,peakOn:"1911-10-25",absoluteMagnitude:5.59,activityExponent:4},{id:"skjellerup-maristany-1927",designation:"C/1927 X1",name:{en:"Comet Skjellerup-Maristany",fr:"comète Skjellerup-Maristany"},orbit:{eccentricity:.999839726885059,perihelionAu:.1761569619628186,inclinationDeg:85.1125991950808,ascendingNodeDeg:78.24360172472711,argumentOfPerihelionDeg:47.15877857390136,perihelionJd:2.4252326808989984e6},peakMagnitude:-6,peakOn:"1927-12-15",absoluteMagnitude:1.19,activityExponent:4,note:"One of the few comets of the century seen in full daylight."},{id:"de-kock-paraskevopoulos-1941",designation:"C/1941 B2",name:{en:"Comet de Kock-Paraskevopoulos",fr:"comète de Kock-Paraskevopoulos"},orbit:{eccentricity:.9991026715181549,perihelionAu:.7900329662827822,inclinationDeg:168.2039226531089,ascendingNodeDeg:43.10609347214336,argumentOfPerihelionDeg:268.6990344196369,perihelionJd:2430022157765061e-9},peakMagnitude:2,peakOn:"1941-02-05",absoluteMagnitude:5.01,activityExponent:4},{id:"southern-1947",designation:"C/1947 X1",name:{en:"the Southern Comet",fr:"comète australe"},orbit:{eccentricity:.9998424430916737,perihelionAu:.1100045955093761,inclinationDeg:138.5113919632757,ascendingNodeDeg:337.3114969669252,argumentOfPerihelionDeg:196.1820121395961,perihelionJd:2.4325220864727003e6},peakMagnitude:-3,peakOn:"1947-12-08",absoluteMagnitude:3.01,activityExponent:4,note:"A bright southern-hemisphere comet of December 1947, the month the American sighting wave of that year was still being argued over."},{id:"eclipse-1948",designation:"C/1948 V1",name:{en:"the Eclipse Comet",fr:"comète de l'éclipse"},orbit:{eccentricity:.9999130678247334,perihelionAu:.1354437057263306,inclinationDeg:23.11668597152911,ascendingNodeDeg:211.0454985994762,argumentOfPerihelionDeg:107.2474157073104,perihelionJd:2.4328519265329437e6},peakMagnitude:-2,peakOn:"1948-11-01",absoluteMagnitude:4.79,activityExponent:4,note:"Found during the total solar eclipse of 1 November 1948, which is how a comet that bright had gone unnoticed: it had been hidden in the Sun's glare."},{id:"arend-roland-1957",designation:"C/1956 R1",name:{en:"Comet Arend-Roland",fr:"comète Arend-Roland"},orbit:{eccentricity:1.0002570255357,perihelionAu:.3160532361485914,inclinationDeg:119.9440863251822,ascendingNodeDeg:215.8548157717755,argumentOfPerihelionDeg:308.775920364167,perihelionJd:2.4359365327396123e6},peakMagnitude:.5,peakOn:"1957-04-25",absoluteMagnitude:3.96,activityExponent:4,note:"Showed a spike pointing back TOWARD the Sun in late April 1957 — a real anti-tail, and much reported at the time."},{id:"mrkos-1957",designation:"C/1957 P1",name:{en:"Comet Mrkos",fr:"comète Mrkos"},orbit:{eccentricity:.9993521583504134,perihelionAu:.3549238508212375,inclinationDeg:93.9433042053929,ascendingNodeDeg:68.32441518619923,argumentOfPerihelionDeg:40.31823675802871,perihelionJd:243605193752228e-8},peakMagnitude:1,peakOn:"1957-08-05",absoluteMagnitude:5.07,activityExponent:4,note:"The second bright naked-eye comet of 1957, four months after Arend-Roland."},{id:"seki-lines-1962",designation:"C/1962 C1",name:{en:"Comet Seki-Lines",fr:"comète Seki-Lines"},orbit:{eccentricity:1.000003791331562,perihelionAu:.03139689112215131,inclinationDeg:65.01487186102287,ascendingNodeDeg:304.6776602796538,argumentOfPerihelionDeg:11.47295326312573,perihelionJd:2437756163010178e-9},peakMagnitude:-2.5,peakOn:"1962-04-01",absoluteMagnitude:9.3,activityExponent:4},{id:"ikeya-seki-1965",designation:"C/1965 S1",name:{en:"Comet Ikeya-Seki",fr:"comète Ikeya-Seki"},orbit:{eccentricity:.9999141178248997,perihelionAu:.007785966366889336,inclinationDeg:141.8642315267051,ascendingNodeDeg:346.9951764632611,argumentOfPerihelionDeg:69.04909813996062,perihelionJd:2.4390546837018197e6},peakMagnitude:-10,peakOn:"1965-10-21",alsoRecordedMagnitude:2,alsoRecordedOn:"1965-10-30",absoluteMagnitude:5.26,activityExponent:4.002,tailLengthDeg:25,tailLengthAu:.5048,note:"A sungrazer that passed 450 000 km above the Sun's surface and was seen beside it in broad daylight — the brightest comet of the twentieth century. It then stood in the dawn sky for a fortnight with a tail some 25 degrees long, which is the second magnitude recorded here."},{id:"bennett-1970",designation:"C/1969 Y1",name:{en:"Comet Bennett",fr:"comète Bennett"},orbit:{eccentricity:.9962979048768408,perihelionAu:.5376209981502136,inclinationDeg:90.03975717147327,ascendingNodeDeg:224.6576652531314,argumentOfPerihelionDeg:354.1494209173161,perihelionJd:2.4406655455270996e6},peakMagnitude:0,peakOn:"1970-03-26",absoluteMagnitude:3.36,activityExponent:4},{id:"white-ortiz-bolelli-1970",designation:"C/1970 K1",name:{en:"Comet White-Ortiz-Bolelli",fr:"comète White-Ortiz-Bolelli"},orbit:{eccentricity:.9999488875801225,perihelionAu:.00884411465256722,inclinationDeg:138.9520738221631,ascendingNodeDeg:336.8194095816687,argumentOfPerihelionDeg:61.10224765396615,perihelionJd:2.4407209807728203e6},peakMagnitude:1,peakOn:"1970-05-22",absoluteMagnitude:4.35,activityExponent:4},{id:"kohoutek-1973",designation:"C/1973 E1",name:{en:"Comet Kohoutek",fr:"comète Kohoutek"},orbit:{eccentricity:1.000007152175185,perihelionAu:.1424250377812859,inclinationDeg:14.30414984159355,ascendingNodeDeg:258.4893339663974,argumentOfPerihelionDeg:37.79772760699667,perihelionJd:2442044930687027e-9},peakMagnitude:0,peakOn:"1974-01-05",absoluteMagnitude:4.89,activityExponent:4,note:"Announced in advance as the comet of the century and remembered for disappointing: it was an ordinary naked-eye object, not the spectacle the press had promised."},{id:"west-1976",designation:"C/1975 V1",name:{en:"Comet West",fr:"comète West"},orbit:{eccentricity:1.000017859625611,perihelionAu:.1966006188461085,inclinationDeg:43.07319920579427,ascendingNodeDeg:118.9189245655447,argumentOfPerihelionDeg:358.4315101259072,perihelionJd:2442833721841768e-9},peakMagnitude:-3,peakOn:"1976-02-25",absoluteMagnitude:4.41,activityExponent:4,tailLengthDeg:30,tailLengthAu:.4325,note:"Broke into four pieces at perihelion. Barely reported at the time — the press had been burned by Kohoutek two years earlier."},{id:"iras-araki-alcock-1983",designation:"C/1983 H1",name:{en:"Comet IRAS-Araki-Alcock",fr:"comète IRAS-Araki-Alcock"},orbit:{eccentricity:.9898409731606003,perihelionAu:.9913412593828502,inclinationDeg:73.25000846947029,ascendingNodeDeg:49.10235754476374,argumentOfPerihelionDeg:192.8506176754439,perihelionJd:2.4454757545235856e6},peakMagnitude:1.7,peakOn:"1983-05-11",absoluteMagnitude:9.04,activityExponent:4,note:"Passed 0.031 au from Earth on 11 May 1983, one of the closest cometary approaches on record: it crossed a quarter of the sky in a night, which no other comet in this list did."},{id:"halley-1986",designation:"1P/Halley",name:{en:"Halley's Comet",fr:"comète de Halley"},orbit:{eccentricity:.9672792271749998,perihelionAu:.5871034488173393,inclinationDeg:162.2422242700916,ascendingNodeDeg:58.85993640671803,argumentOfPerihelionDeg:111.8655480539208,perihelionJd:2.4464709589610207e6},peakMagnitude:2.1,peakOn:"1986-03-10",absoluteMagnitude:2.71,activityExponent:4,note:"The worst-placed return in two thousand years — famous, expected, and for most observers a faint smudge."},{id:"hyakutake-1996",designation:"C/1996 B2",name:{en:"Comet Hyakutake",fr:"comète Hyakutake"},orbit:{eccentricity:.9997295133739305,perihelionAu:.2302272039470452,inclinationDeg:124.923592343765,ascendingNodeDeg:188.0454295899424,argumentOfPerihelionDeg:130.1724036582639,perihelionJd:2.4502048946148166e6},peakMagnitude:0,peakOn:"1996-03-25",absoluteMagnitude:4.75,activityExponent:4,tailLengthDeg:80,tailLengthAu:1,note:"Passed 0.10 au from Earth in March 1996, five weeks BEFORE perihelion, with a tail measured at some 80 degrees — the longest of the modern era."},{id:"hale-bopp-1997",designation:"C/1995 O1",name:{en:"Comet Hale-Bopp",fr:"comète Hale-Bopp"},orbit:{eccentricity:.9951314746156615,perihelionAu:.9141695067003724,inclinationDeg:89.43017155012492,ascendingNodeDeg:282.470602866853,argumentOfPerihelionDeg:130.5872524854533,perihelionJd:2450539633099368e-9},peakMagnitude:-.8,peakOn:"1997-04-01",absoluteMagnitude:-1.06,activityExponent:4,tailLengthDeg:20,tailLengthAu:.9938,note:"Visible to the naked eye for about eighteen months, longer than any comet on record."},{id:"mcnaught-2007",designation:"C/2006 P1",name:{en:"Comet McNaught",fr:"comète McNaught"},orbit:{eccentricity:1.00001811603225,perihelionAu:.1707325614080681,inclinationDeg:77.83726446452654,ascendingNodeDeg:267.4149080498975,argumentOfPerihelionDeg:155.9756130642756,perihelionJd:2454113298753579e-9},peakMagnitude:-5.5,peakOn:"2007-01-13",absoluteMagnitude:2.53,activityExponent:4,tailLengthDeg:35,tailLengthAu:.5009,note:"The brightest comet since Ikeya-Seki, seen in daylight beside the Sun in January 2007."},{id:"lovejoy-2011",designation:"C/2011 W3",name:{en:"Comet Lovejoy",fr:"comète Lovejoy"},orbit:{eccentricity:.999915056276912,perihelionAu:.005553783989325053,inclinationDeg:134.3558712062691,ascendingNodeDeg:326.3693517957772,argumentOfPerihelionDeg:53.50991655176601,perihelionJd:2455911511809431e-9},peakMagnitude:-3,peakOn:"2011-12-16",alsoRecordedMagnitude:1.5,alsoRecordedOn:"2011-12-22",absoluteMagnitude:3.51,activityExponent:1.194,note:"A sungrazer that was expected to be destroyed at perihelion and came out the other side, to stand in the southern dawn sky for the rest of December — which is the second magnitude recorded here."},{id:"panstarrs-2013",designation:"C/2011 L4",name:{en:"Comet PANSTARRS",fr:"comète PANSTARRS"},orbit:{eccentricity:1.000032542889696,perihelionAu:.301544229714915,inclinationDeg:84.2081978367921,ascendingNodeDeg:65.66588626213694,argumentOfPerihelionDeg:333.6516444379993,perihelionJd:2456361669960698e-9},peakMagnitude:1,peakOn:"2013-03-10",absoluteMagnitude:5.98,activityExponent:4},{id:"neowise-2020",designation:"C/2020 F3",name:{en:"Comet NEOWISE",fr:"comète NEOWISE"},orbit:{eccentricity:.9991782081129224,perihelionAu:.2946512466331692,inclinationDeg:128.9375043020912,ascendingNodeDeg:61.01042991771634,argumentOfPerihelionDeg:37.2786526292898,perihelionJd:2.4590341788972816e6},peakMagnitude:.9,peakOn:"2020-07-08",absoluteMagnitude:5.79,activityExponent:4,tailLengthDeg:10,tailLengthAu:.1808,note:"The first comet since Hale-Bopp that ordinary observers in the northern hemisphere saw without being told where to look."},{id:"tsuchinshan-atlas-2024",designation:"C/2023 A3",name:{en:"Comet Tsuchinshan-ATLAS",fr:"comète Tsuchinshan-ATLAS"},orbit:{eccentricity:1.000020192843226,perihelionAu:.3914228969475176,inclinationDeg:139.1105462619479,ascendingNodeDeg:21.55945689078845,argumentOfPerihelionDeg:308.4913086299446,perihelionJd:2460581242087108e-9},peakMagnitude:0,peakOn:"2024-10-14",absoluteMagnitude:3.97,activityExponent:4,tailLengthDeg:20,tailLengthAu:.1902,note:"Briefly reported far brighter around 9 October 2024, when it stood almost between the observer and the Sun and forward-scattered the light through its own dust — a geometry this catalog's brightness model does not attempt, so what is stored is the ordinary evening-sky peak a few days later."}];class sS{static WINDOW_DAYS=200;static TWILIGHT_ELONGATION_DEG=15;static LIGHT_SPEED_AU_PER_DAY=173.144632674;static orbits=new Map;static aroundDate(t){const e=this.julianDayOf(t);return nf.filter(n=>Math.abs(e-n.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(t,e){return this.aroundDate(t).map(n=>this.appearanceOf(n,t,e)).sort((n,s)=>n.magnitude-s.magnitude)[0]}static appearanceOf(t,e,n){const s=De(e),r=this.earthPositionAt(s),a=this.apparentPositionOf(t,2451545+s.tt,r),o=this.subtract(a,r),c=this.length(a),l=this.length(o),h=this.tailEndAt(t,a,r,c,s,e,n),u=this.horizontalOf(o,s,e,n);return{apparition:t,position:u,...h,heliocentricDistanceAu:c,earthDistanceAu:l,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},r)),magnitude:this.magnitudeAt(t,c,l)}}static magnitudeAt(t,e,n){const s=t.absoluteMagnitude+5*Math.log10(n)+2.5*t.activityExponent*Math.log10(e);return Math.max(s,t.peakMagnitude)}static tailEndAt(t,e,n,s,r,a,o){if(t.tailLengthAu===void 0)return{};const c=1+t.tailLengthAu/s,l=this.subtract({x:e.x*c,y:e.y*c,z:e.z*c},n),h=this.subtract(e,n);return{tailEnd:this.horizontalOf(l,r,a,o),tailLengthDeg:this.angleBetween(h,l)}}static apparentPositionOf(t,e,n){const s=this.orbitOf(t);let r=s.positionAt(e);for(let a=0;a<2;a++){const o=this.length(this.subtract(r,n))/this.LIGHT_SPEED_AU_PER_DAY;r=s.positionAt(e-o)}return r}static horizontalOf(t,e,n,s){const r=wa(Bx(),new de(t.x,t.y,t.z,e)),a=wa(kx(e),r),o=gx(e,new Ql(s.lat,s.lng,s.elevationM)),c=new de(a.x-o.x,a.y-o.y,a.z-o.z,e),l=Fd(c);return Qa(l.ra,l.dec,n,s)}static earthPositionAt(t){return wa(zx(),yi(yt.Earth,t))}static julianDayOf(t){return 2451545+De(t).tt}static orbitOf(t){const e=this.orbits.get(t.id);if(e)return e;const n=new Qn(t.orbit);return this.orbits.set(t.id,n),n}static subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}static length(t){return Math.hypot(t.x,t.y,t.z)}static angleBetween(t,e){const n=(t.x*e.x+t.y*e.y+t.z*e.z)/(this.length(t)*this.length(e)||1);return Math.acos(Math.min(1,Math.max(-1,n)))*180/Math.PI}}const rS=[{id:"quadrantids",code:"QUA",name:{en:"Quadrantids",fr:"Quadrantides"},radiantRaHours:15.33,radiantDecDeg:49.7,start:{month:12,day:28},peak:{month:1,day:3},end:{month:1,day:12},peakZhr:110,velocityKmS:41,populationIndex:2.1},{id:"lyrids",code:"LYR",name:{en:"April Lyrids",fr:"Lyrides d'avril"},radiantRaHours:18.13,radiantDecDeg:33.3,start:{month:4,day:16},peak:{month:4,day:22},end:{month:4,day:25},peakZhr:18,velocityKmS:49,populationIndex:2.1},{id:"eta-aquariids",code:"ETA",name:{en:"eta Aquariids",fr:"Êta Aquarides"},radiantRaHours:22.53,radiantDecDeg:-1,start:{month:4,day:19},peak:{month:5,day:6},end:{month:5,day:28},peakZhr:50,velocityKmS:66,populationIndex:2.4},{id:"alpha-capricornids",code:"CAP",name:{en:"alpha Capricornids",fr:"Alpha Capricornides"},radiantRaHours:20.47,radiantDecDeg:-9.2,start:{month:7,day:3},peak:{month:7,day:30},end:{month:8,day:15},peakZhr:5,velocityKmS:23,populationIndex:2.5},{id:"southern-delta-aquariids",code:"SDA",name:{en:"Southern delta Aquariids",fr:"Delta Aquarides du Sud"},radiantRaHours:22.67,radiantDecDeg:-16.4,start:{month:7,day:12},peak:{month:7,day:30},end:{month:8,day:23},peakZhr:25,velocityKmS:41,populationIndex:3.2},{id:"perseids",code:"PER",name:{en:"Perseids",fr:"Perséides"},radiantRaHours:3.22,radiantDecDeg:58,start:{month:7,day:17},peak:{month:8,day:12},end:{month:8,day:24},peakZhr:100,velocityKmS:59,populationIndex:2.2},{id:"southern-taurids",code:"STA",name:{en:"Southern Taurids",fr:"Taurides du Sud"},radiantRaHours:3.47,radiantDecDeg:13,start:{month:9,day:10},peak:{month:10,day:10},end:{month:11,day:20},peakZhr:5,velocityKmS:27,populationIndex:2.3},{id:"draconids",code:"DRA",name:{en:"October Draconids",fr:"Draconides d'octobre"},radiantRaHours:17.47,radiantDecDeg:54,start:{month:10,day:6},peak:{month:10,day:8},end:{month:10,day:10},peakZhr:10,velocityKmS:20,populationIndex:2.6},{id:"orionids",code:"ORI",name:{en:"Orionids",fr:"Orionides"},radiantRaHours:6.35,radiantDecDeg:15.6,start:{month:10,day:2},peak:{month:10,day:21},end:{month:11,day:7},peakZhr:20,velocityKmS:66,populationIndex:2.5},{id:"northern-taurids",code:"NTA",name:{en:"Northern Taurids",fr:"Taurides du Nord"},radiantRaHours:3.87,radiantDecDeg:22,start:{month:10,day:20},peak:{month:11,day:12},end:{month:12,day:10},peakZhr:5,velocityKmS:29,populationIndex:2.3},{id:"leonids",code:"LEO",name:{en:"Leonids",fr:"Léonides"},radiantRaHours:10.13,radiantDecDeg:21.6,start:{month:11,day:6},peak:{month:11,day:17},end:{month:11,day:30},peakZhr:15,velocityKmS:71,populationIndex:2.5},{id:"geminids",code:"GEM",name:{en:"Geminids",fr:"Géminides"},radiantRaHours:7.47,radiantDecDeg:32.3,start:{month:12,day:4},peak:{month:12,day:14},end:{month:12,day:17},peakZhr:150,velocityKmS:35,populationIndex:2.6},{id:"ursids",code:"URS",name:{en:"Ursids",fr:"Ursides"},radiantRaHours:14.47,radiantDecDeg:75.3,start:{month:12,day:17},peak:{month:12,day:22},end:{month:12,day:26},peakZhr:10,velocityKmS:33,populationIndex:3}],Ga=6.5;class ic{static activeAt(t){return rS.flatMap(e=>{const n=this.nearness(e,t);return n<=0?[]:[{shower:e,zhr:e.peakZhr*n,nearness:n}]})}static nearness(t,e){const n=this.dayOfYear(e),s=this.dayOfYear(this.asDate(t.start)),r=this.dayOfYear(this.asDate(t.peak)),a=this.dayOfYear(this.asDate(t.end)),o=this.wrappedDelta(n,r),c=this.wrappedDelta(r,s),l=this.wrappedDelta(a,r);return o<0?o<-c?0:1+o/c:o>0?o>l?0:1-o/l:1}static observedRatePerHour(t,e,n,s=Ga){if(e<=0)return 0;const r=Ga-s;return t*Math.sin(e*Math.PI/180)/Math.pow(n,r)}static radiantPosition(t,e,n){return Qa(t.radiantRaHours,t.radiantDecDeg,e,n)}static dayOfYear(t){const e=Date.UTC(t.getUTCFullYear(),0,1);return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-e)/864e5)+1}static asDate(t){return new Date(Date.UTC(2001,t.month-1,t.day))}static wrappedDelta(t,e){const n=t-e;return n>182?n-365:n<-182?n+365:n}}class xe{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(t,e){const n=De(t),s=new $l(0,px(t).elon-90,1),r=wa(Gx(n),Ud(s,n)),a=Fd(r);return Qa(a.ra,a.dec,t,e)}static observedRatePerHour(t,e=Ga){const n=xe.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(t*Math.PI/180)),s=Ga-e;return(xe.QUIET_RATE_PER_HOUR+n)/Math.pow(xe.POPULATION_INDEX,s)}static schedule(t){const e=new Wd(t.seed^1542469173);return Wi.schedule(t).map(n=>{const s=xe.toCartesian({altitudeDeg:Math.asin(e.next())*180/Math.PI,azimuthDeg:e.between(0,360)}),r=n.fromRadiantDeg*Math.PI/180,a=xe.turnAround(s,e.between(0,360)),o={x:s.x*Math.cos(r)+a.x*Math.sin(r),y:s.y*Math.cos(r)+a.y*Math.sin(r),z:s.z*Math.cos(r)+a.z*Math.sin(r)};return{...n,radiant:xe.toHorizontal(o),bearingDeg:xe.bearingFrom(o,s)}})}static turnAround(t,e){const[n,s]=xe.basisAround(t),r=e*Math.PI/180;return{x:n.x*Math.cos(r)+s.x*Math.sin(r),y:n.y*Math.cos(r)+s.y*Math.sin(r),z:n.z*Math.cos(r)+s.z*Math.sin(r)}}static bearingFrom(t,e){const[n,s]=xe.basisAround(t),r=t.x*e.x+t.y*e.y+t.z*e.z,a=xe.normalise({x:e.x-t.x*r,y:e.y-t.y*r,z:e.z-t.z*r});return(Math.atan2(a.x*s.x+a.y*s.y+a.z*s.z,a.x*n.x+a.y*n.y+a.z*n.z)*180/Math.PI%360+360)%360}static basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=xe.normalise(xe.cross(t,e));return[n,xe.normalise(xe.cross(t,n))]}static toHorizontal(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{altitudeDeg:Math.asin(Math.min(1,Math.max(-1,t.y/e)))*180/Math.PI,azimuthDeg:(Math.atan2(t.x,-t.z)*180/Math.PI%360+360)%360}}static appearanceOf(t){const e=xe.toCartesian(t.radiant??{altitudeDeg:90,azimuthDeg:0}),n=xe.turnAround(e,t.bearingDeg),s=t.fromRadiantDeg*Math.PI/180;return xe.toHorizontal({x:e.x*Math.cos(s)+n.x*Math.sin(s),y:e.y*Math.cos(s)+n.y*Math.sin(s),z:e.z*Math.cos(s)+n.z*Math.sin(s)})}static toCartesian(t){const e=t.altitudeDeg*Math.PI/180,n=t.azimuthDeg*Math.PI/180,s=Math.cos(e);return{x:s*Math.sin(n),y:Math.sin(e),z:-s*Math.cos(n)}}static cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}static normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}static TYPICAL_VELOCITY_KM_S=40}class aS{lowerM;upperM;add(t,e){if(!(t<=0)){if(e.behindM!==void 0){const n=Je.sizeMAt(e.behindM,t);this.lowerM=this.lowerM===void 0?n:Math.max(this.lowerM,n)}if(e.inFrontM!==void 0){const n=Je.sizeMAt(e.inFrontM,t);this.upperM=this.upperM===void 0?n:Math.min(this.upperM,n)}}}get sizeRange(){return{minM:this.lowerM,maxM:this.upperM}}get empty(){return this.lowerM===void 0&&this.upperM===void 0}get contradictory(){return this.lowerM!==void 0&&this.upperM!==void 0&&this.lowerM>this.upperM}distanceRangeAt(t){return t<=0?{}:{minM:this.lowerM===void 0?void 0:Je.distanceMAt(this.lowerM,t),maxM:this.upperM===void 0?void 0:Je.distanceMAt(this.upperM,t)}}clear(){this.lowerM=void 0,this.upperM=void 0}}P0();const oS={sun:{en:"Sun",fr:"Soleil"},moon:{en:"Moon",fr:"Lune"},Venus:{en:"Venus",fr:"Vénus"},Mars:{en:"Mars",fr:"Mars"},Jupiter:{en:"Jupiter",fr:"Jupiter"},Saturn:{en:"Saturn",fr:"Saturne"}},cS=["en","fr"],b0="comet:",lS={building:{en:"Building",fr:"Bâtiment"},tree:{en:"Tree",fr:"Arbre"},streetlight:{en:"Streetlight",fr:"Lampadaire"},vehicle:{en:"Vehicle",fr:"Véhicule"},witness:{en:"Witness",fr:"Témoin"},aircraft:{en:"Aircraft",fr:"Aéronef"}},hS=new URL(""+new URL("stars-mag7.5-DDr9QasD.bin",import.meta.url).href,import.meta.url).href,uS={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},sc={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class dS extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","show-compass","lens-flare-intensity","lens-flare-brightness"]}shadow;stageElement;frameElement;sceneCanvas;ufoElement;sceneRenderer;hoverTooltip;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;meteorScheduleFor;lastTimeMs=0;starCatalog;weatherAudio=new iS;thunderTimeoutId;handleFullscreenChange=()=>this.resizeToStage();handlePointerMove=t=>{this.sceneRenderer.setCompassHovered(!0);const e=this.ufoElement.canvasElement,n=e.getBoundingClientRect();if(n.width===0||n.height===0)return;const s=(t.clientX-n.left)/n.width*e.width,r=(t.clientY-n.top)/n.height*e.height;if(this.ufoElement.hasVisibleShapeAt(s,r)){this.hoverTooltip.hidden=!0;return}const a=(t.clientX-n.left)/n.width*2-1,o=-((t.clientY-n.top)/n.height*2-1),c=wl(navigator.languages,cS),l=this.sceneRenderer.pickBodyAt(a,o);if(l){this.showHoverTooltip(t,this.bodyName(l,c));return}const h=this.sceneRenderer.pickDecorAt(a,o),u=h?this.ufoElement.sighting.decor.find(d=>d.id===h):void 0;if(u){this.showHoverTooltip(t,u.title||lS[u.kind][c]);return}this.hoverTooltip.hidden=!0};bodyName(t,e){const n=t.startsWith(b0)?t.slice(b0.length):void 0;return(n?nf.find(r=>r.id===n):void 0)?.name[e]??oS[t]?.[e]??t}showHoverTooltip(t,e){this.hoverTooltip.textContent=e,this.hoverTooltip.hidden=!1;const n=this.stageElement.getBoundingClientRect();this.hoverTooltip.style.left=`${t.clientX-n.left+12}px`,this.hoverTooltip.style.top=`${t.clientY-n.top+12}px`}handlePointerLeave=()=>{this.hoverTooltip.hidden=!0,this.sceneRenderer.setCompassHovered(!1)};handleLightningFlash=()=>{clearTimeout(this.thunderTimeoutId);const t=(.5+Math.random()*3.5)*1e3;this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),t)};handleFirstInteraction=()=>{this.weatherAudio.resume(),this.setWeather(dh(this.ufoElement.sighting,this.lastTimeMs))};handleTimeUpdate=t=>{this.lastTimeMs=t.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.updateUfoOcclusion(this.lastTimeMs)};syncAnimationsToPlayback(){const t=this.ufoElement.playbackState==="playing";this.sceneRenderer.setAnimationsRunning(t),this.weatherAudio.setPaused(!t),t||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${df}</style>${uf}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.frameElement=this.shadow.getElementById("frame"),this.sceneCanvas=this.shadow.getElementById("scene-canvas"),this.sceneRenderer=new zM(this.sceneCanvas,void 0,this.handleLightningFlash),this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(oc),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.style.setProperty("--ufo-canvas-background","transparent"),this.ufoElement.style.setProperty("--ufo-canvas-border","none"),this.ufoElement.fullscreenTarget=this.stageElement,this.shadow.getElementById("ufo-slot").replaceWith(this.ufoElement),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.canvasElement.addEventListener("pointermove",this.handlePointerMove),this.ufoElement.canvasElement.addEventListener("pointerleave",this.handlePointerLeave),this.ufoElement.canvasElement.addEventListener("pointerdown",this.handleFirstInteraction,{once:!0})}connectedCallback(){this.resizeToStage(),this.updateAstronomy(this.lastTimeMs),this.loadStars(),this.resizeObserver=new ResizeObserver(()=>this.resizeToStage()),this.resizeObserver.observe(this.frameElement),document.addEventListener("fullscreenchange",this.handleFullscreenChange);const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose()}attributeChangedCallback(t,e,n){if(t==="src"&&n&&n!==e&&this.isConnected&&this.loadFromSrc(n),t==="star-catalog-src"&&n!==e&&this.isConnected&&this.loadStars(),t==="show-compass"&&n!==e&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),t==="lens-flare-intensity"&&n!==e){const s=n===null?NaN:parseFloat(n);this.sceneRenderer.setLensFlareArtifactIntensity(Number.isFinite(s)?s:0)}if(t==="lens-flare-brightness"&&n!==e){const s=n===null?NaN:parseFloat(n);this.sceneRenderer.setDazzleIntensity(Number.isFinite(s)?s:1)}}setCompassForced(t){this.sceneRenderer.setCompassForced(t)}setIndoorLook(t,e){this.sceneRenderer.setIndoorLook(t,e)}setWeather(t){this.sceneRenderer.setWeather(t),this.weatherAudio.setAmbient(t.precipitationType,t.precipitationIntensity,t.windSpeed)}pickDecorAt(t,e){return this.sceneRenderer.pickDecorAt(t,e)}resumeWeatherAudio(){this.weatherAudio.resume()}async loadFromSrc(t){const e=await fetch(t);this.sightingData=await e.json()}get sightingData(){return this.ufoElement.sightingData}set sightingData(t){this.ufoElement.sightingData=t,this.lastTimeMs=0,this.updateAstronomy(0)}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}setTerrainProviders(t){this.sceneRenderer.setTerrainProviders(t)}resizeToStage(){const t=this.frameElement.getBoundingClientRect(),e=Math.max(1,Math.round(t.width)),n=Math.max(1,Math.round(t.height));this.sceneCanvas.width=e,this.sceneCanvas.height=n,this.sceneRenderer.resize(e,n)}async loadStars(){const t=this.getAttribute("star-catalog-src")??hS;this.starCatalog=await JM(t),this.updateAstronomy(this.lastTimeMs)}updateAstronomy(t){const e=this.ufoElement.sighting;this.setWeather(dh(e,t)),this.sceneRenderer.setInstrument(e.instrument),this.updateMeteorShower(e,t),this.sceneRenderer.setDecor(e.decor);const n=hr(e,t);this.sceneRenderer.setObserverPose(n??sc),this.sceneRenderer.updateDecorAnchoring(hr(e,0),n,t),this.sceneRenderer.updateDecorLitState(t),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng);const s=n?.lat??sc.lat,r=n?.lng??sc.lng,a=Bu(e.event.time??{},r,e.event.utcOffsetHours);if(!a){this.sceneRenderer.setAstronomy(uS);return}const o=new Date(a.getTime()+t),c={lat:s,lng:r,elevationM:n?.elevationM??0},l={...Xo("Sun",o,c),magnitude:qo("Sun",o)},h={...Xo("Moon",o,c),phase:Vx(o),magnitude:qo("Moon",o)},u=Hx.map(d=>({body:d,position:Xo(d,o,c),magnitude:qo(d,o)}));this.sceneRenderer.setAstronomy({sun:l,moon:h,planets:u,comet:this.cometAt(o,c),stars:this.starCatalog?{catalog:this.starCatalog,date:o,observer:c}:void 0})}cometAt(t,e){const n=sS.brightestAt(t,e);if(n)return{id:n.apparition.id,position:n.position,tailEnd:n.tailEnd,magnitude:n.magnitude}}updateUfoOcclusion(t){const e=this.ufoElement.sighting;e!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.sizeEstimatesFor=e);const n=e.timeline,s=this.ufoElement.canvasElement,r=new Set;for(const a of n.sourceIds){const o=n.getInterpolatedShapeAt(t,a);if(!o)continue;const c=(o.bounds.x+o.bounds.width/2)/s.width*2-1,l=-((o.bounds.y+o.bounds.height/2)/s.height*2-1);this.sceneRenderer.isScreenPointOccluded(c,l,a,o.behindCloud)&&r.add(a);const h=o.angular?.widthDeg??this.projectionAt(t).pxToDeg(o.bounds.width);this.sizeEstimateOf(a).add(h,this.sceneRenderer.decorDistancesAt(c,l,a))}this.ufoElement.setOccludedSourceIds(r)}sizeRangeOf(t){return this.sizeEstimateOf(t).sizeRange}distanceRangeAt(t,e){const n=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(e,t);if(!n)return{};const s=n.angular?.widthDeg??this.projectionAt(e).pxToDeg(n.bounds.width);return this.sizeEstimateOf(t).distanceRangeAt(s)}sizeContradictory(t){return this.sizeEstimateOf(t).contradictory}updateMeteorShower(t,e){this.ensureMeteorSchedule(t),this.sceneRenderer.updateMeteors(e)}ensureMeteorSchedule(t){const e=this.meteorInputsOf(t);e!==this.meteorScheduleFor&&(this.meteorScheduleFor=e,this.scheduleMeteors(t))}meteorInputsOf(t){const e=t.event.place?.[0],n=t.event.time;return JSON.stringify([e?.lat,e?.lng,n?.year,n?.month,n?.day,n?.hour,n?.minute,t.event.utcOffsetHours,t.event.durationSeconds,t.timeline.duration])}scheduleMeteors(t){const e=t.event.place?.[0],n=t.event.time,s=e?.lat!==void 0&&e.lng!==void 0&&n?.year!==void 0?Bu(n,e.lng,t.event.utcOffsetHours):void 0;if(!s||e?.lat===void 0||e.lng===void 0){this.sceneRenderer.setMeteorShower([],0,0);return}const r={lat:e.lat,lng:e.lng,elevationM:0},a=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,o=Math.round(s.getTime()/1e3)+Math.round(e.lat*1e3),c=xe.schedule({ratePerHour:xe.observedRatePerHour(xe.apexPosition(s,r).altitudeDeg),durationMs:a,velocityKmS:xe.TYPICAL_VELOCITY_KM_S,seed:o}),l=ic.activeAt(s).map(u=>{const d=ic.radiantPosition(u.shower,s,r);return{entry:u,position:d,rate:ic.observedRatePerHour(u.zhr,d.altitudeDeg,u.shower.populationIndex)}}).sort((u,d)=>d.rate-u.rate)[0];if(!l||l.rate<=0){this.sceneRenderer.setMeteorShower(c,0,0);return}const h=Wi.schedule({ratePerHour:l.rate,durationMs:a,velocityKmS:l.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...c],l.position.altitudeDeg,l.position.azimuthDeg)}meteorByRank(t){this.ensureMeteorSchedule(this.ufoElement.sighting);const e=[...this.sceneRenderer.meteorSchedule].filter(r=>r.t+r.durationMs<=this.ufoElement.seekableDuration).sort((r,a)=>a.brightness-r.brightness);if(e.length===0)return;const n=e[t%e.length],s=this.sceneRenderer.meteorMidpoint(n);if(s)return{t:Math.round(n.t+n.durationMs*.45),...s}}projectionAt(t){const e=this.ufoElement.sighting,n=hr(e,t)?.fovDeg??Tl.DEFAULT_FOV_DEG;return Rs.of(e.instrument,Je.CANVAS_HEIGHT_PX,n)}sizeEstimateOf(t){let e=this.sizeEstimates.get(t);return e||(e=new aS,this.sizeEstimates.set(t,e)),e}}const A0="rr0-scene";function fS(){P0(),customElements.get(A0)||customElements.define(A0,dS)}fS();
5311
+ `;let Ta;function tS(){if(Ta)return Ta;const i=128,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=e.createRadialGradient(i/2,i/2,0,i/2,i/2,i/2);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.4,"rgba(255,255,255,0.35)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,i,i),Ta=new oi(t),Ta}function eS(i){const e=document.createElement("canvas");e.width=128,e.height=128;const n=e.getContext("2d"),s=128/2-2,r=128/2,a=128/2,o="#2e2b26",c="#f4f1e2";n.fillStyle=o,n.beginPath(),n.arc(r,a,s,0,Math.PI*2),n.fill();const l=lf(i.illuminatedFraction,0,1),h=i.phaseFraction<.5,u=s*Math.abs(1-2*l),d=l<.5;return n.save(),n.beginPath(),n.arc(r,a,s,0,Math.PI*2),n.clip(),n.fillStyle=c,n.beginPath(),h?(n.arc(r,a,s,-Math.PI/2,Math.PI/2,!1),n.ellipse(r,a,u,s,0,Math.PI/2,-Math.PI/2,d)):(n.arc(r,a,s,Math.PI/2,-Math.PI/2,!1),n.ellipse(r,a,u,s,0,-Math.PI/2,Math.PI/2,d)),n.fill(),n.restore(),new oi(e)}function nS(i){const t=document.createElement("canvas");t.width=128,t.height=128;const e=t.getContext("2d");return e.fillStyle="rgba(0, 0, 0, 0.55)",e.beginPath(),e.arc(64,64,60,0,Math.PI*2),e.fill(),e.fillStyle="#ffffff",e.font="bold 52px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(i,64,68),new oi(t)}function lc(i){let t=i;return function(){t|=0,t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const P0=new Map;function iS(i){const t=i.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),e=t,n=e*Float32Array.BYTES_PER_ELEMENT;return{count:t,ra:new Float32Array(i,0*n,e),dec:new Float32Array(i,1*n,e),mag:new Float32Array(i,2*n,e),ci:new Float32Array(i,3*n,e)}}function sS(i){let t=P0.get(i);return t||(t=fetch(i).then(e=>e.arrayBuffer()).then(iS),P0.set(i,t)),t}const rS=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,aS=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,oS=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,cS=20,lS=1;class hS{context;buffers=new Map;ambientSource;ambientGain;ambientKey="none";ambientToken=0;ambientVolume=0;windSource;windGain;windActive=!1;windToken=0;windVolume=0;paused=!0;requested={type:"none",intensity:0,windSpeed:0};resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",t);return}}this.context.state==="suspended"&&this.context.resume()}setAmbient(t,e,n){if(this.requested={type:t,intensity:e,windSpeed:n},!this.context)return;this.paused&&(t="none",e=0,n=0);const s=t==="rain"||t==="hail"?t:"none";if(this.ambientVolume=s==="hail"?Math.min(1,e*1.3+.2):s==="rain"?e:0,s!==this.ambientKey){this.ambientKey=s;const a=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,s!=="none"&&this.startLoop(rS,this.ambientVolume).then(o=>this.applyIfCurrent(o,a,()=>this.ambientToken,c=>{this.ambientSource=c?.source,this.ambientGain=c?.gain,c&&(c.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(n/cS,1);const r=n>lS;if(r!==this.windActive){this.windActive=r;const a=++this.windToken;this.stopSource(this.windSource,this.windGain),this.windSource=void 0,this.windGain=void 0,r&&this.startLoop(aS,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,c=>{this.windSource=c?.source,this.windGain=c?.gain,c&&(c.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(t){if(t===this.paused)return;this.paused=t;const{type:e,intensity:n,windSpeed:s}=this.requested;this.setAmbient(e,n,s)}playThunder(){!this.context||this.paused||this.playOneShot(oS,.9)}dispose(){this.ambientToken++,this.windToken++,this.stopSource(this.ambientSource,this.ambientGain),this.stopSource(this.windSource,this.windGain),this.ambientSource=void 0,this.ambientGain=void 0,this.windSource=void 0,this.windGain=void 0,this.context?.close(),this.context=void 0,this.buffers.clear()}applyIfCurrent(t,e,n,s){if(e!==n()){t?.source.stop();return}s(t)}async startLoop(t,e){const n=this.context;if(n)try{const s=await this.getBuffer(t),r=n.createBufferSource();r.buffer=s,r.loop=!0;const a=n.createGain();return a.gain.value=e,r.connect(a).connect(n.destination),r.start(),{source:r,gain:a}}catch(s){console.warn("Weather ambient sound failed to load, staying silent:",s);return}}async playOneShot(t,e){const n=this.context;if(n)try{const s=await this.getBuffer(t),r=n.createBufferSource();r.buffer=s;const a=n.createGain();a.gain.value=e,r.connect(a).connect(n.destination),r.start()}catch(s){console.warn("Thunder sound failed to load:",s)}}async getBuffer(t){const e=this.context;if(!e)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(t);return n||(n=fetch(t).then(s=>{if(!s.ok)throw new Error(`Audio fetch failed (${s.status}): ${t}`);return s.arrayBuffer()}).then(s=>e.decodeAudioData(s)),this.buffers.set(t,n)),n}stopSource(t,e){try{t?.stop()}catch{}t?.disconnect(),e?.disconnect()}}class ni{constructor(t){this.elements=t;const{eccentricity:e,perihelionAu:n}=t,[s,r]=this.perifocalAxes(),a=Math.sqrt(ni.SUN_GM_AU3_PER_DAY2*(1+e)/n);this.perihelionPosition=this.scale(s,n),this.perihelionVelocity=this.scale(r,a),this.inverseSemiMajorAxis=(1-e)/n}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(t){const e=t-this.elements.perihelionJd,n=this.universalAnomaly(e),s=this.inverseSemiMajorAxis*n*n,r=this.elements.perihelionAu,a=1-n*n/r*ni.stumpffC(s),o=e-n*n*n/Math.sqrt(ni.SUN_GM_AU3_PER_DAY2)*ni.stumpffS(s);return{x:a*this.perihelionPosition.x+o*this.perihelionVelocity.x,y:a*this.perihelionPosition.y+o*this.perihelionVelocity.y,z:a*this.perihelionPosition.z+o*this.perihelionVelocity.z}}heliocentricDistanceAt(t){const e=this.positionAt(t);return Math.hypot(e.x,e.y,e.z)}universalAnomaly(t){if(t===0)return 0;const e=Math.sign(t),n=Math.sqrt(ni.SUN_GM_AU3_PER_DAY2)*Math.abs(t),s=o=>{const c=this.inverseSemiMajorAxis*o*o,l=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*l)*o*o*o*ni.stumpffS(c)+l*o};let r=Math.max(1,n/this.elements.perihelionAu);for(;s(r)<n;)r*=2;let a=0;for(let o=0;o<ni.MAX_ITERATIONS&&r-a>1e-13*Math.max(1,r);o++){const c=(a+r)/2;s(c)<n?a=c:r=c}return e*(a+r)/2}perifocalAxes(){const t=this.elements.ascendingNodeDeg*Math.PI/180,e=this.elements.argumentOfPerihelionDeg*Math.PI/180,n=this.elements.inclinationDeg*Math.PI/180,s=Math.cos(t),r=Math.sin(t),a=Math.cos(e),o=Math.sin(e),c=Math.cos(n),l=Math.sin(n);return[{x:s*a-r*o*c,y:r*a+s*o*c,z:o*l},{x:-s*o-r*a*c,y:-r*o+s*a*c,z:a*l}]}scale(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}static stumpffC(t){if(Math.abs(t)<1e-6)return 1/2-t/24+t*t/720;if(t>0)return(1-Math.cos(Math.sqrt(t)))/t;const e=Math.sqrt(-t);return(Math.cosh(e)-1)/-t}static stumpffS(t){if(Math.abs(t)<1e-6)return 1/6-t/120+t*t/5040;if(t>0){const n=Math.sqrt(t);return(n-Math.sin(n))/(n*n*n)}const e=Math.sqrt(-t);return(Math.sinh(e)-e)/(e*e*e)}}const hf=[{id:"halley-1910",designation:"1P/Halley",name:{en:"Halley's Comet",fr:"comète de Halley"},orbit:{eccentricity:.9672960498922706,perihelionAu:.5872100477652511,inclinationDeg:162.218798367122,ascendingNodeDeg:58.56208298700436,argumentOfPerihelionDeg:111.7366940639061,perihelionJd:2.4187816784171113e6},peakMagnitude:0,peakOn:"1910-05-20",absoluteMagnitude:4.72,activityExponent:4,tailLengthDeg:100,tailLengthAu:.1638,note:"Passed 0.15 au from Earth on 20 May 1910, and the Earth crossed the outer tail the day before — the apparition that produced a genuine public panic."},{id:"brooks-1911",designation:"C/1911 O1",name:{en:"Comet Brooks",fr:"comète Brooks"},orbit:{eccentricity:.9876404970138669,perihelionAu:.4898172916113738,inclinationDeg:33.34043866978714,ascendingNodeDeg:293.7022074981857,argumentOfPerihelionDeg:153.5578007321686,perihelionJd:2.4193378856140426e6},peakMagnitude:2,peakOn:"1911-10-25",absoluteMagnitude:5.59,activityExponent:4},{id:"skjellerup-maristany-1927",designation:"C/1927 X1",name:{en:"Comet Skjellerup-Maristany",fr:"comète Skjellerup-Maristany"},orbit:{eccentricity:.999839726885059,perihelionAu:.1761569619628186,inclinationDeg:85.1125991950808,ascendingNodeDeg:78.24360172472711,argumentOfPerihelionDeg:47.15877857390136,perihelionJd:2.4252326808989984e6},peakMagnitude:-6,peakOn:"1927-12-15",absoluteMagnitude:1.19,activityExponent:4,note:"One of the few comets of the century seen in full daylight."},{id:"de-kock-paraskevopoulos-1941",designation:"C/1941 B2",name:{en:"Comet de Kock-Paraskevopoulos",fr:"comète de Kock-Paraskevopoulos"},orbit:{eccentricity:.9991026715181549,perihelionAu:.7900329662827822,inclinationDeg:168.2039226531089,ascendingNodeDeg:43.10609347214336,argumentOfPerihelionDeg:268.6990344196369,perihelionJd:2430022157765061e-9},peakMagnitude:2,peakOn:"1941-02-05",absoluteMagnitude:5.01,activityExponent:4},{id:"southern-1947",designation:"C/1947 X1",name:{en:"the Southern Comet",fr:"comète australe"},orbit:{eccentricity:.9998424430916737,perihelionAu:.1100045955093761,inclinationDeg:138.5113919632757,ascendingNodeDeg:337.3114969669252,argumentOfPerihelionDeg:196.1820121395961,perihelionJd:2.4325220864727003e6},peakMagnitude:-3,peakOn:"1947-12-08",absoluteMagnitude:3.01,activityExponent:4,note:"A bright southern-hemisphere comet of December 1947, the month the American sighting wave of that year was still being argued over."},{id:"eclipse-1948",designation:"C/1948 V1",name:{en:"the Eclipse Comet",fr:"comète de l'éclipse"},orbit:{eccentricity:.9999130678247334,perihelionAu:.1354437057263306,inclinationDeg:23.11668597152911,ascendingNodeDeg:211.0454985994762,argumentOfPerihelionDeg:107.2474157073104,perihelionJd:2.4328519265329437e6},peakMagnitude:-2,peakOn:"1948-11-01",absoluteMagnitude:4.79,activityExponent:4,note:"Found during the total solar eclipse of 1 November 1948, which is how a comet that bright had gone unnoticed: it had been hidden in the Sun's glare."},{id:"arend-roland-1957",designation:"C/1956 R1",name:{en:"Comet Arend-Roland",fr:"comète Arend-Roland"},orbit:{eccentricity:1.0002570255357,perihelionAu:.3160532361485914,inclinationDeg:119.9440863251822,ascendingNodeDeg:215.8548157717755,argumentOfPerihelionDeg:308.775920364167,perihelionJd:2.4359365327396123e6},peakMagnitude:.5,peakOn:"1957-04-25",absoluteMagnitude:3.96,activityExponent:4,note:"Showed a spike pointing back TOWARD the Sun in late April 1957 — a real anti-tail, and much reported at the time."},{id:"mrkos-1957",designation:"C/1957 P1",name:{en:"Comet Mrkos",fr:"comète Mrkos"},orbit:{eccentricity:.9993521583504134,perihelionAu:.3549238508212375,inclinationDeg:93.9433042053929,ascendingNodeDeg:68.32441518619923,argumentOfPerihelionDeg:40.31823675802871,perihelionJd:243605193752228e-8},peakMagnitude:1,peakOn:"1957-08-05",absoluteMagnitude:5.07,activityExponent:4,note:"The second bright naked-eye comet of 1957, four months after Arend-Roland."},{id:"seki-lines-1962",designation:"C/1962 C1",name:{en:"Comet Seki-Lines",fr:"comète Seki-Lines"},orbit:{eccentricity:1.000003791331562,perihelionAu:.03139689112215131,inclinationDeg:65.01487186102287,ascendingNodeDeg:304.6776602796538,argumentOfPerihelionDeg:11.47295326312573,perihelionJd:2437756163010178e-9},peakMagnitude:-2.5,peakOn:"1962-04-01",absoluteMagnitude:9.3,activityExponent:4},{id:"ikeya-seki-1965",designation:"C/1965 S1",name:{en:"Comet Ikeya-Seki",fr:"comète Ikeya-Seki"},orbit:{eccentricity:.9999141178248997,perihelionAu:.007785966366889336,inclinationDeg:141.8642315267051,ascendingNodeDeg:346.9951764632611,argumentOfPerihelionDeg:69.04909813996062,perihelionJd:2.4390546837018197e6},peakMagnitude:-10,peakOn:"1965-10-21",alsoRecordedMagnitude:2,alsoRecordedOn:"1965-10-30",absoluteMagnitude:5.26,activityExponent:4.002,tailLengthDeg:25,tailLengthAu:.5048,note:"A sungrazer that passed 450 000 km above the Sun's surface and was seen beside it in broad daylight — the brightest comet of the twentieth century. It then stood in the dawn sky for a fortnight with a tail some 25 degrees long, which is the second magnitude recorded here."},{id:"bennett-1970",designation:"C/1969 Y1",name:{en:"Comet Bennett",fr:"comète Bennett"},orbit:{eccentricity:.9962979048768408,perihelionAu:.5376209981502136,inclinationDeg:90.03975717147327,ascendingNodeDeg:224.6576652531314,argumentOfPerihelionDeg:354.1494209173161,perihelionJd:2.4406655455270996e6},peakMagnitude:0,peakOn:"1970-03-26",absoluteMagnitude:3.36,activityExponent:4},{id:"white-ortiz-bolelli-1970",designation:"C/1970 K1",name:{en:"Comet White-Ortiz-Bolelli",fr:"comète White-Ortiz-Bolelli"},orbit:{eccentricity:.9999488875801225,perihelionAu:.00884411465256722,inclinationDeg:138.9520738221631,ascendingNodeDeg:336.8194095816687,argumentOfPerihelionDeg:61.10224765396615,perihelionJd:2.4407209807728203e6},peakMagnitude:1,peakOn:"1970-05-22",absoluteMagnitude:4.35,activityExponent:4},{id:"kohoutek-1973",designation:"C/1973 E1",name:{en:"Comet Kohoutek",fr:"comète Kohoutek"},orbit:{eccentricity:1.000007152175185,perihelionAu:.1424250377812859,inclinationDeg:14.30414984159355,ascendingNodeDeg:258.4893339663974,argumentOfPerihelionDeg:37.79772760699667,perihelionJd:2442044930687027e-9},peakMagnitude:0,peakOn:"1974-01-05",absoluteMagnitude:4.89,activityExponent:4,note:"Announced in advance as the comet of the century and remembered for disappointing: it was an ordinary naked-eye object, not the spectacle the press had promised."},{id:"west-1976",designation:"C/1975 V1",name:{en:"Comet West",fr:"comète West"},orbit:{eccentricity:1.000017859625611,perihelionAu:.1966006188461085,inclinationDeg:43.07319920579427,ascendingNodeDeg:118.9189245655447,argumentOfPerihelionDeg:358.4315101259072,perihelionJd:2442833721841768e-9},peakMagnitude:-3,peakOn:"1976-02-25",absoluteMagnitude:4.41,activityExponent:4,tailLengthDeg:30,tailLengthAu:.4325,note:"Broke into four pieces at perihelion. Barely reported at the time — the press had been burned by Kohoutek two years earlier."},{id:"iras-araki-alcock-1983",designation:"C/1983 H1",name:{en:"Comet IRAS-Araki-Alcock",fr:"comète IRAS-Araki-Alcock"},orbit:{eccentricity:.9898409731606003,perihelionAu:.9913412593828502,inclinationDeg:73.25000846947029,ascendingNodeDeg:49.10235754476374,argumentOfPerihelionDeg:192.8506176754439,perihelionJd:2.4454757545235856e6},peakMagnitude:1.7,peakOn:"1983-05-11",absoluteMagnitude:9.04,activityExponent:4,note:"Passed 0.031 au from Earth on 11 May 1983, one of the closest cometary approaches on record: it crossed a quarter of the sky in a night, which no other comet in this list did."},{id:"halley-1986",designation:"1P/Halley",name:{en:"Halley's Comet",fr:"comète de Halley"},orbit:{eccentricity:.9672792271749998,perihelionAu:.5871034488173393,inclinationDeg:162.2422242700916,ascendingNodeDeg:58.85993640671803,argumentOfPerihelionDeg:111.8655480539208,perihelionJd:2.4464709589610207e6},peakMagnitude:2.1,peakOn:"1986-03-10",absoluteMagnitude:2.71,activityExponent:4,note:"The worst-placed return in two thousand years — famous, expected, and for most observers a faint smudge."},{id:"hyakutake-1996",designation:"C/1996 B2",name:{en:"Comet Hyakutake",fr:"comète Hyakutake"},orbit:{eccentricity:.9997295133739305,perihelionAu:.2302272039470452,inclinationDeg:124.923592343765,ascendingNodeDeg:188.0454295899424,argumentOfPerihelionDeg:130.1724036582639,perihelionJd:2.4502048946148166e6},peakMagnitude:0,peakOn:"1996-03-25",absoluteMagnitude:4.75,activityExponent:4,tailLengthDeg:80,tailLengthAu:1,note:"Passed 0.10 au from Earth in March 1996, five weeks BEFORE perihelion, with a tail measured at some 80 degrees — the longest of the modern era."},{id:"hale-bopp-1997",designation:"C/1995 O1",name:{en:"Comet Hale-Bopp",fr:"comète Hale-Bopp"},orbit:{eccentricity:.9951314746156615,perihelionAu:.9141695067003724,inclinationDeg:89.43017155012492,ascendingNodeDeg:282.470602866853,argumentOfPerihelionDeg:130.5872524854533,perihelionJd:2450539633099368e-9},peakMagnitude:-.8,peakOn:"1997-04-01",absoluteMagnitude:-1.06,activityExponent:4,tailLengthDeg:20,tailLengthAu:.9938,note:"Visible to the naked eye for about eighteen months, longer than any comet on record."},{id:"mcnaught-2007",designation:"C/2006 P1",name:{en:"Comet McNaught",fr:"comète McNaught"},orbit:{eccentricity:1.00001811603225,perihelionAu:.1707325614080681,inclinationDeg:77.83726446452654,ascendingNodeDeg:267.4149080498975,argumentOfPerihelionDeg:155.9756130642756,perihelionJd:2454113298753579e-9},peakMagnitude:-5.5,peakOn:"2007-01-13",absoluteMagnitude:2.53,activityExponent:4,tailLengthDeg:35,tailLengthAu:.5009,note:"The brightest comet since Ikeya-Seki, seen in daylight beside the Sun in January 2007."},{id:"lovejoy-2011",designation:"C/2011 W3",name:{en:"Comet Lovejoy",fr:"comète Lovejoy"},orbit:{eccentricity:.999915056276912,perihelionAu:.005553783989325053,inclinationDeg:134.3558712062691,ascendingNodeDeg:326.3693517957772,argumentOfPerihelionDeg:53.50991655176601,perihelionJd:2455911511809431e-9},peakMagnitude:-3,peakOn:"2011-12-16",alsoRecordedMagnitude:1.5,alsoRecordedOn:"2011-12-22",absoluteMagnitude:3.51,activityExponent:1.194,note:"A sungrazer that was expected to be destroyed at perihelion and came out the other side, to stand in the southern dawn sky for the rest of December — which is the second magnitude recorded here."},{id:"panstarrs-2013",designation:"C/2011 L4",name:{en:"Comet PANSTARRS",fr:"comète PANSTARRS"},orbit:{eccentricity:1.000032542889696,perihelionAu:.301544229714915,inclinationDeg:84.2081978367921,ascendingNodeDeg:65.66588626213694,argumentOfPerihelionDeg:333.6516444379993,perihelionJd:2456361669960698e-9},peakMagnitude:1,peakOn:"2013-03-10",absoluteMagnitude:5.98,activityExponent:4},{id:"neowise-2020",designation:"C/2020 F3",name:{en:"Comet NEOWISE",fr:"comète NEOWISE"},orbit:{eccentricity:.9991782081129224,perihelionAu:.2946512466331692,inclinationDeg:128.9375043020912,ascendingNodeDeg:61.01042991771634,argumentOfPerihelionDeg:37.2786526292898,perihelionJd:2.4590341788972816e6},peakMagnitude:.9,peakOn:"2020-07-08",absoluteMagnitude:5.79,activityExponent:4,tailLengthDeg:10,tailLengthAu:.1808,note:"The first comet since Hale-Bopp that ordinary observers in the northern hemisphere saw without being told where to look."},{id:"tsuchinshan-atlas-2024",designation:"C/2023 A3",name:{en:"Comet Tsuchinshan-ATLAS",fr:"comète Tsuchinshan-ATLAS"},orbit:{eccentricity:1.000020192843226,perihelionAu:.3914228969475176,inclinationDeg:139.1105462619479,ascendingNodeDeg:21.55945689078845,argumentOfPerihelionDeg:308.4913086299446,perihelionJd:2460581242087108e-9},peakMagnitude:0,peakOn:"2024-10-14",absoluteMagnitude:3.97,activityExponent:4,tailLengthDeg:20,tailLengthAu:.1902,note:"Briefly reported far brighter around 9 October 2024, when it stood almost between the observer and the Sun and forward-scattered the light through its own dust — a geometry this catalog's brightness model does not attempt, so what is stored is the ordinary evening-sky peak a few days later."}];class uS{static WINDOW_DAYS=200;static TWILIGHT_ELONGATION_DEG=15;static LIGHT_SPEED_AU_PER_DAY=173.144632674;static orbits=new Map;static aroundDate(t){const e=this.julianDayOf(t);return hf.filter(n=>Math.abs(e-n.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(t,e){return this.aroundDate(t).map(n=>this.appearanceOf(n,t,e)).sort((n,s)=>n.magnitude-s.magnitude)[0]}static appearanceOf(t,e,n){const s=Le(e),r=this.earthPositionAt(s),a=this.apparentPositionOf(t,2451545+s.tt,r),o=this.subtract(a,r),c=this.length(a),l=this.length(o),h=this.tailEndAt(t,a,r,c,s,e,n),u=this.horizontalOf(o,s,e,n);return{apparition:t,position:u,...h,heliocentricDistanceAu:c,earthDistanceAu:l,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},r)),magnitude:this.magnitudeAt(t,c,l)}}static magnitudeAt(t,e,n){const s=t.absoluteMagnitude+5*Math.log10(n)+2.5*t.activityExponent*Math.log10(e);return Math.max(s,t.peakMagnitude)}static tailEndAt(t,e,n,s,r,a,o){if(t.tailLengthAu===void 0)return{};const c=1+t.tailLengthAu/s,l=this.subtract({x:e.x*c,y:e.y*c,z:e.z*c},n),h=this.subtract(e,n);return{tailEnd:this.horizontalOf(l,r,a,o),tailLengthDeg:this.angleBetween(h,l)}}static apparentPositionOf(t,e,n){const s=this.orbitOf(t);let r=s.positionAt(e);for(let a=0;a<2;a++){const o=this.length(this.subtract(r,n))/this.LIGHT_SPEED_AU_PER_DAY;r=s.positionAt(e-o)}return r}static horizontalOf(t,e,n,s){const r=Na(qx(),new ue(t.x,t.y,t.z,e)),a=Na(Yx(e),r),o=Ex(e,new ah(s.lat,s.lng,s.elevationM)),c=new ue(a.x-o.x,a.y-o.y,a.z-o.z,e),l=Vd(c);return ao(l.ra,l.dec,n,s)}static earthPositionAt(t){return Na(Xx(),Ti(yt.Earth,t))}static julianDayOf(t){return 2451545+Le(t).tt}static orbitOf(t){const e=this.orbits.get(t.id);if(e)return e;const n=new ni(t.orbit);return this.orbits.set(t.id,n),n}static subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}static length(t){return Math.hypot(t.x,t.y,t.z)}static angleBetween(t,e){const n=(t.x*e.x+t.y*e.y+t.z*e.z)/(this.length(t)*this.length(e)||1);return Math.acos(Math.min(1,Math.max(-1,n)))*180/Math.PI}}const dS=[{id:"quadrantids",code:"QUA",name:{en:"Quadrantids",fr:"Quadrantides"},radiantRaHours:15.33,radiantDecDeg:49.7,start:{month:12,day:28},peak:{month:1,day:3},end:{month:1,day:12},peakZhr:110,velocityKmS:41,populationIndex:2.1},{id:"lyrids",code:"LYR",name:{en:"April Lyrids",fr:"Lyrides d'avril"},radiantRaHours:18.13,radiantDecDeg:33.3,start:{month:4,day:16},peak:{month:4,day:22},end:{month:4,day:25},peakZhr:18,velocityKmS:49,populationIndex:2.1},{id:"eta-aquariids",code:"ETA",name:{en:"eta Aquariids",fr:"Êta Aquarides"},radiantRaHours:22.53,radiantDecDeg:-1,start:{month:4,day:19},peak:{month:5,day:6},end:{month:5,day:28},peakZhr:50,velocityKmS:66,populationIndex:2.4},{id:"alpha-capricornids",code:"CAP",name:{en:"alpha Capricornids",fr:"Alpha Capricornides"},radiantRaHours:20.47,radiantDecDeg:-9.2,start:{month:7,day:3},peak:{month:7,day:30},end:{month:8,day:15},peakZhr:5,velocityKmS:23,populationIndex:2.5},{id:"southern-delta-aquariids",code:"SDA",name:{en:"Southern delta Aquariids",fr:"Delta Aquarides du Sud"},radiantRaHours:22.67,radiantDecDeg:-16.4,start:{month:7,day:12},peak:{month:7,day:30},end:{month:8,day:23},peakZhr:25,velocityKmS:41,populationIndex:3.2},{id:"perseids",code:"PER",name:{en:"Perseids",fr:"Perséides"},radiantRaHours:3.22,radiantDecDeg:58,start:{month:7,day:17},peak:{month:8,day:12},end:{month:8,day:24},peakZhr:100,velocityKmS:59,populationIndex:2.2},{id:"southern-taurids",code:"STA",name:{en:"Southern Taurids",fr:"Taurides du Sud"},radiantRaHours:3.47,radiantDecDeg:13,start:{month:9,day:10},peak:{month:10,day:10},end:{month:11,day:20},peakZhr:5,velocityKmS:27,populationIndex:2.3},{id:"draconids",code:"DRA",name:{en:"October Draconids",fr:"Draconides d'octobre"},radiantRaHours:17.47,radiantDecDeg:54,start:{month:10,day:6},peak:{month:10,day:8},end:{month:10,day:10},peakZhr:10,velocityKmS:20,populationIndex:2.6},{id:"orionids",code:"ORI",name:{en:"Orionids",fr:"Orionides"},radiantRaHours:6.35,radiantDecDeg:15.6,start:{month:10,day:2},peak:{month:10,day:21},end:{month:11,day:7},peakZhr:20,velocityKmS:66,populationIndex:2.5},{id:"northern-taurids",code:"NTA",name:{en:"Northern Taurids",fr:"Taurides du Nord"},radiantRaHours:3.87,radiantDecDeg:22,start:{month:10,day:20},peak:{month:11,day:12},end:{month:12,day:10},peakZhr:5,velocityKmS:29,populationIndex:2.3},{id:"leonids",code:"LEO",name:{en:"Leonids",fr:"Léonides"},radiantRaHours:10.13,radiantDecDeg:21.6,start:{month:11,day:6},peak:{month:11,day:17},end:{month:11,day:30},peakZhr:15,velocityKmS:71,populationIndex:2.5},{id:"geminids",code:"GEM",name:{en:"Geminids",fr:"Géminides"},radiantRaHours:7.47,radiantDecDeg:32.3,start:{month:12,day:4},peak:{month:12,day:14},end:{month:12,day:17},peakZhr:150,velocityKmS:35,populationIndex:2.6},{id:"ursids",code:"URS",name:{en:"Ursids",fr:"Ursides"},radiantRaHours:14.47,radiantDecDeg:75.3,start:{month:12,day:17},peak:{month:12,day:22},end:{month:12,day:26},peakZhr:10,velocityKmS:33,populationIndex:3}],Za=6.5;class hc{static activeAt(t){return dS.flatMap(e=>{const n=this.nearness(e,t);return n<=0?[]:[{shower:e,zhr:e.peakZhr*n,nearness:n}]})}static nearness(t,e){const n=this.dayOfYear(e),s=this.dayOfYear(this.asDate(t.start)),r=this.dayOfYear(this.asDate(t.peak)),a=this.dayOfYear(this.asDate(t.end)),o=this.wrappedDelta(n,r),c=this.wrappedDelta(r,s),l=this.wrappedDelta(a,r);return o<0?o<-c?0:1+o/c:o>0?o>l?0:1-o/l:1}static observedRatePerHour(t,e,n,s=Za){if(e<=0)return 0;const r=Za-s;return t*Math.sin(e*Math.PI/180)/Math.pow(n,r)}static radiantPosition(t,e,n){return ao(t.radiantRaHours,t.radiantDecDeg,e,n)}static dayOfYear(t){const e=Date.UTC(t.getUTCFullYear(),0,1);return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-e)/864e5)+1}static asDate(t){return new Date(Date.UTC(2001,t.month-1,t.day))}static wrappedDelta(t,e){const n=t-e;return n>182?n-365:n<-182?n+365:n}}class xe{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(t,e){const n=Le(t),s=new sh(0,Sx(t).elon-90,1),r=Na(Kx(n),Hd(s,n)),a=Vd(r);return ao(a.ra,a.dec,t,e)}static observedRatePerHour(t,e=Za){const n=xe.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(t*Math.PI/180)),s=Za-e;return(xe.QUIET_RATE_PER_HOUR+n)/Math.pow(xe.POPULATION_INDEX,s)}static schedule(t){const e=new Jd(t.seed^1542469173);return Ki.schedule(t).map(n=>{const s=xe.toCartesian({altitudeDeg:Math.asin(e.next())*180/Math.PI,azimuthDeg:e.between(0,360)}),r=n.fromRadiantDeg*Math.PI/180,a=xe.turnAround(s,e.between(0,360)),o={x:s.x*Math.cos(r)+a.x*Math.sin(r),y:s.y*Math.cos(r)+a.y*Math.sin(r),z:s.z*Math.cos(r)+a.z*Math.sin(r)};return{...n,radiant:xe.toHorizontal(o),bearingDeg:xe.bearingFrom(o,s)}})}static turnAround(t,e){const[n,s]=xe.basisAround(t),r=e*Math.PI/180;return{x:n.x*Math.cos(r)+s.x*Math.sin(r),y:n.y*Math.cos(r)+s.y*Math.sin(r),z:n.z*Math.cos(r)+s.z*Math.sin(r)}}static bearingFrom(t,e){const[n,s]=xe.basisAround(t),r=t.x*e.x+t.y*e.y+t.z*e.z,a=xe.normalise({x:e.x-t.x*r,y:e.y-t.y*r,z:e.z-t.z*r});return(Math.atan2(a.x*s.x+a.y*s.y+a.z*s.z,a.x*n.x+a.y*n.y+a.z*n.z)*180/Math.PI%360+360)%360}static basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=xe.normalise(xe.cross(t,e));return[n,xe.normalise(xe.cross(t,n))]}static toHorizontal(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{altitudeDeg:Math.asin(Math.min(1,Math.max(-1,t.y/e)))*180/Math.PI,azimuthDeg:(Math.atan2(t.x,-t.z)*180/Math.PI%360+360)%360}}static appearanceOf(t){const e=xe.toCartesian(t.radiant??{altitudeDeg:90,azimuthDeg:0}),n=xe.turnAround(e,t.bearingDeg),s=t.fromRadiantDeg*Math.PI/180;return xe.toHorizontal({x:e.x*Math.cos(s)+n.x*Math.sin(s),y:e.y*Math.cos(s)+n.y*Math.sin(s),z:e.z*Math.cos(s)+n.z*Math.sin(s)})}static toCartesian(t){const e=t.altitudeDeg*Math.PI/180,n=t.azimuthDeg*Math.PI/180,s=Math.cos(e);return{x:s*Math.sin(n),y:Math.sin(e),z:-s*Math.cos(n)}}static cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}static normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}static TYPICAL_VELOCITY_KM_S=40}class fS{lowerM;upperM;add(t,e){if(!(t<=0)){if(e.behindM!==void 0){const n=tn.sizeMAt(e.behindM,t);this.lowerM=this.lowerM===void 0?n:Math.max(this.lowerM,n)}if(e.inFrontM!==void 0){const n=tn.sizeMAt(e.inFrontM,t);this.upperM=this.upperM===void 0?n:Math.min(this.upperM,n)}}}get sizeRange(){return{minM:this.lowerM,maxM:this.upperM}}get empty(){return this.lowerM===void 0&&this.upperM===void 0}get contradictory(){return this.lowerM!==void 0&&this.upperM!==void 0&&this.lowerM>this.upperM}distanceRangeAt(t){return t<=0?{}:{minM:this.lowerM===void 0?void 0:tn.distanceMAt(this.lowerM,t),maxM:this.upperM===void 0?void 0:tn.distanceMAt(this.upperM,t)}}clear(){this.lowerM=void 0,this.upperM=void 0}}B0();const pS={sun:{en:"Sun",fr:"Soleil"},moon:{en:"Moon",fr:"Lune"},Venus:{en:"Venus",fr:"Vénus"},Mars:{en:"Mars",fr:"Mars"},Jupiter:{en:"Jupiter",fr:"Jupiter"},Saturn:{en:"Saturn",fr:"Saturne"}},mS=["en","fr"],I0="comet:",gS={building:{en:"Building",fr:"Bâtiment"},tree:{en:"Tree",fr:"Arbre"},streetlight:{en:"Streetlight",fr:"Lampadaire"},vehicle:{en:"Vehicle",fr:"Véhicule"},witness:{en:"Witness",fr:"Témoin"},aircraft:{en:"Aircraft",fr:"Aéronef"}},_S=new URL(""+new URL("stars-mag7.5-DDr9QasD.bin",import.meta.url).href,import.meta.url).href,vS={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},uc={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class xS extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","show-compass","lens-flare-intensity"]}shadow;stageElement;frameElement;sceneCanvas;ufoElement;sceneRenderer;hoverTooltip;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;meteorScheduleFor;lastTimeMs=0;starCatalog;weatherAudio=new hS;thunderTimeoutId;handleFullscreenChange=()=>this.resizeToStage();handlePointerMove=t=>{this.sceneRenderer.setCompassHovered(!0);const e=this.ufoElement.canvasElement,n=e.getBoundingClientRect();if(n.width===0||n.height===0)return;const s=(t.clientX-n.left)/n.width*e.width,r=(t.clientY-n.top)/n.height*e.height;if(this.ufoElement.hasVisibleShapeAt(s,r)){this.hoverTooltip.hidden=!0;return}const a=(t.clientX-n.left)/n.width*2-1,o=-((t.clientY-n.top)/n.height*2-1),c=Nl(navigator.languages,mS),l=this.sceneRenderer.pickBodyAt(a,o);if(l){this.showHoverTooltip(t,this.bodyName(l,c));return}const h=this.sceneRenderer.pickDecorAt(a,o),u=h?this.ufoElement.sighting.decor.find(d=>d.id===h):void 0;if(u){this.showHoverTooltip(t,u.title||gS[u.kind][c]);return}this.hoverTooltip.hidden=!0};bodyName(t,e){const n=t.startsWith(I0)?t.slice(I0.length):void 0;return(n?hf.find(r=>r.id===n):void 0)?.name[e]??pS[t]?.[e]??t}showHoverTooltip(t,e){this.hoverTooltip.textContent=e,this.hoverTooltip.hidden=!1;const n=this.stageElement.getBoundingClientRect();this.hoverTooltip.style.left=`${t.clientX-n.left+12}px`,this.hoverTooltip.style.top=`${t.clientY-n.top+12}px`}handlePointerLeave=()=>{this.hoverTooltip.hidden=!0,this.sceneRenderer.setCompassHovered(!1)};handleLightningFlash=()=>{clearTimeout(this.thunderTimeoutId);const t=(.5+Math.random()*3.5)*1e3;this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),t)};handleFirstInteraction=()=>{this.weatherAudio.resume(),this.setWeather(Mh(this.ufoElement.sighting,this.lastTimeMs))};handleTimeUpdate=t=>{this.lastTimeMs=t.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.updateUfoOcclusion(this.lastTimeMs)};syncAnimationsToPlayback(){const t=this.ufoElement.playbackState==="playing";this.sceneRenderer.setAnimationsRunning(t),this.weatherAudio.setPaused(!t),t||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${xf}</style>${vf}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.frameElement=this.shadow.getElementById("frame"),this.sceneCanvas=this.shadow.getElementById("scene-canvas"),this.sceneRenderer=new XM(this.sceneCanvas,void 0,this.handleLightningFlash),this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(pc),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.style.setProperty("--ufo-canvas-background","transparent"),this.ufoElement.style.setProperty("--ufo-canvas-border","none"),this.ufoElement.fullscreenTarget=this.stageElement,this.shadow.getElementById("ufo-slot").replaceWith(this.ufoElement),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.canvasElement.addEventListener("pointermove",this.handlePointerMove),this.ufoElement.canvasElement.addEventListener("pointerleave",this.handlePointerLeave),this.ufoElement.canvasElement.addEventListener("pointerdown",this.handleFirstInteraction,{once:!0})}connectedCallback(){this.resizeToStage(),this.updateAstronomy(this.lastTimeMs),this.loadStars(),this.resizeObserver=new ResizeObserver(()=>this.resizeToStage()),this.resizeObserver.observe(this.frameElement),document.addEventListener("fullscreenchange",this.handleFullscreenChange);const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose()}attributeChangedCallback(t,e,n){if(t==="src"&&n&&n!==e&&this.isConnected&&this.loadFromSrc(n),t==="star-catalog-src"&&n!==e&&this.isConnected&&this.loadStars(),t==="show-compass"&&n!==e&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),t==="lens-flare-intensity"&&n!==e){const s=n===null?NaN:parseFloat(n);this.sceneRenderer.setLensFlareArtifactIntensity(Number.isFinite(s)?s:0)}}setCompassForced(t){this.sceneRenderer.setCompassForced(t)}setIndoorLook(t,e){this.sceneRenderer.setIndoorLook(t,e)}setWeather(t){this.sceneRenderer.setWeather(t),this.weatherAudio.setAmbient(t.precipitationType,t.precipitationIntensity,t.windSpeed)}pickDecorAt(t,e){return this.sceneRenderer.pickDecorAt(t,e)}resumeWeatherAudio(){this.weatherAudio.resume()}async loadFromSrc(t){const e=await fetch(t);this.sightingData=await e.json()}get sightingData(){return this.ufoElement.sightingData}set sightingData(t){this.ufoElement.sightingData=t,this.lastTimeMs=0,this.updateAstronomy(0)}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}setTerrainProviders(t){this.sceneRenderer.setTerrainProviders(t)}resizeToStage(){const t=this.frameElement.getBoundingClientRect(),e=Math.max(1,Math.round(t.width)),n=Math.max(1,Math.round(t.height));this.sceneCanvas.width=e,this.sceneCanvas.height=n,this.sceneRenderer.resize(e,n)}async loadStars(){const t=this.getAttribute("star-catalog-src")??_S;this.starCatalog=await sS(t),this.updateAstronomy(this.lastTimeMs)}updateAstronomy(t){const e=this.ufoElement.sighting;this.setWeather(Mh(e,t)),this.sceneRenderer.setInstrument(e.instrument),this.updateMeteorShower(e,t),this.sceneRenderer.setDecor(e.decor);const n=mr(e,t);this.sceneRenderer.setObserverPose(n??uc),this.sceneRenderer.updateDecorAnchoring(mr(e,0),n,t),this.sceneRenderer.updateDecorLitState(t),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng);const s=n?.lat??uc.lat,r=n?.lng??uc.lng,a=Yu(e.event.time??{},r,e.event.utcOffsetHours);if(!a){this.sceneRenderer.setAstronomy(vS);return}const o=new Date(a.getTime()+t),c={lat:s,lng:r,elevationM:n?.elevationM??0},l={...Qo("Sun",o,c),magnitude:jo("Sun",o)},h={...Qo("Moon",o,c),phase:$x(o),magnitude:jo("Moon",o)},u=Zx.map(d=>({body:d,position:Qo(d,o,c),magnitude:jo(d,o)}));this.sceneRenderer.setAstronomy({sun:l,moon:h,planets:u,comet:this.cometAt(o,c),stars:this.starCatalog?{catalog:this.starCatalog,date:o,observer:c}:void 0})}cometAt(t,e){const n=uS.brightestAt(t,e);if(n)return{id:n.apparition.id,position:n.position,tailEnd:n.tailEnd,magnitude:n.magnitude}}updateUfoOcclusion(t){const e=this.ufoElement.sighting;e!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.sizeEstimatesFor=e);const n=e.timeline,s=this.ufoElement.canvasElement,r=new Set;for(const a of n.sourceIds){const o=n.getInterpolatedShapeAt(t,a);if(!o)continue;const c=(o.bounds.x+o.bounds.width/2)/s.width*2-1,l=-((o.bounds.y+o.bounds.height/2)/s.height*2-1);this.sceneRenderer.isScreenPointOccluded(c,l,a,o.behindCloud)&&r.add(a);const h=o.angular?.widthDeg??this.projectionAt(t).pxToDeg(o.bounds.width);this.sizeEstimateOf(a).add(h,this.sceneRenderer.decorDistancesAt(c,l,a))}this.ufoElement.setOccludedSourceIds(r)}sizeRangeOf(t){return this.sizeEstimateOf(t).sizeRange}distanceRangeAt(t,e){const n=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(e,t);if(!n)return{};const s=n.angular?.widthDeg??this.projectionAt(e).pxToDeg(n.bounds.width);return this.sizeEstimateOf(t).distanceRangeAt(s)}sizeContradictory(t){return this.sizeEstimateOf(t).contradictory}updateMeteorShower(t,e){this.ensureMeteorSchedule(t),this.sceneRenderer.updateMeteors(e)}ensureMeteorSchedule(t){const e=this.meteorInputsOf(t);e!==this.meteorScheduleFor&&(this.meteorScheduleFor=e,this.scheduleMeteors(t))}meteorInputsOf(t){const e=t.event.place?.[0],n=t.event.time;return JSON.stringify([e?.lat,e?.lng,n?.year,n?.month,n?.day,n?.hour,n?.minute,t.event.utcOffsetHours,t.event.durationSeconds,t.timeline.duration])}scheduleMeteors(t){const e=t.event.place?.[0],n=t.event.time,s=e?.lat!==void 0&&e.lng!==void 0&&n?.year!==void 0?Yu(n,e.lng,t.event.utcOffsetHours):void 0;if(!s||e?.lat===void 0||e.lng===void 0){this.sceneRenderer.setMeteorShower([],0,0);return}const r={lat:e.lat,lng:e.lng,elevationM:0},a=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,o=Math.round(s.getTime()/1e3)+Math.round(e.lat*1e3),c=xe.schedule({ratePerHour:xe.observedRatePerHour(xe.apexPosition(s,r).altitudeDeg),durationMs:a,velocityKmS:xe.TYPICAL_VELOCITY_KM_S,seed:o}),l=hc.activeAt(s).map(u=>{const d=hc.radiantPosition(u.shower,s,r);return{entry:u,position:d,rate:hc.observedRatePerHour(u.zhr,d.altitudeDeg,u.shower.populationIndex)}}).sort((u,d)=>d.rate-u.rate)[0];if(!l||l.rate<=0){this.sceneRenderer.setMeteorShower(c,0,0);return}const h=Ki.schedule({ratePerHour:l.rate,durationMs:a,velocityKmS:l.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...c],l.position.altitudeDeg,l.position.azimuthDeg)}meteorByRank(t){this.ensureMeteorSchedule(this.ufoElement.sighting);const e=[...this.sceneRenderer.meteorSchedule].filter(r=>r.t+r.durationMs<=this.ufoElement.seekableDuration).sort((r,a)=>a.brightness-r.brightness);if(e.length===0)return;const n=e[t%e.length],s=this.sceneRenderer.meteorMidpoint(n);if(s)return{t:Math.round(n.t+n.durationMs*.45),...s}}projectionAt(t){const e=this.ufoElement.sighting,n=mr(e,t)?.fovDeg??Ll.DEFAULT_FOV_DEG;return Ps.of(e.instrument,tn.CANVAS_HEIGHT_PX,n)}sizeEstimateOf(t){let e=this.sizeEstimates.get(t);return e||(e=new fS,this.sizeEstimates.set(t,e)),e}}const L0="rr0-scene";function MS(){B0(),customElements.get(L0)||customElements.define(L0,xS)}MS();