@rr0/ufoathome 0.42.0 → 0.43.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 Hf=`
1
+ const em=`
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 Hf=`
6
6
  <div id="ufo-slot"></div>
7
7
  <div id="hover-tooltip" class="hover-tooltip" hidden></div>
8
8
  </div>
9
- `,kf=`
9
+ `,tm=`
10
10
  :host {
11
11
  display: block;
12
12
  }
@@ -95,7 +95,7 @@ const Hf=`
95
95
  pointer-events: none;
96
96
  white-space: nowrap;
97
97
  }
98
- `;class vs extends Error{constructor(e,t,n){super(`${e}: ${t}${n===void 0?"":` (HTTP ${n})`}`),this.kind=e,this.url=t,this.status=n,this.name="SightingFetchError"}}class e0{static async json(e){const t=new URL(e,location.href);if(location.protocol==="https:"&&t.protocol==="http:")throw new vs("mixed-content",e);let n;try{n=await fetch(e)}catch{throw await this.diagnose(e,t)}if(!n.ok)throw new vs("status",e,n.status);try{return await n.json()}catch{throw new vs("malformed",e)}}static async diagnose(e,t){if(t.origin===location.origin)return new vs("unreachable",e);try{return await fetch(e,{mode:"no-cors"}),new vs("cors",e)}catch{return new vs("unreachable",e)}}}const Gf=`
98
+ `;class As extends Error{constructor(e,t,n){super(`${e}: ${t}${n===void 0?"":` (HTTP ${n})`}`),this.kind=e,this.url=t,this.status=n,this.name="SightingFetchError"}}class ff{static async json(e){const t=new URL(e,location.href);if(location.protocol==="https:"&&t.protocol==="http:")throw new As("mixed-content",e);let n;try{n=await fetch(e)}catch{throw await this.diagnose(e,t)}if(!n.ok)throw new As("status",e,n.status);try{return await n.json()}catch{throw new As("malformed",e)}}static async diagnose(e,t){if(t.origin===location.origin)return new As("unreachable",e);try{return await fetch(e,{mode:"no-cors"}),new As("cors",e)}catch{return new As("unreachable",e)}}}const nm=`
99
99
  <div class="stage" id="stage">
100
100
  <div class="frame" id="frame">
101
101
  <canvas id="canvas" width="640" height="360"></canvas>
@@ -110,7 +110,7 @@ const Hf=`
110
110
  <button id="loop" type="button" title="Auto-replay" aria-label="Auto-replay" aria-pressed="true">↻</button>
111
111
  </div>
112
112
  </div>
113
- `,Vf=`
113
+ `,im=`
114
114
  :host {
115
115
  display: block;
116
116
  font-family: sans-serif;
@@ -326,21 +326,21 @@ input[type=range] {
326
326
  pointer-events: none;
327
327
  white-space: nowrap;
328
328
  }
329
- `,Yr=[{id:"eye",name:{en:"Naked eye",fr:"Œil nu"},flare:0,projection:"equidistant"},{id:"rectilinear-lens",name:{en:"Camera, unknown device",fr:"Appareil, modèle inconnu"},projection:"rectilinear",fNumber:8,fNumberRange:{min:2,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:8},apertureBlades:6},{id:"instamatic-126",name:{en:"Instamatic, 126 film",fr:"Instamatic, film 126"},projection:"rectilinear",frame:{widthMm:28,heightMm:28,focalLengthMm:43},fNumber:11,exposureSeconds:1/90,years:{from:1963,to:1988},apertureBlades:5},{id:"slr-35mm-50",name:{en:"35 mm SLR, 50 mm lens",fr:"Reflex 35 mm, objectif 50 mm"},projection:"rectilinear",frame:{widthMm:36,heightMm:24,focalLengthMm:50},fNumber:8,fNumberRange:{min:2,max:16},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:3600},years:{from:1959},apertureBlades:6},{id:"slr-35mm-zoom",name:{en:"35 mm SLR, 70-210 mm zoom",fr:"Reflex 35 mm, zoom 70-210 mm"},projection:"rectilinear",frame:{widthMm:36,heightMm:24,focalLengthMm:135,focalRangeMm:{minMm:70,maxMm:210}},fNumber:8,fNumberRange:{min:4,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:3600},apertureBlades:8,years:{from:1975}},{id:"phone-landscape",name:{en:"Phone, held sideways",fr:"Téléphone, tenu couché"},projection:"rectilinear",frame:{widthMm:7.6,heightMm:5.7,focalLengthMm:5.7},exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0},{id:"phone-portrait",name:{en:"Phone, held upright",fr:"Téléphone, tenu debout"},projection:"rectilinear",frame:{widthMm:5.7,heightMm:7.6,focalLengthMm:5.7},exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0}];class Zt{static get default(){return Yr[0]}static byId(e){return Yr.find(t=>t.id===e)??this.default}static UNAIDED_FIELD_DEG=60;static UNAIDED_ASPECT=16/9;static fieldOfViewDeg(e){const t=e.frame;return t?2*Math.atan(t.heightMm/(2*t.focalLengthMm))*180/Math.PI:Zt.UNAIDED_FIELD_DEG}static aspectOf(e){const t=e.frame;return t?t.widthMm/t.heightMm:Zt.UNAIDED_ASPECT}static frameWidthPx(e,t){return Math.round(t*Zt.aspectOf(e))}static availableAt(e){return e===void 0?Yr:Yr.filter(t=>!t.years||e>=t.years.from&&(t.years.to===void 0||e<=t.years.to))}static fieldOfViewDegAt(e,t){const n=e.frame;if(!(!n||t<=0))return 2*Math.atan(n.heightMm/(2*t))*180/Math.PI}static focalLengthMmFor(e,t){const n=e.frame;if(!(!n||t<=0||t>=180))return n.heightMm/(2*Math.tan(t*Math.PI/360))}static bladesShowing(e,t){const n=t??e.fNumber;if(n===void 0||e.apertureBlades===void 0)return 0;const s=e.fNumberRange;return!s||s.max<=s.min?1:Math.max(0,Math.min(1,(n-s.min)/(s.max-s.min)))}static LENS_FLARE_ARTIFACTS=1;static flareArtifactsOf(e){return e.flare??Zt.LENS_FLARE_ARTIFACTS}static starPointsOf(e){const t=e.apertureBlades;return t===void 0||t<3?0:t%2===0?t:t*2}}class Kt{static MOON_ANGULAR_WIDTH_DEG=.5237;static CANVAS_WIDTH_PX=640;static CANVAS_HEIGHT_PX=360;static angularWidthDeg(e){return 2*Math.atan(e.sizeM/(2*e.distanceM))*180/Math.PI}static inMoons(e){return e/Kt.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(e,t,n){if(!(!e||!t))return{widthDeg:e.widthDeg+(t.widthDeg-e.widthDeg)*n,heightDeg:e.heightDeg+(t.heightDeg-e.heightDeg)*n}}static sizeMAt(e,t){return 2*e*Math.tan(t*Math.PI/360)}static distanceMAt(e,t){return e/(2*Math.tan(t*Math.PI/360))}}function Wf(i,e,t){const{bounds:n}=i;return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function cn(i,e,t){return i+(e-i)*t}function Nh(i){const e=/^#([0-9a-f]{6})$/i.exec(i);if(!e)return;const t=parseInt(e[1],16);return[t>>16&255,t>>8&255,t&255]}function Xf(i){return`#${i.map(e=>Math.round(e).toString(16).padStart(2,"0")).join("")}`}function qf(i,e,t){const n=Nh(i),s=Nh(e);return!n||!s?t<1?i:e:Xf([cn(n[0],s[0],t),cn(n[1],s[1],t),cn(n[2],s[2],t)])}function Yf(i,e,t){const n={x:cn(i.bounds.x,e.bounds.x,t),y:cn(i.bounds.y,e.bounds.y,t),width:cn(i.bounds.width,e.bounds.width,t),height:cn(i.bounds.height,e.bounds.height,t)},s=cn(i.angle,e.angle,t),r=cn(i.transparency,e.transparency,t),a=cn(i.haloScale,e.haloScale,t),o=cn(i.blur??0,e.blur??0,t),c=cn(i.brightness??0,e.brightness??0,t),l=qf(i.color,e.color,t),h=Kt.lerpAngular(i.angular,e.angular,t);return i.kind==="polygon"&&e.kind==="polygon"&&i.points.length===e.points.length?{...i,bounds:n,angle:s,transparency:r,haloScale:a,blur:o,brightness:c,color:l,angular:h,behindCloud:t<1?i.behindCloud:e.behindCloud,points:i.points.map((u,d)=>({x:cn(u.x,e.points[d].x,t),y:cn(u.y,e.points[d].y,t)}))}:{...t<1?i:e,bounds:n,angle:s,transparency:r,haloScale:a,blur:o,brightness:c,color:l,angular:h}}class mo{keyframes=[];order=[];groups=[];addKeyframe(e,t){const n=this.findInsertIndex(e);if(this.keyframes[n]?.t===e){const s=new Set(t.map(r=>r.sourceId));this.keyframes[n]={t:e,shapes:[...this.keyframes[n].shapes.filter(r=>!s.has(r.sourceId)),...t]}}else this.keyframes.splice(n,0,{t:e,shapes:[...t]});for(const s of t)this.order.includes(s.sourceId)||this.order.push(s.sourceId)}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const s=t+n>>>1;this.keyframes[s].t<e?t=s+1:n=s}return t}getKeyframeAt(e){const t=this.findInsertIndex(e),n=this.keyframes[t];return n?.t===e?n:void 0}getShapeAt(e,t){return this.getKeyframeAt(e)?.shapes.find(n=>n.sourceId===t)?.shape}getLatestShapeAt(e,t){let n=this.findInsertIndex(e);for(this.keyframes[n]?.t!==e&&(n-=1);n>=0;n--){const s=this.keyframes[n].shapes.find(r=>r.sourceId===t);if(s)return s.shape}}getInterpolatedShapeAt(e,t){const n=this.findShapeAtOrBefore(e,t);if(n?.t===e)return n.shape;const s=this.findShapeAtOrAfter(e,t);return n?s?Yf(n.shape,s.shape,(e-n.t)/(s.t-n.t)):n.shape:s?.shape}findShapeAtOrBefore(e,t){let n=this.findInsertIndex(e);for(this.keyframes[n]?.t!==e&&(n-=1);n>=0;n--){const s=this.keyframes[n].shapes.find(r=>r.sourceId===t);if(s)return{t:this.keyframes[n].t,shape:s.shape}}}findShapeAtOrAfter(e,t){for(let n=this.findInsertIndex(e);n<this.keyframes.length;n++){const s=this.keyframes[n].shapes.find(r=>r.sourceId===t);if(s)return{t:this.keyframes[n].t,shape:s.shape}}}hitTest(e,t,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(e,r[a]);if(o&&Wf(o,t,n))return{sourceId:r[a],shape:o}}}removeSource(e){for(let t=this.keyframes.length-1;t>=0;t--){const n=this.keyframes[t].shapes.filter(s=>s.sourceId!==e);n.length===0?this.keyframes.splice(t,1):n.length!==this.keyframes[t].shapes.length&&(this.keyframes[t]={t:this.keyframes[t].t,shapes:n})}this.order=this.order.filter(t=>t!==e),this.removeFromGroup(e)}group(e){if(!(e.length<2)){for(const t of e)this.removeFromGroup(t);this.groups.push([...e])}}ungroup(e){const t=this.groups.findIndex(n=>n.includes(e));t!==-1&&this.groups.splice(t,1)}groupMembers(e){return this.groups.find(t=>t.includes(e))}removeFromGroup(e){const t=this.groups.findIndex(s=>s.includes(e));if(t===-1)return;const n=this.groups[t].filter(s=>s!==e);n.length<2?this.groups.splice(t,1):this.groups[t]=n}bringToFront(e){const t=this.order.indexOf(e);t!==-1&&(this.order.splice(t,1),this.order.push(e))}sendToBack(e){const t=this.order.indexOf(e);t!==-1&&(this.order.splice(t,1),this.order.unshift(e))}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(e){const t=new mo;for(const n of e.keyframes)t.addKeyframe(n.t,n.shapes);if(e.order){const n=t.order.filter(s=>!e.order.includes(s));t.order=[...e.order,...n]}return e.groups&&(t.groups=e.groups.map(n=>n.filter(s=>t.order.includes(s))).filter(n=>n.length>=2)),t}}function Kf(i,e,t){return Math.max(e,Math.min(t,i))}function Zf(i,e,t){const n=((e-i)%360+540)%360-180;return((i+n*t)%360+360)%360}function _s(i,e,t){return i+(e-i)*t}function $f(i,e,t){return{lat:i.lat===void 0||e.lat===void 0?void 0:_s(i.lat,e.lat,t),lng:i.lng===void 0||e.lng===void 0?void 0:_s(i.lng,e.lng,t),elevationM:_s(i.elevationM,e.elevationM,t),headingDeg:i.headingDeg===void 0||e.headingDeg===void 0?void 0:Zf(i.headingDeg,e.headingDeg,t),pitchDeg:_s(i.pitchDeg,e.pitchDeg,t),rollDeg:_s(i.rollDeg??0,e.rollDeg??0,t),fovDeg:_s(i.fovDeg,e.fovDeg,t),fNumber:i.fNumber,focusDistanceM:i.focusDistanceM}}class Nr{keyframes=[];addKeyframe(e,t){const n=this.findInsertIndex(e);this.keyframes[n]?.t===e?this.keyframes[n]={t:e,pose:t}:this.keyframes.splice(n,0,{t:e,pose:t})}clear(){this.keyframes.length=0}removeKeyframeAt(e){const t=this.findInsertIndex(e);this.keyframes[t]?.t===e&&this.keyframes.splice(t,1)}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const s=t+n>>>1;this.keyframes[s].t<e?t=s+1:n=s}return t}getLatestPoseAt(e){let t=this.findInsertIndex(e);return this.keyframes[t]?.t!==e&&(t-=1),t>=0?this.keyframes[t].pose:void 0}getInterpolatedPoseAt(e){const t=this.findInsertIndex(e),n=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(n?.t===e)return n.pose;const s=this.keyframes[t]?.t===e?void 0:this.keyframes[t];return n?s?$f(n.pose,s.pose,Kf((e-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(e){const t=new Nr;for(const n of e.keyframes)t.addKeyframe(n.t,n.pose);return t}}function Mi(i,e,t){return i+(e-i)*t}function Jf(i,e,t){const n=((e-i)%360+540)%360-180;return((i+n*t)%360+360)%360}function Qf(i,e,t){return Math.max(e,Math.min(t,i))}function jf(i,e,t){return{cloudCover:Mi(i.cloudCover,e.cloudCover,t),cloudDarkness:Mi(i.cloudDarkness,e.cloudDarkness,t),highCloudCover:i.highCloudCover===void 0||e.highCloudCover===void 0?void 0:Mi(i.highCloudCover,e.highCloudCover,t),iceCrystalAlignment:i.iceCrystalAlignment===void 0||e.iceCrystalAlignment===void 0?void 0:Mi(i.iceCrystalAlignment,e.iceCrystalAlignment,t),lowerCloudCover:i.lowerCloudCover===void 0||e.lowerCloudCover===void 0?void 0:Mi(i.lowerCloudCover,e.lowerCloudCover,t),cloudBaseM:i.cloudBaseM===void 0||e.cloudBaseM===void 0?void 0:Mi(i.cloudBaseM,e.cloudBaseM,t),precipitationType:t<1?i.precipitationType:e.precipitationType,precipitationIntensity:Mi(i.precipitationIntensity,e.precipitationIntensity,t),windDirectionDeg:Jf(i.windDirectionDeg,e.windDirectionDeg,t),windSpeed:Mi(i.windSpeed,e.windSpeed,t),storm:t<1?i.storm:e.storm}}class Ur{keyframes=[];addKeyframe(e,t){const n=this.findInsertIndex(e);this.keyframes[n]?.t===e?this.keyframes[n]={t:e,weather:t}:this.keyframes.splice(n,0,{t:e,weather:t})}clear(){this.keyframes.length=0}removeKeyframeAt(e){const t=this.findInsertIndex(e);this.keyframes[t]?.t===e&&this.keyframes.splice(t,1)}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const s=t+n>>>1;this.keyframes[s].t<e?t=s+1:n=s}return t}getLatestWeatherAt(e){let t=this.findInsertIndex(e);return this.keyframes[t]?.t!==e&&(t-=1),t>=0?this.keyframes[t].weather:void 0}getInterpolatedWeatherAt(e){const t=this.findInsertIndex(e),n=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(n?.t===e)return n.weather;const s=this.keyframes[t]?.t===e?void 0:this.keyframes[t];return n?s?jf(n.weather,s.weather,Qf((e-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(e){const t=new Ur;for(const n of e.keyframes)t.addKeyframe(n.t,n.weather);return t}}class Or{keyframes=[];addKeyframe(e,t){const n=this.findInsertIndex(e);this.keyframes[n]?.t===e?this.keyframes[n]={t:e,sound:t}:this.keyframes.splice(n,0,{t:e,sound:t})}clear(){this.keyframes.length=0}removeKeyframeAt(e){const t=this.findInsertIndex(e);this.keyframes[t]?.t===e&&this.keyframes.splice(t,1)}getLatestSoundAt(e){let t=this.findInsertIndex(e);return this.keyframes[t]?.t!==e&&(t-=1),t>=0?this.keyframes[t].sound:void 0}getInterpolatedSoundAt(e){const t=this.findInsertIndex(e),n=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(n?.t===e)return n.sound;const s=this.keyframes[t]?.t===e?void 0:this.keyframes[t];if(!n)return s?.sound;if(!s)return n.sound;const r=(e-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(e){const t=new Or;for(const n of e.keyframes)t.addKeyframe(n.t,n.sound);return t}lerp(e,t,n){return{kind:n<1?e.kind:t.kind,volume:e.volume+(t.volume-e.volume)*n,pitchHz:e.pitchHz+(t.pitchHz-e.pitchHz)*n,src:n<1?e.src:t.src}}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const s=t+n>>>1;this.keyframes[s].t<e?t=s+1:n=s}return t}}const t0=1e3,ep=.65,n0={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,storm:!1},tp=100,np={kind:"none",volume:0,pitchHz:tp};function Lc(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 Uh(i){return(((i.day??0)*24+(i.hour??0))*60+(i.minute??0))*6e4+(i.second??0)*1e3}const ip=["year","month","day","hour","minute"],sp=["day","hour","minute"];function Oh(i,e){return e.filter(t=>i[t]!==void 0).join(",")}function rp(i){if(i.durationSeconds!==void 0)return i.durationSeconds*1e3;if(!i.time||!i.endTime)return;const e=i.time.year!==void 0&&i.endTime.year!==void 0,t=e?ip:sp,n=Oh(i.time,t);if(!(n===""||n!==Oh(i.endTime,t)))return e?Lc(i.endTime)-Lc(i.time):Uh(i.endTime)-Uh(i.time)}class go{constructor(e,t,n,s,r,a,o,c,l=[],h,u,d){this.event=e,this.timeline=t,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,this.exposureSeconds=d}get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return Zt.byId(this.instrumentId)}static create(e,t,n){return new go({eventType:"sighting",time:e,place:t},new mo,new Nr,new Ur,new Or,n)}}const ap=0,op=0;function Vs(i,e){const t=i.witnessTrack.getInterpolatedPoseAt(e);if(t)return t;const n=i.event.place?.[0];if(n)return{lat:n.lat,lng:n.lng,elevationM:ap,headingDeg:void 0,pitchDeg:op,fovDeg:Zt.fieldOfViewDeg(i.instrument)}}function Fh(i,e){return i.weatherTrack.getInterpolatedWeatherAt(e)??i.weather??n0}function cp(i,e){return i.soundTrack.getInterpolatedSoundAt(e)??np}class lp{constructor(e,t){this.timeline=e,this.onFrame=t}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;onEnded;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 e=()=>{if(this.state!=="playing")return;const t=performance.now();if(this.currentT+=(t-this.lastWallTime)*this.playbackRate,this.lastWallTime=t,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(e);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT),this.onEnded?.();return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(e)};this.rafId=requestAnimationFrame(e)}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(e){this.currentT=Math.max(0,Math.min(e,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(e){const t=new Map;for(const n of this.timeline.sourceIds){const s=this.timeline.getInterpolatedShapeAt(e,n);s&&t.set(n,s)}this.onFrame(e,t)}}const i0=["nw","n","ne","e","se","s","sw","w"],hp=24,Kr=8,up=3,dp=8;function Zr(i,e,t){const n=i.x-e.x,s=i.y-e.y,r=Math.cos(t),a=Math.sin(t);return{x:e.x+n*r-s*a,y:e.y+n*a+s*r}}function lr(i){return{x:i.x+i.width/2,y:i.y+i.height/2}}const fp={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 vn{static handlePointsFor(e){const{x:t,y:n,width:s,height:r}=e.bounds,a={nw:{x:t,y:n},n:{x:t+s/2,y:n},ne:{x:t+s,y:n},e:{x:t+s,y:n+r/2},se:{x:t+s,y:n+r},s:{x:t+s/2,y:n+r},sw:{x:t,y:n+r},w:{x:t,y:n+r/2},rotate:{x:t+s/2,y:n-hp}},o=lr(e.bounds),c={};for(const l of Object.keys(a))c[l]=Zr(a[l],o,e.angle);return c}static hitTestHandle(e,t,n=8,s=[...i0,"rotate"]){const r=vn.handlePointsFor(e);for(const a of s)if(Math.hypot(t.x-r[a].x,t.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(e,t){const s=((vn.HANDLE_DIRECTION_DEG[e]+t*180/Math.PI)%180+180)%180/45,r=["ew","nwse","ns","nesw"];return r[Math.round(s)%r.length]}static resizeBounds(e,t,n,s){const r=lr(e),a=Zr(s,r,-t),{x:o,y:c,width:l,height:h}=e,u=fp[n];let d=o,f=c,g=o+l,x=c+h;return u.left&&(d=Math.min(a.x,g-Kr)),u.right&&(g=Math.max(a.x,d+Kr)),u.top&&(f=Math.min(a.y,x-Kr)),u.bottom&&(x=Math.max(a.y,f+Kr)),{x:d,y:f,width:g-d,height:x-f}}static resizeShape(e,t,n){if(t==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:s,height:r}=e.bounds,a=vn.resizeBounds(e.bounds,e.angle,t,n);if(e.kind==="oval")return{...e,bounds:a};const o=s===0?1:a.width/s,c=r===0?1:a.height/r;return{...e,bounds:a,points:e.points.map(l=>({x:l.x*o,y:l.y*c}))}}static rotateShape(e,t){const n=lr(e.bounds),s=Math.atan2(t.y-n.y,t.x-n.x)+Math.PI/2;return{...e,angle:s}}static groupBoundsFor(e){const t=Math.min(...e.map(a=>a.x)),n=Math.min(...e.map(a=>a.y)),s=Math.max(...e.map(a=>a.x+a.width)),r=Math.max(...e.map(a=>a.y+a.height));return{x:t,y:n,width:s-t,height:r-n}}static vertexPointsFor(e){const t=lr(e.bounds);return e.points.map(n=>Zr({x:e.bounds.x+n.x,y:e.bounds.y+n.y},t,e.angle))}static hitTestVertex(e,t,n=dp){const s=vn.vertexPointsFor(e);let r,a=n;return s.forEach((o,c)=>{const l=Math.hypot(t.x-o.x,t.y-o.y);l<=a&&(a=l,r=c)}),r}static toLocalPoint(e,t){const n=lr(e.bounds),s=Zr(t,n,-e.angle);return{x:s.x-e.bounds.x,y:s.y-e.bounds.y}}static moveVertex(e,t,n){const s=e.points.map((u,d)=>d===t?vn.toLocalPoint(e,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:e.bounds.x+r,y:e.bounds.y+a,width:o-r,height:c-a},h=s.map(u=>({x:u.x-r,y:u.y-a}));return{...e,bounds:l,points:h}}static insertVertexNear(e,t){const n=vn.toLocalPoint(e,t),{points:s}=e;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=vn.distanceToSegment(n,l,h);u<a&&(a=u,r=c)}const o=[...s.slice(0,r+1),n,...s.slice(r+1)];return{...e,points:o}}static distanceToSegment(e,t,n){const s=n.x-t.x,r=n.y-t.y,a=s*s+r*r,o=a===0?0:Math.max(0,Math.min(1,((e.x-t.x)*s+(e.y-t.y)*r)/a)),c=t.x+o*s,l=t.y+o*r;return Math.hypot(e.x-c,e.y-l)}static deleteVertex(e,t){return e.points.length<=up?e:{...e,points:e.points.filter((n,s)=>s!==t)}}}const Nc=6,$r=Nc/2,pp=20,mp=24,gp=9,zh=6,vp=7,Bh=4;class _p{constructor(e){this.ctx=e}starPoints=0;roll=0;clear(e,t){this.ctx.clearRect(0,0,e,t)}paintShape(e){this.ctx.save(),this.ctx.globalAlpha=1-e.transparency;const t=e.blur??0;t>0&&(this.ctx.filter=`blur(${(mp*t).toFixed(2)}px)`);const n=e.brightness??0;n>0&&this.paintDazzle(e,n),e.haloScale>0&&this.paintHalo(e),this.paintBase(e),this.ctx.restore(),e.selected&&this.paintSelectionHandles(e)}setStarPoints(e){this.starPoints=Math.max(0,Math.floor(e))}setRoll(e){this.roll=e}paintDazzle(e,t){const{x:n,y:s,width:r,height:a}=e.bounds,o=n+r/2,c=s+a/2,l=Math.max(r,a)/2,h=l*(1+gp*t);if(h<=0)return;this.ctx.save(),this.ctx.globalCompositeOperation="lighter";const u=this.ctx.createRadialGradient(o,c,0,o,c,h);for(let d=0;d<=zh;d++){const f=d/zh,g=1/(1+24*f*f);this.ctx.globalAlpha=1,u.addColorStop(f,this.withAlpha(e.color,g*t*.55))}if(this.ctx.fillStyle=u,this.ctx.beginPath(),this.ctx.arc(o,c,h,0,2*Math.PI),this.ctx.fill(),this.starPoints>0){const d=l*(1+vp*t);this.ctx.lineWidth=Math.max(1,l*.12),this.ctx.lineCap="round";for(let f=0;f<this.starPoints;f++){const g=f/this.starPoints*Math.PI*2+this.roll,x=o+Math.cos(g)*d,m=c+Math.sin(g)*d,p=this.ctx.createLinearGradient(o,c,x,m);p.addColorStop(0,this.withAlpha(e.color,t*.55)),p.addColorStop(.35,this.withAlpha(e.color,t*.22)),p.addColorStop(1,this.withAlpha(e.color,0)),this.ctx.strokeStyle=p,this.ctx.beginPath(),this.ctx.moveTo(o,c),this.ctx.lineTo(x,m),this.ctx.stroke()}}this.ctx.restore()}dazzledFill(e,t){if(t<=0)return e.color;const n=/^#([0-9a-f]{6})$/i.exec(e.color.trim());if(!n)return e.color;const s=Number.parseInt(n[1],16),r=a=>Math.round(a+(255-a)*t);return`rgb(${r(s>>16&255)}, ${r(s>>8&255)}, ${r(s&255)})`}withAlpha(e,t){const n=Math.max(0,Math.min(1,t)),s=/^#([0-9a-f]{6})$/i.exec(e.trim());if(!s)return e;const r=Number.parseInt(s[1],16);return`rgba(${r>>16&255}, ${r>>8&255}, ${r&255}, ${n.toFixed(3)})`}paintBase(e){if(this.ctx.fillStyle=this.dazzledFill(e,e.brightness??0),this.ctx.beginPath(),e.kind==="oval"){const{x:t,y:n,width:s,height:r}=e.bounds,a=s/2,o=r/2;this.ctx.ellipse(t+a,n+o,a,o,e.angle,0,2*Math.PI)}else{const{x:t,y:n,width:s,height:r}=e.bounds;this.ctx.save(),this.ctx.translate(t+s/2,n+r/2),this.ctx.rotate(e.angle),this.ctx.translate(-s/2,-r/2),e.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(e){this.ctx.save(),this.ctx.shadowColor=e.color,this.ctx.shadowBlur=pp*e.haloScale,this.paintBase(e),this.ctx.restore()}paintSelectionHandles(e){this.paintHandleFrame(vn.handlePointsFor(e),{includeRotate:!0}),e.kind==="polygon"&&this.paintVertexHandles(e)}paintVertexHandles(e){this.ctx.fillStyle="#39f";for(const t of vn.vertexPointsFor(e))this.ctx.beginPath(),this.ctx.ellipse(t.x,t.y,Bh,Bh,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(e){this.paintOutline(vn.handlePointsFor(e))}paintGroupHandles(e){this.paintHandleFrame(vn.handlePointsFor({bounds:e,angle:0}),{includeRotate:!0})}paintOutline(e){this.ctx.strokeStyle="lightgray",this.ctx.beginPath(),this.ctx.moveTo(e.nw.x,e.nw.y),this.ctx.lineTo(e.ne.x,e.ne.y),this.ctx.lineTo(e.se.x,e.se.y),this.ctx.lineTo(e.sw.x,e.sw.y),this.ctx.closePath(),this.ctx.stroke()}paintHandleFrame(e,{includeRotate:t}){this.paintOutline(e),this.ctx.fillStyle="lightgray";for(const n of i0){const s=e[n];this.ctx.fillRect(s.x-$r,s.y-$r,Nc,Nc)}t&&(this.ctx.beginPath(),this.ctx.moveTo(e.n.x,e.n.y),this.ctx.lineTo(e.rotate.x,e.rotate.y),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.ellipse(e.rotate.x,e.rotate.y,$r+1,$r+1,0,0,2*Math.PI),this.ctx.fill())}}const Hh=.05,kh=.08,Gh=2,Vh=3,xp=14,Mp=.02;class Sp{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(e){console.warn("SightingAudio: Web Audio unavailable, the sighting stays silent:",e);return}}this.context.state==="suspended"&&this.context.resume()}setSound(e){if(this.requested=e,!this.context)return;const t=this.keyFor(e);if(!t){this.silence();return}if(this.voice?.key!==t){this.stopVoice();const n=++this.voiceToken;t.startsWith("src:")?this.buildRecordedVoice(e.src,t,n):this.voice=this.buildSynthesizedVoice(e,t)}this.applyTo(this.voice,e)}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(e){if(!(e.volume<=0))return e.src?`src:${e.src}`:e.kind==="none"?void 0:e.kind}applyTo(e,t){const n=this.context;if(!e||!n)return;const s=n.currentTime;e.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,t.volume))*e.gainScale,s,Hh);for(const{param:r,ratio:a}of e.pitch)r.setTargetAtTime(Math.min(t.pitchHz*a,n.sampleRate/2-1),s,Hh)}buildSynthesizedVoice(e,t){const n=this.context;if(n)switch(e.kind){case"hum":return this.buildHum(n,t);case"whistle":return this.buildWhistle(n,t);case"rumble":return this.buildRumble(n,t);case"crackle":return this.buildCrackle(n,t);default:return}}buildHum(e,t){const n=e.createOscillator();n.type="sawtooth";const s=e.createOscillator();s.type="sawtooth";const r=e.createBiquadFilter();r.type="lowpass",r.Q.value=1;const a=e.createGain();return a.gain.value=0,n.connect(r),s.connect(r),r.connect(a).connect(e.destination),n.start(),s.start(),{key:t,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(e,t){const n=e.createOscillator();n.type="sine";const s=e.createOscillator();s.type="sine",s.frequency.value=5;const r=e.createGain(),a=e.createGain();return a.gain.value=0,s.connect(r).connect(n.frequency),n.connect(a).connect(e.destination),n.start(),s.start(),{key:t,nodes:[r,a],sources:[n,s],volumeParam:a.gain,gainScale:.22,pitch:[{param:n.frequency,ratio:1},{param:r.gain,ratio:.012}]}}buildRumble(e,t){const n=e.createBufferSource();n.buffer=this.brownNoise(e),n.loop=!0;const s=e.createBiquadFilter();s.type="lowpass",s.Q.value=.8;const r=e.createGain();return r.gain.value=0,n.connect(s).connect(r).connect(e.destination),n.start(),{key:t,nodes:[s,r],sources:[n],volumeParam:r.gain,gainScale:1.4,pitch:[{param:s.frequency,ratio:1}]}}buildCrackle(e,t){const n=e.createBufferSource();n.buffer=this.whiteNoise(e),n.loop=!0;const s=e.createBiquadFilter();s.type="bandpass",s.Q.value=1.2;const r=e.createGain();r.gain.value=0;const a=e.createBufferSource();a.buffer=this.crackleEnvelope(e),a.loop=!0;const o=e.createGain();return o.gain.value=0,a.connect(o).connect(r.gain),n.connect(s).connect(r).connect(e.destination),n.start(),a.start(),{key:t,nodes:[s,r,o],sources:[n,a],volumeParam:o.gain,gainScale:.9,pitch:[{param:s.frequency,ratio:4}]}}async buildRecordedVoice(e,t,n){const s=this.context;if(!s)return;let r;try{r=await this.getBuffer(e)}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:t,nodes:[o],sources:[a],volumeParam:o.gain,gainScale:1,pitch:[]},this.requested&&this.applyTo(this.voice,this.requested)}async getBuffer(e){const t=this.context;if(!t)throw new Error("SightingAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(e);return n||(n=fetch(e).then(s=>{if(!s.ok)throw new Error(`Audio fetch failed (${s.status}): ${e}`);return s.arrayBuffer()}).then(s=>t.decodeAudioData(s)),this.buffers.set(e,n)),n}whiteNoise(e){if(!this.noiseBuffer){const t=e.createBuffer(1,Math.floor(e.sampleRate*Gh),e.sampleRate),n=t.getChannelData(0);for(let s=0;s<n.length;s++)n[s]=Math.random()*2-1;this.noiseBuffer=t}return this.noiseBuffer}brownNoise(e){const t=e.createBuffer(1,Math.floor(e.sampleRate*Gh),e.sampleRate),n=t.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 t}crackleEnvelope(e){if(!this.crackleBuffer){const t=e.createBuffer(1,Math.floor(e.sampleRate*Vh),e.sampleRate),n=t.getChannelData(0),s=Math.max(1,Math.floor(Mp*e.sampleRate)),r=Math.round(Vh*xp);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=t}return this.crackleBuffer}stopVoice(){const e=this.voice,t=this.context;if(this.voice=void 0,!e||!t)return;const n=t.currentTime;e.volumeParam.cancelScheduledValues(n),e.volumeParam.setTargetAtTime(0,n,kh/3);const s=n+kh;for(const r of e.sources){r.onended=()=>{r.disconnect();for(const a of e.nodes)a.disconnect()};try{r.stop(s)}catch{r.disconnect();for(const a of e.nodes)a.disconnect()}}}}const Do=Math.PI/180,Jr=180/Math.PI;class Ys{constructor(e,t,n){this.kind=e,this.canvasHeightPx=t,this.fovDeg=n;const s=n*Do/2;this.focalPx=e==="equidistant"?t/2/s:t/2/Math.tan(s)}focalPx;static of(e,t,n){return new Ys(e.projection,t,n)}degToPx(e){const t=e*Do;return this.kind==="equidistant"?this.focalPx*t:2*this.focalPx*Math.tan(t/2)}pxToDeg(e){return this.kind==="equidistant"?e/this.focalPx*Jr:2*Math.atan(e/(2*this.focalPx))*Jr}angleDegToRadiusPx(e){const t=e*Do;return this.kind==="equidistant"?this.focalPx*t:this.focalPx*Math.tan(t)}radiusPxToAngleDeg(e){return this.kind==="equidistant"?e/this.focalPx*Jr:Math.atan(e/this.focalPx)*Jr}ofBounds(e){return{widthDeg:this.pxToDeg(e.width),heightDeg:this.pxToDeg(e.height)}}toBoundsSize(e){return{width:this.degToPx(e.widthDeg),height:this.degToPx(e.heightDeg)}}widthPx(e){return this.degToPx(Kt.angularWidthDeg(e))}}class Dr{static fovOf(e,t){return Vs(e,t)?.fovDeg??Zt.fieldOfViewDeg(e.instrument)}static toAngular(e){this.eachKeyframe(e,(t,n)=>({...t,angular:n.ofBounds(t.bounds)}))}static toBounds(e){this.eachKeyframe(e,(t,n)=>{if(!t.angular)return t;const{width:s,height:r}=n.toBoundsSize(t.angular),a={x:t.bounds.x+(t.bounds.width-s)/2,y:t.bounds.y+(t.bounds.height-r)/2,width:s,height:r};if(t.kind!=="polygon")return{...t,bounds:a};const o=t.bounds.width===0?1:s/t.bounds.width,c=t.bounds.height===0?1:r/t.bounds.height;return{...t,bounds:a,points:t.points.map(l=>({x:l.x*o,y:l.y*c}))}})}static reproject(e,t,n){const s=Zt.frameWidthPx(t,Kt.CANVAS_HEIGHT_PX)/2,r=Zt.frameWidthPx(e.instrument,Kt.CANVAS_HEIGHT_PX)/2,a=Kt.CANVAS_HEIGHT_PX/2;for(const o of[...e.timeline.allKeyframes]){const c=this.fovOf(e,o.t),l=n?.get(o.t)??c,h=Ys.of(t,Kt.CANVAS_HEIGHT_PX,l),u=Ys.of(e.instrument,Kt.CANVAS_HEIGHT_PX,c);e.timeline.addKeyframe(o.t,o.shapes.map(d=>{const{bounds:f}=d.shape,g=f.x+f.width/2-s,x=f.y+f.height/2-a,m=Math.hypot(g,x),p=m===0?1:u.angleDegToRadiusPx(h.radiusPxToAngleDeg(m))/m,A={...f,x:r+g*p-f.width/2,y:a+x*p-f.height/2};return{...d,shape:{...d.shape,bounds:A}}}))}this.toBounds(e)}static eachKeyframe(e,t){const{timeline:n}=e;for(const s of[...n.allKeyframes]){const r=this.fovOf(e,s.t),a=Ys.of(e.instrument,Kt.CANVAS_HEIGHT_PX,r);n.addKeyframe(s.t,s.shapes.map(o=>({...o,shape:t(o.shape,a)})))}}}function yp(i){return Dr.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,exposureSeconds:i.exposureSeconds}}function Ep(i){const e=new go({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},mo.fromJSON(i.timeline),i.witnessTrack?Nr.fromJSON(i.witnessTrack):new Nr,i.weatherTrack?Ur.fromJSON(i.weatherTrack):new Ur,i.soundTrack?Or.fromJSON(i.soundTrack):new Or,i.witness,i.caseId,i.weather,i.decor??[],i.weatherSource,i.instrument,i.exposureSeconds??i.witnessTrack?.keyframes.map(t=>t.pose.exposureSeconds).find(t=>t!==void 0));return Dr.toBounds(e),e}function jl(i,e){for(const t of i){const n=t.toLowerCase().split("-")[0];if(e.includes(n))return n}return"en"}class s0{static preferencesFor(e){const t=navigator.languages??[],n=e.closest("[lang]")?.getAttribute("lang")?.trim();return n?[n,...t]:t}}const Ap="modulepreload",bp=function(i,e){return new URL(i,e).href},Wh={},Xh=function(e,t,n){let s=Promise.resolve();if(t&&t.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(t.map(h=>{if(h=bp(h,n),h in Wh)return;Wh[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":Ap,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 e().catch(r)})},Tp=["en","fr"],wp={en:()=>Xh(()=>Promise.resolve().then(()=>Dp),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 Rp(i){return wp[i]()}const r0={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"},Dp=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:r0},Symbol.toStringTag,{value:"Module"})),qh=new Set;class Ji extends HTMLElement{static get observedAttributes(){return["src"]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;loopButton;fullscreenButton;seekInput;timeStartLabel;timeEndLabel;currentSighting=go.create();sightingAudio=new Sp;soundPreview;player;loopEnabled=!0;playbackBeforeClick;highlightedSourceIds=new Set;occludedSourceIds=qh;enableClickToPlay=!0;fullscreenTarget;messages=r0;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>this.updateFullscreenButton();handlePointerMove=e=>{const t=this.canvasPointFromEvent(e),n=t&&this.shapeAt(t.x,t.y);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=`${e.clientX-s.left+12}px`,this.tooltip.style.top=`${e.clientY-s.top+12}px`};handlePointerLeave=()=>{this.tooltip.hidden=!0};constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${Vf}</style>${Gf}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new _p(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 t of[this.timeStartLabel,this.timeEndLabel])t.addEventListener("click",()=>this.toggleTimeDisplay()),t.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",t=>{this.enableClickToPlay&&(t.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause())}),this.canvas.addEventListener("dblclick",t=>{this.enableClickToPlay&&(t.preventDefault(),this.restorePlayback(),this.toggleFullscreen())}),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 e=this.getAttribute("src");e&&this.loadFromSrc(e)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sightingAudio.dispose()}attributeChangedCallback(e,t,n){e==="src"&&n&&n!==t&&this.isConnected&&this.loadFromSrc(n)}async loadFromSrc(e){this.sightingData=await e0.json(e)}get sightingData(){return yp(this.currentSighting)}set sightingData(e){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=Ep(e),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh()}get sighting(){return this.currentSighting}previewSound(e){this.soundPreview=e,this.sightingAudio.resume(),this.sightingAudio.setSound(e)}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(e){this.player.seek(e)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(e){e!==this.loopEnabled&&this.toggleLoop()}play(){this.player.seekableDuration<=0||this.playbackState==="playing"||this.togglePlayPause()}pause(){this.playbackState==="playing"&&this.togglePlayPause()}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(e){this.toolbar.classList.toggle("hidden",!e)}get playbackState(){return this.player.playbackState}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(e){this.currentSighting.event.durationSeconds=e,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(e){const t=new Set(e);t.size===this.highlightedSourceIds.size&&[...t].every(s=>this.highlightedSourceIds.has(s))||(this.highlightedSourceIds=t,this.refresh())}setOccludedSourceIds(e){e.size===this.occludedSourceIds.size&&[...e].every(n=>this.occludedSourceIds.has(n))||(this.occludedSourceIds=e,this.refresh())}hasVisibleShapeAt(e,t){return this.shapeAt(e,t)!==void 0}refresh(){this.applyFrameFormat(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.player.seek(this.player.time)}exposureInstants(e){const t=this.exposureTimes(e),n=1/t.length;return t.map(s=>({shapes:this.shapesAt(s),share:n}))}exposureTimes(e=this.currentTime){const t=(this.currentSighting.exposure??0)*1e3;if(t<Ji.SHORTEST_VISIBLE_EXPOSURE_MS)return[e];const n=Math.min(Ji.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(t/Ji.SHORTEST_VISIBLE_EXPOSURE_MS))),s=Math.ceil(this.travelPxOver(e,t)/Ji.EXPOSURE_STEP_PX),r=Math.min(Ji.MAX_TRAVEL_STEPS,Math.max(n,s)),a=[];for(let o=0;o<r;o++)a.push(e+t*o/r);return a}travelPxOver(e,t){const n=this.shapesAt(e),s=this.shapesAt(e+t);let r=0;for(const[a,o]of n){const c=s.get(a);if(!c)continue;const l=c.bounds.x+c.bounds.width/2-(o.bounds.x+o.bounds.width/2),h=c.bounds.y+c.bounds.height/2-(o.bounds.y+o.bounds.height/2);r=Math.max(r,Math.hypot(l,h))}return r}shapeAt(e,t,n=this.occludedSourceIds){for(const s of this.exposureTimes()){const r=this.currentSighting.timeline.hitTest(s,e,t,n);if(r)return r}}shapesAt(e){const t=new Map;for(const n of this.currentSighting.timeline.sourceIds){const s=this.currentSighting.timeline.getInterpolatedShapeAt(e,n);s&&t.set(n,s)}return t}static SHORTEST_VISIBLE_EXPOSURE_MS=20;static MAX_EXPOSURE_STEPS=48;static EXPOSURE_STEP_PX=2;static MAX_TRAVEL_STEPS=320;applyFrameFormat(){const e=Zt.frameWidthPx(this.currentSighting.instrument,this.canvas.height);if(this.canvas.width===e)return;this.canvas.width=e,this.canvas.parentElement?.style.setProperty("--frame-aspect",`${e} / ${this.canvas.height}`)}canvasPointFromEvent(e){const t=this.canvas.getBoundingClientRect();if(!(t.width===0||t.height===0))return{x:(e.clientX-t.left)/t.width*this.canvas.width,y:(e.clientY-t.top)/t.height*this.canvas.height}}onFrame(e,t){this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const n=this.playbackState!=="playing"?this.highlightedSourceIds:qh;this.canvasRenderer.setStarPoints(Zt.starPointsOf(this.sighting.instrument)),this.canvasRenderer.setRoll((Vs(this.sighting,e)?.rollDeg??0)*Math.PI/180);const s=this.exposureInstants(e);for(const r of s)for(const[a,o]of r.shapes){if(this.occludedSourceIds.has(a))continue;const c=r.share,l=c===1?o:{...o,transparency:1-(1-o.transparency)*c};this.canvasRenderer.paintShape(l)}for(const[r,a]of s[0].shapes)this.occludedSourceIds.has(r)||!n.has(r)||(n.size===1?this.canvasRenderer.paintShape({...a,selected:!0}):this.canvasRenderer.paintMemberOutline(a));if(n.size>1){const r=vn.groupBoundsFor([...t].filter(([a])=>n.has(a)).map(([,a])=>a.bounds));this.canvasRenderer.paintGroupHandles(r)}this.seekInput.value=String(e),this.timeStartLabel.textContent=this.formatPosition(e),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(cp(this.currentSighting,e))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:e}}))}createPlayer(){const e=new lp(this.currentSighting.timeline,(t,n)=>this.onFrame(t,n));return e.loop=this.loopEnabled,e.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},e}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 e=this.player.playbackState==="playing";this.playPauseButton.textContent=e?"⏸":"▶";const t=this.player.seekableDuration>0;this.playPauseButton.disabled=!t;const n=t?e?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",e),this.fullscreenButton.classList.toggle("auto-hide",e)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.loopButton.setAttribute("aria-pressed",String(this.loopEnabled)),this.player.loop=this.loopEnabled}restorePlayback(){const e=this.playbackBeforeClick;e&&(this.currentTime=e.time,e.state==="playing"?this.play():this.pause())}toggleFullscreen(){document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(e=>{console.error("<rr0-ufo>: requestFullscreen() failed —",e)})}updateFullscreenButton(){const e=document.fullscreenElement===this.fullscreenTarget;this.fullscreenButton.title=e?this.messages.exitFullscreen:this.messages.fullscreen,this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}async loadLocaleMessages(){const e=jl(s0.preferencesFor(this),Tp);e!=="en"&&this.applyMessages(await Rp(e))}updateTimeLabelTitles(){const e=this.showClockTime?this.messages.switchToElapsed:this.messages.switchToClockTime,t=this.canSwitchTimeDisplay?` — ${e}`:"";this.timeStartLabel.title=this.messages.currentPosition+t,this.timeEndLabel.title=this.messages.duration+t;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(e){this.messages=e,this.updateTimeLabelTitles(),this.loopButton.title=e.autoReplay,this.loopButton.setAttribute("aria-label",e.autoReplay),this.updatePlayPauseButton(),this.updateFullscreenButton()}updateTimeLabels(){const e=this.currentSighting.event,t=rp(e);this.realDurationMs=t!==void 0&&t>0?t:void 0,this.realStartMs=e.time?Lc(e.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(e){if(this.realDurationMs===void 0)return Qr(e);const t=this.currentSighting.timeline.duration,n=t>0&&e<=t?e/t*this.realDurationMs:e;return this.canShowClockTime?Kh(Yh(this.realStartMs+n)):Qr(n)}formatEndOfTimeline(){return this.realDurationMs===void 0?Qr(this.currentSighting.timeline.duration):this.canShowClockTime?Kh(Yh(this.realStartMs+this.realDurationMs)):Qr(this.realDurationMs)}}function Yh(i){const e=new Date(i);return{hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds()}}function Kh(i){if(i.hour===void 0)return"0:00";const e=t=>String(t).padStart(2,"0");return i.second?`${e(i.hour)}:${e(i.minute??0)}:${e(i.second)}`:`${e(i.hour)}:${e(i.minute??0)}`}function Qr(i){const e=Math.round(i/1e3),t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,"0")}`}const Uc="rr0-ufo";function a0(){customElements.get(Uc)||customElements.define(Uc,Ji)}/**
329
+ `,pa=[{id:"eye",name:{en:"Naked eye",fr:"Œil nu"},flare:0,projection:"equidistant"},{id:"rectilinear-lens",name:{en:"Camera, unknown device",fr:"Appareil, modèle inconnu"},projection:"rectilinear",fNumber:8,fNumberRange:{min:2,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:8},apertureBlades:6},{id:"instamatic-126",name:{en:"Instamatic, 126 film",fr:"Instamatic, film 126"},projection:"rectilinear",frame:{widthMm:28,heightMm:28,focalLengthMm:43},fNumber:11,exposureSeconds:1/90,years:{from:1963,to:1988},apertureBlades:5},{id:"slr-35mm-50",name:{en:"35 mm SLR, 50 mm lens",fr:"Reflex 35 mm, objectif 50 mm"},projection:"rectilinear",frame:{widthMm:36,heightMm:24,focalLengthMm:50},fNumber:8,fNumberRange:{min:2,max:16},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:3600},years:{from:1959},apertureBlades:6},{id:"slr-35mm-zoom",name:{en:"35 mm SLR, 70-210 mm zoom",fr:"Reflex 35 mm, zoom 70-210 mm"},projection:"rectilinear",frame:{widthMm:36,heightMm:24,focalLengthMm:135,focalRangeMm:{minMm:70,maxMm:210}},fNumber:8,fNumberRange:{min:4,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:3600},apertureBlades:8,years:{from:1975}},{id:"phone-landscape",name:{en:"Phone, held sideways",fr:"Téléphone, tenu couché"},projection:"rectilinear",frame:{widthMm:7.6,heightMm:5.7,focalLengthMm:5.7},exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0},{id:"phone-portrait",name:{en:"Phone, held upright",fr:"Téléphone, tenu debout"},projection:"rectilinear",frame:{widthMm:5.7,heightMm:7.6,focalLengthMm:5.7},exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0}];class Jt{static get default(){return pa[0]}static byId(e){return pa.find(t=>t.id===e)??this.default}static UNAIDED_FIELD_DEG=60;static UNAIDED_ASPECT=16/9;static fieldOfViewDeg(e){const t=e.frame;return t?2*Math.atan(t.heightMm/(2*t.focalLengthMm))*180/Math.PI:Jt.UNAIDED_FIELD_DEG}static aspectOf(e){const t=e.frame;return t?t.widthMm/t.heightMm:Jt.UNAIDED_ASPECT}static frameWidthPx(e,t){return Math.round(t*Jt.aspectOf(e))}static availableAt(e){return e===void 0?pa:pa.filter(t=>!t.years||e>=t.years.from&&(t.years.to===void 0||e<=t.years.to))}static fieldOfViewDegAt(e,t){const n=e.frame;if(!(!n||t<=0))return 2*Math.atan(n.heightMm/(2*t))*180/Math.PI}static focalLengthMmFor(e,t){const n=e.frame;if(!(!n||t<=0||t>=180))return n.heightMm/(2*Math.tan(t*Math.PI/360))}static bladesShowing(e,t){const n=t??e.fNumber;if(n===void 0||e.apertureBlades===void 0)return 0;const s=e.fNumberRange;return!s||s.max<=s.min?1:Math.max(0,Math.min(1,(n-s.min)/(s.max-s.min)))}static LENS_FLARE_ARTIFACTS=1;static flareArtifactsOf(e){return e.flare??Jt.LENS_FLARE_ARTIFACTS}static starPointsOf(e){const t=e.apertureBlades;return t===void 0||t<3?0:t%2===0?t:t*2}}class Zt{static MOON_ANGULAR_WIDTH_DEG=.5237;static CANVAS_WIDTH_PX=640;static CANVAS_HEIGHT_PX=360;static angularWidthDeg(e){return 2*Math.atan(e.sizeM/(2*e.distanceM))*180/Math.PI}static inMoons(e){return e/Zt.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(e,t,n){if(!(!e||!t))return{widthDeg:e.widthDeg+(t.widthDeg-e.widthDeg)*n,heightDeg:e.heightDeg+(t.heightDeg-e.heightDeg)*n}}static sizeMAt(e,t){return 2*e*Math.tan(t*Math.PI/360)}static distanceMAt(e,t){return e/(2*Math.tan(t*Math.PI/360))}}function sm(i,e,t){const{bounds:n}=i;return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function hn(i,e,t){return i+(e-i)*t}function Mu(i){const e=/^#([0-9a-f]{6})$/i.exec(i);if(!e)return;const t=parseInt(e[1],16);return[t>>16&255,t>>8&255,t&255]}function rm(i){return`#${i.map(e=>Math.round(e).toString(16).padStart(2,"0")).join("")}`}function am(i,e,t){const n=Mu(i),s=Mu(e);return!n||!s?t<1?i:e:rm([hn(n[0],s[0],t),hn(n[1],s[1],t),hn(n[2],s[2],t)])}function om(i,e,t){const n={x:hn(i.bounds.x,e.bounds.x,t),y:hn(i.bounds.y,e.bounds.y,t),width:hn(i.bounds.width,e.bounds.width,t),height:hn(i.bounds.height,e.bounds.height,t)},s=hn(i.angle,e.angle,t),r=hn(i.transparency,e.transparency,t),a=hn(i.haloScale,e.haloScale,t),o=hn(i.blur??0,e.blur??0,t),c=hn(i.brightness??0,e.brightness??0,t),l=am(i.color,e.color,t),h=Zt.lerpAngular(i.angular,e.angular,t);return i.kind==="polygon"&&e.kind==="polygon"&&i.points.length===e.points.length?{...i,bounds:n,angle:s,transparency:r,haloScale:a,blur:o,brightness:c,color:l,angular:h,behindCloud:t<1?i.behindCloud:e.behindCloud,points:i.points.map((u,d)=>({x:hn(u.x,e.points[d].x,t),y:hn(u.y,e.points[d].y,t)}))}:{...t<1?i:e,bounds:n,angle:s,transparency:r,haloScale:a,blur:o,brightness:c,color:l,angular:h}}class Wo{keyframes=[];order=[];groups=[];addKeyframe(e,t){const n=this.findInsertIndex(e);if(this.keyframes[n]?.t===e){const s=new Set(t.map(r=>r.sourceId));this.keyframes[n]={t:e,shapes:[...this.keyframes[n].shapes.filter(r=>!s.has(r.sourceId)),...t]}}else this.keyframes.splice(n,0,{t:e,shapes:[...t]});for(const s of t)this.order.includes(s.sourceId)||this.order.push(s.sourceId)}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const s=t+n>>>1;this.keyframes[s].t<e?t=s+1:n=s}return t}getKeyframeAt(e){const t=this.findInsertIndex(e),n=this.keyframes[t];return n?.t===e?n:void 0}getShapeAt(e,t){return this.getKeyframeAt(e)?.shapes.find(n=>n.sourceId===t)?.shape}getLatestShapeAt(e,t){let n=this.findInsertIndex(e);for(this.keyframes[n]?.t!==e&&(n-=1);n>=0;n--){const s=this.keyframes[n].shapes.find(r=>r.sourceId===t);if(s)return s.shape}}getInterpolatedShapeAt(e,t){const n=this.findShapeAtOrBefore(e,t);if(n?.t===e)return n.shape;const s=this.findShapeAtOrAfter(e,t);return n?s?om(n.shape,s.shape,(e-n.t)/(s.t-n.t)):n.shape:s?.shape}findShapeAtOrBefore(e,t){let n=this.findInsertIndex(e);for(this.keyframes[n]?.t!==e&&(n-=1);n>=0;n--){const s=this.keyframes[n].shapes.find(r=>r.sourceId===t);if(s)return{t:this.keyframes[n].t,shape:s.shape}}}findShapeAtOrAfter(e,t){for(let n=this.findInsertIndex(e);n<this.keyframes.length;n++){const s=this.keyframes[n].shapes.find(r=>r.sourceId===t);if(s)return{t:this.keyframes[n].t,shape:s.shape}}}hitTest(e,t,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(e,r[a]);if(o&&sm(o,t,n))return{sourceId:r[a],shape:o}}}removeSource(e){for(let t=this.keyframes.length-1;t>=0;t--){const n=this.keyframes[t].shapes.filter(s=>s.sourceId!==e);n.length===0?this.keyframes.splice(t,1):n.length!==this.keyframes[t].shapes.length&&(this.keyframes[t]={t:this.keyframes[t].t,shapes:n})}this.order=this.order.filter(t=>t!==e),this.removeFromGroup(e)}group(e){if(!(e.length<2)){for(const t of e)this.removeFromGroup(t);this.groups.push([...e])}}ungroup(e){const t=this.groups.findIndex(n=>n.includes(e));t!==-1&&this.groups.splice(t,1)}groupMembers(e){return this.groups.find(t=>t.includes(e))}removeFromGroup(e){const t=this.groups.findIndex(s=>s.includes(e));if(t===-1)return;const n=this.groups[t].filter(s=>s!==e);n.length<2?this.groups.splice(t,1):this.groups[t]=n}bringToFront(e){const t=this.order.indexOf(e);t!==-1&&(this.order.splice(t,1),this.order.push(e))}sendToBack(e){const t=this.order.indexOf(e);t!==-1&&(this.order.splice(t,1),this.order.unshift(e))}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(e){const t=new Wo;for(const n of e.keyframes)t.addKeyframe(n.t,n.shapes);if(e.order){const n=t.order.filter(s=>!e.order.includes(s));t.order=[...e.order,...n]}return e.groups&&(t.groups=e.groups.map(n=>n.filter(s=>t.order.includes(s))).filter(n=>n.length>=2)),t}}function cm(i,e,t){return Math.max(e,Math.min(t,i))}function lm(i,e,t){const n=((e-i)%360+540)%360-180;return((i+n*t)%360+360)%360}function ws(i,e,t){return i+(e-i)*t}function hm(i,e,t){return{lat:i.lat===void 0||e.lat===void 0?void 0:ws(i.lat,e.lat,t),lng:i.lng===void 0||e.lng===void 0?void 0:ws(i.lng,e.lng,t),elevationM:ws(i.elevationM,e.elevationM,t),headingDeg:i.headingDeg===void 0||e.headingDeg===void 0?void 0:lm(i.headingDeg,e.headingDeg,t),pitchDeg:ws(i.pitchDeg,e.pitchDeg,t),rollDeg:ws(i.rollDeg??0,e.rollDeg??0,t),fovDeg:ws(i.fovDeg,e.fovDeg,t),fNumber:i.fNumber,focusDistanceM:i.focusDistanceM}}class Qr{keyframes=[];addKeyframe(e,t){const n=this.findInsertIndex(e);this.keyframes[n]?.t===e?this.keyframes[n]={t:e,pose:t}:this.keyframes.splice(n,0,{t:e,pose:t})}clear(){this.keyframes.length=0}removeKeyframeAt(e){const t=this.findInsertIndex(e);this.keyframes[t]?.t===e&&this.keyframes.splice(t,1)}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const s=t+n>>>1;this.keyframes[s].t<e?t=s+1:n=s}return t}getLatestPoseAt(e){let t=this.findInsertIndex(e);return this.keyframes[t]?.t!==e&&(t-=1),t>=0?this.keyframes[t].pose:void 0}getInterpolatedPoseAt(e){const t=this.findInsertIndex(e),n=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(n?.t===e)return n.pose;const s=this.keyframes[t]?.t===e?void 0:this.keyframes[t];return n?s?hm(n.pose,s.pose,cm((e-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(e){const t=new Qr;for(const n of e.keyframes)t.addKeyframe(n.t,n.pose);return t}}function Ci(i,e,t){return i+(e-i)*t}function um(i,e,t){const n=((e-i)%360+540)%360-180;return((i+n*t)%360+360)%360}function dm(i,e,t){return Math.max(e,Math.min(t,i))}function fm(i,e,t){return{cloudCover:Ci(i.cloudCover,e.cloudCover,t),cloudDarkness:Ci(i.cloudDarkness,e.cloudDarkness,t),highCloudCover:i.highCloudCover===void 0||e.highCloudCover===void 0?void 0:Ci(i.highCloudCover,e.highCloudCover,t),iceCrystalAlignment:i.iceCrystalAlignment===void 0||e.iceCrystalAlignment===void 0?void 0:Ci(i.iceCrystalAlignment,e.iceCrystalAlignment,t),lowerCloudCover:i.lowerCloudCover===void 0||e.lowerCloudCover===void 0?void 0:Ci(i.lowerCloudCover,e.lowerCloudCover,t),cloudBaseM:i.cloudBaseM===void 0||e.cloudBaseM===void 0?void 0:Ci(i.cloudBaseM,e.cloudBaseM,t),precipitationType:t<1?i.precipitationType:e.precipitationType,precipitationIntensity:Ci(i.precipitationIntensity,e.precipitationIntensity,t),windDirectionDeg:um(i.windDirectionDeg,e.windDirectionDeg,t),windSpeed:Ci(i.windSpeed,e.windSpeed,t),storm:t<1?i.storm:e.storm}}class jr{keyframes=[];addKeyframe(e,t){const n=this.findInsertIndex(e);this.keyframes[n]?.t===e?this.keyframes[n]={t:e,weather:t}:this.keyframes.splice(n,0,{t:e,weather:t})}clear(){this.keyframes.length=0}removeKeyframeAt(e){const t=this.findInsertIndex(e);this.keyframes[t]?.t===e&&this.keyframes.splice(t,1)}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const s=t+n>>>1;this.keyframes[s].t<e?t=s+1:n=s}return t}getLatestWeatherAt(e){let t=this.findInsertIndex(e);return this.keyframes[t]?.t!==e&&(t-=1),t>=0?this.keyframes[t].weather:void 0}getInterpolatedWeatherAt(e){const t=this.findInsertIndex(e),n=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(n?.t===e)return n.weather;const s=this.keyframes[t]?.t===e?void 0:this.keyframes[t];return n?s?fm(n.weather,s.weather,dm((e-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(e){const t=new jr;for(const n of e.keyframes)t.addKeyframe(n.t,n.weather);return t}}class ea{keyframes=[];addKeyframe(e,t){const n=this.findInsertIndex(e);this.keyframes[n]?.t===e?this.keyframes[n]={t:e,sound:t}:this.keyframes.splice(n,0,{t:e,sound:t})}clear(){this.keyframes.length=0}removeKeyframeAt(e){const t=this.findInsertIndex(e);this.keyframes[t]?.t===e&&this.keyframes.splice(t,1)}getLatestSoundAt(e){let t=this.findInsertIndex(e);return this.keyframes[t]?.t!==e&&(t-=1),t>=0?this.keyframes[t].sound:void 0}getInterpolatedSoundAt(e){const t=this.findInsertIndex(e),n=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(n?.t===e)return n.sound;const s=this.keyframes[t]?.t===e?void 0:this.keyframes[t];if(!n)return s?.sound;if(!s)return n.sound;const r=(e-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(e){const t=new ea;for(const n of e.keyframes)t.addKeyframe(n.t,n.sound);return t}lerp(e,t,n){return{kind:n<1?e.kind:t.kind,volume:e.volume+(t.volume-e.volume)*n,pitchHz:e.pitchHz+(t.pitchHz-e.pitchHz)*n,src:n<1?e.src:t.src}}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const s=t+n>>>1;this.keyframes[s].t<e?t=s+1:n=s}return t}}const pf=1e3,pm=.65,mf={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,storm:!1},mm=100,gm={kind:"none",volume:0,pitchHz:mm};function fl(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 yu(i){return(((i.day??0)*24+(i.hour??0))*60+(i.minute??0))*6e4+(i.second??0)*1e3}const vm=["year","month","day","hour","minute"],_m=["day","hour","minute"];function Su(i,e){return e.filter(t=>i[t]!==void 0).join(",")}function xm(i){if(i.durationSeconds!==void 0)return i.durationSeconds*1e3;if(!i.time||!i.endTime)return;const e=i.time.year!==void 0&&i.endTime.year!==void 0,t=e?vm:_m,n=Su(i.time,t);if(!(n===""||n!==Su(i.endTime,t)))return e?fl(i.endTime)-fl(i.time):yu(i.endTime)-yu(i.time)}class Xo{constructor(e,t,n,s,r,a,o,c,l=[],h,u,d){this.event=e,this.timeline=t,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,this.exposureSeconds=d}get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return Jt.byId(this.instrumentId)}static create(e,t,n){return new Xo({eventType:"sighting",time:e,place:t},new Wo,new Qr,new jr,new ea,n)}}const Mm=0,ym=0;function Qs(i,e){const t=i.witnessTrack.getInterpolatedPoseAt(e);if(t)return t;const n=i.event.place?.[0];if(n)return{lat:n.lat,lng:n.lng,elevationM:Mm,headingDeg:void 0,pitchDeg:ym,fovDeg:Jt.fieldOfViewDeg(i.instrument)}}function Eu(i,e){return i.weatherTrack.getInterpolatedWeatherAt(e)??i.weather??mf}function Sm(i,e){return i.soundTrack.getInterpolatedSoundAt(e)??gm}class Em{constructor(e,t){this.timeline=e,this.onFrame=t}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;onEnded;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 e=()=>{if(this.state!=="playing")return;const t=performance.now();if(this.currentT+=(t-this.lastWallTime)*this.playbackRate,this.lastWallTime=t,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(e);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT),this.onEnded?.();return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(e)};this.rafId=requestAnimationFrame(e)}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(e){this.currentT=Math.max(0,Math.min(e,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(e){const t=new Map;for(const n of this.timeline.sourceIds){const s=this.timeline.getInterpolatedShapeAt(e,n);s&&t.set(n,s)}this.onFrame(e,t)}}const gf=["nw","n","ne","e","se","s","sw","w"],bm=24,ma=8,Am=3,wm=8;function ga(i,e,t){const n=i.x-e.x,s=i.y-e.y,r=Math.cos(t),a=Math.sin(t);return{x:e.x+n*r-s*a,y:e.y+n*a+s*r}}function yr(i){return{x:i.x+i.width/2,y:i.y+i.height/2}}const Tm={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 Mn{static handlePointsFor(e){const{x:t,y:n,width:s,height:r}=e.bounds,a={nw:{x:t,y:n},n:{x:t+s/2,y:n},ne:{x:t+s,y:n},e:{x:t+s,y:n+r/2},se:{x:t+s,y:n+r},s:{x:t+s/2,y:n+r},sw:{x:t,y:n+r},w:{x:t,y:n+r/2},rotate:{x:t+s/2,y:n-bm}},o=yr(e.bounds),c={};for(const l of Object.keys(a))c[l]=ga(a[l],o,e.angle);return c}static hitTestHandle(e,t,n=8,s=[...gf,"rotate"]){const r=Mn.handlePointsFor(e);for(const a of s)if(Math.hypot(t.x-r[a].x,t.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(e,t){const s=((Mn.HANDLE_DIRECTION_DEG[e]+t*180/Math.PI)%180+180)%180/45,r=["ew","nwse","ns","nesw"];return r[Math.round(s)%r.length]}static resizeBounds(e,t,n,s){const r=yr(e),a=ga(s,r,-t),{x:o,y:c,width:l,height:h}=e,u=Tm[n];let d=o,f=c,g=o+l,x=c+h;return u.left&&(d=Math.min(a.x,g-ma)),u.right&&(g=Math.max(a.x,d+ma)),u.top&&(f=Math.min(a.y,x-ma)),u.bottom&&(x=Math.max(a.y,f+ma)),{x:d,y:f,width:g-d,height:x-f}}static resizeShape(e,t,n){if(t==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:s,height:r}=e.bounds,a=Mn.resizeBounds(e.bounds,e.angle,t,n);if(e.kind==="oval")return{...e,bounds:a};const o=s===0?1:a.width/s,c=r===0?1:a.height/r;return{...e,bounds:a,points:e.points.map(l=>({x:l.x*o,y:l.y*c}))}}static rotateShape(e,t){const n=yr(e.bounds),s=Math.atan2(t.y-n.y,t.x-n.x)+Math.PI/2;return{...e,angle:s}}static groupBoundsFor(e){const t=Math.min(...e.map(a=>a.x)),n=Math.min(...e.map(a=>a.y)),s=Math.max(...e.map(a=>a.x+a.width)),r=Math.max(...e.map(a=>a.y+a.height));return{x:t,y:n,width:s-t,height:r-n}}static vertexPointsFor(e){const t=yr(e.bounds);return e.points.map(n=>ga({x:e.bounds.x+n.x,y:e.bounds.y+n.y},t,e.angle))}static hitTestVertex(e,t,n=wm){const s=Mn.vertexPointsFor(e);let r,a=n;return s.forEach((o,c)=>{const l=Math.hypot(t.x-o.x,t.y-o.y);l<=a&&(a=l,r=c)}),r}static toLocalPoint(e,t){const n=yr(e.bounds),s=ga(t,n,-e.angle);return{x:s.x-e.bounds.x,y:s.y-e.bounds.y}}static moveVertex(e,t,n){const s=e.points.map((u,d)=>d===t?Mn.toLocalPoint(e,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:e.bounds.x+r,y:e.bounds.y+a,width:o-r,height:c-a},h=s.map(u=>({x:u.x-r,y:u.y-a}));return{...e,bounds:l,points:h}}static insertVertexNear(e,t){const n=Mn.toLocalPoint(e,t),{points:s}=e;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=Mn.distanceToSegment(n,l,h);u<a&&(a=u,r=c)}const o=[...s.slice(0,r+1),n,...s.slice(r+1)];return{...e,points:o}}static distanceToSegment(e,t,n){const s=n.x-t.x,r=n.y-t.y,a=s*s+r*r,o=a===0?0:Math.max(0,Math.min(1,((e.x-t.x)*s+(e.y-t.y)*r)/a)),c=t.x+o*s,l=t.y+o*r;return Math.hypot(e.x-c,e.y-l)}static deleteVertex(e,t){return e.points.length<=Am?e:{...e,points:e.points.filter((n,s)=>s!==t)}}}const pl=6,va=pl/2,Rm=20,Dm=24,Cm=9,bu=6,Pm=7,Au=4;class Im{constructor(e){this.ctx=e}starPoints=0;roll=0;clear(e,t){this.ctx.clearRect(0,0,e,t)}paintShape(e){this.ctx.save(),this.ctx.globalAlpha=1-e.transparency;const t=e.blur??0;t>0&&(this.ctx.filter=`blur(${(Dm*t).toFixed(2)}px)`);const n=e.brightness??0;n>0&&this.paintDazzle(e,n),e.haloScale>0&&this.paintHalo(e),this.paintBase(e),this.ctx.restore(),e.selected&&this.paintSelectionHandles(e)}setStarPoints(e){this.starPoints=Math.max(0,Math.floor(e))}setRoll(e){this.roll=e}paintDazzle(e,t){const{x:n,y:s,width:r,height:a}=e.bounds,o=n+r/2,c=s+a/2,l=Math.max(r,a)/2,h=l*(1+Cm*t);if(h<=0)return;this.ctx.save(),this.ctx.globalCompositeOperation="lighter";const u=this.ctx.createRadialGradient(o,c,0,o,c,h);for(let d=0;d<=bu;d++){const f=d/bu,g=1/(1+24*f*f);this.ctx.globalAlpha=1,u.addColorStop(f,this.withAlpha(e.color,g*t*.55))}if(this.ctx.fillStyle=u,this.ctx.beginPath(),this.ctx.arc(o,c,h,0,2*Math.PI),this.ctx.fill(),this.starPoints>0){const d=l*(1+Pm*t);this.ctx.lineWidth=Math.max(1,l*.12),this.ctx.lineCap="round";for(let f=0;f<this.starPoints;f++){const g=f/this.starPoints*Math.PI*2+this.roll,x=o+Math.cos(g)*d,m=c+Math.sin(g)*d,p=this.ctx.createLinearGradient(o,c,x,m);p.addColorStop(0,this.withAlpha(e.color,t*.55)),p.addColorStop(.35,this.withAlpha(e.color,t*.22)),p.addColorStop(1,this.withAlpha(e.color,0)),this.ctx.strokeStyle=p,this.ctx.beginPath(),this.ctx.moveTo(o,c),this.ctx.lineTo(x,m),this.ctx.stroke()}}this.ctx.restore()}dazzledFill(e,t){if(t<=0)return e.color;const n=/^#([0-9a-f]{6})$/i.exec(e.color.trim());if(!n)return e.color;const s=Number.parseInt(n[1],16),r=a=>Math.round(a+(255-a)*t);return`rgb(${r(s>>16&255)}, ${r(s>>8&255)}, ${r(s&255)})`}withAlpha(e,t){const n=Math.max(0,Math.min(1,t)),s=/^#([0-9a-f]{6})$/i.exec(e.trim());if(!s)return e;const r=Number.parseInt(s[1],16);return`rgba(${r>>16&255}, ${r>>8&255}, ${r&255}, ${n.toFixed(3)})`}paintBase(e){if(this.ctx.fillStyle=this.dazzledFill(e,e.brightness??0),this.ctx.beginPath(),e.kind==="oval"){const{x:t,y:n,width:s,height:r}=e.bounds,a=s/2,o=r/2;this.ctx.ellipse(t+a,n+o,a,o,e.angle,0,2*Math.PI)}else{const{x:t,y:n,width:s,height:r}=e.bounds;this.ctx.save(),this.ctx.translate(t+s/2,n+r/2),this.ctx.rotate(e.angle),this.ctx.translate(-s/2,-r/2),e.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(e){this.ctx.save(),this.ctx.shadowColor=e.color,this.ctx.shadowBlur=Rm*e.haloScale,this.paintBase(e),this.ctx.restore()}paintSelectionHandles(e){this.paintHandleFrame(Mn.handlePointsFor(e),{includeRotate:!0}),e.kind==="polygon"&&this.paintVertexHandles(e)}paintVertexHandles(e){this.ctx.fillStyle="#39f";for(const t of Mn.vertexPointsFor(e))this.ctx.beginPath(),this.ctx.ellipse(t.x,t.y,Au,Au,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(e){this.paintOutline(Mn.handlePointsFor(e))}paintGroupHandles(e){this.paintHandleFrame(Mn.handlePointsFor({bounds:e,angle:0}),{includeRotate:!0})}paintOutline(e){this.ctx.strokeStyle="lightgray",this.ctx.beginPath(),this.ctx.moveTo(e.nw.x,e.nw.y),this.ctx.lineTo(e.ne.x,e.ne.y),this.ctx.lineTo(e.se.x,e.se.y),this.ctx.lineTo(e.sw.x,e.sw.y),this.ctx.closePath(),this.ctx.stroke()}paintHandleFrame(e,{includeRotate:t}){this.paintOutline(e),this.ctx.fillStyle="lightgray";for(const n of gf){const s=e[n];this.ctx.fillRect(s.x-va,s.y-va,pl,pl)}t&&(this.ctx.beginPath(),this.ctx.moveTo(e.n.x,e.n.y),this.ctx.lineTo(e.rotate.x,e.rotate.y),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.ellipse(e.rotate.x,e.rotate.y,va+1,va+1,0,0,2*Math.PI),this.ctx.fill())}}const wu=.05,Tu=.08,Ru=2,Du=3,Lm=14,Nm=.02;class Um{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(e){console.warn("SightingAudio: Web Audio unavailable, the sighting stays silent:",e);return}}this.context.state==="suspended"&&this.context.resume()}setSound(e){if(this.requested=e,!this.context)return;const t=this.keyFor(e);if(!t){this.silence();return}if(this.voice?.key!==t){this.stopVoice();const n=++this.voiceToken;t.startsWith("src:")?this.buildRecordedVoice(e.src,t,n):this.voice=this.buildSynthesizedVoice(e,t)}this.applyTo(this.voice,e)}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(e){if(!(e.volume<=0))return e.src?`src:${e.src}`:e.kind==="none"?void 0:e.kind}applyTo(e,t){const n=this.context;if(!e||!n)return;const s=n.currentTime;e.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,t.volume))*e.gainScale,s,wu);for(const{param:r,ratio:a}of e.pitch)r.setTargetAtTime(Math.min(t.pitchHz*a,n.sampleRate/2-1),s,wu)}buildSynthesizedVoice(e,t){const n=this.context;if(n)switch(e.kind){case"hum":return this.buildHum(n,t);case"whistle":return this.buildWhistle(n,t);case"rumble":return this.buildRumble(n,t);case"crackle":return this.buildCrackle(n,t);default:return}}buildHum(e,t){const n=e.createOscillator();n.type="sawtooth";const s=e.createOscillator();s.type="sawtooth";const r=e.createBiquadFilter();r.type="lowpass",r.Q.value=1;const a=e.createGain();return a.gain.value=0,n.connect(r),s.connect(r),r.connect(a).connect(e.destination),n.start(),s.start(),{key:t,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(e,t){const n=e.createOscillator();n.type="sine";const s=e.createOscillator();s.type="sine",s.frequency.value=5;const r=e.createGain(),a=e.createGain();return a.gain.value=0,s.connect(r).connect(n.frequency),n.connect(a).connect(e.destination),n.start(),s.start(),{key:t,nodes:[r,a],sources:[n,s],volumeParam:a.gain,gainScale:.22,pitch:[{param:n.frequency,ratio:1},{param:r.gain,ratio:.012}]}}buildRumble(e,t){const n=e.createBufferSource();n.buffer=this.brownNoise(e),n.loop=!0;const s=e.createBiquadFilter();s.type="lowpass",s.Q.value=.8;const r=e.createGain();return r.gain.value=0,n.connect(s).connect(r).connect(e.destination),n.start(),{key:t,nodes:[s,r],sources:[n],volumeParam:r.gain,gainScale:1.4,pitch:[{param:s.frequency,ratio:1}]}}buildCrackle(e,t){const n=e.createBufferSource();n.buffer=this.whiteNoise(e),n.loop=!0;const s=e.createBiquadFilter();s.type="bandpass",s.Q.value=1.2;const r=e.createGain();r.gain.value=0;const a=e.createBufferSource();a.buffer=this.crackleEnvelope(e),a.loop=!0;const o=e.createGain();return o.gain.value=0,a.connect(o).connect(r.gain),n.connect(s).connect(r).connect(e.destination),n.start(),a.start(),{key:t,nodes:[s,r,o],sources:[n,a],volumeParam:o.gain,gainScale:.9,pitch:[{param:s.frequency,ratio:4}]}}async buildRecordedVoice(e,t,n){const s=this.context;if(!s)return;let r;try{r=await this.getBuffer(e)}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:t,nodes:[o],sources:[a],volumeParam:o.gain,gainScale:1,pitch:[]},this.requested&&this.applyTo(this.voice,this.requested)}async getBuffer(e){const t=this.context;if(!t)throw new Error("SightingAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(e);return n||(n=fetch(e).then(s=>{if(!s.ok)throw new Error(`Audio fetch failed (${s.status}): ${e}`);return s.arrayBuffer()}).then(s=>t.decodeAudioData(s)),this.buffers.set(e,n)),n}whiteNoise(e){if(!this.noiseBuffer){const t=e.createBuffer(1,Math.floor(e.sampleRate*Ru),e.sampleRate),n=t.getChannelData(0);for(let s=0;s<n.length;s++)n[s]=Math.random()*2-1;this.noiseBuffer=t}return this.noiseBuffer}brownNoise(e){const t=e.createBuffer(1,Math.floor(e.sampleRate*Ru),e.sampleRate),n=t.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 t}crackleEnvelope(e){if(!this.crackleBuffer){const t=e.createBuffer(1,Math.floor(e.sampleRate*Du),e.sampleRate),n=t.getChannelData(0),s=Math.max(1,Math.floor(Nm*e.sampleRate)),r=Math.round(Du*Lm);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=t}return this.crackleBuffer}stopVoice(){const e=this.voice,t=this.context;if(this.voice=void 0,!e||!t)return;const n=t.currentTime;e.volumeParam.cancelScheduledValues(n),e.volumeParam.setTargetAtTime(0,n,Tu/3);const s=n+Tu;for(const r of e.sources){r.onended=()=>{r.disconnect();for(const a of e.nodes)a.disconnect()};try{r.stop(s)}catch{r.disconnect();for(const a of e.nodes)a.disconnect()}}}}const ic=Math.PI/180,_a=180/Math.PI;class nr{constructor(e,t,n){this.kind=e,this.canvasHeightPx=t,this.fovDeg=n;const s=n*ic/2;this.focalPx=e==="equidistant"?t/2/s:t/2/Math.tan(s)}focalPx;static of(e,t,n){return new nr(e.projection,t,n)}degToPx(e){const t=e*ic;return this.kind==="equidistant"?this.focalPx*t:2*this.focalPx*Math.tan(t/2)}pxToDeg(e){return this.kind==="equidistant"?e/this.focalPx*_a:2*Math.atan(e/(2*this.focalPx))*_a}angleDegToRadiusPx(e){const t=e*ic;return this.kind==="equidistant"?this.focalPx*t:this.focalPx*Math.tan(t)}radiusPxToAngleDeg(e){return this.kind==="equidistant"?e/this.focalPx*_a:Math.atan(e/this.focalPx)*_a}ofBounds(e){return{widthDeg:this.pxToDeg(e.width),heightDeg:this.pxToDeg(e.height)}}toBoundsSize(e){return{width:this.degToPx(e.widthDeg),height:this.degToPx(e.heightDeg)}}widthPx(e){return this.degToPx(Zt.angularWidthDeg(e))}}class Xr{static fovOf(e,t){return Qs(e,t)?.fovDeg??Jt.fieldOfViewDeg(e.instrument)}static toAngular(e){this.eachKeyframe(e,(t,n)=>({...t,angular:n.ofBounds(t.bounds)}))}static toBounds(e){this.eachKeyframe(e,(t,n)=>{if(!t.angular)return t;const{width:s,height:r}=n.toBoundsSize(t.angular),a={x:t.bounds.x+(t.bounds.width-s)/2,y:t.bounds.y+(t.bounds.height-r)/2,width:s,height:r};if(t.kind!=="polygon")return{...t,bounds:a};const o=t.bounds.width===0?1:s/t.bounds.width,c=t.bounds.height===0?1:r/t.bounds.height;return{...t,bounds:a,points:t.points.map(l=>({x:l.x*o,y:l.y*c}))}})}static reproject(e,t,n){const s=Jt.frameWidthPx(t,Zt.CANVAS_HEIGHT_PX)/2,r=Jt.frameWidthPx(e.instrument,Zt.CANVAS_HEIGHT_PX)/2,a=Zt.CANVAS_HEIGHT_PX/2;for(const o of[...e.timeline.allKeyframes]){const c=this.fovOf(e,o.t),l=n?.get(o.t)??c,h=nr.of(t,Zt.CANVAS_HEIGHT_PX,l),u=nr.of(e.instrument,Zt.CANVAS_HEIGHT_PX,c);e.timeline.addKeyframe(o.t,o.shapes.map(d=>{const{bounds:f}=d.shape,g=f.x+f.width/2-s,x=f.y+f.height/2-a,m=Math.hypot(g,x),p=m===0?1:u.angleDegToRadiusPx(h.radiusPxToAngleDeg(m))/m,b={...f,x:r+g*p-f.width/2,y:a+x*p-f.height/2};return{...d,shape:{...d.shape,bounds:b}}}))}this.toBounds(e)}static eachKeyframe(e,t){const{timeline:n}=e;for(const s of[...n.allKeyframes]){const r=this.fovOf(e,s.t),a=nr.of(e.instrument,Zt.CANVAS_HEIGHT_PX,r);n.addKeyframe(s.t,s.shapes.map(o=>({...o,shape:t(o.shape,a)})))}}}function Om(i){return Xr.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,exposureSeconds:i.exposureSeconds}}function Fm(i){const e=new Xo({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},Wo.fromJSON(i.timeline),i.witnessTrack?Qr.fromJSON(i.witnessTrack):new Qr,i.weatherTrack?jr.fromJSON(i.weatherTrack):new jr,i.soundTrack?ea.fromJSON(i.soundTrack):new ea,i.witness,i.caseId,i.weather,i.decor??[],i.weatherSource,i.instrument,i.exposureSeconds??i.witnessTrack?.keyframes.map(t=>t.pose.exposureSeconds).find(t=>t!==void 0));return Xr.toBounds(e),e}function Nh(i,e){for(const t of i){const n=t.toLowerCase().split("-")[0];if(e.includes(n))return n}return"en"}class vf{static preferencesFor(e){const t=navigator.languages??[],n=e.closest("[lang]")?.getAttribute("lang")?.trim();return n?[n,...t]:t}}const zm="modulepreload",Bm=function(i,e){return new URL(i,e).href},Cu={},ml=function(e,t,n){let s=Promise.resolve();if(t&&t.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(t.map(h=>{if(h=Bm(h,n),h in Cu)return;Cu[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":zm,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 e().catch(r)})},km=["en","fr"],Hm={en:()=>ml(()=>Promise.resolve().then(()=>Vm),void 0,import.meta.url).then(i=>i.ufoMessages_en),fr:()=>ml(()=>import("./UfoMessages_fr-Hq24iVzT.js"),[],import.meta.url).then(i=>i.ufoMessages_fr)};function Gm(i){return Hm[i]()}const _f={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"},Vm=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:_f},Symbol.toStringTag,{value:"Module"})),Pu=new Set;class rs extends HTMLElement{static get observedAttributes(){return["src"]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;loopButton;fullscreenButton;seekInput;timeStartLabel;timeEndLabel;currentSighting=Xo.create();sightingAudio=new Um;soundPreview;player;loopEnabled=!0;playbackBeforeClick;highlightedSourceIds=new Set;occludedSourceIds=Pu;enableClickToPlay=!0;fullscreenTarget;messages=_f;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>this.updateFullscreenButton();handlePointerMove=e=>{const t=this.canvasPointFromEvent(e),n=t&&this.shapeAt(t.x,t.y);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=`${e.clientX-s.left+12}px`,this.tooltip.style.top=`${e.clientY-s.top+12}px`};handlePointerLeave=()=>{this.tooltip.hidden=!0};constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${im}</style>${nm}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Im(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 t of[this.timeStartLabel,this.timeEndLabel])t.addEventListener("click",()=>this.toggleTimeDisplay()),t.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",t=>{this.enableClickToPlay&&(t.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause())}),this.canvas.addEventListener("dblclick",t=>{this.enableClickToPlay&&(t.preventDefault(),this.restorePlayback(),this.toggleFullscreen())}),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 e=this.getAttribute("src");e&&this.loadFromSrc(e)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sightingAudio.dispose()}attributeChangedCallback(e,t,n){e==="src"&&n&&n!==t&&this.isConnected&&this.loadFromSrc(n)}async loadFromSrc(e){this.sightingData=await ff.json(e)}get sightingData(){return Om(this.currentSighting)}set sightingData(e){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=Fm(e),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh()}get sighting(){return this.currentSighting}previewSound(e){this.soundPreview=e,this.sightingAudio.resume(),this.sightingAudio.setSound(e)}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(e){this.player.seek(e)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(e){e!==this.loopEnabled&&this.toggleLoop()}play(){this.player.seekableDuration<=0||this.playbackState==="playing"||this.togglePlayPause()}pause(){this.playbackState==="playing"&&this.togglePlayPause()}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(e){this.toolbar.classList.toggle("hidden",!e)}get playbackState(){return this.player.playbackState}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(e){this.currentSighting.event.durationSeconds=e,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(e){const t=new Set(e);t.size===this.highlightedSourceIds.size&&[...t].every(s=>this.highlightedSourceIds.has(s))||(this.highlightedSourceIds=t,this.refresh())}setOccludedSourceIds(e){e.size===this.occludedSourceIds.size&&[...e].every(n=>this.occludedSourceIds.has(n))||(this.occludedSourceIds=e,this.refresh())}hasVisibleShapeAt(e,t){return this.shapeAt(e,t)!==void 0}refresh(){this.applyFrameFormat(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.player.seek(this.player.time)}exposureInstants(e){const t=this.exposureTimes(e),n=1/t.length;return t.map(s=>({shapes:this.shapesAt(s),share:n}))}exposureTimes(e=this.currentTime){const t=(this.currentSighting.exposure??0)*1e3;if(t<rs.SHORTEST_VISIBLE_EXPOSURE_MS)return[e];const n=Math.min(rs.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(t/rs.SHORTEST_VISIBLE_EXPOSURE_MS))),s=Math.ceil(this.travelPxOver(e,t)/rs.EXPOSURE_STEP_PX),r=Math.min(rs.MAX_TRAVEL_STEPS,Math.max(n,s)),a=[];for(let o=0;o<r;o++)a.push(e+t*o/r);return a}travelPxOver(e,t){const n=this.shapesAt(e),s=this.shapesAt(e+t);let r=0;for(const[a,o]of n){const c=s.get(a);if(!c)continue;const l=c.bounds.x+c.bounds.width/2-(o.bounds.x+o.bounds.width/2),h=c.bounds.y+c.bounds.height/2-(o.bounds.y+o.bounds.height/2);r=Math.max(r,Math.hypot(l,h))}return r}shapeAt(e,t,n=this.occludedSourceIds){for(const s of this.exposureTimes()){const r=this.currentSighting.timeline.hitTest(s,e,t,n);if(r)return r}}shapesAt(e){const t=new Map;for(const n of this.currentSighting.timeline.sourceIds){const s=this.currentSighting.timeline.getInterpolatedShapeAt(e,n);s&&t.set(n,s)}return t}static SHORTEST_VISIBLE_EXPOSURE_MS=20;static MAX_EXPOSURE_STEPS=48;static EXPOSURE_STEP_PX=2;static MAX_TRAVEL_STEPS=320;applyFrameFormat(){const e=Jt.frameWidthPx(this.currentSighting.instrument,this.canvas.height);if(this.canvas.width===e)return;this.canvas.width=e,this.canvas.parentElement?.style.setProperty("--frame-aspect",`${e} / ${this.canvas.height}`)}canvasPointFromEvent(e){const t=this.canvas.getBoundingClientRect();if(!(t.width===0||t.height===0))return{x:(e.clientX-t.left)/t.width*this.canvas.width,y:(e.clientY-t.top)/t.height*this.canvas.height}}onFrame(e,t){this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const n=this.playbackState!=="playing"?this.highlightedSourceIds:Pu;this.canvasRenderer.setStarPoints(Jt.starPointsOf(this.sighting.instrument)),this.canvasRenderer.setRoll((Qs(this.sighting,e)?.rollDeg??0)*Math.PI/180);const s=this.exposureInstants(e);for(const r of s)for(const[a,o]of r.shapes){if(this.occludedSourceIds.has(a))continue;const c=r.share,l=c===1?o:{...o,transparency:1-(1-o.transparency)*c};this.canvasRenderer.paintShape(l)}for(const[r,a]of s[0].shapes)this.occludedSourceIds.has(r)||!n.has(r)||(n.size===1?this.canvasRenderer.paintShape({...a,selected:!0}):this.canvasRenderer.paintMemberOutline(a));if(n.size>1){const r=Mn.groupBoundsFor([...t].filter(([a])=>n.has(a)).map(([,a])=>a.bounds));this.canvasRenderer.paintGroupHandles(r)}this.seekInput.value=String(e),this.timeStartLabel.textContent=this.formatPosition(e),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(Sm(this.currentSighting,e))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:e}}))}createPlayer(){const e=new Em(this.currentSighting.timeline,(t,n)=>this.onFrame(t,n));return e.loop=this.loopEnabled,e.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},e}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 e=this.player.playbackState==="playing";this.playPauseButton.textContent=e?"⏸":"▶";const t=this.player.seekableDuration>0;this.playPauseButton.disabled=!t;const n=t?e?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",e),this.fullscreenButton.classList.toggle("auto-hide",e)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.loopButton.setAttribute("aria-pressed",String(this.loopEnabled)),this.player.loop=this.loopEnabled}restorePlayback(){const e=this.playbackBeforeClick;e&&(this.currentTime=e.time,e.state==="playing"?this.play():this.pause())}toggleFullscreen(){document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(e=>{console.error("<rr0-ufo>: requestFullscreen() failed —",e)})}updateFullscreenButton(){const e=document.fullscreenElement===this.fullscreenTarget;this.fullscreenButton.title=e?this.messages.exitFullscreen:this.messages.fullscreen,this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}async loadLocaleMessages(){const e=Nh(vf.preferencesFor(this),km);e!=="en"&&this.applyMessages(await Gm(e))}updateTimeLabelTitles(){const e=this.showClockTime?this.messages.switchToElapsed:this.messages.switchToClockTime,t=this.canSwitchTimeDisplay?` — ${e}`:"";this.timeStartLabel.title=this.messages.currentPosition+t,this.timeEndLabel.title=this.messages.duration+t;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(e){this.messages=e,this.updateTimeLabelTitles(),this.loopButton.title=e.autoReplay,this.loopButton.setAttribute("aria-label",e.autoReplay),this.updatePlayPauseButton(),this.updateFullscreenButton()}updateTimeLabels(){const e=this.currentSighting.event,t=xm(e);this.realDurationMs=t!==void 0&&t>0?t:void 0,this.realStartMs=e.time?fl(e.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(e){if(this.realDurationMs===void 0)return xa(e);const t=this.currentSighting.timeline.duration,n=t>0&&e<=t?e/t*this.realDurationMs:e;return this.canShowClockTime?Lu(Iu(this.realStartMs+n)):xa(n)}formatEndOfTimeline(){return this.realDurationMs===void 0?xa(this.currentSighting.timeline.duration):this.canShowClockTime?Lu(Iu(this.realStartMs+this.realDurationMs)):xa(this.realDurationMs)}}function Iu(i){const e=new Date(i);return{hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds()}}function Lu(i){if(i.hour===void 0)return"0:00";const e=t=>String(t).padStart(2,"0");return i.second?`${e(i.hour)}:${e(i.minute??0)}:${e(i.second)}`:`${e(i.hour)}:${e(i.minute??0)}`}function xa(i){const e=Math.round(i/1e3),t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,"0")}`}const gl="rr0-ufo";function xf(){customElements.get(gl)||customElements.define(gl,rs)}/**
330
330
  * @license
331
331
  * Copyright 2010-2026 Three.js Authors
332
332
  * SPDX-License-Identifier: MIT
333
- */const eh="185",Cp=0,Zh=1,Pp=2,Cr=1,Ip=2,Er=3,Fi=0,It=1,Ln=2,jn=0,Ks=1,ni=2,$h=3,Jh=4,Lp=5,Qi=100,Np=101,Up=102,Op=103,Fp=104,zp=200,Bp=201,Hp=202,kp=203,Oc=204,Fc=205,Gp=206,Vp=207,Wp=208,Xp=209,qp=210,Yp=211,Kp=212,Zp=213,$p=214,zc=0,Bc=1,Hc=2,tr=3,kc=4,Gc=5,Vc=6,Wc=7,th=0,Jp=1,Qp=2,ei=0,o0=1,c0=2,l0=3,h0=4,u0=5,d0=6,f0=7,p0=300,as=301,nr=302,Co=303,Po=304,vo=306,Qa=1e3,sn=1001,Xc=1002,Nt=1003,jp=1004,jr=1005,Et=1006,Io=1007,ns=1008,xn=1009,m0=1010,g0=1011,Fr=1012,nh=1013,On=1014,$n=1015,Qt=1016,ih=1017,sh=1018,zr=1020,v0=35902,_0=35899,x0=1021,M0=1022,hn=1023,mi=1026,is=1027,S0=1028,rh=1029,os=1030,ah=1031,oh=1033,Wa=33776,Xa=33777,qa=33778,Ya=33779,qc=35840,Yc=35841,Kc=35842,Zc=35843,$c=36196,Jc=37492,Qc=37496,jc=37488,el=37489,ja=37490,tl=37491,nl=37808,il=37809,sl=37810,rl=37811,al=37812,ol=37813,cl=37814,ll=37815,hl=37816,ul=37817,dl=37818,fl=37819,pl=37820,ml=37821,gl=36492,vl=36494,_l=36495,xl=36283,Ml=36284,eo=36285,Sl=36286,em=3200,yl=0,tm=1,Pi="",An="srgb",to="srgb-linear",no="linear",it="srgb",xs=7680,Qh=519,nm=512,im=513,sm=514,ch=515,rm=516,am=517,lh=518,om=519,El=35044,jh="300 es",Jn=2e3,Br=2001;function cm(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function io(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function lm(){const i=io("canvas");return i.style.display="block",i}const eu={};function so(...i){const e="THREE."+i.shift();console.log(e,...i)}function y0(i){const e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Fe(...i){i=y0(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function Ze(...i){i=y0(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function Zs(...i){const e=i.join(" ");e in eu||(eu[e]=!0,Fe(...i))}function hm(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}const um={[zc]:Bc,[Hc]:Vc,[kc]:Wc,[tr]:Gc,[Bc]:zc,[Vc]:Hc,[Wc]:kc,[Gc]:tr};class fs{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const s=n[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,e);e.target=null}}}const Xt=["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"],Lo=Math.PI/180,Al=180/Math.PI;function Ni(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Xt[i&255]+Xt[i>>8&255]+Xt[i>>16&255]+Xt[i>>24&255]+"-"+Xt[e&255]+Xt[e>>8&255]+"-"+Xt[e>>16&15|64]+Xt[e>>24&255]+"-"+Xt[t&63|128]+Xt[t>>8&255]+"-"+Xt[t>>16&255]+Xt[t>>24&255]+Xt[n&255]+Xt[n>>8&255]+Xt[n>>16&255]+Xt[n>>24&255]).toLowerCase()}function Ye(i,e,t){return Math.max(e,Math.min(t,i))}function dm(i,e){return(i%e+e)%e}function No(i,e,t){return(1-t)*i+t*e}function Zn(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function at(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}class Le{static{Le.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Ye(this.x,e.x,t.x),this.y=Ye(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ye(this.x,e,t),this.y=Ye(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ye(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Ye(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*s+e.x,this.y=r*s+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ar{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,a,o){let 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}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,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 e[t]=o*g+h*u+c*f-l*d,e[t+1]=c*g+h*d+l*u-o*f,e[t+2]=l*g+h*f+o*d-c*u,e[t+3]=h*g-o*u-c*d-l*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,s){return this._x=e,this._y=t,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,s=e._y,r=e._z,a=e._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:Fe("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],s=t[4],r=t[8],a=t[1],o=t[5],c=t[9],l=t[2],h=t[6],u=t[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(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ye(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const s=Math.min(1,t/n);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,s=e._y,r=e._z,a=e._w,o=t._x,c=t._y,l=t._z,h=t._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(e,t){let n=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let c=1-t;if(o<.9995){const l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,t=Math.sin(t*l)/h,this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this._onChangeCallback()}else this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class L{static{L.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(tu.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(tu.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,s=this.z,r=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*s-o*n),h=2*(o*t-r*s),u=2*(r*n-a*t);return this.x=t+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(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Ye(this.x,e.x,t.x),this.y=Ye(this.y,e.y,t.y),this.z=Ye(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ye(this.x,e,t),this.y=Ye(this.y,e,t),this.z=Ye(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ye(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,s=e.y,r=e.z,a=t.x,o=t.y,c=t.z;return this.x=s*c-r*o,this.y=r*a-n*c,this.z=n*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Uo.copy(this).projectOnVector(e),this.sub(Uo)}reflect(e){return this.sub(Uo.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Ye(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Uo=new L,tu=new ar;class ze{static{ze.prototype.isMatrix3=!0}constructor(e,t,n,s,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,c,l)}set(e,t,n,s,r,a,o,c,l){const h=this.elements;return h[0]=e,h[1]=s,h[2]=o,h[3]=t,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(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.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(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8];return t*a*h-t*o*l-n*r*h+n*o*c+s*r*l-s*a*c}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=h*a-o*l,d=o*c-h*r,f=l*r-a*c,g=t*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 e[0]=u*x,e[1]=(s*l-h*n)*x,e[2]=(o*n-s*a)*x,e[3]=d*x,e[4]=(h*t-s*c)*x,e[5]=(s*r-o*t)*x,e[6]=f*x,e[7]=(n*c-l*t)*x,e[8]=(a*t-n*r)*x,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,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+e,-s*l,s*c,-s*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return Zs("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Oo.makeScale(e,t)),this}rotate(e){return Zs("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Oo.makeRotation(-e)),this}translate(e,t){return Zs("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Oo.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Oo=new ze,nu=new ze().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),iu=new ze().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function fm(){const i={enabled:!0,workingColorSpace:to,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===it&&(s.r=pi(s.r),s.g=pi(s.g),s.b=pi(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===it&&(s.r=$s(s.r),s.g=$s(s.g),s.b=$s(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===Pi?no: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 Zs("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Zs("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[to]:{primaries:e,whitePoint:n,transfer:no,toXYZ:nu,fromXYZ:iu,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:An},outputColorSpaceConfig:{drawingBufferColorSpace:An}},[An]:{primaries:e,whitePoint:n,transfer:it,toXYZ:nu,fromXYZ:iu,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:An}}}),i}const $e=fm();function pi(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function $s(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Ms;class pm{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Ms===void 0&&(Ms=io("canvas")),Ms.width=e.width,Ms.height=e.height;const s=Ms.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=Ms}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=io("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=pi(r[a]/255)*255;return n.putImageData(s,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(pi(t[n]/255)*255):t[n]=pi(t[n]);return{data:t,width:e.width,height:e.height}}else return Fe("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let mm=0;class hh{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:mm++}),this.uuid=Ni(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.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(Fo(s[a].image)):r.push(Fo(s[a]))}else r=Fo(s);n.url=r}return t||(e.images[this.uuid]=n),n}}function Fo(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?pm.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Fe("Texture: Unable to serialize Texture."),{})}let gm=0;const zo=new L;class Jt extends fs{constructor(e=Jt.DEFAULT_IMAGE,t=Jt.DEFAULT_MAPPING,n=sn,s=sn,r=Et,a=ns,o=hn,c=xn,l=Jt.DEFAULT_ANISOTROPY,h=Pi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:gm++}),this.uuid=Ni(),this.name="",this.source=new hh(e),this.mipmaps=[],this.mapping=t,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 Le(0,0),this.repeat=new Le(1,1),this.center=new Le(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ze,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(zo).x}get height(){return this.source.getSize(zo).y}get depth(){return this.source.getSize(zo).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){Fe(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Fe(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==p0)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Qa:e.x=e.x-Math.floor(e.x);break;case sn:e.x=e.x<0?0:1;break;case Xc:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Qa:e.y=e.y-Math.floor(e.y);break;case sn:e.y=e.y<0?0:1;break;case Xc:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Jt.DEFAULT_IMAGE=null;Jt.DEFAULT_MAPPING=p0;Jt.DEFAULT_ANISOTROPY=1;class vt{static{vt.prototype.isVector4=!0}constructor(e=0,t=0,n=0,s=1){this.x=e,this.y=t,this.z=n,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,s,r;const c=e.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;t=Math.PI;const T=(l+1)/2,M=(f+1)/2,y=(p+1)/2,b=(h+d)/4,R=(u+x)/4,_=(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=_/s):y<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(y),n=R/r,s=_/r),this.set(n,s,r,t),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(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Ye(this.x,e.x,t.x),this.y=Ye(this.y,e.y,t.y),this.z=Ye(this.z,e.z,t.z),this.w=Ye(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ye(this.x,e,t),this.y=Ye(this.y,e,t),this.z=Ye(this.z,e,t),this.w=Ye(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ye(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class vm extends fs{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Et,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new vt(0,0,e,t),this.scissorTest=!1,this.viewport=new vt(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:n.depth},r=new Jt(s),a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){const t={minFilter:Et,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].image.depth=n,this.textures[s].isData3DTexture!==!0&&(this.textures[s].isArrayTexture=this.textures[s].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const s=Object.assign({},e.textures[t].image);this.textures[t].source=new hh(s)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class un extends vm{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class E0 extends Jt{constructor(e=null,t=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Nt,this.minFilter=Nt,this.wrapR=sn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class _m extends Jt{constructor(e=null,t=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Nt,this.minFilter=Nt,this.wrapR=sn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class dt{static{dt.prototype.isMatrix4=!0}constructor(e,t,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],e!==void 0&&this.set(e,t,n,s,r,a,o,c,l,h,u,d,f,g,x,m)}set(e,t,n,s,r,a,o,c,l,h,u,d,f,g,x,m){const p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=s,p[1]=r,p[5]=a,p[9]=o,p[13]=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 dt().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const t=this.elements,n=e.elements,s=1/Ss.setFromMatrixColumn(e,0).length(),r=1/Ss.setFromMatrixColumn(e,1).length(),a=1/Ss.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,s=e.y,r=e.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(e.order==="XYZ"){const d=a*h,f=a*u,g=o*h,x=o*u;t[0]=c*h,t[4]=-c*u,t[8]=l,t[1]=f+g*l,t[5]=d-x*l,t[9]=-o*c,t[2]=x-d*l,t[6]=g+f*l,t[10]=a*c}else if(e.order==="YXZ"){const d=c*h,f=c*u,g=l*h,x=l*u;t[0]=d+x*o,t[4]=g*o-f,t[8]=a*l,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=f*o-g,t[6]=x+d*o,t[10]=a*c}else if(e.order==="ZXY"){const d=c*h,f=c*u,g=l*h,x=l*u;t[0]=d-x*o,t[4]=-a*u,t[8]=g+f*o,t[1]=f+g*o,t[5]=a*h,t[9]=x-d*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const d=a*h,f=a*u,g=o*h,x=o*u;t[0]=c*h,t[4]=g*l-f,t[8]=d*l+x,t[1]=c*u,t[5]=x*l+d,t[9]=f*l-g,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const d=a*c,f=a*l,g=o*c,x=o*l;t[0]=c*h,t[4]=x-d*u,t[8]=g*u+f,t[1]=u,t[5]=a*h,t[9]=-o*h,t[2]=-l*h,t[6]=f*u+g,t[10]=d-x*u}else if(e.order==="XZY"){const d=a*c,f=a*l,g=o*c,x=o*l;t[0]=c*h,t[4]=-u,t[8]=l*h,t[1]=d*u+x,t[5]=a*h,t[9]=f*u-g,t[2]=g*u-f,t[6]=o*h,t[10]=x*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(xm,e,Mm)}lookAt(e,t,n){const s=this.elements;return fn.subVectors(e,t),fn.lengthSq()===0&&(fn.z=1),fn.normalize(),Si.crossVectors(n,fn),Si.lengthSq()===0&&(Math.abs(n.z)===1?fn.x+=1e-4:fn.z+=1e-4,fn.normalize(),Si.crossVectors(n,fn)),Si.normalize(),ea.crossVectors(fn,Si),s[0]=Si.x,s[4]=ea.x,s[8]=fn.x,s[1]=Si.y,s[5]=ea.y,s[9]=fn.y,s[2]=Si.z,s[6]=ea.z,s[10]=fn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.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],_=s[8],E=s[12],C=s[1],D=s[5],I=s[9],W=s[13],X=s[2],O=s[6],q=s[10],G=s[14],$=s[3],te=s[7],j=s[11],ie=s[15];return r[0]=a*b+o*C+c*X+l*$,r[4]=a*R+o*D+c*O+l*te,r[8]=a*_+o*I+c*q+l*j,r[12]=a*E+o*W+c*G+l*ie,r[1]=h*b+u*C+d*X+f*$,r[5]=h*R+u*D+d*O+f*te,r[9]=h*_+u*I+d*q+f*j,r[13]=h*E+u*W+d*G+f*ie,r[2]=g*b+x*C+m*X+p*$,r[6]=g*R+x*D+m*O+p*te,r[10]=g*_+x*I+m*q+p*j,r[14]=g*E+x*W+m*G+p*ie,r[3]=A*b+T*C+M*X+y*$,r[7]=A*R+T*D+M*O+y*te,r[11]=A*_+T*I+M*q+y*j,r[15]=A*E+T*W+M*G+y*ie,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],s=e[8],r=e[12],a=e[1],o=e[5],c=e[9],l=e[13],h=e[2],u=e[6],d=e[10],f=e[14],g=e[3],x=e[7],m=e[11],p=e[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 t*(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 e=this.elements,t=e[0],n=e[4],s=e[8],r=e[1],a=e[5],o=e[9],c=e[2],l=e[6],h=e[10];return t*(a*h-o*l)-n*(r*h-o*c)+s*(r*l-a*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=e[9],d=e[10],f=e[11],g=e[12],x=e[13],m=e[14],p=e[15],A=t*o-n*a,T=t*c-s*a,M=t*l-r*a,y=n*c-s*o,b=n*l-r*o,R=s*l-r*c,_=h*x-u*g,E=h*m-d*g,C=h*p-f*g,D=u*m-d*x,I=u*p-f*x,W=d*p-f*m,X=A*W-T*I+M*D+y*C-b*E+R*_;if(X===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/X;return e[0]=(o*W-c*I+l*D)*O,e[1]=(s*I-n*W-r*D)*O,e[2]=(x*R-m*b+p*y)*O,e[3]=(d*b-u*R-f*y)*O,e[4]=(c*C-a*W-l*E)*O,e[5]=(t*W-s*C+r*E)*O,e[6]=(m*M-g*R-p*T)*O,e[7]=(h*R-d*M+f*T)*O,e[8]=(a*I-o*C+l*_)*O,e[9]=(n*C-t*I-r*_)*O,e[10]=(g*b-x*M+p*A)*O,e[11]=(u*M-h*b-f*A)*O,e[12]=(o*E-a*D-c*_)*O,e[13]=(t*D-n*E+s*_)*O,e[14]=(x*T-g*y-m*A)*O,e[15]=(h*y-u*T+d*A)*O,this}scale(e){const t=this.elements,n=e.x,s=e.y,r=e.z;return t[0]*=n,t[4]*=s,t[8]*=r,t[1]*=n,t[5]*=s,t[9]*=r,t[2]*=n,t[6]*=s,t[10]*=r,t[3]*=n,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),s=Math.sin(t),r=1-n,a=e.x,o=e.y,c=e.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(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,s,r,a){return this.set(1,n,r,0,e,1,a,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){const s=this.elements,r=t._x,a=t._y,o=t._z,c=t._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]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){const s=this.elements;e.x=s[12],e.y=s[13],e.z=s[14];const r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let a=Ss.set(s[0],s[1],s[2]).length();const o=Ss.set(s[4],s[5],s[6]).length(),c=Ss.set(s[8],s[9],s[10]).length();r<0&&(a=-a),Rn.copy(this);const l=1/a,h=1/o,u=1/c;return Rn.elements[0]*=l,Rn.elements[1]*=l,Rn.elements[2]*=l,Rn.elements[4]*=h,Rn.elements[5]*=h,Rn.elements[6]*=h,Rn.elements[8]*=u,Rn.elements[9]*=u,Rn.elements[10]*=u,t.setFromRotationMatrix(Rn),n.x=a,n.y=o,n.z=c,this}makePerspective(e,t,n,s,r,a,o=Jn,c=!1){const l=this.elements,h=2*r/(t-e),u=2*r/(n-s),d=(t+e)/(t-e),f=(n+s)/(n-s);let g,x;if(c)g=r/(a-r),x=a*r/(a-r);else if(o===Jn)g=-(a+r)/(a-r),x=-2*a*r/(a-r);else if(o===Br)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(e,t,n,s,r,a,o=Jn,c=!1){const l=this.elements,h=2/(t-e),u=2/(n-s),d=-(t+e)/(t-e),f=-(n+s)/(n-s);let g,x;if(c)g=1/(a-r),x=a/(a-r);else if(o===Jn)g=-2/(a-r),x=-(a+r)/(a-r);else if(o===Br)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(e){const t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Ss=new L,Rn=new dt,xm=new L(0,0,0),Mm=new L(1,1,1),Si=new L,ea=new L,fn=new L,su=new dt,ru=new ar;class zi{constructor(e=0,t=0,n=0,s=zi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const s=e.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(t){case"XYZ":this._y=Math.asin(Ye(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ye(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(Ye(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(-Ye(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(Ye(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(-Ye(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:Fe("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return su.makeRotationFromQuaternion(e),this.setFromRotationMatrix(su,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ru.setFromEuler(this),this.setFromQuaternion(ru,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}zi.DEFAULT_ORDER="XYZ";class uh{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let Sm=0;const au=new L,ys=new ar,ii=new dt,ta=new L,hr=new L,ym=new L,Em=new ar,ou=new L(1,0,0),cu=new L(0,1,0),lu=new L(0,0,1),hu={type:"added"},Am={type:"removed"},Es={type:"childadded",child:null},Bo={type:"childremoved",child:null};class Lt extends fs{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Sm++}),this.uuid=Ni(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Lt.DEFAULT_UP.clone();const e=new L,t=new zi,n=new ar,s=new L(1,1,1);function r(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new dt},normalMatrix:{value:new ze}}),this.matrix=new dt,this.matrixWorld=new dt,this.matrixAutoUpdate=Lt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Lt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new uh,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return ys.setFromAxisAngle(e,t),this.quaternion.multiply(ys),this}rotateOnWorldAxis(e,t){return ys.setFromAxisAngle(e,t),this.quaternion.premultiply(ys),this}rotateX(e){return this.rotateOnAxis(ou,e)}rotateY(e){return this.rotateOnAxis(cu,e)}rotateZ(e){return this.rotateOnAxis(lu,e)}translateOnAxis(e,t){return au.copy(e).applyQuaternion(this.quaternion),this.position.add(au.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(ou,e)}translateY(e){return this.translateOnAxis(cu,e)}translateZ(e){return this.translateOnAxis(lu,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ii.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?ta.copy(e):ta.set(e,t,n);const s=this.parent;this.updateWorldMatrix(!0,!1),hr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ii.lookAt(hr,ta,this.up):ii.lookAt(ta,hr,this.up),this.quaternion.setFromRotationMatrix(ii),s&&(ii.extractRotation(s.matrixWorld),ys.setFromRotationMatrix(ii),this.quaternion.premultiply(ys.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Ze("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(hu),Es.child=e,this.dispatchEvent(Es),Es.child=null):Ze("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Am),Bo.child=e,this.dispatchEvent(Bo),Bo.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ii.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ii.multiply(e.parent.matrixWorld)),e.applyMatrix4(ii),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(hu),Es.child=e,this.dispatchEvent(Es),Es.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,s=this.children.length;n<s;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(hr,e,ym),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(hr,Em,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,n=e.y,s=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*s,r[13]+=n-r[1]*t-r[5]*n-r[9]*s,r[14]+=s-r[2]*t-r[6]*n-r[10]*s}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){const s=this.parent;if(e===!0&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){const r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,n)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});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(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);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(e.shapes,u)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(r(e.materials,this.material[c]));s.material=o}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];s.animations.push(r(e.animations,c))}}if(t){const o=a(e.geometries),c=a(e.materials),l=a(e.textures),h=a(e.images),u=a(e.shapes),d=a(e.skeletons),f=a(e.animations),g=a(e.nodes);o.length>0&&(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(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const s=e.children[n];this.add(s.clone())}return this}}Lt.DEFAULT_UP=new L(0,1,0);Lt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Lt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Un extends Lt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const bm={type:"move"};class Ho{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Un,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 Un,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new L,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new L),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Un,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new L,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new L,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let s=null,r=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(const x of e.hand.values()){const m=t.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:e.handedness,target:this})):!l.inputState.pinching&&d<=f-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.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:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(bm)))}return o!==null&&(o.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Un;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const A0={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},yi={h:0,s:0,l:0},na={h:0,s:0,l:0};function ko(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class Me{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=An){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,$e.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=$e.workingColorSpace){return this.r=e,this.g=t,this.b=n,$e.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=$e.workingColorSpace){if(e=dm(e,1),t=Ye(t,0,1),n=Ye(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=ko(a,r,e+1/3),this.g=ko(a,r,e),this.b=ko(a,r,e-1/3)}return $e.colorSpaceToWorking(this,s),this}setStyle(e,t=An){function n(r){r!==void 0&&parseFloat(r)<1&&Fe("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){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,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Fe("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){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,t);if(a===6)return this.setHex(parseInt(r,16),t);Fe("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=An){const n=A0[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Fe("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=pi(e.r),this.g=pi(e.g),this.b=pi(e.b),this}copyLinearToSRGB(e){return this.r=$s(e.r),this.g=$s(e.g),this.b=$s(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=An){return $e.workingToColorSpace(qt.copy(this),e),Math.round(Ye(qt.r*255,0,255))*65536+Math.round(Ye(qt.g*255,0,255))*256+Math.round(Ye(qt.b*255,0,255))}getHexString(e=An){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=$e.workingColorSpace){$e.workingToColorSpace(qt.copy(this),t);const n=qt.r,s=qt.g,r=qt.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 e.h=c,e.s=l,e.l=h,e}getRGB(e,t=$e.workingColorSpace){return $e.workingToColorSpace(qt.copy(this),t),e.r=qt.r,e.g=qt.g,e.b=qt.b,e}getStyle(e=An){$e.workingToColorSpace(qt.copy(this),e);const t=qt.r,n=qt.g,s=qt.b;return e!==An?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(yi),this.setHSL(yi.h+e,yi.s+t,yi.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(yi),e.getHSL(na);const n=No(yi.h,na.h,t),s=No(yi.s,na.s,t),r=No(yi.l,na.l,t);return this.setHSL(n,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*s,this.g=r[1]*t+r[4]*n+r[7]*s,this.b=r[2]*t+r[5]*n+r[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const qt=new Me;Me.NAMES=A0;class dh{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Me(e),this.near=t,this.far=n}clone(){return new dh(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class _o extends Lt{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 zi,this.environmentIntensity=1,this.environmentRotation=new zi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Dn=new L,si=new L,Go=new L,ri=new L,As=new L,bs=new L,uu=new L,Vo=new L,Wo=new L,Xo=new L,qo=new vt,Yo=new vt,Ko=new vt;class bn{constructor(e=new L,t=new L,n=new L){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),Dn.subVectors(e,t),s.cross(Dn);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){Dn.subVectors(s,t),si.subVectors(n,t),Go.subVectors(e,t);const a=Dn.dot(Dn),o=Dn.dot(si),c=Dn.dot(Go),l=si.dot(si),h=si.dot(Go),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(e,t,n,s){return this.getBarycoord(e,t,n,s,ri)===null?!1:ri.x>=0&&ri.y>=0&&ri.x+ri.y<=1}static getInterpolation(e,t,n,s,r,a,o,c){return this.getBarycoord(e,t,n,s,ri)===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,ri.x),c.addScaledVector(a,ri.y),c.addScaledVector(o,ri.z),c)}static getInterpolatedAttribute(e,t,n,s,r,a){return qo.setScalar(0),Yo.setScalar(0),Ko.setScalar(0),qo.fromBufferAttribute(e,t),Yo.fromBufferAttribute(e,n),Ko.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(qo,r.x),a.addScaledVector(Yo,r.y),a.addScaledVector(Ko,r.z),a}static isFrontFacing(e,t,n,s){return Dn.subVectors(n,t),si.subVectors(e,t),Dn.cross(si).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Dn.subVectors(this.c,this.b),si.subVectors(this.a,this.b),Dn.cross(si).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return bn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return bn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return bn.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return bn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return bn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,s=this.b,r=this.c;let a,o;As.subVectors(s,n),bs.subVectors(r,n),Vo.subVectors(e,n);const c=As.dot(Vo),l=bs.dot(Vo);if(c<=0&&l<=0)return t.copy(n);Wo.subVectors(e,s);const h=As.dot(Wo),u=bs.dot(Wo);if(h>=0&&u<=h)return t.copy(s);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),t.copy(n).addScaledVector(As,a);Xo.subVectors(e,r);const f=As.dot(Xo),g=bs.dot(Xo);if(g>=0&&f<=g)return t.copy(r);const x=f*l-c*g;if(x<=0&&l>=0&&g<=0)return o=l/(l-g),t.copy(n).addScaledVector(bs,o);const m=h*g-f*u;if(m<=0&&u-h>=0&&f-g>=0)return uu.subVectors(r,s),o=(u-h)/(u-h+(f-g)),t.copy(s).addScaledVector(uu,o);const p=1/(m+x+d);return a=x*p,o=d*p,t.copy(n).addScaledVector(As,a).addScaledVector(bs,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class kr{constructor(e=new L(1/0,1/0,1/0),t=new L(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Cn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Cn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Cn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Cn):Cn.fromBufferAttribute(r,a),Cn.applyMatrix4(e.matrixWorld),this.expandByPoint(Cn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),ia.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),ia.copy(n.boundingBox)),ia.applyMatrix4(e.matrixWorld),this.union(ia)}const s=e.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Cn),Cn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ur),sa.subVectors(this.max,ur),Ts.subVectors(e.a,ur),ws.subVectors(e.b,ur),Rs.subVectors(e.c,ur),Ei.subVectors(ws,Ts),Ai.subVectors(Rs,ws),Vi.subVectors(Ts,Rs);let t=[0,-Ei.z,Ei.y,0,-Ai.z,Ai.y,0,-Vi.z,Vi.y,Ei.z,0,-Ei.x,Ai.z,0,-Ai.x,Vi.z,0,-Vi.x,-Ei.y,Ei.x,0,-Ai.y,Ai.x,0,-Vi.y,Vi.x,0];return!Zo(t,Ts,ws,Rs,sa)||(t=[1,0,0,0,1,0,0,0,1],!Zo(t,Ts,ws,Rs,sa))?!1:(ra.crossVectors(Ei,Ai),t=[ra.x,ra.y,ra.z],Zo(t,Ts,ws,Rs,sa))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Cn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Cn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(ai[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ai[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ai[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ai[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ai[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ai[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ai[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ai[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ai),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const ai=[new L,new L,new L,new L,new L,new L,new L,new L],Cn=new L,ia=new kr,Ts=new L,ws=new L,Rs=new L,Ei=new L,Ai=new L,Vi=new L,ur=new L,sa=new L,ra=new L,Wi=new L;function Zo(i,e,t,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){Wi.fromArray(i,r);const o=s.x*Math.abs(Wi.x)+s.y*Math.abs(Wi.y)+s.z*Math.abs(Wi.z),c=e.dot(Wi),l=t.dot(Wi),h=n.dot(Wi);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const fi=Tm();function Tm(){const i=new ArrayBuffer(4),e=new Float32Array(i),t=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:e,uint32View:t,baseTable:n,shiftTable:s,mantissaTable:r,exponentTable:a,offsetTable:o}}function wm(i){Math.abs(i)>65504&&Fe("DataUtils.toHalfFloat(): Value out of range."),i=Ye(i,-65504,65504),fi.floatView[0]=i;const e=fi.uint32View[0],t=e>>23&511;return fi.baseTable[t]+((e&8388607)>>fi.shiftTable[t])}function Rm(i){const e=i>>10;return fi.uint32View[0]=fi.mantissaTable[fi.offsetTable[e]+(i&1023)]+fi.exponentTable[e],fi.floatView[0]}class Ui{static toHalfFloat(e){return wm(e)}static fromHalfFloat(e){return Rm(e)}}const Ct=new L,aa=new Le;let Dm=0;class ut extends fs{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Dm++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=El,this.updateRanges=[],this.gpuType=$n,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[e+s]=t.array[n+s];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)aa.fromBufferAttribute(this,t),aa.applyMatrix3(e),this.setXY(t,aa.x,aa.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Ct.fromBufferAttribute(this,t),Ct.applyMatrix3(e),this.setXYZ(t,Ct.x,Ct.y,Ct.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Ct.fromBufferAttribute(this,t),Ct.applyMatrix4(e),this.setXYZ(t,Ct.x,Ct.y,Ct.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Ct.fromBufferAttribute(this,t),Ct.applyNormalMatrix(e),this.setXYZ(t,Ct.x,Ct.y,Ct.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Ct.fromBufferAttribute(this,t),Ct.transformDirection(e),this.setXYZ(t,Ct.x,Ct.y,Ct.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Zn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=at(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Zn(t,this.array)),t}setX(e,t){return this.normalized&&(t=at(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Zn(t,this.array)),t}setY(e,t){return this.normalized&&(t=at(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Zn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=at(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Zn(t,this.array)),t}setW(e,t){return this.normalized&&(t=at(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=at(t,this.array),n=at(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=at(t,this.array),n=at(n,this.array),s=at(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e*=this.itemSize,this.normalized&&(t=at(t,this.array),n=at(n,this.array),s=at(s,this.array),r=at(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==El&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class b0 extends ut{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class T0 extends ut{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Ut extends ut{constructor(e,t,n){super(new Float32Array(e),t,n)}}const Cm=new kr,dr=new L,$o=new L;class xo{constructor(e=new L,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Cm.setFromPoints(e).getCenter(n);let s=0;for(let r=0,a=e.length;r<a;r++)s=Math.max(s,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;dr.subVectors(e,this.center);const t=dr.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(dr,s/n),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):($o.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(dr.copy(e.center).add($o)),this.expandByPoint(dr.copy(e.center).sub($o))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let Pm=0;const Sn=new dt,Jo=new Lt,Ds=new L,pn=new kr,fr=new kr,Bt=new L;class Rt extends fs{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Pm++}),this.uuid=Ni(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(cm(e)?T0:b0)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new ze().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Sn.makeRotationFromQuaternion(e),this.applyMatrix4(Sn),this}rotateX(e){return Sn.makeRotationX(e),this.applyMatrix4(Sn),this}rotateY(e){return Sn.makeRotationY(e),this.applyMatrix4(Sn),this}rotateZ(e){return Sn.makeRotationZ(e),this.applyMatrix4(Sn),this}translate(e,t,n){return Sn.makeTranslation(e,t,n),this.applyMatrix4(Sn),this}scale(e,t,n){return Sn.makeScale(e,t,n),this.applyMatrix4(Sn),this}lookAt(e){return Jo.lookAt(e),Jo.updateMatrix(),this.applyMatrix4(Jo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ds).negate(),this.translate(Ds.x,Ds.y,Ds.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let s=0,r=e.length;s<r;s++){const a=e[s];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Ut(n,3))}else{const n=Math.min(e.length,t.count);for(let s=0;s<n;s++){const r=e[s];t.setXYZ(s,r.x,r.y,r.z||0)}e.length>t.count&&Fe("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new kr);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ze("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new L(-1/0,-1/0,-1/0),new L(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n<s;n++){const r=t[n];pn.setFromBufferAttribute(r),this.morphTargetsRelative?(Bt.addVectors(this.boundingBox.min,pn.min),this.boundingBox.expandByPoint(Bt),Bt.addVectors(this.boundingBox.max,pn.max),this.boundingBox.expandByPoint(Bt)):(this.boundingBox.expandByPoint(pn.min),this.boundingBox.expandByPoint(pn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ze('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 xo);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ze("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new L,1/0);return}if(e){const n=this.boundingSphere.center;if(pn.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];fr.setFromBufferAttribute(o),this.morphTargetsRelative?(Bt.addVectors(pn.min,fr.min),pn.expandByPoint(Bt),Bt.addVectors(pn.max,fr.max),pn.expandByPoint(Bt)):(pn.expandByPoint(fr.min),pn.expandByPoint(fr.max))}pn.getCenter(n);let s=0;for(let r=0,a=e.count;r<a;r++)Bt.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(Bt));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)Bt.fromBufferAttribute(o,l),c&&(Ds.fromBufferAttribute(e,l),Bt.add(Ds)),s=Math.max(s,n.distanceToSquared(Bt))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&Ze('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ze("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,s=t.normal,r=t.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new ut(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],c=[];for(let _=0;_<n.count;_++)o[_]=new L,c[_]=new L;const l=new L,h=new L,u=new L,d=new Le,f=new Le,g=new Le,x=new L,m=new L;function p(_,E,C){l.fromBufferAttribute(n,_),h.fromBufferAttribute(n,E),u.fromBufferAttribute(n,C),d.fromBufferAttribute(r,_),f.fromBufferAttribute(r,E),g.fromBufferAttribute(r,C),h.sub(l),u.sub(l),f.sub(d),g.sub(d);const D=1/(f.x*g.y-g.x*f.y);isFinite(D)&&(x.copy(h).multiplyScalar(g.y).addScaledVector(u,-f.y).multiplyScalar(D),m.copy(u).multiplyScalar(f.x).addScaledVector(h,-g.x).multiplyScalar(D),o[_].add(x),o[E].add(x),o[C].add(x),c[_].add(m),c[E].add(m),c[C].add(m))}let A=this.groups;A.length===0&&(A=[{start:0,count:e.count}]);for(let _=0,E=A.length;_<E;++_){const C=A[_],D=C.start,I=C.count;for(let W=D,X=D+I;W<X;W+=3)p(e.getX(W+0),e.getX(W+1),e.getX(W+2))}const T=new L,M=new L,y=new L,b=new L;function R(_){y.fromBufferAttribute(s,_),b.copy(y);const E=o[_];T.copy(E),T.sub(y.multiplyScalar(y.dot(E))).normalize(),M.crossVectors(b,E);const D=M.dot(c[_])<0?-1:1;a.setXYZW(_,T.x,T.y,T.z,D)}for(let _=0,E=A.length;_<E;++_){const C=A[_],D=C.start,I=C.count;for(let W=D,X=D+I;W<X;W+=3)R(e.getX(W+0)),R(e.getX(W+1)),R(e.getX(W+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new ut(new Float32Array(t.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 L,r=new L,a=new L,o=new L,c=new L,l=new L,h=new L,u=new L;if(e)for(let d=0,f=e.count;d<f;d+=3){const g=e.getX(d+0),x=e.getX(d+1),m=e.getX(d+2);s.fromBufferAttribute(t,g),r.fromBufferAttribute(t,x),a.fromBufferAttribute(t,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=t.count;d<f;d+=3)s.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,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 e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Bt.fromBufferAttribute(e,t),Bt.normalize(),e.setXYZ(t,Bt.x,Bt.y,Bt.z)}toNonIndexed(){function e(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 ut(d,h,u)}if(this.index===null)return Fe("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Rt,n=this.index.array,s=this.attributes;for(const o in s){const c=s[o],l=e(c,n);t.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=e(d,n);c.push(f)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const 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(e.data))}h.length>0&&(s[c]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const s=e.attributes;for(const l in s){const h=s[l];this.setAttribute(l,h.clone(t))}const r=e.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(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.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=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Im{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=El,this.updateRanges=[],this.version=0,this.uuid=Ni()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let s=0,r=this.stride;s<r;s++)this.array[e+s]=t.array[n+s];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ni()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ni()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const jt=new L;class ro{constructor(e,t,n,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.applyMatrix4(e),this.setXYZ(t,jt.x,jt.y,jt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.applyNormalMatrix(e),this.setXYZ(t,jt.x,jt.y,jt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.transformDirection(e),this.setXYZ(t,jt.x,jt.y,jt.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Zn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=at(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=at(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=at(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=at(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=at(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Zn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Zn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Zn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Zn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=at(t,this.array),n=at(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=at(t,this.array),n=at(n,this.array),s=at(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=at(t,this.array),n=at(n,this.array),s=at(s,this.array),r=at(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this.data.array[e+3]=r,this}clone(e){if(e===void 0){so("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return new ut(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new ro(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){so("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let Lm=0;class ps extends fs{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Lm++}),this.uuid=Ni(),this.name="",this.type="Material",this.blending=Ks,this.side=Fi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Oc,this.blendDst=Fc,this.blendEquation=Qi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Me(0,0,0),this.blendAlpha=0,this.depthFunc=tr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Qh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=xs,this.stencilZFail=xs,this.stencilZPass=xs,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){Fe(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Fe(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={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(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Ks&&(n.blending=this.blending),this.side!==Fi&&(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!==Oc&&(n.blendSrc=this.blendSrc),this.blendDst!==Fc&&(n.blendDst=this.blendDst),this.blendEquation!==Qi&&(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!==tr&&(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!==Qh&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==xs&&(n.stencilFail=this.stencilFail),this.stencilZFail!==xs&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==xs&&(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(t){const r=s(e.textures),a=s(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Me().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Le().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Le().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const s=t.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Ar extends ps{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Me(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Cs;const pr=new L,Ps=new L,Is=new L,Ls=new Le,mr=new Le,w0=new dt,oa=new L,gr=new L,ca=new L,du=new Le,Qo=new Le,fu=new Le;class la extends Lt{constructor(e=new Ar){if(super(),this.isSprite=!0,this.type="Sprite",Cs===void 0){Cs=new Rt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Im(t,5);Cs.setIndex([0,1,2,0,2,3]),Cs.setAttribute("position",new ro(n,3,0,!1)),Cs.setAttribute("uv",new ro(n,2,3,!1))}this.geometry=Cs,this.material=e,this.center=new Le(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Ze('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ps.setFromMatrixScale(this.matrixWorld),w0.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Is.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ps.multiplyScalar(-Is.z);const n=this.material.rotation;let s,r;n!==0&&(r=Math.cos(n),s=Math.sin(n));const a=this.center;ha(oa.set(-.5,-.5,0),Is,a,Ps,s,r),ha(gr.set(.5,-.5,0),Is,a,Ps,s,r),ha(ca.set(.5,.5,0),Is,a,Ps,s,r),du.set(0,0),Qo.set(1,0),fu.set(1,1);let o=e.ray.intersectTriangle(oa,gr,ca,!1,pr);if(o===null&&(ha(gr.set(-.5,.5,0),Is,a,Ps,s,r),Qo.set(0,1),o=e.ray.intersectTriangle(oa,ca,gr,!1,pr),o===null))return;const c=e.ray.origin.distanceTo(pr);c<e.near||c>e.far||t.push({distance:c,point:pr.clone(),uv:bn.getInterpolation(pr,oa,gr,ca,du,Qo,fu,new Le),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function ha(i,e,t,n,s,r){Ls.subVectors(i,t).addScalar(.5).multiply(n),s!==void 0?(mr.x=r*Ls.x-s*Ls.y,mr.y=s*Ls.x+r*Ls.y):mr.copy(Ls),i.copy(e),i.x+=mr.x,i.y+=mr.y,i.applyMatrix4(w0)}const oi=new L,jo=new L,ua=new L,bi=new L,ec=new L,da=new L,tc=new L;class fh{constructor(e=new L,t=new L(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,oi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=oi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(oi.copy(this.origin).addScaledVector(this.direction,t),oi.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){jo.copy(e).add(t).multiplyScalar(.5),ua.copy(t).sub(e).normalize(),bi.copy(this.origin).sub(jo);const r=e.distanceTo(t)*.5,a=-this.direction.dot(ua),o=bi.dot(this.direction),c=-bi.dot(ua),l=bi.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(jo).addScaledVector(ua,d),f}intersectSphere(e,t){oi.subVectors(e.center,this.origin);const n=oi.dot(this.direction),s=oi.dot(oi)-n*n,r=e.radius*e.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,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,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=(e.min.x-d.x)*l,s=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,s=(e.min.x-d.x)*l),h>=0?(r=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(r=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),u>=0?(o=(e.min.z-d.z)*u,c=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,c=(e.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,t)}intersectsBox(e){return this.intersectBox(e,oi)!==null}intersectTriangle(e,t,n,s,r){ec.subVectors(t,e),da.subVectors(n,e),tc.crossVectors(ec,da);let a=this.direction.dot(tc),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;bi.subVectors(this.origin,e);const c=o*this.direction.dot(da.crossVectors(bi,da));if(c<0)return null;const l=o*this.direction.dot(ec.cross(bi));if(l<0||c+l>a)return null;const h=-o*bi.dot(tc);return h<0?null:this.at(h/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class cs extends ps{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Me(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 zi,this.combine=th,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const pu=new dt,Xi=new fh,fa=new xo,mu=new L,pa=new L,ma=new L,ga=new L,nc=new L,va=new L,gu=new L,_a=new L;class je extends Lt{constructor(e=new Rt,t=new cs){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[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(e,t){const n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(s,e);const o=this.morphTargetInfluences;if(r&&o){va.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const h=o[c],u=r[c];h!==0&&(nc.fromBufferAttribute(u,e),a?va.addScaledVector(nc,h):va.addScaledVector(nc.sub(t),h))}t.add(va)}return t}raycast(e,t){const n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),fa.copy(n.boundingSphere),fa.applyMatrix4(r),Xi.copy(e.ray).recast(e.near),!(fa.containsPoint(Xi.origin)===!1&&(Xi.intersectSphere(fa,mu)===null||Xi.origin.distanceToSquared(mu)>(e.far-e.near)**2))&&(pu.copy(r).invert(),Xi.copy(e.ray).applyMatrix4(pu),!(n.boundingBox!==null&&Xi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Xi)))}_computeIntersections(e,t,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),_=o.getX(M+2);s=xa(this,p,e,n,l,h,u,b,R,_),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=m.materialIndex,t.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=xa(this,a,e,n,l,h,u,A,T,M),s&&(s.faceIndex=Math.floor(m/3),t.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,_=M+2;s=xa(this,p,e,n,l,h,u,b,R,_),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=m.materialIndex,t.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=xa(this,a,e,n,l,h,u,A,T,M),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}}}function Nm(i,e,t,n,s,r,a,o){let c;if(e.side===It?c=n.intersectTriangle(a,r,s,!0,o):c=n.intersectTriangle(s,r,a,e.side===Fi,o),c===null)return null;_a.copy(o),_a.applyMatrix4(i.matrixWorld);const l=t.ray.origin.distanceTo(_a);return l<t.near||l>t.far?null:{distance:l,point:_a.clone(),object:i}}function xa(i,e,t,n,s,r,a,o,c,l){i.getVertexPosition(o,pa),i.getVertexPosition(c,ma),i.getVertexPosition(l,ga);const h=Nm(i,e,t,n,pa,ma,ga,gu);if(h){const u=new L;bn.getBarycoord(gu,pa,ma,ga,u),s&&(h.uv=bn.getInterpolatedAttribute(s,o,c,l,u,new Le)),r&&(h.uv1=bn.getInterpolatedAttribute(r,o,c,l,u,new Le)),a&&(h.normal=bn.getInterpolatedAttribute(a,o,c,l,u,new L),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new L,materialIndex:0};bn.getNormal(pa,ma,ga,d.normal),h.face=d,h.barycoord=u}return h}class Mo extends Jt{constructor(e=null,t=1,n=1,s,r,a,o,c,l=Nt,h=Nt,u,d){super(null,a,o,c,l,h,s,r,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const ic=new L,Um=new L,Om=new ze;class $i{constructor(e=new L(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const s=ic.subVectors(n,t).cross(Um.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){const s=e.delta(ic),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Om.getNormalMatrix(e),s=this.coplanarPoint(ic).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const qi=new xo,Fm=new Le(.5,.5),Ma=new L;class ph{constructor(e=new $i,t=new $i,n=new $i,s=new $i,r=new $i,a=new $i){this.planes=[e,t,n,s,r,a]}set(e,t,n,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Jn,n=!1){const s=this.planes,r=e.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(),t===Jn)s[5].setComponents(l+c,f+d,p+m,y+M).normalize();else if(t===Br)s[5].setComponents(c,d,m,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),qi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),qi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(qi)}intersectsSprite(e){qi.center.set(0,0,0);const t=Fm.distanceTo(e.center);return qi.radius=.7071067811865476+t,qi.applyMatrix4(e.matrixWorld),this.intersectsSphere(qi)}intersectsSphere(e){const t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const s=t[n];if(Ma.x=s.normal.x>0?e.max.x:e.min.x,Ma.y=s.normal.y>0?e.max.y:e.min.y,Ma.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(Ma)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class R0 extends ps{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Me(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const vu=new dt,bl=new fh,Sa=new xo,ya=new L;class Ka extends Lt{constructor(e=new Rt,t=new R0){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,s=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Sa.copy(n.boundingSphere),Sa.applyMatrix4(s),Sa.radius+=r,e.ray.intersectsSphere(Sa)===!1)return;vu.copy(s).invert(),bl.copy(e.ray).applyMatrix4(vu);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);ya.fromBufferAttribute(u,m),_u(ya,m,c,s,e,t,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++)ya.fromBufferAttribute(u,g),_u(ya,g,c,s,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[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 _u(i,e,t,n,s,r,a){const o=bl.distanceSqToPoint(i);if(o<t){const c=new L;bl.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:e,face:null,faceIndex:null,barycoord:null,object:a})}}class D0 extends Jt{constructor(e=[],t=as,n,s,r,a,o,c,l,h){super(e,t,n,s,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class gi extends Jt{constructor(e,t,n,s,r,a,o,c,l){super(e,t,n,s,r,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class ls extends Jt{constructor(e,t,n=On,s,r,a,o=Nt,c=Nt,l,h=mi,u=1){if(h!==mi&&h!==is)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,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(e){return super.copy(e),this.source=new hh(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class zm extends ls{constructor(e,t=On,n=as,s,r,a=Nt,o=Nt,c,l=mi){const h={width:e,height:e,depth:1},u=[h,h,h,h,h,h];super(e,e,t,n,s,r,a,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class C0 extends Jt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Tn extends Rt{constructor(e=1,t=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};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,t,e,a,r,0),g("z","y","x",1,-1,n,t,-e,a,r,1),g("x","z","y",1,1,e,n,t,s,a,2),g("x","z","y",1,-1,e,n,-t,s,a,3),g("x","y","z",1,-1,e,t,n,s,r,4),g("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(c),this.setAttribute("position",new Ut(l,3)),this.setAttribute("normal",new Ut(h,3)),this.setAttribute("uv",new Ut(u,2));function g(x,m,p,A,T,M,y,b,R,_,E){const C=M/R,D=y/_,I=M/2,W=y/2,X=b/2,O=R+1,q=_+1;let G=0,$=0;const te=new L;for(let j=0;j<q;j++){const ie=j*D-W;for(let ue=0;ue<O;ue++){const He=ue*C-I;te[x]=He*A,te[m]=ie*T,te[p]=X,l.push(te.x,te.y,te.z),te[x]=0,te[m]=0,te[p]=b>0?1:-1,h.push(te.x,te.y,te.z),u.push(ue/R),u.push(1-j/_),G+=1}}for(let j=0;j<_;j++)for(let ie=0;ie<R;ie++){const ue=d+ie+O*j,He=d+ie+O*(j+1),Ke=d+(ie+1)+O*(j+1),Be=d+(ie+1)+O*j;c.push(ue,He,Be),c.push(He,Ke,Be),$+=6}o.addGroup(f,$,E),f+=$,d+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Tn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class mh extends Rt{constructor(e=1,t=32,n=0,s=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:s},t=Math.max(3,t);const r=[],a=[],o=[],c=[],l=new L,h=new Le;a.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let u=0,d=3;u<=t;u++,d+=3){const f=n+u/t*s;l.x=e*Math.cos(f),l.y=e*Math.sin(f),a.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(a[d]/e+1)/2,h.y=(a[d+1]/e+1)/2,c.push(h.x,h.y)}for(let u=1;u<=t;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new Ut(a,3)),this.setAttribute("normal",new Ut(o,3)),this.setAttribute("uv",new Ut(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mh(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Hi extends Rt{constructor(e=1,t=1,n=1,s=32,r=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,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&&(e>0&&T(!0),t>0&&T(!1)),this.setIndex(h),this.setAttribute("position",new Ut(u,3)),this.setAttribute("normal",new Ut(d,3)),this.setAttribute("uv",new Ut(f,2));function A(){const M=new L,y=new L;let b=0;const R=(t-e)/n;for(let _=0;_<=r;_++){const E=[],C=_/r,D=C*(t-e)+e;for(let I=0;I<=s;I++){const W=I/s,X=W*c+o,O=Math.sin(X),q=Math.cos(X);y.x=D*O,y.y=-C*n+m,y.z=D*q,u.push(y.x,y.y,y.z),M.set(O,R,q).normalize(),d.push(M.x,M.y,M.z),f.push(W,1-C),E.push(g++)}x.push(E)}for(let _=0;_<s;_++)for(let E=0;E<r;E++){const C=x[E][_],D=x[E+1][_],I=x[E+1][_+1],W=x[E][_+1];(e>0||E!==0)&&(h.push(C,D,W),b+=3),(t>0||E!==r-1)&&(h.push(D,I,W),b+=3)}l.addGroup(p,b,0),p+=b}function T(M){const y=g,b=new Le,R=new L;let _=0;const E=M===!0?e:t,C=M===!0?1:-1;for(let I=1;I<=s;I++)u.push(0,m*C,0),d.push(0,C,0),f.push(.5,.5),g++;const D=g;for(let I=0;I<=s;I++){const X=I/s*c+o,O=Math.cos(X),q=Math.sin(X);R.x=E*q,R.y=m*C,R.z=E*O,u.push(R.x,R.y,R.z),d.push(0,C,0),b.x=O*.5+.5,b.y=q*.5*C+.5,f.push(b.x,b.y),g++}for(let I=0;I<s;I++){const W=y+I,X=D+I;M===!0?h.push(X,X+1,W):h.push(X+1,X,W),_+=3}l.addGroup(p,_,M===!0?1:2),p+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Hi(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class So extends Hi{constructor(e=1,t=1,n=32,s=1,r=!1,a=0,o=Math.PI*2){super(0,e,t,n,s,r,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:s,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(e){return new So(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class ki extends Rt{constructor(e=1,t=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:s};const r=e/2,a=t/2,o=Math.floor(n),c=Math.floor(s),l=o+1,h=c+1,u=e/o,d=t/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 Ut(g,3)),this.setAttribute("normal",new Ut(x,3)),this.setAttribute("uv",new Ut(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ki(e.width,e.height,e.widthSegments,e.heightSegments)}}class wn extends Rt{constructor(e=1,t=32,n=16,s=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:s,phiLength:r,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const c=Math.min(a+o,Math.PI);let l=0;const h=[],u=new L,d=new L,f=[],g=[],x=[],m=[];for(let p=0;p<=n;p++){const A=[],T=p/n,M=a+T*o,y=e*Math.cos(M),b=Math.sqrt(e*e-y*y);let R=0;p===0&&a===0?R=.5/t:p===n&&c===Math.PI&&(R=-.5/t);for(let _=0;_<=t;_++){const E=_/t,C=s+E*r;u.x=-b*Math.cos(C),u.y=y,u.z=b*Math.sin(C),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<t;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 Ut(g,3)),this.setAttribute("normal",new Ut(x,3)),this.setAttribute("uv",new Ut(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new wn(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}function ir(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const s=i[t][n];if(xu(s))s.isRenderTargetTexture?(Fe("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=s.clone();else if(Array.isArray(s))if(xu(s[0])){const r=[];for(let a=0,o=s.length;a<o;a++)r[a]=s[a].clone();e[t][n]=r}else e[t][n]=s.slice();else e[t][n]=s}}return e}function en(i){const e={};for(let t=0;t<i.length;t++){const n=ir(i[t]);for(const s in n)e[s]=n[s]}return e}function xu(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function Bm(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function P0(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:$e.workingColorSpace}const Hm={clone:ir,merge:en};var km=`void main() {
333
+ */const Uh="185",Wm=0,Nu=1,Xm=2,qr=1,qm=2,Br=3,qi=0,Ut=1,Fn=2,ii=0,ir=1,ai=2,Uu=3,Ou=4,Ym=5,as=100,Km=101,$m=102,Zm=103,Jm=104,Qm=200,jm=201,eg=202,tg=203,vl=204,_l=205,ng=206,ig=207,sg=208,rg=209,ag=210,og=211,cg=212,lg=213,hg=214,xl=0,Ml=1,yl=2,hr=3,Sl=4,El=5,bl=6,Al=7,Oh=0,ug=1,dg=2,si=0,Mf=1,yf=2,Sf=3,Ef=4,bf=5,Af=6,wf=7,Fu="attached",fg="detached",Tf=300,ps=301,ur=302,sc=303,rc=304,qo=306,Ao=1e3,rn=1001,wl=1002,Ot=1003,pg=1004,Ma=1005,At=1006,ac=1007,hs=1008,yn=1009,Rf=1010,Df=1011,ta=1012,Fh=1013,Hn=1014,Dn=1015,jt=1016,zh=1017,Bh=1018,na=1020,Cf=35902,Pf=35899,If=1021,Lf=1022,an=1023,Si=1026,us=1027,kh=1028,Hh=1029,ms=1030,Gh=1031,Vh=1033,vo=33776,_o=33777,xo=33778,Mo=33779,Tl=35840,Rl=35841,Dl=35842,Cl=35843,Pl=36196,Il=37492,Ll=37496,Nl=37488,Ul=37489,wo=37490,Ol=37491,Fl=37808,zl=37809,Bl=37810,kl=37811,Hl=37812,Gl=37813,Vl=37814,Wl=37815,Xl=37816,ql=37817,Yl=37818,Kl=37819,$l=37820,Zl=37821,Jl=36492,Ql=36494,jl=36495,eh=36283,th=36284,To=36285,nh=36286,Ro=2300,ih=2301,oc=2302,zu=2303,Bu=2400,ku=2401,Hu=2402,mg=2500,ZE=0,JE=1,QE=2,gg=3200,Do=0,vg=1,Hi="",Tn="srgb",Co="srgb-linear",Po="linear",st="srgb",Ts=7680,Gu=519,_g=512,xg=513,Mg=514,Wh=515,yg=516,Sg=517,Xh=518,Eg=519,sh=35044,Vu="300 es",ti=2e3,ia=2001;function bg(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Ag(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function sa(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function wg(){const i=sa("canvas");return i.style.display="block",i}const Wu={};function Io(...i){const e="THREE."+i.shift();console.log(e,...i)}function Nf(i){const e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Ae(...i){i=Nf(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function ze(...i){i=Nf(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function sr(...i){const e=i.join(" ");e in Wu||(Wu[e]=!0,Ae(...i))}function Tg(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}const Rg={[xl]:Ml,[yl]:bl,[Sl]:Al,[hr]:El,[Ml]:xl,[bl]:yl,[Al]:Sl,[El]:hr};class ys{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const s=n[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,e);e.target=null}}}const Yt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Xu=1234567;const Yr=Math.PI/180,dr=180/Math.PI;function kn(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Yt[i&255]+Yt[i>>8&255]+Yt[i>>16&255]+Yt[i>>24&255]+"-"+Yt[e&255]+Yt[e>>8&255]+"-"+Yt[e>>16&15|64]+Yt[e>>24&255]+"-"+Yt[t&63|128]+Yt[t>>8&255]+"-"+Yt[t>>16&255]+Yt[t>>24&255]+Yt[n&255]+Yt[n>>8&255]+Yt[n>>16&255]+Yt[n>>24&255]).toLowerCase()}function Ye(i,e,t){return Math.max(e,Math.min(t,i))}function qh(i,e){return(i%e+e)%e}function Dg(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function Cg(i,e,t){return i!==e?(t-i)/(e-i):0}function Kr(i,e,t){return(1-t)*i+t*e}function Pg(i,e,t,n){return Kr(i,e,1-Math.exp(-t*n))}function Ig(i,e=1){return e-Math.abs(qh(i,e*2)-e)}function Lg(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function Ng(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function Ug(i,e){return i+Math.floor(Math.random()*(e-i+1))}function Og(i,e){return i+Math.random()*(e-i)}function Fg(i){return i*(.5-Math.random())}function zg(i){i!==void 0&&(Xu=i);let e=Xu+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Bg(i){return i*Yr}function kg(i){return i*dr}function Hg(i){return(i&i-1)===0&&i!==0}function Gg(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Vg(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Wg(i,e,t,n,s){const r=Math.cos,a=Math.sin,o=r(t/2),c=a(t/2),l=r((e+n)/2),h=a((e+n)/2),u=r((e-n)/2),d=a((e-n)/2),f=r((n-e)/2),g=a((n-e)/2);switch(s){case"XYX":i.set(o*h,c*u,c*d,o*l);break;case"YZY":i.set(c*d,o*h,c*u,o*l);break;case"ZXZ":i.set(c*u,c*d,o*h,o*l);break;case"XZX":i.set(o*h,c*g,c*f,o*l);break;case"YXY":i.set(c*f,o*h,c*g,o*l);break;case"ZYZ":i.set(c*g,c*f,o*h,o*l);break;default:Ae("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function zn(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function rt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const jE={DEG2RAD:Yr,RAD2DEG:dr,generateUUID:kn,clamp:Ye,euclideanModulo:qh,mapLinear:Dg,inverseLerp:Cg,lerp:Kr,damp:Pg,pingpong:Ig,smoothstep:Lg,smootherstep:Ng,randInt:Ug,randFloat:Og,randFloatSpread:Fg,seededRandom:zg,degToRad:Bg,radToDeg:kg,isPowerOfTwo:Hg,ceilPowerOfTwo:Gg,floorPowerOfTwo:Vg,setQuaternionFromProperEuler:Wg,normalize:rt,denormalize:zn};class Ie{static{Ie.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Ye(this.x,e.x,t.x),this.y=Ye(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ye(this.x,e,t),this.y=Ye(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ye(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Ye(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*s+e.x,this.y=r*s+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ss{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,a,o){let 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 b=Math.acos(m),w=Math.sin(b);p=Math.sin(p*b)/w,o=Math.sin(o*b)/w,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 b=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=b,l*=b,h*=b,u*=b}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,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 e[t]=o*g+h*u+c*f-l*d,e[t+1]=c*g+h*d+l*u-o*f,e[t+2]=l*g+h*f+o*d-c*u,e[t+3]=h*g-o*u-c*d-l*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,s){return this._x=e,this._y=t,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,s=e._y,r=e._z,a=e._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:Ae("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],s=t[4],r=t[8],a=t[1],o=t[5],c=t[9],l=t[2],h=t[6],u=t[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(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ye(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const s=Math.min(1,t/n);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,s=e._y,r=e._z,a=e._w,o=t._x,c=t._y,l=t._z,h=t._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(e,t){let n=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let c=1-t;if(o<.9995){const l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,t=Math.sin(t*l)/h,this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this._onChangeCallback()}else this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class P{static{P.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(qu.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(qu.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,s=this.z,r=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*s-o*n),h=2*(o*t-r*s),u=2*(r*n-a*t);return this.x=t+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(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Ye(this.x,e.x,t.x),this.y=Ye(this.y,e.y,t.y),this.z=Ye(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ye(this.x,e,t),this.y=Ye(this.y,e,t),this.z=Ye(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ye(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,s=e.y,r=e.z,a=t.x,o=t.y,c=t.z;return this.x=s*c-r*o,this.y=r*a-n*c,this.z=n*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return cc.copy(this).projectOnVector(e),this.sub(cc)}reflect(e){return this.sub(cc.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Ye(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const cc=new P,qu=new Ss;class Be{static{Be.prototype.isMatrix3=!0}constructor(e,t,n,s,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,c,l)}set(e,t,n,s,r,a,o,c,l){const h=this.elements;return h[0]=e,h[1]=s,h[2]=o,h[3]=t,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(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.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],b=s[1],w=s[4],M=s[7],S=s[2],A=s[5],R=s[8];return r[0]=a*x+o*b+c*S,r[3]=a*m+o*w+c*A,r[6]=a*p+o*M+c*R,r[1]=l*x+h*b+u*S,r[4]=l*m+h*w+u*A,r[7]=l*p+h*M+u*R,r[2]=d*x+f*b+g*S,r[5]=d*m+f*w+g*A,r[8]=d*p+f*M+g*R,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8];return t*a*h-t*o*l-n*r*h+n*o*c+s*r*l-s*a*c}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=h*a-o*l,d=o*c-h*r,f=l*r-a*c,g=t*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 e[0]=u*x,e[1]=(s*l-h*n)*x,e[2]=(o*n-s*a)*x,e[3]=d*x,e[4]=(h*t-s*c)*x,e[5]=(s*r-o*t)*x,e[6]=f*x,e[7]=(n*c-l*t)*x,e[8]=(a*t-n*r)*x,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,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+e,-s*l,s*c,-s*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return sr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(lc.makeScale(e,t)),this}rotate(e){return sr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(lc.makeRotation(-e)),this}translate(e,t){return sr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(lc.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const lc=new Be,Yu=new Be().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Ku=new Be().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Xg(){const i={enabled:!0,workingColorSpace:Co,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===st&&(s.r=yi(s.r),s.g=yi(s.g),s.b=yi(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===st&&(s.r=rr(s.r),s.g=rr(s.g),s.b=rr(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===Hi?Po: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 sr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return sr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Co]:{primaries:e,whitePoint:n,transfer:Po,toXYZ:Yu,fromXYZ:Ku,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Tn},outputColorSpaceConfig:{drawingBufferColorSpace:Tn}},[Tn]:{primaries:e,whitePoint:n,transfer:st,toXYZ:Yu,fromXYZ:Ku,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Tn}}}),i}const Je=Xg();function yi(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function rr(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Rs;class qg{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Rs===void 0&&(Rs=sa("canvas")),Rs.width=e.width,Rs.height=e.height;const s=Rs.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=Rs}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=sa("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=yi(r[a]/255)*255;return n.putImageData(s,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(yi(t[n]/255)*255):t[n]=yi(t[n]);return{data:t,width:e.width,height:e.height}}else return Ae("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Yg=0;class Yh{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Yg++}),this.uuid=kn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.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(hc(s[a].image)):r.push(hc(s[a]))}else r=hc(s);n.url=r}return t||(e.images[this.uuid]=n),n}}function hc(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?qg.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Ae("Texture: Unable to serialize Texture."),{})}let Kg=0;const uc=new P;class Xt extends ys{constructor(e=Xt.DEFAULT_IMAGE,t=Xt.DEFAULT_MAPPING,n=rn,s=rn,r=At,a=hs,o=an,c=yn,l=Xt.DEFAULT_ANISOTROPY,h=Hi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Kg++}),this.uuid=kn(),this.name="",this.source=new Yh(e),this.mipmaps=[],this.mapping=t,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 Ie(0,0),this.repeat=new Ie(1,1),this.center=new Ie(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Be,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(uc).x}get height(){return this.source.getSize(uc).y}get depth(){return this.source.getSize(uc).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){Ae(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ae(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Tf)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ao:e.x=e.x-Math.floor(e.x);break;case rn:e.x=e.x<0?0:1;break;case wl:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ao:e.y=e.y-Math.floor(e.y);break;case rn:e.y=e.y<0?0:1;break;case wl:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Xt.DEFAULT_IMAGE=null;Xt.DEFAULT_MAPPING=Tf;Xt.DEFAULT_ANISOTROPY=1;class lt{static{lt.prototype.isVector4=!0}constructor(e=0,t=0,n=0,s=1){this.x=e,this.y=t,this.z=n,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,s,r;const c=e.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;t=Math.PI;const w=(l+1)/2,M=(f+1)/2,S=(p+1)/2,A=(h+d)/4,R=(u+x)/4,_=(g+m)/4;return w>M&&w>S?w<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(w),s=A/n,r=R/n):M>S?M<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(M),n=A/s,r=_/s):S<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(S),n=R/r,s=_/r),this.set(n,s,r,t),this}let b=Math.sqrt((m-g)*(m-g)+(u-x)*(u-x)+(d-h)*(d-h));return Math.abs(b)<.001&&(b=1),this.x=(m-g)/b,this.y=(u-x)/b,this.z=(d-h)/b,this.w=Math.acos((l+f+p-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Ye(this.x,e.x,t.x),this.y=Ye(this.y,e.y,t.y),this.z=Ye(this.z,e.z,t.z),this.w=Ye(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ye(this.x,e,t),this.y=Ye(this.y,e,t),this.z=Ye(this.z,e,t),this.w=Ye(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ye(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class $g extends ys{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:At,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new lt(0,0,e,t),this.scissorTest=!1,this.viewport=new lt(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:n.depth},r=new Xt(s),a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){const t={minFilter:At,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].image.depth=n,this.textures[s].isData3DTexture!==!0&&(this.textures[s].isArrayTexture=this.textures[s].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const s=Object.assign({},e.textures[t].image);this.textures[t].source=new Yh(s)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class fn extends $g{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class Uf extends Xt{constructor(e=null,t=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Ot,this.minFilter=Ot,this.wrapR=rn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Zg extends Xt{constructor(e=null,t=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Ot,this.minFilter=Ot,this.wrapR=rn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class qe{static{qe.prototype.isMatrix4=!0}constructor(e,t,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],e!==void 0&&this.set(e,t,n,s,r,a,o,c,l,h,u,d,f,g,x,m)}set(e,t,n,s,r,a,o,c,l,h,u,d,f,g,x,m){const p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=s,p[1]=r,p[5]=a,p[9]=o,p[13]=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 qe().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const t=this.elements,n=e.elements,s=1/Ds.setFromMatrixColumn(e,0).length(),r=1/Ds.setFromMatrixColumn(e,1).length(),a=1/Ds.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,s=e.y,r=e.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(e.order==="XYZ"){const d=a*h,f=a*u,g=o*h,x=o*u;t[0]=c*h,t[4]=-c*u,t[8]=l,t[1]=f+g*l,t[5]=d-x*l,t[9]=-o*c,t[2]=x-d*l,t[6]=g+f*l,t[10]=a*c}else if(e.order==="YXZ"){const d=c*h,f=c*u,g=l*h,x=l*u;t[0]=d+x*o,t[4]=g*o-f,t[8]=a*l,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=f*o-g,t[6]=x+d*o,t[10]=a*c}else if(e.order==="ZXY"){const d=c*h,f=c*u,g=l*h,x=l*u;t[0]=d-x*o,t[4]=-a*u,t[8]=g+f*o,t[1]=f+g*o,t[5]=a*h,t[9]=x-d*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const d=a*h,f=a*u,g=o*h,x=o*u;t[0]=c*h,t[4]=g*l-f,t[8]=d*l+x,t[1]=c*u,t[5]=x*l+d,t[9]=f*l-g,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const d=a*c,f=a*l,g=o*c,x=o*l;t[0]=c*h,t[4]=x-d*u,t[8]=g*u+f,t[1]=u,t[5]=a*h,t[9]=-o*h,t[2]=-l*h,t[6]=f*u+g,t[10]=d-x*u}else if(e.order==="XZY"){const d=a*c,f=a*l,g=o*c,x=o*l;t[0]=c*h,t[4]=-u,t[8]=l*h,t[1]=d*u+x,t[5]=a*h,t[9]=f*u-g,t[2]=g*u-f,t[6]=o*h,t[10]=x*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Jg,e,Qg)}lookAt(e,t,n){const s=this.elements;return mn.subVectors(e,t),mn.lengthSq()===0&&(mn.z=1),mn.normalize(),Pi.crossVectors(n,mn),Pi.lengthSq()===0&&(Math.abs(n.z)===1?mn.x+=1e-4:mn.z+=1e-4,mn.normalize(),Pi.crossVectors(n,mn)),Pi.normalize(),ya.crossVectors(mn,Pi),s[0]=Pi.x,s[4]=ya.x,s[8]=mn.x,s[1]=Pi.y,s[5]=ya.y,s[9]=mn.y,s[2]=Pi.z,s[6]=ya.z,s[10]=mn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.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],b=n[3],w=n[7],M=n[11],S=n[15],A=s[0],R=s[4],_=s[8],E=s[12],C=s[1],D=s[5],I=s[9],V=s[13],q=s[2],U=s[6],X=s[10],G=s[14],Z=s[3],te=s[7],j=s[11],ie=s[15];return r[0]=a*A+o*C+c*q+l*Z,r[4]=a*R+o*D+c*U+l*te,r[8]=a*_+o*I+c*X+l*j,r[12]=a*E+o*V+c*G+l*ie,r[1]=h*A+u*C+d*q+f*Z,r[5]=h*R+u*D+d*U+f*te,r[9]=h*_+u*I+d*X+f*j,r[13]=h*E+u*V+d*G+f*ie,r[2]=g*A+x*C+m*q+p*Z,r[6]=g*R+x*D+m*U+p*te,r[10]=g*_+x*I+m*X+p*j,r[14]=g*E+x*V+m*G+p*ie,r[3]=b*A+w*C+M*q+S*Z,r[7]=b*R+w*D+M*U+S*te,r[11]=b*_+w*I+M*X+S*j,r[15]=b*E+w*V+M*G+S*ie,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],s=e[8],r=e[12],a=e[1],o=e[5],c=e[9],l=e[13],h=e[2],u=e[6],d=e[10],f=e[14],g=e[3],x=e[7],m=e[11],p=e[15],b=c*f-l*d,w=o*f-l*u,M=o*d-c*u,S=a*f-l*h,A=a*d-c*h,R=a*u-o*h;return t*(x*b-m*w+p*M)-n*(g*b-m*S+p*A)+s*(g*w-x*S+p*R)-r*(g*M-x*A+m*R)}determinantAffine(){const e=this.elements,t=e[0],n=e[4],s=e[8],r=e[1],a=e[5],o=e[9],c=e[2],l=e[6],h=e[10];return t*(a*h-o*l)-n*(r*h-o*c)+s*(r*l-a*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=e[9],d=e[10],f=e[11],g=e[12],x=e[13],m=e[14],p=e[15],b=t*o-n*a,w=t*c-s*a,M=t*l-r*a,S=n*c-s*o,A=n*l-r*o,R=s*l-r*c,_=h*x-u*g,E=h*m-d*g,C=h*p-f*g,D=u*m-d*x,I=u*p-f*x,V=d*p-f*m,q=b*V-w*I+M*D+S*C-A*E+R*_;if(q===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const U=1/q;return e[0]=(o*V-c*I+l*D)*U,e[1]=(s*I-n*V-r*D)*U,e[2]=(x*R-m*A+p*S)*U,e[3]=(d*A-u*R-f*S)*U,e[4]=(c*C-a*V-l*E)*U,e[5]=(t*V-s*C+r*E)*U,e[6]=(m*M-g*R-p*w)*U,e[7]=(h*R-d*M+f*w)*U,e[8]=(a*I-o*C+l*_)*U,e[9]=(n*C-t*I-r*_)*U,e[10]=(g*A-x*M+p*b)*U,e[11]=(u*M-h*A-f*b)*U,e[12]=(o*E-a*D-c*_)*U,e[13]=(t*D-n*E+s*_)*U,e[14]=(x*w-g*S-m*b)*U,e[15]=(h*S-u*w+d*b)*U,this}scale(e){const t=this.elements,n=e.x,s=e.y,r=e.z;return t[0]*=n,t[4]*=s,t[8]*=r,t[1]*=n,t[5]*=s,t[9]*=r,t[2]*=n,t[6]*=s,t[10]*=r,t[3]*=n,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),s=Math.sin(t),r=1-n,a=e.x,o=e.y,c=e.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(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,s,r,a){return this.set(1,n,r,0,e,1,a,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){const s=this.elements,r=t._x,a=t._y,o=t._z,c=t._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,b=c*l,w=c*h,M=c*u,S=n.x,A=n.y,R=n.z;return s[0]=(1-(x+p))*S,s[1]=(f+M)*S,s[2]=(g-w)*S,s[3]=0,s[4]=(f-M)*A,s[5]=(1-(d+p))*A,s[6]=(m+b)*A,s[7]=0,s[8]=(g+w)*R,s[9]=(m-b)*R,s[10]=(1-(d+x))*R,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){const s=this.elements;e.x=s[12],e.y=s[13],e.z=s[14];const r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let a=Ds.set(s[0],s[1],s[2]).length();const o=Ds.set(s[4],s[5],s[6]).length(),c=Ds.set(s[8],s[9],s[10]).length();r<0&&(a=-a),In.copy(this);const l=1/a,h=1/o,u=1/c;return In.elements[0]*=l,In.elements[1]*=l,In.elements[2]*=l,In.elements[4]*=h,In.elements[5]*=h,In.elements[6]*=h,In.elements[8]*=u,In.elements[9]*=u,In.elements[10]*=u,t.setFromRotationMatrix(In),n.x=a,n.y=o,n.z=c,this}makePerspective(e,t,n,s,r,a,o=ti,c=!1){const l=this.elements,h=2*r/(t-e),u=2*r/(n-s),d=(t+e)/(t-e),f=(n+s)/(n-s);let g,x;if(c)g=r/(a-r),x=a*r/(a-r);else if(o===ti)g=-(a+r)/(a-r),x=-2*a*r/(a-r);else if(o===ia)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(e,t,n,s,r,a,o=ti,c=!1){const l=this.elements,h=2/(t-e),u=2/(n-s),d=-(t+e)/(t-e),f=-(n+s)/(n-s);let g,x;if(c)g=1/(a-r),x=a/(a-r);else if(o===ti)g=-2/(a-r),x=-(a+r)/(a-r);else if(o===ia)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(e){const t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Ds=new P,In=new qe,Jg=new P(0,0,0),Qg=new P(1,1,1),Pi=new P,ya=new P,mn=new P,$u=new qe,Zu=new Ss;class Ei{constructor(e=0,t=0,n=0,s=Ei.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const s=e.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(t){case"XYZ":this._y=Math.asin(Ye(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ye(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(Ye(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(-Ye(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(Ye(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(-Ye(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:Ae("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return $u.makeRotationFromQuaternion(e),this.setFromRotationMatrix($u,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Zu.setFromEuler(this),this.setFromQuaternion(Zu,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ei.DEFAULT_ORDER="XYZ";class Kh{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let jg=0;const Ju=new P,Cs=new Ss,ci=new qe,Sa=new P,Sr=new P,e1=new P,t1=new Ss,Qu=new P(1,0,0),ju=new P(0,1,0),ed=new P(0,0,1),td={type:"added"},n1={type:"removed"},Ps={type:"childadded",child:null},dc={type:"childremoved",child:null};class _t extends ys{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:jg++}),this.uuid=kn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=_t.DEFAULT_UP.clone();const e=new P,t=new Ei,n=new Ss,s=new P(1,1,1);function r(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new qe},normalMatrix:{value:new Be}}),this.matrix=new qe,this.matrixWorld=new qe,this.matrixAutoUpdate=_t.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Kh,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Cs.setFromAxisAngle(e,t),this.quaternion.multiply(Cs),this}rotateOnWorldAxis(e,t){return Cs.setFromAxisAngle(e,t),this.quaternion.premultiply(Cs),this}rotateX(e){return this.rotateOnAxis(Qu,e)}rotateY(e){return this.rotateOnAxis(ju,e)}rotateZ(e){return this.rotateOnAxis(ed,e)}translateOnAxis(e,t){return Ju.copy(e).applyQuaternion(this.quaternion),this.position.add(Ju.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Qu,e)}translateY(e){return this.translateOnAxis(ju,e)}translateZ(e){return this.translateOnAxis(ed,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ci.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Sa.copy(e):Sa.set(e,t,n);const s=this.parent;this.updateWorldMatrix(!0,!1),Sr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ci.lookAt(Sr,Sa,this.up):ci.lookAt(Sa,Sr,this.up),this.quaternion.setFromRotationMatrix(ci),s&&(ci.extractRotation(s.matrixWorld),Cs.setFromRotationMatrix(ci),this.quaternion.premultiply(Cs.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(ze("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(td),Ps.child=e,this.dispatchEvent(Ps),Ps.child=null):ze("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(n1),dc.child=e,this.dispatchEvent(dc),dc.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ci.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ci.multiply(e.parent.matrixWorld)),e.applyMatrix4(ci),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(td),Ps.child=e,this.dispatchEvent(Ps),Ps.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,s=this.children.length;n<s;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Sr,e,e1),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Sr,t1,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,n=e.y,s=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*s,r[13]+=n-r[1]*t-r[5]*n-r[9]*s,r[14]+=s-r[2]*t-r[6]*n-r[10]*s}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){const s=this.parent;if(e===!0&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){const r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,n)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});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(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);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(e.shapes,u)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(r(e.materials,this.material[c]));s.material=o}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];s.animations.push(r(e.animations,c))}}if(t){const o=a(e.geometries),c=a(e.materials),l=a(e.textures),h=a(e.images),u=a(e.shapes),d=a(e.skeletons),f=a(e.animations),g=a(e.nodes);o.length>0&&(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(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const s=e.children[n];this.add(s.clone())}return this}}_t.DEFAULT_UP=new P(0,1,0);_t.DEFAULT_MATRIX_AUTO_UPDATE=!0;_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Sn extends _t{constructor(){super(),this.isGroup=!0,this.type="Group"}}const i1={type:"move"};class fc{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Sn,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 Sn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new P),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Sn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new P,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let s=null,r=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(const x of e.hand.values()){const m=t.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:e.handedness,target:this})):!l.inputState.pinching&&d<=f-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.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:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(i1)))}return o!==null&&(o.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Sn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const Of={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},Ii={h:0,s:0,l:0},Ea={h:0,s:0,l:0};function pc(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class ve{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Tn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Je.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=Je.workingColorSpace){return this.r=e,this.g=t,this.b=n,Je.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=Je.workingColorSpace){if(e=qh(e,1),t=Ye(t,0,1),n=Ye(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=pc(a,r,e+1/3),this.g=pc(a,r,e),this.b=pc(a,r,e-1/3)}return Je.colorSpaceToWorking(this,s),this}setStyle(e,t=Tn){function n(r){r!==void 0&&parseFloat(r)<1&&Ae("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){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,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ae("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){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,t);if(a===6)return this.setHex(parseInt(r,16),t);Ae("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Tn){const n=Of[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Ae("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=yi(e.r),this.g=yi(e.g),this.b=yi(e.b),this}copyLinearToSRGB(e){return this.r=rr(e.r),this.g=rr(e.g),this.b=rr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Tn){return Je.workingToColorSpace(Kt.copy(this),e),Math.round(Ye(Kt.r*255,0,255))*65536+Math.round(Ye(Kt.g*255,0,255))*256+Math.round(Ye(Kt.b*255,0,255))}getHexString(e=Tn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Je.workingColorSpace){Je.workingToColorSpace(Kt.copy(this),t);const n=Kt.r,s=Kt.g,r=Kt.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 e.h=c,e.s=l,e.l=h,e}getRGB(e,t=Je.workingColorSpace){return Je.workingToColorSpace(Kt.copy(this),t),e.r=Kt.r,e.g=Kt.g,e.b=Kt.b,e}getStyle(e=Tn){Je.workingToColorSpace(Kt.copy(this),e);const t=Kt.r,n=Kt.g,s=Kt.b;return e!==Tn?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(Ii),this.setHSL(Ii.h+e,Ii.s+t,Ii.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Ii),e.getHSL(Ea);const n=Kr(Ii.h,Ea.h,t),s=Kr(Ii.s,Ea.s,t),r=Kr(Ii.l,Ea.l,t);return this.setHSL(n,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*s,this.g=r[1]*t+r[4]*n+r[7]*s,this.b=r[2]*t+r[5]*n+r[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Kt=new ve;ve.NAMES=Of;class $h{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new ve(e),this.near=t,this.far=n}clone(){return new $h(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Yo extends _t{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 Ei,this.environmentIntensity=1,this.environmentRotation=new Ei,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Ln=new P,li=new P,mc=new P,hi=new P,Is=new P,Ls=new P,nd=new P,gc=new P,vc=new P,_c=new P,xc=new lt,Mc=new lt,yc=new lt;class Rn{constructor(e=new P,t=new P,n=new P){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),Ln.subVectors(e,t),s.cross(Ln);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){Ln.subVectors(s,t),li.subVectors(n,t),mc.subVectors(e,t);const a=Ln.dot(Ln),o=Ln.dot(li),c=Ln.dot(mc),l=li.dot(li),h=li.dot(mc),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(e,t,n,s){return this.getBarycoord(e,t,n,s,hi)===null?!1:hi.x>=0&&hi.y>=0&&hi.x+hi.y<=1}static getInterpolation(e,t,n,s,r,a,o,c){return this.getBarycoord(e,t,n,s,hi)===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,hi.x),c.addScaledVector(a,hi.y),c.addScaledVector(o,hi.z),c)}static getInterpolatedAttribute(e,t,n,s,r,a){return xc.setScalar(0),Mc.setScalar(0),yc.setScalar(0),xc.fromBufferAttribute(e,t),Mc.fromBufferAttribute(e,n),yc.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(xc,r.x),a.addScaledVector(Mc,r.y),a.addScaledVector(yc,r.z),a}static isFrontFacing(e,t,n,s){return Ln.subVectors(n,t),li.subVectors(e,t),Ln.cross(li).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Ln.subVectors(this.c,this.b),li.subVectors(this.a,this.b),Ln.cross(li).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Rn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Rn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return Rn.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return Rn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Rn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,s=this.b,r=this.c;let a,o;Is.subVectors(s,n),Ls.subVectors(r,n),gc.subVectors(e,n);const c=Is.dot(gc),l=Ls.dot(gc);if(c<=0&&l<=0)return t.copy(n);vc.subVectors(e,s);const h=Is.dot(vc),u=Ls.dot(vc);if(h>=0&&u<=h)return t.copy(s);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),t.copy(n).addScaledVector(Is,a);_c.subVectors(e,r);const f=Is.dot(_c),g=Ls.dot(_c);if(g>=0&&f<=g)return t.copy(r);const x=f*l-c*g;if(x<=0&&l>=0&&g<=0)return o=l/(l-g),t.copy(n).addScaledVector(Ls,o);const m=h*g-f*u;if(m<=0&&u-h>=0&&f-g>=0)return nd.subVectors(r,s),o=(u-h)/(u-h+(f-g)),t.copy(s).addScaledVector(nd,o);const p=1/(m+x+d);return a=x*p,o=d*p,t.copy(n).addScaledVector(Is,a).addScaledVector(Ls,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class oi{constructor(e=new P(1/0,1/0,1/0),t=new P(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Nn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Nn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Nn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Nn):Nn.fromBufferAttribute(r,a),Nn.applyMatrix4(e.matrixWorld),this.expandByPoint(Nn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),ba.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),ba.copy(n.boundingBox)),ba.applyMatrix4(e.matrixWorld),this.union(ba)}const s=e.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Nn),Nn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Er),Aa.subVectors(this.max,Er),Ns.subVectors(e.a,Er),Us.subVectors(e.b,Er),Os.subVectors(e.c,Er),Li.subVectors(Us,Ns),Ni.subVectors(Os,Us),Ji.subVectors(Ns,Os);let t=[0,-Li.z,Li.y,0,-Ni.z,Ni.y,0,-Ji.z,Ji.y,Li.z,0,-Li.x,Ni.z,0,-Ni.x,Ji.z,0,-Ji.x,-Li.y,Li.x,0,-Ni.y,Ni.x,0,-Ji.y,Ji.x,0];return!Sc(t,Ns,Us,Os,Aa)||(t=[1,0,0,0,1,0,0,0,1],!Sc(t,Ns,Us,Os,Aa))?!1:(wa.crossVectors(Li,Ni),t=[wa.x,wa.y,wa.z],Sc(t,Ns,Us,Os,Aa))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Nn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Nn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(ui[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ui[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ui[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ui[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ui[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ui[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ui[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ui[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ui),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const ui=[new P,new P,new P,new P,new P,new P,new P,new P],Nn=new P,ba=new oi,Ns=new P,Us=new P,Os=new P,Li=new P,Ni=new P,Ji=new P,Er=new P,Aa=new P,wa=new P,Qi=new P;function Sc(i,e,t,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){Qi.fromArray(i,r);const o=s.x*Math.abs(Qi.x)+s.y*Math.abs(Qi.y)+s.z*Math.abs(Qi.z),c=e.dot(Qi),l=t.dot(Qi),h=n.dot(Qi);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const xi=s1();function s1(){const i=new ArrayBuffer(4),e=new Float32Array(i),t=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:e,uint32View:t,baseTable:n,shiftTable:s,mantissaTable:r,exponentTable:a,offsetTable:o}}function r1(i){Math.abs(i)>65504&&Ae("DataUtils.toHalfFloat(): Value out of range."),i=Ye(i,-65504,65504),xi.floatView[0]=i;const e=xi.uint32View[0],t=e>>23&511;return xi.baseTable[t]+((e&8388607)>>xi.shiftTable[t])}function a1(i){const e=i>>10;return xi.uint32View[0]=xi.mantissaTable[xi.offsetTable[e]+(i&1023)]+xi.exponentTable[e],xi.floatView[0]}class Wi{static toHalfFloat(e){return r1(e)}static fromHalfFloat(e){return a1(e)}}const Lt=new P,Ta=new Ie;let o1=0;class dt extends ys{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:o1++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=sh,this.updateRanges=[],this.gpuType=Dn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[e+s]=t.array[n+s];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Ta.fromBufferAttribute(this,t),Ta.applyMatrix3(e),this.setXY(t,Ta.x,Ta.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Lt.fromBufferAttribute(this,t),Lt.applyMatrix3(e),this.setXYZ(t,Lt.x,Lt.y,Lt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Lt.fromBufferAttribute(this,t),Lt.applyMatrix4(e),this.setXYZ(t,Lt.x,Lt.y,Lt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Lt.fromBufferAttribute(this,t),Lt.applyNormalMatrix(e),this.setXYZ(t,Lt.x,Lt.y,Lt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Lt.fromBufferAttribute(this,t),Lt.transformDirection(e),this.setXYZ(t,Lt.x,Lt.y,Lt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=zn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=rt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=zn(t,this.array)),t}setX(e,t){return this.normalized&&(t=rt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=zn(t,this.array)),t}setY(e,t){return this.normalized&&(t=rt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=zn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=rt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=zn(t,this.array)),t}setW(e,t){return this.normalized&&(t=rt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=rt(t,this.array),n=rt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=rt(t,this.array),n=rt(n,this.array),s=rt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e*=this.itemSize,this.normalized&&(t=rt(t,this.array),n=rt(n,this.array),s=rt(s,this.array),r=rt(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==sh&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class Ff extends dt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class zf extends dt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Pt extends dt{constructor(e,t,n){super(new Float32Array(e),t,n)}}const c1=new oi,br=new P,Ec=new P;class bi{constructor(e=new P,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):c1.setFromPoints(e).getCenter(n);let s=0;for(let r=0,a=e.length;r<a;r++)s=Math.max(s,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;br.subVectors(e,this.center);const t=br.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(br,s/n),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Ec.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(br.copy(e.center).add(Ec)),this.expandByPoint(br.copy(e.center).sub(Ec))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let l1=0;const bn=new qe,bc=new _t,Fs=new P,gn=new oi,Ar=new oi,kt=new P;class wt extends ys{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:l1++}),this.uuid=kn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(bg(e)?zf:Ff)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new Be().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return bn.makeRotationFromQuaternion(e),this.applyMatrix4(bn),this}rotateX(e){return bn.makeRotationX(e),this.applyMatrix4(bn),this}rotateY(e){return bn.makeRotationY(e),this.applyMatrix4(bn),this}rotateZ(e){return bn.makeRotationZ(e),this.applyMatrix4(bn),this}translate(e,t,n){return bn.makeTranslation(e,t,n),this.applyMatrix4(bn),this}scale(e,t,n){return bn.makeScale(e,t,n),this.applyMatrix4(bn),this}lookAt(e){return bc.lookAt(e),bc.updateMatrix(),this.applyMatrix4(bc.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Fs).negate(),this.translate(Fs.x,Fs.y,Fs.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let s=0,r=e.length;s<r;s++){const a=e[s];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Pt(n,3))}else{const n=Math.min(e.length,t.count);for(let s=0;s<n;s++){const r=e[s];t.setXYZ(s,r.x,r.y,r.z||0)}e.length>t.count&&Ae("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new oi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ze("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new P(-1/0,-1/0,-1/0),new P(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n<s;n++){const r=t[n];gn.setFromBufferAttribute(r),this.morphTargetsRelative?(kt.addVectors(this.boundingBox.min,gn.min),this.boundingBox.expandByPoint(kt),kt.addVectors(this.boundingBox.max,gn.max),this.boundingBox.expandByPoint(kt)):(this.boundingBox.expandByPoint(gn.min),this.boundingBox.expandByPoint(gn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ze('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 bi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ze("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new P,1/0);return}if(e){const n=this.boundingSphere.center;if(gn.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];Ar.setFromBufferAttribute(o),this.morphTargetsRelative?(kt.addVectors(gn.min,Ar.min),gn.expandByPoint(kt),kt.addVectors(gn.max,Ar.max),gn.expandByPoint(kt)):(gn.expandByPoint(Ar.min),gn.expandByPoint(Ar.max))}gn.getCenter(n);let s=0;for(let r=0,a=e.count;r<a;r++)kt.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(kt));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)kt.fromBufferAttribute(o,l),c&&(Fs.fromBufferAttribute(e,l),kt.add(Fs)),s=Math.max(s,n.distanceToSquared(kt))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&ze('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){ze("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,s=t.normal,r=t.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new dt(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],c=[];for(let _=0;_<n.count;_++)o[_]=new P,c[_]=new P;const l=new P,h=new P,u=new P,d=new Ie,f=new Ie,g=new Ie,x=new P,m=new P;function p(_,E,C){l.fromBufferAttribute(n,_),h.fromBufferAttribute(n,E),u.fromBufferAttribute(n,C),d.fromBufferAttribute(r,_),f.fromBufferAttribute(r,E),g.fromBufferAttribute(r,C),h.sub(l),u.sub(l),f.sub(d),g.sub(d);const D=1/(f.x*g.y-g.x*f.y);isFinite(D)&&(x.copy(h).multiplyScalar(g.y).addScaledVector(u,-f.y).multiplyScalar(D),m.copy(u).multiplyScalar(f.x).addScaledVector(h,-g.x).multiplyScalar(D),o[_].add(x),o[E].add(x),o[C].add(x),c[_].add(m),c[E].add(m),c[C].add(m))}let b=this.groups;b.length===0&&(b=[{start:0,count:e.count}]);for(let _=0,E=b.length;_<E;++_){const C=b[_],D=C.start,I=C.count;for(let V=D,q=D+I;V<q;V+=3)p(e.getX(V+0),e.getX(V+1),e.getX(V+2))}const w=new P,M=new P,S=new P,A=new P;function R(_){S.fromBufferAttribute(s,_),A.copy(S);const E=o[_];w.copy(E),w.sub(S.multiplyScalar(S.dot(E))).normalize(),M.crossVectors(A,E);const D=M.dot(c[_])<0?-1:1;a.setXYZW(_,w.x,w.y,w.z,D)}for(let _=0,E=b.length;_<E;++_){const C=b[_],D=C.start,I=C.count;for(let V=D,q=D+I;V<q;V+=3)R(e.getX(V+0)),R(e.getX(V+1)),R(e.getX(V+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new dt(new Float32Array(t.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 P,r=new P,a=new P,o=new P,c=new P,l=new P,h=new P,u=new P;if(e)for(let d=0,f=e.count;d<f;d+=3){const g=e.getX(d+0),x=e.getX(d+1),m=e.getX(d+2);s.fromBufferAttribute(t,g),r.fromBufferAttribute(t,x),a.fromBufferAttribute(t,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=t.count;d<f;d+=3)s.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,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 e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)kt.fromBufferAttribute(e,t),kt.normalize(),e.setXYZ(t,kt.x,kt.y,kt.z)}toNonIndexed(){function e(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 dt(d,h,u)}if(this.index===null)return Ae("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new wt,n=this.index.array,s=this.attributes;for(const o in s){const c=s[o],l=e(c,n);t.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=e(d,n);c.push(f)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const 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(e.data))}h.length>0&&(s[c]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const s=e.attributes;for(const l in s){const h=s[l];this.setAttribute(l,h.clone(t))}const r=e.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(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.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=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class h1{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=sh,this.updateRanges=[],this.version=0,this.uuid=kn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let s=0,r=this.stride;s<r;s++)this.array[e+s]=t.array[n+s];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=kn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=kn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const en=new P;class Lo{constructor(e,t,n,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)en.fromBufferAttribute(this,t),en.applyMatrix4(e),this.setXYZ(t,en.x,en.y,en.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)en.fromBufferAttribute(this,t),en.applyNormalMatrix(e),this.setXYZ(t,en.x,en.y,en.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)en.fromBufferAttribute(this,t),en.transformDirection(e),this.setXYZ(t,en.x,en.y,en.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=zn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=rt(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=rt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=rt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=rt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=rt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=zn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=zn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=zn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=zn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=rt(t,this.array),n=rt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=rt(t,this.array),n=rt(n,this.array),s=rt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=rt(t,this.array),n=rt(n,this.array),s=rt(s,this.array),r=rt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Io("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return new dt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Lo(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Io("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let u1=0;class Ai extends ys{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:u1++}),this.uuid=kn(),this.name="",this.type="Material",this.blending=ir,this.side=qi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=vl,this.blendDst=_l,this.blendEquation=as,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ve(0,0,0),this.blendAlpha=0,this.depthFunc=hr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Gu,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ts,this.stencilZFail=Ts,this.stencilZPass=Ts,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){Ae(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ae(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={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(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==ir&&(n.blending=this.blending),this.side!==qi&&(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!==vl&&(n.blendSrc=this.blendSrc),this.blendDst!==_l&&(n.blendDst=this.blendDst),this.blendEquation!==as&&(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!==hr&&(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!==Gu&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ts&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ts&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ts&&(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(t){const r=s(e.textures),a=s(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new ve().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Ie().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Ie().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const s=t.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class kr extends Ai{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ve(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let zs;const wr=new P,Bs=new P,ks=new P,Hs=new Ie,Tr=new Ie,Bf=new qe,Ra=new P,Rr=new P,Da=new P,id=new Ie,Ac=new Ie,sd=new Ie;class Ca extends _t{constructor(e=new kr){if(super(),this.isSprite=!0,this.type="Sprite",zs===void 0){zs=new wt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new h1(t,5);zs.setIndex([0,1,2,0,2,3]),zs.setAttribute("position",new Lo(n,3,0,!1)),zs.setAttribute("uv",new Lo(n,2,3,!1))}this.geometry=zs,this.material=e,this.center=new Ie(.5,.5),this.count=1}raycast(e,t){e.camera===null&&ze('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Bs.setFromMatrixScale(this.matrixWorld),Bf.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),ks.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Bs.multiplyScalar(-ks.z);const n=this.material.rotation;let s,r;n!==0&&(r=Math.cos(n),s=Math.sin(n));const a=this.center;Pa(Ra.set(-.5,-.5,0),ks,a,Bs,s,r),Pa(Rr.set(.5,-.5,0),ks,a,Bs,s,r),Pa(Da.set(.5,.5,0),ks,a,Bs,s,r),id.set(0,0),Ac.set(1,0),sd.set(1,1);let o=e.ray.intersectTriangle(Ra,Rr,Da,!1,wr);if(o===null&&(Pa(Rr.set(-.5,.5,0),ks,a,Bs,s,r),Ac.set(0,1),o=e.ray.intersectTriangle(Ra,Da,Rr,!1,wr),o===null))return;const c=e.ray.origin.distanceTo(wr);c<e.near||c>e.far||t.push({distance:c,point:wr.clone(),uv:Rn.getInterpolation(wr,Ra,Rr,Da,id,Ac,sd,new Ie),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Pa(i,e,t,n,s,r){Hs.subVectors(i,t).addScalar(.5).multiply(n),s!==void 0?(Tr.x=r*Hs.x-s*Hs.y,Tr.y=s*Hs.x+r*Hs.y):Tr.copy(Hs),i.copy(e),i.x+=Tr.x,i.y+=Tr.y,i.applyMatrix4(Bf)}const di=new P,wc=new P,Ia=new P,Ui=new P,Tc=new P,La=new P,Rc=new P;class aa{constructor(e=new P,t=new P(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,di)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=di.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(di.copy(this.origin).addScaledVector(this.direction,t),di.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){wc.copy(e).add(t).multiplyScalar(.5),Ia.copy(t).sub(e).normalize(),Ui.copy(this.origin).sub(wc);const r=e.distanceTo(t)*.5,a=-this.direction.dot(Ia),o=Ui.dot(this.direction),c=-Ui.dot(Ia),l=Ui.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(wc).addScaledVector(Ia,d),f}intersectSphere(e,t){di.subVectors(e.center,this.origin);const n=di.dot(this.direction),s=di.dot(di)-n*n,r=e.radius*e.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,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,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=(e.min.x-d.x)*l,s=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,s=(e.min.x-d.x)*l),h>=0?(r=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(r=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),u>=0?(o=(e.min.z-d.z)*u,c=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,c=(e.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,t)}intersectsBox(e){return this.intersectBox(e,di)!==null}intersectTriangle(e,t,n,s,r){Tc.subVectors(t,e),La.subVectors(n,e),Rc.crossVectors(Tc,La);let a=this.direction.dot(Rc),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ui.subVectors(this.origin,e);const c=o*this.direction.dot(La.crossVectors(Ui,La));if(c<0)return null;const l=o*this.direction.dot(Tc.cross(Ui));if(l<0||c+l>a)return null;const h=-o*Ui.dot(Rc);return h<0?null:this.at(h/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class gs extends Ai{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ve(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ei,this.combine=Oh,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const rd=new qe,ji=new aa,Na=new bi,ad=new P,Ua=new P,Oa=new P,Fa=new P,Dc=new P,za=new P,od=new P,Ba=new P;class Qe extends _t{constructor(e=new wt,t=new gs){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[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(e,t){const n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(s,e);const o=this.morphTargetInfluences;if(r&&o){za.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const h=o[c],u=r[c];h!==0&&(Dc.fromBufferAttribute(u,e),a?za.addScaledVector(Dc,h):za.addScaledVector(Dc.sub(t),h))}t.add(za)}return t}raycast(e,t){const n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Na.copy(n.boundingSphere),Na.applyMatrix4(r),ji.copy(e.ray).recast(e.near),!(Na.containsPoint(ji.origin)===!1&&(ji.intersectSphere(Na,ad)===null||ji.origin.distanceToSquared(ad)>(e.far-e.near)**2))&&(rd.copy(r).invert(),ji.copy(e.ray).applyMatrix4(rd),!(n.boundingBox!==null&&ji.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,ji)))}_computeIntersections(e,t,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],b=Math.max(m.start,f.start),w=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let M=b,S=w;M<S;M+=3){const A=o.getX(M),R=o.getX(M+1),_=o.getX(M+2);s=ka(this,p,e,n,l,h,u,A,R,_),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=m.materialIndex,t.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 b=o.getX(m),w=o.getX(m+1),M=o.getX(m+2);s=ka(this,a,e,n,l,h,u,b,w,M),s&&(s.faceIndex=Math.floor(m/3),t.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],b=Math.max(m.start,f.start),w=Math.min(c.count,Math.min(m.start+m.count,f.start+f.count));for(let M=b,S=w;M<S;M+=3){const A=M,R=M+1,_=M+2;s=ka(this,p,e,n,l,h,u,A,R,_),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=m.materialIndex,t.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 b=m,w=m+1,M=m+2;s=ka(this,a,e,n,l,h,u,b,w,M),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}}}function d1(i,e,t,n,s,r,a,o){let c;if(e.side===Ut?c=n.intersectTriangle(a,r,s,!0,o):c=n.intersectTriangle(s,r,a,e.side===qi,o),c===null)return null;Ba.copy(o),Ba.applyMatrix4(i.matrixWorld);const l=t.ray.origin.distanceTo(Ba);return l<t.near||l>t.far?null:{distance:l,point:Ba.clone(),object:i}}function ka(i,e,t,n,s,r,a,o,c,l){i.getVertexPosition(o,Ua),i.getVertexPosition(c,Oa),i.getVertexPosition(l,Fa);const h=d1(i,e,t,n,Ua,Oa,Fa,od);if(h){const u=new P;Rn.getBarycoord(od,Ua,Oa,Fa,u),s&&(h.uv=Rn.getInterpolatedAttribute(s,o,c,l,u,new Ie)),r&&(h.uv1=Rn.getInterpolatedAttribute(r,o,c,l,u,new Ie)),a&&(h.normal=Rn.getInterpolatedAttribute(a,o,c,l,u,new P),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new P,materialIndex:0};Rn.getNormal(Ua,Oa,Fa,d.normal),h.face=d,h.barycoord=u}return h}const Dr=new lt,cd=new lt,ld=new lt,f1=new lt,hd=new qe,Ha=new P,Cc=new bi,ud=new qe,Pc=new aa;class eb extends Qe{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Fu,this.bindMatrix=new qe,this.bindMatrixInverse=new qe,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new oi),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ha),this.boundingBox.expandByPoint(Ha)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new bi),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ha),this.boundingSphere.expandByPoint(Ha)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,s=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Cc.copy(this.boundingSphere),Cc.applyMatrix4(s),e.ray.intersectsSphere(Cc)!==!1&&(ud.copy(s).invert(),Pc.copy(e.ray).applyMatrix4(ud),!(this.boundingBox!==null&&Pc.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Pc)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new lt,t=this.geometry.attributes.skinWeight;for(let n=0,s=t.count;n<s;n++){e.fromBufferAttribute(t,n);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Fu?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===fg?this.bindMatrixInverse.copy(this.bindMatrix).invert():Ae("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,s=this.geometry;cd.fromBufferAttribute(s.attributes.skinIndex,e),ld.fromBufferAttribute(s.attributes.skinWeight,e),t.isVector4?(Dr.copy(t),t.set(0,0,0,0)):(Dr.set(...t,1),t.set(0,0,0)),Dr.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){const a=ld.getComponent(r);if(a!==0){const o=cd.getComponent(r);hd.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(f1.copy(Dr).applyMatrix4(hd),a)}}return t.isVector4&&(t.w=Dr.w),t.applyMatrix4(this.bindMatrixInverse)}}class p1 extends _t{constructor(){super(),this.isBone=!0,this.type="Bone"}}class gr extends Xt{constructor(e=null,t=1,n=1,s,r,a,o,c,l=Ot,h=Ot,u,d){super(null,a,o,c,l,h,s,r,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const dd=new qe,m1=new qe;class kf{constructor(e=[],t=[]){this.uuid=kn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Ae("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,s=this.bones.length;n<s;n++)this.boneInverses.push(new qe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new qe;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,s=this.boneTexture;for(let r=0,a=e.length;r<a;r++){const o=e[r]?e[r].matrixWorld:m1;dd.multiplyMatrices(o,t[r]),dd.toArray(n,r*16)}s!==null&&(s.needsUpdate=!0)}clone(){return new kf(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new gr(t,e,e,an,Dn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const s=this.bones[t];if(s.name===e)return s}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,s=e.bones.length;n<s;n++){const r=e.bones[n];let a=t[r];a===void 0&&(Ae("Skeleton: No bone found with UUID:",r),a=new p1),this.bones.push(a),this.boneInverses.push(new qe().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let s=0,r=t.length;s<r;s++){const a=t[s];e.bones.push(a.uuid);const o=n[s];e.boneInverses.push(o.toArray())}return e}}class fd extends dt{constructor(e,t,n,s=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Gs=new qe,pd=new qe,Ga=[],md=new oi,g1=new qe,Cr=new Qe,Pr=new bi;class tb extends Qe{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new fd(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let s=0;s<n;s++)this.setMatrixAt(s,g1)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new oi),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Gs),md.copy(e.boundingBox).applyMatrix4(Gs),this.boundingBox.union(md)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new bi),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Gs),Pr.copy(e.boundingSphere).applyMatrix4(Gs),this.boundingSphere.union(Pr)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,s=this.morphTexture.source.data.data,r=n.length+1,a=e*r+1;for(let o=0;o<n.length;o++)n[o]=s[a+o]}raycast(e,t){const n=this.matrixWorld,s=this.count;if(Cr.geometry=this.geometry,Cr.material=this.material,Cr.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Pr.copy(this.boundingSphere),Pr.applyMatrix4(n),e.ray.intersectsSphere(Pr)!==!1))for(let r=0;r<s;r++){this.getMatrixAt(r,Gs),pd.multiplyMatrices(n,Gs),Cr.matrixWorld=pd,Cr.raycast(e,Ga);for(let a=0,o=Ga.length;a<o;a++){const c=Ga[a];c.instanceId=r,c.object=this,t.push(c)}Ga.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new fd(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){const n=t.morphTargetInfluences,s=n.length+1;this.morphTexture===null&&(this.morphTexture=new gr(new Float32Array(s*this.count),s,this.count,kh,Dn));const r=this.morphTexture.source.data.data;let a=0;for(let l=0;l<n.length;l++)a+=n[l];const o=this.geometry.morphTargetsRelative?1:1-a,c=s*e;return r[c]=o,r.set(n,c+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Ic=new P,v1=new P,_1=new Be;class ss{constructor(e=new P(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const s=Ic.subVectors(n,t).cross(v1.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){const s=e.delta(Ic),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||_1.getNormalMatrix(e),s=this.coplanarPoint(Ic).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const es=new bi,x1=new Ie(.5,.5),Va=new P;class Zh{constructor(e=new ss,t=new ss,n=new ss,s=new ss,r=new ss,a=new ss){this.planes=[e,t,n,s,r,a]}set(e,t,n,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=ti,n=!1){const s=this.planes,r=e.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],b=r[12],w=r[13],M=r[14],S=r[15];if(s[0].setComponents(l-a,f-h,p-g,S-b).normalize(),s[1].setComponents(l+a,f+h,p+g,S+b).normalize(),s[2].setComponents(l+o,f+u,p+x,S+w).normalize(),s[3].setComponents(l-o,f-u,p-x,S-w).normalize(),n)s[4].setComponents(c,d,m,M).normalize(),s[5].setComponents(l-c,f-d,p-m,S-M).normalize();else if(s[4].setComponents(l-c,f-d,p-m,S-M).normalize(),t===ti)s[5].setComponents(l+c,f+d,p+m,S+M).normalize();else if(t===ia)s[5].setComponents(c,d,m,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),es.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),es.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(es)}intersectsSprite(e){es.center.set(0,0,0);const t=x1.distanceTo(e.center);return es.radius=.7071067811865476+t,es.applyMatrix4(e.matrixWorld),this.intersectsSphere(es)}intersectsSphere(e){const t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const s=t[n];if(Va.x=s.normal.x>0?e.max.x:e.min.x,Va.y=s.normal.y>0?e.max.y:e.min.y,Va.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(Va)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class M1 extends Ai{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ve(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const No=new P,Uo=new P,gd=new qe,Ir=new aa,Wa=new bi,Lc=new P,vd=new P;class Hf extends _t{constructor(e=new wt,t=new M1){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let s=1,r=t.count;s<r;s++)No.fromBufferAttribute(t,s-1),Uo.fromBufferAttribute(t,s),n[s]=n[s-1],n[s]+=No.distanceTo(Uo);e.setAttribute("lineDistance",new Pt(n,1))}else Ae("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,s=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Wa.copy(n.boundingSphere),Wa.applyMatrix4(s),Wa.radius+=r,e.ray.intersectsSphere(Wa)===!1)return;gd.copy(s).invert(),Ir.copy(e.ray).applyMatrix4(gd);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){const f=Math.max(0,a.start),g=Math.min(h.count,a.start+a.count);for(let x=f,m=g-1;x<m;x+=l){const p=h.getX(x),b=h.getX(x+1),w=Xa(this,e,Ir,c,p,b,x);w&&t.push(w)}if(this.isLineLoop){const x=h.getX(g-1),m=h.getX(f),p=Xa(this,e,Ir,c,x,m,g-1);p&&t.push(p)}}else{const f=Math.max(0,a.start),g=Math.min(d.count,a.start+a.count);for(let x=f,m=g-1;x<m;x+=l){const p=Xa(this,e,Ir,c,x,x+1,x);p&&t.push(p)}if(this.isLineLoop){const x=Xa(this,e,Ir,c,g-1,f,g-1);x&&t.push(x)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[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 Xa(i,e,t,n,s,r,a){const o=i.geometry.attributes.position;if(No.fromBufferAttribute(o,s),Uo.fromBufferAttribute(o,r),t.distanceSqToSegment(No,Uo,Lc,vd)>n)return;Lc.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(Lc);if(!(l<e.near||l>e.far))return{distance:l,point:vd.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}const _d=new P,xd=new P;class nb extends Hf{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let s=0,r=t.count;s<r;s+=2)_d.fromBufferAttribute(t,s),xd.fromBufferAttribute(t,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+_d.distanceTo(xd);e.setAttribute("lineDistance",new Pt(n,1))}else Ae("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class ib extends Hf{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Gf extends Ai{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ve(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Md=new qe,rh=new aa,qa=new bi,Ya=new P;class yo extends _t{constructor(e=new wt,t=new Gf){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,s=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),qa.copy(n.boundingSphere),qa.applyMatrix4(s),qa.radius+=r,e.ray.intersectsSphere(qa)===!1)return;Md.copy(s).invert(),rh.copy(e.ray).applyMatrix4(Md);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);Ya.fromBufferAttribute(u,m),yd(Ya,m,c,s,e,t,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++)Ya.fromBufferAttribute(u,g),yd(Ya,g,c,s,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[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 yd(i,e,t,n,s,r,a){const o=rh.distanceSqToPoint(i);if(o<t){const c=new P;rh.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:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Vf extends Xt{constructor(e=[],t=ps,n,s,r,a,o,c,l,h){super(e,t,n,s,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class wi extends Xt{constructor(e,t,n,s,r,a,o,c,l){super(e,t,n,s,r,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class vs extends Xt{constructor(e,t,n=Hn,s,r,a,o=Ot,c=Ot,l,h=Si,u=1){if(h!==Si&&h!==us)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,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(e){return super.copy(e),this.source=new Yh(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class y1 extends vs{constructor(e,t=Hn,n=ps,s,r,a=Ot,o=Ot,c,l=Si){const h={width:e,height:e,depth:1},u=[h,h,h,h,h,h];super(e,e,t,n,s,r,a,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Wf extends Xt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Cn extends wt{constructor(e=1,t=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};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,t,e,a,r,0),g("z","y","x",1,-1,n,t,-e,a,r,1),g("x","z","y",1,1,e,n,t,s,a,2),g("x","z","y",1,-1,e,n,-t,s,a,3),g("x","y","z",1,-1,e,t,n,s,r,4),g("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(c),this.setAttribute("position",new Pt(l,3)),this.setAttribute("normal",new Pt(h,3)),this.setAttribute("uv",new Pt(u,2));function g(x,m,p,b,w,M,S,A,R,_,E){const C=M/R,D=S/_,I=M/2,V=S/2,q=A/2,U=R+1,X=_+1;let G=0,Z=0;const te=new P;for(let j=0;j<X;j++){const ie=j*D-V;for(let ue=0;ue<U;ue++){const He=ue*C-I;te[x]=He*b,te[m]=ie*w,te[p]=q,l.push(te.x,te.y,te.z),te[x]=0,te[m]=0,te[p]=A>0?1:-1,h.push(te.x,te.y,te.z),u.push(ue/R),u.push(1-j/_),G+=1}}for(let j=0;j<_;j++)for(let ie=0;ie<R;ie++){const ue=d+ie+U*j,He=d+ie+U*(j+1),Ze=d+(ie+1)+U*(j+1),ke=d+(ie+1)+U*j;c.push(ue,He,ke),c.push(He,Ze,ke),Z+=6}o.addGroup(f,Z,E),f+=Z,d+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Cn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Jh extends wt{constructor(e=1,t=32,n=0,s=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:s},t=Math.max(3,t);const r=[],a=[],o=[],c=[],l=new P,h=new Ie;a.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let u=0,d=3;u<=t;u++,d+=3){const f=n+u/t*s;l.x=e*Math.cos(f),l.y=e*Math.sin(f),a.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(a[d]/e+1)/2,h.y=(a[d+1]/e+1)/2,c.push(h.x,h.y)}for(let u=1;u<=t;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new Pt(a,3)),this.setAttribute("normal",new Pt(o,3)),this.setAttribute("uv",new Pt(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Jh(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Ki extends wt{constructor(e=1,t=1,n=1,s=32,r=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,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;b(),a===!1&&(e>0&&w(!0),t>0&&w(!1)),this.setIndex(h),this.setAttribute("position",new Pt(u,3)),this.setAttribute("normal",new Pt(d,3)),this.setAttribute("uv",new Pt(f,2));function b(){const M=new P,S=new P;let A=0;const R=(t-e)/n;for(let _=0;_<=r;_++){const E=[],C=_/r,D=C*(t-e)+e;for(let I=0;I<=s;I++){const V=I/s,q=V*c+o,U=Math.sin(q),X=Math.cos(q);S.x=D*U,S.y=-C*n+m,S.z=D*X,u.push(S.x,S.y,S.z),M.set(U,R,X).normalize(),d.push(M.x,M.y,M.z),f.push(V,1-C),E.push(g++)}x.push(E)}for(let _=0;_<s;_++)for(let E=0;E<r;E++){const C=x[E][_],D=x[E+1][_],I=x[E+1][_+1],V=x[E][_+1];(e>0||E!==0)&&(h.push(C,D,V),A+=3),(t>0||E!==r-1)&&(h.push(D,I,V),A+=3)}l.addGroup(p,A,0),p+=A}function w(M){const S=g,A=new Ie,R=new P;let _=0;const E=M===!0?e:t,C=M===!0?1:-1;for(let I=1;I<=s;I++)u.push(0,m*C,0),d.push(0,C,0),f.push(.5,.5),g++;const D=g;for(let I=0;I<=s;I++){const q=I/s*c+o,U=Math.cos(q),X=Math.sin(q);R.x=E*X,R.y=m*C,R.z=E*U,u.push(R.x,R.y,R.z),d.push(0,C,0),A.x=U*.5+.5,A.y=X*.5*C+.5,f.push(A.x,A.y),g++}for(let I=0;I<s;I++){const V=S+I,q=D+I;M===!0?h.push(q,q+1,V):h.push(q+1,q,V),_+=3}l.addGroup(p,_,M===!0?1:2),p+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ki(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ko extends Ki{constructor(e=1,t=1,n=32,s=1,r=!1,a=0,o=Math.PI*2){super(0,e,t,n,s,r,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:s,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Ko(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class $i extends wt{constructor(e=1,t=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:s};const r=e/2,a=t/2,o=Math.floor(n),c=Math.floor(s),l=o+1,h=c+1,u=e/o,d=t/c,f=[],g=[],x=[],m=[];for(let p=0;p<h;p++){const b=p*d-a;for(let w=0;w<l;w++){const M=w*u-r;g.push(M,-b,0),x.push(0,0,1),m.push(w/o),m.push(1-p/c)}}for(let p=0;p<c;p++)for(let b=0;b<o;b++){const w=b+l*p,M=b+l*(p+1),S=b+1+l*(p+1),A=b+1+l*p;f.push(w,M,A),f.push(M,S,A)}this.setIndex(f),this.setAttribute("position",new Pt(g,3)),this.setAttribute("normal",new Pt(x,3)),this.setAttribute("uv",new Pt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $i(e.width,e.height,e.widthSegments,e.heightSegments)}}class Pn extends wt{constructor(e=1,t=32,n=16,s=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:s,phiLength:r,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const c=Math.min(a+o,Math.PI);let l=0;const h=[],u=new P,d=new P,f=[],g=[],x=[],m=[];for(let p=0;p<=n;p++){const b=[],w=p/n,M=a+w*o,S=e*Math.cos(M),A=Math.sqrt(e*e-S*S);let R=0;p===0&&a===0?R=.5/t:p===n&&c===Math.PI&&(R=-.5/t);for(let _=0;_<=t;_++){const E=_/t,C=s+E*r;u.x=-A*Math.cos(C),u.y=S,u.z=A*Math.sin(C),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-w),b.push(l++)}h.push(b)}for(let p=0;p<n;p++)for(let b=0;b<t;b++){const w=h[p][b+1],M=h[p][b],S=h[p+1][b],A=h[p+1][b+1];(p!==0||a>0)&&f.push(w,M,A),(p!==n-1||c<Math.PI)&&f.push(M,S,A)}this.setIndex(f),this.setAttribute("position",new Pt(g,3)),this.setAttribute("normal",new Pt(x,3)),this.setAttribute("uv",new Pt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Pn(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}function fr(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const s=i[t][n];if(Sd(s))s.isRenderTargetTexture?(Ae("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=s.clone();else if(Array.isArray(s))if(Sd(s[0])){const r=[];for(let a=0,o=s.length;a<o;a++)r[a]=s[a].clone();e[t][n]=r}else e[t][n]=s.slice();else e[t][n]=s}}return e}function tn(i){const e={};for(let t=0;t<i.length;t++){const n=fr(i[t]);for(const s in n)e[s]=n[s]}return e}function Sd(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function S1(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function Xf(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Je.workingColorSpace}const E1={clone:fr,merge:tn};var b1=`void main() {
334
334
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
335
- }`,Gm=`void main() {
335
+ }`,A1=`void main() {
336
336
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
337
- }`;class At extends ps{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=km,this.fragmentShader=Gm,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=ir(e.uniforms),this.uniformsGroups=Bm(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const s in this.uniforms){const a=this.uniforms[s].value;a&&a.isTexture?t.uniforms[s]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[s]={type:"m4",value:a.toArray()}:t.uniforms[s]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const n in e.uniforms){const s=e.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=t[s.value]||null;break;case"c":this.uniforms[n].value=new Me().setHex(s.value);break;case"v2":this.uniforms[n].value=new Le().fromArray(s.value);break;case"v3":this.uniforms[n].value=new L().fromArray(s.value);break;case"v4":this.uniforms[n].value=new vt().fromArray(s.value);break;case"m3":this.uniforms[n].value=new ze().fromArray(s.value);break;case"m4":this.uniforms[n].value=new dt().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Vm extends At{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Gr extends ps{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Me(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Me(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yl,this.normalScale=new Le(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new zi,this.combine=th,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(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Wm extends ps{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=em,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Xm extends ps{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class gh extends Lt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Me(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class qm extends gh{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Lt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Me(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}const sc=new dt,Mu=new L,Su=new L;class I0{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Le(512,512),this.mapType=xn,this.map=null,this.mapPass=null,this.matrix=new dt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ph,this._frameExtents=new Le(1,1),this._viewportCount=1,this._viewports=[new vt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Mu.setFromMatrixPosition(e.matrixWorld),t.position.copy(Mu),Su.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Su),t.updateMatrixWorld(),sc.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(sc,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===Br||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(sc)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const Ea=new L,Aa=new ar,Hn=new L;class L0 extends Lt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new dt,this.projectionMatrix=new dt,this.projectionMatrixInverse=new dt,this.coordinateSystem=Jn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(Ea,Aa,Hn),Hn.x===1&&Hn.y===1&&Hn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Ea,Aa,Hn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Ea,Aa,Hn),Hn.x===1&&Hn.y===1&&Hn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Ea,Aa,Hn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Ti=new L,yu=new Le,Eu=new Le;class _n extends L0{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Al*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Lo*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Al*2*Math.atan(Math.tan(Lo*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Ti.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ti.x,Ti.y).multiplyScalar(-e/Ti.z),Ti.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Ti.x,Ti.y).multiplyScalar(-e/Ti.z)}getViewSize(e,t){return this.getViewBounds(e,yu,Eu),t.subVectors(Eu,yu)}setViewOffset(e,t,n,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Lo*.5*this.fov)/this.zoom,n=2*t,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,t-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Ym extends I0{constructor(){super(new _n(90,1,.5,500)),this.isPointLightShadow=!0}}class Km extends gh{constructor(e,t,n=0,s=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=s,this.shadow=new Ym}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class or extends L0{constructor(e=-1,t=1,n=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=n-e,a=n+e,o=s+t,c=s-t;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(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class Zm extends I0{constructor(){super(new or(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class $m extends gh{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Lt.DEFAULT_UP),this.updateMatrix(),this.target=new Lt,this.shadow=new Zm}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}const Ns=-90,Us=1;class Jm extends Lt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new _n(Ns,Us,e,t);s.layers=this.layers,this.add(s);const r=new _n(Ns,Us,e,t);r.layers=this.layers,this.add(r);const a=new _n(Ns,Us,e,t);a.layers=this.layers,this.add(a);const o=new _n(Ns,Us,e,t);o.layers=this.layers,this.add(o);const c=new _n(Ns,Us,e,t);c.layers=this.layers,this.add(c);const l=new _n(Ns,Us,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,s,r,a,o,c]=t;for(const l of t)this.remove(l);if(e===Jn)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(e===Br)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: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,c,l,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const x=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(n,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(n,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),n.texture.generateMipmaps=x,e.setRenderTarget(n,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(u,d,f),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class Qm extends _n{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Au=new dt;class rc{constructor(e,t,n=0,s=1/0){this.ray=new fh(e,t),this.near=n,this.far=s,this.camera=null,this.layers=new uh,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):Ze("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Au.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Au),this}intersectObject(e,t=!0,n=[]){return Tl(e,this,n,t),n.sort(bu),n}intersectObjects(e,t=!0,n=[]){for(let s=0,r=e.length;s<r;s++)Tl(e[s],this,n,t);return n.sort(bu),n}}function bu(i,e){return i.distance-e.distance}function Tl(i,e,t,n){let s=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(s=!1),s===!0&&n===!0){const r=i.children;for(let a=0,o=r.length;a<o;a++)Tl(r[a],e,t,!0)}}class N0{static{N0.prototype.isMatrix2=!0}constructor(e,t,n,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,s){const r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=s,this}}function Tu(i,e,t,n){const s=jm(n);switch(t){case x0:return i*e;case S0:return i*e/s.components*s.byteLength;case rh:return i*e/s.components*s.byteLength;case os:return i*e*2/s.components*s.byteLength;case ah:return i*e*2/s.components*s.byteLength;case M0:return i*e*3/s.components*s.byteLength;case hn:return i*e*4/s.components*s.byteLength;case oh:return i*e*4/s.components*s.byteLength;case Wa:case Xa:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case qa:case Ya:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Yc:case Zc:return Math.max(i,16)*Math.max(e,8)/4;case qc:case Kc:return Math.max(i,8)*Math.max(e,8)/2;case $c:case Jc:case jc:case el:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Qc:case ja:case tl:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case nl:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case il:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case sl:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case rl:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case al:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case ol:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case cl:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case ll:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case hl:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case ul:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case dl:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case fl:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case pl:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case ml:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case gl:case vl:case _l:return Math.ceil(i/4)*Math.ceil(e/4)*16;case xl:case Ml:return Math.ceil(i/4)*Math.ceil(e/4)*8;case eo:case Sl:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function jm(i){switch(i){case xn:case m0:return{byteLength:1,components:1};case Fr:case g0:case Qt:return{byteLength:2,components:1};case ih:case sh:return{byteLength:2,components:4};case On:case nh:case $n:return{byteLength:4,components:1};case v0:case _0: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:eh}}));typeof window<"u"&&(window.__THREE__?Fe("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=eh);/**
337
+ }`;class Tt extends Ai{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=b1,this.fragmentShader=A1,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=fr(e.uniforms),this.uniformsGroups=S1(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const s in this.uniforms){const a=this.uniforms[s].value;a&&a.isTexture?t.uniforms[s]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[s]={type:"m4",value:a.toArray()}:t.uniforms[s]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const n in e.uniforms){const s=e.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=t[s.value]||null;break;case"c":this.uniforms[n].value=new ve().setHex(s.value);break;case"v2":this.uniforms[n].value=new Ie().fromArray(s.value);break;case"v3":this.uniforms[n].value=new P().fromArray(s.value);break;case"v4":this.uniforms[n].value=new lt().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Be().fromArray(s.value);break;case"m4":this.uniforms[n].value=new qe().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class w1 extends Tt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class T1 extends Ai{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new ve(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Do,this.normalScale=new Ie(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ei,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class sb extends T1{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ie(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ye(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ve(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new ve(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ve(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class oa extends Ai{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ve(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Do,this.normalScale=new Ie(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ei,this.combine=Oh,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(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class R1 extends Ai{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=gg,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class D1 extends Ai{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function Ka(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function C1(i){function e(s,r){return i[s]-i[r]}const t=i.length,n=new Array(t);for(let s=0;s!==t;++s)n[s]=s;return n.sort(e),n}function Ed(i,e,t){const n=i.length,s=new i.constructor(n);for(let r=0,a=0;a!==n;++r){const o=t[r]*e;for(let c=0;c!==e;++c)s[a++]=i[o+c]}return s}function P1(i,e,t,n){let s=1,r=i[0];for(;r!==void 0&&r[n]===void 0;)r=i[s++];if(r===void 0)return;let a=r[n];if(a!==void 0)if(Array.isArray(a))do a=r[n],a!==void 0&&(e.push(r.time),t.push(...a)),r=i[s++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[n],a!==void 0&&(e.push(r.time),a.toArray(t,t.length)),r=i[s++];while(r!==void 0);else do a=r[n],a!==void 0&&(e.push(r.time),t.push(a)),r=i[s++];while(r!==void 0)}class ca{constructor(e,t,n,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,s=t[n],r=t[n-1];n:{e:{let a;t:{i:if(!(e<s)){for(let o=n+2;;){if(s===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=s,s=t[++n],e<s)break e}a=t.length;break t}if(!(e>=r)){const o=t[1];e<o&&(n=2,r=o);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(s=r,r=t[--n-1],e>=r)break e}a=n,n=0;break t}break n}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(s=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,e,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s;for(let a=0;a!==s;++a)t[a]=n[r+a];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class I1 extends ca{constructor(e,t,n,s){super(e,t,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Bu,endingEnd:Bu}}intervalChanged_(e,t,n){const s=this.parameterPositions;let r=e-2,a=e+1,o=s[r],c=s[a];if(o===void 0)switch(this.getSettings_().endingStart){case ku:r=e,o=2*t-n;break;case Hu:r=s.length-2,o=t+s[r]-s[r+1];break;default:r=e,o=n}if(c===void 0)switch(this.getSettings_().endingEnd){case ku:a=e,c=2*n-t;break;case Hu:a=1,c=n+s[1]-s[0];break;default:a=e-1,c=t}const l=(n-t)*.5,h=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(e,t,n,s){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,g=(n-t)/(s-t),x=g*g,m=x*g,p=-d*m+2*d*x-d*g,b=(1+d)*m+(-1.5-2*d)*x+(-.5+d)*g+1,w=(-1-f)*m+(1.5+f)*x+.5*g,M=f*m-f*x;for(let S=0;S!==o;++S)r[S]=p*a[h+S]+b*a[l+S]+w*a[c+S]+M*a[u+S];return r}}class L1 extends ca{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=(n-t)/(s-t),u=1-h;for(let d=0;d!==o;++d)r[d]=a[l+d]*u+a[c+d]*h;return r}}class N1 extends ca{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e){return this.copySampleValue_(e-1)}}class U1 extends ca{interpolate_(e,t,n,s){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this.inTangents,u=this.outTangents;if(!h||!u){const g=(n-t)/(s-t),x=1-g;for(let m=0;m!==o;++m)r[m]=a[l+m]*x+a[c+m]*g;return r}const d=o*2,f=e-1;for(let g=0;g!==o;++g){const x=a[l+g],m=a[c+g],p=f*d+g*2,b=u[p],w=u[p+1],M=e*d+g*2,S=h[M],A=h[M+1];let R=(n-t)/(s-t),_,E,C,D,I;for(let V=0;V<8;V++){_=R*R,E=_*R,C=1-R,D=C*C,I=D*C;const U=I*t+3*D*R*b+3*C*_*S+E*s-n;if(Math.abs(U)<1e-10)break;const X=3*D*(b-t)+6*C*R*(S-b)+3*_*(s-S);if(Math.abs(X)<1e-10)break;R=R-U/X,R=Math.max(0,Math.min(1,R))}r[g]=I*x+3*D*R*w+3*C*_*A+E*m}return r}}class Gn{constructor(e,t,n,s){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Ka(t,this.TimeBufferType),this.values=Ka(n,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Ka(e.times,Array),values:Ka(e.values,Array)};const s=e.getInterpolation();s!==e.DefaultInterpolation&&(n.interpolation=s)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new N1(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new L1(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new I1(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){const t=new U1(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case Ro:t=this.InterpolantFactoryMethodDiscrete;break;case ih:t=this.InterpolantFactoryMethodLinear;break;case oc:t=this.InterpolantFactoryMethodSmooth;break;case zu:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return Ae("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ro;case this.InterpolantFactoryMethodLinear:return ih;case this.InterpolantFactoryMethodSmooth:return oc;case this.InterpolantFactoryMethodBezier:return zu}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]*=e}return this}trim(e,t){const n=this.times,s=n.length;let r=0,a=s-1;for(;r!==s&&n[r]<e;)++r;for(;a!==-1&&n[a]>t;)--a;if(++a,r!==0||a!==s){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(ze("KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,s=this.values,r=n.length;r===0&&(ze("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){const c=n[o];if(typeof c=="number"&&isNaN(c)){ze("KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(a!==null&&a>c){ze("KeyframeTrack: Out of order keys.",this,o,c,a),e=!1;break}a=c}if(s!==void 0&&Ag(s))for(let o=0,c=s.length;o!==c;++o){const l=s[o];if(isNaN(l)){ze("KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===oc,r=e.length-1;let a=1;for(let o=1;o<r;++o){let c=!1;const l=e[o],h=e[o+1];if(l!==h&&(o!==1||l!==e[0]))if(s)c=!0;else{const u=o*n,d=u-n,f=u+n;for(let g=0;g!==n;++g){const x=t[u+g];if(x!==t[d+g]||x!==t[f+g]){c=!0;break}}}if(c){if(o!==a){e[a]=e[o];const u=o*n,d=a*n;for(let f=0;f!==n;++f)t[d+f]=t[u+f]}++a}}if(r>0){e[a]=e[r];for(let o=r*n,c=a*n,l=0;l!==n;++l)t[c+l]=t[o+l];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,s}}Gn.prototype.ValueTypeName="";Gn.prototype.TimeBufferType=Float32Array;Gn.prototype.ValueBufferType=Float32Array;Gn.prototype.DefaultInterpolation=ih;class vr extends Gn{constructor(e,t,n){super(e,t,n)}}vr.prototype.ValueTypeName="bool";vr.prototype.ValueBufferType=Array;vr.prototype.DefaultInterpolation=Ro;vr.prototype.InterpolantFactoryMethodLinear=void 0;vr.prototype.InterpolantFactoryMethodSmooth=void 0;class qf extends Gn{constructor(e,t,n,s){super(e,t,n,s)}}qf.prototype.ValueTypeName="color";class Qh extends Gn{constructor(e,t,n,s){super(e,t,n,s)}}Qh.prototype.ValueTypeName="number";class O1 extends ca{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-t)/(s-t);let l=e*o;for(let h=l+o;l!==h;l+=4)Ss.slerpFlat(r,0,a,l-o,a,l,c);return r}}class jh extends Gn{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new O1(this.times,this.values,this.getValueSize(),e)}}jh.prototype.ValueTypeName="quaternion";jh.prototype.InterpolantFactoryMethodSmooth=void 0;class _r extends Gn{constructor(e,t,n){super(e,t,n)}}_r.prototype.ValueTypeName="string";_r.prototype.ValueBufferType=Array;_r.prototype.DefaultInterpolation=Ro;_r.prototype.InterpolantFactoryMethodLinear=void 0;_r.prototype.InterpolantFactoryMethodSmooth=void 0;class Yf extends Gn{constructor(e,t,n,s){super(e,t,n,s)}}Yf.prototype.ValueTypeName="vector";class rb{constructor(e="",t=-1,n=[],s=mg){this.name=e,this.tracks=n,this.duration=t,this.blendMode=s,this.uuid=kn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,s=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(z1(n[a]).scale(s));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){const t=[],n=e.tracks,s={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,a=n.length;r!==a;++r)t.push(Gn.toJSON(n[r]));return s}static CreateFromMorphTargetSequence(e,t,n,s){const r=t.length,a=[];for(let o=0;o<r;o++){let c=[],l=[];c.push((o+r-1)%r,o,(o+1)%r),l.push(0,1,0);const h=C1(c);c=Ed(c,1,h),l=Ed(l,1,h),!s&&c[0]===0&&(c.push(r),l.push(l[0])),a.push(new Qh(".morphTargetInfluences["+t[o].name+"]",c,l).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const s=e;n=s.geometry&&s.geometry.animations||s.animations}for(let s=0;s<n.length;s++)if(n[s].name===t)return n[s];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const s={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,c=e.length;o<c;o++){const l=e[o],h=l.name.match(r);if(h&&h.length>1){const u=h[1];let d=s[u];d||(s[u]=d=[]),d.push(l)}}const a=[];for(const o in s)a.push(this.CreateFromMorphTargetSequence(o,s[o],t,n));return a}resetDuration(){const e=this.tracks;let t=0;for(let n=0,s=e.length;n!==s;++n){const r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function F1(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Qh;case"vector":case"vector2":case"vector3":case"vector4":return Yf;case"color":return qf;case"quaternion":return jh;case"bool":case"boolean":return vr;case"string":return _r}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function z1(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=F1(i.type);if(i.times===void 0){const t=[],n=[];P1(i.keys,t,n,"value"),i.times=t,i.values=n}return e.parse!==void 0?e.parse(i):new e(i.name,i.times,i.values,i.interpolation)}const Mi={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(bd(i)||(this.files[i]=e))},get:function(i){if(this.enabled!==!1&&!bd(i))return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};function bd(i){try{const e=i.slice(i.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}class B1{constructor(e,t,n){const s=this;let r=!1,a=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(h){o++,r===!1&&s.onStart!==void 0&&s.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,s.onProgress!==void 0&&s.onProgress(h,a,o),a===o&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){const u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){const f=l[u],g=l[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return g}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const k1=new B1;class la{constructor(e){this.manager=e!==void 0?e:k1,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){const n=this;return new Promise(function(s,r){n.load(e,s,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}la.DEFAULT_MATERIAL_NAME="__DEFAULT";const fi={};class H1 extends Error{constructor(e,t){super(e),this.response=t}}class ab extends la{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=Mi.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0);return}if(fi[e]!==void 0){fi[e].push({onLoad:t,onProgress:n,onError:s});return}fi[e]=[],fi[e].push({onLoad:t,onProgress:n,onError:s});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,c=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&Ae("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const h=fi[e],u=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),f=d?parseInt(d):0,g=f!==0;let x=0;const m=new ReadableStream({start(p){b();function b(){u.read().then(({done:w,value:M})=>{if(w)p.close();else{x+=M.byteLength;const S=new ProgressEvent("progress",{lengthComputable:g,loaded:x,total:f});for(let A=0,R=h.length;A<R;A++){const _=h[A];_.onProgress&&_.onProgress(S)}p.enqueue(M),b()}},w=>{p.error(w)})}}});return new Response(m)}else throw new H1(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return l.json();default:if(o==="")return l.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return l.arrayBuffer().then(g=>f.decode(g))}}}).then(l=>{Mi.add(`file:${e}`,l);const h=fi[e];delete fi[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(l)}}).catch(l=>{const h=fi[e];if(h===void 0)throw this.manager.itemError(e),l;delete fi[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onError&&f.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const Vs=new WeakMap;class G1 extends la{constructor(e){super(e)}load(e,t,n,s){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Mi.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)r.manager.itemStart(e),setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);else{let u=Vs.get(a);u===void 0&&(u=[],Vs.set(a,u)),u.push({onLoad:t,onError:s})}return a}const o=sa("img");function c(){h(),t&&t(this);const u=Vs.get(this)||[];for(let d=0;d<u.length;d++){const f=u[d];f.onLoad&&f.onLoad(this)}Vs.delete(this),r.manager.itemEnd(e)}function l(u){h(),s&&s(u),Mi.remove(`image:${e}`);const d=Vs.get(this)||[];for(let f=0;f<d.length;f++){const g=d[f];g.onError&&g.onError(u)}Vs.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function h(){o.removeEventListener("load",c,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),Mi.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class ob extends la{constructor(e){super(e)}load(e,t,n,s){const r=new Xt,a=new G1(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){r.image=o,r.needsUpdate=!0,t!==void 0&&t(r)},n,s),r}}class $o extends _t{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new ve(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class V1 extends $o{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ve(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}const Nc=new qe,Ad=new P,wd=new P;class eu{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ie(512,512),this.mapType=yn,this.map=null,this.mapPass=null,this.matrix=new qe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Zh,this._frameExtents=new Ie(1,1),this._viewportCount=1,this._viewports=[new lt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Ad.setFromMatrixPosition(e.matrixWorld),t.position.copy(Ad),wd.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(wd),t.updateMatrixWorld(),Nc.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Nc,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===ia||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Nc)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const $a=new P,Za=new Ss,qn=new P;class Kf extends _t{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new qe,this.projectionMatrix=new qe,this.projectionMatrixInverse=new qe,this.coordinateSystem=ti,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose($a,Za,qn),qn.x===1&&qn.y===1&&qn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose($a,Za,qn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose($a,Za,qn),qn.x===1&&qn.y===1&&qn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose($a,Za,qn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Oi=new P,Td=new Ie,Rd=new Ie;class dn extends Kf{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=dr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Yr*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return dr*2*Math.atan(Math.tan(Yr*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Oi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Oi.x,Oi.y).multiplyScalar(-e/Oi.z),Oi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Oi.x,Oi.y).multiplyScalar(-e/Oi.z)}getViewSize(e,t){return this.getViewBounds(e,Td,Rd),t.subVectors(Rd,Td)}setViewOffset(e,t,n,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Yr*.5*this.fov)/this.zoom,n=2*t,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,t-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class W1 extends eu{constructor(){super(new dn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=dr*2*e.angle*this.focus,s=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;(n!==t.fov||s!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=s,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class cb extends $o{constructor(e,t,n=0,s=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.distance=n,this.angle=s,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new W1}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class X1 extends eu{constructor(){super(new dn(90,1,.5,500)),this.isPointLightShadow=!0}}class q1 extends $o{constructor(e,t,n=0,s=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=s,this.shadow=new X1}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class xr extends Kf{constructor(e=-1,t=1,n=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=n-e,a=n+e,o=s+t,c=s-t;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(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class Y1 extends eu{constructor(){super(new xr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class K1 extends $o{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.shadow=new Y1}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class lb{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}const Uc=new WeakMap;class hb extends la{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&Ae("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Ae("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Mi.get(`image-bitmap:${e}`);if(a!==void 0){if(r.manager.itemStart(e),a.then){a.then(l=>{Uc.has(a)===!0?(s&&s(Uc.get(a)),r.manager.itemError(e),r.manager.itemEnd(e)):(t&&t(l),r.manager.itemEnd(e))});return}setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);return}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const c=fetch(e,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){Mi.add(`image-bitmap:${e}`,l),t&&t(l),r.manager.itemEnd(e)}).catch(function(l){s&&s(l),Uc.set(c,l),Mi.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});Mi.add(`image-bitmap:${e}`,c),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const Ws=-90,Xs=1;class $1 extends _t{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new dn(Ws,Xs,e,t);s.layers=this.layers,this.add(s);const r=new dn(Ws,Xs,e,t);r.layers=this.layers,this.add(r);const a=new dn(Ws,Xs,e,t);a.layers=this.layers,this.add(a);const o=new dn(Ws,Xs,e,t);o.layers=this.layers,this.add(o);const c=new dn(Ws,Xs,e,t);c.layers=this.layers,this.add(c);const l=new dn(Ws,Xs,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,s,r,a,o,c]=t;for(const l of t)this.remove(l);if(e===ti)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(e===ia)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: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,c,l,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const x=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(n,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(n,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),n.texture.generateMipmaps=x,e.setRenderTarget(n,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(u,d,f),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class Z1 extends dn{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const tu="\\[\\]\\.:\\/",J1=new RegExp("["+tu+"]","g"),nu="[^"+tu+"]",Q1="[^"+tu.replace("\\.","")+"]",j1=/((?:WC+[\/:])*)/.source.replace("WC",nu),e2=/(WCOD+)?/.source.replace("WCOD",Q1),t2=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",nu),n2=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",nu),i2=new RegExp("^"+j1+e2+t2+n2+"$"),s2=["material","materials","bones","map"];class r2{constructor(e,t,n){const s=n||ct.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class ct{constructor(e,t,n){this.path=t,this.parsedPath=n||ct.parseTrackName(t),this.node=ct.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new ct.Composite(e,t,n):new ct(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(J1,"")}static parseTrackName(e){const t=i2.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){const r=n.nodeName.substring(s+1);s2.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(r){for(let a=0;a<r.length;a++){const o=r[a];if(o.name===t||o.uuid===t)return o;const c=n(o.children);if(c)return c}return null},s=n(e.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)e[t++]=n[s]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,s=t.propertyName;let r=t.propertyIndex;if(e||(e=ct.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ae("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){ze("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){ze("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){ze("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){ze("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){ze("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){ze("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){ze("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}const a=e[s];if(a===void 0){const l=t.nodeName;ze("PropertyBinding: Trying to update property for track: "+l+"."+s+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(s==="morphTargetInfluences"){if(!e.geometry){ze("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){ze("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(c=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=s;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ct.Composite=r2;ct.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ct.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ct.prototype.GetterByBindingType=[ct.prototype._getValue_direct,ct.prototype._getValue_array,ct.prototype._getValue_arrayElement,ct.prototype._getValue_toArray];ct.prototype.SetterByBindingTypeAndVersioning=[[ct.prototype._setValue_direct,ct.prototype._setValue_direct_setNeedsUpdate,ct.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_array,ct.prototype._setValue_array_setNeedsUpdate,ct.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_arrayElement,ct.prototype._setValue_arrayElement_setNeedsUpdate,ct.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_fromArray,ct.prototype._setValue_fromArray_setNeedsUpdate,ct.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const Dd=new qe;class Oc{constructor(e,t,n=0,s=1/0){this.ray=new aa(e,t),this.near=n,this.far=s,this.camera=null,this.layers=new Kh,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):ze("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Dd.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Dd),this}intersectObject(e,t=!0,n=[]){return ah(e,this,n,t),n.sort(Cd),n}intersectObjects(e,t=!0,n=[]){for(let s=0,r=e.length;s<r;s++)ah(e[s],this,n,t);return n.sort(Cd),n}}function Cd(i,e){return i.distance-e.distance}function ah(i,e,t,n){let s=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(s=!1),s===!0&&n===!0){const r=i.children;for(let a=0,o=r.length;a<o;a++)ah(r[a],e,t,!0)}}class $f{static{$f.prototype.isMatrix2=!0}constructor(e,t,n,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,s){const r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=s,this}}function Pd(i,e,t,n){const s=a2(n);switch(t){case If:return i*e;case kh:return i*e/s.components*s.byteLength;case Hh:return i*e/s.components*s.byteLength;case ms:return i*e*2/s.components*s.byteLength;case Gh:return i*e*2/s.components*s.byteLength;case Lf:return i*e*3/s.components*s.byteLength;case an:return i*e*4/s.components*s.byteLength;case Vh:return i*e*4/s.components*s.byteLength;case vo:case _o:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case xo:case Mo:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Rl:case Cl:return Math.max(i,16)*Math.max(e,8)/4;case Tl:case Dl:return Math.max(i,8)*Math.max(e,8)/2;case Pl:case Il:case Nl:case Ul:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Ll:case wo:case Ol:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Fl:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case zl:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Bl:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case kl:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Hl:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Gl:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Vl:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Wl:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case Xl:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case ql:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Yl:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case Kl:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case $l:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Zl:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case Jl:case Ql:case jl:return Math.ceil(i/4)*Math.ceil(e/4)*16;case eh:case th:return Math.ceil(i/4)*Math.ceil(e/4)*8;case To:case nh:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function a2(i){switch(i){case yn:case Rf:return{byteLength:1,components:1};case ta:case Df:case jt:return{byteLength:2,components:1};case zh:case Bh:return{byteLength:2,components:4};case Hn:case Fh:case Dn:return{byteLength:4,components:1};case Cf:case Pf: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:Uh}}));typeof window<"u"&&(window.__THREE__?Ae("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Uh);/**
338
338
  * @license
339
339
  * Copyright 2010-2026 Three.js Authors
340
340
  * SPDX-License-Identifier: MIT
341
- */function U0(){let i=null,e=!1,t=null,n=null;function s(r,a){t(r,a),n=i.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&i!==null&&(n=i.requestAnimationFrame(s),e=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){i=r}}}function eg(i){const e=new WeakMap;function t(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),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const c=e.get(o);c&&(i.deleteBuffer(c.buffer),e.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=e.get(o);(!h||h.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const l=e.get(o);if(l===void 0)e.set(o,t(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 tg=`#ifdef USE_ALPHAHASH
341
+ */function Zf(){let i=null,e=!1,t=null,n=null;function s(r,a){t(r,a),n=i.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&i!==null&&(n=i.requestAnimationFrame(s),e=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){i=r}}}function o2(i){const e=new WeakMap;function t(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),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const c=e.get(o);c&&(i.deleteBuffer(c.buffer),e.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=e.get(o);(!h||h.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const l=e.get(o);if(l===void 0)e.set(o,t(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 c2=`#ifdef USE_ALPHAHASH
342
342
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
343
- #endif`,ng=`#ifdef USE_ALPHAHASH
343
+ #endif`,l2=`#ifdef USE_ALPHAHASH
344
344
  const float ALPHA_HASH_SCALE = 0.05;
345
345
  float hash2D( vec2 value ) {
346
346
  return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -375,20 +375,20 @@ input[type=range] {
375
375
  : cases.z;
376
376
  return clamp( threshold , 1.0e-6, 1.0 );
377
377
  }
378
- #endif`,ig=`#ifdef USE_ALPHAMAP
378
+ #endif`,h2=`#ifdef USE_ALPHAMAP
379
379
  diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
380
- #endif`,sg=`#ifdef USE_ALPHAMAP
380
+ #endif`,u2=`#ifdef USE_ALPHAMAP
381
381
  uniform sampler2D alphaMap;
382
- #endif`,rg=`#ifdef USE_ALPHATEST
382
+ #endif`,d2=`#ifdef USE_ALPHATEST
383
383
  #ifdef ALPHA_TO_COVERAGE
384
384
  diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
385
385
  if ( diffuseColor.a == 0.0 ) discard;
386
386
  #else
387
387
  if ( diffuseColor.a < alphaTest ) discard;
388
388
  #endif
389
- #endif`,ag=`#ifdef USE_ALPHATEST
389
+ #endif`,f2=`#ifdef USE_ALPHATEST
390
390
  uniform float alphaTest;
391
- #endif`,og=`#ifdef USE_AOMAP
391
+ #endif`,p2=`#ifdef USE_AOMAP
392
392
  float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
393
393
  reflectedLight.indirectDiffuse *= ambientOcclusion;
394
394
  #if defined( USE_CLEARCOAT )
@@ -401,10 +401,10 @@ input[type=range] {
401
401
  float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
402
402
  reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
403
403
  #endif
404
- #endif`,cg=`#ifdef USE_AOMAP
404
+ #endif`,m2=`#ifdef USE_AOMAP
405
405
  uniform sampler2D aoMap;
406
406
  uniform float aoMapIntensity;
407
- #endif`,lg=`#ifdef USE_BATCHING
407
+ #endif`,g2=`#ifdef USE_BATCHING
408
408
  #if ! defined( GL_ANGLE_multi_draw )
409
409
  #define gl_DrawID _gl_DrawID
410
410
  uniform int _gl_DrawID;
@@ -438,15 +438,15 @@ input[type=range] {
438
438
  int y = j / size;
439
439
  return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
440
440
  }
441
- #endif`,hg=`#ifdef USE_BATCHING
441
+ #endif`,v2=`#ifdef USE_BATCHING
442
442
  mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
443
- #endif`,ug=`vec3 transformed = vec3( position );
443
+ #endif`,_2=`vec3 transformed = vec3( position );
444
444
  #ifdef USE_ALPHAHASH
445
445
  vPosition = vec3( position );
446
- #endif`,dg=`vec3 objectNormal = vec3( normal );
446
+ #endif`,x2=`vec3 objectNormal = vec3( normal );
447
447
  #ifdef USE_TANGENT
448
448
  vec3 objectTangent = vec3( tangent.xyz );
449
- #endif`,fg=`float G_BlinnPhong_Implicit( ) {
449
+ #endif`,M2=`float G_BlinnPhong_Implicit( ) {
450
450
  return 0.25;
451
451
  }
452
452
  float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -460,7 +460,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
460
460
  float G = G_BlinnPhong_Implicit( );
461
461
  float D = D_BlinnPhong( shininess, dotNH );
462
462
  return F * ( G * D );
463
- } // validated`,pg=`#ifdef USE_IRIDESCENCE
463
+ } // validated`,y2=`#ifdef USE_IRIDESCENCE
464
464
  const mat3 XYZ_TO_REC709 = mat3(
465
465
  3.2404542, -0.9692660, 0.0556434,
466
466
  -1.5371385, 1.8760108, -0.2040259,
@@ -523,7 +523,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
523
523
  }
524
524
  return max( I, vec3( 0.0 ) );
525
525
  }
526
- #endif`,mg=`#ifdef USE_BUMPMAP
526
+ #endif`,S2=`#ifdef USE_BUMPMAP
527
527
  uniform sampler2D bumpMap;
528
528
  uniform float bumpScale;
529
529
  vec2 dHdxy_fwd() {
@@ -544,7 +544,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
544
544
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
545
545
  return normalize( abs( fDet ) * surf_norm - vGrad );
546
546
  }
547
- #endif`,gg=`#if NUM_CLIPPING_PLANES > 0
547
+ #endif`,E2=`#if NUM_CLIPPING_PLANES > 0
548
548
  vec4 plane;
549
549
  #ifdef ALPHA_TO_COVERAGE
550
550
  float distanceToPlane, distanceGradient;
@@ -590,20 +590,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
590
590
  if ( clipped ) discard;
591
591
  #endif
592
592
  #endif
593
- #endif`,vg=`#if NUM_CLIPPING_PLANES > 0
593
+ #endif`,b2=`#if NUM_CLIPPING_PLANES > 0
594
594
  varying vec3 vClipPosition;
595
595
  uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
596
- #endif`,_g=`#if NUM_CLIPPING_PLANES > 0
596
+ #endif`,A2=`#if NUM_CLIPPING_PLANES > 0
597
597
  varying vec3 vClipPosition;
598
- #endif`,xg=`#if NUM_CLIPPING_PLANES > 0
598
+ #endif`,w2=`#if NUM_CLIPPING_PLANES > 0
599
599
  vClipPosition = - mvPosition.xyz;
600
- #endif`,Mg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
600
+ #endif`,T2=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
601
601
  diffuseColor *= vColor;
602
- #endif`,Sg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
602
+ #endif`,R2=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
603
603
  varying vec4 vColor;
604
- #endif`,yg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
604
+ #endif`,D2=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
605
605
  varying vec4 vColor;
606
- #endif`,Eg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
606
+ #endif`,C2=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
607
607
  vColor = vec4( 1.0 );
608
608
  #endif
609
609
  #ifdef USE_COLOR_ALPHA
@@ -616,7 +616,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
616
616
  #endif
617
617
  #ifdef USE_BATCHING_COLOR
618
618
  vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
619
- #endif`,Ag=`#define PI 3.141592653589793
619
+ #endif`,P2=`#define PI 3.141592653589793
620
620
  #define PI2 6.283185307179586
621
621
  #define PI_HALF 1.5707963267948966
622
622
  #define RECIPROCAL_PI 0.3183098861837907
@@ -687,7 +687,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
687
687
  float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
688
688
  float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
689
689
  return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
690
- } // validated`,bg=`#ifdef ENVMAP_TYPE_CUBE_UV
690
+ } // validated`,I2=`#ifdef ENVMAP_TYPE_CUBE_UV
691
691
  #define cubeUV_minMipLevel 4.0
692
692
  #define cubeUV_minTileSize 16.0
693
693
  float getFace( vec3 direction ) {
@@ -780,7 +780,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
780
780
  return vec4( mix( color0, color1, mipF ), 1.0 );
781
781
  }
782
782
  }
783
- #endif`,Tg=`vec3 transformedNormal = objectNormal;
783
+ #endif`,L2=`vec3 transformedNormal = objectNormal;
784
784
  #ifdef USE_TANGENT
785
785
  vec3 transformedTangent = objectTangent;
786
786
  #endif
@@ -806,21 +806,21 @@ transformedNormal = normalMatrix * transformedNormal;
806
806
  #endif
807
807
  #ifdef USE_TANGENT
808
808
  transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
809
- #endif`,wg=`#ifdef USE_DISPLACEMENTMAP
809
+ #endif`,N2=`#ifdef USE_DISPLACEMENTMAP
810
810
  uniform sampler2D displacementMap;
811
811
  uniform float displacementScale;
812
812
  uniform float displacementBias;
813
- #endif`,Rg=`#ifdef USE_DISPLACEMENTMAP
813
+ #endif`,U2=`#ifdef USE_DISPLACEMENTMAP
814
814
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
815
- #endif`,Dg=`#ifdef USE_EMISSIVEMAP
815
+ #endif`,O2=`#ifdef USE_EMISSIVEMAP
816
816
  vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
817
817
  #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
818
818
  emissiveColor = sRGBTransferEOTF( emissiveColor );
819
819
  #endif
820
820
  totalEmissiveRadiance *= emissiveColor.rgb;
821
- #endif`,Cg=`#ifdef USE_EMISSIVEMAP
821
+ #endif`,F2=`#ifdef USE_EMISSIVEMAP
822
822
  uniform sampler2D emissiveMap;
823
- #endif`,Pg="gl_FragColor = linearToOutputTexel( gl_FragColor );",Ig=`vec4 LinearTransferOETF( in vec4 value ) {
823
+ #endif`,z2="gl_FragColor = linearToOutputTexel( gl_FragColor );",B2=`vec4 LinearTransferOETF( in vec4 value ) {
824
824
  return value;
825
825
  }
826
826
  vec4 sRGBTransferEOTF( in vec4 value ) {
@@ -828,7 +828,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
828
828
  }
829
829
  vec4 sRGBTransferOETF( in vec4 value ) {
830
830
  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 );
831
- }`,Lg=`#ifdef USE_ENVMAP
831
+ }`,k2=`#ifdef USE_ENVMAP
832
832
  #ifdef ENV_WORLDPOS
833
833
  vec3 cameraToFrag;
834
834
  if ( isOrthographic ) {
@@ -855,7 +855,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
855
855
  outgoingLight += envColor.xyz * specularStrength * reflectivity;
856
856
  #endif
857
857
  #endif
858
- #endif`,Ng=`#ifdef USE_ENVMAP
858
+ #endif`,H2=`#ifdef USE_ENVMAP
859
859
  uniform float envMapIntensity;
860
860
  uniform mat3 envMapRotation;
861
861
  #ifdef ENVMAP_TYPE_CUBE
@@ -863,7 +863,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
863
863
  #else
864
864
  uniform sampler2D envMap;
865
865
  #endif
866
- #endif`,Ug=`#ifdef USE_ENVMAP
866
+ #endif`,G2=`#ifdef USE_ENVMAP
867
867
  uniform float reflectivity;
868
868
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
869
869
  #define ENV_WORLDPOS
@@ -874,7 +874,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
874
874
  #else
875
875
  varying vec3 vReflect;
876
876
  #endif
877
- #endif`,Og=`#ifdef USE_ENVMAP
877
+ #endif`,V2=`#ifdef USE_ENVMAP
878
878
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
879
879
  #define ENV_WORLDPOS
880
880
  #endif
@@ -885,7 +885,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
885
885
  varying vec3 vReflect;
886
886
  uniform float refractionRatio;
887
887
  #endif
888
- #endif`,Fg=`#ifdef USE_ENVMAP
888
+ #endif`,W2=`#ifdef USE_ENVMAP
889
889
  #ifdef ENV_WORLDPOS
890
890
  vWorldPosition = worldPosition.xyz;
891
891
  #else
@@ -902,18 +902,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
902
902
  vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
903
903
  #endif
904
904
  #endif
905
- #endif`,zg=`#ifdef USE_FOG
905
+ #endif`,X2=`#ifdef USE_FOG
906
906
  vFogDepth = - mvPosition.z;
907
- #endif`,Bg=`#ifdef USE_FOG
907
+ #endif`,q2=`#ifdef USE_FOG
908
908
  varying float vFogDepth;
909
- #endif`,Hg=`#ifdef USE_FOG
909
+ #endif`,Y2=`#ifdef USE_FOG
910
910
  #ifdef FOG_EXP2
911
911
  float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
912
912
  #else
913
913
  float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
914
914
  #endif
915
915
  gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
916
- #endif`,kg=`#ifdef USE_FOG
916
+ #endif`,K2=`#ifdef USE_FOG
917
917
  uniform vec3 fogColor;
918
918
  varying float vFogDepth;
919
919
  #ifdef FOG_EXP2
@@ -922,7 +922,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
922
922
  uniform float fogNear;
923
923
  uniform float fogFar;
924
924
  #endif
925
- #endif`,Gg=`#ifdef USE_GRADIENTMAP
925
+ #endif`,$2=`#ifdef USE_GRADIENTMAP
926
926
  uniform sampler2D gradientMap;
927
927
  #endif
928
928
  vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -934,12 +934,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
934
934
  vec2 fw = fwidth( coord ) * 0.5;
935
935
  return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
936
936
  #endif
937
- }`,Vg=`#ifdef USE_LIGHTMAP
937
+ }`,Z2=`#ifdef USE_LIGHTMAP
938
938
  uniform sampler2D lightMap;
939
939
  uniform float lightMapIntensity;
940
- #endif`,Wg=`LambertMaterial material;
940
+ #endif`,J2=`LambertMaterial material;
941
941
  material.diffuseColor = diffuseColor.rgb;
942
- material.specularStrength = specularStrength;`,Xg=`varying vec3 vViewPosition;
942
+ material.specularStrength = specularStrength;`,Q2=`varying vec3 vViewPosition;
943
943
  struct LambertMaterial {
944
944
  vec3 diffuseColor;
945
945
  float specularStrength;
@@ -953,7 +953,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
953
953
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
954
954
  }
955
955
  #define RE_Direct RE_Direct_Lambert
956
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,qg=`uniform bool receiveShadow;
956
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,j2=`uniform bool receiveShadow;
957
957
  uniform vec3 ambientLightColor;
958
958
  #if defined( USE_LIGHT_PROBES )
959
959
  uniform vec3 lightProbe[ 9 ];
@@ -1070,7 +1070,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
1070
1070
  return irradiance;
1071
1071
  }
1072
1072
  #endif
1073
- #include <lightprobes_pars_fragment>`,Yg=`#ifdef USE_ENVMAP
1073
+ #include <lightprobes_pars_fragment>`,ev=`#ifdef USE_ENVMAP
1074
1074
  vec3 getIBLIrradiance( const in vec3 normal ) {
1075
1075
  #ifdef ENVMAP_TYPE_CUBE_UV
1076
1076
  vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
@@ -1103,8 +1103,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
1103
1103
  #endif
1104
1104
  }
1105
1105
  #endif
1106
- #endif`,Kg=`ToonMaterial material;
1107
- material.diffuseColor = diffuseColor.rgb;`,Zg=`varying vec3 vViewPosition;
1106
+ #endif`,tv=`ToonMaterial material;
1107
+ material.diffuseColor = diffuseColor.rgb;`,nv=`varying vec3 vViewPosition;
1108
1108
  struct ToonMaterial {
1109
1109
  vec3 diffuseColor;
1110
1110
  };
@@ -1116,11 +1116,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
1116
1116
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1117
1117
  }
1118
1118
  #define RE_Direct RE_Direct_Toon
1119
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,$g=`BlinnPhongMaterial material;
1119
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,iv=`BlinnPhongMaterial material;
1120
1120
  material.diffuseColor = diffuseColor.rgb;
1121
1121
  material.specularColor = specular;
1122
1122
  material.specularShininess = shininess;
1123
- material.specularStrength = specularStrength;`,Jg=`varying vec3 vViewPosition;
1123
+ material.specularStrength = specularStrength;`,sv=`varying vec3 vViewPosition;
1124
1124
  struct BlinnPhongMaterial {
1125
1125
  vec3 diffuseColor;
1126
1126
  vec3 specularColor;
@@ -1137,7 +1137,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
1137
1137
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1138
1138
  }
1139
1139
  #define RE_Direct RE_Direct_BlinnPhong
1140
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Qg=`PhysicalMaterial material;
1140
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,rv=`PhysicalMaterial material;
1141
1141
  material.diffuseColor = diffuseColor.rgb;
1142
1142
  material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
1143
1143
  material.metalness = metalnessFactor;
@@ -1227,7 +1227,7 @@ material.roughness = min( material.roughness, 1.0 );
1227
1227
  material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
1228
1228
  material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
1229
1229
  material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
1230
- #endif`,jg=`uniform sampler2D dfgLUT;
1230
+ #endif`,av=`uniform sampler2D dfgLUT;
1231
1231
  struct PhysicalMaterial {
1232
1232
  vec3 diffuseColor;
1233
1233
  vec3 diffuseContribution;
@@ -1587,7 +1587,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
1587
1587
  #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1588
1588
  float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1589
1589
  return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1590
- }`,e1=`
1590
+ }`,ov=`
1591
1591
  vec3 geometryPosition = - vViewPosition;
1592
1592
  vec3 geometryNormal = normal;
1593
1593
  vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1709,7 +1709,7 @@ IncidentLight directLight;
1709
1709
  #if defined( RE_IndirectSpecular )
1710
1710
  vec3 radiance = vec3( 0.0 );
1711
1711
  vec3 clearcoatRadiance = vec3( 0.0 );
1712
- #endif`,t1=`#if defined( RE_IndirectDiffuse )
1712
+ #endif`,cv=`#if defined( RE_IndirectDiffuse )
1713
1713
  #ifdef USE_LIGHTMAP
1714
1714
  vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1715
1715
  vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1730,7 +1730,7 @@ IncidentLight directLight;
1730
1730
  #ifdef USE_CLEARCOAT
1731
1731
  clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1732
1732
  #endif
1733
- #endif`,n1=`#if defined( RE_IndirectDiffuse )
1733
+ #endif`,lv=`#if defined( RE_IndirectDiffuse )
1734
1734
  #if defined( LAMBERT ) || defined( PHONG )
1735
1735
  irradiance += iblIrradiance;
1736
1736
  #endif
@@ -1738,7 +1738,7 @@ IncidentLight directLight;
1738
1738
  #endif
1739
1739
  #if defined( RE_IndirectSpecular )
1740
1740
  RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1741
- #endif`,i1=`#ifdef USE_LIGHT_PROBES_GRID
1741
+ #endif`,hv=`#ifdef USE_LIGHT_PROBES_GRID
1742
1742
  uniform highp sampler3D probesSH;
1743
1743
  uniform vec3 probesMin;
1744
1744
  uniform vec3 probesMax;
@@ -1783,27 +1783,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1783
1783
  result += c8 * 0.429043 * ( x * x - y * y );
1784
1784
  return max( result, vec3( 0.0 ) );
1785
1785
  }
1786
- #endif`,s1=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1786
+ #endif`,uv=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1787
1787
  gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1788
- #endif`,r1=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1788
+ #endif`,dv=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1789
1789
  uniform float logDepthBufFC;
1790
1790
  varying float vFragDepth;
1791
1791
  varying float vIsPerspective;
1792
- #endif`,a1=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1792
+ #endif`,fv=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1793
1793
  varying float vFragDepth;
1794
1794
  varying float vIsPerspective;
1795
- #endif`,o1=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1795
+ #endif`,pv=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1796
1796
  vFragDepth = 1.0 + gl_Position.w;
1797
1797
  vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1798
- #endif`,c1=`#ifdef USE_MAP
1798
+ #endif`,mv=`#ifdef USE_MAP
1799
1799
  vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1800
1800
  #ifdef DECODE_VIDEO_TEXTURE
1801
1801
  sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1802
1802
  #endif
1803
1803
  diffuseColor *= sampledDiffuseColor;
1804
- #endif`,l1=`#ifdef USE_MAP
1804
+ #endif`,gv=`#ifdef USE_MAP
1805
1805
  uniform sampler2D map;
1806
- #endif`,h1=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1806
+ #endif`,vv=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1807
1807
  #if defined( USE_POINTS_UV )
1808
1808
  vec2 uv = vUv;
1809
1809
  #else
@@ -1815,7 +1815,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1815
1815
  #endif
1816
1816
  #ifdef USE_ALPHAMAP
1817
1817
  diffuseColor.a *= texture2D( alphaMap, uv ).g;
1818
- #endif`,u1=`#if defined( USE_POINTS_UV )
1818
+ #endif`,_v=`#if defined( USE_POINTS_UV )
1819
1819
  varying vec2 vUv;
1820
1820
  #else
1821
1821
  #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1827,19 +1827,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1827
1827
  #endif
1828
1828
  #ifdef USE_ALPHAMAP
1829
1829
  uniform sampler2D alphaMap;
1830
- #endif`,d1=`float metalnessFactor = metalness;
1830
+ #endif`,xv=`float metalnessFactor = metalness;
1831
1831
  #ifdef USE_METALNESSMAP
1832
1832
  vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1833
1833
  metalnessFactor *= texelMetalness.b;
1834
- #endif`,f1=`#ifdef USE_METALNESSMAP
1834
+ #endif`,Mv=`#ifdef USE_METALNESSMAP
1835
1835
  uniform sampler2D metalnessMap;
1836
- #endif`,p1=`#ifdef USE_INSTANCING_MORPH
1836
+ #endif`,yv=`#ifdef USE_INSTANCING_MORPH
1837
1837
  float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1838
1838
  float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1839
1839
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1840
1840
  morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1841
1841
  }
1842
- #endif`,m1=`#if defined( USE_MORPHCOLORS )
1842
+ #endif`,Sv=`#if defined( USE_MORPHCOLORS )
1843
1843
  vColor *= morphTargetBaseInfluence;
1844
1844
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1845
1845
  #if defined( USE_COLOR_ALPHA )
@@ -1848,12 +1848,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1848
1848
  if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1849
1849
  #endif
1850
1850
  }
1851
- #endif`,g1=`#ifdef USE_MORPHNORMALS
1851
+ #endif`,Ev=`#ifdef USE_MORPHNORMALS
1852
1852
  objectNormal *= morphTargetBaseInfluence;
1853
1853
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1854
1854
  if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1855
1855
  }
1856
- #endif`,v1=`#ifdef USE_MORPHTARGETS
1856
+ #endif`,bv=`#ifdef USE_MORPHTARGETS
1857
1857
  #ifndef USE_INSTANCING_MORPH
1858
1858
  uniform float morphTargetBaseInfluence;
1859
1859
  uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -1867,12 +1867,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1867
1867
  ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1868
1868
  return texelFetch( morphTargetsTexture, morphUV, 0 );
1869
1869
  }
1870
- #endif`,_1=`#ifdef USE_MORPHTARGETS
1870
+ #endif`,Av=`#ifdef USE_MORPHTARGETS
1871
1871
  transformed *= morphTargetBaseInfluence;
1872
1872
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1873
1873
  if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1874
1874
  }
1875
- #endif`,x1=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1875
+ #endif`,wv=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1876
1876
  #ifdef FLAT_SHADED
1877
1877
  vec3 fdx = dFdx( vViewPosition );
1878
1878
  vec3 fdy = dFdy( vViewPosition );
@@ -1913,7 +1913,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1913
1913
  tbn2[1] *= faceDirection;
1914
1914
  #endif
1915
1915
  #endif
1916
- vec3 nonPerturbedNormal = normal;`,M1=`#ifdef USE_NORMALMAP_OBJECTSPACE
1916
+ vec3 nonPerturbedNormal = normal;`,Tv=`#ifdef USE_NORMALMAP_OBJECTSPACE
1917
1917
  normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1918
1918
  #ifdef FLIP_SIDED
1919
1919
  normal = - normal;
@@ -1931,19 +1931,19 @@ vec3 nonPerturbedNormal = normal;`,M1=`#ifdef USE_NORMALMAP_OBJECTSPACE
1931
1931
  normal = normalize( tbn * mapN );
1932
1932
  #elif defined( USE_BUMPMAP )
1933
1933
  normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1934
- #endif`,S1=`#ifndef FLAT_SHADED
1934
+ #endif`,Rv=`#ifndef FLAT_SHADED
1935
1935
  varying vec3 vNormal;
1936
1936
  #ifdef USE_TANGENT
1937
1937
  varying vec3 vTangent;
1938
1938
  varying vec3 vBitangent;
1939
1939
  #endif
1940
- #endif`,y1=`#ifndef FLAT_SHADED
1940
+ #endif`,Dv=`#ifndef FLAT_SHADED
1941
1941
  varying vec3 vNormal;
1942
1942
  #ifdef USE_TANGENT
1943
1943
  varying vec3 vTangent;
1944
1944
  varying vec3 vBitangent;
1945
1945
  #endif
1946
- #endif`,E1=`#ifndef FLAT_SHADED
1946
+ #endif`,Cv=`#ifndef FLAT_SHADED
1947
1947
  vNormal = normalize( transformedNormal );
1948
1948
  #ifdef USE_TANGENT
1949
1949
  vTangent = normalize( transformedTangent );
@@ -1952,7 +1952,7 @@ vec3 nonPerturbedNormal = normal;`,M1=`#ifdef USE_NORMALMAP_OBJECTSPACE
1952
1952
  vBitangent = - vBitangent;
1953
1953
  #endif
1954
1954
  #endif
1955
- #endif`,A1=`#ifdef USE_NORMALMAP
1955
+ #endif`,Pv=`#ifdef USE_NORMALMAP
1956
1956
  uniform sampler2D normalMap;
1957
1957
  uniform vec2 normalScale;
1958
1958
  #endif
@@ -1974,13 +1974,13 @@ vec3 nonPerturbedNormal = normal;`,M1=`#ifdef USE_NORMALMAP_OBJECTSPACE
1974
1974
  float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1975
1975
  return mat3( T * scale, B * scale, N );
1976
1976
  }
1977
- #endif`,b1=`#ifdef USE_CLEARCOAT
1977
+ #endif`,Iv=`#ifdef USE_CLEARCOAT
1978
1978
  vec3 clearcoatNormal = nonPerturbedNormal;
1979
- #endif`,T1=`#ifdef USE_CLEARCOAT_NORMALMAP
1979
+ #endif`,Lv=`#ifdef USE_CLEARCOAT_NORMALMAP
1980
1980
  vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1981
1981
  clearcoatMapN.xy *= clearcoatNormalScale;
1982
1982
  clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1983
- #endif`,w1=`#ifdef USE_CLEARCOATMAP
1983
+ #endif`,Nv=`#ifdef USE_CLEARCOATMAP
1984
1984
  uniform sampler2D clearcoatMap;
1985
1985
  #endif
1986
1986
  #ifdef USE_CLEARCOAT_NORMALMAP
@@ -1989,18 +1989,18 @@ vec3 nonPerturbedNormal = normal;`,M1=`#ifdef USE_NORMALMAP_OBJECTSPACE
1989
1989
  #endif
1990
1990
  #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1991
1991
  uniform sampler2D clearcoatRoughnessMap;
1992
- #endif`,R1=`#ifdef USE_IRIDESCENCEMAP
1992
+ #endif`,Uv=`#ifdef USE_IRIDESCENCEMAP
1993
1993
  uniform sampler2D iridescenceMap;
1994
1994
  #endif
1995
1995
  #ifdef USE_IRIDESCENCE_THICKNESSMAP
1996
1996
  uniform sampler2D iridescenceThicknessMap;
1997
- #endif`,D1=`#ifdef OPAQUE
1997
+ #endif`,Ov=`#ifdef OPAQUE
1998
1998
  diffuseColor.a = 1.0;
1999
1999
  #endif
2000
2000
  #ifdef USE_TRANSMISSION
2001
2001
  diffuseColor.a *= material.transmissionAlpha;
2002
2002
  #endif
2003
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,C1=`vec3 packNormalToRGB( const in vec3 normal ) {
2003
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Fv=`vec3 packNormalToRGB( const in vec3 normal ) {
2004
2004
  return normalize( normal ) * 0.5 + 0.5;
2005
2005
  }
2006
2006
  vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -2079,9 +2079,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
2079
2079
  #else
2080
2080
  return ( near * far ) / ( ( far - near ) * depth - far );
2081
2081
  #endif
2082
- }`,P1=`#ifdef PREMULTIPLIED_ALPHA
2082
+ }`,zv=`#ifdef PREMULTIPLIED_ALPHA
2083
2083
  gl_FragColor.rgb *= gl_FragColor.a;
2084
- #endif`,I1=`vec4 mvPosition = vec4( transformed, 1.0 );
2084
+ #endif`,Bv=`vec4 mvPosition = vec4( transformed, 1.0 );
2085
2085
  #ifdef USE_BATCHING
2086
2086
  mvPosition = batchingMatrix * mvPosition;
2087
2087
  #endif
@@ -2089,22 +2089,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
2089
2089
  mvPosition = instanceMatrix * mvPosition;
2090
2090
  #endif
2091
2091
  mvPosition = modelViewMatrix * mvPosition;
2092
- gl_Position = projectionMatrix * mvPosition;`,L1=`#ifdef DITHERING
2092
+ gl_Position = projectionMatrix * mvPosition;`,kv=`#ifdef DITHERING
2093
2093
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
2094
- #endif`,N1=`#ifdef DITHERING
2094
+ #endif`,Hv=`#ifdef DITHERING
2095
2095
  vec3 dithering( vec3 color ) {
2096
2096
  float grid_position = rand( gl_FragCoord.xy );
2097
2097
  vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
2098
2098
  dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
2099
2099
  return color + dither_shift_RGB;
2100
2100
  }
2101
- #endif`,U1=`float roughnessFactor = roughness;
2101
+ #endif`,Gv=`float roughnessFactor = roughness;
2102
2102
  #ifdef USE_ROUGHNESSMAP
2103
2103
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
2104
2104
  roughnessFactor *= texelRoughness.g;
2105
- #endif`,O1=`#ifdef USE_ROUGHNESSMAP
2105
+ #endif`,Vv=`#ifdef USE_ROUGHNESSMAP
2106
2106
  uniform sampler2D roughnessMap;
2107
- #endif`,F1=`#if NUM_SPOT_LIGHT_COORDS > 0
2107
+ #endif`,Wv=`#if NUM_SPOT_LIGHT_COORDS > 0
2108
2108
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
2109
2109
  #endif
2110
2110
  #if NUM_SPOT_LIGHT_MAPS > 0
@@ -2304,7 +2304,7 @@ gl_Position = projectionMatrix * mvPosition;`,L1=`#ifdef DITHERING
2304
2304
  }
2305
2305
  #endif
2306
2306
  #endif
2307
- #endif`,z1=`#if NUM_SPOT_LIGHT_COORDS > 0
2307
+ #endif`,Xv=`#if NUM_SPOT_LIGHT_COORDS > 0
2308
2308
  uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
2309
2309
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
2310
2310
  #endif
@@ -2345,7 +2345,7 @@ gl_Position = projectionMatrix * mvPosition;`,L1=`#ifdef DITHERING
2345
2345
  };
2346
2346
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
2347
2347
  #endif
2348
- #endif`,B1=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2348
+ #endif`,qv=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2349
2349
  #ifdef HAS_NORMAL
2350
2350
  vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
2351
2351
  #else
@@ -2381,7 +2381,7 @@ gl_Position = projectionMatrix * mvPosition;`,L1=`#ifdef DITHERING
2381
2381
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
2382
2382
  }
2383
2383
  #pragma unroll_loop_end
2384
- #endif`,H1=`float getShadowMask() {
2384
+ #endif`,Yv=`float getShadowMask() {
2385
2385
  float shadow = 1.0;
2386
2386
  #ifdef USE_SHADOWMAP
2387
2387
  #if NUM_DIR_LIGHT_SHADOWS > 0
@@ -2413,12 +2413,12 @@ gl_Position = projectionMatrix * mvPosition;`,L1=`#ifdef DITHERING
2413
2413
  #endif
2414
2414
  #endif
2415
2415
  return shadow;
2416
- }`,k1=`#ifdef USE_SKINNING
2416
+ }`,Kv=`#ifdef USE_SKINNING
2417
2417
  mat4 boneMatX = getBoneMatrix( skinIndex.x );
2418
2418
  mat4 boneMatY = getBoneMatrix( skinIndex.y );
2419
2419
  mat4 boneMatZ = getBoneMatrix( skinIndex.z );
2420
2420
  mat4 boneMatW = getBoneMatrix( skinIndex.w );
2421
- #endif`,G1=`#ifdef USE_SKINNING
2421
+ #endif`,$v=`#ifdef USE_SKINNING
2422
2422
  uniform mat4 bindMatrix;
2423
2423
  uniform mat4 bindMatrixInverse;
2424
2424
  uniform highp sampler2D boneTexture;
@@ -2433,7 +2433,7 @@ gl_Position = projectionMatrix * mvPosition;`,L1=`#ifdef DITHERING
2433
2433
  vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2434
2434
  return mat4( v1, v2, v3, v4 );
2435
2435
  }
2436
- #endif`,V1=`#ifdef USE_SKINNING
2436
+ #endif`,Zv=`#ifdef USE_SKINNING
2437
2437
  vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2438
2438
  vec4 skinned = vec4( 0.0 );
2439
2439
  skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2441,7 +2441,7 @@ gl_Position = projectionMatrix * mvPosition;`,L1=`#ifdef DITHERING
2441
2441
  skinned += boneMatZ * skinVertex * skinWeight.z;
2442
2442
  skinned += boneMatW * skinVertex * skinWeight.w;
2443
2443
  transformed = ( bindMatrixInverse * skinned ).xyz;
2444
- #endif`,W1=`#ifdef USE_SKINNING
2444
+ #endif`,Jv=`#ifdef USE_SKINNING
2445
2445
  mat4 skinMatrix = mat4( 0.0 );
2446
2446
  skinMatrix += skinWeight.x * boneMatX;
2447
2447
  skinMatrix += skinWeight.y * boneMatY;
@@ -2452,17 +2452,17 @@ gl_Position = projectionMatrix * mvPosition;`,L1=`#ifdef DITHERING
2452
2452
  #ifdef USE_TANGENT
2453
2453
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2454
2454
  #endif
2455
- #endif`,X1=`float specularStrength;
2455
+ #endif`,Qv=`float specularStrength;
2456
2456
  #ifdef USE_SPECULARMAP
2457
2457
  vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2458
2458
  specularStrength = texelSpecular.r;
2459
2459
  #else
2460
2460
  specularStrength = 1.0;
2461
- #endif`,q1=`#ifdef USE_SPECULARMAP
2461
+ #endif`,jv=`#ifdef USE_SPECULARMAP
2462
2462
  uniform sampler2D specularMap;
2463
- #endif`,Y1=`#if defined( TONE_MAPPING )
2463
+ #endif`,e_=`#if defined( TONE_MAPPING )
2464
2464
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2465
- #endif`,K1=`#ifndef saturate
2465
+ #endif`,t_=`#ifndef saturate
2466
2466
  #define saturate( a ) clamp( a, 0.0, 1.0 )
2467
2467
  #endif
2468
2468
  uniform float toneMappingExposure;
@@ -2559,7 +2559,7 @@ vec3 NeutralToneMapping( vec3 color ) {
2559
2559
  float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2560
2560
  return mix( color, vec3( newPeak ), g );
2561
2561
  }
2562
- vec3 CustomToneMapping( vec3 color ) { return color; }`,Z1=`#ifdef USE_TRANSMISSION
2562
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,n_=`#ifdef USE_TRANSMISSION
2563
2563
  material.transmission = transmission;
2564
2564
  material.transmissionAlpha = 1.0;
2565
2565
  material.thickness = thickness;
@@ -2580,7 +2580,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Z1=`#ifdef USE_TRANSMISS
2580
2580
  material.attenuationColor, material.attenuationDistance );
2581
2581
  material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2582
2582
  totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2583
- #endif`,$1=`#ifdef USE_TRANSMISSION
2583
+ #endif`,i_=`#ifdef USE_TRANSMISSION
2584
2584
  uniform float transmission;
2585
2585
  uniform float thickness;
2586
2586
  uniform float attenuationDistance;
@@ -2706,7 +2706,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Z1=`#ifdef USE_TRANSMISS
2706
2706
  float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2707
2707
  return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2708
2708
  }
2709
- #endif`,J1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2709
+ #endif`,s_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2710
2710
  varying vec2 vUv;
2711
2711
  #endif
2712
2712
  #ifdef USE_MAP
@@ -2776,7 +2776,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Z1=`#ifdef USE_TRANSMISS
2776
2776
  #ifdef USE_THICKNESSMAP
2777
2777
  uniform mat3 thicknessMapTransform;
2778
2778
  varying vec2 vThicknessMapUv;
2779
- #endif`,Q1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2779
+ #endif`,r_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2780
2780
  varying vec2 vUv;
2781
2781
  #endif
2782
2782
  #ifdef USE_MAP
@@ -2870,7 +2870,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Z1=`#ifdef USE_TRANSMISS
2870
2870
  #ifdef USE_THICKNESSMAP
2871
2871
  uniform mat3 thicknessMapTransform;
2872
2872
  varying vec2 vThicknessMapUv;
2873
- #endif`,j1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2873
+ #endif`,a_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2874
2874
  vUv = vec3( uv, 1 ).xy;
2875
2875
  #endif
2876
2876
  #ifdef USE_MAP
@@ -2941,7 +2941,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Z1=`#ifdef USE_TRANSMISS
2941
2941
  #endif
2942
2942
  #ifdef USE_THICKNESSMAP
2943
2943
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2944
- #endif`,e2=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2944
+ #endif`,o_=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2945
2945
  vec4 worldPosition = vec4( transformed, 1.0 );
2946
2946
  #ifdef USE_BATCHING
2947
2947
  worldPosition = batchingMatrix * worldPosition;
@@ -2950,12 +2950,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Z1=`#ifdef USE_TRANSMISS
2950
2950
  worldPosition = instanceMatrix * worldPosition;
2951
2951
  #endif
2952
2952
  worldPosition = modelMatrix * worldPosition;
2953
- #endif`;const t2=`varying vec2 vUv;
2953
+ #endif`;const c_=`varying vec2 vUv;
2954
2954
  uniform mat3 uvTransform;
2955
2955
  void main() {
2956
2956
  vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2957
2957
  gl_Position = vec4( position.xy, 1.0, 1.0 );
2958
- }`,n2=`uniform sampler2D t2D;
2958
+ }`,l_=`uniform sampler2D t2D;
2959
2959
  uniform float backgroundIntensity;
2960
2960
  varying vec2 vUv;
2961
2961
  void main() {
@@ -2967,14 +2967,14 @@ void main() {
2967
2967
  gl_FragColor = texColor;
2968
2968
  #include <tonemapping_fragment>
2969
2969
  #include <colorspace_fragment>
2970
- }`,i2=`varying vec3 vWorldDirection;
2970
+ }`,h_=`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
- }`,s2=`#ifdef ENVMAP_TYPE_CUBE
2977
+ }`,u_=`#ifdef ENVMAP_TYPE_CUBE
2978
2978
  uniform samplerCube envMap;
2979
2979
  #elif defined( ENVMAP_TYPE_CUBE_UV )
2980
2980
  uniform sampler2D envMap;
@@ -2996,14 +2996,14 @@ void main() {
2996
2996
  gl_FragColor = texColor;
2997
2997
  #include <tonemapping_fragment>
2998
2998
  #include <colorspace_fragment>
2999
- }`,r2=`varying vec3 vWorldDirection;
2999
+ }`,d_=`varying vec3 vWorldDirection;
3000
3000
  #include <common>
3001
3001
  void main() {
3002
3002
  vWorldDirection = transformDirection( position, modelMatrix );
3003
3003
  #include <begin_vertex>
3004
3004
  #include <project_vertex>
3005
3005
  gl_Position.z = gl_Position.w;
3006
- }`,a2=`uniform samplerCube tCube;
3006
+ }`,f_=`uniform samplerCube tCube;
3007
3007
  uniform float tFlip;
3008
3008
  uniform float opacity;
3009
3009
  varying vec3 vWorldDirection;
@@ -3013,7 +3013,7 @@ void main() {
3013
3013
  gl_FragColor.a *= opacity;
3014
3014
  #include <tonemapping_fragment>
3015
3015
  #include <colorspace_fragment>
3016
- }`,o2=`#include <common>
3016
+ }`,p_=`#include <common>
3017
3017
  #include <batching_pars_vertex>
3018
3018
  #include <uv_pars_vertex>
3019
3019
  #include <displacementmap_pars_vertex>
@@ -3040,7 +3040,7 @@ void main() {
3040
3040
  #include <logdepthbuf_vertex>
3041
3041
  #include <clipping_planes_vertex>
3042
3042
  vHighPrecisionZW = gl_Position.zw;
3043
- }`,c2=`#if DEPTH_PACKING == 3200
3043
+ }`,m_=`#if DEPTH_PACKING == 3200
3044
3044
  uniform float opacity;
3045
3045
  #endif
3046
3046
  #include <common>
@@ -3078,7 +3078,7 @@ void main() {
3078
3078
  #elif DEPTH_PACKING == 3203
3079
3079
  gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
3080
3080
  #endif
3081
- }`,l2=`#define DISTANCE
3081
+ }`,g_=`#define DISTANCE
3082
3082
  varying vec3 vWorldPosition;
3083
3083
  #include <common>
3084
3084
  #include <batching_pars_vertex>
@@ -3105,7 +3105,7 @@ void main() {
3105
3105
  #include <worldpos_vertex>
3106
3106
  #include <clipping_planes_vertex>
3107
3107
  vWorldPosition = worldPosition.xyz;
3108
- }`,h2=`#define DISTANCE
3108
+ }`,v_=`#define DISTANCE
3109
3109
  uniform vec3 referencePosition;
3110
3110
  uniform float nearDistance;
3111
3111
  uniform float farDistance;
@@ -3128,13 +3128,13 @@ void main() {
3128
3128
  dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
3129
3129
  dist = saturate( dist );
3130
3130
  gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
3131
- }`,u2=`varying vec3 vWorldDirection;
3131
+ }`,__=`varying vec3 vWorldDirection;
3132
3132
  #include <common>
3133
3133
  void main() {
3134
3134
  vWorldDirection = transformDirection( position, modelMatrix );
3135
3135
  #include <begin_vertex>
3136
3136
  #include <project_vertex>
3137
- }`,d2=`uniform sampler2D tEquirect;
3137
+ }`,x_=`uniform sampler2D tEquirect;
3138
3138
  varying vec3 vWorldDirection;
3139
3139
  #include <common>
3140
3140
  void main() {
@@ -3143,7 +3143,7 @@ void main() {
3143
3143
  gl_FragColor = texture2D( tEquirect, sampleUV );
3144
3144
  #include <tonemapping_fragment>
3145
3145
  #include <colorspace_fragment>
3146
- }`,f2=`uniform float scale;
3146
+ }`,M_=`uniform float scale;
3147
3147
  attribute float lineDistance;
3148
3148
  varying float vLineDistance;
3149
3149
  #include <common>
@@ -3165,7 +3165,7 @@ void main() {
3165
3165
  #include <logdepthbuf_vertex>
3166
3166
  #include <clipping_planes_vertex>
3167
3167
  #include <fog_vertex>
3168
- }`,p2=`uniform vec3 diffuse;
3168
+ }`,y_=`uniform vec3 diffuse;
3169
3169
  uniform float opacity;
3170
3170
  uniform float dashSize;
3171
3171
  uniform float totalSize;
@@ -3193,7 +3193,7 @@ void main() {
3193
3193
  #include <colorspace_fragment>
3194
3194
  #include <fog_fragment>
3195
3195
  #include <premultiplied_alpha_fragment>
3196
- }`,m2=`#include <common>
3196
+ }`,S_=`#include <common>
3197
3197
  #include <batching_pars_vertex>
3198
3198
  #include <uv_pars_vertex>
3199
3199
  #include <envmap_pars_vertex>
@@ -3225,7 +3225,7 @@ void main() {
3225
3225
  #include <worldpos_vertex>
3226
3226
  #include <envmap_vertex>
3227
3227
  #include <fog_vertex>
3228
- }`,g2=`uniform vec3 diffuse;
3228
+ }`,E_=`uniform vec3 diffuse;
3229
3229
  uniform float opacity;
3230
3230
  #ifndef FLAT_SHADED
3231
3231
  varying vec3 vNormal;
@@ -3273,7 +3273,7 @@ void main() {
3273
3273
  #include <fog_fragment>
3274
3274
  #include <premultiplied_alpha_fragment>
3275
3275
  #include <dithering_fragment>
3276
- }`,v2=`#define LAMBERT
3276
+ }`,b_=`#define LAMBERT
3277
3277
  varying vec3 vViewPosition;
3278
3278
  #include <common>
3279
3279
  #include <batching_pars_vertex>
@@ -3312,7 +3312,7 @@ void main() {
3312
3312
  #include <envmap_vertex>
3313
3313
  #include <shadowmap_vertex>
3314
3314
  #include <fog_vertex>
3315
- }`,_2=`#define LAMBERT
3315
+ }`,A_=`#define LAMBERT
3316
3316
  uniform vec3 diffuse;
3317
3317
  uniform vec3 emissive;
3318
3318
  uniform float opacity;
@@ -3370,7 +3370,7 @@ void main() {
3370
3370
  #include <fog_fragment>
3371
3371
  #include <premultiplied_alpha_fragment>
3372
3372
  #include <dithering_fragment>
3373
- }`,x2=`#define MATCAP
3373
+ }`,w_=`#define MATCAP
3374
3374
  varying vec3 vViewPosition;
3375
3375
  #include <common>
3376
3376
  #include <batching_pars_vertex>
@@ -3404,7 +3404,7 @@ void main() {
3404
3404
  #include <clipping_planes_vertex>
3405
3405
  #include <fog_vertex>
3406
3406
  vViewPosition = - mvPosition.xyz;
3407
- }`,M2=`#define MATCAP
3407
+ }`,T_=`#define MATCAP
3408
3408
  uniform vec3 diffuse;
3409
3409
  uniform float opacity;
3410
3410
  uniform sampler2D matcap;
@@ -3450,7 +3450,7 @@ void main() {
3450
3450
  #include <fog_fragment>
3451
3451
  #include <premultiplied_alpha_fragment>
3452
3452
  #include <dithering_fragment>
3453
- }`,S2=`#define NORMAL
3453
+ }`,R_=`#define NORMAL
3454
3454
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3455
3455
  varying vec3 vViewPosition;
3456
3456
  #endif
@@ -3483,7 +3483,7 @@ void main() {
3483
3483
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3484
3484
  vViewPosition = - mvPosition.xyz;
3485
3485
  #endif
3486
- }`,y2=`#define NORMAL
3486
+ }`,D_=`#define NORMAL
3487
3487
  uniform float opacity;
3488
3488
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3489
3489
  varying vec3 vViewPosition;
@@ -3504,7 +3504,7 @@ void main() {
3504
3504
  #ifdef OPAQUE
3505
3505
  gl_FragColor.a = 1.0;
3506
3506
  #endif
3507
- }`,E2=`#define PHONG
3507
+ }`,C_=`#define PHONG
3508
3508
  varying vec3 vViewPosition;
3509
3509
  #include <common>
3510
3510
  #include <batching_pars_vertex>
@@ -3543,7 +3543,7 @@ void main() {
3543
3543
  #include <envmap_vertex>
3544
3544
  #include <shadowmap_vertex>
3545
3545
  #include <fog_vertex>
3546
- }`,A2=`#define PHONG
3546
+ }`,P_=`#define PHONG
3547
3547
  uniform vec3 diffuse;
3548
3548
  uniform vec3 emissive;
3549
3549
  uniform vec3 specular;
@@ -3603,7 +3603,7 @@ void main() {
3603
3603
  #include <fog_fragment>
3604
3604
  #include <premultiplied_alpha_fragment>
3605
3605
  #include <dithering_fragment>
3606
- }`,b2=`#define STANDARD
3606
+ }`,I_=`#define STANDARD
3607
3607
  varying vec3 vViewPosition;
3608
3608
  #ifdef USE_TRANSMISSION
3609
3609
  varying vec3 vWorldPosition;
@@ -3646,7 +3646,7 @@ void main() {
3646
3646
  #ifdef USE_TRANSMISSION
3647
3647
  vWorldPosition = worldPosition.xyz;
3648
3648
  #endif
3649
- }`,T2=`#define STANDARD
3649
+ }`,L_=`#define STANDARD
3650
3650
  #ifdef PHYSICAL
3651
3651
  #define IOR
3652
3652
  #define USE_SPECULAR
@@ -3771,7 +3771,7 @@ void main() {
3771
3771
  #include <fog_fragment>
3772
3772
  #include <premultiplied_alpha_fragment>
3773
3773
  #include <dithering_fragment>
3774
- }`,w2=`#define TOON
3774
+ }`,N_=`#define TOON
3775
3775
  varying vec3 vViewPosition;
3776
3776
  #include <common>
3777
3777
  #include <batching_pars_vertex>
@@ -3808,7 +3808,7 @@ void main() {
3808
3808
  #include <worldpos_vertex>
3809
3809
  #include <shadowmap_vertex>
3810
3810
  #include <fog_vertex>
3811
- }`,R2=`#define TOON
3811
+ }`,U_=`#define TOON
3812
3812
  uniform vec3 diffuse;
3813
3813
  uniform vec3 emissive;
3814
3814
  uniform float opacity;
@@ -3860,7 +3860,7 @@ void main() {
3860
3860
  #include <fog_fragment>
3861
3861
  #include <premultiplied_alpha_fragment>
3862
3862
  #include <dithering_fragment>
3863
- }`,D2=`uniform float size;
3863
+ }`,O_=`uniform float size;
3864
3864
  uniform float scale;
3865
3865
  #include <common>
3866
3866
  #include <color_pars_vertex>
@@ -3891,7 +3891,7 @@ void main() {
3891
3891
  #include <clipping_planes_vertex>
3892
3892
  #include <worldpos_vertex>
3893
3893
  #include <fog_vertex>
3894
- }`,C2=`uniform vec3 diffuse;
3894
+ }`,F_=`uniform vec3 diffuse;
3895
3895
  uniform float opacity;
3896
3896
  #include <common>
3897
3897
  #include <color_pars_fragment>
@@ -3916,7 +3916,7 @@ void main() {
3916
3916
  #include <colorspace_fragment>
3917
3917
  #include <fog_fragment>
3918
3918
  #include <premultiplied_alpha_fragment>
3919
- }`,P2=`#include <common>
3919
+ }`,z_=`#include <common>
3920
3920
  #include <batching_pars_vertex>
3921
3921
  #include <fog_pars_vertex>
3922
3922
  #include <morphtarget_pars_vertex>
@@ -3939,7 +3939,7 @@ void main() {
3939
3939
  #include <worldpos_vertex>
3940
3940
  #include <shadowmap_vertex>
3941
3941
  #include <fog_vertex>
3942
- }`,I2=`uniform vec3 color;
3942
+ }`,B_=`uniform vec3 color;
3943
3943
  uniform float opacity;
3944
3944
  #include <common>
3945
3945
  #include <fog_pars_fragment>
@@ -3955,7 +3955,7 @@ void main() {
3955
3955
  #include <colorspace_fragment>
3956
3956
  #include <fog_fragment>
3957
3957
  #include <premultiplied_alpha_fragment>
3958
- }`,L2=`uniform float rotation;
3958
+ }`,k_=`uniform float rotation;
3959
3959
  uniform vec2 center;
3960
3960
  #include <common>
3961
3961
  #include <uv_pars_vertex>
@@ -3979,7 +3979,7 @@ void main() {
3979
3979
  #include <logdepthbuf_vertex>
3980
3980
  #include <clipping_planes_vertex>
3981
3981
  #include <fog_vertex>
3982
- }`,N2=`uniform vec3 diffuse;
3982
+ }`,H_=`uniform vec3 diffuse;
3983
3983
  uniform float opacity;
3984
3984
  #include <common>
3985
3985
  #include <uv_pars_fragment>
@@ -4004,7 +4004,7 @@ void main() {
4004
4004
  #include <tonemapping_fragment>
4005
4005
  #include <colorspace_fragment>
4006
4006
  #include <fog_fragment>
4007
- }`,Ve={alphahash_fragment:tg,alphahash_pars_fragment:ng,alphamap_fragment:ig,alphamap_pars_fragment:sg,alphatest_fragment:rg,alphatest_pars_fragment:ag,aomap_fragment:og,aomap_pars_fragment:cg,batching_pars_vertex:lg,batching_vertex:hg,begin_vertex:ug,beginnormal_vertex:dg,bsdfs:fg,iridescence_fragment:pg,bumpmap_pars_fragment:mg,clipping_planes_fragment:gg,clipping_planes_pars_fragment:vg,clipping_planes_pars_vertex:_g,clipping_planes_vertex:xg,color_fragment:Mg,color_pars_fragment:Sg,color_pars_vertex:yg,color_vertex:Eg,common:Ag,cube_uv_reflection_fragment:bg,defaultnormal_vertex:Tg,displacementmap_pars_vertex:wg,displacementmap_vertex:Rg,emissivemap_fragment:Dg,emissivemap_pars_fragment:Cg,colorspace_fragment:Pg,colorspace_pars_fragment:Ig,envmap_fragment:Lg,envmap_common_pars_fragment:Ng,envmap_pars_fragment:Ug,envmap_pars_vertex:Og,envmap_physical_pars_fragment:Yg,envmap_vertex:Fg,fog_vertex:zg,fog_pars_vertex:Bg,fog_fragment:Hg,fog_pars_fragment:kg,gradientmap_pars_fragment:Gg,lightmap_pars_fragment:Vg,lights_lambert_fragment:Wg,lights_lambert_pars_fragment:Xg,lights_pars_begin:qg,lights_toon_fragment:Kg,lights_toon_pars_fragment:Zg,lights_phong_fragment:$g,lights_phong_pars_fragment:Jg,lights_physical_fragment:Qg,lights_physical_pars_fragment:jg,lights_fragment_begin:e1,lights_fragment_maps:t1,lights_fragment_end:n1,lightprobes_pars_fragment:i1,logdepthbuf_fragment:s1,logdepthbuf_pars_fragment:r1,logdepthbuf_pars_vertex:a1,logdepthbuf_vertex:o1,map_fragment:c1,map_pars_fragment:l1,map_particle_fragment:h1,map_particle_pars_fragment:u1,metalnessmap_fragment:d1,metalnessmap_pars_fragment:f1,morphinstance_vertex:p1,morphcolor_vertex:m1,morphnormal_vertex:g1,morphtarget_pars_vertex:v1,morphtarget_vertex:_1,normal_fragment_begin:x1,normal_fragment_maps:M1,normal_pars_fragment:S1,normal_pars_vertex:y1,normal_vertex:E1,normalmap_pars_fragment:A1,clearcoat_normal_fragment_begin:b1,clearcoat_normal_fragment_maps:T1,clearcoat_pars_fragment:w1,iridescence_pars_fragment:R1,opaque_fragment:D1,packing:C1,premultiplied_alpha_fragment:P1,project_vertex:I1,dithering_fragment:L1,dithering_pars_fragment:N1,roughnessmap_fragment:U1,roughnessmap_pars_fragment:O1,shadowmap_pars_fragment:F1,shadowmap_pars_vertex:z1,shadowmap_vertex:B1,shadowmask_pars_fragment:H1,skinbase_vertex:k1,skinning_pars_vertex:G1,skinning_vertex:V1,skinnormal_vertex:W1,specularmap_fragment:X1,specularmap_pars_fragment:q1,tonemapping_fragment:Y1,tonemapping_pars_fragment:K1,transmission_fragment:Z1,transmission_pars_fragment:$1,uv_pars_fragment:J1,uv_pars_vertex:Q1,uv_vertex:j1,worldpos_vertex:e2,background_vert:t2,background_frag:n2,backgroundCube_vert:i2,backgroundCube_frag:s2,cube_vert:r2,cube_frag:a2,depth_vert:o2,depth_frag:c2,distance_vert:l2,distance_frag:h2,equirect_vert:u2,equirect_frag:d2,linedashed_vert:f2,linedashed_frag:p2,meshbasic_vert:m2,meshbasic_frag:g2,meshlambert_vert:v2,meshlambert_frag:_2,meshmatcap_vert:x2,meshmatcap_frag:M2,meshnormal_vert:S2,meshnormal_frag:y2,meshphong_vert:E2,meshphong_frag:A2,meshphysical_vert:b2,meshphysical_frag:T2,meshtoon_vert:w2,meshtoon_frag:R2,points_vert:D2,points_frag:C2,shadow_vert:P2,shadow_frag:I2,sprite_vert:L2,sprite_frag:N2},fe={common:{diffuse:{value:new Me(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ze}},envmap:{envMap:{value:null},envMapRotation:{value:new ze},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ze}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ze}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ze},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ze},normalScale:{value:new Le(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ze},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ze}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ze}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ze}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Me(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 L},probesMax:{value:new L},probesResolution:{value:new L}},points:{diffuse:{value:new Me(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0},uvTransform:{value:new ze}},sprite:{diffuse:{value:new Me(16777215)},opacity:{value:1},center:{value:new Le(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}}},Wn={basic:{uniforms:en([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.fog]),vertexShader:Ve.meshbasic_vert,fragmentShader:Ve.meshbasic_frag},lambert:{uniforms:en([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new Me(0)},envMapIntensity:{value:1}}]),vertexShader:Ve.meshlambert_vert,fragmentShader:Ve.meshlambert_frag},phong:{uniforms:en([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new Me(0)},specular:{value:new Me(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ve.meshphong_vert,fragmentShader:Ve.meshphong_frag},standard:{uniforms:en([fe.common,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.roughnessmap,fe.metalnessmap,fe.fog,fe.lights,{emissive:{value:new Me(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag},toon:{uniforms:en([fe.common,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.gradientmap,fe.fog,fe.lights,{emissive:{value:new Me(0)}}]),vertexShader:Ve.meshtoon_vert,fragmentShader:Ve.meshtoon_frag},matcap:{uniforms:en([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,{matcap:{value:null}}]),vertexShader:Ve.meshmatcap_vert,fragmentShader:Ve.meshmatcap_frag},points:{uniforms:en([fe.points,fe.fog]),vertexShader:Ve.points_vert,fragmentShader:Ve.points_frag},dashed:{uniforms:en([fe.common,fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ve.linedashed_vert,fragmentShader:Ve.linedashed_frag},depth:{uniforms:en([fe.common,fe.displacementmap]),vertexShader:Ve.depth_vert,fragmentShader:Ve.depth_frag},normal:{uniforms:en([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,{opacity:{value:1}}]),vertexShader:Ve.meshnormal_vert,fragmentShader:Ve.meshnormal_frag},sprite:{uniforms:en([fe.sprite,fe.fog]),vertexShader:Ve.sprite_vert,fragmentShader:Ve.sprite_frag},background:{uniforms:{uvTransform:{value:new ze},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ve.background_vert,fragmentShader:Ve.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ze}},vertexShader:Ve.backgroundCube_vert,fragmentShader:Ve.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ve.cube_vert,fragmentShader:Ve.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ve.equirect_vert,fragmentShader:Ve.equirect_frag},distance:{uniforms:en([fe.common,fe.displacementmap,{referencePosition:{value:new L},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ve.distance_vert,fragmentShader:Ve.distance_frag},shadow:{uniforms:en([fe.lights,fe.fog,{color:{value:new Me(0)},opacity:{value:1}}]),vertexShader:Ve.shadow_vert,fragmentShader:Ve.shadow_frag}};Wn.physical={uniforms:en([Wn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ze},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ze},clearcoatNormalScale:{value:new Le(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ze},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ze},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ze},sheen:{value:0},sheenColor:{value:new Me(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ze},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ze},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ze},transmissionSamplerSize:{value:new Le},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ze},attenuationDistance:{value:0},attenuationColor:{value:new Me(0)},specularColor:{value:new Me(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ze},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ze},anisotropyVector:{value:new Le},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ze}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag};const ba={r:0,b:0,g:0},U2=new dt,O0=new ze;O0.set(-1,0,0,0,1,0,0,0,1);function O2(i,e,t,n,s,r){const a=new Me(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=e.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"?t.buffers.color.setClear(0,0,0,1,r):y==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||T)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function x(A,T){const M=f(T);M&&(M.isCubeTexture||M.mapping===vo)?(l===void 0&&(l=new je(new Tn(1,1,1),new At({name:"BackgroundCubeMaterial",uniforms:ir(Wn.backgroundCube.uniforms),vertexShader:Wn.backgroundCube.vertexShader,fragmentShader:Wn.backgroundCube.fragmentShader,side:It,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(U2.makeRotationFromEuler(T.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(O0),l.material.toneMapped=$e.getTransfer(M.colorSpace)!==it,(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 je(new ki(2,2),new At({name:"BackgroundMaterial",uniforms:ir(Wn.background.uniforms),vertexShader:Wn.background.vertexShader,fragmentShader:Wn.background.fragmentShader,side:Fi,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=$e.getTransfer(M.colorSpace)!==it,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(ba,P0(i)),t.buffers.color.setClear(ba.r,ba.g,ba.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 F2(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=d(null);let r=s,a=!1;function o(D,I,W,X,O){let q=!1;const G=u(D,X,W,I);r!==G&&(r=G,l(r.object)),q=f(D,X,W,O),q&&g(D,X,W,O),O!==null&&e.update(O,i.ELEMENT_ARRAY_BUFFER),(q||a)&&(a=!1,M(D,I,W,X),O!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(O).buffer))}function c(){return i.createVertexArray()}function l(D){return i.bindVertexArray(D)}function h(D){return i.deleteVertexArray(D)}function u(D,I,W,X){const O=X.wireframe===!0;let q=n[I.id];q===void 0&&(q={},n[I.id]=q);const G=D.isInstancedMesh===!0?D.id:0;let $=q[G];$===void 0&&($={},q[G]=$);let te=$[W.id];te===void 0&&(te={},$[W.id]=te);let j=te[O];return j===void 0&&(j=d(c()),te[O]=j),j}function d(D){const I=[],W=[],X=[];for(let O=0;O<t;O++)I[O]=0,W[O]=0,X[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:W,attributeDivisors:X,object:D,attributes:{},index:null}}function f(D,I,W,X){const O=r.attributes,q=I.attributes;let G=0;const $=W.getAttributes();for(const te in $)if($[te].location>=0){const ie=O[te];let ue=q[te];if(ue===void 0&&(te==="instanceMatrix"&&D.instanceMatrix&&(ue=D.instanceMatrix),te==="instanceColor"&&D.instanceColor&&(ue=D.instanceColor)),ie===void 0||ie.attribute!==ue||ue&&ie.data!==ue.data)return!0;G++}return r.attributesNum!==G||r.index!==X}function g(D,I,W,X){const O={},q=I.attributes;let G=0;const $=W.getAttributes();for(const te in $)if($[te].location>=0){let ie=q[te];ie===void 0&&(te==="instanceMatrix"&&D.instanceMatrix&&(ie=D.instanceMatrix),te==="instanceColor"&&D.instanceColor&&(ie=D.instanceColor));const ue={};ue.attribute=ie,ie&&ie.data&&(ue.data=ie.data),O[te]=ue,G++}r.attributes=O,r.attributesNum=G,r.index=X}function x(){const D=r.newAttributes;for(let I=0,W=D.length;I<W;I++)D[I]=0}function m(D){p(D,0)}function p(D,I){const W=r.newAttributes,X=r.enabledAttributes,O=r.attributeDivisors;W[D]=1,X[D]===0&&(i.enableVertexAttribArray(D),X[D]=1),O[D]!==I&&(i.vertexAttribDivisor(D,I),O[D]=I)}function A(){const D=r.newAttributes,I=r.enabledAttributes;for(let W=0,X=I.length;W<X;W++)I[W]!==D[W]&&(i.disableVertexAttribArray(W),I[W]=0)}function T(D,I,W,X,O,q,G){G===!0?i.vertexAttribIPointer(D,I,W,O,q):i.vertexAttribPointer(D,I,W,X,O,q)}function M(D,I,W,X){x();const O=X.attributes,q=W.getAttributes(),G=I.defaultAttributeValues;for(const $ in q){const te=q[$];if(te.location>=0){let j=O[$];if(j===void 0&&($==="instanceMatrix"&&D.instanceMatrix&&(j=D.instanceMatrix),$==="instanceColor"&&D.instanceColor&&(j=D.instanceColor)),j!==void 0){const ie=j.normalized,ue=j.itemSize,He=e.get(j);if(He===void 0)continue;const Ke=He.buffer,Be=He.type,Y=He.bytesPerElement,re=Be===i.INT||Be===i.UNSIGNED_INT||j.gpuType===nh;if(j.isInterleavedBufferAttribute){const ne=j.data,z=ne.stride,Ae=j.offset;if(ne.isInstancedInterleavedBuffer){for(let Ce=0;Ce<te.locationSize;Ce++)p(te.location+Ce,ne.meshPerAttribute);D.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let Ce=0;Ce<te.locationSize;Ce++)m(te.location+Ce);i.bindBuffer(i.ARRAY_BUFFER,Ke);for(let Ce=0;Ce<te.locationSize;Ce++)T(te.location+Ce,ue/te.locationSize,Be,ie,z*Y,(Ae+ue/te.locationSize*Ce)*Y,re)}else{if(j.isInstancedBufferAttribute){for(let ne=0;ne<te.locationSize;ne++)p(te.location+ne,j.meshPerAttribute);D.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=j.meshPerAttribute*j.count)}else for(let ne=0;ne<te.locationSize;ne++)m(te.location+ne);i.bindBuffer(i.ARRAY_BUFFER,Ke);for(let ne=0;ne<te.locationSize;ne++)T(te.location+ne,ue/te.locationSize,Be,ie,ue*Y,ue/te.locationSize*ne*Y,re)}}else if(G!==void 0){const ie=G[$];if(ie!==void 0)switch(ie.length){case 2:i.vertexAttrib2fv(te.location,ie);break;case 3:i.vertexAttrib3fv(te.location,ie);break;case 4:i.vertexAttrib4fv(te.location,ie);break;default:i.vertexAttrib1fv(te.location,ie)}}}}A()}function y(){E();for(const D in n){const I=n[D];for(const W in I){const X=I[W];for(const O in X){const q=X[O];for(const G in q)h(q[G].object),delete q[G];delete X[O]}}delete n[D]}}function b(D){if(n[D.id]===void 0)return;const I=n[D.id];for(const W in I){const X=I[W];for(const O in X){const q=X[O];for(const G in q)h(q[G].object),delete q[G];delete X[O]}}delete n[D.id]}function R(D){for(const I in n){const W=n[I];for(const X in W){const O=W[X];if(O[D.id]===void 0)continue;const q=O[D.id];for(const G in q)h(q[G].object),delete q[G];delete O[D.id]}}}function _(D){for(const I in n){const W=n[I],X=D.isInstancedMesh===!0?D.id:0,O=W[X];if(O!==void 0){for(const q in O){const G=O[q];for(const $ in G)h(G[$].object),delete G[$];delete O[q]}delete W[X],Object.keys(W).length===0&&delete n[I]}}}function E(){C(),a=!0,r!==s&&(r=s,l(r.object))}function C(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:E,resetDefaultState:C,dispose:y,releaseStatesOfGeometry:b,releaseStatesOfObject:_,releaseStatesOfProgram:R,initAttributes:x,enableAttribute:m,disableUnusedAttributes:A}}function z2(i,e,t){let n;function s(c){n=c}function r(c,l){i.drawArrays(n,c,l),t.update(l,n,1)}function a(c,l,h){h!==0&&(i.drawArraysInstanced(n,c,l,h),t.update(l,n,h))}function o(c,l,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,h);let d=0;for(let f=0;f<h;f++)d+=l[f];t.update(d,n,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function B2(i,e,t,n){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){const R=e.get("EXT_texture_filter_anisotropic");s=i.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(R){return!(R!==hn&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const _=R===Qt&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(R!==xn&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==$n&&!_)}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=t.precision!==void 0?t.precision:"highp";const h=c(l);h!==l&&(Fe("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const u=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&d===!1&&Fe("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 H2(i){const e=this;let t=null,n=0,s=!1,r=!1;const a=new $i,o=new ze,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){t=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]=t[y];p.clippingState=M,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=A}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.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 e.numPlanes=x,e.numIntersection=0,m}}const Ii=4,wu=[.125,.215,.35,.446,.526,.582],ji=20,k2=256,vr=new or,Ru=new Me;let ac=null,oc=0,cc=0,lc=!1;const G2=new L;class Du{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,s=100,r={}){const{size:a=256,position:o=G2}=r;ac=this._renderer.getRenderTarget(),oc=this._renderer.getActiveCubeFace(),cc=this._renderer.getActiveMipmapLevel(),lc=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,n,s,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Iu(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Pu(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(ac,oc,cc),this._renderer.xr.enabled=lc,e.scissorTest=!1,Os(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===as||e.mapping===nr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),ac=this._renderer.getRenderTarget(),oc=this._renderer.getActiveCubeFace(),cc=this._renderer.getActiveMipmapLevel(),lc=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Et,minFilter:Et,generateMipmaps:!1,type:Qt,format:hn,colorSpace:to,depthBuffer:!1},s=Cu(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Cu(e,t,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=V2(r)),this._blurMaterial=X2(r,e,t),this._ggxMaterial=W2(r,e,t)}return s}_compileMaterial(e){const t=new je(new Rt,e);this._renderer.compile(t,vr)}_sceneToCubeUV(e,t,n,s,r){const c=new _n(90,1,t,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(Ru),u.toneMapping=ei,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(s),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new je(new Tn,new cs({name:"PMREM.Background",side:It,depthWrite:!1,depthTest:!1})));const x=this._backgroundBox,m=x.material;let p=!1;const A=e.background;A?A.isColor&&(m.color.copy(A),e.background=null,p=!0):(m.color.copy(Ru),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;Os(s,M*y,T>2?y:0,y,y),u.setRenderTarget(s),p&&u.render(x,c),u.render(e,c)}u.toneMapping=f,u.autoClear=d,e.background=A}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===as||e.mapping===nr;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Iu()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Pu());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const c=this._cubeSize;Os(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,vr)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;r<s;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,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=t/(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-Ii?n-g+Ii:0),p=4*(this._cubeSize-x);c.envMap.value=e.texture,c.roughness.value=f,c.mipInt.value=g-t,Os(r,m,p,3*x,2*x),s.setRenderTarget(r),s.render(o,vr),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=g-n,Os(e,m,p,3*x,2*x),s.setRenderTarget(e),s.render(o,vr)}_blur(e,t,n,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,s,"latitudinal",r),this._halfBlur(a,e,n,n,s,"longitudinal",r)}_halfBlur(e,t,n,s,r,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Ze("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*ji-1),x=r/g,m=isFinite(r)?1+Math.floor(h*x):ji;m>ji&&Fe(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${ji}`);const p=[];let A=0;for(let R=0;R<ji;++R){const _=R/x,E=Math.exp(-_*_/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=e.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-Ii?s-T+Ii:0),b=4*(this._cubeSize-M);Os(t,y,b,3*M,2*M),c.setRenderTarget(t),c.render(u,vr)}}function V2(i){const e=[],t=[],n=[];let s=i;const r=i-Ii+1+wu.length;for(let a=0;a<r;a++){const o=Math.pow(2,s);e.push(o);let c=1/o;a>i-Ii?c=wu[a-i+Ii-1]:a===0&&(c=0),t.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,_=b>2?0:-1,E=[R,_,0,R+2/3,_,0,R+2/3,_+1,0,R,_,0,R+2/3,_+1,0,R,_+1,0];A.set(E,x*g*b),T.set(d,m*g*b);const C=[b,b,b,b,b,b];M.set(C,p*g*b)}const y=new Rt;y.setAttribute("position",new ut(A,x)),y.setAttribute("uv",new ut(T,m)),y.setAttribute("faceIndex",new ut(M,p)),n.push(new je(y,null)),s>Ii&&s--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Cu(i,e,t){const n=new un(i,e,t);return n.texture.mapping=vo,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Os(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function W2(i,e,t){return new At({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:k2,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:yo(),fragmentShader:`
4007
+ }`,We={alphahash_fragment:c2,alphahash_pars_fragment:l2,alphamap_fragment:h2,alphamap_pars_fragment:u2,alphatest_fragment:d2,alphatest_pars_fragment:f2,aomap_fragment:p2,aomap_pars_fragment:m2,batching_pars_vertex:g2,batching_vertex:v2,begin_vertex:_2,beginnormal_vertex:x2,bsdfs:M2,iridescence_fragment:y2,bumpmap_pars_fragment:S2,clipping_planes_fragment:E2,clipping_planes_pars_fragment:b2,clipping_planes_pars_vertex:A2,clipping_planes_vertex:w2,color_fragment:T2,color_pars_fragment:R2,color_pars_vertex:D2,color_vertex:C2,common:P2,cube_uv_reflection_fragment:I2,defaultnormal_vertex:L2,displacementmap_pars_vertex:N2,displacementmap_vertex:U2,emissivemap_fragment:O2,emissivemap_pars_fragment:F2,colorspace_fragment:z2,colorspace_pars_fragment:B2,envmap_fragment:k2,envmap_common_pars_fragment:H2,envmap_pars_fragment:G2,envmap_pars_vertex:V2,envmap_physical_pars_fragment:ev,envmap_vertex:W2,fog_vertex:X2,fog_pars_vertex:q2,fog_fragment:Y2,fog_pars_fragment:K2,gradientmap_pars_fragment:$2,lightmap_pars_fragment:Z2,lights_lambert_fragment:J2,lights_lambert_pars_fragment:Q2,lights_pars_begin:j2,lights_toon_fragment:tv,lights_toon_pars_fragment:nv,lights_phong_fragment:iv,lights_phong_pars_fragment:sv,lights_physical_fragment:rv,lights_physical_pars_fragment:av,lights_fragment_begin:ov,lights_fragment_maps:cv,lights_fragment_end:lv,lightprobes_pars_fragment:hv,logdepthbuf_fragment:uv,logdepthbuf_pars_fragment:dv,logdepthbuf_pars_vertex:fv,logdepthbuf_vertex:pv,map_fragment:mv,map_pars_fragment:gv,map_particle_fragment:vv,map_particle_pars_fragment:_v,metalnessmap_fragment:xv,metalnessmap_pars_fragment:Mv,morphinstance_vertex:yv,morphcolor_vertex:Sv,morphnormal_vertex:Ev,morphtarget_pars_vertex:bv,morphtarget_vertex:Av,normal_fragment_begin:wv,normal_fragment_maps:Tv,normal_pars_fragment:Rv,normal_pars_vertex:Dv,normal_vertex:Cv,normalmap_pars_fragment:Pv,clearcoat_normal_fragment_begin:Iv,clearcoat_normal_fragment_maps:Lv,clearcoat_pars_fragment:Nv,iridescence_pars_fragment:Uv,opaque_fragment:Ov,packing:Fv,premultiplied_alpha_fragment:zv,project_vertex:Bv,dithering_fragment:kv,dithering_pars_fragment:Hv,roughnessmap_fragment:Gv,roughnessmap_pars_fragment:Vv,shadowmap_pars_fragment:Wv,shadowmap_pars_vertex:Xv,shadowmap_vertex:qv,shadowmask_pars_fragment:Yv,skinbase_vertex:Kv,skinning_pars_vertex:$v,skinning_vertex:Zv,skinnormal_vertex:Jv,specularmap_fragment:Qv,specularmap_pars_fragment:jv,tonemapping_fragment:e_,tonemapping_pars_fragment:t_,transmission_fragment:n_,transmission_pars_fragment:i_,uv_pars_fragment:s_,uv_pars_vertex:r_,uv_vertex:a_,worldpos_vertex:o_,background_vert:c_,background_frag:l_,backgroundCube_vert:h_,backgroundCube_frag:u_,cube_vert:d_,cube_frag:f_,depth_vert:p_,depth_frag:m_,distance_vert:g_,distance_frag:v_,equirect_vert:__,equirect_frag:x_,linedashed_vert:M_,linedashed_frag:y_,meshbasic_vert:S_,meshbasic_frag:E_,meshlambert_vert:b_,meshlambert_frag:A_,meshmatcap_vert:w_,meshmatcap_frag:T_,meshnormal_vert:R_,meshnormal_frag:D_,meshphong_vert:C_,meshphong_frag:P_,meshphysical_vert:I_,meshphysical_frag:L_,meshtoon_vert:N_,meshtoon_frag:U_,points_vert:O_,points_frag:F_,shadow_vert:z_,shadow_frag:B_,sprite_vert:k_,sprite_frag:H_},fe={common:{diffuse:{value:new ve(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Be},alphaMap:{value:null},alphaMapTransform:{value:new Be},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Be}},envmap:{envMap:{value:null},envMapRotation:{value:new Be},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Be}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Be}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Be},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Be},normalScale:{value:new Ie(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Be},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Be}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Be}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Be}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ve(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{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 P},probesMax:{value:new P},probesResolution:{value:new P}},points:{diffuse:{value:new ve(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Be},alphaTest:{value:0},uvTransform:{value:new Be}},sprite:{diffuse:{value:new ve(16777215)},opacity:{value:1},center:{value:new Ie(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Be},alphaMap:{value:null},alphaMapTransform:{value:new Be},alphaTest:{value:0}}},Zn={basic:{uniforms:tn([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.fog]),vertexShader:We.meshbasic_vert,fragmentShader:We.meshbasic_frag},lambert:{uniforms:tn([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new ve(0)},envMapIntensity:{value:1}}]),vertexShader:We.meshlambert_vert,fragmentShader:We.meshlambert_frag},phong:{uniforms:tn([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new ve(0)},specular:{value:new ve(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:We.meshphong_vert,fragmentShader:We.meshphong_frag},standard:{uniforms:tn([fe.common,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.roughnessmap,fe.metalnessmap,fe.fog,fe.lights,{emissive:{value:new ve(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:We.meshphysical_vert,fragmentShader:We.meshphysical_frag},toon:{uniforms:tn([fe.common,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.gradientmap,fe.fog,fe.lights,{emissive:{value:new ve(0)}}]),vertexShader:We.meshtoon_vert,fragmentShader:We.meshtoon_frag},matcap:{uniforms:tn([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,{matcap:{value:null}}]),vertexShader:We.meshmatcap_vert,fragmentShader:We.meshmatcap_frag},points:{uniforms:tn([fe.points,fe.fog]),vertexShader:We.points_vert,fragmentShader:We.points_frag},dashed:{uniforms:tn([fe.common,fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:We.linedashed_vert,fragmentShader:We.linedashed_frag},depth:{uniforms:tn([fe.common,fe.displacementmap]),vertexShader:We.depth_vert,fragmentShader:We.depth_frag},normal:{uniforms:tn([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,{opacity:{value:1}}]),vertexShader:We.meshnormal_vert,fragmentShader:We.meshnormal_frag},sprite:{uniforms:tn([fe.sprite,fe.fog]),vertexShader:We.sprite_vert,fragmentShader:We.sprite_frag},background:{uniforms:{uvTransform:{value:new Be},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:We.background_vert,fragmentShader:We.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Be}},vertexShader:We.backgroundCube_vert,fragmentShader:We.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:We.cube_vert,fragmentShader:We.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:We.equirect_vert,fragmentShader:We.equirect_frag},distance:{uniforms:tn([fe.common,fe.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:We.distance_vert,fragmentShader:We.distance_frag},shadow:{uniforms:tn([fe.lights,fe.fog,{color:{value:new ve(0)},opacity:{value:1}}]),vertexShader:We.shadow_vert,fragmentShader:We.shadow_frag}};Zn.physical={uniforms:tn([Zn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Be},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Be},clearcoatNormalScale:{value:new Ie(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Be},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Be},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Be},sheen:{value:0},sheenColor:{value:new ve(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Be},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Be},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Be},transmissionSamplerSize:{value:new Ie},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Be},attenuationDistance:{value:0},attenuationColor:{value:new ve(0)},specularColor:{value:new ve(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Be},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Be},anisotropyVector:{value:new Ie},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Be}}]),vertexShader:We.meshphysical_vert,fragmentShader:We.meshphysical_frag};const Ja={r:0,b:0,g:0},G_=new qe,Jf=new Be;Jf.set(-1,0,0,0,1,0,0,0,1);function V_(i,e,t,n,s,r){const a=new ve(0);let o=s===!0?0:1,c,l,h=null,u=0,d=null;function f(b){let w=b.isScene===!0?b.background:null;if(w&&w.isTexture){const M=b.backgroundBlurriness>0;w=e.get(w,M)}return w}function g(b){let w=!1;const M=f(b);M===null?m(a,o):M&&M.isColor&&(m(M,1),w=!0);const S=i.xr.getEnvironmentBlendMode();S==="additive"?t.buffers.color.setClear(0,0,0,1,r):S==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||w)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function x(b,w){const M=f(w);M&&(M.isCubeTexture||M.mapping===qo)?(l===void 0&&(l=new Qe(new Cn(1,1,1),new Tt({name:"BackgroundCubeMaterial",uniforms:fr(Zn.backgroundCube.uniforms),vertexShader:Zn.backgroundCube.vertexShader,fragmentShader:Zn.backgroundCube.fragmentShader,side:Ut,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(S,A,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=M,l.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(G_.makeRotationFromEuler(w.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Jf),l.material.toneMapped=Je.getTransfer(M.colorSpace)!==st,(h!==M||u!==M.version||d!==i.toneMapping)&&(l.material.needsUpdate=!0,h=M,u=M.version,d=i.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new Qe(new $i(2,2),new Tt({name:"BackgroundMaterial",uniforms:fr(Zn.background.uniforms),vertexShader:Zn.background.vertexShader,fragmentShader:Zn.background.fragmentShader,side:qi,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=w.backgroundIntensity,c.material.toneMapped=Je.getTransfer(M.colorSpace)!==st,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(),b.unshift(c,c.geometry,c.material,0,0,null))}function m(b,w){b.getRGB(Ja,Xf(i)),t.buffers.color.setClear(Ja.r,Ja.g,Ja.b,w,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(b,w=1){a.set(b),o=w,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(b){o=b,m(a,o)},render:g,addToRenderList:x,dispose:p}}function W_(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=d(null);let r=s,a=!1;function o(D,I,V,q,U){let X=!1;const G=u(D,q,V,I);r!==G&&(r=G,l(r.object)),X=f(D,q,V,U),X&&g(D,q,V,U),U!==null&&e.update(U,i.ELEMENT_ARRAY_BUFFER),(X||a)&&(a=!1,M(D,I,V,q),U!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(U).buffer))}function c(){return i.createVertexArray()}function l(D){return i.bindVertexArray(D)}function h(D){return i.deleteVertexArray(D)}function u(D,I,V,q){const U=q.wireframe===!0;let X=n[I.id];X===void 0&&(X={},n[I.id]=X);const G=D.isInstancedMesh===!0?D.id:0;let Z=X[G];Z===void 0&&(Z={},X[G]=Z);let te=Z[V.id];te===void 0&&(te={},Z[V.id]=te);let j=te[U];return j===void 0&&(j=d(c()),te[U]=j),j}function d(D){const I=[],V=[],q=[];for(let U=0;U<t;U++)I[U]=0,V[U]=0,q[U]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:V,attributeDivisors:q,object:D,attributes:{},index:null}}function f(D,I,V,q){const U=r.attributes,X=I.attributes;let G=0;const Z=V.getAttributes();for(const te in Z)if(Z[te].location>=0){const ie=U[te];let ue=X[te];if(ue===void 0&&(te==="instanceMatrix"&&D.instanceMatrix&&(ue=D.instanceMatrix),te==="instanceColor"&&D.instanceColor&&(ue=D.instanceColor)),ie===void 0||ie.attribute!==ue||ue&&ie.data!==ue.data)return!0;G++}return r.attributesNum!==G||r.index!==q}function g(D,I,V,q){const U={},X=I.attributes;let G=0;const Z=V.getAttributes();for(const te in Z)if(Z[te].location>=0){let ie=X[te];ie===void 0&&(te==="instanceMatrix"&&D.instanceMatrix&&(ie=D.instanceMatrix),te==="instanceColor"&&D.instanceColor&&(ie=D.instanceColor));const ue={};ue.attribute=ie,ie&&ie.data&&(ue.data=ie.data),U[te]=ue,G++}r.attributes=U,r.attributesNum=G,r.index=q}function x(){const D=r.newAttributes;for(let I=0,V=D.length;I<V;I++)D[I]=0}function m(D){p(D,0)}function p(D,I){const V=r.newAttributes,q=r.enabledAttributes,U=r.attributeDivisors;V[D]=1,q[D]===0&&(i.enableVertexAttribArray(D),q[D]=1),U[D]!==I&&(i.vertexAttribDivisor(D,I),U[D]=I)}function b(){const D=r.newAttributes,I=r.enabledAttributes;for(let V=0,q=I.length;V<q;V++)I[V]!==D[V]&&(i.disableVertexAttribArray(V),I[V]=0)}function w(D,I,V,q,U,X,G){G===!0?i.vertexAttribIPointer(D,I,V,U,X):i.vertexAttribPointer(D,I,V,q,U,X)}function M(D,I,V,q){x();const U=q.attributes,X=V.getAttributes(),G=I.defaultAttributeValues;for(const Z in X){const te=X[Z];if(te.location>=0){let j=U[Z];if(j===void 0&&(Z==="instanceMatrix"&&D.instanceMatrix&&(j=D.instanceMatrix),Z==="instanceColor"&&D.instanceColor&&(j=D.instanceColor)),j!==void 0){const ie=j.normalized,ue=j.itemSize,He=e.get(j);if(He===void 0)continue;const Ze=He.buffer,ke=He.type,Y=He.bytesPerElement,re=ke===i.INT||ke===i.UNSIGNED_INT||j.gpuType===Fh;if(j.isInterleavedBufferAttribute){const ne=j.data,z=ne.stride,be=j.offset;if(ne.isInstancedInterleavedBuffer){for(let Pe=0;Pe<te.locationSize;Pe++)p(te.location+Pe,ne.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let Pe=0;Pe<te.locationSize;Pe++)m(te.location+Pe);i.bindBuffer(i.ARRAY_BUFFER,Ze);for(let Pe=0;Pe<te.locationSize;Pe++)w(te.location+Pe,ue/te.locationSize,ke,ie,z*Y,(be+ue/te.locationSize*Pe)*Y,re)}else{if(j.isInstancedBufferAttribute){for(let ne=0;ne<te.locationSize;ne++)p(te.location+ne,j.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=j.meshPerAttribute*j.count)}else for(let ne=0;ne<te.locationSize;ne++)m(te.location+ne);i.bindBuffer(i.ARRAY_BUFFER,Ze);for(let ne=0;ne<te.locationSize;ne++)w(te.location+ne,ue/te.locationSize,ke,ie,ue*Y,ue/te.locationSize*ne*Y,re)}}else if(G!==void 0){const ie=G[Z];if(ie!==void 0)switch(ie.length){case 2:i.vertexAttrib2fv(te.location,ie);break;case 3:i.vertexAttrib3fv(te.location,ie);break;case 4:i.vertexAttrib4fv(te.location,ie);break;default:i.vertexAttrib1fv(te.location,ie)}}}}b()}function S(){E();for(const D in n){const I=n[D];for(const V in I){const q=I[V];for(const U in q){const X=q[U];for(const G in X)h(X[G].object),delete X[G];delete q[U]}}delete n[D]}}function A(D){if(n[D.id]===void 0)return;const I=n[D.id];for(const V in I){const q=I[V];for(const U in q){const X=q[U];for(const G in X)h(X[G].object),delete X[G];delete q[U]}}delete n[D.id]}function R(D){for(const I in n){const V=n[I];for(const q in V){const U=V[q];if(U[D.id]===void 0)continue;const X=U[D.id];for(const G in X)h(X[G].object),delete X[G];delete U[D.id]}}}function _(D){for(const I in n){const V=n[I],q=D.isInstancedMesh===!0?D.id:0,U=V[q];if(U!==void 0){for(const X in U){const G=U[X];for(const Z in G)h(G[Z].object),delete G[Z];delete U[X]}delete V[q],Object.keys(V).length===0&&delete n[I]}}}function E(){C(),a=!0,r!==s&&(r=s,l(r.object))}function C(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:E,resetDefaultState:C,dispose:S,releaseStatesOfGeometry:A,releaseStatesOfObject:_,releaseStatesOfProgram:R,initAttributes:x,enableAttribute:m,disableUnusedAttributes:b}}function X_(i,e,t){let n;function s(c){n=c}function r(c,l){i.drawArrays(n,c,l),t.update(l,n,1)}function a(c,l,h){h!==0&&(i.drawArraysInstanced(n,c,l,h),t.update(l,n,h))}function o(c,l,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,h);let d=0;for(let f=0;f<h;f++)d+=l[f];t.update(d,n,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function q_(i,e,t,n){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){const R=e.get("EXT_texture_filter_anisotropic");s=i.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(R){return!(R!==an&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const _=R===jt&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(R!==yn&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==Dn&&!_)}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=t.precision!==void 0?t.precision:"highp";const h=c(l);h!==l&&(Ae("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const u=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&d===!1&&Ae("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),b=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),w=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),S=i.getParameter(i.MAX_SAMPLES),A=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:b,maxVaryings:w,maxFragmentUniforms:M,maxSamples:S,samples:A}}function Y_(i){const e=this;let t=null,n=0,s=!1,r=!1;const a=new ss,o=new Be,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){t=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 b=r?0:n,w=b*4;let M=p.clippingState||null;c.value=M,M=h(g,d,w,f);for(let S=0;S!==w;++S)M[S]=t[S];p.clippingState=M,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=b}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.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,b=d.matrixWorldInverse;o.getNormalMatrix(b),(m===null||m.length<p)&&(m=new Float32Array(p));for(let w=0,M=f;w!==x;++w,M+=4)a.copy(u[w]).applyMatrix4(b,o),a.normal.toArray(m,M),m[M+3]=a.constant}c.value=m,c.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,m}}const Gi=4,Id=[.125,.215,.35,.446,.526,.582],os=20,K_=256,Lr=new xr,Ld=new ve;let Fc=null,zc=0,Bc=0,kc=!1;const $_=new P;class Nd{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,s=100,r={}){const{size:a=256,position:o=$_}=r;Fc=this._renderer.getRenderTarget(),zc=this._renderer.getActiveCubeFace(),Bc=this._renderer.getActiveMipmapLevel(),kc=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,n,s,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Fd(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Od(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Fc,zc,Bc),this._renderer.xr.enabled=kc,e.scissorTest=!1,qs(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ps||e.mapping===ur?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Fc=this._renderer.getRenderTarget(),zc=this._renderer.getActiveCubeFace(),Bc=this._renderer.getActiveMipmapLevel(),kc=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:At,minFilter:At,generateMipmaps:!1,type:jt,format:an,colorSpace:Co,depthBuffer:!1},s=Ud(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Ud(e,t,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Z_(r)),this._blurMaterial=Q_(r,e,t),this._ggxMaterial=J_(r,e,t)}return s}_compileMaterial(e){const t=new Qe(new wt,e);this._renderer.compile(t,Lr)}_sceneToCubeUV(e,t,n,s,r){const c=new dn(90,1,t,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(Ld),u.toneMapping=si,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(s),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Qe(new Cn,new gs({name:"PMREM.Background",side:Ut,depthWrite:!1,depthTest:!1})));const x=this._backgroundBox,m=x.material;let p=!1;const b=e.background;b?b.isColor&&(m.color.copy(b),e.background=null,p=!0):(m.color.copy(Ld),p=!0);for(let w=0;w<6;w++){const M=w%3;M===0?(c.up.set(0,l[w],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+h[w],r.y,r.z)):M===1?(c.up.set(0,0,l[w]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+h[w],r.z)):(c.up.set(0,l[w],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+h[w]));const S=this._cubeSize;qs(s,M*S,w>2?S:0,S,S),u.setRenderTarget(s),p&&u.render(x,c),u.render(e,c)}u.toneMapping=f,u.autoClear=d,e.background=b}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===ps||e.mapping===ur;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Fd()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Od());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const c=this._cubeSize;qs(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,Lr)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;r<s;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,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=t/(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-Gi?n-g+Gi:0),p=4*(this._cubeSize-x);c.envMap.value=e.texture,c.roughness.value=f,c.mipInt.value=g-t,qs(r,m,p,3*x,2*x),s.setRenderTarget(r),s.render(o,Lr),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=g-n,qs(e,m,p,3*x,2*x),s.setRenderTarget(e),s.render(o,Lr)}_blur(e,t,n,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,s,"latitudinal",r),this._halfBlur(a,e,n,n,s,"longitudinal",r)}_halfBlur(e,t,n,s,r,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&ze("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*os-1),x=r/g,m=isFinite(r)?1+Math.floor(h*x):os;m>os&&Ae(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${os}`);const p=[];let b=0;for(let R=0;R<os;++R){const _=R/x,E=Math.exp(-_*_/2);p.push(E),R===0?b+=E:R<m&&(b+=2*E)}for(let R=0;R<p.length;R++)p[R]=p[R]/b;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=p,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:w}=this;d.dTheta.value=g,d.mipInt.value=w-n;const M=this._sizeLods[s],S=3*M*(s>w-Gi?s-w+Gi:0),A=4*(this._cubeSize-M);qs(t,S,A,3*M,2*M),c.setRenderTarget(t),c.render(u,Lr)}}function Z_(i){const e=[],t=[],n=[];let s=i;const r=i-Gi+1+Id.length;for(let a=0;a<r;a++){const o=Math.pow(2,s);e.push(o);let c=1/o;a>i-Gi?c=Id[a-i+Gi-1]:a===0&&(c=0),t.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,b=new Float32Array(x*g*f),w=new Float32Array(m*g*f),M=new Float32Array(p*g*f);for(let A=0;A<f;A++){const R=A%3*2/3-1,_=A>2?0:-1,E=[R,_,0,R+2/3,_,0,R+2/3,_+1,0,R,_,0,R+2/3,_+1,0,R,_+1,0];b.set(E,x*g*A),w.set(d,m*g*A);const C=[A,A,A,A,A,A];M.set(C,p*g*A)}const S=new wt;S.setAttribute("position",new dt(b,x)),S.setAttribute("uv",new dt(w,m)),S.setAttribute("faceIndex",new dt(M,p)),n.push(new Qe(S,null)),s>Gi&&s--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Ud(i,e,t){const n=new fn(i,e,t);return n.texture.mapping=qo,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function qs(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function J_(i,e,t){return new Tt({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:K_,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Zo(),fragmentShader:`
4008
4008
 
4009
4009
  precision highp float;
4010
4010
  precision highp int;
@@ -4108,7 +4108,7 @@ void main() {
4108
4108
 
4109
4109
  gl_FragColor = vec4(prefilteredColor, 1.0);
4110
4110
  }
4111
- `,blending:jn,depthTest:!1,depthWrite:!1})}function X2(i,e,t){const n=new Float32Array(ji),s=new L(0,1,0);return new At({name:"SphericalGaussianBlur",defines:{n:ji,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:yo(),fragmentShader:`
4111
+ `,blending:ii,depthTest:!1,depthWrite:!1})}function Q_(i,e,t){const n=new Float32Array(os),s=new P(0,1,0);return new Tt({name:"SphericalGaussianBlur",defines:{n:os,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Zo(),fragmentShader:`
4112
4112
 
4113
4113
  precision mediump float;
4114
4114
  precision mediump int;
@@ -4168,7 +4168,7 @@ void main() {
4168
4168
  }
4169
4169
 
4170
4170
  }
4171
- `,blending:jn,depthTest:!1,depthWrite:!1})}function Pu(){return new At({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:yo(),fragmentShader:`
4171
+ `,blending:ii,depthTest:!1,depthWrite:!1})}function Od(){return new Tt({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Zo(),fragmentShader:`
4172
4172
 
4173
4173
  precision mediump float;
4174
4174
  precision mediump int;
@@ -4187,7 +4187,7 @@ void main() {
4187
4187
  gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
4188
4188
 
4189
4189
  }
4190
- `,blending:jn,depthTest:!1,depthWrite:!1})}function Iu(){return new At({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:yo(),fragmentShader:`
4190
+ `,blending:ii,depthTest:!1,depthWrite:!1})}function Fd(){return new Tt({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Zo(),fragmentShader:`
4191
4191
 
4192
4192
  precision mediump float;
4193
4193
  precision mediump int;
@@ -4203,7 +4203,7 @@ void main() {
4203
4203
  gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
4204
4204
 
4205
4205
  }
4206
- `,blending:jn,depthTest:!1,depthWrite:!1})}function yo(){return`
4206
+ `,blending:ii,depthTest:!1,depthWrite:!1})}function Zo(){return`
4207
4207
 
4208
4208
  precision mediump float;
4209
4209
  precision mediump int;
@@ -4258,7 +4258,7 @@ void main() {
4258
4258
  gl_Position = vec4( position, 1.0 );
4259
4259
 
4260
4260
  }
4261
- `}class F0 extends un{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new D0(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
4261
+ `}class Qf extends fn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new Vf(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
4262
4262
 
4263
4263
  varying vec3 vWorldDirection;
4264
4264
 
@@ -4293,7 +4293,7 @@ void main() {
4293
4293
  gl_FragColor = texture2D( tEquirect, sampleUV );
4294
4294
 
4295
4295
  }
4296
- `},s=new Tn(5,5,5),r=new At({name:"CubemapFromEquirect",uniforms:ir(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:It,blending:jn});r.uniforms.tEquirect.value=t;const a=new je(s,r),o=t.minFilter;return t.minFilter===ns&&(t.minFilter=Et),new Jm(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,s);e.setRenderTarget(r)}}function q2(i){let e=new WeakMap,t=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===Co||f===Po)if(e.has(d)){const g=e.get(d).texture;return o(g,d.mapping)}else{const g=d.image;if(g&&g.height>0){const x=new F0(g.height);return x.fromEquirectangularTexture(i,d),e.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===Co||f===Po,x=f===as||f===nr;if(g||x){let m=t.get(d);const p=m!==void 0?m.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==p)return n===null&&(n=new Du(i)),m=g?n.fromEquirectangular(d,m):n.fromCubemap(d,m),m.texture.pmremVersion=d.pmremVersion,t.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 Du(i)),m=g?n.fromEquirectangular(d):n.fromCubemap(d),m.texture.pmremVersion=d.pmremVersion,t.set(d,m),d.addEventListener("dispose",h),m.texture):null}}}return d}function o(d,f){return f===Co?d.mapping=as:f===Po&&(d.mapping=nr),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=e.get(f);g!==void 0&&(e.delete(f),g.dispose())}function h(d){const f=d.target;f.removeEventListener("dispose",h);const g=t.get(f);g!==void 0&&(t.delete(f),g.dispose())}function u(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:s,dispose:u}}function Y2(i){const e={};function t(n){if(e[n]!==void 0)return e[n];const s=i.getExtension(n);return e[n]=s,s}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const s=t(n);return s===null&&Zs("WebGLRenderer: "+n+" extension not supported."),s}}}function K2(i,e,t,n){const s={},r=new WeakMap;function a(u){const d=u.target;d.index!==null&&e.remove(d.index);for(const g in d.attributes)e.remove(d.attributes[g]);d.removeEventListener("dispose",a),delete s[d.id];const f=r.get(d);f&&(e.remove(f),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(u,d){return s[d.id]===!0||(d.addEventListener("dispose",a),s[d.id]=!0,t.memory.geometries++),d}function c(u){const d=u.attributes;for(const f in d)e.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?T0:b0)(d,1);m.version=x;const p=r.get(u);p&&e.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 Z2(i,e,t){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),t.update(d,n,1)}function l(u,d,f){f!==0&&(i.drawElementsInstanced(n,d,r,u*a,f),t.update(d,n,f))}function h(u,d,f){if(f===0)return;e.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];t.update(x,n,1)}this.setMode=s,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h}function $2(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=o*(r/3);break;case i.LINES:t.lines+=o*(r/2);break;case i.LINE_STRIP:t.lines+=o*(r-1);break;case i.LINE_LOOP:t.lines+=o*r;break;case i.POINTS:t.points+=o*r;break;default:Ze("WebGLInfo: Unknown draw mode:",a);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:n}}function J2(i,e,t){const n=new WeakMap,s=new vt;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>e.maxTextureSize&&(y=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);const b=new Float32Array(M*y*4*u),R=new E0(b,M,y,u);R.type=$n,R.needsUpdate=!0;const _=T*4;for(let C=0;C<u;C++){const D=m[C],I=p[C],W=A[C],X=M*y*4*C;for(let O=0;O<D.count;O++){const q=O*_;f===!0&&(s.fromBufferAttribute(D,O),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,O),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,O),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 Le(M,y)},n.set(o,d),o.addEventListener("dispose",E)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);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,t),c.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:r}}function Q2(i,e,t,n,s){let r=new WeakMap;function a(l){const h=s.render.frame,u=l.geometry,d=e.get(l,u);if(r.get(d)!==h&&(e.update(d),r.set(d,h)),l.isInstancedMesh&&(l.hasEventListener("dispose",c)===!1&&l.addEventListener("dispose",c),r.get(l)!==h&&(t.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&t.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),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:a,dispose:o}}const j2={[o0]:"LINEAR_TONE_MAPPING",[c0]:"REINHARD_TONE_MAPPING",[l0]:"CINEON_TONE_MAPPING",[h0]:"ACES_FILMIC_TONE_MAPPING",[d0]:"AGX_TONE_MAPPING",[f0]:"NEUTRAL_TONE_MAPPING",[u0]:"CUSTOM_TONE_MAPPING"};function ev(i,e,t,n,s,r){const a=new un(e,t,{type:i,depthBuffer:s,stencilBuffer:r,samples:n?4:0,depthTexture:s?new ls(e,t):void 0}),o=new un(e,t,{type:Qt,depthBuffer:!1,stencilBuffer:!1}),c=new Rt;c.setAttribute("position",new Ut([-1,3,0,-1,-1,0,3,-1,0],3)),c.setAttribute("uv",new Ut([0,2,0,0,2,0],2));const l=new Vm({uniforms:{tDiffuse:{value:null}},vertexShader:`
4296
+ `},s=new Cn(5,5,5),r=new Tt({name:"CubemapFromEquirect",uniforms:fr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ut,blending:ii});r.uniforms.tEquirect.value=t;const a=new Qe(s,r),o=t.minFilter;return t.minFilter===hs&&(t.minFilter=At),new $1(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,s);e.setRenderTarget(r)}}function j_(i){let e=new WeakMap,t=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===sc||f===rc)if(e.has(d)){const g=e.get(d).texture;return o(g,d.mapping)}else{const g=d.image;if(g&&g.height>0){const x=new Qf(g.height);return x.fromEquirectangularTexture(i,d),e.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===sc||f===rc,x=f===ps||f===ur;if(g||x){let m=t.get(d);const p=m!==void 0?m.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==p)return n===null&&(n=new Nd(i)),m=g?n.fromEquirectangular(d,m):n.fromCubemap(d,m),m.texture.pmremVersion=d.pmremVersion,t.set(d,m),m.texture;if(m!==void 0)return m.texture;{const b=d.image;return g&&b&&b.height>0||x&&b&&c(b)?(n===null&&(n=new Nd(i)),m=g?n.fromEquirectangular(d):n.fromCubemap(d),m.texture.pmremVersion=d.pmremVersion,t.set(d,m),d.addEventListener("dispose",h),m.texture):null}}}return d}function o(d,f){return f===sc?d.mapping=ps:f===rc&&(d.mapping=ur),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=e.get(f);g!==void 0&&(e.delete(f),g.dispose())}function h(d){const f=d.target;f.removeEventListener("dispose",h);const g=t.get(f);g!==void 0&&(t.delete(f),g.dispose())}function u(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:s,dispose:u}}function ex(i){const e={};function t(n){if(e[n]!==void 0)return e[n];const s=i.getExtension(n);return e[n]=s,s}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const s=t(n);return s===null&&sr("WebGLRenderer: "+n+" extension not supported."),s}}}function tx(i,e,t,n){const s={},r=new WeakMap;function a(u){const d=u.target;d.index!==null&&e.remove(d.index);for(const g in d.attributes)e.remove(d.attributes[g]);d.removeEventListener("dispose",a),delete s[d.id];const f=r.get(d);f&&(e.remove(f),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(u,d){return s[d.id]===!0||(d.addEventListener("dispose",a),s[d.id]=!0,t.memory.geometries++),d}function c(u){const d=u.attributes;for(const f in d)e.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 b=f.array;x=f.version;for(let w=0,M=b.length;w<M;w+=3){const S=b[w+0],A=b[w+1],R=b[w+2];d.push(S,A,A,R,R,S)}}else{const b=g.array;x=g.version;for(let w=0,M=b.length/3-1;w<M;w+=3){const S=w+0,A=w+1,R=w+2;d.push(S,A,A,R,R,S)}}const m=new(g.count>=65535?zf:Ff)(d,1);m.version=x;const p=r.get(u);p&&e.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 nx(i,e,t){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),t.update(d,n,1)}function l(u,d,f){f!==0&&(i.drawElementsInstanced(n,d,r,u*a,f),t.update(d,n,f))}function h(u,d,f){if(f===0)return;e.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];t.update(x,n,1)}this.setMode=s,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h}function ix(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=o*(r/3);break;case i.LINES:t.lines+=o*(r/2);break;case i.LINE_STRIP:t.lines+=o*(r-1);break;case i.LINE_LOOP:t.lines+=o*r;break;case i.POINTS:t.points+=o*r;break;default:ze("WebGLInfo: Unknown draw mode:",a);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:n}}function sx(i,e,t){const n=new WeakMap,s=new lt;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||[],b=o.morphAttributes.color||[];let w=0;f===!0&&(w=1),g===!0&&(w=2),x===!0&&(w=3);let M=o.attributes.position.count*w,S=1;M>e.maxTextureSize&&(S=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);const A=new Float32Array(M*S*4*u),R=new Uf(A,M,S,u);R.type=Dn,R.needsUpdate=!0;const _=w*4;for(let C=0;C<u;C++){const D=m[C],I=p[C],V=b[C],q=M*S*4*C;for(let U=0;U<D.count;U++){const X=U*_;f===!0&&(s.fromBufferAttribute(D,U),A[q+X+0]=s.x,A[q+X+1]=s.y,A[q+X+2]=s.z,A[q+X+3]=0),g===!0&&(s.fromBufferAttribute(I,U),A[q+X+4]=s.x,A[q+X+5]=s.y,A[q+X+6]=s.z,A[q+X+7]=0),x===!0&&(s.fromBufferAttribute(V,U),A[q+X+8]=s.x,A[q+X+9]=s.y,A[q+X+10]=s.z,A[q+X+11]=V.itemSize===4?s.w:1)}}d={count:u,texture:R,size:new Ie(M,S)},n.set(o,d),o.addEventListener("dispose",E)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);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,t),c.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:r}}function rx(i,e,t,n,s){let r=new WeakMap;function a(l){const h=s.render.frame,u=l.geometry,d=e.get(l,u);if(r.get(d)!==h&&(e.update(d),r.set(d,h)),l.isInstancedMesh&&(l.hasEventListener("dispose",c)===!1&&l.addEventListener("dispose",c),r.get(l)!==h&&(t.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&t.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),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:a,dispose:o}}const ax={[Mf]:"LINEAR_TONE_MAPPING",[yf]:"REINHARD_TONE_MAPPING",[Sf]:"CINEON_TONE_MAPPING",[Ef]:"ACES_FILMIC_TONE_MAPPING",[Af]:"AGX_TONE_MAPPING",[wf]:"NEUTRAL_TONE_MAPPING",[bf]:"CUSTOM_TONE_MAPPING"};function ox(i,e,t,n,s,r){const a=new fn(e,t,{type:i,depthBuffer:s,stencilBuffer:r,samples:n?4:0,depthTexture:s?new vs(e,t):void 0}),o=new fn(e,t,{type:jt,depthBuffer:!1,stencilBuffer:!1}),c=new wt;c.setAttribute("position",new Pt([-1,3,0,-1,-1,0,3,-1,0],3)),c.setAttribute("uv",new Pt([0,2,0,0,2,0],2));const l=new w1({uniforms:{tDiffuse:{value:null}},vertexShader:`
4297
4297
  precision highp float;
4298
4298
 
4299
4299
  uniform mat4 modelViewMatrix;
@@ -4339,17 +4339,17 @@ void main() {
4339
4339
  #ifdef SRGB_TRANSFER
4340
4340
  gl_FragColor = sRGBTransferOETF( gl_FragColor );
4341
4341
  #endif
4342
- }`,depthTest:!1,depthWrite:!1}),h=new je(c,l),u=new or(-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===ei&&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=ei,!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 _=p[R];if(_.enabled!==!1&&(_.render(T,b,y,M),_.needsSwap!==!1)){const E=y;y=b,b=E}}if(d!==T.outputColorSpace||f!==T.toneMapping){d=T.outputColorSpace,f=T.toneMapping,l.defines={},$e.getTransfer(d)===it&&(l.defines.SRGB_TRANSFER="");const R=j2[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 z0=new Jt,wl=new ls(1,1),B0=new E0,H0=new _m,k0=new D0,Lu=[],Nu=[],Uu=new Float32Array(16),Ou=new Float32Array(9),Fu=new Float32Array(4);function cr(i,e,t){const n=i[0];if(n<=0||n>0)return i;const s=e*t;let r=Lu[s];if(r===void 0&&(r=new Float32Array(s),Lu[s]=r),e!==0){n.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(r,o)}return r}function Ot(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function Ft(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Eo(i,e){let t=Nu[e];t===void 0&&(t=new Int32Array(e),Nu[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function tv(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function nv(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ot(t,e))return;i.uniform2fv(this.addr,e),Ft(t,e)}}function iv(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Ot(t,e))return;i.uniform3fv(this.addr,e),Ft(t,e)}}function sv(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Ot(t,e))return;i.uniform4fv(this.addr,e),Ft(t,e)}}function rv(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(Ot(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),Ft(t,e)}else{if(Ot(t,n))return;Fu.set(n),i.uniformMatrix2fv(this.addr,!1,Fu),Ft(t,n)}}function av(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(Ot(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),Ft(t,e)}else{if(Ot(t,n))return;Ou.set(n),i.uniformMatrix3fv(this.addr,!1,Ou),Ft(t,n)}}function ov(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(Ot(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),Ft(t,e)}else{if(Ot(t,n))return;Uu.set(n),i.uniformMatrix4fv(this.addr,!1,Uu),Ft(t,n)}}function cv(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function lv(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ot(t,e))return;i.uniform2iv(this.addr,e),Ft(t,e)}}function hv(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Ot(t,e))return;i.uniform3iv(this.addr,e),Ft(t,e)}}function uv(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Ot(t,e))return;i.uniform4iv(this.addr,e),Ft(t,e)}}function dv(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function fv(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ot(t,e))return;i.uniform2uiv(this.addr,e),Ft(t,e)}}function pv(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Ot(t,e))return;i.uniform3uiv(this.addr,e),Ft(t,e)}}function mv(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Ot(t,e))return;i.uniform4uiv(this.addr,e),Ft(t,e)}}function gv(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?(wl.compareFunction=t.isReversedDepthBuffer()?lh:ch,r=wl):r=z0,t.setTexture2D(e||r,s)}function vv(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||H0,s)}function _v(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTextureCube(e||k0,s)}function xv(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||B0,s)}function Mv(i){switch(i){case 5126:return tv;case 35664:return nv;case 35665:return iv;case 35666:return sv;case 35674:return rv;case 35675:return av;case 35676:return ov;case 5124:case 35670:return cv;case 35667:case 35671:return lv;case 35668:case 35672:return hv;case 35669:case 35673:return uv;case 5125:return dv;case 36294:return fv;case 36295:return pv;case 36296:return mv;case 35678:case 36198:case 36298:case 36306:case 35682:return gv;case 35679:case 36299:case 36307:return vv;case 35680:case 36300:case 36308:case 36293:return _v;case 36289:case 36303:case 36311:case 36292:return xv}}function Sv(i,e){i.uniform1fv(this.addr,e)}function yv(i,e){const t=cr(e,this.size,2);i.uniform2fv(this.addr,t)}function Ev(i,e){const t=cr(e,this.size,3);i.uniform3fv(this.addr,t)}function Av(i,e){const t=cr(e,this.size,4);i.uniform4fv(this.addr,t)}function bv(i,e){const t=cr(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function Tv(i,e){const t=cr(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function wv(i,e){const t=cr(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function Rv(i,e){i.uniform1iv(this.addr,e)}function Dv(i,e){i.uniform2iv(this.addr,e)}function Cv(i,e){i.uniform3iv(this.addr,e)}function Pv(i,e){i.uniform4iv(this.addr,e)}function Iv(i,e){i.uniform1uiv(this.addr,e)}function Lv(i,e){i.uniform2uiv(this.addr,e)}function Nv(i,e){i.uniform3uiv(this.addr,e)}function Uv(i,e){i.uniform4uiv(this.addr,e)}function Ov(i,e,t){const n=this.cache,s=e.length,r=Eo(t,s);Ot(n,r)||(i.uniform1iv(this.addr,r),Ft(n,r));let a;this.type===i.SAMPLER_2D_SHADOW?a=wl:a=z0;for(let o=0;o!==s;++o)t.setTexture2D(e[o]||a,r[o])}function Fv(i,e,t){const n=this.cache,s=e.length,r=Eo(t,s);Ot(n,r)||(i.uniform1iv(this.addr,r),Ft(n,r));for(let a=0;a!==s;++a)t.setTexture3D(e[a]||H0,r[a])}function zv(i,e,t){const n=this.cache,s=e.length,r=Eo(t,s);Ot(n,r)||(i.uniform1iv(this.addr,r),Ft(n,r));for(let a=0;a!==s;++a)t.setTextureCube(e[a]||k0,r[a])}function Bv(i,e,t){const n=this.cache,s=e.length,r=Eo(t,s);Ot(n,r)||(i.uniform1iv(this.addr,r),Ft(n,r));for(let a=0;a!==s;++a)t.setTexture2DArray(e[a]||B0,r[a])}function Hv(i){switch(i){case 5126:return Sv;case 35664:return yv;case 35665:return Ev;case 35666:return Av;case 35674:return bv;case 35675:return Tv;case 35676:return wv;case 5124:case 35670:return Rv;case 35667:case 35671:return Dv;case 35668:case 35672:return Cv;case 35669:case 35673:return Pv;case 5125:return Iv;case 36294:return Lv;case 36295:return Nv;case 36296:return Uv;case 35678:case 36198:case 36298:case 36306:case 35682:return Ov;case 35679:case 36299:case 36307:return Fv;case 35680:case 36300:case 36308:case 36293:return zv;case 36289:case 36303:case 36311:case 36292:return Bv}}class kv{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Mv(t.type)}}class Gv{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Hv(t.type)}}class Vv{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const s=this.seq;for(let r=0,a=s.length;r!==a;++r){const o=s[r];o.setValue(e,t[o.id],n)}}}const hc=/(\w+)(\])?(\[|\.)?/g;function zu(i,e){i.seq.push(e),i.map[e.id]=e}function Wv(i,e,t){const n=i.name,s=n.length;for(hc.lastIndex=0;;){const r=hc.exec(n),a=hc.lastIndex;let o=r[1];const c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===s){zu(t,l===void 0?new kv(o,i,e):new Gv(o,i,e));break}else{let u=t.map[o];u===void 0&&(u=new Vv(o),zu(t,u)),t=u}}}class Za{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){const o=e.getActiveUniform(t,a),c=e.getUniformLocation(t,o.name);Wv(o,c,this)}const s=[],r=[];for(const a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?s.push(a):r.push(a);s.length>0&&(this.seq=s.concat(r))}setValue(e,t,n,s){const r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){const s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,s)}}static seqWithValue(e,t){const n=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&n.push(a)}return n}}function Bu(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const Xv=37297;let qv=0;function Yv(i,e){const t=i.split(`
4342
+ }`,depthTest:!1,depthWrite:!1}),h=new Qe(c,l),u=new xr(-1,1,1,-1,0,1);let d=null,f=null,g=!1,x,m=null,p=[],b=!1;this.setSize=function(w,M){a.setSize(w,M),o.setSize(w,M);for(let S=0;S<p.length;S++){const A=p[S];A.setSize&&A.setSize(w,M)}},this.setEffects=function(w){p=w,b=p.length>0&&p[0].isRenderPass===!0;const M=a.width,S=a.height;for(let A=0;A<p.length;A++){const R=p[A];R.setSize&&R.setSize(M,S)}},this.begin=function(w,M){if(g||w.toneMapping===si&&p.length===0)return!1;if(m=M,M!==null){const S=M.width,A=M.height;(a.width!==S||a.height!==A)&&this.setSize(S,A)}return b===!1&&w.setRenderTarget(a),x=w.toneMapping,w.toneMapping=si,!0},this.hasRenderPass=function(){return b},this.end=function(w,M){w.toneMapping=x,g=!0;let S=a,A=o;for(let R=0;R<p.length;R++){const _=p[R];if(_.enabled!==!1&&(_.render(w,A,S,M),_.needsSwap!==!1)){const E=S;S=A,A=E}}if(d!==w.outputColorSpace||f!==w.toneMapping){d=w.outputColorSpace,f=w.toneMapping,l.defines={},Je.getTransfer(d)===st&&(l.defines.SRGB_TRANSFER="");const R=ax[f];R&&(l.defines[R]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=S.texture,w.setRenderTarget(m),w.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 jf=new Xt,oh=new vs(1,1),ep=new Uf,tp=new Zg,np=new Vf,zd=[],Bd=[],kd=new Float32Array(16),Hd=new Float32Array(9),Gd=new Float32Array(4);function Mr(i,e,t){const n=i[0];if(n<=0||n>0)return i;const s=e*t;let r=zd[s];if(r===void 0&&(r=new Float32Array(s),zd[s]=r),e!==0){n.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(r,o)}return r}function Ft(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function zt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Jo(i,e){let t=Bd[e];t===void 0&&(t=new Int32Array(e),Bd[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function cx(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function lx(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ft(t,e))return;i.uniform2fv(this.addr,e),zt(t,e)}}function hx(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Ft(t,e))return;i.uniform3fv(this.addr,e),zt(t,e)}}function ux(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Ft(t,e))return;i.uniform4fv(this.addr,e),zt(t,e)}}function dx(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(Ft(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),zt(t,e)}else{if(Ft(t,n))return;Gd.set(n),i.uniformMatrix2fv(this.addr,!1,Gd),zt(t,n)}}function fx(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(Ft(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),zt(t,e)}else{if(Ft(t,n))return;Hd.set(n),i.uniformMatrix3fv(this.addr,!1,Hd),zt(t,n)}}function px(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(Ft(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),zt(t,e)}else{if(Ft(t,n))return;kd.set(n),i.uniformMatrix4fv(this.addr,!1,kd),zt(t,n)}}function mx(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function gx(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ft(t,e))return;i.uniform2iv(this.addr,e),zt(t,e)}}function vx(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Ft(t,e))return;i.uniform3iv(this.addr,e),zt(t,e)}}function _x(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Ft(t,e))return;i.uniform4iv(this.addr,e),zt(t,e)}}function xx(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function Mx(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ft(t,e))return;i.uniform2uiv(this.addr,e),zt(t,e)}}function yx(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Ft(t,e))return;i.uniform3uiv(this.addr,e),zt(t,e)}}function Sx(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Ft(t,e))return;i.uniform4uiv(this.addr,e),zt(t,e)}}function Ex(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?(oh.compareFunction=t.isReversedDepthBuffer()?Xh:Wh,r=oh):r=jf,t.setTexture2D(e||r,s)}function bx(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||tp,s)}function Ax(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTextureCube(e||np,s)}function wx(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||ep,s)}function Tx(i){switch(i){case 5126:return cx;case 35664:return lx;case 35665:return hx;case 35666:return ux;case 35674:return dx;case 35675:return fx;case 35676:return px;case 5124:case 35670:return mx;case 35667:case 35671:return gx;case 35668:case 35672:return vx;case 35669:case 35673:return _x;case 5125:return xx;case 36294:return Mx;case 36295:return yx;case 36296:return Sx;case 35678:case 36198:case 36298:case 36306:case 35682:return Ex;case 35679:case 36299:case 36307:return bx;case 35680:case 36300:case 36308:case 36293:return Ax;case 36289:case 36303:case 36311:case 36292:return wx}}function Rx(i,e){i.uniform1fv(this.addr,e)}function Dx(i,e){const t=Mr(e,this.size,2);i.uniform2fv(this.addr,t)}function Cx(i,e){const t=Mr(e,this.size,3);i.uniform3fv(this.addr,t)}function Px(i,e){const t=Mr(e,this.size,4);i.uniform4fv(this.addr,t)}function Ix(i,e){const t=Mr(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function Lx(i,e){const t=Mr(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function Nx(i,e){const t=Mr(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function Ux(i,e){i.uniform1iv(this.addr,e)}function Ox(i,e){i.uniform2iv(this.addr,e)}function Fx(i,e){i.uniform3iv(this.addr,e)}function zx(i,e){i.uniform4iv(this.addr,e)}function Bx(i,e){i.uniform1uiv(this.addr,e)}function kx(i,e){i.uniform2uiv(this.addr,e)}function Hx(i,e){i.uniform3uiv(this.addr,e)}function Gx(i,e){i.uniform4uiv(this.addr,e)}function Vx(i,e,t){const n=this.cache,s=e.length,r=Jo(t,s);Ft(n,r)||(i.uniform1iv(this.addr,r),zt(n,r));let a;this.type===i.SAMPLER_2D_SHADOW?a=oh:a=jf;for(let o=0;o!==s;++o)t.setTexture2D(e[o]||a,r[o])}function Wx(i,e,t){const n=this.cache,s=e.length,r=Jo(t,s);Ft(n,r)||(i.uniform1iv(this.addr,r),zt(n,r));for(let a=0;a!==s;++a)t.setTexture3D(e[a]||tp,r[a])}function Xx(i,e,t){const n=this.cache,s=e.length,r=Jo(t,s);Ft(n,r)||(i.uniform1iv(this.addr,r),zt(n,r));for(let a=0;a!==s;++a)t.setTextureCube(e[a]||np,r[a])}function qx(i,e,t){const n=this.cache,s=e.length,r=Jo(t,s);Ft(n,r)||(i.uniform1iv(this.addr,r),zt(n,r));for(let a=0;a!==s;++a)t.setTexture2DArray(e[a]||ep,r[a])}function Yx(i){switch(i){case 5126:return Rx;case 35664:return Dx;case 35665:return Cx;case 35666:return Px;case 35674:return Ix;case 35675:return Lx;case 35676:return Nx;case 5124:case 35670:return Ux;case 35667:case 35671:return Ox;case 35668:case 35672:return Fx;case 35669:case 35673:return zx;case 5125:return Bx;case 36294:return kx;case 36295:return Hx;case 36296:return Gx;case 35678:case 36198:case 36298:case 36306:case 35682:return Vx;case 35679:case 36299:case 36307:return Wx;case 35680:case 36300:case 36308:case 36293:return Xx;case 36289:case 36303:case 36311:case 36292:return qx}}class Kx{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Tx(t.type)}}class $x{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Yx(t.type)}}class Zx{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const s=this.seq;for(let r=0,a=s.length;r!==a;++r){const o=s[r];o.setValue(e,t[o.id],n)}}}const Hc=/(\w+)(\])?(\[|\.)?/g;function Vd(i,e){i.seq.push(e),i.map[e.id]=e}function Jx(i,e,t){const n=i.name,s=n.length;for(Hc.lastIndex=0;;){const r=Hc.exec(n),a=Hc.lastIndex;let o=r[1];const c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===s){Vd(t,l===void 0?new Kx(o,i,e):new $x(o,i,e));break}else{let u=t.map[o];u===void 0&&(u=new Zx(o),Vd(t,u)),t=u}}}class So{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){const o=e.getActiveUniform(t,a),c=e.getUniformLocation(t,o.name);Jx(o,c,this)}const s=[],r=[];for(const a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?s.push(a):r.push(a);s.length>0&&(this.seq=s.concat(r))}setValue(e,t,n,s){const r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){const s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,s)}}static seqWithValue(e,t){const n=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&n.push(a)}return n}}function Wd(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const Qx=37297;let jx=0;function eM(i,e){const t=i.split(`
4343
4343
  `),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a<r;a++){const o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
4344
- `)}const Hu=new ze;function Kv(i){$e._getMatrix(Hu,$e.workingColorSpace,i);const e=`mat3( ${Hu.elements.map(t=>t.toFixed(4))} )`;switch($e.getTransfer(i)){case no:return[e,"LinearTransferOETF"];case it:return[e,"sRGBTransferOETF"];default:return Fe("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function ku(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),r=(i.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
4344
+ `)}const Xd=new Be;function tM(i){Je._getMatrix(Xd,Je.workingColorSpace,i);const e=`mat3( ${Xd.elements.map(t=>t.toFixed(4))} )`;switch(Je.getTransfer(i)){case Po:return[e,"LinearTransferOETF"];case st:return[e,"sRGBTransferOETF"];default:return Ae("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function qd(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),r=(i.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
4345
4345
 
4346
4346
  `+r+`
4347
4347
 
4348
- `+Yv(i.getShaderSource(e),o)}else return r}function Zv(i,e){const t=Kv(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
4349
- `)}const $v={[o0]:"Linear",[c0]:"Reinhard",[l0]:"Cineon",[h0]:"ACESFilmic",[d0]:"AgX",[f0]:"Neutral",[u0]:"Custom"};function Jv(i,e){const t=$v[e];return t===void 0?(Fe("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Ta=new L;function Qv(){$e.getLuminanceCoefficients(Ta);const i=Ta.x.toFixed(4),e=Ta.y.toFixed(4),t=Ta.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
4350
- `)}function jv(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(br).join(`
4351
- `)}function e_(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
4352
- `)}function t_(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){const r=i.getActiveAttrib(e,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),t[a]={type:r.type,location:i.getAttribLocation(e,a),locationSize:o}}return t}function br(i){return i!==""}function Gu(i,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Vu(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const n_=/^[ \t]*#include +<([\w\d./]+)>/gm;function Rl(i){return i.replace(n_,s_)}const i_=new Map;function s_(i,e){let t=Ve[e];if(t===void 0){const n=i_.get(e);if(n!==void 0)t=Ve[n],Fe('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Rl(t)}const r_=/#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 Wu(i){return i.replace(r_,a_)}function a_(i,e,t,n){let s="";for(let r=parseInt(e);r<parseInt(t);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function Xu(i){let e=`precision ${i.precision} float;
4348
+ `+eM(i.getShaderSource(e),o)}else return r}function nM(i,e){const t=tM(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
4349
+ `)}const iM={[Mf]:"Linear",[yf]:"Reinhard",[Sf]:"Cineon",[Ef]:"ACESFilmic",[Af]:"AgX",[wf]:"Neutral",[bf]:"Custom"};function sM(i,e){const t=iM[e];return t===void 0?(Ae("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Qa=new P;function rM(){Je.getLuminanceCoefficients(Qa);const i=Qa.x.toFixed(4),e=Qa.y.toFixed(4),t=Qa.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
4350
+ `)}function aM(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Hr).join(`
4351
+ `)}function oM(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
4352
+ `)}function cM(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){const r=i.getActiveAttrib(e,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),t[a]={type:r.type,location:i.getAttribLocation(e,a),locationSize:o}}return t}function Hr(i){return i!==""}function Yd(i,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Kd(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const lM=/^[ \t]*#include +<([\w\d./]+)>/gm;function ch(i){return i.replace(lM,uM)}const hM=new Map;function uM(i,e){let t=We[e];if(t===void 0){const n=hM.get(e);if(n!==void 0)t=We[n],Ae('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return ch(t)}const dM=/#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 $d(i){return i.replace(dM,fM)}function fM(i,e,t,n){let s="";for(let r=parseInt(e);r<parseInt(t);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function Zd(i){let e=`precision ${i.precision} float;
4353
4353
  precision ${i.precision} int;
4354
4354
  precision ${i.precision} sampler2D;
4355
4355
  precision ${i.precision} samplerCube;
@@ -4369,30 +4369,30 @@ void main() {
4369
4369
  `;return i.precision==="highp"?e+=`
4370
4370
  #define HIGH_PRECISION`:i.precision==="mediump"?e+=`
4371
4371
  #define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
4372
- #define LOW_PRECISION`),e}const o_={[Cr]:"SHADOWMAP_TYPE_PCF",[Er]:"SHADOWMAP_TYPE_VSM"};function c_(i){return o_[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const l_={[as]:"ENVMAP_TYPE_CUBE",[nr]:"ENVMAP_TYPE_CUBE",[vo]:"ENVMAP_TYPE_CUBE_UV"};function h_(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":l_[i.envMapMode]||"ENVMAP_TYPE_CUBE"}const u_={[nr]:"ENVMAP_MODE_REFRACTION"};function d_(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":u_[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}const f_={[th]:"ENVMAP_BLENDING_MULTIPLY",[Jp]:"ENVMAP_BLENDING_MIX",[Qp]:"ENVMAP_BLENDING_ADD"};function p_(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":f_[i.combine]||"ENVMAP_BLENDING_NONE"}function m_(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function g_(i,e,t,n){const s=i.getContext(),r=t.defines;let a=t.vertexShader,o=t.fragmentShader;const c=c_(t),l=h_(t),h=d_(t),u=p_(t),d=m_(t),f=jv(t),g=e_(r),x=s.createProgram();let m,p,A=t.glslVersion?"#version "+t.glslVersion+`
4373
- `:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(br).join(`
4372
+ #define LOW_PRECISION`),e}const pM={[qr]:"SHADOWMAP_TYPE_PCF",[Br]:"SHADOWMAP_TYPE_VSM"};function mM(i){return pM[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const gM={[ps]:"ENVMAP_TYPE_CUBE",[ur]:"ENVMAP_TYPE_CUBE",[qo]:"ENVMAP_TYPE_CUBE_UV"};function vM(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":gM[i.envMapMode]||"ENVMAP_TYPE_CUBE"}const _M={[ur]:"ENVMAP_MODE_REFRACTION"};function xM(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":_M[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}const MM={[Oh]:"ENVMAP_BLENDING_MULTIPLY",[ug]:"ENVMAP_BLENDING_MIX",[dg]:"ENVMAP_BLENDING_ADD"};function yM(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":MM[i.combine]||"ENVMAP_BLENDING_NONE"}function SM(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function EM(i,e,t,n){const s=i.getContext(),r=t.defines;let a=t.vertexShader,o=t.fragmentShader;const c=mM(t),l=vM(t),h=xM(t),u=yM(t),d=SM(t),f=aM(t),g=oM(r),x=s.createProgram();let m,p,b=t.glslVersion?"#version "+t.glslVersion+`
4373
+ `:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Hr).join(`
4374
4374
  `),m.length>0&&(m+=`
4375
- `),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(br).join(`
4375
+ `),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Hr).join(`
4376
4376
  `),p.length>0&&(p+=`
4377
- `)):(m=[Xu(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
4378
- `].filter(br).join(`
4379
- `),p=[Xu(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==ei?"#define TONE_MAPPING":"",t.toneMapping!==ei?Ve.tonemapping_pars_fragment:"",t.toneMapping!==ei?Jv("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ve.colorspace_pars_fragment,Zv("linearToOutputTexel",t.outputColorSpace),Qv(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
4380
- `].filter(br).join(`
4381
- `)),a=Rl(a),a=Gu(a,t),a=Vu(a,t),o=Rl(o),o=Gu(o,t),o=Vu(o,t),a=Wu(a),o=Wu(o),t.isRawShaderMaterial!==!0&&(A=`#version 300 es
4377
+ `)):(m=[Zd(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
4378
+ `].filter(Hr).join(`
4379
+ `),p=[Zd(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==si?"#define TONE_MAPPING":"",t.toneMapping!==si?We.tonemapping_pars_fragment:"",t.toneMapping!==si?sM("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",We.colorspace_pars_fragment,nM("linearToOutputTexel",t.outputColorSpace),rM(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
4380
+ `].filter(Hr).join(`
4381
+ `)),a=ch(a),a=Yd(a,t),a=Kd(a,t),o=ch(o),o=Yd(o,t),o=Kd(o,t),a=$d(a),o=$d(o),t.isRawShaderMaterial!==!0&&(b=`#version 300 es
4382
4382
  `,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
4383
4383
  `)+`
4384
- `+m,p=["#define varying in",t.glslVersion===jh?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===jh?"":"#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(`
4384
+ `+m,p=["#define varying in",t.glslVersion===Vu?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Vu?"":"#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(`
4385
4385
  `)+`
4386
- `+p);const T=A+m+a,M=A+p+o,y=Bu(s,s.VERTEX_SHADER,T),b=Bu(s,s.FRAGMENT_SHADER,M);s.attachShader(x,y),s.attachShader(x,b),t.index0AttributeName!==void 0?s.bindAttribLocation(x,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(x,0,"position"),s.linkProgram(x);function R(D){if(i.debug.checkShaderErrors){const I=s.getProgramInfoLog(x)||"",W=s.getShaderInfoLog(y)||"",X=s.getShaderInfoLog(b)||"",O=I.trim(),q=W.trim(),G=X.trim();let $=!0,te=!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=ku(s,y,"vertex"),ie=ku(s,b,"fragment");Ze("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(x,s.VALIDATE_STATUS)+`
4386
+ `+p);const w=b+m+a,M=b+p+o,S=Wd(s,s.VERTEX_SHADER,w),A=Wd(s,s.FRAGMENT_SHADER,M);s.attachShader(x,S),s.attachShader(x,A),t.index0AttributeName!==void 0?s.bindAttribLocation(x,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(x,0,"position"),s.linkProgram(x);function R(D){if(i.debug.checkShaderErrors){const I=s.getProgramInfoLog(x)||"",V=s.getShaderInfoLog(S)||"",q=s.getShaderInfoLog(A)||"",U=I.trim(),X=V.trim(),G=q.trim();let Z=!0,te=!0;if(s.getProgramParameter(x,s.LINK_STATUS)===!1)if(Z=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,x,S,A);else{const j=qd(s,S,"vertex"),ie=qd(s,A,"fragment");ze("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(x,s.VALIDATE_STATUS)+`
4387
4387
 
4388
4388
  Material Name: `+D.name+`
4389
4389
  Material Type: `+D.type+`
4390
4390
 
4391
- Program Info Log: `+O+`
4391
+ Program Info Log: `+U+`
4392
4392
  `+j+`
4393
- `+ie)}else O!==""?Fe("WebGLProgram: Program Info Log:",O):(q===""||G==="")&&(te=!1);te&&(D.diagnostics={runnable:$,programLog:O,vertexShader:{log:q,prefix:m},fragmentShader:{log:G,prefix:p}})}s.deleteShader(y),s.deleteShader(b),_=new Za(s,x),E=t_(s,x)}let _;this.getUniforms=function(){return _===void 0&&R(this),_};let E;this.getAttributes=function(){return E===void 0&&R(this),E};let C=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return C===!1&&(C=s.getProgramParameter(x,Xv)),C},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(x),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=qv++,this.cacheKey=e,this.usedTimes=1,this.program=x,this.vertexShader=y,this.fragmentShader=b,this}let v_=0;class __{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){const s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new x_(e),t.set(e,n)),n}}class x_{constructor(e){this.id=v_++,this.code=e,this.usedTimes=0}}function M_(i){return i===os||i===ja||i===eo}function S_(i,e,t,n,s,r){const a=new uh,o=new __,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(_){return c.add(_),_===0?"uv":`uv${_}`}function x(_,E,C,D,I,W){const X=D.fog,O=I.geometry,q=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?D.environment:null,G=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,$=e.get(_.envMap||q,G),te=$&&$.mapping===vo?$.image.height:null,j=f[_.type];_.precision!==null&&(d=n.getMaxPrecision(_.precision),d!==_.precision&&Fe("WebGLProgram.getParameters:",_.precision,"not supported, using",d,"instead."));const ie=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,ue=ie!==void 0?ie.length:0;let He=0;O.morphAttributes.position!==void 0&&(He=1),O.morphAttributes.normal!==void 0&&(He=2),O.morphAttributes.color!==void 0&&(He=3);let Ke,Be,Y,re;if(j){const Se=Wn[j];Ke=Se.vertexShader,Be=Se.fragmentShader}else{Ke=_.vertexShader,Be=_.fragmentShader;const Se=o.getVertexShaderStage(_),Mt=o.getFragmentShaderStage(_);o.update(_,Se,Mt),Y=Se.id,re=Mt.id}const ne=i.getRenderTarget(),z=i.state.buffers.depth.getReversed(),Ae=I.isInstancedMesh===!0,Ce=I.isBatchedMesh===!0,Te=!!_.map,_e=!!_.matcap,Ie=!!$,Ne=!!_.aoMap,Ue=!!_.lightMap,et=!!_.bumpMap&&_.wireframe===!1,tt=!!_.normalMap,_t=!!_.displacementMap,pt=!!_.emissiveMap,xt=!!_.metalnessMap,Dt=!!_.roughnessMap,N=_.anisotropy>0,an=_.clearcoat>0,nt=_.dispersion>0,w=_.iridescence>0,v=_.sheen>0,F=_.transmission>0,k=N&&!!_.anisotropyMap,K=an&&!!_.clearcoatMap,se=an&&!!_.clearcoatNormalMap,oe=an&&!!_.clearcoatRoughnessMap,Z=w&&!!_.iridescenceMap,Q=w&&!!_.iridescenceThicknessMap,ce=v&&!!_.sheenColorMap,we=v&&!!_.sheenRoughnessMap,de=!!_.specularMap,le=!!_.specularColorMap,Pe=!!_.specularIntensityMap,Oe=F&&!!_.transmissionMap,ke=F&&!!_.thicknessMap,P=!!_.gradientMap,ae=!!_.alphaMap,J=_.alphaTest>0,he=!!_.alphaHash,ge=!!_.extensions;let ee=ei;_.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(ee=i.toneMapping);const be={shaderID:j,shaderType:_.type,shaderName:_.name,vertexShader:Ke,fragmentShader:Be,defines:_.defines,customVertexShaderID:Y,customFragmentShaderID:re,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:d,batching:Ce,batchingColor:Ce&&I._colorsTexture!==null,instancing:Ae,instancingColor:Ae&&I.instanceColor!==null,instancingMorph:Ae&&I.morphTexture!==null,outputColorSpace:ne===null?i.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:$e.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:Te,matcap:_e,envMap:Ie,envMapMode:Ie&&$.mapping,envMapCubeUVHeight:te,aoMap:Ne,lightMap:Ue,bumpMap:et,normalMap:tt,displacementMap:_t,emissiveMap:pt,normalMapObjectSpace:tt&&_.normalMapType===tm,normalMapTangentSpace:tt&&_.normalMapType===yl,packedNormalMap:tt&&_.normalMapType===yl&&M_(_.normalMap.format),metalnessMap:xt,roughnessMap:Dt,anisotropy:N,anisotropyMap:k,clearcoat:an,clearcoatMap:K,clearcoatNormalMap:se,clearcoatRoughnessMap:oe,dispersion:nt,iridescence:w,iridescenceMap:Z,iridescenceThicknessMap:Q,sheen:v,sheenColorMap:ce,sheenRoughnessMap:we,specularMap:de,specularColorMap:le,specularIntensityMap:Pe,transmission:F,transmissionMap:Oe,thicknessMap:ke,gradientMap:P,opaque:_.transparent===!1&&_.blending===Ks&&_.alphaToCoverage===!1,alphaMap:ae,alphaTest:J,alphaHash:he,combine:_.combine,mapUv:Te&&g(_.map.channel),aoMapUv:Ne&&g(_.aoMap.channel),lightMapUv:Ue&&g(_.lightMap.channel),bumpMapUv:et&&g(_.bumpMap.channel),normalMapUv:tt&&g(_.normalMap.channel),displacementMapUv:_t&&g(_.displacementMap.channel),emissiveMapUv:pt&&g(_.emissiveMap.channel),metalnessMapUv:xt&&g(_.metalnessMap.channel),roughnessMapUv:Dt&&g(_.roughnessMap.channel),anisotropyMapUv:k&&g(_.anisotropyMap.channel),clearcoatMapUv:K&&g(_.clearcoatMap.channel),clearcoatNormalMapUv:se&&g(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:oe&&g(_.clearcoatRoughnessMap.channel),iridescenceMapUv:Z&&g(_.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&g(_.iridescenceThicknessMap.channel),sheenColorMapUv:ce&&g(_.sheenColorMap.channel),sheenRoughnessMapUv:we&&g(_.sheenRoughnessMap.channel),specularMapUv:de&&g(_.specularMap.channel),specularColorMapUv:le&&g(_.specularColorMap.channel),specularIntensityMapUv:Pe&&g(_.specularIntensityMap.channel),transmissionMapUv:Oe&&g(_.transmissionMap.channel),thicknessMapUv:ke&&g(_.thicknessMap.channel),alphaMapUv:ae&&g(_.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&(tt||N),vertexNormals:!!O.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!O.attributes.uv&&(Te||ae),fog:!!X,useFog:_.fog===!0,fogExp2:!!X&&X.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||O.attributes.normal===void 0&&tt===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:z,skinning:I.isSkinnedMesh===!0,hasPositionAttribute:O.attributes.position!==void 0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:ue,morphTextureStride:He,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:_.dithering,shadowMapEnabled:i.shadowMap.enabled&&C.length>0,shadowMapType:i.shadowMap.type,toneMapping:ee,decodeVideoTexture:Te&&_.map.isVideoTexture===!0&&$e.getTransfer(_.map.colorSpace)===it,decodeVideoTextureEmissive:pt&&_.emissiveMap.isVideoTexture===!0&&$e.getTransfer(_.emissiveMap.colorSpace)===it,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===Ln,flipSided:_.side===It,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:ge&&_.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ge&&_.extensions.multiDraw===!0||Ce)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return be.vertexUv1s=c.has(1),be.vertexUv2s=c.has(2),be.vertexUv3s=c.has(3),c.clear(),be}function m(_){const E=[];if(_.shaderID?E.push(_.shaderID):(E.push(_.customVertexShaderID),E.push(_.customFragmentShaderID)),_.defines!==void 0)for(const C in _.defines)E.push(C),E.push(_.defines[C]);return _.isRawShaderMaterial===!1&&(p(E,_),A(E,_),E.push(i.outputColorSpace)),E.push(_.customProgramCacheKey),E.join()}function p(_,E){_.push(E.precision),_.push(E.outputColorSpace),_.push(E.envMapMode),_.push(E.envMapCubeUVHeight),_.push(E.mapUv),_.push(E.alphaMapUv),_.push(E.lightMapUv),_.push(E.aoMapUv),_.push(E.bumpMapUv),_.push(E.normalMapUv),_.push(E.displacementMapUv),_.push(E.emissiveMapUv),_.push(E.metalnessMapUv),_.push(E.roughnessMapUv),_.push(E.anisotropyMapUv),_.push(E.clearcoatMapUv),_.push(E.clearcoatNormalMapUv),_.push(E.clearcoatRoughnessMapUv),_.push(E.iridescenceMapUv),_.push(E.iridescenceThicknessMapUv),_.push(E.sheenColorMapUv),_.push(E.sheenRoughnessMapUv),_.push(E.specularMapUv),_.push(E.specularColorMapUv),_.push(E.specularIntensityMapUv),_.push(E.transmissionMapUv),_.push(E.thicknessMapUv),_.push(E.combine),_.push(E.fogExp2),_.push(E.sizeAttenuation),_.push(E.morphTargetsCount),_.push(E.morphAttributeCount),_.push(E.numDirLights),_.push(E.numPointLights),_.push(E.numSpotLights),_.push(E.numSpotLightMaps),_.push(E.numHemiLights),_.push(E.numRectAreaLights),_.push(E.numDirLightShadows),_.push(E.numPointLightShadows),_.push(E.numSpotLightShadows),_.push(E.numSpotLightShadowsWithMaps),_.push(E.numLightProbes),_.push(E.shadowMapType),_.push(E.toneMapping),_.push(E.numClippingPlanes),_.push(E.numClipIntersection),_.push(E.depthPacking)}function A(_,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),_.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),_.push(a.mask)}function T(_){const E=f[_.type];let C;if(E){const D=Wn[E];C=Hm.clone(D.uniforms)}else C=_.uniforms;return C}function M(_,E){let C=h.get(E);return C!==void 0?++C.usedTimes:(C=new g_(i,E,_,s),l.push(C),h.set(E,C)),C}function y(_){if(--_.usedTimes===0){const E=l.indexOf(_);l[E]=l[l.length-1],l.pop(),h.delete(_.cacheKey),_.destroy()}}function b(_){o.remove(_)}function R(){o.dispose()}return{getParameters:x,getProgramCacheKey:m,getUniforms:T,acquireProgram:M,releaseProgram:y,releaseShaderCache:b,programs:l,dispose:R}}function y_(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,c){i.get(a)[o]=c}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function E_(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function qu(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Yu(){const i=[];let e=0;const t=[],n=[],s=[];function r(){e=0,t.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[e];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[e]=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),e++,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):t.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):t.unshift(A)}function h(d,f,g){t.length>1&&t.sort(d||E_),n.length>1&&n.sort(f||qu),s.length>1&&s.sort(f||qu),g&&(t.reverse(),n.reverse(),s.reverse())}function u(){for(let d=e,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:t,transmissive:n,transparent:s,init:r,push:c,unshift:l,finish:u,sort:h}}function A_(){let i=new WeakMap;function e(n,s){const r=i.get(n);let a;return r===void 0?(a=new Yu,i.set(n,[a])):s>=r.length?(a=new Yu,r.push(a)):a=r[s],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function b_(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new L,color:new Me};break;case"SpotLight":t={position:new L,direction:new L,color:new Me,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new L,color:new Me,distance:0,decay:0};break;case"HemisphereLight":t={direction:new L,skyColor:new Me,groundColor:new Me};break;case"RectAreaLight":t={color:new Me,position:new L,halfWidth:new L,halfHeight:new L};break}return i[e.id]=t,t}}}function T_(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Le};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Le};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Le,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let w_=0;function R_(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function D_(i){const e=new b_,t=T_(),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 L);const s=new L,r=new dt,a=new dt;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(R_);for(let E=0,C=l.length;E<C;E++){const D=l[E],I=D.color,W=D.intensity,X=D.distance;let O=null;if(D.shadow&&D.shadow.map&&(D.shadow.map.texture.format===os?O=D.shadow.map.texture:O=D.shadow.map.depthTexture||D.shadow.map.texture),D.isAmbientLight)h+=I.r*W,u+=I.g*W,d+=I.b*W;else if(D.isLightProbe){for(let q=0;q<9;q++)n.probe[q].addScaledVector(D.sh.coefficients[q],W);R++}else if(D.isDirectionalLight){const q=e.get(D);if(q.color.copy(D.color).multiplyScalar(D.intensity),D.castShadow){const G=D.shadow,$=t.get(D);$.shadowIntensity=G.intensity,$.shadowBias=G.bias,$.shadowNormalBias=G.normalBias,$.shadowRadius=G.radius,$.shadowMapSize=G.mapSize,n.directionalShadow[f]=$,n.directionalShadowMap[f]=O,n.directionalShadowMatrix[f]=D.shadow.matrix,A++}n.directional[f]=q,f++}else if(D.isSpotLight){const q=e.get(D);q.position.setFromMatrixPosition(D.matrixWorld),q.color.copy(I).multiplyScalar(W),q.distance=X,q.coneCos=Math.cos(D.angle),q.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),q.decay=D.decay,n.spot[x]=q;const G=D.shadow;if(D.map&&(n.spotLightMap[y]=D.map,y++,G.updateMatrices(D),D.castShadow&&b++),n.spotLightMatrix[x]=G.matrix,D.castShadow){const $=t.get(D);$.shadowIntensity=G.intensity,$.shadowBias=G.bias,$.shadowNormalBias=G.normalBias,$.shadowRadius=G.radius,$.shadowMapSize=G.mapSize,n.spotShadow[x]=$,n.spotShadowMap[x]=O,M++}x++}else if(D.isRectAreaLight){const q=e.get(D);q.color.copy(I).multiplyScalar(W),q.halfWidth.set(D.width*.5,0,0),q.halfHeight.set(0,D.height*.5,0),n.rectArea[m]=q,m++}else if(D.isPointLight){const q=e.get(D);if(q.color.copy(D.color).multiplyScalar(D.intensity),q.distance=D.distance,q.decay=D.decay,D.castShadow){const G=D.shadow,$=t.get(D);$.shadowIntensity=G.intensity,$.shadowBias=G.bias,$.shadowNormalBias=G.normalBias,$.shadowRadius=G.radius,$.shadowMapSize=G.mapSize,$.shadowCameraNear=G.camera.near,$.shadowCameraFar=G.camera.far,n.pointShadow[g]=$,n.pointShadowMap[g]=O,n.pointShadowMatrix[g]=D.shadow.matrix,T++}n.point[g]=q,g++}else if(D.isHemisphereLight){const q=e.get(D);q.skyColor.copy(D.color).multiplyScalar(W),q.groundColor.copy(D.groundColor).multiplyScalar(W),n.hemi[p]=q,p++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=fe.LTC_FLOAT_1,n.rectAreaLTC2=fe.LTC_FLOAT_2):(n.rectAreaLTC1=fe.LTC_HALF_1,n.rectAreaLTC2=fe.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const _=n.hash;(_.directionalLength!==f||_.pointLength!==g||_.spotLength!==x||_.rectAreaLength!==m||_.hemiLength!==p||_.numDirectionalShadows!==A||_.numPointShadows!==T||_.numSpotShadows!==M||_.numSpotMaps!==y||_.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,_.directionalLength=f,_.pointLength=g,_.spotLength=x,_.rectAreaLength=m,_.hemiLength=p,_.numDirectionalShadows=A,_.numPointShadows=T,_.numSpotShadows=M,_.numSpotMaps=y,_.numLightProbes=R,n.version=w_++)}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 Ku(i){const e=new D_(i),t=[],n=[],s=[];function r(d){u.camera=d,t.length=0,n.length=0,s.length=0}function a(d){t.push(d)}function o(d){n.push(d)}function c(d){s.push(d)}function l(){e.setup(t)}function h(d){e.setupView(t,d)}const u={lightsArray:t,shadowsArray:n,lightProbeGridArray:s,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:u,setupLights:l,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function C_(i){let e=new WeakMap;function t(s,r=0){const a=e.get(s);let o;return a===void 0?(o=new Ku(i),e.set(s,[o])):r>=a.length?(o=new Ku(i),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const P_=`void main() {
4393
+ `+ie)}else U!==""?Ae("WebGLProgram: Program Info Log:",U):(X===""||G==="")&&(te=!1);te&&(D.diagnostics={runnable:Z,programLog:U,vertexShader:{log:X,prefix:m},fragmentShader:{log:G,prefix:p}})}s.deleteShader(S),s.deleteShader(A),_=new So(s,x),E=cM(s,x)}let _;this.getUniforms=function(){return _===void 0&&R(this),_};let E;this.getAttributes=function(){return E===void 0&&R(this),E};let C=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return C===!1&&(C=s.getProgramParameter(x,Qx)),C},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(x),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=jx++,this.cacheKey=e,this.usedTimes=1,this.program=x,this.vertexShader=S,this.fragmentShader=A,this}let bM=0;class AM{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){const s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new wM(e),t.set(e,n)),n}}class wM{constructor(e){this.id=bM++,this.code=e,this.usedTimes=0}}function TM(i){return i===ms||i===wo||i===To}function RM(i,e,t,n,s,r){const a=new Kh,o=new AM,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(_){return c.add(_),_===0?"uv":`uv${_}`}function x(_,E,C,D,I,V){const q=D.fog,U=I.geometry,X=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?D.environment:null,G=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,Z=e.get(_.envMap||X,G),te=Z&&Z.mapping===qo?Z.image.height:null,j=f[_.type];_.precision!==null&&(d=n.getMaxPrecision(_.precision),d!==_.precision&&Ae("WebGLProgram.getParameters:",_.precision,"not supported, using",d,"instead."));const ie=U.morphAttributes.position||U.morphAttributes.normal||U.morphAttributes.color,ue=ie!==void 0?ie.length:0;let He=0;U.morphAttributes.position!==void 0&&(He=1),U.morphAttributes.normal!==void 0&&(He=2),U.morphAttributes.color!==void 0&&(He=3);let Ze,ke,Y,re;if(j){const ye=Zn[j];Ze=ye.vertexShader,ke=ye.fragmentShader}else{Ze=_.vertexShader,ke=_.fragmentShader;const ye=o.getVertexShaderStage(_),St=o.getFragmentShaderStage(_);o.update(_,ye,St),Y=ye.id,re=St.id}const ne=i.getRenderTarget(),z=i.state.buffers.depth.getReversed(),be=I.isInstancedMesh===!0,Pe=I.isBatchedMesh===!0,Te=!!_.map,xe=!!_.matcap,Ne=!!Z,Ue=!!_.aoMap,Oe=!!_.lightMap,tt=!!_.bumpMap&&_.wireframe===!1,nt=!!_.normalMap,Mt=!!_.displacementMap,gt=!!_.emissiveMap,yt=!!_.metalnessMap,It=!!_.roughnessMap,N=_.anisotropy>0,cn=_.clearcoat>0,it=_.dispersion>0,T=_.iridescence>0,v=_.sheen>0,F=_.transmission>0,H=N&&!!_.anisotropyMap,K=cn&&!!_.clearcoatMap,se=cn&&!!_.clearcoatNormalMap,oe=cn&&!!_.clearcoatRoughnessMap,$=T&&!!_.iridescenceMap,Q=T&&!!_.iridescenceThicknessMap,ce=v&&!!_.sheenColorMap,Re=v&&!!_.sheenRoughnessMap,de=!!_.specularMap,le=!!_.specularColorMap,Le=!!_.specularIntensityMap,Fe=F&&!!_.transmissionMap,Ge=F&&!!_.thicknessMap,L=!!_.gradientMap,ae=!!_.alphaMap,J=_.alphaTest>0,he=!!_.alphaHash,ge=!!_.extensions;let ee=si;_.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(ee=i.toneMapping);const we={shaderID:j,shaderType:_.type,shaderName:_.name,vertexShader:Ze,fragmentShader:ke,defines:_.defines,customVertexShaderID:Y,customFragmentShaderID:re,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:d,batching:Pe,batchingColor:Pe&&I._colorsTexture!==null,instancing:be,instancingColor:be&&I.instanceColor!==null,instancingMorph:be&&I.morphTexture!==null,outputColorSpace:ne===null?i.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:Je.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:Te,matcap:xe,envMap:Ne,envMapMode:Ne&&Z.mapping,envMapCubeUVHeight:te,aoMap:Ue,lightMap:Oe,bumpMap:tt,normalMap:nt,displacementMap:Mt,emissiveMap:gt,normalMapObjectSpace:nt&&_.normalMapType===vg,normalMapTangentSpace:nt&&_.normalMapType===Do,packedNormalMap:nt&&_.normalMapType===Do&&TM(_.normalMap.format),metalnessMap:yt,roughnessMap:It,anisotropy:N,anisotropyMap:H,clearcoat:cn,clearcoatMap:K,clearcoatNormalMap:se,clearcoatRoughnessMap:oe,dispersion:it,iridescence:T,iridescenceMap:$,iridescenceThicknessMap:Q,sheen:v,sheenColorMap:ce,sheenRoughnessMap:Re,specularMap:de,specularColorMap:le,specularIntensityMap:Le,transmission:F,transmissionMap:Fe,thicknessMap:Ge,gradientMap:L,opaque:_.transparent===!1&&_.blending===ir&&_.alphaToCoverage===!1,alphaMap:ae,alphaTest:J,alphaHash:he,combine:_.combine,mapUv:Te&&g(_.map.channel),aoMapUv:Ue&&g(_.aoMap.channel),lightMapUv:Oe&&g(_.lightMap.channel),bumpMapUv:tt&&g(_.bumpMap.channel),normalMapUv:nt&&g(_.normalMap.channel),displacementMapUv:Mt&&g(_.displacementMap.channel),emissiveMapUv:gt&&g(_.emissiveMap.channel),metalnessMapUv:yt&&g(_.metalnessMap.channel),roughnessMapUv:It&&g(_.roughnessMap.channel),anisotropyMapUv:H&&g(_.anisotropyMap.channel),clearcoatMapUv:K&&g(_.clearcoatMap.channel),clearcoatNormalMapUv:se&&g(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:oe&&g(_.clearcoatRoughnessMap.channel),iridescenceMapUv:$&&g(_.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&g(_.iridescenceThicknessMap.channel),sheenColorMapUv:ce&&g(_.sheenColorMap.channel),sheenRoughnessMapUv:Re&&g(_.sheenRoughnessMap.channel),specularMapUv:de&&g(_.specularMap.channel),specularColorMapUv:le&&g(_.specularColorMap.channel),specularIntensityMapUv:Le&&g(_.specularIntensityMap.channel),transmissionMapUv:Fe&&g(_.transmissionMap.channel),thicknessMapUv:Ge&&g(_.thicknessMap.channel),alphaMapUv:ae&&g(_.alphaMap.channel),vertexTangents:!!U.attributes.tangent&&(nt||N),vertexNormals:!!U.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!U.attributes.color&&U.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!U.attributes.uv&&(Te||ae),fog:!!q,useFog:_.fog===!0,fogExp2:!!q&&q.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||U.attributes.normal===void 0&&nt===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.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:ue,morphTextureStride:He,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:V.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:_.dithering,shadowMapEnabled:i.shadowMap.enabled&&C.length>0,shadowMapType:i.shadowMap.type,toneMapping:ee,decodeVideoTexture:Te&&_.map.isVideoTexture===!0&&Je.getTransfer(_.map.colorSpace)===st,decodeVideoTextureEmissive:gt&&_.emissiveMap.isVideoTexture===!0&&Je.getTransfer(_.emissiveMap.colorSpace)===st,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===Fn,flipSided:_.side===Ut,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:ge&&_.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ge&&_.extensions.multiDraw===!0||Pe)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return we.vertexUv1s=c.has(1),we.vertexUv2s=c.has(2),we.vertexUv3s=c.has(3),c.clear(),we}function m(_){const E=[];if(_.shaderID?E.push(_.shaderID):(E.push(_.customVertexShaderID),E.push(_.customFragmentShaderID)),_.defines!==void 0)for(const C in _.defines)E.push(C),E.push(_.defines[C]);return _.isRawShaderMaterial===!1&&(p(E,_),b(E,_),E.push(i.outputColorSpace)),E.push(_.customProgramCacheKey),E.join()}function p(_,E){_.push(E.precision),_.push(E.outputColorSpace),_.push(E.envMapMode),_.push(E.envMapCubeUVHeight),_.push(E.mapUv),_.push(E.alphaMapUv),_.push(E.lightMapUv),_.push(E.aoMapUv),_.push(E.bumpMapUv),_.push(E.normalMapUv),_.push(E.displacementMapUv),_.push(E.emissiveMapUv),_.push(E.metalnessMapUv),_.push(E.roughnessMapUv),_.push(E.anisotropyMapUv),_.push(E.clearcoatMapUv),_.push(E.clearcoatNormalMapUv),_.push(E.clearcoatRoughnessMapUv),_.push(E.iridescenceMapUv),_.push(E.iridescenceThicknessMapUv),_.push(E.sheenColorMapUv),_.push(E.sheenRoughnessMapUv),_.push(E.specularMapUv),_.push(E.specularColorMapUv),_.push(E.specularIntensityMapUv),_.push(E.transmissionMapUv),_.push(E.thicknessMapUv),_.push(E.combine),_.push(E.fogExp2),_.push(E.sizeAttenuation),_.push(E.morphTargetsCount),_.push(E.morphAttributeCount),_.push(E.numDirLights),_.push(E.numPointLights),_.push(E.numSpotLights),_.push(E.numSpotLightMaps),_.push(E.numHemiLights),_.push(E.numRectAreaLights),_.push(E.numDirLightShadows),_.push(E.numPointLightShadows),_.push(E.numSpotLightShadows),_.push(E.numSpotLightShadowsWithMaps),_.push(E.numLightProbes),_.push(E.shadowMapType),_.push(E.toneMapping),_.push(E.numClippingPlanes),_.push(E.numClipIntersection),_.push(E.depthPacking)}function b(_,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),_.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),_.push(a.mask)}function w(_){const E=f[_.type];let C;if(E){const D=Zn[E];C=E1.clone(D.uniforms)}else C=_.uniforms;return C}function M(_,E){let C=h.get(E);return C!==void 0?++C.usedTimes:(C=new EM(i,E,_,s),l.push(C),h.set(E,C)),C}function S(_){if(--_.usedTimes===0){const E=l.indexOf(_);l[E]=l[l.length-1],l.pop(),h.delete(_.cacheKey),_.destroy()}}function A(_){o.remove(_)}function R(){o.dispose()}return{getParameters:x,getProgramCacheKey:m,getUniforms:w,acquireProgram:M,releaseProgram:S,releaseShaderCache:A,programs:l,dispose:R}}function DM(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,c){i.get(a)[o]=c}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function CM(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function Jd(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Qd(){const i=[];let e=0;const t=[],n=[],s=[];function r(){e=0,t.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 b=i[e];return b===void 0?(b={id:d.id,object:d,geometry:f,material:g,materialVariant:a(d),groupOrder:x,renderOrder:d.renderOrder,z:m,group:p},i[e]=b):(b.id=d.id,b.object=d,b.geometry=f,b.material=g,b.materialVariant=a(d),b.groupOrder=x,b.renderOrder=d.renderOrder,b.z=m,b.group=p),e++,b}function c(d,f,g,x,m,p){const b=o(d,f,g,x,m,p);g.transmission>0?n.push(b):g.transparent===!0?s.push(b):t.push(b)}function l(d,f,g,x,m,p){const b=o(d,f,g,x,m,p);g.transmission>0?n.unshift(b):g.transparent===!0?s.unshift(b):t.unshift(b)}function h(d,f,g){t.length>1&&t.sort(d||CM),n.length>1&&n.sort(f||Jd),s.length>1&&s.sort(f||Jd),g&&(t.reverse(),n.reverse(),s.reverse())}function u(){for(let d=e,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:t,transmissive:n,transparent:s,init:r,push:c,unshift:l,finish:u,sort:h}}function PM(){let i=new WeakMap;function e(n,s){const r=i.get(n);let a;return r===void 0?(a=new Qd,i.set(n,[a])):s>=r.length?(a=new Qd,r.push(a)):a=r[s],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function IM(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new P,color:new ve};break;case"SpotLight":t={position:new P,direction:new P,color:new ve,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new P,color:new ve,distance:0,decay:0};break;case"HemisphereLight":t={direction:new P,skyColor:new ve,groundColor:new ve};break;case"RectAreaLight":t={color:new ve,position:new P,halfWidth:new P,halfHeight:new P};break}return i[e.id]=t,t}}}function LM(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ie};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ie};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ie,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let NM=0;function UM(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function OM(i){const e=new IM,t=LM(),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 P);const s=new P,r=new qe,a=new qe;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,b=0,w=0,M=0,S=0,A=0,R=0;l.sort(UM);for(let E=0,C=l.length;E<C;E++){const D=l[E],I=D.color,V=D.intensity,q=D.distance;let U=null;if(D.shadow&&D.shadow.map&&(D.shadow.map.texture.format===ms?U=D.shadow.map.texture:U=D.shadow.map.depthTexture||D.shadow.map.texture),D.isAmbientLight)h+=I.r*V,u+=I.g*V,d+=I.b*V;else if(D.isLightProbe){for(let X=0;X<9;X++)n.probe[X].addScaledVector(D.sh.coefficients[X],V);R++}else if(D.isDirectionalLight){const X=e.get(D);if(X.color.copy(D.color).multiplyScalar(D.intensity),D.castShadow){const G=D.shadow,Z=t.get(D);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,n.directionalShadow[f]=Z,n.directionalShadowMap[f]=U,n.directionalShadowMatrix[f]=D.shadow.matrix,b++}n.directional[f]=X,f++}else if(D.isSpotLight){const X=e.get(D);X.position.setFromMatrixPosition(D.matrixWorld),X.color.copy(I).multiplyScalar(V),X.distance=q,X.coneCos=Math.cos(D.angle),X.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),X.decay=D.decay,n.spot[x]=X;const G=D.shadow;if(D.map&&(n.spotLightMap[S]=D.map,S++,G.updateMatrices(D),D.castShadow&&A++),n.spotLightMatrix[x]=G.matrix,D.castShadow){const Z=t.get(D);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,n.spotShadow[x]=Z,n.spotShadowMap[x]=U,M++}x++}else if(D.isRectAreaLight){const X=e.get(D);X.color.copy(I).multiplyScalar(V),X.halfWidth.set(D.width*.5,0,0),X.halfHeight.set(0,D.height*.5,0),n.rectArea[m]=X,m++}else if(D.isPointLight){const X=e.get(D);if(X.color.copy(D.color).multiplyScalar(D.intensity),X.distance=D.distance,X.decay=D.decay,D.castShadow){const G=D.shadow,Z=t.get(D);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,Z.shadowCameraNear=G.camera.near,Z.shadowCameraFar=G.camera.far,n.pointShadow[g]=Z,n.pointShadowMap[g]=U,n.pointShadowMatrix[g]=D.shadow.matrix,w++}n.point[g]=X,g++}else if(D.isHemisphereLight){const X=e.get(D);X.skyColor.copy(D.color).multiplyScalar(V),X.groundColor.copy(D.groundColor).multiplyScalar(V),n.hemi[p]=X,p++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=fe.LTC_FLOAT_1,n.rectAreaLTC2=fe.LTC_FLOAT_2):(n.rectAreaLTC1=fe.LTC_HALF_1,n.rectAreaLTC2=fe.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const _=n.hash;(_.directionalLength!==f||_.pointLength!==g||_.spotLength!==x||_.rectAreaLength!==m||_.hemiLength!==p||_.numDirectionalShadows!==b||_.numPointShadows!==w||_.numSpotShadows!==M||_.numSpotMaps!==S||_.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=b,n.directionalShadowMap.length=b,n.pointShadow.length=w,n.pointShadowMap.length=w,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=b,n.pointShadowMatrix.length=w,n.spotLightMatrix.length=M+S-A,n.spotLightMap.length=S,n.numSpotLightShadowsWithMaps=A,n.numLightProbes=R,_.directionalLength=f,_.pointLength=g,_.spotLength=x,_.rectAreaLength=m,_.hemiLength=p,_.numDirectionalShadows=b,_.numPointShadows=w,_.numSpotShadows=M,_.numSpotMaps=S,_.numLightProbes=R,n.version=NM++)}function c(l,h){let u=0,d=0,f=0,g=0,x=0;const m=h.matrixWorldInverse;for(let p=0,b=l.length;p<b;p++){const w=l[p];if(w.isDirectionalLight){const M=n.directional[u];M.direction.setFromMatrixPosition(w.matrixWorld),s.setFromMatrixPosition(w.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),u++}else if(w.isSpotLight){const M=n.spot[f];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(w.matrixWorld),s.setFromMatrixPosition(w.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),f++}else if(w.isRectAreaLight){const M=n.rectArea[g];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),a.identity(),r.copy(w.matrixWorld),r.premultiply(m),a.extractRotation(r),M.halfWidth.set(w.width*.5,0,0),M.halfHeight.set(0,w.height*.5,0),M.halfWidth.applyMatrix4(a),M.halfHeight.applyMatrix4(a),g++}else if(w.isPointLight){const M=n.point[d];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),d++}else if(w.isHemisphereLight){const M=n.hemi[x];M.direction.setFromMatrixPosition(w.matrixWorld),M.direction.transformDirection(m),x++}}}return{setup:o,setupView:c,state:n}}function jd(i){const e=new OM(i),t=[],n=[],s=[];function r(d){u.camera=d,t.length=0,n.length=0,s.length=0}function a(d){t.push(d)}function o(d){n.push(d)}function c(d){s.push(d)}function l(){e.setup(t)}function h(d){e.setupView(t,d)}const u={lightsArray:t,shadowsArray:n,lightProbeGridArray:s,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:u,setupLights:l,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function FM(i){let e=new WeakMap;function t(s,r=0){const a=e.get(s);let o;return a===void 0?(o=new jd(i),e.set(s,[o])):r>=a.length?(o=new jd(i),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const zM=`void main() {
4394
4394
  gl_Position = vec4( position, 1.0 );
4395
- }`,I_=`uniform sampler2D shadow_pass;
4395
+ }`,BM=`uniform sampler2D shadow_pass;
4396
4396
  uniform vec2 resolution;
4397
4397
  uniform float radius;
4398
4398
  void main() {
@@ -4417,12 +4417,12 @@ void main() {
4417
4417
  squared_mean = squared_mean / samples;
4418
4418
  float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
4419
4419
  gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
4420
- }`,L_=[new L(1,0,0),new L(-1,0,0),new L(0,1,0),new L(0,-1,0),new L(0,0,1),new L(0,0,-1)],N_=[new L(0,-1,0),new L(0,-1,0),new L(0,0,1),new L(0,0,-1),new L(0,-1,0),new L(0,-1,0)],Zu=new dt,_r=new L,uc=new L;function U_(i,e,t){let n=new ph;const s=new Le,r=new Le,a=new vt,o=new Wm,c=new Xm,l={},h=t.maxTextureSize,u={[Fi]:It,[It]:Fi,[Ln]:Ln},d=new At({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Le},radius:{value:4}},vertexShader:P_,fragmentShader:I_}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const g=new Rt;g.setAttribute("position",new ut(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new je(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Cr;let p=this.type;this.render=function(b,R,_){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;this.type===Ip&&(Fe("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Cr);const E=i.getRenderTarget(),C=i.getActiveCubeFace(),D=i.getActiveMipmapLevel(),I=i.state;I.setBlending(jn),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(O=>O.needsUpdate=!0):X.material.needsUpdate=!0)});for(let X=0,O=b.length;X<O;X++){const q=b[X],G=q.shadow;if(G===void 0){Fe("WebGLShadowMap:",q,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;s.copy(G.mapSize);const $=G.getFrameExtents();s.multiply($),r.copy(G.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/$.x),s.x=r.x*$.x,G.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/$.y),s.y=r.y*$.y,G.mapSize.y=r.y));const te=i.state.buffers.depth.getReversed();if(G.camera._reversedDepth=te,G.map===null||W===!0){if(G.map!==null&&(G.map.depthTexture!==null&&(G.map.depthTexture.dispose(),G.map.depthTexture=null),G.map.dispose()),this.type===Er){if(q.isPointLight){Fe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}G.map=new un(s.x,s.y,{format:os,type:Qt,minFilter:Et,magFilter:Et,generateMipmaps:!1}),G.map.texture.name=q.name+".shadowMap",G.map.depthTexture=new ls(s.x,s.y,$n),G.map.depthTexture.name=q.name+".shadowMapDepth",G.map.depthTexture.format=mi,G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Nt,G.map.depthTexture.magFilter=Nt}else q.isPointLight?(G.map=new F0(s.x),G.map.depthTexture=new zm(s.x,On)):(G.map=new un(s.x,s.y),G.map.depthTexture=new ls(s.x,s.y,On)),G.map.depthTexture.name=q.name+".shadowMap",G.map.depthTexture.format=mi,this.type===Cr?(G.map.depthTexture.compareFunction=te?lh:ch,G.map.depthTexture.minFilter=Et,G.map.depthTexture.magFilter=Et):(G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Nt,G.map.depthTexture.magFilter=Nt);G.camera.updateProjectionMatrix()}const j=G.map.isWebGLCubeRenderTarget?6:1;for(let ie=0;ie<j;ie++){if(G.map.isWebGLCubeRenderTarget)i.setRenderTarget(G.map,ie),i.clear();else{ie===0&&(i.setRenderTarget(G.map),i.clear());const ue=G.getViewport(ie);a.set(r.x*ue.x,r.y*ue.y,r.x*ue.z,r.y*ue.w),I.viewport(a)}if(q.isPointLight){const ue=G.camera,He=G.matrix,Ke=q.distance||ue.far;Ke!==ue.far&&(ue.far=Ke,ue.updateProjectionMatrix()),_r.setFromMatrixPosition(q.matrixWorld),ue.position.copy(_r),uc.copy(ue.position),uc.add(L_[ie]),ue.up.copy(N_[ie]),ue.lookAt(uc),ue.updateMatrixWorld(),He.makeTranslation(-_r.x,-_r.y,-_r.z),Zu.multiplyMatrices(ue.projectionMatrix,ue.matrixWorldInverse),G._frustum.setFromProjectionMatrix(Zu,ue.coordinateSystem,ue.reversedDepth)}else G.updateMatrices(q);n=G.getFrustum(),M(R,_,G.camera,q,this.type)}G.isPointLightShadow!==!0&&this.type===Er&&A(G,_),G.needsUpdate=!1}p=this.type,m.needsUpdate=!1,i.setRenderTarget(E,C,D)};function A(b,R){const _=e.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 un(s.x,s.y,{format:os,type:Qt})),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,_,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,_,f,x,null)}function T(b,R,_,E){let C=null;const D=_.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(D!==void 0)C=D;else if(C=_.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=C.uuid,W=R.uuid;let X=l[I];X===void 0&&(X={},l[I]=X);let O=X[W];O===void 0&&(O=C.clone(),X[W]=O,R.addEventListener("dispose",y)),C=O}if(C.visible=R.visible,C.wireframe=R.wireframe,E===Er?C.side=R.shadowSide!==null?R.shadowSide:R.side:C.side=R.shadowSide!==null?R.shadowSide:u[R.side],C.alphaMap=R.alphaMap,C.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,C.map=R.map,C.clipShadows=R.clipShadows,C.clippingPlanes=R.clippingPlanes,C.clipIntersection=R.clipIntersection,C.displacementMap=R.displacementMap,C.displacementScale=R.displacementScale,C.displacementBias=R.displacementBias,C.wireframeLinewidth=R.wireframeLinewidth,C.linewidth=R.linewidth,_.isPointLight===!0&&C.isMeshDistanceMaterial===!0){const I=i.properties.get(C);I.light=_}return C}function M(b,R,_,E,C){if(b.visible===!1)return;if(b.layers.test(R.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&C===Er)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,b.matrixWorld);const W=e.update(b),X=b.material;if(Array.isArray(X)){const O=W.groups;for(let q=0,G=O.length;q<G;q++){const $=O[q],te=X[$.materialIndex];if(te&&te.visible){const j=T(b,te,E,C);b.onBeforeShadow(i,b,R,_,W,j,$),i.renderBufferDirect(_,null,W,j,b,$),b.onAfterShadow(i,b,R,_,W,j,$)}}}else if(X.visible){const O=T(b,X,E,C);b.onBeforeShadow(i,b,R,_,W,O,null),i.renderBufferDirect(_,null,W,O,b,null),b.onAfterShadow(i,b,R,_,W,O,null)}}const I=b.children;for(let W=0,X=I.length;W<X;W++)M(I[W],R,_,E,C)}function y(b){b.target.removeEventListener("dispose",y);for(const _ in l){const E=l[_],C=b.target.uuid;C in E&&(E[C].dispose(),delete E[C])}}}function O_(i,e){function t(){let P=!1;const ae=new vt;let J=null;const he=new vt(0,0,0,0);return{setMask:function(ge){J!==ge&&!P&&(i.colorMask(ge,ge,ge,ge),J=ge)},setLocked:function(ge){P=ge},setClear:function(ge,ee,be,Se,Mt){Mt===!0&&(ge*=Se,ee*=Se,be*=Se),ae.set(ge,ee,be,Se),he.equals(ae)===!1&&(i.clearColor(ge,ee,be,Se),he.copy(ae))},reset:function(){P=!1,J=null,he.set(-1,0,0,0)}}}function n(){let P=!1,ae=!1,J=null,he=null,ge=null;return{setReversed:function(ee){if(ae!==ee){const be=e.get("EXT_clip_control");ee?be.clipControlEXT(be.LOWER_LEFT_EXT,be.ZERO_TO_ONE_EXT):be.clipControlEXT(be.LOWER_LEFT_EXT,be.NEGATIVE_ONE_TO_ONE_EXT),ae=ee;const Se=ge;ge=null,this.setClear(Se)}},getReversed:function(){return ae},setTest:function(ee){ee?ne(i.DEPTH_TEST):z(i.DEPTH_TEST)},setMask:function(ee){J!==ee&&!P&&(i.depthMask(ee),J=ee)},setFunc:function(ee){if(ae&&(ee=um[ee]),he!==ee){switch(ee){case zc:i.depthFunc(i.NEVER);break;case Bc:i.depthFunc(i.ALWAYS);break;case Hc:i.depthFunc(i.LESS);break;case tr:i.depthFunc(i.LEQUAL);break;case kc:i.depthFunc(i.EQUAL);break;case Gc:i.depthFunc(i.GEQUAL);break;case Vc:i.depthFunc(i.GREATER);break;case Wc:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}he=ee}},setLocked:function(ee){P=ee},setClear:function(ee){ge!==ee&&(ge=ee,ae&&(ee=1-ee),i.clearDepth(ee))},reset:function(){P=!1,J=null,he=null,ge=null,ae=!1}}}function s(){let P=!1,ae=null,J=null,he=null,ge=null,ee=null,be=null,Se=null,Mt=null;return{setTest:function(lt){P||(lt?ne(i.STENCIL_TEST):z(i.STENCIL_TEST))},setMask:function(lt){ae!==lt&&!P&&(i.stencilMask(lt),ae=lt)},setFunc:function(lt,Fn,zn){(J!==lt||he!==Fn||ge!==zn)&&(i.stencilFunc(lt,Fn,zn),J=lt,he=Fn,ge=zn)},setOp:function(lt,Fn,zn){(ee!==lt||be!==Fn||Se!==zn)&&(i.stencilOp(lt,Fn,zn),ee=lt,be=Fn,Se=zn)},setLocked:function(lt){P=lt},setClear:function(lt){Mt!==lt&&(i.clearStencil(lt),Mt=lt)},reset:function(){P=!1,ae=null,J=null,he=null,ge=null,ee=null,be=null,Se=null,Mt=null}}}const r=new t,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,_=new Me(0,0,0),E=0,C=!1,D=null,I=null,W=null,X=null,O=null;const q=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let G=!1,$=0;const te=i.getParameter(i.VERSION);te.indexOf("WebGL")!==-1?($=parseFloat(/^WebGL (\d)/.exec(te)[1]),G=$>=1):te.indexOf("OpenGL ES")!==-1&&($=parseFloat(/^OpenGL ES (\d)/.exec(te)[1]),G=$>=2);let j=null,ie={};const ue=i.getParameter(i.SCISSOR_BOX),He=i.getParameter(i.VIEWPORT),Ke=new vt().fromArray(ue),Be=new vt().fromArray(He);function Y(P,ae,J,he){const ge=new Uint8Array(4),ee=i.createTexture();i.bindTexture(P,ee),i.texParameteri(P,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(P,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let be=0;be<J;be++)P===i.TEXTURE_3D||P===i.TEXTURE_2D_ARRAY?i.texImage3D(ae,0,i.RGBA,1,1,he,0,i.RGBA,i.UNSIGNED_BYTE,ge):i.texImage2D(ae+be,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,ge);return ee}const re={};re[i.TEXTURE_2D]=Y(i.TEXTURE_2D,i.TEXTURE_2D,1),re[i.TEXTURE_CUBE_MAP]=Y(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[i.TEXTURE_2D_ARRAY]=Y(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),re[i.TEXTURE_3D]=Y(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ne(i.DEPTH_TEST),a.setFunc(tr),et(!1),tt(Zh),ne(i.CULL_FACE),Ne(jn);function ne(P){h[P]!==!0&&(i.enable(P),h[P]=!0)}function z(P){h[P]!==!1&&(i.disable(P),h[P]=!1)}function Ae(P,ae){return d[P]!==ae?(i.bindFramebuffer(P,ae),d[P]=ae,P===i.DRAW_FRAMEBUFFER&&(d[i.FRAMEBUFFER]=ae),P===i.FRAMEBUFFER&&(d[i.DRAW_FRAMEBUFFER]=ae),!0):!1}function Ce(P,ae){let J=g,he=!1;if(P){J=f.get(ae),J===void 0&&(J=[],f.set(ae,J));const ge=P.textures;if(J.length!==ge.length||J[0]!==i.COLOR_ATTACHMENT0){for(let ee=0,be=ge.length;ee<be;ee++)J[ee]=i.COLOR_ATTACHMENT0+ee;J.length=ge.length,he=!0}}else J[0]!==i.BACK&&(J[0]=i.BACK,he=!0);he&&i.drawBuffers(J)}function Te(P){return x!==P?(i.useProgram(P),x=P,!0):!1}const _e={[Qi]:i.FUNC_ADD,[Np]:i.FUNC_SUBTRACT,[Up]:i.FUNC_REVERSE_SUBTRACT};_e[Op]=i.MIN,_e[Fp]=i.MAX;const Ie={[zp]:i.ZERO,[Bp]:i.ONE,[Hp]:i.SRC_COLOR,[Oc]:i.SRC_ALPHA,[qp]:i.SRC_ALPHA_SATURATE,[Wp]:i.DST_COLOR,[Gp]:i.DST_ALPHA,[kp]:i.ONE_MINUS_SRC_COLOR,[Fc]:i.ONE_MINUS_SRC_ALPHA,[Xp]:i.ONE_MINUS_DST_COLOR,[Vp]:i.ONE_MINUS_DST_ALPHA,[Yp]:i.CONSTANT_COLOR,[Kp]:i.ONE_MINUS_CONSTANT_COLOR,[Zp]:i.CONSTANT_ALPHA,[$p]:i.ONE_MINUS_CONSTANT_ALPHA};function Ne(P,ae,J,he,ge,ee,be,Se,Mt,lt){if(P===jn){m===!0&&(z(i.BLEND),m=!1);return}if(m===!1&&(ne(i.BLEND),m=!0),P!==Lp){if(P!==p||lt!==C){if((A!==Qi||y!==Qi)&&(i.blendEquation(i.FUNC_ADD),A=Qi,y=Qi),lt)switch(P){case Ks:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ni:i.blendFunc(i.ONE,i.ONE);break;case $h:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Jh:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Ze("WebGLState: Invalid blending: ",P);break}else switch(P){case Ks:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ni:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case $h:Ze("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Jh:Ze("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ze("WebGLState: Invalid blending: ",P);break}T=null,M=null,b=null,R=null,_.set(0,0,0),E=0,p=P,C=lt}return}ge=ge||ae,ee=ee||J,be=be||he,(ae!==A||ge!==y)&&(i.blendEquationSeparate(_e[ae],_e[ge]),A=ae,y=ge),(J!==T||he!==M||ee!==b||be!==R)&&(i.blendFuncSeparate(Ie[J],Ie[he],Ie[ee],Ie[be]),T=J,M=he,b=ee,R=be),(Se.equals(_)===!1||Mt!==E)&&(i.blendColor(Se.r,Se.g,Se.b,Mt),_.copy(Se),E=Mt),p=P,C=!1}function Ue(P,ae){P.side===Ln?z(i.CULL_FACE):ne(i.CULL_FACE);let J=P.side===It;ae&&(J=!J),et(J),P.blending===Ks&&P.transparent===!1?Ne(jn):Ne(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 he=P.stencilWrite;o.setTest(he),he&&(o.setMask(P.stencilWriteMask),o.setFunc(P.stencilFunc,P.stencilRef,P.stencilFuncMask),o.setOp(P.stencilFail,P.stencilZFail,P.stencilZPass)),pt(P.polygonOffset,P.polygonOffsetFactor,P.polygonOffsetUnits),P.alphaToCoverage===!0?ne(i.SAMPLE_ALPHA_TO_COVERAGE):z(i.SAMPLE_ALPHA_TO_COVERAGE)}function et(P){D!==P&&(P?i.frontFace(i.CW):i.frontFace(i.CCW),D=P)}function tt(P){P!==Cp?(ne(i.CULL_FACE),P!==I&&(P===Zh?i.cullFace(i.BACK):P===Pp?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):z(i.CULL_FACE),I=P}function _t(P){P!==W&&(G&&i.lineWidth(P),W=P)}function pt(P,ae,J){P?(ne(i.POLYGON_OFFSET_FILL),(X!==ae||O!==J)&&(X=ae,O=J,a.getReversed()&&(ae=-ae),i.polygonOffset(ae,J))):z(i.POLYGON_OFFSET_FILL)}function xt(P){P?ne(i.SCISSOR_TEST):z(i.SCISSOR_TEST)}function Dt(P){P===void 0&&(P=i.TEXTURE0+q-1),j!==P&&(i.activeTexture(P),j=P)}function N(P,ae,J){J===void 0&&(j===null?J=i.TEXTURE0+q-1:J=j);let he=ie[J];he===void 0&&(he={type:void 0,texture:void 0},ie[J]=he),(he.type!==P||he.texture!==ae)&&(j!==J&&(i.activeTexture(J),j=J),i.bindTexture(P,ae||re[P]),he.type=P,he.texture=ae)}function an(){const P=ie[j];P!==void 0&&P.type!==void 0&&(i.bindTexture(P.type,null),P.type=void 0,P.texture=void 0)}function nt(){try{i.compressedTexImage2D(...arguments)}catch(P){Ze("WebGLState:",P)}}function w(){try{i.compressedTexImage3D(...arguments)}catch(P){Ze("WebGLState:",P)}}function v(){try{i.texSubImage2D(...arguments)}catch(P){Ze("WebGLState:",P)}}function F(){try{i.texSubImage3D(...arguments)}catch(P){Ze("WebGLState:",P)}}function k(){try{i.compressedTexSubImage2D(...arguments)}catch(P){Ze("WebGLState:",P)}}function K(){try{i.compressedTexSubImage3D(...arguments)}catch(P){Ze("WebGLState:",P)}}function se(){try{i.texStorage2D(...arguments)}catch(P){Ze("WebGLState:",P)}}function oe(){try{i.texStorage3D(...arguments)}catch(P){Ze("WebGLState:",P)}}function Z(){try{i.texImage2D(...arguments)}catch(P){Ze("WebGLState:",P)}}function Q(){try{i.texImage3D(...arguments)}catch(P){Ze("WebGLState:",P)}}function ce(P){return u[P]!==void 0?u[P]:i.getParameter(P)}function we(P,ae){u[P]!==ae&&(i.pixelStorei(P,ae),u[P]=ae)}function de(P){Ke.equals(P)===!1&&(i.scissor(P.x,P.y,P.z,P.w),Ke.copy(P))}function le(P){Be.equals(P)===!1&&(i.viewport(P.x,P.y,P.z,P.w),Be.copy(P))}function Pe(P,ae){let J=l.get(ae);J===void 0&&(J=new WeakMap,l.set(ae,J));let he=J.get(P);he===void 0&&(he=i.getUniformBlockIndex(ae,P.name),J.set(P,he))}function Oe(P,ae){const he=l.get(ae).get(P);c.get(ae)!==he&&(i.uniformBlockBinding(ae,he,P.__bindingPointIndex),c.set(ae,he))}function ke(){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,ie={},d={},f=new WeakMap,g=[],x=null,m=!1,p=null,A=null,T=null,M=null,y=null,b=null,R=null,_=new Me(0,0,0),E=0,C=!1,D=null,I=null,W=null,X=null,O=null,Ke.set(0,0,i.canvas.width,i.canvas.height),Be.set(0,0,i.canvas.width,i.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:ne,disable:z,bindFramebuffer:Ae,drawBuffers:Ce,useProgram:Te,setBlending:Ne,setMaterial:Ue,setFlipSided:et,setCullFace:tt,setLineWidth:_t,setPolygonOffset:pt,setScissorTest:xt,activeTexture:Dt,bindTexture:N,unbindTexture:an,compressedTexImage2D:nt,compressedTexImage3D:w,texImage2D:Z,texImage3D:Q,pixelStorei:we,getParameter:ce,updateUBOMapping:Pe,uniformBlockBinding:Oe,texStorage2D:se,texStorage3D:oe,texSubImage2D:v,texSubImage3D:F,compressedTexSubImage2D:k,compressedTexSubImage3D:K,scissor:de,viewport:le,reset:ke}}function F_(i,e,t,n,s,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Le,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,v){return g?new OffscreenCanvas(w,v):io("canvas")}function m(w,v,F){let k=1;const K=nt(w);if((K.width>F||K.height>F)&&(k=F/Math.max(K.width,K.height)),k<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 se=Math.floor(k*K.width),oe=Math.floor(k*K.height);d===void 0&&(d=x(se,oe));const Z=v?x(se,oe):d;return Z.width=se,Z.height=oe,Z.getContext("2d").drawImage(w,0,0,se,oe),Fe("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+se+"x"+oe+")."),Z}else return"data"in w&&Fe("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,v,F,k,K,se=!1){if(w!==null){if(i[w]!==void 0)return i[w];Fe("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+w+"'")}let oe;k&&(oe=e.get("EXT_texture_norm16"),oe||Fe("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Z=v;if(v===i.RED&&(F===i.FLOAT&&(Z=i.R32F),F===i.HALF_FLOAT&&(Z=i.R16F),F===i.UNSIGNED_BYTE&&(Z=i.R8),F===i.UNSIGNED_SHORT&&oe&&(Z=oe.R16_EXT),F===i.SHORT&&oe&&(Z=oe.R16_SNORM_EXT)),v===i.RED_INTEGER&&(F===i.UNSIGNED_BYTE&&(Z=i.R8UI),F===i.UNSIGNED_SHORT&&(Z=i.R16UI),F===i.UNSIGNED_INT&&(Z=i.R32UI),F===i.BYTE&&(Z=i.R8I),F===i.SHORT&&(Z=i.R16I),F===i.INT&&(Z=i.R32I)),v===i.RG&&(F===i.FLOAT&&(Z=i.RG32F),F===i.HALF_FLOAT&&(Z=i.RG16F),F===i.UNSIGNED_BYTE&&(Z=i.RG8),F===i.UNSIGNED_SHORT&&oe&&(Z=oe.RG16_EXT),F===i.SHORT&&oe&&(Z=oe.RG16_SNORM_EXT)),v===i.RG_INTEGER&&(F===i.UNSIGNED_BYTE&&(Z=i.RG8UI),F===i.UNSIGNED_SHORT&&(Z=i.RG16UI),F===i.UNSIGNED_INT&&(Z=i.RG32UI),F===i.BYTE&&(Z=i.RG8I),F===i.SHORT&&(Z=i.RG16I),F===i.INT&&(Z=i.RG32I)),v===i.RGB_INTEGER&&(F===i.UNSIGNED_BYTE&&(Z=i.RGB8UI),F===i.UNSIGNED_SHORT&&(Z=i.RGB16UI),F===i.UNSIGNED_INT&&(Z=i.RGB32UI),F===i.BYTE&&(Z=i.RGB8I),F===i.SHORT&&(Z=i.RGB16I),F===i.INT&&(Z=i.RGB32I)),v===i.RGBA_INTEGER&&(F===i.UNSIGNED_BYTE&&(Z=i.RGBA8UI),F===i.UNSIGNED_SHORT&&(Z=i.RGBA16UI),F===i.UNSIGNED_INT&&(Z=i.RGBA32UI),F===i.BYTE&&(Z=i.RGBA8I),F===i.SHORT&&(Z=i.RGBA16I),F===i.INT&&(Z=i.RGBA32I)),v===i.RGB&&(F===i.UNSIGNED_SHORT&&oe&&(Z=oe.RGB16_EXT),F===i.SHORT&&oe&&(Z=oe.RGB16_SNORM_EXT),F===i.UNSIGNED_INT_5_9_9_9_REV&&(Z=i.RGB9_E5),F===i.UNSIGNED_INT_10F_11F_11F_REV&&(Z=i.R11F_G11F_B10F)),v===i.RGBA){const Q=se?no:$e.getTransfer(K);F===i.FLOAT&&(Z=i.RGBA32F),F===i.HALF_FLOAT&&(Z=i.RGBA16F),F===i.UNSIGNED_BYTE&&(Z=Q===it?i.SRGB8_ALPHA8:i.RGBA8),F===i.UNSIGNED_SHORT&&oe&&(Z=oe.RGBA16_EXT),F===i.SHORT&&oe&&(Z=oe.RGBA16_SNORM_EXT),F===i.UNSIGNED_SHORT_4_4_4_4&&(Z=i.RGBA4),F===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)&&e.get("EXT_color_buffer_float"),Z}function y(w,v){let F;return w?v===null||v===On||v===zr?F=i.DEPTH24_STENCIL8:v===$n?F=i.DEPTH32F_STENCIL8:v===Fr&&(F=i.DEPTH24_STENCIL8,Fe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):v===null||v===On||v===zr?F=i.DEPTH_COMPONENT24:v===$n?F=i.DEPTH_COMPONENT32F:v===Fr&&(F=i.DEPTH_COMPONENT16),F}function b(w,v){return p(w)===!0||w.isFramebufferTexture&&w.minFilter!==Nt&&w.minFilter!==Et?Math.log2(Math.max(v.width,v.height))+1:w.mipmaps!==void 0&&w.mipmaps.length>0?w.mipmaps.length:w.isCompressedTexture&&Array.isArray(w.image)?v.mipmaps.length:1}function R(w){const v=w.target;v.removeEventListener("dispose",R),E(v),v.isVideoTexture&&h.delete(v),v.isHTMLTexture&&u.delete(v)}function _(w){const v=w.target;v.removeEventListener("dispose",_),D(v)}function E(w){const v=n.get(w);if(v.__webglInit===void 0)return;const F=w.source,k=f.get(F);if(k){const K=k[v.__cacheKey];K.usedTimes--,K.usedTimes===0&&C(w),Object.keys(k).length===0&&f.delete(F)}n.remove(w)}function C(w){const v=n.get(w);i.deleteTexture(v.__webglTexture);const F=w.source,k=f.get(F);delete k[v.__cacheKey],a.memory.textures--}function D(w){const v=n.get(w);if(w.depthTexture&&(w.depthTexture.dispose(),n.remove(w.depthTexture)),w.isWebGLCubeRenderTarget)for(let k=0;k<6;k++){if(Array.isArray(v.__webglFramebuffer[k]))for(let K=0;K<v.__webglFramebuffer[k].length;K++)i.deleteFramebuffer(v.__webglFramebuffer[k][K]);else i.deleteFramebuffer(v.__webglFramebuffer[k]);v.__webglDepthbuffer&&i.deleteRenderbuffer(v.__webglDepthbuffer[k])}else{if(Array.isArray(v.__webglFramebuffer))for(let k=0;k<v.__webglFramebuffer.length;k++)i.deleteFramebuffer(v.__webglFramebuffer[k]);else i.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer&&i.deleteRenderbuffer(v.__webglDepthbuffer),v.__webglMultisampledFramebuffer&&i.deleteFramebuffer(v.__webglMultisampledFramebuffer),v.__webglColorRenderbuffer)for(let k=0;k<v.__webglColorRenderbuffer.length;k++)v.__webglColorRenderbuffer[k]&&i.deleteRenderbuffer(v.__webglColorRenderbuffer[k]);v.__webglDepthRenderbuffer&&i.deleteRenderbuffer(v.__webglDepthRenderbuffer)}const F=w.textures;for(let k=0,K=F.length;k<K;k++){const se=n.get(F[k]);se.__webglTexture&&(i.deleteTexture(se.__webglTexture),a.memory.textures--),n.remove(F[k])}n.remove(w)}let I=0;function W(){I=0}function X(){return I}function O(w){I=w}function q(){const w=I;return w>=s.maxTextures&&Fe("WebGLTextures: Trying to use "+w+" texture units while this GPU supports only "+s.maxTextures),I+=1,w}function G(w){const v=[];return v.push(w.wrapS),v.push(w.wrapT),v.push(w.wrapR||0),v.push(w.magFilter),v.push(w.minFilter),v.push(w.anisotropy),v.push(w.internalFormat),v.push(w.format),v.push(w.type),v.push(w.generateMipmaps),v.push(w.premultiplyAlpha),v.push(w.flipY),v.push(w.unpackAlignment),v.push(w.colorSpace),v.join()}function $(w,v){const F=n.get(w);if(w.isVideoTexture&&N(w),w.isRenderTargetTexture===!1&&w.isExternalTexture!==!0&&w.version>0&&F.__version!==w.version){const k=w.image;if(k===null)Fe("WebGLRenderer: Texture marked for update but no image data found.");else if(k.complete===!1)Fe("WebGLRenderer: Texture marked for update but image is incomplete");else{z(F,w,v);return}}else w.isExternalTexture&&(F.__webglTexture=w.sourceTexture?w.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,F.__webglTexture,i.TEXTURE0+v)}function te(w,v){const F=n.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&F.__version!==w.version){z(F,w,v);return}else w.isExternalTexture&&(F.__webglTexture=w.sourceTexture?w.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,F.__webglTexture,i.TEXTURE0+v)}function j(w,v){const F=n.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&F.__version!==w.version){z(F,w,v);return}t.bindTexture(i.TEXTURE_3D,F.__webglTexture,i.TEXTURE0+v)}function ie(w,v){const F=n.get(w);if(w.isCubeDepthTexture!==!0&&w.version>0&&F.__version!==w.version){Ae(F,w,v);return}t.bindTexture(i.TEXTURE_CUBE_MAP,F.__webglTexture,i.TEXTURE0+v)}const ue={[Qa]:i.REPEAT,[sn]:i.CLAMP_TO_EDGE,[Xc]:i.MIRRORED_REPEAT},He={[Nt]:i.NEAREST,[jp]:i.NEAREST_MIPMAP_NEAREST,[jr]:i.NEAREST_MIPMAP_LINEAR,[Et]:i.LINEAR,[Io]:i.LINEAR_MIPMAP_NEAREST,[ns]:i.LINEAR_MIPMAP_LINEAR},Ke={[nm]:i.NEVER,[om]:i.ALWAYS,[im]:i.LESS,[ch]:i.LEQUAL,[sm]:i.EQUAL,[lh]:i.GEQUAL,[rm]:i.GREATER,[am]:i.NOTEQUAL};function Be(w,v){if(v.type===$n&&e.has("OES_texture_float_linear")===!1&&(v.magFilter===Et||v.magFilter===Io||v.magFilter===jr||v.magFilter===ns||v.minFilter===Et||v.minFilter===Io||v.minFilter===jr||v.minFilter===ns)&&Fe("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,ue[v.wrapS]),i.texParameteri(w,i.TEXTURE_WRAP_T,ue[v.wrapT]),(w===i.TEXTURE_3D||w===i.TEXTURE_2D_ARRAY)&&i.texParameteri(w,i.TEXTURE_WRAP_R,ue[v.wrapR]),i.texParameteri(w,i.TEXTURE_MAG_FILTER,He[v.magFilter]),i.texParameteri(w,i.TEXTURE_MIN_FILTER,He[v.minFilter]),v.compareFunction&&(i.texParameteri(w,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(w,i.TEXTURE_COMPARE_FUNC,Ke[v.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===Nt||v.minFilter!==jr&&v.minFilter!==ns||v.type===$n&&e.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||n.get(v).__currentAnisotropy){const F=e.get("EXT_texture_filter_anisotropic");i.texParameterf(w,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,s.getMaxAnisotropy())),n.get(v).__currentAnisotropy=v.anisotropy}}}function Y(w,v){let F=!1;w.__webglInit===void 0&&(w.__webglInit=!0,v.addEventListener("dispose",R));const k=v.source;let K=f.get(k);K===void 0&&(K={},f.set(k,K));const se=G(v);if(se!==w.__cacheKey){K[se]===void 0&&(K[se]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,F=!0),K[se].usedTimes++;const oe=K[w.__cacheKey];oe!==void 0&&(K[w.__cacheKey].usedTimes--,oe.usedTimes===0&&C(v)),w.__cacheKey=se,w.__webglTexture=K[se].texture}return F}function re(w,v,F){return Math.floor(Math.floor(w/F)/v)}function ne(w,v,F,k){const se=w.updateRanges;if(se.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,v.width,v.height,F,k,v.data);else{se.sort((we,de)=>we.start-de.start);let oe=0;for(let we=1;we<se.length;we++){const de=se[oe],le=se[we],Pe=de.start+de.count,Oe=re(le.start,v.width,4),ke=re(de.start,v.width,4);le.start<=Pe+1&&Oe===ke&&re(le.start+le.count-1,v.width,4)===Oe?de.count=Math.max(de.count,le.start+le.count-de.start):(++oe,se[oe]=le)}se.length=oe+1;const Z=t.getParameter(i.UNPACK_ROW_LENGTH),Q=t.getParameter(i.UNPACK_SKIP_PIXELS),ce=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,v.width);for(let we=0,de=se.length;we<de;we++){const le=se[we],Pe=Math.floor(le.start/4),Oe=Math.ceil(le.count/4),ke=Pe%v.width,P=Math.floor(Pe/v.width),ae=Oe,J=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,ke),t.pixelStorei(i.UNPACK_SKIP_ROWS,P),t.texSubImage2D(i.TEXTURE_2D,0,ke,P,ae,J,F,k,v.data)}w.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,Z),t.pixelStorei(i.UNPACK_SKIP_PIXELS,Q),t.pixelStorei(i.UNPACK_SKIP_ROWS,ce)}}function z(w,v,F){let k=i.TEXTURE_2D;(v.isDataArrayTexture||v.isCompressedArrayTexture)&&(k=i.TEXTURE_2D_ARRAY),v.isData3DTexture&&(k=i.TEXTURE_3D);const K=Y(w,v),se=v.source;t.bindTexture(k,w.__webglTexture,i.TEXTURE0+F);const oe=n.get(se);if(se.version!==oe.__version||K===!0){if(t.activeTexture(i.TEXTURE0+F),(typeof ImageBitmap<"u"&&v.image instanceof ImageBitmap)===!1){const J=$e.getPrimaries($e.workingColorSpace),he=v.colorSpace===Pi?null:$e.getPrimaries(v.colorSpace),ge=v.colorSpace===Pi||J===he?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,v.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,ge)}t.pixelStorei(i.UNPACK_ALIGNMENT,v.unpackAlignment);let Q=m(v.image,!1,s.maxTextureSize);Q=an(v,Q);const ce=r.convert(v.format,v.colorSpace),we=r.convert(v.type);let de=M(v.internalFormat,ce,we,v.normalized,v.colorSpace,v.isVideoTexture);Be(k,v);let le;const Pe=v.mipmaps,Oe=v.isVideoTexture!==!0,ke=oe.__version===void 0||K===!0,P=se.dataReady,ae=b(v,Q);if(v.isDepthTexture)de=y(v.format===is,v.type),ke&&(Oe?t.texStorage2D(i.TEXTURE_2D,1,de,Q.width,Q.height):t.texImage2D(i.TEXTURE_2D,0,de,Q.width,Q.height,0,ce,we,null));else if(v.isDataTexture)if(Pe.length>0){Oe&&ke&&t.texStorage2D(i.TEXTURE_2D,ae,de,Pe[0].width,Pe[0].height);for(let J=0,he=Pe.length;J<he;J++)le=Pe[J],Oe?P&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,le.width,le.height,ce,we,le.data):t.texImage2D(i.TEXTURE_2D,J,de,le.width,le.height,0,ce,we,le.data);v.generateMipmaps=!1}else Oe?(ke&&t.texStorage2D(i.TEXTURE_2D,ae,de,Q.width,Q.height),P&&ne(v,Q,ce,we)):t.texImage2D(i.TEXTURE_2D,0,de,Q.width,Q.height,0,ce,we,Q.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){Oe&&ke&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ae,de,Pe[0].width,Pe[0].height,Q.depth);for(let J=0,he=Pe.length;J<he;J++)if(le=Pe[J],v.format!==hn)if(ce!==null)if(Oe){if(P)if(v.layerUpdates.size>0){const ge=Tu(le.width,le.height,v.format,v.type);for(const ee of v.layerUpdates){const be=le.data.subarray(ee*ge/le.data.BYTES_PER_ELEMENT,(ee+1)*ge/le.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,ee,le.width,le.height,1,ce,be)}v.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,le.width,le.height,Q.depth,ce,le.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,J,de,le.width,le.height,Q.depth,0,le.data,0,0);else Fe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Oe?P&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,le.width,le.height,Q.depth,ce,we,le.data):t.texImage3D(i.TEXTURE_2D_ARRAY,J,de,le.width,le.height,Q.depth,0,ce,we,le.data)}else{Oe&&ke&&t.texStorage2D(i.TEXTURE_2D,ae,de,Pe[0].width,Pe[0].height);for(let J=0,he=Pe.length;J<he;J++)le=Pe[J],v.format!==hn?ce!==null?Oe?P&&t.compressedTexSubImage2D(i.TEXTURE_2D,J,0,0,le.width,le.height,ce,le.data):t.compressedTexImage2D(i.TEXTURE_2D,J,de,le.width,le.height,0,le.data):Fe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Oe?P&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,le.width,le.height,ce,we,le.data):t.texImage2D(i.TEXTURE_2D,J,de,le.width,le.height,0,ce,we,le.data)}else if(v.isDataArrayTexture)if(Oe){if(ke&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ae,de,Q.width,Q.height,Q.depth),P)if(v.layerUpdates.size>0){const J=Tu(Q.width,Q.height,v.format,v.type);for(const he of v.layerUpdates){const ge=Q.data.subarray(he*J/Q.data.BYTES_PER_ELEMENT,(he+1)*J/Q.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,he,Q.width,Q.height,1,ce,we,ge)}v.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,ce,we,Q.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,de,Q.width,Q.height,Q.depth,0,ce,we,Q.data);else if(v.isData3DTexture)Oe?(ke&&t.texStorage3D(i.TEXTURE_3D,ae,de,Q.width,Q.height,Q.depth),P&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,ce,we,Q.data)):t.texImage3D(i.TEXTURE_3D,0,de,Q.width,Q.height,Q.depth,0,ce,we,Q.data);else if(v.isFramebufferTexture){if(ke)if(Oe)t.texStorage2D(i.TEXTURE_2D,ae,de,Q.width,Q.height);else{let J=Q.width,he=Q.height;for(let ge=0;ge<ae;ge++)t.texImage2D(i.TEXTURE_2D,ge,de,J,he,0,ce,we,null),J>>=1,he>>=1}}else if(v.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(v),J.onpaint=he=>{const ge=he.changedElements;for(const ee of u)ge.includes(ee.image)&&(ee.needsUpdate=!0)},J.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,Q);else{const ge=i.RGBA,ee=i.RGBA,be=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,ge,ee,be,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(Pe.length>0){if(Oe&&ke){const J=nt(Pe[0]);t.texStorage2D(i.TEXTURE_2D,ae,de,J.width,J.height)}for(let J=0,he=Pe.length;J<he;J++)le=Pe[J],Oe?P&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,ce,we,le):t.texImage2D(i.TEXTURE_2D,J,de,ce,we,le);v.generateMipmaps=!1}else if(Oe){if(ke){const J=nt(Q);t.texStorage2D(i.TEXTURE_2D,ae,de,J.width,J.height)}P&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,ce,we,Q)}else t.texImage2D(i.TEXTURE_2D,0,de,ce,we,Q);p(v)&&A(k),oe.__version=se.version,v.onUpdate&&v.onUpdate(v)}w.__version=v.version}function Ae(w,v,F){if(v.image.length!==6)return;const k=Y(w,v),K=v.source;t.bindTexture(i.TEXTURE_CUBE_MAP,w.__webglTexture,i.TEXTURE0+F);const se=n.get(K);if(K.version!==se.__version||k===!0){t.activeTexture(i.TEXTURE0+F);const oe=$e.getPrimaries($e.workingColorSpace),Z=v.colorSpace===Pi?null:$e.getPrimaries(v.colorSpace),Q=v.colorSpace===Pi||oe===Z?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,v.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),t.pixelStorei(i.UNPACK_ALIGNMENT,v.unpackAlignment),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);const ce=v.isCompressedTexture||v.image[0].isCompressedTexture,we=v.image[0]&&v.image[0].isDataTexture,de=[];for(let ee=0;ee<6;ee++)!ce&&!we?de[ee]=m(v.image[ee],!0,s.maxCubemapSize):de[ee]=we?v.image[ee].image:v.image[ee],de[ee]=an(v,de[ee]);const le=de[0],Pe=r.convert(v.format,v.colorSpace),Oe=r.convert(v.type),ke=M(v.internalFormat,Pe,Oe,v.normalized,v.colorSpace),P=v.isVideoTexture!==!0,ae=se.__version===void 0||k===!0,J=K.dataReady;let he=b(v,le);Be(i.TEXTURE_CUBE_MAP,v);let ge;if(ce){P&&ae&&t.texStorage2D(i.TEXTURE_CUBE_MAP,he,ke,le.width,le.height);for(let ee=0;ee<6;ee++){ge=de[ee].mipmaps;for(let be=0;be<ge.length;be++){const Se=ge[be];v.format!==hn?Pe!==null?P?J&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,be,0,0,Se.width,Se.height,Pe,Se.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,be,ke,Se.width,Se.height,0,Se.data):Fe("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):P?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,be,0,0,Se.width,Se.height,Pe,Oe,Se.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,be,ke,Se.width,Se.height,0,Pe,Oe,Se.data)}}}else{if(ge=v.mipmaps,P&&ae){ge.length>0&&he++;const ee=nt(de[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,he,ke,ee.width,ee.height)}for(let ee=0;ee<6;ee++)if(we){P?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,de[ee].width,de[ee].height,Pe,Oe,de[ee].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,ke,de[ee].width,de[ee].height,0,Pe,Oe,de[ee].data);for(let be=0;be<ge.length;be++){const Mt=ge[be].image[ee].image;P?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,be+1,0,0,Mt.width,Mt.height,Pe,Oe,Mt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,be+1,ke,Mt.width,Mt.height,0,Pe,Oe,Mt.data)}}else{P?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,Pe,Oe,de[ee]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,ke,Pe,Oe,de[ee]);for(let be=0;be<ge.length;be++){const Se=ge[be];P?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,be+1,0,0,Pe,Oe,Se.image[ee]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,be+1,ke,Pe,Oe,Se.image[ee])}}}p(v)&&A(i.TEXTURE_CUBE_MAP),se.__version=K.version,v.onUpdate&&v.onUpdate(v)}w.__version=v.version}function Ce(w,v,F,k,K,se){const oe=r.convert(F.format,F.colorSpace),Z=r.convert(F.type),Q=M(F.internalFormat,oe,Z,F.normalized,F.colorSpace),ce=n.get(v),we=n.get(F);if(we.__renderTarget=v,!ce.__hasExternalTextures){const de=Math.max(1,v.width>>se),le=Math.max(1,v.height>>se);K===i.TEXTURE_3D||K===i.TEXTURE_2D_ARRAY?t.texImage3D(K,se,Q,de,le,v.depth,0,oe,Z,null):t.texImage2D(K,se,Q,de,le,0,oe,Z,null)}t.bindFramebuffer(i.FRAMEBUFFER,w),Dt(v)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,k,K,we.__webglTexture,0,xt(v)):(K===i.TEXTURE_2D||K>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,k,K,we.__webglTexture,se),t.bindFramebuffer(i.FRAMEBUFFER,null)}function Te(w,v,F){if(i.bindRenderbuffer(i.RENDERBUFFER,w),v.depthBuffer){const k=v.depthTexture,K=k&&k.isDepthTexture?k.type:null,se=y(v.stencilBuffer,K),oe=v.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;Dt(v)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,xt(v),se,v.width,v.height):F?i.renderbufferStorageMultisample(i.RENDERBUFFER,xt(v),se,v.width,v.height):i.renderbufferStorage(i.RENDERBUFFER,se,v.width,v.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,oe,i.RENDERBUFFER,w)}else{const k=v.textures;for(let K=0;K<k.length;K++){const se=k[K],oe=r.convert(se.format,se.colorSpace),Z=r.convert(se.type),Q=M(se.internalFormat,oe,Z,se.normalized,se.colorSpace);Dt(v)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,xt(v),Q,v.width,v.height):F?i.renderbufferStorageMultisample(i.RENDERBUFFER,xt(v),Q,v.width,v.height):i.renderbufferStorage(i.RENDERBUFFER,Q,v.width,v.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function _e(w,v,F){const k=v.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,w),!(v.depthTexture&&v.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const K=n.get(v.depthTexture);if(K.__renderTarget=v,(!K.__webglTexture||v.depthTexture.image.width!==v.width||v.depthTexture.image.height!==v.height)&&(v.depthTexture.image.width=v.width,v.depthTexture.image.height=v.height,v.depthTexture.needsUpdate=!0),k){if(K.__webglInit===void 0&&(K.__webglInit=!0,v.depthTexture.addEventListener("dispose",R)),K.__webglTexture===void 0){K.__webglTexture=i.createTexture(),t.bindTexture(i.TEXTURE_CUBE_MAP,K.__webglTexture),Be(i.TEXTURE_CUBE_MAP,v.depthTexture);const ce=r.convert(v.depthTexture.format),we=r.convert(v.depthTexture.type);let de;v.depthTexture.format===mi?de=i.DEPTH_COMPONENT24:v.depthTexture.format===is&&(de=i.DEPTH24_STENCIL8);for(let le=0;le<6;le++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,de,v.width,v.height,0,ce,we,null)}}else $(v.depthTexture,0);const se=K.__webglTexture,oe=xt(v),Z=k?i.TEXTURE_CUBE_MAP_POSITIVE_X+F:i.TEXTURE_2D,Q=v.depthTexture.format===is?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(v.depthTexture.format===mi)Dt(v)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Q,Z,se,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,Q,Z,se,0);else if(v.depthTexture.format===is)Dt(v)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Q,Z,se,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,Q,Z,se,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ie(w){const v=n.get(w),F=w.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==w.depthTexture){const k=w.depthTexture;if(v.__depthDisposeCallback&&v.__depthDisposeCallback(),k){const K=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,k.removeEventListener("dispose",K)};k.addEventListener("dispose",K),v.__depthDisposeCallback=K}v.__boundDepthTexture=k}if(w.depthTexture&&!v.__autoAllocateDepthBuffer)if(F)for(let k=0;k<6;k++)_e(v.__webglFramebuffer[k],w,k);else{const k=w.texture.mipmaps;k&&k.length>0?_e(v.__webglFramebuffer[0],w,0):_e(v.__webglFramebuffer,w,0)}else if(F){v.__webglDepthbuffer=[];for(let k=0;k<6;k++)if(t.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer[k]),v.__webglDepthbuffer[k]===void 0)v.__webglDepthbuffer[k]=i.createRenderbuffer(),Te(v.__webglDepthbuffer[k],w,!1);else{const K=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,se=v.__webglDepthbuffer[k];i.bindRenderbuffer(i.RENDERBUFFER,se),i.framebufferRenderbuffer(i.FRAMEBUFFER,K,i.RENDERBUFFER,se)}}else{const k=w.texture.mipmaps;if(k&&k.length>0?t.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer),v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=i.createRenderbuffer(),Te(v.__webglDepthbuffer,w,!1);else{const K=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,se=v.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,se),i.framebufferRenderbuffer(i.FRAMEBUFFER,K,i.RENDERBUFFER,se)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function Ne(w,v,F){const k=n.get(w);v!==void 0&&Ce(k.__webglFramebuffer,w,w.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),F!==void 0&&Ie(w)}function Ue(w){const v=w.texture,F=n.get(w),k=n.get(v);w.addEventListener("dispose",_);const K=w.textures,se=w.isWebGLCubeRenderTarget===!0,oe=K.length>1;if(oe||(k.__webglTexture===void 0&&(k.__webglTexture=i.createTexture()),k.__version=v.version,a.memory.textures++),se){F.__webglFramebuffer=[];for(let Z=0;Z<6;Z++)if(v.mipmaps&&v.mipmaps.length>0){F.__webglFramebuffer[Z]=[];for(let Q=0;Q<v.mipmaps.length;Q++)F.__webglFramebuffer[Z][Q]=i.createFramebuffer()}else F.__webglFramebuffer[Z]=i.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){F.__webglFramebuffer=[];for(let Z=0;Z<v.mipmaps.length;Z++)F.__webglFramebuffer[Z]=i.createFramebuffer()}else F.__webglFramebuffer=i.createFramebuffer();if(oe)for(let Z=0,Q=K.length;Z<Q;Z++){const ce=n.get(K[Z]);ce.__webglTexture===void 0&&(ce.__webglTexture=i.createTexture(),a.memory.textures++)}if(w.samples>0&&Dt(w)===!1){F.__webglMultisampledFramebuffer=i.createFramebuffer(),F.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let Z=0;Z<K.length;Z++){const Q=K[Z];F.__webglColorRenderbuffer[Z]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,F.__webglColorRenderbuffer[Z]);const ce=r.convert(Q.format,Q.colorSpace),we=r.convert(Q.type),de=M(Q.internalFormat,ce,we,Q.normalized,Q.colorSpace,w.isXRRenderTarget===!0),le=xt(w);i.renderbufferStorageMultisample(i.RENDERBUFFER,le,de,w.width,w.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Z,i.RENDERBUFFER,F.__webglColorRenderbuffer[Z])}i.bindRenderbuffer(i.RENDERBUFFER,null),w.depthBuffer&&(F.__webglDepthRenderbuffer=i.createRenderbuffer(),Te(F.__webglDepthRenderbuffer,w,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(se){t.bindTexture(i.TEXTURE_CUBE_MAP,k.__webglTexture),Be(i.TEXTURE_CUBE_MAP,v);for(let Z=0;Z<6;Z++)if(v.mipmaps&&v.mipmaps.length>0)for(let Q=0;Q<v.mipmaps.length;Q++)Ce(F.__webglFramebuffer[Z][Q],w,v,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Q);else Ce(F.__webglFramebuffer[Z],w,v,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0);p(v)&&A(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(oe){for(let Z=0,Q=K.length;Z<Q;Z++){const ce=K[Z],we=n.get(ce);let de=i.TEXTURE_2D;(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)&&(de=w.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(de,we.__webglTexture),Be(de,ce),Ce(F.__webglFramebuffer,w,ce,i.COLOR_ATTACHMENT0+Z,de,0),p(ce)&&A(de)}t.unbindTexture()}else{let Z=i.TEXTURE_2D;if((w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)&&(Z=w.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(Z,k.__webglTexture),Be(Z,v),v.mipmaps&&v.mipmaps.length>0)for(let Q=0;Q<v.mipmaps.length;Q++)Ce(F.__webglFramebuffer[Q],w,v,i.COLOR_ATTACHMENT0,Z,Q);else Ce(F.__webglFramebuffer,w,v,i.COLOR_ATTACHMENT0,Z,0);p(v)&&A(Z),t.unbindTexture()}w.depthBuffer&&Ie(w)}function et(w){const v=w.textures;for(let F=0,k=v.length;F<k;F++){const K=v[F];if(p(K)){const se=T(w),oe=n.get(K).__webglTexture;t.bindTexture(se,oe),A(se),t.unbindTexture()}}}const tt=[],_t=[];function pt(w){if(w.samples>0){if(Dt(w)===!1){const v=w.textures,F=w.width,k=w.height;let K=i.COLOR_BUFFER_BIT;const se=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,oe=n.get(w),Z=v.length>1;if(Z)for(let ce=0;ce<v.length;ce++)t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,oe.__webglMultisampledFramebuffer);const Q=w.texture.mipmaps;Q&&Q.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglFramebuffer);for(let ce=0;ce<v.length;ce++){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,oe.__webglColorRenderbuffer[ce]);const we=n.get(v[ce]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,we,0)}i.blitFramebuffer(0,0,F,k,0,0,F,k,K,i.NEAREST),c===!0&&(tt.length=0,_t.length=0,tt.push(i.COLOR_ATTACHMENT0+ce),w.depthBuffer&&w.resolveDepthBuffer===!1&&(tt.push(se),_t.push(se),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,_t)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,tt))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),Z)for(let ce=0;ce<v.length;ce++){t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.RENDERBUFFER,oe.__webglColorRenderbuffer[ce]);const we=n.get(v[ce]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.TEXTURE_2D,we,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglMultisampledFramebuffer)}else if(w.depthBuffer&&w.resolveDepthBuffer===!1&&c){const v=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[v])}}}function xt(w){return Math.min(s.maxSamples,w.samples)}function Dt(w){const v=n.get(w);return w.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function N(w){const v=a.render.frame;h.get(w)!==v&&(h.set(w,v),w.update())}function an(w,v){const F=w.colorSpace,k=w.format,K=w.type;return w.isCompressedTexture===!0||w.isVideoTexture===!0||F!==to&&F!==Pi&&($e.getTransfer(F)===it?(k!==hn||K!==xn)&&Fe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ze("WebGLTextures: Unsupported texture color space:",F)),v}function nt(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=O,this.setTexture2D=$,this.setTexture2DArray=te,this.setTexture3D=j,this.setTextureCube=ie,this.rebindTextures=Ne,this.setupRenderTarget=Ue,this.updateRenderTargetMipmap=et,this.updateMultisampleRenderTarget=pt,this.setupDepthRenderbuffer=Ie,this.setupFrameBufferTexture=Ce,this.useMultisampledRTT=Dt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function z_(i,e){function t(n,s=Pi){let r;const a=$e.getTransfer(s);if(n===xn)return i.UNSIGNED_BYTE;if(n===ih)return i.UNSIGNED_SHORT_4_4_4_4;if(n===sh)return i.UNSIGNED_SHORT_5_5_5_1;if(n===v0)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===_0)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===m0)return i.BYTE;if(n===g0)return i.SHORT;if(n===Fr)return i.UNSIGNED_SHORT;if(n===nh)return i.INT;if(n===On)return i.UNSIGNED_INT;if(n===$n)return i.FLOAT;if(n===Qt)return i.HALF_FLOAT;if(n===x0)return i.ALPHA;if(n===M0)return i.RGB;if(n===hn)return i.RGBA;if(n===mi)return i.DEPTH_COMPONENT;if(n===is)return i.DEPTH_STENCIL;if(n===S0)return i.RED;if(n===rh)return i.RED_INTEGER;if(n===os)return i.RG;if(n===ah)return i.RG_INTEGER;if(n===oh)return i.RGBA_INTEGER;if(n===Wa||n===Xa||n===qa||n===Ya)if(a===it)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Wa)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Xa)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===qa)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ya)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Wa)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Xa)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===qa)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ya)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===qc||n===Yc||n===Kc||n===Zc)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===qc)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Yc)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Kc)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Zc)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===$c||n===Jc||n===Qc||n===jc||n===el||n===ja||n===tl)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===$c||n===Jc)return a===it?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Qc)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===jc)return r.COMPRESSED_R11_EAC;if(n===el)return r.COMPRESSED_SIGNED_R11_EAC;if(n===ja)return r.COMPRESSED_RG11_EAC;if(n===tl)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===nl||n===il||n===sl||n===rl||n===al||n===ol||n===cl||n===ll||n===hl||n===ul||n===dl||n===fl||n===pl||n===ml)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===nl)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===il)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===sl)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===rl)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===al)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===ol)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===cl)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===ll)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===hl)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===ul)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===dl)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===fl)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===pl)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ml)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===gl||n===vl||n===_l)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===gl)return a===it?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===vl)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===_l)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===xl||n===Ml||n===eo||n===Sl)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===xl)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Ml)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===eo)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Sl)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===zr?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const B_=`
4420
+ }`,kM=[new P(1,0,0),new P(-1,0,0),new P(0,1,0),new P(0,-1,0),new P(0,0,1),new P(0,0,-1)],HM=[new P(0,-1,0),new P(0,-1,0),new P(0,0,1),new P(0,0,-1),new P(0,-1,0),new P(0,-1,0)],e0=new qe,Nr=new P,Gc=new P;function GM(i,e,t){let n=new Zh;const s=new Ie,r=new Ie,a=new lt,o=new R1,c=new D1,l={},h=t.maxTextureSize,u={[qi]:Ut,[Ut]:qi,[Fn]:Fn},d=new Tt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ie},radius:{value:4}},vertexShader:zM,fragmentShader:BM}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const g=new wt;g.setAttribute("position",new dt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new Qe(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=qr;let p=this.type;this.render=function(A,R,_){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||A.length===0)return;this.type===qm&&(Ae("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=qr);const E=i.getRenderTarget(),C=i.getActiveCubeFace(),D=i.getActiveMipmapLevel(),I=i.state;I.setBlending(ii),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 V=p!==this.type;V&&R.traverse(function(q){q.material&&(Array.isArray(q.material)?q.material.forEach(U=>U.needsUpdate=!0):q.material.needsUpdate=!0)});for(let q=0,U=A.length;q<U;q++){const X=A[q],G=X.shadow;if(G===void 0){Ae("WebGLShadowMap:",X,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;s.copy(G.mapSize);const Z=G.getFrameExtents();s.multiply(Z),r.copy(G.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/Z.x),s.x=r.x*Z.x,G.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/Z.y),s.y=r.y*Z.y,G.mapSize.y=r.y));const te=i.state.buffers.depth.getReversed();if(G.camera._reversedDepth=te,G.map===null||V===!0){if(G.map!==null&&(G.map.depthTexture!==null&&(G.map.depthTexture.dispose(),G.map.depthTexture=null),G.map.dispose()),this.type===Br){if(X.isPointLight){Ae("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}G.map=new fn(s.x,s.y,{format:ms,type:jt,minFilter:At,magFilter:At,generateMipmaps:!1}),G.map.texture.name=X.name+".shadowMap",G.map.depthTexture=new vs(s.x,s.y,Dn),G.map.depthTexture.name=X.name+".shadowMapDepth",G.map.depthTexture.format=Si,G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Ot,G.map.depthTexture.magFilter=Ot}else X.isPointLight?(G.map=new Qf(s.x),G.map.depthTexture=new y1(s.x,Hn)):(G.map=new fn(s.x,s.y),G.map.depthTexture=new vs(s.x,s.y,Hn)),G.map.depthTexture.name=X.name+".shadowMap",G.map.depthTexture.format=Si,this.type===qr?(G.map.depthTexture.compareFunction=te?Xh:Wh,G.map.depthTexture.minFilter=At,G.map.depthTexture.magFilter=At):(G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Ot,G.map.depthTexture.magFilter=Ot);G.camera.updateProjectionMatrix()}const j=G.map.isWebGLCubeRenderTarget?6:1;for(let ie=0;ie<j;ie++){if(G.map.isWebGLCubeRenderTarget)i.setRenderTarget(G.map,ie),i.clear();else{ie===0&&(i.setRenderTarget(G.map),i.clear());const ue=G.getViewport(ie);a.set(r.x*ue.x,r.y*ue.y,r.x*ue.z,r.y*ue.w),I.viewport(a)}if(X.isPointLight){const ue=G.camera,He=G.matrix,Ze=X.distance||ue.far;Ze!==ue.far&&(ue.far=Ze,ue.updateProjectionMatrix()),Nr.setFromMatrixPosition(X.matrixWorld),ue.position.copy(Nr),Gc.copy(ue.position),Gc.add(kM[ie]),ue.up.copy(HM[ie]),ue.lookAt(Gc),ue.updateMatrixWorld(),He.makeTranslation(-Nr.x,-Nr.y,-Nr.z),e0.multiplyMatrices(ue.projectionMatrix,ue.matrixWorldInverse),G._frustum.setFromProjectionMatrix(e0,ue.coordinateSystem,ue.reversedDepth)}else G.updateMatrices(X);n=G.getFrustum(),M(R,_,G.camera,X,this.type)}G.isPointLightShadow!==!0&&this.type===Br&&b(G,_),G.needsUpdate=!1}p=this.type,m.needsUpdate=!1,i.setRenderTarget(E,C,D)};function b(A,R){const _=e.update(x);d.defines.VSM_SAMPLES!==A.blurSamples&&(d.defines.VSM_SAMPLES=A.blurSamples,f.defines.VSM_SAMPLES=A.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),A.mapPass===null&&(A.mapPass=new fn(s.x,s.y,{format:ms,type:jt})),d.uniforms.shadow_pass.value=A.map.depthTexture,d.uniforms.resolution.value=A.mapSize,d.uniforms.radius.value=A.radius,i.setRenderTarget(A.mapPass),i.clear(),i.renderBufferDirect(R,null,_,d,x,null),f.uniforms.shadow_pass.value=A.mapPass.texture,f.uniforms.resolution.value=A.mapSize,f.uniforms.radius.value=A.radius,i.setRenderTarget(A.map),i.clear(),i.renderBufferDirect(R,null,_,f,x,null)}function w(A,R,_,E){let C=null;const D=_.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(D!==void 0)C=D;else if(C=_.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=C.uuid,V=R.uuid;let q=l[I];q===void 0&&(q={},l[I]=q);let U=q[V];U===void 0&&(U=C.clone(),q[V]=U,R.addEventListener("dispose",S)),C=U}if(C.visible=R.visible,C.wireframe=R.wireframe,E===Br?C.side=R.shadowSide!==null?R.shadowSide:R.side:C.side=R.shadowSide!==null?R.shadowSide:u[R.side],C.alphaMap=R.alphaMap,C.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,C.map=R.map,C.clipShadows=R.clipShadows,C.clippingPlanes=R.clippingPlanes,C.clipIntersection=R.clipIntersection,C.displacementMap=R.displacementMap,C.displacementScale=R.displacementScale,C.displacementBias=R.displacementBias,C.wireframeLinewidth=R.wireframeLinewidth,C.linewidth=R.linewidth,_.isPointLight===!0&&C.isMeshDistanceMaterial===!0){const I=i.properties.get(C);I.light=_}return C}function M(A,R,_,E,C){if(A.visible===!1)return;if(A.layers.test(R.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&C===Br)&&(!A.frustumCulled||n.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,A.matrixWorld);const V=e.update(A),q=A.material;if(Array.isArray(q)){const U=V.groups;for(let X=0,G=U.length;X<G;X++){const Z=U[X],te=q[Z.materialIndex];if(te&&te.visible){const j=w(A,te,E,C);A.onBeforeShadow(i,A,R,_,V,j,Z),i.renderBufferDirect(_,null,V,j,A,Z),A.onAfterShadow(i,A,R,_,V,j,Z)}}}else if(q.visible){const U=w(A,q,E,C);A.onBeforeShadow(i,A,R,_,V,U,null),i.renderBufferDirect(_,null,V,U,A,null),A.onAfterShadow(i,A,R,_,V,U,null)}}const I=A.children;for(let V=0,q=I.length;V<q;V++)M(I[V],R,_,E,C)}function S(A){A.target.removeEventListener("dispose",S);for(const _ in l){const E=l[_],C=A.target.uuid;C in E&&(E[C].dispose(),delete E[C])}}}function VM(i,e){function t(){let L=!1;const ae=new lt;let J=null;const he=new lt(0,0,0,0);return{setMask:function(ge){J!==ge&&!L&&(i.colorMask(ge,ge,ge,ge),J=ge)},setLocked:function(ge){L=ge},setClear:function(ge,ee,we,ye,St){St===!0&&(ge*=ye,ee*=ye,we*=ye),ae.set(ge,ee,we,ye),he.equals(ae)===!1&&(i.clearColor(ge,ee,we,ye),he.copy(ae))},reset:function(){L=!1,J=null,he.set(-1,0,0,0)}}}function n(){let L=!1,ae=!1,J=null,he=null,ge=null;return{setReversed:function(ee){if(ae!==ee){const we=e.get("EXT_clip_control");ee?we.clipControlEXT(we.LOWER_LEFT_EXT,we.ZERO_TO_ONE_EXT):we.clipControlEXT(we.LOWER_LEFT_EXT,we.NEGATIVE_ONE_TO_ONE_EXT),ae=ee;const ye=ge;ge=null,this.setClear(ye)}},getReversed:function(){return ae},setTest:function(ee){ee?ne(i.DEPTH_TEST):z(i.DEPTH_TEST)},setMask:function(ee){J!==ee&&!L&&(i.depthMask(ee),J=ee)},setFunc:function(ee){if(ae&&(ee=Rg[ee]),he!==ee){switch(ee){case xl:i.depthFunc(i.NEVER);break;case Ml:i.depthFunc(i.ALWAYS);break;case yl:i.depthFunc(i.LESS);break;case hr:i.depthFunc(i.LEQUAL);break;case Sl:i.depthFunc(i.EQUAL);break;case El:i.depthFunc(i.GEQUAL);break;case bl:i.depthFunc(i.GREATER);break;case Al:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}he=ee}},setLocked:function(ee){L=ee},setClear:function(ee){ge!==ee&&(ge=ee,ae&&(ee=1-ee),i.clearDepth(ee))},reset:function(){L=!1,J=null,he=null,ge=null,ae=!1}}}function s(){let L=!1,ae=null,J=null,he=null,ge=null,ee=null,we=null,ye=null,St=null;return{setTest:function(ft){L||(ft?ne(i.STENCIL_TEST):z(i.STENCIL_TEST))},setMask:function(ft){ae!==ft&&!L&&(i.stencilMask(ft),ae=ft)},setFunc:function(ft,Vn,Wn){(J!==ft||he!==Vn||ge!==Wn)&&(i.stencilFunc(ft,Vn,Wn),J=ft,he=Vn,ge=Wn)},setOp:function(ft,Vn,Wn){(ee!==ft||we!==Vn||ye!==Wn)&&(i.stencilOp(ft,Vn,Wn),ee=ft,we=Vn,ye=Wn)},setLocked:function(ft){L=ft},setClear:function(ft){St!==ft&&(i.clearStencil(ft),St=ft)},reset:function(){L=!1,ae=null,J=null,he=null,ge=null,ee=null,we=null,ye=null,St=null}}}const r=new t,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,b=null,w=null,M=null,S=null,A=null,R=null,_=new ve(0,0,0),E=0,C=!1,D=null,I=null,V=null,q=null,U=null;const X=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let G=!1,Z=0;const te=i.getParameter(i.VERSION);te.indexOf("WebGL")!==-1?(Z=parseFloat(/^WebGL (\d)/.exec(te)[1]),G=Z>=1):te.indexOf("OpenGL ES")!==-1&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(te)[1]),G=Z>=2);let j=null,ie={};const ue=i.getParameter(i.SCISSOR_BOX),He=i.getParameter(i.VIEWPORT),Ze=new lt().fromArray(ue),ke=new lt().fromArray(He);function Y(L,ae,J,he){const ge=new Uint8Array(4),ee=i.createTexture();i.bindTexture(L,ee),i.texParameteri(L,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(L,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let we=0;we<J;we++)L===i.TEXTURE_3D||L===i.TEXTURE_2D_ARRAY?i.texImage3D(ae,0,i.RGBA,1,1,he,0,i.RGBA,i.UNSIGNED_BYTE,ge):i.texImage2D(ae+we,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,ge);return ee}const re={};re[i.TEXTURE_2D]=Y(i.TEXTURE_2D,i.TEXTURE_2D,1),re[i.TEXTURE_CUBE_MAP]=Y(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[i.TEXTURE_2D_ARRAY]=Y(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),re[i.TEXTURE_3D]=Y(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ne(i.DEPTH_TEST),a.setFunc(hr),tt(!1),nt(Nu),ne(i.CULL_FACE),Ue(ii);function ne(L){h[L]!==!0&&(i.enable(L),h[L]=!0)}function z(L){h[L]!==!1&&(i.disable(L),h[L]=!1)}function be(L,ae){return d[L]!==ae?(i.bindFramebuffer(L,ae),d[L]=ae,L===i.DRAW_FRAMEBUFFER&&(d[i.FRAMEBUFFER]=ae),L===i.FRAMEBUFFER&&(d[i.DRAW_FRAMEBUFFER]=ae),!0):!1}function Pe(L,ae){let J=g,he=!1;if(L){J=f.get(ae),J===void 0&&(J=[],f.set(ae,J));const ge=L.textures;if(J.length!==ge.length||J[0]!==i.COLOR_ATTACHMENT0){for(let ee=0,we=ge.length;ee<we;ee++)J[ee]=i.COLOR_ATTACHMENT0+ee;J.length=ge.length,he=!0}}else J[0]!==i.BACK&&(J[0]=i.BACK,he=!0);he&&i.drawBuffers(J)}function Te(L){return x!==L?(i.useProgram(L),x=L,!0):!1}const xe={[as]:i.FUNC_ADD,[Km]:i.FUNC_SUBTRACT,[$m]:i.FUNC_REVERSE_SUBTRACT};xe[Zm]=i.MIN,xe[Jm]=i.MAX;const Ne={[Qm]:i.ZERO,[jm]:i.ONE,[eg]:i.SRC_COLOR,[vl]:i.SRC_ALPHA,[ag]:i.SRC_ALPHA_SATURATE,[sg]:i.DST_COLOR,[ng]:i.DST_ALPHA,[tg]:i.ONE_MINUS_SRC_COLOR,[_l]:i.ONE_MINUS_SRC_ALPHA,[rg]:i.ONE_MINUS_DST_COLOR,[ig]:i.ONE_MINUS_DST_ALPHA,[og]:i.CONSTANT_COLOR,[cg]:i.ONE_MINUS_CONSTANT_COLOR,[lg]:i.CONSTANT_ALPHA,[hg]:i.ONE_MINUS_CONSTANT_ALPHA};function Ue(L,ae,J,he,ge,ee,we,ye,St,ft){if(L===ii){m===!0&&(z(i.BLEND),m=!1);return}if(m===!1&&(ne(i.BLEND),m=!0),L!==Ym){if(L!==p||ft!==C){if((b!==as||S!==as)&&(i.blendEquation(i.FUNC_ADD),b=as,S=as),ft)switch(L){case ir:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ai:i.blendFunc(i.ONE,i.ONE);break;case Uu:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Ou:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:ze("WebGLState: Invalid blending: ",L);break}else switch(L){case ir:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ai:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case Uu:ze("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Ou:ze("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ze("WebGLState: Invalid blending: ",L);break}w=null,M=null,A=null,R=null,_.set(0,0,0),E=0,p=L,C=ft}return}ge=ge||ae,ee=ee||J,we=we||he,(ae!==b||ge!==S)&&(i.blendEquationSeparate(xe[ae],xe[ge]),b=ae,S=ge),(J!==w||he!==M||ee!==A||we!==R)&&(i.blendFuncSeparate(Ne[J],Ne[he],Ne[ee],Ne[we]),w=J,M=he,A=ee,R=we),(ye.equals(_)===!1||St!==E)&&(i.blendColor(ye.r,ye.g,ye.b,St),_.copy(ye),E=St),p=L,C=!1}function Oe(L,ae){L.side===Fn?z(i.CULL_FACE):ne(i.CULL_FACE);let J=L.side===Ut;ae&&(J=!J),tt(J),L.blending===ir&&L.transparent===!1?Ue(ii):Ue(L.blending,L.blendEquation,L.blendSrc,L.blendDst,L.blendEquationAlpha,L.blendSrcAlpha,L.blendDstAlpha,L.blendColor,L.blendAlpha,L.premultipliedAlpha),a.setFunc(L.depthFunc),a.setTest(L.depthTest),a.setMask(L.depthWrite),r.setMask(L.colorWrite);const he=L.stencilWrite;o.setTest(he),he&&(o.setMask(L.stencilWriteMask),o.setFunc(L.stencilFunc,L.stencilRef,L.stencilFuncMask),o.setOp(L.stencilFail,L.stencilZFail,L.stencilZPass)),gt(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?ne(i.SAMPLE_ALPHA_TO_COVERAGE):z(i.SAMPLE_ALPHA_TO_COVERAGE)}function tt(L){D!==L&&(L?i.frontFace(i.CW):i.frontFace(i.CCW),D=L)}function nt(L){L!==Wm?(ne(i.CULL_FACE),L!==I&&(L===Nu?i.cullFace(i.BACK):L===Xm?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):z(i.CULL_FACE),I=L}function Mt(L){L!==V&&(G&&i.lineWidth(L),V=L)}function gt(L,ae,J){L?(ne(i.POLYGON_OFFSET_FILL),(q!==ae||U!==J)&&(q=ae,U=J,a.getReversed()&&(ae=-ae),i.polygonOffset(ae,J))):z(i.POLYGON_OFFSET_FILL)}function yt(L){L?ne(i.SCISSOR_TEST):z(i.SCISSOR_TEST)}function It(L){L===void 0&&(L=i.TEXTURE0+X-1),j!==L&&(i.activeTexture(L),j=L)}function N(L,ae,J){J===void 0&&(j===null?J=i.TEXTURE0+X-1:J=j);let he=ie[J];he===void 0&&(he={type:void 0,texture:void 0},ie[J]=he),(he.type!==L||he.texture!==ae)&&(j!==J&&(i.activeTexture(J),j=J),i.bindTexture(L,ae||re[L]),he.type=L,he.texture=ae)}function cn(){const L=ie[j];L!==void 0&&L.type!==void 0&&(i.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function it(){try{i.compressedTexImage2D(...arguments)}catch(L){ze("WebGLState:",L)}}function T(){try{i.compressedTexImage3D(...arguments)}catch(L){ze("WebGLState:",L)}}function v(){try{i.texSubImage2D(...arguments)}catch(L){ze("WebGLState:",L)}}function F(){try{i.texSubImage3D(...arguments)}catch(L){ze("WebGLState:",L)}}function H(){try{i.compressedTexSubImage2D(...arguments)}catch(L){ze("WebGLState:",L)}}function K(){try{i.compressedTexSubImage3D(...arguments)}catch(L){ze("WebGLState:",L)}}function se(){try{i.texStorage2D(...arguments)}catch(L){ze("WebGLState:",L)}}function oe(){try{i.texStorage3D(...arguments)}catch(L){ze("WebGLState:",L)}}function $(){try{i.texImage2D(...arguments)}catch(L){ze("WebGLState:",L)}}function Q(){try{i.texImage3D(...arguments)}catch(L){ze("WebGLState:",L)}}function ce(L){return u[L]!==void 0?u[L]:i.getParameter(L)}function Re(L,ae){u[L]!==ae&&(i.pixelStorei(L,ae),u[L]=ae)}function de(L){Ze.equals(L)===!1&&(i.scissor(L.x,L.y,L.z,L.w),Ze.copy(L))}function le(L){ke.equals(L)===!1&&(i.viewport(L.x,L.y,L.z,L.w),ke.copy(L))}function Le(L,ae){let J=l.get(ae);J===void 0&&(J=new WeakMap,l.set(ae,J));let he=J.get(L);he===void 0&&(he=i.getUniformBlockIndex(ae,L.name),J.set(L,he))}function Fe(L,ae){const he=l.get(ae).get(L);c.get(ae)!==he&&(i.uniformBlockBinding(ae,he,L.__bindingPointIndex),c.set(ae,he))}function Ge(){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,ie={},d={},f=new WeakMap,g=[],x=null,m=!1,p=null,b=null,w=null,M=null,S=null,A=null,R=null,_=new ve(0,0,0),E=0,C=!1,D=null,I=null,V=null,q=null,U=null,Ze.set(0,0,i.canvas.width,i.canvas.height),ke.set(0,0,i.canvas.width,i.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:ne,disable:z,bindFramebuffer:be,drawBuffers:Pe,useProgram:Te,setBlending:Ue,setMaterial:Oe,setFlipSided:tt,setCullFace:nt,setLineWidth:Mt,setPolygonOffset:gt,setScissorTest:yt,activeTexture:It,bindTexture:N,unbindTexture:cn,compressedTexImage2D:it,compressedTexImage3D:T,texImage2D:$,texImage3D:Q,pixelStorei:Re,getParameter:ce,updateUBOMapping:Le,uniformBlockBinding:Fe,texStorage2D:se,texStorage3D:oe,texSubImage2D:v,texSubImage3D:F,compressedTexSubImage2D:H,compressedTexSubImage3D:K,scissor:de,viewport:le,reset:Ge}}function WM(i,e,t,n,s,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ie,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(T,v){return g?new OffscreenCanvas(T,v):sa("canvas")}function m(T,v,F){let H=1;const K=it(T);if((K.width>F||K.height>F)&&(H=F/Math.max(K.width,K.height)),H<1)if(typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&T instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&T instanceof ImageBitmap||typeof VideoFrame<"u"&&T instanceof VideoFrame){const se=Math.floor(H*K.width),oe=Math.floor(H*K.height);d===void 0&&(d=x(se,oe));const $=v?x(se,oe):d;return $.width=se,$.height=oe,$.getContext("2d").drawImage(T,0,0,se,oe),Ae("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+se+"x"+oe+")."),$}else return"data"in T&&Ae("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),T;return T}function p(T){return T.generateMipmaps}function b(T){i.generateMipmap(T)}function w(T){return T.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?i.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function M(T,v,F,H,K,se=!1){if(T!==null){if(i[T]!==void 0)return i[T];Ae("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let oe;H&&(oe=e.get("EXT_texture_norm16"),oe||Ae("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let $=v;if(v===i.RED&&(F===i.FLOAT&&($=i.R32F),F===i.HALF_FLOAT&&($=i.R16F),F===i.UNSIGNED_BYTE&&($=i.R8),F===i.UNSIGNED_SHORT&&oe&&($=oe.R16_EXT),F===i.SHORT&&oe&&($=oe.R16_SNORM_EXT)),v===i.RED_INTEGER&&(F===i.UNSIGNED_BYTE&&($=i.R8UI),F===i.UNSIGNED_SHORT&&($=i.R16UI),F===i.UNSIGNED_INT&&($=i.R32UI),F===i.BYTE&&($=i.R8I),F===i.SHORT&&($=i.R16I),F===i.INT&&($=i.R32I)),v===i.RG&&(F===i.FLOAT&&($=i.RG32F),F===i.HALF_FLOAT&&($=i.RG16F),F===i.UNSIGNED_BYTE&&($=i.RG8),F===i.UNSIGNED_SHORT&&oe&&($=oe.RG16_EXT),F===i.SHORT&&oe&&($=oe.RG16_SNORM_EXT)),v===i.RG_INTEGER&&(F===i.UNSIGNED_BYTE&&($=i.RG8UI),F===i.UNSIGNED_SHORT&&($=i.RG16UI),F===i.UNSIGNED_INT&&($=i.RG32UI),F===i.BYTE&&($=i.RG8I),F===i.SHORT&&($=i.RG16I),F===i.INT&&($=i.RG32I)),v===i.RGB_INTEGER&&(F===i.UNSIGNED_BYTE&&($=i.RGB8UI),F===i.UNSIGNED_SHORT&&($=i.RGB16UI),F===i.UNSIGNED_INT&&($=i.RGB32UI),F===i.BYTE&&($=i.RGB8I),F===i.SHORT&&($=i.RGB16I),F===i.INT&&($=i.RGB32I)),v===i.RGBA_INTEGER&&(F===i.UNSIGNED_BYTE&&($=i.RGBA8UI),F===i.UNSIGNED_SHORT&&($=i.RGBA16UI),F===i.UNSIGNED_INT&&($=i.RGBA32UI),F===i.BYTE&&($=i.RGBA8I),F===i.SHORT&&($=i.RGBA16I),F===i.INT&&($=i.RGBA32I)),v===i.RGB&&(F===i.UNSIGNED_SHORT&&oe&&($=oe.RGB16_EXT),F===i.SHORT&&oe&&($=oe.RGB16_SNORM_EXT),F===i.UNSIGNED_INT_5_9_9_9_REV&&($=i.RGB9_E5),F===i.UNSIGNED_INT_10F_11F_11F_REV&&($=i.R11F_G11F_B10F)),v===i.RGBA){const Q=se?Po:Je.getTransfer(K);F===i.FLOAT&&($=i.RGBA32F),F===i.HALF_FLOAT&&($=i.RGBA16F),F===i.UNSIGNED_BYTE&&($=Q===st?i.SRGB8_ALPHA8:i.RGBA8),F===i.UNSIGNED_SHORT&&oe&&($=oe.RGBA16_EXT),F===i.SHORT&&oe&&($=oe.RGBA16_SNORM_EXT),F===i.UNSIGNED_SHORT_4_4_4_4&&($=i.RGBA4),F===i.UNSIGNED_SHORT_5_5_5_1&&($=i.RGB5_A1)}return($===i.R16F||$===i.R32F||$===i.RG16F||$===i.RG32F||$===i.RGBA16F||$===i.RGBA32F)&&e.get("EXT_color_buffer_float"),$}function S(T,v){let F;return T?v===null||v===Hn||v===na?F=i.DEPTH24_STENCIL8:v===Dn?F=i.DEPTH32F_STENCIL8:v===ta&&(F=i.DEPTH24_STENCIL8,Ae("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):v===null||v===Hn||v===na?F=i.DEPTH_COMPONENT24:v===Dn?F=i.DEPTH_COMPONENT32F:v===ta&&(F=i.DEPTH_COMPONENT16),F}function A(T,v){return p(T)===!0||T.isFramebufferTexture&&T.minFilter!==Ot&&T.minFilter!==At?Math.log2(Math.max(v.width,v.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?v.mipmaps.length:1}function R(T){const v=T.target;v.removeEventListener("dispose",R),E(v),v.isVideoTexture&&h.delete(v),v.isHTMLTexture&&u.delete(v)}function _(T){const v=T.target;v.removeEventListener("dispose",_),D(v)}function E(T){const v=n.get(T);if(v.__webglInit===void 0)return;const F=T.source,H=f.get(F);if(H){const K=H[v.__cacheKey];K.usedTimes--,K.usedTimes===0&&C(T),Object.keys(H).length===0&&f.delete(F)}n.remove(T)}function C(T){const v=n.get(T);i.deleteTexture(v.__webglTexture);const F=T.source,H=f.get(F);delete H[v.__cacheKey],a.memory.textures--}function D(T){const v=n.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),n.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(v.__webglFramebuffer[H]))for(let K=0;K<v.__webglFramebuffer[H].length;K++)i.deleteFramebuffer(v.__webglFramebuffer[H][K]);else i.deleteFramebuffer(v.__webglFramebuffer[H]);v.__webglDepthbuffer&&i.deleteRenderbuffer(v.__webglDepthbuffer[H])}else{if(Array.isArray(v.__webglFramebuffer))for(let H=0;H<v.__webglFramebuffer.length;H++)i.deleteFramebuffer(v.__webglFramebuffer[H]);else i.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer&&i.deleteRenderbuffer(v.__webglDepthbuffer),v.__webglMultisampledFramebuffer&&i.deleteFramebuffer(v.__webglMultisampledFramebuffer),v.__webglColorRenderbuffer)for(let H=0;H<v.__webglColorRenderbuffer.length;H++)v.__webglColorRenderbuffer[H]&&i.deleteRenderbuffer(v.__webglColorRenderbuffer[H]);v.__webglDepthRenderbuffer&&i.deleteRenderbuffer(v.__webglDepthRenderbuffer)}const F=T.textures;for(let H=0,K=F.length;H<K;H++){const se=n.get(F[H]);se.__webglTexture&&(i.deleteTexture(se.__webglTexture),a.memory.textures--),n.remove(F[H])}n.remove(T)}let I=0;function V(){I=0}function q(){return I}function U(T){I=T}function X(){const T=I;return T>=s.maxTextures&&Ae("WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+s.maxTextures),I+=1,T}function G(T){const v=[];return v.push(T.wrapS),v.push(T.wrapT),v.push(T.wrapR||0),v.push(T.magFilter),v.push(T.minFilter),v.push(T.anisotropy),v.push(T.internalFormat),v.push(T.format),v.push(T.type),v.push(T.generateMipmaps),v.push(T.premultiplyAlpha),v.push(T.flipY),v.push(T.unpackAlignment),v.push(T.colorSpace),v.join()}function Z(T,v){const F=n.get(T);if(T.isVideoTexture&&N(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&F.__version!==T.version){const H=T.image;if(H===null)Ae("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Ae("WebGLRenderer: Texture marked for update but image is incomplete");else{z(F,T,v);return}}else T.isExternalTexture&&(F.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,F.__webglTexture,i.TEXTURE0+v)}function te(T,v){const F=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&F.__version!==T.version){z(F,T,v);return}else T.isExternalTexture&&(F.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,F.__webglTexture,i.TEXTURE0+v)}function j(T,v){const F=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&F.__version!==T.version){z(F,T,v);return}t.bindTexture(i.TEXTURE_3D,F.__webglTexture,i.TEXTURE0+v)}function ie(T,v){const F=n.get(T);if(T.isCubeDepthTexture!==!0&&T.version>0&&F.__version!==T.version){be(F,T,v);return}t.bindTexture(i.TEXTURE_CUBE_MAP,F.__webglTexture,i.TEXTURE0+v)}const ue={[Ao]:i.REPEAT,[rn]:i.CLAMP_TO_EDGE,[wl]:i.MIRRORED_REPEAT},He={[Ot]:i.NEAREST,[pg]:i.NEAREST_MIPMAP_NEAREST,[Ma]:i.NEAREST_MIPMAP_LINEAR,[At]:i.LINEAR,[ac]:i.LINEAR_MIPMAP_NEAREST,[hs]:i.LINEAR_MIPMAP_LINEAR},Ze={[_g]:i.NEVER,[Eg]:i.ALWAYS,[xg]:i.LESS,[Wh]:i.LEQUAL,[Mg]:i.EQUAL,[Xh]:i.GEQUAL,[yg]:i.GREATER,[Sg]:i.NOTEQUAL};function ke(T,v){if(v.type===Dn&&e.has("OES_texture_float_linear")===!1&&(v.magFilter===At||v.magFilter===ac||v.magFilter===Ma||v.magFilter===hs||v.minFilter===At||v.minFilter===ac||v.minFilter===Ma||v.minFilter===hs)&&Ae("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(T,i.TEXTURE_WRAP_S,ue[v.wrapS]),i.texParameteri(T,i.TEXTURE_WRAP_T,ue[v.wrapT]),(T===i.TEXTURE_3D||T===i.TEXTURE_2D_ARRAY)&&i.texParameteri(T,i.TEXTURE_WRAP_R,ue[v.wrapR]),i.texParameteri(T,i.TEXTURE_MAG_FILTER,He[v.magFilter]),i.texParameteri(T,i.TEXTURE_MIN_FILTER,He[v.minFilter]),v.compareFunction&&(i.texParameteri(T,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(T,i.TEXTURE_COMPARE_FUNC,Ze[v.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===Ot||v.minFilter!==Ma&&v.minFilter!==hs||v.type===Dn&&e.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||n.get(v).__currentAnisotropy){const F=e.get("EXT_texture_filter_anisotropic");i.texParameterf(T,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,s.getMaxAnisotropy())),n.get(v).__currentAnisotropy=v.anisotropy}}}function Y(T,v){let F=!1;T.__webglInit===void 0&&(T.__webglInit=!0,v.addEventListener("dispose",R));const H=v.source;let K=f.get(H);K===void 0&&(K={},f.set(H,K));const se=G(v);if(se!==T.__cacheKey){K[se]===void 0&&(K[se]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,F=!0),K[se].usedTimes++;const oe=K[T.__cacheKey];oe!==void 0&&(K[T.__cacheKey].usedTimes--,oe.usedTimes===0&&C(v)),T.__cacheKey=se,T.__webglTexture=K[se].texture}return F}function re(T,v,F){return Math.floor(Math.floor(T/F)/v)}function ne(T,v,F,H){const se=T.updateRanges;if(se.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,v.width,v.height,F,H,v.data);else{se.sort((Re,de)=>Re.start-de.start);let oe=0;for(let Re=1;Re<se.length;Re++){const de=se[oe],le=se[Re],Le=de.start+de.count,Fe=re(le.start,v.width,4),Ge=re(de.start,v.width,4);le.start<=Le+1&&Fe===Ge&&re(le.start+le.count-1,v.width,4)===Fe?de.count=Math.max(de.count,le.start+le.count-de.start):(++oe,se[oe]=le)}se.length=oe+1;const $=t.getParameter(i.UNPACK_ROW_LENGTH),Q=t.getParameter(i.UNPACK_SKIP_PIXELS),ce=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,v.width);for(let Re=0,de=se.length;Re<de;Re++){const le=se[Re],Le=Math.floor(le.start/4),Fe=Math.ceil(le.count/4),Ge=Le%v.width,L=Math.floor(Le/v.width),ae=Fe,J=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,Ge),t.pixelStorei(i.UNPACK_SKIP_ROWS,L),t.texSubImage2D(i.TEXTURE_2D,0,Ge,L,ae,J,F,H,v.data)}T.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,$),t.pixelStorei(i.UNPACK_SKIP_PIXELS,Q),t.pixelStorei(i.UNPACK_SKIP_ROWS,ce)}}function z(T,v,F){let H=i.TEXTURE_2D;(v.isDataArrayTexture||v.isCompressedArrayTexture)&&(H=i.TEXTURE_2D_ARRAY),v.isData3DTexture&&(H=i.TEXTURE_3D);const K=Y(T,v),se=v.source;t.bindTexture(H,T.__webglTexture,i.TEXTURE0+F);const oe=n.get(se);if(se.version!==oe.__version||K===!0){if(t.activeTexture(i.TEXTURE0+F),(typeof ImageBitmap<"u"&&v.image instanceof ImageBitmap)===!1){const J=Je.getPrimaries(Je.workingColorSpace),he=v.colorSpace===Hi?null:Je.getPrimaries(v.colorSpace),ge=v.colorSpace===Hi||J===he?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,v.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,ge)}t.pixelStorei(i.UNPACK_ALIGNMENT,v.unpackAlignment);let Q=m(v.image,!1,s.maxTextureSize);Q=cn(v,Q);const ce=r.convert(v.format,v.colorSpace),Re=r.convert(v.type);let de=M(v.internalFormat,ce,Re,v.normalized,v.colorSpace,v.isVideoTexture);ke(H,v);let le;const Le=v.mipmaps,Fe=v.isVideoTexture!==!0,Ge=oe.__version===void 0||K===!0,L=se.dataReady,ae=A(v,Q);if(v.isDepthTexture)de=S(v.format===us,v.type),Ge&&(Fe?t.texStorage2D(i.TEXTURE_2D,1,de,Q.width,Q.height):t.texImage2D(i.TEXTURE_2D,0,de,Q.width,Q.height,0,ce,Re,null));else if(v.isDataTexture)if(Le.length>0){Fe&&Ge&&t.texStorage2D(i.TEXTURE_2D,ae,de,Le[0].width,Le[0].height);for(let J=0,he=Le.length;J<he;J++)le=Le[J],Fe?L&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,le.width,le.height,ce,Re,le.data):t.texImage2D(i.TEXTURE_2D,J,de,le.width,le.height,0,ce,Re,le.data);v.generateMipmaps=!1}else Fe?(Ge&&t.texStorage2D(i.TEXTURE_2D,ae,de,Q.width,Q.height),L&&ne(v,Q,ce,Re)):t.texImage2D(i.TEXTURE_2D,0,de,Q.width,Q.height,0,ce,Re,Q.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){Fe&&Ge&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ae,de,Le[0].width,Le[0].height,Q.depth);for(let J=0,he=Le.length;J<he;J++)if(le=Le[J],v.format!==an)if(ce!==null)if(Fe){if(L)if(v.layerUpdates.size>0){const ge=Pd(le.width,le.height,v.format,v.type);for(const ee of v.layerUpdates){const we=le.data.subarray(ee*ge/le.data.BYTES_PER_ELEMENT,(ee+1)*ge/le.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,ee,le.width,le.height,1,ce,we)}v.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,le.width,le.height,Q.depth,ce,le.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,J,de,le.width,le.height,Q.depth,0,le.data,0,0);else Ae("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Fe?L&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,le.width,le.height,Q.depth,ce,Re,le.data):t.texImage3D(i.TEXTURE_2D_ARRAY,J,de,le.width,le.height,Q.depth,0,ce,Re,le.data)}else{Fe&&Ge&&t.texStorage2D(i.TEXTURE_2D,ae,de,Le[0].width,Le[0].height);for(let J=0,he=Le.length;J<he;J++)le=Le[J],v.format!==an?ce!==null?Fe?L&&t.compressedTexSubImage2D(i.TEXTURE_2D,J,0,0,le.width,le.height,ce,le.data):t.compressedTexImage2D(i.TEXTURE_2D,J,de,le.width,le.height,0,le.data):Ae("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Fe?L&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,le.width,le.height,ce,Re,le.data):t.texImage2D(i.TEXTURE_2D,J,de,le.width,le.height,0,ce,Re,le.data)}else if(v.isDataArrayTexture)if(Fe){if(Ge&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ae,de,Q.width,Q.height,Q.depth),L)if(v.layerUpdates.size>0){const J=Pd(Q.width,Q.height,v.format,v.type);for(const he of v.layerUpdates){const ge=Q.data.subarray(he*J/Q.data.BYTES_PER_ELEMENT,(he+1)*J/Q.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,he,Q.width,Q.height,1,ce,Re,ge)}v.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,ce,Re,Q.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,de,Q.width,Q.height,Q.depth,0,ce,Re,Q.data);else if(v.isData3DTexture)Fe?(Ge&&t.texStorage3D(i.TEXTURE_3D,ae,de,Q.width,Q.height,Q.depth),L&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,ce,Re,Q.data)):t.texImage3D(i.TEXTURE_3D,0,de,Q.width,Q.height,Q.depth,0,ce,Re,Q.data);else if(v.isFramebufferTexture){if(Ge)if(Fe)t.texStorage2D(i.TEXTURE_2D,ae,de,Q.width,Q.height);else{let J=Q.width,he=Q.height;for(let ge=0;ge<ae;ge++)t.texImage2D(i.TEXTURE_2D,ge,de,J,he,0,ce,Re,null),J>>=1,he>>=1}}else if(v.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(v),J.onpaint=he=>{const ge=he.changedElements;for(const ee of u)ge.includes(ee.image)&&(ee.needsUpdate=!0)},J.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,Q);else{const ge=i.RGBA,ee=i.RGBA,we=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,ge,ee,we,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(Le.length>0){if(Fe&&Ge){const J=it(Le[0]);t.texStorage2D(i.TEXTURE_2D,ae,de,J.width,J.height)}for(let J=0,he=Le.length;J<he;J++)le=Le[J],Fe?L&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,ce,Re,le):t.texImage2D(i.TEXTURE_2D,J,de,ce,Re,le);v.generateMipmaps=!1}else if(Fe){if(Ge){const J=it(Q);t.texStorage2D(i.TEXTURE_2D,ae,de,J.width,J.height)}L&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,ce,Re,Q)}else t.texImage2D(i.TEXTURE_2D,0,de,ce,Re,Q);p(v)&&b(H),oe.__version=se.version,v.onUpdate&&v.onUpdate(v)}T.__version=v.version}function be(T,v,F){if(v.image.length!==6)return;const H=Y(T,v),K=v.source;t.bindTexture(i.TEXTURE_CUBE_MAP,T.__webglTexture,i.TEXTURE0+F);const se=n.get(K);if(K.version!==se.__version||H===!0){t.activeTexture(i.TEXTURE0+F);const oe=Je.getPrimaries(Je.workingColorSpace),$=v.colorSpace===Hi?null:Je.getPrimaries(v.colorSpace),Q=v.colorSpace===Hi||oe===$?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,v.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),t.pixelStorei(i.UNPACK_ALIGNMENT,v.unpackAlignment),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);const ce=v.isCompressedTexture||v.image[0].isCompressedTexture,Re=v.image[0]&&v.image[0].isDataTexture,de=[];for(let ee=0;ee<6;ee++)!ce&&!Re?de[ee]=m(v.image[ee],!0,s.maxCubemapSize):de[ee]=Re?v.image[ee].image:v.image[ee],de[ee]=cn(v,de[ee]);const le=de[0],Le=r.convert(v.format,v.colorSpace),Fe=r.convert(v.type),Ge=M(v.internalFormat,Le,Fe,v.normalized,v.colorSpace),L=v.isVideoTexture!==!0,ae=se.__version===void 0||H===!0,J=K.dataReady;let he=A(v,le);ke(i.TEXTURE_CUBE_MAP,v);let ge;if(ce){L&&ae&&t.texStorage2D(i.TEXTURE_CUBE_MAP,he,Ge,le.width,le.height);for(let ee=0;ee<6;ee++){ge=de[ee].mipmaps;for(let we=0;we<ge.length;we++){const ye=ge[we];v.format!==an?Le!==null?L?J&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we,0,0,ye.width,ye.height,Le,ye.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we,Ge,ye.width,ye.height,0,ye.data):Ae("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we,0,0,ye.width,ye.height,Le,Fe,ye.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we,Ge,ye.width,ye.height,0,Le,Fe,ye.data)}}}else{if(ge=v.mipmaps,L&&ae){ge.length>0&&he++;const ee=it(de[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,he,Ge,ee.width,ee.height)}for(let ee=0;ee<6;ee++)if(Re){L?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,de[ee].width,de[ee].height,Le,Fe,de[ee].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,Ge,de[ee].width,de[ee].height,0,Le,Fe,de[ee].data);for(let we=0;we<ge.length;we++){const St=ge[we].image[ee].image;L?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we+1,0,0,St.width,St.height,Le,Fe,St.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we+1,Ge,St.width,St.height,0,Le,Fe,St.data)}}else{L?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,Le,Fe,de[ee]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,Ge,Le,Fe,de[ee]);for(let we=0;we<ge.length;we++){const ye=ge[we];L?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we+1,0,0,Le,Fe,ye.image[ee]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we+1,Ge,Le,Fe,ye.image[ee])}}}p(v)&&b(i.TEXTURE_CUBE_MAP),se.__version=K.version,v.onUpdate&&v.onUpdate(v)}T.__version=v.version}function Pe(T,v,F,H,K,se){const oe=r.convert(F.format,F.colorSpace),$=r.convert(F.type),Q=M(F.internalFormat,oe,$,F.normalized,F.colorSpace),ce=n.get(v),Re=n.get(F);if(Re.__renderTarget=v,!ce.__hasExternalTextures){const de=Math.max(1,v.width>>se),le=Math.max(1,v.height>>se);K===i.TEXTURE_3D||K===i.TEXTURE_2D_ARRAY?t.texImage3D(K,se,Q,de,le,v.depth,0,oe,$,null):t.texImage2D(K,se,Q,de,le,0,oe,$,null)}t.bindFramebuffer(i.FRAMEBUFFER,T),It(v)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,H,K,Re.__webglTexture,0,yt(v)):(K===i.TEXTURE_2D||K>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,H,K,Re.__webglTexture,se),t.bindFramebuffer(i.FRAMEBUFFER,null)}function Te(T,v,F){if(i.bindRenderbuffer(i.RENDERBUFFER,T),v.depthBuffer){const H=v.depthTexture,K=H&&H.isDepthTexture?H.type:null,se=S(v.stencilBuffer,K),oe=v.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;It(v)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,yt(v),se,v.width,v.height):F?i.renderbufferStorageMultisample(i.RENDERBUFFER,yt(v),se,v.width,v.height):i.renderbufferStorage(i.RENDERBUFFER,se,v.width,v.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,oe,i.RENDERBUFFER,T)}else{const H=v.textures;for(let K=0;K<H.length;K++){const se=H[K],oe=r.convert(se.format,se.colorSpace),$=r.convert(se.type),Q=M(se.internalFormat,oe,$,se.normalized,se.colorSpace);It(v)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,yt(v),Q,v.width,v.height):F?i.renderbufferStorageMultisample(i.RENDERBUFFER,yt(v),Q,v.width,v.height):i.renderbufferStorage(i.RENDERBUFFER,Q,v.width,v.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function xe(T,v,F){const H=v.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,T),!(v.depthTexture&&v.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const K=n.get(v.depthTexture);if(K.__renderTarget=v,(!K.__webglTexture||v.depthTexture.image.width!==v.width||v.depthTexture.image.height!==v.height)&&(v.depthTexture.image.width=v.width,v.depthTexture.image.height=v.height,v.depthTexture.needsUpdate=!0),H){if(K.__webglInit===void 0&&(K.__webglInit=!0,v.depthTexture.addEventListener("dispose",R)),K.__webglTexture===void 0){K.__webglTexture=i.createTexture(),t.bindTexture(i.TEXTURE_CUBE_MAP,K.__webglTexture),ke(i.TEXTURE_CUBE_MAP,v.depthTexture);const ce=r.convert(v.depthTexture.format),Re=r.convert(v.depthTexture.type);let de;v.depthTexture.format===Si?de=i.DEPTH_COMPONENT24:v.depthTexture.format===us&&(de=i.DEPTH24_STENCIL8);for(let le=0;le<6;le++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,de,v.width,v.height,0,ce,Re,null)}}else Z(v.depthTexture,0);const se=K.__webglTexture,oe=yt(v),$=H?i.TEXTURE_CUBE_MAP_POSITIVE_X+F:i.TEXTURE_2D,Q=v.depthTexture.format===us?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(v.depthTexture.format===Si)It(v)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Q,$,se,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,Q,$,se,0);else if(v.depthTexture.format===us)It(v)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Q,$,se,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,Q,$,se,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ne(T){const v=n.get(T),F=T.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==T.depthTexture){const H=T.depthTexture;if(v.__depthDisposeCallback&&v.__depthDisposeCallback(),H){const K=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,H.removeEventListener("dispose",K)};H.addEventListener("dispose",K),v.__depthDisposeCallback=K}v.__boundDepthTexture=H}if(T.depthTexture&&!v.__autoAllocateDepthBuffer)if(F)for(let H=0;H<6;H++)xe(v.__webglFramebuffer[H],T,H);else{const H=T.texture.mipmaps;H&&H.length>0?xe(v.__webglFramebuffer[0],T,0):xe(v.__webglFramebuffer,T,0)}else if(F){v.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(t.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer[H]),v.__webglDepthbuffer[H]===void 0)v.__webglDepthbuffer[H]=i.createRenderbuffer(),Te(v.__webglDepthbuffer[H],T,!1);else{const K=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,se=v.__webglDepthbuffer[H];i.bindRenderbuffer(i.RENDERBUFFER,se),i.framebufferRenderbuffer(i.FRAMEBUFFER,K,i.RENDERBUFFER,se)}}else{const H=T.texture.mipmaps;if(H&&H.length>0?t.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer),v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=i.createRenderbuffer(),Te(v.__webglDepthbuffer,T,!1);else{const K=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,se=v.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,se),i.framebufferRenderbuffer(i.FRAMEBUFFER,K,i.RENDERBUFFER,se)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function Ue(T,v,F){const H=n.get(T);v!==void 0&&Pe(H.__webglFramebuffer,T,T.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),F!==void 0&&Ne(T)}function Oe(T){const v=T.texture,F=n.get(T),H=n.get(v);T.addEventListener("dispose",_);const K=T.textures,se=T.isWebGLCubeRenderTarget===!0,oe=K.length>1;if(oe||(H.__webglTexture===void 0&&(H.__webglTexture=i.createTexture()),H.__version=v.version,a.memory.textures++),se){F.__webglFramebuffer=[];for(let $=0;$<6;$++)if(v.mipmaps&&v.mipmaps.length>0){F.__webglFramebuffer[$]=[];for(let Q=0;Q<v.mipmaps.length;Q++)F.__webglFramebuffer[$][Q]=i.createFramebuffer()}else F.__webglFramebuffer[$]=i.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){F.__webglFramebuffer=[];for(let $=0;$<v.mipmaps.length;$++)F.__webglFramebuffer[$]=i.createFramebuffer()}else F.__webglFramebuffer=i.createFramebuffer();if(oe)for(let $=0,Q=K.length;$<Q;$++){const ce=n.get(K[$]);ce.__webglTexture===void 0&&(ce.__webglTexture=i.createTexture(),a.memory.textures++)}if(T.samples>0&&It(T)===!1){F.__webglMultisampledFramebuffer=i.createFramebuffer(),F.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let $=0;$<K.length;$++){const Q=K[$];F.__webglColorRenderbuffer[$]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,F.__webglColorRenderbuffer[$]);const ce=r.convert(Q.format,Q.colorSpace),Re=r.convert(Q.type),de=M(Q.internalFormat,ce,Re,Q.normalized,Q.colorSpace,T.isXRRenderTarget===!0),le=yt(T);i.renderbufferStorageMultisample(i.RENDERBUFFER,le,de,T.width,T.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+$,i.RENDERBUFFER,F.__webglColorRenderbuffer[$])}i.bindRenderbuffer(i.RENDERBUFFER,null),T.depthBuffer&&(F.__webglDepthRenderbuffer=i.createRenderbuffer(),Te(F.__webglDepthRenderbuffer,T,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(se){t.bindTexture(i.TEXTURE_CUBE_MAP,H.__webglTexture),ke(i.TEXTURE_CUBE_MAP,v);for(let $=0;$<6;$++)if(v.mipmaps&&v.mipmaps.length>0)for(let Q=0;Q<v.mipmaps.length;Q++)Pe(F.__webglFramebuffer[$][Q],T,v,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+$,Q);else Pe(F.__webglFramebuffer[$],T,v,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+$,0);p(v)&&b(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(oe){for(let $=0,Q=K.length;$<Q;$++){const ce=K[$],Re=n.get(ce);let de=i.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(de=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(de,Re.__webglTexture),ke(de,ce),Pe(F.__webglFramebuffer,T,ce,i.COLOR_ATTACHMENT0+$,de,0),p(ce)&&b(de)}t.unbindTexture()}else{let $=i.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&($=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture($,H.__webglTexture),ke($,v),v.mipmaps&&v.mipmaps.length>0)for(let Q=0;Q<v.mipmaps.length;Q++)Pe(F.__webglFramebuffer[Q],T,v,i.COLOR_ATTACHMENT0,$,Q);else Pe(F.__webglFramebuffer,T,v,i.COLOR_ATTACHMENT0,$,0);p(v)&&b($),t.unbindTexture()}T.depthBuffer&&Ne(T)}function tt(T){const v=T.textures;for(let F=0,H=v.length;F<H;F++){const K=v[F];if(p(K)){const se=w(T),oe=n.get(K).__webglTexture;t.bindTexture(se,oe),b(se),t.unbindTexture()}}}const nt=[],Mt=[];function gt(T){if(T.samples>0){if(It(T)===!1){const v=T.textures,F=T.width,H=T.height;let K=i.COLOR_BUFFER_BIT;const se=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,oe=n.get(T),$=v.length>1;if($)for(let ce=0;ce<v.length;ce++)t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,oe.__webglMultisampledFramebuffer);const Q=T.texture.mipmaps;Q&&Q.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglFramebuffer);for(let ce=0;ce<v.length;ce++){if(T.resolveDepthBuffer&&(T.depthBuffer&&(K|=i.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&(K|=i.STENCIL_BUFFER_BIT)),$){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,oe.__webglColorRenderbuffer[ce]);const Re=n.get(v[ce]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Re,0)}i.blitFramebuffer(0,0,F,H,0,0,F,H,K,i.NEAREST),c===!0&&(nt.length=0,Mt.length=0,nt.push(i.COLOR_ATTACHMENT0+ce),T.depthBuffer&&T.resolveDepthBuffer===!1&&(nt.push(se),Mt.push(se),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,Mt)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,nt))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),$)for(let ce=0;ce<v.length;ce++){t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.RENDERBUFFER,oe.__webglColorRenderbuffer[ce]);const Re=n.get(v[ce]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.TEXTURE_2D,Re,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&c){const v=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[v])}}}function yt(T){return Math.min(s.maxSamples,T.samples)}function It(T){const v=n.get(T);return T.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function N(T){const v=a.render.frame;h.get(T)!==v&&(h.set(T,v),T.update())}function cn(T,v){const F=T.colorSpace,H=T.format,K=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||F!==Co&&F!==Hi&&(Je.getTransfer(F)===st?(H!==an||K!==yn)&&Ae("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ze("WebGLTextures: Unsupported texture color space:",F)),v}function it(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(l.width=T.naturalWidth||T.width,l.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(l.width=T.displayWidth,l.height=T.displayHeight):(l.width=T.width,l.height=T.height),l}this.allocateTextureUnit=X,this.resetTextureUnits=V,this.getTextureUnits=q,this.setTextureUnits=U,this.setTexture2D=Z,this.setTexture2DArray=te,this.setTexture3D=j,this.setTextureCube=ie,this.rebindTextures=Ue,this.setupRenderTarget=Oe,this.updateRenderTargetMipmap=tt,this.updateMultisampleRenderTarget=gt,this.setupDepthRenderbuffer=Ne,this.setupFrameBufferTexture=Pe,this.useMultisampledRTT=It,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function XM(i,e){function t(n,s=Hi){let r;const a=Je.getTransfer(s);if(n===yn)return i.UNSIGNED_BYTE;if(n===zh)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Bh)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Cf)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Pf)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Rf)return i.BYTE;if(n===Df)return i.SHORT;if(n===ta)return i.UNSIGNED_SHORT;if(n===Fh)return i.INT;if(n===Hn)return i.UNSIGNED_INT;if(n===Dn)return i.FLOAT;if(n===jt)return i.HALF_FLOAT;if(n===If)return i.ALPHA;if(n===Lf)return i.RGB;if(n===an)return i.RGBA;if(n===Si)return i.DEPTH_COMPONENT;if(n===us)return i.DEPTH_STENCIL;if(n===kh)return i.RED;if(n===Hh)return i.RED_INTEGER;if(n===ms)return i.RG;if(n===Gh)return i.RG_INTEGER;if(n===Vh)return i.RGBA_INTEGER;if(n===vo||n===_o||n===xo||n===Mo)if(a===st)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===vo)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===_o)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===xo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Mo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===vo)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===_o)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===xo)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Mo)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Tl||n===Rl||n===Dl||n===Cl)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Tl)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Rl)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Dl)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Cl)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Pl||n===Il||n===Ll||n===Nl||n===Ul||n===wo||n===Ol)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Pl||n===Il)return a===st?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Ll)return a===st?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Nl)return r.COMPRESSED_R11_EAC;if(n===Ul)return r.COMPRESSED_SIGNED_R11_EAC;if(n===wo)return r.COMPRESSED_RG11_EAC;if(n===Ol)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Fl||n===zl||n===Bl||n===kl||n===Hl||n===Gl||n===Vl||n===Wl||n===Xl||n===ql||n===Yl||n===Kl||n===$l||n===Zl)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Fl)return a===st?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===zl)return a===st?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Bl)return a===st?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===kl)return a===st?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Hl)return a===st?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Gl)return a===st?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Vl)return a===st?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Wl)return a===st?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Xl)return a===st?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===ql)return a===st?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Yl)return a===st?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Kl)return a===st?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===$l)return a===st?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Zl)return a===st?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Jl||n===Ql||n===jl)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===Jl)return a===st?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Ql)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===jl)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===eh||n===th||n===To||n===nh)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===eh)return r.COMPRESSED_RED_RGTC1_EXT;if(n===th)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===To)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===nh)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===na?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const qM=`
4421
4421
  void main() {
4422
4422
 
4423
4423
  gl_Position = vec4( position, 1.0 );
4424
4424
 
4425
- }`,H_=`
4425
+ }`,YM=`
4426
4426
  uniform sampler2DArray depthColor;
4427
4427
  uniform float depthWidth;
4428
4428
  uniform float depthHeight;
@@ -4441,20 +4441,20 @@ void main() {
4441
4441
 
4442
4442
  }
4443
4443
 
4444
- }`;class k_{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new C0(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new At({vertexShader:B_,fragmentShader:H_,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new je(new ki(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class G_ extends fs{constructor(e,t){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 k_,p={},A=t.getContextAttributes();let T=null,M=null;const y=[],b=[],R=new Le;let _=null;const E=new _n;E.viewport=new vt;const C=new _n;C.viewport=new vt;const D=[E,C],I=new Qm;let W=null,X=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let re=y[Y];return re===void 0&&(re=new Ho,y[Y]=re),re.getTargetRaySpace()},this.getControllerGrip=function(Y){let re=y[Y];return re===void 0&&(re=new Ho,y[Y]=re),re.getGripSpace()},this.getHand=function(Y){let re=y[Y];return re===void 0&&(re=new Ho,y[Y]=re),re.getHandSpace()};function O(Y){const re=b.indexOf(Y.inputSource);if(re===-1)return;const ne=y[re];ne!==void 0&&(ne.update(Y.inputSource,Y.frame,l||a),ne.dispatchEvent({type:Y.type,data:Y.inputSource}))}function q(){s.removeEventListener("select",O),s.removeEventListener("selectstart",O),s.removeEventListener("selectend",O),s.removeEventListener("squeeze",O),s.removeEventListener("squeezestart",O),s.removeEventListener("squeezeend",O),s.removeEventListener("end",q),s.removeEventListener("inputsourceschange",G);for(let Y=0;Y<y.length;Y++){const re=b[Y];re!==null&&(b[Y]=null,y[Y].disconnect(re))}W=null,X=null,m.reset();for(const Y in p)delete p[Y];e.setRenderTarget(T),f=null,d=null,u=null,s=null,M=null,Be.stop(),n.isPresenting=!1,e.setPixelRatio(_),e.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){r=Y,n.isPresenting===!0&&Fe("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,n.isPresenting===!0&&Fe("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,t)),u},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(Y){if(s=Y,s!==null){if(T=e.getRenderTarget(),s.addEventListener("select",O),s.addEventListener("selectstart",O),s.addEventListener("selectend",O),s.addEventListener("squeeze",O),s.addEventListener("squeezestart",O),s.addEventListener("squeezeend",O),s.addEventListener("end",q),s.addEventListener("inputsourceschange",G),A.xrCompatible!==!0&&await t.makeXRCompatible(),_=e.getPixelRatio(),e.getSize(R),x&&"createProjectionLayer"in XRWebGLBinding.prototype){let ne=null,z=null,Ae=null;A.depth&&(Ae=A.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ne=A.stencil?is:mi,z=A.stencil?zr:On);const Ce={colorFormat:t.RGBA8,depthFormat:Ae,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(Ce),s.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),M=new un(d.textureWidth,d.textureHeight,{format:hn,type:xn,depthTexture:new ls(d.textureWidth,d.textureHeight,z,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:A.stencil,colorSpace:e.outputColorSpace,samples:A.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const ne={antialias:A.antialias,alpha:!0,depth:A.depth,stencil:A.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(s,t,ne),s.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),M=new un(f.framebufferWidth,f.framebufferHeight,{format:hn,type:xn,colorSpace:e.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),Be.setContext(s),Be.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function G(Y){for(let re=0;re<Y.removed.length;re++){const ne=Y.removed[re],z=b.indexOf(ne);z>=0&&(b[z]=null,y[z].disconnect(ne))}for(let re=0;re<Y.added.length;re++){const ne=Y.added[re];let z=b.indexOf(ne);if(z===-1){for(let Ce=0;Ce<y.length;Ce++)if(Ce>=b.length){b.push(ne),z=Ce;break}else if(b[Ce]===null){b[Ce]=ne,z=Ce;break}if(z===-1)break}const Ae=y[z];Ae&&Ae.connect(ne)}}const $=new L,te=new L;function j(Y,re,ne){$.setFromMatrixPosition(re.matrixWorld),te.setFromMatrixPosition(ne.matrixWorld);const z=$.distanceTo(te),Ae=re.projectionMatrix.elements,Ce=ne.projectionMatrix.elements,Te=Ae[14]/(Ae[10]-1),_e=Ae[14]/(Ae[10]+1),Ie=(Ae[9]+1)/Ae[5],Ne=(Ae[9]-1)/Ae[5],Ue=(Ae[8]-1)/Ae[0],et=(Ce[8]+1)/Ce[0],tt=Te*Ue,_t=Te*et,pt=z/(-Ue+et),xt=pt*-Ue;if(re.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(xt),Y.translateZ(pt),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),Ae[10]===-1)Y.projectionMatrix.copy(re.projectionMatrix),Y.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{const Dt=Te+pt,N=_e+pt,an=tt-xt,nt=_t+(z-xt),w=Ie*_e/N*Dt,v=Ne*_e/N*Dt;Y.projectionMatrix.makePerspective(an,nt,w,v,Dt,N),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function ie(Y,re){re===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(re.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(s===null)return;let re=Y.near,ne=Y.far;m.texture!==null&&(m.depthNear>0&&(re=m.depthNear),m.depthFar>0&&(ne=m.depthFar)),I.near=C.near=E.near=re,I.far=C.far=E.far=ne,(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,C.layers.mask=I.layers.mask&-3;const z=Y.parent,Ae=I.cameras;ie(I,z);for(let Ce=0;Ce<Ae.length;Ce++)ie(Ae[Ce],z);Ae.length===2?j(I,E,C):I.projectionMatrix.copy(E.projectionMatrix),ue(Y,I,z)};function ue(Y,re,ne){ne===null?Y.matrix.copy(re.matrixWorld):(Y.matrix.copy(ne.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(re.matrixWorld)),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(re.projectionMatrix),Y.projectionMatrixInverse.copy(re.projectionMatrixInverse),Y.isPerspectiveCamera&&(Y.fov=Al*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 He=null;function Ke(Y,re){if(h=re.getViewerPose(l||a),g=re,h!==null){const ne=h.views;f!==null&&(e.setRenderTargetFramebuffer(M,f.framebuffer),e.setRenderTarget(M));let z=!1;ne.length!==I.cameras.length&&(I.cameras.length=0,z=!0);for(let _e=0;_e<ne.length;_e++){const Ie=ne[_e];let Ne=null;if(f!==null)Ne=f.getViewport(Ie);else{const et=u.getViewSubImage(d,Ie);Ne=et.viewport,_e===0&&(e.setRenderTargetTextures(M,et.colorTexture,et.depthStencilTexture),e.setRenderTarget(M))}let Ue=D[_e];Ue===void 0&&(Ue=new _n,Ue.layers.enable(_e),Ue.viewport=new vt,D[_e]=Ue),Ue.matrix.fromArray(Ie.transform.matrix),Ue.matrix.decompose(Ue.position,Ue.quaternion,Ue.scale),Ue.projectionMatrix.fromArray(Ie.projectionMatrix),Ue.projectionMatrixInverse.copy(Ue.projectionMatrix).invert(),Ue.viewport.set(Ne.x,Ne.y,Ne.width,Ne.height),_e===0&&(I.matrix.copy(Ue.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),z===!0&&I.cameras.push(Ue)}const Ae=s.enabledFeatures;if(Ae&&Ae.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&x){u=n.getBinding();const _e=u.getDepthInformation(ne[0]);_e&&_e.isValid&&_e.texture&&m.init(_e,s.renderState)}if(Ae&&Ae.includes("camera-access")&&x){e.state.unbindTexture(),u=n.getBinding();for(let _e=0;_e<ne.length;_e++){const Ie=ne[_e].camera;if(Ie){let Ne=p[Ie];Ne||(Ne=new C0,p[Ie]=Ne);const Ue=u.getCameraImage(Ie);Ne.sourceTexture=Ue}}}}for(let ne=0;ne<y.length;ne++){const z=b[ne],Ae=y[ne];z!==null&&Ae!==void 0&&Ae.update(z,re,l||a)}He&&He(Y,re),re.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:re}),g=null}const Be=new U0;Be.setAnimationLoop(Ke),this.setAnimationLoop=function(Y){He=Y},this.dispose=function(){}}}const V_=new dt,G0=new ze;G0.set(-1,0,0,0,1,0,0,0,1);function W_(i,e){function t(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,P0(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,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,t(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===It&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,t(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===It&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,t(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,t(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);const A=e.get(p),T=A.envMap,M=A.envMapRotation;T&&(m.envMap.value=T,m.envMapRotation.value.setFromMatrix4(V_.makeRotationFromEuler(M)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(G0),m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,m.aoMapTransform))}function a(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform))}function o(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function 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,t(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function 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,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function h(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function u(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function d(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,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,t(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===It&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=A.texture,m.transmissionSamplerSize.value.set(A.width,A.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function x(m,p){const A=e.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 X_(i,e,t,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 _=e.render.frame;r[M.id]!==_&&(d(M),r[M.id]=_)}function h(M){const y=u();M.__bindingPointIndex=y;const b=i.createBuffer(),R=M.__size,_=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,R,_),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 Ze("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 _=0,E=b.length;_<E;_++){const C=b[_];if(Array.isArray(C))for(let D=0,I=C.length;D<I;D++)f(C[D],_,D,R);else f(C,_,0,R)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function f(M,y,b,R){if(x(M,y,b,R)===!0){const _=M.__offset,E=M.value;if(Array.isArray(E)){let C=0;for(let D=0;D<E.length;D++){const I=E[D],W=p(I);g(I,M.__data,C),typeof I!="number"&&typeof I!="boolean"&&!I.isMatrix3&&!ArrayBuffer.isView(I)&&(C+=W.storage/Float32Array.BYTES_PER_ELEMENT)}}else g(E,M.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,_,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 _=M.value,E=y+"_"+b;if(R[E]===void 0)return typeof _=="number"||typeof _=="boolean"?R[E]=_:ArrayBuffer.isView(_)?R[E]=_.slice():R[E]=_.clone(),!0;{const C=R[E];if(typeof _=="number"||typeof _=="boolean"){if(C!==_)return R[E]=_,!0}else{if(ArrayBuffer.isView(_))return!0;if(C.equals(_)===!1)return C.copy(_),!0}}return!1}function m(M){const y=M.uniforms;let b=0;const R=16;for(let E=0,C=y.length;E<C;E++){const D=Array.isArray(y[E])?y[E]:[y[E]];for(let I=0,W=D.length;I<W;I++){const X=D[I],O=Array.isArray(X.value)?X.value:[X.value];for(let q=0,G=O.length;q<G;q++){const $=O[q],te=p($),j=b%R,ie=j%te.boundary,ue=j+ie;b+=ie,ue!==0&&R-ue<te.storage&&(b+=R-ue),X.__data=new Float32Array(te.storage/Float32Array.BYTES_PER_ELEMENT),X.__offset=b,b+=te.storage}}}const _=b%R;return _>0&&(b+=R-_),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?Fe("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(y.boundary=16,y.storage=M.byteLength):Fe("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 q_=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 kn=null;function Y_(){return kn===null&&(kn=new Mo(q_,16,16,os,Qt),kn.name="DFG_LUT",kn.minFilter=Et,kn.magFilter=Et,kn.wrapS=sn,kn.wrapT=sn,kn.generateMipmaps=!1,kn.needsUpdate=!0),kn}class K_{constructor(e={}){const{canvas:t=lm(),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=xn}=e;this.isWebGLRenderer=!0;let g;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=n.getContextAttributes().alpha}else g=a;const x=f,m=new Set([oh,ah,rh]),p=new Set([xn,On,Fr,zr,ih,sh]),A=new Uint32Array(4),T=new Int32Array(4),M=new L;let y=null,b=null;const R=[],_=[];let E=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=ei,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let D=!1,I=null,W=null,X=null,O=null;this._outputColorSpace=An;let q=0,G=0,$=null,te=-1,j=null;const ie=new vt,ue=new vt;let He=null;const Ke=new Me(0);let Be=0,Y=t.width,re=t.height,ne=1,z=null,Ae=null;const Ce=new vt(0,0,Y,re),Te=new vt(0,0,Y,re);let _e=!1;const Ie=new ph;let Ne=!1,Ue=!1;const et=new dt,tt=new L,_t=new vt,pt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let xt=!1;function Dt(){return $===null?ne:1}let N=n;function an(S,U){return t.getContext(S,U)}try{const S={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${eh}`),t.addEventListener("webglcontextlost",Mt,!1),t.addEventListener("webglcontextrestored",lt,!1),t.addEventListener("webglcontextcreationerror",Fn,!1),N===null){const U="webgl2";if(N=an(U,S),N===null)throw an(U)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(S){throw Ze("WebGLRenderer: "+S.message),S}let nt,w,v,F,k,K,se,oe,Z,Q,ce,we,de,le,Pe,Oe,ke,P,ae,J,he,ge,ee;function be(){nt=new Y2(N),nt.init(),he=new z_(N,nt),w=new B2(N,nt,e,he),v=new O_(N,nt),w.reversedDepthBuffer&&d&&v.buffers.depth.setReversed(!0),W=N.createFramebuffer(),X=N.createFramebuffer(),O=N.createFramebuffer(),F=new $2(N),k=new y_,K=new F_(N,nt,v,k,w,he,F),se=new q2(C),oe=new eg(N),ge=new F2(N,oe),Z=new K2(N,oe,F,ge),Q=new Q2(N,Z,oe,ge,F),P=new J2(N,w,K),Pe=new H2(k),ce=new S_(C,se,nt,w,ge,Pe),we=new W_(C,k),de=new A_,le=new C_(nt),ke=new O2(C,se,v,Q,g,c),Oe=new U_(C,Q,w),ee=new X_(N,F,w,v),ae=new z2(N,nt,F),J=new Z2(N,nt,F),F.programs=ce.programs,C.capabilities=w,C.extensions=nt,C.properties=k,C.renderLists=de,C.shadowMap=Oe,C.state=v,C.info=F}be(),x!==xn&&(E=new ev(x,t.width,t.height,o,s,r));const Se=new G_(C,N);this.xr=Se,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){const S=nt.get("WEBGL_lose_context");S&&S.loseContext()},this.forceContextRestore=function(){const S=nt.get("WEBGL_lose_context");S&&S.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(S){S!==void 0&&(ne=S,this.setSize(Y,re,!1))},this.getSize=function(S){return S.set(Y,re)},this.setSize=function(S,U,V=!0){if(Se.isPresenting){Fe("WebGLRenderer: Can't change size while VR device is presenting.");return}Y=S,re=U,t.width=Math.floor(S*ne),t.height=Math.floor(U*ne),V===!0&&(t.style.width=S+"px",t.style.height=U+"px"),E!==null&&E.setSize(t.width,t.height),this.setViewport(0,0,S,U)},this.getDrawingBufferSize=function(S){return S.set(Y*ne,re*ne).floor()},this.setDrawingBufferSize=function(S,U,V){Y=S,re=U,ne=V,t.width=Math.floor(S*V),t.height=Math.floor(U*V),this.setViewport(0,0,S,U)},this.setEffects=function(S){if(x===xn){Ze("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(S){for(let U=0;U<S.length;U++)if(S[U].isOutputPass===!0){Fe("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(ie)},this.getViewport=function(S){return S.copy(Ce)},this.setViewport=function(S,U,V,B){S.isVector4?Ce.set(S.x,S.y,S.z,S.w):Ce.set(S,U,V,B),v.viewport(ie.copy(Ce).multiplyScalar(ne).round())},this.getScissor=function(S){return S.copy(Te)},this.setScissor=function(S,U,V,B){S.isVector4?Te.set(S.x,S.y,S.z,S.w):Te.set(S,U,V,B),v.scissor(ue.copy(Te).multiplyScalar(ne).round())},this.getScissorTest=function(){return _e},this.setScissorTest=function(S){v.setScissorTest(_e=S)},this.setOpaqueSort=function(S){z=S},this.setTransparentSort=function(S){Ae=S},this.getClearColor=function(S){return S.copy(ke.getClearColor())},this.setClearColor=function(){ke.setClearColor(...arguments)},this.getClearAlpha=function(){return ke.getClearAlpha()},this.setClearAlpha=function(){ke.setClearAlpha(...arguments)},this.clear=function(S=!0,U=!0,V=!0){let B=0;if(S){let H=!1;if($!==null){const me=$.texture.format;H=m.has(me)}if(H){const me=$.texture.type,xe=p.has(me),pe=ke.getClearColor(),Ee=ke.getClearAlpha(),Re=pe.r,Ge=pe.g,We=pe.b;xe?(A[0]=Re,A[1]=Ge,A[2]=We,A[3]=Ee,N.clearBufferuiv(N.COLOR,0,A)):(T[0]=Re,T[1]=Ge,T[2]=We,T[3]=Ee,N.clearBufferiv(N.COLOR,0,T))}else B|=N.COLOR_BUFFER_BIT}U&&(B|=N.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),V&&(B|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B!==0&&N.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(){t.removeEventListener("webglcontextlost",Mt,!1),t.removeEventListener("webglcontextrestored",lt,!1),t.removeEventListener("webglcontextcreationerror",Fn,!1),ke.dispose(),de.dispose(),le.dispose(),k.dispose(),se.dispose(),Q.dispose(),ge.dispose(),ee.dispose(),ce.dispose(),Se.dispose(),Se.removeEventListener("sessionstart",Th),Se.removeEventListener("sessionend",wh),Gi.stop()};function Mt(S){S.preventDefault(),so("WebGLRenderer: Context Lost."),D=!0}function lt(){so("WebGLRenderer: Context Restored."),D=!1;const S=F.autoReset,U=Oe.enabled,V=Oe.autoUpdate,B=Oe.needsUpdate,H=Oe.type;be(),F.autoReset=S,Oe.enabled=U,Oe.autoUpdate=V,Oe.needsUpdate=B,Oe.type=H}function Fn(S){Ze("WebGLRenderer: A WebGL context could not be created. Reason: ",S.statusMessage)}function zn(S){const U=S.target;U.removeEventListener("dispose",zn),Lf(U)}function Lf(S){Nf(S),k.remove(S)}function Nf(S){const U=k.get(S).programs;U!==void 0&&(U.forEach(function(V){ce.releaseProgram(V)}),S.isShaderMaterial&&ce.releaseShaderCache(S))}this.renderBufferDirect=function(S,U,V,B,H,me){U===null&&(U=pt);const xe=H.isMesh&&H.matrixWorld.determinantAffine()<0,pe=Ff(S,U,V,B,H);v.setMaterial(B,xe);let Ee=V.index,Re=1;if(B.wireframe===!0){if(Ee=Z.getWireframeAttribute(V),Ee===void 0)return;Re=2}const Ge=V.drawRange,We=V.attributes.position;let De=Ge.start*Re,rt=(Ge.start+Ge.count)*Re;me!==null&&(De=Math.max(De,me.start*Re),rt=Math.min(rt,(me.start+me.count)*Re)),Ee!==null?(De=Math.max(De,0),rt=Math.min(rt,Ee.count)):We!=null&&(De=Math.max(De,0),rt=Math.min(rt,We.count));const bt=rt-De;if(bt<0||bt===1/0)return;ge.setup(H,B,pe,V,Ee);let St,ot=ae;if(Ee!==null&&(St=oe.get(Ee),ot=J,ot.setIndex(St)),H.isMesh)B.wireframe===!0?(v.setLineWidth(B.wireframeLinewidth*Dt()),ot.setMode(N.LINES)):ot.setMode(N.TRIANGLES);else if(H.isLine){let Wt=B.linewidth;Wt===void 0&&(Wt=1),v.setLineWidth(Wt*Dt()),H.isLineSegments?ot.setMode(N.LINES):H.isLineLoop?ot.setMode(N.LINE_LOOP):ot.setMode(N.LINE_STRIP)}else H.isPoints?ot.setMode(N.POINTS):H.isSprite&&ot.setMode(N.TRIANGLES);if(H.isBatchedMesh)if(nt.get("WEBGL_multi_draw"))ot.renderMultiDraw(H._multiDrawStarts,H._multiDrawCounts,H._multiDrawCount);else{const Wt=H._multiDrawStarts,ve=H._multiDrawCounts,dn=H._multiDrawCount,Je=Ee?oe.get(Ee).bytesPerElement:1,Mn=k.get(B).currentProgram.getUniforms();for(let Bn=0;Bn<dn;Bn++)Mn.setValue(N,"_gl_DrawID",Bn),ot.render(Wt[Bn]/Je,ve[Bn])}else if(H.isInstancedMesh)ot.renderInstances(De,bt,H.count);else if(V.isInstancedBufferGeometry){const Wt=V._maxInstanceCount!==void 0?V._maxInstanceCount:1/0,ve=Math.min(V.instanceCount,Wt);ot.renderInstances(De,bt,ve)}else ot.render(De,bt)};function bh(S,U,V){S.transparent===!0&&S.side===Ln&&S.forceSinglePass===!1?(S.side=It,S.needsUpdate=!0,qr(S,U,V),S.side=Fi,S.needsUpdate=!0,qr(S,U,V),S.side=Ln):qr(S,U,V)}this.compile=function(S,U,V=null){V===null&&(V=S),b=le.get(V),b.init(U),_.push(b),V.traverseVisible(function(H){H.isLight&&H.layers.test(U.layers)&&(b.pushLight(H),H.castShadow&&b.pushShadow(H))}),S!==V&&S.traverseVisible(function(H){H.isLight&&H.layers.test(U.layers)&&(b.pushLight(H),H.castShadow&&b.pushShadow(H))}),b.setupLights();const B=new Set;return S.traverse(function(H){if(!(H.isMesh||H.isPoints||H.isLine||H.isSprite))return;const me=H.material;if(me)if(Array.isArray(me))for(let xe=0;xe<me.length;xe++){const pe=me[xe];bh(pe,V,H),B.add(pe)}else bh(me,V,H),B.add(me)}),b=_.pop(),B},this.compileAsync=function(S,U,V=null){const B=this.compile(S,U,V);return new Promise(H=>{function me(){if(B.forEach(function(xe){k.get(xe).currentProgram.isReady()&&B.delete(xe)}),B.size===0){H(S);return}setTimeout(me,10)}nt.get("KHR_parallel_shader_compile")!==null?me():setTimeout(me,10)})};let wo=null;function Uf(S){wo&&wo(S)}function Th(){Gi.stop()}function wh(){Gi.start()}const Gi=new U0;Gi.setAnimationLoop(Uf),typeof self<"u"&&Gi.setContext(self),this.setAnimationLoop=function(S){wo=S,Se.setAnimationLoop(S),S===null?Gi.stop():Gi.start()},Se.addEventListener("sessionstart",Th),Se.addEventListener("sessionend",wh),this.render=function(S,U){if(U!==void 0&&U.isCamera!==!0){Ze("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;I!==null&&I.renderStart(S,U);const V=Se.enabled===!0&&Se.isPresenting===!0,B=E!==null&&($===null||V)&&E.begin(C,$);if(S.matrixWorldAutoUpdate===!0&&S.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),Se.enabled===!0&&Se.isPresenting===!0&&(E===null||E.isCompositing()===!1)&&(Se.cameraAutoUpdate===!0&&Se.updateCamera(U),U=Se.getCamera()),S.isScene===!0&&S.onBeforeRender(C,S,U,$),b=le.get(S,_.length),b.init(U),b.state.textureUnits=K.getTextureUnits(),_.push(b),et.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Ie.setFromProjectionMatrix(et,Jn,U.reversedDepth),Ue=this.localClippingEnabled,Ne=Pe.init(this.clippingPlanes,Ue),y=de.get(S,R.length),y.init(),R.push(y),Se.enabled===!0&&Se.isPresenting===!0){const xe=C.xr.getDepthSensingMesh();xe!==null&&Ro(xe,U,-1/0,C.sortObjects)}Ro(S,U,0,C.sortObjects),y.finish(),C.sortObjects===!0&&y.sort(z,Ae,U.reversedDepth),xt=Se.enabled===!1||Se.isPresenting===!1||Se.hasDepthSensing()===!1,xt&&ke.addToRenderList(y,S),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Ne===!0&&Pe.beginShadows();const H=b.state.shadowsArray;if(Oe.render(H,S,U),Ne===!0&&Pe.endShadows(),(B&&E.hasRenderPass())===!1){const xe=y.opaque,pe=y.transmissive;if(b.setupLights(),U.isArrayCamera){const Ee=U.cameras;if(pe.length>0)for(let Re=0,Ge=Ee.length;Re<Ge;Re++){const We=Ee[Re];Dh(xe,pe,S,We)}xt&&ke.render(S);for(let Re=0,Ge=Ee.length;Re<Ge;Re++){const We=Ee[Re];Rh(y,S,We,We.viewport)}}else pe.length>0&&Dh(xe,pe,S,U),xt&&ke.render(S),Rh(y,S,U)}$!==null&&G===0&&(K.updateMultisampleRenderTarget($),K.updateRenderTargetMipmap($)),B&&E.end(C),S.isScene===!0&&S.onAfterRender(C,S,U),ge.resetDefaultState(),te=-1,j=null,_.pop(),_.length>0?(b=_[_.length-1],K.setTextureUnits(b.state.textureUnits),Ne===!0&&Pe.setGlobalState(C.clippingPlanes,b.state.camera)):b=null,R.pop(),R.length>0?y=R[R.length-1]:y=null,I!==null&&I.renderEnd()};function Ro(S,U,V,B){if(S.visible===!1)return;if(S.layers.test(U.layers)){if(S.isGroup)V=S.renderOrder;else if(S.isLOD)S.autoUpdate===!0&&S.update(U);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||Ie.intersectsSprite(S)){B&&_t.setFromMatrixPosition(S.matrixWorld).applyMatrix4(et);const xe=Q.update(S),pe=S.material;pe.visible&&y.push(S,xe,pe,V,_t.z,null)}}else if((S.isMesh||S.isLine||S.isPoints)&&(!S.frustumCulled||Ie.intersectsObject(S))){const xe=Q.update(S),pe=S.material;if(B&&(S.boundingSphere!==void 0?(S.boundingSphere===null&&S.computeBoundingSphere(),_t.copy(S.boundingSphere.center)):(xe.boundingSphere===null&&xe.computeBoundingSphere(),_t.copy(xe.boundingSphere.center)),_t.applyMatrix4(S.matrixWorld).applyMatrix4(et)),Array.isArray(pe)){const Ee=xe.groups;for(let Re=0,Ge=Ee.length;Re<Ge;Re++){const We=Ee[Re],De=pe[We.materialIndex];De&&De.visible&&y.push(S,xe,De,V,_t.z,We)}}else pe.visible&&y.push(S,xe,pe,V,_t.z,null)}}const me=S.children;for(let xe=0,pe=me.length;xe<pe;xe++)Ro(me[xe],U,V,B)}function Rh(S,U,V,B){const{opaque:H,transmissive:me,transparent:xe}=S;b.setupLightsView(V),Ne===!0&&Pe.setGlobalState(C.clippingPlanes,V),B&&v.viewport(ie.copy(B)),H.length>0&&Xr(H,U,V),me.length>0&&Xr(me,U,V),xe.length>0&&Xr(xe,U,V),v.buffers.depth.setTest(!0),v.buffers.depth.setMask(!0),v.buffers.color.setMask(!0),v.setPolygonOffset(!1)}function Dh(S,U,V,B){if((V.isScene===!0?V.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[B.id]===void 0){const De=nt.has("EXT_color_buffer_half_float")||nt.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[B.id]=new un(1,1,{generateMipmaps:!0,type:De?Qt:xn,minFilter:ns,samples:Math.max(4,w.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:$e.workingColorSpace})}const me=b.state.transmissionRenderTarget[B.id],xe=B.viewport||ie;me.setSize(xe.z*C.transmissionResolutionScale,xe.w*C.transmissionResolutionScale);const pe=C.getRenderTarget(),Ee=C.getActiveCubeFace(),Re=C.getActiveMipmapLevel();C.setRenderTarget(me),C.getClearColor(Ke),Be=C.getClearAlpha(),Be<1&&C.setClearColor(16777215,.5),C.clear(),xt&&ke.render(V);const Ge=C.toneMapping;C.toneMapping=ei;const We=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),b.setupLightsView(B),Ne===!0&&Pe.setGlobalState(C.clippingPlanes,B),Xr(S,V,B),K.updateMultisampleRenderTarget(me),K.updateRenderTargetMipmap(me),nt.has("WEBGL_multisampled_render_to_texture")===!1){let De=!1;for(let rt=0,bt=U.length;rt<bt;rt++){const St=U[rt],{object:ot,geometry:Wt,material:ve,group:dn}=St;if(ve.side===Ln&&ot.layers.test(B.layers)){const Je=ve.side;ve.side=It,ve.needsUpdate=!0,Ch(ot,V,B,Wt,ve,dn),ve.side=Je,ve.needsUpdate=!0,De=!0}}De===!0&&(K.updateMultisampleRenderTarget(me),K.updateRenderTargetMipmap(me))}C.setRenderTarget(pe,Ee,Re),C.setClearColor(Ke,Be),We!==void 0&&(B.viewport=We),C.toneMapping=Ge}function Xr(S,U,V){const B=U.isScene===!0?U.overrideMaterial:null;for(let H=0,me=S.length;H<me;H++){const xe=S[H],{object:pe,geometry:Ee,group:Re}=xe;let Ge=xe.material;Ge.allowOverride===!0&&B!==null&&(Ge=B),pe.layers.test(V.layers)&&Ch(pe,U,V,Ee,Ge,Re)}}function Ch(S,U,V,B,H,me){S.onBeforeRender(C,U,V,B,H,me),S.modelViewMatrix.multiplyMatrices(V.matrixWorldInverse,S.matrixWorld),S.normalMatrix.getNormalMatrix(S.modelViewMatrix),H.onBeforeRender(C,U,V,B,S,me),H.transparent===!0&&H.side===Ln&&H.forceSinglePass===!1?(H.side=It,H.needsUpdate=!0,C.renderBufferDirect(V,U,B,H,S,me),H.side=Fi,H.needsUpdate=!0,C.renderBufferDirect(V,U,B,H,S,me),H.side=Ln):C.renderBufferDirect(V,U,B,H,S,me),S.onAfterRender(C,U,V,B,H,me)}function qr(S,U,V){U.isScene!==!0&&(U=pt);const B=k.get(S),H=b.state.lights,me=b.state.shadowsArray,xe=H.state.version,pe=ce.getParameters(S,H.state,me,U,V,b.state.lightProbeGridArray),Ee=ce.getProgramCacheKey(pe);let Re=B.programs;B.environment=S.isMeshStandardMaterial||S.isMeshLambertMaterial||S.isMeshPhongMaterial?U.environment:null,B.fog=U.fog;const Ge=S.isMeshStandardMaterial||S.isMeshLambertMaterial&&!S.envMap||S.isMeshPhongMaterial&&!S.envMap;B.envMap=se.get(S.envMap||B.environment,Ge),B.envMapRotation=B.environment!==null&&S.envMap===null?U.environmentRotation:S.envMapRotation,Re===void 0&&(S.addEventListener("dispose",zn),Re=new Map,B.programs=Re);let We=Re.get(Ee);if(We!==void 0){if(B.currentProgram===We&&B.lightsStateVersion===xe)return Ih(S,pe),We}else pe.uniforms=ce.getUniforms(S),I!==null&&S.isNodeMaterial&&I.build(S,V,pe),S.onBeforeCompile(pe,C),We=ce.acquireProgram(pe,Ee),Re.set(Ee,We),B.uniforms=pe.uniforms;const De=B.uniforms;return(!S.isShaderMaterial&&!S.isRawShaderMaterial||S.clipping===!0)&&(De.clippingPlanes=Pe.uniform),Ih(S,pe),B.needsLights=Bf(S),B.lightsStateVersion=xe,B.needsLights&&(De.ambientLightColor.value=H.state.ambient,De.lightProbe.value=H.state.probe,De.directionalLights.value=H.state.directional,De.directionalLightShadows.value=H.state.directionalShadow,De.spotLights.value=H.state.spot,De.spotLightShadows.value=H.state.spotShadow,De.rectAreaLights.value=H.state.rectArea,De.ltc_1.value=H.state.rectAreaLTC1,De.ltc_2.value=H.state.rectAreaLTC2,De.pointLights.value=H.state.point,De.pointLightShadows.value=H.state.pointShadow,De.hemisphereLights.value=H.state.hemi,De.directionalShadowMatrix.value=H.state.directionalShadowMatrix,De.spotLightMatrix.value=H.state.spotLightMatrix,De.spotLightMap.value=H.state.spotLightMap,De.pointShadowMatrix.value=H.state.pointShadowMatrix),B.lightProbeGrid=b.state.lightProbeGridArray.length>0,B.currentProgram=We,B.uniformsList=null,We}function Ph(S){if(S.uniformsList===null){const U=S.currentProgram.getUniforms();S.uniformsList=Za.seqWithValue(U.seq,S.uniforms)}return S.uniformsList}function Ih(S,U){const V=k.get(S);V.outputColorSpace=U.outputColorSpace,V.batching=U.batching,V.batchingColor=U.batchingColor,V.instancing=U.instancing,V.instancingColor=U.instancingColor,V.instancingMorph=U.instancingMorph,V.skinning=U.skinning,V.morphTargets=U.morphTargets,V.morphNormals=U.morphNormals,V.morphColors=U.morphColors,V.morphTargetsCount=U.morphTargetsCount,V.numClippingPlanes=U.numClippingPlanes,V.numIntersection=U.numClipIntersection,V.vertexAlphas=U.vertexAlphas,V.vertexTangents=U.vertexTangents,V.toneMapping=U.toneMapping}function Of(S,U){if(S.length===0)return null;if(S.length===1)return S[0].texture!==null?S[0]:null;M.setFromMatrixPosition(U.matrixWorld);for(let V=0,B=S.length;V<B;V++){const H=S[V];if(H.texture!==null&&H.boundingBox.containsPoint(M))return H}return null}function Ff(S,U,V,B,H){U.isScene!==!0&&(U=pt),K.resetTextureUnits();const me=U.fog,xe=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?U.environment:null,pe=$===null?C.outputColorSpace:$.isXRRenderTarget===!0?$.texture.colorSpace:$e.workingColorSpace,Ee=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Re=se.get(B.envMap||xe,Ee),Ge=B.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,We=!!V.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),De=!!V.morphAttributes.position,rt=!!V.morphAttributes.normal,bt=!!V.morphAttributes.color;let St=ei;B.toneMapped&&($===null||$.isXRRenderTarget===!0)&&(St=C.toneMapping);const ot=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,Wt=ot!==void 0?ot.length:0,ve=k.get(B),dn=b.state.lights;if(Ne===!0&&(Ue===!0||S!==j)){const ht=S===j&&B.id===te;Pe.setState(B,S,ht)}let Je=!1;B.version===ve.__version?(ve.needsLights&&ve.lightsStateVersion!==dn.state.version||ve.outputColorSpace!==pe||H.isBatchedMesh&&ve.batching===!1||!H.isBatchedMesh&&ve.batching===!0||H.isBatchedMesh&&ve.batchingColor===!0&&H.colorTexture===null||H.isBatchedMesh&&ve.batchingColor===!1&&H.colorTexture!==null||H.isInstancedMesh&&ve.instancing===!1||!H.isInstancedMesh&&ve.instancing===!0||H.isSkinnedMesh&&ve.skinning===!1||!H.isSkinnedMesh&&ve.skinning===!0||H.isInstancedMesh&&ve.instancingColor===!0&&H.instanceColor===null||H.isInstancedMesh&&ve.instancingColor===!1&&H.instanceColor!==null||H.isInstancedMesh&&ve.instancingMorph===!0&&H.morphTexture===null||H.isInstancedMesh&&ve.instancingMorph===!1&&H.morphTexture!==null||ve.envMap!==Re||B.fog===!0&&ve.fog!==me||ve.numClippingPlanes!==void 0&&(ve.numClippingPlanes!==Pe.numPlanes||ve.numIntersection!==Pe.numIntersection)||ve.vertexAlphas!==Ge||ve.vertexTangents!==We||ve.morphTargets!==De||ve.morphNormals!==rt||ve.morphColors!==bt||ve.toneMapping!==St||ve.morphTargetsCount!==Wt||!!ve.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(Je=!0):(Je=!0,ve.__version=B.version);let Mn=ve.currentProgram;Je===!0&&(Mn=qr(B,U,H),I&&B.isNodeMaterial&&I.onUpdateProgram(B,Mn,ve));let Bn=!1,vi=!1,ms=!1;const ct=Mn.getUniforms(),Tt=ve.uniforms;if(v.useProgram(Mn.program)&&(Bn=!0,vi=!0,ms=!0),B.id!==te&&(te=B.id,vi=!0),ve.needsLights){const ht=Of(b.state.lightProbeGridArray,H);ve.lightProbeGrid!==ht&&(ve.lightProbeGrid=ht,vi=!0)}if(Bn||j!==S){v.buffers.depth.getReversed()&&S.reversedDepth!==!0&&(S._reversedDepth=!0,S.updateProjectionMatrix()),ct.setValue(N,"projectionMatrix",S.projectionMatrix),ct.setValue(N,"viewMatrix",S.matrixWorldInverse);const xi=ct.map.cameraPosition;xi!==void 0&&xi.setValue(N,tt.setFromMatrixPosition(S.matrixWorld)),w.logarithmicDepthBuffer&&ct.setValue(N,"logDepthBufFC",2/(Math.log(S.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&ct.setValue(N,"isOrthographic",S.isOrthographicCamera===!0),j!==S&&(j=S,vi=!0,ms=!0)}if(ve.needsLights&&(dn.state.directionalShadowMap.length>0&&ct.setValue(N,"directionalShadowMap",dn.state.directionalShadowMap,K),dn.state.spotShadowMap.length>0&&ct.setValue(N,"spotShadowMap",dn.state.spotShadowMap,K),dn.state.pointShadowMap.length>0&&ct.setValue(N,"pointShadowMap",dn.state.pointShadowMap,K)),H.isSkinnedMesh){ct.setOptional(N,H,"bindMatrix"),ct.setOptional(N,H,"bindMatrixInverse");const ht=H.skeleton;ht&&(ht.boneTexture===null&&ht.computeBoneTexture(),ct.setValue(N,"boneTexture",ht.boneTexture,K))}H.isBatchedMesh&&(ct.setOptional(N,H,"batchingTexture"),ct.setValue(N,"batchingTexture",H._matricesTexture,K),ct.setOptional(N,H,"batchingIdTexture"),ct.setValue(N,"batchingIdTexture",H._indirectTexture,K),ct.setOptional(N,H,"batchingColorTexture"),H._colorsTexture!==null&&ct.setValue(N,"batchingColorTexture",H._colorsTexture,K));const _i=V.morphAttributes;if((_i.position!==void 0||_i.normal!==void 0||_i.color!==void 0)&&P.update(H,V,Mn),(vi||ve.receiveShadow!==H.receiveShadow)&&(ve.receiveShadow=H.receiveShadow,ct.setValue(N,"receiveShadow",H.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&U.environment!==null&&(Tt.envMapIntensity.value=U.environmentIntensity),Tt.dfgLUT!==void 0&&(Tt.dfgLUT.value=Y_()),vi){if(ct.setValue(N,"toneMappingExposure",C.toneMappingExposure),ve.needsLights&&zf(Tt,ms),me&&B.fog===!0&&we.refreshFogUniforms(Tt,me),we.refreshMaterialUniforms(Tt,B,ne,re,b.state.transmissionRenderTarget[S.id]),ve.needsLights&&ve.lightProbeGrid){const ht=ve.lightProbeGrid;Tt.probesSH.value=ht.texture,Tt.probesMin.value.copy(ht.boundingBox.min),Tt.probesMax.value.copy(ht.boundingBox.max),Tt.probesResolution.value.copy(ht.resolution)}Za.upload(N,Ph(ve),Tt,K)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(Za.upload(N,Ph(ve),Tt,K),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&ct.setValue(N,"center",H.center),ct.setValue(N,"modelViewMatrix",H.modelViewMatrix),ct.setValue(N,"normalMatrix",H.normalMatrix),ct.setValue(N,"modelMatrix",H.matrixWorld),B.uniformsGroups!==void 0){const ht=B.uniformsGroups;for(let xi=0,gs=ht.length;xi<gs;xi++){const Lh=ht[xi];ee.update(Lh,Mn),ee.bind(Lh,Mn)}}return Mn}function zf(S,U){S.ambientLightColor.needsUpdate=U,S.lightProbe.needsUpdate=U,S.directionalLights.needsUpdate=U,S.directionalLightShadows.needsUpdate=U,S.pointLights.needsUpdate=U,S.pointLightShadows.needsUpdate=U,S.spotLights.needsUpdate=U,S.spotLightShadows.needsUpdate=U,S.rectAreaLights.needsUpdate=U,S.hemisphereLights.needsUpdate=U}function Bf(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 G},this.getRenderTarget=function(){return $},this.setRenderTargetTextures=function(S,U,V){const B=k.get(S);B.__autoAllocateDepthBuffer=S.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),k.get(S.texture).__webglTexture=U,k.get(S.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:V,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(S,U){const V=k.get(S);V.__webglFramebuffer=U,V.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(S,U=0,V=0){$=S,q=U,G=V;let B=null,H=!1,me=!1;if(S){const pe=k.get(S);if(pe.__useDefaultFramebuffer!==void 0){v.bindFramebuffer(N.FRAMEBUFFER,pe.__webglFramebuffer),ie.copy(S.viewport),ue.copy(S.scissor),He=S.scissorTest,v.viewport(ie),v.scissor(ue),v.setScissorTest(He),te=-1;return}else if(pe.__webglFramebuffer===void 0)K.setupRenderTarget(S);else if(pe.__hasExternalTextures)K.rebindTextures(S,k.get(S.texture).__webglTexture,k.get(S.depthTexture).__webglTexture);else if(S.depthBuffer){const Ge=S.depthTexture;if(pe.__boundDepthTexture!==Ge){if(Ge!==null&&k.has(Ge)&&(S.width!==Ge.image.width||S.height!==Ge.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");K.setupDepthRenderbuffer(S)}}const Ee=S.texture;(Ee.isData3DTexture||Ee.isDataArrayTexture||Ee.isCompressedArrayTexture)&&(me=!0);const Re=k.get(S).__webglFramebuffer;S.isWebGLCubeRenderTarget?(Array.isArray(Re[U])?B=Re[U][V]:B=Re[U],H=!0):S.samples>0&&K.useMultisampledRTT(S)===!1?B=k.get(S).__webglMultisampledFramebuffer:Array.isArray(Re)?B=Re[V]:B=Re,ie.copy(S.viewport),ue.copy(S.scissor),He=S.scissorTest}else ie.copy(Ce).multiplyScalar(ne).floor(),ue.copy(Te).multiplyScalar(ne).floor(),He=_e;if(V!==0&&(B=W),v.bindFramebuffer(N.FRAMEBUFFER,B)&&v.drawBuffers(S,B),v.viewport(ie),v.scissor(ue),v.setScissorTest(He),H){const pe=k.get(S.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+U,pe.__webglTexture,V)}else if(me){const pe=U;for(let Ee=0;Ee<S.textures.length;Ee++){const Re=k.get(S.textures[Ee]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+Ee,Re.__webglTexture,V,pe)}}else if(S!==null&&V!==0){const pe=k.get(S.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,pe.__webglTexture,V)}te=-1},this.readRenderTargetPixels=function(S,U,V,B,H,me,xe,pe=0){if(!(S&&S.isWebGLRenderTarget)){Ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ee=k.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&xe!==void 0&&(Ee=Ee[xe]),Ee){v.bindFramebuffer(N.FRAMEBUFFER,Ee);try{const Re=S.textures[pe],Ge=Re.format,We=Re.type;if(S.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+pe),!w.textureFormatReadable(Ge)){Ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!w.textureTypeReadable(We)){Ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=S.width-B&&V>=0&&V<=S.height-H&&N.readPixels(U,V,B,H,he.convert(Ge),he.convert(We),me)}finally{const Re=$!==null?k.get($).__webglFramebuffer:null;v.bindFramebuffer(N.FRAMEBUFFER,Re)}}},this.readRenderTargetPixelsAsync=async function(S,U,V,B,H,me,xe,pe=0){if(!(S&&S.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ee=k.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&xe!==void 0&&(Ee=Ee[xe]),Ee)if(U>=0&&U<=S.width-B&&V>=0&&V<=S.height-H){v.bindFramebuffer(N.FRAMEBUFFER,Ee);const Re=S.textures[pe],Ge=Re.format,We=Re.type;if(S.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+pe),!w.textureFormatReadable(Ge))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!w.textureTypeReadable(We))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const De=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,De),N.bufferData(N.PIXEL_PACK_BUFFER,me.byteLength,N.STREAM_READ),N.readPixels(U,V,B,H,he.convert(Ge),he.convert(We),0);const rt=$!==null?k.get($).__webglFramebuffer:null;v.bindFramebuffer(N.FRAMEBUFFER,rt);const bt=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await hm(N,bt,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,De),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,me),N.deleteBuffer(De),N.deleteSync(bt),me}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(S,U=null,V=0){const B=Math.pow(2,-V),H=Math.floor(S.image.width*B),me=Math.floor(S.image.height*B),xe=U!==null?U.x:0,pe=U!==null?U.y:0;K.setTexture2D(S,0),N.copyTexSubImage2D(N.TEXTURE_2D,V,0,0,xe,pe,H,me),v.unbindTexture()},this.copyTextureToTexture=function(S,U,V=null,B=null,H=0,me=0){let xe,pe,Ee,Re,Ge,We,De,rt,bt;const St=S.isCompressedTexture?S.mipmaps[me]:S.image;if(V!==null)xe=V.max.x-V.min.x,pe=V.max.y-V.min.y,Ee=V.isBox3?V.max.z-V.min.z:1,Re=V.min.x,Ge=V.min.y,We=V.isBox3?V.min.z:0;else{const Tt=Math.pow(2,-H);xe=Math.floor(St.width*Tt),pe=Math.floor(St.height*Tt),S.isDataArrayTexture?Ee=St.depth:S.isData3DTexture?Ee=Math.floor(St.depth*Tt):Ee=1,Re=0,Ge=0,We=0}B!==null?(De=B.x,rt=B.y,bt=B.z):(De=0,rt=0,bt=0);const ot=he.convert(U.format),Wt=he.convert(U.type);let ve;U.isData3DTexture?(K.setTexture3D(U,0),ve=N.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?(K.setTexture2DArray(U,0),ve=N.TEXTURE_2D_ARRAY):(K.setTexture2D(U,0),ve=N.TEXTURE_2D),v.activeTexture(N.TEXTURE0),v.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,U.flipY),v.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),v.pixelStorei(N.UNPACK_ALIGNMENT,U.unpackAlignment);const dn=v.getParameter(N.UNPACK_ROW_LENGTH),Je=v.getParameter(N.UNPACK_IMAGE_HEIGHT),Mn=v.getParameter(N.UNPACK_SKIP_PIXELS),Bn=v.getParameter(N.UNPACK_SKIP_ROWS),vi=v.getParameter(N.UNPACK_SKIP_IMAGES);v.pixelStorei(N.UNPACK_ROW_LENGTH,St.width),v.pixelStorei(N.UNPACK_IMAGE_HEIGHT,St.height),v.pixelStorei(N.UNPACK_SKIP_PIXELS,Re),v.pixelStorei(N.UNPACK_SKIP_ROWS,Ge),v.pixelStorei(N.UNPACK_SKIP_IMAGES,We);const ms=S.isDataArrayTexture||S.isData3DTexture,ct=U.isDataArrayTexture||U.isData3DTexture;if(S.isDepthTexture){const Tt=k.get(S),_i=k.get(U),ht=k.get(Tt.__renderTarget),xi=k.get(_i.__renderTarget);v.bindFramebuffer(N.READ_FRAMEBUFFER,ht.__webglFramebuffer),v.bindFramebuffer(N.DRAW_FRAMEBUFFER,xi.__webglFramebuffer);for(let gs=0;gs<Ee;gs++)ms&&(N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,k.get(S).__webglTexture,H,We+gs),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,k.get(U).__webglTexture,me,bt+gs)),N.blitFramebuffer(Re,Ge,xe,pe,De,rt,xe,pe,N.DEPTH_BUFFER_BIT,N.NEAREST);v.bindFramebuffer(N.READ_FRAMEBUFFER,null),v.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(H!==0||S.isRenderTargetTexture||k.has(S)){const Tt=k.get(S),_i=k.get(U);v.bindFramebuffer(N.READ_FRAMEBUFFER,X),v.bindFramebuffer(N.DRAW_FRAMEBUFFER,O);for(let ht=0;ht<Ee;ht++)ms?N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Tt.__webglTexture,H,We+ht):N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Tt.__webglTexture,H),ct?N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,_i.__webglTexture,me,bt+ht):N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,_i.__webglTexture,me),H!==0?N.blitFramebuffer(Re,Ge,xe,pe,De,rt,xe,pe,N.COLOR_BUFFER_BIT,N.NEAREST):ct?N.copyTexSubImage3D(ve,me,De,rt,bt+ht,Re,Ge,xe,pe):N.copyTexSubImage2D(ve,me,De,rt,Re,Ge,xe,pe);v.bindFramebuffer(N.READ_FRAMEBUFFER,null),v.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else ct?S.isDataTexture||S.isData3DTexture?N.texSubImage3D(ve,me,De,rt,bt,xe,pe,Ee,ot,Wt,St.data):U.isCompressedArrayTexture?N.compressedTexSubImage3D(ve,me,De,rt,bt,xe,pe,Ee,ot,St.data):N.texSubImage3D(ve,me,De,rt,bt,xe,pe,Ee,ot,Wt,St):S.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,me,De,rt,xe,pe,ot,Wt,St.data):S.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,me,De,rt,St.width,St.height,ot,St.data):N.texSubImage2D(N.TEXTURE_2D,me,De,rt,xe,pe,ot,Wt,St);v.pixelStorei(N.UNPACK_ROW_LENGTH,dn),v.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Je),v.pixelStorei(N.UNPACK_SKIP_PIXELS,Mn),v.pixelStorei(N.UNPACK_SKIP_ROWS,Bn),v.pixelStorei(N.UNPACK_SKIP_IMAGES,vi),me===0&&U.generateMipmaps&&N.generateMipmap(ve),v.unbindTexture()},this.initRenderTarget=function(S){k.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),v.unbindTexture()},this.resetState=function(){q=0,G=0,$=null,v.reset(),ge.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Jn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=$e._getDrawingBufferColorSpace(e),t.unpackColorSpace=$e._getUnpackColorSpace()}}const Ao=`
4444
+ }`;class KM{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new Wf(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Tt({vertexShader:qM,fragmentShader:YM,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Qe(new $i(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class $M extends ys{constructor(e,t){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 KM,p={},b=t.getContextAttributes();let w=null,M=null;const S=[],A=[],R=new Ie;let _=null;const E=new dn;E.viewport=new lt;const C=new dn;C.viewport=new lt;const D=[E,C],I=new Z1;let V=null,q=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let re=S[Y];return re===void 0&&(re=new fc,S[Y]=re),re.getTargetRaySpace()},this.getControllerGrip=function(Y){let re=S[Y];return re===void 0&&(re=new fc,S[Y]=re),re.getGripSpace()},this.getHand=function(Y){let re=S[Y];return re===void 0&&(re=new fc,S[Y]=re),re.getHandSpace()};function U(Y){const re=A.indexOf(Y.inputSource);if(re===-1)return;const ne=S[re];ne!==void 0&&(ne.update(Y.inputSource,Y.frame,l||a),ne.dispatchEvent({type:Y.type,data:Y.inputSource}))}function X(){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",X),s.removeEventListener("inputsourceschange",G);for(let Y=0;Y<S.length;Y++){const re=A[Y];re!==null&&(A[Y]=null,S[Y].disconnect(re))}V=null,q=null,m.reset();for(const Y in p)delete p[Y];e.setRenderTarget(w),f=null,d=null,u=null,s=null,M=null,ke.stop(),n.isPresenting=!1,e.setPixelRatio(_),e.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){r=Y,n.isPresenting===!0&&Ae("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,n.isPresenting===!0&&Ae("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,t)),u},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(Y){if(s=Y,s!==null){if(w=e.getRenderTarget(),s.addEventListener("select",U),s.addEventListener("selectstart",U),s.addEventListener("selectend",U),s.addEventListener("squeeze",U),s.addEventListener("squeezestart",U),s.addEventListener("squeezeend",U),s.addEventListener("end",X),s.addEventListener("inputsourceschange",G),b.xrCompatible!==!0&&await t.makeXRCompatible(),_=e.getPixelRatio(),e.getSize(R),x&&"createProjectionLayer"in XRWebGLBinding.prototype){let ne=null,z=null,be=null;b.depth&&(be=b.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ne=b.stencil?us:Si,z=b.stencil?na:Hn);const Pe={colorFormat:t.RGBA8,depthFormat:be,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(Pe),s.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),M=new fn(d.textureWidth,d.textureHeight,{format:an,type:yn,depthTexture:new vs(d.textureWidth,d.textureHeight,z,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:b.stencil,colorSpace:e.outputColorSpace,samples:b.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const ne={antialias:b.antialias,alpha:!0,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(s,t,ne),s.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),M=new fn(f.framebufferWidth,f.framebufferHeight,{format:an,type:yn,colorSpace:e.outputColorSpace,stencilBuffer:b.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await s.requestReferenceSpace(o),ke.setContext(s),ke.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function G(Y){for(let re=0;re<Y.removed.length;re++){const ne=Y.removed[re],z=A.indexOf(ne);z>=0&&(A[z]=null,S[z].disconnect(ne))}for(let re=0;re<Y.added.length;re++){const ne=Y.added[re];let z=A.indexOf(ne);if(z===-1){for(let Pe=0;Pe<S.length;Pe++)if(Pe>=A.length){A.push(ne),z=Pe;break}else if(A[Pe]===null){A[Pe]=ne,z=Pe;break}if(z===-1)break}const be=S[z];be&&be.connect(ne)}}const Z=new P,te=new P;function j(Y,re,ne){Z.setFromMatrixPosition(re.matrixWorld),te.setFromMatrixPosition(ne.matrixWorld);const z=Z.distanceTo(te),be=re.projectionMatrix.elements,Pe=ne.projectionMatrix.elements,Te=be[14]/(be[10]-1),xe=be[14]/(be[10]+1),Ne=(be[9]+1)/be[5],Ue=(be[9]-1)/be[5],Oe=(be[8]-1)/be[0],tt=(Pe[8]+1)/Pe[0],nt=Te*Oe,Mt=Te*tt,gt=z/(-Oe+tt),yt=gt*-Oe;if(re.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(yt),Y.translateZ(gt),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),be[10]===-1)Y.projectionMatrix.copy(re.projectionMatrix),Y.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{const It=Te+gt,N=xe+gt,cn=nt-yt,it=Mt+(z-yt),T=Ne*xe/N*It,v=Ue*xe/N*It;Y.projectionMatrix.makePerspective(cn,it,T,v,It,N),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function ie(Y,re){re===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(re.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(s===null)return;let re=Y.near,ne=Y.far;m.texture!==null&&(m.depthNear>0&&(re=m.depthNear),m.depthFar>0&&(ne=m.depthFar)),I.near=C.near=E.near=re,I.far=C.far=E.far=ne,(V!==I.near||q!==I.far)&&(s.updateRenderState({depthNear:I.near,depthFar:I.far}),V=I.near,q=I.far),I.layers.mask=Y.layers.mask|6,E.layers.mask=I.layers.mask&-5,C.layers.mask=I.layers.mask&-3;const z=Y.parent,be=I.cameras;ie(I,z);for(let Pe=0;Pe<be.length;Pe++)ie(be[Pe],z);be.length===2?j(I,E,C):I.projectionMatrix.copy(E.projectionMatrix),ue(Y,I,z)};function ue(Y,re,ne){ne===null?Y.matrix.copy(re.matrixWorld):(Y.matrix.copy(ne.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(re.matrixWorld)),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(re.projectionMatrix),Y.projectionMatrixInverse.copy(re.projectionMatrixInverse),Y.isPerspectiveCamera&&(Y.fov=dr*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 He=null;function Ze(Y,re){if(h=re.getViewerPose(l||a),g=re,h!==null){const ne=h.views;f!==null&&(e.setRenderTargetFramebuffer(M,f.framebuffer),e.setRenderTarget(M));let z=!1;ne.length!==I.cameras.length&&(I.cameras.length=0,z=!0);for(let xe=0;xe<ne.length;xe++){const Ne=ne[xe];let Ue=null;if(f!==null)Ue=f.getViewport(Ne);else{const tt=u.getViewSubImage(d,Ne);Ue=tt.viewport,xe===0&&(e.setRenderTargetTextures(M,tt.colorTexture,tt.depthStencilTexture),e.setRenderTarget(M))}let Oe=D[xe];Oe===void 0&&(Oe=new dn,Oe.layers.enable(xe),Oe.viewport=new lt,D[xe]=Oe),Oe.matrix.fromArray(Ne.transform.matrix),Oe.matrix.decompose(Oe.position,Oe.quaternion,Oe.scale),Oe.projectionMatrix.fromArray(Ne.projectionMatrix),Oe.projectionMatrixInverse.copy(Oe.projectionMatrix).invert(),Oe.viewport.set(Ue.x,Ue.y,Ue.width,Ue.height),xe===0&&(I.matrix.copy(Oe.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),z===!0&&I.cameras.push(Oe)}const be=s.enabledFeatures;if(be&&be.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&x){u=n.getBinding();const xe=u.getDepthInformation(ne[0]);xe&&xe.isValid&&xe.texture&&m.init(xe,s.renderState)}if(be&&be.includes("camera-access")&&x){e.state.unbindTexture(),u=n.getBinding();for(let xe=0;xe<ne.length;xe++){const Ne=ne[xe].camera;if(Ne){let Ue=p[Ne];Ue||(Ue=new Wf,p[Ne]=Ue);const Oe=u.getCameraImage(Ne);Ue.sourceTexture=Oe}}}}for(let ne=0;ne<S.length;ne++){const z=A[ne],be=S[ne];z!==null&&be!==void 0&&be.update(z,re,l||a)}He&&He(Y,re),re.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:re}),g=null}const ke=new Zf;ke.setAnimationLoop(Ze),this.setAnimationLoop=function(Y){He=Y},this.dispose=function(){}}}const ZM=new qe,ip=new Be;ip.set(-1,0,0,0,1,0,0,0,1);function JM(i,e){function t(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,Xf(i)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function s(m,p,b,w,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,b,w):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,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,t(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===Ut&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,t(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===Ut&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,t(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,t(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);const b=e.get(p),w=b.envMap,M=b.envMapRotation;w&&(m.envMap.value=w,m.envMapRotation.value.setFromMatrix4(ZM.makeRotationFromEuler(M)).transpose(),w.isCubeTexture&&w.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(ip),m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,m.aoMapTransform))}function a(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform))}function o(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function c(m,p,b,w){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*b,m.scale.value=w*.5,p.map&&(m.map.value=p.map,t(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function 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,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function h(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function u(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function d(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,b){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===Ut&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function x(m,p){const b=e.get(p).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function QM(i,e,t,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,S){const A=S.program;n.uniformBlockBinding(M,A)}function l(M,S){let A=s[M.id];A===void 0&&(m(M),A=h(M),s[M.id]=A,M.addEventListener("dispose",b));const R=S.program;n.updateUBOMapping(M,R);const _=e.render.frame;r[M.id]!==_&&(d(M),r[M.id]=_)}function h(M){const S=u();M.__bindingPointIndex=S;const A=i.createBuffer(),R=M.__size,_=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,A),i.bufferData(i.UNIFORM_BUFFER,R,_),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,S,A),A}function u(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.push(M),M;return ze("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(M){const S=s[M.id],A=M.uniforms,R=M.__cache;i.bindBuffer(i.UNIFORM_BUFFER,S);for(let _=0,E=A.length;_<E;_++){const C=A[_];if(Array.isArray(C))for(let D=0,I=C.length;D<I;D++)f(C[D],_,D,R);else f(C,_,0,R)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function f(M,S,A,R){if(x(M,S,A,R)===!0){const _=M.__offset,E=M.value;if(Array.isArray(E)){let C=0;for(let D=0;D<E.length;D++){const I=E[D],V=p(I);g(I,M.__data,C),typeof I!="number"&&typeof I!="boolean"&&!I.isMatrix3&&!ArrayBuffer.isView(I)&&(C+=V.storage/Float32Array.BYTES_PER_ELEMENT)}}else g(E,M.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,_,M.__data)}}function g(M,S,A){typeof M=="number"||typeof M=="boolean"?S[0]=M:M.isMatrix3?(S[0]=M.elements[0],S[1]=M.elements[1],S[2]=M.elements[2],S[3]=0,S[4]=M.elements[3],S[5]=M.elements[4],S[6]=M.elements[5],S[7]=0,S[8]=M.elements[6],S[9]=M.elements[7],S[10]=M.elements[8],S[11]=0):ArrayBuffer.isView(M)?S.set(new M.constructor(M.buffer,M.byteOffset,S.length)):M.toArray(S,A)}function x(M,S,A,R){const _=M.value,E=S+"_"+A;if(R[E]===void 0)return typeof _=="number"||typeof _=="boolean"?R[E]=_:ArrayBuffer.isView(_)?R[E]=_.slice():R[E]=_.clone(),!0;{const C=R[E];if(typeof _=="number"||typeof _=="boolean"){if(C!==_)return R[E]=_,!0}else{if(ArrayBuffer.isView(_))return!0;if(C.equals(_)===!1)return C.copy(_),!0}}return!1}function m(M){const S=M.uniforms;let A=0;const R=16;for(let E=0,C=S.length;E<C;E++){const D=Array.isArray(S[E])?S[E]:[S[E]];for(let I=0,V=D.length;I<V;I++){const q=D[I],U=Array.isArray(q.value)?q.value:[q.value];for(let X=0,G=U.length;X<G;X++){const Z=U[X],te=p(Z),j=A%R,ie=j%te.boundary,ue=j+ie;A+=ie,ue!==0&&R-ue<te.storage&&(A+=R-ue),q.__data=new Float32Array(te.storage/Float32Array.BYTES_PER_ELEMENT),q.__offset=A,A+=te.storage}}}const _=A%R;return _>0&&(A+=R-_),M.__size=A,M.__cache={},this}function p(M){const S={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(S.boundary=4,S.storage=4):M.isVector2?(S.boundary=8,S.storage=8):M.isVector3||M.isColor?(S.boundary=16,S.storage=12):M.isVector4?(S.boundary=16,S.storage=16):M.isMatrix3?(S.boundary=48,S.storage=48):M.isMatrix4?(S.boundary=64,S.storage=64):M.isTexture?Ae("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(S.boundary=16,S.storage=M.byteLength):Ae("WebGLRenderer: Unsupported uniform value type.",M),S}function b(M){const S=M.target;S.removeEventListener("dispose",b);const A=a.indexOf(S.__bindingPointIndex);a.splice(A,1),i.deleteBuffer(s[S.id]),delete s[S.id],delete r[S.id]}function w(){for(const M in s)i.deleteBuffer(s[M]);a=[],s={},r={}}return{bind:c,update:l,dispose:w}}const jM=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 Yn=null;function e3(){return Yn===null&&(Yn=new gr(jM,16,16,ms,jt),Yn.name="DFG_LUT",Yn.minFilter=At,Yn.magFilter=At,Yn.wrapS=rn,Yn.wrapT=rn,Yn.generateMipmaps=!1,Yn.needsUpdate=!0),Yn}class t3{constructor(e={}){const{canvas:t=wg(),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=yn}=e;this.isWebGLRenderer=!0;let g;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=n.getContextAttributes().alpha}else g=a;const x=f,m=new Set([Vh,Gh,Hh]),p=new Set([yn,Hn,ta,na,zh,Bh]),b=new Uint32Array(4),w=new Int32Array(4),M=new P;let S=null,A=null;const R=[],_=[];let E=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=si,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let D=!1,I=null,V=null,q=null,U=null;this._outputColorSpace=Tn;let X=0,G=0,Z=null,te=-1,j=null;const ie=new lt,ue=new lt;let He=null;const Ze=new ve(0);let ke=0,Y=t.width,re=t.height,ne=1,z=null,be=null;const Pe=new lt(0,0,Y,re),Te=new lt(0,0,Y,re);let xe=!1;const Ne=new Zh;let Ue=!1,Oe=!1;const tt=new qe,nt=new P,Mt=new lt,gt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let yt=!1;function It(){return Z===null?ne:1}let N=n;function cn(y,O){return t.getContext(y,O)}try{const y={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Uh}`),t.addEventListener("webglcontextlost",St,!1),t.addEventListener("webglcontextrestored",ft,!1),t.addEventListener("webglcontextcreationerror",Vn,!1),N===null){const O="webgl2";if(N=cn(O,y),N===null)throw cn(O)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(y){throw ze("WebGLRenderer: "+y.message),y}let it,T,v,F,H,K,se,oe,$,Q,ce,Re,de,le,Le,Fe,Ge,L,ae,J,he,ge,ee;function we(){it=new ex(N),it.init(),he=new XM(N,it),T=new q_(N,it,e,he),v=new VM(N,it),T.reversedDepthBuffer&&d&&v.buffers.depth.setReversed(!0),V=N.createFramebuffer(),q=N.createFramebuffer(),U=N.createFramebuffer(),F=new ix(N),H=new DM,K=new WM(N,it,v,H,T,he,F),se=new j_(C),oe=new o2(N),ge=new W_(N,oe),$=new tx(N,oe,F,ge),Q=new rx(N,$,oe,ge,F),L=new sx(N,T,K),Le=new Y_(H),ce=new RM(C,se,it,T,ge,Le),Re=new JM(C,H),de=new PM,le=new FM(it),Ge=new V_(C,se,v,Q,g,c),Fe=new GM(C,Q,T),ee=new QM(N,F,T,v),ae=new X_(N,it,F),J=new nx(N,it,F),F.programs=ce.programs,C.capabilities=T,C.extensions=it,C.properties=H,C.renderLists=de,C.shadowMap=Fe,C.state=v,C.info=F}we(),x!==yn&&(E=new ox(x,t.width,t.height,o,s,r));const ye=new $M(C,N);this.xr=ye,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){const y=it.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){const y=it.get("WEBGL_lose_context");y&&y.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(y){y!==void 0&&(ne=y,this.setSize(Y,re,!1))},this.getSize=function(y){return y.set(Y,re)},this.setSize=function(y,O,W=!0){if(ye.isPresenting){Ae("WebGLRenderer: Can't change size while VR device is presenting.");return}Y=y,re=O,t.width=Math.floor(y*ne),t.height=Math.floor(O*ne),W===!0&&(t.style.width=y+"px",t.style.height=O+"px"),E!==null&&E.setSize(t.width,t.height),this.setViewport(0,0,y,O)},this.getDrawingBufferSize=function(y){return y.set(Y*ne,re*ne).floor()},this.setDrawingBufferSize=function(y,O,W){Y=y,re=O,ne=W,t.width=Math.floor(y*W),t.height=Math.floor(O*W),this.setViewport(0,0,y,O)},this.setEffects=function(y){if(x===yn){ze("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(y){for(let O=0;O<y.length;O++)if(y[O].isOutputPass===!0){Ae("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}E.setEffects(y||[])},this.getCurrentViewport=function(y){return y.copy(ie)},this.getViewport=function(y){return y.copy(Pe)},this.setViewport=function(y,O,W,B){y.isVector4?Pe.set(y.x,y.y,y.z,y.w):Pe.set(y,O,W,B),v.viewport(ie.copy(Pe).multiplyScalar(ne).round())},this.getScissor=function(y){return y.copy(Te)},this.setScissor=function(y,O,W,B){y.isVector4?Te.set(y.x,y.y,y.z,y.w):Te.set(y,O,W,B),v.scissor(ue.copy(Te).multiplyScalar(ne).round())},this.getScissorTest=function(){return xe},this.setScissorTest=function(y){v.setScissorTest(xe=y)},this.setOpaqueSort=function(y){z=y},this.setTransparentSort=function(y){be=y},this.getClearColor=function(y){return y.copy(Ge.getClearColor())},this.setClearColor=function(){Ge.setClearColor(...arguments)},this.getClearAlpha=function(){return Ge.getClearAlpha()},this.setClearAlpha=function(){Ge.setClearAlpha(...arguments)},this.clear=function(y=!0,O=!0,W=!0){let B=0;if(y){let k=!1;if(Z!==null){const me=Z.texture.format;k=m.has(me)}if(k){const me=Z.texture.type,Me=p.has(me),pe=Ge.getClearColor(),Ee=Ge.getClearAlpha(),De=pe.r,Ve=pe.g,Xe=pe.b;Me?(b[0]=De,b[1]=Ve,b[2]=Xe,b[3]=Ee,N.clearBufferuiv(N.COLOR,0,b)):(w[0]=De,w[1]=Ve,w[2]=Xe,w[3]=Ee,N.clearBufferiv(N.COLOR,0,w))}else B|=N.COLOR_BUFFER_BIT}O&&(B|=N.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),W&&(B|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B!==0&&N.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(y){y.setRenderer(this),I=y},this.dispose=function(){t.removeEventListener("webglcontextlost",St,!1),t.removeEventListener("webglcontextrestored",ft,!1),t.removeEventListener("webglcontextcreationerror",Vn,!1),Ge.dispose(),de.dispose(),le.dispose(),H.dispose(),se.dispose(),Q.dispose(),ge.dispose(),ee.dispose(),ce.dispose(),ye.dispose(),ye.removeEventListener("sessionstart",du),ye.removeEventListener("sessionend",fu),Zi.stop()};function St(y){y.preventDefault(),Io("WebGLRenderer: Context Lost."),D=!0}function ft(){Io("WebGLRenderer: Context Restored."),D=!1;const y=F.autoReset,O=Fe.enabled,W=Fe.autoUpdate,B=Fe.needsUpdate,k=Fe.type;we(),F.autoReset=y,Fe.enabled=O,Fe.autoUpdate=W,Fe.needsUpdate=B,Fe.type=k}function Vn(y){ze("WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function Wn(y){const O=y.target;O.removeEventListener("dispose",Wn),Yp(O)}function Yp(y){Kp(y),H.remove(y)}function Kp(y){const O=H.get(y).programs;O!==void 0&&(O.forEach(function(W){ce.releaseProgram(W)}),y.isShaderMaterial&&ce.releaseShaderCache(y))}this.renderBufferDirect=function(y,O,W,B,k,me){O===null&&(O=gt);const Me=k.isMesh&&k.matrixWorld.determinantAffine()<0,pe=Jp(y,O,W,B,k);v.setMaterial(B,Me);let Ee=W.index,De=1;if(B.wireframe===!0){if(Ee=$.getWireframeAttribute(W),Ee===void 0)return;De=2}const Ve=W.drawRange,Xe=W.attributes.position;let Ce=Ve.start*De,ot=(Ve.start+Ve.count)*De;me!==null&&(Ce=Math.max(Ce,me.start*De),ot=Math.min(ot,(me.start+me.count)*De)),Ee!==null?(Ce=Math.max(Ce,0),ot=Math.min(ot,Ee.count)):Xe!=null&&(Ce=Math.max(Ce,0),ot=Math.min(ot,Xe.count));const Rt=ot-Ce;if(Rt<0||Rt===1/0)return;ge.setup(k,B,pe,W,Ee);let Et,ht=ae;if(Ee!==null&&(Et=oe.get(Ee),ht=J,ht.setIndex(Et)),k.isMesh)B.wireframe===!0?(v.setLineWidth(B.wireframeLinewidth*It()),ht.setMode(N.LINES)):ht.setMode(N.TRIANGLES);else if(k.isLine){let qt=B.linewidth;qt===void 0&&(qt=1),v.setLineWidth(qt*It()),k.isLineSegments?ht.setMode(N.LINES):k.isLineLoop?ht.setMode(N.LINE_LOOP):ht.setMode(N.LINE_STRIP)}else k.isPoints?ht.setMode(N.POINTS):k.isSprite&&ht.setMode(N.TRIANGLES);if(k.isBatchedMesh)if(it.get("WEBGL_multi_draw"))ht.renderMultiDraw(k._multiDrawStarts,k._multiDrawCounts,k._multiDrawCount);else{const qt=k._multiDrawStarts,_e=k._multiDrawCounts,pn=k._multiDrawCount,je=Ee?oe.get(Ee).bytesPerElement:1,En=H.get(B).currentProgram.getUniforms();for(let Xn=0;Xn<pn;Xn++)En.setValue(N,"_gl_DrawID",Xn),ht.render(qt[Xn]/je,_e[Xn])}else if(k.isInstancedMesh)ht.renderInstances(Ce,Rt,k.count);else if(W.isInstancedBufferGeometry){const qt=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,_e=Math.min(W.instanceCount,qt);ht.renderInstances(Ce,Rt,_e)}else ht.render(Ce,Rt)};function uu(y,O,W){y.transparent===!0&&y.side===Fn&&y.forceSinglePass===!1?(y.side=Ut,y.needsUpdate=!0,fa(y,O,W),y.side=qi,y.needsUpdate=!0,fa(y,O,W),y.side=Fn):fa(y,O,W)}this.compile=function(y,O,W=null){W===null&&(W=y),A=le.get(W),A.init(O),_.push(A),W.traverseVisible(function(k){k.isLight&&k.layers.test(O.layers)&&(A.pushLight(k),k.castShadow&&A.pushShadow(k))}),y!==W&&y.traverseVisible(function(k){k.isLight&&k.layers.test(O.layers)&&(A.pushLight(k),k.castShadow&&A.pushShadow(k))}),A.setupLights();const B=new Set;return y.traverse(function(k){if(!(k.isMesh||k.isPoints||k.isLine||k.isSprite))return;const me=k.material;if(me)if(Array.isArray(me))for(let Me=0;Me<me.length;Me++){const pe=me[Me];uu(pe,W,k),B.add(pe)}else uu(me,W,k),B.add(me)}),A=_.pop(),B},this.compileAsync=function(y,O,W=null){const B=this.compile(y,O,W);return new Promise(k=>{function me(){if(B.forEach(function(Me){H.get(Me).currentProgram.isReady()&&B.delete(Me)}),B.size===0){k(y);return}setTimeout(me,10)}it.get("KHR_parallel_shader_compile")!==null?me():setTimeout(me,10)})};let tc=null;function $p(y){tc&&tc(y)}function du(){Zi.stop()}function fu(){Zi.start()}const Zi=new Zf;Zi.setAnimationLoop($p),typeof self<"u"&&Zi.setContext(self),this.setAnimationLoop=function(y){tc=y,ye.setAnimationLoop(y),y===null?Zi.stop():Zi.start()},ye.addEventListener("sessionstart",du),ye.addEventListener("sessionend",fu),this.render=function(y,O){if(O!==void 0&&O.isCamera!==!0){ze("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;I!==null&&I.renderStart(y,O);const W=ye.enabled===!0&&ye.isPresenting===!0,B=E!==null&&(Z===null||W)&&E.begin(C,Z);if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),O.parent===null&&O.matrixWorldAutoUpdate===!0&&O.updateMatrixWorld(),ye.enabled===!0&&ye.isPresenting===!0&&(E===null||E.isCompositing()===!1)&&(ye.cameraAutoUpdate===!0&&ye.updateCamera(O),O=ye.getCamera()),y.isScene===!0&&y.onBeforeRender(C,y,O,Z),A=le.get(y,_.length),A.init(O),A.state.textureUnits=K.getTextureUnits(),_.push(A),tt.multiplyMatrices(O.projectionMatrix,O.matrixWorldInverse),Ne.setFromProjectionMatrix(tt,ti,O.reversedDepth),Oe=this.localClippingEnabled,Ue=Le.init(this.clippingPlanes,Oe),S=de.get(y,R.length),S.init(),R.push(S),ye.enabled===!0&&ye.isPresenting===!0){const Me=C.xr.getDepthSensingMesh();Me!==null&&nc(Me,O,-1/0,C.sortObjects)}nc(y,O,0,C.sortObjects),S.finish(),C.sortObjects===!0&&S.sort(z,be,O.reversedDepth),yt=ye.enabled===!1||ye.isPresenting===!1||ye.hasDepthSensing()===!1,yt&&Ge.addToRenderList(S,y),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Ue===!0&&Le.beginShadows();const k=A.state.shadowsArray;if(Fe.render(k,y,O),Ue===!0&&Le.endShadows(),(B&&E.hasRenderPass())===!1){const Me=S.opaque,pe=S.transmissive;if(A.setupLights(),O.isArrayCamera){const Ee=O.cameras;if(pe.length>0)for(let De=0,Ve=Ee.length;De<Ve;De++){const Xe=Ee[De];mu(Me,pe,y,Xe)}yt&&Ge.render(y);for(let De=0,Ve=Ee.length;De<Ve;De++){const Xe=Ee[De];pu(S,y,Xe,Xe.viewport)}}else pe.length>0&&mu(Me,pe,y,O),yt&&Ge.render(y),pu(S,y,O)}Z!==null&&G===0&&(K.updateMultisampleRenderTarget(Z),K.updateRenderTargetMipmap(Z)),B&&E.end(C),y.isScene===!0&&y.onAfterRender(C,y,O),ge.resetDefaultState(),te=-1,j=null,_.pop(),_.length>0?(A=_[_.length-1],K.setTextureUnits(A.state.textureUnits),Ue===!0&&Le.setGlobalState(C.clippingPlanes,A.state.camera)):A=null,R.pop(),R.length>0?S=R[R.length-1]:S=null,I!==null&&I.renderEnd()};function nc(y,O,W,B){if(y.visible===!1)return;if(y.layers.test(O.layers)){if(y.isGroup)W=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(O);else if(y.isLightProbeGrid)A.pushLightProbeGrid(y);else if(y.isLight)A.pushLight(y),y.castShadow&&A.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||Ne.intersectsSprite(y)){B&&Mt.setFromMatrixPosition(y.matrixWorld).applyMatrix4(tt);const Me=Q.update(y),pe=y.material;pe.visible&&S.push(y,Me,pe,W,Mt.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||Ne.intersectsObject(y))){const Me=Q.update(y),pe=y.material;if(B&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),Mt.copy(y.boundingSphere.center)):(Me.boundingSphere===null&&Me.computeBoundingSphere(),Mt.copy(Me.boundingSphere.center)),Mt.applyMatrix4(y.matrixWorld).applyMatrix4(tt)),Array.isArray(pe)){const Ee=Me.groups;for(let De=0,Ve=Ee.length;De<Ve;De++){const Xe=Ee[De],Ce=pe[Xe.materialIndex];Ce&&Ce.visible&&S.push(y,Me,Ce,W,Mt.z,Xe)}}else pe.visible&&S.push(y,Me,pe,W,Mt.z,null)}}const me=y.children;for(let Me=0,pe=me.length;Me<pe;Me++)nc(me[Me],O,W,B)}function pu(y,O,W,B){const{opaque:k,transmissive:me,transparent:Me}=y;A.setupLightsView(W),Ue===!0&&Le.setGlobalState(C.clippingPlanes,W),B&&v.viewport(ie.copy(B)),k.length>0&&da(k,O,W),me.length>0&&da(me,O,W),Me.length>0&&da(Me,O,W),v.buffers.depth.setTest(!0),v.buffers.depth.setMask(!0),v.buffers.color.setMask(!0),v.setPolygonOffset(!1)}function mu(y,O,W,B){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(A.state.transmissionRenderTarget[B.id]===void 0){const Ce=it.has("EXT_color_buffer_half_float")||it.has("EXT_color_buffer_float");A.state.transmissionRenderTarget[B.id]=new fn(1,1,{generateMipmaps:!0,type:Ce?jt:yn,minFilter:hs,samples:Math.max(4,T.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Je.workingColorSpace})}const me=A.state.transmissionRenderTarget[B.id],Me=B.viewport||ie;me.setSize(Me.z*C.transmissionResolutionScale,Me.w*C.transmissionResolutionScale);const pe=C.getRenderTarget(),Ee=C.getActiveCubeFace(),De=C.getActiveMipmapLevel();C.setRenderTarget(me),C.getClearColor(Ze),ke=C.getClearAlpha(),ke<1&&C.setClearColor(16777215,.5),C.clear(),yt&&Ge.render(W);const Ve=C.toneMapping;C.toneMapping=si;const Xe=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),A.setupLightsView(B),Ue===!0&&Le.setGlobalState(C.clippingPlanes,B),da(y,W,B),K.updateMultisampleRenderTarget(me),K.updateRenderTargetMipmap(me),it.has("WEBGL_multisampled_render_to_texture")===!1){let Ce=!1;for(let ot=0,Rt=O.length;ot<Rt;ot++){const Et=O[ot],{object:ht,geometry:qt,material:_e,group:pn}=Et;if(_e.side===Fn&&ht.layers.test(B.layers)){const je=_e.side;_e.side=Ut,_e.needsUpdate=!0,gu(ht,W,B,qt,_e,pn),_e.side=je,_e.needsUpdate=!0,Ce=!0}}Ce===!0&&(K.updateMultisampleRenderTarget(me),K.updateRenderTargetMipmap(me))}C.setRenderTarget(pe,Ee,De),C.setClearColor(Ze,ke),Xe!==void 0&&(B.viewport=Xe),C.toneMapping=Ve}function da(y,O,W){const B=O.isScene===!0?O.overrideMaterial:null;for(let k=0,me=y.length;k<me;k++){const Me=y[k],{object:pe,geometry:Ee,group:De}=Me;let Ve=Me.material;Ve.allowOverride===!0&&B!==null&&(Ve=B),pe.layers.test(W.layers)&&gu(pe,O,W,Ee,Ve,De)}}function gu(y,O,W,B,k,me){y.onBeforeRender(C,O,W,B,k,me),y.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),k.onBeforeRender(C,O,W,B,y,me),k.transparent===!0&&k.side===Fn&&k.forceSinglePass===!1?(k.side=Ut,k.needsUpdate=!0,C.renderBufferDirect(W,O,B,k,y,me),k.side=qi,k.needsUpdate=!0,C.renderBufferDirect(W,O,B,k,y,me),k.side=Fn):C.renderBufferDirect(W,O,B,k,y,me),y.onAfterRender(C,O,W,B,k,me)}function fa(y,O,W){O.isScene!==!0&&(O=gt);const B=H.get(y),k=A.state.lights,me=A.state.shadowsArray,Me=k.state.version,pe=ce.getParameters(y,k.state,me,O,W,A.state.lightProbeGridArray),Ee=ce.getProgramCacheKey(pe);let De=B.programs;B.environment=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?O.environment:null,B.fog=O.fog;const Ve=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap;B.envMap=se.get(y.envMap||B.environment,Ve),B.envMapRotation=B.environment!==null&&y.envMap===null?O.environmentRotation:y.envMapRotation,De===void 0&&(y.addEventListener("dispose",Wn),De=new Map,B.programs=De);let Xe=De.get(Ee);if(Xe!==void 0){if(B.currentProgram===Xe&&B.lightsStateVersion===Me)return _u(y,pe),Xe}else pe.uniforms=ce.getUniforms(y),I!==null&&y.isNodeMaterial&&I.build(y,W,pe),y.onBeforeCompile(pe,C),Xe=ce.acquireProgram(pe,Ee),De.set(Ee,Xe),B.uniforms=pe.uniforms;const Ce=B.uniforms;return(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)&&(Ce.clippingPlanes=Le.uniform),_u(y,pe),B.needsLights=jp(y),B.lightsStateVersion=Me,B.needsLights&&(Ce.ambientLightColor.value=k.state.ambient,Ce.lightProbe.value=k.state.probe,Ce.directionalLights.value=k.state.directional,Ce.directionalLightShadows.value=k.state.directionalShadow,Ce.spotLights.value=k.state.spot,Ce.spotLightShadows.value=k.state.spotShadow,Ce.rectAreaLights.value=k.state.rectArea,Ce.ltc_1.value=k.state.rectAreaLTC1,Ce.ltc_2.value=k.state.rectAreaLTC2,Ce.pointLights.value=k.state.point,Ce.pointLightShadows.value=k.state.pointShadow,Ce.hemisphereLights.value=k.state.hemi,Ce.directionalShadowMatrix.value=k.state.directionalShadowMatrix,Ce.spotLightMatrix.value=k.state.spotLightMatrix,Ce.spotLightMap.value=k.state.spotLightMap,Ce.pointShadowMatrix.value=k.state.pointShadowMatrix),B.lightProbeGrid=A.state.lightProbeGridArray.length>0,B.currentProgram=Xe,B.uniformsList=null,Xe}function vu(y){if(y.uniformsList===null){const O=y.currentProgram.getUniforms();y.uniformsList=So.seqWithValue(O.seq,y.uniforms)}return y.uniformsList}function _u(y,O){const W=H.get(y);W.outputColorSpace=O.outputColorSpace,W.batching=O.batching,W.batchingColor=O.batchingColor,W.instancing=O.instancing,W.instancingColor=O.instancingColor,W.instancingMorph=O.instancingMorph,W.skinning=O.skinning,W.morphTargets=O.morphTargets,W.morphNormals=O.morphNormals,W.morphColors=O.morphColors,W.morphTargetsCount=O.morphTargetsCount,W.numClippingPlanes=O.numClippingPlanes,W.numIntersection=O.numClipIntersection,W.vertexAlphas=O.vertexAlphas,W.vertexTangents=O.vertexTangents,W.toneMapping=O.toneMapping}function Zp(y,O){if(y.length===0)return null;if(y.length===1)return y[0].texture!==null?y[0]:null;M.setFromMatrixPosition(O.matrixWorld);for(let W=0,B=y.length;W<B;W++){const k=y[W];if(k.texture!==null&&k.boundingBox.containsPoint(M))return k}return null}function Jp(y,O,W,B,k){O.isScene!==!0&&(O=gt),K.resetTextureUnits();const me=O.fog,Me=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?O.environment:null,pe=Z===null?C.outputColorSpace:Z.isXRRenderTarget===!0?Z.texture.colorSpace:Je.workingColorSpace,Ee=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,De=se.get(B.envMap||Me,Ee),Ve=B.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,Xe=!!W.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Ce=!!W.morphAttributes.position,ot=!!W.morphAttributes.normal,Rt=!!W.morphAttributes.color;let Et=si;B.toneMapped&&(Z===null||Z.isXRRenderTarget===!0)&&(Et=C.toneMapping);const ht=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,qt=ht!==void 0?ht.length:0,_e=H.get(B),pn=A.state.lights;if(Ue===!0&&(Oe===!0||y!==j)){const pt=y===j&&B.id===te;Le.setState(B,y,pt)}let je=!1;B.version===_e.__version?(_e.needsLights&&_e.lightsStateVersion!==pn.state.version||_e.outputColorSpace!==pe||k.isBatchedMesh&&_e.batching===!1||!k.isBatchedMesh&&_e.batching===!0||k.isBatchedMesh&&_e.batchingColor===!0&&k.colorTexture===null||k.isBatchedMesh&&_e.batchingColor===!1&&k.colorTexture!==null||k.isInstancedMesh&&_e.instancing===!1||!k.isInstancedMesh&&_e.instancing===!0||k.isSkinnedMesh&&_e.skinning===!1||!k.isSkinnedMesh&&_e.skinning===!0||k.isInstancedMesh&&_e.instancingColor===!0&&k.instanceColor===null||k.isInstancedMesh&&_e.instancingColor===!1&&k.instanceColor!==null||k.isInstancedMesh&&_e.instancingMorph===!0&&k.morphTexture===null||k.isInstancedMesh&&_e.instancingMorph===!1&&k.morphTexture!==null||_e.envMap!==De||B.fog===!0&&_e.fog!==me||_e.numClippingPlanes!==void 0&&(_e.numClippingPlanes!==Le.numPlanes||_e.numIntersection!==Le.numIntersection)||_e.vertexAlphas!==Ve||_e.vertexTangents!==Xe||_e.morphTargets!==Ce||_e.morphNormals!==ot||_e.morphColors!==Rt||_e.toneMapping!==Et||_e.morphTargetsCount!==qt||!!_e.lightProbeGrid!=A.state.lightProbeGridArray.length>0)&&(je=!0):(je=!0,_e.__version=B.version);let En=_e.currentProgram;je===!0&&(En=fa(B,O,k),I&&B.isNodeMaterial&&I.onUpdateProgram(B,En,_e));let Xn=!1,Ti=!1,Es=!1;const ut=En.getUniforms(),Dt=_e.uniforms;if(v.useProgram(En.program)&&(Xn=!0,Ti=!0,Es=!0),B.id!==te&&(te=B.id,Ti=!0),_e.needsLights){const pt=Zp(A.state.lightProbeGridArray,k);_e.lightProbeGrid!==pt&&(_e.lightProbeGrid=pt,Ti=!0)}if(Xn||j!==y){v.buffers.depth.getReversed()&&y.reversedDepth!==!0&&(y._reversedDepth=!0,y.updateProjectionMatrix()),ut.setValue(N,"projectionMatrix",y.projectionMatrix),ut.setValue(N,"viewMatrix",y.matrixWorldInverse);const Di=ut.map.cameraPosition;Di!==void 0&&Di.setValue(N,nt.setFromMatrixPosition(y.matrixWorld)),T.logarithmicDepthBuffer&&ut.setValue(N,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&ut.setValue(N,"isOrthographic",y.isOrthographicCamera===!0),j!==y&&(j=y,Ti=!0,Es=!0)}if(_e.needsLights&&(pn.state.directionalShadowMap.length>0&&ut.setValue(N,"directionalShadowMap",pn.state.directionalShadowMap,K),pn.state.spotShadowMap.length>0&&ut.setValue(N,"spotShadowMap",pn.state.spotShadowMap,K),pn.state.pointShadowMap.length>0&&ut.setValue(N,"pointShadowMap",pn.state.pointShadowMap,K)),k.isSkinnedMesh){ut.setOptional(N,k,"bindMatrix"),ut.setOptional(N,k,"bindMatrixInverse");const pt=k.skeleton;pt&&(pt.boneTexture===null&&pt.computeBoneTexture(),ut.setValue(N,"boneTexture",pt.boneTexture,K))}k.isBatchedMesh&&(ut.setOptional(N,k,"batchingTexture"),ut.setValue(N,"batchingTexture",k._matricesTexture,K),ut.setOptional(N,k,"batchingIdTexture"),ut.setValue(N,"batchingIdTexture",k._indirectTexture,K),ut.setOptional(N,k,"batchingColorTexture"),k._colorsTexture!==null&&ut.setValue(N,"batchingColorTexture",k._colorsTexture,K));const Ri=W.morphAttributes;if((Ri.position!==void 0||Ri.normal!==void 0||Ri.color!==void 0)&&L.update(k,W,En),(Ti||_e.receiveShadow!==k.receiveShadow)&&(_e.receiveShadow=k.receiveShadow,ut.setValue(N,"receiveShadow",k.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&O.environment!==null&&(Dt.envMapIntensity.value=O.environmentIntensity),Dt.dfgLUT!==void 0&&(Dt.dfgLUT.value=e3()),Ti){if(ut.setValue(N,"toneMappingExposure",C.toneMappingExposure),_e.needsLights&&Qp(Dt,Es),me&&B.fog===!0&&Re.refreshFogUniforms(Dt,me),Re.refreshMaterialUniforms(Dt,B,ne,re,A.state.transmissionRenderTarget[y.id]),_e.needsLights&&_e.lightProbeGrid){const pt=_e.lightProbeGrid;Dt.probesSH.value=pt.texture,Dt.probesMin.value.copy(pt.boundingBox.min),Dt.probesMax.value.copy(pt.boundingBox.max),Dt.probesResolution.value.copy(pt.resolution)}So.upload(N,vu(_e),Dt,K)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(So.upload(N,vu(_e),Dt,K),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&ut.setValue(N,"center",k.center),ut.setValue(N,"modelViewMatrix",k.modelViewMatrix),ut.setValue(N,"normalMatrix",k.normalMatrix),ut.setValue(N,"modelMatrix",k.matrixWorld),B.uniformsGroups!==void 0){const pt=B.uniformsGroups;for(let Di=0,bs=pt.length;Di<bs;Di++){const xu=pt[Di];ee.update(xu,En),ee.bind(xu,En)}}return En}function Qp(y,O){y.ambientLightColor.needsUpdate=O,y.lightProbe.needsUpdate=O,y.directionalLights.needsUpdate=O,y.directionalLightShadows.needsUpdate=O,y.pointLights.needsUpdate=O,y.pointLightShadows.needsUpdate=O,y.spotLights.needsUpdate=O,y.spotLightShadows.needsUpdate=O,y.rectAreaLights.needsUpdate=O,y.hemisphereLights.needsUpdate=O}function jp(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return X},this.getActiveMipmapLevel=function(){return G},this.getRenderTarget=function(){return Z},this.setRenderTargetTextures=function(y,O,W){const B=H.get(y);B.__autoAllocateDepthBuffer=y.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),H.get(y.texture).__webglTexture=O,H.get(y.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:W,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(y,O){const W=H.get(y);W.__webglFramebuffer=O,W.__useDefaultFramebuffer=O===void 0},this.setRenderTarget=function(y,O=0,W=0){Z=y,X=O,G=W;let B=null,k=!1,me=!1;if(y){const pe=H.get(y);if(pe.__useDefaultFramebuffer!==void 0){v.bindFramebuffer(N.FRAMEBUFFER,pe.__webglFramebuffer),ie.copy(y.viewport),ue.copy(y.scissor),He=y.scissorTest,v.viewport(ie),v.scissor(ue),v.setScissorTest(He),te=-1;return}else if(pe.__webglFramebuffer===void 0)K.setupRenderTarget(y);else if(pe.__hasExternalTextures)K.rebindTextures(y,H.get(y.texture).__webglTexture,H.get(y.depthTexture).__webglTexture);else if(y.depthBuffer){const Ve=y.depthTexture;if(pe.__boundDepthTexture!==Ve){if(Ve!==null&&H.has(Ve)&&(y.width!==Ve.image.width||y.height!==Ve.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");K.setupDepthRenderbuffer(y)}}const Ee=y.texture;(Ee.isData3DTexture||Ee.isDataArrayTexture||Ee.isCompressedArrayTexture)&&(me=!0);const De=H.get(y).__webglFramebuffer;y.isWebGLCubeRenderTarget?(Array.isArray(De[O])?B=De[O][W]:B=De[O],k=!0):y.samples>0&&K.useMultisampledRTT(y)===!1?B=H.get(y).__webglMultisampledFramebuffer:Array.isArray(De)?B=De[W]:B=De,ie.copy(y.viewport),ue.copy(y.scissor),He=y.scissorTest}else ie.copy(Pe).multiplyScalar(ne).floor(),ue.copy(Te).multiplyScalar(ne).floor(),He=xe;if(W!==0&&(B=V),v.bindFramebuffer(N.FRAMEBUFFER,B)&&v.drawBuffers(y,B),v.viewport(ie),v.scissor(ue),v.setScissorTest(He),k){const pe=H.get(y.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+O,pe.__webglTexture,W)}else if(me){const pe=O;for(let Ee=0;Ee<y.textures.length;Ee++){const De=H.get(y.textures[Ee]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+Ee,De.__webglTexture,W,pe)}}else if(y!==null&&W!==0){const pe=H.get(y.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,pe.__webglTexture,W)}te=-1},this.readRenderTargetPixels=function(y,O,W,B,k,me,Me,pe=0){if(!(y&&y.isWebGLRenderTarget)){ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ee=H.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&Me!==void 0&&(Ee=Ee[Me]),Ee){v.bindFramebuffer(N.FRAMEBUFFER,Ee);try{const De=y.textures[pe],Ve=De.format,Xe=De.type;if(y.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+pe),!T.textureFormatReadable(Ve)){ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!T.textureTypeReadable(Xe)){ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}O>=0&&O<=y.width-B&&W>=0&&W<=y.height-k&&N.readPixels(O,W,B,k,he.convert(Ve),he.convert(Xe),me)}finally{const De=Z!==null?H.get(Z).__webglFramebuffer:null;v.bindFramebuffer(N.FRAMEBUFFER,De)}}},this.readRenderTargetPixelsAsync=async function(y,O,W,B,k,me,Me,pe=0){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ee=H.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&Me!==void 0&&(Ee=Ee[Me]),Ee)if(O>=0&&O<=y.width-B&&W>=0&&W<=y.height-k){v.bindFramebuffer(N.FRAMEBUFFER,Ee);const De=y.textures[pe],Ve=De.format,Xe=De.type;if(y.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+pe),!T.textureFormatReadable(Ve))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!T.textureTypeReadable(Xe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ce=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,Ce),N.bufferData(N.PIXEL_PACK_BUFFER,me.byteLength,N.STREAM_READ),N.readPixels(O,W,B,k,he.convert(Ve),he.convert(Xe),0);const ot=Z!==null?H.get(Z).__webglFramebuffer:null;v.bindFramebuffer(N.FRAMEBUFFER,ot);const Rt=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await Tg(N,Rt,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,Ce),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,me),N.deleteBuffer(Ce),N.deleteSync(Rt),me}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,O=null,W=0){const B=Math.pow(2,-W),k=Math.floor(y.image.width*B),me=Math.floor(y.image.height*B),Me=O!==null?O.x:0,pe=O!==null?O.y:0;K.setTexture2D(y,0),N.copyTexSubImage2D(N.TEXTURE_2D,W,0,0,Me,pe,k,me),v.unbindTexture()},this.copyTextureToTexture=function(y,O,W=null,B=null,k=0,me=0){let Me,pe,Ee,De,Ve,Xe,Ce,ot,Rt;const Et=y.isCompressedTexture?y.mipmaps[me]:y.image;if(W!==null)Me=W.max.x-W.min.x,pe=W.max.y-W.min.y,Ee=W.isBox3?W.max.z-W.min.z:1,De=W.min.x,Ve=W.min.y,Xe=W.isBox3?W.min.z:0;else{const Dt=Math.pow(2,-k);Me=Math.floor(Et.width*Dt),pe=Math.floor(Et.height*Dt),y.isDataArrayTexture?Ee=Et.depth:y.isData3DTexture?Ee=Math.floor(Et.depth*Dt):Ee=1,De=0,Ve=0,Xe=0}B!==null?(Ce=B.x,ot=B.y,Rt=B.z):(Ce=0,ot=0,Rt=0);const ht=he.convert(O.format),qt=he.convert(O.type);let _e;O.isData3DTexture?(K.setTexture3D(O,0),_e=N.TEXTURE_3D):O.isDataArrayTexture||O.isCompressedArrayTexture?(K.setTexture2DArray(O,0),_e=N.TEXTURE_2D_ARRAY):(K.setTexture2D(O,0),_e=N.TEXTURE_2D),v.activeTexture(N.TEXTURE0),v.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,O.flipY),v.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),v.pixelStorei(N.UNPACK_ALIGNMENT,O.unpackAlignment);const pn=v.getParameter(N.UNPACK_ROW_LENGTH),je=v.getParameter(N.UNPACK_IMAGE_HEIGHT),En=v.getParameter(N.UNPACK_SKIP_PIXELS),Xn=v.getParameter(N.UNPACK_SKIP_ROWS),Ti=v.getParameter(N.UNPACK_SKIP_IMAGES);v.pixelStorei(N.UNPACK_ROW_LENGTH,Et.width),v.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Et.height),v.pixelStorei(N.UNPACK_SKIP_PIXELS,De),v.pixelStorei(N.UNPACK_SKIP_ROWS,Ve),v.pixelStorei(N.UNPACK_SKIP_IMAGES,Xe);const Es=y.isDataArrayTexture||y.isData3DTexture,ut=O.isDataArrayTexture||O.isData3DTexture;if(y.isDepthTexture){const Dt=H.get(y),Ri=H.get(O),pt=H.get(Dt.__renderTarget),Di=H.get(Ri.__renderTarget);v.bindFramebuffer(N.READ_FRAMEBUFFER,pt.__webglFramebuffer),v.bindFramebuffer(N.DRAW_FRAMEBUFFER,Di.__webglFramebuffer);for(let bs=0;bs<Ee;bs++)Es&&(N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,H.get(y).__webglTexture,k,Xe+bs),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,H.get(O).__webglTexture,me,Rt+bs)),N.blitFramebuffer(De,Ve,Me,pe,Ce,ot,Me,pe,N.DEPTH_BUFFER_BIT,N.NEAREST);v.bindFramebuffer(N.READ_FRAMEBUFFER,null),v.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(k!==0||y.isRenderTargetTexture||H.has(y)){const Dt=H.get(y),Ri=H.get(O);v.bindFramebuffer(N.READ_FRAMEBUFFER,q),v.bindFramebuffer(N.DRAW_FRAMEBUFFER,U);for(let pt=0;pt<Ee;pt++)Es?N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Dt.__webglTexture,k,Xe+pt):N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Dt.__webglTexture,k),ut?N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Ri.__webglTexture,me,Rt+pt):N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Ri.__webglTexture,me),k!==0?N.blitFramebuffer(De,Ve,Me,pe,Ce,ot,Me,pe,N.COLOR_BUFFER_BIT,N.NEAREST):ut?N.copyTexSubImage3D(_e,me,Ce,ot,Rt+pt,De,Ve,Me,pe):N.copyTexSubImage2D(_e,me,Ce,ot,De,Ve,Me,pe);v.bindFramebuffer(N.READ_FRAMEBUFFER,null),v.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else ut?y.isDataTexture||y.isData3DTexture?N.texSubImage3D(_e,me,Ce,ot,Rt,Me,pe,Ee,ht,qt,Et.data):O.isCompressedArrayTexture?N.compressedTexSubImage3D(_e,me,Ce,ot,Rt,Me,pe,Ee,ht,Et.data):N.texSubImage3D(_e,me,Ce,ot,Rt,Me,pe,Ee,ht,qt,Et):y.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,me,Ce,ot,Me,pe,ht,qt,Et.data):y.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,me,Ce,ot,Et.width,Et.height,ht,Et.data):N.texSubImage2D(N.TEXTURE_2D,me,Ce,ot,Me,pe,ht,qt,Et);v.pixelStorei(N.UNPACK_ROW_LENGTH,pn),v.pixelStorei(N.UNPACK_IMAGE_HEIGHT,je),v.pixelStorei(N.UNPACK_SKIP_PIXELS,En),v.pixelStorei(N.UNPACK_SKIP_ROWS,Xn),v.pixelStorei(N.UNPACK_SKIP_IMAGES,Ti),me===0&&O.generateMipmaps&&N.generateMipmap(_e),v.unbindTexture()},this.initRenderTarget=function(y){H.get(y).__webglFramebuffer===void 0&&K.setupRenderTarget(y)},this.initTexture=function(y){y.isCubeTexture?K.setTextureCube(y,0):y.isData3DTexture?K.setTexture3D(y,0):y.isDataArrayTexture||y.isCompressedArrayTexture?K.setTexture2DArray(y,0):K.setTexture2D(y,0),v.unbindTexture()},this.resetState=function(){X=0,G=0,Z=null,v.reset(),ge.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ti}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Je._getDrawingBufferColorSpace(e),t.unpackColorSpace=Je._getUnpackColorSpace()}}const Qo=`
4445
4445
  vec3 encodeSrgb(vec3 linear) {
4446
4446
  vec3 clamped = max(linear, vec3(0.0));
4447
4447
  vec3 low = clamped * 12.92;
4448
4448
  vec3 high = 1.055 * pow(clamped, vec3(1.0 / 2.4)) - 0.055;
4449
4449
  return mix(low, high, step(vec3(0.0031308), clamped));
4450
4450
  }
4451
- `;class Z_{frameTarget;filmTarget;quadScene=new _o;quadCamera=new or(-1,1,1,-1,0,1);addMaterial;developMaterial;quad;width;height;constructor(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.frameTarget=new un(this.width,this.height,{type:Qt}),this.filmTarget=new un(this.width,this.height,{type:Qt});const n=`
4451
+ `;class n3{frameTarget;filmTarget;quadScene=new Yo;quadCamera=new xr(-1,1,1,-1,0,1);addMaterial;developMaterial;quad;width;height;constructor(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.frameTarget=new fn(this.width,this.height,{type:jt}),this.filmTarget=new fn(this.width,this.height,{type:jt});const n=`
4452
4452
  varying vec2 vUv;
4453
4453
  void main() {
4454
4454
  vUv = position.xy * 0.5 + 0.5;
4455
4455
  gl_Position = vec4(position.xy, 0.0, 1.0);
4456
4456
  }
4457
- `;this.addMaterial=new At({uniforms:{uSource:{value:this.frameTarget.texture},uShare:{value:1}},vertexShader:n,fragmentShader:`
4457
+ `;this.addMaterial=new Tt({uniforms:{uSource:{value:this.frameTarget.texture},uShare:{value:1}},vertexShader:n,fragmentShader:`
4458
4458
  precision highp float;
4459
4459
  varying vec2 vUv;
4460
4460
  uniform sampler2D uSource;
@@ -4462,16 +4462,16 @@ vec3 encodeSrgb(vec3 linear) {
4462
4462
  void main() {
4463
4463
  gl_FragColor = vec4(texture2D(uSource, vUv).rgb * uShare, 1.0);
4464
4464
  }
4465
- `,blending:ni,depthTest:!1,depthWrite:!1}),this.developMaterial=new At({uniforms:{uFilm:{value:this.filmTarget.texture},uGain:{value:1}},vertexShader:n,fragmentShader:`
4465
+ `,blending:ai,depthTest:!1,depthWrite:!1}),this.developMaterial=new Tt({uniforms:{uFilm:{value:this.filmTarget.texture},uGain:{value:1}},vertexShader:n,fragmentShader:`
4466
4466
  precision highp float;
4467
- ${Ao}
4467
+ ${Qo}
4468
4468
  varying vec2 vUv;
4469
4469
  uniform sampler2D uFilm;
4470
4470
  uniform float uGain;
4471
4471
  void main() {
4472
4472
  gl_FragColor = vec4(encodeSrgb(texture2D(uFilm, vUv).rgb * uGain), 1.0);
4473
4473
  }
4474
- `,blending:jn,depthTest:!1,depthWrite:!1}),this.quad=new je(new ki(2,2),this.addMaterial),this.quadScene.add(this.quad)}get instantTarget(){return this.frameTarget}open(e){const t=e.getRenderTarget();e.setRenderTarget(this.filmTarget),e.setClearColor(0,1),e.clear(!0,!0,!0),e.setRenderTarget(t)}add(e,t){this.addMaterial.uniforms.uShare.value=t,this.quad.material=this.addMaterial;const n=e.getRenderTarget(),s=e.autoClear;e.autoClear=!1,e.setRenderTarget(this.filmTarget),e.render(this.quadScene,this.quadCamera),e.setRenderTarget(n),e.autoClear=s}develop(e,t=1){this.developMaterial.uniforms.uGain.value=t,this.quad.material=this.developMaterial,e.setRenderTarget(null),e.render(this.quadScene,this.quadCamera)}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.frameTarget.setSize(this.width,this.height),this.filmTarget.setSize(this.width,this.height)}dispose(){this.frameTarget.dispose(),this.filmTarget.dispose(),this.addMaterial.dispose(),this.developMaterial.dispose(),this.quad.geometry.dispose(),this.quadScene.clear()}}const Dl=Math.PI/180,$u=180/Math.PI;function Vr(i,e,t){return Math.max(e,Math.min(t,i))}const wi=[{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 dc(i,e,t){return i+(e-i)*t}function ao(i,e,t){return[dc(i[0],e[0],t),dc(i[1],e[1],t),dc(i[2],e[2],t)]}function Cl(i){const e=Math.max(wi[0].altitudeDeg,Math.min(wi[wi.length-1].altitudeDeg,i));for(let n=0;n<wi.length-1;n++){const s=wi[n],r=wi[n+1];if(e>=s.altitudeDeg&&e<=r.altitudeDeg){const a=(e-s.altitudeDeg)/(r.altitudeDeg-s.altitudeDeg);return{zenith:ao(s.zenith,r.zenith,a),horizon:ao(s.horizon,r.horizon,a)}}}const t=wi[wi.length-1];return{zenith:t.zenith,horizon:t.horizon}}const Ju=-18,Qu=-4,$_=1.8;function ju(i){if(i<=Ju)return $a;if(i>=0)return Qu;const e=i/Ju;return $a-($a-Qu)*(1-e)**$_}const J_=-1.5,$a=6.5,ed=$a,Q_=1.6;function fc(i){const e=(ed-i)/(ed-J_);return Vr(e,0,1)**Q_}function tn(i,e,t){const n=i*Dl,s=e*Dl,r=t*Math.cos(n);return{x:r*Math.sin(s),y:t*Math.sin(n),z:-r*Math.cos(s)}}function j_(i,e,t){const n=Math.sqrt(i*i+e*e+t*t),s=n===0?0:Math.asin(Vr(e/n,-1,1))*$u,r=(Math.atan2(i,-t)*$u+360)%360;return{altitudeDeg:s,azimuthDeg:r}}function ex(i,e){const t=Math.abs(i-e)%360;return t>180?360-t:t}function tx(i,e,t,n){const s=Math.max(0,1-ex(i,t)/nx),r=Math.exp(-Math.max(0,e)/ix),a=n>0?Math.max(0,1-n/sx):Math.max(0,1-Math.abs(n+rx)/ax);return s*r*a}const nx=90,ix=12,sx=8,rx=2,ax=12;function ox(i,e,t,n){const{zenith:s,horizon:r}=Cl(n),a=Vr((i+90)/180,0,1),o=ao(r,s,a),c=tx(e,i,t,n);if(c<=0)return o;const l=Cl(n+cx).horizon,h=[Math.max(r[0],l[0]),Math.max(r[1],l[1]),Math.max(r[2],l[2])];return ao(o,h,c)}const cx=6;function pc(i){return .12+.88*i}const lx=-4;function hx(i){return Math.max(0,lx-i)}const ux=6,dx=60;function fx(i){return Math.min(dx,ux*Math.sqrt(i))}const px=3,mx=.55;function gx(i){return mx*Vr(i/px,0,1)}function V0(i){const e=Math.max(i,-4),t=Math.sin(e*Dl)+.50572*Math.pow(e+6.07995,-1.6364);return Vr(1/t,1,40)}function Yi(i){const e=V0(i)-1;return[1,Math.exp(-.022*e),Math.exp(-.062*e)]}function vx(i){return xx*(V0(Math.max(i,0))-1)}function _x(i){return Math.pow(10,-.4*vx(i))}const xx=5/37,W0=[{maxBrightness:.35,size:1.2},{maxBrightness:.7,size:2},{maxBrightness:1/0,size:3.2}];function Mx(i){return W0.findIndex(e=>i<=e.maxBrightness)}const Sx=.25,td=.3,yx=2.2;function Ex(i,{phase:e,speedFactor:t},n){const r=1+Sx*(td+(1-td)*i)*Math.sin(n*yx*t+e);return Math.min(1,Math.max(0,r))}/**
4474
+ `,blending:ii,depthTest:!1,depthWrite:!1}),this.quad=new Qe(new $i(2,2),this.addMaterial),this.quadScene.add(this.quad)}get instantTarget(){return this.frameTarget}open(e){const t=e.getRenderTarget();e.setRenderTarget(this.filmTarget),e.setClearColor(0,1),e.clear(!0,!0,!0),e.setRenderTarget(t)}add(e,t){this.addMaterial.uniforms.uShare.value=t,this.quad.material=this.addMaterial;const n=e.getRenderTarget(),s=e.autoClear;e.autoClear=!1,e.setRenderTarget(this.filmTarget),e.render(this.quadScene,this.quadCamera),e.setRenderTarget(n),e.autoClear=s}develop(e,t=1){this.developMaterial.uniforms.uGain.value=t,this.quad.material=this.developMaterial,e.setRenderTarget(null),e.render(this.quadScene,this.quadCamera)}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.frameTarget.setSize(this.width,this.height),this.filmTarget.setSize(this.width,this.height)}dispose(){this.frameTarget.dispose(),this.filmTarget.dispose(),this.addMaterial.dispose(),this.developMaterial.dispose(),this.quad.geometry.dispose(),this.quadScene.clear()}}const lh=Math.PI/180,t0=180/Math.PI;function ha(i,e,t){return Math.max(e,Math.min(t,i))}const Fi=[{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 Vc(i,e,t){return i+(e-i)*t}function Oo(i,e,t){return[Vc(i[0],e[0],t),Vc(i[1],e[1],t),Vc(i[2],e[2],t)]}function hh(i){const e=Math.max(Fi[0].altitudeDeg,Math.min(Fi[Fi.length-1].altitudeDeg,i));for(let n=0;n<Fi.length-1;n++){const s=Fi[n],r=Fi[n+1];if(e>=s.altitudeDeg&&e<=r.altitudeDeg){const a=(e-s.altitudeDeg)/(r.altitudeDeg-s.altitudeDeg);return{zenith:Oo(s.zenith,r.zenith,a),horizon:Oo(s.horizon,r.horizon,a)}}}const t=Fi[Fi.length-1];return{zenith:t.zenith,horizon:t.horizon}}const n0=-18,i0=-4,i3=1.8;function s0(i){if(i<=n0)return Eo;if(i>=0)return i0;const e=i/n0;return Eo-(Eo-i0)*(1-e)**i3}const s3=-1.5,Eo=6.5,r0=Eo,r3=1.6;function Wc(i){const e=(r0-i)/(r0-s3);return ha(e,0,1)**r3}function nn(i,e,t){const n=i*lh,s=e*lh,r=t*Math.cos(n);return{x:r*Math.sin(s),y:t*Math.sin(n),z:-r*Math.cos(s)}}function a3(i,e,t){const n=Math.sqrt(i*i+e*e+t*t),s=n===0?0:Math.asin(ha(e/n,-1,1))*t0,r=(Math.atan2(i,-t)*t0+360)%360;return{altitudeDeg:s,azimuthDeg:r}}function o3(i,e){const t=Math.abs(i-e)%360;return t>180?360-t:t}function c3(i,e,t,n){const s=Math.max(0,1-o3(i,t)/l3),r=Math.exp(-Math.max(0,e)/h3),a=n>0?Math.max(0,1-n/u3):Math.max(0,1-Math.abs(n+d3)/f3);return s*r*a}const l3=90,h3=12,u3=8,d3=2,f3=12;function p3(i,e,t,n){const{zenith:s,horizon:r}=hh(n),a=ha((i+90)/180,0,1),o=Oo(r,s,a),c=c3(e,i,t,n);if(c<=0)return o;const l=hh(n+m3).horizon,h=[Math.max(r[0],l[0]),Math.max(r[1],l[1]),Math.max(r[2],l[2])];return Oo(o,h,c)}const m3=6;function Xc(i){return .12+.88*i}const g3=-4;function v3(i){return Math.max(0,g3-i)}const _3=6,x3=60;function M3(i){return Math.min(x3,_3*Math.sqrt(i))}const y3=3,S3=.55;function E3(i){return S3*ha(i/y3,0,1)}function sp(i){const e=Math.max(i,-4),t=Math.sin(e*lh)+.50572*Math.pow(e+6.07995,-1.6364);return ha(1/t,1,40)}function ts(i){const e=sp(i)-1;return[1,Math.exp(-.022*e),Math.exp(-.062*e)]}function b3(i){return w3*(sp(Math.max(i,0))-1)}function A3(i){return Math.pow(10,-.4*b3(i))}const w3=5/37,rp=[{maxBrightness:.35,size:1.2},{maxBrightness:.7,size:2},{maxBrightness:1/0,size:3.2}];function T3(i){return rp.findIndex(e=>i<=e.maxBrightness)}const R3=.25,a0=.3,D3=2.2;function C3(i,{phase:e,speedFactor:t},n){const r=1+R3*(a0+(1-a0)*i)*Math.sin(n*D3*t+e);return Math.min(1,Math.max(0,r))}/**
4475
4475
  @preserve
4476
4476
 
4477
4477
  Astronomy library for JavaScript (browser and Node.js).
@@ -4502,11 +4502,11 @@ vec3 encodeSrgb(vec3 linear) {
4502
4502
  * @fileoverview Astronomy calculation library for browser scripting and Node.js.
4503
4503
  * @author Don Cross <cosinekitty@gmail.com>
4504
4504
  * @license MIT
4505
- */const vh=173.1446326846693,es=14959787069098932e-8,st=.017453292519943295,nd=.26179938779914946,ti=57.29577951308232,X0=3.819718634205488,Ax=365.24217,id=new Date("2000-01-01T12:00:00Z"),ci=2*Math.PI,Ri=3600*(180/Math.PI),Ws=484813681109536e-20,q0=10800*60,bx=2*q0,sd=7292115e-11,Tx=q0/Math.PI,wx=-.17-5*Math.log10(Tx),Pl=.996647180302104,Rx=Pl*Pl,Il=6378.1366,Dx=Il/es,Y0=81.30056,_h=.0002959122082855911,Ll=2825345909524226e-22,Nl=8459715185680659e-23,Ul=1292024916781969e-23,Ol=1524358900784276e-23;function oo(i){if(i!==!0&&i!==!1)throw console.trace(),`Value is not boolean: ${i}`;return i}function Vt(i){if(!Number.isFinite(i))throw console.trace(),`Value is not a finite number: ${i}`;return i}function Fs(i){return i-Math.floor(i)}function Cx(i,e){const t=i.x*i.x+i.y*i.y+i.z*i.z;if(Math.abs(t)<1e-8)throw"AngleBetween: first vector is too short.";const n=e.x*e.x+e.y*e.y+e.z*e.z;if(Math.abs(n)<1e-8)throw"AngleBetween: second vector is too short.";const s=(i.x*e.x+i.y*e.y+i.z*e.z)/Math.sqrt(t*n);return s<=-1?180:s>=1?0:ti*Math.acos(s)}var ye;(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"})(ye||(ye={}));const Px=[ye.Star1,ye.Star2,ye.Star3,ye.Star4,ye.Star5,ye.Star6,ye.Star7,ye.Star8],Ix=[{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 e=Px.indexOf(i);return e>=0?Ix[e]:null}function xh(i){const e=Lx(i);return e&&e.dist>0?e:null}var rn;(function(i){i[i.From2000=0]="From2000",i[i.Into2000=1]="Into2000"})(rn||(rn={}));const Qn={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 Nx(i){var e,t,n,s,r,a,o;const c=2e3+(i-14)/Ax;return c<-500?(e=(c-1820)/100,-20+32*e*e):c<500?(e=c/100,t=e*e,n=e*t,s=t*t,r=t*n,a=n*n,10583.6-1014.41*e+33.78311*t-5.952053*n-.1798452*s+.022174192*r+.0090316521*a):c<1600?(e=(c-1e3)/100,t=e*e,n=e*t,s=t*t,r=t*n,a=n*n,1574.2-556.01*e+71.23472*t+.319781*n-.8503463*s-.005050998*r+.0083572073*a):c<1700?(e=c-1600,t=e*e,n=e*t,120-.9808*e-.01532*t+n/7129):c<1800?(e=c-1700,t=e*e,n=e*t,s=t*t,8.83+.1603*e-.0059285*t+13336e-8*n-s/1174e3):c<1860?(e=c-1800,t=e*e,n=e*t,s=t*t,r=t*n,a=n*n,o=n*s,13.72-.332447*e+.0068612*t+.0041116*n-37436e-8*s+121272e-10*r-1699e-10*a+875e-12*o):c<1900?(e=c-1860,t=e*e,n=e*t,s=t*t,r=t*n,7.62+.5737*e-.251754*t+.01680668*n-.0004473624*s+r/233174):c<1920?(e=c-1900,t=e*e,n=e*t,s=t*t,-2.79+1.494119*e-.0598939*t+.0061966*n-197e-6*s):c<1941?(e=c-1920,t=e*e,n=e*t,21.2+.84493*e-.0761*t+.0020936*n):c<1961?(e=c-1950,t=e*e,n=e*t,29.07+.407*e-t/233+n/2547):c<1986?(e=c-1975,t=e*e,n=e*t,45.45+1.067*e-t/260-n/718):c<2005?(e=c-2e3,t=e*e,n=e*t,s=t*t,r=t*n,63.86+.3345*e-.060374*t+.0017275*n+651814e-9*s+2373599e-11*r):c<2050?(e=c-2e3,62.92+.32217*e+.005589*e*e):c<2150?(e=(c-1820)/100,-20+32*e*e-.5628*(2150-c)):(e=(c-1820)/100,-20+32*e*e)}let Ux=Nx;function rd(i){return i+Ux(i)/86400}class Js{constructor(e){if(e instanceof Js){this.date=e.date,this.ut=e.ut,this.tt=e.tt;return}const t=1e3*3600*24;if(e instanceof Date&&Number.isFinite(e.getTime())){this.date=e,this.ut=(e.getTime()-id.getTime())/t,this.tt=rd(this.ut);return}if(Number.isFinite(e)){this.date=new Date(id.getTime()+e*t),this.ut=e,this.tt=rd(this.ut);return}throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(e){let t=new Js(e);for(;;){const n=e-t.tt;if(Math.abs(n)<1e-12)return t;t=t.AddDays(n)}}toString(){return this.date.toISOString()}AddDays(e){return new Js(this.ut+e)}}function zt(i){return i instanceof Js?i:new Js(i)}function Ox(i){function e(d){return d%bx*Ws}const t=i.tt/36525,n=e(128710479305e-5+t*1295965810481e-4),s=e(335779.526232+t*17395272628478e-4),r=e(107226070369e-5+t*1602961601209e-3),a=e(450160.398036-t*69628905431e-4);let o=Math.sin(a),c=Math.cos(a),l=(-172064161-174666*t)*o+33386*c,h=(92052331+9086*t)*c+15377*o,u=2*(s-r+a);return o=Math.sin(u),c=Math.cos(u),l+=(-13170906-1675*t)*o-13696*c,h+=(5730336-3015*t)*c-4587*o,u=2*(s+a),o=Math.sin(u),c=Math.cos(u),l+=(-2276413-234*t)*o+2796*c,h+=(978459-485*t)*c+1374*o,u=2*a,o=Math.sin(u),c=Math.cos(u),l+=(2074554+207*t)*o-698*c,h+=(-897492+470*t)*c-291*o,o=Math.sin(n),c=Math.cos(n),l+=(1475877-3633*t)*o+11817*c,h+=(73871-184*t)*c-1924*o,{dpsi:-135e-6+l*1e-7,deps:388e-6+h*1e-7}}function K0(i){var e=i.tt/36525,t=((((-434e-10*e-576e-9)*e+.0020034)*e-1831e-7)*e-46.836769)*e+84381.406;return t/3600}var wa;function Wr(i){if(!wa||Math.abs(wa.tt-i.tt)>1e-6){const e=Ox(i),t=K0(i),n=t+e.deps/3600;wa={tt:i.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*st)/15,mobl:t,tobl:n}}return wa}function Fx(i,e){const t=i*st,n=Math.cos(t),s=Math.sin(t);return[e[0],e[1]*n-e[2]*s,e[1]*s+e[2]*n]}function zx(i,e){return Fx(K0(i),e)}function Bx(i){const e=i.tt/36525;function t(Te,_e){const Ie=[];let Ne;for(Ne=0;Ne<=_e-Te;++Ne)Ie.push(0);return{min:Te,array:Ie}}function n(Te,_e,Ie,Ne){const Ue=[];for(let et=0;et<=_e-Te;++et)Ue.push(t(Ie,Ne));return{min:Te,array:Ue}}function s(Te,_e,Ie){const Ne=Te.array[_e-Te.min];return Ne.array[Ie-Ne.min]}function r(Te,_e,Ie,Ne){const Ue=Te.array[_e-Te.min];Ue.array[Ie-Ue.min]=Ne}let a,o,c,l,h,u,d,f,g,x,m,p,A,T,M,y,b,R,_,E,C,D,I,W=n(-6,6,1,4),X=n(-6,6,1,4);function O(Te,_e){return s(W,Te,_e)}function q(Te,_e){return s(X,Te,_e)}function G(Te,_e,Ie){return r(W,Te,_e,Ie)}function $(Te,_e,Ie){return r(X,Te,_e,Ie)}function te(Te,_e,Ie,Ne,Ue){Ue(Te*Ie-_e*Ne,_e*Ie+Te*Ne)}function j(Te){return Math.sin(ci*Te)}d=e*e,g=0,I=0,m=0,p=3422.7;var ie=j(.19833+.05611*e),ue=j(.27869+.04508*e),He=j(.16827-.36903*e),Ke=j(.34734-5.37261*e),Be=j(.10498-5.37899*e),Y=j(.42681-.41855*e),re=j(.14943-5.37511*e);for(R=.84*ie+.31*ue+14.27*He+7.26*Ke+.28*Be+.24*Y,_=2.94*ie+.31*ue+14.27*He+9.34*Ke+1.12*Be+.83*Y,E=-6.4*ie-1.89*Y,C=.21*ie+.31*ue+14.27*He-88.7*Ke-15.3*Be+.24*Y-1.86*re,D=R-E,f=-3332e-9*j(.59734-5.37261*e)-539e-9*j(.35498-5.37899*e)-64e-9*j(.39943-5.37511*e),A=ci*Fs(.60643382+1336.85522467*e-313e-8*d)+R/Ri,T=ci*Fs(.37489701+1325.55240982*e+2565e-8*d)+_/Ri,M=ci*Fs(.99312619+99.99735956*e-44e-8*d)+E/Ri,y=ci*Fs(.25909118+1342.2278298*e-892e-8*d)+C/Ri,b=ci*Fs(.82736186+1236.85308708*e-397e-8*d)+D/Ri,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*e;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(G(0,h,1),G(1,h,Math.cos(c)*l),$(0,h,0),$(1,h,Math.sin(c)*l),u=2;u<=o;++u)te(O(u-1,h),q(u-1,h),O(1,h),q(1,h),(Te,_e)=>(G(u,h,Te),$(u,h,_e)));for(u=1;u<=o;++u)G(-u,h,O(u,h)),$(-u,h,-q(u,h))}function ne(Te,_e,Ie,Ne){for(var Ue={x:1,y:0},et=[0,Te,_e,Ie,Ne],tt=1;tt<=4;++tt)et[tt]!==0&&te(Ue.x,Ue.y,O(et[tt],tt),q(et[tt],tt),(_t,pt)=>(Ue.x=_t,Ue.y=pt));return Ue}function z(Te,_e,Ie,Ne,Ue,et,tt,_t){var pt=ne(Ue,et,tt,_t);g+=Te*pt.y,I+=_e*pt.y,m+=Ie*pt.x,p+=Ne*pt.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 Ae(Te,_e,Ie,Ne,Ue){return Te*ne(_e,Ie,Ne,Ue).y}x=0,x+=Ae(-526.069,0,0,1,-2),x+=Ae(-3.352,0,0,1,-4),x+=Ae(44.297,1,0,1,-2),x+=Ae(-6,1,0,1,-4),x+=Ae(20.599,-1,0,1,0),x+=Ae(-30.598,-1,0,1,-2),x+=Ae(-24.649,-2,0,1,0),x+=Ae(-2,-2,0,1,-2),x+=Ae(-22.571,0,1,1,-2),x+=Ae(10.985,0,-1,1,-2),g+=.82*j(.7736-62.5512*e)+.31*j(.0466-125.1025*e)+.35*j(.5785-25.1042*e)+.66*j(.4591+1335.8075*e)+.64*j(.313-91.568*e)+1.14*j(.148+1331.2898*e)+.21*j(.5918+1056.5859*e)+.44*j(.5784+1322.8595*e)+.24*j(.2275-5.7374*e)+.28*j(.2965+2.6929*e)+.33*j(.3132+6.3368*e),a=y+I/Ri;let Ce=(1.000002708+139.978*f)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+x;return{geo_eclip_lon:ci*Fs((A+g/Ri)/ci),geo_eclip_lat:Math.PI/(180*3600)*Ce,distance_au:Ri*Dx/(.999953253*p)}}function Z0(i,e){return[i.rot[0][0]*e[0]+i.rot[1][0]*e[1]+i.rot[2][0]*e[2],i.rot[0][1]*e[0]+i.rot[1][1]*e[1]+i.rot[2][1]*e[2],i.rot[0][2]*e[0]+i.rot[1][2]*e[1]+i.rot[2][2]*e[2]]}function co(i,e,t){const n=$0(e,t);return Z0(n,i)}function $0(i,e){const t=i.tt/36525;let n=84381.406,s=((((-951e-10*t+132851e-9)*t-.00114045)*t-1.0790069)*t+5038.481507)*t,r=((((3337e-10*t-467e-9)*t-.00772503)*t+.0512623)*t-.025754)*t+n,a=((((-56e-9*t+170663e-9)*t-.00121197)*t-2.3814292)*t+10.556403)*t;n*=Ws,s*=Ws,r*=Ws,a*=Ws;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(e===rn.Into2000)return new Bi([[x,m,p],[A,T,M],[y,b,R]]);if(e===rn.From2000)return new Bi([[x,A,y],[m,T,b],[p,M,R]]);throw"Invalid precess direction"}function Hx(i){const e=.779057273264+.00273781191135448*i.ut,t=i.ut%1;let n=360*((e+t)%1);return n<0&&(n+=360),n}let Ra;function Mh(i){if(!Ra||Ra.tt!==i.tt){const e=i.tt/36525;let t=15*Wr(i).ee;const n=Hx(i);let r=((t+.014506+((((-368e-10*e-29956e-9)*e-44e-8)*e+1.3915817)*e+4612.156534)*e)/3600+n)%360/15;r<0&&(r+=24),Ra={tt:i.tt,st:r}}return Ra.st}function J0(i,e){const t=i.latitude*st,n=Math.sin(t),s=Math.cos(t),r=1/Math.hypot(s,Pl*n),a=Rx*r,o=i.height/1e3,c=Il*r+o,l=Il*a+o,h=(15*e+i.longitude)*st,u=Math.sin(h),d=Math.cos(h);return{pos:[c*s*d/es,c*s*u/es,l*n/es],vel:[-sd*c*s*u*86400/es,sd*c*s*d*86400/es,0]}}function Fl(i,e,t){const n=Q0(e,t);return Z0(n,i)}function Q0(i,e){const t=Wr(i),n=t.mobl*st,s=t.tobl*st,r=t.dpsi*Ws,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(e===rn.From2000)return new Bi([[d,x,A],[f,m,T],[g,p,M]]);if(e===rn.Into2000)return new Bi([[d,f,g],[x,m,p],[A,T,M]]);throw"Invalid precess direction"}function Sh(i,e,t){return t===rn.Into2000?co(Fl(i,e,t),e,t):Fl(co(i,e,t),e,t)}function kx(i,e){const t=Mh(i),n=J0(e,t).pos;return Sh(n,i,rn.Into2000)}class ft{constructor(e,t,n,s){this.x=e,this.y=t,this.z=n,this.t=s}Length(){return Math.hypot(this.x,this.y,this.z)}}class Li{constructor(e,t,n,s,r,a,o){this.x=e,this.y=t,this.z=n,this.vx=s,this.vy=r,this.vz=a,this.t=o}}class yh{constructor(e,t,n){this.lat=Vt(e),this.lon=Vt(t),this.dist=Vt(n)}}class zl{constructor(e,t,n,s){this.ra=Vt(e),this.dec=Vt(t),this.dist=Vt(n),this.vec=s}}class Bi{constructor(e){this.rot=e}}class Gx{constructor(e,t,n,s){this.azimuth=Vt(e),this.altitude=Vt(t),this.ra=Vt(n),this.dec=Vt(s)}}class Vx{constructor(e,t,n){this.vec=e,this.elat=Vt(t),this.elon=Vt(n)}}function j0(i,e){return new ft(i[0],i[1],i[2],e)}function Wx(i,e){const t=j0(i,e),n=t.x*t.x+t.y*t.y,s=Math.sqrt(n+t.z*t.z);if(n===0){if(t.z===0)throw"Indeterminate sky coordinates";return new zl(0,t.z<0?-90:90,s,t)}let r=X0*Math.atan2(t.y,t.x);r<0&&(r+=24);const a=ti*Math.atan2(i[2],Math.sqrt(n));return new zl(r,a,s,t)}function mc(i,e){const t=i*st,n=Math.cos(t),s=Math.sin(t);return[n*e[0]+s*e[1],n*e[1]-s*e[0],e[2]]}function ef(i,e,t,n,s){let r=zt(i);Eh(e),Vt(t),Vt(n);const a=Math.sin(e.latitude*st),o=Math.cos(e.latitude*st),c=Math.sin(e.longitude*st),l=Math.cos(e.longitude*st),h=Math.sin(n*st),u=Math.cos(n*st),d=Math.sin(t*nd),f=Math.cos(t*nd);let g=[o*l,o*c,a],x=[-a*l,-a*c,o],m=[c,-l,0];const p=-15*Mh(r);let A=mc(p,g),T=mc(p,x),M=mc(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],_=y[0]*M[0]+y[1]*M[1]+y[2]*M[2];let E=Math.hypot(R,_),C;E>0?(C=-ti*Math.atan2(_,R),C<0&&(C+=360)):C=0;let D=ti*Math.atan2(E,b),I=t,W=n;if(s){let X=D,O=p3(s,90-D);if(D-=O,O>0&&D>3e-4){const q=Math.sin(D*st),G=Math.cos(D*st),$=Math.sin(X*st),te=Math.cos(X*st),j=[];for(let ie=0;ie<3;++ie)j.push((y[ie]-te*A[ie])/$*q+A[ie]*G);E=Math.hypot(j[0],j[1]),E>0?(I=X0*Math.atan2(j[1],j[0]),I<0&&(I+=24)):I=0,W=ti*Math.atan2(j[2],E)}}return new Gx(C,90-D,I,W)}function Eh(i){if(!(i instanceof Ah))throw`Not an instance of the Observer class: ${i}`;if(Vt(i.latitude),Vt(i.longitude),Vt(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(e,t,n){this.latitude=e,this.longitude=t,this.height=n,Eh(this)}}function Xx(i){const e=zt(i).AddDays(-1/vh),t=js(Qn.Earth,e),n=[-t.x,-t.y,-t.z],[s,r,a]=Sh(n,e,rn.From2000),o=st*Wr(e).tobl,c=Math.cos(o),l=Math.sin(o),h=new ft(s,r,a,e);return tf(h,c,l)}function qx(i,e,t,n,s){Eh(t),oo(n),oo(s);const r=zt(e),a=kx(r,t),o=Kl(i,r,s),c=[o.x-a[0],o.y-a[1],o.z-a[2]],l=Sh(c,r,rn.From2000);return Wx(l,r)}function Yx(i,e,t){const n=zt(i),s=Mh(n);let r=J0(e,s).pos;return j0(r,n)}function tf(i,e,t){const n=i.x,s=i.y*e+i.z*t,r=-i.y*t+i.z*e,a=Math.hypot(n,s);let o=0;a>0&&(o=ti*Math.atan2(s,n),o<0&&(o+=360));let c=ti*Math.atan2(r,a),l=new ft(n,s,r,i.t);return new Vx(l,c,o)}function Bl(i){const e=Wr(i.t),t=[i.x,i.y,i.z],n=co(t,i.t,rn.From2000),[s,r,a]=Fl(n,i.t,rn.From2000),o=new ft(s,r,a,i.t),c=e.tobl*st;return tf(o,Math.cos(c),Math.sin(c))}function sr(i){const e=zt(i),t=Bx(e),n=t.distance_au*Math.cos(t.geo_eclip_lat),s=[n*Math.cos(t.geo_eclip_lon),n*Math.sin(t.geo_eclip_lon),t.distance_au*Math.sin(t.geo_eclip_lat)],r=zx(e,s),a=co(r,e,rn.Into2000);return new ft(a[0],a[1],a[2],e)}function nf(i){const e=zt(i),t=1e-5,n=e.AddDays(-t),s=e.AddDays(+t),r=sr(n),a=sr(s);return new Li((r.x+a.x)/2,(r.y+a.y)/2,(r.z+a.z)/2,(a.x-r.x)/(2*t),(a.y-r.y)/(2*t),(a.z-r.z)/(2*t),e)}function Kx(i){const e=zt(i),t=nf(e),n=1+Y0;return new Li(t.x/n,t.y/n,t.z/n,t.vx/n,t.vy/n,t.vz/n,e)}function Qs(i,e,t){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+e*h);let o=n*a;t&&(o%=ci),s+=o,n*=e}return s}function gc(i,e){let t=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+e*u;o+=l*u*Math.sin(d),r>0&&(c+=l*Math.cos(d))}s+=r*n*c-t*o,n=t,t*=e,++r}return s}const Tr=365250,Hl=0,kl=1,Gl=2;function Vl(i){return new Yt(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 sf(i,e,t){const n=t*Math.cos(e),s=Math.cos(i),r=Math.sin(i);return[n*s,n*r,t*Math.sin(e)]}function js(i,e){const t=e.tt/Tr,n=Qs(i[Hl],t,!0),s=Qs(i[kl],t,!1),r=Qs(i[Gl],t,!1),a=sf(n,s,r);return Vl(a).ToAstroVector(e)}function Wl(i,e){const t=e/Tr,n=Qs(i[Hl],t,!0),s=Qs(i[kl],t,!1),r=Qs(i[Gl],t,!1),a=gc(i[Hl],t),o=gc(i[kl],t),c=gc(i[Gl],t),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=sf(n,s,r),p=[f/Tr,g/Tr,x/Tr],A=Vl(m),T=Vl(p);return new hs(e,A,T)}function Da(i,e,t,n){const s=n/(n+_h),r=js(Qn[t],e);i.x+=s*r.x,i.y+=s*r.y,i.z+=s*r.z}function Zx(i){const e=new ft(0,0,0,i);return Da(e,i,ye.Jupiter,Ll),Da(e,i,ye.Saturn,Nl),Da(e,i,ye.Uranus,Ul),Da(e,i,ye.Neptune,Ol),e}const Xl=51,$x=29200,Xs=146,li=201,ss=[[-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 Yt{constructor(e,t,n){this.x=e,this.y=t,this.z=n}clone(){return new Yt(this.x,this.y,this.z)}ToAstroVector(e){return new ft(this.x,this.y,this.z,e)}static zero(){return new Yt(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new Yt(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new Yt(this.x-e.x,this.y-e.y,this.z-e.z)}incr(e){this.x+=e.x,this.y+=e.y,this.z+=e.z}decr(e){this.x-=e.x,this.y-=e.y,this.z-=e.z}mul(e){return new Yt(e*this.x,e*this.y,e*this.z)}div(e){return new Yt(this.x/e,this.y/e,this.z/e)}mean(e){return new Yt((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new Yt(-this.x,-this.y,-this.z)}}class hs{constructor(e,t,n){this.tt=e,this.r=t,this.v=n}clone(){return new hs(this.tt,this.r,this.v)}sub(e){return new hs(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function Jx(i){let[e,[t,n,s],[r,a,o]]=i;return new hs(e,new Yt(t,n,s),new Yt(r,a,o))}function Ca(i,e,t,n){const s=n/(n+_h),r=Wl(Qn[t],e);return i.r.incr(r.r.mul(s)),i.v.incr(r.v.mul(s)),r}function xr(i,e,t){const n=t.sub(i),s=n.quadrature();return n.mul(e/(s*Math.sqrt(s)))}class bo{constructor(e){let t=new hs(e,new Yt(0,0,0),new Yt(0,0,0));this.Jupiter=Ca(t,e,ye.Jupiter,Ll),this.Saturn=Ca(t,e,ye.Saturn,Nl),this.Uranus=Ca(t,e,ye.Uranus,Ul),this.Neptune=Ca(t,e,ye.Neptune,Ol),this.Jupiter.r.decr(t.r),this.Jupiter.v.decr(t.v),this.Saturn.r.decr(t.r),this.Saturn.v.decr(t.v),this.Uranus.r.decr(t.r),this.Uranus.v.decr(t.v),this.Neptune.r.decr(t.r),this.Neptune.v.decr(t.v),this.Sun=new hs(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=xr(e,_h,this.Sun.r);return t.incr(xr(e,Ll,this.Jupiter.r)),t.incr(xr(e,Nl,this.Saturn.r)),t.incr(xr(e,Ul,this.Uranus.r)),t.incr(xr(e,Ol,this.Neptune.r)),t}}class To{constructor(e,t,n,s){this.tt=e,this.r=t,this.v=n,this.a=s}clone(){return new To(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class rf{constructor(e,t){this.bary=e,this.grav=t}}function lo(i,e,t,n){return new Yt(e.x+i*(t.x+i*n.x/2),e.y+i*(t.y+i*n.y/2),e.z+i*(t.z+i*n.z/2))}function ad(i,e,t){return new Yt(e.x+i*t.x,e.y+i*t.y,e.z+i*t.z)}function ql(i,e){const t=i-e.tt,n=new bo(i),s=lo(t,e.r,e.v,e.a),r=n.Acceleration(s).mean(e.a),a=lo(t,e.r,e.v,r),o=e.v.add(r.mul(t)),c=n.Acceleration(a),l=new To(i,a,o,c);return new rf(n,l)}const Qx=[];function af(i,e){const t=Math.floor(i);return t<0?0:t>=e?e-1:t}function Yl(i){const e=Jx(i),t=new bo(e.tt),n=e.r.add(t.Sun.r),s=e.v.add(t.Sun.v),r=t.Acceleration(n),a=new To(e.tt,n,s,r);return new rf(t,a)}function jx(i,e){const t=ss[0][0];if(e<t||e>ss[Xl-1][0])return null;const n=af((e-t)/$x,Xl-1);if(!i[n]){const r=i[n]=[];r[0]=Yl(ss[n]).grav,r[li-1]=Yl(ss[n+1]).grav;let a,o=r[0].tt;for(a=1;a<li-1;++a)r[a]=ql(o+=Xs,r[a-1]).grav;o=r[li-1].tt;var s=[];for(s[li-1]=r[li-1],a=li-2;a>0;--a)s[a]=ql(o-=Xs,s[a+1]).grav;for(a=li-2;a>0;--a){const c=a/(li-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 od(i,e,t){let n=Yl(i);const s=Math.ceil((e-n.grav.tt)/t);for(let r=0;r<s;++r)n=ql(r+1===s?e:n.grav.tt+t,n.grav);return n}function of(i,e){let t,n,s;const r=jx(Qx,i.tt);if(r){const a=af((i.tt-r[0].tt)/Xs,li-1),o=r[a],c=r[a+1],l=o.a.mean(c.a),h=lo(i.tt-o.tt,o.r,o.v,l),u=ad(i.tt-o.tt,o.v,l),d=lo(i.tt-c.tt,c.r,c.v,l),f=ad(i.tt-c.tt,c.v,l),g=(i.tt-o.tt)/Xs;t=h.mul(1-g).add(d.mul(g)),n=u.mul(1-g).add(f.mul(g))}else{let a;i.tt<ss[0][0]?a=od(ss[0],i.tt,-Xs):a=od(ss[Xl-1],i.tt,+Xs),t=a.grav.r,n=a.grav.v,s=a.bary}return s||(s=new bo(i.tt)),t=t.sub(s.Sun.r),n=n.sub(s.Sun.v),new Li(t.x,t.y,t.z,n.x,n.y,n.z,i)}function Oi(i,e){var t=zt(e);if(i in Qn)return js(Qn[i],t);if(i===ye.Pluto){const a=of(t);return new ft(a.x,a.y,a.z,t)}if(i===ye.Sun)return new ft(0,0,0,t);if(i===ye.Moon){var n=js(Qn.Earth,t),s=sr(t);return new ft(n.x+s.x,n.y+s.y,n.z+s.z,t)}if(i===ye.EMB){const a=js(Qn.Earth,t),o=sr(t),c=1+Y0;return new ft(a.x+o.x/c,a.y+o.y/c,a.z+o.z/c,t)}if(i===ye.SSB)return Zx(t);const r=xh(i);if(r){const a=new yh(r.dec,15*r.ra,r.dist);return lf(a,t)}throw`HelioVector: Unknown body "${i}"`}function e3(i,e){let t=e,n=0;for(let s=0;s<10;++s){const r=i(t),a=r.Length()/vh;if(a>1)throw"Object is too distant for light-travel solver.";const o=e.AddDays(-a);if(n=Math.abs(o.tt-t.tt),n<1e-9)return r;t=o}throw`Light-travel time solver did not converge: dt = ${n}`}class t3{constructor(e,t,n,s){this.observerBody=e,this.targetBody=t,this.aberration=n,this.observerPos=s}Position(e){this.aberration&&(this.observerPos=Oi(this.observerBody,e));const t=Oi(this.targetBody,e);return new ft(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function n3(i,e,t,n){oo(n);const s=zt(i);if(xh(t)){const o=Oi(t,s);if(n){const l=s3(e,s),h=new ft(o.x-l.x,o.y-l.y,o.z-l.z,s),u=vh/h.Length();return new ft(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,s)}const c=Oi(e,s);return new ft(o.x-c.x,o.y-c.y,o.z-c.z,s)}let r;n?r=new ft(0,0,0,s):r=Oi(e,s);const a=new t3(e,t,n,r);return e3(o=>a.Position(o),s)}function Kl(i,e,t){oo(t);const n=zt(e);switch(i){case ye.Earth:return new ft(0,0,0,n);case ye.Moon:return sr(n);default:const s=n3(n,ye.Earth,i,t);return s.t=n,s}}function i3(i,e){return new Li(i.r.x,i.r.y,i.r.z,i.v.x,i.v.y,i.v.z,e)}function s3(i,e){const t=zt(e);switch(i){case ye.Sun:return new Li(0,0,0,0,0,0,t);case ye.SSB:const n=new bo(t.tt);return new Li(-n.Sun.r.x,-n.Sun.r.y,-n.Sun.r.z,-n.Sun.v.x,-n.Sun.v.y,-n.Sun.v.z,t);case ye.Mercury:case ye.Venus:case ye.Earth:case ye.Mars:case ye.Jupiter:case ye.Saturn:case ye.Uranus:case ye.Neptune:const s=Wl(Qn[i],t.tt);return i3(s,t);case ye.Pluto:return of(t);case ye.Moon:case ye.EMB:const r=Wl(Qn.Earth,t.tt),a=i==ye.Moon?nf(t):Kx(t);return new Li(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,t);default:if(xh(i)){const o=Oi(i,t);return new Li(o.x,o.y,o.z,0,0,0,t)}throw`HelioState: Unsupported body "${i}"`}}function r3(i){for(;i<0;)i+=360;for(;i>=360;)i-=360;return i}function a3(i,e,t){if(i===ye.Earth||e===ye.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=zt(t),s=Kl(i,n,!1),r=Bl(s),a=Kl(e,n,!1),o=Bl(a);return r3(r.elon-o.elon)}function o3(i,e,t,n){let s,r=0,a=0,o=0;switch(i){case ye.Mercury:s=-.6,r=4.98,a=-4.88,o=3.02;break;case ye.Venus:e<163.6?(s=-4.47,r=1.03,a=.57,o=.13):(s=.98,r=-1.02);break;case ye.Mars:s=-1.52,r=1.6;break;case ye.Jupiter:s=-9.4,r=.5;break;case ye.Uranus:s=-7.19,r=.25;break;case ye.Neptune:s=-6.87;break;case ye.Pluto:s=-1,r=4;break;default:throw`VisualMagnitude: unsupported body ${i}`}const c=e/100;let l=s+c*(r+c*(a+c*o));return l+=5*Math.log10(t*n),l}function c3(i,e,t,n,s){const r=Bl(n),a=st*28.06,o=st*(169.51+382e-7*s.tt),c=st*r.elat,l=st*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(e*t),{mag:d,ring_tilt:ti*h}}function l3(i,e,t){let n=i*st,s=n*n,r=s*s,a=-12.717+1.49*Math.abs(n)+.0431*r;const o=385000.6/es;let c=t/o;return a+=5*Math.log10(e*c),a}class h3{constructor(e,t,n,s,r,a,o,c){this.time=e,this.mag=t,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(st*n))/2}}function cf(i,e){if(i===ye.Earth)throw"The illumination of the Earth is not defined.";const t=zt(e),n=js(Qn.Earth,t);let s,r,a,o;i===ye.Sun?(a=new ft(-n.x,-n.y,-n.z,t),r=new ft(0,0,0,t),s=0):(i===ye.Moon?(a=sr(t),r=new ft(n.x+a.x,n.y+a.y,n.z+a.z,t)):(r=Oi(i,e),a=new ft(r.x-n.x,r.y-n.y,r.z-n.z,t)),s=Cx(a,r));let c=a.Length(),l=r.Length(),h;if(i===ye.Sun)o=wx+5*Math.log10(c);else if(i===ye.Moon)o=l3(s,l,c);else if(i===ye.Saturn){const u=c3(s,l,c,a,t);o=u.mag,h=u.ring_tilt}else o=o3(i,s,l,c);return new h3(t,o,s,l,c,a,r,h)}function u3(i){return a3(ye.Moon,ye.Sun,i)}var cd;(function(i){i[i.Pericenter=0]="Pericenter",i[i.Apocenter=1]="Apocenter"})(cd||(cd={}));function d3(i,e){return new Bi([[e.rot[0][0]*i.rot[0][0]+e.rot[1][0]*i.rot[0][1]+e.rot[2][0]*i.rot[0][2],e.rot[0][1]*i.rot[0][0]+e.rot[1][1]*i.rot[0][1]+e.rot[2][1]*i.rot[0][2],e.rot[0][2]*i.rot[0][0]+e.rot[1][2]*i.rot[0][1]+e.rot[2][2]*i.rot[0][2]],[e.rot[0][0]*i.rot[1][0]+e.rot[1][0]*i.rot[1][1]+e.rot[2][0]*i.rot[1][2],e.rot[0][1]*i.rot[1][0]+e.rot[1][1]*i.rot[1][1]+e.rot[2][1]*i.rot[1][2],e.rot[0][2]*i.rot[1][0]+e.rot[1][2]*i.rot[1][1]+e.rot[2][2]*i.rot[1][2]],[e.rot[0][0]*i.rot[2][0]+e.rot[1][0]*i.rot[2][1]+e.rot[2][0]*i.rot[2][2],e.rot[0][1]*i.rot[2][0]+e.rot[1][1]*i.rot[2][1]+e.rot[2][1]*i.rot[2][2],e.rot[0][2]*i.rot[2][0]+e.rot[1][2]*i.rot[2][1]+e.rot[2][2]*i.rot[2][2]]])}function lf(i,e){e=zt(e);const t=i.lat*st,n=i.lon*st,s=i.dist*Math.cos(t);return new ft(s*Math.cos(n),s*Math.sin(n),i.dist*Math.sin(t),e)}function hf(i){const e=f3(i);return new zl(e.lon/15,e.lat,e.dist,i)}function f3(i){const e=i.x*i.x+i.y*i.y,t=Math.sqrt(e+i.z*i.z);let n,s;if(e===0){if(i.z===0)throw"Zero-length vector not allowed.";s=0,n=i.z<0?-90:90}else s=ti*Math.atan2(i.y,i.x),s<0&&(s+=360),n=ti*Math.atan2(i.z,Math.sqrt(e));return new yh(n,s,t)}function p3(i,e){let t;if(Vt(e),e<-90||e>90)return 0;if(i==="normal"||i==="jplhor"){let n=e;n<-1&&(n=-1),t=1.02/Math.tan((n+10.3/(n+5.11))*st)/60,i==="normal"&&e<-1&&(t*=(e+90)/89)}else if(!i)t=0;else throw`Invalid refraction option: ${i}`;return t}function Ja(i,e){return new ft(i.rot[0][0]*e.x+i.rot[1][0]*e.y+i.rot[2][0]*e.z,i.rot[0][1]*e.x+i.rot[1][1]*e.y+i.rot[2][1]*e.z,i.rot[0][2]*e.x+i.rot[1][2]*e.y+i.rot[2][2]*e.z,e.t)}function m3(){return new Bi([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function g3(){return new Bi([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function v3(i){i=zt(i);const e=$0(i,rn.From2000),t=Q0(i,rn.From2000);return d3(e,t)}function _3(i){const t=Wr(zt(i)).tobl*st,n=Math.cos(t),s=Math.sin(t);return new Bi([[1,0,0],[0,+n,+s],[0,-s,+n]])}var ld;(function(i){i.Penumbral="penumbral",i.Partial="partial",i.Annular="annular",i.Total="total"})(ld||(ld={}));var hd;(function(i){i[i.Invalid=0]="Invalid",i[i.Ascending=1]="Ascending",i[i.Descending=-1]="Descending"})(hd||(hd={}));const x3=["Venus","Mars","Jupiter","Saturn"];function uf(i){return new Ah(i.lat,i.lng,i.elevationM)}function rr(i,e,t,n,s=!0){const r=ef(t,uf(n),i,e,s?"normal":void 0);return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function vc(i,e,t){const n=uf(t),s=qx(ye[i],e,n,!0,!0),r=ef(e,n,s.ra,s.dec,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function _c(i,e){return cf(ye[i],e).mag}function M3(i){const e=u3(i),t=cf(ye.Moon,i);return{phaseFraction:e/360,illuminatedFraction:t.phase_fraction}}const S3=2e3,y3=3,E3=20;function ud(i,e,t){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??S3,r=i.month??(n?1:y3),a=i.day??(n?1:E3),o=t??Math.round(e/15);return new Date(Date.UTC(s,r-1,a,(i.hour??12)-o,i.minute??0,i.second??0))}class ts{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static apply(e){e.transparent=!0,e.depthWrite=!1,e.onBeforeCompile=t=>{t.fragmentShader=ts.patch(t.fragmentShader)}}static patch(e){return e.replace(ts.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
4505
+ */const iu=173.1446326846693,cs=14959787069098932e-8,at=.017453292519943295,o0=.26179938779914946,ri=57.29577951308232,ap=3.819718634205488,P3=365.24217,c0=new Date("2000-01-01T12:00:00Z"),pi=2*Math.PI,zi=3600*(180/Math.PI),js=484813681109536e-20,op=10800*60,I3=2*op,l0=7292115e-11,L3=op/Math.PI,N3=-.17-5*Math.log10(L3),uh=.996647180302104,U3=uh*uh,dh=6378.1366,O3=dh/cs,cp=81.30056,su=.0002959122082855911,fh=2825345909524226e-22,ph=8459715185680659e-23,mh=1292024916781969e-23,gh=1524358900784276e-23;function Fo(i){if(i!==!0&&i!==!1)throw console.trace(),`Value is not boolean: ${i}`;return i}function Wt(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 F3(i,e){const t=i.x*i.x+i.y*i.y+i.z*i.z;if(Math.abs(t)<1e-8)throw"AngleBetween: first vector is too short.";const n=e.x*e.x+e.y*e.y+e.z*e.z;if(Math.abs(n)<1e-8)throw"AngleBetween: second vector is too short.";const s=(i.x*e.x+i.y*e.y+i.z*e.z)/Math.sqrt(t*n);return s<=-1?180:s>=1?0:ri*Math.acos(s)}var Se;(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"})(Se||(Se={}));const z3=[Se.Star1,Se.Star2,Se.Star3,Se.Star4,Se.Star5,Se.Star6,Se.Star7,Se.Star8],B3=[{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 k3(i){const e=z3.indexOf(i);return e>=0?B3[e]:null}function ru(i){const e=k3(i);return e&&e.dist>0?e:null}var on;(function(i){i[i.From2000=0]="From2000",i[i.Into2000=1]="Into2000"})(on||(on={}));const ni={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 H3(i){var e,t,n,s,r,a,o;const c=2e3+(i-14)/P3;return c<-500?(e=(c-1820)/100,-20+32*e*e):c<500?(e=c/100,t=e*e,n=e*t,s=t*t,r=t*n,a=n*n,10583.6-1014.41*e+33.78311*t-5.952053*n-.1798452*s+.022174192*r+.0090316521*a):c<1600?(e=(c-1e3)/100,t=e*e,n=e*t,s=t*t,r=t*n,a=n*n,1574.2-556.01*e+71.23472*t+.319781*n-.8503463*s-.005050998*r+.0083572073*a):c<1700?(e=c-1600,t=e*e,n=e*t,120-.9808*e-.01532*t+n/7129):c<1800?(e=c-1700,t=e*e,n=e*t,s=t*t,8.83+.1603*e-.0059285*t+13336e-8*n-s/1174e3):c<1860?(e=c-1800,t=e*e,n=e*t,s=t*t,r=t*n,a=n*n,o=n*s,13.72-.332447*e+.0068612*t+.0041116*n-37436e-8*s+121272e-10*r-1699e-10*a+875e-12*o):c<1900?(e=c-1860,t=e*e,n=e*t,s=t*t,r=t*n,7.62+.5737*e-.251754*t+.01680668*n-.0004473624*s+r/233174):c<1920?(e=c-1900,t=e*e,n=e*t,s=t*t,-2.79+1.494119*e-.0598939*t+.0061966*n-197e-6*s):c<1941?(e=c-1920,t=e*e,n=e*t,21.2+.84493*e-.0761*t+.0020936*n):c<1961?(e=c-1950,t=e*e,n=e*t,29.07+.407*e-t/233+n/2547):c<1986?(e=c-1975,t=e*e,n=e*t,45.45+1.067*e-t/260-n/718):c<2005?(e=c-2e3,t=e*e,n=e*t,s=t*t,r=t*n,63.86+.3345*e-.060374*t+.0017275*n+651814e-9*s+2373599e-11*r):c<2050?(e=c-2e3,62.92+.32217*e+.005589*e*e):c<2150?(e=(c-1820)/100,-20+32*e*e-.5628*(2150-c)):(e=(c-1820)/100,-20+32*e*e)}let G3=H3;function h0(i){return i+G3(i)/86400}class ar{constructor(e){if(e instanceof ar){this.date=e.date,this.ut=e.ut,this.tt=e.tt;return}const t=1e3*3600*24;if(e instanceof Date&&Number.isFinite(e.getTime())){this.date=e,this.ut=(e.getTime()-c0.getTime())/t,this.tt=h0(this.ut);return}if(Number.isFinite(e)){this.date=new Date(c0.getTime()+e*t),this.ut=e,this.tt=h0(this.ut);return}throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(e){let t=new ar(e);for(;;){const n=e-t.tt;if(Math.abs(n)<1e-12)return t;t=t.AddDays(n)}}toString(){return this.date.toISOString()}AddDays(e){return new ar(this.ut+e)}}function Bt(i){return i instanceof ar?i:new ar(i)}function V3(i){function e(d){return d%I3*js}const t=i.tt/36525,n=e(128710479305e-5+t*1295965810481e-4),s=e(335779.526232+t*17395272628478e-4),r=e(107226070369e-5+t*1602961601209e-3),a=e(450160.398036-t*69628905431e-4);let o=Math.sin(a),c=Math.cos(a),l=(-172064161-174666*t)*o+33386*c,h=(92052331+9086*t)*c+15377*o,u=2*(s-r+a);return o=Math.sin(u),c=Math.cos(u),l+=(-13170906-1675*t)*o-13696*c,h+=(5730336-3015*t)*c-4587*o,u=2*(s+a),o=Math.sin(u),c=Math.cos(u),l+=(-2276413-234*t)*o+2796*c,h+=(978459-485*t)*c+1374*o,u=2*a,o=Math.sin(u),c=Math.cos(u),l+=(2074554+207*t)*o-698*c,h+=(-897492+470*t)*c-291*o,o=Math.sin(n),c=Math.cos(n),l+=(1475877-3633*t)*o+11817*c,h+=(73871-184*t)*c-1924*o,{dpsi:-135e-6+l*1e-7,deps:388e-6+h*1e-7}}function lp(i){var e=i.tt/36525,t=((((-434e-10*e-576e-9)*e+.0020034)*e-1831e-7)*e-46.836769)*e+84381.406;return t/3600}var ja;function ua(i){if(!ja||Math.abs(ja.tt-i.tt)>1e-6){const e=V3(i),t=lp(i),n=t+e.deps/3600;ja={tt:i.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*at)/15,mobl:t,tobl:n}}return ja}function W3(i,e){const t=i*at,n=Math.cos(t),s=Math.sin(t);return[e[0],e[1]*n-e[2]*s,e[1]*s+e[2]*n]}function X3(i,e){return W3(lp(i),e)}function q3(i){const e=i.tt/36525;function t(Te,xe){const Ne=[];let Ue;for(Ue=0;Ue<=xe-Te;++Ue)Ne.push(0);return{min:Te,array:Ne}}function n(Te,xe,Ne,Ue){const Oe=[];for(let tt=0;tt<=xe-Te;++tt)Oe.push(t(Ne,Ue));return{min:Te,array:Oe}}function s(Te,xe,Ne){const Ue=Te.array[xe-Te.min];return Ue.array[Ne-Ue.min]}function r(Te,xe,Ne,Ue){const Oe=Te.array[xe-Te.min];Oe.array[Ne-Oe.min]=Ue}let a,o,c,l,h,u,d,f,g,x,m,p,b,w,M,S,A,R,_,E,C,D,I,V=n(-6,6,1,4),q=n(-6,6,1,4);function U(Te,xe){return s(V,Te,xe)}function X(Te,xe){return s(q,Te,xe)}function G(Te,xe,Ne){return r(V,Te,xe,Ne)}function Z(Te,xe,Ne){return r(q,Te,xe,Ne)}function te(Te,xe,Ne,Ue,Oe){Oe(Te*Ne-xe*Ue,xe*Ne+Te*Ue)}function j(Te){return Math.sin(pi*Te)}d=e*e,g=0,I=0,m=0,p=3422.7;var ie=j(.19833+.05611*e),ue=j(.27869+.04508*e),He=j(.16827-.36903*e),Ze=j(.34734-5.37261*e),ke=j(.10498-5.37899*e),Y=j(.42681-.41855*e),re=j(.14943-5.37511*e);for(R=.84*ie+.31*ue+14.27*He+7.26*Ze+.28*ke+.24*Y,_=2.94*ie+.31*ue+14.27*He+9.34*Ze+1.12*ke+.83*Y,E=-6.4*ie-1.89*Y,C=.21*ie+.31*ue+14.27*He-88.7*Ze-15.3*ke+.24*Y-1.86*re,D=R-E,f=-3332e-9*j(.59734-5.37261*e)-539e-9*j(.35498-5.37899*e)-64e-9*j(.39943-5.37511*e),b=pi*Ys(.60643382+1336.85522467*e-313e-8*d)+R/zi,w=pi*Ys(.37489701+1325.55240982*e+2565e-8*d)+_/zi,M=pi*Ys(.99312619+99.99735956*e-44e-8*d)+E/zi,S=pi*Ys(.25909118+1342.2278298*e-892e-8*d)+C/zi,A=pi*Ys(.82736186+1236.85308708*e-397e-8*d)+D/zi,h=1;h<=4;++h){switch(h){case 1:c=w,o=4,l=1.000002208;break;case 2:c=M,o=3,l=.997504612-.002495388*e;break;case 3:c=S,o=4,l=1.000002708+139.978*f;break;case 4:c=A,o=6,l=1;break;default:throw`Internal error: I = ${h}`}for(G(0,h,1),G(1,h,Math.cos(c)*l),Z(0,h,0),Z(1,h,Math.sin(c)*l),u=2;u<=o;++u)te(U(u-1,h),X(u-1,h),U(1,h),X(1,h),(Te,xe)=>(G(u,h,Te),Z(u,h,xe)));for(u=1;u<=o;++u)G(-u,h,U(u,h)),Z(-u,h,-X(u,h))}function ne(Te,xe,Ne,Ue){for(var Oe={x:1,y:0},tt=[0,Te,xe,Ne,Ue],nt=1;nt<=4;++nt)tt[nt]!==0&&te(Oe.x,Oe.y,U(tt[nt],nt),X(tt[nt],nt),(Mt,gt)=>(Oe.x=Mt,Oe.y=gt));return Oe}function z(Te,xe,Ne,Ue,Oe,tt,nt,Mt){var gt=ne(Oe,tt,nt,Mt);g+=Te*gt.y,I+=xe*gt.y,m+=Ne*gt.x,p+=Ue*gt.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 be(Te,xe,Ne,Ue,Oe){return Te*ne(xe,Ne,Ue,Oe).y}x=0,x+=be(-526.069,0,0,1,-2),x+=be(-3.352,0,0,1,-4),x+=be(44.297,1,0,1,-2),x+=be(-6,1,0,1,-4),x+=be(20.599,-1,0,1,0),x+=be(-30.598,-1,0,1,-2),x+=be(-24.649,-2,0,1,0),x+=be(-2,-2,0,1,-2),x+=be(-22.571,0,1,1,-2),x+=be(10.985,0,-1,1,-2),g+=.82*j(.7736-62.5512*e)+.31*j(.0466-125.1025*e)+.35*j(.5785-25.1042*e)+.66*j(.4591+1335.8075*e)+.64*j(.313-91.568*e)+1.14*j(.148+1331.2898*e)+.21*j(.5918+1056.5859*e)+.44*j(.5784+1322.8595*e)+.24*j(.2275-5.7374*e)+.28*j(.2965+2.6929*e)+.33*j(.3132+6.3368*e),a=S+I/zi;let Pe=(1.000002708+139.978*f)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+x;return{geo_eclip_lon:pi*Ys((b+g/zi)/pi),geo_eclip_lat:Math.PI/(180*3600)*Pe,distance_au:zi*O3/(.999953253*p)}}function hp(i,e){return[i.rot[0][0]*e[0]+i.rot[1][0]*e[1]+i.rot[2][0]*e[2],i.rot[0][1]*e[0]+i.rot[1][1]*e[1]+i.rot[2][1]*e[2],i.rot[0][2]*e[0]+i.rot[1][2]*e[1]+i.rot[2][2]*e[2]]}function zo(i,e,t){const n=up(e,t);return hp(n,i)}function up(i,e){const t=i.tt/36525;let n=84381.406,s=((((-951e-10*t+132851e-9)*t-.00114045)*t-1.0790069)*t+5038.481507)*t,r=((((3337e-10*t-467e-9)*t-.00772503)*t+.0512623)*t-.025754)*t+n,a=((((-56e-9*t+170663e-9)*t-.00121197)*t-2.3814292)*t+10.556403)*t;n*=js,s*=js,r*=js,a*=js;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,b=-f*h-l*g*d,w=-f*l*c+g*d*h*c-o*g*u,M=-f*l*o+g*d*h*o+c*g*u,S=l*u,A=-u*h*c-o*d,R=-u*h*o+d*c;if(e===on.Into2000)return new Yi([[x,m,p],[b,w,M],[S,A,R]]);if(e===on.From2000)return new Yi([[x,b,S],[m,w,A],[p,M,R]]);throw"Invalid precess direction"}function Y3(i){const e=.779057273264+.00273781191135448*i.ut,t=i.ut%1;let n=360*((e+t)%1);return n<0&&(n+=360),n}let eo;function au(i){if(!eo||eo.tt!==i.tt){const e=i.tt/36525;let t=15*ua(i).ee;const n=Y3(i);let r=((t+.014506+((((-368e-10*e-29956e-9)*e-44e-8)*e+1.3915817)*e+4612.156534)*e)/3600+n)%360/15;r<0&&(r+=24),eo={tt:i.tt,st:r}}return eo.st}function dp(i,e){const t=i.latitude*at,n=Math.sin(t),s=Math.cos(t),r=1/Math.hypot(s,uh*n),a=U3*r,o=i.height/1e3,c=dh*r+o,l=dh*a+o,h=(15*e+i.longitude)*at,u=Math.sin(h),d=Math.cos(h);return{pos:[c*s*d/cs,c*s*u/cs,l*n/cs],vel:[-l0*c*s*u*86400/cs,l0*c*s*d*86400/cs,0]}}function vh(i,e,t){const n=fp(e,t);return hp(n,i)}function fp(i,e){const t=ua(i),n=t.mobl*at,s=t.tobl*at,r=t.dpsi*js,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,b=u*l,w=h*a*l-o*c,M=h*o*l+a*c;if(e===on.From2000)return new Yi([[d,x,b],[f,m,w],[g,p,M]]);if(e===on.Into2000)return new Yi([[d,f,g],[x,m,p],[b,w,M]]);throw"Invalid precess direction"}function ou(i,e,t){return t===on.Into2000?zo(vh(i,e,t),e,t):vh(zo(i,e,t),e,t)}function K3(i,e){const t=au(i),n=dp(e,t).pos;return ou(n,i,on.Into2000)}class mt{constructor(e,t,n,s){this.x=e,this.y=t,this.z=n,this.t=s}Length(){return Math.hypot(this.x,this.y,this.z)}}class Vi{constructor(e,t,n,s,r,a,o){this.x=e,this.y=t,this.z=n,this.vx=s,this.vy=r,this.vz=a,this.t=o}}class cu{constructor(e,t,n){this.lat=Wt(e),this.lon=Wt(t),this.dist=Wt(n)}}class _h{constructor(e,t,n,s){this.ra=Wt(e),this.dec=Wt(t),this.dist=Wt(n),this.vec=s}}class Yi{constructor(e){this.rot=e}}class $3{constructor(e,t,n,s){this.azimuth=Wt(e),this.altitude=Wt(t),this.ra=Wt(n),this.dec=Wt(s)}}class Z3{constructor(e,t,n){this.vec=e,this.elat=Wt(t),this.elon=Wt(n)}}function pp(i,e){return new mt(i[0],i[1],i[2],e)}function J3(i,e){const t=pp(i,e),n=t.x*t.x+t.y*t.y,s=Math.sqrt(n+t.z*t.z);if(n===0){if(t.z===0)throw"Indeterminate sky coordinates";return new _h(0,t.z<0?-90:90,s,t)}let r=ap*Math.atan2(t.y,t.x);r<0&&(r+=24);const a=ri*Math.atan2(i[2],Math.sqrt(n));return new _h(r,a,s,t)}function qc(i,e){const t=i*at,n=Math.cos(t),s=Math.sin(t);return[n*e[0]+s*e[1],n*e[1]-s*e[0],e[2]]}function mp(i,e,t,n,s){let r=Bt(i);lu(e),Wt(t),Wt(n);const a=Math.sin(e.latitude*at),o=Math.cos(e.latitude*at),c=Math.sin(e.longitude*at),l=Math.cos(e.longitude*at),h=Math.sin(n*at),u=Math.cos(n*at),d=Math.sin(t*o0),f=Math.cos(t*o0);let g=[o*l,o*c,a],x=[-a*l,-a*c,o],m=[c,-l,0];const p=-15*au(r);let b=qc(p,g),w=qc(p,x),M=qc(p,m),S=[u*f,u*d,h];const A=S[0]*b[0]+S[1]*b[1]+S[2]*b[2],R=S[0]*w[0]+S[1]*w[1]+S[2]*w[2],_=S[0]*M[0]+S[1]*M[1]+S[2]*M[2];let E=Math.hypot(R,_),C;E>0?(C=-ri*Math.atan2(_,R),C<0&&(C+=360)):C=0;let D=ri*Math.atan2(E,A),I=t,V=n;if(s){let q=D,U=yy(s,90-D);if(D-=U,U>0&&D>3e-4){const X=Math.sin(D*at),G=Math.cos(D*at),Z=Math.sin(q*at),te=Math.cos(q*at),j=[];for(let ie=0;ie<3;++ie)j.push((S[ie]-te*b[ie])/Z*X+b[ie]*G);E=Math.hypot(j[0],j[1]),E>0?(I=ap*Math.atan2(j[1],j[0]),I<0&&(I+=24)):I=0,V=ri*Math.atan2(j[2],E)}}return new $3(C,90-D,I,V)}function lu(i){if(!(i instanceof hu))throw`Not an instance of the Observer class: ${i}`;if(Wt(i.latitude),Wt(i.longitude),Wt(i.height),i.latitude<-90||i.latitude>90)throw`Latitude ${i.latitude} is out of range. Must be -90..+90.`;return i}class hu{constructor(e,t,n){this.latitude=e,this.longitude=t,this.height=n,lu(this)}}function Q3(i){const e=Bt(i).AddDays(-1/iu),t=cr(ni.Earth,e),n=[-t.x,-t.y,-t.z],[s,r,a]=ou(n,e,on.From2000),o=at*ua(e).tobl,c=Math.cos(o),l=Math.sin(o),h=new mt(s,r,a,e);return gp(h,c,l)}function j3(i,e,t,n,s){lu(t),Fo(n),Fo(s);const r=Bt(e),a=K3(r,t),o=Rh(i,r,s),c=[o.x-a[0],o.y-a[1],o.z-a[2]],l=ou(c,r,on.From2000);return J3(l,r)}function ey(i,e,t){const n=Bt(i),s=au(n);let r=dp(e,s).pos;return pp(r,n)}function gp(i,e,t){const n=i.x,s=i.y*e+i.z*t,r=-i.y*t+i.z*e,a=Math.hypot(n,s);let o=0;a>0&&(o=ri*Math.atan2(s,n),o<0&&(o+=360));let c=ri*Math.atan2(r,a),l=new mt(n,s,r,i.t);return new Z3(l,c,o)}function xh(i){const e=ua(i.t),t=[i.x,i.y,i.z],n=zo(t,i.t,on.From2000),[s,r,a]=vh(n,i.t,on.From2000),o=new mt(s,r,a,i.t),c=e.tobl*at;return gp(o,Math.cos(c),Math.sin(c))}function pr(i){const e=Bt(i),t=q3(e),n=t.distance_au*Math.cos(t.geo_eclip_lat),s=[n*Math.cos(t.geo_eclip_lon),n*Math.sin(t.geo_eclip_lon),t.distance_au*Math.sin(t.geo_eclip_lat)],r=X3(e,s),a=zo(r,e,on.Into2000);return new mt(a[0],a[1],a[2],e)}function vp(i){const e=Bt(i),t=1e-5,n=e.AddDays(-t),s=e.AddDays(+t),r=pr(n),a=pr(s);return new Vi((r.x+a.x)/2,(r.y+a.y)/2,(r.z+a.z)/2,(a.x-r.x)/(2*t),(a.y-r.y)/(2*t),(a.z-r.z)/(2*t),e)}function ty(i){const e=Bt(i),t=vp(e),n=1+cp;return new Vi(t.x/n,t.y/n,t.z/n,t.vx/n,t.vy/n,t.vz/n,e)}function or(i,e,t){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+e*h);let o=n*a;t&&(o%=pi),s+=o,n*=e}return s}function Yc(i,e){let t=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+e*u;o+=l*u*Math.sin(d),r>0&&(c+=l*Math.cos(d))}s+=r*n*c-t*o,n=t,t*=e,++r}return s}const Gr=365250,Mh=0,yh=1,Sh=2;function Eh(i){return new $t(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 _p(i,e,t){const n=t*Math.cos(e),s=Math.cos(i),r=Math.sin(i);return[n*s,n*r,t*Math.sin(e)]}function cr(i,e){const t=e.tt/Gr,n=or(i[Mh],t,!0),s=or(i[yh],t,!1),r=or(i[Sh],t,!1),a=_p(n,s,r);return Eh(a).ToAstroVector(e)}function bh(i,e){const t=e/Gr,n=or(i[Mh],t,!0),s=or(i[yh],t,!1),r=or(i[Sh],t,!1),a=Yc(i[Mh],t),o=Yc(i[yh],t),c=Yc(i[Sh],t),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=_p(n,s,r),p=[f/Gr,g/Gr,x/Gr],b=Eh(m),w=Eh(p);return new _s(e,b,w)}function to(i,e,t,n){const s=n/(n+su),r=cr(ni[t],e);i.x+=s*r.x,i.y+=s*r.y,i.z+=s*r.z}function ny(i){const e=new mt(0,0,0,i);return to(e,i,Se.Jupiter,fh),to(e,i,Se.Saturn,ph),to(e,i,Se.Uranus,mh),to(e,i,Se.Neptune,gh),e}const Ah=51,iy=29200,er=146,mi=201,ds=[[-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 $t{constructor(e,t,n){this.x=e,this.y=t,this.z=n}clone(){return new $t(this.x,this.y,this.z)}ToAstroVector(e){return new mt(this.x,this.y,this.z,e)}static zero(){return new $t(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new $t(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new $t(this.x-e.x,this.y-e.y,this.z-e.z)}incr(e){this.x+=e.x,this.y+=e.y,this.z+=e.z}decr(e){this.x-=e.x,this.y-=e.y,this.z-=e.z}mul(e){return new $t(e*this.x,e*this.y,e*this.z)}div(e){return new $t(this.x/e,this.y/e,this.z/e)}mean(e){return new $t((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new $t(-this.x,-this.y,-this.z)}}class _s{constructor(e,t,n){this.tt=e,this.r=t,this.v=n}clone(){return new _s(this.tt,this.r,this.v)}sub(e){return new _s(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function sy(i){let[e,[t,n,s],[r,a,o]]=i;return new _s(e,new $t(t,n,s),new $t(r,a,o))}function no(i,e,t,n){const s=n/(n+su),r=bh(ni[t],e);return i.r.incr(r.r.mul(s)),i.v.incr(r.v.mul(s)),r}function Ur(i,e,t){const n=t.sub(i),s=n.quadrature();return n.mul(e/(s*Math.sqrt(s)))}class jo{constructor(e){let t=new _s(e,new $t(0,0,0),new $t(0,0,0));this.Jupiter=no(t,e,Se.Jupiter,fh),this.Saturn=no(t,e,Se.Saturn,ph),this.Uranus=no(t,e,Se.Uranus,mh),this.Neptune=no(t,e,Se.Neptune,gh),this.Jupiter.r.decr(t.r),this.Jupiter.v.decr(t.v),this.Saturn.r.decr(t.r),this.Saturn.v.decr(t.v),this.Uranus.r.decr(t.r),this.Uranus.v.decr(t.v),this.Neptune.r.decr(t.r),this.Neptune.v.decr(t.v),this.Sun=new _s(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=Ur(e,su,this.Sun.r);return t.incr(Ur(e,fh,this.Jupiter.r)),t.incr(Ur(e,ph,this.Saturn.r)),t.incr(Ur(e,mh,this.Uranus.r)),t.incr(Ur(e,gh,this.Neptune.r)),t}}class ec{constructor(e,t,n,s){this.tt=e,this.r=t,this.v=n,this.a=s}clone(){return new ec(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class xp{constructor(e,t){this.bary=e,this.grav=t}}function Bo(i,e,t,n){return new $t(e.x+i*(t.x+i*n.x/2),e.y+i*(t.y+i*n.y/2),e.z+i*(t.z+i*n.z/2))}function u0(i,e,t){return new $t(e.x+i*t.x,e.y+i*t.y,e.z+i*t.z)}function wh(i,e){const t=i-e.tt,n=new jo(i),s=Bo(t,e.r,e.v,e.a),r=n.Acceleration(s).mean(e.a),a=Bo(t,e.r,e.v,r),o=e.v.add(r.mul(t)),c=n.Acceleration(a),l=new ec(i,a,o,c);return new xp(n,l)}const ry=[];function Mp(i,e){const t=Math.floor(i);return t<0?0:t>=e?e-1:t}function Th(i){const e=sy(i),t=new jo(e.tt),n=e.r.add(t.Sun.r),s=e.v.add(t.Sun.v),r=t.Acceleration(n),a=new ec(e.tt,n,s,r);return new xp(t,a)}function ay(i,e){const t=ds[0][0];if(e<t||e>ds[Ah-1][0])return null;const n=Mp((e-t)/iy,Ah-1);if(!i[n]){const r=i[n]=[];r[0]=Th(ds[n]).grav,r[mi-1]=Th(ds[n+1]).grav;let a,o=r[0].tt;for(a=1;a<mi-1;++a)r[a]=wh(o+=er,r[a-1]).grav;o=r[mi-1].tt;var s=[];for(s[mi-1]=r[mi-1],a=mi-2;a>0;--a)s[a]=wh(o-=er,s[a+1]).grav;for(a=mi-2;a>0;--a){const c=a/(mi-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 d0(i,e,t){let n=Th(i);const s=Math.ceil((e-n.grav.tt)/t);for(let r=0;r<s;++r)n=wh(r+1===s?e:n.grav.tt+t,n.grav);return n}function yp(i,e){let t,n,s;const r=ay(ry,i.tt);if(r){const a=Mp((i.tt-r[0].tt)/er,mi-1),o=r[a],c=r[a+1],l=o.a.mean(c.a),h=Bo(i.tt-o.tt,o.r,o.v,l),u=u0(i.tt-o.tt,o.v,l),d=Bo(i.tt-c.tt,c.r,c.v,l),f=u0(i.tt-c.tt,c.v,l),g=(i.tt-o.tt)/er;t=h.mul(1-g).add(d.mul(g)),n=u.mul(1-g).add(f.mul(g))}else{let a;i.tt<ds[0][0]?a=d0(ds[0],i.tt,-er):a=d0(ds[Ah-1],i.tt,+er),t=a.grav.r,n=a.grav.v,s=a.bary}return s||(s=new jo(i.tt)),t=t.sub(s.Sun.r),n=n.sub(s.Sun.v),new Vi(t.x,t.y,t.z,n.x,n.y,n.z,i)}function Xi(i,e){var t=Bt(e);if(i in ni)return cr(ni[i],t);if(i===Se.Pluto){const a=yp(t);return new mt(a.x,a.y,a.z,t)}if(i===Se.Sun)return new mt(0,0,0,t);if(i===Se.Moon){var n=cr(ni.Earth,t),s=pr(t);return new mt(n.x+s.x,n.y+s.y,n.z+s.z,t)}if(i===Se.EMB){const a=cr(ni.Earth,t),o=pr(t),c=1+cp;return new mt(a.x+o.x/c,a.y+o.y/c,a.z+o.z/c,t)}if(i===Se.SSB)return ny(t);const r=ru(i);if(r){const a=new cu(r.dec,15*r.ra,r.dist);return Ep(a,t)}throw`HelioVector: Unknown body "${i}"`}function oy(i,e){let t=e,n=0;for(let s=0;s<10;++s){const r=i(t),a=r.Length()/iu;if(a>1)throw"Object is too distant for light-travel solver.";const o=e.AddDays(-a);if(n=Math.abs(o.tt-t.tt),n<1e-9)return r;t=o}throw`Light-travel time solver did not converge: dt = ${n}`}class cy{constructor(e,t,n,s){this.observerBody=e,this.targetBody=t,this.aberration=n,this.observerPos=s}Position(e){this.aberration&&(this.observerPos=Xi(this.observerBody,e));const t=Xi(this.targetBody,e);return new mt(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function ly(i,e,t,n){Fo(n);const s=Bt(i);if(ru(t)){const o=Xi(t,s);if(n){const l=uy(e,s),h=new mt(o.x-l.x,o.y-l.y,o.z-l.z,s),u=iu/h.Length();return new mt(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,s)}const c=Xi(e,s);return new mt(o.x-c.x,o.y-c.y,o.z-c.z,s)}let r;n?r=new mt(0,0,0,s):r=Xi(e,s);const a=new cy(e,t,n,r);return oy(o=>a.Position(o),s)}function Rh(i,e,t){Fo(t);const n=Bt(e);switch(i){case Se.Earth:return new mt(0,0,0,n);case Se.Moon:return pr(n);default:const s=ly(n,Se.Earth,i,t);return s.t=n,s}}function hy(i,e){return new Vi(i.r.x,i.r.y,i.r.z,i.v.x,i.v.y,i.v.z,e)}function uy(i,e){const t=Bt(e);switch(i){case Se.Sun:return new Vi(0,0,0,0,0,0,t);case Se.SSB:const n=new jo(t.tt);return new Vi(-n.Sun.r.x,-n.Sun.r.y,-n.Sun.r.z,-n.Sun.v.x,-n.Sun.v.y,-n.Sun.v.z,t);case Se.Mercury:case Se.Venus:case Se.Earth:case Se.Mars:case Se.Jupiter:case Se.Saturn:case Se.Uranus:case Se.Neptune:const s=bh(ni[i],t.tt);return hy(s,t);case Se.Pluto:return yp(t);case Se.Moon:case Se.EMB:const r=bh(ni.Earth,t.tt),a=i==Se.Moon?vp(t):ty(t);return new Vi(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,t);default:if(ru(i)){const o=Xi(i,t);return new Vi(o.x,o.y,o.z,0,0,0,t)}throw`HelioState: Unsupported body "${i}"`}}function dy(i){for(;i<0;)i+=360;for(;i>=360;)i-=360;return i}function fy(i,e,t){if(i===Se.Earth||e===Se.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=Bt(t),s=Rh(i,n,!1),r=xh(s),a=Rh(e,n,!1),o=xh(a);return dy(r.elon-o.elon)}function py(i,e,t,n){let s,r=0,a=0,o=0;switch(i){case Se.Mercury:s=-.6,r=4.98,a=-4.88,o=3.02;break;case Se.Venus:e<163.6?(s=-4.47,r=1.03,a=.57,o=.13):(s=.98,r=-1.02);break;case Se.Mars:s=-1.52,r=1.6;break;case Se.Jupiter:s=-9.4,r=.5;break;case Se.Uranus:s=-7.19,r=.25;break;case Se.Neptune:s=-6.87;break;case Se.Pluto:s=-1,r=4;break;default:throw`VisualMagnitude: unsupported body ${i}`}const c=e/100;let l=s+c*(r+c*(a+c*o));return l+=5*Math.log10(t*n),l}function my(i,e,t,n,s){const r=xh(n),a=at*28.06,o=at*(169.51+382e-7*s.tt),c=at*r.elat,l=at*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(e*t),{mag:d,ring_tilt:ri*h}}function gy(i,e,t){let n=i*at,s=n*n,r=s*s,a=-12.717+1.49*Math.abs(n)+.0431*r;const o=385000.6/cs;let c=t/o;return a+=5*Math.log10(e*c),a}class vy{constructor(e,t,n,s,r,a,o,c){this.time=e,this.mag=t,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(at*n))/2}}function Sp(i,e){if(i===Se.Earth)throw"The illumination of the Earth is not defined.";const t=Bt(e),n=cr(ni.Earth,t);let s,r,a,o;i===Se.Sun?(a=new mt(-n.x,-n.y,-n.z,t),r=new mt(0,0,0,t),s=0):(i===Se.Moon?(a=pr(t),r=new mt(n.x+a.x,n.y+a.y,n.z+a.z,t)):(r=Xi(i,e),a=new mt(r.x-n.x,r.y-n.y,r.z-n.z,t)),s=F3(a,r));let c=a.Length(),l=r.Length(),h;if(i===Se.Sun)o=N3+5*Math.log10(c);else if(i===Se.Moon)o=gy(s,l,c);else if(i===Se.Saturn){const u=my(s,l,c,a,t);o=u.mag,h=u.ring_tilt}else o=py(i,s,l,c);return new vy(t,o,s,l,c,a,r,h)}function _y(i){return fy(Se.Moon,Se.Sun,i)}var f0;(function(i){i[i.Pericenter=0]="Pericenter",i[i.Apocenter=1]="Apocenter"})(f0||(f0={}));function xy(i,e){return new Yi([[e.rot[0][0]*i.rot[0][0]+e.rot[1][0]*i.rot[0][1]+e.rot[2][0]*i.rot[0][2],e.rot[0][1]*i.rot[0][0]+e.rot[1][1]*i.rot[0][1]+e.rot[2][1]*i.rot[0][2],e.rot[0][2]*i.rot[0][0]+e.rot[1][2]*i.rot[0][1]+e.rot[2][2]*i.rot[0][2]],[e.rot[0][0]*i.rot[1][0]+e.rot[1][0]*i.rot[1][1]+e.rot[2][0]*i.rot[1][2],e.rot[0][1]*i.rot[1][0]+e.rot[1][1]*i.rot[1][1]+e.rot[2][1]*i.rot[1][2],e.rot[0][2]*i.rot[1][0]+e.rot[1][2]*i.rot[1][1]+e.rot[2][2]*i.rot[1][2]],[e.rot[0][0]*i.rot[2][0]+e.rot[1][0]*i.rot[2][1]+e.rot[2][0]*i.rot[2][2],e.rot[0][1]*i.rot[2][0]+e.rot[1][1]*i.rot[2][1]+e.rot[2][1]*i.rot[2][2],e.rot[0][2]*i.rot[2][0]+e.rot[1][2]*i.rot[2][1]+e.rot[2][2]*i.rot[2][2]]])}function Ep(i,e){e=Bt(e);const t=i.lat*at,n=i.lon*at,s=i.dist*Math.cos(t);return new mt(s*Math.cos(n),s*Math.sin(n),i.dist*Math.sin(t),e)}function bp(i){const e=My(i);return new _h(e.lon/15,e.lat,e.dist,i)}function My(i){const e=i.x*i.x+i.y*i.y,t=Math.sqrt(e+i.z*i.z);let n,s;if(e===0){if(i.z===0)throw"Zero-length vector not allowed.";s=0,n=i.z<0?-90:90}else s=ri*Math.atan2(i.y,i.x),s<0&&(s+=360),n=ri*Math.atan2(i.z,Math.sqrt(e));return new cu(n,s,t)}function yy(i,e){let t;if(Wt(e),e<-90||e>90)return 0;if(i==="normal"||i==="jplhor"){let n=e;n<-1&&(n=-1),t=1.02/Math.tan((n+10.3/(n+5.11))*at)/60,i==="normal"&&e<-1&&(t*=(e+90)/89)}else if(!i)t=0;else throw`Invalid refraction option: ${i}`;return t}function bo(i,e){return new mt(i.rot[0][0]*e.x+i.rot[1][0]*e.y+i.rot[2][0]*e.z,i.rot[0][1]*e.x+i.rot[1][1]*e.y+i.rot[2][1]*e.z,i.rot[0][2]*e.x+i.rot[1][2]*e.y+i.rot[2][2]*e.z,e.t)}function Sy(){return new Yi([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function Ey(){return new Yi([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function by(i){i=Bt(i);const e=up(i,on.From2000),t=fp(i,on.From2000);return xy(e,t)}function Ay(i){const t=ua(Bt(i)).tobl*at,n=Math.cos(t),s=Math.sin(t);return new Yi([[1,0,0],[0,+n,+s],[0,-s,+n]])}var p0;(function(i){i.Penumbral="penumbral",i.Partial="partial",i.Annular="annular",i.Total="total"})(p0||(p0={}));var m0;(function(i){i[i.Invalid=0]="Invalid",i[i.Ascending=1]="Ascending",i[i.Descending=-1]="Descending"})(m0||(m0={}));const wy=["Venus","Mars","Jupiter","Saturn"];function Ap(i){return new hu(i.lat,i.lng,i.elevationM)}function mr(i,e,t,n,s=!0){const r=mp(t,Ap(n),i,e,s?"normal":void 0);return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function Kc(i,e,t){const n=Ap(t),s=j3(Se[i],e,n,!0,!0),r=mp(e,n,s.ra,s.dec,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function $c(i,e){return Sp(Se[i],e).mag}function Ty(i){const e=_y(i),t=Sp(Se.Moon,i);return{phaseFraction:e/360,illuminatedFraction:t.phase_fraction}}const Ry=2e3,Dy=3,Cy=20;function g0(i,e,t){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??Ry,r=i.month??(n?1:Dy),a=i.day??(n?1:Cy),o=t??Math.round(e/15);return new Date(Date.UTC(s,r-1,a,(i.hour??12)-o,i.minute??0,i.second??0))}class ls{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static apply(e){e.transparent=!0,e.depthWrite=!1,e.onBeforeCompile=t=>{t.fragmentShader=ls.patch(t.fragmentShader)}}static patch(e){return e.replace(ls.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
4506
4506
  // Outside the inscribed circle there is no star at all — this is what kills the corners.
4507
- if ( distanceFromCentre > ${ts.RIM.toFixed(2)} ) discard;
4508
- float glare = 1.0 - smoothstep( ${ts.CORE.toFixed(2)}, ${ts.RIM.toFixed(2)}, distanceFromCentre );
4509
- vec4 diffuseColor = vec4( diffuse, opacity * glare );`)}}const A3=[{name:{en:"Sirius",fr:"Sirius"},raHours:6.7525,decDeg:-16.7161,mag:-1.44},{name:{en:"Canopus",fr:"Canopus"},raHours:6.3992,decDeg:-52.6957,mag:-.62},{name:{en:"Arcturus",fr:"Arcturus"},raHours:14.261,decDeg:19.1824,mag:-.05},{name:{en:"Rigil Kentaurus",fr:"Rigil Kentaurus"},raHours:14.6608,decDeg:-60.834,mag:-.01},{name:{en:"Vega",fr:"Véga"},raHours:18.6156,decDeg:38.7837,mag:.03},{name:{en:"Capella",fr:"Capella"},raHours:5.2782,decDeg:45.998,mag:.08},{name:{en:"Rigel",fr:"Rigel"},raHours:5.2423,decDeg:-8.2016,mag:.18},{name:{en:"Procyon",fr:"Procyon"},raHours:7.655,decDeg:5.225,mag:.4},{name:{en:"Achernar",fr:"Achernar"},raHours:1.6286,decDeg:-57.2368,mag:.45},{name:{en:"Betelgeuse",fr:"Bételgeuse"},raHours:5.9195,decDeg:7.4071,mag:.45},{name:{en:"Hadar",fr:"Hadar"},raHours:14.0637,decDeg:-60.373,mag:.61},{name:{en:"Altair",fr:"Altaïr"},raHours:19.8464,decDeg:8.8683,mag:.76},{name:{en:"Acrux",fr:"Acrux"},raHours:12.4433,decDeg:-63.0991,mag:.77},{name:{en:"Aldebaran",fr:"Aldébaran"},raHours:4.5987,decDeg:16.5093,mag:.87},{name:{en:"Spica",fr:"Spica"},raHours:13.4199,decDeg:-11.1613,mag:.98},{name:{en:"Antares",fr:"Antarès"},raHours:16.4901,decDeg:-26.432,mag:1.06},{name:{en:"Pollux",fr:"Pollux"},raHours:7.7553,decDeg:28.0262,mag:1.16},{name:{en:"Fomalhaut",fr:"Fomalhaut"},raHours:22.9608,decDeg:-29.6222,mag:1.17},{name:{en:"Mimosa",fr:"Mimosa"},raHours:12.7954,decDeg:-59.6888,mag:1.25},{name:{en:"Deneb",fr:"Deneb"},raHours:20.6905,decDeg:45.2803,mag:1.25},{name:{en:"Toliman",fr:"Toliman"},raHours:14.6603,decDeg:-60.8383,mag:1.35},{name:{en:"Regulus",fr:"Régulus"},raHours:10.1395,decDeg:11.9672,mag:1.36},{name:{en:"Adhara",fr:"Adhara"},raHours:6.9771,decDeg:-28.9721,mag:1.5},{name:{en:"Castor",fr:"Castor"},raHours:7.5766,decDeg:31.8883,mag:1.58},{name:{en:"Gacrux",fr:"Gacrux"},raHours:12.5194,decDeg:-57.1132,mag:1.59},{name:{en:"Shaula",fr:"Shaula"},raHours:17.5601,decDeg:-37.1038,mag:1.62},{name:{en:"Bellatrix",fr:"Bellatrix"},raHours:5.4189,decDeg:6.3497,mag:1.64},{name:{en:"Elnath",fr:"Elnath"},raHours:5.4382,decDeg:28.6075,mag:1.65},{name:{en:"Miaplacidus",fr:"Miaplacidus"},raHours:9.22,decDeg:-69.7172,mag:1.67},{name:{en:"Alnilam",fr:"Alnilam"},raHours:5.6036,decDeg:-1.2019,mag:1.69},{name:{en:"Alnair",fr:"Alnair"},raHours:22.1372,decDeg:-46.961,mag:1.73},{name:{en:"Alnitak",fr:"Alnitak"},raHours:5.6793,decDeg:-1.9426,mag:1.74},{name:{en:"γ² Velorum",fr:"γ² Velorum"},raHours:8.1589,decDeg:-47.3366,mag:1.75},{name:{en:"Alioth",fr:"Alioth"},raHours:12.9005,decDeg:55.9598,mag:1.76},{name:{en:"Mirfak",fr:"Mirfak"},raHours:3.4054,decDeg:49.8612,mag:1.79},{name:{en:"Kaus Australis",fr:"Kaus Australis"},raHours:18.4029,decDeg:-34.3846,mag:1.79},{name:{en:"Dubhe",fr:"Dubhe"},raHours:11.0622,decDeg:61.751,mag:1.81},{name:{en:"Wezen",fr:"Wezen"},raHours:7.1399,decDeg:-26.3932,mag:1.83},{name:{en:"Alkaid",fr:"Alkaid"},raHours:13.7924,decDeg:49.3133,mag:1.85},{name:{en:"Avior",fr:"Avior"},raHours:8.3752,decDeg:-59.5095,mag:1.86},{name:{en:"Sargas",fr:"Sargas"},raHours:17.622,decDeg:-42.9978,mag:1.86},{name:{en:"Menkalinan",fr:"Menkalinan"},raHours:5.9921,decDeg:44.9474,mag:1.9},{name:{en:"Atria",fr:"Atria"},raHours:16.8111,decDeg:-69.0277,mag:1.91},{name:{en:"Alhena",fr:"Alhena"},raHours:6.6285,decDeg:16.3993,mag:1.93},{name:{en:"Alsephina",fr:"Alsephina"},raHours:8.7451,decDeg:-54.7088,mag:1.93},{name:{en:"Peacock",fr:"Peacock"},raHours:20.4275,decDeg:-56.7351,mag:1.94},{name:{en:"Polaris",fr:"Polaris"},raHours:2.5297,decDeg:89.2641,mag:1.97},{name:{en:"Mirzam",fr:"Mirzam"},raHours:6.3783,decDeg:-17.9559,mag:1.98},{name:{en:"Alphard",fr:"Alphard"},raHours:9.4598,decDeg:-8.6586,mag:1.99},{name:{en:"Hamal",fr:"Hamal"},raHours:2.1196,decDeg:23.4624,mag:2.01},{name:{en:"Algieba",fr:"Algieba"},raHours:10.3329,decDeg:19.8415,mag:2.01},{name:{en:"Diphda",fr:"Diphda"},raHours:.7265,decDeg:-17.9866,mag:2.04},{name:{en:"Nunki",fr:"Nunki"},raHours:18.9211,decDeg:-26.2967,mag:2.05},{name:{en:"Menkent",fr:"Menkent"},raHours:14.1114,decDeg:-36.37,mag:2.06},{name:{en:"Alpheratz",fr:"Alpheratz"},raHours:.1398,decDeg:29.0904,mag:2.07},{name:{en:"Mirach",fr:"Mirach"},raHours:1.1622,decDeg:35.6206,mag:2.07},{name:{en:"Saiph",fr:"Saiph"},raHours:5.7959,decDeg:-9.6696,mag:2.07},{name:{en:"Kochab",fr:"Kochab"},raHours:14.8451,decDeg:74.1555,mag:2.07},{name:{en:"Tiaki",fr:"Tiaki"},raHours:22.7111,decDeg:-46.8846,mag:2.07},{name:{en:"Rasalhague",fr:"Rasalhague"},raHours:17.5822,decDeg:12.56,mag:2.08},{name:{en:"Algol",fr:"Algol"},raHours:3.1361,decDeg:40.9556,mag:2.09},{name:{en:"Almach",fr:"Almach"},raHours:2.065,decDeg:42.3297,mag:2.1},{name:{en:"Denebola",fr:"Denebola"},raHours:11.8177,decDeg:14.5721,mag:2.14},{name:{en:"Cih",fr:"Cih"},raHours:.9451,decDeg:60.7167,mag:2.15},{name:{en:"γ Centauri",fr:"γ Centauri"},raHours:12.692,decDeg:-48.9599,mag:2.2},{name:{en:"Naos",fr:"Naos"},raHours:8.0597,decDeg:-40.0031,mag:2.21},{name:{en:"Aspidiske",fr:"Aspidiske"},raHours:9.2848,decDeg:-59.2752,mag:2.21},{name:{en:"Alphecca",fr:"Alphecca"},raHours:15.5781,decDeg:26.7147,mag:2.22},{name:{en:"Suhail",fr:"Suhail"},raHours:9.1333,decDeg:-43.4326,mag:2.23},{name:{en:"Mizar",fr:"Mizar"},raHours:13.3987,decDeg:54.9254,mag:2.23},{name:{en:"Sadr",fr:"Sadr"},raHours:20.3705,decDeg:40.2567,mag:2.23},{name:{en:"Schedar",fr:"Schedar"},raHours:.6751,decDeg:56.5373,mag:2.24},{name:{en:"Eltanin",fr:"Eltanin"},raHours:17.9434,decDeg:51.4889,mag:2.24},{name:{en:"Mintaka",fr:"Mintaka"},raHours:5.5334,decDeg:-.2991,mag:2.25},{name:{en:"Caph",fr:"Caph"},raHours:.1529,decDeg:59.1498,mag:2.28},{name:{en:"ε Centauri",fr:"ε Centauri"},raHours:13.6648,decDeg:-53.4664,mag:2.29},{name:{en:"Dschubba",fr:"Dschubba"},raHours:16.0056,decDeg:-22.6217,mag:2.29},{name:{en:"Larawag",fr:"Larawag"},raHours:16.8361,decDeg:-34.2932,mag:2.29},{name:{en:"α Lupi",fr:"α Lupi"},raHours:14.6988,decDeg:-47.3882,mag:2.3},{name:{en:"η Centauri",fr:"η Centauri"},raHours:14.5918,decDeg:-42.1578,mag:2.33},{name:{en:"Merak",fr:"Merak"},raHours:11.0307,decDeg:56.3824,mag:2.34},{name:{en:"Izar",fr:"Izar"},raHours:14.7498,decDeg:27.0742,mag:2.35},{name:{en:"Enif",fr:"Enif"},raHours:21.7364,decDeg:9.875,mag:2.38},{name:{en:"κ Scorpii",fr:"κ Scorpii"},raHours:17.7081,decDeg:-39.03,mag:2.39},{name:{en:"Ankaa",fr:"Ankaa"},raHours:.4381,decDeg:-42.306,mag:2.4},{name:{en:"Phecda",fr:"Phecda"},raHours:11.8972,decDeg:53.6948,mag:2.41},{name:{en:"Sabik",fr:"Sabik"},raHours:17.173,decDeg:-15.7249,mag:2.43},{name:{en:"Scheat",fr:"Scheat"},raHours:23.0629,decDeg:28.0828,mag:2.44},{name:{en:"Aludra",fr:"Aludra"},raHours:7.4016,decDeg:-29.3031,mag:2.45},{name:{en:"Alderamin",fr:"Alderamin"},raHours:21.3096,decDeg:62.5856,mag:2.45},{name:{en:"Markeb",fr:"Markeb"},raHours:9.3686,decDeg:-55.0107,mag:2.47},{name:{en:"Aljanah",fr:"Aljanah"},raHours:20.7702,decDeg:33.9703,mag:2.48},{name:{en:"Markab",fr:"Markab"},raHours:23.0793,decDeg:15.2053,mag:2.49},{name:{en:"Menkar",fr:"Menkar"},raHours:3.038,decDeg:4.0897,mag:2.54},{name:{en:"ζ Ophiuchi",fr:"ζ Ophiuchi"},raHours:16.6193,decDeg:-10.5671,mag:2.54},{name:{en:"ζ Centauri",fr:"ζ Centauri"},raHours:13.9257,decDeg:-47.2884,mag:2.55},{name:{en:"Zosma",fr:"Zosma"},raHours:11.2351,decDeg:20.5237,mag:2.56},{name:{en:"Acrab",fr:"Acrab"},raHours:16.0906,decDeg:-19.8055,mag:2.56},{name:{en:"Arneb",fr:"Arneb"},raHours:5.5455,decDeg:-17.8223,mag:2.58},{name:{en:"δ Centauri",fr:"δ Centauri"},raHours:12.1393,decDeg:-50.7224,mag:2.58},{name:{en:"Gienah",fr:"Gienah"},raHours:12.2634,decDeg:-17.5419,mag:2.58},{name:{en:"Ascella",fr:"Ascella"},raHours:19.0435,decDeg:-29.8801,mag:2.6},{name:{en:"Zubeneschamali",fr:"Zubeneschamali"},raHours:15.2834,decDeg:-9.3829,mag:2.61},{name:{en:"Unukalhai",fr:"Unukalhai"},raHours:15.7378,decDeg:6.4256,mag:2.63},{name:{en:"Sheratan",fr:"Sheratan"},raHours:1.9107,decDeg:20.808,mag:2.64},{name:{en:"Phact",fr:"Phact"},raHours:5.6608,decDeg:-34.0741,mag:2.65},{name:{en:"Mahasim",fr:"Mahasim"},raHours:5.9954,decDeg:37.2126,mag:2.65},{name:{en:"Kraz",fr:"Kraz"},raHours:12.5731,decDeg:-23.3968,mag:2.65},{name:{en:"Ruchbah",fr:"Ruchbah"},raHours:1.4302,decDeg:60.2353,mag:2.66},{name:{en:"Muphrid",fr:"Muphrid"},raHours:13.9114,decDeg:18.3977,mag:2.68},{name:{en:"β Lupi",fr:"β Lupi"},raHours:14.9755,decDeg:-43.134,mag:2.68},{name:{en:"Hassaleh",fr:"Hassaleh"},raHours:4.9499,decDeg:33.1661,mag:2.69},{name:{en:"μ Velorum",fr:"μ Velorum"},raHours:10.7795,decDeg:-49.4203,mag:2.69},{name:{en:"α Muscae",fr:"α Muscae"},raHours:12.6197,decDeg:-69.1356,mag:2.69},{name:{en:"Lesath",fr:"Lesath"},raHours:17.5127,decDeg:-37.2958,mag:2.7},{name:{en:"π Puppis",fr:"π Puppis"},raHours:7.2857,decDeg:-37.0975,mag:2.71},{name:{en:"Kaus Media",fr:"Kaus Media"},raHours:18.3499,decDeg:-29.8281,mag:2.72},{name:{en:"Tarazed",fr:"Tarazed"},raHours:19.771,decDeg:10.6133,mag:2.72},{name:{en:"Yed Prior",fr:"Yed Prior"},raHours:16.2391,decDeg:-3.6943,mag:2.73},{name:{en:"Athebyne",fr:"Athebyne"},raHours:16.3999,decDeg:61.5142,mag:2.73},{name:{en:"θ Carinae",fr:"θ Carinae"},raHours:10.7159,decDeg:-64.3945,mag:2.74},{name:{en:"Porrima",fr:"Porrima"},raHours:12.6943,decDeg:-1.4494,mag:2.74},{name:{en:"Hatysa",fr:"Hatysa"},raHours:5.5906,decDeg:-5.9099,mag:2.75},{name:{en:"ι Centauri",fr:"ι Centauri"},raHours:13.3433,decDeg:-36.7123,mag:2.75},{name:{en:"Zubenelgenubi",fr:"Zubenelgenubi"},raHours:14.848,decDeg:-16.0418,mag:2.75},{name:{en:"Cebalrai",fr:"Cebalrai"},raHours:17.7245,decDeg:4.5673,mag:2.76},{name:{en:"Cursa",fr:"Cursa"},raHours:5.1308,decDeg:-5.0864,mag:2.78},{name:{en:"Kornephoros",fr:"Kornephoros"},raHours:16.5037,decDeg:21.4896,mag:2.78},{name:{en:"Rasalgethi",fr:"Rasalgethi"},raHours:17.2441,decDeg:14.3903,mag:2.78},{name:{en:"Imai",fr:"Imai"},raHours:12.2524,decDeg:-58.7489,mag:2.79},{name:{en:"Rastaban",fr:"Rastaban"},raHours:17.5072,decDeg:52.3014,mag:2.79},{name:{en:"γ Lupi",fr:"γ Lupi"},raHours:15.5857,decDeg:-41.1668,mag:2.8},{name:{en:"Nihal",fr:"Nihal"},raHours:5.4708,decDeg:-20.7594,mag:2.81},{name:{en:"ζ Herculis",fr:"ζ Herculis"},raHours:16.6881,decDeg:31.6027,mag:2.81},{name:{en:"β Hydri",fr:"β Hydri"},raHours:.4279,decDeg:-77.2542,mag:2.82},{name:{en:"Paikauhale",fr:"Paikauhale"},raHours:16.598,decDeg:-28.216,mag:2.82},{name:{en:"Kaus Borealis",fr:"Kaus Borealis"},raHours:18.4662,decDeg:-25.4217,mag:2.82},{name:{en:"Algenib",fr:"Algenib"},raHours:.2206,decDeg:15.1836,mag:2.83},{name:{en:"Tureis",fr:"Tureis"},raHours:8.1257,decDeg:-24.3043,mag:2.83},{name:{en:"β Trianguli Australis",fr:"β Trianguli Australis"},raHours:15.9191,decDeg:-63.4307,mag:2.83},{name:{en:"ζ Persei",fr:"ζ Persei"},raHours:3.9022,decDeg:31.8836,mag:2.84},{name:{en:"β Arae",fr:"β Arae"},raHours:17.4217,decDeg:-55.5299,mag:2.84},{name:{en:"α Arae",fr:"α Arae"},raHours:17.5307,decDeg:-49.8761,mag:2.84},{name:{en:"Alcyone",fr:"Alcyone"},raHours:3.7914,decDeg:24.1051,mag:2.85},{name:{en:"Vindemiatrix",fr:"Vindemiatrix"},raHours:13.0363,decDeg:10.9591,mag:2.85},{name:{en:"Deneb Algedi",fr:"Deneb Algedi"},raHours:21.784,decDeg:-16.1273,mag:2.85},{name:{en:"Castor B",fr:"Castor B"},raHours:7.5768,decDeg:31.8905,mag:2.85},{name:{en:"α Hydri",fr:"α Hydri"},raHours:1.9795,decDeg:-61.5699,mag:2.86},{name:{en:"Fawaris",fr:"Fawaris"},raHours:19.7496,decDeg:45.1308,mag:2.86},{name:{en:"Tejat",fr:"Tejat"},raHours:6.3827,decDeg:22.5136,mag:2.87},{name:{en:"γ Trianguli Australis",fr:"γ Trianguli Australis"},raHours:15.3152,decDeg:-68.6795,mag:2.87},{name:{en:"α Tucanae",fr:"α Tucanae"},raHours:22.3084,decDeg:-60.2596,mag:2.87},{name:{en:"Acamar",fr:"Acamar"},raHours:2.971,decDeg:-40.3047,mag:2.88},{name:{en:"Albaldah",fr:"Albaldah"},raHours:19.1627,decDeg:-21.0236,mag:2.88},{name:{en:"Gomeisa",fr:"Gomeisa"},raHours:7.4525,decDeg:8.2893,mag:2.89},{name:{en:"Cor Caroli",fr:"Cor Caroli"},raHours:12.9338,decDeg:38.3184,mag:2.89},{name:{en:"Fang",fr:"Fang"},raHours:15.9809,decDeg:-26.1141,mag:2.89},{name:{en:"ε Persei",fr:"ε Persei"},raHours:3.9642,decDeg:40.0102,mag:2.9},{name:{en:"Alniyat",fr:"Alniyat"},raHours:16.3531,decDeg:-25.5928,mag:2.9},{name:{en:"Sadalsuud",fr:"Sadalsuud"},raHours:21.526,decDeg:-5.5712,mag:2.9},{name:{en:"γ Persei",fr:"γ Persei"},raHours:3.0799,decDeg:53.5064,mag:2.91},{name:{en:"υ Carinae",fr:"υ Carinae"},raHours:9.785,decDeg:-65.072,mag:2.92},{name:{en:"Matar",fr:"Matar"},raHours:22.7167,decDeg:30.2212,mag:2.93},{name:{en:"τ Puppis",fr:"τ Puppis"},raHours:6.8323,decDeg:-50.6146,mag:2.94},{name:{en:"Algorab",fr:"Algorab"},raHours:12.4977,decDeg:-16.5154,mag:2.94},{name:{en:"Sadalmelik",fr:"Sadalmelik"},raHours:22.0964,decDeg:-.3199,mag:2.95},{name:{en:"Zaurak",fr:"Zaurak"},raHours:3.9672,decDeg:-13.5085,mag:2.97},{name:{en:"Tianguan",fr:"Tianguan"},raHours:5.6274,decDeg:21.1425,mag:2.97},{name:{en:"Ras Elased Australis",fr:"Ras Elased Australis"},raHours:9.7642,decDeg:23.7743,mag:2.97},{name:{en:"Alnasl",fr:"Alnasl"},raHours:18.0968,decDeg:-30.4241,mag:2.98},{name:{en:"γ Hydrae",fr:"γ Hydrae"},raHours:13.3154,decDeg:-23.1715,mag:2.99},{name:{en:"ι¹ Scorpii",fr:"ι¹ Scorpii"},raHours:17.7931,decDeg:-40.127,mag:2.99},{name:{en:"Okab",fr:"Okab"},raHours:19.0902,decDeg:13.8635,mag:2.99},{name:{en:"β Trianguli",fr:"β Trianguli"},raHours:2.1591,decDeg:34.9873,mag:3},{name:{en:"ψ Ursae Majoris",fr:"ψ Ursae Majoris"},raHours:11.1611,decDeg:44.4985,mag:3},{name:{en:"Pherkad",fr:"Pherkad"},raHours:15.3455,decDeg:71.834,mag:3},{name:{en:"Xamidimura",fr:"Xamidimura"},raHours:16.8645,decDeg:-38.0474,mag:3},{name:{en:"Aldhanab",fr:"Aldhanab"},raHours:21.8988,decDeg:-37.3649,mag:3}],df=Math.PI/180,b3=180/Math.PI,T3=256,w3=19;function R3(i,e){return 156543.03392*Math.cos(i*df)/2**e}function D3(i,e){return R3(i,e)*T3}function ff(i,e){let t=0;for(;t<w3&&D3(i,t+1)>=e;)t++;return t}function pf(i,e,t){const n=2**t,s=(i+180)/360*n,r=e*df,a=(1-Math.log(Math.tan(r)+1/Math.cos(r))/Math.PI)/2*n;return{x:s,y:a}}function C3(i,e,t){const{x:n,y:s}=pf(i,e,t);return{x:Math.floor(n),y:Math.floor(s),z:t}}function P3(i){const e=2**i.z,t=i.x/e*360-180,n=(i.x+1)/e*360-180,s=dd(i.y,e);return{south:dd(i.y+1,e),north:s,west:t,east:n}}function dd(i,e){const t=i/e;return Math.atan(Math.sinh(Math.PI*(1-2*t)))*b3}function mf(i,e,t,n){const s=C3(i,e,t),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:t});const o=a.map(P3),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 gf=Math.PI/180,ho=111320;function us(i,e,t,n){const s=ho*Math.cos(t*gf),r=(i-t)*ho;return{x:(e-n)*s,z:-r}}function Pa(i,e,t,n){const s=ho*Math.cos(t*gf),r=-e,a=i;return{lat:t+r/ho,lng:n+a/s}}const yn=256,fd=3,I3=32768;class L3{fetchImpl;tileUrlTemplate;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=e.tileUrlTemplate??"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"}async getElevationGrid(e,t){const n=(e.south+e.north)/2,s=(e.west+e.east)/2,r=Math.abs(us(n,e.east,n,e.west).x),a=Math.abs(us(e.north,s,e.south,s).z),o=ff(n,Math.max(r,a)),{tiles:c}=mf(s,n,o,fd),l=fd*yn,h=new Float32Array(l*l),u=c[0];await Promise.all(c.map(f=>this.decodeTileInto(f,u,h,l)));const d=new Float32Array(t.width*t.height);for(let f=0;f<t.height;f++){const g=e.north+(e.south-e.north)*(f/(t.height-1));for(let x=0;x<t.width;x++){const m=e.west+(e.east-e.west)*(x/(t.width-1));d[f*t.width+x]=this.sampleAt(g,m,o,u,h,l)}}return{heights:d,width:t.width,height:t.height,bounds:e}}async decodeTileInto(e,t,n,s){const r=this.tileUrlTemplate.replace("{z}",String(e.z)).replace("{x}",String(e.x)).replace("{y}",String(e.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=yn,c.height=yn;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,yn,yn),u=(e.x-t.x)*yn,d=(e.y-t.y)*yn;for(let f=0;f<yn;f++)for(let g=0;g<yn;g++){const x=(f*yn+g)*4,m=h[x]*256+h[x+1]+h[x+2]/256-I3,p=u+g,A=d+f;n[A*s+p]=m}}sampleAt(e,t,n,s,r,a){const{x:o,y:c}=pf(t,e,n),l=(o-s.x)*yn,h=(c-s.y)*yn,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 xc=256,pd=3;async function N3(i,e,t,n){const s=(i.south+i.north)/2,r=(i.west+i.east)/2,a=Math.abs(us(s,i.east,s,i.west).x),o=Math.abs(us(i.north,r,i.south,r).z),c=ff(s,Math.max(a,o)),{tiles:l}=mf(r,s,c,pd),h=pd*xc,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=t(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)*xc,(m.y-f.y)*xc)}));const g=document.createElement("canvas");g.width=e.width,g.height=e.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,e.width,e.height),g}class U3{attribution="Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community";fetchImpl;tileUrlTemplate;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=e.tileUrlTemplate??"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"}async getImageryTexture(e,t){return{source:await N3(e,t,s=>this.tileUrlTemplate.replace("{z}",String(s.z)).replace("{y}",String(s.y)).replace("{x}",String(s.x)),this.fetchImpl),width:t.width,height:t.height}}}function O3(){return{elevation:new L3,imagery:new U3}}const wr=64,Ht=wr+1,md=512,F3=900,z3=700/900,B3=0,H3=.01;function k3(i,e,t){return{north:Pa(0,-t,i,e).lat,south:Pa(0,t,i,e).lat,east:Pa(t,0,i,e).lng,west:Pa(-t,0,i,e).lng}}async function G3(i,e,t,n=F3){const s=n,r=n*z3,a=k3(i,e,s),o={width:Ht,height:Ht},[c,l]=await Promise.all([t.elevation.getElevationGrid(a,o),t.imagery.getImageryTexture(a,{width:md,height:md})]),h=Math.floor(Ht/2),u=c.heights[h*Ht+h],d=new Float32Array(Ht*Ht*3),f=new Float32Array(Ht*Ht*2),g=new Float32Array(Ht*Ht*4);for(let y=0;y<Ht;y++){const b=y/(Ht-1),R=a.north+(a.south-a.north)*b;for(let _=0;_<Ht;_++){const E=_/(Ht-1),C=a.west+(a.east-a.west)*E,{x:D,z:I}=us(R,C,i,e),W=c.heights[y*Ht+_],X=B3+H3+(W-u),O=y*Ht+_;d[O*3]=D,d[O*3+1]=X,d[O*3+2]=I,f[O*2]=E,f[O*2+1]=b;const q=Math.max(Math.abs(D),Math.abs(I)),G=1-V3((q-r)/(s-r),0,1);g[O*4]=1,g[O*4+1]=1,g[O*4+2]=1,g[O*4+3]=G}}const x=new Uint16Array(wr*wr*6);let m=0;for(let y=0;y<wr;y++)for(let b=0;b<wr;b++){const R=y*Ht+b,_=R+1,E=R+Ht,C=E+1;x[m++]=R,x[m++]=E,x[m++]=_,x[m++]=_,x[m++]=E,x[m++]=C}const p=new Rt;p.setAttribute("position",new ut(d,3)),p.setAttribute("uv",new ut(f,2)),p.setAttribute("color",new ut(g,4)),p.setIndex(new ut(x,1)),p.computeVertexNormals();const A=new gi(l.source);A.flipY=!1;const T=new Gr({map:A,color:new Me(1,1,1),vertexColors:!0,transparent:!0,fog:!0,depthTest:!1}),M=new je(p,T);return M.receiveShadow=!0,M.castShadow=!0,{mesh:M,attribution:t.imagery.attribution}}function V3(i,e,t){return Math.max(e,Math.min(t,i))}const W3=18,X3=.55,q3=.5,Y3=`
4507
+ if ( distanceFromCentre > ${ls.RIM.toFixed(2)} ) discard;
4508
+ float glare = 1.0 - smoothstep( ${ls.CORE.toFixed(2)}, ${ls.RIM.toFixed(2)}, distanceFromCentre );
4509
+ vec4 diffuseColor = vec4( diffuse, opacity * glare );`)}}const Py=[{name:{en:"Sirius",fr:"Sirius"},raHours:6.7525,decDeg:-16.7161,mag:-1.44},{name:{en:"Canopus",fr:"Canopus"},raHours:6.3992,decDeg:-52.6957,mag:-.62},{name:{en:"Arcturus",fr:"Arcturus"},raHours:14.261,decDeg:19.1824,mag:-.05},{name:{en:"Rigil Kentaurus",fr:"Rigil Kentaurus"},raHours:14.6608,decDeg:-60.834,mag:-.01},{name:{en:"Vega",fr:"Véga"},raHours:18.6156,decDeg:38.7837,mag:.03},{name:{en:"Capella",fr:"Capella"},raHours:5.2782,decDeg:45.998,mag:.08},{name:{en:"Rigel",fr:"Rigel"},raHours:5.2423,decDeg:-8.2016,mag:.18},{name:{en:"Procyon",fr:"Procyon"},raHours:7.655,decDeg:5.225,mag:.4},{name:{en:"Achernar",fr:"Achernar"},raHours:1.6286,decDeg:-57.2368,mag:.45},{name:{en:"Betelgeuse",fr:"Bételgeuse"},raHours:5.9195,decDeg:7.4071,mag:.45},{name:{en:"Hadar",fr:"Hadar"},raHours:14.0637,decDeg:-60.373,mag:.61},{name:{en:"Altair",fr:"Altaïr"},raHours:19.8464,decDeg:8.8683,mag:.76},{name:{en:"Acrux",fr:"Acrux"},raHours:12.4433,decDeg:-63.0991,mag:.77},{name:{en:"Aldebaran",fr:"Aldébaran"},raHours:4.5987,decDeg:16.5093,mag:.87},{name:{en:"Spica",fr:"Spica"},raHours:13.4199,decDeg:-11.1613,mag:.98},{name:{en:"Antares",fr:"Antarès"},raHours:16.4901,decDeg:-26.432,mag:1.06},{name:{en:"Pollux",fr:"Pollux"},raHours:7.7553,decDeg:28.0262,mag:1.16},{name:{en:"Fomalhaut",fr:"Fomalhaut"},raHours:22.9608,decDeg:-29.6222,mag:1.17},{name:{en:"Mimosa",fr:"Mimosa"},raHours:12.7954,decDeg:-59.6888,mag:1.25},{name:{en:"Deneb",fr:"Deneb"},raHours:20.6905,decDeg:45.2803,mag:1.25},{name:{en:"Toliman",fr:"Toliman"},raHours:14.6603,decDeg:-60.8383,mag:1.35},{name:{en:"Regulus",fr:"Régulus"},raHours:10.1395,decDeg:11.9672,mag:1.36},{name:{en:"Adhara",fr:"Adhara"},raHours:6.9771,decDeg:-28.9721,mag:1.5},{name:{en:"Castor",fr:"Castor"},raHours:7.5766,decDeg:31.8883,mag:1.58},{name:{en:"Gacrux",fr:"Gacrux"},raHours:12.5194,decDeg:-57.1132,mag:1.59},{name:{en:"Shaula",fr:"Shaula"},raHours:17.5601,decDeg:-37.1038,mag:1.62},{name:{en:"Bellatrix",fr:"Bellatrix"},raHours:5.4189,decDeg:6.3497,mag:1.64},{name:{en:"Elnath",fr:"Elnath"},raHours:5.4382,decDeg:28.6075,mag:1.65},{name:{en:"Miaplacidus",fr:"Miaplacidus"},raHours:9.22,decDeg:-69.7172,mag:1.67},{name:{en:"Alnilam",fr:"Alnilam"},raHours:5.6036,decDeg:-1.2019,mag:1.69},{name:{en:"Alnair",fr:"Alnair"},raHours:22.1372,decDeg:-46.961,mag:1.73},{name:{en:"Alnitak",fr:"Alnitak"},raHours:5.6793,decDeg:-1.9426,mag:1.74},{name:{en:"γ² Velorum",fr:"γ² Velorum"},raHours:8.1589,decDeg:-47.3366,mag:1.75},{name:{en:"Alioth",fr:"Alioth"},raHours:12.9005,decDeg:55.9598,mag:1.76},{name:{en:"Mirfak",fr:"Mirfak"},raHours:3.4054,decDeg:49.8612,mag:1.79},{name:{en:"Kaus Australis",fr:"Kaus Australis"},raHours:18.4029,decDeg:-34.3846,mag:1.79},{name:{en:"Dubhe",fr:"Dubhe"},raHours:11.0622,decDeg:61.751,mag:1.81},{name:{en:"Wezen",fr:"Wezen"},raHours:7.1399,decDeg:-26.3932,mag:1.83},{name:{en:"Alkaid",fr:"Alkaid"},raHours:13.7924,decDeg:49.3133,mag:1.85},{name:{en:"Avior",fr:"Avior"},raHours:8.3752,decDeg:-59.5095,mag:1.86},{name:{en:"Sargas",fr:"Sargas"},raHours:17.622,decDeg:-42.9978,mag:1.86},{name:{en:"Menkalinan",fr:"Menkalinan"},raHours:5.9921,decDeg:44.9474,mag:1.9},{name:{en:"Atria",fr:"Atria"},raHours:16.8111,decDeg:-69.0277,mag:1.91},{name:{en:"Alhena",fr:"Alhena"},raHours:6.6285,decDeg:16.3993,mag:1.93},{name:{en:"Alsephina",fr:"Alsephina"},raHours:8.7451,decDeg:-54.7088,mag:1.93},{name:{en:"Peacock",fr:"Peacock"},raHours:20.4275,decDeg:-56.7351,mag:1.94},{name:{en:"Polaris",fr:"Polaris"},raHours:2.5297,decDeg:89.2641,mag:1.97},{name:{en:"Mirzam",fr:"Mirzam"},raHours:6.3783,decDeg:-17.9559,mag:1.98},{name:{en:"Alphard",fr:"Alphard"},raHours:9.4598,decDeg:-8.6586,mag:1.99},{name:{en:"Hamal",fr:"Hamal"},raHours:2.1196,decDeg:23.4624,mag:2.01},{name:{en:"Algieba",fr:"Algieba"},raHours:10.3329,decDeg:19.8415,mag:2.01},{name:{en:"Diphda",fr:"Diphda"},raHours:.7265,decDeg:-17.9866,mag:2.04},{name:{en:"Nunki",fr:"Nunki"},raHours:18.9211,decDeg:-26.2967,mag:2.05},{name:{en:"Menkent",fr:"Menkent"},raHours:14.1114,decDeg:-36.37,mag:2.06},{name:{en:"Alpheratz",fr:"Alpheratz"},raHours:.1398,decDeg:29.0904,mag:2.07},{name:{en:"Mirach",fr:"Mirach"},raHours:1.1622,decDeg:35.6206,mag:2.07},{name:{en:"Saiph",fr:"Saiph"},raHours:5.7959,decDeg:-9.6696,mag:2.07},{name:{en:"Kochab",fr:"Kochab"},raHours:14.8451,decDeg:74.1555,mag:2.07},{name:{en:"Tiaki",fr:"Tiaki"},raHours:22.7111,decDeg:-46.8846,mag:2.07},{name:{en:"Rasalhague",fr:"Rasalhague"},raHours:17.5822,decDeg:12.56,mag:2.08},{name:{en:"Algol",fr:"Algol"},raHours:3.1361,decDeg:40.9556,mag:2.09},{name:{en:"Almach",fr:"Almach"},raHours:2.065,decDeg:42.3297,mag:2.1},{name:{en:"Denebola",fr:"Denebola"},raHours:11.8177,decDeg:14.5721,mag:2.14},{name:{en:"Cih",fr:"Cih"},raHours:.9451,decDeg:60.7167,mag:2.15},{name:{en:"γ Centauri",fr:"γ Centauri"},raHours:12.692,decDeg:-48.9599,mag:2.2},{name:{en:"Naos",fr:"Naos"},raHours:8.0597,decDeg:-40.0031,mag:2.21},{name:{en:"Aspidiske",fr:"Aspidiske"},raHours:9.2848,decDeg:-59.2752,mag:2.21},{name:{en:"Alphecca",fr:"Alphecca"},raHours:15.5781,decDeg:26.7147,mag:2.22},{name:{en:"Suhail",fr:"Suhail"},raHours:9.1333,decDeg:-43.4326,mag:2.23},{name:{en:"Mizar",fr:"Mizar"},raHours:13.3987,decDeg:54.9254,mag:2.23},{name:{en:"Sadr",fr:"Sadr"},raHours:20.3705,decDeg:40.2567,mag:2.23},{name:{en:"Schedar",fr:"Schedar"},raHours:.6751,decDeg:56.5373,mag:2.24},{name:{en:"Eltanin",fr:"Eltanin"},raHours:17.9434,decDeg:51.4889,mag:2.24},{name:{en:"Mintaka",fr:"Mintaka"},raHours:5.5334,decDeg:-.2991,mag:2.25},{name:{en:"Caph",fr:"Caph"},raHours:.1529,decDeg:59.1498,mag:2.28},{name:{en:"ε Centauri",fr:"ε Centauri"},raHours:13.6648,decDeg:-53.4664,mag:2.29},{name:{en:"Dschubba",fr:"Dschubba"},raHours:16.0056,decDeg:-22.6217,mag:2.29},{name:{en:"Larawag",fr:"Larawag"},raHours:16.8361,decDeg:-34.2932,mag:2.29},{name:{en:"α Lupi",fr:"α Lupi"},raHours:14.6988,decDeg:-47.3882,mag:2.3},{name:{en:"η Centauri",fr:"η Centauri"},raHours:14.5918,decDeg:-42.1578,mag:2.33},{name:{en:"Merak",fr:"Merak"},raHours:11.0307,decDeg:56.3824,mag:2.34},{name:{en:"Izar",fr:"Izar"},raHours:14.7498,decDeg:27.0742,mag:2.35},{name:{en:"Enif",fr:"Enif"},raHours:21.7364,decDeg:9.875,mag:2.38},{name:{en:"κ Scorpii",fr:"κ Scorpii"},raHours:17.7081,decDeg:-39.03,mag:2.39},{name:{en:"Ankaa",fr:"Ankaa"},raHours:.4381,decDeg:-42.306,mag:2.4},{name:{en:"Phecda",fr:"Phecda"},raHours:11.8972,decDeg:53.6948,mag:2.41},{name:{en:"Sabik",fr:"Sabik"},raHours:17.173,decDeg:-15.7249,mag:2.43},{name:{en:"Scheat",fr:"Scheat"},raHours:23.0629,decDeg:28.0828,mag:2.44},{name:{en:"Aludra",fr:"Aludra"},raHours:7.4016,decDeg:-29.3031,mag:2.45},{name:{en:"Alderamin",fr:"Alderamin"},raHours:21.3096,decDeg:62.5856,mag:2.45},{name:{en:"Markeb",fr:"Markeb"},raHours:9.3686,decDeg:-55.0107,mag:2.47},{name:{en:"Aljanah",fr:"Aljanah"},raHours:20.7702,decDeg:33.9703,mag:2.48},{name:{en:"Markab",fr:"Markab"},raHours:23.0793,decDeg:15.2053,mag:2.49},{name:{en:"Menkar",fr:"Menkar"},raHours:3.038,decDeg:4.0897,mag:2.54},{name:{en:"ζ Ophiuchi",fr:"ζ Ophiuchi"},raHours:16.6193,decDeg:-10.5671,mag:2.54},{name:{en:"ζ Centauri",fr:"ζ Centauri"},raHours:13.9257,decDeg:-47.2884,mag:2.55},{name:{en:"Zosma",fr:"Zosma"},raHours:11.2351,decDeg:20.5237,mag:2.56},{name:{en:"Acrab",fr:"Acrab"},raHours:16.0906,decDeg:-19.8055,mag:2.56},{name:{en:"Arneb",fr:"Arneb"},raHours:5.5455,decDeg:-17.8223,mag:2.58},{name:{en:"δ Centauri",fr:"δ Centauri"},raHours:12.1393,decDeg:-50.7224,mag:2.58},{name:{en:"Gienah",fr:"Gienah"},raHours:12.2634,decDeg:-17.5419,mag:2.58},{name:{en:"Ascella",fr:"Ascella"},raHours:19.0435,decDeg:-29.8801,mag:2.6},{name:{en:"Zubeneschamali",fr:"Zubeneschamali"},raHours:15.2834,decDeg:-9.3829,mag:2.61},{name:{en:"Unukalhai",fr:"Unukalhai"},raHours:15.7378,decDeg:6.4256,mag:2.63},{name:{en:"Sheratan",fr:"Sheratan"},raHours:1.9107,decDeg:20.808,mag:2.64},{name:{en:"Phact",fr:"Phact"},raHours:5.6608,decDeg:-34.0741,mag:2.65},{name:{en:"Mahasim",fr:"Mahasim"},raHours:5.9954,decDeg:37.2126,mag:2.65},{name:{en:"Kraz",fr:"Kraz"},raHours:12.5731,decDeg:-23.3968,mag:2.65},{name:{en:"Ruchbah",fr:"Ruchbah"},raHours:1.4302,decDeg:60.2353,mag:2.66},{name:{en:"Muphrid",fr:"Muphrid"},raHours:13.9114,decDeg:18.3977,mag:2.68},{name:{en:"β Lupi",fr:"β Lupi"},raHours:14.9755,decDeg:-43.134,mag:2.68},{name:{en:"Hassaleh",fr:"Hassaleh"},raHours:4.9499,decDeg:33.1661,mag:2.69},{name:{en:"μ Velorum",fr:"μ Velorum"},raHours:10.7795,decDeg:-49.4203,mag:2.69},{name:{en:"α Muscae",fr:"α Muscae"},raHours:12.6197,decDeg:-69.1356,mag:2.69},{name:{en:"Lesath",fr:"Lesath"},raHours:17.5127,decDeg:-37.2958,mag:2.7},{name:{en:"π Puppis",fr:"π Puppis"},raHours:7.2857,decDeg:-37.0975,mag:2.71},{name:{en:"Kaus Media",fr:"Kaus Media"},raHours:18.3499,decDeg:-29.8281,mag:2.72},{name:{en:"Tarazed",fr:"Tarazed"},raHours:19.771,decDeg:10.6133,mag:2.72},{name:{en:"Yed Prior",fr:"Yed Prior"},raHours:16.2391,decDeg:-3.6943,mag:2.73},{name:{en:"Athebyne",fr:"Athebyne"},raHours:16.3999,decDeg:61.5142,mag:2.73},{name:{en:"θ Carinae",fr:"θ Carinae"},raHours:10.7159,decDeg:-64.3945,mag:2.74},{name:{en:"Porrima",fr:"Porrima"},raHours:12.6943,decDeg:-1.4494,mag:2.74},{name:{en:"Hatysa",fr:"Hatysa"},raHours:5.5906,decDeg:-5.9099,mag:2.75},{name:{en:"ι Centauri",fr:"ι Centauri"},raHours:13.3433,decDeg:-36.7123,mag:2.75},{name:{en:"Zubenelgenubi",fr:"Zubenelgenubi"},raHours:14.848,decDeg:-16.0418,mag:2.75},{name:{en:"Cebalrai",fr:"Cebalrai"},raHours:17.7245,decDeg:4.5673,mag:2.76},{name:{en:"Cursa",fr:"Cursa"},raHours:5.1308,decDeg:-5.0864,mag:2.78},{name:{en:"Kornephoros",fr:"Kornephoros"},raHours:16.5037,decDeg:21.4896,mag:2.78},{name:{en:"Rasalgethi",fr:"Rasalgethi"},raHours:17.2441,decDeg:14.3903,mag:2.78},{name:{en:"Imai",fr:"Imai"},raHours:12.2524,decDeg:-58.7489,mag:2.79},{name:{en:"Rastaban",fr:"Rastaban"},raHours:17.5072,decDeg:52.3014,mag:2.79},{name:{en:"γ Lupi",fr:"γ Lupi"},raHours:15.5857,decDeg:-41.1668,mag:2.8},{name:{en:"Nihal",fr:"Nihal"},raHours:5.4708,decDeg:-20.7594,mag:2.81},{name:{en:"ζ Herculis",fr:"ζ Herculis"},raHours:16.6881,decDeg:31.6027,mag:2.81},{name:{en:"β Hydri",fr:"β Hydri"},raHours:.4279,decDeg:-77.2542,mag:2.82},{name:{en:"Paikauhale",fr:"Paikauhale"},raHours:16.598,decDeg:-28.216,mag:2.82},{name:{en:"Kaus Borealis",fr:"Kaus Borealis"},raHours:18.4662,decDeg:-25.4217,mag:2.82},{name:{en:"Algenib",fr:"Algenib"},raHours:.2206,decDeg:15.1836,mag:2.83},{name:{en:"Tureis",fr:"Tureis"},raHours:8.1257,decDeg:-24.3043,mag:2.83},{name:{en:"β Trianguli Australis",fr:"β Trianguli Australis"},raHours:15.9191,decDeg:-63.4307,mag:2.83},{name:{en:"ζ Persei",fr:"ζ Persei"},raHours:3.9022,decDeg:31.8836,mag:2.84},{name:{en:"β Arae",fr:"β Arae"},raHours:17.4217,decDeg:-55.5299,mag:2.84},{name:{en:"α Arae",fr:"α Arae"},raHours:17.5307,decDeg:-49.8761,mag:2.84},{name:{en:"Alcyone",fr:"Alcyone"},raHours:3.7914,decDeg:24.1051,mag:2.85},{name:{en:"Vindemiatrix",fr:"Vindemiatrix"},raHours:13.0363,decDeg:10.9591,mag:2.85},{name:{en:"Deneb Algedi",fr:"Deneb Algedi"},raHours:21.784,decDeg:-16.1273,mag:2.85},{name:{en:"Castor B",fr:"Castor B"},raHours:7.5768,decDeg:31.8905,mag:2.85},{name:{en:"α Hydri",fr:"α Hydri"},raHours:1.9795,decDeg:-61.5699,mag:2.86},{name:{en:"Fawaris",fr:"Fawaris"},raHours:19.7496,decDeg:45.1308,mag:2.86},{name:{en:"Tejat",fr:"Tejat"},raHours:6.3827,decDeg:22.5136,mag:2.87},{name:{en:"γ Trianguli Australis",fr:"γ Trianguli Australis"},raHours:15.3152,decDeg:-68.6795,mag:2.87},{name:{en:"α Tucanae",fr:"α Tucanae"},raHours:22.3084,decDeg:-60.2596,mag:2.87},{name:{en:"Acamar",fr:"Acamar"},raHours:2.971,decDeg:-40.3047,mag:2.88},{name:{en:"Albaldah",fr:"Albaldah"},raHours:19.1627,decDeg:-21.0236,mag:2.88},{name:{en:"Gomeisa",fr:"Gomeisa"},raHours:7.4525,decDeg:8.2893,mag:2.89},{name:{en:"Cor Caroli",fr:"Cor Caroli"},raHours:12.9338,decDeg:38.3184,mag:2.89},{name:{en:"Fang",fr:"Fang"},raHours:15.9809,decDeg:-26.1141,mag:2.89},{name:{en:"ε Persei",fr:"ε Persei"},raHours:3.9642,decDeg:40.0102,mag:2.9},{name:{en:"Alniyat",fr:"Alniyat"},raHours:16.3531,decDeg:-25.5928,mag:2.9},{name:{en:"Sadalsuud",fr:"Sadalsuud"},raHours:21.526,decDeg:-5.5712,mag:2.9},{name:{en:"γ Persei",fr:"γ Persei"},raHours:3.0799,decDeg:53.5064,mag:2.91},{name:{en:"υ Carinae",fr:"υ Carinae"},raHours:9.785,decDeg:-65.072,mag:2.92},{name:{en:"Matar",fr:"Matar"},raHours:22.7167,decDeg:30.2212,mag:2.93},{name:{en:"τ Puppis",fr:"τ Puppis"},raHours:6.8323,decDeg:-50.6146,mag:2.94},{name:{en:"Algorab",fr:"Algorab"},raHours:12.4977,decDeg:-16.5154,mag:2.94},{name:{en:"Sadalmelik",fr:"Sadalmelik"},raHours:22.0964,decDeg:-.3199,mag:2.95},{name:{en:"Zaurak",fr:"Zaurak"},raHours:3.9672,decDeg:-13.5085,mag:2.97},{name:{en:"Tianguan",fr:"Tianguan"},raHours:5.6274,decDeg:21.1425,mag:2.97},{name:{en:"Ras Elased Australis",fr:"Ras Elased Australis"},raHours:9.7642,decDeg:23.7743,mag:2.97},{name:{en:"Alnasl",fr:"Alnasl"},raHours:18.0968,decDeg:-30.4241,mag:2.98},{name:{en:"γ Hydrae",fr:"γ Hydrae"},raHours:13.3154,decDeg:-23.1715,mag:2.99},{name:{en:"ι¹ Scorpii",fr:"ι¹ Scorpii"},raHours:17.7931,decDeg:-40.127,mag:2.99},{name:{en:"Okab",fr:"Okab"},raHours:19.0902,decDeg:13.8635,mag:2.99},{name:{en:"β Trianguli",fr:"β Trianguli"},raHours:2.1591,decDeg:34.9873,mag:3},{name:{en:"ψ Ursae Majoris",fr:"ψ Ursae Majoris"},raHours:11.1611,decDeg:44.4985,mag:3},{name:{en:"Pherkad",fr:"Pherkad"},raHours:15.3455,decDeg:71.834,mag:3},{name:{en:"Xamidimura",fr:"Xamidimura"},raHours:16.8645,decDeg:-38.0474,mag:3},{name:{en:"Aldhanab",fr:"Aldhanab"},raHours:21.8988,decDeg:-37.3649,mag:3}],wp=Math.PI/180,Iy=180/Math.PI,Ly=256,Ny=19;function Uy(i,e){return 156543.03392*Math.cos(i*wp)/2**e}function Oy(i,e){return Uy(i,e)*Ly}function Tp(i,e){let t=0;for(;t<Ny&&Oy(i,t+1)>=e;)t++;return t}function Rp(i,e,t){const n=2**t,s=(i+180)/360*n,r=e*wp,a=(1-Math.log(Math.tan(r)+1/Math.cos(r))/Math.PI)/2*n;return{x:s,y:a}}function Fy(i,e,t){const{x:n,y:s}=Rp(i,e,t);return{x:Math.floor(n),y:Math.floor(s),z:t}}function zy(i){const e=2**i.z,t=i.x/e*360-180,n=(i.x+1)/e*360-180,s=v0(i.y,e);return{south:v0(i.y+1,e),north:s,west:t,east:n}}function v0(i,e){const t=i/e;return Math.atan(Math.sinh(Math.PI*(1-2*t)))*Iy}function Dp(i,e,t,n){const s=Fy(i,e,t),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:t});const o=a.map(zy),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 Cp=Math.PI/180,ko=111320;function xs(i,e,t,n){const s=ko*Math.cos(t*Cp),r=(i-t)*ko;return{x:(e-n)*s,z:-r}}function io(i,e,t,n){const s=ko*Math.cos(t*Cp),r=-e,a=i;return{lat:t+r/ko,lng:n+a/s}}const An=256,_0=3,By=32768;class ky{fetchImpl;tileUrlTemplate;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=e.tileUrlTemplate??"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"}async getElevationGrid(e,t){const n=(e.south+e.north)/2,s=(e.west+e.east)/2,r=Math.abs(xs(n,e.east,n,e.west).x),a=Math.abs(xs(e.north,s,e.south,s).z),o=Tp(n,Math.max(r,a)),{tiles:c}=Dp(s,n,o,_0),l=_0*An,h=new Float32Array(l*l),u=c[0];await Promise.all(c.map(f=>this.decodeTileInto(f,u,h,l)));const d=new Float32Array(t.width*t.height);for(let f=0;f<t.height;f++){const g=e.north+(e.south-e.north)*(f/(t.height-1));for(let x=0;x<t.width;x++){const m=e.west+(e.east-e.west)*(x/(t.width-1));d[f*t.width+x]=this.sampleAt(g,m,o,u,h,l)}}return{heights:d,width:t.width,height:t.height,bounds:e}}async decodeTileInto(e,t,n,s){const r=this.tileUrlTemplate.replace("{z}",String(e.z)).replace("{x}",String(e.x)).replace("{y}",String(e.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=An,c.height=An;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,An,An),u=(e.x-t.x)*An,d=(e.y-t.y)*An;for(let f=0;f<An;f++)for(let g=0;g<An;g++){const x=(f*An+g)*4,m=h[x]*256+h[x+1]+h[x+2]/256-By,p=u+g,b=d+f;n[b*s+p]=m}}sampleAt(e,t,n,s,r,a){const{x:o,y:c}=Rp(t,e,n),l=(o-s.x)*An,h=(c-s.y)*An,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],b=r[d*a+f],w=r[g*a+u],M=r[g*a+f],S=p+(b-p)*x,A=w+(M-w)*x;return S+(A-S)*m}}const Zc=256,x0=3;async function Hy(i,e,t,n){const s=(i.south+i.north)/2,r=(i.west+i.east)/2,a=Math.abs(xs(s,i.east,s,i.west).x),o=Math.abs(xs(i.north,r,i.south,r).z),c=Tp(s,Math.max(a,o)),{tiles:l}=Dp(r,s,c,x0),h=x0*Zc,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=t(m),b=await n(p);if(!b.ok)throw new Error(`Imagery tile fetch failed (${b.status}): ${p}`);const w=await createImageBitmap(await b.blob());d.drawImage(w,(m.x-f.x)*Zc,(m.y-f.y)*Zc)}));const g=document.createElement("canvas");g.width=e.width,g.height=e.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,e.width,e.height),g}class Gy{attribution="Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community";fetchImpl;tileUrlTemplate;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=e.tileUrlTemplate??"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"}async getImageryTexture(e,t){return{source:await Hy(e,t,s=>this.tileUrlTemplate.replace("{z}",String(s.z)).replace("{y}",String(s.y)).replace("{x}",String(s.x)),this.fetchImpl),width:t.width,height:t.height}}}function Vy(){return{elevation:new ky,imagery:new Gy}}const Vr=64,Ht=Vr+1,M0=512,Wy=900,Xy=700/900,qy=0,Yy=.01;function Ky(i,e,t){return{north:io(0,-t,i,e).lat,south:io(0,t,i,e).lat,east:io(t,0,i,e).lng,west:io(-t,0,i,e).lng}}async function $y(i,e,t,n=Wy){const s=n,r=n*Xy,a=Ky(i,e,s),o={width:Ht,height:Ht},[c,l]=await Promise.all([t.elevation.getElevationGrid(a,o),t.imagery.getImageryTexture(a,{width:M0,height:M0})]),h=Math.floor(Ht/2),u=c.heights[h*Ht+h],d=new Float32Array(Ht*Ht*3),f=new Float32Array(Ht*Ht*2),g=new Float32Array(Ht*Ht*4);for(let S=0;S<Ht;S++){const A=S/(Ht-1),R=a.north+(a.south-a.north)*A;for(let _=0;_<Ht;_++){const E=_/(Ht-1),C=a.west+(a.east-a.west)*E,{x:D,z:I}=xs(R,C,i,e),V=c.heights[S*Ht+_],q=qy+Yy+(V-u),U=S*Ht+_;d[U*3]=D,d[U*3+1]=q,d[U*3+2]=I,f[U*2]=E,f[U*2+1]=A;const X=Math.max(Math.abs(D),Math.abs(I)),G=1-Zy((X-r)/(s-r),0,1);g[U*4]=1,g[U*4+1]=1,g[U*4+2]=1,g[U*4+3]=G}}const x=new Uint16Array(Vr*Vr*6);let m=0;for(let S=0;S<Vr;S++)for(let A=0;A<Vr;A++){const R=S*Ht+A,_=R+1,E=R+Ht,C=E+1;x[m++]=R,x[m++]=E,x[m++]=_,x[m++]=_,x[m++]=E,x[m++]=C}const p=new wt;p.setAttribute("position",new dt(d,3)),p.setAttribute("uv",new dt(f,2)),p.setAttribute("color",new dt(g,4)),p.setIndex(new dt(x,1)),p.computeVertexNormals();const b=new wi(l.source);b.flipY=!1;const w=new oa({map:b,color:new ve(1,1,1),vertexColors:!0,transparent:!0,fog:!0}),M=new Qe(p,w);return M.receiveShadow=!0,M.castShadow=!0,{mesh:M,attribution:t.imagery.attribution}}function Zy(i,e,t){return Math.max(e,Math.min(t,i))}const Jy=18,Qy=.55,jy=.5,eS=`
4510
4510
  attribute float aSpeed;
4511
4511
  uniform float uTime;
4512
4512
  uniform float uOverallSpeed;
@@ -4564,9 +4564,9 @@ void main() {
4564
4564
  vec2 travel = vec2((ahead.x - here.x) * uAspect, ahead.y - here.y);
4565
4565
  // Straight down is the texture's own orientation, so that is the zero.
4566
4566
  vSlant = length(travel) < 1e-6 ? 0.0 : atan(travel.x, -travel.y);
4567
- gl_PointSize = uPixelSize / dist + vNearBlur * ${W3.toFixed(1)};
4567
+ gl_PointSize = uPixelSize / dist + vNearBlur * ${Jy.toFixed(1)};
4568
4568
  }
4569
- `,K3=`
4569
+ `,tS=`
4570
4570
  precision mediump float;
4571
4571
  uniform sampler2D uTexture;
4572
4572
  uniform vec3 uColor;
@@ -4602,18 +4602,18 @@ void main() {
4602
4602
  // defocus doesn't change color, only spreads+dims (see vertex shader's own gl_PointSize term) —
4603
4603
  // both dim the alpha so a maximally blurred/hazy drop doesn't stay as visually "solid" as a sharp
4604
4604
  // one right in the middle distance.
4605
- vec3 color = mix(uColor, uHazeColor, vHaze * ${X3.toFixed(2)});
4605
+ vec3 color = mix(uColor, uHazeColor, vHaze * ${Qy.toFixed(2)});
4606
4606
  float blur = max(vNearBlur, vHaze);
4607
- gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${q3.toFixed(2)}));
4607
+ gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${jy.toFixed(2)}));
4608
4608
  }
4609
- `;function Z3(i){let e=i;return function(){e|=0,e=e+1831565813|0;let n=Math.imul(e^e>>>15,1|e);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const $3=.14,gd=4.5;let Ia;function J3(){if(Ia)return Ia;const i=128,e=document.createElement("canvas");e.width=i,e.height=i;const t=e.getContext("2d"),n=t.createImageData(i,i),s=i/2,r=i*$3,a=i-r;for(let o=0;o<i;o++)for(let c=0;c<i;c++){const l=c+.5-s,h=o+.5<r?o+.5-r:o+.5>a?o+.5-a:0,u=Math.hypot(l,h),d=Math.exp(-(u*u)/(2*gd*gd)),f=(o*i+c)*4;n.data[f]=255,n.data[f+1]=255,n.data[f+2]=255,n.data[f+3]=Math.round(255*Math.min(1,d))}return t.putImageData(n,0,0),Ia=new gi(e),Ia}function Q3(i){const e=Z3(i.seed),t=new Float32Array(i.count*3),n=new Float32Array(i.count),s=i.radiusM;for(let l=0;l<i.count;l++){const h=e()*Math.PI*2,u=Math.sqrt(e())*i.radiusM;t[l*3]=Math.cos(h)*u,t[l*3+1]=e()*i.heightM,t[l*3+2]=Math.sin(h)*u,n[l]=.85+e()*.3}const r=new Rt;r.setAttribute("position",new ut(t,3)),r.setAttribute("aSpeed",new ut(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 Le(0,0)},uDropVelocity:{value:new L(0,-1,0)},uAspect:{value:1},uHeight:{value:i.heightM},uBottomY:{value:i.bottomYM},uHalfWidth:{value:s},uTexture:{value:J3()},uNearFocusDistance:{value:i.nearFocusDistanceM},uHazeDistance:{value:i.hazeDistanceM},uHazeColor:{value:i.hazeColor}},o=new At({uniforms:a,vertexShader:Y3,fragmentShader:K3,transparent:!0,depthWrite:!1,depthTest:!0}),c=new Ka(r,o);return c.frustumCulled=!1,{points:c,uniforms:a}}const j3=`
4609
+ `;function nS(i){let e=i;return function(){e|=0,e=e+1831565813|0;let n=Math.imul(e^e>>>15,1|e);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const iS=.14,y0=4.5;let so;function sS(){if(so)return so;const i=128,e=document.createElement("canvas");e.width=i,e.height=i;const t=e.getContext("2d"),n=t.createImageData(i,i),s=i/2,r=i*iS,a=i-r;for(let o=0;o<i;o++)for(let c=0;c<i;c++){const l=c+.5-s,h=o+.5<r?o+.5-r:o+.5>a?o+.5-a:0,u=Math.hypot(l,h),d=Math.exp(-(u*u)/(2*y0*y0)),f=(o*i+c)*4;n.data[f]=255,n.data[f+1]=255,n.data[f+2]=255,n.data[f+3]=Math.round(255*Math.min(1,d))}return t.putImageData(n,0,0),so=new wi(e),so}function rS(i){const e=nS(i.seed),t=new Float32Array(i.count*3),n=new Float32Array(i.count),s=i.radiusM;for(let l=0;l<i.count;l++){const h=e()*Math.PI*2,u=Math.sqrt(e())*i.radiusM;t[l*3]=Math.cos(h)*u,t[l*3+1]=e()*i.heightM,t[l*3+2]=Math.sin(h)*u,n[l]=.85+e()*.3}const r=new wt;r.setAttribute("position",new dt(t,3)),r.setAttribute("aSpeed",new dt(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 Ie(0,0)},uDropVelocity:{value:new P(0,-1,0)},uAspect:{value:1},uHeight:{value:i.heightM},uBottomY:{value:i.bottomYM},uHalfWidth:{value:s},uTexture:{value:sS()},uNearFocusDistance:{value:i.nearFocusDistanceM},uHazeDistance:{value:i.hazeDistanceM},uHazeColor:{value:i.hazeColor}},o=new Tt({uniforms:a,vertexShader:eS,fragmentShader:tS,transparent:!0,depthWrite:!1,depthTest:!0}),c=new yo(r,o);return c.frustumCulled=!1,{points:c,uniforms:a}}const aS=`
4610
4610
  varying vec3 vDir;
4611
4611
 
4612
4612
  void main() {
4613
4613
  vDir = normalize(position);
4614
4614
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
4615
4615
  }
4616
- `,vf=`vec3 hash3(vec3 p) {
4616
+ `,Pp=`vec3 hash3(vec3 p) {
4617
4617
  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)));
4618
4618
  return fract(sin(p) * 43758.5453) * 2.0 - 1.0;
4619
4619
  }
@@ -4641,7 +4641,7 @@ float fbm(vec3 p) {
4641
4641
  amp *= 0.55;
4642
4642
  }
4643
4643
  return sum;
4644
- }`,eM=`
4644
+ }`,oS=`
4645
4645
  float cirrusCoverAt(vec3 dir, float layerHeight, float coverage) {
4646
4646
  if (coverage <= 0.0 || dir.y <= 0.02) return 0.0;
4647
4647
  vec3 planePos = dir * (layerHeight / max(dir.y, 0.04));
@@ -4661,7 +4661,7 @@ float cirrusCoverAt(vec3 dir, float layerHeight, float coverage) {
4661
4661
  // is what makes a halo brighter along one arc than another even under total cover.
4662
4662
  return present * (0.30 + 0.70 * smoothstep(0.25, 0.85, shape));
4663
4663
  }
4664
- `,tM=`
4664
+ `,cS=`
4665
4665
  precision highp float;
4666
4666
  uniform vec3 sunDir;
4667
4667
  uniform vec3 sunColor;
@@ -4679,7 +4679,7 @@ varying vec3 vDir;
4679
4679
  uniform float layerHeight;
4680
4680
  uniform float fibrous;
4681
4681
 
4682
- ${vf}
4682
+ ${Pp}
4683
4683
 
4684
4684
  // Cellular (Worley) noise — distance to the nearest of 27 randomly-jittered cell points. Unlike
4685
4685
  // fbm's smooth interpolated blobs, this has genuinely sharp valleys between cells, reading as
@@ -4783,7 +4783,7 @@ void main() {
4783
4783
 
4784
4784
  gl_FragColor = vec4(color, alpha);
4785
4785
  }
4786
- `;function vd(i,e,t,n=0){const s={sunDir:{value:new L(0,1,0)},sunColor:{value:new Me(1,1,1)},ambientColor:{value:new Me(.5,.5,.5)},baseColor:{value:i},coverage:{value:e},layerHeight:{value:t},fibrous:{value:n}};return{material:new At({uniforms:s,vertexShader:j3,fragmentShader:tM,transparent:!0,depthWrite:!1,depthTest:!1,side:It}),uniforms:s}}const nM=1.5;function _d(i){const e=Math.PI/2-nM*Math.PI/180;return new wn(i,48,24,0,Math.PI*2,0,e)}class Pt{static OCTAVES=4;static GAIN=.55;static LACUNARITY=2.03;static fract(e){return e-Math.floor(e)}static hash3(e,t,n){const s=e*127.1+t*311.7+n*74.7,r=e*269.5+t*183.3+n*246.1,a=e*113.5+t*271.9+n*124.6;return[Pt.fract(Math.sin(s)*43758.5453)*2-1,Pt.fract(Math.sin(r)*43758.5453)*2-1,Pt.fract(Math.sin(a)*43758.5453)*2-1]}static noise3D(e,t,n){const s=Math.floor(e),r=Math.floor(t),a=Math.floor(n),o=e-s,c=t-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]=Pt.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(e,t,n){let s=0,r=Pt.GAIN;for(let a=0;a<Pt.OCTAVES;a++)s+=Pt.noise3D(e,t,n)*r,e*=Pt.LACUNARITY,t*=Pt.LACUNARITY,n*=Pt.LACUNARITY,r*=Pt.GAIN;return s}static worley(e,t,n){const s=Math.floor(e),r=Math.floor(t),a=Math.floor(n),o=e-s,c=t-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]=Pt.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(e,t,n){if(n<=0)return 0;const s=Math.abs(e.y);if(s<.026)return 0;const r=t/Math.max(s,.04),a=e.x*r,o=e.y*r,c=e.z*r,l=a*.006,h=o*.006,u=c*.006,d=a+Pt.fbm(l+12.3,h+12.3,u+12.3)*40,f=o+Pt.fbm(l+47.1,h+47.1,u+47.1)*40,g=c+Pt.fbm(l+91.7,h+91.7,u+91.7)*40,x=Pt.fbm(d*.014,f*.014,g*.014)*.5+.5,m=1-Pt.worley(d*.011,f*.011,g*.011),p=x+(m-x)*.4,A=1-n,T=(y,b,R)=>{const _=Math.min(1,Math.max(0,(R-y)/(b-y)));return _*_*(3-2*_)},M=T(A-.08,A+.08,p);return M+(1-M)*T(.82,1,n)}}class ds{static S10_MAG_PER_ARCSEC2=10+2.5*Math.log10(3600*3600);static toMagPerArcsec2(e){return ds.S10_MAG_PER_ARCSEC2-2.5*Math.log10(Math.max(e,1e-12))}static fromMagPerArcsec2(e){return 10**(.4*(ds.S10_MAG_PER_ARCSEC2-e))}static latitudeOfRowCoord(e){const t=2*e-1;return 90*Math.sign(t)*t*t}static rowCoordOfLatitude(e){return(Math.sign(e)*Math.sqrt(Math.min(Math.abs(e),90)/90)+1)/2}static angleOfColumnCoord(e){return 180*e*e}static columnCoordOfAngle(e){return Math.sqrt(Math.min(Math.max(e,0),180)/180)}}class qe{static LONGITUDE_STEPS=256;static LATITUDE_STEPS=128;static SUN_RADIUS_KPC=8.2;static SUN_HEIGHT_KPC=.02;static DISK_SCALE_LENGTH_KPC=2.6;static DISK_SCALE_HEIGHT_KPC=.3;static BULGE_SCALE_KPC=.5;static BULGE_FLATTENING=.6;static BULGE_TO_LOCAL_DISK=20;static DUST_SCALE_LENGTH_KPC=3.5;static DUST_SCALE_HEIGHT_KPC=.1;static EXTINCTION_MAG_PER_KPC=.8;static NEAR_LIMIT_KPC=.01;static FAR_LIMIT_KPC=40;static STEPS=192;static OPAQUE_MAG=15;static PEAK_MAG_PER_ARCSEC2=21;static PEAK_RADIANCE=6.278;static PEAK_LONGITUDE_DEG=0;static PEAK_LATITUDE_DEG=4.5;surfaceBrightnessS10(e,t){return this.radianceTowards(e,t)*qe.anchor()}static anchor(){return ds.fromMagPerArcsec2(qe.PEAK_MAG_PER_ARCSEC2)/qe.PEAK_RADIANCE}radianceTowards(e,t){return this.trace(e,t).light}extinctionTowards(e,t){return this.trace(e,t).extinctionMag}trace(e,t){const n=e*Math.PI/180,s=t*Math.PI/180,r=-Math.cos(s)*Math.cos(n),a=Math.cos(s)*Math.sin(n),o=Math.sin(s);let c=0,l=0,h=0;const u=Math.log(qe.NEAR_LIMIT_KPC),d=Math.log(qe.FAR_LIMIT_KPC)-u;for(let f=0;f<qe.STEPS;f++){const g=Math.exp(u+d*f/(qe.STEPS-1)),x=g-h;h=g;const m=g-x/2,p=qe.SUN_RADIUS_KPC+m*r,A=m*a,T=qe.SUN_HEIGHT_KPC+m*o,M=Math.hypot(p,A),y=Math.exp(-(M-qe.SUN_RADIUS_KPC)/qe.DISK_SCALE_LENGTH_KPC-Math.abs(T)/qe.DISK_SCALE_HEIGHT_KPC),b=Math.hypot(M,T/qe.BULGE_FLATTENING),R=qe.BULGE_TO_LOCAL_DISK*Math.exp(-b/qe.BULGE_SCALE_KPC);if(c+=(y+R)*x*10**(-.4*l),l+=qe.EXTINCTION_MAG_PER_KPC*Math.exp(-(M-qe.SUN_RADIUS_KPC)/qe.DUST_SCALE_LENGTH_KPC-(Math.abs(T)-qe.SUN_HEIGHT_KPC)/qe.DUST_SCALE_HEIGHT_KPC)*x,l>qe.OPAQUE_MAG)break}return{light:c,extinctionMag:l}}values=new Float32Array(qe.LONGITUDE_STEPS*qe.LATITUDE_STEPS);walked=0;get done(){return this.walked>=qe.LATITUDE_STEPS}walk(e){const t=qe.LONGITUDE_STEPS,n=Math.min(qe.LATITUDE_STEPS,this.walked+e);for(;this.walked<n;this.walked++){const s=ds.latitudeOfRowCoord((this.walked+.5)/qe.LATITUDE_STEPS);for(let r=0;r<t;r++)this.values[this.walked*t+r]=this.radianceTowards(360*(r+.5)/t,s)}}harvest(){let e=Number.POSITIVE_INFINITY;for(const s of this.values)s<e&&(e=s);const t=qe.anchor(),n=new Float32Array(this.values.length);for(let s=0;s<n.length;s++)n[s]=(this.values[s]-e)*t;return{width:qe.LONGITUDE_STEPS,height:qe.LATITUDE_STEPS,data:n}}}class gt{static LONGITUDE_STEPS=128;static LATITUDE_STEPS=96;static RADIAL_FALLOFF=1.3;static FAN_EXPONENT=2.6;static SUBLIMATION_AU=.1;static NEAR_LIMIT_AU=.004;static FAR_LIMIT_AU=8;static STEPS=224;static LOBE_ASYMMETRY=[.7,-.2,-.81];static LOBE_WEIGHT=[.665,.33,.00541];static RIGHT_ANGLE_S10=200;static POLE_S10=77;surfaceBrightnessS10(e,t){return this.radianceTowards(e,t)*this.anchor()}anchored;anchor(){return this.anchored===void 0&&(this.anchored=gt.RIGHT_ANGLE_S10/this.radianceTowards(90,0)),this.anchored}radianceTowards(e,t){const n=e*Math.PI/180,s=t*Math.PI/180,r=-Math.cos(s)*Math.cos(n),a=-Math.cos(s)*Math.sin(n),o=Math.sin(s),c=-r;let l=0,h=0;const u=Math.log(gt.NEAR_LIMIT_AU),d=Math.log(gt.FAR_LIMIT_AU)-u;for(let f=0;f<gt.STEPS;f++){const g=Math.exp(u+d*f/(gt.STEPS-1)),x=g-h;h=g;const m=g-x/2,p=1+m*r,A=m*a,T=m*o,M=Math.hypot(p,A,T);if(M<gt.SUBLIMATION_AU)continue;const y=T/M,b=M**-1.3*Math.exp(-2.6*Math.abs(y)),R=(c-m)/M;l+=b*this.scattering(R)*x/(M*M)}return l}scattering(e){let t=0;for(let n=0;n<gt.LOBE_ASYMMETRY.length;n++){const s=gt.LOBE_ASYMMETRY[n],r=1+s*s-2*s*e;t+=gt.LOBE_WEIGHT[n]*(1-s*s)/(4*Math.PI*r**1.5)}return t}values=new Float32Array(gt.LONGITUDE_STEPS*gt.LATITUDE_STEPS);walked=0;get done(){return this.walked>=gt.LATITUDE_STEPS}walk(e){const t=gt.LONGITUDE_STEPS,n=Math.min(gt.LATITUDE_STEPS,this.walked+e);for(;this.walked<n;this.walked++){const s=ds.latitudeOfRowCoord((this.walked+.5)/gt.LATITUDE_STEPS);for(let r=0;r<t;r++){const a=ds.angleOfColumnCoord((r+.5)/t);this.values[this.walked*t+r]=this.radianceTowards(a,s)}}}harvest(){const e=this.anchor();let t=Number.POSITIVE_INFINITY;for(const s of this.values)s<t&&(t=s);const n=new Float32Array(this.values.length);for(let s=0;s<n.length;s++)n[s]=(this.values[s]-t)*e;return{width:gt.LONGITUDE_STEPS,height:gt.LATITUDE_STEPS,data:n}}}class Xe{static get NANOLAMBERTS_PER_S10(){return Xe.toNanolamberts(10+2.5*Math.log10(3600*3600))}static nanolambertsOfS10(e){return e*Xe.NANOLAMBERTS_PER_S10}static TWILIGHT=[{sunAltitudeDeg:90,magPerArcsec2:3.5},{sunAltitudeDeg:10,magPerArcsec2:4.2},{sunAltitudeDeg:0,magPerArcsec2:7.5},{sunAltitudeDeg:-4,magPerArcsec2:13},{sunAltitudeDeg:-6,magPerArcsec2:15.6},{sunAltitudeDeg:-8,magPerArcsec2:17.2},{sunAltitudeDeg:-10,magPerArcsec2:18.5},{sunAltitudeDeg:-12,magPerArcsec2:19.7},{sunAltitudeDeg:-14,magPerArcsec2:20.8},{sunAltitudeDeg:-16,magPerArcsec2:21.6},{sunAltitudeDeg:-18,magPerArcsec2:21.9},{sunAltitudeDeg:-24,magPerArcsec2:22}];static moonlessMagPerArcsec2(e){const t=Xe.TWILIGHT;for(let n=0;n<t.length-1;n++){const s=t[n],r=t[n+1];if(e<=s.sunAltitudeDeg&&e>=r.sunAltitudeDeg){const a=(s.sunAltitudeDeg-e)/(s.sunAltitudeDeg-r.sunAltitudeDeg);return s.magPerArcsec2+(r.magPerArcsec2-s.magPerArcsec2)*a}}return e>0?t[0].magPerArcsec2:t[t.length-1].magPerArcsec2}static toNanolamberts(e){return 34.08*Math.exp(Xe.NANOLAMBERT_OFFSET-Xe.PER_MAGNITUDE*e)}static fromNanolamberts(e){return(Xe.NANOLAMBERT_OFFSET-Math.log(Math.max(e,1e-6)/34.08))/Xe.PER_MAGNITUDE}static NANOLAMBERT_OFFSET=20.7233;static PER_MAGNITUDE=Math.LN10/2.5;static airMass(e){const t=Math.cos(Math.max(e,0)*Math.PI/180);return 1/Math.sqrt(Math.max(1-.96*t*t,.001))}static EXTINCTION_PER_AIR_MASS=.172;static scatteringAt(e){const t=Math.min(Math.max(e,0),180)*Math.PI/180;return 10**5.36*(1.06+Math.cos(t)**2)+10**(6.15-Math.min(e,180)/40)}static scatteredFraction(e){return 1-10**(-.4*Xe.EXTINCTION_PER_AIR_MASS*Xe.airMass(e))}static AIRGLOW_MAG_PER_ARCSEC2=22;static twilightExcessNanolamberts(e){return Math.max(0,Xe.toNanolamberts(Xe.moonlessMagPerArcsec2(e))-Xe.toNanolamberts(Xe.AIRGLOW_MAG_PER_ARCSEC2))}static twilightOutput(e){const t=Xe.scatteringAt(90-e)*Xe.scatteredFraction(90);return Xe.twilightExcessNanolamberts(e)/t}static moonNanolamberts(e,t,n,s){return Xe.scatteringAt(n)*Xe.moonOutput(e,t)*Xe.scatteredFraction(s)}static moonOutput(e,t){if(t<=0)return 0;const n=Math.min(Math.abs(e),180);return 10**(-.4*(3.84+.026*n+4e-9*n**4))*10**(-.4*Xe.EXTINCTION_PER_AIR_MASS*Xe.airMass(t))}static phaseAngleOf(e){return Math.acos(Math.min(Math.max(2*e-1,-1),1))*180/Math.PI}static magPerArcsec2(e,t,n){const s=Xe.scatteredFraction(n),r=Xe.scatteringAt(e.separationDeg)*Xe.twilightOutput(e.altitudeDeg)*s,a=Xe.scatteringAt(t.separationDeg)*Xe.moonOutput(t.phaseAngleDeg,t.altitudeDeg)*s;return Xe.fromNanolamberts(Xe.toNanolamberts(Xe.AIRGLOW_MAG_PER_ARCSEC2)+r+a)}}class Pn{static RADIUS=890;static WORK_BUDGET_MS=6;static TOO_BRIGHT_MAG_PER_ARCSEC2=16;static MILKY_WAY_TINT=[.9,.94,1];static ZODIACAL_TINT=[1,.97,.9];object;material;galaxy=new qe;dust=new gt;milkyWayTexture;zodiacalTexture;milkyWayTexels;zodiacalTexels;workHandle;repaint;constructor(){this.milkyWayTexels=new Uint16Array(qe.LONGITUDE_STEPS*qe.LATITUDE_STEPS*4),this.milkyWayTexture=Pn.buildTexture(this.milkyWayTexels,qe.LONGITUDE_STEPS,qe.LATITUDE_STEPS,Qa),this.zodiacalTexels=new Uint16Array(gt.LONGITUDE_STEPS*gt.LATITUDE_STEPS*4),this.zodiacalTexture=Pn.buildTexture(this.zodiacalTexels,gt.LONGITUDE_STEPS,gt.LATITUDE_STEPS,sn),this.material=new At({uniforms:{uMilkyWay:{value:this.milkyWayTexture},uZodiacal:{value:this.zodiacalTexture},uGalactic:{value:new ze},uEclipticPole:{value:new L(0,1,0)},uSunLongitude:{value:new L(1,0,0)},uMoonDirection:{value:new L(0,-1,0)},uMoonOutput:{value:0},uSunDirection:{value:new L(0,-1,0)},uTwilightOutput:{value:0},uAirglowNanolamberts:{value:Xe.toNanolamberts(Xe.AIRGLOW_MAG_PER_ARCSEC2)},uSkyColor:{value:new L(0,0,0)},uMilkyWayTint:{value:new L(...Pn.MILKY_WAY_TINT)},uZodiacalTint:{value:new L(...Pn.ZODIACAL_TINT)},uReady:{value:0},uEncodeDestination:{value:1}},vertexShader:`
4786
+ `;function S0(i,e,t,n=0){const s={sunDir:{value:new P(0,1,0)},sunColor:{value:new ve(1,1,1)},ambientColor:{value:new ve(.5,.5,.5)},baseColor:{value:i},coverage:{value:e},layerHeight:{value:t},fibrous:{value:n}};return{material:new Tt({uniforms:s,vertexShader:aS,fragmentShader:cS,transparent:!0,depthWrite:!1,depthTest:!1,side:Ut}),uniforms:s}}const lS=1.5;function E0(i){const e=Math.PI/2-lS*Math.PI/180;return new Pn(i,48,24,0,Math.PI*2,0,e)}class Nt{static OCTAVES=4;static GAIN=.55;static LACUNARITY=2.03;static fract(e){return e-Math.floor(e)}static hash3(e,t,n){const s=e*127.1+t*311.7+n*74.7,r=e*269.5+t*183.3+n*246.1,a=e*113.5+t*271.9+n*124.6;return[Nt.fract(Math.sin(s)*43758.5453)*2-1,Nt.fract(Math.sin(r)*43758.5453)*2-1,Nt.fract(Math.sin(a)*43758.5453)*2-1]}static noise3D(e,t,n){const s=Math.floor(e),r=Math.floor(t),a=Math.floor(n),o=e-s,c=t-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[b,w,M]=Nt.hash3(s+x,r+m,a+p);return b*(o-x)+w*(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(e,t,n){let s=0,r=Nt.GAIN;for(let a=0;a<Nt.OCTAVES;a++)s+=Nt.noise3D(e,t,n)*r,e*=Nt.LACUNARITY,t*=Nt.LACUNARITY,n*=Nt.LACUNARITY,r*=Nt.GAIN;return s}static worley(e,t,n){const s=Math.floor(e),r=Math.floor(t),a=Math.floor(n),o=e-s,c=t-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]=Nt.hash3(s+u,r+d,a+f),p=u+(g*.5+.5)-o,b=d+(x*.5+.5)-c,w=f+(m*.5+.5)-l;h=Math.min(h,p*p+b*b+w*w)}return Math.sqrt(h)}static alphaAt(e,t,n){if(n<=0)return 0;const s=Math.abs(e.y);if(s<.026)return 0;const r=t/Math.max(s,.04),a=e.x*r,o=e.y*r,c=e.z*r,l=a*.006,h=o*.006,u=c*.006,d=a+Nt.fbm(l+12.3,h+12.3,u+12.3)*40,f=o+Nt.fbm(l+47.1,h+47.1,u+47.1)*40,g=c+Nt.fbm(l+91.7,h+91.7,u+91.7)*40,x=Nt.fbm(d*.014,f*.014,g*.014)*.5+.5,m=1-Nt.worley(d*.011,f*.011,g*.011),p=x+(m-x)*.4,b=1-n,w=(S,A,R)=>{const _=Math.min(1,Math.max(0,(R-S)/(A-S)));return _*_*(3-2*_)},M=w(b-.08,b+.08,p);return M+(1-M)*w(.82,1,n)}}class Ms{static S10_MAG_PER_ARCSEC2=10+2.5*Math.log10(3600*3600);static toMagPerArcsec2(e){return Ms.S10_MAG_PER_ARCSEC2-2.5*Math.log10(Math.max(e,1e-12))}static fromMagPerArcsec2(e){return 10**(.4*(Ms.S10_MAG_PER_ARCSEC2-e))}static latitudeOfRowCoord(e){const t=2*e-1;return 90*Math.sign(t)*t*t}static rowCoordOfLatitude(e){return(Math.sign(e)*Math.sqrt(Math.min(Math.abs(e),90)/90)+1)/2}static angleOfColumnCoord(e){return 180*e*e}static columnCoordOfAngle(e){return Math.sqrt(Math.min(Math.max(e,0),180)/180)}}class $e{static LONGITUDE_STEPS=256;static LATITUDE_STEPS=128;static SUN_RADIUS_KPC=8.2;static SUN_HEIGHT_KPC=.02;static DISK_SCALE_LENGTH_KPC=2.6;static DISK_SCALE_HEIGHT_KPC=.3;static BULGE_SCALE_KPC=.5;static BULGE_FLATTENING=.6;static BULGE_TO_LOCAL_DISK=20;static DUST_SCALE_LENGTH_KPC=3.5;static DUST_SCALE_HEIGHT_KPC=.1;static EXTINCTION_MAG_PER_KPC=.8;static NEAR_LIMIT_KPC=.01;static FAR_LIMIT_KPC=40;static STEPS=192;static OPAQUE_MAG=15;static PEAK_MAG_PER_ARCSEC2=21;static PEAK_RADIANCE=6.278;static PEAK_LONGITUDE_DEG=0;static PEAK_LATITUDE_DEG=4.5;surfaceBrightnessS10(e,t){return this.radianceTowards(e,t)*$e.anchor()}static anchor(){return Ms.fromMagPerArcsec2($e.PEAK_MAG_PER_ARCSEC2)/$e.PEAK_RADIANCE}radianceTowards(e,t){return this.trace(e,t).light}extinctionTowards(e,t){return this.trace(e,t).extinctionMag}trace(e,t){const n=e*Math.PI/180,s=t*Math.PI/180,r=-Math.cos(s)*Math.cos(n),a=Math.cos(s)*Math.sin(n),o=Math.sin(s);let c=0,l=0,h=0;const u=Math.log($e.NEAR_LIMIT_KPC),d=Math.log($e.FAR_LIMIT_KPC)-u;for(let f=0;f<$e.STEPS;f++){const g=Math.exp(u+d*f/($e.STEPS-1)),x=g-h;h=g;const m=g-x/2,p=$e.SUN_RADIUS_KPC+m*r,b=m*a,w=$e.SUN_HEIGHT_KPC+m*o,M=Math.hypot(p,b),S=Math.exp(-(M-$e.SUN_RADIUS_KPC)/$e.DISK_SCALE_LENGTH_KPC-Math.abs(w)/$e.DISK_SCALE_HEIGHT_KPC),A=Math.hypot(M,w/$e.BULGE_FLATTENING),R=$e.BULGE_TO_LOCAL_DISK*Math.exp(-A/$e.BULGE_SCALE_KPC);if(c+=(S+R)*x*10**(-.4*l),l+=$e.EXTINCTION_MAG_PER_KPC*Math.exp(-(M-$e.SUN_RADIUS_KPC)/$e.DUST_SCALE_LENGTH_KPC-(Math.abs(w)-$e.SUN_HEIGHT_KPC)/$e.DUST_SCALE_HEIGHT_KPC)*x,l>$e.OPAQUE_MAG)break}return{light:c,extinctionMag:l}}values=new Float32Array($e.LONGITUDE_STEPS*$e.LATITUDE_STEPS);walked=0;get done(){return this.walked>=$e.LATITUDE_STEPS}walk(e){const t=$e.LONGITUDE_STEPS,n=Math.min($e.LATITUDE_STEPS,this.walked+e);for(;this.walked<n;this.walked++){const s=Ms.latitudeOfRowCoord((this.walked+.5)/$e.LATITUDE_STEPS);for(let r=0;r<t;r++)this.values[this.walked*t+r]=this.radianceTowards(360*(r+.5)/t,s)}}harvest(){let e=Number.POSITIVE_INFINITY;for(const s of this.values)s<e&&(e=s);const t=$e.anchor(),n=new Float32Array(this.values.length);for(let s=0;s<n.length;s++)n[s]=(this.values[s]-e)*t;return{width:$e.LONGITUDE_STEPS,height:$e.LATITUDE_STEPS,data:n}}}class xt{static LONGITUDE_STEPS=128;static LATITUDE_STEPS=96;static RADIAL_FALLOFF=1.3;static FAN_EXPONENT=2.6;static SUBLIMATION_AU=.1;static NEAR_LIMIT_AU=.004;static FAR_LIMIT_AU=8;static STEPS=224;static LOBE_ASYMMETRY=[.7,-.2,-.81];static LOBE_WEIGHT=[.665,.33,.00541];static RIGHT_ANGLE_S10=200;static POLE_S10=77;surfaceBrightnessS10(e,t){return this.radianceTowards(e,t)*this.anchor()}anchored;anchor(){return this.anchored===void 0&&(this.anchored=xt.RIGHT_ANGLE_S10/this.radianceTowards(90,0)),this.anchored}radianceTowards(e,t){const n=e*Math.PI/180,s=t*Math.PI/180,r=-Math.cos(s)*Math.cos(n),a=-Math.cos(s)*Math.sin(n),o=Math.sin(s),c=-r;let l=0,h=0;const u=Math.log(xt.NEAR_LIMIT_AU),d=Math.log(xt.FAR_LIMIT_AU)-u;for(let f=0;f<xt.STEPS;f++){const g=Math.exp(u+d*f/(xt.STEPS-1)),x=g-h;h=g;const m=g-x/2,p=1+m*r,b=m*a,w=m*o,M=Math.hypot(p,b,w);if(M<xt.SUBLIMATION_AU)continue;const S=w/M,A=M**-1.3*Math.exp(-2.6*Math.abs(S)),R=(c-m)/M;l+=A*this.scattering(R)*x/(M*M)}return l}scattering(e){let t=0;for(let n=0;n<xt.LOBE_ASYMMETRY.length;n++){const s=xt.LOBE_ASYMMETRY[n],r=1+s*s-2*s*e;t+=xt.LOBE_WEIGHT[n]*(1-s*s)/(4*Math.PI*r**1.5)}return t}values=new Float32Array(xt.LONGITUDE_STEPS*xt.LATITUDE_STEPS);walked=0;get done(){return this.walked>=xt.LATITUDE_STEPS}walk(e){const t=xt.LONGITUDE_STEPS,n=Math.min(xt.LATITUDE_STEPS,this.walked+e);for(;this.walked<n;this.walked++){const s=Ms.latitudeOfRowCoord((this.walked+.5)/xt.LATITUDE_STEPS);for(let r=0;r<t;r++){const a=Ms.angleOfColumnCoord((r+.5)/t);this.values[this.walked*t+r]=this.radianceTowards(a,s)}}}harvest(){const e=this.anchor();let t=Number.POSITIVE_INFINITY;for(const s of this.values)s<t&&(t=s);const n=new Float32Array(this.values.length);for(let s=0;s<n.length;s++)n[s]=(this.values[s]-t)*e;return{width:xt.LONGITUDE_STEPS,height:xt.LATITUDE_STEPS,data:n}}}class Ke{static get NANOLAMBERTS_PER_S10(){return Ke.toNanolamberts(10+2.5*Math.log10(3600*3600))}static nanolambertsOfS10(e){return e*Ke.NANOLAMBERTS_PER_S10}static TWILIGHT=[{sunAltitudeDeg:90,magPerArcsec2:3.5},{sunAltitudeDeg:10,magPerArcsec2:4.2},{sunAltitudeDeg:0,magPerArcsec2:7.5},{sunAltitudeDeg:-4,magPerArcsec2:13},{sunAltitudeDeg:-6,magPerArcsec2:15.6},{sunAltitudeDeg:-8,magPerArcsec2:17.2},{sunAltitudeDeg:-10,magPerArcsec2:18.5},{sunAltitudeDeg:-12,magPerArcsec2:19.7},{sunAltitudeDeg:-14,magPerArcsec2:20.8},{sunAltitudeDeg:-16,magPerArcsec2:21.6},{sunAltitudeDeg:-18,magPerArcsec2:21.9},{sunAltitudeDeg:-24,magPerArcsec2:22}];static moonlessMagPerArcsec2(e){const t=Ke.TWILIGHT;for(let n=0;n<t.length-1;n++){const s=t[n],r=t[n+1];if(e<=s.sunAltitudeDeg&&e>=r.sunAltitudeDeg){const a=(s.sunAltitudeDeg-e)/(s.sunAltitudeDeg-r.sunAltitudeDeg);return s.magPerArcsec2+(r.magPerArcsec2-s.magPerArcsec2)*a}}return e>0?t[0].magPerArcsec2:t[t.length-1].magPerArcsec2}static toNanolamberts(e){return 34.08*Math.exp(Ke.NANOLAMBERT_OFFSET-Ke.PER_MAGNITUDE*e)}static fromNanolamberts(e){return(Ke.NANOLAMBERT_OFFSET-Math.log(Math.max(e,1e-6)/34.08))/Ke.PER_MAGNITUDE}static NANOLAMBERT_OFFSET=20.7233;static PER_MAGNITUDE=Math.LN10/2.5;static airMass(e){const t=Math.cos(Math.max(e,0)*Math.PI/180);return 1/Math.sqrt(Math.max(1-.96*t*t,.001))}static EXTINCTION_PER_AIR_MASS=.172;static scatteringAt(e){const t=Math.min(Math.max(e,0),180)*Math.PI/180;return 10**5.36*(1.06+Math.cos(t)**2)+10**(6.15-Math.min(e,180)/40)}static scatteredFraction(e){return 1-10**(-.4*Ke.EXTINCTION_PER_AIR_MASS*Ke.airMass(e))}static AIRGLOW_MAG_PER_ARCSEC2=22;static twilightExcessNanolamberts(e){return Math.max(0,Ke.toNanolamberts(Ke.moonlessMagPerArcsec2(e))-Ke.toNanolamberts(Ke.AIRGLOW_MAG_PER_ARCSEC2))}static twilightOutput(e){const t=Ke.scatteringAt(90-e)*Ke.scatteredFraction(90);return Ke.twilightExcessNanolamberts(e)/t}static moonNanolamberts(e,t,n,s){return Ke.scatteringAt(n)*Ke.moonOutput(e,t)*Ke.scatteredFraction(s)}static moonOutput(e,t){if(t<=0)return 0;const n=Math.min(Math.abs(e),180);return 10**(-.4*(3.84+.026*n+4e-9*n**4))*10**(-.4*Ke.EXTINCTION_PER_AIR_MASS*Ke.airMass(t))}static phaseAngleOf(e){return Math.acos(Math.min(Math.max(2*e-1,-1),1))*180/Math.PI}static magPerArcsec2(e,t,n){const s=Ke.scatteredFraction(n),r=Ke.scatteringAt(e.separationDeg)*Ke.twilightOutput(e.altitudeDeg)*s,a=Ke.scatteringAt(t.separationDeg)*Ke.moonOutput(t.phaseAngleDeg,t.altitudeDeg)*s;return Ke.fromNanolamberts(Ke.toNanolamberts(Ke.AIRGLOW_MAG_PER_ARCSEC2)+r+a)}}class Un{static RADIUS=890;static WORK_BUDGET_MS=6;static TOO_BRIGHT_MAG_PER_ARCSEC2=16;static MILKY_WAY_TINT=[.9,.94,1];static ZODIACAL_TINT=[1,.97,.9];object;material;galaxy=new $e;dust=new xt;milkyWayTexture;zodiacalTexture;milkyWayTexels;zodiacalTexels;workHandle;repaint;constructor(){this.milkyWayTexels=new Uint16Array($e.LONGITUDE_STEPS*$e.LATITUDE_STEPS*4),this.milkyWayTexture=Un.buildTexture(this.milkyWayTexels,$e.LONGITUDE_STEPS,$e.LATITUDE_STEPS,Ao),this.zodiacalTexels=new Uint16Array(xt.LONGITUDE_STEPS*xt.LATITUDE_STEPS*4),this.zodiacalTexture=Un.buildTexture(this.zodiacalTexels,xt.LONGITUDE_STEPS,xt.LATITUDE_STEPS,rn),this.material=new Tt({uniforms:{uMilkyWay:{value:this.milkyWayTexture},uZodiacal:{value:this.zodiacalTexture},uGalactic:{value:new Be},uEclipticPole:{value:new P(0,1,0)},uSunLongitude:{value:new P(1,0,0)},uMoonDirection:{value:new P(0,-1,0)},uMoonOutput:{value:0},uSunDirection:{value:new P(0,-1,0)},uTwilightOutput:{value:0},uAirglowNanolamberts:{value:Ke.toNanolamberts(Ke.AIRGLOW_MAG_PER_ARCSEC2)},uSkyColor:{value:new P(0,0,0)},uMilkyWayTint:{value:new P(...Un.MILKY_WAY_TINT)},uZodiacalTint:{value:new P(...Un.ZODIACAL_TINT)},uReady:{value:0},uEncodeDestination:{value:1}},vertexShader:`
4787
4787
  varying vec3 vDirection;
4788
4788
  void main() {
4789
4789
  vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
@@ -4791,7 +4791,7 @@ void main() {
4791
4791
  }
4792
4792
  `,fragmentShader:`
4793
4793
  precision highp float;
4794
- ${Ao}
4794
+ ${Qo}
4795
4795
  varying vec3 vDirection;
4796
4796
  uniform sampler2D uMilkyWay;
4797
4797
  uniform sampler2D uZodiacal;
@@ -4898,13 +4898,13 @@ void main() {
4898
4898
  vec3 onEncoded = encodeSrgb(uSkyColor + light) - encodeSrgb(uSkyColor);
4899
4899
  gl_FragColor = vec4(mix(light, onEncoded, uEncodeDestination), 1.0);
4900
4900
  }
4901
- `,transparent:!0,blending:ni,depthWrite:!1,side:It,fog:!1}),this.object=new je(new wn(Pn.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}static buildTexture(e,t,n,s){const r=new Mo(e,t,n,hn,Qt);return r.minFilter=Et,r.magFilter=Et,r.wrapS=s,r.wrapT=sn,r.needsUpdate=!0,r}set onReady(e){this.repaint=e}update(e){if(Xe.moonlessMagPerArcsec2(e.sunAltitudeDeg)<Pn.TOO_BRIGHT_MAG_PER_ARCSEC2){this.object.visible=!1,this.stopWork();return}const n=this.material.uniforms;n.uGalactic.value.copy(e.galactic),n.uEclipticPole.value.copy(e.eclipticPole).normalize(),n.uSunLongitude.value.copy(e.sunLongitude).normalize(),n.uMoonDirection.value.copy(e.moon.direction).normalize(),n.uSunDirection.value.copy(e.sunDirection).normalize(),n.uMoonOutput.value=Xe.moonOutput(e.moon.phaseAngleDeg,e.moon.altitudeDeg),n.uTwilightOutput.value=Xe.twilightOutput(e.sunAltitudeDeg),n.uSkyColor.value.copy(e.skyColor),this.object.visible=!0,n.uReady.value<.5&&this.scheduleWork()}setDestinationEncoded(e){this.material.uniforms.uEncodeDestination.value=e?1:0}hide(){this.object.visible=!1,this.stopWork()}scheduleWork(){if(this.workHandle!==void 0)return;const e=()=>{this.workHandle=void 0;const t=performance.now()+Pn.WORK_BUDGET_MS;for(;performance.now()<t&&!(this.galaxy.done&&this.dust.done);)this.galaxy.walk(1),this.dust.walk(1);if(this.galaxy.done&&this.dust.done){this.publish();return}this.workHandle=requestAnimationFrame(e)};this.workHandle=requestAnimationFrame(e)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0}publish(){Pn.fill(this.milkyWayTexels,this.galaxy.harvest()),this.milkyWayTexture.needsUpdate=!0,Pn.fill(this.zodiacalTexels,this.dust.harvest()),this.zodiacalTexture.needsUpdate=!0,this.material.uniforms.uReady.value=1,this.repaint?.()}static fill(e,t){for(let n=0;n<t.data.length;n++)e[n*4]=Ui.toHalfFloat(Xe.nanolambertsOfS10(t.data[n])),e[n*4+3]=Ui.toHalfFloat(1)}dispose(){this.stopWork(),this.milkyWayTexture.dispose(),this.zodiacalTexture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class In{static GALACTIC_CENTRE={raHours:266.4051/15,decDeg:-28.936175};static GALACTIC_ROTATION={raHours:318.00448/15,decDeg:48.32964};static GALACTIC_POLE={raHours:192.85948/15,decDeg:27.12825};static ECLIPTIC_POLE={raHours:18,decDeg:90-23.439291};static galactic(e,t){return{centre:In.at(In.GALACTIC_CENTRE,e,t),rotation:In.at(In.GALACTIC_ROTATION,e,t),pole:In.at(In.GALACTIC_POLE,e,t)}}static eclipticPole(e,t){return In.at(In.ECLIPTIC_POLE,e,t)}static at(e,t,n){return rr(e.raHours,e.decDeg,t,n,!1)}}const iM=`
4901
+ `,transparent:!0,blending:ai,depthWrite:!1,side:Ut,fog:!1}),this.object=new Qe(new Pn(Un.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}static buildTexture(e,t,n,s){const r=new gr(e,t,n,an,jt);return r.minFilter=At,r.magFilter=At,r.wrapS=s,r.wrapT=rn,r.needsUpdate=!0,r}set onReady(e){this.repaint=e}update(e){if(Ke.moonlessMagPerArcsec2(e.sunAltitudeDeg)<Un.TOO_BRIGHT_MAG_PER_ARCSEC2){this.object.visible=!1,this.stopWork();return}const n=this.material.uniforms;n.uGalactic.value.copy(e.galactic),n.uEclipticPole.value.copy(e.eclipticPole).normalize(),n.uSunLongitude.value.copy(e.sunLongitude).normalize(),n.uMoonDirection.value.copy(e.moon.direction).normalize(),n.uSunDirection.value.copy(e.sunDirection).normalize(),n.uMoonOutput.value=Ke.moonOutput(e.moon.phaseAngleDeg,e.moon.altitudeDeg),n.uTwilightOutput.value=Ke.twilightOutput(e.sunAltitudeDeg),n.uSkyColor.value.copy(e.skyColor),this.object.visible=!0,n.uReady.value<.5&&this.scheduleWork()}setDestinationEncoded(e){this.material.uniforms.uEncodeDestination.value=e?1:0}hide(){this.object.visible=!1,this.stopWork()}scheduleWork(){if(this.workHandle!==void 0)return;const e=()=>{this.workHandle=void 0;const t=performance.now()+Un.WORK_BUDGET_MS;for(;performance.now()<t&&!(this.galaxy.done&&this.dust.done);)this.galaxy.walk(1),this.dust.walk(1);if(this.galaxy.done&&this.dust.done){this.publish();return}this.workHandle=requestAnimationFrame(e)};this.workHandle=requestAnimationFrame(e)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0}publish(){Un.fill(this.milkyWayTexels,this.galaxy.harvest()),this.milkyWayTexture.needsUpdate=!0,Un.fill(this.zodiacalTexels,this.dust.harvest()),this.zodiacalTexture.needsUpdate=!0,this.material.uniforms.uReady.value=1,this.repaint?.()}static fill(e,t){for(let n=0;n<t.data.length;n++)e[n*4]=Wi.toHalfFloat(Ke.nanolambertsOfS10(t.data[n])),e[n*4+3]=Wi.toHalfFloat(1)}dispose(){this.stopWork(),this.milkyWayTexture.dispose(),this.zodiacalTexture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class On{static GALACTIC_CENTRE={raHours:266.4051/15,decDeg:-28.936175};static GALACTIC_ROTATION={raHours:318.00448/15,decDeg:48.32964};static GALACTIC_POLE={raHours:192.85948/15,decDeg:27.12825};static ECLIPTIC_POLE={raHours:18,decDeg:90-23.439291};static galactic(e,t){return{centre:On.at(On.GALACTIC_CENTRE,e,t),rotation:On.at(On.GALACTIC_ROTATION,e,t),pole:On.at(On.GALACTIC_POLE,e,t)}}static eclipticPole(e,t){return On.at(On.ECLIPTIC_POLE,e,t)}static at(e,t,n){return mr(e.raHours,e.decDeg,t,n,!1)}}const hS=`
4902
4902
  varying vec2 vUv;
4903
4903
  void main() {
4904
4904
  vUv = uv;
4905
4905
  gl_Position = vec4(position, 1.0);
4906
4906
  }
4907
- `,sM=`
4907
+ `,uS=`
4908
4908
  // Based on https://www.shadertoy.com/view/4sX3Rs
4909
4909
  uniform float uTime;
4910
4910
  uniform vec2 uLensPosition;
@@ -5334,7 +5334,7 @@ void main()
5334
5334
  // stays what it always was for the optional artifacts.
5335
5335
  gl_FragColor = vec4(dazzle + artifactsContribution * uOpacity, 1.0);
5336
5336
  }
5337
- `;let La;function rM(){if(La)return La;const i=256,e=document.createElement("canvas");e.width=i,e.height=i;const t=e.getContext("2d");t.fillStyle="rgba(60,60,60,1)",t.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=t.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)"),t.fillStyle=c,t.fillRect(0,0,i,i)}return La=new gi(e),La}function aM(){const i={uTime:{value:0},uResolution:{value:new Le(1,1)},uLensPosition:{value:new Le(0,0)},uColorGain:{value:new Me(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 Me(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:rM()}},e=new At({uniforms:i,vertexShader:iM,fragmentShader:sM,transparent:!0,depthWrite:!1,depthTest:!1,blending:ni,fog:!1,name:"LensFlareShader"}),t=new je(new ki(2,2),e);return t.frustumCulled=!1,t.renderOrder=20,{mesh:t,uniforms:i}}class uo{static MAX_HALF_ANGLE_DEG=80;target;quadScene=new _o;quadCamera=new or(-1,1,1,-1,0,1);material;width;height;constructor(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target=new un(this.width,this.height,{type:Qt}),this.material=new At({uniforms:{uSource:{value:this.target.texture},uHalfFovRad:{value:.5236},uAspect:{value:this.width/this.height},uSrcTanHalfFovY:{value:1},uResolution:{value:new Le(this.width,this.height)},uEncodeOutput:{value:1}},vertexShader:`
5337
+ `;let ro;function dS(){if(ro)return ro;const i=256,e=document.createElement("canvas");e.width=i,e.height=i;const t=e.getContext("2d");t.fillStyle="rgba(60,60,60,1)",t.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=t.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)"),t.fillStyle=c,t.fillRect(0,0,i,i)}return ro=new wi(e),ro}function fS(){const i={uTime:{value:0},uResolution:{value:new Ie(1,1)},uLensPosition:{value:new Ie(0,0)},uColorGain:{value:new ve(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 ve(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:dS()}},e=new Tt({uniforms:i,vertexShader:hS,fragmentShader:uS,transparent:!0,depthWrite:!1,depthTest:!1,blending:ai,fog:!1,name:"LensFlareShader"}),t=new Qe(new $i(2,2),e);return t.frustumCulled=!1,t.renderOrder=20,{mesh:t,uniforms:i}}class Ho{static MAX_HALF_ANGLE_DEG=80;target;quadScene=new Yo;quadCamera=new xr(-1,1,1,-1,0,1);material;width;height;constructor(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target=new fn(this.width,this.height,{type:jt}),this.material=new Tt({uniforms:{uSource:{value:this.target.texture},uHalfFovRad:{value:.5236},uAspect:{value:this.width/this.height},uSrcTanHalfFovY:{value:1},uResolution:{value:new Ie(this.width,this.height)},uEncodeOutput:{value:1}},vertexShader:`
5338
5338
  varying vec2 vNdc;
5339
5339
  void main() {
5340
5340
  vNdc = position.xy;
@@ -5342,7 +5342,7 @@ void main()
5342
5342
  }
5343
5343
  `,fragmentShader:`
5344
5344
  precision highp float;
5345
- ${Ao}
5345
+ ${Qo}
5346
5346
  uniform sampler2D uSource;
5347
5347
  uniform float uHalfFovRad;
5348
5348
  uniform float uAspect;
@@ -5374,7 +5374,7 @@ void main()
5374
5374
  vec3 colour = texture2D(uSource, src * 0.5 + 0.5).rgb;
5375
5375
  gl_FragColor = vec4(uEncodeOutput > 0.5 ? encodeSrgb(colour) : colour, 1.0);
5376
5376
  }
5377
- `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new je(new ki(2,2),this.material))}directionFor(e,t,n){const s=this.width/this.height,r=n/2*Math.PI/180,a=e*s*r,o=t*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(e,t){return e/2*Math.hypot(t,1)}static supports(e,t){return this.cornerHalfAngleDeg(e,t)<=this.MAX_HALF_ANGLE_DEG}setEncodesOutput(e){this.material.uniforms.uEncodeOutput.value=e?1:0}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),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(e,t,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=e.getRenderTarget();e.setRenderTarget(this.target),e.render(t,n),e.setRenderTarget(c),n.fov=o,n.updateProjectionMatrix(),e.render(this.quadScene,this.quadCamera)}sourceFovDeg(e,t){return Math.atan(this.sourceTanHalfFovY(e,t))*360/Math.PI}sourceTanHalfFovY(e,t){const n=uo.cornerHalfAngleDeg(e,t)*Math.PI/180;return Math.tan(n)/Math.hypot(t,1)}dispose(){this.target.dispose(),this.material.dispose(),this.quadScene.clear()}}class Pr{static MAX_RADIUS_PX=24;static TAPS=32;target;quadScene=new _o;quadCamera=new or(-1,1,1,-1,0,1);material;width;height;constructor(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t);const n=new ls(this.width,this.height,On);n.minFilter=Nt,n.magFilter=Nt,this.target=new un(this.width,this.height,{type:Qt,depthTexture:n}),this.material=new At({uniforms:{uColour:{value:this.target.texture},uDepth:{value:n},uResolution:{value:new Le(this.width,this.height)},uNear:{value:.1},uFar:{value:1e3},uApertureMm2:{value:0},uFocusDistance:{value:0},uFocalLengthMm:{value:50},uPixelsPerMm:{value:0},uMaxRadius:{value:Pr.MAX_RADIUS_PX},uEncodeOutput:{value:1}},vertexShader:`
5377
+ `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new Qe(new $i(2,2),this.material))}directionFor(e,t,n){const s=this.width/this.height,r=n/2*Math.PI/180,a=e*s*r,o=t*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(e,t){return e/2*Math.hypot(t,1)}static supports(e,t){return this.cornerHalfAngleDeg(e,t)<=this.MAX_HALF_ANGLE_DEG}setEncodesOutput(e){this.material.uniforms.uEncodeOutput.value=e?1:0}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),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(e,t,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=e.getRenderTarget();e.setRenderTarget(this.target),e.render(t,n),e.setRenderTarget(c),n.fov=o,n.updateProjectionMatrix(),e.render(this.quadScene,this.quadCamera)}sourceFovDeg(e,t){return Math.atan(this.sourceTanHalfFovY(e,t))*360/Math.PI}sourceTanHalfFovY(e,t){const n=Ho.cornerHalfAngleDeg(e,t)*Math.PI/180;return Math.tan(n)/Math.hypot(t,1)}dispose(){this.target.dispose(),this.material.dispose(),this.quadScene.clear()}}class $r{static MAX_RADIUS_PX=24;static TAPS=32;target;quadScene=new Yo;quadCamera=new xr(-1,1,1,-1,0,1);material;width;height;constructor(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t);const n=new vs(this.width,this.height,Hn);n.minFilter=Ot,n.magFilter=Ot,this.target=new fn(this.width,this.height,{type:jt,depthTexture:n}),this.material=new Tt({uniforms:{uColour:{value:this.target.texture},uDepth:{value:n},uResolution:{value:new Ie(this.width,this.height)},uNear:{value:.1},uFar:{value:1e3},uApertureMm2:{value:0},uFocusDistance:{value:0},uFocalLengthMm:{value:50},uPixelsPerMm:{value:0},uMaxRadius:{value:$r.MAX_RADIUS_PX},uEncodeOutput:{value:1}},vertexShader:`
5378
5378
  varying vec2 vUv;
5379
5379
  void main() {
5380
5380
  vUv = position.xy * 0.5 + 0.5;
@@ -5382,7 +5382,7 @@ void main()
5382
5382
  }
5383
5383
  `,fragmentShader:`
5384
5384
  precision highp float;
5385
- ${Ao}
5385
+ ${Qo}
5386
5386
  varying vec2 vUv;
5387
5387
  uniform sampler2D uColour;
5388
5388
  uniform sampler2D uDepth;
@@ -5433,12 +5433,12 @@ void main()
5433
5433
  vec2 texel = 1.0 / uResolution;
5434
5434
  vec3 total = colour.rgb;
5435
5435
  float weight = 1.0;
5436
- for (int tap = 0; tap < ${Pr.TAPS}; tap++) {
5436
+ for (int tap = 0; tap < ${$r.TAPS}; tap++) {
5437
5437
  // Golden angle, with the radius growing as the square root of the index so the samples
5438
5438
  // cover the disc evenly rather than crowding its middle.
5439
5439
  float index = float(tap) + 0.5;
5440
5440
  float angle = index * 2.39996323;
5441
- float spread = sqrt(index / float(${Pr.TAPS})) * radius;
5441
+ float spread = sqrt(index / float(${$r.TAPS})) * radius;
5442
5442
  vec2 at = vUv + vec2(cos(angle), sin(angle)) * spread * texel;
5443
5443
  // A sample only lends its light to this pixel if it is at least as blurred as the
5444
5444
  // distance it would have to cross — otherwise a sharp foreground would bleed into the
@@ -5451,7 +5451,7 @@ void main()
5451
5451
  // values — and encoded only at the very end. See colorSpace.ts.
5452
5452
  gl_FragColor = vec4(forDestination(total / weight), colour.a);
5453
5453
  }
5454
- `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new je(new ki(2,2),this.material))}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height)}setLens(e,t,n,s){const r=this.material.uniforms;r.uApertureMm2.value=e*e/Math.max(.1,t),r.uFocusDistance.value=Math.max(0,n),r.uFocalLengthMm.value=e,r.uPixelsPerMm.value=this.height/Math.max(.1,s)}setEncodesOutput(e){this.material.uniforms.uEncodeOutput.value=e?1:0}render(e,t,n){const s=this.material.uniforms;s.uNear.value=n.near,s.uFar.value=n.far;const r=e.getRenderTarget();e.setRenderTarget(this.target),e.clear(),e.render(t,n),e.setRenderTarget(r),e.render(this.quadScene,this.quadCamera)}dispose(){this.target.depthTexture?.dispose(),this.target.dispose(),this.material.dispose()}}class Qe{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 e=Qe.ICE_INDEX_RED,t=Math.sqrt((4-e*e)/3);return Math.asin(Math.min(1,t))*180/Math.PI}static minimumDeviationDeg(e,t){const n=e*Math.PI/180,s=t*Math.sin(n/2);return s>1?Number.NaN:(2*Math.asin(s)-n)*180/Math.PI}static effectiveIndex(e,t){const n=t*Math.PI/180,s=Math.cos(n);return s<=0?Number.POSITIVE_INFINITY:Math.sqrt(e*e-Math.sin(n)**2)/s}static parheliaAzimuthDeg(e,t=Qe.ICE_INDEX_RED){const n=Qe.minimumDeviationDeg(Qe.SIDE_PRISM_ANGLE_DEG,Qe.effectiveIndex(t,e));return Number.isFinite(n)?n:void 0}static parheliaDistanceDeg(e,t=Qe.ICE_INDEX_RED){const n=Qe.parheliaAzimuthDeg(e,t);if(n===void 0)return;const s=e*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 e=Qe.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(e*e-1)))*180/Math.PI}static circumzenithalAltitudeDeg(e,t=Qe.ICE_INDEX_RED){if(e<0||e>90-Qe.PLATE_END_FACE_LIMIT_DEG)return;const n=Math.cos(e*Math.PI/180),s=Math.sqrt(t*t-n*n);if(!(s>=1))return Math.asin(s)*180/Math.PI}static DECK_HEIGHT_M=8e3;static deckLitUntilDeg(e){return Math.acos(6371e3/(6371e3+Math.max(0,e)))*180/Math.PI}static halo22(){return Qe.ringOf("halo22",Qe.SIDE_PRISM_ANGLE_DEG)}static halo46(){return Qe.ringOf("halo46",Qe.END_PRISM_ANGLE_DEG)}static ringOf(e,t){const n=Qe.minimumDeviationDeg(t,Qe.ICE_INDEX_RED),s=Qe.minimumDeviationDeg(t,Qe.ICE_INDEX_BLUE);return{id:e,angleDeg:(n+s)/2,redAngleDeg:n,blueAngleDeg:s}}static strength(e,t,n=90,s=0){const r=Math.max(0,Math.min(1,e)),a=Math.max(0,1-Math.max(0,Math.min(1,t))),o=n>=0?1:s<=0?0:Math.max(0,1+n/s);return r*a*o}static formsAt(e,t=0){if(e<=-t)return[];const n=[Qe.halo22(),Qe.halo46()],s=e>0?Qe.parheliaDistanceDeg(e):void 0;s!==void 0&&n.push({id:"parhelia",angleDeg:s,redAngleDeg:s,blueAngleDeg:Qe.parheliaDistanceDeg(e,Qe.ICE_INDEX_BLUE)}),n.push({id:"tangentArc",angleDeg:Qe.halo22().angleDeg}),e>0&&n.push({id:"parhelicCircle",angleDeg:e});const r=Qe.circumzenithalAltitudeDeg(e);return r!==void 0&&n.push({id:"circumzenithal",angleDeg:r}),e>Qe.PLATE_END_FACE_LIMIT_DEG&&n.push({id:"circumhorizontal"}),e<Qe.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&n.push({id:"pillar"}),n}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class fo{static reflectance(e,t,n){const r=t/n*Math.sqrt(Math.max(0,1-e*e));if(r>=1)return 1;const a=Math.sqrt(Math.max(0,1-r*r)),o=(n*e-t*a)/(n*e+t*a),c=(t*e-n*a)/(t*e+n*a);return(o*o+c*c)/2}}class Gt{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(Gt.ANCHOR_BLUE-Gt.ANCHOR_RED)/(1/(Gt.BLUE_NM*Gt.BLUE_NM)-1/(Gt.RED_NM*Gt.RED_NM));static A=Gt.ANCHOR_RED-Gt.B/(Gt.RED_NM*Gt.RED_NM);static indexAt(e){return Gt.A+Gt.B/(e*e)}}class er{static MAX_CHORDS=4;index=1.333;set refractiveIndex(e){this.index=e}trace(e,t){const n=Math.min(1,Math.max(0,e)),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=fo.reflectance(s,1,this.index);let h=0;t[h].chords=0,t[h].scatteringAngle=er.folded(Math.PI-2*o),t[h].weight=l,h++;const u=fo.reflectance(a,this.index,1);let d=1-l;for(let f=1;f<=er.MAX_CHORDS&&h<t.length;f++){const g=2*(o-c)+(f-1)*(Math.PI-2*c);t[h].chords=f,t[h].scatteringAngle=er.folded(g),t[h].weight=d*(1-u),h++,d*=u}return h}static folded(e){const t=2*Math.PI;let n=e%t;return n<0&&(n+=t),n>Math.PI?t-n:n}}class ln{static get WATER_INDEX_RED(){return Gt.indexAt(Gt.RED_NM)}static get WATER_INDEX_BLUE(){return Gt.indexAt(Gt.BLUE_NM)}static radiusDeg(e,t){const n=(t*t-1)/(e*e-1);if(n<0||n>1)return Number.NaN;const s=Math.acos(Math.sqrt(n)),r=Math.asin(Math.sin(s)/t),a=2*(s-r)+(e-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 ln.bowOf("primary",2,0)}static secondary(){return ln.bowOf("secondary",3,0)}static bowOf(e,t,n){const s=ln.radiusDeg(t,ln.WATER_INDEX_RED),r=ln.radiusDeg(t,ln.WATER_INDEX_BLUE),a=(s+r)/2;return{id:e,radiusDeg:a,redRadiusDeg:s,violetRadiusDeg:r,topAltitudeDeg:a-n}}static alexandersBandDeg(){return{fromDeg:ln.primary().redRadiusDeg,toDeg:ln.secondary().redRadiusDeg}}static formsAt(e){return e<0?[]:[ln.bowOf("primary",2,e),ln.bowOf("secondary",3,e)].filter(t=>t.topAltitudeDeg>0)}static FULL_MOON_MAGNITUDE=-12.7;static moonlightShare(e){return Math.min(1,10**(-.4*(e-ln.FULL_MOON_MAGNITUDE)))}static strength(e,t,n){if(n<=0)return 0;const s=Math.max(0,Math.min(1,e)),r=Math.max(0,1-Math.max(0,Math.min(1,t)));return s*r}}class gn{constructor(e){this.radius=e;const t=gn.SEGMENTS*gn.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const n=new Rt;n.setAttribute("position",new ut(this.positions,3)),n.setAttribute("color",new ut(this.colors,3)),n.setDrawRange(0,0),this.object=new je(n,new cs({vertexColors:!0,transparent:!0,blending:ni,depthWrite:!1,fog:!1,side:Ln})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=gn.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(gn.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(e,t,n){this.head=e&&tn(e.altitudeDeg,e.azimuthDeg,1),this.tip=t&&tn(t.altitudeDeg,t.azimuthDeg,1),this.brightness=n,this.rebuild()}rebuild(){const e=this.object.geometry,t=this.head,n=this.tip;if(!t||!n||this.brightness<=0){e.setDrawRange(0,0);return}const s=this.angleBetween(t,n);if(s<=0){e.setDrawRange(0,0);return}const r=s*gn.SPREAD_FRACTION*Math.PI/180,a=h=>this.scale(this.slerp(t,n,h),this.radius),o=h=>this.radius*(gn.HEAD_HALF_WIDTH_DEG*Math.PI/180+r*h),c=h=>this.brightness*(1-h)**gn.FADE_POWER;let l=0;for(let h=1;h<gn.POINTS;h++){const u=(h-1)/gn.SEGMENTS,d=h/gn.SEGMENTS;l=this.pushBand(l,a(u),a(d),o(u),o(d),c(u),c(d))}e.setDrawRange(0,l),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}pushBand(e,t,n,s,r,a,o){const c=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(n,t))));for(let l=0;l<gn.ACROSS-1;l++){const h=l-1,u=l,d=this.across(t,c,s,h),f=this.across(n,c,r,h),g=this.across(t,c,s,u),x=this.across(n,c,r,u),m=(p,A)=>p===0?A:0;e=this.push(e,d,m(h,a)),e=this.push(e,f,m(h,o)),e=this.push(e,g,m(u,a)),e=this.push(e,f,m(h,o)),e=this.push(e,x,m(u,o)),e=this.push(e,g,m(u,a))}return e}across(e,t,n,s){return{x:e.x+t.x*n*s,y:e.y+t.y*n*s,z:e.z+t.z*n*s}}push(e,t,n){const s=e*3;this.positions[s]=t.x,this.positions[s+1]=t.y,this.positions[s+2]=t.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,e+1}slerp(e,t,n){const s=this.angleBetweenRadians(e,t);if(s<1e-9)return e;const r=Math.sin(s),a=Math.sin((1-n)*s)/r,o=Math.sin(n*s)/r;return{x:e.x*a+t.x*o,y:e.y*a+t.y*o,z:e.z*a+t.z*o}}angleBetween(e,t){return this.angleBetweenRadians(e,t)*180/Math.PI}angleBetweenRadians(e,t){const n=e.x*t.x+e.y*t.y+e.z*t.z;return Math.acos(Math.min(1,Math.max(-1,n)))}scale(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}class on{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(on.ANCHOR_BLUE-on.ANCHOR_RED)/(1/(on.BLUE_NM*on.BLUE_NM)-1/(on.RED_NM*on.RED_NM));static A=on.ANCHOR_RED-on.B/(on.RED_NM*on.RED_NM);static indexAt(e){return on.A+on.B/(e*e)}}class Hr{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(e,t,n,s,r,a){let o=0,c=0,l=0;Math.abs(n)<.9?(o=-t,c=e,l=0):(o=0,c=-n,l=t);const h=Math.hypot(o,c,l)||1;o/=h,c/=h,l/=h;const u=t*l-n*c,d=n*o-e*l,f=e*c-t*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]=e,this.normals[19]=t,this.normals[20]=n,this.offsets[6]=x,this.normals[21]=-e,this.normals[22]=-t,this.normals[23]=-n,this.offsets[7]=x,this.radius=Math.hypot(g,x)}get aimRadius(){return this.radius}trace(e,t,n,s,r,a,o){let c=-t,l=e,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=t*h-n*l,f=n*c-e*h,g=e*l-t*c,x=c*s+d*r-e*this.radius*2,m=l*s+f*r-t*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 ie=this.normals[j*3],ue=this.normals[j*3+1],He=this.normals[j*3+2],Ke=ie*e+ue*t+He*n,Be=this.offsets[j]-(ie*x+ue*m+He*p);if(Ke>1e-9){const Y=Be/Ke;Y<M&&(M=Y)}else if(Ke<-1e-9){const Y=Be/Ke;Y>T&&(T=Y,A=j)}else if(Be<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],_=this.normals[A*3+2],E=-(b*e+R*t+_*n),C=fo.reflectance(E,1,a);o[y].x=e+2*E*b,o[y].y=t+2*E*R,o[y].z=n+2*E*_,o[y].weight=C,y++;const D=1/a,I=Math.sqrt(Math.max(0,1-D*D*(1-E*E)));let W=D*e+(D*E-I)*b,X=D*t+(D*E-I)*R,O=D*n+(D*E-I)*_,q=x+e*T,G=m+t*T,$=p+n*T,te=1-C;for(let j=0;j<Hr.MAX_BOUNCES&&te>Hr.MIN_WEIGHT;j++){let ie=-1,ue=1/0;for(let z=0;z<8;z++){const Ae=this.normals[z*3],Ce=this.normals[z*3+1],Te=this.normals[z*3+2],_e=Ae*W+Ce*X+Te*O;if(_e<=1e-9)continue;const Ie=(this.offsets[z]-(Ae*q+Ce*G+Te*$))/_e;Ie>1e-9&&Ie<ue&&(ue=Ie,ie=z)}if(ie<0)break;const He=this.normals[ie*3],Ke=this.normals[ie*3+1],Be=this.normals[ie*3+2],Y=He*W+Ke*X+Be*O,re=a*Math.sqrt(Math.max(0,1-Y*Y));if(q+=W*ue,G+=X*ue,$+=O*ue,re<1){const z=Math.sqrt(Math.max(0,1-re*re)),Ae=fo.reflectance(Y,a,1);if(o[y].x=a*W-(a*Y-z)*He,o[y].y=a*X-(a*Y-z)*Ke,o[y].z=a*O-(a*Y-z)*Be,o[y].weight=te*(1-Ae),y++,y>=o.length)return y;te*=Ae}const ne=2*Y;W-=ne*He,X-=ne*Ke,O-=ne*Be}return y}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class Nn{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=Nn.build(24);static build(e){const t=[];let n=0,s=0,r=0;for(let a=0;a<e;a++){const o=Nn.VIOLET_NM+(a+.5)/e*(Nn.DEEP_RED_NM-Nn.VIOLET_NM),[c,l,h]=Nn.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,t.push(u)}for(const a of t)a.r/=n,a.g/=s,a.b/=r;return t}static colourMatching(e){const t=(n,s,r)=>{const a=(e-n)/(e<n?s:r);return Math.exp(-.5*a*a)};return[1.056*t(599.8,37.9,31)+.362*t(442,16,26.7)-.065*t(501.1,20.4,26.2),.821*t(568.8,46.9,40.5)+.286*t(530.9,16.3,31.1),1.217*t(437,11.8,36)+.681*t(459,26,13.8)]}}class mt{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 Hr;emergent=Array.from({length:Hr.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(mt.AZIMUTH_BINS*mt.ALTITUDE_BINS*3);radiance=new Float32Array(mt.AZIMUTH_BINS*mt.ALTITUDE_BINS*3);scratch=new Float32Array(mt.AZIMUTH_BINS*mt.ALTITUDE_BINS*3);seed=1;spare=0;hasSpare=!1;altitude=0;tilt=0;alignment=0;traced=0;begin(e,t,n=2654435769){this.seed=n>>>0||1,this.hasSpare=!1,this.tally.fill(0),this.traced=0,this.altitude=e*Math.PI/180,this.alignment=Math.min(1,Math.max(0,t));const s=mt.WORST_TILT_DEG*(mt.BEST_TILT_DEG/mt.WORST_TILT_DEG)**this.alignment;this.tilt=s*Math.PI/180}trace(e){const t=mt.AZIMUTH_BINS,n=mt.ALTITUDE_BINS,s=this.tally,r=mt.SOURCE_RADIUS_DEG*Math.PI/180,a=Math.cos(mt.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let c=0;c<e;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=Nn.SAMPLES[this.random()*Nn.SAMPLES.length|0],b=this.crystal.trace(g,x,m,A,T,on.indexAt(y.wavelengthNm),this.emergent);for(let R=0;R<b;R++){const _=this.emergent[R],E=Math.hypot(_.x,_.y,_.z);if(E<1e-9||_.weight<=0)continue;const C=_.x/E,D=_.y/E,I=_.z/E;if(C*g+D*x+I*m>a)continue;const W=Math.asin(Math.max(-1,Math.min(1,-I))),X=Math.abs(Math.atan2(-D,-C)),O=Math.min(t-1,X/Math.PI*t|0),G=(Math.min(n-1,(W+Math.PI/2)/Math.PI*n|0)*t+O)*3,$=_.weight*M*Nn.SAMPLES.length;s[G]+=$*y.r,s[G+1]+=$*y.g,s[G+2]+=$*y.b}}this.traced+=e}get tracedRays(){return this.traced}harvest(){const e=mt.AZIMUTH_BINS,t=mt.ALTITUDE_BINS;return this.toRadiance(e,t),this.smooth(e,t),{width:e,height:t,data:this.radiance,sourceAltitudeDeg:this.altitude*180/Math.PI,alignment:this.alignment,rays:this.traced}}compute(e,t,n,s){return this.begin(e,t,s),this.trace(n),this.harvest()}toRadiance(e,t){const n=2*Math.PI/e,s=Math.max(1,this.traced),r=4*mt.REFERENCE_MICRONS*mt.REFERENCE_MICRONS;for(let a=0;a<t;a++){const o=Math.sin(a/t*Math.PI-Math.PI/2),c=Math.sin((a+1)/t*Math.PI-Math.PI/2),l=1/(n*(c-o)*s*r);for(let h=0;h<e;h++){const u=(a*e+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(e,t){const n=this.scratch,s=this.radiance;n.set(s);for(let a=0;a<t;a++){const o=a*e*3;for(let c=0;c<3;c++){let l=n[o+c];for(let h=0;h<e;h++){const u=o+h*3+c,d=h+1<e?n[u+3]:n[u];s[u]=(l+2*n[u]+d)/4,l=n[u]}}}n.set(s);const r=e*3;for(let a=0;a<t;a++){const o=a>0?-r:0,c=a+1<t?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 e=this.random();let t=0;for(const n of mt.POPULATIONS)if(t+=n.share,e<=t)return n;return mt.POPULATIONS[mt.POPULATIONS.length-1]}orient(e,t){const n=this.random()*2*Math.PI;let s=this.random()*2*Math.PI,r=0,a=0,o=1;switch(e.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(t);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(t);const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n),e.orientation==="parry"&&(s=Math.PI/2+this.gaussian()*t);break}}this.crystal.set(r,a,o,s,e.widthMicrons,e.lengthMicrons)}random(){this.seed=this.seed+1831565813>>>0;let e=this.seed;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}spreadAboutAnAxis(e){const t=1/Math.max(1e-6,e*e),n=Math.max(1e-12,this.random()),s=1+Math.log(n+(1-n)*Math.exp(-2*t))/t;return Math.max(-1,Math.min(1,s))}spreadAboutAPlane(e){for(let t=0;t<8;t++){const n=this.gaussian()*e;if(n>=-1&&n<=1)return n}return this.random()*2-1}gaussian(){if(this.hasSpare)return this.hasSpare=!1,this.spare;const e=Math.sqrt(-2*Math.log(Math.max(1e-12,this.random()))),t=2*Math.PI*this.random();return this.spare=e*Math.sin(t),this.hasSpare=!0,e*Math.cos(t)}}class Vn{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 mt;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;refining=!0;nextGlimpse=Vn.FIRST_GLIMPSE_RAYS;workHandle;onRepaint;constructor(){const e=mt.AZIMUTH_BINS,t=mt.ALTITUDE_BINS;this.texels=new Uint16Array(e*t*4),this.texture=new Mo(this.texels,e,t,hn,Qt),this.texture.minFilter=Et,this.texture.magFilter=Et,this.texture.wrapS=sn,this.texture.wrapT=sn,this.texture.needsUpdate=!0,this.material=new At({uniforms:{uSource:{value:new L(0,1,0)},uUp:{value:new L(0,1,0)},uStrength:{value:0},uTint:{value:new L(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uMap:{value:this.texture},uGain:{value:Vn.GAIN}},vertexShader:`
5454
+ `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new Qe(new $i(2,2),this.material))}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height)}setLens(e,t,n,s){const r=this.material.uniforms;r.uApertureMm2.value=e*e/Math.max(.1,t),r.uFocusDistance.value=Math.max(0,n),r.uFocalLengthMm.value=e,r.uPixelsPerMm.value=this.height/Math.max(.1,s)}setEncodesOutput(e){this.material.uniforms.uEncodeOutput.value=e?1:0}render(e,t,n){const s=this.material.uniforms;s.uNear.value=n.near,s.uFar.value=n.far;const r=e.getRenderTarget();e.setRenderTarget(this.target),e.clear(),e.render(t,n),e.setRenderTarget(r),e.render(this.quadScene,this.quadCamera)}dispose(){this.target.depthTexture?.dispose(),this.target.dispose(),this.material.dispose()}}class et{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 e=et.ICE_INDEX_RED,t=Math.sqrt((4-e*e)/3);return Math.asin(Math.min(1,t))*180/Math.PI}static minimumDeviationDeg(e,t){const n=e*Math.PI/180,s=t*Math.sin(n/2);return s>1?Number.NaN:(2*Math.asin(s)-n)*180/Math.PI}static effectiveIndex(e,t){const n=t*Math.PI/180,s=Math.cos(n);return s<=0?Number.POSITIVE_INFINITY:Math.sqrt(e*e-Math.sin(n)**2)/s}static parheliaAzimuthDeg(e,t=et.ICE_INDEX_RED){const n=et.minimumDeviationDeg(et.SIDE_PRISM_ANGLE_DEG,et.effectiveIndex(t,e));return Number.isFinite(n)?n:void 0}static parheliaDistanceDeg(e,t=et.ICE_INDEX_RED){const n=et.parheliaAzimuthDeg(e,t);if(n===void 0)return;const s=e*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 e=et.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(e*e-1)))*180/Math.PI}static circumzenithalAltitudeDeg(e,t=et.ICE_INDEX_RED){if(e<0||e>90-et.PLATE_END_FACE_LIMIT_DEG)return;const n=Math.cos(e*Math.PI/180),s=Math.sqrt(t*t-n*n);if(!(s>=1))return Math.asin(s)*180/Math.PI}static DECK_HEIGHT_M=8e3;static deckLitUntilDeg(e){return Math.acos(6371e3/(6371e3+Math.max(0,e)))*180/Math.PI}static halo22(){return et.ringOf("halo22",et.SIDE_PRISM_ANGLE_DEG)}static halo46(){return et.ringOf("halo46",et.END_PRISM_ANGLE_DEG)}static ringOf(e,t){const n=et.minimumDeviationDeg(t,et.ICE_INDEX_RED),s=et.minimumDeviationDeg(t,et.ICE_INDEX_BLUE);return{id:e,angleDeg:(n+s)/2,redAngleDeg:n,blueAngleDeg:s}}static strength(e,t,n=90,s=0){const r=Math.max(0,Math.min(1,e)),a=Math.max(0,1-Math.max(0,Math.min(1,t))),o=n>=0?1:s<=0?0:Math.max(0,1+n/s);return r*a*o}static formsAt(e,t=0){if(e<=-t)return[];const n=[et.halo22(),et.halo46()],s=e>0?et.parheliaDistanceDeg(e):void 0;s!==void 0&&n.push({id:"parhelia",angleDeg:s,redAngleDeg:s,blueAngleDeg:et.parheliaDistanceDeg(e,et.ICE_INDEX_BLUE)}),n.push({id:"tangentArc",angleDeg:et.halo22().angleDeg}),e>0&&n.push({id:"parhelicCircle",angleDeg:e});const r=et.circumzenithalAltitudeDeg(e);return r!==void 0&&n.push({id:"circumzenithal",angleDeg:r}),e>et.PLATE_END_FACE_LIMIT_DEG&&n.push({id:"circumhorizontal"}),e<et.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&n.push({id:"pillar"}),n}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class Go{static reflectance(e,t,n){const r=t/n*Math.sqrt(Math.max(0,1-e*e));if(r>=1)return 1;const a=Math.sqrt(Math.max(0,1-r*r)),o=(n*e-t*a)/(n*e+t*a),c=(t*e-n*a)/(t*e+n*a);return(o*o+c*c)/2}}class Vt{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(Vt.ANCHOR_BLUE-Vt.ANCHOR_RED)/(1/(Vt.BLUE_NM*Vt.BLUE_NM)-1/(Vt.RED_NM*Vt.RED_NM));static A=Vt.ANCHOR_RED-Vt.B/(Vt.RED_NM*Vt.RED_NM);static indexAt(e){return Vt.A+Vt.B/(e*e)}}class lr{static MAX_CHORDS=4;index=1.333;set refractiveIndex(e){this.index=e}trace(e,t){const n=Math.min(1,Math.max(0,e)),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=Go.reflectance(s,1,this.index);let h=0;t[h].chords=0,t[h].scatteringAngle=lr.folded(Math.PI-2*o),t[h].weight=l,h++;const u=Go.reflectance(a,this.index,1);let d=1-l;for(let f=1;f<=lr.MAX_CHORDS&&h<t.length;f++){const g=2*(o-c)+(f-1)*(Math.PI-2*c);t[h].chords=f,t[h].scatteringAngle=lr.folded(g),t[h].weight=d*(1-u),h++,d*=u}return h}static folded(e){const t=2*Math.PI;let n=e%t;return n<0&&(n+=t),n>Math.PI?t-n:n}}class un{static get WATER_INDEX_RED(){return Vt.indexAt(Vt.RED_NM)}static get WATER_INDEX_BLUE(){return Vt.indexAt(Vt.BLUE_NM)}static radiusDeg(e,t){const n=(t*t-1)/(e*e-1);if(n<0||n>1)return Number.NaN;const s=Math.acos(Math.sqrt(n)),r=Math.asin(Math.sin(s)/t),a=2*(s-r)+(e-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 un.bowOf("primary",2,0)}static secondary(){return un.bowOf("secondary",3,0)}static bowOf(e,t,n){const s=un.radiusDeg(t,un.WATER_INDEX_RED),r=un.radiusDeg(t,un.WATER_INDEX_BLUE),a=(s+r)/2;return{id:e,radiusDeg:a,redRadiusDeg:s,violetRadiusDeg:r,topAltitudeDeg:a-n}}static alexandersBandDeg(){return{fromDeg:un.primary().redRadiusDeg,toDeg:un.secondary().redRadiusDeg}}static formsAt(e){return e<0?[]:[un.bowOf("primary",2,e),un.bowOf("secondary",3,e)].filter(t=>t.topAltitudeDeg>0)}static FULL_MOON_MAGNITUDE=-12.7;static moonlightShare(e){return Math.min(1,10**(-.4*(e-un.FULL_MOON_MAGNITUDE)))}static strength(e,t,n){if(n<=0)return 0;const s=Math.max(0,Math.min(1,e)),r=Math.max(0,1-Math.max(0,Math.min(1,t)));return s*r}}class _n{constructor(e){this.radius=e;const t=_n.SEGMENTS*_n.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const n=new wt;n.setAttribute("position",new dt(this.positions,3)),n.setAttribute("color",new dt(this.colors,3)),n.setDrawRange(0,0),this.object=new Qe(n,new gs({vertexColors:!0,transparent:!0,blending:ai,depthWrite:!1,fog:!1,side:Fn})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=_n.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(_n.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(e,t,n){this.head=e&&nn(e.altitudeDeg,e.azimuthDeg,1),this.tip=t&&nn(t.altitudeDeg,t.azimuthDeg,1),this.brightness=n,this.rebuild()}rebuild(){const e=this.object.geometry,t=this.head,n=this.tip;if(!t||!n||this.brightness<=0){e.setDrawRange(0,0);return}const s=this.angleBetween(t,n);if(s<=0){e.setDrawRange(0,0);return}const r=s*_n.SPREAD_FRACTION*Math.PI/180,a=h=>this.scale(this.slerp(t,n,h),this.radius),o=h=>this.radius*(_n.HEAD_HALF_WIDTH_DEG*Math.PI/180+r*h),c=h=>this.brightness*(1-h)**_n.FADE_POWER;let l=0;for(let h=1;h<_n.POINTS;h++){const u=(h-1)/_n.SEGMENTS,d=h/_n.SEGMENTS;l=this.pushBand(l,a(u),a(d),o(u),o(d),c(u),c(d))}e.setDrawRange(0,l),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}pushBand(e,t,n,s,r,a,o){const c=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(n,t))));for(let l=0;l<_n.ACROSS-1;l++){const h=l-1,u=l,d=this.across(t,c,s,h),f=this.across(n,c,r,h),g=this.across(t,c,s,u),x=this.across(n,c,r,u),m=(p,b)=>p===0?b:0;e=this.push(e,d,m(h,a)),e=this.push(e,f,m(h,o)),e=this.push(e,g,m(u,a)),e=this.push(e,f,m(h,o)),e=this.push(e,x,m(u,o)),e=this.push(e,g,m(u,a))}return e}across(e,t,n,s){return{x:e.x+t.x*n*s,y:e.y+t.y*n*s,z:e.z+t.z*n*s}}push(e,t,n){const s=e*3;this.positions[s]=t.x,this.positions[s+1]=t.y,this.positions[s+2]=t.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,e+1}slerp(e,t,n){const s=this.angleBetweenRadians(e,t);if(s<1e-9)return e;const r=Math.sin(s),a=Math.sin((1-n)*s)/r,o=Math.sin(n*s)/r;return{x:e.x*a+t.x*o,y:e.y*a+t.y*o,z:e.z*a+t.z*o}}angleBetween(e,t){return this.angleBetweenRadians(e,t)*180/Math.PI}angleBetweenRadians(e,t){const n=e.x*t.x+e.y*t.y+e.z*t.z;return Math.acos(Math.min(1,Math.max(-1,n)))}scale(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}class ln{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(ln.ANCHOR_BLUE-ln.ANCHOR_RED)/(1/(ln.BLUE_NM*ln.BLUE_NM)-1/(ln.RED_NM*ln.RED_NM));static A=ln.ANCHOR_RED-ln.B/(ln.RED_NM*ln.RED_NM);static indexAt(e){return ln.A+ln.B/(e*e)}}class ra{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(e,t,n,s,r,a){let o=0,c=0,l=0;Math.abs(n)<.9?(o=-t,c=e,l=0):(o=0,c=-n,l=t);const h=Math.hypot(o,c,l)||1;o/=h,c/=h,l/=h;const u=t*l-n*c,d=n*o-e*l,f=e*c-t*o,g=r/2,x=a/2;for(let m=0;m<6;m++){const p=s+m*Math.PI/3,b=Math.cos(p),w=Math.sin(p);this.normals[m*3]=o*b+u*w,this.normals[m*3+1]=c*b+d*w,this.normals[m*3+2]=l*b+f*w,this.offsets[m]=g}this.normals[18]=e,this.normals[19]=t,this.normals[20]=n,this.offsets[6]=x,this.normals[21]=-e,this.normals[22]=-t,this.normals[23]=-n,this.offsets[7]=x,this.radius=Math.hypot(g,x)}get aimRadius(){return this.radius}trace(e,t,n,s,r,a,o){let c=-t,l=e,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=t*h-n*l,f=n*c-e*h,g=e*l-t*c,x=c*s+d*r-e*this.radius*2,m=l*s+f*r-t*this.radius*2,p=h*s+g*r-n*this.radius*2;let b=-1,w=-1/0,M=1/0;for(let j=0;j<8;j++){const ie=this.normals[j*3],ue=this.normals[j*3+1],He=this.normals[j*3+2],Ze=ie*e+ue*t+He*n,ke=this.offsets[j]-(ie*x+ue*m+He*p);if(Ze>1e-9){const Y=ke/Ze;Y<M&&(M=Y)}else if(Ze<-1e-9){const Y=ke/Ze;Y>w&&(w=Y,b=j)}else if(ke<0)return 0}if(b<0||w>=M)return 0;let S=0;const A=this.normals[b*3],R=this.normals[b*3+1],_=this.normals[b*3+2],E=-(A*e+R*t+_*n),C=Go.reflectance(E,1,a);o[S].x=e+2*E*A,o[S].y=t+2*E*R,o[S].z=n+2*E*_,o[S].weight=C,S++;const D=1/a,I=Math.sqrt(Math.max(0,1-D*D*(1-E*E)));let V=D*e+(D*E-I)*A,q=D*t+(D*E-I)*R,U=D*n+(D*E-I)*_,X=x+e*w,G=m+t*w,Z=p+n*w,te=1-C;for(let j=0;j<ra.MAX_BOUNCES&&te>ra.MIN_WEIGHT;j++){let ie=-1,ue=1/0;for(let z=0;z<8;z++){const be=this.normals[z*3],Pe=this.normals[z*3+1],Te=this.normals[z*3+2],xe=be*V+Pe*q+Te*U;if(xe<=1e-9)continue;const Ne=(this.offsets[z]-(be*X+Pe*G+Te*Z))/xe;Ne>1e-9&&Ne<ue&&(ue=Ne,ie=z)}if(ie<0)break;const He=this.normals[ie*3],Ze=this.normals[ie*3+1],ke=this.normals[ie*3+2],Y=He*V+Ze*q+ke*U,re=a*Math.sqrt(Math.max(0,1-Y*Y));if(X+=V*ue,G+=q*ue,Z+=U*ue,re<1){const z=Math.sqrt(Math.max(0,1-re*re)),be=Go.reflectance(Y,a,1);if(o[S].x=a*V-(a*Y-z)*He,o[S].y=a*q-(a*Y-z)*Ze,o[S].z=a*U-(a*Y-z)*ke,o[S].weight=te*(1-be),S++,S>=o.length)return S;te*=be}const ne=2*Y;V-=ne*He,q-=ne*Ze,U-=ne*ke}return S}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class Bn{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=Bn.build(24);static build(e){const t=[];let n=0,s=0,r=0;for(let a=0;a<e;a++){const o=Bn.VIOLET_NM+(a+.5)/e*(Bn.DEEP_RED_NM-Bn.VIOLET_NM),[c,l,h]=Bn.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,t.push(u)}for(const a of t)a.r/=n,a.g/=s,a.b/=r;return t}static colourMatching(e){const t=(n,s,r)=>{const a=(e-n)/(e<n?s:r);return Math.exp(-.5*a*a)};return[1.056*t(599.8,37.9,31)+.362*t(442,16,26.7)-.065*t(501.1,20.4,26.2),.821*t(568.8,46.9,40.5)+.286*t(530.9,16.3,31.1),1.217*t(437,11.8,36)+.681*t(459,26,13.8)]}}class vt{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 ra;emergent=Array.from({length:ra.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(vt.AZIMUTH_BINS*vt.ALTITUDE_BINS*3);radiance=new Float32Array(vt.AZIMUTH_BINS*vt.ALTITUDE_BINS*3);scratch=new Float32Array(vt.AZIMUTH_BINS*vt.ALTITUDE_BINS*3);seed=1;spare=0;hasSpare=!1;altitude=0;tilt=0;alignment=0;traced=0;begin(e,t,n=2654435769){this.seed=n>>>0||1,this.hasSpare=!1,this.tally.fill(0),this.traced=0,this.altitude=e*Math.PI/180,this.alignment=Math.min(1,Math.max(0,t));const s=vt.WORST_TILT_DEG*(vt.BEST_TILT_DEG/vt.WORST_TILT_DEG)**this.alignment;this.tilt=s*Math.PI/180}trace(e){const t=vt.AZIMUTH_BINS,n=vt.ALTITUDE_BINS,s=this.tally,r=vt.SOURCE_RADIUS_DEG*Math.PI/180,a=Math.cos(vt.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let c=0;c<e;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,b=(this.random()*2-1)*p,w=(this.random()*2-1)*p,M=4*p*p,S=Bn.SAMPLES[this.random()*Bn.SAMPLES.length|0],A=this.crystal.trace(g,x,m,b,w,ln.indexAt(S.wavelengthNm),this.emergent);for(let R=0;R<A;R++){const _=this.emergent[R],E=Math.hypot(_.x,_.y,_.z);if(E<1e-9||_.weight<=0)continue;const C=_.x/E,D=_.y/E,I=_.z/E;if(C*g+D*x+I*m>a)continue;const V=Math.asin(Math.max(-1,Math.min(1,-I))),q=Math.abs(Math.atan2(-D,-C)),U=Math.min(t-1,q/Math.PI*t|0),G=(Math.min(n-1,(V+Math.PI/2)/Math.PI*n|0)*t+U)*3,Z=_.weight*M*Bn.SAMPLES.length;s[G]+=Z*S.r,s[G+1]+=Z*S.g,s[G+2]+=Z*S.b}}this.traced+=e}get tracedRays(){return this.traced}harvest(){const e=vt.AZIMUTH_BINS,t=vt.ALTITUDE_BINS;return this.toRadiance(e,t),this.smooth(e,t),{width:e,height:t,data:this.radiance,sourceAltitudeDeg:this.altitude*180/Math.PI,alignment:this.alignment,rays:this.traced}}compute(e,t,n,s){return this.begin(e,t,s),this.trace(n),this.harvest()}toRadiance(e,t){const n=2*Math.PI/e,s=Math.max(1,this.traced),r=4*vt.REFERENCE_MICRONS*vt.REFERENCE_MICRONS;for(let a=0;a<t;a++){const o=Math.sin(a/t*Math.PI-Math.PI/2),c=Math.sin((a+1)/t*Math.PI-Math.PI/2),l=1/(n*(c-o)*s*r);for(let h=0;h<e;h++){const u=(a*e+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(e,t){const n=this.scratch,s=this.radiance;n.set(s);for(let a=0;a<t;a++){const o=a*e*3;for(let c=0;c<3;c++){let l=n[o+c];for(let h=0;h<e;h++){const u=o+h*3+c,d=h+1<e?n[u+3]:n[u];s[u]=(l+2*n[u]+d)/4,l=n[u]}}}n.set(s);const r=e*3;for(let a=0;a<t;a++){const o=a>0?-r:0,c=a+1<t?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 e=this.random();let t=0;for(const n of vt.POPULATIONS)if(t+=n.share,e<=t)return n;return vt.POPULATIONS[vt.POPULATIONS.length-1]}orient(e,t){const n=this.random()*2*Math.PI;let s=this.random()*2*Math.PI,r=0,a=0,o=1;switch(e.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(t);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(t);const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n),e.orientation==="parry"&&(s=Math.PI/2+this.gaussian()*t);break}}this.crystal.set(r,a,o,s,e.widthMicrons,e.lengthMicrons)}random(){this.seed=this.seed+1831565813>>>0;let e=this.seed;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}spreadAboutAnAxis(e){const t=1/Math.max(1e-6,e*e),n=Math.max(1e-12,this.random()),s=1+Math.log(n+(1-n)*Math.exp(-2*t))/t;return Math.max(-1,Math.min(1,s))}spreadAboutAPlane(e){for(let t=0;t<8;t++){const n=this.gaussian()*e;if(n>=-1&&n<=1)return n}return this.random()*2-1}gaussian(){if(this.hasSpare)return this.hasSpare=!1,this.spare;const e=Math.sqrt(-2*Math.log(Math.max(1e-12,this.random()))),t=2*Math.PI*this.random();return this.spare=e*Math.sin(t),this.hasSpare=!0,e*Math.cos(t)}}class $n{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 vt;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;refining=!0;nextGlimpse=$n.FIRST_GLIMPSE_RAYS;workHandle;onRepaint;constructor(){const e=vt.AZIMUTH_BINS,t=vt.ALTITUDE_BINS;this.texels=new Uint16Array(e*t*4),this.texture=new gr(this.texels,e,t,an,jt),this.texture.minFilter=At,this.texture.magFilter=At,this.texture.wrapS=rn,this.texture.wrapT=rn,this.texture.needsUpdate=!0,this.material=new Tt({uniforms:{uSource:{value:new P(0,1,0)},uUp:{value:new P(0,1,0)},uStrength:{value:0},uTint:{value:new P(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uMap:{value:this.texture},uGain:{value:$n.GAIN}},vertexShader:`
5455
5455
  varying vec3 vDirection;
5456
5456
  void main() {
5457
5457
  vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
@@ -5459,8 +5459,8 @@ void main()
5459
5459
  }
5460
5460
  `,fragmentShader:`
5461
5461
  precision highp float;
5462
- ${vf}
5463
- ${eM}
5462
+ ${Pp}
5463
+ ${oS}
5464
5464
  varying vec3 vDirection;
5465
5465
  uniform vec3 uSource;
5466
5466
  uniform vec3 uUp;
@@ -5501,7 +5501,7 @@ void main()
5501
5501
  // display fades at the edge of a fibre instead of ending on a cut line.
5502
5502
  gl_FragColor = vec4(light * uStrength * (0.25 + 0.75 * ice), 1.0);
5503
5503
  }
5504
- `,transparent:!0,blending:ni,depthWrite:!1,side:It,fog:!1}),this.object=new je(new wn(Vn.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}set onReady(e){this.onRepaint=e}update(e,t,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(e.x,e.y,e.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(t,a)}requestMap(e,t){!(!(Math.abs(e-this.mappedAltitudeDeg)<Vn.ALTITUDE_STEP_DEG)||t!==this.mappedAlignment)||this.tracingFor(e,t)||(this.pendingAltitudeDeg=e,this.pendingAlignment=t,this.sky.begin(e,t),this.tracing=!0,this.nextGlimpse=Vn.FIRST_GLIMPSE_RAYS,this.scheduleWork())}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;tracingFor(e,t){return this.tracing&&Math.abs(e-this.pendingAltitudeDeg)<Vn.ALTITUDE_STEP_DEG&&t===this.pendingAlignment}scheduleWork(){if(this.workHandle!==void 0)return;const e=()=>{if(this.workHandle=void 0,!this.tracing)return;this.sky.trace(Vn.RAYS_PER_FRAME);const t=this.sky.tracedRays>=Vn.RAYS,n=this.refining&&this.sky.tracedRays>=this.nextGlimpse;if(n&&(this.nextGlimpse*=2),(t||n)&&this.publish(),t){this.tracing=!1,this.refining=!1,this.mappedAltitudeDeg=this.pendingAltitudeDeg,this.mappedAlignment=this.pendingAlignment;return}this.workHandle=requestAnimationFrame(e)};this.workHandle=requestAnimationFrame(e)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0,this.tracing=!1}publish(){const t=this.sky.harvest().data;for(let n=0,s=0;s<t.length;n+=4,s+=3)this.texels[n]=Ui.toHalfFloat(t[s]),this.texels[n+1]=Ui.toHalfFloat(t[s+1]),this.texels[n+2]=Ui.toHalfFloat(t[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 wt{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new er;previous=wt.emergences();current=wt.emergences();tally=new Float32Array(wt.BINS*3);radiance=new Float32Array(wt.BINS*3);scratch=new Float32Array(wt.BINS*3);static emergences(){return Array.from({length:er.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const e of Nn.SAMPLES)this.sweep(e);return this.toRadiance(),this.blurBySourceDisc(),{bins:wt.BINS,data:this.radiance,binDeg:180/wt.BINS}}sweep(e){this.drop.refractiveIndex=Gt.indexAt(e.wavelengthNm);const t=wt.IMPACT_STEPS;let n=this.drop.trace(0,this.previous);const s=1/t;for(let r=1;r<=t;r++){const a=this.drop.trace(Math.sqrt(r/t),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,e)}n=a,this.copyInto(this.current,this.previous)}}copyInto(e,t){for(let n=0;n<e.length;n++)t[n].chords=e[n].chords,t[n].scatteringAngle=e[n].scatteringAngle,t[n].weight=e[n].weight}deposit(e,t,n,s){if(n<=0)return;const r=wt.BINS,a=Math.PI/r,o=Math.min(e,t),c=Math.max(e,t),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(e,t,n){const s=e*3,r=t*Nn.SAMPLES.length;this.tally[s]+=r*n.r,this.tally[s+1]+=r*n.g,this.tally[s+2]+=r*n.b}toRadiance(){const e=wt.BINS,t=Math.PI/e;for(let n=0;n<e;n++){const s=2*Math.PI*(Math.cos(n*t)-Math.cos((n+1)*t)),r=s>0?this.backwardShare((n+.5)*(180/e))/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(e){const t=180-e;if(t<=wt.FULL_UNTIL_DEG)return 1;if(t>=wt.FADED_BY_DEG)return 0;const n=(t-wt.FULL_UNTIL_DEG)/(wt.FADED_BY_DEG-wt.FULL_UNTIL_DEG);return Math.cos(n*Math.PI/2)**2}blurBySourceDisc(){const e=wt.BINS,t=wt.SOURCE_RADIUS_DEG*e/180,n=Math.max(1,Math.ceil(t)),s=[];let r=0;for(let a=-n;a<=n;a++){const o=Math.max(0,t*t-a*a),c=Math.sqrt(o);s.push(c),r+=c}if(!(r<=0)){this.scratch.set(this.radiance);for(let a=0;a<e;a++){let o=0,c=0,l=0;for(let u=-n;u<=n;u++){const d=Math.min(e-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 Ir{static RADIUS=880;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new wt;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(wt.BINS*4),this.texture=new Mo(this.texels,wt.BINS,1,hn,Qt),this.texture.minFilter=Et,this.texture.magFilter=Et,this.texture.wrapS=sn,this.texture.wrapT=sn,this.texture.needsUpdate=!0,this.material=new At({uniforms:{uSource:{value:new L(0,1,0)},uStrength:{value:0},uTint:{value:new L(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:Ir.GAIN}},vertexShader:`
5504
+ `,transparent:!0,blending:ai,depthWrite:!1,side:Ut,fog:!1}),this.object=new Qe(new Pn($n.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}set onReady(e){this.onRepaint=e}update(e,t,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(e.x,e.y,e.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(t,a)}requestMap(e,t){!(!(Math.abs(e-this.mappedAltitudeDeg)<$n.ALTITUDE_STEP_DEG)||t!==this.mappedAlignment)||this.tracingFor(e,t)||(this.pendingAltitudeDeg=e,this.pendingAlignment=t,this.sky.begin(e,t),this.tracing=!0,this.nextGlimpse=$n.FIRST_GLIMPSE_RAYS,this.scheduleWork())}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;tracingFor(e,t){return this.tracing&&Math.abs(e-this.pendingAltitudeDeg)<$n.ALTITUDE_STEP_DEG&&t===this.pendingAlignment}scheduleWork(){if(this.workHandle!==void 0)return;const e=()=>{if(this.workHandle=void 0,!this.tracing)return;this.sky.trace($n.RAYS_PER_FRAME);const t=this.sky.tracedRays>=$n.RAYS,n=this.refining&&this.sky.tracedRays>=this.nextGlimpse;if(n&&(this.nextGlimpse*=2),(t||n)&&this.publish(),t){this.tracing=!1,this.refining=!1,this.mappedAltitudeDeg=this.pendingAltitudeDeg,this.mappedAlignment=this.pendingAlignment;return}this.workHandle=requestAnimationFrame(e)};this.workHandle=requestAnimationFrame(e)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0,this.tracing=!1}publish(){const t=this.sky.harvest().data;for(let n=0,s=0;s<t.length;n+=4,s+=3)this.texels[n]=Wi.toHalfFloat(t[s]),this.texels[n+1]=Wi.toHalfFloat(t[s+1]),this.texels[n+2]=Wi.toHalfFloat(t[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 Ct{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new lr;previous=Ct.emergences();current=Ct.emergences();tally=new Float32Array(Ct.BINS*3);radiance=new Float32Array(Ct.BINS*3);scratch=new Float32Array(Ct.BINS*3);static emergences(){return Array.from({length:lr.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const e of Bn.SAMPLES)this.sweep(e);return this.toRadiance(),this.blurBySourceDisc(),{bins:Ct.BINS,data:this.radiance,binDeg:180/Ct.BINS}}sweep(e){this.drop.refractiveIndex=Vt.indexAt(e.wavelengthNm);const t=Ct.IMPACT_STEPS;let n=this.drop.trace(0,this.previous);const s=1/t;for(let r=1;r<=t;r++){const a=this.drop.trace(Math.sqrt(r/t),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,e)}n=a,this.copyInto(this.current,this.previous)}}copyInto(e,t){for(let n=0;n<e.length;n++)t[n].chords=e[n].chords,t[n].scatteringAngle=e[n].scatteringAngle,t[n].weight=e[n].weight}deposit(e,t,n,s){if(n<=0)return;const r=Ct.BINS,a=Math.PI/r,o=Math.min(e,t),c=Math.max(e,t),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(e,t,n){const s=e*3,r=t*Bn.SAMPLES.length;this.tally[s]+=r*n.r,this.tally[s+1]+=r*n.g,this.tally[s+2]+=r*n.b}toRadiance(){const e=Ct.BINS,t=Math.PI/e;for(let n=0;n<e;n++){const s=2*Math.PI*(Math.cos(n*t)-Math.cos((n+1)*t)),r=s>0?this.backwardShare((n+.5)*(180/e))/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(e){const t=180-e;if(t<=Ct.FULL_UNTIL_DEG)return 1;if(t>=Ct.FADED_BY_DEG)return 0;const n=(t-Ct.FULL_UNTIL_DEG)/(Ct.FADED_BY_DEG-Ct.FULL_UNTIL_DEG);return Math.cos(n*Math.PI/2)**2}blurBySourceDisc(){const e=Ct.BINS,t=Ct.SOURCE_RADIUS_DEG*e/180,n=Math.max(1,Math.ceil(t)),s=[];let r=0;for(let a=-n;a<=n;a++){const o=Math.max(0,t*t-a*a),c=Math.sqrt(o);s.push(c),r+=c}if(!(r<=0)){this.scratch.set(this.radiance);for(let a=0;a<e;a++){let o=0,c=0,l=0;for(let u=-n;u<=n;u++){const d=Math.min(e-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 Zr{static RADIUS=880;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new Ct;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(Ct.BINS*4),this.texture=new gr(this.texels,Ct.BINS,1,an,jt),this.texture.minFilter=At,this.texture.magFilter=At,this.texture.wrapS=rn,this.texture.wrapT=rn,this.texture.needsUpdate=!0,this.material=new Tt({uniforms:{uSource:{value:new P(0,1,0)},uStrength:{value:0},uTint:{value:new P(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:Zr.GAIN}},vertexShader:`
5505
5505
  varying vec3 vDirection;
5506
5506
  void main() {
5507
5507
  vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
@@ -5529,7 +5529,7 @@ void main()
5529
5529
  light = mix(vec3(grey), light, uSaturation);
5530
5530
  gl_FragColor = vec4(light * uStrength, 1.0);
5531
5531
  }
5532
- `,transparent:!0,blending:ni,depthWrite:!1,side:It,fog:!1}),this.object=new je(new wn(Ir.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}update(e,t,n,s){const r=this.material.uniforms;if(t<=0){r.uStrength.value=0,this.object.visible=!1;return}this.computed||this.publish(),r.uSource.value.set(e.x,e.y,e.z).normalize(),r.uStrength.value=t,r.uTint.value.set(n[0],n[1],n[2]),r.uSaturation.value=s?1:Ir.MOON_SATURATION,this.object.visible=!0}publish(){const t=this.sky.compute().data;for(let n=0,s=0;s<t.length;n+=4,s+=3)this.texels[n]=Ui.toHalfFloat(t[s]),this.texels[n+1]=Ui.toHalfFloat(t[s+1]),this.texels[n+2]=Ui.toHalfFloat(t[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 _f{constructor(e){this.state=e}next(){this.state=this.state+1831565813|0;let e=this.state;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}between(e,t){return e+this.next()*(t-e)}}class rs{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(e){const{ratePerHour:t,durationMs:n,velocityKmS:s,seed:r}=e;if(t<=0||n<=0)return[];const a=t*n/36e5,o=new _f(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=rs.MAX_DURATION_MS-d*(rs.MAX_DURATION_MS-rs.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(e,t){return e.filter(n=>t>=n.t&&t<=n.t+n.durationMs).map(n=>({meteor:n,progress:(t-n.t)/n.durationMs}))}}class kt{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=kt.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(kt.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 e=kt.MAX_CONCURRENT*kt.SEGMENTS*kt.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const t=new Rt;t.setAttribute("position",new ut(this.positions,3)),t.setAttribute("color",new ut(this.colors,3)),t.setDrawRange(0,0),this.object=new je(t,new cs({vertexColors:!0,transparent:!0,blending:ni,depthWrite:!1,fog:!1,side:Ln})),this.object.frustumCulled=!1}get schedule(){return this.meteors}setShower(e,t,n){this.meteors=e,this.radiantAltitudeDeg=t,this.radiantAzimuthDeg=n}update(e){const t=this.object.geometry;if(this.meteors.length===0){t.setDrawRange(0,0);return}const n=rs.aliveAt(this.meteors,e).slice(0,kt.MAX_CONCURRENT);let s=0;for(const{meteor:r,progress:a}of n){const o=this.radiantOf(r);if(!o)continue;const c=tn(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=>kt.RADIUS*((kt.MIN_HALF_WIDTH_DEG+kt.BRIGHT_HALF_WIDTH_DEG*r.brightness*T)*Math.PI/180);for(let T=1;T<kt.POINTS;T++){const M=(T-1)/kt.SEGMENTS,y=T/kt.SEGMENTS;s=this.pushRibbon(s,p(M),p(y),A(M),A(y),m(M),m(y))}}t.setDrawRange(0,s),t.getAttribute("position").needsUpdate=!0,t.getAttribute("color").needsUpdate=!0}midpointOf(e){const t=this.radiantOf(e);if(!t)return;const n=tn(t.altitudeDeg,t.azimuthDeg,1),[s,r]=this.basisAround(n),a=this.turn(s,r,e.bearingDeg),o=this.onSphere(n,a,e.fromRadiantDeg+e.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(e){return e.radiant?e.radiant:this.radiantAltitudeDeg>0?{altitudeDeg:this.radiantAltitudeDeg,azimuthDeg:this.radiantAzimuthDeg}:void 0}pushRibbon(e,t,n,s,r,a,o){const c=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(n,t))));for(let l=0;l<kt.ACROSS-1;l++){const h=l-1,u=l,d=this.across(t,c,s,h),f=this.across(n,c,r,h),g=this.across(t,c,s,u),x=this.across(n,c,r,u),m=(p,A)=>p===0?A:0;e=this.push(e,d,m(h,a)),e=this.push(e,f,m(h,o)),e=this.push(e,g,m(u,a)),e=this.push(e,f,m(h,o)),e=this.push(e,x,m(u,o)),e=this.push(e,g,m(u,a))}return e}across(e,t,n,s){return{x:e.x+t.x*n*s,y:e.y+t.y*n*s,z:e.z+t.z*n*s}}push(e,t,n){const s=e*3;this.positions[s]=t.x,this.positions[s+1]=t.y,this.positions[s+2]=t.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,e+1}turn(e,t,n){const s=n*Math.PI/180,r=Math.cos(s),a=Math.sin(s);return{x:e.x*r+t.x*a,y:e.y*r+t.y*a,z:e.z*r+t.z*a}}onSphere(e,t,n){const s=n*Math.PI/180,r=Math.cos(s),a=Math.sin(s);return{x:(e.x*r+t.x*a)*kt.RADIUS,y:(e.y*r+t.y*a)*kt.RADIUS,z:(e.z*r+t.z*a)*kt.RADIUS}}basisAround(e){const t=Math.abs(e.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=this.normalise(this.cross(e,t));return[n,this.normalise(this.cross(e,n))]}subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}const oM=2;function cM(i){return i==="building"||i==="vehicle"}function lM(i,e){const t=i.litKeyframes;if(!t||t.length===0)return i.lit??!1;let n=t[0];for(const s of t){if(s.t>e)break;n=s}return n.lit}function hM(i,e){return i.pattern.kind==="steady"?!0:xf(i,e,e+1)>.5}function xf(i,e,t){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=e/o+r,l=t/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 Mf(i,e){const t=i.track,n={eastM:i.eastM,northM:i.northM,altitudeM:0,headingDeg:i.headingDeg};if(!t||t.length===0)return n;if(t.length===1||e<=t[0].t)return xd(t[0],i);const s=t[t.length-1];if(e>=s.t)return xd(s,i);for(let r=0;r<t.length-1;r++){const a=t[r],o=t[r+1];if(e<a.t||e>o.t)continue;const c=o.t-a.t,l=c===0?0:(e-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 xd(i,e){return{eastM:i.eastM,northM:i.northM,altitudeM:i.altitudeM??0,headingDeg:i.headingDeg??e.headingDeg}}const Md=Math.PI/180;function $t(i,e,t,n,s=!1){const r=s?new cs({color:new Me(...t)}):new Gr({color:new Me(...t)}),a=new je(e,r);return a.position.y=n,a.userData={emissive:s},a.castShadow=!s,a.receiveShadow=!s,i.add(a),a}const Sd=.25,uM=.002,dM=20;function fM(i){const e=/^#([0-9a-f]{6})$/i.exec(i);if(!e)return[1,1,1];const t=parseInt(e[1],16);return[(t>>16&255)/255,(t>>8&255)/255,(t&255)/255]}const Sf=[.32,.32,.3],yf=[1,.85,.5],Ef=[.25,.25,.25],Af=[1,.97,.85],pM=[.55,.68,.72],Xn=.03,qn=.05,bf={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 nn(i,e){return i?.[e]}function Yn(i,e,t,n,s,r,a,o){if(o===void 0)return;const c=new Gr({color:new Me(...pM),transparent:!0,opacity:o/100}),l=new je(new Tn(e,t,n),c);l.position.set(s,r,a),i.add(l)}const En=.05,Mc=[.6,.58,.53],yd=[.5,.5,.48];function qs(i,e,t,n,s,r,a,o){const c=new Gr({color:new Me(...o),side:It}),l=new je(new Tn(e,t,n),c);l.position.set(s,r,a),i.add(l)}function mM(i,e,t,n,s,r,a,o,c){const l=(n-r)/2,h=(g,x,m,p)=>{g<=0||(e?qs(i,g,x,En,m,o+p,a,c):qs(i,En,x,g,a,o+p,m,c))};h(t,l,0,n/2-l/2),h(t,l,0,-(n/2-l/2));const u=[...s].sort((g,x)=>g.center-x.center);let d=-t/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=t/2-d;h(f,r,d+f/2,0)}function Tf(i,e,t,n,s,r,a,o,c,l){const h=(n+s)/2,u=s-n,d=(f,g,x,m)=>{f.length===0?g?qs(i,x,u,En,0,h,m,Mc):qs(i,En,u,x,m,h,0,Mc):mM(i,g,x,u,f,r,m,h,Mc)};d(a,!0,e*2,-t+En),d(o,!0,e*2,t-En),d(c,!1,t*2,-e+En),d(l,!1,t*2,e-En),qs(i,e*2,En,t*2,0,n+En,0,yd),qs(i,e*2,En,t*2,0,s-En,0,yd)}function Zl(i,e,t,n){switch(i){case"front":return{x:0,z:-(t-n)};case"behind":return{x:0,z:t-n};case"left":return{x:-(e-n),z:0};case"right":return{x:e-n,z:0};case"front-left":return{x:-(e-n),z:-Kn};case"front-right":return{x:e-n,z:-Kn};case"behind-left":return{x:-(e-n),z:Kn};case"behind-right":return{x:e-n,z:Kn}}}function wf(i,e,t,n,s,r,a){const o=Cf();o.scale.setScalar(n),o.rotation.y=bf[e];const{x:c,z:l}=Zl(e,s,r,a);o.position.set(c,t,l),i.add(o)}const $l=6,Jl=6,Ci=3,Mr=1.4,Sr=Ci*.5,Rf=1.2,Df=.35,gM=.75,vM=1.6;function _M(i,e,t,n){const s=new Un,r=Math.max(1,i+1),a=r*Ci;$t(s,new Tn($l,a,Jl),[.55,.54,.5],a/2);const o=$l/2,c=Jl/2;for(let l=0;l<r;l++){const h=l*Ci+Ci/2;Yn(s,Mr,Sr,qn,0,h,-c-Xn,nn(e,"front")),Yn(s,Mr,Sr,qn,0,h,c+Xn,nn(e,"behind")),Yn(s,qn,Sr,Mr,-o-Xn,h,0,nn(e,"left")),Yn(s,qn,Sr,Mr,o+Xn,h,0,nn(e,"right"))}if(t){const l=Math.min(Math.max(n??0,0),r-1);wf(s,t,l*Ci,.72,o,c,Rf);const h=u=>nn(e,u)!==void 0?[{main:Mr,center:0}]:[];Tf(s,o,c,l*Ci,(l+1)*Ci,Sr,h("front"),h("behind"),h("left"),h("right"))}return s}function xM(){const i=new Un;return $t(i,new Hi(.15,.22,2,8),[.32,.22,.14],1),$t(i,new So(1.4,3,8),[.16,.32,.14],3.5),i}function MM(i){const e=new Un;return $t(e,new Hi(.05,.08,5,8),[.28,.28,.3],2.5),$t(e,new wn(.25,12,8),i?yf:Sf,5.1,!0),e}const SM=[.08,.08,.08],Di=.8,ks=1,Gn=1.7,Sc=.6,Ki=.4,Na=1.2,zs=.7,Kn=.5,yM=Gn;function EM(i,e,t){const n=new Un;$t(n,new Tn(1.8,1.4,4.2),[.45,.14,.14],.7),$t(n,new Tn(Di*2,Sc,ks*2),[.4,.12,.12],Gn);for(const r of[-1.4,1.4])for(const a of[-.95,.95]){const o=$t(n,new Hi(.4,.4,.3,12),SM,.4);o.rotation.z=Math.PI/2,o.position.x=a,o.position.z=r}const s=i?Af:Ef;for(const r of[-.7,.7])$t(n,new wn(.15,8,6),s,.7,!0).position.set(r,.7,-2.1);if(Yn(n,Na,Ki,qn,0,Gn,-ks-Xn,nn(e,"front")),Yn(n,Na,Ki,qn,0,Gn,ks+Xn,nn(e,"behind")),Yn(n,qn,Ki,zs,-Di-Xn,Gn,-Kn,nn(e,"front-left")),Yn(n,qn,Ki,zs,-Di-Xn,Gn,Kn,nn(e,"behind-left")),Yn(n,qn,Ki,zs,Di+Xn,Gn,-Kn,nn(e,"front-right")),Yn(n,qn,Ki,zs,Di+Xn,Gn,Kn,nn(e,"behind-right")),t){wf(n,t,gM,.5,Di,ks,Df);const r=(c,l)=>{const h=[];return nn(e,c)!==void 0&&h.push({main:zs,center:-Kn}),nn(e,l)!==void 0&&h.push({main:zs,center:Kn}),h},a=nn(e,"front")!==void 0?[{main:Na,center:0}]:[],o=nn(e,"behind")!==void 0?[{main:Na,center:0}]:[];Tf(n,Di,ks,Gn-Sc/2,Gn+Sc/2,Ki,a,o,r("front-left","behind-left"),r("front-right","behind-right"))}return n}const AM=[.95,.9,.82];function Cf(){const i=new Un;$t(i,new Hi(.25,.3,1.5,10),[.3,.3,.35],.75),$t(i,new wn(.22,10,8),[.62,.52,.46],1.72);const e=$t(i,new So(.07,.16,8),AM,1.72);return e.rotation.x=-Math.PI/2,e.position.z=-.2,i}const bM=17,Ed=18.5,yc=[.16,.16,.18];function TM(){const i=new Un,e=$t(i,new Hi(1.8,1.8,Ed*2,10),yc,0);e.rotation.x=Math.PI/2,$t(i,new Tn(bM*2,.5,4.5),yc,0);const t=$t(i,new Tn(.4,5.5,4),yc,3);return t.position.z=-Ed+2,i}class Bs{static occupantView(e){const t=e.witnessSide;if(!t)throw new Error("occupantView requires object.witnessSide to be set");const{x:n,z:s}=e.kind==="vehicle"?Zl(t,Di,ks,Df):Zl(t,$l/2,Jl/2,Rf),r=e.kind==="vehicle"?yM:(e.occupiedFloor??0)*Ci+vM,a=(e.headingDeg??0)-bf[t]/Md;return{x:n,z:s,eyeY:r,headingDeg:a}}static build(e,t){const n=e.kind==="building"?_M(e.floors??oM,e.windows,e.witnessSide,e.occupiedFloor):e.kind==="tree"?xM():e.kind==="streetlight"?MM(t):e.kind==="vehicle"?EM(t,e.windows,e.witnessSide):e.kind==="aircraft"?TM():Cf();return e.headingDeg!==void 0&&(n.rotation.y=-e.headingDeg*Md),this.addLights(n,e.lights),e.kind==="aircraft"&&this.exemptFromFog(n),n}static exemptFromFog(e){for(const t of e.children){if(!(t instanceof je))continue;const n=t.material;n.fog=!1,n.needsUpdate=!0}}static addLights(e,t){for(const n of t??[]){const s=fM(n.color),r=$t(e,new wn(Sd,8,6),s,n.offsetM.y,!0);r.position.set(n.offsetM.x,n.offsetM.y,n.offsetM.z),r.userData={emissive:!0,lightId:n.id,lightColor:s},r.visible=!1}}static setLights(e,t,n,s,r=0){if(!t||t.length===0)return;const a=new Map(t.map(c=>[c.id,c])),o=Math.max(1,s*uM/Sd);for(const c of e.children){if(!(c instanceof je))continue;const l=c.userData.lightId;if(!l)continue;const h=a.get(l);if(!h)continue;const u=r>0?xf(h,n,n+r):hM(h,n)?1:0;c.visible=u>0;const d=c.material,f=c.userData.lightColor;if(f){const g=r>0?u*dM*(h.intensity??1):u;d.color.setRGB(f[0]*g,f[1]*g,f[2]*g)}c.scale.setScalar(o)}}static setLit(e,t,n){const s=t==="streetlight"?n?yf:Sf:n?Af:Ef;for(const r of e.children){const a=r.userData;!(r instanceof je)||!a.emissive||a.lightId||r.material.color.setRGB(...s)}}static dispose(e){for(const t of e.children)t instanceof je&&(t.geometry.dispose(),t.material.dispose())}}function wM(i,e){return i.cloudCover===e.cloudCover&&i.cloudDarkness===e.cloudDarkness&&i.cloudBaseM===e.cloudBaseM&&i.highCloudCover===e.highCloudCover&&i.iceCrystalAlignment===e.iceCrystalAlignment&&i.lowerCloudCover===e.lowerCloudCover&&i.precipitationType===e.precipitationType&&i.precipitationIntensity===e.precipitationIntensity&&i.windDirectionDeg===e.windDirectionDeg&&i.windSpeed===e.windSpeed&&i.storm===e.storm}const Ua=900,Ec=.5,Rr=900,RM=6371e3,DM=3e4;function Ad(i){const e=Math.sqrt(2*RM*Math.max(i,0));return Math.max(Rr,Math.min(e,DM))}const Ac=.5,bd=850,CM=.03,Oa=850,bc=4,Td=1.5,wd=-1,PM=6,Ql=-4,Rd=.2,Fa=2600,IM=.97,LM=.38,Dd=Ql,NM=3,UM=.15,OM=.6,FM=40,zM=30,BM=[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"]},kM=["en","fr"],GM=880,Tc=40,VM=60,WM=10,XM=1,qM=150,YM=55,KM=.5,ZM=2.05,Cd=.265,Pd=[[0,0],...Array.from({length:8},(i,e)=>{const t=e*Math.PI/4;return[Math.cos(t)*Cd,Math.sin(t)*Cd]})],Id=700,$M=250/t0,JM=12,Ld=5,wc=6,Zi=[.92,.92,.95],Rc=[.15,.15,.19],Nd={snow:{fallSpeedMPerS:2,size:.3,color:new Me(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new Me(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},Gs=0,QM=0,Ud=3e3,yr=20,jM=15,Od=Gs,eS=40,Fd=1,tS=9;function zd(i){return Fd+(tS-Fd)*i}const nS=new Me(.75,.82,.92),iS=10,sS=.5;function rS(i){return Pf(i/iS,sS,1)}const Hs=200,Bd=.18,Hd=.32,aS=.35,oS=new Me(.85,.9,.98),kd=5,Gd=.85,Vd=.01;function Dc(i,e){return Math.round(i*(Vd+(1-Vd)*e))}const Wd=230,Xd=.7,qd=.05,cS=.6,lS=.7,hS=.15,Yd=.35,uS=3,dS=1/12,fS=.5,Kd=8,Zd=25,$d=.12,pS={Venus:new Me(1,.96,.85),Mars:new Me(1,.55,.4),Jupiter:new Me(.95,.87,.72),Saturn:new Me(.92,.86,.68)};class hi{renderer;scene=new _o;camera;celestialGroup=new Un;skyMesh;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;celestialLight=new $m(16777215,0);celestialLightTarget=new Lt;skyLight=new qm(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;raycaster=new rc;weather=n0;observerElevationM=0;groundRadius=Rr;terrainRadius=Rr;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new L;rainLastVerticalFacing=-1;rainViewportSize=new Le;lightningArmed=!1;nextLightningAtS=null;lightningFlashRemainingS=0;baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunCloudTransmission=1;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new L;sunVisible=!1;lensFlareScratch=new L;sunOcclusionRaycaster=new rc;sunOcclusionDirectionScratch=new L;sunOcclusionRightScratch=new L;sunOcclusionUpScratch=new L;ufoOcclusionRaycaster=new rc;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;exposureAccumulation;exposureInstants=1;get developingExposure(){return this.exposureInstants>1&&this.exposureInstantAt!==void 0}static EXPOSURE_BUDGET_MS=12;exposureFrameId=null;exposureInstantsDone=0;exposureInstantAt;restatingExposure=!1;lensOptics;meteorSystem;cometTail;iceHalos;rainbow;skyGlow;cometKey;onLightningFlash;constructor(e,t=O3(),n){this.renderer=new K_({canvas:e,antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=Cr,this.camera=new _n(60,e.width/Math.max(e.height,1),.1,Ua*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=t,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(e,t){this.renderer.setSize(e,t,!1),this.camera.aspect=e/Math.max(t,1),this.camera.updateProjectionMatrix(),this.render()}setObserverPose(e){const t=(e.rollDeg??0)*mn;e.headingDeg!==void 0?this.camera.rotation.set(e.pitchDeg*mn,-e.headingDeg*mn,t,"YXZ"):this.camera.rotation.set(e.pitchDeg*mn,this.camera.rotation.y,t,"YXZ"),e.elevationM!==this.observerElevationM&&(this.observerElevationM=e.elevationM,this.syncCloudLayer(),Math.abs(Ad(e.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/Rr),this.camera.far=Math.max(Ua*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.camera.position.y=1.6+e.elevationM,this.celestialGroup.position.y=this.camera.position.y,this.camera.fov!==e.fovDeg&&(this.camera.fov=e.fovDeg,this.camera.updateProjectionMatrix(),this.updateCompassScale())}setTerrainProviders(e){this.terrainProviders=e,this.disposeMesh(this.terrainMesh),this.terrainMesh=void 0,this.terrainOrigin=void 0,this.terrainAttribution=void 0,this.terrainBuildToken++}setTerrainOrigin(e,t,n){if(e===void 0||t===void 0)return;const s=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-s)<s*.1){const{x:a,z:o}=us(e,t,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(a*a+o*o)<qM*(s/Rr))return}this.terrainOrigin={lat:e,lng:t},this.terrainRadius=s;const r=++this.terrainBuildToken;G3(e,t,this.terrainProviders,s).then(({mesh:a,attribution:o})=>{r===this.terrainBuildToken&&(this.disposeMesh(this.terrainMesh),a.renderOrder=XM,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(e){this.showCompass!==e&&(this.showCompass=e,this.disposeCompassLabels(),e&&this.buildCompassLabels(),this.render())}applyLensFlareTint(e){if(!this.lensFlare)return;const t=YM*this.sunCloudTransmission;this.lensFlare.uniforms.uColorGain.value.setRGB(t*e[0],t*e[1],t*e[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const e=this.lastSunPosition?.altitudeDeg??-90,t=_x(e)*this.sunCloudTransmission*this.sunUnhiddenFraction,n=Yi(e);this.lensFlare.uniforms.uDazzleColour.value.setRGB(n[0],n[1],n[2]),this.lensFlare.uniforms.uVeilStrength.value=ZM**2*Math.max(0,t)}setCompassHovered(e){this.compassHovered!==e&&(this.compassHovered=e,this.updateCompassVisibility())}setCompassForced(e){this.compassForced!==e&&(this.compassForced=e,this.updateCompassVisibility())}updateCompassVisibility(){const e=this.compassHovered||this.compassForced;for(const t of this.compassSprites)t.visible=e;this.render()}setWeather(e){wM(this.weather,e)||(this.weather=e,this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lightningArmed=e.storm&&e.cloudDarkness>=fS,this.lightningArmed||(this.nextLightningAtS=null,this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),this.render())}setDecor(e){if(this.decorObjects!==e){this.decorObjects=e;for(const t of this.decorGroups.values())t.removeFromParent(),Bs.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear();for(const t of e){const n=Bs.build(t,t.lit??!1);this.scene.add(n),this.decorGroups.set(t.id,n),t.kind==="streetlight"&&this.addStreetlightLight(t.id,n)}this.celestialLight.castShadow=this.decorGroups.size>0}}updateDecorAnchoring(e,t,n=0){const s=e?.lat!==void 0&&e.lng!==void 0&&t?.lat!==void 0&&t?.lng!==void 0?us(e.lat,e.lng,t.lat,t.lng):{x:0,z:0},r=this.decorObjects.find(l=>l.witnessSide!==void 0&&cM(l.kind)),a={x:0,z:0};let o=0;if(r){const l=Bs.occupantView(r),h=-(r.headingDeg??0)*mn,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*mn,-(l.headingDeg+this.indoorLookYawDeg)*mn,0,"YXZ")}for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=Mf(l,n);h.position.set(u.eastM+s.x+a.x,QM+u.altitudeM,-u.northM+s.z+a.z),u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*mn),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(e,t){this.indoorLookYawDeg=e,this.indoorLookPitchDeg=t}updateDecorLitState(e,t=0){for(const n of this.decorObjects){const s=this.decorGroups.get(n.id);if(s&&n.lights?.length&&Bs.setLights(s,n.lights,e,s.position.distanceTo(this.camera.position),t),n.kind!=="streetlight"&&n.kind!=="vehicle")continue;const r=this.decorGroups.get(n.id);if(!r)continue;const a=lM(n,e);Bs.setLit(r,n.kind,a);const o=this.streetlightLights.get(n.id);o&&(o.visible=a)}}addStreetlightLight(e,t){const n=t.children.find(r=>r.userData.emissive);if(!n)return;const s=new Km(16764006,FM,zM);s.position.copy(n.position),s.castShadow=!0,s.shadow.mapSize.set(512,512),s.shadow.bias=-.002,t.add(s),this.streetlightLights.set(e,s)}setAstronomy(e){const t=Cl(e.sun.altitudeDeg),n=t.horizon;this.baseFogColor=n,this.lastSunPosition=e.sun,this.buildSky(e.sun),this.buildGround(),this.updateCloudLighting(e.sun,n),this.updateCelestialLight(e,t.zenith,n),this.buildStars(e.stars,e.sun.altitudeDeg);const s=ju(e.sun.altitudeDeg);this.setBodyMesh("sun",e.sun,bc,new Me(1,.96,.88),e.sun.magnitude),this.setMoonMesh(e.moon,s),this.buildPlanets(e.planets,s),this.buildComet(e.comet,s),this.buildIceHalos(e.sun,e.moon),this.buildRainbow(e.sun,e.moon),this.buildSkyGlow(e,t.zenith),this.scene.fog=new dh(new Me(...n),this.groundRadius*.2,this.groundRadius),this.syncAnimationLoop(),this.render()}updateCelestialLight(e,t,n){this.skyLight.color.setRGB(t[0],t[1],t[2]),this.skyLight.groundColor.setRGB(n[0],n[1],n[2]),this.skyLight.intensity=OM;const s=e.sun.altitudeDeg>=Dd,r=!s&&e.moon.altitudeDeg>=Dd;if(!s&&!r){this.celestialLight.intensity=0;return}const a=s?e.sun:e.moon,{x:o,y:c,z:l}=tn(a.altitudeDeg,a.azimuthDeg,Oa);this.celestialLight.position.set(o,c,l);const h=Yi(a.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const u=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*mn));this.celestialLight.intensity=(s?NM:UM)*u,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(e,t,n){this.meteorSystem||(this.meteorSystem=new kt,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(e,t,n)}get meteorSchedule(){return this.meteorSystem?.schedule??[]}meteorMidpoint(e){return this.meteorSystem?.midpointOf(e)}updateMeteors(e){this.meteorSystem?.update(e)}setInstrument(e){this.projectionKind=e.projection;const t=Zt.starPointsOf(e),n=Zt.flareArtifactsOf(e);t===this.starPoints&&n===this.lensFlareArtifactIntensity||(this.starPoints=t,this.lensFlareArtifactIntensity=n,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=t,this.lensFlare.uniforms.uFlareIntensity.value=n),this.render())}render(){this.restatingExposure||(this.renderOnce(),this.developingExposure&&this.startExposure())}setExposure(e,t){const n=t?Math.max(1,Math.round(e)):1;if(n===this.exposureInstants&&(n===1||t===this.exposureInstantAt)){this.exposureInstantAt=t;return}this.exposureInstants=n,this.exposureInstantAt=t,n===1&&(this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0),this.render()}renderOnce(e){const t=this.usableEquidistantPass(),n=this.renderer.getRenderTarget();if(!t){this.updateLensFlarePosition();const s=this.usableDepthOfFieldPass();s?.setEncodesOutput(e===void 0),this.skyGlow?.setDestinationEncoded(e===void 0&&!s),e&&this.renderer.setRenderTarget(e),s?s.render(this.renderer,this.scene,this.camera):this.renderer.render(this.scene,this.camera),e&&this.renderer.setRenderTarget(n);return}t.setEncodesOutput(e===void 0),this.skyGlow?.setDestinationEncoded(!1),e&&this.renderer.setRenderTarget(e),t.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition()),e&&this.renderer.setRenderTarget(n)}startExposure(){this.cancelExposure();const e=this.renderer.getDrawingBufferSize(new Le),t=Math.max(1,Math.round(e.x)),n=Math.max(1,Math.round(e.y));this.exposureAccumulation||(this.exposureAccumulation=new Z_(t,n)),this.exposureAccumulation.resize(t,n),this.exposureAccumulation.open(this.renderer),this.exposureInstantsDone=0,this.exposureFrameId=requestAnimationFrame(()=>this.developExposure())}developExposure(){this.exposureFrameId=null;const e=this.exposureInstantAt,t=this.exposureAccumulation;if(!e||!t)return;const n=1/this.exposureInstants,s=performance.now()+hi.EXPOSURE_BUDGET_MS;do this.restateAt(e,this.exposureInstantsDone),this.renderOnce(t.instantTarget),t.add(this.renderer,n),this.exposureInstantsDone++;while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<s);this.restateAt(e,0),t.develop(this.renderer,this.exposureInstants/this.exposureInstantsDone),this.exposureInstantsDone<this.exposureInstants&&(this.exposureFrameId=requestAnimationFrame(()=>this.developExposure()))}restateAt(e,t){this.restatingExposure=!0;try{e(t)}finally{this.restatingExposure=!1}}cancelExposure(){this.exposureFrameId!==null&&(cancelAnimationFrame(this.exposureFrameId),this.exposureFrameId=null)}setLensOptics(e){const t=this.lensOptics;this.lensOptics=e,(t===void 0!=(e===void 0)||t&&e&&(t.focalLengthMm!==e.focalLengthMm||t.fNumber!==e.fNumber||t.focusDistance!==e.focusDistance||t.frameHeightMm!==e.frameHeightMm))&&(e&&this.depthOfFieldPass&&this.depthOfFieldPass.setLens(e.focalLengthMm,e.fNumber,e.focusDistance,e.frameHeightMm),this.render())}usableDepthOfFieldPass(){const e=this.lensOptics;if(!e)return;const t=this.renderer.getDrawingBufferSize(new Le),n=Math.max(1,Math.round(t.x)),s=Math.max(1,Math.round(t.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new Pr(n,s)),this.depthOfFieldPass.resize(n,s),this.depthOfFieldPass.setLens(e.focalLengthMm,e.fNumber,e.focusDistance,e.frameHeightMm),this.depthOfFieldPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const e=this.renderer.getDrawingBufferSize(new Le);if(uo.supports(this.camera.fov,e.x/Math.max(e.y,1)))return this.equidistantPass?this.equidistantPass.resize(e.x,e.y):this.equidistantPass=new uo(e.x,e.y),this.equidistantPass}aimAtScreenPoint(e,t,n){const s=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!s){e.setFromCamera(new Le(t,n),this.camera);return}const r=s.directionFor(t,n,this.camera.fov);this.camera.updateMatrixWorld(),e.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),e.ray.direction.set(r.x,r.y,r.z).applyQuaternion(this.camera.quaternion).normalize(),e.camera=this.camera}updateLensFlarePosition(){const e=this.lensFlare;if(!e)return;if(!this.sunVisible){e.mesh.visible=!1;return}if(this.camera.updateMatrixWorld(),this.lensFlareScratch.copy(this.sunWorldPosition).applyMatrix4(this.camera.matrixWorldInverse),this.lensFlareScratch.z>0){e.mesh.visible=!1;return}const t=this.sunVisibleFraction();if(t<=0){e.mesh.visible=!1;return}e.mesh.visible=!0,this.sunUnhiddenFraction=t,this.applyDazzleStrength();const n=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);e.uniforms.uLensPosition.value.set(n.x,n.y);const s=this.renderer.domElement.width,r=this.renderer.domElement.height;e.uniforms.uResolution.value.set(s,r),e.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}sunVisibleFraction(){let e=0;for(const t of Pd)this.isSunOccluded(t[0],t[1])||e++;return e/Pd.length}isSunOccluded(e=0,t=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(),e!==0||t!==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,e*o).addScaledVector(l,t*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(e,t,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,e,t),this.ufoOcclusionRaycaster.near=Ec,this.ufoOcclusionRaycaster.intersectObjects(r,!0).length>0)}decorDistancesAt(e,t,n){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),this.ufoOcclusionRaycaster.near=Ec;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(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const n=[...this.hitAreas.entries()],s=this.raycaster.intersectObjects(n.map(([,r])=>r))[0];if(s&&!this.groundHides(e,t))return n.find(([,r])=>r===s.object)?.[0]}pickStarAt(e,t){if(this.namedStars.length===0)return;this.aimAtScreenPoint(this.raycaster,e,t);const n=this.raycaster.ray.direction,s=Math.cos(CM*this.camera.fov*Math.PI/180);let r,a=s;for(const o of this.namedStars){const c=o.direction.dot(n);c>a&&(a=c,r={star:o.star,altitudeDeg:o.altitudeDeg})}return r&&this.groundHides(e,t)?void 0:r}groundHides(e,t){const n=[this.terrainMesh,this.groundMesh].filter(s=>s!==void 0);return n.length===0?!1:(this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),this.ufoOcclusionRaycaster.near=Ec,this.ufoOcclusionRaycaster.intersectObjects(n,!0).length>0)}pickDecorAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);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.skyGlow?.dispose(),this.skyGlow=void 0,this.depthOfFieldPass?.dispose(),this.depthOfFieldPass=void 0,this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0,this.cometTail?.dispose(),this.cometTail=void 0;for(const e of this.bodyMeshes.values())this.disposeMesh(e);this.bodyMeshes.clear();for(const e of[...this.hitAreas.keys()])this.disposeHitArea(e);for(const e of[...this.glareSprites.keys()])this.disposeGlare(e);this.disposeCompassLabels();for(const e of this.decorGroups.values())Bs.dispose(e);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 e;const t=n=>{const s=e===void 0?0:Math.min((n-e)/1e3,dS);e=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.developingExposure||this.render(),this.animationFrameId=requestAnimationFrame(t)};this.animationFrameId=requestAnimationFrame(t)}setAnimationsRunning(e){e!==this.animationsRunning&&(this.animationsRunning=e,e?this.nextLightningAtS=null:this.lightningFlashRemainingS>0&&(this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),e||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(e){this.disposeMesh(this.skyMesh);const t=new wn(Ua,32,16),n=t.attributes.position,s=[];for(let a=0;a<n.count;a++){const{altitudeDeg:o,azimuthDeg:c}=j_(n.getX(a),n.getY(a),n.getZ(a)),l=ox(o,c,e.azimuthDeg,e.altitudeDeg);s.push(l[0],l[1],l[2])}t.setAttribute("color",new Ut(s,3));const r=new cs({vertexColors:!0,side:It,fog:!1,depthWrite:!1});this.skyMesh=new je(t,r),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){this.disposeMesh(this.groundMesh),this.groundRadius=Ad(this.observerElevationM);const e=new mh(this.groundRadius,48),t=new Gr({color:new Me(Ac,Ac,Ac),fog:!0});this.groundMesh=new je(e,t),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh)}cloudTransmission(e){const t=tn(e.altitudeDeg,e.azimuthDeg,1);let n=1;const s=this.lowerCloudCover();s>0&&(n*=1-Pt.alphaAt(t,Math.abs(this.cloudLayerOffset()),s)*IM);const r=this.weather.highCloudCover??0;return r>0&&(n*=1-Pt.alphaAt(t,Fa,r)*LM),Math.max(0,Math.min(1,n))}setBodyMesh(e,t,n,s,r){if(this.disposeMesh(this.bodyMeshes.get(e)),this.disposeHitArea(e),this.disposeGlare(e),t.altitudeDeg<Ql){this.bodyMeshes.delete(e),e==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:c}=tn(t.altitudeDeg,t.azimuthDeg,Oa),l=Yi(t.altitudeDeg),h=this.cloudTransmission(t),u=new Me(s.r*l[0]*h,s.g*l[1]*h,s.b*l[2]*h),d=new wn(n,16,16),f=new cs({color:u,fog:!1}),g=new je(d,f);g.position.set(a,o,c),this.celestialGroup.add(g),this.bodyMeshes.set(e,g),this.setHitArea(e,a,o,c,n);const x=r-2.5*Math.log10(Math.max(h,.001));if(e==="sun"&&(this.sunCloudTransmission=h),e!=="sun"&&this.setGlare(e,a,o,c,x,u),e==="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=aM(),this.lensFlare.uniforms.uOpacity.value=KM,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(l)}}setMoonMesh(e,t){const n="moon";if(this.disposeMesh(this.bodyMeshes.get(n)),this.disposeHitArea(n),this.disposeGlare(n),e.magnitude>t||e.altitudeDeg<Ql){this.bodyMeshes.delete(n);return}const{x:s,y:r,z:a}=tn(e.altitudeDeg,e.azimuthDeg,Oa),o=Yi(e.altitudeDeg),c=new Me(o[0],o[1],o[2]),l=new Ar({map:AS(e.phase),color:c,fog:!1}),h=new la(l);h.position.set(s,r,a);const u=bc*2;h.scale.set(u,u,1),this.celestialGroup.add(h),this.bodyMeshes.set(n,h),this.setHitArea(n,s,r,a,bc),this.setGlare(n,s,r,a,e.magnitude,c)}setHitArea(e,t,n,s,r){const a=new Ar({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1}),o=new la(a);o.position.set(t,n,s);const c=r*PM;o.scale.set(c,c,1),this.celestialGroup.add(o),this.hitAreas.set(e,o)}disposeHitArea(e){const t=this.hitAreas.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.hitAreas.delete(e))}setGlare(e,t,n,s,r,a){const o=hx(r);if(o<=0){this.disposeGlare(e);return}const c=fx(o),l=this.glareSprites.get(e),h=l??new la(new Ar({map:ES(),transparent:!0,blending:ni,depthWrite:!1,fog:!1}));h.material.color.copy(a),h.material.opacity=gx(o),h.position.set(t,n,s),h.scale.set(c*2,c*2,1),l||(this.celestialGroup.add(h),this.glareSprites.set(e,h))}disposeGlare(e){const t=this.glareSprites.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.glareSprites.delete(e))}buildComet(e,t){const n=e&&`comet:${e.id}`;if(!e||!n||e.magnitude>t){this.disposeComet();return}this.cometKey&&this.cometKey!==n&&this.disposeComet();const s=fc(e.magnitude),r=pc(s);this.cometKey=n,this.setBodyMesh(n,e.position,Td*(.5+.5*s),new Me(r,r,r),e.magnitude),this.cometTail||(this.cometTail=new gn(Oa),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(e.position,e.tailEnd,s)}buildIceHalos(e,t){this.iceHalos||(this.iceHalos=new Vn,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=Qe.deckLitUntilDeg(Qe.DECK_HEIGHT_M),a=e.altitudeDeg>-r?e:t,o=Qe.strength(n,s,a.altitudeDeg,r)*(a===e?1:Rd),{x:c,y:l,z:h}=tn(a.altitudeDeg,a.azimuthDeg,1),u=Yi(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??ep)}buildRainbow(e,t){this.rainbow||(this.rainbow=new Ir,this.celestialGroup.add(this.rainbow.object));const n=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity:0,s=e.altitudeDeg>0,r=s?e:t,a=this.weather.lowerCloudCover??this.weather.cloudCover,o=Rd*ln.moonlightShare(t.magnitude),c=ln.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}=tn(r.altitudeDeg,r.azimuthDeg,1),d=Yi(r.altitudeDeg);this.rainbow.update({x:l,y:h,z:u},c,[d[0],d[1],d[2]],s)}buildSkyGlow(e,t){if(!e.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new Pn,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:n,observer:s}=e.frame,r=In.galactic(n,s),a=hi.directionOf(r.centre),o=hi.directionOf(r.rotation),c=hi.directionOf(r.pole),l=new ze().set(a.x,a.y,a.z,o.x,o.y,o.z,c.x,c.y,c.z),h=hi.directionOf(In.eclipticPole(n,s)),u=hi.directionOf(e.sun),d=u.clone().addScaledVector(h,-u.dot(h)).normalize();this.skyGlow.update({galactic:l,eclipticPole:h,sunLongitude:d,sunDirection:u,sunAltitudeDeg:e.sun.altitudeDeg,moon:{direction:hi.directionOf(e.moon),altitudeDeg:e.moon.altitudeDeg,phaseAngleDeg:Xe.phaseAngleOf(e.moon.phase.illuminatedFraction)},skyColor:new L(t[0],t[1],t[2])})}static directionOf(e){const{x:t,y:n,z:s}=tn(e.altitudeDeg,e.azimuthDeg,1);return new L(t,n,s).normalize()}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(e,t){const n=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[]]);for(const s of e){if(s.magnitude>t)continue;n.add(s.body);const r=fc(s.magnitude),a=pc(r),o=pS[s.body]??new Me(1,1,1),c=new Me(o.r*a,o.g*a,o.b*a),l=Td*(.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(e,t){if(this.disposeStarTiers(),this.namedStars=[],!e||e.catalog.count===0){this.syncAnimationLoop();return}const{catalog:n,date:s,observer:r}=e,a=ju(t),o=Cc(1337),c=[];for(let l=0;l<n.count;l++){const h=n.mag[l];if(h>a)continue;const{altitudeDeg:u,azimuthDeg:d}=rr(n.ra[l],n.dec[l],s,r);if(u<wd)continue;const{x:f,y:g,z:x}=tn(u,d,bd);c.push({x:f,y:g,z:x,brightness:fc(h),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}for(const l of A3){if(l.mag>a)continue;const{altitudeDeg:h,azimuthDeg:u}=rr(l.raHours,l.decDeg,s,r);if(h<wd)continue;const{x:d,y:f,z:g}=tn(h,u,bd);this.namedStars.push({star:l,direction:new L(d,f,g).normalize(),altitudeDeg:h})}this.starTiers=W0.map((l,h)=>{const u=c.filter(M=>Mx(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 Rt;m.setAttribute("position",new ut(d,3));const p=new ut(new Float32Array(u.length*3),3);m.setAttribute("color",p);const A=new R0({vertexColors:!0,size:l.size,sizeAttenuation:!1,fog:!1});ts.apply(A);const T=new Ka(m,A);return this.celestialGroup.add(T),{points:T,colorAttribute:p,brightness:f,phase:g,speedFactor:x}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(e){for(const t of this.starTiers){const n=t.colorAttribute.array;for(let s=0;s<t.brightness.length;s++){const r=Ex(t.brightness[s],{phase:t.phase[s],speedFactor:t.speedFactor[s]},e),a=pc(t.brightness[s])*r;n[s*3]=a,n[s*3+1]=a,n[s*3+2]=a}t.colorAttribute.needsUpdate=!0}}buildClouds(){this.disposeCloudSystem();const e=this.lowerCloudCover();if(e<=0)return;const t=this.weather.cloudDarkness,n=new Me(Zi[0]+(Rc[0]-Zi[0])*t,Zi[1]+(Rc[1]-Zi[1])*t,Zi[2]+(Rc[2]-Zi[2])*t),{material:s,uniforms:r}=vd(n,e,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=s,this.cloudUniforms=r,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const a=_d(Id);this.cloudMesh=new je(a,s),this.cloudLayerOffset()<0&&(this.cloudMesh.scale.y=-1),this.cloudMesh.renderOrder=Ld,this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.lowerCloudCover??this.weather.cloudCover}buildCirrus(){this.disposeCirrus();const e=this.weather.highCloudCover??0;if(e<=0)return;const{material:t,uniforms:n}=vd(new Me(...Zi),e,Fa,1);this.cirrusMaterial=t,this.cirrusUniforms=n,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new je(_d(Id*1.04),t),this.cirrusMesh.renderOrder=Ld-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 e=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(e)),this.cloudMesh&&(this.cloudMesh.scale.y=e<0?-1:1)}cloudLayerOffset(){const t=((this.weather.cloudBaseM??t0)-this.observerElevationM)*$M;return Math.sign(t||1)*Math.max(Math.abs(t),JM)}updateCloudLighting(e,t){const n=[this.cloudUniforms,this.cirrusUniforms].filter(l=>l!==void 0);if(n.length===0)return;const{x:s,y:r,z:a}=tn(e.altitudeDeg,e.azimuthDeg,1),o=Yi(e.altitudeDeg),c=Math.max(0,Math.sin(Math.max(e.altitudeDeg,0)*mn));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(t[0],t[1],t[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 e=this.weather.precipitationType;if(e==="none")return;if(e==="rain"){this.buildRain();return}const t=Nd[e],n=t.poolSize,s=Cc(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()*t.radiusM;r[T*3]=Math.cos(M)*y,r[T*3+1]=Gs+s()*(t.topYM-Gs),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 Rt;x.setAttribute("position",new ut(r,3)),x.setDrawRange(0,Dc(n,this.weather.precipitationIntensity));const m={uSize:{value:t.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:t.opacity},uColor:{value:t.color},uHazeColor:{value:new Me(...this.baseFogColor)},uTexture:{value:mS(e)},uNearFocusDistance:{value:kd},uHazeDistance:{value:t.radiusM*Gd}},p=new At({uniforms:m,vertexShader:SS,fragmentShader:yS,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const A=new Ka(x,p);A.renderOrder=wc,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(e,t){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter||(this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor),t<=0))return;const n=this.weather.precipitationType;if(n==="none"||n==="rain")return;const s=Nd[n],r=this.weather.windDirectionDeg*mn,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]-=t,f[y]<=0){const _=Math.random()*Math.PI*2,E=Math.sqrt(Math.random())*s.radiusM;c[M]=Math.cos(_)*E,c[M+1]=s.topYM,c[M+2]=Math.sin(_)*E,f[y]=0}else{const _=1-f[y]/x[y];c[M+1]=Gs+Math.sin(Math.PI*_)*g[y],c[M]=Ba(c[M]+(a+m[y])*t,s.radiusM),c[M+2]=Ba(c[M+2]+(o+p[y])*t,s.radiusM)}continue}let b=0,R=0;if(A){const _=cS*u[y],E=lS*d[y];b=Math.sin(e*_*Math.PI*2+l[y])*E,R=Math.sin(e*_*Math.PI*2+l[y]+Math.PI/2)*E}if(c[M]+=(a+b)*t,c[M+1]-=s.fallSpeedMPerS*h[y]*t,c[M+2]+=(o+R)*t,c[M]=Ba(c[M],s.radiusM),c[M+2]=Ba(c[M+2],s.radiusM),c[M+1]<Gs){if(T){g[y]=Yd*(.2+Math.random()*1.6),x[y]=hS*(.5+Math.random()),f[y]=x[y];const C=Math.random()*Math.PI*2,D=uS*(g[y]/Yd);m[y]=Math.cos(C)*D,p[y]=Math.sin(C)*D,c[M+1]=Gs;continue}const _=Math.random()*Math.PI*2,E=Math.sqrt(Math.random())*s.radiusM;c[M]=Math.cos(_)*E,c[M+1]=s.topYM,c[M+2]=Math.sin(_)*E}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const e=zd(this.weather.precipitationIntensity);this.rainSystem=Q3({count:Ud,radiusM:yr,heightM:jM,bottomYM:Od,overallSpeed:eS,color:nS,opacity:.85,visibleCount:Dc(Ud,this.weather.precipitationIntensity),speedStreak:rS(e),pixelSize:Wd,seed:9001,nearFocusDistanceM:kd,hazeDistanceM:yr*Gd,hazeColor:new Me(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=wc,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const e=Cc(4242),t=new Float32Array(Hs*3),n=new Float32Array(Hs),s=new Float32Array(Hs),r=new Float32Array(Hs);for(let h=0;h<Hs;h++){const u=e()*Math.PI*2,d=Math.sqrt(e())*yr;t[h*3]=Math.cos(u)*d,t[h*3+1]=Od,t[h*3+2]=Math.sin(u)*d,s[h]=za(Bd,Hd),n[h]=e()*s[h],r[h]=n[h]/s[h]}const a=new Rt;a.setAttribute("position",new ut(t,3));const o=new ut(r,1);a.setAttribute("aLife",o),a.setDrawRange(0,Dc(Hs,this.weather.precipitationIntensity));const c=new At({uniforms:{uMaxSize:{value:aS},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:oS},uTexture:{value:_S()}},vertexShader:xS,fragmentShader:MS,transparent:!0,depthWrite:!1}),l=new Ka(a,c);l.renderOrder=wc,this.scene.add(l),this.rainSplashSystem={points:l,positions:t,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}syncRainSlant(){const e=this.rainSystem;if(!e)return;const t=this.weather.windDirectionDeg*mn;e.uniforms.uDropVelocity.value.set(Math.sin(t)*this.weather.windSpeed,-zd(this.weather.precipitationIntensity),-Math.cos(t)*this.weather.windSpeed);const n=this.renderer.getSize(this.rainViewportSize);e.uniforms.uAspect.value=n.x/Math.max(n.y,1)}updateRain(e){const t=this.rainSystem;if(!t)return;t.uniforms.uTime.value+=e,t.uniforms.uHazeColor.value.setRGB(...this.baseFogColor);const n=this.weather.windDirectionDeg*mn,s=Math.sin(n)*this.weather.windSpeed,r=-Math.cos(n)*this.weather.windSpeed,a=yr,o=l=>(l%(a*2)+a*3)%(a*2)-a;t.uniforms.uWindOffset.value.set(o(t.uniforms.uWindOffset.value.x+s*e),o(t.uniforms.uWindOffset.value.y+r*e)),this.syncRainSlant(),this.camera.getWorldDirection(this.rainCameraDirection);const c=Math.abs(this.rainCameraDirection.y);if(Math.abs(c-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=c;const l=Xd+(1-Xd)*(1-c),h=qd+(1-qd)*(1-c);t.uniforms.uUvSquash.value=h,t.uniforms.uPixelSize.value=Wd*l*(.5+.5*h)}this.updateRainSplashes(e)}updateRainSplashes(e){const t=this.rainSplashSystem;if(!t||e<=0)return;const{positions:n,life:s,duration:r,lifeAttribute:a}=t,o=a.array;for(let c=0,l=0;c<n.length;c+=3,l++){if(s[l]+=e,s[l]>=r[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*yr;n[c]=Math.cos(h)*u,n[c+2]=Math.sin(h)*u,r[l]=za(Bd,Hd),s[l]=0}o[l]=s[l]/r[l]}t.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}updateLightning(e,t){if(this.lightningArmed){if(this.lightningFlashRemainingS>0){this.lightningFlashRemainingS=Math.max(0,this.lightningFlashRemainingS-t);const n=this.lightningFlashRemainingS/$d;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=e+za(Kd,Zd);return}e>=this.nextLightningAtS&&(this.lightningFlashRemainingS=$d,this.nextLightningAtS=e+za(Kd,Zd),this.onLightningFlash?.())}}buildCompassLabels(){const e=jl(navigator.languages,kM),t=HM[e];this.compassSprites=BM.map((n,s)=>{const r=t[s],a=new Ar({map:bS(r),depthTest:!1,fog:!1}),o=new la(a),{x:c,y:l,z:h}=tn(0,n,GM);return o.position.set(c,l,h),o.scale.set(Tc,Tc,1),o.renderOrder=WM,o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o}),this.updateCompassScale()}updateCompassScale(){const e=this.camera.fov*Math.PI/360,t=VM*Math.PI/360,n=Tc*Math.tan(e)/Math.tan(t);for(const s of this.compassSprites)s.scale.set(n,n,1)}disposeCompassLabels(){for(const e of this.compassSprites)e.removeFromParent(),e.material.map?.dispose(),e.material.dispose();this.compassSprites=[]}disposeStarTiers(){for(const e of this.starTiers)this.disposeMesh(e.points);this.starTiers=[]}disposeMesh(e){if(!e)return;e.removeFromParent(),"geometry"in e&&e.geometry.dispose();const t=e.material;for(const n of Array.isArray(t)?t:[t]){const s=n.map;s&&s.dispose(),n.dispose()}}}const mn=Math.PI/180;function Pf(i,e,t){return Math.max(e,Math.min(t,i))}function za(i,e){return i+Math.random()*(e-i)}function Ba(i,e){return(i%(e*2)+e*3)%(e*2)-e}let Ha,ka;function mS(i){switch(i){case"snow":return gS();case"hail":return vS()}}function gS(){if(Ha)return Ha;const i=64,e=document.createElement("canvas");e.width=i,e.height=i;const t=e.getContext("2d"),n=t.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)"),t.fillStyle=n,t.fillRect(0,0,i,i),Ha=new gi(e),Ha}function vS(){if(ka)return ka;const i=64,e=document.createElement("canvas");e.width=i,e.height=i;const t=e.getContext("2d"),n=t.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)"),t.fillStyle=n,t.fillRect(0,0,i,i),ka=new gi(e),ka}let Ga;function _S(){if(Ga)return Ga;const i=64,e=document.createElement("canvas");e.width=i,e.height=i;const t=e.getContext("2d"),n=t.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)"),t.fillStyle=n,t.fillRect(0,0,i,i),Ga=new gi(e),Ga}const xS=`
5532
+ `,transparent:!0,blending:ai,depthWrite:!1,side:Ut,fog:!1}),this.object=new Qe(new Pn(Zr.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}update(e,t,n,s){const r=this.material.uniforms;if(t<=0){r.uStrength.value=0,this.object.visible=!1;return}this.computed||this.publish(),r.uSource.value.set(e.x,e.y,e.z).normalize(),r.uStrength.value=t,r.uTint.value.set(n[0],n[1],n[2]),r.uSaturation.value=s?1:Zr.MOON_SATURATION,this.object.visible=!0}publish(){const t=this.sky.compute().data;for(let n=0,s=0;s<t.length;n+=4,s+=3)this.texels[n]=Wi.toHalfFloat(t[s]),this.texels[n+1]=Wi.toHalfFloat(t[s+1]),this.texels[n+2]=Wi.toHalfFloat(t[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 Ip{constructor(e){this.state=e}next(){this.state=this.state+1831565813|0;let e=this.state;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}between(e,t){return e+this.next()*(t-e)}}class fs{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(e){const{ratePerHour:t,durationMs:n,velocityKmS:s,seed:r}=e;if(t<=0||n<=0)return[];const a=t*n/36e5,o=new Ip(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=fs.MAX_DURATION_MS-d*(fs.MAX_DURATION_MS-fs.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(e,t){return e.filter(n=>t>=n.t&&t<=n.t+n.durationMs).map(n=>({meteor:n,progress:(t-n.t)/n.durationMs}))}}class Gt{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=Gt.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(Gt.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 e=Gt.MAX_CONCURRENT*Gt.SEGMENTS*Gt.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const t=new wt;t.setAttribute("position",new dt(this.positions,3)),t.setAttribute("color",new dt(this.colors,3)),t.setDrawRange(0,0),this.object=new Qe(t,new gs({vertexColors:!0,transparent:!0,blending:ai,depthWrite:!1,fog:!1,side:Fn})),this.object.frustumCulled=!1}get schedule(){return this.meteors}setShower(e,t,n){this.meteors=e,this.radiantAltitudeDeg=t,this.radiantAzimuthDeg=n}update(e){const t=this.object.geometry;if(this.meteors.length===0){t.setDrawRange(0,0);return}const n=fs.aliveAt(this.meteors,e).slice(0,Gt.MAX_CONCURRENT);let s=0;for(const{meteor:r,progress:a}of n){const o=this.radiantOf(r);if(!o)continue;const c=nn(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=w=>x*w**1.6,p=w=>this.onSphere(c,g,d+(u-d)*w),b=w=>Gt.RADIUS*((Gt.MIN_HALF_WIDTH_DEG+Gt.BRIGHT_HALF_WIDTH_DEG*r.brightness*w)*Math.PI/180);for(let w=1;w<Gt.POINTS;w++){const M=(w-1)/Gt.SEGMENTS,S=w/Gt.SEGMENTS;s=this.pushRibbon(s,p(M),p(S),b(M),b(S),m(M),m(S))}}t.setDrawRange(0,s),t.getAttribute("position").needsUpdate=!0,t.getAttribute("color").needsUpdate=!0}midpointOf(e){const t=this.radiantOf(e);if(!t)return;const n=nn(t.altitudeDeg,t.azimuthDeg,1),[s,r]=this.basisAround(n),a=this.turn(s,r,e.bearingDeg),o=this.onSphere(n,a,e.fromRadiantDeg+e.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(e){return e.radiant?e.radiant:this.radiantAltitudeDeg>0?{altitudeDeg:this.radiantAltitudeDeg,azimuthDeg:this.radiantAzimuthDeg}:void 0}pushRibbon(e,t,n,s,r,a,o){const c=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(n,t))));for(let l=0;l<Gt.ACROSS-1;l++){const h=l-1,u=l,d=this.across(t,c,s,h),f=this.across(n,c,r,h),g=this.across(t,c,s,u),x=this.across(n,c,r,u),m=(p,b)=>p===0?b:0;e=this.push(e,d,m(h,a)),e=this.push(e,f,m(h,o)),e=this.push(e,g,m(u,a)),e=this.push(e,f,m(h,o)),e=this.push(e,x,m(u,o)),e=this.push(e,g,m(u,a))}return e}across(e,t,n,s){return{x:e.x+t.x*n*s,y:e.y+t.y*n*s,z:e.z+t.z*n*s}}push(e,t,n){const s=e*3;this.positions[s]=t.x,this.positions[s+1]=t.y,this.positions[s+2]=t.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,e+1}turn(e,t,n){const s=n*Math.PI/180,r=Math.cos(s),a=Math.sin(s);return{x:e.x*r+t.x*a,y:e.y*r+t.y*a,z:e.z*r+t.z*a}}onSphere(e,t,n){const s=n*Math.PI/180,r=Math.cos(s),a=Math.sin(s);return{x:(e.x*r+t.x*a)*Gt.RADIUS,y:(e.y*r+t.y*a)*Gt.RADIUS,z:(e.z*r+t.z*a)*Gt.RADIUS}}basisAround(e){const t=Math.abs(e.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=this.normalise(this.cross(e,t));return[n,this.normalise(this.cross(e,n))]}subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}const b0=2;function Lp(i){return i==="building"||i==="vehicle"}function pS(i,e){const t=i.litKeyframes;if(!t||t.length===0)return i.lit??!1;let n=t[0];for(const s of t){if(s.t>e)break;n=s}return n.lit}function mS(i,e){return i.pattern.kind==="steady"?!0:Np(i,e,e+1)>.5}function Np(i,e,t){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=e/o+r,l=t/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 Up(i,e){const t=i.track,n={eastM:i.eastM,northM:i.northM,altitudeM:0,headingDeg:i.headingDeg};if(!t||t.length===0)return n;if(t.length===1||e<=t[0].t)return A0(t[0],i);const s=t[t.length-1];if(e>=s.t)return A0(s,i);for(let r=0;r<t.length-1;r++){const a=t[r],o=t[r+1];if(e<a.t||e>o.t)continue;const c=o.t-a.t,l=c===0?0:(e-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 A0(i,e){return{eastM:i.eastM,northM:i.northM,altitudeM:i.altitudeM??0,headingDeg:i.headingDeg??e.headingDeg}}const Jc=Math.PI/180;function Qt(i,e,t,n,s=!1){const r=s?new gs({color:new ve(...t)}):new oa({color:new ve(...t)}),a=new Qe(e,r);return a.position.y=n,a.userData={emissive:s},a.castShadow=!s,a.receiveShadow=!s,i.add(a),a}const w0=.25,gS=.002,vS=20;function _S(i){const e=/^#([0-9a-f]{6})$/i.exec(i);if(!e)return[1,1,1];const t=parseInt(e[1],16);return[(t>>16&255)/255,(t>>8&255)/255,(t&255)/255]}const Op=[.32,.32,.3],Fp=[1,.85,.5],zp=[.25,.25,.25],Bp=[1,.97,.85],xS=[.55,.68,.72],Jn=.03,Qn=.05,kp={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 sn(i,e){return i?.[e]}function jn(i,e,t,n,s,r,a,o){if(o===void 0)return;const c=new oa({color:new ve(...xS),transparent:!0,opacity:o/100}),l=new Qe(new Cn(e,t,n),c);l.position.set(s,r,a),i.add(l)}const wn=.05,Qc=[.6,.58,.53],T0=[.5,.5,.48];function tr(i,e,t,n,s,r,a,o){const c=new oa({color:new ve(...o),side:Ut}),l=new Qe(new Cn(e,t,n),c);l.position.set(s,r,a),i.add(l)}function MS(i,e,t,n,s,r,a,o,c){const l=(n-r)/2,h=(g,x,m,p)=>{g<=0||(e?tr(i,g,x,wn,m,o+p,a,c):tr(i,wn,x,g,a,o+p,m,c))};h(t,l,0,n/2-l/2),h(t,l,0,-(n/2-l/2));const u=[...s].sort((g,x)=>g.center-x.center);let d=-t/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=t/2-d;h(f,r,d+f/2,0)}function Hp(i,e,t,n,s,r,a,o,c,l){const h=(n+s)/2,u=s-n,d=(f,g,x,m)=>{f.length===0?g?tr(i,x,u,wn,0,h,m,Qc):tr(i,wn,u,x,m,h,0,Qc):MS(i,g,x,u,f,r,m,h,Qc)};d(a,!0,e*2,-t+wn),d(o,!0,e*2,t-wn),d(c,!1,t*2,-e+wn),d(l,!1,t*2,e-wn),tr(i,e*2,wn,t*2,0,n+wn,0,T0),tr(i,e*2,wn,t*2,0,s-wn,0,T0)}function Dh(i,e,t,n){switch(i){case"front":return{x:0,z:-(t-n)};case"behind":return{x:0,z:t-n};case"left":return{x:-(e-n),z:0};case"right":return{x:e-n,z:0};case"front-left":return{x:-(e-n),z:-ei};case"front-right":return{x:e-n,z:-ei};case"behind-left":return{x:-(e-n),z:ei};case"behind-right":return{x:e-n,z:ei}}}function Gp(i,e,t,n,s,r,a){const o=Ih();o.scale.setScalar(n),o.rotation.y=kp[e];const{x:c,z:l}=Dh(e,s,r,a);o.position.set(c,t,l),i.add(o)}const Ch=6,Ph=6,ki=3,Or=1.4,Fr=ki*.5,Vp=1.2,Wp=.35,yS=.75,SS=1.6;function R0(i,e,t,n){const s=new Sn,r=Math.max(1,i+1),a=r*ki;Qt(s,new Cn(Ch,a,Ph),[.55,.54,.5],a/2);const o=Ch/2,c=Ph/2;for(let l=0;l<r;l++){const h=l*ki+ki/2;jn(s,Or,Fr,Qn,0,h,-c-Jn,sn(e,"front")),jn(s,Or,Fr,Qn,0,h,c+Jn,sn(e,"behind")),jn(s,Qn,Fr,Or,-o-Jn,h,0,sn(e,"left")),jn(s,Qn,Fr,Or,o+Jn,h,0,sn(e,"right"))}if(t){const l=Math.min(Math.max(n??0,0),r-1);Gp(s,t,l*ki,.72,o,c,Vp);const h=u=>sn(e,u)!==void 0?[{main:Or,center:0}]:[];Hp(s,o,c,l*ki,(l+1)*ki,Fr,h("front"),h("behind"),h("left"),h("right"))}return s}function D0(){const i=new Sn;return Qt(i,new Ki(.15,.22,2,8),[.32,.22,.14],1),Qt(i,new Ko(1.4,3,8),[.16,.32,.14],3.5),i}function C0(i){const e=new Sn;return Qt(e,new Ki(.05,.08,5,8),[.28,.28,.3],2.5),Qt(e,new Pn(.25,12,8),i?Fp:Op,5.1,!0),e}const ES=[.08,.08,.08],Bi=.8,Zs=1,Kn=1.7,jc=.6,ns=.4,ao=1.2,Ks=.7,ei=.5,bS=Kn;function P0(i,e,t){const n=new Sn;Qt(n,new Cn(1.8,1.4,4.2),[.45,.14,.14],.7),Qt(n,new Cn(Bi*2,jc,Zs*2),[.4,.12,.12],Kn);for(const r of[-1.4,1.4])for(const a of[-.95,.95]){const o=Qt(n,new Ki(.4,.4,.3,12),ES,.4);o.rotation.z=Math.PI/2,o.position.x=a,o.position.z=r}const s=i?Bp:zp;for(const r of[-.7,.7])Qt(n,new Pn(.15,8,6),s,.7,!0).position.set(r,.7,-2.1);if(jn(n,ao,ns,Qn,0,Kn,-Zs-Jn,sn(e,"front")),jn(n,ao,ns,Qn,0,Kn,Zs+Jn,sn(e,"behind")),jn(n,Qn,ns,Ks,-Bi-Jn,Kn,-ei,sn(e,"front-left")),jn(n,Qn,ns,Ks,-Bi-Jn,Kn,ei,sn(e,"behind-left")),jn(n,Qn,ns,Ks,Bi+Jn,Kn,-ei,sn(e,"front-right")),jn(n,Qn,ns,Ks,Bi+Jn,Kn,ei,sn(e,"behind-right")),t){Gp(n,t,yS,.5,Bi,Zs,Wp);const r=(c,l)=>{const h=[];return sn(e,c)!==void 0&&h.push({main:Ks,center:-ei}),sn(e,l)!==void 0&&h.push({main:Ks,center:ei}),h},a=sn(e,"front")!==void 0?[{main:ao,center:0}]:[],o=sn(e,"behind")!==void 0?[{main:ao,center:0}]:[];Hp(n,Bi,Zs,Kn-jc/2,Kn+jc/2,ns,a,o,r("front-left","behind-left"),r("front-right","behind-right"))}return n}const I0=new Map;function L0(i,e){if(!i)return;const t=[[i.lengthM,e.lengthM],[i.heightM,e.heightM],[i.widthM,e.widthM]];for(const[n,s]of t)if(n!==void 0&&s>1e-6)return n/s}function el(i,e){return e>1e-6?i/e:1}const AS=[.95,.9,.82];function Ih(){const i=new Sn;Qt(i,new Ki(.25,.3,1.5,10),[.3,.3,.35],.75),Qt(i,new Pn(.22,10,8),[.62,.52,.46],1.72);const e=Qt(i,new Ko(.07,.16,8),AS,1.72);return e.rotation.x=-Math.PI/2,e.position.z=-.2,i}const wS=17,N0=18.5,tl=[.16,.16,.18];function U0(){const i=new Sn,e=Qt(i,new Ki(1.8,1.8,N0*2,10),tl,0);e.rotation.x=Math.PI/2,Qt(i,new Cn(wS*2,.5,4.5),tl,0);const t=Qt(i,new Cn(.4,5.5,4),tl,3);return t.position.z=-N0+2,i}class xn{static occupantView(e){const t=e.witnessSide;if(!t)throw new Error("occupantView requires object.witnessSide to be set");const{x:n,z:s}=e.kind==="vehicle"?Dh(t,Bi,Zs,Wp):Dh(t,Ch/2,Ph/2,Vp),r=e.kind==="vehicle"?bS:(e.occupiedFloor??0)*ki+SS,a=(e.headingDeg??0)-kp[t]/Jc,o=this.scaleFor(e);return{x:n*o.x,z:s*o.z,eyeY:r*o.y,headingDeg:a}}static BODY_NAME="decor-body";static bodyOf(e){return e.getObjectByName(xn.BODY_NAME)??e}static build(e,t){const n=e.kind==="building"?R0(e.floors??b0,e.windows,e.witnessSide,e.occupiedFloor):e.kind==="tree"?D0():e.kind==="streetlight"?C0(t):e.kind==="vehicle"?P0(t,e.windows,e.witnessSide):e.kind==="aircraft"?U0():Ih(),s=this.scaleFor(e),r=new Sn;return n.name=xn.BODY_NAME,n.scale.copy(s),r.add(n),e.headingDeg!==void 0&&(r.rotation.y=-e.headingDeg*Jc),this.addLights(r,e.lights),e.kind==="aircraft"&&this.exemptFromFog(r),r}static scaleFor(e){const t=e.sizeM;if(!t)return new P(1,1,1);const n=this.naturalSize(e.kind,e.floors);return new P(t.widthM===void 0?1:el(t.widthM,n.widthM),t.heightM===void 0?1:el(t.heightM,n.heightM),t.lengthM===void 0?1:el(t.lengthM,n.lengthM))}static naturalSize(e,t){const n=e==="building"?Math.max(1,(t??b0)+1):0,s=`${e}:${n}`,r=I0.get(s);if(r)return r;const a=e==="building"?R0(n-1,void 0,void 0,void 0):e==="tree"?D0():e==="streetlight"?C0(!1):e==="vehicle"?P0(!1,void 0,void 0):e==="aircraft"?U0():Ih(),o=new oi().setFromObject(a),c={widthM:o.max.x-o.min.x,heightM:o.max.y-o.min.y,lengthM:o.max.z-o.min.z};return this.dispose(a),I0.set(s,c),c}static usesModel(e){return e.model!==void 0&&!(e.witnessSide!==void 0&&Lp(e.kind))}static applyModel(e,t,n,s={}){const r=this.bodyOf(e),a=new Sn;a.name=xn.BODY_NAME,n.rotation.y=-(s.headingOffsetDeg??0)*Jc,n.updateMatrixWorld(!0);const o=new oi().setFromObject(n),c={lengthM:o.max.z-o.min.z,heightM:o.max.y-o.min.y,widthM:o.max.x-o.min.x},l=L0(t.sizeM,c)??L0(s.depictedSizeM,c)??1;n.scale.multiplyScalar(l);const h=o.getCenter(new P).multiplyScalar(l);n.position.x-=h.x,n.position.z-=h.z,n.position.y-=t.kind==="aircraft"?h.y:o.min.y*l,a.add(n),r.parent?(r.parent.add(a),r.removeFromParent()):e.add(a),this.dispose(r)}static sizeOf(e){const t=this.naturalSize(e.kind,e.floors);return{widthM:e.sizeM?.widthM??t.widthM,lengthM:e.sizeM?.lengthM??t.lengthM,heightM:e.sizeM?.heightM??t.heightM}}static exemptFromFog(e){e.traverse(t=>{if(!(t instanceof Qe))return;const n=t.material;n.fog=!1,n.needsUpdate=!0})}static addLights(e,t){for(const n of t??[]){const s=_S(n.color),r=Qt(e,new Pn(w0,8,6),s,n.offsetM.y,!0);r.position.set(n.offsetM.x,n.offsetM.y,n.offsetM.z),r.userData={emissive:!0,lightId:n.id,lightColor:s},r.visible=!1}}static setLights(e,t,n,s,r=0){if(!t||t.length===0)return;const a=new Map(t.map(c=>[c.id,c])),o=Math.max(1,s*gS/w0);for(const c of e.children){if(!(c instanceof Qe))continue;const l=c.userData.lightId;if(!l)continue;const h=a.get(l);if(!h)continue;const u=r>0?Np(h,n,n+r):mS(h,n)?1:0;c.visible=u>0;const d=c.material,f=c.userData.lightColor;if(f){const g=r>0?u*vS*(h.intensity??1):u;d.color.setRGB(f[0]*g,f[1]*g,f[2]*g)}c.scale.setScalar(o)}}static setLit(e,t,n){const s=t==="streetlight"?n?Fp:Op:n?Bp:zp;e.traverse(r=>{const a=r.userData;!(r instanceof Qe)||!a.emissive||a.lightId||r.material.color.setRGB(...s)})}static dispose(e){e.traverse(t=>{if(!(t instanceof Qe))return;t.geometry.dispose();const n=t.material;for(const s of Array.isArray(n)?n:[n])s.dispose()})}}const nl="https://ufoathome.org/models/index.json";class TS{attribution="3D models re-hosted by UFO@home, each under its own author's licence";fetchImpl;indexUrls;loading;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.indexUrls=e.indexUrls??RS()}async entries(e){const t=await this.load();return e?t.filter(n=>n.kind===e):t}async entry(e){return(await this.load()).find(t=>t.id===e)}load(){return this.loading??=this.fetchFirstAvailable(),this.loading}async fetchFirstAvailable(){for(const e of this.indexUrls){const t=await this.fetchIndex(e);if(t)return t}return[]}async fetchIndex(e){try{const t=await this.fetchImpl(e);if(!t.ok)return;const n=await t.json();return Array.isArray(n?.models)?n.models.map(({file:s,...r})=>({...r,url:new URL(s,e).href})):void 0}catch{return}}}function RS(){const i=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return i&&i!==nl?[i,nl]:[nl]}const DS=[{id:"ufoathome",name:"UFO@home",credit:"3D models re-hosted by UFO@home, each under its own author's licence",creditUrl:"https://ufoathome.org/models/",create:()=>new TS}];async function CS(i){const{GLTFLoader:e}=await ml(async()=>{const{GLTFLoader:n}=await import("./GLTFLoader-BumifFuq.js");return{GLTFLoader:n}},[],import.meta.url),t=new e;return new Promise((n,s)=>{t.load(i,r=>n(r.scene),void 0,r=>s(new Error(`Could not load 3D model ${i}: ${r instanceof Error?r.message:String(r)}`)))})}function PS(i,e){return i.cloudCover===e.cloudCover&&i.cloudDarkness===e.cloudDarkness&&i.cloudBaseM===e.cloudBaseM&&i.highCloudCover===e.highCloudCover&&i.iceCrystalAlignment===e.iceCrystalAlignment&&i.lowerCloudCover===e.lowerCloudCover&&i.precipitationType===e.precipitationType&&i.precipitationIntensity===e.precipitationIntensity&&i.windDirectionDeg===e.windDirectionDeg&&i.windSpeed===e.windSpeed&&i.storm===e.storm}const oo=900,il=.5,Wr=900,IS=6371e3,LS=3e4;function O0(i){const e=Math.sqrt(2*IS*Math.max(i,0));return Math.max(Wr,Math.min(e,LS))}const sl=.5,F0=850,NS=.03,co=850,rl=4,z0=1.5,B0=-1,US=6,Lh=-4,k0=.2,lo=2600,OS=.97,FS=.38,H0=Lh,zS=3,BS=.15,kS=.6,HS=40,GS=30,VS=[0,45,90,135,180,225,270,315],WS={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},XS=["en","fr"],qS=880,al=40,YS=60,KS=10,$S=1,ZS=150,JS=55,QS=.5,jS=2.05,G0=.265,V0=[[0,0],...Array.from({length:8},(i,e)=>{const t=e*Math.PI/4;return[Math.cos(t)*G0,Math.sin(t)*G0]})],W0=700,eE=250/pf,tE=12,X0=5,ol=6,is=[.92,.92,.95],cl=[.15,.15,.19],q0={snow:{fallSpeedMPerS:2,size:.3,color:new ve(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new ve(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},Js=0,nE=0,Y0=3e3,zr=20,iE=15,K0=Js,sE=40,$0=1,rE=9;function Z0(i){return $0+(rE-$0)*i}const aE=new ve(.75,.82,.92),oE=10,cE=.5;function lE(i){return Xp(i/oE,cE,1)}const $s=200,J0=.18,Q0=.32,hE=.35,uE=new ve(.85,.9,.98),j0=5,ef=.85,tf=.01;function ll(i,e){return Math.round(i*(tf+(1-tf)*e))}const nf=230,sf=.7,rf=.05,dE=.6,fE=.7,pE=.15,af=.35,mE=3,gE=1/12,vE=.5,of=8,cf=25,lf=.12,_E={Venus:new ve(1,.96,.85),Mars:new ve(1,.55,.4),Jupiter:new ve(.95,.87,.72),Saturn:new ve(.92,.86,.68)};class gi{renderer;scene=new Yo;camera;celestialGroup=new Sn;skyMesh;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;decorModelProvider=DS[0].create();decorModelToken=0;decorModelCredits=new Map;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;celestialLight=new K1(16777215,0);celestialLightTarget=new _t;skyLight=new V1(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;raycaster=new Oc;weather=mf;observerElevationM=0;groundRadius=Wr;terrainRadius=Wr;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new P;rainLastVerticalFacing=-1;rainViewportSize=new Ie;lightningArmed=!1;nextLightningAtS=null;lightningFlashRemainingS=0;baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunCloudTransmission=1;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new P;sunVisible=!1;lensFlareScratch=new P;sunOcclusionRaycaster=new Oc;sunOcclusionDirectionScratch=new P;sunOcclusionRightScratch=new P;sunOcclusionUpScratch=new P;ufoOcclusionRaycaster=new Oc;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;exposureAccumulation;exposureInstants=1;get developingExposure(){return this.exposureInstants>1&&this.exposureInstantAt!==void 0}static EXPOSURE_BUDGET_MS=12;exposureFrameId=null;exposureInstantsDone=0;exposureInstantAt;restatingExposure=!1;lensOptics;meteorSystem;cometTail;iceHalos;rainbow;skyGlow;cometKey;onLightningFlash;constructor(e,t=Vy(),n){this.renderer=new t3({canvas:e,antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=qr,this.camera=new dn(60,e.width/Math.max(e.height,1),.1,oo*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=t,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(e,t){this.renderer.setSize(e,t,!1),this.camera.aspect=e/Math.max(t,1),this.camera.updateProjectionMatrix(),this.render()}setObserverPose(e){const t=(e.rollDeg??0)*vn;e.headingDeg!==void 0?this.camera.rotation.set(e.pitchDeg*vn,-e.headingDeg*vn,t,"YXZ"):this.camera.rotation.set(e.pitchDeg*vn,this.camera.rotation.y,t,"YXZ"),e.elevationM!==this.observerElevationM&&(this.observerElevationM=e.elevationM,this.syncCloudLayer(),Math.abs(O0(e.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/Wr),this.camera.far=Math.max(oo*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.camera.position.y=1.6+e.elevationM,this.celestialGroup.position.y=this.camera.position.y,this.camera.fov!==e.fovDeg&&(this.camera.fov=e.fovDeg,this.camera.updateProjectionMatrix(),this.updateCompassScale())}setTerrainProviders(e){this.terrainProviders=e,this.disposeMesh(this.terrainMesh),this.terrainMesh=void 0,this.terrainOrigin=void 0,this.terrainAttribution=void 0,this.applyGroundDepthWrite(),this.terrainBuildToken++}setTerrainOrigin(e,t,n){if(e===void 0||t===void 0)return;const s=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-s)<s*.1){const{x:a,z:o}=xs(e,t,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(a*a+o*o)<ZS*(s/Wr))return}this.terrainOrigin={lat:e,lng:t},this.terrainRadius=s;const r=++this.terrainBuildToken;$y(e,t,this.terrainProviders,s).then(({mesh:a,attribution:o})=>{r===this.terrainBuildToken&&(this.disposeMesh(this.terrainMesh),a.renderOrder=$S,this.terrainMesh=a,this.terrainAttribution=o,this.scene.add(a),this.applyGroundDepthWrite(),this.render(),n?.())}).catch(a=>{console.warn("Terrain build failed, keeping the flat ground fallback:",a),n?.()})}setShowCompass(e){this.showCompass!==e&&(this.showCompass=e,this.disposeCompassLabels(),e&&this.buildCompassLabels(),this.render())}applyLensFlareTint(e){if(!this.lensFlare)return;const t=JS*this.sunCloudTransmission;this.lensFlare.uniforms.uColorGain.value.setRGB(t*e[0],t*e[1],t*e[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const e=this.lastSunPosition?.altitudeDeg??-90,t=A3(e)*this.sunCloudTransmission*this.sunUnhiddenFraction,n=ts(e);this.lensFlare.uniforms.uDazzleColour.value.setRGB(n[0],n[1],n[2]),this.lensFlare.uniforms.uVeilStrength.value=jS**2*Math.max(0,t)}setCompassHovered(e){this.compassHovered!==e&&(this.compassHovered=e,this.updateCompassVisibility())}setCompassForced(e){this.compassForced!==e&&(this.compassForced=e,this.updateCompassVisibility())}updateCompassVisibility(){const e=this.compassHovered||this.compassForced;for(const t of this.compassSprites)t.visible=e;this.render()}setWeather(e){PS(this.weather,e)||(this.weather=e,this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lightningArmed=e.storm&&e.cloudDarkness>=vE,this.lightningArmed||(this.nextLightningAtS=null,this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),this.render())}setDecor(e){if(this.decorObjects!==e){this.decorObjects=e,this.decorModelToken++,this.decorModelCredits.clear();for(const t of this.decorGroups.values())t.removeFromParent(),xn.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear();for(const t of e){const n=xn.build(t,t.lit??!1);this.scene.add(n),this.decorGroups.set(t.id,n),t.kind==="streetlight"&&this.addStreetlightLight(t.id,n),this.loadDecorModel(t,this.decorModelToken)}this.celestialLight.castShadow=this.decorGroups.size>0}}setDecorModelProvider(e){this.decorModelProvider=e;const t=this.decorObjects;this.decorObjects=[],this.setDecor(t)}get currentDecorModelCredits(){return[...this.decorModelCredits.values()]}async loadDecorModel(e,t){const n=e.model;if(!(!n||!xn.usesModel(e)))try{const s=n.url?void 0:n.id?await this.decorModelProvider.entry(n.id):void 0,r=n.url??s?.url,a=n.credit??s?.credit;if(!r||!a)return;const o=await CS(r);if(t!==this.decorModelToken)return;const c=this.decorGroups.get(e.id);if(!c)return;xn.applyModel(c,e,o,{headingOffsetDeg:n.headingOffsetDeg??s?.headingOffsetDeg,depictedSizeM:s?.sizeM}),this.decorModelCredits.set(e.id,a),this.render()}catch(s){console.warn(`Keeping the built-in shape for decor "${e.id}":`,s)}}updateDecorAnchoring(e,t,n=0){const s=e?.lat!==void 0&&e.lng!==void 0&&t?.lat!==void 0&&t?.lng!==void 0?xs(e.lat,e.lng,t.lat,t.lng):{x:0,z:0},r=this.decorObjects.find(l=>l.witnessSide!==void 0&&Lp(l.kind)),a={x:0,z:0};let o=0;if(r){const l=xn.occupantView(r),h=-(r.headingDeg??0)*vn,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*vn,-(l.headingDeg+this.indoorLookYawDeg)*vn,0,"YXZ")}for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=Up(l,n);h.position.set(u.eastM+s.x+a.x,nE+u.altitudeM,-u.northM+s.z+a.z),u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*vn),o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(oo*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(e,t){this.indoorLookYawDeg=e,this.indoorLookPitchDeg=t}updateDecorLitState(e,t=0){for(const n of this.decorObjects){const s=this.decorGroups.get(n.id);if(s&&n.lights?.length&&xn.setLights(s,n.lights,e,s.position.distanceTo(this.camera.position),t),n.kind!=="streetlight"&&n.kind!=="vehicle")continue;const r=this.decorGroups.get(n.id);if(!r)continue;const a=pS(n,e);xn.setLit(r,n.kind,a);const o=this.streetlightLights.get(n.id);o&&(o.visible=a)}}addStreetlightLight(e,t){const n=xn.bodyOf(t),s=n.children.find(a=>a.userData.emissive);if(!s)return;const r=new q1(16764006,HS,GS);r.position.copy(s.position).multiply(n.scale),r.castShadow=!0,r.shadow.mapSize.set(512,512),r.shadow.bias=-.002,t.add(r),this.streetlightLights.set(e,r)}setAstronomy(e){const t=hh(e.sun.altitudeDeg),n=t.horizon;this.baseFogColor=n,this.lastSunPosition=e.sun,this.buildSky(e.sun),this.buildGround(),this.updateCloudLighting(e.sun,n),this.updateCelestialLight(e,t.zenith,n),this.buildStars(e.stars,e.sun.altitudeDeg);const s=s0(e.sun.altitudeDeg);this.setBodyMesh("sun",e.sun,rl,new ve(1,.96,.88),e.sun.magnitude),this.setMoonMesh(e.moon,s),this.buildPlanets(e.planets,s),this.buildComet(e.comet,s),this.buildIceHalos(e.sun,e.moon),this.buildRainbow(e.sun,e.moon),this.buildSkyGlow(e,t.zenith),this.scene.fog=new $h(new ve(...n),this.groundRadius*.2,this.groundRadius),this.syncAnimationLoop(),this.render()}updateCelestialLight(e,t,n){this.skyLight.color.setRGB(t[0],t[1],t[2]),this.skyLight.groundColor.setRGB(n[0],n[1],n[2]),this.skyLight.intensity=kS;const s=e.sun.altitudeDeg>=H0,r=!s&&e.moon.altitudeDeg>=H0;if(!s&&!r){this.celestialLight.intensity=0;return}const a=s?e.sun:e.moon,{x:o,y:c,z:l}=nn(a.altitudeDeg,a.azimuthDeg,co);this.celestialLight.position.set(o,c,l);const h=ts(a.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const u=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*vn));this.celestialLight.intensity=(s?zS:BS)*u,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(e,t,n){this.meteorSystem||(this.meteorSystem=new Gt,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(e,t,n)}get meteorSchedule(){return this.meteorSystem?.schedule??[]}meteorMidpoint(e){return this.meteorSystem?.midpointOf(e)}updateMeteors(e){this.meteorSystem?.update(e)}setInstrument(e){this.projectionKind=e.projection;const t=Jt.starPointsOf(e),n=Jt.flareArtifactsOf(e);t===this.starPoints&&n===this.lensFlareArtifactIntensity||(this.starPoints=t,this.lensFlareArtifactIntensity=n,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=t,this.lensFlare.uniforms.uFlareIntensity.value=n),this.render())}render(){this.restatingExposure||(this.renderOnce(),this.developingExposure&&this.startExposure())}setExposure(e,t){const n=t?Math.max(1,Math.round(e)):1;if(n===this.exposureInstants&&(n===1||t===this.exposureInstantAt)){this.exposureInstantAt=t;return}this.exposureInstants=n,this.exposureInstantAt=t,n===1&&(this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0),this.render()}renderOnce(e){const t=this.usableEquidistantPass(),n=this.renderer.getRenderTarget();if(!t){this.updateLensFlarePosition();const s=this.usableDepthOfFieldPass();s?.setEncodesOutput(e===void 0),this.skyGlow?.setDestinationEncoded(e===void 0&&!s),e&&this.renderer.setRenderTarget(e),s?s.render(this.renderer,this.scene,this.camera):this.renderer.render(this.scene,this.camera),e&&this.renderer.setRenderTarget(n);return}t.setEncodesOutput(e===void 0),this.skyGlow?.setDestinationEncoded(!1),e&&this.renderer.setRenderTarget(e),t.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition()),e&&this.renderer.setRenderTarget(n)}startExposure(){this.cancelExposure();const e=this.renderer.getDrawingBufferSize(new Ie),t=Math.max(1,Math.round(e.x)),n=Math.max(1,Math.round(e.y));this.exposureAccumulation||(this.exposureAccumulation=new n3(t,n)),this.exposureAccumulation.resize(t,n),this.exposureAccumulation.open(this.renderer),this.exposureInstantsDone=0,this.exposureFrameId=requestAnimationFrame(()=>this.developExposure())}developExposure(){this.exposureFrameId=null;const e=this.exposureInstantAt,t=this.exposureAccumulation;if(!e||!t)return;const n=1/this.exposureInstants,s=performance.now()+gi.EXPOSURE_BUDGET_MS;do this.restateAt(e,this.exposureInstantsDone),this.renderOnce(t.instantTarget),t.add(this.renderer,n),this.exposureInstantsDone++;while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<s);this.restateAt(e,0),t.develop(this.renderer,this.exposureInstants/this.exposureInstantsDone),this.exposureInstantsDone<this.exposureInstants&&(this.exposureFrameId=requestAnimationFrame(()=>this.developExposure()))}restateAt(e,t){this.restatingExposure=!0;try{e(t)}finally{this.restatingExposure=!1}}cancelExposure(){this.exposureFrameId!==null&&(cancelAnimationFrame(this.exposureFrameId),this.exposureFrameId=null)}setLensOptics(e){const t=this.lensOptics;this.lensOptics=e,(t===void 0!=(e===void 0)||t&&e&&(t.focalLengthMm!==e.focalLengthMm||t.fNumber!==e.fNumber||t.focusDistance!==e.focusDistance||t.frameHeightMm!==e.frameHeightMm))&&(e&&this.depthOfFieldPass&&this.depthOfFieldPass.setLens(e.focalLengthMm,e.fNumber,e.focusDistance,e.frameHeightMm),this.render())}usableDepthOfFieldPass(){const e=this.lensOptics;if(!e)return;const t=this.renderer.getDrawingBufferSize(new Ie),n=Math.max(1,Math.round(t.x)),s=Math.max(1,Math.round(t.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new $r(n,s)),this.depthOfFieldPass.resize(n,s),this.depthOfFieldPass.setLens(e.focalLengthMm,e.fNumber,e.focusDistance,e.frameHeightMm),this.depthOfFieldPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const e=this.renderer.getDrawingBufferSize(new Ie);if(Ho.supports(this.camera.fov,e.x/Math.max(e.y,1)))return this.equidistantPass?this.equidistantPass.resize(e.x,e.y):this.equidistantPass=new Ho(e.x,e.y),this.equidistantPass}aimAtScreenPoint(e,t,n){const s=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!s){e.setFromCamera(new Ie(t,n),this.camera);return}const r=s.directionFor(t,n,this.camera.fov);this.camera.updateMatrixWorld(),e.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),e.ray.direction.set(r.x,r.y,r.z).applyQuaternion(this.camera.quaternion).normalize(),e.camera=this.camera}updateLensFlarePosition(){const e=this.lensFlare;if(!e)return;if(!this.sunVisible){e.mesh.visible=!1;return}if(this.camera.updateMatrixWorld(),this.lensFlareScratch.copy(this.sunWorldPosition).applyMatrix4(this.camera.matrixWorldInverse),this.lensFlareScratch.z>0){e.mesh.visible=!1;return}const t=this.sunVisibleFraction();if(t<=0){e.mesh.visible=!1;return}e.mesh.visible=!0,this.sunUnhiddenFraction=t,this.applyDazzleStrength();const n=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);e.uniforms.uLensPosition.value.set(n.x,n.y);const s=this.renderer.domElement.width,r=this.renderer.domElement.height;e.uniforms.uResolution.value.set(s,r),e.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}sunVisibleFraction(){let e=0;for(const t of V0)this.isSunOccluded(t[0],t[1])||e++;return e/V0.length}isSunOccluded(e=0,t=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(),e!==0||t!==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,e*o).addScaledVector(l,t*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(e,t,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,e,t),this.ufoOcclusionRaycaster.near=il,this.ufoOcclusionRaycaster.intersectObjects(r,!0).length>0)}decorDistancesAt(e,t,n){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),this.ufoOcclusionRaycaster.near=il;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(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const n=[...this.hitAreas.entries()],s=this.raycaster.intersectObjects(n.map(([,r])=>r))[0];if(s&&!this.groundHides(e,t))return n.find(([,r])=>r===s.object)?.[0]}pickStarAt(e,t){if(this.namedStars.length===0)return;this.aimAtScreenPoint(this.raycaster,e,t);const n=this.raycaster.ray.direction,s=Math.cos(NS*this.camera.fov*Math.PI/180);let r,a=s;for(const o of this.namedStars){const c=o.direction.dot(n);c>a&&(a=c,r={star:o.star,altitudeDeg:o.altitudeDeg})}return r&&this.groundHides(e,t)?void 0:r}groundHides(e,t){const n=[this.terrainMesh,this.groundMesh].filter(s=>s!==void 0);return n.length===0?!1:(this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),this.ufoOcclusionRaycaster.near=il,this.ufoOcclusionRaycaster.intersectObjects(n,!0).length>0)}pickDecorAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);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.skyGlow?.dispose(),this.skyGlow=void 0,this.depthOfFieldPass?.dispose(),this.depthOfFieldPass=void 0,this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0,this.cometTail?.dispose(),this.cometTail=void 0;for(const e of this.bodyMeshes.values())this.disposeMesh(e);this.bodyMeshes.clear();for(const e of[...this.hitAreas.keys()])this.disposeHitArea(e);for(const e of[...this.glareSprites.keys()])this.disposeGlare(e);this.disposeCompassLabels();for(const e of this.decorGroups.values())xn.dispose(e);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 e;const t=n=>{const s=e===void 0?0:Math.min((n-e)/1e3,gE);e=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.developingExposure||this.render(),this.animationFrameId=requestAnimationFrame(t)};this.animationFrameId=requestAnimationFrame(t)}setAnimationsRunning(e){e!==this.animationsRunning&&(this.animationsRunning=e,e?this.nextLightningAtS=null:this.lightningFlashRemainingS>0&&(this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),e||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(e){this.disposeMesh(this.skyMesh);const t=new Pn(oo,32,16),n=t.attributes.position,s=[];for(let a=0;a<n.count;a++){const{altitudeDeg:o,azimuthDeg:c}=a3(n.getX(a),n.getY(a),n.getZ(a)),l=p3(o,c,e.azimuthDeg,e.altitudeDeg);s.push(l[0],l[1],l[2])}t.setAttribute("color",new Pt(s,3));const r=new gs({vertexColors:!0,side:Ut,fog:!1,depthWrite:!1});this.skyMesh=new Qe(t,r),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){this.disposeMesh(this.groundMesh),this.groundRadius=O0(this.observerElevationM);const e=new Jh(this.groundRadius,48),t=new oa({color:new ve(sl,sl,sl),fog:!0});this.groundMesh=new Qe(e,t),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh),this.applyGroundDepthWrite()}applyGroundDepthWrite(){const e=this.groundMesh?.material;if(!e)return;const t=this.terrainMesh===void 0;e.depthWrite!==t&&(e.depthWrite=t,e.needsUpdate=!0)}cloudTransmission(e){const t=nn(e.altitudeDeg,e.azimuthDeg,1);let n=1;const s=this.lowerCloudCover();s>0&&(n*=1-Nt.alphaAt(t,Math.abs(this.cloudLayerOffset()),s)*OS);const r=this.weather.highCloudCover??0;return r>0&&(n*=1-Nt.alphaAt(t,lo,r)*FS),Math.max(0,Math.min(1,n))}setBodyMesh(e,t,n,s,r){if(this.disposeMesh(this.bodyMeshes.get(e)),this.disposeHitArea(e),this.disposeGlare(e),t.altitudeDeg<Lh){this.bodyMeshes.delete(e),e==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:c}=nn(t.altitudeDeg,t.azimuthDeg,co),l=ts(t.altitudeDeg),h=this.cloudTransmission(t),u=new ve(s.r*l[0]*h,s.g*l[1]*h,s.b*l[2]*h),d=new Pn(n,16,16),f=new gs({color:u,fog:!1}),g=new Qe(d,f);g.position.set(a,o,c),this.celestialGroup.add(g),this.bodyMeshes.set(e,g),this.setHitArea(e,a,o,c,n);const x=r-2.5*Math.log10(Math.max(h,.001));if(e==="sun"&&(this.sunCloudTransmission=h),e!=="sun"&&this.setGlare(e,a,o,c,x,u),e==="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=fS(),this.lensFlare.uniforms.uOpacity.value=QS,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(l)}}setMoonMesh(e,t){const n="moon";if(this.disposeMesh(this.bodyMeshes.get(n)),this.disposeHitArea(n),this.disposeGlare(n),e.magnitude>t||e.altitudeDeg<Lh){this.bodyMeshes.delete(n);return}const{x:s,y:r,z:a}=nn(e.altitudeDeg,e.azimuthDeg,co),o=ts(e.altitudeDeg),c=new ve(o[0],o[1],o[2]),l=new kr({map:RE(e.phase),color:c,fog:!1}),h=new Ca(l);h.position.set(s,r,a);const u=rl*2;h.scale.set(u,u,1),this.celestialGroup.add(h),this.bodyMeshes.set(n,h),this.setHitArea(n,s,r,a,rl),this.setGlare(n,s,r,a,e.magnitude,c)}setHitArea(e,t,n,s,r){const a=new kr({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1}),o=new Ca(a);o.position.set(t,n,s);const c=r*US;o.scale.set(c,c,1),this.celestialGroup.add(o),this.hitAreas.set(e,o)}disposeHitArea(e){const t=this.hitAreas.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.hitAreas.delete(e))}setGlare(e,t,n,s,r,a){const o=v3(r);if(o<=0){this.disposeGlare(e);return}const c=M3(o),l=this.glareSprites.get(e),h=l??new Ca(new kr({map:TE(),transparent:!0,blending:ai,depthWrite:!1,fog:!1}));h.material.color.copy(a),h.material.opacity=E3(o),h.position.set(t,n,s),h.scale.set(c*2,c*2,1),l||(this.celestialGroup.add(h),this.glareSprites.set(e,h))}disposeGlare(e){const t=this.glareSprites.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.glareSprites.delete(e))}buildComet(e,t){const n=e&&`comet:${e.id}`;if(!e||!n||e.magnitude>t){this.disposeComet();return}this.cometKey&&this.cometKey!==n&&this.disposeComet();const s=Wc(e.magnitude),r=Xc(s);this.cometKey=n,this.setBodyMesh(n,e.position,z0*(.5+.5*s),new ve(r,r,r),e.magnitude),this.cometTail||(this.cometTail=new _n(co),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(e.position,e.tailEnd,s)}buildIceHalos(e,t){this.iceHalos||(this.iceHalos=new $n,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:lo},0);return}const s=this.weather.lowerCloudCover??this.weather.cloudCover,r=et.deckLitUntilDeg(et.DECK_HEIGHT_M),a=e.altitudeDeg>-r?e:t,o=et.strength(n,s,a.altitudeDeg,r)*(a===e?1:k0),{x:c,y:l,z:h}=nn(a.altitudeDeg,a.azimuthDeg,1),u=ts(a.altitudeDeg);this.iceHalos.update({x:c,y:l,z:h},a.altitudeDeg,o,[u[0],u[1],u[2]],{cover:n,layerHeight:lo},this.weather.iceCrystalAlignment??pm)}buildRainbow(e,t){this.rainbow||(this.rainbow=new Zr,this.celestialGroup.add(this.rainbow.object));const n=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity:0,s=e.altitudeDeg>0,r=s?e:t,a=this.weather.lowerCloudCover??this.weather.cloudCover,o=k0*un.moonlightShare(t.magnitude),c=un.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}=nn(r.altitudeDeg,r.azimuthDeg,1),d=ts(r.altitudeDeg);this.rainbow.update({x:l,y:h,z:u},c,[d[0],d[1],d[2]],s)}buildSkyGlow(e,t){if(!e.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new Un,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:n,observer:s}=e.frame,r=On.galactic(n,s),a=gi.directionOf(r.centre),o=gi.directionOf(r.rotation),c=gi.directionOf(r.pole),l=new Be().set(a.x,a.y,a.z,o.x,o.y,o.z,c.x,c.y,c.z),h=gi.directionOf(On.eclipticPole(n,s)),u=gi.directionOf(e.sun),d=u.clone().addScaledVector(h,-u.dot(h)).normalize();this.skyGlow.update({galactic:l,eclipticPole:h,sunLongitude:d,sunDirection:u,sunAltitudeDeg:e.sun.altitudeDeg,moon:{direction:gi.directionOf(e.moon),altitudeDeg:e.moon.altitudeDeg,phaseAngleDeg:Ke.phaseAngleOf(e.moon.phase.illuminatedFraction)},skyColor:new P(t[0],t[1],t[2])})}static directionOf(e){const{x:t,y:n,z:s}=nn(e.altitudeDeg,e.azimuthDeg,1);return new P(t,n,s).normalize()}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(e,t){const n=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[]]);for(const s of e){if(s.magnitude>t)continue;n.add(s.body);const r=Wc(s.magnitude),a=Xc(r),o=_E[s.body]??new ve(1,1,1),c=new ve(o.r*a,o.g*a,o.b*a),l=z0*(.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(e,t){if(this.disposeStarTiers(),this.namedStars=[],!e||e.catalog.count===0){this.syncAnimationLoop();return}const{catalog:n,date:s,observer:r}=e,a=s0(t),o=hl(1337),c=[];for(let l=0;l<n.count;l++){const h=n.mag[l];if(h>a)continue;const{altitudeDeg:u,azimuthDeg:d}=mr(n.ra[l],n.dec[l],s,r);if(u<B0)continue;const{x:f,y:g,z:x}=nn(u,d,F0);c.push({x:f,y:g,z:x,brightness:Wc(h),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}for(const l of Py){if(l.mag>a)continue;const{altitudeDeg:h,azimuthDeg:u}=mr(l.raHours,l.decDeg,s,r);if(h<B0)continue;const{x:d,y:f,z:g}=nn(h,u,F0);this.namedStars.push({star:l,direction:new P(d,f,g).normalize(),altitudeDeg:h})}this.starTiers=rp.map((l,h)=>{const u=c.filter(M=>T3(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,S)=>{d[S*3]=M.x,d[S*3+1]=M.y,d[S*3+2]=M.z,f[S]=M.brightness,g[S]=M.phase,x[S]=M.speedFactor});const m=new wt;m.setAttribute("position",new dt(d,3));const p=new dt(new Float32Array(u.length*3),3);m.setAttribute("color",p);const b=new Gf({vertexColors:!0,size:l.size,sizeAttenuation:!1,fog:!1});ls.apply(b);const w=new yo(m,b);return this.celestialGroup.add(w),{points:w,colorAttribute:p,brightness:f,phase:g,speedFactor:x}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(e){for(const t of this.starTiers){const n=t.colorAttribute.array;for(let s=0;s<t.brightness.length;s++){const r=C3(t.brightness[s],{phase:t.phase[s],speedFactor:t.speedFactor[s]},e),a=Xc(t.brightness[s])*r;n[s*3]=a,n[s*3+1]=a,n[s*3+2]=a}t.colorAttribute.needsUpdate=!0}}buildClouds(){this.disposeCloudSystem();const e=this.lowerCloudCover();if(e<=0)return;const t=this.weather.cloudDarkness,n=new ve(is[0]+(cl[0]-is[0])*t,is[1]+(cl[1]-is[1])*t,is[2]+(cl[2]-is[2])*t),{material:s,uniforms:r}=S0(n,e,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=s,this.cloudUniforms=r,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const a=E0(W0);this.cloudMesh=new Qe(a,s),this.cloudLayerOffset()<0&&(this.cloudMesh.scale.y=-1),this.cloudMesh.renderOrder=X0,this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.lowerCloudCover??this.weather.cloudCover}buildCirrus(){this.disposeCirrus();const e=this.weather.highCloudCover??0;if(e<=0)return;const{material:t,uniforms:n}=S0(new ve(...is),e,lo,1);this.cirrusMaterial=t,this.cirrusUniforms=n,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new Qe(E0(W0*1.04),t),this.cirrusMesh.renderOrder=X0-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 e=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(e)),this.cloudMesh&&(this.cloudMesh.scale.y=e<0?-1:1)}cloudLayerOffset(){const t=((this.weather.cloudBaseM??pf)-this.observerElevationM)*eE;return Math.sign(t||1)*Math.max(Math.abs(t),tE)}updateCloudLighting(e,t){const n=[this.cloudUniforms,this.cirrusUniforms].filter(l=>l!==void 0);if(n.length===0)return;const{x:s,y:r,z:a}=nn(e.altitudeDeg,e.azimuthDeg,1),o=ts(e.altitudeDeg),c=Math.max(0,Math.sin(Math.max(e.altitudeDeg,0)*vn));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(t[0],t[1],t[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 e=this.weather.precipitationType;if(e==="none")return;if(e==="rain"){this.buildRain();return}const t=q0[e],n=t.poolSize,s=hl(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 w=0;w<n;w++){const M=s()*Math.PI*2,S=s()*t.radiusM;r[w*3]=Math.cos(M)*S,r[w*3+1]=Js+s()*(t.topYM-Js),r[w*3+2]=Math.sin(M)*S,a[w]=s()*Math.PI*2,o[w]=.7+s()*.6,c[w]=.6+s()*.8,l[w]=.4+s()*1.2}const x=new wt;x.setAttribute("position",new dt(r,3)),x.setDrawRange(0,ll(n,this.weather.precipitationIntensity));const m={uSize:{value:t.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:t.opacity},uColor:{value:t.color},uHazeColor:{value:new ve(...this.baseFogColor)},uTexture:{value:xE(e)},uNearFocusDistance:{value:j0},uHazeDistance:{value:t.radiusM*ef}},p=new Tt({uniforms:m,vertexShader:AE,fragmentShader:wE,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const b=new yo(x,p);b.renderOrder=ol,this.scene.add(b),this.precipitationPoints=b,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(e,t){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter||(this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor),t<=0))return;const n=this.weather.precipitationType;if(n==="none"||n==="rain")return;const s=q0[n],r=this.weather.windDirectionDeg*vn,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,b=n==="snow"&&u&&d,w=n==="hail"&&f&&g&&x&&m&&p;for(let M=0,S=0;M<c.length;M+=3,S++){if(w&&f[S]>0){if(f[S]-=t,f[S]<=0){const _=Math.random()*Math.PI*2,E=Math.sqrt(Math.random())*s.radiusM;c[M]=Math.cos(_)*E,c[M+1]=s.topYM,c[M+2]=Math.sin(_)*E,f[S]=0}else{const _=1-f[S]/x[S];c[M+1]=Js+Math.sin(Math.PI*_)*g[S],c[M]=uo(c[M]+(a+m[S])*t,s.radiusM),c[M+2]=uo(c[M+2]+(o+p[S])*t,s.radiusM)}continue}let A=0,R=0;if(b){const _=dE*u[S],E=fE*d[S];A=Math.sin(e*_*Math.PI*2+l[S])*E,R=Math.sin(e*_*Math.PI*2+l[S]+Math.PI/2)*E}if(c[M]+=(a+A)*t,c[M+1]-=s.fallSpeedMPerS*h[S]*t,c[M+2]+=(o+R)*t,c[M]=uo(c[M],s.radiusM),c[M+2]=uo(c[M+2],s.radiusM),c[M+1]<Js){if(w){g[S]=af*(.2+Math.random()*1.6),x[S]=pE*(.5+Math.random()),f[S]=x[S];const C=Math.random()*Math.PI*2,D=mE*(g[S]/af);m[S]=Math.cos(C)*D,p[S]=Math.sin(C)*D,c[M+1]=Js;continue}const _=Math.random()*Math.PI*2,E=Math.sqrt(Math.random())*s.radiusM;c[M]=Math.cos(_)*E,c[M+1]=s.topYM,c[M+2]=Math.sin(_)*E}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const e=Z0(this.weather.precipitationIntensity);this.rainSystem=rS({count:Y0,radiusM:zr,heightM:iE,bottomYM:K0,overallSpeed:sE,color:aE,opacity:.85,visibleCount:ll(Y0,this.weather.precipitationIntensity),speedStreak:lE(e),pixelSize:nf,seed:9001,nearFocusDistanceM:j0,hazeDistanceM:zr*ef,hazeColor:new ve(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=ol,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const e=hl(4242),t=new Float32Array($s*3),n=new Float32Array($s),s=new Float32Array($s),r=new Float32Array($s);for(let h=0;h<$s;h++){const u=e()*Math.PI*2,d=Math.sqrt(e())*zr;t[h*3]=Math.cos(u)*d,t[h*3+1]=K0,t[h*3+2]=Math.sin(u)*d,s[h]=ho(J0,Q0),n[h]=e()*s[h],r[h]=n[h]/s[h]}const a=new wt;a.setAttribute("position",new dt(t,3));const o=new dt(r,1);a.setAttribute("aLife",o),a.setDrawRange(0,ll($s,this.weather.precipitationIntensity));const c=new Tt({uniforms:{uMaxSize:{value:hE},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:uE},uTexture:{value:SE()}},vertexShader:EE,fragmentShader:bE,transparent:!0,depthWrite:!1}),l=new yo(a,c);l.renderOrder=ol,this.scene.add(l),this.rainSplashSystem={points:l,positions:t,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}syncRainSlant(){const e=this.rainSystem;if(!e)return;const t=this.weather.windDirectionDeg*vn;e.uniforms.uDropVelocity.value.set(Math.sin(t)*this.weather.windSpeed,-Z0(this.weather.precipitationIntensity),-Math.cos(t)*this.weather.windSpeed);const n=this.renderer.getSize(this.rainViewportSize);e.uniforms.uAspect.value=n.x/Math.max(n.y,1)}updateRain(e){const t=this.rainSystem;if(!t)return;t.uniforms.uTime.value+=e,t.uniforms.uHazeColor.value.setRGB(...this.baseFogColor);const n=this.weather.windDirectionDeg*vn,s=Math.sin(n)*this.weather.windSpeed,r=-Math.cos(n)*this.weather.windSpeed,a=zr,o=l=>(l%(a*2)+a*3)%(a*2)-a;t.uniforms.uWindOffset.value.set(o(t.uniforms.uWindOffset.value.x+s*e),o(t.uniforms.uWindOffset.value.y+r*e)),this.syncRainSlant(),this.camera.getWorldDirection(this.rainCameraDirection);const c=Math.abs(this.rainCameraDirection.y);if(Math.abs(c-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=c;const l=sf+(1-sf)*(1-c),h=rf+(1-rf)*(1-c);t.uniforms.uUvSquash.value=h,t.uniforms.uPixelSize.value=nf*l*(.5+.5*h)}this.updateRainSplashes(e)}updateRainSplashes(e){const t=this.rainSplashSystem;if(!t||e<=0)return;const{positions:n,life:s,duration:r,lifeAttribute:a}=t,o=a.array;for(let c=0,l=0;c<n.length;c+=3,l++){if(s[l]+=e,s[l]>=r[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*zr;n[c]=Math.cos(h)*u,n[c+2]=Math.sin(h)*u,r[l]=ho(J0,Q0),s[l]=0}o[l]=s[l]/r[l]}t.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}updateLightning(e,t){if(this.lightningArmed){if(this.lightningFlashRemainingS>0){this.lightningFlashRemainingS=Math.max(0,this.lightningFlashRemainingS-t);const n=this.lightningFlashRemainingS/lf;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=e+ho(of,cf);return}e>=this.nextLightningAtS&&(this.lightningFlashRemainingS=lf,this.nextLightningAtS=e+ho(of,cf),this.onLightningFlash?.())}}buildCompassLabels(){const e=Nh(navigator.languages,XS),t=WS[e];this.compassSprites=VS.map((n,s)=>{const r=t[s],a=new kr({map:DE(r),depthTest:!1,fog:!1}),o=new Ca(a),{x:c,y:l,z:h}=nn(0,n,qS);return o.position.set(c,l,h),o.scale.set(al,al,1),o.renderOrder=KS,o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o}),this.updateCompassScale()}updateCompassScale(){const e=this.camera.fov*Math.PI/360,t=YS*Math.PI/360,n=al*Math.tan(e)/Math.tan(t);for(const s of this.compassSprites)s.scale.set(n,n,1)}disposeCompassLabels(){for(const e of this.compassSprites)e.removeFromParent(),e.material.map?.dispose(),e.material.dispose();this.compassSprites=[]}disposeStarTiers(){for(const e of this.starTiers)this.disposeMesh(e.points);this.starTiers=[]}disposeMesh(e){if(!e)return;e.removeFromParent(),"geometry"in e&&e.geometry.dispose();const t=e.material;for(const n of Array.isArray(t)?t:[t]){const s=n.map;s&&s.dispose(),n.dispose()}}}const vn=Math.PI/180;function Xp(i,e,t){return Math.max(e,Math.min(t,i))}function ho(i,e){return i+Math.random()*(e-i)}function uo(i,e){return(i%(e*2)+e*3)%(e*2)-e}let fo,po;function xE(i){switch(i){case"snow":return ME();case"hail":return yE()}}function ME(){if(fo)return fo;const i=64,e=document.createElement("canvas");e.width=i,e.height=i;const t=e.getContext("2d"),n=t.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)"),t.fillStyle=n,t.fillRect(0,0,i,i),fo=new wi(e),fo}function yE(){if(po)return po;const i=64,e=document.createElement("canvas");e.width=i,e.height=i;const t=e.getContext("2d"),n=t.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)"),t.fillStyle=n,t.fillRect(0,0,i,i),po=new wi(e),po}let mo;function SE(){if(mo)return mo;const i=64,e=document.createElement("canvas");e.width=i,e.height=i;const t=e.getContext("2d"),n=t.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)"),t.fillStyle=n,t.fillRect(0,0,i,i),mo=new wi(e),mo}const EE=`
5533
5533
  uniform float uMaxSize;
5534
5534
  uniform float uScale;
5535
5535
  attribute float aLife;
@@ -5542,7 +5542,7 @@ void main() {
5542
5542
  vOpacity = 1.0 - aLife;
5543
5543
  gl_Position = projectionMatrix * mvPosition;
5544
5544
  }
5545
- `,MS=`
5545
+ `,bE=`
5546
5546
  uniform vec3 uColor;
5547
5547
  uniform sampler2D uTexture;
5548
5548
  varying float vOpacity;
@@ -5553,7 +5553,7 @@ void main() {
5553
5553
  if (alpha < 0.01) discard;
5554
5554
  gl_FragColor = vec4(uColor, alpha);
5555
5555
  }
5556
- `,SS=`
5556
+ `,AE=`
5557
5557
  uniform float uSize;
5558
5558
  uniform float uScale;
5559
5559
  uniform float uNearFocusDistance;
@@ -5579,7 +5579,7 @@ void main() {
5579
5579
  gl_PointSize = max(1.0, uSize * uScale / dist + vNearBlur * 12.0);
5580
5580
  gl_Position = projectionMatrix * mvPosition;
5581
5581
  }
5582
- `,yS=`
5582
+ `,wE=`
5583
5583
  precision mediump float;
5584
5584
  uniform sampler2D uTexture;
5585
5585
  uniform vec3 uColor;
@@ -5594,4 +5594,4 @@ void main() {
5594
5594
  float blur = max(vNearBlur, vHaze);
5595
5595
  gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * 0.5));
5596
5596
  }
5597
- `;let Va;function ES(){if(Va)return Va;const i=128,e=document.createElement("canvas");e.width=i,e.height=i;const t=e.getContext("2d"),n=t.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)"),t.fillStyle=n,t.fillRect(0,0,i,i),Va=new gi(e),Va}function AS(i){const t=document.createElement("canvas");t.width=128,t.height=128;const n=t.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=Pf(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 gi(t)}function bS(i){const e=document.createElement("canvas");e.width=128,e.height=128;const t=e.getContext("2d");return t.fillStyle="rgba(0, 0, 0, 0.55)",t.beginPath(),t.arc(64,64,60,0,Math.PI*2),t.fill(),t.fillStyle="#ffffff",t.font="bold 52px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(i,64,68),new gi(e)}function Cc(i){let e=i;return function(){e|=0,e=e+1831565813|0;let n=Math.imul(e^e>>>15,1|e);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const Jd=new Map;function TS(i){const e=i.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),t=e,n=t*Float32Array.BYTES_PER_ELEMENT;return{count:e,ra:new Float32Array(i,0*n,t),dec:new Float32Array(i,1*n,t),mag:new Float32Array(i,2*n,t),ci:new Float32Array(i,3*n,t)}}function wS(i){let e=Jd.get(i);return e||(e=fetch(i).then(t=>t.arrayBuffer()).then(TS),Jd.set(i,e)),e}const RS=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,DS=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,CS=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,PS=20,IS=1;class LS{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(e){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",e);return}}this.context.state==="suspended"&&this.context.resume()}setAmbient(e,t,n){if(this.requested={type:e,intensity:t,windSpeed:n},!this.context)return;this.paused&&(e="none",t=0,n=0);const s=e==="rain"||e==="hail"?e:"none";if(this.ambientVolume=s==="hail"?Math.min(1,t*1.3+.2):s==="rain"?t: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/PS,1);const r=n>IS;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(DS,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(e){if(e===this.paused)return;this.paused=e;const{type:t,intensity:n,windSpeed:s}=this.requested;this.setAmbient(t,n,s)}playThunder(){!this.context||this.paused||this.playOneShot(CS,.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(e,t,n,s){if(t!==n()){e?.source.stop();return}s(e)}async startLoop(e,t){const n=this.context;if(n)try{const s=await this.getBuffer(e),r=n.createBufferSource();r.buffer=s,r.loop=!0;const a=n.createGain();return a.gain.value=t,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(e,t){const n=this.context;if(n)try{const s=await this.getBuffer(e),r=n.createBufferSource();r.buffer=s;const a=n.createGain();a.gain.value=t,r.connect(a).connect(n.destination),r.start()}catch(s){console.warn("Thunder sound failed to load:",s)}}async getBuffer(e){const t=this.context;if(!t)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(e);return n||(n=fetch(e).then(s=>{if(!s.ok)throw new Error(`Audio fetch failed (${s.status}): ${e}`);return s.arrayBuffer()}).then(s=>t.decodeAudioData(s)),this.buffers.set(e,n)),n}stopSource(e,t){try{e?.stop()}catch{}e?.disconnect(),t?.disconnect()}}class ui{constructor(e){this.elements=e;const{eccentricity:t,perihelionAu:n}=e,[s,r]=this.perifocalAxes(),a=Math.sqrt(ui.SUN_GM_AU3_PER_DAY2*(1+t)/n);this.perihelionPosition=this.scale(s,n),this.perihelionVelocity=this.scale(r,a),this.inverseSemiMajorAxis=(1-t)/n}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(e){const t=e-this.elements.perihelionJd,n=this.universalAnomaly(t),s=this.inverseSemiMajorAxis*n*n,r=this.elements.perihelionAu,a=1-n*n/r*ui.stumpffC(s),o=t-n*n*n/Math.sqrt(ui.SUN_GM_AU3_PER_DAY2)*ui.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(e){const t=this.positionAt(e);return Math.hypot(t.x,t.y,t.z)}universalAnomaly(e){if(e===0)return 0;const t=Math.sign(e),n=Math.sqrt(ui.SUN_GM_AU3_PER_DAY2)*Math.abs(e),s=o=>{const c=this.inverseSemiMajorAxis*o*o,l=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*l)*o*o*o*ui.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<ui.MAX_ITERATIONS&&r-a>1e-13*Math.max(1,r);o++){const c=(a+r)/2;s(c)<n?a=c:r=c}return t*(a+r)/2}perifocalAxes(){const e=this.elements.ascendingNodeDeg*Math.PI/180,t=this.elements.argumentOfPerihelionDeg*Math.PI/180,n=this.elements.inclinationDeg*Math.PI/180,s=Math.cos(e),r=Math.sin(e),a=Math.cos(t),o=Math.sin(t),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(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}static stumpffC(e){if(Math.abs(e)<1e-6)return 1/2-e/24+e*e/720;if(e>0)return(1-Math.cos(Math.sqrt(e)))/e;const t=Math.sqrt(-e);return(Math.cosh(t)-1)/-e}static stumpffS(e){if(Math.abs(e)<1e-6)return 1/6-e/120+e*e/5040;if(e>0){const n=Math.sqrt(e);return(n-Math.sin(n))/(n*n*n)}const t=Math.sqrt(-e);return(Math.sinh(t)-t)/(t*t*t)}}const If=[{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 NS{static WINDOW_DAYS=200;static TWILIGHT_ELONGATION_DEG=15;static LIGHT_SPEED_AU_PER_DAY=173.144632674;static orbits=new Map;static aroundDate(e){const t=this.julianDayOf(e);return If.filter(n=>Math.abs(t-n.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(e,t){return this.aroundDate(e).map(n=>this.appearanceOf(n,e,t)).sort((n,s)=>n.magnitude-s.magnitude)[0]}static appearanceOf(e,t,n){const s=zt(t),r=this.earthPositionAt(s),a=this.apparentPositionOf(e,2451545+s.tt,r),o=this.subtract(a,r),c=this.length(a),l=this.length(o),h=this.tailEndAt(e,a,r,c,s,t,n),u=this.horizontalOf(o,s,t,n);return{apparition:e,position:u,...h,heliocentricDistanceAu:c,earthDistanceAu:l,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},r)),magnitude:this.magnitudeAt(e,c,l)}}static magnitudeAt(e,t,n){const s=e.absoluteMagnitude+5*Math.log10(n)+2.5*e.activityExponent*Math.log10(t);return Math.max(s,e.peakMagnitude)}static tailEndAt(e,t,n,s,r,a,o){if(e.tailLengthAu===void 0)return{};const c=1+e.tailLengthAu/s,l=this.subtract({x:t.x*c,y:t.y*c,z:t.z*c},n),h=this.subtract(t,n);return{tailEnd:this.horizontalOf(l,r,a,o),tailLengthDeg:this.angleBetween(h,l)}}static apparentPositionOf(e,t,n){const s=this.orbitOf(e);let r=s.positionAt(t);for(let a=0;a<2;a++){const o=this.length(this.subtract(r,n))/this.LIGHT_SPEED_AU_PER_DAY;r=s.positionAt(t-o)}return r}static horizontalOf(e,t,n,s){const r=Ja(g3(),new ft(e.x,e.y,e.z,t)),a=Ja(v3(t),r),o=Yx(t,new Ah(s.lat,s.lng,s.elevationM)),c=new ft(a.x-o.x,a.y-o.y,a.z-o.z,t),l=hf(c);return rr(l.ra,l.dec,n,s)}static earthPositionAt(e){return Ja(m3(),Oi(ye.Earth,e))}static julianDayOf(e){return 2451545+zt(e).tt}static orbitOf(e){const t=this.orbits.get(e.id);if(t)return t;const n=new ui(e.orbit);return this.orbits.set(e.id,n),n}static subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}static length(e){return Math.hypot(e.x,e.y,e.z)}static angleBetween(e,t){const n=(e.x*t.x+e.y*t.y+e.z*t.z)/(this.length(e)*this.length(t)||1);return Math.acos(Math.min(1,Math.max(-1,n)))*180/Math.PI}}const US=[{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}],po=6.5;class Pc{static activeAt(e){return US.flatMap(t=>{const n=this.nearness(t,e);return n<=0?[]:[{shower:t,zhr:t.peakZhr*n,nearness:n}]})}static nearness(e,t){const n=this.dayOfYear(t),s=this.dayOfYear(this.asDate(e.start)),r=this.dayOfYear(this.asDate(e.peak)),a=this.dayOfYear(this.asDate(e.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(e,t,n,s=po){if(t<=0)return 0;const r=po-s;return e*Math.sin(t*Math.PI/180)/Math.pow(n,r)}static radiantPosition(e,t,n){return rr(e.radiantRaHours,e.radiantDecDeg,t,n)}static dayOfYear(e){const t=Date.UTC(e.getUTCFullYear(),0,1);return Math.floor((Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())-t)/864e5)+1}static asDate(e){return new Date(Date.UTC(2001,e.month-1,e.day))}static wrappedDelta(e,t){const n=e-t;return n>182?n-365:n<-182?n+365:n}}class yt{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(e,t){const n=zt(e),s=new yh(0,Xx(e).elon-90,1),r=Ja(_3(n),lf(s,n)),a=hf(r);return rr(a.ra,a.dec,e,t)}static observedRatePerHour(e,t=po){const n=yt.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(e*Math.PI/180)),s=po-t;return(yt.QUIET_RATE_PER_HOUR+n)/Math.pow(yt.POPULATION_INDEX,s)}static schedule(e){const t=new _f(e.seed^1542469173);return rs.schedule(e).map(n=>{const s=yt.toCartesian({altitudeDeg:Math.asin(t.next())*180/Math.PI,azimuthDeg:t.between(0,360)}),r=n.fromRadiantDeg*Math.PI/180,a=yt.turnAround(s,t.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:yt.toHorizontal(o),bearingDeg:yt.bearingFrom(o,s)}})}static turnAround(e,t){const[n,s]=yt.basisAround(e),r=t*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(e,t){const[n,s]=yt.basisAround(e),r=e.x*t.x+e.y*t.y+e.z*t.z,a=yt.normalise({x:t.x-e.x*r,y:t.y-e.y*r,z:t.z-e.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(e){const t=Math.abs(e.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=yt.normalise(yt.cross(e,t));return[n,yt.normalise(yt.cross(e,n))]}static toHorizontal(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{altitudeDeg:Math.asin(Math.min(1,Math.max(-1,e.y/t)))*180/Math.PI,azimuthDeg:(Math.atan2(e.x,-e.z)*180/Math.PI%360+360)%360}}static appearanceOf(e){const t=yt.toCartesian(e.radiant??{altitudeDeg:90,azimuthDeg:0}),n=yt.turnAround(t,e.bearingDeg),s=e.fromRadiantDeg*Math.PI/180;return yt.toHorizontal({x:t.x*Math.cos(s)+n.x*Math.sin(s),y:t.y*Math.cos(s)+n.y*Math.sin(s),z:t.z*Math.cos(s)+n.z*Math.sin(s)})}static toCartesian(e){const t=e.altitudeDeg*Math.PI/180,n=e.azimuthDeg*Math.PI/180,s=Math.cos(t);return{x:s*Math.sin(n),y:Math.sin(t),z:-s*Math.cos(n)}}static cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}static normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}static TYPICAL_VELOCITY_KM_S=40}class OS{lowerM;upperM;add(e,t){if(!(e<=0)){if(t.behindM!==void 0){const n=Kt.sizeMAt(t.behindM,e);this.lowerM=this.lowerM===void 0?n:Math.max(this.lowerM,n)}if(t.inFrontM!==void 0){const n=Kt.sizeMAt(t.inFrontM,e);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(e){return e<=0?{}:{minM:this.lowerM===void 0?void 0:Kt.distanceMAt(this.lowerM,e),maxM:this.upperM===void 0?void 0:Kt.distanceMAt(this.upperM,e)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class Lr{static DEG_PER_SECOND=360/86164.0905;static degOver(e){return Math.max(0,e)*Lr.DEG_PER_SECOND}static instants(e,t){if(!(t>0))return 1;const n=Lr.degOver(e)/t;return n<1?1:Math.min(Lr.MAX_INSTANTS,Math.max(2,Math.ceil(n)))}static MAX_INSTANTS=64}class di{static PIXELS_PER_INSTANT=2;static INSTANTS_PER_FLASH=2;static MAX_INSTANTS=512;static instants(e,t,n,s,r){if(!(s>0))return 1;const a=r>0?di.travelDegOver(e,t,n,n+s*1e3)/r/di.PIXELS_PER_INSTANT:0,o=di.flashesOver(e,s)*di.INSTANTS_PER_FLASH,c=Math.ceil(Math.max(a,o));return c<2?1:Math.min(di.MAX_INSTANTS,c)}static travelDegOver(e,t,n,s){let r=0;for(const a of e){if(!a.track||a.track.length<2)continue;const o=di.directionAt(a,t,n),c=di.directionAt(a,t,s),l=Math.min(1,Math.max(-1,o.x*c.x+o.y*c.y+o.z*c.z));r=Math.max(r,Math.acos(l)*180/Math.PI)}return r}static flashesOver(e,t){let n=0;for(const s of e)for(const r of s.lights??[])r.pattern.kind==="flash"&&(n=Math.max(n,r.pattern.perMinute));return n/60*t}static directionAt(e,t,n){const s=Mf(e,n),r=s.eastM,a=s.altitudeM-t,o=s.northM,c=Math.hypot(r,a,o);return c===0?{x:0,y:1,z:0}:{x:r/c,y:a/c,z:o/c}}}a0();const FS={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"}},zS=["en","fr"],BS={en:"{name} — mag {mag}, {alt}° above the horizon",fr:"{name} — mag {mag}, {alt}° au-dessus de l'horizon"},HS={en:"{name} — mag {mag}, {alt}° below the horizontal",fr:"{name} — mag {mag}, {alt}° sous l'horizontale"},Qd="comet:",kS={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"}},GS=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:[]},Ic={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class WS extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","show-compass"]}shadow;stageElement;frameElement;sceneCanvas;ufoElement;sceneRenderer;hoverTooltip;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;meteorScheduleFor;lastTimeMs=0;starCatalog;weatherAudio=new LS;animateWhilePausedValue=!1;set animateWhilePaused(e){e!==this.animateWhilePausedValue&&(this.animateWhilePausedValue=e,this.syncAnimationsToPlayback())}get animateWhilePaused(){return this.animateWhilePausedValue}thunderTimeoutId;handleFullscreenChange=()=>this.resizeToStage();handlePointerMove=e=>{this.sceneRenderer.setCompassHovered(!0);const t=this.ufoElement.canvasElement,n=t.getBoundingClientRect();if(n.width===0||n.height===0)return;const s=(e.clientX-n.left)/n.width*t.width,r=(e.clientY-n.top)/n.height*t.height;if(this.ufoElement.hasVisibleShapeAt(s,r)){this.hoverTooltip.hidden=!0;return}const a=(e.clientX-n.left)/n.width*2-1,o=-((e.clientY-n.top)/n.height*2-1),c=jl(s0.preferencesFor(this),zS),l=this.sceneRenderer.pickBodyAt(a,o);if(l){this.showHoverTooltip(e,this.bodyName(l,c));return}const h=this.sceneRenderer.pickDecorAt(a,o),u=h?this.ufoElement.sighting.decor.find(f=>f.id===h):void 0;if(u){this.showHoverTooltip(e,u.title||kS[u.kind][c]);return}const d=this.sceneRenderer.pickStarAt(a,o);if(d){const f=d.star.mag,g=d.altitudeDeg,x=(g<0?HS:BS)[c];this.showHoverTooltip(e,x.replace("{name}",d.star.name[c]).replace("{mag}",f.toLocaleString(void 0,{maximumFractionDigits:Math.abs(f)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(g)))));return}this.hoverTooltip.hidden=!0};bodyName(e,t){const n=e.startsWith(Qd)?e.slice(Qd.length):void 0;return(n?If.find(r=>r.id===n):void 0)?.name[t]??FS[e]?.[t]??e}showHoverTooltip(e,t){this.hoverTooltip.textContent=t,this.hoverTooltip.hidden=!1;const n=this.stageElement.getBoundingClientRect();this.hoverTooltip.style.left=`${e.clientX-n.left+12}px`,this.hoverTooltip.style.top=`${e.clientY-n.top+12}px`}handlePointerLeave=()=>{this.hoverTooltip.hidden=!0,this.sceneRenderer.setCompassHovered(!1)};handleLightningFlash=()=>{clearTimeout(this.thunderTimeoutId);const e=(.5+Math.random()*3.5)*1e3;this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),e)};handleFirstInteraction=()=>{this.weatherAudio.resume(),this.setWeather(Fh(this.ufoElement.sighting,this.lastTimeMs))};handleTimeUpdate=e=>{this.lastTimeMs=e.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.updateUfoOcclusion(this.lastTimeMs)};syncAnimationsToPlayback(){const e=this.ufoElement.playbackState==="playing"||this.animateWhilePaused;this.sceneRenderer.setAnimationsRunning(e),this.weatherAudio.setPaused(!e),e||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${kf}</style>${Hf}`,this.shadow.appendChild(e.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 hi(this.sceneCanvas,void 0,this.handleLightningFlash),this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(Uc),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 e=this.getAttribute("src");e&&this.loadFromSrc(e)}disconnectedCallback(){this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose()}attributeChangedCallback(e,t,n){e==="src"&&n&&n!==t&&this.isConnected&&this.loadFromSrc(n),e==="star-catalog-src"&&n!==t&&this.isConnected&&this.loadStars(),e==="show-compass"&&n!==t&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass"))}setCompassForced(e){this.sceneRenderer.setCompassForced(e)}setIndoorLook(e,t){this.sceneRenderer.setIndoorLook(e,t)}setWeather(e){this.sceneRenderer.setWeather(e),this.weatherAudio.setAmbient(e.precipitationType,e.precipitationIntensity,e.windSpeed)}pickDecorAt(e,t){return this.sceneRenderer.pickDecorAt(e,t)}resumeWeatherAudio(){this.weatherAudio.resume()}async loadFromSrc(e){this.sightingData=await e0.json(e)}get sightingData(){return this.ufoElement.sightingData}set sightingData(e){this.ufoElement.sightingData=e,this.applyFrameFormat(),this.lastTimeMs=0,this.updateAstronomy(0)}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}setTerrainProviders(e){this.sceneRenderer.setTerrainProviders(e)}applyFrameFormat(){const e=this.ufoElement.sighting.instrument,t=Kt.CANVAS_HEIGHT_PX,n=Zt.frameWidthPx(e,t);this.frameElement.style.setProperty("--frame-aspect",`${n} / ${t}`)}resizeToStage(){const e=this.frameElement.getBoundingClientRect(),t=Math.max(1,Math.round(e.width)),n=Math.max(1,Math.round(e.height));this.sceneCanvas.width=t,this.sceneCanvas.height=n,this.sceneRenderer.resize(t,n)}async loadStars(){const e=this.getAttribute("star-catalog-src")??GS;this.starCatalog=await wS(e),this.updateAstronomy(this.lastTimeMs)}updateAstronomy(e){this.applySceneAt(e);const t=this.exposureSeconds(),n=this.degreesPerPixelAt(e),s=Lr.instants(t,n),r=Math.max(s,di.instants(this.ufoElement.sighting.decor,Vs(this.ufoElement.sighting,e)?.elevationM??0,e,t,n));if(r<=1){this.sceneRenderer.setExposure(1);return}const a=t*1e3;this.sceneRenderer.setExposure(r,o=>this.applySceneAt(e+a*o/r,{sky:Math.floor(o*s/r)!==Math.floor((o-1)*s/r),stepMs:a/r}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(e){const t=this.sceneCanvas.height;return t<=0?0:Dr.fovOf(this.ufoElement.sighting,e)/t}applySceneAt(e,t){const n=this.ufoElement.sighting;this.setWeather(Fh(n,e)),this.sceneRenderer.setInstrument(n.instrument),this.updateMeteorShower(n,e),this.sceneRenderer.setDecor(n.decor);const s=Vs(n,e);if(this.sceneRenderer.setObserverPose(s??Ic),this.sceneRenderer.setLensOptics(this.lensOpticsAt(e)),this.sceneRenderer.updateDecorAnchoring(Vs(n,0),s,e),this.sceneRenderer.updateDecorLitState(e,t?.stepMs??0),this.sceneRenderer.setTerrainOrigin(s?.lat,s?.lng),t&&!t.sky)return;const r=s?.lat??Ic.lat,a=s?.lng??Ic.lng,o=ud(n.event.time??{},a,n.event.utcOffsetHours);if(!o){this.sceneRenderer.setAstronomy(VS);return}const c=new Date(o.getTime()+e),l={lat:r,lng:a,elevationM:s?.elevationM??0},h={...vc("Sun",c,l),magnitude:_c("Sun",c)},u={...vc("Moon",c,l),phase:M3(c),magnitude:_c("Moon",c)},d=x3.map(f=>({body:f,position:vc(f,c,l),magnitude:_c(f,c)}));this.sceneRenderer.setAstronomy({sun:h,moon:u,planets:d,comet:this.cometAt(c,l),stars:this.starCatalog?{catalog:this.starCatalog,date:c,observer:l}:void 0,frame:{date:c,observer:l}})}cometAt(e,t){const n=NS.brightestAt(e,t);if(n)return{id:n.apparition.id,position:n.position,tailEnd:n.tailEnd,magnitude:n.magnitude}}updateUfoOcclusion(e){const t=this.ufoElement.sighting;t!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.sizeEstimatesFor=t);const n=t.timeline,s=this.ufoElement.canvasElement,r=new Set;for(const a of n.sourceIds){const o=n.getInterpolatedShapeAt(e,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(e).pxToDeg(o.bounds.width);this.sizeEstimateOf(a).add(h,this.sceneRenderer.decorDistancesAt(c,l,a))}this.ufoElement.setOccludedSourceIds(r)}sizeRangeOf(e){return this.sizeEstimateOf(e).sizeRange}distanceRangeAt(e,t){const n=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(t,e);if(!n)return{};const s=n.angular?.widthDeg??this.projectionAt(t).pxToDeg(n.bounds.width);return this.sizeEstimateOf(e).distanceRangeAt(s)}sizeContradictory(e){return this.sizeEstimateOf(e).contradictory}updateMeteorShower(e,t){this.ensureMeteorSchedule(e),this.sceneRenderer.updateMeteors(t)}ensureMeteorSchedule(e){const t=this.meteorInputsOf(e);t!==this.meteorScheduleFor&&(this.meteorScheduleFor=t,this.scheduleMeteors(e))}meteorInputsOf(e){const t=e.event.place?.[0],n=e.event.time;return JSON.stringify([t?.lat,t?.lng,n?.year,n?.month,n?.day,n?.hour,n?.minute,e.event.utcOffsetHours,e.event.durationSeconds,e.timeline.duration])}scheduleMeteors(e){const t=e.event.place?.[0],n=e.event.time,s=t?.lat!==void 0&&t.lng!==void 0&&n?.year!==void 0?ud(n,t.lng,e.event.utcOffsetHours):void 0;if(!s||t?.lat===void 0||t.lng===void 0){this.sceneRenderer.setMeteorShower([],0,0);return}const r={lat:t.lat,lng:t.lng,elevationM:0},a=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,o=Math.round(s.getTime()/1e3)+Math.round(t.lat*1e3),c=yt.schedule({ratePerHour:yt.observedRatePerHour(yt.apexPosition(s,r).altitudeDeg),durationMs:a,velocityKmS:yt.TYPICAL_VELOCITY_KM_S,seed:o}),l=Pc.activeAt(s).map(u=>{const d=Pc.radiantPosition(u.shower,s,r);return{entry:u,position:d,rate:Pc.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=rs.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(e){this.ensureMeteorSchedule(this.ufoElement.sighting);const t=[...this.sceneRenderer.meteorSchedule].filter(r=>r.t+r.durationMs<=this.ufoElement.seekableDuration).sort((r,a)=>a.brightness-r.brightness);if(t.length===0)return;const n=t[e%t.length],s=this.sceneRenderer.meteorMidpoint(n);if(s)return{t:Math.round(n.t+n.durationMs*.45),...s}}lensOpticsAt(e){const t=this.ufoElement.sighting,n=t.instrument,s=n.frame,r=Vs(t,e),a=r?.fNumber??n.fNumber;if(!s||a===void 0)return;const o=Zt.focalLengthMmFor(n,Dr.fovOf(t,e));if(o!==void 0)return{focalLengthMm:o,fNumber:a,focusDistance:r?.focusDistanceM??0,frameHeightMm:s.heightMm}}projectionAt(e){const t=this.ufoElement.sighting;return Ys.of(t.instrument,Kt.CANVAS_HEIGHT_PX,Dr.fovOf(t,e))}sizeEstimateOf(e){let t=this.sizeEstimates.get(e);return t||(t=new OS,this.sizeEstimates.set(e,t)),t}}const jd="rr0-scene";function XS(){a0(),customElements.get(jd)||customElements.define(jd,WS)}XS();
5597
+ `;let go;function TE(){if(go)return go;const i=128,e=document.createElement("canvas");e.width=i,e.height=i;const t=e.getContext("2d"),n=t.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)"),t.fillStyle=n,t.fillRect(0,0,i,i),go=new wi(e),go}function RE(i){const t=document.createElement("canvas");t.width=128,t.height=128;const n=t.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=Xp(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 wi(t)}function DE(i){const e=document.createElement("canvas");e.width=128,e.height=128;const t=e.getContext("2d");return t.fillStyle="rgba(0, 0, 0, 0.55)",t.beginPath(),t.arc(64,64,60,0,Math.PI*2),t.fill(),t.fillStyle="#ffffff",t.font="bold 52px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(i,64,68),new wi(e)}function hl(i){let e=i;return function(){e|=0,e=e+1831565813|0;let n=Math.imul(e^e>>>15,1|e);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const hf=new Map;function CE(i){const e=i.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),t=e,n=t*Float32Array.BYTES_PER_ELEMENT;return{count:e,ra:new Float32Array(i,0*n,t),dec:new Float32Array(i,1*n,t),mag:new Float32Array(i,2*n,t),ci:new Float32Array(i,3*n,t)}}function PE(i){let e=hf.get(i);return e||(e=fetch(i).then(t=>t.arrayBuffer()).then(CE),hf.set(i,e)),e}const IE=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,LE=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,NE=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,UE=20,OE=1;class FE{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(e){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",e);return}}this.context.state==="suspended"&&this.context.resume()}setAmbient(e,t,n){if(this.requested={type:e,intensity:t,windSpeed:n},!this.context)return;this.paused&&(e="none",t=0,n=0);const s=e==="rain"||e==="hail"?e:"none";if(this.ambientVolume=s==="hail"?Math.min(1,t*1.3+.2):s==="rain"?t: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(IE,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/UE,1);const r=n>OE;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(LE,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(e){if(e===this.paused)return;this.paused=e;const{type:t,intensity:n,windSpeed:s}=this.requested;this.setAmbient(t,n,s)}playThunder(){!this.context||this.paused||this.playOneShot(NE,.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(e,t,n,s){if(t!==n()){e?.source.stop();return}s(e)}async startLoop(e,t){const n=this.context;if(n)try{const s=await this.getBuffer(e),r=n.createBufferSource();r.buffer=s,r.loop=!0;const a=n.createGain();return a.gain.value=t,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(e,t){const n=this.context;if(n)try{const s=await this.getBuffer(e),r=n.createBufferSource();r.buffer=s;const a=n.createGain();a.gain.value=t,r.connect(a).connect(n.destination),r.start()}catch(s){console.warn("Thunder sound failed to load:",s)}}async getBuffer(e){const t=this.context;if(!t)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(e);return n||(n=fetch(e).then(s=>{if(!s.ok)throw new Error(`Audio fetch failed (${s.status}): ${e}`);return s.arrayBuffer()}).then(s=>t.decodeAudioData(s)),this.buffers.set(e,n)),n}stopSource(e,t){try{e?.stop()}catch{}e?.disconnect(),t?.disconnect()}}class vi{constructor(e){this.elements=e;const{eccentricity:t,perihelionAu:n}=e,[s,r]=this.perifocalAxes(),a=Math.sqrt(vi.SUN_GM_AU3_PER_DAY2*(1+t)/n);this.perihelionPosition=this.scale(s,n),this.perihelionVelocity=this.scale(r,a),this.inverseSemiMajorAxis=(1-t)/n}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(e){const t=e-this.elements.perihelionJd,n=this.universalAnomaly(t),s=this.inverseSemiMajorAxis*n*n,r=this.elements.perihelionAu,a=1-n*n/r*vi.stumpffC(s),o=t-n*n*n/Math.sqrt(vi.SUN_GM_AU3_PER_DAY2)*vi.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(e){const t=this.positionAt(e);return Math.hypot(t.x,t.y,t.z)}universalAnomaly(e){if(e===0)return 0;const t=Math.sign(e),n=Math.sqrt(vi.SUN_GM_AU3_PER_DAY2)*Math.abs(e),s=o=>{const c=this.inverseSemiMajorAxis*o*o,l=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*l)*o*o*o*vi.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<vi.MAX_ITERATIONS&&r-a>1e-13*Math.max(1,r);o++){const c=(a+r)/2;s(c)<n?a=c:r=c}return t*(a+r)/2}perifocalAxes(){const e=this.elements.ascendingNodeDeg*Math.PI/180,t=this.elements.argumentOfPerihelionDeg*Math.PI/180,n=this.elements.inclinationDeg*Math.PI/180,s=Math.cos(e),r=Math.sin(e),a=Math.cos(t),o=Math.sin(t),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(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}static stumpffC(e){if(Math.abs(e)<1e-6)return 1/2-e/24+e*e/720;if(e>0)return(1-Math.cos(Math.sqrt(e)))/e;const t=Math.sqrt(-e);return(Math.cosh(t)-1)/-e}static stumpffS(e){if(Math.abs(e)<1e-6)return 1/6-e/120+e*e/5040;if(e>0){const n=Math.sqrt(e);return(n-Math.sin(n))/(n*n*n)}const t=Math.sqrt(-e);return(Math.sinh(t)-t)/(t*t*t)}}const qp=[{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 zE{static WINDOW_DAYS=200;static TWILIGHT_ELONGATION_DEG=15;static LIGHT_SPEED_AU_PER_DAY=173.144632674;static orbits=new Map;static aroundDate(e){const t=this.julianDayOf(e);return qp.filter(n=>Math.abs(t-n.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(e,t){return this.aroundDate(e).map(n=>this.appearanceOf(n,e,t)).sort((n,s)=>n.magnitude-s.magnitude)[0]}static appearanceOf(e,t,n){const s=Bt(t),r=this.earthPositionAt(s),a=this.apparentPositionOf(e,2451545+s.tt,r),o=this.subtract(a,r),c=this.length(a),l=this.length(o),h=this.tailEndAt(e,a,r,c,s,t,n),u=this.horizontalOf(o,s,t,n);return{apparition:e,position:u,...h,heliocentricDistanceAu:c,earthDistanceAu:l,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},r)),magnitude:this.magnitudeAt(e,c,l)}}static magnitudeAt(e,t,n){const s=e.absoluteMagnitude+5*Math.log10(n)+2.5*e.activityExponent*Math.log10(t);return Math.max(s,e.peakMagnitude)}static tailEndAt(e,t,n,s,r,a,o){if(e.tailLengthAu===void 0)return{};const c=1+e.tailLengthAu/s,l=this.subtract({x:t.x*c,y:t.y*c,z:t.z*c},n),h=this.subtract(t,n);return{tailEnd:this.horizontalOf(l,r,a,o),tailLengthDeg:this.angleBetween(h,l)}}static apparentPositionOf(e,t,n){const s=this.orbitOf(e);let r=s.positionAt(t);for(let a=0;a<2;a++){const o=this.length(this.subtract(r,n))/this.LIGHT_SPEED_AU_PER_DAY;r=s.positionAt(t-o)}return r}static horizontalOf(e,t,n,s){const r=bo(Ey(),new mt(e.x,e.y,e.z,t)),a=bo(by(t),r),o=ey(t,new hu(s.lat,s.lng,s.elevationM)),c=new mt(a.x-o.x,a.y-o.y,a.z-o.z,t),l=bp(c);return mr(l.ra,l.dec,n,s)}static earthPositionAt(e){return bo(Sy(),Xi(Se.Earth,e))}static julianDayOf(e){return 2451545+Bt(e).tt}static orbitOf(e){const t=this.orbits.get(e.id);if(t)return t;const n=new vi(e.orbit);return this.orbits.set(e.id,n),n}static subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}static length(e){return Math.hypot(e.x,e.y,e.z)}static angleBetween(e,t){const n=(e.x*t.x+e.y*t.y+e.z*t.z)/(this.length(e)*this.length(t)||1);return Math.acos(Math.min(1,Math.max(-1,n)))*180/Math.PI}}const BE=[{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}],Vo=6.5;class ul{static activeAt(e){return BE.flatMap(t=>{const n=this.nearness(t,e);return n<=0?[]:[{shower:t,zhr:t.peakZhr*n,nearness:n}]})}static nearness(e,t){const n=this.dayOfYear(t),s=this.dayOfYear(this.asDate(e.start)),r=this.dayOfYear(this.asDate(e.peak)),a=this.dayOfYear(this.asDate(e.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(e,t,n,s=Vo){if(t<=0)return 0;const r=Vo-s;return e*Math.sin(t*Math.PI/180)/Math.pow(n,r)}static radiantPosition(e,t,n){return mr(e.radiantRaHours,e.radiantDecDeg,t,n)}static dayOfYear(e){const t=Date.UTC(e.getUTCFullYear(),0,1);return Math.floor((Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())-t)/864e5)+1}static asDate(e){return new Date(Date.UTC(2001,e.month-1,e.day))}static wrappedDelta(e,t){const n=e-t;return n>182?n-365:n<-182?n+365:n}}class bt{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(e,t){const n=Bt(e),s=new cu(0,Q3(e).elon-90,1),r=bo(Ay(n),Ep(s,n)),a=bp(r);return mr(a.ra,a.dec,e,t)}static observedRatePerHour(e,t=Vo){const n=bt.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(e*Math.PI/180)),s=Vo-t;return(bt.QUIET_RATE_PER_HOUR+n)/Math.pow(bt.POPULATION_INDEX,s)}static schedule(e){const t=new Ip(e.seed^1542469173);return fs.schedule(e).map(n=>{const s=bt.toCartesian({altitudeDeg:Math.asin(t.next())*180/Math.PI,azimuthDeg:t.between(0,360)}),r=n.fromRadiantDeg*Math.PI/180,a=bt.turnAround(s,t.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:bt.toHorizontal(o),bearingDeg:bt.bearingFrom(o,s)}})}static turnAround(e,t){const[n,s]=bt.basisAround(e),r=t*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(e,t){const[n,s]=bt.basisAround(e),r=e.x*t.x+e.y*t.y+e.z*t.z,a=bt.normalise({x:t.x-e.x*r,y:t.y-e.y*r,z:t.z-e.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(e){const t=Math.abs(e.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=bt.normalise(bt.cross(e,t));return[n,bt.normalise(bt.cross(e,n))]}static toHorizontal(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{altitudeDeg:Math.asin(Math.min(1,Math.max(-1,e.y/t)))*180/Math.PI,azimuthDeg:(Math.atan2(e.x,-e.z)*180/Math.PI%360+360)%360}}static appearanceOf(e){const t=bt.toCartesian(e.radiant??{altitudeDeg:90,azimuthDeg:0}),n=bt.turnAround(t,e.bearingDeg),s=e.fromRadiantDeg*Math.PI/180;return bt.toHorizontal({x:t.x*Math.cos(s)+n.x*Math.sin(s),y:t.y*Math.cos(s)+n.y*Math.sin(s),z:t.z*Math.cos(s)+n.z*Math.sin(s)})}static toCartesian(e){const t=e.altitudeDeg*Math.PI/180,n=e.azimuthDeg*Math.PI/180,s=Math.cos(t);return{x:s*Math.sin(n),y:Math.sin(t),z:-s*Math.cos(n)}}static cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}static normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}static TYPICAL_VELOCITY_KM_S=40}class kE{lowerM;upperM;add(e,t){if(!(e<=0)){if(t.behindM!==void 0){const n=Zt.sizeMAt(t.behindM,e);this.lowerM=this.lowerM===void 0?n:Math.max(this.lowerM,n)}if(t.inFrontM!==void 0){const n=Zt.sizeMAt(t.inFrontM,e);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(e){return e<=0?{}:{minM:this.lowerM===void 0?void 0:Zt.distanceMAt(this.lowerM,e),maxM:this.upperM===void 0?void 0:Zt.distanceMAt(this.upperM,e)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class Jr{static DEG_PER_SECOND=360/86164.0905;static degOver(e){return Math.max(0,e)*Jr.DEG_PER_SECOND}static instants(e,t){if(!(t>0))return 1;const n=Jr.degOver(e)/t;return n<1?1:Math.min(Jr.MAX_INSTANTS,Math.max(2,Math.ceil(n)))}static MAX_INSTANTS=64}class _i{static PIXELS_PER_INSTANT=2;static INSTANTS_PER_FLASH=2;static MAX_INSTANTS=512;static instants(e,t,n,s,r){if(!(s>0))return 1;const a=r>0?_i.travelDegOver(e,t,n,n+s*1e3)/r/_i.PIXELS_PER_INSTANT:0,o=_i.flashesOver(e,s)*_i.INSTANTS_PER_FLASH,c=Math.ceil(Math.max(a,o));return c<2?1:Math.min(_i.MAX_INSTANTS,c)}static travelDegOver(e,t,n,s){let r=0;for(const a of e){if(!a.track||a.track.length<2)continue;const o=_i.directionAt(a,t,n),c=_i.directionAt(a,t,s),l=Math.min(1,Math.max(-1,o.x*c.x+o.y*c.y+o.z*c.z));r=Math.max(r,Math.acos(l)*180/Math.PI)}return r}static flashesOver(e,t){let n=0;for(const s of e)for(const r of s.lights??[])r.pattern.kind==="flash"&&(n=Math.max(n,r.pattern.perMinute));return n/60*t}static directionAt(e,t,n){const s=Up(e,n),r=s.eastM,a=s.altitudeM-t,o=s.northM,c=Math.hypot(r,a,o);return c===0?{x:0,y:1,z:0}:{x:r/c,y:a/c,z:o/c}}}xf();const HE={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"}},GE=["en","fr"],VE={en:"{name} — mag {mag}, {alt}° above the horizon",fr:"{name} — mag {mag}, {alt}° au-dessus de l'horizon"},WE={en:"{name} — mag {mag}, {alt}° below the horizontal",fr:"{name} — mag {mag}, {alt}° sous l'horizontale"},uf="comet:",XE={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"}},qE=new URL(""+new URL("stars-mag7.5-DDr9QasD.bin",import.meta.url).href,import.meta.url).href,YE={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},dl={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class KE extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","show-compass"]}shadow;stageElement;frameElement;sceneCanvas;ufoElement;sceneRenderer;hoverTooltip;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;meteorScheduleFor;lastTimeMs=0;starCatalog;weatherAudio=new FE;animateWhilePausedValue=!1;set animateWhilePaused(e){e!==this.animateWhilePausedValue&&(this.animateWhilePausedValue=e,this.syncAnimationsToPlayback())}get animateWhilePaused(){return this.animateWhilePausedValue}thunderTimeoutId;handleFullscreenChange=()=>this.resizeToStage();handlePointerMove=e=>{this.sceneRenderer.setCompassHovered(!0);const t=this.ufoElement.canvasElement,n=t.getBoundingClientRect();if(n.width===0||n.height===0)return;const s=(e.clientX-n.left)/n.width*t.width,r=(e.clientY-n.top)/n.height*t.height;if(this.ufoElement.hasVisibleShapeAt(s,r)){this.hoverTooltip.hidden=!0;return}const a=(e.clientX-n.left)/n.width*2-1,o=-((e.clientY-n.top)/n.height*2-1),c=Nh(vf.preferencesFor(this),GE),l=this.sceneRenderer.pickBodyAt(a,o);if(l){this.showHoverTooltip(e,this.bodyName(l,c));return}const h=this.sceneRenderer.pickDecorAt(a,o),u=h?this.ufoElement.sighting.decor.find(f=>f.id===h):void 0;if(u){this.showHoverTooltip(e,u.title||XE[u.kind][c]);return}const d=this.sceneRenderer.pickStarAt(a,o);if(d){const f=d.star.mag,g=d.altitudeDeg,x=(g<0?WE:VE)[c];this.showHoverTooltip(e,x.replace("{name}",d.star.name[c]).replace("{mag}",f.toLocaleString(void 0,{maximumFractionDigits:Math.abs(f)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(g)))));return}this.hoverTooltip.hidden=!0};bodyName(e,t){const n=e.startsWith(uf)?e.slice(uf.length):void 0;return(n?qp.find(r=>r.id===n):void 0)?.name[t]??HE[e]?.[t]??e}showHoverTooltip(e,t){this.hoverTooltip.textContent=t,this.hoverTooltip.hidden=!1;const n=this.stageElement.getBoundingClientRect();this.hoverTooltip.style.left=`${e.clientX-n.left+12}px`,this.hoverTooltip.style.top=`${e.clientY-n.top+12}px`}handlePointerLeave=()=>{this.hoverTooltip.hidden=!0,this.sceneRenderer.setCompassHovered(!1)};handleLightningFlash=()=>{clearTimeout(this.thunderTimeoutId);const e=(.5+Math.random()*3.5)*1e3;this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),e)};handleFirstInteraction=()=>{this.weatherAudio.resume(),this.setWeather(Eu(this.ufoElement.sighting,this.lastTimeMs))};handleTimeUpdate=e=>{this.lastTimeMs=e.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.updateUfoOcclusion(this.lastTimeMs)};syncAnimationsToPlayback(){const e=this.ufoElement.playbackState==="playing"||this.animateWhilePaused;this.sceneRenderer.setAnimationsRunning(e),this.weatherAudio.setPaused(!e),e||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${tm}</style>${em}`,this.shadow.appendChild(e.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 gi(this.sceneCanvas,void 0,this.handleLightningFlash),this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(gl),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 e=this.getAttribute("src");e&&this.loadFromSrc(e)}disconnectedCallback(){this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose()}attributeChangedCallback(e,t,n){e==="src"&&n&&n!==t&&this.isConnected&&this.loadFromSrc(n),e==="star-catalog-src"&&n!==t&&this.isConnected&&this.loadStars(),e==="show-compass"&&n!==t&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass"))}setCompassForced(e){this.sceneRenderer.setCompassForced(e)}setIndoorLook(e,t){this.sceneRenderer.setIndoorLook(e,t)}setWeather(e){this.sceneRenderer.setWeather(e),this.weatherAudio.setAmbient(e.precipitationType,e.precipitationIntensity,e.windSpeed)}pickDecorAt(e,t){return this.sceneRenderer.pickDecorAt(e,t)}resumeWeatherAudio(){this.weatherAudio.resume()}async loadFromSrc(e){this.sightingData=await ff.json(e)}get sightingData(){return this.ufoElement.sightingData}set sightingData(e){this.ufoElement.sightingData=e,this.applyFrameFormat(),this.lastTimeMs=0,this.updateAstronomy(0)}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}setTerrainProviders(e){this.sceneRenderer.setTerrainProviders(e)}setDecorModelProvider(e){this.sceneRenderer.setDecorModelProvider(e)}get decorModelCredits(){return this.sceneRenderer.currentDecorModelCredits}applyFrameFormat(){const e=this.ufoElement.sighting.instrument,t=Zt.CANVAS_HEIGHT_PX,n=Jt.frameWidthPx(e,t);this.frameElement.style.setProperty("--frame-aspect",`${n} / ${t}`)}resizeToStage(){const e=this.frameElement.getBoundingClientRect(),t=Math.max(1,Math.round(e.width)),n=Math.max(1,Math.round(e.height));this.sceneCanvas.width=t,this.sceneCanvas.height=n,this.sceneRenderer.resize(t,n)}async loadStars(){const e=this.getAttribute("star-catalog-src")??qE;this.starCatalog=await PE(e),this.updateAstronomy(this.lastTimeMs)}updateAstronomy(e){this.applySceneAt(e);const t=this.exposureSeconds(),n=this.degreesPerPixelAt(e),s=Jr.instants(t,n),r=Math.max(s,_i.instants(this.ufoElement.sighting.decor,Qs(this.ufoElement.sighting,e)?.elevationM??0,e,t,n));if(r<=1){this.sceneRenderer.setExposure(1);return}const a=t*1e3;this.sceneRenderer.setExposure(r,o=>this.applySceneAt(e+a*o/r,{sky:Math.floor(o*s/r)!==Math.floor((o-1)*s/r),stepMs:a/r}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(e){const t=this.sceneCanvas.height;return t<=0?0:Xr.fovOf(this.ufoElement.sighting,e)/t}applySceneAt(e,t){const n=this.ufoElement.sighting;this.setWeather(Eu(n,e)),this.sceneRenderer.setInstrument(n.instrument),this.updateMeteorShower(n,e),this.sceneRenderer.setDecor(n.decor);const s=Qs(n,e);if(this.sceneRenderer.setObserverPose(s??dl),this.sceneRenderer.setLensOptics(this.lensOpticsAt(e)),this.sceneRenderer.updateDecorAnchoring(Qs(n,0),s,e),this.sceneRenderer.updateDecorLitState(e,t?.stepMs??0),this.sceneRenderer.setTerrainOrigin(s?.lat,s?.lng),t&&!t.sky)return;const r=s?.lat??dl.lat,a=s?.lng??dl.lng,o=g0(n.event.time??{},a,n.event.utcOffsetHours);if(!o){this.sceneRenderer.setAstronomy(YE);return}const c=new Date(o.getTime()+e),l={lat:r,lng:a,elevationM:s?.elevationM??0},h={...Kc("Sun",c,l),magnitude:$c("Sun",c)},u={...Kc("Moon",c,l),phase:Ty(c),magnitude:$c("Moon",c)},d=wy.map(f=>({body:f,position:Kc(f,c,l),magnitude:$c(f,c)}));this.sceneRenderer.setAstronomy({sun:h,moon:u,planets:d,comet:this.cometAt(c,l),stars:this.starCatalog?{catalog:this.starCatalog,date:c,observer:l}:void 0,frame:{date:c,observer:l}})}cometAt(e,t){const n=zE.brightestAt(e,t);if(n)return{id:n.apparition.id,position:n.position,tailEnd:n.tailEnd,magnitude:n.magnitude}}updateUfoOcclusion(e){const t=this.ufoElement.sighting;t!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.sizeEstimatesFor=t);const n=t.timeline,s=this.ufoElement.canvasElement,r=new Set;for(const a of n.sourceIds){const o=n.getInterpolatedShapeAt(e,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(e).pxToDeg(o.bounds.width);this.sizeEstimateOf(a).add(h,this.sceneRenderer.decorDistancesAt(c,l,a))}this.ufoElement.setOccludedSourceIds(r)}sizeRangeOf(e){return this.sizeEstimateOf(e).sizeRange}distanceRangeAt(e,t){const n=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(t,e);if(!n)return{};const s=n.angular?.widthDeg??this.projectionAt(t).pxToDeg(n.bounds.width);return this.sizeEstimateOf(e).distanceRangeAt(s)}sizeContradictory(e){return this.sizeEstimateOf(e).contradictory}updateMeteorShower(e,t){this.ensureMeteorSchedule(e),this.sceneRenderer.updateMeteors(t)}ensureMeteorSchedule(e){const t=this.meteorInputsOf(e);t!==this.meteorScheduleFor&&(this.meteorScheduleFor=t,this.scheduleMeteors(e))}meteorInputsOf(e){const t=e.event.place?.[0],n=e.event.time;return JSON.stringify([t?.lat,t?.lng,n?.year,n?.month,n?.day,n?.hour,n?.minute,e.event.utcOffsetHours,e.event.durationSeconds,e.timeline.duration])}scheduleMeteors(e){const t=e.event.place?.[0],n=e.event.time,s=t?.lat!==void 0&&t.lng!==void 0&&n?.year!==void 0?g0(n,t.lng,e.event.utcOffsetHours):void 0;if(!s||t?.lat===void 0||t.lng===void 0){this.sceneRenderer.setMeteorShower([],0,0);return}const r={lat:t.lat,lng:t.lng,elevationM:0},a=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,o=Math.round(s.getTime()/1e3)+Math.round(t.lat*1e3),c=bt.schedule({ratePerHour:bt.observedRatePerHour(bt.apexPosition(s,r).altitudeDeg),durationMs:a,velocityKmS:bt.TYPICAL_VELOCITY_KM_S,seed:o}),l=ul.activeAt(s).map(u=>{const d=ul.radiantPosition(u.shower,s,r);return{entry:u,position:d,rate:ul.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=fs.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(e){this.ensureMeteorSchedule(this.ufoElement.sighting);const t=[...this.sceneRenderer.meteorSchedule].filter(r=>r.t+r.durationMs<=this.ufoElement.seekableDuration).sort((r,a)=>a.brightness-r.brightness);if(t.length===0)return;const n=t[e%t.length],s=this.sceneRenderer.meteorMidpoint(n);if(s)return{t:Math.round(n.t+n.durationMs*.45),...s}}lensOpticsAt(e){const t=this.ufoElement.sighting,n=t.instrument,s=n.frame,r=Qs(t,e),a=r?.fNumber??n.fNumber;if(!s||a===void 0)return;const o=Jt.focalLengthMmFor(n,Xr.fovOf(t,e));if(o!==void 0)return{focalLengthMm:o,fNumber:a,focusDistance:r?.focusDistanceM??0,frameHeightMm:s.heightMm}}projectionAt(e){const t=this.ufoElement.sighting;return nr.of(t.instrument,Zt.CANVAS_HEIGHT_PX,Xr.fovOf(t,e))}sizeEstimateOf(e){let t=this.sizeEstimates.get(e);return t||(t=new kE,this.sizeEstimates.set(e,t)),t}}const df="rr0-scene";function $E(){xf(),customElements.get(df)||customElements.define(df,KE)}$E();export{p1 as $,eb as A,dt as B,ve as C,K1 as D,Qe as E,ab as F,nb as G,Hf as H,tb as I,ib as J,yo as K,la as L,sb as M,Ma as N,_t as O,q1 as P,Ss as Q,Ao as R,Tn as S,ZE as T,Sn as U,Ie as V,dn as W,jE as X,xr as Y,kf as Z,rb as _,QE as a,Ro as a0,ih as a1,Lo as a2,Xt as a3,Yf as a4,Qh as a5,jh as a6,Je as a7,qi as a8,ca as a9,oi as aa,bi as ab,JE as b,lb as c,Co as d,cb as e,qe as f,P as g,fd as h,ob as i,hb as j,h1 as k,hs as l,ac as m,pg as n,At as o,Ot as p,wl as q,rn as r,Gf as s,Ai as t,M1 as u,T1 as v,Fn as w,gs as x,ct as y,wt as z};