@rr0/ufoathome 0.35.0 → 0.36.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 Gf=`
1
+ const qf=`
2
2
  <div class="toolbar" id="toolbar" hidden>
3
3
  <span id="testimony" class="testimony">
4
4
  <span id="testimony-prefix">Testimony by</span>
@@ -44,7 +44,7 @@ const Gf=`
44
44
  dropped into an article is there to be watched, and forty labels under it is a data sheet.
45
45
  Read-only here, unlike in the editor, where each one is a way back to its field. -->
46
46
  <div id="param-summary" class="param-summary" hidden></div>
47
- `,Vf=`
47
+ `,Yf=`
48
48
  :host {
49
49
  display: block;
50
50
  font-family: sans-serif;
@@ -311,7 +311,7 @@ const Gf=`
311
311
  margin: 0.4em 0 0;
312
312
  padding-left: 1.2em;
313
313
  }
314
- `;class qt{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/qt.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 tn(i,e,t){return i+(e-i)*t}function Ph(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=Ph(i),s=Ph(e);return!n||!s?t<1?i:e:Xf([tn(n[0],s[0],t),tn(n[1],s[1],t),tn(n[2],s[2],t)])}function Yf(i,e,t){const n={x:tn(i.bounds.x,e.bounds.x,t),y:tn(i.bounds.y,e.bounds.y,t),width:tn(i.bounds.width,e.bounds.width,t),height:tn(i.bounds.height,e.bounds.height,t)},s=tn(i.angle,e.angle,t),r=tn(i.transparency,e.transparency,t),a=tn(i.haloScale,e.haloScale,t),o=tn(i.blur??0,e.blur??0,t),l=tn(i.brightness??0,e.brightness??0,t),c=qf(i.color,e.color,t),h=qt.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:l,color:c,angular:h,behindCloud:t<1?i.behindCloud:e.behindCloud,points:i.points.map((u,d)=>({x:tn(u.x,e.points[d].x,t),y:tn(u.y,e.points[d].y,t)}))}:{...t<1?i:e,bounds:n,angle:s,transparency:r,haloScale:a,blur:o,brightness:l,color:c,angular:h}}class oo{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 oo;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 $f(i,e,t){const n=((e-i)%360+540)%360-180;return((i+n*t)%360+360)%360}function cs(i,e,t){return i+(e-i)*t}function Zf(i,e,t){return{lat:i.lat===void 0||e.lat===void 0?void 0:cs(i.lat,e.lat,t),lng:i.lng===void 0||e.lng===void 0?void 0:cs(i.lng,e.lng,t),elevationM:cs(i.elevationM,e.elevationM,t),headingDeg:i.headingDeg===void 0||e.headingDeg===void 0?void 0:$f(i.headingDeg,e.headingDeg,t),pitchDeg:cs(i.pitchDeg,e.pitchDeg,t),rollDeg:cs(i.rollDeg??0,e.rollDeg??0,t),fovDeg:cs(i.fovDeg,e.fovDeg,t),fNumber:i.fNumber,exposureSeconds:i.exposureSeconds,focusDistanceM:i.focusDistanceM}}class br{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?Zf(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 br;for(const n of e.keyframes)t.addKeyframe(n.t,n.pose);return t}}function di(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:di(i.cloudCover,e.cloudCover,t),cloudDarkness:di(i.cloudDarkness,e.cloudDarkness,t),highCloudCover:i.highCloudCover===void 0||e.highCloudCover===void 0?void 0:di(i.highCloudCover,e.highCloudCover,t),iceCrystalAlignment:i.iceCrystalAlignment===void 0||e.iceCrystalAlignment===void 0?void 0:di(i.iceCrystalAlignment,e.iceCrystalAlignment,t),lowerCloudCover:i.lowerCloudCover===void 0||e.lowerCloudCover===void 0?void 0:di(i.lowerCloudCover,e.lowerCloudCover,t),cloudBaseM:i.cloudBaseM===void 0||e.cloudBaseM===void 0?void 0:di(i.cloudBaseM,e.cloudBaseM,t),precipitationType:t<1?i.precipitationType:e.precipitationType,precipitationIntensity:di(i.precipitationIntensity,e.precipitationIntensity,t),windDirectionDeg:Jf(i.windDirectionDeg,e.windDirectionDeg,t),windSpeed:di(i.windSpeed,e.windSpeed,t),storm:t<1?i.storm:e.storm}}class Er{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 Er;for(const n of e.keyframes)t.addKeyframe(n.t,n.weather);return t}}class wr{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 wr;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 jd=1e3,ep=.65,e0={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,storm:!1},tp=100,np={kind:"none",volume:0,pitchHz:tp},zr=[{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:30},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:30},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 Ht{static get default(){return zr[0]}static byId(e){return zr.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:Ht.UNAIDED_FIELD_DEG}static aspectOf(e){const t=e.frame;return t?t.widthMm/t.heightMm:Ht.UNAIDED_ASPECT}static frameWidthPx(e,t){return Math.round(t*Ht.aspectOf(e))}static availableAt(e){return e===void 0?zr:zr.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??Ht.LENS_FLARE_ARTIFACTS}static starPointsOf(e){const t=e.apertureBlades;return t===void 0||t<3?0:t%2===0?t:t*2}}function Ih(i){if(i.raw!==void 0)return i.raw;if(i.year===void 0){if(i.hour===void 0)return"";let t=`${String(i.hour).padStart(2,"0")}:${String(i.minute??0).padStart(2,"0")}`;return i.second!==void 0&&(t+=`:${String(i.second).padStart(2,"0")}`),t}let e=String(i.year).padStart(4,"0");return i.month===void 0||(e+=`-${String(i.month).padStart(2,"0")}`,i.day===void 0)||(e+=`-${String(i.day).padStart(2,"0")}`,i.hour===void 0)||(e+=`T${String(i.hour).padStart(2,"0")}:${String(i.minute??0).padStart(2,"0")}`,i.second!==void 0&&(e+=`:${String(i.second).padStart(2,"0")}`)),e}function El(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 Lh(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 Nh(i,e){return e.filter(t=>i[t]!==void 0).join(",")}function t0(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=Nh(i.time,t);if(!(n===""||n!==Nh(i.endTime,t)))return e?El(i.endTime)-El(i.time):Lh(i.endTime)-Lh(i.time)}class lo{constructor(e,t,n,s,r,a,o,l,c=[],h,u){this.event=e,this.timeline=t,this.witnessTrack=n,this.weatherTrack=s,this.soundTrack=r,this.witness=a,this.caseId=o,this.weather=l,this.decor=c,this.weatherSource=h,this.instrumentId=u}get instrument(){return Ht.byId(this.instrumentId)}static create(e,t,n){return new lo({eventType:"sighting",time:e,place:t},new oo,new br,new Er,new wr,n)}}const rp=0,ap=0;function Ai(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:rp,headingDeg:void 0,pitchDeg:ap,fovDeg:Ht.fieldOfViewDeg(i.instrument)}}function wl(i,e){return i.weatherTrack.getInterpolatedWeatherAt(e)??i.weather??e0}function n0(i,e){return i.soundTrack.getInterpolatedSoundAt(e)??np}const op=2;function lp(i){return i==="building"||i==="vehicle"}function i0(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 cp(i,e){return i.pattern.kind==="steady"?!0:hp(i,e,e+1)>.5}function hp(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,l=e/o+r,c=t/o+r;if(c<=l)return Math.min(Math.max(l-Math.floor(l),0),a)<a?1:0;const h=u=>Math.floor(u)*a+Math.min(u-Math.floor(u),a);return(h(c)-h(l))/(c-l)}function s0(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 Uh(t[0],i);const s=t[t.length-1];if(e>=s.t)return Uh(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 l=o.t-a.t,c=l===0?0:(e-a.t)/l;return{eastM:a.eastM+(o.eastM-a.eastM)*c,northM:a.northM+(o.northM-a.northM)*c,altitudeM:(a.altitudeM??0)+((o.altitudeM??0)-(a.altitudeM??0))*c,headingDeg:a.headingDeg??i.headingDeg}}return n}function Uh(i,e){return{eastM:i.eastM,northM:i.northM,altitudeM:i.altitudeM??0,headingDeg:i.headingDeg??e.headingDeg}}const Fh="#ff2200",Oh="#00ff44",Ui="#ffffff",Br="#ffa500",hs="#ff0000",up="#2244ff",dp=[{id:"airliner",name:"Airliner",kinds:["aircraft"],create:()=>[{id:"nav-port",offsetM:{x:-17,y:0,z:0},color:Fh,pattern:{kind:"steady"}},{id:"nav-starboard",offsetM:{x:17,y:0,z:0},color:Oh,pattern:{kind:"steady"}},{id:"nav-tail",offsetM:{x:0,y:1,z:-18},color:Ui,pattern:{kind:"steady"}},{id:"beacon-top",offsetM:{x:0,y:2,z:0},color:hs,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.18}},{id:"beacon-bottom",offsetM:{x:0,y:-2,z:0},color:hs,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.18}},{id:"strobe-port",offsetM:{x:-17,y:0,z:-1},color:Ui,intensity:4,pattern:{kind:"flash",perMinute:60,dutyCycle:.01}},{id:"strobe-starboard",offsetM:{x:17,y:0,z:-1},color:Ui,intensity:4,pattern:{kind:"flash",perMinute:60,dutyCycle:.01,phase:.08}}]},{id:"helicopter",name:"Helicopter",kinds:["aircraft"],create:()=>[{id:"nav-port",offsetM:{x:-5,y:0,z:0},color:Fh,pattern:{kind:"steady"}},{id:"nav-starboard",offsetM:{x:5,y:0,z:0},color:Oh,pattern:{kind:"steady"}},{id:"nav-tail",offsetM:{x:0,y:1,z:-7},color:Ui,pattern:{kind:"steady"}},{id:"beacon",offsetM:{x:0,y:2,z:-2},color:hs,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.2}},{id:"strobe",offsetM:{x:0,y:-1,z:0},color:Ui,intensity:3,pattern:{kind:"flash",perMinute:75,dutyCycle:.015}}]},{id:"car-headlights",name:"Car, headlights on",kinds:["vehicle"],create:()=>[{id:"head-left",offsetM:{x:-.7,y:.6,z:2},color:Ui,intensity:2,pattern:{kind:"steady"}},{id:"head-right",offsetM:{x:.7,y:.6,z:2},color:Ui,intensity:2,pattern:{kind:"steady"}},{id:"tail-left",offsetM:{x:-.7,y:.6,z:-2},color:hs,pattern:{kind:"steady"}},{id:"tail-right",offsetM:{x:.7,y:.6,z:-2},color:hs,pattern:{kind:"steady"}}]},{id:"car-hazards",name:"Car, hazard flashers",kinds:["vehicle"],create:()=>[{id:"hazard-front-left",offsetM:{x:-.8,y:.6,z:2},color:Br,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-front-right",offsetM:{x:.8,y:.6,z:2},color:Br,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-rear-left",offsetM:{x:-.8,y:.6,z:-2},color:Br,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-rear-right",offsetM:{x:.8,y:.6,z:-2},color:Br,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}}]},{id:"emergency-beacons",name:"Emergency vehicle beacons",kinds:["vehicle"],create:()=>[{id:"beacon-blue",offsetM:{x:-.4,y:1.6,z:0},color:up,intensity:2.5,pattern:{kind:"flash",perMinute:120,dutyCycle:.1}},{id:"beacon-red",offsetM:{x:.4,y:1.6,z:0},color:hs,intensity:2.5,pattern:{kind:"flash",perMinute:120,dutyCycle:.1,phase:.5}}]},{id:"streetlamp",name:"Streetlamp",kinds:["streetlight"],create:()=>[{id:"lamp",offsetM:{x:0,y:5,z:0},color:"#ffd9a0",intensity:2,pattern:{kind:"steady"}}]}];class zh{constructor(e,t){this.labels=e,this.language=t}entriesFor(e,t,n={}){const s=[];return this.addObservation(s,e),this.addWitness(s,e,t),this.addLocation(s,e,t,n.groundElevationM),this.addDecor(s,e,t,n.decorId),this.addTemporal(s,e),this.addWeather(s,e,t),this.addSound(s,e,t),this.addShape(s,e,t,n.sourceId),s}push(e,t,n,s,r,a="",o={}){r===void 0||r===""||e.push({group:t,field:n,label:s,value:String(r),unit:a,color:o.color,fromSource:o.fromSource===!0})}percent(e){return e===void 0?void 0:`${Math.round(e*100)} %`}rounded(e,t=0){return e===void 0?void 0:String(Number(e.toFixed(t)))}addObservation(e,t){this.push(e,"observation","caseId",this.labels.caseId,t.caseId);const n=t.event.tags;this.push(e,"observation","tags",this.labels.tags,n&&n.length>0?n.join(", "):void 0)}addWitness(e,t,n){const s=t.witness;this.push(e,"witness","witnessId",this.labels.witnessId,s?.id),this.push(e,"witness","witnessTitle",this.labels.witnessTitle,s?.title),this.push(e,"witness","witnessLastName",this.labels.witnessLastName,s?.lastName);const r=s?.firstNames;this.push(e,"witness","witnessFirstNames",this.labels.witnessFirstNames,r&&r.length>0?r.join(", "):void 0);const a=t.instrument;this.push(e,"witness","instrument",this.labels.instrument,a.name[this.language]);const o=Ai(t,n);if(o){const l=Ht.focalLengthMmFor(a,o.fovDeg);l===void 0?this.push(e,"witness","focalLength",this.labels.fieldOfView,this.rounded(o.fovDeg,1),"°"):this.push(e,"witness","focalLength",this.labels.focalLength,this.rounded(l,1),"mm"),this.push(e,"witness","fNumber",this.labels.aperture,this.rounded(o.fNumber??a.fNumber,1));const c=o.exposureSeconds??a.exposureSeconds;this.push(e,"witness","exposureSeconds",this.labels.exposure,c===void 0?void 0:c<1?`1/${Math.round(1/c)}`:this.rounded(c,2),"s"),this.push(e,"witness","focusDistance",this.labels.focusDistance,this.rounded(o.focusDistanceM,1),"m"),this.push(e,"witness","roll",this.labels.roll,o.rollDeg===void 0||o.rollDeg===0?void 0:this.rounded(o.rollDeg),"°")}}addLocation(e,t,n,s){const r=t.event.place?.[0];this.push(e,"location","placeName",this.labels.placeName,r?.name);const a=Ai(t,n);a&&(this.push(e,"location","lat",this.labels.latitude,this.rounded(a.lat,6)),this.push(e,"location","lng",this.labels.longitude,this.rounded(a.lng,6)),this.push(e,"location","heading",this.labels.heading,this.rounded(a.headingDeg),"°"),this.push(e,"location","pitch",this.labels.pitch,this.rounded(a.pitchDeg),"°"),s===void 0?this.push(e,"location","elevation",this.labels.heightAboveGround,a.elevationM===0?void 0:this.rounded(a.elevationM),"m"):this.push(e,"location","elevation",this.labels.elevation,this.rounded(s+a.elevationM),"m"))}addDecor(e,t,n,s){const r=t.decor.find(c=>c.id===s);if(!r){for(const c of t.decor)this.push(e,"decor",`decor:${c.id}`,this.decorLabel(c),this.decorKindName(c.kind));return}this.push(e,"decor","decorTitle",this.labels.decorTitle,r.title);const a=s0(r,n);this.push(e,"decor","decorEast",this.labels.decorEast,this.rounded(a.eastM,1),"m"),this.push(e,"decor","decorNorth",this.labels.decorNorth,this.rounded(a.northM,1),"m"),this.push(e,"decor","decorAltitude",this.labels.decorAltitude,this.rounded(a.altitudeM),"m"),this.push(e,"decor","decorHeading",this.labels.decorHeading,this.rounded(a.headingDeg),"°"),i0(r,n)&&this.push(e,"decor","decorLit",this.labels.decorLit,"✓");const o=r.lights?.map(c=>c.id).join()??"",l=o===""?void 0:dp.find(c=>c.create().map(h=>h.id).join()===o);this.push(e,"decor","decorLightRig",this.labels.decorLights,l?.name),this.push(e,"decor","decorFloors",this.labels.decorFloors,r.floors),this.push(e,"decor","decorOccupiedFloor",this.labels.decorOccupiedFloor,r.occupiedFloor),this.push(e,"decor","decorWitnessSide",this.labels.decorWitnessSide,this.decorSideName(r.witnessSide));for(const[c,h]of Object.entries(r.windows??{}))this.push(e,"decor",`decorWindow${this.capitalise(c)}`,`${this.labels.decorWindows} ${this.decorSideName(c)}`,h,"%")}addTemporal(e,t){const n=t.event;this.push(e,"temporal","obs-time",this.labels.observationTime,n.time&&Ih(n.time)),this.push(e,"temporal","obs-end-time",this.labels.observationEndTime,n.endTime&&Ih(n.endTime));const s=t0(n);this.push(e,"temporal","durationSeconds",this.labels.duration,this.rounded(s&&s/1e3,1),"s"),this.push(e,"temporal","timeZone",this.labels.utcOffset,n.timeZone),this.push(e,"temporal","utcOffsetHours",this.labels.utcOffset,this.rounded(n.utcOffsetHours,1),"UTC±h")}addWeather(e,t,n){const s=wl(t,n),a={fromSource:t.weatherSource!==void 0};this.push(e,"weather","cloudCover",this.labels.cloudCover,this.percent(s.cloudCover),"",a),this.push(e,"weather","highCloudCover",this.labels.highCloudCover,this.percent(s.highCloudCover),"",a),this.push(e,"weather","iceCrystalAlignment",this.labels.iceCrystalAlignment,this.percent(s.iceCrystalAlignment)),this.push(e,"weather","cloudDarkness",this.labels.cloudDarkness,this.percent(s.cloudDarkness),"",a),this.push(e,"weather","cloudBase",this.labels.cloudBase,this.rounded(s.cloudBaseM),"m",a),this.push(e,"weather","precipitationType",this.labels.precipitationType,s.precipitationType==="none"?void 0:this.precipitationName(s.precipitationType),"",a),this.push(e,"weather","precipitationIntensity",this.labels.precipitationIntensity,s.precipitationType==="none"?void 0:this.percent(s.precipitationIntensity),"",a),this.push(e,"weather","windDirection",this.labels.windDirection,this.rounded(s.windDirectionDeg),"°",a),this.push(e,"weather","windSpeed",this.labels.windSpeed,this.rounded(s.windSpeed,2),"m/s",a),s.storm&&this.push(e,"weather","storm",this.labels.storm,"✓","",a)}addSound(e,t,n){const s=n0(t,n);s.kind!=="none"&&(this.push(e,"sound","soundKind",this.labels.soundKind,this.soundKindName(s.kind)),this.push(e,"sound","soundVolume",this.labels.soundVolume,this.percent(s.volume)),this.push(e,"sound","soundPitch",this.labels.soundPitch,this.rounded(s.pitchHz),"Hz"),this.push(e,"sound","soundSrc",this.labels.soundSrc,s.src))}addShape(e,t,n,s){if(s===void 0)return;const r=t.timeline.getInterpolatedShapeAt(n,s);r&&(this.push(e,"shape","shapeTitle",this.labels.shapeTitle,r.title),this.push(e,"shape","color",this.labels.color,r.color,"",{color:r.color}),this.push(e,"shape","transparency",this.labels.transparency,this.percent(r.transparency)),this.push(e,"shape","haloScale",this.labels.halo,this.rounded(r.haloScale,2)),this.push(e,"shape","blur",this.labels.blur,r.blur===void 0||r.blur===0?void 0:this.percent(r.blur)),this.push(e,"shape","brightness",this.labels.brightness,r.brightness===void 0||r.brightness===0?void 0:this.percent(r.brightness)))}decorLabel(e){return e.title??this.decorKindName(e.kind)}decorKindName(e){switch(e){case"building":return this.labels.decorBuilding;case"tree":return this.labels.decorTree;case"streetlight":return this.labels.decorStreetlight;case"vehicle":return this.labels.decorVehicle;case"aircraft":return this.labels.decorAircraft;default:return this.labels.decorWitness}}decorSideName(e){switch(e){case"front":return this.labels.decorSideFront;case"behind":return this.labels.decorSideBehind;case"left":return this.labels.decorSideLeft;case"right":return this.labels.decorSideRight;case"front-left":return this.labels.decorSideFrontLeft;case"front-right":return this.labels.decorSideFrontRight;case"behind-left":return this.labels.decorSideBehindLeft;case"behind-right":return this.labels.decorSideBehindRight;default:return}}precipitationName(e){switch(e){case"rain":return this.labels.precipitationRain;case"snow":return this.labels.precipitationSnow;case"hail":return this.labels.precipitationHail;default:return this.labels.precipitationNone}}soundKindName(e){switch(e){case"hum":return this.labels.soundHum;case"whistle":return this.labels.soundWhistle;case"rumble":return this.labels.soundRumble;case"crackle":return this.labels.soundCrackle;default:return this.labels.soundNone}}capitalise(e){return e.replace(/(^|-)([a-z])/g,(t,n,s)=>s.toUpperCase())}}const fp=`
314
+ `;class qt{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/qt.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 Kf(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 nn(i,e,t){return i+(e-i)*t}function Fh(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 $f(i){return`#${i.map(e=>Math.round(e).toString(16).padStart(2,"0")).join("")}`}function Zf(i,e,t){const n=Fh(i),s=Fh(e);return!n||!s?t<1?i:e:$f([nn(n[0],s[0],t),nn(n[1],s[1],t),nn(n[2],s[2],t)])}function Jf(i,e,t){const n={x:nn(i.bounds.x,e.bounds.x,t),y:nn(i.bounds.y,e.bounds.y,t),width:nn(i.bounds.width,e.bounds.width,t),height:nn(i.bounds.height,e.bounds.height,t)},s=nn(i.angle,e.angle,t),r=nn(i.transparency,e.transparency,t),a=nn(i.haloScale,e.haloScale,t),o=nn(i.blur??0,e.blur??0,t),l=nn(i.brightness??0,e.brightness??0,t),c=Zf(i.color,e.color,t),h=qt.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:l,color:c,angular:h,behindCloud:t<1?i.behindCloud:e.behindCloud,points:i.points.map((u,d)=>({x:nn(u.x,e.points[d].x,t),y:nn(u.y,e.points[d].y,t)}))}:{...t<1?i:e,bounds:n,angle:s,transparency:r,haloScale:a,blur:o,brightness:l,color:c,angular:h}}class co{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?Jf(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&&Kf(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 co;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 Qf(i,e,t){return Math.max(e,Math.min(t,i))}function jf(i,e,t){const n=((e-i)%360+540)%360-180;return((i+n*t)%360+360)%360}function us(i,e,t){return i+(e-i)*t}function ep(i,e,t){return{lat:i.lat===void 0||e.lat===void 0?void 0:us(i.lat,e.lat,t),lng:i.lng===void 0||e.lng===void 0?void 0:us(i.lng,e.lng,t),elevationM:us(i.elevationM,e.elevationM,t),headingDeg:i.headingDeg===void 0||e.headingDeg===void 0?void 0:jf(i.headingDeg,e.headingDeg,t),pitchDeg:us(i.pitchDeg,e.pitchDeg,t),rollDeg:us(i.rollDeg??0,e.rollDeg??0,t),fovDeg:us(i.fovDeg,e.fovDeg,t),fNumber:i.fNumber,focusDistanceM:i.focusDistanceM}}class Tr{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?ep(n.pose,s.pose,Qf((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 Tr;for(const n of e.keyframes)t.addKeyframe(n.t,n.pose);return t}}function pi(i,e,t){return i+(e-i)*t}function tp(i,e,t){const n=((e-i)%360+540)%360-180;return((i+n*t)%360+360)%360}function np(i,e,t){return Math.max(e,Math.min(t,i))}function ip(i,e,t){return{cloudCover:pi(i.cloudCover,e.cloudCover,t),cloudDarkness:pi(i.cloudDarkness,e.cloudDarkness,t),highCloudCover:i.highCloudCover===void 0||e.highCloudCover===void 0?void 0:pi(i.highCloudCover,e.highCloudCover,t),iceCrystalAlignment:i.iceCrystalAlignment===void 0||e.iceCrystalAlignment===void 0?void 0:pi(i.iceCrystalAlignment,e.iceCrystalAlignment,t),lowerCloudCover:i.lowerCloudCover===void 0||e.lowerCloudCover===void 0?void 0:pi(i.lowerCloudCover,e.lowerCloudCover,t),cloudBaseM:i.cloudBaseM===void 0||e.cloudBaseM===void 0?void 0:pi(i.cloudBaseM,e.cloudBaseM,t),precipitationType:t<1?i.precipitationType:e.precipitationType,precipitationIntensity:pi(i.precipitationIntensity,e.precipitationIntensity,t),windDirectionDeg:tp(i.windDirectionDeg,e.windDirectionDeg,t),windSpeed:pi(i.windSpeed,e.windSpeed,t),storm:t<1?i.storm:e.storm}}class Rr{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?ip(n.weather,s.weather,np((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 Rr;for(const n of e.keyframes)t.addKeyframe(n.t,n.weather);return t}}class Cr{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 Cr;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 s0=1e3,sp=.65,r0={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,storm:!1},rp=100,ap={kind:"none",volume:0,pitchHz:rp},Hr=[{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 Ht{static get default(){return Hr[0]}static byId(e){return Hr.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:Ht.UNAIDED_FIELD_DEG}static aspectOf(e){const t=e.frame;return t?t.widthMm/t.heightMm:Ht.UNAIDED_ASPECT}static frameWidthPx(e,t){return Math.round(t*Ht.aspectOf(e))}static availableAt(e){return e===void 0?Hr:Hr.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??Ht.LENS_FLARE_ARTIFACTS}static starPointsOf(e){const t=e.apertureBlades;return t===void 0||t<3?0:t%2===0?t:t*2}}function Oh(i){if(i.raw!==void 0)return i.raw;if(i.year===void 0){if(i.hour===void 0)return"";let t=`${String(i.hour).padStart(2,"0")}:${String(i.minute??0).padStart(2,"0")}`;return i.second!==void 0&&(t+=`:${String(i.second).padStart(2,"0")}`),t}let e=String(i.year).padStart(4,"0");return i.month===void 0||(e+=`-${String(i.month).padStart(2,"0")}`,i.day===void 0)||(e+=`-${String(i.day).padStart(2,"0")}`,i.hour===void 0)||(e+=`T${String(i.hour).padStart(2,"0")}:${String(i.minute??0).padStart(2,"0")}`,i.second!==void 0&&(e+=`:${String(i.second).padStart(2,"0")}`)),e}function Tl(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 zh(i){return(((i.day??0)*24+(i.hour??0))*60+(i.minute??0))*6e4+(i.second??0)*1e3}const op=["year","month","day","hour","minute"],lp=["day","hour","minute"];function Bh(i,e){return e.filter(t=>i[t]!==void 0).join(",")}function a0(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?op:lp,n=Bh(i.time,t);if(!(n===""||n!==Bh(i.endTime,t)))return e?Tl(i.endTime)-Tl(i.time):zh(i.endTime)-zh(i.time)}class ho{constructor(e,t,n,s,r,a,o,l,c=[],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=l,this.decor=c,this.weatherSource=h,this.instrumentId=u,this.exposureSeconds=d}get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return Ht.byId(this.instrumentId)}static create(e,t,n){return new ho({eventType:"sighting",time:e,place:t},new co,new Tr,new Rr,new Cr,n)}}const cp=0,hp=0;function Ai(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:cp,headingDeg:void 0,pitchDeg:hp,fovDeg:Ht.fieldOfViewDeg(i.instrument)}}function Rl(i,e){return i.weatherTrack.getInterpolatedWeatherAt(e)??i.weather??r0}function o0(i,e){return i.soundTrack.getInterpolatedSoundAt(e)??ap}const up=2;function dp(i){return i==="building"||i==="vehicle"}function l0(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 fp(i,e){return i.pattern.kind==="steady"?!0:c0(i,e,e+1)>.5}function c0(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,l=e/o+r,c=t/o+r;if(c<=l)return Math.min(Math.max(l-Math.floor(l),0),a)<a?1:0;const h=u=>Math.floor(u)*a+Math.min(u-Math.floor(u),a);return(h(c)-h(l))/(c-l)}function Qc(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 kh(t[0],i);const s=t[t.length-1];if(e>=s.t)return kh(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 l=o.t-a.t,c=l===0?0:(e-a.t)/l;return{eastM:a.eastM+(o.eastM-a.eastM)*c,northM:a.northM+(o.northM-a.northM)*c,altitudeM:(a.altitudeM??0)+((o.altitudeM??0)-(a.altitudeM??0))*c,headingDeg:a.headingDeg??i.headingDeg}}return n}function kh(i,e){return{eastM:i.eastM,northM:i.northM,altitudeM:i.altitudeM??0,headingDeg:i.headingDeg??e.headingDeg}}const Hh="#ff2200",Gh="#00ff44",Oi="#ffffff",Gr="#ffa500",ds="#ff0000",pp="#2244ff",mp=[{id:"airliner",name:"Airliner",kinds:["aircraft"],create:()=>[{id:"nav-port",offsetM:{x:-17,y:0,z:0},color:Hh,pattern:{kind:"steady"}},{id:"nav-starboard",offsetM:{x:17,y:0,z:0},color:Gh,pattern:{kind:"steady"}},{id:"nav-tail",offsetM:{x:0,y:1,z:-18},color:Oi,pattern:{kind:"steady"}},{id:"beacon-top",offsetM:{x:0,y:2,z:0},color:ds,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.18}},{id:"beacon-bottom",offsetM:{x:0,y:-2,z:0},color:ds,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.18}},{id:"strobe-port",offsetM:{x:-17,y:0,z:-1},color:Oi,intensity:20,pattern:{kind:"flash",perMinute:60,dutyCycle:.01}},{id:"strobe-starboard",offsetM:{x:17,y:0,z:-1},color:Oi,intensity:20,pattern:{kind:"flash",perMinute:60,dutyCycle:.01,phase:.08}}]},{id:"helicopter",name:"Helicopter",kinds:["aircraft"],create:()=>[{id:"nav-port",offsetM:{x:-5,y:0,z:0},color:Hh,pattern:{kind:"steady"}},{id:"nav-starboard",offsetM:{x:5,y:0,z:0},color:Gh,pattern:{kind:"steady"}},{id:"nav-tail",offsetM:{x:0,y:1,z:-7},color:Oi,pattern:{kind:"steady"}},{id:"beacon",offsetM:{x:0,y:2,z:-2},color:ds,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.2}},{id:"strobe",offsetM:{x:0,y:-1,z:0},color:Oi,intensity:15,pattern:{kind:"flash",perMinute:75,dutyCycle:.015}}]},{id:"car-headlights",name:"Car, headlights on",kinds:["vehicle"],create:()=>[{id:"head-left",offsetM:{x:-.7,y:.6,z:2},color:Oi,intensity:2,pattern:{kind:"steady"}},{id:"head-right",offsetM:{x:.7,y:.6,z:2},color:Oi,intensity:2,pattern:{kind:"steady"}},{id:"tail-left",offsetM:{x:-.7,y:.6,z:-2},color:ds,pattern:{kind:"steady"}},{id:"tail-right",offsetM:{x:.7,y:.6,z:-2},color:ds,pattern:{kind:"steady"}}]},{id:"car-hazards",name:"Car, hazard flashers",kinds:["vehicle"],create:()=>[{id:"hazard-front-left",offsetM:{x:-.8,y:.6,z:2},color:Gr,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-front-right",offsetM:{x:.8,y:.6,z:2},color:Gr,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-rear-left",offsetM:{x:-.8,y:.6,z:-2},color:Gr,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-rear-right",offsetM:{x:.8,y:.6,z:-2},color:Gr,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}}]},{id:"emergency-beacons",name:"Emergency vehicle beacons",kinds:["vehicle"],create:()=>[{id:"beacon-blue",offsetM:{x:-.4,y:1.6,z:0},color:pp,intensity:2.5,pattern:{kind:"flash",perMinute:120,dutyCycle:.1}},{id:"beacon-red",offsetM:{x:.4,y:1.6,z:0},color:ds,intensity:2.5,pattern:{kind:"flash",perMinute:120,dutyCycle:.1,phase:.5}}]},{id:"streetlamp",name:"Streetlamp",kinds:["streetlight"],create:()=>[{id:"lamp",offsetM:{x:0,y:5,z:0},color:"#ffd9a0",intensity:2,pattern:{kind:"steady"}}]}];class Vh{constructor(e,t){this.labels=e,this.language=t}entriesFor(e,t,n={}){const s=[];return this.addObservation(s,e),this.addWitness(s,e,t),this.addLocation(s,e,t,n.groundElevationM),this.addDecor(s,e,t,n.decorId),this.addTemporal(s,e),this.addWeather(s,e,t),this.addSound(s,e,t),this.addShape(s,e,t,n.sourceId),s}push(e,t,n,s,r,a="",o={}){r===void 0||r===""||e.push({group:t,field:n,label:s,value:String(r),unit:a,color:o.color,fromSource:o.fromSource===!0})}percent(e){return e===void 0?void 0:`${Math.round(e*100)} %`}rounded(e,t=0){return e===void 0?void 0:String(Number(e.toFixed(t)))}addObservation(e,t){this.push(e,"observation","caseId",this.labels.caseId,t.caseId);const n=t.event.tags;this.push(e,"observation","tags",this.labels.tags,n&&n.length>0?n.join(", "):void 0)}addWitness(e,t,n){const s=t.witness;this.push(e,"witness","witnessId",this.labels.witnessId,s?.id),this.push(e,"witness","witnessTitle",this.labels.witnessTitle,s?.title),this.push(e,"witness","witnessLastName",this.labels.witnessLastName,s?.lastName);const r=s?.firstNames;this.push(e,"witness","witnessFirstNames",this.labels.witnessFirstNames,r&&r.length>0?r.join(", "):void 0);const a=t.instrument;this.push(e,"witness","instrument",this.labels.instrument,a.name[this.language]);const o=t.exposure;this.push(e,"witness","exposureSeconds",this.labels.exposure,o===void 0?void 0:o<1?`1/${Math.round(1/o)}`:this.rounded(o,2),"s");const l=Ai(t,n);if(l){const c=Ht.focalLengthMmFor(a,l.fovDeg);c===void 0?this.push(e,"witness","focalLength",this.labels.fieldOfView,this.rounded(l.fovDeg,1),"°"):this.push(e,"witness","focalLength",this.labels.focalLength,this.rounded(c,1),"mm"),this.push(e,"witness","fNumber",this.labels.aperture,this.rounded(l.fNumber??a.fNumber,1)),this.push(e,"witness","focusDistance",this.labels.focusDistance,this.rounded(l.focusDistanceM,1),"m"),this.push(e,"witness","roll",this.labels.roll,l.rollDeg===void 0||l.rollDeg===0?void 0:this.rounded(l.rollDeg),"°")}}addLocation(e,t,n,s){const r=t.event.place?.[0];this.push(e,"location","placeName",this.labels.placeName,r?.name);const a=Ai(t,n);a&&(this.push(e,"location","lat",this.labels.latitude,this.rounded(a.lat,6)),this.push(e,"location","lng",this.labels.longitude,this.rounded(a.lng,6)),this.push(e,"location","heading",this.labels.heading,this.rounded(a.headingDeg),"°"),this.push(e,"location","pitch",this.labels.pitch,this.rounded(a.pitchDeg),"°"),s===void 0?this.push(e,"location","elevation",this.labels.heightAboveGround,a.elevationM===0?void 0:this.rounded(a.elevationM),"m"):this.push(e,"location","elevation",this.labels.elevation,this.rounded(s+a.elevationM),"m"))}addDecor(e,t,n,s){const r=t.decor.find(c=>c.id===s);if(!r){for(const c of t.decor)this.push(e,"decor",`decor:${c.id}`,this.decorLabel(c),this.decorKindName(c.kind));return}this.push(e,"decor","decorTitle",this.labels.decorTitle,r.title);const a=Qc(r,n);this.push(e,"decor","decorEast",this.labels.decorEast,this.rounded(a.eastM,1),"m"),this.push(e,"decor","decorNorth",this.labels.decorNorth,this.rounded(a.northM,1),"m"),this.push(e,"decor","decorAltitude",this.labels.decorAltitude,this.rounded(a.altitudeM),"m"),this.push(e,"decor","decorHeading",this.labels.decorHeading,this.rounded(a.headingDeg),"°"),l0(r,n)&&this.push(e,"decor","decorLit",this.labels.decorLit,"✓");const o=r.lights?.map(c=>c.id).join()??"",l=o===""?void 0:mp.find(c=>c.create().map(h=>h.id).join()===o);this.push(e,"decor","decorLightRig",this.labels.decorLights,l?.name),this.push(e,"decor","decorFloors",this.labels.decorFloors,r.floors),this.push(e,"decor","decorOccupiedFloor",this.labels.decorOccupiedFloor,r.occupiedFloor),this.push(e,"decor","decorWitnessSide",this.labels.decorWitnessSide,this.decorSideName(r.witnessSide));for(const[c,h]of Object.entries(r.windows??{}))this.push(e,"decor",`decorWindow${this.capitalise(c)}`,`${this.labels.decorWindows} ${this.decorSideName(c)}`,h,"%")}addTemporal(e,t){const n=t.event;this.push(e,"temporal","obs-time",this.labels.observationTime,n.time&&Oh(n.time)),this.push(e,"temporal","obs-end-time",this.labels.observationEndTime,n.endTime&&Oh(n.endTime));const s=a0(n);this.push(e,"temporal","durationSeconds",this.labels.duration,this.rounded(s&&s/1e3,1),"s"),this.push(e,"temporal","timeZone",this.labels.utcOffset,n.timeZone),this.push(e,"temporal","utcOffsetHours",this.labels.utcOffset,this.rounded(n.utcOffsetHours,1),"UTC±h")}addWeather(e,t,n){const s=Rl(t,n),a={fromSource:t.weatherSource!==void 0};this.push(e,"weather","cloudCover",this.labels.cloudCover,this.percent(s.cloudCover),"",a),this.push(e,"weather","highCloudCover",this.labels.highCloudCover,this.percent(s.highCloudCover),"",a),this.push(e,"weather","iceCrystalAlignment",this.labels.iceCrystalAlignment,this.percent(s.iceCrystalAlignment)),this.push(e,"weather","cloudDarkness",this.labels.cloudDarkness,this.percent(s.cloudDarkness),"",a),this.push(e,"weather","cloudBase",this.labels.cloudBase,this.rounded(s.cloudBaseM),"m",a),this.push(e,"weather","precipitationType",this.labels.precipitationType,s.precipitationType==="none"?void 0:this.precipitationName(s.precipitationType),"",a),this.push(e,"weather","precipitationIntensity",this.labels.precipitationIntensity,s.precipitationType==="none"?void 0:this.percent(s.precipitationIntensity),"",a),this.push(e,"weather","windDirection",this.labels.windDirection,this.rounded(s.windDirectionDeg),"°",a),this.push(e,"weather","windSpeed",this.labels.windSpeed,this.rounded(s.windSpeed,2),"m/s",a),s.storm&&this.push(e,"weather","storm",this.labels.storm,"✓","",a)}addSound(e,t,n){const s=o0(t,n);s.kind!=="none"&&(this.push(e,"sound","soundKind",this.labels.soundKind,this.soundKindName(s.kind)),this.push(e,"sound","soundVolume",this.labels.soundVolume,this.percent(s.volume)),this.push(e,"sound","soundPitch",this.labels.soundPitch,this.rounded(s.pitchHz),"Hz"),this.push(e,"sound","soundSrc",this.labels.soundSrc,s.src))}addShape(e,t,n,s){if(s===void 0)return;const r=t.timeline.getInterpolatedShapeAt(n,s);r&&(this.push(e,"shape","shapeTitle",this.labels.shapeTitle,r.title),this.push(e,"shape","color",this.labels.color,r.color,"",{color:r.color}),this.push(e,"shape","transparency",this.labels.transparency,this.percent(r.transparency)),this.push(e,"shape","haloScale",this.labels.halo,this.rounded(r.haloScale,2)),this.push(e,"shape","blur",this.labels.blur,r.blur===void 0||r.blur===0?void 0:this.percent(r.blur)),this.push(e,"shape","brightness",this.labels.brightness,r.brightness===void 0||r.brightness===0?void 0:this.percent(r.brightness)))}decorLabel(e){return e.title??this.decorKindName(e.kind)}decorKindName(e){switch(e){case"building":return this.labels.decorBuilding;case"tree":return this.labels.decorTree;case"streetlight":return this.labels.decorStreetlight;case"vehicle":return this.labels.decorVehicle;case"aircraft":return this.labels.decorAircraft;default:return this.labels.decorWitness}}decorSideName(e){switch(e){case"front":return this.labels.decorSideFront;case"behind":return this.labels.decorSideBehind;case"left":return this.labels.decorSideLeft;case"right":return this.labels.decorSideRight;case"front-left":return this.labels.decorSideFrontLeft;case"front-right":return this.labels.decorSideFrontRight;case"behind-left":return this.labels.decorSideBehindLeft;case"behind-right":return this.labels.decorSideBehindRight;default:return}}precipitationName(e){switch(e){case"rain":return this.labels.precipitationRain;case"snow":return this.labels.precipitationSnow;case"hail":return this.labels.precipitationHail;default:return this.labels.precipitationNone}}soundKindName(e){switch(e){case"hum":return this.labels.soundHum;case"whistle":return this.labels.soundWhistle;case"rumble":return this.labels.soundRumble;case"crackle":return this.labels.soundCrackle;default:return this.labels.soundNone}}capitalise(e){return e.replace(/(^|-)([a-z])/g,(t,n,s)=>s.toUpperCase())}}const gp=`
315
315
  <div class="stage" id="stage">
316
316
  <div class="frame" id="frame">
317
317
  <canvas id="scene-canvas"></canvas>
@@ -319,7 +319,7 @@ const Gf=`
319
319
  <div id="ufo-slot"></div>
320
320
  <div id="hover-tooltip" class="hover-tooltip" hidden></div>
321
321
  </div>
322
- `,pp=`
322
+ `,vp=`
323
323
  :host {
324
324
  display: block;
325
325
  }
@@ -408,7 +408,7 @@ const Gf=`
408
408
  pointer-events: none;
409
409
  white-space: nowrap;
410
410
  }
411
- `,mp=`
411
+ `,xp=`
412
412
  <div class="stage" id="stage">
413
413
  <div class="frame" id="frame">
414
414
  <canvas id="canvas" width="640" height="360"></canvas>
@@ -423,7 +423,7 @@ const Gf=`
423
423
  <button id="loop" type="button" title="Auto-replay" aria-label="Auto-replay" aria-pressed="true">↻</button>
424
424
  </div>
425
425
  </div>
426
- `,gp=`
426
+ `,_p=`
427
427
  :host {
428
428
  display: block;
429
429
  font-family: sans-serif;
@@ -639,21 +639,21 @@ input[type=range] {
639
639
  pointer-events: none;
640
640
  white-space: nowrap;
641
641
  }
642
- `;class vp{constructor(e,t){this.timeline=e,this.onFrame=t}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;durationOverrideMs=0;get seekableDuration(){return Math.max(this.timeline.duration,this.durationOverrideMs)}play(){if(this.state==="playing")return;this.currentT>=this.seekableDuration&&(this.currentT=0,this.resolveFrame(0)),this.state="playing",this.lastWallTime=performance.now();const 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);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 r0=["nw","n","ne","e","se","s","sw","w"],_p=24,kr=8,xp=3,Mp=8;function Hr(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 js(i){return{x:i.x+i.width/2,y:i.y+i.height/2}}const yp={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 hn{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-_p}},o=js(e.bounds),l={};for(const c of Object.keys(a))l[c]=Hr(a[c],o,e.angle);return l}static hitTestHandle(e,t,n=8,s=[...r0,"rotate"]){const r=hn.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=((hn.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=js(e),a=Hr(s,r,-t),{x:o,y:l,width:c,height:h}=e,u=yp[n];let d=o,f=l,g=o+c,x=l+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=hn.resizeBounds(e.bounds,e.angle,t,n);if(e.kind==="oval")return{...e,bounds:a};const o=s===0?1:a.width/s,l=r===0?1:a.height/r;return{...e,bounds:a,points:e.points.map(c=>({x:c.x*o,y:c.y*l}))}}static rotateShape(e,t){const n=js(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=js(e.bounds);return e.points.map(n=>Hr({x:e.bounds.x+n.x,y:e.bounds.y+n.y},t,e.angle))}static hitTestVertex(e,t,n=Mp){const s=hn.vertexPointsFor(e);let r,a=n;return s.forEach((o,l)=>{const c=Math.hypot(t.x-o.x,t.y-o.y);c<=a&&(a=c,r=l)}),r}static toLocalPoint(e,t){const n=js(e.bounds),s=Hr(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?hn.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)),l=Math.max(...s.map(u=>u.y)),c={x:e.bounds.x+r,y:e.bounds.y+a,width:o-r,height:l-a},h=s.map(u=>({x:u.x-r,y:u.y-a}));return{...e,bounds:c,points:h}}static insertVertexNear(e,t){const n=hn.toLocalPoint(e,t),{points:s}=e;let r=s.length-1,a=1/0;for(let l=0;l<s.length;l++){const c=s[l],h=s[(l+1)%s.length],u=hn.distanceToSegment(n,c,h);u<a&&(a=u,r=l)}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)),l=t.x+o*s,c=t.y+o*r;return Math.hypot(e.x-l,e.y-c)}static deleteVertex(e,t){return e.points.length<=xp?e:{...e,points:e.points.filter((n,s)=>s!==t)}}}const Al=6,Gr=Al/2,Sp=20,bp=24,Ep=9,Bh=6,wp=7,kh=4;class Ap{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(${(bp*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,l=s+a/2,c=Math.max(r,a)/2,h=c*(1+Ep*t);if(h<=0)return;this.ctx.save(),this.ctx.globalCompositeOperation="lighter";const u=this.ctx.createRadialGradient(o,l,0,o,l,h);for(let d=0;d<=Bh;d++){const f=d/Bh,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,l,h,0,2*Math.PI),this.ctx.fill(),this.starPoints>0){const d=c*(1+wp*t);this.ctx.lineWidth=Math.max(1,c*.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=l+Math.sin(g)*d,p=this.ctx.createLinearGradient(o,l,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,l),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=Sp*e.haloScale,this.paintBase(e),this.ctx.restore()}paintSelectionHandles(e){this.paintHandleFrame(hn.handlePointsFor(e),{includeRotate:!0}),e.kind==="polygon"&&this.paintVertexHandles(e)}paintVertexHandles(e){this.ctx.fillStyle="#39f";for(const t of hn.vertexPointsFor(e))this.ctx.beginPath(),this.ctx.ellipse(t.x,t.y,kh,kh,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(e){this.paintOutline(hn.handlePointsFor(e))}paintGroupHandles(e){this.paintHandleFrame(hn.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 r0){const s=e[n];this.ctx.fillRect(s.x-Gr,s.y-Gr,Al,Al)}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,Gr+1,Gr+1,0,0,2*Math.PI),this.ctx.fill())}}const Hh=.05,Gh=.08,Vh=2,Wh=3,Tp=14,Rp=.02;class Cp{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(l){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",l);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*Vh),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*Vh),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*Wh),e.sampleRate),n=t.getChannelData(0),s=Math.max(1,Math.floor(Rp*e.sampleRate)),r=Math.round(Wh*Tp);for(let a=0;a<r;a++){const o=Math.floor(Math.random()*n.length),l=.4+Math.random()*.6;for(let c=0;c<s&&o+c<n.length;c++)n[o+c]=Math.max(n[o+c],l*(1-c/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,Gh/3);const s=n+Gh;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 Mo=Math.PI/180,Vr=180/Math.PI;class zs{constructor(e,t,n){this.kind=e,this.canvasHeightPx=t,this.fovDeg=n;const s=n*Mo/2;this.focalPx=e==="equidistant"?t/2/s:t/2/Math.tan(s)}focalPx;static of(e,t,n){return new zs(e.projection,t,n)}degToPx(e){const t=e*Mo;return this.kind==="equidistant"?this.focalPx*t:2*this.focalPx*Math.tan(t/2)}pxToDeg(e){return this.kind==="equidistant"?e/this.focalPx*Vr:2*Math.atan(e/(2*this.focalPx))*Vr}angleDegToRadiusPx(e){const t=e*Mo;return this.kind==="equidistant"?this.focalPx*t:this.focalPx*Math.tan(t)}radiusPxToAngleDeg(e){return this.kind==="equidistant"?e/this.focalPx*Vr:Math.atan(e/this.focalPx)*Vr}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(qt.angularWidthDeg(e))}}class Wa{static fovOf(e,t){return Ai(e,t)?.fovDeg??Ht.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,l=t.bounds.height===0?1:r/t.bounds.height;return{...t,bounds:a,points:t.points.map(c=>({x:c.x*o,y:c.y*l}))}})}static reproject(e,t,n){const s=Ht.frameWidthPx(t,qt.CANVAS_HEIGHT_PX)/2,r=Ht.frameWidthPx(e.instrument,qt.CANVAS_HEIGHT_PX)/2,a=qt.CANVAS_HEIGHT_PX/2;for(const o of[...e.timeline.allKeyframes]){const l=this.fovOf(e,o.t),c=n?.get(o.t)??l,h=zs.of(t,qt.CANVAS_HEIGHT_PX,c),u=zs.of(e.instrument,qt.CANVAS_HEIGHT_PX,l);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,E={...f,x:r+g*p-f.width/2,y:a+x*p-f.height/2};return{...d,shape:{...d.shape,bounds:E}}}))}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=zs.of(e.instrument,qt.CANVAS_HEIGHT_PX,r);n.addKeyframe(s.t,s.shapes.map(o=>({...o,shape:t(o.shape,a)})))}}}function Dp(i){return Wa.toAngular(i),{version:1,time:i.event.time,endTime:i.event.endTime,durationSeconds:i.event.durationSeconds,utcOffsetHours:i.event.utcOffsetHours,timeZone:i.event.timeZone,place:i.event.place,witness:i.witness,caseId:i.caseId,description:i.event.description,tags:i.event.tags,timeline:i.timeline.toJSON(),witnessTrack:i.witnessTrack.toJSON(),weatherTrack:i.weatherTrack.toJSON(),soundTrack:i.soundTrack.toJSON(),weather:i.weather,decor:i.decor,weatherSource:i.weatherSource,instrument:i.instrumentId}}function Pp(i){const e=new lo({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},oo.fromJSON(i.timeline),i.witnessTrack?br.fromJSON(i.witnessTrack):new br,i.weatherTrack?Er.fromJSON(i.weatherTrack):new Er,i.soundTrack?wr.fromJSON(i.soundTrack):new wr,i.witness,i.caseId,i.weather,i.decor??[],i.weatherSource,i.instrument);return Wa.toBounds(e),e}function co(i,e){for(const t of i){const n=t.toLowerCase().split("-")[0];if(e.includes(n))return n}return"en"}const Ip="modulepreload",Lp=function(i,e){return new URL(i,e).href},Xh={},Xa=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"),l=document.querySelector("meta[property=csp-nonce]"),c=l?.nonce||l?.getAttribute("nonce");s=a(t.map(h=>{if(h=Lp(h,n),h in Xh)return;Xh[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":Ip,u||(g.as="script"),g.crossOrigin="",g.href=h,c&&g.setAttribute("nonce",c),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)})},a0=["en","fr"],Np={en:()=>Xa(()=>Promise.resolve().then(()=>zp),void 0,import.meta.url).then(i=>i.ufoMessages_en),fr:()=>Xa(()=>import("./UfoMessages_fr-Hq24iVzT.js"),[],import.meta.url).then(i=>i.ufoMessages_fr)};function Up(i){return Np[i]()}const Fp={en:()=>Xa(()=>Promise.resolve().then(()=>$y),void 0,import.meta.url).then(i=>i.eyewitnessMessages_en),fr:()=>Xa(()=>import("./EyewitnessMessages_fr-BHImAxjF.js"),[],import.meta.url).then(i=>i.eyewitnessMessages_fr)};function Op(i){return Fp[i]()}const o0={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"},zp=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:o0},Symbol.toStringTag,{value:"Module"})),qh=new Set;class xr extends HTMLElement{static get observedAttributes(){return["src"]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;loopButton;fullscreenButton;seekInput;timeStartLabel;timeEndLabel;currentSighting=lo.create();sightingAudio=new Cp;soundPreview;player;loopEnabled=!0;highlightedSourceIds=new Set;occludedSourceIds=qh;enableClickToPlay=!0;fullscreenTarget;messages=o0;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>this.updateFullscreenButton();handlePointerMove=e=>{const t=this.canvasPointFromEvent(e),n=t&&this.currentSighting.timeline.hitTest(this.currentTime,t.x,t.y,this.occludedSourceIds);if(!n?.shape.title){this.tooltip.hidden=!0;return}this.tooltip.textContent=n.shape.title,this.tooltip.hidden=!1;const s=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${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>${gp}</style>${mp}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Ap(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",()=>{this.enableClickToPlay&&this.togglePlayPause()}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.refresh(),this.loadLocaleMessages()}connectedCallback(){const 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){const t=await fetch(e);this.sightingData=await t.json()}get sightingData(){return Dp(this.currentSighting)}set sightingData(e){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=Pp(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}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.currentSighting.timeline.hitTest(this.currentTime,e,t,this.occludedSourceIds)!==void 0}refresh(){this.applyFrameFormat(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.player.seek(this.player.time)}exposureInstants(e){const t=(Ai(this.currentSighting,e)?.exposureSeconds??0)*1e3,n=()=>[{shapes:this.shapesAt(e),share:1}];if(t<xr.SHORTEST_VISIBLE_EXPOSURE_MS)return n();const s=Math.min(xr.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(t/xr.SHORTEST_VISIBLE_EXPOSURE_MS))),r=[];for(let a=0;a<s;a++)r.push({shapes:this.shapesAt(e+t*a/s),share:1/s});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;applyFrameFormat(){const e=Ht.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(Ht.starPointsOf(this.sighting.instrument)),this.canvasRenderer.setRoll((Ai(this.sighting,e)?.rollDeg??0)*Math.PI/180);for(const s of this.exposureInstants(e))for(const[r,a]of s.shapes){if(this.occludedSourceIds.has(r))continue;const o=s.share,l=o===1?a:{...a,transparency:1-(1-a.transparency)*o},c=n.has(r)&&o===1;c&&n.size===1?this.canvasRenderer.paintShape({...l,selected:!0}):(this.canvasRenderer.paintShape(l),c&&this.canvasRenderer.paintMemberOutline(l))}if(n.size>1){const s=hn.groupBoundsFor([...t].filter(([r])=>n.has(r)).map(([,r])=>r.bounds));this.canvasRenderer.paintGroupHandles(s)}this.seekInput.value=String(e),this.timeStartLabel.textContent=this.formatPosition(e),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(n0(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 vp(this.currentSighting.timeline,(t,n)=>this.onFrame(t,n));return e.loop=this.loopEnabled,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}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=co(navigator.languages,a0);e!=="en"&&this.applyMessages(await Up(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=t0(e);this.realDurationMs=t!==void 0&&t>0?t:void 0,this.realStartMs=e.time?El(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 Wr(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)):Wr(n)}formatEndOfTimeline(){return this.realDurationMs===void 0?Wr(this.currentSighting.timeline.duration):this.canShowClockTime?Kh(Yh(this.realStartMs+this.realDurationMs)):Wr(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 Wr(i){const e=Math.round(i/1e3),t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,"0")}`}const Tl="rr0-ufo";function l0(){customElements.get(Tl)||customElements.define(Tl,xr)}/**
642
+ `;class Mp{constructor(e,t){this.timeline=e,this.onFrame=t}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;durationOverrideMs=0;get seekableDuration(){return Math.max(this.timeline.duration,this.durationOverrideMs)}play(){if(this.state==="playing")return;this.currentT>=this.seekableDuration&&(this.currentT=0,this.resolveFrame(0)),this.state="playing",this.lastWallTime=performance.now();const 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);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 h0=["nw","n","ne","e","se","s","sw","w"],yp=24,Vr=8,Sp=3,bp=8;function Wr(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 nr(i){return{x:i.x+i.width/2,y:i.y+i.height/2}}const Ep={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 dn{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-yp}},o=nr(e.bounds),l={};for(const c of Object.keys(a))l[c]=Wr(a[c],o,e.angle);return l}static hitTestHandle(e,t,n=8,s=[...h0,"rotate"]){const r=dn.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=((dn.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=nr(e),a=Wr(s,r,-t),{x:o,y:l,width:c,height:h}=e,u=Ep[n];let d=o,f=l,g=o+c,_=l+h;return u.left&&(d=Math.min(a.x,g-Vr)),u.right&&(g=Math.max(a.x,d+Vr)),u.top&&(f=Math.min(a.y,_-Vr)),u.bottom&&(_=Math.max(a.y,f+Vr)),{x:d,y:f,width:g-d,height:_-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=dn.resizeBounds(e.bounds,e.angle,t,n);if(e.kind==="oval")return{...e,bounds:a};const o=s===0?1:a.width/s,l=r===0?1:a.height/r;return{...e,bounds:a,points:e.points.map(c=>({x:c.x*o,y:c.y*l}))}}static rotateShape(e,t){const n=nr(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=nr(e.bounds);return e.points.map(n=>Wr({x:e.bounds.x+n.x,y:e.bounds.y+n.y},t,e.angle))}static hitTestVertex(e,t,n=bp){const s=dn.vertexPointsFor(e);let r,a=n;return s.forEach((o,l)=>{const c=Math.hypot(t.x-o.x,t.y-o.y);c<=a&&(a=c,r=l)}),r}static toLocalPoint(e,t){const n=nr(e.bounds),s=Wr(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?dn.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)),l=Math.max(...s.map(u=>u.y)),c={x:e.bounds.x+r,y:e.bounds.y+a,width:o-r,height:l-a},h=s.map(u=>({x:u.x-r,y:u.y-a}));return{...e,bounds:c,points:h}}static insertVertexNear(e,t){const n=dn.toLocalPoint(e,t),{points:s}=e;let r=s.length-1,a=1/0;for(let l=0;l<s.length;l++){const c=s[l],h=s[(l+1)%s.length],u=dn.distanceToSegment(n,c,h);u<a&&(a=u,r=l)}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)),l=t.x+o*s,c=t.y+o*r;return Math.hypot(e.x-l,e.y-c)}static deleteVertex(e,t){return e.points.length<=Sp?e:{...e,points:e.points.filter((n,s)=>s!==t)}}}const Cl=6,Xr=Cl/2,wp=20,Ap=24,Tp=9,Wh=6,Rp=7,Xh=4;class Cp{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(${(Ap*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,l=s+a/2,c=Math.max(r,a)/2,h=c*(1+Tp*t);if(h<=0)return;this.ctx.save(),this.ctx.globalCompositeOperation="lighter";const u=this.ctx.createRadialGradient(o,l,0,o,l,h);for(let d=0;d<=Wh;d++){const f=d/Wh,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,l,h,0,2*Math.PI),this.ctx.fill(),this.starPoints>0){const d=c*(1+Rp*t);this.ctx.lineWidth=Math.max(1,c*.12),this.ctx.lineCap="round";for(let f=0;f<this.starPoints;f++){const g=f/this.starPoints*Math.PI*2+this.roll,_=o+Math.cos(g)*d,m=l+Math.sin(g)*d,p=this.ctx.createLinearGradient(o,l,_,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,l),this.ctx.lineTo(_,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=wp*e.haloScale,this.paintBase(e),this.ctx.restore()}paintSelectionHandles(e){this.paintHandleFrame(dn.handlePointsFor(e),{includeRotate:!0}),e.kind==="polygon"&&this.paintVertexHandles(e)}paintVertexHandles(e){this.ctx.fillStyle="#39f";for(const t of dn.vertexPointsFor(e))this.ctx.beginPath(),this.ctx.ellipse(t.x,t.y,Xh,Xh,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(e){this.paintOutline(dn.handlePointsFor(e))}paintGroupHandles(e){this.paintHandleFrame(dn.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 h0){const s=e[n];this.ctx.fillRect(s.x-Xr,s.y-Xr,Cl,Cl)}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,Xr+1,Xr+1,0,0,2*Math.PI),this.ctx.fill())}}const qh=.05,Yh=.08,Kh=2,$h=3,Dp=14,Pp=.02;class Ip{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,qh);for(const{param:r,ratio:a}of e.pitch)r.setTargetAtTime(Math.min(t.pitchHz*a,n.sampleRate/2-1),s,qh)}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(l){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",l);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*Kh),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*Kh),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*$h),e.sampleRate),n=t.getChannelData(0),s=Math.max(1,Math.floor(Pp*e.sampleRate)),r=Math.round($h*Dp);for(let a=0;a<r;a++){const o=Math.floor(Math.random()*n.length),l=.4+Math.random()*.6;for(let c=0;c<s&&o+c<n.length;c++)n[o+c]=Math.max(n[o+c],l*(1-c/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,Yh/3);const s=n+Yh;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 bo=Math.PI/180,qr=180/Math.PI;class ks{constructor(e,t,n){this.kind=e,this.canvasHeightPx=t,this.fovDeg=n;const s=n*bo/2;this.focalPx=e==="equidistant"?t/2/s:t/2/Math.tan(s)}focalPx;static of(e,t,n){return new ks(e.projection,t,n)}degToPx(e){const t=e*bo;return this.kind==="equidistant"?this.focalPx*t:2*this.focalPx*Math.tan(t/2)}pxToDeg(e){return this.kind==="equidistant"?e/this.focalPx*qr:2*Math.atan(e/(2*this.focalPx))*qr}angleDegToRadiusPx(e){const t=e*bo;return this.kind==="equidistant"?this.focalPx*t:this.focalPx*Math.tan(t)}radiusPxToAngleDeg(e){return this.kind==="equidistant"?e/this.focalPx*qr:Math.atan(e/this.focalPx)*qr}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(qt.angularWidthDeg(e))}}class Sr{static fovOf(e,t){return Ai(e,t)?.fovDeg??Ht.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,l=t.bounds.height===0?1:r/t.bounds.height;return{...t,bounds:a,points:t.points.map(c=>({x:c.x*o,y:c.y*l}))}})}static reproject(e,t,n){const s=Ht.frameWidthPx(t,qt.CANVAS_HEIGHT_PX)/2,r=Ht.frameWidthPx(e.instrument,qt.CANVAS_HEIGHT_PX)/2,a=qt.CANVAS_HEIGHT_PX/2;for(const o of[...e.timeline.allKeyframes]){const l=this.fovOf(e,o.t),c=n?.get(o.t)??l,h=ks.of(t,qt.CANVAS_HEIGHT_PX,c),u=ks.of(e.instrument,qt.CANVAS_HEIGHT_PX,l);e.timeline.addKeyframe(o.t,o.shapes.map(d=>{const{bounds:f}=d.shape,g=f.x+f.width/2-s,_=f.y+f.height/2-a,m=Math.hypot(g,_),p=m===0?1:u.angleDegToRadiusPx(h.radiusPxToAngleDeg(m))/m,E={...f,x:r+g*p-f.width/2,y:a+_*p-f.height/2};return{...d,shape:{...d.shape,bounds:E}}}))}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=ks.of(e.instrument,qt.CANVAS_HEIGHT_PX,r);n.addKeyframe(s.t,s.shapes.map(o=>({...o,shape:t(o.shape,a)})))}}}function Lp(i){return Sr.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 Np(i){const e=new ho({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},co.fromJSON(i.timeline),i.witnessTrack?Tr.fromJSON(i.witnessTrack):new Tr,i.weatherTrack?Rr.fromJSON(i.weatherTrack):new Rr,i.soundTrack?Cr.fromJSON(i.soundTrack):new Cr,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 Sr.toBounds(e),e}function uo(i,e){for(const t of i){const n=t.toLowerCase().split("-")[0];if(e.includes(n))return n}return"en"}const Up="modulepreload",Fp=function(i,e){return new URL(i,e).href},Zh={},Ya=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"),l=document.querySelector("meta[property=csp-nonce]"),c=l?.nonce||l?.getAttribute("nonce");s=a(t.map(h=>{if(h=Fp(h,n),h in Zh)return;Zh[h]=!0;const u=h.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(!!n)for(let _=o.length-1;_>=0;_--){const m=o[_];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":Up,u||(g.as="script"),g.crossOrigin="",g.href=h,c&&g.setAttribute("nonce",c),document.head.appendChild(g),u)return new Promise((_,m)=>{g.addEventListener("load",_),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)})},u0=["en","fr"],Op={en:()=>Ya(()=>Promise.resolve().then(()=>Hp),void 0,import.meta.url).then(i=>i.ufoMessages_en),fr:()=>Ya(()=>import("./UfoMessages_fr-Hq24iVzT.js"),[],import.meta.url).then(i=>i.ufoMessages_fr)};function zp(i){return Op[i]()}const Bp={en:()=>Ya(()=>Promise.resolve().then(()=>jy),void 0,import.meta.url).then(i=>i.eyewitnessMessages_en),fr:()=>Ya(()=>import("./EyewitnessMessages_fr-BHImAxjF.js"),[],import.meta.url).then(i=>i.eyewitnessMessages_fr)};function kp(i){return Bp[i]()}const d0={play:"Play",pause:"Pause",noDuration:"No observation duration",autoReplay:"Auto-replay",currentPosition:"Current position",duration:"Duration",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen"},Hp=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:d0},Symbol.toStringTag,{value:"Module"})),Jh=new Set;class qi extends HTMLElement{static get observedAttributes(){return["src"]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;loopButton;fullscreenButton;seekInput;timeStartLabel;timeEndLabel;currentSighting=ho.create();sightingAudio=new Ip;soundPreview;player;loopEnabled=!0;highlightedSourceIds=new Set;occludedSourceIds=Jh;enableClickToPlay=!0;fullscreenTarget;messages=d0;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>${_p}</style>${xp}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Cp(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",()=>{this.enableClickToPlay&&this.togglePlayPause()}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.refresh(),this.loadLocaleMessages()}connectedCallback(){const 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){const t=await fetch(e);this.sightingData=await t.json()}get sightingData(){return Lp(this.currentSighting)}set sightingData(e){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=Np(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}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<qi.SHORTEST_VISIBLE_EXPOSURE_MS)return[e];const n=Math.min(qi.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(t/qi.SHORTEST_VISIBLE_EXPOSURE_MS))),s=Math.ceil(this.travelPxOver(e,t)/qi.EXPOSURE_STEP_PX),r=Math.min(qi.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 l=s.get(a);if(!l)continue;const c=l.bounds.x+l.bounds.width/2-(o.bounds.x+o.bounds.width/2),h=l.bounds.y+l.bounds.height/2-(o.bounds.y+o.bounds.height/2);r=Math.max(r,Math.hypot(c,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=Ht.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:Jh;this.canvasRenderer.setStarPoints(Ht.starPointsOf(this.sighting.instrument)),this.canvasRenderer.setRoll((Ai(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 l=r.share,c=l===1?o:{...o,transparency:1-(1-o.transparency)*l};this.canvasRenderer.paintShape(c)}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=dn.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(o0(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 Mp(this.currentSighting.timeline,(t,n)=>this.onFrame(t,n));return e.loop=this.loopEnabled,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}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=uo(navigator.languages,u0);e!=="en"&&this.applyMessages(await zp(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=a0(e);this.realDurationMs=t!==void 0&&t>0?t:void 0,this.realStartMs=e.time?Tl(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 Yr(e);const t=this.currentSighting.timeline.duration,n=t>0&&e<=t?e/t*this.realDurationMs:e;return this.canShowClockTime?jh(Qh(this.realStartMs+n)):Yr(n)}formatEndOfTimeline(){return this.realDurationMs===void 0?Yr(this.currentSighting.timeline.duration):this.canShowClockTime?jh(Qh(this.realStartMs+this.realDurationMs)):Yr(this.realDurationMs)}}function Qh(i){const e=new Date(i);return{hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds()}}function jh(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 Yr(i){const e=Math.round(i/1e3),t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,"0")}`}const Dl="rr0-ufo";function f0(){customElements.get(Dl)||customElements.define(Dl,qi)}/**
643
643
  * @license
644
644
  * Copyright 2010-2026 Three.js Authors
645
645
  * SPDX-License-Identifier: MIT
646
- */const $c="185",Bp=0,$h=1,kp=2,Mr=1,Hp=2,fr=3,Ci=0,Dt=1,Tn=2,ri=0,Bs=1,Di=2,Zh=3,Jh=4,Gp=5,Wi=100,Vp=101,Wp=102,Xp=103,qp=104,Yp=200,Kp=201,$p=202,Zp=203,Rl=204,Cl=205,Jp=206,Qp=207,jp=208,em=209,tm=210,nm=211,im=212,sm=213,rm=214,Dl=0,Pl=1,Il=2,Ys=3,Ll=4,Nl=5,Ul=6,Fl=7,Zc=0,am=1,om=2,Kn=0,c0=1,h0=2,u0=3,d0=4,f0=5,p0=6,m0=7,g0=300,Qi=301,Ks=302,yo=303,So=304,ho=306,Ol=1e3,fn=1001,zl=1002,Ct=1003,lm=1004,Xr=1005,Tt=1006,bo=1007,Ki=1008,dn=1009,v0=1010,_0=1011,Ar=1012,Jc=1013,Dn=1014,Xn=1015,mn=1016,Qc=1017,jc=1018,Tr=1020,x0=35902,M0=35899,y0=1021,S0=1022,pn=1023,oi=1026,$i=1027,b0=1028,eh=1029,ji=1030,th=1031,nh=1033,Fa=33776,Oa=33777,za=33778,Ba=33779,Bl=35840,kl=35841,Hl=35842,Gl=35843,Vl=36196,Wl=37492,Xl=37496,ql=37488,Yl=37489,qa=37490,Kl=37491,$l=37808,Zl=37809,Jl=37810,Ql=37811,jl=37812,ec=37813,tc=37814,nc=37815,ic=37816,sc=37817,rc=37818,ac=37819,oc=37820,lc=37821,cc=36492,hc=36494,uc=36495,dc=36283,fc=36284,Ya=36285,pc=36286,cm=3200,mc=0,hm=1,bi="",Mn="srgb",Ka="srgb-linear",$a="linear",et="srgb",us=7680,Qh=519,um=512,dm=513,fm=514,ih=515,pm=516,mm=517,sh=518,gm=519,gc=35044,jh="300 es",qn=2e3,Rr=2001;function vm(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Za(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function _m(){const i=Za("canvas");return i.style.display="block",i}const eu={};function Ja(...i){const e="THREE."+i.shift();console.log(e,...i)}function E0(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 Oe(...i){i=E0(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function Ye(...i){i=E0(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function ks(...i){const e=i.join(" ");e in eu||(eu[e]=!0,Oe(...i))}function xm(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 Mm={[Dl]:Pl,[Il]:Ul,[Ll]:Fl,[Ys]:Nl,[Pl]:Dl,[Ul]:Il,[Fl]:Ll,[Nl]:Ys};class ss{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 Vt=["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"],Eo=Math.PI/180,vc=180/Math.PI;function Ti(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Vt[i&255]+Vt[i>>8&255]+Vt[i>>16&255]+Vt[i>>24&255]+"-"+Vt[e&255]+Vt[e>>8&255]+"-"+Vt[e>>16&15|64]+Vt[e>>24&255]+"-"+Vt[t&63|128]+Vt[t>>8&255]+"-"+Vt[t>>16&255]+Vt[t>>24&255]+Vt[n&255]+Vt[n>>8&255]+Vt[n>>16&255]+Vt[n>>24&255]).toLowerCase()}function Xe(i,e,t){return Math.max(e,Math.min(t,i))}function ym(i,e){return(i%e+e)%e}function wo(i,e,t){return(1-t)*i+t*e}function Wn(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function st(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}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=Xe(this.x,e.x,t.x),this.y=Xe(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Xe(this.x,e,t),this.y=Xe(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Xe(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(Xe(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 Js{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,a,o){let l=n[s+0],c=n[s+1],h=n[s+2],u=n[s+3],d=r[a+0],f=r[a+1],g=r[a+2],x=r[a+3];if(u!==x||l!==d||c!==f||h!==g){let m=l*d+c*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 E=Math.acos(m),A=Math.sin(E);p=Math.sin(p*E)/A,o=Math.sin(o*E)/A,l=l*p+d*o,c=c*p+f*o,h=h*p+g*o,u=u*p+x*o}else{l=l*p+d*o,c=c*p+f*o,h=h*p+g*o,u=u*p+x*o;const E=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=E,c*=E,h*=E,u*=E}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,s,r,a){const o=n[s],l=n[s+1],c=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+l*f-c*d,e[t+1]=l*g+h*d+c*u-o*f,e[t+2]=c*g+h*f+o*d-l*u,e[t+3]=h*g-o*u-l*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,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,l=Math.sin,c=o(n/2),h=o(s/2),u=o(r/2),d=l(n/2),f=l(s/2),g=l(r/2);switch(a){case"XYZ":this._x=d*h*u+c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u-d*f*g;break;case"YXZ":this._x=d*h*u+c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u+d*f*g;break;case"ZXY":this._x=d*h*u-c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u-d*f*g;break;case"ZYX":this._x=d*h*u-c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u+d*f*g;break;case"YZX":this._x=d*h*u+c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u-d*f*g;break;case"XZY":this._x=d*h*u-c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u+d*f*g;break;default:Oe("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],l=t[9],c=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-l)*f,this._y=(r-c)*f,this._z=(a-s)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-l)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+c)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(r-c)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(a-s)/f,this._x=(r+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Xe(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,l=t._y,c=t._z,h=t._w;return this._x=n*h+a*o+s*c-r*l,this._y=s*h+a*l+r*o-n*c,this._z=r*h+a*c+n*l-s*o,this._w=a*h-n*o-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),h=Math.sin(c);l=Math.sin(l*c)/h,t=Math.sin(t*c)/h,this._x=this._x*l+n*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){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 U{static{U.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,l=e.w,c=2*(a*s-o*n),h=2*(o*t-r*s),u=2*(r*n-a*t);return this.x=t+l*c+a*u-o*h,this.y=n+l*h+o*c-r*u,this.z=s+l*u+r*h-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){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=Xe(this.x,e.x,t.x),this.y=Xe(this.y,e.y,t.y),this.z=Xe(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Xe(this.x,e,t),this.y=Xe(this.y,e,t),this.z=Xe(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Xe(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,l=t.z;return this.x=s*l-r*o,this.y=r*a-n*l,this.z=n*o-s*a,this}projectOnVector(e){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 Ao.copy(this).projectOnVector(e),this.sub(Ao)}reflect(e){return this.sub(Ao.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(Xe(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 Ao=new U,tu=new Js;class ze{static{ze.prototype.isMatrix3=!0}constructor(e,t,n,s,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,l,c)}set(e,t,n,s,r,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=s,h[2]=o,h[3]=t,h[4]=r,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){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],l=n[6],c=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],E=s[1],A=s[4],M=s[7],S=s[2],w=s[5],R=s[8];return r[0]=a*x+o*E+l*S,r[3]=a*m+o*A+l*w,r[6]=a*p+o*M+l*R,r[1]=c*x+h*E+u*S,r[4]=c*m+h*A+u*w,r[7]=c*p+h*M+u*R,r[2]=d*x+f*E+g*S,r[5]=d*m+f*A+g*w,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],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-n*r*h+n*o*l+s*r*c-s*a*l}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=h*a-o*c,d=o*l-h*r,f=c*r-a*l,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*c-h*n)*x,e[2]=(o*n-s*a)*x,e[3]=d*x,e[4]=(h*t-s*l)*x,e[5]=(s*r-o*t)*x,e[6]=f*x,e[7]=(n*l-c*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 l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-s*c,s*l,-s*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return ks("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(To.makeScale(e,t)),this}rotate(e){return ks("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(To.makeRotation(-e)),this}translate(e,t){return ks("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(To.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 To=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 Sm(){const i={enabled:!0,workingColorSpace:Ka,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===et&&(s.r=ai(s.r),s.g=ai(s.g),s.b=ai(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===et&&(s.r=Hs(s.r),s.g=Hs(s.g),s.b=Hs(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===bi?$a: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 ks("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return ks("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({[Ka]:{primaries:e,whitePoint:n,transfer:$a,toXYZ:nu,fromXYZ:iu,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Mn},outputColorSpaceConfig:{drawingBufferColorSpace:Mn}},[Mn]:{primaries:e,whitePoint:n,transfer:et,toXYZ:nu,fromXYZ:iu,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Mn}}}),i}const Ke=Sm();function ai(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Hs(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let ds;class bm{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{ds===void 0&&(ds=Za("canvas")),ds.width=e.width,ds.height=e.height;const s=ds.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=ds}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=Za("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]=ai(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(ai(t[n]/255)*255):t[n]=ai(t[n]);return{data:t,width:e.width,height:e.height}}else return Oe("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Em=0;class rh{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Em++}),this.uuid=Ti(),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(Ro(s[a].image)):r.push(Ro(s[a]))}else r=Ro(s);n.url=r}return t||(e.images[this.uuid]=n),n}}function Ro(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?bm.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Oe("Texture: Unable to serialize Texture."),{})}let wm=0;const Co=new U;class Kt extends ss{constructor(e=Kt.DEFAULT_IMAGE,t=Kt.DEFAULT_MAPPING,n=fn,s=fn,r=Tt,a=Ki,o=pn,l=dn,c=Kt.DEFAULT_ANISOTROPY,h=bi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:wm++}),this.uuid=Ti(),this.name="",this.source=new rh(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new 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(Co).x}get height(){return this.source.getSize(Co).y}get depth(){return this.source.getSize(Co).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){Oe(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Oe(`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!==g0)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ol:e.x=e.x-Math.floor(e.x);break;case fn:e.x=e.x<0?0:1;break;case zl: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 Ol:e.y=e.y-Math.floor(e.y);break;case fn:e.y=e.y<0?0:1;break;case zl:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Kt.DEFAULT_IMAGE=null;Kt.DEFAULT_MAPPING=g0;Kt.DEFAULT_ANISOTROPY=1;class pt{static{pt.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 l=e.elements,c=l[0],h=l[4],u=l[8],d=l[1],f=l[5],g=l[9],x=l[2],m=l[6],p=l[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(c+f+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const A=(c+1)/2,M=(f+1)/2,S=(p+1)/2,w=(h+d)/4,R=(u+x)/4,_=(g+m)/4;return A>M&&A>S?A<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(A),s=w/n,r=R/n):M>S?M<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(M),n=w/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 E=Math.sqrt((m-g)*(m-g)+(u-x)*(u-x)+(d-h)*(d-h));return Math.abs(E)<.001&&(E=1),this.x=(m-g)/E,this.y=(u-x)/E,this.z=(d-h)/E,this.w=Math.acos((c+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=Xe(this.x,e.x,t.x),this.y=Xe(this.y,e.y,t.y),this.z=Xe(this.z,e.z,t.z),this.w=Xe(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Xe(this.x,e,t),this.y=Xe(this.y,e,t),this.z=Xe(this.z,e,t),this.w=Xe(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Xe(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 Am extends ss{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Tt,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 pt(0,0,e,t),this.scissorTest=!1,this.viewport=new pt(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:n.depth},r=new Kt(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:Tt,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 rh(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 Sn extends Am{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class w0 extends Kt{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=Ct,this.minFilter=Ct,this.wrapR=fn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Tm extends Kt{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=Ct,this.minFilter=Ct,this.wrapR=fn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ht{static{ht.prototype.isMatrix4=!0}constructor(e,t,n,s,r,a,o,l,c,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,l,c,h,u,d,f,g,x,m)}set(e,t,n,s,r,a,o,l,c,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]=l,p[2]=c,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 ht().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/fs.setFromMatrixColumn(e,0).length(),r=1/fs.setFromMatrixColumn(e,1).length(),a=1/fs.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),l=Math.cos(s),c=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]=l*h,t[4]=-l*u,t[8]=c,t[1]=f+g*c,t[5]=d-x*c,t[9]=-o*l,t[2]=x-d*c,t[6]=g+f*c,t[10]=a*l}else if(e.order==="YXZ"){const d=l*h,f=l*u,g=c*h,x=c*u;t[0]=d+x*o,t[4]=g*o-f,t[8]=a*c,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=f*o-g,t[6]=x+d*o,t[10]=a*l}else if(e.order==="ZXY"){const d=l*h,f=l*u,g=c*h,x=c*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*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const d=a*h,f=a*u,g=o*h,x=o*u;t[0]=l*h,t[4]=g*c-f,t[8]=d*c+x,t[1]=l*u,t[5]=x*c+d,t[9]=f*c-g,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const d=a*l,f=a*c,g=o*l,x=o*c;t[0]=l*h,t[4]=x-d*u,t[8]=g*u+f,t[1]=u,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=f*u+g,t[10]=d-x*u}else if(e.order==="XZY"){const d=a*l,f=a*c,g=o*l,x=o*c;t[0]=l*h,t[4]=-u,t[8]=c*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(Rm,e,Cm)}lookAt(e,t,n){const s=this.elements;return an.subVectors(e,t),an.lengthSq()===0&&(an.z=1),an.normalize(),fi.crossVectors(n,an),fi.lengthSq()===0&&(Math.abs(n.z)===1?an.x+=1e-4:an.z+=1e-4,an.normalize(),fi.crossVectors(n,an)),fi.normalize(),qr.crossVectors(an,fi),s[0]=fi.x,s[4]=qr.x,s[8]=an.x,s[1]=fi.y,s[5]=qr.y,s[9]=an.y,s[2]=fi.z,s[6]=qr.z,s[10]=an.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],l=n[8],c=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],E=n[3],A=n[7],M=n[11],S=n[15],w=s[0],R=s[4],_=s[8],b=s[12],D=s[1],C=s[5],I=s[9],W=s[13],X=s[2],F=s[6],q=s[10],G=s[14],Z=s[3],te=s[7],j=s[11],ie=s[15];return r[0]=a*w+o*D+l*X+c*Z,r[4]=a*R+o*C+l*F+c*te,r[8]=a*_+o*I+l*q+c*j,r[12]=a*b+o*W+l*G+c*ie,r[1]=h*w+u*D+d*X+f*Z,r[5]=h*R+u*C+d*F+f*te,r[9]=h*_+u*I+d*q+f*j,r[13]=h*b+u*W+d*G+f*ie,r[2]=g*w+x*D+m*X+p*Z,r[6]=g*R+x*C+m*F+p*te,r[10]=g*_+x*I+m*q+p*j,r[14]=g*b+x*W+m*G+p*ie,r[3]=E*w+A*D+M*X+S*Z,r[7]=E*R+A*C+M*F+S*te,r[11]=E*_+A*I+M*q+S*j,r[15]=E*b+A*W+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],l=e[9],c=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],E=l*f-c*d,A=o*f-c*u,M=o*d-l*u,S=a*f-c*h,w=a*d-l*h,R=a*u-o*h;return t*(x*E-m*A+p*M)-n*(g*E-m*S+p*w)+s*(g*A-x*S+p*R)-r*(g*M-x*w+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],l=e[2],c=e[6],h=e[10];return t*(a*h-o*c)-n*(r*h-o*l)+s*(r*c-a*l)}transpose(){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],l=e[6],c=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],E=t*o-n*a,A=t*l-s*a,M=t*c-r*a,S=n*l-s*o,w=n*c-r*o,R=s*c-r*l,_=h*x-u*g,b=h*m-d*g,D=h*p-f*g,C=u*m-d*x,I=u*p-f*x,W=d*p-f*m,X=E*W-A*I+M*C+S*D-w*b+R*_;if(X===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const F=1/X;return e[0]=(o*W-l*I+c*C)*F,e[1]=(s*I-n*W-r*C)*F,e[2]=(x*R-m*w+p*S)*F,e[3]=(d*w-u*R-f*S)*F,e[4]=(l*D-a*W-c*b)*F,e[5]=(t*W-s*D+r*b)*F,e[6]=(m*M-g*R-p*A)*F,e[7]=(h*R-d*M+f*A)*F,e[8]=(a*I-o*D+c*_)*F,e[9]=(n*D-t*I-r*_)*F,e[10]=(g*w-x*M+p*E)*F,e[11]=(u*M-h*w-f*E)*F,e[12]=(o*b-a*C-l*_)*F,e[13]=(t*C-n*b+s*_)*F,e[14]=(x*A-g*S-m*E)*F,e[15]=(h*S-u*A+d*E)*F,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,l=e.z,c=r*a,h=r*o;return this.set(c*a+n,c*o-s*l,c*l+s*o,0,c*o+s*l,h*o+n,h*l-s*a,0,c*l-s*o,h*l+s*a,r*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,s,r,a){return this.set(1,n,r,0,e,1,a,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){const s=this.elements,r=t._x,a=t._y,o=t._z,l=t._w,c=r+r,h=a+a,u=o+o,d=r*c,f=r*h,g=r*u,x=a*h,m=a*u,p=o*u,E=l*c,A=l*h,M=l*u,S=n.x,w=n.y,R=n.z;return s[0]=(1-(x+p))*S,s[1]=(f+M)*S,s[2]=(g-A)*S,s[3]=0,s[4]=(f-M)*w,s[5]=(1-(d+p))*w,s[6]=(m+E)*w,s[7]=0,s[8]=(g+A)*R,s[9]=(m-E)*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=fs.set(s[0],s[1],s[2]).length();const o=fs.set(s[4],s[5],s[6]).length(),l=fs.set(s[8],s[9],s[10]).length();r<0&&(a=-a),En.copy(this);const c=1/a,h=1/o,u=1/l;return En.elements[0]*=c,En.elements[1]*=c,En.elements[2]*=c,En.elements[4]*=h,En.elements[5]*=h,En.elements[6]*=h,En.elements[8]*=u,En.elements[9]*=u,En.elements[10]*=u,t.setFromRotationMatrix(En),n.x=a,n.y=o,n.z=l,this}makePerspective(e,t,n,s,r,a,o=qn,l=!1){const c=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(l)g=r/(a-r),x=a*r/(a-r);else if(o===qn)g=-(a+r)/(a-r),x=-2*a*r/(a-r);else if(o===Rr)g=-a/(a-r),x=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=g,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,s,r,a,o=qn,l=!1){const c=this.elements,h=2/(t-e),u=2/(n-s),d=-(t+e)/(t-e),f=-(n+s)/(n-s);let g,x;if(l)g=1/(a-r),x=a/(a-r);else if(o===qn)g=-2/(a-r),x=-(a+r)/(a-r);else if(o===Rr)g=-1/(a-r),x=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=g,c[14]=x,c[3]=0,c[7]=0,c[11]=0,c[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 fs=new U,En=new ht,Rm=new U(0,0,0),Cm=new U(1,1,1),fi=new U,qr=new U,an=new U,su=new ht,ru=new Js;class Pi{constructor(e=0,t=0,n=0,s=Pi.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],l=s[1],c=s[5],h=s[9],u=s[2],d=s[6],f=s[10];switch(t){case"XYZ":this._y=Math.asin(Xe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Xe(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(Xe(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-Xe(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Xe(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Xe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,f),this._y=0);break;default:Oe("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}}Pi.DEFAULT_ORDER="XYZ";class ah{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 Dm=0;const au=new U,ps=new Js,Zn=new ht,Yr=new U,er=new U,Pm=new U,Im=new Js,ou=new U(1,0,0),lu=new U(0,1,0),cu=new U(0,0,1),hu={type:"added"},Lm={type:"removed"},ms={type:"childadded",child:null},Do={type:"childremoved",child:null};class Rt extends ss{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Dm++}),this.uuid=Ti(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Rt.DEFAULT_UP.clone();const e=new U,t=new Pi,n=new Js,s=new U(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 ht},normalMatrix:{value:new ze}}),this.matrix=new ht,this.matrixWorld=new ht,this.matrixAutoUpdate=Rt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Rt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ah,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 ps.setFromAxisAngle(e,t),this.quaternion.multiply(ps),this}rotateOnWorldAxis(e,t){return ps.setFromAxisAngle(e,t),this.quaternion.premultiply(ps),this}rotateX(e){return this.rotateOnAxis(ou,e)}rotateY(e){return this.rotateOnAxis(lu,e)}rotateZ(e){return this.rotateOnAxis(cu,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(lu,e)}translateZ(e){return this.translateOnAxis(cu,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Zn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Yr.copy(e):Yr.set(e,t,n);const s=this.parent;this.updateWorldMatrix(!0,!1),er.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Zn.lookAt(er,Yr,this.up):Zn.lookAt(Yr,er,this.up),this.quaternion.setFromRotationMatrix(Zn),s&&(Zn.extractRotation(s.matrixWorld),ps.setFromRotationMatrix(Zn),this.quaternion.premultiply(ps.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Ye("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),ms.child=e,this.dispatchEvent(ms),ms.child=null):Ye("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(Lm),Do.child=e,this.dispatchEvent(Do),Do.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),Zn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Zn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Zn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(hu),ms.child=e,this.dispatchEvent(ms),ms.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(er,e,Pm),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(er,Im,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,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const u=l[c];r(e.shapes,u)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(r(e.materials,this.material[l]));s.material=o}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];s.animations.push(r(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),u=a(e.shapes),d=a(e.skeletons),f=a(e.animations),g=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),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 l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const s=e.children[n];this.add(s.clone())}return this}}Rt.DEFAULT_UP=new U(0,1,0);Rt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Rt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Cn extends Rt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Nm={type:"move"};class Po{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Cn,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 Cn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new U,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new U),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Cn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new U,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new U,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,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const x of e.hand.values()){const m=t.getJointPose(x,n),p=this._getHandJoint(c,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=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,g=.005;c.inputState.pinching&&d>f+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=f-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Nm)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Cn;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},pi={h:0,s:0,l:0},Kr={h:0,s:0,l:0};function Io(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=Mn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ke.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=Ke.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ke.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=Ke.workingColorSpace){if(e=ym(e,1),t=Xe(t,0,1),n=Xe(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=Io(a,r,e+1/3),this.g=Io(a,r,e),this.b=Io(a,r,e-1/3)}return Ke.colorSpaceToWorking(this,s),this}setStyle(e,t=Mn){function n(r){r!==void 0&&parseFloat(r)<1&&Oe("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:Oe("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);Oe("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Mn){const n=A0[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Oe("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=ai(e.r),this.g=ai(e.g),this.b=ai(e.b),this}copyLinearToSRGB(e){return this.r=Hs(e.r),this.g=Hs(e.g),this.b=Hs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Mn){return Ke.workingToColorSpace(Wt.copy(this),e),Math.round(Xe(Wt.r*255,0,255))*65536+Math.round(Xe(Wt.g*255,0,255))*256+Math.round(Xe(Wt.b*255,0,255))}getHexString(e=Mn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ke.workingColorSpace){Ke.workingToColorSpace(Wt.copy(this),t);const n=Wt.r,s=Wt.g,r=Wt.b,a=Math.max(n,s,r),o=Math.min(n,s,r);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const u=a-o;switch(c=h<=.5?u/(a+o):u/(2-a-o),a){case n:l=(s-r)/u+(s<r?6:0);break;case s:l=(r-n)/u+2;break;case r:l=(n-s)/u+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Ke.workingColorSpace){return Ke.workingToColorSpace(Wt.copy(this),t),e.r=Wt.r,e.g=Wt.g,e.b=Wt.b,e}getStyle(e=Mn){Ke.workingToColorSpace(Wt.copy(this),e);const t=Wt.r,n=Wt.g,s=Wt.b;return e!==Mn?`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(pi),this.setHSL(pi.h+e,pi.s+t,pi.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(pi),e.getHSL(Kr);const n=wo(pi.h,Kr.h,t),s=wo(pi.s,Kr.s,t),r=wo(pi.l,Kr.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 Wt=new Me;Me.NAMES=A0;class oh{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 oh(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class lh extends Rt{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 Pi,this.environmentIntensity=1,this.environmentRotation=new Pi,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 wn=new U,Jn=new U,Lo=new U,Qn=new U,gs=new U,vs=new U,uu=new U,No=new U,Uo=new U,Fo=new U,Oo=new pt,zo=new pt,Bo=new pt;class yn{constructor(e=new U,t=new U,n=new U){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),wn.subVectors(e,t),s.cross(wn);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){wn.subVectors(s,t),Jn.subVectors(n,t),Lo.subVectors(e,t);const a=wn.dot(wn),o=wn.dot(Jn),l=wn.dot(Lo),c=Jn.dot(Jn),h=Jn.dot(Lo),u=a*c-o*o;if(u===0)return r.set(0,0,0),null;const d=1/u,f=(c*l-o*h)*d,g=(a*h-o*l)*d;return r.set(1-f-g,g,f)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,Qn)===null?!1:Qn.x>=0&&Qn.y>=0&&Qn.x+Qn.y<=1}static getInterpolation(e,t,n,s,r,a,o,l){return this.getBarycoord(e,t,n,s,Qn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,Qn.x),l.addScaledVector(a,Qn.y),l.addScaledVector(o,Qn.z),l)}static getInterpolatedAttribute(e,t,n,s,r,a){return Oo.setScalar(0),zo.setScalar(0),Bo.setScalar(0),Oo.fromBufferAttribute(e,t),zo.fromBufferAttribute(e,n),Bo.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(Oo,r.x),a.addScaledVector(zo,r.y),a.addScaledVector(Bo,r.z),a}static isFrontFacing(e,t,n,s){return wn.subVectors(n,t),Jn.subVectors(e,t),wn.cross(Jn).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 wn.subVectors(this.c,this.b),Jn.subVectors(this.a,this.b),wn.cross(Jn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return yn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return yn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return yn.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return yn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return yn.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;gs.subVectors(s,n),vs.subVectors(r,n),No.subVectors(e,n);const l=gs.dot(No),c=vs.dot(No);if(l<=0&&c<=0)return t.copy(n);Uo.subVectors(e,s);const h=gs.dot(Uo),u=vs.dot(Uo);if(h>=0&&u<=h)return t.copy(s);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(n).addScaledVector(gs,a);Fo.subVectors(e,r);const f=gs.dot(Fo),g=vs.dot(Fo);if(g>=0&&f<=g)return t.copy(r);const x=f*c-l*g;if(x<=0&&c>=0&&g<=0)return o=c/(c-g),t.copy(n).addScaledVector(vs,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(gs,a).addScaledVector(vs,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Pr{constructor(e=new U(1/0,1/0,1/0),t=new U(-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(An.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(An.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=An.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,An):An.fromBufferAttribute(r,a),An.applyMatrix4(e.matrixWorld),this.expandByPoint(An);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),$r.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),$r.copy(n.boundingBox)),$r.applyMatrix4(e.matrixWorld),this.union($r)}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,An),An.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(tr),Zr.subVectors(this.max,tr),_s.subVectors(e.a,tr),xs.subVectors(e.b,tr),Ms.subVectors(e.c,tr),mi.subVectors(xs,_s),gi.subVectors(Ms,xs),Fi.subVectors(_s,Ms);let t=[0,-mi.z,mi.y,0,-gi.z,gi.y,0,-Fi.z,Fi.y,mi.z,0,-mi.x,gi.z,0,-gi.x,Fi.z,0,-Fi.x,-mi.y,mi.x,0,-gi.y,gi.x,0,-Fi.y,Fi.x,0];return!ko(t,_s,xs,Ms,Zr)||(t=[1,0,0,0,1,0,0,0,1],!ko(t,_s,xs,Ms,Zr))?!1:(Jr.crossVectors(mi,gi),t=[Jr.x,Jr.y,Jr.z],ko(t,_s,xs,Ms,Zr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,An).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(An).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:(jn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),jn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),jn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),jn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),jn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),jn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),jn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),jn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(jn),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 jn=[new U,new U,new U,new U,new U,new U,new U,new U],An=new U,$r=new Pr,_s=new U,xs=new U,Ms=new U,mi=new U,gi=new U,Fi=new U,tr=new U,Zr=new U,Jr=new U,Oi=new U;function ko(i,e,t,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){Oi.fromArray(i,r);const o=s.x*Math.abs(Oi.x)+s.y*Math.abs(Oi.y)+s.z*Math.abs(Oi.z),l=e.dot(Oi),c=t.dot(Oi),h=n.dot(Oi);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const si=Um();function Um(){const i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),s=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,s[l]=24,s[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,s[l]=-c-1,s[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,s[l]=13,s[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,s[l]=24,s[l|256]=24):(n[l]=31744,n[l|256]=64512,s[l]=13,s[l|256]=13)}const r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;(c&8388608)===0;)c<<=1,h-=8388608;c&=-8388609,h+=947912704,r[l]=c|h}for(let l=1024;l<2048;++l)r[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:s,mantissaTable:r,exponentTable:a,offsetTable:o}}function Fm(i){Math.abs(i)>65504&&Oe("DataUtils.toHalfFloat(): Value out of range."),i=Xe(i,-65504,65504),si.floatView[0]=i;const e=si.uint32View[0],t=e>>23&511;return si.baseTable[t]+((e&8388607)>>si.shiftTable[t])}function Om(i){const e=i>>10;return si.uint32View[0]=si.mantissaTable[si.offsetTable[e]+(i&1023)]+si.exponentTable[e],si.floatView[0]}class Gs{static toHalfFloat(e){return Fm(e)}static fromHalfFloat(e){return Om(e)}}const wt=new U,Qr=new Le;let zm=0;class ct extends ss{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:zm++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=gc,this.updateRanges=[],this.gpuType=Xn,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++)Qr.fromBufferAttribute(this,t),Qr.applyMatrix3(e),this.setXY(t,Qr.x,Qr.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)wt.fromBufferAttribute(this,t),wt.applyMatrix3(e),this.setXYZ(t,wt.x,wt.y,wt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)wt.fromBufferAttribute(this,t),wt.applyMatrix4(e),this.setXYZ(t,wt.x,wt.y,wt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)wt.fromBufferAttribute(this,t),wt.applyNormalMatrix(e),this.setXYZ(t,wt.x,wt.y,wt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)wt.fromBufferAttribute(this,t),wt.transformDirection(e),this.setXYZ(t,wt.x,wt.y,wt.z);return this}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=Wn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=st(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Wn(t,this.array)),t}setX(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Wn(t,this.array)),t}setY(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Wn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Wn(t,this.array)),t}setW(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array),s=st(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array),s=st(s,this.array),r=st(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){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!==gc&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class T0 extends ct{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class R0 extends ct{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Pt extends ct{constructor(e,t,n){super(new Float32Array(e),t,n)}}const Bm=new Pr,nr=new U,Ho=new U;class uo{constructor(e=new U,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):Bm.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;nr.subVectors(e,this.center);const t=nr.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(nr,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):(Ho.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(nr.copy(e.center).add(Ho)),this.expandByPoint(nr.copy(e.center).sub(Ho))),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 km=0;const vn=new ht,Go=new Rt,ys=new U,on=new Pr,ir=new Pr,Ft=new U;class bt extends ss{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:km++}),this.uuid=Ti(),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(vm(e)?R0:T0)(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 vn.makeRotationFromQuaternion(e),this.applyMatrix4(vn),this}rotateX(e){return vn.makeRotationX(e),this.applyMatrix4(vn),this}rotateY(e){return vn.makeRotationY(e),this.applyMatrix4(vn),this}rotateZ(e){return vn.makeRotationZ(e),this.applyMatrix4(vn),this}translate(e,t,n){return vn.makeTranslation(e,t,n),this.applyMatrix4(vn),this}scale(e,t,n){return vn.makeScale(e,t,n),this.applyMatrix4(vn),this}lookAt(e){return Go.lookAt(e),Go.updateMatrix(),this.applyMatrix4(Go.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ys).negate(),this.translate(ys.x,ys.y,ys.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&&Oe("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 Pr);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ye("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new U(-1/0,-1/0,-1/0),new U(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];on.setFromBufferAttribute(r),this.morphTargetsRelative?(Ft.addVectors(this.boundingBox.min,on.min),this.boundingBox.expandByPoint(Ft),Ft.addVectors(this.boundingBox.max,on.max),this.boundingBox.expandByPoint(Ft)):(this.boundingBox.expandByPoint(on.min),this.boundingBox.expandByPoint(on.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ye('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 uo);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ye("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new U,1/0);return}if(e){const n=this.boundingSphere.center;if(on.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];ir.setFromBufferAttribute(o),this.morphTargetsRelative?(Ft.addVectors(on.min,ir.min),on.expandByPoint(Ft),Ft.addVectors(on.max,ir.max),on.expandByPoint(Ft)):(on.expandByPoint(ir.min),on.expandByPoint(ir.max))}on.getCenter(n);let s=0;for(let r=0,a=e.count;r<a;r++)Ft.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(Ft));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)Ft.fromBufferAttribute(o,c),l&&(ys.fromBufferAttribute(e,c),Ft.add(ys)),s=Math.max(s,n.distanceToSquared(Ft))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&Ye('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){Ye("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 ct(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],l=[];for(let _=0;_<n.count;_++)o[_]=new U,l[_]=new U;const c=new U,h=new U,u=new U,d=new Le,f=new Le,g=new Le,x=new U,m=new U;function p(_,b,D){c.fromBufferAttribute(n,_),h.fromBufferAttribute(n,b),u.fromBufferAttribute(n,D),d.fromBufferAttribute(r,_),f.fromBufferAttribute(r,b),g.fromBufferAttribute(r,D),h.sub(c),u.sub(c),f.sub(d),g.sub(d);const C=1/(f.x*g.y-g.x*f.y);isFinite(C)&&(x.copy(h).multiplyScalar(g.y).addScaledVector(u,-f.y).multiplyScalar(C),m.copy(u).multiplyScalar(f.x).addScaledVector(h,-g.x).multiplyScalar(C),o[_].add(x),o[b].add(x),o[D].add(x),l[_].add(m),l[b].add(m),l[D].add(m))}let E=this.groups;E.length===0&&(E=[{start:0,count:e.count}]);for(let _=0,b=E.length;_<b;++_){const D=E[_],C=D.start,I=D.count;for(let W=C,X=C+I;W<X;W+=3)p(e.getX(W+0),e.getX(W+1),e.getX(W+2))}const A=new U,M=new U,S=new U,w=new U;function R(_){S.fromBufferAttribute(s,_),w.copy(S);const b=o[_];A.copy(b),A.sub(S.multiplyScalar(S.dot(b))).normalize(),M.crossVectors(w,b);const C=M.dot(l[_])<0?-1:1;a.setXYZW(_,A.x,A.y,A.z,C)}for(let _=0,b=E.length;_<b;++_){const D=E[_],C=D.start,I=D.count;for(let W=C,X=C+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 ct(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 U,r=new U,a=new U,o=new U,l=new U,c=new U,h=new U,u=new U;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),l.fromBufferAttribute(n,x),c.fromBufferAttribute(n,m),o.add(h),l.add(h),c.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(x,l.x,l.y,l.z),n.setXYZ(m,c.x,c.y,c.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++)Ft.fromBufferAttribute(e,t),Ft.normalize(),e.setXYZ(t,Ft.x,Ft.y,Ft.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,u=o.normalized,d=new c.constructor(l.length*h);let f=0,g=0;for(let x=0,m=l.length;x<m;x++){o.isInterleavedBufferAttribute?f=l[x]*o.data.stride+o.offset:f=l[x]*h;for(let p=0;p<h;p++)d[g++]=c[f++]}return new ct(d,h,u)}if(this.index===null)return Oe("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new bt,n=this.index.array,s=this.attributes;for(const o in s){const l=s[o],c=e(l,n);t.setAttribute(o,c)}const r=this.morphAttributes;for(const o in r){const l=[],c=r[o];for(let h=0,u=c.length;h<u;h++){const d=c[h],f=e(d,n);l.push(f)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.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 l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);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 l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){const f=c[u];h.push(f.toJSON(e.data))}h.length>0&&(s[l]=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 c in s){const h=s[c];this.setAttribute(c,h.clone(t))}const r=e.morphAttributes;for(const c in r){const h=[],u=r[c];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,h=a.length;c<h;c++){const u=a[c];this.addGroup(u.start,u.count,u.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Hm{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=gc,this.updateRanges=[],this.version=0,this.uuid=Ti()}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=Ti()),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=Ti()),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 $t=new U;class Qa{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++)$t.fromBufferAttribute(this,t),$t.applyMatrix4(e),this.setXYZ(t,$t.x,$t.y,$t.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)$t.fromBufferAttribute(this,t),$t.applyNormalMatrix(e),this.setXYZ(t,$t.x,$t.y,$t.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)$t.fromBufferAttribute(this,t),$t.transformDirection(e),this.setXYZ(t,$t.x,$t.y,$t.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Wn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=st(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Wn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Wn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Wn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Wn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),n=st(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),n=st(n,this.array),s=st(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),n=st(n,this.array),s=st(s,this.array),r=st(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Ja("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 ct(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 Qa(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Ja("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 Gm=0;class rs extends ss{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Gm++}),this.uuid=Ti(),this.name="",this.type="Material",this.blending=Bs,this.side=Ci,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Rl,this.blendDst=Cl,this.blendEquation=Wi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Me(0,0,0),this.blendAlpha=0,this.depthFunc=Ys,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Qh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=us,this.stencilZFail=us,this.stencilZPass=us,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){Oe(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Oe(`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!==Bs&&(n.blending=this.blending),this.side!==Ci&&(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!==Rl&&(n.blendSrc=this.blendSrc),this.blendDst!==Cl&&(n.blendDst=this.blendDst),this.blendEquation!==Wi&&(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!==Ys&&(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!==us&&(n.stencilFail=this.stencilFail),this.stencilZFail!==us&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==us&&(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 l=r[o];delete l.metadata,a.push(l)}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 pr extends rs{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 Ss;const sr=new U,bs=new U,Es=new U,ws=new Le,rr=new Le,C0=new ht,jr=new U,ar=new U,ea=new U,du=new Le,Vo=new Le,fu=new Le;class ta extends Rt{constructor(e=new pr){if(super(),this.isSprite=!0,this.type="Sprite",Ss===void 0){Ss=new bt;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 Hm(t,5);Ss.setIndex([0,1,2,0,2,3]),Ss.setAttribute("position",new Qa(n,3,0,!1)),Ss.setAttribute("uv",new Qa(n,2,3,!1))}this.geometry=Ss,this.material=e,this.center=new Le(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Ye('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),bs.setFromMatrixScale(this.matrixWorld),C0.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Es.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&bs.multiplyScalar(-Es.z);const n=this.material.rotation;let s,r;n!==0&&(r=Math.cos(n),s=Math.sin(n));const a=this.center;na(jr.set(-.5,-.5,0),Es,a,bs,s,r),na(ar.set(.5,-.5,0),Es,a,bs,s,r),na(ea.set(.5,.5,0),Es,a,bs,s,r),du.set(0,0),Vo.set(1,0),fu.set(1,1);let o=e.ray.intersectTriangle(jr,ar,ea,!1,sr);if(o===null&&(na(ar.set(-.5,.5,0),Es,a,bs,s,r),Vo.set(0,1),o=e.ray.intersectTriangle(jr,ea,ar,!1,sr),o===null))return;const l=e.ray.origin.distanceTo(sr);l<e.near||l>e.far||t.push({distance:l,point:sr.clone(),uv:yn.getInterpolation(sr,jr,ar,ea,du,Vo,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 na(i,e,t,n,s,r){ws.subVectors(i,t).addScalar(.5).multiply(n),s!==void 0?(rr.x=r*ws.x-s*ws.y,rr.y=s*ws.x+r*ws.y):rr.copy(ws),i.copy(e),i.x+=rr.x,i.y+=rr.y,i.applyMatrix4(C0)}const ei=new U,Wo=new U,ia=new U,vi=new U,Xo=new U,sa=new U,qo=new U;class ch{constructor(e=new U,t=new U(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,ei)),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=ei.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ei.copy(this.origin).addScaledVector(this.direction,t),ei.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){Wo.copy(e).add(t).multiplyScalar(.5),ia.copy(t).sub(e).normalize(),vi.copy(this.origin).sub(Wo);const r=e.distanceTo(t)*.5,a=-this.direction.dot(ia),o=vi.dot(this.direction),l=-vi.dot(ia),c=vi.lengthSq(),h=Math.abs(1-a*a);let u,d,f,g;if(h>0)if(u=a*l-o,d=a*o-l,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*l)+c}else d=r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d=-r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d<=-g?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-l),r),f=-u*u+d*(d+2*l)+c):d<=g?(u=0,d=Math.min(Math.max(-r,-l),r),f=d*(d+2*l)+c):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-l),r),f=-u*u+d*(d+2*l)+c);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(Wo).addScaledVector(ia,d),f}intersectSphere(e,t){ei.subVectors(e.center,this.origin);const n=ei.dot(this.direction),s=ei.dot(ei)-n*n,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){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,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,s=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,s=(e.min.x-d.x)*c),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,l=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,l=(e.min.z-d.z)*u),n>l||o>s)||((o>n||n!==n)&&(n=o),(l<s||s!==s)&&(s=l),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,ei)!==null}intersectTriangle(e,t,n,s,r){Xo.subVectors(t,e),sa.subVectors(n,e),qo.crossVectors(Xo,sa);let a=this.direction.dot(qo),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;vi.subVectors(this.origin,e);const l=o*this.direction.dot(sa.crossVectors(vi,sa));if(l<0)return null;const c=o*this.direction.dot(Xo.cross(vi));if(c<0||l+c>a)return null;const h=-o*vi.dot(qo);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 es extends rs{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 Pi,this.combine=Zc,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 ht,zi=new ch,ra=new uo,mu=new U,aa=new U,oa=new U,la=new U,Yo=new U,ca=new U,gu=new U,ha=new U;class nt extends Rt{constructor(e=new bt,t=new es){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){ca.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const h=o[l],u=r[l];h!==0&&(Yo.fromBufferAttribute(u,e),a?ca.addScaledVector(Yo,h):ca.addScaledVector(Yo.sub(t),h))}t.add(ca)}return t}raycast(e,t){const n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),ra.copy(n.boundingSphere),ra.applyMatrix4(r),zi.copy(e.ray).recast(e.near),!(ra.containsPoint(zi.origin)===!1&&(zi.intersectSphere(ra,mu)===null||zi.origin.distanceToSquared(mu)>(e.far-e.near)**2))&&(pu.copy(r).invert(),zi.copy(e.ray).applyMatrix4(pu),!(n.boundingBox!==null&&zi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,zi)))}_computeIntersections(e,t,n){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=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],E=Math.max(m.start,f.start),A=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let M=E,S=A;M<S;M+=3){const w=o.getX(M),R=o.getX(M+1),_=o.getX(M+2);s=ua(this,p,e,n,c,h,u,w,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 E=o.getX(m),A=o.getX(m+1),M=o.getX(m+2);s=ua(this,a,e,n,c,h,u,E,A,M),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}else if(l!==void 0)if(Array.isArray(a))for(let g=0,x=d.length;g<x;g++){const m=d[g],p=a[m.materialIndex],E=Math.max(m.start,f.start),A=Math.min(l.count,Math.min(m.start+m.count,f.start+f.count));for(let M=E,S=A;M<S;M+=3){const w=M,R=M+1,_=M+2;s=ua(this,p,e,n,c,h,u,w,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(l.count,f.start+f.count);for(let m=g,p=x;m<p;m+=3){const E=m,A=m+1,M=m+2;s=ua(this,a,e,n,c,h,u,E,A,M),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}}}function Vm(i,e,t,n,s,r,a,o){let l;if(e.side===Dt?l=n.intersectTriangle(a,r,s,!0,o):l=n.intersectTriangle(s,r,a,e.side===Ci,o),l===null)return null;ha.copy(o),ha.applyMatrix4(i.matrixWorld);const c=t.ray.origin.distanceTo(ha);return c<t.near||c>t.far?null:{distance:c,point:ha.clone(),object:i}}function ua(i,e,t,n,s,r,a,o,l,c){i.getVertexPosition(o,aa),i.getVertexPosition(l,oa),i.getVertexPosition(c,la);const h=Vm(i,e,t,n,aa,oa,la,gu);if(h){const u=new U;yn.getBarycoord(gu,aa,oa,la,u),s&&(h.uv=yn.getInterpolatedAttribute(s,o,l,c,u,new Le)),r&&(h.uv1=yn.getInterpolatedAttribute(r,o,l,c,u,new Le)),a&&(h.normal=yn.getInterpolatedAttribute(a,o,l,c,u,new U),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new U,materialIndex:0};yn.getNormal(aa,oa,la,d.normal),h.face=d,h.barycoord=u}return h}class hh extends Kt{constructor(e=null,t=1,n=1,s,r,a,o,l,c=Ct,h=Ct,u,d){super(null,a,o,l,c,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 Ko=new U,Wm=new U,Xm=new ze;class Vi{constructor(e=new U(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=Ko.subVectors(n,t).cross(Wm.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(Ko),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||Xm.getNormalMatrix(e),s=this.coplanarPoint(Ko).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 Bi=new uo,qm=new Le(.5,.5),da=new U;class uh{constructor(e=new Vi,t=new Vi,n=new Vi,s=new Vi,r=new Vi,a=new Vi){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=qn,n=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=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],E=r[12],A=r[13],M=r[14],S=r[15];if(s[0].setComponents(c-a,f-h,p-g,S-E).normalize(),s[1].setComponents(c+a,f+h,p+g,S+E).normalize(),s[2].setComponents(c+o,f+u,p+x,S+A).normalize(),s[3].setComponents(c-o,f-u,p-x,S-A).normalize(),n)s[4].setComponents(l,d,m,M).normalize(),s[5].setComponents(c-l,f-d,p-m,S-M).normalize();else if(s[4].setComponents(c-l,f-d,p-m,S-M).normalize(),t===qn)s[5].setComponents(c+l,f+d,p+m,S+M).normalize();else if(t===Rr)s[5].setComponents(l,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(),Bi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Bi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Bi)}intersectsSprite(e){Bi.center.set(0,0,0);const t=qm.distanceTo(e.center);return Bi.radius=.7071067811865476+t,Bi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Bi)}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(da.x=s.normal.x>0?e.max.x:e.min.x,da.y=s.normal.y>0?e.max.y:e.min.y,da.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(da)<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 D0 extends rs{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 ht,_c=new ch,fa=new uo,pa=new U;class ka extends Rt{constructor(e=new bt,t=new D0){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(),fa.copy(n.boundingSphere),fa.applyMatrix4(s),fa.radius+=r,e.ray.intersectsSphere(fa)===!1)return;vu.copy(s).invert(),_c.copy(e.ray).applyMatrix4(vu);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,u=n.attributes.position;if(c!==null){const d=Math.max(0,a.start),f=Math.min(c.count,a.start+a.count);for(let g=d,x=f;g<x;g++){const m=c.getX(g);pa.fromBufferAttribute(u,m),_u(pa,m,l,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++)pa.fromBufferAttribute(u,g),_u(pa,g,l,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=_c.distanceSqToPoint(i);if(o<t){const l=new U;_c.closestPointToPoint(i,l),l.applyMatrix4(n);const c=s.ray.origin.distanceTo(l);if(c<s.near||c>s.far)return;r.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class P0 extends Kt{constructor(e=[],t=Qi,n,s,r,a,o,l,c,h){super(e,t,n,s,r,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class li extends Kt{constructor(e,t,n,s,r,a,o,l,c){super(e,t,n,s,r,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class ts extends Kt{constructor(e,t,n=Dn,s,r,a,o=Ct,l=Ct,c,h=oi,u=1){if(h!==oi&&h!==$i)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,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new rh(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 Ym extends ts{constructor(e,t=Dn,n=Qi,s,r,a=Ct,o=Ct,l,c=oi){const h={width:e,height:e,depth:1},u=[h,h,h,h,h,h];super(e,e,t,n,s,r,a,o,l,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class I0 extends Kt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class bn extends bt{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 l=[],c=[],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(l),this.setAttribute("position",new Pt(c,3)),this.setAttribute("normal",new Pt(h,3)),this.setAttribute("uv",new Pt(u,2));function g(x,m,p,E,A,M,S,w,R,_,b){const D=M/R,C=S/_,I=M/2,W=S/2,X=w/2,F=R+1,q=_+1;let G=0,Z=0;const te=new U;for(let j=0;j<q;j++){const ie=j*C-W;for(let ue=0;ue<F;ue++){const ke=ue*D-I;te[x]=ke*E,te[m]=ie*A,te[p]=X,c.push(te.x,te.y,te.z),te[x]=0,te[m]=0,te[p]=w>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+F*j,ke=d+ie+F*(j+1),qe=d+(ie+1)+F*(j+1),Be=d+(ie+1)+F*j;l.push(ue,ke,Be),l.push(ke,qe,Be),Z+=6}o.addGroup(f,Z,b),f+=Z,d+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class dh extends bt{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=[],l=[],c=new U,h=new Le;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let u=0,d=3;u<=t;u++,d+=3){const f=n+u/t*s;c.x=e*Math.cos(f),c.y=e*Math.sin(f),a.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(a[d]/e+1)/2,h.y=(a[d+1]/e+1)/2,l.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(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new dh(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Li extends bt{constructor(e=1,t=1,n=1,s=32,r=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:s,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:l};const c=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;E(),a===!1&&(e>0&&A(!0),t>0&&A(!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 E(){const M=new U,S=new U;let w=0;const R=(t-e)/n;for(let _=0;_<=r;_++){const b=[],D=_/r,C=D*(t-e)+e;for(let I=0;I<=s;I++){const W=I/s,X=W*l+o,F=Math.sin(X),q=Math.cos(X);S.x=C*F,S.y=-D*n+m,S.z=C*q,u.push(S.x,S.y,S.z),M.set(F,R,q).normalize(),d.push(M.x,M.y,M.z),f.push(W,1-D),b.push(g++)}x.push(b)}for(let _=0;_<s;_++)for(let b=0;b<r;b++){const D=x[b][_],C=x[b+1][_],I=x[b+1][_+1],W=x[b][_+1];(e>0||b!==0)&&(h.push(D,C,W),w+=3),(t>0||b!==r-1)&&(h.push(C,I,W),w+=3)}c.addGroup(p,w,0),p+=w}function A(M){const S=g,w=new Le,R=new U;let _=0;const b=M===!0?e:t,D=M===!0?1:-1;for(let I=1;I<=s;I++)u.push(0,m*D,0),d.push(0,D,0),f.push(.5,.5),g++;const C=g;for(let I=0;I<=s;I++){const X=I/s*l+o,F=Math.cos(X),q=Math.sin(X);R.x=b*q,R.y=m*D,R.z=b*F,u.push(R.x,R.y,R.z),d.push(0,D,0),w.x=F*.5+.5,w.y=q*.5*D+.5,f.push(w.x,w.y),g++}for(let I=0;I<s;I++){const W=S+I,X=C+I;M===!0?h.push(X,X+1,W):h.push(X+1,X,W),_+=3}c.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 Li(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class fo extends Li{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 fo(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class as extends bt{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),l=Math.floor(s),c=o+1,h=l+1,u=e/o,d=t/l,f=[],g=[],x=[],m=[];for(let p=0;p<h;p++){const E=p*d-a;for(let A=0;A<c;A++){const M=A*u-r;g.push(M,-E,0),x.push(0,0,1),m.push(A/o),m.push(1-p/l)}}for(let p=0;p<l;p++)for(let E=0;E<o;E++){const A=E+c*p,M=E+c*(p+1),S=E+1+c*(p+1),w=E+1+c*p;f.push(A,M,w),f.push(M,S,w)}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 as(e.width,e.height,e.widthSegments,e.heightSegments)}}class Pn extends bt{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 l=Math.min(a+o,Math.PI);let c=0;const h=[],u=new U,d=new U,f=[],g=[],x=[],m=[];for(let p=0;p<=n;p++){const E=[],A=p/n,M=a+A*o,S=e*Math.cos(M),w=Math.sqrt(e*e-S*S);let R=0;p===0&&a===0?R=.5/t:p===n&&l===Math.PI&&(R=-.5/t);for(let _=0;_<=t;_++){const b=_/t,D=s+b*r;u.x=-w*Math.cos(D),u.y=S,u.z=w*Math.sin(D),g.push(u.x,u.y,u.z),d.copy(u).normalize(),x.push(d.x,d.y,d.z),m.push(b+R,1-A),E.push(c++)}h.push(E)}for(let p=0;p<n;p++)for(let E=0;E<t;E++){const A=h[p][E+1],M=h[p][E],S=h[p+1][E],w=h[p+1][E+1];(p!==0||a>0)&&f.push(A,M,w),(p!==n-1||l<Math.PI)&&f.push(M,S,w)}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 $s(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?(Oe("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 Zt(i){const e={};for(let t=0;t<i.length;t++){const n=$s(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 Km(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function L0(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ke.workingColorSpace}const $m={clone:$s,merge:Zt};var Zm=`void main() {
646
+ */const jc="185",Gp=0,eu=1,Vp=2,br=1,Wp=2,gr=3,Pi=0,Pt=1,Tn=2,Kn=0,Hs=1,li=2,tu=3,nu=4,Xp=5,Yi=100,qp=101,Yp=102,Kp=103,$p=104,Zp=200,Jp=201,Qp=202,jp=203,Pl=204,Il=205,em=206,tm=207,nm=208,im=209,sm=210,rm=211,am=212,om=213,lm=214,Ll=0,Nl=1,Ul=2,$s=3,Fl=4,Ol=5,zl=6,Bl=7,eh=0,cm=1,hm=2,$n=0,p0=1,m0=2,g0=3,v0=4,x0=5,_0=6,M0=7,y0=300,ts=301,Zs=302,Eo=303,wo=304,fo=306,kl=1e3,mn=1001,Hl=1002,Dt=1003,um=1004,Kr=1005,Rt=1006,Ao=1007,Ji=1008,pn=1009,S0=1010,b0=1011,Dr=1012,th=1013,Dn=1014,Xn=1015,Qt=1016,nh=1017,ih=1018,Pr=1020,E0=35902,w0=35899,A0=1021,T0=1022,gn=1023,ci=1026,Qi=1027,R0=1028,sh=1029,ns=1030,rh=1031,ah=1033,Ba=33776,ka=33777,Ha=33778,Ga=33779,Gl=35840,Vl=35841,Wl=35842,Xl=35843,ql=36196,Yl=37492,Kl=37496,$l=37488,Zl=37489,Ka=37490,Jl=37491,Ql=37808,jl=37809,ec=37810,tc=37811,nc=37812,ic=37813,sc=37814,rc=37815,ac=37816,oc=37817,lc=37818,cc=37819,hc=37820,uc=37821,dc=36492,fc=36494,pc=36495,mc=36283,gc=36284,$a=36285,vc=36286,dm=3200,xc=0,fm=1,wi="",yn="srgb",Za="srgb-linear",Ja="linear",tt="srgb",fs=7680,iu=519,pm=512,mm=513,gm=514,oh=515,vm=516,xm=517,lh=518,_m=519,_c=35044,su="300 es",qn=2e3,Ir=2001;function Mm(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Qa(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function ym(){const i=Qa("canvas");return i.style.display="block",i}const ru={};function ja(...i){const e="THREE."+i.shift();console.log(e,...i)}function C0(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 Oe(...i){i=C0(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function Ye(...i){i=C0(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function Gs(...i){const e=i.join(" ");e in ru||(ru[e]=!0,Oe(...i))}function Sm(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 bm={[Ll]:Nl,[Ul]:zl,[Fl]:Bl,[$s]:Ol,[Nl]:Ll,[zl]:Ul,[Bl]:Fl,[Ol]:$s};class os{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 Vt=["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"],To=Math.PI/180,Mc=180/Math.PI;function Ci(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Vt[i&255]+Vt[i>>8&255]+Vt[i>>16&255]+Vt[i>>24&255]+"-"+Vt[e&255]+Vt[e>>8&255]+"-"+Vt[e>>16&15|64]+Vt[e>>24&255]+"-"+Vt[t&63|128]+Vt[t>>8&255]+"-"+Vt[t>>16&255]+Vt[t>>24&255]+Vt[n&255]+Vt[n>>8&255]+Vt[n>>16&255]+Vt[n>>24&255]).toLowerCase()}function Xe(i,e,t){return Math.max(e,Math.min(t,i))}function Em(i,e){return(i%e+e)%e}function Ro(i,e,t){return(1-t)*i+t*e}function Wn(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function st(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}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=Xe(this.x,e.x,t.x),this.y=Xe(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Xe(this.x,e,t),this.y=Xe(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Xe(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(Xe(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 js{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,a,o){let l=n[s+0],c=n[s+1],h=n[s+2],u=n[s+3],d=r[a+0],f=r[a+1],g=r[a+2],_=r[a+3];if(u!==_||l!==d||c!==f||h!==g){let m=l*d+c*f+h*g+u*_;m<0&&(d=-d,f=-f,g=-g,_=-_,m=-m);let p=1-o;if(m<.9995){const E=Math.acos(m),A=Math.sin(E);p=Math.sin(p*E)/A,o=Math.sin(o*E)/A,l=l*p+d*o,c=c*p+f*o,h=h*p+g*o,u=u*p+_*o}else{l=l*p+d*o,c=c*p+f*o,h=h*p+g*o,u=u*p+_*o;const E=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=E,c*=E,h*=E,u*=E}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,s,r,a){const o=n[s],l=n[s+1],c=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+l*f-c*d,e[t+1]=l*g+h*d+c*u-o*f,e[t+2]=c*g+h*f+o*d-l*u,e[t+3]=h*g-o*u-l*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,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,l=Math.sin,c=o(n/2),h=o(s/2),u=o(r/2),d=l(n/2),f=l(s/2),g=l(r/2);switch(a){case"XYZ":this._x=d*h*u+c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u-d*f*g;break;case"YXZ":this._x=d*h*u+c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u+d*f*g;break;case"ZXY":this._x=d*h*u-c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u-d*f*g;break;case"ZYX":this._x=d*h*u-c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u+d*f*g;break;case"YZX":this._x=d*h*u+c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u-d*f*g;break;case"XZY":this._x=d*h*u-c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u+d*f*g;break;default:Oe("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],l=t[9],c=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-l)*f,this._y=(r-c)*f,this._z=(a-s)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-l)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+c)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(r-c)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(a-s)/f,this._x=(r+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Xe(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,l=t._y,c=t._z,h=t._w;return this._x=n*h+a*o+s*c-r*l,this._y=s*h+a*l+r*o-n*c,this._z=r*h+a*c+n*l-s*o,this._w=a*h-n*o-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),h=Math.sin(c);l=Math.sin(l*c)/h,t=Math.sin(t*c)/h,this._x=this._x*l+n*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){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 U{static{U.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(au.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(au.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,l=e.w,c=2*(a*s-o*n),h=2*(o*t-r*s),u=2*(r*n-a*t);return this.x=t+l*c+a*u-o*h,this.y=n+l*h+o*c-r*u,this.z=s+l*u+r*h-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){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=Xe(this.x,e.x,t.x),this.y=Xe(this.y,e.y,t.y),this.z=Xe(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Xe(this.x,e,t),this.y=Xe(this.y,e,t),this.z=Xe(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Xe(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,l=t.z;return this.x=s*l-r*o,this.y=r*a-n*l,this.z=n*o-s*a,this}projectOnVector(e){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 Co.copy(this).projectOnVector(e),this.sub(Co)}reflect(e){return this.sub(Co.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(Xe(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 Co=new U,au=new js;class ze{static{ze.prototype.isMatrix3=!0}constructor(e,t,n,s,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,l,c)}set(e,t,n,s,r,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=s,h[2]=o,h[3]=t,h[4]=r,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){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],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],f=n[5],g=n[8],_=s[0],m=s[3],p=s[6],E=s[1],A=s[4],M=s[7],S=s[2],w=s[5],R=s[8];return r[0]=a*_+o*E+l*S,r[3]=a*m+o*A+l*w,r[6]=a*p+o*M+l*R,r[1]=c*_+h*E+u*S,r[4]=c*m+h*A+u*w,r[7]=c*p+h*M+u*R,r[2]=d*_+f*E+g*S,r[5]=d*m+f*A+g*w,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],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-n*r*h+n*o*l+s*r*c-s*a*l}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=h*a-o*c,d=o*l-h*r,f=c*r-a*l,g=t*u+n*d+s*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/g;return e[0]=u*_,e[1]=(s*c-h*n)*_,e[2]=(o*n-s*a)*_,e[3]=d*_,e[4]=(h*t-s*l)*_,e[5]=(s*r-o*t)*_,e[6]=f*_,e[7]=(n*l-c*t)*_,e[8]=(a*t-n*r)*_,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 l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-s*c,s*l,-s*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return Gs("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Do.makeScale(e,t)),this}rotate(e){return Gs("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Do.makeRotation(-e)),this}translate(e,t){return Gs("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Do.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 Do=new ze,ou=new ze().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),lu=new ze().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function wm(){const i={enabled:!0,workingColorSpace:Za,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===tt&&(s.r=oi(s.r),s.g=oi(s.g),s.b=oi(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===tt&&(s.r=Vs(s.r),s.g=Vs(s.g),s.b=Vs(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===wi?Ja: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 Gs("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Gs("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({[Za]:{primaries:e,whitePoint:n,transfer:Ja,toXYZ:ou,fromXYZ:lu,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:yn},outputColorSpaceConfig:{drawingBufferColorSpace:yn}},[yn]:{primaries:e,whitePoint:n,transfer:tt,toXYZ:ou,fromXYZ:lu,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:yn}}}),i}const Ke=wm();function oi(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Vs(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let ps;class Am{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{ps===void 0&&(ps=Qa("canvas")),ps.width=e.width,ps.height=e.height;const s=ps.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=ps}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=Qa("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]=oi(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(oi(t[n]/255)*255):t[n]=oi(t[n]);return{data:t,width:e.width,height:e.height}}else return Oe("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Tm=0;class ch{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Tm++}),this.uuid=Ci(),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(Po(s[a].image)):r.push(Po(s[a]))}else r=Po(s);n.url=r}return t||(e.images[this.uuid]=n),n}}function Po(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?Am.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Oe("Texture: Unable to serialize Texture."),{})}let Rm=0;const Io=new U;class Kt extends os{constructor(e=Kt.DEFAULT_IMAGE,t=Kt.DEFAULT_MAPPING,n=mn,s=mn,r=Rt,a=Ji,o=gn,l=pn,c=Kt.DEFAULT_ANISOTROPY,h=wi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Rm++}),this.uuid=Ci(),this.name="",this.source=new ch(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new 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(Io).x}get height(){return this.source.getSize(Io).y}get depth(){return this.source.getSize(Io).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){Oe(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Oe(`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!==y0)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case kl:e.x=e.x-Math.floor(e.x);break;case mn:e.x=e.x<0?0:1;break;case Hl: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 kl:e.y=e.y-Math.floor(e.y);break;case mn:e.y=e.y<0?0:1;break;case Hl:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Kt.DEFAULT_IMAGE=null;Kt.DEFAULT_MAPPING=y0;Kt.DEFAULT_ANISOTROPY=1;class pt{static{pt.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 l=e.elements,c=l[0],h=l[4],u=l[8],d=l[1],f=l[5],g=l[9],_=l[2],m=l[6],p=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-_)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+_)<.1&&Math.abs(g+m)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const A=(c+1)/2,M=(f+1)/2,S=(p+1)/2,w=(h+d)/4,R=(u+_)/4,x=(g+m)/4;return A>M&&A>S?A<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(A),s=w/n,r=R/n):M>S?M<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(M),n=w/s,r=x/s):S<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(S),n=R/r,s=x/r),this.set(n,s,r,t),this}let E=Math.sqrt((m-g)*(m-g)+(u-_)*(u-_)+(d-h)*(d-h));return Math.abs(E)<.001&&(E=1),this.x=(m-g)/E,this.y=(u-_)/E,this.z=(d-h)/E,this.w=Math.acos((c+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=Xe(this.x,e.x,t.x),this.y=Xe(this.y,e.y,t.y),this.z=Xe(this.z,e.z,t.z),this.w=Xe(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Xe(this.x,e,t),this.y=Xe(this.y,e,t),this.z=Xe(this.z,e,t),this.w=Xe(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Xe(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 Cm extends os{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Rt,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 pt(0,0,e,t),this.scissorTest=!1,this.viewport=new pt(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:n.depth},r=new Kt(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:Rt,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 ch(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 an extends Cm{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class D0 extends Kt{constructor(e=null,t=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Dt,this.minFilter=Dt,this.wrapR=mn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Dm extends Kt{constructor(e=null,t=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Dt,this.minFilter=Dt,this.wrapR=mn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ht{static{ht.prototype.isMatrix4=!0}constructor(e,t,n,s,r,a,o,l,c,h,u,d,f,g,_,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,l,c,h,u,d,f,g,_,m)}set(e,t,n,s,r,a,o,l,c,h,u,d,f,g,_,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]=l,p[2]=c,p[6]=h,p[10]=u,p[14]=d,p[3]=f,p[7]=g,p[11]=_,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 ht().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/ms.setFromMatrixColumn(e,0).length(),r=1/ms.setFromMatrixColumn(e,1).length(),a=1/ms.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),l=Math.cos(s),c=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,_=o*u;t[0]=l*h,t[4]=-l*u,t[8]=c,t[1]=f+g*c,t[5]=d-_*c,t[9]=-o*l,t[2]=_-d*c,t[6]=g+f*c,t[10]=a*l}else if(e.order==="YXZ"){const d=l*h,f=l*u,g=c*h,_=c*u;t[0]=d+_*o,t[4]=g*o-f,t[8]=a*c,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=f*o-g,t[6]=_+d*o,t[10]=a*l}else if(e.order==="ZXY"){const d=l*h,f=l*u,g=c*h,_=c*u;t[0]=d-_*o,t[4]=-a*u,t[8]=g+f*o,t[1]=f+g*o,t[5]=a*h,t[9]=_-d*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const d=a*h,f=a*u,g=o*h,_=o*u;t[0]=l*h,t[4]=g*c-f,t[8]=d*c+_,t[1]=l*u,t[5]=_*c+d,t[9]=f*c-g,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const d=a*l,f=a*c,g=o*l,_=o*c;t[0]=l*h,t[4]=_-d*u,t[8]=g*u+f,t[1]=u,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=f*u+g,t[10]=d-_*u}else if(e.order==="XZY"){const d=a*l,f=a*c,g=o*l,_=o*c;t[0]=l*h,t[4]=-u,t[8]=c*h,t[1]=d*u+_,t[5]=a*h,t[9]=f*u-g,t[2]=g*u-f,t[6]=o*h,t[10]=_*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(Pm,e,Im)}lookAt(e,t,n){const s=this.elements;return ln.subVectors(e,t),ln.lengthSq()===0&&(ln.z=1),ln.normalize(),mi.crossVectors(n,ln),mi.lengthSq()===0&&(Math.abs(n.z)===1?ln.x+=1e-4:ln.z+=1e-4,ln.normalize(),mi.crossVectors(n,ln)),mi.normalize(),$r.crossVectors(ln,mi),s[0]=mi.x,s[4]=$r.x,s[8]=ln.x,s[1]=mi.y,s[5]=$r.y,s[9]=ln.y,s[2]=mi.z,s[6]=$r.z,s[10]=ln.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],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],f=n[13],g=n[2],_=n[6],m=n[10],p=n[14],E=n[3],A=n[7],M=n[11],S=n[15],w=s[0],R=s[4],x=s[8],b=s[12],D=s[1],C=s[5],I=s[9],W=s[13],X=s[2],F=s[6],q=s[10],G=s[14],Z=s[3],te=s[7],j=s[11],ie=s[15];return r[0]=a*w+o*D+l*X+c*Z,r[4]=a*R+o*C+l*F+c*te,r[8]=a*x+o*I+l*q+c*j,r[12]=a*b+o*W+l*G+c*ie,r[1]=h*w+u*D+d*X+f*Z,r[5]=h*R+u*C+d*F+f*te,r[9]=h*x+u*I+d*q+f*j,r[13]=h*b+u*W+d*G+f*ie,r[2]=g*w+_*D+m*X+p*Z,r[6]=g*R+_*C+m*F+p*te,r[10]=g*x+_*I+m*q+p*j,r[14]=g*b+_*W+m*G+p*ie,r[3]=E*w+A*D+M*X+S*Z,r[7]=E*R+A*C+M*F+S*te,r[11]=E*x+A*I+M*q+S*j,r[15]=E*b+A*W+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],l=e[9],c=e[13],h=e[2],u=e[6],d=e[10],f=e[14],g=e[3],_=e[7],m=e[11],p=e[15],E=l*f-c*d,A=o*f-c*u,M=o*d-l*u,S=a*f-c*h,w=a*d-l*h,R=a*u-o*h;return t*(_*E-m*A+p*M)-n*(g*E-m*S+p*w)+s*(g*A-_*S+p*R)-r*(g*M-_*w+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],l=e[2],c=e[6],h=e[10];return t*(a*h-o*c)-n*(r*h-o*l)+s*(r*c-a*l)}transpose(){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],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],f=e[11],g=e[12],_=e[13],m=e[14],p=e[15],E=t*o-n*a,A=t*l-s*a,M=t*c-r*a,S=n*l-s*o,w=n*c-r*o,R=s*c-r*l,x=h*_-u*g,b=h*m-d*g,D=h*p-f*g,C=u*m-d*_,I=u*p-f*_,W=d*p-f*m,X=E*W-A*I+M*C+S*D-w*b+R*x;if(X===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const F=1/X;return e[0]=(o*W-l*I+c*C)*F,e[1]=(s*I-n*W-r*C)*F,e[2]=(_*R-m*w+p*S)*F,e[3]=(d*w-u*R-f*S)*F,e[4]=(l*D-a*W-c*b)*F,e[5]=(t*W-s*D+r*b)*F,e[6]=(m*M-g*R-p*A)*F,e[7]=(h*R-d*M+f*A)*F,e[8]=(a*I-o*D+c*x)*F,e[9]=(n*D-t*I-r*x)*F,e[10]=(g*w-_*M+p*E)*F,e[11]=(u*M-h*w-f*E)*F,e[12]=(o*b-a*C-l*x)*F,e[13]=(t*C-n*b+s*x)*F,e[14]=(_*A-g*S-m*E)*F,e[15]=(h*S-u*A+d*E)*F,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,l=e.z,c=r*a,h=r*o;return this.set(c*a+n,c*o-s*l,c*l+s*o,0,c*o+s*l,h*o+n,h*l-s*a,0,c*l-s*o,h*l+s*a,r*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,s,r,a){return this.set(1,n,r,0,e,1,a,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){const s=this.elements,r=t._x,a=t._y,o=t._z,l=t._w,c=r+r,h=a+a,u=o+o,d=r*c,f=r*h,g=r*u,_=a*h,m=a*u,p=o*u,E=l*c,A=l*h,M=l*u,S=n.x,w=n.y,R=n.z;return s[0]=(1-(_+p))*S,s[1]=(f+M)*S,s[2]=(g-A)*S,s[3]=0,s[4]=(f-M)*w,s[5]=(1-(d+p))*w,s[6]=(m+E)*w,s[7]=0,s[8]=(g+A)*R,s[9]=(m-E)*R,s[10]=(1-(d+_))*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=ms.set(s[0],s[1],s[2]).length();const o=ms.set(s[4],s[5],s[6]).length(),l=ms.set(s[8],s[9],s[10]).length();r<0&&(a=-a),En.copy(this);const c=1/a,h=1/o,u=1/l;return En.elements[0]*=c,En.elements[1]*=c,En.elements[2]*=c,En.elements[4]*=h,En.elements[5]*=h,En.elements[6]*=h,En.elements[8]*=u,En.elements[9]*=u,En.elements[10]*=u,t.setFromRotationMatrix(En),n.x=a,n.y=o,n.z=l,this}makePerspective(e,t,n,s,r,a,o=qn,l=!1){const c=this.elements,h=2*r/(t-e),u=2*r/(n-s),d=(t+e)/(t-e),f=(n+s)/(n-s);let g,_;if(l)g=r/(a-r),_=a*r/(a-r);else if(o===qn)g=-(a+r)/(a-r),_=-2*a*r/(a-r);else if(o===Ir)g=-a/(a-r),_=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=g,c[14]=_,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,s,r,a,o=qn,l=!1){const c=this.elements,h=2/(t-e),u=2/(n-s),d=-(t+e)/(t-e),f=-(n+s)/(n-s);let g,_;if(l)g=1/(a-r),_=a/(a-r);else if(o===qn)g=-2/(a-r),_=-(a+r)/(a-r);else if(o===Ir)g=-1/(a-r),_=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=g,c[14]=_,c[3]=0,c[7]=0,c[11]=0,c[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 ms=new U,En=new ht,Pm=new U(0,0,0),Im=new U(1,1,1),mi=new U,$r=new U,ln=new U,cu=new ht,hu=new js;class Ii{constructor(e=0,t=0,n=0,s=Ii.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],l=s[1],c=s[5],h=s[9],u=s[2],d=s[6],f=s[10];switch(t){case"XYZ":this._y=Math.asin(Xe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Xe(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(Xe(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-Xe(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Xe(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Xe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,f),this._y=0);break;default:Oe("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return cu.makeRotationFromQuaternion(e),this.setFromRotationMatrix(cu,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return hu.setFromEuler(this),this.setFromQuaternion(hu,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}}Ii.DEFAULT_ORDER="XYZ";class hh{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 Lm=0;const uu=new U,gs=new js,Jn=new ht,Zr=new U,ir=new U,Nm=new U,Um=new js,du=new U(1,0,0),fu=new U(0,1,0),pu=new U(0,0,1),mu={type:"added"},Fm={type:"removed"},vs={type:"childadded",child:null},Lo={type:"childremoved",child:null};class Ct extends os{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Lm++}),this.uuid=Ci(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ct.DEFAULT_UP.clone();const e=new U,t=new Ii,n=new js,s=new U(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 ht},normalMatrix:{value:new ze}}),this.matrix=new ht,this.matrixWorld=new ht,this.matrixAutoUpdate=Ct.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ct.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new hh,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 gs.setFromAxisAngle(e,t),this.quaternion.multiply(gs),this}rotateOnWorldAxis(e,t){return gs.setFromAxisAngle(e,t),this.quaternion.premultiply(gs),this}rotateX(e){return this.rotateOnAxis(du,e)}rotateY(e){return this.rotateOnAxis(fu,e)}rotateZ(e){return this.rotateOnAxis(pu,e)}translateOnAxis(e,t){return uu.copy(e).applyQuaternion(this.quaternion),this.position.add(uu.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(du,e)}translateY(e){return this.translateOnAxis(fu,e)}translateZ(e){return this.translateOnAxis(pu,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Jn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Zr.copy(e):Zr.set(e,t,n);const s=this.parent;this.updateWorldMatrix(!0,!1),ir.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Jn.lookAt(ir,Zr,this.up):Jn.lookAt(Zr,ir,this.up),this.quaternion.setFromRotationMatrix(Jn),s&&(Jn.extractRotation(s.matrixWorld),gs.setFromRotationMatrix(Jn),this.quaternion.premultiply(gs.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Ye("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(mu),vs.child=e,this.dispatchEvent(vs),vs.child=null):Ye("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(Fm),Lo.child=e,this.dispatchEvent(Lo),Lo.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),Jn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Jn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Jn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(mu),vs.child=e,this.dispatchEvent(vs),vs.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(ir,e,Nm),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ir,Um,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,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const u=l[c];r(e.shapes,u)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(r(e.materials,this.material[l]));s.material=o}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];s.animations.push(r(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),u=a(e.shapes),d=a(e.skeletons),f=a(e.animations),g=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),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 l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const s=e.children[n];this.add(s.clone())}return this}}Ct.DEFAULT_UP=new U(0,1,0);Ct.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ct.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Cn extends Ct{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Om={type:"move"};class No{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Cn,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 Cn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new U,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new U),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Cn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new U,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new U,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,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const _ of e.hand.values()){const m=t.getJointPose(_,n),p=this._getHandJoint(c,_);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=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,g=.005;c.inputState.pinching&&d>f+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=f-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Om)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Cn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const P0={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},gi={h:0,s:0,l:0},Jr={h:0,s:0,l:0};function Uo(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=yn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ke.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=Ke.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ke.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=Ke.workingColorSpace){if(e=Em(e,1),t=Xe(t,0,1),n=Xe(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=Uo(a,r,e+1/3),this.g=Uo(a,r,e),this.b=Uo(a,r,e-1/3)}return Ke.colorSpaceToWorking(this,s),this}setStyle(e,t=yn){function n(r){r!==void 0&&parseFloat(r)<1&&Oe("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:Oe("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);Oe("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=yn){const n=P0[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Oe("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=oi(e.r),this.g=oi(e.g),this.b=oi(e.b),this}copyLinearToSRGB(e){return this.r=Vs(e.r),this.g=Vs(e.g),this.b=Vs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=yn){return Ke.workingToColorSpace(Wt.copy(this),e),Math.round(Xe(Wt.r*255,0,255))*65536+Math.round(Xe(Wt.g*255,0,255))*256+Math.round(Xe(Wt.b*255,0,255))}getHexString(e=yn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ke.workingColorSpace){Ke.workingToColorSpace(Wt.copy(this),t);const n=Wt.r,s=Wt.g,r=Wt.b,a=Math.max(n,s,r),o=Math.min(n,s,r);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const u=a-o;switch(c=h<=.5?u/(a+o):u/(2-a-o),a){case n:l=(s-r)/u+(s<r?6:0);break;case s:l=(r-n)/u+2;break;case r:l=(n-s)/u+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Ke.workingColorSpace){return Ke.workingToColorSpace(Wt.copy(this),t),e.r=Wt.r,e.g=Wt.g,e.b=Wt.b,e}getStyle(e=yn){Ke.workingToColorSpace(Wt.copy(this),e);const t=Wt.r,n=Wt.g,s=Wt.b;return e!==yn?`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(gi),this.setHSL(gi.h+e,gi.s+t,gi.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(gi),e.getHSL(Jr);const n=Ro(gi.h,Jr.h,t),s=Ro(gi.s,Jr.s,t),r=Ro(gi.l,Jr.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 Wt=new Me;Me.NAMES=P0;class uh{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 uh(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class po extends Ct{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 Ii,this.environmentIntensity=1,this.environmentRotation=new Ii,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 wn=new U,Qn=new U,Fo=new U,jn=new U,xs=new U,_s=new U,gu=new U,Oo=new U,zo=new U,Bo=new U,ko=new pt,Ho=new pt,Go=new pt;class Sn{constructor(e=new U,t=new U,n=new U){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),wn.subVectors(e,t),s.cross(wn);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){wn.subVectors(s,t),Qn.subVectors(n,t),Fo.subVectors(e,t);const a=wn.dot(wn),o=wn.dot(Qn),l=wn.dot(Fo),c=Qn.dot(Qn),h=Qn.dot(Fo),u=a*c-o*o;if(u===0)return r.set(0,0,0),null;const d=1/u,f=(c*l-o*h)*d,g=(a*h-o*l)*d;return r.set(1-f-g,g,f)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,jn)===null?!1:jn.x>=0&&jn.y>=0&&jn.x+jn.y<=1}static getInterpolation(e,t,n,s,r,a,o,l){return this.getBarycoord(e,t,n,s,jn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,jn.x),l.addScaledVector(a,jn.y),l.addScaledVector(o,jn.z),l)}static getInterpolatedAttribute(e,t,n,s,r,a){return ko.setScalar(0),Ho.setScalar(0),Go.setScalar(0),ko.fromBufferAttribute(e,t),Ho.fromBufferAttribute(e,n),Go.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(ko,r.x),a.addScaledVector(Ho,r.y),a.addScaledVector(Go,r.z),a}static isFrontFacing(e,t,n,s){return wn.subVectors(n,t),Qn.subVectors(e,t),wn.cross(Qn).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 wn.subVectors(this.c,this.b),Qn.subVectors(this.a,this.b),wn.cross(Qn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Sn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Sn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return Sn.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return Sn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Sn.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;xs.subVectors(s,n),_s.subVectors(r,n),Oo.subVectors(e,n);const l=xs.dot(Oo),c=_s.dot(Oo);if(l<=0&&c<=0)return t.copy(n);zo.subVectors(e,s);const h=xs.dot(zo),u=_s.dot(zo);if(h>=0&&u<=h)return t.copy(s);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(n).addScaledVector(xs,a);Bo.subVectors(e,r);const f=xs.dot(Bo),g=_s.dot(Bo);if(g>=0&&f<=g)return t.copy(r);const _=f*c-l*g;if(_<=0&&c>=0&&g<=0)return o=c/(c-g),t.copy(n).addScaledVector(_s,o);const m=h*g-f*u;if(m<=0&&u-h>=0&&f-g>=0)return gu.subVectors(r,s),o=(u-h)/(u-h+(f-g)),t.copy(s).addScaledVector(gu,o);const p=1/(m+_+d);return a=_*p,o=d*p,t.copy(n).addScaledVector(xs,a).addScaledVector(_s,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Ur{constructor(e=new U(1/0,1/0,1/0),t=new U(-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(An.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(An.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=An.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,An):An.fromBufferAttribute(r,a),An.applyMatrix4(e.matrixWorld),this.expandByPoint(An);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Qr.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Qr.copy(n.boundingBox)),Qr.applyMatrix4(e.matrixWorld),this.union(Qr)}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,An),An.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(sr),jr.subVectors(this.max,sr),Ms.subVectors(e.a,sr),ys.subVectors(e.b,sr),Ss.subVectors(e.c,sr),vi.subVectors(ys,Ms),xi.subVectors(Ss,ys),zi.subVectors(Ms,Ss);let t=[0,-vi.z,vi.y,0,-xi.z,xi.y,0,-zi.z,zi.y,vi.z,0,-vi.x,xi.z,0,-xi.x,zi.z,0,-zi.x,-vi.y,vi.x,0,-xi.y,xi.x,0,-zi.y,zi.x,0];return!Vo(t,Ms,ys,Ss,jr)||(t=[1,0,0,0,1,0,0,0,1],!Vo(t,Ms,ys,Ss,jr))?!1:(ea.crossVectors(vi,xi),t=[ea.x,ea.y,ea.z],Vo(t,Ms,ys,Ss,jr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,An).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(An).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:(ei[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ei[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ei[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ei[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ei[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ei[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ei[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ei[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ei),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 ei=[new U,new U,new U,new U,new U,new U,new U,new U],An=new U,Qr=new Ur,Ms=new U,ys=new U,Ss=new U,vi=new U,xi=new U,zi=new U,sr=new U,jr=new U,ea=new U,Bi=new U;function Vo(i,e,t,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){Bi.fromArray(i,r);const o=s.x*Math.abs(Bi.x)+s.y*Math.abs(Bi.y)+s.z*Math.abs(Bi.z),l=e.dot(Bi),c=t.dot(Bi),h=n.dot(Bi);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const ai=zm();function zm(){const i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),s=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,s[l]=24,s[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,s[l]=-c-1,s[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,s[l]=13,s[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,s[l]=24,s[l|256]=24):(n[l]=31744,n[l|256]=64512,s[l]=13,s[l|256]=13)}const r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;(c&8388608)===0;)c<<=1,h-=8388608;c&=-8388609,h+=947912704,r[l]=c|h}for(let l=1024;l<2048;++l)r[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:s,mantissaTable:r,exponentTable:a,offsetTable:o}}function Bm(i){Math.abs(i)>65504&&Oe("DataUtils.toHalfFloat(): Value out of range."),i=Xe(i,-65504,65504),ai.floatView[0]=i;const e=ai.uint32View[0],t=e>>23&511;return ai.baseTable[t]+((e&8388607)>>ai.shiftTable[t])}function km(i){const e=i>>10;return ai.uint32View[0]=ai.mantissaTable[ai.offsetTable[e]+(i&1023)]+ai.exponentTable[e],ai.floatView[0]}class Ws{static toHalfFloat(e){return Bm(e)}static fromHalfFloat(e){return km(e)}}const At=new U,ta=new Le;let Hm=0;class ct extends os{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:Hm++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=_c,this.updateRanges=[],this.gpuType=Xn,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++)At.fromBufferAttribute(this,t),At.applyMatrix3(e),this.setXYZ(t,At.x,At.y,At.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)At.fromBufferAttribute(this,t),At.applyMatrix4(e),this.setXYZ(t,At.x,At.y,At.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)At.fromBufferAttribute(this,t),At.applyNormalMatrix(e),this.setXYZ(t,At.x,At.y,At.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)At.fromBufferAttribute(this,t),At.transformDirection(e),this.setXYZ(t,At.x,At.y,At.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=Wn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=st(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Wn(t,this.array)),t}setX(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Wn(t,this.array)),t}setY(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Wn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Wn(t,this.array)),t}setW(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array),s=st(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array),s=st(s,this.array),r=st(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){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!==_c&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class I0 extends ct{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class L0 extends ct{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class It extends ct{constructor(e,t,n){super(new Float32Array(e),t,n)}}const Gm=new Ur,rr=new U,Wo=new U;class mo{constructor(e=new U,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):Gm.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;rr.subVectors(e,this.center);const t=rr.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(rr,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):(Wo.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(rr.copy(e.center).add(Wo)),this.expandByPoint(rr.copy(e.center).sub(Wo))),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 Vm=0;const xn=new ht,Xo=new Ct,bs=new U,cn=new Ur,ar=new Ur,Ft=new U;class bt extends os{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Vm++}),this.uuid=Ci(),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(Mm(e)?L0:I0)(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 xn.makeRotationFromQuaternion(e),this.applyMatrix4(xn),this}rotateX(e){return xn.makeRotationX(e),this.applyMatrix4(xn),this}rotateY(e){return xn.makeRotationY(e),this.applyMatrix4(xn),this}rotateZ(e){return xn.makeRotationZ(e),this.applyMatrix4(xn),this}translate(e,t,n){return xn.makeTranslation(e,t,n),this.applyMatrix4(xn),this}scale(e,t,n){return xn.makeScale(e,t,n),this.applyMatrix4(xn),this}lookAt(e){return Xo.lookAt(e),Xo.updateMatrix(),this.applyMatrix4(Xo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(bs).negate(),this.translate(bs.x,bs.y,bs.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 It(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&&Oe("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 Ur);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ye("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new U(-1/0,-1/0,-1/0),new U(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];cn.setFromBufferAttribute(r),this.morphTargetsRelative?(Ft.addVectors(this.boundingBox.min,cn.min),this.boundingBox.expandByPoint(Ft),Ft.addVectors(this.boundingBox.max,cn.max),this.boundingBox.expandByPoint(Ft)):(this.boundingBox.expandByPoint(cn.min),this.boundingBox.expandByPoint(cn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ye('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 mo);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ye("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new U,1/0);return}if(e){const n=this.boundingSphere.center;if(cn.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];ar.setFromBufferAttribute(o),this.morphTargetsRelative?(Ft.addVectors(cn.min,ar.min),cn.expandByPoint(Ft),Ft.addVectors(cn.max,ar.max),cn.expandByPoint(Ft)):(cn.expandByPoint(ar.min),cn.expandByPoint(ar.max))}cn.getCenter(n);let s=0;for(let r=0,a=e.count;r<a;r++)Ft.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(Ft));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)Ft.fromBufferAttribute(o,c),l&&(bs.fromBufferAttribute(e,c),Ft.add(bs)),s=Math.max(s,n.distanceToSquared(Ft))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&Ye('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){Ye("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 ct(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],l=[];for(let x=0;x<n.count;x++)o[x]=new U,l[x]=new U;const c=new U,h=new U,u=new U,d=new Le,f=new Le,g=new Le,_=new U,m=new U;function p(x,b,D){c.fromBufferAttribute(n,x),h.fromBufferAttribute(n,b),u.fromBufferAttribute(n,D),d.fromBufferAttribute(r,x),f.fromBufferAttribute(r,b),g.fromBufferAttribute(r,D),h.sub(c),u.sub(c),f.sub(d),g.sub(d);const C=1/(f.x*g.y-g.x*f.y);isFinite(C)&&(_.copy(h).multiplyScalar(g.y).addScaledVector(u,-f.y).multiplyScalar(C),m.copy(u).multiplyScalar(f.x).addScaledVector(h,-g.x).multiplyScalar(C),o[x].add(_),o[b].add(_),o[D].add(_),l[x].add(m),l[b].add(m),l[D].add(m))}let E=this.groups;E.length===0&&(E=[{start:0,count:e.count}]);for(let x=0,b=E.length;x<b;++x){const D=E[x],C=D.start,I=D.count;for(let W=C,X=C+I;W<X;W+=3)p(e.getX(W+0),e.getX(W+1),e.getX(W+2))}const A=new U,M=new U,S=new U,w=new U;function R(x){S.fromBufferAttribute(s,x),w.copy(S);const b=o[x];A.copy(b),A.sub(S.multiplyScalar(S.dot(b))).normalize(),M.crossVectors(w,b);const C=M.dot(l[x])<0?-1:1;a.setXYZW(x,A.x,A.y,A.z,C)}for(let x=0,b=E.length;x<b;++x){const D=E[x],C=D.start,I=D.count;for(let W=C,X=C+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 ct(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 U,r=new U,a=new U,o=new U,l=new U,c=new U,h=new U,u=new U;if(e)for(let d=0,f=e.count;d<f;d+=3){const g=e.getX(d+0),_=e.getX(d+1),m=e.getX(d+2);s.fromBufferAttribute(t,g),r.fromBufferAttribute(t,_),a.fromBufferAttribute(t,m),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),o.fromBufferAttribute(n,g),l.fromBufferAttribute(n,_),c.fromBufferAttribute(n,m),o.add(h),l.add(h),c.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(_,l.x,l.y,l.z),n.setXYZ(m,c.x,c.y,c.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++)Ft.fromBufferAttribute(e,t),Ft.normalize(),e.setXYZ(t,Ft.x,Ft.y,Ft.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,u=o.normalized,d=new c.constructor(l.length*h);let f=0,g=0;for(let _=0,m=l.length;_<m;_++){o.isInterleavedBufferAttribute?f=l[_]*o.data.stride+o.offset:f=l[_]*h;for(let p=0;p<h;p++)d[g++]=c[f++]}return new ct(d,h,u)}if(this.index===null)return Oe("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new bt,n=this.index.array,s=this.attributes;for(const o in s){const l=s[o],c=e(l,n);t.setAttribute(o,c)}const r=this.morphAttributes;for(const o in r){const l=[],c=r[o];for(let h=0,u=c.length;h<u;h++){const d=c[h],f=e(d,n);l.push(f)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.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 l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);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 l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){const f=c[u];h.push(f.toJSON(e.data))}h.length>0&&(s[l]=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 c in s){const h=s[c];this.setAttribute(c,h.clone(t))}const r=e.morphAttributes;for(const c in r){const h=[],u=r[c];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,h=a.length;c<h;c++){const u=a[c];this.addGroup(u.start,u.count,u.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Wm{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=_c,this.updateRanges=[],this.version=0,this.uuid=Ci()}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=Ci()),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=Ci()),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 $t=new U;class eo{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++)$t.fromBufferAttribute(this,t),$t.applyMatrix4(e),this.setXYZ(t,$t.x,$t.y,$t.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)$t.fromBufferAttribute(this,t),$t.applyNormalMatrix(e),this.setXYZ(t,$t.x,$t.y,$t.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)$t.fromBufferAttribute(this,t),$t.transformDirection(e),this.setXYZ(t,$t.x,$t.y,$t.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Wn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=st(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Wn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Wn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Wn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Wn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),n=st(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),n=st(n,this.array),s=st(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),n=st(n,this.array),s=st(s,this.array),r=st(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this.data.array[e+3]=r,this}clone(e){if(e===void 0){ja("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 ct(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 eo(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){ja("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 Xm=0;class ls extends os{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Xm++}),this.uuid=Ci(),this.name="",this.type="Material",this.blending=Hs,this.side=Pi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Pl,this.blendDst=Il,this.blendEquation=Yi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Me(0,0,0),this.blendAlpha=0,this.depthFunc=$s,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=iu,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=fs,this.stencilZFail=fs,this.stencilZPass=fs,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){Oe(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Oe(`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!==Hs&&(n.blending=this.blending),this.side!==Pi&&(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!==Pl&&(n.blendSrc=this.blendSrc),this.blendDst!==Il&&(n.blendDst=this.blendDst),this.blendEquation!==Yi&&(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!==$s&&(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!==iu&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==fs&&(n.stencilFail=this.stencilFail),this.stencilZFail!==fs&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==fs&&(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 l=r[o];delete l.metadata,a.push(l)}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 vr extends ls{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 Es;const or=new U,ws=new U,As=new U,Ts=new Le,lr=new Le,N0=new ht,na=new U,cr=new U,ia=new U,vu=new Le,qo=new Le,xu=new Le;class sa extends Ct{constructor(e=new vr){if(super(),this.isSprite=!0,this.type="Sprite",Es===void 0){Es=new bt;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 Wm(t,5);Es.setIndex([0,1,2,0,2,3]),Es.setAttribute("position",new eo(n,3,0,!1)),Es.setAttribute("uv",new eo(n,2,3,!1))}this.geometry=Es,this.material=e,this.center=new Le(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Ye('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),ws.setFromMatrixScale(this.matrixWorld),N0.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),As.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&ws.multiplyScalar(-As.z);const n=this.material.rotation;let s,r;n!==0&&(r=Math.cos(n),s=Math.sin(n));const a=this.center;ra(na.set(-.5,-.5,0),As,a,ws,s,r),ra(cr.set(.5,-.5,0),As,a,ws,s,r),ra(ia.set(.5,.5,0),As,a,ws,s,r),vu.set(0,0),qo.set(1,0),xu.set(1,1);let o=e.ray.intersectTriangle(na,cr,ia,!1,or);if(o===null&&(ra(cr.set(-.5,.5,0),As,a,ws,s,r),qo.set(0,1),o=e.ray.intersectTriangle(na,ia,cr,!1,or),o===null))return;const l=e.ray.origin.distanceTo(or);l<e.near||l>e.far||t.push({distance:l,point:or.clone(),uv:Sn.getInterpolation(or,na,cr,ia,vu,qo,xu,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 ra(i,e,t,n,s,r){Ts.subVectors(i,t).addScalar(.5).multiply(n),s!==void 0?(lr.x=r*Ts.x-s*Ts.y,lr.y=s*Ts.x+r*Ts.y):lr.copy(Ts),i.copy(e),i.x+=lr.x,i.y+=lr.y,i.applyMatrix4(N0)}const ti=new U,Yo=new U,aa=new U,_i=new U,Ko=new U,oa=new U,$o=new U;class dh{constructor(e=new U,t=new U(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,ti)),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=ti.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ti.copy(this.origin).addScaledVector(this.direction,t),ti.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){Yo.copy(e).add(t).multiplyScalar(.5),aa.copy(t).sub(e).normalize(),_i.copy(this.origin).sub(Yo);const r=e.distanceTo(t)*.5,a=-this.direction.dot(aa),o=_i.dot(this.direction),l=-_i.dot(aa),c=_i.lengthSq(),h=Math.abs(1-a*a);let u,d,f,g;if(h>0)if(u=a*l-o,d=a*o-l,g=r*h,u>=0)if(d>=-g)if(d<=g){const _=1/h;u*=_,d*=_,f=u*(u+a*d+2*o)+d*(a*u+d+2*l)+c}else d=r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d=-r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d<=-g?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-l),r),f=-u*u+d*(d+2*l)+c):d<=g?(u=0,d=Math.min(Math.max(-r,-l),r),f=d*(d+2*l)+c):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-l),r),f=-u*u+d*(d+2*l)+c);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(Yo).addScaledVector(aa,d),f}intersectSphere(e,t){ti.subVectors(e.center,this.origin);const n=ti.dot(this.direction),s=ti.dot(ti)-n*n,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){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,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,s=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,s=(e.min.x-d.x)*c),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,l=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,l=(e.min.z-d.z)*u),n>l||o>s)||((o>n||n!==n)&&(n=o),(l<s||s!==s)&&(s=l),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,ti)!==null}intersectTriangle(e,t,n,s,r){Ko.subVectors(t,e),oa.subVectors(n,e),$o.crossVectors(Ko,oa);let a=this.direction.dot($o),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;_i.subVectors(this.origin,e);const l=o*this.direction.dot(oa.crossVectors(_i,oa));if(l<0)return null;const c=o*this.direction.dot(Ko.cross(_i));if(c<0||l+c>a)return null;const h=-o*_i.dot($o);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 is extends ls{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 Ii,this.combine=eh,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 _u=new ht,ki=new dh,la=new mo,Mu=new U,ca=new U,ha=new U,ua=new U,Zo=new U,da=new U,yu=new U,fa=new U;class Je extends Ct{constructor(e=new bt,t=new is){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){da.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const h=o[l],u=r[l];h!==0&&(Zo.fromBufferAttribute(u,e),a?da.addScaledVector(Zo,h):da.addScaledVector(Zo.sub(t),h))}t.add(da)}return t}raycast(e,t){const n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),la.copy(n.boundingSphere),la.applyMatrix4(r),ki.copy(e.ray).recast(e.near),!(la.containsPoint(ki.origin)===!1&&(ki.intersectSphere(la,Mu)===null||ki.origin.distanceToSquared(Mu)>(e.far-e.near)**2))&&(_u.copy(r).invert(),ki.copy(e.ray).applyMatrix4(_u),!(n.boundingBox!==null&&ki.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,ki)))}_computeIntersections(e,t,n){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=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,_=d.length;g<_;g++){const m=d[g],p=a[m.materialIndex],E=Math.max(m.start,f.start),A=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let M=E,S=A;M<S;M+=3){const w=o.getX(M),R=o.getX(M+1),x=o.getX(M+2);s=pa(this,p,e,n,c,h,u,w,R,x),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{const g=Math.max(0,f.start),_=Math.min(o.count,f.start+f.count);for(let m=g,p=_;m<p;m+=3){const E=o.getX(m),A=o.getX(m+1),M=o.getX(m+2);s=pa(this,a,e,n,c,h,u,E,A,M),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}else if(l!==void 0)if(Array.isArray(a))for(let g=0,_=d.length;g<_;g++){const m=d[g],p=a[m.materialIndex],E=Math.max(m.start,f.start),A=Math.min(l.count,Math.min(m.start+m.count,f.start+f.count));for(let M=E,S=A;M<S;M+=3){const w=M,R=M+1,x=M+2;s=pa(this,p,e,n,c,h,u,w,R,x),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{const g=Math.max(0,f.start),_=Math.min(l.count,f.start+f.count);for(let m=g,p=_;m<p;m+=3){const E=m,A=m+1,M=m+2;s=pa(this,a,e,n,c,h,u,E,A,M),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}}}function qm(i,e,t,n,s,r,a,o){let l;if(e.side===Pt?l=n.intersectTriangle(a,r,s,!0,o):l=n.intersectTriangle(s,r,a,e.side===Pi,o),l===null)return null;fa.copy(o),fa.applyMatrix4(i.matrixWorld);const c=t.ray.origin.distanceTo(fa);return c<t.near||c>t.far?null:{distance:c,point:fa.clone(),object:i}}function pa(i,e,t,n,s,r,a,o,l,c){i.getVertexPosition(o,ca),i.getVertexPosition(l,ha),i.getVertexPosition(c,ua);const h=qm(i,e,t,n,ca,ha,ua,yu);if(h){const u=new U;Sn.getBarycoord(yu,ca,ha,ua,u),s&&(h.uv=Sn.getInterpolatedAttribute(s,o,l,c,u,new Le)),r&&(h.uv1=Sn.getInterpolatedAttribute(r,o,l,c,u,new Le)),a&&(h.normal=Sn.getInterpolatedAttribute(a,o,l,c,u,new U),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new U,materialIndex:0};Sn.getNormal(ca,ha,ua,d.normal),h.face=d,h.barycoord=u}return h}class fh extends Kt{constructor(e=null,t=1,n=1,s,r,a,o,l,c=Dt,h=Dt,u,d){super(null,a,o,l,c,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 Jo=new U,Ym=new U,Km=new ze;class Xi{constructor(e=new U(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=Jo.subVectors(n,t).cross(Ym.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(Jo),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||Km.getNormalMatrix(e),s=this.coplanarPoint(Jo).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 Hi=new mo,$m=new Le(.5,.5),ma=new U;class ph{constructor(e=new Xi,t=new Xi,n=new Xi,s=new Xi,r=new Xi,a=new Xi){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=qn,n=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],h=r[4],u=r[5],d=r[6],f=r[7],g=r[8],_=r[9],m=r[10],p=r[11],E=r[12],A=r[13],M=r[14],S=r[15];if(s[0].setComponents(c-a,f-h,p-g,S-E).normalize(),s[1].setComponents(c+a,f+h,p+g,S+E).normalize(),s[2].setComponents(c+o,f+u,p+_,S+A).normalize(),s[3].setComponents(c-o,f-u,p-_,S-A).normalize(),n)s[4].setComponents(l,d,m,M).normalize(),s[5].setComponents(c-l,f-d,p-m,S-M).normalize();else if(s[4].setComponents(c-l,f-d,p-m,S-M).normalize(),t===qn)s[5].setComponents(c+l,f+d,p+m,S+M).normalize();else if(t===Ir)s[5].setComponents(l,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(),Hi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Hi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Hi)}intersectsSprite(e){Hi.center.set(0,0,0);const t=$m.distanceTo(e.center);return Hi.radius=.7071067811865476+t,Hi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Hi)}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 U0 extends ls{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 Su=new ht,yc=new dh,ga=new mo,va=new U;class Va extends Ct{constructor(e=new bt,t=new U0){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(),ga.copy(n.boundingSphere),ga.applyMatrix4(s),ga.radius+=r,e.ray.intersectsSphere(ga)===!1)return;Su.copy(s).invert(),yc.copy(e.ray).applyMatrix4(Su);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,u=n.attributes.position;if(c!==null){const d=Math.max(0,a.start),f=Math.min(c.count,a.start+a.count);for(let g=d,_=f;g<_;g++){const m=c.getX(g);va.fromBufferAttribute(u,m),bu(va,m,l,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,_=f;g<_;g++)va.fromBufferAttribute(u,g),bu(va,g,l,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 bu(i,e,t,n,s,r,a){const o=yc.distanceSqToPoint(i);if(o<t){const l=new U;yc.closestPointToPoint(i,l),l.applyMatrix4(n);const c=s.ray.origin.distanceTo(l);if(c<s.near||c>s.far)return;r.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class F0 extends Kt{constructor(e=[],t=ts,n,s,r,a,o,l,c,h){super(e,t,n,s,r,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class hi extends Kt{constructor(e,t,n,s,r,a,o,l,c){super(e,t,n,s,r,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class ss extends Kt{constructor(e,t,n=Dn,s,r,a,o=Dt,l=Dt,c,h=ci,u=1){if(h!==ci&&h!==Qi)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,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ch(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 ss{constructor(e,t=Dn,n=ts,s,r,a=Dt,o=Dt,l,c=ci){const h={width:e,height:e,depth:1},u=[h,h,h,h,h,h];super(e,e,t,n,s,r,a,o,l,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class O0 extends Kt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class bn extends bt{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 l=[],c=[],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(l),this.setAttribute("position",new It(c,3)),this.setAttribute("normal",new It(h,3)),this.setAttribute("uv",new It(u,2));function g(_,m,p,E,A,M,S,w,R,x,b){const D=M/R,C=S/x,I=M/2,W=S/2,X=w/2,F=R+1,q=x+1;let G=0,Z=0;const te=new U;for(let j=0;j<q;j++){const ie=j*C-W;for(let ue=0;ue<F;ue++){const ke=ue*D-I;te[_]=ke*E,te[m]=ie*A,te[p]=X,c.push(te.x,te.y,te.z),te[_]=0,te[m]=0,te[p]=w>0?1:-1,h.push(te.x,te.y,te.z),u.push(ue/R),u.push(1-j/x),G+=1}}for(let j=0;j<x;j++)for(let ie=0;ie<R;ie++){const ue=d+ie+F*j,ke=d+ie+F*(j+1),qe=d+(ie+1)+F*(j+1),Be=d+(ie+1)+F*j;l.push(ue,ke,Be),l.push(ke,qe,Be),Z+=6}o.addGroup(f,Z,b),f+=Z,d+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class mh extends bt{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=[],l=[],c=new U,h=new Le;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let u=0,d=3;u<=t;u++,d+=3){const f=n+u/t*s;c.x=e*Math.cos(f),c.y=e*Math.sin(f),a.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(a[d]/e+1)/2,h.y=(a[d+1]/e+1)/2,l.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 It(a,3)),this.setAttribute("normal",new It(o,3)),this.setAttribute("uv",new It(l,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 Ni extends bt{constructor(e=1,t=1,n=1,s=32,r=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:s,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:l};const c=this;s=Math.floor(s),r=Math.floor(r);const h=[],u=[],d=[],f=[];let g=0;const _=[],m=n/2;let p=0;E(),a===!1&&(e>0&&A(!0),t>0&&A(!1)),this.setIndex(h),this.setAttribute("position",new It(u,3)),this.setAttribute("normal",new It(d,3)),this.setAttribute("uv",new It(f,2));function E(){const M=new U,S=new U;let w=0;const R=(t-e)/n;for(let x=0;x<=r;x++){const b=[],D=x/r,C=D*(t-e)+e;for(let I=0;I<=s;I++){const W=I/s,X=W*l+o,F=Math.sin(X),q=Math.cos(X);S.x=C*F,S.y=-D*n+m,S.z=C*q,u.push(S.x,S.y,S.z),M.set(F,R,q).normalize(),d.push(M.x,M.y,M.z),f.push(W,1-D),b.push(g++)}_.push(b)}for(let x=0;x<s;x++)for(let b=0;b<r;b++){const D=_[b][x],C=_[b+1][x],I=_[b+1][x+1],W=_[b][x+1];(e>0||b!==0)&&(h.push(D,C,W),w+=3),(t>0||b!==r-1)&&(h.push(C,I,W),w+=3)}c.addGroup(p,w,0),p+=w}function A(M){const S=g,w=new Le,R=new U;let x=0;const b=M===!0?e:t,D=M===!0?1:-1;for(let I=1;I<=s;I++)u.push(0,m*D,0),d.push(0,D,0),f.push(.5,.5),g++;const C=g;for(let I=0;I<=s;I++){const X=I/s*l+o,F=Math.cos(X),q=Math.sin(X);R.x=b*q,R.y=m*D,R.z=b*F,u.push(R.x,R.y,R.z),d.push(0,D,0),w.x=F*.5+.5,w.y=q*.5*D+.5,f.push(w.x,w.y),g++}for(let I=0;I<s;I++){const W=S+I,X=C+I;M===!0?h.push(X,X+1,W):h.push(X+1,X,W),x+=3}c.addGroup(p,x,M===!0?1:2),p+=x}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ni(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class go extends Ni{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 go(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ui extends bt{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),l=Math.floor(s),c=o+1,h=l+1,u=e/o,d=t/l,f=[],g=[],_=[],m=[];for(let p=0;p<h;p++){const E=p*d-a;for(let A=0;A<c;A++){const M=A*u-r;g.push(M,-E,0),_.push(0,0,1),m.push(A/o),m.push(1-p/l)}}for(let p=0;p<l;p++)for(let E=0;E<o;E++){const A=E+c*p,M=E+c*(p+1),S=E+1+c*(p+1),w=E+1+c*p;f.push(A,M,w),f.push(M,S,w)}this.setIndex(f),this.setAttribute("position",new It(g,3)),this.setAttribute("normal",new It(_,3)),this.setAttribute("uv",new It(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ui(e.width,e.height,e.widthSegments,e.heightSegments)}}class Pn extends bt{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 l=Math.min(a+o,Math.PI);let c=0;const h=[],u=new U,d=new U,f=[],g=[],_=[],m=[];for(let p=0;p<=n;p++){const E=[],A=p/n,M=a+A*o,S=e*Math.cos(M),w=Math.sqrt(e*e-S*S);let R=0;p===0&&a===0?R=.5/t:p===n&&l===Math.PI&&(R=-.5/t);for(let x=0;x<=t;x++){const b=x/t,D=s+b*r;u.x=-w*Math.cos(D),u.y=S,u.z=w*Math.sin(D),g.push(u.x,u.y,u.z),d.copy(u).normalize(),_.push(d.x,d.y,d.z),m.push(b+R,1-A),E.push(c++)}h.push(E)}for(let p=0;p<n;p++)for(let E=0;E<t;E++){const A=h[p][E+1],M=h[p][E],S=h[p+1][E],w=h[p+1][E+1];(p!==0||a>0)&&f.push(A,M,w),(p!==n-1||l<Math.PI)&&f.push(M,S,w)}this.setIndex(f),this.setAttribute("position",new It(g,3)),this.setAttribute("normal",new It(_,3)),this.setAttribute("uv",new It(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 Js(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const s=i[t][n];if(Eu(s))s.isRenderTargetTexture?(Oe("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(Eu(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 Zt(i){const e={};for(let t=0;t<i.length;t++){const n=Js(i[t]);for(const s in n)e[s]=n[s]}return e}function Eu(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function Jm(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function z0(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ke.workingColorSpace}const Qm={clone:Js,merge:Zt};var jm=`void main() {
647
647
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
648
- }`,Jm=`void main() {
648
+ }`,eg=`void main() {
649
649
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
650
- }`;class It extends rs{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Zm,this.fragmentShader=Jm,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=$s(e.uniforms),this.uniformsGroups=Km(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 U().fromArray(s.value);break;case"v4":this.uniforms[n].value=new pt().fromArray(s.value);break;case"m3":this.uniforms[n].value=new ze().fromArray(s.value);break;case"m4":this.uniforms[n].value=new ht().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 Qm extends It{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Ir extends rs{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=mc,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 Pi,this.combine=Zc,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 jm extends rs{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=cm,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 eg extends rs{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 fh extends Rt{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 tg extends fh{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Rt.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 $o=new ht,Mu=new U,yu=new U;class N0{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=dn,this.map=null,this.mapPass=null,this.matrix=new ht,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new uh,this._frameExtents=new Le(1,1),this._viewportCount=1,this._viewports=[new pt(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),yu.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(yu),t.updateMatrixWorld(),$o.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix($o,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===Rr||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($o)}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 ma=new U,ga=new Js,Un=new U;class U0 extends Rt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ht,this.projectionMatrix=new ht,this.projectionMatrixInverse=new ht,this.coordinateSystem=qn,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(ma,ga,Un),Un.x===1&&Un.y===1&&Un.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ma,ga,Un.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(ma,ga,Un),Un.x===1&&Un.y===1&&Un.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ma,ga,Un.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const _i=new U,Su=new Le,bu=new Le;class un extends U0{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=vc*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Eo*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return vc*2*Math.atan(Math.tan(Eo*.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){_i.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(_i.x,_i.y).multiplyScalar(-e/_i.z),_i.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(_i.x,_i.y).multiplyScalar(-e/_i.z)}getViewSize(e,t){return this.getViewBounds(e,Su,bu),t.subVectors(bu,Su)}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(Eo*.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 l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,t-=a.offsetY*n/c,s*=a.width/l,n*=a.height/c}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 ng extends N0{constructor(){super(new un(90,1,.5,500)),this.isPointLightShadow=!0}}class ig extends fh{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 ng}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 Lr extends U0{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,l=s-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){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 sg extends N0{constructor(){super(new Lr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class rg extends fh{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Rt.DEFAULT_UP),this.updateMatrix(),this.target=new Rt,this.shadow=new sg}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 As=-90,Ts=1;class ag extends Rt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new un(As,Ts,e,t);s.layers=this.layers,this.add(s);const r=new un(As,Ts,e,t);r.layers=this.layers,this.add(r);const a=new un(As,Ts,e,t);a.layers=this.layers,this.add(a);const o=new un(As,Ts,e,t);o.layers=this.layers,this.add(o);const l=new un(As,Ts,e,t);l.layers=this.layers,this.add(l);const c=new un(As,Ts,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,s,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===qn)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Rr)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.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,l,c,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,l),e.setRenderTarget(n,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),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 og extends un{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Eu=new ht;class Zo{constructor(e,t,n=0,s=1/0){this.ray=new ch(e,t),this.near=n,this.far=s,this.camera=null,this.layers=new ah,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):Ye("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Eu.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Eu),this}intersectObject(e,t=!0,n=[]){return xc(e,this,n,t),n.sort(wu),n}intersectObjects(e,t=!0,n=[]){for(let s=0,r=e.length;s<r;s++)xc(e[s],this,n,t);return n.sort(wu),n}}function wu(i,e){return i.distance-e.distance}function xc(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++)xc(r[a],e,t,!0)}}class F0{static{F0.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 Au(i,e,t,n){const s=lg(n);switch(t){case y0:return i*e;case b0:return i*e/s.components*s.byteLength;case eh:return i*e/s.components*s.byteLength;case ji:return i*e*2/s.components*s.byteLength;case th:return i*e*2/s.components*s.byteLength;case S0:return i*e*3/s.components*s.byteLength;case pn:return i*e*4/s.components*s.byteLength;case nh:return i*e*4/s.components*s.byteLength;case Fa:case Oa:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case za:case Ba:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case kl:case Gl:return Math.max(i,16)*Math.max(e,8)/4;case Bl:case Hl:return Math.max(i,8)*Math.max(e,8)/2;case Vl:case Wl:case ql:case Yl:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Xl:case qa:case Kl:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case $l: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 Jl:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Ql:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case jl:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case ec:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case tc:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case nc:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case ic:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case sc:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case rc:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case ac:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case oc:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case lc:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case cc:case hc:case uc:return Math.ceil(i/4)*Math.ceil(e/4)*16;case dc:case fc:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Ya:case pc:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function lg(i){switch(i){case dn:case v0:return{byteLength:1,components:1};case Ar:case _0:case mn:return{byteLength:2,components:1};case Qc:case jc:return{byteLength:2,components:4};case Dn:case Jc:case Xn:return{byteLength:4,components:1};case x0:case M0: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:$c}}));typeof window<"u"&&(window.__THREE__?Oe("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=$c);/**
650
+ }`;class Et extends ls{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=jm,this.fragmentShader=eg,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=Js(e.uniforms),this.uniformsGroups=Jm(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 U().fromArray(s.value);break;case"v4":this.uniforms[n].value=new pt().fromArray(s.value);break;case"m3":this.uniforms[n].value=new ze().fromArray(s.value);break;case"m4":this.uniforms[n].value=new ht().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 tg extends Et{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Fr extends ls{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=xc,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 Ii,this.combine=eh,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 ng extends ls{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=dm,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 ig extends ls{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 Ct{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 sg extends gh{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Ct.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 Qo=new ht,wu=new U,Au=new U;class B0{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=pn,this.map=null,this.mapPass=null,this.matrix=new ht,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ph,this._frameExtents=new Le(1,1),this._viewportCount=1,this._viewports=[new pt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;wu.setFromMatrixPosition(e.matrixWorld),t.position.copy(wu),Au.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Au),t.updateMatrixWorld(),Qo.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Qo,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===Ir||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(Qo)}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 xa=new U,_a=new js,Un=new U;class k0 extends Ct{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ht,this.projectionMatrix=new ht,this.projectionMatrixInverse=new ht,this.coordinateSystem=qn,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(xa,_a,Un),Un.x===1&&Un.y===1&&Un.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(xa,_a,Un.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(xa,_a,Un),Un.x===1&&Un.y===1&&Un.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(xa,_a,Un.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Mi=new U,Tu=new Le,Ru=new Le;class fn extends k0{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=Mc*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(To*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Mc*2*Math.atan(Math.tan(To*.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){Mi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Mi.x,Mi.y).multiplyScalar(-e/Mi.z),Mi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Mi.x,Mi.y).multiplyScalar(-e/Mi.z)}getViewSize(e,t){return this.getViewBounds(e,Tu,Ru),t.subVectors(Ru,Tu)}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(To*.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 l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,t-=a.offsetY*n/c,s*=a.width/l,n*=a.height/c}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 rg extends B0{constructor(){super(new fn(90,1,.5,500)),this.isPointLightShadow=!0}}class ag 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 rg}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 er extends k0{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,l=s-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){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 og extends B0{constructor(){super(new er(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class lg extends gh{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ct.DEFAULT_UP),this.updateMatrix(),this.target=new Ct,this.shadow=new og}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 Rs=-90,Cs=1;class cg extends Ct{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new fn(Rs,Cs,e,t);s.layers=this.layers,this.add(s);const r=new fn(Rs,Cs,e,t);r.layers=this.layers,this.add(r);const a=new fn(Rs,Cs,e,t);a.layers=this.layers,this.add(a);const o=new fn(Rs,Cs,e,t);o.layers=this.layers,this.add(o);const l=new fn(Rs,Cs,e,t);l.layers=this.layers,this.add(l);const c=new fn(Rs,Cs,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,s,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===qn)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Ir)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.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,l,c,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const _=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(n,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(n,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=_,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 hg extends fn{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Cu=new ht;class jo{constructor(e,t,n=0,s=1/0){this.ray=new dh(e,t),this.near=n,this.far=s,this.camera=null,this.layers=new hh,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):Ye("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Cu.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Cu),this}intersectObject(e,t=!0,n=[]){return Sc(e,this,n,t),n.sort(Du),n}intersectObjects(e,t=!0,n=[]){for(let s=0,r=e.length;s<r;s++)Sc(e[s],this,n,t);return n.sort(Du),n}}function Du(i,e){return i.distance-e.distance}function Sc(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++)Sc(r[a],e,t,!0)}}class H0{static{H0.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 Pu(i,e,t,n){const s=ug(n);switch(t){case A0:return i*e;case R0:return i*e/s.components*s.byteLength;case sh:return i*e/s.components*s.byteLength;case ns:return i*e*2/s.components*s.byteLength;case rh:return i*e*2/s.components*s.byteLength;case T0:return i*e*3/s.components*s.byteLength;case gn:return i*e*4/s.components*s.byteLength;case ah:return i*e*4/s.components*s.byteLength;case Ba:case ka:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Ha:case Ga:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Vl:case Xl:return Math.max(i,16)*Math.max(e,8)/4;case Gl:case Wl:return Math.max(i,8)*Math.max(e,8)/2;case ql:case Yl:case $l:case Zl:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Kl:case Ka:case Jl:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Ql:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case jl:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case ec:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case tc:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case nc:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case ic:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case sc:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case rc:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case ac:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case oc:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case lc:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case cc:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case hc:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case uc:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case dc:case fc:case pc:return Math.ceil(i/4)*Math.ceil(e/4)*16;case mc:case gc:return Math.ceil(i/4)*Math.ceil(e/4)*8;case $a:case vc:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function ug(i){switch(i){case pn:case S0:return{byteLength:1,components:1};case Dr:case b0:case Qt:return{byteLength:2,components:1};case nh:case ih:return{byteLength:2,components:4};case Dn:case th:case Xn:return{byteLength:4,components:1};case E0:case w0: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:jc}}));typeof window<"u"&&(window.__THREE__?Oe("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=jc);/**
651
651
  * @license
652
652
  * Copyright 2010-2026 Three.js Authors
653
653
  * SPDX-License-Identifier: MIT
654
- */function O0(){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 cg(i){const e=new WeakMap;function t(o,l){const c=o.array,h=o.usage,u=c.byteLength,d=i.createBuffer();i.bindBuffer(l,d),i.bufferData(l,c,h),o.onUploadCallback();let f;if(c instanceof Float32Array)f=i.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=i.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=i.HALF_FLOAT:f=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=i.SHORT;else if(c instanceof Uint32Array)f=i.UNSIGNED_INT;else if(c instanceof Int32Array)f=i.INT;else if(c instanceof Int8Array)f=i.BYTE;else if(c instanceof Uint8Array)f=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,l,c){const h=l.array,u=l.updateRanges;if(i.bindBuffer(c,o),u.length===0)i.bufferSubData(c,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(c,x.start*h.BYTES_PER_ELEMENT,h,x.start,x.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(i.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){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 c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,o,l),c.version=o.version}}return{get:s,remove:r,update:a}}var hg=`#ifdef USE_ALPHAHASH
654
+ */function G0(){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 dg(i){const e=new WeakMap;function t(o,l){const c=o.array,h=o.usage,u=c.byteLength,d=i.createBuffer();i.bindBuffer(l,d),i.bufferData(l,c,h),o.onUploadCallback();let f;if(c instanceof Float32Array)f=i.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=i.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=i.HALF_FLOAT:f=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=i.SHORT;else if(c instanceof Uint32Array)f=i.UNSIGNED_INT;else if(c instanceof Int32Array)f=i.INT;else if(c instanceof Int8Array)f=i.BYTE;else if(c instanceof Uint8Array)f=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,l,c){const h=l.array,u=l.updateRanges;if(i.bindBuffer(c,o),u.length===0)i.bufferSubData(c,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],_=u[f];_.start<=g.start+g.count+1?g.count=Math.max(g.count,_.start+_.count-g.start):(++d,u[d]=_)}u.length=d+1;for(let f=0,g=u.length;f<g;f++){const _=u[f];i.bufferSubData(c,_.start*h.BYTES_PER_ELEMENT,h,_.start,_.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(i.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){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 c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,o,l),c.version=o.version}}return{get:s,remove:r,update:a}}var fg=`#ifdef USE_ALPHAHASH
655
655
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
656
- #endif`,ug=`#ifdef USE_ALPHAHASH
656
+ #endif`,pg=`#ifdef USE_ALPHAHASH
657
657
  const float ALPHA_HASH_SCALE = 0.05;
658
658
  float hash2D( vec2 value ) {
659
659
  return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -688,20 +688,20 @@ input[type=range] {
688
688
  : cases.z;
689
689
  return clamp( threshold , 1.0e-6, 1.0 );
690
690
  }
691
- #endif`,dg=`#ifdef USE_ALPHAMAP
691
+ #endif`,mg=`#ifdef USE_ALPHAMAP
692
692
  diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
693
- #endif`,fg=`#ifdef USE_ALPHAMAP
693
+ #endif`,gg=`#ifdef USE_ALPHAMAP
694
694
  uniform sampler2D alphaMap;
695
- #endif`,pg=`#ifdef USE_ALPHATEST
695
+ #endif`,vg=`#ifdef USE_ALPHATEST
696
696
  #ifdef ALPHA_TO_COVERAGE
697
697
  diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
698
698
  if ( diffuseColor.a == 0.0 ) discard;
699
699
  #else
700
700
  if ( diffuseColor.a < alphaTest ) discard;
701
701
  #endif
702
- #endif`,mg=`#ifdef USE_ALPHATEST
702
+ #endif`,xg=`#ifdef USE_ALPHATEST
703
703
  uniform float alphaTest;
704
- #endif`,gg=`#ifdef USE_AOMAP
704
+ #endif`,_g=`#ifdef USE_AOMAP
705
705
  float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
706
706
  reflectedLight.indirectDiffuse *= ambientOcclusion;
707
707
  #if defined( USE_CLEARCOAT )
@@ -714,10 +714,10 @@ input[type=range] {
714
714
  float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
715
715
  reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
716
716
  #endif
717
- #endif`,vg=`#ifdef USE_AOMAP
717
+ #endif`,Mg=`#ifdef USE_AOMAP
718
718
  uniform sampler2D aoMap;
719
719
  uniform float aoMapIntensity;
720
- #endif`,_g=`#ifdef USE_BATCHING
720
+ #endif`,yg=`#ifdef USE_BATCHING
721
721
  #if ! defined( GL_ANGLE_multi_draw )
722
722
  #define gl_DrawID _gl_DrawID
723
723
  uniform int _gl_DrawID;
@@ -751,15 +751,15 @@ input[type=range] {
751
751
  int y = j / size;
752
752
  return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
753
753
  }
754
- #endif`,xg=`#ifdef USE_BATCHING
754
+ #endif`,Sg=`#ifdef USE_BATCHING
755
755
  mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
756
- #endif`,Mg=`vec3 transformed = vec3( position );
756
+ #endif`,bg=`vec3 transformed = vec3( position );
757
757
  #ifdef USE_ALPHAHASH
758
758
  vPosition = vec3( position );
759
- #endif`,yg=`vec3 objectNormal = vec3( normal );
759
+ #endif`,Eg=`vec3 objectNormal = vec3( normal );
760
760
  #ifdef USE_TANGENT
761
761
  vec3 objectTangent = vec3( tangent.xyz );
762
- #endif`,Sg=`float G_BlinnPhong_Implicit( ) {
762
+ #endif`,wg=`float G_BlinnPhong_Implicit( ) {
763
763
  return 0.25;
764
764
  }
765
765
  float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -773,7 +773,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
773
773
  float G = G_BlinnPhong_Implicit( );
774
774
  float D = D_BlinnPhong( shininess, dotNH );
775
775
  return F * ( G * D );
776
- } // validated`,bg=`#ifdef USE_IRIDESCENCE
776
+ } // validated`,Ag=`#ifdef USE_IRIDESCENCE
777
777
  const mat3 XYZ_TO_REC709 = mat3(
778
778
  3.2404542, -0.9692660, 0.0556434,
779
779
  -1.5371385, 1.8760108, -0.2040259,
@@ -836,7 +836,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
836
836
  }
837
837
  return max( I, vec3( 0.0 ) );
838
838
  }
839
- #endif`,Eg=`#ifdef USE_BUMPMAP
839
+ #endif`,Tg=`#ifdef USE_BUMPMAP
840
840
  uniform sampler2D bumpMap;
841
841
  uniform float bumpScale;
842
842
  vec2 dHdxy_fwd() {
@@ -857,7 +857,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
857
857
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
858
858
  return normalize( abs( fDet ) * surf_norm - vGrad );
859
859
  }
860
- #endif`,wg=`#if NUM_CLIPPING_PLANES > 0
860
+ #endif`,Rg=`#if NUM_CLIPPING_PLANES > 0
861
861
  vec4 plane;
862
862
  #ifdef ALPHA_TO_COVERAGE
863
863
  float distanceToPlane, distanceGradient;
@@ -903,20 +903,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
903
903
  if ( clipped ) discard;
904
904
  #endif
905
905
  #endif
906
- #endif`,Ag=`#if NUM_CLIPPING_PLANES > 0
906
+ #endif`,Cg=`#if NUM_CLIPPING_PLANES > 0
907
907
  varying vec3 vClipPosition;
908
908
  uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
909
- #endif`,Tg=`#if NUM_CLIPPING_PLANES > 0
909
+ #endif`,Dg=`#if NUM_CLIPPING_PLANES > 0
910
910
  varying vec3 vClipPosition;
911
- #endif`,Rg=`#if NUM_CLIPPING_PLANES > 0
911
+ #endif`,Pg=`#if NUM_CLIPPING_PLANES > 0
912
912
  vClipPosition = - mvPosition.xyz;
913
- #endif`,Cg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
913
+ #endif`,Ig=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
914
914
  diffuseColor *= vColor;
915
- #endif`,Dg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
915
+ #endif`,Lg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
916
916
  varying vec4 vColor;
917
- #endif`,Pg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
917
+ #endif`,Ng=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
918
918
  varying vec4 vColor;
919
- #endif`,Ig=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
919
+ #endif`,Ug=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
920
920
  vColor = vec4( 1.0 );
921
921
  #endif
922
922
  #ifdef USE_COLOR_ALPHA
@@ -929,7 +929,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
929
929
  #endif
930
930
  #ifdef USE_BATCHING_COLOR
931
931
  vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
932
- #endif`,Lg=`#define PI 3.141592653589793
932
+ #endif`,Fg=`#define PI 3.141592653589793
933
933
  #define PI2 6.283185307179586
934
934
  #define PI_HALF 1.5707963267948966
935
935
  #define RECIPROCAL_PI 0.3183098861837907
@@ -1000,7 +1000,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
1000
1000
  float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
1001
1001
  float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
1002
1002
  return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
1003
- } // validated`,Ng=`#ifdef ENVMAP_TYPE_CUBE_UV
1003
+ } // validated`,Og=`#ifdef ENVMAP_TYPE_CUBE_UV
1004
1004
  #define cubeUV_minMipLevel 4.0
1005
1005
  #define cubeUV_minTileSize 16.0
1006
1006
  float getFace( vec3 direction ) {
@@ -1093,7 +1093,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
1093
1093
  return vec4( mix( color0, color1, mipF ), 1.0 );
1094
1094
  }
1095
1095
  }
1096
- #endif`,Ug=`vec3 transformedNormal = objectNormal;
1096
+ #endif`,zg=`vec3 transformedNormal = objectNormal;
1097
1097
  #ifdef USE_TANGENT
1098
1098
  vec3 transformedTangent = objectTangent;
1099
1099
  #endif
@@ -1119,21 +1119,21 @@ transformedNormal = normalMatrix * transformedNormal;
1119
1119
  #endif
1120
1120
  #ifdef USE_TANGENT
1121
1121
  transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
1122
- #endif`,Fg=`#ifdef USE_DISPLACEMENTMAP
1122
+ #endif`,Bg=`#ifdef USE_DISPLACEMENTMAP
1123
1123
  uniform sampler2D displacementMap;
1124
1124
  uniform float displacementScale;
1125
1125
  uniform float displacementBias;
1126
- #endif`,Og=`#ifdef USE_DISPLACEMENTMAP
1126
+ #endif`,kg=`#ifdef USE_DISPLACEMENTMAP
1127
1127
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
1128
- #endif`,zg=`#ifdef USE_EMISSIVEMAP
1128
+ #endif`,Hg=`#ifdef USE_EMISSIVEMAP
1129
1129
  vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
1130
1130
  #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
1131
1131
  emissiveColor = sRGBTransferEOTF( emissiveColor );
1132
1132
  #endif
1133
1133
  totalEmissiveRadiance *= emissiveColor.rgb;
1134
- #endif`,Bg=`#ifdef USE_EMISSIVEMAP
1134
+ #endif`,Gg=`#ifdef USE_EMISSIVEMAP
1135
1135
  uniform sampler2D emissiveMap;
1136
- #endif`,kg="gl_FragColor = linearToOutputTexel( gl_FragColor );",Hg=`vec4 LinearTransferOETF( in vec4 value ) {
1136
+ #endif`,Vg="gl_FragColor = linearToOutputTexel( gl_FragColor );",Wg=`vec4 LinearTransferOETF( in vec4 value ) {
1137
1137
  return value;
1138
1138
  }
1139
1139
  vec4 sRGBTransferEOTF( in vec4 value ) {
@@ -1141,7 +1141,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
1141
1141
  }
1142
1142
  vec4 sRGBTransferOETF( in vec4 value ) {
1143
1143
  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 );
1144
- }`,Gg=`#ifdef USE_ENVMAP
1144
+ }`,Xg=`#ifdef USE_ENVMAP
1145
1145
  #ifdef ENV_WORLDPOS
1146
1146
  vec3 cameraToFrag;
1147
1147
  if ( isOrthographic ) {
@@ -1168,7 +1168,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
1168
1168
  outgoingLight += envColor.xyz * specularStrength * reflectivity;
1169
1169
  #endif
1170
1170
  #endif
1171
- #endif`,Vg=`#ifdef USE_ENVMAP
1171
+ #endif`,qg=`#ifdef USE_ENVMAP
1172
1172
  uniform float envMapIntensity;
1173
1173
  uniform mat3 envMapRotation;
1174
1174
  #ifdef ENVMAP_TYPE_CUBE
@@ -1176,7 +1176,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
1176
1176
  #else
1177
1177
  uniform sampler2D envMap;
1178
1178
  #endif
1179
- #endif`,Wg=`#ifdef USE_ENVMAP
1179
+ #endif`,Yg=`#ifdef USE_ENVMAP
1180
1180
  uniform float reflectivity;
1181
1181
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
1182
1182
  #define ENV_WORLDPOS
@@ -1187,7 +1187,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
1187
1187
  #else
1188
1188
  varying vec3 vReflect;
1189
1189
  #endif
1190
- #endif`,Xg=`#ifdef USE_ENVMAP
1190
+ #endif`,Kg=`#ifdef USE_ENVMAP
1191
1191
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
1192
1192
  #define ENV_WORLDPOS
1193
1193
  #endif
@@ -1198,7 +1198,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
1198
1198
  varying vec3 vReflect;
1199
1199
  uniform float refractionRatio;
1200
1200
  #endif
1201
- #endif`,qg=`#ifdef USE_ENVMAP
1201
+ #endif`,$g=`#ifdef USE_ENVMAP
1202
1202
  #ifdef ENV_WORLDPOS
1203
1203
  vWorldPosition = worldPosition.xyz;
1204
1204
  #else
@@ -1215,18 +1215,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
1215
1215
  vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
1216
1216
  #endif
1217
1217
  #endif
1218
- #endif`,Yg=`#ifdef USE_FOG
1218
+ #endif`,Zg=`#ifdef USE_FOG
1219
1219
  vFogDepth = - mvPosition.z;
1220
- #endif`,Kg=`#ifdef USE_FOG
1220
+ #endif`,Jg=`#ifdef USE_FOG
1221
1221
  varying float vFogDepth;
1222
- #endif`,$g=`#ifdef USE_FOG
1222
+ #endif`,Qg=`#ifdef USE_FOG
1223
1223
  #ifdef FOG_EXP2
1224
1224
  float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
1225
1225
  #else
1226
1226
  float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
1227
1227
  #endif
1228
1228
  gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
1229
- #endif`,Zg=`#ifdef USE_FOG
1229
+ #endif`,jg=`#ifdef USE_FOG
1230
1230
  uniform vec3 fogColor;
1231
1231
  varying float vFogDepth;
1232
1232
  #ifdef FOG_EXP2
@@ -1235,7 +1235,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
1235
1235
  uniform float fogNear;
1236
1236
  uniform float fogFar;
1237
1237
  #endif
1238
- #endif`,Jg=`#ifdef USE_GRADIENTMAP
1238
+ #endif`,e1=`#ifdef USE_GRADIENTMAP
1239
1239
  uniform sampler2D gradientMap;
1240
1240
  #endif
1241
1241
  vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -1247,12 +1247,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
1247
1247
  vec2 fw = fwidth( coord ) * 0.5;
1248
1248
  return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
1249
1249
  #endif
1250
- }`,Qg=`#ifdef USE_LIGHTMAP
1250
+ }`,t1=`#ifdef USE_LIGHTMAP
1251
1251
  uniform sampler2D lightMap;
1252
1252
  uniform float lightMapIntensity;
1253
- #endif`,jg=`LambertMaterial material;
1253
+ #endif`,n1=`LambertMaterial material;
1254
1254
  material.diffuseColor = diffuseColor.rgb;
1255
- material.specularStrength = specularStrength;`,e1=`varying vec3 vViewPosition;
1255
+ material.specularStrength = specularStrength;`,i1=`varying vec3 vViewPosition;
1256
1256
  struct LambertMaterial {
1257
1257
  vec3 diffuseColor;
1258
1258
  float specularStrength;
@@ -1266,7 +1266,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
1266
1266
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1267
1267
  }
1268
1268
  #define RE_Direct RE_Direct_Lambert
1269
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,t1=`uniform bool receiveShadow;
1269
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,s1=`uniform bool receiveShadow;
1270
1270
  uniform vec3 ambientLightColor;
1271
1271
  #if defined( USE_LIGHT_PROBES )
1272
1272
  uniform vec3 lightProbe[ 9 ];
@@ -1383,7 +1383,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
1383
1383
  return irradiance;
1384
1384
  }
1385
1385
  #endif
1386
- #include <lightprobes_pars_fragment>`,n1=`#ifdef USE_ENVMAP
1386
+ #include <lightprobes_pars_fragment>`,r1=`#ifdef USE_ENVMAP
1387
1387
  vec3 getIBLIrradiance( const in vec3 normal ) {
1388
1388
  #ifdef ENVMAP_TYPE_CUBE_UV
1389
1389
  vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
@@ -1416,8 +1416,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
1416
1416
  #endif
1417
1417
  }
1418
1418
  #endif
1419
- #endif`,i1=`ToonMaterial material;
1420
- material.diffuseColor = diffuseColor.rgb;`,s1=`varying vec3 vViewPosition;
1419
+ #endif`,a1=`ToonMaterial material;
1420
+ material.diffuseColor = diffuseColor.rgb;`,o1=`varying vec3 vViewPosition;
1421
1421
  struct ToonMaterial {
1422
1422
  vec3 diffuseColor;
1423
1423
  };
@@ -1429,11 +1429,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
1429
1429
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1430
1430
  }
1431
1431
  #define RE_Direct RE_Direct_Toon
1432
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,r1=`BlinnPhongMaterial material;
1432
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,l1=`BlinnPhongMaterial material;
1433
1433
  material.diffuseColor = diffuseColor.rgb;
1434
1434
  material.specularColor = specular;
1435
1435
  material.specularShininess = shininess;
1436
- material.specularStrength = specularStrength;`,a1=`varying vec3 vViewPosition;
1436
+ material.specularStrength = specularStrength;`,c1=`varying vec3 vViewPosition;
1437
1437
  struct BlinnPhongMaterial {
1438
1438
  vec3 diffuseColor;
1439
1439
  vec3 specularColor;
@@ -1450,7 +1450,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
1450
1450
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1451
1451
  }
1452
1452
  #define RE_Direct RE_Direct_BlinnPhong
1453
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,o1=`PhysicalMaterial material;
1453
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,h1=`PhysicalMaterial material;
1454
1454
  material.diffuseColor = diffuseColor.rgb;
1455
1455
  material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
1456
1456
  material.metalness = metalnessFactor;
@@ -1540,7 +1540,7 @@ material.roughness = min( material.roughness, 1.0 );
1540
1540
  material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
1541
1541
  material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
1542
1542
  material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
1543
- #endif`,l1=`uniform sampler2D dfgLUT;
1543
+ #endif`,u1=`uniform sampler2D dfgLUT;
1544
1544
  struct PhysicalMaterial {
1545
1545
  vec3 diffuseColor;
1546
1546
  vec3 diffuseContribution;
@@ -1900,7 +1900,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
1900
1900
  #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1901
1901
  float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1902
1902
  return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1903
- }`,c1=`
1903
+ }`,d1=`
1904
1904
  vec3 geometryPosition = - vViewPosition;
1905
1905
  vec3 geometryNormal = normal;
1906
1906
  vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -2022,7 +2022,7 @@ IncidentLight directLight;
2022
2022
  #if defined( RE_IndirectSpecular )
2023
2023
  vec3 radiance = vec3( 0.0 );
2024
2024
  vec3 clearcoatRadiance = vec3( 0.0 );
2025
- #endif`,h1=`#if defined( RE_IndirectDiffuse )
2025
+ #endif`,f1=`#if defined( RE_IndirectDiffuse )
2026
2026
  #ifdef USE_LIGHTMAP
2027
2027
  vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
2028
2028
  vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -2043,7 +2043,7 @@ IncidentLight directLight;
2043
2043
  #ifdef USE_CLEARCOAT
2044
2044
  clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
2045
2045
  #endif
2046
- #endif`,u1=`#if defined( RE_IndirectDiffuse )
2046
+ #endif`,p1=`#if defined( RE_IndirectDiffuse )
2047
2047
  #if defined( LAMBERT ) || defined( PHONG )
2048
2048
  irradiance += iblIrradiance;
2049
2049
  #endif
@@ -2051,7 +2051,7 @@ IncidentLight directLight;
2051
2051
  #endif
2052
2052
  #if defined( RE_IndirectSpecular )
2053
2053
  RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
2054
- #endif`,d1=`#ifdef USE_LIGHT_PROBES_GRID
2054
+ #endif`,m1=`#ifdef USE_LIGHT_PROBES_GRID
2055
2055
  uniform highp sampler3D probesSH;
2056
2056
  uniform vec3 probesMin;
2057
2057
  uniform vec3 probesMax;
@@ -2096,27 +2096,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
2096
2096
  result += c8 * 0.429043 * ( x * x - y * y );
2097
2097
  return max( result, vec3( 0.0 ) );
2098
2098
  }
2099
- #endif`,f1=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
2099
+ #endif`,g1=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
2100
2100
  gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
2101
- #endif`,p1=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
2101
+ #endif`,v1=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
2102
2102
  uniform float logDepthBufFC;
2103
2103
  varying float vFragDepth;
2104
2104
  varying float vIsPerspective;
2105
- #endif`,m1=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
2105
+ #endif`,x1=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
2106
2106
  varying float vFragDepth;
2107
2107
  varying float vIsPerspective;
2108
- #endif`,g1=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
2108
+ #endif`,_1=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
2109
2109
  vFragDepth = 1.0 + gl_Position.w;
2110
2110
  vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
2111
- #endif`,v1=`#ifdef USE_MAP
2111
+ #endif`,M1=`#ifdef USE_MAP
2112
2112
  vec4 sampledDiffuseColor = texture2D( map, vMapUv );
2113
2113
  #ifdef DECODE_VIDEO_TEXTURE
2114
2114
  sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
2115
2115
  #endif
2116
2116
  diffuseColor *= sampledDiffuseColor;
2117
- #endif`,_1=`#ifdef USE_MAP
2117
+ #endif`,y1=`#ifdef USE_MAP
2118
2118
  uniform sampler2D map;
2119
- #endif`,x1=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
2119
+ #endif`,S1=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
2120
2120
  #if defined( USE_POINTS_UV )
2121
2121
  vec2 uv = vUv;
2122
2122
  #else
@@ -2128,7 +2128,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
2128
2128
  #endif
2129
2129
  #ifdef USE_ALPHAMAP
2130
2130
  diffuseColor.a *= texture2D( alphaMap, uv ).g;
2131
- #endif`,M1=`#if defined( USE_POINTS_UV )
2131
+ #endif`,b1=`#if defined( USE_POINTS_UV )
2132
2132
  varying vec2 vUv;
2133
2133
  #else
2134
2134
  #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -2140,19 +2140,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
2140
2140
  #endif
2141
2141
  #ifdef USE_ALPHAMAP
2142
2142
  uniform sampler2D alphaMap;
2143
- #endif`,y1=`float metalnessFactor = metalness;
2143
+ #endif`,E1=`float metalnessFactor = metalness;
2144
2144
  #ifdef USE_METALNESSMAP
2145
2145
  vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
2146
2146
  metalnessFactor *= texelMetalness.b;
2147
- #endif`,S1=`#ifdef USE_METALNESSMAP
2147
+ #endif`,w1=`#ifdef USE_METALNESSMAP
2148
2148
  uniform sampler2D metalnessMap;
2149
- #endif`,b1=`#ifdef USE_INSTANCING_MORPH
2149
+ #endif`,A1=`#ifdef USE_INSTANCING_MORPH
2150
2150
  float morphTargetInfluences[ MORPHTARGETS_COUNT ];
2151
2151
  float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
2152
2152
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
2153
2153
  morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
2154
2154
  }
2155
- #endif`,E1=`#if defined( USE_MORPHCOLORS )
2155
+ #endif`,T1=`#if defined( USE_MORPHCOLORS )
2156
2156
  vColor *= morphTargetBaseInfluence;
2157
2157
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
2158
2158
  #if defined( USE_COLOR_ALPHA )
@@ -2161,12 +2161,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
2161
2161
  if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
2162
2162
  #endif
2163
2163
  }
2164
- #endif`,w1=`#ifdef USE_MORPHNORMALS
2164
+ #endif`,R1=`#ifdef USE_MORPHNORMALS
2165
2165
  objectNormal *= morphTargetBaseInfluence;
2166
2166
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
2167
2167
  if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
2168
2168
  }
2169
- #endif`,A1=`#ifdef USE_MORPHTARGETS
2169
+ #endif`,C1=`#ifdef USE_MORPHTARGETS
2170
2170
  #ifndef USE_INSTANCING_MORPH
2171
2171
  uniform float morphTargetBaseInfluence;
2172
2172
  uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -2180,12 +2180,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
2180
2180
  ivec3 morphUV = ivec3( x, y, morphTargetIndex );
2181
2181
  return texelFetch( morphTargetsTexture, morphUV, 0 );
2182
2182
  }
2183
- #endif`,T1=`#ifdef USE_MORPHTARGETS
2183
+ #endif`,D1=`#ifdef USE_MORPHTARGETS
2184
2184
  transformed *= morphTargetBaseInfluence;
2185
2185
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
2186
2186
  if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
2187
2187
  }
2188
- #endif`,R1=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
2188
+ #endif`,P1=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
2189
2189
  #ifdef FLAT_SHADED
2190
2190
  vec3 fdx = dFdx( vViewPosition );
2191
2191
  vec3 fdy = dFdy( vViewPosition );
@@ -2226,7 +2226,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
2226
2226
  tbn2[1] *= faceDirection;
2227
2227
  #endif
2228
2228
  #endif
2229
- vec3 nonPerturbedNormal = normal;`,C1=`#ifdef USE_NORMALMAP_OBJECTSPACE
2229
+ vec3 nonPerturbedNormal = normal;`,I1=`#ifdef USE_NORMALMAP_OBJECTSPACE
2230
2230
  normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
2231
2231
  #ifdef FLIP_SIDED
2232
2232
  normal = - normal;
@@ -2244,19 +2244,19 @@ vec3 nonPerturbedNormal = normal;`,C1=`#ifdef USE_NORMALMAP_OBJECTSPACE
2244
2244
  normal = normalize( tbn * mapN );
2245
2245
  #elif defined( USE_BUMPMAP )
2246
2246
  normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
2247
- #endif`,D1=`#ifndef FLAT_SHADED
2247
+ #endif`,L1=`#ifndef FLAT_SHADED
2248
2248
  varying vec3 vNormal;
2249
2249
  #ifdef USE_TANGENT
2250
2250
  varying vec3 vTangent;
2251
2251
  varying vec3 vBitangent;
2252
2252
  #endif
2253
- #endif`,P1=`#ifndef FLAT_SHADED
2253
+ #endif`,N1=`#ifndef FLAT_SHADED
2254
2254
  varying vec3 vNormal;
2255
2255
  #ifdef USE_TANGENT
2256
2256
  varying vec3 vTangent;
2257
2257
  varying vec3 vBitangent;
2258
2258
  #endif
2259
- #endif`,I1=`#ifndef FLAT_SHADED
2259
+ #endif`,U1=`#ifndef FLAT_SHADED
2260
2260
  vNormal = normalize( transformedNormal );
2261
2261
  #ifdef USE_TANGENT
2262
2262
  vTangent = normalize( transformedTangent );
@@ -2265,7 +2265,7 @@ vec3 nonPerturbedNormal = normal;`,C1=`#ifdef USE_NORMALMAP_OBJECTSPACE
2265
2265
  vBitangent = - vBitangent;
2266
2266
  #endif
2267
2267
  #endif
2268
- #endif`,L1=`#ifdef USE_NORMALMAP
2268
+ #endif`,F1=`#ifdef USE_NORMALMAP
2269
2269
  uniform sampler2D normalMap;
2270
2270
  uniform vec2 normalScale;
2271
2271
  #endif
@@ -2287,13 +2287,13 @@ vec3 nonPerturbedNormal = normal;`,C1=`#ifdef USE_NORMALMAP_OBJECTSPACE
2287
2287
  float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
2288
2288
  return mat3( T * scale, B * scale, N );
2289
2289
  }
2290
- #endif`,N1=`#ifdef USE_CLEARCOAT
2290
+ #endif`,O1=`#ifdef USE_CLEARCOAT
2291
2291
  vec3 clearcoatNormal = nonPerturbedNormal;
2292
- #endif`,U1=`#ifdef USE_CLEARCOAT_NORMALMAP
2292
+ #endif`,z1=`#ifdef USE_CLEARCOAT_NORMALMAP
2293
2293
  vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
2294
2294
  clearcoatMapN.xy *= clearcoatNormalScale;
2295
2295
  clearcoatNormal = normalize( tbn2 * clearcoatMapN );
2296
- #endif`,F1=`#ifdef USE_CLEARCOATMAP
2296
+ #endif`,B1=`#ifdef USE_CLEARCOATMAP
2297
2297
  uniform sampler2D clearcoatMap;
2298
2298
  #endif
2299
2299
  #ifdef USE_CLEARCOAT_NORMALMAP
@@ -2302,18 +2302,18 @@ vec3 nonPerturbedNormal = normal;`,C1=`#ifdef USE_NORMALMAP_OBJECTSPACE
2302
2302
  #endif
2303
2303
  #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2304
2304
  uniform sampler2D clearcoatRoughnessMap;
2305
- #endif`,O1=`#ifdef USE_IRIDESCENCEMAP
2305
+ #endif`,k1=`#ifdef USE_IRIDESCENCEMAP
2306
2306
  uniform sampler2D iridescenceMap;
2307
2307
  #endif
2308
2308
  #ifdef USE_IRIDESCENCE_THICKNESSMAP
2309
2309
  uniform sampler2D iridescenceThicknessMap;
2310
- #endif`,z1=`#ifdef OPAQUE
2310
+ #endif`,H1=`#ifdef OPAQUE
2311
2311
  diffuseColor.a = 1.0;
2312
2312
  #endif
2313
2313
  #ifdef USE_TRANSMISSION
2314
2314
  diffuseColor.a *= material.transmissionAlpha;
2315
2315
  #endif
2316
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,B1=`vec3 packNormalToRGB( const in vec3 normal ) {
2316
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,G1=`vec3 packNormalToRGB( const in vec3 normal ) {
2317
2317
  return normalize( normal ) * 0.5 + 0.5;
2318
2318
  }
2319
2319
  vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -2392,9 +2392,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
2392
2392
  #else
2393
2393
  return ( near * far ) / ( ( far - near ) * depth - far );
2394
2394
  #endif
2395
- }`,k1=`#ifdef PREMULTIPLIED_ALPHA
2395
+ }`,V1=`#ifdef PREMULTIPLIED_ALPHA
2396
2396
  gl_FragColor.rgb *= gl_FragColor.a;
2397
- #endif`,H1=`vec4 mvPosition = vec4( transformed, 1.0 );
2397
+ #endif`,W1=`vec4 mvPosition = vec4( transformed, 1.0 );
2398
2398
  #ifdef USE_BATCHING
2399
2399
  mvPosition = batchingMatrix * mvPosition;
2400
2400
  #endif
@@ -2402,22 +2402,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
2402
2402
  mvPosition = instanceMatrix * mvPosition;
2403
2403
  #endif
2404
2404
  mvPosition = modelViewMatrix * mvPosition;
2405
- gl_Position = projectionMatrix * mvPosition;`,G1=`#ifdef DITHERING
2405
+ gl_Position = projectionMatrix * mvPosition;`,X1=`#ifdef DITHERING
2406
2406
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
2407
- #endif`,V1=`#ifdef DITHERING
2407
+ #endif`,q1=`#ifdef DITHERING
2408
2408
  vec3 dithering( vec3 color ) {
2409
2409
  float grid_position = rand( gl_FragCoord.xy );
2410
2410
  vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
2411
2411
  dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
2412
2412
  return color + dither_shift_RGB;
2413
2413
  }
2414
- #endif`,W1=`float roughnessFactor = roughness;
2414
+ #endif`,Y1=`float roughnessFactor = roughness;
2415
2415
  #ifdef USE_ROUGHNESSMAP
2416
2416
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
2417
2417
  roughnessFactor *= texelRoughness.g;
2418
- #endif`,X1=`#ifdef USE_ROUGHNESSMAP
2418
+ #endif`,K1=`#ifdef USE_ROUGHNESSMAP
2419
2419
  uniform sampler2D roughnessMap;
2420
- #endif`,q1=`#if NUM_SPOT_LIGHT_COORDS > 0
2420
+ #endif`,$1=`#if NUM_SPOT_LIGHT_COORDS > 0
2421
2421
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
2422
2422
  #endif
2423
2423
  #if NUM_SPOT_LIGHT_MAPS > 0
@@ -2617,7 +2617,7 @@ gl_Position = projectionMatrix * mvPosition;`,G1=`#ifdef DITHERING
2617
2617
  }
2618
2618
  #endif
2619
2619
  #endif
2620
- #endif`,Y1=`#if NUM_SPOT_LIGHT_COORDS > 0
2620
+ #endif`,Z1=`#if NUM_SPOT_LIGHT_COORDS > 0
2621
2621
  uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
2622
2622
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
2623
2623
  #endif
@@ -2658,7 +2658,7 @@ gl_Position = projectionMatrix * mvPosition;`,G1=`#ifdef DITHERING
2658
2658
  };
2659
2659
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
2660
2660
  #endif
2661
- #endif`,K1=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2661
+ #endif`,J1=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2662
2662
  #ifdef HAS_NORMAL
2663
2663
  vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
2664
2664
  #else
@@ -2694,7 +2694,7 @@ gl_Position = projectionMatrix * mvPosition;`,G1=`#ifdef DITHERING
2694
2694
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
2695
2695
  }
2696
2696
  #pragma unroll_loop_end
2697
- #endif`,$1=`float getShadowMask() {
2697
+ #endif`,Q1=`float getShadowMask() {
2698
2698
  float shadow = 1.0;
2699
2699
  #ifdef USE_SHADOWMAP
2700
2700
  #if NUM_DIR_LIGHT_SHADOWS > 0
@@ -2726,12 +2726,12 @@ gl_Position = projectionMatrix * mvPosition;`,G1=`#ifdef DITHERING
2726
2726
  #endif
2727
2727
  #endif
2728
2728
  return shadow;
2729
- }`,Z1=`#ifdef USE_SKINNING
2729
+ }`,j1=`#ifdef USE_SKINNING
2730
2730
  mat4 boneMatX = getBoneMatrix( skinIndex.x );
2731
2731
  mat4 boneMatY = getBoneMatrix( skinIndex.y );
2732
2732
  mat4 boneMatZ = getBoneMatrix( skinIndex.z );
2733
2733
  mat4 boneMatW = getBoneMatrix( skinIndex.w );
2734
- #endif`,J1=`#ifdef USE_SKINNING
2734
+ #endif`,e2=`#ifdef USE_SKINNING
2735
2735
  uniform mat4 bindMatrix;
2736
2736
  uniform mat4 bindMatrixInverse;
2737
2737
  uniform highp sampler2D boneTexture;
@@ -2746,7 +2746,7 @@ gl_Position = projectionMatrix * mvPosition;`,G1=`#ifdef DITHERING
2746
2746
  vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2747
2747
  return mat4( v1, v2, v3, v4 );
2748
2748
  }
2749
- #endif`,Q1=`#ifdef USE_SKINNING
2749
+ #endif`,t2=`#ifdef USE_SKINNING
2750
2750
  vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2751
2751
  vec4 skinned = vec4( 0.0 );
2752
2752
  skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2754,7 +2754,7 @@ gl_Position = projectionMatrix * mvPosition;`,G1=`#ifdef DITHERING
2754
2754
  skinned += boneMatZ * skinVertex * skinWeight.z;
2755
2755
  skinned += boneMatW * skinVertex * skinWeight.w;
2756
2756
  transformed = ( bindMatrixInverse * skinned ).xyz;
2757
- #endif`,j1=`#ifdef USE_SKINNING
2757
+ #endif`,n2=`#ifdef USE_SKINNING
2758
2758
  mat4 skinMatrix = mat4( 0.0 );
2759
2759
  skinMatrix += skinWeight.x * boneMatX;
2760
2760
  skinMatrix += skinWeight.y * boneMatY;
@@ -2765,17 +2765,17 @@ gl_Position = projectionMatrix * mvPosition;`,G1=`#ifdef DITHERING
2765
2765
  #ifdef USE_TANGENT
2766
2766
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2767
2767
  #endif
2768
- #endif`,e2=`float specularStrength;
2768
+ #endif`,i2=`float specularStrength;
2769
2769
  #ifdef USE_SPECULARMAP
2770
2770
  vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2771
2771
  specularStrength = texelSpecular.r;
2772
2772
  #else
2773
2773
  specularStrength = 1.0;
2774
- #endif`,t2=`#ifdef USE_SPECULARMAP
2774
+ #endif`,s2=`#ifdef USE_SPECULARMAP
2775
2775
  uniform sampler2D specularMap;
2776
- #endif`,n2=`#if defined( TONE_MAPPING )
2776
+ #endif`,r2=`#if defined( TONE_MAPPING )
2777
2777
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2778
- #endif`,i2=`#ifndef saturate
2778
+ #endif`,a2=`#ifndef saturate
2779
2779
  #define saturate( a ) clamp( a, 0.0, 1.0 )
2780
2780
  #endif
2781
2781
  uniform float toneMappingExposure;
@@ -2872,7 +2872,7 @@ vec3 NeutralToneMapping( vec3 color ) {
2872
2872
  float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2873
2873
  return mix( color, vec3( newPeak ), g );
2874
2874
  }
2875
- vec3 CustomToneMapping( vec3 color ) { return color; }`,s2=`#ifdef USE_TRANSMISSION
2875
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,o2=`#ifdef USE_TRANSMISSION
2876
2876
  material.transmission = transmission;
2877
2877
  material.transmissionAlpha = 1.0;
2878
2878
  material.thickness = thickness;
@@ -2893,7 +2893,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,s2=`#ifdef USE_TRANSMISS
2893
2893
  material.attenuationColor, material.attenuationDistance );
2894
2894
  material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2895
2895
  totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2896
- #endif`,r2=`#ifdef USE_TRANSMISSION
2896
+ #endif`,l2=`#ifdef USE_TRANSMISSION
2897
2897
  uniform float transmission;
2898
2898
  uniform float thickness;
2899
2899
  uniform float attenuationDistance;
@@ -3019,7 +3019,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,s2=`#ifdef USE_TRANSMISS
3019
3019
  float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
3020
3020
  return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
3021
3021
  }
3022
- #endif`,a2=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
3022
+ #endif`,c2=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
3023
3023
  varying vec2 vUv;
3024
3024
  #endif
3025
3025
  #ifdef USE_MAP
@@ -3089,7 +3089,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,s2=`#ifdef USE_TRANSMISS
3089
3089
  #ifdef USE_THICKNESSMAP
3090
3090
  uniform mat3 thicknessMapTransform;
3091
3091
  varying vec2 vThicknessMapUv;
3092
- #endif`,o2=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
3092
+ #endif`,h2=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
3093
3093
  varying vec2 vUv;
3094
3094
  #endif
3095
3095
  #ifdef USE_MAP
@@ -3183,7 +3183,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,s2=`#ifdef USE_TRANSMISS
3183
3183
  #ifdef USE_THICKNESSMAP
3184
3184
  uniform mat3 thicknessMapTransform;
3185
3185
  varying vec2 vThicknessMapUv;
3186
- #endif`,l2=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
3186
+ #endif`,u2=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
3187
3187
  vUv = vec3( uv, 1 ).xy;
3188
3188
  #endif
3189
3189
  #ifdef USE_MAP
@@ -3254,7 +3254,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,s2=`#ifdef USE_TRANSMISS
3254
3254
  #endif
3255
3255
  #ifdef USE_THICKNESSMAP
3256
3256
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
3257
- #endif`,c2=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
3257
+ #endif`,d2=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
3258
3258
  vec4 worldPosition = vec4( transformed, 1.0 );
3259
3259
  #ifdef USE_BATCHING
3260
3260
  worldPosition = batchingMatrix * worldPosition;
@@ -3263,12 +3263,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,s2=`#ifdef USE_TRANSMISS
3263
3263
  worldPosition = instanceMatrix * worldPosition;
3264
3264
  #endif
3265
3265
  worldPosition = modelMatrix * worldPosition;
3266
- #endif`;const h2=`varying vec2 vUv;
3266
+ #endif`;const f2=`varying vec2 vUv;
3267
3267
  uniform mat3 uvTransform;
3268
3268
  void main() {
3269
3269
  vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
3270
3270
  gl_Position = vec4( position.xy, 1.0, 1.0 );
3271
- }`,u2=`uniform sampler2D t2D;
3271
+ }`,p2=`uniform sampler2D t2D;
3272
3272
  uniform float backgroundIntensity;
3273
3273
  varying vec2 vUv;
3274
3274
  void main() {
@@ -3280,14 +3280,14 @@ void main() {
3280
3280
  gl_FragColor = texColor;
3281
3281
  #include <tonemapping_fragment>
3282
3282
  #include <colorspace_fragment>
3283
- }`,d2=`varying vec3 vWorldDirection;
3283
+ }`,m2=`varying vec3 vWorldDirection;
3284
3284
  #include <common>
3285
3285
  void main() {
3286
3286
  vWorldDirection = transformDirection( position, modelMatrix );
3287
3287
  #include <begin_vertex>
3288
3288
  #include <project_vertex>
3289
3289
  gl_Position.z = gl_Position.w;
3290
- }`,f2=`#ifdef ENVMAP_TYPE_CUBE
3290
+ }`,g2=`#ifdef ENVMAP_TYPE_CUBE
3291
3291
  uniform samplerCube envMap;
3292
3292
  #elif defined( ENVMAP_TYPE_CUBE_UV )
3293
3293
  uniform sampler2D envMap;
@@ -3309,14 +3309,14 @@ void main() {
3309
3309
  gl_FragColor = texColor;
3310
3310
  #include <tonemapping_fragment>
3311
3311
  #include <colorspace_fragment>
3312
- }`,p2=`varying vec3 vWorldDirection;
3312
+ }`,v2=`varying vec3 vWorldDirection;
3313
3313
  #include <common>
3314
3314
  void main() {
3315
3315
  vWorldDirection = transformDirection( position, modelMatrix );
3316
3316
  #include <begin_vertex>
3317
3317
  #include <project_vertex>
3318
3318
  gl_Position.z = gl_Position.w;
3319
- }`,m2=`uniform samplerCube tCube;
3319
+ }`,x2=`uniform samplerCube tCube;
3320
3320
  uniform float tFlip;
3321
3321
  uniform float opacity;
3322
3322
  varying vec3 vWorldDirection;
@@ -3326,7 +3326,7 @@ void main() {
3326
3326
  gl_FragColor.a *= opacity;
3327
3327
  #include <tonemapping_fragment>
3328
3328
  #include <colorspace_fragment>
3329
- }`,g2=`#include <common>
3329
+ }`,_2=`#include <common>
3330
3330
  #include <batching_pars_vertex>
3331
3331
  #include <uv_pars_vertex>
3332
3332
  #include <displacementmap_pars_vertex>
@@ -3353,7 +3353,7 @@ void main() {
3353
3353
  #include <logdepthbuf_vertex>
3354
3354
  #include <clipping_planes_vertex>
3355
3355
  vHighPrecisionZW = gl_Position.zw;
3356
- }`,v2=`#if DEPTH_PACKING == 3200
3356
+ }`,M2=`#if DEPTH_PACKING == 3200
3357
3357
  uniform float opacity;
3358
3358
  #endif
3359
3359
  #include <common>
@@ -3391,7 +3391,7 @@ void main() {
3391
3391
  #elif DEPTH_PACKING == 3203
3392
3392
  gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
3393
3393
  #endif
3394
- }`,_2=`#define DISTANCE
3394
+ }`,y2=`#define DISTANCE
3395
3395
  varying vec3 vWorldPosition;
3396
3396
  #include <common>
3397
3397
  #include <batching_pars_vertex>
@@ -3418,7 +3418,7 @@ void main() {
3418
3418
  #include <worldpos_vertex>
3419
3419
  #include <clipping_planes_vertex>
3420
3420
  vWorldPosition = worldPosition.xyz;
3421
- }`,x2=`#define DISTANCE
3421
+ }`,S2=`#define DISTANCE
3422
3422
  uniform vec3 referencePosition;
3423
3423
  uniform float nearDistance;
3424
3424
  uniform float farDistance;
@@ -3441,13 +3441,13 @@ void main() {
3441
3441
  dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
3442
3442
  dist = saturate( dist );
3443
3443
  gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
3444
- }`,M2=`varying vec3 vWorldDirection;
3444
+ }`,b2=`varying vec3 vWorldDirection;
3445
3445
  #include <common>
3446
3446
  void main() {
3447
3447
  vWorldDirection = transformDirection( position, modelMatrix );
3448
3448
  #include <begin_vertex>
3449
3449
  #include <project_vertex>
3450
- }`,y2=`uniform sampler2D tEquirect;
3450
+ }`,E2=`uniform sampler2D tEquirect;
3451
3451
  varying vec3 vWorldDirection;
3452
3452
  #include <common>
3453
3453
  void main() {
@@ -3456,7 +3456,7 @@ void main() {
3456
3456
  gl_FragColor = texture2D( tEquirect, sampleUV );
3457
3457
  #include <tonemapping_fragment>
3458
3458
  #include <colorspace_fragment>
3459
- }`,S2=`uniform float scale;
3459
+ }`,w2=`uniform float scale;
3460
3460
  attribute float lineDistance;
3461
3461
  varying float vLineDistance;
3462
3462
  #include <common>
@@ -3478,7 +3478,7 @@ void main() {
3478
3478
  #include <logdepthbuf_vertex>
3479
3479
  #include <clipping_planes_vertex>
3480
3480
  #include <fog_vertex>
3481
- }`,b2=`uniform vec3 diffuse;
3481
+ }`,A2=`uniform vec3 diffuse;
3482
3482
  uniform float opacity;
3483
3483
  uniform float dashSize;
3484
3484
  uniform float totalSize;
@@ -3506,7 +3506,7 @@ void main() {
3506
3506
  #include <colorspace_fragment>
3507
3507
  #include <fog_fragment>
3508
3508
  #include <premultiplied_alpha_fragment>
3509
- }`,E2=`#include <common>
3509
+ }`,T2=`#include <common>
3510
3510
  #include <batching_pars_vertex>
3511
3511
  #include <uv_pars_vertex>
3512
3512
  #include <envmap_pars_vertex>
@@ -3538,7 +3538,7 @@ void main() {
3538
3538
  #include <worldpos_vertex>
3539
3539
  #include <envmap_vertex>
3540
3540
  #include <fog_vertex>
3541
- }`,w2=`uniform vec3 diffuse;
3541
+ }`,R2=`uniform vec3 diffuse;
3542
3542
  uniform float opacity;
3543
3543
  #ifndef FLAT_SHADED
3544
3544
  varying vec3 vNormal;
@@ -3586,7 +3586,7 @@ void main() {
3586
3586
  #include <fog_fragment>
3587
3587
  #include <premultiplied_alpha_fragment>
3588
3588
  #include <dithering_fragment>
3589
- }`,A2=`#define LAMBERT
3589
+ }`,C2=`#define LAMBERT
3590
3590
  varying vec3 vViewPosition;
3591
3591
  #include <common>
3592
3592
  #include <batching_pars_vertex>
@@ -3625,7 +3625,7 @@ void main() {
3625
3625
  #include <envmap_vertex>
3626
3626
  #include <shadowmap_vertex>
3627
3627
  #include <fog_vertex>
3628
- }`,T2=`#define LAMBERT
3628
+ }`,D2=`#define LAMBERT
3629
3629
  uniform vec3 diffuse;
3630
3630
  uniform vec3 emissive;
3631
3631
  uniform float opacity;
@@ -3683,7 +3683,7 @@ void main() {
3683
3683
  #include <fog_fragment>
3684
3684
  #include <premultiplied_alpha_fragment>
3685
3685
  #include <dithering_fragment>
3686
- }`,R2=`#define MATCAP
3686
+ }`,P2=`#define MATCAP
3687
3687
  varying vec3 vViewPosition;
3688
3688
  #include <common>
3689
3689
  #include <batching_pars_vertex>
@@ -3717,7 +3717,7 @@ void main() {
3717
3717
  #include <clipping_planes_vertex>
3718
3718
  #include <fog_vertex>
3719
3719
  vViewPosition = - mvPosition.xyz;
3720
- }`,C2=`#define MATCAP
3720
+ }`,I2=`#define MATCAP
3721
3721
  uniform vec3 diffuse;
3722
3722
  uniform float opacity;
3723
3723
  uniform sampler2D matcap;
@@ -3763,7 +3763,7 @@ void main() {
3763
3763
  #include <fog_fragment>
3764
3764
  #include <premultiplied_alpha_fragment>
3765
3765
  #include <dithering_fragment>
3766
- }`,D2=`#define NORMAL
3766
+ }`,L2=`#define NORMAL
3767
3767
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3768
3768
  varying vec3 vViewPosition;
3769
3769
  #endif
@@ -3796,7 +3796,7 @@ void main() {
3796
3796
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3797
3797
  vViewPosition = - mvPosition.xyz;
3798
3798
  #endif
3799
- }`,P2=`#define NORMAL
3799
+ }`,N2=`#define NORMAL
3800
3800
  uniform float opacity;
3801
3801
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3802
3802
  varying vec3 vViewPosition;
@@ -3817,7 +3817,7 @@ void main() {
3817
3817
  #ifdef OPAQUE
3818
3818
  gl_FragColor.a = 1.0;
3819
3819
  #endif
3820
- }`,I2=`#define PHONG
3820
+ }`,U2=`#define PHONG
3821
3821
  varying vec3 vViewPosition;
3822
3822
  #include <common>
3823
3823
  #include <batching_pars_vertex>
@@ -3856,7 +3856,7 @@ void main() {
3856
3856
  #include <envmap_vertex>
3857
3857
  #include <shadowmap_vertex>
3858
3858
  #include <fog_vertex>
3859
- }`,L2=`#define PHONG
3859
+ }`,F2=`#define PHONG
3860
3860
  uniform vec3 diffuse;
3861
3861
  uniform vec3 emissive;
3862
3862
  uniform vec3 specular;
@@ -3916,7 +3916,7 @@ void main() {
3916
3916
  #include <fog_fragment>
3917
3917
  #include <premultiplied_alpha_fragment>
3918
3918
  #include <dithering_fragment>
3919
- }`,N2=`#define STANDARD
3919
+ }`,O2=`#define STANDARD
3920
3920
  varying vec3 vViewPosition;
3921
3921
  #ifdef USE_TRANSMISSION
3922
3922
  varying vec3 vWorldPosition;
@@ -3959,7 +3959,7 @@ void main() {
3959
3959
  #ifdef USE_TRANSMISSION
3960
3960
  vWorldPosition = worldPosition.xyz;
3961
3961
  #endif
3962
- }`,U2=`#define STANDARD
3962
+ }`,z2=`#define STANDARD
3963
3963
  #ifdef PHYSICAL
3964
3964
  #define IOR
3965
3965
  #define USE_SPECULAR
@@ -4084,7 +4084,7 @@ void main() {
4084
4084
  #include <fog_fragment>
4085
4085
  #include <premultiplied_alpha_fragment>
4086
4086
  #include <dithering_fragment>
4087
- }`,F2=`#define TOON
4087
+ }`,B2=`#define TOON
4088
4088
  varying vec3 vViewPosition;
4089
4089
  #include <common>
4090
4090
  #include <batching_pars_vertex>
@@ -4121,7 +4121,7 @@ void main() {
4121
4121
  #include <worldpos_vertex>
4122
4122
  #include <shadowmap_vertex>
4123
4123
  #include <fog_vertex>
4124
- }`,O2=`#define TOON
4124
+ }`,k2=`#define TOON
4125
4125
  uniform vec3 diffuse;
4126
4126
  uniform vec3 emissive;
4127
4127
  uniform float opacity;
@@ -4173,7 +4173,7 @@ void main() {
4173
4173
  #include <fog_fragment>
4174
4174
  #include <premultiplied_alpha_fragment>
4175
4175
  #include <dithering_fragment>
4176
- }`,z2=`uniform float size;
4176
+ }`,H2=`uniform float size;
4177
4177
  uniform float scale;
4178
4178
  #include <common>
4179
4179
  #include <color_pars_vertex>
@@ -4204,7 +4204,7 @@ void main() {
4204
4204
  #include <clipping_planes_vertex>
4205
4205
  #include <worldpos_vertex>
4206
4206
  #include <fog_vertex>
4207
- }`,B2=`uniform vec3 diffuse;
4207
+ }`,G2=`uniform vec3 diffuse;
4208
4208
  uniform float opacity;
4209
4209
  #include <common>
4210
4210
  #include <color_pars_fragment>
@@ -4229,7 +4229,7 @@ void main() {
4229
4229
  #include <colorspace_fragment>
4230
4230
  #include <fog_fragment>
4231
4231
  #include <premultiplied_alpha_fragment>
4232
- }`,k2=`#include <common>
4232
+ }`,V2=`#include <common>
4233
4233
  #include <batching_pars_vertex>
4234
4234
  #include <fog_pars_vertex>
4235
4235
  #include <morphtarget_pars_vertex>
@@ -4252,7 +4252,7 @@ void main() {
4252
4252
  #include <worldpos_vertex>
4253
4253
  #include <shadowmap_vertex>
4254
4254
  #include <fog_vertex>
4255
- }`,H2=`uniform vec3 color;
4255
+ }`,W2=`uniform vec3 color;
4256
4256
  uniform float opacity;
4257
4257
  #include <common>
4258
4258
  #include <fog_pars_fragment>
@@ -4268,7 +4268,7 @@ void main() {
4268
4268
  #include <colorspace_fragment>
4269
4269
  #include <fog_fragment>
4270
4270
  #include <premultiplied_alpha_fragment>
4271
- }`,G2=`uniform float rotation;
4271
+ }`,X2=`uniform float rotation;
4272
4272
  uniform vec2 center;
4273
4273
  #include <common>
4274
4274
  #include <uv_pars_vertex>
@@ -4292,7 +4292,7 @@ void main() {
4292
4292
  #include <logdepthbuf_vertex>
4293
4293
  #include <clipping_planes_vertex>
4294
4294
  #include <fog_vertex>
4295
- }`,V2=`uniform vec3 diffuse;
4295
+ }`,q2=`uniform vec3 diffuse;
4296
4296
  uniform float opacity;
4297
4297
  #include <common>
4298
4298
  #include <uv_pars_fragment>
@@ -4317,7 +4317,7 @@ void main() {
4317
4317
  #include <tonemapping_fragment>
4318
4318
  #include <colorspace_fragment>
4319
4319
  #include <fog_fragment>
4320
- }`,Ve={alphahash_fragment:hg,alphahash_pars_fragment:ug,alphamap_fragment:dg,alphamap_pars_fragment:fg,alphatest_fragment:pg,alphatest_pars_fragment:mg,aomap_fragment:gg,aomap_pars_fragment:vg,batching_pars_vertex:_g,batching_vertex:xg,begin_vertex:Mg,beginnormal_vertex:yg,bsdfs:Sg,iridescence_fragment:bg,bumpmap_pars_fragment:Eg,clipping_planes_fragment:wg,clipping_planes_pars_fragment:Ag,clipping_planes_pars_vertex:Tg,clipping_planes_vertex:Rg,color_fragment:Cg,color_pars_fragment:Dg,color_pars_vertex:Pg,color_vertex:Ig,common:Lg,cube_uv_reflection_fragment:Ng,defaultnormal_vertex:Ug,displacementmap_pars_vertex:Fg,displacementmap_vertex:Og,emissivemap_fragment:zg,emissivemap_pars_fragment:Bg,colorspace_fragment:kg,colorspace_pars_fragment:Hg,envmap_fragment:Gg,envmap_common_pars_fragment:Vg,envmap_pars_fragment:Wg,envmap_pars_vertex:Xg,envmap_physical_pars_fragment:n1,envmap_vertex:qg,fog_vertex:Yg,fog_pars_vertex:Kg,fog_fragment:$g,fog_pars_fragment:Zg,gradientmap_pars_fragment:Jg,lightmap_pars_fragment:Qg,lights_lambert_fragment:jg,lights_lambert_pars_fragment:e1,lights_pars_begin:t1,lights_toon_fragment:i1,lights_toon_pars_fragment:s1,lights_phong_fragment:r1,lights_phong_pars_fragment:a1,lights_physical_fragment:o1,lights_physical_pars_fragment:l1,lights_fragment_begin:c1,lights_fragment_maps:h1,lights_fragment_end:u1,lightprobes_pars_fragment:d1,logdepthbuf_fragment:f1,logdepthbuf_pars_fragment:p1,logdepthbuf_pars_vertex:m1,logdepthbuf_vertex:g1,map_fragment:v1,map_pars_fragment:_1,map_particle_fragment:x1,map_particle_pars_fragment:M1,metalnessmap_fragment:y1,metalnessmap_pars_fragment:S1,morphinstance_vertex:b1,morphcolor_vertex:E1,morphnormal_vertex:w1,morphtarget_pars_vertex:A1,morphtarget_vertex:T1,normal_fragment_begin:R1,normal_fragment_maps:C1,normal_pars_fragment:D1,normal_pars_vertex:P1,normal_vertex:I1,normalmap_pars_fragment:L1,clearcoat_normal_fragment_begin:N1,clearcoat_normal_fragment_maps:U1,clearcoat_pars_fragment:F1,iridescence_pars_fragment:O1,opaque_fragment:z1,packing:B1,premultiplied_alpha_fragment:k1,project_vertex:H1,dithering_fragment:G1,dithering_pars_fragment:V1,roughnessmap_fragment:W1,roughnessmap_pars_fragment:X1,shadowmap_pars_fragment:q1,shadowmap_pars_vertex:Y1,shadowmap_vertex:K1,shadowmask_pars_fragment:$1,skinbase_vertex:Z1,skinning_pars_vertex:J1,skinning_vertex:Q1,skinnormal_vertex:j1,specularmap_fragment:e2,specularmap_pars_fragment:t2,tonemapping_fragment:n2,tonemapping_pars_fragment:i2,transmission_fragment:s2,transmission_pars_fragment:r2,uv_pars_fragment:a2,uv_pars_vertex:o2,uv_vertex:l2,worldpos_vertex:c2,background_vert:h2,background_frag:u2,backgroundCube_vert:d2,backgroundCube_frag:f2,cube_vert:p2,cube_frag:m2,depth_vert:g2,depth_frag:v2,distance_vert:_2,distance_frag:x2,equirect_vert:M2,equirect_frag:y2,linedashed_vert:S2,linedashed_frag:b2,meshbasic_vert:E2,meshbasic_frag:w2,meshlambert_vert:A2,meshlambert_frag:T2,meshmatcap_vert:R2,meshmatcap_frag:C2,meshnormal_vert:D2,meshnormal_frag:P2,meshphong_vert:I2,meshphong_frag:L2,meshphysical_vert:N2,meshphysical_frag:U2,meshtoon_vert:F2,meshtoon_frag:O2,points_vert:z2,points_frag:B2,shadow_vert:k2,shadow_frag:H2,sprite_vert:G2,sprite_frag:V2},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 U},probesMax:{value:new U},probesResolution:{value:new U}},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}}},Bn={basic:{uniforms:Zt([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.fog]),vertexShader:Ve.meshbasic_vert,fragmentShader:Ve.meshbasic_frag},lambert:{uniforms:Zt([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:Zt([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:Zt([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:Zt([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:Zt([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,{matcap:{value:null}}]),vertexShader:Ve.meshmatcap_vert,fragmentShader:Ve.meshmatcap_frag},points:{uniforms:Zt([fe.points,fe.fog]),vertexShader:Ve.points_vert,fragmentShader:Ve.points_frag},dashed:{uniforms:Zt([fe.common,fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ve.linedashed_vert,fragmentShader:Ve.linedashed_frag},depth:{uniforms:Zt([fe.common,fe.displacementmap]),vertexShader:Ve.depth_vert,fragmentShader:Ve.depth_frag},normal:{uniforms:Zt([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,{opacity:{value:1}}]),vertexShader:Ve.meshnormal_vert,fragmentShader:Ve.meshnormal_frag},sprite:{uniforms:Zt([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:Zt([fe.common,fe.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ve.distance_vert,fragmentShader:Ve.distance_frag},shadow:{uniforms:Zt([fe.lights,fe.fog,{color:{value:new Me(0)},opacity:{value:1}}]),vertexShader:Ve.shadow_vert,fragmentShader:Ve.shadow_frag}};Bn.physical={uniforms:Zt([Bn.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 va={r:0,b:0,g:0},W2=new ht,z0=new ze;z0.set(-1,0,0,0,1,0,0,0,1);function X2(i,e,t,n,s,r){const a=new Me(0);let o=s===!0?0:1,l,c,h=null,u=0,d=null;function f(E){let A=E.isScene===!0?E.background:null;if(A&&A.isTexture){const M=E.backgroundBlurriness>0;A=e.get(A,M)}return A}function g(E){let A=!1;const M=f(E);M===null?m(a,o):M&&M.isColor&&(m(M,1),A=!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||A)&&(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(E,A){const M=f(A);M&&(M.isCubeTexture||M.mapping===ho)?(c===void 0&&(c=new nt(new bn(1,1,1),new It({name:"BackgroundCubeMaterial",uniforms:$s(Bn.backgroundCube.uniforms),vertexShader:Bn.backgroundCube.vertexShader,fragmentShader:Bn.backgroundCube.fragmentShader,side:Dt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(S,w,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=M,c.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(W2.makeRotationFromEuler(A.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(z0),c.material.toneMapped=Ke.getTransfer(M.colorSpace)!==et,(h!==M||u!==M.version||d!==i.toneMapping)&&(c.material.needsUpdate=!0,h=M,u=M.version,d=i.toneMapping),c.layers.enableAll(),E.unshift(c,c.geometry,c.material,0,0,null)):M&&M.isTexture&&(l===void 0&&(l=new nt(new as(2,2),new It({name:"BackgroundMaterial",uniforms:$s(Bn.background.uniforms),vertexShader:Bn.background.vertexShader,fragmentShader:Bn.background.fragmentShader,side:Ci,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=M,l.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,l.material.toneMapped=Ke.getTransfer(M.colorSpace)!==et,M.matrixAutoUpdate===!0&&M.updateMatrix(),l.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||u!==M.version||d!==i.toneMapping)&&(l.material.needsUpdate=!0,h=M,u=M.version,d=i.toneMapping),l.layers.enableAll(),E.unshift(l,l.geometry,l.material,0,0,null))}function m(E,A){E.getRGB(va,L0(i)),t.buffers.color.setClear(va.r,va.g,va.b,A,r)}function p(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(E,A=1){a.set(E),o=A,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(E){o=E,m(a,o)},render:g,addToRenderList:x,dispose:p}}function q2(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=d(null);let r=s,a=!1;function o(C,I,W,X,F){let q=!1;const G=u(C,X,W,I);r!==G&&(r=G,c(r.object)),q=f(C,X,W,F),q&&g(C,X,W,F),F!==null&&e.update(F,i.ELEMENT_ARRAY_BUFFER),(q||a)&&(a=!1,M(C,I,W,X),F!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(F).buffer))}function l(){return i.createVertexArray()}function c(C){return i.bindVertexArray(C)}function h(C){return i.deleteVertexArray(C)}function u(C,I,W,X){const F=X.wireframe===!0;let q=n[I.id];q===void 0&&(q={},n[I.id]=q);const G=C.isInstancedMesh===!0?C.id:0;let Z=q[G];Z===void 0&&(Z={},q[G]=Z);let te=Z[W.id];te===void 0&&(te={},Z[W.id]=te);let j=te[F];return j===void 0&&(j=d(l()),te[F]=j),j}function d(C){const I=[],W=[],X=[];for(let F=0;F<t;F++)I[F]=0,W[F]=0,X[F]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:W,attributeDivisors:X,object:C,attributes:{},index:null}}function f(C,I,W,X){const F=r.attributes,q=I.attributes;let G=0;const Z=W.getAttributes();for(const te in Z)if(Z[te].location>=0){const ie=F[te];let ue=q[te];if(ue===void 0&&(te==="instanceMatrix"&&C.instanceMatrix&&(ue=C.instanceMatrix),te==="instanceColor"&&C.instanceColor&&(ue=C.instanceColor)),ie===void 0||ie.attribute!==ue||ue&&ie.data!==ue.data)return!0;G++}return r.attributesNum!==G||r.index!==X}function g(C,I,W,X){const F={},q=I.attributes;let G=0;const Z=W.getAttributes();for(const te in Z)if(Z[te].location>=0){let ie=q[te];ie===void 0&&(te==="instanceMatrix"&&C.instanceMatrix&&(ie=C.instanceMatrix),te==="instanceColor"&&C.instanceColor&&(ie=C.instanceColor));const ue={};ue.attribute=ie,ie&&ie.data&&(ue.data=ie.data),F[te]=ue,G++}r.attributes=F,r.attributesNum=G,r.index=X}function x(){const C=r.newAttributes;for(let I=0,W=C.length;I<W;I++)C[I]=0}function m(C){p(C,0)}function p(C,I){const W=r.newAttributes,X=r.enabledAttributes,F=r.attributeDivisors;W[C]=1,X[C]===0&&(i.enableVertexAttribArray(C),X[C]=1),F[C]!==I&&(i.vertexAttribDivisor(C,I),F[C]=I)}function E(){const C=r.newAttributes,I=r.enabledAttributes;for(let W=0,X=I.length;W<X;W++)I[W]!==C[W]&&(i.disableVertexAttribArray(W),I[W]=0)}function A(C,I,W,X,F,q,G){G===!0?i.vertexAttribIPointer(C,I,W,F,q):i.vertexAttribPointer(C,I,W,X,F,q)}function M(C,I,W,X){x();const F=X.attributes,q=W.getAttributes(),G=I.defaultAttributeValues;for(const Z in q){const te=q[Z];if(te.location>=0){let j=F[Z];if(j===void 0&&(Z==="instanceMatrix"&&C.instanceMatrix&&(j=C.instanceMatrix),Z==="instanceColor"&&C.instanceColor&&(j=C.instanceColor)),j!==void 0){const ie=j.normalized,ue=j.itemSize,ke=e.get(j);if(ke===void 0)continue;const qe=ke.buffer,Be=ke.type,Y=ke.bytesPerElement,re=Be===i.INT||Be===i.UNSIGNED_INT||j.gpuType===Jc;if(j.isInterleavedBufferAttribute){const ne=j.data,z=ne.stride,Ee=j.offset;if(ne.isInstancedInterleavedBuffer){for(let De=0;De<te.locationSize;De++)p(te.location+De,ne.meshPerAttribute);C.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let De=0;De<te.locationSize;De++)m(te.location+De);i.bindBuffer(i.ARRAY_BUFFER,qe);for(let De=0;De<te.locationSize;De++)A(te.location+De,ue/te.locationSize,Be,ie,z*Y,(Ee+ue/te.locationSize*De)*Y,re)}else{if(j.isInstancedBufferAttribute){for(let ne=0;ne<te.locationSize;ne++)p(te.location+ne,j.meshPerAttribute);C.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,qe);for(let ne=0;ne<te.locationSize;ne++)A(te.location+ne,ue/te.locationSize,Be,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)}}}}E()}function S(){b();for(const C in n){const I=n[C];for(const W in I){const X=I[W];for(const F in X){const q=X[F];for(const G in q)h(q[G].object),delete q[G];delete X[F]}}delete n[C]}}function w(C){if(n[C.id]===void 0)return;const I=n[C.id];for(const W in I){const X=I[W];for(const F in X){const q=X[F];for(const G in q)h(q[G].object),delete q[G];delete X[F]}}delete n[C.id]}function R(C){for(const I in n){const W=n[I];for(const X in W){const F=W[X];if(F[C.id]===void 0)continue;const q=F[C.id];for(const G in q)h(q[G].object),delete q[G];delete F[C.id]}}}function _(C){for(const I in n){const W=n[I],X=C.isInstancedMesh===!0?C.id:0,F=W[X];if(F!==void 0){for(const q in F){const G=F[q];for(const Z in G)h(G[Z].object),delete G[Z];delete F[q]}delete W[X],Object.keys(W).length===0&&delete n[I]}}}function b(){D(),a=!0,r!==s&&(r=s,c(r.object))}function D(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:b,resetDefaultState:D,dispose:S,releaseStatesOfGeometry:w,releaseStatesOfObject:_,releaseStatesOfProgram:R,initAttributes:x,enableAttribute:m,disableUnusedAttributes:E}}function Y2(i,e,t){let n;function s(l){n=l}function r(l,c){i.drawArrays(n,l,c),t.update(c,n,1)}function a(l,c,h){h!==0&&(i.drawArraysInstanced(n,l,c,h),t.update(c,n,h))}function o(l,c,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,c,0,h);let d=0;for(let f=0;f<h;f++)d+=c[f];t.update(d,n,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function K2(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!==pn&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const _=R===mn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(R!==dn&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==Xn&&!_)}function l(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 c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(Oe("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&d===!1&&Oe("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),E=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),A=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),S=i.getParameter(i.MAX_SAMPLES),w=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:E,maxVaryings:A,maxFragmentUniforms:M,maxSamples:S,samples:w}}function $2(i){const e=this;let t=null,n=0,s=!1,r=!1;const a=new Vi,o=new ze,l={value:null,needsUpdate:!1};this.uniform=l,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):c();else{const E=r?0:n,A=E*4;let M=p.clippingState||null;l.value=M,M=h(g,d,A,f);for(let S=0;S!==A;++S)M[S]=t[S];p.clippingState=M,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=E}};function c(){l.value!==t&&(l.value=t,l.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=l.value,g!==!0||m===null){const p=f+x*4,E=d.matrixWorldInverse;o.getNormalMatrix(E),(m===null||m.length<p)&&(m=new Float32Array(p));for(let A=0,M=f;A!==x;++A,M+=4)a.copy(u[A]).applyMatrix4(E,o),a.normal.toArray(m,M),m[M+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,m}}const Ei=4,Tu=[.125,.215,.35,.446,.526,.582],Xi=20,Z2=256,or=new Lr,Ru=new Me;let Jo=null,Qo=0,jo=0,el=!1;const J2=new U;class Cu{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=J2}=r;Jo=this._renderer.getRenderTarget(),Qo=this._renderer.getActiveCubeFace(),jo=this._renderer.getActiveMipmapLevel(),el=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,s,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=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(Jo,Qo,jo),this._renderer.xr.enabled=el,e.scissorTest=!1,Rs(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Qi||e.mapping===Ks?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Jo=this._renderer.getRenderTarget(),Qo=this._renderer.getActiveCubeFace(),jo=this._renderer.getActiveMipmapLevel(),el=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:Tt,minFilter:Tt,generateMipmaps:!1,type:mn,format:pn,colorSpace:Ka,depthBuffer:!1},s=Du(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Du(e,t,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Q2(r)),this._blurMaterial=ev(r,e,t),this._ggxMaterial=j2(r,e,t)}return s}_compileMaterial(e){const t=new nt(new bt,e);this._renderer.compile(t,or)}_sceneToCubeUV(e,t,n,s,r){const l=new un(90,1,t,n),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(Ru),u.toneMapping=Kn,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(s),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new nt(new bn,new es({name:"PMREM.Background",side:Dt,depthWrite:!1,depthTest:!1})));const x=this._backgroundBox,m=x.material;let p=!1;const E=e.background;E?E.isColor&&(m.color.copy(E),e.background=null,p=!0):(m.color.copy(Ru),p=!0);for(let A=0;A<6;A++){const M=A%3;M===0?(l.up.set(0,c[A],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x+h[A],r.y,r.z)):M===1?(l.up.set(0,0,c[A]),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y+h[A],r.z)):(l.up.set(0,c[A],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y,r.z+h[A]));const S=this._cubeSize;Rs(s,M*S,A>2?S:0,S,S),u.setRenderTarget(s),p&&u.render(x,l),u.render(e,l)}u.toneMapping=f,u.autoClear=d,e.background=E}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===Qi||e.mapping===Ks;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 l=this._cubeSize;Rs(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,or)}_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 l=a.uniforms,c=n/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-h*h),d=0+c*1.25,f=u*d,{_lodMax:g}=this,x=this._sizeLods[n],m=3*x*(n>g-Ei?n-g+Ei:0),p=4*(this._cubeSize-x);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=g-t,Rs(r,m,p,3*x,2*x),s.setRenderTarget(r),s.render(o,or),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=g-n,Rs(e,m,p,3*x,2*x),s.setRenderTarget(e),s.render(o,or)}_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 l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Ye("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[s];u.material=c;const d=c.uniforms,f=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Xi-1),x=r/g,m=isFinite(r)?1+Math.floor(h*x):Xi;m>Xi&&Oe(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Xi}`);const p=[];let E=0;for(let R=0;R<Xi;++R){const _=R/x,b=Math.exp(-_*_/2);p.push(b),R===0?E+=b:R<m&&(E+=2*b)}for(let R=0;R<p.length;R++)p[R]=p[R]/E;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:A}=this;d.dTheta.value=g,d.mipInt.value=A-n;const M=this._sizeLods[s],S=3*M*(s>A-Ei?s-A+Ei:0),w=4*(this._cubeSize-M);Rs(t,S,w,3*M,2*M),l.setRenderTarget(t),l.render(u,or)}}function Q2(i){const e=[],t=[],n=[];let s=i;const r=i-Ei+1+Tu.length;for(let a=0;a<r;a++){const o=Math.pow(2,s);e.push(o);let l=1/o;a>i-Ei?l=Tu[a-i+Ei-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,g=6,x=3,m=2,p=1,E=new Float32Array(x*g*f),A=new Float32Array(m*g*f),M=new Float32Array(p*g*f);for(let w=0;w<f;w++){const R=w%3*2/3-1,_=w>2?0:-1,b=[R,_,0,R+2/3,_,0,R+2/3,_+1,0,R,_,0,R+2/3,_+1,0,R,_+1,0];E.set(b,x*g*w),A.set(d,m*g*w);const D=[w,w,w,w,w,w];M.set(D,p*g*w)}const S=new bt;S.setAttribute("position",new ct(E,x)),S.setAttribute("uv",new ct(A,m)),S.setAttribute("faceIndex",new ct(M,p)),n.push(new nt(S,null)),s>Ei&&s--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Du(i,e,t){const n=new Sn(i,e,t);return n.texture.mapping=ho,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Rs(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function j2(i,e,t){return new It({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Z2,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:po(),fragmentShader:`
4320
+ }`,Ve={alphahash_fragment:fg,alphahash_pars_fragment:pg,alphamap_fragment:mg,alphamap_pars_fragment:gg,alphatest_fragment:vg,alphatest_pars_fragment:xg,aomap_fragment:_g,aomap_pars_fragment:Mg,batching_pars_vertex:yg,batching_vertex:Sg,begin_vertex:bg,beginnormal_vertex:Eg,bsdfs:wg,iridescence_fragment:Ag,bumpmap_pars_fragment:Tg,clipping_planes_fragment:Rg,clipping_planes_pars_fragment:Cg,clipping_planes_pars_vertex:Dg,clipping_planes_vertex:Pg,color_fragment:Ig,color_pars_fragment:Lg,color_pars_vertex:Ng,color_vertex:Ug,common:Fg,cube_uv_reflection_fragment:Og,defaultnormal_vertex:zg,displacementmap_pars_vertex:Bg,displacementmap_vertex:kg,emissivemap_fragment:Hg,emissivemap_pars_fragment:Gg,colorspace_fragment:Vg,colorspace_pars_fragment:Wg,envmap_fragment:Xg,envmap_common_pars_fragment:qg,envmap_pars_fragment:Yg,envmap_pars_vertex:Kg,envmap_physical_pars_fragment:r1,envmap_vertex:$g,fog_vertex:Zg,fog_pars_vertex:Jg,fog_fragment:Qg,fog_pars_fragment:jg,gradientmap_pars_fragment:e1,lightmap_pars_fragment:t1,lights_lambert_fragment:n1,lights_lambert_pars_fragment:i1,lights_pars_begin:s1,lights_toon_fragment:a1,lights_toon_pars_fragment:o1,lights_phong_fragment:l1,lights_phong_pars_fragment:c1,lights_physical_fragment:h1,lights_physical_pars_fragment:u1,lights_fragment_begin:d1,lights_fragment_maps:f1,lights_fragment_end:p1,lightprobes_pars_fragment:m1,logdepthbuf_fragment:g1,logdepthbuf_pars_fragment:v1,logdepthbuf_pars_vertex:x1,logdepthbuf_vertex:_1,map_fragment:M1,map_pars_fragment:y1,map_particle_fragment:S1,map_particle_pars_fragment:b1,metalnessmap_fragment:E1,metalnessmap_pars_fragment:w1,morphinstance_vertex:A1,morphcolor_vertex:T1,morphnormal_vertex:R1,morphtarget_pars_vertex:C1,morphtarget_vertex:D1,normal_fragment_begin:P1,normal_fragment_maps:I1,normal_pars_fragment:L1,normal_pars_vertex:N1,normal_vertex:U1,normalmap_pars_fragment:F1,clearcoat_normal_fragment_begin:O1,clearcoat_normal_fragment_maps:z1,clearcoat_pars_fragment:B1,iridescence_pars_fragment:k1,opaque_fragment:H1,packing:G1,premultiplied_alpha_fragment:V1,project_vertex:W1,dithering_fragment:X1,dithering_pars_fragment:q1,roughnessmap_fragment:Y1,roughnessmap_pars_fragment:K1,shadowmap_pars_fragment:$1,shadowmap_pars_vertex:Z1,shadowmap_vertex:J1,shadowmask_pars_fragment:Q1,skinbase_vertex:j1,skinning_pars_vertex:e2,skinning_vertex:t2,skinnormal_vertex:n2,specularmap_fragment:i2,specularmap_pars_fragment:s2,tonemapping_fragment:r2,tonemapping_pars_fragment:a2,transmission_fragment:o2,transmission_pars_fragment:l2,uv_pars_fragment:c2,uv_pars_vertex:h2,uv_vertex:u2,worldpos_vertex:d2,background_vert:f2,background_frag:p2,backgroundCube_vert:m2,backgroundCube_frag:g2,cube_vert:v2,cube_frag:x2,depth_vert:_2,depth_frag:M2,distance_vert:y2,distance_frag:S2,equirect_vert:b2,equirect_frag:E2,linedashed_vert:w2,linedashed_frag:A2,meshbasic_vert:T2,meshbasic_frag:R2,meshlambert_vert:C2,meshlambert_frag:D2,meshmatcap_vert:P2,meshmatcap_frag:I2,meshnormal_vert:L2,meshnormal_frag:N2,meshphong_vert:U2,meshphong_frag:F2,meshphysical_vert:O2,meshphysical_frag:z2,meshtoon_vert:B2,meshtoon_frag:k2,points_vert:H2,points_frag:G2,shadow_vert:V2,shadow_frag:W2,sprite_vert:X2,sprite_frag:q2},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 U},probesMax:{value:new U},probesResolution:{value:new U}},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}}},Bn={basic:{uniforms:Zt([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.fog]),vertexShader:Ve.meshbasic_vert,fragmentShader:Ve.meshbasic_frag},lambert:{uniforms:Zt([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:Zt([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:Zt([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:Zt([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:Zt([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,{matcap:{value:null}}]),vertexShader:Ve.meshmatcap_vert,fragmentShader:Ve.meshmatcap_frag},points:{uniforms:Zt([fe.points,fe.fog]),vertexShader:Ve.points_vert,fragmentShader:Ve.points_frag},dashed:{uniforms:Zt([fe.common,fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ve.linedashed_vert,fragmentShader:Ve.linedashed_frag},depth:{uniforms:Zt([fe.common,fe.displacementmap]),vertexShader:Ve.depth_vert,fragmentShader:Ve.depth_frag},normal:{uniforms:Zt([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,{opacity:{value:1}}]),vertexShader:Ve.meshnormal_vert,fragmentShader:Ve.meshnormal_frag},sprite:{uniforms:Zt([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:Zt([fe.common,fe.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ve.distance_vert,fragmentShader:Ve.distance_frag},shadow:{uniforms:Zt([fe.lights,fe.fog,{color:{value:new Me(0)},opacity:{value:1}}]),vertexShader:Ve.shadow_vert,fragmentShader:Ve.shadow_frag}};Bn.physical={uniforms:Zt([Bn.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 Ma={r:0,b:0,g:0},Y2=new ht,V0=new ze;V0.set(-1,0,0,0,1,0,0,0,1);function K2(i,e,t,n,s,r){const a=new Me(0);let o=s===!0?0:1,l,c,h=null,u=0,d=null;function f(E){let A=E.isScene===!0?E.background:null;if(A&&A.isTexture){const M=E.backgroundBlurriness>0;A=e.get(A,M)}return A}function g(E){let A=!1;const M=f(E);M===null?m(a,o):M&&M.isColor&&(m(M,1),A=!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||A)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function _(E,A){const M=f(A);M&&(M.isCubeTexture||M.mapping===fo)?(c===void 0&&(c=new Je(new bn(1,1,1),new Et({name:"BackgroundCubeMaterial",uniforms:Js(Bn.backgroundCube.uniforms),vertexShader:Bn.backgroundCube.vertexShader,fragmentShader:Bn.backgroundCube.fragmentShader,side:Pt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(S,w,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=M,c.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Y2.makeRotationFromEuler(A.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(V0),c.material.toneMapped=Ke.getTransfer(M.colorSpace)!==tt,(h!==M||u!==M.version||d!==i.toneMapping)&&(c.material.needsUpdate=!0,h=M,u=M.version,d=i.toneMapping),c.layers.enableAll(),E.unshift(c,c.geometry,c.material,0,0,null)):M&&M.isTexture&&(l===void 0&&(l=new Je(new Ui(2,2),new Et({name:"BackgroundMaterial",uniforms:Js(Bn.background.uniforms),vertexShader:Bn.background.vertexShader,fragmentShader:Bn.background.fragmentShader,side:Pi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=M,l.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,l.material.toneMapped=Ke.getTransfer(M.colorSpace)!==tt,M.matrixAutoUpdate===!0&&M.updateMatrix(),l.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||u!==M.version||d!==i.toneMapping)&&(l.material.needsUpdate=!0,h=M,u=M.version,d=i.toneMapping),l.layers.enableAll(),E.unshift(l,l.geometry,l.material,0,0,null))}function m(E,A){E.getRGB(Ma,z0(i)),t.buffers.color.setClear(Ma.r,Ma.g,Ma.b,A,r)}function p(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(E,A=1){a.set(E),o=A,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(E){o=E,m(a,o)},render:g,addToRenderList:_,dispose:p}}function $2(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=d(null);let r=s,a=!1;function o(C,I,W,X,F){let q=!1;const G=u(C,X,W,I);r!==G&&(r=G,c(r.object)),q=f(C,X,W,F),q&&g(C,X,W,F),F!==null&&e.update(F,i.ELEMENT_ARRAY_BUFFER),(q||a)&&(a=!1,M(C,I,W,X),F!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(F).buffer))}function l(){return i.createVertexArray()}function c(C){return i.bindVertexArray(C)}function h(C){return i.deleteVertexArray(C)}function u(C,I,W,X){const F=X.wireframe===!0;let q=n[I.id];q===void 0&&(q={},n[I.id]=q);const G=C.isInstancedMesh===!0?C.id:0;let Z=q[G];Z===void 0&&(Z={},q[G]=Z);let te=Z[W.id];te===void 0&&(te={},Z[W.id]=te);let j=te[F];return j===void 0&&(j=d(l()),te[F]=j),j}function d(C){const I=[],W=[],X=[];for(let F=0;F<t;F++)I[F]=0,W[F]=0,X[F]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:W,attributeDivisors:X,object:C,attributes:{},index:null}}function f(C,I,W,X){const F=r.attributes,q=I.attributes;let G=0;const Z=W.getAttributes();for(const te in Z)if(Z[te].location>=0){const ie=F[te];let ue=q[te];if(ue===void 0&&(te==="instanceMatrix"&&C.instanceMatrix&&(ue=C.instanceMatrix),te==="instanceColor"&&C.instanceColor&&(ue=C.instanceColor)),ie===void 0||ie.attribute!==ue||ue&&ie.data!==ue.data)return!0;G++}return r.attributesNum!==G||r.index!==X}function g(C,I,W,X){const F={},q=I.attributes;let G=0;const Z=W.getAttributes();for(const te in Z)if(Z[te].location>=0){let ie=q[te];ie===void 0&&(te==="instanceMatrix"&&C.instanceMatrix&&(ie=C.instanceMatrix),te==="instanceColor"&&C.instanceColor&&(ie=C.instanceColor));const ue={};ue.attribute=ie,ie&&ie.data&&(ue.data=ie.data),F[te]=ue,G++}r.attributes=F,r.attributesNum=G,r.index=X}function _(){const C=r.newAttributes;for(let I=0,W=C.length;I<W;I++)C[I]=0}function m(C){p(C,0)}function p(C,I){const W=r.newAttributes,X=r.enabledAttributes,F=r.attributeDivisors;W[C]=1,X[C]===0&&(i.enableVertexAttribArray(C),X[C]=1),F[C]!==I&&(i.vertexAttribDivisor(C,I),F[C]=I)}function E(){const C=r.newAttributes,I=r.enabledAttributes;for(let W=0,X=I.length;W<X;W++)I[W]!==C[W]&&(i.disableVertexAttribArray(W),I[W]=0)}function A(C,I,W,X,F,q,G){G===!0?i.vertexAttribIPointer(C,I,W,F,q):i.vertexAttribPointer(C,I,W,X,F,q)}function M(C,I,W,X){_();const F=X.attributes,q=W.getAttributes(),G=I.defaultAttributeValues;for(const Z in q){const te=q[Z];if(te.location>=0){let j=F[Z];if(j===void 0&&(Z==="instanceMatrix"&&C.instanceMatrix&&(j=C.instanceMatrix),Z==="instanceColor"&&C.instanceColor&&(j=C.instanceColor)),j!==void 0){const ie=j.normalized,ue=j.itemSize,ke=e.get(j);if(ke===void 0)continue;const qe=ke.buffer,Be=ke.type,Y=ke.bytesPerElement,re=Be===i.INT||Be===i.UNSIGNED_INT||j.gpuType===th;if(j.isInterleavedBufferAttribute){const ne=j.data,z=ne.stride,Ee=j.offset;if(ne.isInstancedInterleavedBuffer){for(let De=0;De<te.locationSize;De++)p(te.location+De,ne.meshPerAttribute);C.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let De=0;De<te.locationSize;De++)m(te.location+De);i.bindBuffer(i.ARRAY_BUFFER,qe);for(let De=0;De<te.locationSize;De++)A(te.location+De,ue/te.locationSize,Be,ie,z*Y,(Ee+ue/te.locationSize*De)*Y,re)}else{if(j.isInstancedBufferAttribute){for(let ne=0;ne<te.locationSize;ne++)p(te.location+ne,j.meshPerAttribute);C.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,qe);for(let ne=0;ne<te.locationSize;ne++)A(te.location+ne,ue/te.locationSize,Be,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)}}}}E()}function S(){b();for(const C in n){const I=n[C];for(const W in I){const X=I[W];for(const F in X){const q=X[F];for(const G in q)h(q[G].object),delete q[G];delete X[F]}}delete n[C]}}function w(C){if(n[C.id]===void 0)return;const I=n[C.id];for(const W in I){const X=I[W];for(const F in X){const q=X[F];for(const G in q)h(q[G].object),delete q[G];delete X[F]}}delete n[C.id]}function R(C){for(const I in n){const W=n[I];for(const X in W){const F=W[X];if(F[C.id]===void 0)continue;const q=F[C.id];for(const G in q)h(q[G].object),delete q[G];delete F[C.id]}}}function x(C){for(const I in n){const W=n[I],X=C.isInstancedMesh===!0?C.id:0,F=W[X];if(F!==void 0){for(const q in F){const G=F[q];for(const Z in G)h(G[Z].object),delete G[Z];delete F[q]}delete W[X],Object.keys(W).length===0&&delete n[I]}}}function b(){D(),a=!0,r!==s&&(r=s,c(r.object))}function D(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:b,resetDefaultState:D,dispose:S,releaseStatesOfGeometry:w,releaseStatesOfObject:x,releaseStatesOfProgram:R,initAttributes:_,enableAttribute:m,disableUnusedAttributes:E}}function Z2(i,e,t){let n;function s(l){n=l}function r(l,c){i.drawArrays(n,l,c),t.update(c,n,1)}function a(l,c,h){h!==0&&(i.drawArraysInstanced(n,l,c,h),t.update(c,n,h))}function o(l,c,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,c,0,h);let d=0;for(let f=0;f<h;f++)d+=c[f];t.update(d,n,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function J2(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!==gn&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const x=R===Qt&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(R!==pn&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==Xn&&!x)}function l(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 c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(Oe("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&d===!1&&Oe("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),_=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),E=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),A=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),S=i.getParameter(i.MAX_SAMPLES),w=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:_,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:E,maxVaryings:A,maxFragmentUniforms:M,maxSamples:S,samples:w}}function Q2(i){const e=this;let t=null,n=0,s=!1,r=!1;const a=new Xi,o=new ze,l={value:null,needsUpdate:!1};this.uniform=l,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,_=u.clipIntersection,m=u.clipShadows,p=i.get(u);if(!s||g===null||g.length===0||r&&!m)r?h(null):c();else{const E=r?0:n,A=E*4;let M=p.clippingState||null;l.value=M,M=h(g,d,A,f);for(let S=0;S!==A;++S)M[S]=t[S];p.clippingState=M,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=E}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,d,f,g){const _=u!==null?u.length:0;let m=null;if(_!==0){if(m=l.value,g!==!0||m===null){const p=f+_*4,E=d.matrixWorldInverse;o.getNormalMatrix(E),(m===null||m.length<p)&&(m=new Float32Array(p));for(let A=0,M=f;A!==_;++A,M+=4)a.copy(u[A]).applyMatrix4(E,o),a.normal.toArray(m,M),m[M+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=_,e.numIntersection=0,m}}const Ti=4,Iu=[.125,.215,.35,.446,.526,.582],Ki=20,j2=256,hr=new er,Lu=new Me;let el=null,tl=0,nl=0,il=!1;const ev=new U;class Nu{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=ev}=r;el=this._renderer.getRenderTarget(),tl=this._renderer.getActiveCubeFace(),nl=this._renderer.getActiveMipmapLevel(),il=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,s,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Ou(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Fu(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(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(el,tl,nl),this._renderer.xr.enabled=il,e.scissorTest=!1,Ds(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ts||e.mapping===Zs?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),el=this._renderer.getRenderTarget(),tl=this._renderer.getActiveCubeFace(),nl=this._renderer.getActiveMipmapLevel(),il=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:Rt,minFilter:Rt,generateMipmaps:!1,type:Qt,format:gn,colorSpace:Za,depthBuffer:!1},s=Uu(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Uu(e,t,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=tv(r)),this._blurMaterial=iv(r,e,t),this._ggxMaterial=nv(r,e,t)}return s}_compileMaterial(e){const t=new Je(new bt,e);this._renderer.compile(t,hr)}_sceneToCubeUV(e,t,n,s,r){const l=new fn(90,1,t,n),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(Lu),u.toneMapping=$n,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(s),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Je(new bn,new is({name:"PMREM.Background",side:Pt,depthWrite:!1,depthTest:!1})));const _=this._backgroundBox,m=_.material;let p=!1;const E=e.background;E?E.isColor&&(m.color.copy(E),e.background=null,p=!0):(m.color.copy(Lu),p=!0);for(let A=0;A<6;A++){const M=A%3;M===0?(l.up.set(0,c[A],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x+h[A],r.y,r.z)):M===1?(l.up.set(0,0,c[A]),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y+h[A],r.z)):(l.up.set(0,c[A],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y,r.z+h[A]));const S=this._cubeSize;Ds(s,M*S,A>2?S:0,S,S),u.setRenderTarget(s),p&&u.render(_,l),u.render(e,l)}u.toneMapping=f,u.autoClear=d,e.background=E}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===ts||e.mapping===Zs;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Ou()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Fu());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;Ds(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,hr)}_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 l=a.uniforms,c=n/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-h*h),d=0+c*1.25,f=u*d,{_lodMax:g}=this,_=this._sizeLods[n],m=3*_*(n>g-Ti?n-g+Ti:0),p=4*(this._cubeSize-_);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=g-t,Ds(r,m,p,3*_,2*_),s.setRenderTarget(r),s.render(o,hr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=g-n,Ds(e,m,p,3*_,2*_),s.setRenderTarget(e),s.render(o,hr)}_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 l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Ye("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[s];u.material=c;const d=c.uniforms,f=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Ki-1),_=r/g,m=isFinite(r)?1+Math.floor(h*_):Ki;m>Ki&&Oe(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ki}`);const p=[];let E=0;for(let R=0;R<Ki;++R){const x=R/_,b=Math.exp(-x*x/2);p.push(b),R===0?E+=b:R<m&&(E+=2*b)}for(let R=0;R<p.length;R++)p[R]=p[R]/E;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:A}=this;d.dTheta.value=g,d.mipInt.value=A-n;const M=this._sizeLods[s],S=3*M*(s>A-Ti?s-A+Ti:0),w=4*(this._cubeSize-M);Ds(t,S,w,3*M,2*M),l.setRenderTarget(t),l.render(u,hr)}}function tv(i){const e=[],t=[],n=[];let s=i;const r=i-Ti+1+Iu.length;for(let a=0;a<r;a++){const o=Math.pow(2,s);e.push(o);let l=1/o;a>i-Ti?l=Iu[a-i+Ti-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,g=6,_=3,m=2,p=1,E=new Float32Array(_*g*f),A=new Float32Array(m*g*f),M=new Float32Array(p*g*f);for(let w=0;w<f;w++){const R=w%3*2/3-1,x=w>2?0:-1,b=[R,x,0,R+2/3,x,0,R+2/3,x+1,0,R,x,0,R+2/3,x+1,0,R,x+1,0];E.set(b,_*g*w),A.set(d,m*g*w);const D=[w,w,w,w,w,w];M.set(D,p*g*w)}const S=new bt;S.setAttribute("position",new ct(E,_)),S.setAttribute("uv",new ct(A,m)),S.setAttribute("faceIndex",new ct(M,p)),n.push(new Je(S,null)),s>Ti&&s--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Uu(i,e,t){const n=new an(i,e,t);return n.texture.mapping=fo,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ds(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function nv(i,e,t){return new Et({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:j2,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:vo(),fragmentShader:`
4321
4321
 
4322
4322
  precision highp float;
4323
4323
  precision highp int;
@@ -4421,7 +4421,7 @@ void main() {
4421
4421
 
4422
4422
  gl_FragColor = vec4(prefilteredColor, 1.0);
4423
4423
  }
4424
- `,blending:ri,depthTest:!1,depthWrite:!1})}function ev(i,e,t){const n=new Float32Array(Xi),s=new U(0,1,0);return new It({name:"SphericalGaussianBlur",defines:{n:Xi,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:po(),fragmentShader:`
4424
+ `,blending:Kn,depthTest:!1,depthWrite:!1})}function iv(i,e,t){const n=new Float32Array(Ki),s=new U(0,1,0);return new Et({name:"SphericalGaussianBlur",defines:{n:Ki,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:vo(),fragmentShader:`
4425
4425
 
4426
4426
  precision mediump float;
4427
4427
  precision mediump int;
@@ -4481,7 +4481,7 @@ void main() {
4481
4481
  }
4482
4482
 
4483
4483
  }
4484
- `,blending:ri,depthTest:!1,depthWrite:!1})}function Pu(){return new It({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:po(),fragmentShader:`
4484
+ `,blending:Kn,depthTest:!1,depthWrite:!1})}function Fu(){return new Et({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:vo(),fragmentShader:`
4485
4485
 
4486
4486
  precision mediump float;
4487
4487
  precision mediump int;
@@ -4500,7 +4500,7 @@ void main() {
4500
4500
  gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
4501
4501
 
4502
4502
  }
4503
- `,blending:ri,depthTest:!1,depthWrite:!1})}function Iu(){return new It({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:po(),fragmentShader:`
4503
+ `,blending:Kn,depthTest:!1,depthWrite:!1})}function Ou(){return new Et({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:vo(),fragmentShader:`
4504
4504
 
4505
4505
  precision mediump float;
4506
4506
  precision mediump int;
@@ -4516,7 +4516,7 @@ void main() {
4516
4516
  gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
4517
4517
 
4518
4518
  }
4519
- `,blending:ri,depthTest:!1,depthWrite:!1})}function po(){return`
4519
+ `,blending:Kn,depthTest:!1,depthWrite:!1})}function vo(){return`
4520
4520
 
4521
4521
  precision mediump float;
4522
4522
  precision mediump int;
@@ -4571,7 +4571,7 @@ void main() {
4571
4571
  gl_Position = vec4( position, 1.0 );
4572
4572
 
4573
4573
  }
4574
- `}class B0 extends Sn{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 P0(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:`
4574
+ `}class W0 extends an{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 F0(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:`
4575
4575
 
4576
4576
  varying vec3 vWorldDirection;
4577
4577
 
@@ -4606,7 +4606,7 @@ void main() {
4606
4606
  gl_FragColor = texture2D( tEquirect, sampleUV );
4607
4607
 
4608
4608
  }
4609
- `},s=new bn(5,5,5),r=new It({name:"CubemapFromEquirect",uniforms:$s(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Dt,blending:ri});r.uniforms.tEquirect.value=t;const a=new nt(s,r),o=t.minFilter;return t.minFilter===Ki&&(t.minFilter=Tt),new ag(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 tv(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===yo||f===So)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 B0(g.height);return x.fromEquirectangularTexture(i,d),e.set(d,x),d.addEventListener("dispose",c),o(x.texture,d.mapping)}else return null}}return d}function a(d){if(d&&d.isTexture){const f=d.mapping,g=f===yo||f===So,x=f===Qi||f===Ks;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 Cu(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 E=d.image;return g&&E&&E.height>0||x&&E&&l(E)?(n===null&&(n=new Cu(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===yo?d.mapping=Qi:f===So&&(d.mapping=Ks),d}function l(d){let f=0;const g=6;for(let x=0;x<g;x++)d[x]!==void 0&&f++;return f===g}function c(d){const f=d.target;f.removeEventListener("dispose",c);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 nv(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&&ks("WebGLRenderer: "+n+" extension not supported."),s}}}function iv(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 l(u){const d=u.attributes;for(const f in d)e.update(d[f],i.ARRAY_BUFFER)}function c(u){const d=[],f=u.index,g=u.attributes.position;let x=0;if(g===void 0)return;if(f!==null){const E=f.array;x=f.version;for(let A=0,M=E.length;A<M;A+=3){const S=E[A+0],w=E[A+1],R=E[A+2];d.push(S,w,w,R,R,S)}}else{const E=g.array;x=g.version;for(let A=0,M=E.length/3-1;A<M;A+=3){const S=A+0,w=A+1,R=A+2;d.push(S,w,w,R,R,S)}}const m=new(g.count>=65535?R0:T0)(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&&c(u)}else c(u);return r.get(u)}return{get:o,update:l,getWireframeAttribute:h}}function sv(i,e,t){let n;function s(u){n=u}let r,a;function o(u){r=u.type,a=u.bytesPerElement}function l(u,d){i.drawElements(n,d,r,u*a),t.update(d,n,1)}function c(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=l,this.renderInstances=c,this.renderMultiDraw=h}function rv(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:Ye("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 av(i,e,t){const n=new WeakMap,s=new pt;function r(a,o,l){const c=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 b=function(){R.dispose(),n.delete(o),o.removeEventListener("dispose",b)};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||[],E=o.morphAttributes.color||[];let A=0;f===!0&&(A=1),g===!0&&(A=2),x===!0&&(A=3);let M=o.attributes.position.count*A,S=1;M>e.maxTextureSize&&(S=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);const w=new Float32Array(M*S*4*u),R=new w0(w,M,S,u);R.type=Xn,R.needsUpdate=!0;const _=A*4;for(let D=0;D<u;D++){const C=m[D],I=p[D],W=E[D],X=M*S*4*D;for(let F=0;F<C.count;F++){const q=F*_;f===!0&&(s.fromBufferAttribute(C,F),w[X+q+0]=s.x,w[X+q+1]=s.y,w[X+q+2]=s.z,w[X+q+3]=0),g===!0&&(s.fromBufferAttribute(I,F),w[X+q+4]=s.x,w[X+q+5]=s.y,w[X+q+6]=s.z,w[X+q+7]=0),x===!0&&(s.fromBufferAttribute(W,F),w[X+q+8]=s.x,w[X+q+9]=s.y,w[X+q+10]=s.z,w[X+q+11]=W.itemSize===4?s.w:1)}}d={count:u,texture:R,size:new Le(M,S)},n.set(o,d),o.addEventListener("dispose",b)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let f=0;for(let x=0;x<c.length;x++)f+=c[x];const g=o.morphTargetsRelative?1:1-f;l.getUniforms().setValue(i,"morphTargetBaseInfluence",g),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",d.texture,t),l.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:r}}function ov(i,e,t,n,s){let r=new WeakMap;function a(c){const h=s.render.frame,u=c.geometry,d=e.get(c,u);if(r.get(d)!==h&&(e.update(d),r.set(d,h)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),r.get(c)!==h&&(t.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,i.ARRAY_BUFFER),r.set(c,h))),c.isSkinnedMesh){const f=c.skeleton;r.get(f)!==h&&(f.update(),r.set(f,h))}return d}function o(){r=new WeakMap}function l(c){const h=c.target;h.removeEventListener("dispose",l),n.releaseStatesOfObject(h),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:a,dispose:o}}const lv={[c0]:"LINEAR_TONE_MAPPING",[h0]:"REINHARD_TONE_MAPPING",[u0]:"CINEON_TONE_MAPPING",[d0]:"ACES_FILMIC_TONE_MAPPING",[p0]:"AGX_TONE_MAPPING",[m0]:"NEUTRAL_TONE_MAPPING",[f0]:"CUSTOM_TONE_MAPPING"};function cv(i,e,t,n,s,r){const a=new Sn(e,t,{type:i,depthBuffer:s,stencilBuffer:r,samples:n?4:0,depthTexture:s?new ts(e,t):void 0}),o=new Sn(e,t,{type:mn,depthBuffer:!1,stencilBuffer:!1}),l=new bt;l.setAttribute("position",new Pt([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Pt([0,2,0,0,2,0],2));const c=new Qm({uniforms:{tDiffuse:{value:null}},vertexShader:`
4609
+ `},s=new bn(5,5,5),r=new Et({name:"CubemapFromEquirect",uniforms:Js(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Pt,blending:Kn});r.uniforms.tEquirect.value=t;const a=new Je(s,r),o=t.minFilter;return t.minFilter===Ji&&(t.minFilter=Rt),new cg(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 sv(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===Eo||f===wo)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 _=new W0(g.height);return _.fromEquirectangularTexture(i,d),e.set(d,_),d.addEventListener("dispose",c),o(_.texture,d.mapping)}else return null}}return d}function a(d){if(d&&d.isTexture){const f=d.mapping,g=f===Eo||f===wo,_=f===ts||f===Zs;if(g||_){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 Nu(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 E=d.image;return g&&E&&E.height>0||_&&E&&l(E)?(n===null&&(n=new Nu(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===Eo?d.mapping=ts:f===wo&&(d.mapping=Zs),d}function l(d){let f=0;const g=6;for(let _=0;_<g;_++)d[_]!==void 0&&f++;return f===g}function c(d){const f=d.target;f.removeEventListener("dispose",c);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 rv(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&&Gs("WebGLRenderer: "+n+" extension not supported."),s}}}function av(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 l(u){const d=u.attributes;for(const f in d)e.update(d[f],i.ARRAY_BUFFER)}function c(u){const d=[],f=u.index,g=u.attributes.position;let _=0;if(g===void 0)return;if(f!==null){const E=f.array;_=f.version;for(let A=0,M=E.length;A<M;A+=3){const S=E[A+0],w=E[A+1],R=E[A+2];d.push(S,w,w,R,R,S)}}else{const E=g.array;_=g.version;for(let A=0,M=E.length/3-1;A<M;A+=3){const S=A+0,w=A+1,R=A+2;d.push(S,w,w,R,R,S)}}const m=new(g.count>=65535?L0:I0)(d,1);m.version=_;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&&c(u)}else c(u);return r.get(u)}return{get:o,update:l,getWireframeAttribute:h}}function ov(i,e,t){let n;function s(u){n=u}let r,a;function o(u){r=u.type,a=u.bytesPerElement}function l(u,d){i.drawElements(n,d,r,u*a),t.update(d,n,1)}function c(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 _=0;for(let m=0;m<f;m++)_+=d[m];t.update(_,n,1)}this.setMode=s,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h}function lv(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:Ye("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 cv(i,e,t){const n=new WeakMap,s=new pt;function r(a,o,l){const c=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 b=function(){R.dispose(),n.delete(o),o.removeEventListener("dispose",b)};d!==void 0&&d.texture.dispose();const f=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,_=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],p=o.morphAttributes.normal||[],E=o.morphAttributes.color||[];let A=0;f===!0&&(A=1),g===!0&&(A=2),_===!0&&(A=3);let M=o.attributes.position.count*A,S=1;M>e.maxTextureSize&&(S=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);const w=new Float32Array(M*S*4*u),R=new D0(w,M,S,u);R.type=Xn,R.needsUpdate=!0;const x=A*4;for(let D=0;D<u;D++){const C=m[D],I=p[D],W=E[D],X=M*S*4*D;for(let F=0;F<C.count;F++){const q=F*x;f===!0&&(s.fromBufferAttribute(C,F),w[X+q+0]=s.x,w[X+q+1]=s.y,w[X+q+2]=s.z,w[X+q+3]=0),g===!0&&(s.fromBufferAttribute(I,F),w[X+q+4]=s.x,w[X+q+5]=s.y,w[X+q+6]=s.z,w[X+q+7]=0),_===!0&&(s.fromBufferAttribute(W,F),w[X+q+8]=s.x,w[X+q+9]=s.y,w[X+q+10]=s.z,w[X+q+11]=W.itemSize===4?s.w:1)}}d={count:u,texture:R,size:new Le(M,S)},n.set(o,d),o.addEventListener("dispose",b)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let f=0;for(let _=0;_<c.length;_++)f+=c[_];const g=o.morphTargetsRelative?1:1-f;l.getUniforms().setValue(i,"morphTargetBaseInfluence",g),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",d.texture,t),l.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:r}}function hv(i,e,t,n,s){let r=new WeakMap;function a(c){const h=s.render.frame,u=c.geometry,d=e.get(c,u);if(r.get(d)!==h&&(e.update(d),r.set(d,h)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),r.get(c)!==h&&(t.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,i.ARRAY_BUFFER),r.set(c,h))),c.isSkinnedMesh){const f=c.skeleton;r.get(f)!==h&&(f.update(),r.set(f,h))}return d}function o(){r=new WeakMap}function l(c){const h=c.target;h.removeEventListener("dispose",l),n.releaseStatesOfObject(h),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:a,dispose:o}}const uv={[p0]:"LINEAR_TONE_MAPPING",[m0]:"REINHARD_TONE_MAPPING",[g0]:"CINEON_TONE_MAPPING",[v0]:"ACES_FILMIC_TONE_MAPPING",[_0]:"AGX_TONE_MAPPING",[M0]:"NEUTRAL_TONE_MAPPING",[x0]:"CUSTOM_TONE_MAPPING"};function dv(i,e,t,n,s,r){const a=new an(e,t,{type:i,depthBuffer:s,stencilBuffer:r,samples:n?4:0,depthTexture:s?new ss(e,t):void 0}),o=new an(e,t,{type:Qt,depthBuffer:!1,stencilBuffer:!1}),l=new bt;l.setAttribute("position",new It([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new It([0,2,0,0,2,0],2));const c=new tg({uniforms:{tDiffuse:{value:null}},vertexShader:`
4610
4610
  precision highp float;
4611
4611
 
4612
4612
  uniform mat4 modelViewMatrix;
@@ -4652,17 +4652,17 @@ void main() {
4652
4652
  #ifdef SRGB_TRANSFER
4653
4653
  gl_FragColor = sRGBTransferOETF( gl_FragColor );
4654
4654
  #endif
4655
- }`,depthTest:!1,depthWrite:!1}),h=new nt(l,c),u=new Lr(-1,1,1,-1,0,1);let d=null,f=null,g=!1,x,m=null,p=[],E=!1;this.setSize=function(A,M){a.setSize(A,M),o.setSize(A,M);for(let S=0;S<p.length;S++){const w=p[S];w.setSize&&w.setSize(A,M)}},this.setEffects=function(A){p=A,E=p.length>0&&p[0].isRenderPass===!0;const M=a.width,S=a.height;for(let w=0;w<p.length;w++){const R=p[w];R.setSize&&R.setSize(M,S)}},this.begin=function(A,M){if(g||A.toneMapping===Kn&&p.length===0)return!1;if(m=M,M!==null){const S=M.width,w=M.height;(a.width!==S||a.height!==w)&&this.setSize(S,w)}return E===!1&&A.setRenderTarget(a),x=A.toneMapping,A.toneMapping=Kn,!0},this.hasRenderPass=function(){return E},this.end=function(A,M){A.toneMapping=x,g=!0;let S=a,w=o;for(let R=0;R<p.length;R++){const _=p[R];if(_.enabled!==!1&&(_.render(A,w,S,M),_.needsSwap!==!1)){const b=S;S=w,w=b}}if(d!==A.outputColorSpace||f!==A.toneMapping){d=A.outputColorSpace,f=A.toneMapping,c.defines={},Ke.getTransfer(d)===et&&(c.defines.SRGB_TRANSFER="");const R=lv[f];R&&(c.defines[R]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=S.texture,A.setRenderTarget(m),A.render(h,u),m=null,g=!1},this.isCompositing=function(){return g},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),l.dispose(),c.dispose()}}const k0=new Kt,Mc=new ts(1,1),H0=new w0,G0=new Tm,V0=new P0,Lu=[],Nu=[],Uu=new Float32Array(16),Fu=new Float32Array(9),Ou=new Float32Array(4);function Qs(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 Lt(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 Nt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function mo(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 hv(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function uv(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(Lt(t,e))return;i.uniform2fv(this.addr,e),Nt(t,e)}}function dv(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(Lt(t,e))return;i.uniform3fv(this.addr,e),Nt(t,e)}}function fv(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(Lt(t,e))return;i.uniform4fv(this.addr,e),Nt(t,e)}}function pv(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(Lt(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),Nt(t,e)}else{if(Lt(t,n))return;Ou.set(n),i.uniformMatrix2fv(this.addr,!1,Ou),Nt(t,n)}}function mv(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(Lt(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),Nt(t,e)}else{if(Lt(t,n))return;Fu.set(n),i.uniformMatrix3fv(this.addr,!1,Fu),Nt(t,n)}}function gv(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(Lt(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),Nt(t,e)}else{if(Lt(t,n))return;Uu.set(n),i.uniformMatrix4fv(this.addr,!1,Uu),Nt(t,n)}}function vv(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function _v(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(Lt(t,e))return;i.uniform2iv(this.addr,e),Nt(t,e)}}function xv(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(Lt(t,e))return;i.uniform3iv(this.addr,e),Nt(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.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(Lt(t,e))return;i.uniform4iv(this.addr,e),Nt(t,e)}}function yv(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function Sv(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(Lt(t,e))return;i.uniform2uiv(this.addr,e),Nt(t,e)}}function bv(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(Lt(t,e))return;i.uniform3uiv(this.addr,e),Nt(t,e)}}function Ev(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(Lt(t,e))return;i.uniform4uiv(this.addr,e),Nt(t,e)}}function wv(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?(Mc.compareFunction=t.isReversedDepthBuffer()?sh:ih,r=Mc):r=k0,t.setTexture2D(e||r,s)}function Av(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||G0,s)}function Tv(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTextureCube(e||V0,s)}function Rv(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||H0,s)}function Cv(i){switch(i){case 5126:return hv;case 35664:return uv;case 35665:return dv;case 35666:return fv;case 35674:return pv;case 35675:return mv;case 35676:return gv;case 5124:case 35670:return vv;case 35667:case 35671:return _v;case 35668:case 35672:return xv;case 35669:case 35673:return Mv;case 5125:return yv;case 36294:return Sv;case 36295:return bv;case 36296:return Ev;case 35678:case 36198:case 36298:case 36306:case 35682:return wv;case 35679:case 36299:case 36307:return Av;case 35680:case 36300:case 36308:case 36293:return Tv;case 36289:case 36303:case 36311:case 36292:return Rv}}function Dv(i,e){i.uniform1fv(this.addr,e)}function Pv(i,e){const t=Qs(e,this.size,2);i.uniform2fv(this.addr,t)}function Iv(i,e){const t=Qs(e,this.size,3);i.uniform3fv(this.addr,t)}function Lv(i,e){const t=Qs(e,this.size,4);i.uniform4fv(this.addr,t)}function Nv(i,e){const t=Qs(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function Uv(i,e){const t=Qs(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function Fv(i,e){const t=Qs(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function Ov(i,e){i.uniform1iv(this.addr,e)}function zv(i,e){i.uniform2iv(this.addr,e)}function Bv(i,e){i.uniform3iv(this.addr,e)}function kv(i,e){i.uniform4iv(this.addr,e)}function Hv(i,e){i.uniform1uiv(this.addr,e)}function Gv(i,e){i.uniform2uiv(this.addr,e)}function Vv(i,e){i.uniform3uiv(this.addr,e)}function Wv(i,e){i.uniform4uiv(this.addr,e)}function Xv(i,e,t){const n=this.cache,s=e.length,r=mo(t,s);Lt(n,r)||(i.uniform1iv(this.addr,r),Nt(n,r));let a;this.type===i.SAMPLER_2D_SHADOW?a=Mc:a=k0;for(let o=0;o!==s;++o)t.setTexture2D(e[o]||a,r[o])}function qv(i,e,t){const n=this.cache,s=e.length,r=mo(t,s);Lt(n,r)||(i.uniform1iv(this.addr,r),Nt(n,r));for(let a=0;a!==s;++a)t.setTexture3D(e[a]||G0,r[a])}function Yv(i,e,t){const n=this.cache,s=e.length,r=mo(t,s);Lt(n,r)||(i.uniform1iv(this.addr,r),Nt(n,r));for(let a=0;a!==s;++a)t.setTextureCube(e[a]||V0,r[a])}function Kv(i,e,t){const n=this.cache,s=e.length,r=mo(t,s);Lt(n,r)||(i.uniform1iv(this.addr,r),Nt(n,r));for(let a=0;a!==s;++a)t.setTexture2DArray(e[a]||H0,r[a])}function $v(i){switch(i){case 5126:return Dv;case 35664:return Pv;case 35665:return Iv;case 35666:return Lv;case 35674:return Nv;case 35675:return Uv;case 35676:return Fv;case 5124:case 35670:return Ov;case 35667:case 35671:return zv;case 35668:case 35672:return Bv;case 35669:case 35673:return kv;case 5125:return Hv;case 36294:return Gv;case 36295:return Vv;case 36296:return Wv;case 35678:case 36198:case 36298:case 36306:case 35682:return Xv;case 35679:case 36299:case 36307:return qv;case 35680:case 36300:case 36308:case 36293:return Yv;case 36289:case 36303:case 36311:case 36292:return Kv}}class Zv{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Cv(t.type)}}class Jv{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=$v(t.type)}}class Qv{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 tl=/(\w+)(\])?(\[|\.)?/g;function zu(i,e){i.seq.push(e),i.map[e.id]=e}function jv(i,e,t){const n=i.name,s=n.length;for(tl.lastIndex=0;;){const r=tl.exec(n),a=tl.lastIndex;let o=r[1];const l=r[2]==="]",c=r[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===s){zu(t,c===void 0?new Zv(o,i,e):new Jv(o,i,e));break}else{let u=t.map[o];u===void 0&&(u=new Qv(o),zu(t,u)),t=u}}}class Ha{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),l=e.getUniformLocation(t,o.name);jv(o,l,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],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.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 e_=37297;let t_=0;function n_(i,e){const t=i.split(`
4655
+ }`,depthTest:!1,depthWrite:!1}),h=new Je(l,c),u=new er(-1,1,1,-1,0,1);let d=null,f=null,g=!1,_,m=null,p=[],E=!1;this.setSize=function(A,M){a.setSize(A,M),o.setSize(A,M);for(let S=0;S<p.length;S++){const w=p[S];w.setSize&&w.setSize(A,M)}},this.setEffects=function(A){p=A,E=p.length>0&&p[0].isRenderPass===!0;const M=a.width,S=a.height;for(let w=0;w<p.length;w++){const R=p[w];R.setSize&&R.setSize(M,S)}},this.begin=function(A,M){if(g||A.toneMapping===$n&&p.length===0)return!1;if(m=M,M!==null){const S=M.width,w=M.height;(a.width!==S||a.height!==w)&&this.setSize(S,w)}return E===!1&&A.setRenderTarget(a),_=A.toneMapping,A.toneMapping=$n,!0},this.hasRenderPass=function(){return E},this.end=function(A,M){A.toneMapping=_,g=!0;let S=a,w=o;for(let R=0;R<p.length;R++){const x=p[R];if(x.enabled!==!1&&(x.render(A,w,S,M),x.needsSwap!==!1)){const b=S;S=w,w=b}}if(d!==A.outputColorSpace||f!==A.toneMapping){d=A.outputColorSpace,f=A.toneMapping,c.defines={},Ke.getTransfer(d)===tt&&(c.defines.SRGB_TRANSFER="");const R=uv[f];R&&(c.defines[R]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=S.texture,A.setRenderTarget(m),A.render(h,u),m=null,g=!1},this.isCompositing=function(){return g},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),l.dispose(),c.dispose()}}const X0=new Kt,bc=new ss(1,1),q0=new D0,Y0=new Dm,K0=new F0,zu=[],Bu=[],ku=new Float32Array(16),Hu=new Float32Array(9),Gu=new Float32Array(4);function tr(i,e,t){const n=i[0];if(n<=0||n>0)return i;const s=e*t;let r=zu[s];if(r===void 0&&(r=new Float32Array(s),zu[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 Lt(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 Nt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function xo(i,e){let t=Bu[e];t===void 0&&(t=new Int32Array(e),Bu[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function fv(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function pv(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(Lt(t,e))return;i.uniform2fv(this.addr,e),Nt(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)&&(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(Lt(t,e))return;i.uniform3fv(this.addr,e),Nt(t,e)}}function gv(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(Lt(t,e))return;i.uniform4fv(this.addr,e),Nt(t,e)}}function vv(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(Lt(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),Nt(t,e)}else{if(Lt(t,n))return;Gu.set(n),i.uniformMatrix2fv(this.addr,!1,Gu),Nt(t,n)}}function xv(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(Lt(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),Nt(t,e)}else{if(Lt(t,n))return;Hu.set(n),i.uniformMatrix3fv(this.addr,!1,Hu),Nt(t,n)}}function _v(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(Lt(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),Nt(t,e)}else{if(Lt(t,n))return;ku.set(n),i.uniformMatrix4fv(this.addr,!1,ku),Nt(t,n)}}function Mv(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function yv(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(Lt(t,e))return;i.uniform2iv(this.addr,e),Nt(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)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Lt(t,e))return;i.uniform3iv(this.addr,e),Nt(t,e)}}function bv(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(Lt(t,e))return;i.uniform4iv(this.addr,e),Nt(t,e)}}function Ev(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function wv(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(Lt(t,e))return;i.uniform2uiv(this.addr,e),Nt(t,e)}}function Av(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(Lt(t,e))return;i.uniform3uiv(this.addr,e),Nt(t,e)}}function Tv(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(Lt(t,e))return;i.uniform4uiv(this.addr,e),Nt(t,e)}}function Rv(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?(bc.compareFunction=t.isReversedDepthBuffer()?lh:oh,r=bc):r=X0,t.setTexture2D(e||r,s)}function Cv(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||Y0,s)}function Dv(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 Pv(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||q0,s)}function Iv(i){switch(i){case 5126:return fv;case 35664:return pv;case 35665:return mv;case 35666:return gv;case 35674:return vv;case 35675:return xv;case 35676:return _v;case 5124:case 35670:return Mv;case 35667:case 35671:return yv;case 35668:case 35672:return Sv;case 35669:case 35673:return bv;case 5125:return Ev;case 36294:return wv;case 36295:return Av;case 36296:return Tv;case 35678:case 36198:case 36298:case 36306:case 35682:return Rv;case 35679:case 36299:case 36307:return Cv;case 35680:case 36300:case 36308:case 36293:return Dv;case 36289:case 36303:case 36311:case 36292:return Pv}}function Lv(i,e){i.uniform1fv(this.addr,e)}function Nv(i,e){const t=tr(e,this.size,2);i.uniform2fv(this.addr,t)}function Uv(i,e){const t=tr(e,this.size,3);i.uniform3fv(this.addr,t)}function Fv(i,e){const t=tr(e,this.size,4);i.uniform4fv(this.addr,t)}function Ov(i,e){const t=tr(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function zv(i,e){const t=tr(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function Bv(i,e){const t=tr(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function kv(i,e){i.uniform1iv(this.addr,e)}function Hv(i,e){i.uniform2iv(this.addr,e)}function Gv(i,e){i.uniform3iv(this.addr,e)}function Vv(i,e){i.uniform4iv(this.addr,e)}function Wv(i,e){i.uniform1uiv(this.addr,e)}function Xv(i,e){i.uniform2uiv(this.addr,e)}function qv(i,e){i.uniform3uiv(this.addr,e)}function Yv(i,e){i.uniform4uiv(this.addr,e)}function Kv(i,e,t){const n=this.cache,s=e.length,r=xo(t,s);Lt(n,r)||(i.uniform1iv(this.addr,r),Nt(n,r));let a;this.type===i.SAMPLER_2D_SHADOW?a=bc:a=X0;for(let o=0;o!==s;++o)t.setTexture2D(e[o]||a,r[o])}function $v(i,e,t){const n=this.cache,s=e.length,r=xo(t,s);Lt(n,r)||(i.uniform1iv(this.addr,r),Nt(n,r));for(let a=0;a!==s;++a)t.setTexture3D(e[a]||Y0,r[a])}function Zv(i,e,t){const n=this.cache,s=e.length,r=xo(t,s);Lt(n,r)||(i.uniform1iv(this.addr,r),Nt(n,r));for(let a=0;a!==s;++a)t.setTextureCube(e[a]||K0,r[a])}function Jv(i,e,t){const n=this.cache,s=e.length,r=xo(t,s);Lt(n,r)||(i.uniform1iv(this.addr,r),Nt(n,r));for(let a=0;a!==s;++a)t.setTexture2DArray(e[a]||q0,r[a])}function Qv(i){switch(i){case 5126:return Lv;case 35664:return Nv;case 35665:return Uv;case 35666:return Fv;case 35674:return Ov;case 35675:return zv;case 35676:return Bv;case 5124:case 35670:return kv;case 35667:case 35671:return Hv;case 35668:case 35672:return Gv;case 35669:case 35673:return Vv;case 5125:return Wv;case 36294:return Xv;case 36295:return qv;case 36296:return Yv;case 35678:case 36198:case 36298:case 36306:case 35682:return Kv;case 35679:case 36299:case 36307:return $v;case 35680:case 36300:case 36308:case 36293:return Zv;case 36289:case 36303:case 36311:case 36292:return Jv}}class jv{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Iv(t.type)}}class ex{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Qv(t.type)}}class tx{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 sl=/(\w+)(\])?(\[|\.)?/g;function Vu(i,e){i.seq.push(e),i.map[e.id]=e}function nx(i,e,t){const n=i.name,s=n.length;for(sl.lastIndex=0;;){const r=sl.exec(n),a=sl.lastIndex;let o=r[1];const l=r[2]==="]",c=r[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===s){Vu(t,c===void 0?new jv(o,i,e):new ex(o,i,e));break}else{let u=t.map[o];u===void 0&&(u=new tx(o),Vu(t,u)),t=u}}}class Wa{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),l=e.getUniformLocation(t,o.name);nx(o,l,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],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.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 Wu(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const ix=37297;let sx=0;function rx(i,e){const t=i.split(`
4656
4656
  `),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(`
4657
- `)}const ku=new ze;function i_(i){Ke._getMatrix(ku,Ke.workingColorSpace,i);const e=`mat3( ${ku.elements.map(t=>t.toFixed(4))} )`;switch(Ke.getTransfer(i)){case $a:return[e,"LinearTransferOETF"];case et:return[e,"sRGBTransferOETF"];default:return Oe("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function Hu(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()+`
4657
+ `)}const Xu=new ze;function ax(i){Ke._getMatrix(Xu,Ke.workingColorSpace,i);const e=`mat3( ${Xu.elements.map(t=>t.toFixed(4))} )`;switch(Ke.getTransfer(i)){case Ja:return[e,"LinearTransferOETF"];case tt:return[e,"sRGBTransferOETF"];default:return Oe("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function qu(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()+`
4658
4658
 
4659
4659
  `+r+`
4660
4660
 
4661
- `+n_(i.getShaderSource(e),o)}else return r}function s_(i,e){const t=i_(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
4662
- `)}const r_={[c0]:"Linear",[h0]:"Reinhard",[u0]:"Cineon",[d0]:"ACESFilmic",[p0]:"AgX",[m0]:"Neutral",[f0]:"Custom"};function a_(i,e){const t=r_[e];return t===void 0?(Oe("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const _a=new U;function o_(){Ke.getLuminanceCoefficients(_a);const i=_a.x.toFixed(4),e=_a.y.toFixed(4),t=_a.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
4663
- `)}function l_(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(mr).join(`
4664
- `)}function c_(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
4665
- `)}function h_(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 mr(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 u_=/^[ \t]*#include +<([\w\d./]+)>/gm;function yc(i){return i.replace(u_,f_)}const d_=new Map;function f_(i,e){let t=Ve[e];if(t===void 0){const n=d_.get(e);if(n!==void 0)t=Ve[n],Oe('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return yc(t)}const p_=/#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(p_,m_)}function m_(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;
4661
+ `+rx(i.getShaderSource(e),o)}else return r}function ox(i,e){const t=ax(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
4662
+ `)}const lx={[p0]:"Linear",[m0]:"Reinhard",[g0]:"Cineon",[v0]:"ACESFilmic",[_0]:"AgX",[M0]:"Neutral",[x0]:"Custom"};function cx(i,e){const t=lx[e];return t===void 0?(Oe("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const ya=new U;function hx(){Ke.getLuminanceCoefficients(ya);const i=ya.x.toFixed(4),e=ya.y.toFixed(4),t=ya.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
4663
+ `)}function ux(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(xr).join(`
4664
+ `)}function dx(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
4665
+ `)}function fx(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 xr(i){return i!==""}function Yu(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 Ku(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const px=/^[ \t]*#include +<([\w\d./]+)>/gm;function Ec(i){return i.replace(px,gx)}const mx=new Map;function gx(i,e){let t=Ve[e];if(t===void 0){const n=mx.get(e);if(n!==void 0)t=Ve[n],Oe('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Ec(t)}const vx=/#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 $u(i){return i.replace(vx,xx)}function xx(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 Zu(i){let e=`precision ${i.precision} float;
4666
4666
  precision ${i.precision} int;
4667
4667
  precision ${i.precision} sampler2D;
4668
4668
  precision ${i.precision} samplerCube;
@@ -4682,30 +4682,30 @@ void main() {
4682
4682
  `;return i.precision==="highp"?e+=`
4683
4683
  #define HIGH_PRECISION`:i.precision==="mediump"?e+=`
4684
4684
  #define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
4685
- #define LOW_PRECISION`),e}const g_={[Mr]:"SHADOWMAP_TYPE_PCF",[fr]:"SHADOWMAP_TYPE_VSM"};function v_(i){return g_[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const __={[Qi]:"ENVMAP_TYPE_CUBE",[Ks]:"ENVMAP_TYPE_CUBE",[ho]:"ENVMAP_TYPE_CUBE_UV"};function x_(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":__[i.envMapMode]||"ENVMAP_TYPE_CUBE"}const M_={[Ks]:"ENVMAP_MODE_REFRACTION"};function y_(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":M_[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}const S_={[Zc]:"ENVMAP_BLENDING_MULTIPLY",[am]:"ENVMAP_BLENDING_MIX",[om]:"ENVMAP_BLENDING_ADD"};function b_(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":S_[i.combine]||"ENVMAP_BLENDING_NONE"}function E_(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 w_(i,e,t,n){const s=i.getContext(),r=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=v_(t),c=x_(t),h=y_(t),u=b_(t),d=E_(t),f=l_(t),g=c_(r),x=s.createProgram();let m,p,E=t.glslVersion?"#version "+t.glslVersion+`
4686
- `:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(mr).join(`
4685
+ #define LOW_PRECISION`),e}const _x={[br]:"SHADOWMAP_TYPE_PCF",[gr]:"SHADOWMAP_TYPE_VSM"};function Mx(i){return _x[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const yx={[ts]:"ENVMAP_TYPE_CUBE",[Zs]:"ENVMAP_TYPE_CUBE",[fo]:"ENVMAP_TYPE_CUBE_UV"};function Sx(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":yx[i.envMapMode]||"ENVMAP_TYPE_CUBE"}const bx={[Zs]:"ENVMAP_MODE_REFRACTION"};function Ex(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":bx[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}const wx={[eh]:"ENVMAP_BLENDING_MULTIPLY",[cm]:"ENVMAP_BLENDING_MIX",[hm]:"ENVMAP_BLENDING_ADD"};function Ax(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":wx[i.combine]||"ENVMAP_BLENDING_NONE"}function Tx(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 Rx(i,e,t,n){const s=i.getContext(),r=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=Mx(t),c=Sx(t),h=Ex(t),u=Ax(t),d=Tx(t),f=ux(t),g=dx(r),_=s.createProgram();let m,p,E=t.glslVersion?"#version "+t.glslVersion+`
4686
+ `:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(xr).join(`
4687
4687
  `),m.length>0&&(m+=`
4688
- `),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(mr).join(`
4688
+ `),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(xr).join(`
4689
4689
  `),p.length>0&&(p+=`
4690
- `)):(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 "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
4691
- `].filter(mr).join(`
4692
- `),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 "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Kn?"#define TONE_MAPPING":"",t.toneMapping!==Kn?Ve.tonemapping_pars_fragment:"",t.toneMapping!==Kn?a_("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ve.colorspace_pars_fragment,s_("linearToOutputTexel",t.outputColorSpace),o_(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
4693
- `].filter(mr).join(`
4694
- `)),a=yc(a),a=Gu(a,t),a=Vu(a,t),o=yc(o),o=Gu(o,t),o=Vu(o,t),a=Wu(a),o=Wu(o),t.isRawShaderMaterial!==!0&&(E=`#version 300 es
4690
+ `)):(m=[Zu(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
4691
+ `].filter(xr).join(`
4692
+ `),p=[Zu(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==$n?"#define TONE_MAPPING":"",t.toneMapping!==$n?Ve.tonemapping_pars_fragment:"",t.toneMapping!==$n?cx("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ve.colorspace_pars_fragment,ox("linearToOutputTexel",t.outputColorSpace),hx(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
4693
+ `].filter(xr).join(`
4694
+ `)),a=Ec(a),a=Yu(a,t),a=Ku(a,t),o=Ec(o),o=Yu(o,t),o=Ku(o,t),a=$u(a),o=$u(o),t.isRawShaderMaterial!==!0&&(E=`#version 300 es
4695
4695
  `,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
4696
4696
  `)+`
4697
- `+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(`
4697
+ `+m,p=["#define varying in",t.glslVersion===su?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===su?"":"#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(`
4698
4698
  `)+`
4699
- `+p);const A=E+m+a,M=E+p+o,S=Bu(s,s.VERTEX_SHADER,A),w=Bu(s,s.FRAGMENT_SHADER,M);s.attachShader(x,S),s.attachShader(x,w),t.index0AttributeName!==void 0?s.bindAttribLocation(x,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(x,0,"position"),s.linkProgram(x);function R(C){if(i.debug.checkShaderErrors){const I=s.getProgramInfoLog(x)||"",W=s.getShaderInfoLog(S)||"",X=s.getShaderInfoLog(w)||"",F=I.trim(),q=W.trim(),G=X.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,w);else{const j=Hu(s,S,"vertex"),ie=Hu(s,w,"fragment");Ye("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(x,s.VALIDATE_STATUS)+`
4699
+ `+p);const A=E+m+a,M=E+p+o,S=Wu(s,s.VERTEX_SHADER,A),w=Wu(s,s.FRAGMENT_SHADER,M);s.attachShader(_,S),s.attachShader(_,w),t.index0AttributeName!==void 0?s.bindAttribLocation(_,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function R(C){if(i.debug.checkShaderErrors){const I=s.getProgramInfoLog(_)||"",W=s.getShaderInfoLog(S)||"",X=s.getShaderInfoLog(w)||"",F=I.trim(),q=W.trim(),G=X.trim();let Z=!0,te=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(Z=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,_,S,w);else{const j=qu(s,S,"vertex"),ie=qu(s,w,"fragment");Ye("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+`
4700
4700
 
4701
4701
  Material Name: `+C.name+`
4702
4702
  Material Type: `+C.type+`
4703
4703
 
4704
4704
  Program Info Log: `+F+`
4705
4705
  `+j+`
4706
- `+ie)}else F!==""?Oe("WebGLProgram: Program Info Log:",F):(q===""||G==="")&&(te=!1);te&&(C.diagnostics={runnable:Z,programLog:F,vertexShader:{log:q,prefix:m},fragmentShader:{log:G,prefix:p}})}s.deleteShader(S),s.deleteShader(w),_=new Ha(s,x),b=h_(s,x)}let _;this.getUniforms=function(){return _===void 0&&R(this),_};let b;this.getAttributes=function(){return b===void 0&&R(this),b};let D=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=s.getProgramParameter(x,e_)),D},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(x),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=t_++,this.cacheKey=e,this.usedTimes=1,this.program=x,this.vertexShader=S,this.fragmentShader=w,this}let A_=0;class T_{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 R_(e),t.set(e,n)),n}}class R_{constructor(e){this.id=A_++,this.code=e,this.usedTimes=0}}function C_(i){return i===ji||i===qa||i===Ya}function D_(i,e,t,n,s,r){const a=new ah,o=new T_,l=new Set,c=[],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 l.add(_),_===0?"uv":`uv${_}`}function x(_,b,D,C,I,W){const X=C.fog,F=I.geometry,q=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?C.environment:null,G=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,Z=e.get(_.envMap||q,G),te=Z&&Z.mapping===ho?Z.image.height:null,j=f[_.type];_.precision!==null&&(d=n.getMaxPrecision(_.precision),d!==_.precision&&Oe("WebGLProgram.getParameters:",_.precision,"not supported, using",d,"instead."));const ie=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,ue=ie!==void 0?ie.length:0;let ke=0;F.morphAttributes.position!==void 0&&(ke=1),F.morphAttributes.normal!==void 0&&(ke=2),F.morphAttributes.color!==void 0&&(ke=3);let qe,Be,Y,re;if(j){const ye=Bn[j];qe=ye.vertexShader,Be=ye.fragmentShader}else{qe=_.vertexShader,Be=_.fragmentShader;const ye=o.getVertexShaderStage(_),vt=o.getFragmentShaderStage(_);o.update(_,ye,vt),Y=ye.id,re=vt.id}const ne=i.getRenderTarget(),z=i.state.buffers.depth.getReversed(),Ee=I.isInstancedMesh===!0,De=I.isBatchedMesh===!0,Ae=!!_.map,_e=!!_.matcap,Ie=!!Z,Ne=!!_.aoMap,Ue=!!_.lightMap,Je=!!_.bumpMap&&_.wireframe===!1,Qe=!!_.normalMap,mt=!!_.displacementMap,dt=!!_.emissiveMap,gt=!!_.metalnessMap,Et=!!_.roughnessMap,L=_.anisotropy>0,jt=_.clearcoat>0,je=_.dispersion>0,T=_.iridescence>0,v=_.sheen>0,O=_.transmission>0,H=L&&!!_.anisotropyMap,K=jt&&!!_.clearcoatMap,se=jt&&!!_.clearcoatNormalMap,oe=jt&&!!_.clearcoatRoughnessMap,$=T&&!!_.iridescenceMap,Q=T&&!!_.iridescenceThicknessMap,le=v&&!!_.sheenColorMap,Te=v&&!!_.sheenRoughnessMap,de=!!_.specularMap,ce=!!_.specularColorMap,Pe=!!_.specularIntensityMap,Fe=O&&!!_.transmissionMap,He=O&&!!_.thicknessMap,P=!!_.gradientMap,ae=!!_.alphaMap,J=_.alphaTest>0,he=!!_.alphaHash,ge=!!_.extensions;let ee=Kn;_.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(ee=i.toneMapping);const we={shaderID:j,shaderType:_.type,shaderName:_.name,vertexShader:qe,fragmentShader:Be,defines:_.defines,customVertexShaderID:Y,customFragmentShaderID:re,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:d,batching:De,batchingColor:De&&I._colorsTexture!==null,instancing:Ee,instancingColor:Ee&&I.instanceColor!==null,instancingMorph:Ee&&I.morphTexture!==null,outputColorSpace:ne===null?i.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:Ke.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:Ae,matcap:_e,envMap:Ie,envMapMode:Ie&&Z.mapping,envMapCubeUVHeight:te,aoMap:Ne,lightMap:Ue,bumpMap:Je,normalMap:Qe,displacementMap:mt,emissiveMap:dt,normalMapObjectSpace:Qe&&_.normalMapType===hm,normalMapTangentSpace:Qe&&_.normalMapType===mc,packedNormalMap:Qe&&_.normalMapType===mc&&C_(_.normalMap.format),metalnessMap:gt,roughnessMap:Et,anisotropy:L,anisotropyMap:H,clearcoat:jt,clearcoatMap:K,clearcoatNormalMap:se,clearcoatRoughnessMap:oe,dispersion:je,iridescence:T,iridescenceMap:$,iridescenceThicknessMap:Q,sheen:v,sheenColorMap:le,sheenRoughnessMap:Te,specularMap:de,specularColorMap:ce,specularIntensityMap:Pe,transmission:O,transmissionMap:Fe,thicknessMap:He,gradientMap:P,opaque:_.transparent===!1&&_.blending===Bs&&_.alphaToCoverage===!1,alphaMap:ae,alphaTest:J,alphaHash:he,combine:_.combine,mapUv:Ae&&g(_.map.channel),aoMapUv:Ne&&g(_.aoMap.channel),lightMapUv:Ue&&g(_.lightMap.channel),bumpMapUv:Je&&g(_.bumpMap.channel),normalMapUv:Qe&&g(_.normalMap.channel),displacementMapUv:mt&&g(_.displacementMap.channel),emissiveMapUv:dt&&g(_.emissiveMap.channel),metalnessMapUv:gt&&g(_.metalnessMap.channel),roughnessMapUv:Et&&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:le&&g(_.sheenColorMap.channel),sheenRoughnessMapUv:Te&&g(_.sheenRoughnessMap.channel),specularMapUv:de&&g(_.specularMap.channel),specularColorMapUv:ce&&g(_.specularColorMap.channel),specularIntensityMapUv:Pe&&g(_.specularIntensityMap.channel),transmissionMapUv:Fe&&g(_.transmissionMap.channel),thicknessMapUv:He&&g(_.thicknessMap.channel),alphaMapUv:ae&&g(_.alphaMap.channel),vertexTangents:!!F.attributes.tangent&&(Qe||L),vertexNormals:!!F.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!F.attributes.uv&&(Ae||ae),fog:!!X,useFog:_.fog===!0,fogExp2:!!X&&X.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||F.attributes.normal===void 0&&Qe===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:z,skinning:I.isSkinnedMesh===!0,hasPositionAttribute:F.attributes.position!==void 0,morphTargets:F.morphAttributes.position!==void 0,morphNormals:F.morphAttributes.normal!==void 0,morphColors:F.morphAttributes.color!==void 0,morphTargetsCount:ue,morphTextureStride:ke,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numLightProbeGrids:W.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:_.dithering,shadowMapEnabled:i.shadowMap.enabled&&D.length>0,shadowMapType:i.shadowMap.type,toneMapping:ee,decodeVideoTexture:Ae&&_.map.isVideoTexture===!0&&Ke.getTransfer(_.map.colorSpace)===et,decodeVideoTextureEmissive:dt&&_.emissiveMap.isVideoTexture===!0&&Ke.getTransfer(_.emissiveMap.colorSpace)===et,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===Tn,flipSided:_.side===Dt,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:ge&&_.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ge&&_.extensions.multiDraw===!0||De)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return we.vertexUv1s=l.has(1),we.vertexUv2s=l.has(2),we.vertexUv3s=l.has(3),l.clear(),we}function m(_){const b=[];if(_.shaderID?b.push(_.shaderID):(b.push(_.customVertexShaderID),b.push(_.customFragmentShaderID)),_.defines!==void 0)for(const D in _.defines)b.push(D),b.push(_.defines[D]);return _.isRawShaderMaterial===!1&&(p(b,_),E(b,_),b.push(i.outputColorSpace)),b.push(_.customProgramCacheKey),b.join()}function p(_,b){_.push(b.precision),_.push(b.outputColorSpace),_.push(b.envMapMode),_.push(b.envMapCubeUVHeight),_.push(b.mapUv),_.push(b.alphaMapUv),_.push(b.lightMapUv),_.push(b.aoMapUv),_.push(b.bumpMapUv),_.push(b.normalMapUv),_.push(b.displacementMapUv),_.push(b.emissiveMapUv),_.push(b.metalnessMapUv),_.push(b.roughnessMapUv),_.push(b.anisotropyMapUv),_.push(b.clearcoatMapUv),_.push(b.clearcoatNormalMapUv),_.push(b.clearcoatRoughnessMapUv),_.push(b.iridescenceMapUv),_.push(b.iridescenceThicknessMapUv),_.push(b.sheenColorMapUv),_.push(b.sheenRoughnessMapUv),_.push(b.specularMapUv),_.push(b.specularColorMapUv),_.push(b.specularIntensityMapUv),_.push(b.transmissionMapUv),_.push(b.thicknessMapUv),_.push(b.combine),_.push(b.fogExp2),_.push(b.sizeAttenuation),_.push(b.morphTargetsCount),_.push(b.morphAttributeCount),_.push(b.numDirLights),_.push(b.numPointLights),_.push(b.numSpotLights),_.push(b.numSpotLightMaps),_.push(b.numHemiLights),_.push(b.numRectAreaLights),_.push(b.numDirLightShadows),_.push(b.numPointLightShadows),_.push(b.numSpotLightShadows),_.push(b.numSpotLightShadowsWithMaps),_.push(b.numLightProbes),_.push(b.shadowMapType),_.push(b.toneMapping),_.push(b.numClippingPlanes),_.push(b.numClipIntersection),_.push(b.depthPacking)}function E(_,b){a.disableAll(),b.instancing&&a.enable(0),b.instancingColor&&a.enable(1),b.instancingMorph&&a.enable(2),b.matcap&&a.enable(3),b.envMap&&a.enable(4),b.normalMapObjectSpace&&a.enable(5),b.normalMapTangentSpace&&a.enable(6),b.clearcoat&&a.enable(7),b.iridescence&&a.enable(8),b.alphaTest&&a.enable(9),b.vertexColors&&a.enable(10),b.vertexAlphas&&a.enable(11),b.vertexUv1s&&a.enable(12),b.vertexUv2s&&a.enable(13),b.vertexUv3s&&a.enable(14),b.vertexTangents&&a.enable(15),b.anisotropy&&a.enable(16),b.alphaHash&&a.enable(17),b.batching&&a.enable(18),b.dispersion&&a.enable(19),b.batchingColor&&a.enable(20),b.gradientMap&&a.enable(21),b.packedNormalMap&&a.enable(22),b.vertexNormals&&a.enable(23),_.push(a.mask),a.disableAll(),b.fog&&a.enable(0),b.useFog&&a.enable(1),b.flatShading&&a.enable(2),b.logarithmicDepthBuffer&&a.enable(3),b.reversedDepthBuffer&&a.enable(4),b.skinning&&a.enable(5),b.morphTargets&&a.enable(6),b.morphNormals&&a.enable(7),b.morphColors&&a.enable(8),b.premultipliedAlpha&&a.enable(9),b.shadowMapEnabled&&a.enable(10),b.doubleSided&&a.enable(11),b.flipSided&&a.enable(12),b.useDepthPacking&&a.enable(13),b.dithering&&a.enable(14),b.transmission&&a.enable(15),b.sheen&&a.enable(16),b.opaque&&a.enable(17),b.pointsUvs&&a.enable(18),b.decodeVideoTexture&&a.enable(19),b.decodeVideoTextureEmissive&&a.enable(20),b.alphaToCoverage&&a.enable(21),b.numLightProbeGrids>0&&a.enable(22),b.hasPositionAttribute&&a.enable(23),_.push(a.mask)}function A(_){const b=f[_.type];let D;if(b){const C=Bn[b];D=$m.clone(C.uniforms)}else D=_.uniforms;return D}function M(_,b){let D=h.get(b);return D!==void 0?++D.usedTimes:(D=new w_(i,b,_,s),c.push(D),h.set(b,D)),D}function S(_){if(--_.usedTimes===0){const b=c.indexOf(_);c[b]=c[c.length-1],c.pop(),h.delete(_.cacheKey),_.destroy()}}function w(_){o.remove(_)}function R(){o.dispose()}return{getParameters:x,getProgramCacheKey:m,getUniforms:A,acquireProgram:M,releaseProgram:S,releaseShaderCache:w,programs:c,dispose:R}}function P_(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,l){i.get(a)[o]=l}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function I_(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 E=i[e];return E===void 0?(E={id:d.id,object:d,geometry:f,material:g,materialVariant:a(d),groupOrder:x,renderOrder:d.renderOrder,z:m,group:p},i[e]=E):(E.id=d.id,E.object=d,E.geometry=f,E.material=g,E.materialVariant=a(d),E.groupOrder=x,E.renderOrder=d.renderOrder,E.z=m,E.group=p),e++,E}function l(d,f,g,x,m,p){const E=o(d,f,g,x,m,p);g.transmission>0?n.push(E):g.transparent===!0?s.push(E):t.push(E)}function c(d,f,g,x,m,p){const E=o(d,f,g,x,m,p);g.transmission>0?n.unshift(E):g.transparent===!0?s.unshift(E):t.unshift(E)}function h(d,f,g){t.length>1&&t.sort(d||I_),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:l,unshift:c,finish:u,sort:h}}function L_(){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 N_(){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 U,color:new Me};break;case"SpotLight":t={position:new U,direction:new U,color:new Me,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new U,color:new Me,distance:0,decay:0};break;case"HemisphereLight":t={direction:new U,skyColor:new Me,groundColor:new Me};break;case"RectAreaLight":t={color:new Me,position:new U,halfWidth:new U,halfHeight:new U};break}return i[e.id]=t,t}}}function U_(){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 F_=0;function O_(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function z_(i){const e=new N_,t=U_(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new U);const s=new U,r=new ht,a=new ht;function o(c){let h=0,u=0,d=0;for(let b=0;b<9;b++)n.probe[b].set(0,0,0);let f=0,g=0,x=0,m=0,p=0,E=0,A=0,M=0,S=0,w=0,R=0;c.sort(O_);for(let b=0,D=c.length;b<D;b++){const C=c[b],I=C.color,W=C.intensity,X=C.distance;let F=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===ji?F=C.shadow.map.texture:F=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)h+=I.r*W,u+=I.g*W,d+=I.b*W;else if(C.isLightProbe){for(let q=0;q<9;q++)n.probe[q].addScaledVector(C.sh.coefficients[q],W);R++}else if(C.isDirectionalLight){const q=e.get(C);if(q.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){const G=C.shadow,Z=t.get(C);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]=F,n.directionalShadowMatrix[f]=C.shadow.matrix,E++}n.directional[f]=q,f++}else if(C.isSpotLight){const q=e.get(C);q.position.setFromMatrixPosition(C.matrixWorld),q.color.copy(I).multiplyScalar(W),q.distance=X,q.coneCos=Math.cos(C.angle),q.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),q.decay=C.decay,n.spot[x]=q;const G=C.shadow;if(C.map&&(n.spotLightMap[S]=C.map,S++,G.updateMatrices(C),C.castShadow&&w++),n.spotLightMatrix[x]=G.matrix,C.castShadow){const Z=t.get(C);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]=F,M++}x++}else if(C.isRectAreaLight){const q=e.get(C);q.color.copy(I).multiplyScalar(W),q.halfWidth.set(C.width*.5,0,0),q.halfHeight.set(0,C.height*.5,0),n.rectArea[m]=q,m++}else if(C.isPointLight){const q=e.get(C);if(q.color.copy(C.color).multiplyScalar(C.intensity),q.distance=C.distance,q.decay=C.decay,C.castShadow){const G=C.shadow,Z=t.get(C);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]=F,n.pointShadowMatrix[g]=C.shadow.matrix,A++}n.point[g]=q,g++}else if(C.isHemisphereLight){const q=e.get(C);q.skyColor.copy(C.color).multiplyScalar(W),q.groundColor.copy(C.groundColor).multiplyScalar(W),n.hemi[p]=q,p++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=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!==E||_.numPointShadows!==A||_.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=E,n.directionalShadowMap.length=E,n.pointShadow.length=A,n.pointShadowMap.length=A,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=E,n.pointShadowMatrix.length=A,n.spotLightMatrix.length=M+S-w,n.spotLightMap.length=S,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=R,_.directionalLength=f,_.pointLength=g,_.spotLength=x,_.rectAreaLength=m,_.hemiLength=p,_.numDirectionalShadows=E,_.numPointShadows=A,_.numSpotShadows=M,_.numSpotMaps=S,_.numLightProbes=R,n.version=F_++)}function l(c,h){let u=0,d=0,f=0,g=0,x=0;const m=h.matrixWorldInverse;for(let p=0,E=c.length;p<E;p++){const A=c[p];if(A.isDirectionalLight){const M=n.directional[u];M.direction.setFromMatrixPosition(A.matrixWorld),s.setFromMatrixPosition(A.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),u++}else if(A.isSpotLight){const M=n.spot[f];M.position.setFromMatrixPosition(A.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(A.matrixWorld),s.setFromMatrixPosition(A.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),f++}else if(A.isRectAreaLight){const M=n.rectArea[g];M.position.setFromMatrixPosition(A.matrixWorld),M.position.applyMatrix4(m),a.identity(),r.copy(A.matrixWorld),r.premultiply(m),a.extractRotation(r),M.halfWidth.set(A.width*.5,0,0),M.halfHeight.set(0,A.height*.5,0),M.halfWidth.applyMatrix4(a),M.halfHeight.applyMatrix4(a),g++}else if(A.isPointLight){const M=n.point[d];M.position.setFromMatrixPosition(A.matrixWorld),M.position.applyMatrix4(m),d++}else if(A.isHemisphereLight){const M=n.hemi[x];M.direction.setFromMatrixPosition(A.matrixWorld),M.direction.transformDirection(m),x++}}}return{setup:o,setupView:l,state:n}}function Ku(i){const e=new z_(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 l(d){s.push(d)}function c(){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:c,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:l}}function B_(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 k_=`void main() {
4706
+ `+ie)}else F!==""?Oe("WebGLProgram: Program Info Log:",F):(q===""||G==="")&&(te=!1);te&&(C.diagnostics={runnable:Z,programLog:F,vertexShader:{log:q,prefix:m},fragmentShader:{log:G,prefix:p}})}s.deleteShader(S),s.deleteShader(w),x=new Wa(s,_),b=fx(s,_)}let x;this.getUniforms=function(){return x===void 0&&R(this),x};let b;this.getAttributes=function(){return b===void 0&&R(this),b};let D=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=s.getProgramParameter(_,ix)),D},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=sx++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=S,this.fragmentShader=w,this}let Cx=0;class Dx{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 Px(e),t.set(e,n)),n}}class Px{constructor(e){this.id=Cx++,this.code=e,this.usedTimes=0}}function Ix(i){return i===ns||i===Ka||i===$a}function Lx(i,e,t,n,s,r){const a=new hh,o=new Dx,l=new Set,c=[],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(x){return l.add(x),x===0?"uv":`uv${x}`}function _(x,b,D,C,I,W){const X=C.fog,F=I.geometry,q=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?C.environment:null,G=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,Z=e.get(x.envMap||q,G),te=Z&&Z.mapping===fo?Z.image.height:null,j=f[x.type];x.precision!==null&&(d=n.getMaxPrecision(x.precision),d!==x.precision&&Oe("WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead."));const ie=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,ue=ie!==void 0?ie.length:0;let ke=0;F.morphAttributes.position!==void 0&&(ke=1),F.morphAttributes.normal!==void 0&&(ke=2),F.morphAttributes.color!==void 0&&(ke=3);let qe,Be,Y,re;if(j){const ye=Bn[j];qe=ye.vertexShader,Be=ye.fragmentShader}else{qe=x.vertexShader,Be=x.fragmentShader;const ye=o.getVertexShaderStage(x),vt=o.getFragmentShaderStage(x);o.update(x,ye,vt),Y=ye.id,re=vt.id}const ne=i.getRenderTarget(),z=i.state.buffers.depth.getReversed(),Ee=I.isInstancedMesh===!0,De=I.isBatchedMesh===!0,Ae=!!x.map,xe=!!x.matcap,Ie=!!Z,Ne=!!x.aoMap,Ue=!!x.lightMap,Qe=!!x.bumpMap&&x.wireframe===!1,je=!!x.normalMap,mt=!!x.displacementMap,dt=!!x.emissiveMap,gt=!!x.metalnessMap,wt=!!x.roughnessMap,L=x.anisotropy>0,en=x.clearcoat>0,et=x.dispersion>0,T=x.iridescence>0,v=x.sheen>0,O=x.transmission>0,H=L&&!!x.anisotropyMap,K=en&&!!x.clearcoatMap,se=en&&!!x.clearcoatNormalMap,oe=en&&!!x.clearcoatRoughnessMap,$=T&&!!x.iridescenceMap,Q=T&&!!x.iridescenceThicknessMap,le=v&&!!x.sheenColorMap,Te=v&&!!x.sheenRoughnessMap,de=!!x.specularMap,ce=!!x.specularColorMap,Pe=!!x.specularIntensityMap,Fe=O&&!!x.transmissionMap,He=O&&!!x.thicknessMap,P=!!x.gradientMap,ae=!!x.alphaMap,J=x.alphaTest>0,he=!!x.alphaHash,ge=!!x.extensions;let ee=$n;x.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(ee=i.toneMapping);const we={shaderID:j,shaderType:x.type,shaderName:x.name,vertexShader:qe,fragmentShader:Be,defines:x.defines,customVertexShaderID:Y,customFragmentShaderID:re,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,batching:De,batchingColor:De&&I._colorsTexture!==null,instancing:Ee,instancingColor:Ee&&I.instanceColor!==null,instancingMorph:Ee&&I.morphTexture!==null,outputColorSpace:ne===null?i.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:Ke.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Ae,matcap:xe,envMap:Ie,envMapMode:Ie&&Z.mapping,envMapCubeUVHeight:te,aoMap:Ne,lightMap:Ue,bumpMap:Qe,normalMap:je,displacementMap:mt,emissiveMap:dt,normalMapObjectSpace:je&&x.normalMapType===fm,normalMapTangentSpace:je&&x.normalMapType===xc,packedNormalMap:je&&x.normalMapType===xc&&Ix(x.normalMap.format),metalnessMap:gt,roughnessMap:wt,anisotropy:L,anisotropyMap:H,clearcoat:en,clearcoatMap:K,clearcoatNormalMap:se,clearcoatRoughnessMap:oe,dispersion:et,iridescence:T,iridescenceMap:$,iridescenceThicknessMap:Q,sheen:v,sheenColorMap:le,sheenRoughnessMap:Te,specularMap:de,specularColorMap:ce,specularIntensityMap:Pe,transmission:O,transmissionMap:Fe,thicknessMap:He,gradientMap:P,opaque:x.transparent===!1&&x.blending===Hs&&x.alphaToCoverage===!1,alphaMap:ae,alphaTest:J,alphaHash:he,combine:x.combine,mapUv:Ae&&g(x.map.channel),aoMapUv:Ne&&g(x.aoMap.channel),lightMapUv:Ue&&g(x.lightMap.channel),bumpMapUv:Qe&&g(x.bumpMap.channel),normalMapUv:je&&g(x.normalMap.channel),displacementMapUv:mt&&g(x.displacementMap.channel),emissiveMapUv:dt&&g(x.emissiveMap.channel),metalnessMapUv:gt&&g(x.metalnessMap.channel),roughnessMapUv:wt&&g(x.roughnessMap.channel),anisotropyMapUv:H&&g(x.anisotropyMap.channel),clearcoatMapUv:K&&g(x.clearcoatMap.channel),clearcoatNormalMapUv:se&&g(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:oe&&g(x.clearcoatRoughnessMap.channel),iridescenceMapUv:$&&g(x.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&g(x.iridescenceThicknessMap.channel),sheenColorMapUv:le&&g(x.sheenColorMap.channel),sheenRoughnessMapUv:Te&&g(x.sheenRoughnessMap.channel),specularMapUv:de&&g(x.specularMap.channel),specularColorMapUv:ce&&g(x.specularColorMap.channel),specularIntensityMapUv:Pe&&g(x.specularIntensityMap.channel),transmissionMapUv:Fe&&g(x.transmissionMap.channel),thicknessMapUv:He&&g(x.thicknessMap.channel),alphaMapUv:ae&&g(x.alphaMap.channel),vertexTangents:!!F.attributes.tangent&&(je||L),vertexNormals:!!F.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!F.attributes.uv&&(Ae||ae),fog:!!X,useFog:x.fog===!0,fogExp2:!!X&&X.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||F.attributes.normal===void 0&&je===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:z,skinning:I.isSkinnedMesh===!0,hasPositionAttribute:F.attributes.position!==void 0,morphTargets:F.morphAttributes.position!==void 0,morphNormals:F.morphAttributes.normal!==void 0,morphColors:F.morphAttributes.color!==void 0,morphTargetsCount:ue,morphTextureStride:ke,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numLightProbeGrids:W.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:x.dithering,shadowMapEnabled:i.shadowMap.enabled&&D.length>0,shadowMapType:i.shadowMap.type,toneMapping:ee,decodeVideoTexture:Ae&&x.map.isVideoTexture===!0&&Ke.getTransfer(x.map.colorSpace)===tt,decodeVideoTextureEmissive:dt&&x.emissiveMap.isVideoTexture===!0&&Ke.getTransfer(x.emissiveMap.colorSpace)===tt,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===Tn,flipSided:x.side===Pt,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ge&&x.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ge&&x.extensions.multiDraw===!0||De)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return we.vertexUv1s=l.has(1),we.vertexUv2s=l.has(2),we.vertexUv3s=l.has(3),l.clear(),we}function m(x){const b=[];if(x.shaderID?b.push(x.shaderID):(b.push(x.customVertexShaderID),b.push(x.customFragmentShaderID)),x.defines!==void 0)for(const D in x.defines)b.push(D),b.push(x.defines[D]);return x.isRawShaderMaterial===!1&&(p(b,x),E(b,x),b.push(i.outputColorSpace)),b.push(x.customProgramCacheKey),b.join()}function p(x,b){x.push(b.precision),x.push(b.outputColorSpace),x.push(b.envMapMode),x.push(b.envMapCubeUVHeight),x.push(b.mapUv),x.push(b.alphaMapUv),x.push(b.lightMapUv),x.push(b.aoMapUv),x.push(b.bumpMapUv),x.push(b.normalMapUv),x.push(b.displacementMapUv),x.push(b.emissiveMapUv),x.push(b.metalnessMapUv),x.push(b.roughnessMapUv),x.push(b.anisotropyMapUv),x.push(b.clearcoatMapUv),x.push(b.clearcoatNormalMapUv),x.push(b.clearcoatRoughnessMapUv),x.push(b.iridescenceMapUv),x.push(b.iridescenceThicknessMapUv),x.push(b.sheenColorMapUv),x.push(b.sheenRoughnessMapUv),x.push(b.specularMapUv),x.push(b.specularColorMapUv),x.push(b.specularIntensityMapUv),x.push(b.transmissionMapUv),x.push(b.thicknessMapUv),x.push(b.combine),x.push(b.fogExp2),x.push(b.sizeAttenuation),x.push(b.morphTargetsCount),x.push(b.morphAttributeCount),x.push(b.numDirLights),x.push(b.numPointLights),x.push(b.numSpotLights),x.push(b.numSpotLightMaps),x.push(b.numHemiLights),x.push(b.numRectAreaLights),x.push(b.numDirLightShadows),x.push(b.numPointLightShadows),x.push(b.numSpotLightShadows),x.push(b.numSpotLightShadowsWithMaps),x.push(b.numLightProbes),x.push(b.shadowMapType),x.push(b.toneMapping),x.push(b.numClippingPlanes),x.push(b.numClipIntersection),x.push(b.depthPacking)}function E(x,b){a.disableAll(),b.instancing&&a.enable(0),b.instancingColor&&a.enable(1),b.instancingMorph&&a.enable(2),b.matcap&&a.enable(3),b.envMap&&a.enable(4),b.normalMapObjectSpace&&a.enable(5),b.normalMapTangentSpace&&a.enable(6),b.clearcoat&&a.enable(7),b.iridescence&&a.enable(8),b.alphaTest&&a.enable(9),b.vertexColors&&a.enable(10),b.vertexAlphas&&a.enable(11),b.vertexUv1s&&a.enable(12),b.vertexUv2s&&a.enable(13),b.vertexUv3s&&a.enable(14),b.vertexTangents&&a.enable(15),b.anisotropy&&a.enable(16),b.alphaHash&&a.enable(17),b.batching&&a.enable(18),b.dispersion&&a.enable(19),b.batchingColor&&a.enable(20),b.gradientMap&&a.enable(21),b.packedNormalMap&&a.enable(22),b.vertexNormals&&a.enable(23),x.push(a.mask),a.disableAll(),b.fog&&a.enable(0),b.useFog&&a.enable(1),b.flatShading&&a.enable(2),b.logarithmicDepthBuffer&&a.enable(3),b.reversedDepthBuffer&&a.enable(4),b.skinning&&a.enable(5),b.morphTargets&&a.enable(6),b.morphNormals&&a.enable(7),b.morphColors&&a.enable(8),b.premultipliedAlpha&&a.enable(9),b.shadowMapEnabled&&a.enable(10),b.doubleSided&&a.enable(11),b.flipSided&&a.enable(12),b.useDepthPacking&&a.enable(13),b.dithering&&a.enable(14),b.transmission&&a.enable(15),b.sheen&&a.enable(16),b.opaque&&a.enable(17),b.pointsUvs&&a.enable(18),b.decodeVideoTexture&&a.enable(19),b.decodeVideoTextureEmissive&&a.enable(20),b.alphaToCoverage&&a.enable(21),b.numLightProbeGrids>0&&a.enable(22),b.hasPositionAttribute&&a.enable(23),x.push(a.mask)}function A(x){const b=f[x.type];let D;if(b){const C=Bn[b];D=Qm.clone(C.uniforms)}else D=x.uniforms;return D}function M(x,b){let D=h.get(b);return D!==void 0?++D.usedTimes:(D=new Rx(i,b,x,s),c.push(D),h.set(b,D)),D}function S(x){if(--x.usedTimes===0){const b=c.indexOf(x);c[b]=c[c.length-1],c.pop(),h.delete(x.cacheKey),x.destroy()}}function w(x){o.remove(x)}function R(){o.dispose()}return{getParameters:_,getProgramCacheKey:m,getUniforms:A,acquireProgram:M,releaseProgram:S,releaseShaderCache:w,programs:c,dispose:R}}function Nx(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,l){i.get(a)[o]=l}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function Ux(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function Ju(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Qu(){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,_,m,p){let E=i[e];return E===void 0?(E={id:d.id,object:d,geometry:f,material:g,materialVariant:a(d),groupOrder:_,renderOrder:d.renderOrder,z:m,group:p},i[e]=E):(E.id=d.id,E.object=d,E.geometry=f,E.material=g,E.materialVariant=a(d),E.groupOrder=_,E.renderOrder=d.renderOrder,E.z=m,E.group=p),e++,E}function l(d,f,g,_,m,p){const E=o(d,f,g,_,m,p);g.transmission>0?n.push(E):g.transparent===!0?s.push(E):t.push(E)}function c(d,f,g,_,m,p){const E=o(d,f,g,_,m,p);g.transmission>0?n.unshift(E):g.transparent===!0?s.unshift(E):t.unshift(E)}function h(d,f,g){t.length>1&&t.sort(d||Ux),n.length>1&&n.sort(f||Ju),s.length>1&&s.sort(f||Ju),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:l,unshift:c,finish:u,sort:h}}function Fx(){let i=new WeakMap;function e(n,s){const r=i.get(n);let a;return r===void 0?(a=new Qu,i.set(n,[a])):s>=r.length?(a=new Qu,r.push(a)):a=r[s],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function Ox(){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 U,color:new Me};break;case"SpotLight":t={position:new U,direction:new U,color:new Me,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new U,color:new Me,distance:0,decay:0};break;case"HemisphereLight":t={direction:new U,skyColor:new Me,groundColor:new Me};break;case"RectAreaLight":t={color:new Me,position:new U,halfWidth:new U,halfHeight:new U};break}return i[e.id]=t,t}}}function zx(){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 Bx=0;function kx(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function Hx(i){const e=new Ox,t=zx(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new U);const s=new U,r=new ht,a=new ht;function o(c){let h=0,u=0,d=0;for(let b=0;b<9;b++)n.probe[b].set(0,0,0);let f=0,g=0,_=0,m=0,p=0,E=0,A=0,M=0,S=0,w=0,R=0;c.sort(kx);for(let b=0,D=c.length;b<D;b++){const C=c[b],I=C.color,W=C.intensity,X=C.distance;let F=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===ns?F=C.shadow.map.texture:F=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)h+=I.r*W,u+=I.g*W,d+=I.b*W;else if(C.isLightProbe){for(let q=0;q<9;q++)n.probe[q].addScaledVector(C.sh.coefficients[q],W);R++}else if(C.isDirectionalLight){const q=e.get(C);if(q.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){const G=C.shadow,Z=t.get(C);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]=F,n.directionalShadowMatrix[f]=C.shadow.matrix,E++}n.directional[f]=q,f++}else if(C.isSpotLight){const q=e.get(C);q.position.setFromMatrixPosition(C.matrixWorld),q.color.copy(I).multiplyScalar(W),q.distance=X,q.coneCos=Math.cos(C.angle),q.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),q.decay=C.decay,n.spot[_]=q;const G=C.shadow;if(C.map&&(n.spotLightMap[S]=C.map,S++,G.updateMatrices(C),C.castShadow&&w++),n.spotLightMatrix[_]=G.matrix,C.castShadow){const Z=t.get(C);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,n.spotShadow[_]=Z,n.spotShadowMap[_]=F,M++}_++}else if(C.isRectAreaLight){const q=e.get(C);q.color.copy(I).multiplyScalar(W),q.halfWidth.set(C.width*.5,0,0),q.halfHeight.set(0,C.height*.5,0),n.rectArea[m]=q,m++}else if(C.isPointLight){const q=e.get(C);if(q.color.copy(C.color).multiplyScalar(C.intensity),q.distance=C.distance,q.decay=C.decay,C.castShadow){const G=C.shadow,Z=t.get(C);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]=F,n.pointShadowMatrix[g]=C.shadow.matrix,A++}n.point[g]=q,g++}else if(C.isHemisphereLight){const q=e.get(C);q.skyColor.copy(C.color).multiplyScalar(W),q.groundColor.copy(C.groundColor).multiplyScalar(W),n.hemi[p]=q,p++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=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 x=n.hash;(x.directionalLength!==f||x.pointLength!==g||x.spotLength!==_||x.rectAreaLength!==m||x.hemiLength!==p||x.numDirectionalShadows!==E||x.numPointShadows!==A||x.numSpotShadows!==M||x.numSpotMaps!==S||x.numLightProbes!==R)&&(n.directional.length=f,n.spot.length=_,n.rectArea.length=m,n.point.length=g,n.hemi.length=p,n.directionalShadow.length=E,n.directionalShadowMap.length=E,n.pointShadow.length=A,n.pointShadowMap.length=A,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=E,n.pointShadowMatrix.length=A,n.spotLightMatrix.length=M+S-w,n.spotLightMap.length=S,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=R,x.directionalLength=f,x.pointLength=g,x.spotLength=_,x.rectAreaLength=m,x.hemiLength=p,x.numDirectionalShadows=E,x.numPointShadows=A,x.numSpotShadows=M,x.numSpotMaps=S,x.numLightProbes=R,n.version=Bx++)}function l(c,h){let u=0,d=0,f=0,g=0,_=0;const m=h.matrixWorldInverse;for(let p=0,E=c.length;p<E;p++){const A=c[p];if(A.isDirectionalLight){const M=n.directional[u];M.direction.setFromMatrixPosition(A.matrixWorld),s.setFromMatrixPosition(A.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),u++}else if(A.isSpotLight){const M=n.spot[f];M.position.setFromMatrixPosition(A.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(A.matrixWorld),s.setFromMatrixPosition(A.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),f++}else if(A.isRectAreaLight){const M=n.rectArea[g];M.position.setFromMatrixPosition(A.matrixWorld),M.position.applyMatrix4(m),a.identity(),r.copy(A.matrixWorld),r.premultiply(m),a.extractRotation(r),M.halfWidth.set(A.width*.5,0,0),M.halfHeight.set(0,A.height*.5,0),M.halfWidth.applyMatrix4(a),M.halfHeight.applyMatrix4(a),g++}else if(A.isPointLight){const M=n.point[d];M.position.setFromMatrixPosition(A.matrixWorld),M.position.applyMatrix4(m),d++}else if(A.isHemisphereLight){const M=n.hemi[_];M.direction.setFromMatrixPosition(A.matrixWorld),M.direction.transformDirection(m),_++}}}return{setup:o,setupView:l,state:n}}function ju(i){const e=new Hx(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 l(d){s.push(d)}function c(){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:c,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:l}}function Gx(i){let e=new WeakMap;function t(s,r=0){const a=e.get(s);let o;return a===void 0?(o=new ju(i),e.set(s,[o])):r>=a.length?(o=new ju(i),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const Vx=`void main() {
4707
4707
  gl_Position = vec4( position, 1.0 );
4708
- }`,H_=`uniform sampler2D shadow_pass;
4708
+ }`,Wx=`uniform sampler2D shadow_pass;
4709
4709
  uniform vec2 resolution;
4710
4710
  uniform float radius;
4711
4711
  void main() {
@@ -4730,12 +4730,12 @@ void main() {
4730
4730
  squared_mean = squared_mean / samples;
4731
4731
  float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
4732
4732
  gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
4733
- }`,G_=[new U(1,0,0),new U(-1,0,0),new U(0,1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1)],V_=[new U(0,-1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1),new U(0,-1,0),new U(0,-1,0)],$u=new ht,lr=new U,nl=new U;function W_(i,e,t){let n=new uh;const s=new Le,r=new Le,a=new pt,o=new jm,l=new eg,c={},h=t.maxTextureSize,u={[Ci]:Dt,[Dt]:Ci,[Tn]:Tn},d=new It({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Le},radius:{value:4}},vertexShader:k_,fragmentShader:H_}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const g=new bt;g.setAttribute("position",new ct(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new nt(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Mr;let p=this.type;this.render=function(w,R,_){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||w.length===0)return;this.type===Hp&&(Oe("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Mr);const b=i.getRenderTarget(),D=i.getActiveCubeFace(),C=i.getActiveMipmapLevel(),I=i.state;I.setBlending(ri),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(F=>F.needsUpdate=!0):X.material.needsUpdate=!0)});for(let X=0,F=w.length;X<F;X++){const q=w[X],G=q.shadow;if(G===void 0){Oe("WebGLShadowMap:",q,"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||W===!0){if(G.map!==null&&(G.map.depthTexture!==null&&(G.map.depthTexture.dispose(),G.map.depthTexture=null),G.map.dispose()),this.type===fr){if(q.isPointLight){Oe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}G.map=new Sn(s.x,s.y,{format:ji,type:mn,minFilter:Tt,magFilter:Tt,generateMipmaps:!1}),G.map.texture.name=q.name+".shadowMap",G.map.depthTexture=new ts(s.x,s.y,Xn),G.map.depthTexture.name=q.name+".shadowMapDepth",G.map.depthTexture.format=oi,G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Ct,G.map.depthTexture.magFilter=Ct}else q.isPointLight?(G.map=new B0(s.x),G.map.depthTexture=new Ym(s.x,Dn)):(G.map=new Sn(s.x,s.y),G.map.depthTexture=new ts(s.x,s.y,Dn)),G.map.depthTexture.name=q.name+".shadowMap",G.map.depthTexture.format=oi,this.type===Mr?(G.map.depthTexture.compareFunction=te?sh:ih,G.map.depthTexture.minFilter=Tt,G.map.depthTexture.magFilter=Tt):(G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Ct,G.map.depthTexture.magFilter=Ct);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,ke=G.matrix,qe=q.distance||ue.far;qe!==ue.far&&(ue.far=qe,ue.updateProjectionMatrix()),lr.setFromMatrixPosition(q.matrixWorld),ue.position.copy(lr),nl.copy(ue.position),nl.add(G_[ie]),ue.up.copy(V_[ie]),ue.lookAt(nl),ue.updateMatrixWorld(),ke.makeTranslation(-lr.x,-lr.y,-lr.z),$u.multiplyMatrices(ue.projectionMatrix,ue.matrixWorldInverse),G._frustum.setFromProjectionMatrix($u,ue.coordinateSystem,ue.reversedDepth)}else G.updateMatrices(q);n=G.getFrustum(),M(R,_,G.camera,q,this.type)}G.isPointLightShadow!==!0&&this.type===fr&&E(G,_),G.needsUpdate=!1}p=this.type,m.needsUpdate=!1,i.setRenderTarget(b,D,C)};function E(w,R){const _=e.update(x);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new Sn(s.x,s.y,{format:ji,type:mn})),d.uniforms.shadow_pass.value=w.map.depthTexture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,i.setRenderTarget(w.mapPass),i.clear(),i.renderBufferDirect(R,null,_,d,x,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,i.setRenderTarget(w.map),i.clear(),i.renderBufferDirect(R,null,_,f,x,null)}function A(w,R,_,b){let D=null;const C=_.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(C!==void 0)D=C;else if(D=_.isPointLight===!0?l:o,i.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){const I=D.uuid,W=R.uuid;let X=c[I];X===void 0&&(X={},c[I]=X);let F=X[W];F===void 0&&(F=D.clone(),X[W]=F,R.addEventListener("dispose",S)),D=F}if(D.visible=R.visible,D.wireframe=R.wireframe,b===fr?D.side=R.shadowSide!==null?R.shadowSide:R.side:D.side=R.shadowSide!==null?R.shadowSide:u[R.side],D.alphaMap=R.alphaMap,D.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,D.map=R.map,D.clipShadows=R.clipShadows,D.clippingPlanes=R.clippingPlanes,D.clipIntersection=R.clipIntersection,D.displacementMap=R.displacementMap,D.displacementScale=R.displacementScale,D.displacementBias=R.displacementBias,D.wireframeLinewidth=R.wireframeLinewidth,D.linewidth=R.linewidth,_.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const I=i.properties.get(D);I.light=_}return D}function M(w,R,_,b,D){if(w.visible===!1)return;if(w.layers.test(R.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&D===fr)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,w.matrixWorld);const W=e.update(w),X=w.material;if(Array.isArray(X)){const F=W.groups;for(let q=0,G=F.length;q<G;q++){const Z=F[q],te=X[Z.materialIndex];if(te&&te.visible){const j=A(w,te,b,D);w.onBeforeShadow(i,w,R,_,W,j,Z),i.renderBufferDirect(_,null,W,j,w,Z),w.onAfterShadow(i,w,R,_,W,j,Z)}}}else if(X.visible){const F=A(w,X,b,D);w.onBeforeShadow(i,w,R,_,W,F,null),i.renderBufferDirect(_,null,W,F,w,null),w.onAfterShadow(i,w,R,_,W,F,null)}}const I=w.children;for(let W=0,X=I.length;W<X;W++)M(I[W],R,_,b,D)}function S(w){w.target.removeEventListener("dispose",S);for(const _ in c){const b=c[_],D=w.target.uuid;D in b&&(b[D].dispose(),delete b[D])}}}function X_(i,e){function t(){let P=!1;const ae=new pt;let J=null;const he=new pt(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,we,ye,vt){vt===!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(){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 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&&!P&&(i.depthMask(ee),J=ee)},setFunc:function(ee){if(ae&&(ee=Mm[ee]),he!==ee){switch(ee){case Dl:i.depthFunc(i.NEVER);break;case Pl:i.depthFunc(i.ALWAYS);break;case Il:i.depthFunc(i.LESS);break;case Ys:i.depthFunc(i.LEQUAL);break;case Ll:i.depthFunc(i.EQUAL);break;case Nl:i.depthFunc(i.GEQUAL);break;case Ul:i.depthFunc(i.GREATER);break;case Fl: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,we=null,ye=null,vt=null;return{setTest:function(ot){P||(ot?ne(i.STENCIL_TEST):z(i.STENCIL_TEST))},setMask:function(ot){ae!==ot&&!P&&(i.stencilMask(ot),ae=ot)},setFunc:function(ot,In,Ln){(J!==ot||he!==In||ge!==Ln)&&(i.stencilFunc(ot,In,Ln),J=ot,he=In,ge=Ln)},setOp:function(ot,In,Ln){(ee!==ot||we!==In||ye!==Ln)&&(i.stencilOp(ot,In,Ln),ee=ot,we=In,ye=Ln)},setLocked:function(ot){P=ot},setClear:function(ot){vt!==ot&&(i.clearStencil(ot),vt=ot)},reset:function(){P=!1,ae=null,J=null,he=null,ge=null,ee=null,we=null,ye=null,vt=null}}}const r=new t,a=new n,o=new s,l=new WeakMap,c=new WeakMap;let h={},u={},d={},f=new WeakMap,g=[],x=null,m=!1,p=null,E=null,A=null,M=null,S=null,w=null,R=null,_=new Me(0,0,0),b=0,D=!1,C=null,I=null,W=null,X=null,F=null;const q=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),ke=i.getParameter(i.VIEWPORT),qe=new pt().fromArray(ue),Be=new pt().fromArray(ke);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 we=0;we<J;we++)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+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(Ys),Je(!1),Qe($h),ne(i.CULL_FACE),Ne(ri);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 Ee(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 De(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,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 Ae(P){return x!==P?(i.useProgram(P),x=P,!0):!1}const _e={[Wi]:i.FUNC_ADD,[Vp]:i.FUNC_SUBTRACT,[Wp]:i.FUNC_REVERSE_SUBTRACT};_e[Xp]=i.MIN,_e[qp]=i.MAX;const Ie={[Yp]:i.ZERO,[Kp]:i.ONE,[$p]:i.SRC_COLOR,[Rl]:i.SRC_ALPHA,[tm]:i.SRC_ALPHA_SATURATE,[jp]:i.DST_COLOR,[Jp]:i.DST_ALPHA,[Zp]:i.ONE_MINUS_SRC_COLOR,[Cl]:i.ONE_MINUS_SRC_ALPHA,[em]:i.ONE_MINUS_DST_COLOR,[Qp]:i.ONE_MINUS_DST_ALPHA,[nm]:i.CONSTANT_COLOR,[im]:i.ONE_MINUS_CONSTANT_COLOR,[sm]:i.CONSTANT_ALPHA,[rm]:i.ONE_MINUS_CONSTANT_ALPHA};function Ne(P,ae,J,he,ge,ee,we,ye,vt,ot){if(P===ri){m===!0&&(z(i.BLEND),m=!1);return}if(m===!1&&(ne(i.BLEND),m=!0),P!==Gp){if(P!==p||ot!==D){if((E!==Wi||S!==Wi)&&(i.blendEquation(i.FUNC_ADD),E=Wi,S=Wi),ot)switch(P){case Bs:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Di:i.blendFunc(i.ONE,i.ONE);break;case Zh: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:Ye("WebGLState: Invalid blending: ",P);break}else switch(P){case Bs:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Di:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case Zh:Ye("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Jh:Ye("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ye("WebGLState: Invalid blending: ",P);break}A=null,M=null,w=null,R=null,_.set(0,0,0),b=0,p=P,D=ot}return}ge=ge||ae,ee=ee||J,we=we||he,(ae!==E||ge!==S)&&(i.blendEquationSeparate(_e[ae],_e[ge]),E=ae,S=ge),(J!==A||he!==M||ee!==w||we!==R)&&(i.blendFuncSeparate(Ie[J],Ie[he],Ie[ee],Ie[we]),A=J,M=he,w=ee,R=we),(ye.equals(_)===!1||vt!==b)&&(i.blendColor(ye.r,ye.g,ye.b,vt),_.copy(ye),b=vt),p=P,D=!1}function Ue(P,ae){P.side===Tn?z(i.CULL_FACE):ne(i.CULL_FACE);let J=P.side===Dt;ae&&(J=!J),Je(J),P.blending===Bs&&P.transparent===!1?Ne(ri):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)),dt(P.polygonOffset,P.polygonOffsetFactor,P.polygonOffsetUnits),P.alphaToCoverage===!0?ne(i.SAMPLE_ALPHA_TO_COVERAGE):z(i.SAMPLE_ALPHA_TO_COVERAGE)}function Je(P){C!==P&&(P?i.frontFace(i.CW):i.frontFace(i.CCW),C=P)}function Qe(P){P!==Bp?(ne(i.CULL_FACE),P!==I&&(P===$h?i.cullFace(i.BACK):P===kp?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):z(i.CULL_FACE),I=P}function mt(P){P!==W&&(G&&i.lineWidth(P),W=P)}function dt(P,ae,J){P?(ne(i.POLYGON_OFFSET_FILL),(X!==ae||F!==J)&&(X=ae,F=J,a.getReversed()&&(ae=-ae),i.polygonOffset(ae,J))):z(i.POLYGON_OFFSET_FILL)}function gt(P){P?ne(i.SCISSOR_TEST):z(i.SCISSOR_TEST)}function Et(P){P===void 0&&(P=i.TEXTURE0+q-1),j!==P&&(i.activeTexture(P),j=P)}function L(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 jt(){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 je(){try{i.compressedTexImage2D(...arguments)}catch(P){Ye("WebGLState:",P)}}function T(){try{i.compressedTexImage3D(...arguments)}catch(P){Ye("WebGLState:",P)}}function v(){try{i.texSubImage2D(...arguments)}catch(P){Ye("WebGLState:",P)}}function O(){try{i.texSubImage3D(...arguments)}catch(P){Ye("WebGLState:",P)}}function H(){try{i.compressedTexSubImage2D(...arguments)}catch(P){Ye("WebGLState:",P)}}function K(){try{i.compressedTexSubImage3D(...arguments)}catch(P){Ye("WebGLState:",P)}}function se(){try{i.texStorage2D(...arguments)}catch(P){Ye("WebGLState:",P)}}function oe(){try{i.texStorage3D(...arguments)}catch(P){Ye("WebGLState:",P)}}function $(){try{i.texImage2D(...arguments)}catch(P){Ye("WebGLState:",P)}}function Q(){try{i.texImage3D(...arguments)}catch(P){Ye("WebGLState:",P)}}function le(P){return u[P]!==void 0?u[P]:i.getParameter(P)}function Te(P,ae){u[P]!==ae&&(i.pixelStorei(P,ae),u[P]=ae)}function de(P){qe.equals(P)===!1&&(i.scissor(P.x,P.y,P.z,P.w),qe.copy(P))}function ce(P){Be.equals(P)===!1&&(i.viewport(P.x,P.y,P.z,P.w),Be.copy(P))}function Pe(P,ae){let J=c.get(ae);J===void 0&&(J=new WeakMap,c.set(ae,J));let he=J.get(P);he===void 0&&(he=i.getUniformBlockIndex(ae,P.name),J.set(P,he))}function Fe(P,ae){const he=c.get(ae).get(P);l.get(ae)!==he&&(i.uniformBlockBinding(ae,he,P.__bindingPointIndex),l.set(ae,he))}function He(){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,E=null,A=null,M=null,S=null,w=null,R=null,_=new Me(0,0,0),b=0,D=!1,C=null,I=null,W=null,X=null,F=null,qe.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:Ee,drawBuffers:De,useProgram:Ae,setBlending:Ne,setMaterial:Ue,setFlipSided:Je,setCullFace:Qe,setLineWidth:mt,setPolygonOffset:dt,setScissorTest:gt,activeTexture:Et,bindTexture:L,unbindTexture:jt,compressedTexImage2D:je,compressedTexImage3D:T,texImage2D:$,texImage3D:Q,pixelStorei:Te,getParameter:le,updateUBOMapping:Pe,uniformBlockBinding:Fe,texStorage2D:se,texStorage3D:oe,texSubImage2D:v,texSubImage3D:O,compressedTexSubImage2D:H,compressedTexSubImage3D:K,scissor:de,viewport:ce,reset:He}}function q_(i,e,t,n,s,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new 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(T,v){return g?new OffscreenCanvas(T,v):Za("canvas")}function m(T,v,O){let H=1;const K=je(T);if((K.width>O||K.height>O)&&(H=O/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),Oe("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+se+"x"+oe+")."),$}else return"data"in T&&Oe("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),T;return T}function p(T){return T.generateMipmaps}function E(T){i.generateMipmap(T)}function A(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,O,H,K,se=!1){if(T!==null){if(i[T]!==void 0)return i[T];Oe("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let oe;H&&(oe=e.get("EXT_texture_norm16"),oe||Oe("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let $=v;if(v===i.RED&&(O===i.FLOAT&&($=i.R32F),O===i.HALF_FLOAT&&($=i.R16F),O===i.UNSIGNED_BYTE&&($=i.R8),O===i.UNSIGNED_SHORT&&oe&&($=oe.R16_EXT),O===i.SHORT&&oe&&($=oe.R16_SNORM_EXT)),v===i.RED_INTEGER&&(O===i.UNSIGNED_BYTE&&($=i.R8UI),O===i.UNSIGNED_SHORT&&($=i.R16UI),O===i.UNSIGNED_INT&&($=i.R32UI),O===i.BYTE&&($=i.R8I),O===i.SHORT&&($=i.R16I),O===i.INT&&($=i.R32I)),v===i.RG&&(O===i.FLOAT&&($=i.RG32F),O===i.HALF_FLOAT&&($=i.RG16F),O===i.UNSIGNED_BYTE&&($=i.RG8),O===i.UNSIGNED_SHORT&&oe&&($=oe.RG16_EXT),O===i.SHORT&&oe&&($=oe.RG16_SNORM_EXT)),v===i.RG_INTEGER&&(O===i.UNSIGNED_BYTE&&($=i.RG8UI),O===i.UNSIGNED_SHORT&&($=i.RG16UI),O===i.UNSIGNED_INT&&($=i.RG32UI),O===i.BYTE&&($=i.RG8I),O===i.SHORT&&($=i.RG16I),O===i.INT&&($=i.RG32I)),v===i.RGB_INTEGER&&(O===i.UNSIGNED_BYTE&&($=i.RGB8UI),O===i.UNSIGNED_SHORT&&($=i.RGB16UI),O===i.UNSIGNED_INT&&($=i.RGB32UI),O===i.BYTE&&($=i.RGB8I),O===i.SHORT&&($=i.RGB16I),O===i.INT&&($=i.RGB32I)),v===i.RGBA_INTEGER&&(O===i.UNSIGNED_BYTE&&($=i.RGBA8UI),O===i.UNSIGNED_SHORT&&($=i.RGBA16UI),O===i.UNSIGNED_INT&&($=i.RGBA32UI),O===i.BYTE&&($=i.RGBA8I),O===i.SHORT&&($=i.RGBA16I),O===i.INT&&($=i.RGBA32I)),v===i.RGB&&(O===i.UNSIGNED_SHORT&&oe&&($=oe.RGB16_EXT),O===i.SHORT&&oe&&($=oe.RGB16_SNORM_EXT),O===i.UNSIGNED_INT_5_9_9_9_REV&&($=i.RGB9_E5),O===i.UNSIGNED_INT_10F_11F_11F_REV&&($=i.R11F_G11F_B10F)),v===i.RGBA){const Q=se?$a:Ke.getTransfer(K);O===i.FLOAT&&($=i.RGBA32F),O===i.HALF_FLOAT&&($=i.RGBA16F),O===i.UNSIGNED_BYTE&&($=Q===et?i.SRGB8_ALPHA8:i.RGBA8),O===i.UNSIGNED_SHORT&&oe&&($=oe.RGBA16_EXT),O===i.SHORT&&oe&&($=oe.RGBA16_SNORM_EXT),O===i.UNSIGNED_SHORT_4_4_4_4&&($=i.RGBA4),O===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 O;return T?v===null||v===Dn||v===Tr?O=i.DEPTH24_STENCIL8:v===Xn?O=i.DEPTH32F_STENCIL8:v===Ar&&(O=i.DEPTH24_STENCIL8,Oe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):v===null||v===Dn||v===Tr?O=i.DEPTH_COMPONENT24:v===Xn?O=i.DEPTH_COMPONENT32F:v===Ar&&(O=i.DEPTH_COMPONENT16),O}function w(T,v){return p(T)===!0||T.isFramebufferTexture&&T.minFilter!==Ct&&T.minFilter!==Tt?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),b(v),v.isVideoTexture&&h.delete(v),v.isHTMLTexture&&u.delete(v)}function _(T){const v=T.target;v.removeEventListener("dispose",_),C(v)}function b(T){const v=n.get(T);if(v.__webglInit===void 0)return;const O=T.source,H=f.get(O);if(H){const K=H[v.__cacheKey];K.usedTimes--,K.usedTimes===0&&D(T),Object.keys(H).length===0&&f.delete(O)}n.remove(T)}function D(T){const v=n.get(T);i.deleteTexture(v.__webglTexture);const O=T.source,H=f.get(O);delete H[v.__cacheKey],a.memory.textures--}function C(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 O=T.textures;for(let H=0,K=O.length;H<K;H++){const se=n.get(O[H]);se.__webglTexture&&(i.deleteTexture(se.__webglTexture),a.memory.textures--),n.remove(O[H])}n.remove(T)}let I=0;function W(){I=0}function X(){return I}function F(T){I=T}function q(){const T=I;return T>=s.maxTextures&&Oe("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 O=n.get(T);if(T.isVideoTexture&&L(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&O.__version!==T.version){const H=T.image;if(H===null)Oe("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Oe("WebGLRenderer: Texture marked for update but image is incomplete");else{z(O,T,v);return}}else T.isExternalTexture&&(O.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,O.__webglTexture,i.TEXTURE0+v)}function te(T,v){const O=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&O.__version!==T.version){z(O,T,v);return}else T.isExternalTexture&&(O.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,O.__webglTexture,i.TEXTURE0+v)}function j(T,v){const O=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&O.__version!==T.version){z(O,T,v);return}t.bindTexture(i.TEXTURE_3D,O.__webglTexture,i.TEXTURE0+v)}function ie(T,v){const O=n.get(T);if(T.isCubeDepthTexture!==!0&&T.version>0&&O.__version!==T.version){Ee(O,T,v);return}t.bindTexture(i.TEXTURE_CUBE_MAP,O.__webglTexture,i.TEXTURE0+v)}const ue={[Ol]:i.REPEAT,[fn]:i.CLAMP_TO_EDGE,[zl]:i.MIRRORED_REPEAT},ke={[Ct]:i.NEAREST,[lm]:i.NEAREST_MIPMAP_NEAREST,[Xr]:i.NEAREST_MIPMAP_LINEAR,[Tt]:i.LINEAR,[bo]:i.LINEAR_MIPMAP_NEAREST,[Ki]:i.LINEAR_MIPMAP_LINEAR},qe={[um]:i.NEVER,[gm]:i.ALWAYS,[dm]:i.LESS,[ih]:i.LEQUAL,[fm]:i.EQUAL,[sh]:i.GEQUAL,[pm]:i.GREATER,[mm]:i.NOTEQUAL};function Be(T,v){if(v.type===Xn&&e.has("OES_texture_float_linear")===!1&&(v.magFilter===Tt||v.magFilter===bo||v.magFilter===Xr||v.magFilter===Ki||v.minFilter===Tt||v.minFilter===bo||v.minFilter===Xr||v.minFilter===Ki)&&Oe("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,ke[v.magFilter]),i.texParameteri(T,i.TEXTURE_MIN_FILTER,ke[v.minFilter]),v.compareFunction&&(i.texParameteri(T,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(T,i.TEXTURE_COMPARE_FUNC,qe[v.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===Ct||v.minFilter!==Xr&&v.minFilter!==Ki||v.type===Xn&&e.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||n.get(v).__currentAnisotropy){const O=e.get("EXT_texture_filter_anisotropic");i.texParameterf(T,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,s.getMaxAnisotropy())),n.get(v).__currentAnisotropy=v.anisotropy}}}function Y(T,v){let O=!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++,O=!0),K[se].usedTimes++;const oe=K[T.__cacheKey];oe!==void 0&&(K[T.__cacheKey].usedTimes--,oe.usedTimes===0&&D(v)),T.__cacheKey=se,T.__webglTexture=K[se].texture}return O}function re(T,v,O){return Math.floor(Math.floor(T/O)/v)}function ne(T,v,O,H){const se=T.updateRanges;if(se.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,v.width,v.height,O,H,v.data);else{se.sort((Te,de)=>Te.start-de.start);let oe=0;for(let Te=1;Te<se.length;Te++){const de=se[oe],ce=se[Te],Pe=de.start+de.count,Fe=re(ce.start,v.width,4),He=re(de.start,v.width,4);ce.start<=Pe+1&&Fe===He&&re(ce.start+ce.count-1,v.width,4)===Fe?de.count=Math.max(de.count,ce.start+ce.count-de.start):(++oe,se[oe]=ce)}se.length=oe+1;const $=t.getParameter(i.UNPACK_ROW_LENGTH),Q=t.getParameter(i.UNPACK_SKIP_PIXELS),le=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,v.width);for(let Te=0,de=se.length;Te<de;Te++){const ce=se[Te],Pe=Math.floor(ce.start/4),Fe=Math.ceil(ce.count/4),He=Pe%v.width,P=Math.floor(Pe/v.width),ae=Fe,J=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,He),t.pixelStorei(i.UNPACK_SKIP_ROWS,P),t.texSubImage2D(i.TEXTURE_2D,0,He,P,ae,J,O,H,v.data)}T.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,$),t.pixelStorei(i.UNPACK_SKIP_PIXELS,Q),t.pixelStorei(i.UNPACK_SKIP_ROWS,le)}}function z(T,v,O){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+O);const oe=n.get(se);if(se.version!==oe.__version||K===!0){if(t.activeTexture(i.TEXTURE0+O),(typeof ImageBitmap<"u"&&v.image instanceof ImageBitmap)===!1){const J=Ke.getPrimaries(Ke.workingColorSpace),he=v.colorSpace===bi?null:Ke.getPrimaries(v.colorSpace),ge=v.colorSpace===bi||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=jt(v,Q);const le=r.convert(v.format,v.colorSpace),Te=r.convert(v.type);let de=M(v.internalFormat,le,Te,v.normalized,v.colorSpace,v.isVideoTexture);Be(H,v);let ce;const Pe=v.mipmaps,Fe=v.isVideoTexture!==!0,He=oe.__version===void 0||K===!0,P=se.dataReady,ae=w(v,Q);if(v.isDepthTexture)de=S(v.format===$i,v.type),He&&(Fe?t.texStorage2D(i.TEXTURE_2D,1,de,Q.width,Q.height):t.texImage2D(i.TEXTURE_2D,0,de,Q.width,Q.height,0,le,Te,null));else if(v.isDataTexture)if(Pe.length>0){Fe&&He&&t.texStorage2D(i.TEXTURE_2D,ae,de,Pe[0].width,Pe[0].height);for(let J=0,he=Pe.length;J<he;J++)ce=Pe[J],Fe?P&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,ce.width,ce.height,le,Te,ce.data):t.texImage2D(i.TEXTURE_2D,J,de,ce.width,ce.height,0,le,Te,ce.data);v.generateMipmaps=!1}else Fe?(He&&t.texStorage2D(i.TEXTURE_2D,ae,de,Q.width,Q.height),P&&ne(v,Q,le,Te)):t.texImage2D(i.TEXTURE_2D,0,de,Q.width,Q.height,0,le,Te,Q.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){Fe&&He&&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(ce=Pe[J],v.format!==pn)if(le!==null)if(Fe){if(P)if(v.layerUpdates.size>0){const ge=Au(ce.width,ce.height,v.format,v.type);for(const ee of v.layerUpdates){const we=ce.data.subarray(ee*ge/ce.data.BYTES_PER_ELEMENT,(ee+1)*ge/ce.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,ee,ce.width,ce.height,1,le,we)}v.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,ce.width,ce.height,Q.depth,le,ce.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,J,de,ce.width,ce.height,Q.depth,0,ce.data,0,0);else Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Fe?P&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,ce.width,ce.height,Q.depth,le,Te,ce.data):t.texImage3D(i.TEXTURE_2D_ARRAY,J,de,ce.width,ce.height,Q.depth,0,le,Te,ce.data)}else{Fe&&He&&t.texStorage2D(i.TEXTURE_2D,ae,de,Pe[0].width,Pe[0].height);for(let J=0,he=Pe.length;J<he;J++)ce=Pe[J],v.format!==pn?le!==null?Fe?P&&t.compressedTexSubImage2D(i.TEXTURE_2D,J,0,0,ce.width,ce.height,le,ce.data):t.compressedTexImage2D(i.TEXTURE_2D,J,de,ce.width,ce.height,0,ce.data):Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Fe?P&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,ce.width,ce.height,le,Te,ce.data):t.texImage2D(i.TEXTURE_2D,J,de,ce.width,ce.height,0,le,Te,ce.data)}else if(v.isDataArrayTexture)if(Fe){if(He&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ae,de,Q.width,Q.height,Q.depth),P)if(v.layerUpdates.size>0){const J=Au(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,le,Te,ge)}v.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,le,Te,Q.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,de,Q.width,Q.height,Q.depth,0,le,Te,Q.data);else if(v.isData3DTexture)Fe?(He&&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,le,Te,Q.data)):t.texImage3D(i.TEXTURE_3D,0,de,Q.width,Q.height,Q.depth,0,le,Te,Q.data);else if(v.isFramebufferTexture){if(He)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,le,Te,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(Pe.length>0){if(Fe&&He){const J=je(Pe[0]);t.texStorage2D(i.TEXTURE_2D,ae,de,J.width,J.height)}for(let J=0,he=Pe.length;J<he;J++)ce=Pe[J],Fe?P&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,le,Te,ce):t.texImage2D(i.TEXTURE_2D,J,de,le,Te,ce);v.generateMipmaps=!1}else if(Fe){if(He){const J=je(Q);t.texStorage2D(i.TEXTURE_2D,ae,de,J.width,J.height)}P&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,le,Te,Q)}else t.texImage2D(i.TEXTURE_2D,0,de,le,Te,Q);p(v)&&E(H),oe.__version=se.version,v.onUpdate&&v.onUpdate(v)}T.__version=v.version}function Ee(T,v,O){if(v.image.length!==6)return;const H=Y(T,v),K=v.source;t.bindTexture(i.TEXTURE_CUBE_MAP,T.__webglTexture,i.TEXTURE0+O);const se=n.get(K);if(K.version!==se.__version||H===!0){t.activeTexture(i.TEXTURE0+O);const oe=Ke.getPrimaries(Ke.workingColorSpace),$=v.colorSpace===bi?null:Ke.getPrimaries(v.colorSpace),Q=v.colorSpace===bi||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 le=v.isCompressedTexture||v.image[0].isCompressedTexture,Te=v.image[0]&&v.image[0].isDataTexture,de=[];for(let ee=0;ee<6;ee++)!le&&!Te?de[ee]=m(v.image[ee],!0,s.maxCubemapSize):de[ee]=Te?v.image[ee].image:v.image[ee],de[ee]=jt(v,de[ee]);const ce=de[0],Pe=r.convert(v.format,v.colorSpace),Fe=r.convert(v.type),He=M(v.internalFormat,Pe,Fe,v.normalized,v.colorSpace),P=v.isVideoTexture!==!0,ae=se.__version===void 0||H===!0,J=K.dataReady;let he=w(v,ce);Be(i.TEXTURE_CUBE_MAP,v);let ge;if(le){P&&ae&&t.texStorage2D(i.TEXTURE_CUBE_MAP,he,He,ce.width,ce.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!==pn?Pe!==null?P?J&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we,0,0,ye.width,ye.height,Pe,ye.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we,He,ye.width,ye.height,0,ye.data):Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):P?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we,0,0,ye.width,ye.height,Pe,Fe,ye.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we,He,ye.width,ye.height,0,Pe,Fe,ye.data)}}}else{if(ge=v.mipmaps,P&&ae){ge.length>0&&he++;const ee=je(de[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,he,He,ee.width,ee.height)}for(let ee=0;ee<6;ee++)if(Te){P?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,de[ee].width,de[ee].height,Pe,Fe,de[ee].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,He,de[ee].width,de[ee].height,0,Pe,Fe,de[ee].data);for(let we=0;we<ge.length;we++){const vt=ge[we].image[ee].image;P?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we+1,0,0,vt.width,vt.height,Pe,Fe,vt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we+1,He,vt.width,vt.height,0,Pe,Fe,vt.data)}}else{P?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,Pe,Fe,de[ee]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,He,Pe,Fe,de[ee]);for(let we=0;we<ge.length;we++){const ye=ge[we];P?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we+1,0,0,Pe,Fe,ye.image[ee]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we+1,He,Pe,Fe,ye.image[ee])}}}p(v)&&E(i.TEXTURE_CUBE_MAP),se.__version=K.version,v.onUpdate&&v.onUpdate(v)}T.__version=v.version}function De(T,v,O,H,K,se){const oe=r.convert(O.format,O.colorSpace),$=r.convert(O.type),Q=M(O.internalFormat,oe,$,O.normalized,O.colorSpace),le=n.get(v),Te=n.get(O);if(Te.__renderTarget=v,!le.__hasExternalTextures){const de=Math.max(1,v.width>>se),ce=Math.max(1,v.height>>se);K===i.TEXTURE_3D||K===i.TEXTURE_2D_ARRAY?t.texImage3D(K,se,Q,de,ce,v.depth,0,oe,$,null):t.texImage2D(K,se,Q,de,ce,0,oe,$,null)}t.bindFramebuffer(i.FRAMEBUFFER,T),Et(v)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,H,K,Te.__webglTexture,0,gt(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,Te.__webglTexture,se),t.bindFramebuffer(i.FRAMEBUFFER,null)}function Ae(T,v,O){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;Et(v)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,gt(v),se,v.width,v.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,gt(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);Et(v)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,gt(v),Q,v.width,v.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,gt(v),Q,v.width,v.height):i.renderbufferStorage(i.RENDERBUFFER,Q,v.width,v.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function _e(T,v,O){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),Be(i.TEXTURE_CUBE_MAP,v.depthTexture);const le=r.convert(v.depthTexture.format),Te=r.convert(v.depthTexture.type);let de;v.depthTexture.format===oi?de=i.DEPTH_COMPONENT24:v.depthTexture.format===$i&&(de=i.DEPTH24_STENCIL8);for(let ce=0;ce<6;ce++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,de,v.width,v.height,0,le,Te,null)}}else Z(v.depthTexture,0);const se=K.__webglTexture,oe=gt(v),$=H?i.TEXTURE_CUBE_MAP_POSITIVE_X+O:i.TEXTURE_2D,Q=v.depthTexture.format===$i?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(v.depthTexture.format===oi)Et(v)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Q,$,se,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,Q,$,se,0);else if(v.depthTexture.format===$i)Et(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 Ie(T){const v=n.get(T),O=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(O)for(let H=0;H<6;H++)_e(v.__webglFramebuffer[H],T,H);else{const H=T.texture.mipmaps;H&&H.length>0?_e(v.__webglFramebuffer[0],T,0):_e(v.__webglFramebuffer,T,0)}else if(O){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(),Ae(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(),Ae(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 Ne(T,v,O){const H=n.get(T);v!==void 0&&De(H.__webglFramebuffer,T,T.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),O!==void 0&&Ie(T)}function Ue(T){const v=T.texture,O=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){O.__webglFramebuffer=[];for(let $=0;$<6;$++)if(v.mipmaps&&v.mipmaps.length>0){O.__webglFramebuffer[$]=[];for(let Q=0;Q<v.mipmaps.length;Q++)O.__webglFramebuffer[$][Q]=i.createFramebuffer()}else O.__webglFramebuffer[$]=i.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){O.__webglFramebuffer=[];for(let $=0;$<v.mipmaps.length;$++)O.__webglFramebuffer[$]=i.createFramebuffer()}else O.__webglFramebuffer=i.createFramebuffer();if(oe)for(let $=0,Q=K.length;$<Q;$++){const le=n.get(K[$]);le.__webglTexture===void 0&&(le.__webglTexture=i.createTexture(),a.memory.textures++)}if(T.samples>0&&Et(T)===!1){O.__webglMultisampledFramebuffer=i.createFramebuffer(),O.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let $=0;$<K.length;$++){const Q=K[$];O.__webglColorRenderbuffer[$]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,O.__webglColorRenderbuffer[$]);const le=r.convert(Q.format,Q.colorSpace),Te=r.convert(Q.type),de=M(Q.internalFormat,le,Te,Q.normalized,Q.colorSpace,T.isXRRenderTarget===!0),ce=gt(T);i.renderbufferStorageMultisample(i.RENDERBUFFER,ce,de,T.width,T.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+$,i.RENDERBUFFER,O.__webglColorRenderbuffer[$])}i.bindRenderbuffer(i.RENDERBUFFER,null),T.depthBuffer&&(O.__webglDepthRenderbuffer=i.createRenderbuffer(),Ae(O.__webglDepthRenderbuffer,T,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(se){t.bindTexture(i.TEXTURE_CUBE_MAP,H.__webglTexture),Be(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++)De(O.__webglFramebuffer[$][Q],T,v,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+$,Q);else De(O.__webglFramebuffer[$],T,v,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+$,0);p(v)&&E(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(oe){for(let $=0,Q=K.length;$<Q;$++){const le=K[$],Te=n.get(le);let de=i.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(de=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(de,Te.__webglTexture),Be(de,le),De(O.__webglFramebuffer,T,le,i.COLOR_ATTACHMENT0+$,de,0),p(le)&&E(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),Be($,v),v.mipmaps&&v.mipmaps.length>0)for(let Q=0;Q<v.mipmaps.length;Q++)De(O.__webglFramebuffer[Q],T,v,i.COLOR_ATTACHMENT0,$,Q);else De(O.__webglFramebuffer,T,v,i.COLOR_ATTACHMENT0,$,0);p(v)&&E($),t.unbindTexture()}T.depthBuffer&&Ie(T)}function Je(T){const v=T.textures;for(let O=0,H=v.length;O<H;O++){const K=v[O];if(p(K)){const se=A(T),oe=n.get(K).__webglTexture;t.bindTexture(se,oe),E(se),t.unbindTexture()}}}const Qe=[],mt=[];function dt(T){if(T.samples>0){if(Et(T)===!1){const v=T.textures,O=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 le=0;le<v.length;le++)t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+le,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+le,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 le=0;le<v.length;le++){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[le]);const Te=n.get(v[le]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Te,0)}i.blitFramebuffer(0,0,O,H,0,0,O,H,K,i.NEAREST),l===!0&&(Qe.length=0,mt.length=0,Qe.push(i.COLOR_ATTACHMENT0+le),T.depthBuffer&&T.resolveDepthBuffer===!1&&(Qe.push(se),mt.push(se),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,mt)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,Qe))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),$)for(let le=0;le<v.length;le++){t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+le,i.RENDERBUFFER,oe.__webglColorRenderbuffer[le]);const Te=n.get(v[le]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+le,i.TEXTURE_2D,Te,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&l){const v=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[v])}}}function gt(T){return Math.min(s.maxSamples,T.samples)}function Et(T){const v=n.get(T);return T.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function L(T){const v=a.render.frame;h.get(T)!==v&&(h.set(T,v),T.update())}function jt(T,v){const O=T.colorSpace,H=T.format,K=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||O!==Ka&&O!==bi&&(Ke.getTransfer(O)===et?(H!==pn||K!==dn)&&Oe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ye("WebGLTextures: Unsupported texture color space:",O)),v}function je(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(c.width=T.naturalWidth||T.width,c.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(c.width=T.displayWidth,c.height=T.displayHeight):(c.width=T.width,c.height=T.height),c}this.allocateTextureUnit=q,this.resetTextureUnits=W,this.getTextureUnits=X,this.setTextureUnits=F,this.setTexture2D=Z,this.setTexture2DArray=te,this.setTexture3D=j,this.setTextureCube=ie,this.rebindTextures=Ne,this.setupRenderTarget=Ue,this.updateRenderTargetMipmap=Je,this.updateMultisampleRenderTarget=dt,this.setupDepthRenderbuffer=Ie,this.setupFrameBufferTexture=De,this.useMultisampledRTT=Et,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Y_(i,e){function t(n,s=bi){let r;const a=Ke.getTransfer(s);if(n===dn)return i.UNSIGNED_BYTE;if(n===Qc)return i.UNSIGNED_SHORT_4_4_4_4;if(n===jc)return i.UNSIGNED_SHORT_5_5_5_1;if(n===x0)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===M0)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===v0)return i.BYTE;if(n===_0)return i.SHORT;if(n===Ar)return i.UNSIGNED_SHORT;if(n===Jc)return i.INT;if(n===Dn)return i.UNSIGNED_INT;if(n===Xn)return i.FLOAT;if(n===mn)return i.HALF_FLOAT;if(n===y0)return i.ALPHA;if(n===S0)return i.RGB;if(n===pn)return i.RGBA;if(n===oi)return i.DEPTH_COMPONENT;if(n===$i)return i.DEPTH_STENCIL;if(n===b0)return i.RED;if(n===eh)return i.RED_INTEGER;if(n===ji)return i.RG;if(n===th)return i.RG_INTEGER;if(n===nh)return i.RGBA_INTEGER;if(n===Fa||n===Oa||n===za||n===Ba)if(a===et)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Fa)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Oa)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===za)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ba)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Fa)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Oa)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===za)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ba)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Bl||n===kl||n===Hl||n===Gl)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Bl)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===kl)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Hl)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Gl)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Vl||n===Wl||n===Xl||n===ql||n===Yl||n===qa||n===Kl)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Vl||n===Wl)return a===et?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Xl)return a===et?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===ql)return r.COMPRESSED_R11_EAC;if(n===Yl)return r.COMPRESSED_SIGNED_R11_EAC;if(n===qa)return r.COMPRESSED_RG11_EAC;if(n===Kl)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===$l||n===Zl||n===Jl||n===Ql||n===jl||n===ec||n===tc||n===nc||n===ic||n===sc||n===rc||n===ac||n===oc||n===lc)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===$l)return a===et?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Zl)return a===et?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Jl)return a===et?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Ql)return a===et?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===jl)return a===et?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===ec)return a===et?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===tc)return a===et?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===nc)return a===et?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ic)return a===et?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===sc)return a===et?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===rc)return a===et?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ac)return a===et?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===oc)return a===et?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===lc)return a===et?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===cc||n===hc||n===uc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===cc)return a===et?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===hc)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===uc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===dc||n===fc||n===Ya||n===pc)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===dc)return r.COMPRESSED_RED_RGTC1_EXT;if(n===fc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ya)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===pc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Tr?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const K_=`
4733
+ }`,Xx=[new U(1,0,0),new U(-1,0,0),new U(0,1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1)],qx=[new U(0,-1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1),new U(0,-1,0),new U(0,-1,0)],ed=new ht,ur=new U,rl=new U;function Yx(i,e,t){let n=new ph;const s=new Le,r=new Le,a=new pt,o=new ng,l=new ig,c={},h=t.maxTextureSize,u={[Pi]:Pt,[Pt]:Pi,[Tn]:Tn},d=new Et({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Le},radius:{value:4}},vertexShader:Vx,fragmentShader:Wx}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const g=new bt;g.setAttribute("position",new ct(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new Je(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=br;let p=this.type;this.render=function(w,R,x){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||w.length===0)return;this.type===Wp&&(Oe("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=br);const b=i.getRenderTarget(),D=i.getActiveCubeFace(),C=i.getActiveMipmapLevel(),I=i.state;I.setBlending(Kn),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(F=>F.needsUpdate=!0):X.material.needsUpdate=!0)});for(let X=0,F=w.length;X<F;X++){const q=w[X],G=q.shadow;if(G===void 0){Oe("WebGLShadowMap:",q,"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||W===!0){if(G.map!==null&&(G.map.depthTexture!==null&&(G.map.depthTexture.dispose(),G.map.depthTexture=null),G.map.dispose()),this.type===gr){if(q.isPointLight){Oe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}G.map=new an(s.x,s.y,{format:ns,type:Qt,minFilter:Rt,magFilter:Rt,generateMipmaps:!1}),G.map.texture.name=q.name+".shadowMap",G.map.depthTexture=new ss(s.x,s.y,Xn),G.map.depthTexture.name=q.name+".shadowMapDepth",G.map.depthTexture.format=ci,G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Dt,G.map.depthTexture.magFilter=Dt}else q.isPointLight?(G.map=new W0(s.x),G.map.depthTexture=new Zm(s.x,Dn)):(G.map=new an(s.x,s.y),G.map.depthTexture=new ss(s.x,s.y,Dn)),G.map.depthTexture.name=q.name+".shadowMap",G.map.depthTexture.format=ci,this.type===br?(G.map.depthTexture.compareFunction=te?lh:oh,G.map.depthTexture.minFilter=Rt,G.map.depthTexture.magFilter=Rt):(G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Dt,G.map.depthTexture.magFilter=Dt);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,ke=G.matrix,qe=q.distance||ue.far;qe!==ue.far&&(ue.far=qe,ue.updateProjectionMatrix()),ur.setFromMatrixPosition(q.matrixWorld),ue.position.copy(ur),rl.copy(ue.position),rl.add(Xx[ie]),ue.up.copy(qx[ie]),ue.lookAt(rl),ue.updateMatrixWorld(),ke.makeTranslation(-ur.x,-ur.y,-ur.z),ed.multiplyMatrices(ue.projectionMatrix,ue.matrixWorldInverse),G._frustum.setFromProjectionMatrix(ed,ue.coordinateSystem,ue.reversedDepth)}else G.updateMatrices(q);n=G.getFrustum(),M(R,x,G.camera,q,this.type)}G.isPointLightShadow!==!0&&this.type===gr&&E(G,x),G.needsUpdate=!1}p=this.type,m.needsUpdate=!1,i.setRenderTarget(b,D,C)};function E(w,R){const x=e.update(_);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new an(s.x,s.y,{format:ns,type:Qt})),d.uniforms.shadow_pass.value=w.map.depthTexture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,i.setRenderTarget(w.mapPass),i.clear(),i.renderBufferDirect(R,null,x,d,_,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,i.setRenderTarget(w.map),i.clear(),i.renderBufferDirect(R,null,x,f,_,null)}function A(w,R,x,b){let D=null;const C=x.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(C!==void 0)D=C;else if(D=x.isPointLight===!0?l:o,i.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){const I=D.uuid,W=R.uuid;let X=c[I];X===void 0&&(X={},c[I]=X);let F=X[W];F===void 0&&(F=D.clone(),X[W]=F,R.addEventListener("dispose",S)),D=F}if(D.visible=R.visible,D.wireframe=R.wireframe,b===gr?D.side=R.shadowSide!==null?R.shadowSide:R.side:D.side=R.shadowSide!==null?R.shadowSide:u[R.side],D.alphaMap=R.alphaMap,D.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,D.map=R.map,D.clipShadows=R.clipShadows,D.clippingPlanes=R.clippingPlanes,D.clipIntersection=R.clipIntersection,D.displacementMap=R.displacementMap,D.displacementScale=R.displacementScale,D.displacementBias=R.displacementBias,D.wireframeLinewidth=R.wireframeLinewidth,D.linewidth=R.linewidth,x.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const I=i.properties.get(D);I.light=x}return D}function M(w,R,x,b,D){if(w.visible===!1)return;if(w.layers.test(R.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&D===gr)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,w.matrixWorld);const W=e.update(w),X=w.material;if(Array.isArray(X)){const F=W.groups;for(let q=0,G=F.length;q<G;q++){const Z=F[q],te=X[Z.materialIndex];if(te&&te.visible){const j=A(w,te,b,D);w.onBeforeShadow(i,w,R,x,W,j,Z),i.renderBufferDirect(x,null,W,j,w,Z),w.onAfterShadow(i,w,R,x,W,j,Z)}}}else if(X.visible){const F=A(w,X,b,D);w.onBeforeShadow(i,w,R,x,W,F,null),i.renderBufferDirect(x,null,W,F,w,null),w.onAfterShadow(i,w,R,x,W,F,null)}}const I=w.children;for(let W=0,X=I.length;W<X;W++)M(I[W],R,x,b,D)}function S(w){w.target.removeEventListener("dispose",S);for(const x in c){const b=c[x],D=w.target.uuid;D in b&&(b[D].dispose(),delete b[D])}}}function Kx(i,e){function t(){let P=!1;const ae=new pt;let J=null;const he=new pt(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,we,ye,vt){vt===!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(){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 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&&!P&&(i.depthMask(ee),J=ee)},setFunc:function(ee){if(ae&&(ee=bm[ee]),he!==ee){switch(ee){case Ll:i.depthFunc(i.NEVER);break;case Nl:i.depthFunc(i.ALWAYS);break;case Ul:i.depthFunc(i.LESS);break;case $s:i.depthFunc(i.LEQUAL);break;case Fl:i.depthFunc(i.EQUAL);break;case Ol:i.depthFunc(i.GEQUAL);break;case zl:i.depthFunc(i.GREATER);break;case Bl: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,we=null,ye=null,vt=null;return{setTest:function(ot){P||(ot?ne(i.STENCIL_TEST):z(i.STENCIL_TEST))},setMask:function(ot){ae!==ot&&!P&&(i.stencilMask(ot),ae=ot)},setFunc:function(ot,In,Ln){(J!==ot||he!==In||ge!==Ln)&&(i.stencilFunc(ot,In,Ln),J=ot,he=In,ge=Ln)},setOp:function(ot,In,Ln){(ee!==ot||we!==In||ye!==Ln)&&(i.stencilOp(ot,In,Ln),ee=ot,we=In,ye=Ln)},setLocked:function(ot){P=ot},setClear:function(ot){vt!==ot&&(i.clearStencil(ot),vt=ot)},reset:function(){P=!1,ae=null,J=null,he=null,ge=null,ee=null,we=null,ye=null,vt=null}}}const r=new t,a=new n,o=new s,l=new WeakMap,c=new WeakMap;let h={},u={},d={},f=new WeakMap,g=[],_=null,m=!1,p=null,E=null,A=null,M=null,S=null,w=null,R=null,x=new Me(0,0,0),b=0,D=!1,C=null,I=null,W=null,X=null,F=null;const q=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),ke=i.getParameter(i.VIEWPORT),qe=new pt().fromArray(ue),Be=new pt().fromArray(ke);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 we=0;we<J;we++)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+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($s),Qe(!1),je(eu),ne(i.CULL_FACE),Ne(Kn);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 Ee(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 De(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,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 Ae(P){return _!==P?(i.useProgram(P),_=P,!0):!1}const xe={[Yi]:i.FUNC_ADD,[qp]:i.FUNC_SUBTRACT,[Yp]:i.FUNC_REVERSE_SUBTRACT};xe[Kp]=i.MIN,xe[$p]=i.MAX;const Ie={[Zp]:i.ZERO,[Jp]:i.ONE,[Qp]:i.SRC_COLOR,[Pl]:i.SRC_ALPHA,[sm]:i.SRC_ALPHA_SATURATE,[nm]:i.DST_COLOR,[em]:i.DST_ALPHA,[jp]:i.ONE_MINUS_SRC_COLOR,[Il]:i.ONE_MINUS_SRC_ALPHA,[im]:i.ONE_MINUS_DST_COLOR,[tm]:i.ONE_MINUS_DST_ALPHA,[rm]:i.CONSTANT_COLOR,[am]:i.ONE_MINUS_CONSTANT_COLOR,[om]:i.CONSTANT_ALPHA,[lm]:i.ONE_MINUS_CONSTANT_ALPHA};function Ne(P,ae,J,he,ge,ee,we,ye,vt,ot){if(P===Kn){m===!0&&(z(i.BLEND),m=!1);return}if(m===!1&&(ne(i.BLEND),m=!0),P!==Xp){if(P!==p||ot!==D){if((E!==Yi||S!==Yi)&&(i.blendEquation(i.FUNC_ADD),E=Yi,S=Yi),ot)switch(P){case Hs:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case li:i.blendFunc(i.ONE,i.ONE);break;case tu:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case nu:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Ye("WebGLState: Invalid blending: ",P);break}else switch(P){case Hs:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case li:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case tu:Ye("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case nu:Ye("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ye("WebGLState: Invalid blending: ",P);break}A=null,M=null,w=null,R=null,x.set(0,0,0),b=0,p=P,D=ot}return}ge=ge||ae,ee=ee||J,we=we||he,(ae!==E||ge!==S)&&(i.blendEquationSeparate(xe[ae],xe[ge]),E=ae,S=ge),(J!==A||he!==M||ee!==w||we!==R)&&(i.blendFuncSeparate(Ie[J],Ie[he],Ie[ee],Ie[we]),A=J,M=he,w=ee,R=we),(ye.equals(x)===!1||vt!==b)&&(i.blendColor(ye.r,ye.g,ye.b,vt),x.copy(ye),b=vt),p=P,D=!1}function Ue(P,ae){P.side===Tn?z(i.CULL_FACE):ne(i.CULL_FACE);let J=P.side===Pt;ae&&(J=!J),Qe(J),P.blending===Hs&&P.transparent===!1?Ne(Kn):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)),dt(P.polygonOffset,P.polygonOffsetFactor,P.polygonOffsetUnits),P.alphaToCoverage===!0?ne(i.SAMPLE_ALPHA_TO_COVERAGE):z(i.SAMPLE_ALPHA_TO_COVERAGE)}function Qe(P){C!==P&&(P?i.frontFace(i.CW):i.frontFace(i.CCW),C=P)}function je(P){P!==Gp?(ne(i.CULL_FACE),P!==I&&(P===eu?i.cullFace(i.BACK):P===Vp?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):z(i.CULL_FACE),I=P}function mt(P){P!==W&&(G&&i.lineWidth(P),W=P)}function dt(P,ae,J){P?(ne(i.POLYGON_OFFSET_FILL),(X!==ae||F!==J)&&(X=ae,F=J,a.getReversed()&&(ae=-ae),i.polygonOffset(ae,J))):z(i.POLYGON_OFFSET_FILL)}function gt(P){P?ne(i.SCISSOR_TEST):z(i.SCISSOR_TEST)}function wt(P){P===void 0&&(P=i.TEXTURE0+q-1),j!==P&&(i.activeTexture(P),j=P)}function L(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 en(){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 et(){try{i.compressedTexImage2D(...arguments)}catch(P){Ye("WebGLState:",P)}}function T(){try{i.compressedTexImage3D(...arguments)}catch(P){Ye("WebGLState:",P)}}function v(){try{i.texSubImage2D(...arguments)}catch(P){Ye("WebGLState:",P)}}function O(){try{i.texSubImage3D(...arguments)}catch(P){Ye("WebGLState:",P)}}function H(){try{i.compressedTexSubImage2D(...arguments)}catch(P){Ye("WebGLState:",P)}}function K(){try{i.compressedTexSubImage3D(...arguments)}catch(P){Ye("WebGLState:",P)}}function se(){try{i.texStorage2D(...arguments)}catch(P){Ye("WebGLState:",P)}}function oe(){try{i.texStorage3D(...arguments)}catch(P){Ye("WebGLState:",P)}}function $(){try{i.texImage2D(...arguments)}catch(P){Ye("WebGLState:",P)}}function Q(){try{i.texImage3D(...arguments)}catch(P){Ye("WebGLState:",P)}}function le(P){return u[P]!==void 0?u[P]:i.getParameter(P)}function Te(P,ae){u[P]!==ae&&(i.pixelStorei(P,ae),u[P]=ae)}function de(P){qe.equals(P)===!1&&(i.scissor(P.x,P.y,P.z,P.w),qe.copy(P))}function ce(P){Be.equals(P)===!1&&(i.viewport(P.x,P.y,P.z,P.w),Be.copy(P))}function Pe(P,ae){let J=c.get(ae);J===void 0&&(J=new WeakMap,c.set(ae,J));let he=J.get(P);he===void 0&&(he=i.getUniformBlockIndex(ae,P.name),J.set(P,he))}function Fe(P,ae){const he=c.get(ae).get(P);l.get(ae)!==he&&(i.uniformBlockBinding(ae,he,P.__bindingPointIndex),l.set(ae,he))}function He(){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=[],_=null,m=!1,p=null,E=null,A=null,M=null,S=null,w=null,R=null,x=new Me(0,0,0),b=0,D=!1,C=null,I=null,W=null,X=null,F=null,qe.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:Ee,drawBuffers:De,useProgram:Ae,setBlending:Ne,setMaterial:Ue,setFlipSided:Qe,setCullFace:je,setLineWidth:mt,setPolygonOffset:dt,setScissorTest:gt,activeTexture:wt,bindTexture:L,unbindTexture:en,compressedTexImage2D:et,compressedTexImage3D:T,texImage2D:$,texImage3D:Q,pixelStorei:Te,getParameter:le,updateUBOMapping:Pe,uniformBlockBinding:Fe,texStorage2D:se,texStorage3D:oe,texSubImage2D:v,texSubImage3D:O,compressedTexSubImage2D:H,compressedTexSubImage3D:K,scissor:de,viewport:ce,reset:He}}function $x(i,e,t,n,s,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new 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 _(T,v){return g?new OffscreenCanvas(T,v):Qa("canvas")}function m(T,v,O){let H=1;const K=et(T);if((K.width>O||K.height>O)&&(H=O/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=_(se,oe));const $=v?_(se,oe):d;return $.width=se,$.height=oe,$.getContext("2d").drawImage(T,0,0,se,oe),Oe("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+se+"x"+oe+")."),$}else return"data"in T&&Oe("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),T;return T}function p(T){return T.generateMipmaps}function E(T){i.generateMipmap(T)}function A(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,O,H,K,se=!1){if(T!==null){if(i[T]!==void 0)return i[T];Oe("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let oe;H&&(oe=e.get("EXT_texture_norm16"),oe||Oe("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let $=v;if(v===i.RED&&(O===i.FLOAT&&($=i.R32F),O===i.HALF_FLOAT&&($=i.R16F),O===i.UNSIGNED_BYTE&&($=i.R8),O===i.UNSIGNED_SHORT&&oe&&($=oe.R16_EXT),O===i.SHORT&&oe&&($=oe.R16_SNORM_EXT)),v===i.RED_INTEGER&&(O===i.UNSIGNED_BYTE&&($=i.R8UI),O===i.UNSIGNED_SHORT&&($=i.R16UI),O===i.UNSIGNED_INT&&($=i.R32UI),O===i.BYTE&&($=i.R8I),O===i.SHORT&&($=i.R16I),O===i.INT&&($=i.R32I)),v===i.RG&&(O===i.FLOAT&&($=i.RG32F),O===i.HALF_FLOAT&&($=i.RG16F),O===i.UNSIGNED_BYTE&&($=i.RG8),O===i.UNSIGNED_SHORT&&oe&&($=oe.RG16_EXT),O===i.SHORT&&oe&&($=oe.RG16_SNORM_EXT)),v===i.RG_INTEGER&&(O===i.UNSIGNED_BYTE&&($=i.RG8UI),O===i.UNSIGNED_SHORT&&($=i.RG16UI),O===i.UNSIGNED_INT&&($=i.RG32UI),O===i.BYTE&&($=i.RG8I),O===i.SHORT&&($=i.RG16I),O===i.INT&&($=i.RG32I)),v===i.RGB_INTEGER&&(O===i.UNSIGNED_BYTE&&($=i.RGB8UI),O===i.UNSIGNED_SHORT&&($=i.RGB16UI),O===i.UNSIGNED_INT&&($=i.RGB32UI),O===i.BYTE&&($=i.RGB8I),O===i.SHORT&&($=i.RGB16I),O===i.INT&&($=i.RGB32I)),v===i.RGBA_INTEGER&&(O===i.UNSIGNED_BYTE&&($=i.RGBA8UI),O===i.UNSIGNED_SHORT&&($=i.RGBA16UI),O===i.UNSIGNED_INT&&($=i.RGBA32UI),O===i.BYTE&&($=i.RGBA8I),O===i.SHORT&&($=i.RGBA16I),O===i.INT&&($=i.RGBA32I)),v===i.RGB&&(O===i.UNSIGNED_SHORT&&oe&&($=oe.RGB16_EXT),O===i.SHORT&&oe&&($=oe.RGB16_SNORM_EXT),O===i.UNSIGNED_INT_5_9_9_9_REV&&($=i.RGB9_E5),O===i.UNSIGNED_INT_10F_11F_11F_REV&&($=i.R11F_G11F_B10F)),v===i.RGBA){const Q=se?Ja:Ke.getTransfer(K);O===i.FLOAT&&($=i.RGBA32F),O===i.HALF_FLOAT&&($=i.RGBA16F),O===i.UNSIGNED_BYTE&&($=Q===tt?i.SRGB8_ALPHA8:i.RGBA8),O===i.UNSIGNED_SHORT&&oe&&($=oe.RGBA16_EXT),O===i.SHORT&&oe&&($=oe.RGBA16_SNORM_EXT),O===i.UNSIGNED_SHORT_4_4_4_4&&($=i.RGBA4),O===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 O;return T?v===null||v===Dn||v===Pr?O=i.DEPTH24_STENCIL8:v===Xn?O=i.DEPTH32F_STENCIL8:v===Dr&&(O=i.DEPTH24_STENCIL8,Oe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):v===null||v===Dn||v===Pr?O=i.DEPTH_COMPONENT24:v===Xn?O=i.DEPTH_COMPONENT32F:v===Dr&&(O=i.DEPTH_COMPONENT16),O}function w(T,v){return p(T)===!0||T.isFramebufferTexture&&T.minFilter!==Dt&&T.minFilter!==Rt?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),b(v),v.isVideoTexture&&h.delete(v),v.isHTMLTexture&&u.delete(v)}function x(T){const v=T.target;v.removeEventListener("dispose",x),C(v)}function b(T){const v=n.get(T);if(v.__webglInit===void 0)return;const O=T.source,H=f.get(O);if(H){const K=H[v.__cacheKey];K.usedTimes--,K.usedTimes===0&&D(T),Object.keys(H).length===0&&f.delete(O)}n.remove(T)}function D(T){const v=n.get(T);i.deleteTexture(v.__webglTexture);const O=T.source,H=f.get(O);delete H[v.__cacheKey],a.memory.textures--}function C(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 O=T.textures;for(let H=0,K=O.length;H<K;H++){const se=n.get(O[H]);se.__webglTexture&&(i.deleteTexture(se.__webglTexture),a.memory.textures--),n.remove(O[H])}n.remove(T)}let I=0;function W(){I=0}function X(){return I}function F(T){I=T}function q(){const T=I;return T>=s.maxTextures&&Oe("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 O=n.get(T);if(T.isVideoTexture&&L(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&O.__version!==T.version){const H=T.image;if(H===null)Oe("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Oe("WebGLRenderer: Texture marked for update but image is incomplete");else{z(O,T,v);return}}else T.isExternalTexture&&(O.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,O.__webglTexture,i.TEXTURE0+v)}function te(T,v){const O=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&O.__version!==T.version){z(O,T,v);return}else T.isExternalTexture&&(O.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,O.__webglTexture,i.TEXTURE0+v)}function j(T,v){const O=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&O.__version!==T.version){z(O,T,v);return}t.bindTexture(i.TEXTURE_3D,O.__webglTexture,i.TEXTURE0+v)}function ie(T,v){const O=n.get(T);if(T.isCubeDepthTexture!==!0&&T.version>0&&O.__version!==T.version){Ee(O,T,v);return}t.bindTexture(i.TEXTURE_CUBE_MAP,O.__webglTexture,i.TEXTURE0+v)}const ue={[kl]:i.REPEAT,[mn]:i.CLAMP_TO_EDGE,[Hl]:i.MIRRORED_REPEAT},ke={[Dt]:i.NEAREST,[um]:i.NEAREST_MIPMAP_NEAREST,[Kr]:i.NEAREST_MIPMAP_LINEAR,[Rt]:i.LINEAR,[Ao]:i.LINEAR_MIPMAP_NEAREST,[Ji]:i.LINEAR_MIPMAP_LINEAR},qe={[pm]:i.NEVER,[_m]:i.ALWAYS,[mm]:i.LESS,[oh]:i.LEQUAL,[gm]:i.EQUAL,[lh]:i.GEQUAL,[vm]:i.GREATER,[xm]:i.NOTEQUAL};function Be(T,v){if(v.type===Xn&&e.has("OES_texture_float_linear")===!1&&(v.magFilter===Rt||v.magFilter===Ao||v.magFilter===Kr||v.magFilter===Ji||v.minFilter===Rt||v.minFilter===Ao||v.minFilter===Kr||v.minFilter===Ji)&&Oe("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,ke[v.magFilter]),i.texParameteri(T,i.TEXTURE_MIN_FILTER,ke[v.minFilter]),v.compareFunction&&(i.texParameteri(T,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(T,i.TEXTURE_COMPARE_FUNC,qe[v.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===Dt||v.minFilter!==Kr&&v.minFilter!==Ji||v.type===Xn&&e.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||n.get(v).__currentAnisotropy){const O=e.get("EXT_texture_filter_anisotropic");i.texParameterf(T,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,s.getMaxAnisotropy())),n.get(v).__currentAnisotropy=v.anisotropy}}}function Y(T,v){let O=!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++,O=!0),K[se].usedTimes++;const oe=K[T.__cacheKey];oe!==void 0&&(K[T.__cacheKey].usedTimes--,oe.usedTimes===0&&D(v)),T.__cacheKey=se,T.__webglTexture=K[se].texture}return O}function re(T,v,O){return Math.floor(Math.floor(T/O)/v)}function ne(T,v,O,H){const se=T.updateRanges;if(se.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,v.width,v.height,O,H,v.data);else{se.sort((Te,de)=>Te.start-de.start);let oe=0;for(let Te=1;Te<se.length;Te++){const de=se[oe],ce=se[Te],Pe=de.start+de.count,Fe=re(ce.start,v.width,4),He=re(de.start,v.width,4);ce.start<=Pe+1&&Fe===He&&re(ce.start+ce.count-1,v.width,4)===Fe?de.count=Math.max(de.count,ce.start+ce.count-de.start):(++oe,se[oe]=ce)}se.length=oe+1;const $=t.getParameter(i.UNPACK_ROW_LENGTH),Q=t.getParameter(i.UNPACK_SKIP_PIXELS),le=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,v.width);for(let Te=0,de=se.length;Te<de;Te++){const ce=se[Te],Pe=Math.floor(ce.start/4),Fe=Math.ceil(ce.count/4),He=Pe%v.width,P=Math.floor(Pe/v.width),ae=Fe,J=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,He),t.pixelStorei(i.UNPACK_SKIP_ROWS,P),t.texSubImage2D(i.TEXTURE_2D,0,He,P,ae,J,O,H,v.data)}T.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,$),t.pixelStorei(i.UNPACK_SKIP_PIXELS,Q),t.pixelStorei(i.UNPACK_SKIP_ROWS,le)}}function z(T,v,O){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+O);const oe=n.get(se);if(se.version!==oe.__version||K===!0){if(t.activeTexture(i.TEXTURE0+O),(typeof ImageBitmap<"u"&&v.image instanceof ImageBitmap)===!1){const J=Ke.getPrimaries(Ke.workingColorSpace),he=v.colorSpace===wi?null:Ke.getPrimaries(v.colorSpace),ge=v.colorSpace===wi||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=en(v,Q);const le=r.convert(v.format,v.colorSpace),Te=r.convert(v.type);let de=M(v.internalFormat,le,Te,v.normalized,v.colorSpace,v.isVideoTexture);Be(H,v);let ce;const Pe=v.mipmaps,Fe=v.isVideoTexture!==!0,He=oe.__version===void 0||K===!0,P=se.dataReady,ae=w(v,Q);if(v.isDepthTexture)de=S(v.format===Qi,v.type),He&&(Fe?t.texStorage2D(i.TEXTURE_2D,1,de,Q.width,Q.height):t.texImage2D(i.TEXTURE_2D,0,de,Q.width,Q.height,0,le,Te,null));else if(v.isDataTexture)if(Pe.length>0){Fe&&He&&t.texStorage2D(i.TEXTURE_2D,ae,de,Pe[0].width,Pe[0].height);for(let J=0,he=Pe.length;J<he;J++)ce=Pe[J],Fe?P&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,ce.width,ce.height,le,Te,ce.data):t.texImage2D(i.TEXTURE_2D,J,de,ce.width,ce.height,0,le,Te,ce.data);v.generateMipmaps=!1}else Fe?(He&&t.texStorage2D(i.TEXTURE_2D,ae,de,Q.width,Q.height),P&&ne(v,Q,le,Te)):t.texImage2D(i.TEXTURE_2D,0,de,Q.width,Q.height,0,le,Te,Q.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){Fe&&He&&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(ce=Pe[J],v.format!==gn)if(le!==null)if(Fe){if(P)if(v.layerUpdates.size>0){const ge=Pu(ce.width,ce.height,v.format,v.type);for(const ee of v.layerUpdates){const we=ce.data.subarray(ee*ge/ce.data.BYTES_PER_ELEMENT,(ee+1)*ge/ce.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,ee,ce.width,ce.height,1,le,we)}v.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,ce.width,ce.height,Q.depth,le,ce.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,J,de,ce.width,ce.height,Q.depth,0,ce.data,0,0);else Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Fe?P&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,ce.width,ce.height,Q.depth,le,Te,ce.data):t.texImage3D(i.TEXTURE_2D_ARRAY,J,de,ce.width,ce.height,Q.depth,0,le,Te,ce.data)}else{Fe&&He&&t.texStorage2D(i.TEXTURE_2D,ae,de,Pe[0].width,Pe[0].height);for(let J=0,he=Pe.length;J<he;J++)ce=Pe[J],v.format!==gn?le!==null?Fe?P&&t.compressedTexSubImage2D(i.TEXTURE_2D,J,0,0,ce.width,ce.height,le,ce.data):t.compressedTexImage2D(i.TEXTURE_2D,J,de,ce.width,ce.height,0,ce.data):Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Fe?P&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,ce.width,ce.height,le,Te,ce.data):t.texImage2D(i.TEXTURE_2D,J,de,ce.width,ce.height,0,le,Te,ce.data)}else if(v.isDataArrayTexture)if(Fe){if(He&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ae,de,Q.width,Q.height,Q.depth),P)if(v.layerUpdates.size>0){const J=Pu(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,le,Te,ge)}v.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,le,Te,Q.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,de,Q.width,Q.height,Q.depth,0,le,Te,Q.data);else if(v.isData3DTexture)Fe?(He&&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,le,Te,Q.data)):t.texImage3D(i.TEXTURE_3D,0,de,Q.width,Q.height,Q.depth,0,le,Te,Q.data);else if(v.isFramebufferTexture){if(He)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,le,Te,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(Pe.length>0){if(Fe&&He){const J=et(Pe[0]);t.texStorage2D(i.TEXTURE_2D,ae,de,J.width,J.height)}for(let J=0,he=Pe.length;J<he;J++)ce=Pe[J],Fe?P&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,le,Te,ce):t.texImage2D(i.TEXTURE_2D,J,de,le,Te,ce);v.generateMipmaps=!1}else if(Fe){if(He){const J=et(Q);t.texStorage2D(i.TEXTURE_2D,ae,de,J.width,J.height)}P&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,le,Te,Q)}else t.texImage2D(i.TEXTURE_2D,0,de,le,Te,Q);p(v)&&E(H),oe.__version=se.version,v.onUpdate&&v.onUpdate(v)}T.__version=v.version}function Ee(T,v,O){if(v.image.length!==6)return;const H=Y(T,v),K=v.source;t.bindTexture(i.TEXTURE_CUBE_MAP,T.__webglTexture,i.TEXTURE0+O);const se=n.get(K);if(K.version!==se.__version||H===!0){t.activeTexture(i.TEXTURE0+O);const oe=Ke.getPrimaries(Ke.workingColorSpace),$=v.colorSpace===wi?null:Ke.getPrimaries(v.colorSpace),Q=v.colorSpace===wi||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 le=v.isCompressedTexture||v.image[0].isCompressedTexture,Te=v.image[0]&&v.image[0].isDataTexture,de=[];for(let ee=0;ee<6;ee++)!le&&!Te?de[ee]=m(v.image[ee],!0,s.maxCubemapSize):de[ee]=Te?v.image[ee].image:v.image[ee],de[ee]=en(v,de[ee]);const ce=de[0],Pe=r.convert(v.format,v.colorSpace),Fe=r.convert(v.type),He=M(v.internalFormat,Pe,Fe,v.normalized,v.colorSpace),P=v.isVideoTexture!==!0,ae=se.__version===void 0||H===!0,J=K.dataReady;let he=w(v,ce);Be(i.TEXTURE_CUBE_MAP,v);let ge;if(le){P&&ae&&t.texStorage2D(i.TEXTURE_CUBE_MAP,he,He,ce.width,ce.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!==gn?Pe!==null?P?J&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we,0,0,ye.width,ye.height,Pe,ye.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we,He,ye.width,ye.height,0,ye.data):Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):P?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we,0,0,ye.width,ye.height,Pe,Fe,ye.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we,He,ye.width,ye.height,0,Pe,Fe,ye.data)}}}else{if(ge=v.mipmaps,P&&ae){ge.length>0&&he++;const ee=et(de[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,he,He,ee.width,ee.height)}for(let ee=0;ee<6;ee++)if(Te){P?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,de[ee].width,de[ee].height,Pe,Fe,de[ee].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,He,de[ee].width,de[ee].height,0,Pe,Fe,de[ee].data);for(let we=0;we<ge.length;we++){const vt=ge[we].image[ee].image;P?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we+1,0,0,vt.width,vt.height,Pe,Fe,vt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we+1,He,vt.width,vt.height,0,Pe,Fe,vt.data)}}else{P?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,Pe,Fe,de[ee]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,He,Pe,Fe,de[ee]);for(let we=0;we<ge.length;we++){const ye=ge[we];P?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we+1,0,0,Pe,Fe,ye.image[ee]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ee,we+1,He,Pe,Fe,ye.image[ee])}}}p(v)&&E(i.TEXTURE_CUBE_MAP),se.__version=K.version,v.onUpdate&&v.onUpdate(v)}T.__version=v.version}function De(T,v,O,H,K,se){const oe=r.convert(O.format,O.colorSpace),$=r.convert(O.type),Q=M(O.internalFormat,oe,$,O.normalized,O.colorSpace),le=n.get(v),Te=n.get(O);if(Te.__renderTarget=v,!le.__hasExternalTextures){const de=Math.max(1,v.width>>se),ce=Math.max(1,v.height>>se);K===i.TEXTURE_3D||K===i.TEXTURE_2D_ARRAY?t.texImage3D(K,se,Q,de,ce,v.depth,0,oe,$,null):t.texImage2D(K,se,Q,de,ce,0,oe,$,null)}t.bindFramebuffer(i.FRAMEBUFFER,T),wt(v)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,H,K,Te.__webglTexture,0,gt(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,Te.__webglTexture,se),t.bindFramebuffer(i.FRAMEBUFFER,null)}function Ae(T,v,O){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;wt(v)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,gt(v),se,v.width,v.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,gt(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);wt(v)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,gt(v),Q,v.width,v.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,gt(v),Q,v.width,v.height):i.renderbufferStorage(i.RENDERBUFFER,Q,v.width,v.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function xe(T,v,O){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),Be(i.TEXTURE_CUBE_MAP,v.depthTexture);const le=r.convert(v.depthTexture.format),Te=r.convert(v.depthTexture.type);let de;v.depthTexture.format===ci?de=i.DEPTH_COMPONENT24:v.depthTexture.format===Qi&&(de=i.DEPTH24_STENCIL8);for(let ce=0;ce<6;ce++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,de,v.width,v.height,0,le,Te,null)}}else Z(v.depthTexture,0);const se=K.__webglTexture,oe=gt(v),$=H?i.TEXTURE_CUBE_MAP_POSITIVE_X+O:i.TEXTURE_2D,Q=v.depthTexture.format===Qi?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(v.depthTexture.format===ci)wt(v)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Q,$,se,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,Q,$,se,0);else if(v.depthTexture.format===Qi)wt(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 Ie(T){const v=n.get(T),O=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(O)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(O){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(),Ae(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(),Ae(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 Ne(T,v,O){const H=n.get(T);v!==void 0&&De(H.__webglFramebuffer,T,T.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),O!==void 0&&Ie(T)}function Ue(T){const v=T.texture,O=n.get(T),H=n.get(v);T.addEventListener("dispose",x);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){O.__webglFramebuffer=[];for(let $=0;$<6;$++)if(v.mipmaps&&v.mipmaps.length>0){O.__webglFramebuffer[$]=[];for(let Q=0;Q<v.mipmaps.length;Q++)O.__webglFramebuffer[$][Q]=i.createFramebuffer()}else O.__webglFramebuffer[$]=i.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){O.__webglFramebuffer=[];for(let $=0;$<v.mipmaps.length;$++)O.__webglFramebuffer[$]=i.createFramebuffer()}else O.__webglFramebuffer=i.createFramebuffer();if(oe)for(let $=0,Q=K.length;$<Q;$++){const le=n.get(K[$]);le.__webglTexture===void 0&&(le.__webglTexture=i.createTexture(),a.memory.textures++)}if(T.samples>0&&wt(T)===!1){O.__webglMultisampledFramebuffer=i.createFramebuffer(),O.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let $=0;$<K.length;$++){const Q=K[$];O.__webglColorRenderbuffer[$]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,O.__webglColorRenderbuffer[$]);const le=r.convert(Q.format,Q.colorSpace),Te=r.convert(Q.type),de=M(Q.internalFormat,le,Te,Q.normalized,Q.colorSpace,T.isXRRenderTarget===!0),ce=gt(T);i.renderbufferStorageMultisample(i.RENDERBUFFER,ce,de,T.width,T.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+$,i.RENDERBUFFER,O.__webglColorRenderbuffer[$])}i.bindRenderbuffer(i.RENDERBUFFER,null),T.depthBuffer&&(O.__webglDepthRenderbuffer=i.createRenderbuffer(),Ae(O.__webglDepthRenderbuffer,T,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(se){t.bindTexture(i.TEXTURE_CUBE_MAP,H.__webglTexture),Be(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++)De(O.__webglFramebuffer[$][Q],T,v,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+$,Q);else De(O.__webglFramebuffer[$],T,v,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+$,0);p(v)&&E(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(oe){for(let $=0,Q=K.length;$<Q;$++){const le=K[$],Te=n.get(le);let de=i.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(de=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(de,Te.__webglTexture),Be(de,le),De(O.__webglFramebuffer,T,le,i.COLOR_ATTACHMENT0+$,de,0),p(le)&&E(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),Be($,v),v.mipmaps&&v.mipmaps.length>0)for(let Q=0;Q<v.mipmaps.length;Q++)De(O.__webglFramebuffer[Q],T,v,i.COLOR_ATTACHMENT0,$,Q);else De(O.__webglFramebuffer,T,v,i.COLOR_ATTACHMENT0,$,0);p(v)&&E($),t.unbindTexture()}T.depthBuffer&&Ie(T)}function Qe(T){const v=T.textures;for(let O=0,H=v.length;O<H;O++){const K=v[O];if(p(K)){const se=A(T),oe=n.get(K).__webglTexture;t.bindTexture(se,oe),E(se),t.unbindTexture()}}}const je=[],mt=[];function dt(T){if(T.samples>0){if(wt(T)===!1){const v=T.textures,O=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 le=0;le<v.length;le++)t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+le,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+le,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 le=0;le<v.length;le++){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[le]);const Te=n.get(v[le]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Te,0)}i.blitFramebuffer(0,0,O,H,0,0,O,H,K,i.NEAREST),l===!0&&(je.length=0,mt.length=0,je.push(i.COLOR_ATTACHMENT0+le),T.depthBuffer&&T.resolveDepthBuffer===!1&&(je.push(se),mt.push(se),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,mt)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,je))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),$)for(let le=0;le<v.length;le++){t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+le,i.RENDERBUFFER,oe.__webglColorRenderbuffer[le]);const Te=n.get(v[le]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+le,i.TEXTURE_2D,Te,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&l){const v=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[v])}}}function gt(T){return Math.min(s.maxSamples,T.samples)}function wt(T){const v=n.get(T);return T.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function L(T){const v=a.render.frame;h.get(T)!==v&&(h.set(T,v),T.update())}function en(T,v){const O=T.colorSpace,H=T.format,K=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||O!==Za&&O!==wi&&(Ke.getTransfer(O)===tt?(H!==gn||K!==pn)&&Oe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ye("WebGLTextures: Unsupported texture color space:",O)),v}function et(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(c.width=T.naturalWidth||T.width,c.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(c.width=T.displayWidth,c.height=T.displayHeight):(c.width=T.width,c.height=T.height),c}this.allocateTextureUnit=q,this.resetTextureUnits=W,this.getTextureUnits=X,this.setTextureUnits=F,this.setTexture2D=Z,this.setTexture2DArray=te,this.setTexture3D=j,this.setTextureCube=ie,this.rebindTextures=Ne,this.setupRenderTarget=Ue,this.updateRenderTargetMipmap=Qe,this.updateMultisampleRenderTarget=dt,this.setupDepthRenderbuffer=Ie,this.setupFrameBufferTexture=De,this.useMultisampledRTT=wt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Zx(i,e){function t(n,s=wi){let r;const a=Ke.getTransfer(s);if(n===pn)return i.UNSIGNED_BYTE;if(n===nh)return i.UNSIGNED_SHORT_4_4_4_4;if(n===ih)return i.UNSIGNED_SHORT_5_5_5_1;if(n===E0)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===w0)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===S0)return i.BYTE;if(n===b0)return i.SHORT;if(n===Dr)return i.UNSIGNED_SHORT;if(n===th)return i.INT;if(n===Dn)return i.UNSIGNED_INT;if(n===Xn)return i.FLOAT;if(n===Qt)return i.HALF_FLOAT;if(n===A0)return i.ALPHA;if(n===T0)return i.RGB;if(n===gn)return i.RGBA;if(n===ci)return i.DEPTH_COMPONENT;if(n===Qi)return i.DEPTH_STENCIL;if(n===R0)return i.RED;if(n===sh)return i.RED_INTEGER;if(n===ns)return i.RG;if(n===rh)return i.RG_INTEGER;if(n===ah)return i.RGBA_INTEGER;if(n===Ba||n===ka||n===Ha||n===Ga)if(a===tt)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Ba)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===ka)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Ha)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ga)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Ba)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===ka)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Ha)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ga)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Gl||n===Vl||n===Wl||n===Xl)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Gl)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Vl)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Wl)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Xl)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ql||n===Yl||n===Kl||n===$l||n===Zl||n===Ka||n===Jl)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===ql||n===Yl)return a===tt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Kl)return a===tt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===$l)return r.COMPRESSED_R11_EAC;if(n===Zl)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Ka)return r.COMPRESSED_RG11_EAC;if(n===Jl)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Ql||n===jl||n===ec||n===tc||n===nc||n===ic||n===sc||n===rc||n===ac||n===oc||n===lc||n===cc||n===hc||n===uc)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Ql)return a===tt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===jl)return a===tt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===ec)return a===tt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===tc)return a===tt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===nc)return a===tt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===ic)return a===tt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===sc)return a===tt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===rc)return a===tt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ac)return a===tt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===oc)return a===tt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===lc)return a===tt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===cc)return a===tt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===hc)return a===tt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===uc)return a===tt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===dc||n===fc||n===pc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===dc)return a===tt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===fc)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===pc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===mc||n===gc||n===$a||n===vc)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===mc)return r.COMPRESSED_RED_RGTC1_EXT;if(n===gc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===$a)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===vc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Pr?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const Jx=`
4734
4734
  void main() {
4735
4735
 
4736
4736
  gl_Position = vec4( position, 1.0 );
4737
4737
 
4738
- }`,$_=`
4738
+ }`,Qx=`
4739
4739
  uniform sampler2DArray depthColor;
4740
4740
  uniform float depthWidth;
4741
4741
  uniform float depthHeight;
@@ -4754,7 +4754,37 @@ void main() {
4754
4754
 
4755
4755
  }
4756
4756
 
4757
- }`;class Z_{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new I0(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 It({vertexShader:K_,fragmentShader:$_,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new nt(new as(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class J_ extends ss{constructor(e,t){super();const n=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,f=null,g=null;const x=typeof XRWebGLBinding<"u",m=new Z_,p={},E=t.getContextAttributes();let A=null,M=null;const S=[],w=[],R=new Le;let _=null;const b=new un;b.viewport=new pt;const D=new un;D.viewport=new pt;const C=[b,D],I=new og;let W=null,X=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let re=S[Y];return re===void 0&&(re=new Po,S[Y]=re),re.getTargetRaySpace()},this.getControllerGrip=function(Y){let re=S[Y];return re===void 0&&(re=new Po,S[Y]=re),re.getGripSpace()},this.getHand=function(Y){let re=S[Y];return re===void 0&&(re=new Po,S[Y]=re),re.getHandSpace()};function F(Y){const re=w.indexOf(Y.inputSource);if(re===-1)return;const ne=S[re];ne!==void 0&&(ne.update(Y.inputSource,Y.frame,c||a),ne.dispatchEvent({type:Y.type,data:Y.inputSource}))}function q(){s.removeEventListener("select",F),s.removeEventListener("selectstart",F),s.removeEventListener("selectend",F),s.removeEventListener("squeeze",F),s.removeEventListener("squeezestart",F),s.removeEventListener("squeezeend",F),s.removeEventListener("end",q),s.removeEventListener("inputsourceschange",G);for(let Y=0;Y<S.length;Y++){const re=w[Y];re!==null&&(w[Y]=null,S[Y].disconnect(re))}W=null,X=null,m.reset();for(const Y in p)delete p[Y];e.setRenderTarget(A),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&&Oe("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,n.isPresenting===!0&&Oe("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(Y){c=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(A=e.getRenderTarget(),s.addEventListener("select",F),s.addEventListener("selectstart",F),s.addEventListener("selectend",F),s.addEventListener("squeeze",F),s.addEventListener("squeezestart",F),s.addEventListener("squeezeend",F),s.addEventListener("end",q),s.addEventListener("inputsourceschange",G),E.xrCompatible!==!0&&await t.makeXRCompatible(),_=e.getPixelRatio(),e.getSize(R),x&&"createProjectionLayer"in XRWebGLBinding.prototype){let ne=null,z=null,Ee=null;E.depth&&(Ee=E.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ne=E.stencil?$i:oi,z=E.stencil?Tr:Dn);const De={colorFormat:t.RGBA8,depthFormat:Ee,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(De),s.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),M=new Sn(d.textureWidth,d.textureHeight,{format:pn,type:dn,depthTexture:new ts(d.textureWidth,d.textureHeight,z,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:E.stencil,colorSpace:e.outputColorSpace,samples:E.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const ne={antialias:E.antialias,alpha:!0,depth:E.depth,stencil:E.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 Sn(f.framebufferWidth,f.framebufferHeight,{format:pn,type:dn,colorSpace:e.outputColorSpace,stencilBuffer:E.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(l),c=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=w.indexOf(ne);z>=0&&(w[z]=null,S[z].disconnect(ne))}for(let re=0;re<Y.added.length;re++){const ne=Y.added[re];let z=w.indexOf(ne);if(z===-1){for(let De=0;De<S.length;De++)if(De>=w.length){w.push(ne),z=De;break}else if(w[De]===null){w[De]=ne,z=De;break}if(z===-1)break}const Ee=S[z];Ee&&Ee.connect(ne)}}const Z=new U,te=new U;function j(Y,re,ne){Z.setFromMatrixPosition(re.matrixWorld),te.setFromMatrixPosition(ne.matrixWorld);const z=Z.distanceTo(te),Ee=re.projectionMatrix.elements,De=ne.projectionMatrix.elements,Ae=Ee[14]/(Ee[10]-1),_e=Ee[14]/(Ee[10]+1),Ie=(Ee[9]+1)/Ee[5],Ne=(Ee[9]-1)/Ee[5],Ue=(Ee[8]-1)/Ee[0],Je=(De[8]+1)/De[0],Qe=Ae*Ue,mt=Ae*Je,dt=z/(-Ue+Je),gt=dt*-Ue;if(re.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(gt),Y.translateZ(dt),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),Ee[10]===-1)Y.projectionMatrix.copy(re.projectionMatrix),Y.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{const Et=Ae+dt,L=_e+dt,jt=Qe-gt,je=mt+(z-gt),T=Ie*_e/L*Et,v=Ne*_e/L*Et;Y.projectionMatrix.makePerspective(jt,je,T,v,Et,L),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=D.near=b.near=re,I.far=D.far=b.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,b.layers.mask=I.layers.mask&-5,D.layers.mask=I.layers.mask&-3;const z=Y.parent,Ee=I.cameras;ie(I,z);for(let De=0;De<Ee.length;De++)ie(Ee[De],z);Ee.length===2?j(I,b,D):I.projectionMatrix.copy(b.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=vc*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 l},this.setFoveation=function(Y){l=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 ke=null;function qe(Y,re){if(h=re.getViewerPose(c||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 Je=u.getViewSubImage(d,Ie);Ne=Je.viewport,_e===0&&(e.setRenderTargetTextures(M,Je.colorTexture,Je.depthStencilTexture),e.setRenderTarget(M))}let Ue=C[_e];Ue===void 0&&(Ue=new un,Ue.layers.enable(_e),Ue.viewport=new pt,C[_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 Ee=s.enabledFeatures;if(Ee&&Ee.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(Ee&&Ee.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 I0,p[Ie]=Ne);const Ue=u.getCameraImage(Ie);Ne.sourceTexture=Ue}}}}for(let ne=0;ne<S.length;ne++){const z=w[ne],Ee=S[ne];z!==null&&Ee!==void 0&&Ee.update(z,re,c||a)}ke&&ke(Y,re),re.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:re}),g=null}const Be=new O0;Be.setAnimationLoop(qe),this.setAnimationLoop=function(Y){ke=Y},this.dispose=function(){}}}const Q_=new ht,W0=new ze;W0.set(-1,0,0,0,1,0,0,0,1);function j_(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,L0(i)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function s(m,p,E,A,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?l(m,p,E,A):p.isSpriteMaterial?c(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,t(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===Dt&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,t(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===Dt&&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 E=e.get(p),A=E.envMap,M=E.envMapRotation;A&&(m.envMap.value=A,m.envMapRotation.value.setFromMatrix4(Q_.makeRotationFromEuler(M)).transpose(),A.isCubeTexture&&A.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(W0),m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,m.aoMapTransform))}function a(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform))}function o(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function l(m,p,E,A){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*E,m.scale.value=A*.5,p.map&&(m.map.value=p.map,t(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function c(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function h(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function u(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function d(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,E){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===Dt&&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=E.texture,m.transmissionSamplerSize.value.set(E.width,E.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 E=e.get(p).light;m.referencePosition.value.setFromMatrixPosition(E.matrixWorld),m.nearDistance.value=E.shadow.camera.near,m.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function ex(i,e,t,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(M,S){const w=S.program;n.uniformBlockBinding(M,w)}function c(M,S){let w=s[M.id];w===void 0&&(m(M),w=h(M),s[M.id]=w,M.addEventListener("dispose",E));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 w=i.createBuffer(),R=M.__size,_=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,w),i.bufferData(i.UNIFORM_BUFFER,R,_),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,S,w),w}function u(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.push(M),M;return Ye("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(M){const S=s[M.id],w=M.uniforms,R=M.__cache;i.bindBuffer(i.UNIFORM_BUFFER,S);for(let _=0,b=w.length;_<b;_++){const D=w[_];if(Array.isArray(D))for(let C=0,I=D.length;C<I;C++)f(D[C],_,C,R);else f(D,_,0,R)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function f(M,S,w,R){if(x(M,S,w,R)===!0){const _=M.__offset,b=M.value;if(Array.isArray(b)){let D=0;for(let C=0;C<b.length;C++){const I=b[C],W=p(I);g(I,M.__data,D),typeof I!="number"&&typeof I!="boolean"&&!I.isMatrix3&&!ArrayBuffer.isView(I)&&(D+=W.storage/Float32Array.BYTES_PER_ELEMENT)}}else g(b,M.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,_,M.__data)}}function g(M,S,w){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,w)}function x(M,S,w,R){const _=M.value,b=S+"_"+w;if(R[b]===void 0)return typeof _=="number"||typeof _=="boolean"?R[b]=_:ArrayBuffer.isView(_)?R[b]=_.slice():R[b]=_.clone(),!0;{const D=R[b];if(typeof _=="number"||typeof _=="boolean"){if(D!==_)return R[b]=_,!0}else{if(ArrayBuffer.isView(_))return!0;if(D.equals(_)===!1)return D.copy(_),!0}}return!1}function m(M){const S=M.uniforms;let w=0;const R=16;for(let b=0,D=S.length;b<D;b++){const C=Array.isArray(S[b])?S[b]:[S[b]];for(let I=0,W=C.length;I<W;I++){const X=C[I],F=Array.isArray(X.value)?X.value:[X.value];for(let q=0,G=F.length;q<G;q++){const Z=F[q],te=p(Z),j=w%R,ie=j%te.boundary,ue=j+ie;w+=ie,ue!==0&&R-ue<te.storage&&(w+=R-ue),X.__data=new Float32Array(te.storage/Float32Array.BYTES_PER_ELEMENT),X.__offset=w,w+=te.storage}}}const _=w%R;return _>0&&(w+=R-_),M.__size=w,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?Oe("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(S.boundary=16,S.storage=M.byteLength):Oe("WebGLRenderer: Unsupported uniform value type.",M),S}function E(M){const S=M.target;S.removeEventListener("dispose",E);const w=a.indexOf(S.__bindingPointIndex);a.splice(w,1),i.deleteBuffer(s[S.id]),delete s[S.id],delete r[S.id]}function A(){for(const M in s)i.deleteBuffer(s[M]);a=[],s={},r={}}return{bind:l,update:c,dispose:A}}const tx=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 Fn=null;function nx(){return Fn===null&&(Fn=new hh(tx,16,16,ji,mn),Fn.name="DFG_LUT",Fn.minFilter=Tt,Fn.magFilter=Tt,Fn.wrapS=fn,Fn.wrapT=fn,Fn.generateMipmaps=!1,Fn.needsUpdate=!0),Fn}class ix{constructor(e={}){const{canvas:t=_m(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=dn}=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([nh,th,eh]),p=new Set([dn,Dn,Ar,Tr,Qc,jc]),E=new Uint32Array(4),A=new Int32Array(4),M=new U;let S=null,w=null;const R=[],_=[];let b=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=Kn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const D=this;let C=!1,I=null,W=null,X=null,F=null;this._outputColorSpace=Mn;let q=0,G=0,Z=null,te=-1,j=null;const ie=new pt,ue=new pt;let ke=null;const qe=new Me(0);let Be=0,Y=t.width,re=t.height,ne=1,z=null,Ee=null;const De=new pt(0,0,Y,re),Ae=new pt(0,0,Y,re);let _e=!1;const Ie=new uh;let Ne=!1,Ue=!1;const Je=new ht,Qe=new U,mt=new pt,dt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let gt=!1;function Et(){return Z===null?ne:1}let L=n;function jt(y,N){return t.getContext(y,N)}try{const y={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${$c}`),t.addEventListener("webglcontextlost",vt,!1),t.addEventListener("webglcontextrestored",ot,!1),t.addEventListener("webglcontextcreationerror",In,!1),L===null){const N="webgl2";if(L=jt(N,y),L===null)throw jt(N)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(y){throw Ye("WebGLRenderer: "+y.message),y}let je,T,v,O,H,K,se,oe,$,Q,le,Te,de,ce,Pe,Fe,He,P,ae,J,he,ge,ee;function we(){je=new nv(L),je.init(),he=new Y_(L,je),T=new K2(L,je,e,he),v=new X_(L,je),T.reversedDepthBuffer&&d&&v.buffers.depth.setReversed(!0),W=L.createFramebuffer(),X=L.createFramebuffer(),F=L.createFramebuffer(),O=new rv(L),H=new P_,K=new q_(L,je,v,H,T,he,O),se=new tv(D),oe=new cg(L),ge=new q2(L,oe),$=new iv(L,oe,O,ge),Q=new ov(L,$,oe,ge,O),P=new av(L,T,K),Pe=new $2(H),le=new D_(D,se,je,T,ge,Pe),Te=new j_(D,H),de=new L_,ce=new B_(je),He=new X2(D,se,v,Q,g,l),Fe=new W_(D,Q,T),ee=new ex(L,O,T,v),ae=new Y2(L,je,O),J=new sv(L,je,O),O.programs=le.programs,D.capabilities=T,D.extensions=je,D.properties=H,D.renderLists=de,D.shadowMap=Fe,D.state=v,D.info=O}we(),x!==dn&&(b=new cv(x,t.width,t.height,o,s,r));const ye=new J_(D,L);this.xr=ye,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){const y=je.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){const y=je.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,N,V=!0){if(ye.isPresenting){Oe("WebGLRenderer: Can't change size while VR device is presenting.");return}Y=y,re=N,t.width=Math.floor(y*ne),t.height=Math.floor(N*ne),V===!0&&(t.style.width=y+"px",t.style.height=N+"px"),b!==null&&b.setSize(t.width,t.height),this.setViewport(0,0,y,N)},this.getDrawingBufferSize=function(y){return y.set(Y*ne,re*ne).floor()},this.setDrawingBufferSize=function(y,N,V){Y=y,re=N,ne=V,t.width=Math.floor(y*V),t.height=Math.floor(N*V),this.setViewport(0,0,y,N)},this.setEffects=function(y){if(x===dn){Ye("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(y){for(let N=0;N<y.length;N++)if(y[N].isOutputPass===!0){Oe("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}b.setEffects(y||[])},this.getCurrentViewport=function(y){return y.copy(ie)},this.getViewport=function(y){return y.copy(De)},this.setViewport=function(y,N,V,B){y.isVector4?De.set(y.x,y.y,y.z,y.w):De.set(y,N,V,B),v.viewport(ie.copy(De).multiplyScalar(ne).round())},this.getScissor=function(y){return y.copy(Ae)},this.setScissor=function(y,N,V,B){y.isVector4?Ae.set(y.x,y.y,y.z,y.w):Ae.set(y,N,V,B),v.scissor(ue.copy(Ae).multiplyScalar(ne).round())},this.getScissorTest=function(){return _e},this.setScissorTest=function(y){v.setScissorTest(_e=y)},this.setOpaqueSort=function(y){z=y},this.setTransparentSort=function(y){Ee=y},this.getClearColor=function(y){return y.copy(He.getClearColor())},this.setClearColor=function(){He.setClearColor(...arguments)},this.getClearAlpha=function(){return He.getClearAlpha()},this.setClearAlpha=function(){He.setClearAlpha(...arguments)},this.clear=function(y=!0,N=!0,V=!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,xe=p.has(me),pe=He.getClearColor(),be=He.getClearAlpha(),Re=pe.r,Ge=pe.g,We=pe.b;xe?(E[0]=Re,E[1]=Ge,E[2]=We,E[3]=be,L.clearBufferuiv(L.COLOR,0,E)):(A[0]=Re,A[1]=Ge,A[2]=We,A[3]=be,L.clearBufferiv(L.COLOR,0,A))}else B|=L.COLOR_BUFFER_BIT}N&&(B|=L.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),V&&(B|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B!==0&&L.clear(B)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(y){y.setRenderer(this),I=y},this.dispose=function(){t.removeEventListener("webglcontextlost",vt,!1),t.removeEventListener("webglcontextrestored",ot,!1),t.removeEventListener("webglcontextcreationerror",In,!1),He.dispose(),de.dispose(),ce.dispose(),H.dispose(),se.dispose(),Q.dispose(),ge.dispose(),ee.dispose(),le.dispose(),ye.dispose(),ye.removeEventListener("sessionstart",bh),ye.removeEventListener("sessionend",Eh),Ni.stop()};function vt(y){y.preventDefault(),Ja("WebGLRenderer: Context Lost."),C=!0}function ot(){Ja("WebGLRenderer: Context Restored."),C=!1;const y=O.autoReset,N=Fe.enabled,V=Fe.autoUpdate,B=Fe.needsUpdate,k=Fe.type;we(),O.autoReset=y,Fe.enabled=N,Fe.autoUpdate=V,Fe.needsUpdate=B,Fe.type=k}function In(y){Ye("WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function Ln(y){const N=y.target;N.removeEventListener("dispose",Ln),Uf(N)}function Uf(y){Ff(y),H.remove(y)}function Ff(y){const N=H.get(y).programs;N!==void 0&&(N.forEach(function(V){le.releaseProgram(V)}),y.isShaderMaterial&&le.releaseShaderCache(y))}this.renderBufferDirect=function(y,N,V,B,k,me){N===null&&(N=dt);const xe=k.isMesh&&k.matrixWorld.determinantAffine()<0,pe=Bf(y,N,V,B,k);v.setMaterial(B,xe);let be=V.index,Re=1;if(B.wireframe===!0){if(be=$.getWireframeAttribute(V),be===void 0)return;Re=2}const Ge=V.drawRange,We=V.attributes.position;let Ce=Ge.start*Re,it=(Ge.start+Ge.count)*Re;me!==null&&(Ce=Math.max(Ce,me.start*Re),it=Math.min(it,(me.start+me.count)*Re)),be!==null?(Ce=Math.max(Ce,0),it=Math.min(it,be.count)):We!=null&&(Ce=Math.max(Ce,0),it=Math.min(it,We.count));const Mt=it-Ce;if(Mt<0||Mt===1/0)return;ge.setup(k,B,pe,V,be);let _t,rt=ae;if(be!==null&&(_t=oe.get(be),rt=J,rt.setIndex(_t)),k.isMesh)B.wireframe===!0?(v.setLineWidth(B.wireframeLinewidth*Et()),rt.setMode(L.LINES)):rt.setMode(L.TRIANGLES);else if(k.isLine){let Gt=B.linewidth;Gt===void 0&&(Gt=1),v.setLineWidth(Gt*Et()),k.isLineSegments?rt.setMode(L.LINES):k.isLineLoop?rt.setMode(L.LINE_LOOP):rt.setMode(L.LINE_STRIP)}else k.isPoints?rt.setMode(L.POINTS):k.isSprite&&rt.setMode(L.TRIANGLES);if(k.isBatchedMesh)if(je.get("WEBGL_multi_draw"))rt.renderMultiDraw(k._multiDrawStarts,k._multiDrawCounts,k._multiDrawCount);else{const Gt=k._multiDrawStarts,ve=k._multiDrawCounts,rn=k._multiDrawCount,$e=be?oe.get(be).bytesPerElement:1,gn=H.get(B).currentProgram.getUniforms();for(let Nn=0;Nn<rn;Nn++)gn.setValue(L,"_gl_DrawID",Nn),rt.render(Gt[Nn]/$e,ve[Nn])}else if(k.isInstancedMesh)rt.renderInstances(Ce,Mt,k.count);else if(V.isInstancedBufferGeometry){const Gt=V._maxInstanceCount!==void 0?V._maxInstanceCount:1/0,ve=Math.min(V.instanceCount,Gt);rt.renderInstances(Ce,Mt,ve)}else rt.render(Ce,Mt)};function Sh(y,N,V){y.transparent===!0&&y.side===Tn&&y.forceSinglePass===!1?(y.side=Dt,y.needsUpdate=!0,Or(y,N,V),y.side=Ci,y.needsUpdate=!0,Or(y,N,V),y.side=Tn):Or(y,N,V)}this.compile=function(y,N,V=null){V===null&&(V=y),w=ce.get(V),w.init(N),_.push(w),V.traverseVisible(function(k){k.isLight&&k.layers.test(N.layers)&&(w.pushLight(k),k.castShadow&&w.pushShadow(k))}),y!==V&&y.traverseVisible(function(k){k.isLight&&k.layers.test(N.layers)&&(w.pushLight(k),k.castShadow&&w.pushShadow(k))}),w.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 xe=0;xe<me.length;xe++){const pe=me[xe];Sh(pe,V,k),B.add(pe)}else Sh(me,V,k),B.add(me)}),w=_.pop(),B},this.compileAsync=function(y,N,V=null){const B=this.compile(y,N,V);return new Promise(k=>{function me(){if(B.forEach(function(xe){H.get(xe).currentProgram.isReady()&&B.delete(xe)}),B.size===0){k(y);return}setTimeout(me,10)}je.get("KHR_parallel_shader_compile")!==null?me():setTimeout(me,10)})};let _o=null;function Of(y){_o&&_o(y)}function bh(){Ni.stop()}function Eh(){Ni.start()}const Ni=new O0;Ni.setAnimationLoop(Of),typeof self<"u"&&Ni.setContext(self),this.setAnimationLoop=function(y){_o=y,ye.setAnimationLoop(y),y===null?Ni.stop():Ni.start()},ye.addEventListener("sessionstart",bh),ye.addEventListener("sessionend",Eh),this.render=function(y,N){if(N!==void 0&&N.isCamera!==!0){Ye("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;I!==null&&I.renderStart(y,N);const V=ye.enabled===!0&&ye.isPresenting===!0,B=b!==null&&(Z===null||V)&&b.begin(D,Z);if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),N.parent===null&&N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),ye.enabled===!0&&ye.isPresenting===!0&&(b===null||b.isCompositing()===!1)&&(ye.cameraAutoUpdate===!0&&ye.updateCamera(N),N=ye.getCamera()),y.isScene===!0&&y.onBeforeRender(D,y,N,Z),w=ce.get(y,_.length),w.init(N),w.state.textureUnits=K.getTextureUnits(),_.push(w),Je.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),Ie.setFromProjectionMatrix(Je,qn,N.reversedDepth),Ue=this.localClippingEnabled,Ne=Pe.init(this.clippingPlanes,Ue),S=de.get(y,R.length),S.init(),R.push(S),ye.enabled===!0&&ye.isPresenting===!0){const xe=D.xr.getDepthSensingMesh();xe!==null&&xo(xe,N,-1/0,D.sortObjects)}xo(y,N,0,D.sortObjects),S.finish(),D.sortObjects===!0&&S.sort(z,Ee,N.reversedDepth),gt=ye.enabled===!1||ye.isPresenting===!1||ye.hasDepthSensing()===!1,gt&&He.addToRenderList(S,y),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Ne===!0&&Pe.beginShadows();const k=w.state.shadowsArray;if(Fe.render(k,y,N),Ne===!0&&Pe.endShadows(),(B&&b.hasRenderPass())===!1){const xe=S.opaque,pe=S.transmissive;if(w.setupLights(),N.isArrayCamera){const be=N.cameras;if(pe.length>0)for(let Re=0,Ge=be.length;Re<Ge;Re++){const We=be[Re];Ah(xe,pe,y,We)}gt&&He.render(y);for(let Re=0,Ge=be.length;Re<Ge;Re++){const We=be[Re];wh(S,y,We,We.viewport)}}else pe.length>0&&Ah(xe,pe,y,N),gt&&He.render(y),wh(S,y,N)}Z!==null&&G===0&&(K.updateMultisampleRenderTarget(Z),K.updateRenderTargetMipmap(Z)),B&&b.end(D),y.isScene===!0&&y.onAfterRender(D,y,N),ge.resetDefaultState(),te=-1,j=null,_.pop(),_.length>0?(w=_[_.length-1],K.setTextureUnits(w.state.textureUnits),Ne===!0&&Pe.setGlobalState(D.clippingPlanes,w.state.camera)):w=null,R.pop(),R.length>0?S=R[R.length-1]:S=null,I!==null&&I.renderEnd()};function xo(y,N,V,B){if(y.visible===!1)return;if(y.layers.test(N.layers)){if(y.isGroup)V=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(N);else if(y.isLightProbeGrid)w.pushLightProbeGrid(y);else if(y.isLight)w.pushLight(y),y.castShadow&&w.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||Ie.intersectsSprite(y)){B&&mt.setFromMatrixPosition(y.matrixWorld).applyMatrix4(Je);const xe=Q.update(y),pe=y.material;pe.visible&&S.push(y,xe,pe,V,mt.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||Ie.intersectsObject(y))){const xe=Q.update(y),pe=y.material;if(B&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),mt.copy(y.boundingSphere.center)):(xe.boundingSphere===null&&xe.computeBoundingSphere(),mt.copy(xe.boundingSphere.center)),mt.applyMatrix4(y.matrixWorld).applyMatrix4(Je)),Array.isArray(pe)){const be=xe.groups;for(let Re=0,Ge=be.length;Re<Ge;Re++){const We=be[Re],Ce=pe[We.materialIndex];Ce&&Ce.visible&&S.push(y,xe,Ce,V,mt.z,We)}}else pe.visible&&S.push(y,xe,pe,V,mt.z,null)}}const me=y.children;for(let xe=0,pe=me.length;xe<pe;xe++)xo(me[xe],N,V,B)}function wh(y,N,V,B){const{opaque:k,transmissive:me,transparent:xe}=y;w.setupLightsView(V),Ne===!0&&Pe.setGlobalState(D.clippingPlanes,V),B&&v.viewport(ie.copy(B)),k.length>0&&Fr(k,N,V),me.length>0&&Fr(me,N,V),xe.length>0&&Fr(xe,N,V),v.buffers.depth.setTest(!0),v.buffers.depth.setMask(!0),v.buffers.color.setMask(!0),v.setPolygonOffset(!1)}function Ah(y,N,V,B){if((V.isScene===!0?V.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[B.id]===void 0){const Ce=je.has("EXT_color_buffer_half_float")||je.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[B.id]=new Sn(1,1,{generateMipmaps:!0,type:Ce?mn:dn,minFilter:Ki,samples:Math.max(4,T.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ke.workingColorSpace})}const me=w.state.transmissionRenderTarget[B.id],xe=B.viewport||ie;me.setSize(xe.z*D.transmissionResolutionScale,xe.w*D.transmissionResolutionScale);const pe=D.getRenderTarget(),be=D.getActiveCubeFace(),Re=D.getActiveMipmapLevel();D.setRenderTarget(me),D.getClearColor(qe),Be=D.getClearAlpha(),Be<1&&D.setClearColor(16777215,.5),D.clear(),gt&&He.render(V);const Ge=D.toneMapping;D.toneMapping=Kn;const We=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),w.setupLightsView(B),Ne===!0&&Pe.setGlobalState(D.clippingPlanes,B),Fr(y,V,B),K.updateMultisampleRenderTarget(me),K.updateRenderTargetMipmap(me),je.has("WEBGL_multisampled_render_to_texture")===!1){let Ce=!1;for(let it=0,Mt=N.length;it<Mt;it++){const _t=N[it],{object:rt,geometry:Gt,material:ve,group:rn}=_t;if(ve.side===Tn&&rt.layers.test(B.layers)){const $e=ve.side;ve.side=Dt,ve.needsUpdate=!0,Th(rt,V,B,Gt,ve,rn),ve.side=$e,ve.needsUpdate=!0,Ce=!0}}Ce===!0&&(K.updateMultisampleRenderTarget(me),K.updateRenderTargetMipmap(me))}D.setRenderTarget(pe,be,Re),D.setClearColor(qe,Be),We!==void 0&&(B.viewport=We),D.toneMapping=Ge}function Fr(y,N,V){const B=N.isScene===!0?N.overrideMaterial:null;for(let k=0,me=y.length;k<me;k++){const xe=y[k],{object:pe,geometry:be,group:Re}=xe;let Ge=xe.material;Ge.allowOverride===!0&&B!==null&&(Ge=B),pe.layers.test(V.layers)&&Th(pe,N,V,be,Ge,Re)}}function Th(y,N,V,B,k,me){y.onBeforeRender(D,N,V,B,k,me),y.modelViewMatrix.multiplyMatrices(V.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),k.onBeforeRender(D,N,V,B,y,me),k.transparent===!0&&k.side===Tn&&k.forceSinglePass===!1?(k.side=Dt,k.needsUpdate=!0,D.renderBufferDirect(V,N,B,k,y,me),k.side=Ci,k.needsUpdate=!0,D.renderBufferDirect(V,N,B,k,y,me),k.side=Tn):D.renderBufferDirect(V,N,B,k,y,me),y.onAfterRender(D,N,V,B,k,me)}function Or(y,N,V){N.isScene!==!0&&(N=dt);const B=H.get(y),k=w.state.lights,me=w.state.shadowsArray,xe=k.state.version,pe=le.getParameters(y,k.state,me,N,V,w.state.lightProbeGridArray),be=le.getProgramCacheKey(pe);let Re=B.programs;B.environment=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?N.environment:null,B.fog=N.fog;const Ge=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap;B.envMap=se.get(y.envMap||B.environment,Ge),B.envMapRotation=B.environment!==null&&y.envMap===null?N.environmentRotation:y.envMapRotation,Re===void 0&&(y.addEventListener("dispose",Ln),Re=new Map,B.programs=Re);let We=Re.get(be);if(We!==void 0){if(B.currentProgram===We&&B.lightsStateVersion===xe)return Ch(y,pe),We}else pe.uniforms=le.getUniforms(y),I!==null&&y.isNodeMaterial&&I.build(y,V,pe),y.onBeforeCompile(pe,D),We=le.acquireProgram(pe,be),Re.set(be,We),B.uniforms=pe.uniforms;const Ce=B.uniforms;return(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)&&(Ce.clippingPlanes=Pe.uniform),Ch(y,pe),B.needsLights=Hf(y),B.lightsStateVersion=xe,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=w.state.lightProbeGridArray.length>0,B.currentProgram=We,B.uniformsList=null,We}function Rh(y){if(y.uniformsList===null){const N=y.currentProgram.getUniforms();y.uniformsList=Ha.seqWithValue(N.seq,y.uniforms)}return y.uniformsList}function Ch(y,N){const V=H.get(y);V.outputColorSpace=N.outputColorSpace,V.batching=N.batching,V.batchingColor=N.batchingColor,V.instancing=N.instancing,V.instancingColor=N.instancingColor,V.instancingMorph=N.instancingMorph,V.skinning=N.skinning,V.morphTargets=N.morphTargets,V.morphNormals=N.morphNormals,V.morphColors=N.morphColors,V.morphTargetsCount=N.morphTargetsCount,V.numClippingPlanes=N.numClippingPlanes,V.numIntersection=N.numClipIntersection,V.vertexAlphas=N.vertexAlphas,V.vertexTangents=N.vertexTangents,V.toneMapping=N.toneMapping}function zf(y,N){if(y.length===0)return null;if(y.length===1)return y[0].texture!==null?y[0]:null;M.setFromMatrixPosition(N.matrixWorld);for(let V=0,B=y.length;V<B;V++){const k=y[V];if(k.texture!==null&&k.boundingBox.containsPoint(M))return k}return null}function Bf(y,N,V,B,k){N.isScene!==!0&&(N=dt),K.resetTextureUnits();const me=N.fog,xe=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?N.environment:null,pe=Z===null?D.outputColorSpace:Z.isXRRenderTarget===!0?Z.texture.colorSpace:Ke.workingColorSpace,be=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Re=se.get(B.envMap||xe,be),Ge=B.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,We=!!V.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Ce=!!V.morphAttributes.position,it=!!V.morphAttributes.normal,Mt=!!V.morphAttributes.color;let _t=Kn;B.toneMapped&&(Z===null||Z.isXRRenderTarget===!0)&&(_t=D.toneMapping);const rt=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,Gt=rt!==void 0?rt.length:0,ve=H.get(B),rn=w.state.lights;if(Ne===!0&&(Ue===!0||y!==j)){const lt=y===j&&B.id===te;Pe.setState(B,y,lt)}let $e=!1;B.version===ve.__version?(ve.needsLights&&ve.lightsStateVersion!==rn.state.version||ve.outputColorSpace!==pe||k.isBatchedMesh&&ve.batching===!1||!k.isBatchedMesh&&ve.batching===!0||k.isBatchedMesh&&ve.batchingColor===!0&&k.colorTexture===null||k.isBatchedMesh&&ve.batchingColor===!1&&k.colorTexture!==null||k.isInstancedMesh&&ve.instancing===!1||!k.isInstancedMesh&&ve.instancing===!0||k.isSkinnedMesh&&ve.skinning===!1||!k.isSkinnedMesh&&ve.skinning===!0||k.isInstancedMesh&&ve.instancingColor===!0&&k.instanceColor===null||k.isInstancedMesh&&ve.instancingColor===!1&&k.instanceColor!==null||k.isInstancedMesh&&ve.instancingMorph===!0&&k.morphTexture===null||k.isInstancedMesh&&ve.instancingMorph===!1&&k.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!==Ce||ve.morphNormals!==it||ve.morphColors!==Mt||ve.toneMapping!==_t||ve.morphTargetsCount!==Gt||!!ve.lightProbeGrid!=w.state.lightProbeGridArray.length>0)&&($e=!0):($e=!0,ve.__version=B.version);let gn=ve.currentProgram;$e===!0&&(gn=Or(B,N,k),I&&B.isNodeMaterial&&I.onUpdateProgram(B,gn,ve));let Nn=!1,ci=!1,os=!1;const at=gn.getUniforms(),yt=ve.uniforms;if(v.useProgram(gn.program)&&(Nn=!0,ci=!0,os=!0),B.id!==te&&(te=B.id,ci=!0),ve.needsLights){const lt=zf(w.state.lightProbeGridArray,k);ve.lightProbeGrid!==lt&&(ve.lightProbeGrid=lt,ci=!0)}if(Nn||j!==y){v.buffers.depth.getReversed()&&y.reversedDepth!==!0&&(y._reversedDepth=!0,y.updateProjectionMatrix()),at.setValue(L,"projectionMatrix",y.projectionMatrix),at.setValue(L,"viewMatrix",y.matrixWorldInverse);const ui=at.map.cameraPosition;ui!==void 0&&ui.setValue(L,Qe.setFromMatrixPosition(y.matrixWorld)),T.logarithmicDepthBuffer&&at.setValue(L,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&at.setValue(L,"isOrthographic",y.isOrthographicCamera===!0),j!==y&&(j=y,ci=!0,os=!0)}if(ve.needsLights&&(rn.state.directionalShadowMap.length>0&&at.setValue(L,"directionalShadowMap",rn.state.directionalShadowMap,K),rn.state.spotShadowMap.length>0&&at.setValue(L,"spotShadowMap",rn.state.spotShadowMap,K),rn.state.pointShadowMap.length>0&&at.setValue(L,"pointShadowMap",rn.state.pointShadowMap,K)),k.isSkinnedMesh){at.setOptional(L,k,"bindMatrix"),at.setOptional(L,k,"bindMatrixInverse");const lt=k.skeleton;lt&&(lt.boneTexture===null&&lt.computeBoneTexture(),at.setValue(L,"boneTexture",lt.boneTexture,K))}k.isBatchedMesh&&(at.setOptional(L,k,"batchingTexture"),at.setValue(L,"batchingTexture",k._matricesTexture,K),at.setOptional(L,k,"batchingIdTexture"),at.setValue(L,"batchingIdTexture",k._indirectTexture,K),at.setOptional(L,k,"batchingColorTexture"),k._colorsTexture!==null&&at.setValue(L,"batchingColorTexture",k._colorsTexture,K));const hi=V.morphAttributes;if((hi.position!==void 0||hi.normal!==void 0||hi.color!==void 0)&&P.update(k,V,gn),(ci||ve.receiveShadow!==k.receiveShadow)&&(ve.receiveShadow=k.receiveShadow,at.setValue(L,"receiveShadow",k.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&N.environment!==null&&(yt.envMapIntensity.value=N.environmentIntensity),yt.dfgLUT!==void 0&&(yt.dfgLUT.value=nx()),ci){if(at.setValue(L,"toneMappingExposure",D.toneMappingExposure),ve.needsLights&&kf(yt,os),me&&B.fog===!0&&Te.refreshFogUniforms(yt,me),Te.refreshMaterialUniforms(yt,B,ne,re,w.state.transmissionRenderTarget[y.id]),ve.needsLights&&ve.lightProbeGrid){const lt=ve.lightProbeGrid;yt.probesSH.value=lt.texture,yt.probesMin.value.copy(lt.boundingBox.min),yt.probesMax.value.copy(lt.boundingBox.max),yt.probesResolution.value.copy(lt.resolution)}Ha.upload(L,Rh(ve),yt,K)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(Ha.upload(L,Rh(ve),yt,K),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&at.setValue(L,"center",k.center),at.setValue(L,"modelViewMatrix",k.modelViewMatrix),at.setValue(L,"normalMatrix",k.normalMatrix),at.setValue(L,"modelMatrix",k.matrixWorld),B.uniformsGroups!==void 0){const lt=B.uniformsGroups;for(let ui=0,ls=lt.length;ui<ls;ui++){const Dh=lt[ui];ee.update(Dh,gn),ee.bind(Dh,gn)}}return gn}function kf(y,N){y.ambientLightColor.needsUpdate=N,y.lightProbe.needsUpdate=N,y.directionalLights.needsUpdate=N,y.directionalLightShadows.needsUpdate=N,y.pointLights.needsUpdate=N,y.pointLightShadows.needsUpdate=N,y.spotLights.needsUpdate=N,y.spotLightShadows.needsUpdate=N,y.rectAreaLights.needsUpdate=N,y.hemisphereLights.needsUpdate=N}function Hf(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return q},this.getActiveMipmapLevel=function(){return G},this.getRenderTarget=function(){return Z},this.setRenderTargetTextures=function(y,N,V){const B=H.get(y);B.__autoAllocateDepthBuffer=y.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),H.get(y.texture).__webglTexture=N,H.get(y.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:V,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(y,N){const V=H.get(y);V.__webglFramebuffer=N,V.__useDefaultFramebuffer=N===void 0},this.setRenderTarget=function(y,N=0,V=0){Z=y,q=N,G=V;let B=null,k=!1,me=!1;if(y){const pe=H.get(y);if(pe.__useDefaultFramebuffer!==void 0){v.bindFramebuffer(L.FRAMEBUFFER,pe.__webglFramebuffer),ie.copy(y.viewport),ue.copy(y.scissor),ke=y.scissorTest,v.viewport(ie),v.scissor(ue),v.setScissorTest(ke),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 Ge=y.depthTexture;if(pe.__boundDepthTexture!==Ge){if(Ge!==null&&H.has(Ge)&&(y.width!==Ge.image.width||y.height!==Ge.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");K.setupDepthRenderbuffer(y)}}const be=y.texture;(be.isData3DTexture||be.isDataArrayTexture||be.isCompressedArrayTexture)&&(me=!0);const Re=H.get(y).__webglFramebuffer;y.isWebGLCubeRenderTarget?(Array.isArray(Re[N])?B=Re[N][V]:B=Re[N],k=!0):y.samples>0&&K.useMultisampledRTT(y)===!1?B=H.get(y).__webglMultisampledFramebuffer:Array.isArray(Re)?B=Re[V]:B=Re,ie.copy(y.viewport),ue.copy(y.scissor),ke=y.scissorTest}else ie.copy(De).multiplyScalar(ne).floor(),ue.copy(Ae).multiplyScalar(ne).floor(),ke=_e;if(V!==0&&(B=W),v.bindFramebuffer(L.FRAMEBUFFER,B)&&v.drawBuffers(y,B),v.viewport(ie),v.scissor(ue),v.setScissorTest(ke),k){const pe=H.get(y.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+N,pe.__webglTexture,V)}else if(me){const pe=N;for(let be=0;be<y.textures.length;be++){const Re=H.get(y.textures[be]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+be,Re.__webglTexture,V,pe)}}else if(y!==null&&V!==0){const pe=H.get(y.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,pe.__webglTexture,V)}te=-1},this.readRenderTargetPixels=function(y,N,V,B,k,me,xe,pe=0){if(!(y&&y.isWebGLRenderTarget)){Ye("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let be=H.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&xe!==void 0&&(be=be[xe]),be){v.bindFramebuffer(L.FRAMEBUFFER,be);try{const Re=y.textures[pe],Ge=Re.format,We=Re.type;if(y.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+pe),!T.textureFormatReadable(Ge)){Ye("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!T.textureTypeReadable(We)){Ye("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}N>=0&&N<=y.width-B&&V>=0&&V<=y.height-k&&L.readPixels(N,V,B,k,he.convert(Ge),he.convert(We),me)}finally{const Re=Z!==null?H.get(Z).__webglFramebuffer:null;v.bindFramebuffer(L.FRAMEBUFFER,Re)}}},this.readRenderTargetPixelsAsync=async function(y,N,V,B,k,me,xe,pe=0){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let be=H.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&xe!==void 0&&(be=be[xe]),be)if(N>=0&&N<=y.width-B&&V>=0&&V<=y.height-k){v.bindFramebuffer(L.FRAMEBUFFER,be);const Re=y.textures[pe],Ge=Re.format,We=Re.type;if(y.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+pe),!T.textureFormatReadable(Ge))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!T.textureTypeReadable(We))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ce=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,Ce),L.bufferData(L.PIXEL_PACK_BUFFER,me.byteLength,L.STREAM_READ),L.readPixels(N,V,B,k,he.convert(Ge),he.convert(We),0);const it=Z!==null?H.get(Z).__webglFramebuffer:null;v.bindFramebuffer(L.FRAMEBUFFER,it);const Mt=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await xm(L,Mt,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,Ce),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,me),L.deleteBuffer(Ce),L.deleteSync(Mt),me}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,N=null,V=0){const B=Math.pow(2,-V),k=Math.floor(y.image.width*B),me=Math.floor(y.image.height*B),xe=N!==null?N.x:0,pe=N!==null?N.y:0;K.setTexture2D(y,0),L.copyTexSubImage2D(L.TEXTURE_2D,V,0,0,xe,pe,k,me),v.unbindTexture()},this.copyTextureToTexture=function(y,N,V=null,B=null,k=0,me=0){let xe,pe,be,Re,Ge,We,Ce,it,Mt;const _t=y.isCompressedTexture?y.mipmaps[me]:y.image;if(V!==null)xe=V.max.x-V.min.x,pe=V.max.y-V.min.y,be=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 yt=Math.pow(2,-k);xe=Math.floor(_t.width*yt),pe=Math.floor(_t.height*yt),y.isDataArrayTexture?be=_t.depth:y.isData3DTexture?be=Math.floor(_t.depth*yt):be=1,Re=0,Ge=0,We=0}B!==null?(Ce=B.x,it=B.y,Mt=B.z):(Ce=0,it=0,Mt=0);const rt=he.convert(N.format),Gt=he.convert(N.type);let ve;N.isData3DTexture?(K.setTexture3D(N,0),ve=L.TEXTURE_3D):N.isDataArrayTexture||N.isCompressedArrayTexture?(K.setTexture2DArray(N,0),ve=L.TEXTURE_2D_ARRAY):(K.setTexture2D(N,0),ve=L.TEXTURE_2D),v.activeTexture(L.TEXTURE0),v.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,N.flipY),v.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),v.pixelStorei(L.UNPACK_ALIGNMENT,N.unpackAlignment);const rn=v.getParameter(L.UNPACK_ROW_LENGTH),$e=v.getParameter(L.UNPACK_IMAGE_HEIGHT),gn=v.getParameter(L.UNPACK_SKIP_PIXELS),Nn=v.getParameter(L.UNPACK_SKIP_ROWS),ci=v.getParameter(L.UNPACK_SKIP_IMAGES);v.pixelStorei(L.UNPACK_ROW_LENGTH,_t.width),v.pixelStorei(L.UNPACK_IMAGE_HEIGHT,_t.height),v.pixelStorei(L.UNPACK_SKIP_PIXELS,Re),v.pixelStorei(L.UNPACK_SKIP_ROWS,Ge),v.pixelStorei(L.UNPACK_SKIP_IMAGES,We);const os=y.isDataArrayTexture||y.isData3DTexture,at=N.isDataArrayTexture||N.isData3DTexture;if(y.isDepthTexture){const yt=H.get(y),hi=H.get(N),lt=H.get(yt.__renderTarget),ui=H.get(hi.__renderTarget);v.bindFramebuffer(L.READ_FRAMEBUFFER,lt.__webglFramebuffer),v.bindFramebuffer(L.DRAW_FRAMEBUFFER,ui.__webglFramebuffer);for(let ls=0;ls<be;ls++)os&&(L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,H.get(y).__webglTexture,k,We+ls),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,H.get(N).__webglTexture,me,Mt+ls)),L.blitFramebuffer(Re,Ge,xe,pe,Ce,it,xe,pe,L.DEPTH_BUFFER_BIT,L.NEAREST);v.bindFramebuffer(L.READ_FRAMEBUFFER,null),v.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(k!==0||y.isRenderTargetTexture||H.has(y)){const yt=H.get(y),hi=H.get(N);v.bindFramebuffer(L.READ_FRAMEBUFFER,X),v.bindFramebuffer(L.DRAW_FRAMEBUFFER,F);for(let lt=0;lt<be;lt++)os?L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,yt.__webglTexture,k,We+lt):L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,yt.__webglTexture,k),at?L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,hi.__webglTexture,me,Mt+lt):L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,hi.__webglTexture,me),k!==0?L.blitFramebuffer(Re,Ge,xe,pe,Ce,it,xe,pe,L.COLOR_BUFFER_BIT,L.NEAREST):at?L.copyTexSubImage3D(ve,me,Ce,it,Mt+lt,Re,Ge,xe,pe):L.copyTexSubImage2D(ve,me,Ce,it,Re,Ge,xe,pe);v.bindFramebuffer(L.READ_FRAMEBUFFER,null),v.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else at?y.isDataTexture||y.isData3DTexture?L.texSubImage3D(ve,me,Ce,it,Mt,xe,pe,be,rt,Gt,_t.data):N.isCompressedArrayTexture?L.compressedTexSubImage3D(ve,me,Ce,it,Mt,xe,pe,be,rt,_t.data):L.texSubImage3D(ve,me,Ce,it,Mt,xe,pe,be,rt,Gt,_t):y.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,me,Ce,it,xe,pe,rt,Gt,_t.data):y.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,me,Ce,it,_t.width,_t.height,rt,_t.data):L.texSubImage2D(L.TEXTURE_2D,me,Ce,it,xe,pe,rt,Gt,_t);v.pixelStorei(L.UNPACK_ROW_LENGTH,rn),v.pixelStorei(L.UNPACK_IMAGE_HEIGHT,$e),v.pixelStorei(L.UNPACK_SKIP_PIXELS,gn),v.pixelStorei(L.UNPACK_SKIP_ROWS,Nn),v.pixelStorei(L.UNPACK_SKIP_IMAGES,ci),me===0&&N.generateMipmaps&&L.generateMipmap(ve),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(){q=0,G=0,Z=null,v.reset(),ge.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return qn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Ke._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ke._getUnpackColorSpace()}}const Sc=Math.PI/180,Zu=180/Math.PI;function Nr(i,e,t){return Math.max(e,Math.min(t,i))}const xi=[{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 il(i,e,t){return i+(e-i)*t}function ja(i,e,t){return[il(i[0],e[0],t),il(i[1],e[1],t),il(i[2],e[2],t)]}function bc(i){const e=Math.max(xi[0].altitudeDeg,Math.min(xi[xi.length-1].altitudeDeg,i));for(let n=0;n<xi.length-1;n++){const s=xi[n],r=xi[n+1];if(e>=s.altitudeDeg&&e<=r.altitudeDeg){const a=(e-s.altitudeDeg)/(r.altitudeDeg-s.altitudeDeg);return{zenith:ja(s.zenith,r.zenith,a),horizon:ja(s.horizon,r.horizon,a)}}}const t=xi[xi.length-1];return{zenith:t.zenith,horizon:t.horizon}}const Ju=-18,Qu=-4,sx=1.8;function ju(i){if(i<=Ju)return Ga;if(i>=0)return Qu;const e=i/Ju;return Ga-(Ga-Qu)*(1-e)**sx}const rx=-1.5,Ga=6.5,ed=Ga,ax=1.6;function sl(i){const e=(ed-i)/(ed-rx);return Nr(e,0,1)**ax}function sn(i,e,t){const n=i*Sc,s=e*Sc,r=t*Math.cos(n);return{x:r*Math.sin(s),y:t*Math.sin(n),z:-r*Math.cos(s)}}function ox(i,e,t){const n=Math.sqrt(i*i+e*e+t*t),s=n===0?0:Math.asin(Nr(e/n,-1,1))*Zu,r=(Math.atan2(i,-t)*Zu+360)%360;return{altitudeDeg:s,azimuthDeg:r}}function lx(i,e){const t=Math.abs(i-e)%360;return t>180?360-t:t}function cx(i,e,t,n){const s=Math.max(0,1-lx(i,t)/hx),r=Math.exp(-Math.max(0,e)/ux),a=n>0?Math.max(0,1-n/dx):Math.max(0,1-Math.abs(n+fx)/px);return s*r*a}const hx=90,ux=12,dx=8,fx=2,px=12;function mx(i,e,t,n){const{zenith:s,horizon:r}=bc(n),a=Nr((i+90)/180,0,1),o=ja(r,s,a),l=cx(e,i,t,n);if(l<=0)return o;const c=bc(n+gx).horizon,h=[Math.max(r[0],c[0]),Math.max(r[1],c[1]),Math.max(r[2],c[2])];return ja(o,h,l)}const gx=6;function rl(i){return .12+.88*i}const vx=-4;function _x(i){return Math.max(0,vx-i)}const xx=6,Mx=60;function yx(i){return Math.min(Mx,xx*Math.sqrt(i))}const Sx=3,bx=.55;function Ex(i){return bx*Nr(i/Sx,0,1)}function X0(i){const e=Math.max(i,-4),t=Math.sin(e*Sc)+.50572*Math.pow(e+6.07995,-1.6364);return Nr(1/t,1,40)}function ki(i){const e=X0(i)-1;return[1,Math.exp(-.022*e),Math.exp(-.062*e)]}function wx(i){return Tx*(X0(Math.max(i,0))-1)}function Ax(i){return Math.pow(10,-.4*wx(i))}const Tx=5/37,q0=[{maxBrightness:.35,size:1.2},{maxBrightness:.7,size:2},{maxBrightness:1/0,size:3.2}];function Rx(i){return q0.findIndex(e=>i<=e.maxBrightness)}const Cx=.25,td=.3,Dx=2.2;function Px(i,{phase:e,speedFactor:t},n){const r=1+Cx*(td+(1-td)*i)*Math.sin(n*Dx*t+e);return Math.min(1,Math.max(0,r))}/**
4757
+ }`;class jx{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new O0(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 Et({vertexShader:Jx,fragmentShader:Qx,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Je(new Ui(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class e_ extends os{constructor(e,t){super();const n=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,f=null,g=null;const _=typeof XRWebGLBinding<"u",m=new jx,p={},E=t.getContextAttributes();let A=null,M=null;const S=[],w=[],R=new Le;let x=null;const b=new fn;b.viewport=new pt;const D=new fn;D.viewport=new pt;const C=[b,D],I=new hg;let W=null,X=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let re=S[Y];return re===void 0&&(re=new No,S[Y]=re),re.getTargetRaySpace()},this.getControllerGrip=function(Y){let re=S[Y];return re===void 0&&(re=new No,S[Y]=re),re.getGripSpace()},this.getHand=function(Y){let re=S[Y];return re===void 0&&(re=new No,S[Y]=re),re.getHandSpace()};function F(Y){const re=w.indexOf(Y.inputSource);if(re===-1)return;const ne=S[re];ne!==void 0&&(ne.update(Y.inputSource,Y.frame,c||a),ne.dispatchEvent({type:Y.type,data:Y.inputSource}))}function q(){s.removeEventListener("select",F),s.removeEventListener("selectstart",F),s.removeEventListener("selectend",F),s.removeEventListener("squeeze",F),s.removeEventListener("squeezestart",F),s.removeEventListener("squeezeend",F),s.removeEventListener("end",q),s.removeEventListener("inputsourceschange",G);for(let Y=0;Y<S.length;Y++){const re=w[Y];re!==null&&(w[Y]=null,S[Y].disconnect(re))}W=null,X=null,m.reset();for(const Y in p)delete p[Y];e.setRenderTarget(A),f=null,d=null,u=null,s=null,M=null,Be.stop(),n.isPresenting=!1,e.setPixelRatio(x),e.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){r=Y,n.isPresenting===!0&&Oe("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,n.isPresenting===!0&&Oe("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(Y){c=Y},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&_&&(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(A=e.getRenderTarget(),s.addEventListener("select",F),s.addEventListener("selectstart",F),s.addEventListener("selectend",F),s.addEventListener("squeeze",F),s.addEventListener("squeezestart",F),s.addEventListener("squeezeend",F),s.addEventListener("end",q),s.addEventListener("inputsourceschange",G),E.xrCompatible!==!0&&await t.makeXRCompatible(),x=e.getPixelRatio(),e.getSize(R),_&&"createProjectionLayer"in XRWebGLBinding.prototype){let ne=null,z=null,Ee=null;E.depth&&(Ee=E.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ne=E.stencil?Qi:ci,z=E.stencil?Pr:Dn);const De={colorFormat:t.RGBA8,depthFormat:Ee,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(De),s.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),M=new an(d.textureWidth,d.textureHeight,{format:gn,type:pn,depthTexture:new ss(d.textureWidth,d.textureHeight,z,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:E.stencil,colorSpace:e.outputColorSpace,samples:E.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const ne={antialias:E.antialias,alpha:!0,depth:E.depth,stencil:E.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 an(f.framebufferWidth,f.framebufferHeight,{format:gn,type:pn,colorSpace:e.outputColorSpace,stencilBuffer:E.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(l),c=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=w.indexOf(ne);z>=0&&(w[z]=null,S[z].disconnect(ne))}for(let re=0;re<Y.added.length;re++){const ne=Y.added[re];let z=w.indexOf(ne);if(z===-1){for(let De=0;De<S.length;De++)if(De>=w.length){w.push(ne),z=De;break}else if(w[De]===null){w[De]=ne,z=De;break}if(z===-1)break}const Ee=S[z];Ee&&Ee.connect(ne)}}const Z=new U,te=new U;function j(Y,re,ne){Z.setFromMatrixPosition(re.matrixWorld),te.setFromMatrixPosition(ne.matrixWorld);const z=Z.distanceTo(te),Ee=re.projectionMatrix.elements,De=ne.projectionMatrix.elements,Ae=Ee[14]/(Ee[10]-1),xe=Ee[14]/(Ee[10]+1),Ie=(Ee[9]+1)/Ee[5],Ne=(Ee[9]-1)/Ee[5],Ue=(Ee[8]-1)/Ee[0],Qe=(De[8]+1)/De[0],je=Ae*Ue,mt=Ae*Qe,dt=z/(-Ue+Qe),gt=dt*-Ue;if(re.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(gt),Y.translateZ(dt),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),Ee[10]===-1)Y.projectionMatrix.copy(re.projectionMatrix),Y.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{const wt=Ae+dt,L=xe+dt,en=je-gt,et=mt+(z-gt),T=Ie*xe/L*wt,v=Ne*xe/L*wt;Y.projectionMatrix.makePerspective(en,et,T,v,wt,L),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=D.near=b.near=re,I.far=D.far=b.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,b.layers.mask=I.layers.mask&-5,D.layers.mask=I.layers.mask&-3;const z=Y.parent,Ee=I.cameras;ie(I,z);for(let De=0;De<Ee.length;De++)ie(Ee[De],z);Ee.length===2?j(I,b,D):I.projectionMatrix.copy(b.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=Mc*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 l},this.setFoveation=function(Y){l=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 ke=null;function qe(Y,re){if(h=re.getViewerPose(c||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 Ie=ne[xe];let Ne=null;if(f!==null)Ne=f.getViewport(Ie);else{const Qe=u.getViewSubImage(d,Ie);Ne=Qe.viewport,xe===0&&(e.setRenderTargetTextures(M,Qe.colorTexture,Qe.depthStencilTexture),e.setRenderTarget(M))}let Ue=C[xe];Ue===void 0&&(Ue=new fn,Ue.layers.enable(xe),Ue.viewport=new pt,C[xe]=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),xe===0&&(I.matrix.copy(Ue.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),z===!0&&I.cameras.push(Ue)}const Ee=s.enabledFeatures;if(Ee&&Ee.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&_){u=n.getBinding();const xe=u.getDepthInformation(ne[0]);xe&&xe.isValid&&xe.texture&&m.init(xe,s.renderState)}if(Ee&&Ee.includes("camera-access")&&_){e.state.unbindTexture(),u=n.getBinding();for(let xe=0;xe<ne.length;xe++){const Ie=ne[xe].camera;if(Ie){let Ne=p[Ie];Ne||(Ne=new O0,p[Ie]=Ne);const Ue=u.getCameraImage(Ie);Ne.sourceTexture=Ue}}}}for(let ne=0;ne<S.length;ne++){const z=w[ne],Ee=S[ne];z!==null&&Ee!==void 0&&Ee.update(z,re,c||a)}ke&&ke(Y,re),re.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:re}),g=null}const Be=new G0;Be.setAnimationLoop(qe),this.setAnimationLoop=function(Y){ke=Y},this.dispose=function(){}}}const t_=new ht,$0=new ze;$0.set(-1,0,0,0,1,0,0,0,1);function n_(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,z0(i)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function s(m,p,E,A,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),_(m,p)):p.isMeshNormalMaterial?r(m,p):p.isLineBasicMaterial?(a(m,p),p.isLineDashedMaterial&&o(m,p)):p.isPointsMaterial?l(m,p,E,A):p.isSpriteMaterial?c(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,t(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===Pt&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,t(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===Pt&&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 E=e.get(p),A=E.envMap,M=E.envMapRotation;A&&(m.envMap.value=A,m.envMapRotation.value.setFromMatrix4(t_.makeRotationFromEuler(M)).transpose(),A.isCubeTexture&&A.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply($0),m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,m.aoMapTransform))}function a(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform))}function o(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function l(m,p,E,A){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*E,m.scale.value=A*.5,p.map&&(m.map.value=p.map,t(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function c(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function h(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function u(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function d(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,E){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===Pt&&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=E.texture,m.transmissionSamplerSize.value.set(E.width,E.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 _(m,p){const E=e.get(p).light;m.referencePosition.value.setFromMatrixPosition(E.matrixWorld),m.nearDistance.value=E.shadow.camera.near,m.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function i_(i,e,t,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(M,S){const w=S.program;n.uniformBlockBinding(M,w)}function c(M,S){let w=s[M.id];w===void 0&&(m(M),w=h(M),s[M.id]=w,M.addEventListener("dispose",E));const R=S.program;n.updateUBOMapping(M,R);const x=e.render.frame;r[M.id]!==x&&(d(M),r[M.id]=x)}function h(M){const S=u();M.__bindingPointIndex=S;const w=i.createBuffer(),R=M.__size,x=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,w),i.bufferData(i.UNIFORM_BUFFER,R,x),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,S,w),w}function u(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.push(M),M;return Ye("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(M){const S=s[M.id],w=M.uniforms,R=M.__cache;i.bindBuffer(i.UNIFORM_BUFFER,S);for(let x=0,b=w.length;x<b;x++){const D=w[x];if(Array.isArray(D))for(let C=0,I=D.length;C<I;C++)f(D[C],x,C,R);else f(D,x,0,R)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function f(M,S,w,R){if(_(M,S,w,R)===!0){const x=M.__offset,b=M.value;if(Array.isArray(b)){let D=0;for(let C=0;C<b.length;C++){const I=b[C],W=p(I);g(I,M.__data,D),typeof I!="number"&&typeof I!="boolean"&&!I.isMatrix3&&!ArrayBuffer.isView(I)&&(D+=W.storage/Float32Array.BYTES_PER_ELEMENT)}}else g(b,M.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,x,M.__data)}}function g(M,S,w){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,w)}function _(M,S,w,R){const x=M.value,b=S+"_"+w;if(R[b]===void 0)return typeof x=="number"||typeof x=="boolean"?R[b]=x:ArrayBuffer.isView(x)?R[b]=x.slice():R[b]=x.clone(),!0;{const D=R[b];if(typeof x=="number"||typeof x=="boolean"){if(D!==x)return R[b]=x,!0}else{if(ArrayBuffer.isView(x))return!0;if(D.equals(x)===!1)return D.copy(x),!0}}return!1}function m(M){const S=M.uniforms;let w=0;const R=16;for(let b=0,D=S.length;b<D;b++){const C=Array.isArray(S[b])?S[b]:[S[b]];for(let I=0,W=C.length;I<W;I++){const X=C[I],F=Array.isArray(X.value)?X.value:[X.value];for(let q=0,G=F.length;q<G;q++){const Z=F[q],te=p(Z),j=w%R,ie=j%te.boundary,ue=j+ie;w+=ie,ue!==0&&R-ue<te.storage&&(w+=R-ue),X.__data=new Float32Array(te.storage/Float32Array.BYTES_PER_ELEMENT),X.__offset=w,w+=te.storage}}}const x=w%R;return x>0&&(w+=R-x),M.__size=w,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?Oe("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(S.boundary=16,S.storage=M.byteLength):Oe("WebGLRenderer: Unsupported uniform value type.",M),S}function E(M){const S=M.target;S.removeEventListener("dispose",E);const w=a.indexOf(S.__bindingPointIndex);a.splice(w,1),i.deleteBuffer(s[S.id]),delete s[S.id],delete r[S.id]}function A(){for(const M in s)i.deleteBuffer(s[M]);a=[],s={},r={}}return{bind:l,update:c,dispose:A}}const s_=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 Fn=null;function r_(){return Fn===null&&(Fn=new fh(s_,16,16,ns,Qt),Fn.name="DFG_LUT",Fn.minFilter=Rt,Fn.magFilter=Rt,Fn.wrapS=mn,Fn.wrapT=mn,Fn.generateMipmaps=!1,Fn.needsUpdate=!0),Fn}class a_{constructor(e={}){const{canvas:t=ym(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=pn}=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 _=f,m=new Set([ah,rh,sh]),p=new Set([pn,Dn,Dr,Pr,nh,ih]),E=new Uint32Array(4),A=new Int32Array(4),M=new U;let S=null,w=null;const R=[],x=[];let b=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=$n,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const D=this;let C=!1,I=null,W=null,X=null,F=null;this._outputColorSpace=yn;let q=0,G=0,Z=null,te=-1,j=null;const ie=new pt,ue=new pt;let ke=null;const qe=new Me(0);let Be=0,Y=t.width,re=t.height,ne=1,z=null,Ee=null;const De=new pt(0,0,Y,re),Ae=new pt(0,0,Y,re);let xe=!1;const Ie=new ph;let Ne=!1,Ue=!1;const Qe=new ht,je=new U,mt=new pt,dt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let gt=!1;function wt(){return Z===null?ne:1}let L=n;function en(y,N){return t.getContext(y,N)}try{const y={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${jc}`),t.addEventListener("webglcontextlost",vt,!1),t.addEventListener("webglcontextrestored",ot,!1),t.addEventListener("webglcontextcreationerror",In,!1),L===null){const N="webgl2";if(L=en(N,y),L===null)throw en(N)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(y){throw Ye("WebGLRenderer: "+y.message),y}let et,T,v,O,H,K,se,oe,$,Q,le,Te,de,ce,Pe,Fe,He,P,ae,J,he,ge,ee;function we(){et=new rv(L),et.init(),he=new Zx(L,et),T=new J2(L,et,e,he),v=new Kx(L,et),T.reversedDepthBuffer&&d&&v.buffers.depth.setReversed(!0),W=L.createFramebuffer(),X=L.createFramebuffer(),F=L.createFramebuffer(),O=new lv(L),H=new Nx,K=new $x(L,et,v,H,T,he,O),se=new sv(D),oe=new dg(L),ge=new $2(L,oe),$=new av(L,oe,O,ge),Q=new hv(L,$,oe,ge,O),P=new cv(L,T,K),Pe=new Q2(H),le=new Lx(D,se,et,T,ge,Pe),Te=new n_(D,H),de=new Fx,ce=new Gx(et),He=new K2(D,se,v,Q,g,l),Fe=new Yx(D,Q,T),ee=new i_(L,O,T,v),ae=new Z2(L,et,O),J=new ov(L,et,O),O.programs=le.programs,D.capabilities=T,D.extensions=et,D.properties=H,D.renderLists=de,D.shadowMap=Fe,D.state=v,D.info=O}we(),_!==pn&&(b=new dv(_,t.width,t.height,o,s,r));const ye=new e_(D,L);this.xr=ye,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){const y=et.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){const y=et.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,N,V=!0){if(ye.isPresenting){Oe("WebGLRenderer: Can't change size while VR device is presenting.");return}Y=y,re=N,t.width=Math.floor(y*ne),t.height=Math.floor(N*ne),V===!0&&(t.style.width=y+"px",t.style.height=N+"px"),b!==null&&b.setSize(t.width,t.height),this.setViewport(0,0,y,N)},this.getDrawingBufferSize=function(y){return y.set(Y*ne,re*ne).floor()},this.setDrawingBufferSize=function(y,N,V){Y=y,re=N,ne=V,t.width=Math.floor(y*V),t.height=Math.floor(N*V),this.setViewport(0,0,y,N)},this.setEffects=function(y){if(_===pn){Ye("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(y){for(let N=0;N<y.length;N++)if(y[N].isOutputPass===!0){Oe("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}b.setEffects(y||[])},this.getCurrentViewport=function(y){return y.copy(ie)},this.getViewport=function(y){return y.copy(De)},this.setViewport=function(y,N,V,B){y.isVector4?De.set(y.x,y.y,y.z,y.w):De.set(y,N,V,B),v.viewport(ie.copy(De).multiplyScalar(ne).round())},this.getScissor=function(y){return y.copy(Ae)},this.setScissor=function(y,N,V,B){y.isVector4?Ae.set(y.x,y.y,y.z,y.w):Ae.set(y,N,V,B),v.scissor(ue.copy(Ae).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){Ee=y},this.getClearColor=function(y){return y.copy(He.getClearColor())},this.setClearColor=function(){He.setClearColor(...arguments)},this.getClearAlpha=function(){return He.getClearAlpha()},this.setClearAlpha=function(){He.setClearAlpha(...arguments)},this.clear=function(y=!0,N=!0,V=!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,_e=p.has(me),pe=He.getClearColor(),be=He.getClearAlpha(),Re=pe.r,Ge=pe.g,We=pe.b;_e?(E[0]=Re,E[1]=Ge,E[2]=We,E[3]=be,L.clearBufferuiv(L.COLOR,0,E)):(A[0]=Re,A[1]=Ge,A[2]=We,A[3]=be,L.clearBufferiv(L.COLOR,0,A))}else B|=L.COLOR_BUFFER_BIT}N&&(B|=L.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),V&&(B|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B!==0&&L.clear(B)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(y){y.setRenderer(this),I=y},this.dispose=function(){t.removeEventListener("webglcontextlost",vt,!1),t.removeEventListener("webglcontextrestored",ot,!1),t.removeEventListener("webglcontextcreationerror",In,!1),He.dispose(),de.dispose(),ce.dispose(),H.dispose(),se.dispose(),Q.dispose(),ge.dispose(),ee.dispose(),le.dispose(),ye.dispose(),ye.removeEventListener("sessionstart",Rh),ye.removeEventListener("sessionend",Ch),Fi.stop()};function vt(y){y.preventDefault(),ja("WebGLRenderer: Context Lost."),C=!0}function ot(){ja("WebGLRenderer: Context Restored."),C=!1;const y=O.autoReset,N=Fe.enabled,V=Fe.autoUpdate,B=Fe.needsUpdate,k=Fe.type;we(),O.autoReset=y,Fe.enabled=N,Fe.autoUpdate=V,Fe.needsUpdate=B,Fe.type=k}function In(y){Ye("WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function Ln(y){const N=y.target;N.removeEventListener("dispose",Ln),Bf(N)}function Bf(y){kf(y),H.remove(y)}function kf(y){const N=H.get(y).programs;N!==void 0&&(N.forEach(function(V){le.releaseProgram(V)}),y.isShaderMaterial&&le.releaseShaderCache(y))}this.renderBufferDirect=function(y,N,V,B,k,me){N===null&&(N=dt);const _e=k.isMesh&&k.matrixWorld.determinantAffine()<0,pe=Vf(y,N,V,B,k);v.setMaterial(B,_e);let be=V.index,Re=1;if(B.wireframe===!0){if(be=$.getWireframeAttribute(V),be===void 0)return;Re=2}const Ge=V.drawRange,We=V.attributes.position;let Ce=Ge.start*Re,it=(Ge.start+Ge.count)*Re;me!==null&&(Ce=Math.max(Ce,me.start*Re),it=Math.min(it,(me.start+me.count)*Re)),be!==null?(Ce=Math.max(Ce,0),it=Math.min(it,be.count)):We!=null&&(Ce=Math.max(Ce,0),it=Math.min(it,We.count));const Mt=it-Ce;if(Mt<0||Mt===1/0)return;ge.setup(k,B,pe,V,be);let xt,rt=ae;if(be!==null&&(xt=oe.get(be),rt=J,rt.setIndex(xt)),k.isMesh)B.wireframe===!0?(v.setLineWidth(B.wireframeLinewidth*wt()),rt.setMode(L.LINES)):rt.setMode(L.TRIANGLES);else if(k.isLine){let Gt=B.linewidth;Gt===void 0&&(Gt=1),v.setLineWidth(Gt*wt()),k.isLineSegments?rt.setMode(L.LINES):k.isLineLoop?rt.setMode(L.LINE_LOOP):rt.setMode(L.LINE_STRIP)}else k.isPoints?rt.setMode(L.POINTS):k.isSprite&&rt.setMode(L.TRIANGLES);if(k.isBatchedMesh)if(et.get("WEBGL_multi_draw"))rt.renderMultiDraw(k._multiDrawStarts,k._multiDrawCounts,k._multiDrawCount);else{const Gt=k._multiDrawStarts,ve=k._multiDrawCounts,on=k._multiDrawCount,$e=be?oe.get(be).bytesPerElement:1,vn=H.get(B).currentProgram.getUniforms();for(let Nn=0;Nn<on;Nn++)vn.setValue(L,"_gl_DrawID",Nn),rt.render(Gt[Nn]/$e,ve[Nn])}else if(k.isInstancedMesh)rt.renderInstances(Ce,Mt,k.count);else if(V.isInstancedBufferGeometry){const Gt=V._maxInstanceCount!==void 0?V._maxInstanceCount:1/0,ve=Math.min(V.instanceCount,Gt);rt.renderInstances(Ce,Mt,ve)}else rt.render(Ce,Mt)};function Th(y,N,V){y.transparent===!0&&y.side===Tn&&y.forceSinglePass===!1?(y.side=Pt,y.needsUpdate=!0,kr(y,N,V),y.side=Pi,y.needsUpdate=!0,kr(y,N,V),y.side=Tn):kr(y,N,V)}this.compile=function(y,N,V=null){V===null&&(V=y),w=ce.get(V),w.init(N),x.push(w),V.traverseVisible(function(k){k.isLight&&k.layers.test(N.layers)&&(w.pushLight(k),k.castShadow&&w.pushShadow(k))}),y!==V&&y.traverseVisible(function(k){k.isLight&&k.layers.test(N.layers)&&(w.pushLight(k),k.castShadow&&w.pushShadow(k))}),w.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 _e=0;_e<me.length;_e++){const pe=me[_e];Th(pe,V,k),B.add(pe)}else Th(me,V,k),B.add(me)}),w=x.pop(),B},this.compileAsync=function(y,N,V=null){const B=this.compile(y,N,V);return new Promise(k=>{function me(){if(B.forEach(function(_e){H.get(_e).currentProgram.isReady()&&B.delete(_e)}),B.size===0){k(y);return}setTimeout(me,10)}et.get("KHR_parallel_shader_compile")!==null?me():setTimeout(me,10)})};let yo=null;function Hf(y){yo&&yo(y)}function Rh(){Fi.stop()}function Ch(){Fi.start()}const Fi=new G0;Fi.setAnimationLoop(Hf),typeof self<"u"&&Fi.setContext(self),this.setAnimationLoop=function(y){yo=y,ye.setAnimationLoop(y),y===null?Fi.stop():Fi.start()},ye.addEventListener("sessionstart",Rh),ye.addEventListener("sessionend",Ch),this.render=function(y,N){if(N!==void 0&&N.isCamera!==!0){Ye("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;I!==null&&I.renderStart(y,N);const V=ye.enabled===!0&&ye.isPresenting===!0,B=b!==null&&(Z===null||V)&&b.begin(D,Z);if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),N.parent===null&&N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),ye.enabled===!0&&ye.isPresenting===!0&&(b===null||b.isCompositing()===!1)&&(ye.cameraAutoUpdate===!0&&ye.updateCamera(N),N=ye.getCamera()),y.isScene===!0&&y.onBeforeRender(D,y,N,Z),w=ce.get(y,x.length),w.init(N),w.state.textureUnits=K.getTextureUnits(),x.push(w),Qe.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),Ie.setFromProjectionMatrix(Qe,qn,N.reversedDepth),Ue=this.localClippingEnabled,Ne=Pe.init(this.clippingPlanes,Ue),S=de.get(y,R.length),S.init(),R.push(S),ye.enabled===!0&&ye.isPresenting===!0){const _e=D.xr.getDepthSensingMesh();_e!==null&&So(_e,N,-1/0,D.sortObjects)}So(y,N,0,D.sortObjects),S.finish(),D.sortObjects===!0&&S.sort(z,Ee,N.reversedDepth),gt=ye.enabled===!1||ye.isPresenting===!1||ye.hasDepthSensing()===!1,gt&&He.addToRenderList(S,y),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Ne===!0&&Pe.beginShadows();const k=w.state.shadowsArray;if(Fe.render(k,y,N),Ne===!0&&Pe.endShadows(),(B&&b.hasRenderPass())===!1){const _e=S.opaque,pe=S.transmissive;if(w.setupLights(),N.isArrayCamera){const be=N.cameras;if(pe.length>0)for(let Re=0,Ge=be.length;Re<Ge;Re++){const We=be[Re];Ph(_e,pe,y,We)}gt&&He.render(y);for(let Re=0,Ge=be.length;Re<Ge;Re++){const We=be[Re];Dh(S,y,We,We.viewport)}}else pe.length>0&&Ph(_e,pe,y,N),gt&&He.render(y),Dh(S,y,N)}Z!==null&&G===0&&(K.updateMultisampleRenderTarget(Z),K.updateRenderTargetMipmap(Z)),B&&b.end(D),y.isScene===!0&&y.onAfterRender(D,y,N),ge.resetDefaultState(),te=-1,j=null,x.pop(),x.length>0?(w=x[x.length-1],K.setTextureUnits(w.state.textureUnits),Ne===!0&&Pe.setGlobalState(D.clippingPlanes,w.state.camera)):w=null,R.pop(),R.length>0?S=R[R.length-1]:S=null,I!==null&&I.renderEnd()};function So(y,N,V,B){if(y.visible===!1)return;if(y.layers.test(N.layers)){if(y.isGroup)V=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(N);else if(y.isLightProbeGrid)w.pushLightProbeGrid(y);else if(y.isLight)w.pushLight(y),y.castShadow&&w.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||Ie.intersectsSprite(y)){B&&mt.setFromMatrixPosition(y.matrixWorld).applyMatrix4(Qe);const _e=Q.update(y),pe=y.material;pe.visible&&S.push(y,_e,pe,V,mt.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||Ie.intersectsObject(y))){const _e=Q.update(y),pe=y.material;if(B&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),mt.copy(y.boundingSphere.center)):(_e.boundingSphere===null&&_e.computeBoundingSphere(),mt.copy(_e.boundingSphere.center)),mt.applyMatrix4(y.matrixWorld).applyMatrix4(Qe)),Array.isArray(pe)){const be=_e.groups;for(let Re=0,Ge=be.length;Re<Ge;Re++){const We=be[Re],Ce=pe[We.materialIndex];Ce&&Ce.visible&&S.push(y,_e,Ce,V,mt.z,We)}}else pe.visible&&S.push(y,_e,pe,V,mt.z,null)}}const me=y.children;for(let _e=0,pe=me.length;_e<pe;_e++)So(me[_e],N,V,B)}function Dh(y,N,V,B){const{opaque:k,transmissive:me,transparent:_e}=y;w.setupLightsView(V),Ne===!0&&Pe.setGlobalState(D.clippingPlanes,V),B&&v.viewport(ie.copy(B)),k.length>0&&Br(k,N,V),me.length>0&&Br(me,N,V),_e.length>0&&Br(_e,N,V),v.buffers.depth.setTest(!0),v.buffers.depth.setMask(!0),v.buffers.color.setMask(!0),v.setPolygonOffset(!1)}function Ph(y,N,V,B){if((V.isScene===!0?V.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[B.id]===void 0){const Ce=et.has("EXT_color_buffer_half_float")||et.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[B.id]=new an(1,1,{generateMipmaps:!0,type:Ce?Qt:pn,minFilter:Ji,samples:Math.max(4,T.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ke.workingColorSpace})}const me=w.state.transmissionRenderTarget[B.id],_e=B.viewport||ie;me.setSize(_e.z*D.transmissionResolutionScale,_e.w*D.transmissionResolutionScale);const pe=D.getRenderTarget(),be=D.getActiveCubeFace(),Re=D.getActiveMipmapLevel();D.setRenderTarget(me),D.getClearColor(qe),Be=D.getClearAlpha(),Be<1&&D.setClearColor(16777215,.5),D.clear(),gt&&He.render(V);const Ge=D.toneMapping;D.toneMapping=$n;const We=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),w.setupLightsView(B),Ne===!0&&Pe.setGlobalState(D.clippingPlanes,B),Br(y,V,B),K.updateMultisampleRenderTarget(me),K.updateRenderTargetMipmap(me),et.has("WEBGL_multisampled_render_to_texture")===!1){let Ce=!1;for(let it=0,Mt=N.length;it<Mt;it++){const xt=N[it],{object:rt,geometry:Gt,material:ve,group:on}=xt;if(ve.side===Tn&&rt.layers.test(B.layers)){const $e=ve.side;ve.side=Pt,ve.needsUpdate=!0,Ih(rt,V,B,Gt,ve,on),ve.side=$e,ve.needsUpdate=!0,Ce=!0}}Ce===!0&&(K.updateMultisampleRenderTarget(me),K.updateRenderTargetMipmap(me))}D.setRenderTarget(pe,be,Re),D.setClearColor(qe,Be),We!==void 0&&(B.viewport=We),D.toneMapping=Ge}function Br(y,N,V){const B=N.isScene===!0?N.overrideMaterial:null;for(let k=0,me=y.length;k<me;k++){const _e=y[k],{object:pe,geometry:be,group:Re}=_e;let Ge=_e.material;Ge.allowOverride===!0&&B!==null&&(Ge=B),pe.layers.test(V.layers)&&Ih(pe,N,V,be,Ge,Re)}}function Ih(y,N,V,B,k,me){y.onBeforeRender(D,N,V,B,k,me),y.modelViewMatrix.multiplyMatrices(V.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),k.onBeforeRender(D,N,V,B,y,me),k.transparent===!0&&k.side===Tn&&k.forceSinglePass===!1?(k.side=Pt,k.needsUpdate=!0,D.renderBufferDirect(V,N,B,k,y,me),k.side=Pi,k.needsUpdate=!0,D.renderBufferDirect(V,N,B,k,y,me),k.side=Tn):D.renderBufferDirect(V,N,B,k,y,me),y.onAfterRender(D,N,V,B,k,me)}function kr(y,N,V){N.isScene!==!0&&(N=dt);const B=H.get(y),k=w.state.lights,me=w.state.shadowsArray,_e=k.state.version,pe=le.getParameters(y,k.state,me,N,V,w.state.lightProbeGridArray),be=le.getProgramCacheKey(pe);let Re=B.programs;B.environment=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?N.environment:null,B.fog=N.fog;const Ge=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap;B.envMap=se.get(y.envMap||B.environment,Ge),B.envMapRotation=B.environment!==null&&y.envMap===null?N.environmentRotation:y.envMapRotation,Re===void 0&&(y.addEventListener("dispose",Ln),Re=new Map,B.programs=Re);let We=Re.get(be);if(We!==void 0){if(B.currentProgram===We&&B.lightsStateVersion===_e)return Nh(y,pe),We}else pe.uniforms=le.getUniforms(y),I!==null&&y.isNodeMaterial&&I.build(y,V,pe),y.onBeforeCompile(pe,D),We=le.acquireProgram(pe,be),Re.set(be,We),B.uniforms=pe.uniforms;const Ce=B.uniforms;return(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)&&(Ce.clippingPlanes=Pe.uniform),Nh(y,pe),B.needsLights=Xf(y),B.lightsStateVersion=_e,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=w.state.lightProbeGridArray.length>0,B.currentProgram=We,B.uniformsList=null,We}function Lh(y){if(y.uniformsList===null){const N=y.currentProgram.getUniforms();y.uniformsList=Wa.seqWithValue(N.seq,y.uniforms)}return y.uniformsList}function Nh(y,N){const V=H.get(y);V.outputColorSpace=N.outputColorSpace,V.batching=N.batching,V.batchingColor=N.batchingColor,V.instancing=N.instancing,V.instancingColor=N.instancingColor,V.instancingMorph=N.instancingMorph,V.skinning=N.skinning,V.morphTargets=N.morphTargets,V.morphNormals=N.morphNormals,V.morphColors=N.morphColors,V.morphTargetsCount=N.morphTargetsCount,V.numClippingPlanes=N.numClippingPlanes,V.numIntersection=N.numClipIntersection,V.vertexAlphas=N.vertexAlphas,V.vertexTangents=N.vertexTangents,V.toneMapping=N.toneMapping}function Gf(y,N){if(y.length===0)return null;if(y.length===1)return y[0].texture!==null?y[0]:null;M.setFromMatrixPosition(N.matrixWorld);for(let V=0,B=y.length;V<B;V++){const k=y[V];if(k.texture!==null&&k.boundingBox.containsPoint(M))return k}return null}function Vf(y,N,V,B,k){N.isScene!==!0&&(N=dt),K.resetTextureUnits();const me=N.fog,_e=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?N.environment:null,pe=Z===null?D.outputColorSpace:Z.isXRRenderTarget===!0?Z.texture.colorSpace:Ke.workingColorSpace,be=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Re=se.get(B.envMap||_e,be),Ge=B.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,We=!!V.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Ce=!!V.morphAttributes.position,it=!!V.morphAttributes.normal,Mt=!!V.morphAttributes.color;let xt=$n;B.toneMapped&&(Z===null||Z.isXRRenderTarget===!0)&&(xt=D.toneMapping);const rt=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,Gt=rt!==void 0?rt.length:0,ve=H.get(B),on=w.state.lights;if(Ne===!0&&(Ue===!0||y!==j)){const lt=y===j&&B.id===te;Pe.setState(B,y,lt)}let $e=!1;B.version===ve.__version?(ve.needsLights&&ve.lightsStateVersion!==on.state.version||ve.outputColorSpace!==pe||k.isBatchedMesh&&ve.batching===!1||!k.isBatchedMesh&&ve.batching===!0||k.isBatchedMesh&&ve.batchingColor===!0&&k.colorTexture===null||k.isBatchedMesh&&ve.batchingColor===!1&&k.colorTexture!==null||k.isInstancedMesh&&ve.instancing===!1||!k.isInstancedMesh&&ve.instancing===!0||k.isSkinnedMesh&&ve.skinning===!1||!k.isSkinnedMesh&&ve.skinning===!0||k.isInstancedMesh&&ve.instancingColor===!0&&k.instanceColor===null||k.isInstancedMesh&&ve.instancingColor===!1&&k.instanceColor!==null||k.isInstancedMesh&&ve.instancingMorph===!0&&k.morphTexture===null||k.isInstancedMesh&&ve.instancingMorph===!1&&k.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!==Ce||ve.morphNormals!==it||ve.morphColors!==Mt||ve.toneMapping!==xt||ve.morphTargetsCount!==Gt||!!ve.lightProbeGrid!=w.state.lightProbeGridArray.length>0)&&($e=!0):($e=!0,ve.__version=B.version);let vn=ve.currentProgram;$e===!0&&(vn=kr(B,N,k),I&&B.isNodeMaterial&&I.onUpdateProgram(B,vn,ve));let Nn=!1,ui=!1,cs=!1;const at=vn.getUniforms(),yt=ve.uniforms;if(v.useProgram(vn.program)&&(Nn=!0,ui=!0,cs=!0),B.id!==te&&(te=B.id,ui=!0),ve.needsLights){const lt=Gf(w.state.lightProbeGridArray,k);ve.lightProbeGrid!==lt&&(ve.lightProbeGrid=lt,ui=!0)}if(Nn||j!==y){v.buffers.depth.getReversed()&&y.reversedDepth!==!0&&(y._reversedDepth=!0,y.updateProjectionMatrix()),at.setValue(L,"projectionMatrix",y.projectionMatrix),at.setValue(L,"viewMatrix",y.matrixWorldInverse);const fi=at.map.cameraPosition;fi!==void 0&&fi.setValue(L,je.setFromMatrixPosition(y.matrixWorld)),T.logarithmicDepthBuffer&&at.setValue(L,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&at.setValue(L,"isOrthographic",y.isOrthographicCamera===!0),j!==y&&(j=y,ui=!0,cs=!0)}if(ve.needsLights&&(on.state.directionalShadowMap.length>0&&at.setValue(L,"directionalShadowMap",on.state.directionalShadowMap,K),on.state.spotShadowMap.length>0&&at.setValue(L,"spotShadowMap",on.state.spotShadowMap,K),on.state.pointShadowMap.length>0&&at.setValue(L,"pointShadowMap",on.state.pointShadowMap,K)),k.isSkinnedMesh){at.setOptional(L,k,"bindMatrix"),at.setOptional(L,k,"bindMatrixInverse");const lt=k.skeleton;lt&&(lt.boneTexture===null&&lt.computeBoneTexture(),at.setValue(L,"boneTexture",lt.boneTexture,K))}k.isBatchedMesh&&(at.setOptional(L,k,"batchingTexture"),at.setValue(L,"batchingTexture",k._matricesTexture,K),at.setOptional(L,k,"batchingIdTexture"),at.setValue(L,"batchingIdTexture",k._indirectTexture,K),at.setOptional(L,k,"batchingColorTexture"),k._colorsTexture!==null&&at.setValue(L,"batchingColorTexture",k._colorsTexture,K));const di=V.morphAttributes;if((di.position!==void 0||di.normal!==void 0||di.color!==void 0)&&P.update(k,V,vn),(ui||ve.receiveShadow!==k.receiveShadow)&&(ve.receiveShadow=k.receiveShadow,at.setValue(L,"receiveShadow",k.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&N.environment!==null&&(yt.envMapIntensity.value=N.environmentIntensity),yt.dfgLUT!==void 0&&(yt.dfgLUT.value=r_()),ui){if(at.setValue(L,"toneMappingExposure",D.toneMappingExposure),ve.needsLights&&Wf(yt,cs),me&&B.fog===!0&&Te.refreshFogUniforms(yt,me),Te.refreshMaterialUniforms(yt,B,ne,re,w.state.transmissionRenderTarget[y.id]),ve.needsLights&&ve.lightProbeGrid){const lt=ve.lightProbeGrid;yt.probesSH.value=lt.texture,yt.probesMin.value.copy(lt.boundingBox.min),yt.probesMax.value.copy(lt.boundingBox.max),yt.probesResolution.value.copy(lt.resolution)}Wa.upload(L,Lh(ve),yt,K)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(Wa.upload(L,Lh(ve),yt,K),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&at.setValue(L,"center",k.center),at.setValue(L,"modelViewMatrix",k.modelViewMatrix),at.setValue(L,"normalMatrix",k.normalMatrix),at.setValue(L,"modelMatrix",k.matrixWorld),B.uniformsGroups!==void 0){const lt=B.uniformsGroups;for(let fi=0,hs=lt.length;fi<hs;fi++){const Uh=lt[fi];ee.update(Uh,vn),ee.bind(Uh,vn)}}return vn}function Wf(y,N){y.ambientLightColor.needsUpdate=N,y.lightProbe.needsUpdate=N,y.directionalLights.needsUpdate=N,y.directionalLightShadows.needsUpdate=N,y.pointLights.needsUpdate=N,y.pointLightShadows.needsUpdate=N,y.spotLights.needsUpdate=N,y.spotLightShadows.needsUpdate=N,y.rectAreaLights.needsUpdate=N,y.hemisphereLights.needsUpdate=N}function Xf(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return q},this.getActiveMipmapLevel=function(){return G},this.getRenderTarget=function(){return Z},this.setRenderTargetTextures=function(y,N,V){const B=H.get(y);B.__autoAllocateDepthBuffer=y.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),H.get(y.texture).__webglTexture=N,H.get(y.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:V,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(y,N){const V=H.get(y);V.__webglFramebuffer=N,V.__useDefaultFramebuffer=N===void 0},this.setRenderTarget=function(y,N=0,V=0){Z=y,q=N,G=V;let B=null,k=!1,me=!1;if(y){const pe=H.get(y);if(pe.__useDefaultFramebuffer!==void 0){v.bindFramebuffer(L.FRAMEBUFFER,pe.__webglFramebuffer),ie.copy(y.viewport),ue.copy(y.scissor),ke=y.scissorTest,v.viewport(ie),v.scissor(ue),v.setScissorTest(ke),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 Ge=y.depthTexture;if(pe.__boundDepthTexture!==Ge){if(Ge!==null&&H.has(Ge)&&(y.width!==Ge.image.width||y.height!==Ge.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");K.setupDepthRenderbuffer(y)}}const be=y.texture;(be.isData3DTexture||be.isDataArrayTexture||be.isCompressedArrayTexture)&&(me=!0);const Re=H.get(y).__webglFramebuffer;y.isWebGLCubeRenderTarget?(Array.isArray(Re[N])?B=Re[N][V]:B=Re[N],k=!0):y.samples>0&&K.useMultisampledRTT(y)===!1?B=H.get(y).__webglMultisampledFramebuffer:Array.isArray(Re)?B=Re[V]:B=Re,ie.copy(y.viewport),ue.copy(y.scissor),ke=y.scissorTest}else ie.copy(De).multiplyScalar(ne).floor(),ue.copy(Ae).multiplyScalar(ne).floor(),ke=xe;if(V!==0&&(B=W),v.bindFramebuffer(L.FRAMEBUFFER,B)&&v.drawBuffers(y,B),v.viewport(ie),v.scissor(ue),v.setScissorTest(ke),k){const pe=H.get(y.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+N,pe.__webglTexture,V)}else if(me){const pe=N;for(let be=0;be<y.textures.length;be++){const Re=H.get(y.textures[be]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+be,Re.__webglTexture,V,pe)}}else if(y!==null&&V!==0){const pe=H.get(y.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,pe.__webglTexture,V)}te=-1},this.readRenderTargetPixels=function(y,N,V,B,k,me,_e,pe=0){if(!(y&&y.isWebGLRenderTarget)){Ye("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let be=H.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&_e!==void 0&&(be=be[_e]),be){v.bindFramebuffer(L.FRAMEBUFFER,be);try{const Re=y.textures[pe],Ge=Re.format,We=Re.type;if(y.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+pe),!T.textureFormatReadable(Ge)){Ye("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!T.textureTypeReadable(We)){Ye("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}N>=0&&N<=y.width-B&&V>=0&&V<=y.height-k&&L.readPixels(N,V,B,k,he.convert(Ge),he.convert(We),me)}finally{const Re=Z!==null?H.get(Z).__webglFramebuffer:null;v.bindFramebuffer(L.FRAMEBUFFER,Re)}}},this.readRenderTargetPixelsAsync=async function(y,N,V,B,k,me,_e,pe=0){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let be=H.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&_e!==void 0&&(be=be[_e]),be)if(N>=0&&N<=y.width-B&&V>=0&&V<=y.height-k){v.bindFramebuffer(L.FRAMEBUFFER,be);const Re=y.textures[pe],Ge=Re.format,We=Re.type;if(y.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+pe),!T.textureFormatReadable(Ge))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!T.textureTypeReadable(We))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ce=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,Ce),L.bufferData(L.PIXEL_PACK_BUFFER,me.byteLength,L.STREAM_READ),L.readPixels(N,V,B,k,he.convert(Ge),he.convert(We),0);const it=Z!==null?H.get(Z).__webglFramebuffer:null;v.bindFramebuffer(L.FRAMEBUFFER,it);const Mt=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await Sm(L,Mt,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,Ce),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,me),L.deleteBuffer(Ce),L.deleteSync(Mt),me}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,N=null,V=0){const B=Math.pow(2,-V),k=Math.floor(y.image.width*B),me=Math.floor(y.image.height*B),_e=N!==null?N.x:0,pe=N!==null?N.y:0;K.setTexture2D(y,0),L.copyTexSubImage2D(L.TEXTURE_2D,V,0,0,_e,pe,k,me),v.unbindTexture()},this.copyTextureToTexture=function(y,N,V=null,B=null,k=0,me=0){let _e,pe,be,Re,Ge,We,Ce,it,Mt;const xt=y.isCompressedTexture?y.mipmaps[me]:y.image;if(V!==null)_e=V.max.x-V.min.x,pe=V.max.y-V.min.y,be=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 yt=Math.pow(2,-k);_e=Math.floor(xt.width*yt),pe=Math.floor(xt.height*yt),y.isDataArrayTexture?be=xt.depth:y.isData3DTexture?be=Math.floor(xt.depth*yt):be=1,Re=0,Ge=0,We=0}B!==null?(Ce=B.x,it=B.y,Mt=B.z):(Ce=0,it=0,Mt=0);const rt=he.convert(N.format),Gt=he.convert(N.type);let ve;N.isData3DTexture?(K.setTexture3D(N,0),ve=L.TEXTURE_3D):N.isDataArrayTexture||N.isCompressedArrayTexture?(K.setTexture2DArray(N,0),ve=L.TEXTURE_2D_ARRAY):(K.setTexture2D(N,0),ve=L.TEXTURE_2D),v.activeTexture(L.TEXTURE0),v.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,N.flipY),v.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),v.pixelStorei(L.UNPACK_ALIGNMENT,N.unpackAlignment);const on=v.getParameter(L.UNPACK_ROW_LENGTH),$e=v.getParameter(L.UNPACK_IMAGE_HEIGHT),vn=v.getParameter(L.UNPACK_SKIP_PIXELS),Nn=v.getParameter(L.UNPACK_SKIP_ROWS),ui=v.getParameter(L.UNPACK_SKIP_IMAGES);v.pixelStorei(L.UNPACK_ROW_LENGTH,xt.width),v.pixelStorei(L.UNPACK_IMAGE_HEIGHT,xt.height),v.pixelStorei(L.UNPACK_SKIP_PIXELS,Re),v.pixelStorei(L.UNPACK_SKIP_ROWS,Ge),v.pixelStorei(L.UNPACK_SKIP_IMAGES,We);const cs=y.isDataArrayTexture||y.isData3DTexture,at=N.isDataArrayTexture||N.isData3DTexture;if(y.isDepthTexture){const yt=H.get(y),di=H.get(N),lt=H.get(yt.__renderTarget),fi=H.get(di.__renderTarget);v.bindFramebuffer(L.READ_FRAMEBUFFER,lt.__webglFramebuffer),v.bindFramebuffer(L.DRAW_FRAMEBUFFER,fi.__webglFramebuffer);for(let hs=0;hs<be;hs++)cs&&(L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,H.get(y).__webglTexture,k,We+hs),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,H.get(N).__webglTexture,me,Mt+hs)),L.blitFramebuffer(Re,Ge,_e,pe,Ce,it,_e,pe,L.DEPTH_BUFFER_BIT,L.NEAREST);v.bindFramebuffer(L.READ_FRAMEBUFFER,null),v.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(k!==0||y.isRenderTargetTexture||H.has(y)){const yt=H.get(y),di=H.get(N);v.bindFramebuffer(L.READ_FRAMEBUFFER,X),v.bindFramebuffer(L.DRAW_FRAMEBUFFER,F);for(let lt=0;lt<be;lt++)cs?L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,yt.__webglTexture,k,We+lt):L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,yt.__webglTexture,k),at?L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,di.__webglTexture,me,Mt+lt):L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,di.__webglTexture,me),k!==0?L.blitFramebuffer(Re,Ge,_e,pe,Ce,it,_e,pe,L.COLOR_BUFFER_BIT,L.NEAREST):at?L.copyTexSubImage3D(ve,me,Ce,it,Mt+lt,Re,Ge,_e,pe):L.copyTexSubImage2D(ve,me,Ce,it,Re,Ge,_e,pe);v.bindFramebuffer(L.READ_FRAMEBUFFER,null),v.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else at?y.isDataTexture||y.isData3DTexture?L.texSubImage3D(ve,me,Ce,it,Mt,_e,pe,be,rt,Gt,xt.data):N.isCompressedArrayTexture?L.compressedTexSubImage3D(ve,me,Ce,it,Mt,_e,pe,be,rt,xt.data):L.texSubImage3D(ve,me,Ce,it,Mt,_e,pe,be,rt,Gt,xt):y.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,me,Ce,it,_e,pe,rt,Gt,xt.data):y.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,me,Ce,it,xt.width,xt.height,rt,xt.data):L.texSubImage2D(L.TEXTURE_2D,me,Ce,it,_e,pe,rt,Gt,xt);v.pixelStorei(L.UNPACK_ROW_LENGTH,on),v.pixelStorei(L.UNPACK_IMAGE_HEIGHT,$e),v.pixelStorei(L.UNPACK_SKIP_PIXELS,vn),v.pixelStorei(L.UNPACK_SKIP_ROWS,Nn),v.pixelStorei(L.UNPACK_SKIP_IMAGES,ui),me===0&&N.generateMipmaps&&L.generateMipmap(ve),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(){q=0,G=0,Z=null,v.reset(),ge.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return qn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Ke._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ke._getUnpackColorSpace()}}const vh=`
4758
+ vec3 encodeSrgb(vec3 linear) {
4759
+ vec3 clamped = max(linear, vec3(0.0));
4760
+ vec3 low = clamped * 12.92;
4761
+ vec3 high = 1.055 * pow(clamped, vec3(1.0 / 2.4)) - 0.055;
4762
+ return mix(low, high, step(vec3(0.0031308), clamped));
4763
+ }
4764
+ `;class o_{frameTarget;filmTarget;quadScene=new po;quadCamera=new er(-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 an(this.width,this.height,{type:Qt}),this.filmTarget=new an(this.width,this.height,{type:Qt});const n=`
4765
+ varying vec2 vUv;
4766
+ void main() {
4767
+ vUv = position.xy * 0.5 + 0.5;
4768
+ gl_Position = vec4(position.xy, 0.0, 1.0);
4769
+ }
4770
+ `;this.addMaterial=new Et({uniforms:{uSource:{value:this.frameTarget.texture},uShare:{value:1}},vertexShader:n,fragmentShader:`
4771
+ precision highp float;
4772
+ varying vec2 vUv;
4773
+ uniform sampler2D uSource;
4774
+ uniform float uShare;
4775
+ void main() {
4776
+ gl_FragColor = vec4(texture2D(uSource, vUv).rgb * uShare, 1.0);
4777
+ }
4778
+ `,blending:li,depthTest:!1,depthWrite:!1}),this.developMaterial=new Et({uniforms:{uFilm:{value:this.filmTarget.texture},uGain:{value:1}},vertexShader:n,fragmentShader:`
4779
+ precision highp float;
4780
+ ${vh}
4781
+ varying vec2 vUv;
4782
+ uniform sampler2D uFilm;
4783
+ uniform float uGain;
4784
+ void main() {
4785
+ gl_FragColor = vec4(encodeSrgb(texture2D(uFilm, vUv).rgb * uGain), 1.0);
4786
+ }
4787
+ `,blending:Kn,depthTest:!1,depthWrite:!1}),this.quad=new Je(new Ui(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 wc=Math.PI/180,td=180/Math.PI;function Or(i,e,t){return Math.max(e,Math.min(t,i))}const yi=[{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 al(i,e,t){return i+(e-i)*t}function to(i,e,t){return[al(i[0],e[0],t),al(i[1],e[1],t),al(i[2],e[2],t)]}function Ac(i){const e=Math.max(yi[0].altitudeDeg,Math.min(yi[yi.length-1].altitudeDeg,i));for(let n=0;n<yi.length-1;n++){const s=yi[n],r=yi[n+1];if(e>=s.altitudeDeg&&e<=r.altitudeDeg){const a=(e-s.altitudeDeg)/(r.altitudeDeg-s.altitudeDeg);return{zenith:to(s.zenith,r.zenith,a),horizon:to(s.horizon,r.horizon,a)}}}const t=yi[yi.length-1];return{zenith:t.zenith,horizon:t.horizon}}const nd=-18,id=-4,l_=1.8;function sd(i){if(i<=nd)return Xa;if(i>=0)return id;const e=i/nd;return Xa-(Xa-id)*(1-e)**l_}const c_=-1.5,Xa=6.5,rd=Xa,h_=1.6;function ol(i){const e=(rd-i)/(rd-c_);return Or(e,0,1)**h_}function rn(i,e,t){const n=i*wc,s=e*wc,r=t*Math.cos(n);return{x:r*Math.sin(s),y:t*Math.sin(n),z:-r*Math.cos(s)}}function u_(i,e,t){const n=Math.sqrt(i*i+e*e+t*t),s=n===0?0:Math.asin(Or(e/n,-1,1))*td,r=(Math.atan2(i,-t)*td+360)%360;return{altitudeDeg:s,azimuthDeg:r}}function d_(i,e){const t=Math.abs(i-e)%360;return t>180?360-t:t}function f_(i,e,t,n){const s=Math.max(0,1-d_(i,t)/p_),r=Math.exp(-Math.max(0,e)/m_),a=n>0?Math.max(0,1-n/g_):Math.max(0,1-Math.abs(n+v_)/x_);return s*r*a}const p_=90,m_=12,g_=8,v_=2,x_=12;function __(i,e,t,n){const{zenith:s,horizon:r}=Ac(n),a=Or((i+90)/180,0,1),o=to(r,s,a),l=f_(e,i,t,n);if(l<=0)return o;const c=Ac(n+M_).horizon,h=[Math.max(r[0],c[0]),Math.max(r[1],c[1]),Math.max(r[2],c[2])];return to(o,h,l)}const M_=6;function ll(i){return .12+.88*i}const y_=-4;function S_(i){return Math.max(0,y_-i)}const b_=6,E_=60;function w_(i){return Math.min(E_,b_*Math.sqrt(i))}const A_=3,T_=.55;function R_(i){return T_*Or(i/A_,0,1)}function Z0(i){const e=Math.max(i,-4),t=Math.sin(e*wc)+.50572*Math.pow(e+6.07995,-1.6364);return Or(1/t,1,40)}function Gi(i){const e=Z0(i)-1;return[1,Math.exp(-.022*e),Math.exp(-.062*e)]}function C_(i){return P_*(Z0(Math.max(i,0))-1)}function D_(i){return Math.pow(10,-.4*C_(i))}const P_=5/37,J0=[{maxBrightness:.35,size:1.2},{maxBrightness:.7,size:2},{maxBrightness:1/0,size:3.2}];function I_(i){return J0.findIndex(e=>i<=e.maxBrightness)}const L_=.25,ad=.3,N_=2.2;function U_(i,{phase:e,speedFactor:t},n){const r=1+L_*(ad+(1-ad)*i)*Math.sin(n*N_*t+e);return Math.min(1,Math.max(0,r))}/**
4758
4788
  @preserve
4759
4789
 
4760
4790
  Astronomy library for JavaScript (browser and Node.js).
@@ -4785,11 +4815,11 @@ void main() {
4785
4815
  * @fileoverview Astronomy calculation library for browser scripting and Node.js.
4786
4816
  * @author Don Cross <cosinekitty@gmail.com>
4787
4817
  * @license MIT
4788
- */const ph=173.1446326846693,qi=14959787069098932e-8,tt=.017453292519943295,nd=.26179938779914946,$n=57.29577951308232,Y0=3.819718634205488,Ix=365.24217,id=new Date("2000-01-01T12:00:00Z"),ti=2*Math.PI,Mi=3600*(180/Math.PI),Us=484813681109536e-20,K0=10800*60,Lx=2*K0,sd=7292115e-11,Nx=K0/Math.PI,Ux=-.17-5*Math.log10(Nx),Ec=.996647180302104,Fx=Ec*Ec,wc=6378.1366,Ox=wc/qi,$0=81.30056,mh=.0002959122082855911,Ac=2825345909524226e-22,Tc=8459715185680659e-23,Rc=1292024916781969e-23,Cc=1524358900784276e-23;function eo(i){if(i!==!0&&i!==!1)throw console.trace(),`Value is not boolean: ${i}`;return i}function kt(i){if(!Number.isFinite(i))throw console.trace(),`Value is not a finite number: ${i}`;return i}function Cs(i){return i-Math.floor(i)}function zx(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:$n*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 Bx=[Se.Star1,Se.Star2,Se.Star3,Se.Star4,Se.Star5,Se.Star6,Se.Star7,Se.Star8],kx=[{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 Hx(i){const e=Bx.indexOf(i);return e>=0?kx[e]:null}function gh(i){const e=Hx(i);return e&&e.dist>0?e:null}var Qt;(function(i){i[i.From2000=0]="From2000",i[i.Into2000=1]="Into2000"})(Qt||(Qt={}));const Yn={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 Gx(i){var e,t,n,s,r,a,o;const l=2e3+(i-14)/Ix;return l<-500?(e=(l-1820)/100,-20+32*e*e):l<500?(e=l/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):l<1600?(e=(l-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):l<1700?(e=l-1600,t=e*e,n=e*t,120-.9808*e-.01532*t+n/7129):l<1800?(e=l-1700,t=e*e,n=e*t,s=t*t,8.83+.1603*e-.0059285*t+13336e-8*n-s/1174e3):l<1860?(e=l-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):l<1900?(e=l-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):l<1920?(e=l-1900,t=e*e,n=e*t,s=t*t,-2.79+1.494119*e-.0598939*t+.0061966*n-197e-6*s):l<1941?(e=l-1920,t=e*e,n=e*t,21.2+.84493*e-.0761*t+.0020936*n):l<1961?(e=l-1950,t=e*e,n=e*t,29.07+.407*e-t/233+n/2547):l<1986?(e=l-1975,t=e*e,n=e*t,45.45+1.067*e-t/260-n/718):l<2005?(e=l-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):l<2050?(e=l-2e3,62.92+.32217*e+.005589*e*e):l<2150?(e=(l-1820)/100,-20+32*e*e-.5628*(2150-l)):(e=(l-1820)/100,-20+32*e*e)}let Vx=Gx;function rd(i){return i+Vx(i)/86400}class Vs{constructor(e){if(e instanceof Vs){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 Vs(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 Vs(this.ut+e)}}function Ut(i){return i instanceof Vs?i:new Vs(i)}function Wx(i){function e(d){return d%Lx*Us}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),l=Math.cos(a),c=(-172064161-174666*t)*o+33386*l,h=(92052331+9086*t)*l+15377*o,u=2*(s-r+a);return o=Math.sin(u),l=Math.cos(u),c+=(-13170906-1675*t)*o-13696*l,h+=(5730336-3015*t)*l-4587*o,u=2*(s+a),o=Math.sin(u),l=Math.cos(u),c+=(-2276413-234*t)*o+2796*l,h+=(978459-485*t)*l+1374*o,u=2*a,o=Math.sin(u),l=Math.cos(u),c+=(2074554+207*t)*o-698*l,h+=(-897492+470*t)*l-291*o,o=Math.sin(n),l=Math.cos(n),c+=(1475877-3633*t)*o+11817*l,h+=(73871-184*t)*l-1924*o,{dpsi:-135e-6+c*1e-7,deps:388e-6+h*1e-7}}function Z0(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 xa;function Ur(i){if(!xa||Math.abs(xa.tt-i.tt)>1e-6){const e=Wx(i),t=Z0(i),n=t+e.deps/3600;xa={tt:i.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*tt)/15,mobl:t,tobl:n}}return xa}function Xx(i,e){const t=i*tt,n=Math.cos(t),s=Math.sin(t);return[e[0],e[1]*n-e[2]*s,e[1]*s+e[2]*n]}function qx(i,e){return Xx(Z0(i),e)}function Yx(i){const e=i.tt/36525;function t(Ae,_e){const Ie=[];let Ne;for(Ne=0;Ne<=_e-Ae;++Ne)Ie.push(0);return{min:Ae,array:Ie}}function n(Ae,_e,Ie,Ne){const Ue=[];for(let Je=0;Je<=_e-Ae;++Je)Ue.push(t(Ie,Ne));return{min:Ae,array:Ue}}function s(Ae,_e,Ie){const Ne=Ae.array[_e-Ae.min];return Ne.array[Ie-Ne.min]}function r(Ae,_e,Ie,Ne){const Ue=Ae.array[_e-Ae.min];Ue.array[Ie-Ue.min]=Ne}let a,o,l,c,h,u,d,f,g,x,m,p,E,A,M,S,w,R,_,b,D,C,I,W=n(-6,6,1,4),X=n(-6,6,1,4);function F(Ae,_e){return s(W,Ae,_e)}function q(Ae,_e){return s(X,Ae,_e)}function G(Ae,_e,Ie){return r(W,Ae,_e,Ie)}function Z(Ae,_e,Ie){return r(X,Ae,_e,Ie)}function te(Ae,_e,Ie,Ne,Ue){Ue(Ae*Ie-_e*Ne,_e*Ie+Ae*Ne)}function j(Ae){return Math.sin(ti*Ae)}d=e*e,g=0,I=0,m=0,p=3422.7;var ie=j(.19833+.05611*e),ue=j(.27869+.04508*e),ke=j(.16827-.36903*e),qe=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*ke+7.26*qe+.28*Be+.24*Y,_=2.94*ie+.31*ue+14.27*ke+9.34*qe+1.12*Be+.83*Y,b=-6.4*ie-1.89*Y,D=.21*ie+.31*ue+14.27*ke-88.7*qe-15.3*Be+.24*Y-1.86*re,C=R-b,f=-3332e-9*j(.59734-5.37261*e)-539e-9*j(.35498-5.37899*e)-64e-9*j(.39943-5.37511*e),E=ti*Cs(.60643382+1336.85522467*e-313e-8*d)+R/Mi,A=ti*Cs(.37489701+1325.55240982*e+2565e-8*d)+_/Mi,M=ti*Cs(.99312619+99.99735956*e-44e-8*d)+b/Mi,S=ti*Cs(.25909118+1342.2278298*e-892e-8*d)+D/Mi,w=ti*Cs(.82736186+1236.85308708*e-397e-8*d)+C/Mi,h=1;h<=4;++h){switch(h){case 1:l=A,o=4,c=1.000002208;break;case 2:l=M,o=3,c=.997504612-.002495388*e;break;case 3:l=S,o=4,c=1.000002708+139.978*f;break;case 4:l=w,o=6,c=1;break;default:throw`Internal error: I = ${h}`}for(G(0,h,1),G(1,h,Math.cos(l)*c),Z(0,h,0),Z(1,h,Math.sin(l)*c),u=2;u<=o;++u)te(F(u-1,h),q(u-1,h),F(1,h),q(1,h),(Ae,_e)=>(G(u,h,Ae),Z(u,h,_e)));for(u=1;u<=o;++u)G(-u,h,F(u,h)),Z(-u,h,-q(u,h))}function ne(Ae,_e,Ie,Ne){for(var Ue={x:1,y:0},Je=[0,Ae,_e,Ie,Ne],Qe=1;Qe<=4;++Qe)Je[Qe]!==0&&te(Ue.x,Ue.y,F(Je[Qe],Qe),q(Je[Qe],Qe),(mt,dt)=>(Ue.x=mt,Ue.y=dt));return Ue}function z(Ae,_e,Ie,Ne,Ue,Je,Qe,mt){var dt=ne(Ue,Je,Qe,mt);g+=Ae*dt.y,I+=_e*dt.y,m+=Ie*dt.x,p+=Ne*dt.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 Ee(Ae,_e,Ie,Ne,Ue){return Ae*ne(_e,Ie,Ne,Ue).y}x=0,x+=Ee(-526.069,0,0,1,-2),x+=Ee(-3.352,0,0,1,-4),x+=Ee(44.297,1,0,1,-2),x+=Ee(-6,1,0,1,-4),x+=Ee(20.599,-1,0,1,0),x+=Ee(-30.598,-1,0,1,-2),x+=Ee(-24.649,-2,0,1,0),x+=Ee(-2,-2,0,1,-2),x+=Ee(-22.571,0,1,1,-2),x+=Ee(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/Mi;let De=(1.000002708+139.978*f)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+x;return{geo_eclip_lon:ti*Cs((E+g/Mi)/ti),geo_eclip_lat:Math.PI/(180*3600)*De,distance_au:Mi*Ox/(.999953253*p)}}function J0(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 to(i,e,t){const n=Q0(e,t);return J0(n,i)}function Q0(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*=Us,s*=Us,r*=Us,a*=Us;const o=Math.sin(n),l=Math.cos(n),c=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-c*f*d,m=g*c*l+f*d*h*l-o*f*u,p=g*c*o+f*d*h*o+l*f*u,E=-f*h-c*g*d,A=-f*c*l+g*d*h*l-o*g*u,M=-f*c*o+g*d*h*o+l*g*u,S=c*u,w=-u*h*l-o*d,R=-u*h*o+d*l;if(e===Qt.Into2000)return new Ii([[x,m,p],[E,A,M],[S,w,R]]);if(e===Qt.From2000)return new Ii([[x,E,S],[m,A,w],[p,M,R]]);throw"Invalid precess direction"}function Kx(i){const e=.779057273264+.00273781191135448*i.ut,t=i.ut%1;let n=360*((e+t)%1);return n<0&&(n+=360),n}let Ma;function vh(i){if(!Ma||Ma.tt!==i.tt){const e=i.tt/36525;let t=15*Ur(i).ee;const n=Kx(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),Ma={tt:i.tt,st:r}}return Ma.st}function j0(i,e){const t=i.latitude*tt,n=Math.sin(t),s=Math.cos(t),r=1/Math.hypot(s,Ec*n),a=Fx*r,o=i.height/1e3,l=wc*r+o,c=wc*a+o,h=(15*e+i.longitude)*tt,u=Math.sin(h),d=Math.cos(h);return{pos:[l*s*d/qi,l*s*u/qi,c*n/qi],vel:[-sd*l*s*u*86400/qi,sd*l*s*d*86400/qi,0]}}function Dc(i,e,t){const n=ef(e,t);return J0(n,i)}function ef(i,e){const t=Ur(i),n=t.mobl*tt,s=t.tobl*tt,r=t.dpsi*Us,a=Math.cos(n),o=Math.sin(n),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),u=Math.sin(r),d=h,f=-u*a,g=-u*o,x=u*l,m=h*a*l+o*c,p=h*o*l-a*c,E=u*c,A=h*a*c-o*l,M=h*o*c+a*l;if(e===Qt.From2000)return new Ii([[d,x,E],[f,m,A],[g,p,M]]);if(e===Qt.Into2000)return new Ii([[d,f,g],[x,m,p],[E,A,M]]);throw"Invalid precess direction"}function _h(i,e,t){return t===Qt.Into2000?to(Dc(i,e,t),e,t):Dc(to(i,e,t),e,t)}function $x(i,e){const t=vh(i),n=j0(e,t).pos;return _h(n,i,Qt.Into2000)}class ut{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 wi{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 xh{constructor(e,t,n){this.lat=kt(e),this.lon=kt(t),this.dist=kt(n)}}class Pc{constructor(e,t,n,s){this.ra=kt(e),this.dec=kt(t),this.dist=kt(n),this.vec=s}}class Ii{constructor(e){this.rot=e}}class Zx{constructor(e,t,n,s){this.azimuth=kt(e),this.altitude=kt(t),this.ra=kt(n),this.dec=kt(s)}}class Jx{constructor(e,t,n){this.vec=e,this.elat=kt(t),this.elon=kt(n)}}function tf(i,e){return new ut(i[0],i[1],i[2],e)}function Qx(i,e){const t=tf(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 Pc(0,t.z<0?-90:90,s,t)}let r=Y0*Math.atan2(t.y,t.x);r<0&&(r+=24);const a=$n*Math.atan2(i[2],Math.sqrt(n));return new Pc(r,a,s,t)}function al(i,e){const t=i*tt,n=Math.cos(t),s=Math.sin(t);return[n*e[0]+s*e[1],n*e[1]-s*e[0],e[2]]}function nf(i,e,t,n,s){let r=Ut(i);Mh(e),kt(t),kt(n);const a=Math.sin(e.latitude*tt),o=Math.cos(e.latitude*tt),l=Math.sin(e.longitude*tt),c=Math.cos(e.longitude*tt),h=Math.sin(n*tt),u=Math.cos(n*tt),d=Math.sin(t*nd),f=Math.cos(t*nd);let g=[o*c,o*l,a],x=[-a*c,-a*l,o],m=[l,-c,0];const p=-15*vh(r);let E=al(p,g),A=al(p,x),M=al(p,m),S=[u*f,u*d,h];const w=S[0]*E[0]+S[1]*E[1]+S[2]*E[2],R=S[0]*A[0]+S[1]*A[1]+S[2]*A[2],_=S[0]*M[0]+S[1]*M[1]+S[2]*M[2];let b=Math.hypot(R,_),D;b>0?(D=-$n*Math.atan2(_,R),D<0&&(D+=360)):D=0;let C=$n*Math.atan2(b,w),I=t,W=n;{let X=C,F=S3(s,90-C);if(C-=F,F>0&&C>3e-4){const q=Math.sin(C*tt),G=Math.cos(C*tt),Z=Math.sin(X*tt),te=Math.cos(X*tt),j=[];for(let ie=0;ie<3;++ie)j.push((S[ie]-te*E[ie])/Z*q+E[ie]*G);b=Math.hypot(j[0],j[1]),b>0?(I=Y0*Math.atan2(j[1],j[0]),I<0&&(I+=24)):I=0,W=$n*Math.atan2(j[2],b)}}return new Zx(D,90-C,I,W)}function Mh(i){if(!(i instanceof yh))throw`Not an instance of the Observer class: ${i}`;if(kt(i.latitude),kt(i.longitude),kt(i.height),i.latitude<-90||i.latitude>90)throw`Latitude ${i.latitude} is out of range. Must be -90..+90.`;return i}class yh{constructor(e,t,n){this.latitude=e,this.longitude=t,this.height=n,Mh(this)}}function jx(i){const e=Ut(i).AddDays(-1/ph),t=Xs(Yn.Earth,e),n=[-t.x,-t.y,-t.z],[s,r,a]=_h(n,e,Qt.From2000),o=tt*Ur(e).tobl,l=Math.cos(o),c=Math.sin(o),h=new ut(s,r,a,e);return sf(h,l,c)}function e3(i,e,t,n,s){Mh(t),eo(n),eo(s);const r=Ut(e),a=$x(r,t),o=Hc(i,r,s),l=[o.x-a[0],o.y-a[1],o.z-a[2]],c=_h(l,r,Qt.From2000);return Qx(c,r)}function t3(i,e,t){const n=Ut(i),s=vh(n);let r=j0(e,s).pos;return tf(r,n)}function sf(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=$n*Math.atan2(s,n),o<0&&(o+=360));let l=$n*Math.atan2(r,a),c=new ut(n,s,r,i.t);return new Jx(c,l,o)}function Ic(i){const e=Ur(i.t),t=[i.x,i.y,i.z],n=to(t,i.t,Qt.From2000),[s,r,a]=Dc(n,i.t,Qt.From2000),o=new ut(s,r,a,i.t),l=e.tobl*tt;return sf(o,Math.cos(l),Math.sin(l))}function Zs(i){const e=Ut(i),t=Yx(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=qx(e,s),a=to(r,e,Qt.Into2000);return new ut(a[0],a[1],a[2],e)}function rf(i){const e=Ut(i),t=1e-5,n=e.AddDays(-t),s=e.AddDays(+t),r=Zs(n),a=Zs(s);return new wi((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 n3(i){const e=Ut(i),t=rf(e),n=1+$0;return new wi(t.x/n,t.y/n,t.z/n,t.vx/n,t.vy/n,t.vz/n,e)}function Ws(i,e,t){let n=1,s=0;for(let r of i){let a=0;for(let[l,c,h]of r)a+=l*Math.cos(c+e*h);let o=n*a;t&&(o%=ti),s+=o,n*=e}return s}function ol(i,e){let t=1,n=0,s=0,r=0;for(let a of i){let o=0,l=0;for(let[c,h,u]of a){let d=h+e*u;o+=c*u*Math.sin(d),r>0&&(l+=c*Math.cos(d))}s+=r*n*l-t*o,n=t,t*=e,++r}return s}const gr=365250,Lc=0,Nc=1,Uc=2;function Fc(i){return new Xt(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 af(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 Xs(i,e){const t=e.tt/gr,n=Ws(i[Lc],t,!0),s=Ws(i[Nc],t,!1),r=Ws(i[Uc],t,!1),a=af(n,s,r);return Fc(a).ToAstroVector(e)}function Oc(i,e){const t=e/gr,n=Ws(i[Lc],t,!0),s=Ws(i[Nc],t,!1),r=Ws(i[Uc],t,!1),a=ol(i[Lc],t),o=ol(i[Nc],t),l=ol(i[Uc],t),c=Math.cos(n),h=Math.sin(n),u=Math.cos(s),d=Math.sin(s),f=+(l*u*c)-r*d*c*o-r*u*h*a,g=+(l*u*h)-r*d*h*o+r*u*c*a,x=+(l*d)+r*u*o,m=af(n,s,r),p=[f/gr,g/gr,x/gr],E=Fc(m),A=Fc(p);return new ns(e,E,A)}function ya(i,e,t,n){const s=n/(n+mh),r=Xs(Yn[t],e);i.x+=s*r.x,i.y+=s*r.y,i.z+=s*r.z}function i3(i){const e=new ut(0,0,0,i);return ya(e,i,Se.Jupiter,Ac),ya(e,i,Se.Saturn,Tc),ya(e,i,Se.Uranus,Rc),ya(e,i,Se.Neptune,Cc),e}const zc=51,s3=29200,Fs=146,ni=201,Zi=[[-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 Xt{constructor(e,t,n){this.x=e,this.y=t,this.z=n}clone(){return new Xt(this.x,this.y,this.z)}ToAstroVector(e){return new ut(this.x,this.y,this.z,e)}static zero(){return new Xt(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new Xt(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new Xt(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 Xt(e*this.x,e*this.y,e*this.z)}div(e){return new Xt(this.x/e,this.y/e,this.z/e)}mean(e){return new Xt((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new Xt(-this.x,-this.y,-this.z)}}class ns{constructor(e,t,n){this.tt=e,this.r=t,this.v=n}clone(){return new ns(this.tt,this.r,this.v)}sub(e){return new ns(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function r3(i){let[e,[t,n,s],[r,a,o]]=i;return new ns(e,new Xt(t,n,s),new Xt(r,a,o))}function Sa(i,e,t,n){const s=n/(n+mh),r=Oc(Yn[t],e);return i.r.incr(r.r.mul(s)),i.v.incr(r.v.mul(s)),r}function cr(i,e,t){const n=t.sub(i),s=n.quadrature();return n.mul(e/(s*Math.sqrt(s)))}class go{constructor(e){let t=new ns(e,new Xt(0,0,0),new Xt(0,0,0));this.Jupiter=Sa(t,e,Se.Jupiter,Ac),this.Saturn=Sa(t,e,Se.Saturn,Tc),this.Uranus=Sa(t,e,Se.Uranus,Rc),this.Neptune=Sa(t,e,Se.Neptune,Cc),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 ns(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=cr(e,mh,this.Sun.r);return t.incr(cr(e,Ac,this.Jupiter.r)),t.incr(cr(e,Tc,this.Saturn.r)),t.incr(cr(e,Rc,this.Uranus.r)),t.incr(cr(e,Cc,this.Neptune.r)),t}}class vo{constructor(e,t,n,s){this.tt=e,this.r=t,this.v=n,this.a=s}clone(){return new vo(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class of{constructor(e,t){this.bary=e,this.grav=t}}function no(i,e,t,n){return new Xt(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 Xt(e.x+i*t.x,e.y+i*t.y,e.z+i*t.z)}function Bc(i,e){const t=i-e.tt,n=new go(i),s=no(t,e.r,e.v,e.a),r=n.Acceleration(s).mean(e.a),a=no(t,e.r,e.v,r),o=e.v.add(r.mul(t)),l=n.Acceleration(a),c=new vo(i,a,o,l);return new of(n,c)}const a3=[];function lf(i,e){const t=Math.floor(i);return t<0?0:t>=e?e-1:t}function kc(i){const e=r3(i),t=new go(e.tt),n=e.r.add(t.Sun.r),s=e.v.add(t.Sun.v),r=t.Acceleration(n),a=new vo(e.tt,n,s,r);return new of(t,a)}function o3(i,e){const t=Zi[0][0];if(e<t||e>Zi[zc-1][0])return null;const n=lf((e-t)/s3,zc-1);if(!i[n]){const r=i[n]=[];r[0]=kc(Zi[n]).grav,r[ni-1]=kc(Zi[n+1]).grav;let a,o=r[0].tt;for(a=1;a<ni-1;++a)r[a]=Bc(o+=Fs,r[a-1]).grav;o=r[ni-1].tt;var s=[];for(s[ni-1]=r[ni-1],a=ni-2;a>0;--a)s[a]=Bc(o-=Fs,s[a+1]).grav;for(a=ni-2;a>0;--a){const l=a/(ni-1);r[a].r=r[a].r.mul(1-l).add(s[a].r.mul(l)),r[a].v=r[a].v.mul(1-l).add(s[a].v.mul(l)),r[a].a=r[a].a.mul(1-l).add(s[a].a.mul(l))}}return i[n]}function od(i,e,t){let n=kc(i);const s=Math.ceil((e-n.grav.tt)/t);for(let r=0;r<s;++r)n=Bc(r+1===s?e:n.grav.tt+t,n.grav);return n}function cf(i,e){let t,n,s;const r=o3(a3,i.tt);if(r){const a=lf((i.tt-r[0].tt)/Fs,ni-1),o=r[a],l=r[a+1],c=o.a.mean(l.a),h=no(i.tt-o.tt,o.r,o.v,c),u=ad(i.tt-o.tt,o.v,c),d=no(i.tt-l.tt,l.r,l.v,c),f=ad(i.tt-l.tt,l.v,c),g=(i.tt-o.tt)/Fs;t=h.mul(1-g).add(d.mul(g)),n=u.mul(1-g).add(f.mul(g))}else{let a;i.tt<Zi[0][0]?a=od(Zi[0],i.tt,-Fs):a=od(Zi[zc-1],i.tt,+Fs),t=a.grav.r,n=a.grav.v,s=a.bary}return s||(s=new go(i.tt)),t=t.sub(s.Sun.r),n=n.sub(s.Sun.v),new wi(t.x,t.y,t.z,n.x,n.y,n.z,i)}function Ri(i,e){var t=Ut(e);if(i in Yn)return Xs(Yn[i],t);if(i===Se.Pluto){const a=cf(t);return new ut(a.x,a.y,a.z,t)}if(i===Se.Sun)return new ut(0,0,0,t);if(i===Se.Moon){var n=Xs(Yn.Earth,t),s=Zs(t);return new ut(n.x+s.x,n.y+s.y,n.z+s.z,t)}if(i===Se.EMB){const a=Xs(Yn.Earth,t),o=Zs(t),l=1+$0;return new ut(a.x+o.x/l,a.y+o.y/l,a.z+o.z/l,t)}if(i===Se.SSB)return i3(t);const r=gh(i);if(r){const a=new xh(r.dec,15*r.ra,r.dist);return uf(a,t)}throw`HelioVector: Unknown body "${i}"`}function l3(i,e){let t=e,n=0;for(let s=0;s<10;++s){const r=i(t),a=r.Length()/ph;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 c3{constructor(e,t,n,s){this.observerBody=e,this.targetBody=t,this.aberration=n,this.observerPos=s}Position(e){this.aberration&&(this.observerPos=Ri(this.observerBody,e));const t=Ri(this.targetBody,e);return new ut(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function h3(i,e,t,n){eo(n);const s=Ut(i);if(gh(t)){const o=Ri(t,s);if(n){const c=d3(e,s),h=new ut(o.x-c.x,o.y-c.y,o.z-c.z,s),u=ph/h.Length();return new ut(h.x+c.vx/u,h.y+c.vy/u,h.z+c.vz/u,s)}const l=Ri(e,s);return new ut(o.x-l.x,o.y-l.y,o.z-l.z,s)}let r;n?r=new ut(0,0,0,s):r=Ri(e,s);const a=new c3(e,t,n,r);return l3(o=>a.Position(o),s)}function Hc(i,e,t){eo(t);const n=Ut(e);switch(i){case Se.Earth:return new ut(0,0,0,n);case Se.Moon:return Zs(n);default:const s=h3(n,Se.Earth,i,t);return s.t=n,s}}function u3(i,e){return new wi(i.r.x,i.r.y,i.r.z,i.v.x,i.v.y,i.v.z,e)}function d3(i,e){const t=Ut(e);switch(i){case Se.Sun:return new wi(0,0,0,0,0,0,t);case Se.SSB:const n=new go(t.tt);return new wi(-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=Oc(Yn[i],t.tt);return u3(s,t);case Se.Pluto:return cf(t);case Se.Moon:case Se.EMB:const r=Oc(Yn.Earth,t.tt),a=i==Se.Moon?rf(t):n3(t);return new wi(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(gh(i)){const o=Ri(i,t);return new wi(o.x,o.y,o.z,0,0,0,t)}throw`HelioState: Unsupported body "${i}"`}}function f3(i){for(;i<0;)i+=360;for(;i>=360;)i-=360;return i}function p3(i,e,t){if(i===Se.Earth||e===Se.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=Ut(t),s=Hc(i,n,!1),r=Ic(s),a=Hc(e,n,!1),o=Ic(a);return f3(r.elon-o.elon)}function m3(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 l=e/100;let c=s+l*(r+l*(a+l*o));return c+=5*Math.log10(t*n),c}function g3(i,e,t,n,s){const r=Ic(n),a=tt*28.06,o=tt*(169.51+382e-7*s.tt),l=tt*r.elat,c=tt*r.elon,h=Math.asin(Math.sin(l)*Math.cos(a)-Math.cos(l)*Math.sin(a)*Math.sin(c-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:$n*h}}function v3(i,e,t){let n=i*tt,s=n*n,r=s*s,a=-12.717+1.49*Math.abs(n)+.0431*r;const o=385000.6/qi;let l=t/o;return a+=5*Math.log10(e*l),a}class _3{constructor(e,t,n,s,r,a,o,l){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=l,this.phase_fraction=(1+Math.cos(tt*n))/2}}function hf(i,e){if(i===Se.Earth)throw"The illumination of the Earth is not defined.";const t=Ut(e),n=Xs(Yn.Earth,t);let s,r,a,o;i===Se.Sun?(a=new ut(-n.x,-n.y,-n.z,t),r=new ut(0,0,0,t),s=0):(i===Se.Moon?(a=Zs(t),r=new ut(n.x+a.x,n.y+a.y,n.z+a.z,t)):(r=Ri(i,e),a=new ut(r.x-n.x,r.y-n.y,r.z-n.z,t)),s=zx(a,r));let l=a.Length(),c=r.Length(),h;if(i===Se.Sun)o=Ux+5*Math.log10(l);else if(i===Se.Moon)o=v3(s,c,l);else if(i===Se.Saturn){const u=g3(s,c,l,a,t);o=u.mag,h=u.ring_tilt}else o=m3(i,s,c,l);return new _3(t,o,s,c,l,a,r,h)}function x3(i){return p3(Se.Moon,Se.Sun,i)}var ld;(function(i){i[i.Pericenter=0]="Pericenter",i[i.Apocenter=1]="Apocenter"})(ld||(ld={}));function M3(i,e){return new Ii([[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 uf(i,e){e=Ut(e);const t=i.lat*tt,n=i.lon*tt,s=i.dist*Math.cos(t);return new ut(s*Math.cos(n),s*Math.sin(n),i.dist*Math.sin(t),e)}function df(i){const e=y3(i);return new Pc(e.lon/15,e.lat,e.dist,i)}function y3(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=$n*Math.atan2(i.y,i.x),s<0&&(s+=360),n=$n*Math.atan2(i.z,Math.sqrt(e));return new xh(n,s,t)}function S3(i,e){let t;if(kt(e),e<-90||e>90)return 0;{let n=e;n<-1&&(n=-1),t=1.02/Math.tan((n+10.3/(n+5.11))*tt)/60,e<-1&&(t*=(e+90)/89)}return t}function Va(i,e){return new ut(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 b3(){return new Ii([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function E3(){return new Ii([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function w3(i){i=Ut(i);const e=Q0(i,Qt.From2000),t=ef(i,Qt.From2000);return M3(e,t)}function A3(i){const t=Ur(Ut(i)).tobl*tt,n=Math.cos(t),s=Math.sin(t);return new Ii([[1,0,0],[0,+n,+s],[0,-s,+n]])}var cd;(function(i){i.Penumbral="penumbral",i.Partial="partial",i.Annular="annular",i.Total="total"})(cd||(cd={}));var hd;(function(i){i[i.Invalid=0]="Invalid",i[i.Ascending=1]="Ascending",i[i.Descending=-1]="Descending"})(hd||(hd={}));const T3=["Venus","Mars","Jupiter","Saturn"];function ff(i){return new yh(i.lat,i.lng,i.elevationM)}function Cr(i,e,t,n){const s=nf(t,ff(n),i,e,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function ll(i,e,t){const n=ff(t),s=e3(Se[i],e,n,!0,!0),r=nf(e,n,s.ra,s.dec,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function cl(i,e){return hf(Se[i],e).mag}function R3(i){const e=x3(i),t=hf(Se.Moon,i);return{phaseFraction:e/360,illuminatedFraction:t.phase_fraction}}const C3=2e3,D3=3,P3=20;function Gc(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??C3,r=i.month??(n?1:D3),a=i.day??(n?1:P3),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 Yi{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=Yi.patch(t.fragmentShader)}}static patch(e){return e.replace(Yi.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
4818
+ */const xh=173.1446326846693,$i=14959787069098932e-8,nt=.017453292519943295,od=.26179938779914946,Zn=57.29577951308232,Q0=3.819718634205488,F_=365.24217,ld=new Date("2000-01-01T12:00:00Z"),ni=2*Math.PI,Si=3600*(180/Math.PI),Os=484813681109536e-20,j0=10800*60,O_=2*j0,cd=7292115e-11,z_=j0/Math.PI,B_=-.17-5*Math.log10(z_),Tc=.996647180302104,k_=Tc*Tc,Rc=6378.1366,H_=Rc/$i,ef=81.30056,_h=.0002959122082855911,Cc=2825345909524226e-22,Dc=8459715185680659e-23,Pc=1292024916781969e-23,Ic=1524358900784276e-23;function no(i){if(i!==!0&&i!==!1)throw console.trace(),`Value is not boolean: ${i}`;return i}function kt(i){if(!Number.isFinite(i))throw console.trace(),`Value is not a finite number: ${i}`;return i}function Ps(i){return i-Math.floor(i)}function G_(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:Zn*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 V_=[Se.Star1,Se.Star2,Se.Star3,Se.Star4,Se.Star5,Se.Star6,Se.Star7,Se.Star8],W_=[{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 X_(i){const e=V_.indexOf(i);return e>=0?W_[e]:null}function Mh(i){const e=X_(i);return e&&e.dist>0?e:null}var jt;(function(i){i[i.From2000=0]="From2000",i[i.Into2000=1]="Into2000"})(jt||(jt={}));const Yn={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 q_(i){var e,t,n,s,r,a,o;const l=2e3+(i-14)/F_;return l<-500?(e=(l-1820)/100,-20+32*e*e):l<500?(e=l/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):l<1600?(e=(l-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):l<1700?(e=l-1600,t=e*e,n=e*t,120-.9808*e-.01532*t+n/7129):l<1800?(e=l-1700,t=e*e,n=e*t,s=t*t,8.83+.1603*e-.0059285*t+13336e-8*n-s/1174e3):l<1860?(e=l-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):l<1900?(e=l-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):l<1920?(e=l-1900,t=e*e,n=e*t,s=t*t,-2.79+1.494119*e-.0598939*t+.0061966*n-197e-6*s):l<1941?(e=l-1920,t=e*e,n=e*t,21.2+.84493*e-.0761*t+.0020936*n):l<1961?(e=l-1950,t=e*e,n=e*t,29.07+.407*e-t/233+n/2547):l<1986?(e=l-1975,t=e*e,n=e*t,45.45+1.067*e-t/260-n/718):l<2005?(e=l-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):l<2050?(e=l-2e3,62.92+.32217*e+.005589*e*e):l<2150?(e=(l-1820)/100,-20+32*e*e-.5628*(2150-l)):(e=(l-1820)/100,-20+32*e*e)}let Y_=q_;function hd(i){return i+Y_(i)/86400}class Xs{constructor(e){if(e instanceof Xs){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()-ld.getTime())/t,this.tt=hd(this.ut);return}if(Number.isFinite(e)){this.date=new Date(ld.getTime()+e*t),this.ut=e,this.tt=hd(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 Xs(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 Xs(this.ut+e)}}function Ut(i){return i instanceof Xs?i:new Xs(i)}function K_(i){function e(d){return d%O_*Os}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),l=Math.cos(a),c=(-172064161-174666*t)*o+33386*l,h=(92052331+9086*t)*l+15377*o,u=2*(s-r+a);return o=Math.sin(u),l=Math.cos(u),c+=(-13170906-1675*t)*o-13696*l,h+=(5730336-3015*t)*l-4587*o,u=2*(s+a),o=Math.sin(u),l=Math.cos(u),c+=(-2276413-234*t)*o+2796*l,h+=(978459-485*t)*l+1374*o,u=2*a,o=Math.sin(u),l=Math.cos(u),c+=(2074554+207*t)*o-698*l,h+=(-897492+470*t)*l-291*o,o=Math.sin(n),l=Math.cos(n),c+=(1475877-3633*t)*o+11817*l,h+=(73871-184*t)*l-1924*o,{dpsi:-135e-6+c*1e-7,deps:388e-6+h*1e-7}}function tf(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 Sa;function zr(i){if(!Sa||Math.abs(Sa.tt-i.tt)>1e-6){const e=K_(i),t=tf(i),n=t+e.deps/3600;Sa={tt:i.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*nt)/15,mobl:t,tobl:n}}return Sa}function $_(i,e){const t=i*nt,n=Math.cos(t),s=Math.sin(t);return[e[0],e[1]*n-e[2]*s,e[1]*s+e[2]*n]}function Z_(i,e){return $_(tf(i),e)}function J_(i){const e=i.tt/36525;function t(Ae,xe){const Ie=[];let Ne;for(Ne=0;Ne<=xe-Ae;++Ne)Ie.push(0);return{min:Ae,array:Ie}}function n(Ae,xe,Ie,Ne){const Ue=[];for(let Qe=0;Qe<=xe-Ae;++Qe)Ue.push(t(Ie,Ne));return{min:Ae,array:Ue}}function s(Ae,xe,Ie){const Ne=Ae.array[xe-Ae.min];return Ne.array[Ie-Ne.min]}function r(Ae,xe,Ie,Ne){const Ue=Ae.array[xe-Ae.min];Ue.array[Ie-Ue.min]=Ne}let a,o,l,c,h,u,d,f,g,_,m,p,E,A,M,S,w,R,x,b,D,C,I,W=n(-6,6,1,4),X=n(-6,6,1,4);function F(Ae,xe){return s(W,Ae,xe)}function q(Ae,xe){return s(X,Ae,xe)}function G(Ae,xe,Ie){return r(W,Ae,xe,Ie)}function Z(Ae,xe,Ie){return r(X,Ae,xe,Ie)}function te(Ae,xe,Ie,Ne,Ue){Ue(Ae*Ie-xe*Ne,xe*Ie+Ae*Ne)}function j(Ae){return Math.sin(ni*Ae)}d=e*e,g=0,I=0,m=0,p=3422.7;var ie=j(.19833+.05611*e),ue=j(.27869+.04508*e),ke=j(.16827-.36903*e),qe=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*ke+7.26*qe+.28*Be+.24*Y,x=2.94*ie+.31*ue+14.27*ke+9.34*qe+1.12*Be+.83*Y,b=-6.4*ie-1.89*Y,D=.21*ie+.31*ue+14.27*ke-88.7*qe-15.3*Be+.24*Y-1.86*re,C=R-b,f=-3332e-9*j(.59734-5.37261*e)-539e-9*j(.35498-5.37899*e)-64e-9*j(.39943-5.37511*e),E=ni*Ps(.60643382+1336.85522467*e-313e-8*d)+R/Si,A=ni*Ps(.37489701+1325.55240982*e+2565e-8*d)+x/Si,M=ni*Ps(.99312619+99.99735956*e-44e-8*d)+b/Si,S=ni*Ps(.25909118+1342.2278298*e-892e-8*d)+D/Si,w=ni*Ps(.82736186+1236.85308708*e-397e-8*d)+C/Si,h=1;h<=4;++h){switch(h){case 1:l=A,o=4,c=1.000002208;break;case 2:l=M,o=3,c=.997504612-.002495388*e;break;case 3:l=S,o=4,c=1.000002708+139.978*f;break;case 4:l=w,o=6,c=1;break;default:throw`Internal error: I = ${h}`}for(G(0,h,1),G(1,h,Math.cos(l)*c),Z(0,h,0),Z(1,h,Math.sin(l)*c),u=2;u<=o;++u)te(F(u-1,h),q(u-1,h),F(1,h),q(1,h),(Ae,xe)=>(G(u,h,Ae),Z(u,h,xe)));for(u=1;u<=o;++u)G(-u,h,F(u,h)),Z(-u,h,-q(u,h))}function ne(Ae,xe,Ie,Ne){for(var Ue={x:1,y:0},Qe=[0,Ae,xe,Ie,Ne],je=1;je<=4;++je)Qe[je]!==0&&te(Ue.x,Ue.y,F(Qe[je],je),q(Qe[je],je),(mt,dt)=>(Ue.x=mt,Ue.y=dt));return Ue}function z(Ae,xe,Ie,Ne,Ue,Qe,je,mt){var dt=ne(Ue,Qe,je,mt);g+=Ae*dt.y,I+=xe*dt.y,m+=Ie*dt.x,p+=Ne*dt.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 Ee(Ae,xe,Ie,Ne,Ue){return Ae*ne(xe,Ie,Ne,Ue).y}_=0,_+=Ee(-526.069,0,0,1,-2),_+=Ee(-3.352,0,0,1,-4),_+=Ee(44.297,1,0,1,-2),_+=Ee(-6,1,0,1,-4),_+=Ee(20.599,-1,0,1,0),_+=Ee(-30.598,-1,0,1,-2),_+=Ee(-24.649,-2,0,1,0),_+=Ee(-2,-2,0,1,-2),_+=Ee(-22.571,0,1,1,-2),_+=Ee(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/Si;let De=(1.000002708+139.978*f)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+_;return{geo_eclip_lon:ni*Ps((E+g/Si)/ni),geo_eclip_lat:Math.PI/(180*3600)*De,distance_au:Si*H_/(.999953253*p)}}function nf(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 io(i,e,t){const n=sf(e,t);return nf(n,i)}function sf(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*=Os,s*=Os,r*=Os,a*=Os;const o=Math.sin(n),l=Math.cos(n),c=Math.sin(-s),h=Math.cos(-s),u=Math.sin(-r),d=Math.cos(-r),f=Math.sin(a),g=Math.cos(a),_=g*h-c*f*d,m=g*c*l+f*d*h*l-o*f*u,p=g*c*o+f*d*h*o+l*f*u,E=-f*h-c*g*d,A=-f*c*l+g*d*h*l-o*g*u,M=-f*c*o+g*d*h*o+l*g*u,S=c*u,w=-u*h*l-o*d,R=-u*h*o+d*l;if(e===jt.Into2000)return new Li([[_,m,p],[E,A,M],[S,w,R]]);if(e===jt.From2000)return new Li([[_,E,S],[m,A,w],[p,M,R]]);throw"Invalid precess direction"}function Q_(i){const e=.779057273264+.00273781191135448*i.ut,t=i.ut%1;let n=360*((e+t)%1);return n<0&&(n+=360),n}let ba;function yh(i){if(!ba||ba.tt!==i.tt){const e=i.tt/36525;let t=15*zr(i).ee;const n=Q_(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),ba={tt:i.tt,st:r}}return ba.st}function rf(i,e){const t=i.latitude*nt,n=Math.sin(t),s=Math.cos(t),r=1/Math.hypot(s,Tc*n),a=k_*r,o=i.height/1e3,l=Rc*r+o,c=Rc*a+o,h=(15*e+i.longitude)*nt,u=Math.sin(h),d=Math.cos(h);return{pos:[l*s*d/$i,l*s*u/$i,c*n/$i],vel:[-cd*l*s*u*86400/$i,cd*l*s*d*86400/$i,0]}}function Lc(i,e,t){const n=af(e,t);return nf(n,i)}function af(i,e){const t=zr(i),n=t.mobl*nt,s=t.tobl*nt,r=t.dpsi*Os,a=Math.cos(n),o=Math.sin(n),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),u=Math.sin(r),d=h,f=-u*a,g=-u*o,_=u*l,m=h*a*l+o*c,p=h*o*l-a*c,E=u*c,A=h*a*c-o*l,M=h*o*c+a*l;if(e===jt.From2000)return new Li([[d,_,E],[f,m,A],[g,p,M]]);if(e===jt.Into2000)return new Li([[d,f,g],[_,m,p],[E,A,M]]);throw"Invalid precess direction"}function Sh(i,e,t){return t===jt.Into2000?io(Lc(i,e,t),e,t):Lc(io(i,e,t),e,t)}function j_(i,e){const t=yh(i),n=rf(e,t).pos;return Sh(n,i,jt.Into2000)}class ut{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 Ri{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 bh{constructor(e,t,n){this.lat=kt(e),this.lon=kt(t),this.dist=kt(n)}}class Nc{constructor(e,t,n,s){this.ra=kt(e),this.dec=kt(t),this.dist=kt(n),this.vec=s}}class Li{constructor(e){this.rot=e}}class e3{constructor(e,t,n,s){this.azimuth=kt(e),this.altitude=kt(t),this.ra=kt(n),this.dec=kt(s)}}class t3{constructor(e,t,n){this.vec=e,this.elat=kt(t),this.elon=kt(n)}}function of(i,e){return new ut(i[0],i[1],i[2],e)}function n3(i,e){const t=of(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 Nc(0,t.z<0?-90:90,s,t)}let r=Q0*Math.atan2(t.y,t.x);r<0&&(r+=24);const a=Zn*Math.atan2(i[2],Math.sqrt(n));return new Nc(r,a,s,t)}function cl(i,e){const t=i*nt,n=Math.cos(t),s=Math.sin(t);return[n*e[0]+s*e[1],n*e[1]-s*e[0],e[2]]}function lf(i,e,t,n,s){let r=Ut(i);Eh(e),kt(t),kt(n);const a=Math.sin(e.latitude*nt),o=Math.cos(e.latitude*nt),l=Math.sin(e.longitude*nt),c=Math.cos(e.longitude*nt),h=Math.sin(n*nt),u=Math.cos(n*nt),d=Math.sin(t*od),f=Math.cos(t*od);let g=[o*c,o*l,a],_=[-a*c,-a*l,o],m=[l,-c,0];const p=-15*yh(r);let E=cl(p,g),A=cl(p,_),M=cl(p,m),S=[u*f,u*d,h];const w=S[0]*E[0]+S[1]*E[1]+S[2]*E[2],R=S[0]*A[0]+S[1]*A[1]+S[2]*A[2],x=S[0]*M[0]+S[1]*M[1]+S[2]*M[2];let b=Math.hypot(R,x),D;b>0?(D=-Zn*Math.atan2(x,R),D<0&&(D+=360)):D=0;let C=Zn*Math.atan2(b,w),I=t,W=n;{let X=C,F=A3(s,90-C);if(C-=F,F>0&&C>3e-4){const q=Math.sin(C*nt),G=Math.cos(C*nt),Z=Math.sin(X*nt),te=Math.cos(X*nt),j=[];for(let ie=0;ie<3;++ie)j.push((S[ie]-te*E[ie])/Z*q+E[ie]*G);b=Math.hypot(j[0],j[1]),b>0?(I=Q0*Math.atan2(j[1],j[0]),I<0&&(I+=24)):I=0,W=Zn*Math.atan2(j[2],b)}}return new e3(D,90-C,I,W)}function Eh(i){if(!(i instanceof wh))throw`Not an instance of the Observer class: ${i}`;if(kt(i.latitude),kt(i.longitude),kt(i.height),i.latitude<-90||i.latitude>90)throw`Latitude ${i.latitude} is out of range. Must be -90..+90.`;return i}class wh{constructor(e,t,n){this.latitude=e,this.longitude=t,this.height=n,Eh(this)}}function i3(i){const e=Ut(i).AddDays(-1/xh),t=Ys(Yn.Earth,e),n=[-t.x,-t.y,-t.z],[s,r,a]=Sh(n,e,jt.From2000),o=nt*zr(e).tobl,l=Math.cos(o),c=Math.sin(o),h=new ut(s,r,a,e);return cf(h,l,c)}function s3(i,e,t,n,s){Eh(t),no(n),no(s);const r=Ut(e),a=j_(r,t),o=Wc(i,r,s),l=[o.x-a[0],o.y-a[1],o.z-a[2]],c=Sh(l,r,jt.From2000);return n3(c,r)}function r3(i,e,t){const n=Ut(i),s=yh(n);let r=rf(e,s).pos;return of(r,n)}function cf(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=Zn*Math.atan2(s,n),o<0&&(o+=360));let l=Zn*Math.atan2(r,a),c=new ut(n,s,r,i.t);return new t3(c,l,o)}function Uc(i){const e=zr(i.t),t=[i.x,i.y,i.z],n=io(t,i.t,jt.From2000),[s,r,a]=Lc(n,i.t,jt.From2000),o=new ut(s,r,a,i.t),l=e.tobl*nt;return cf(o,Math.cos(l),Math.sin(l))}function Qs(i){const e=Ut(i),t=J_(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=Z_(e,s),a=io(r,e,jt.Into2000);return new ut(a[0],a[1],a[2],e)}function hf(i){const e=Ut(i),t=1e-5,n=e.AddDays(-t),s=e.AddDays(+t),r=Qs(n),a=Qs(s);return new Ri((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 a3(i){const e=Ut(i),t=hf(e),n=1+ef;return new Ri(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[l,c,h]of r)a+=l*Math.cos(c+e*h);let o=n*a;t&&(o%=ni),s+=o,n*=e}return s}function hl(i,e){let t=1,n=0,s=0,r=0;for(let a of i){let o=0,l=0;for(let[c,h,u]of a){let d=h+e*u;o+=c*u*Math.sin(d),r>0&&(l+=c*Math.cos(d))}s+=r*n*l-t*o,n=t,t*=e,++r}return s}const _r=365250,Fc=0,Oc=1,zc=2;function Bc(i){return new Xt(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 uf(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 Ys(i,e){const t=e.tt/_r,n=qs(i[Fc],t,!0),s=qs(i[Oc],t,!1),r=qs(i[zc],t,!1),a=uf(n,s,r);return Bc(a).ToAstroVector(e)}function kc(i,e){const t=e/_r,n=qs(i[Fc],t,!0),s=qs(i[Oc],t,!1),r=qs(i[zc],t,!1),a=hl(i[Fc],t),o=hl(i[Oc],t),l=hl(i[zc],t),c=Math.cos(n),h=Math.sin(n),u=Math.cos(s),d=Math.sin(s),f=+(l*u*c)-r*d*c*o-r*u*h*a,g=+(l*u*h)-r*d*h*o+r*u*c*a,_=+(l*d)+r*u*o,m=uf(n,s,r),p=[f/_r,g/_r,_/_r],E=Bc(m),A=Bc(p);return new rs(e,E,A)}function Ea(i,e,t,n){const s=n/(n+_h),r=Ys(Yn[t],e);i.x+=s*r.x,i.y+=s*r.y,i.z+=s*r.z}function o3(i){const e=new ut(0,0,0,i);return Ea(e,i,Se.Jupiter,Cc),Ea(e,i,Se.Saturn,Dc),Ea(e,i,Se.Uranus,Pc),Ea(e,i,Se.Neptune,Ic),e}const Hc=51,l3=29200,zs=146,ii=201,ji=[[-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 Xt{constructor(e,t,n){this.x=e,this.y=t,this.z=n}clone(){return new Xt(this.x,this.y,this.z)}ToAstroVector(e){return new ut(this.x,this.y,this.z,e)}static zero(){return new Xt(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new Xt(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new Xt(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 Xt(e*this.x,e*this.y,e*this.z)}div(e){return new Xt(this.x/e,this.y/e,this.z/e)}mean(e){return new Xt((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new Xt(-this.x,-this.y,-this.z)}}class rs{constructor(e,t,n){this.tt=e,this.r=t,this.v=n}clone(){return new rs(this.tt,this.r,this.v)}sub(e){return new rs(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function c3(i){let[e,[t,n,s],[r,a,o]]=i;return new rs(e,new Xt(t,n,s),new Xt(r,a,o))}function wa(i,e,t,n){const s=n/(n+_h),r=kc(Yn[t],e);return i.r.incr(r.r.mul(s)),i.v.incr(r.v.mul(s)),r}function dr(i,e,t){const n=t.sub(i),s=n.quadrature();return n.mul(e/(s*Math.sqrt(s)))}class _o{constructor(e){let t=new rs(e,new Xt(0,0,0),new Xt(0,0,0));this.Jupiter=wa(t,e,Se.Jupiter,Cc),this.Saturn=wa(t,e,Se.Saturn,Dc),this.Uranus=wa(t,e,Se.Uranus,Pc),this.Neptune=wa(t,e,Se.Neptune,Ic),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 rs(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=dr(e,_h,this.Sun.r);return t.incr(dr(e,Cc,this.Jupiter.r)),t.incr(dr(e,Dc,this.Saturn.r)),t.incr(dr(e,Pc,this.Uranus.r)),t.incr(dr(e,Ic,this.Neptune.r)),t}}class Mo{constructor(e,t,n,s){this.tt=e,this.r=t,this.v=n,this.a=s}clone(){return new Mo(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class df{constructor(e,t){this.bary=e,this.grav=t}}function so(i,e,t,n){return new Xt(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 ud(i,e,t){return new Xt(e.x+i*t.x,e.y+i*t.y,e.z+i*t.z)}function Gc(i,e){const t=i-e.tt,n=new _o(i),s=so(t,e.r,e.v,e.a),r=n.Acceleration(s).mean(e.a),a=so(t,e.r,e.v,r),o=e.v.add(r.mul(t)),l=n.Acceleration(a),c=new Mo(i,a,o,l);return new df(n,c)}const h3=[];function ff(i,e){const t=Math.floor(i);return t<0?0:t>=e?e-1:t}function Vc(i){const e=c3(i),t=new _o(e.tt),n=e.r.add(t.Sun.r),s=e.v.add(t.Sun.v),r=t.Acceleration(n),a=new Mo(e.tt,n,s,r);return new df(t,a)}function u3(i,e){const t=ji[0][0];if(e<t||e>ji[Hc-1][0])return null;const n=ff((e-t)/l3,Hc-1);if(!i[n]){const r=i[n]=[];r[0]=Vc(ji[n]).grav,r[ii-1]=Vc(ji[n+1]).grav;let a,o=r[0].tt;for(a=1;a<ii-1;++a)r[a]=Gc(o+=zs,r[a-1]).grav;o=r[ii-1].tt;var s=[];for(s[ii-1]=r[ii-1],a=ii-2;a>0;--a)s[a]=Gc(o-=zs,s[a+1]).grav;for(a=ii-2;a>0;--a){const l=a/(ii-1);r[a].r=r[a].r.mul(1-l).add(s[a].r.mul(l)),r[a].v=r[a].v.mul(1-l).add(s[a].v.mul(l)),r[a].a=r[a].a.mul(1-l).add(s[a].a.mul(l))}}return i[n]}function dd(i,e,t){let n=Vc(i);const s=Math.ceil((e-n.grav.tt)/t);for(let r=0;r<s;++r)n=Gc(r+1===s?e:n.grav.tt+t,n.grav);return n}function pf(i,e){let t,n,s;const r=u3(h3,i.tt);if(r){const a=ff((i.tt-r[0].tt)/zs,ii-1),o=r[a],l=r[a+1],c=o.a.mean(l.a),h=so(i.tt-o.tt,o.r,o.v,c),u=ud(i.tt-o.tt,o.v,c),d=so(i.tt-l.tt,l.r,l.v,c),f=ud(i.tt-l.tt,l.v,c),g=(i.tt-o.tt)/zs;t=h.mul(1-g).add(d.mul(g)),n=u.mul(1-g).add(f.mul(g))}else{let a;i.tt<ji[0][0]?a=dd(ji[0],i.tt,-zs):a=dd(ji[Hc-1],i.tt,+zs),t=a.grav.r,n=a.grav.v,s=a.bary}return s||(s=new _o(i.tt)),t=t.sub(s.Sun.r),n=n.sub(s.Sun.v),new Ri(t.x,t.y,t.z,n.x,n.y,n.z,i)}function Di(i,e){var t=Ut(e);if(i in Yn)return Ys(Yn[i],t);if(i===Se.Pluto){const a=pf(t);return new ut(a.x,a.y,a.z,t)}if(i===Se.Sun)return new ut(0,0,0,t);if(i===Se.Moon){var n=Ys(Yn.Earth,t),s=Qs(t);return new ut(n.x+s.x,n.y+s.y,n.z+s.z,t)}if(i===Se.EMB){const a=Ys(Yn.Earth,t),o=Qs(t),l=1+ef;return new ut(a.x+o.x/l,a.y+o.y/l,a.z+o.z/l,t)}if(i===Se.SSB)return o3(t);const r=Mh(i);if(r){const a=new bh(r.dec,15*r.ra,r.dist);return gf(a,t)}throw`HelioVector: Unknown body "${i}"`}function d3(i,e){let t=e,n=0;for(let s=0;s<10;++s){const r=i(t),a=r.Length()/xh;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 f3{constructor(e,t,n,s){this.observerBody=e,this.targetBody=t,this.aberration=n,this.observerPos=s}Position(e){this.aberration&&(this.observerPos=Di(this.observerBody,e));const t=Di(this.targetBody,e);return new ut(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function p3(i,e,t,n){no(n);const s=Ut(i);if(Mh(t)){const o=Di(t,s);if(n){const c=g3(e,s),h=new ut(o.x-c.x,o.y-c.y,o.z-c.z,s),u=xh/h.Length();return new ut(h.x+c.vx/u,h.y+c.vy/u,h.z+c.vz/u,s)}const l=Di(e,s);return new ut(o.x-l.x,o.y-l.y,o.z-l.z,s)}let r;n?r=new ut(0,0,0,s):r=Di(e,s);const a=new f3(e,t,n,r);return d3(o=>a.Position(o),s)}function Wc(i,e,t){no(t);const n=Ut(e);switch(i){case Se.Earth:return new ut(0,0,0,n);case Se.Moon:return Qs(n);default:const s=p3(n,Se.Earth,i,t);return s.t=n,s}}function m3(i,e){return new Ri(i.r.x,i.r.y,i.r.z,i.v.x,i.v.y,i.v.z,e)}function g3(i,e){const t=Ut(e);switch(i){case Se.Sun:return new Ri(0,0,0,0,0,0,t);case Se.SSB:const n=new _o(t.tt);return new Ri(-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=kc(Yn[i],t.tt);return m3(s,t);case Se.Pluto:return pf(t);case Se.Moon:case Se.EMB:const r=kc(Yn.Earth,t.tt),a=i==Se.Moon?hf(t):a3(t);return new Ri(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(Mh(i)){const o=Di(i,t);return new Ri(o.x,o.y,o.z,0,0,0,t)}throw`HelioState: Unsupported body "${i}"`}}function v3(i){for(;i<0;)i+=360;for(;i>=360;)i-=360;return i}function x3(i,e,t){if(i===Se.Earth||e===Se.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=Ut(t),s=Wc(i,n,!1),r=Uc(s),a=Wc(e,n,!1),o=Uc(a);return v3(r.elon-o.elon)}function _3(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 l=e/100;let c=s+l*(r+l*(a+l*o));return c+=5*Math.log10(t*n),c}function M3(i,e,t,n,s){const r=Uc(n),a=nt*28.06,o=nt*(169.51+382e-7*s.tt),l=nt*r.elat,c=nt*r.elon,h=Math.asin(Math.sin(l)*Math.cos(a)-Math.cos(l)*Math.sin(a)*Math.sin(c-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:Zn*h}}function y3(i,e,t){let n=i*nt,s=n*n,r=s*s,a=-12.717+1.49*Math.abs(n)+.0431*r;const o=385000.6/$i;let l=t/o;return a+=5*Math.log10(e*l),a}class S3{constructor(e,t,n,s,r,a,o,l){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=l,this.phase_fraction=(1+Math.cos(nt*n))/2}}function mf(i,e){if(i===Se.Earth)throw"The illumination of the Earth is not defined.";const t=Ut(e),n=Ys(Yn.Earth,t);let s,r,a,o;i===Se.Sun?(a=new ut(-n.x,-n.y,-n.z,t),r=new ut(0,0,0,t),s=0):(i===Se.Moon?(a=Qs(t),r=new ut(n.x+a.x,n.y+a.y,n.z+a.z,t)):(r=Di(i,e),a=new ut(r.x-n.x,r.y-n.y,r.z-n.z,t)),s=G_(a,r));let l=a.Length(),c=r.Length(),h;if(i===Se.Sun)o=B_+5*Math.log10(l);else if(i===Se.Moon)o=y3(s,c,l);else if(i===Se.Saturn){const u=M3(s,c,l,a,t);o=u.mag,h=u.ring_tilt}else o=_3(i,s,c,l);return new S3(t,o,s,c,l,a,r,h)}function b3(i){return x3(Se.Moon,Se.Sun,i)}var fd;(function(i){i[i.Pericenter=0]="Pericenter",i[i.Apocenter=1]="Apocenter"})(fd||(fd={}));function E3(i,e){return new Li([[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 gf(i,e){e=Ut(e);const t=i.lat*nt,n=i.lon*nt,s=i.dist*Math.cos(t);return new ut(s*Math.cos(n),s*Math.sin(n),i.dist*Math.sin(t),e)}function vf(i){const e=w3(i);return new Nc(e.lon/15,e.lat,e.dist,i)}function w3(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=Zn*Math.atan2(i.y,i.x),s<0&&(s+=360),n=Zn*Math.atan2(i.z,Math.sqrt(e));return new bh(n,s,t)}function A3(i,e){let t;if(kt(e),e<-90||e>90)return 0;{let n=e;n<-1&&(n=-1),t=1.02/Math.tan((n+10.3/(n+5.11))*nt)/60,e<-1&&(t*=(e+90)/89)}return t}function qa(i,e){return new ut(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 T3(){return new Li([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function R3(){return new Li([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function C3(i){i=Ut(i);const e=sf(i,jt.From2000),t=af(i,jt.From2000);return E3(e,t)}function D3(i){const t=zr(Ut(i)).tobl*nt,n=Math.cos(t),s=Math.sin(t);return new Li([[1,0,0],[0,+n,+s],[0,-s,+n]])}var pd;(function(i){i.Penumbral="penumbral",i.Partial="partial",i.Annular="annular",i.Total="total"})(pd||(pd={}));var md;(function(i){i[i.Invalid=0]="Invalid",i[i.Ascending=1]="Ascending",i[i.Descending=-1]="Descending"})(md||(md={}));const P3=["Venus","Mars","Jupiter","Saturn"];function xf(i){return new wh(i.lat,i.lng,i.elevationM)}function Lr(i,e,t,n){const s=lf(t,xf(n),i,e,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function ul(i,e,t){const n=xf(t),s=s3(Se[i],e,n,!0,!0),r=lf(e,n,s.ra,s.dec,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function dl(i,e){return mf(Se[i],e).mag}function I3(i){const e=b3(i),t=mf(Se.Moon,i);return{phaseFraction:e/360,illuminatedFraction:t.phase_fraction}}const L3=2e3,N3=3,U3=20;function Xc(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??L3,r=i.month??(n?1:N3),a=i.day??(n?1:U3),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 Zi{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=Zi.patch(t.fragmentShader)}}static patch(e){return e.replace(Zi.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
4789
4819
  // Outside the inscribed circle there is no star at all — this is what kills the corners.
4790
- if ( distanceFromCentre > ${Yi.RIM.toFixed(2)} ) discard;
4791
- float glare = 1.0 - smoothstep( ${Yi.CORE.toFixed(2)}, ${Yi.RIM.toFixed(2)}, distanceFromCentre );
4792
- vec4 diffuseColor = vec4( diffuse, opacity * glare );`)}}const I3=[{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}],pf=Math.PI/180,L3=180/Math.PI,N3=256,U3=19;function F3(i,e){return 156543.03392*Math.cos(i*pf)/2**e}function O3(i,e){return F3(i,e)*N3}function mf(i,e){let t=0;for(;t<U3&&O3(i,t+1)>=e;)t++;return t}function gf(i,e,t){const n=2**t,s=(i+180)/360*n,r=e*pf,a=(1-Math.log(Math.tan(r)+1/Math.cos(r))/Math.PI)/2*n;return{x:s,y:a}}function z3(i,e,t){const{x:n,y:s}=gf(i,e,t);return{x:Math.floor(n),y:Math.floor(s),z:t}}function B3(i){const e=2**i.z,t=i.x/e*360-180,n=(i.x+1)/e*360-180,s=ud(i.y,e);return{south:ud(i.y+1,e),north:s,west:t,east:n}}function ud(i,e){const t=i/e;return Math.atan(Math.sinh(Math.PI*(1-2*t)))*L3}function vf(i,e,t,n){const s=z3(i,e,t),r=Math.floor(n/2),a=[];for(let c=-r;c<=r;c++)for(let h=-r;h<=r;h++)a.push({x:s.x+h,y:s.y+c,z:t});const o=a.map(B3),l={south:Math.min(...o.map(c=>c.south)),north:Math.max(...o.map(c=>c.north)),west:Math.min(...o.map(c=>c.west)),east:Math.max(...o.map(c=>c.east))};return{tiles:a,bounds:l}}const _f=Math.PI/180,io=111320;function is(i,e,t,n){const s=io*Math.cos(t*_f),r=(i-t)*io;return{x:(e-n)*s,z:-r}}function ba(i,e,t,n){const s=io*Math.cos(t*_f),r=-e,a=i;return{lat:t+r/io,lng:n+a/s}}const _n=256,dd=3,k3=32768;class H3{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(is(n,e.east,n,e.west).x),a=Math.abs(is(e.north,s,e.south,s).z),o=mf(n,Math.max(r,a)),{tiles:l}=vf(s,n,o,dd),c=dd*_n,h=new Float32Array(c*c),u=l[0];await Promise.all(l.map(f=>this.decodeTileInto(f,u,h,c)));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,c)}}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()),l=document.createElement("canvas");l.width=_n,l.height=_n;const c=l.getContext("2d");if(!c)throw new Error("2D canvas context unavailable");c.drawImage(o,0,0);const{data:h}=c.getImageData(0,0,_n,_n),u=(e.x-t.x)*_n,d=(e.y-t.y)*_n;for(let f=0;f<_n;f++)for(let g=0;g<_n;g++){const x=(f*_n+g)*4,m=h[x]*256+h[x+1]+h[x+2]/256-k3,p=u+g,E=d+f;n[E*s+p]=m}}sampleAt(e,t,n,s,r,a){const{x:o,y:l}=gf(t,e,n),c=(o-s.x)*_n,h=(l-s.y)*_n,u=Math.max(0,Math.min(a-1,Math.floor(c))),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=c-u,m=h-d,p=r[d*a+u],E=r[d*a+f],A=r[g*a+u],M=r[g*a+f],S=p+(E-p)*x,w=A+(M-A)*x;return S+(w-S)*m}}const hl=256,fd=3;async function G3(i,e,t,n){const s=(i.south+i.north)/2,r=(i.west+i.east)/2,a=Math.abs(is(s,i.east,s,i.west).x),o=Math.abs(is(i.north,r,i.south,r).z),l=mf(s,Math.max(a,o)),{tiles:c}=vf(r,s,l,fd),h=fd*hl,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=c[0];await Promise.all(c.map(async m=>{const p=t(m),E=await n(p);if(!E.ok)throw new Error(`Imagery tile fetch failed (${E.status}): ${p}`);const A=await createImageBitmap(await E.blob());d.drawImage(A,(m.x-f.x)*hl,(m.y-f.y)*hl)}));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 V3{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 G3(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 W3(){return{elevation:new H3,imagery:new V3}}const vr=64,Ot=vr+1,pd=512,X3=900,q3=700/900,Y3=0,K3=.01;function $3(i,e,t){return{north:ba(0,-t,i,e).lat,south:ba(0,t,i,e).lat,east:ba(t,0,i,e).lng,west:ba(-t,0,i,e).lng}}async function Z3(i,e,t,n=X3){const s=n,r=n*q3,a=$3(i,e,s),o={width:Ot,height:Ot},[l,c]=await Promise.all([t.elevation.getElevationGrid(a,o),t.imagery.getImageryTexture(a,{width:pd,height:pd})]),h=Math.floor(Ot/2),u=l.heights[h*Ot+h],d=new Float32Array(Ot*Ot*3),f=new Float32Array(Ot*Ot*2),g=new Float32Array(Ot*Ot*4);for(let S=0;S<Ot;S++){const w=S/(Ot-1),R=a.north+(a.south-a.north)*w;for(let _=0;_<Ot;_++){const b=_/(Ot-1),D=a.west+(a.east-a.west)*b,{x:C,z:I}=is(R,D,i,e),W=l.heights[S*Ot+_],X=Y3+K3+(W-u),F=S*Ot+_;d[F*3]=C,d[F*3+1]=X,d[F*3+2]=I,f[F*2]=b,f[F*2+1]=w;const q=Math.max(Math.abs(C),Math.abs(I)),G=1-J3((q-r)/(s-r),0,1);g[F*4]=1,g[F*4+1]=1,g[F*4+2]=1,g[F*4+3]=G}}const x=new Uint16Array(vr*vr*6);let m=0;for(let S=0;S<vr;S++)for(let w=0;w<vr;w++){const R=S*Ot+w,_=R+1,b=R+Ot,D=b+1;x[m++]=R,x[m++]=b,x[m++]=_,x[m++]=_,x[m++]=b,x[m++]=D}const p=new bt;p.setAttribute("position",new ct(d,3)),p.setAttribute("uv",new ct(f,2)),p.setAttribute("color",new ct(g,4)),p.setIndex(new ct(x,1)),p.computeVertexNormals();const E=new li(c.source);E.flipY=!1;const A=new Ir({map:E,color:new Me(1,1,1),vertexColors:!0,transparent:!0,fog:!0,depthTest:!1}),M=new nt(p,A);return M.receiveShadow=!0,M.castShadow=!0,{mesh:M,attribution:t.imagery.attribution}}function J3(i,e,t){return Math.max(e,Math.min(t,i))}const Q3=18,j3=.55,eM=.5,tM=`
4820
+ if ( distanceFromCentre > ${Zi.RIM.toFixed(2)} ) discard;
4821
+ float glare = 1.0 - smoothstep( ${Zi.CORE.toFixed(2)}, ${Zi.RIM.toFixed(2)}, distanceFromCentre );
4822
+ vec4 diffuseColor = vec4( diffuse, opacity * glare );`)}}const F3=[{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}],_f=Math.PI/180,O3=180/Math.PI,z3=256,B3=19;function k3(i,e){return 156543.03392*Math.cos(i*_f)/2**e}function H3(i,e){return k3(i,e)*z3}function Mf(i,e){let t=0;for(;t<B3&&H3(i,t+1)>=e;)t++;return t}function yf(i,e,t){const n=2**t,s=(i+180)/360*n,r=e*_f,a=(1-Math.log(Math.tan(r)+1/Math.cos(r))/Math.PI)/2*n;return{x:s,y:a}}function G3(i,e,t){const{x:n,y:s}=yf(i,e,t);return{x:Math.floor(n),y:Math.floor(s),z:t}}function V3(i){const e=2**i.z,t=i.x/e*360-180,n=(i.x+1)/e*360-180,s=gd(i.y,e);return{south:gd(i.y+1,e),north:s,west:t,east:n}}function gd(i,e){const t=i/e;return Math.atan(Math.sinh(Math.PI*(1-2*t)))*O3}function Sf(i,e,t,n){const s=G3(i,e,t),r=Math.floor(n/2),a=[];for(let c=-r;c<=r;c++)for(let h=-r;h<=r;h++)a.push({x:s.x+h,y:s.y+c,z:t});const o=a.map(V3),l={south:Math.min(...o.map(c=>c.south)),north:Math.max(...o.map(c=>c.north)),west:Math.min(...o.map(c=>c.west)),east:Math.max(...o.map(c=>c.east))};return{tiles:a,bounds:l}}const bf=Math.PI/180,ro=111320;function as(i,e,t,n){const s=ro*Math.cos(t*bf),r=(i-t)*ro;return{x:(e-n)*s,z:-r}}function Aa(i,e,t,n){const s=ro*Math.cos(t*bf),r=-e,a=i;return{lat:t+r/ro,lng:n+a/s}}const _n=256,vd=3,W3=32768;class X3{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(as(n,e.east,n,e.west).x),a=Math.abs(as(e.north,s,e.south,s).z),o=Mf(n,Math.max(r,a)),{tiles:l}=Sf(s,n,o,vd),c=vd*_n,h=new Float32Array(c*c),u=l[0];await Promise.all(l.map(f=>this.decodeTileInto(f,u,h,c)));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 _=0;_<t.width;_++){const m=e.west+(e.east-e.west)*(_/(t.width-1));d[f*t.width+_]=this.sampleAt(g,m,o,u,h,c)}}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()),l=document.createElement("canvas");l.width=_n,l.height=_n;const c=l.getContext("2d");if(!c)throw new Error("2D canvas context unavailable");c.drawImage(o,0,0);const{data:h}=c.getImageData(0,0,_n,_n),u=(e.x-t.x)*_n,d=(e.y-t.y)*_n;for(let f=0;f<_n;f++)for(let g=0;g<_n;g++){const _=(f*_n+g)*4,m=h[_]*256+h[_+1]+h[_+2]/256-W3,p=u+g,E=d+f;n[E*s+p]=m}}sampleAt(e,t,n,s,r,a){const{x:o,y:l}=yf(t,e,n),c=(o-s.x)*_n,h=(l-s.y)*_n,u=Math.max(0,Math.min(a-1,Math.floor(c))),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),_=c-u,m=h-d,p=r[d*a+u],E=r[d*a+f],A=r[g*a+u],M=r[g*a+f],S=p+(E-p)*_,w=A+(M-A)*_;return S+(w-S)*m}}const fl=256,xd=3;async function q3(i,e,t,n){const s=(i.south+i.north)/2,r=(i.west+i.east)/2,a=Math.abs(as(s,i.east,s,i.west).x),o=Math.abs(as(i.north,r,i.south,r).z),l=Mf(s,Math.max(a,o)),{tiles:c}=Sf(r,s,l,xd),h=xd*fl,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=c[0];await Promise.all(c.map(async m=>{const p=t(m),E=await n(p);if(!E.ok)throw new Error(`Imagery tile fetch failed (${E.status}): ${p}`);const A=await createImageBitmap(await E.blob());d.drawImage(A,(m.x-f.x)*fl,(m.y-f.y)*fl)}));const g=document.createElement("canvas");g.width=e.width,g.height=e.height;const _=g.getContext("2d");if(!_)throw new Error("2D canvas context unavailable");return _.drawImage(u,0,0,h,h,0,0,e.width,e.height),g}class Y3{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 q3(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 K3(){return{elevation:new X3,imagery:new Y3}}const Mr=64,Ot=Mr+1,_d=512,$3=900,Z3=700/900,J3=0,Q3=.01;function j3(i,e,t){return{north:Aa(0,-t,i,e).lat,south:Aa(0,t,i,e).lat,east:Aa(t,0,i,e).lng,west:Aa(-t,0,i,e).lng}}async function eM(i,e,t,n=$3){const s=n,r=n*Z3,a=j3(i,e,s),o={width:Ot,height:Ot},[l,c]=await Promise.all([t.elevation.getElevationGrid(a,o),t.imagery.getImageryTexture(a,{width:_d,height:_d})]),h=Math.floor(Ot/2),u=l.heights[h*Ot+h],d=new Float32Array(Ot*Ot*3),f=new Float32Array(Ot*Ot*2),g=new Float32Array(Ot*Ot*4);for(let S=0;S<Ot;S++){const w=S/(Ot-1),R=a.north+(a.south-a.north)*w;for(let x=0;x<Ot;x++){const b=x/(Ot-1),D=a.west+(a.east-a.west)*b,{x:C,z:I}=as(R,D,i,e),W=l.heights[S*Ot+x],X=J3+Q3+(W-u),F=S*Ot+x;d[F*3]=C,d[F*3+1]=X,d[F*3+2]=I,f[F*2]=b,f[F*2+1]=w;const q=Math.max(Math.abs(C),Math.abs(I)),G=1-tM((q-r)/(s-r),0,1);g[F*4]=1,g[F*4+1]=1,g[F*4+2]=1,g[F*4+3]=G}}const _=new Uint16Array(Mr*Mr*6);let m=0;for(let S=0;S<Mr;S++)for(let w=0;w<Mr;w++){const R=S*Ot+w,x=R+1,b=R+Ot,D=b+1;_[m++]=R,_[m++]=b,_[m++]=x,_[m++]=x,_[m++]=b,_[m++]=D}const p=new bt;p.setAttribute("position",new ct(d,3)),p.setAttribute("uv",new ct(f,2)),p.setAttribute("color",new ct(g,4)),p.setIndex(new ct(_,1)),p.computeVertexNormals();const E=new hi(c.source);E.flipY=!1;const A=new Fr({map:E,color:new Me(1,1,1),vertexColors:!0,transparent:!0,fog:!0,depthTest:!1}),M=new Je(p,A);return M.receiveShadow=!0,M.castShadow=!0,{mesh:M,attribution:t.imagery.attribution}}function tM(i,e,t){return Math.max(e,Math.min(t,i))}const nM=18,iM=.55,sM=.5,rM=`
4793
4823
  attribute float aSpeed;
4794
4824
  uniform float uTime;
4795
4825
  uniform float uOverallSpeed;
@@ -4847,9 +4877,9 @@ void main() {
4847
4877
  vec2 travel = vec2((ahead.x - here.x) * uAspect, ahead.y - here.y);
4848
4878
  // Straight down is the texture's own orientation, so that is the zero.
4849
4879
  vSlant = length(travel) < 1e-6 ? 0.0 : atan(travel.x, -travel.y);
4850
- gl_PointSize = uPixelSize / dist + vNearBlur * ${Q3.toFixed(1)};
4880
+ gl_PointSize = uPixelSize / dist + vNearBlur * ${nM.toFixed(1)};
4851
4881
  }
4852
- `,nM=`
4882
+ `,aM=`
4853
4883
  precision mediump float;
4854
4884
  uniform sampler2D uTexture;
4855
4885
  uniform vec3 uColor;
@@ -4885,18 +4915,18 @@ void main() {
4885
4915
  // defocus doesn't change color, only spreads+dims (see vertex shader's own gl_PointSize term) —
4886
4916
  // both dim the alpha so a maximally blurred/hazy drop doesn't stay as visually "solid" as a sharp
4887
4917
  // one right in the middle distance.
4888
- vec3 color = mix(uColor, uHazeColor, vHaze * ${j3.toFixed(2)});
4918
+ vec3 color = mix(uColor, uHazeColor, vHaze * ${iM.toFixed(2)});
4889
4919
  float blur = max(vNearBlur, vHaze);
4890
- gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${eM.toFixed(2)}));
4920
+ gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${sM.toFixed(2)}));
4891
4921
  }
4892
- `;function iM(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 sM=.14,md=4.5;let Ea;function rM(){if(Ea)return Ea;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*sM,a=i-r;for(let o=0;o<i;o++)for(let l=0;l<i;l++){const c=l+.5-s,h=o+.5<r?o+.5-r:o+.5>a?o+.5-a:0,u=Math.hypot(c,h),d=Math.exp(-(u*u)/(2*md*md)),f=(o*i+l)*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),Ea=new li(e),Ea}function aM(i){const e=iM(i.seed),t=new Float32Array(i.count*3),n=new Float32Array(i.count),s=i.radiusM;for(let c=0;c<i.count;c++){const h=e()*Math.PI*2,u=Math.sqrt(e())*i.radiusM;t[c*3]=Math.cos(h)*u,t[c*3+1]=e()*i.heightM,t[c*3+2]=Math.sin(h)*u,n[c]=.85+e()*.3}const r=new bt;r.setAttribute("position",new ct(t,3)),r.setAttribute("aSpeed",new ct(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 U(0,-1,0)},uAspect:{value:1},uHeight:{value:i.heightM},uBottomY:{value:i.bottomYM},uHalfWidth:{value:s},uTexture:{value:rM()},uNearFocusDistance:{value:i.nearFocusDistanceM},uHazeDistance:{value:i.hazeDistanceM},uHazeColor:{value:i.hazeColor}},o=new It({uniforms:a,vertexShader:tM,fragmentShader:nM,transparent:!0,depthWrite:!1,depthTest:!0}),l=new ka(r,o);return l.frustumCulled=!1,{points:l,uniforms:a}}const oM=`
4922
+ `;function oM(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 lM=.14,Md=4.5;let Ta;function cM(){if(Ta)return Ta;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*lM,a=i-r;for(let o=0;o<i;o++)for(let l=0;l<i;l++){const c=l+.5-s,h=o+.5<r?o+.5-r:o+.5>a?o+.5-a:0,u=Math.hypot(c,h),d=Math.exp(-(u*u)/(2*Md*Md)),f=(o*i+l)*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),Ta=new hi(e),Ta}function hM(i){const e=oM(i.seed),t=new Float32Array(i.count*3),n=new Float32Array(i.count),s=i.radiusM;for(let c=0;c<i.count;c++){const h=e()*Math.PI*2,u=Math.sqrt(e())*i.radiusM;t[c*3]=Math.cos(h)*u,t[c*3+1]=e()*i.heightM,t[c*3+2]=Math.sin(h)*u,n[c]=.85+e()*.3}const r=new bt;r.setAttribute("position",new ct(t,3)),r.setAttribute("aSpeed",new ct(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 U(0,-1,0)},uAspect:{value:1},uHeight:{value:i.heightM},uBottomY:{value:i.bottomYM},uHalfWidth:{value:s},uTexture:{value:cM()},uNearFocusDistance:{value:i.nearFocusDistanceM},uHazeDistance:{value:i.hazeDistanceM},uHazeColor:{value:i.hazeColor}},o=new Et({uniforms:a,vertexShader:rM,fragmentShader:aM,transparent:!0,depthWrite:!1,depthTest:!0}),l=new Va(r,o);return l.frustumCulled=!1,{points:l,uniforms:a}}const uM=`
4893
4923
  varying vec3 vDir;
4894
4924
 
4895
4925
  void main() {
4896
4926
  vDir = normalize(position);
4897
4927
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
4898
4928
  }
4899
- `,xf=`vec3 hash3(vec3 p) {
4929
+ `,Ef=`vec3 hash3(vec3 p) {
4900
4930
  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)));
4901
4931
  return fract(sin(p) * 43758.5453) * 2.0 - 1.0;
4902
4932
  }
@@ -4924,7 +4954,7 @@ float fbm(vec3 p) {
4924
4954
  amp *= 0.55;
4925
4955
  }
4926
4956
  return sum;
4927
- }`,lM=`
4957
+ }`,dM=`
4928
4958
  float cirrusCoverAt(vec3 dir, float layerHeight, float coverage) {
4929
4959
  if (coverage <= 0.0 || dir.y <= 0.02) return 0.0;
4930
4960
  vec3 planePos = dir * (layerHeight / max(dir.y, 0.04));
@@ -4944,7 +4974,7 @@ float cirrusCoverAt(vec3 dir, float layerHeight, float coverage) {
4944
4974
  // is what makes a halo brighter along one arc than another even under total cover.
4945
4975
  return present * (0.30 + 0.70 * smoothstep(0.25, 0.85, shape));
4946
4976
  }
4947
- `,cM=`
4977
+ `,fM=`
4948
4978
  precision highp float;
4949
4979
  uniform vec3 sunDir;
4950
4980
  uniform vec3 sunColor;
@@ -4962,7 +4992,7 @@ varying vec3 vDir;
4962
4992
  uniform float layerHeight;
4963
4993
  uniform float fibrous;
4964
4994
 
4965
- ${xf}
4995
+ ${Ef}
4966
4996
 
4967
4997
  // Cellular (Worley) noise — distance to the nearest of 27 randomly-jittered cell points. Unlike
4968
4998
  // fbm's smooth interpolated blobs, this has genuinely sharp valleys between cells, reading as
@@ -5066,13 +5096,13 @@ void main() {
5066
5096
 
5067
5097
  gl_FragColor = vec4(color, alpha);
5068
5098
  }
5069
- `;function gd(i,e,t,n=0){const s={sunDir:{value:new U(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 It({uniforms:s,vertexShader:oM,fragmentShader:cM,transparent:!0,depthWrite:!1,depthTest:!1,side:Dt}),uniforms:s}}const hM=1.5;function vd(i){const e=Math.PI/2-hM*Math.PI/180;return new Pn(i,48,24,0,Math.PI*2,0,e)}class At{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[At.fract(Math.sin(s)*43758.5453)*2-1,At.fract(Math.sin(r)*43758.5453)*2-1,At.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,l=t-r,c=n-a,h=o*o*(3-2*o),u=l*l*(3-2*l),d=c*c*(3-2*c),f=(x,m,p)=>{const[E,A,M]=At.hash3(s+x,r+m,a+p);return E*(o-x)+A*(l-m)+M*(c-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=At.GAIN;for(let a=0;a<At.OCTAVES;a++)s+=At.noise3D(e,t,n)*r,e*=At.LACUNARITY,t*=At.LACUNARITY,n*=At.LACUNARITY,r*=At.GAIN;return s}static worley(e,t,n){const s=Math.floor(e),r=Math.floor(t),a=Math.floor(n),o=e-s,l=t-r,c=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]=At.hash3(s+u,r+d,a+f),p=u+(g*.5+.5)-o,E=d+(x*.5+.5)-l,A=f+(m*.5+.5)-c;h=Math.min(h,p*p+E*E+A*A)}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,l=e.z*r,c=a*.006,h=o*.006,u=l*.006,d=a+At.fbm(c+12.3,h+12.3,u+12.3)*40,f=o+At.fbm(c+47.1,h+47.1,u+47.1)*40,g=l+At.fbm(c+91.7,h+91.7,u+91.7)*40,x=At.fbm(d*.014,f*.014,g*.014)*.5+.5,m=1-At.worley(d*.011,f*.011,g*.011),p=x+(m-x)*.4,E=1-n,A=(S,w,R)=>{const _=Math.min(1,Math.max(0,(R-S)/(w-S)));return _*_*(3-2*_)},M=A(E-.08,E+.08,p);return M+(1-M)*A(.82,1,n)}}const uM=`
5099
+ `;function yd(i,e,t,n=0){const s={sunDir:{value:new U(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 Et({uniforms:s,vertexShader:uM,fragmentShader:fM,transparent:!0,depthWrite:!1,depthTest:!1,side:Pt}),uniforms:s}}const pM=1.5;function Sd(i){const e=Math.PI/2-pM*Math.PI/180;return new Pn(i,48,24,0,Math.PI*2,0,e)}class Tt{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[Tt.fract(Math.sin(s)*43758.5453)*2-1,Tt.fract(Math.sin(r)*43758.5453)*2-1,Tt.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,l=t-r,c=n-a,h=o*o*(3-2*o),u=l*l*(3-2*l),d=c*c*(3-2*c),f=(_,m,p)=>{const[E,A,M]=Tt.hash3(s+_,r+m,a+p);return E*(o-_)+A*(l-m)+M*(c-p)},g=(_,m,p)=>_+(m-_)*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=Tt.GAIN;for(let a=0;a<Tt.OCTAVES;a++)s+=Tt.noise3D(e,t,n)*r,e*=Tt.LACUNARITY,t*=Tt.LACUNARITY,n*=Tt.LACUNARITY,r*=Tt.GAIN;return s}static worley(e,t,n){const s=Math.floor(e),r=Math.floor(t),a=Math.floor(n),o=e-s,l=t-r,c=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,_,m]=Tt.hash3(s+u,r+d,a+f),p=u+(g*.5+.5)-o,E=d+(_*.5+.5)-l,A=f+(m*.5+.5)-c;h=Math.min(h,p*p+E*E+A*A)}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,l=e.z*r,c=a*.006,h=o*.006,u=l*.006,d=a+Tt.fbm(c+12.3,h+12.3,u+12.3)*40,f=o+Tt.fbm(c+47.1,h+47.1,u+47.1)*40,g=l+Tt.fbm(c+91.7,h+91.7,u+91.7)*40,_=Tt.fbm(d*.014,f*.014,g*.014)*.5+.5,m=1-Tt.worley(d*.011,f*.011,g*.011),p=_+(m-_)*.4,E=1-n,A=(S,w,R)=>{const x=Math.min(1,Math.max(0,(R-S)/(w-S)));return x*x*(3-2*x)},M=A(E-.08,E+.08,p);return M+(1-M)*A(.82,1,n)}}const mM=`
5070
5100
  varying vec2 vUv;
5071
5101
  void main() {
5072
5102
  vUv = uv;
5073
5103
  gl_Position = vec4(position, 1.0);
5074
5104
  }
5075
- `,dM=`
5105
+ `,gM=`
5076
5106
  // Based on https://www.shadertoy.com/view/4sX3Rs
5077
5107
  uniform float uTime;
5078
5108
  uniform vec2 uLensPosition;
@@ -5502,14 +5532,7 @@ void main()
5502
5532
  // stays what it always was for the optional artifacts.
5503
5533
  gl_FragColor = vec4(dazzle + artifactsContribution * uOpacity, 1.0);
5504
5534
  }
5505
- `;let wa;function fM(){if(wa)return wa;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 l=t.createRadialGradient(s*i,r*i,0,s*i,r*i,a*i);l.addColorStop(0,`rgba(200,200,200,${o})`),l.addColorStop(1,"rgba(200,200,200,0)"),t.fillStyle=l,t.fillRect(0,0,i,i)}return wa=new li(e),wa}function pM(){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:fM()}},e=new It({uniforms:i,vertexShader:uM,fragmentShader:dM,transparent:!0,depthWrite:!1,depthTest:!1,blending:Di,fog:!1,name:"LensFlareShader"}),t=new nt(new as(2,2),e);return t.frustumCulled=!1,t.renderOrder=20,{mesh:t,uniforms:i}}const Mf=`
5506
- vec3 encodeSrgb(vec3 linear) {
5507
- vec3 clamped = max(linear, vec3(0.0));
5508
- vec3 low = clamped * 12.92;
5509
- vec3 high = 1.055 * pow(clamped, vec3(1.0 / 2.4)) - 0.055;
5510
- return mix(low, high, step(vec3(0.0031308), clamped));
5511
- }
5512
- `;class so{static MAX_HALF_ANGLE_DEG=80;target;quadScene=new lh;quadCamera=new Lr(-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 Sn(this.width,this.height,{type:mn}),this.material=new It({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)}},vertexShader:`
5535
+ `;let Ra;function vM(){if(Ra)return Ra;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 l=t.createRadialGradient(s*i,r*i,0,s*i,r*i,a*i);l.addColorStop(0,`rgba(200,200,200,${o})`),l.addColorStop(1,"rgba(200,200,200,0)"),t.fillStyle=l,t.fillRect(0,0,i,i)}return Ra=new hi(e),Ra}function xM(){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:vM()}},e=new Et({uniforms:i,vertexShader:mM,fragmentShader:gM,transparent:!0,depthWrite:!1,depthTest:!1,blending:li,fog:!1,name:"LensFlareShader"}),t=new Je(new Ui(2,2),e);return t.frustumCulled=!1,t.renderOrder=20,{mesh:t,uniforms:i}}class ao{static MAX_HALF_ANGLE_DEG=80;target;quadScene=new po;quadCamera=new er(-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 an(this.width,this.height,{type:Qt}),this.material=new Et({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:`
5513
5536
  varying vec2 vNdc;
5514
5537
  void main() {
5515
5538
  vNdc = position.xy;
@@ -5517,11 +5540,12 @@ vec3 encodeSrgb(vec3 linear) {
5517
5540
  }
5518
5541
  `,fragmentShader:`
5519
5542
  precision highp float;
5520
- ${Mf}
5543
+ ${vh}
5521
5544
  uniform sampler2D uSource;
5522
5545
  uniform float uHalfFovRad;
5523
5546
  uniform float uAspect;
5524
5547
  uniform float uSrcTanHalfFovY;
5548
+ uniform float uEncodeOutput;
5525
5549
  varying vec2 vNdc;
5526
5550
 
5527
5551
  void main() {
@@ -5543,10 +5567,12 @@ vec3 encodeSrgb(vec3 linear) {
5543
5567
  vec2 src = vec2(dir.x / -dir.z / (uSrcTanHalfFovY * uAspect), dir.y / -dir.z / uSrcTanHalfFovY);
5544
5568
  if (any(greaterThan(abs(src), vec2(1.0)))) { gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); return; }
5545
5569
  // Encoded here because this pass draws to the CANVAS, which three.js would have encoded
5546
- // for itself had the scene gone there directly — see colorSpace.ts.
5547
- gl_FragColor = vec4(encodeSrgb(texture2D(uSource, src * 0.5 + 0.5).rgb), 1.0);
5570
+ // for itself had the scene gone there directly — see colorSpace.ts. Not encoded when the
5571
+ // frame is on its way into a longer exposure's accumulation, which has to add up light.
5572
+ vec3 colour = texture2D(uSource, src * 0.5 + 0.5).rgb;
5573
+ gl_FragColor = vec4(uEncodeOutput > 0.5 ? encodeSrgb(colour) : colour, 1.0);
5548
5574
  }
5549
- `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new nt(new as(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,l=Math.hypot(a,o);if(l<1e-6)return{x:0,y:0,z:-1};const c=Math.sin(l);return{x:a/l*c,y:o/l*c,z:-Math.cos(l)}}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}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 l=e.getRenderTarget();e.setRenderTarget(this.target),e.render(t,n),e.setRenderTarget(l),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=so.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 yr{static MAX_RADIUS_PX=24;static TAPS=32;target;quadScene=new lh;quadCamera=new Lr(-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 ts(this.width,this.height,Dn);n.minFilter=Ct,n.magFilter=Ct,this.target=new Sn(this.width,this.height,{type:mn,depthTexture:n}),this.material=new It({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:yr.MAX_RADIUS_PX}},vertexShader:`
5575
+ `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new Je(new Ui(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,l=Math.hypot(a,o);if(l<1e-6)return{x:0,y:0,z:-1};const c=Math.sin(l);return{x:a/l*c,y:o/l*c,z:-Math.cos(l)}}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 l=e.getRenderTarget();e.setRenderTarget(this.target),e.render(t,n),e.setRenderTarget(l),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=ao.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 Er{static MAX_RADIUS_PX=24;static TAPS=32;target;quadScene=new po;quadCamera=new er(-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 ss(this.width,this.height,Dn);n.minFilter=Dt,n.magFilter=Dt,this.target=new an(this.width,this.height,{type:Qt,depthTexture:n}),this.material=new Et({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:Er.MAX_RADIUS_PX},uEncodeOutput:{value:1}},vertexShader:`
5550
5576
  varying vec2 vUv;
5551
5577
  void main() {
5552
5578
  vUv = position.xy * 0.5 + 0.5;
@@ -5554,7 +5580,7 @@ vec3 encodeSrgb(vec3 linear) {
5554
5580
  }
5555
5581
  `,fragmentShader:`
5556
5582
  precision highp float;
5557
- ${Mf}
5583
+ ${vh}
5558
5584
  varying vec2 vUv;
5559
5585
  uniform sampler2D uColour;
5560
5586
  uniform sampler2D uDepth;
@@ -5566,6 +5592,12 @@ vec3 encodeSrgb(vec3 linear) {
5566
5592
  uniform float uFocalLengthMm;
5567
5593
  uniform float uPixelsPerMm;
5568
5594
  uniform float uMaxRadius;
5595
+ uniform float uEncodeOutput;
5596
+
5597
+ /** The curve, or not — see setEncodesOutput. */
5598
+ vec3 forDestination(vec3 linear) {
5599
+ return uEncodeOutput > 0.5 ? encodeSrgb(linear) : linear;
5600
+ }
5569
5601
 
5570
5602
  /** How far away, in the scene's own units, whatever was drawn at this pixel stands. */
5571
5603
  float distanceAt(vec2 uv) {
@@ -5593,18 +5625,18 @@ vec3 encodeSrgb(vec3 linear) {
5593
5625
  float radius = blurRadius(here);
5594
5626
  vec4 colour = texture2D(uColour, vUv);
5595
5627
  if (radius < 0.75) {
5596
- gl_FragColor = vec4(encodeSrgb(colour.rgb), colour.a);
5628
+ gl_FragColor = vec4(forDestination(colour.rgb), colour.a);
5597
5629
  return;
5598
5630
  }
5599
5631
  vec2 texel = 1.0 / uResolution;
5600
5632
  vec3 total = colour.rgb;
5601
5633
  float weight = 1.0;
5602
- for (int tap = 0; tap < ${yr.TAPS}; tap++) {
5634
+ for (int tap = 0; tap < ${Er.TAPS}; tap++) {
5603
5635
  // Golden angle, with the radius growing as the square root of the index so the samples
5604
5636
  // cover the disc evenly rather than crowding its middle.
5605
5637
  float index = float(tap) + 0.5;
5606
5638
  float angle = index * 2.39996323;
5607
- float spread = sqrt(index / float(${yr.TAPS})) * radius;
5639
+ float spread = sqrt(index / float(${Er.TAPS})) * radius;
5608
5640
  vec2 at = vUv + vec2(cos(angle), sin(angle)) * spread * texel;
5609
5641
  // A sample only lends its light to this pixel if it is at least as blurred as the
5610
5642
  // distance it would have to cross — otherwise a sharp foreground would bleed into the
@@ -5615,9 +5647,9 @@ vec3 encodeSrgb(vec3 linear) {
5615
5647
  }
5616
5648
  // Averaged in LINEAR light, which is what a lens does — it adds photons, not screen
5617
5649
  // values — and encoded only at the very end. See colorSpace.ts.
5618
- gl_FragColor = vec4(encodeSrgb(total / weight), colour.a);
5650
+ gl_FragColor = vec4(forDestination(total / weight), colour.a);
5619
5651
  }
5620
- `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new nt(new as(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)}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 Ze{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=Ze.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=Ze.ICE_INDEX_RED){const n=Ze.minimumDeviationDeg(Ze.SIDE_PRISM_ANGLE_DEG,Ze.effectiveIndex(t,e));return Number.isFinite(n)?n:void 0}static parheliaDistanceDeg(e,t=Ze.ICE_INDEX_RED){const n=Ze.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=Ze.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(e*e-1)))*180/Math.PI}static circumzenithalAltitudeDeg(e,t=Ze.ICE_INDEX_RED){if(e<0||e>90-Ze.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 Ze.ringOf("halo22",Ze.SIDE_PRISM_ANGLE_DEG)}static halo46(){return Ze.ringOf("halo46",Ze.END_PRISM_ANGLE_DEG)}static ringOf(e,t){const n=Ze.minimumDeviationDeg(t,Ze.ICE_INDEX_RED),s=Ze.minimumDeviationDeg(t,Ze.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=[Ze.halo22(),Ze.halo46()],s=e>0?Ze.parheliaDistanceDeg(e):void 0;s!==void 0&&n.push({id:"parhelia",angleDeg:s,redAngleDeg:s,blueAngleDeg:Ze.parheliaDistanceDeg(e,Ze.ICE_INDEX_BLUE)}),n.push({id:"tangentArc",angleDeg:Ze.halo22().angleDeg}),e>0&&n.push({id:"parhelicCircle",angleDeg:e});const r=Ze.circumzenithalAltitudeDeg(e);return r!==void 0&&n.push({id:"circumzenithal",angleDeg:r}),e>Ze.PLATE_END_FACE_LIMIT_DEG&&n.push({id:"circumhorizontal"}),e<Ze.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&n.push({id:"pillar"}),n}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class ro{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),l=(t*e-n*a)/(t*e+n*a);return(o*o+l*l)/2}}class Bt{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(Bt.ANCHOR_BLUE-Bt.ANCHOR_RED)/(1/(Bt.BLUE_NM*Bt.BLUE_NM)-1/(Bt.RED_NM*Bt.RED_NM));static A=Bt.ANCHOR_RED-Bt.B/(Bt.RED_NM*Bt.RED_NM);static indexAt(e){return Bt.A+Bt.B/(e*e)}}class qs{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),l=Math.asin(r),c=ro.reflectance(s,1,this.index);let h=0;t[h].chords=0,t[h].scatteringAngle=qs.folded(Math.PI-2*o),t[h].weight=c,h++;const u=ro.reflectance(a,this.index,1);let d=1-c;for(let f=1;f<=qs.MAX_CHORDS&&h<t.length;f++){const g=2*(o-l)+(f-1)*(Math.PI-2*l);t[h].chords=f,t[h].scatteringAngle=qs.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 nn{static get WATER_INDEX_RED(){return Bt.indexAt(Bt.RED_NM)}static get WATER_INDEX_BLUE(){return Bt.indexAt(Bt.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 l=a%o;return l<0&&(l+=o),l>Math.PI&&(l=o-l),180-l*180/Math.PI}static primary(){return nn.bowOf("primary",2,0)}static secondary(){return nn.bowOf("secondary",3,0)}static bowOf(e,t,n){const s=nn.radiusDeg(t,nn.WATER_INDEX_RED),r=nn.radiusDeg(t,nn.WATER_INDEX_BLUE),a=(s+r)/2;return{id:e,radiusDeg:a,redRadiusDeg:s,violetRadiusDeg:r,topAltitudeDeg:a-n}}static alexandersBandDeg(){return{fromDeg:nn.primary().redRadiusDeg,toDeg:nn.secondary().redRadiusDeg}}static formsAt(e){return e<0?[]:[nn.bowOf("primary",2,e),nn.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-nn.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 cn{constructor(e){this.radius=e;const t=cn.SEGMENTS*cn.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const n=new bt;n.setAttribute("position",new ct(this.positions,3)),n.setAttribute("color",new ct(this.colors,3)),n.setDrawRange(0,0),this.object=new nt(n,new es({vertexColors:!0,transparent:!0,blending:Di,depthWrite:!1,fog:!1,side:Tn})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=cn.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(cn.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&&sn(e.altitudeDeg,e.azimuthDeg,1),this.tip=t&&sn(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*cn.SPREAD_FRACTION*Math.PI/180,a=h=>this.scale(this.slerp(t,n,h),this.radius),o=h=>this.radius*(cn.HEAD_HALF_WIDTH_DEG*Math.PI/180+r*h),l=h=>this.brightness*(1-h)**cn.FADE_POWER;let c=0;for(let h=1;h<cn.POINTS;h++){const u=(h-1)/cn.SEGMENTS,d=h/cn.SEGMENTS;c=this.pushBand(c,a(u),a(d),o(u),o(d),l(u),l(d))}e.setDrawRange(0,c),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}pushBand(e,t,n,s,r,a,o){const l=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(n,t))));for(let c=0;c<cn.ACROSS-1;c++){const h=c-1,u=c,d=this.across(t,l,s,h),f=this.across(n,l,r,h),g=this.across(t,l,s,u),x=this.across(n,l,r,u),m=(p,E)=>p===0?E: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 en{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(en.ANCHOR_BLUE-en.ANCHOR_RED)/(1/(en.BLUE_NM*en.BLUE_NM)-1/(en.RED_NM*en.RED_NM));static A=en.ANCHOR_RED-en.B/(en.RED_NM*en.RED_NM);static indexAt(e){return en.A+en.B/(e*e)}}class Dr{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(e,t,n,s,r,a){let o=0,l=0,c=0;Math.abs(n)<.9?(o=-t,l=e,c=0):(o=0,l=-n,c=t);const h=Math.hypot(o,l,c)||1;o/=h,l/=h,c/=h;const u=t*c-n*l,d=n*o-e*c,f=e*l-t*o,g=r/2,x=a/2;for(let m=0;m<6;m++){const p=s+m*Math.PI/3,E=Math.cos(p),A=Math.sin(p);this.normals[m*3]=o*E+u*A,this.normals[m*3+1]=l*E+d*A,this.normals[m*3+2]=c*E+f*A,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 l=-t,c=e,h=0,u=Math.hypot(l,c,h);u<1e-6&&(l=1,c=0,h=0,u=1),l/=u,c/=u,h/=u;const d=t*h-n*c,f=n*l-e*h,g=e*c-t*l,x=l*s+d*r-e*this.radius*2,m=c*s+f*r-t*this.radius*2,p=h*s+g*r-n*this.radius*2;let E=-1,A=-1/0,M=1/0;for(let j=0;j<8;j++){const ie=this.normals[j*3],ue=this.normals[j*3+1],ke=this.normals[j*3+2],qe=ie*e+ue*t+ke*n,Be=this.offsets[j]-(ie*x+ue*m+ke*p);if(qe>1e-9){const Y=Be/qe;Y<M&&(M=Y)}else if(qe<-1e-9){const Y=Be/qe;Y>A&&(A=Y,E=j)}else if(Be<0)return 0}if(E<0||A>=M)return 0;let S=0;const w=this.normals[E*3],R=this.normals[E*3+1],_=this.normals[E*3+2],b=-(w*e+R*t+_*n),D=ro.reflectance(b,1,a);o[S].x=e+2*b*w,o[S].y=t+2*b*R,o[S].z=n+2*b*_,o[S].weight=D,S++;const C=1/a,I=Math.sqrt(Math.max(0,1-C*C*(1-b*b)));let W=C*e+(C*b-I)*w,X=C*t+(C*b-I)*R,F=C*n+(C*b-I)*_,q=x+e*A,G=m+t*A,Z=p+n*A,te=1-D;for(let j=0;j<Dr.MAX_BOUNCES&&te>Dr.MIN_WEIGHT;j++){let ie=-1,ue=1/0;for(let z=0;z<8;z++){const Ee=this.normals[z*3],De=this.normals[z*3+1],Ae=this.normals[z*3+2],_e=Ee*W+De*X+Ae*F;if(_e<=1e-9)continue;const Ie=(this.offsets[z]-(Ee*q+De*G+Ae*Z))/_e;Ie>1e-9&&Ie<ue&&(ue=Ie,ie=z)}if(ie<0)break;const ke=this.normals[ie*3],qe=this.normals[ie*3+1],Be=this.normals[ie*3+2],Y=ke*W+qe*X+Be*F,re=a*Math.sqrt(Math.max(0,1-Y*Y));if(q+=W*ue,G+=X*ue,Z+=F*ue,re<1){const z=Math.sqrt(Math.max(0,1-re*re)),Ee=ro.reflectance(Y,a,1);if(o[S].x=a*W-(a*Y-z)*ke,o[S].y=a*X-(a*Y-z)*qe,o[S].z=a*F-(a*Y-z)*Be,o[S].weight=te*(1-Ee),S++,S>=o.length)return S;te*=Ee}const ne=2*Y;W-=ne*ke,X-=ne*qe,F-=ne*Be}return S}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class Rn{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=Rn.build(24);static build(e){const t=[];let n=0,s=0,r=0;for(let a=0;a<e;a++){const o=Rn.VIOLET_NM+(a+.5)/e*(Rn.DEEP_RED_NM-Rn.VIOLET_NM),[l,c,h]=Rn.colourMatching(o),u={wavelengthNm:o,r:Math.max(0,3.2406*l-1.5372*c-.4986*h),g:Math.max(0,-.9689*l+1.8758*c+.0415*h),b:Math.max(0,.0557*l-.204*c+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 ft{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 Dr;emergent=Array.from({length:Dr.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(ft.AZIMUTH_BINS*ft.ALTITUDE_BINS*3);radiance=new Float32Array(ft.AZIMUTH_BINS*ft.ALTITUDE_BINS*3);scratch=new Float32Array(ft.AZIMUTH_BINS*ft.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=ft.WORST_TILT_DEG*(ft.BEST_TILT_DEG/ft.WORST_TILT_DEG)**this.alignment;this.tilt=s*Math.PI/180}trace(e){const t=ft.AZIMUTH_BINS,n=ft.ALTITUDE_BINS,s=this.tally,r=ft.SOURCE_RADIUS_DEG*Math.PI/180,a=Math.cos(ft.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let l=0;l<e;l++){const c=this.pickPopulation();this.orient(c,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,E=(this.random()*2-1)*p,A=(this.random()*2-1)*p,M=4*p*p,S=Rn.SAMPLES[this.random()*Rn.SAMPLES.length|0],w=this.crystal.trace(g,x,m,E,A,en.indexAt(S.wavelengthNm),this.emergent);for(let R=0;R<w;R++){const _=this.emergent[R],b=Math.hypot(_.x,_.y,_.z);if(b<1e-9||_.weight<=0)continue;const D=_.x/b,C=_.y/b,I=_.z/b;if(D*g+C*x+I*m>a)continue;const W=Math.asin(Math.max(-1,Math.min(1,-I))),X=Math.abs(Math.atan2(-C,-D)),F=Math.min(t-1,X/Math.PI*t|0),G=(Math.min(n-1,(W+Math.PI/2)/Math.PI*n|0)*t+F)*3,Z=_.weight*M*Rn.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=ft.AZIMUTH_BINS,t=ft.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*ft.REFERENCE_MICRONS*ft.REFERENCE_MICRONS;for(let a=0;a<t;a++){const o=Math.sin(a/t*Math.PI-Math.PI/2),l=Math.sin((a+1)/t*Math.PI-Math.PI/2),c=1/(n*(l-o)*s*r);for(let h=0;h<e;h++){const u=(a*e+h)*3;this.radiance[u]=this.tally[u]*c,this.radiance[u+1]=this.tally[u+1]*c,this.radiance[u+2]=this.tally[u+2]*c}}}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 l=0;l<3;l++){let c=n[o+l];for(let h=0;h<e;h++){const u=o+h*3+l,d=h+1<e?n[u+3]:n[u];s[u]=(c+2*n[u]+d)/4,c=n[u]}}}n.set(s);const r=e*3;for(let a=0;a<t;a++){const o=a>0?-r:0,l=a+1<t?r:0,c=a*r;for(let h=c;h<c+r;h++)s[h]=(n[h+o]+2*n[h]+n[h+l])/4}}pickPopulation(){const e=this.random();let t=0;for(const n of ft.POPULATIONS)if(t+=n.share,e<=t)return n;return ft.POPULATIONS[ft.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 l=Math.sqrt(Math.max(0,1-o*o));r=l*Math.cos(n),a=l*Math.sin(n);break}case"plate":{o=this.spreadAboutAnAxis(t);const l=Math.sqrt(Math.max(0,1-o*o));r=l*Math.cos(n),a=l*Math.sin(n);break}case"column":case"parry":{o=this.spreadAboutAPlane(t);const l=Math.sqrt(Math.max(0,1-o*o));r=l*Math.cos(n),a=l*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 zn{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 ft;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;refining=!0;nextGlimpse=zn.FIRST_GLIMPSE_RAYS;workHandle;onRepaint;constructor(){const e=ft.AZIMUTH_BINS,t=ft.ALTITUDE_BINS;this.texels=new Uint16Array(e*t*4),this.texture=new hh(this.texels,e,t,pn,mn),this.texture.minFilter=Tt,this.texture.magFilter=Tt,this.texture.wrapS=fn,this.texture.wrapT=fn,this.texture.needsUpdate=!0,this.material=new It({uniforms:{uSource:{value:new U(0,1,0)},uUp:{value:new U(0,1,0)},uStrength:{value:0},uTint:{value:new U(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uMap:{value:this.texture},uGain:{value:zn.GAIN}},vertexShader:`
5652
+ `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new Je(new Ui(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 Ze{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=Ze.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=Ze.ICE_INDEX_RED){const n=Ze.minimumDeviationDeg(Ze.SIDE_PRISM_ANGLE_DEG,Ze.effectiveIndex(t,e));return Number.isFinite(n)?n:void 0}static parheliaDistanceDeg(e,t=Ze.ICE_INDEX_RED){const n=Ze.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=Ze.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(e*e-1)))*180/Math.PI}static circumzenithalAltitudeDeg(e,t=Ze.ICE_INDEX_RED){if(e<0||e>90-Ze.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 Ze.ringOf("halo22",Ze.SIDE_PRISM_ANGLE_DEG)}static halo46(){return Ze.ringOf("halo46",Ze.END_PRISM_ANGLE_DEG)}static ringOf(e,t){const n=Ze.minimumDeviationDeg(t,Ze.ICE_INDEX_RED),s=Ze.minimumDeviationDeg(t,Ze.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=[Ze.halo22(),Ze.halo46()],s=e>0?Ze.parheliaDistanceDeg(e):void 0;s!==void 0&&n.push({id:"parhelia",angleDeg:s,redAngleDeg:s,blueAngleDeg:Ze.parheliaDistanceDeg(e,Ze.ICE_INDEX_BLUE)}),n.push({id:"tangentArc",angleDeg:Ze.halo22().angleDeg}),e>0&&n.push({id:"parhelicCircle",angleDeg:e});const r=Ze.circumzenithalAltitudeDeg(e);return r!==void 0&&n.push({id:"circumzenithal",angleDeg:r}),e>Ze.PLATE_END_FACE_LIMIT_DEG&&n.push({id:"circumhorizontal"}),e<Ze.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&n.push({id:"pillar"}),n}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class oo{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),l=(t*e-n*a)/(t*e+n*a);return(o*o+l*l)/2}}class Bt{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(Bt.ANCHOR_BLUE-Bt.ANCHOR_RED)/(1/(Bt.BLUE_NM*Bt.BLUE_NM)-1/(Bt.RED_NM*Bt.RED_NM));static A=Bt.ANCHOR_RED-Bt.B/(Bt.RED_NM*Bt.RED_NM);static indexAt(e){return Bt.A+Bt.B/(e*e)}}class Ks{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),l=Math.asin(r),c=oo.reflectance(s,1,this.index);let h=0;t[h].chords=0,t[h].scatteringAngle=Ks.folded(Math.PI-2*o),t[h].weight=c,h++;const u=oo.reflectance(a,this.index,1);let d=1-c;for(let f=1;f<=Ks.MAX_CHORDS&&h<t.length;f++){const g=2*(o-l)+(f-1)*(Math.PI-2*l);t[h].chords=f,t[h].scatteringAngle=Ks.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 sn{static get WATER_INDEX_RED(){return Bt.indexAt(Bt.RED_NM)}static get WATER_INDEX_BLUE(){return Bt.indexAt(Bt.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 l=a%o;return l<0&&(l+=o),l>Math.PI&&(l=o-l),180-l*180/Math.PI}static primary(){return sn.bowOf("primary",2,0)}static secondary(){return sn.bowOf("secondary",3,0)}static bowOf(e,t,n){const s=sn.radiusDeg(t,sn.WATER_INDEX_RED),r=sn.radiusDeg(t,sn.WATER_INDEX_BLUE),a=(s+r)/2;return{id:e,radiusDeg:a,redRadiusDeg:s,violetRadiusDeg:r,topAltitudeDeg:a-n}}static alexandersBandDeg(){return{fromDeg:sn.primary().redRadiusDeg,toDeg:sn.secondary().redRadiusDeg}}static formsAt(e){return e<0?[]:[sn.bowOf("primary",2,e),sn.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-sn.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 un{constructor(e){this.radius=e;const t=un.SEGMENTS*un.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const n=new bt;n.setAttribute("position",new ct(this.positions,3)),n.setAttribute("color",new ct(this.colors,3)),n.setDrawRange(0,0),this.object=new Je(n,new is({vertexColors:!0,transparent:!0,blending:li,depthWrite:!1,fog:!1,side:Tn})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=un.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(un.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&&rn(e.altitudeDeg,e.azimuthDeg,1),this.tip=t&&rn(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*un.SPREAD_FRACTION*Math.PI/180,a=h=>this.scale(this.slerp(t,n,h),this.radius),o=h=>this.radius*(un.HEAD_HALF_WIDTH_DEG*Math.PI/180+r*h),l=h=>this.brightness*(1-h)**un.FADE_POWER;let c=0;for(let h=1;h<un.POINTS;h++){const u=(h-1)/un.SEGMENTS,d=h/un.SEGMENTS;c=this.pushBand(c,a(u),a(d),o(u),o(d),l(u),l(d))}e.setDrawRange(0,c),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}pushBand(e,t,n,s,r,a,o){const l=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(n,t))));for(let c=0;c<un.ACROSS-1;c++){const h=c-1,u=c,d=this.across(t,l,s,h),f=this.across(n,l,r,h),g=this.across(t,l,s,u),_=this.across(n,l,r,u),m=(p,E)=>p===0?E: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,_,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 tn{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(tn.ANCHOR_BLUE-tn.ANCHOR_RED)/(1/(tn.BLUE_NM*tn.BLUE_NM)-1/(tn.RED_NM*tn.RED_NM));static A=tn.ANCHOR_RED-tn.B/(tn.RED_NM*tn.RED_NM);static indexAt(e){return tn.A+tn.B/(e*e)}}class Nr{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(e,t,n,s,r,a){let o=0,l=0,c=0;Math.abs(n)<.9?(o=-t,l=e,c=0):(o=0,l=-n,c=t);const h=Math.hypot(o,l,c)||1;o/=h,l/=h,c/=h;const u=t*c-n*l,d=n*o-e*c,f=e*l-t*o,g=r/2,_=a/2;for(let m=0;m<6;m++){const p=s+m*Math.PI/3,E=Math.cos(p),A=Math.sin(p);this.normals[m*3]=o*E+u*A,this.normals[m*3+1]=l*E+d*A,this.normals[m*3+2]=c*E+f*A,this.offsets[m]=g}this.normals[18]=e,this.normals[19]=t,this.normals[20]=n,this.offsets[6]=_,this.normals[21]=-e,this.normals[22]=-t,this.normals[23]=-n,this.offsets[7]=_,this.radius=Math.hypot(g,_)}get aimRadius(){return this.radius}trace(e,t,n,s,r,a,o){let l=-t,c=e,h=0,u=Math.hypot(l,c,h);u<1e-6&&(l=1,c=0,h=0,u=1),l/=u,c/=u,h/=u;const d=t*h-n*c,f=n*l-e*h,g=e*c-t*l,_=l*s+d*r-e*this.radius*2,m=c*s+f*r-t*this.radius*2,p=h*s+g*r-n*this.radius*2;let E=-1,A=-1/0,M=1/0;for(let j=0;j<8;j++){const ie=this.normals[j*3],ue=this.normals[j*3+1],ke=this.normals[j*3+2],qe=ie*e+ue*t+ke*n,Be=this.offsets[j]-(ie*_+ue*m+ke*p);if(qe>1e-9){const Y=Be/qe;Y<M&&(M=Y)}else if(qe<-1e-9){const Y=Be/qe;Y>A&&(A=Y,E=j)}else if(Be<0)return 0}if(E<0||A>=M)return 0;let S=0;const w=this.normals[E*3],R=this.normals[E*3+1],x=this.normals[E*3+2],b=-(w*e+R*t+x*n),D=oo.reflectance(b,1,a);o[S].x=e+2*b*w,o[S].y=t+2*b*R,o[S].z=n+2*b*x,o[S].weight=D,S++;const C=1/a,I=Math.sqrt(Math.max(0,1-C*C*(1-b*b)));let W=C*e+(C*b-I)*w,X=C*t+(C*b-I)*R,F=C*n+(C*b-I)*x,q=_+e*A,G=m+t*A,Z=p+n*A,te=1-D;for(let j=0;j<Nr.MAX_BOUNCES&&te>Nr.MIN_WEIGHT;j++){let ie=-1,ue=1/0;for(let z=0;z<8;z++){const Ee=this.normals[z*3],De=this.normals[z*3+1],Ae=this.normals[z*3+2],xe=Ee*W+De*X+Ae*F;if(xe<=1e-9)continue;const Ie=(this.offsets[z]-(Ee*q+De*G+Ae*Z))/xe;Ie>1e-9&&Ie<ue&&(ue=Ie,ie=z)}if(ie<0)break;const ke=this.normals[ie*3],qe=this.normals[ie*3+1],Be=this.normals[ie*3+2],Y=ke*W+qe*X+Be*F,re=a*Math.sqrt(Math.max(0,1-Y*Y));if(q+=W*ue,G+=X*ue,Z+=F*ue,re<1){const z=Math.sqrt(Math.max(0,1-re*re)),Ee=oo.reflectance(Y,a,1);if(o[S].x=a*W-(a*Y-z)*ke,o[S].y=a*X-(a*Y-z)*qe,o[S].z=a*F-(a*Y-z)*Be,o[S].weight=te*(1-Ee),S++,S>=o.length)return S;te*=Ee}const ne=2*Y;W-=ne*ke,X-=ne*qe,F-=ne*Be}return S}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class Rn{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=Rn.build(24);static build(e){const t=[];let n=0,s=0,r=0;for(let a=0;a<e;a++){const o=Rn.VIOLET_NM+(a+.5)/e*(Rn.DEEP_RED_NM-Rn.VIOLET_NM),[l,c,h]=Rn.colourMatching(o),u={wavelengthNm:o,r:Math.max(0,3.2406*l-1.5372*c-.4986*h),g:Math.max(0,-.9689*l+1.8758*c+.0415*h),b:Math.max(0,.0557*l-.204*c+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 ft{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 Nr;emergent=Array.from({length:Nr.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(ft.AZIMUTH_BINS*ft.ALTITUDE_BINS*3);radiance=new Float32Array(ft.AZIMUTH_BINS*ft.ALTITUDE_BINS*3);scratch=new Float32Array(ft.AZIMUTH_BINS*ft.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=ft.WORST_TILT_DEG*(ft.BEST_TILT_DEG/ft.WORST_TILT_DEG)**this.alignment;this.tilt=s*Math.PI/180}trace(e){const t=ft.AZIMUTH_BINS,n=ft.ALTITUDE_BINS,s=this.tally,r=ft.SOURCE_RADIUS_DEG*Math.PI/180,a=Math.cos(ft.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let l=0;l<e;l++){const c=this.pickPopulation();this.orient(c,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),_=-Math.cos(d)*Math.sin(f),m=-Math.sin(d),p=this.crystal.aimRadius,E=(this.random()*2-1)*p,A=(this.random()*2-1)*p,M=4*p*p,S=Rn.SAMPLES[this.random()*Rn.SAMPLES.length|0],w=this.crystal.trace(g,_,m,E,A,tn.indexAt(S.wavelengthNm),this.emergent);for(let R=0;R<w;R++){const x=this.emergent[R],b=Math.hypot(x.x,x.y,x.z);if(b<1e-9||x.weight<=0)continue;const D=x.x/b,C=x.y/b,I=x.z/b;if(D*g+C*_+I*m>a)continue;const W=Math.asin(Math.max(-1,Math.min(1,-I))),X=Math.abs(Math.atan2(-C,-D)),F=Math.min(t-1,X/Math.PI*t|0),G=(Math.min(n-1,(W+Math.PI/2)/Math.PI*n|0)*t+F)*3,Z=x.weight*M*Rn.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=ft.AZIMUTH_BINS,t=ft.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*ft.REFERENCE_MICRONS*ft.REFERENCE_MICRONS;for(let a=0;a<t;a++){const o=Math.sin(a/t*Math.PI-Math.PI/2),l=Math.sin((a+1)/t*Math.PI-Math.PI/2),c=1/(n*(l-o)*s*r);for(let h=0;h<e;h++){const u=(a*e+h)*3;this.radiance[u]=this.tally[u]*c,this.radiance[u+1]=this.tally[u+1]*c,this.radiance[u+2]=this.tally[u+2]*c}}}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 l=0;l<3;l++){let c=n[o+l];for(let h=0;h<e;h++){const u=o+h*3+l,d=h+1<e?n[u+3]:n[u];s[u]=(c+2*n[u]+d)/4,c=n[u]}}}n.set(s);const r=e*3;for(let a=0;a<t;a++){const o=a>0?-r:0,l=a+1<t?r:0,c=a*r;for(let h=c;h<c+r;h++)s[h]=(n[h+o]+2*n[h]+n[h+l])/4}}pickPopulation(){const e=this.random();let t=0;for(const n of ft.POPULATIONS)if(t+=n.share,e<=t)return n;return ft.POPULATIONS[ft.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 l=Math.sqrt(Math.max(0,1-o*o));r=l*Math.cos(n),a=l*Math.sin(n);break}case"plate":{o=this.spreadAboutAnAxis(t);const l=Math.sqrt(Math.max(0,1-o*o));r=l*Math.cos(n),a=l*Math.sin(n);break}case"column":case"parry":{o=this.spreadAboutAPlane(t);const l=Math.sqrt(Math.max(0,1-o*o));r=l*Math.cos(n),a=l*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 zn{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 ft;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;refining=!0;nextGlimpse=zn.FIRST_GLIMPSE_RAYS;workHandle;onRepaint;constructor(){const e=ft.AZIMUTH_BINS,t=ft.ALTITUDE_BINS;this.texels=new Uint16Array(e*t*4),this.texture=new fh(this.texels,e,t,gn,Qt),this.texture.minFilter=Rt,this.texture.magFilter=Rt,this.texture.wrapS=mn,this.texture.wrapT=mn,this.texture.needsUpdate=!0,this.material=new Et({uniforms:{uSource:{value:new U(0,1,0)},uUp:{value:new U(0,1,0)},uStrength:{value:0},uTint:{value:new U(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uMap:{value:this.texture},uGain:{value:zn.GAIN}},vertexShader:`
5621
5653
  varying vec3 vDirection;
5622
5654
  void main() {
5623
5655
  vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
@@ -5625,8 +5657,8 @@ vec3 encodeSrgb(vec3 linear) {
5625
5657
  }
5626
5658
  `,fragmentShader:`
5627
5659
  precision highp float;
5628
- ${xf}
5629
- ${lM}
5660
+ ${Ef}
5661
+ ${dM}
5630
5662
  varying vec3 vDirection;
5631
5663
  uniform vec3 uSource;
5632
5664
  uniform vec3 uUp;
@@ -5667,7 +5699,7 @@ vec3 encodeSrgb(vec3 linear) {
5667
5699
  // display fades at the edge of a fibre instead of ending on a cut line.
5668
5700
  gl_FragColor = vec4(light * uStrength * (0.25 + 0.75 * ice), 1.0);
5669
5701
  }
5670
- `,transparent:!0,blending:Di,depthWrite:!1,side:Dt,fog:!1}),this.object=new nt(new Pn(zn.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)<zn.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=zn.FIRST_GLIMPSE_RAYS,this.scheduleWork())}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;tracingFor(e,t){return this.tracing&&Math.abs(e-this.pendingAltitudeDeg)<zn.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(zn.RAYS_PER_FRAME);const t=this.sky.tracedRays>=zn.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]=Gs.toHalfFloat(t[s]),this.texels[n+1]=Gs.toHalfFloat(t[s+1]),this.texels[n+2]=Gs.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 St{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new qs;previous=St.emergences();current=St.emergences();tally=new Float32Array(St.BINS*3);radiance=new Float32Array(St.BINS*3);scratch=new Float32Array(St.BINS*3);static emergences(){return Array.from({length:qs.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const e of Rn.SAMPLES)this.sweep(e);return this.toRadiance(),this.blurBySourceDisc(),{bins:St.BINS,data:this.radiance,binDeg:180/St.BINS}}sweep(e){this.drop.refractiveIndex=Bt.indexAt(e.wavelengthNm);const t=St.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 l=this.previous[o],c=this.current[o];l.chords===c.chords&&this.deposit(l.scatteringAngle,c.scatteringAngle,(l.weight+c.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=St.BINS,a=Math.PI/r,o=Math.min(e,t),l=Math.max(e,t),c=l-o,h=Math.min(r-1,Math.max(0,Math.floor(o/a))),u=Math.min(r-1,Math.max(0,Math.floor(l/a)));if(c<=0||h===u){this.add(h,n,s);return}for(let d=h;d<=u;d++){const f=Math.min(l,(d+1)*a)-Math.max(o,d*a);f>0&&this.add(d,n*f/c,s)}}add(e,t,n){const s=e*3,r=t*Rn.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=St.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<=St.FULL_UNTIL_DEG)return 1;if(t>=St.FADED_BY_DEG)return 0;const n=(t-St.FULL_UNTIL_DEG)/(St.FADED_BY_DEG-St.FULL_UNTIL_DEG);return Math.cos(n*Math.PI/2)**2}blurBySourceDisc(){const e=St.BINS,t=St.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),l=Math.sqrt(o);s.push(l),r+=l}if(!(r<=0)){this.scratch.set(this.radiance);for(let a=0;a<e;a++){let o=0,l=0,c=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,l+=this.scratch[d+1]*f,c+=this.scratch[d+2]*f}const h=a*3;this.radiance[h]=o/r,this.radiance[h+1]=l/r,this.radiance[h+2]=c/r}}}}class Sr{static RADIUS=880;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new St;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(St.BINS*4),this.texture=new hh(this.texels,St.BINS,1,pn,mn),this.texture.minFilter=Tt,this.texture.magFilter=Tt,this.texture.wrapS=fn,this.texture.wrapT=fn,this.texture.needsUpdate=!0,this.material=new It({uniforms:{uSource:{value:new U(0,1,0)},uStrength:{value:0},uTint:{value:new U(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:Sr.GAIN}},vertexShader:`
5702
+ `,transparent:!0,blending:li,depthWrite:!1,side:Pt,fog:!1}),this.object=new Je(new Pn(zn.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)<zn.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=zn.FIRST_GLIMPSE_RAYS,this.scheduleWork())}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;tracingFor(e,t){return this.tracing&&Math.abs(e-this.pendingAltitudeDeg)<zn.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(zn.RAYS_PER_FRAME);const t=this.sky.tracedRays>=zn.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]=Ws.toHalfFloat(t[s]),this.texels[n+1]=Ws.toHalfFloat(t[s+1]),this.texels[n+2]=Ws.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 St{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new Ks;previous=St.emergences();current=St.emergences();tally=new Float32Array(St.BINS*3);radiance=new Float32Array(St.BINS*3);scratch=new Float32Array(St.BINS*3);static emergences(){return Array.from({length:Ks.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const e of Rn.SAMPLES)this.sweep(e);return this.toRadiance(),this.blurBySourceDisc(),{bins:St.BINS,data:this.radiance,binDeg:180/St.BINS}}sweep(e){this.drop.refractiveIndex=Bt.indexAt(e.wavelengthNm);const t=St.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 l=this.previous[o],c=this.current[o];l.chords===c.chords&&this.deposit(l.scatteringAngle,c.scatteringAngle,(l.weight+c.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=St.BINS,a=Math.PI/r,o=Math.min(e,t),l=Math.max(e,t),c=l-o,h=Math.min(r-1,Math.max(0,Math.floor(o/a))),u=Math.min(r-1,Math.max(0,Math.floor(l/a)));if(c<=0||h===u){this.add(h,n,s);return}for(let d=h;d<=u;d++){const f=Math.min(l,(d+1)*a)-Math.max(o,d*a);f>0&&this.add(d,n*f/c,s)}}add(e,t,n){const s=e*3,r=t*Rn.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=St.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<=St.FULL_UNTIL_DEG)return 1;if(t>=St.FADED_BY_DEG)return 0;const n=(t-St.FULL_UNTIL_DEG)/(St.FADED_BY_DEG-St.FULL_UNTIL_DEG);return Math.cos(n*Math.PI/2)**2}blurBySourceDisc(){const e=St.BINS,t=St.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),l=Math.sqrt(o);s.push(l),r+=l}if(!(r<=0)){this.scratch.set(this.radiance);for(let a=0;a<e;a++){let o=0,l=0,c=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,l+=this.scratch[d+1]*f,c+=this.scratch[d+2]*f}const h=a*3;this.radiance[h]=o/r,this.radiance[h+1]=l/r,this.radiance[h+2]=c/r}}}}class wr{static RADIUS=880;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new St;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(St.BINS*4),this.texture=new fh(this.texels,St.BINS,1,gn,Qt),this.texture.minFilter=Rt,this.texture.magFilter=Rt,this.texture.wrapS=mn,this.texture.wrapT=mn,this.texture.needsUpdate=!0,this.material=new Et({uniforms:{uSource:{value:new U(0,1,0)},uStrength:{value:0},uTint:{value:new U(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:wr.GAIN}},vertexShader:`
5671
5703
  varying vec3 vDirection;
5672
5704
  void main() {
5673
5705
  vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
@@ -5695,7 +5727,7 @@ vec3 encodeSrgb(vec3 linear) {
5695
5727
  light = mix(vec3(grey), light, uSaturation);
5696
5728
  gl_FragColor = vec4(light * uStrength, 1.0);
5697
5729
  }
5698
- `,transparent:!0,blending:Di,depthWrite:!1,side:Dt,fog:!1}),this.object=new nt(new Pn(Sr.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:Sr.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]=Gs.toHalfFloat(t[s]),this.texels[n+1]=Gs.toHalfFloat(t[s+1]),this.texels[n+2]=Gs.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 yf{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 Ji{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 yf(r),l=Math.floor(a),c=l+(o.next()<a-l?1:0),h=[];for(let u=0;u<c;u++){const d=Math.min(1,Math.max(0,(s-20)/52)),f=Ji.MAX_DURATION_MS-d*(Ji.MAX_DURATION_MS-Ji.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 zt{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=zt.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(zt.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=zt.MAX_CONCURRENT*zt.SEGMENTS*zt.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const t=new bt;t.setAttribute("position",new ct(this.positions,3)),t.setAttribute("color",new ct(this.colors,3)),t.setDrawRange(0,0),this.object=new nt(t,new es({vertexColors:!0,transparent:!0,blending:Di,depthWrite:!1,fog:!1,side:Tn})),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=Ji.aliveAt(this.meteors,e).slice(0,zt.MAX_CONCURRENT);let s=0;for(const{meteor:r,progress:a}of n){const o=this.radiantOf(r);if(!o)continue;const l=sn(o.altitudeDeg,o.azimuthDeg,1),[c,h]=this.basisAround(l),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(c,h,r.bearingDeg),x=(.15+.85*r.brightness)*f,m=A=>x*A**1.6,p=A=>this.onSphere(l,g,d+(u-d)*A),E=A=>zt.RADIUS*((zt.MIN_HALF_WIDTH_DEG+zt.BRIGHT_HALF_WIDTH_DEG*r.brightness*A)*Math.PI/180);for(let A=1;A<zt.POINTS;A++){const M=(A-1)/zt.SEGMENTS,S=A/zt.SEGMENTS;s=this.pushRibbon(s,p(M),p(S),E(M),E(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=sn(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),l=Math.hypot(o.x,o.y,o.z)||1;return{altitudeDeg:Math.asin(o.y/l)*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 l=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(n,t))));for(let c=0;c<zt.ACROSS-1;c++){const h=c-1,u=c,d=this.across(t,l,s,h),f=this.across(n,l,r,h),g=this.across(t,l,s,u),x=this.across(n,l,r,u),m=(p,E)=>p===0?E: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)*zt.RADIUS,y:(e.y*r+t.y*a)*zt.RADIUS,z:(e.z*r+t.z*a)*zt.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 _d=Math.PI/180;function Yt(i,e,t,n,s=!1){const r=s?new es({color:new Me(...t)}):new Ir({color:new Me(...t)}),a=new nt(e,r);return a.position.y=n,a.userData={emissive:s},a.castShadow=!s,a.receiveShadow=!s,i.add(a),a}const xd=.25,mM=.002;function gM(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],bf=[1,.85,.5],Ef=[.25,.25,.25],wf=[1,.97,.85],vM=[.55,.68,.72],kn=.03,Hn=.05,Af={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 Jt(i,e){return i?.[e]}function Gn(i,e,t,n,s,r,a,o){if(o===void 0)return;const l=new Ir({color:new Me(...vM),transparent:!0,opacity:o/100}),c=new nt(new bn(e,t,n),l);c.position.set(s,r,a),i.add(c)}const xn=.05,ul=[.6,.58,.53],Md=[.5,.5,.48];function Os(i,e,t,n,s,r,a,o){const l=new Ir({color:new Me(...o),side:Dt}),c=new nt(new bn(e,t,n),l);c.position.set(s,r,a),i.add(c)}function _M(i,e,t,n,s,r,a,o,l){const c=(n-r)/2,h=(g,x,m,p)=>{g<=0||(e?Os(i,g,x,xn,m,o+p,a,l):Os(i,xn,x,g,a,o+p,m,l))};h(t,c,0,n/2-c/2),h(t,c,0,-(n/2-c/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,l,c){const h=(n+s)/2,u=s-n,d=(f,g,x,m)=>{f.length===0?g?Os(i,x,u,xn,0,h,m,ul):Os(i,xn,u,x,m,h,0,ul):_M(i,g,x,u,f,r,m,h,ul)};d(a,!0,e*2,-t+xn),d(o,!0,e*2,t-xn),d(l,!1,t*2,-e+xn),d(c,!1,t*2,e-xn),Os(i,e*2,xn,t*2,0,n+xn,0,Md),Os(i,e*2,xn,t*2,0,s-xn,0,Md)}function Vc(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:-Vn};case"front-right":return{x:e-n,z:-Vn};case"behind-left":return{x:-(e-n),z:Vn};case"behind-right":return{x:e-n,z:Vn}}}function Rf(i,e,t,n,s,r,a){const o=Pf();o.scale.setScalar(n),o.rotation.y=Af[e];const{x:l,z:c}=Vc(e,s,r,a);o.position.set(l,t,c),i.add(o)}const Wc=6,Xc=6,Si=3,hr=1.4,ur=Si*.5,Cf=1.2,Df=.35,xM=.75,MM=1.6;function yM(i,e,t,n){const s=new Cn,r=Math.max(1,i+1),a=r*Si;Yt(s,new bn(Wc,a,Xc),[.55,.54,.5],a/2);const o=Wc/2,l=Xc/2;for(let c=0;c<r;c++){const h=c*Si+Si/2;Gn(s,hr,ur,Hn,0,h,-l-kn,Jt(e,"front")),Gn(s,hr,ur,Hn,0,h,l+kn,Jt(e,"behind")),Gn(s,Hn,ur,hr,-o-kn,h,0,Jt(e,"left")),Gn(s,Hn,ur,hr,o+kn,h,0,Jt(e,"right"))}if(t){const c=Math.min(Math.max(n??0,0),r-1);Rf(s,t,c*Si,.72,o,l,Cf);const h=u=>Jt(e,u)!==void 0?[{main:hr,center:0}]:[];Tf(s,o,l,c*Si,(c+1)*Si,ur,h("front"),h("behind"),h("left"),h("right"))}return s}function SM(){const i=new Cn;return Yt(i,new Li(.15,.22,2,8),[.32,.22,.14],1),Yt(i,new fo(1.4,3,8),[.16,.32,.14],3.5),i}function bM(i){const e=new Cn;return Yt(e,new Li(.05,.08,5,8),[.28,.28,.3],2.5),Yt(e,new Pn(.25,12,8),i?bf:Sf,5.1,!0),e}const EM=[.08,.08,.08],yi=.8,Ls=1,On=1.7,dl=.6,Hi=.4,Aa=1.2,Ds=.7,Vn=.5,wM=On;function AM(i,e,t){const n=new Cn;Yt(n,new bn(1.8,1.4,4.2),[.45,.14,.14],.7),Yt(n,new bn(yi*2,dl,Ls*2),[.4,.12,.12],On);for(const r of[-1.4,1.4])for(const a of[-.95,.95]){const o=Yt(n,new Li(.4,.4,.3,12),EM,.4);o.rotation.z=Math.PI/2,o.position.x=a,o.position.z=r}const s=i?wf:Ef;for(const r of[-.7,.7])Yt(n,new Pn(.15,8,6),s,.7,!0).position.set(r,.7,-2.1);if(Gn(n,Aa,Hi,Hn,0,On,-Ls-kn,Jt(e,"front")),Gn(n,Aa,Hi,Hn,0,On,Ls+kn,Jt(e,"behind")),Gn(n,Hn,Hi,Ds,-yi-kn,On,-Vn,Jt(e,"front-left")),Gn(n,Hn,Hi,Ds,-yi-kn,On,Vn,Jt(e,"behind-left")),Gn(n,Hn,Hi,Ds,yi+kn,On,-Vn,Jt(e,"front-right")),Gn(n,Hn,Hi,Ds,yi+kn,On,Vn,Jt(e,"behind-right")),t){Rf(n,t,xM,.5,yi,Ls,Df);const r=(l,c)=>{const h=[];return Jt(e,l)!==void 0&&h.push({main:Ds,center:-Vn}),Jt(e,c)!==void 0&&h.push({main:Ds,center:Vn}),h},a=Jt(e,"front")!==void 0?[{main:Aa,center:0}]:[],o=Jt(e,"behind")!==void 0?[{main:Aa,center:0}]:[];Tf(n,yi,Ls,On-dl/2,On+dl/2,Hi,a,o,r("front-left","behind-left"),r("front-right","behind-right"))}return n}const TM=[.95,.9,.82];function Pf(){const i=new Cn;Yt(i,new Li(.25,.3,1.5,10),[.3,.3,.35],.75),Yt(i,new Pn(.22,10,8),[.62,.52,.46],1.72);const e=Yt(i,new fo(.07,.16,8),TM,1.72);return e.rotation.x=-Math.PI/2,e.position.z=-.2,i}const RM=17,yd=18.5,fl=[.16,.16,.18];function CM(){const i=new Cn,e=Yt(i,new Li(1.8,1.8,yd*2,10),fl,0);e.rotation.x=Math.PI/2,Yt(i,new bn(RM*2,.5,4.5),fl,0);const t=Yt(i,new bn(.4,5.5,4),fl,3);return t.position.z=-yd+2,i}class Ps{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"?Vc(t,yi,Ls,Df):Vc(t,Wc/2,Xc/2,Cf),r=e.kind==="vehicle"?wM:(e.occupiedFloor??0)*Si+MM,a=(e.headingDeg??0)-Af[t]/_d;return{x:n,z:s,eyeY:r,headingDeg:a}}static build(e,t){const n=e.kind==="building"?yM(e.floors??op,e.windows,e.witnessSide,e.occupiedFloor):e.kind==="tree"?SM():e.kind==="streetlight"?bM(t):e.kind==="vehicle"?AM(t,e.windows,e.witnessSide):e.kind==="aircraft"?CM():Pf();return e.headingDeg!==void 0&&(n.rotation.y=-e.headingDeg*_d),this.addLights(n,e.lights),e.kind==="aircraft"&&this.exemptFromFog(n),n}static exemptFromFog(e){for(const t of e.children){if(!(t instanceof nt))continue;const n=t.material;n.fog=!1,n.needsUpdate=!0}}static addLights(e,t){for(const n of t??[]){const s=Yt(e,new Pn(xd,8,6),gM(n.color),n.offsetM.y,!0);s.position.set(n.offsetM.x,n.offsetM.y,n.offsetM.z),s.userData={emissive:!0,lightId:n.id},s.visible=!1}}static setLights(e,t,n,s){if(!t||t.length===0)return;const r=new Map(t.map(o=>[o.id,o])),a=Math.max(1,s*mM/xd);for(const o of e.children){if(!(o instanceof nt))continue;const l=o.userData.lightId;if(!l)continue;const c=r.get(l);c&&(o.visible=cp(c,n),o.scale.setScalar(a*(c.intensity??1)**.5))}}static setLit(e,t,n){const s=t==="streetlight"?n?bf:Sf:n?wf:Ef;for(const r of e.children){const a=r.userData;!(r instanceof nt)||!a.emissive||a.lightId||r.material.color.setRGB(...s)}}static dispose(e){for(const t of e.children)t instanceof nt&&(t.geometry.dispose(),t.material.dispose())}}function DM(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 Ta=900,Sd=.5,_r=900,PM=6371e3,IM=3e4;function bd(i){const e=Math.sqrt(2*PM*Math.max(i,0));return Math.max(_r,Math.min(e,IM))}const pl=.5,Ed=850,LM=.03,Ra=850,ml=4,wd=1.5,Ad=-1,NM=6,qc=-4,Td=.2,Ca=2600,UM=.97,FM=.38,Rd=qc,OM=3,zM=.15,BM=.6,kM=40,HM=30,GM=[0,45,90,135,180,225,270,315],VM={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},WM=["en","fr"],XM=880,gl=40,qM=60,YM=10,KM=1,$M=150,ZM=55,JM=.5,QM=2.05,Cd=.265,Dd=[[0,0],...Array.from({length:8},(i,e)=>{const t=e*Math.PI/4;return[Math.cos(t)*Cd,Math.sin(t)*Cd]})],Pd=700,jM=250/jd,ey=12,Id=5,vl=6,Gi=[.92,.92,.95],_l=[.15,.15,.19],Ld={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}},Ns=0,ty=0,Nd=3e3,dr=20,ny=15,Ud=Ns,iy=40,Fd=1,sy=9;function Od(i){return Fd+(sy-Fd)*i}const ry=new Me(.75,.82,.92),ay=10,oy=.5;function ly(i){return If(i/ay,oy,1)}const Is=200,zd=.18,Bd=.32,cy=.35,hy=new Me(.85,.9,.98),kd=5,Hd=.85,Gd=.01;function xl(i,e){return Math.round(i*(Gd+(1-Gd)*e))}const Vd=230,Wd=.7,Xd=.05,uy=.6,dy=.7,fy=.15,qd=.35,py=3,my=1/12,gy=.5,Yd=8,Kd=25,$d=.12,vy={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 _y{renderer;scene=new lh;camera;celestialGroup=new Cn;skyMesh;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;celestialLight=new rg(16777215,0);celestialLightTarget=new Rt;skyLight=new tg(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;raycaster=new Zo;weather=e0;observerElevationM=0;groundRadius=_r;terrainRadius=_r;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new U;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 U;sunVisible=!1;lensFlareScratch=new U;sunOcclusionRaycaster=new Zo;sunOcclusionDirectionScratch=new U;sunOcclusionRightScratch=new U;sunOcclusionUpScratch=new U;ufoOcclusionRaycaster=new Zo;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;lensOptics;meteorSystem;cometTail;iceHalos;rainbow;cometKey;onLightningFlash;constructor(e,t=W3(),n){this.renderer=new ix({canvas:e,antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=Mr,this.camera=new un(60,e.width/Math.max(e.height,1),.1,Ta*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)*ln;e.headingDeg!==void 0?this.camera.rotation.set(e.pitchDeg*ln,-e.headingDeg*ln,t,"YXZ"):this.camera.rotation.set(e.pitchDeg*ln,this.camera.rotation.y,t,"YXZ"),e.elevationM!==this.observerElevationM&&(this.observerElevationM=e.elevationM,this.syncCloudLayer(),Math.abs(bd(e.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/_r),this.camera.far=Math.max(Ta*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}=is(e,t,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(a*a+o*o)<$M*(s/_r))return}this.terrainOrigin={lat:e,lng:t},this.terrainRadius=s;const r=++this.terrainBuildToken;Z3(e,t,this.terrainProviders,s).then(({mesh:a,attribution:o})=>{r===this.terrainBuildToken&&(this.disposeMesh(this.terrainMesh),a.renderOrder=KM,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=ZM*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=Ax(e)*this.sunCloudTransmission*this.sunUnhiddenFraction,n=ki(e);this.lensFlare.uniforms.uDazzleColour.value.setRGB(n[0],n[1],n[2]),this.lensFlare.uniforms.uVeilStrength.value=QM**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){DM(this.weather,e)||(this.weather=e,this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lightningArmed=e.storm&&e.cloudDarkness>=gy,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(),Ps.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear();for(const t of e){const n=Ps.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?is(e.lat,e.lng,t.lat,t.lng):{x:0,z:0},r=this.decorObjects.find(c=>c.witnessSide!==void 0&&lp(c.kind)),a={x:0,z:0};let o=0;if(r){const c=Ps.occupantView(r),h=-(r.headingDeg??0)*ln,u=c.x*Math.cos(h)+c.z*Math.sin(h),d=-c.x*Math.sin(h)+c.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=c.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*ln,-(c.headingDeg+this.indoorLookYawDeg)*ln,0,"YXZ")}for(const c of this.decorObjects){const h=this.decorGroups.get(c.id);if(!h)continue;const u=s0(c,n);h.position.set(u.eastM+s.x+a.x,ty+u.altitudeM,-u.northM+s.z+a.z),u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*ln),o=Math.max(o,h.position.distanceTo(this.camera.position))}const l=Math.max(Ta*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-l)>1&&(this.camera.far=l,this.camera.updateProjectionMatrix())}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(e,t){this.indoorLookYawDeg=e,this.indoorLookPitchDeg=t}updateDecorLitState(e){for(const t of this.decorObjects){const n=this.decorGroups.get(t.id);if(n&&t.lights?.length&&Ps.setLights(n,t.lights,e,n.position.distanceTo(this.camera.position)),t.kind!=="streetlight"&&t.kind!=="vehicle")continue;const s=this.decorGroups.get(t.id);if(!s)continue;const r=i0(t,e);Ps.setLit(s,t.kind,r);const a=this.streetlightLights.get(t.id);a&&(a.visible=r)}}addStreetlightLight(e,t){const n=t.children.find(r=>r.userData.emissive);if(!n)return;const s=new ig(16764006,kM,HM);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=bc(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,ml,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.scene.fog=new oh(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=BM;const s=e.sun.altitudeDeg>=Rd,r=!s&&e.moon.altitudeDeg>=Rd;if(!s&&!r){this.celestialLight.intensity=0;return}const a=s?e.sun:e.moon,{x:o,y:l,z:c}=sn(a.altitudeDeg,a.azimuthDeg,Ra);this.celestialLight.position.set(o,l,c);const h=ki(a.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const u=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*ln));this.celestialLight.intensity=(s?OM:zM)*u,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(e,t,n){this.meteorSystem||(this.meteorSystem=new zt,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=Ht.starPointsOf(e),n=Ht.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(){const e=this.usableEquidistantPass();if(!e){this.updateLensFlarePosition();const t=this.usableDepthOfFieldPass();t?t.render(this.renderer,this.scene,this.camera):this.renderer.render(this.scene,this.camera);return}e.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition())}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 yr(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(so.supports(this.camera.fov,e.x/Math.max(e.y,1)))return this.equidistantPass?this.equidistantPass.resize(e.x,e.y):this.equidistantPass=new so(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 Dd)this.isSunOccluded(t[0],t[1])||e++;return e/Dd.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,l=this.sunOcclusionRightScratch.set(s.z,0,-s.x);l.lengthSq()<1e-9&&l.set(1,0,0),l.normalize();const c=this.sunOcclusionUpScratch.crossVectors(l,s).normalize();s.addScaledVector(l,e*o).addScaledVector(c,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=Sd,this.ufoOcclusionRaycaster.intersectObjects(r,!0).length>0)}decorDistancesAt(e,t,n){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),this.ufoOcclusionRaycaster.near=Sd;let s,r;for(const a of this.decorObjects){const o=this.decorGroups.get(a.id);if(!o)continue;const l=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];l&&(a.occludesSourceIds?.includes(n)?s=s===void 0?l.distance:Math.max(s,l.distance):r=r===void 0?l.distance:Math.min(r,l.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)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(LM*this.camera.fov*Math.PI/180);let r,a=s;for(const o of this.namedStars){const l=o.direction.dot(n);l>a&&(a=l,r={star:o.star,altitudeDeg:o.altitudeDeg})}return r}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.depthOfFieldPass?.dispose(),this.depthOfFieldPass=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())Ps.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,my);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.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(Ta,32,16),n=t.attributes.position,s=[];for(let a=0;a<n.count;a++){const{altitudeDeg:o,azimuthDeg:l}=ox(n.getX(a),n.getY(a),n.getZ(a)),c=mx(o,l,e.azimuthDeg,e.altitudeDeg);s.push(c[0],c[1],c[2])}t.setAttribute("color",new Pt(s,3));const r=new es({vertexColors:!0,side:Dt,fog:!1,depthWrite:!1});this.skyMesh=new nt(t,r),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){this.disposeMesh(this.groundMesh),this.groundRadius=bd(this.observerElevationM);const e=new dh(this.groundRadius,48),t=new Ir({color:new Me(pl,pl,pl),fog:!0});this.groundMesh=new nt(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=sn(e.altitudeDeg,e.azimuthDeg,1);let n=1;const s=this.lowerCloudCover();s>0&&(n*=1-At.alphaAt(t,Math.abs(this.cloudLayerOffset()),s)*UM);const r=this.weather.highCloudCover??0;return r>0&&(n*=1-At.alphaAt(t,Ca,r)*FM),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<qc){this.bodyMeshes.delete(e),e==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:l}=sn(t.altitudeDeg,t.azimuthDeg,Ra),c=ki(t.altitudeDeg),h=this.cloudTransmission(t),u=new Me(s.r*c[0]*h,s.g*c[1]*h,s.b*c[2]*h),d=new Pn(n,16,16),f=new es({color:u,fog:!1}),g=new nt(d,f);g.position.set(a,o,l),this.celestialGroup.add(g),this.bodyMeshes.set(e,g),this.setHitArea(e,a,o,l,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,l,x,u),e==="sun"){this.sunVisible=!0;const m=this.celestialGroup.scale.x;this.sunWorldPosition.set(a*m,o*m+this.celestialGroup.position.y,l*m),this.lensFlare||(this.lensFlare=pM(),this.lensFlare.uniforms.uOpacity.value=JM,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(c)}}setMoonMesh(e,t){const n="moon";if(this.disposeMesh(this.bodyMeshes.get(n)),this.disposeHitArea(n),this.disposeGlare(n),e.magnitude>t||e.altitudeDeg<qc){this.bodyMeshes.delete(n);return}const{x:s,y:r,z:a}=sn(e.altitudeDeg,e.azimuthDeg,Ra),o=ki(e.altitudeDeg),l=new Me(o[0],o[1],o[2]),c=new pr({map:Ry(e.phase),color:l,fog:!1}),h=new ta(c);h.position.set(s,r,a);const u=ml*2;h.scale.set(u,u,1),this.celestialGroup.add(h),this.bodyMeshes.set(n,h),this.setHitArea(n,s,r,a,ml),this.setGlare(n,s,r,a,e.magnitude,l)}setHitArea(e,t,n,s,r){const a=new pr({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1}),o=new ta(a);o.position.set(t,n,s);const l=r*NM;o.scale.set(l,l,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=_x(r);if(o<=0){this.disposeGlare(e);return}const l=yx(o),c=this.glareSprites.get(e),h=c??new ta(new pr({map:Ty(),transparent:!0,blending:Di,depthWrite:!1,fog:!1}));h.material.color.copy(a),h.material.opacity=Ex(o),h.position.set(t,n,s),h.scale.set(l*2,l*2,1),c||(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=sl(e.magnitude),r=rl(s);this.cometKey=n,this.setBodyMesh(n,e.position,wd*(.5+.5*s),new Me(r,r,r),e.magnitude),this.cometTail||(this.cometTail=new cn(Ra),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(e.position,e.tailEnd,s)}buildIceHalos(e,t){this.iceHalos||(this.iceHalos=new zn,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:Ca},0);return}const s=this.weather.lowerCloudCover??this.weather.cloudCover,r=Ze.deckLitUntilDeg(Ze.DECK_HEIGHT_M),a=e.altitudeDeg>-r?e:t,o=Ze.strength(n,s,a.altitudeDeg,r)*(a===e?1:Td),{x:l,y:c,z:h}=sn(a.altitudeDeg,a.azimuthDeg,1),u=ki(a.altitudeDeg);this.iceHalos.update({x:l,y:c,z:h},a.altitudeDeg,o,[u[0],u[1],u[2]],{cover:n,layerHeight:Ca},this.weather.iceCrystalAlignment??ep)}buildRainbow(e,t){this.rainbow||(this.rainbow=new Sr,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=Td*nn.moonlightShare(t.magnitude),l=nn.strength(n,a,r.altitudeDeg)*(s?1:o);if(l<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:c,y:h,z:u}=sn(r.altitudeDeg,r.azimuthDeg,1),d=ki(r.altitudeDeg);this.rainbow.update({x:c,y:h,z:u},l,[d[0],d[1],d[2]],s)}disposeComet(){this.cometTail?.set(void 0,void 0,0),this.cometKey&&(this.disposeMesh(this.bodyMeshes.get(this.cometKey)),this.bodyMeshes.delete(this.cometKey),this.disposeHitArea(this.cometKey),this.disposeGlare(this.cometKey),this.cometKey=void 0)}buildPlanets(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=sl(s.magnitude),a=rl(r),o=vy[s.body]??new Me(1,1,1),l=new Me(o.r*a,o.g*a,o.b*a),c=wd*(.5+.5*r);this.setBodyMesh(s.body,s.position,c,l,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=Ml(1337),l=[];for(let c=0;c<n.count;c++){const h=n.mag[c];if(h>a)continue;const{altitudeDeg:u,azimuthDeg:d}=Cr(n.ra[c],n.dec[c],s,r);if(u<Ad)continue;const{x:f,y:g,z:x}=sn(u,d,Ed);l.push({x:f,y:g,z:x,brightness:sl(h),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}for(const c of I3){if(c.mag>a)continue;const{altitudeDeg:h,azimuthDeg:u}=Cr(c.raHours,c.decDeg,s,r);if(h<Ad)continue;const{x:d,y:f,z:g}=sn(h,u,Ed);this.namedStars.push({star:c,direction:new U(d,f,g).normalize(),altitudeDeg:h})}this.starTiers=q0.map((c,h)=>{const u=l.filter(M=>Rx(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 bt;m.setAttribute("position",new ct(d,3));const p=new ct(new Float32Array(u.length*3),3);m.setAttribute("color",p);const E=new D0({vertexColors:!0,size:c.size,sizeAttenuation:!1,fog:!1});Yi.apply(E);const A=new ka(m,E);return this.celestialGroup.add(A),{points:A,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=Px(t.brightness[s],{phase:t.phase[s],speedFactor:t.speedFactor[s]},e),a=rl(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(Gi[0]+(_l[0]-Gi[0])*t,Gi[1]+(_l[1]-Gi[1])*t,Gi[2]+(_l[2]-Gi[2])*t),{material:s,uniforms:r}=gd(n,e,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=s,this.cloudUniforms=r,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const a=vd(Pd);this.cloudMesh=new nt(a,s),this.cloudLayerOffset()<0&&(this.cloudMesh.scale.y=-1),this.cloudMesh.renderOrder=Id,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}=gd(new Me(...Gi),e,Ca,1);this.cirrusMaterial=t,this.cirrusUniforms=n,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new nt(vd(Pd*1.04),t),this.cirrusMesh.renderOrder=Id-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??jd)-this.observerElevationM)*jM;return Math.sign(t||1)*Math.max(Math.abs(t),ey)}updateCloudLighting(e,t){const n=[this.cloudUniforms,this.cirrusUniforms].filter(c=>c!==void 0);if(n.length===0)return;const{x:s,y:r,z:a}=sn(e.altitudeDeg,e.azimuthDeg,1),o=ki(e.altitudeDeg),l=Math.max(0,Math.sin(Math.max(e.altitudeDeg,0)*ln));for(const c of n)c.sunDir.value.set(s,r,a),c.sunColor.value.setRGB(o[0]*l,.96*o[1]*l,.88*o[2]*l),c.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=Ld[e],n=t.poolSize,s=Ml(9001),r=new Float32Array(n*3),a=new Float32Array(n),o=new Float32Array(n),l=new Float32Array(n),c=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 A=0;A<n;A++){const M=s()*Math.PI*2,S=s()*t.radiusM;r[A*3]=Math.cos(M)*S,r[A*3+1]=Ns+s()*(t.topYM-Ns),r[A*3+2]=Math.sin(M)*S,a[A]=s()*Math.PI*2,o[A]=.7+s()*.6,l[A]=.6+s()*.8,c[A]=.4+s()*1.2}const x=new bt;x.setAttribute("position",new ct(r,3)),x.setDrawRange(0,xl(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:xy(e)},uNearFocusDistance:{value:kd},uHazeDistance:{value:t.radiusM*Hd}},p=new It({uniforms:m,vertexShader:wy,fragmentShader:Ay,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const E=new ka(x,p);E.renderOrder=vl,this.scene.add(E),this.precipitationPoints=E,this.precipitationPositions=r,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=l,this.precipitationWobbleAmpJitter=c,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=Ld[n],r=this.weather.windDirectionDeg*ln,a=Math.sin(r)*this.weather.windSpeed*s.driftSensitivity,o=-Math.cos(r)*this.weather.windSpeed*s.driftSensitivity,l=this.precipitationPositions,c=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,E=n==="snow"&&u&&d,A=n==="hail"&&f&&g&&x&&m&&p;for(let M=0,S=0;M<l.length;M+=3,S++){if(A&&f[S]>0){if(f[S]-=t,f[S]<=0){const _=Math.random()*Math.PI*2,b=Math.sqrt(Math.random())*s.radiusM;l[M]=Math.cos(_)*b,l[M+1]=s.topYM,l[M+2]=Math.sin(_)*b,f[S]=0}else{const _=1-f[S]/x[S];l[M+1]=Ns+Math.sin(Math.PI*_)*g[S],l[M]=Pa(l[M]+(a+m[S])*t,s.radiusM),l[M+2]=Pa(l[M+2]+(o+p[S])*t,s.radiusM)}continue}let w=0,R=0;if(E){const _=uy*u[S],b=dy*d[S];w=Math.sin(e*_*Math.PI*2+c[S])*b,R=Math.sin(e*_*Math.PI*2+c[S]+Math.PI/2)*b}if(l[M]+=(a+w)*t,l[M+1]-=s.fallSpeedMPerS*h[S]*t,l[M+2]+=(o+R)*t,l[M]=Pa(l[M],s.radiusM),l[M+2]=Pa(l[M+2],s.radiusM),l[M+1]<Ns){if(A){g[S]=qd*(.2+Math.random()*1.6),x[S]=fy*(.5+Math.random()),f[S]=x[S];const D=Math.random()*Math.PI*2,C=py*(g[S]/qd);m[S]=Math.cos(D)*C,p[S]=Math.sin(D)*C,l[M+1]=Ns;continue}const _=Math.random()*Math.PI*2,b=Math.sqrt(Math.random())*s.radiusM;l[M]=Math.cos(_)*b,l[M+1]=s.topYM,l[M+2]=Math.sin(_)*b}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const e=Od(this.weather.precipitationIntensity);this.rainSystem=aM({count:Nd,radiusM:dr,heightM:ny,bottomYM:Ud,overallSpeed:iy,color:ry,opacity:.85,visibleCount:xl(Nd,this.weather.precipitationIntensity),speedStreak:ly(e),pixelSize:Vd,seed:9001,nearFocusDistanceM:kd,hazeDistanceM:dr*Hd,hazeColor:new Me(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=vl,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const e=Ml(4242),t=new Float32Array(Is*3),n=new Float32Array(Is),s=new Float32Array(Is),r=new Float32Array(Is);for(let h=0;h<Is;h++){const u=e()*Math.PI*2,d=Math.sqrt(e())*dr;t[h*3]=Math.cos(u)*d,t[h*3+1]=Ud,t[h*3+2]=Math.sin(u)*d,s[h]=Da(zd,Bd),n[h]=e()*s[h],r[h]=n[h]/s[h]}const a=new bt;a.setAttribute("position",new ct(t,3));const o=new ct(r,1);a.setAttribute("aLife",o),a.setDrawRange(0,xl(Is,this.weather.precipitationIntensity));const l=new It({uniforms:{uMaxSize:{value:cy},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:hy},uTexture:{value:Sy()}},vertexShader:by,fragmentShader:Ey,transparent:!0,depthWrite:!1}),c=new ka(a,l);c.renderOrder=vl,this.scene.add(c),this.rainSplashSystem={points:c,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*ln;e.uniforms.uDropVelocity.value.set(Math.sin(t)*this.weather.windSpeed,-Od(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*ln,s=Math.sin(n)*this.weather.windSpeed,r=-Math.cos(n)*this.weather.windSpeed,a=dr,o=c=>(c%(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 l=Math.abs(this.rainCameraDirection.y);if(Math.abs(l-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=l;const c=Wd+(1-Wd)*(1-l),h=Xd+(1-Xd)*(1-l);t.uniforms.uUvSquash.value=h,t.uniforms.uPixelSize.value=Vd*c*(.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 l=0,c=0;l<n.length;l+=3,c++){if(s[c]+=e,s[c]>=r[c]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*dr;n[l]=Math.cos(h)*u,n[l+2]=Math.sin(h)*u,r[c]=Da(zd,Bd),s[c]=0}o[c]=s[c]/r[c]}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+Da(Yd,Kd);return}e>=this.nextLightningAtS&&(this.lightningFlashRemainingS=$d,this.nextLightningAtS=e+Da(Yd,Kd),this.onLightningFlash?.())}}buildCompassLabels(){const e=co(navigator.languages,WM),t=VM[e];this.compassSprites=GM.map((n,s)=>{const r=t[s],a=new pr({map:Cy(r),depthTest:!1,fog:!1}),o=new ta(a),{x:l,y:c,z:h}=sn(0,n,XM);return o.position.set(l,c,h),o.scale.set(gl,gl,1),o.renderOrder=YM,o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o}),this.updateCompassScale()}updateCompassScale(){const e=this.camera.fov*Math.PI/360,t=qM*Math.PI/360,n=gl*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 ln=Math.PI/180;function If(i,e,t){return Math.max(e,Math.min(t,i))}function Da(i,e){return i+Math.random()*(e-i)}function Pa(i,e){return(i%(e*2)+e*3)%(e*2)-e}let Ia,La;function xy(i){switch(i){case"snow":return My();case"hail":return yy()}}function My(){if(Ia)return Ia;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),Ia=new li(e),Ia}function yy(){if(La)return La;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),La=new li(e),La}let Na;function Sy(){if(Na)return Na;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),Na=new li(e),Na}const by=`
5730
+ `,transparent:!0,blending:li,depthWrite:!1,side:Pt,fog:!1}),this.object=new Je(new Pn(wr.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:wr.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]=Ws.toHalfFloat(t[s]),this.texels[n+1]=Ws.toHalfFloat(t[s+1]),this.texels[n+2]=Ws.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 wf{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 es{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 wf(r),l=Math.floor(a),c=l+(o.next()<a-l?1:0),h=[];for(let u=0;u<c;u++){const d=Math.min(1,Math.max(0,(s-20)/52)),f=es.MAX_DURATION_MS-d*(es.MAX_DURATION_MS-es.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((_,m)=>_.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 zt{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=zt.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(zt.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=zt.MAX_CONCURRENT*zt.SEGMENTS*zt.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const t=new bt;t.setAttribute("position",new ct(this.positions,3)),t.setAttribute("color",new ct(this.colors,3)),t.setDrawRange(0,0),this.object=new Je(t,new is({vertexColors:!0,transparent:!0,blending:li,depthWrite:!1,fog:!1,side:Tn})),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=es.aliveAt(this.meteors,e).slice(0,zt.MAX_CONCURRENT);let s=0;for(const{meteor:r,progress:a}of n){const o=this.radiantOf(r);if(!o)continue;const l=rn(o.altitudeDeg,o.azimuthDeg,1),[c,h]=this.basisAround(l),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(c,h,r.bearingDeg),_=(.15+.85*r.brightness)*f,m=A=>_*A**1.6,p=A=>this.onSphere(l,g,d+(u-d)*A),E=A=>zt.RADIUS*((zt.MIN_HALF_WIDTH_DEG+zt.BRIGHT_HALF_WIDTH_DEG*r.brightness*A)*Math.PI/180);for(let A=1;A<zt.POINTS;A++){const M=(A-1)/zt.SEGMENTS,S=A/zt.SEGMENTS;s=this.pushRibbon(s,p(M),p(S),E(M),E(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=rn(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),l=Math.hypot(o.x,o.y,o.z)||1;return{altitudeDeg:Math.asin(o.y/l)*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 l=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(n,t))));for(let c=0;c<zt.ACROSS-1;c++){const h=c-1,u=c,d=this.across(t,l,s,h),f=this.across(n,l,r,h),g=this.across(t,l,s,u),_=this.across(n,l,r,u),m=(p,E)=>p===0?E: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,_,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)*zt.RADIUS,y:(e.y*r+t.y*a)*zt.RADIUS,z:(e.z*r+t.z*a)*zt.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 bd=Math.PI/180;function Yt(i,e,t,n,s=!1){const r=s?new is({color:new Me(...t)}):new Fr({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 Ed=.25,_M=.002,MM=20;function yM(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 Af=[.32,.32,.3],Tf=[1,.85,.5],Rf=[.25,.25,.25],Cf=[1,.97,.85],SM=[.55,.68,.72],kn=.03,Hn=.05,Df={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 Jt(i,e){return i?.[e]}function Gn(i,e,t,n,s,r,a,o){if(o===void 0)return;const l=new Fr({color:new Me(...SM),transparent:!0,opacity:o/100}),c=new Je(new bn(e,t,n),l);c.position.set(s,r,a),i.add(c)}const Mn=.05,pl=[.6,.58,.53],wd=[.5,.5,.48];function Bs(i,e,t,n,s,r,a,o){const l=new Fr({color:new Me(...o),side:Pt}),c=new Je(new bn(e,t,n),l);c.position.set(s,r,a),i.add(c)}function bM(i,e,t,n,s,r,a,o,l){const c=(n-r)/2,h=(g,_,m,p)=>{g<=0||(e?Bs(i,g,_,Mn,m,o+p,a,l):Bs(i,Mn,_,g,a,o+p,m,l))};h(t,c,0,n/2-c/2),h(t,c,0,-(n/2-c/2));const u=[...s].sort((g,_)=>g.center-_.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 Pf(i,e,t,n,s,r,a,o,l,c){const h=(n+s)/2,u=s-n,d=(f,g,_,m)=>{f.length===0?g?Bs(i,_,u,Mn,0,h,m,pl):Bs(i,Mn,u,_,m,h,0,pl):bM(i,g,_,u,f,r,m,h,pl)};d(a,!0,e*2,-t+Mn),d(o,!0,e*2,t-Mn),d(l,!1,t*2,-e+Mn),d(c,!1,t*2,e-Mn),Bs(i,e*2,Mn,t*2,0,n+Mn,0,wd),Bs(i,e*2,Mn,t*2,0,s-Mn,0,wd)}function qc(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:-Vn};case"front-right":return{x:e-n,z:-Vn};case"behind-left":return{x:-(e-n),z:Vn};case"behind-right":return{x:e-n,z:Vn}}}function If(i,e,t,n,s,r,a){const o=Uf();o.scale.setScalar(n),o.rotation.y=Df[e];const{x:l,z:c}=qc(e,s,r,a);o.position.set(l,t,c),i.add(o)}const Yc=6,Kc=6,Ei=3,fr=1.4,pr=Ei*.5,Lf=1.2,Nf=.35,EM=.75,wM=1.6;function AM(i,e,t,n){const s=new Cn,r=Math.max(1,i+1),a=r*Ei;Yt(s,new bn(Yc,a,Kc),[.55,.54,.5],a/2);const o=Yc/2,l=Kc/2;for(let c=0;c<r;c++){const h=c*Ei+Ei/2;Gn(s,fr,pr,Hn,0,h,-l-kn,Jt(e,"front")),Gn(s,fr,pr,Hn,0,h,l+kn,Jt(e,"behind")),Gn(s,Hn,pr,fr,-o-kn,h,0,Jt(e,"left")),Gn(s,Hn,pr,fr,o+kn,h,0,Jt(e,"right"))}if(t){const c=Math.min(Math.max(n??0,0),r-1);If(s,t,c*Ei,.72,o,l,Lf);const h=u=>Jt(e,u)!==void 0?[{main:fr,center:0}]:[];Pf(s,o,l,c*Ei,(c+1)*Ei,pr,h("front"),h("behind"),h("left"),h("right"))}return s}function TM(){const i=new Cn;return Yt(i,new Ni(.15,.22,2,8),[.32,.22,.14],1),Yt(i,new go(1.4,3,8),[.16,.32,.14],3.5),i}function RM(i){const e=new Cn;return Yt(e,new Ni(.05,.08,5,8),[.28,.28,.3],2.5),Yt(e,new Pn(.25,12,8),i?Tf:Af,5.1,!0),e}const CM=[.08,.08,.08],bi=.8,Us=1,On=1.7,ml=.6,Vi=.4,Ca=1.2,Is=.7,Vn=.5,DM=On;function PM(i,e,t){const n=new Cn;Yt(n,new bn(1.8,1.4,4.2),[.45,.14,.14],.7),Yt(n,new bn(bi*2,ml,Us*2),[.4,.12,.12],On);for(const r of[-1.4,1.4])for(const a of[-.95,.95]){const o=Yt(n,new Ni(.4,.4,.3,12),CM,.4);o.rotation.z=Math.PI/2,o.position.x=a,o.position.z=r}const s=i?Cf:Rf;for(const r of[-.7,.7])Yt(n,new Pn(.15,8,6),s,.7,!0).position.set(r,.7,-2.1);if(Gn(n,Ca,Vi,Hn,0,On,-Us-kn,Jt(e,"front")),Gn(n,Ca,Vi,Hn,0,On,Us+kn,Jt(e,"behind")),Gn(n,Hn,Vi,Is,-bi-kn,On,-Vn,Jt(e,"front-left")),Gn(n,Hn,Vi,Is,-bi-kn,On,Vn,Jt(e,"behind-left")),Gn(n,Hn,Vi,Is,bi+kn,On,-Vn,Jt(e,"front-right")),Gn(n,Hn,Vi,Is,bi+kn,On,Vn,Jt(e,"behind-right")),t){If(n,t,EM,.5,bi,Us,Nf);const r=(l,c)=>{const h=[];return Jt(e,l)!==void 0&&h.push({main:Is,center:-Vn}),Jt(e,c)!==void 0&&h.push({main:Is,center:Vn}),h},a=Jt(e,"front")!==void 0?[{main:Ca,center:0}]:[],o=Jt(e,"behind")!==void 0?[{main:Ca,center:0}]:[];Pf(n,bi,Us,On-ml/2,On+ml/2,Vi,a,o,r("front-left","behind-left"),r("front-right","behind-right"))}return n}const IM=[.95,.9,.82];function Uf(){const i=new Cn;Yt(i,new Ni(.25,.3,1.5,10),[.3,.3,.35],.75),Yt(i,new Pn(.22,10,8),[.62,.52,.46],1.72);const e=Yt(i,new go(.07,.16,8),IM,1.72);return e.rotation.x=-Math.PI/2,e.position.z=-.2,i}const LM=17,Ad=18.5,gl=[.16,.16,.18];function NM(){const i=new Cn,e=Yt(i,new Ni(1.8,1.8,Ad*2,10),gl,0);e.rotation.x=Math.PI/2,Yt(i,new bn(LM*2,.5,4.5),gl,0);const t=Yt(i,new bn(.4,5.5,4),gl,3);return t.position.z=-Ad+2,i}class Ls{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"?qc(t,bi,Us,Nf):qc(t,Yc/2,Kc/2,Lf),r=e.kind==="vehicle"?DM:(e.occupiedFloor??0)*Ei+wM,a=(e.headingDeg??0)-Df[t]/bd;return{x:n,z:s,eyeY:r,headingDeg:a}}static build(e,t){const n=e.kind==="building"?AM(e.floors??up,e.windows,e.witnessSide,e.occupiedFloor):e.kind==="tree"?TM():e.kind==="streetlight"?RM(t):e.kind==="vehicle"?PM(t,e.windows,e.witnessSide):e.kind==="aircraft"?NM():Uf();return e.headingDeg!==void 0&&(n.rotation.y=-e.headingDeg*bd),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=yM(n.color),r=Yt(e,new Pn(Ed,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(l=>[l.id,l])),o=Math.max(1,s*_M/Ed);for(const l of e.children){if(!(l instanceof Je))continue;const c=l.userData.lightId;if(!c)continue;const h=a.get(c);if(!h)continue;const u=r>0?c0(h,n,n+r):fp(h,n)?1:0;l.visible=u>0;const d=l.material,f=l.userData.lightColor;if(f){const g=r>0?u*MM*(h.intensity??1):u;d.color.setRGB(f[0]*g,f[1]*g,f[2]*g)}l.scale.setScalar(o)}}static setLit(e,t,n){const s=t==="streetlight"?n?Tf:Af:n?Cf:Rf;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 UM(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 Da=900,Td=.5,yr=900,FM=6371e3,OM=3e4;function Rd(i){const e=Math.sqrt(2*FM*Math.max(i,0));return Math.max(yr,Math.min(e,OM))}const vl=.5,Cd=850,zM=.03,Pa=850,xl=4,Dd=1.5,Pd=-1,BM=6,$c=-4,Id=.2,Ia=2600,kM=.97,HM=.38,Ld=$c,GM=3,VM=.15,WM=.6,XM=40,qM=30,YM=[0,45,90,135,180,225,270,315],KM={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},$M=["en","fr"],ZM=880,_l=40,JM=60,QM=10,jM=1,ey=150,ty=55,ny=.5,iy=2.05,Nd=.265,Ud=[[0,0],...Array.from({length:8},(i,e)=>{const t=e*Math.PI/4;return[Math.cos(t)*Nd,Math.sin(t)*Nd]})],Fd=700,sy=250/s0,ry=12,Od=5,Ml=6,Wi=[.92,.92,.95],yl=[.15,.15,.19],zd={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}},Fs=0,ay=0,Bd=3e3,mr=20,oy=15,kd=Fs,ly=40,Hd=1,cy=9;function Gd(i){return Hd+(cy-Hd)*i}const hy=new Me(.75,.82,.92),uy=10,dy=.5;function fy(i){return Ff(i/uy,dy,1)}const Ns=200,Vd=.18,Wd=.32,py=.35,my=new Me(.85,.9,.98),Xd=5,qd=.85,Yd=.01;function Sl(i,e){return Math.round(i*(Yd+(1-Yd)*e))}const Kd=230,$d=.7,Zd=.05,gy=.6,vy=.7,xy=.15,Jd=.35,_y=3,My=1/12,yy=.5,Qd=8,jd=25,e0=.12,Sy={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 Ah{renderer;scene=new po;camera;celestialGroup=new Cn;skyMesh;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;celestialLight=new lg(16777215,0);celestialLightTarget=new Ct;skyLight=new sg(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;raycaster=new jo;weather=r0;observerElevationM=0;groundRadius=yr;terrainRadius=yr;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new U;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 U;sunVisible=!1;lensFlareScratch=new U;sunOcclusionRaycaster=new jo;sunOcclusionDirectionScratch=new U;sunOcclusionRightScratch=new U;sunOcclusionUpScratch=new U;ufoOcclusionRaycaster=new jo;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;cometKey;onLightningFlash;constructor(e,t=K3(),n){this.renderer=new a_({canvas:e,antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=br,this.camera=new fn(60,e.width/Math.max(e.height,1),.1,Da*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)*hn;e.headingDeg!==void 0?this.camera.rotation.set(e.pitchDeg*hn,-e.headingDeg*hn,t,"YXZ"):this.camera.rotation.set(e.pitchDeg*hn,this.camera.rotation.y,t,"YXZ"),e.elevationM!==this.observerElevationM&&(this.observerElevationM=e.elevationM,this.syncCloudLayer(),Math.abs(Rd(e.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/yr),this.camera.far=Math.max(Da*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}=as(e,t,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(a*a+o*o)<ey*(s/yr))return}this.terrainOrigin={lat:e,lng:t},this.terrainRadius=s;const r=++this.terrainBuildToken;eM(e,t,this.terrainProviders,s).then(({mesh:a,attribution:o})=>{r===this.terrainBuildToken&&(this.disposeMesh(this.terrainMesh),a.renderOrder=jM,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=ty*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=D_(e)*this.sunCloudTransmission*this.sunUnhiddenFraction,n=Gi(e);this.lensFlare.uniforms.uDazzleColour.value.setRGB(n[0],n[1],n[2]),this.lensFlare.uniforms.uVeilStrength.value=iy**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){UM(this.weather,e)||(this.weather=e,this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lightningArmed=e.storm&&e.cloudDarkness>=yy,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(),Ls.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear();for(const t of e){const n=Ls.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?as(e.lat,e.lng,t.lat,t.lng):{x:0,z:0},r=this.decorObjects.find(c=>c.witnessSide!==void 0&&dp(c.kind)),a={x:0,z:0};let o=0;if(r){const c=Ls.occupantView(r),h=-(r.headingDeg??0)*hn,u=c.x*Math.cos(h)+c.z*Math.sin(h),d=-c.x*Math.sin(h)+c.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=c.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*hn,-(c.headingDeg+this.indoorLookYawDeg)*hn,0,"YXZ")}for(const c of this.decorObjects){const h=this.decorGroups.get(c.id);if(!h)continue;const u=Qc(c,n);h.position.set(u.eastM+s.x+a.x,ay+u.altitudeM,-u.northM+s.z+a.z),u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*hn),o=Math.max(o,h.position.distanceTo(this.camera.position))}const l=Math.max(Da*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-l)>1&&(this.camera.far=l,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&&Ls.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=l0(n,e);Ls.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 ag(16764006,XM,qM);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=Ac(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=sd(e.sun.altitudeDeg);this.setBodyMesh("sun",e.sun,xl,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.scene.fog=new uh(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=WM;const s=e.sun.altitudeDeg>=Ld,r=!s&&e.moon.altitudeDeg>=Ld;if(!s&&!r){this.celestialLight.intensity=0;return}const a=s?e.sun:e.moon,{x:o,y:l,z:c}=rn(a.altitudeDeg,a.azimuthDeg,Pa);this.celestialLight.position.set(o,l,c);const h=Gi(a.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const u=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*hn));this.celestialLight.intensity=(s?GM:VM)*u,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(e,t,n){this.meteorSystem||(this.meteorSystem=new zt,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=Ht.starPointsOf(e),n=Ht.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),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),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 o_(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()+Ah.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 Er(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(ao.supports(this.camera.fov,e.x/Math.max(e.y,1)))return this.equidistantPass?this.equidistantPass.resize(e.x,e.y):this.equidistantPass=new ao(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 Ud)this.isSunOccluded(t[0],t[1])||e++;return e/Ud.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,l=this.sunOcclusionRightScratch.set(s.z,0,-s.x);l.lengthSq()<1e-9&&l.set(1,0,0),l.normalize();const c=this.sunOcclusionUpScratch.crossVectors(l,s).normalize();s.addScaledVector(l,e*o).addScaledVector(c,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=Td,this.ufoOcclusionRaycaster.intersectObjects(r,!0).length>0)}decorDistancesAt(e,t,n){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),this.ufoOcclusionRaycaster.near=Td;let s,r;for(const a of this.decorObjects){const o=this.decorGroups.get(a.id);if(!o)continue;const l=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];l&&(a.occludesSourceIds?.includes(n)?s=s===void 0?l.distance:Math.max(s,l.distance):r=r===void 0?l.distance:Math.min(r,l.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)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(zM*this.camera.fov*Math.PI/180);let r,a=s;for(const o of this.namedStars){const l=o.direction.dot(n);l>a&&(a=l,r={star:o.star,altitudeDeg:o.altitudeDeg})}return r}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.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())Ls.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,My);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(Da,32,16),n=t.attributes.position,s=[];for(let a=0;a<n.count;a++){const{altitudeDeg:o,azimuthDeg:l}=u_(n.getX(a),n.getY(a),n.getZ(a)),c=__(o,l,e.azimuthDeg,e.altitudeDeg);s.push(c[0],c[1],c[2])}t.setAttribute("color",new It(s,3));const r=new is({vertexColors:!0,side:Pt,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=Rd(this.observerElevationM);const e=new mh(this.groundRadius,48),t=new Fr({color:new Me(vl,vl,vl),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=rn(e.altitudeDeg,e.azimuthDeg,1);let n=1;const s=this.lowerCloudCover();s>0&&(n*=1-Tt.alphaAt(t,Math.abs(this.cloudLayerOffset()),s)*kM);const r=this.weather.highCloudCover??0;return r>0&&(n*=1-Tt.alphaAt(t,Ia,r)*HM),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<$c){this.bodyMeshes.delete(e),e==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:l}=rn(t.altitudeDeg,t.azimuthDeg,Pa),c=Gi(t.altitudeDeg),h=this.cloudTransmission(t),u=new Me(s.r*c[0]*h,s.g*c[1]*h,s.b*c[2]*h),d=new Pn(n,16,16),f=new is({color:u,fog:!1}),g=new Je(d,f);g.position.set(a,o,l),this.celestialGroup.add(g),this.bodyMeshes.set(e,g),this.setHitArea(e,a,o,l,n);const _=r-2.5*Math.log10(Math.max(h,.001));if(e==="sun"&&(this.sunCloudTransmission=h),e!=="sun"&&this.setGlare(e,a,o,l,_,u),e==="sun"){this.sunVisible=!0;const m=this.celestialGroup.scale.x;this.sunWorldPosition.set(a*m,o*m+this.celestialGroup.position.y,l*m),this.lensFlare||(this.lensFlare=xM(),this.lensFlare.uniforms.uOpacity.value=ny,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(c)}}setMoonMesh(e,t){const n="moon";if(this.disposeMesh(this.bodyMeshes.get(n)),this.disposeHitArea(n),this.disposeGlare(n),e.magnitude>t||e.altitudeDeg<$c){this.bodyMeshes.delete(n);return}const{x:s,y:r,z:a}=rn(e.altitudeDeg,e.azimuthDeg,Pa),o=Gi(e.altitudeDeg),l=new Me(o[0],o[1],o[2]),c=new vr({map:Iy(e.phase),color:l,fog:!1}),h=new sa(c);h.position.set(s,r,a);const u=xl*2;h.scale.set(u,u,1),this.celestialGroup.add(h),this.bodyMeshes.set(n,h),this.setHitArea(n,s,r,a,xl),this.setGlare(n,s,r,a,e.magnitude,l)}setHitArea(e,t,n,s,r){const a=new vr({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1}),o=new sa(a);o.position.set(t,n,s);const l=r*BM;o.scale.set(l,l,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=S_(r);if(o<=0){this.disposeGlare(e);return}const l=w_(o),c=this.glareSprites.get(e),h=c??new sa(new vr({map:Py(),transparent:!0,blending:li,depthWrite:!1,fog:!1}));h.material.color.copy(a),h.material.opacity=R_(o),h.position.set(t,n,s),h.scale.set(l*2,l*2,1),c||(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=ol(e.magnitude),r=ll(s);this.cometKey=n,this.setBodyMesh(n,e.position,Dd*(.5+.5*s),new Me(r,r,r),e.magnitude),this.cometTail||(this.cometTail=new un(Pa),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(e.position,e.tailEnd,s)}buildIceHalos(e,t){this.iceHalos||(this.iceHalos=new zn,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:Ia},0);return}const s=this.weather.lowerCloudCover??this.weather.cloudCover,r=Ze.deckLitUntilDeg(Ze.DECK_HEIGHT_M),a=e.altitudeDeg>-r?e:t,o=Ze.strength(n,s,a.altitudeDeg,r)*(a===e?1:Id),{x:l,y:c,z:h}=rn(a.altitudeDeg,a.azimuthDeg,1),u=Gi(a.altitudeDeg);this.iceHalos.update({x:l,y:c,z:h},a.altitudeDeg,o,[u[0],u[1],u[2]],{cover:n,layerHeight:Ia},this.weather.iceCrystalAlignment??sp)}buildRainbow(e,t){this.rainbow||(this.rainbow=new wr,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=Id*sn.moonlightShare(t.magnitude),l=sn.strength(n,a,r.altitudeDeg)*(s?1:o);if(l<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:c,y:h,z:u}=rn(r.altitudeDeg,r.azimuthDeg,1),d=Gi(r.altitudeDeg);this.rainbow.update({x:c,y:h,z:u},l,[d[0],d[1],d[2]],s)}disposeComet(){this.cometTail?.set(void 0,void 0,0),this.cometKey&&(this.disposeMesh(this.bodyMeshes.get(this.cometKey)),this.bodyMeshes.delete(this.cometKey),this.disposeHitArea(this.cometKey),this.disposeGlare(this.cometKey),this.cometKey=void 0)}buildPlanets(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=ol(s.magnitude),a=ll(r),o=Sy[s.body]??new Me(1,1,1),l=new Me(o.r*a,o.g*a,o.b*a),c=Dd*(.5+.5*r);this.setBodyMesh(s.body,s.position,c,l,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=sd(t),o=bl(1337),l=[];for(let c=0;c<n.count;c++){const h=n.mag[c];if(h>a)continue;const{altitudeDeg:u,azimuthDeg:d}=Lr(n.ra[c],n.dec[c],s,r);if(u<Pd)continue;const{x:f,y:g,z:_}=rn(u,d,Cd);l.push({x:f,y:g,z:_,brightness:ol(h),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}for(const c of F3){if(c.mag>a)continue;const{altitudeDeg:h,azimuthDeg:u}=Lr(c.raHours,c.decDeg,s,r);if(h<Pd)continue;const{x:d,y:f,z:g}=rn(h,u,Cd);this.namedStars.push({star:c,direction:new U(d,f,g).normalize(),altitudeDeg:h})}this.starTiers=J0.map((c,h)=>{const u=l.filter(M=>I_(M.brightness)===h),d=new Float32Array(u.length*3),f=new Float32Array(u.length),g=new Float32Array(u.length),_=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,_[S]=M.speedFactor});const m=new bt;m.setAttribute("position",new ct(d,3));const p=new ct(new Float32Array(u.length*3),3);m.setAttribute("color",p);const E=new U0({vertexColors:!0,size:c.size,sizeAttenuation:!1,fog:!1});Zi.apply(E);const A=new Va(m,E);return this.celestialGroup.add(A),{points:A,colorAttribute:p,brightness:f,phase:g,speedFactor:_}}),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=U_(t.brightness[s],{phase:t.phase[s],speedFactor:t.speedFactor[s]},e),a=ll(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(Wi[0]+(yl[0]-Wi[0])*t,Wi[1]+(yl[1]-Wi[1])*t,Wi[2]+(yl[2]-Wi[2])*t),{material:s,uniforms:r}=yd(n,e,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=s,this.cloudUniforms=r,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const a=Sd(Fd);this.cloudMesh=new Je(a,s),this.cloudLayerOffset()<0&&(this.cloudMesh.scale.y=-1),this.cloudMesh.renderOrder=Od,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}=yd(new Me(...Wi),e,Ia,1);this.cirrusMaterial=t,this.cirrusUniforms=n,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new Je(Sd(Fd*1.04),t),this.cirrusMesh.renderOrder=Od-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??s0)-this.observerElevationM)*sy;return Math.sign(t||1)*Math.max(Math.abs(t),ry)}updateCloudLighting(e,t){const n=[this.cloudUniforms,this.cirrusUniforms].filter(c=>c!==void 0);if(n.length===0)return;const{x:s,y:r,z:a}=rn(e.altitudeDeg,e.azimuthDeg,1),o=Gi(e.altitudeDeg),l=Math.max(0,Math.sin(Math.max(e.altitudeDeg,0)*hn));for(const c of n)c.sunDir.value.set(s,r,a),c.sunColor.value.setRGB(o[0]*l,.96*o[1]*l,.88*o[2]*l),c.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=zd[e],n=t.poolSize,s=bl(9001),r=new Float32Array(n*3),a=new Float32Array(n),o=new Float32Array(n),l=new Float32Array(n),c=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 A=0;A<n;A++){const M=s()*Math.PI*2,S=s()*t.radiusM;r[A*3]=Math.cos(M)*S,r[A*3+1]=Fs+s()*(t.topYM-Fs),r[A*3+2]=Math.sin(M)*S,a[A]=s()*Math.PI*2,o[A]=.7+s()*.6,l[A]=.6+s()*.8,c[A]=.4+s()*1.2}const _=new bt;_.setAttribute("position",new ct(r,3)),_.setDrawRange(0,Sl(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:by(e)},uNearFocusDistance:{value:Xd},uHazeDistance:{value:t.radiusM*qd}},p=new Et({uniforms:m,vertexShader:Cy,fragmentShader:Dy,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const E=new Va(_,p);E.renderOrder=Ml,this.scene.add(E),this.precipitationPoints=E,this.precipitationPositions=r,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=l,this.precipitationWobbleAmpJitter=c,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=zd[n],r=this.weather.windDirectionDeg*hn,a=Math.sin(r)*this.weather.windSpeed*s.driftSensitivity,o=-Math.cos(r)*this.weather.windSpeed*s.driftSensitivity,l=this.precipitationPositions,c=this.precipitationPhase,h=this.precipitationSpeedJitter,u=this.precipitationWobbleFreqJitter,d=this.precipitationWobbleAmpJitter,f=this.precipitationBounceRemaining,g=this.precipitationBounceHeight,_=this.precipitationBounceDuration,m=this.precipitationBounceVelX,p=this.precipitationBounceVelZ,E=n==="snow"&&u&&d,A=n==="hail"&&f&&g&&_&&m&&p;for(let M=0,S=0;M<l.length;M+=3,S++){if(A&&f[S]>0){if(f[S]-=t,f[S]<=0){const x=Math.random()*Math.PI*2,b=Math.sqrt(Math.random())*s.radiusM;l[M]=Math.cos(x)*b,l[M+1]=s.topYM,l[M+2]=Math.sin(x)*b,f[S]=0}else{const x=1-f[S]/_[S];l[M+1]=Fs+Math.sin(Math.PI*x)*g[S],l[M]=Na(l[M]+(a+m[S])*t,s.radiusM),l[M+2]=Na(l[M+2]+(o+p[S])*t,s.radiusM)}continue}let w=0,R=0;if(E){const x=gy*u[S],b=vy*d[S];w=Math.sin(e*x*Math.PI*2+c[S])*b,R=Math.sin(e*x*Math.PI*2+c[S]+Math.PI/2)*b}if(l[M]+=(a+w)*t,l[M+1]-=s.fallSpeedMPerS*h[S]*t,l[M+2]+=(o+R)*t,l[M]=Na(l[M],s.radiusM),l[M+2]=Na(l[M+2],s.radiusM),l[M+1]<Fs){if(A){g[S]=Jd*(.2+Math.random()*1.6),_[S]=xy*(.5+Math.random()),f[S]=_[S];const D=Math.random()*Math.PI*2,C=_y*(g[S]/Jd);m[S]=Math.cos(D)*C,p[S]=Math.sin(D)*C,l[M+1]=Fs;continue}const x=Math.random()*Math.PI*2,b=Math.sqrt(Math.random())*s.radiusM;l[M]=Math.cos(x)*b,l[M+1]=s.topYM,l[M+2]=Math.sin(x)*b}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const e=Gd(this.weather.precipitationIntensity);this.rainSystem=hM({count:Bd,radiusM:mr,heightM:oy,bottomYM:kd,overallSpeed:ly,color:hy,opacity:.85,visibleCount:Sl(Bd,this.weather.precipitationIntensity),speedStreak:fy(e),pixelSize:Kd,seed:9001,nearFocusDistanceM:Xd,hazeDistanceM:mr*qd,hazeColor:new Me(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=Ml,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const e=bl(4242),t=new Float32Array(Ns*3),n=new Float32Array(Ns),s=new Float32Array(Ns),r=new Float32Array(Ns);for(let h=0;h<Ns;h++){const u=e()*Math.PI*2,d=Math.sqrt(e())*mr;t[h*3]=Math.cos(u)*d,t[h*3+1]=kd,t[h*3+2]=Math.sin(u)*d,s[h]=La(Vd,Wd),n[h]=e()*s[h],r[h]=n[h]/s[h]}const a=new bt;a.setAttribute("position",new ct(t,3));const o=new ct(r,1);a.setAttribute("aLife",o),a.setDrawRange(0,Sl(Ns,this.weather.precipitationIntensity));const l=new Et({uniforms:{uMaxSize:{value:py},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:my},uTexture:{value:Ay()}},vertexShader:Ty,fragmentShader:Ry,transparent:!0,depthWrite:!1}),c=new Va(a,l);c.renderOrder=Ml,this.scene.add(c),this.rainSplashSystem={points:c,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*hn;e.uniforms.uDropVelocity.value.set(Math.sin(t)*this.weather.windSpeed,-Gd(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*hn,s=Math.sin(n)*this.weather.windSpeed,r=-Math.cos(n)*this.weather.windSpeed,a=mr,o=c=>(c%(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 l=Math.abs(this.rainCameraDirection.y);if(Math.abs(l-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=l;const c=$d+(1-$d)*(1-l),h=Zd+(1-Zd)*(1-l);t.uniforms.uUvSquash.value=h,t.uniforms.uPixelSize.value=Kd*c*(.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 l=0,c=0;l<n.length;l+=3,c++){if(s[c]+=e,s[c]>=r[c]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*mr;n[l]=Math.cos(h)*u,n[l+2]=Math.sin(h)*u,r[c]=La(Vd,Wd),s[c]=0}o[c]=s[c]/r[c]}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/e0;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+La(Qd,jd);return}e>=this.nextLightningAtS&&(this.lightningFlashRemainingS=e0,this.nextLightningAtS=e+La(Qd,jd),this.onLightningFlash?.())}}buildCompassLabels(){const e=uo(navigator.languages,$M),t=KM[e];this.compassSprites=YM.map((n,s)=>{const r=t[s],a=new vr({map:Ly(r),depthTest:!1,fog:!1}),o=new sa(a),{x:l,y:c,z:h}=rn(0,n,ZM);return o.position.set(l,c,h),o.scale.set(_l,_l,1),o.renderOrder=QM,o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o}),this.updateCompassScale()}updateCompassScale(){const e=this.camera.fov*Math.PI/360,t=JM*Math.PI/360,n=_l*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 hn=Math.PI/180;function Ff(i,e,t){return Math.max(e,Math.min(t,i))}function La(i,e){return i+Math.random()*(e-i)}function Na(i,e){return(i%(e*2)+e*3)%(e*2)-e}let Ua,Fa;function by(i){switch(i){case"snow":return Ey();case"hail":return wy()}}function Ey(){if(Ua)return Ua;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),Ua=new hi(e),Ua}function wy(){if(Fa)return Fa;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),Fa=new hi(e),Fa}let Oa;function Ay(){if(Oa)return Oa;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),Oa=new hi(e),Oa}const Ty=`
5699
5731
  uniform float uMaxSize;
5700
5732
  uniform float uScale;
5701
5733
  attribute float aLife;
@@ -5708,7 +5740,7 @@ void main() {
5708
5740
  vOpacity = 1.0 - aLife;
5709
5741
  gl_Position = projectionMatrix * mvPosition;
5710
5742
  }
5711
- `,Ey=`
5743
+ `,Ry=`
5712
5744
  uniform vec3 uColor;
5713
5745
  uniform sampler2D uTexture;
5714
5746
  varying float vOpacity;
@@ -5719,7 +5751,7 @@ void main() {
5719
5751
  if (alpha < 0.01) discard;
5720
5752
  gl_FragColor = vec4(uColor, alpha);
5721
5753
  }
5722
- `,wy=`
5754
+ `,Cy=`
5723
5755
  uniform float uSize;
5724
5756
  uniform float uScale;
5725
5757
  uniform float uNearFocusDistance;
@@ -5745,7 +5777,7 @@ void main() {
5745
5777
  gl_PointSize = max(1.0, uSize * uScale / dist + vNearBlur * 12.0);
5746
5778
  gl_Position = projectionMatrix * mvPosition;
5747
5779
  }
5748
- `,Ay=`
5780
+ `,Dy=`
5749
5781
  precision mediump float;
5750
5782
  uniform sampler2D uTexture;
5751
5783
  uniform vec3 uColor;
@@ -5760,5 +5792,5 @@ void main() {
5760
5792
  float blur = max(vNearBlur, vHaze);
5761
5793
  gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * 0.5));
5762
5794
  }
5763
- `;let Ua;function Ty(){if(Ua)return Ua;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),Ua=new li(e),Ua}function Ry(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",l="#f4f1e2";n.fillStyle=o,n.beginPath(),n.arc(r,a,s,0,Math.PI*2),n.fill();const c=If(i.illuminatedFraction,0,1),h=i.phaseFraction<.5,u=s*Math.abs(1-2*c),d=c<.5;return n.save(),n.beginPath(),n.arc(r,a,s,0,Math.PI*2),n.clip(),n.fillStyle=l,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 li(t)}function Cy(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 li(e)}function Ml(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 Zd=new Map;function Dy(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 Py(i){let e=Zd.get(i);return e||(e=fetch(i).then(t=>t.arrayBuffer()).then(Dy),Zd.set(i,e)),e}const Iy=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,Ly=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,Ny=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,Uy=20,Fy=1;class Oy{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(Iy,this.ambientVolume).then(o=>this.applyIfCurrent(o,a,()=>this.ambientToken,l=>{this.ambientSource=l?.source,this.ambientGain=l?.gain,l&&(l.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(n/Uy,1);const r=n>Fy;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(Ly,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,l=>{this.windSource=l?.source,this.windGain=l?.gain,l&&(l.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(Ny,.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 ii{constructor(e){this.elements=e;const{eccentricity:t,perihelionAu:n}=e,[s,r]=this.perifocalAxes(),a=Math.sqrt(ii.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*ii.stumpffC(s),o=t-n*n*n/Math.sqrt(ii.SUN_GM_AU3_PER_DAY2)*ii.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(ii.SUN_GM_AU3_PER_DAY2)*Math.abs(e),s=o=>{const l=this.inverseSemiMajorAxis*o*o,c=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*c)*o*o*o*ii.stumpffS(l)+c*o};let r=Math.max(1,n/this.elements.perihelionAu);for(;s(r)<n;)r*=2;let a=0;for(let o=0;o<ii.MAX_ITERATIONS&&r-a>1e-13*Math.max(1,r);o++){const l=(a+r)/2;s(l)<n?a=l:r=l}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),l=Math.cos(n),c=Math.sin(n);return[{x:s*a-r*o*l,y:r*a+s*o*l,z:o*c},{x:-s*o-r*a*l,y:-r*o+s*a*l,z:a*c}]}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 Lf=[{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 zy{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 Lf.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=Ut(t),r=this.earthPositionAt(s),a=this.apparentPositionOf(e,2451545+s.tt,r),o=this.subtract(a,r),l=this.length(a),c=this.length(o),h=this.tailEndAt(e,a,r,l,s,t,n),u=this.horizontalOf(o,s,t,n);return{apparition:e,position:u,...h,heliocentricDistanceAu:l,earthDistanceAu:c,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},r)),magnitude:this.magnitudeAt(e,l,c)}}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 l=1+e.tailLengthAu/s,c=this.subtract({x:t.x*l,y:t.y*l,z:t.z*l},n),h=this.subtract(t,n);return{tailEnd:this.horizontalOf(c,r,a,o),tailLengthDeg:this.angleBetween(h,c)}}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=Va(E3(),new ut(e.x,e.y,e.z,t)),a=Va(w3(t),r),o=t3(t,new yh(s.lat,s.lng,s.elevationM)),l=new ut(a.x-o.x,a.y-o.y,a.z-o.z,t),c=df(l);return Cr(c.ra,c.dec,n,s)}static earthPositionAt(e){return Va(b3(),Ri(Se.Earth,e))}static julianDayOf(e){return 2451545+Ut(e).tt}static orbitOf(e){const t=this.orbits.get(e.id);if(t)return t;const n=new ii(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 By=[{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}],ao=6.5;class yl{static activeAt(e){return By.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),l=this.wrappedDelta(r,s),c=this.wrappedDelta(a,r);return o<0?o<-l?0:1+o/l:o>0?o>c?0:1-o/c:1}static observedRatePerHour(e,t,n,s=ao){if(t<=0)return 0;const r=ao-s;return e*Math.sin(t*Math.PI/180)/Math.pow(n,r)}static radiantPosition(e,t,n){return Cr(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 xt{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(e,t){const n=Ut(e),s=new xh(0,jx(e).elon-90,1),r=Va(A3(n),uf(s,n)),a=df(r);return Cr(a.ra,a.dec,e,t)}static observedRatePerHour(e,t=ao){const n=xt.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(e*Math.PI/180)),s=ao-t;return(xt.QUIET_RATE_PER_HOUR+n)/Math.pow(xt.POPULATION_INDEX,s)}static schedule(e){const t=new yf(e.seed^1542469173);return Ji.schedule(e).map(n=>{const s=xt.toCartesian({altitudeDeg:Math.asin(t.next())*180/Math.PI,azimuthDeg:t.between(0,360)}),r=n.fromRadiantDeg*Math.PI/180,a=xt.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:xt.toHorizontal(o),bearingDeg:xt.bearingFrom(o,s)}})}static turnAround(e,t){const[n,s]=xt.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]=xt.basisAround(e),r=e.x*t.x+e.y*t.y+e.z*t.z,a=xt.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=xt.normalise(xt.cross(e,t));return[n,xt.normalise(xt.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=xt.toCartesian(e.radiant??{altitudeDeg:90,azimuthDeg:0}),n=xt.turnAround(t,e.bearingDeg),s=e.fromRadiantDeg*Math.PI/180;return xt.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 ky{lowerM;upperM;add(e,t){if(!(e<=0)){if(t.behindM!==void 0){const n=qt.sizeMAt(t.behindM,e);this.lowerM=this.lowerM===void 0?n:Math.max(this.lowerM,n)}if(t.inFrontM!==void 0){const n=qt.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:qt.distanceMAt(this.lowerM,e),maxM:this.upperM===void 0?void 0:qt.distanceMAt(this.upperM,e)}}clear(){this.lowerM=void 0,this.upperM=void 0}}l0();const Hy={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"}},Gy=["en","fr"],Vy={en:"{name} — mag {mag}, {alt}° above the horizon",fr:"{name} — mag {mag}, {alt}° au-dessus de l'horizon"},Jd="comet:",Wy={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"}},Xy=new URL(""+new URL("stars-mag7.5-DDr9QasD.bin",import.meta.url).href,import.meta.url).href,qy={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},Sl={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class Yy 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 Oy;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),l=co(navigator.languages,Gy),c=this.sceneRenderer.pickBodyAt(a,o);if(c){this.showHoverTooltip(e,this.bodyName(c,l));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||Wy[u.kind][l]);return}const d=this.sceneRenderer.pickStarAt(a,o);if(d){const f=d.star.mag;this.showHoverTooltip(e,Vy[l].replace("{name}",d.star.name[l]).replace("{mag}",f.toLocaleString(void 0,{maximumFractionDigits:Math.abs(f)<1?2:1})).replace("{alt}",String(Math.round(d.altitudeDeg))));return}this.hoverTooltip.hidden=!0};bodyName(e,t){const n=e.startsWith(Jd)?e.slice(Jd.length):void 0;return(n?Lf.find(r=>r.id===n):void 0)?.name[t]??Hy[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(wl(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>${pp}</style>${fp}`,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 _y(this.sceneCanvas,void 0,this.handleLightningFlash),this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(Tl),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){const t=await fetch(e);this.sightingData=await t.json()}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=qt.CANVAS_HEIGHT_PX,n=Ht.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")??Xy;this.starCatalog=await Py(e),this.updateAstronomy(this.lastTimeMs)}updateAstronomy(e){const t=this.ufoElement.sighting;this.setWeather(wl(t,e)),this.sceneRenderer.setInstrument(t.instrument),this.updateMeteorShower(t,e),this.sceneRenderer.setDecor(t.decor);const n=Ai(t,e);this.sceneRenderer.setObserverPose(n??Sl),this.sceneRenderer.setLensOptics(this.lensOpticsAt(e)),this.sceneRenderer.updateDecorAnchoring(Ai(t,0),n,e),this.sceneRenderer.updateDecorLitState(e),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng);const s=n?.lat??Sl.lat,r=n?.lng??Sl.lng,a=Gc(t.event.time??{},r,t.event.utcOffsetHours);if(!a){this.sceneRenderer.setAstronomy(qy);return}const o=new Date(a.getTime()+e),l={lat:s,lng:r,elevationM:n?.elevationM??0},c={...ll("Sun",o,l),magnitude:cl("Sun",o)},h={...ll("Moon",o,l),phase:R3(o),magnitude:cl("Moon",o)},u=T3.map(d=>({body:d,position:ll(d,o,l),magnitude:cl(d,o)}));this.sceneRenderer.setAstronomy({sun:c,moon:h,planets:u,comet:this.cometAt(o,l),stars:this.starCatalog?{catalog:this.starCatalog,date:o,observer:l}:void 0})}cometAt(e,t){const n=zy.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 l=(o.bounds.x+o.bounds.width/2)/s.width*2-1,c=-((o.bounds.y+o.bounds.height/2)/s.height*2-1);this.sceneRenderer.isScreenPointOccluded(l,c,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(l,c,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?Gc(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),l=xt.schedule({ratePerHour:xt.observedRatePerHour(xt.apexPosition(s,r).altitudeDeg),durationMs:a,velocityKmS:xt.TYPICAL_VELOCITY_KM_S,seed:o}),c=yl.activeAt(s).map(u=>{const d=yl.radiantPosition(u.shower,s,r);return{entry:u,position:d,rate:yl.observedRatePerHour(u.zhr,d.altitudeDeg,u.shower.populationIndex)}}).sort((u,d)=>d.rate-u.rate)[0];if(!c||c.rate<=0){this.sceneRenderer.setMeteorShower(l,0,0);return}const h=Ji.schedule({ratePerHour:c.rate,durationMs:a,velocityKmS:c.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...l],c.position.altitudeDeg,c.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=Ai(t,e),a=r?.fNumber??n.fNumber;if(!s||a===void 0)return;const o=Ht.focalLengthMmFor(n,Wa.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 zs.of(t.instrument,qt.CANVAS_HEIGHT_PX,Wa.fovOf(t,e))}sizeEstimateOf(e){let t=this.sizeEstimates.get(e);return t||(t=new ky,this.sizeEstimates.set(e,t)),t}}const Yc="rr0-scene";function Nf(){l0(),customElements.get(Yc)||customElements.define(Yc,Yy)}const Ky={color:"Color",transparency:"Transparency",halo:"Halo",blur:"Blur",brightness:"Brilliance",shapeTitle:"Name",utcOffset:"Time zone",cloudBase:"Cloud base",elevation:"Altitude",heightAboveGround:"Height above ground",duration:"Duration",placeName:"Place",latitude:"Latitude",longitude:"Longitude",heading:"Heading",pitch:"Tilt",roll:"Roll",observationTime:"Observation start",observationEndTime:"Observation end",witnessId:"Witness ID",witnessTitle:"Witness title",witnessLastName:"Witness last name",witnessFirstNames:"Witness first names",caseId:"Case ID",tags:"Tags",cloudCover:"Cloud cover",highCloudCover:"Ice cloud (cirrus)",focalLength:"Focal length",fieldOfView:"Field of view",aperture:"Aperture",exposure:"Exposure",focusDistance:"Focused at",iceCrystalAlignment:"Crystal alignment",cloudDarkness:"Cloud darkness",precipitationType:"Precipitation",precipitationNone:"None",precipitationRain:"Rain",precipitationSnow:"Snow",precipitationHail:"Hail",precipitationIntensity:"Intensity",windDirection:"Wind direction",windSpeed:"Wind speed",storm:"Storm",soundKind:"Sound",soundNone:"None (silent)",soundHum:"Hum",soundWhistle:"Whistle",soundRumble:"Rumble",soundCrackle:"Crackle",soundVolume:"Loudness",soundPitch:"Pitch",soundSrc:"Recording",instrument:"Observed through",decorAircraft:"Aircraft",decorAltitude:"Altitude",decorLights:"Lights",decorLightsNone:"none",decor:"Decor",decorBuilding:"Building",decorTree:"Tree",decorStreetlight:"Streetlight",decorVehicle:"Vehicle",decorWitness:"Other witness",decorEast:"Distance east",decorNorth:"Distance north",decorHeading:"Heading",decorLit:"Lit",decorTitle:"Name",decorFloors:"Floors",decorOccupiedFloor:"Occupied floor",decorWitnessSide:"Witness location",decorWitnessSideNone:"Not present",decorWindows:"Windows",decorSideFront:"Front",decorSideBehind:"Behind",decorSideLeft:"Left",decorSideRight:"Right",decorSideFrontLeft:"Front-left",decorSideFrontRight:"Front-right",decorSideBehindLeft:"Behind-left",decorSideBehindRight:"Behind-right"},Kc={...Ky,testimonyBy:"Testimony by",about:"About",close:"Close",observation:"Observation",date:"Date",location:"Location",case:"Case",description:"Description",credits:"Credits",editThisObservation:"Edit this observation",embed:"Embed",embedReplay:"Replay",embedEdit:"Editor",embedCopy:"Copy",embedCopied:"Copied",showLabels:"Show what it states",hideLabels:"Hide what it states"},$y=Object.freeze(Object.defineProperty({__proto__:null,eyewitnessMessages_en:Kc},Symbol.toStringTag,{value:"Module"}));Nf();const Zy="“Thunder” by Jerimee",Jy="https://creativecommons.org/licenses/by/3.0/",Qy="CC BY 3.0",bl="https://ufoathome.org";class jy extends HTMLElement{static get observedAttributes(){return["src","show-labels"]}shadow;sceneElement;toolbarElement;testimonyPrefix;witnessText;witnessSelect;infoButton;infoPanel;infoAppLink;infoObservationHeading;infoObservationList;infoCreditsToggle;infoCreditsList;infoCloseButton;infoEmbedToggle;infoEmbedPanel;embedReplayRadio;embedEditRadio;labelEmbedReplay;labelEmbedEdit;embedMarkup;embedCopyButton;labelsToggle;paramSummary;summaryBuilder=new zh(Kc,"en");summarySignature="";supportsPopover=typeof HTMLElement.prototype.showPopover=="function";entries=[];currentSrc;infoOpen=!1;creditsOpen=!1;embedOpen=!1;labelsShown=!1;language="en";messages=Kc;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.sceneElement=document.createElement(Yc),this.shadow.getElementById("ufo-slot").replaceWith(this.sceneElement),this.toolbarElement=this.shadow.getElementById("toolbar"),this.testimonyPrefix=this.shadow.getElementById("testimony-prefix"),this.witnessText=this.shadow.getElementById("witness-text"),this.witnessSelect=this.shadow.getElementById("witness"),this.infoButton=this.shadow.getElementById("info-button"),this.infoPanel=this.shadow.getElementById("info-panel"),this.infoAppLink=this.shadow.getElementById("info-app-link"),this.infoObservationHeading=this.shadow.getElementById("info-observation-heading"),this.infoObservationList=this.shadow.getElementById("info-observation-list"),this.infoCreditsToggle=this.shadow.getElementById("info-credits-toggle"),this.infoCreditsList=this.shadow.getElementById("info-credits-list"),this.infoCloseButton=this.shadow.getElementById("info-close"),this.labelsToggle=this.shadow.getElementById("info-labels-toggle"),this.paramSummary=this.shadow.getElementById("param-summary"),this.labelsToggle.addEventListener("click",()=>{this.showLabels=!this.showLabels}),this.infoEmbedToggle=this.shadow.getElementById("info-embed-toggle"),this.infoEmbedPanel=this.shadow.getElementById("info-embed"),this.embedReplayRadio=this.shadow.getElementById("embed-kind-replay"),this.embedEditRadio=this.shadow.getElementById("embed-kind-edit"),this.labelEmbedReplay=this.shadow.getElementById("label-embed-replay"),this.labelEmbedEdit=this.shadow.getElementById("label-embed-edit"),this.embedMarkup=this.shadow.getElementById("embed-markup"),this.embedCopyButton=this.shadow.getElementById("embed-copy"),this.witnessSelect.addEventListener("change",()=>this.selectWitness(this.witnessSelect.value)),this.sceneElement.ufoElement.addEventListener("timeupdate",()=>this.refreshParamSummary()),this.supportsPopover?(this.infoPanel.setAttribute("popover","auto"),this.infoPanel.removeAttribute("hidden"),this.infoButton.setAttribute("popovertarget","info-panel"),this.infoPanel.addEventListener("beforetoggle",t=>{t.newState==="open"&&this.populateInfoPanel()}),this.infoPanel.addEventListener("toggle",t=>this.syncInfoOpen(t.newState==="open"))):this.infoButton.addEventListener("click",()=>this.toggleInfoPanel()),this.infoCloseButton.addEventListener("click",()=>this.toggleInfoPanel()),this.infoCreditsToggle.addEventListener("click",()=>this.toggleCredits()),this.infoEmbedToggle.addEventListener("click",()=>this.toggleEmbed());for(const t of[this.embedReplayRadio,this.embedEditRadio])t.addEventListener("change",()=>this.refreshEmbedMarkup());this.embedCopyButton.addEventListener("click",()=>void this.copyEmbedMarkup()),this.loadLocaleMessages()}async loadLocaleMessages(){this.language=co(navigator.languages,a0),this.language!=="en"&&(this.messages=await Op(this.language),this.testimonyPrefix.textContent=this.messages.testimonyBy,this.infoButton.title=this.messages.about,this.infoButton.setAttribute("aria-label",this.messages.about),this.infoCloseButton.setAttribute("aria-label",this.messages.close),this.infoObservationHeading.textContent=this.messages.observation,this.infoCreditsToggle.textContent=this.messages.credits,this.summaryBuilder=new zh(this.messages,this.language==="fr"?"fr":"en"),this.syncLabelsToggle(),this.refreshParamSummary(),this.infoEmbedToggle.textContent=this.messages.embed,this.labelEmbedReplay.textContent=this.messages.embedReplay,this.labelEmbedEdit.textContent=this.messages.embedEdit,this.embedCopyButton.textContent=this.messages.embedCopy,this.infoOpen&&this.populateInfoPanel(),this.updateTestimonyLine())}connectedCallback(){const e=this.getAttribute("src");e&&this.loadFromSrc(e)}disconnectedCallback(){document.removeEventListener("click",this.handleOutsideClick)}attributeChangedCallback(e,t,n){e==="src"&&n&&n!==t&&this.isConnected&&this.loadFromSrc(n),e==="show-labels"&&this.applyLabels(this.hasAttribute("show-labels"))}async loadFromSrc(e){const n=await(await fetch(e)).json();Array.isArray(n)?await this.loadWitnessUrls(n):this.setEntries([{src:e,sighting:n}])}get witnessUrls(){return this.entries.map(e=>e.src)}set witnessUrls(e){this.loadWitnessUrls(e)}async loadWitnessUrls(e){const t=await Promise.all(e.map(async n=>{const s=await fetch(n);return{src:n,sighting:await s.json()}}));this.setEntries(t)}setEntries(e){this.entries=e,this.warnOnMismatchedCaseIds(e),this.toolbarElement.hidden=e.length===0;const t=e.length>1;this.witnessSelect.hidden=!t,this.witnessText.hidden=t,this.witnessSelect.innerHTML="";for(const s of e){const r=document.createElement("option");r.value=s.src,r.textContent=this.witnessDisplayName(s.sighting.witness)??s.src,this.witnessSelect.appendChild(r)}const n=e.find(s=>s.src===this.currentSrc)??e[0];n?this.selectWitness(n.src):this.updateTestimonyLine()}editorUrl(){if(!this.currentSrc)return bl;const e=new URL(this.currentSrc,location.href);return e.origin===location.origin?`${bl}${e.pathname}`:`${bl}/?sighting=${encodeURIComponent(e.href)}`}embedMarkupFor(e){const t=e==="edit"?"rr0-ufo-recorder":"rr0-eyewitness",n=new URL(`${t}.mjs`,import.meta.url).href,s=this.currentSrc?new URL(this.currentSrc,location.href).href:"";return`<script type="module" src="${n}"><\/script>
5764
- <${t} src="${s}"></${t}>`}refreshEmbedMarkup(){this.embedMarkup.value=this.embedMarkupFor(this.embedEditRadio.checked?"edit":"replay")}async copyEmbedMarkup(){try{await navigator.clipboard.writeText(this.embedMarkup.value),this.embedCopyButton.textContent=this.messages.embedCopied,window.setTimeout(()=>this.embedCopyButton.textContent=this.messages.embedCopy,1500)}catch{this.embedMarkup.select()}}warnOnMismatchedCaseIds(e){const t=new Set(e.map(n=>n.sighting.caseId).filter(n=>n!==void 0));t.size>1&&console.warn(`<rr0-eyewitness>: witnesses declare different case ids (${[...t].join(", ")}) — they may not belong to the same case.`)}selectWitness(e){const t=this.entries.find(n=>n.src===e);t&&(this.currentSrc=e,this.witnessSelect.value=e,this.sceneElement.sightingData=t.sighting,this.updateTestimonyLine(),this.refreshParamSummary(),this.infoOpen&&this.populateInfoPanel())}updateTestimonyLine(){const e=this.entries.find(t=>t.src===this.currentSrc);e&&(this.witnessText.textContent=this.witnessDisplayName(e.sighting.witness)??e.src)}witnessDisplayName(e){if(!e)return;const t=[...e.firstNames??[],e.lastName].filter(Boolean).join(" ");return e.title||t||e.id||e.dirName}formatDate(e){const t=e.place?.[0],n=Gc(e.time??{},t?.lng??0,e.utcOffsetHours);if(!n)return;const s=n.getTime()+this.utcOffsetHoursOf(e,t?.lng??0)*36e5;return new Intl.DateTimeFormat(this.language==="fr"?"fr-FR":"en-US",{dateStyle:"long",timeStyle:"short",timeZone:"UTC"}).format(new Date(s))}utcOffsetHoursOf(e,t){return e.utcOffsetHours??Math.round(t/15)}formatLocation(e){const t=e.place?.[0];if(t)return`${t.lat.toFixed(4)}, ${t.lng.toFixed(4)}`}toggleInfoPanel(){const e=!this.infoOpen;if(this.supportsPopover){const t=this.infoPanel.matches(":popover-open");e&&!t?this.infoPanel.showPopover():!e&&t&&this.infoPanel.hidePopover();return}this.syncInfoOpen(e),this.infoPanel.hidden=!e,e?document.addEventListener("click",this.handleOutsideClick):document.removeEventListener("click",this.handleOutsideClick)}syncInfoOpen(e){e!==this.infoOpen&&(this.infoOpen=e,this.infoButton.setAttribute("aria-expanded",String(e)),e?this.supportsPopover||this.populateInfoPanel():(this.creditsOpen=!1,this.infoCreditsList.hidden=!0,this.infoCreditsToggle.setAttribute("aria-expanded","false"),this.embedOpen=!1,this.infoEmbedPanel.hidden=!0,this.infoEmbedToggle.setAttribute("aria-expanded","false")))}handleOutsideClick=e=>{const t=e.composedPath();!t.includes(this.infoPanel)&&!t.includes(this.infoButton)&&this.toggleInfoPanel()};toggleCredits(){this.creditsOpen=!this.creditsOpen,this.infoCreditsList.hidden=!this.creditsOpen,this.infoCreditsToggle.setAttribute("aria-expanded",String(this.creditsOpen)),this.creditsOpen&&this.revealInPanel(this.infoCreditsList)}toggleEmbed(){this.embedOpen=!this.embedOpen,this.infoEmbedPanel.hidden=!this.embedOpen,this.infoEmbedToggle.setAttribute("aria-expanded",String(this.embedOpen)),this.embedOpen&&(this.refreshEmbedMarkup(),this.revealInPanel(this.infoEmbedPanel))}revealInPanel(e){e.scrollIntoView?.({block:"nearest"})}get showLabels(){return this.labelsShown}set showLabels(e){this.toggleAttribute("show-labels",e)}applyLabels(e){this.labelsShown=e,this.syncLabelsToggle(),this.refreshParamSummary(),this.populateInfoPanel()}syncLabelsToggle(){this.labelsToggle.textContent=this.labelsShown?this.messages.hideLabels:this.messages.showLabels,this.labelsToggle.setAttribute("aria-pressed",String(this.labelsShown))}refreshParamSummary(){if(this.paramSummary.hidden=!this.labelsShown,!this.labelsShown){this.paramSummary.replaceChildren(),this.summarySignature="";return}const e=this.sceneElement.ufoElement.sighting,t=this.summaryBuilder.entriesFor(e,this.sceneElement.ufoElement.currentTime),n=t.map(s=>`${s.field}=${s.label}=${s.value}${s.unit}${s.fromSource?"*":""}`).join("|");n!==this.summarySignature&&(this.summarySignature=n,this.paramSummary.replaceChildren(...t.map(s=>{const r=document.createElement("span");if(r.className=s.fromSource?"param-label from-source":"param-label",r.append(`${s.label} `),s.color!==void 0){const o=document.createElement("span");o.className="param-label-swatch",o.style.background=s.color,r.append(o)}const a=document.createElement("span");return a.className="param-label-value",a.textContent=s.unit===""?s.value:`${s.value} ${s.unit}`,r.append(a),r})))}populateInfoPanel(){const e=this.entries.find(r=>r.src===this.currentSrc);if(this.infoObservationList.innerHTML="",e){if(!this.labelsShown){const r=this.formatDate(e.sighting);r&&this.appendInfoRow(this.infoObservationList,this.messages.date,r);const a=this.formatLocation(e.sighting);a&&this.appendInfoRow(this.infoObservationList,this.messages.location,a),e.sighting.caseId&&this.appendInfoRow(this.infoObservationList,this.messages.case,e.sighting.caseId)}e.sighting.description&&this.appendInfoRow(this.infoObservationList,this.messages.description,e.sighting.description),!this.labelsShown&&e.sighting.tags&&e.sighting.tags.length>0&&this.appendInfoRow(this.infoObservationList,this.messages.tags,e.sighting.tags.join(", "))}this.refreshEmbedMarkup(),this.infoAppLink.href=this.editorUrl(),this.infoAppLink.textContent="UFO@home v0.35.0",this.infoAppLink.title=this.messages.editThisObservation,this.infoAppLink.setAttribute("aria-label",this.messages.editThisObservation),this.infoCreditsList.innerHTML="";const t=this.sceneElement.currentTerrainAttribution;if(t){const r=document.createElement("li");r.textContent=t,this.infoCreditsList.appendChild(r)}const n=document.createElement("li");n.textContent=`${Zy} (`;const s=document.createElement("a");s.href=Jy,s.target="_blank",s.rel="noopener",s.textContent=Qy,n.appendChild(s),n.appendChild(document.createTextNode(")")),this.infoCreditsList.appendChild(n)}appendInfoRow(e,t,n){const s=document.createElement("dt");s.textContent=t;const r=document.createElement("dd");r.textContent=n,e.appendChild(s),e.appendChild(r)}}const Qd="rr0-eyewitness";function eS(){Nf(),customElements.get(Qd)||customElements.define(Qd,jy)}eS();
5795
+ `;let za;function Py(){if(za)return za;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),za=new hi(e),za}function Iy(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",l="#f4f1e2";n.fillStyle=o,n.beginPath(),n.arc(r,a,s,0,Math.PI*2),n.fill();const c=Ff(i.illuminatedFraction,0,1),h=i.phaseFraction<.5,u=s*Math.abs(1-2*c),d=c<.5;return n.save(),n.beginPath(),n.arc(r,a,s,0,Math.PI*2),n.clip(),n.fillStyle=l,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 hi(t)}function Ly(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 hi(e)}function bl(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 t0=new Map;function Ny(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 Uy(i){let e=t0.get(i);return e||(e=fetch(i).then(t=>t.arrayBuffer()).then(Ny),t0.set(i,e)),e}const Fy=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,Oy=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,zy=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,By=20,ky=1;class Hy{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(Fy,this.ambientVolume).then(o=>this.applyIfCurrent(o,a,()=>this.ambientToken,l=>{this.ambientSource=l?.source,this.ambientGain=l?.gain,l&&(l.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(n/By,1);const r=n>ky;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(Oy,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,l=>{this.windSource=l?.source,this.windGain=l?.gain,l&&(l.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(zy,.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 si{constructor(e){this.elements=e;const{eccentricity:t,perihelionAu:n}=e,[s,r]=this.perifocalAxes(),a=Math.sqrt(si.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*si.stumpffC(s),o=t-n*n*n/Math.sqrt(si.SUN_GM_AU3_PER_DAY2)*si.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(si.SUN_GM_AU3_PER_DAY2)*Math.abs(e),s=o=>{const l=this.inverseSemiMajorAxis*o*o,c=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*c)*o*o*o*si.stumpffS(l)+c*o};let r=Math.max(1,n/this.elements.perihelionAu);for(;s(r)<n;)r*=2;let a=0;for(let o=0;o<si.MAX_ITERATIONS&&r-a>1e-13*Math.max(1,r);o++){const l=(a+r)/2;s(l)<n?a=l:r=l}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),l=Math.cos(n),c=Math.sin(n);return[{x:s*a-r*o*l,y:r*a+s*o*l,z:o*c},{x:-s*o-r*a*l,y:-r*o+s*a*l,z:a*c}]}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 Of=[{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 Gy{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 Of.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=Ut(t),r=this.earthPositionAt(s),a=this.apparentPositionOf(e,2451545+s.tt,r),o=this.subtract(a,r),l=this.length(a),c=this.length(o),h=this.tailEndAt(e,a,r,l,s,t,n),u=this.horizontalOf(o,s,t,n);return{apparition:e,position:u,...h,heliocentricDistanceAu:l,earthDistanceAu:c,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},r)),magnitude:this.magnitudeAt(e,l,c)}}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 l=1+e.tailLengthAu/s,c=this.subtract({x:t.x*l,y:t.y*l,z:t.z*l},n),h=this.subtract(t,n);return{tailEnd:this.horizontalOf(c,r,a,o),tailLengthDeg:this.angleBetween(h,c)}}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=qa(R3(),new ut(e.x,e.y,e.z,t)),a=qa(C3(t),r),o=r3(t,new wh(s.lat,s.lng,s.elevationM)),l=new ut(a.x-o.x,a.y-o.y,a.z-o.z,t),c=vf(l);return Lr(c.ra,c.dec,n,s)}static earthPositionAt(e){return qa(T3(),Di(Se.Earth,e))}static julianDayOf(e){return 2451545+Ut(e).tt}static orbitOf(e){const t=this.orbits.get(e.id);if(t)return t;const n=new si(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 Vy=[{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}],lo=6.5;class El{static activeAt(e){return Vy.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),l=this.wrappedDelta(r,s),c=this.wrappedDelta(a,r);return o<0?o<-l?0:1+o/l:o>0?o>c?0:1-o/c:1}static observedRatePerHour(e,t,n,s=lo){if(t<=0)return 0;const r=lo-s;return e*Math.sin(t*Math.PI/180)/Math.pow(n,r)}static radiantPosition(e,t,n){return Lr(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 _t{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(e,t){const n=Ut(e),s=new bh(0,i3(e).elon-90,1),r=qa(D3(n),gf(s,n)),a=vf(r);return Lr(a.ra,a.dec,e,t)}static observedRatePerHour(e,t=lo){const n=_t.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(e*Math.PI/180)),s=lo-t;return(_t.QUIET_RATE_PER_HOUR+n)/Math.pow(_t.POPULATION_INDEX,s)}static schedule(e){const t=new wf(e.seed^1542469173);return es.schedule(e).map(n=>{const s=_t.toCartesian({altitudeDeg:Math.asin(t.next())*180/Math.PI,azimuthDeg:t.between(0,360)}),r=n.fromRadiantDeg*Math.PI/180,a=_t.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:_t.toHorizontal(o),bearingDeg:_t.bearingFrom(o,s)}})}static turnAround(e,t){const[n,s]=_t.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]=_t.basisAround(e),r=e.x*t.x+e.y*t.y+e.z*t.z,a=_t.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=_t.normalise(_t.cross(e,t));return[n,_t.normalise(_t.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=_t.toCartesian(e.radiant??{altitudeDeg:90,azimuthDeg:0}),n=_t.turnAround(t,e.bearingDeg),s=e.fromRadiantDeg*Math.PI/180;return _t.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 Wy{lowerM;upperM;add(e,t){if(!(e<=0)){if(t.behindM!==void 0){const n=qt.sizeMAt(t.behindM,e);this.lowerM=this.lowerM===void 0?n:Math.max(this.lowerM,n)}if(t.inFrontM!==void 0){const n=qt.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:qt.distanceMAt(this.lowerM,e),maxM:this.upperM===void 0?void 0:qt.distanceMAt(this.upperM,e)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class Ar{static DEG_PER_SECOND=360/86164.0905;static degOver(e){return Math.max(0,e)*Ar.DEG_PER_SECOND}static instants(e,t){if(!(t>0))return 1;const n=Ar.degOver(e)/t;return n<1?1:Math.min(Ar.MAX_INSTANTS,Math.max(2,Math.ceil(n)))}static MAX_INSTANTS=64}class ri{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?ri.travelDegOver(e,t,n,n+s*1e3)/r/ri.PIXELS_PER_INSTANT:0,o=ri.flashesOver(e,s)*ri.INSTANTS_PER_FLASH,l=Math.ceil(Math.max(a,o));return l<2?1:Math.min(ri.MAX_INSTANTS,l)}static travelDegOver(e,t,n,s){let r=0;for(const a of e){if(!a.track||a.track.length<2)continue;const o=ri.directionAt(a,t,n),l=ri.directionAt(a,t,s),c=Math.min(1,Math.max(-1,o.x*l.x+o.y*l.y+o.z*l.z));r=Math.max(r,Math.acos(c)*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=Qc(e,n),r=s.eastM,a=s.altitudeM-t,o=s.northM,l=Math.hypot(r,a,o);return l===0?{x:0,y:1,z:0}:{x:r/l,y:a/l,z:o/l}}}f0();const Xy={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"}},qy=["en","fr"],Yy={en:"{name} — mag {mag}, {alt}° above the horizon",fr:"{name} — mag {mag}, {alt}° au-dessus de l'horizon"},n0="comet:",Ky={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"}},$y=new URL(""+new URL("stars-mag7.5-DDr9QasD.bin",import.meta.url).href,import.meta.url).href,Zy={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},wl={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class Jy 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 Hy;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),l=uo(navigator.languages,qy),c=this.sceneRenderer.pickBodyAt(a,o);if(c){this.showHoverTooltip(e,this.bodyName(c,l));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||Ky[u.kind][l]);return}const d=this.sceneRenderer.pickStarAt(a,o);if(d){const f=d.star.mag;this.showHoverTooltip(e,Yy[l].replace("{name}",d.star.name[l]).replace("{mag}",f.toLocaleString(void 0,{maximumFractionDigits:Math.abs(f)<1?2:1})).replace("{alt}",String(Math.round(d.altitudeDeg))));return}this.hoverTooltip.hidden=!0};bodyName(e,t){const n=e.startsWith(n0)?e.slice(n0.length):void 0;return(n?Of.find(r=>r.id===n):void 0)?.name[t]??Xy[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(Rl(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>${vp}</style>${gp}`,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 Ah(this.sceneCanvas,void 0,this.handleLightningFlash),this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(Dl),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){const t=await fetch(e);this.sightingData=await t.json()}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=qt.CANVAS_HEIGHT_PX,n=Ht.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")??$y;this.starCatalog=await Uy(e),this.updateAstronomy(this.lastTimeMs)}updateAstronomy(e){this.applySceneAt(e);const t=this.exposureSeconds(),n=this.degreesPerPixelAt(e),s=Ar.instants(t,n),r=Math.max(s,ri.instants(this.ufoElement.sighting.decor,Ai(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:Sr.fovOf(this.ufoElement.sighting,e)/t}applySceneAt(e,t){const n=this.ufoElement.sighting;this.setWeather(Rl(n,e)),this.sceneRenderer.setInstrument(n.instrument),this.updateMeteorShower(n,e),this.sceneRenderer.setDecor(n.decor);const s=Ai(n,e);if(this.sceneRenderer.setObserverPose(s??wl),this.sceneRenderer.setLensOptics(this.lensOpticsAt(e)),this.sceneRenderer.updateDecorAnchoring(Ai(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??wl.lat,a=s?.lng??wl.lng,o=Xc(n.event.time??{},a,n.event.utcOffsetHours);if(!o){this.sceneRenderer.setAstronomy(Zy);return}const l=new Date(o.getTime()+e),c={lat:r,lng:a,elevationM:s?.elevationM??0},h={...ul("Sun",l,c),magnitude:dl("Sun",l)},u={...ul("Moon",l,c),phase:I3(l),magnitude:dl("Moon",l)},d=P3.map(f=>({body:f,position:ul(f,l,c),magnitude:dl(f,l)}));this.sceneRenderer.setAstronomy({sun:h,moon:u,planets:d,comet:this.cometAt(l,c),stars:this.starCatalog?{catalog:this.starCatalog,date:l,observer:c}:void 0})}cometAt(e,t){const n=Gy.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 l=(o.bounds.x+o.bounds.width/2)/s.width*2-1,c=-((o.bounds.y+o.bounds.height/2)/s.height*2-1);this.sceneRenderer.isScreenPointOccluded(l,c,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(l,c,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?Xc(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),l=_t.schedule({ratePerHour:_t.observedRatePerHour(_t.apexPosition(s,r).altitudeDeg),durationMs:a,velocityKmS:_t.TYPICAL_VELOCITY_KM_S,seed:o}),c=El.activeAt(s).map(u=>{const d=El.radiantPosition(u.shower,s,r);return{entry:u,position:d,rate:El.observedRatePerHour(u.zhr,d.altitudeDeg,u.shower.populationIndex)}}).sort((u,d)=>d.rate-u.rate)[0];if(!c||c.rate<=0){this.sceneRenderer.setMeteorShower(l,0,0);return}const h=es.schedule({ratePerHour:c.rate,durationMs:a,velocityKmS:c.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...l],c.position.altitudeDeg,c.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=Ai(t,e),a=r?.fNumber??n.fNumber;if(!s||a===void 0)return;const o=Ht.focalLengthMmFor(n,Sr.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 ks.of(t.instrument,qt.CANVAS_HEIGHT_PX,Sr.fovOf(t,e))}sizeEstimateOf(e){let t=this.sizeEstimates.get(e);return t||(t=new Wy,this.sizeEstimates.set(e,t)),t}}const Zc="rr0-scene";function zf(){f0(),customElements.get(Zc)||customElements.define(Zc,Jy)}const Qy={color:"Color",transparency:"Transparency",halo:"Halo",blur:"Blur",brightness:"Brilliance",shapeTitle:"Name",utcOffset:"Time zone",cloudBase:"Cloud base",elevation:"Altitude",heightAboveGround:"Height above ground",duration:"Duration",placeName:"Place",latitude:"Latitude",longitude:"Longitude",heading:"Heading",pitch:"Tilt",roll:"Roll",observationTime:"Observation start",observationEndTime:"Observation end",witnessId:"Witness ID",witnessTitle:"Witness title",witnessLastName:"Witness last name",witnessFirstNames:"Witness first names",caseId:"Case ID",tags:"Tags",cloudCover:"Cloud cover",highCloudCover:"Ice cloud (cirrus)",focalLength:"Focal length",fieldOfView:"Field of view",aperture:"Aperture",exposure:"Exposure",focusDistance:"Focused at",iceCrystalAlignment:"Crystal alignment",cloudDarkness:"Cloud darkness",precipitationType:"Precipitation",precipitationNone:"None",precipitationRain:"Rain",precipitationSnow:"Snow",precipitationHail:"Hail",precipitationIntensity:"Intensity",windDirection:"Wind direction",windSpeed:"Wind speed",storm:"Storm",soundKind:"Sound",soundNone:"None (silent)",soundHum:"Hum",soundWhistle:"Whistle",soundRumble:"Rumble",soundCrackle:"Crackle",soundVolume:"Loudness",soundPitch:"Pitch",soundSrc:"Recording",instrument:"Observed through",decorAircraft:"Aircraft",decorAltitude:"Altitude",decorLights:"Lights",decorLightsNone:"none",decor:"Decor",decorBuilding:"Building",decorTree:"Tree",decorStreetlight:"Streetlight",decorVehicle:"Vehicle",decorWitness:"Other witness",decorEast:"Distance east",decorNorth:"Distance north",decorHeading:"Heading",decorLit:"Lit",decorTitle:"Name",decorFloors:"Floors",decorOccupiedFloor:"Occupied floor",decorWitnessSide:"Witness location",decorWitnessSideNone:"Not present",decorWindows:"Windows",decorSideFront:"Front",decorSideBehind:"Behind",decorSideLeft:"Left",decorSideRight:"Right",decorSideFrontLeft:"Front-left",decorSideFrontRight:"Front-right",decorSideBehindLeft:"Behind-left",decorSideBehindRight:"Behind-right"},Jc={...Qy,testimonyBy:"Testimony by",about:"About",close:"Close",observation:"Observation",date:"Date",location:"Location",case:"Case",description:"Description",credits:"Credits",editThisObservation:"Edit this observation",embed:"Embed",embedReplay:"Replay",embedEdit:"Editor",embedCopy:"Copy",embedCopied:"Copied",showLabels:"Show what it states",hideLabels:"Hide what it states"},jy=Object.freeze(Object.defineProperty({__proto__:null,eyewitnessMessages_en:Jc},Symbol.toStringTag,{value:"Module"}));zf();const eS="“Thunder” by Jerimee",tS="https://creativecommons.org/licenses/by/3.0/",nS="CC BY 3.0",Al="https://ufoathome.org";class iS extends HTMLElement{static get observedAttributes(){return["src","show-labels"]}shadow;sceneElement;toolbarElement;testimonyPrefix;witnessText;witnessSelect;infoButton;infoPanel;infoAppLink;infoObservationHeading;infoObservationList;infoCreditsToggle;infoCreditsList;infoCloseButton;infoEmbedToggle;infoEmbedPanel;embedReplayRadio;embedEditRadio;labelEmbedReplay;labelEmbedEdit;embedMarkup;embedCopyButton;labelsToggle;paramSummary;summaryBuilder=new Vh(Jc,"en");summarySignature="";supportsPopover=typeof HTMLElement.prototype.showPopover=="function";entries=[];currentSrc;infoOpen=!1;creditsOpen=!1;embedOpen=!1;labelsShown=!1;language="en";messages=Jc;constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${Yf}</style>${qf}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.sceneElement=document.createElement(Zc),this.shadow.getElementById("ufo-slot").replaceWith(this.sceneElement),this.toolbarElement=this.shadow.getElementById("toolbar"),this.testimonyPrefix=this.shadow.getElementById("testimony-prefix"),this.witnessText=this.shadow.getElementById("witness-text"),this.witnessSelect=this.shadow.getElementById("witness"),this.infoButton=this.shadow.getElementById("info-button"),this.infoPanel=this.shadow.getElementById("info-panel"),this.infoAppLink=this.shadow.getElementById("info-app-link"),this.infoObservationHeading=this.shadow.getElementById("info-observation-heading"),this.infoObservationList=this.shadow.getElementById("info-observation-list"),this.infoCreditsToggle=this.shadow.getElementById("info-credits-toggle"),this.infoCreditsList=this.shadow.getElementById("info-credits-list"),this.infoCloseButton=this.shadow.getElementById("info-close"),this.labelsToggle=this.shadow.getElementById("info-labels-toggle"),this.paramSummary=this.shadow.getElementById("param-summary"),this.labelsToggle.addEventListener("click",()=>{this.showLabels=!this.showLabels}),this.infoEmbedToggle=this.shadow.getElementById("info-embed-toggle"),this.infoEmbedPanel=this.shadow.getElementById("info-embed"),this.embedReplayRadio=this.shadow.getElementById("embed-kind-replay"),this.embedEditRadio=this.shadow.getElementById("embed-kind-edit"),this.labelEmbedReplay=this.shadow.getElementById("label-embed-replay"),this.labelEmbedEdit=this.shadow.getElementById("label-embed-edit"),this.embedMarkup=this.shadow.getElementById("embed-markup"),this.embedCopyButton=this.shadow.getElementById("embed-copy"),this.witnessSelect.addEventListener("change",()=>this.selectWitness(this.witnessSelect.value)),this.sceneElement.ufoElement.addEventListener("timeupdate",()=>this.refreshParamSummary()),this.supportsPopover?(this.infoPanel.setAttribute("popover","auto"),this.infoPanel.removeAttribute("hidden"),this.infoButton.setAttribute("popovertarget","info-panel"),this.infoPanel.addEventListener("beforetoggle",t=>{t.newState==="open"&&this.populateInfoPanel()}),this.infoPanel.addEventListener("toggle",t=>this.syncInfoOpen(t.newState==="open"))):this.infoButton.addEventListener("click",()=>this.toggleInfoPanel()),this.infoCloseButton.addEventListener("click",()=>this.toggleInfoPanel()),this.infoCreditsToggle.addEventListener("click",()=>this.toggleCredits()),this.infoEmbedToggle.addEventListener("click",()=>this.toggleEmbed());for(const t of[this.embedReplayRadio,this.embedEditRadio])t.addEventListener("change",()=>this.refreshEmbedMarkup());this.embedCopyButton.addEventListener("click",()=>void this.copyEmbedMarkup()),this.loadLocaleMessages()}async loadLocaleMessages(){this.language=uo(navigator.languages,u0),this.language!=="en"&&(this.messages=await kp(this.language),this.testimonyPrefix.textContent=this.messages.testimonyBy,this.infoButton.title=this.messages.about,this.infoButton.setAttribute("aria-label",this.messages.about),this.infoCloseButton.setAttribute("aria-label",this.messages.close),this.infoObservationHeading.textContent=this.messages.observation,this.infoCreditsToggle.textContent=this.messages.credits,this.summaryBuilder=new Vh(this.messages,this.language==="fr"?"fr":"en"),this.syncLabelsToggle(),this.refreshParamSummary(),this.infoEmbedToggle.textContent=this.messages.embed,this.labelEmbedReplay.textContent=this.messages.embedReplay,this.labelEmbedEdit.textContent=this.messages.embedEdit,this.embedCopyButton.textContent=this.messages.embedCopy,this.infoOpen&&this.populateInfoPanel(),this.updateTestimonyLine())}connectedCallback(){const e=this.getAttribute("src");e&&this.loadFromSrc(e)}disconnectedCallback(){document.removeEventListener("click",this.handleOutsideClick)}attributeChangedCallback(e,t,n){e==="src"&&n&&n!==t&&this.isConnected&&this.loadFromSrc(n),e==="show-labels"&&this.applyLabels(this.hasAttribute("show-labels"))}async loadFromSrc(e){const n=await(await fetch(e)).json();Array.isArray(n)?await this.loadWitnessUrls(n):this.setEntries([{src:e,sighting:n}])}get witnessUrls(){return this.entries.map(e=>e.src)}set witnessUrls(e){this.loadWitnessUrls(e)}async loadWitnessUrls(e){const t=await Promise.all(e.map(async n=>{const s=await fetch(n);return{src:n,sighting:await s.json()}}));this.setEntries(t)}setEntries(e){this.entries=e,this.warnOnMismatchedCaseIds(e),this.toolbarElement.hidden=e.length===0;const t=e.length>1;this.witnessSelect.hidden=!t,this.witnessText.hidden=t,this.witnessSelect.innerHTML="";for(const s of e){const r=document.createElement("option");r.value=s.src,r.textContent=this.witnessDisplayName(s.sighting.witness)??s.src,this.witnessSelect.appendChild(r)}const n=e.find(s=>s.src===this.currentSrc)??e[0];n?this.selectWitness(n.src):this.updateTestimonyLine()}editorUrl(){if(!this.currentSrc)return Al;const e=new URL(this.currentSrc,location.href);return e.origin===location.origin?`${Al}${e.pathname}`:`${Al}/?sighting=${encodeURIComponent(e.href)}`}embedMarkupFor(e){const t=e==="edit"?"rr0-ufo-recorder":"rr0-eyewitness",n=new URL(`${t}.mjs`,import.meta.url).href,s=this.currentSrc?new URL(this.currentSrc,location.href).href:"";return`<script type="module" src="${n}"><\/script>
5796
+ <${t} src="${s}"></${t}>`}refreshEmbedMarkup(){this.embedMarkup.value=this.embedMarkupFor(this.embedEditRadio.checked?"edit":"replay")}async copyEmbedMarkup(){try{await navigator.clipboard.writeText(this.embedMarkup.value),this.embedCopyButton.textContent=this.messages.embedCopied,window.setTimeout(()=>this.embedCopyButton.textContent=this.messages.embedCopy,1500)}catch{this.embedMarkup.select()}}warnOnMismatchedCaseIds(e){const t=new Set(e.map(n=>n.sighting.caseId).filter(n=>n!==void 0));t.size>1&&console.warn(`<rr0-eyewitness>: witnesses declare different case ids (${[...t].join(", ")}) — they may not belong to the same case.`)}selectWitness(e){const t=this.entries.find(n=>n.src===e);t&&(this.currentSrc=e,this.witnessSelect.value=e,this.sceneElement.sightingData=t.sighting,this.updateTestimonyLine(),this.refreshParamSummary(),this.infoOpen&&this.populateInfoPanel())}updateTestimonyLine(){const e=this.entries.find(t=>t.src===this.currentSrc);e&&(this.witnessText.textContent=this.witnessDisplayName(e.sighting.witness)??e.src)}witnessDisplayName(e){if(!e)return;const t=[...e.firstNames??[],e.lastName].filter(Boolean).join(" ");return e.title||t||e.id||e.dirName}formatDate(e){const t=e.place?.[0],n=Xc(e.time??{},t?.lng??0,e.utcOffsetHours);if(!n)return;const s=n.getTime()+this.utcOffsetHoursOf(e,t?.lng??0)*36e5;return new Intl.DateTimeFormat(this.language==="fr"?"fr-FR":"en-US",{dateStyle:"long",timeStyle:"short",timeZone:"UTC"}).format(new Date(s))}utcOffsetHoursOf(e,t){return e.utcOffsetHours??Math.round(t/15)}formatLocation(e){const t=e.place?.[0];if(t)return`${t.lat.toFixed(4)}, ${t.lng.toFixed(4)}`}toggleInfoPanel(){const e=!this.infoOpen;if(this.supportsPopover){const t=this.infoPanel.matches(":popover-open");e&&!t?this.infoPanel.showPopover():!e&&t&&this.infoPanel.hidePopover();return}this.syncInfoOpen(e),this.infoPanel.hidden=!e,e?document.addEventListener("click",this.handleOutsideClick):document.removeEventListener("click",this.handleOutsideClick)}syncInfoOpen(e){e!==this.infoOpen&&(this.infoOpen=e,this.infoButton.setAttribute("aria-expanded",String(e)),e?this.supportsPopover||this.populateInfoPanel():(this.creditsOpen=!1,this.infoCreditsList.hidden=!0,this.infoCreditsToggle.setAttribute("aria-expanded","false"),this.embedOpen=!1,this.infoEmbedPanel.hidden=!0,this.infoEmbedToggle.setAttribute("aria-expanded","false")))}handleOutsideClick=e=>{const t=e.composedPath();!t.includes(this.infoPanel)&&!t.includes(this.infoButton)&&this.toggleInfoPanel()};toggleCredits(){this.creditsOpen=!this.creditsOpen,this.infoCreditsList.hidden=!this.creditsOpen,this.infoCreditsToggle.setAttribute("aria-expanded",String(this.creditsOpen)),this.creditsOpen&&this.revealInPanel(this.infoCreditsList)}toggleEmbed(){this.embedOpen=!this.embedOpen,this.infoEmbedPanel.hidden=!this.embedOpen,this.infoEmbedToggle.setAttribute("aria-expanded",String(this.embedOpen)),this.embedOpen&&(this.refreshEmbedMarkup(),this.revealInPanel(this.infoEmbedPanel))}revealInPanel(e){e.scrollIntoView?.({block:"nearest"})}get showLabels(){return this.labelsShown}set showLabels(e){this.toggleAttribute("show-labels",e)}applyLabels(e){this.labelsShown=e,this.syncLabelsToggle(),this.refreshParamSummary(),this.populateInfoPanel()}syncLabelsToggle(){this.labelsToggle.textContent=this.labelsShown?this.messages.hideLabels:this.messages.showLabels,this.labelsToggle.setAttribute("aria-pressed",String(this.labelsShown))}refreshParamSummary(){if(this.paramSummary.hidden=!this.labelsShown,!this.labelsShown){this.paramSummary.replaceChildren(),this.summarySignature="";return}const e=this.sceneElement.ufoElement.sighting,t=this.summaryBuilder.entriesFor(e,this.sceneElement.ufoElement.currentTime),n=t.map(s=>`${s.field}=${s.label}=${s.value}${s.unit}${s.fromSource?"*":""}`).join("|");n!==this.summarySignature&&(this.summarySignature=n,this.paramSummary.replaceChildren(...t.map(s=>{const r=document.createElement("span");if(r.className=s.fromSource?"param-label from-source":"param-label",r.append(`${s.label} `),s.color!==void 0){const o=document.createElement("span");o.className="param-label-swatch",o.style.background=s.color,r.append(o)}const a=document.createElement("span");return a.className="param-label-value",a.textContent=s.unit===""?s.value:`${s.value} ${s.unit}`,r.append(a),r})))}populateInfoPanel(){const e=this.entries.find(r=>r.src===this.currentSrc);if(this.infoObservationList.innerHTML="",e){if(!this.labelsShown){const r=this.formatDate(e.sighting);r&&this.appendInfoRow(this.infoObservationList,this.messages.date,r);const a=this.formatLocation(e.sighting);a&&this.appendInfoRow(this.infoObservationList,this.messages.location,a),e.sighting.caseId&&this.appendInfoRow(this.infoObservationList,this.messages.case,e.sighting.caseId)}e.sighting.description&&this.appendInfoRow(this.infoObservationList,this.messages.description,e.sighting.description),!this.labelsShown&&e.sighting.tags&&e.sighting.tags.length>0&&this.appendInfoRow(this.infoObservationList,this.messages.tags,e.sighting.tags.join(", "))}this.refreshEmbedMarkup(),this.infoAppLink.href=this.editorUrl(),this.infoAppLink.textContent="UFO@home v0.36.0",this.infoAppLink.title=this.messages.editThisObservation,this.infoAppLink.setAttribute("aria-label",this.messages.editThisObservation),this.infoCreditsList.innerHTML="";const t=this.sceneElement.currentTerrainAttribution;if(t){const r=document.createElement("li");r.textContent=t,this.infoCreditsList.appendChild(r)}const n=document.createElement("li");n.textContent=`${eS} (`;const s=document.createElement("a");s.href=tS,s.target="_blank",s.rel="noopener",s.textContent=nS,n.appendChild(s),n.appendChild(document.createTextNode(")")),this.infoCreditsList.appendChild(n)}appendInfoRow(e,t,n){const s=document.createElement("dt");s.textContent=t;const r=document.createElement("dd");r.textContent=n,e.appendChild(s),e.appendChild(r)}}const i0="rr0-eyewitness";function sS(){zf(),customElements.get(i0)||customElements.define(i0,iS)}sS();