@rr0/ufoathome 0.65.0 → 0.65.1
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 E1="modulepreload",A1=function(a,e){return new URL(a,e).href},b0={},Wc=function(e,t,i){let n=Promise.resolve();if(t&&t.length>0){let r=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};const o=document.getElementsByTagName("link"),c=document.querySelector("meta[property=csp-nonce]"),l=c?.nonce||c?.getAttribute("nonce");n=r(t.map(h=>{if(h=A1(h,i),h in b0)return;b0[h]=!0;const u=h.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(!!i)for(let v=o.length-1;v>=0;v--){const m=o[v];if(m.href===h&&(!u||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${d}`))return;const p=document.createElement("link");if(p.rel=u?"stylesheet":E1,u||(p.as="script"),p.crossOrigin="",p.href=h,l&&p.setAttribute("nonce",l),document.head.appendChild(p),u)return new Promise((v,m)=>{p.addEventListener("load",v),p.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${h}`)))})}))}function s(r){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=r,window.dispatchEvent(o),!o.defaultPrevented)throw r}return n.then(r=>{for(const o of r||[])o.status==="rejected"&&s(o.reason);return e().catch(s)})};const Pm={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,storm:!1};function Xc(a){if(a.cloudLayers!==void 0)return a.cloudLayers;const e=[],t=a.lowerCloudCover??a.cloudCover;return t>0&&e.push({id:"lower",type:"cumulus",baseM:a.cloudBaseM??1e3,thicknessM:650,coverage:t,sizeM:1400,density:1,darkness:a.cloudDarkness}),(a.highCloudCover??0)>0&&e.push({id:"cirrus",type:"cirrus",baseM:8e3,thicknessM:400,coverage:a.highCloudCover,sizeM:2200,density:.35,darkness:a.cloudDarkness,iceCrystalAlignment:a.iceCrystalAlignment}),e}const Lm=Math.PI/180,qc=111320;function
|
|
1
|
+
const E1="modulepreload",A1=function(a,e){return new URL(a,e).href},b0={},Wc=function(e,t,i){let n=Promise.resolve();if(t&&t.length>0){let r=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};const o=document.getElementsByTagName("link"),c=document.querySelector("meta[property=csp-nonce]"),l=c?.nonce||c?.getAttribute("nonce");n=r(t.map(h=>{if(h=A1(h,i),h in b0)return;b0[h]=!0;const u=h.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(!!i)for(let v=o.length-1;v>=0;v--){const m=o[v];if(m.href===h&&(!u||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${d}`))return;const p=document.createElement("link");if(p.rel=u?"stylesheet":E1,u||(p.as="script"),p.crossOrigin="",p.href=h,l&&p.setAttribute("nonce",l),document.head.appendChild(p),u)return new Promise((v,m)=>{p.addEventListener("load",v),p.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${h}`)))})}))}function s(r){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=r,window.dispatchEvent(o),!o.defaultPrevented)throw r}return n.then(r=>{for(const o of r||[])o.status==="rejected"&&s(o.reason);return e().catch(s)})};const Pm={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,storm:!1};function Xc(a){if(a.cloudLayers!==void 0)return a.cloudLayers;const e=[],t=a.lowerCloudCover??a.cloudCover;return t>0&&e.push({id:"lower",type:"cumulus",baseM:a.cloudBaseM??1e3,thicknessM:650,coverage:t,sizeM:1400,density:1,darkness:a.cloudDarkness}),(a.highCloudCover??0)>0&&e.push({id:"cirrus",type:"cirrus",baseM:8e3,thicknessM:400,coverage:a.highCloudCover,sizeM:2200,density:.35,darkness:a.cloudDarkness,iceCrystalAlignment:a.iceCrystalAlignment}),e}const Lm=Math.PI/180,qc=111320;function li(a,e,t,i){const n=qc*Math.cos(t*Lm),s=(a-t)*qc;return{x:(e-i)*n,z:-s}}function fs(a,e,t,i){const n=qc*Math.cos(t*Lm),s=-e,r=a;return{lat:t+s/qc,lng:i+r/n}}function E0(a,e,t,i,n,s){const r=i?.lat!==void 0&&i.lng!==void 0&&n?.lat!==void 0&&n.lng!==void 0?li(n.lat,n.lng,i.lat,i.lng):{x:0,z:0},o=Math.max(0,a),c=[0,...e.allKeyframes.map(l=>l.t).filter(l=>l>0&&l<o),o];for(let l=1;l<c.length;l++){const h=c[l-1],u=c[l]-h;if(u===0)continue;const d=32;for(let f=0;f<=d;f++){const p=e.getInterpolatedWeatherAt(h+u*f/d)??t,v=s===void 0?void 0:p.cloudLayers?.find(w=>w.id===s),m=(v?.windDirectionDeg??p.windDirectionDeg)*Math.PI/180,g=f===0||f===d?1:f%2===0?2:4,_=(v?.windSpeed??p.windSpeed)*u/1e3/d/3*g;r.x-=Math.sin(m)*_,r.z+=Math.cos(m)*_}}return r}const T1=`
|
|
2
2
|
<div class="stage" id="stage">
|
|
3
3
|
<div class="frame" id="frame">
|
|
4
4
|
<canvas id="scene-canvas"></canvas>
|
|
@@ -624,15 +624,15 @@ input[type=range] {
|
|
|
624
624
|
pointer-events: none;
|
|
625
625
|
white-space: nowrap;
|
|
626
626
|
}
|
|
627
|
-
`,Po=[{id:"eye",name:{en:"Naked eye",fr:"Œil nu"},flare:0,projection:"equidistant",stabilization:.97},{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,detailUm:20},{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,detailUm:20},{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},detailUm:20},{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},fNumber:1.8,exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0,detailUm:1.4},{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},fNumber:1.8,exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0,detailUm:1.4}];class ai{static get default(){return Po[0]}static byId(e){return Po.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:ai.UNAIDED_FIELD_DEG}static aspectOf(e){const t=e.frame;return t?t.widthMm/t.heightMm:ai.UNAIDED_ASPECT}static frameWidthPx(e,t){return Math.round(t*ai.aspectOf(e))}static availableAt(e){return e===void 0?Po:Po.filter(t=>!t.years||e>=t.years.from&&(t.years.to===void 0||e<=t.years.to))}static fieldOfViewDegAt(e,t){const i=e.frame;if(!(!i||t<=0))return 2*Math.atan(i.heightMm/(2*t))*180/Math.PI}static focalLengthMmFor(e,t){const i=e.frame;if(!(!i||t<=0||t>=180))return i.heightMm/(2*Math.tan(t*Math.PI/360))}static bladesShowing(e,t){const i=t??e.fNumber;if(i===void 0||e.apertureBlades===void 0)return 0;const n=e.fNumberRange;return!n||n.max<=n.min?1:Math.max(0,Math.min(1,(i-n.min)/(n.max-n.min)))}static LENS_FLARE_ARTIFACTS=1;static flareArtifactsOf(e){return e.flare??ai.LENS_FLARE_ARTIFACTS}static starPointsOf(e){const t=e.apertureBlades;return t===void 0||t<3?0:t%2===0?t:t*2}}class ho{constructor(e){this.points=e}static STATIONARY_M=5;static of(e){const t=[];for(const i of e.witnessTrack.allKeyframes){const{lat:n,lng:s,headingDeg:r}=i.pose;n===void 0||s===void 0||t.push({t:i.t,lat:n,lng:s,headingDeg:r})}if(t.length===0){const i=e.event.place?.[0];if(!i)return;t.push({t:0,lat:i.lat,lng:i.lng})}return new ho(t)}get moved(){return this.spanM>ho.STATIONARY_M}get spanM(){const e=this.box,t=(e.south+e.north)/2,i=(e.west+e.east)/2;return Math.max(Math.abs(ci(t,e.east,t,e.west).x),Math.abs(ci(e.north,i,e.south,i).z))}get center(){const e=this.box;return{lat:(e.south+e.north)/2,lng:(e.west+e.east)/2}}boundsAround(e,t){const{lat:i,lng:n}=this.center,s=Math.max(this.spanM*(1+t),e)/2;return{north:fs(0,-s,i,n).lat,south:fs(0,s,i,n).lat,east:fs(s,0,i,n).lng,west:fs(-s,0,i,n).lng}}get box(){const e=this.points.map(i=>i.lat),t=this.points.map(i=>i.lng);return{south:Math.min(...e),north:Math.max(...e),west:Math.min(...t),east:Math.max(...t)}}}class ni{constructor(e,t){this.stretches=e,this.rotationPassed=t}static REFERENCE_SPEED_M_PER_S=1.4;static REFERENCE_STEP_HZ=1.9;static CADENCE_EXPONENT=.43;static RISE_M_PER_M_PER_S=.0175;static SWAY_M=.0175;static SLOWEST_WALK_M_PER_S=.2;static FASTEST_WALK_M_PER_S=2.2;static HEAD_ROLL_DEG=1.5;static HEAD_PITCH_DEG=1.25;static HEAD_YAW_DEG=1;static STILL=Object.freeze({eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0});static of(e){const t=ho.of(e);if(!t||t.points.length<2)return;const i=[];let n=0;for(let s=1;s<t.points.length;s++){const r=t.points[s-1],o=t.points[s],c=(o.t-r.t)/1e3;if(c<=0)continue;const l=ci(o.lat,o.lng,r.lat,r.lng),h=l.x,u=-l.z,d=Math.hypot(h,u),f=d/c,p=ni.stepHzFor(f);i.push({startMs:r.t,endMs:o.t,speedMPerS:f,eastUnit:d>0?h/d:0,northUnit:d>0?u/d:0,stepHz:p,stepsBefore:n,rampsIn:!0,rampsOut:!0}),n+=p*c}for(let s=0;s<i.length;s++){const r=i[s-1],o=i[s+1];i[s].rampsIn=r===void 0||r.stepHz===0,i[s].rampsOut=o===void 0||o.stepHz===0}if(i.some(s=>s.stepHz>0))return new ni(i,1-(e.instrument.stabilization??0))}static stepHzFor(e){return e<ni.SLOWEST_WALK_M_PER_S||e>ni.FASTEST_WALK_M_PER_S?0:ni.REFERENCE_STEP_HZ*Math.pow(e/ni.REFERENCE_SPEED_M_PER_S,ni.CADENCE_EXPONENT)}offsetAt(e){const t=this.stretches.find(c=>e>=c.startMs&&e<=c.endMs);if(!t||t.stepHz===0)return ni.STILL;const i=t.stepsBefore+t.stepHz*(e-t.startMs)/1e3,n=2*Math.PI*i,s=this.amplitudeAt(t,e),r=ni.SWAY_M*s*Math.cos(n/2),o=s*this.rotationPassed*t.speedMPerS/ni.REFERENCE_SPEED_M_PER_S;return{eastM:r*t.northUnit,northM:-r*t.eastUnit,upM:ni.RISE_M_PER_M_PER_S*t.speedMPerS*s*Math.cos(n),rollDeg:ni.HEAD_ROLL_DEG*o*Math.cos(n/2),pitchDeg:-1.25*o*Math.cos(n),yawDeg:ni.HEAD_YAW_DEG*o*Math.cos(n/2)}}amplitudeAt(e,t){const i=1e3/e.stepHz,n=Math.min(i,(e.endMs-e.startMs)/2);if(n<=0)return 1;const s=t-e.startMs,r=e.endMs-t,o=Math.min(e.rampsIn?s/n:1,e.rampsOut?r/n:1,1);return(1-Math.cos(Math.PI*Math.max(o,0)))/2}}class Rt{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/Rt.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(e,t,i){if(!(!e||!t))return{widthDeg:e.widthDeg+(t.widthDeg-e.widthDeg)*i,heightDeg:e.heightDeg+(t.heightDeg-e.heightDeg)*i}}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 I1(a,e,t){if(!a||!e)return t<1?a:e;const i=((e.azimuthDeg-a.azimuthDeg)%360+540)%360-180;return{azimuthDeg:((a.azimuthDeg+i*t)%360+360)%360,altitudeDeg:a.altitudeDeg+(e.altitudeDeg-a.altitudeDeg)*t}}function P1(a,e,t){const{bounds:i}=a;return e>=i.x&&e<=i.x+i.width&&t>=i.y&&t<=i.y+i.height}function Gi(a,e,t){return a+(e-a)*t}function A0(a){const e=/^#([0-9a-f]{6})$/i.exec(a);if(!e)return;const t=parseInt(e[1],16);return[t>>16&255,t>>8&255,t&255]}function L1(a){return`#${a.map(e=>Math.round(e).toString(16).padStart(2,"0")).join("")}`}function N1(a,e,t){const i=A0(a),n=A0(e);return!i||!n?t<1?a:e:L1([Gi(i[0],n[0],t),Gi(i[1],n[1],t),Gi(i[2],n[2],t)])}function O1(a,e,t){const i={x:Gi(a.bounds.x,e.bounds.x,t),y:Gi(a.bounds.y,e.bounds.y,t),width:Gi(a.bounds.width,e.bounds.width,t),height:Gi(a.bounds.height,e.bounds.height,t)},n=Gi(a.angle,e.angle,t),s=Gi(a.transparency,e.transparency,t),r=Gi(a.haloScale,e.haloScale,t),o=Gi(a.blur??0,e.blur??0,t),c=Gi(a.brightness??0,e.brightness??0,t),l=N1(a.color,e.color,t),h=Rt.lerpAngular(a.angular,e.angular,t),u=I1(a.aim,e.aim,t);return a.kind==="polygon"&&e.kind==="polygon"&&a.points.length===e.points.length?{...a,bounds:i,angle:n,transparency:s,haloScale:r,blur:o,brightness:c,color:l,angular:h,aim:u,points:a.points.map((d,f)=>({x:Gi(d.x,e.points[f].x,t),y:Gi(d.y,e.points[f].y,t)}))}:{...t<1?a:e,bounds:i,angle:n,transparency:s,haloScale:r,blur:o,brightness:c,color:l,angular:h,aim:u}}class gl{keyframes=[];order=[];groups=[];addKeyframe(e,t){const i=this.findInsertIndex(e);if(this.keyframes[i]?.t===e){const n=new Set(t.map(s=>s.sourceId));this.keyframes[i]={t:e,shapes:[...this.keyframes[i].shapes.filter(s=>!n.has(s.sourceId)),...t]}}else this.keyframes.splice(i,0,{t:e,shapes:[...t]});for(const n of t)this.order.includes(n.sourceId)||this.order.push(n.sourceId)}findInsertIndex(e){let t=0,i=this.keyframes.length;for(;t<i;){const n=t+i>>>1;this.keyframes[n].t<e?t=n+1:i=n}return t}getKeyframeAt(e){const t=this.findInsertIndex(e),i=this.keyframes[t];return i?.t===e?i:void 0}getShapeAt(e,t){return this.getKeyframeAt(e)?.shapes.find(i=>i.sourceId===t)?.shape}getLatestShapeAt(e,t){let i=this.findInsertIndex(e);for(this.keyframes[i]?.t!==e&&(i-=1);i>=0;i--){const n=this.keyframes[i].shapes.find(s=>s.sourceId===t);if(n)return n.shape}}getInterpolatedShapeAt(e,t){const i=this.findShapeAtOrBefore(e,t);if(i?.t===e)return i.shape;const n=this.findShapeAtOrAfter(e,t);return i?n?O1(i.shape,n.shape,(e-i.t)/(n.t-i.t)):i.shape:n?.shape}findShapeAtOrBefore(e,t){let i=this.findInsertIndex(e);for(this.keyframes[i]?.t!==e&&(i-=1);i>=0;i--){const n=this.keyframes[i].shapes.find(s=>s.sourceId===t);if(n)return{t:this.keyframes[i].t,shape:n.shape}}}findShapeAtOrAfter(e,t){for(let i=this.findInsertIndex(e);i<this.keyframes.length;i++){const n=this.keyframes[i].shapes.find(s=>s.sourceId===t);if(n)return{t:this.keyframes[i].t,shape:n.shape}}}hitTest(e,t,i,n){const s=this.sourceIds;for(let r=s.length-1;r>=0;r--){if(n?.has(s[r]))continue;const o=this.getInterpolatedShapeAt(e,s[r]);if(o&&P1(o,t,i))return{sourceId:s[r],shape:o}}}removeSource(e){for(let t=this.keyframes.length-1;t>=0;t--){const i=this.keyframes[t].shapes.filter(n=>n.sourceId!==e);i.length===0?this.keyframes.splice(t,1):i.length!==this.keyframes[t].shapes.length&&(this.keyframes[t]={t:this.keyframes[t].t,shapes:i})}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(i=>i.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(n=>n.includes(e));if(t===-1)return;const i=this.groups[t].filter(n=>n!==e);i.length<2?this.groups.splice(t,1):this.groups[t]=i}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 gl;for(const i of e.keyframes)t.addKeyframe(i.t,i.shapes);if(e.order){const i=t.order.filter(n=>!e.order.includes(n));t.order=[...e.order,...i]}return e.groups&&(t.groups=e.groups.map(i=>i.filter(n=>t.order.includes(n))).filter(i=>i.length>=2)),t}}function U1(a,e,t){return Math.max(e,Math.min(t,a))}function F1(a,e,t){const i=((e-a)%360+540)%360-180;return((a+i*t)%360+360)%360}function Ra(a,e,t){return a+(e-a)*t}function k1(a,e,t){return{lat:a.lat===void 0||e.lat===void 0?void 0:Ra(a.lat,e.lat,t),lng:a.lng===void 0||e.lng===void 0?void 0:Ra(a.lng,e.lng,t),elevationM:Ra(a.elevationM,e.elevationM,t),headingDeg:a.headingDeg===void 0||e.headingDeg===void 0?void 0:F1(a.headingDeg,e.headingDeg,t),pitchDeg:Ra(a.pitchDeg,e.pitchDeg,t),rollDeg:Ra(a.rollDeg??0,e.rollDeg??0,t),fovDeg:Ra(a.fovDeg,e.fovDeg,t),fNumber:a.fNumber,focusDistanceM:a.focusDistanceM}}class uo{keyframes=[];addKeyframe(e,t){const i=this.findInsertIndex(e);this.keyframes[i]?.t===e?this.keyframes[i]={t:e,pose:t}:this.keyframes.splice(i,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,i=this.keyframes.length;for(;t<i;){const n=t+i>>>1;this.keyframes[n].t<e?t=n+1:i=n}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),i=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(i?.t===e)return i.pose;const n=this.keyframes[t]?.t===e?void 0:this.keyframes[t];return i?n?k1(i.pose,n.pose,U1((e-i.t)/(n.t-i.t),0,1)):i.pose:n?.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 uo;for(const i of e.keyframes)t.addKeyframe(i.t,i.pose);return t}}function It(a,e,t){return a+(e-a)*t}function Ed(a,e,t){const i=((e-a)%360+540)%360-180;return((a+i*t)%360+360)%360}function z1(a,e,t){return Math.max(e,Math.min(t,a))}function H1(a=[],e=[],t){if(!(!a.length&&!e.length))return[...new Set([...a.map(i=>i.id),...e.map(i=>i.id)])].map(i=>{const n=a.find(c=>c.id===i),s=e.find(c=>c.id===i),r=n??{...s,density:0},o=s??{...n,density:0};return{...r,eastM:It(r.eastM,o.eastM,t),northM:It(r.northM,o.northM,t),baseM:It(r.baseM,o.baseM,t),thicknessM:It(r.thicknessM,o.thicknessM,t),widthM:It(r.widthM,o.widthM,t),depthM:It(r.depthM,o.depthM,t),rotationDeg:Ed(r.rotationDeg,o.rotationDeg,t),density:It(r.density,o.density,t),darkness:It(r.darkness??0,o.darkness??0,t)}})}function B1(a,e,t){if(a.cloudLayers===void 0&&e.cloudLayers===void 0)return;const i=Xc(a),n=Xc(e);return t>=1?n.map(r=>({...r})):[...new Set([...i.map(r=>r.id),...n.map(r=>r.id)])].map(r=>{const o=i.find(u=>u.id===r),c=n.find(u=>u.id===r),l=o??{...c,coverage:0},h=c??{...o,coverage:0};return{...l,instances:H1(o?.instances,c?.instances,t),baseM:It(l.baseM,h.baseM,t),thicknessM:It(l.thicknessM,h.thicknessM,t),coverage:It(l.coverage,h.coverage,t),sizeM:It(l.sizeM,h.sizeM,t),density:It(l.density,h.density,t),darkness:It(l.darkness??a.cloudDarkness,h.darkness??e.cloudDarkness,t),iceCrystalAlignment:l.iceCrystalAlignment===void 0||h.iceCrystalAlignment===void 0?void 0:It(l.iceCrystalAlignment,h.iceCrystalAlignment,t),windSpeed:l.windSpeed===void 0&&h.windSpeed===void 0?void 0:It(l.windSpeed??a.windSpeed,h.windSpeed??e.windSpeed,t),windDirectionDeg:l.windDirectionDeg===void 0&&h.windDirectionDeg===void 0?void 0:Ed(l.windDirectionDeg??a.windDirectionDeg,h.windDirectionDeg??e.windDirectionDeg,t)}})}function G1(a,e,t){return{cloudLayers:B1(a,e,t),cloudCover:It(a.cloudCover,e.cloudCover,t),cloudDarkness:It(a.cloudDarkness,e.cloudDarkness,t),highCloudCover:a.highCloudCover===void 0||e.highCloudCover===void 0?void 0:It(a.highCloudCover,e.highCloudCover,t),iceCrystalAlignment:a.iceCrystalAlignment===void 0||e.iceCrystalAlignment===void 0?void 0:It(a.iceCrystalAlignment,e.iceCrystalAlignment,t),lowerCloudCover:a.lowerCloudCover===void 0||e.lowerCloudCover===void 0?void 0:It(a.lowerCloudCover,e.lowerCloudCover,t),cloudBaseM:a.cloudBaseM===void 0||e.cloudBaseM===void 0?void 0:It(a.cloudBaseM,e.cloudBaseM,t),relativeHumidity:a.relativeHumidity===void 0||e.relativeHumidity===void 0?void 0:It(a.relativeHumidity,e.relativeHumidity,t),precipitationType:t<1?a.precipitationType:e.precipitationType,precipitationIntensity:It(a.precipitationIntensity,e.precipitationIntensity,t),windDirectionDeg:Ed(a.windDirectionDeg,e.windDirectionDeg,t),windSpeed:It(a.windSpeed,e.windSpeed,t),storm:t<1?a.storm:e.storm}}class fo{keyframes=[];addKeyframe(e,t){const i=this.findInsertIndex(e);this.keyframes[i]?.t===e?this.keyframes[i]={t:e,weather:t}:this.keyframes.splice(i,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,i=this.keyframes.length;for(;t<i;){const n=t+i>>>1;this.keyframes[n].t<e?t=n+1:i=n}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),i=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(i?.t===e)return i.weather;const n=this.keyframes[t]?.t===e?void 0:this.keyframes[t];return i?n?G1(i.weather,n.weather,z1((e-i.t)/(n.t-i.t),0,1)):i.weather:n?.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 fo;for(const i of e.keyframes)t.addKeyframe(i.t,i.weather);return t}}class po{keyframes=[];addKeyframe(e,t){const i=this.findInsertIndex(e);this.keyframes[i]?.t===e?this.keyframes[i]={t:e,sound:t}:this.keyframes.splice(i,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),i=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(i?.t===e)return i.sound;const n=this.keyframes[t]?.t===e?void 0:this.keyframes[t];if(!i)return n?.sound;if(!n)return i.sound;const s=(e-i.t)/(n.t-i.t);return this.lerp(i.sound,n.sound,Math.max(0,Math.min(1,s)))}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 po;for(const i of e.keyframes)t.addKeyframe(i.t,i.sound);return t}lerp(e,t,i){return{kind:i<1?e.kind:t.kind,volume:e.volume+(t.volume-e.volume)*i,pitchHz:e.pitchHz+(t.pitchHz-e.pitchHz)*i,src:i<1?e.src:t.src}}findInsertIndex(e){let t=0,i=this.keyframes.length;for(;t<i;){const n=t+i>>>1;this.keyframes[n].t<e?t=n+1:i=n}return t}}const V1=100,W1={kind:"none",volume:0,pitchHz:V1};class un{constructor(e){this.entries=e}static empty(){return new un(new Map)}get size(){return this.entries.size}at(e){return this.entries.get(e)}paths(){return[...this.entries.keys()]}set(e,t){t.basis==="stated"&&t.rationale===void 0?this.entries.delete(e):this.entries.set(e,t)}clear(e){for(const t of this.entries.keys())(t===e||t.startsWith(`${e}.`))&&this.entries.delete(t)}static strip(e){const t=new un(new Map);return{recording:un.stripValue(e,[],t),provenance:t}}static restore(e,t){if(t.size===0)return e;const i=structuredClone(e);for(const n of t.paths()){const s=t.at(n),r=n.split("."),o=un.holderOf(i,r);if(!o)continue;const c=r[r.length-1],l=o[c];l!==void 0&&(s.of!==void 0&&JSON.stringify(s.of)!==JSON.stringify(l)||(o[c]={value:l,...s.basis==="stated"?{}:{basis:s.basis},...s.rationale===void 0?{}:{rationale:s.rationale}}))}return i}static isWrapper(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"value"in e}static stripValue(e,t,i){return un.isWrapper(e)?(i.set(t.join("."),{basis:e.basis??"stated",...e.rationale===void 0?{}:{rationale:e.rationale},of:e.value}),un.stripValue(e.value,t,i)):Array.isArray(e)?e.map((n,s)=>un.stripValue(n,[...t,String(s)],i)):typeof e=="object"&&e!==null?Object.fromEntries(Object.entries(e).map(([n,s])=>[n,un.stripValue(s,[...t,n],i)])):e}static holderOf(e,t){let i=e;for(const n of t.slice(0,-1)){if(typeof i!="object"||i===null)return;i=i[n]}return typeof i=="object"&&i!==null?i:void 0}}function eu(a){if(a.year!==void 0)return Date.UTC(a.year,(a.month??1)-1,a.day??1,a.hour??0,a.minute??0,a.second??0)}function T0(a){return(((a.day??0)*24+(a.hour??0))*60+(a.minute??0))*6e4+(a.second??0)*1e3}const X1=["year","month","day","hour","minute"],q1=["day","hour","minute"];function R0(a,e){return e.filter(t=>a[t]!==void 0).join(",")}function Y1(a){if(a.durationSeconds!==void 0)return a.durationSeconds*1e3;if(!a.time||!a.endTime)return;const e=a.time.year!==void 0&&a.endTime.year!==void 0,t=e?X1:q1,i=R0(a.time,t);if(!(i===""||i!==R0(a.endTime,t)))return e?eu(a.endTime)-eu(a.time):T0(a.endTime)-T0(a.time)}class vl{constructor(e,t,i,n,s,r,o,c,l=[],h,u,d,f=[],p=[],v=[]){this.event=e,this.timeline=t,this.witnessTrack=i,this.weatherTrack=n,this.soundTrack=s,this.witness=r,this.id=o,this.weather=c,this.decor=l,this.weatherSource=h,this.instrumentId=u,this.exposureSeconds=d,this.milestones=f,this.references=p,this.roads=v}provenance=un.empty();testimony;interpretation;get witnessCount(){return 1+this.decor.filter(e=>e.kind==="witness").length}get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return ai.byId(this.instrumentId)}static create(e,t,i){return new vl({eventType:"sighting",time:e,place:t},new gl,new uo,new fo,new po,i)}}const K1=0,$1=0;function si(a,e){const t=a.witnessTrack.getInterpolatedPoseAt(e);if(t)return t;const i=a.event.place?.[0];if(i)return{lat:i.lat,lng:i.lng,elevationM:K1,headingDeg:void 0,pitchDeg:$1,fovDeg:ai.fieldOfViewDeg(a.instrument)}}function Js(a,e){return a.weatherTrack.getInterpolatedWeatherAt(e)??a.weather??Pm}function Z1(a,e){return a.soundTrack.getInterpolatedSoundAt(e)??W1}class J1{constructor(e,t){this.timeline=e,this.onFrame=t}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;onEnded;durationOverrideMs=0;get seekableDuration(){return Math.max(this.timeline.duration,this.durationOverrideMs)}play(){if(this.state==="playing")return;this.currentT>=this.seekableDuration&&(this.currentT=0,this.resolveFrame(0)),this.state="playing",this.lastWallTime=performance.now();const e=()=>{if(this.state!=="playing")return;const t=performance.now();if(this.currentT+=(t-this.lastWallTime)*this.playbackRate,this.lastWallTime=t,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(e);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT),this.onEnded?.();return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(e)};this.rafId=requestAnimationFrame(e)}pause(){this.state==="playing"&&(this.state="paused",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null))}stop(){this.state="stopped",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}seek(e){this.currentT=Math.max(0,Math.min(e,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(e){const t=new Map;for(const i of this.timeline.sourceIds){const n=this.timeline.getInterpolatedShapeAt(e,i);n&&t.set(i,n)}this.onFrame(e,t)}}const Om=["nw","n","ne","e","se","s","sw","w"],j1=24,Lo=8,Q1=3,e2=8;function No(a,e,t){const i=a.x-e.x,n=a.y-e.y,s=Math.cos(t),r=Math.sin(t);return{x:e.x+i*s-n*r,y:e.y+i*r+n*s}}function Ar(a){return{x:a.x+a.width/2,y:a.y+a.height/2}}const t2={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 ji{static handlePointsFor(e){const{x:t,y:i,width:n,height:s}=e.bounds,r={nw:{x:t,y:i},n:{x:t+n/2,y:i},ne:{x:t+n,y:i},e:{x:t+n,y:i+s/2},se:{x:t+n,y:i+s},s:{x:t+n/2,y:i+s},sw:{x:t,y:i+s},w:{x:t,y:i+s/2},rotate:{x:t+n/2,y:i-j1}},o=Ar(e.bounds),c={};for(const l of Object.keys(r))c[l]=No(r[l],o,e.angle);return c}static hitTestHandle(e,t,i=8,n=[...Om,"rotate"]){const s=ji.handlePointsFor(e);for(const r of n)if(Math.hypot(t.x-s[r].x,t.y-s[r].y)<=i)return r}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 n=((ji.HANDLE_DIRECTION_DEG[e]+t*180/Math.PI)%180+180)%180/45,s=["ew","nwse","ns","nesw"];return s[Math.round(n)%s.length]}static resizeBounds(e,t,i,n){const s=Ar(e),r=No(n,s,-t),{x:o,y:c,width:l,height:h}=e,u=t2[i];let d=o,f=c,p=o+l,v=c+h;return u.left&&(d=Math.min(r.x,p-Lo)),u.right&&(p=Math.max(r.x,d+Lo)),u.top&&(f=Math.min(r.y,v-Lo)),u.bottom&&(v=Math.max(r.y,f+Lo)),{x:d,y:f,width:p-d,height:v-f}}static resizeShape(e,t,i){if(t==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:n,height:s}=e.bounds,r=ji.resizeBounds(e.bounds,e.angle,t,i);if(e.kind==="oval")return{...e,bounds:r};const o=n===0?1:r.width/n,c=s===0?1:r.height/s;return{...e,bounds:r,points:e.points.map(l=>({x:l.x*o,y:l.y*c}))}}static rotateShape(e,t){const i=Ar(e.bounds),n=Math.atan2(t.y-i.y,t.x-i.x)+Math.PI/2;return{...e,angle:n}}static groupBoundsFor(e){const t=Math.min(...e.map(r=>r.x)),i=Math.min(...e.map(r=>r.y)),n=Math.max(...e.map(r=>r.x+r.width)),s=Math.max(...e.map(r=>r.y+r.height));return{x:t,y:i,width:n-t,height:s-i}}static vertexPointsFor(e){const t=Ar(e.bounds);return e.points.map(i=>No({x:e.bounds.x+i.x,y:e.bounds.y+i.y},t,e.angle))}static hitTestVertex(e,t,i=e2){const n=ji.vertexPointsFor(e);let s,r=i;return n.forEach((o,c)=>{const l=Math.hypot(t.x-o.x,t.y-o.y);l<=r&&(r=l,s=c)}),s}static toLocalPoint(e,t){const i=Ar(e.bounds),n=No(t,i,-e.angle);return{x:n.x-e.bounds.x,y:n.y-e.bounds.y}}static moveVertex(e,t,i){const n=e.points.map((u,d)=>d===t?ji.toLocalPoint(e,i):u),s=Math.min(...n.map(u=>u.x)),r=Math.min(...n.map(u=>u.y)),o=Math.max(...n.map(u=>u.x)),c=Math.max(...n.map(u=>u.y)),l={x:e.bounds.x+s,y:e.bounds.y+r,width:o-s,height:c-r},h=n.map(u=>({x:u.x-s,y:u.y-r}));return{...e,bounds:l,points:h}}static insertVertexNear(e,t){const i=ji.toLocalPoint(e,t),{points:n}=e;let s=n.length-1,r=1/0;for(let c=0;c<n.length;c++){const l=n[c],h=n[(c+1)%n.length],u=ji.distanceToSegment(i,l,h);u<r&&(r=u,s=c)}const o=[...n.slice(0,s+1),i,...n.slice(s+1)];return{...e,points:o}}static distanceToSegment(e,t,i){const n=i.x-t.x,s=i.y-t.y,r=n*n+s*s,o=r===0?0:Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*s)/r)),c=t.x+o*n,l=t.y+o*s;return Math.hypot(e.x-c,e.y-l)}static deleteVertex(e,t){return e.points.length<=Q1?e:{...e,points:e.points.filter((i,n)=>n!==t)}}}const tu=6,Oo=tu/2,D0=20,C0=24,I0=9,P0=6,L0=7,N0=6,On=4;class mo{constructor(e){this.ctx=e}starPoints=0;roll=0;clear(e,t){this.ctx.clearRect(0,0,e,t)}static paintExtent(e){const{x:t,y:i,width:n,height:s}=e.bounds,r=t+n/2,o=i+s/2,c=e.angle%(2*Math.PI)!==0,l=Math.hypot(n,s)/2,h=c?l:n/2,u=c?l:s/2,d=Math.max(n,s)/2,f=e.brightness??0,p=f>0?Math.max(d*(1+I0*f),N0*f)-d:0,v=f>0?d*(1+L0*f)-d:0,m=3*C0*(e.blur??0)+1.5*D0*e.haloScale,g=Math.max(p,v,0)+m+2;return{x:r-h-g,y:o-u-g,width:2*(h+g),height:2*(u+g)}}paintInto(e,t,i,n=!1){this.ctx.save(),this.ctx.scale(i,i),this.ctx.translate(-t.x,-t.y);const s=e.selected?{...e,selected:!1}:e;n?this.paintGhost(s,1.5):this.paintShape(s),this.ctx.restore()}paintShape(e){this.ctx.save(),this.ctx.globalAlpha=1-e.transparency;const t=e.blur??0;t>0&&(this.ctx.filter=`blur(${(C0*t).toFixed(2)}px)`);const i=e.brightness??0;i>0&&this.paintDazzle(e,i),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:i,y:n,width:s,height:r}=e.bounds,o=i+s/2,c=n+r/2,l=Math.max(s,r)/2,h=Math.max(l*(1+I0*t),N0*t);if(h<=0)return;this.ctx.save(),this.ctx.globalCompositeOperation="lighter";const u=this.ctx.createRadialGradient(o,c,0,o,c,h);for(let d=0;d<=P0;d++){const f=d/P0,p=1/(1+24*f*f);this.ctx.globalAlpha=1,u.addColorStop(f,this.withAlpha(e.color,p*t*.55))}if(this.ctx.fillStyle=u,this.ctx.beginPath(),this.ctx.arc(o,c,h,0,2*Math.PI),this.ctx.fill(),this.starPoints>0){const d=l*(1+L0*t);this.ctx.lineWidth=Math.max(1,l*.12),this.ctx.lineCap="round";for(let f=0;f<this.starPoints;f++){const p=f/this.starPoints*Math.PI*2+this.roll,v=o+Math.cos(p)*d,m=c+Math.sin(p)*d,g=this.ctx.createLinearGradient(o,c,v,m);g.addColorStop(0,this.withAlpha(e.color,t*.55)),g.addColorStop(.35,this.withAlpha(e.color,t*.22)),g.addColorStop(1,this.withAlpha(e.color,0)),this.ctx.strokeStyle=g,this.ctx.beginPath(),this.ctx.moveTo(o,c),this.ctx.lineTo(v,m),this.ctx.stroke()}}this.ctx.restore()}dazzledFill(e,t){if(t<=0)return e.color;const i=/^#([0-9a-f]{6})$/i.exec(e.color.trim());if(!i)return e.color;const n=Number.parseInt(i[1],16),s=r=>Math.round(r+(255-r)*t);return`rgb(${s(n>>16&255)}, ${s(n>>8&255)}, ${s(n&255)})`}withAlpha(e,t){const i=Math.max(0,Math.min(1,t)),n=/^#([0-9a-f]{6})$/i.exec(e.trim());if(!n)return e;const s=Number.parseInt(n[1],16);return`rgba(${s>>16&255}, ${s>>8&255}, ${s&255}, ${i.toFixed(3)})`}paintBase(e){this.ctx.fillStyle=this.dazzledFill(e,e.brightness??0),this.tracePath(e),this.ctx.fill()}paintGhost(e,t){this.ctx.save(),this.tracePath(e),this.ctx.setLineDash([t*3,t*2]),this.ctx.lineWidth=t,this.ctx.strokeStyle=e.color,this.ctx.stroke(),this.ctx.restore()}tracePath(e){if(this.ctx.beginPath(),e.kind==="oval"){const{x:t,y:i,width:n,height:s}=e.bounds,r=n/2,o=s/2;this.ctx.ellipse(t+r,i+o,r,o,e.angle,0,2*Math.PI)}else{const{x:t,y:i,width:n,height:s}=e.bounds;this.ctx.save(),this.ctx.translate(t+n/2,i+s/2),this.ctx.rotate(e.angle),this.ctx.translate(-n/2,-s/2),e.points.forEach((r,o)=>{o===0?this.ctx.moveTo(r.x,r.y):this.ctx.lineTo(r.x,r.y)}),this.ctx.closePath(),this.ctx.restore()}}paintHalo(e){this.ctx.save(),this.ctx.shadowColor=e.color,this.ctx.shadowBlur=D0*e.haloScale,this.paintBase(e),this.ctx.restore()}paintSelectionHandles(e){this.paintHandleFrame(ji.handlePointsFor(e),{includeRotate:!0}),e.kind==="polygon"&&this.paintVertexHandles(e)}paintVertexHandles(e){this.ctx.fillStyle="#39f";for(const t of ji.vertexPointsFor(e))this.ctx.beginPath(),this.ctx.ellipse(t.x,t.y,On,On,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(e){this.paintOutline(ji.handlePointsFor(e))}paintSelectionOnly(e){this.paintSelectionHandles(e)}paintPictureFrame(e,t,i){const n=this.ctx;if(n.save(),e&&e.length===4){n.strokeStyle="#39f",n.lineWidth=1.5,n.setLineDash([6,4]),n.beginPath(),n.moveTo(e[0].x,e[0].y);for(const s of e.slice(1))n.lineTo(s.x,s.y);n.closePath(),n.stroke(),n.setLineDash([])}for(const s of t){const r=mo.landmarkColour(s.residualDeg),o=s.selected?3:2;s.selected&&(n.strokeStyle="#fff",n.lineWidth=o+3,n.beginPath(),n.ellipse(s.picture.x,s.picture.y,On+2,On+2,0,0,2*Math.PI),n.stroke()),s.scene&&(n.strokeStyle=r,n.lineWidth=1,n.beginPath(),n.moveTo(s.picture.x,s.picture.y),n.lineTo(s.scene.x,s.scene.y),n.stroke(),n.fillStyle=r,n.beginPath(),n.ellipse(s.scene.x,s.scene.y,On,On,0,0,2*Math.PI),n.fill()),n.strokeStyle=r,n.lineWidth=o,n.beginPath(),n.ellipse(s.picture.x,s.picture.y,On+2,On+2,0,0,2*Math.PI),n.stroke(),this.paintLabel(s.label,s.picture.x+On+5,s.picture.y-On-2,r)}i&&this.paintLabel(i,8,8,"#fff",13),n.restore()}static landmarkColour(e){return e===void 0?"#ffb000":e<=1?"#3c3":e<=3?"#ffb000":"#f33"}paintLabel(e,t,i,n,s=11){const r=this.ctx;r.save(),r.font=`${s}px system-ui, sans-serif`,r.textBaseline="top";const o=r.measureText(e).width;r.fillStyle="rgba(0, 0, 0, 0.6)",r.fillRect(t-3,i-2,o+6,s+4),r.fillStyle=n,r.fillText(e,t,i),r.restore()}paintGroupHandles(e){this.paintHandleFrame(ji.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 i of Om){const n=e[i];this.ctx.fillRect(n.x-Oo,n.y-Oo,tu,tu)}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,Oo+1,Oo+1,0,0,2*Math.PI),this.ctx.fill())}}const O0=.05,U0=.08,F0=2,k0=3,i2=14,n2=.02;class s2{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 i=++this.voiceToken;t.startsWith("src:")?this.buildRecordedVoice(e.src,t,i):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 i=this.context;if(!e||!i)return;const n=i.currentTime;e.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,t.volume))*e.gainScale,n,O0);for(const{param:s,ratio:r}of e.pitch)s.setTargetAtTime(Math.min(t.pitchHz*r,i.sampleRate/2-1),n,O0)}buildSynthesizedVoice(e,t){const i=this.context;if(i)switch(e.kind){case"hum":return this.buildHum(i,t);case"whistle":return this.buildWhistle(i,t);case"rumble":return this.buildRumble(i,t);case"crackle":return this.buildCrackle(i,t);default:return}}buildHum(e,t){const i=e.createOscillator();i.type="sawtooth";const n=e.createOscillator();n.type="sawtooth";const s=e.createBiquadFilter();s.type="lowpass",s.Q.value=1;const r=e.createGain();return r.gain.value=0,i.connect(s),n.connect(s),s.connect(r).connect(e.destination),i.start(),n.start(),{key:t,nodes:[s,r],sources:[i,n],volumeParam:r.gain,gainScale:.16,pitch:[{param:i.frequency,ratio:1},{param:n.frequency,ratio:1.006},{param:s.frequency,ratio:6}]}}buildWhistle(e,t){const i=e.createOscillator();i.type="sine";const n=e.createOscillator();n.type="sine",n.frequency.value=5;const s=e.createGain(),r=e.createGain();return r.gain.value=0,n.connect(s).connect(i.frequency),i.connect(r).connect(e.destination),i.start(),n.start(),{key:t,nodes:[s,r],sources:[i,n],volumeParam:r.gain,gainScale:.22,pitch:[{param:i.frequency,ratio:1},{param:s.gain,ratio:.012}]}}buildRumble(e,t){const i=e.createBufferSource();i.buffer=this.brownNoise(e),i.loop=!0;const n=e.createBiquadFilter();n.type="lowpass",n.Q.value=.8;const s=e.createGain();return s.gain.value=0,i.connect(n).connect(s).connect(e.destination),i.start(),{key:t,nodes:[n,s],sources:[i],volumeParam:s.gain,gainScale:1.4,pitch:[{param:n.frequency,ratio:1}]}}buildCrackle(e,t){const i=e.createBufferSource();i.buffer=this.whiteNoise(e),i.loop=!0;const n=e.createBiquadFilter();n.type="bandpass",n.Q.value=1.2;const s=e.createGain();s.gain.value=0;const r=e.createBufferSource();r.buffer=this.crackleEnvelope(e),r.loop=!0;const o=e.createGain();return o.gain.value=0,r.connect(o).connect(s.gain),i.connect(n).connect(s).connect(e.destination),i.start(),r.start(),{key:t,nodes:[n,s,o],sources:[i,r],volumeParam:o.gain,gainScale:.9,pitch:[{param:n.frequency,ratio:4}]}}async buildRecordedVoice(e,t,i){const n=this.context;if(!n)return;let s;try{s=await this.getBuffer(e)}catch(c){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",c);return}if(i!==this.voiceToken||!this.context)return;const r=n.createBufferSource();r.buffer=s,r.loop=!0;const o=n.createGain();o.gain.value=0,r.connect(o).connect(n.destination),r.start(),this.voice={key:t,nodes:[o],sources:[r],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 i=this.buffers.get(e);return i||(i=fetch(e).then(n=>{if(!n.ok)throw new Error(`Audio fetch failed (${n.status}): ${e}`);return n.arrayBuffer()}).then(n=>t.decodeAudioData(n)),this.buffers.set(e,i)),i}whiteNoise(e){if(!this.noiseBuffer){const t=e.createBuffer(1,Math.floor(e.sampleRate*F0),e.sampleRate),i=t.getChannelData(0);for(let n=0;n<i.length;n++)i[n]=Math.random()*2-1;this.noiseBuffer=t}return this.noiseBuffer}brownNoise(e){const t=e.createBuffer(1,Math.floor(e.sampleRate*F0),e.sampleRate),i=t.getChannelData(0);let n=0,s=0;for(let r=0;r<i.length;r++)n=(n+.02*(Math.random()*2-1))/1.02,i[r]=n,s=Math.max(s,Math.abs(n));if(s>0)for(let r=0;r<i.length;r++)i[r]/=s;return t}crackleEnvelope(e){if(!this.crackleBuffer){const t=e.createBuffer(1,Math.floor(e.sampleRate*k0),e.sampleRate),i=t.getChannelData(0),n=Math.max(1,Math.floor(n2*e.sampleRate)),s=Math.round(k0*i2);for(let r=0;r<s;r++){const o=Math.floor(Math.random()*i.length),c=.4+Math.random()*.6;for(let l=0;l<n&&o+l<i.length;l++)i[o+l]=Math.max(i[o+l],c*(1-l/n))}this.crackleBuffer=t}return this.crackleBuffer}stopVoice(){const e=this.voice,t=this.context;if(this.voice=void 0,!e||!t)return;const i=t.currentTime;e.volumeParam.cancelScheduledValues(i),e.volumeParam.setTargetAtTime(0,i,U0/3);const n=i+U0;for(const s of e.sources){s.onended=()=>{s.disconnect();for(const r of e.nodes)r.disconnect()};try{s.stop(n)}catch{s.disconnect();for(const r of e.nodes)r.disconnect()}}}}function Yc(a){return[...a].sort((e,t)=>e.t-t.t)}function z0(a,e){let t;for(const i of Yc(a)){if(i.t>e)break;t=i}return t}const Nl=Math.PI/180,Uo=180/Math.PI;class ps{constructor(e,t,i){this.kind=e,this.canvasHeightPx=t,this.fovDeg=i;const n=i*Nl/2;this.focalPx=e==="equidistant"?t/2/n:t/2/Math.tan(n)}focalPx;static of(e,t,i){return new ps(e.projection,t,i)}degToPx(e){const t=e*Nl;return this.kind==="equidistant"?this.focalPx*t:2*this.focalPx*Math.tan(t/2)}pxToDeg(e){return this.kind==="equidistant"?e/this.focalPx*Uo:2*Math.atan(e/(2*this.focalPx))*Uo}angleDegToRadiusPx(e){const t=e*Nl;return this.kind==="equidistant"?this.focalPx*t:this.focalPx*Math.tan(t)}halfWidthAngleDeg(e){return this.radiusPxToAngleDeg(this.canvasHeightPx*e/2)}radiusPxToAngleDeg(e){return this.kind==="equidistant"?e/this.focalPx*Uo:Math.atan(e/this.focalPx)*Uo}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(Rt.angularWidthDeg(e))}}class Wi{static fovOf(e,t){return si(e,t)?.fovDeg??ai.fieldOfViewDeg(e.instrument)}static toAngular(e){this.eachKeyframe(e,(t,i)=>({...t,angular:i.ofBounds(t.bounds)}))}static toBounds(e){this.eachKeyframe(e,(t,i)=>{if(!t.angular)return t;const{width:n,height:s}=i.toBoundsSize(t.angular),r={x:t.bounds.x+(t.bounds.width-n)/2,y:t.bounds.y+(t.bounds.height-s)/2,width:n,height:s};if(t.kind!=="polygon")return{...t,bounds:r};const o=t.bounds.width===0?1:n/t.bounds.width,c=t.bounds.height===0?1:s/t.bounds.height;return{...t,bounds:r,points:t.points.map(l=>({x:l.x*o,y:l.y*c}))}})}static toAim(e){this.eachKeyframe(e,(t,i,n)=>{const s=t.aim&&this.positionOf(e,t.aim,t.bounds,i,n);if(s&&Math.abs(s.x-t.bounds.x)<Wi.UNMOVED_PX&&Math.abs(s.y-t.bounds.y)<Wi.UNMOVED_PX)return t;const r=this.aimFrom(e,i,n,t.bounds);return r?{...t,aim:r}:t})}static UNMOVED_PX=.01;static aimOf(e,t,i){const n=ps.of(e.instrument,Rt.CANVAS_HEIGHT_PX,this.fovOf(e,t));return this.aimFrom(e,n,si(e,t),i)}static aimFrom(e,t,i,n){if(i?.headingDeg===void 0)return;const s=this.frameCentre(e),r=t.radiusPxToAngleDeg(n.x+n.width/2-s.x),o=t.radiusPxToAngleDeg(s.y-(n.y+n.height/2));return{azimuthDeg:((i.headingDeg+r)%360+360)%360,altitudeDeg:i.pitchDeg+o}}static toPosition(e){this.eachKeyframe(e,(t,i,n)=>{const s=t.aim&&this.positionOf(e,t.aim,t.bounds,i,n);return s?{...t,bounds:{...t.bounds,...s}}:t})}static positionOf(e,t,i,n,s){if(s?.headingDeg===void 0)return;const r=this.frameCentre(e),o=this.shortestArc(t.azimuthDeg-s.headingDeg),c=t.altitudeDeg-s.pitchDeg;return{x:r.x+this.offAxisPx(n,o)-i.width/2,y:r.y-this.offAxisPx(n,c)-i.height/2}}static frameCentre(e){return{x:ai.frameWidthPx(e.instrument,Rt.CANVAS_HEIGHT_PX)/2,y:Rt.CANVAS_HEIGHT_PX/2}}static shortestArc(e){return(e%360+540)%360-180}static offAxisPx(e,t){return Math.abs(t)>=Wi.OFF_CANVAS_DEG?Math.sign(t)*Wi.OFF_CANVAS_PX:e.angleDegToRadiusPx(t)}static OFF_CANVAS_DEG=89;static OFF_CANVAS_PX=1e5;static reproject(e,t,i){const n=ai.frameWidthPx(t,Rt.CANVAS_HEIGHT_PX)/2,s=ai.frameWidthPx(e.instrument,Rt.CANVAS_HEIGHT_PX)/2,r=Rt.CANVAS_HEIGHT_PX/2;for(const o of[...e.timeline.allKeyframes]){const c=this.fovOf(e,o.t),l=i?.get(o.t)??c,h=ps.of(t,Rt.CANVAS_HEIGHT_PX,l),u=ps.of(e.instrument,Rt.CANVAS_HEIGHT_PX,c);e.timeline.addKeyframe(o.t,o.shapes.map(d=>{const{bounds:f}=d.shape,p=f.x+f.width/2-n,v=f.y+f.height/2-r,m=Math.hypot(p,v),g=m===0?1:u.angleDegToRadiusPx(h.radiusPxToAngleDeg(m))/m,_={...f,x:s+p*g-f.width/2,y:r+v*g-f.height/2};return{...d,shape:{...d.shape,bounds:_}}}))}this.toBounds(e)}static eachKeyframe(e,t){const{timeline:i}=e;for(const n of[...i.allKeyframes]){const s=si(e,n.t),r=this.fovOf(e,n.t),o=ps.of(e.instrument,Rt.CANVAS_HEIGHT_PX,r);i.addKeyframe(n.t,n.shapes.map(c=>({...c,shape:t(c.shape,o,s)})))}}}function a2(a){return un.restore(r2(a),a.provenance)}function r2(a){return Wi.toAngular(a),Wi.toAim(a),{version:1,id:a.id,time:a.event.time,endTime:a.event.endTime,durationSeconds:a.event.durationSeconds,utcOffsetHours:a.event.utcOffsetHours,timeZone:a.event.timeZone,place:a.event.place,witness:a.witness,testimony:a.testimony,description:a.event.description,tags:a.event.tags,timeline:a.timeline.toJSON(),witnessTrack:a.witnessTrack.toJSON(),weatherTrack:a.weatherTrack.toJSON(),soundTrack:a.soundTrack.toJSON(),weather:a.weather,decor:a.decor,milestones:a.milestones.length>0?a.milestones:void 0,references:a.references.length>0?a.references:void 0,roads:a.roads.length>0?a.roads:void 0,weatherSource:a.weatherSource,instrument:a.instrumentId,exposureSeconds:a.exposureSeconds,interpretation:a.interpretation}}function o2(a){const{recording:e,provenance:t}=un.strip(a),i=c2(e);return i.provenance=t,i}function c2(a){const e=new vl({eventType:"sighting",time:a.time,endTime:a.endTime,durationSeconds:a.durationSeconds,utcOffsetHours:a.utcOffsetHours,timeZone:a.timeZone,place:a.place,description:a.description,tags:a.tags},gl.fromJSON(a.timeline),a.witnessTrack?uo.fromJSON(a.witnessTrack):new uo,a.weatherTrack?fo.fromJSON(a.weatherTrack):new fo,a.soundTrack?po.fromJSON(a.soundTrack):new po,a.witness&&{id:a.witness.id,title:a.witness.title,lastName:a.witness.lastName,firstNames:a.witness.firstNames},a.id,a.weather,a.decor??[],a.weatherSource,a.instrument,a.exposureSeconds??a.witnessTrack?.keyframes.map(t=>t.pose.exposureSeconds).find(t=>t!==void 0),Yc(a.milestones??[]),a.references??[],a.roads??[]);return e.testimony=a.testimony,e.interpretation=a.interpretation,Wi.toBounds(e),Wi.toPosition(e),e}const H0=2;function Um(a){return a==="building"||a==="vehicle"}function l2(a,e){const t=a.litKeyframes;if(!t||t.length===0)return a.lit??!1;let i=t[0];for(const n of t){if(n.t>e)break;i=n}return i.lit}function h2(a,e){return a.pattern.kind==="steady"?!0:Fm(a,e,e+1)>.5}function Fm(a,e,t){if(a.pattern.kind==="steady")return 1;const{perMinute:i,dutyCycle:n,phase:s=0}=a.pattern,r=Math.min(Math.max(n,0),1);if(r===0||i<=0)return 0;const o=6e4/i,c=e/o+s,l=t/o+s;if(l<=c)return Math.min(Math.max(c-Math.floor(c),0),r)<r?1:0;const h=u=>Math.floor(u)*r+Math.min(u-Math.floor(u),r);return(h(l)-h(c))/(l-c)}function Ad(a,e){const t=a.track,i={eastM:a.eastM,northM:a.northM,altitudeM:0,headingDeg:a.headingDeg};if(!t||t.length===0)return i;if(t.length===1||e<=t[0].t)return B0(t[0],a);const n=t[t.length-1];if(e>=n.t)return B0(n,a);for(let s=0;s<t.length-1;s++){const r=t[s],o=t[s+1];if(e<r.t||e>o.t)continue;const c=o.t-r.t,l=c===0?0:(e-r.t)/c;return{eastM:r.eastM+(o.eastM-r.eastM)*l,northM:r.northM+(o.northM-r.northM)*l,altitudeM:(r.altitudeM??0)+((o.altitudeM??0)-(r.altitudeM??0))*l,headingDeg:r.headingDeg??a.headingDeg}}return i}function B0(a,e){return{eastM:a.eastM,northM:a.northM,altitudeM:a.altitudeM??0,headingDeg:a.headingDeg??e.headingDeg}}class bn{static PIXELS_PER_INSTANT=2;static INSTANTS_PER_FLASH=2;static MAX_INSTANTS=512;static windowEndingAt(e,t){const i=Number.isFinite(t)?Math.max(0,t):0,n=Math.max(0,e-i*1e3),s=Math.max(0,e-n);return{fromMs:n,toMs:e,ms:s,seconds:s/1e3}}static instants(e,t,i,n,s){if(!(n>0))return 1;const r=s>0?bn.travelDegOver(e,t,i,i+n*1e3)/s/bn.PIXELS_PER_INSTANT:0,o=bn.flashesOver(e,n)*bn.INSTANTS_PER_FLASH,c=Math.ceil(Math.max(r,o));return c<2?1:Math.min(bn.MAX_INSTANTS,c)}static travelDegOver(e,t,i,n){let s=0;for(const r of e){if(!r.track||r.track.length<2)continue;const o=bn.directionAt(r,t,i),c=bn.directionAt(r,t,n),l=Math.min(1,Math.max(-1,o.x*c.x+o.y*c.y+o.z*c.z));s=Math.max(s,Math.acos(l)*180/Math.PI)}return s}static flashesOver(e,t){let i=0;for(const n of e)for(const s of n.lights??[])s.pattern.kind==="flash"&&(i=Math.max(i,s.pattern.perMinute));return i/60*t}static directionAt(e,t,i){const n=Ad(e,i),s=n.eastM,r=n.altitudeM-t,o=n.northM,c=Math.hypot(s,r,o);return c===0?{x:0,y:1,z:0}:{x:s/c,y:r/c,z:o/c}}}function Td(a,e){for(const t of a){const i=t.toLowerCase().split("-")[0];if(e.includes(i))return i}return"en"}class Kc{static preferencesFor(e){const t=navigator.languages??[],i=this.declaredFor(e);return i?[i,...t]:t}static declaredFor(e){for(let t=e;t;){const i=t.closest("[lang]")?.getAttribute("lang")?.trim();if(i)return i;const n=t.getRootNode();t=n instanceof ShadowRoot?n.host:void 0}}}class ks{constructor(e){this.preferences=e}read(e){if(e===void 0||typeof e=="string")return e===""?void 0:e;for(const i of this.preferences){const n=e[i]??e[ks.base(i)];if(n)return n}const t=new Set(this.preferences.map(i=>ks.base(i)));for(const[i,n]of Object.entries(e))if(n&&t.has(ks.base(i)))return n;return Object.values(e).find(i=>i)??void 0}write(e,t,i){const n=t?.trim()?t.trim():void 0;if(e===void 0||typeof e=="string")return n;const s={...e},r=Object.keys(s).find(o=>o===i)??Object.keys(s).find(o=>ks.base(o)===ks.base(i))??i;return n===void 0?delete s[r]:s[r]=n,Object.keys(s).length===0?void 0:s}static base(e){return e.toLowerCase().split("-")[0]}}const u2=["en","fr"],d2={en:()=>Wc(()=>Promise.resolve().then(()=>p2),void 0,import.meta.url).then(a=>a.ufoMessages_en),fr:()=>Wc(()=>import("./UfoMessages_fr-CnenjNH2.js"),[],import.meta.url).then(a=>a.ufoMessages_fr)};function f2(a){return d2[a]()}const km={play:"Play",pause:"Pause",noDuration:"No observation duration",currentPosition:"Current position",duration:"Duration",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",showWitnessMap:"Show where the witness was",hideWitnessMap:"Hide where the witness was",mapImageryUnavailable:"Aerial imagery unavailable",showReferences:"Show the pictures of the place",hideReferences:"Hide the pictures of the place",referenceOpacity:"Picture opacity",showMilestones:"Show the account's moments",hideMilestones:"Hide the account's moments",witnessHere:"The witness, here",decorHere:"Scenery"},p2=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:km},Symbol.toStringTag,{value:"Module"})),zm=Math.PI/180,m2=180/Math.PI,g2=256,Hm=19,v2=1.25;function Bm(a,e){return 156543.03392*Math.cos(a*zm)/2**e}function Gm(a,e){return Bm(a,e)*g2}function M2(a,e){let t=0;for(;t<Hm&&Gm(a,t+1)>=e;)t++;return t}function Vm(a,e){return Gm(a,e)}function x2(a,e){const t=e*v2;let i=0;for(;i<Hm&&Bm(a,i)>t;)i++;return i}function Nc(a){const e=a*zm;return(1-Math.log(Math.tan(e)+1/Math.cos(e))/Math.PI)/2}function Wm(a,e,t){const i=2**t;return{x:(a+180)/360*i,y:Nc(e)*i}}function Xm(a,e,t){const i=Nc(a.north),n=Nc(a.south);return{x:(e-a.west)/(a.east-a.west),y:(Nc(t)-i)/(n-i)}}function y2(a,e,t){const{x:i,y:n}=Wm(a,e,t);return{x:Math.floor(i),y:Math.floor(n),z:t}}function _2(a){const e=2**a.z,t=a.x/e*360-180,i=(a.x+1)/e*360-180,n=G0(a.y,e);return{south:G0(a.y+1,e),north:n,west:t,east:i}}function G0(a,e){const t=a/e;return Math.atan(Math.sinh(Math.PI*(1-2*t)))*m2}function qm(a,e,t,i){const n=y2(a,e,t),s=Math.floor(i/2),r=[];for(let l=-s;l<=s;l++)for(let h=-s;h<=s;h++)r.push({x:n.x+h,y:n.y+l,z:t});const o=r.map(_2),c={south:Math.min(...o.map(l=>l.south)),north:Math.max(...o.map(l=>l.north)),west:Math.min(...o.map(l=>l.west)),east:Math.max(...o.map(l=>l.east))};return{tiles:r,bounds:c}}class aa{constructor(e){this.ctx=e}static SCALE_STEPS_M=[5e3,2e3,1e3,500,200,100,50,20,10,5];static MARKER_RADIUS_PX=8.5;static ON_MARKER_M=3;targets=[];hitTest(e,t){let i,n=1/0;for(const s of this.targets){const r=Math.hypot(s.x-e,s.y-t);r>s.radius||r>n||(i=s,n=r)}return i}get width(){return this.ctx.canvas.width}get height(){return this.ctx.canvas.height}paint(e){const{ctx:t}=this;t.save(),this.targets=[],t.clearRect(0,0,this.width,this.height),this.paintGround(e),this.paintNight(e.nightFraction),this.paintPath(e),e.position?(this.paintCone(e,e.position),this.paintDecor(e),this.paintMarkers(e),this.paintWitness(e,e.position)):(this.paintDecor(e),this.paintMarkers(e)),this.paintNorth(),this.paintFooter(e.bounds,e.attribution),t.restore()}toCanvas(e,t,i){const n=Xm(e,i,t);return{x:n.x*this.width,y:n.y*this.height}}paintGround(e){const{ctx:t}=this;t.fillStyle="#1d2321",t.fillRect(0,0,this.width,this.height);const i=e.imagery;if(!i)return;const n=this.toCanvas(e.bounds,i.bounds.north,i.bounds.west),s=this.toCanvas(e.bounds,i.bounds.south,i.bounds.east);t.drawImage(i.source,n.x,n.y,s.x-n.x,s.y-n.y)}paintNight(e=0){if(e<=0)return;const{ctx:t}=this;t.save(),t.fillStyle=`rgba(6, 12, 30, ${Math.min(e,1)*.78})`,t.fillRect(0,0,this.width,this.height),t.restore()}paintDecor(e){const{ctx:t}=this;for(const i of e.decor){const n=this.toCanvas(e.bounds,i.lat,i.lng);if(i.label&&this.targets.push({kind:"decor",label:i.label,lat:i.lat,lng:i.lng,x:n.x,y:n.y,radius:7}),t.beginPath(),t.rect(n.x-3.5,n.y-3.5,7,7),t.fillStyle="rgba(120, 220, 255, 0.85)",t.fill(),t.lineWidth=1.5,t.strokeStyle="rgba(0, 0, 0, 0.7)",t.stroke(),i.headingDeg===void 0)continue;const s=(i.headingDeg-90)*Math.PI/180;t.beginPath(),t.moveTo(n.x,n.y),t.lineTo(n.x+Math.cos(s)*10,n.y+Math.sin(s)*10),t.lineWidth=3,t.strokeStyle="rgba(0, 0, 0, 0.6)",t.stroke(),t.lineWidth=1.5,t.strokeStyle="rgba(120, 220, 255, 0.9)",t.stroke()}}paintPath(e){if(!e.path.moved)return;const{ctx:t}=this,i=e.path.points.map(n=>this.toCanvas(e.bounds,n.lat,n.lng));t.beginPath(),t.moveTo(i[0].x,i[0].y);for(const n of i.slice(1))t.lineTo(n.x,n.y);t.lineJoin="round",t.lineCap="round",t.strokeStyle="rgba(0, 0, 0, 0.65)",t.lineWidth=5,t.stroke(),t.strokeStyle="rgba(255, 255, 255, 0.9)",t.lineWidth=2,t.stroke()}paintCone(e,t){const{headingDeg:i,coneHalfAngleDeg:n}=e;if(i===void 0||n===void 0)return;const{ctx:s}=this,r=this.toCanvas(e.bounds,t.lat,t.lng),o=Math.hypot(this.width,this.height),c=(i-90)*Math.PI/180,l=n*Math.PI/180;s.save(),s.beginPath(),s.moveTo(r.x,r.y),s.arc(r.x,r.y,o,c-l,c+l),s.closePath();const h=s.createRadialGradient(r.x,r.y,0,r.x,r.y,o);h.addColorStop(0,"rgba(255, 224, 130, 0.55)"),h.addColorStop(.35,"rgba(255, 224, 130, 0.22)"),h.addColorStop(1,"rgba(255, 224, 130, 0)"),s.fillStyle=h,s.fill(),s.restore()}paintMarkers(e){const{ctx:t}=this;t.textAlign="center",t.textBaseline="middle",t.font="bold 10px sans-serif";for(const i of[...e.markers].sort((n,s)=>Number(n.current)-Number(s.current))){const n=this.toCanvas(e.bounds,i.lat,i.lng);this.targets.push({kind:"milestone",label:i.note?`${i.label} — ${i.note}`:i.label,lat:i.lat,lng:i.lng,t:i.t,x:n.x,y:n.y,radius:aa.MARKER_RADIUS_PX}),t.beginPath(),t.arc(n.x,n.y,aa.MARKER_RADIUS_PX,0,Math.PI*2),t.fillStyle=i.current?"rgba(255, 224, 130, 0.95)":"rgba(0, 0, 0, 0.55)",t.fill(),t.lineWidth=2,t.strokeStyle="rgba(255, 255, 255, 0.9)",t.stroke(),t.fillStyle=i.current?"#1d2321":"#fff",t.fillText(i.label,n.x,n.y)}}paintWitness(e,t){const{ctx:i}=this,n=this.toCanvas(e.bounds,t.lat,t.lng);e.witnessLabel&&this.targets.push({kind:"witness",label:e.witnessLabel,lat:t.lat,lng:t.lng,x:n.x,y:n.y,radius:8});const s=e.markers.some(r=>{if(!r.current)return!1;const o=ci(r.lat,r.lng,t.lat,t.lng);return Math.hypot(o.x,o.z)<=aa.ON_MARKER_M});i.beginPath(),i.arc(n.x,n.y,s?aa.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),s||(i.fillStyle="#ff5a3c",i.fill()),i.lineWidth=4,i.strokeStyle="rgba(0, 0, 0, 0.5)",i.stroke(),i.lineWidth=s?3:2.5,i.strokeStyle=s?"#ff5a3c":"#fff",i.stroke()}paintNorth(){const{ctx:e}=this,t=this.width-14,i=16;e.beginPath(),e.moveTo(t,i-9),e.lineTo(t-4.5,i+5),e.lineTo(t,i+2),e.lineTo(t+4.5,i+5),e.closePath(),e.fillStyle="rgba(255, 255, 255, 0.92)",e.strokeStyle="rgba(0, 0, 0, 0.6)",e.lineWidth=1,e.fill(),e.stroke(),e.font="bold 9px sans-serif",e.textAlign="center",e.textBaseline="top",e.strokeText("N",t,i+6),e.fillText("N",t,i+6)}paintFooter(e,t){const{ctx:i}=this;i.font="9px sans-serif",i.textBaseline="bottom";const n=t?this.wrap(t,this.width-20):[];let s=this.height-4;i.textAlign="right";for(const f of n.slice().reverse())this.paintOutlinedText(f,this.width-6,s),s-=11;const r=(e.south+e.north)/2,c=Math.abs(ci(r,e.east,r,e.west).x)/this.width,l=aa.SCALE_STEPS_M.find(f=>f/c<=this.width/3);if(l===void 0)return;const h=l/c,u=8,d=s-3;i.lineWidth=3,i.strokeStyle="rgba(0, 0, 0, 0.6)",i.beginPath(),i.moveTo(u,d),i.lineTo(u+h,d),i.stroke(),i.lineWidth=1.5,i.strokeStyle="rgba(255, 255, 255, 0.95)",i.stroke(),i.textAlign="left",this.paintOutlinedText(l>=1e3?`${l/1e3} km`:`${l} m`,u,d-3)}paintOutlinedText(e,t,i){const{ctx:n}=this;n.lineWidth=3,n.strokeStyle="rgba(0, 0, 0, 0.75)",n.strokeText(e,t,i),n.fillStyle="#fff",n.fillText(e,t,i)}wrap(e,t){const i=[];let n="";for(const s of e.split(" ")){const r=n?`${n} ${s}`:s;n&&this.ctx.measureText(r).width>t?(i.push(n),n=s):n=r}return n&&i.push(n),i}}const rn=256,V0=3,S2=32768;class w2{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 i=(e.south+e.north)/2,n=(e.west+e.east)/2,s=Math.abs(ci(i,e.east,i,e.west).x),r=Math.abs(ci(e.north,n,e.south,n).z),o=M2(i,Math.max(s,r)),{tiles:c}=qm(n,i,o,V0),l=V0*rn,h=new Float32Array(l*l),u=c[0];await Promise.all(c.map(f=>this.decodeTileInto(f,u,h,l)));const d=new Float32Array(t.width*t.height);for(let f=0;f<t.height;f++){const p=e.north+(e.south-e.north)*(f/(t.height-1));for(let v=0;v<t.width;v++){const m=e.west+(e.east-e.west)*(v/(t.width-1));d[f*t.width+v]=this.sampleAt(p,m,o,u,h,l)}}return{heights:d,width:t.width,height:t.height,bounds:e}}async decodeTileInto(e,t,i,n){const s=this.tileUrlTemplate.replace("{z}",String(e.z)).replace("{x}",String(e.x)).replace("{y}",String(e.y)),r=await this.fetchImpl(s);if(!r.ok)throw new Error(`Elevation tile fetch failed (${r.status}): ${s}`);const o=await createImageBitmap(await r.blob()),c=document.createElement("canvas");c.width=rn,c.height=rn;const l=c.getContext("2d");if(!l)throw new Error("2D canvas context unavailable");l.drawImage(o,0,0);const{data:h}=l.getImageData(0,0,rn,rn),u=(e.x-t.x)*rn,d=(e.y-t.y)*rn;for(let f=0;f<rn;f++)for(let p=0;p<rn;p++){const v=(f*rn+p)*4,m=h[v]*256+h[v+1]+h[v+2]/256-S2,g=u+p,_=d+f;i[_*n+g]=m}}sampleAt(e,t,i,n,s,r){const{x:o,y:c}=Wm(t,e,i),l=(o-n.x)*rn,h=(c-n.y)*rn,u=Math.max(0,Math.min(r-1,Math.floor(l))),d=Math.max(0,Math.min(r-1,Math.floor(h))),f=Math.min(r-1,u+1),p=Math.min(r-1,d+1),v=l-u,m=h-d,g=s[d*r+u],_=s[d*r+f],w=s[p*r+u],M=s[p*r+f],S=g+(_-g)*v,b=w+(M-w)*v;return S+(b-S)*m}}const Oc=256,b2=5;async function E2(a,e,t,i){const n=(a.south+a.north)/2,s=(a.west+a.east)/2,r=Math.abs(ci(n,a.east,n,a.west).x),o=Math.abs(ci(a.north,s,a.south,s).z),c=Math.max(r,o),{zoom:l,gridSize:h}=A2(n,c,Math.max(e.width,e.height)),{tiles:u,bounds:d}=qm(s,n,l,h),f=h*Oc,p=document.createElement("canvas");p.width=f,p.height=f;const v=p.getContext("2d");if(!v)throw new Error("2D canvas context unavailable");const m=u[0];await Promise.all(u.map(async M=>{const S=t(M),b=await i(S);if(!b.ok)throw new Error(`Imagery tile fetch failed (${b.status}): ${S}`);const T=await createImageBitmap(await b.blob());v.drawImage(T,(M.x-m.x)*Oc,(M.y-m.y)*Oc)}));const g=Math.min(Math.max(e.width,e.height),f);if(g===f)return{source:p,width:f,height:f,bounds:d};const _=document.createElement("canvas");_.width=g,_.height=g;const w=_.getContext("2d");if(!w)throw new Error("2D canvas context unavailable");return w.drawImage(p,0,0,f,f,0,0,g,g),{source:_,width:g,height:g,bounds:d}}function A2(a,e,t){let i=x2(a,e/Math.max(1,t)),n=W0(a,i,e);for(;n>b2&&i>0;)i--,n=W0(a,i,e);return{zoom:i,gridSize:n,mPerPixel:Vm(a,i)/Oc}}function W0(a,e,t){const i=Math.ceil(t/2/Vm(a,e));return Math.max(3,2*i+1)}class T2{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 E2(e,t,i=>this.tileUrlTemplate.replace("{z}",String(i.z)).replace("{y}",String(i.y)).replace("{x}",String(i.x)),this.fetchImpl)}}class _n{attribution="Roads © OpenStreetMap contributors, as surveyed today";contemporary=!0;static DRIVABLE=["motorway","trunk","primary","secondary","tertiary","unclassified","residential","service","track","motorway_link","trunk_link","primary_link","secondary_link","tertiary_link"];static WIDTH_M={motorway:11,trunk:9,primary:8,secondary:7,tertiary:6.5,unclassified:5.5,residential:5.5,service:4,track:3.5};static DEFAULT_WIDTH_M=5;static ENDPOINTS=["https://overpass-api.de/api/interpreter","https://overpass.kumi.systems/api/interpreter","https://overpass.private.coffee/api/interpreter"];fetchImpl;endpoints;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.endpoints=e.endpoints??_n.ENDPOINTS}static queue=Promise.resolve();static RETRY_MS=4e3;async getRoads(e){const t=`${e.south},${e.west},${e.north},${e.east}`,i=`[out:json][timeout:30];way["highway"~"^(${_n.DRIVABLE.join("|")})$"](${t});out geom;`;return this.waysFrom(await this.queued(()=>this.ask(i)))}waysFrom(e){const t=[];for(const i of e.elements??[]){const n=i.geometry,s=i.tags;!s||!n||n.length<2||t.push({id:`osm-${i.id??t.length}`,name:s.name,surface:_n.surfaceOf(s),widthM:_n.widthOf(s),points:n.map(r=>({lat:r.lat,lng:r.lon}))})}return t}queued(e){const t=_n.queue.then(e,e);return _n.queue=t.catch(()=>{}),t}async ask(e){let t;for(const i of this.endpoints)for(let n=0;n<2;n++){try{const s=await this.fetchImpl(`${i}?data=${encodeURIComponent(e)}`);if(s.ok)return await s.json();if(t=new Error(`${new URL(i).host} refused (${s.status})`),s.status!==429&&s.status!==504)break}catch(s){t=new Error(`${new URL(i).host} unreachable (${String(s)})`);break}await new Promise(s=>setTimeout(s,_n.RETRY_MS))}throw t??new Error("No Overpass instance answered")}static widthOf(e){const t=Number.parseFloat(e.width??e.est_width??"");if(Number.isFinite(t)&&t>0)return t;const i=Number.parseInt(e.lanes??"",10);return Number.isFinite(i)&&i>0?i*3.5:_n.WIDTH_M[e.highway]??_n.DEFAULT_WIDTH_M}static surfaceOf(e){const t=e.surface;return t==="dirt"||t==="earth"||t==="mud"?"dirt":t==="gravel"||t==="fine_gravel"||t==="compacted"||t==="ground"||t==="sand"||t==="unpaved"?"gravel":t?"paved":e.highway==="track"?"gravel":"paved"}}const Ol="https://ufoathome.org/roads/index.json";class Rd{attributionRead;contemporaryRead;fetchImpl;indexUrls;fallback;index;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.indexUrls=e.indexUrls??Rd.defaultIndexUrls(),this.fallback=e.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Roads © OpenStreetMap contributors"}get contemporary(){return this.contemporaryRead??this.fallback?.contemporary??!0}async getRoads(e){const t=await this.held(e);if(t)return t;if(!this.fallback)return[];const i=await this.fallback.getRoads(e);return this.attributionRead=this.fallback.attribution,this.contemporaryRead=this.fallback.contemporary,i}async held(e){let t;try{t=await this.load()}catch{return}const i=t.find(({entry:n})=>n.north>=e.north&&n.south<=e.south&&n.east>=e.east&&n.west<=e.west);if(i)try{const n=await this.fetchImpl(new URL(i.entry.file,i.indexUrl).href);if(!n.ok)return;const s=await n.json();return Array.isArray(s?.ways)?(this.attributionRead=s.attribution,this.contemporaryRead=s.contemporary,s.ways):void 0}catch{return}}load(){return this.index??=this.fetchFirstAvailable(),this.index}async fetchFirstAvailable(){for(const e of this.indexUrls)try{const t=await this.fetchImpl(e);if(!t.ok)continue;const i=await t.json();if(Array.isArray(i?.entries))return i.entries.map(n=>({entry:n,indexUrl:e}))}catch{}return[]}static defaultIndexUrls(){const e=`?v=${encodeURIComponent("0.64.3")}`,t=typeof location>"u"?void 0:new URL("/roads/index.json",location.href).href;return(t&&t!==Ol?[t,Ol]:[Ol]).map(i=>i+e)}}function R2(){return{elevation:new w2,imagery:Ym(),roads:D2()}}function Ym(){return new T2}function D2(){return new Rd({fallback:new _n})}const C2=new Set,ar="show-witness-map",rr="hide-milestones";class Ki extends HTMLElement{static get observedAttributes(){return["src",ar,rr]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;static WITNESS_MAP_MIN_SPAN_M=400;static WITNESS_MAP_MARGIN=.6;static WITNESS_MAP_IMAGERY_PX=768;fullscreenButton;cornerButtons;witnessMapButton;referencesButton;referenceOpacityInput;referencesShownState=!0;referenceOpacityTouched=!1;milestonesButton;witnessMapPanel;witnessMapCanvas;witnessMapRenderer;seekInput;milestoneMarks;milestoneCaption;timeStartLabel;timeEndLabel;witnessPath;witnessMapBounds;witnessMapImagery;witnessMapImageryRequested=!1;witnessMapImageryCredit;witnessMapImageryFailed=!1;creditShownExternally=!1;lookYawDeg=0;lookPitchDeg=0;milestonesShown=!0;currentSighting=vl.create();sightingAudio=new s2;soundPreview;player;loopEnabled=!1;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;selectionShown=!0;overlayPainter;enableClickToPlay=!0;fullscreenTarget;messages=km;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>{this.updateFullscreenButton(),this.resizeWitnessMap()};witnessMapResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.resizeWitnessMap());resizeWitnessMap(){this.witnessMapPanel.hidden||(this.sizeWitnessMapCanvas(),this.paintWitnessMap(this.currentTime))}simulatedFullscreen=!1;styleBeforeSimulatedFullscreen;bodyOverflowBeforeSimulatedFullscreen;handleSimulatedFullscreenKey=e=>{e.key==="Escape"&&this.exitSimulatedFullscreen()};handlePointerMove=e=>{const t=this.canvasPointFromEvent(e),i=t&&this.shapeAt(t.x,t.y),n=this.said.read(i?.shape.title);if(!n){this.tooltip.hidden=!0;return}this.tooltip.textContent=n,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`};handleWitnessMapPointerMove=e=>{const t=this.witnessMapTargetFrom(e);if(!t){this.tooltip.hidden=!0,this.witnessMapCanvas.style.cursor="default";return}this.witnessMapCanvas.style.cursor="pointer",this.tooltip.textContent=t.label,this.tooltip.hidden=!1;const i=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${e.clientX-i.left+12}px`,this.tooltip.style.top=`${e.clientY-i.top+12}px`};handleWitnessMapClick=e=>{const t=this.witnessMapTargetFrom(e);if(t){if(t.kind==="milestone"&&t.t!==void 0){this.player.seek(t.t);return}this.dispatchEvent(new CustomEvent("lookat",{detail:{lat:t.lat,lng:t.lng,kind:t.kind},bubbles:!0,composed:!0}))}};witnessMapTargetFrom(e){const t=this.witnessMapCanvas.getBoundingClientRect();if(!(t.width===0||t.height===0))return this.witnessMapRenderer.hitTest((e.clientX-t.left)/t.width*this.witnessMapCanvas.width,(e.clientY-t.top)/t.height*this.witnessMapCanvas.height)}handlePointerLeave=()=>{this.tooltip.hidden=!0};constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${C1}</style>${D1}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new mo(this.canvas.getContext("2d")),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.playPauseButton=this.shadow.getElementById("play-pause"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.cornerButtons=this.shadow.getElementById("corner-buttons"),this.witnessMapButton=this.shadow.getElementById("witness-map"),this.referencesButton=this.shadow.getElementById("references"),this.referenceOpacityInput=this.shadow.getElementById("reference-opacity"),this.milestonesButton=this.shadow.getElementById("milestones"),this.witnessMapPanel=this.shadow.getElementById("witness-map-panel"),this.witnessMapCanvas=this.shadow.getElementById("witness-map-canvas"),this.witnessMapRenderer=new aa(this.witnessMapCanvas.getContext("2d")),this.seekInput=this.shadow.getElementById("seek"),this.milestoneMarks=this.shadow.getElementById("milestone-marks"),this.milestoneCaption=this.shadow.getElementById("milestone-caption"),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",i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),this.toggleTimeDisplay())});this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.witnessMapButton.addEventListener("click",()=>this.toggleWitnessMap()),this.referencesButton.addEventListener("click",()=>this.toggleReferences()),this.referenceOpacityInput.addEventListener("input",()=>{this.referenceOpacityTouched=!0,this.dispatchReferenceView()}),this.milestonesButton.addEventListener("click",()=>this.toggleMilestones()),this.witnessMapCanvas.addEventListener("pointermove",this.handleWitnessMapPointerMove),this.witnessMapCanvas.addEventListener("pointerleave",this.handlePointerLeave),this.witnessMapCanvas.addEventListener("click",this.handleWitnessMapClick),this.seekInput.addEventListener("input",()=>this.player.seek(this.snapSeekToMark(Number(this.seekInput.value)))),this.seekInput.addEventListener("pointerdown",t=>{this.seekSnapArmed=!0,this.nameMarkUnder(t)}),this.seekInput.addEventListener("pointerup",()=>{this.seekSnapArmed=!1}),this.seekInput.addEventListener("pointermove",t=>this.nameMarkUnder(t)),this.seekInput.addEventListener("pointerleave",()=>this.seekInput.removeAttribute("title")),this.canvas.addEventListener("click",t=>{this.enableClickToPlay&&(t.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause())}),this.canvas.addEventListener("dblclick",t=>{this.enableClickToPlay&&(t.preventDefault(),this.restorePlayback(),this.toggleFullscreen())}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),this.witnessMapResizeObserver?.observe(this.witnessMapPanel),this.hostControls(void 0),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateReferencesButton(),this.updateMilestonesButton(),this.refresh(),this.loadLocaleMessages()}connectedCallback(){this.saidTexts=void 0;const e=this.getAttribute("src");e&&this.loadFromSrc(e)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.witnessMapResizeObserver?.disconnect(),this.exitSimulatedFullscreen(),this.sightingAudio.dispose()}attributeChangedCallback(e,t,i){e==="src"&&i&&i!==t&&this.isConnected&&this.loadFromSrc(i),e===ar&&this.applyWitnessMapDefault(),e===rr&&this.setMilestonesShown(!this.hasAttribute(rr))}async loadFromSrc(e){this.sightingData=await Nm.json(e)}get sightingData(){return a2(this.currentSighting)}set sightingData(e){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=o2(e),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh(),this.applyWitnessMapDefault()}get sighting(){return this.currentSighting}previewSound(e){this.soundPreview=e,this.sightingAudio.resume(),this.sightingAudio.setSound(e)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(e){this.player.seek(e)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(e){e!==this.loopEnabled&&this.toggleLoop()}play(){this.player.seekableDuration<=0||this.playbackState==="playing"||this.togglePlayPause()}pause(){this.playbackState==="playing"&&this.togglePlayPause()}get positionLabel(){return this.timeStartLabel.textContent??""}get durationLabel(){return this.timeEndLabel.textContent??""}get showingClockTime(){return this.canShowClockTime}get canSwitchTimeDisplay(){return this.realStartMs!==void 0}toggleTimeDisplay(){this.canSwitchTimeDisplay&&(this.showClockTime=!this.showClockTime,this.updateTimeLabels(),this.updateTimeLabelTitles(),this.dispatchEvent(new CustomEvent("timedisplaychange",{bubbles:!0,composed:!0})))}get canShowClockTime(){return this.realStartMs!==void 0&&this.showClockTime}set showToolbar(e){this.toolbar.classList.toggle("hidden",!e)}get playbackState(){return this.player.playbackState}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(e){this.currentSighting.event.durationSeconds=e,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(e){const t=new Set(e);t.size===this.highlightedSourceIds.size&&[...t].every(n=>this.highlightedSourceIds.has(n))||(this.highlightedSourceIds=t,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.refreshMilestoneMarks(),this.updateMilestonesButton(),this.updateWitnessMap(),this.updateReferences(),this.player.seek(this.player.time)}hostControls(e){const t=[this.milestonesButton,this.referenceOpacityInput,this.referencesButton,this.witnessMapButton];if(e)for(const i of t)e.appendChild(i);else for(const i of t)this.toolbar.appendChild(i)}get referencesShown(){return this.referencesShownState}get referenceOpacity(){return Number(this.referenceOpacityInput.value)}toggleReferences(){this.referencesShownState=!this.referencesShownState,this.updateReferencesButton(),this.dispatchReferenceView()}updateReferences(){const e=this.currentSighting.references;!this.referenceOpacityTouched&&e.length>0&&(this.referenceOpacityInput.value=String(e[0].opacity)),this.updateReferencesButton()}updateReferencesButton(){const e=this.currentSighting.references.length>0;this.referencesButton.hidden=!e,this.referenceOpacityInput.hidden=!e||!this.referencesShownState,this.referencesButton.setAttribute("aria-pressed",String(this.referencesShownState));const t=this.referencesShownState?this.messages.hideReferences:this.messages.showReferences;this.referencesButton.title=t,this.referencesButton.setAttribute("aria-label",t),this.referenceOpacityInput.title=this.messages.referenceOpacity,this.referenceOpacityInput.setAttribute("aria-label",this.messages.referenceOpacity)}dispatchReferenceView(){this.dispatchEvent(new CustomEvent("referenceview",{detail:{shown:this.referencesShown,opacity:this.referenceOpacity}}))}refreshMilestoneMarks(){const e=this.player.seekableDuration,t=e>0?Yc(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...t.map(i=>{const n=document.createElement("button");n.type="button",n.className="milestone-mark",n.style.left=`${Math.min(Math.max(i.t/e,0),1)*100}%`;const s=this.said.read(i.label)??"",r=this.said.read(i.note),o=r?`${s} — ${r}`:s;return n.title=o,n.setAttribute("aria-label",o),n.dataset.t=String(i.t),n.addEventListener("click",()=>this.player.seek(i.t)),n}))}seekSnapArmed=!1;static MARK_SNAP_PX=6;markNear(e){const t=this.player.seekableDuration,i=this.seekInput.getBoundingClientRect().width;if(t<=0||i<=0)return;const n=Ki.MARK_SNAP_PX/i*t;let s;for(const r of this.milestoneMarks.children){const o=Number(r.dataset.t);Math.abs(o-e)>n||(!s||Math.abs(o-e)<Math.abs(s.t-e))&&(s={t:o,name:r.title})}return s}snapSeekToMark(e){return this.seekSnapArmed?(this.seekSnapArmed=!1,this.markNear(e)?.t??e):e}nameMarkUnder(e){const t=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(t.width<=0||i<=0)return;const n=(e.clientX-t.left)/t.width*i,s=this.markNear(n);s?this.seekInput.title=s.name:this.seekInput.removeAttribute("title")}showMilestoneAt(e){const t=this.milestonesShown&&this.sighting.milestones.length>0?z0(this.sighting.milestones,e):void 0;if(this.milestoneCaption.hidden=t===void 0,!t)return;const i=document.createElement("b");i.textContent=this.said.read(t.label)??"";const n=this.said.read(t.note),s=n?` — ${n}`:"";this.milestoneCaption.replaceChildren(i,document.createTextNode(s))}exposureInstants(e){const t=this.exposureTimes(e),i=1/t.length;return t.map(n=>({shapes:this.shapesAt(n),share:i}))}exposureTimes(e=this.currentTime){const t=bn.windowEndingAt(e,this.currentSighting.exposure??0);if(t.ms<Ki.SHORTEST_VISIBLE_EXPOSURE_MS)return[e];const i=Math.min(Ki.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(t.ms/Ki.SHORTEST_VISIBLE_EXPOSURE_MS))),n=Math.ceil(this.travelPxOver(t.fromMs,t.ms)/Ki.EXPOSURE_STEP_PX),s=Math.min(Ki.MAX_TRAVEL_STEPS,Math.max(i,n)),r=[];for(let o=0;o<s;o++)r.push(t.fromMs+t.ms*o/(s-1));return r}travelPxOver(e,t){const i=this.shapesAt(e),n=this.shapesAt(e+t);let s=0;for(const[r,o]of i){const c=n.get(r);if(!c)continue;const l=c.bounds.x+c.bounds.width/2-(o.bounds.x+o.bounds.width/2),h=c.bounds.y+c.bounds.height/2-(o.bounds.y+o.bounds.height/2);s=Math.max(s,Math.hypot(l,h))}return s}shapeAt(e,t,i){for(const n of this.exposureTimes()){const s=this.currentSighting.timeline.hitTest(n,e,t,i);if(s)return s}}shapesAt(e){const t=new Map;for(const i of this.currentSighting.timeline.sourceIds){const n=this.currentSighting.timeline.getInterpolatedShapeAt(e,i);n&&t.set(i,n)}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=ai.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 i=this.playbackState!=="playing"?this.highlightedSourceIds:C2;this.canvasRenderer.setStarPoints(ai.starPointsOf(this.sighting.instrument));const n=(si(this.sighting,e)?.rollDeg??0)+this.gaitAt(e).rollDeg;this.canvasRenderer.setRoll(n*Math.PI/180);const s=this.exposureInstants(e),r=this.frameShift;if(this.paintsShapes)for(const o of s)for(const[,c]of o.shapes){const l=o.share,h=l===1?c:{...c,transparency:1-(1-c.transparency)*l};this.canvasRenderer.paintShape(this.shifted(h,r))}for(const[o,c]of s[0].shapes)!this.selectionShown||!i.has(o)||(this.paintsShapes?i.size===1?this.canvasRenderer.paintShape({...c,selected:!0}):this.canvasRenderer.paintMemberOutline(c):this.canvasRenderer.paintSelectionOnly(this.shifted(c,r)));if(this.selectionShown&&i.size>1){const o=ji.groupBoundsFor([...t].filter(([c])=>i.has(c)).map(([,c])=>c.bounds));this.canvasRenderer.paintGroupHandles(o)}this.overlayPainter?.(this.canvasRenderer),this.mapShapeBounds=s.flatMap(o=>[...o.shapes.values()].filter(c=>c.transparency<1).map(c=>this.shifted(c,r).bounds)),this.keepWitnessMapClear(),this.seekInput.value=String(e),this.timeStartLabel.textContent=this.formatPosition(e),this.showMilestoneAt(e),this.paintWitnessMap(e),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(Z1(this.currentSighting,e))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:e}}))}shifted(e,t){return t.x===0&&t.y===0?e:{...e,bounds:{...e.bounds,x:e.bounds.x+t.x,y:e.bounds.y+t.y}}}createPlayer(){const e=new J1(this.currentSighting.timeline,(t,i)=>this.onFrame(t,i));return e.loop=this.loopEnabled,e.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},e}togglePlayPause(){this.player.seekableDuration<=0||(this.player.playbackState==="playing"?(this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh()):(this.sightingAudio.resume(),this.player.play()),this.updatePlayPauseButton())}updatePlayPauseButton(){const e=this.player.playbackState==="playing";this.playPauseButton.textContent=e?"⏸":"▶";const t=this.player.seekableDuration>0;this.playPauseButton.disabled=!t;const i=t?e?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=i,this.playPauseButton.setAttribute("aria-label",i),this.toolbar.classList.toggle("auto-hide",e),this.cornerButtons.classList.toggle("auto-hide",e)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.player.loop=this.loopEnabled}restorePlayback(){const e=this.playbackBeforeClick;e&&(this.currentTime=e.time,e.state==="playing"?this.play():this.pause())}get canUseNativeFullscreen(){return typeof this.fullscreenTarget.requestFullscreen=="function"&&document.fullscreenEnabled}toggleFullscreen(){if(!this.canUseNativeFullscreen){this.simulatedFullscreen?this.exitSimulatedFullscreen():this.enterSimulatedFullscreen();return}document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(e=>{console.error("<rr0-ufo>: requestFullscreen() failed —",e)})}enterSimulatedFullscreen(){const e=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen=e.getAttribute("style")??"",this.bodyOverflowBeforeSimulatedFullscreen=document.body.style.overflow;const t=e.style;t.setProperty("position","fixed"),t.setProperty("inset","0"),t.setProperty("margin","0"),t.setProperty("max-width","none"),t.setProperty("max-height","none"),t.setProperty("aspect-ratio","auto"),t.setProperty("z-index","2147483647"),t.setProperty("background","#000"),t.setProperty("width","100vw"),t.setProperty("width","100dvw"),t.setProperty("height","100vh"),t.setProperty("height","100dvh"),document.body.style.overflow="hidden",this.simulatedFullscreen=!0,document.addEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton()}exitSimulatedFullscreen(){if(!this.simulatedFullscreen)return;const e=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen?e.setAttribute("style",this.styleBeforeSimulatedFullscreen):e.removeAttribute("style"),document.body.style.overflow=this.bodyOverflowBeforeSimulatedFullscreen??"",this.simulatedFullscreen=!1,document.removeEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton()}toggleWitnessMap(){this.setWitnessMapOpen(this.witnessMapPanel.hidden)}applyWitnessMapDefault(){this.setWitnessMapOpen(this.hasAttribute(ar)&&this.witnessPath!==void 0)}setWitnessMapOpen(e){this.witnessMapPanel.hidden=!e,this.witnessMapPanel.removeAttribute("title"),this.witnessMapButton.setAttribute("aria-pressed",String(e)),this.updateWitnessMapButton(),e&&(this.sizeWitnessMapCanvas(),this.loadWitnessMapImagery(),this.paintWitnessMap(this.currentTime))}updateWitnessMapButton(){const t=!this.witnessMapPanel.hidden?this.messages.hideWitnessMap:this.messages.showWitnessMap;this.witnessMapButton.title=t,this.witnessMapButton.setAttribute("aria-label",t)}updateWitnessMap(){const e=this.witnessPath!==void 0;if(this.witnessPath=ho.of(this.currentSighting),this.witnessMapButton.hidden=this.witnessPath===void 0,!e&&this.witnessPath&&this.applyWitnessMapDefault(),!this.witnessPath){this.setWitnessMapOpen(!1),this.witnessMapBounds=void 0;return}const t=this.witnessPath.boundsAround(Ki.WITNESS_MAP_MIN_SPAN_M,Ki.WITNESS_MAP_MARGIN);(!this.witnessMapBounds||!this.sameGround(this.witnessMapBounds,t))&&(this.witnessMapBounds=t,this.witnessMapImagery=void 0,this.witnessMapImageryCredit=void 0,this.witnessMapImageryFailed=!1,this.witnessMapImageryRequested=!1,this.witnessMapPanel.hidden||this.loadWitnessMapImagery())}sameGround(e,t){const i=Math.abs(e.east-e.west)/20;return Math.abs(e.north-t.north)<i&&Math.abs(e.south-t.south)<i&&Math.abs(e.west-t.west)<i&&Math.abs(e.east-t.east)<i}async loadWitnessMapImagery(){if(this.witnessMapImageryRequested||!this.witnessMapBounds)return;this.witnessMapImageryRequested=!0;const e=Ym(),t=this.witnessMapBounds;try{const i=await e.getImageryTexture(t,{width:Ki.WITNESS_MAP_IMAGERY_PX,height:Ki.WITNESS_MAP_IMAGERY_PX});if(this.witnessMapBounds!==t)return;this.witnessMapImagery=i,this.witnessMapImageryCredit=e.attribution}catch{this.witnessMapImageryFailed=!0}this.paintWitnessMap(this.currentTime)}get witnessMapCredit(){return this.witnessMapImageryCredit}get witnessMapFooterLine(){return this.witnessMapImageryFailed?this.messages.mapImageryUnavailable:this.creditShownExternally?void 0:this.witnessMapImageryCredit}mapShapeBounds=[];mapSceneBounds=[];setMapSubjectBounds(e){this.mapSceneBounds=e.map(t=>({x:t.x*this.canvas.width,y:t.y*this.canvas.height,width:t.width*this.canvas.width,height:t.height*this.canvas.height})),this.keepWitnessMapClear()}keepWitnessMapClear(){if(this.witnessMapPanel.hidden)return;const e=this.witnessMapBoxPx;if(!e)return;const t=[...this.mapShapeBounds,...this.mapSceneBounds],i=(l,h,u)=>{for(const d of t)if(!(d.x+d.width<l-u||d.x>h+u)&&!(d.y>e.bottom+u||d.y+d.height<e.top-u))return!0;return!1},n=[this.canvas.width-e.width,this.canvas.width],s=[0,e.width],r=Ki.WITNESS_MAP_CLEARANCE_PX,o=i(...n,0),c=i(...s,0);if(this.witnessMapPanel.classList.toggle("subject-overlap",o&&c),this.witnessMapPanel.classList.contains("on-the-left")){!o&&(c||!i(n[0],n[1],r))&&this.witnessMapPanel.classList.remove("on-the-left");return}i(n[0],n[1],0)&&!i(s[0],s[1],0)&&this.witnessMapPanel.classList.add("on-the-left")}witnessMapBoxPx;static WITNESS_MAP_CLEARANCE_PX=24;sizeWitnessMapCanvas(){const e=this.witnessMapPanel.clientWidth;if(e===0)return;const t=Math.round(e*(globalThis.devicePixelRatio??1));this.measureWitnessMapBox(),this.witnessMapCanvas.width!==t&&(this.witnessMapCanvas.width=t,this.witnessMapCanvas.height=t)}measureWitnessMapBox(){const e=this.witnessMapPanel.getBoundingClientRect(),t=this.canvas.getBoundingClientRect();if(t.width===0||t.height===0)return;const i=this.canvas.width/t.width,n=this.canvas.height/t.height;this.witnessMapBoxPx={width:e.width*i,top:(e.top-t.top)*n,bottom:(e.bottom-t.top)*n}}paintWitnessMap(e){if(this.witnessMapPanel.hidden||!this.witnessPath||!this.witnessMapBounds)return;const t=si(this.currentSighting,e),i=this.currentSighting.instrument,n=[],s=this.currentSighting.milestones.length>0?z0(this.currentSighting.milestones,e):void 0;for(const r of this.milestonesShown?Yc(this.currentSighting.milestones):[]){const o=si(this.currentSighting,r.t);o?.lat===void 0||o.lng===void 0||n.push({label:this.said.read(r.label)??"",note:this.said.read(r.note),t:r.t,lat:o.lat,lng:o.lng,current:r===s})}this.witnessMapRenderer.paint({bounds:this.witnessMapBounds,imagery:this.witnessMapImagery,path:this.witnessPath,position:t?.lat!==void 0&&t.lng!==void 0?{lat:t.lat,lng:t.lng}:void 0,headingDeg:t?.headingDeg===void 0?void 0:t.headingDeg+this.lookYawDeg,coneHalfAngleDeg:t?ps.of(i,this.canvas.height,t.fovDeg).halfWidthAngleDeg(ai.aspectOf(i)):void 0,markers:n,decor:this.witnessMapDecorAt(e),witnessLabel:this.said.read(this.currentSighting.witness?.title)??this.messages.witnessHere,nightFraction:this.witnessMapNightFraction,attribution:this.witnessMapFooterLine})}toggleMilestones(){this.setMilestonesShown(!this.milestonesShown)}setMilestonesShown(e){this.milestonesShown=e,this.milestoneMarks.hidden=!e,this.milestonesButton.setAttribute("aria-pressed",String(e)),this.updateMilestonesButton(),this.showMilestoneAt(this.currentTime),this.paintWitnessMap(this.currentTime)}updateMilestonesButton(){this.milestonesButton.hidden=this.currentSighting.milestones.length===0;const e=this.milestonesShown?this.messages.hideMilestones:this.messages.showMilestones;this.milestonesButton.title=e,this.milestonesButton.setAttribute("aria-label",e)}witnessMapDecorAt(e){const t=si(this.currentSighting,0);return t?.lat===void 0||t.lng===void 0?[]:this.currentSighting.decor.filter(i=>i.kind!=="crop").map(i=>{const n=Ad(i,e),{lat:s,lng:r}=fs(n.eastM,-n.northM,t.lat,t.lng);return{lat:s,lng:r,headingDeg:n.headingDeg,label:this.said.read(i.title)??this.messages.decorHere}})}witnessMapNightFraction;setSunAltitude(e){const t=e===void 0?void 0:Math.max(0,Math.min(1,-e/12));t!==this.witnessMapNightFraction&&(this.witnessMapNightFraction=t,this.paintWitnessMap(this.currentTime))}setLookOffset(e,t){e===this.lookYawDeg&&t===this.lookPitchDeg||(this.lookYawDeg=e,this.lookPitchDeg=t,this.refresh())}get frameShiftPx(){return this.frameShift}get frameShift(){const e=this.gaitAt(this.currentTime),t=this.lookYawDeg+e.yawDeg,i=this.lookPitchDeg+e.pitchDeg;if(t===0&&i===0)return{x:0,y:0};const n=si(this.currentSighting,this.currentTime),s=ps.of(this.currentSighting.instrument,this.canvas.height,n?.fovDeg??60);return{x:-s.angleDegToRadiusPx(t),y:s.angleDegToRadiusPx(i)}}gaitAt(e){return ni.of(this.currentSighting)?.offsetAt(e)??ni.STILL}updateFullscreenButton(){const e=this.simulatedFullscreen||document.fullscreenElement===this.fullscreenTarget;this.fullscreenButton.title=e?this.messages.exitFullscreen:this.messages.fullscreen,this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}get said(){return this.saidTexts??=new ks(Kc.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const e=Td(Kc.preferencesFor(this),u2);e!=="en"&&this.applyMessages(await f2(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 i of[this.timeStartLabel,this.timeEndLabel])i.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(i.setAttribute("role","button"),i.setAttribute("tabindex","0")):(i.removeAttribute("role"),i.removeAttribute("tabindex"))}applyMessages(e){this.messages=e,this.updateTimeLabelTitles(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateReferencesButton(),this.updateMilestonesButton()}updateTimeLabels(){const e=this.currentSighting.event,t=Y1(e);this.realDurationMs=t!==void 0&&t>0?t:void 0,this.realStartMs=e.time?eu(e.time):void 0;const i=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&i>0?i/this.realDurationMs:1,this.player.durationOverrideMs=i>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 Fo(e);const t=this.currentSighting.timeline.duration,i=t>0&&e<=t?e/t*this.realDurationMs:e;return this.canShowClockTime?q0(X0(this.realStartMs+i)):Fo(i)}formatEndOfTimeline(){return this.realDurationMs===void 0?Fo(this.currentSighting.timeline.duration):this.canShowClockTime?q0(X0(this.realStartMs+this.realDurationMs)):Fo(this.realDurationMs)}}function X0(a){const e=new Date(a);return{hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds()}}function q0(a){if(a.hour===void 0)return"0:00";const e=t=>String(t).padStart(2,"0");return a.second?`${e(a.hour)}:${e(a.minute??0)}:${e(a.second)}`:`${e(a.hour)}:${e(a.minute??0)}`}function Fo(a){const e=Math.round(a/1e3),t=Math.floor(e/60),i=e%60;return`${t}:${String(i).padStart(2,"0")}`}const iu="rr0-ufo";function Km(){customElements.get(iu)||customElements.define(iu,Ki)}/**
|
|
627
|
+
`,Po=[{id:"eye",name:{en:"Naked eye",fr:"Œil nu"},flare:0,projection:"equidistant",stabilization:.97},{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,detailUm:20},{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,detailUm:20},{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},detailUm:20},{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},fNumber:1.8,exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0,detailUm:1.4},{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},fNumber:1.8,exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0,detailUm:1.4}];class ri{static get default(){return Po[0]}static byId(e){return Po.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:ri.UNAIDED_FIELD_DEG}static aspectOf(e){const t=e.frame;return t?t.widthMm/t.heightMm:ri.UNAIDED_ASPECT}static frameWidthPx(e,t){return Math.round(t*ri.aspectOf(e))}static availableAt(e){return e===void 0?Po:Po.filter(t=>!t.years||e>=t.years.from&&(t.years.to===void 0||e<=t.years.to))}static fieldOfViewDegAt(e,t){const i=e.frame;if(!(!i||t<=0))return 2*Math.atan(i.heightMm/(2*t))*180/Math.PI}static focalLengthMmFor(e,t){const i=e.frame;if(!(!i||t<=0||t>=180))return i.heightMm/(2*Math.tan(t*Math.PI/360))}static bladesShowing(e,t){const i=t??e.fNumber;if(i===void 0||e.apertureBlades===void 0)return 0;const n=e.fNumberRange;return!n||n.max<=n.min?1:Math.max(0,Math.min(1,(i-n.min)/(n.max-n.min)))}static LENS_FLARE_ARTIFACTS=1;static flareArtifactsOf(e){return e.flare??ri.LENS_FLARE_ARTIFACTS}static starPointsOf(e){const t=e.apertureBlades;return t===void 0||t<3?0:t%2===0?t:t*2}}class ho{constructor(e){this.points=e}static STATIONARY_M=5;static of(e){const t=[];for(const i of e.witnessTrack.allKeyframes){const{lat:n,lng:s,headingDeg:r}=i.pose;n===void 0||s===void 0||t.push({t:i.t,lat:n,lng:s,headingDeg:r})}if(t.length===0){const i=e.event.place?.[0];if(!i)return;t.push({t:0,lat:i.lat,lng:i.lng})}return new ho(t)}get moved(){return this.spanM>ho.STATIONARY_M}get spanM(){const e=this.box,t=(e.south+e.north)/2,i=(e.west+e.east)/2;return Math.max(Math.abs(li(t,e.east,t,e.west).x),Math.abs(li(e.north,i,e.south,i).z))}get center(){const e=this.box;return{lat:(e.south+e.north)/2,lng:(e.west+e.east)/2}}boundsAround(e,t){const{lat:i,lng:n}=this.center,s=Math.max(this.spanM*(1+t),e)/2;return{north:fs(0,-s,i,n).lat,south:fs(0,s,i,n).lat,east:fs(s,0,i,n).lng,west:fs(-s,0,i,n).lng}}get box(){const e=this.points.map(i=>i.lat),t=this.points.map(i=>i.lng);return{south:Math.min(...e),north:Math.max(...e),west:Math.min(...t),east:Math.max(...t)}}}class si{constructor(e,t){this.stretches=e,this.rotationPassed=t}static REFERENCE_SPEED_M_PER_S=1.4;static REFERENCE_STEP_HZ=1.9;static CADENCE_EXPONENT=.43;static RISE_M_PER_M_PER_S=.0175;static SWAY_M=.0175;static SLOWEST_WALK_M_PER_S=.2;static FASTEST_WALK_M_PER_S=2.2;static HEAD_ROLL_DEG=1.5;static HEAD_PITCH_DEG=1.25;static HEAD_YAW_DEG=1;static STILL=Object.freeze({eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0});static of(e){const t=ho.of(e);if(!t||t.points.length<2)return;const i=[];let n=0;for(let s=1;s<t.points.length;s++){const r=t.points[s-1],o=t.points[s],c=(o.t-r.t)/1e3;if(c<=0)continue;const l=li(o.lat,o.lng,r.lat,r.lng),h=l.x,u=-l.z,d=Math.hypot(h,u),f=d/c,p=si.stepHzFor(f);i.push({startMs:r.t,endMs:o.t,speedMPerS:f,eastUnit:d>0?h/d:0,northUnit:d>0?u/d:0,stepHz:p,stepsBefore:n,rampsIn:!0,rampsOut:!0}),n+=p*c}for(let s=0;s<i.length;s++){const r=i[s-1],o=i[s+1];i[s].rampsIn=r===void 0||r.stepHz===0,i[s].rampsOut=o===void 0||o.stepHz===0}if(i.some(s=>s.stepHz>0))return new si(i,1-(e.instrument.stabilization??0))}static stepHzFor(e){return e<si.SLOWEST_WALK_M_PER_S||e>si.FASTEST_WALK_M_PER_S?0:si.REFERENCE_STEP_HZ*Math.pow(e/si.REFERENCE_SPEED_M_PER_S,si.CADENCE_EXPONENT)}offsetAt(e){const t=this.stretches.find(c=>e>=c.startMs&&e<=c.endMs);if(!t||t.stepHz===0)return si.STILL;const i=t.stepsBefore+t.stepHz*(e-t.startMs)/1e3,n=2*Math.PI*i,s=this.amplitudeAt(t,e),r=si.SWAY_M*s*Math.cos(n/2),o=s*this.rotationPassed*t.speedMPerS/si.REFERENCE_SPEED_M_PER_S;return{eastM:r*t.northUnit,northM:-r*t.eastUnit,upM:si.RISE_M_PER_M_PER_S*t.speedMPerS*s*Math.cos(n),rollDeg:si.HEAD_ROLL_DEG*o*Math.cos(n/2),pitchDeg:-1.25*o*Math.cos(n),yawDeg:si.HEAD_YAW_DEG*o*Math.cos(n/2)}}amplitudeAt(e,t){const i=1e3/e.stepHz,n=Math.min(i,(e.endMs-e.startMs)/2);if(n<=0)return 1;const s=t-e.startMs,r=e.endMs-t,o=Math.min(e.rampsIn?s/n:1,e.rampsOut?r/n:1,1);return(1-Math.cos(Math.PI*Math.max(o,0)))/2}}class Rt{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/Rt.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(e,t,i){if(!(!e||!t))return{widthDeg:e.widthDeg+(t.widthDeg-e.widthDeg)*i,heightDeg:e.heightDeg+(t.heightDeg-e.heightDeg)*i}}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 I1(a,e,t){if(!a||!e)return t<1?a:e;const i=((e.azimuthDeg-a.azimuthDeg)%360+540)%360-180;return{azimuthDeg:((a.azimuthDeg+i*t)%360+360)%360,altitudeDeg:a.altitudeDeg+(e.altitudeDeg-a.altitudeDeg)*t}}function P1(a,e,t){const{bounds:i}=a;return e>=i.x&&e<=i.x+i.width&&t>=i.y&&t<=i.y+i.height}function Gi(a,e,t){return a+(e-a)*t}function A0(a){const e=/^#([0-9a-f]{6})$/i.exec(a);if(!e)return;const t=parseInt(e[1],16);return[t>>16&255,t>>8&255,t&255]}function L1(a){return`#${a.map(e=>Math.round(e).toString(16).padStart(2,"0")).join("")}`}function N1(a,e,t){const i=A0(a),n=A0(e);return!i||!n?t<1?a:e:L1([Gi(i[0],n[0],t),Gi(i[1],n[1],t),Gi(i[2],n[2],t)])}function O1(a,e,t){const i={x:Gi(a.bounds.x,e.bounds.x,t),y:Gi(a.bounds.y,e.bounds.y,t),width:Gi(a.bounds.width,e.bounds.width,t),height:Gi(a.bounds.height,e.bounds.height,t)},n=Gi(a.angle,e.angle,t),s=Gi(a.transparency,e.transparency,t),r=Gi(a.haloScale,e.haloScale,t),o=Gi(a.blur??0,e.blur??0,t),c=Gi(a.brightness??0,e.brightness??0,t),l=N1(a.color,e.color,t),h=Rt.lerpAngular(a.angular,e.angular,t),u=I1(a.aim,e.aim,t);return a.kind==="polygon"&&e.kind==="polygon"&&a.points.length===e.points.length?{...a,bounds:i,angle:n,transparency:s,haloScale:r,blur:o,brightness:c,color:l,angular:h,aim:u,points:a.points.map((d,f)=>({x:Gi(d.x,e.points[f].x,t),y:Gi(d.y,e.points[f].y,t)}))}:{...t<1?a:e,bounds:i,angle:n,transparency:s,haloScale:r,blur:o,brightness:c,color:l,angular:h,aim:u}}class gl{keyframes=[];order=[];groups=[];addKeyframe(e,t){const i=this.findInsertIndex(e);if(this.keyframes[i]?.t===e){const n=new Set(t.map(s=>s.sourceId));this.keyframes[i]={t:e,shapes:[...this.keyframes[i].shapes.filter(s=>!n.has(s.sourceId)),...t]}}else this.keyframes.splice(i,0,{t:e,shapes:[...t]});for(const n of t)this.order.includes(n.sourceId)||this.order.push(n.sourceId)}findInsertIndex(e){let t=0,i=this.keyframes.length;for(;t<i;){const n=t+i>>>1;this.keyframes[n].t<e?t=n+1:i=n}return t}getKeyframeAt(e){const t=this.findInsertIndex(e),i=this.keyframes[t];return i?.t===e?i:void 0}getShapeAt(e,t){return this.getKeyframeAt(e)?.shapes.find(i=>i.sourceId===t)?.shape}getLatestShapeAt(e,t){let i=this.findInsertIndex(e);for(this.keyframes[i]?.t!==e&&(i-=1);i>=0;i--){const n=this.keyframes[i].shapes.find(s=>s.sourceId===t);if(n)return n.shape}}getInterpolatedShapeAt(e,t){const i=this.findShapeAtOrBefore(e,t);if(i?.t===e)return i.shape;const n=this.findShapeAtOrAfter(e,t);return i?n?O1(i.shape,n.shape,(e-i.t)/(n.t-i.t)):i.shape:n?.shape}findShapeAtOrBefore(e,t){let i=this.findInsertIndex(e);for(this.keyframes[i]?.t!==e&&(i-=1);i>=0;i--){const n=this.keyframes[i].shapes.find(s=>s.sourceId===t);if(n)return{t:this.keyframes[i].t,shape:n.shape}}}findShapeAtOrAfter(e,t){for(let i=this.findInsertIndex(e);i<this.keyframes.length;i++){const n=this.keyframes[i].shapes.find(s=>s.sourceId===t);if(n)return{t:this.keyframes[i].t,shape:n.shape}}}hitTest(e,t,i,n){const s=this.sourceIds;for(let r=s.length-1;r>=0;r--){if(n?.has(s[r]))continue;const o=this.getInterpolatedShapeAt(e,s[r]);if(o&&P1(o,t,i))return{sourceId:s[r],shape:o}}}removeSource(e){for(let t=this.keyframes.length-1;t>=0;t--){const i=this.keyframes[t].shapes.filter(n=>n.sourceId!==e);i.length===0?this.keyframes.splice(t,1):i.length!==this.keyframes[t].shapes.length&&(this.keyframes[t]={t:this.keyframes[t].t,shapes:i})}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(i=>i.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(n=>n.includes(e));if(t===-1)return;const i=this.groups[t].filter(n=>n!==e);i.length<2?this.groups.splice(t,1):this.groups[t]=i}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 gl;for(const i of e.keyframes)t.addKeyframe(i.t,i.shapes);if(e.order){const i=t.order.filter(n=>!e.order.includes(n));t.order=[...e.order,...i]}return e.groups&&(t.groups=e.groups.map(i=>i.filter(n=>t.order.includes(n))).filter(i=>i.length>=2)),t}}function U1(a,e,t){return Math.max(e,Math.min(t,a))}function F1(a,e,t){const i=((e-a)%360+540)%360-180;return((a+i*t)%360+360)%360}function Ra(a,e,t){return a+(e-a)*t}function k1(a,e,t){return{lat:a.lat===void 0||e.lat===void 0?void 0:Ra(a.lat,e.lat,t),lng:a.lng===void 0||e.lng===void 0?void 0:Ra(a.lng,e.lng,t),elevationM:Ra(a.elevationM,e.elevationM,t),headingDeg:a.headingDeg===void 0||e.headingDeg===void 0?void 0:F1(a.headingDeg,e.headingDeg,t),pitchDeg:Ra(a.pitchDeg,e.pitchDeg,t),rollDeg:Ra(a.rollDeg??0,e.rollDeg??0,t),fovDeg:Ra(a.fovDeg,e.fovDeg,t),fNumber:a.fNumber,focusDistanceM:a.focusDistanceM}}class uo{keyframes=[];addKeyframe(e,t){const i=this.findInsertIndex(e);this.keyframes[i]?.t===e?this.keyframes[i]={t:e,pose:t}:this.keyframes.splice(i,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,i=this.keyframes.length;for(;t<i;){const n=t+i>>>1;this.keyframes[n].t<e?t=n+1:i=n}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),i=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(i?.t===e)return i.pose;const n=this.keyframes[t]?.t===e?void 0:this.keyframes[t];return i?n?k1(i.pose,n.pose,U1((e-i.t)/(n.t-i.t),0,1)):i.pose:n?.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 uo;for(const i of e.keyframes)t.addKeyframe(i.t,i.pose);return t}}function It(a,e,t){return a+(e-a)*t}function Ed(a,e,t){const i=((e-a)%360+540)%360-180;return((a+i*t)%360+360)%360}function z1(a,e,t){return Math.max(e,Math.min(t,a))}function H1(a=[],e=[],t){if(!(!a.length&&!e.length))return[...new Set([...a.map(i=>i.id),...e.map(i=>i.id)])].map(i=>{const n=a.find(c=>c.id===i),s=e.find(c=>c.id===i),r=n??{...s,density:0},o=s??{...n,density:0};return{...r,eastM:It(r.eastM,o.eastM,t),northM:It(r.northM,o.northM,t),baseM:It(r.baseM,o.baseM,t),thicknessM:It(r.thicknessM,o.thicknessM,t),widthM:It(r.widthM,o.widthM,t),depthM:It(r.depthM,o.depthM,t),rotationDeg:Ed(r.rotationDeg,o.rotationDeg,t),density:It(r.density,o.density,t),darkness:It(r.darkness??0,o.darkness??0,t)}})}function B1(a,e,t){if(a.cloudLayers===void 0&&e.cloudLayers===void 0)return;const i=Xc(a),n=Xc(e);return t>=1?n.map(r=>({...r})):[...new Set([...i.map(r=>r.id),...n.map(r=>r.id)])].map(r=>{const o=i.find(u=>u.id===r),c=n.find(u=>u.id===r),l=o??{...c,coverage:0},h=c??{...o,coverage:0};return{...l,instances:H1(o?.instances,c?.instances,t),baseM:It(l.baseM,h.baseM,t),thicknessM:It(l.thicknessM,h.thicknessM,t),coverage:It(l.coverage,h.coverage,t),sizeM:It(l.sizeM,h.sizeM,t),density:It(l.density,h.density,t),darkness:It(l.darkness??a.cloudDarkness,h.darkness??e.cloudDarkness,t),iceCrystalAlignment:l.iceCrystalAlignment===void 0||h.iceCrystalAlignment===void 0?void 0:It(l.iceCrystalAlignment,h.iceCrystalAlignment,t),windSpeed:l.windSpeed===void 0&&h.windSpeed===void 0?void 0:It(l.windSpeed??a.windSpeed,h.windSpeed??e.windSpeed,t),windDirectionDeg:l.windDirectionDeg===void 0&&h.windDirectionDeg===void 0?void 0:Ed(l.windDirectionDeg??a.windDirectionDeg,h.windDirectionDeg??e.windDirectionDeg,t)}})}function G1(a,e,t){return{cloudLayers:B1(a,e,t),cloudCover:It(a.cloudCover,e.cloudCover,t),cloudDarkness:It(a.cloudDarkness,e.cloudDarkness,t),highCloudCover:a.highCloudCover===void 0||e.highCloudCover===void 0?void 0:It(a.highCloudCover,e.highCloudCover,t),iceCrystalAlignment:a.iceCrystalAlignment===void 0||e.iceCrystalAlignment===void 0?void 0:It(a.iceCrystalAlignment,e.iceCrystalAlignment,t),lowerCloudCover:a.lowerCloudCover===void 0||e.lowerCloudCover===void 0?void 0:It(a.lowerCloudCover,e.lowerCloudCover,t),cloudBaseM:a.cloudBaseM===void 0||e.cloudBaseM===void 0?void 0:It(a.cloudBaseM,e.cloudBaseM,t),relativeHumidity:a.relativeHumidity===void 0||e.relativeHumidity===void 0?void 0:It(a.relativeHumidity,e.relativeHumidity,t),precipitationType:t<1?a.precipitationType:e.precipitationType,precipitationIntensity:It(a.precipitationIntensity,e.precipitationIntensity,t),windDirectionDeg:Ed(a.windDirectionDeg,e.windDirectionDeg,t),windSpeed:It(a.windSpeed,e.windSpeed,t),storm:t<1?a.storm:e.storm}}class fo{keyframes=[];addKeyframe(e,t){const i=this.findInsertIndex(e);this.keyframes[i]?.t===e?this.keyframes[i]={t:e,weather:t}:this.keyframes.splice(i,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,i=this.keyframes.length;for(;t<i;){const n=t+i>>>1;this.keyframes[n].t<e?t=n+1:i=n}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),i=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(i?.t===e)return i.weather;const n=this.keyframes[t]?.t===e?void 0:this.keyframes[t];return i?n?G1(i.weather,n.weather,z1((e-i.t)/(n.t-i.t),0,1)):i.weather:n?.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 fo;for(const i of e.keyframes)t.addKeyframe(i.t,i.weather);return t}}class po{keyframes=[];addKeyframe(e,t){const i=this.findInsertIndex(e);this.keyframes[i]?.t===e?this.keyframes[i]={t:e,sound:t}:this.keyframes.splice(i,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),i=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(i?.t===e)return i.sound;const n=this.keyframes[t]?.t===e?void 0:this.keyframes[t];if(!i)return n?.sound;if(!n)return i.sound;const s=(e-i.t)/(n.t-i.t);return this.lerp(i.sound,n.sound,Math.max(0,Math.min(1,s)))}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 po;for(const i of e.keyframes)t.addKeyframe(i.t,i.sound);return t}lerp(e,t,i){return{kind:i<1?e.kind:t.kind,volume:e.volume+(t.volume-e.volume)*i,pitchHz:e.pitchHz+(t.pitchHz-e.pitchHz)*i,src:i<1?e.src:t.src}}findInsertIndex(e){let t=0,i=this.keyframes.length;for(;t<i;){const n=t+i>>>1;this.keyframes[n].t<e?t=n+1:i=n}return t}}const V1=100,W1={kind:"none",volume:0,pitchHz:V1};class un{constructor(e){this.entries=e}static empty(){return new un(new Map)}get size(){return this.entries.size}at(e){return this.entries.get(e)}paths(){return[...this.entries.keys()]}set(e,t){t.basis==="stated"&&t.rationale===void 0?this.entries.delete(e):this.entries.set(e,t)}clear(e){for(const t of this.entries.keys())(t===e||t.startsWith(`${e}.`))&&this.entries.delete(t)}static strip(e){const t=new un(new Map);return{recording:un.stripValue(e,[],t),provenance:t}}static restore(e,t){if(t.size===0)return e;const i=structuredClone(e);for(const n of t.paths()){const s=t.at(n),r=n.split("."),o=un.holderOf(i,r);if(!o)continue;const c=r[r.length-1],l=o[c];l!==void 0&&(s.of!==void 0&&JSON.stringify(s.of)!==JSON.stringify(l)||(o[c]={value:l,...s.basis==="stated"?{}:{basis:s.basis},...s.rationale===void 0?{}:{rationale:s.rationale}}))}return i}static isWrapper(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"value"in e}static stripValue(e,t,i){return un.isWrapper(e)?(i.set(t.join("."),{basis:e.basis??"stated",...e.rationale===void 0?{}:{rationale:e.rationale},of:e.value}),un.stripValue(e.value,t,i)):Array.isArray(e)?e.map((n,s)=>un.stripValue(n,[...t,String(s)],i)):typeof e=="object"&&e!==null?Object.fromEntries(Object.entries(e).map(([n,s])=>[n,un.stripValue(s,[...t,n],i)])):e}static holderOf(e,t){let i=e;for(const n of t.slice(0,-1)){if(typeof i!="object"||i===null)return;i=i[n]}return typeof i=="object"&&i!==null?i:void 0}}function eu(a){if(a.year!==void 0)return Date.UTC(a.year,(a.month??1)-1,a.day??1,a.hour??0,a.minute??0,a.second??0)}function T0(a){return(((a.day??0)*24+(a.hour??0))*60+(a.minute??0))*6e4+(a.second??0)*1e3}const X1=["year","month","day","hour","minute"],q1=["day","hour","minute"];function R0(a,e){return e.filter(t=>a[t]!==void 0).join(",")}function Y1(a){if(a.durationSeconds!==void 0)return a.durationSeconds*1e3;if(!a.time||!a.endTime)return;const e=a.time.year!==void 0&&a.endTime.year!==void 0,t=e?X1:q1,i=R0(a.time,t);if(!(i===""||i!==R0(a.endTime,t)))return e?eu(a.endTime)-eu(a.time):T0(a.endTime)-T0(a.time)}class vl{constructor(e,t,i,n,s,r,o,c,l=[],h,u,d,f=[],p=[],v=[]){this.event=e,this.timeline=t,this.witnessTrack=i,this.weatherTrack=n,this.soundTrack=s,this.witness=r,this.id=o,this.weather=c,this.decor=l,this.weatherSource=h,this.instrumentId=u,this.exposureSeconds=d,this.milestones=f,this.references=p,this.roads=v}provenance=un.empty();testimony;interpretation;get witnessCount(){return 1+this.decor.filter(e=>e.kind==="witness").length}get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return ri.byId(this.instrumentId)}static create(e,t,i){return new vl({eventType:"sighting",time:e,place:t},new gl,new uo,new fo,new po,i)}}const K1=0,$1=0;function ai(a,e){const t=a.witnessTrack.getInterpolatedPoseAt(e);if(t)return t;const i=a.event.place?.[0];if(i)return{lat:i.lat,lng:i.lng,elevationM:K1,headingDeg:void 0,pitchDeg:$1,fovDeg:ri.fieldOfViewDeg(a.instrument)}}function Js(a,e){return a.weatherTrack.getInterpolatedWeatherAt(e)??a.weather??Pm}function Z1(a,e){return a.soundTrack.getInterpolatedSoundAt(e)??W1}class J1{constructor(e,t){this.timeline=e,this.onFrame=t}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;onEnded;durationOverrideMs=0;get seekableDuration(){return Math.max(this.timeline.duration,this.durationOverrideMs)}play(){if(this.state==="playing")return;this.currentT>=this.seekableDuration&&(this.currentT=0,this.resolveFrame(0)),this.state="playing",this.lastWallTime=performance.now();const e=()=>{if(this.state!=="playing")return;const t=performance.now();if(this.currentT+=(t-this.lastWallTime)*this.playbackRate,this.lastWallTime=t,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(e);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT),this.onEnded?.();return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(e)};this.rafId=requestAnimationFrame(e)}pause(){this.state==="playing"&&(this.state="paused",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null))}stop(){this.state="stopped",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}seek(e){this.currentT=Math.max(0,Math.min(e,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(e){const t=new Map;for(const i of this.timeline.sourceIds){const n=this.timeline.getInterpolatedShapeAt(e,i);n&&t.set(i,n)}this.onFrame(e,t)}}const Om=["nw","n","ne","e","se","s","sw","w"],j1=24,Lo=8,Q1=3,e2=8;function No(a,e,t){const i=a.x-e.x,n=a.y-e.y,s=Math.cos(t),r=Math.sin(t);return{x:e.x+i*s-n*r,y:e.y+i*r+n*s}}function Ar(a){return{x:a.x+a.width/2,y:a.y+a.height/2}}const t2={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 ji{static handlePointsFor(e){const{x:t,y:i,width:n,height:s}=e.bounds,r={nw:{x:t,y:i},n:{x:t+n/2,y:i},ne:{x:t+n,y:i},e:{x:t+n,y:i+s/2},se:{x:t+n,y:i+s},s:{x:t+n/2,y:i+s},sw:{x:t,y:i+s},w:{x:t,y:i+s/2},rotate:{x:t+n/2,y:i-j1}},o=Ar(e.bounds),c={};for(const l of Object.keys(r))c[l]=No(r[l],o,e.angle);return c}static hitTestHandle(e,t,i=8,n=[...Om,"rotate"]){const s=ji.handlePointsFor(e);for(const r of n)if(Math.hypot(t.x-s[r].x,t.y-s[r].y)<=i)return r}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 n=((ji.HANDLE_DIRECTION_DEG[e]+t*180/Math.PI)%180+180)%180/45,s=["ew","nwse","ns","nesw"];return s[Math.round(n)%s.length]}static resizeBounds(e,t,i,n){const s=Ar(e),r=No(n,s,-t),{x:o,y:c,width:l,height:h}=e,u=t2[i];let d=o,f=c,p=o+l,v=c+h;return u.left&&(d=Math.min(r.x,p-Lo)),u.right&&(p=Math.max(r.x,d+Lo)),u.top&&(f=Math.min(r.y,v-Lo)),u.bottom&&(v=Math.max(r.y,f+Lo)),{x:d,y:f,width:p-d,height:v-f}}static resizeShape(e,t,i){if(t==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:n,height:s}=e.bounds,r=ji.resizeBounds(e.bounds,e.angle,t,i);if(e.kind==="oval")return{...e,bounds:r};const o=n===0?1:r.width/n,c=s===0?1:r.height/s;return{...e,bounds:r,points:e.points.map(l=>({x:l.x*o,y:l.y*c}))}}static rotateShape(e,t){const i=Ar(e.bounds),n=Math.atan2(t.y-i.y,t.x-i.x)+Math.PI/2;return{...e,angle:n}}static groupBoundsFor(e){const t=Math.min(...e.map(r=>r.x)),i=Math.min(...e.map(r=>r.y)),n=Math.max(...e.map(r=>r.x+r.width)),s=Math.max(...e.map(r=>r.y+r.height));return{x:t,y:i,width:n-t,height:s-i}}static vertexPointsFor(e){const t=Ar(e.bounds);return e.points.map(i=>No({x:e.bounds.x+i.x,y:e.bounds.y+i.y},t,e.angle))}static hitTestVertex(e,t,i=e2){const n=ji.vertexPointsFor(e);let s,r=i;return n.forEach((o,c)=>{const l=Math.hypot(t.x-o.x,t.y-o.y);l<=r&&(r=l,s=c)}),s}static toLocalPoint(e,t){const i=Ar(e.bounds),n=No(t,i,-e.angle);return{x:n.x-e.bounds.x,y:n.y-e.bounds.y}}static moveVertex(e,t,i){const n=e.points.map((u,d)=>d===t?ji.toLocalPoint(e,i):u),s=Math.min(...n.map(u=>u.x)),r=Math.min(...n.map(u=>u.y)),o=Math.max(...n.map(u=>u.x)),c=Math.max(...n.map(u=>u.y)),l={x:e.bounds.x+s,y:e.bounds.y+r,width:o-s,height:c-r},h=n.map(u=>({x:u.x-s,y:u.y-r}));return{...e,bounds:l,points:h}}static insertVertexNear(e,t){const i=ji.toLocalPoint(e,t),{points:n}=e;let s=n.length-1,r=1/0;for(let c=0;c<n.length;c++){const l=n[c],h=n[(c+1)%n.length],u=ji.distanceToSegment(i,l,h);u<r&&(r=u,s=c)}const o=[...n.slice(0,s+1),i,...n.slice(s+1)];return{...e,points:o}}static distanceToSegment(e,t,i){const n=i.x-t.x,s=i.y-t.y,r=n*n+s*s,o=r===0?0:Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*s)/r)),c=t.x+o*n,l=t.y+o*s;return Math.hypot(e.x-c,e.y-l)}static deleteVertex(e,t){return e.points.length<=Q1?e:{...e,points:e.points.filter((i,n)=>n!==t)}}}const tu=6,Oo=tu/2,D0=20,C0=24,I0=9,P0=6,L0=7,N0=6,On=4;class mo{constructor(e){this.ctx=e}starPoints=0;roll=0;clear(e,t){this.ctx.clearRect(0,0,e,t)}static paintExtent(e){const{x:t,y:i,width:n,height:s}=e.bounds,r=t+n/2,o=i+s/2,c=e.angle%(2*Math.PI)!==0,l=Math.hypot(n,s)/2,h=c?l:n/2,u=c?l:s/2,d=Math.max(n,s)/2,f=e.brightness??0,p=f>0?Math.max(d*(1+I0*f),N0*f)-d:0,v=f>0?d*(1+L0*f)-d:0,m=3*C0*(e.blur??0)+1.5*D0*e.haloScale,g=Math.max(p,v,0)+m+2;return{x:r-h-g,y:o-u-g,width:2*(h+g),height:2*(u+g)}}paintInto(e,t,i,n=!1){this.ctx.save(),this.ctx.scale(i,i),this.ctx.translate(-t.x,-t.y);const s=e.selected?{...e,selected:!1}:e;n?this.paintGhost(s,1.5):this.paintShape(s),this.ctx.restore()}paintShape(e){this.ctx.save(),this.ctx.globalAlpha=1-e.transparency;const t=e.blur??0;t>0&&(this.ctx.filter=`blur(${(C0*t).toFixed(2)}px)`);const i=e.brightness??0;i>0&&this.paintDazzle(e,i),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:i,y:n,width:s,height:r}=e.bounds,o=i+s/2,c=n+r/2,l=Math.max(s,r)/2,h=Math.max(l*(1+I0*t),N0*t);if(h<=0)return;this.ctx.save(),this.ctx.globalCompositeOperation="lighter";const u=this.ctx.createRadialGradient(o,c,0,o,c,h);for(let d=0;d<=P0;d++){const f=d/P0,p=1/(1+24*f*f);this.ctx.globalAlpha=1,u.addColorStop(f,this.withAlpha(e.color,p*t*.55))}if(this.ctx.fillStyle=u,this.ctx.beginPath(),this.ctx.arc(o,c,h,0,2*Math.PI),this.ctx.fill(),this.starPoints>0){const d=l*(1+L0*t);this.ctx.lineWidth=Math.max(1,l*.12),this.ctx.lineCap="round";for(let f=0;f<this.starPoints;f++){const p=f/this.starPoints*Math.PI*2+this.roll,v=o+Math.cos(p)*d,m=c+Math.sin(p)*d,g=this.ctx.createLinearGradient(o,c,v,m);g.addColorStop(0,this.withAlpha(e.color,t*.55)),g.addColorStop(.35,this.withAlpha(e.color,t*.22)),g.addColorStop(1,this.withAlpha(e.color,0)),this.ctx.strokeStyle=g,this.ctx.beginPath(),this.ctx.moveTo(o,c),this.ctx.lineTo(v,m),this.ctx.stroke()}}this.ctx.restore()}dazzledFill(e,t){if(t<=0)return e.color;const i=/^#([0-9a-f]{6})$/i.exec(e.color.trim());if(!i)return e.color;const n=Number.parseInt(i[1],16),s=r=>Math.round(r+(255-r)*t);return`rgb(${s(n>>16&255)}, ${s(n>>8&255)}, ${s(n&255)})`}withAlpha(e,t){const i=Math.max(0,Math.min(1,t)),n=/^#([0-9a-f]{6})$/i.exec(e.trim());if(!n)return e;const s=Number.parseInt(n[1],16);return`rgba(${s>>16&255}, ${s>>8&255}, ${s&255}, ${i.toFixed(3)})`}paintBase(e){this.ctx.fillStyle=this.dazzledFill(e,e.brightness??0),this.tracePath(e),this.ctx.fill()}paintGhost(e,t){this.ctx.save(),this.tracePath(e),this.ctx.setLineDash([t*3,t*2]),this.ctx.lineWidth=t,this.ctx.strokeStyle=e.color,this.ctx.stroke(),this.ctx.restore()}tracePath(e){if(this.ctx.beginPath(),e.kind==="oval"){const{x:t,y:i,width:n,height:s}=e.bounds,r=n/2,o=s/2;this.ctx.ellipse(t+r,i+o,r,o,e.angle,0,2*Math.PI)}else{const{x:t,y:i,width:n,height:s}=e.bounds;this.ctx.save(),this.ctx.translate(t+n/2,i+s/2),this.ctx.rotate(e.angle),this.ctx.translate(-n/2,-s/2),e.points.forEach((r,o)=>{o===0?this.ctx.moveTo(r.x,r.y):this.ctx.lineTo(r.x,r.y)}),this.ctx.closePath(),this.ctx.restore()}}paintHalo(e){this.ctx.save(),this.ctx.shadowColor=e.color,this.ctx.shadowBlur=D0*e.haloScale,this.paintBase(e),this.ctx.restore()}paintSelectionHandles(e){this.paintHandleFrame(ji.handlePointsFor(e),{includeRotate:!0}),e.kind==="polygon"&&this.paintVertexHandles(e)}paintVertexHandles(e){this.ctx.fillStyle="#39f";for(const t of ji.vertexPointsFor(e))this.ctx.beginPath(),this.ctx.ellipse(t.x,t.y,On,On,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(e){this.paintOutline(ji.handlePointsFor(e))}paintSelectionOnly(e){this.paintSelectionHandles(e)}paintPictureFrame(e,t,i){const n=this.ctx;if(n.save(),e&&e.length===4){n.strokeStyle="#39f",n.lineWidth=1.5,n.setLineDash([6,4]),n.beginPath(),n.moveTo(e[0].x,e[0].y);for(const s of e.slice(1))n.lineTo(s.x,s.y);n.closePath(),n.stroke(),n.setLineDash([])}for(const s of t){const r=mo.landmarkColour(s.residualDeg),o=s.selected?3:2;s.selected&&(n.strokeStyle="#fff",n.lineWidth=o+3,n.beginPath(),n.ellipse(s.picture.x,s.picture.y,On+2,On+2,0,0,2*Math.PI),n.stroke()),s.scene&&(n.strokeStyle=r,n.lineWidth=1,n.beginPath(),n.moveTo(s.picture.x,s.picture.y),n.lineTo(s.scene.x,s.scene.y),n.stroke(),n.fillStyle=r,n.beginPath(),n.ellipse(s.scene.x,s.scene.y,On,On,0,0,2*Math.PI),n.fill()),n.strokeStyle=r,n.lineWidth=o,n.beginPath(),n.ellipse(s.picture.x,s.picture.y,On+2,On+2,0,0,2*Math.PI),n.stroke(),this.paintLabel(s.label,s.picture.x+On+5,s.picture.y-On-2,r)}i&&this.paintLabel(i,8,8,"#fff",13),n.restore()}static landmarkColour(e){return e===void 0?"#ffb000":e<=1?"#3c3":e<=3?"#ffb000":"#f33"}paintLabel(e,t,i,n,s=11){const r=this.ctx;r.save(),r.font=`${s}px system-ui, sans-serif`,r.textBaseline="top";const o=r.measureText(e).width;r.fillStyle="rgba(0, 0, 0, 0.6)",r.fillRect(t-3,i-2,o+6,s+4),r.fillStyle=n,r.fillText(e,t,i),r.restore()}paintGroupHandles(e){this.paintHandleFrame(ji.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 i of Om){const n=e[i];this.ctx.fillRect(n.x-Oo,n.y-Oo,tu,tu)}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,Oo+1,Oo+1,0,0,2*Math.PI),this.ctx.fill())}}const O0=.05,U0=.08,F0=2,k0=3,i2=14,n2=.02;class s2{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 i=++this.voiceToken;t.startsWith("src:")?this.buildRecordedVoice(e.src,t,i):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 i=this.context;if(!e||!i)return;const n=i.currentTime;e.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,t.volume))*e.gainScale,n,O0);for(const{param:s,ratio:r}of e.pitch)s.setTargetAtTime(Math.min(t.pitchHz*r,i.sampleRate/2-1),n,O0)}buildSynthesizedVoice(e,t){const i=this.context;if(i)switch(e.kind){case"hum":return this.buildHum(i,t);case"whistle":return this.buildWhistle(i,t);case"rumble":return this.buildRumble(i,t);case"crackle":return this.buildCrackle(i,t);default:return}}buildHum(e,t){const i=e.createOscillator();i.type="sawtooth";const n=e.createOscillator();n.type="sawtooth";const s=e.createBiquadFilter();s.type="lowpass",s.Q.value=1;const r=e.createGain();return r.gain.value=0,i.connect(s),n.connect(s),s.connect(r).connect(e.destination),i.start(),n.start(),{key:t,nodes:[s,r],sources:[i,n],volumeParam:r.gain,gainScale:.16,pitch:[{param:i.frequency,ratio:1},{param:n.frequency,ratio:1.006},{param:s.frequency,ratio:6}]}}buildWhistle(e,t){const i=e.createOscillator();i.type="sine";const n=e.createOscillator();n.type="sine",n.frequency.value=5;const s=e.createGain(),r=e.createGain();return r.gain.value=0,n.connect(s).connect(i.frequency),i.connect(r).connect(e.destination),i.start(),n.start(),{key:t,nodes:[s,r],sources:[i,n],volumeParam:r.gain,gainScale:.22,pitch:[{param:i.frequency,ratio:1},{param:s.gain,ratio:.012}]}}buildRumble(e,t){const i=e.createBufferSource();i.buffer=this.brownNoise(e),i.loop=!0;const n=e.createBiquadFilter();n.type="lowpass",n.Q.value=.8;const s=e.createGain();return s.gain.value=0,i.connect(n).connect(s).connect(e.destination),i.start(),{key:t,nodes:[n,s],sources:[i],volumeParam:s.gain,gainScale:1.4,pitch:[{param:n.frequency,ratio:1}]}}buildCrackle(e,t){const i=e.createBufferSource();i.buffer=this.whiteNoise(e),i.loop=!0;const n=e.createBiquadFilter();n.type="bandpass",n.Q.value=1.2;const s=e.createGain();s.gain.value=0;const r=e.createBufferSource();r.buffer=this.crackleEnvelope(e),r.loop=!0;const o=e.createGain();return o.gain.value=0,r.connect(o).connect(s.gain),i.connect(n).connect(s).connect(e.destination),i.start(),r.start(),{key:t,nodes:[n,s,o],sources:[i,r],volumeParam:o.gain,gainScale:.9,pitch:[{param:n.frequency,ratio:4}]}}async buildRecordedVoice(e,t,i){const n=this.context;if(!n)return;let s;try{s=await this.getBuffer(e)}catch(c){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",c);return}if(i!==this.voiceToken||!this.context)return;const r=n.createBufferSource();r.buffer=s,r.loop=!0;const o=n.createGain();o.gain.value=0,r.connect(o).connect(n.destination),r.start(),this.voice={key:t,nodes:[o],sources:[r],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 i=this.buffers.get(e);return i||(i=fetch(e).then(n=>{if(!n.ok)throw new Error(`Audio fetch failed (${n.status}): ${e}`);return n.arrayBuffer()}).then(n=>t.decodeAudioData(n)),this.buffers.set(e,i)),i}whiteNoise(e){if(!this.noiseBuffer){const t=e.createBuffer(1,Math.floor(e.sampleRate*F0),e.sampleRate),i=t.getChannelData(0);for(let n=0;n<i.length;n++)i[n]=Math.random()*2-1;this.noiseBuffer=t}return this.noiseBuffer}brownNoise(e){const t=e.createBuffer(1,Math.floor(e.sampleRate*F0),e.sampleRate),i=t.getChannelData(0);let n=0,s=0;for(let r=0;r<i.length;r++)n=(n+.02*(Math.random()*2-1))/1.02,i[r]=n,s=Math.max(s,Math.abs(n));if(s>0)for(let r=0;r<i.length;r++)i[r]/=s;return t}crackleEnvelope(e){if(!this.crackleBuffer){const t=e.createBuffer(1,Math.floor(e.sampleRate*k0),e.sampleRate),i=t.getChannelData(0),n=Math.max(1,Math.floor(n2*e.sampleRate)),s=Math.round(k0*i2);for(let r=0;r<s;r++){const o=Math.floor(Math.random()*i.length),c=.4+Math.random()*.6;for(let l=0;l<n&&o+l<i.length;l++)i[o+l]=Math.max(i[o+l],c*(1-l/n))}this.crackleBuffer=t}return this.crackleBuffer}stopVoice(){const e=this.voice,t=this.context;if(this.voice=void 0,!e||!t)return;const i=t.currentTime;e.volumeParam.cancelScheduledValues(i),e.volumeParam.setTargetAtTime(0,i,U0/3);const n=i+U0;for(const s of e.sources){s.onended=()=>{s.disconnect();for(const r of e.nodes)r.disconnect()};try{s.stop(n)}catch{s.disconnect();for(const r of e.nodes)r.disconnect()}}}}function Yc(a){return[...a].sort((e,t)=>e.t-t.t)}function z0(a,e){let t;for(const i of Yc(a)){if(i.t>e)break;t=i}return t}const Nl=Math.PI/180,Uo=180/Math.PI;class ps{constructor(e,t,i){this.kind=e,this.canvasHeightPx=t,this.fovDeg=i;const n=i*Nl/2;this.focalPx=e==="equidistant"?t/2/n:t/2/Math.tan(n)}focalPx;static of(e,t,i){return new ps(e.projection,t,i)}degToPx(e){const t=e*Nl;return this.kind==="equidistant"?this.focalPx*t:2*this.focalPx*Math.tan(t/2)}pxToDeg(e){return this.kind==="equidistant"?e/this.focalPx*Uo:2*Math.atan(e/(2*this.focalPx))*Uo}angleDegToRadiusPx(e){const t=e*Nl;return this.kind==="equidistant"?this.focalPx*t:this.focalPx*Math.tan(t)}halfWidthAngleDeg(e){return this.radiusPxToAngleDeg(this.canvasHeightPx*e/2)}radiusPxToAngleDeg(e){return this.kind==="equidistant"?e/this.focalPx*Uo:Math.atan(e/this.focalPx)*Uo}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(Rt.angularWidthDeg(e))}}class Wi{static fovOf(e,t){return ai(e,t)?.fovDeg??ri.fieldOfViewDeg(e.instrument)}static toAngular(e){this.eachKeyframe(e,(t,i)=>({...t,angular:i.ofBounds(t.bounds)}))}static toBounds(e){this.eachKeyframe(e,(t,i)=>{if(!t.angular)return t;const{width:n,height:s}=i.toBoundsSize(t.angular),r={x:t.bounds.x+(t.bounds.width-n)/2,y:t.bounds.y+(t.bounds.height-s)/2,width:n,height:s};if(t.kind!=="polygon")return{...t,bounds:r};const o=t.bounds.width===0?1:n/t.bounds.width,c=t.bounds.height===0?1:s/t.bounds.height;return{...t,bounds:r,points:t.points.map(l=>({x:l.x*o,y:l.y*c}))}})}static toAim(e){this.eachKeyframe(e,(t,i,n)=>{const s=t.aim&&this.positionOf(e,t.aim,t.bounds,i,n);if(s&&Math.abs(s.x-t.bounds.x)<Wi.UNMOVED_PX&&Math.abs(s.y-t.bounds.y)<Wi.UNMOVED_PX)return t;const r=this.aimFrom(e,i,n,t.bounds);return r?{...t,aim:r}:t})}static UNMOVED_PX=.01;static aimOf(e,t,i){const n=ps.of(e.instrument,Rt.CANVAS_HEIGHT_PX,this.fovOf(e,t));return this.aimFrom(e,n,ai(e,t),i)}static aimFrom(e,t,i,n){if(i?.headingDeg===void 0)return;const s=this.frameCentre(e),r=t.radiusPxToAngleDeg(n.x+n.width/2-s.x),o=t.radiusPxToAngleDeg(s.y-(n.y+n.height/2));return{azimuthDeg:((i.headingDeg+r)%360+360)%360,altitudeDeg:i.pitchDeg+o}}static toPosition(e){this.eachKeyframe(e,(t,i,n)=>{const s=t.aim&&this.positionOf(e,t.aim,t.bounds,i,n);return s?{...t,bounds:{...t.bounds,...s}}:t})}static positionOf(e,t,i,n,s){if(s?.headingDeg===void 0)return;const r=this.frameCentre(e),o=this.shortestArc(t.azimuthDeg-s.headingDeg),c=t.altitudeDeg-s.pitchDeg;return{x:r.x+this.offAxisPx(n,o)-i.width/2,y:r.y-this.offAxisPx(n,c)-i.height/2}}static frameCentre(e){return{x:ri.frameWidthPx(e.instrument,Rt.CANVAS_HEIGHT_PX)/2,y:Rt.CANVAS_HEIGHT_PX/2}}static shortestArc(e){return(e%360+540)%360-180}static offAxisPx(e,t){return Math.abs(t)>=Wi.OFF_CANVAS_DEG?Math.sign(t)*Wi.OFF_CANVAS_PX:e.angleDegToRadiusPx(t)}static OFF_CANVAS_DEG=89;static OFF_CANVAS_PX=1e5;static reproject(e,t,i){const n=ri.frameWidthPx(t,Rt.CANVAS_HEIGHT_PX)/2,s=ri.frameWidthPx(e.instrument,Rt.CANVAS_HEIGHT_PX)/2,r=Rt.CANVAS_HEIGHT_PX/2;for(const o of[...e.timeline.allKeyframes]){const c=this.fovOf(e,o.t),l=i?.get(o.t)??c,h=ps.of(t,Rt.CANVAS_HEIGHT_PX,l),u=ps.of(e.instrument,Rt.CANVAS_HEIGHT_PX,c);e.timeline.addKeyframe(o.t,o.shapes.map(d=>{const{bounds:f}=d.shape,p=f.x+f.width/2-n,v=f.y+f.height/2-r,m=Math.hypot(p,v),g=m===0?1:u.angleDegToRadiusPx(h.radiusPxToAngleDeg(m))/m,_={...f,x:s+p*g-f.width/2,y:r+v*g-f.height/2};return{...d,shape:{...d.shape,bounds:_}}}))}this.toBounds(e)}static eachKeyframe(e,t){const{timeline:i}=e;for(const n of[...i.allKeyframes]){const s=ai(e,n.t),r=this.fovOf(e,n.t),o=ps.of(e.instrument,Rt.CANVAS_HEIGHT_PX,r);i.addKeyframe(n.t,n.shapes.map(c=>({...c,shape:t(c.shape,o,s)})))}}}function a2(a){return un.restore(r2(a),a.provenance)}function r2(a){return Wi.toAngular(a),Wi.toAim(a),{version:1,id:a.id,time:a.event.time,endTime:a.event.endTime,durationSeconds:a.event.durationSeconds,utcOffsetHours:a.event.utcOffsetHours,timeZone:a.event.timeZone,place:a.event.place,witness:a.witness,testimony:a.testimony,description:a.event.description,tags:a.event.tags,timeline:a.timeline.toJSON(),witnessTrack:a.witnessTrack.toJSON(),weatherTrack:a.weatherTrack.toJSON(),soundTrack:a.soundTrack.toJSON(),weather:a.weather,decor:a.decor,milestones:a.milestones.length>0?a.milestones:void 0,references:a.references.length>0?a.references:void 0,roads:a.roads.length>0?a.roads:void 0,weatherSource:a.weatherSource,instrument:a.instrumentId,exposureSeconds:a.exposureSeconds,interpretation:a.interpretation}}function o2(a){const{recording:e,provenance:t}=un.strip(a),i=c2(e);return i.provenance=t,i}function c2(a){const e=new vl({eventType:"sighting",time:a.time,endTime:a.endTime,durationSeconds:a.durationSeconds,utcOffsetHours:a.utcOffsetHours,timeZone:a.timeZone,place:a.place,description:a.description,tags:a.tags},gl.fromJSON(a.timeline),a.witnessTrack?uo.fromJSON(a.witnessTrack):new uo,a.weatherTrack?fo.fromJSON(a.weatherTrack):new fo,a.soundTrack?po.fromJSON(a.soundTrack):new po,a.witness&&{id:a.witness.id,title:a.witness.title,lastName:a.witness.lastName,firstNames:a.witness.firstNames},a.id,a.weather,a.decor??[],a.weatherSource,a.instrument,a.exposureSeconds??a.witnessTrack?.keyframes.map(t=>t.pose.exposureSeconds).find(t=>t!==void 0),Yc(a.milestones??[]),a.references??[],a.roads??[]);return e.testimony=a.testimony,e.interpretation=a.interpretation,Wi.toBounds(e),Wi.toPosition(e),e}const H0=2;function Um(a){return a==="building"||a==="vehicle"}function l2(a,e){const t=a.litKeyframes;if(!t||t.length===0)return a.lit??!1;let i=t[0];for(const n of t){if(n.t>e)break;i=n}return i.lit}function h2(a,e){return a.pattern.kind==="steady"?!0:Fm(a,e,e+1)>.5}function Fm(a,e,t){if(a.pattern.kind==="steady")return 1;const{perMinute:i,dutyCycle:n,phase:s=0}=a.pattern,r=Math.min(Math.max(n,0),1);if(r===0||i<=0)return 0;const o=6e4/i,c=e/o+s,l=t/o+s;if(l<=c)return Math.min(Math.max(c-Math.floor(c),0),r)<r?1:0;const h=u=>Math.floor(u)*r+Math.min(u-Math.floor(u),r);return(h(l)-h(c))/(l-c)}function Ad(a,e){const t=a.track,i={eastM:a.eastM,northM:a.northM,altitudeM:0,headingDeg:a.headingDeg};if(!t||t.length===0)return i;if(t.length===1||e<=t[0].t)return B0(t[0],a);const n=t[t.length-1];if(e>=n.t)return B0(n,a);for(let s=0;s<t.length-1;s++){const r=t[s],o=t[s+1];if(e<r.t||e>o.t)continue;const c=o.t-r.t,l=c===0?0:(e-r.t)/c;return{eastM:r.eastM+(o.eastM-r.eastM)*l,northM:r.northM+(o.northM-r.northM)*l,altitudeM:(r.altitudeM??0)+((o.altitudeM??0)-(r.altitudeM??0))*l,headingDeg:r.headingDeg??a.headingDeg}}return i}function B0(a,e){return{eastM:a.eastM,northM:a.northM,altitudeM:a.altitudeM??0,headingDeg:a.headingDeg??e.headingDeg}}class bn{static PIXELS_PER_INSTANT=2;static INSTANTS_PER_FLASH=2;static MAX_INSTANTS=512;static windowEndingAt(e,t){const i=Number.isFinite(t)?Math.max(0,t):0,n=Math.max(0,e-i*1e3),s=Math.max(0,e-n);return{fromMs:n,toMs:e,ms:s,seconds:s/1e3}}static instants(e,t,i,n,s){if(!(n>0))return 1;const r=s>0?bn.travelDegOver(e,t,i,i+n*1e3)/s/bn.PIXELS_PER_INSTANT:0,o=bn.flashesOver(e,n)*bn.INSTANTS_PER_FLASH,c=Math.ceil(Math.max(r,o));return c<2?1:Math.min(bn.MAX_INSTANTS,c)}static travelDegOver(e,t,i,n){let s=0;for(const r of e){if(!r.track||r.track.length<2)continue;const o=bn.directionAt(r,t,i),c=bn.directionAt(r,t,n),l=Math.min(1,Math.max(-1,o.x*c.x+o.y*c.y+o.z*c.z));s=Math.max(s,Math.acos(l)*180/Math.PI)}return s}static flashesOver(e,t){let i=0;for(const n of e)for(const s of n.lights??[])s.pattern.kind==="flash"&&(i=Math.max(i,s.pattern.perMinute));return i/60*t}static directionAt(e,t,i){const n=Ad(e,i),s=n.eastM,r=n.altitudeM-t,o=n.northM,c=Math.hypot(s,r,o);return c===0?{x:0,y:1,z:0}:{x:s/c,y:r/c,z:o/c}}}function Td(a,e){for(const t of a){const i=t.toLowerCase().split("-")[0];if(e.includes(i))return i}return"en"}class Kc{static preferencesFor(e){const t=navigator.languages??[],i=this.declaredFor(e);return i?[i,...t]:t}static declaredFor(e){for(let t=e;t;){const i=t.closest("[lang]")?.getAttribute("lang")?.trim();if(i)return i;const n=t.getRootNode();t=n instanceof ShadowRoot?n.host:void 0}}}class ks{constructor(e){this.preferences=e}read(e){if(e===void 0||typeof e=="string")return e===""?void 0:e;for(const i of this.preferences){const n=e[i]??e[ks.base(i)];if(n)return n}const t=new Set(this.preferences.map(i=>ks.base(i)));for(const[i,n]of Object.entries(e))if(n&&t.has(ks.base(i)))return n;return Object.values(e).find(i=>i)??void 0}write(e,t,i){const n=t?.trim()?t.trim():void 0;if(e===void 0||typeof e=="string")return n;const s={...e},r=Object.keys(s).find(o=>o===i)??Object.keys(s).find(o=>ks.base(o)===ks.base(i))??i;return n===void 0?delete s[r]:s[r]=n,Object.keys(s).length===0?void 0:s}static base(e){return e.toLowerCase().split("-")[0]}}const u2=["en","fr"],d2={en:()=>Wc(()=>Promise.resolve().then(()=>p2),void 0,import.meta.url).then(a=>a.ufoMessages_en),fr:()=>Wc(()=>import("./UfoMessages_fr-CnenjNH2.js"),[],import.meta.url).then(a=>a.ufoMessages_fr)};function f2(a){return d2[a]()}const km={play:"Play",pause:"Pause",noDuration:"No observation duration",currentPosition:"Current position",duration:"Duration",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",showWitnessMap:"Show where the witness was",hideWitnessMap:"Hide where the witness was",mapImageryUnavailable:"Aerial imagery unavailable",showReferences:"Show the pictures of the place",hideReferences:"Hide the pictures of the place",referenceOpacity:"Picture opacity",showMilestones:"Show the account's moments",hideMilestones:"Hide the account's moments",witnessHere:"The witness, here",decorHere:"Scenery"},p2=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:km},Symbol.toStringTag,{value:"Module"})),zm=Math.PI/180,m2=180/Math.PI,g2=256,Hm=19,v2=1.25;function Bm(a,e){return 156543.03392*Math.cos(a*zm)/2**e}function Gm(a,e){return Bm(a,e)*g2}function M2(a,e){let t=0;for(;t<Hm&&Gm(a,t+1)>=e;)t++;return t}function Vm(a,e){return Gm(a,e)}function x2(a,e){const t=e*v2;let i=0;for(;i<Hm&&Bm(a,i)>t;)i++;return i}function Nc(a){const e=a*zm;return(1-Math.log(Math.tan(e)+1/Math.cos(e))/Math.PI)/2}function Wm(a,e,t){const i=2**t;return{x:(a+180)/360*i,y:Nc(e)*i}}function Xm(a,e,t){const i=Nc(a.north),n=Nc(a.south);return{x:(e-a.west)/(a.east-a.west),y:(Nc(t)-i)/(n-i)}}function y2(a,e,t){const{x:i,y:n}=Wm(a,e,t);return{x:Math.floor(i),y:Math.floor(n),z:t}}function _2(a){const e=2**a.z,t=a.x/e*360-180,i=(a.x+1)/e*360-180,n=G0(a.y,e);return{south:G0(a.y+1,e),north:n,west:t,east:i}}function G0(a,e){const t=a/e;return Math.atan(Math.sinh(Math.PI*(1-2*t)))*m2}function qm(a,e,t,i){const n=y2(a,e,t),s=Math.floor(i/2),r=[];for(let l=-s;l<=s;l++)for(let h=-s;h<=s;h++)r.push({x:n.x+h,y:n.y+l,z:t});const o=r.map(_2),c={south:Math.min(...o.map(l=>l.south)),north:Math.max(...o.map(l=>l.north)),west:Math.min(...o.map(l=>l.west)),east:Math.max(...o.map(l=>l.east))};return{tiles:r,bounds:c}}class aa{constructor(e){this.ctx=e}static SCALE_STEPS_M=[5e3,2e3,1e3,500,200,100,50,20,10,5];static MARKER_RADIUS_PX=8.5;static ON_MARKER_M=3;targets=[];hitTest(e,t){let i,n=1/0;for(const s of this.targets){const r=Math.hypot(s.x-e,s.y-t);r>s.radius||r>n||(i=s,n=r)}return i}get width(){return this.ctx.canvas.width}get height(){return this.ctx.canvas.height}paint(e){const{ctx:t}=this;t.save(),this.targets=[],t.clearRect(0,0,this.width,this.height),this.paintGround(e),this.paintNight(e.nightFraction),this.paintPath(e),e.position?(this.paintCone(e,e.position),this.paintDecor(e),this.paintMarkers(e),this.paintWitness(e,e.position)):(this.paintDecor(e),this.paintMarkers(e)),this.paintNorth(),this.paintFooter(e.bounds,e.attribution),t.restore()}toCanvas(e,t,i){const n=Xm(e,i,t);return{x:n.x*this.width,y:n.y*this.height}}paintGround(e){const{ctx:t}=this;t.fillStyle="#1d2321",t.fillRect(0,0,this.width,this.height);const i=e.imagery;if(!i)return;const n=this.toCanvas(e.bounds,i.bounds.north,i.bounds.west),s=this.toCanvas(e.bounds,i.bounds.south,i.bounds.east);t.drawImage(i.source,n.x,n.y,s.x-n.x,s.y-n.y)}paintNight(e=0){if(e<=0)return;const{ctx:t}=this;t.save(),t.fillStyle=`rgba(6, 12, 30, ${Math.min(e,1)*.78})`,t.fillRect(0,0,this.width,this.height),t.restore()}paintDecor(e){const{ctx:t}=this;for(const i of e.decor){const n=this.toCanvas(e.bounds,i.lat,i.lng);if(i.label&&this.targets.push({kind:"decor",label:i.label,lat:i.lat,lng:i.lng,x:n.x,y:n.y,radius:7}),t.beginPath(),t.rect(n.x-3.5,n.y-3.5,7,7),t.fillStyle="rgba(120, 220, 255, 0.85)",t.fill(),t.lineWidth=1.5,t.strokeStyle="rgba(0, 0, 0, 0.7)",t.stroke(),i.headingDeg===void 0)continue;const s=(i.headingDeg-90)*Math.PI/180;t.beginPath(),t.moveTo(n.x,n.y),t.lineTo(n.x+Math.cos(s)*10,n.y+Math.sin(s)*10),t.lineWidth=3,t.strokeStyle="rgba(0, 0, 0, 0.6)",t.stroke(),t.lineWidth=1.5,t.strokeStyle="rgba(120, 220, 255, 0.9)",t.stroke()}}paintPath(e){if(!e.path.moved)return;const{ctx:t}=this,i=e.path.points.map(n=>this.toCanvas(e.bounds,n.lat,n.lng));t.beginPath(),t.moveTo(i[0].x,i[0].y);for(const n of i.slice(1))t.lineTo(n.x,n.y);t.lineJoin="round",t.lineCap="round",t.strokeStyle="rgba(0, 0, 0, 0.65)",t.lineWidth=5,t.stroke(),t.strokeStyle="rgba(255, 255, 255, 0.9)",t.lineWidth=2,t.stroke()}paintCone(e,t){const{headingDeg:i,coneHalfAngleDeg:n}=e;if(i===void 0||n===void 0)return;const{ctx:s}=this,r=this.toCanvas(e.bounds,t.lat,t.lng),o=Math.hypot(this.width,this.height),c=(i-90)*Math.PI/180,l=n*Math.PI/180;s.save(),s.beginPath(),s.moveTo(r.x,r.y),s.arc(r.x,r.y,o,c-l,c+l),s.closePath();const h=s.createRadialGradient(r.x,r.y,0,r.x,r.y,o);h.addColorStop(0,"rgba(255, 224, 130, 0.55)"),h.addColorStop(.35,"rgba(255, 224, 130, 0.22)"),h.addColorStop(1,"rgba(255, 224, 130, 0)"),s.fillStyle=h,s.fill(),s.restore()}paintMarkers(e){const{ctx:t}=this;t.textAlign="center",t.textBaseline="middle",t.font="bold 10px sans-serif";for(const i of[...e.markers].sort((n,s)=>Number(n.current)-Number(s.current))){const n=this.toCanvas(e.bounds,i.lat,i.lng);this.targets.push({kind:"milestone",label:i.note?`${i.label} — ${i.note}`:i.label,lat:i.lat,lng:i.lng,t:i.t,x:n.x,y:n.y,radius:aa.MARKER_RADIUS_PX}),t.beginPath(),t.arc(n.x,n.y,aa.MARKER_RADIUS_PX,0,Math.PI*2),t.fillStyle=i.current?"rgba(255, 224, 130, 0.95)":"rgba(0, 0, 0, 0.55)",t.fill(),t.lineWidth=2,t.strokeStyle="rgba(255, 255, 255, 0.9)",t.stroke(),t.fillStyle=i.current?"#1d2321":"#fff",t.fillText(i.label,n.x,n.y)}}paintWitness(e,t){const{ctx:i}=this,n=this.toCanvas(e.bounds,t.lat,t.lng);e.witnessLabel&&this.targets.push({kind:"witness",label:e.witnessLabel,lat:t.lat,lng:t.lng,x:n.x,y:n.y,radius:8});const s=e.markers.some(r=>{if(!r.current)return!1;const o=li(r.lat,r.lng,t.lat,t.lng);return Math.hypot(o.x,o.z)<=aa.ON_MARKER_M});i.beginPath(),i.arc(n.x,n.y,s?aa.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),s||(i.fillStyle="#ff5a3c",i.fill()),i.lineWidth=4,i.strokeStyle="rgba(0, 0, 0, 0.5)",i.stroke(),i.lineWidth=s?3:2.5,i.strokeStyle=s?"#ff5a3c":"#fff",i.stroke()}paintNorth(){const{ctx:e}=this,t=this.width-14,i=16;e.beginPath(),e.moveTo(t,i-9),e.lineTo(t-4.5,i+5),e.lineTo(t,i+2),e.lineTo(t+4.5,i+5),e.closePath(),e.fillStyle="rgba(255, 255, 255, 0.92)",e.strokeStyle="rgba(0, 0, 0, 0.6)",e.lineWidth=1,e.fill(),e.stroke(),e.font="bold 9px sans-serif",e.textAlign="center",e.textBaseline="top",e.strokeText("N",t,i+6),e.fillText("N",t,i+6)}paintFooter(e,t){const{ctx:i}=this;i.font="9px sans-serif",i.textBaseline="bottom";const n=t?this.wrap(t,this.width-20):[];let s=this.height-4;i.textAlign="right";for(const f of n.slice().reverse())this.paintOutlinedText(f,this.width-6,s),s-=11;const r=(e.south+e.north)/2,c=Math.abs(li(r,e.east,r,e.west).x)/this.width,l=aa.SCALE_STEPS_M.find(f=>f/c<=this.width/3);if(l===void 0)return;const h=l/c,u=8,d=s-3;i.lineWidth=3,i.strokeStyle="rgba(0, 0, 0, 0.6)",i.beginPath(),i.moveTo(u,d),i.lineTo(u+h,d),i.stroke(),i.lineWidth=1.5,i.strokeStyle="rgba(255, 255, 255, 0.95)",i.stroke(),i.textAlign="left",this.paintOutlinedText(l>=1e3?`${l/1e3} km`:`${l} m`,u,d-3)}paintOutlinedText(e,t,i){const{ctx:n}=this;n.lineWidth=3,n.strokeStyle="rgba(0, 0, 0, 0.75)",n.strokeText(e,t,i),n.fillStyle="#fff",n.fillText(e,t,i)}wrap(e,t){const i=[];let n="";for(const s of e.split(" ")){const r=n?`${n} ${s}`:s;n&&this.ctx.measureText(r).width>t?(i.push(n),n=s):n=r}return n&&i.push(n),i}}const rn=256,V0=3,S2=32768;class w2{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 i=(e.south+e.north)/2,n=(e.west+e.east)/2,s=Math.abs(li(i,e.east,i,e.west).x),r=Math.abs(li(e.north,n,e.south,n).z),o=M2(i,Math.max(s,r)),{tiles:c}=qm(n,i,o,V0),l=V0*rn,h=new Float32Array(l*l),u=c[0];await Promise.all(c.map(f=>this.decodeTileInto(f,u,h,l)));const d=new Float32Array(t.width*t.height);for(let f=0;f<t.height;f++){const p=e.north+(e.south-e.north)*(f/(t.height-1));for(let v=0;v<t.width;v++){const m=e.west+(e.east-e.west)*(v/(t.width-1));d[f*t.width+v]=this.sampleAt(p,m,o,u,h,l)}}return{heights:d,width:t.width,height:t.height,bounds:e}}async decodeTileInto(e,t,i,n){const s=this.tileUrlTemplate.replace("{z}",String(e.z)).replace("{x}",String(e.x)).replace("{y}",String(e.y)),r=await this.fetchImpl(s);if(!r.ok)throw new Error(`Elevation tile fetch failed (${r.status}): ${s}`);const o=await createImageBitmap(await r.blob()),c=document.createElement("canvas");c.width=rn,c.height=rn;const l=c.getContext("2d");if(!l)throw new Error("2D canvas context unavailable");l.drawImage(o,0,0);const{data:h}=l.getImageData(0,0,rn,rn),u=(e.x-t.x)*rn,d=(e.y-t.y)*rn;for(let f=0;f<rn;f++)for(let p=0;p<rn;p++){const v=(f*rn+p)*4,m=h[v]*256+h[v+1]+h[v+2]/256-S2,g=u+p,_=d+f;i[_*n+g]=m}}sampleAt(e,t,i,n,s,r){const{x:o,y:c}=Wm(t,e,i),l=(o-n.x)*rn,h=(c-n.y)*rn,u=Math.max(0,Math.min(r-1,Math.floor(l))),d=Math.max(0,Math.min(r-1,Math.floor(h))),f=Math.min(r-1,u+1),p=Math.min(r-1,d+1),v=l-u,m=h-d,g=s[d*r+u],_=s[d*r+f],w=s[p*r+u],M=s[p*r+f],S=g+(_-g)*v,b=w+(M-w)*v;return S+(b-S)*m}}const Oc=256,b2=5;async function E2(a,e,t,i){const n=(a.south+a.north)/2,s=(a.west+a.east)/2,r=Math.abs(li(n,a.east,n,a.west).x),o=Math.abs(li(a.north,s,a.south,s).z),c=Math.max(r,o),{zoom:l,gridSize:h}=A2(n,c,Math.max(e.width,e.height)),{tiles:u,bounds:d}=qm(s,n,l,h),f=h*Oc,p=document.createElement("canvas");p.width=f,p.height=f;const v=p.getContext("2d");if(!v)throw new Error("2D canvas context unavailable");const m=u[0];await Promise.all(u.map(async M=>{const S=t(M),b=await i(S);if(!b.ok)throw new Error(`Imagery tile fetch failed (${b.status}): ${S}`);const T=await createImageBitmap(await b.blob());v.drawImage(T,(M.x-m.x)*Oc,(M.y-m.y)*Oc)}));const g=Math.min(Math.max(e.width,e.height),f);if(g===f)return{source:p,width:f,height:f,bounds:d};const _=document.createElement("canvas");_.width=g,_.height=g;const w=_.getContext("2d");if(!w)throw new Error("2D canvas context unavailable");return w.drawImage(p,0,0,f,f,0,0,g,g),{source:_,width:g,height:g,bounds:d}}function A2(a,e,t){let i=x2(a,e/Math.max(1,t)),n=W0(a,i,e);for(;n>b2&&i>0;)i--,n=W0(a,i,e);return{zoom:i,gridSize:n,mPerPixel:Vm(a,i)/Oc}}function W0(a,e,t){const i=Math.ceil(t/2/Vm(a,e));return Math.max(3,2*i+1)}class T2{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 E2(e,t,i=>this.tileUrlTemplate.replace("{z}",String(i.z)).replace("{y}",String(i.y)).replace("{x}",String(i.x)),this.fetchImpl)}}class _n{attribution="Roads © OpenStreetMap contributors, as surveyed today";contemporary=!0;static DRIVABLE=["motorway","trunk","primary","secondary","tertiary","unclassified","residential","service","track","motorway_link","trunk_link","primary_link","secondary_link","tertiary_link"];static WIDTH_M={motorway:11,trunk:9,primary:8,secondary:7,tertiary:6.5,unclassified:5.5,residential:5.5,service:4,track:3.5};static DEFAULT_WIDTH_M=5;static ENDPOINTS=["https://overpass-api.de/api/interpreter","https://overpass.kumi.systems/api/interpreter","https://overpass.private.coffee/api/interpreter"];fetchImpl;endpoints;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.endpoints=e.endpoints??_n.ENDPOINTS}static queue=Promise.resolve();static RETRY_MS=4e3;async getRoads(e){const t=`${e.south},${e.west},${e.north},${e.east}`,i=`[out:json][timeout:30];way["highway"~"^(${_n.DRIVABLE.join("|")})$"](${t});out geom;`;return this.waysFrom(await this.queued(()=>this.ask(i)))}waysFrom(e){const t=[];for(const i of e.elements??[]){const n=i.geometry,s=i.tags;!s||!n||n.length<2||t.push({id:`osm-${i.id??t.length}`,name:s.name,surface:_n.surfaceOf(s),widthM:_n.widthOf(s),points:n.map(r=>({lat:r.lat,lng:r.lon}))})}return t}queued(e){const t=_n.queue.then(e,e);return _n.queue=t.catch(()=>{}),t}async ask(e){let t;for(const i of this.endpoints)for(let n=0;n<2;n++){try{const s=await this.fetchImpl(`${i}?data=${encodeURIComponent(e)}`);if(s.ok)return await s.json();if(t=new Error(`${new URL(i).host} refused (${s.status})`),s.status!==429&&s.status!==504)break}catch(s){t=new Error(`${new URL(i).host} unreachable (${String(s)})`);break}await new Promise(s=>setTimeout(s,_n.RETRY_MS))}throw t??new Error("No Overpass instance answered")}static widthOf(e){const t=Number.parseFloat(e.width??e.est_width??"");if(Number.isFinite(t)&&t>0)return t;const i=Number.parseInt(e.lanes??"",10);return Number.isFinite(i)&&i>0?i*3.5:_n.WIDTH_M[e.highway]??_n.DEFAULT_WIDTH_M}static surfaceOf(e){const t=e.surface;return t==="dirt"||t==="earth"||t==="mud"?"dirt":t==="gravel"||t==="fine_gravel"||t==="compacted"||t==="ground"||t==="sand"||t==="unpaved"?"gravel":t?"paved":e.highway==="track"?"gravel":"paved"}}const Ol="https://ufoathome.org/roads/index.json";class Rd{attributionRead;contemporaryRead;fetchImpl;indexUrls;fallback;index;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.indexUrls=e.indexUrls??Rd.defaultIndexUrls(),this.fallback=e.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Roads © OpenStreetMap contributors"}get contemporary(){return this.contemporaryRead??this.fallback?.contemporary??!0}async getRoads(e){const t=await this.held(e);if(t)return t;if(!this.fallback)return[];const i=await this.fallback.getRoads(e);return this.attributionRead=this.fallback.attribution,this.contemporaryRead=this.fallback.contemporary,i}async held(e){let t;try{t=await this.load()}catch{return}const i=t.find(({entry:n})=>n.north>=e.north&&n.south<=e.south&&n.east>=e.east&&n.west<=e.west);if(i)try{const n=await this.fetchImpl(new URL(i.entry.file,i.indexUrl).href);if(!n.ok)return;const s=await n.json();return Array.isArray(s?.ways)?(this.attributionRead=s.attribution,this.contemporaryRead=s.contemporary,s.ways):void 0}catch{return}}load(){return this.index??=this.fetchFirstAvailable(),this.index}async fetchFirstAvailable(){for(const e of this.indexUrls)try{const t=await this.fetchImpl(e);if(!t.ok)continue;const i=await t.json();if(Array.isArray(i?.entries))return i.entries.map(n=>({entry:n,indexUrl:e}))}catch{}return[]}static defaultIndexUrls(){const e=`?v=${encodeURIComponent("0.65.0")}`,t=typeof location>"u"?void 0:new URL("/roads/index.json",location.href).href;return(t&&t!==Ol?[t,Ol]:[Ol]).map(i=>i+e)}}function R2(){return{elevation:new w2,imagery:Ym(),roads:D2()}}function Ym(){return new T2}function D2(){return new Rd({fallback:new _n})}const C2=new Set,ar="show-witness-map",rr="hide-milestones";class Ki extends HTMLElement{static get observedAttributes(){return["src",ar,rr]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;static WITNESS_MAP_MIN_SPAN_M=400;static WITNESS_MAP_MARGIN=.6;static WITNESS_MAP_IMAGERY_PX=768;fullscreenButton;cornerButtons;witnessMapButton;referencesButton;referenceOpacityInput;referencesShownState=!0;referenceOpacityTouched=!1;milestonesButton;witnessMapPanel;witnessMapCanvas;witnessMapRenderer;seekInput;milestoneMarks;milestoneCaption;timeStartLabel;timeEndLabel;witnessPath;witnessMapBounds;witnessMapImagery;witnessMapImageryRequested=!1;witnessMapImageryCredit;witnessMapImageryFailed=!1;creditShownExternally=!1;lookYawDeg=0;lookPitchDeg=0;milestonesShown=!0;currentSighting=vl.create();sightingAudio=new s2;soundPreview;player;loopEnabled=!1;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;selectionShown=!0;overlayPainter;enableClickToPlay=!0;fullscreenTarget;messages=km;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>{this.updateFullscreenButton(),this.resizeWitnessMap()};witnessMapResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.resizeWitnessMap());resizeWitnessMap(){this.witnessMapPanel.hidden||(this.sizeWitnessMapCanvas(),this.paintWitnessMap(this.currentTime))}simulatedFullscreen=!1;styleBeforeSimulatedFullscreen;bodyOverflowBeforeSimulatedFullscreen;handleSimulatedFullscreenKey=e=>{e.key==="Escape"&&this.exitSimulatedFullscreen()};handlePointerMove=e=>{const t=this.canvasPointFromEvent(e),i=t&&this.shapeAt(t.x,t.y),n=this.said.read(i?.shape.title);if(!n){this.tooltip.hidden=!0;return}this.tooltip.textContent=n,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`};handleWitnessMapPointerMove=e=>{const t=this.witnessMapTargetFrom(e);if(!t){this.tooltip.hidden=!0,this.witnessMapCanvas.style.cursor="default";return}this.witnessMapCanvas.style.cursor="pointer",this.tooltip.textContent=t.label,this.tooltip.hidden=!1;const i=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${e.clientX-i.left+12}px`,this.tooltip.style.top=`${e.clientY-i.top+12}px`};handleWitnessMapClick=e=>{const t=this.witnessMapTargetFrom(e);if(t){if(t.kind==="milestone"&&t.t!==void 0){this.player.seek(t.t);return}this.dispatchEvent(new CustomEvent("lookat",{detail:{lat:t.lat,lng:t.lng,kind:t.kind},bubbles:!0,composed:!0}))}};witnessMapTargetFrom(e){const t=this.witnessMapCanvas.getBoundingClientRect();if(!(t.width===0||t.height===0))return this.witnessMapRenderer.hitTest((e.clientX-t.left)/t.width*this.witnessMapCanvas.width,(e.clientY-t.top)/t.height*this.witnessMapCanvas.height)}handlePointerLeave=()=>{this.tooltip.hidden=!0};constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${C1}</style>${D1}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new mo(this.canvas.getContext("2d")),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.playPauseButton=this.shadow.getElementById("play-pause"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.cornerButtons=this.shadow.getElementById("corner-buttons"),this.witnessMapButton=this.shadow.getElementById("witness-map"),this.referencesButton=this.shadow.getElementById("references"),this.referenceOpacityInput=this.shadow.getElementById("reference-opacity"),this.milestonesButton=this.shadow.getElementById("milestones"),this.witnessMapPanel=this.shadow.getElementById("witness-map-panel"),this.witnessMapCanvas=this.shadow.getElementById("witness-map-canvas"),this.witnessMapRenderer=new aa(this.witnessMapCanvas.getContext("2d")),this.seekInput=this.shadow.getElementById("seek"),this.milestoneMarks=this.shadow.getElementById("milestone-marks"),this.milestoneCaption=this.shadow.getElementById("milestone-caption"),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",i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),this.toggleTimeDisplay())});this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.witnessMapButton.addEventListener("click",()=>this.toggleWitnessMap()),this.referencesButton.addEventListener("click",()=>this.toggleReferences()),this.referenceOpacityInput.addEventListener("input",()=>{this.referenceOpacityTouched=!0,this.dispatchReferenceView()}),this.milestonesButton.addEventListener("click",()=>this.toggleMilestones()),this.witnessMapCanvas.addEventListener("pointermove",this.handleWitnessMapPointerMove),this.witnessMapCanvas.addEventListener("pointerleave",this.handlePointerLeave),this.witnessMapCanvas.addEventListener("click",this.handleWitnessMapClick),this.seekInput.addEventListener("input",()=>this.player.seek(this.snapSeekToMark(Number(this.seekInput.value)))),this.seekInput.addEventListener("pointerdown",t=>{this.seekSnapArmed=!0,this.nameMarkUnder(t)}),this.seekInput.addEventListener("pointerup",()=>{this.seekSnapArmed=!1}),this.seekInput.addEventListener("pointermove",t=>this.nameMarkUnder(t)),this.seekInput.addEventListener("pointerleave",()=>this.seekInput.removeAttribute("title")),this.canvas.addEventListener("click",t=>{this.enableClickToPlay&&(t.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause())}),this.canvas.addEventListener("dblclick",t=>{this.enableClickToPlay&&(t.preventDefault(),this.restorePlayback(),this.toggleFullscreen())}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),this.witnessMapResizeObserver?.observe(this.witnessMapPanel),this.hostControls(void 0),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateReferencesButton(),this.updateMilestonesButton(),this.refresh(),this.loadLocaleMessages()}connectedCallback(){this.saidTexts=void 0;const e=this.getAttribute("src");e&&this.loadFromSrc(e)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.witnessMapResizeObserver?.disconnect(),this.exitSimulatedFullscreen(),this.sightingAudio.dispose()}attributeChangedCallback(e,t,i){e==="src"&&i&&i!==t&&this.isConnected&&this.loadFromSrc(i),e===ar&&this.applyWitnessMapDefault(),e===rr&&this.setMilestonesShown(!this.hasAttribute(rr))}async loadFromSrc(e){this.sightingData=await Nm.json(e)}get sightingData(){return a2(this.currentSighting)}set sightingData(e){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=o2(e),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh(),this.applyWitnessMapDefault()}get sighting(){return this.currentSighting}previewSound(e){this.soundPreview=e,this.sightingAudio.resume(),this.sightingAudio.setSound(e)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(e){this.player.seek(e)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(e){e!==this.loopEnabled&&this.toggleLoop()}play(){this.player.seekableDuration<=0||this.playbackState==="playing"||this.togglePlayPause()}pause(){this.playbackState==="playing"&&this.togglePlayPause()}get positionLabel(){return this.timeStartLabel.textContent??""}get durationLabel(){return this.timeEndLabel.textContent??""}get showingClockTime(){return this.canShowClockTime}get canSwitchTimeDisplay(){return this.realStartMs!==void 0}toggleTimeDisplay(){this.canSwitchTimeDisplay&&(this.showClockTime=!this.showClockTime,this.updateTimeLabels(),this.updateTimeLabelTitles(),this.dispatchEvent(new CustomEvent("timedisplaychange",{bubbles:!0,composed:!0})))}get canShowClockTime(){return this.realStartMs!==void 0&&this.showClockTime}set showToolbar(e){this.toolbar.classList.toggle("hidden",!e)}get playbackState(){return this.player.playbackState}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(e){this.currentSighting.event.durationSeconds=e,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(e){const t=new Set(e);t.size===this.highlightedSourceIds.size&&[...t].every(n=>this.highlightedSourceIds.has(n))||(this.highlightedSourceIds=t,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.refreshMilestoneMarks(),this.updateMilestonesButton(),this.updateWitnessMap(),this.updateReferences(),this.player.seek(this.player.time)}hostControls(e){const t=[this.milestonesButton,this.referenceOpacityInput,this.referencesButton,this.witnessMapButton];if(e)for(const i of t)e.appendChild(i);else for(const i of t)this.toolbar.appendChild(i)}get referencesShown(){return this.referencesShownState}get referenceOpacity(){return Number(this.referenceOpacityInput.value)}toggleReferences(){this.referencesShownState=!this.referencesShownState,this.updateReferencesButton(),this.dispatchReferenceView()}updateReferences(){const e=this.currentSighting.references;!this.referenceOpacityTouched&&e.length>0&&(this.referenceOpacityInput.value=String(e[0].opacity)),this.updateReferencesButton()}updateReferencesButton(){const e=this.currentSighting.references.length>0;this.referencesButton.hidden=!e,this.referenceOpacityInput.hidden=!e||!this.referencesShownState,this.referencesButton.setAttribute("aria-pressed",String(this.referencesShownState));const t=this.referencesShownState?this.messages.hideReferences:this.messages.showReferences;this.referencesButton.title=t,this.referencesButton.setAttribute("aria-label",t),this.referenceOpacityInput.title=this.messages.referenceOpacity,this.referenceOpacityInput.setAttribute("aria-label",this.messages.referenceOpacity)}dispatchReferenceView(){this.dispatchEvent(new CustomEvent("referenceview",{detail:{shown:this.referencesShown,opacity:this.referenceOpacity}}))}refreshMilestoneMarks(){const e=this.player.seekableDuration,t=e>0?Yc(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...t.map(i=>{const n=document.createElement("button");n.type="button",n.className="milestone-mark",n.style.left=`${Math.min(Math.max(i.t/e,0),1)*100}%`;const s=this.said.read(i.label)??"",r=this.said.read(i.note),o=r?`${s} — ${r}`:s;return n.title=o,n.setAttribute("aria-label",o),n.dataset.t=String(i.t),n.addEventListener("click",()=>this.player.seek(i.t)),n}))}seekSnapArmed=!1;static MARK_SNAP_PX=6;markNear(e){const t=this.player.seekableDuration,i=this.seekInput.getBoundingClientRect().width;if(t<=0||i<=0)return;const n=Ki.MARK_SNAP_PX/i*t;let s;for(const r of this.milestoneMarks.children){const o=Number(r.dataset.t);Math.abs(o-e)>n||(!s||Math.abs(o-e)<Math.abs(s.t-e))&&(s={t:o,name:r.title})}return s}snapSeekToMark(e){return this.seekSnapArmed?(this.seekSnapArmed=!1,this.markNear(e)?.t??e):e}nameMarkUnder(e){const t=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(t.width<=0||i<=0)return;const n=(e.clientX-t.left)/t.width*i,s=this.markNear(n);s?this.seekInput.title=s.name:this.seekInput.removeAttribute("title")}showMilestoneAt(e){const t=this.milestonesShown&&this.sighting.milestones.length>0?z0(this.sighting.milestones,e):void 0;if(this.milestoneCaption.hidden=t===void 0,!t)return;const i=document.createElement("b");i.textContent=this.said.read(t.label)??"";const n=this.said.read(t.note),s=n?` — ${n}`:"";this.milestoneCaption.replaceChildren(i,document.createTextNode(s))}exposureInstants(e){const t=this.exposureTimes(e),i=1/t.length;return t.map(n=>({shapes:this.shapesAt(n),share:i}))}exposureTimes(e=this.currentTime){const t=bn.windowEndingAt(e,this.currentSighting.exposure??0);if(t.ms<Ki.SHORTEST_VISIBLE_EXPOSURE_MS)return[e];const i=Math.min(Ki.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(t.ms/Ki.SHORTEST_VISIBLE_EXPOSURE_MS))),n=Math.ceil(this.travelPxOver(t.fromMs,t.ms)/Ki.EXPOSURE_STEP_PX),s=Math.min(Ki.MAX_TRAVEL_STEPS,Math.max(i,n)),r=[];for(let o=0;o<s;o++)r.push(t.fromMs+t.ms*o/(s-1));return r}travelPxOver(e,t){const i=this.shapesAt(e),n=this.shapesAt(e+t);let s=0;for(const[r,o]of i){const c=n.get(r);if(!c)continue;const l=c.bounds.x+c.bounds.width/2-(o.bounds.x+o.bounds.width/2),h=c.bounds.y+c.bounds.height/2-(o.bounds.y+o.bounds.height/2);s=Math.max(s,Math.hypot(l,h))}return s}shapeAt(e,t,i){for(const n of this.exposureTimes()){const s=this.currentSighting.timeline.hitTest(n,e,t,i);if(s)return s}}shapesAt(e){const t=new Map;for(const i of this.currentSighting.timeline.sourceIds){const n=this.currentSighting.timeline.getInterpolatedShapeAt(e,i);n&&t.set(i,n)}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=ri.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 i=this.playbackState!=="playing"?this.highlightedSourceIds:C2;this.canvasRenderer.setStarPoints(ri.starPointsOf(this.sighting.instrument));const n=(ai(this.sighting,e)?.rollDeg??0)+this.gaitAt(e).rollDeg;this.canvasRenderer.setRoll(n*Math.PI/180);const s=this.exposureInstants(e),r=this.frameShift;if(this.paintsShapes)for(const o of s)for(const[,c]of o.shapes){const l=o.share,h=l===1?c:{...c,transparency:1-(1-c.transparency)*l};this.canvasRenderer.paintShape(this.shifted(h,r))}for(const[o,c]of s[0].shapes)!this.selectionShown||!i.has(o)||(this.paintsShapes?i.size===1?this.canvasRenderer.paintShape({...c,selected:!0}):this.canvasRenderer.paintMemberOutline(c):this.canvasRenderer.paintSelectionOnly(this.shifted(c,r)));if(this.selectionShown&&i.size>1){const o=ji.groupBoundsFor([...t].filter(([c])=>i.has(c)).map(([,c])=>c.bounds));this.canvasRenderer.paintGroupHandles(o)}this.overlayPainter?.(this.canvasRenderer),this.mapShapeBounds=s.flatMap(o=>[...o.shapes.values()].filter(c=>c.transparency<1).map(c=>this.shifted(c,r).bounds)),this.keepWitnessMapClear(),this.seekInput.value=String(e),this.timeStartLabel.textContent=this.formatPosition(e),this.showMilestoneAt(e),this.paintWitnessMap(e),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(Z1(this.currentSighting,e))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:e}}))}shifted(e,t){return t.x===0&&t.y===0?e:{...e,bounds:{...e.bounds,x:e.bounds.x+t.x,y:e.bounds.y+t.y}}}createPlayer(){const e=new J1(this.currentSighting.timeline,(t,i)=>this.onFrame(t,i));return e.loop=this.loopEnabled,e.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},e}togglePlayPause(){this.player.seekableDuration<=0||(this.player.playbackState==="playing"?(this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh()):(this.sightingAudio.resume(),this.player.play()),this.updatePlayPauseButton())}updatePlayPauseButton(){const e=this.player.playbackState==="playing";this.playPauseButton.textContent=e?"⏸":"▶";const t=this.player.seekableDuration>0;this.playPauseButton.disabled=!t;const i=t?e?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=i,this.playPauseButton.setAttribute("aria-label",i),this.toolbar.classList.toggle("auto-hide",e),this.cornerButtons.classList.toggle("auto-hide",e)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.player.loop=this.loopEnabled}restorePlayback(){const e=this.playbackBeforeClick;e&&(this.currentTime=e.time,e.state==="playing"?this.play():this.pause())}get canUseNativeFullscreen(){return typeof this.fullscreenTarget.requestFullscreen=="function"&&document.fullscreenEnabled}toggleFullscreen(){if(!this.canUseNativeFullscreen){this.simulatedFullscreen?this.exitSimulatedFullscreen():this.enterSimulatedFullscreen();return}document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(e=>{console.error("<rr0-ufo>: requestFullscreen() failed —",e)})}enterSimulatedFullscreen(){const e=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen=e.getAttribute("style")??"",this.bodyOverflowBeforeSimulatedFullscreen=document.body.style.overflow;const t=e.style;t.setProperty("position","fixed"),t.setProperty("inset","0"),t.setProperty("margin","0"),t.setProperty("max-width","none"),t.setProperty("max-height","none"),t.setProperty("aspect-ratio","auto"),t.setProperty("z-index","2147483647"),t.setProperty("background","#000"),t.setProperty("width","100vw"),t.setProperty("width","100dvw"),t.setProperty("height","100vh"),t.setProperty("height","100dvh"),document.body.style.overflow="hidden",this.simulatedFullscreen=!0,document.addEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton()}exitSimulatedFullscreen(){if(!this.simulatedFullscreen)return;const e=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen?e.setAttribute("style",this.styleBeforeSimulatedFullscreen):e.removeAttribute("style"),document.body.style.overflow=this.bodyOverflowBeforeSimulatedFullscreen??"",this.simulatedFullscreen=!1,document.removeEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton()}toggleWitnessMap(){this.setWitnessMapOpen(this.witnessMapPanel.hidden)}applyWitnessMapDefault(){this.setWitnessMapOpen(this.hasAttribute(ar)&&this.witnessPath!==void 0)}setWitnessMapOpen(e){this.witnessMapPanel.hidden=!e,this.witnessMapPanel.removeAttribute("title"),this.witnessMapButton.setAttribute("aria-pressed",String(e)),this.updateWitnessMapButton(),e&&(this.sizeWitnessMapCanvas(),this.loadWitnessMapImagery(),this.paintWitnessMap(this.currentTime))}updateWitnessMapButton(){const t=!this.witnessMapPanel.hidden?this.messages.hideWitnessMap:this.messages.showWitnessMap;this.witnessMapButton.title=t,this.witnessMapButton.setAttribute("aria-label",t)}updateWitnessMap(){const e=this.witnessPath!==void 0;if(this.witnessPath=ho.of(this.currentSighting),this.witnessMapButton.hidden=this.witnessPath===void 0,!e&&this.witnessPath&&this.applyWitnessMapDefault(),!this.witnessPath){this.setWitnessMapOpen(!1),this.witnessMapBounds=void 0;return}const t=this.witnessPath.boundsAround(Ki.WITNESS_MAP_MIN_SPAN_M,Ki.WITNESS_MAP_MARGIN);(!this.witnessMapBounds||!this.sameGround(this.witnessMapBounds,t))&&(this.witnessMapBounds=t,this.witnessMapImagery=void 0,this.witnessMapImageryCredit=void 0,this.witnessMapImageryFailed=!1,this.witnessMapImageryRequested=!1,this.witnessMapPanel.hidden||this.loadWitnessMapImagery())}sameGround(e,t){const i=Math.abs(e.east-e.west)/20;return Math.abs(e.north-t.north)<i&&Math.abs(e.south-t.south)<i&&Math.abs(e.west-t.west)<i&&Math.abs(e.east-t.east)<i}async loadWitnessMapImagery(){if(this.witnessMapImageryRequested||!this.witnessMapBounds)return;this.witnessMapImageryRequested=!0;const e=Ym(),t=this.witnessMapBounds;try{const i=await e.getImageryTexture(t,{width:Ki.WITNESS_MAP_IMAGERY_PX,height:Ki.WITNESS_MAP_IMAGERY_PX});if(this.witnessMapBounds!==t)return;this.witnessMapImagery=i,this.witnessMapImageryCredit=e.attribution}catch{this.witnessMapImageryFailed=!0}this.paintWitnessMap(this.currentTime)}get witnessMapCredit(){return this.witnessMapImageryCredit}get witnessMapFooterLine(){return this.witnessMapImageryFailed?this.messages.mapImageryUnavailable:this.creditShownExternally?void 0:this.witnessMapImageryCredit}mapShapeBounds=[];mapSceneBounds=[];setMapSubjectBounds(e){this.mapSceneBounds=e.map(t=>({x:t.x*this.canvas.width,y:t.y*this.canvas.height,width:t.width*this.canvas.width,height:t.height*this.canvas.height})),this.keepWitnessMapClear()}keepWitnessMapClear(){if(this.witnessMapPanel.hidden)return;const e=this.witnessMapBoxPx;if(!e)return;const t=[...this.mapShapeBounds,...this.mapSceneBounds],i=(l,h,u)=>{for(const d of t)if(!(d.x+d.width<l-u||d.x>h+u)&&!(d.y>e.bottom+u||d.y+d.height<e.top-u))return!0;return!1},n=[this.canvas.width-e.width,this.canvas.width],s=[0,e.width],r=Ki.WITNESS_MAP_CLEARANCE_PX,o=i(...n,0),c=i(...s,0);if(this.witnessMapPanel.classList.toggle("subject-overlap",o&&c),this.witnessMapPanel.classList.contains("on-the-left")){!o&&(c||!i(n[0],n[1],r))&&this.witnessMapPanel.classList.remove("on-the-left");return}i(n[0],n[1],0)&&!i(s[0],s[1],0)&&this.witnessMapPanel.classList.add("on-the-left")}witnessMapBoxPx;static WITNESS_MAP_CLEARANCE_PX=24;sizeWitnessMapCanvas(){const e=this.witnessMapPanel.clientWidth;if(e===0)return;const t=Math.round(e*(globalThis.devicePixelRatio??1));this.measureWitnessMapBox(),this.witnessMapCanvas.width!==t&&(this.witnessMapCanvas.width=t,this.witnessMapCanvas.height=t)}measureWitnessMapBox(){const e=this.witnessMapPanel.getBoundingClientRect(),t=this.canvas.getBoundingClientRect();if(t.width===0||t.height===0)return;const i=this.canvas.width/t.width,n=this.canvas.height/t.height;this.witnessMapBoxPx={width:e.width*i,top:(e.top-t.top)*n,bottom:(e.bottom-t.top)*n}}paintWitnessMap(e){if(this.witnessMapPanel.hidden||!this.witnessPath||!this.witnessMapBounds)return;const t=ai(this.currentSighting,e),i=this.currentSighting.instrument,n=[],s=this.currentSighting.milestones.length>0?z0(this.currentSighting.milestones,e):void 0;for(const r of this.milestonesShown?Yc(this.currentSighting.milestones):[]){const o=ai(this.currentSighting,r.t);o?.lat===void 0||o.lng===void 0||n.push({label:this.said.read(r.label)??"",note:this.said.read(r.note),t:r.t,lat:o.lat,lng:o.lng,current:r===s})}this.witnessMapRenderer.paint({bounds:this.witnessMapBounds,imagery:this.witnessMapImagery,path:this.witnessPath,position:t?.lat!==void 0&&t.lng!==void 0?{lat:t.lat,lng:t.lng}:void 0,headingDeg:t?.headingDeg===void 0?void 0:t.headingDeg+this.lookYawDeg,coneHalfAngleDeg:t?ps.of(i,this.canvas.height,t.fovDeg).halfWidthAngleDeg(ri.aspectOf(i)):void 0,markers:n,decor:this.witnessMapDecorAt(e),witnessLabel:this.said.read(this.currentSighting.witness?.title)??this.messages.witnessHere,nightFraction:this.witnessMapNightFraction,attribution:this.witnessMapFooterLine})}toggleMilestones(){this.setMilestonesShown(!this.milestonesShown)}setMilestonesShown(e){this.milestonesShown=e,this.milestoneMarks.hidden=!e,this.milestonesButton.setAttribute("aria-pressed",String(e)),this.updateMilestonesButton(),this.showMilestoneAt(this.currentTime),this.paintWitnessMap(this.currentTime)}updateMilestonesButton(){this.milestonesButton.hidden=this.currentSighting.milestones.length===0;const e=this.milestonesShown?this.messages.hideMilestones:this.messages.showMilestones;this.milestonesButton.title=e,this.milestonesButton.setAttribute("aria-label",e)}witnessMapDecorAt(e){const t=ai(this.currentSighting,0);return t?.lat===void 0||t.lng===void 0?[]:this.currentSighting.decor.filter(i=>i.kind!=="crop").map(i=>{const n=Ad(i,e),{lat:s,lng:r}=fs(n.eastM,-n.northM,t.lat,t.lng);return{lat:s,lng:r,headingDeg:n.headingDeg,label:this.said.read(i.title)??this.messages.decorHere}})}witnessMapNightFraction;setSunAltitude(e){const t=e===void 0?void 0:Math.max(0,Math.min(1,-e/12));t!==this.witnessMapNightFraction&&(this.witnessMapNightFraction=t,this.paintWitnessMap(this.currentTime))}setLookOffset(e,t){e===this.lookYawDeg&&t===this.lookPitchDeg||(this.lookYawDeg=e,this.lookPitchDeg=t,this.refresh())}get frameShiftPx(){return this.frameShift}get frameShift(){const e=this.gaitAt(this.currentTime),t=this.lookYawDeg+e.yawDeg,i=this.lookPitchDeg+e.pitchDeg;if(t===0&&i===0)return{x:0,y:0};const n=ai(this.currentSighting,this.currentTime),s=ps.of(this.currentSighting.instrument,this.canvas.height,n?.fovDeg??60);return{x:-s.angleDegToRadiusPx(t),y:s.angleDegToRadiusPx(i)}}gaitAt(e){return si.of(this.currentSighting)?.offsetAt(e)??si.STILL}updateFullscreenButton(){const e=this.simulatedFullscreen||document.fullscreenElement===this.fullscreenTarget;this.fullscreenButton.title=e?this.messages.exitFullscreen:this.messages.fullscreen,this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}get said(){return this.saidTexts??=new ks(Kc.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const e=Td(Kc.preferencesFor(this),u2);e!=="en"&&this.applyMessages(await f2(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 i of[this.timeStartLabel,this.timeEndLabel])i.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(i.setAttribute("role","button"),i.setAttribute("tabindex","0")):(i.removeAttribute("role"),i.removeAttribute("tabindex"))}applyMessages(e){this.messages=e,this.updateTimeLabelTitles(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateReferencesButton(),this.updateMilestonesButton()}updateTimeLabels(){const e=this.currentSighting.event,t=Y1(e);this.realDurationMs=t!==void 0&&t>0?t:void 0,this.realStartMs=e.time?eu(e.time):void 0;const i=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&i>0?i/this.realDurationMs:1,this.player.durationOverrideMs=i>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 Fo(e);const t=this.currentSighting.timeline.duration,i=t>0&&e<=t?e/t*this.realDurationMs:e;return this.canShowClockTime?q0(X0(this.realStartMs+i)):Fo(i)}formatEndOfTimeline(){return this.realDurationMs===void 0?Fo(this.currentSighting.timeline.duration):this.canShowClockTime?q0(X0(this.realStartMs+this.realDurationMs)):Fo(this.realDurationMs)}}function X0(a){const e=new Date(a);return{hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds()}}function q0(a){if(a.hour===void 0)return"0:00";const e=t=>String(t).padStart(2,"0");return a.second?`${e(a.hour)}:${e(a.minute??0)}:${e(a.second)}`:`${e(a.hour)}:${e(a.minute??0)}`}function Fo(a){const e=Math.round(a/1e3),t=Math.floor(e/60),i=e%60;return`${t}:${String(i).padStart(2,"0")}`}const iu="rr0-ufo";function Km(){customElements.get(iu)||customElements.define(iu,Ki)}/**
|
|
628
628
|
* @license
|
|
629
629
|
* Copyright 2010-2026 Three.js Authors
|
|
630
630
|
* SPDX-License-Identifier: MIT
|
|
631
|
-
*/const Dd="185",I2=0,Y0=1,P2=2,io=1,L2=2,Zr=3,qs=0,Ot=1,tn=2,Zn=0,Ws=1,Di=2,K0=3,$0=4,Ml=5,ra=100,N2=101,O2=102,U2=103,F2=104,k2=200,go=201,z2=202,H2=203,nu=204,vo=205,B2=206,G2=207,V2=208,W2=209,X2=210,q2=211,Y2=212,K2=213,$2=214,su=0,au=1,ru=2,gr=3,ou=4,cu=5,lu=6,hu=7,Cd=0,Z2=1,J2=2,Jn=0,$m=1,Zm=2,Jm=3,jm=4,Qm=5,eg=6,tg=7,Z0="attached",j2="detached",ig=300,ya=301,vr=302,Ul=303,Fl=304,xl=306,Mo=1e3,xi=1001,uu=1002,wt=1003,Q2=1004,ko=1005,st=1006,kl=1007,da=1008,nn=1009,ng=1010,sg=1011,xo=1012,Id=1013,gn=1014,Ri=1015,Ft=1016,Pd=1017,Ld=1018,yo=1020,ag=35902,rg=35899,og=1021,cg=1022,yi=1023,vs=1026,fa=1027,yl=1028,Nd=1029,_a=1030,Od=1031,Ud=1033,Uc=33776,Fc=33777,kc=33778,zc=33779,du=35840,fu=35841,pu=35842,mu=35843,gu=36196,vu=37492,Mu=37496,xu=37488,yu=37489,$c=37490,_u=37491,Su=37808,wu=37809,bu=37810,Eu=37811,Au=37812,Tu=37813,Ru=37814,Du=37815,Cu=37816,Iu=37817,Pu=37818,Lu=37819,Nu=37820,Ou=37821,Uu=36492,Fu=36494,ku=36495,zu=36283,Hu=36284,Zc=36285,Bu=36286,Jc=2300,Gu=2301,zl=2302,J0=2303,j0=2400,Q0=2401,ef=2402,ev=2500,mE=0,gE=1,vE=2,tv=3200,jc=0,iv=1,zs="",Fi="srgb",Qc="srgb-linear",el="linear",gt="srgb",Da=7680,tf=519,nv=512,sv=513,av=514,Fd=515,rv=516,ov=517,kd=518,cv=519,Vu=35044,tl="300 es",Kn=2e3,_o=2001;function lv(a){for(let e=a.length-1;e>=0;--e)if(a[e]>=65535)return!0;return!1}function hv(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)}function So(a){return document.createElementNS("http://www.w3.org/1999/xhtml",a)}function uv(){const a=So("canvas");return a.style.display="block",a}const nf={};function il(...a){const e="THREE."+a.shift();console.log(e,...a)}function lg(a){const e=a[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=a[1];t&&t.isStackTrace?a[0]+=" "+t.getLocation():a[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return a}function Te(...a){a=lg(a);const e="THREE."+a.shift();{const t=a[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...a)}}function Be(...a){a=lg(a);const e="THREE."+a.shift();{const t=a[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...a)}}function or(...a){const e=a.join(" ");e in nf||(nf[e]=!0,Te(...a))}function dv(a,e,t){return new Promise(function(i,n){function s(){switch(a.clientWaitSync(e,a.SYNC_FLUSH_COMMANDS_BIT,0)){case a.WAIT_FAILED:n();break;case a.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:i()}}setTimeout(s,t)})}const fv={[su]:au,[ru]:lu,[ou]:hu,[gr]:cu,[au]:su,[lu]:ru,[hu]:ou,[cu]:gr};class ba{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const n=i[e];if(n!==void 0){const s=n.indexOf(t);s!==-1&&n.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const n=i.slice(0);for(let s=0,r=n.length;s<r;s++)n[s].call(this,e);e.target=null}}}const wi=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let sf=1234567;const no=Math.PI/180,Mr=180/Math.PI;function Rn(){const a=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(wi[a&255]+wi[a>>8&255]+wi[a>>16&255]+wi[a>>24&255]+"-"+wi[e&255]+wi[e>>8&255]+"-"+wi[e>>16&15|64]+wi[e>>24&255]+"-"+wi[t&63|128]+wi[t>>8&255]+"-"+wi[t>>16&255]+wi[t>>24&255]+wi[i&255]+wi[i>>8&255]+wi[i>>16&255]+wi[i>>24&255]).toLowerCase()}function je(a,e,t){return Math.max(e,Math.min(t,a))}function zd(a,e){return(a%e+e)%e}function pv(a,e,t,i,n){return i+(a-e)*(n-i)/(t-e)}function mv(a,e,t){return a!==e?(t-a)/(e-a):0}function so(a,e,t){return(1-t)*a+t*e}function gv(a,e,t,i){return so(a,e,1-Math.exp(-t*i))}function vv(a,e=1){return e-Math.abs(zd(a,e*2)-e)}function Mv(a,e,t){return a<=e?0:a>=t?1:(a=(a-e)/(t-e),a*a*(3-2*a))}function xv(a,e,t){return a<=e?0:a>=t?1:(a=(a-e)/(t-e),a*a*a*(a*(a*6-15)+10))}function yv(a,e){return a+Math.floor(Math.random()*(e-a+1))}function _v(a,e){return a+Math.random()*(e-a)}function Sv(a){return a*(.5-Math.random())}function wv(a){a!==void 0&&(sf=a);let e=sf+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function bv(a){return a*no}function Ev(a){return a*Mr}function Av(a){return(a&a-1)===0&&a!==0}function Tv(a){return Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function Rv(a){return Math.pow(2,Math.floor(Math.log(a)/Math.LN2))}function Dv(a,e,t,i,n){const s=Math.cos,r=Math.sin,o=s(t/2),c=r(t/2),l=s((e+i)/2),h=r((e+i)/2),u=s((e-i)/2),d=r((e-i)/2),f=s((i-e)/2),p=r((i-e)/2);switch(n){case"XYX":a.set(o*h,c*u,c*d,o*l);break;case"YZY":a.set(c*d,o*h,c*u,o*l);break;case"ZXZ":a.set(c*u,c*d,o*h,o*l);break;case"XZX":a.set(o*h,c*p,c*f,o*l);break;case"YXY":a.set(c*f,o*h,c*p,o*l);break;case"ZYZ":a.set(c*p,c*f,o*h,o*l);break;default:Te("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function An(a,e){switch(e.constructor){case Float32Array:return a;case Uint32Array:return a/4294967295;case Uint16Array:return a/65535;case Uint8Array:return a/255;case Int32Array:return Math.max(a/2147483647,-1);case Int16Array:return Math.max(a/32767,-1);case Int8Array:return Math.max(a/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function vt(a,e){switch(e.constructor){case Float32Array:return a;case Uint32Array:return Math.round(a*4294967295);case Uint16Array:return Math.round(a*65535);case Uint8Array:return Math.round(a*255);case Int32Array:return Math.round(a*2147483647);case Int16Array:return Math.round(a*32767);case Int8Array:return Math.round(a*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const ME={DEG2RAD:no,RAD2DEG:Mr,generateUUID:Rn,clamp:je,euclideanModulo:zd,mapLinear:pv,inverseLerp:mv,lerp:so,damp:gv,pingpong:vv,smoothstep:Mv,smootherstep:xv,randInt:yv,randFloat:_v,randFloatSpread:Sv,seededRandom:wv,degToRad:bv,radToDeg:Ev,isPowerOfTwo:Av,ceilPowerOfTwo:Tv,floorPowerOfTwo:Rv,setQuaternionFromProperEuler:Dv,normalize:vt,denormalize:An};class xe{static{xe.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,i=this.y,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6],this.y=n[1]*t+n[4]*i+n[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=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),n=Math.sin(t),s=this.x-e.x,r=this.y-e.y;return this.x=s*i-r*n+e.x,this.y=s*n+r*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Qn{constructor(e=0,t=0,i=0,n=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=n}static slerpFlat(e,t,i,n,s,r,o){let c=i[n+0],l=i[n+1],h=i[n+2],u=i[n+3],d=s[r+0],f=s[r+1],p=s[r+2],v=s[r+3];if(u!==v||c!==d||l!==f||h!==p){let m=c*d+l*f+h*p+u*v;m<0&&(d=-d,f=-f,p=-p,v=-v,m=-m);let g=1-o;if(m<.9995){const _=Math.acos(m),w=Math.sin(_);g=Math.sin(g*_)/w,o=Math.sin(o*_)/w,c=c*g+d*o,l=l*g+f*o,h=h*g+p*o,u=u*g+v*o}else{c=c*g+d*o,l=l*g+f*o,h=h*g+p*o,u=u*g+v*o;const _=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=_,l*=_,h*=_,u*=_}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,i,n,s,r){const o=i[n],c=i[n+1],l=i[n+2],h=i[n+3],u=s[r],d=s[r+1],f=s[r+2],p=s[r+3];return e[t]=o*p+h*u+c*f-l*d,e[t+1]=c*p+h*d+l*u-o*f,e[t+2]=l*p+h*f+o*d-c*u,e[t+3]=h*p-o*u-c*d-l*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,n){return this._x=e,this._y=t,this._z=i,this._w=n,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 i=e._x,n=e._y,s=e._z,r=e._order,o=Math.cos,c=Math.sin,l=o(i/2),h=o(n/2),u=o(s/2),d=c(i/2),f=c(n/2),p=c(s/2);switch(r){case"XYZ":this._x=d*h*u+l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u-d*f*p;break;case"YXZ":this._x=d*h*u+l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u+d*f*p;break;case"ZXY":this._x=d*h*u-l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u-d*f*p;break;case"ZYX":this._x=d*h*u-l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u+d*f*p;break;case"YZX":this._x=d*h*u+l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u-d*f*p;break;case"XZY":this._x=d*h*u-l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u+d*f*p;break;default:Te("Quaternion: .setFromEuler() encountered an unknown order: "+r)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,n=Math.sin(i);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],n=t[4],s=t[8],r=t[1],o=t[5],c=t[9],l=t[2],h=t[6],u=t[10],d=i+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(s-l)*f,this._z=(r-n)*f}else if(i>o&&i>u){const f=2*Math.sqrt(1+i-o-u);this._w=(h-c)/f,this._x=.25*f,this._y=(n+r)/f,this._z=(s+l)/f}else if(o>u){const f=2*Math.sqrt(1+o-i-u);this._w=(s-l)/f,this._x=(n+r)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+u-i-o);this._w=(r-n)/f,this._x=(s+l)/f,this._y=(c+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(je(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const n=Math.min(1,t/i);return this.slerp(e,n),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 i=e._x,n=e._y,s=e._z,r=e._w,o=t._x,c=t._y,l=t._z,h=t._w;return this._x=i*h+r*o+n*l-s*c,this._y=n*h+r*c+s*o-i*l,this._z=s*h+r*l+i*c-n*o,this._w=r*h-i*o-n*c-s*l,this._onChangeCallback(),this}slerp(e,t){let i=e._x,n=e._y,s=e._z,r=e._w,o=this.dot(e);o<0&&(i=-i,n=-n,s=-s,r=-r,o=-o);let c=1-t;if(o<.9995){const l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,t=Math.sin(t*l)/h,this._x=this._x*c+i*t,this._y=this._y*c+n*t,this._z=this._z*c+s*t,this._w=this._w*c+r*t,this._onChangeCallback()}else this._x=this._x*c+i*t,this._y=this._y*c+n*t,this._z=this._z*c+s*t,this._w=this._w*c+r*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(n*Math.sin(e),n*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class D{static{D.prototype.isVector3=!0}constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("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(af.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(af.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,n=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*n,this.y=s[1]*t+s[4]*i+s[7]*n,this.z=s[2]*t+s[5]*i+s[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,s=e.elements,r=1/(s[3]*t+s[7]*i+s[11]*n+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*n+s[12])*r,this.y=(s[1]*t+s[5]*i+s[9]*n+s[13])*r,this.z=(s[2]*t+s[6]*i+s[10]*n+s[14])*r,this}applyQuaternion(e){const t=this.x,i=this.y,n=this.z,s=e.x,r=e.y,o=e.z,c=e.w,l=2*(r*n-o*i),h=2*(o*t-s*n),u=2*(s*i-r*t);return this.x=t+c*l+r*u-o*h,this.y=i+c*h+o*l-s*u,this.z=n+c*u+s*h-r*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,n=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*n,this.y=s[1]*t+s[5]*i+s[9]*n,this.z=s[2]*t+s[6]*i+s[10]*n,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=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,n=e.y,s=e.z,r=t.x,o=t.y,c=t.z;return this.x=n*c-s*o,this.y=s*r-i*c,this.z=i*o-n*r,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Hl.copy(this).projectOnVector(e),this.sub(Hl)}reflect(e){return this.sub(Hl.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 i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return t*t+i*i+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const n=Math.sin(t)*e;return this.x=n*Math.sin(i),this.y=Math.cos(t)*e,this.z=n*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){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(),i=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=n,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,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Hl=new D,af=new Qn;class Xe{static{Xe.prototype.isMatrix3=!0}constructor(e,t,i,n,s,r,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,n,s,r,o,c,l)}set(e,t,i,n,s,r,o,c,l){const h=this.elements;return h[0]=e,h[1]=n,h[2]=o,h[3]=t,h[4]=s,h[5]=c,h[6]=i,h[7]=r,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){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 i=e.elements,n=t.elements,s=this.elements,r=i[0],o=i[3],c=i[6],l=i[1],h=i[4],u=i[7],d=i[2],f=i[5],p=i[8],v=n[0],m=n[3],g=n[6],_=n[1],w=n[4],M=n[7],S=n[2],b=n[5],T=n[8];return s[0]=r*v+o*_+c*S,s[3]=r*m+o*w+c*b,s[6]=r*g+o*M+c*T,s[1]=l*v+h*_+u*S,s[4]=l*m+h*w+u*b,s[7]=l*g+h*M+u*T,s[2]=d*v+f*_+p*S,s[5]=d*m+f*w+p*b,s[8]=d*g+f*M+p*T,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],i=e[1],n=e[2],s=e[3],r=e[4],o=e[5],c=e[6],l=e[7],h=e[8];return t*r*h-t*o*l-i*s*h+i*o*c+n*s*l-n*r*c}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],s=e[3],r=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=h*r-o*l,d=o*c-h*s,f=l*s-r*c,p=t*u+i*d+n*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/p;return e[0]=u*v,e[1]=(n*l-h*i)*v,e[2]=(o*i-n*r)*v,e[3]=d*v,e[4]=(h*t-n*c)*v,e[5]=(n*s-o*t)*v,e[6]=f*v,e[7]=(i*c-l*t)*v,e[8]=(r*t-i*s)*v,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,i,n,s,r,o){const c=Math.cos(s),l=Math.sin(s);return this.set(i*c,i*l,-i*(c*r+l*o)+r+e,-n*l,n*c,-n*(-l*r+c*o)+o+t,0,0,1),this}scale(e,t){return or("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Bl.makeScale(e,t)),this}rotate(e){return or("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Bl.makeRotation(-e)),this}translate(e,t){return or("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Bl.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),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let n=0;n<9;n++)if(t[n]!==i[n])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Bl=new Xe,rf=new Xe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),of=new Xe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Cv(){const a={enabled:!0,workingColorSpace:Qc,spaces:{},convert:function(n,s,r){return this.enabled===!1||s===r||!s||!r||(this.spaces[s].transfer===gt&&(n.r=gs(n.r),n.g=gs(n.g),n.b=gs(n.b)),this.spaces[s].primaries!==this.spaces[r].primaries&&(n.applyMatrix3(this.spaces[s].toXYZ),n.applyMatrix3(this.spaces[r].fromXYZ)),this.spaces[r].transfer===gt&&(n.r=cr(n.r),n.g=cr(n.g),n.b=cr(n.b))),n},workingToColorSpace:function(n,s){return this.convert(n,this.workingColorSpace,s)},colorSpaceToWorking:function(n,s){return this.convert(n,s,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===zs?el:this.spaces[n].transfer},getToneMappingMode:function(n){return this.spaces[n].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(n,s=this.workingColorSpace){return n.fromArray(this.spaces[s].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,s,r){return n.copy(this.spaces[s].toXYZ).multiply(this.spaces[r].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(n,s){return or("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),a.workingToColorSpace(n,s)},toWorkingColorSpace:function(n,s){return or("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),a.colorSpaceToWorking(n,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return a.define({[Qc]:{primaries:e,whitePoint:i,transfer:el,toXYZ:rf,fromXYZ:of,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Fi},outputColorSpaceConfig:{drawingBufferColorSpace:Fi}},[Fi]:{primaries:e,whitePoint:i,transfer:gt,toXYZ:rf,fromXYZ:of,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Fi}}}),a}const it=Cv();function gs(a){return a<.04045?a*.0773993808:Math.pow(a*.9478672986+.0521327014,2.4)}function cr(a){return a<.0031308?a*12.92:1.055*Math.pow(a,.41666)-.055}let Ca;class Iv{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{Ca===void 0&&(Ca=So("canvas")),Ca.width=e.width,Ca.height=e.height;const n=Ca.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),i=Ca}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=So("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const n=i.getImageData(0,0,e.width,e.height),s=n.data;for(let r=0;r<s.length;r++)s[r]=gs(s[r]/255)*255;return i.putImageData(n,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(gs(t[i]/255)*255):t[i]=gs(t[i]);return{data:t,width:e.width,height:e.height}}else return Te("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Pv=0;class Hd{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Pv++}),this.uuid=Rn(),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 i={uuid:this.uuid,url:""},n=this.data;if(n!==null){let s;if(Array.isArray(n)){s=[];for(let r=0,o=n.length;r<o;r++)n[r].isDataTexture?s.push(Gl(n[r].image)):s.push(Gl(n[r]))}else s=Gl(n);i.url=s}return t||(e.images[this.uuid]=i),i}}function Gl(a){return typeof HTMLImageElement<"u"&&a instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&a instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&a instanceof ImageBitmap?Iv.getDataURL(a):a.data?{data:Array.from(a.data),width:a.width,height:a.height,type:a.data.constructor.name}:(Te("Texture: Unable to serialize Texture."),{})}let Lv=0;const Vl=new D;class Mi extends ba{constructor(e=Mi.DEFAULT_IMAGE,t=Mi.DEFAULT_MAPPING,i=xi,n=xi,s=st,r=da,o=yi,c=nn,l=Mi.DEFAULT_ANISOTROPY,h=zs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Lv++}),this.uuid=Rn(),this.name="",this.source=new Hd(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=s,this.minFilter=r,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new xe(0,0),this.repeat=new xe(1,1),this.center=new xe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Xe,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(Vl).x}get height(){return this.source.getSize(Vl).y}get depth(){return this.source.getSize(Vl).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 i=e[t];if(i===void 0){Te(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){Te(`Texture.setValues(): property '${t}' does not exist.`);continue}n&&i&&n.isVector2&&i.isVector2||n&&i&&n.isVector3&&i.isVector3||n&&i&&n.isMatrix3&&i.isMatrix3?n.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,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&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ig)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Mo:e.x=e.x-Math.floor(e.x);break;case xi:e.x=e.x<0?0:1;break;case uu: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 Mo:e.y=e.y-Math.floor(e.y);break;case xi:e.y=e.y<0?0:1;break;case uu: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++}}Mi.DEFAULT_IMAGE=null;Mi.DEFAULT_MAPPING=ig;Mi.DEFAULT_ANISOTROPY=1;class nt{static{nt.prototype.isVector4=!0}constructor(e=0,t=0,i=0,n=1){this.x=e,this.y=t,this.z=i,this.w=n}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,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,i=this.y,n=this.z,s=this.w,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*n+r[12]*s,this.y=r[1]*t+r[5]*i+r[9]*n+r[13]*s,this.z=r[2]*t+r[6]*i+r[10]*n+r[14]*s,this.w=r[3]*t+r[7]*i+r[11]*n+r[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);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,i,n,s;const c=e.elements,l=c[0],h=c[4],u=c[8],d=c[1],f=c[5],p=c[9],v=c[2],m=c[6],g=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-v)<.01&&Math.abs(p-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+v)<.1&&Math.abs(p+m)<.1&&Math.abs(l+f+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const w=(l+1)/2,M=(f+1)/2,S=(g+1)/2,b=(h+d)/4,T=(u+v)/4,x=(p+m)/4;return w>M&&w>S?w<.01?(i=0,n=.707106781,s=.707106781):(i=Math.sqrt(w),n=b/i,s=T/i):M>S?M<.01?(i=.707106781,n=0,s=.707106781):(n=Math.sqrt(M),i=b/n,s=x/n):S<.01?(i=.707106781,n=.707106781,s=0):(s=Math.sqrt(S),i=T/s,n=x/s),this.set(i,n,s,t),this}let _=Math.sqrt((m-p)*(m-p)+(u-v)*(u-v)+(d-h)*(d-h));return Math.abs(_)<.001&&(_=1),this.x=(m-p)/_,this.y=(u-v)/_,this.z=(d-h)/_,this.w=Math.acos((l+f+g-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=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this.w=je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this.w=je(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Nv extends ba{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:st,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new nt(0,0,e,t),this.scissorTest=!1,this.viewport=new nt(0,0,e,t),this.textures=[];const n={width:e,height:t,depth:i.depth},s=new Mi(n),r=i.count;for(let o=0;o<r;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview,this.useArrayDepthTexture=i.useArrayDepthTexture}_setTextureOptions(e={}){const t={minFilter:st,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let n=0,s=this.textures.length;n<s;n++)this.textures[n].image.width=e,this.textures[n].image.height=t,this.textures[n].image.depth=i,this.textures[n].isData3DTexture!==!0&&(this.textures[n].isArrayTexture=this.textures[n].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const n=Object.assign({},e.textures[t].image);this.textures[t].source=new Hd(n)}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 Jt extends Nv{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class hg extends Mi{constructor(e=null,t=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:n},this.magFilter=wt,this.minFilter=wt,this.wrapR=xi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class ug extends Mi{constructor(e=null,t=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:n},this.magFilter=wt,this.minFilter=wt,this.wrapR=xi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ze{static{Ze.prototype.isMatrix4=!0}constructor(e,t,i,n,s,r,o,c,l,h,u,d,f,p,v,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,i,n,s,r,o,c,l,h,u,d,f,p,v,m)}set(e,t,i,n,s,r,o,c,l,h,u,d,f,p,v,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=n,g[1]=s,g[5]=r,g[9]=o,g[13]=c,g[2]=l,g[6]=h,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=v,g[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 Ze().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[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,i){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const t=this.elements,i=e.elements,n=1/Ia.setFromMatrixColumn(e,0).length(),s=1/Ia.setFromMatrixColumn(e,1).length(),r=1/Ia.setFromMatrixColumn(e,2).length();return t[0]=i[0]*n,t[1]=i[1]*n,t[2]=i[2]*n,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*r,t[9]=i[9]*r,t[10]=i[10]*r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,n=e.y,s=e.z,r=Math.cos(i),o=Math.sin(i),c=Math.cos(n),l=Math.sin(n),h=Math.cos(s),u=Math.sin(s);if(e.order==="XYZ"){const d=r*h,f=r*u,p=o*h,v=o*u;t[0]=c*h,t[4]=-c*u,t[8]=l,t[1]=f+p*l,t[5]=d-v*l,t[9]=-o*c,t[2]=v-d*l,t[6]=p+f*l,t[10]=r*c}else if(e.order==="YXZ"){const d=c*h,f=c*u,p=l*h,v=l*u;t[0]=d+v*o,t[4]=p*o-f,t[8]=r*l,t[1]=r*u,t[5]=r*h,t[9]=-o,t[2]=f*o-p,t[6]=v+d*o,t[10]=r*c}else if(e.order==="ZXY"){const d=c*h,f=c*u,p=l*h,v=l*u;t[0]=d-v*o,t[4]=-r*u,t[8]=p+f*o,t[1]=f+p*o,t[5]=r*h,t[9]=v-d*o,t[2]=-r*l,t[6]=o,t[10]=r*c}else if(e.order==="ZYX"){const d=r*h,f=r*u,p=o*h,v=o*u;t[0]=c*h,t[4]=p*l-f,t[8]=d*l+v,t[1]=c*u,t[5]=v*l+d,t[9]=f*l-p,t[2]=-l,t[6]=o*c,t[10]=r*c}else if(e.order==="YZX"){const d=r*c,f=r*l,p=o*c,v=o*l;t[0]=c*h,t[4]=v-d*u,t[8]=p*u+f,t[1]=u,t[5]=r*h,t[9]=-o*h,t[2]=-l*h,t[6]=f*u+p,t[10]=d-v*u}else if(e.order==="XZY"){const d=r*c,f=r*l,p=o*c,v=o*l;t[0]=c*h,t[4]=-u,t[8]=l*h,t[1]=d*u+v,t[5]=r*h,t[9]=f*u-p,t[2]=p*u-f,t[6]=o*h,t[10]=v*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(Ov,e,Uv)}lookAt(e,t,i){const n=this.elements;return qi.subVectors(e,t),qi.lengthSq()===0&&(qi.z=1),qi.normalize(),As.crossVectors(i,qi),As.lengthSq()===0&&(Math.abs(i.z)===1?qi.x+=1e-4:qi.z+=1e-4,qi.normalize(),As.crossVectors(i,qi)),As.normalize(),zo.crossVectors(qi,As),n[0]=As.x,n[4]=zo.x,n[8]=qi.x,n[1]=As.y,n[5]=zo.y,n[9]=qi.y,n[2]=As.z,n[6]=zo.z,n[10]=qi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,s=this.elements,r=i[0],o=i[4],c=i[8],l=i[12],h=i[1],u=i[5],d=i[9],f=i[13],p=i[2],v=i[6],m=i[10],g=i[14],_=i[3],w=i[7],M=i[11],S=i[15],b=n[0],T=n[4],x=n[8],A=n[12],I=n[1],C=n[5],P=n[9],X=n[13],z=n[2],N=n[6],V=n[10],k=n[14],K=n[3],ee=n[7],J=n[11],ie=n[15];return s[0]=r*b+o*I+c*z+l*K,s[4]=r*T+o*C+c*N+l*ee,s[8]=r*x+o*P+c*V+l*J,s[12]=r*A+o*X+c*k+l*ie,s[1]=h*b+u*I+d*z+f*K,s[5]=h*T+u*C+d*N+f*ee,s[9]=h*x+u*P+d*V+f*J,s[13]=h*A+u*X+d*k+f*ie,s[2]=p*b+v*I+m*z+g*K,s[6]=p*T+v*C+m*N+g*ee,s[10]=p*x+v*P+m*V+g*J,s[14]=p*A+v*X+m*k+g*ie,s[3]=_*b+w*I+M*z+S*K,s[7]=_*T+w*C+M*N+S*ee,s[11]=_*x+w*P+M*V+S*J,s[15]=_*A+w*X+M*k+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],i=e[4],n=e[8],s=e[12],r=e[1],o=e[5],c=e[9],l=e[13],h=e[2],u=e[6],d=e[10],f=e[14],p=e[3],v=e[7],m=e[11],g=e[15],_=c*f-l*d,w=o*f-l*u,M=o*d-c*u,S=r*f-l*h,b=r*d-c*h,T=r*u-o*h;return t*(v*_-m*w+g*M)-i*(p*_-m*S+g*b)+n*(p*w-v*S+g*T)-s*(p*M-v*b+m*T)}determinantAffine(){const e=this.elements,t=e[0],i=e[4],n=e[8],s=e[1],r=e[5],o=e[9],c=e[2],l=e[6],h=e[10];return t*(r*h-o*l)-i*(s*h-o*c)+n*(s*l-r*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const n=this.elements;return e.isVector3?(n[12]=e.x,n[13]=e.y,n[14]=e.z):(n[12]=e,n[13]=t,n[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],s=e[3],r=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=e[9],d=e[10],f=e[11],p=e[12],v=e[13],m=e[14],g=e[15],_=t*o-i*r,w=t*c-n*r,M=t*l-s*r,S=i*c-n*o,b=i*l-s*o,T=n*l-s*c,x=h*v-u*p,A=h*m-d*p,I=h*g-f*p,C=u*m-d*v,P=u*g-f*v,X=d*g-f*m,z=_*X-w*P+M*C+S*I-b*A+T*x;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const N=1/z;return e[0]=(o*X-c*P+l*C)*N,e[1]=(n*P-i*X-s*C)*N,e[2]=(v*T-m*b+g*S)*N,e[3]=(d*b-u*T-f*S)*N,e[4]=(c*I-r*X-l*A)*N,e[5]=(t*X-n*I+s*A)*N,e[6]=(m*M-p*T-g*w)*N,e[7]=(h*T-d*M+f*w)*N,e[8]=(r*P-o*I+l*x)*N,e[9]=(i*I-t*P-s*x)*N,e[10]=(p*b-v*M+g*_)*N,e[11]=(u*M-h*b-f*_)*N,e[12]=(o*A-r*C-c*x)*N,e[13]=(t*C-i*A+n*x)*N,e[14]=(v*w-p*S-m*_)*N,e[15]=(h*S-u*w+d*_)*N,this}scale(e){const t=this.elements,i=e.x,n=e.y,s=e.z;return t[0]*=i,t[4]*=n,t[8]*=s,t[1]*=i,t[5]*=n,t[9]*=s,t[2]*=i,t[6]*=n,t[10]*=s,t[3]*=i,t[7]*=n,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,n))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),n=Math.sin(t),s=1-i,r=e.x,o=e.y,c=e.z,l=s*r,h=s*o;return this.set(l*r+i,l*o-n*c,l*c+n*o,0,l*o+n*c,h*o+i,h*c-n*r,0,l*c-n*o,h*c+n*r,s*c*c+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,n,s,r){return this.set(1,i,s,0,e,1,r,0,t,n,1,0,0,0,0,1),this}compose(e,t,i){const n=this.elements,s=t._x,r=t._y,o=t._z,c=t._w,l=s+s,h=r+r,u=o+o,d=s*l,f=s*h,p=s*u,v=r*h,m=r*u,g=o*u,_=c*l,w=c*h,M=c*u,S=i.x,b=i.y,T=i.z;return n[0]=(1-(v+g))*S,n[1]=(f+M)*S,n[2]=(p-w)*S,n[3]=0,n[4]=(f-M)*b,n[5]=(1-(d+g))*b,n[6]=(m+_)*b,n[7]=0,n[8]=(p+w)*T,n[9]=(m-_)*T,n[10]=(1-(d+v))*T,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,this}decompose(e,t,i){const n=this.elements;e.x=n[12],e.y=n[13],e.z=n[14];const s=this.determinantAffine();if(s===0)return i.set(1,1,1),t.identity(),this;let r=Ia.set(n[0],n[1],n[2]).length();const o=Ia.set(n[4],n[5],n[6]).length(),c=Ia.set(n[8],n[9],n[10]).length();s<0&&(r=-r),Mn.copy(this);const l=1/r,h=1/o,u=1/c;return Mn.elements[0]*=l,Mn.elements[1]*=l,Mn.elements[2]*=l,Mn.elements[4]*=h,Mn.elements[5]*=h,Mn.elements[6]*=h,Mn.elements[8]*=u,Mn.elements[9]*=u,Mn.elements[10]*=u,t.setFromRotationMatrix(Mn),i.x=r,i.y=o,i.z=c,this}makePerspective(e,t,i,n,s,r,o=Kn,c=!1){const l=this.elements,h=2*s/(t-e),u=2*s/(i-n),d=(t+e)/(t-e),f=(i+n)/(i-n);let p,v;if(c)p=s/(r-s),v=r*s/(r-s);else if(o===Kn)p=-(r+s)/(r-s),v=-2*r*s/(r-s);else if(o===_o)p=-r/(r-s),v=-r*s/(r-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,n,s,r,o=Kn,c=!1){const l=this.elements,h=2/(t-e),u=2/(i-n),d=-(t+e)/(t-e),f=-(i+n)/(i-n);let p,v;if(c)p=1/(r-s),v=r/(r-s);else if(o===Kn)p=-2/(r-s),v=-(r+s)/(r-s);else if(o===_o)p=-1/(r-s),v=-s/(r-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=f,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let n=0;n<16;n++)if(t[n]!==i[n])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const Ia=new D,Mn=new Ze,Ov=new D(0,0,0),Uv=new D(1,1,1),As=new D,zo=new D,qi=new D,cf=new Ze,lf=new Qn;class Ms{constructor(e=0,t=0,i=0,n=Ms.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=n}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,n=this._order){return this._x=e,this._y=t,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const n=e.elements,s=n[0],r=n[4],o=n[8],c=n[1],l=n[5],h=n[9],u=n[2],d=n[6],f=n[10];switch(t){case"XYZ":this._y=Math.asin(je(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-r,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-je(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(je(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-r,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-je(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-r,l));break;case"YZX":this._z=Math.asin(je(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-je(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:Te("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return cf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(cf,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return lf.setFromEuler(this),this.setFromQuaternion(lf,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}}Ms.DEFAULT_ORDER="XYZ";class Bd{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 Fv=0;const hf=new D,Pa=new Qn,ts=new Ze,Ho=new D,Tr=new D,kv=new D,zv=new Qn,uf=new D(1,0,0),df=new D(0,1,0),ff=new D(0,0,1),pf={type:"added"},Hv={type:"removed"},La={type:"childadded",child:null},Wl={type:"childremoved",child:null};class Pt extends ba{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Fv++}),this.uuid=Rn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Pt.DEFAULT_UP.clone();const e=new D,t=new Ms,i=new Qn,n=new D(1,1,1);function s(){i.setFromEuler(t,!1)}function r(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._onChange(r),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Ze},normalMatrix:{value:new Xe}}),this.matrix=new Ze,this.matrixWorld=new Ze,this.matrixAutoUpdate=Pt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Bd,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 Pa.setFromAxisAngle(e,t),this.quaternion.multiply(Pa),this}rotateOnWorldAxis(e,t){return Pa.setFromAxisAngle(e,t),this.quaternion.premultiply(Pa),this}rotateX(e){return this.rotateOnAxis(uf,e)}rotateY(e){return this.rotateOnAxis(df,e)}rotateZ(e){return this.rotateOnAxis(ff,e)}translateOnAxis(e,t){return hf.copy(e).applyQuaternion(this.quaternion),this.position.add(hf.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(uf,e)}translateY(e){return this.translateOnAxis(df,e)}translateZ(e){return this.translateOnAxis(ff,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ts.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Ho.copy(e):Ho.set(e,t,i);const n=this.parent;this.updateWorldMatrix(!0,!1),Tr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ts.lookAt(Tr,Ho,this.up):ts.lookAt(Ho,Tr,this.up),this.quaternion.setFromRotationMatrix(ts),n&&(ts.extractRotation(n.matrixWorld),Pa.setFromRotationMatrix(ts),this.quaternion.premultiply(Pa.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Be("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(pf),La.child=e,this.dispatchEvent(La),La.child=null):Be("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Hv),Wl.child=e,this.dispatchEvent(Wl),Wl.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),ts.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ts.multiply(e.parent.matrixWorld)),e.applyMatrix4(ts),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(pf),La.child=e,this.dispatchEvent(La),La.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,n=this.children.length;i<n;i++){const r=this.children[i].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const n=this.children;for(let s=0,r=n.length;s<r;s++)n[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Tr,e,kv),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Tr,zv,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 i=0,n=t.length;i<n;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].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,i=e.y,n=e.z,s=this.matrix.elements;s[12]+=t-s[0]*t-s[4]*i-s[8]*n,s[13]+=i-s[1]*t-s[5]*i-s[9]*n,s[14]+=n-s[2]*t-s[6]*i-s[10]*n}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 i=0,n=t.length;i<n;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t,i=!1){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||i)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,i=!0),t===!0){const s=this.children;for(let r=0,o=s.length;r<o;r++)s[r].updateWorldMatrix(!1,!0,i)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),this.static!==!1&&(n.static=this.static),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),this.pivot!==null&&(n.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(n.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(n.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),n.instanceInfo=this._instanceInfo.map(o=>({...o})),n.availableInstanceIds=this._availableInstanceIds.slice(),n.availableGeometryIds=this._availableGeometryIds.slice(),n.nextIndexStart=this._nextIndexStart,n.nextVertexStart=this._nextVertexStart,n.geometryCount=this._geometryCount,n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.matricesTexture=this._matricesTexture.toJSON(e),n.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(n.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(n.boundingBox=this.boundingBox.toJSON()));function s(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const u=c[l];s(e.shapes,u)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(s(e.materials,this.material[c]));n.material=o}else n.material=s(e.materials,this.material);if(this.children.length>0){n.children=[];for(let o=0;o<this.children.length;o++)n.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){n.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];n.animations.push(s(e.animations,c))}}if(t){const o=r(e.geometries),c=r(e.materials),l=r(e.textures),h=r(e.images),u=r(e.shapes),d=r(e.skeletons),f=r(e.animations),p=r(e.nodes);o.length>0&&(i.geometries=o),c.length>0&&(i.materials=c),l.length>0&&(i.textures=l),h.length>0&&(i.images=h),u.length>0&&(i.shapes=u),d.length>0&&(i.skeletons=d),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=n,i;function r(o){const c=[];for(const l in o){const h=o[l];delete h.metadata,c.push(h)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const n=e.children[i];this.add(n.clone())}return this}}Pt.DEFAULT_UP=new D(0,1,0);Pt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Dt extends Pt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Bv={type:"move"};class Xl{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Dt,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 Dt,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new D,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new D),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Dt,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new D,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new D,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 i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let n=null,s=null,r=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){r=!0;for(const v of e.hand.values()){const m=t.getJointPose(v,i),g=this._getHandJoint(l,v);m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=m.radius),g.visible=m!==null}const h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,p=.005;l.inputState.pinching&&d>f+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=f-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(n=t.getPose(e.targetRaySpace,i),n===null&&s!==null&&(n=s),n!==null&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,n.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(n.linearVelocity)):o.hasLinearVelocity=!1,n.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(n.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Bv)))}return o!==null&&(o.visible=n!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=r!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Dt;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const dg={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},Ts={h:0,s:0,l:0},Bo={h:0,s:0,l:0};function ql(a,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?a+(e-a)*6*t:t<1/2?e:t<2/3?a+(e-a)*6*(2/3-t):a}class se{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const n=e;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Fi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,it.colorSpaceToWorking(this,t),this}setRGB(e,t,i,n=it.workingColorSpace){return this.r=e,this.g=t,this.b=i,it.colorSpaceToWorking(this,n),this}setHSL(e,t,i,n=it.workingColorSpace){if(e=zd(e,1),t=je(t,0,1),i=je(i,0,1),t===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+t):i+t-i*t,r=2*i-s;this.r=ql(r,s,e+1/3),this.g=ql(r,s,e),this.b=ql(r,s,e-1/3)}return it.colorSpaceToWorking(this,n),this}setStyle(e,t=Fi){function i(s){s!==void 0&&parseFloat(s)<1&&Te("Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const r=n[1],o=n[2];switch(r){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:Te("Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=n[1],r=s.length;if(r===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(r===6)return this.setHex(parseInt(s,16),t);Te("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Fi){const i=dg[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Te("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=gs(e.r),this.g=gs(e.g),this.b=gs(e.b),this}copyLinearToSRGB(e){return this.r=cr(e.r),this.g=cr(e.g),this.b=cr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Fi){return it.workingToColorSpace(bi.copy(this),e),Math.round(je(bi.r*255,0,255))*65536+Math.round(je(bi.g*255,0,255))*256+Math.round(je(bi.b*255,0,255))}getHexString(e=Fi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=it.workingColorSpace){it.workingToColorSpace(bi.copy(this),t);const i=bi.r,n=bi.g,s=bi.b,r=Math.max(i,n,s),o=Math.min(i,n,s);let c,l;const h=(o+r)/2;if(o===r)c=0,l=0;else{const u=r-o;switch(l=h<=.5?u/(r+o):u/(2-r-o),r){case i:c=(n-s)/u+(n<s?6:0);break;case n:c=(s-i)/u+2;break;case s:c=(i-n)/u+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=it.workingColorSpace){return it.workingToColorSpace(bi.copy(this),t),e.r=bi.r,e.g=bi.g,e.b=bi.b,e}getStyle(e=Fi){it.workingToColorSpace(bi.copy(this),e);const t=bi.r,i=bi.g,n=bi.b;return e!==Fi?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(n*255)})`}offsetHSL(e,t,i){return this.getHSL(Ts),this.setHSL(Ts.h+e,Ts.s+t,Ts.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(Ts),e.getHSL(Bo);const i=so(Ts.h,Bo.h,t),n=so(Ts.s,Bo.s,t),s=so(Ts.l,Bo.l,t);return this.setHSL(i,n,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,n=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*n,this.g=s[1]*t+s[4]*i+s[7]*n,this.b=s[2]*t+s[5]*i+s[8]*n,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 bi=new se;se.NAMES=dg;class Gd{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new se(e),this.near=t,this.far=i}clone(){return new Gd(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class xs extends Pt{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 Ms,this.environmentIntensity=1,this.environmentRotation=new Ms,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 xn=new D,is=new D,Yl=new D,ns=new D,Na=new D,Oa=new D,mf=new D,Kl=new D,$l=new D,Zl=new D,Jl=new nt,jl=new nt,Ql=new nt;class pn{constructor(e=new D,t=new D,i=new D){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,n){n.subVectors(i,t),xn.subVectors(e,t),n.cross(xn);const s=n.lengthSq();return s>0?n.multiplyScalar(1/Math.sqrt(s)):n.set(0,0,0)}static getBarycoord(e,t,i,n,s){xn.subVectors(n,t),is.subVectors(i,t),Yl.subVectors(e,t);const r=xn.dot(xn),o=xn.dot(is),c=xn.dot(Yl),l=is.dot(is),h=is.dot(Yl),u=r*l-o*o;if(u===0)return s.set(0,0,0),null;const d=1/u,f=(l*c-o*h)*d,p=(r*h-o*c)*d;return s.set(1-f-p,p,f)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,ns)===null?!1:ns.x>=0&&ns.y>=0&&ns.x+ns.y<=1}static getInterpolation(e,t,i,n,s,r,o,c){return this.getBarycoord(e,t,i,n,ns)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,ns.x),c.addScaledVector(r,ns.y),c.addScaledVector(o,ns.z),c)}static getInterpolatedAttribute(e,t,i,n,s,r){return Jl.setScalar(0),jl.setScalar(0),Ql.setScalar(0),Jl.fromBufferAttribute(e,t),jl.fromBufferAttribute(e,i),Ql.fromBufferAttribute(e,n),r.setScalar(0),r.addScaledVector(Jl,s.x),r.addScaledVector(jl,s.y),r.addScaledVector(Ql,s.z),r}static isFrontFacing(e,t,i,n){return xn.subVectors(i,t),is.subVectors(e,t),xn.cross(is).dot(n)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,n){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[n]),this}setFromAttributeAndIndices(e,t,i,n){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,n),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 xn.subVectors(this.c,this.b),is.subVectors(this.a,this.b),xn.cross(is).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return pn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return pn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,n,s){return pn.getInterpolation(e,this.a,this.b,this.c,t,i,n,s)}containsPoint(e){return pn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return pn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,n=this.b,s=this.c;let r,o;Na.subVectors(n,i),Oa.subVectors(s,i),Kl.subVectors(e,i);const c=Na.dot(Kl),l=Oa.dot(Kl);if(c<=0&&l<=0)return t.copy(i);$l.subVectors(e,n);const h=Na.dot($l),u=Oa.dot($l);if(h>=0&&u<=h)return t.copy(n);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return r=c/(c-h),t.copy(i).addScaledVector(Na,r);Zl.subVectors(e,s);const f=Na.dot(Zl),p=Oa.dot(Zl);if(p>=0&&f<=p)return t.copy(s);const v=f*l-c*p;if(v<=0&&l>=0&&p<=0)return o=l/(l-p),t.copy(i).addScaledVector(Oa,o);const m=h*p-f*u;if(m<=0&&u-h>=0&&f-p>=0)return mf.subVectors(s,n),o=(u-h)/(u-h+(f-p)),t.copy(n).addScaledVector(mf,o);const g=1/(m+v+d);return r=v*g,o=d*g,t.copy(i).addScaledVector(Na,r).addScaledVector(Oa,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class vn{constructor(e=new D(1/0,1/0,1/0),t=new D(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(yn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(yn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=yn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let r=0,o=s.count;r<o;r++)e.isMesh===!0?e.getVertexPosition(r,yn):yn.fromBufferAttribute(s,r),yn.applyMatrix4(e.matrixWorld),this.expandByPoint(yn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Go.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Go.copy(i.boundingBox)),Go.applyMatrix4(e.matrixWorld),this.union(Go)}const n=e.children;for(let s=0,r=n.length;s<r;s++)this.expandByObject(n[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,yn),yn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Rr),Vo.subVectors(this.max,Rr),Ua.subVectors(e.a,Rr),Fa.subVectors(e.b,Rr),ka.subVectors(e.c,Rr),Rs.subVectors(Fa,Ua),Ds.subVectors(ka,Fa),js.subVectors(Ua,ka);let t=[0,-Rs.z,Rs.y,0,-Ds.z,Ds.y,0,-js.z,js.y,Rs.z,0,-Rs.x,Ds.z,0,-Ds.x,js.z,0,-js.x,-Rs.y,Rs.x,0,-Ds.y,Ds.x,0,-js.y,js.x,0];return!eh(t,Ua,Fa,ka,Vo)||(t=[1,0,0,0,1,0,0,0,1],!eh(t,Ua,Fa,ka,Vo))?!1:(Wo.crossVectors(Rs,Ds),t=[Wo.x,Wo.y,Wo.z],eh(t,Ua,Fa,ka,Vo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,yn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(yn).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:(ss[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ss[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ss[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ss[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ss[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ss[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ss[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ss[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ss),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 ss=[new D,new D,new D,new D,new D,new D,new D,new D],yn=new D,Go=new vn,Ua=new D,Fa=new D,ka=new D,Rs=new D,Ds=new D,js=new D,Rr=new D,Vo=new D,Wo=new D,Qs=new D;function eh(a,e,t,i,n){for(let s=0,r=a.length-3;s<=r;s+=3){Qs.fromArray(a,s);const o=n.x*Math.abs(Qs.x)+n.y*Math.abs(Qs.y)+n.z*Math.abs(Qs.z),c=e.dot(Qs),l=t.dot(Qs),h=i.dot(Qs);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const ds=Gv();function Gv(){const a=new ArrayBuffer(4),e=new Float32Array(a),t=new Uint32Array(a),i=new Uint32Array(512),n=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(i[c]=0,i[c|256]=32768,n[c]=24,n[c|256]=24):l<-14?(i[c]=1024>>-l-14,i[c|256]=1024>>-l-14|32768,n[c]=-l-1,n[c|256]=-l-1):l<=15?(i[c]=l+15<<10,i[c|256]=l+15<<10|32768,n[c]=13,n[c|256]=13):l<128?(i[c]=31744,i[c|256]=64512,n[c]=24,n[c|256]=24):(i[c]=31744,i[c|256]=64512,n[c]=13,n[c|256]=13)}const s=new Uint32Array(2048),r=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,s[c]=l|h}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)r[c]=c<<23;r[31]=1199570944,r[32]=2147483648;for(let c=33;c<63;++c)r[c]=2147483648+(c-32<<23);r[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:n,mantissaTable:s,exponentTable:r,offsetTable:o}}function Vv(a){Math.abs(a)>65504&&Te("DataUtils.toHalfFloat(): Value out of range."),a=je(a,-65504,65504),ds.floatView[0]=a;const e=ds.uint32View[0],t=e>>23&511;return ds.baseTable[t]+((e&8388607)>>ds.shiftTable[t])}function Wv(a){const e=a>>10;return ds.uint32View[0]=ds.mantissaTable[ds.offsetTable[e]+(a&1023)]+ds.exponentTable[e],ds.floatView[0]}class Dn{static toHalfFloat(e){return Vv(e)}static fromHalfFloat(e){return Wv(e)}}const ei=new D,Xo=new xe;let Xv=0;class et extends ba{constructor(e,t,i=!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:Xv++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=Vu,this.updateRanges=[],this.gpuType=Ri,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let n=0,s=this.itemSize;n<s;n++)this.array[e+n]=t.array[i+n];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)Xo.fromBufferAttribute(this,t),Xo.applyMatrix3(e),this.setXY(t,Xo.x,Xo.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)ei.fromBufferAttribute(this,t),ei.applyMatrix3(e),this.setXYZ(t,ei.x,ei.y,ei.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)ei.fromBufferAttribute(this,t),ei.applyMatrix4(e),this.setXYZ(t,ei.x,ei.y,ei.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)ei.fromBufferAttribute(this,t),ei.applyNormalMatrix(e),this.setXYZ(t,ei.x,ei.y,ei.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)ei.fromBufferAttribute(this,t),ei.transformDirection(e),this.setXYZ(t,ei.x,ei.y,ei.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=An(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=vt(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=An(t,this.array)),t}setX(e,t){return this.normalized&&(t=vt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=An(t,this.array)),t}setY(e,t){return this.normalized&&(t=vt(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=An(t,this.array)),t}setZ(e,t){return this.normalized&&(t=vt(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=An(t,this.array)),t}setW(e,t){return this.normalized&&(t=vt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=vt(t,this.array),i=vt(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,n){return e*=this.itemSize,this.normalized&&(t=vt(t,this.array),i=vt(i,this.array),n=vt(n,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this}setXYZW(e,t,i,n,s){return e*=this.itemSize,this.normalized&&(t=vt(t,this.array),i=vt(i,this.array),n=vt(n,this.array),s=vt(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){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!==Vu&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class fg extends et{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class Vd extends et{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class xt extends et{constructor(e,t,i){super(new Float32Array(e),t,i)}}const qv=new vn,Dr=new D,th=new D;class ys{constructor(e=new D,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 i=this.center;t!==void 0?i.copy(t):qv.setFromPoints(e).getCenter(i);let n=0;for(let s=0,r=e.length;s<r;s++)n=Math.max(n,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(n),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 i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Dr.subVectors(e,this.center);const t=Dr.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),n=(i-this.radius)*.5;this.center.addScaledVector(Dr,n/i),this.radius+=n}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):(th.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Dr.copy(e.center).add(th)),this.expandByPoint(Dr.copy(e.center).sub(th))),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 Yv=0;const on=new Ze,ih=new Pt,za=new D,Yi=new vn,Cr=new vn,ui=new D;class ut extends ba{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Yv++}),this.uuid=Rn(),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(lv(e)?Vd:fg)(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,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const s=new Xe().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return on.makeRotationFromQuaternion(e),this.applyMatrix4(on),this}rotateX(e){return on.makeRotationX(e),this.applyMatrix4(on),this}rotateY(e){return on.makeRotationY(e),this.applyMatrix4(on),this}rotateZ(e){return on.makeRotationZ(e),this.applyMatrix4(on),this}translate(e,t,i){return on.makeTranslation(e,t,i),this.applyMatrix4(on),this}scale(e,t,i){return on.makeScale(e,t,i),this.applyMatrix4(on),this}lookAt(e){return ih.lookAt(e),ih.updateMatrix(),this.applyMatrix4(ih.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(za).negate(),this.translate(za.x,za.y,za.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let n=0,s=e.length;n<s;n++){const r=e[n];i.push(r.x,r.y,r.z||0)}this.setAttribute("position",new xt(i,3))}else{const i=Math.min(e.length,t.count);for(let n=0;n<i;n++){const s=e[n];t.setXYZ(n,s.x,s.y,s.z||0)}e.length>t.count&&Te("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 vn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Be("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,n=t.length;i<n;i++){const s=t[i];Yi.setFromBufferAttribute(s),this.morphTargetsRelative?(ui.addVectors(this.boundingBox.min,Yi.min),this.boundingBox.expandByPoint(ui),ui.addVectors(this.boundingBox.max,Yi.max),this.boundingBox.expandByPoint(ui)):(this.boundingBox.expandByPoint(Yi.min),this.boundingBox.expandByPoint(Yi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Be('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 ys);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Be("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new D,1/0);return}if(e){const i=this.boundingSphere.center;if(Yi.setFromBufferAttribute(e),t)for(let s=0,r=t.length;s<r;s++){const o=t[s];Cr.setFromBufferAttribute(o),this.morphTargetsRelative?(ui.addVectors(Yi.min,Cr.min),Yi.expandByPoint(ui),ui.addVectors(Yi.max,Cr.max),Yi.expandByPoint(ui)):(Yi.expandByPoint(Cr.min),Yi.expandByPoint(Cr.max))}Yi.getCenter(i);let n=0;for(let s=0,r=e.count;s<r;s++)ui.fromBufferAttribute(e,s),n=Math.max(n,i.distanceToSquared(ui));if(t)for(let s=0,r=t.length;s<r;s++){const o=t[s],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)ui.fromBufferAttribute(o,l),c&&(za.fromBufferAttribute(e,l),ui.add(za)),n=Math.max(n,i.distanceToSquared(ui))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&Be('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){Be("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,n=t.normal,s=t.uv;let r=this.getAttribute("tangent");(r===void 0||r.count!==i.count)&&(r=new et(new Float32Array(4*i.count),4),this.setAttribute("tangent",r));const o=[],c=[];for(let x=0;x<i.count;x++)o[x]=new D,c[x]=new D;const l=new D,h=new D,u=new D,d=new xe,f=new xe,p=new xe,v=new D,m=new D;function g(x,A,I){l.fromBufferAttribute(i,x),h.fromBufferAttribute(i,A),u.fromBufferAttribute(i,I),d.fromBufferAttribute(s,x),f.fromBufferAttribute(s,A),p.fromBufferAttribute(s,I),h.sub(l),u.sub(l),f.sub(d),p.sub(d);const C=1/(f.x*p.y-p.x*f.y);isFinite(C)&&(v.copy(h).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(C),m.copy(u).multiplyScalar(f.x).addScaledVector(h,-p.x).multiplyScalar(C),o[x].add(v),o[A].add(v),o[I].add(v),c[x].add(m),c[A].add(m),c[I].add(m))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let x=0,A=_.length;x<A;++x){const I=_[x],C=I.start,P=I.count;for(let X=C,z=C+P;X<z;X+=3)g(e.getX(X+0),e.getX(X+1),e.getX(X+2))}const w=new D,M=new D,S=new D,b=new D;function T(x){S.fromBufferAttribute(n,x),b.copy(S);const A=o[x];w.copy(A),w.sub(S.multiplyScalar(S.dot(A))).normalize(),M.crossVectors(b,A);const C=M.dot(c[x])<0?-1:1;r.setXYZW(x,w.x,w.y,w.z,C)}for(let x=0,A=_.length;x<A;++x){const I=_[x],C=I.start,P=I.count;for(let X=C,z=C+P;X<z;X+=3)T(e.getX(X+0)),T(e.getX(X+1)),T(e.getX(X+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0||i.count!==t.count)i=new et(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let d=0,f=i.count;d<f;d++)i.setXYZ(d,0,0,0);const n=new D,s=new D,r=new D,o=new D,c=new D,l=new D,h=new D,u=new D;if(e)for(let d=0,f=e.count;d<f;d+=3){const p=e.getX(d+0),v=e.getX(d+1),m=e.getX(d+2);n.fromBufferAttribute(t,p),s.fromBufferAttribute(t,v),r.fromBufferAttribute(t,m),h.subVectors(r,s),u.subVectors(n,s),h.cross(u),o.fromBufferAttribute(i,p),c.fromBufferAttribute(i,v),l.fromBufferAttribute(i,m),o.add(h),c.add(h),l.add(h),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(v,c.x,c.y,c.z),i.setXYZ(m,l.x,l.y,l.z)}else for(let d=0,f=t.count;d<f;d+=3)n.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),r.fromBufferAttribute(t,d+2),h.subVectors(r,s),u.subVectors(n,s),h.cross(u),i.setXYZ(d+0,h.x,h.y,h.z),i.setXYZ(d+1,h.x,h.y,h.z),i.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)ui.fromBufferAttribute(e,t),ui.normalize(),e.setXYZ(t,ui.x,ui.y,ui.z)}toNonIndexed(){function e(o,c){const l=o.array,h=o.itemSize,u=o.normalized,d=new l.constructor(c.length*h);let f=0,p=0;for(let v=0,m=c.length;v<m;v++){o.isInterleavedBufferAttribute?f=c[v]*o.data.stride+o.offset:f=c[v]*h;for(let g=0;g<h;g++)d[p++]=l[f++]}return new et(d,h,u)}if(this.index===null)return Te("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new ut,i=this.index.array,n=this.attributes;for(const o in n){const c=n[o],l=e(c,i);t.setAttribute(o,l)}const s=this.morphAttributes;for(const o in s){const c=[],l=s[o];for(let h=0,u=l.length;h<u;h++){const d=l[h],f=e(d,i);c.push(f)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const r=this.groups;for(let o=0,c=r.length;o<c;o++){const l=r[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const c in i){const l=i[c];e.data.attributes[c]=l.toJSON(e.data)}const n={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){const f=l[u];h.push(f.toJSON(e.data))}h.length>0&&(n[c]=h,s=!0)}s&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(e.data.groups=JSON.parse(JSON.stringify(r)));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 i=e.index;i!==null&&this.setIndex(i.clone());const n=e.attributes;for(const l in n){const h=n[l];this.setAttribute(l,h.clone(t))}const s=e.morphAttributes;for(const l in s){const h=[],u=s[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;const r=e.groups;for(let l=0,h=r.length;l<h;l++){const u=r[l];this.addGroup(u.start,u.count,u.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Kv{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Vu,this.updateRanges=[],this.version=0,this.uuid=Rn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let n=0,s=this.stride;n<s;n++)this.array[e+n]=t.array[i+n];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=Rn()),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]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Rn()),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 Ci=new D;class nl{constructor(e,t,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Ci.fromBufferAttribute(this,t),Ci.applyMatrix4(e),this.setXYZ(t,Ci.x,Ci.y,Ci.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ci.fromBufferAttribute(this,t),Ci.applyNormalMatrix(e),this.setXYZ(t,Ci.x,Ci.y,Ci.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ci.fromBufferAttribute(this,t),Ci.transformDirection(e),this.setXYZ(t,Ci.x,Ci.y,Ci.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=An(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=vt(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=vt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=vt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=vt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=vt(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=An(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=An(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=An(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=An(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=vt(t,this.array),i=vt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=vt(t,this.array),i=vt(i,this.array),n=vt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this}setXYZW(e,t,i,n,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=vt(t,this.array),i=vt(i,this.array),n=vt(n,this.array),s=vt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this.data.array[e+3]=s,this}clone(e){if(e===void 0){il("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[n+s])}return new et(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 nl(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){il("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[n+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let $v=0;class _s extends ba{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:$v++}),this.uuid=Rn(),this.name="",this.type="Material",this.blending=Ws,this.side=qs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=nu,this.blendDst=vo,this.blendEquation=ra,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new se(0,0,0),this.blendAlpha=0,this.depthFunc=gr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=tf,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Da,this.stencilZFail=Da,this.stencilZPass=Da,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 i=e[t];if(i===void 0){Te(`Material: parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){Te(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}n&&n.isColor?n.set(i):n&&n.isVector2&&i&&i.isVector2||n&&n.isEuler&&i&&i.isEuler||n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Ws&&(i.blending=this.blending),this.side!==qs&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==nu&&(i.blendSrc=this.blendSrc),this.blendDst!==vo&&(i.blendDst=this.blendDst),this.blendEquation!==ra&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==gr&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==tf&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Da&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Da&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Da&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function n(s){const r=[];for(const o in s){const c=s[o];delete c.metadata,r.push(c)}return r}if(t){const s=n(e.textures),r=n(e.images);s.length>0&&(i.textures=s),r.length>0&&(i.images=r)}return i}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 se().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 i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new xe().fromArray(i)}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 xe().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 i=null;if(t!==null){const n=t.length;i=new Array(n);for(let s=0;s!==n;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.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 Hc extends _s{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new se(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 Ha;const Ir=new D,Ba=new D,Ga=new D,Va=new xe,Pr=new xe,pg=new Ze,qo=new D,Lr=new D,Yo=new D,gf=new xe,nh=new xe,vf=new xe;class Nr extends Pt{constructor(e=new Hc){if(super(),this.isSprite=!0,this.type="Sprite",Ha===void 0){Ha=new ut;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new Kv(t,5);Ha.setIndex([0,1,2,0,2,3]),Ha.setAttribute("position",new nl(i,3,0,!1)),Ha.setAttribute("uv",new nl(i,2,3,!1))}this.geometry=Ha,this.material=e,this.center=new xe(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Be('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ba.setFromMatrixScale(this.matrixWorld),pg.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ga.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ba.multiplyScalar(-Ga.z);const i=this.material.rotation;let n,s;i!==0&&(s=Math.cos(i),n=Math.sin(i));const r=this.center;Ko(qo.set(-.5,-.5,0),Ga,r,Ba,n,s),Ko(Lr.set(.5,-.5,0),Ga,r,Ba,n,s),Ko(Yo.set(.5,.5,0),Ga,r,Ba,n,s),gf.set(0,0),nh.set(1,0),vf.set(1,1);let o=e.ray.intersectTriangle(qo,Lr,Yo,!1,Ir);if(o===null&&(Ko(Lr.set(-.5,.5,0),Ga,r,Ba,n,s),nh.set(0,1),o=e.ray.intersectTriangle(qo,Yo,Lr,!1,Ir),o===null))return;const c=e.ray.origin.distanceTo(Ir);c<e.near||c>e.far||t.push({distance:c,point:Ir.clone(),uv:pn.getInterpolation(Ir,qo,Lr,Yo,gf,nh,vf,new xe),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 Ko(a,e,t,i,n,s){Va.subVectors(a,t).addScalar(.5).multiply(i),n!==void 0?(Pr.x=s*Va.x-n*Va.y,Pr.y=n*Va.x+s*Va.y):Pr.copy(Va),a.copy(e),a.x+=Pr.x,a.y+=Pr.y,a.applyMatrix4(pg)}const as=new D,sh=new D,$o=new D,Cs=new D,ah=new D,Zo=new D,rh=new D;class Ao{constructor(e=new D,t=new D(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,as)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=as.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(as.copy(this.origin).addScaledVector(this.direction,t),as.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){sh.copy(e).add(t).multiplyScalar(.5),$o.copy(t).sub(e).normalize(),Cs.copy(this.origin).sub(sh);const s=e.distanceTo(t)*.5,r=-this.direction.dot($o),o=Cs.dot(this.direction),c=-Cs.dot($o),l=Cs.lengthSq(),h=Math.abs(1-r*r);let u,d,f,p;if(h>0)if(u=r*c-o,d=r*o-c,p=s*h,u>=0)if(d>=-p)if(d<=p){const v=1/h;u*=v,d*=v,f=u*(u+r*d+2*o)+d*(r*u+d+2*c)+l}else d=s,u=Math.max(0,-(r*d+o)),f=-u*u+d*(d+2*c)+l;else d=-s,u=Math.max(0,-(r*d+o)),f=-u*u+d*(d+2*c)+l;else d<=-p?(u=Math.max(0,-(-r*s+o)),d=u>0?-s:Math.min(Math.max(-s,-c),s),f=-u*u+d*(d+2*c)+l):d<=p?(u=0,d=Math.min(Math.max(-s,-c),s),f=d*(d+2*c)+l):(u=Math.max(0,-(r*s+o)),d=u>0?s:Math.min(Math.max(-s,-c),s),f=-u*u+d*(d+2*c)+l);else d=r>0?-s:s,u=Math.max(0,-(r*d+o)),f=-u*u+d*(d+2*c)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,u),n&&n.copy(sh).addScaledVector($o,d),f}intersectSphere(e,t){as.subVectors(e.center,this.origin);const i=as.dot(this.direction),n=as.dot(as)-i*i,s=e.radius*e.radius;if(n>s)return null;const r=Math.sqrt(s-n),o=i-r,c=i+r;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,n,s,r,o,c;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(i=(e.min.x-d.x)*l,n=(e.max.x-d.x)*l):(i=(e.max.x-d.x)*l,n=(e.min.x-d.x)*l),h>=0?(s=(e.min.y-d.y)*h,r=(e.max.y-d.y)*h):(s=(e.max.y-d.y)*h,r=(e.min.y-d.y)*h),i>r||s>n||((s>i||isNaN(i))&&(i=s),(r<n||isNaN(n))&&(n=r),u>=0?(o=(e.min.z-d.z)*u,c=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,c=(e.min.z-d.z)*u),i>c||o>n)||((o>i||i!==i)&&(i=o),(c<n||n!==n)&&(n=c),n<0)?null:this.at(i>=0?i:n,t)}intersectsBox(e){return this.intersectBox(e,as)!==null}intersectTriangle(e,t,i,n,s){ah.subVectors(t,e),Zo.subVectors(i,e),rh.crossVectors(ah,Zo);let r=this.direction.dot(rh),o;if(r>0){if(n)return null;o=1}else if(r<0)o=-1,r=-r;else return null;Cs.subVectors(this.origin,e);const c=o*this.direction.dot(Zo.crossVectors(Cs,Zo));if(c<0)return null;const l=o*this.direction.dot(ah.cross(Cs));if(l<0||c+l>r)return null;const h=-o*Cs.dot(rh);return h<0?null:this.at(h/r,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class mn extends _s{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new se(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 Ms,this.combine=Cd,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 Mf=new Ze,ea=new Ao,Jo=new ys,xf=new D,jo=new D,Qo=new D,ec=new D,oh=new D,tc=new D,yf=new D,ic=new D;class De extends Pt{constructor(e=new ut,t=new mn){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,i=Object.keys(t);if(i.length>0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=n.length;s<r;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const i=this.geometry,n=i.attributes.position,s=i.morphAttributes.position,r=i.morphTargetsRelative;t.fromBufferAttribute(n,e);const o=this.morphTargetInfluences;if(s&&o){tc.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const h=o[c],u=s[c];h!==0&&(oh.fromBufferAttribute(u,e),r?tc.addScaledVector(oh,h):tc.addScaledVector(oh.sub(t),h))}t.add(tc)}return t}raycast(e,t){const i=this.geometry,n=this.material,s=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Jo.copy(i.boundingSphere),Jo.applyMatrix4(s),ea.copy(e.ray).recast(e.near),!(Jo.containsPoint(ea.origin)===!1&&(ea.intersectSphere(Jo,xf)===null||ea.origin.distanceToSquared(xf)>(e.far-e.near)**2))&&(Mf.copy(s).invert(),ea.copy(e.ray).applyMatrix4(Mf),!(i.boundingBox!==null&&ea.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,ea)))}_computeIntersections(e,t,i){let n;const s=this.geometry,r=this.material,o=s.index,c=s.attributes.position,l=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,d=s.groups,f=s.drawRange;if(o!==null)if(Array.isArray(r))for(let p=0,v=d.length;p<v;p++){const m=d[p],g=r[m.materialIndex],_=Math.max(m.start,f.start),w=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let M=_,S=w;M<S;M+=3){const b=o.getX(M),T=o.getX(M+1),x=o.getX(M+2);n=nc(this,g,e,i,l,h,u,b,T,x),n&&(n.faceIndex=Math.floor(M/3),n.face.materialIndex=m.materialIndex,t.push(n))}}else{const p=Math.max(0,f.start),v=Math.min(o.count,f.start+f.count);for(let m=p,g=v;m<g;m+=3){const _=o.getX(m),w=o.getX(m+1),M=o.getX(m+2);n=nc(this,r,e,i,l,h,u,_,w,M),n&&(n.faceIndex=Math.floor(m/3),t.push(n))}}else if(c!==void 0)if(Array.isArray(r))for(let p=0,v=d.length;p<v;p++){const m=d[p],g=r[m.materialIndex],_=Math.max(m.start,f.start),w=Math.min(c.count,Math.min(m.start+m.count,f.start+f.count));for(let M=_,S=w;M<S;M+=3){const b=M,T=M+1,x=M+2;n=nc(this,g,e,i,l,h,u,b,T,x),n&&(n.faceIndex=Math.floor(M/3),n.face.materialIndex=m.materialIndex,t.push(n))}}else{const p=Math.max(0,f.start),v=Math.min(c.count,f.start+f.count);for(let m=p,g=v;m<g;m+=3){const _=m,w=m+1,M=m+2;n=nc(this,r,e,i,l,h,u,_,w,M),n&&(n.faceIndex=Math.floor(m/3),t.push(n))}}}}function Zv(a,e,t,i,n,s,r,o){let c;if(e.side===Ot?c=i.intersectTriangle(r,s,n,!0,o):c=i.intersectTriangle(n,s,r,e.side===qs,o),c===null)return null;ic.copy(o),ic.applyMatrix4(a.matrixWorld);const l=t.ray.origin.distanceTo(ic);return l<t.near||l>t.far?null:{distance:l,point:ic.clone(),object:a}}function nc(a,e,t,i,n,s,r,o,c,l){a.getVertexPosition(o,jo),a.getVertexPosition(c,Qo),a.getVertexPosition(l,ec);const h=Zv(a,e,t,i,jo,Qo,ec,yf);if(h){const u=new D;pn.getBarycoord(yf,jo,Qo,ec,u),n&&(h.uv=pn.getInterpolatedAttribute(n,o,c,l,u,new xe)),s&&(h.uv1=pn.getInterpolatedAttribute(s,o,c,l,u,new xe)),r&&(h.normal=pn.getInterpolatedAttribute(r,o,c,l,u,new D),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new D,materialIndex:0};pn.getNormal(jo,Qo,ec,d.normal),h.face=d,h.barycoord=u}return h}const Or=new nt,_f=new nt,Sf=new nt,Jv=new nt,wf=new Ze,sc=new D,ch=new ys,bf=new Ze,lh=new Ao;class xE extends De{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Z0,this.bindMatrix=new Ze,this.bindMatrixInverse=new Ze,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new vn),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,sc),this.boundingBox.expandByPoint(sc)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new ys),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,sc),this.boundingSphere.expandByPoint(sc)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const i=this.material,n=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ch.copy(this.boundingSphere),ch.applyMatrix4(n),e.ray.intersectsSphere(ch)!==!1&&(bf.copy(n).invert(),lh.copy(e.ray).applyMatrix4(bf),!(this.boundingBox!==null&&lh.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,lh)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new nt,t=this.geometry.attributes.skinWeight;for(let i=0,n=t.count;i<n;i++){e.fromBufferAttribute(t,i);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Z0?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===j2?this.bindMatrixInverse.copy(this.bindMatrix).invert():Te("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,n=this.geometry;_f.fromBufferAttribute(n.attributes.skinIndex,e),Sf.fromBufferAttribute(n.attributes.skinWeight,e),t.isVector4?(Or.copy(t),t.set(0,0,0,0)):(Or.set(...t,1),t.set(0,0,0)),Or.applyMatrix4(this.bindMatrix);for(let s=0;s<4;s++){const r=Sf.getComponent(s);if(r!==0){const o=_f.getComponent(s);wf.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(Jv.copy(Or).applyMatrix4(wf),r)}}return t.isVector4&&(t.w=Or.w),t.applyMatrix4(this.bindMatrixInverse)}}class jv extends Pt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class $s extends Mi{constructor(e=null,t=1,i=1,n,s,r,o,c,l=wt,h=wt,u,d){super(null,r,o,c,l,h,n,s,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Ef=new Ze,Qv=new Ze;class mg{constructor(e=[],t=[]){this.uuid=Rn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Te("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,n=this.bones.length;i<n;i++)this.boneInverses.push(new Ze)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new Ze;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let s=0,r=e.length;s<r;s++){const o=e[s]?e[s].matrixWorld:Qv;Ef.multiplyMatrices(o,t[s]),Ef.toArray(i,s*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new mg(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new $s(t,e,e,yi,Ri);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,n=e.bones.length;i<n;i++){const s=e.bones[i];let r=t[s];r===void 0&&(Te("Skeleton: No bone found with UUID:",s),r=new jv),this.bones.push(r),this.boneInverses.push(new Ze().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let n=0,s=t.length;n<s;n++){const r=t[n];e.bones.push(r.uuid);const o=i[n];e.boneInverses.push(o.toArray())}return e}}class Af extends et{constructor(e,t,i,n=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Wa=new Ze,Tf=new Ze,ac=[],Rf=new vn,eM=new Ze,Ur=new De,Fr=new ys;class yE extends De{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Af(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<i;n++)this.setMatrixAt(n,eM)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new vn),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Wa),Rf.copy(e.boundingBox).applyMatrix4(Wa),this.boundingBox.union(Rf)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new ys),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Wa),Fr.copy(e.boundingSphere).applyMatrix4(Wa),this.boundingSphere.union(Fr)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const i=t.morphTargetInfluences,n=this.morphTexture.source.data.data,s=i.length+1,r=e*s+1;for(let o=0;o<i.length;o++)i[o]=n[r+o]}raycast(e,t){const i=this.matrixWorld,n=this.count;if(Ur.geometry=this.geometry,Ur.material=this.material,Ur.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Fr.copy(this.boundingSphere),Fr.applyMatrix4(i),e.ray.intersectsSphere(Fr)!==!1))for(let s=0;s<n;s++){this.getMatrixAt(s,Wa),Tf.multiplyMatrices(i,Wa),Ur.matrixWorld=Tf,Ur.raycast(e,ac);for(let r=0,o=ac.length;r<o;r++){const c=ac[r];c.instanceId=s,c.object=this,t.push(c)}ac.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new Af(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){const i=t.morphTargetInfluences,n=i.length+1;this.morphTexture===null&&(this.morphTexture=new $s(new Float32Array(n*this.count),n,this.count,yl,Ri));const s=this.morphTexture.source.data.data;let r=0;for(let l=0;l<i.length;l++)r+=i[l];const o=this.geometry.morphTargetsRelative?1:1-r,c=n*e;return s[c]=o,s.set(i,c+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const hh=new D,tM=new D,iM=new Xe;class sa{constructor(e=new D(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,n){return this.normal.set(e,t,i),this.constant=n,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const n=hh.subVectors(i,t).cross(tM.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(n,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,i=!0){const n=e.delta(hh),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/s;return i===!0&&(r<0||r>1)?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||iM.getNormalMatrix(e),n=this.coplanarPoint(hh).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const ta=new ys,nM=new xe(.5,.5),rc=new D;class Wd{constructor(e=new sa,t=new sa,i=new sa,n=new sa,s=new sa,r=new sa){this.planes=[e,t,i,n,s,r]}set(e,t,i,n,s,r){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(n),o[4].copy(s),o[5].copy(r),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Kn,i=!1){const n=this.planes,s=e.elements,r=s[0],o=s[1],c=s[2],l=s[3],h=s[4],u=s[5],d=s[6],f=s[7],p=s[8],v=s[9],m=s[10],g=s[11],_=s[12],w=s[13],M=s[14],S=s[15];if(n[0].setComponents(l-r,f-h,g-p,S-_).normalize(),n[1].setComponents(l+r,f+h,g+p,S+_).normalize(),n[2].setComponents(l+o,f+u,g+v,S+w).normalize(),n[3].setComponents(l-o,f-u,g-v,S-w).normalize(),i)n[4].setComponents(c,d,m,M).normalize(),n[5].setComponents(l-c,f-d,g-m,S-M).normalize();else if(n[4].setComponents(l-c,f-d,g-m,S-M).normalize(),t===Kn)n[5].setComponents(l+c,f+d,g+m,S+M).normalize();else if(t===_o)n[5].setComponents(c,d,m,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),ta.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),ta.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ta)}intersectsSprite(e){ta.center.set(0,0,0);const t=nM.distanceTo(e.center);return ta.radius=.7071067811865476+t,ta.applyMatrix4(e.matrixWorld),this.intersectsSphere(ta)}intersectsSphere(e){const t=this.planes,i=e.center,n=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<n)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const n=t[i];if(rc.x=n.normal.x>0?e.max.x:e.min.x,rc.y=n.normal.y>0?e.max.y:e.min.y,rc.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(rc)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class sM extends _s{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new se(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const sl=new D,al=new D,Df=new Ze,kr=new Ao,oc=new ys,uh=new D,Cf=new D;class gg extends Pt{constructor(e=new ut,t=new sM){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let n=1,s=t.count;n<s;n++)sl.fromBufferAttribute(t,n-1),al.fromBufferAttribute(t,n),i[n]=i[n-1],i[n]+=sl.distanceTo(al);e.setAttribute("lineDistance",new xt(i,1))}else Te("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,s=e.params.Line.threshold,r=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),oc.copy(i.boundingSphere),oc.applyMatrix4(n),oc.radius+=s,e.ray.intersectsSphere(oc)===!1)return;Df.copy(n).invert(),kr.copy(e.ray).applyMatrix4(Df);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=i.index,d=i.attributes.position;if(h!==null){const f=Math.max(0,r.start),p=Math.min(h.count,r.start+r.count);for(let v=f,m=p-1;v<m;v+=l){const g=h.getX(v),_=h.getX(v+1),w=cc(this,e,kr,c,g,_,v);w&&t.push(w)}if(this.isLineLoop){const v=h.getX(p-1),m=h.getX(f),g=cc(this,e,kr,c,v,m,p-1);g&&t.push(g)}}else{const f=Math.max(0,r.start),p=Math.min(d.count,r.start+r.count);for(let v=f,m=p-1;v<m;v+=l){const g=cc(this,e,kr,c,v,v+1,v);g&&t.push(g)}if(this.isLineLoop){const v=cc(this,e,kr,c,p-1,f,p-1);v&&t.push(v)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=n.length;s<r;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function cc(a,e,t,i,n,s,r){const o=a.geometry.attributes.position;if(sl.fromBufferAttribute(o,n),al.fromBufferAttribute(o,s),t.distanceSqToSegment(sl,al,uh,Cf)>i)return;uh.applyMatrix4(a.matrixWorld);const l=e.ray.origin.distanceTo(uh);if(!(l<e.near||l>e.far))return{distance:l,point:Cf.clone().applyMatrix4(a.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:a}}const If=new D,Pf=new D;class _E extends gg{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let n=0,s=t.count;n<s;n+=2)If.fromBufferAttribute(t,n),Pf.fromBufferAttribute(t,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+If.distanceTo(Pf);e.setAttribute("lineDistance",new xt(i,1))}else Te("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class SE extends gg{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class vg extends _s{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new se(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 Lf=new Ze,Wu=new Ao,lc=new ys,hc=new D;class us extends Pt{constructor(e=new ut,t=new vg){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 i=this.geometry,n=this.matrixWorld,s=e.params.Points.threshold,r=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),lc.copy(i.boundingSphere),lc.applyMatrix4(n),lc.radius+=s,e.ray.intersectsSphere(lc)===!1)return;Lf.copy(n).invert(),Wu.copy(e.ray).applyMatrix4(Lf);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=i.index,u=i.attributes.position;if(l!==null){const d=Math.max(0,r.start),f=Math.min(l.count,r.start+r.count);for(let p=d,v=f;p<v;p++){const m=l.getX(p);hc.fromBufferAttribute(u,m),Nf(hc,m,c,n,e,t,this)}}else{const d=Math.max(0,r.start),f=Math.min(u.count,r.start+r.count);for(let p=d,v=f;p<v;p++)hc.fromBufferAttribute(u,p),Nf(hc,p,c,n,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=n.length;s<r;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function Nf(a,e,t,i,n,s,r){const o=Wu.distanceSqToPoint(a);if(o<t){const c=new D;Wu.closestPointToPoint(a,c),c.applyMatrix4(i);const l=n.ray.origin.distanceTo(c);if(l<n.near||l>n.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:r})}}class Mg extends Mi{constructor(e=[],t=ya,i,n,s,r,o,c,l,h){super(e,t,i,n,s,r,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Ss extends Mi{constructor(e,t,i,n,s,r,o,c,l){super(e,t,i,n,s,r,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Ys extends Mi{constructor(e,t,i=gn,n,s,r,o=wt,c=wt,l,h=vs,u=1){if(h!==vs&&h!==fa)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:u};super(d,n,s,r,o,c,h,i,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Hd(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 aM extends Ys{constructor(e,t=gn,i=ya,n,s,r=wt,o=wt,c,l=vs){const h={width:e,height:e,depth:1},u=[h,h,h,h,h,h];super(e,e,t,i,n,s,r,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class xg extends Mi{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class sn extends ut{constructor(e=1,t=1,i=1,n=1,s=1,r=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:n,heightSegments:s,depthSegments:r};const o=this;n=Math.floor(n),s=Math.floor(s),r=Math.floor(r);const c=[],l=[],h=[],u=[];let d=0,f=0;p("z","y","x",-1,-1,i,t,e,r,s,0),p("z","y","x",1,-1,i,t,-e,r,s,1),p("x","z","y",1,1,e,i,t,n,r,2),p("x","z","y",1,-1,e,i,-t,n,r,3),p("x","y","z",1,-1,e,t,i,n,s,4),p("x","y","z",-1,-1,e,t,-i,n,s,5),this.setIndex(c),this.setAttribute("position",new xt(l,3)),this.setAttribute("normal",new xt(h,3)),this.setAttribute("uv",new xt(u,2));function p(v,m,g,_,w,M,S,b,T,x,A){const I=M/T,C=S/x,P=M/2,X=S/2,z=b/2,N=T+1,V=x+1;let k=0,K=0;const ee=new D;for(let J=0;J<V;J++){const ie=J*C-X;for(let oe=0;oe<N;oe++){const Ve=oe*I-P;ee[v]=Ve*_,ee[m]=ie*w,ee[g]=z,l.push(ee.x,ee.y,ee.z),ee[v]=0,ee[m]=0,ee[g]=b>0?1:-1,h.push(ee.x,ee.y,ee.z),u.push(oe/T),u.push(1-J/x),k+=1}}for(let J=0;J<x;J++)for(let ie=0;ie<T;ie++){const oe=d+ie+N*J,Ve=d+ie+N*(J+1),Qe=d+(ie+1)+N*(J+1),qe=d+(ie+1)+N*J;c.push(oe,Ve,qe),c.push(Ve,Qe,qe),K+=6}o.addGroup(f,K,A),f+=K,d+=k}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new sn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Xd extends ut{constructor(e=1,t=32,i=0,n=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:n},t=Math.max(3,t);const s=[],r=[],o=[],c=[],l=new D,h=new xe;r.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let u=0,d=3;u<=t;u++,d+=3){const f=i+u/t*n;l.x=e*Math.cos(f),l.y=e*Math.sin(f),r.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(r[d]/e+1)/2,h.y=(r[d+1]/e+1)/2,c.push(h.x,h.y)}for(let u=1;u<=t;u++)s.push(u,u+1,0);this.setIndex(s),this.setAttribute("position",new xt(r,3)),this.setAttribute("normal",new xt(o,3)),this.setAttribute("uv",new xt(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Xd(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class es extends ut{constructor(e=1,t=1,i=1,n=32,s=1,r=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:n,heightSegments:s,openEnded:r,thetaStart:o,thetaLength:c};const l=this;n=Math.floor(n),s=Math.floor(s);const h=[],u=[],d=[],f=[];let p=0;const v=[],m=i/2;let g=0;_(),r===!1&&(e>0&&w(!0),t>0&&w(!1)),this.setIndex(h),this.setAttribute("position",new xt(u,3)),this.setAttribute("normal",new xt(d,3)),this.setAttribute("uv",new xt(f,2));function _(){const M=new D,S=new D;let b=0;const T=(t-e)/i;for(let x=0;x<=s;x++){const A=[],I=x/s,C=I*(t-e)+e;for(let P=0;P<=n;P++){const X=P/n,z=X*c+o,N=Math.sin(z),V=Math.cos(z);S.x=C*N,S.y=-I*i+m,S.z=C*V,u.push(S.x,S.y,S.z),M.set(N,T,V).normalize(),d.push(M.x,M.y,M.z),f.push(X,1-I),A.push(p++)}v.push(A)}for(let x=0;x<n;x++)for(let A=0;A<s;A++){const I=v[A][x],C=v[A+1][x],P=v[A+1][x+1],X=v[A][x+1];(e>0||A!==0)&&(h.push(I,C,X),b+=3),(t>0||A!==s-1)&&(h.push(C,P,X),b+=3)}l.addGroup(g,b,0),g+=b}function w(M){const S=p,b=new xe,T=new D;let x=0;const A=M===!0?e:t,I=M===!0?1:-1;for(let P=1;P<=n;P++)u.push(0,m*I,0),d.push(0,I,0),f.push(.5,.5),p++;const C=p;for(let P=0;P<=n;P++){const z=P/n*c+o,N=Math.cos(z),V=Math.sin(z);T.x=A*V,T.y=m*I,T.z=A*N,u.push(T.x,T.y,T.z),d.push(0,I,0),b.x=N*.5+.5,b.y=V*.5*I+.5,f.push(b.x,b.y),p++}for(let P=0;P<n;P++){const X=S+P,z=C+P;M===!0?h.push(z,z+1,X):h.push(z+1,z,X),x+=3}l.addGroup(g,x,M===!0?1:2),g+=x}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new es(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class _r extends es{constructor(e=1,t=1,i=32,n=1,s=!1,r=0,o=Math.PI*2){super(0,e,t,i,n,s,r,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:n,openEnded:s,thetaStart:r,thetaLength:o}}static fromJSON(e){return new _r(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class _l extends ut{constructor(e=[new xe(0,-.5),new xe(.5,0),new xe(0,.5)],t=12,i=0,n=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:n},t=Math.floor(t),n=je(n,0,Math.PI*2);const s=[],r=[],o=[],c=[],l=[],h=1/t,u=new D,d=new xe,f=new D,p=new D,v=new D;let m=0,g=0;for(let _=0;_<=e.length-1;_++)switch(_){case 0:m=e[_+1].x-e[_].x,g=e[_+1].y-e[_].y,f.x=g*1,f.y=-m,f.z=g*0,v.copy(f),f.normalize(),c.push(f.x,f.y,f.z);break;case e.length-1:c.push(v.x,v.y,v.z);break;default:m=e[_+1].x-e[_].x,g=e[_+1].y-e[_].y,f.x=g*1,f.y=-m,f.z=g*0,p.copy(f),f.x+=v.x,f.y+=v.y,f.z+=v.z,f.normalize(),c.push(f.x,f.y,f.z),v.copy(p)}for(let _=0;_<=t;_++){const w=i+_*h*n,M=Math.sin(w),S=Math.cos(w);for(let b=0;b<=e.length-1;b++){u.x=e[b].x*M,u.y=e[b].y,u.z=e[b].x*S,r.push(u.x,u.y,u.z),d.x=_/t,d.y=b/(e.length-1),o.push(d.x,d.y);const T=c[3*b+0]*M,x=c[3*b+1],A=c[3*b+0]*S;l.push(T,x,A)}}for(let _=0;_<t;_++)for(let w=0;w<e.length-1;w++){const M=w+_*e.length,S=M,b=M+e.length,T=M+e.length+1,x=M+1;s.push(S,b,x),s.push(T,x,b)}this.setIndex(s),this.setAttribute("position",new xt(r,3)),this.setAttribute("uv",new xt(o,2)),this.setAttribute("normal",new xt(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new _l(e.points,e.segments,e.phiStart,e.phiLength)}}class ki extends ut{constructor(e=1,t=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:n};const s=e/2,r=t/2,o=Math.floor(i),c=Math.floor(n),l=o+1,h=c+1,u=e/o,d=t/c,f=[],p=[],v=[],m=[];for(let g=0;g<h;g++){const _=g*d-r;for(let w=0;w<l;w++){const M=w*u-s;p.push(M,-_,0),v.push(0,0,1),m.push(w/o),m.push(1-g/c)}}for(let g=0;g<c;g++)for(let _=0;_<o;_++){const w=_+l*g,M=_+l*(g+1),S=_+1+l*(g+1),b=_+1+l*g;f.push(w,M,b),f.push(M,S,b)}this.setIndex(f),this.setAttribute("position",new xt(p,3)),this.setAttribute("normal",new xt(v,3)),this.setAttribute("uv",new xt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ki(e.width,e.height,e.widthSegments,e.heightSegments)}}class jt extends ut{constructor(e=1,t=32,i=16,n=0,s=Math.PI*2,r=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:n,phiLength:s,thetaStart:r,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const c=Math.min(r+o,Math.PI);let l=0;const h=[],u=new D,d=new D,f=[],p=[],v=[],m=[];for(let g=0;g<=i;g++){const _=[],w=g/i,M=r+w*o,S=e*Math.cos(M),b=Math.sqrt(e*e-S*S);let T=0;g===0&&r===0?T=.5/t:g===i&&c===Math.PI&&(T=-.5/t);for(let x=0;x<=t;x++){const A=x/t,I=n+A*s;u.x=-b*Math.cos(I),u.y=S,u.z=b*Math.sin(I),p.push(u.x,u.y,u.z),d.copy(u).normalize(),v.push(d.x,d.y,d.z),m.push(A+T,1-w),_.push(l++)}h.push(_)}for(let g=0;g<i;g++)for(let _=0;_<t;_++){const w=h[g][_+1],M=h[g][_],S=h[g+1][_],b=h[g+1][_+1];(g!==0||r>0)&&f.push(w,M,b),(g!==i-1||c<Math.PI)&&f.push(M,S,b)}this.setIndex(f),this.setAttribute("position",new xt(p,3)),this.setAttribute("normal",new xt(v,3)),this.setAttribute("uv",new xt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new jt(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class qd extends ut{constructor(e=1,t=.4,i=12,n=48,s=Math.PI*2,r=0,o=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:n,arc:s,thetaStart:r,thetaLength:o},i=Math.floor(i),n=Math.floor(n);const c=[],l=[],h=[],u=[],d=new D,f=new D,p=new D;for(let v=0;v<=i;v++){const m=r+v/i*o;for(let g=0;g<=n;g++){const _=g/n*s;f.x=(e+t*Math.cos(m))*Math.cos(_),f.y=(e+t*Math.cos(m))*Math.sin(_),f.z=t*Math.sin(m),l.push(f.x,f.y,f.z),d.x=e*Math.cos(_),d.y=e*Math.sin(_),p.subVectors(f,d).normalize(),h.push(p.x,p.y,p.z),u.push(g/n),u.push(v/i)}}for(let v=1;v<=i;v++)for(let m=1;m<=n;m++){const g=(n+1)*v+m-1,_=(n+1)*(v-1)+m-1,w=(n+1)*(v-1)+m,M=(n+1)*v+m;c.push(g,_,M),c.push(_,w,M)}this.setIndex(c),this.setAttribute("position",new xt(l,3)),this.setAttribute("normal",new xt(h,3)),this.setAttribute("uv",new xt(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new qd(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}function xr(a){const e={};for(const t in a){e[t]={};for(const i in a[t]){const n=a[t][i];if(Of(n))n.isRenderTargetTexture?(Te("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=n.clone();else if(Array.isArray(n))if(Of(n[0])){const s=[];for(let r=0,o=n.length;r<o;r++)s[r]=n[r].clone();e[t][i]=s}else e[t][i]=n.slice();else e[t][i]=n}}return e}function Ii(a){const e={};for(let t=0;t<a.length;t++){const i=xr(a[t]);for(const n in i)e[n]=i[n]}return e}function Of(a){return a&&(a.isColor||a.isMatrix3||a.isMatrix4||a.isVector2||a.isVector3||a.isVector4||a.isTexture||a.isQuaternion)}function rM(a){const e=[];for(let t=0;t<a.length;t++)e.push(a[t].clone());return e}function yg(a){const e=a.getRenderTarget();return e===null?a.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:it.workingColorSpace}const oM={clone:xr,merge:Ii};var cM=`void main() {
|
|
631
|
+
*/const Dd="185",I2=0,Y0=1,P2=2,io=1,L2=2,Zr=3,qs=0,Ot=1,tn=2,Zn=0,Ws=1,Ci=2,K0=3,$0=4,Ml=5,ra=100,N2=101,O2=102,U2=103,F2=104,k2=200,go=201,z2=202,H2=203,nu=204,vo=205,B2=206,G2=207,V2=208,W2=209,X2=210,q2=211,Y2=212,K2=213,$2=214,su=0,au=1,ru=2,gr=3,ou=4,cu=5,lu=6,hu=7,Cd=0,Z2=1,J2=2,Jn=0,$m=1,Zm=2,Jm=3,jm=4,Qm=5,eg=6,tg=7,Z0="attached",j2="detached",ig=300,ya=301,vr=302,Ul=303,Fl=304,xl=306,Mo=1e3,yi=1001,uu=1002,wt=1003,Q2=1004,ko=1005,st=1006,kl=1007,da=1008,nn=1009,ng=1010,sg=1011,xo=1012,Id=1013,gn=1014,Di=1015,kt=1016,Pd=1017,Ld=1018,yo=1020,ag=35902,rg=35899,og=1021,cg=1022,_i=1023,vs=1026,fa=1027,yl=1028,Nd=1029,_a=1030,Od=1031,Ud=1033,Uc=33776,Fc=33777,kc=33778,zc=33779,du=35840,fu=35841,pu=35842,mu=35843,gu=36196,vu=37492,Mu=37496,xu=37488,yu=37489,$c=37490,_u=37491,Su=37808,wu=37809,bu=37810,Eu=37811,Au=37812,Tu=37813,Ru=37814,Du=37815,Cu=37816,Iu=37817,Pu=37818,Lu=37819,Nu=37820,Ou=37821,Uu=36492,Fu=36494,ku=36495,zu=36283,Hu=36284,Zc=36285,Bu=36286,Jc=2300,Gu=2301,zl=2302,J0=2303,j0=2400,Q0=2401,ef=2402,ev=2500,gE=0,vE=1,ME=2,tv=3200,jc=0,iv=1,zs="",Fi="srgb",Qc="srgb-linear",el="linear",gt="srgb",Da=7680,tf=519,nv=512,sv=513,av=514,Fd=515,rv=516,ov=517,kd=518,cv=519,Vu=35044,tl="300 es",Kn=2e3,_o=2001;function lv(a){for(let e=a.length-1;e>=0;--e)if(a[e]>=65535)return!0;return!1}function hv(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)}function So(a){return document.createElementNS("http://www.w3.org/1999/xhtml",a)}function uv(){const a=So("canvas");return a.style.display="block",a}const nf={};function il(...a){const e="THREE."+a.shift();console.log(e,...a)}function lg(a){const e=a[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=a[1];t&&t.isStackTrace?a[0]+=" "+t.getLocation():a[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return a}function Te(...a){a=lg(a);const e="THREE."+a.shift();{const t=a[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...a)}}function Be(...a){a=lg(a);const e="THREE."+a.shift();{const t=a[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...a)}}function or(...a){const e=a.join(" ");e in nf||(nf[e]=!0,Te(...a))}function dv(a,e,t){return new Promise(function(i,n){function s(){switch(a.clientWaitSync(e,a.SYNC_FLUSH_COMMANDS_BIT,0)){case a.WAIT_FAILED:n();break;case a.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:i()}}setTimeout(s,t)})}const fv={[su]:au,[ru]:lu,[ou]:hu,[gr]:cu,[au]:su,[lu]:ru,[hu]:ou,[cu]:gr};class ba{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const n=i[e];if(n!==void 0){const s=n.indexOf(t);s!==-1&&n.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const n=i.slice(0);for(let s=0,r=n.length;s<r;s++)n[s].call(this,e);e.target=null}}}const bi=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let sf=1234567;const no=Math.PI/180,Mr=180/Math.PI;function Rn(){const a=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(bi[a&255]+bi[a>>8&255]+bi[a>>16&255]+bi[a>>24&255]+"-"+bi[e&255]+bi[e>>8&255]+"-"+bi[e>>16&15|64]+bi[e>>24&255]+"-"+bi[t&63|128]+bi[t>>8&255]+"-"+bi[t>>16&255]+bi[t>>24&255]+bi[i&255]+bi[i>>8&255]+bi[i>>16&255]+bi[i>>24&255]).toLowerCase()}function je(a,e,t){return Math.max(e,Math.min(t,a))}function zd(a,e){return(a%e+e)%e}function pv(a,e,t,i,n){return i+(a-e)*(n-i)/(t-e)}function mv(a,e,t){return a!==e?(t-a)/(e-a):0}function so(a,e,t){return(1-t)*a+t*e}function gv(a,e,t,i){return so(a,e,1-Math.exp(-t*i))}function vv(a,e=1){return e-Math.abs(zd(a,e*2)-e)}function Mv(a,e,t){return a<=e?0:a>=t?1:(a=(a-e)/(t-e),a*a*(3-2*a))}function xv(a,e,t){return a<=e?0:a>=t?1:(a=(a-e)/(t-e),a*a*a*(a*(a*6-15)+10))}function yv(a,e){return a+Math.floor(Math.random()*(e-a+1))}function _v(a,e){return a+Math.random()*(e-a)}function Sv(a){return a*(.5-Math.random())}function wv(a){a!==void 0&&(sf=a);let e=sf+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function bv(a){return a*no}function Ev(a){return a*Mr}function Av(a){return(a&a-1)===0&&a!==0}function Tv(a){return Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function Rv(a){return Math.pow(2,Math.floor(Math.log(a)/Math.LN2))}function Dv(a,e,t,i,n){const s=Math.cos,r=Math.sin,o=s(t/2),c=r(t/2),l=s((e+i)/2),h=r((e+i)/2),u=s((e-i)/2),d=r((e-i)/2),f=s((i-e)/2),p=r((i-e)/2);switch(n){case"XYX":a.set(o*h,c*u,c*d,o*l);break;case"YZY":a.set(c*d,o*h,c*u,o*l);break;case"ZXZ":a.set(c*u,c*d,o*h,o*l);break;case"XZX":a.set(o*h,c*p,c*f,o*l);break;case"YXY":a.set(c*f,o*h,c*p,o*l);break;case"ZYZ":a.set(c*p,c*f,o*h,o*l);break;default:Te("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function An(a,e){switch(e.constructor){case Float32Array:return a;case Uint32Array:return a/4294967295;case Uint16Array:return a/65535;case Uint8Array:return a/255;case Int32Array:return Math.max(a/2147483647,-1);case Int16Array:return Math.max(a/32767,-1);case Int8Array:return Math.max(a/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function vt(a,e){switch(e.constructor){case Float32Array:return a;case Uint32Array:return Math.round(a*4294967295);case Uint16Array:return Math.round(a*65535);case Uint8Array:return Math.round(a*255);case Int32Array:return Math.round(a*2147483647);case Int16Array:return Math.round(a*32767);case Int8Array:return Math.round(a*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const xE={DEG2RAD:no,RAD2DEG:Mr,generateUUID:Rn,clamp:je,euclideanModulo:zd,mapLinear:pv,inverseLerp:mv,lerp:so,damp:gv,pingpong:vv,smoothstep:Mv,smootherstep:xv,randInt:yv,randFloat:_v,randFloatSpread:Sv,seededRandom:wv,degToRad:bv,radToDeg:Ev,isPowerOfTwo:Av,ceilPowerOfTwo:Tv,floorPowerOfTwo:Rv,setQuaternionFromProperEuler:Dv,normalize:vt,denormalize:An};class xe{static{xe.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,i=this.y,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6],this.y=n[1]*t+n[4]*i+n[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=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),n=Math.sin(t),s=this.x-e.x,r=this.y-e.y;return this.x=s*i-r*n+e.x,this.y=s*n+r*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Qn{constructor(e=0,t=0,i=0,n=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=n}static slerpFlat(e,t,i,n,s,r,o){let c=i[n+0],l=i[n+1],h=i[n+2],u=i[n+3],d=s[r+0],f=s[r+1],p=s[r+2],v=s[r+3];if(u!==v||c!==d||l!==f||h!==p){let m=c*d+l*f+h*p+u*v;m<0&&(d=-d,f=-f,p=-p,v=-v,m=-m);let g=1-o;if(m<.9995){const _=Math.acos(m),w=Math.sin(_);g=Math.sin(g*_)/w,o=Math.sin(o*_)/w,c=c*g+d*o,l=l*g+f*o,h=h*g+p*o,u=u*g+v*o}else{c=c*g+d*o,l=l*g+f*o,h=h*g+p*o,u=u*g+v*o;const _=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=_,l*=_,h*=_,u*=_}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,i,n,s,r){const o=i[n],c=i[n+1],l=i[n+2],h=i[n+3],u=s[r],d=s[r+1],f=s[r+2],p=s[r+3];return e[t]=o*p+h*u+c*f-l*d,e[t+1]=c*p+h*d+l*u-o*f,e[t+2]=l*p+h*f+o*d-c*u,e[t+3]=h*p-o*u-c*d-l*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,n){return this._x=e,this._y=t,this._z=i,this._w=n,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 i=e._x,n=e._y,s=e._z,r=e._order,o=Math.cos,c=Math.sin,l=o(i/2),h=o(n/2),u=o(s/2),d=c(i/2),f=c(n/2),p=c(s/2);switch(r){case"XYZ":this._x=d*h*u+l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u-d*f*p;break;case"YXZ":this._x=d*h*u+l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u+d*f*p;break;case"ZXY":this._x=d*h*u-l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u-d*f*p;break;case"ZYX":this._x=d*h*u-l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u+d*f*p;break;case"YZX":this._x=d*h*u+l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u-d*f*p;break;case"XZY":this._x=d*h*u-l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u+d*f*p;break;default:Te("Quaternion: .setFromEuler() encountered an unknown order: "+r)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,n=Math.sin(i);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],n=t[4],s=t[8],r=t[1],o=t[5],c=t[9],l=t[2],h=t[6],u=t[10],d=i+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(s-l)*f,this._z=(r-n)*f}else if(i>o&&i>u){const f=2*Math.sqrt(1+i-o-u);this._w=(h-c)/f,this._x=.25*f,this._y=(n+r)/f,this._z=(s+l)/f}else if(o>u){const f=2*Math.sqrt(1+o-i-u);this._w=(s-l)/f,this._x=(n+r)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+u-i-o);this._w=(r-n)/f,this._x=(s+l)/f,this._y=(c+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(je(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const n=Math.min(1,t/i);return this.slerp(e,n),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 i=e._x,n=e._y,s=e._z,r=e._w,o=t._x,c=t._y,l=t._z,h=t._w;return this._x=i*h+r*o+n*l-s*c,this._y=n*h+r*c+s*o-i*l,this._z=s*h+r*l+i*c-n*o,this._w=r*h-i*o-n*c-s*l,this._onChangeCallback(),this}slerp(e,t){let i=e._x,n=e._y,s=e._z,r=e._w,o=this.dot(e);o<0&&(i=-i,n=-n,s=-s,r=-r,o=-o);let c=1-t;if(o<.9995){const l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,t=Math.sin(t*l)/h,this._x=this._x*c+i*t,this._y=this._y*c+n*t,this._z=this._z*c+s*t,this._w=this._w*c+r*t,this._onChangeCallback()}else this._x=this._x*c+i*t,this._y=this._y*c+n*t,this._z=this._z*c+s*t,this._w=this._w*c+r*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(n*Math.sin(e),n*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class D{static{D.prototype.isVector3=!0}constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("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(af.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(af.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,n=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*n,this.y=s[1]*t+s[4]*i+s[7]*n,this.z=s[2]*t+s[5]*i+s[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,s=e.elements,r=1/(s[3]*t+s[7]*i+s[11]*n+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*n+s[12])*r,this.y=(s[1]*t+s[5]*i+s[9]*n+s[13])*r,this.z=(s[2]*t+s[6]*i+s[10]*n+s[14])*r,this}applyQuaternion(e){const t=this.x,i=this.y,n=this.z,s=e.x,r=e.y,o=e.z,c=e.w,l=2*(r*n-o*i),h=2*(o*t-s*n),u=2*(s*i-r*t);return this.x=t+c*l+r*u-o*h,this.y=i+c*h+o*l-s*u,this.z=n+c*u+s*h-r*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,n=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*n,this.y=s[1]*t+s[5]*i+s[9]*n,this.z=s[2]*t+s[6]*i+s[10]*n,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=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,n=e.y,s=e.z,r=t.x,o=t.y,c=t.z;return this.x=n*c-s*o,this.y=s*r-i*c,this.z=i*o-n*r,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Hl.copy(this).projectOnVector(e),this.sub(Hl)}reflect(e){return this.sub(Hl.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 i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return t*t+i*i+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const n=Math.sin(t)*e;return this.x=n*Math.sin(i),this.y=Math.cos(t)*e,this.z=n*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){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(),i=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=n,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,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Hl=new D,af=new Qn;class Xe{static{Xe.prototype.isMatrix3=!0}constructor(e,t,i,n,s,r,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,n,s,r,o,c,l)}set(e,t,i,n,s,r,o,c,l){const h=this.elements;return h[0]=e,h[1]=n,h[2]=o,h[3]=t,h[4]=s,h[5]=c,h[6]=i,h[7]=r,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){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 i=e.elements,n=t.elements,s=this.elements,r=i[0],o=i[3],c=i[6],l=i[1],h=i[4],u=i[7],d=i[2],f=i[5],p=i[8],v=n[0],m=n[3],g=n[6],_=n[1],w=n[4],M=n[7],S=n[2],b=n[5],T=n[8];return s[0]=r*v+o*_+c*S,s[3]=r*m+o*w+c*b,s[6]=r*g+o*M+c*T,s[1]=l*v+h*_+u*S,s[4]=l*m+h*w+u*b,s[7]=l*g+h*M+u*T,s[2]=d*v+f*_+p*S,s[5]=d*m+f*w+p*b,s[8]=d*g+f*M+p*T,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],i=e[1],n=e[2],s=e[3],r=e[4],o=e[5],c=e[6],l=e[7],h=e[8];return t*r*h-t*o*l-i*s*h+i*o*c+n*s*l-n*r*c}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],s=e[3],r=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=h*r-o*l,d=o*c-h*s,f=l*s-r*c,p=t*u+i*d+n*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/p;return e[0]=u*v,e[1]=(n*l-h*i)*v,e[2]=(o*i-n*r)*v,e[3]=d*v,e[4]=(h*t-n*c)*v,e[5]=(n*s-o*t)*v,e[6]=f*v,e[7]=(i*c-l*t)*v,e[8]=(r*t-i*s)*v,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,i,n,s,r,o){const c=Math.cos(s),l=Math.sin(s);return this.set(i*c,i*l,-i*(c*r+l*o)+r+e,-n*l,n*c,-n*(-l*r+c*o)+o+t,0,0,1),this}scale(e,t){return or("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Bl.makeScale(e,t)),this}rotate(e){return or("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Bl.makeRotation(-e)),this}translate(e,t){return or("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Bl.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),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let n=0;n<9;n++)if(t[n]!==i[n])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Bl=new Xe,rf=new Xe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),of=new Xe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Cv(){const a={enabled:!0,workingColorSpace:Qc,spaces:{},convert:function(n,s,r){return this.enabled===!1||s===r||!s||!r||(this.spaces[s].transfer===gt&&(n.r=gs(n.r),n.g=gs(n.g),n.b=gs(n.b)),this.spaces[s].primaries!==this.spaces[r].primaries&&(n.applyMatrix3(this.spaces[s].toXYZ),n.applyMatrix3(this.spaces[r].fromXYZ)),this.spaces[r].transfer===gt&&(n.r=cr(n.r),n.g=cr(n.g),n.b=cr(n.b))),n},workingToColorSpace:function(n,s){return this.convert(n,this.workingColorSpace,s)},colorSpaceToWorking:function(n,s){return this.convert(n,s,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===zs?el:this.spaces[n].transfer},getToneMappingMode:function(n){return this.spaces[n].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(n,s=this.workingColorSpace){return n.fromArray(this.spaces[s].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,s,r){return n.copy(this.spaces[s].toXYZ).multiply(this.spaces[r].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(n,s){return or("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),a.workingToColorSpace(n,s)},toWorkingColorSpace:function(n,s){return or("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),a.colorSpaceToWorking(n,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return a.define({[Qc]:{primaries:e,whitePoint:i,transfer:el,toXYZ:rf,fromXYZ:of,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Fi},outputColorSpaceConfig:{drawingBufferColorSpace:Fi}},[Fi]:{primaries:e,whitePoint:i,transfer:gt,toXYZ:rf,fromXYZ:of,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Fi}}}),a}const nt=Cv();function gs(a){return a<.04045?a*.0773993808:Math.pow(a*.9478672986+.0521327014,2.4)}function cr(a){return a<.0031308?a*12.92:1.055*Math.pow(a,.41666)-.055}let Ca;class Iv{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{Ca===void 0&&(Ca=So("canvas")),Ca.width=e.width,Ca.height=e.height;const n=Ca.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),i=Ca}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=So("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const n=i.getImageData(0,0,e.width,e.height),s=n.data;for(let r=0;r<s.length;r++)s[r]=gs(s[r]/255)*255;return i.putImageData(n,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(gs(t[i]/255)*255):t[i]=gs(t[i]);return{data:t,width:e.width,height:e.height}}else return Te("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Pv=0;class Hd{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Pv++}),this.uuid=Rn(),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 i={uuid:this.uuid,url:""},n=this.data;if(n!==null){let s;if(Array.isArray(n)){s=[];for(let r=0,o=n.length;r<o;r++)n[r].isDataTexture?s.push(Gl(n[r].image)):s.push(Gl(n[r]))}else s=Gl(n);i.url=s}return t||(e.images[this.uuid]=i),i}}function Gl(a){return typeof HTMLImageElement<"u"&&a instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&a instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&a instanceof ImageBitmap?Iv.getDataURL(a):a.data?{data:Array.from(a.data),width:a.width,height:a.height,type:a.data.constructor.name}:(Te("Texture: Unable to serialize Texture."),{})}let Lv=0;const Vl=new D;class xi extends ba{constructor(e=xi.DEFAULT_IMAGE,t=xi.DEFAULT_MAPPING,i=yi,n=yi,s=st,r=da,o=_i,c=nn,l=xi.DEFAULT_ANISOTROPY,h=zs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Lv++}),this.uuid=Rn(),this.name="",this.source=new Hd(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=s,this.minFilter=r,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new xe(0,0),this.repeat=new xe(1,1),this.center=new xe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Xe,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(Vl).x}get height(){return this.source.getSize(Vl).y}get depth(){return this.source.getSize(Vl).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 i=e[t];if(i===void 0){Te(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){Te(`Texture.setValues(): property '${t}' does not exist.`);continue}n&&i&&n.isVector2&&i.isVector2||n&&i&&n.isVector3&&i.isVector3||n&&i&&n.isMatrix3&&i.isMatrix3?n.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,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&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ig)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Mo:e.x=e.x-Math.floor(e.x);break;case yi:e.x=e.x<0?0:1;break;case uu: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 Mo:e.y=e.y-Math.floor(e.y);break;case yi:e.y=e.y<0?0:1;break;case uu: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++}}xi.DEFAULT_IMAGE=null;xi.DEFAULT_MAPPING=ig;xi.DEFAULT_ANISOTROPY=1;class it{static{it.prototype.isVector4=!0}constructor(e=0,t=0,i=0,n=1){this.x=e,this.y=t,this.z=i,this.w=n}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,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,i=this.y,n=this.z,s=this.w,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*n+r[12]*s,this.y=r[1]*t+r[5]*i+r[9]*n+r[13]*s,this.z=r[2]*t+r[6]*i+r[10]*n+r[14]*s,this.w=r[3]*t+r[7]*i+r[11]*n+r[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);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,i,n,s;const c=e.elements,l=c[0],h=c[4],u=c[8],d=c[1],f=c[5],p=c[9],v=c[2],m=c[6],g=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-v)<.01&&Math.abs(p-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+v)<.1&&Math.abs(p+m)<.1&&Math.abs(l+f+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const w=(l+1)/2,M=(f+1)/2,S=(g+1)/2,b=(h+d)/4,T=(u+v)/4,x=(p+m)/4;return w>M&&w>S?w<.01?(i=0,n=.707106781,s=.707106781):(i=Math.sqrt(w),n=b/i,s=T/i):M>S?M<.01?(i=.707106781,n=0,s=.707106781):(n=Math.sqrt(M),i=b/n,s=x/n):S<.01?(i=.707106781,n=.707106781,s=0):(s=Math.sqrt(S),i=T/s,n=x/s),this.set(i,n,s,t),this}let _=Math.sqrt((m-p)*(m-p)+(u-v)*(u-v)+(d-h)*(d-h));return Math.abs(_)<.001&&(_=1),this.x=(m-p)/_,this.y=(u-v)/_,this.z=(d-h)/_,this.w=Math.acos((l+f+g-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=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this.w=je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this.w=je(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Nv extends ba{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:st,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new it(0,0,e,t),this.scissorTest=!1,this.viewport=new it(0,0,e,t),this.textures=[];const n={width:e,height:t,depth:i.depth},s=new xi(n),r=i.count;for(let o=0;o<r;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview,this.useArrayDepthTexture=i.useArrayDepthTexture}_setTextureOptions(e={}){const t={minFilter:st,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let n=0,s=this.textures.length;n<s;n++)this.textures[n].image.width=e,this.textures[n].image.height=t,this.textures[n].image.depth=i,this.textures[n].isData3DTexture!==!0&&(this.textures[n].isArrayTexture=this.textures[n].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const n=Object.assign({},e.textures[t].image);this.textures[t].source=new Hd(n)}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 jt extends Nv{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class hg extends xi{constructor(e=null,t=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:n},this.magFilter=wt,this.minFilter=wt,this.wrapR=yi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class ug extends xi{constructor(e=null,t=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:n},this.magFilter=wt,this.minFilter=wt,this.wrapR=yi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ze{static{Ze.prototype.isMatrix4=!0}constructor(e,t,i,n,s,r,o,c,l,h,u,d,f,p,v,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,i,n,s,r,o,c,l,h,u,d,f,p,v,m)}set(e,t,i,n,s,r,o,c,l,h,u,d,f,p,v,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=n,g[1]=s,g[5]=r,g[9]=o,g[13]=c,g[2]=l,g[6]=h,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=v,g[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 Ze().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[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,i){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const t=this.elements,i=e.elements,n=1/Ia.setFromMatrixColumn(e,0).length(),s=1/Ia.setFromMatrixColumn(e,1).length(),r=1/Ia.setFromMatrixColumn(e,2).length();return t[0]=i[0]*n,t[1]=i[1]*n,t[2]=i[2]*n,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*r,t[9]=i[9]*r,t[10]=i[10]*r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,n=e.y,s=e.z,r=Math.cos(i),o=Math.sin(i),c=Math.cos(n),l=Math.sin(n),h=Math.cos(s),u=Math.sin(s);if(e.order==="XYZ"){const d=r*h,f=r*u,p=o*h,v=o*u;t[0]=c*h,t[4]=-c*u,t[8]=l,t[1]=f+p*l,t[5]=d-v*l,t[9]=-o*c,t[2]=v-d*l,t[6]=p+f*l,t[10]=r*c}else if(e.order==="YXZ"){const d=c*h,f=c*u,p=l*h,v=l*u;t[0]=d+v*o,t[4]=p*o-f,t[8]=r*l,t[1]=r*u,t[5]=r*h,t[9]=-o,t[2]=f*o-p,t[6]=v+d*o,t[10]=r*c}else if(e.order==="ZXY"){const d=c*h,f=c*u,p=l*h,v=l*u;t[0]=d-v*o,t[4]=-r*u,t[8]=p+f*o,t[1]=f+p*o,t[5]=r*h,t[9]=v-d*o,t[2]=-r*l,t[6]=o,t[10]=r*c}else if(e.order==="ZYX"){const d=r*h,f=r*u,p=o*h,v=o*u;t[0]=c*h,t[4]=p*l-f,t[8]=d*l+v,t[1]=c*u,t[5]=v*l+d,t[9]=f*l-p,t[2]=-l,t[6]=o*c,t[10]=r*c}else if(e.order==="YZX"){const d=r*c,f=r*l,p=o*c,v=o*l;t[0]=c*h,t[4]=v-d*u,t[8]=p*u+f,t[1]=u,t[5]=r*h,t[9]=-o*h,t[2]=-l*h,t[6]=f*u+p,t[10]=d-v*u}else if(e.order==="XZY"){const d=r*c,f=r*l,p=o*c,v=o*l;t[0]=c*h,t[4]=-u,t[8]=l*h,t[1]=d*u+v,t[5]=r*h,t[9]=f*u-p,t[2]=p*u-f,t[6]=o*h,t[10]=v*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(Ov,e,Uv)}lookAt(e,t,i){const n=this.elements;return qi.subVectors(e,t),qi.lengthSq()===0&&(qi.z=1),qi.normalize(),As.crossVectors(i,qi),As.lengthSq()===0&&(Math.abs(i.z)===1?qi.x+=1e-4:qi.z+=1e-4,qi.normalize(),As.crossVectors(i,qi)),As.normalize(),zo.crossVectors(qi,As),n[0]=As.x,n[4]=zo.x,n[8]=qi.x,n[1]=As.y,n[5]=zo.y,n[9]=qi.y,n[2]=As.z,n[6]=zo.z,n[10]=qi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,s=this.elements,r=i[0],o=i[4],c=i[8],l=i[12],h=i[1],u=i[5],d=i[9],f=i[13],p=i[2],v=i[6],m=i[10],g=i[14],_=i[3],w=i[7],M=i[11],S=i[15],b=n[0],T=n[4],x=n[8],A=n[12],I=n[1],C=n[5],P=n[9],X=n[13],z=n[2],N=n[6],V=n[10],k=n[14],K=n[3],ee=n[7],J=n[11],ie=n[15];return s[0]=r*b+o*I+c*z+l*K,s[4]=r*T+o*C+c*N+l*ee,s[8]=r*x+o*P+c*V+l*J,s[12]=r*A+o*X+c*k+l*ie,s[1]=h*b+u*I+d*z+f*K,s[5]=h*T+u*C+d*N+f*ee,s[9]=h*x+u*P+d*V+f*J,s[13]=h*A+u*X+d*k+f*ie,s[2]=p*b+v*I+m*z+g*K,s[6]=p*T+v*C+m*N+g*ee,s[10]=p*x+v*P+m*V+g*J,s[14]=p*A+v*X+m*k+g*ie,s[3]=_*b+w*I+M*z+S*K,s[7]=_*T+w*C+M*N+S*ee,s[11]=_*x+w*P+M*V+S*J,s[15]=_*A+w*X+M*k+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],i=e[4],n=e[8],s=e[12],r=e[1],o=e[5],c=e[9],l=e[13],h=e[2],u=e[6],d=e[10],f=e[14],p=e[3],v=e[7],m=e[11],g=e[15],_=c*f-l*d,w=o*f-l*u,M=o*d-c*u,S=r*f-l*h,b=r*d-c*h,T=r*u-o*h;return t*(v*_-m*w+g*M)-i*(p*_-m*S+g*b)+n*(p*w-v*S+g*T)-s*(p*M-v*b+m*T)}determinantAffine(){const e=this.elements,t=e[0],i=e[4],n=e[8],s=e[1],r=e[5],o=e[9],c=e[2],l=e[6],h=e[10];return t*(r*h-o*l)-i*(s*h-o*c)+n*(s*l-r*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const n=this.elements;return e.isVector3?(n[12]=e.x,n[13]=e.y,n[14]=e.z):(n[12]=e,n[13]=t,n[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],s=e[3],r=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=e[9],d=e[10],f=e[11],p=e[12],v=e[13],m=e[14],g=e[15],_=t*o-i*r,w=t*c-n*r,M=t*l-s*r,S=i*c-n*o,b=i*l-s*o,T=n*l-s*c,x=h*v-u*p,A=h*m-d*p,I=h*g-f*p,C=u*m-d*v,P=u*g-f*v,X=d*g-f*m,z=_*X-w*P+M*C+S*I-b*A+T*x;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const N=1/z;return e[0]=(o*X-c*P+l*C)*N,e[1]=(n*P-i*X-s*C)*N,e[2]=(v*T-m*b+g*S)*N,e[3]=(d*b-u*T-f*S)*N,e[4]=(c*I-r*X-l*A)*N,e[5]=(t*X-n*I+s*A)*N,e[6]=(m*M-p*T-g*w)*N,e[7]=(h*T-d*M+f*w)*N,e[8]=(r*P-o*I+l*x)*N,e[9]=(i*I-t*P-s*x)*N,e[10]=(p*b-v*M+g*_)*N,e[11]=(u*M-h*b-f*_)*N,e[12]=(o*A-r*C-c*x)*N,e[13]=(t*C-i*A+n*x)*N,e[14]=(v*w-p*S-m*_)*N,e[15]=(h*S-u*w+d*_)*N,this}scale(e){const t=this.elements,i=e.x,n=e.y,s=e.z;return t[0]*=i,t[4]*=n,t[8]*=s,t[1]*=i,t[5]*=n,t[9]*=s,t[2]*=i,t[6]*=n,t[10]*=s,t[3]*=i,t[7]*=n,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,n))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),n=Math.sin(t),s=1-i,r=e.x,o=e.y,c=e.z,l=s*r,h=s*o;return this.set(l*r+i,l*o-n*c,l*c+n*o,0,l*o+n*c,h*o+i,h*c-n*r,0,l*c-n*o,h*c+n*r,s*c*c+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,n,s,r){return this.set(1,i,s,0,e,1,r,0,t,n,1,0,0,0,0,1),this}compose(e,t,i){const n=this.elements,s=t._x,r=t._y,o=t._z,c=t._w,l=s+s,h=r+r,u=o+o,d=s*l,f=s*h,p=s*u,v=r*h,m=r*u,g=o*u,_=c*l,w=c*h,M=c*u,S=i.x,b=i.y,T=i.z;return n[0]=(1-(v+g))*S,n[1]=(f+M)*S,n[2]=(p-w)*S,n[3]=0,n[4]=(f-M)*b,n[5]=(1-(d+g))*b,n[6]=(m+_)*b,n[7]=0,n[8]=(p+w)*T,n[9]=(m-_)*T,n[10]=(1-(d+v))*T,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,this}decompose(e,t,i){const n=this.elements;e.x=n[12],e.y=n[13],e.z=n[14];const s=this.determinantAffine();if(s===0)return i.set(1,1,1),t.identity(),this;let r=Ia.set(n[0],n[1],n[2]).length();const o=Ia.set(n[4],n[5],n[6]).length(),c=Ia.set(n[8],n[9],n[10]).length();s<0&&(r=-r),Mn.copy(this);const l=1/r,h=1/o,u=1/c;return Mn.elements[0]*=l,Mn.elements[1]*=l,Mn.elements[2]*=l,Mn.elements[4]*=h,Mn.elements[5]*=h,Mn.elements[6]*=h,Mn.elements[8]*=u,Mn.elements[9]*=u,Mn.elements[10]*=u,t.setFromRotationMatrix(Mn),i.x=r,i.y=o,i.z=c,this}makePerspective(e,t,i,n,s,r,o=Kn,c=!1){const l=this.elements,h=2*s/(t-e),u=2*s/(i-n),d=(t+e)/(t-e),f=(i+n)/(i-n);let p,v;if(c)p=s/(r-s),v=r*s/(r-s);else if(o===Kn)p=-(r+s)/(r-s),v=-2*r*s/(r-s);else if(o===_o)p=-r/(r-s),v=-r*s/(r-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,n,s,r,o=Kn,c=!1){const l=this.elements,h=2/(t-e),u=2/(i-n),d=-(t+e)/(t-e),f=-(i+n)/(i-n);let p,v;if(c)p=1/(r-s),v=r/(r-s);else if(o===Kn)p=-2/(r-s),v=-(r+s)/(r-s);else if(o===_o)p=-1/(r-s),v=-s/(r-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=f,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let n=0;n<16;n++)if(t[n]!==i[n])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const Ia=new D,Mn=new Ze,Ov=new D(0,0,0),Uv=new D(1,1,1),As=new D,zo=new D,qi=new D,cf=new Ze,lf=new Qn;class Ms{constructor(e=0,t=0,i=0,n=Ms.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=n}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,n=this._order){return this._x=e,this._y=t,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const n=e.elements,s=n[0],r=n[4],o=n[8],c=n[1],l=n[5],h=n[9],u=n[2],d=n[6],f=n[10];switch(t){case"XYZ":this._y=Math.asin(je(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-r,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-je(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(je(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-r,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-je(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-r,l));break;case"YZX":this._z=Math.asin(je(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-je(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:Te("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return cf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(cf,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return lf.setFromEuler(this),this.setFromQuaternion(lf,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}}Ms.DEFAULT_ORDER="XYZ";class Bd{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 Fv=0;const hf=new D,Pa=new Qn,ts=new Ze,Ho=new D,Tr=new D,kv=new D,zv=new Qn,uf=new D(1,0,0),df=new D(0,1,0),ff=new D(0,0,1),pf={type:"added"},Hv={type:"removed"},La={type:"childadded",child:null},Wl={type:"childremoved",child:null};class Pt extends ba{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Fv++}),this.uuid=Rn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Pt.DEFAULT_UP.clone();const e=new D,t=new Ms,i=new Qn,n=new D(1,1,1);function s(){i.setFromEuler(t,!1)}function r(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._onChange(r),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Ze},normalMatrix:{value:new Xe}}),this.matrix=new Ze,this.matrixWorld=new Ze,this.matrixAutoUpdate=Pt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Bd,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 Pa.setFromAxisAngle(e,t),this.quaternion.multiply(Pa),this}rotateOnWorldAxis(e,t){return Pa.setFromAxisAngle(e,t),this.quaternion.premultiply(Pa),this}rotateX(e){return this.rotateOnAxis(uf,e)}rotateY(e){return this.rotateOnAxis(df,e)}rotateZ(e){return this.rotateOnAxis(ff,e)}translateOnAxis(e,t){return hf.copy(e).applyQuaternion(this.quaternion),this.position.add(hf.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(uf,e)}translateY(e){return this.translateOnAxis(df,e)}translateZ(e){return this.translateOnAxis(ff,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ts.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Ho.copy(e):Ho.set(e,t,i);const n=this.parent;this.updateWorldMatrix(!0,!1),Tr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ts.lookAt(Tr,Ho,this.up):ts.lookAt(Ho,Tr,this.up),this.quaternion.setFromRotationMatrix(ts),n&&(ts.extractRotation(n.matrixWorld),Pa.setFromRotationMatrix(ts),this.quaternion.premultiply(Pa.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Be("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(pf),La.child=e,this.dispatchEvent(La),La.child=null):Be("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Hv),Wl.child=e,this.dispatchEvent(Wl),Wl.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),ts.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ts.multiply(e.parent.matrixWorld)),e.applyMatrix4(ts),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(pf),La.child=e,this.dispatchEvent(La),La.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,n=this.children.length;i<n;i++){const r=this.children[i].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const n=this.children;for(let s=0,r=n.length;s<r;s++)n[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Tr,e,kv),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Tr,zv,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 i=0,n=t.length;i<n;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].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,i=e.y,n=e.z,s=this.matrix.elements;s[12]+=t-s[0]*t-s[4]*i-s[8]*n,s[13]+=i-s[1]*t-s[5]*i-s[9]*n,s[14]+=n-s[2]*t-s[6]*i-s[10]*n}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 i=0,n=t.length;i<n;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t,i=!1){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||i)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,i=!0),t===!0){const s=this.children;for(let r=0,o=s.length;r<o;r++)s[r].updateWorldMatrix(!1,!0,i)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),this.static!==!1&&(n.static=this.static),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),this.pivot!==null&&(n.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(n.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(n.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),n.instanceInfo=this._instanceInfo.map(o=>({...o})),n.availableInstanceIds=this._availableInstanceIds.slice(),n.availableGeometryIds=this._availableGeometryIds.slice(),n.nextIndexStart=this._nextIndexStart,n.nextVertexStart=this._nextVertexStart,n.geometryCount=this._geometryCount,n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.matricesTexture=this._matricesTexture.toJSON(e),n.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(n.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(n.boundingBox=this.boundingBox.toJSON()));function s(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const u=c[l];s(e.shapes,u)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(s(e.materials,this.material[c]));n.material=o}else n.material=s(e.materials,this.material);if(this.children.length>0){n.children=[];for(let o=0;o<this.children.length;o++)n.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){n.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];n.animations.push(s(e.animations,c))}}if(t){const o=r(e.geometries),c=r(e.materials),l=r(e.textures),h=r(e.images),u=r(e.shapes),d=r(e.skeletons),f=r(e.animations),p=r(e.nodes);o.length>0&&(i.geometries=o),c.length>0&&(i.materials=c),l.length>0&&(i.textures=l),h.length>0&&(i.images=h),u.length>0&&(i.shapes=u),d.length>0&&(i.skeletons=d),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=n,i;function r(o){const c=[];for(const l in o){const h=o[l];delete h.metadata,c.push(h)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const n=e.children[i];this.add(n.clone())}return this}}Pt.DEFAULT_UP=new D(0,1,0);Pt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Dt extends Pt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Bv={type:"move"};class Xl{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Dt,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 Dt,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new D,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new D),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Dt,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new D,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new D,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 i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let n=null,s=null,r=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){r=!0;for(const v of e.hand.values()){const m=t.getJointPose(v,i),g=this._getHandJoint(l,v);m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=m.radius),g.visible=m!==null}const h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,p=.005;l.inputState.pinching&&d>f+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=f-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(n=t.getPose(e.targetRaySpace,i),n===null&&s!==null&&(n=s),n!==null&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,n.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(n.linearVelocity)):o.hasLinearVelocity=!1,n.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(n.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Bv)))}return o!==null&&(o.visible=n!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=r!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Dt;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const dg={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},Ts={h:0,s:0,l:0},Bo={h:0,s:0,l:0};function ql(a,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?a+(e-a)*6*t:t<1/2?e:t<2/3?a+(e-a)*6*(2/3-t):a}class se{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const n=e;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Fi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,nt.colorSpaceToWorking(this,t),this}setRGB(e,t,i,n=nt.workingColorSpace){return this.r=e,this.g=t,this.b=i,nt.colorSpaceToWorking(this,n),this}setHSL(e,t,i,n=nt.workingColorSpace){if(e=zd(e,1),t=je(t,0,1),i=je(i,0,1),t===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+t):i+t-i*t,r=2*i-s;this.r=ql(r,s,e+1/3),this.g=ql(r,s,e),this.b=ql(r,s,e-1/3)}return nt.colorSpaceToWorking(this,n),this}setStyle(e,t=Fi){function i(s){s!==void 0&&parseFloat(s)<1&&Te("Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const r=n[1],o=n[2];switch(r){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:Te("Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=n[1],r=s.length;if(r===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(r===6)return this.setHex(parseInt(s,16),t);Te("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Fi){const i=dg[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Te("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=gs(e.r),this.g=gs(e.g),this.b=gs(e.b),this}copyLinearToSRGB(e){return this.r=cr(e.r),this.g=cr(e.g),this.b=cr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Fi){return nt.workingToColorSpace(Ei.copy(this),e),Math.round(je(Ei.r*255,0,255))*65536+Math.round(je(Ei.g*255,0,255))*256+Math.round(je(Ei.b*255,0,255))}getHexString(e=Fi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=nt.workingColorSpace){nt.workingToColorSpace(Ei.copy(this),t);const i=Ei.r,n=Ei.g,s=Ei.b,r=Math.max(i,n,s),o=Math.min(i,n,s);let c,l;const h=(o+r)/2;if(o===r)c=0,l=0;else{const u=r-o;switch(l=h<=.5?u/(r+o):u/(2-r-o),r){case i:c=(n-s)/u+(n<s?6:0);break;case n:c=(s-i)/u+2;break;case s:c=(i-n)/u+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=nt.workingColorSpace){return nt.workingToColorSpace(Ei.copy(this),t),e.r=Ei.r,e.g=Ei.g,e.b=Ei.b,e}getStyle(e=Fi){nt.workingToColorSpace(Ei.copy(this),e);const t=Ei.r,i=Ei.g,n=Ei.b;return e!==Fi?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(n*255)})`}offsetHSL(e,t,i){return this.getHSL(Ts),this.setHSL(Ts.h+e,Ts.s+t,Ts.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(Ts),e.getHSL(Bo);const i=so(Ts.h,Bo.h,t),n=so(Ts.s,Bo.s,t),s=so(Ts.l,Bo.l,t);return this.setHSL(i,n,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,n=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*n,this.g=s[1]*t+s[4]*i+s[7]*n,this.b=s[2]*t+s[5]*i+s[8]*n,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 Ei=new se;se.NAMES=dg;class Gd{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new se(e),this.near=t,this.far=i}clone(){return new Gd(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class xs extends Pt{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 Ms,this.environmentIntensity=1,this.environmentRotation=new Ms,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 xn=new D,is=new D,Yl=new D,ns=new D,Na=new D,Oa=new D,mf=new D,Kl=new D,$l=new D,Zl=new D,Jl=new it,jl=new it,Ql=new it;class pn{constructor(e=new D,t=new D,i=new D){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,n){n.subVectors(i,t),xn.subVectors(e,t),n.cross(xn);const s=n.lengthSq();return s>0?n.multiplyScalar(1/Math.sqrt(s)):n.set(0,0,0)}static getBarycoord(e,t,i,n,s){xn.subVectors(n,t),is.subVectors(i,t),Yl.subVectors(e,t);const r=xn.dot(xn),o=xn.dot(is),c=xn.dot(Yl),l=is.dot(is),h=is.dot(Yl),u=r*l-o*o;if(u===0)return s.set(0,0,0),null;const d=1/u,f=(l*c-o*h)*d,p=(r*h-o*c)*d;return s.set(1-f-p,p,f)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,ns)===null?!1:ns.x>=0&&ns.y>=0&&ns.x+ns.y<=1}static getInterpolation(e,t,i,n,s,r,o,c){return this.getBarycoord(e,t,i,n,ns)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,ns.x),c.addScaledVector(r,ns.y),c.addScaledVector(o,ns.z),c)}static getInterpolatedAttribute(e,t,i,n,s,r){return Jl.setScalar(0),jl.setScalar(0),Ql.setScalar(0),Jl.fromBufferAttribute(e,t),jl.fromBufferAttribute(e,i),Ql.fromBufferAttribute(e,n),r.setScalar(0),r.addScaledVector(Jl,s.x),r.addScaledVector(jl,s.y),r.addScaledVector(Ql,s.z),r}static isFrontFacing(e,t,i,n){return xn.subVectors(i,t),is.subVectors(e,t),xn.cross(is).dot(n)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,n){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[n]),this}setFromAttributeAndIndices(e,t,i,n){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,n),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 xn.subVectors(this.c,this.b),is.subVectors(this.a,this.b),xn.cross(is).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return pn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return pn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,n,s){return pn.getInterpolation(e,this.a,this.b,this.c,t,i,n,s)}containsPoint(e){return pn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return pn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,n=this.b,s=this.c;let r,o;Na.subVectors(n,i),Oa.subVectors(s,i),Kl.subVectors(e,i);const c=Na.dot(Kl),l=Oa.dot(Kl);if(c<=0&&l<=0)return t.copy(i);$l.subVectors(e,n);const h=Na.dot($l),u=Oa.dot($l);if(h>=0&&u<=h)return t.copy(n);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return r=c/(c-h),t.copy(i).addScaledVector(Na,r);Zl.subVectors(e,s);const f=Na.dot(Zl),p=Oa.dot(Zl);if(p>=0&&f<=p)return t.copy(s);const v=f*l-c*p;if(v<=0&&l>=0&&p<=0)return o=l/(l-p),t.copy(i).addScaledVector(Oa,o);const m=h*p-f*u;if(m<=0&&u-h>=0&&f-p>=0)return mf.subVectors(s,n),o=(u-h)/(u-h+(f-p)),t.copy(n).addScaledVector(mf,o);const g=1/(m+v+d);return r=v*g,o=d*g,t.copy(i).addScaledVector(Na,r).addScaledVector(Oa,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class vn{constructor(e=new D(1/0,1/0,1/0),t=new D(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(yn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(yn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=yn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let r=0,o=s.count;r<o;r++)e.isMesh===!0?e.getVertexPosition(r,yn):yn.fromBufferAttribute(s,r),yn.applyMatrix4(e.matrixWorld),this.expandByPoint(yn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Go.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Go.copy(i.boundingBox)),Go.applyMatrix4(e.matrixWorld),this.union(Go)}const n=e.children;for(let s=0,r=n.length;s<r;s++)this.expandByObject(n[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,yn),yn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Rr),Vo.subVectors(this.max,Rr),Ua.subVectors(e.a,Rr),Fa.subVectors(e.b,Rr),ka.subVectors(e.c,Rr),Rs.subVectors(Fa,Ua),Ds.subVectors(ka,Fa),js.subVectors(Ua,ka);let t=[0,-Rs.z,Rs.y,0,-Ds.z,Ds.y,0,-js.z,js.y,Rs.z,0,-Rs.x,Ds.z,0,-Ds.x,js.z,0,-js.x,-Rs.y,Rs.x,0,-Ds.y,Ds.x,0,-js.y,js.x,0];return!eh(t,Ua,Fa,ka,Vo)||(t=[1,0,0,0,1,0,0,0,1],!eh(t,Ua,Fa,ka,Vo))?!1:(Wo.crossVectors(Rs,Ds),t=[Wo.x,Wo.y,Wo.z],eh(t,Ua,Fa,ka,Vo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,yn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(yn).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:(ss[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ss[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ss[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ss[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ss[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ss[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ss[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ss[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ss),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 ss=[new D,new D,new D,new D,new D,new D,new D,new D],yn=new D,Go=new vn,Ua=new D,Fa=new D,ka=new D,Rs=new D,Ds=new D,js=new D,Rr=new D,Vo=new D,Wo=new D,Qs=new D;function eh(a,e,t,i,n){for(let s=0,r=a.length-3;s<=r;s+=3){Qs.fromArray(a,s);const o=n.x*Math.abs(Qs.x)+n.y*Math.abs(Qs.y)+n.z*Math.abs(Qs.z),c=e.dot(Qs),l=t.dot(Qs),h=i.dot(Qs);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const ds=Gv();function Gv(){const a=new ArrayBuffer(4),e=new Float32Array(a),t=new Uint32Array(a),i=new Uint32Array(512),n=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(i[c]=0,i[c|256]=32768,n[c]=24,n[c|256]=24):l<-14?(i[c]=1024>>-l-14,i[c|256]=1024>>-l-14|32768,n[c]=-l-1,n[c|256]=-l-1):l<=15?(i[c]=l+15<<10,i[c|256]=l+15<<10|32768,n[c]=13,n[c|256]=13):l<128?(i[c]=31744,i[c|256]=64512,n[c]=24,n[c|256]=24):(i[c]=31744,i[c|256]=64512,n[c]=13,n[c|256]=13)}const s=new Uint32Array(2048),r=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,s[c]=l|h}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)r[c]=c<<23;r[31]=1199570944,r[32]=2147483648;for(let c=33;c<63;++c)r[c]=2147483648+(c-32<<23);r[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:n,mantissaTable:s,exponentTable:r,offsetTable:o}}function Vv(a){Math.abs(a)>65504&&Te("DataUtils.toHalfFloat(): Value out of range."),a=je(a,-65504,65504),ds.floatView[0]=a;const e=ds.uint32View[0],t=e>>23&511;return ds.baseTable[t]+((e&8388607)>>ds.shiftTable[t])}function Wv(a){const e=a>>10;return ds.uint32View[0]=ds.mantissaTable[ds.offsetTable[e]+(a&1023)]+ds.exponentTable[e],ds.floatView[0]}class Dn{static toHalfFloat(e){return Vv(e)}static fromHalfFloat(e){return Wv(e)}}const ti=new D,Xo=new xe;let Xv=0;class et extends ba{constructor(e,t,i=!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:Xv++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=Vu,this.updateRanges=[],this.gpuType=Di,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let n=0,s=this.itemSize;n<s;n++)this.array[e+n]=t.array[i+n];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)Xo.fromBufferAttribute(this,t),Xo.applyMatrix3(e),this.setXY(t,Xo.x,Xo.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)ti.fromBufferAttribute(this,t),ti.applyMatrix3(e),this.setXYZ(t,ti.x,ti.y,ti.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)ti.fromBufferAttribute(this,t),ti.applyMatrix4(e),this.setXYZ(t,ti.x,ti.y,ti.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)ti.fromBufferAttribute(this,t),ti.applyNormalMatrix(e),this.setXYZ(t,ti.x,ti.y,ti.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)ti.fromBufferAttribute(this,t),ti.transformDirection(e),this.setXYZ(t,ti.x,ti.y,ti.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=An(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=vt(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=An(t,this.array)),t}setX(e,t){return this.normalized&&(t=vt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=An(t,this.array)),t}setY(e,t){return this.normalized&&(t=vt(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=An(t,this.array)),t}setZ(e,t){return this.normalized&&(t=vt(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=An(t,this.array)),t}setW(e,t){return this.normalized&&(t=vt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=vt(t,this.array),i=vt(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,n){return e*=this.itemSize,this.normalized&&(t=vt(t,this.array),i=vt(i,this.array),n=vt(n,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this}setXYZW(e,t,i,n,s){return e*=this.itemSize,this.normalized&&(t=vt(t,this.array),i=vt(i,this.array),n=vt(n,this.array),s=vt(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){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!==Vu&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class fg extends et{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class Vd extends et{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class xt extends et{constructor(e,t,i){super(new Float32Array(e),t,i)}}const qv=new vn,Dr=new D,th=new D;class ys{constructor(e=new D,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 i=this.center;t!==void 0?i.copy(t):qv.setFromPoints(e).getCenter(i);let n=0;for(let s=0,r=e.length;s<r;s++)n=Math.max(n,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(n),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 i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Dr.subVectors(e,this.center);const t=Dr.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),n=(i-this.radius)*.5;this.center.addScaledVector(Dr,n/i),this.radius+=n}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):(th.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Dr.copy(e.center).add(th)),this.expandByPoint(Dr.copy(e.center).sub(th))),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 Yv=0;const on=new Ze,ih=new Pt,za=new D,Yi=new vn,Cr=new vn,di=new D;class ut extends ba{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Yv++}),this.uuid=Rn(),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(lv(e)?Vd:fg)(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,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const s=new Xe().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return on.makeRotationFromQuaternion(e),this.applyMatrix4(on),this}rotateX(e){return on.makeRotationX(e),this.applyMatrix4(on),this}rotateY(e){return on.makeRotationY(e),this.applyMatrix4(on),this}rotateZ(e){return on.makeRotationZ(e),this.applyMatrix4(on),this}translate(e,t,i){return on.makeTranslation(e,t,i),this.applyMatrix4(on),this}scale(e,t,i){return on.makeScale(e,t,i),this.applyMatrix4(on),this}lookAt(e){return ih.lookAt(e),ih.updateMatrix(),this.applyMatrix4(ih.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(za).negate(),this.translate(za.x,za.y,za.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let n=0,s=e.length;n<s;n++){const r=e[n];i.push(r.x,r.y,r.z||0)}this.setAttribute("position",new xt(i,3))}else{const i=Math.min(e.length,t.count);for(let n=0;n<i;n++){const s=e[n];t.setXYZ(n,s.x,s.y,s.z||0)}e.length>t.count&&Te("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 vn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Be("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,n=t.length;i<n;i++){const s=t[i];Yi.setFromBufferAttribute(s),this.morphTargetsRelative?(di.addVectors(this.boundingBox.min,Yi.min),this.boundingBox.expandByPoint(di),di.addVectors(this.boundingBox.max,Yi.max),this.boundingBox.expandByPoint(di)):(this.boundingBox.expandByPoint(Yi.min),this.boundingBox.expandByPoint(Yi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Be('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 ys);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Be("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new D,1/0);return}if(e){const i=this.boundingSphere.center;if(Yi.setFromBufferAttribute(e),t)for(let s=0,r=t.length;s<r;s++){const o=t[s];Cr.setFromBufferAttribute(o),this.morphTargetsRelative?(di.addVectors(Yi.min,Cr.min),Yi.expandByPoint(di),di.addVectors(Yi.max,Cr.max),Yi.expandByPoint(di)):(Yi.expandByPoint(Cr.min),Yi.expandByPoint(Cr.max))}Yi.getCenter(i);let n=0;for(let s=0,r=e.count;s<r;s++)di.fromBufferAttribute(e,s),n=Math.max(n,i.distanceToSquared(di));if(t)for(let s=0,r=t.length;s<r;s++){const o=t[s],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)di.fromBufferAttribute(o,l),c&&(za.fromBufferAttribute(e,l),di.add(za)),n=Math.max(n,i.distanceToSquared(di))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&Be('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){Be("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,n=t.normal,s=t.uv;let r=this.getAttribute("tangent");(r===void 0||r.count!==i.count)&&(r=new et(new Float32Array(4*i.count),4),this.setAttribute("tangent",r));const o=[],c=[];for(let x=0;x<i.count;x++)o[x]=new D,c[x]=new D;const l=new D,h=new D,u=new D,d=new xe,f=new xe,p=new xe,v=new D,m=new D;function g(x,A,I){l.fromBufferAttribute(i,x),h.fromBufferAttribute(i,A),u.fromBufferAttribute(i,I),d.fromBufferAttribute(s,x),f.fromBufferAttribute(s,A),p.fromBufferAttribute(s,I),h.sub(l),u.sub(l),f.sub(d),p.sub(d);const C=1/(f.x*p.y-p.x*f.y);isFinite(C)&&(v.copy(h).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(C),m.copy(u).multiplyScalar(f.x).addScaledVector(h,-p.x).multiplyScalar(C),o[x].add(v),o[A].add(v),o[I].add(v),c[x].add(m),c[A].add(m),c[I].add(m))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let x=0,A=_.length;x<A;++x){const I=_[x],C=I.start,P=I.count;for(let X=C,z=C+P;X<z;X+=3)g(e.getX(X+0),e.getX(X+1),e.getX(X+2))}const w=new D,M=new D,S=new D,b=new D;function T(x){S.fromBufferAttribute(n,x),b.copy(S);const A=o[x];w.copy(A),w.sub(S.multiplyScalar(S.dot(A))).normalize(),M.crossVectors(b,A);const C=M.dot(c[x])<0?-1:1;r.setXYZW(x,w.x,w.y,w.z,C)}for(let x=0,A=_.length;x<A;++x){const I=_[x],C=I.start,P=I.count;for(let X=C,z=C+P;X<z;X+=3)T(e.getX(X+0)),T(e.getX(X+1)),T(e.getX(X+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0||i.count!==t.count)i=new et(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let d=0,f=i.count;d<f;d++)i.setXYZ(d,0,0,0);const n=new D,s=new D,r=new D,o=new D,c=new D,l=new D,h=new D,u=new D;if(e)for(let d=0,f=e.count;d<f;d+=3){const p=e.getX(d+0),v=e.getX(d+1),m=e.getX(d+2);n.fromBufferAttribute(t,p),s.fromBufferAttribute(t,v),r.fromBufferAttribute(t,m),h.subVectors(r,s),u.subVectors(n,s),h.cross(u),o.fromBufferAttribute(i,p),c.fromBufferAttribute(i,v),l.fromBufferAttribute(i,m),o.add(h),c.add(h),l.add(h),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(v,c.x,c.y,c.z),i.setXYZ(m,l.x,l.y,l.z)}else for(let d=0,f=t.count;d<f;d+=3)n.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),r.fromBufferAttribute(t,d+2),h.subVectors(r,s),u.subVectors(n,s),h.cross(u),i.setXYZ(d+0,h.x,h.y,h.z),i.setXYZ(d+1,h.x,h.y,h.z),i.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)di.fromBufferAttribute(e,t),di.normalize(),e.setXYZ(t,di.x,di.y,di.z)}toNonIndexed(){function e(o,c){const l=o.array,h=o.itemSize,u=o.normalized,d=new l.constructor(c.length*h);let f=0,p=0;for(let v=0,m=c.length;v<m;v++){o.isInterleavedBufferAttribute?f=c[v]*o.data.stride+o.offset:f=c[v]*h;for(let g=0;g<h;g++)d[p++]=l[f++]}return new et(d,h,u)}if(this.index===null)return Te("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new ut,i=this.index.array,n=this.attributes;for(const o in n){const c=n[o],l=e(c,i);t.setAttribute(o,l)}const s=this.morphAttributes;for(const o in s){const c=[],l=s[o];for(let h=0,u=l.length;h<u;h++){const d=l[h],f=e(d,i);c.push(f)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const r=this.groups;for(let o=0,c=r.length;o<c;o++){const l=r[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const c in i){const l=i[c];e.data.attributes[c]=l.toJSON(e.data)}const n={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){const f=l[u];h.push(f.toJSON(e.data))}h.length>0&&(n[c]=h,s=!0)}s&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(e.data.groups=JSON.parse(JSON.stringify(r)));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 i=e.index;i!==null&&this.setIndex(i.clone());const n=e.attributes;for(const l in n){const h=n[l];this.setAttribute(l,h.clone(t))}const s=e.morphAttributes;for(const l in s){const h=[],u=s[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;const r=e.groups;for(let l=0,h=r.length;l<h;l++){const u=r[l];this.addGroup(u.start,u.count,u.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Kv{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Vu,this.updateRanges=[],this.version=0,this.uuid=Rn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let n=0,s=this.stride;n<s;n++)this.array[e+n]=t.array[i+n];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=Rn()),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]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Rn()),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 Ii=new D;class nl{constructor(e,t,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Ii.fromBufferAttribute(this,t),Ii.applyMatrix4(e),this.setXYZ(t,Ii.x,Ii.y,Ii.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ii.fromBufferAttribute(this,t),Ii.applyNormalMatrix(e),this.setXYZ(t,Ii.x,Ii.y,Ii.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ii.fromBufferAttribute(this,t),Ii.transformDirection(e),this.setXYZ(t,Ii.x,Ii.y,Ii.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=An(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=vt(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=vt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=vt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=vt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=vt(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=An(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=An(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=An(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=An(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=vt(t,this.array),i=vt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=vt(t,this.array),i=vt(i,this.array),n=vt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this}setXYZW(e,t,i,n,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=vt(t,this.array),i=vt(i,this.array),n=vt(n,this.array),s=vt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this.data.array[e+3]=s,this}clone(e){if(e===void 0){il("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[n+s])}return new et(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 nl(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){il("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[n+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let $v=0;class _s extends ba{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:$v++}),this.uuid=Rn(),this.name="",this.type="Material",this.blending=Ws,this.side=qs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=nu,this.blendDst=vo,this.blendEquation=ra,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new se(0,0,0),this.blendAlpha=0,this.depthFunc=gr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=tf,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Da,this.stencilZFail=Da,this.stencilZPass=Da,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 i=e[t];if(i===void 0){Te(`Material: parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){Te(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}n&&n.isColor?n.set(i):n&&n.isVector2&&i&&i.isVector2||n&&n.isEuler&&i&&i.isEuler||n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Ws&&(i.blending=this.blending),this.side!==qs&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==nu&&(i.blendSrc=this.blendSrc),this.blendDst!==vo&&(i.blendDst=this.blendDst),this.blendEquation!==ra&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==gr&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==tf&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Da&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Da&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Da&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function n(s){const r=[];for(const o in s){const c=s[o];delete c.metadata,r.push(c)}return r}if(t){const s=n(e.textures),r=n(e.images);s.length>0&&(i.textures=s),r.length>0&&(i.images=r)}return i}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 se().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 i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new xe().fromArray(i)}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 xe().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 i=null;if(t!==null){const n=t.length;i=new Array(n);for(let s=0;s!==n;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.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 Hc extends _s{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new se(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 Ha;const Ir=new D,Ba=new D,Ga=new D,Va=new xe,Pr=new xe,pg=new Ze,qo=new D,Lr=new D,Yo=new D,gf=new xe,nh=new xe,vf=new xe;class Nr extends Pt{constructor(e=new Hc){if(super(),this.isSprite=!0,this.type="Sprite",Ha===void 0){Ha=new ut;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new Kv(t,5);Ha.setIndex([0,1,2,0,2,3]),Ha.setAttribute("position",new nl(i,3,0,!1)),Ha.setAttribute("uv",new nl(i,2,3,!1))}this.geometry=Ha,this.material=e,this.center=new xe(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Be('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ba.setFromMatrixScale(this.matrixWorld),pg.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ga.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ba.multiplyScalar(-Ga.z);const i=this.material.rotation;let n,s;i!==0&&(s=Math.cos(i),n=Math.sin(i));const r=this.center;Ko(qo.set(-.5,-.5,0),Ga,r,Ba,n,s),Ko(Lr.set(.5,-.5,0),Ga,r,Ba,n,s),Ko(Yo.set(.5,.5,0),Ga,r,Ba,n,s),gf.set(0,0),nh.set(1,0),vf.set(1,1);let o=e.ray.intersectTriangle(qo,Lr,Yo,!1,Ir);if(o===null&&(Ko(Lr.set(-.5,.5,0),Ga,r,Ba,n,s),nh.set(0,1),o=e.ray.intersectTriangle(qo,Yo,Lr,!1,Ir),o===null))return;const c=e.ray.origin.distanceTo(Ir);c<e.near||c>e.far||t.push({distance:c,point:Ir.clone(),uv:pn.getInterpolation(Ir,qo,Lr,Yo,gf,nh,vf,new xe),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 Ko(a,e,t,i,n,s){Va.subVectors(a,t).addScalar(.5).multiply(i),n!==void 0?(Pr.x=s*Va.x-n*Va.y,Pr.y=n*Va.x+s*Va.y):Pr.copy(Va),a.copy(e),a.x+=Pr.x,a.y+=Pr.y,a.applyMatrix4(pg)}const as=new D,sh=new D,$o=new D,Cs=new D,ah=new D,Zo=new D,rh=new D;class Ao{constructor(e=new D,t=new D(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,as)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=as.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(as.copy(this.origin).addScaledVector(this.direction,t),as.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){sh.copy(e).add(t).multiplyScalar(.5),$o.copy(t).sub(e).normalize(),Cs.copy(this.origin).sub(sh);const s=e.distanceTo(t)*.5,r=-this.direction.dot($o),o=Cs.dot(this.direction),c=-Cs.dot($o),l=Cs.lengthSq(),h=Math.abs(1-r*r);let u,d,f,p;if(h>0)if(u=r*c-o,d=r*o-c,p=s*h,u>=0)if(d>=-p)if(d<=p){const v=1/h;u*=v,d*=v,f=u*(u+r*d+2*o)+d*(r*u+d+2*c)+l}else d=s,u=Math.max(0,-(r*d+o)),f=-u*u+d*(d+2*c)+l;else d=-s,u=Math.max(0,-(r*d+o)),f=-u*u+d*(d+2*c)+l;else d<=-p?(u=Math.max(0,-(-r*s+o)),d=u>0?-s:Math.min(Math.max(-s,-c),s),f=-u*u+d*(d+2*c)+l):d<=p?(u=0,d=Math.min(Math.max(-s,-c),s),f=d*(d+2*c)+l):(u=Math.max(0,-(r*s+o)),d=u>0?s:Math.min(Math.max(-s,-c),s),f=-u*u+d*(d+2*c)+l);else d=r>0?-s:s,u=Math.max(0,-(r*d+o)),f=-u*u+d*(d+2*c)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,u),n&&n.copy(sh).addScaledVector($o,d),f}intersectSphere(e,t){as.subVectors(e.center,this.origin);const i=as.dot(this.direction),n=as.dot(as)-i*i,s=e.radius*e.radius;if(n>s)return null;const r=Math.sqrt(s-n),o=i-r,c=i+r;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,n,s,r,o,c;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(i=(e.min.x-d.x)*l,n=(e.max.x-d.x)*l):(i=(e.max.x-d.x)*l,n=(e.min.x-d.x)*l),h>=0?(s=(e.min.y-d.y)*h,r=(e.max.y-d.y)*h):(s=(e.max.y-d.y)*h,r=(e.min.y-d.y)*h),i>r||s>n||((s>i||isNaN(i))&&(i=s),(r<n||isNaN(n))&&(n=r),u>=0?(o=(e.min.z-d.z)*u,c=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,c=(e.min.z-d.z)*u),i>c||o>n)||((o>i||i!==i)&&(i=o),(c<n||n!==n)&&(n=c),n<0)?null:this.at(i>=0?i:n,t)}intersectsBox(e){return this.intersectBox(e,as)!==null}intersectTriangle(e,t,i,n,s){ah.subVectors(t,e),Zo.subVectors(i,e),rh.crossVectors(ah,Zo);let r=this.direction.dot(rh),o;if(r>0){if(n)return null;o=1}else if(r<0)o=-1,r=-r;else return null;Cs.subVectors(this.origin,e);const c=o*this.direction.dot(Zo.crossVectors(Cs,Zo));if(c<0)return null;const l=o*this.direction.dot(ah.cross(Cs));if(l<0||c+l>r)return null;const h=-o*Cs.dot(rh);return h<0?null:this.at(h/r,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class mn extends _s{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new se(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 Ms,this.combine=Cd,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 Mf=new Ze,ea=new Ao,Jo=new ys,xf=new D,jo=new D,Qo=new D,ec=new D,oh=new D,tc=new D,yf=new D,ic=new D;class De extends Pt{constructor(e=new ut,t=new mn){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,i=Object.keys(t);if(i.length>0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=n.length;s<r;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const i=this.geometry,n=i.attributes.position,s=i.morphAttributes.position,r=i.morphTargetsRelative;t.fromBufferAttribute(n,e);const o=this.morphTargetInfluences;if(s&&o){tc.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const h=o[c],u=s[c];h!==0&&(oh.fromBufferAttribute(u,e),r?tc.addScaledVector(oh,h):tc.addScaledVector(oh.sub(t),h))}t.add(tc)}return t}raycast(e,t){const i=this.geometry,n=this.material,s=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Jo.copy(i.boundingSphere),Jo.applyMatrix4(s),ea.copy(e.ray).recast(e.near),!(Jo.containsPoint(ea.origin)===!1&&(ea.intersectSphere(Jo,xf)===null||ea.origin.distanceToSquared(xf)>(e.far-e.near)**2))&&(Mf.copy(s).invert(),ea.copy(e.ray).applyMatrix4(Mf),!(i.boundingBox!==null&&ea.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,ea)))}_computeIntersections(e,t,i){let n;const s=this.geometry,r=this.material,o=s.index,c=s.attributes.position,l=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,d=s.groups,f=s.drawRange;if(o!==null)if(Array.isArray(r))for(let p=0,v=d.length;p<v;p++){const m=d[p],g=r[m.materialIndex],_=Math.max(m.start,f.start),w=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let M=_,S=w;M<S;M+=3){const b=o.getX(M),T=o.getX(M+1),x=o.getX(M+2);n=nc(this,g,e,i,l,h,u,b,T,x),n&&(n.faceIndex=Math.floor(M/3),n.face.materialIndex=m.materialIndex,t.push(n))}}else{const p=Math.max(0,f.start),v=Math.min(o.count,f.start+f.count);for(let m=p,g=v;m<g;m+=3){const _=o.getX(m),w=o.getX(m+1),M=o.getX(m+2);n=nc(this,r,e,i,l,h,u,_,w,M),n&&(n.faceIndex=Math.floor(m/3),t.push(n))}}else if(c!==void 0)if(Array.isArray(r))for(let p=0,v=d.length;p<v;p++){const m=d[p],g=r[m.materialIndex],_=Math.max(m.start,f.start),w=Math.min(c.count,Math.min(m.start+m.count,f.start+f.count));for(let M=_,S=w;M<S;M+=3){const b=M,T=M+1,x=M+2;n=nc(this,g,e,i,l,h,u,b,T,x),n&&(n.faceIndex=Math.floor(M/3),n.face.materialIndex=m.materialIndex,t.push(n))}}else{const p=Math.max(0,f.start),v=Math.min(c.count,f.start+f.count);for(let m=p,g=v;m<g;m+=3){const _=m,w=m+1,M=m+2;n=nc(this,r,e,i,l,h,u,_,w,M),n&&(n.faceIndex=Math.floor(m/3),t.push(n))}}}}function Zv(a,e,t,i,n,s,r,o){let c;if(e.side===Ot?c=i.intersectTriangle(r,s,n,!0,o):c=i.intersectTriangle(n,s,r,e.side===qs,o),c===null)return null;ic.copy(o),ic.applyMatrix4(a.matrixWorld);const l=t.ray.origin.distanceTo(ic);return l<t.near||l>t.far?null:{distance:l,point:ic.clone(),object:a}}function nc(a,e,t,i,n,s,r,o,c,l){a.getVertexPosition(o,jo),a.getVertexPosition(c,Qo),a.getVertexPosition(l,ec);const h=Zv(a,e,t,i,jo,Qo,ec,yf);if(h){const u=new D;pn.getBarycoord(yf,jo,Qo,ec,u),n&&(h.uv=pn.getInterpolatedAttribute(n,o,c,l,u,new xe)),s&&(h.uv1=pn.getInterpolatedAttribute(s,o,c,l,u,new xe)),r&&(h.normal=pn.getInterpolatedAttribute(r,o,c,l,u,new D),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new D,materialIndex:0};pn.getNormal(jo,Qo,ec,d.normal),h.face=d,h.barycoord=u}return h}const Or=new it,_f=new it,Sf=new it,Jv=new it,wf=new Ze,sc=new D,ch=new ys,bf=new Ze,lh=new Ao;class yE extends De{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Z0,this.bindMatrix=new Ze,this.bindMatrixInverse=new Ze,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new vn),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,sc),this.boundingBox.expandByPoint(sc)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new ys),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,sc),this.boundingSphere.expandByPoint(sc)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const i=this.material,n=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ch.copy(this.boundingSphere),ch.applyMatrix4(n),e.ray.intersectsSphere(ch)!==!1&&(bf.copy(n).invert(),lh.copy(e.ray).applyMatrix4(bf),!(this.boundingBox!==null&&lh.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,lh)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new it,t=this.geometry.attributes.skinWeight;for(let i=0,n=t.count;i<n;i++){e.fromBufferAttribute(t,i);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Z0?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===j2?this.bindMatrixInverse.copy(this.bindMatrix).invert():Te("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,n=this.geometry;_f.fromBufferAttribute(n.attributes.skinIndex,e),Sf.fromBufferAttribute(n.attributes.skinWeight,e),t.isVector4?(Or.copy(t),t.set(0,0,0,0)):(Or.set(...t,1),t.set(0,0,0)),Or.applyMatrix4(this.bindMatrix);for(let s=0;s<4;s++){const r=Sf.getComponent(s);if(r!==0){const o=_f.getComponent(s);wf.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(Jv.copy(Or).applyMatrix4(wf),r)}}return t.isVector4&&(t.w=Or.w),t.applyMatrix4(this.bindMatrixInverse)}}class jv extends Pt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class $s extends xi{constructor(e=null,t=1,i=1,n,s,r,o,c,l=wt,h=wt,u,d){super(null,r,o,c,l,h,n,s,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Ef=new Ze,Qv=new Ze;class mg{constructor(e=[],t=[]){this.uuid=Rn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Te("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,n=this.bones.length;i<n;i++)this.boneInverses.push(new Ze)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new Ze;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let s=0,r=e.length;s<r;s++){const o=e[s]?e[s].matrixWorld:Qv;Ef.multiplyMatrices(o,t[s]),Ef.toArray(i,s*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new mg(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new $s(t,e,e,_i,Di);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,n=e.bones.length;i<n;i++){const s=e.bones[i];let r=t[s];r===void 0&&(Te("Skeleton: No bone found with UUID:",s),r=new jv),this.bones.push(r),this.boneInverses.push(new Ze().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let n=0,s=t.length;n<s;n++){const r=t[n];e.bones.push(r.uuid);const o=i[n];e.boneInverses.push(o.toArray())}return e}}class Af extends et{constructor(e,t,i,n=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Wa=new Ze,Tf=new Ze,ac=[],Rf=new vn,eM=new Ze,Ur=new De,Fr=new ys;class _E extends De{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Af(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<i;n++)this.setMatrixAt(n,eM)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new vn),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Wa),Rf.copy(e.boundingBox).applyMatrix4(Wa),this.boundingBox.union(Rf)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new ys),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Wa),Fr.copy(e.boundingSphere).applyMatrix4(Wa),this.boundingSphere.union(Fr)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const i=t.morphTargetInfluences,n=this.morphTexture.source.data.data,s=i.length+1,r=e*s+1;for(let o=0;o<i.length;o++)i[o]=n[r+o]}raycast(e,t){const i=this.matrixWorld,n=this.count;if(Ur.geometry=this.geometry,Ur.material=this.material,Ur.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Fr.copy(this.boundingSphere),Fr.applyMatrix4(i),e.ray.intersectsSphere(Fr)!==!1))for(let s=0;s<n;s++){this.getMatrixAt(s,Wa),Tf.multiplyMatrices(i,Wa),Ur.matrixWorld=Tf,Ur.raycast(e,ac);for(let r=0,o=ac.length;r<o;r++){const c=ac[r];c.instanceId=s,c.object=this,t.push(c)}ac.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new Af(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){const i=t.morphTargetInfluences,n=i.length+1;this.morphTexture===null&&(this.morphTexture=new $s(new Float32Array(n*this.count),n,this.count,yl,Di));const s=this.morphTexture.source.data.data;let r=0;for(let l=0;l<i.length;l++)r+=i[l];const o=this.geometry.morphTargetsRelative?1:1-r,c=n*e;return s[c]=o,s.set(i,c+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const hh=new D,tM=new D,iM=new Xe;class sa{constructor(e=new D(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,n){return this.normal.set(e,t,i),this.constant=n,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const n=hh.subVectors(i,t).cross(tM.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(n,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,i=!0){const n=e.delta(hh),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/s;return i===!0&&(r<0||r>1)?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||iM.getNormalMatrix(e),n=this.coplanarPoint(hh).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const ta=new ys,nM=new xe(.5,.5),rc=new D;class Wd{constructor(e=new sa,t=new sa,i=new sa,n=new sa,s=new sa,r=new sa){this.planes=[e,t,i,n,s,r]}set(e,t,i,n,s,r){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(n),o[4].copy(s),o[5].copy(r),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Kn,i=!1){const n=this.planes,s=e.elements,r=s[0],o=s[1],c=s[2],l=s[3],h=s[4],u=s[5],d=s[6],f=s[7],p=s[8],v=s[9],m=s[10],g=s[11],_=s[12],w=s[13],M=s[14],S=s[15];if(n[0].setComponents(l-r,f-h,g-p,S-_).normalize(),n[1].setComponents(l+r,f+h,g+p,S+_).normalize(),n[2].setComponents(l+o,f+u,g+v,S+w).normalize(),n[3].setComponents(l-o,f-u,g-v,S-w).normalize(),i)n[4].setComponents(c,d,m,M).normalize(),n[5].setComponents(l-c,f-d,g-m,S-M).normalize();else if(n[4].setComponents(l-c,f-d,g-m,S-M).normalize(),t===Kn)n[5].setComponents(l+c,f+d,g+m,S+M).normalize();else if(t===_o)n[5].setComponents(c,d,m,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),ta.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),ta.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ta)}intersectsSprite(e){ta.center.set(0,0,0);const t=nM.distanceTo(e.center);return ta.radius=.7071067811865476+t,ta.applyMatrix4(e.matrixWorld),this.intersectsSphere(ta)}intersectsSphere(e){const t=this.planes,i=e.center,n=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<n)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const n=t[i];if(rc.x=n.normal.x>0?e.max.x:e.min.x,rc.y=n.normal.y>0?e.max.y:e.min.y,rc.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(rc)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class sM extends _s{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new se(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const sl=new D,al=new D,Df=new Ze,kr=new Ao,oc=new ys,uh=new D,Cf=new D;class gg extends Pt{constructor(e=new ut,t=new sM){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let n=1,s=t.count;n<s;n++)sl.fromBufferAttribute(t,n-1),al.fromBufferAttribute(t,n),i[n]=i[n-1],i[n]+=sl.distanceTo(al);e.setAttribute("lineDistance",new xt(i,1))}else Te("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,s=e.params.Line.threshold,r=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),oc.copy(i.boundingSphere),oc.applyMatrix4(n),oc.radius+=s,e.ray.intersectsSphere(oc)===!1)return;Df.copy(n).invert(),kr.copy(e.ray).applyMatrix4(Df);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=i.index,d=i.attributes.position;if(h!==null){const f=Math.max(0,r.start),p=Math.min(h.count,r.start+r.count);for(let v=f,m=p-1;v<m;v+=l){const g=h.getX(v),_=h.getX(v+1),w=cc(this,e,kr,c,g,_,v);w&&t.push(w)}if(this.isLineLoop){const v=h.getX(p-1),m=h.getX(f),g=cc(this,e,kr,c,v,m,p-1);g&&t.push(g)}}else{const f=Math.max(0,r.start),p=Math.min(d.count,r.start+r.count);for(let v=f,m=p-1;v<m;v+=l){const g=cc(this,e,kr,c,v,v+1,v);g&&t.push(g)}if(this.isLineLoop){const v=cc(this,e,kr,c,p-1,f,p-1);v&&t.push(v)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=n.length;s<r;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function cc(a,e,t,i,n,s,r){const o=a.geometry.attributes.position;if(sl.fromBufferAttribute(o,n),al.fromBufferAttribute(o,s),t.distanceSqToSegment(sl,al,uh,Cf)>i)return;uh.applyMatrix4(a.matrixWorld);const l=e.ray.origin.distanceTo(uh);if(!(l<e.near||l>e.far))return{distance:l,point:Cf.clone().applyMatrix4(a.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:a}}const If=new D,Pf=new D;class SE extends gg{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let n=0,s=t.count;n<s;n+=2)If.fromBufferAttribute(t,n),Pf.fromBufferAttribute(t,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+If.distanceTo(Pf);e.setAttribute("lineDistance",new xt(i,1))}else Te("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class wE extends gg{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class vg extends _s{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new se(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 Lf=new Ze,Wu=new Ao,lc=new ys,hc=new D;class us extends Pt{constructor(e=new ut,t=new vg){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 i=this.geometry,n=this.matrixWorld,s=e.params.Points.threshold,r=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),lc.copy(i.boundingSphere),lc.applyMatrix4(n),lc.radius+=s,e.ray.intersectsSphere(lc)===!1)return;Lf.copy(n).invert(),Wu.copy(e.ray).applyMatrix4(Lf);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=i.index,u=i.attributes.position;if(l!==null){const d=Math.max(0,r.start),f=Math.min(l.count,r.start+r.count);for(let p=d,v=f;p<v;p++){const m=l.getX(p);hc.fromBufferAttribute(u,m),Nf(hc,m,c,n,e,t,this)}}else{const d=Math.max(0,r.start),f=Math.min(u.count,r.start+r.count);for(let p=d,v=f;p<v;p++)hc.fromBufferAttribute(u,p),Nf(hc,p,c,n,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=n.length;s<r;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function Nf(a,e,t,i,n,s,r){const o=Wu.distanceSqToPoint(a);if(o<t){const c=new D;Wu.closestPointToPoint(a,c),c.applyMatrix4(i);const l=n.ray.origin.distanceTo(c);if(l<n.near||l>n.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:r})}}class Mg extends xi{constructor(e=[],t=ya,i,n,s,r,o,c,l,h){super(e,t,i,n,s,r,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Ss extends xi{constructor(e,t,i,n,s,r,o,c,l){super(e,t,i,n,s,r,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Ys extends xi{constructor(e,t,i=gn,n,s,r,o=wt,c=wt,l,h=vs,u=1){if(h!==vs&&h!==fa)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:u};super(d,n,s,r,o,c,h,i,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Hd(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 aM extends Ys{constructor(e,t=gn,i=ya,n,s,r=wt,o=wt,c,l=vs){const h={width:e,height:e,depth:1},u=[h,h,h,h,h,h];super(e,e,t,i,n,s,r,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class xg extends xi{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class sn extends ut{constructor(e=1,t=1,i=1,n=1,s=1,r=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:n,heightSegments:s,depthSegments:r};const o=this;n=Math.floor(n),s=Math.floor(s),r=Math.floor(r);const c=[],l=[],h=[],u=[];let d=0,f=0;p("z","y","x",-1,-1,i,t,e,r,s,0),p("z","y","x",1,-1,i,t,-e,r,s,1),p("x","z","y",1,1,e,i,t,n,r,2),p("x","z","y",1,-1,e,i,-t,n,r,3),p("x","y","z",1,-1,e,t,i,n,s,4),p("x","y","z",-1,-1,e,t,-i,n,s,5),this.setIndex(c),this.setAttribute("position",new xt(l,3)),this.setAttribute("normal",new xt(h,3)),this.setAttribute("uv",new xt(u,2));function p(v,m,g,_,w,M,S,b,T,x,A){const I=M/T,C=S/x,P=M/2,X=S/2,z=b/2,N=T+1,V=x+1;let k=0,K=0;const ee=new D;for(let J=0;J<V;J++){const ie=J*C-X;for(let oe=0;oe<N;oe++){const Ve=oe*I-P;ee[v]=Ve*_,ee[m]=ie*w,ee[g]=z,l.push(ee.x,ee.y,ee.z),ee[v]=0,ee[m]=0,ee[g]=b>0?1:-1,h.push(ee.x,ee.y,ee.z),u.push(oe/T),u.push(1-J/x),k+=1}}for(let J=0;J<x;J++)for(let ie=0;ie<T;ie++){const oe=d+ie+N*J,Ve=d+ie+N*(J+1),Qe=d+(ie+1)+N*(J+1),qe=d+(ie+1)+N*J;c.push(oe,Ve,qe),c.push(Ve,Qe,qe),K+=6}o.addGroup(f,K,A),f+=K,d+=k}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new sn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Xd extends ut{constructor(e=1,t=32,i=0,n=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:n},t=Math.max(3,t);const s=[],r=[],o=[],c=[],l=new D,h=new xe;r.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let u=0,d=3;u<=t;u++,d+=3){const f=i+u/t*n;l.x=e*Math.cos(f),l.y=e*Math.sin(f),r.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(r[d]/e+1)/2,h.y=(r[d+1]/e+1)/2,c.push(h.x,h.y)}for(let u=1;u<=t;u++)s.push(u,u+1,0);this.setIndex(s),this.setAttribute("position",new xt(r,3)),this.setAttribute("normal",new xt(o,3)),this.setAttribute("uv",new xt(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Xd(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class es extends ut{constructor(e=1,t=1,i=1,n=32,s=1,r=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:n,heightSegments:s,openEnded:r,thetaStart:o,thetaLength:c};const l=this;n=Math.floor(n),s=Math.floor(s);const h=[],u=[],d=[],f=[];let p=0;const v=[],m=i/2;let g=0;_(),r===!1&&(e>0&&w(!0),t>0&&w(!1)),this.setIndex(h),this.setAttribute("position",new xt(u,3)),this.setAttribute("normal",new xt(d,3)),this.setAttribute("uv",new xt(f,2));function _(){const M=new D,S=new D;let b=0;const T=(t-e)/i;for(let x=0;x<=s;x++){const A=[],I=x/s,C=I*(t-e)+e;for(let P=0;P<=n;P++){const X=P/n,z=X*c+o,N=Math.sin(z),V=Math.cos(z);S.x=C*N,S.y=-I*i+m,S.z=C*V,u.push(S.x,S.y,S.z),M.set(N,T,V).normalize(),d.push(M.x,M.y,M.z),f.push(X,1-I),A.push(p++)}v.push(A)}for(let x=0;x<n;x++)for(let A=0;A<s;A++){const I=v[A][x],C=v[A+1][x],P=v[A+1][x+1],X=v[A][x+1];(e>0||A!==0)&&(h.push(I,C,X),b+=3),(t>0||A!==s-1)&&(h.push(C,P,X),b+=3)}l.addGroup(g,b,0),g+=b}function w(M){const S=p,b=new xe,T=new D;let x=0;const A=M===!0?e:t,I=M===!0?1:-1;for(let P=1;P<=n;P++)u.push(0,m*I,0),d.push(0,I,0),f.push(.5,.5),p++;const C=p;for(let P=0;P<=n;P++){const z=P/n*c+o,N=Math.cos(z),V=Math.sin(z);T.x=A*V,T.y=m*I,T.z=A*N,u.push(T.x,T.y,T.z),d.push(0,I,0),b.x=N*.5+.5,b.y=V*.5*I+.5,f.push(b.x,b.y),p++}for(let P=0;P<n;P++){const X=S+P,z=C+P;M===!0?h.push(z,z+1,X):h.push(z+1,z,X),x+=3}l.addGroup(g,x,M===!0?1:2),g+=x}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new es(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class _r extends es{constructor(e=1,t=1,i=32,n=1,s=!1,r=0,o=Math.PI*2){super(0,e,t,i,n,s,r,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:n,openEnded:s,thetaStart:r,thetaLength:o}}static fromJSON(e){return new _r(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class _l extends ut{constructor(e=[new xe(0,-.5),new xe(.5,0),new xe(0,.5)],t=12,i=0,n=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:n},t=Math.floor(t),n=je(n,0,Math.PI*2);const s=[],r=[],o=[],c=[],l=[],h=1/t,u=new D,d=new xe,f=new D,p=new D,v=new D;let m=0,g=0;for(let _=0;_<=e.length-1;_++)switch(_){case 0:m=e[_+1].x-e[_].x,g=e[_+1].y-e[_].y,f.x=g*1,f.y=-m,f.z=g*0,v.copy(f),f.normalize(),c.push(f.x,f.y,f.z);break;case e.length-1:c.push(v.x,v.y,v.z);break;default:m=e[_+1].x-e[_].x,g=e[_+1].y-e[_].y,f.x=g*1,f.y=-m,f.z=g*0,p.copy(f),f.x+=v.x,f.y+=v.y,f.z+=v.z,f.normalize(),c.push(f.x,f.y,f.z),v.copy(p)}for(let _=0;_<=t;_++){const w=i+_*h*n,M=Math.sin(w),S=Math.cos(w);for(let b=0;b<=e.length-1;b++){u.x=e[b].x*M,u.y=e[b].y,u.z=e[b].x*S,r.push(u.x,u.y,u.z),d.x=_/t,d.y=b/(e.length-1),o.push(d.x,d.y);const T=c[3*b+0]*M,x=c[3*b+1],A=c[3*b+0]*S;l.push(T,x,A)}}for(let _=0;_<t;_++)for(let w=0;w<e.length-1;w++){const M=w+_*e.length,S=M,b=M+e.length,T=M+e.length+1,x=M+1;s.push(S,b,x),s.push(T,x,b)}this.setIndex(s),this.setAttribute("position",new xt(r,3)),this.setAttribute("uv",new xt(o,2)),this.setAttribute("normal",new xt(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new _l(e.points,e.segments,e.phiStart,e.phiLength)}}class ki extends ut{constructor(e=1,t=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:n};const s=e/2,r=t/2,o=Math.floor(i),c=Math.floor(n),l=o+1,h=c+1,u=e/o,d=t/c,f=[],p=[],v=[],m=[];for(let g=0;g<h;g++){const _=g*d-r;for(let w=0;w<l;w++){const M=w*u-s;p.push(M,-_,0),v.push(0,0,1),m.push(w/o),m.push(1-g/c)}}for(let g=0;g<c;g++)for(let _=0;_<o;_++){const w=_+l*g,M=_+l*(g+1),S=_+1+l*(g+1),b=_+1+l*g;f.push(w,M,b),f.push(M,S,b)}this.setIndex(f),this.setAttribute("position",new xt(p,3)),this.setAttribute("normal",new xt(v,3)),this.setAttribute("uv",new xt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ki(e.width,e.height,e.widthSegments,e.heightSegments)}}class Qt extends ut{constructor(e=1,t=32,i=16,n=0,s=Math.PI*2,r=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:n,phiLength:s,thetaStart:r,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const c=Math.min(r+o,Math.PI);let l=0;const h=[],u=new D,d=new D,f=[],p=[],v=[],m=[];for(let g=0;g<=i;g++){const _=[],w=g/i,M=r+w*o,S=e*Math.cos(M),b=Math.sqrt(e*e-S*S);let T=0;g===0&&r===0?T=.5/t:g===i&&c===Math.PI&&(T=-.5/t);for(let x=0;x<=t;x++){const A=x/t,I=n+A*s;u.x=-b*Math.cos(I),u.y=S,u.z=b*Math.sin(I),p.push(u.x,u.y,u.z),d.copy(u).normalize(),v.push(d.x,d.y,d.z),m.push(A+T,1-w),_.push(l++)}h.push(_)}for(let g=0;g<i;g++)for(let _=0;_<t;_++){const w=h[g][_+1],M=h[g][_],S=h[g+1][_],b=h[g+1][_+1];(g!==0||r>0)&&f.push(w,M,b),(g!==i-1||c<Math.PI)&&f.push(M,S,b)}this.setIndex(f),this.setAttribute("position",new xt(p,3)),this.setAttribute("normal",new xt(v,3)),this.setAttribute("uv",new xt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qt(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class qd extends ut{constructor(e=1,t=.4,i=12,n=48,s=Math.PI*2,r=0,o=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:n,arc:s,thetaStart:r,thetaLength:o},i=Math.floor(i),n=Math.floor(n);const c=[],l=[],h=[],u=[],d=new D,f=new D,p=new D;for(let v=0;v<=i;v++){const m=r+v/i*o;for(let g=0;g<=n;g++){const _=g/n*s;f.x=(e+t*Math.cos(m))*Math.cos(_),f.y=(e+t*Math.cos(m))*Math.sin(_),f.z=t*Math.sin(m),l.push(f.x,f.y,f.z),d.x=e*Math.cos(_),d.y=e*Math.sin(_),p.subVectors(f,d).normalize(),h.push(p.x,p.y,p.z),u.push(g/n),u.push(v/i)}}for(let v=1;v<=i;v++)for(let m=1;m<=n;m++){const g=(n+1)*v+m-1,_=(n+1)*(v-1)+m-1,w=(n+1)*(v-1)+m,M=(n+1)*v+m;c.push(g,_,M),c.push(_,w,M)}this.setIndex(c),this.setAttribute("position",new xt(l,3)),this.setAttribute("normal",new xt(h,3)),this.setAttribute("uv",new xt(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new qd(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}function xr(a){const e={};for(const t in a){e[t]={};for(const i in a[t]){const n=a[t][i];if(Of(n))n.isRenderTargetTexture?(Te("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=n.clone();else if(Array.isArray(n))if(Of(n[0])){const s=[];for(let r=0,o=n.length;r<o;r++)s[r]=n[r].clone();e[t][i]=s}else e[t][i]=n.slice();else e[t][i]=n}}return e}function Pi(a){const e={};for(let t=0;t<a.length;t++){const i=xr(a[t]);for(const n in i)e[n]=i[n]}return e}function Of(a){return a&&(a.isColor||a.isMatrix3||a.isMatrix4||a.isVector2||a.isVector3||a.isVector4||a.isTexture||a.isQuaternion)}function rM(a){const e=[];for(let t=0;t<a.length;t++)e.push(a[t].clone());return e}function yg(a){const e=a.getRenderTarget();return e===null?a.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:nt.workingColorSpace}const oM={clone:xr,merge:Pi};var cM=`void main() {
|
|
632
632
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
633
633
|
}`,lM=`void main() {
|
|
634
634
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
635
|
-
}`;class at extends _s{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=cM,this.fragmentShader=lM,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=xr(e.uniforms),this.uniformsGroups=rM(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 n in this.uniforms){const r=this.uniforms[n].value;r&&r.isTexture?t.uniforms[n]={type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[n]={type:"c",value:r.getHex()}:r&&r.isVector2?t.uniforms[n]={type:"v2",value:r.toArray()}:r&&r.isVector3?t.uniforms[n]={type:"v3",value:r.toArray()}:r&&r.isVector4?t.uniforms[n]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?t.uniforms[n]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?t.uniforms[n]={type:"m4",value:r.toArray()}:t.uniforms[n]={value:r}}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 i={};for(const n in this.extensions)this.extensions[n]===!0&&(i[n]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const i in e.uniforms){const n=e.uniforms[i];switch(this.uniforms[i]={},n.type){case"t":this.uniforms[i].value=t[n.value]||null;break;case"c":this.uniforms[i].value=new se().setHex(n.value);break;case"v2":this.uniforms[i].value=new xe().fromArray(n.value);break;case"v3":this.uniforms[i].value=new D().fromArray(n.value);break;case"v4":this.uniforms[i].value=new nt().fromArray(n.value);break;case"m3":this.uniforms[i].value=new Xe().fromArray(n.value);break;case"m4":this.uniforms[i].value=new Ze().fromArray(n.value);break;default:this.uniforms[i].value=n.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 i in e.extensions)this.extensions[i]=e.extensions[i];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class _g extends at{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class oa extends _s{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new se(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new se(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=jc,this.normalScale=new xe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ms,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class hM extends oa{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new xe(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return je(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new se(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new se(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new se(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Sr extends _s{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new se(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new se(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=jc,this.normalScale=new xe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ms,this.combine=Cd,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 uM extends _s{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=tv,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 dM extends _s{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function uc(a,e){return!a||a.constructor===e?a:typeof e.BYTES_PER_ELEMENT=="number"?new e(a):Array.prototype.slice.call(a)}function fM(a){function e(n,s){return a[n]-a[s]}const t=a.length,i=new Array(t);for(let n=0;n!==t;++n)i[n]=n;return i.sort(e),i}function Uf(a,e,t){const i=a.length,n=new a.constructor(i);for(let s=0,r=0;r!==i;++s){const o=t[s]*e;for(let c=0;c!==e;++c)n[r++]=a[o+c]}return n}function pM(a,e,t,i){let n=1,s=a[0];for(;s!==void 0&&s[i]===void 0;)s=a[n++];if(s===void 0)return;let r=s[i];if(r!==void 0)if(Array.isArray(r))do r=s[i],r!==void 0&&(e.push(s.time),t.push(...r)),s=a[n++];while(s!==void 0);else if(r.toArray!==void 0)do r=s[i],r!==void 0&&(e.push(s.time),r.toArray(t,t.length)),s=a[n++];while(s!==void 0);else do r=s[i],r!==void 0&&(e.push(s.time),t.push(r)),s=a[n++];while(s!==void 0)}class To{constructor(e,t,i,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,n=t[i],s=t[i-1];i:{e:{let r;t:{n:if(!(e<n)){for(let o=i+2;;){if(n===void 0){if(e<s)break n;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(s=n,n=t[++i],e<n)break e}r=t.length;break t}if(!(e>=s)){const o=t[1];e<o&&(i=2,s=o);for(let c=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===c)break;if(n=s,s=t[--i-1],e>=s)break e}r=i,i=0;break t}break i}for(;i<r;){const o=i+r>>>1;e<t[o]?r=o:i=o+1}if(n=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,n)}return this.interpolate_(i,s,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,s=e*n;for(let r=0;r!==n;++r)t[r]=i[s+r];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class mM extends To{constructor(e,t,i,n){super(e,t,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:j0,endingEnd:j0}}intervalChanged_(e,t,i){const n=this.parameterPositions;let s=e-2,r=e+1,o=n[s],c=n[r];if(o===void 0)switch(this.getSettings_().endingStart){case Q0:s=e,o=2*t-i;break;case ef:s=n.length-2,o=t+n[s]-n[s+1];break;default:s=e,o=i}if(c===void 0)switch(this.getSettings_().endingEnd){case Q0:r=e,c=2*i-t;break;case ef:r=1,c=i+n[1]-n[0];break;default:r=e-1,c=t}const l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(c-i),this._offsetPrev=s*h,this._offsetNext=r*h}interpolate_(e,t,i,n){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(i-t)/(n-t),v=p*p,m=v*p,g=-d*m+2*d*v-d*p,_=(1+d)*m+(-1.5-2*d)*v+(-.5+d)*p+1,w=(-1-f)*m+(1.5+f)*v+.5*p,M=f*m-f*v;for(let S=0;S!==o;++S)s[S]=g*r[h+S]+_*r[l+S]+w*r[c+S]+M*r[u+S];return s}}class gM extends To{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=(i-t)/(n-t),u=1-h;for(let d=0;d!==o;++d)s[d]=r[l+d]*u+r[c+d]*h;return s}}class vM extends To{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class MM extends To{interpolate_(e,t,i,n){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this.inTangents,u=this.outTangents;if(!h||!u){const p=(i-t)/(n-t),v=1-p;for(let m=0;m!==o;++m)s[m]=r[l+m]*v+r[c+m]*p;return s}const d=o*2,f=e-1;for(let p=0;p!==o;++p){const v=r[l+p],m=r[c+p],g=f*d+p*2,_=u[g],w=u[g+1],M=e*d+p*2,S=h[M],b=h[M+1];let T=(i-t)/(n-t),x,A,I,C,P;for(let X=0;X<8;X++){x=T*T,A=x*T,I=1-T,C=I*I,P=C*I;const N=P*t+3*C*T*_+3*I*x*S+A*n-i;if(Math.abs(N)<1e-10)break;const V=3*C*(_-t)+6*I*T*(S-_)+3*x*(n-S);if(Math.abs(V)<1e-10)break;T=T-N/V,T=Math.max(0,Math.min(1,T))}s[p]=P*v+3*C*T*w+3*I*x*b+A*m}return s}}class In{constructor(e,t,i,n){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=uc(t,this.TimeBufferType),this.values=uc(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:uc(e.times,Array),values:uc(e.values,Array)};const n=e.getInterpolation();n!==e.DefaultInterpolation&&(i.interpolation=n)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new vM(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new gM(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new mM(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){const t=new MM(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case Jc:t=this.InterpolantFactoryMethodDiscrete;break;case Gu:t=this.InterpolantFactoryMethodLinear;break;case zl:t=this.InterpolantFactoryMethodSmooth;break;case J0:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return Te("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Jc;case this.InterpolantFactoryMethodLinear:return Gu;case this.InterpolantFactoryMethodSmooth:return zl;case this.InterpolantFactoryMethodBezier:return J0}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]*=e}return this}trim(e,t){const i=this.times,n=i.length;let s=0,r=n-1;for(;s!==n&&i[s]<e;)++s;for(;r!==-1&&i[r]>t;)--r;if(++r,s!==0||r!==n){s>=r&&(r=Math.max(r,1),s=r-1);const o=this.getValueSize();this.times=i.slice(s,r),this.values=this.values.slice(s*o,r*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Be("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,n=this.values,s=i.length;s===0&&(Be("KeyframeTrack: Track is empty.",this),e=!1);let r=null;for(let o=0;o!==s;o++){const c=i[o];if(typeof c=="number"&&isNaN(c)){Be("KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(r!==null&&r>c){Be("KeyframeTrack: Out of order keys.",this,o,c,r),e=!1;break}r=c}if(n!==void 0&&hv(n))for(let o=0,c=n.length;o!==c;++o){const l=n[o];if(isNaN(l)){Be("KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),n=this.getInterpolation()===zl,s=e.length-1;let r=1;for(let o=1;o<s;++o){let c=!1;const l=e[o],h=e[o+1];if(l!==h&&(o!==1||l!==e[0]))if(n)c=!0;else{const u=o*i,d=u-i,f=u+i;for(let p=0;p!==i;++p){const v=t[u+p];if(v!==t[d+p]||v!==t[f+p]){c=!0;break}}}if(c){if(o!==r){e[r]=e[o];const u=o*i,d=r*i;for(let f=0;f!==i;++f)t[d+f]=t[u+f]}++r}}if(s>0){e[r]=e[s];for(let o=s*i,c=r*i,l=0;l!==i;++l)t[c+l]=t[o+l];++r}return r!==e.length?(this.times=e.slice(0,r),this.values=t.slice(0,r*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,n=new i(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}In.prototype.ValueTypeName="";In.prototype.TimeBufferType=Float32Array;In.prototype.ValueBufferType=Float32Array;In.prototype.DefaultInterpolation=Gu;class wr extends In{constructor(e,t,i){super(e,t,i)}}wr.prototype.ValueTypeName="bool";wr.prototype.ValueBufferType=Array;wr.prototype.DefaultInterpolation=Jc;wr.prototype.InterpolantFactoryMethodLinear=void 0;wr.prototype.InterpolantFactoryMethodSmooth=void 0;class Sg extends In{constructor(e,t,i,n){super(e,t,i,n)}}Sg.prototype.ValueTypeName="color";class Yd extends In{constructor(e,t,i,n){super(e,t,i,n)}}Yd.prototype.ValueTypeName="number";class xM extends To{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=(i-t)/(n-t);let l=e*o;for(let h=l+o;l!==h;l+=4)Qn.slerpFlat(s,0,r,l-o,r,l,c);return s}}class Kd extends In{constructor(e,t,i,n){super(e,t,i,n)}InterpolantFactoryMethodLinear(e){return new xM(this.times,this.values,this.getValueSize(),e)}}Kd.prototype.ValueTypeName="quaternion";Kd.prototype.InterpolantFactoryMethodSmooth=void 0;class br extends In{constructor(e,t,i){super(e,t,i)}}br.prototype.ValueTypeName="string";br.prototype.ValueBufferType=Array;br.prototype.DefaultInterpolation=Jc;br.prototype.InterpolantFactoryMethodLinear=void 0;br.prototype.InterpolantFactoryMethodSmooth=void 0;class wg extends In{constructor(e,t,i,n){super(e,t,i,n)}}wg.prototype.ValueTypeName="vector";class wE{constructor(e="",t=-1,i=[],n=ev){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=Rn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,n=1/(e.fps||1);for(let r=0,o=i.length;r!==o;++r)t.push(_M(i[r]).scale(n));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s.userData=JSON.parse(e.userData||"{}"),s}static toJSON(e){const t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let s=0,r=i.length;s!==r;++s)t.push(In.toJSON(i[s]));return n}static CreateFromMorphTargetSequence(e,t,i,n){const s=t.length,r=[];for(let o=0;o<s;o++){let c=[],l=[];c.push((o+s-1)%s,o,(o+1)%s),l.push(0,1,0);const h=fM(c);c=Uf(c,1,h),l=Uf(l,1,h),!n&&c[0]===0&&(c.push(s),l.push(l[0])),r.push(new Yd(".morphTargetInfluences["+t[o].name+"]",c,l).scale(1/i))}return new this(e,-1,r)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const n=e;i=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<i.length;n++)if(i[n].name===t)return i[n];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const n={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,c=e.length;o<c;o++){const l=e[o],h=l.name.match(s);if(h&&h.length>1){const u=h[1];let d=n[u];d||(n[u]=d=[]),d.push(l)}}const r=[];for(const o in n)r.push(this.CreateFromMorphTargetSequence(o,n[o],t,i));return r}resetDuration(){const e=this.tracks;let t=0;for(let i=0,n=e.length;i!==n;++i){const s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let i=0;i<this.tracks.length;i++)e.push(this.tracks[i].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function yM(a){switch(a.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Yd;case"vector":case"vector2":case"vector3":case"vector4":return wg;case"color":return Sg;case"quaternion":return Kd;case"bool":case"boolean":return wr;case"string":return br}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+a)}function _M(a){if(a.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=yM(a.type);if(a.times===void 0){const t=[],i=[];pM(a.keys,t,i,"value"),a.times=t,a.values=i}return e.parse!==void 0?e.parse(a):new e(a.name,a.times,a.values,a.interpolation)}const ms={enabled:!1,files:{},add:function(a,e){this.enabled!==!1&&(Ff(a)||(this.files[a]=e))},get:function(a){if(this.enabled!==!1&&!Ff(a))return this.files[a]},remove:function(a){delete this.files[a]},clear:function(){this.files={}}};function Ff(a){try{const e=a.slice(a.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}class SM{constructor(e,t,i){const n=this;let s=!1,r=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this._abortController=null,this.itemStart=function(h){o++,s===!1&&n.onStart!==void 0&&n.onStart(h,r,o),s=!0},this.itemEnd=function(h){r++,n.onProgress!==void 0&&n.onProgress(h,r,o),r===o&&(s=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(h){n.onError!==void 0&&n.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){const u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){const f=l[u],p=l[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return p}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const wM=new SM;class Ro{constructor(e){this.manager=e!==void 0?e:wM,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){const i=this;return new Promise(function(n,s){i.load(e,n,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Ro.DEFAULT_MATERIAL_NAME="__DEFAULT";const rs={};class bM extends Error{constructor(e,t){super(e),this.response=t}}class bE extends Ro{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=ms.get(`file:${e}`);if(s!==void 0){this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0);return}if(rs[e]!==void 0){rs[e].push({onLoad:t,onProgress:i,onError:n});return}rs[e]=[],rs[e].push({onLoad:t,onProgress:i,onError:n});const r=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,c=this.responseType;fetch(r).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&Te("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const h=rs[e],u=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),f=d?parseInt(d):0,p=f!==0;let v=0;const m=new ReadableStream({start(g){_();function _(){u.read().then(({done:w,value:M})=>{if(w)g.close();else{v+=M.byteLength;const S=new ProgressEvent("progress",{lengthComputable:p,loaded:v,total:f});for(let b=0,T=h.length;b<T;b++){const x=h[b];x.onProgress&&x.onProgress(S)}g.enqueue(M),_()}},w=>{g.error(w)})}}});return new Response(m)}else throw new bM(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return l.json();default:if(o==="")return l.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return l.arrayBuffer().then(p=>f.decode(p))}}}).then(l=>{ms.add(`file:${e}`,l);const h=rs[e];delete rs[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(l)}}).catch(l=>{const h=rs[e];if(h===void 0)throw this.manager.itemError(e),l;delete rs[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onError&&f.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const Xa=new WeakMap;class EM extends Ro{constructor(e){super(e)}load(e,t,i,n){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,r=ms.get(`image:${e}`);if(r!==void 0){if(r.complete===!0)s.manager.itemStart(e),setTimeout(function(){t&&t(r),s.manager.itemEnd(e)},0);else{let u=Xa.get(r);u===void 0&&(u=[],Xa.set(r,u)),u.push({onLoad:t,onError:n})}return r}const o=So("img");function c(){h(),t&&t(this);const u=Xa.get(this)||[];for(let d=0;d<u.length;d++){const f=u[d];f.onLoad&&f.onLoad(this)}Xa.delete(this),s.manager.itemEnd(e)}function l(u){h(),n&&n(u),ms.remove(`image:${e}`);const d=Xa.get(this)||[];for(let f=0;f<d.length;f++){const p=d[f];p.onError&&p.onError(u)}Xa.delete(this),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){o.removeEventListener("load",c,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),ms.add(`image:${e}`,o),s.manager.itemStart(e),o.src=e,o}}class EE extends Ro{constructor(e){super(e)}load(e,t,i,n){const s=new Mi,r=new EM(this.manager);return r.setCrossOrigin(this.crossOrigin),r.setPath(this.path),r.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},i,n),s}}class Sl extends Pt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new se(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 AM extends Sl{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new se(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 dh=new Ze,kf=new D,zf=new D;class $d{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 xe(512,512),this.mapType=nn,this.map=null,this.mapPass=null,this.matrix=new Ze,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Wd,this._frameExtents=new xe(1,1),this._viewportCount=1,this._viewports=[new nt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;kf.setFromMatrixPosition(e.matrixWorld),t.position.copy(kf),zf.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(zf),t.updateMatrixWorld(),dh.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(dh,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===_o||t.reversedDepth?i.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(dh)}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 dc=new D,fc=new Qn,Un=new D;class bg extends Pt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ze,this.projectionMatrix=new Ze,this.projectionMatrixInverse=new Ze,this.coordinateSystem=Kn,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(dc,fc,Un),Un.x===1&&Un.y===1&&Un.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(dc,fc,Un.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(dc,fc,Un),Un.x===1&&Un.y===1&&Un.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(dc,fc,Un.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Is=new D,Hf=new xe,Bf=new xe;class Vi extends bg{constructor(e=50,t=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,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=Mr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(no*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Mr*2*Math.atan(Math.tan(no*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){Is.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Is.x,Is.y).multiplyScalar(-e/Is.z),Is.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Is.x,Is.y).multiplyScalar(-e/Is.z)}getViewSize(e,t){return this.getViewBounds(e,Hf,Bf),t.subVectors(Bf,Hf)}setViewOffset(e,t,i,n,s,r){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(no*.5*this.fov)/this.zoom,i=2*t,n=this.aspect*i,s=-.5*n;const r=this.view;if(this.view!==null&&this.view.enabled){const c=r.fullWidth,l=r.fullHeight;s+=r.offsetX*n/c,t-=r.offsetY*i/l,n*=r.width/c,i*=r.height/l}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+n,t,t-i,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 TM extends $d{constructor(){super(new Vi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,i=Mr*2*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height*this.aspect,s=e.distance||t.far;(i!==t.fov||n!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=n,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class AE extends Sl{constructor(e,t,i=0,n=Math.PI/3,s=0,r=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.target=new Pt,this.distance=i,this.angle=n,this.penumbra=s,this.decay=r,this.map=null,this.shadow=new TM}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class RM extends $d{constructor(){super(new Vi(90,1,.5,500)),this.isPointLightShadow=!0}}class Eg extends Sl{constructor(e,t,i=0,n=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new RM}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 Cn extends bg{constructor(e=-1,t=1,i=1,n=-1,s=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=s,this.far=r,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,n,s,r){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=s,this.view.height=r,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),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let s=i-e,r=i+e,o=n+t,c=n-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,r=s+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,r,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class DM extends $d{constructor(){super(new Cn(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Gf extends Sl{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.target=new Pt,this.shadow=new DM}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class TE{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}const fh=new WeakMap;class RE extends Ro{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&Te("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Te("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,r=ms.get(`image-bitmap:${e}`);if(r!==void 0){if(s.manager.itemStart(e),r.then){r.then(l=>{fh.has(r)===!0?(n&&n(fh.get(r)),s.manager.itemError(e),s.manager.itemEnd(e)):(t&&t(l),s.manager.itemEnd(e))});return}setTimeout(function(){t&&t(r),s.manager.itemEnd(e)},0);return}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const c=fetch(e,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){ms.add(`image-bitmap:${e}`,l),t&&t(l),s.manager.itemEnd(e)}).catch(function(l){n&&n(l),fh.set(c,l),ms.remove(`image-bitmap:${e}`),s.manager.itemError(e),s.manager.itemEnd(e)});ms.add(`image-bitmap:${e}`,c),s.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const qa=-90,Ya=1;class Zd extends Pt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new Vi(qa,Ya,e,t);n.layers=this.layers,this.add(n);const s=new Vi(qa,Ya,e,t);s.layers=this.layers,this.add(s);const r=new Vi(qa,Ya,e,t);r.layers=this.layers,this.add(r);const o=new Vi(qa,Ya,e,t);o.layers=this.layers,this.add(o);const c=new Vi(qa,Ya,e,t);c.layers=this.layers,this.add(c);const l=new Vi(qa,Ya,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,n,s,r,o,c]=t;for(const l of t)this.remove(l);if(e===Kn)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),r.up.set(0,0,1),r.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===_o)i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),r.up.set(0,0,-1),r.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:n}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,r,o,c,l,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const v=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(i,0,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(i,1,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(i,2,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(i,4,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),i.texture.generateMipmaps=v,e.setRenderTarget(i,5,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(u,d,f),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class CM extends Vi{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Jd="\\[\\]\\.:\\/",IM=new RegExp("["+Jd+"]","g"),jd="[^"+Jd+"]",PM="[^"+Jd.replace("\\.","")+"]",LM=/((?:WC+[\/:])*)/.source.replace("WC",jd),NM=/(WCOD+)?/.source.replace("WCOD",PM),OM=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",jd),UM=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",jd),FM=new RegExp("^"+LM+NM+OM+UM+"$"),kM=["material","materials","bones","map"];class zM{constructor(e,t,i){const n=i||St.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];n!==void 0&&n.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,s=i.length;n!==s;++n)i[n].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class St{constructor(e,t,i){this.path=t,this.parsedPath=i||St.parseTrackName(t),this.node=St.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new St.Composite(e,t,i):new St(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(IM,"")}static parseTrackName(e){const t=FM.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const s=i.nodeName.substring(n+1);kM.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(s){for(let r=0;r<s.length;r++){const o=s[r];if(o.name===t||o.uuid===t)return o;const c=i(o.children);if(c)return c}return null},n=i(e.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)e[t++]=i[n]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,n=t.propertyName;let s=t.propertyIndex;if(e||(e=St.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Te("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){Be("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Be("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Be("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Be("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Be("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){Be("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){Be("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}const r=e[n];if(r===void 0){const l=t.nodeName;Be("PropertyBinding: Trying to update property for track: "+l+"."+n+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(s!==void 0){if(n==="morphTargetInfluences"){if(!e.geometry){Be("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Be("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}c=this.BindingType.ArrayElement,this.resolvedProperty=r,this.propertyIndex=s}else r.fromArray!==void 0&&r.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=r):Array.isArray(r)?(c=this.BindingType.EntireArray,this.resolvedProperty=r):this.propertyName=n;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}St.Composite=zM;St.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};St.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};St.prototype.GetterByBindingType=[St.prototype._getValue_direct,St.prototype._getValue_array,St.prototype._getValue_arrayElement,St.prototype._getValue_toArray];St.prototype.SetterByBindingTypeAndVersioning=[[St.prototype._setValue_direct,St.prototype._setValue_direct_setNeedsUpdate,St.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[St.prototype._setValue_array,St.prototype._setValue_array_setNeedsUpdate,St.prototype._setValue_array_setMatrixWorldNeedsUpdate],[St.prototype._setValue_arrayElement,St.prototype._setValue_arrayElement_setNeedsUpdate,St.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[St.prototype._setValue_fromArray,St.prototype._setValue_fromArray_setNeedsUpdate,St.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const Vf=new Ze;class ph{constructor(e,t,i=0,n=1/0){this.ray=new Ao(e,t),this.near=i,this.far=n,this.camera=null,this.layers=new Bd,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):Be("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Vf.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Vf),this}intersectObject(e,t=!0,i=[]){return Xu(e,this,i,t),i.sort(Wf),i}intersectObjects(e,t=!0,i=[]){for(let n=0,s=e.length;n<s;n++)Xu(e[n],this,i,t);return i.sort(Wf),i}}function Wf(a,e){return a.distance-e.distance}function Xu(a,e,t,i){let n=!0;if(a.layers.test(e.layers)&&a.raycast(e,t)===!1&&(n=!1),n===!0&&i===!0){const s=a.children;for(let r=0,o=s.length;r<o;r++)Xu(s[r],e,t,!0)}}class Ag{static{Ag.prototype.isMatrix2=!0}constructor(e,t,i,n){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,n)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,n){const s=this.elements;return s[0]=e,s[2]=t,s[1]=i,s[3]=n,this}}function Xf(a,e,t,i){const n=HM(i);switch(t){case og:return a*e;case yl:return a*e/n.components*n.byteLength;case Nd:return a*e/n.components*n.byteLength;case _a:return a*e*2/n.components*n.byteLength;case Od:return a*e*2/n.components*n.byteLength;case cg:return a*e*3/n.components*n.byteLength;case yi:return a*e*4/n.components*n.byteLength;case Ud:return a*e*4/n.components*n.byteLength;case Uc:case Fc:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*8;case kc:case zc:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*16;case fu:case mu:return Math.max(a,16)*Math.max(e,8)/4;case du:case pu:return Math.max(a,8)*Math.max(e,8)/2;case gu:case vu:case xu:case yu:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*8;case Mu:case $c:case _u:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*16;case Su:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*16;case wu:return Math.floor((a+4)/5)*Math.floor((e+3)/4)*16;case bu:return Math.floor((a+4)/5)*Math.floor((e+4)/5)*16;case Eu:return Math.floor((a+5)/6)*Math.floor((e+4)/5)*16;case Au:return Math.floor((a+5)/6)*Math.floor((e+5)/6)*16;case Tu:return Math.floor((a+7)/8)*Math.floor((e+4)/5)*16;case Ru:return Math.floor((a+7)/8)*Math.floor((e+5)/6)*16;case Du:return Math.floor((a+7)/8)*Math.floor((e+7)/8)*16;case Cu:return Math.floor((a+9)/10)*Math.floor((e+4)/5)*16;case Iu:return Math.floor((a+9)/10)*Math.floor((e+5)/6)*16;case Pu:return Math.floor((a+9)/10)*Math.floor((e+7)/8)*16;case Lu:return Math.floor((a+9)/10)*Math.floor((e+9)/10)*16;case Nu:return Math.floor((a+11)/12)*Math.floor((e+9)/10)*16;case Ou:return Math.floor((a+11)/12)*Math.floor((e+11)/12)*16;case Uu:case Fu:case ku:return Math.ceil(a/4)*Math.ceil(e/4)*16;case zu:case Hu:return Math.ceil(a/4)*Math.ceil(e/4)*8;case Zc:case Bu:return Math.ceil(a/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function HM(a){switch(a){case nn:case ng:return{byteLength:1,components:1};case xo:case sg:case Ft:return{byteLength:2,components:1};case Pd:case Ld:return{byteLength:2,components:4};case gn:case Id:case Ri:return{byteLength:4,components:1};case ag:case rg:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${a}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Dd}}));typeof window<"u"&&(window.__THREE__?Te("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Dd);/**
|
|
635
|
+
}`;class at extends _s{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=cM,this.fragmentShader=lM,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=xr(e.uniforms),this.uniformsGroups=rM(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 n in this.uniforms){const r=this.uniforms[n].value;r&&r.isTexture?t.uniforms[n]={type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[n]={type:"c",value:r.getHex()}:r&&r.isVector2?t.uniforms[n]={type:"v2",value:r.toArray()}:r&&r.isVector3?t.uniforms[n]={type:"v3",value:r.toArray()}:r&&r.isVector4?t.uniforms[n]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?t.uniforms[n]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?t.uniforms[n]={type:"m4",value:r.toArray()}:t.uniforms[n]={value:r}}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 i={};for(const n in this.extensions)this.extensions[n]===!0&&(i[n]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const i in e.uniforms){const n=e.uniforms[i];switch(this.uniforms[i]={},n.type){case"t":this.uniforms[i].value=t[n.value]||null;break;case"c":this.uniforms[i].value=new se().setHex(n.value);break;case"v2":this.uniforms[i].value=new xe().fromArray(n.value);break;case"v3":this.uniforms[i].value=new D().fromArray(n.value);break;case"v4":this.uniforms[i].value=new it().fromArray(n.value);break;case"m3":this.uniforms[i].value=new Xe().fromArray(n.value);break;case"m4":this.uniforms[i].value=new Ze().fromArray(n.value);break;default:this.uniforms[i].value=n.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 i in e.extensions)this.extensions[i]=e.extensions[i];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class _g extends at{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class oa extends _s{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new se(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new se(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=jc,this.normalScale=new xe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ms,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class hM extends oa{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new xe(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return je(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new se(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new se(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new se(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Sr extends _s{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new se(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new se(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=jc,this.normalScale=new xe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ms,this.combine=Cd,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 uM extends _s{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=tv,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 dM extends _s{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function uc(a,e){return!a||a.constructor===e?a:typeof e.BYTES_PER_ELEMENT=="number"?new e(a):Array.prototype.slice.call(a)}function fM(a){function e(n,s){return a[n]-a[s]}const t=a.length,i=new Array(t);for(let n=0;n!==t;++n)i[n]=n;return i.sort(e),i}function Uf(a,e,t){const i=a.length,n=new a.constructor(i);for(let s=0,r=0;r!==i;++s){const o=t[s]*e;for(let c=0;c!==e;++c)n[r++]=a[o+c]}return n}function pM(a,e,t,i){let n=1,s=a[0];for(;s!==void 0&&s[i]===void 0;)s=a[n++];if(s===void 0)return;let r=s[i];if(r!==void 0)if(Array.isArray(r))do r=s[i],r!==void 0&&(e.push(s.time),t.push(...r)),s=a[n++];while(s!==void 0);else if(r.toArray!==void 0)do r=s[i],r!==void 0&&(e.push(s.time),r.toArray(t,t.length)),s=a[n++];while(s!==void 0);else do r=s[i],r!==void 0&&(e.push(s.time),t.push(r)),s=a[n++];while(s!==void 0)}class To{constructor(e,t,i,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,n=t[i],s=t[i-1];i:{e:{let r;t:{n:if(!(e<n)){for(let o=i+2;;){if(n===void 0){if(e<s)break n;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(s=n,n=t[++i],e<n)break e}r=t.length;break t}if(!(e>=s)){const o=t[1];e<o&&(i=2,s=o);for(let c=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===c)break;if(n=s,s=t[--i-1],e>=s)break e}r=i,i=0;break t}break i}for(;i<r;){const o=i+r>>>1;e<t[o]?r=o:i=o+1}if(n=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,n)}return this.interpolate_(i,s,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,s=e*n;for(let r=0;r!==n;++r)t[r]=i[s+r];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class mM extends To{constructor(e,t,i,n){super(e,t,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:j0,endingEnd:j0}}intervalChanged_(e,t,i){const n=this.parameterPositions;let s=e-2,r=e+1,o=n[s],c=n[r];if(o===void 0)switch(this.getSettings_().endingStart){case Q0:s=e,o=2*t-i;break;case ef:s=n.length-2,o=t+n[s]-n[s+1];break;default:s=e,o=i}if(c===void 0)switch(this.getSettings_().endingEnd){case Q0:r=e,c=2*i-t;break;case ef:r=1,c=i+n[1]-n[0];break;default:r=e-1,c=t}const l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(c-i),this._offsetPrev=s*h,this._offsetNext=r*h}interpolate_(e,t,i,n){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(i-t)/(n-t),v=p*p,m=v*p,g=-d*m+2*d*v-d*p,_=(1+d)*m+(-1.5-2*d)*v+(-.5+d)*p+1,w=(-1-f)*m+(1.5+f)*v+.5*p,M=f*m-f*v;for(let S=0;S!==o;++S)s[S]=g*r[h+S]+_*r[l+S]+w*r[c+S]+M*r[u+S];return s}}class gM extends To{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=(i-t)/(n-t),u=1-h;for(let d=0;d!==o;++d)s[d]=r[l+d]*u+r[c+d]*h;return s}}class vM extends To{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class MM extends To{interpolate_(e,t,i,n){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this.inTangents,u=this.outTangents;if(!h||!u){const p=(i-t)/(n-t),v=1-p;for(let m=0;m!==o;++m)s[m]=r[l+m]*v+r[c+m]*p;return s}const d=o*2,f=e-1;for(let p=0;p!==o;++p){const v=r[l+p],m=r[c+p],g=f*d+p*2,_=u[g],w=u[g+1],M=e*d+p*2,S=h[M],b=h[M+1];let T=(i-t)/(n-t),x,A,I,C,P;for(let X=0;X<8;X++){x=T*T,A=x*T,I=1-T,C=I*I,P=C*I;const N=P*t+3*C*T*_+3*I*x*S+A*n-i;if(Math.abs(N)<1e-10)break;const V=3*C*(_-t)+6*I*T*(S-_)+3*x*(n-S);if(Math.abs(V)<1e-10)break;T=T-N/V,T=Math.max(0,Math.min(1,T))}s[p]=P*v+3*C*T*w+3*I*x*b+A*m}return s}}class In{constructor(e,t,i,n){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=uc(t,this.TimeBufferType),this.values=uc(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:uc(e.times,Array),values:uc(e.values,Array)};const n=e.getInterpolation();n!==e.DefaultInterpolation&&(i.interpolation=n)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new vM(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new gM(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new mM(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){const t=new MM(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case Jc:t=this.InterpolantFactoryMethodDiscrete;break;case Gu:t=this.InterpolantFactoryMethodLinear;break;case zl:t=this.InterpolantFactoryMethodSmooth;break;case J0:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return Te("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Jc;case this.InterpolantFactoryMethodLinear:return Gu;case this.InterpolantFactoryMethodSmooth:return zl;case this.InterpolantFactoryMethodBezier:return J0}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]*=e}return this}trim(e,t){const i=this.times,n=i.length;let s=0,r=n-1;for(;s!==n&&i[s]<e;)++s;for(;r!==-1&&i[r]>t;)--r;if(++r,s!==0||r!==n){s>=r&&(r=Math.max(r,1),s=r-1);const o=this.getValueSize();this.times=i.slice(s,r),this.values=this.values.slice(s*o,r*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Be("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,n=this.values,s=i.length;s===0&&(Be("KeyframeTrack: Track is empty.",this),e=!1);let r=null;for(let o=0;o!==s;o++){const c=i[o];if(typeof c=="number"&&isNaN(c)){Be("KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(r!==null&&r>c){Be("KeyframeTrack: Out of order keys.",this,o,c,r),e=!1;break}r=c}if(n!==void 0&&hv(n))for(let o=0,c=n.length;o!==c;++o){const l=n[o];if(isNaN(l)){Be("KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),n=this.getInterpolation()===zl,s=e.length-1;let r=1;for(let o=1;o<s;++o){let c=!1;const l=e[o],h=e[o+1];if(l!==h&&(o!==1||l!==e[0]))if(n)c=!0;else{const u=o*i,d=u-i,f=u+i;for(let p=0;p!==i;++p){const v=t[u+p];if(v!==t[d+p]||v!==t[f+p]){c=!0;break}}}if(c){if(o!==r){e[r]=e[o];const u=o*i,d=r*i;for(let f=0;f!==i;++f)t[d+f]=t[u+f]}++r}}if(s>0){e[r]=e[s];for(let o=s*i,c=r*i,l=0;l!==i;++l)t[c+l]=t[o+l];++r}return r!==e.length?(this.times=e.slice(0,r),this.values=t.slice(0,r*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,n=new i(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}In.prototype.ValueTypeName="";In.prototype.TimeBufferType=Float32Array;In.prototype.ValueBufferType=Float32Array;In.prototype.DefaultInterpolation=Gu;class wr extends In{constructor(e,t,i){super(e,t,i)}}wr.prototype.ValueTypeName="bool";wr.prototype.ValueBufferType=Array;wr.prototype.DefaultInterpolation=Jc;wr.prototype.InterpolantFactoryMethodLinear=void 0;wr.prototype.InterpolantFactoryMethodSmooth=void 0;class Sg extends In{constructor(e,t,i,n){super(e,t,i,n)}}Sg.prototype.ValueTypeName="color";class Yd extends In{constructor(e,t,i,n){super(e,t,i,n)}}Yd.prototype.ValueTypeName="number";class xM extends To{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=(i-t)/(n-t);let l=e*o;for(let h=l+o;l!==h;l+=4)Qn.slerpFlat(s,0,r,l-o,r,l,c);return s}}class Kd extends In{constructor(e,t,i,n){super(e,t,i,n)}InterpolantFactoryMethodLinear(e){return new xM(this.times,this.values,this.getValueSize(),e)}}Kd.prototype.ValueTypeName="quaternion";Kd.prototype.InterpolantFactoryMethodSmooth=void 0;class br extends In{constructor(e,t,i){super(e,t,i)}}br.prototype.ValueTypeName="string";br.prototype.ValueBufferType=Array;br.prototype.DefaultInterpolation=Jc;br.prototype.InterpolantFactoryMethodLinear=void 0;br.prototype.InterpolantFactoryMethodSmooth=void 0;class wg extends In{constructor(e,t,i,n){super(e,t,i,n)}}wg.prototype.ValueTypeName="vector";class bE{constructor(e="",t=-1,i=[],n=ev){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=Rn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,n=1/(e.fps||1);for(let r=0,o=i.length;r!==o;++r)t.push(_M(i[r]).scale(n));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s.userData=JSON.parse(e.userData||"{}"),s}static toJSON(e){const t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let s=0,r=i.length;s!==r;++s)t.push(In.toJSON(i[s]));return n}static CreateFromMorphTargetSequence(e,t,i,n){const s=t.length,r=[];for(let o=0;o<s;o++){let c=[],l=[];c.push((o+s-1)%s,o,(o+1)%s),l.push(0,1,0);const h=fM(c);c=Uf(c,1,h),l=Uf(l,1,h),!n&&c[0]===0&&(c.push(s),l.push(l[0])),r.push(new Yd(".morphTargetInfluences["+t[o].name+"]",c,l).scale(1/i))}return new this(e,-1,r)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const n=e;i=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<i.length;n++)if(i[n].name===t)return i[n];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const n={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,c=e.length;o<c;o++){const l=e[o],h=l.name.match(s);if(h&&h.length>1){const u=h[1];let d=n[u];d||(n[u]=d=[]),d.push(l)}}const r=[];for(const o in n)r.push(this.CreateFromMorphTargetSequence(o,n[o],t,i));return r}resetDuration(){const e=this.tracks;let t=0;for(let i=0,n=e.length;i!==n;++i){const s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let i=0;i<this.tracks.length;i++)e.push(this.tracks[i].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function yM(a){switch(a.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Yd;case"vector":case"vector2":case"vector3":case"vector4":return wg;case"color":return Sg;case"quaternion":return Kd;case"bool":case"boolean":return wr;case"string":return br}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+a)}function _M(a){if(a.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=yM(a.type);if(a.times===void 0){const t=[],i=[];pM(a.keys,t,i,"value"),a.times=t,a.values=i}return e.parse!==void 0?e.parse(a):new e(a.name,a.times,a.values,a.interpolation)}const ms={enabled:!1,files:{},add:function(a,e){this.enabled!==!1&&(Ff(a)||(this.files[a]=e))},get:function(a){if(this.enabled!==!1&&!Ff(a))return this.files[a]},remove:function(a){delete this.files[a]},clear:function(){this.files={}}};function Ff(a){try{const e=a.slice(a.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}class SM{constructor(e,t,i){const n=this;let s=!1,r=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this._abortController=null,this.itemStart=function(h){o++,s===!1&&n.onStart!==void 0&&n.onStart(h,r,o),s=!0},this.itemEnd=function(h){r++,n.onProgress!==void 0&&n.onProgress(h,r,o),r===o&&(s=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(h){n.onError!==void 0&&n.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){const u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){const f=l[u],p=l[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return p}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const wM=new SM;class Ro{constructor(e){this.manager=e!==void 0?e:wM,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){const i=this;return new Promise(function(n,s){i.load(e,n,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Ro.DEFAULT_MATERIAL_NAME="__DEFAULT";const rs={};class bM extends Error{constructor(e,t){super(e),this.response=t}}class EE extends Ro{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=ms.get(`file:${e}`);if(s!==void 0){this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0);return}if(rs[e]!==void 0){rs[e].push({onLoad:t,onProgress:i,onError:n});return}rs[e]=[],rs[e].push({onLoad:t,onProgress:i,onError:n});const r=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,c=this.responseType;fetch(r).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&Te("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const h=rs[e],u=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),f=d?parseInt(d):0,p=f!==0;let v=0;const m=new ReadableStream({start(g){_();function _(){u.read().then(({done:w,value:M})=>{if(w)g.close();else{v+=M.byteLength;const S=new ProgressEvent("progress",{lengthComputable:p,loaded:v,total:f});for(let b=0,T=h.length;b<T;b++){const x=h[b];x.onProgress&&x.onProgress(S)}g.enqueue(M),_()}},w=>{g.error(w)})}}});return new Response(m)}else throw new bM(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return l.json();default:if(o==="")return l.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return l.arrayBuffer().then(p=>f.decode(p))}}}).then(l=>{ms.add(`file:${e}`,l);const h=rs[e];delete rs[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(l)}}).catch(l=>{const h=rs[e];if(h===void 0)throw this.manager.itemError(e),l;delete rs[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onError&&f.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const Xa=new WeakMap;class EM extends Ro{constructor(e){super(e)}load(e,t,i,n){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,r=ms.get(`image:${e}`);if(r!==void 0){if(r.complete===!0)s.manager.itemStart(e),setTimeout(function(){t&&t(r),s.manager.itemEnd(e)},0);else{let u=Xa.get(r);u===void 0&&(u=[],Xa.set(r,u)),u.push({onLoad:t,onError:n})}return r}const o=So("img");function c(){h(),t&&t(this);const u=Xa.get(this)||[];for(let d=0;d<u.length;d++){const f=u[d];f.onLoad&&f.onLoad(this)}Xa.delete(this),s.manager.itemEnd(e)}function l(u){h(),n&&n(u),ms.remove(`image:${e}`);const d=Xa.get(this)||[];for(let f=0;f<d.length;f++){const p=d[f];p.onError&&p.onError(u)}Xa.delete(this),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){o.removeEventListener("load",c,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),ms.add(`image:${e}`,o),s.manager.itemStart(e),o.src=e,o}}class AE extends Ro{constructor(e){super(e)}load(e,t,i,n){const s=new xi,r=new EM(this.manager);return r.setCrossOrigin(this.crossOrigin),r.setPath(this.path),r.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},i,n),s}}class Sl extends Pt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new se(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 AM extends Sl{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new se(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 dh=new Ze,kf=new D,zf=new D;class $d{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 xe(512,512),this.mapType=nn,this.map=null,this.mapPass=null,this.matrix=new Ze,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Wd,this._frameExtents=new xe(1,1),this._viewportCount=1,this._viewports=[new it(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;kf.setFromMatrixPosition(e.matrixWorld),t.position.copy(kf),zf.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(zf),t.updateMatrixWorld(),dh.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(dh,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===_o||t.reversedDepth?i.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(dh)}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 dc=new D,fc=new Qn,Un=new D;class bg extends Pt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ze,this.projectionMatrix=new Ze,this.projectionMatrixInverse=new Ze,this.coordinateSystem=Kn,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(dc,fc,Un),Un.x===1&&Un.y===1&&Un.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(dc,fc,Un.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(dc,fc,Un),Un.x===1&&Un.y===1&&Un.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(dc,fc,Un.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Is=new D,Hf=new xe,Bf=new xe;class Vi extends bg{constructor(e=50,t=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,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=Mr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(no*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Mr*2*Math.atan(Math.tan(no*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){Is.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Is.x,Is.y).multiplyScalar(-e/Is.z),Is.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Is.x,Is.y).multiplyScalar(-e/Is.z)}getViewSize(e,t){return this.getViewBounds(e,Hf,Bf),t.subVectors(Bf,Hf)}setViewOffset(e,t,i,n,s,r){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(no*.5*this.fov)/this.zoom,i=2*t,n=this.aspect*i,s=-.5*n;const r=this.view;if(this.view!==null&&this.view.enabled){const c=r.fullWidth,l=r.fullHeight;s+=r.offsetX*n/c,t-=r.offsetY*i/l,n*=r.width/c,i*=r.height/l}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+n,t,t-i,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 TM extends $d{constructor(){super(new Vi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,i=Mr*2*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height*this.aspect,s=e.distance||t.far;(i!==t.fov||n!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=n,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class TE extends Sl{constructor(e,t,i=0,n=Math.PI/3,s=0,r=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.target=new Pt,this.distance=i,this.angle=n,this.penumbra=s,this.decay=r,this.map=null,this.shadow=new TM}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class RM extends $d{constructor(){super(new Vi(90,1,.5,500)),this.isPointLightShadow=!0}}class Eg extends Sl{constructor(e,t,i=0,n=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new RM}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 Cn extends bg{constructor(e=-1,t=1,i=1,n=-1,s=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=s,this.far=r,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,n,s,r){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=s,this.view.height=r,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),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let s=i-e,r=i+e,o=n+t,c=n-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,r=s+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,r,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class DM extends $d{constructor(){super(new Cn(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Gf extends Sl{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.target=new Pt,this.shadow=new DM}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class RE{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}const fh=new WeakMap;class DE extends Ro{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&Te("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Te("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,r=ms.get(`image-bitmap:${e}`);if(r!==void 0){if(s.manager.itemStart(e),r.then){r.then(l=>{fh.has(r)===!0?(n&&n(fh.get(r)),s.manager.itemError(e),s.manager.itemEnd(e)):(t&&t(l),s.manager.itemEnd(e))});return}setTimeout(function(){t&&t(r),s.manager.itemEnd(e)},0);return}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const c=fetch(e,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){ms.add(`image-bitmap:${e}`,l),t&&t(l),s.manager.itemEnd(e)}).catch(function(l){n&&n(l),fh.set(c,l),ms.remove(`image-bitmap:${e}`),s.manager.itemError(e),s.manager.itemEnd(e)});ms.add(`image-bitmap:${e}`,c),s.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const qa=-90,Ya=1;class Zd extends Pt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new Vi(qa,Ya,e,t);n.layers=this.layers,this.add(n);const s=new Vi(qa,Ya,e,t);s.layers=this.layers,this.add(s);const r=new Vi(qa,Ya,e,t);r.layers=this.layers,this.add(r);const o=new Vi(qa,Ya,e,t);o.layers=this.layers,this.add(o);const c=new Vi(qa,Ya,e,t);c.layers=this.layers,this.add(c);const l=new Vi(qa,Ya,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,n,s,r,o,c]=t;for(const l of t)this.remove(l);if(e===Kn)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),r.up.set(0,0,1),r.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===_o)i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),r.up.set(0,0,-1),r.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:n}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,r,o,c,l,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const v=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(i,0,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(i,1,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(i,2,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(i,4,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),i.texture.generateMipmaps=v,e.setRenderTarget(i,5,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(u,d,f),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class CM extends Vi{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Jd="\\[\\]\\.:\\/",IM=new RegExp("["+Jd+"]","g"),jd="[^"+Jd+"]",PM="[^"+Jd.replace("\\.","")+"]",LM=/((?:WC+[\/:])*)/.source.replace("WC",jd),NM=/(WCOD+)?/.source.replace("WCOD",PM),OM=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",jd),UM=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",jd),FM=new RegExp("^"+LM+NM+OM+UM+"$"),kM=["material","materials","bones","map"];class zM{constructor(e,t,i){const n=i||St.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];n!==void 0&&n.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,s=i.length;n!==s;++n)i[n].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class St{constructor(e,t,i){this.path=t,this.parsedPath=i||St.parseTrackName(t),this.node=St.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new St.Composite(e,t,i):new St(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(IM,"")}static parseTrackName(e){const t=FM.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const s=i.nodeName.substring(n+1);kM.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(s){for(let r=0;r<s.length;r++){const o=s[r];if(o.name===t||o.uuid===t)return o;const c=i(o.children);if(c)return c}return null},n=i(e.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)e[t++]=i[n]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,n=t.propertyName;let s=t.propertyIndex;if(e||(e=St.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Te("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){Be("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Be("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Be("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Be("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Be("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){Be("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){Be("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}const r=e[n];if(r===void 0){const l=t.nodeName;Be("PropertyBinding: Trying to update property for track: "+l+"."+n+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(s!==void 0){if(n==="morphTargetInfluences"){if(!e.geometry){Be("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Be("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}c=this.BindingType.ArrayElement,this.resolvedProperty=r,this.propertyIndex=s}else r.fromArray!==void 0&&r.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=r):Array.isArray(r)?(c=this.BindingType.EntireArray,this.resolvedProperty=r):this.propertyName=n;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}St.Composite=zM;St.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};St.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};St.prototype.GetterByBindingType=[St.prototype._getValue_direct,St.prototype._getValue_array,St.prototype._getValue_arrayElement,St.prototype._getValue_toArray];St.prototype.SetterByBindingTypeAndVersioning=[[St.prototype._setValue_direct,St.prototype._setValue_direct_setNeedsUpdate,St.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[St.prototype._setValue_array,St.prototype._setValue_array_setNeedsUpdate,St.prototype._setValue_array_setMatrixWorldNeedsUpdate],[St.prototype._setValue_arrayElement,St.prototype._setValue_arrayElement_setNeedsUpdate,St.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[St.prototype._setValue_fromArray,St.prototype._setValue_fromArray_setNeedsUpdate,St.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const Vf=new Ze;class ph{constructor(e,t,i=0,n=1/0){this.ray=new Ao(e,t),this.near=i,this.far=n,this.camera=null,this.layers=new Bd,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):Be("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Vf.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Vf),this}intersectObject(e,t=!0,i=[]){return Xu(e,this,i,t),i.sort(Wf),i}intersectObjects(e,t=!0,i=[]){for(let n=0,s=e.length;n<s;n++)Xu(e[n],this,i,t);return i.sort(Wf),i}}function Wf(a,e){return a.distance-e.distance}function Xu(a,e,t,i){let n=!0;if(a.layers.test(e.layers)&&a.raycast(e,t)===!1&&(n=!1),n===!0&&i===!0){const s=a.children;for(let r=0,o=s.length;r<o;r++)Xu(s[r],e,t,!0)}}class Ag{static{Ag.prototype.isMatrix2=!0}constructor(e,t,i,n){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,n)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,n){const s=this.elements;return s[0]=e,s[2]=t,s[1]=i,s[3]=n,this}}function Xf(a,e,t,i){const n=HM(i);switch(t){case og:return a*e;case yl:return a*e/n.components*n.byteLength;case Nd:return a*e/n.components*n.byteLength;case _a:return a*e*2/n.components*n.byteLength;case Od:return a*e*2/n.components*n.byteLength;case cg:return a*e*3/n.components*n.byteLength;case _i:return a*e*4/n.components*n.byteLength;case Ud:return a*e*4/n.components*n.byteLength;case Uc:case Fc:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*8;case kc:case zc:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*16;case fu:case mu:return Math.max(a,16)*Math.max(e,8)/4;case du:case pu:return Math.max(a,8)*Math.max(e,8)/2;case gu:case vu:case xu:case yu:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*8;case Mu:case $c:case _u:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*16;case Su:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*16;case wu:return Math.floor((a+4)/5)*Math.floor((e+3)/4)*16;case bu:return Math.floor((a+4)/5)*Math.floor((e+4)/5)*16;case Eu:return Math.floor((a+5)/6)*Math.floor((e+4)/5)*16;case Au:return Math.floor((a+5)/6)*Math.floor((e+5)/6)*16;case Tu:return Math.floor((a+7)/8)*Math.floor((e+4)/5)*16;case Ru:return Math.floor((a+7)/8)*Math.floor((e+5)/6)*16;case Du:return Math.floor((a+7)/8)*Math.floor((e+7)/8)*16;case Cu:return Math.floor((a+9)/10)*Math.floor((e+4)/5)*16;case Iu:return Math.floor((a+9)/10)*Math.floor((e+5)/6)*16;case Pu:return Math.floor((a+9)/10)*Math.floor((e+7)/8)*16;case Lu:return Math.floor((a+9)/10)*Math.floor((e+9)/10)*16;case Nu:return Math.floor((a+11)/12)*Math.floor((e+9)/10)*16;case Ou:return Math.floor((a+11)/12)*Math.floor((e+11)/12)*16;case Uu:case Fu:case ku:return Math.ceil(a/4)*Math.ceil(e/4)*16;case zu:case Hu:return Math.ceil(a/4)*Math.ceil(e/4)*8;case Zc:case Bu:return Math.ceil(a/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function HM(a){switch(a){case nn:case ng:return{byteLength:1,components:1};case xo:case sg:case kt:return{byteLength:2,components:1};case Pd:case Ld:return{byteLength:2,components:4};case gn:case Id:case Di:return{byteLength:4,components:1};case ag:case rg:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${a}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Dd}}));typeof window<"u"&&(window.__THREE__?Te("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Dd);/**
|
|
636
636
|
* @license
|
|
637
637
|
* Copyright 2010-2026 Three.js Authors
|
|
638
638
|
* SPDX-License-Identifier: MIT
|
|
@@ -4302,7 +4302,7 @@ void main() {
|
|
|
4302
4302
|
#include <tonemapping_fragment>
|
|
4303
4303
|
#include <colorspace_fragment>
|
|
4304
4304
|
#include <fog_fragment>
|
|
4305
|
-
}`,We={alphahash_fragment:GM,alphahash_pars_fragment:VM,alphamap_fragment:WM,alphamap_pars_fragment:XM,alphatest_fragment:qM,alphatest_pars_fragment:YM,aomap_fragment:KM,aomap_pars_fragment:$M,batching_pars_vertex:ZM,batching_vertex:JM,begin_vertex:jM,beginnormal_vertex:QM,bsdfs:ex,iridescence_fragment:tx,bumpmap_pars_fragment:ix,clipping_planes_fragment:nx,clipping_planes_pars_fragment:sx,clipping_planes_pars_vertex:ax,clipping_planes_vertex:rx,color_fragment:ox,color_pars_fragment:cx,color_pars_vertex:lx,color_vertex:hx,common:ux,cube_uv_reflection_fragment:dx,defaultnormal_vertex:fx,displacementmap_pars_vertex:px,displacementmap_vertex:mx,emissivemap_fragment:gx,emissivemap_pars_fragment:vx,colorspace_fragment:Mx,colorspace_pars_fragment:xx,envmap_fragment:yx,envmap_common_pars_fragment:_x,envmap_pars_fragment:Sx,envmap_pars_vertex:wx,envmap_physical_pars_fragment:Nx,envmap_vertex:bx,fog_vertex:Ex,fog_pars_vertex:Ax,fog_fragment:Tx,fog_pars_fragment:Rx,gradientmap_pars_fragment:Dx,lightmap_pars_fragment:Cx,lights_lambert_fragment:Ix,lights_lambert_pars_fragment:Px,lights_pars_begin:Lx,lights_toon_fragment:Ox,lights_toon_pars_fragment:Ux,lights_phong_fragment:Fx,lights_phong_pars_fragment:kx,lights_physical_fragment:zx,lights_physical_pars_fragment:Hx,lights_fragment_begin:Bx,lights_fragment_maps:Gx,lights_fragment_end:Vx,lightprobes_pars_fragment:Wx,logdepthbuf_fragment:Xx,logdepthbuf_pars_fragment:qx,logdepthbuf_pars_vertex:Yx,logdepthbuf_vertex:Kx,map_fragment:$x,map_pars_fragment:Zx,map_particle_fragment:Jx,map_particle_pars_fragment:jx,metalnessmap_fragment:Qx,metalnessmap_pars_fragment:e3,morphinstance_vertex:t3,morphcolor_vertex:i3,morphnormal_vertex:n3,morphtarget_pars_vertex:s3,morphtarget_vertex:a3,normal_fragment_begin:r3,normal_fragment_maps:o3,normal_pars_fragment:c3,normal_pars_vertex:l3,normal_vertex:h3,normalmap_pars_fragment:u3,clearcoat_normal_fragment_begin:d3,clearcoat_normal_fragment_maps:f3,clearcoat_pars_fragment:p3,iridescence_pars_fragment:m3,opaque_fragment:g3,packing:v3,premultiplied_alpha_fragment:M3,project_vertex:x3,dithering_fragment:y3,dithering_pars_fragment:_3,roughnessmap_fragment:S3,roughnessmap_pars_fragment:w3,shadowmap_pars_fragment:b3,shadowmap_pars_vertex:E3,shadowmap_vertex:A3,shadowmask_pars_fragment:T3,skinbase_vertex:R3,skinning_pars_vertex:D3,skinning_vertex:C3,skinnormal_vertex:I3,specularmap_fragment:P3,specularmap_pars_fragment:L3,tonemapping_fragment:N3,tonemapping_pars_fragment:O3,transmission_fragment:U3,transmission_pars_fragment:F3,uv_pars_fragment:k3,uv_pars_vertex:z3,uv_vertex:H3,worldpos_vertex:B3,background_vert:G3,background_frag:V3,backgroundCube_vert:W3,backgroundCube_frag:X3,cube_vert:q3,cube_frag:Y3,depth_vert:K3,depth_frag:$3,distance_vert:Z3,distance_frag:J3,equirect_vert:j3,equirect_frag:Q3,linedashed_vert:ey,linedashed_frag:ty,meshbasic_vert:iy,meshbasic_frag:ny,meshlambert_vert:sy,meshlambert_frag:ay,meshmatcap_vert:ry,meshmatcap_frag:oy,meshnormal_vert:cy,meshnormal_frag:ly,meshphong_vert:hy,meshphong_frag:uy,meshphysical_vert:dy,meshphysical_frag:fy,meshtoon_vert:py,meshtoon_frag:my,points_vert:gy,points_frag:vy,shadow_vert:My,shadow_frag:xy,sprite_vert:yy,sprite_frag:_y},pe={common:{diffuse:{value:new se(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Xe},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Xe}},envmap:{envMap:{value:null},envMapRotation:{value:new Xe},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Xe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Xe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Xe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Xe},normalScale:{value:new xe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Xe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Xe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Xe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Xe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new se(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 D},probesMax:{value:new D},probesResolution:{value:new D}},points:{diffuse:{value:new se(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0},uvTransform:{value:new Xe}},sprite:{diffuse:{value:new se(16777215)},opacity:{value:1},center:{value:new xe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Xe},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0}}},Gn={basic:{uniforms:Ii([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.fog]),vertexShader:We.meshbasic_vert,fragmentShader:We.meshbasic_frag},lambert:{uniforms:Ii([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new se(0)},envMapIntensity:{value:1}}]),vertexShader:We.meshlambert_vert,fragmentShader:We.meshlambert_frag},phong:{uniforms:Ii([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new se(0)},specular:{value:new se(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:We.meshphong_vert,fragmentShader:We.meshphong_frag},standard:{uniforms:Ii([pe.common,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.roughnessmap,pe.metalnessmap,pe.fog,pe.lights,{emissive:{value:new se(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:We.meshphysical_vert,fragmentShader:We.meshphysical_frag},toon:{uniforms:Ii([pe.common,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.gradientmap,pe.fog,pe.lights,{emissive:{value:new se(0)}}]),vertexShader:We.meshtoon_vert,fragmentShader:We.meshtoon_frag},matcap:{uniforms:Ii([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,{matcap:{value:null}}]),vertexShader:We.meshmatcap_vert,fragmentShader:We.meshmatcap_frag},points:{uniforms:Ii([pe.points,pe.fog]),vertexShader:We.points_vert,fragmentShader:We.points_frag},dashed:{uniforms:Ii([pe.common,pe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:We.linedashed_vert,fragmentShader:We.linedashed_frag},depth:{uniforms:Ii([pe.common,pe.displacementmap]),vertexShader:We.depth_vert,fragmentShader:We.depth_frag},normal:{uniforms:Ii([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,{opacity:{value:1}}]),vertexShader:We.meshnormal_vert,fragmentShader:We.meshnormal_frag},sprite:{uniforms:Ii([pe.sprite,pe.fog]),vertexShader:We.sprite_vert,fragmentShader:We.sprite_frag},background:{uniforms:{uvTransform:{value:new Xe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:We.background_vert,fragmentShader:We.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Xe}},vertexShader:We.backgroundCube_vert,fragmentShader:We.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:We.cube_vert,fragmentShader:We.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:We.equirect_vert,fragmentShader:We.equirect_frag},distance:{uniforms:Ii([pe.common,pe.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:We.distance_vert,fragmentShader:We.distance_frag},shadow:{uniforms:Ii([pe.lights,pe.fog,{color:{value:new se(0)},opacity:{value:1}}]),vertexShader:We.shadow_vert,fragmentShader:We.shadow_frag}};Gn.physical={uniforms:Ii([Gn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Xe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Xe},clearcoatNormalScale:{value:new xe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Xe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Xe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Xe},sheen:{value:0},sheenColor:{value:new se(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Xe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Xe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Xe},transmissionSamplerSize:{value:new xe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Xe},attenuationDistance:{value:0},attenuationColor:{value:new se(0)},specularColor:{value:new se(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Xe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Xe},anisotropyVector:{value:new xe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Xe}}]),vertexShader:We.meshphysical_vert,fragmentShader:We.meshphysical_frag};const pc={r:0,b:0,g:0},Sy=new Ze,Rg=new Xe;Rg.set(-1,0,0,0,1,0,0,0,1);function wy(a,e,t,i,n,s){const r=new se(0);let o=n===!0?0:1,c,l,h=null,u=0,d=null;function f(_){let w=_.isScene===!0?_.background:null;if(w&&w.isTexture){const M=_.backgroundBlurriness>0;w=e.get(w,M)}return w}function p(_){let w=!1;const M=f(_);M===null?m(r,o):M&&M.isColor&&(m(M,1),w=!0);const S=a.xr.getEnvironmentBlendMode();S==="additive"?t.buffers.color.setClear(0,0,0,1,s):S==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,s),(a.autoClear||w)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),a.clear(a.autoClearColor,a.autoClearDepth,a.autoClearStencil))}function v(_,w){const M=f(w);M&&(M.isCubeTexture||M.mapping===xl)?(l===void 0&&(l=new De(new sn(1,1,1),new at({name:"BackgroundCubeMaterial",uniforms:xr(Gn.backgroundCube.uniforms),vertexShader:Gn.backgroundCube.vertexShader,fragmentShader:Gn.backgroundCube.fragmentShader,side:Ot,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(S,b,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),l.material.uniforms.envMap.value=M,l.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(Sy.makeRotationFromEuler(w.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Rg),l.material.toneMapped=it.getTransfer(M.colorSpace)!==gt,(h!==M||u!==M.version||d!==a.toneMapping)&&(l.material.needsUpdate=!0,h=M,u=M.version,d=a.toneMapping),l.layers.enableAll(),_.unshift(l,l.geometry,l.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new De(new ki(2,2),new at({name:"BackgroundMaterial",uniforms:xr(Gn.background.uniforms),vertexShader:Gn.background.vertexShader,fragmentShader:Gn.background.fragmentShader,side:qs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=M,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.toneMapped=it.getTransfer(M.colorSpace)!==gt,M.matrixAutoUpdate===!0&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||u!==M.version||d!==a.toneMapping)&&(c.material.needsUpdate=!0,h=M,u=M.version,d=a.toneMapping),c.layers.enableAll(),_.unshift(c,c.geometry,c.material,0,0,null))}function m(_,w){_.getRGB(pc,yg(a)),t.buffers.color.setClear(pc.r,pc.g,pc.b,w,s)}function g(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return r},setClearColor:function(_,w=1){r.set(_),o=w,m(r,o)},getClearAlpha:function(){return o},setClearAlpha:function(_){o=_,m(r,o)},render:p,addToRenderList:v,dispose:g}}function by(a,e){const t=a.getParameter(a.MAX_VERTEX_ATTRIBS),i={},n=d(null);let s=n,r=!1;function o(C,P,X,z,N){let V=!1;const k=u(C,z,X,P);s!==k&&(s=k,l(s.object)),V=f(C,z,X,N),V&&p(C,z,X,N),N!==null&&e.update(N,a.ELEMENT_ARRAY_BUFFER),(V||r)&&(r=!1,M(C,P,X,z),N!==null&&a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,e.get(N).buffer))}function c(){return a.createVertexArray()}function l(C){return a.bindVertexArray(C)}function h(C){return a.deleteVertexArray(C)}function u(C,P,X,z){const N=z.wireframe===!0;let V=i[P.id];V===void 0&&(V={},i[P.id]=V);const k=C.isInstancedMesh===!0?C.id:0;let K=V[k];K===void 0&&(K={},V[k]=K);let ee=K[X.id];ee===void 0&&(ee={},K[X.id]=ee);let J=ee[N];return J===void 0&&(J=d(c()),ee[N]=J),J}function d(C){const P=[],X=[],z=[];for(let N=0;N<t;N++)P[N]=0,X[N]=0,z[N]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:X,attributeDivisors:z,object:C,attributes:{},index:null}}function f(C,P,X,z){const N=s.attributes,V=P.attributes;let k=0;const K=X.getAttributes();for(const ee in K)if(K[ee].location>=0){const ie=N[ee];let oe=V[ee];if(oe===void 0&&(ee==="instanceMatrix"&&C.instanceMatrix&&(oe=C.instanceMatrix),ee==="instanceColor"&&C.instanceColor&&(oe=C.instanceColor)),ie===void 0||ie.attribute!==oe||oe&&ie.data!==oe.data)return!0;k++}return s.attributesNum!==k||s.index!==z}function p(C,P,X,z){const N={},V=P.attributes;let k=0;const K=X.getAttributes();for(const ee in K)if(K[ee].location>=0){let ie=V[ee];ie===void 0&&(ee==="instanceMatrix"&&C.instanceMatrix&&(ie=C.instanceMatrix),ee==="instanceColor"&&C.instanceColor&&(ie=C.instanceColor));const oe={};oe.attribute=ie,ie&&ie.data&&(oe.data=ie.data),N[ee]=oe,k++}s.attributes=N,s.attributesNum=k,s.index=z}function v(){const C=s.newAttributes;for(let P=0,X=C.length;P<X;P++)C[P]=0}function m(C){g(C,0)}function g(C,P){const X=s.newAttributes,z=s.enabledAttributes,N=s.attributeDivisors;X[C]=1,z[C]===0&&(a.enableVertexAttribArray(C),z[C]=1),N[C]!==P&&(a.vertexAttribDivisor(C,P),N[C]=P)}function _(){const C=s.newAttributes,P=s.enabledAttributes;for(let X=0,z=P.length;X<z;X++)P[X]!==C[X]&&(a.disableVertexAttribArray(X),P[X]=0)}function w(C,P,X,z,N,V,k){k===!0?a.vertexAttribIPointer(C,P,X,N,V):a.vertexAttribPointer(C,P,X,z,N,V)}function M(C,P,X,z){v();const N=z.attributes,V=X.getAttributes(),k=P.defaultAttributeValues;for(const K in V){const ee=V[K];if(ee.location>=0){let J=N[K];if(J===void 0&&(K==="instanceMatrix"&&C.instanceMatrix&&(J=C.instanceMatrix),K==="instanceColor"&&C.instanceColor&&(J=C.instanceColor)),J!==void 0){const ie=J.normalized,oe=J.itemSize,Ve=e.get(J);if(Ve===void 0)continue;const Qe=Ve.buffer,qe=Ve.type,Y=Ve.bytesPerElement,re=qe===a.INT||qe===a.UNSIGNED_INT||J.gpuType===Id;if(J.isInterleavedBufferAttribute){const ne=J.data,H=ne.stride,Ae=J.offset;if(ne.isInstancedInterleavedBuffer){for(let Ne=0;Ne<ee.locationSize;Ne++)g(ee.location+Ne,ne.meshPerAttribute);C.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let Ne=0;Ne<ee.locationSize;Ne++)m(ee.location+Ne);a.bindBuffer(a.ARRAY_BUFFER,Qe);for(let Ne=0;Ne<ee.locationSize;Ne++)w(ee.location+Ne,oe/ee.locationSize,qe,ie,H*Y,(Ae+oe/ee.locationSize*Ne)*Y,re)}else{if(J.isInstancedBufferAttribute){for(let ne=0;ne<ee.locationSize;ne++)g(ee.location+ne,J.meshPerAttribute);C.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let ne=0;ne<ee.locationSize;ne++)m(ee.location+ne);a.bindBuffer(a.ARRAY_BUFFER,Qe);for(let ne=0;ne<ee.locationSize;ne++)w(ee.location+ne,oe/ee.locationSize,qe,ie,oe*Y,oe/ee.locationSize*ne*Y,re)}}else if(k!==void 0){const ie=k[K];if(ie!==void 0)switch(ie.length){case 2:a.vertexAttrib2fv(ee.location,ie);break;case 3:a.vertexAttrib3fv(ee.location,ie);break;case 4:a.vertexAttrib4fv(ee.location,ie);break;default:a.vertexAttrib1fv(ee.location,ie)}}}}_()}function S(){A();for(const C in i){const P=i[C];for(const X in P){const z=P[X];for(const N in z){const V=z[N];for(const k in V)h(V[k].object),delete V[k];delete z[N]}}delete i[C]}}function b(C){if(i[C.id]===void 0)return;const P=i[C.id];for(const X in P){const z=P[X];for(const N in z){const V=z[N];for(const k in V)h(V[k].object),delete V[k];delete z[N]}}delete i[C.id]}function T(C){for(const P in i){const X=i[P];for(const z in X){const N=X[z];if(N[C.id]===void 0)continue;const V=N[C.id];for(const k in V)h(V[k].object),delete V[k];delete N[C.id]}}}function x(C){for(const P in i){const X=i[P],z=C.isInstancedMesh===!0?C.id:0,N=X[z];if(N!==void 0){for(const V in N){const k=N[V];for(const K in k)h(k[K].object),delete k[K];delete N[V]}delete X[z],Object.keys(X).length===0&&delete i[P]}}}function A(){I(),r=!0,s!==n&&(s=n,l(s.object))}function I(){n.geometry=null,n.program=null,n.wireframe=!1}return{setup:o,reset:A,resetDefaultState:I,dispose:S,releaseStatesOfGeometry:b,releaseStatesOfObject:x,releaseStatesOfProgram:T,initAttributes:v,enableAttribute:m,disableUnusedAttributes:_}}function Ey(a,e,t){let i;function n(c){i=c}function s(c,l){a.drawArrays(i,c,l),t.update(l,i,1)}function r(c,l,h){h!==0&&(a.drawArraysInstanced(i,c,l,h),t.update(l,i,h))}function o(c,l,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,h);let d=0;for(let f=0;f<h;f++)d+=l[f];t.update(d,i,1)}this.setMode=n,this.render=s,this.renderInstances=r,this.renderMultiDraw=o}function Ay(a,e,t,i){let n;function s(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const T=e.get("EXT_texture_filter_anisotropic");n=a.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function r(T){return!(T!==yi&&i.convert(T)!==a.getParameter(a.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(T){const x=T===Ft&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(T!==nn&&i.convert(T)!==a.getParameter(a.IMPLEMENTATION_COLOR_READ_TYPE)&&T!==Ri&&!x)}function c(T){if(T==="highp"){if(a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.HIGH_FLOAT).precision>0&&a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.MEDIUM_FLOAT).precision>0&&a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp";const h=c(l);h!==l&&(Te("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const u=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&d===!1&&Te("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS),p=a.getParameter(a.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=a.getParameter(a.MAX_TEXTURE_SIZE),m=a.getParameter(a.MAX_CUBE_MAP_TEXTURE_SIZE),g=a.getParameter(a.MAX_VERTEX_ATTRIBS),_=a.getParameter(a.MAX_VERTEX_UNIFORM_VECTORS),w=a.getParameter(a.MAX_VARYING_VECTORS),M=a.getParameter(a.MAX_FRAGMENT_UNIFORM_VECTORS),S=a.getParameter(a.MAX_SAMPLES),b=a.getParameter(a.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:r,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:v,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:_,maxVaryings:w,maxFragmentUniforms:M,maxSamples:S,samples:b}}function Ty(a){const e=this;let t=null,i=0,n=!1,s=!1;const r=new sa,o=new Xe,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||i!==0||n;return n=d,i=u.length,f},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,d){t=h(u,d,0)},this.setState=function(u,d,f){const p=u.clippingPlanes,v=u.clipIntersection,m=u.clipShadows,g=a.get(u);if(!n||p===null||p.length===0||s&&!m)s?h(null):l();else{const _=s?0:i,w=_*4;let M=g.clippingState||null;c.value=M,M=h(p,d,w,f);for(let S=0;S!==w;++S)M[S]=t[S];g.clippingState=M,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=_}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(u,d,f,p){const v=u!==null?u.length:0;let m=null;if(v!==0){if(m=c.value,p!==!0||m===null){const g=f+v*4,_=d.matrixWorldInverse;o.getNormalMatrix(_),(m===null||m.length<g)&&(m=new Float32Array(g));for(let w=0,M=f;w!==v;++w,M+=4)r.copy(u[w]).applyMatrix4(_,o),r.normal.toArray(m,M),m[M+3]=r.constant}c.value=m,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,m}}const Hs=4,qf=[.125,.215,.35,.446,.526,.582],ca=20,Ry=256,zr=new Cn,Yf=new se;let mh=null,gh=0,vh=0,Mh=!1;const Dy=new D;class qu{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,i=.1,n=100,s={}){const{size:r=256,position:o=Dy}=s;mh=this._renderer.getRenderTarget(),gh=this._renderer.getActiveCubeFace(),vh=this._renderer.getActiveMipmapLevel(),Mh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(r);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,i,n,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Zf(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=$f(),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(mh,gh,vh),this._renderer.xr.enabled=Mh,e.scissorTest=!1,Ka(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ya||e.mapping===vr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),mh=this._renderer.getRenderTarget(),gh=this._renderer.getActiveCubeFace(),vh=this._renderer.getActiveMipmapLevel(),Mh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:st,minFilter:st,generateMipmaps:!1,type:Ft,format:yi,colorSpace:Qc,depthBuffer:!1},n=Kf(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Kf(e,t,i);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Cy(s)),this._blurMaterial=Py(s,e,t),this._ggxMaterial=Iy(s,e,t)}return n}_compileMaterial(e){const t=new De(new ut,e);this._renderer.compile(t,zr)}_sceneToCubeUV(e,t,i,n,s){const c=new Vi(90,1,t,i),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(Yf),u.toneMapping=Jn,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(n),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new De(new sn,new mn({name:"PMREM.Background",side:Ot,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,m=v.material;let g=!1;const _=e.background;_?_.isColor&&(m.color.copy(_),e.background=null,g=!0):(m.color.copy(Yf),g=!0);for(let w=0;w<6;w++){const M=w%3;M===0?(c.up.set(0,l[w],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+h[w],s.y,s.z)):M===1?(c.up.set(0,0,l[w]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+h[w],s.z)):(c.up.set(0,l[w],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+h[w]));const S=this._cubeSize;Ka(n,M*S,w>2?S:0,S,S),u.setRenderTarget(n),g&&u.render(v,c),u.render(e,c)}u.toneMapping=f,u.autoClear=d,e.background=_}_textureToCubeUV(e,t){const i=this._renderer,n=e.mapping===ya||e.mapping===vr;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=Zf()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=$f());const s=n?this._cubemapMaterial:this._equirectMaterial,r=this._lodMeshes[0];r.material=s;const o=s.uniforms;o.envMap.value=e;const c=this._cubeSize;Ka(t,0,0,3*c,2*c),i.setRenderTarget(t),i.render(r,zr)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const n=this._lodMeshes.length;for(let s=1;s<n;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=i}_applyGGXFilter(e,t,i){const n=this._renderer,s=this._pingPongRenderTarget,r=this._ggxMaterial,o=this._lodMeshes[i];o.material=r;const c=r.uniforms,l=i/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),u=Math.sqrt(l*l-h*h),d=0+l*1.25,f=u*d,{_lodMax:p}=this,v=this._sizeLods[i],m=3*v*(i>p-Hs?i-p+Hs:0),g=4*(this._cubeSize-v);c.envMap.value=e.texture,c.roughness.value=f,c.mipInt.value=p-t,Ka(s,m,g,3*v,2*v),n.setRenderTarget(s),n.render(o,zr),c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=p-i,Ka(e,m,g,3*v,2*v),n.setRenderTarget(e),n.render(o,zr)}_blur(e,t,i,n,s){const r=this._pingPongRenderTarget;this._halfBlur(e,r,t,i,n,"latitudinal",s),this._halfBlur(r,e,i,i,n,"longitudinal",s)}_halfBlur(e,t,i,n,s,r,o){const c=this._renderer,l=this._blurMaterial;r!=="latitudinal"&&r!=="longitudinal"&&Be("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[n];u.material=l;const d=l.uniforms,f=this._sizeLods[i]-1,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*ca-1),v=s/p,m=isFinite(s)?1+Math.floor(h*v):ca;m>ca&&Te(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${ca}`);const g=[];let _=0;for(let T=0;T<ca;++T){const x=T/v,A=Math.exp(-x*x/2);g.push(A),T===0?_+=A:T<m&&(_+=2*A)}for(let T=0;T<g.length;T++)g[T]=g[T]/_;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=g,d.latitudinal.value=r==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:w}=this;d.dTheta.value=p,d.mipInt.value=w-i;const M=this._sizeLods[n],S=3*M*(n>w-Hs?n-w+Hs:0),b=4*(this._cubeSize-M);Ka(t,S,b,3*M,2*M),c.setRenderTarget(t),c.render(u,zr)}}function Cy(a){const e=[],t=[],i=[];let n=a;const s=a-Hs+1+qf.length;for(let r=0;r<s;r++){const o=Math.pow(2,n);e.push(o);let c=1/o;r>a-Hs?c=qf[r-a+Hs-1]:r===0&&(c=0),t.push(c);const l=1/(o-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,p=6,v=3,m=2,g=1,_=new Float32Array(v*p*f),w=new Float32Array(m*p*f),M=new Float32Array(g*p*f);for(let b=0;b<f;b++){const T=b%3*2/3-1,x=b>2?0:-1,A=[T,x,0,T+2/3,x,0,T+2/3,x+1,0,T,x,0,T+2/3,x+1,0,T,x+1,0];_.set(A,v*p*b),w.set(d,m*p*b);const I=[b,b,b,b,b,b];M.set(I,g*p*b)}const S=new ut;S.setAttribute("position",new et(_,v)),S.setAttribute("uv",new et(w,m)),S.setAttribute("faceIndex",new et(M,g)),i.push(new De(S,null)),n>Hs&&n--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function Kf(a,e,t){const i=new Jt(a,e,t);return i.texture.mapping=xl,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Ka(a,e,t,i,n){a.viewport.set(e,t,i,n),a.scissor.set(e,t,i,n)}function Iy(a,e,t){return new at({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Ry,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${a}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:wl(),fragmentShader:`
|
|
4305
|
+
}`,We={alphahash_fragment:GM,alphahash_pars_fragment:VM,alphamap_fragment:WM,alphamap_pars_fragment:XM,alphatest_fragment:qM,alphatest_pars_fragment:YM,aomap_fragment:KM,aomap_pars_fragment:$M,batching_pars_vertex:ZM,batching_vertex:JM,begin_vertex:jM,beginnormal_vertex:QM,bsdfs:ex,iridescence_fragment:tx,bumpmap_pars_fragment:ix,clipping_planes_fragment:nx,clipping_planes_pars_fragment:sx,clipping_planes_pars_vertex:ax,clipping_planes_vertex:rx,color_fragment:ox,color_pars_fragment:cx,color_pars_vertex:lx,color_vertex:hx,common:ux,cube_uv_reflection_fragment:dx,defaultnormal_vertex:fx,displacementmap_pars_vertex:px,displacementmap_vertex:mx,emissivemap_fragment:gx,emissivemap_pars_fragment:vx,colorspace_fragment:Mx,colorspace_pars_fragment:xx,envmap_fragment:yx,envmap_common_pars_fragment:_x,envmap_pars_fragment:Sx,envmap_pars_vertex:wx,envmap_physical_pars_fragment:Nx,envmap_vertex:bx,fog_vertex:Ex,fog_pars_vertex:Ax,fog_fragment:Tx,fog_pars_fragment:Rx,gradientmap_pars_fragment:Dx,lightmap_pars_fragment:Cx,lights_lambert_fragment:Ix,lights_lambert_pars_fragment:Px,lights_pars_begin:Lx,lights_toon_fragment:Ox,lights_toon_pars_fragment:Ux,lights_phong_fragment:Fx,lights_phong_pars_fragment:kx,lights_physical_fragment:zx,lights_physical_pars_fragment:Hx,lights_fragment_begin:Bx,lights_fragment_maps:Gx,lights_fragment_end:Vx,lightprobes_pars_fragment:Wx,logdepthbuf_fragment:Xx,logdepthbuf_pars_fragment:qx,logdepthbuf_pars_vertex:Yx,logdepthbuf_vertex:Kx,map_fragment:$x,map_pars_fragment:Zx,map_particle_fragment:Jx,map_particle_pars_fragment:jx,metalnessmap_fragment:Qx,metalnessmap_pars_fragment:e3,morphinstance_vertex:t3,morphcolor_vertex:i3,morphnormal_vertex:n3,morphtarget_pars_vertex:s3,morphtarget_vertex:a3,normal_fragment_begin:r3,normal_fragment_maps:o3,normal_pars_fragment:c3,normal_pars_vertex:l3,normal_vertex:h3,normalmap_pars_fragment:u3,clearcoat_normal_fragment_begin:d3,clearcoat_normal_fragment_maps:f3,clearcoat_pars_fragment:p3,iridescence_pars_fragment:m3,opaque_fragment:g3,packing:v3,premultiplied_alpha_fragment:M3,project_vertex:x3,dithering_fragment:y3,dithering_pars_fragment:_3,roughnessmap_fragment:S3,roughnessmap_pars_fragment:w3,shadowmap_pars_fragment:b3,shadowmap_pars_vertex:E3,shadowmap_vertex:A3,shadowmask_pars_fragment:T3,skinbase_vertex:R3,skinning_pars_vertex:D3,skinning_vertex:C3,skinnormal_vertex:I3,specularmap_fragment:P3,specularmap_pars_fragment:L3,tonemapping_fragment:N3,tonemapping_pars_fragment:O3,transmission_fragment:U3,transmission_pars_fragment:F3,uv_pars_fragment:k3,uv_pars_vertex:z3,uv_vertex:H3,worldpos_vertex:B3,background_vert:G3,background_frag:V3,backgroundCube_vert:W3,backgroundCube_frag:X3,cube_vert:q3,cube_frag:Y3,depth_vert:K3,depth_frag:$3,distance_vert:Z3,distance_frag:J3,equirect_vert:j3,equirect_frag:Q3,linedashed_vert:ey,linedashed_frag:ty,meshbasic_vert:iy,meshbasic_frag:ny,meshlambert_vert:sy,meshlambert_frag:ay,meshmatcap_vert:ry,meshmatcap_frag:oy,meshnormal_vert:cy,meshnormal_frag:ly,meshphong_vert:hy,meshphong_frag:uy,meshphysical_vert:dy,meshphysical_frag:fy,meshtoon_vert:py,meshtoon_frag:my,points_vert:gy,points_frag:vy,shadow_vert:My,shadow_frag:xy,sprite_vert:yy,sprite_frag:_y},pe={common:{diffuse:{value:new se(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Xe},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Xe}},envmap:{envMap:{value:null},envMapRotation:{value:new Xe},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Xe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Xe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Xe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Xe},normalScale:{value:new xe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Xe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Xe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Xe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Xe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new se(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 D},probesMax:{value:new D},probesResolution:{value:new D}},points:{diffuse:{value:new se(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0},uvTransform:{value:new Xe}},sprite:{diffuse:{value:new se(16777215)},opacity:{value:1},center:{value:new xe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Xe},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0}}},Gn={basic:{uniforms:Pi([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.fog]),vertexShader:We.meshbasic_vert,fragmentShader:We.meshbasic_frag},lambert:{uniforms:Pi([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new se(0)},envMapIntensity:{value:1}}]),vertexShader:We.meshlambert_vert,fragmentShader:We.meshlambert_frag},phong:{uniforms:Pi([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new se(0)},specular:{value:new se(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:We.meshphong_vert,fragmentShader:We.meshphong_frag},standard:{uniforms:Pi([pe.common,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.roughnessmap,pe.metalnessmap,pe.fog,pe.lights,{emissive:{value:new se(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:We.meshphysical_vert,fragmentShader:We.meshphysical_frag},toon:{uniforms:Pi([pe.common,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.gradientmap,pe.fog,pe.lights,{emissive:{value:new se(0)}}]),vertexShader:We.meshtoon_vert,fragmentShader:We.meshtoon_frag},matcap:{uniforms:Pi([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,{matcap:{value:null}}]),vertexShader:We.meshmatcap_vert,fragmentShader:We.meshmatcap_frag},points:{uniforms:Pi([pe.points,pe.fog]),vertexShader:We.points_vert,fragmentShader:We.points_frag},dashed:{uniforms:Pi([pe.common,pe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:We.linedashed_vert,fragmentShader:We.linedashed_frag},depth:{uniforms:Pi([pe.common,pe.displacementmap]),vertexShader:We.depth_vert,fragmentShader:We.depth_frag},normal:{uniforms:Pi([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,{opacity:{value:1}}]),vertexShader:We.meshnormal_vert,fragmentShader:We.meshnormal_frag},sprite:{uniforms:Pi([pe.sprite,pe.fog]),vertexShader:We.sprite_vert,fragmentShader:We.sprite_frag},background:{uniforms:{uvTransform:{value:new Xe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:We.background_vert,fragmentShader:We.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Xe}},vertexShader:We.backgroundCube_vert,fragmentShader:We.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:We.cube_vert,fragmentShader:We.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:We.equirect_vert,fragmentShader:We.equirect_frag},distance:{uniforms:Pi([pe.common,pe.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:We.distance_vert,fragmentShader:We.distance_frag},shadow:{uniforms:Pi([pe.lights,pe.fog,{color:{value:new se(0)},opacity:{value:1}}]),vertexShader:We.shadow_vert,fragmentShader:We.shadow_frag}};Gn.physical={uniforms:Pi([Gn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Xe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Xe},clearcoatNormalScale:{value:new xe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Xe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Xe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Xe},sheen:{value:0},sheenColor:{value:new se(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Xe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Xe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Xe},transmissionSamplerSize:{value:new xe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Xe},attenuationDistance:{value:0},attenuationColor:{value:new se(0)},specularColor:{value:new se(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Xe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Xe},anisotropyVector:{value:new xe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Xe}}]),vertexShader:We.meshphysical_vert,fragmentShader:We.meshphysical_frag};const pc={r:0,b:0,g:0},Sy=new Ze,Rg=new Xe;Rg.set(-1,0,0,0,1,0,0,0,1);function wy(a,e,t,i,n,s){const r=new se(0);let o=n===!0?0:1,c,l,h=null,u=0,d=null;function f(_){let w=_.isScene===!0?_.background:null;if(w&&w.isTexture){const M=_.backgroundBlurriness>0;w=e.get(w,M)}return w}function p(_){let w=!1;const M=f(_);M===null?m(r,o):M&&M.isColor&&(m(M,1),w=!0);const S=a.xr.getEnvironmentBlendMode();S==="additive"?t.buffers.color.setClear(0,0,0,1,s):S==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,s),(a.autoClear||w)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),a.clear(a.autoClearColor,a.autoClearDepth,a.autoClearStencil))}function v(_,w){const M=f(w);M&&(M.isCubeTexture||M.mapping===xl)?(l===void 0&&(l=new De(new sn(1,1,1),new at({name:"BackgroundCubeMaterial",uniforms:xr(Gn.backgroundCube.uniforms),vertexShader:Gn.backgroundCube.vertexShader,fragmentShader:Gn.backgroundCube.fragmentShader,side:Ot,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(S,b,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),l.material.uniforms.envMap.value=M,l.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(Sy.makeRotationFromEuler(w.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Rg),l.material.toneMapped=nt.getTransfer(M.colorSpace)!==gt,(h!==M||u!==M.version||d!==a.toneMapping)&&(l.material.needsUpdate=!0,h=M,u=M.version,d=a.toneMapping),l.layers.enableAll(),_.unshift(l,l.geometry,l.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new De(new ki(2,2),new at({name:"BackgroundMaterial",uniforms:xr(Gn.background.uniforms),vertexShader:Gn.background.vertexShader,fragmentShader:Gn.background.fragmentShader,side:qs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=M,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.toneMapped=nt.getTransfer(M.colorSpace)!==gt,M.matrixAutoUpdate===!0&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||u!==M.version||d!==a.toneMapping)&&(c.material.needsUpdate=!0,h=M,u=M.version,d=a.toneMapping),c.layers.enableAll(),_.unshift(c,c.geometry,c.material,0,0,null))}function m(_,w){_.getRGB(pc,yg(a)),t.buffers.color.setClear(pc.r,pc.g,pc.b,w,s)}function g(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return r},setClearColor:function(_,w=1){r.set(_),o=w,m(r,o)},getClearAlpha:function(){return o},setClearAlpha:function(_){o=_,m(r,o)},render:p,addToRenderList:v,dispose:g}}function by(a,e){const t=a.getParameter(a.MAX_VERTEX_ATTRIBS),i={},n=d(null);let s=n,r=!1;function o(C,P,X,z,N){let V=!1;const k=u(C,z,X,P);s!==k&&(s=k,l(s.object)),V=f(C,z,X,N),V&&p(C,z,X,N),N!==null&&e.update(N,a.ELEMENT_ARRAY_BUFFER),(V||r)&&(r=!1,M(C,P,X,z),N!==null&&a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,e.get(N).buffer))}function c(){return a.createVertexArray()}function l(C){return a.bindVertexArray(C)}function h(C){return a.deleteVertexArray(C)}function u(C,P,X,z){const N=z.wireframe===!0;let V=i[P.id];V===void 0&&(V={},i[P.id]=V);const k=C.isInstancedMesh===!0?C.id:0;let K=V[k];K===void 0&&(K={},V[k]=K);let ee=K[X.id];ee===void 0&&(ee={},K[X.id]=ee);let J=ee[N];return J===void 0&&(J=d(c()),ee[N]=J),J}function d(C){const P=[],X=[],z=[];for(let N=0;N<t;N++)P[N]=0,X[N]=0,z[N]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:X,attributeDivisors:z,object:C,attributes:{},index:null}}function f(C,P,X,z){const N=s.attributes,V=P.attributes;let k=0;const K=X.getAttributes();for(const ee in K)if(K[ee].location>=0){const ie=N[ee];let oe=V[ee];if(oe===void 0&&(ee==="instanceMatrix"&&C.instanceMatrix&&(oe=C.instanceMatrix),ee==="instanceColor"&&C.instanceColor&&(oe=C.instanceColor)),ie===void 0||ie.attribute!==oe||oe&&ie.data!==oe.data)return!0;k++}return s.attributesNum!==k||s.index!==z}function p(C,P,X,z){const N={},V=P.attributes;let k=0;const K=X.getAttributes();for(const ee in K)if(K[ee].location>=0){let ie=V[ee];ie===void 0&&(ee==="instanceMatrix"&&C.instanceMatrix&&(ie=C.instanceMatrix),ee==="instanceColor"&&C.instanceColor&&(ie=C.instanceColor));const oe={};oe.attribute=ie,ie&&ie.data&&(oe.data=ie.data),N[ee]=oe,k++}s.attributes=N,s.attributesNum=k,s.index=z}function v(){const C=s.newAttributes;for(let P=0,X=C.length;P<X;P++)C[P]=0}function m(C){g(C,0)}function g(C,P){const X=s.newAttributes,z=s.enabledAttributes,N=s.attributeDivisors;X[C]=1,z[C]===0&&(a.enableVertexAttribArray(C),z[C]=1),N[C]!==P&&(a.vertexAttribDivisor(C,P),N[C]=P)}function _(){const C=s.newAttributes,P=s.enabledAttributes;for(let X=0,z=P.length;X<z;X++)P[X]!==C[X]&&(a.disableVertexAttribArray(X),P[X]=0)}function w(C,P,X,z,N,V,k){k===!0?a.vertexAttribIPointer(C,P,X,N,V):a.vertexAttribPointer(C,P,X,z,N,V)}function M(C,P,X,z){v();const N=z.attributes,V=X.getAttributes(),k=P.defaultAttributeValues;for(const K in V){const ee=V[K];if(ee.location>=0){let J=N[K];if(J===void 0&&(K==="instanceMatrix"&&C.instanceMatrix&&(J=C.instanceMatrix),K==="instanceColor"&&C.instanceColor&&(J=C.instanceColor)),J!==void 0){const ie=J.normalized,oe=J.itemSize,Ve=e.get(J);if(Ve===void 0)continue;const Qe=Ve.buffer,qe=Ve.type,Y=Ve.bytesPerElement,re=qe===a.INT||qe===a.UNSIGNED_INT||J.gpuType===Id;if(J.isInterleavedBufferAttribute){const ne=J.data,H=ne.stride,Ae=J.offset;if(ne.isInstancedInterleavedBuffer){for(let Ne=0;Ne<ee.locationSize;Ne++)g(ee.location+Ne,ne.meshPerAttribute);C.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let Ne=0;Ne<ee.locationSize;Ne++)m(ee.location+Ne);a.bindBuffer(a.ARRAY_BUFFER,Qe);for(let Ne=0;Ne<ee.locationSize;Ne++)w(ee.location+Ne,oe/ee.locationSize,qe,ie,H*Y,(Ae+oe/ee.locationSize*Ne)*Y,re)}else{if(J.isInstancedBufferAttribute){for(let ne=0;ne<ee.locationSize;ne++)g(ee.location+ne,J.meshPerAttribute);C.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let ne=0;ne<ee.locationSize;ne++)m(ee.location+ne);a.bindBuffer(a.ARRAY_BUFFER,Qe);for(let ne=0;ne<ee.locationSize;ne++)w(ee.location+ne,oe/ee.locationSize,qe,ie,oe*Y,oe/ee.locationSize*ne*Y,re)}}else if(k!==void 0){const ie=k[K];if(ie!==void 0)switch(ie.length){case 2:a.vertexAttrib2fv(ee.location,ie);break;case 3:a.vertexAttrib3fv(ee.location,ie);break;case 4:a.vertexAttrib4fv(ee.location,ie);break;default:a.vertexAttrib1fv(ee.location,ie)}}}}_()}function S(){A();for(const C in i){const P=i[C];for(const X in P){const z=P[X];for(const N in z){const V=z[N];for(const k in V)h(V[k].object),delete V[k];delete z[N]}}delete i[C]}}function b(C){if(i[C.id]===void 0)return;const P=i[C.id];for(const X in P){const z=P[X];for(const N in z){const V=z[N];for(const k in V)h(V[k].object),delete V[k];delete z[N]}}delete i[C.id]}function T(C){for(const P in i){const X=i[P];for(const z in X){const N=X[z];if(N[C.id]===void 0)continue;const V=N[C.id];for(const k in V)h(V[k].object),delete V[k];delete N[C.id]}}}function x(C){for(const P in i){const X=i[P],z=C.isInstancedMesh===!0?C.id:0,N=X[z];if(N!==void 0){for(const V in N){const k=N[V];for(const K in k)h(k[K].object),delete k[K];delete N[V]}delete X[z],Object.keys(X).length===0&&delete i[P]}}}function A(){I(),r=!0,s!==n&&(s=n,l(s.object))}function I(){n.geometry=null,n.program=null,n.wireframe=!1}return{setup:o,reset:A,resetDefaultState:I,dispose:S,releaseStatesOfGeometry:b,releaseStatesOfObject:x,releaseStatesOfProgram:T,initAttributes:v,enableAttribute:m,disableUnusedAttributes:_}}function Ey(a,e,t){let i;function n(c){i=c}function s(c,l){a.drawArrays(i,c,l),t.update(l,i,1)}function r(c,l,h){h!==0&&(a.drawArraysInstanced(i,c,l,h),t.update(l,i,h))}function o(c,l,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,h);let d=0;for(let f=0;f<h;f++)d+=l[f];t.update(d,i,1)}this.setMode=n,this.render=s,this.renderInstances=r,this.renderMultiDraw=o}function Ay(a,e,t,i){let n;function s(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const T=e.get("EXT_texture_filter_anisotropic");n=a.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function r(T){return!(T!==_i&&i.convert(T)!==a.getParameter(a.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(T){const x=T===kt&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(T!==nn&&i.convert(T)!==a.getParameter(a.IMPLEMENTATION_COLOR_READ_TYPE)&&T!==Di&&!x)}function c(T){if(T==="highp"){if(a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.HIGH_FLOAT).precision>0&&a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.MEDIUM_FLOAT).precision>0&&a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp";const h=c(l);h!==l&&(Te("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const u=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&d===!1&&Te("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS),p=a.getParameter(a.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=a.getParameter(a.MAX_TEXTURE_SIZE),m=a.getParameter(a.MAX_CUBE_MAP_TEXTURE_SIZE),g=a.getParameter(a.MAX_VERTEX_ATTRIBS),_=a.getParameter(a.MAX_VERTEX_UNIFORM_VECTORS),w=a.getParameter(a.MAX_VARYING_VECTORS),M=a.getParameter(a.MAX_FRAGMENT_UNIFORM_VECTORS),S=a.getParameter(a.MAX_SAMPLES),b=a.getParameter(a.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:r,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:v,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:_,maxVaryings:w,maxFragmentUniforms:M,maxSamples:S,samples:b}}function Ty(a){const e=this;let t=null,i=0,n=!1,s=!1;const r=new sa,o=new Xe,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||i!==0||n;return n=d,i=u.length,f},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,d){t=h(u,d,0)},this.setState=function(u,d,f){const p=u.clippingPlanes,v=u.clipIntersection,m=u.clipShadows,g=a.get(u);if(!n||p===null||p.length===0||s&&!m)s?h(null):l();else{const _=s?0:i,w=_*4;let M=g.clippingState||null;c.value=M,M=h(p,d,w,f);for(let S=0;S!==w;++S)M[S]=t[S];g.clippingState=M,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=_}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(u,d,f,p){const v=u!==null?u.length:0;let m=null;if(v!==0){if(m=c.value,p!==!0||m===null){const g=f+v*4,_=d.matrixWorldInverse;o.getNormalMatrix(_),(m===null||m.length<g)&&(m=new Float32Array(g));for(let w=0,M=f;w!==v;++w,M+=4)r.copy(u[w]).applyMatrix4(_,o),r.normal.toArray(m,M),m[M+3]=r.constant}c.value=m,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,m}}const Hs=4,qf=[.125,.215,.35,.446,.526,.582],ca=20,Ry=256,zr=new Cn,Yf=new se;let mh=null,gh=0,vh=0,Mh=!1;const Dy=new D;class qu{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,i=.1,n=100,s={}){const{size:r=256,position:o=Dy}=s;mh=this._renderer.getRenderTarget(),gh=this._renderer.getActiveCubeFace(),vh=this._renderer.getActiveMipmapLevel(),Mh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(r);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,i,n,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Zf(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=$f(),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(mh,gh,vh),this._renderer.xr.enabled=Mh,e.scissorTest=!1,Ka(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ya||e.mapping===vr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),mh=this._renderer.getRenderTarget(),gh=this._renderer.getActiveCubeFace(),vh=this._renderer.getActiveMipmapLevel(),Mh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:st,minFilter:st,generateMipmaps:!1,type:kt,format:_i,colorSpace:Qc,depthBuffer:!1},n=Kf(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Kf(e,t,i);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Cy(s)),this._blurMaterial=Py(s,e,t),this._ggxMaterial=Iy(s,e,t)}return n}_compileMaterial(e){const t=new De(new ut,e);this._renderer.compile(t,zr)}_sceneToCubeUV(e,t,i,n,s){const c=new Vi(90,1,t,i),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(Yf),u.toneMapping=Jn,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(n),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new De(new sn,new mn({name:"PMREM.Background",side:Ot,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,m=v.material;let g=!1;const _=e.background;_?_.isColor&&(m.color.copy(_),e.background=null,g=!0):(m.color.copy(Yf),g=!0);for(let w=0;w<6;w++){const M=w%3;M===0?(c.up.set(0,l[w],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+h[w],s.y,s.z)):M===1?(c.up.set(0,0,l[w]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+h[w],s.z)):(c.up.set(0,l[w],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+h[w]));const S=this._cubeSize;Ka(n,M*S,w>2?S:0,S,S),u.setRenderTarget(n),g&&u.render(v,c),u.render(e,c)}u.toneMapping=f,u.autoClear=d,e.background=_}_textureToCubeUV(e,t){const i=this._renderer,n=e.mapping===ya||e.mapping===vr;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=Zf()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=$f());const s=n?this._cubemapMaterial:this._equirectMaterial,r=this._lodMeshes[0];r.material=s;const o=s.uniforms;o.envMap.value=e;const c=this._cubeSize;Ka(t,0,0,3*c,2*c),i.setRenderTarget(t),i.render(r,zr)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const n=this._lodMeshes.length;for(let s=1;s<n;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=i}_applyGGXFilter(e,t,i){const n=this._renderer,s=this._pingPongRenderTarget,r=this._ggxMaterial,o=this._lodMeshes[i];o.material=r;const c=r.uniforms,l=i/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),u=Math.sqrt(l*l-h*h),d=0+l*1.25,f=u*d,{_lodMax:p}=this,v=this._sizeLods[i],m=3*v*(i>p-Hs?i-p+Hs:0),g=4*(this._cubeSize-v);c.envMap.value=e.texture,c.roughness.value=f,c.mipInt.value=p-t,Ka(s,m,g,3*v,2*v),n.setRenderTarget(s),n.render(o,zr),c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=p-i,Ka(e,m,g,3*v,2*v),n.setRenderTarget(e),n.render(o,zr)}_blur(e,t,i,n,s){const r=this._pingPongRenderTarget;this._halfBlur(e,r,t,i,n,"latitudinal",s),this._halfBlur(r,e,i,i,n,"longitudinal",s)}_halfBlur(e,t,i,n,s,r,o){const c=this._renderer,l=this._blurMaterial;r!=="latitudinal"&&r!=="longitudinal"&&Be("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[n];u.material=l;const d=l.uniforms,f=this._sizeLods[i]-1,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*ca-1),v=s/p,m=isFinite(s)?1+Math.floor(h*v):ca;m>ca&&Te(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${ca}`);const g=[];let _=0;for(let T=0;T<ca;++T){const x=T/v,A=Math.exp(-x*x/2);g.push(A),T===0?_+=A:T<m&&(_+=2*A)}for(let T=0;T<g.length;T++)g[T]=g[T]/_;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=g,d.latitudinal.value=r==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:w}=this;d.dTheta.value=p,d.mipInt.value=w-i;const M=this._sizeLods[n],S=3*M*(n>w-Hs?n-w+Hs:0),b=4*(this._cubeSize-M);Ka(t,S,b,3*M,2*M),c.setRenderTarget(t),c.render(u,zr)}}function Cy(a){const e=[],t=[],i=[];let n=a;const s=a-Hs+1+qf.length;for(let r=0;r<s;r++){const o=Math.pow(2,n);e.push(o);let c=1/o;r>a-Hs?c=qf[r-a+Hs-1]:r===0&&(c=0),t.push(c);const l=1/(o-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,p=6,v=3,m=2,g=1,_=new Float32Array(v*p*f),w=new Float32Array(m*p*f),M=new Float32Array(g*p*f);for(let b=0;b<f;b++){const T=b%3*2/3-1,x=b>2?0:-1,A=[T,x,0,T+2/3,x,0,T+2/3,x+1,0,T,x,0,T+2/3,x+1,0,T,x+1,0];_.set(A,v*p*b),w.set(d,m*p*b);const I=[b,b,b,b,b,b];M.set(I,g*p*b)}const S=new ut;S.setAttribute("position",new et(_,v)),S.setAttribute("uv",new et(w,m)),S.setAttribute("faceIndex",new et(M,g)),i.push(new De(S,null)),n>Hs&&n--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function Kf(a,e,t){const i=new jt(a,e,t);return i.texture.mapping=xl,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Ka(a,e,t,i,n){a.viewport.set(e,t,i,n),a.scissor.set(e,t,i,n)}function Iy(a,e,t){return new at({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Ry,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${a}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:wl(),fragmentShader:`
|
|
4306
4306
|
|
|
4307
4307
|
precision highp float;
|
|
4308
4308
|
precision highp int;
|
|
@@ -4556,7 +4556,7 @@ void main() {
|
|
|
4556
4556
|
gl_Position = vec4( position, 1.0 );
|
|
4557
4557
|
|
|
4558
4558
|
}
|
|
4559
|
-
`}class wo extends
|
|
4559
|
+
`}class wo extends jt{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},n=[i,i,i,i,i,i];this.texture=new Mg(n),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 i={uniforms:{tEquirect:{value:null}},vertexShader:`
|
|
4560
4560
|
|
|
4561
4561
|
varying vec3 vWorldDirection;
|
|
4562
4562
|
|
|
@@ -4591,7 +4591,7 @@ void main() {
|
|
|
4591
4591
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
4592
4592
|
|
|
4593
4593
|
}
|
|
4594
|
-
`},n=new sn(5,5,5),s=new at({name:"CubemapFromEquirect",uniforms:xr(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Ot,blending:Zn});s.uniforms.tEquirect.value=t;const r=new De(n,s),o=t.minFilter;return t.minFilter===da&&(t.minFilter=st),new Zd(1,10,this).update(e,r),t.minFilter=o,r.geometry.dispose(),r.material.dispose(),this}clear(e,t=!0,i=!0,n=!0){const s=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,i,n);e.setRenderTarget(s)}}function Ly(a){let e=new WeakMap,t=new WeakMap,i=null;function n(d,f=!1){return d==null?null:f?r(d):s(d)}function s(d){if(d&&d.isTexture){const f=d.mapping;if(f===Ul||f===Fl)if(e.has(d)){const p=e.get(d).texture;return o(p,d.mapping)}else{const p=d.image;if(p&&p.height>0){const v=new wo(p.height);return v.fromEquirectangularTexture(a,d),e.set(d,v),d.addEventListener("dispose",l),o(v.texture,d.mapping)}else return null}}return d}function r(d){if(d&&d.isTexture){const f=d.mapping,p=f===Ul||f===Fl,v=f===ya||f===vr;if(p||v){let m=t.get(d);const g=m!==void 0?m.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==g)return i===null&&(i=new qu(a)),m=p?i.fromEquirectangular(d,m):i.fromCubemap(d,m),m.texture.pmremVersion=d.pmremVersion,t.set(d,m),m.texture;if(m!==void 0)return m.texture;{const _=d.image;return p&&_&&_.height>0||v&&_&&c(_)?(i===null&&(i=new qu(a)),m=p?i.fromEquirectangular(d):i.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===Ul?d.mapping=ya:f===Fl&&(d.mapping=vr),d}function c(d){let f=0;const p=6;for(let v=0;v<p;v++)d[v]!==void 0&&f++;return f===p}function l(d){const f=d.target;f.removeEventListener("dispose",l);const p=e.get(f);p!==void 0&&(e.delete(f),p.dispose())}function h(d){const f=d.target;f.removeEventListener("dispose",h);const p=t.get(f);p!==void 0&&(t.delete(f),p.dispose())}function u(){e=new WeakMap,t=new WeakMap,i!==null&&(i.dispose(),i=null)}return{get:n,dispose:u}}function Ny(a){const e={};function t(i){if(e[i]!==void 0)return e[i];const n=a.getExtension(i);return e[i]=n,n}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){const n=t(i);return n===null&&or("WebGLRenderer: "+i+" extension not supported."),n}}}function Oy(a,e,t,i){const n={},s=new WeakMap;function r(u){const d=u.target;d.index!==null&&e.remove(d.index);for(const p in d.attributes)e.remove(d.attributes[p]);d.removeEventListener("dispose",r),delete n[d.id];const f=s.get(d);f&&(e.remove(f),s.delete(d)),i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(u,d){return n[d.id]===!0||(d.addEventListener("dispose",r),n[d.id]=!0,t.memory.geometries++),d}function c(u){const d=u.attributes;for(const f in d)e.update(d[f],a.ARRAY_BUFFER)}function l(u){const d=[],f=u.index,p=u.attributes.position;let v=0;if(p===void 0)return;if(f!==null){const _=f.array;v=f.version;for(let w=0,M=_.length;w<M;w+=3){const S=_[w+0],b=_[w+1],T=_[w+2];d.push(S,b,b,T,T,S)}}else{const _=p.array;v=p.version;for(let w=0,M=_.length/3-1;w<M;w+=3){const S=w+0,b=w+1,T=w+2;d.push(S,b,b,T,T,S)}}const m=new(p.count>=65535?Vd:fg)(d,1);m.version=v;const g=s.get(u);g&&e.remove(g),s.set(u,m)}function h(u){const d=s.get(u);if(d){const f=u.index;f!==null&&d.version<f.version&&l(u)}else l(u);return s.get(u)}return{get:o,update:c,getWireframeAttribute:h}}function Uy(a,e,t){let i;function n(u){i=u}let s,r;function o(u){s=u.type,r=u.bytesPerElement}function c(u,d){a.drawElements(i,d,s,u*r),t.update(d,i,1)}function l(u,d,f){f!==0&&(a.drawElementsInstanced(i,d,s,u*r,f),t.update(d,i,f))}function h(u,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,d,0,s,u,0,f);let v=0;for(let m=0;m<f;m++)v+=d[m];t.update(v,i,1)}this.setMode=n,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h}function Fy(a){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,r,o){switch(t.calls++,r){case a.TRIANGLES:t.triangles+=o*(s/3);break;case a.LINES:t.lines+=o*(s/2);break;case a.LINE_STRIP:t.lines+=o*(s-1);break;case a.LINE_LOOP:t.lines+=o*s;break;case a.POINTS:t.points+=o*s;break;default:Be("WebGLInfo: Unknown draw mode:",r);break}}function n(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:n,update:i}}function ky(a,e,t){const i=new WeakMap,n=new
|
|
4594
|
+
`},n=new sn(5,5,5),s=new at({name:"CubemapFromEquirect",uniforms:xr(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Ot,blending:Zn});s.uniforms.tEquirect.value=t;const r=new De(n,s),o=t.minFilter;return t.minFilter===da&&(t.minFilter=st),new Zd(1,10,this).update(e,r),t.minFilter=o,r.geometry.dispose(),r.material.dispose(),this}clear(e,t=!0,i=!0,n=!0){const s=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,i,n);e.setRenderTarget(s)}}function Ly(a){let e=new WeakMap,t=new WeakMap,i=null;function n(d,f=!1){return d==null?null:f?r(d):s(d)}function s(d){if(d&&d.isTexture){const f=d.mapping;if(f===Ul||f===Fl)if(e.has(d)){const p=e.get(d).texture;return o(p,d.mapping)}else{const p=d.image;if(p&&p.height>0){const v=new wo(p.height);return v.fromEquirectangularTexture(a,d),e.set(d,v),d.addEventListener("dispose",l),o(v.texture,d.mapping)}else return null}}return d}function r(d){if(d&&d.isTexture){const f=d.mapping,p=f===Ul||f===Fl,v=f===ya||f===vr;if(p||v){let m=t.get(d);const g=m!==void 0?m.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==g)return i===null&&(i=new qu(a)),m=p?i.fromEquirectangular(d,m):i.fromCubemap(d,m),m.texture.pmremVersion=d.pmremVersion,t.set(d,m),m.texture;if(m!==void 0)return m.texture;{const _=d.image;return p&&_&&_.height>0||v&&_&&c(_)?(i===null&&(i=new qu(a)),m=p?i.fromEquirectangular(d):i.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===Ul?d.mapping=ya:f===Fl&&(d.mapping=vr),d}function c(d){let f=0;const p=6;for(let v=0;v<p;v++)d[v]!==void 0&&f++;return f===p}function l(d){const f=d.target;f.removeEventListener("dispose",l);const p=e.get(f);p!==void 0&&(e.delete(f),p.dispose())}function h(d){const f=d.target;f.removeEventListener("dispose",h);const p=t.get(f);p!==void 0&&(t.delete(f),p.dispose())}function u(){e=new WeakMap,t=new WeakMap,i!==null&&(i.dispose(),i=null)}return{get:n,dispose:u}}function Ny(a){const e={};function t(i){if(e[i]!==void 0)return e[i];const n=a.getExtension(i);return e[i]=n,n}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){const n=t(i);return n===null&&or("WebGLRenderer: "+i+" extension not supported."),n}}}function Oy(a,e,t,i){const n={},s=new WeakMap;function r(u){const d=u.target;d.index!==null&&e.remove(d.index);for(const p in d.attributes)e.remove(d.attributes[p]);d.removeEventListener("dispose",r),delete n[d.id];const f=s.get(d);f&&(e.remove(f),s.delete(d)),i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(u,d){return n[d.id]===!0||(d.addEventListener("dispose",r),n[d.id]=!0,t.memory.geometries++),d}function c(u){const d=u.attributes;for(const f in d)e.update(d[f],a.ARRAY_BUFFER)}function l(u){const d=[],f=u.index,p=u.attributes.position;let v=0;if(p===void 0)return;if(f!==null){const _=f.array;v=f.version;for(let w=0,M=_.length;w<M;w+=3){const S=_[w+0],b=_[w+1],T=_[w+2];d.push(S,b,b,T,T,S)}}else{const _=p.array;v=p.version;for(let w=0,M=_.length/3-1;w<M;w+=3){const S=w+0,b=w+1,T=w+2;d.push(S,b,b,T,T,S)}}const m=new(p.count>=65535?Vd:fg)(d,1);m.version=v;const g=s.get(u);g&&e.remove(g),s.set(u,m)}function h(u){const d=s.get(u);if(d){const f=u.index;f!==null&&d.version<f.version&&l(u)}else l(u);return s.get(u)}return{get:o,update:c,getWireframeAttribute:h}}function Uy(a,e,t){let i;function n(u){i=u}let s,r;function o(u){s=u.type,r=u.bytesPerElement}function c(u,d){a.drawElements(i,d,s,u*r),t.update(d,i,1)}function l(u,d,f){f!==0&&(a.drawElementsInstanced(i,d,s,u*r,f),t.update(d,i,f))}function h(u,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,d,0,s,u,0,f);let v=0;for(let m=0;m<f;m++)v+=d[m];t.update(v,i,1)}this.setMode=n,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h}function Fy(a){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,r,o){switch(t.calls++,r){case a.TRIANGLES:t.triangles+=o*(s/3);break;case a.LINES:t.lines+=o*(s/2);break;case a.LINE_STRIP:t.lines+=o*(s-1);break;case a.LINE_LOOP:t.lines+=o*s;break;case a.POINTS:t.points+=o*s;break;default:Be("WebGLInfo: Unknown draw mode:",r);break}}function n(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:n,update:i}}function ky(a,e,t){const i=new WeakMap,n=new it;function s(r,o,c){const l=r.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=i.get(o);if(d===void 0||d.count!==u){let A=function(){T.dispose(),i.delete(o),o.removeEventListener("dispose",A)};d!==void 0&&d.texture.dispose();const f=o.morphAttributes.position!==void 0,p=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],g=o.morphAttributes.normal||[],_=o.morphAttributes.color||[];let w=0;f===!0&&(w=1),p===!0&&(w=2),v===!0&&(w=3);let M=o.attributes.position.count*w,S=1;M>e.maxTextureSize&&(S=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);const b=new Float32Array(M*S*4*u),T=new hg(b,M,S,u);T.type=Di,T.needsUpdate=!0;const x=w*4;for(let I=0;I<u;I++){const C=m[I],P=g[I],X=_[I],z=M*S*4*I;for(let N=0;N<C.count;N++){const V=N*x;f===!0&&(n.fromBufferAttribute(C,N),b[z+V+0]=n.x,b[z+V+1]=n.y,b[z+V+2]=n.z,b[z+V+3]=0),p===!0&&(n.fromBufferAttribute(P,N),b[z+V+4]=n.x,b[z+V+5]=n.y,b[z+V+6]=n.z,b[z+V+7]=0),v===!0&&(n.fromBufferAttribute(X,N),b[z+V+8]=n.x,b[z+V+9]=n.y,b[z+V+10]=n.z,b[z+V+11]=X.itemSize===4?n.w:1)}}d={count:u,texture:T,size:new xe(M,S)},i.set(o,d),o.addEventListener("dispose",A)}if(r.isInstancedMesh===!0&&r.morphTexture!==null)c.getUniforms().setValue(a,"morphTexture",r.morphTexture,t);else{let f=0;for(let v=0;v<l.length;v++)f+=l[v];const p=o.morphTargetsRelative?1:1-f;c.getUniforms().setValue(a,"morphTargetBaseInfluence",p),c.getUniforms().setValue(a,"morphTargetInfluences",l)}c.getUniforms().setValue(a,"morphTargetsTexture",d.texture,t),c.getUniforms().setValue(a,"morphTargetsTextureSize",d.size)}return{update:s}}function zy(a,e,t,i,n){let s=new WeakMap;function r(l){const h=n.render.frame,u=l.geometry,d=e.get(l,u);if(s.get(d)!==h&&(e.update(d),s.set(d,h)),l.isInstancedMesh&&(l.hasEventListener("dispose",c)===!1&&l.addEventListener("dispose",c),s.get(l)!==h&&(t.update(l.instanceMatrix,a.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,a.ARRAY_BUFFER),s.set(l,h))),l.isSkinnedMesh){const f=l.skeleton;s.get(f)!==h&&(f.update(),s.set(f,h))}return d}function o(){s=new WeakMap}function c(l){const h=l.target;h.removeEventListener("dispose",c),i.releaseStatesOfObject(h),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:r,dispose:o}}const Hy={[$m]:"LINEAR_TONE_MAPPING",[Zm]:"REINHARD_TONE_MAPPING",[Jm]:"CINEON_TONE_MAPPING",[jm]:"ACES_FILMIC_TONE_MAPPING",[eg]:"AGX_TONE_MAPPING",[tg]:"NEUTRAL_TONE_MAPPING",[Qm]:"CUSTOM_TONE_MAPPING"};function By(a,e,t,i,n,s){const r=new jt(e,t,{type:a,depthBuffer:n,stencilBuffer:s,samples:i?4:0,depthTexture:n?new Ys(e,t):void 0}),o=new jt(e,t,{type:kt,depthBuffer:!1,stencilBuffer:!1}),c=new ut;c.setAttribute("position",new xt([-1,3,0,-1,-1,0,3,-1,0],3)),c.setAttribute("uv",new xt([0,2,0,0,2,0],2));const l=new _g({uniforms:{tDiffuse:{value:null}},vertexShader:`
|
|
4595
4595
|
precision highp float;
|
|
4596
4596
|
|
|
4597
4597
|
uniform mat4 modelViewMatrix;
|
|
@@ -4637,14 +4637,14 @@ void main() {
|
|
|
4637
4637
|
#ifdef SRGB_TRANSFER
|
|
4638
4638
|
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
|
4639
4639
|
#endif
|
|
4640
|
-
}`,depthTest:!1,depthWrite:!1}),h=new De(c,l),u=new Cn(-1,1,1,-1,0,1);let d=null,f=null,p=!1,v,m=null,g=[],_=!1;this.setSize=function(w,M){r.setSize(w,M),o.setSize(w,M);for(let S=0;S<g.length;S++){const b=g[S];b.setSize&&b.setSize(w,M)}},this.setEffects=function(w){g=w,_=g.length>0&&g[0].isRenderPass===!0;const M=r.width,S=r.height;for(let b=0;b<g.length;b++){const T=g[b];T.setSize&&T.setSize(M,S)}},this.begin=function(w,M){if(p||w.toneMapping===Jn&&g.length===0)return!1;if(m=M,M!==null){const S=M.width,b=M.height;(r.width!==S||r.height!==b)&&this.setSize(S,b)}return _===!1&&w.setRenderTarget(r),v=w.toneMapping,w.toneMapping=Jn,!0},this.hasRenderPass=function(){return _},this.end=function(w,M){w.toneMapping=v,p=!0;let S=r,b=o;for(let T=0;T<g.length;T++){const x=g[T];if(x.enabled!==!1&&(x.render(w,b,S,M),x.needsSwap!==!1)){const A=S;S=b,b=A}}if(d!==w.outputColorSpace||f!==w.toneMapping){d=w.outputColorSpace,f=w.toneMapping,l.defines={},
|
|
4640
|
+
}`,depthTest:!1,depthWrite:!1}),h=new De(c,l),u=new Cn(-1,1,1,-1,0,1);let d=null,f=null,p=!1,v,m=null,g=[],_=!1;this.setSize=function(w,M){r.setSize(w,M),o.setSize(w,M);for(let S=0;S<g.length;S++){const b=g[S];b.setSize&&b.setSize(w,M)}},this.setEffects=function(w){g=w,_=g.length>0&&g[0].isRenderPass===!0;const M=r.width,S=r.height;for(let b=0;b<g.length;b++){const T=g[b];T.setSize&&T.setSize(M,S)}},this.begin=function(w,M){if(p||w.toneMapping===Jn&&g.length===0)return!1;if(m=M,M!==null){const S=M.width,b=M.height;(r.width!==S||r.height!==b)&&this.setSize(S,b)}return _===!1&&w.setRenderTarget(r),v=w.toneMapping,w.toneMapping=Jn,!0},this.hasRenderPass=function(){return _},this.end=function(w,M){w.toneMapping=v,p=!0;let S=r,b=o;for(let T=0;T<g.length;T++){const x=g[T];if(x.enabled!==!1&&(x.render(w,b,S,M),x.needsSwap!==!1)){const A=S;S=b,b=A}}if(d!==w.outputColorSpace||f!==w.toneMapping){d=w.outputColorSpace,f=w.toneMapping,l.defines={},nt.getTransfer(d)===gt&&(l.defines.SRGB_TRANSFER="");const T=Hy[f];T&&(l.defines[T]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=S.texture,w.setRenderTarget(m),w.render(h,u),m=null,p=!1},this.isCompositing=function(){return p},this.dispose=function(){r.depthTexture&&r.depthTexture.dispose(),r.dispose(),o.dispose(),c.dispose(),l.dispose()}}const Dg=new xi,Yu=new Ys(1,1),Cg=new hg,Ig=new ug,Pg=new Mg,Jf=[],jf=[],Qf=new Float32Array(16),ep=new Float32Array(9),tp=new Float32Array(4);function Er(a,e,t){const i=a[0];if(i<=0||i>0)return a;const n=e*t;let s=Jf[n];if(s===void 0&&(s=new Float32Array(n),Jf[n]=s),e!==0){i.toArray(s,0);for(let r=1,o=0;r!==e;++r)o+=t,a[r].toArray(s,o)}return s}function hi(a,e){if(a.length!==e.length)return!1;for(let t=0,i=a.length;t<i;t++)if(a[t]!==e[t])return!1;return!0}function ui(a,e){for(let t=0,i=e.length;t<i;t++)a[t]=e[t]}function bl(a,e){let t=jf[e];t===void 0&&(t=new Int32Array(e),jf[e]=t);for(let i=0;i!==e;++i)t[i]=a.allocateTextureUnit();return t}function Gy(a,e){const t=this.cache;t[0]!==e&&(a.uniform1f(this.addr,e),t[0]=e)}function Vy(a,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(a.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(hi(t,e))return;a.uniform2fv(this.addr,e),ui(t,e)}}function Wy(a,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(a.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)&&(a.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(hi(t,e))return;a.uniform3fv(this.addr,e),ui(t,e)}}function Xy(a,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)&&(a.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(hi(t,e))return;a.uniform4fv(this.addr,e),ui(t,e)}}function qy(a,e){const t=this.cache,i=e.elements;if(i===void 0){if(hi(t,e))return;a.uniformMatrix2fv(this.addr,!1,e),ui(t,e)}else{if(hi(t,i))return;tp.set(i),a.uniformMatrix2fv(this.addr,!1,tp),ui(t,i)}}function Yy(a,e){const t=this.cache,i=e.elements;if(i===void 0){if(hi(t,e))return;a.uniformMatrix3fv(this.addr,!1,e),ui(t,e)}else{if(hi(t,i))return;ep.set(i),a.uniformMatrix3fv(this.addr,!1,ep),ui(t,i)}}function Ky(a,e){const t=this.cache,i=e.elements;if(i===void 0){if(hi(t,e))return;a.uniformMatrix4fv(this.addr,!1,e),ui(t,e)}else{if(hi(t,i))return;Qf.set(i),a.uniformMatrix4fv(this.addr,!1,Qf),ui(t,i)}}function $y(a,e){const t=this.cache;t[0]!==e&&(a.uniform1i(this.addr,e),t[0]=e)}function Zy(a,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(a.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(hi(t,e))return;a.uniform2iv(this.addr,e),ui(t,e)}}function Jy(a,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(a.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(hi(t,e))return;a.uniform3iv(this.addr,e),ui(t,e)}}function jy(a,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)&&(a.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(hi(t,e))return;a.uniform4iv(this.addr,e),ui(t,e)}}function Qy(a,e){const t=this.cache;t[0]!==e&&(a.uniform1ui(this.addr,e),t[0]=e)}function e_(a,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(a.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(hi(t,e))return;a.uniform2uiv(this.addr,e),ui(t,e)}}function t_(a,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(a.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(hi(t,e))return;a.uniform3uiv(this.addr,e),ui(t,e)}}function i_(a,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)&&(a.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(hi(t,e))return;a.uniform4uiv(this.addr,e),ui(t,e)}}function n_(a,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(a.uniform1i(this.addr,n),i[0]=n);let s;this.type===a.SAMPLER_2D_SHADOW?(Yu.compareFunction=t.isReversedDepthBuffer()?kd:Fd,s=Yu):s=Dg,t.setTexture2D(e||s,n)}function s_(a,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(a.uniform1i(this.addr,n),i[0]=n),t.setTexture3D(e||Ig,n)}function a_(a,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(a.uniform1i(this.addr,n),i[0]=n),t.setTextureCube(e||Pg,n)}function r_(a,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(a.uniform1i(this.addr,n),i[0]=n),t.setTexture2DArray(e||Cg,n)}function o_(a){switch(a){case 5126:return Gy;case 35664:return Vy;case 35665:return Wy;case 35666:return Xy;case 35674:return qy;case 35675:return Yy;case 35676:return Ky;case 5124:case 35670:return $y;case 35667:case 35671:return Zy;case 35668:case 35672:return Jy;case 35669:case 35673:return jy;case 5125:return Qy;case 36294:return e_;case 36295:return t_;case 36296:return i_;case 35678:case 36198:case 36298:case 36306:case 35682:return n_;case 35679:case 36299:case 36307:return s_;case 35680:case 36300:case 36308:case 36293:return a_;case 36289:case 36303:case 36311:case 36292:return r_}}function c_(a,e){a.uniform1fv(this.addr,e)}function l_(a,e){const t=Er(e,this.size,2);a.uniform2fv(this.addr,t)}function h_(a,e){const t=Er(e,this.size,3);a.uniform3fv(this.addr,t)}function u_(a,e){const t=Er(e,this.size,4);a.uniform4fv(this.addr,t)}function d_(a,e){const t=Er(e,this.size,4);a.uniformMatrix2fv(this.addr,!1,t)}function f_(a,e){const t=Er(e,this.size,9);a.uniformMatrix3fv(this.addr,!1,t)}function p_(a,e){const t=Er(e,this.size,16);a.uniformMatrix4fv(this.addr,!1,t)}function m_(a,e){a.uniform1iv(this.addr,e)}function g_(a,e){a.uniform2iv(this.addr,e)}function v_(a,e){a.uniform3iv(this.addr,e)}function M_(a,e){a.uniform4iv(this.addr,e)}function x_(a,e){a.uniform1uiv(this.addr,e)}function y_(a,e){a.uniform2uiv(this.addr,e)}function __(a,e){a.uniform3uiv(this.addr,e)}function S_(a,e){a.uniform4uiv(this.addr,e)}function w_(a,e,t){const i=this.cache,n=e.length,s=bl(t,n);hi(i,s)||(a.uniform1iv(this.addr,s),ui(i,s));let r;this.type===a.SAMPLER_2D_SHADOW?r=Yu:r=Dg;for(let o=0;o!==n;++o)t.setTexture2D(e[o]||r,s[o])}function b_(a,e,t){const i=this.cache,n=e.length,s=bl(t,n);hi(i,s)||(a.uniform1iv(this.addr,s),ui(i,s));for(let r=0;r!==n;++r)t.setTexture3D(e[r]||Ig,s[r])}function E_(a,e,t){const i=this.cache,n=e.length,s=bl(t,n);hi(i,s)||(a.uniform1iv(this.addr,s),ui(i,s));for(let r=0;r!==n;++r)t.setTextureCube(e[r]||Pg,s[r])}function A_(a,e,t){const i=this.cache,n=e.length,s=bl(t,n);hi(i,s)||(a.uniform1iv(this.addr,s),ui(i,s));for(let r=0;r!==n;++r)t.setTexture2DArray(e[r]||Cg,s[r])}function T_(a){switch(a){case 5126:return c_;case 35664:return l_;case 35665:return h_;case 35666:return u_;case 35674:return d_;case 35675:return f_;case 35676:return p_;case 5124:case 35670:return m_;case 35667:case 35671:return g_;case 35668:case 35672:return v_;case 35669:case 35673:return M_;case 5125:return x_;case 36294:return y_;case 36295:return __;case 36296:return S_;case 35678:case 36198:case 36298:case 36306:case 35682:return w_;case 35679:case 36299:case 36307:return b_;case 35680:case 36300:case 36308:case 36293:return E_;case 36289:case 36303:case 36311:case 36292:return A_}}class R_{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=o_(t.type)}}class D_{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=T_(t.type)}}class C_{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const n=this.seq;for(let s=0,r=n.length;s!==r;++s){const o=n[s];o.setValue(e,t[o.id],i)}}}const xh=/(\w+)(\])?(\[|\.)?/g;function ip(a,e){a.seq.push(e),a.map[e.id]=e}function I_(a,e,t){const i=a.name,n=i.length;for(xh.lastIndex=0;;){const s=xh.exec(i),r=xh.lastIndex;let o=s[1];const c=s[2]==="]",l=s[3];if(c&&(o=o|0),l===void 0||l==="["&&r+2===n){ip(t,l===void 0?new R_(o,a,e):new D_(o,a,e));break}else{let u=t.map[o];u===void 0&&(u=new C_(o),ip(t,u)),t=u}}}class Bc{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){const o=e.getActiveUniform(t,r),c=e.getUniformLocation(t,o.name);I_(o,c,this)}const n=[],s=[];for(const r of this.seq)r.type===e.SAMPLER_2D_SHADOW||r.type===e.SAMPLER_CUBE_SHADOW||r.type===e.SAMPLER_2D_ARRAY_SHADOW?n.push(r):s.push(r);n.length>0&&(this.seq=n.concat(s))}setValue(e,t,i,n){const s=this.map[t];s!==void 0&&s.setValue(e,i,n)}setOptional(e,t,i){const n=t[i];n!==void 0&&this.setValue(e,i,n)}static upload(e,t,i,n){for(let s=0,r=t.length;s!==r;++s){const o=t[s],c=i[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,n)}}static seqWithValue(e,t){const i=[];for(let n=0,s=e.length;n!==s;++n){const r=e[n];r.id in t&&i.push(r)}return i}}function np(a,e,t){const i=a.createShader(e);return a.shaderSource(i,t),a.compileShader(i),i}const P_=37297;let L_=0;function N_(a,e){const t=a.split(`
|
|
4641
4641
|
`),i=[],n=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let r=n;r<s;r++){const o=r+1;i.push(`${o===e?">":" "} ${o}: ${t[r]}`)}return i.join(`
|
|
4642
|
-
`)}const sp=new Xe;function O_(a){
|
|
4642
|
+
`)}const sp=new Xe;function O_(a){nt._getMatrix(sp,nt.workingColorSpace,a);const e=`mat3( ${sp.elements.map(t=>t.toFixed(4))} )`;switch(nt.getTransfer(a)){case el:return[e,"LinearTransferOETF"];case gt:return[e,"sRGBTransferOETF"];default:return Te("WebGLProgram: Unsupported color space: ",a),[e,"LinearTransferOETF"]}}function ap(a,e,t){const i=a.getShaderParameter(e,a.COMPILE_STATUS),s=(a.getShaderInfoLog(e)||"").trim();if(i&&s==="")return"";const r=/ERROR: 0:(\d+)/.exec(s);if(r){const o=parseInt(r[1]);return t.toUpperCase()+`
|
|
4643
4643
|
|
|
4644
4644
|
`+s+`
|
|
4645
4645
|
|
|
4646
4646
|
`+N_(a.getShaderSource(e),o)}else return s}function U_(a,e){const t=O_(e);return[`vec4 ${a}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
|
4647
|
-
`)}const F_={[$m]:"Linear",[Zm]:"Reinhard",[Jm]:"Cineon",[jm]:"ACESFilmic",[eg]:"AgX",[tg]:"Neutral",[Qm]:"Custom"};function k_(a,e){const t=F_[e];return t===void 0?(Te("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+a+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+a+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const mc=new D;function z_(){
|
|
4647
|
+
`)}const F_={[$m]:"Linear",[Zm]:"Reinhard",[Jm]:"Cineon",[jm]:"ACESFilmic",[eg]:"AgX",[tg]:"Neutral",[Qm]:"Custom"};function k_(a,e){const t=F_[e];return t===void 0?(Te("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+a+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+a+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const mc=new D;function z_(){nt.getLuminanceCoefficients(mc);const a=mc.x.toFixed(4),e=mc.y.toFixed(4),t=mc.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${a}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
|
4648
4648
|
`)}function H_(a){return[a.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",a.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Jr).join(`
|
|
4649
4649
|
`)}function B_(a){const e=[];for(const t in a){const i=a[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
|
|
4650
4650
|
`)}function G_(a,e){const t={},i=a.getProgramParameter(e,a.ACTIVE_ATTRIBUTES);for(let n=0;n<i;n++){const s=a.getActiveAttrib(e,n),r=s.name;let o=1;s.type===a.FLOAT_MAT2&&(o=2),s.type===a.FLOAT_MAT3&&(o=3),s.type===a.FLOAT_MAT4&&(o=4),t[r]={type:s.type,location:a.getAttribLocation(e,r),locationSize:o}}return t}function Jr(a){return a!==""}function rp(a,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return a.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 op(a,e){return a.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const V_=/^[ \t]*#include +<([\w\d./]+)>/gm;function Ku(a){return a.replace(V_,X_)}const W_=new Map;function X_(a,e){let t=We[e];if(t===void 0){const i=W_.get(e);if(i!==void 0)t=We[i],Te('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Ku(t)}const q_=/#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 cp(a){return a.replace(q_,Y_)}function Y_(a,e,t,i){let n="";for(let s=parseInt(e);s<parseInt(t);s++)n+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return n}function lp(a){let e=`precision ${a.precision} float;
|
|
@@ -4688,7 +4688,7 @@ Material Type: `+C.type+`
|
|
|
4688
4688
|
|
|
4689
4689
|
Program Info Log: `+N+`
|
|
4690
4690
|
`+J+`
|
|
4691
|
-
`+ie)}else N!==""?Te("WebGLProgram: Program Info Log:",N):(V===""||k==="")&&(ee=!1);ee&&(C.diagnostics={runnable:K,programLog:N,vertexShader:{log:V,prefix:m},fragmentShader:{log:k,prefix:g}})}n.deleteShader(S),n.deleteShader(b),x=new Bc(n,v),A=G_(n,v)}let x;this.getUniforms=function(){return x===void 0&&T(this),x};let A;this.getAttributes=function(){return A===void 0&&T(this),A};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=n.getProgramParameter(v,P_)),I},this.destroy=function(){i.releaseStatesOfProgram(this),n.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=L_++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=S,this.fragmentShader=b,this}let sS=0;class aS{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,i){const n=this._getShaderCacheForMaterial(e);return n.has(t)===!1&&(n.add(t),t.usedTimes++),n.has(i)===!1&&(n.add(i),i.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.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 i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new rS(e),t.set(e,i)),i}}class rS{constructor(e){this.id=sS++,this.code=e,this.usedTimes=0}}function oS(a){return a===_a||a===$c||a===Zc}function cS(a,e,t,i,n,s){const r=new Bd,o=new aS,c=new Set,l=[],h=new Map,u=i.logarithmicDepthBuffer;let d=i.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 p(x){return c.add(x),x===0?"uv":`uv${x}`}function v(x,A,I,C,P,X){const z=C.fog,N=P.geometry,V=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?C.environment:null,k=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,K=e.get(x.envMap||V,k),ee=K&&K.mapping===xl?K.image.height:null,J=f[x.type];x.precision!==null&&(d=i.getMaxPrecision(x.precision),d!==x.precision&&Te("WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead."));const ie=N.morphAttributes.position||N.morphAttributes.normal||N.morphAttributes.color,oe=ie!==void 0?ie.length:0;let Ve=0;N.morphAttributes.position!==void 0&&(Ve=1),N.morphAttributes.normal!==void 0&&(Ve=2),N.morphAttributes.color!==void 0&&(Ve=3);let Qe,qe,Y,re;if(J){const Se=Gn[J];Qe=Se.vertexShader,qe=Se.fragmentShader}else{Qe=x.vertexShader,qe=x.fragmentShader;const Se=o.getVertexShaderStage(x),Bt=o.getFragmentShaderStage(x);o.update(x,Se,Bt),Y=Se.id,re=Bt.id}const ne=a.getRenderTarget(),H=a.state.buffers.depth.getReversed(),Ae=P.isInstancedMesh===!0,Ne=P.isBatchedMesh===!0,Ce=!!x.map,ye=!!x.matcap,Fe=!!K,ke=!!x.aoMap,ze=!!x.lightMap,ft=!!x.bumpMap&&x.wireframe===!1,pt=!!x.normalMap,zt=!!x.displacementMap,Lt=!!x.emissiveMap,Ht=!!x.metalnessMap,Qt=!!x.roughnessMap,O=x.anisotropy>0,zi=x.clearcoat>0,mt=x.dispersion>0,R=x.iridescence>0,y=x.sheen>0,F=x.transmission>0,W=O&&!!x.anisotropyMap,$=zi&&!!x.clearcoatMap,ae=zi&&!!x.clearcoatNormalMap,le=zi&&!!x.clearcoatRoughnessMap,Z=R&&!!x.iridescenceMap,Q=R&&!!x.iridescenceThicknessMap,he=y&&!!x.sheenColorMap,Ie=y&&!!x.sheenRoughnessMap,fe=!!x.specularMap,ue=!!x.specularColorMap,Ue=!!x.specularIntensityMap,He=F&&!!x.transmissionMap,Ke=F&&!!x.thicknessMap,L=!!x.gradientMap,ce=!!x.alphaMap,j=x.alphaTest>0,de=!!x.alphaHash,ve=!!x.extensions;let te=Jn;x.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(te=a.toneMapping);const Re={shaderID:J,shaderType:x.type,shaderName:x.name,vertexShader:Qe,fragmentShader:qe,defines:x.defines,customVertexShaderID:Y,customFragmentShaderID:re,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,batching:Ne,batchingColor:Ne&&P._colorsTexture!==null,instancing:Ae,instancingColor:Ae&&P.instanceColor!==null,instancingMorph:Ae&&P.morphTexture!==null,outputColorSpace:ne===null?a.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:it.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Ce,matcap:ye,envMap:Fe,envMapMode:Fe&&K.mapping,envMapCubeUVHeight:ee,aoMap:ke,lightMap:ze,bumpMap:ft,normalMap:pt,displacementMap:zt,emissiveMap:Lt,normalMapObjectSpace:pt&&x.normalMapType===iv,normalMapTangentSpace:pt&&x.normalMapType===jc,packedNormalMap:pt&&x.normalMapType===jc&&oS(x.normalMap.format),metalnessMap:Ht,roughnessMap:Qt,anisotropy:O,anisotropyMap:W,clearcoat:zi,clearcoatMap:$,clearcoatNormalMap:ae,clearcoatRoughnessMap:le,dispersion:mt,iridescence:R,iridescenceMap:Z,iridescenceThicknessMap:Q,sheen:y,sheenColorMap:he,sheenRoughnessMap:Ie,specularMap:fe,specularColorMap:ue,specularIntensityMap:Ue,transmission:F,transmissionMap:He,thicknessMap:Ke,gradientMap:L,opaque:x.transparent===!1&&x.blending===Ws&&x.alphaToCoverage===!1,alphaMap:ce,alphaTest:j,alphaHash:de,combine:x.combine,mapUv:Ce&&p(x.map.channel),aoMapUv:ke&&p(x.aoMap.channel),lightMapUv:ze&&p(x.lightMap.channel),bumpMapUv:ft&&p(x.bumpMap.channel),normalMapUv:pt&&p(x.normalMap.channel),displacementMapUv:zt&&p(x.displacementMap.channel),emissiveMapUv:Lt&&p(x.emissiveMap.channel),metalnessMapUv:Ht&&p(x.metalnessMap.channel),roughnessMapUv:Qt&&p(x.roughnessMap.channel),anisotropyMapUv:W&&p(x.anisotropyMap.channel),clearcoatMapUv:$&&p(x.clearcoatMap.channel),clearcoatNormalMapUv:ae&&p(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:le&&p(x.clearcoatRoughnessMap.channel),iridescenceMapUv:Z&&p(x.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&p(x.iridescenceThicknessMap.channel),sheenColorMapUv:he&&p(x.sheenColorMap.channel),sheenRoughnessMapUv:Ie&&p(x.sheenRoughnessMap.channel),specularMapUv:fe&&p(x.specularMap.channel),specularColorMapUv:ue&&p(x.specularColorMap.channel),specularIntensityMapUv:Ue&&p(x.specularIntensityMap.channel),transmissionMapUv:He&&p(x.transmissionMap.channel),thicknessMapUv:Ke&&p(x.thicknessMap.channel),alphaMapUv:ce&&p(x.alphaMap.channel),vertexTangents:!!N.attributes.tangent&&(pt||O),vertexNormals:!!N.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!N.attributes.color&&N.attributes.color.itemSize===4,pointsUvs:P.isPoints===!0&&!!N.attributes.uv&&(Ce||ce),fog:!!z,useFog:x.fog===!0,fogExp2:!!z&&z.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||N.attributes.normal===void 0&&pt===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:H,skinning:P.isSkinnedMesh===!0,hasPositionAttribute:N.attributes.position!==void 0,morphTargets:N.morphAttributes.position!==void 0,morphNormals:N.morphAttributes.normal!==void 0,morphColors:N.morphAttributes.color!==void 0,morphTargetsCount:oe,morphTextureStride:Ve,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numLightProbeGrids:X.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:a.shadowMap.enabled&&I.length>0,shadowMapType:a.shadowMap.type,toneMapping:te,decodeVideoTexture:Ce&&x.map.isVideoTexture===!0&&it.getTransfer(x.map.colorSpace)===gt,decodeVideoTextureEmissive:Lt&&x.emissiveMap.isVideoTexture===!0&&it.getTransfer(x.emissiveMap.colorSpace)===gt,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===tn,flipSided:x.side===Ot,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ve&&x.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ve&&x.extensions.multiDraw===!0||Ne)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return Re.vertexUv1s=c.has(1),Re.vertexUv2s=c.has(2),Re.vertexUv3s=c.has(3),c.clear(),Re}function m(x){const A=[];if(x.shaderID?A.push(x.shaderID):(A.push(x.customVertexShaderID),A.push(x.customFragmentShaderID)),x.defines!==void 0)for(const I in x.defines)A.push(I),A.push(x.defines[I]);return x.isRawShaderMaterial===!1&&(g(A,x),_(A,x),A.push(a.outputColorSpace)),A.push(x.customProgramCacheKey),A.join()}function g(x,A){x.push(A.precision),x.push(A.outputColorSpace),x.push(A.envMapMode),x.push(A.envMapCubeUVHeight),x.push(A.mapUv),x.push(A.alphaMapUv),x.push(A.lightMapUv),x.push(A.aoMapUv),x.push(A.bumpMapUv),x.push(A.normalMapUv),x.push(A.displacementMapUv),x.push(A.emissiveMapUv),x.push(A.metalnessMapUv),x.push(A.roughnessMapUv),x.push(A.anisotropyMapUv),x.push(A.clearcoatMapUv),x.push(A.clearcoatNormalMapUv),x.push(A.clearcoatRoughnessMapUv),x.push(A.iridescenceMapUv),x.push(A.iridescenceThicknessMapUv),x.push(A.sheenColorMapUv),x.push(A.sheenRoughnessMapUv),x.push(A.specularMapUv),x.push(A.specularColorMapUv),x.push(A.specularIntensityMapUv),x.push(A.transmissionMapUv),x.push(A.thicknessMapUv),x.push(A.combine),x.push(A.fogExp2),x.push(A.sizeAttenuation),x.push(A.morphTargetsCount),x.push(A.morphAttributeCount),x.push(A.numDirLights),x.push(A.numPointLights),x.push(A.numSpotLights),x.push(A.numSpotLightMaps),x.push(A.numHemiLights),x.push(A.numRectAreaLights),x.push(A.numDirLightShadows),x.push(A.numPointLightShadows),x.push(A.numSpotLightShadows),x.push(A.numSpotLightShadowsWithMaps),x.push(A.numLightProbes),x.push(A.shadowMapType),x.push(A.toneMapping),x.push(A.numClippingPlanes),x.push(A.numClipIntersection),x.push(A.depthPacking)}function _(x,A){r.disableAll(),A.instancing&&r.enable(0),A.instancingColor&&r.enable(1),A.instancingMorph&&r.enable(2),A.matcap&&r.enable(3),A.envMap&&r.enable(4),A.normalMapObjectSpace&&r.enable(5),A.normalMapTangentSpace&&r.enable(6),A.clearcoat&&r.enable(7),A.iridescence&&r.enable(8),A.alphaTest&&r.enable(9),A.vertexColors&&r.enable(10),A.vertexAlphas&&r.enable(11),A.vertexUv1s&&r.enable(12),A.vertexUv2s&&r.enable(13),A.vertexUv3s&&r.enable(14),A.vertexTangents&&r.enable(15),A.anisotropy&&r.enable(16),A.alphaHash&&r.enable(17),A.batching&&r.enable(18),A.dispersion&&r.enable(19),A.batchingColor&&r.enable(20),A.gradientMap&&r.enable(21),A.packedNormalMap&&r.enable(22),A.vertexNormals&&r.enable(23),x.push(r.mask),r.disableAll(),A.fog&&r.enable(0),A.useFog&&r.enable(1),A.flatShading&&r.enable(2),A.logarithmicDepthBuffer&&r.enable(3),A.reversedDepthBuffer&&r.enable(4),A.skinning&&r.enable(5),A.morphTargets&&r.enable(6),A.morphNormals&&r.enable(7),A.morphColors&&r.enable(8),A.premultipliedAlpha&&r.enable(9),A.shadowMapEnabled&&r.enable(10),A.doubleSided&&r.enable(11),A.flipSided&&r.enable(12),A.useDepthPacking&&r.enable(13),A.dithering&&r.enable(14),A.transmission&&r.enable(15),A.sheen&&r.enable(16),A.opaque&&r.enable(17),A.pointsUvs&&r.enable(18),A.decodeVideoTexture&&r.enable(19),A.decodeVideoTextureEmissive&&r.enable(20),A.alphaToCoverage&&r.enable(21),A.numLightProbeGrids>0&&r.enable(22),A.hasPositionAttribute&&r.enable(23),x.push(r.mask)}function w(x){const A=f[x.type];let I;if(A){const C=Gn[A];I=oM.clone(C.uniforms)}else I=x.uniforms;return I}function M(x,A){let I=h.get(A);return I!==void 0?++I.usedTimes:(I=new nS(a,A,x,n),l.push(I),h.set(A,I)),I}function S(x){if(--x.usedTimes===0){const A=l.indexOf(x);l[A]=l[l.length-1],l.pop(),h.delete(x.cacheKey),x.destroy()}}function b(x){o.remove(x)}function T(){o.dispose()}return{getParameters:v,getProgramCacheKey:m,getUniforms:w,acquireProgram:M,releaseProgram:S,releaseShaderCache:b,programs:l,dispose:T}}function lS(){let a=new WeakMap;function e(r){return a.has(r)}function t(r){let o=a.get(r);return o===void 0&&(o={},a.set(r,o)),o}function i(r){a.delete(r)}function n(r,o,c){a.get(r)[o]=c}function s(){a=new WeakMap}return{has:e,get:t,remove:i,update:n,dispose:s}}function hS(a,e){return a.groupOrder!==e.groupOrder?a.groupOrder-e.groupOrder:a.renderOrder!==e.renderOrder?a.renderOrder-e.renderOrder:a.material.id!==e.material.id?a.material.id-e.material.id:a.materialVariant!==e.materialVariant?a.materialVariant-e.materialVariant:a.z!==e.z?a.z-e.z:a.id-e.id}function hp(a,e){return a.groupOrder!==e.groupOrder?a.groupOrder-e.groupOrder:a.renderOrder!==e.renderOrder?a.renderOrder-e.renderOrder:a.z!==e.z?e.z-a.z:a.id-e.id}function up(){const a=[];let e=0;const t=[],i=[],n=[];function s(){e=0,t.length=0,i.length=0,n.length=0}function r(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function o(d,f,p,v,m,g){let _=a[e];return _===void 0?(_={id:d.id,object:d,geometry:f,material:p,materialVariant:r(d),groupOrder:v,renderOrder:d.renderOrder,z:m,group:g},a[e]=_):(_.id=d.id,_.object=d,_.geometry=f,_.material=p,_.materialVariant=r(d),_.groupOrder=v,_.renderOrder=d.renderOrder,_.z=m,_.group=g),e++,_}function c(d,f,p,v,m,g){const _=o(d,f,p,v,m,g);p.transmission>0?i.push(_):p.transparent===!0?n.push(_):t.push(_)}function l(d,f,p,v,m,g){const _=o(d,f,p,v,m,g);p.transmission>0?i.unshift(_):p.transparent===!0?n.unshift(_):t.unshift(_)}function h(d,f,p){t.length>1&&t.sort(d||hS),i.length>1&&i.sort(f||hp),n.length>1&&n.sort(f||hp),p&&(t.reverse(),i.reverse(),n.reverse())}function u(){for(let d=e,f=a.length;d<f;d++){const p=a[d];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:i,transparent:n,init:s,push:c,unshift:l,finish:u,sort:h}}function uS(){let a=new WeakMap;function e(i,n){const s=a.get(i);let r;return s===void 0?(r=new up,a.set(i,[r])):n>=s.length?(r=new up,s.push(r)):r=s[n],r}function t(){a=new WeakMap}return{get:e,dispose:t}}function dS(){const a={};return{get:function(e){if(a[e.id]!==void 0)return a[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new D,color:new se};break;case"SpotLight":t={position:new D,direction:new D,color:new se,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new D,color:new se,distance:0,decay:0};break;case"HemisphereLight":t={direction:new D,skyColor:new se,groundColor:new se};break;case"RectAreaLight":t={color:new se,position:new D,halfWidth:new D,halfHeight:new D};break}return a[e.id]=t,t}}}function fS(){const a={};return{get:function(e){if(a[e.id]!==void 0)return a[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xe};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xe};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xe,shadowCameraNear:1,shadowCameraFar:1e3};break}return a[e.id]=t,t}}}let pS=0;function mS(a,e){return(e.castShadow?2:0)-(a.castShadow?2:0)+(e.map?1:0)-(a.map?1:0)}function gS(a){const e=new dS,t=fS(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new D);const n=new D,s=new Ze,r=new Ze;function o(l){let h=0,u=0,d=0;for(let A=0;A<9;A++)i.probe[A].set(0,0,0);let f=0,p=0,v=0,m=0,g=0,_=0,w=0,M=0,S=0,b=0,T=0;l.sort(mS);for(let A=0,I=l.length;A<I;A++){const C=l[A],P=C.color,X=C.intensity,z=C.distance;let N=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===_a?N=C.shadow.map.texture:N=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)h+=P.r*X,u+=P.g*X,d+=P.b*X;else if(C.isLightProbe){for(let V=0;V<9;V++)i.probe[V].addScaledVector(C.sh.coefficients[V],X);T++}else if(C.isDirectionalLight){const V=e.get(C);if(V.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){const k=C.shadow,K=t.get(C);K.shadowIntensity=k.intensity,K.shadowBias=k.bias,K.shadowNormalBias=k.normalBias,K.shadowRadius=k.radius,K.shadowMapSize=k.mapSize,i.directionalShadow[f]=K,i.directionalShadowMap[f]=N,i.directionalShadowMatrix[f]=C.shadow.matrix,_++}i.directional[f]=V,f++}else if(C.isSpotLight){const V=e.get(C);V.position.setFromMatrixPosition(C.matrixWorld),V.color.copy(P).multiplyScalar(X),V.distance=z,V.coneCos=Math.cos(C.angle),V.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),V.decay=C.decay,i.spot[v]=V;const k=C.shadow;if(C.map&&(i.spotLightMap[S]=C.map,S++,k.updateMatrices(C),C.castShadow&&b++),i.spotLightMatrix[v]=k.matrix,C.castShadow){const K=t.get(C);K.shadowIntensity=k.intensity,K.shadowBias=k.bias,K.shadowNormalBias=k.normalBias,K.shadowRadius=k.radius,K.shadowMapSize=k.mapSize,i.spotShadow[v]=K,i.spotShadowMap[v]=N,M++}v++}else if(C.isRectAreaLight){const V=e.get(C);V.color.copy(P).multiplyScalar(X),V.halfWidth.set(C.width*.5,0,0),V.halfHeight.set(0,C.height*.5,0),i.rectArea[m]=V,m++}else if(C.isPointLight){const V=e.get(C);if(V.color.copy(C.color).multiplyScalar(C.intensity),V.distance=C.distance,V.decay=C.decay,C.castShadow){const k=C.shadow,K=t.get(C);K.shadowIntensity=k.intensity,K.shadowBias=k.bias,K.shadowNormalBias=k.normalBias,K.shadowRadius=k.radius,K.shadowMapSize=k.mapSize,K.shadowCameraNear=k.camera.near,K.shadowCameraFar=k.camera.far,i.pointShadow[p]=K,i.pointShadowMap[p]=N,i.pointShadowMatrix[p]=C.shadow.matrix,w++}i.point[p]=V,p++}else if(C.isHemisphereLight){const V=e.get(C);V.skyColor.copy(C.color).multiplyScalar(X),V.groundColor.copy(C.groundColor).multiplyScalar(X),i.hemi[g]=V,g++}}m>0&&(a.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=pe.LTC_FLOAT_1,i.rectAreaLTC2=pe.LTC_FLOAT_2):(i.rectAreaLTC1=pe.LTC_HALF_1,i.rectAreaLTC2=pe.LTC_HALF_2)),i.ambient[0]=h,i.ambient[1]=u,i.ambient[2]=d;const x=i.hash;(x.directionalLength!==f||x.pointLength!==p||x.spotLength!==v||x.rectAreaLength!==m||x.hemiLength!==g||x.numDirectionalShadows!==_||x.numPointShadows!==w||x.numSpotShadows!==M||x.numSpotMaps!==S||x.numLightProbes!==T)&&(i.directional.length=f,i.spot.length=v,i.rectArea.length=m,i.point.length=p,i.hemi.length=g,i.directionalShadow.length=_,i.directionalShadowMap.length=_,i.pointShadow.length=w,i.pointShadowMap.length=w,i.spotShadow.length=M,i.spotShadowMap.length=M,i.directionalShadowMatrix.length=_,i.pointShadowMatrix.length=w,i.spotLightMatrix.length=M+S-b,i.spotLightMap.length=S,i.numSpotLightShadowsWithMaps=b,i.numLightProbes=T,x.directionalLength=f,x.pointLength=p,x.spotLength=v,x.rectAreaLength=m,x.hemiLength=g,x.numDirectionalShadows=_,x.numPointShadows=w,x.numSpotShadows=M,x.numSpotMaps=S,x.numLightProbes=T,i.version=pS++)}function c(l,h){let u=0,d=0,f=0,p=0,v=0;const m=h.matrixWorldInverse;for(let g=0,_=l.length;g<_;g++){const w=l[g];if(w.isDirectionalLight){const M=i.directional[u];M.direction.setFromMatrixPosition(w.matrixWorld),n.setFromMatrixPosition(w.target.matrixWorld),M.direction.sub(n),M.direction.transformDirection(m),u++}else if(w.isSpotLight){const M=i.spot[f];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(w.matrixWorld),n.setFromMatrixPosition(w.target.matrixWorld),M.direction.sub(n),M.direction.transformDirection(m),f++}else if(w.isRectAreaLight){const M=i.rectArea[p];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),r.identity(),s.copy(w.matrixWorld),s.premultiply(m),r.extractRotation(s),M.halfWidth.set(w.width*.5,0,0),M.halfHeight.set(0,w.height*.5,0),M.halfWidth.applyMatrix4(r),M.halfHeight.applyMatrix4(r),p++}else if(w.isPointLight){const M=i.point[d];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),d++}else if(w.isHemisphereLight){const M=i.hemi[v];M.direction.setFromMatrixPosition(w.matrixWorld),M.direction.transformDirection(m),v++}}}return{setup:o,setupView:c,state:i}}function dp(a){const e=new gS(a),t=[],i=[],n=[];function s(d){u.camera=d,t.length=0,i.length=0,n.length=0}function r(d){t.push(d)}function o(d){i.push(d)}function c(d){n.push(d)}function l(){e.setup(t)}function h(d){e.setupView(t,d)}const u={lightsArray:t,shadowsArray:i,lightProbeGridArray:n,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:u,setupLights:l,setupLightsView:h,pushLight:r,pushShadow:o,pushLightProbeGrid:c}}function vS(a){let e=new WeakMap;function t(n,s=0){const r=e.get(n);let o;return r===void 0?(o=new dp(a),e.set(n,[o])):s>=r.length?(o=new dp(a),r.push(o)):o=r[s],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const MS=`void main() {
|
|
4691
|
+
`+ie)}else N!==""?Te("WebGLProgram: Program Info Log:",N):(V===""||k==="")&&(ee=!1);ee&&(C.diagnostics={runnable:K,programLog:N,vertexShader:{log:V,prefix:m},fragmentShader:{log:k,prefix:g}})}n.deleteShader(S),n.deleteShader(b),x=new Bc(n,v),A=G_(n,v)}let x;this.getUniforms=function(){return x===void 0&&T(this),x};let A;this.getAttributes=function(){return A===void 0&&T(this),A};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=n.getProgramParameter(v,P_)),I},this.destroy=function(){i.releaseStatesOfProgram(this),n.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=L_++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=S,this.fragmentShader=b,this}let sS=0;class aS{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,i){const n=this._getShaderCacheForMaterial(e);return n.has(t)===!1&&(n.add(t),t.usedTimes++),n.has(i)===!1&&(n.add(i),i.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.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 i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new rS(e),t.set(e,i)),i}}class rS{constructor(e){this.id=sS++,this.code=e,this.usedTimes=0}}function oS(a){return a===_a||a===$c||a===Zc}function cS(a,e,t,i,n,s){const r=new Bd,o=new aS,c=new Set,l=[],h=new Map,u=i.logarithmicDepthBuffer;let d=i.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 p(x){return c.add(x),x===0?"uv":`uv${x}`}function v(x,A,I,C,P,X){const z=C.fog,N=P.geometry,V=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?C.environment:null,k=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,K=e.get(x.envMap||V,k),ee=K&&K.mapping===xl?K.image.height:null,J=f[x.type];x.precision!==null&&(d=i.getMaxPrecision(x.precision),d!==x.precision&&Te("WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead."));const ie=N.morphAttributes.position||N.morphAttributes.normal||N.morphAttributes.color,oe=ie!==void 0?ie.length:0;let Ve=0;N.morphAttributes.position!==void 0&&(Ve=1),N.morphAttributes.normal!==void 0&&(Ve=2),N.morphAttributes.color!==void 0&&(Ve=3);let Qe,qe,Y,re;if(J){const Se=Gn[J];Qe=Se.vertexShader,qe=Se.fragmentShader}else{Qe=x.vertexShader,qe=x.fragmentShader;const Se=o.getVertexShaderStage(x),Gt=o.getFragmentShaderStage(x);o.update(x,Se,Gt),Y=Se.id,re=Gt.id}const ne=a.getRenderTarget(),H=a.state.buffers.depth.getReversed(),Ae=P.isInstancedMesh===!0,Ne=P.isBatchedMesh===!0,Ce=!!x.map,ye=!!x.matcap,Fe=!!K,ke=!!x.aoMap,ze=!!x.lightMap,ft=!!x.bumpMap&&x.wireframe===!1,pt=!!x.normalMap,Ht=!!x.displacementMap,Lt=!!x.emissiveMap,Bt=!!x.metalnessMap,ei=!!x.roughnessMap,O=x.anisotropy>0,zi=x.clearcoat>0,mt=x.dispersion>0,R=x.iridescence>0,y=x.sheen>0,F=x.transmission>0,W=O&&!!x.anisotropyMap,$=zi&&!!x.clearcoatMap,ae=zi&&!!x.clearcoatNormalMap,le=zi&&!!x.clearcoatRoughnessMap,Z=R&&!!x.iridescenceMap,Q=R&&!!x.iridescenceThicknessMap,he=y&&!!x.sheenColorMap,Ie=y&&!!x.sheenRoughnessMap,fe=!!x.specularMap,ue=!!x.specularColorMap,Ue=!!x.specularIntensityMap,He=F&&!!x.transmissionMap,Ke=F&&!!x.thicknessMap,L=!!x.gradientMap,ce=!!x.alphaMap,j=x.alphaTest>0,de=!!x.alphaHash,ve=!!x.extensions;let te=Jn;x.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(te=a.toneMapping);const Re={shaderID:J,shaderType:x.type,shaderName:x.name,vertexShader:Qe,fragmentShader:qe,defines:x.defines,customVertexShaderID:Y,customFragmentShaderID:re,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,batching:Ne,batchingColor:Ne&&P._colorsTexture!==null,instancing:Ae,instancingColor:Ae&&P.instanceColor!==null,instancingMorph:Ae&&P.morphTexture!==null,outputColorSpace:ne===null?a.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:nt.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Ce,matcap:ye,envMap:Fe,envMapMode:Fe&&K.mapping,envMapCubeUVHeight:ee,aoMap:ke,lightMap:ze,bumpMap:ft,normalMap:pt,displacementMap:Ht,emissiveMap:Lt,normalMapObjectSpace:pt&&x.normalMapType===iv,normalMapTangentSpace:pt&&x.normalMapType===jc,packedNormalMap:pt&&x.normalMapType===jc&&oS(x.normalMap.format),metalnessMap:Bt,roughnessMap:ei,anisotropy:O,anisotropyMap:W,clearcoat:zi,clearcoatMap:$,clearcoatNormalMap:ae,clearcoatRoughnessMap:le,dispersion:mt,iridescence:R,iridescenceMap:Z,iridescenceThicknessMap:Q,sheen:y,sheenColorMap:he,sheenRoughnessMap:Ie,specularMap:fe,specularColorMap:ue,specularIntensityMap:Ue,transmission:F,transmissionMap:He,thicknessMap:Ke,gradientMap:L,opaque:x.transparent===!1&&x.blending===Ws&&x.alphaToCoverage===!1,alphaMap:ce,alphaTest:j,alphaHash:de,combine:x.combine,mapUv:Ce&&p(x.map.channel),aoMapUv:ke&&p(x.aoMap.channel),lightMapUv:ze&&p(x.lightMap.channel),bumpMapUv:ft&&p(x.bumpMap.channel),normalMapUv:pt&&p(x.normalMap.channel),displacementMapUv:Ht&&p(x.displacementMap.channel),emissiveMapUv:Lt&&p(x.emissiveMap.channel),metalnessMapUv:Bt&&p(x.metalnessMap.channel),roughnessMapUv:ei&&p(x.roughnessMap.channel),anisotropyMapUv:W&&p(x.anisotropyMap.channel),clearcoatMapUv:$&&p(x.clearcoatMap.channel),clearcoatNormalMapUv:ae&&p(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:le&&p(x.clearcoatRoughnessMap.channel),iridescenceMapUv:Z&&p(x.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&p(x.iridescenceThicknessMap.channel),sheenColorMapUv:he&&p(x.sheenColorMap.channel),sheenRoughnessMapUv:Ie&&p(x.sheenRoughnessMap.channel),specularMapUv:fe&&p(x.specularMap.channel),specularColorMapUv:ue&&p(x.specularColorMap.channel),specularIntensityMapUv:Ue&&p(x.specularIntensityMap.channel),transmissionMapUv:He&&p(x.transmissionMap.channel),thicknessMapUv:Ke&&p(x.thicknessMap.channel),alphaMapUv:ce&&p(x.alphaMap.channel),vertexTangents:!!N.attributes.tangent&&(pt||O),vertexNormals:!!N.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!N.attributes.color&&N.attributes.color.itemSize===4,pointsUvs:P.isPoints===!0&&!!N.attributes.uv&&(Ce||ce),fog:!!z,useFog:x.fog===!0,fogExp2:!!z&&z.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||N.attributes.normal===void 0&&pt===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:H,skinning:P.isSkinnedMesh===!0,hasPositionAttribute:N.attributes.position!==void 0,morphTargets:N.morphAttributes.position!==void 0,morphNormals:N.morphAttributes.normal!==void 0,morphColors:N.morphAttributes.color!==void 0,morphTargetsCount:oe,morphTextureStride:Ve,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numLightProbeGrids:X.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:a.shadowMap.enabled&&I.length>0,shadowMapType:a.shadowMap.type,toneMapping:te,decodeVideoTexture:Ce&&x.map.isVideoTexture===!0&&nt.getTransfer(x.map.colorSpace)===gt,decodeVideoTextureEmissive:Lt&&x.emissiveMap.isVideoTexture===!0&&nt.getTransfer(x.emissiveMap.colorSpace)===gt,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===tn,flipSided:x.side===Ot,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ve&&x.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ve&&x.extensions.multiDraw===!0||Ne)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return Re.vertexUv1s=c.has(1),Re.vertexUv2s=c.has(2),Re.vertexUv3s=c.has(3),c.clear(),Re}function m(x){const A=[];if(x.shaderID?A.push(x.shaderID):(A.push(x.customVertexShaderID),A.push(x.customFragmentShaderID)),x.defines!==void 0)for(const I in x.defines)A.push(I),A.push(x.defines[I]);return x.isRawShaderMaterial===!1&&(g(A,x),_(A,x),A.push(a.outputColorSpace)),A.push(x.customProgramCacheKey),A.join()}function g(x,A){x.push(A.precision),x.push(A.outputColorSpace),x.push(A.envMapMode),x.push(A.envMapCubeUVHeight),x.push(A.mapUv),x.push(A.alphaMapUv),x.push(A.lightMapUv),x.push(A.aoMapUv),x.push(A.bumpMapUv),x.push(A.normalMapUv),x.push(A.displacementMapUv),x.push(A.emissiveMapUv),x.push(A.metalnessMapUv),x.push(A.roughnessMapUv),x.push(A.anisotropyMapUv),x.push(A.clearcoatMapUv),x.push(A.clearcoatNormalMapUv),x.push(A.clearcoatRoughnessMapUv),x.push(A.iridescenceMapUv),x.push(A.iridescenceThicknessMapUv),x.push(A.sheenColorMapUv),x.push(A.sheenRoughnessMapUv),x.push(A.specularMapUv),x.push(A.specularColorMapUv),x.push(A.specularIntensityMapUv),x.push(A.transmissionMapUv),x.push(A.thicknessMapUv),x.push(A.combine),x.push(A.fogExp2),x.push(A.sizeAttenuation),x.push(A.morphTargetsCount),x.push(A.morphAttributeCount),x.push(A.numDirLights),x.push(A.numPointLights),x.push(A.numSpotLights),x.push(A.numSpotLightMaps),x.push(A.numHemiLights),x.push(A.numRectAreaLights),x.push(A.numDirLightShadows),x.push(A.numPointLightShadows),x.push(A.numSpotLightShadows),x.push(A.numSpotLightShadowsWithMaps),x.push(A.numLightProbes),x.push(A.shadowMapType),x.push(A.toneMapping),x.push(A.numClippingPlanes),x.push(A.numClipIntersection),x.push(A.depthPacking)}function _(x,A){r.disableAll(),A.instancing&&r.enable(0),A.instancingColor&&r.enable(1),A.instancingMorph&&r.enable(2),A.matcap&&r.enable(3),A.envMap&&r.enable(4),A.normalMapObjectSpace&&r.enable(5),A.normalMapTangentSpace&&r.enable(6),A.clearcoat&&r.enable(7),A.iridescence&&r.enable(8),A.alphaTest&&r.enable(9),A.vertexColors&&r.enable(10),A.vertexAlphas&&r.enable(11),A.vertexUv1s&&r.enable(12),A.vertexUv2s&&r.enable(13),A.vertexUv3s&&r.enable(14),A.vertexTangents&&r.enable(15),A.anisotropy&&r.enable(16),A.alphaHash&&r.enable(17),A.batching&&r.enable(18),A.dispersion&&r.enable(19),A.batchingColor&&r.enable(20),A.gradientMap&&r.enable(21),A.packedNormalMap&&r.enable(22),A.vertexNormals&&r.enable(23),x.push(r.mask),r.disableAll(),A.fog&&r.enable(0),A.useFog&&r.enable(1),A.flatShading&&r.enable(2),A.logarithmicDepthBuffer&&r.enable(3),A.reversedDepthBuffer&&r.enable(4),A.skinning&&r.enable(5),A.morphTargets&&r.enable(6),A.morphNormals&&r.enable(7),A.morphColors&&r.enable(8),A.premultipliedAlpha&&r.enable(9),A.shadowMapEnabled&&r.enable(10),A.doubleSided&&r.enable(11),A.flipSided&&r.enable(12),A.useDepthPacking&&r.enable(13),A.dithering&&r.enable(14),A.transmission&&r.enable(15),A.sheen&&r.enable(16),A.opaque&&r.enable(17),A.pointsUvs&&r.enable(18),A.decodeVideoTexture&&r.enable(19),A.decodeVideoTextureEmissive&&r.enable(20),A.alphaToCoverage&&r.enable(21),A.numLightProbeGrids>0&&r.enable(22),A.hasPositionAttribute&&r.enable(23),x.push(r.mask)}function w(x){const A=f[x.type];let I;if(A){const C=Gn[A];I=oM.clone(C.uniforms)}else I=x.uniforms;return I}function M(x,A){let I=h.get(A);return I!==void 0?++I.usedTimes:(I=new nS(a,A,x,n),l.push(I),h.set(A,I)),I}function S(x){if(--x.usedTimes===0){const A=l.indexOf(x);l[A]=l[l.length-1],l.pop(),h.delete(x.cacheKey),x.destroy()}}function b(x){o.remove(x)}function T(){o.dispose()}return{getParameters:v,getProgramCacheKey:m,getUniforms:w,acquireProgram:M,releaseProgram:S,releaseShaderCache:b,programs:l,dispose:T}}function lS(){let a=new WeakMap;function e(r){return a.has(r)}function t(r){let o=a.get(r);return o===void 0&&(o={},a.set(r,o)),o}function i(r){a.delete(r)}function n(r,o,c){a.get(r)[o]=c}function s(){a=new WeakMap}return{has:e,get:t,remove:i,update:n,dispose:s}}function hS(a,e){return a.groupOrder!==e.groupOrder?a.groupOrder-e.groupOrder:a.renderOrder!==e.renderOrder?a.renderOrder-e.renderOrder:a.material.id!==e.material.id?a.material.id-e.material.id:a.materialVariant!==e.materialVariant?a.materialVariant-e.materialVariant:a.z!==e.z?a.z-e.z:a.id-e.id}function hp(a,e){return a.groupOrder!==e.groupOrder?a.groupOrder-e.groupOrder:a.renderOrder!==e.renderOrder?a.renderOrder-e.renderOrder:a.z!==e.z?e.z-a.z:a.id-e.id}function up(){const a=[];let e=0;const t=[],i=[],n=[];function s(){e=0,t.length=0,i.length=0,n.length=0}function r(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function o(d,f,p,v,m,g){let _=a[e];return _===void 0?(_={id:d.id,object:d,geometry:f,material:p,materialVariant:r(d),groupOrder:v,renderOrder:d.renderOrder,z:m,group:g},a[e]=_):(_.id=d.id,_.object=d,_.geometry=f,_.material=p,_.materialVariant=r(d),_.groupOrder=v,_.renderOrder=d.renderOrder,_.z=m,_.group=g),e++,_}function c(d,f,p,v,m,g){const _=o(d,f,p,v,m,g);p.transmission>0?i.push(_):p.transparent===!0?n.push(_):t.push(_)}function l(d,f,p,v,m,g){const _=o(d,f,p,v,m,g);p.transmission>0?i.unshift(_):p.transparent===!0?n.unshift(_):t.unshift(_)}function h(d,f,p){t.length>1&&t.sort(d||hS),i.length>1&&i.sort(f||hp),n.length>1&&n.sort(f||hp),p&&(t.reverse(),i.reverse(),n.reverse())}function u(){for(let d=e,f=a.length;d<f;d++){const p=a[d];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:i,transparent:n,init:s,push:c,unshift:l,finish:u,sort:h}}function uS(){let a=new WeakMap;function e(i,n){const s=a.get(i);let r;return s===void 0?(r=new up,a.set(i,[r])):n>=s.length?(r=new up,s.push(r)):r=s[n],r}function t(){a=new WeakMap}return{get:e,dispose:t}}function dS(){const a={};return{get:function(e){if(a[e.id]!==void 0)return a[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new D,color:new se};break;case"SpotLight":t={position:new D,direction:new D,color:new se,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new D,color:new se,distance:0,decay:0};break;case"HemisphereLight":t={direction:new D,skyColor:new se,groundColor:new se};break;case"RectAreaLight":t={color:new se,position:new D,halfWidth:new D,halfHeight:new D};break}return a[e.id]=t,t}}}function fS(){const a={};return{get:function(e){if(a[e.id]!==void 0)return a[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xe};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xe};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xe,shadowCameraNear:1,shadowCameraFar:1e3};break}return a[e.id]=t,t}}}let pS=0;function mS(a,e){return(e.castShadow?2:0)-(a.castShadow?2:0)+(e.map?1:0)-(a.map?1:0)}function gS(a){const e=new dS,t=fS(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new D);const n=new D,s=new Ze,r=new Ze;function o(l){let h=0,u=0,d=0;for(let A=0;A<9;A++)i.probe[A].set(0,0,0);let f=0,p=0,v=0,m=0,g=0,_=0,w=0,M=0,S=0,b=0,T=0;l.sort(mS);for(let A=0,I=l.length;A<I;A++){const C=l[A],P=C.color,X=C.intensity,z=C.distance;let N=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===_a?N=C.shadow.map.texture:N=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)h+=P.r*X,u+=P.g*X,d+=P.b*X;else if(C.isLightProbe){for(let V=0;V<9;V++)i.probe[V].addScaledVector(C.sh.coefficients[V],X);T++}else if(C.isDirectionalLight){const V=e.get(C);if(V.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){const k=C.shadow,K=t.get(C);K.shadowIntensity=k.intensity,K.shadowBias=k.bias,K.shadowNormalBias=k.normalBias,K.shadowRadius=k.radius,K.shadowMapSize=k.mapSize,i.directionalShadow[f]=K,i.directionalShadowMap[f]=N,i.directionalShadowMatrix[f]=C.shadow.matrix,_++}i.directional[f]=V,f++}else if(C.isSpotLight){const V=e.get(C);V.position.setFromMatrixPosition(C.matrixWorld),V.color.copy(P).multiplyScalar(X),V.distance=z,V.coneCos=Math.cos(C.angle),V.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),V.decay=C.decay,i.spot[v]=V;const k=C.shadow;if(C.map&&(i.spotLightMap[S]=C.map,S++,k.updateMatrices(C),C.castShadow&&b++),i.spotLightMatrix[v]=k.matrix,C.castShadow){const K=t.get(C);K.shadowIntensity=k.intensity,K.shadowBias=k.bias,K.shadowNormalBias=k.normalBias,K.shadowRadius=k.radius,K.shadowMapSize=k.mapSize,i.spotShadow[v]=K,i.spotShadowMap[v]=N,M++}v++}else if(C.isRectAreaLight){const V=e.get(C);V.color.copy(P).multiplyScalar(X),V.halfWidth.set(C.width*.5,0,0),V.halfHeight.set(0,C.height*.5,0),i.rectArea[m]=V,m++}else if(C.isPointLight){const V=e.get(C);if(V.color.copy(C.color).multiplyScalar(C.intensity),V.distance=C.distance,V.decay=C.decay,C.castShadow){const k=C.shadow,K=t.get(C);K.shadowIntensity=k.intensity,K.shadowBias=k.bias,K.shadowNormalBias=k.normalBias,K.shadowRadius=k.radius,K.shadowMapSize=k.mapSize,K.shadowCameraNear=k.camera.near,K.shadowCameraFar=k.camera.far,i.pointShadow[p]=K,i.pointShadowMap[p]=N,i.pointShadowMatrix[p]=C.shadow.matrix,w++}i.point[p]=V,p++}else if(C.isHemisphereLight){const V=e.get(C);V.skyColor.copy(C.color).multiplyScalar(X),V.groundColor.copy(C.groundColor).multiplyScalar(X),i.hemi[g]=V,g++}}m>0&&(a.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=pe.LTC_FLOAT_1,i.rectAreaLTC2=pe.LTC_FLOAT_2):(i.rectAreaLTC1=pe.LTC_HALF_1,i.rectAreaLTC2=pe.LTC_HALF_2)),i.ambient[0]=h,i.ambient[1]=u,i.ambient[2]=d;const x=i.hash;(x.directionalLength!==f||x.pointLength!==p||x.spotLength!==v||x.rectAreaLength!==m||x.hemiLength!==g||x.numDirectionalShadows!==_||x.numPointShadows!==w||x.numSpotShadows!==M||x.numSpotMaps!==S||x.numLightProbes!==T)&&(i.directional.length=f,i.spot.length=v,i.rectArea.length=m,i.point.length=p,i.hemi.length=g,i.directionalShadow.length=_,i.directionalShadowMap.length=_,i.pointShadow.length=w,i.pointShadowMap.length=w,i.spotShadow.length=M,i.spotShadowMap.length=M,i.directionalShadowMatrix.length=_,i.pointShadowMatrix.length=w,i.spotLightMatrix.length=M+S-b,i.spotLightMap.length=S,i.numSpotLightShadowsWithMaps=b,i.numLightProbes=T,x.directionalLength=f,x.pointLength=p,x.spotLength=v,x.rectAreaLength=m,x.hemiLength=g,x.numDirectionalShadows=_,x.numPointShadows=w,x.numSpotShadows=M,x.numSpotMaps=S,x.numLightProbes=T,i.version=pS++)}function c(l,h){let u=0,d=0,f=0,p=0,v=0;const m=h.matrixWorldInverse;for(let g=0,_=l.length;g<_;g++){const w=l[g];if(w.isDirectionalLight){const M=i.directional[u];M.direction.setFromMatrixPosition(w.matrixWorld),n.setFromMatrixPosition(w.target.matrixWorld),M.direction.sub(n),M.direction.transformDirection(m),u++}else if(w.isSpotLight){const M=i.spot[f];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(w.matrixWorld),n.setFromMatrixPosition(w.target.matrixWorld),M.direction.sub(n),M.direction.transformDirection(m),f++}else if(w.isRectAreaLight){const M=i.rectArea[p];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),r.identity(),s.copy(w.matrixWorld),s.premultiply(m),r.extractRotation(s),M.halfWidth.set(w.width*.5,0,0),M.halfHeight.set(0,w.height*.5,0),M.halfWidth.applyMatrix4(r),M.halfHeight.applyMatrix4(r),p++}else if(w.isPointLight){const M=i.point[d];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),d++}else if(w.isHemisphereLight){const M=i.hemi[v];M.direction.setFromMatrixPosition(w.matrixWorld),M.direction.transformDirection(m),v++}}}return{setup:o,setupView:c,state:i}}function dp(a){const e=new gS(a),t=[],i=[],n=[];function s(d){u.camera=d,t.length=0,i.length=0,n.length=0}function r(d){t.push(d)}function o(d){i.push(d)}function c(d){n.push(d)}function l(){e.setup(t)}function h(d){e.setupView(t,d)}const u={lightsArray:t,shadowsArray:i,lightProbeGridArray:n,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:u,setupLights:l,setupLightsView:h,pushLight:r,pushShadow:o,pushLightProbeGrid:c}}function vS(a){let e=new WeakMap;function t(n,s=0){const r=e.get(n);let o;return r===void 0?(o=new dp(a),e.set(n,[o])):s>=r.length?(o=new dp(a),r.push(o)):o=r[s],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const MS=`void main() {
|
|
4692
4692
|
gl_Position = vec4( position, 1.0 );
|
|
4693
4693
|
}`,xS=`uniform sampler2D shadow_pass;
|
|
4694
4694
|
uniform vec2 resolution;
|
|
@@ -4715,7 +4715,7 @@ void main() {
|
|
|
4715
4715
|
squared_mean = squared_mean / samples;
|
|
4716
4716
|
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
|
|
4717
4717
|
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
|
|
4718
|
-
}`,yS=[new D(1,0,0),new D(-1,0,0),new D(0,1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1)],_S=[new D(0,-1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1),new D(0,-1,0),new D(0,-1,0)],fp=new Ze,Hr=new D,yh=new D;function SS(a,e,t){let i=new Wd;const n=new xe,s=new xe,r=new nt,o=new uM,c=new dM,l={},h=t.maxTextureSize,u={[qs]:Ot,[Ot]:qs,[tn]:tn},d=new at({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new xe},radius:{value:4}},vertexShader:MS,fragmentShader:xS}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const p=new ut;p.setAttribute("position",new et(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new De(p,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=io;let g=this.type;this.render=function(b,T,x){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;this.type===L2&&(Te("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=io);const A=a.getRenderTarget(),I=a.getActiveCubeFace(),C=a.getActiveMipmapLevel(),P=a.state;P.setBlending(Zn),P.buffers.depth.getReversed()===!0?P.buffers.color.setClear(0,0,0,0):P.buffers.color.setClear(1,1,1,1),P.buffers.depth.setTest(!0),P.setScissorTest(!1);const X=g!==this.type;X&&T.traverse(function(z){z.material&&(Array.isArray(z.material)?z.material.forEach(N=>N.needsUpdate=!0):z.material.needsUpdate=!0)});for(let z=0,N=b.length;z<N;z++){const V=b[z],k=V.shadow;if(k===void 0){Te("WebGLShadowMap:",V,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;n.copy(k.mapSize);const K=k.getFrameExtents();n.multiply(K),s.copy(k.mapSize),(n.x>h||n.y>h)&&(n.x>h&&(s.x=Math.floor(h/K.x),n.x=s.x*K.x,k.mapSize.x=s.x),n.y>h&&(s.y=Math.floor(h/K.y),n.y=s.y*K.y,k.mapSize.y=s.y));const ee=a.state.buffers.depth.getReversed();if(k.camera._reversedDepth=ee,k.map===null||X===!0){if(k.map!==null&&(k.map.depthTexture!==null&&(k.map.depthTexture.dispose(),k.map.depthTexture=null),k.map.dispose()),this.type===Zr){if(V.isPointLight){Te("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}k.map=new Jt(n.x,n.y,{format:_a,type:Ft,minFilter:st,magFilter:st,generateMipmaps:!1}),k.map.texture.name=V.name+".shadowMap",k.map.depthTexture=new Ys(n.x,n.y,Ri),k.map.depthTexture.name=V.name+".shadowMapDepth",k.map.depthTexture.format=vs,k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=wt,k.map.depthTexture.magFilter=wt}else V.isPointLight?(k.map=new wo(n.x),k.map.depthTexture=new aM(n.x,gn)):(k.map=new Jt(n.x,n.y),k.map.depthTexture=new Ys(n.x,n.y,gn)),k.map.depthTexture.name=V.name+".shadowMap",k.map.depthTexture.format=vs,this.type===io?(k.map.depthTexture.compareFunction=ee?kd:Fd,k.map.depthTexture.minFilter=st,k.map.depthTexture.magFilter=st):(k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=wt,k.map.depthTexture.magFilter=wt);k.camera.updateProjectionMatrix()}const J=k.map.isWebGLCubeRenderTarget?6:1;for(let ie=0;ie<J;ie++){if(k.map.isWebGLCubeRenderTarget)a.setRenderTarget(k.map,ie),a.clear();else{ie===0&&(a.setRenderTarget(k.map),a.clear());const oe=k.getViewport(ie);r.set(s.x*oe.x,s.y*oe.y,s.x*oe.z,s.y*oe.w),P.viewport(r)}if(V.isPointLight){const oe=k.camera,Ve=k.matrix,Qe=V.distance||oe.far;Qe!==oe.far&&(oe.far=Qe,oe.updateProjectionMatrix()),Hr.setFromMatrixPosition(V.matrixWorld),oe.position.copy(Hr),yh.copy(oe.position),yh.add(yS[ie]),oe.up.copy(_S[ie]),oe.lookAt(yh),oe.updateMatrixWorld(),Ve.makeTranslation(-Hr.x,-Hr.y,-Hr.z),fp.multiplyMatrices(oe.projectionMatrix,oe.matrixWorldInverse),k._frustum.setFromProjectionMatrix(fp,oe.coordinateSystem,oe.reversedDepth)}else k.updateMatrices(V);i=k.getFrustum(),M(T,x,k.camera,V,this.type)}k.isPointLightShadow!==!0&&this.type===Zr&&_(k,x),k.needsUpdate=!1}g=this.type,m.needsUpdate=!1,a.setRenderTarget(A,I,C)};function _(b,T){const x=e.update(v);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,f.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new Jt(n.x,n.y,{format:_a,type:Ft})),d.uniforms.shadow_pass.value=b.map.depthTexture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,a.setRenderTarget(b.mapPass),a.clear(),a.renderBufferDirect(T,null,x,d,v,null),f.uniforms.shadow_pass.value=b.mapPass.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,a.setRenderTarget(b.map),a.clear(),a.renderBufferDirect(T,null,x,f,v,null)}function w(b,T,x,A){let I=null;const C=x.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0)I=C;else if(I=x.isPointLight===!0?c:o,a.localClippingEnabled&&T.clipShadows===!0&&Array.isArray(T.clippingPlanes)&&T.clippingPlanes.length!==0||T.displacementMap&&T.displacementScale!==0||T.alphaMap&&T.alphaTest>0||T.map&&T.alphaTest>0||T.alphaToCoverage===!0){const P=I.uuid,X=T.uuid;let z=l[P];z===void 0&&(z={},l[P]=z);let N=z[X];N===void 0&&(N=I.clone(),z[X]=N,T.addEventListener("dispose",S)),I=N}if(I.visible=T.visible,I.wireframe=T.wireframe,A===Zr?I.side=T.shadowSide!==null?T.shadowSide:T.side:I.side=T.shadowSide!==null?T.shadowSide:u[T.side],I.alphaMap=T.alphaMap,I.alphaTest=T.alphaToCoverage===!0?.5:T.alphaTest,I.map=T.map,I.clipShadows=T.clipShadows,I.clippingPlanes=T.clippingPlanes,I.clipIntersection=T.clipIntersection,I.displacementMap=T.displacementMap,I.displacementScale=T.displacementScale,I.displacementBias=T.displacementBias,I.wireframeLinewidth=T.wireframeLinewidth,I.linewidth=T.linewidth,x.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const P=a.properties.get(I);P.light=x}return I}function M(b,T,x,A,I){if(b.visible===!1)return;if(b.layers.test(T.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&I===Zr)&&(!b.frustumCulled||i.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,b.matrixWorld);const X=e.update(b),z=b.material;if(Array.isArray(z)){const N=X.groups;for(let V=0,k=N.length;V<k;V++){const K=N[V],ee=z[K.materialIndex];if(ee&&ee.visible){const J=w(b,ee,A,I);b.onBeforeShadow(a,b,T,x,X,J,K),a.renderBufferDirect(x,null,X,J,b,K),b.onAfterShadow(a,b,T,x,X,J,K)}}}else if(z.visible){const N=w(b,z,A,I);b.onBeforeShadow(a,b,T,x,X,N,null),a.renderBufferDirect(x,null,X,N,b,null),b.onAfterShadow(a,b,T,x,X,N,null)}}const P=b.children;for(let X=0,z=P.length;X<z;X++)M(P[X],T,x,A,I)}function S(b){b.target.removeEventListener("dispose",S);for(const x in l){const A=l[x],I=b.target.uuid;I in A&&(A[I].dispose(),delete A[I])}}}function wS(a,e){function t(){let L=!1;const ce=new nt;let j=null;const de=new nt(0,0,0,0);return{setMask:function(ve){j!==ve&&!L&&(a.colorMask(ve,ve,ve,ve),j=ve)},setLocked:function(ve){L=ve},setClear:function(ve,te,Re,Se,Bt){Bt===!0&&(ve*=Se,te*=Se,Re*=Se),ce.set(ve,te,Re,Se),de.equals(ce)===!1&&(a.clearColor(ve,te,Re,Se),de.copy(ce))},reset:function(){L=!1,j=null,de.set(-1,0,0,0)}}}function i(){let L=!1,ce=!1,j=null,de=null,ve=null;return{setReversed:function(te){if(ce!==te){const Re=e.get("EXT_clip_control");te?Re.clipControlEXT(Re.LOWER_LEFT_EXT,Re.ZERO_TO_ONE_EXT):Re.clipControlEXT(Re.LOWER_LEFT_EXT,Re.NEGATIVE_ONE_TO_ONE_EXT),ce=te;const Se=ve;ve=null,this.setClear(Se)}},getReversed:function(){return ce},setTest:function(te){te?ne(a.DEPTH_TEST):H(a.DEPTH_TEST)},setMask:function(te){j!==te&&!L&&(a.depthMask(te),j=te)},setFunc:function(te){if(ce&&(te=fv[te]),de!==te){switch(te){case su:a.depthFunc(a.NEVER);break;case au:a.depthFunc(a.ALWAYS);break;case ru:a.depthFunc(a.LESS);break;case gr:a.depthFunc(a.LEQUAL);break;case ou:a.depthFunc(a.EQUAL);break;case cu:a.depthFunc(a.GEQUAL);break;case lu:a.depthFunc(a.GREATER);break;case hu:a.depthFunc(a.NOTEQUAL);break;default:a.depthFunc(a.LEQUAL)}de=te}},setLocked:function(te){L=te},setClear:function(te){ve!==te&&(ve=te,ce&&(te=1-te),a.clearDepth(te))},reset:function(){L=!1,j=null,de=null,ve=null,ce=!1}}}function n(){let L=!1,ce=null,j=null,de=null,ve=null,te=null,Re=null,Se=null,Bt=null;return{setTest:function(At){L||(At?ne(a.STENCIL_TEST):H(a.STENCIL_TEST))},setMask:function(At){ce!==At&&!L&&(a.stencilMask(At),ce=At)},setFunc:function(At,Pn,Ln){(j!==At||de!==Pn||ve!==Ln)&&(a.stencilFunc(At,Pn,Ln),j=At,de=Pn,ve=Ln)},setOp:function(At,Pn,Ln){(te!==At||Re!==Pn||Se!==Ln)&&(a.stencilOp(At,Pn,Ln),te=At,Re=Pn,Se=Ln)},setLocked:function(At){L=At},setClear:function(At){Bt!==At&&(a.clearStencil(At),Bt=At)},reset:function(){L=!1,ce=null,j=null,de=null,ve=null,te=null,Re=null,Se=null,Bt=null}}}const s=new t,r=new i,o=new n,c=new WeakMap,l=new WeakMap;let h={},u={},d={},f=new WeakMap,p=[],v=null,m=!1,g=null,_=null,w=null,M=null,S=null,b=null,T=null,x=new se(0,0,0),A=0,I=!1,C=null,P=null,X=null,z=null,N=null;const V=a.getParameter(a.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let k=!1,K=0;const ee=a.getParameter(a.VERSION);ee.indexOf("WebGL")!==-1?(K=parseFloat(/^WebGL (\d)/.exec(ee)[1]),k=K>=1):ee.indexOf("OpenGL ES")!==-1&&(K=parseFloat(/^OpenGL ES (\d)/.exec(ee)[1]),k=K>=2);let J=null,ie={};const oe=a.getParameter(a.SCISSOR_BOX),Ve=a.getParameter(a.VIEWPORT),Qe=new nt().fromArray(oe),qe=new nt().fromArray(Ve);function Y(L,ce,j,de){const ve=new Uint8Array(4),te=a.createTexture();a.bindTexture(L,te),a.texParameteri(L,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(L,a.TEXTURE_MAG_FILTER,a.NEAREST);for(let Re=0;Re<j;Re++)L===a.TEXTURE_3D||L===a.TEXTURE_2D_ARRAY?a.texImage3D(ce,0,a.RGBA,1,1,de,0,a.RGBA,a.UNSIGNED_BYTE,ve):a.texImage2D(ce+Re,0,a.RGBA,1,1,0,a.RGBA,a.UNSIGNED_BYTE,ve);return te}const re={};re[a.TEXTURE_2D]=Y(a.TEXTURE_2D,a.TEXTURE_2D,1),re[a.TEXTURE_CUBE_MAP]=Y(a.TEXTURE_CUBE_MAP,a.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[a.TEXTURE_2D_ARRAY]=Y(a.TEXTURE_2D_ARRAY,a.TEXTURE_2D_ARRAY,1,1),re[a.TEXTURE_3D]=Y(a.TEXTURE_3D,a.TEXTURE_3D,1,1),s.setClear(0,0,0,1),r.setClear(1),o.setClear(0),ne(a.DEPTH_TEST),r.setFunc(gr),ft(!1),pt(Y0),ne(a.CULL_FACE),ke(Zn);function ne(L){h[L]!==!0&&(a.enable(L),h[L]=!0)}function H(L){h[L]!==!1&&(a.disable(L),h[L]=!1)}function Ae(L,ce){return d[L]!==ce?(a.bindFramebuffer(L,ce),d[L]=ce,L===a.DRAW_FRAMEBUFFER&&(d[a.FRAMEBUFFER]=ce),L===a.FRAMEBUFFER&&(d[a.DRAW_FRAMEBUFFER]=ce),!0):!1}function Ne(L,ce){let j=p,de=!1;if(L){j=f.get(ce),j===void 0&&(j=[],f.set(ce,j));const ve=L.textures;if(j.length!==ve.length||j[0]!==a.COLOR_ATTACHMENT0){for(let te=0,Re=ve.length;te<Re;te++)j[te]=a.COLOR_ATTACHMENT0+te;j.length=ve.length,de=!0}}else j[0]!==a.BACK&&(j[0]=a.BACK,de=!0);de&&a.drawBuffers(j)}function Ce(L){return v!==L?(a.useProgram(L),v=L,!0):!1}const ye={[ra]:a.FUNC_ADD,[N2]:a.FUNC_SUBTRACT,[O2]:a.FUNC_REVERSE_SUBTRACT};ye[U2]=a.MIN,ye[F2]=a.MAX;const Fe={[k2]:a.ZERO,[go]:a.ONE,[z2]:a.SRC_COLOR,[nu]:a.SRC_ALPHA,[X2]:a.SRC_ALPHA_SATURATE,[V2]:a.DST_COLOR,[B2]:a.DST_ALPHA,[H2]:a.ONE_MINUS_SRC_COLOR,[vo]:a.ONE_MINUS_SRC_ALPHA,[W2]:a.ONE_MINUS_DST_COLOR,[G2]:a.ONE_MINUS_DST_ALPHA,[q2]:a.CONSTANT_COLOR,[Y2]:a.ONE_MINUS_CONSTANT_COLOR,[K2]:a.CONSTANT_ALPHA,[$2]:a.ONE_MINUS_CONSTANT_ALPHA};function ke(L,ce,j,de,ve,te,Re,Se,Bt,At){if(L===Zn){m===!0&&(H(a.BLEND),m=!1);return}if(m===!1&&(ne(a.BLEND),m=!0),L!==Ml){if(L!==g||At!==I){if((_!==ra||S!==ra)&&(a.blendEquation(a.FUNC_ADD),_=ra,S=ra),At)switch(L){case Ws:a.blendFuncSeparate(a.ONE,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA);break;case Di:a.blendFunc(a.ONE,a.ONE);break;case K0:a.blendFuncSeparate(a.ZERO,a.ONE_MINUS_SRC_COLOR,a.ZERO,a.ONE);break;case $0:a.blendFuncSeparate(a.DST_COLOR,a.ONE_MINUS_SRC_ALPHA,a.ZERO,a.ONE);break;default:Be("WebGLState: Invalid blending: ",L);break}else switch(L){case Ws:a.blendFuncSeparate(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA);break;case Di:a.blendFuncSeparate(a.SRC_ALPHA,a.ONE,a.ONE,a.ONE);break;case K0:Be("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case $0:Be("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Be("WebGLState: Invalid blending: ",L);break}w=null,M=null,b=null,T=null,x.set(0,0,0),A=0,g=L,I=At}return}ve=ve||ce,te=te||j,Re=Re||de,(ce!==_||ve!==S)&&(a.blendEquationSeparate(ye[ce],ye[ve]),_=ce,S=ve),(j!==w||de!==M||te!==b||Re!==T)&&(a.blendFuncSeparate(Fe[j],Fe[de],Fe[te],Fe[Re]),w=j,M=de,b=te,T=Re),(Se.equals(x)===!1||Bt!==A)&&(a.blendColor(Se.r,Se.g,Se.b,Bt),x.copy(Se),A=Bt),g=L,I=!1}function ze(L,ce){L.side===tn?H(a.CULL_FACE):ne(a.CULL_FACE);let j=L.side===Ot;ce&&(j=!j),ft(j),L.blending===Ws&&L.transparent===!1?ke(Zn):ke(L.blending,L.blendEquation,L.blendSrc,L.blendDst,L.blendEquationAlpha,L.blendSrcAlpha,L.blendDstAlpha,L.blendColor,L.blendAlpha,L.premultipliedAlpha),r.setFunc(L.depthFunc),r.setTest(L.depthTest),r.setMask(L.depthWrite),s.setMask(L.colorWrite);const de=L.stencilWrite;o.setTest(de),de&&(o.setMask(L.stencilWriteMask),o.setFunc(L.stencilFunc,L.stencilRef,L.stencilFuncMask),o.setOp(L.stencilFail,L.stencilZFail,L.stencilZPass)),Lt(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?ne(a.SAMPLE_ALPHA_TO_COVERAGE):H(a.SAMPLE_ALPHA_TO_COVERAGE)}function ft(L){C!==L&&(L?a.frontFace(a.CW):a.frontFace(a.CCW),C=L)}function pt(L){L!==I2?(ne(a.CULL_FACE),L!==P&&(L===Y0?a.cullFace(a.BACK):L===P2?a.cullFace(a.FRONT):a.cullFace(a.FRONT_AND_BACK))):H(a.CULL_FACE),P=L}function zt(L){L!==X&&(k&&a.lineWidth(L),X=L)}function Lt(L,ce,j){L?(ne(a.POLYGON_OFFSET_FILL),(z!==ce||N!==j)&&(z=ce,N=j,r.getReversed()&&(ce=-ce),a.polygonOffset(ce,j))):H(a.POLYGON_OFFSET_FILL)}function Ht(L){L?ne(a.SCISSOR_TEST):H(a.SCISSOR_TEST)}function Qt(L){L===void 0&&(L=a.TEXTURE0+V-1),J!==L&&(a.activeTexture(L),J=L)}function O(L,ce,j){j===void 0&&(J===null?j=a.TEXTURE0+V-1:j=J);let de=ie[j];de===void 0&&(de={type:void 0,texture:void 0},ie[j]=de),(de.type!==L||de.texture!==ce)&&(J!==j&&(a.activeTexture(j),J=j),a.bindTexture(L,ce||re[L]),de.type=L,de.texture=ce)}function zi(){const L=ie[J];L!==void 0&&L.type!==void 0&&(a.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function mt(){try{a.compressedTexImage2D(...arguments)}catch(L){Be("WebGLState:",L)}}function R(){try{a.compressedTexImage3D(...arguments)}catch(L){Be("WebGLState:",L)}}function y(){try{a.texSubImage2D(...arguments)}catch(L){Be("WebGLState:",L)}}function F(){try{a.texSubImage3D(...arguments)}catch(L){Be("WebGLState:",L)}}function W(){try{a.compressedTexSubImage2D(...arguments)}catch(L){Be("WebGLState:",L)}}function $(){try{a.compressedTexSubImage3D(...arguments)}catch(L){Be("WebGLState:",L)}}function ae(){try{a.texStorage2D(...arguments)}catch(L){Be("WebGLState:",L)}}function le(){try{a.texStorage3D(...arguments)}catch(L){Be("WebGLState:",L)}}function Z(){try{a.texImage2D(...arguments)}catch(L){Be("WebGLState:",L)}}function Q(){try{a.texImage3D(...arguments)}catch(L){Be("WebGLState:",L)}}function he(L){return u[L]!==void 0?u[L]:a.getParameter(L)}function Ie(L,ce){u[L]!==ce&&(a.pixelStorei(L,ce),u[L]=ce)}function fe(L){Qe.equals(L)===!1&&(a.scissor(L.x,L.y,L.z,L.w),Qe.copy(L))}function ue(L){qe.equals(L)===!1&&(a.viewport(L.x,L.y,L.z,L.w),qe.copy(L))}function Ue(L,ce){let j=l.get(ce);j===void 0&&(j=new WeakMap,l.set(ce,j));let de=j.get(L);de===void 0&&(de=a.getUniformBlockIndex(ce,L.name),j.set(L,de))}function He(L,ce){const de=l.get(ce).get(L);c.get(ce)!==de&&(a.uniformBlockBinding(ce,de,L.__bindingPointIndex),c.set(ce,de))}function Ke(){a.disable(a.BLEND),a.disable(a.CULL_FACE),a.disable(a.DEPTH_TEST),a.disable(a.POLYGON_OFFSET_FILL),a.disable(a.SCISSOR_TEST),a.disable(a.STENCIL_TEST),a.disable(a.SAMPLE_ALPHA_TO_COVERAGE),a.blendEquation(a.FUNC_ADD),a.blendFunc(a.ONE,a.ZERO),a.blendFuncSeparate(a.ONE,a.ZERO,a.ONE,a.ZERO),a.blendColor(0,0,0,0),a.colorMask(!0,!0,!0,!0),a.clearColor(0,0,0,0),a.depthMask(!0),a.depthFunc(a.LESS),r.setReversed(!1),a.clearDepth(1),a.stencilMask(4294967295),a.stencilFunc(a.ALWAYS,0,4294967295),a.stencilOp(a.KEEP,a.KEEP,a.KEEP),a.clearStencil(0),a.cullFace(a.BACK),a.frontFace(a.CCW),a.polygonOffset(0,0),a.activeTexture(a.TEXTURE0),a.bindFramebuffer(a.FRAMEBUFFER,null),a.bindFramebuffer(a.DRAW_FRAMEBUFFER,null),a.bindFramebuffer(a.READ_FRAMEBUFFER,null),a.useProgram(null),a.lineWidth(1),a.scissor(0,0,a.canvas.width,a.canvas.height),a.viewport(0,0,a.canvas.width,a.canvas.height),a.pixelStorei(a.PACK_ALIGNMENT,4),a.pixelStorei(a.UNPACK_ALIGNMENT,4),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,!1),a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),a.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,a.BROWSER_DEFAULT_WEBGL),a.pixelStorei(a.PACK_ROW_LENGTH,0),a.pixelStorei(a.PACK_SKIP_PIXELS,0),a.pixelStorei(a.PACK_SKIP_ROWS,0),a.pixelStorei(a.UNPACK_ROW_LENGTH,0),a.pixelStorei(a.UNPACK_IMAGE_HEIGHT,0),a.pixelStorei(a.UNPACK_SKIP_PIXELS,0),a.pixelStorei(a.UNPACK_SKIP_ROWS,0),a.pixelStorei(a.UNPACK_SKIP_IMAGES,0),h={},u={},J=null,ie={},d={},f=new WeakMap,p=[],v=null,m=!1,g=null,_=null,w=null,M=null,S=null,b=null,T=null,x=new se(0,0,0),A=0,I=!1,C=null,P=null,X=null,z=null,N=null,Qe.set(0,0,a.canvas.width,a.canvas.height),qe.set(0,0,a.canvas.width,a.canvas.height),s.reset(),r.reset(),o.reset()}return{buffers:{color:s,depth:r,stencil:o},enable:ne,disable:H,bindFramebuffer:Ae,drawBuffers:Ne,useProgram:Ce,setBlending:ke,setMaterial:ze,setFlipSided:ft,setCullFace:pt,setLineWidth:zt,setPolygonOffset:Lt,setScissorTest:Ht,activeTexture:Qt,bindTexture:O,unbindTexture:zi,compressedTexImage2D:mt,compressedTexImage3D:R,texImage2D:Z,texImage3D:Q,pixelStorei:Ie,getParameter:he,updateUBOMapping:Ue,uniformBlockBinding:He,texStorage2D:ae,texStorage3D:le,texSubImage2D:y,texSubImage3D:F,compressedTexSubImage2D:W,compressedTexSubImage3D:$,scissor:fe,viewport:ue,reset:Ke}}function bS(a,e,t,i,n,s,r){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new xe,h=new WeakMap,u=new Set;let d;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(R,y){return p?new OffscreenCanvas(R,y):So("canvas")}function m(R,y,F){let W=1;const $=mt(R);if(($.width>F||$.height>F)&&(W=F/Math.max($.width,$.height)),W<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const ae=Math.floor(W*$.width),le=Math.floor(W*$.height);d===void 0&&(d=v(ae,le));const Z=y?v(ae,le):d;return Z.width=ae,Z.height=le,Z.getContext("2d").drawImage(R,0,0,ae,le),Te("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+ae+"x"+le+")."),Z}else return"data"in R&&Te("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),R;return R}function g(R){return R.generateMipmaps}function _(R){a.generateMipmap(R)}function w(R){return R.isWebGLCubeRenderTarget?a.TEXTURE_CUBE_MAP:R.isWebGL3DRenderTarget?a.TEXTURE_3D:R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture?a.TEXTURE_2D_ARRAY:a.TEXTURE_2D}function M(R,y,F,W,$,ae=!1){if(R!==null){if(a[R]!==void 0)return a[R];Te("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let le;W&&(le=e.get("EXT_texture_norm16"),le||Te("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Z=y;if(y===a.RED&&(F===a.FLOAT&&(Z=a.R32F),F===a.HALF_FLOAT&&(Z=a.R16F),F===a.UNSIGNED_BYTE&&(Z=a.R8),F===a.UNSIGNED_SHORT&&le&&(Z=le.R16_EXT),F===a.SHORT&&le&&(Z=le.R16_SNORM_EXT)),y===a.RED_INTEGER&&(F===a.UNSIGNED_BYTE&&(Z=a.R8UI),F===a.UNSIGNED_SHORT&&(Z=a.R16UI),F===a.UNSIGNED_INT&&(Z=a.R32UI),F===a.BYTE&&(Z=a.R8I),F===a.SHORT&&(Z=a.R16I),F===a.INT&&(Z=a.R32I)),y===a.RG&&(F===a.FLOAT&&(Z=a.RG32F),F===a.HALF_FLOAT&&(Z=a.RG16F),F===a.UNSIGNED_BYTE&&(Z=a.RG8),F===a.UNSIGNED_SHORT&&le&&(Z=le.RG16_EXT),F===a.SHORT&&le&&(Z=le.RG16_SNORM_EXT)),y===a.RG_INTEGER&&(F===a.UNSIGNED_BYTE&&(Z=a.RG8UI),F===a.UNSIGNED_SHORT&&(Z=a.RG16UI),F===a.UNSIGNED_INT&&(Z=a.RG32UI),F===a.BYTE&&(Z=a.RG8I),F===a.SHORT&&(Z=a.RG16I),F===a.INT&&(Z=a.RG32I)),y===a.RGB_INTEGER&&(F===a.UNSIGNED_BYTE&&(Z=a.RGB8UI),F===a.UNSIGNED_SHORT&&(Z=a.RGB16UI),F===a.UNSIGNED_INT&&(Z=a.RGB32UI),F===a.BYTE&&(Z=a.RGB8I),F===a.SHORT&&(Z=a.RGB16I),F===a.INT&&(Z=a.RGB32I)),y===a.RGBA_INTEGER&&(F===a.UNSIGNED_BYTE&&(Z=a.RGBA8UI),F===a.UNSIGNED_SHORT&&(Z=a.RGBA16UI),F===a.UNSIGNED_INT&&(Z=a.RGBA32UI),F===a.BYTE&&(Z=a.RGBA8I),F===a.SHORT&&(Z=a.RGBA16I),F===a.INT&&(Z=a.RGBA32I)),y===a.RGB&&(F===a.UNSIGNED_SHORT&&le&&(Z=le.RGB16_EXT),F===a.SHORT&&le&&(Z=le.RGB16_SNORM_EXT),F===a.UNSIGNED_INT_5_9_9_9_REV&&(Z=a.RGB9_E5),F===a.UNSIGNED_INT_10F_11F_11F_REV&&(Z=a.R11F_G11F_B10F)),y===a.RGBA){const Q=ae?el:it.getTransfer($);F===a.FLOAT&&(Z=a.RGBA32F),F===a.HALF_FLOAT&&(Z=a.RGBA16F),F===a.UNSIGNED_BYTE&&(Z=Q===gt?a.SRGB8_ALPHA8:a.RGBA8),F===a.UNSIGNED_SHORT&&le&&(Z=le.RGBA16_EXT),F===a.SHORT&&le&&(Z=le.RGBA16_SNORM_EXT),F===a.UNSIGNED_SHORT_4_4_4_4&&(Z=a.RGBA4),F===a.UNSIGNED_SHORT_5_5_5_1&&(Z=a.RGB5_A1)}return(Z===a.R16F||Z===a.R32F||Z===a.RG16F||Z===a.RG32F||Z===a.RGBA16F||Z===a.RGBA32F)&&e.get("EXT_color_buffer_float"),Z}function S(R,y){let F;return R?y===null||y===gn||y===yo?F=a.DEPTH24_STENCIL8:y===Ri?F=a.DEPTH32F_STENCIL8:y===xo&&(F=a.DEPTH24_STENCIL8,Te("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):y===null||y===gn||y===yo?F=a.DEPTH_COMPONENT24:y===Ri?F=a.DEPTH_COMPONENT32F:y===xo&&(F=a.DEPTH_COMPONENT16),F}function b(R,y){return g(R)===!0||R.isFramebufferTexture&&R.minFilter!==wt&&R.minFilter!==st?Math.log2(Math.max(y.width,y.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?y.mipmaps.length:1}function T(R){const y=R.target;y.removeEventListener("dispose",T),A(y),y.isVideoTexture&&h.delete(y),y.isHTMLTexture&&u.delete(y)}function x(R){const y=R.target;y.removeEventListener("dispose",x),C(y)}function A(R){const y=i.get(R);if(y.__webglInit===void 0)return;const F=R.source,W=f.get(F);if(W){const $=W[y.__cacheKey];$.usedTimes--,$.usedTimes===0&&I(R),Object.keys(W).length===0&&f.delete(F)}i.remove(R)}function I(R){const y=i.get(R);a.deleteTexture(y.__webglTexture);const F=R.source,W=f.get(F);delete W[y.__cacheKey],r.memory.textures--}function C(R){const y=i.get(R);if(R.depthTexture&&(R.depthTexture.dispose(),i.remove(R.depthTexture)),R.isWebGLCubeRenderTarget)for(let W=0;W<6;W++){if(Array.isArray(y.__webglFramebuffer[W]))for(let $=0;$<y.__webglFramebuffer[W].length;$++)a.deleteFramebuffer(y.__webglFramebuffer[W][$]);else a.deleteFramebuffer(y.__webglFramebuffer[W]);y.__webglDepthbuffer&&a.deleteRenderbuffer(y.__webglDepthbuffer[W])}else{if(Array.isArray(y.__webglFramebuffer))for(let W=0;W<y.__webglFramebuffer.length;W++)a.deleteFramebuffer(y.__webglFramebuffer[W]);else a.deleteFramebuffer(y.__webglFramebuffer);if(y.__webglDepthbuffer&&a.deleteRenderbuffer(y.__webglDepthbuffer),y.__webglMultisampledFramebuffer&&a.deleteFramebuffer(y.__webglMultisampledFramebuffer),y.__webglColorRenderbuffer)for(let W=0;W<y.__webglColorRenderbuffer.length;W++)y.__webglColorRenderbuffer[W]&&a.deleteRenderbuffer(y.__webglColorRenderbuffer[W]);y.__webglDepthRenderbuffer&&a.deleteRenderbuffer(y.__webglDepthRenderbuffer)}const F=R.textures;for(let W=0,$=F.length;W<$;W++){const ae=i.get(F[W]);ae.__webglTexture&&(a.deleteTexture(ae.__webglTexture),r.memory.textures--),i.remove(F[W])}i.remove(R)}let P=0;function X(){P=0}function z(){return P}function N(R){P=R}function V(){const R=P;return R>=n.maxTextures&&Te("WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+n.maxTextures),P+=1,R}function k(R){const y=[];return y.push(R.wrapS),y.push(R.wrapT),y.push(R.wrapR||0),y.push(R.magFilter),y.push(R.minFilter),y.push(R.anisotropy),y.push(R.internalFormat),y.push(R.format),y.push(R.type),y.push(R.generateMipmaps),y.push(R.premultiplyAlpha),y.push(R.flipY),y.push(R.unpackAlignment),y.push(R.colorSpace),y.join()}function K(R,y){const F=i.get(R);if(R.isVideoTexture&&O(R),R.isRenderTargetTexture===!1&&R.isExternalTexture!==!0&&R.version>0&&F.__version!==R.version){const W=R.image;if(W===null)Te("WebGLRenderer: Texture marked for update but no image data found.");else if(W.complete===!1)Te("WebGLRenderer: Texture marked for update but image is incomplete");else{H(F,R,y);return}}else R.isExternalTexture&&(F.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(a.TEXTURE_2D,F.__webglTexture,a.TEXTURE0+y)}function ee(R,y){const F=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&F.__version!==R.version){H(F,R,y);return}else R.isExternalTexture&&(F.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(a.TEXTURE_2D_ARRAY,F.__webglTexture,a.TEXTURE0+y)}function J(R,y){const F=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&F.__version!==R.version){H(F,R,y);return}t.bindTexture(a.TEXTURE_3D,F.__webglTexture,a.TEXTURE0+y)}function ie(R,y){const F=i.get(R);if(R.isCubeDepthTexture!==!0&&R.version>0&&F.__version!==R.version){Ae(F,R,y);return}t.bindTexture(a.TEXTURE_CUBE_MAP,F.__webglTexture,a.TEXTURE0+y)}const oe={[Mo]:a.REPEAT,[xi]:a.CLAMP_TO_EDGE,[uu]:a.MIRRORED_REPEAT},Ve={[wt]:a.NEAREST,[Q2]:a.NEAREST_MIPMAP_NEAREST,[ko]:a.NEAREST_MIPMAP_LINEAR,[st]:a.LINEAR,[kl]:a.LINEAR_MIPMAP_NEAREST,[da]:a.LINEAR_MIPMAP_LINEAR},Qe={[nv]:a.NEVER,[cv]:a.ALWAYS,[sv]:a.LESS,[Fd]:a.LEQUAL,[av]:a.EQUAL,[kd]:a.GEQUAL,[rv]:a.GREATER,[ov]:a.NOTEQUAL};function qe(R,y){if(y.type===Ri&&e.has("OES_texture_float_linear")===!1&&(y.magFilter===st||y.magFilter===kl||y.magFilter===ko||y.magFilter===da||y.minFilter===st||y.minFilter===kl||y.minFilter===ko||y.minFilter===da)&&Te("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),a.texParameteri(R,a.TEXTURE_WRAP_S,oe[y.wrapS]),a.texParameteri(R,a.TEXTURE_WRAP_T,oe[y.wrapT]),(R===a.TEXTURE_3D||R===a.TEXTURE_2D_ARRAY)&&a.texParameteri(R,a.TEXTURE_WRAP_R,oe[y.wrapR]),a.texParameteri(R,a.TEXTURE_MAG_FILTER,Ve[y.magFilter]),a.texParameteri(R,a.TEXTURE_MIN_FILTER,Ve[y.minFilter]),y.compareFunction&&(a.texParameteri(R,a.TEXTURE_COMPARE_MODE,a.COMPARE_REF_TO_TEXTURE),a.texParameteri(R,a.TEXTURE_COMPARE_FUNC,Qe[y.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===wt||y.minFilter!==ko&&y.minFilter!==da||y.type===Ri&&e.has("OES_texture_float_linear")===!1)return;if(y.anisotropy>1||i.get(y).__currentAnisotropy){const F=e.get("EXT_texture_filter_anisotropic");a.texParameterf(R,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,n.getMaxAnisotropy())),i.get(y).__currentAnisotropy=y.anisotropy}}}function Y(R,y){let F=!1;R.__webglInit===void 0&&(R.__webglInit=!0,y.addEventListener("dispose",T));const W=y.source;let $=f.get(W);$===void 0&&($={},f.set(W,$));const ae=k(y);if(ae!==R.__cacheKey){$[ae]===void 0&&($[ae]={texture:a.createTexture(),usedTimes:0},r.memory.textures++,F=!0),$[ae].usedTimes++;const le=$[R.__cacheKey];le!==void 0&&($[R.__cacheKey].usedTimes--,le.usedTimes===0&&I(y)),R.__cacheKey=ae,R.__webglTexture=$[ae].texture}return F}function re(R,y,F){return Math.floor(Math.floor(R/F)/y)}function ne(R,y,F,W){const ae=R.updateRanges;if(ae.length===0)t.texSubImage2D(a.TEXTURE_2D,0,0,0,y.width,y.height,F,W,y.data);else{ae.sort((Ie,fe)=>Ie.start-fe.start);let le=0;for(let Ie=1;Ie<ae.length;Ie++){const fe=ae[le],ue=ae[Ie],Ue=fe.start+fe.count,He=re(ue.start,y.width,4),Ke=re(fe.start,y.width,4);ue.start<=Ue+1&&He===Ke&&re(ue.start+ue.count-1,y.width,4)===He?fe.count=Math.max(fe.count,ue.start+ue.count-fe.start):(++le,ae[le]=ue)}ae.length=le+1;const Z=t.getParameter(a.UNPACK_ROW_LENGTH),Q=t.getParameter(a.UNPACK_SKIP_PIXELS),he=t.getParameter(a.UNPACK_SKIP_ROWS);t.pixelStorei(a.UNPACK_ROW_LENGTH,y.width);for(let Ie=0,fe=ae.length;Ie<fe;Ie++){const ue=ae[Ie],Ue=Math.floor(ue.start/4),He=Math.ceil(ue.count/4),Ke=Ue%y.width,L=Math.floor(Ue/y.width),ce=He,j=1;t.pixelStorei(a.UNPACK_SKIP_PIXELS,Ke),t.pixelStorei(a.UNPACK_SKIP_ROWS,L),t.texSubImage2D(a.TEXTURE_2D,0,Ke,L,ce,j,F,W,y.data)}R.clearUpdateRanges(),t.pixelStorei(a.UNPACK_ROW_LENGTH,Z),t.pixelStorei(a.UNPACK_SKIP_PIXELS,Q),t.pixelStorei(a.UNPACK_SKIP_ROWS,he)}}function H(R,y,F){let W=a.TEXTURE_2D;(y.isDataArrayTexture||y.isCompressedArrayTexture)&&(W=a.TEXTURE_2D_ARRAY),y.isData3DTexture&&(W=a.TEXTURE_3D);const $=Y(R,y),ae=y.source;t.bindTexture(W,R.__webglTexture,a.TEXTURE0+F);const le=i.get(ae);if(ae.version!==le.__version||$===!0){if(t.activeTexture(a.TEXTURE0+F),(typeof ImageBitmap<"u"&&y.image instanceof ImageBitmap)===!1){const j=it.getPrimaries(it.workingColorSpace),de=y.colorSpace===zs?null:it.getPrimaries(y.colorSpace),ve=y.colorSpace===zs||j===de?a.NONE:a.BROWSER_DEFAULT_WEBGL;t.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,y.flipY),t.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),t.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,ve)}t.pixelStorei(a.UNPACK_ALIGNMENT,y.unpackAlignment);let Q=m(y.image,!1,n.maxTextureSize);Q=zi(y,Q);const he=s.convert(y.format,y.colorSpace),Ie=s.convert(y.type);let fe=M(y.internalFormat,he,Ie,y.normalized,y.colorSpace,y.isVideoTexture);qe(W,y);let ue;const Ue=y.mipmaps,He=y.isVideoTexture!==!0,Ke=le.__version===void 0||$===!0,L=ae.dataReady,ce=b(y,Q);if(y.isDepthTexture)fe=S(y.format===fa,y.type),Ke&&(He?t.texStorage2D(a.TEXTURE_2D,1,fe,Q.width,Q.height):t.texImage2D(a.TEXTURE_2D,0,fe,Q.width,Q.height,0,he,Ie,null));else if(y.isDataTexture)if(Ue.length>0){He&&Ke&&t.texStorage2D(a.TEXTURE_2D,ce,fe,Ue[0].width,Ue[0].height);for(let j=0,de=Ue.length;j<de;j++)ue=Ue[j],He?L&&t.texSubImage2D(a.TEXTURE_2D,j,0,0,ue.width,ue.height,he,Ie,ue.data):t.texImage2D(a.TEXTURE_2D,j,fe,ue.width,ue.height,0,he,Ie,ue.data);y.generateMipmaps=!1}else He?(Ke&&t.texStorage2D(a.TEXTURE_2D,ce,fe,Q.width,Q.height),L&&ne(y,Q,he,Ie)):t.texImage2D(a.TEXTURE_2D,0,fe,Q.width,Q.height,0,he,Ie,Q.data);else if(y.isCompressedTexture)if(y.isCompressedArrayTexture){He&&Ke&&t.texStorage3D(a.TEXTURE_2D_ARRAY,ce,fe,Ue[0].width,Ue[0].height,Q.depth);for(let j=0,de=Ue.length;j<de;j++)if(ue=Ue[j],y.format!==yi)if(he!==null)if(He){if(L)if(y.layerUpdates.size>0){const ve=Xf(ue.width,ue.height,y.format,y.type);for(const te of y.layerUpdates){const Re=ue.data.subarray(te*ve/ue.data.BYTES_PER_ELEMENT,(te+1)*ve/ue.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(a.TEXTURE_2D_ARRAY,j,0,0,te,ue.width,ue.height,1,he,Re)}y.clearLayerUpdates()}else t.compressedTexSubImage3D(a.TEXTURE_2D_ARRAY,j,0,0,0,ue.width,ue.height,Q.depth,he,ue.data)}else t.compressedTexImage3D(a.TEXTURE_2D_ARRAY,j,fe,ue.width,ue.height,Q.depth,0,ue.data,0,0);else Te("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else He?L&&t.texSubImage3D(a.TEXTURE_2D_ARRAY,j,0,0,0,ue.width,ue.height,Q.depth,he,Ie,ue.data):t.texImage3D(a.TEXTURE_2D_ARRAY,j,fe,ue.width,ue.height,Q.depth,0,he,Ie,ue.data)}else{He&&Ke&&t.texStorage2D(a.TEXTURE_2D,ce,fe,Ue[0].width,Ue[0].height);for(let j=0,de=Ue.length;j<de;j++)ue=Ue[j],y.format!==yi?he!==null?He?L&&t.compressedTexSubImage2D(a.TEXTURE_2D,j,0,0,ue.width,ue.height,he,ue.data):t.compressedTexImage2D(a.TEXTURE_2D,j,fe,ue.width,ue.height,0,ue.data):Te("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):He?L&&t.texSubImage2D(a.TEXTURE_2D,j,0,0,ue.width,ue.height,he,Ie,ue.data):t.texImage2D(a.TEXTURE_2D,j,fe,ue.width,ue.height,0,he,Ie,ue.data)}else if(y.isDataArrayTexture)if(He){if(Ke&&t.texStorage3D(a.TEXTURE_2D_ARRAY,ce,fe,Q.width,Q.height,Q.depth),L)if(y.layerUpdates.size>0){const j=Xf(Q.width,Q.height,y.format,y.type);for(const de of y.layerUpdates){const ve=Q.data.subarray(de*j/Q.data.BYTES_PER_ELEMENT,(de+1)*j/Q.data.BYTES_PER_ELEMENT);t.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,de,Q.width,Q.height,1,he,Ie,ve)}y.clearLayerUpdates()}else t.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,he,Ie,Q.data)}else t.texImage3D(a.TEXTURE_2D_ARRAY,0,fe,Q.width,Q.height,Q.depth,0,he,Ie,Q.data);else if(y.isData3DTexture)He?(Ke&&t.texStorage3D(a.TEXTURE_3D,ce,fe,Q.width,Q.height,Q.depth),L&&t.texSubImage3D(a.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,he,Ie,Q.data)):t.texImage3D(a.TEXTURE_3D,0,fe,Q.width,Q.height,Q.depth,0,he,Ie,Q.data);else if(y.isFramebufferTexture){if(Ke)if(He)t.texStorage2D(a.TEXTURE_2D,ce,fe,Q.width,Q.height);else{let j=Q.width,de=Q.height;for(let ve=0;ve<ce;ve++)t.texImage2D(a.TEXTURE_2D,ve,fe,j,de,0,he,Ie,null),j>>=1,de>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in a){const j=a.canvas;if(j.hasAttribute("layoutsubtree")||j.setAttribute("layoutsubtree","true"),Q.parentNode!==j){j.appendChild(Q),u.add(y),j.onpaint=de=>{const ve=de.changedElements;for(const te of u)ve.includes(te.image)&&(te.needsUpdate=!0)},j.requestPaint();return}if(a.texElementImage2D.length===3)a.texElementImage2D(a.TEXTURE_2D,a.RGBA8,Q);else{const ve=a.RGBA,te=a.RGBA,Re=a.UNSIGNED_BYTE;a.texElementImage2D(a.TEXTURE_2D,0,ve,te,Re,Q)}a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE)}}else if(Ue.length>0){if(He&&Ke){const j=mt(Ue[0]);t.texStorage2D(a.TEXTURE_2D,ce,fe,j.width,j.height)}for(let j=0,de=Ue.length;j<de;j++)ue=Ue[j],He?L&&t.texSubImage2D(a.TEXTURE_2D,j,0,0,he,Ie,ue):t.texImage2D(a.TEXTURE_2D,j,fe,he,Ie,ue);y.generateMipmaps=!1}else if(He){if(Ke){const j=mt(Q);t.texStorage2D(a.TEXTURE_2D,ce,fe,j.width,j.height)}L&&t.texSubImage2D(a.TEXTURE_2D,0,0,0,he,Ie,Q)}else t.texImage2D(a.TEXTURE_2D,0,fe,he,Ie,Q);g(y)&&_(W),le.__version=ae.version,y.onUpdate&&y.onUpdate(y)}R.__version=y.version}function Ae(R,y,F){if(y.image.length!==6)return;const W=Y(R,y),$=y.source;t.bindTexture(a.TEXTURE_CUBE_MAP,R.__webglTexture,a.TEXTURE0+F);const ae=i.get($);if($.version!==ae.__version||W===!0){t.activeTexture(a.TEXTURE0+F);const le=it.getPrimaries(it.workingColorSpace),Z=y.colorSpace===zs?null:it.getPrimaries(y.colorSpace),Q=y.colorSpace===zs||le===Z?a.NONE:a.BROWSER_DEFAULT_WEBGL;t.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,y.flipY),t.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),t.pixelStorei(a.UNPACK_ALIGNMENT,y.unpackAlignment),t.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);const he=y.isCompressedTexture||y.image[0].isCompressedTexture,Ie=y.image[0]&&y.image[0].isDataTexture,fe=[];for(let te=0;te<6;te++)!he&&!Ie?fe[te]=m(y.image[te],!0,n.maxCubemapSize):fe[te]=Ie?y.image[te].image:y.image[te],fe[te]=zi(y,fe[te]);const ue=fe[0],Ue=s.convert(y.format,y.colorSpace),He=s.convert(y.type),Ke=M(y.internalFormat,Ue,He,y.normalized,y.colorSpace),L=y.isVideoTexture!==!0,ce=ae.__version===void 0||W===!0,j=$.dataReady;let de=b(y,ue);qe(a.TEXTURE_CUBE_MAP,y);let ve;if(he){L&&ce&&t.texStorage2D(a.TEXTURE_CUBE_MAP,de,Ke,ue.width,ue.height);for(let te=0;te<6;te++){ve=fe[te].mipmaps;for(let Re=0;Re<ve.length;Re++){const Se=ve[Re];y.format!==yi?Ue!==null?L?j&&t.compressedTexSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,Re,0,0,Se.width,Se.height,Ue,Se.data):t.compressedTexImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,Re,Ke,Se.width,Se.height,0,Se.data):Te("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?j&&t.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,Re,0,0,Se.width,Se.height,Ue,He,Se.data):t.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,Re,Ke,Se.width,Se.height,0,Ue,He,Se.data)}}}else{if(ve=y.mipmaps,L&&ce){ve.length>0&&de++;const te=mt(fe[0]);t.texStorage2D(a.TEXTURE_CUBE_MAP,de,Ke,te.width,te.height)}for(let te=0;te<6;te++)if(Ie){L?j&&t.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,fe[te].width,fe[te].height,Ue,He,fe[te].data):t.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,Ke,fe[te].width,fe[te].height,0,Ue,He,fe[te].data);for(let Re=0;Re<ve.length;Re++){const Bt=ve[Re].image[te].image;L?j&&t.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,Re+1,0,0,Bt.width,Bt.height,Ue,He,Bt.data):t.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,Re+1,Ke,Bt.width,Bt.height,0,Ue,He,Bt.data)}}else{L?j&&t.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,Ue,He,fe[te]):t.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,Ke,Ue,He,fe[te]);for(let Re=0;Re<ve.length;Re++){const Se=ve[Re];L?j&&t.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,Re+1,0,0,Ue,He,Se.image[te]):t.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,Re+1,Ke,Ue,He,Se.image[te])}}}g(y)&&_(a.TEXTURE_CUBE_MAP),ae.__version=$.version,y.onUpdate&&y.onUpdate(y)}R.__version=y.version}function Ne(R,y,F,W,$,ae){const le=s.convert(F.format,F.colorSpace),Z=s.convert(F.type),Q=M(F.internalFormat,le,Z,F.normalized,F.colorSpace),he=i.get(y),Ie=i.get(F);if(Ie.__renderTarget=y,!he.__hasExternalTextures){const fe=Math.max(1,y.width>>ae),ue=Math.max(1,y.height>>ae);$===a.TEXTURE_3D||$===a.TEXTURE_2D_ARRAY?t.texImage3D($,ae,Q,fe,ue,y.depth,0,le,Z,null):t.texImage2D($,ae,Q,fe,ue,0,le,Z,null)}t.bindFramebuffer(a.FRAMEBUFFER,R),Qt(y)?o.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,W,$,Ie.__webglTexture,0,Ht(y)):($===a.TEXTURE_2D||$>=a.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=a.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&a.framebufferTexture2D(a.FRAMEBUFFER,W,$,Ie.__webglTexture,ae),t.bindFramebuffer(a.FRAMEBUFFER,null)}function Ce(R,y,F){if(a.bindRenderbuffer(a.RENDERBUFFER,R),y.depthBuffer){const W=y.depthTexture,$=W&&W.isDepthTexture?W.type:null,ae=S(y.stencilBuffer,$),le=y.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;Qt(y)?o.renderbufferStorageMultisampleEXT(a.RENDERBUFFER,Ht(y),ae,y.width,y.height):F?a.renderbufferStorageMultisample(a.RENDERBUFFER,Ht(y),ae,y.width,y.height):a.renderbufferStorage(a.RENDERBUFFER,ae,y.width,y.height),a.framebufferRenderbuffer(a.FRAMEBUFFER,le,a.RENDERBUFFER,R)}else{const W=y.textures;for(let $=0;$<W.length;$++){const ae=W[$],le=s.convert(ae.format,ae.colorSpace),Z=s.convert(ae.type),Q=M(ae.internalFormat,le,Z,ae.normalized,ae.colorSpace);Qt(y)?o.renderbufferStorageMultisampleEXT(a.RENDERBUFFER,Ht(y),Q,y.width,y.height):F?a.renderbufferStorageMultisample(a.RENDERBUFFER,Ht(y),Q,y.width,y.height):a.renderbufferStorage(a.RENDERBUFFER,Q,y.width,y.height)}}a.bindRenderbuffer(a.RENDERBUFFER,null)}function ye(R,y,F){const W=y.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(a.FRAMEBUFFER,R),!(y.depthTexture&&y.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const $=i.get(y.depthTexture);if($.__renderTarget=y,(!$.__webglTexture||y.depthTexture.image.width!==y.width||y.depthTexture.image.height!==y.height)&&(y.depthTexture.image.width=y.width,y.depthTexture.image.height=y.height,y.depthTexture.needsUpdate=!0),W){if($.__webglInit===void 0&&($.__webglInit=!0,y.depthTexture.addEventListener("dispose",T)),$.__webglTexture===void 0){$.__webglTexture=a.createTexture(),t.bindTexture(a.TEXTURE_CUBE_MAP,$.__webglTexture),qe(a.TEXTURE_CUBE_MAP,y.depthTexture);const he=s.convert(y.depthTexture.format),Ie=s.convert(y.depthTexture.type);let fe;y.depthTexture.format===vs?fe=a.DEPTH_COMPONENT24:y.depthTexture.format===fa&&(fe=a.DEPTH24_STENCIL8);for(let ue=0;ue<6;ue++)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+ue,0,fe,y.width,y.height,0,he,Ie,null)}}else K(y.depthTexture,0);const ae=$.__webglTexture,le=Ht(y),Z=W?a.TEXTURE_CUBE_MAP_POSITIVE_X+F:a.TEXTURE_2D,Q=y.depthTexture.format===fa?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;if(y.depthTexture.format===vs)Qt(y)?o.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,Q,Z,ae,0,le):a.framebufferTexture2D(a.FRAMEBUFFER,Q,Z,ae,0);else if(y.depthTexture.format===fa)Qt(y)?o.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,Q,Z,ae,0,le):a.framebufferTexture2D(a.FRAMEBUFFER,Q,Z,ae,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Fe(R){const y=i.get(R),F=R.isWebGLCubeRenderTarget===!0;if(y.__boundDepthTexture!==R.depthTexture){const W=R.depthTexture;if(y.__depthDisposeCallback&&y.__depthDisposeCallback(),W){const $=()=>{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,W.removeEventListener("dispose",$)};W.addEventListener("dispose",$),y.__depthDisposeCallback=$}y.__boundDepthTexture=W}if(R.depthTexture&&!y.__autoAllocateDepthBuffer)if(F)for(let W=0;W<6;W++)ye(y.__webglFramebuffer[W],R,W);else{const W=R.texture.mipmaps;W&&W.length>0?ye(y.__webglFramebuffer[0],R,0):ye(y.__webglFramebuffer,R,0)}else if(F){y.__webglDepthbuffer=[];for(let W=0;W<6;W++)if(t.bindFramebuffer(a.FRAMEBUFFER,y.__webglFramebuffer[W]),y.__webglDepthbuffer[W]===void 0)y.__webglDepthbuffer[W]=a.createRenderbuffer(),Ce(y.__webglDepthbuffer[W],R,!1);else{const $=R.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,ae=y.__webglDepthbuffer[W];a.bindRenderbuffer(a.RENDERBUFFER,ae),a.framebufferRenderbuffer(a.FRAMEBUFFER,$,a.RENDERBUFFER,ae)}}else{const W=R.texture.mipmaps;if(W&&W.length>0?t.bindFramebuffer(a.FRAMEBUFFER,y.__webglFramebuffer[0]):t.bindFramebuffer(a.FRAMEBUFFER,y.__webglFramebuffer),y.__webglDepthbuffer===void 0)y.__webglDepthbuffer=a.createRenderbuffer(),Ce(y.__webglDepthbuffer,R,!1);else{const $=R.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,ae=y.__webglDepthbuffer;a.bindRenderbuffer(a.RENDERBUFFER,ae),a.framebufferRenderbuffer(a.FRAMEBUFFER,$,a.RENDERBUFFER,ae)}}t.bindFramebuffer(a.FRAMEBUFFER,null)}function ke(R,y,F){const W=i.get(R);y!==void 0&&Ne(W.__webglFramebuffer,R,R.texture,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,0),F!==void 0&&Fe(R)}function ze(R){const y=R.texture,F=i.get(R),W=i.get(y);R.addEventListener("dispose",x);const $=R.textures,ae=R.isWebGLCubeRenderTarget===!0,le=$.length>1;if(le||(W.__webglTexture===void 0&&(W.__webglTexture=a.createTexture()),W.__version=y.version,r.memory.textures++),ae){F.__webglFramebuffer=[];for(let Z=0;Z<6;Z++)if(y.mipmaps&&y.mipmaps.length>0){F.__webglFramebuffer[Z]=[];for(let Q=0;Q<y.mipmaps.length;Q++)F.__webglFramebuffer[Z][Q]=a.createFramebuffer()}else F.__webglFramebuffer[Z]=a.createFramebuffer()}else{if(y.mipmaps&&y.mipmaps.length>0){F.__webglFramebuffer=[];for(let Z=0;Z<y.mipmaps.length;Z++)F.__webglFramebuffer[Z]=a.createFramebuffer()}else F.__webglFramebuffer=a.createFramebuffer();if(le)for(let Z=0,Q=$.length;Z<Q;Z++){const he=i.get($[Z]);he.__webglTexture===void 0&&(he.__webglTexture=a.createTexture(),r.memory.textures++)}if(R.samples>0&&Qt(R)===!1){F.__webglMultisampledFramebuffer=a.createFramebuffer(),F.__webglColorRenderbuffer=[],t.bindFramebuffer(a.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let Z=0;Z<$.length;Z++){const Q=$[Z];F.__webglColorRenderbuffer[Z]=a.createRenderbuffer(),a.bindRenderbuffer(a.RENDERBUFFER,F.__webglColorRenderbuffer[Z]);const he=s.convert(Q.format,Q.colorSpace),Ie=s.convert(Q.type),fe=M(Q.internalFormat,he,Ie,Q.normalized,Q.colorSpace,R.isXRRenderTarget===!0),ue=Ht(R);a.renderbufferStorageMultisample(a.RENDERBUFFER,ue,fe,R.width,R.height),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+Z,a.RENDERBUFFER,F.__webglColorRenderbuffer[Z])}a.bindRenderbuffer(a.RENDERBUFFER,null),R.depthBuffer&&(F.__webglDepthRenderbuffer=a.createRenderbuffer(),Ce(F.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(a.FRAMEBUFFER,null)}}if(ae){t.bindTexture(a.TEXTURE_CUBE_MAP,W.__webglTexture),qe(a.TEXTURE_CUBE_MAP,y);for(let Z=0;Z<6;Z++)if(y.mipmaps&&y.mipmaps.length>0)for(let Q=0;Q<y.mipmaps.length;Q++)Ne(F.__webglFramebuffer[Z][Q],R,y,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Q);else Ne(F.__webglFramebuffer[Z],R,y,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0);g(y)&&_(a.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(le){for(let Z=0,Q=$.length;Z<Q;Z++){const he=$[Z],Ie=i.get(he);let fe=a.TEXTURE_2D;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(fe=R.isWebGL3DRenderTarget?a.TEXTURE_3D:a.TEXTURE_2D_ARRAY),t.bindTexture(fe,Ie.__webglTexture),qe(fe,he),Ne(F.__webglFramebuffer,R,he,a.COLOR_ATTACHMENT0+Z,fe,0),g(he)&&_(fe)}t.unbindTexture()}else{let Z=a.TEXTURE_2D;if((R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(Z=R.isWebGL3DRenderTarget?a.TEXTURE_3D:a.TEXTURE_2D_ARRAY),t.bindTexture(Z,W.__webglTexture),qe(Z,y),y.mipmaps&&y.mipmaps.length>0)for(let Q=0;Q<y.mipmaps.length;Q++)Ne(F.__webglFramebuffer[Q],R,y,a.COLOR_ATTACHMENT0,Z,Q);else Ne(F.__webglFramebuffer,R,y,a.COLOR_ATTACHMENT0,Z,0);g(y)&&_(Z),t.unbindTexture()}R.depthBuffer&&Fe(R)}function ft(R){const y=R.textures;for(let F=0,W=y.length;F<W;F++){const $=y[F];if(g($)){const ae=w(R),le=i.get($).__webglTexture;t.bindTexture(ae,le),_(ae),t.unbindTexture()}}}const pt=[],zt=[];function Lt(R){if(R.samples>0){if(Qt(R)===!1){const y=R.textures,F=R.width,W=R.height;let $=a.COLOR_BUFFER_BIT;const ae=R.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,le=i.get(R),Z=y.length>1;if(Z)for(let he=0;he<y.length;he++)t.bindFramebuffer(a.FRAMEBUFFER,le.__webglMultisampledFramebuffer),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+he,a.RENDERBUFFER,null),t.bindFramebuffer(a.FRAMEBUFFER,le.__webglFramebuffer),a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0+he,a.TEXTURE_2D,null,0);t.bindFramebuffer(a.READ_FRAMEBUFFER,le.__webglMultisampledFramebuffer);const Q=R.texture.mipmaps;Q&&Q.length>0?t.bindFramebuffer(a.DRAW_FRAMEBUFFER,le.__webglFramebuffer[0]):t.bindFramebuffer(a.DRAW_FRAMEBUFFER,le.__webglFramebuffer);for(let he=0;he<y.length;he++){if(R.resolveDepthBuffer&&(R.depthBuffer&&($|=a.DEPTH_BUFFER_BIT),R.stencilBuffer&&R.resolveStencilBuffer&&($|=a.STENCIL_BUFFER_BIT)),Z){a.framebufferRenderbuffer(a.READ_FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.RENDERBUFFER,le.__webglColorRenderbuffer[he]);const Ie=i.get(y[he]).__webglTexture;a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,Ie,0)}a.blitFramebuffer(0,0,F,W,0,0,F,W,$,a.NEAREST),c===!0&&(pt.length=0,zt.length=0,pt.push(a.COLOR_ATTACHMENT0+he),R.depthBuffer&&R.resolveDepthBuffer===!1&&(pt.push(ae),zt.push(ae),a.invalidateFramebuffer(a.DRAW_FRAMEBUFFER,zt)),a.invalidateFramebuffer(a.READ_FRAMEBUFFER,pt))}if(t.bindFramebuffer(a.READ_FRAMEBUFFER,null),t.bindFramebuffer(a.DRAW_FRAMEBUFFER,null),Z)for(let he=0;he<y.length;he++){t.bindFramebuffer(a.FRAMEBUFFER,le.__webglMultisampledFramebuffer),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+he,a.RENDERBUFFER,le.__webglColorRenderbuffer[he]);const Ie=i.get(y[he]).__webglTexture;t.bindFramebuffer(a.FRAMEBUFFER,le.__webglFramebuffer),a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0+he,a.TEXTURE_2D,Ie,0)}t.bindFramebuffer(a.DRAW_FRAMEBUFFER,le.__webglMultisampledFramebuffer)}else if(R.depthBuffer&&R.resolveDepthBuffer===!1&&c){const y=R.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;a.invalidateFramebuffer(a.DRAW_FRAMEBUFFER,[y])}}}function Ht(R){return Math.min(n.maxSamples,R.samples)}function Qt(R){const y=i.get(R);return R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function O(R){const y=r.render.frame;h.get(R)!==y&&(h.set(R,y),R.update())}function zi(R,y){const F=R.colorSpace,W=R.format,$=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||F!==Qc&&F!==zs&&(it.getTransfer(F)===gt?(W!==yi||$!==nn)&&Te("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Be("WebGLTextures: Unsupported texture color space:",F)),y}function mt(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(l.width=R.naturalWidth||R.width,l.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(l.width=R.displayWidth,l.height=R.displayHeight):(l.width=R.width,l.height=R.height),l}this.allocateTextureUnit=V,this.resetTextureUnits=X,this.getTextureUnits=z,this.setTextureUnits=N,this.setTexture2D=K,this.setTexture2DArray=ee,this.setTexture3D=J,this.setTextureCube=ie,this.rebindTextures=ke,this.setupRenderTarget=ze,this.updateRenderTargetMipmap=ft,this.updateMultisampleRenderTarget=Lt,this.setupDepthRenderbuffer=Fe,this.setupFrameBufferTexture=Ne,this.useMultisampledRTT=Qt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function ES(a,e){function t(i,n=zs){let s;const r=it.getTransfer(n);if(i===nn)return a.UNSIGNED_BYTE;if(i===Pd)return a.UNSIGNED_SHORT_4_4_4_4;if(i===Ld)return a.UNSIGNED_SHORT_5_5_5_1;if(i===ag)return a.UNSIGNED_INT_5_9_9_9_REV;if(i===rg)return a.UNSIGNED_INT_10F_11F_11F_REV;if(i===ng)return a.BYTE;if(i===sg)return a.SHORT;if(i===xo)return a.UNSIGNED_SHORT;if(i===Id)return a.INT;if(i===gn)return a.UNSIGNED_INT;if(i===Ri)return a.FLOAT;if(i===Ft)return a.HALF_FLOAT;if(i===og)return a.ALPHA;if(i===cg)return a.RGB;if(i===yi)return a.RGBA;if(i===vs)return a.DEPTH_COMPONENT;if(i===fa)return a.DEPTH_STENCIL;if(i===yl)return a.RED;if(i===Nd)return a.RED_INTEGER;if(i===_a)return a.RG;if(i===Od)return a.RG_INTEGER;if(i===Ud)return a.RGBA_INTEGER;if(i===Uc||i===Fc||i===kc||i===zc)if(r===gt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===Uc)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Fc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===kc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===zc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===Uc)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Fc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===kc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===zc)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===du||i===fu||i===pu||i===mu)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===du)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===fu)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===pu)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===mu)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===gu||i===vu||i===Mu||i===xu||i===yu||i===$c||i===_u)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===gu||i===vu)return r===gt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Mu)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===xu)return s.COMPRESSED_R11_EAC;if(i===yu)return s.COMPRESSED_SIGNED_R11_EAC;if(i===$c)return s.COMPRESSED_RG11_EAC;if(i===_u)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Su||i===wu||i===bu||i===Eu||i===Au||i===Tu||i===Ru||i===Du||i===Cu||i===Iu||i===Pu||i===Lu||i===Nu||i===Ou)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Su)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===wu)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===bu)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Eu)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Au)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Tu)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Ru)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Du)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Cu)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Iu)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Pu)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Lu)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Nu)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Ou)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Uu||i===Fu||i===ku)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===Uu)return r===gt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Fu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===ku)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===zu||i===Hu||i===Zc||i===Bu)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===zu)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Hu)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Zc)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Bu)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===yo?a.UNSIGNED_INT_24_8:a[i]!==void 0?a[i]:null}return{convert:t}}const AS=`
|
|
4718
|
+
}`,yS=[new D(1,0,0),new D(-1,0,0),new D(0,1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1)],_S=[new D(0,-1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1),new D(0,-1,0),new D(0,-1,0)],fp=new Ze,Hr=new D,yh=new D;function SS(a,e,t){let i=new Wd;const n=new xe,s=new xe,r=new it,o=new uM,c=new dM,l={},h=t.maxTextureSize,u={[qs]:Ot,[Ot]:qs,[tn]:tn},d=new at({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new xe},radius:{value:4}},vertexShader:MS,fragmentShader:xS}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const p=new ut;p.setAttribute("position",new et(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new De(p,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=io;let g=this.type;this.render=function(b,T,x){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;this.type===L2&&(Te("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=io);const A=a.getRenderTarget(),I=a.getActiveCubeFace(),C=a.getActiveMipmapLevel(),P=a.state;P.setBlending(Zn),P.buffers.depth.getReversed()===!0?P.buffers.color.setClear(0,0,0,0):P.buffers.color.setClear(1,1,1,1),P.buffers.depth.setTest(!0),P.setScissorTest(!1);const X=g!==this.type;X&&T.traverse(function(z){z.material&&(Array.isArray(z.material)?z.material.forEach(N=>N.needsUpdate=!0):z.material.needsUpdate=!0)});for(let z=0,N=b.length;z<N;z++){const V=b[z],k=V.shadow;if(k===void 0){Te("WebGLShadowMap:",V,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;n.copy(k.mapSize);const K=k.getFrameExtents();n.multiply(K),s.copy(k.mapSize),(n.x>h||n.y>h)&&(n.x>h&&(s.x=Math.floor(h/K.x),n.x=s.x*K.x,k.mapSize.x=s.x),n.y>h&&(s.y=Math.floor(h/K.y),n.y=s.y*K.y,k.mapSize.y=s.y));const ee=a.state.buffers.depth.getReversed();if(k.camera._reversedDepth=ee,k.map===null||X===!0){if(k.map!==null&&(k.map.depthTexture!==null&&(k.map.depthTexture.dispose(),k.map.depthTexture=null),k.map.dispose()),this.type===Zr){if(V.isPointLight){Te("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}k.map=new jt(n.x,n.y,{format:_a,type:kt,minFilter:st,magFilter:st,generateMipmaps:!1}),k.map.texture.name=V.name+".shadowMap",k.map.depthTexture=new Ys(n.x,n.y,Di),k.map.depthTexture.name=V.name+".shadowMapDepth",k.map.depthTexture.format=vs,k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=wt,k.map.depthTexture.magFilter=wt}else V.isPointLight?(k.map=new wo(n.x),k.map.depthTexture=new aM(n.x,gn)):(k.map=new jt(n.x,n.y),k.map.depthTexture=new Ys(n.x,n.y,gn)),k.map.depthTexture.name=V.name+".shadowMap",k.map.depthTexture.format=vs,this.type===io?(k.map.depthTexture.compareFunction=ee?kd:Fd,k.map.depthTexture.minFilter=st,k.map.depthTexture.magFilter=st):(k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=wt,k.map.depthTexture.magFilter=wt);k.camera.updateProjectionMatrix()}const J=k.map.isWebGLCubeRenderTarget?6:1;for(let ie=0;ie<J;ie++){if(k.map.isWebGLCubeRenderTarget)a.setRenderTarget(k.map,ie),a.clear();else{ie===0&&(a.setRenderTarget(k.map),a.clear());const oe=k.getViewport(ie);r.set(s.x*oe.x,s.y*oe.y,s.x*oe.z,s.y*oe.w),P.viewport(r)}if(V.isPointLight){const oe=k.camera,Ve=k.matrix,Qe=V.distance||oe.far;Qe!==oe.far&&(oe.far=Qe,oe.updateProjectionMatrix()),Hr.setFromMatrixPosition(V.matrixWorld),oe.position.copy(Hr),yh.copy(oe.position),yh.add(yS[ie]),oe.up.copy(_S[ie]),oe.lookAt(yh),oe.updateMatrixWorld(),Ve.makeTranslation(-Hr.x,-Hr.y,-Hr.z),fp.multiplyMatrices(oe.projectionMatrix,oe.matrixWorldInverse),k._frustum.setFromProjectionMatrix(fp,oe.coordinateSystem,oe.reversedDepth)}else k.updateMatrices(V);i=k.getFrustum(),M(T,x,k.camera,V,this.type)}k.isPointLightShadow!==!0&&this.type===Zr&&_(k,x),k.needsUpdate=!1}g=this.type,m.needsUpdate=!1,a.setRenderTarget(A,I,C)};function _(b,T){const x=e.update(v);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,f.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new jt(n.x,n.y,{format:_a,type:kt})),d.uniforms.shadow_pass.value=b.map.depthTexture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,a.setRenderTarget(b.mapPass),a.clear(),a.renderBufferDirect(T,null,x,d,v,null),f.uniforms.shadow_pass.value=b.mapPass.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,a.setRenderTarget(b.map),a.clear(),a.renderBufferDirect(T,null,x,f,v,null)}function w(b,T,x,A){let I=null;const C=x.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0)I=C;else if(I=x.isPointLight===!0?c:o,a.localClippingEnabled&&T.clipShadows===!0&&Array.isArray(T.clippingPlanes)&&T.clippingPlanes.length!==0||T.displacementMap&&T.displacementScale!==0||T.alphaMap&&T.alphaTest>0||T.map&&T.alphaTest>0||T.alphaToCoverage===!0){const P=I.uuid,X=T.uuid;let z=l[P];z===void 0&&(z={},l[P]=z);let N=z[X];N===void 0&&(N=I.clone(),z[X]=N,T.addEventListener("dispose",S)),I=N}if(I.visible=T.visible,I.wireframe=T.wireframe,A===Zr?I.side=T.shadowSide!==null?T.shadowSide:T.side:I.side=T.shadowSide!==null?T.shadowSide:u[T.side],I.alphaMap=T.alphaMap,I.alphaTest=T.alphaToCoverage===!0?.5:T.alphaTest,I.map=T.map,I.clipShadows=T.clipShadows,I.clippingPlanes=T.clippingPlanes,I.clipIntersection=T.clipIntersection,I.displacementMap=T.displacementMap,I.displacementScale=T.displacementScale,I.displacementBias=T.displacementBias,I.wireframeLinewidth=T.wireframeLinewidth,I.linewidth=T.linewidth,x.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const P=a.properties.get(I);P.light=x}return I}function M(b,T,x,A,I){if(b.visible===!1)return;if(b.layers.test(T.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&I===Zr)&&(!b.frustumCulled||i.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,b.matrixWorld);const X=e.update(b),z=b.material;if(Array.isArray(z)){const N=X.groups;for(let V=0,k=N.length;V<k;V++){const K=N[V],ee=z[K.materialIndex];if(ee&&ee.visible){const J=w(b,ee,A,I);b.onBeforeShadow(a,b,T,x,X,J,K),a.renderBufferDirect(x,null,X,J,b,K),b.onAfterShadow(a,b,T,x,X,J,K)}}}else if(z.visible){const N=w(b,z,A,I);b.onBeforeShadow(a,b,T,x,X,N,null),a.renderBufferDirect(x,null,X,N,b,null),b.onAfterShadow(a,b,T,x,X,N,null)}}const P=b.children;for(let X=0,z=P.length;X<z;X++)M(P[X],T,x,A,I)}function S(b){b.target.removeEventListener("dispose",S);for(const x in l){const A=l[x],I=b.target.uuid;I in A&&(A[I].dispose(),delete A[I])}}}function wS(a,e){function t(){let L=!1;const ce=new it;let j=null;const de=new it(0,0,0,0);return{setMask:function(ve){j!==ve&&!L&&(a.colorMask(ve,ve,ve,ve),j=ve)},setLocked:function(ve){L=ve},setClear:function(ve,te,Re,Se,Gt){Gt===!0&&(ve*=Se,te*=Se,Re*=Se),ce.set(ve,te,Re,Se),de.equals(ce)===!1&&(a.clearColor(ve,te,Re,Se),de.copy(ce))},reset:function(){L=!1,j=null,de.set(-1,0,0,0)}}}function i(){let L=!1,ce=!1,j=null,de=null,ve=null;return{setReversed:function(te){if(ce!==te){const Re=e.get("EXT_clip_control");te?Re.clipControlEXT(Re.LOWER_LEFT_EXT,Re.ZERO_TO_ONE_EXT):Re.clipControlEXT(Re.LOWER_LEFT_EXT,Re.NEGATIVE_ONE_TO_ONE_EXT),ce=te;const Se=ve;ve=null,this.setClear(Se)}},getReversed:function(){return ce},setTest:function(te){te?ne(a.DEPTH_TEST):H(a.DEPTH_TEST)},setMask:function(te){j!==te&&!L&&(a.depthMask(te),j=te)},setFunc:function(te){if(ce&&(te=fv[te]),de!==te){switch(te){case su:a.depthFunc(a.NEVER);break;case au:a.depthFunc(a.ALWAYS);break;case ru:a.depthFunc(a.LESS);break;case gr:a.depthFunc(a.LEQUAL);break;case ou:a.depthFunc(a.EQUAL);break;case cu:a.depthFunc(a.GEQUAL);break;case lu:a.depthFunc(a.GREATER);break;case hu:a.depthFunc(a.NOTEQUAL);break;default:a.depthFunc(a.LEQUAL)}de=te}},setLocked:function(te){L=te},setClear:function(te){ve!==te&&(ve=te,ce&&(te=1-te),a.clearDepth(te))},reset:function(){L=!1,j=null,de=null,ve=null,ce=!1}}}function n(){let L=!1,ce=null,j=null,de=null,ve=null,te=null,Re=null,Se=null,Gt=null;return{setTest:function(At){L||(At?ne(a.STENCIL_TEST):H(a.STENCIL_TEST))},setMask:function(At){ce!==At&&!L&&(a.stencilMask(At),ce=At)},setFunc:function(At,Pn,Ln){(j!==At||de!==Pn||ve!==Ln)&&(a.stencilFunc(At,Pn,Ln),j=At,de=Pn,ve=Ln)},setOp:function(At,Pn,Ln){(te!==At||Re!==Pn||Se!==Ln)&&(a.stencilOp(At,Pn,Ln),te=At,Re=Pn,Se=Ln)},setLocked:function(At){L=At},setClear:function(At){Gt!==At&&(a.clearStencil(At),Gt=At)},reset:function(){L=!1,ce=null,j=null,de=null,ve=null,te=null,Re=null,Se=null,Gt=null}}}const s=new t,r=new i,o=new n,c=new WeakMap,l=new WeakMap;let h={},u={},d={},f=new WeakMap,p=[],v=null,m=!1,g=null,_=null,w=null,M=null,S=null,b=null,T=null,x=new se(0,0,0),A=0,I=!1,C=null,P=null,X=null,z=null,N=null;const V=a.getParameter(a.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let k=!1,K=0;const ee=a.getParameter(a.VERSION);ee.indexOf("WebGL")!==-1?(K=parseFloat(/^WebGL (\d)/.exec(ee)[1]),k=K>=1):ee.indexOf("OpenGL ES")!==-1&&(K=parseFloat(/^OpenGL ES (\d)/.exec(ee)[1]),k=K>=2);let J=null,ie={};const oe=a.getParameter(a.SCISSOR_BOX),Ve=a.getParameter(a.VIEWPORT),Qe=new it().fromArray(oe),qe=new it().fromArray(Ve);function Y(L,ce,j,de){const ve=new Uint8Array(4),te=a.createTexture();a.bindTexture(L,te),a.texParameteri(L,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(L,a.TEXTURE_MAG_FILTER,a.NEAREST);for(let Re=0;Re<j;Re++)L===a.TEXTURE_3D||L===a.TEXTURE_2D_ARRAY?a.texImage3D(ce,0,a.RGBA,1,1,de,0,a.RGBA,a.UNSIGNED_BYTE,ve):a.texImage2D(ce+Re,0,a.RGBA,1,1,0,a.RGBA,a.UNSIGNED_BYTE,ve);return te}const re={};re[a.TEXTURE_2D]=Y(a.TEXTURE_2D,a.TEXTURE_2D,1),re[a.TEXTURE_CUBE_MAP]=Y(a.TEXTURE_CUBE_MAP,a.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[a.TEXTURE_2D_ARRAY]=Y(a.TEXTURE_2D_ARRAY,a.TEXTURE_2D_ARRAY,1,1),re[a.TEXTURE_3D]=Y(a.TEXTURE_3D,a.TEXTURE_3D,1,1),s.setClear(0,0,0,1),r.setClear(1),o.setClear(0),ne(a.DEPTH_TEST),r.setFunc(gr),ft(!1),pt(Y0),ne(a.CULL_FACE),ke(Zn);function ne(L){h[L]!==!0&&(a.enable(L),h[L]=!0)}function H(L){h[L]!==!1&&(a.disable(L),h[L]=!1)}function Ae(L,ce){return d[L]!==ce?(a.bindFramebuffer(L,ce),d[L]=ce,L===a.DRAW_FRAMEBUFFER&&(d[a.FRAMEBUFFER]=ce),L===a.FRAMEBUFFER&&(d[a.DRAW_FRAMEBUFFER]=ce),!0):!1}function Ne(L,ce){let j=p,de=!1;if(L){j=f.get(ce),j===void 0&&(j=[],f.set(ce,j));const ve=L.textures;if(j.length!==ve.length||j[0]!==a.COLOR_ATTACHMENT0){for(let te=0,Re=ve.length;te<Re;te++)j[te]=a.COLOR_ATTACHMENT0+te;j.length=ve.length,de=!0}}else j[0]!==a.BACK&&(j[0]=a.BACK,de=!0);de&&a.drawBuffers(j)}function Ce(L){return v!==L?(a.useProgram(L),v=L,!0):!1}const ye={[ra]:a.FUNC_ADD,[N2]:a.FUNC_SUBTRACT,[O2]:a.FUNC_REVERSE_SUBTRACT};ye[U2]=a.MIN,ye[F2]=a.MAX;const Fe={[k2]:a.ZERO,[go]:a.ONE,[z2]:a.SRC_COLOR,[nu]:a.SRC_ALPHA,[X2]:a.SRC_ALPHA_SATURATE,[V2]:a.DST_COLOR,[B2]:a.DST_ALPHA,[H2]:a.ONE_MINUS_SRC_COLOR,[vo]:a.ONE_MINUS_SRC_ALPHA,[W2]:a.ONE_MINUS_DST_COLOR,[G2]:a.ONE_MINUS_DST_ALPHA,[q2]:a.CONSTANT_COLOR,[Y2]:a.ONE_MINUS_CONSTANT_COLOR,[K2]:a.CONSTANT_ALPHA,[$2]:a.ONE_MINUS_CONSTANT_ALPHA};function ke(L,ce,j,de,ve,te,Re,Se,Gt,At){if(L===Zn){m===!0&&(H(a.BLEND),m=!1);return}if(m===!1&&(ne(a.BLEND),m=!0),L!==Ml){if(L!==g||At!==I){if((_!==ra||S!==ra)&&(a.blendEquation(a.FUNC_ADD),_=ra,S=ra),At)switch(L){case Ws:a.blendFuncSeparate(a.ONE,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA);break;case Ci:a.blendFunc(a.ONE,a.ONE);break;case K0:a.blendFuncSeparate(a.ZERO,a.ONE_MINUS_SRC_COLOR,a.ZERO,a.ONE);break;case $0:a.blendFuncSeparate(a.DST_COLOR,a.ONE_MINUS_SRC_ALPHA,a.ZERO,a.ONE);break;default:Be("WebGLState: Invalid blending: ",L);break}else switch(L){case Ws:a.blendFuncSeparate(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA);break;case Ci:a.blendFuncSeparate(a.SRC_ALPHA,a.ONE,a.ONE,a.ONE);break;case K0:Be("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case $0:Be("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Be("WebGLState: Invalid blending: ",L);break}w=null,M=null,b=null,T=null,x.set(0,0,0),A=0,g=L,I=At}return}ve=ve||ce,te=te||j,Re=Re||de,(ce!==_||ve!==S)&&(a.blendEquationSeparate(ye[ce],ye[ve]),_=ce,S=ve),(j!==w||de!==M||te!==b||Re!==T)&&(a.blendFuncSeparate(Fe[j],Fe[de],Fe[te],Fe[Re]),w=j,M=de,b=te,T=Re),(Se.equals(x)===!1||Gt!==A)&&(a.blendColor(Se.r,Se.g,Se.b,Gt),x.copy(Se),A=Gt),g=L,I=!1}function ze(L,ce){L.side===tn?H(a.CULL_FACE):ne(a.CULL_FACE);let j=L.side===Ot;ce&&(j=!j),ft(j),L.blending===Ws&&L.transparent===!1?ke(Zn):ke(L.blending,L.blendEquation,L.blendSrc,L.blendDst,L.blendEquationAlpha,L.blendSrcAlpha,L.blendDstAlpha,L.blendColor,L.blendAlpha,L.premultipliedAlpha),r.setFunc(L.depthFunc),r.setTest(L.depthTest),r.setMask(L.depthWrite),s.setMask(L.colorWrite);const de=L.stencilWrite;o.setTest(de),de&&(o.setMask(L.stencilWriteMask),o.setFunc(L.stencilFunc,L.stencilRef,L.stencilFuncMask),o.setOp(L.stencilFail,L.stencilZFail,L.stencilZPass)),Lt(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?ne(a.SAMPLE_ALPHA_TO_COVERAGE):H(a.SAMPLE_ALPHA_TO_COVERAGE)}function ft(L){C!==L&&(L?a.frontFace(a.CW):a.frontFace(a.CCW),C=L)}function pt(L){L!==I2?(ne(a.CULL_FACE),L!==P&&(L===Y0?a.cullFace(a.BACK):L===P2?a.cullFace(a.FRONT):a.cullFace(a.FRONT_AND_BACK))):H(a.CULL_FACE),P=L}function Ht(L){L!==X&&(k&&a.lineWidth(L),X=L)}function Lt(L,ce,j){L?(ne(a.POLYGON_OFFSET_FILL),(z!==ce||N!==j)&&(z=ce,N=j,r.getReversed()&&(ce=-ce),a.polygonOffset(ce,j))):H(a.POLYGON_OFFSET_FILL)}function Bt(L){L?ne(a.SCISSOR_TEST):H(a.SCISSOR_TEST)}function ei(L){L===void 0&&(L=a.TEXTURE0+V-1),J!==L&&(a.activeTexture(L),J=L)}function O(L,ce,j){j===void 0&&(J===null?j=a.TEXTURE0+V-1:j=J);let de=ie[j];de===void 0&&(de={type:void 0,texture:void 0},ie[j]=de),(de.type!==L||de.texture!==ce)&&(J!==j&&(a.activeTexture(j),J=j),a.bindTexture(L,ce||re[L]),de.type=L,de.texture=ce)}function zi(){const L=ie[J];L!==void 0&&L.type!==void 0&&(a.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function mt(){try{a.compressedTexImage2D(...arguments)}catch(L){Be("WebGLState:",L)}}function R(){try{a.compressedTexImage3D(...arguments)}catch(L){Be("WebGLState:",L)}}function y(){try{a.texSubImage2D(...arguments)}catch(L){Be("WebGLState:",L)}}function F(){try{a.texSubImage3D(...arguments)}catch(L){Be("WebGLState:",L)}}function W(){try{a.compressedTexSubImage2D(...arguments)}catch(L){Be("WebGLState:",L)}}function $(){try{a.compressedTexSubImage3D(...arguments)}catch(L){Be("WebGLState:",L)}}function ae(){try{a.texStorage2D(...arguments)}catch(L){Be("WebGLState:",L)}}function le(){try{a.texStorage3D(...arguments)}catch(L){Be("WebGLState:",L)}}function Z(){try{a.texImage2D(...arguments)}catch(L){Be("WebGLState:",L)}}function Q(){try{a.texImage3D(...arguments)}catch(L){Be("WebGLState:",L)}}function he(L){return u[L]!==void 0?u[L]:a.getParameter(L)}function Ie(L,ce){u[L]!==ce&&(a.pixelStorei(L,ce),u[L]=ce)}function fe(L){Qe.equals(L)===!1&&(a.scissor(L.x,L.y,L.z,L.w),Qe.copy(L))}function ue(L){qe.equals(L)===!1&&(a.viewport(L.x,L.y,L.z,L.w),qe.copy(L))}function Ue(L,ce){let j=l.get(ce);j===void 0&&(j=new WeakMap,l.set(ce,j));let de=j.get(L);de===void 0&&(de=a.getUniformBlockIndex(ce,L.name),j.set(L,de))}function He(L,ce){const de=l.get(ce).get(L);c.get(ce)!==de&&(a.uniformBlockBinding(ce,de,L.__bindingPointIndex),c.set(ce,de))}function Ke(){a.disable(a.BLEND),a.disable(a.CULL_FACE),a.disable(a.DEPTH_TEST),a.disable(a.POLYGON_OFFSET_FILL),a.disable(a.SCISSOR_TEST),a.disable(a.STENCIL_TEST),a.disable(a.SAMPLE_ALPHA_TO_COVERAGE),a.blendEquation(a.FUNC_ADD),a.blendFunc(a.ONE,a.ZERO),a.blendFuncSeparate(a.ONE,a.ZERO,a.ONE,a.ZERO),a.blendColor(0,0,0,0),a.colorMask(!0,!0,!0,!0),a.clearColor(0,0,0,0),a.depthMask(!0),a.depthFunc(a.LESS),r.setReversed(!1),a.clearDepth(1),a.stencilMask(4294967295),a.stencilFunc(a.ALWAYS,0,4294967295),a.stencilOp(a.KEEP,a.KEEP,a.KEEP),a.clearStencil(0),a.cullFace(a.BACK),a.frontFace(a.CCW),a.polygonOffset(0,0),a.activeTexture(a.TEXTURE0),a.bindFramebuffer(a.FRAMEBUFFER,null),a.bindFramebuffer(a.DRAW_FRAMEBUFFER,null),a.bindFramebuffer(a.READ_FRAMEBUFFER,null),a.useProgram(null),a.lineWidth(1),a.scissor(0,0,a.canvas.width,a.canvas.height),a.viewport(0,0,a.canvas.width,a.canvas.height),a.pixelStorei(a.PACK_ALIGNMENT,4),a.pixelStorei(a.UNPACK_ALIGNMENT,4),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,!1),a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),a.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,a.BROWSER_DEFAULT_WEBGL),a.pixelStorei(a.PACK_ROW_LENGTH,0),a.pixelStorei(a.PACK_SKIP_PIXELS,0),a.pixelStorei(a.PACK_SKIP_ROWS,0),a.pixelStorei(a.UNPACK_ROW_LENGTH,0),a.pixelStorei(a.UNPACK_IMAGE_HEIGHT,0),a.pixelStorei(a.UNPACK_SKIP_PIXELS,0),a.pixelStorei(a.UNPACK_SKIP_ROWS,0),a.pixelStorei(a.UNPACK_SKIP_IMAGES,0),h={},u={},J=null,ie={},d={},f=new WeakMap,p=[],v=null,m=!1,g=null,_=null,w=null,M=null,S=null,b=null,T=null,x=new se(0,0,0),A=0,I=!1,C=null,P=null,X=null,z=null,N=null,Qe.set(0,0,a.canvas.width,a.canvas.height),qe.set(0,0,a.canvas.width,a.canvas.height),s.reset(),r.reset(),o.reset()}return{buffers:{color:s,depth:r,stencil:o},enable:ne,disable:H,bindFramebuffer:Ae,drawBuffers:Ne,useProgram:Ce,setBlending:ke,setMaterial:ze,setFlipSided:ft,setCullFace:pt,setLineWidth:Ht,setPolygonOffset:Lt,setScissorTest:Bt,activeTexture:ei,bindTexture:O,unbindTexture:zi,compressedTexImage2D:mt,compressedTexImage3D:R,texImage2D:Z,texImage3D:Q,pixelStorei:Ie,getParameter:he,updateUBOMapping:Ue,uniformBlockBinding:He,texStorage2D:ae,texStorage3D:le,texSubImage2D:y,texSubImage3D:F,compressedTexSubImage2D:W,compressedTexSubImage3D:$,scissor:fe,viewport:ue,reset:Ke}}function bS(a,e,t,i,n,s,r){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new xe,h=new WeakMap,u=new Set;let d;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(R,y){return p?new OffscreenCanvas(R,y):So("canvas")}function m(R,y,F){let W=1;const $=mt(R);if(($.width>F||$.height>F)&&(W=F/Math.max($.width,$.height)),W<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const ae=Math.floor(W*$.width),le=Math.floor(W*$.height);d===void 0&&(d=v(ae,le));const Z=y?v(ae,le):d;return Z.width=ae,Z.height=le,Z.getContext("2d").drawImage(R,0,0,ae,le),Te("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+ae+"x"+le+")."),Z}else return"data"in R&&Te("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),R;return R}function g(R){return R.generateMipmaps}function _(R){a.generateMipmap(R)}function w(R){return R.isWebGLCubeRenderTarget?a.TEXTURE_CUBE_MAP:R.isWebGL3DRenderTarget?a.TEXTURE_3D:R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture?a.TEXTURE_2D_ARRAY:a.TEXTURE_2D}function M(R,y,F,W,$,ae=!1){if(R!==null){if(a[R]!==void 0)return a[R];Te("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let le;W&&(le=e.get("EXT_texture_norm16"),le||Te("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Z=y;if(y===a.RED&&(F===a.FLOAT&&(Z=a.R32F),F===a.HALF_FLOAT&&(Z=a.R16F),F===a.UNSIGNED_BYTE&&(Z=a.R8),F===a.UNSIGNED_SHORT&&le&&(Z=le.R16_EXT),F===a.SHORT&&le&&(Z=le.R16_SNORM_EXT)),y===a.RED_INTEGER&&(F===a.UNSIGNED_BYTE&&(Z=a.R8UI),F===a.UNSIGNED_SHORT&&(Z=a.R16UI),F===a.UNSIGNED_INT&&(Z=a.R32UI),F===a.BYTE&&(Z=a.R8I),F===a.SHORT&&(Z=a.R16I),F===a.INT&&(Z=a.R32I)),y===a.RG&&(F===a.FLOAT&&(Z=a.RG32F),F===a.HALF_FLOAT&&(Z=a.RG16F),F===a.UNSIGNED_BYTE&&(Z=a.RG8),F===a.UNSIGNED_SHORT&&le&&(Z=le.RG16_EXT),F===a.SHORT&&le&&(Z=le.RG16_SNORM_EXT)),y===a.RG_INTEGER&&(F===a.UNSIGNED_BYTE&&(Z=a.RG8UI),F===a.UNSIGNED_SHORT&&(Z=a.RG16UI),F===a.UNSIGNED_INT&&(Z=a.RG32UI),F===a.BYTE&&(Z=a.RG8I),F===a.SHORT&&(Z=a.RG16I),F===a.INT&&(Z=a.RG32I)),y===a.RGB_INTEGER&&(F===a.UNSIGNED_BYTE&&(Z=a.RGB8UI),F===a.UNSIGNED_SHORT&&(Z=a.RGB16UI),F===a.UNSIGNED_INT&&(Z=a.RGB32UI),F===a.BYTE&&(Z=a.RGB8I),F===a.SHORT&&(Z=a.RGB16I),F===a.INT&&(Z=a.RGB32I)),y===a.RGBA_INTEGER&&(F===a.UNSIGNED_BYTE&&(Z=a.RGBA8UI),F===a.UNSIGNED_SHORT&&(Z=a.RGBA16UI),F===a.UNSIGNED_INT&&(Z=a.RGBA32UI),F===a.BYTE&&(Z=a.RGBA8I),F===a.SHORT&&(Z=a.RGBA16I),F===a.INT&&(Z=a.RGBA32I)),y===a.RGB&&(F===a.UNSIGNED_SHORT&&le&&(Z=le.RGB16_EXT),F===a.SHORT&&le&&(Z=le.RGB16_SNORM_EXT),F===a.UNSIGNED_INT_5_9_9_9_REV&&(Z=a.RGB9_E5),F===a.UNSIGNED_INT_10F_11F_11F_REV&&(Z=a.R11F_G11F_B10F)),y===a.RGBA){const Q=ae?el:nt.getTransfer($);F===a.FLOAT&&(Z=a.RGBA32F),F===a.HALF_FLOAT&&(Z=a.RGBA16F),F===a.UNSIGNED_BYTE&&(Z=Q===gt?a.SRGB8_ALPHA8:a.RGBA8),F===a.UNSIGNED_SHORT&&le&&(Z=le.RGBA16_EXT),F===a.SHORT&&le&&(Z=le.RGBA16_SNORM_EXT),F===a.UNSIGNED_SHORT_4_4_4_4&&(Z=a.RGBA4),F===a.UNSIGNED_SHORT_5_5_5_1&&(Z=a.RGB5_A1)}return(Z===a.R16F||Z===a.R32F||Z===a.RG16F||Z===a.RG32F||Z===a.RGBA16F||Z===a.RGBA32F)&&e.get("EXT_color_buffer_float"),Z}function S(R,y){let F;return R?y===null||y===gn||y===yo?F=a.DEPTH24_STENCIL8:y===Di?F=a.DEPTH32F_STENCIL8:y===xo&&(F=a.DEPTH24_STENCIL8,Te("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):y===null||y===gn||y===yo?F=a.DEPTH_COMPONENT24:y===Di?F=a.DEPTH_COMPONENT32F:y===xo&&(F=a.DEPTH_COMPONENT16),F}function b(R,y){return g(R)===!0||R.isFramebufferTexture&&R.minFilter!==wt&&R.minFilter!==st?Math.log2(Math.max(y.width,y.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?y.mipmaps.length:1}function T(R){const y=R.target;y.removeEventListener("dispose",T),A(y),y.isVideoTexture&&h.delete(y),y.isHTMLTexture&&u.delete(y)}function x(R){const y=R.target;y.removeEventListener("dispose",x),C(y)}function A(R){const y=i.get(R);if(y.__webglInit===void 0)return;const F=R.source,W=f.get(F);if(W){const $=W[y.__cacheKey];$.usedTimes--,$.usedTimes===0&&I(R),Object.keys(W).length===0&&f.delete(F)}i.remove(R)}function I(R){const y=i.get(R);a.deleteTexture(y.__webglTexture);const F=R.source,W=f.get(F);delete W[y.__cacheKey],r.memory.textures--}function C(R){const y=i.get(R);if(R.depthTexture&&(R.depthTexture.dispose(),i.remove(R.depthTexture)),R.isWebGLCubeRenderTarget)for(let W=0;W<6;W++){if(Array.isArray(y.__webglFramebuffer[W]))for(let $=0;$<y.__webglFramebuffer[W].length;$++)a.deleteFramebuffer(y.__webglFramebuffer[W][$]);else a.deleteFramebuffer(y.__webglFramebuffer[W]);y.__webglDepthbuffer&&a.deleteRenderbuffer(y.__webglDepthbuffer[W])}else{if(Array.isArray(y.__webglFramebuffer))for(let W=0;W<y.__webglFramebuffer.length;W++)a.deleteFramebuffer(y.__webglFramebuffer[W]);else a.deleteFramebuffer(y.__webglFramebuffer);if(y.__webglDepthbuffer&&a.deleteRenderbuffer(y.__webglDepthbuffer),y.__webglMultisampledFramebuffer&&a.deleteFramebuffer(y.__webglMultisampledFramebuffer),y.__webglColorRenderbuffer)for(let W=0;W<y.__webglColorRenderbuffer.length;W++)y.__webglColorRenderbuffer[W]&&a.deleteRenderbuffer(y.__webglColorRenderbuffer[W]);y.__webglDepthRenderbuffer&&a.deleteRenderbuffer(y.__webglDepthRenderbuffer)}const F=R.textures;for(let W=0,$=F.length;W<$;W++){const ae=i.get(F[W]);ae.__webglTexture&&(a.deleteTexture(ae.__webglTexture),r.memory.textures--),i.remove(F[W])}i.remove(R)}let P=0;function X(){P=0}function z(){return P}function N(R){P=R}function V(){const R=P;return R>=n.maxTextures&&Te("WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+n.maxTextures),P+=1,R}function k(R){const y=[];return y.push(R.wrapS),y.push(R.wrapT),y.push(R.wrapR||0),y.push(R.magFilter),y.push(R.minFilter),y.push(R.anisotropy),y.push(R.internalFormat),y.push(R.format),y.push(R.type),y.push(R.generateMipmaps),y.push(R.premultiplyAlpha),y.push(R.flipY),y.push(R.unpackAlignment),y.push(R.colorSpace),y.join()}function K(R,y){const F=i.get(R);if(R.isVideoTexture&&O(R),R.isRenderTargetTexture===!1&&R.isExternalTexture!==!0&&R.version>0&&F.__version!==R.version){const W=R.image;if(W===null)Te("WebGLRenderer: Texture marked for update but no image data found.");else if(W.complete===!1)Te("WebGLRenderer: Texture marked for update but image is incomplete");else{H(F,R,y);return}}else R.isExternalTexture&&(F.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(a.TEXTURE_2D,F.__webglTexture,a.TEXTURE0+y)}function ee(R,y){const F=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&F.__version!==R.version){H(F,R,y);return}else R.isExternalTexture&&(F.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(a.TEXTURE_2D_ARRAY,F.__webglTexture,a.TEXTURE0+y)}function J(R,y){const F=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&F.__version!==R.version){H(F,R,y);return}t.bindTexture(a.TEXTURE_3D,F.__webglTexture,a.TEXTURE0+y)}function ie(R,y){const F=i.get(R);if(R.isCubeDepthTexture!==!0&&R.version>0&&F.__version!==R.version){Ae(F,R,y);return}t.bindTexture(a.TEXTURE_CUBE_MAP,F.__webglTexture,a.TEXTURE0+y)}const oe={[Mo]:a.REPEAT,[yi]:a.CLAMP_TO_EDGE,[uu]:a.MIRRORED_REPEAT},Ve={[wt]:a.NEAREST,[Q2]:a.NEAREST_MIPMAP_NEAREST,[ko]:a.NEAREST_MIPMAP_LINEAR,[st]:a.LINEAR,[kl]:a.LINEAR_MIPMAP_NEAREST,[da]:a.LINEAR_MIPMAP_LINEAR},Qe={[nv]:a.NEVER,[cv]:a.ALWAYS,[sv]:a.LESS,[Fd]:a.LEQUAL,[av]:a.EQUAL,[kd]:a.GEQUAL,[rv]:a.GREATER,[ov]:a.NOTEQUAL};function qe(R,y){if(y.type===Di&&e.has("OES_texture_float_linear")===!1&&(y.magFilter===st||y.magFilter===kl||y.magFilter===ko||y.magFilter===da||y.minFilter===st||y.minFilter===kl||y.minFilter===ko||y.minFilter===da)&&Te("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),a.texParameteri(R,a.TEXTURE_WRAP_S,oe[y.wrapS]),a.texParameteri(R,a.TEXTURE_WRAP_T,oe[y.wrapT]),(R===a.TEXTURE_3D||R===a.TEXTURE_2D_ARRAY)&&a.texParameteri(R,a.TEXTURE_WRAP_R,oe[y.wrapR]),a.texParameteri(R,a.TEXTURE_MAG_FILTER,Ve[y.magFilter]),a.texParameteri(R,a.TEXTURE_MIN_FILTER,Ve[y.minFilter]),y.compareFunction&&(a.texParameteri(R,a.TEXTURE_COMPARE_MODE,a.COMPARE_REF_TO_TEXTURE),a.texParameteri(R,a.TEXTURE_COMPARE_FUNC,Qe[y.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===wt||y.minFilter!==ko&&y.minFilter!==da||y.type===Di&&e.has("OES_texture_float_linear")===!1)return;if(y.anisotropy>1||i.get(y).__currentAnisotropy){const F=e.get("EXT_texture_filter_anisotropic");a.texParameterf(R,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,n.getMaxAnisotropy())),i.get(y).__currentAnisotropy=y.anisotropy}}}function Y(R,y){let F=!1;R.__webglInit===void 0&&(R.__webglInit=!0,y.addEventListener("dispose",T));const W=y.source;let $=f.get(W);$===void 0&&($={},f.set(W,$));const ae=k(y);if(ae!==R.__cacheKey){$[ae]===void 0&&($[ae]={texture:a.createTexture(),usedTimes:0},r.memory.textures++,F=!0),$[ae].usedTimes++;const le=$[R.__cacheKey];le!==void 0&&($[R.__cacheKey].usedTimes--,le.usedTimes===0&&I(y)),R.__cacheKey=ae,R.__webglTexture=$[ae].texture}return F}function re(R,y,F){return Math.floor(Math.floor(R/F)/y)}function ne(R,y,F,W){const ae=R.updateRanges;if(ae.length===0)t.texSubImage2D(a.TEXTURE_2D,0,0,0,y.width,y.height,F,W,y.data);else{ae.sort((Ie,fe)=>Ie.start-fe.start);let le=0;for(let Ie=1;Ie<ae.length;Ie++){const fe=ae[le],ue=ae[Ie],Ue=fe.start+fe.count,He=re(ue.start,y.width,4),Ke=re(fe.start,y.width,4);ue.start<=Ue+1&&He===Ke&&re(ue.start+ue.count-1,y.width,4)===He?fe.count=Math.max(fe.count,ue.start+ue.count-fe.start):(++le,ae[le]=ue)}ae.length=le+1;const Z=t.getParameter(a.UNPACK_ROW_LENGTH),Q=t.getParameter(a.UNPACK_SKIP_PIXELS),he=t.getParameter(a.UNPACK_SKIP_ROWS);t.pixelStorei(a.UNPACK_ROW_LENGTH,y.width);for(let Ie=0,fe=ae.length;Ie<fe;Ie++){const ue=ae[Ie],Ue=Math.floor(ue.start/4),He=Math.ceil(ue.count/4),Ke=Ue%y.width,L=Math.floor(Ue/y.width),ce=He,j=1;t.pixelStorei(a.UNPACK_SKIP_PIXELS,Ke),t.pixelStorei(a.UNPACK_SKIP_ROWS,L),t.texSubImage2D(a.TEXTURE_2D,0,Ke,L,ce,j,F,W,y.data)}R.clearUpdateRanges(),t.pixelStorei(a.UNPACK_ROW_LENGTH,Z),t.pixelStorei(a.UNPACK_SKIP_PIXELS,Q),t.pixelStorei(a.UNPACK_SKIP_ROWS,he)}}function H(R,y,F){let W=a.TEXTURE_2D;(y.isDataArrayTexture||y.isCompressedArrayTexture)&&(W=a.TEXTURE_2D_ARRAY),y.isData3DTexture&&(W=a.TEXTURE_3D);const $=Y(R,y),ae=y.source;t.bindTexture(W,R.__webglTexture,a.TEXTURE0+F);const le=i.get(ae);if(ae.version!==le.__version||$===!0){if(t.activeTexture(a.TEXTURE0+F),(typeof ImageBitmap<"u"&&y.image instanceof ImageBitmap)===!1){const j=nt.getPrimaries(nt.workingColorSpace),de=y.colorSpace===zs?null:nt.getPrimaries(y.colorSpace),ve=y.colorSpace===zs||j===de?a.NONE:a.BROWSER_DEFAULT_WEBGL;t.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,y.flipY),t.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),t.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,ve)}t.pixelStorei(a.UNPACK_ALIGNMENT,y.unpackAlignment);let Q=m(y.image,!1,n.maxTextureSize);Q=zi(y,Q);const he=s.convert(y.format,y.colorSpace),Ie=s.convert(y.type);let fe=M(y.internalFormat,he,Ie,y.normalized,y.colorSpace,y.isVideoTexture);qe(W,y);let ue;const Ue=y.mipmaps,He=y.isVideoTexture!==!0,Ke=le.__version===void 0||$===!0,L=ae.dataReady,ce=b(y,Q);if(y.isDepthTexture)fe=S(y.format===fa,y.type),Ke&&(He?t.texStorage2D(a.TEXTURE_2D,1,fe,Q.width,Q.height):t.texImage2D(a.TEXTURE_2D,0,fe,Q.width,Q.height,0,he,Ie,null));else if(y.isDataTexture)if(Ue.length>0){He&&Ke&&t.texStorage2D(a.TEXTURE_2D,ce,fe,Ue[0].width,Ue[0].height);for(let j=0,de=Ue.length;j<de;j++)ue=Ue[j],He?L&&t.texSubImage2D(a.TEXTURE_2D,j,0,0,ue.width,ue.height,he,Ie,ue.data):t.texImage2D(a.TEXTURE_2D,j,fe,ue.width,ue.height,0,he,Ie,ue.data);y.generateMipmaps=!1}else He?(Ke&&t.texStorage2D(a.TEXTURE_2D,ce,fe,Q.width,Q.height),L&&ne(y,Q,he,Ie)):t.texImage2D(a.TEXTURE_2D,0,fe,Q.width,Q.height,0,he,Ie,Q.data);else if(y.isCompressedTexture)if(y.isCompressedArrayTexture){He&&Ke&&t.texStorage3D(a.TEXTURE_2D_ARRAY,ce,fe,Ue[0].width,Ue[0].height,Q.depth);for(let j=0,de=Ue.length;j<de;j++)if(ue=Ue[j],y.format!==_i)if(he!==null)if(He){if(L)if(y.layerUpdates.size>0){const ve=Xf(ue.width,ue.height,y.format,y.type);for(const te of y.layerUpdates){const Re=ue.data.subarray(te*ve/ue.data.BYTES_PER_ELEMENT,(te+1)*ve/ue.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(a.TEXTURE_2D_ARRAY,j,0,0,te,ue.width,ue.height,1,he,Re)}y.clearLayerUpdates()}else t.compressedTexSubImage3D(a.TEXTURE_2D_ARRAY,j,0,0,0,ue.width,ue.height,Q.depth,he,ue.data)}else t.compressedTexImage3D(a.TEXTURE_2D_ARRAY,j,fe,ue.width,ue.height,Q.depth,0,ue.data,0,0);else Te("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else He?L&&t.texSubImage3D(a.TEXTURE_2D_ARRAY,j,0,0,0,ue.width,ue.height,Q.depth,he,Ie,ue.data):t.texImage3D(a.TEXTURE_2D_ARRAY,j,fe,ue.width,ue.height,Q.depth,0,he,Ie,ue.data)}else{He&&Ke&&t.texStorage2D(a.TEXTURE_2D,ce,fe,Ue[0].width,Ue[0].height);for(let j=0,de=Ue.length;j<de;j++)ue=Ue[j],y.format!==_i?he!==null?He?L&&t.compressedTexSubImage2D(a.TEXTURE_2D,j,0,0,ue.width,ue.height,he,ue.data):t.compressedTexImage2D(a.TEXTURE_2D,j,fe,ue.width,ue.height,0,ue.data):Te("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):He?L&&t.texSubImage2D(a.TEXTURE_2D,j,0,0,ue.width,ue.height,he,Ie,ue.data):t.texImage2D(a.TEXTURE_2D,j,fe,ue.width,ue.height,0,he,Ie,ue.data)}else if(y.isDataArrayTexture)if(He){if(Ke&&t.texStorage3D(a.TEXTURE_2D_ARRAY,ce,fe,Q.width,Q.height,Q.depth),L)if(y.layerUpdates.size>0){const j=Xf(Q.width,Q.height,y.format,y.type);for(const de of y.layerUpdates){const ve=Q.data.subarray(de*j/Q.data.BYTES_PER_ELEMENT,(de+1)*j/Q.data.BYTES_PER_ELEMENT);t.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,de,Q.width,Q.height,1,he,Ie,ve)}y.clearLayerUpdates()}else t.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,he,Ie,Q.data)}else t.texImage3D(a.TEXTURE_2D_ARRAY,0,fe,Q.width,Q.height,Q.depth,0,he,Ie,Q.data);else if(y.isData3DTexture)He?(Ke&&t.texStorage3D(a.TEXTURE_3D,ce,fe,Q.width,Q.height,Q.depth),L&&t.texSubImage3D(a.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,he,Ie,Q.data)):t.texImage3D(a.TEXTURE_3D,0,fe,Q.width,Q.height,Q.depth,0,he,Ie,Q.data);else if(y.isFramebufferTexture){if(Ke)if(He)t.texStorage2D(a.TEXTURE_2D,ce,fe,Q.width,Q.height);else{let j=Q.width,de=Q.height;for(let ve=0;ve<ce;ve++)t.texImage2D(a.TEXTURE_2D,ve,fe,j,de,0,he,Ie,null),j>>=1,de>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in a){const j=a.canvas;if(j.hasAttribute("layoutsubtree")||j.setAttribute("layoutsubtree","true"),Q.parentNode!==j){j.appendChild(Q),u.add(y),j.onpaint=de=>{const ve=de.changedElements;for(const te of u)ve.includes(te.image)&&(te.needsUpdate=!0)},j.requestPaint();return}if(a.texElementImage2D.length===3)a.texElementImage2D(a.TEXTURE_2D,a.RGBA8,Q);else{const ve=a.RGBA,te=a.RGBA,Re=a.UNSIGNED_BYTE;a.texElementImage2D(a.TEXTURE_2D,0,ve,te,Re,Q)}a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE)}}else if(Ue.length>0){if(He&&Ke){const j=mt(Ue[0]);t.texStorage2D(a.TEXTURE_2D,ce,fe,j.width,j.height)}for(let j=0,de=Ue.length;j<de;j++)ue=Ue[j],He?L&&t.texSubImage2D(a.TEXTURE_2D,j,0,0,he,Ie,ue):t.texImage2D(a.TEXTURE_2D,j,fe,he,Ie,ue);y.generateMipmaps=!1}else if(He){if(Ke){const j=mt(Q);t.texStorage2D(a.TEXTURE_2D,ce,fe,j.width,j.height)}L&&t.texSubImage2D(a.TEXTURE_2D,0,0,0,he,Ie,Q)}else t.texImage2D(a.TEXTURE_2D,0,fe,he,Ie,Q);g(y)&&_(W),le.__version=ae.version,y.onUpdate&&y.onUpdate(y)}R.__version=y.version}function Ae(R,y,F){if(y.image.length!==6)return;const W=Y(R,y),$=y.source;t.bindTexture(a.TEXTURE_CUBE_MAP,R.__webglTexture,a.TEXTURE0+F);const ae=i.get($);if($.version!==ae.__version||W===!0){t.activeTexture(a.TEXTURE0+F);const le=nt.getPrimaries(nt.workingColorSpace),Z=y.colorSpace===zs?null:nt.getPrimaries(y.colorSpace),Q=y.colorSpace===zs||le===Z?a.NONE:a.BROWSER_DEFAULT_WEBGL;t.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,y.flipY),t.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),t.pixelStorei(a.UNPACK_ALIGNMENT,y.unpackAlignment),t.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);const he=y.isCompressedTexture||y.image[0].isCompressedTexture,Ie=y.image[0]&&y.image[0].isDataTexture,fe=[];for(let te=0;te<6;te++)!he&&!Ie?fe[te]=m(y.image[te],!0,n.maxCubemapSize):fe[te]=Ie?y.image[te].image:y.image[te],fe[te]=zi(y,fe[te]);const ue=fe[0],Ue=s.convert(y.format,y.colorSpace),He=s.convert(y.type),Ke=M(y.internalFormat,Ue,He,y.normalized,y.colorSpace),L=y.isVideoTexture!==!0,ce=ae.__version===void 0||W===!0,j=$.dataReady;let de=b(y,ue);qe(a.TEXTURE_CUBE_MAP,y);let ve;if(he){L&&ce&&t.texStorage2D(a.TEXTURE_CUBE_MAP,de,Ke,ue.width,ue.height);for(let te=0;te<6;te++){ve=fe[te].mipmaps;for(let Re=0;Re<ve.length;Re++){const Se=ve[Re];y.format!==_i?Ue!==null?L?j&&t.compressedTexSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,Re,0,0,Se.width,Se.height,Ue,Se.data):t.compressedTexImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,Re,Ke,Se.width,Se.height,0,Se.data):Te("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?j&&t.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,Re,0,0,Se.width,Se.height,Ue,He,Se.data):t.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,Re,Ke,Se.width,Se.height,0,Ue,He,Se.data)}}}else{if(ve=y.mipmaps,L&&ce){ve.length>0&&de++;const te=mt(fe[0]);t.texStorage2D(a.TEXTURE_CUBE_MAP,de,Ke,te.width,te.height)}for(let te=0;te<6;te++)if(Ie){L?j&&t.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,fe[te].width,fe[te].height,Ue,He,fe[te].data):t.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,Ke,fe[te].width,fe[te].height,0,Ue,He,fe[te].data);for(let Re=0;Re<ve.length;Re++){const Gt=ve[Re].image[te].image;L?j&&t.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,Re+1,0,0,Gt.width,Gt.height,Ue,He,Gt.data):t.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,Re+1,Ke,Gt.width,Gt.height,0,Ue,He,Gt.data)}}else{L?j&&t.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,Ue,He,fe[te]):t.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,Ke,Ue,He,fe[te]);for(let Re=0;Re<ve.length;Re++){const Se=ve[Re];L?j&&t.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,Re+1,0,0,Ue,He,Se.image[te]):t.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+te,Re+1,Ke,Ue,He,Se.image[te])}}}g(y)&&_(a.TEXTURE_CUBE_MAP),ae.__version=$.version,y.onUpdate&&y.onUpdate(y)}R.__version=y.version}function Ne(R,y,F,W,$,ae){const le=s.convert(F.format,F.colorSpace),Z=s.convert(F.type),Q=M(F.internalFormat,le,Z,F.normalized,F.colorSpace),he=i.get(y),Ie=i.get(F);if(Ie.__renderTarget=y,!he.__hasExternalTextures){const fe=Math.max(1,y.width>>ae),ue=Math.max(1,y.height>>ae);$===a.TEXTURE_3D||$===a.TEXTURE_2D_ARRAY?t.texImage3D($,ae,Q,fe,ue,y.depth,0,le,Z,null):t.texImage2D($,ae,Q,fe,ue,0,le,Z,null)}t.bindFramebuffer(a.FRAMEBUFFER,R),ei(y)?o.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,W,$,Ie.__webglTexture,0,Bt(y)):($===a.TEXTURE_2D||$>=a.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=a.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&a.framebufferTexture2D(a.FRAMEBUFFER,W,$,Ie.__webglTexture,ae),t.bindFramebuffer(a.FRAMEBUFFER,null)}function Ce(R,y,F){if(a.bindRenderbuffer(a.RENDERBUFFER,R),y.depthBuffer){const W=y.depthTexture,$=W&&W.isDepthTexture?W.type:null,ae=S(y.stencilBuffer,$),le=y.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;ei(y)?o.renderbufferStorageMultisampleEXT(a.RENDERBUFFER,Bt(y),ae,y.width,y.height):F?a.renderbufferStorageMultisample(a.RENDERBUFFER,Bt(y),ae,y.width,y.height):a.renderbufferStorage(a.RENDERBUFFER,ae,y.width,y.height),a.framebufferRenderbuffer(a.FRAMEBUFFER,le,a.RENDERBUFFER,R)}else{const W=y.textures;for(let $=0;$<W.length;$++){const ae=W[$],le=s.convert(ae.format,ae.colorSpace),Z=s.convert(ae.type),Q=M(ae.internalFormat,le,Z,ae.normalized,ae.colorSpace);ei(y)?o.renderbufferStorageMultisampleEXT(a.RENDERBUFFER,Bt(y),Q,y.width,y.height):F?a.renderbufferStorageMultisample(a.RENDERBUFFER,Bt(y),Q,y.width,y.height):a.renderbufferStorage(a.RENDERBUFFER,Q,y.width,y.height)}}a.bindRenderbuffer(a.RENDERBUFFER,null)}function ye(R,y,F){const W=y.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(a.FRAMEBUFFER,R),!(y.depthTexture&&y.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const $=i.get(y.depthTexture);if($.__renderTarget=y,(!$.__webglTexture||y.depthTexture.image.width!==y.width||y.depthTexture.image.height!==y.height)&&(y.depthTexture.image.width=y.width,y.depthTexture.image.height=y.height,y.depthTexture.needsUpdate=!0),W){if($.__webglInit===void 0&&($.__webglInit=!0,y.depthTexture.addEventListener("dispose",T)),$.__webglTexture===void 0){$.__webglTexture=a.createTexture(),t.bindTexture(a.TEXTURE_CUBE_MAP,$.__webglTexture),qe(a.TEXTURE_CUBE_MAP,y.depthTexture);const he=s.convert(y.depthTexture.format),Ie=s.convert(y.depthTexture.type);let fe;y.depthTexture.format===vs?fe=a.DEPTH_COMPONENT24:y.depthTexture.format===fa&&(fe=a.DEPTH24_STENCIL8);for(let ue=0;ue<6;ue++)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+ue,0,fe,y.width,y.height,0,he,Ie,null)}}else K(y.depthTexture,0);const ae=$.__webglTexture,le=Bt(y),Z=W?a.TEXTURE_CUBE_MAP_POSITIVE_X+F:a.TEXTURE_2D,Q=y.depthTexture.format===fa?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;if(y.depthTexture.format===vs)ei(y)?o.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,Q,Z,ae,0,le):a.framebufferTexture2D(a.FRAMEBUFFER,Q,Z,ae,0);else if(y.depthTexture.format===fa)ei(y)?o.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,Q,Z,ae,0,le):a.framebufferTexture2D(a.FRAMEBUFFER,Q,Z,ae,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Fe(R){const y=i.get(R),F=R.isWebGLCubeRenderTarget===!0;if(y.__boundDepthTexture!==R.depthTexture){const W=R.depthTexture;if(y.__depthDisposeCallback&&y.__depthDisposeCallback(),W){const $=()=>{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,W.removeEventListener("dispose",$)};W.addEventListener("dispose",$),y.__depthDisposeCallback=$}y.__boundDepthTexture=W}if(R.depthTexture&&!y.__autoAllocateDepthBuffer)if(F)for(let W=0;W<6;W++)ye(y.__webglFramebuffer[W],R,W);else{const W=R.texture.mipmaps;W&&W.length>0?ye(y.__webglFramebuffer[0],R,0):ye(y.__webglFramebuffer,R,0)}else if(F){y.__webglDepthbuffer=[];for(let W=0;W<6;W++)if(t.bindFramebuffer(a.FRAMEBUFFER,y.__webglFramebuffer[W]),y.__webglDepthbuffer[W]===void 0)y.__webglDepthbuffer[W]=a.createRenderbuffer(),Ce(y.__webglDepthbuffer[W],R,!1);else{const $=R.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,ae=y.__webglDepthbuffer[W];a.bindRenderbuffer(a.RENDERBUFFER,ae),a.framebufferRenderbuffer(a.FRAMEBUFFER,$,a.RENDERBUFFER,ae)}}else{const W=R.texture.mipmaps;if(W&&W.length>0?t.bindFramebuffer(a.FRAMEBUFFER,y.__webglFramebuffer[0]):t.bindFramebuffer(a.FRAMEBUFFER,y.__webglFramebuffer),y.__webglDepthbuffer===void 0)y.__webglDepthbuffer=a.createRenderbuffer(),Ce(y.__webglDepthbuffer,R,!1);else{const $=R.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,ae=y.__webglDepthbuffer;a.bindRenderbuffer(a.RENDERBUFFER,ae),a.framebufferRenderbuffer(a.FRAMEBUFFER,$,a.RENDERBUFFER,ae)}}t.bindFramebuffer(a.FRAMEBUFFER,null)}function ke(R,y,F){const W=i.get(R);y!==void 0&&Ne(W.__webglFramebuffer,R,R.texture,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,0),F!==void 0&&Fe(R)}function ze(R){const y=R.texture,F=i.get(R),W=i.get(y);R.addEventListener("dispose",x);const $=R.textures,ae=R.isWebGLCubeRenderTarget===!0,le=$.length>1;if(le||(W.__webglTexture===void 0&&(W.__webglTexture=a.createTexture()),W.__version=y.version,r.memory.textures++),ae){F.__webglFramebuffer=[];for(let Z=0;Z<6;Z++)if(y.mipmaps&&y.mipmaps.length>0){F.__webglFramebuffer[Z]=[];for(let Q=0;Q<y.mipmaps.length;Q++)F.__webglFramebuffer[Z][Q]=a.createFramebuffer()}else F.__webglFramebuffer[Z]=a.createFramebuffer()}else{if(y.mipmaps&&y.mipmaps.length>0){F.__webglFramebuffer=[];for(let Z=0;Z<y.mipmaps.length;Z++)F.__webglFramebuffer[Z]=a.createFramebuffer()}else F.__webglFramebuffer=a.createFramebuffer();if(le)for(let Z=0,Q=$.length;Z<Q;Z++){const he=i.get($[Z]);he.__webglTexture===void 0&&(he.__webglTexture=a.createTexture(),r.memory.textures++)}if(R.samples>0&&ei(R)===!1){F.__webglMultisampledFramebuffer=a.createFramebuffer(),F.__webglColorRenderbuffer=[],t.bindFramebuffer(a.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let Z=0;Z<$.length;Z++){const Q=$[Z];F.__webglColorRenderbuffer[Z]=a.createRenderbuffer(),a.bindRenderbuffer(a.RENDERBUFFER,F.__webglColorRenderbuffer[Z]);const he=s.convert(Q.format,Q.colorSpace),Ie=s.convert(Q.type),fe=M(Q.internalFormat,he,Ie,Q.normalized,Q.colorSpace,R.isXRRenderTarget===!0),ue=Bt(R);a.renderbufferStorageMultisample(a.RENDERBUFFER,ue,fe,R.width,R.height),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+Z,a.RENDERBUFFER,F.__webglColorRenderbuffer[Z])}a.bindRenderbuffer(a.RENDERBUFFER,null),R.depthBuffer&&(F.__webglDepthRenderbuffer=a.createRenderbuffer(),Ce(F.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(a.FRAMEBUFFER,null)}}if(ae){t.bindTexture(a.TEXTURE_CUBE_MAP,W.__webglTexture),qe(a.TEXTURE_CUBE_MAP,y);for(let Z=0;Z<6;Z++)if(y.mipmaps&&y.mipmaps.length>0)for(let Q=0;Q<y.mipmaps.length;Q++)Ne(F.__webglFramebuffer[Z][Q],R,y,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Q);else Ne(F.__webglFramebuffer[Z],R,y,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0);g(y)&&_(a.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(le){for(let Z=0,Q=$.length;Z<Q;Z++){const he=$[Z],Ie=i.get(he);let fe=a.TEXTURE_2D;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(fe=R.isWebGL3DRenderTarget?a.TEXTURE_3D:a.TEXTURE_2D_ARRAY),t.bindTexture(fe,Ie.__webglTexture),qe(fe,he),Ne(F.__webglFramebuffer,R,he,a.COLOR_ATTACHMENT0+Z,fe,0),g(he)&&_(fe)}t.unbindTexture()}else{let Z=a.TEXTURE_2D;if((R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(Z=R.isWebGL3DRenderTarget?a.TEXTURE_3D:a.TEXTURE_2D_ARRAY),t.bindTexture(Z,W.__webglTexture),qe(Z,y),y.mipmaps&&y.mipmaps.length>0)for(let Q=0;Q<y.mipmaps.length;Q++)Ne(F.__webglFramebuffer[Q],R,y,a.COLOR_ATTACHMENT0,Z,Q);else Ne(F.__webglFramebuffer,R,y,a.COLOR_ATTACHMENT0,Z,0);g(y)&&_(Z),t.unbindTexture()}R.depthBuffer&&Fe(R)}function ft(R){const y=R.textures;for(let F=0,W=y.length;F<W;F++){const $=y[F];if(g($)){const ae=w(R),le=i.get($).__webglTexture;t.bindTexture(ae,le),_(ae),t.unbindTexture()}}}const pt=[],Ht=[];function Lt(R){if(R.samples>0){if(ei(R)===!1){const y=R.textures,F=R.width,W=R.height;let $=a.COLOR_BUFFER_BIT;const ae=R.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,le=i.get(R),Z=y.length>1;if(Z)for(let he=0;he<y.length;he++)t.bindFramebuffer(a.FRAMEBUFFER,le.__webglMultisampledFramebuffer),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+he,a.RENDERBUFFER,null),t.bindFramebuffer(a.FRAMEBUFFER,le.__webglFramebuffer),a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0+he,a.TEXTURE_2D,null,0);t.bindFramebuffer(a.READ_FRAMEBUFFER,le.__webglMultisampledFramebuffer);const Q=R.texture.mipmaps;Q&&Q.length>0?t.bindFramebuffer(a.DRAW_FRAMEBUFFER,le.__webglFramebuffer[0]):t.bindFramebuffer(a.DRAW_FRAMEBUFFER,le.__webglFramebuffer);for(let he=0;he<y.length;he++){if(R.resolveDepthBuffer&&(R.depthBuffer&&($|=a.DEPTH_BUFFER_BIT),R.stencilBuffer&&R.resolveStencilBuffer&&($|=a.STENCIL_BUFFER_BIT)),Z){a.framebufferRenderbuffer(a.READ_FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.RENDERBUFFER,le.__webglColorRenderbuffer[he]);const Ie=i.get(y[he]).__webglTexture;a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,Ie,0)}a.blitFramebuffer(0,0,F,W,0,0,F,W,$,a.NEAREST),c===!0&&(pt.length=0,Ht.length=0,pt.push(a.COLOR_ATTACHMENT0+he),R.depthBuffer&&R.resolveDepthBuffer===!1&&(pt.push(ae),Ht.push(ae),a.invalidateFramebuffer(a.DRAW_FRAMEBUFFER,Ht)),a.invalidateFramebuffer(a.READ_FRAMEBUFFER,pt))}if(t.bindFramebuffer(a.READ_FRAMEBUFFER,null),t.bindFramebuffer(a.DRAW_FRAMEBUFFER,null),Z)for(let he=0;he<y.length;he++){t.bindFramebuffer(a.FRAMEBUFFER,le.__webglMultisampledFramebuffer),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+he,a.RENDERBUFFER,le.__webglColorRenderbuffer[he]);const Ie=i.get(y[he]).__webglTexture;t.bindFramebuffer(a.FRAMEBUFFER,le.__webglFramebuffer),a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0+he,a.TEXTURE_2D,Ie,0)}t.bindFramebuffer(a.DRAW_FRAMEBUFFER,le.__webglMultisampledFramebuffer)}else if(R.depthBuffer&&R.resolveDepthBuffer===!1&&c){const y=R.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;a.invalidateFramebuffer(a.DRAW_FRAMEBUFFER,[y])}}}function Bt(R){return Math.min(n.maxSamples,R.samples)}function ei(R){const y=i.get(R);return R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function O(R){const y=r.render.frame;h.get(R)!==y&&(h.set(R,y),R.update())}function zi(R,y){const F=R.colorSpace,W=R.format,$=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||F!==Qc&&F!==zs&&(nt.getTransfer(F)===gt?(W!==_i||$!==nn)&&Te("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Be("WebGLTextures: Unsupported texture color space:",F)),y}function mt(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(l.width=R.naturalWidth||R.width,l.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(l.width=R.displayWidth,l.height=R.displayHeight):(l.width=R.width,l.height=R.height),l}this.allocateTextureUnit=V,this.resetTextureUnits=X,this.getTextureUnits=z,this.setTextureUnits=N,this.setTexture2D=K,this.setTexture2DArray=ee,this.setTexture3D=J,this.setTextureCube=ie,this.rebindTextures=ke,this.setupRenderTarget=ze,this.updateRenderTargetMipmap=ft,this.updateMultisampleRenderTarget=Lt,this.setupDepthRenderbuffer=Fe,this.setupFrameBufferTexture=Ne,this.useMultisampledRTT=ei,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function ES(a,e){function t(i,n=zs){let s;const r=nt.getTransfer(n);if(i===nn)return a.UNSIGNED_BYTE;if(i===Pd)return a.UNSIGNED_SHORT_4_4_4_4;if(i===Ld)return a.UNSIGNED_SHORT_5_5_5_1;if(i===ag)return a.UNSIGNED_INT_5_9_9_9_REV;if(i===rg)return a.UNSIGNED_INT_10F_11F_11F_REV;if(i===ng)return a.BYTE;if(i===sg)return a.SHORT;if(i===xo)return a.UNSIGNED_SHORT;if(i===Id)return a.INT;if(i===gn)return a.UNSIGNED_INT;if(i===Di)return a.FLOAT;if(i===kt)return a.HALF_FLOAT;if(i===og)return a.ALPHA;if(i===cg)return a.RGB;if(i===_i)return a.RGBA;if(i===vs)return a.DEPTH_COMPONENT;if(i===fa)return a.DEPTH_STENCIL;if(i===yl)return a.RED;if(i===Nd)return a.RED_INTEGER;if(i===_a)return a.RG;if(i===Od)return a.RG_INTEGER;if(i===Ud)return a.RGBA_INTEGER;if(i===Uc||i===Fc||i===kc||i===zc)if(r===gt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===Uc)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Fc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===kc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===zc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===Uc)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Fc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===kc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===zc)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===du||i===fu||i===pu||i===mu)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===du)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===fu)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===pu)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===mu)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===gu||i===vu||i===Mu||i===xu||i===yu||i===$c||i===_u)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===gu||i===vu)return r===gt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Mu)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===xu)return s.COMPRESSED_R11_EAC;if(i===yu)return s.COMPRESSED_SIGNED_R11_EAC;if(i===$c)return s.COMPRESSED_RG11_EAC;if(i===_u)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Su||i===wu||i===bu||i===Eu||i===Au||i===Tu||i===Ru||i===Du||i===Cu||i===Iu||i===Pu||i===Lu||i===Nu||i===Ou)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Su)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===wu)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===bu)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Eu)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Au)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Tu)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Ru)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Du)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Cu)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Iu)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Pu)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Lu)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Nu)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Ou)return r===gt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Uu||i===Fu||i===ku)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===Uu)return r===gt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Fu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===ku)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===zu||i===Hu||i===Zc||i===Bu)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===zu)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Hu)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Zc)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Bu)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===yo?a.UNSIGNED_INT_24_8:a[i]!==void 0?a[i]:null}return{convert:t}}const AS=`
|
|
4719
4719
|
void main() {
|
|
4720
4720
|
|
|
4721
4721
|
gl_Position = vec4( position, 1.0 );
|
|
@@ -4739,7 +4739,7 @@ void main() {
|
|
|
4739
4739
|
|
|
4740
4740
|
}
|
|
4741
4741
|
|
|
4742
|
-
}`;class RS{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new xg(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new at({vertexShader:AS,fragmentShader:TS,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new De(new ki(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class DS extends ba{constructor(e,t){super();const i=this;let n=null,s=1,r=null,o="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,p=null;const v=typeof XRWebGLBinding<"u",m=new RS,g={},_=t.getContextAttributes();let w=null,M=null;const S=[],b=[],T=new xe;let x=null;const A=new Vi;A.viewport=new nt;const I=new Vi;I.viewport=new nt;const C=[A,I],P=new CM;let X=null,z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let re=S[Y];return re===void 0&&(re=new Xl,S[Y]=re),re.getTargetRaySpace()},this.getControllerGrip=function(Y){let re=S[Y];return re===void 0&&(re=new Xl,S[Y]=re),re.getGripSpace()},this.getHand=function(Y){let re=S[Y];return re===void 0&&(re=new Xl,S[Y]=re),re.getHandSpace()};function N(Y){const re=b.indexOf(Y.inputSource);if(re===-1)return;const ne=S[re];ne!==void 0&&(ne.update(Y.inputSource,Y.frame,l||r),ne.dispatchEvent({type:Y.type,data:Y.inputSource}))}function V(){n.removeEventListener("select",N),n.removeEventListener("selectstart",N),n.removeEventListener("selectend",N),n.removeEventListener("squeeze",N),n.removeEventListener("squeezestart",N),n.removeEventListener("squeezeend",N),n.removeEventListener("end",V),n.removeEventListener("inputsourceschange",k);for(let Y=0;Y<S.length;Y++){const re=b[Y];re!==null&&(b[Y]=null,S[Y].disconnect(re))}X=null,z=null,m.reset();for(const Y in g)delete g[Y];e.setRenderTarget(w),f=null,d=null,u=null,n=null,M=null,qe.stop(),i.isPresenting=!1,e.setPixelRatio(x),e.setSize(T.width,T.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){s=Y,i.isPresenting===!0&&Te("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,i.isPresenting===!0&&Te("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||r},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&v&&(u=new XRWebGLBinding(n,t)),u},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(Y){if(n=Y,n!==null){if(w=e.getRenderTarget(),n.addEventListener("select",N),n.addEventListener("selectstart",N),n.addEventListener("selectend",N),n.addEventListener("squeeze",N),n.addEventListener("squeezestart",N),n.addEventListener("squeezeend",N),n.addEventListener("end",V),n.addEventListener("inputsourceschange",k),_.xrCompatible!==!0&&await t.makeXRCompatible(),x=e.getPixelRatio(),e.getSize(T),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let ne=null,H=null,Ae=null;_.depth&&(Ae=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ne=_.stencil?fa:vs,H=_.stencil?yo:gn);const Ne={colorFormat:t.RGBA8,depthFormat:Ae,scaleFactor:s};u=this.getBinding(),d=u.createProjectionLayer(Ne),n.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),M=new Jt(d.textureWidth,d.textureHeight,{format:yi,type:nn,depthTexture:new Ys(d.textureWidth,d.textureHeight,H,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const ne={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(n,t,ne),n.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),M=new Jt(f.framebufferWidth,f.framebufferHeight,{format:yi,type:nn,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(c),l=null,r=await n.requestReferenceSpace(o),qe.setContext(n),qe.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function k(Y){for(let re=0;re<Y.removed.length;re++){const ne=Y.removed[re],H=b.indexOf(ne);H>=0&&(b[H]=null,S[H].disconnect(ne))}for(let re=0;re<Y.added.length;re++){const ne=Y.added[re];let H=b.indexOf(ne);if(H===-1){for(let Ne=0;Ne<S.length;Ne++)if(Ne>=b.length){b.push(ne),H=Ne;break}else if(b[Ne]===null){b[Ne]=ne,H=Ne;break}if(H===-1)break}const Ae=S[H];Ae&&Ae.connect(ne)}}const K=new D,ee=new D;function J(Y,re,ne){K.setFromMatrixPosition(re.matrixWorld),ee.setFromMatrixPosition(ne.matrixWorld);const H=K.distanceTo(ee),Ae=re.projectionMatrix.elements,Ne=ne.projectionMatrix.elements,Ce=Ae[14]/(Ae[10]-1),ye=Ae[14]/(Ae[10]+1),Fe=(Ae[9]+1)/Ae[5],ke=(Ae[9]-1)/Ae[5],ze=(Ae[8]-1)/Ae[0],ft=(Ne[8]+1)/Ne[0],pt=Ce*ze,zt=Ce*ft,Lt=H/(-ze+ft),Ht=Lt*-ze;if(re.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(Ht),Y.translateZ(Lt),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),Ae[10]===-1)Y.projectionMatrix.copy(re.projectionMatrix),Y.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{const Qt=Ce+Lt,O=ye+Lt,zi=pt-Ht,mt=zt+(H-Ht),R=Fe*ye/O*Qt,y=ke*ye/O*Qt;Y.projectionMatrix.makePerspective(zi,mt,R,y,Qt,O),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(n===null)return;let re=Y.near,ne=Y.far;m.texture!==null&&(m.depthNear>0&&(re=m.depthNear),m.depthFar>0&&(ne=m.depthFar)),P.near=I.near=A.near=re,P.far=I.far=A.far=ne,(X!==P.near||z!==P.far)&&(n.updateRenderState({depthNear:P.near,depthFar:P.far}),X=P.near,z=P.far),P.layers.mask=Y.layers.mask|6,A.layers.mask=P.layers.mask&-5,I.layers.mask=P.layers.mask&-3;const H=Y.parent,Ae=P.cameras;ie(P,H);for(let Ne=0;Ne<Ae.length;Ne++)ie(Ae[Ne],H);Ae.length===2?J(P,A,I):P.projectionMatrix.copy(A.projectionMatrix),oe(Y,P,H)};function oe(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=Mr*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return P},this.getFoveation=function(){if(!(d===null&&f===null))return c},this.setFoveation=function(Y){c=Y,d!==null&&(d.fixedFoveation=Y),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=Y)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(P)},this.getCameraTexture=function(Y){return g[Y]};let Ve=null;function Qe(Y,re){if(h=re.getViewerPose(l||r),p=re,h!==null){const ne=h.views;f!==null&&(e.setRenderTargetFramebuffer(M,f.framebuffer),e.setRenderTarget(M));let H=!1;ne.length!==P.cameras.length&&(P.cameras.length=0,H=!0);for(let ye=0;ye<ne.length;ye++){const Fe=ne[ye];let ke=null;if(f!==null)ke=f.getViewport(Fe);else{const ft=u.getViewSubImage(d,Fe);ke=ft.viewport,ye===0&&(e.setRenderTargetTextures(M,ft.colorTexture,ft.depthStencilTexture),e.setRenderTarget(M))}let ze=C[ye];ze===void 0&&(ze=new Vi,ze.layers.enable(ye),ze.viewport=new nt,C[ye]=ze),ze.matrix.fromArray(Fe.transform.matrix),ze.matrix.decompose(ze.position,ze.quaternion,ze.scale),ze.projectionMatrix.fromArray(Fe.projectionMatrix),ze.projectionMatrixInverse.copy(ze.projectionMatrix).invert(),ze.viewport.set(ke.x,ke.y,ke.width,ke.height),ye===0&&(P.matrix.copy(ze.matrix),P.matrix.decompose(P.position,P.quaternion,P.scale)),H===!0&&P.cameras.push(ze)}const Ae=n.enabledFeatures;if(Ae&&Ae.includes("depth-sensing")&&n.depthUsage=="gpu-optimized"&&v){u=i.getBinding();const ye=u.getDepthInformation(ne[0]);ye&&ye.isValid&&ye.texture&&m.init(ye,n.renderState)}if(Ae&&Ae.includes("camera-access")&&v){e.state.unbindTexture(),u=i.getBinding();for(let ye=0;ye<ne.length;ye++){const Fe=ne[ye].camera;if(Fe){let ke=g[Fe];ke||(ke=new xg,g[Fe]=ke);const ze=u.getCameraImage(Fe);ke.sourceTexture=ze}}}}for(let ne=0;ne<S.length;ne++){const H=b[ne],Ae=S[ne];H!==null&&Ae!==void 0&&Ae.update(H,re,l||r)}Ve&&Ve(Y,re),re.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:re}),p=null}const qe=new Tg;qe.setAnimationLoop(Qe),this.setAnimationLoop=function(Y){Ve=Y},this.dispose=function(){}}}const CS=new Ze,Lg=new Xe;Lg.set(-1,0,0,0,1,0,0,0,1);function IS(a,e){function t(m,g){m.matrixAutoUpdate===!0&&m.updateMatrix(),g.value.copy(m.matrix)}function i(m,g){g.color.getRGB(m.fogColor.value,yg(a)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function n(m,g,_,w,M){g.isNodeMaterial?g.uniformsNeedUpdate=!1:g.isMeshBasicMaterial?s(m,g):g.isMeshLambertMaterial?(s(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshToonMaterial?(s(m,g),u(m,g)):g.isMeshPhongMaterial?(s(m,g),h(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshStandardMaterial?(s(m,g),d(m,g),g.isMeshPhysicalMaterial&&f(m,g,M)):g.isMeshMatcapMaterial?(s(m,g),p(m,g)):g.isMeshDepthMaterial?s(m,g):g.isMeshDistanceMaterial?(s(m,g),v(m,g)):g.isMeshNormalMaterial?s(m,g):g.isLineBasicMaterial?(r(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?c(m,g,_,w):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.bumpMap&&(m.bumpMap.value=g.bumpMap,t(g.bumpMap,m.bumpMapTransform),m.bumpScale.value=g.bumpScale,g.side===Ot&&(m.bumpScale.value*=-1)),g.normalMap&&(m.normalMap.value=g.normalMap,t(g.normalMap,m.normalMapTransform),m.normalScale.value.copy(g.normalScale),g.side===Ot&&m.normalScale.value.negate()),g.displacementMap&&(m.displacementMap.value=g.displacementMap,t(g.displacementMap,m.displacementMapTransform),m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,m.emissiveMapTransform)),g.specularMap&&(m.specularMap.value=g.specularMap,t(g.specularMap,m.specularMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);const _=e.get(g),w=_.envMap,M=_.envMapRotation;w&&(m.envMap.value=w,m.envMapRotation.value.setFromMatrix4(CS.makeRotationFromEuler(M)).transpose(),w.isCubeTexture&&w.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Lg),m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap&&(m.lightMap.value=g.lightMap,m.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,m.aoMapTransform))}function r(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform))}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function c(m,g,_,w){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*_,m.scale.value=w*.5,g.map&&(m.map.value=g.map,t(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function h(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function u(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function d(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,_){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===Ot&&m.clearcoatNormalScale.value.negate())),g.dispersion>0&&(m.dispersion.value=g.dispersion),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=_.texture,m.transmissionSamplerSize.value.set(_.width,_.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function v(m,g){const _=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(_.matrixWorld),m.nearDistance.value=_.shadow.camera.near,m.farDistance.value=_.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function PS(a,e,t,i){let n={},s={},r=[];const o=a.getParameter(a.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,S){const b=S.program;i.uniformBlockBinding(M,b)}function l(M,S){let b=n[M.id];b===void 0&&(m(M),b=h(M),n[M.id]=b,M.addEventListener("dispose",_));const T=S.program;i.updateUBOMapping(M,T);const x=e.render.frame;s[M.id]!==x&&(d(M),s[M.id]=x)}function h(M){const S=u();M.__bindingPointIndex=S;const b=a.createBuffer(),T=M.__size,x=M.usage;return a.bindBuffer(a.UNIFORM_BUFFER,b),a.bufferData(a.UNIFORM_BUFFER,T,x),a.bindBuffer(a.UNIFORM_BUFFER,null),a.bindBufferBase(a.UNIFORM_BUFFER,S,b),b}function u(){for(let M=0;M<o;M++)if(r.indexOf(M)===-1)return r.push(M),M;return Be("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(M){const S=n[M.id],b=M.uniforms,T=M.__cache;a.bindBuffer(a.UNIFORM_BUFFER,S);for(let x=0,A=b.length;x<A;x++){const I=b[x];if(Array.isArray(I))for(let C=0,P=I.length;C<P;C++)f(I[C],x,C,T);else f(I,x,0,T)}a.bindBuffer(a.UNIFORM_BUFFER,null)}function f(M,S,b,T){if(v(M,S,b,T)===!0){const x=M.__offset,A=M.value;if(Array.isArray(A)){let I=0;for(let C=0;C<A.length;C++){const P=A[C],X=g(P);p(P,M.__data,I),typeof P!="number"&&typeof P!="boolean"&&!P.isMatrix3&&!ArrayBuffer.isView(P)&&(I+=X.storage/Float32Array.BYTES_PER_ELEMENT)}}else p(A,M.__data,0);a.bufferSubData(a.UNIFORM_BUFFER,x,M.__data)}}function p(M,S,b){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,b)}function v(M,S,b,T){const x=M.value,A=S+"_"+b;if(T[A]===void 0)return typeof x=="number"||typeof x=="boolean"?T[A]=x:ArrayBuffer.isView(x)?T[A]=x.slice():T[A]=x.clone(),!0;{const I=T[A];if(typeof x=="number"||typeof x=="boolean"){if(I!==x)return T[A]=x,!0}else{if(ArrayBuffer.isView(x))return!0;if(I.equals(x)===!1)return I.copy(x),!0}}return!1}function m(M){const S=M.uniforms;let b=0;const T=16;for(let A=0,I=S.length;A<I;A++){const C=Array.isArray(S[A])?S[A]:[S[A]];for(let P=0,X=C.length;P<X;P++){const z=C[P],N=Array.isArray(z.value)?z.value:[z.value];for(let V=0,k=N.length;V<k;V++){const K=N[V],ee=g(K),J=b%T,ie=J%ee.boundary,oe=J+ie;b+=ie,oe!==0&&T-oe<ee.storage&&(b+=T-oe),z.__data=new Float32Array(ee.storage/Float32Array.BYTES_PER_ELEMENT),z.__offset=b,b+=ee.storage}}}const x=b%T;return x>0&&(b+=T-x),M.__size=b,M.__cache={},this}function g(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?Te("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(S.boundary=16,S.storage=M.byteLength):Te("WebGLRenderer: Unsupported uniform value type.",M),S}function _(M){const S=M.target;S.removeEventListener("dispose",_);const b=r.indexOf(S.__bindingPointIndex);r.splice(b,1),a.deleteBuffer(n[S.id]),delete n[S.id],delete s[S.id]}function w(){for(const M in n)a.deleteBuffer(n[M]);r=[],n={},s={}}return{bind:c,update:l,dispose:w}}const LS=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 NS(){return Fn===null&&(Fn=new $s(LS,16,16,_a,Ft),Fn.name="DFG_LUT",Fn.minFilter=st,Fn.magFilter=st,Fn.wrapS=xi,Fn.wrapT=xi,Fn.generateMipmaps=!1,Fn.needsUpdate=!0),Fn}class OS{constructor(e={}){const{canvas:t=uv(),context:i=null,depth:n=!0,stencil:s=!1,alpha:r=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=nn}=e;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=r;const v=f,m=new Set([Ud,Od,Nd]),g=new Set([nn,gn,xo,yo,Pd,Ld]),_=new Uint32Array(4),w=new Int32Array(4),M=new D;let S=null,b=null;const T=[],x=[];let A=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=Jn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let C=!1,P=null,X=null,z=null,N=null;this._outputColorSpace=Fi;let V=0,k=0,K=null,ee=-1,J=null;const ie=new nt,oe=new nt;let Ve=null;const Qe=new se(0);let qe=0,Y=t.width,re=t.height,ne=1,H=null,Ae=null;const Ne=new nt(0,0,Y,re),Ce=new nt(0,0,Y,re);let ye=!1;const Fe=new Wd;let ke=!1,ze=!1;const ft=new Ze,pt=new D,zt=new nt,Lt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ht=!1;function Qt(){return K===null?ne:1}let O=i;function zi(E,U){return t.getContext(E,U)}try{const E={alpha:!0,depth:n,stencil:s,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Dd}`),t.addEventListener("webglcontextlost",Bt,!1),t.addEventListener("webglcontextrestored",At,!1),t.addEventListener("webglcontextcreationerror",Pn,!1),O===null){const U="webgl2";if(O=zi(U,E),O===null)throw zi(U)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(E){throw Be("WebGLRenderer: "+E.message),E}let mt,R,y,F,W,$,ae,le,Z,Q,he,Ie,fe,ue,Ue,He,Ke,L,ce,j,de,ve,te;function Re(){mt=new Ny(O),mt.init(),de=new ES(O,mt),R=new Ay(O,mt,e,de),y=new wS(O,mt),R.reversedDepthBuffer&&d&&y.buffers.depth.setReversed(!0),X=O.createFramebuffer(),z=O.createFramebuffer(),N=O.createFramebuffer(),F=new Fy(O),W=new lS,$=new bS(O,mt,y,W,R,de,F),ae=new Ly(I),le=new BM(O),ve=new by(O,le),Z=new Oy(O,le,F,ve),Q=new zy(O,Z,le,ve,F),L=new ky(O,R,$),Ue=new Ty(W),he=new cS(I,ae,mt,R,ve,Ue),Ie=new IS(I,W),fe=new uS,ue=new vS(mt),Ke=new wy(I,ae,y,Q,p,c),He=new SS(I,Q,R),te=new PS(O,F,R,y),ce=new Ey(O,mt,F),j=new Uy(O,mt,F),F.programs=he.programs,I.capabilities=R,I.extensions=mt,I.properties=W,I.renderLists=fe,I.shadowMap=He,I.state=y,I.info=F}Re(),v!==nn&&(A=new By(v,t.width,t.height,o,n,s));const Se=new DS(I,O);this.xr=Se,this.getContext=function(){return O},this.getContextAttributes=function(){return O.getContextAttributes()},this.forceContextLoss=function(){const E=mt.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){const E=mt.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(E){E!==void 0&&(ne=E,this.setSize(Y,re,!1))},this.getSize=function(E){return E.set(Y,re)},this.setSize=function(E,U,q=!0){if(Se.isPresenting){Te("WebGLRenderer: Can't change size while VR device is presenting.");return}Y=E,re=U,t.width=Math.floor(E*ne),t.height=Math.floor(U*ne),q===!0&&(t.style.width=E+"px",t.style.height=U+"px"),A!==null&&A.setSize(t.width,t.height),this.setViewport(0,0,E,U)},this.getDrawingBufferSize=function(E){return E.set(Y*ne,re*ne).floor()},this.setDrawingBufferSize=function(E,U,q){Y=E,re=U,ne=q,t.width=Math.floor(E*q),t.height=Math.floor(U*q),this.setViewport(0,0,E,U)},this.setEffects=function(E){if(v===nn){Be("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(E){for(let U=0;U<E.length;U++)if(E[U].isOutputPass===!0){Te("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(E||[])},this.getCurrentViewport=function(E){return E.copy(ie)},this.getViewport=function(E){return E.copy(Ne)},this.setViewport=function(E,U,q,B){E.isVector4?Ne.set(E.x,E.y,E.z,E.w):Ne.set(E,U,q,B),y.viewport(ie.copy(Ne).multiplyScalar(ne).round())},this.getScissor=function(E){return E.copy(Ce)},this.setScissor=function(E,U,q,B){E.isVector4?Ce.set(E.x,E.y,E.z,E.w):Ce.set(E,U,q,B),y.scissor(oe.copy(Ce).multiplyScalar(ne).round())},this.getScissorTest=function(){return ye},this.setScissorTest=function(E){y.setScissorTest(ye=E)},this.setOpaqueSort=function(E){H=E},this.setTransparentSort=function(E){Ae=E},this.getClearColor=function(E){return E.copy(Ke.getClearColor())},this.setClearColor=function(){Ke.setClearColor(...arguments)},this.getClearAlpha=function(){return Ke.getClearAlpha()},this.setClearAlpha=function(){Ke.setClearAlpha(...arguments)},this.clear=function(E=!0,U=!0,q=!0){let B=0;if(E){let G=!1;if(K!==null){const ge=K.texture.format;G=m.has(ge)}if(G){const ge=K.texture.type,_e=g.has(ge),me=Ke.getClearColor(),be=Ke.getClearAlpha(),Pe=me.r,$e=me.g,Je=me.b;_e?(_[0]=Pe,_[1]=$e,_[2]=Je,_[3]=be,O.clearBufferuiv(O.COLOR,0,_)):(w[0]=Pe,w[1]=$e,w[2]=Je,w[3]=be,O.clearBufferiv(O.COLOR,0,w))}else B|=O.COLOR_BUFFER_BIT}U&&(B|=O.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),q&&(B|=O.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B!==0&&O.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(E){E.setRenderer(this),P=E},this.dispose=function(){t.removeEventListener("webglcontextlost",Bt,!1),t.removeEventListener("webglcontextrestored",At,!1),t.removeEventListener("webglcontextcreationerror",Pn,!1),Ke.dispose(),fe.dispose(),ue.dispose(),W.dispose(),ae.dispose(),Q.dispose(),ve.dispose(),te.dispose(),he.dispose(),Se.dispose(),Se.removeEventListener("sessionstart",g0),Se.removeEventListener("sessionend",v0),Zs.stop()};function Bt(E){E.preventDefault(),il("WebGLRenderer: Context Lost."),C=!0}function At(){il("WebGLRenderer: Context Restored."),C=!1;const E=F.autoReset,U=He.enabled,q=He.autoUpdate,B=He.needsUpdate,G=He.type;Re(),F.autoReset=E,He.enabled=U,He.autoUpdate=q,He.needsUpdate=B,He.type=G}function Pn(E){Be("WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function Ln(E){const U=E.target;U.removeEventListener("dispose",Ln),M1(U)}function M1(E){x1(E),W.remove(E)}function x1(E){const U=W.get(E).programs;U!==void 0&&(U.forEach(function(q){he.releaseProgram(q)}),E.isShaderMaterial&&he.releaseShaderCache(E))}this.renderBufferDirect=function(E,U,q,B,G,ge){U===null&&(U=Lt);const _e=G.isMesh&&G.matrixWorld.determinantAffine()<0,me=S1(E,U,q,B,G);y.setMaterial(B,_e);let be=q.index,Pe=1;if(B.wireframe===!0){if(be=Z.getWireframeAttribute(q),be===void 0)return;Pe=2}const $e=q.drawRange,Je=q.attributes.position;let Le=$e.start*Pe,yt=($e.start+$e.count)*Pe;ge!==null&&(Le=Math.max(Le,ge.start*Pe),yt=Math.min(yt,(ge.start+ge.count)*Pe)),be!==null?(Le=Math.max(Le,0),yt=Math.min(yt,be.count)):Je!=null&&(Le=Math.max(Le,0),yt=Math.min(yt,Je.count));const Yt=yt-Le;if(Yt<0||Yt===1/0)return;ve.setup(G,B,me,q,be);let Gt,bt=ce;if(be!==null&&(Gt=le.get(be),bt=j,bt.setIndex(Gt)),G.isMesh)B.wireframe===!0?(y.setLineWidth(B.wireframeLinewidth*Qt()),bt.setMode(O.LINES)):bt.setMode(O.TRIANGLES);else if(G.isLine){let Si=B.linewidth;Si===void 0&&(Si=1),y.setLineWidth(Si*Qt()),G.isLineSegments?bt.setMode(O.LINES):G.isLineLoop?bt.setMode(O.LINE_LOOP):bt.setMode(O.LINE_STRIP)}else G.isPoints?bt.setMode(O.POINTS):G.isSprite&&bt.setMode(O.TRIANGLES);if(G.isBatchedMesh)if(mt.get("WEBGL_multi_draw"))bt.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else{const Si=G._multiDrawStarts,Me=G._multiDrawCounts,Xi=G._multiDrawCount,rt=be?le.get(be).bytesPerElement:1,an=W.get(B).currentProgram.getUniforms();for(let Nn=0;Nn<Xi;Nn++)an.setValue(O,"_gl_DrawID",Nn),bt.render(Si[Nn]/rt,Me[Nn])}else if(G.isInstancedMesh)bt.renderInstances(Le,Yt,G.count);else if(q.isInstancedBufferGeometry){const Si=q._maxInstanceCount!==void 0?q._maxInstanceCount:1/0,Me=Math.min(q.instanceCount,Si);bt.renderInstances(Le,Yt,Me)}else bt.render(Le,Yt)};function m0(E,U,q){E.transparent===!0&&E.side===tn&&E.forceSinglePass===!1?(E.side=Ot,E.needsUpdate=!0,Io(E,U,q),E.side=qs,E.needsUpdate=!0,Io(E,U,q),E.side=tn):Io(E,U,q)}this.compile=function(E,U,q=null){q===null&&(q=E),b=ue.get(q),b.init(U),x.push(b),q.traverseVisible(function(G){G.isLight&&G.layers.test(U.layers)&&(b.pushLight(G),G.castShadow&&b.pushShadow(G))}),E!==q&&E.traverseVisible(function(G){G.isLight&&G.layers.test(U.layers)&&(b.pushLight(G),G.castShadow&&b.pushShadow(G))}),b.setupLights();const B=new Set;return E.traverse(function(G){if(!(G.isMesh||G.isPoints||G.isLine||G.isSprite))return;const ge=G.material;if(ge)if(Array.isArray(ge))for(let _e=0;_e<ge.length;_e++){const me=ge[_e];m0(me,q,G),B.add(me)}else m0(ge,q,G),B.add(ge)}),b=x.pop(),B},this.compileAsync=function(E,U,q=null){const B=this.compile(E,U,q);return new Promise(G=>{function ge(){if(B.forEach(function(_e){W.get(_e).currentProgram.isReady()&&B.delete(_e)}),B.size===0){G(E);return}setTimeout(ge,10)}mt.get("KHR_parallel_shader_compile")!==null?ge():setTimeout(ge,10)})};let Pl=null;function y1(E){Pl&&Pl(E)}function g0(){Zs.stop()}function v0(){Zs.start()}const Zs=new Tg;Zs.setAnimationLoop(y1),typeof self<"u"&&Zs.setContext(self),this.setAnimationLoop=function(E){Pl=E,Se.setAnimationLoop(E),E===null?Zs.stop():Zs.start()},Se.addEventListener("sessionstart",g0),Se.addEventListener("sessionend",v0),this.render=function(E,U){if(U!==void 0&&U.isCamera!==!0){Be("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;P!==null&&P.renderStart(E,U);const q=Se.enabled===!0&&Se.isPresenting===!0,B=A!==null&&(K===null||q)&&A.begin(I,K);if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),Se.enabled===!0&&Se.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(Se.cameraAutoUpdate===!0&&Se.updateCamera(U),U=Se.getCamera()),E.isScene===!0&&E.onBeforeRender(I,E,U,K),b=ue.get(E,x.length),b.init(U),b.state.textureUnits=$.getTextureUnits(),x.push(b),ft.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Fe.setFromProjectionMatrix(ft,Kn,U.reversedDepth),ze=this.localClippingEnabled,ke=Ue.init(this.clippingPlanes,ze),S=fe.get(E,T.length),S.init(),T.push(S),Se.enabled===!0&&Se.isPresenting===!0){const _e=I.xr.getDepthSensingMesh();_e!==null&&Ll(_e,U,-1/0,I.sortObjects)}Ll(E,U,0,I.sortObjects),S.finish(),I.sortObjects===!0&&S.sort(H,Ae,U.reversedDepth),Ht=Se.enabled===!1||Se.isPresenting===!1||Se.hasDepthSensing()===!1,Ht&&Ke.addToRenderList(S,E),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),ke===!0&&Ue.beginShadows();const G=b.state.shadowsArray;if(He.render(G,E,U),ke===!0&&Ue.endShadows(),(B&&A.hasRenderPass())===!1){const _e=S.opaque,me=S.transmissive;if(b.setupLights(),U.isArrayCamera){const be=U.cameras;if(me.length>0)for(let Pe=0,$e=be.length;Pe<$e;Pe++){const Je=be[Pe];x0(_e,me,E,Je)}Ht&&Ke.render(E);for(let Pe=0,$e=be.length;Pe<$e;Pe++){const Je=be[Pe];M0(S,E,Je,Je.viewport)}}else me.length>0&&x0(_e,me,E,U),Ht&&Ke.render(E),M0(S,E,U)}K!==null&&k===0&&($.updateMultisampleRenderTarget(K),$.updateRenderTargetMipmap(K)),B&&A.end(I),E.isScene===!0&&E.onAfterRender(I,E,U),ve.resetDefaultState(),ee=-1,J=null,x.pop(),x.length>0?(b=x[x.length-1],$.setTextureUnits(b.state.textureUnits),ke===!0&&Ue.setGlobalState(I.clippingPlanes,b.state.camera)):b=null,T.pop(),T.length>0?S=T[T.length-1]:S=null,P!==null&&P.renderEnd()};function Ll(E,U,q,B){if(E.visible===!1)return;if(E.layers.test(U.layers)){if(E.isGroup)q=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(U);else if(E.isLightProbeGrid)b.pushLightProbeGrid(E);else if(E.isLight)b.pushLight(E),E.castShadow&&b.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||Fe.intersectsSprite(E)){B&&zt.setFromMatrixPosition(E.matrixWorld).applyMatrix4(ft);const _e=Q.update(E),me=E.material;me.visible&&S.push(E,_e,me,q,zt.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||Fe.intersectsObject(E))){const _e=Q.update(E),me=E.material;if(B&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),zt.copy(E.boundingSphere.center)):(_e.boundingSphere===null&&_e.computeBoundingSphere(),zt.copy(_e.boundingSphere.center)),zt.applyMatrix4(E.matrixWorld).applyMatrix4(ft)),Array.isArray(me)){const be=_e.groups;for(let Pe=0,$e=be.length;Pe<$e;Pe++){const Je=be[Pe],Le=me[Je.materialIndex];Le&&Le.visible&&S.push(E,_e,Le,q,zt.z,Je)}}else me.visible&&S.push(E,_e,me,q,zt.z,null)}}const ge=E.children;for(let _e=0,me=ge.length;_e<me;_e++)Ll(ge[_e],U,q,B)}function M0(E,U,q,B){const{opaque:G,transmissive:ge,transparent:_e}=E;b.setupLightsView(q),ke===!0&&Ue.setGlobalState(I.clippingPlanes,q),B&&y.viewport(ie.copy(B)),G.length>0&&Co(G,U,q),ge.length>0&&Co(ge,U,q),_e.length>0&&Co(_e,U,q),y.buffers.depth.setTest(!0),y.buffers.depth.setMask(!0),y.buffers.color.setMask(!0),y.setPolygonOffset(!1)}function x0(E,U,q,B){if((q.isScene===!0?q.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[B.id]===void 0){const Le=mt.has("EXT_color_buffer_half_float")||mt.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[B.id]=new Jt(1,1,{generateMipmaps:!0,type:Le?Ft:nn,minFilter:da,samples:Math.max(4,R.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:it.workingColorSpace})}const ge=b.state.transmissionRenderTarget[B.id],_e=B.viewport||ie;ge.setSize(_e.z*I.transmissionResolutionScale,_e.w*I.transmissionResolutionScale);const me=I.getRenderTarget(),be=I.getActiveCubeFace(),Pe=I.getActiveMipmapLevel();I.setRenderTarget(ge),I.getClearColor(Qe),qe=I.getClearAlpha(),qe<1&&I.setClearColor(16777215,.5),I.clear(),Ht&&Ke.render(q);const $e=I.toneMapping;I.toneMapping=Jn;const Je=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),b.setupLightsView(B),ke===!0&&Ue.setGlobalState(I.clippingPlanes,B),Co(E,q,B),$.updateMultisampleRenderTarget(ge),$.updateRenderTargetMipmap(ge),mt.has("WEBGL_multisampled_render_to_texture")===!1){let Le=!1;for(let yt=0,Yt=U.length;yt<Yt;yt++){const Gt=U[yt],{object:bt,geometry:Si,material:Me,group:Xi}=Gt;if(Me.side===tn&&bt.layers.test(B.layers)){const rt=Me.side;Me.side=Ot,Me.needsUpdate=!0,y0(bt,q,B,Si,Me,Xi),Me.side=rt,Me.needsUpdate=!0,Le=!0}}Le===!0&&($.updateMultisampleRenderTarget(ge),$.updateRenderTargetMipmap(ge))}I.setRenderTarget(me,be,Pe),I.setClearColor(Qe,qe),Je!==void 0&&(B.viewport=Je),I.toneMapping=$e}function Co(E,U,q){const B=U.isScene===!0?U.overrideMaterial:null;for(let G=0,ge=E.length;G<ge;G++){const _e=E[G],{object:me,geometry:be,group:Pe}=_e;let $e=_e.material;$e.allowOverride===!0&&B!==null&&($e=B),me.layers.test(q.layers)&&y0(me,U,q,be,$e,Pe)}}function y0(E,U,q,B,G,ge){E.onBeforeRender(I,U,q,B,G,ge),E.modelViewMatrix.multiplyMatrices(q.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),G.onBeforeRender(I,U,q,B,E,ge),G.transparent===!0&&G.side===tn&&G.forceSinglePass===!1?(G.side=Ot,G.needsUpdate=!0,I.renderBufferDirect(q,U,B,G,E,ge),G.side=qs,G.needsUpdate=!0,I.renderBufferDirect(q,U,B,G,E,ge),G.side=tn):I.renderBufferDirect(q,U,B,G,E,ge),E.onAfterRender(I,U,q,B,G,ge)}function Io(E,U,q){U.isScene!==!0&&(U=Lt);const B=W.get(E),G=b.state.lights,ge=b.state.shadowsArray,_e=G.state.version,me=he.getParameters(E,G.state,ge,U,q,b.state.lightProbeGridArray),be=he.getProgramCacheKey(me);let Pe=B.programs;B.environment=E.isMeshStandardMaterial||E.isMeshLambertMaterial||E.isMeshPhongMaterial?U.environment:null,B.fog=U.fog;const $e=E.isMeshStandardMaterial||E.isMeshLambertMaterial&&!E.envMap||E.isMeshPhongMaterial&&!E.envMap;B.envMap=ae.get(E.envMap||B.environment,$e),B.envMapRotation=B.environment!==null&&E.envMap===null?U.environmentRotation:E.envMapRotation,Pe===void 0&&(E.addEventListener("dispose",Ln),Pe=new Map,B.programs=Pe);let Je=Pe.get(be);if(Je!==void 0){if(B.currentProgram===Je&&B.lightsStateVersion===_e)return S0(E,me),Je}else me.uniforms=he.getUniforms(E),P!==null&&E.isNodeMaterial&&P.build(E,q,me),E.onBeforeCompile(me,I),Je=he.acquireProgram(me,be),Pe.set(be,Je),B.uniforms=me.uniforms;const Le=B.uniforms;return(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(Le.clippingPlanes=Ue.uniform),S0(E,me),B.needsLights=b1(E),B.lightsStateVersion=_e,B.needsLights&&(Le.ambientLightColor.value=G.state.ambient,Le.lightProbe.value=G.state.probe,Le.directionalLights.value=G.state.directional,Le.directionalLightShadows.value=G.state.directionalShadow,Le.spotLights.value=G.state.spot,Le.spotLightShadows.value=G.state.spotShadow,Le.rectAreaLights.value=G.state.rectArea,Le.ltc_1.value=G.state.rectAreaLTC1,Le.ltc_2.value=G.state.rectAreaLTC2,Le.pointLights.value=G.state.point,Le.pointLightShadows.value=G.state.pointShadow,Le.hemisphereLights.value=G.state.hemi,Le.directionalShadowMatrix.value=G.state.directionalShadowMatrix,Le.spotLightMatrix.value=G.state.spotLightMatrix,Le.spotLightMap.value=G.state.spotLightMap,Le.pointShadowMatrix.value=G.state.pointShadowMatrix),B.lightProbeGrid=b.state.lightProbeGridArray.length>0,B.currentProgram=Je,B.uniformsList=null,Je}function _0(E){if(E.uniformsList===null){const U=E.currentProgram.getUniforms();E.uniformsList=Bc.seqWithValue(U.seq,E.uniforms)}return E.uniformsList}function S0(E,U){const q=W.get(E);q.outputColorSpace=U.outputColorSpace,q.batching=U.batching,q.batchingColor=U.batchingColor,q.instancing=U.instancing,q.instancingColor=U.instancingColor,q.instancingMorph=U.instancingMorph,q.skinning=U.skinning,q.morphTargets=U.morphTargets,q.morphNormals=U.morphNormals,q.morphColors=U.morphColors,q.morphTargetsCount=U.morphTargetsCount,q.numClippingPlanes=U.numClippingPlanes,q.numIntersection=U.numClipIntersection,q.vertexAlphas=U.vertexAlphas,q.vertexTangents=U.vertexTangents,q.toneMapping=U.toneMapping}function _1(E,U){if(E.length===0)return null;if(E.length===1)return E[0].texture!==null?E[0]:null;M.setFromMatrixPosition(U.matrixWorld);for(let q=0,B=E.length;q<B;q++){const G=E[q];if(G.texture!==null&&G.boundingBox.containsPoint(M))return G}return null}function S1(E,U,q,B,G){U.isScene!==!0&&(U=Lt),$.resetTextureUnits();const ge=U.fog,_e=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?U.environment:null,me=K===null?I.outputColorSpace:K.isXRRenderTarget===!0?K.texture.colorSpace:it.workingColorSpace,be=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Pe=ae.get(B.envMap||_e,be),$e=B.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,Je=!!q.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Le=!!q.morphAttributes.position,yt=!!q.morphAttributes.normal,Yt=!!q.morphAttributes.color;let Gt=Jn;B.toneMapped&&(K===null||K.isXRRenderTarget===!0)&&(Gt=I.toneMapping);const bt=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,Si=bt!==void 0?bt.length:0,Me=W.get(B),Xi=b.state.lights;if(ke===!0&&(ze===!0||E!==J)){const Tt=E===J&&B.id===ee;Ue.setState(B,E,Tt)}let rt=!1;B.version===Me.__version?(Me.needsLights&&Me.lightsStateVersion!==Xi.state.version||Me.outputColorSpace!==me||G.isBatchedMesh&&Me.batching===!1||!G.isBatchedMesh&&Me.batching===!0||G.isBatchedMesh&&Me.batchingColor===!0&&G.colorTexture===null||G.isBatchedMesh&&Me.batchingColor===!1&&G.colorTexture!==null||G.isInstancedMesh&&Me.instancing===!1||!G.isInstancedMesh&&Me.instancing===!0||G.isSkinnedMesh&&Me.skinning===!1||!G.isSkinnedMesh&&Me.skinning===!0||G.isInstancedMesh&&Me.instancingColor===!0&&G.instanceColor===null||G.isInstancedMesh&&Me.instancingColor===!1&&G.instanceColor!==null||G.isInstancedMesh&&Me.instancingMorph===!0&&G.morphTexture===null||G.isInstancedMesh&&Me.instancingMorph===!1&&G.morphTexture!==null||Me.envMap!==Pe||B.fog===!0&&Me.fog!==ge||Me.numClippingPlanes!==void 0&&(Me.numClippingPlanes!==Ue.numPlanes||Me.numIntersection!==Ue.numIntersection)||Me.vertexAlphas!==$e||Me.vertexTangents!==Je||Me.morphTargets!==Le||Me.morphNormals!==yt||Me.morphColors!==Yt||Me.toneMapping!==Gt||Me.morphTargetsCount!==Si||!!Me.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(rt=!0):(rt=!0,Me.__version=B.version);let an=Me.currentProgram;rt===!0&&(an=Io(B,U,G),P&&B.isNodeMaterial&&P.onUpdateProgram(B,an,Me));let Nn=!1,ws=!1,Ea=!1;const Et=an.getUniforms(),Kt=Me.uniforms;if(y.useProgram(an.program)&&(Nn=!0,ws=!0,Ea=!0),B.id!==ee&&(ee=B.id,ws=!0),Me.needsLights){const Tt=_1(b.state.lightProbeGridArray,G);Me.lightProbeGrid!==Tt&&(Me.lightProbeGrid=Tt,ws=!0)}if(Nn||J!==E){y.buffers.depth.getReversed()&&E.reversedDepth!==!0&&(E._reversedDepth=!0,E.updateProjectionMatrix()),Et.setValue(O,"projectionMatrix",E.projectionMatrix),Et.setValue(O,"viewMatrix",E.matrixWorldInverse);const Es=Et.map.cameraPosition;Es!==void 0&&Es.setValue(O,pt.setFromMatrixPosition(E.matrixWorld)),R.logarithmicDepthBuffer&&Et.setValue(O,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&Et.setValue(O,"isOrthographic",E.isOrthographicCamera===!0),J!==E&&(J=E,ws=!0,Ea=!0)}if(Me.needsLights&&(Xi.state.directionalShadowMap.length>0&&Et.setValue(O,"directionalShadowMap",Xi.state.directionalShadowMap,$),Xi.state.spotShadowMap.length>0&&Et.setValue(O,"spotShadowMap",Xi.state.spotShadowMap,$),Xi.state.pointShadowMap.length>0&&Et.setValue(O,"pointShadowMap",Xi.state.pointShadowMap,$)),G.isSkinnedMesh){Et.setOptional(O,G,"bindMatrix"),Et.setOptional(O,G,"bindMatrixInverse");const Tt=G.skeleton;Tt&&(Tt.boneTexture===null&&Tt.computeBoneTexture(),Et.setValue(O,"boneTexture",Tt.boneTexture,$))}G.isBatchedMesh&&(Et.setOptional(O,G,"batchingTexture"),Et.setValue(O,"batchingTexture",G._matricesTexture,$),Et.setOptional(O,G,"batchingIdTexture"),Et.setValue(O,"batchingIdTexture",G._indirectTexture,$),Et.setOptional(O,G,"batchingColorTexture"),G._colorsTexture!==null&&Et.setValue(O,"batchingColorTexture",G._colorsTexture,$));const bs=q.morphAttributes;if((bs.position!==void 0||bs.normal!==void 0||bs.color!==void 0)&&L.update(G,q,an),(ws||Me.receiveShadow!==G.receiveShadow)&&(Me.receiveShadow=G.receiveShadow,Et.setValue(O,"receiveShadow",G.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&U.environment!==null&&(Kt.envMapIntensity.value=U.environmentIntensity),Kt.dfgLUT!==void 0&&(Kt.dfgLUT.value=NS()),ws){if(Et.setValue(O,"toneMappingExposure",I.toneMappingExposure),Me.needsLights&&w1(Kt,Ea),ge&&B.fog===!0&&Ie.refreshFogUniforms(Kt,ge),Ie.refreshMaterialUniforms(Kt,B,ne,re,b.state.transmissionRenderTarget[E.id]),Me.needsLights&&Me.lightProbeGrid){const Tt=Me.lightProbeGrid;Kt.probesSH.value=Tt.texture,Kt.probesMin.value.copy(Tt.boundingBox.min),Kt.probesMax.value.copy(Tt.boundingBox.max),Kt.probesResolution.value.copy(Tt.resolution)}Bc.upload(O,_0(Me),Kt,$)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(Bc.upload(O,_0(Me),Kt,$),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&Et.setValue(O,"center",G.center),Et.setValue(O,"modelViewMatrix",G.modelViewMatrix),Et.setValue(O,"normalMatrix",G.normalMatrix),Et.setValue(O,"modelMatrix",G.matrixWorld),B.uniformsGroups!==void 0){const Tt=B.uniformsGroups;for(let Es=0,Aa=Tt.length;Es<Aa;Es++){const w0=Tt[Es];te.update(w0,an),te.bind(w0,an)}}return an}function w1(E,U){E.ambientLightColor.needsUpdate=U,E.lightProbe.needsUpdate=U,E.directionalLights.needsUpdate=U,E.directionalLightShadows.needsUpdate=U,E.pointLights.needsUpdate=U,E.pointLightShadows.needsUpdate=U,E.spotLights.needsUpdate=U,E.spotLightShadows.needsUpdate=U,E.rectAreaLights.needsUpdate=U,E.hemisphereLights.needsUpdate=U}function b1(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return V},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return K},this.setRenderTargetTextures=function(E,U,q){const B=W.get(E);B.__autoAllocateDepthBuffer=E.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),W.get(E.texture).__webglTexture=U,W.get(E.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:q,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(E,U){const q=W.get(E);q.__webglFramebuffer=U,q.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(E,U=0,q=0){K=E,V=U,k=q;let B=null,G=!1,ge=!1;if(E){const me=W.get(E);if(me.__useDefaultFramebuffer!==void 0){y.bindFramebuffer(O.FRAMEBUFFER,me.__webglFramebuffer),ie.copy(E.viewport),oe.copy(E.scissor),Ve=E.scissorTest,y.viewport(ie),y.scissor(oe),y.setScissorTest(Ve),ee=-1;return}else if(me.__webglFramebuffer===void 0)$.setupRenderTarget(E);else if(me.__hasExternalTextures)$.rebindTextures(E,W.get(E.texture).__webglTexture,W.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){const $e=E.depthTexture;if(me.__boundDepthTexture!==$e){if($e!==null&&W.has($e)&&(E.width!==$e.image.width||E.height!==$e.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");$.setupDepthRenderbuffer(E)}}const be=E.texture;(be.isData3DTexture||be.isDataArrayTexture||be.isCompressedArrayTexture)&&(ge=!0);const Pe=W.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(Pe[U])?B=Pe[U][q]:B=Pe[U],G=!0):E.samples>0&&$.useMultisampledRTT(E)===!1?B=W.get(E).__webglMultisampledFramebuffer:Array.isArray(Pe)?B=Pe[q]:B=Pe,ie.copy(E.viewport),oe.copy(E.scissor),Ve=E.scissorTest}else ie.copy(Ne).multiplyScalar(ne).floor(),oe.copy(Ce).multiplyScalar(ne).floor(),Ve=ye;if(q!==0&&(B=X),y.bindFramebuffer(O.FRAMEBUFFER,B)&&y.drawBuffers(E,B),y.viewport(ie),y.scissor(oe),y.setScissorTest(Ve),G){const me=W.get(E.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_CUBE_MAP_POSITIVE_X+U,me.__webglTexture,q)}else if(ge){const me=U;for(let be=0;be<E.textures.length;be++){const Pe=W.get(E.textures[be]);O.framebufferTextureLayer(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0+be,Pe.__webglTexture,q,me)}}else if(E!==null&&q!==0){const me=W.get(E.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,me.__webglTexture,q)}ee=-1},this.readRenderTargetPixels=function(E,U,q,B,G,ge,_e,me=0){if(!(E&&E.isWebGLRenderTarget)){Be("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let be=W.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&_e!==void 0&&(be=be[_e]),be){y.bindFramebuffer(O.FRAMEBUFFER,be);try{const Pe=E.textures[me],$e=Pe.format,Je=Pe.type;if(E.textures.length>1&&O.readBuffer(O.COLOR_ATTACHMENT0+me),!R.textureFormatReadable($e)){Be("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!R.textureTypeReadable(Je)){Be("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=E.width-B&&q>=0&&q<=E.height-G&&O.readPixels(U,q,B,G,de.convert($e),de.convert(Je),ge)}finally{const Pe=K!==null?W.get(K).__webglFramebuffer:null;y.bindFramebuffer(O.FRAMEBUFFER,Pe)}}},this.readRenderTargetPixelsAsync=async function(E,U,q,B,G,ge,_e,me=0){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let be=W.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&_e!==void 0&&(be=be[_e]),be)if(U>=0&&U<=E.width-B&&q>=0&&q<=E.height-G){y.bindFramebuffer(O.FRAMEBUFFER,be);const Pe=E.textures[me],$e=Pe.format,Je=Pe.type;if(E.textures.length>1&&O.readBuffer(O.COLOR_ATTACHMENT0+me),!R.textureFormatReadable($e))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!R.textureTypeReadable(Je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Le=O.createBuffer();O.bindBuffer(O.PIXEL_PACK_BUFFER,Le),O.bufferData(O.PIXEL_PACK_BUFFER,ge.byteLength,O.STREAM_READ),O.readPixels(U,q,B,G,de.convert($e),de.convert(Je),0);const yt=K!==null?W.get(K).__webglFramebuffer:null;y.bindFramebuffer(O.FRAMEBUFFER,yt);const Yt=O.fenceSync(O.SYNC_GPU_COMMANDS_COMPLETE,0);return O.flush(),await dv(O,Yt,4),O.bindBuffer(O.PIXEL_PACK_BUFFER,Le),O.getBufferSubData(O.PIXEL_PACK_BUFFER,0,ge),O.deleteBuffer(Le),O.deleteSync(Yt),ge}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(E,U=null,q=0){const B=Math.pow(2,-q),G=Math.floor(E.image.width*B),ge=Math.floor(E.image.height*B),_e=U!==null?U.x:0,me=U!==null?U.y:0;$.setTexture2D(E,0),O.copyTexSubImage2D(O.TEXTURE_2D,q,0,0,_e,me,G,ge),y.unbindTexture()},this.copyTextureToTexture=function(E,U,q=null,B=null,G=0,ge=0){let _e,me,be,Pe,$e,Je,Le,yt,Yt;const Gt=E.isCompressedTexture?E.mipmaps[ge]:E.image;if(q!==null)_e=q.max.x-q.min.x,me=q.max.y-q.min.y,be=q.isBox3?q.max.z-q.min.z:1,Pe=q.min.x,$e=q.min.y,Je=q.isBox3?q.min.z:0;else{const Kt=Math.pow(2,-G);_e=Math.floor(Gt.width*Kt),me=Math.floor(Gt.height*Kt),E.isDataArrayTexture?be=Gt.depth:E.isData3DTexture?be=Math.floor(Gt.depth*Kt):be=1,Pe=0,$e=0,Je=0}B!==null?(Le=B.x,yt=B.y,Yt=B.z):(Le=0,yt=0,Yt=0);const bt=de.convert(U.format),Si=de.convert(U.type);let Me;U.isData3DTexture?($.setTexture3D(U,0),Me=O.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?($.setTexture2DArray(U,0),Me=O.TEXTURE_2D_ARRAY):($.setTexture2D(U,0),Me=O.TEXTURE_2D),y.activeTexture(O.TEXTURE0),y.pixelStorei(O.UNPACK_FLIP_Y_WEBGL,U.flipY),y.pixelStorei(O.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),y.pixelStorei(O.UNPACK_ALIGNMENT,U.unpackAlignment);const Xi=y.getParameter(O.UNPACK_ROW_LENGTH),rt=y.getParameter(O.UNPACK_IMAGE_HEIGHT),an=y.getParameter(O.UNPACK_SKIP_PIXELS),Nn=y.getParameter(O.UNPACK_SKIP_ROWS),ws=y.getParameter(O.UNPACK_SKIP_IMAGES);y.pixelStorei(O.UNPACK_ROW_LENGTH,Gt.width),y.pixelStorei(O.UNPACK_IMAGE_HEIGHT,Gt.height),y.pixelStorei(O.UNPACK_SKIP_PIXELS,Pe),y.pixelStorei(O.UNPACK_SKIP_ROWS,$e),y.pixelStorei(O.UNPACK_SKIP_IMAGES,Je);const Ea=E.isDataArrayTexture||E.isData3DTexture,Et=U.isDataArrayTexture||U.isData3DTexture;if(E.isDepthTexture){const Kt=W.get(E),bs=W.get(U),Tt=W.get(Kt.__renderTarget),Es=W.get(bs.__renderTarget);y.bindFramebuffer(O.READ_FRAMEBUFFER,Tt.__webglFramebuffer),y.bindFramebuffer(O.DRAW_FRAMEBUFFER,Es.__webglFramebuffer);for(let Aa=0;Aa<be;Aa++)Ea&&(O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,W.get(E).__webglTexture,G,Je+Aa),O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,W.get(U).__webglTexture,ge,Yt+Aa)),O.blitFramebuffer(Pe,$e,_e,me,Le,yt,_e,me,O.DEPTH_BUFFER_BIT,O.NEAREST);y.bindFramebuffer(O.READ_FRAMEBUFFER,null),y.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else if(G!==0||E.isRenderTargetTexture||W.has(E)){const Kt=W.get(E),bs=W.get(U);y.bindFramebuffer(O.READ_FRAMEBUFFER,z),y.bindFramebuffer(O.DRAW_FRAMEBUFFER,N);for(let Tt=0;Tt<be;Tt++)Ea?O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,Kt.__webglTexture,G,Je+Tt):O.framebufferTexture2D(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,Kt.__webglTexture,G),Et?O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,bs.__webglTexture,ge,Yt+Tt):O.framebufferTexture2D(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,bs.__webglTexture,ge),G!==0?O.blitFramebuffer(Pe,$e,_e,me,Le,yt,_e,me,O.COLOR_BUFFER_BIT,O.NEAREST):Et?O.copyTexSubImage3D(Me,ge,Le,yt,Yt+Tt,Pe,$e,_e,me):O.copyTexSubImage2D(Me,ge,Le,yt,Pe,$e,_e,me);y.bindFramebuffer(O.READ_FRAMEBUFFER,null),y.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else Et?E.isDataTexture||E.isData3DTexture?O.texSubImage3D(Me,ge,Le,yt,Yt,_e,me,be,bt,Si,Gt.data):U.isCompressedArrayTexture?O.compressedTexSubImage3D(Me,ge,Le,yt,Yt,_e,me,be,bt,Gt.data):O.texSubImage3D(Me,ge,Le,yt,Yt,_e,me,be,bt,Si,Gt):E.isDataTexture?O.texSubImage2D(O.TEXTURE_2D,ge,Le,yt,_e,me,bt,Si,Gt.data):E.isCompressedTexture?O.compressedTexSubImage2D(O.TEXTURE_2D,ge,Le,yt,Gt.width,Gt.height,bt,Gt.data):O.texSubImage2D(O.TEXTURE_2D,ge,Le,yt,_e,me,bt,Si,Gt);y.pixelStorei(O.UNPACK_ROW_LENGTH,Xi),y.pixelStorei(O.UNPACK_IMAGE_HEIGHT,rt),y.pixelStorei(O.UNPACK_SKIP_PIXELS,an),y.pixelStorei(O.UNPACK_SKIP_ROWS,Nn),y.pixelStorei(O.UNPACK_SKIP_IMAGES,ws),ge===0&&U.generateMipmaps&&O.generateMipmap(Me),y.unbindTexture()},this.initRenderTarget=function(E){W.get(E).__webglFramebuffer===void 0&&$.setupRenderTarget(E)},this.initTexture=function(E){E.isCubeTexture?$.setTextureCube(E,0):E.isData3DTexture?$.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?$.setTexture2DArray(E,0):$.setTexture2D(E,0),y.unbindTexture()},this.resetState=function(){V=0,k=0,K=null,y.reset(),ve.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Kn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=it._getDrawingBufferColorSpace(e),t.unpackColorSpace=it._getUnpackColorSpace()}}const US=`
|
|
4742
|
+
}`;class RS{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new xg(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new at({vertexShader:AS,fragmentShader:TS,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new De(new ki(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class DS extends ba{constructor(e,t){super();const i=this;let n=null,s=1,r=null,o="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,p=null;const v=typeof XRWebGLBinding<"u",m=new RS,g={},_=t.getContextAttributes();let w=null,M=null;const S=[],b=[],T=new xe;let x=null;const A=new Vi;A.viewport=new it;const I=new Vi;I.viewport=new it;const C=[A,I],P=new CM;let X=null,z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let re=S[Y];return re===void 0&&(re=new Xl,S[Y]=re),re.getTargetRaySpace()},this.getControllerGrip=function(Y){let re=S[Y];return re===void 0&&(re=new Xl,S[Y]=re),re.getGripSpace()},this.getHand=function(Y){let re=S[Y];return re===void 0&&(re=new Xl,S[Y]=re),re.getHandSpace()};function N(Y){const re=b.indexOf(Y.inputSource);if(re===-1)return;const ne=S[re];ne!==void 0&&(ne.update(Y.inputSource,Y.frame,l||r),ne.dispatchEvent({type:Y.type,data:Y.inputSource}))}function V(){n.removeEventListener("select",N),n.removeEventListener("selectstart",N),n.removeEventListener("selectend",N),n.removeEventListener("squeeze",N),n.removeEventListener("squeezestart",N),n.removeEventListener("squeezeend",N),n.removeEventListener("end",V),n.removeEventListener("inputsourceschange",k);for(let Y=0;Y<S.length;Y++){const re=b[Y];re!==null&&(b[Y]=null,S[Y].disconnect(re))}X=null,z=null,m.reset();for(const Y in g)delete g[Y];e.setRenderTarget(w),f=null,d=null,u=null,n=null,M=null,qe.stop(),i.isPresenting=!1,e.setPixelRatio(x),e.setSize(T.width,T.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){s=Y,i.isPresenting===!0&&Te("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,i.isPresenting===!0&&Te("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||r},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&v&&(u=new XRWebGLBinding(n,t)),u},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(Y){if(n=Y,n!==null){if(w=e.getRenderTarget(),n.addEventListener("select",N),n.addEventListener("selectstart",N),n.addEventListener("selectend",N),n.addEventListener("squeeze",N),n.addEventListener("squeezestart",N),n.addEventListener("squeezeend",N),n.addEventListener("end",V),n.addEventListener("inputsourceschange",k),_.xrCompatible!==!0&&await t.makeXRCompatible(),x=e.getPixelRatio(),e.getSize(T),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let ne=null,H=null,Ae=null;_.depth&&(Ae=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ne=_.stencil?fa:vs,H=_.stencil?yo:gn);const Ne={colorFormat:t.RGBA8,depthFormat:Ae,scaleFactor:s};u=this.getBinding(),d=u.createProjectionLayer(Ne),n.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),M=new jt(d.textureWidth,d.textureHeight,{format:_i,type:nn,depthTexture:new Ys(d.textureWidth,d.textureHeight,H,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const ne={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(n,t,ne),n.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),M=new jt(f.framebufferWidth,f.framebufferHeight,{format:_i,type:nn,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(c),l=null,r=await n.requestReferenceSpace(o),qe.setContext(n),qe.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function k(Y){for(let re=0;re<Y.removed.length;re++){const ne=Y.removed[re],H=b.indexOf(ne);H>=0&&(b[H]=null,S[H].disconnect(ne))}for(let re=0;re<Y.added.length;re++){const ne=Y.added[re];let H=b.indexOf(ne);if(H===-1){for(let Ne=0;Ne<S.length;Ne++)if(Ne>=b.length){b.push(ne),H=Ne;break}else if(b[Ne]===null){b[Ne]=ne,H=Ne;break}if(H===-1)break}const Ae=S[H];Ae&&Ae.connect(ne)}}const K=new D,ee=new D;function J(Y,re,ne){K.setFromMatrixPosition(re.matrixWorld),ee.setFromMatrixPosition(ne.matrixWorld);const H=K.distanceTo(ee),Ae=re.projectionMatrix.elements,Ne=ne.projectionMatrix.elements,Ce=Ae[14]/(Ae[10]-1),ye=Ae[14]/(Ae[10]+1),Fe=(Ae[9]+1)/Ae[5],ke=(Ae[9]-1)/Ae[5],ze=(Ae[8]-1)/Ae[0],ft=(Ne[8]+1)/Ne[0],pt=Ce*ze,Ht=Ce*ft,Lt=H/(-ze+ft),Bt=Lt*-ze;if(re.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(Bt),Y.translateZ(Lt),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),Ae[10]===-1)Y.projectionMatrix.copy(re.projectionMatrix),Y.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{const ei=Ce+Lt,O=ye+Lt,zi=pt-Bt,mt=Ht+(H-Bt),R=Fe*ye/O*ei,y=ke*ye/O*ei;Y.projectionMatrix.makePerspective(zi,mt,R,y,ei,O),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(n===null)return;let re=Y.near,ne=Y.far;m.texture!==null&&(m.depthNear>0&&(re=m.depthNear),m.depthFar>0&&(ne=m.depthFar)),P.near=I.near=A.near=re,P.far=I.far=A.far=ne,(X!==P.near||z!==P.far)&&(n.updateRenderState({depthNear:P.near,depthFar:P.far}),X=P.near,z=P.far),P.layers.mask=Y.layers.mask|6,A.layers.mask=P.layers.mask&-5,I.layers.mask=P.layers.mask&-3;const H=Y.parent,Ae=P.cameras;ie(P,H);for(let Ne=0;Ne<Ae.length;Ne++)ie(Ae[Ne],H);Ae.length===2?J(P,A,I):P.projectionMatrix.copy(A.projectionMatrix),oe(Y,P,H)};function oe(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=Mr*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return P},this.getFoveation=function(){if(!(d===null&&f===null))return c},this.setFoveation=function(Y){c=Y,d!==null&&(d.fixedFoveation=Y),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=Y)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(P)},this.getCameraTexture=function(Y){return g[Y]};let Ve=null;function Qe(Y,re){if(h=re.getViewerPose(l||r),p=re,h!==null){const ne=h.views;f!==null&&(e.setRenderTargetFramebuffer(M,f.framebuffer),e.setRenderTarget(M));let H=!1;ne.length!==P.cameras.length&&(P.cameras.length=0,H=!0);for(let ye=0;ye<ne.length;ye++){const Fe=ne[ye];let ke=null;if(f!==null)ke=f.getViewport(Fe);else{const ft=u.getViewSubImage(d,Fe);ke=ft.viewport,ye===0&&(e.setRenderTargetTextures(M,ft.colorTexture,ft.depthStencilTexture),e.setRenderTarget(M))}let ze=C[ye];ze===void 0&&(ze=new Vi,ze.layers.enable(ye),ze.viewport=new it,C[ye]=ze),ze.matrix.fromArray(Fe.transform.matrix),ze.matrix.decompose(ze.position,ze.quaternion,ze.scale),ze.projectionMatrix.fromArray(Fe.projectionMatrix),ze.projectionMatrixInverse.copy(ze.projectionMatrix).invert(),ze.viewport.set(ke.x,ke.y,ke.width,ke.height),ye===0&&(P.matrix.copy(ze.matrix),P.matrix.decompose(P.position,P.quaternion,P.scale)),H===!0&&P.cameras.push(ze)}const Ae=n.enabledFeatures;if(Ae&&Ae.includes("depth-sensing")&&n.depthUsage=="gpu-optimized"&&v){u=i.getBinding();const ye=u.getDepthInformation(ne[0]);ye&&ye.isValid&&ye.texture&&m.init(ye,n.renderState)}if(Ae&&Ae.includes("camera-access")&&v){e.state.unbindTexture(),u=i.getBinding();for(let ye=0;ye<ne.length;ye++){const Fe=ne[ye].camera;if(Fe){let ke=g[Fe];ke||(ke=new xg,g[Fe]=ke);const ze=u.getCameraImage(Fe);ke.sourceTexture=ze}}}}for(let ne=0;ne<S.length;ne++){const H=b[ne],Ae=S[ne];H!==null&&Ae!==void 0&&Ae.update(H,re,l||r)}Ve&&Ve(Y,re),re.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:re}),p=null}const qe=new Tg;qe.setAnimationLoop(Qe),this.setAnimationLoop=function(Y){Ve=Y},this.dispose=function(){}}}const CS=new Ze,Lg=new Xe;Lg.set(-1,0,0,0,1,0,0,0,1);function IS(a,e){function t(m,g){m.matrixAutoUpdate===!0&&m.updateMatrix(),g.value.copy(m.matrix)}function i(m,g){g.color.getRGB(m.fogColor.value,yg(a)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function n(m,g,_,w,M){g.isNodeMaterial?g.uniformsNeedUpdate=!1:g.isMeshBasicMaterial?s(m,g):g.isMeshLambertMaterial?(s(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshToonMaterial?(s(m,g),u(m,g)):g.isMeshPhongMaterial?(s(m,g),h(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshStandardMaterial?(s(m,g),d(m,g),g.isMeshPhysicalMaterial&&f(m,g,M)):g.isMeshMatcapMaterial?(s(m,g),p(m,g)):g.isMeshDepthMaterial?s(m,g):g.isMeshDistanceMaterial?(s(m,g),v(m,g)):g.isMeshNormalMaterial?s(m,g):g.isLineBasicMaterial?(r(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?c(m,g,_,w):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.bumpMap&&(m.bumpMap.value=g.bumpMap,t(g.bumpMap,m.bumpMapTransform),m.bumpScale.value=g.bumpScale,g.side===Ot&&(m.bumpScale.value*=-1)),g.normalMap&&(m.normalMap.value=g.normalMap,t(g.normalMap,m.normalMapTransform),m.normalScale.value.copy(g.normalScale),g.side===Ot&&m.normalScale.value.negate()),g.displacementMap&&(m.displacementMap.value=g.displacementMap,t(g.displacementMap,m.displacementMapTransform),m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,m.emissiveMapTransform)),g.specularMap&&(m.specularMap.value=g.specularMap,t(g.specularMap,m.specularMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);const _=e.get(g),w=_.envMap,M=_.envMapRotation;w&&(m.envMap.value=w,m.envMapRotation.value.setFromMatrix4(CS.makeRotationFromEuler(M)).transpose(),w.isCubeTexture&&w.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Lg),m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap&&(m.lightMap.value=g.lightMap,m.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,m.aoMapTransform))}function r(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform))}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function c(m,g,_,w){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*_,m.scale.value=w*.5,g.map&&(m.map.value=g.map,t(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function h(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function u(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function d(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,_){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===Ot&&m.clearcoatNormalScale.value.negate())),g.dispersion>0&&(m.dispersion.value=g.dispersion),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=_.texture,m.transmissionSamplerSize.value.set(_.width,_.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function v(m,g){const _=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(_.matrixWorld),m.nearDistance.value=_.shadow.camera.near,m.farDistance.value=_.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function PS(a,e,t,i){let n={},s={},r=[];const o=a.getParameter(a.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,S){const b=S.program;i.uniformBlockBinding(M,b)}function l(M,S){let b=n[M.id];b===void 0&&(m(M),b=h(M),n[M.id]=b,M.addEventListener("dispose",_));const T=S.program;i.updateUBOMapping(M,T);const x=e.render.frame;s[M.id]!==x&&(d(M),s[M.id]=x)}function h(M){const S=u();M.__bindingPointIndex=S;const b=a.createBuffer(),T=M.__size,x=M.usage;return a.bindBuffer(a.UNIFORM_BUFFER,b),a.bufferData(a.UNIFORM_BUFFER,T,x),a.bindBuffer(a.UNIFORM_BUFFER,null),a.bindBufferBase(a.UNIFORM_BUFFER,S,b),b}function u(){for(let M=0;M<o;M++)if(r.indexOf(M)===-1)return r.push(M),M;return Be("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(M){const S=n[M.id],b=M.uniforms,T=M.__cache;a.bindBuffer(a.UNIFORM_BUFFER,S);for(let x=0,A=b.length;x<A;x++){const I=b[x];if(Array.isArray(I))for(let C=0,P=I.length;C<P;C++)f(I[C],x,C,T);else f(I,x,0,T)}a.bindBuffer(a.UNIFORM_BUFFER,null)}function f(M,S,b,T){if(v(M,S,b,T)===!0){const x=M.__offset,A=M.value;if(Array.isArray(A)){let I=0;for(let C=0;C<A.length;C++){const P=A[C],X=g(P);p(P,M.__data,I),typeof P!="number"&&typeof P!="boolean"&&!P.isMatrix3&&!ArrayBuffer.isView(P)&&(I+=X.storage/Float32Array.BYTES_PER_ELEMENT)}}else p(A,M.__data,0);a.bufferSubData(a.UNIFORM_BUFFER,x,M.__data)}}function p(M,S,b){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,b)}function v(M,S,b,T){const x=M.value,A=S+"_"+b;if(T[A]===void 0)return typeof x=="number"||typeof x=="boolean"?T[A]=x:ArrayBuffer.isView(x)?T[A]=x.slice():T[A]=x.clone(),!0;{const I=T[A];if(typeof x=="number"||typeof x=="boolean"){if(I!==x)return T[A]=x,!0}else{if(ArrayBuffer.isView(x))return!0;if(I.equals(x)===!1)return I.copy(x),!0}}return!1}function m(M){const S=M.uniforms;let b=0;const T=16;for(let A=0,I=S.length;A<I;A++){const C=Array.isArray(S[A])?S[A]:[S[A]];for(let P=0,X=C.length;P<X;P++){const z=C[P],N=Array.isArray(z.value)?z.value:[z.value];for(let V=0,k=N.length;V<k;V++){const K=N[V],ee=g(K),J=b%T,ie=J%ee.boundary,oe=J+ie;b+=ie,oe!==0&&T-oe<ee.storage&&(b+=T-oe),z.__data=new Float32Array(ee.storage/Float32Array.BYTES_PER_ELEMENT),z.__offset=b,b+=ee.storage}}}const x=b%T;return x>0&&(b+=T-x),M.__size=b,M.__cache={},this}function g(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?Te("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(S.boundary=16,S.storage=M.byteLength):Te("WebGLRenderer: Unsupported uniform value type.",M),S}function _(M){const S=M.target;S.removeEventListener("dispose",_);const b=r.indexOf(S.__bindingPointIndex);r.splice(b,1),a.deleteBuffer(n[S.id]),delete n[S.id],delete s[S.id]}function w(){for(const M in n)a.deleteBuffer(n[M]);r=[],n={},s={}}return{bind:c,update:l,dispose:w}}const LS=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 NS(){return Fn===null&&(Fn=new $s(LS,16,16,_a,kt),Fn.name="DFG_LUT",Fn.minFilter=st,Fn.magFilter=st,Fn.wrapS=yi,Fn.wrapT=yi,Fn.generateMipmaps=!1,Fn.needsUpdate=!0),Fn}class OS{constructor(e={}){const{canvas:t=uv(),context:i=null,depth:n=!0,stencil:s=!1,alpha:r=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=nn}=e;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=r;const v=f,m=new Set([Ud,Od,Nd]),g=new Set([nn,gn,xo,yo,Pd,Ld]),_=new Uint32Array(4),w=new Int32Array(4),M=new D;let S=null,b=null;const T=[],x=[];let A=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=Jn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let C=!1,P=null,X=null,z=null,N=null;this._outputColorSpace=Fi;let V=0,k=0,K=null,ee=-1,J=null;const ie=new it,oe=new it;let Ve=null;const Qe=new se(0);let qe=0,Y=t.width,re=t.height,ne=1,H=null,Ae=null;const Ne=new it(0,0,Y,re),Ce=new it(0,0,Y,re);let ye=!1;const Fe=new Wd;let ke=!1,ze=!1;const ft=new Ze,pt=new D,Ht=new it,Lt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Bt=!1;function ei(){return K===null?ne:1}let O=i;function zi(E,U){return t.getContext(E,U)}try{const E={alpha:!0,depth:n,stencil:s,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Dd}`),t.addEventListener("webglcontextlost",Gt,!1),t.addEventListener("webglcontextrestored",At,!1),t.addEventListener("webglcontextcreationerror",Pn,!1),O===null){const U="webgl2";if(O=zi(U,E),O===null)throw zi(U)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(E){throw Be("WebGLRenderer: "+E.message),E}let mt,R,y,F,W,$,ae,le,Z,Q,he,Ie,fe,ue,Ue,He,Ke,L,ce,j,de,ve,te;function Re(){mt=new Ny(O),mt.init(),de=new ES(O,mt),R=new Ay(O,mt,e,de),y=new wS(O,mt),R.reversedDepthBuffer&&d&&y.buffers.depth.setReversed(!0),X=O.createFramebuffer(),z=O.createFramebuffer(),N=O.createFramebuffer(),F=new Fy(O),W=new lS,$=new bS(O,mt,y,W,R,de,F),ae=new Ly(I),le=new BM(O),ve=new by(O,le),Z=new Oy(O,le,F,ve),Q=new zy(O,Z,le,ve,F),L=new ky(O,R,$),Ue=new Ty(W),he=new cS(I,ae,mt,R,ve,Ue),Ie=new IS(I,W),fe=new uS,ue=new vS(mt),Ke=new wy(I,ae,y,Q,p,c),He=new SS(I,Q,R),te=new PS(O,F,R,y),ce=new Ey(O,mt,F),j=new Uy(O,mt,F),F.programs=he.programs,I.capabilities=R,I.extensions=mt,I.properties=W,I.renderLists=fe,I.shadowMap=He,I.state=y,I.info=F}Re(),v!==nn&&(A=new By(v,t.width,t.height,o,n,s));const Se=new DS(I,O);this.xr=Se,this.getContext=function(){return O},this.getContextAttributes=function(){return O.getContextAttributes()},this.forceContextLoss=function(){const E=mt.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){const E=mt.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(E){E!==void 0&&(ne=E,this.setSize(Y,re,!1))},this.getSize=function(E){return E.set(Y,re)},this.setSize=function(E,U,q=!0){if(Se.isPresenting){Te("WebGLRenderer: Can't change size while VR device is presenting.");return}Y=E,re=U,t.width=Math.floor(E*ne),t.height=Math.floor(U*ne),q===!0&&(t.style.width=E+"px",t.style.height=U+"px"),A!==null&&A.setSize(t.width,t.height),this.setViewport(0,0,E,U)},this.getDrawingBufferSize=function(E){return E.set(Y*ne,re*ne).floor()},this.setDrawingBufferSize=function(E,U,q){Y=E,re=U,ne=q,t.width=Math.floor(E*q),t.height=Math.floor(U*q),this.setViewport(0,0,E,U)},this.setEffects=function(E){if(v===nn){Be("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(E){for(let U=0;U<E.length;U++)if(E[U].isOutputPass===!0){Te("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(E||[])},this.getCurrentViewport=function(E){return E.copy(ie)},this.getViewport=function(E){return E.copy(Ne)},this.setViewport=function(E,U,q,B){E.isVector4?Ne.set(E.x,E.y,E.z,E.w):Ne.set(E,U,q,B),y.viewport(ie.copy(Ne).multiplyScalar(ne).round())},this.getScissor=function(E){return E.copy(Ce)},this.setScissor=function(E,U,q,B){E.isVector4?Ce.set(E.x,E.y,E.z,E.w):Ce.set(E,U,q,B),y.scissor(oe.copy(Ce).multiplyScalar(ne).round())},this.getScissorTest=function(){return ye},this.setScissorTest=function(E){y.setScissorTest(ye=E)},this.setOpaqueSort=function(E){H=E},this.setTransparentSort=function(E){Ae=E},this.getClearColor=function(E){return E.copy(Ke.getClearColor())},this.setClearColor=function(){Ke.setClearColor(...arguments)},this.getClearAlpha=function(){return Ke.getClearAlpha()},this.setClearAlpha=function(){Ke.setClearAlpha(...arguments)},this.clear=function(E=!0,U=!0,q=!0){let B=0;if(E){let G=!1;if(K!==null){const ge=K.texture.format;G=m.has(ge)}if(G){const ge=K.texture.type,_e=g.has(ge),me=Ke.getClearColor(),be=Ke.getClearAlpha(),Pe=me.r,$e=me.g,Je=me.b;_e?(_[0]=Pe,_[1]=$e,_[2]=Je,_[3]=be,O.clearBufferuiv(O.COLOR,0,_)):(w[0]=Pe,w[1]=$e,w[2]=Je,w[3]=be,O.clearBufferiv(O.COLOR,0,w))}else B|=O.COLOR_BUFFER_BIT}U&&(B|=O.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),q&&(B|=O.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B!==0&&O.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(E){E.setRenderer(this),P=E},this.dispose=function(){t.removeEventListener("webglcontextlost",Gt,!1),t.removeEventListener("webglcontextrestored",At,!1),t.removeEventListener("webglcontextcreationerror",Pn,!1),Ke.dispose(),fe.dispose(),ue.dispose(),W.dispose(),ae.dispose(),Q.dispose(),ve.dispose(),te.dispose(),he.dispose(),Se.dispose(),Se.removeEventListener("sessionstart",g0),Se.removeEventListener("sessionend",v0),Zs.stop()};function Gt(E){E.preventDefault(),il("WebGLRenderer: Context Lost."),C=!0}function At(){il("WebGLRenderer: Context Restored."),C=!1;const E=F.autoReset,U=He.enabled,q=He.autoUpdate,B=He.needsUpdate,G=He.type;Re(),F.autoReset=E,He.enabled=U,He.autoUpdate=q,He.needsUpdate=B,He.type=G}function Pn(E){Be("WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function Ln(E){const U=E.target;U.removeEventListener("dispose",Ln),M1(U)}function M1(E){x1(E),W.remove(E)}function x1(E){const U=W.get(E).programs;U!==void 0&&(U.forEach(function(q){he.releaseProgram(q)}),E.isShaderMaterial&&he.releaseShaderCache(E))}this.renderBufferDirect=function(E,U,q,B,G,ge){U===null&&(U=Lt);const _e=G.isMesh&&G.matrixWorld.determinantAffine()<0,me=S1(E,U,q,B,G);y.setMaterial(B,_e);let be=q.index,Pe=1;if(B.wireframe===!0){if(be=Z.getWireframeAttribute(q),be===void 0)return;Pe=2}const $e=q.drawRange,Je=q.attributes.position;let Le=$e.start*Pe,yt=($e.start+$e.count)*Pe;ge!==null&&(Le=Math.max(Le,ge.start*Pe),yt=Math.min(yt,(ge.start+ge.count)*Pe)),be!==null?(Le=Math.max(Le,0),yt=Math.min(yt,be.count)):Je!=null&&(Le=Math.max(Le,0),yt=Math.min(yt,Je.count));const Kt=yt-Le;if(Kt<0||Kt===1/0)return;ve.setup(G,B,me,q,be);let Vt,bt=ce;if(be!==null&&(Vt=le.get(be),bt=j,bt.setIndex(Vt)),G.isMesh)B.wireframe===!0?(y.setLineWidth(B.wireframeLinewidth*ei()),bt.setMode(O.LINES)):bt.setMode(O.TRIANGLES);else if(G.isLine){let wi=B.linewidth;wi===void 0&&(wi=1),y.setLineWidth(wi*ei()),G.isLineSegments?bt.setMode(O.LINES):G.isLineLoop?bt.setMode(O.LINE_LOOP):bt.setMode(O.LINE_STRIP)}else G.isPoints?bt.setMode(O.POINTS):G.isSprite&&bt.setMode(O.TRIANGLES);if(G.isBatchedMesh)if(mt.get("WEBGL_multi_draw"))bt.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else{const wi=G._multiDrawStarts,Me=G._multiDrawCounts,Xi=G._multiDrawCount,rt=be?le.get(be).bytesPerElement:1,an=W.get(B).currentProgram.getUniforms();for(let Nn=0;Nn<Xi;Nn++)an.setValue(O,"_gl_DrawID",Nn),bt.render(wi[Nn]/rt,Me[Nn])}else if(G.isInstancedMesh)bt.renderInstances(Le,Kt,G.count);else if(q.isInstancedBufferGeometry){const wi=q._maxInstanceCount!==void 0?q._maxInstanceCount:1/0,Me=Math.min(q.instanceCount,wi);bt.renderInstances(Le,Kt,Me)}else bt.render(Le,Kt)};function m0(E,U,q){E.transparent===!0&&E.side===tn&&E.forceSinglePass===!1?(E.side=Ot,E.needsUpdate=!0,Io(E,U,q),E.side=qs,E.needsUpdate=!0,Io(E,U,q),E.side=tn):Io(E,U,q)}this.compile=function(E,U,q=null){q===null&&(q=E),b=ue.get(q),b.init(U),x.push(b),q.traverseVisible(function(G){G.isLight&&G.layers.test(U.layers)&&(b.pushLight(G),G.castShadow&&b.pushShadow(G))}),E!==q&&E.traverseVisible(function(G){G.isLight&&G.layers.test(U.layers)&&(b.pushLight(G),G.castShadow&&b.pushShadow(G))}),b.setupLights();const B=new Set;return E.traverse(function(G){if(!(G.isMesh||G.isPoints||G.isLine||G.isSprite))return;const ge=G.material;if(ge)if(Array.isArray(ge))for(let _e=0;_e<ge.length;_e++){const me=ge[_e];m0(me,q,G),B.add(me)}else m0(ge,q,G),B.add(ge)}),b=x.pop(),B},this.compileAsync=function(E,U,q=null){const B=this.compile(E,U,q);return new Promise(G=>{function ge(){if(B.forEach(function(_e){W.get(_e).currentProgram.isReady()&&B.delete(_e)}),B.size===0){G(E);return}setTimeout(ge,10)}mt.get("KHR_parallel_shader_compile")!==null?ge():setTimeout(ge,10)})};let Pl=null;function y1(E){Pl&&Pl(E)}function g0(){Zs.stop()}function v0(){Zs.start()}const Zs=new Tg;Zs.setAnimationLoop(y1),typeof self<"u"&&Zs.setContext(self),this.setAnimationLoop=function(E){Pl=E,Se.setAnimationLoop(E),E===null?Zs.stop():Zs.start()},Se.addEventListener("sessionstart",g0),Se.addEventListener("sessionend",v0),this.render=function(E,U){if(U!==void 0&&U.isCamera!==!0){Be("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;P!==null&&P.renderStart(E,U);const q=Se.enabled===!0&&Se.isPresenting===!0,B=A!==null&&(K===null||q)&&A.begin(I,K);if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),Se.enabled===!0&&Se.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(Se.cameraAutoUpdate===!0&&Se.updateCamera(U),U=Se.getCamera()),E.isScene===!0&&E.onBeforeRender(I,E,U,K),b=ue.get(E,x.length),b.init(U),b.state.textureUnits=$.getTextureUnits(),x.push(b),ft.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Fe.setFromProjectionMatrix(ft,Kn,U.reversedDepth),ze=this.localClippingEnabled,ke=Ue.init(this.clippingPlanes,ze),S=fe.get(E,T.length),S.init(),T.push(S),Se.enabled===!0&&Se.isPresenting===!0){const _e=I.xr.getDepthSensingMesh();_e!==null&&Ll(_e,U,-1/0,I.sortObjects)}Ll(E,U,0,I.sortObjects),S.finish(),I.sortObjects===!0&&S.sort(H,Ae,U.reversedDepth),Bt=Se.enabled===!1||Se.isPresenting===!1||Se.hasDepthSensing()===!1,Bt&&Ke.addToRenderList(S,E),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),ke===!0&&Ue.beginShadows();const G=b.state.shadowsArray;if(He.render(G,E,U),ke===!0&&Ue.endShadows(),(B&&A.hasRenderPass())===!1){const _e=S.opaque,me=S.transmissive;if(b.setupLights(),U.isArrayCamera){const be=U.cameras;if(me.length>0)for(let Pe=0,$e=be.length;Pe<$e;Pe++){const Je=be[Pe];x0(_e,me,E,Je)}Bt&&Ke.render(E);for(let Pe=0,$e=be.length;Pe<$e;Pe++){const Je=be[Pe];M0(S,E,Je,Je.viewport)}}else me.length>0&&x0(_e,me,E,U),Bt&&Ke.render(E),M0(S,E,U)}K!==null&&k===0&&($.updateMultisampleRenderTarget(K),$.updateRenderTargetMipmap(K)),B&&A.end(I),E.isScene===!0&&E.onAfterRender(I,E,U),ve.resetDefaultState(),ee=-1,J=null,x.pop(),x.length>0?(b=x[x.length-1],$.setTextureUnits(b.state.textureUnits),ke===!0&&Ue.setGlobalState(I.clippingPlanes,b.state.camera)):b=null,T.pop(),T.length>0?S=T[T.length-1]:S=null,P!==null&&P.renderEnd()};function Ll(E,U,q,B){if(E.visible===!1)return;if(E.layers.test(U.layers)){if(E.isGroup)q=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(U);else if(E.isLightProbeGrid)b.pushLightProbeGrid(E);else if(E.isLight)b.pushLight(E),E.castShadow&&b.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||Fe.intersectsSprite(E)){B&&Ht.setFromMatrixPosition(E.matrixWorld).applyMatrix4(ft);const _e=Q.update(E),me=E.material;me.visible&&S.push(E,_e,me,q,Ht.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||Fe.intersectsObject(E))){const _e=Q.update(E),me=E.material;if(B&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),Ht.copy(E.boundingSphere.center)):(_e.boundingSphere===null&&_e.computeBoundingSphere(),Ht.copy(_e.boundingSphere.center)),Ht.applyMatrix4(E.matrixWorld).applyMatrix4(ft)),Array.isArray(me)){const be=_e.groups;for(let Pe=0,$e=be.length;Pe<$e;Pe++){const Je=be[Pe],Le=me[Je.materialIndex];Le&&Le.visible&&S.push(E,_e,Le,q,Ht.z,Je)}}else me.visible&&S.push(E,_e,me,q,Ht.z,null)}}const ge=E.children;for(let _e=0,me=ge.length;_e<me;_e++)Ll(ge[_e],U,q,B)}function M0(E,U,q,B){const{opaque:G,transmissive:ge,transparent:_e}=E;b.setupLightsView(q),ke===!0&&Ue.setGlobalState(I.clippingPlanes,q),B&&y.viewport(ie.copy(B)),G.length>0&&Co(G,U,q),ge.length>0&&Co(ge,U,q),_e.length>0&&Co(_e,U,q),y.buffers.depth.setTest(!0),y.buffers.depth.setMask(!0),y.buffers.color.setMask(!0),y.setPolygonOffset(!1)}function x0(E,U,q,B){if((q.isScene===!0?q.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[B.id]===void 0){const Le=mt.has("EXT_color_buffer_half_float")||mt.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[B.id]=new jt(1,1,{generateMipmaps:!0,type:Le?kt:nn,minFilter:da,samples:Math.max(4,R.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:nt.workingColorSpace})}const ge=b.state.transmissionRenderTarget[B.id],_e=B.viewport||ie;ge.setSize(_e.z*I.transmissionResolutionScale,_e.w*I.transmissionResolutionScale);const me=I.getRenderTarget(),be=I.getActiveCubeFace(),Pe=I.getActiveMipmapLevel();I.setRenderTarget(ge),I.getClearColor(Qe),qe=I.getClearAlpha(),qe<1&&I.setClearColor(16777215,.5),I.clear(),Bt&&Ke.render(q);const $e=I.toneMapping;I.toneMapping=Jn;const Je=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),b.setupLightsView(B),ke===!0&&Ue.setGlobalState(I.clippingPlanes,B),Co(E,q,B),$.updateMultisampleRenderTarget(ge),$.updateRenderTargetMipmap(ge),mt.has("WEBGL_multisampled_render_to_texture")===!1){let Le=!1;for(let yt=0,Kt=U.length;yt<Kt;yt++){const Vt=U[yt],{object:bt,geometry:wi,material:Me,group:Xi}=Vt;if(Me.side===tn&&bt.layers.test(B.layers)){const rt=Me.side;Me.side=Ot,Me.needsUpdate=!0,y0(bt,q,B,wi,Me,Xi),Me.side=rt,Me.needsUpdate=!0,Le=!0}}Le===!0&&($.updateMultisampleRenderTarget(ge),$.updateRenderTargetMipmap(ge))}I.setRenderTarget(me,be,Pe),I.setClearColor(Qe,qe),Je!==void 0&&(B.viewport=Je),I.toneMapping=$e}function Co(E,U,q){const B=U.isScene===!0?U.overrideMaterial:null;for(let G=0,ge=E.length;G<ge;G++){const _e=E[G],{object:me,geometry:be,group:Pe}=_e;let $e=_e.material;$e.allowOverride===!0&&B!==null&&($e=B),me.layers.test(q.layers)&&y0(me,U,q,be,$e,Pe)}}function y0(E,U,q,B,G,ge){E.onBeforeRender(I,U,q,B,G,ge),E.modelViewMatrix.multiplyMatrices(q.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),G.onBeforeRender(I,U,q,B,E,ge),G.transparent===!0&&G.side===tn&&G.forceSinglePass===!1?(G.side=Ot,G.needsUpdate=!0,I.renderBufferDirect(q,U,B,G,E,ge),G.side=qs,G.needsUpdate=!0,I.renderBufferDirect(q,U,B,G,E,ge),G.side=tn):I.renderBufferDirect(q,U,B,G,E,ge),E.onAfterRender(I,U,q,B,G,ge)}function Io(E,U,q){U.isScene!==!0&&(U=Lt);const B=W.get(E),G=b.state.lights,ge=b.state.shadowsArray,_e=G.state.version,me=he.getParameters(E,G.state,ge,U,q,b.state.lightProbeGridArray),be=he.getProgramCacheKey(me);let Pe=B.programs;B.environment=E.isMeshStandardMaterial||E.isMeshLambertMaterial||E.isMeshPhongMaterial?U.environment:null,B.fog=U.fog;const $e=E.isMeshStandardMaterial||E.isMeshLambertMaterial&&!E.envMap||E.isMeshPhongMaterial&&!E.envMap;B.envMap=ae.get(E.envMap||B.environment,$e),B.envMapRotation=B.environment!==null&&E.envMap===null?U.environmentRotation:E.envMapRotation,Pe===void 0&&(E.addEventListener("dispose",Ln),Pe=new Map,B.programs=Pe);let Je=Pe.get(be);if(Je!==void 0){if(B.currentProgram===Je&&B.lightsStateVersion===_e)return S0(E,me),Je}else me.uniforms=he.getUniforms(E),P!==null&&E.isNodeMaterial&&P.build(E,q,me),E.onBeforeCompile(me,I),Je=he.acquireProgram(me,be),Pe.set(be,Je),B.uniforms=me.uniforms;const Le=B.uniforms;return(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(Le.clippingPlanes=Ue.uniform),S0(E,me),B.needsLights=b1(E),B.lightsStateVersion=_e,B.needsLights&&(Le.ambientLightColor.value=G.state.ambient,Le.lightProbe.value=G.state.probe,Le.directionalLights.value=G.state.directional,Le.directionalLightShadows.value=G.state.directionalShadow,Le.spotLights.value=G.state.spot,Le.spotLightShadows.value=G.state.spotShadow,Le.rectAreaLights.value=G.state.rectArea,Le.ltc_1.value=G.state.rectAreaLTC1,Le.ltc_2.value=G.state.rectAreaLTC2,Le.pointLights.value=G.state.point,Le.pointLightShadows.value=G.state.pointShadow,Le.hemisphereLights.value=G.state.hemi,Le.directionalShadowMatrix.value=G.state.directionalShadowMatrix,Le.spotLightMatrix.value=G.state.spotLightMatrix,Le.spotLightMap.value=G.state.spotLightMap,Le.pointShadowMatrix.value=G.state.pointShadowMatrix),B.lightProbeGrid=b.state.lightProbeGridArray.length>0,B.currentProgram=Je,B.uniformsList=null,Je}function _0(E){if(E.uniformsList===null){const U=E.currentProgram.getUniforms();E.uniformsList=Bc.seqWithValue(U.seq,E.uniforms)}return E.uniformsList}function S0(E,U){const q=W.get(E);q.outputColorSpace=U.outputColorSpace,q.batching=U.batching,q.batchingColor=U.batchingColor,q.instancing=U.instancing,q.instancingColor=U.instancingColor,q.instancingMorph=U.instancingMorph,q.skinning=U.skinning,q.morphTargets=U.morphTargets,q.morphNormals=U.morphNormals,q.morphColors=U.morphColors,q.morphTargetsCount=U.morphTargetsCount,q.numClippingPlanes=U.numClippingPlanes,q.numIntersection=U.numClipIntersection,q.vertexAlphas=U.vertexAlphas,q.vertexTangents=U.vertexTangents,q.toneMapping=U.toneMapping}function _1(E,U){if(E.length===0)return null;if(E.length===1)return E[0].texture!==null?E[0]:null;M.setFromMatrixPosition(U.matrixWorld);for(let q=0,B=E.length;q<B;q++){const G=E[q];if(G.texture!==null&&G.boundingBox.containsPoint(M))return G}return null}function S1(E,U,q,B,G){U.isScene!==!0&&(U=Lt),$.resetTextureUnits();const ge=U.fog,_e=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?U.environment:null,me=K===null?I.outputColorSpace:K.isXRRenderTarget===!0?K.texture.colorSpace:nt.workingColorSpace,be=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Pe=ae.get(B.envMap||_e,be),$e=B.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,Je=!!q.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Le=!!q.morphAttributes.position,yt=!!q.morphAttributes.normal,Kt=!!q.morphAttributes.color;let Vt=Jn;B.toneMapped&&(K===null||K.isXRRenderTarget===!0)&&(Vt=I.toneMapping);const bt=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,wi=bt!==void 0?bt.length:0,Me=W.get(B),Xi=b.state.lights;if(ke===!0&&(ze===!0||E!==J)){const Tt=E===J&&B.id===ee;Ue.setState(B,E,Tt)}let rt=!1;B.version===Me.__version?(Me.needsLights&&Me.lightsStateVersion!==Xi.state.version||Me.outputColorSpace!==me||G.isBatchedMesh&&Me.batching===!1||!G.isBatchedMesh&&Me.batching===!0||G.isBatchedMesh&&Me.batchingColor===!0&&G.colorTexture===null||G.isBatchedMesh&&Me.batchingColor===!1&&G.colorTexture!==null||G.isInstancedMesh&&Me.instancing===!1||!G.isInstancedMesh&&Me.instancing===!0||G.isSkinnedMesh&&Me.skinning===!1||!G.isSkinnedMesh&&Me.skinning===!0||G.isInstancedMesh&&Me.instancingColor===!0&&G.instanceColor===null||G.isInstancedMesh&&Me.instancingColor===!1&&G.instanceColor!==null||G.isInstancedMesh&&Me.instancingMorph===!0&&G.morphTexture===null||G.isInstancedMesh&&Me.instancingMorph===!1&&G.morphTexture!==null||Me.envMap!==Pe||B.fog===!0&&Me.fog!==ge||Me.numClippingPlanes!==void 0&&(Me.numClippingPlanes!==Ue.numPlanes||Me.numIntersection!==Ue.numIntersection)||Me.vertexAlphas!==$e||Me.vertexTangents!==Je||Me.morphTargets!==Le||Me.morphNormals!==yt||Me.morphColors!==Kt||Me.toneMapping!==Vt||Me.morphTargetsCount!==wi||!!Me.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(rt=!0):(rt=!0,Me.__version=B.version);let an=Me.currentProgram;rt===!0&&(an=Io(B,U,G),P&&B.isNodeMaterial&&P.onUpdateProgram(B,an,Me));let Nn=!1,ws=!1,Ea=!1;const Et=an.getUniforms(),$t=Me.uniforms;if(y.useProgram(an.program)&&(Nn=!0,ws=!0,Ea=!0),B.id!==ee&&(ee=B.id,ws=!0),Me.needsLights){const Tt=_1(b.state.lightProbeGridArray,G);Me.lightProbeGrid!==Tt&&(Me.lightProbeGrid=Tt,ws=!0)}if(Nn||J!==E){y.buffers.depth.getReversed()&&E.reversedDepth!==!0&&(E._reversedDepth=!0,E.updateProjectionMatrix()),Et.setValue(O,"projectionMatrix",E.projectionMatrix),Et.setValue(O,"viewMatrix",E.matrixWorldInverse);const Es=Et.map.cameraPosition;Es!==void 0&&Es.setValue(O,pt.setFromMatrixPosition(E.matrixWorld)),R.logarithmicDepthBuffer&&Et.setValue(O,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&Et.setValue(O,"isOrthographic",E.isOrthographicCamera===!0),J!==E&&(J=E,ws=!0,Ea=!0)}if(Me.needsLights&&(Xi.state.directionalShadowMap.length>0&&Et.setValue(O,"directionalShadowMap",Xi.state.directionalShadowMap,$),Xi.state.spotShadowMap.length>0&&Et.setValue(O,"spotShadowMap",Xi.state.spotShadowMap,$),Xi.state.pointShadowMap.length>0&&Et.setValue(O,"pointShadowMap",Xi.state.pointShadowMap,$)),G.isSkinnedMesh){Et.setOptional(O,G,"bindMatrix"),Et.setOptional(O,G,"bindMatrixInverse");const Tt=G.skeleton;Tt&&(Tt.boneTexture===null&&Tt.computeBoneTexture(),Et.setValue(O,"boneTexture",Tt.boneTexture,$))}G.isBatchedMesh&&(Et.setOptional(O,G,"batchingTexture"),Et.setValue(O,"batchingTexture",G._matricesTexture,$),Et.setOptional(O,G,"batchingIdTexture"),Et.setValue(O,"batchingIdTexture",G._indirectTexture,$),Et.setOptional(O,G,"batchingColorTexture"),G._colorsTexture!==null&&Et.setValue(O,"batchingColorTexture",G._colorsTexture,$));const bs=q.morphAttributes;if((bs.position!==void 0||bs.normal!==void 0||bs.color!==void 0)&&L.update(G,q,an),(ws||Me.receiveShadow!==G.receiveShadow)&&(Me.receiveShadow=G.receiveShadow,Et.setValue(O,"receiveShadow",G.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&U.environment!==null&&($t.envMapIntensity.value=U.environmentIntensity),$t.dfgLUT!==void 0&&($t.dfgLUT.value=NS()),ws){if(Et.setValue(O,"toneMappingExposure",I.toneMappingExposure),Me.needsLights&&w1($t,Ea),ge&&B.fog===!0&&Ie.refreshFogUniforms($t,ge),Ie.refreshMaterialUniforms($t,B,ne,re,b.state.transmissionRenderTarget[E.id]),Me.needsLights&&Me.lightProbeGrid){const Tt=Me.lightProbeGrid;$t.probesSH.value=Tt.texture,$t.probesMin.value.copy(Tt.boundingBox.min),$t.probesMax.value.copy(Tt.boundingBox.max),$t.probesResolution.value.copy(Tt.resolution)}Bc.upload(O,_0(Me),$t,$)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(Bc.upload(O,_0(Me),$t,$),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&Et.setValue(O,"center",G.center),Et.setValue(O,"modelViewMatrix",G.modelViewMatrix),Et.setValue(O,"normalMatrix",G.normalMatrix),Et.setValue(O,"modelMatrix",G.matrixWorld),B.uniformsGroups!==void 0){const Tt=B.uniformsGroups;for(let Es=0,Aa=Tt.length;Es<Aa;Es++){const w0=Tt[Es];te.update(w0,an),te.bind(w0,an)}}return an}function w1(E,U){E.ambientLightColor.needsUpdate=U,E.lightProbe.needsUpdate=U,E.directionalLights.needsUpdate=U,E.directionalLightShadows.needsUpdate=U,E.pointLights.needsUpdate=U,E.pointLightShadows.needsUpdate=U,E.spotLights.needsUpdate=U,E.spotLightShadows.needsUpdate=U,E.rectAreaLights.needsUpdate=U,E.hemisphereLights.needsUpdate=U}function b1(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return V},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return K},this.setRenderTargetTextures=function(E,U,q){const B=W.get(E);B.__autoAllocateDepthBuffer=E.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),W.get(E.texture).__webglTexture=U,W.get(E.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:q,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(E,U){const q=W.get(E);q.__webglFramebuffer=U,q.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(E,U=0,q=0){K=E,V=U,k=q;let B=null,G=!1,ge=!1;if(E){const me=W.get(E);if(me.__useDefaultFramebuffer!==void 0){y.bindFramebuffer(O.FRAMEBUFFER,me.__webglFramebuffer),ie.copy(E.viewport),oe.copy(E.scissor),Ve=E.scissorTest,y.viewport(ie),y.scissor(oe),y.setScissorTest(Ve),ee=-1;return}else if(me.__webglFramebuffer===void 0)$.setupRenderTarget(E);else if(me.__hasExternalTextures)$.rebindTextures(E,W.get(E.texture).__webglTexture,W.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){const $e=E.depthTexture;if(me.__boundDepthTexture!==$e){if($e!==null&&W.has($e)&&(E.width!==$e.image.width||E.height!==$e.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");$.setupDepthRenderbuffer(E)}}const be=E.texture;(be.isData3DTexture||be.isDataArrayTexture||be.isCompressedArrayTexture)&&(ge=!0);const Pe=W.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(Pe[U])?B=Pe[U][q]:B=Pe[U],G=!0):E.samples>0&&$.useMultisampledRTT(E)===!1?B=W.get(E).__webglMultisampledFramebuffer:Array.isArray(Pe)?B=Pe[q]:B=Pe,ie.copy(E.viewport),oe.copy(E.scissor),Ve=E.scissorTest}else ie.copy(Ne).multiplyScalar(ne).floor(),oe.copy(Ce).multiplyScalar(ne).floor(),Ve=ye;if(q!==0&&(B=X),y.bindFramebuffer(O.FRAMEBUFFER,B)&&y.drawBuffers(E,B),y.viewport(ie),y.scissor(oe),y.setScissorTest(Ve),G){const me=W.get(E.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_CUBE_MAP_POSITIVE_X+U,me.__webglTexture,q)}else if(ge){const me=U;for(let be=0;be<E.textures.length;be++){const Pe=W.get(E.textures[be]);O.framebufferTextureLayer(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0+be,Pe.__webglTexture,q,me)}}else if(E!==null&&q!==0){const me=W.get(E.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,me.__webglTexture,q)}ee=-1},this.readRenderTargetPixels=function(E,U,q,B,G,ge,_e,me=0){if(!(E&&E.isWebGLRenderTarget)){Be("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let be=W.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&_e!==void 0&&(be=be[_e]),be){y.bindFramebuffer(O.FRAMEBUFFER,be);try{const Pe=E.textures[me],$e=Pe.format,Je=Pe.type;if(E.textures.length>1&&O.readBuffer(O.COLOR_ATTACHMENT0+me),!R.textureFormatReadable($e)){Be("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!R.textureTypeReadable(Je)){Be("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=E.width-B&&q>=0&&q<=E.height-G&&O.readPixels(U,q,B,G,de.convert($e),de.convert(Je),ge)}finally{const Pe=K!==null?W.get(K).__webglFramebuffer:null;y.bindFramebuffer(O.FRAMEBUFFER,Pe)}}},this.readRenderTargetPixelsAsync=async function(E,U,q,B,G,ge,_e,me=0){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let be=W.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&_e!==void 0&&(be=be[_e]),be)if(U>=0&&U<=E.width-B&&q>=0&&q<=E.height-G){y.bindFramebuffer(O.FRAMEBUFFER,be);const Pe=E.textures[me],$e=Pe.format,Je=Pe.type;if(E.textures.length>1&&O.readBuffer(O.COLOR_ATTACHMENT0+me),!R.textureFormatReadable($e))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!R.textureTypeReadable(Je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Le=O.createBuffer();O.bindBuffer(O.PIXEL_PACK_BUFFER,Le),O.bufferData(O.PIXEL_PACK_BUFFER,ge.byteLength,O.STREAM_READ),O.readPixels(U,q,B,G,de.convert($e),de.convert(Je),0);const yt=K!==null?W.get(K).__webglFramebuffer:null;y.bindFramebuffer(O.FRAMEBUFFER,yt);const Kt=O.fenceSync(O.SYNC_GPU_COMMANDS_COMPLETE,0);return O.flush(),await dv(O,Kt,4),O.bindBuffer(O.PIXEL_PACK_BUFFER,Le),O.getBufferSubData(O.PIXEL_PACK_BUFFER,0,ge),O.deleteBuffer(Le),O.deleteSync(Kt),ge}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(E,U=null,q=0){const B=Math.pow(2,-q),G=Math.floor(E.image.width*B),ge=Math.floor(E.image.height*B),_e=U!==null?U.x:0,me=U!==null?U.y:0;$.setTexture2D(E,0),O.copyTexSubImage2D(O.TEXTURE_2D,q,0,0,_e,me,G,ge),y.unbindTexture()},this.copyTextureToTexture=function(E,U,q=null,B=null,G=0,ge=0){let _e,me,be,Pe,$e,Je,Le,yt,Kt;const Vt=E.isCompressedTexture?E.mipmaps[ge]:E.image;if(q!==null)_e=q.max.x-q.min.x,me=q.max.y-q.min.y,be=q.isBox3?q.max.z-q.min.z:1,Pe=q.min.x,$e=q.min.y,Je=q.isBox3?q.min.z:0;else{const $t=Math.pow(2,-G);_e=Math.floor(Vt.width*$t),me=Math.floor(Vt.height*$t),E.isDataArrayTexture?be=Vt.depth:E.isData3DTexture?be=Math.floor(Vt.depth*$t):be=1,Pe=0,$e=0,Je=0}B!==null?(Le=B.x,yt=B.y,Kt=B.z):(Le=0,yt=0,Kt=0);const bt=de.convert(U.format),wi=de.convert(U.type);let Me;U.isData3DTexture?($.setTexture3D(U,0),Me=O.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?($.setTexture2DArray(U,0),Me=O.TEXTURE_2D_ARRAY):($.setTexture2D(U,0),Me=O.TEXTURE_2D),y.activeTexture(O.TEXTURE0),y.pixelStorei(O.UNPACK_FLIP_Y_WEBGL,U.flipY),y.pixelStorei(O.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),y.pixelStorei(O.UNPACK_ALIGNMENT,U.unpackAlignment);const Xi=y.getParameter(O.UNPACK_ROW_LENGTH),rt=y.getParameter(O.UNPACK_IMAGE_HEIGHT),an=y.getParameter(O.UNPACK_SKIP_PIXELS),Nn=y.getParameter(O.UNPACK_SKIP_ROWS),ws=y.getParameter(O.UNPACK_SKIP_IMAGES);y.pixelStorei(O.UNPACK_ROW_LENGTH,Vt.width),y.pixelStorei(O.UNPACK_IMAGE_HEIGHT,Vt.height),y.pixelStorei(O.UNPACK_SKIP_PIXELS,Pe),y.pixelStorei(O.UNPACK_SKIP_ROWS,$e),y.pixelStorei(O.UNPACK_SKIP_IMAGES,Je);const Ea=E.isDataArrayTexture||E.isData3DTexture,Et=U.isDataArrayTexture||U.isData3DTexture;if(E.isDepthTexture){const $t=W.get(E),bs=W.get(U),Tt=W.get($t.__renderTarget),Es=W.get(bs.__renderTarget);y.bindFramebuffer(O.READ_FRAMEBUFFER,Tt.__webglFramebuffer),y.bindFramebuffer(O.DRAW_FRAMEBUFFER,Es.__webglFramebuffer);for(let Aa=0;Aa<be;Aa++)Ea&&(O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,W.get(E).__webglTexture,G,Je+Aa),O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,W.get(U).__webglTexture,ge,Kt+Aa)),O.blitFramebuffer(Pe,$e,_e,me,Le,yt,_e,me,O.DEPTH_BUFFER_BIT,O.NEAREST);y.bindFramebuffer(O.READ_FRAMEBUFFER,null),y.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else if(G!==0||E.isRenderTargetTexture||W.has(E)){const $t=W.get(E),bs=W.get(U);y.bindFramebuffer(O.READ_FRAMEBUFFER,z),y.bindFramebuffer(O.DRAW_FRAMEBUFFER,N);for(let Tt=0;Tt<be;Tt++)Ea?O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,$t.__webglTexture,G,Je+Tt):O.framebufferTexture2D(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,$t.__webglTexture,G),Et?O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,bs.__webglTexture,ge,Kt+Tt):O.framebufferTexture2D(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,bs.__webglTexture,ge),G!==0?O.blitFramebuffer(Pe,$e,_e,me,Le,yt,_e,me,O.COLOR_BUFFER_BIT,O.NEAREST):Et?O.copyTexSubImage3D(Me,ge,Le,yt,Kt+Tt,Pe,$e,_e,me):O.copyTexSubImage2D(Me,ge,Le,yt,Pe,$e,_e,me);y.bindFramebuffer(O.READ_FRAMEBUFFER,null),y.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else Et?E.isDataTexture||E.isData3DTexture?O.texSubImage3D(Me,ge,Le,yt,Kt,_e,me,be,bt,wi,Vt.data):U.isCompressedArrayTexture?O.compressedTexSubImage3D(Me,ge,Le,yt,Kt,_e,me,be,bt,Vt.data):O.texSubImage3D(Me,ge,Le,yt,Kt,_e,me,be,bt,wi,Vt):E.isDataTexture?O.texSubImage2D(O.TEXTURE_2D,ge,Le,yt,_e,me,bt,wi,Vt.data):E.isCompressedTexture?O.compressedTexSubImage2D(O.TEXTURE_2D,ge,Le,yt,Vt.width,Vt.height,bt,Vt.data):O.texSubImage2D(O.TEXTURE_2D,ge,Le,yt,_e,me,bt,wi,Vt);y.pixelStorei(O.UNPACK_ROW_LENGTH,Xi),y.pixelStorei(O.UNPACK_IMAGE_HEIGHT,rt),y.pixelStorei(O.UNPACK_SKIP_PIXELS,an),y.pixelStorei(O.UNPACK_SKIP_ROWS,Nn),y.pixelStorei(O.UNPACK_SKIP_IMAGES,ws),ge===0&&U.generateMipmaps&&O.generateMipmap(Me),y.unbindTexture()},this.initRenderTarget=function(E){W.get(E).__webglFramebuffer===void 0&&$.setupRenderTarget(E)},this.initTexture=function(E){E.isCubeTexture?$.setTextureCube(E,0):E.isData3DTexture?$.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?$.setTexture2DArray(E,0):$.setTexture2D(E,0),y.unbindTexture()},this.resetState=function(){V=0,k=0,K=null,y.reset(),ve.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Kn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=nt._getDrawingBufferColorSpace(e),t.unpackColorSpace=nt._getUnpackColorSpace()}}const US=`
|
|
4743
4743
|
varying vec3 vDir;
|
|
4744
4744
|
varying vec3 vWorldDir;
|
|
4745
4745
|
|
|
@@ -5048,7 +5048,7 @@ void main() {
|
|
|
5048
5048
|
// what is behind: exactly what the display drawn first and the deck laid over it gave.
|
|
5049
5049
|
gl_FragColor = uPremultiplied > 0.5 ? vec4(color * alpha + halo * (1.0 - alpha), alpha) : vec4(color, alpha);
|
|
5050
5050
|
}
|
|
5051
|
-
`;function Zu(a,e,t,i=0){const n={sunDir:{value:new D(0,1,0)},sunColor:{value:new se(1,1,1)},ambientColor:{value:new se(.5,.5,.5)},baseColor:{value:a},coverage:{value:e},opticalDensity:{value:1},darkness:{value:0},layerHeight:{value:t},fieldOffset:{value:new D},fibrous:{value:i},uHaloShown:{value:0},uPremultiplied:{value:0},uSource:{value:new D(0,1,0)},uUp:{value:new D(0,1,0)},uStrength:{value:0},uTint:{value:new D(1,1,1)},uMap:{value:null},uGain:{value:0}};return{material:new at({uniforms:n,vertexShader:US,fragmentShader:FS,transparent:!0,depthWrite:!1,depthTest:!0,side:Ot}),uniforms:n}}function Ju(a){return new
|
|
5051
|
+
`;function Zu(a,e,t,i=0){const n={sunDir:{value:new D(0,1,0)},sunColor:{value:new se(1,1,1)},ambientColor:{value:new se(.5,.5,.5)},baseColor:{value:a},coverage:{value:e},opticalDensity:{value:1},darkness:{value:0},layerHeight:{value:t},fieldOffset:{value:new D},fibrous:{value:i},uHaloShown:{value:0},uPremultiplied:{value:0},uSource:{value:new D(0,1,0)},uUp:{value:new D(0,1,0)},uStrength:{value:0},uTint:{value:new D(1,1,1)},uMap:{value:null},uGain:{value:0}};return{material:new at({uniforms:n,vertexShader:US,fragmentShader:FS,transparent:!0,depthWrite:!1,depthTest:!0,side:Ot}),uniforms:n}}function Ju(a){return new Qt(a,48,24,0,Math.PI*2,0,Math.PI/2)}class ht{static OCTAVES=4;static GAIN=.55;static LACUNARITY=2.03;static fract(e){return e-Math.floor(e)}static hash3(e,t,i){const n=e*127.1+t*311.7+i*74.7,s=e*269.5+t*183.3+i*246.1,r=e*113.5+t*271.9+i*124.6;return[ht.fract(Math.sin(n)*43758.5453)*2-1,ht.fract(Math.sin(s)*43758.5453)*2-1,ht.fract(Math.sin(r)*43758.5453)*2-1]}static noise3D(e,t,i){const n=Math.floor(e),s=Math.floor(t),r=Math.floor(i),o=e-n,c=t-s,l=i-r,h=o*o*(3-2*o),u=c*c*(3-2*c),d=l*l*(3-2*l),f=(v,m,g)=>{const[_,w,M]=ht.hash3(n+v,s+m,r+g);return _*(o-v)+w*(c-m)+M*(l-g)},p=(v,m,g)=>v+(m-v)*g;return p(p(p(f(0,0,0),f(1,0,0),h),p(f(0,1,0),f(1,1,0),h),u),p(p(f(0,0,1),f(1,0,1),h),p(f(0,1,1),f(1,1,1),h),u),d)}static thresholdFor(e,t,i){const n=Math.min(.999,Math.max(.001,e));return t-i*(Math.sqrt(3)/Math.PI)*Math.log(n/(1-n))}static fbm(e,t,i){let n=0,s=ht.GAIN;for(let r=0;r<ht.OCTAVES;r++)n+=ht.noise3D(e,t,i)*s,e*=ht.LACUNARITY,t*=ht.LACUNARITY,i*=ht.LACUNARITY,s*=ht.GAIN;return n}static worley(e,t,i){const n=Math.floor(e),s=Math.floor(t),r=Math.floor(i),o=e-n,c=t-s,l=i-r;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[p,v,m]=ht.hash3(n+u,s+d,r+f),g=u+(p*.5+.5)-o,_=d+(v*.5+.5)-c,w=f+(m*.5+.5)-l;h=Math.min(h,g*g+_*_+w*w)}return Math.sqrt(h)}static alphaAt(e,t,i,n={x:0,z:0}){if(i<=0)return 0;const[s,r,o]=ht.warpedAt(e,t,n),c=ht.fbm(s*.014,r*.014,o*.014)*.5+.5,l=1-ht.worley(s*.011,r*.011,o*.011),h=c+(l-c)*.4,u=ht.thresholdFor(i,Og,Qd),d=ht.smoothstep(u-rl,u+rl,h);return d+(1-d)*ht.smoothstep(.82,1,i)}static iceAlphaAt(e,t,i,n={x:0,z:0}){if(i<=0)return 0;const[s,r,o]=ht.warpedAt(e,t,n),c=s*.0016,l=r*.02,h=o*.045,u=ht.fbm(c,l,h)*.5+.5,d=ht.fbm(c*3.1+7,l*3.1+7,h*3.1+7)*.5+.5,f=ht.thresholdFor(i,e0,El);return ht.smoothstep(f-$u,f+$u,u*.72+d*.28)}static warpedAt(e,t,i){const n=Math.abs(e.y),s=t/Math.max(n,.04),r=e.x*s+i.x,o=e.y*s,c=e.z*s+i.z,l=r*.006,h=o*.006,u=c*.006;return[r+ht.fbm(l+12.3,h+12.3,u+12.3)*40,o+ht.fbm(l+47.1,h+47.1,u+47.1)*40,c+ht.fbm(l+91.7,h+91.7,u+91.7)*40]}static smoothstep(e,t,i){const n=Math.min(1,Math.max(0,(i-e)/(t-e)));return n*n*(3-2*n)}}const Bs=6371e3,Jt=64,Br=8,_h=.2787;function ju(a){if(a.seed!==void 0)return a.seed;let e=2166136261;for(const t of a.id)e=Math.imul(e^t.charCodeAt(0),16777619);return e>>>0}function kS(){const a=new Uint8Array(Jt**3),e=(n,s,r,o)=>{let c=Math.imul(n%o+1,374761393)^Math.imul(s%o+1,668265263)^Math.imul(r%o+1,1274126177);return c=Math.imul(c^c>>>13,1274126177),((c^c>>>16)>>>0)/4294967295},t=(n,s,r,o)=>{const c=Math.floor(n),l=Math.floor(s),h=Math.floor(r),u=m=>m*m*(3-2*m),d=u(n-c),f=u(s-l),p=u(r-h);let v=0;for(let m=0;m<2;m++)for(let g=0;g<2;g++)for(let _=0;_<2;_++)v+=e(c+_,l+g,h+m,o)*(_?d:1-d)*(g?f:1-f)*(m?p:1-p);return v};for(let n=0;n<Jt;n++)for(let s=0;s<Jt;s++)for(let r=0;r<Jt;r++){let o=0;for(const[c,l]of[[4,.65],[8,.25],[16,.1]])o+=t(r/Jt*c,s/Jt*c,n/Jt*c,c)*l;a[r+Jt*(s+Jt*n)]=Math.round(o*255)}const i=new ug(a,Jt,Jt,Jt);return i.format=yl,i.minFilter=i.magFilter=st,i.wrapS=i.wrapT=i.wrapR=Mo,i.needsUpdate=!0,i}function zS(a,e,t,i){const n=h=>{const u=(Bs+e)*a,d=(e-h)*(2*Bs+e+h),f=u*u-d;if(f<0)return;const p=-u-(u>=0?1:-1)*Math.sqrt(f),v=p===0?0:d/p;return[Math.min(p,v),Math.max(p,v)]},s=n(t+i);if(!s||s[1]<=0)return;let r=Math.max(0,s[0]),o=s[1];const c=n(t);c&&(r>=c[0]&&r<c[1]?r=c[1]:c[0]>r&&(o=Math.min(o,c[0])));const l=n(0);return l&&l[0]>=0&&(o=Math.min(o,l[0])),o>r?[r,o]:void 0}const HS=`varying vec3 vCloudDirection;
|
|
5052
5052
|
void main() {
|
|
5053
5053
|
vCloudDirection = position;
|
|
5054
5054
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
@@ -5255,7 +5255,7 @@ float transmissionAt(vec3 dir, float distanceM) {
|
|
|
5255
5255
|
if (transmission < 0.015) break;
|
|
5256
5256
|
}
|
|
5257
5257
|
return transmission;
|
|
5258
|
-
}`,i=/\b(noiseMap|sunDir|sunColor|ambientColor|hazeColor|offsetM|seedOffset|localCenter|localSize|localRotation|baseM|thicknessM|eyeM|coverage|sizeM|density|darkness|flatness|SLICE|MAX_HOLES|holeCount|holeCenter|holeSize|holeRotation|R|roots|altitude|coverageThreshold|ellipsoidRadius|clipLocal|densityAt|transmissionAt)\b/g;return(e+t).replace(i,n=>a+n)}class ol{mesh;uniforms;constructor(e,t){this.uniforms={noiseMap:{value:e},sunDir:{value:new D(0,1,0)},sunColor:{value:new se(1,1,1)},ambientColor:{value:new se(.4,.45,.5)},hazeColor:{value:new se(.5,.6,.7)},offsetM:{value:new D},seedOffset:{value:new D},localCenter:{value:new D},localSize:{value:new D},localRotation:{value:0},holeCount:{value:0},holeCenter:{value:Array.from({length:Br},()=>new D)},holeSize:{value:Array.from({length:Br},()=>new D)},holeRotation:{value:new Array(Br).fill(0)},baseM:{value:1e3},thicknessM:{value:650},eyeM:{value:1.6},coverage:{value:.5},sizeM:{value:1400},density:{value:1},darkness:{value:0},flatness:{value:0}};const i=new at({uniforms:this.uniforms,vertexShader:HS,fragmentShader:Qu,transparent:!0,depthWrite:!1,depthTest:!0,side:Ot});this.mesh=new De(new jt(t,32,16),i),this.mesh.frustumCulled=!1}update(e,t,i,n=[]){const s=this.uniforms;s.localSize.value.set(i?.widthM??0,i?.thicknessM??0,i?.depthM??0),s.localCenter.value.set(i?.eastM??0,i?i.baseM+i.thicknessM/2:0,-(i?.northM??0)),s.localRotation.value=(i?.rotationDeg??0)*Math.PI/180,s.holeCount.value=Math.min(Br,n.length),n.slice(0,Br).forEach((o,c)=>{s.holeCenter.value[c].set(o.eastM,o.baseM+o.thicknessM/2,-o.northM),s.holeSize.value[c].set(o.widthM,o.thicknessM,o.depthM),s.holeRotation.value[c]=o.rotationDeg*Math.PI/180}),s.baseM.value=Math.max(0,e.baseM),s.thicknessM.value=Math.max(10,e.thicknessM),s.coverage.value=Math.max(0,Math.min(1,e.coverage)),s.sizeM.value=Math.max(50,e.sizeM),s.density.value=Math.max(0,Math.min(2,e.density)),s.darkness.value=Math.max(0,Math.min(1,e.darkness??0)),s.eyeM.value=Math.max(.1,t),s.flatness.value=e.type==="stratus"?1:e.type==="stratocumulus"?.45:0;const r=ju(e);s.seedOffset.value.set(r%97/97,r%61/61,r%37/37),this.mesh.visible=s.density.value>0&&(i!==void 0||s.coverage.value>0)}static thresholdFor(e){const t=Math.min(.999,Math.max(.001,e));return .564-.2516*(Math.sqrt(3)/Math.PI)*Math.log(t/(1-t))}densityAt(e){const t=this.uniforms,i=(z,N,V)=>{const k=Math.max(0,Math.min(1,(V-z)/(N-z)));return k*k*(3-2*k)},n=(z,N,V)=>z+(N-z)*V,s=t.eyeM.value+e.y,r=2*Bs*s+e.x**2+s**2+e.z**2,o=r/(Math.sqrt(Bs**2+r)+Bs),c=(o-t.baseM.value)/t.thicknessM.value,l=t.localSize.value.x>0;if(c<=0||c>=1||t.coverage.value<=0&&!l)return 0;const h=(z,N,V)=>{const k=e.x+t.offsetM.value.x-z.x,K=e.z+t.offsetM.value.z-z.z,ee=Math.cos(V),J=Math.sin(V);return Math.hypot((ee*k-J*K)/(N.x*.5),(o-z.y)/(N.y*.5),(J*k+ee*K)/(N.z*.5))},u=l?h(t.localCenter.value,t.localSize.value,t.localRotation.value):0;if(u>1.3)return 0;const d=[e.x,e.y,e.z].map((z,N)=>(z+t.offsetM.value.getComponent(N))/(t.sizeM.value*4)+t.seedOffset.value.getComponent(N)),f=t.noiseMap.value.image.data,p=(z,N,V)=>{const k=[z,N,V].map(ie=>(ie%1+1)%1*Zt-.5),K=k.map(Math.floor),ee=k.map((ie,oe)=>ie-K[oe]);let J=0;for(let ie=0;ie<2;ie++)for(let oe=0;oe<2;oe++)for(let Ve=0;Ve<2;Ve++){const Qe=(K[0]+Ve+Zt)%Zt,qe=(K[1]+oe+Zt)%Zt,Y=(K[2]+ie+Zt)%Zt;J+=f[Qe+Zt*(qe+Zt*Y)]/255*(Ve?ee[0]:1-ee[0])*(oe?ee[1]:1-ee[1])*(ie?ee[2]:1-ee[2])}return J},v=[d[0]*.173,_h,d[2]*.173];d[0]+=(p(v[0]+.13,v[1]+.27,v[2]+.41)-.5)*1.3,d[2]+=(p(v[0]+.67,v[1]+.53,v[2]+.19)-.5)*1.3;const m=(d[0]*.731+d[2]*.682)*1.371,g=(-d[0]*.682+d[2]*.731)*1.371;let _=i(.2,.8,p(d[0],_h,d[2])*.65+p(m,_h+.37,g)*.35);const w=i(8e3,4e4,Math.hypot(e.x,e.y,e.z)),M=n(p(d[0]*2,d[1]*3,d[2]*2),.5,w),S=n(p(d[0]*7,d[1]*7,d[2]*7),.5,w);let b=ol.thresholdFor(t.coverage.value),T=1,x=0;if(l){const z=u+(M-.5)*.18;x=1-i(.35,1,z),T=1-i(.85,1.15,z),_=n(_,1,x),b=Math.min(b,ol.thresholdFor(.5))}for(let z=0;z<t.holeCount.value;z++)T*=i(.85,1.15,h(t.holeCenter.value[z],t.holeSize.value[z],t.holeRotation.value[z])+(M-.5)*.18);if(T<.001)return 0;const A=(1-t.flatness.value)*.3*c*c;let I=i(b-.1+A,b+.1+A,_+(M-.5)*.12*c);if(I=n(I,1,i(.92,1,t.coverage.value)),I=n(I,Math.max(t.coverage.value,x),w),I<.001)return 0;const C=n(.45+.55*M,.96,t.flatness.value),P=i(0,.09,c)*(1-i(C-.22,C,c)),X=n(Math.max(0,I-(1-M)*.38-(1-S)*.1),I*.8,t.flatness.value);return P*X*t.density.value*T}transmissionAt(e,t=1/0){const i=this.uniforms,n=zS(e.y,i.eyeM.value,i.baseM.value,i.thicknessM.value);if(!n)return 1;let[s,r]=n;if(i.localSize.value.x>0){const h=i.localCenter.value.clone().sub(i.offsetM.value);h.y-=i.eyeM.value+(h.x**2+h.z**2)/(2*Bs);const u=i.localSize.value.length()*.5+25,d=e.x*h.x+e.y*h.y+e.z*h.z,f=d*d-h.lengthSq()+u*u;if(f<0)return 1;s=Math.max(s,d-Math.sqrt(f)),r=Math.min(r,d+Math.sqrt(f))}const o=Math.min(r,t,s+18e3);if(o<=s)return 1;const c=(o-s)/48;let l=1;for(let h=0;h<48;h++){const u=s+(h+.5)*c;if(l*=Math.exp(-this.densityAt({x:e.x*u,y:e.y*u,z:e.z*u})*c*.006),l<.015)break}return l}dispose(){this.mesh.removeFromParent(),this.mesh.geometry.dispose(),this.mesh.material.dispose()}}class oi{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=oi.build(24);static build(e){const t=[];let i=0,n=0,s=0;for(let r=0;r<e;r++){const o=oi.VIOLET_NM+(r+.5)/e*(oi.DEEP_RED_NM-oi.VIOLET_NM),[c,l,h]=oi.colourMatching(o),u={wavelengthNm:o,r:Math.max(0,3.2406*c-1.5372*l-.4986*h),g:Math.max(0,-.9689*c+1.8758*l+.0415*h),b:Math.max(0,.0557*c-.204*l+1.057*h)};i+=u.r,n+=u.g,s+=u.b,t.push(u)}for(const r of t)r.r/=i,r.g/=n,r.b/=s;return t}static tristimulus(e,t,i){let n=0,s=0,r=0;for(let c=0;c<e.length;c++){const[l,h,u]=oi.colourMatching(e[c]);n+=l*t[c],s+=h*t[c],r+=u*t[c]}const o=683*i;return[n*o,s*o,r*o]}static scotopic(e){const t=e/1e3;return .992*Math.exp(-321.9*(t-.5)**2)}static linearSrgbOf([e,t,i]){return[3.2406*e-1.5372*t-.4986*i,-.9689*e+1.8758*t+.0415*i,.0557*e-.204*t+1.057*i]}static colourMatching(e){const t=(i,n,s)=>{const r=(e-i)/(e<i?n:s);return Math.exp(-.5*r*r)};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 cl{static reflectance(e,t,i){const s=t/i*Math.sqrt(Math.max(0,1-e*e));if(s>=1)return 1;const r=Math.sqrt(Math.max(0,1-s*s)),o=(i*e-t*r)/(i*e+t*r),c=(t*e-i*r)/(t*e+i*r);return(o*o+c*c)/2}}class mi{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(mi.ANCHOR_BLUE-mi.ANCHOR_RED)/(1/(mi.BLUE_NM*mi.BLUE_NM)-1/(mi.RED_NM*mi.RED_NM));static A=mi.ANCHOR_RED-mi.B/(mi.RED_NM*mi.RED_NM);static indexAt(e){return mi.A+mi.B/(e*e)}}class lr{static MAX_CHORDS=4;index=1.333;set refractiveIndex(e){this.index=e}trace(e,t){const i=Math.min(1,Math.max(0,e)),n=Math.sqrt(Math.max(0,1-i*i)),s=i/this.index,r=Math.sqrt(Math.max(0,1-s*s)),o=Math.asin(i),c=Math.asin(s),l=cl.reflectance(n,1,this.index);let h=0;t[h].chords=0,t[h].scatteringAngle=lr.folded(Math.PI-2*o),t[h].weight=l,h++;const u=cl.reflectance(r,this.index,1);let d=1-l;for(let f=1;f<=lr.MAX_CHORDS&&h<t.length;f++){const p=2*(o-c)+(f-1)*(Math.PI-2*c);t[h].chords=f,t[h].scatteringAngle=lr.folded(p),t[h].weight=d*(1-u),h++,d*=u}return h}static folded(e){const t=2*Math.PI;let i=e%t;return i<0&&(i+=t),i>Math.PI?t-i:i}}class $t{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new lr;previous=$t.emergences();current=$t.emergences();tally=new Float32Array($t.BINS*3);radiance=new Float32Array($t.BINS*3);scratch=new Float32Array($t.BINS*3);static emergences(){return Array.from({length:lr.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const e of oi.SAMPLES)this.sweep(e);return this.toRadiance(),this.blurBySourceDisc(),{bins:$t.BINS,data:this.radiance,binDeg:180/$t.BINS}}sweep(e){this.drop.refractiveIndex=mi.indexAt(e.wavelengthNm);const t=$t.IMPACT_STEPS;let i=this.drop.trace(0,this.previous);const n=1/t;for(let s=1;s<=t;s++){const r=this.drop.trace(Math.sqrt(s/t),this.current);for(let o=0;o<Math.min(r,i);o++){const c=this.previous[o],l=this.current[o];c.chords===l.chords&&this.deposit(c.scatteringAngle,l.scatteringAngle,(c.weight+l.weight)/2*n,e)}i=r,this.copyInto(this.current,this.previous)}}copyInto(e,t){for(let i=0;i<e.length;i++)t[i].chords=e[i].chords,t[i].scatteringAngle=e[i].scatteringAngle,t[i].weight=e[i].weight}deposit(e,t,i,n){if(i<=0)return;const s=$t.BINS,r=Math.PI/s,o=Math.min(e,t),c=Math.max(e,t),l=c-o,h=Math.min(s-1,Math.max(0,Math.floor(o/r))),u=Math.min(s-1,Math.max(0,Math.floor(c/r)));if(l<=0||h===u){this.add(h,i,n);return}for(let d=h;d<=u;d++){const f=Math.min(c,(d+1)*r)-Math.max(o,d*r);f>0&&this.add(d,i*f/l,n)}}add(e,t,i){const n=e*3,s=t*oi.SAMPLES.length;this.tally[n]+=s*i.r,this.tally[n+1]+=s*i.g,this.tally[n+2]+=s*i.b}toRadiance(){const e=$t.BINS,t=Math.PI/e;for(let i=0;i<e;i++){const n=2*Math.PI*(Math.cos(i*t)-Math.cos((i+1)*t)),s=n>0?this.backwardShare((i+.5)*(180/e))/n:0,r=i*3;this.radiance[r]=this.tally[r]*s,this.radiance[r+1]=this.tally[r+1]*s,this.radiance[r+2]=this.tally[r+2]*s}}backwardShare(e){const t=180-e;if(t<=$t.FULL_UNTIL_DEG)return 1;if(t>=$t.FADED_BY_DEG)return 0;const i=(t-$t.FULL_UNTIL_DEG)/($t.FADED_BY_DEG-$t.FULL_UNTIL_DEG);return Math.cos(i*Math.PI/2)**2}blurBySourceDisc(){const e=$t.BINS,t=$t.SOURCE_RADIUS_DEG*e/180,i=Math.max(1,Math.ceil(t)),n=[];let s=0;for(let r=-i;r<=i;r++){const o=Math.max(0,t*t-r*r),c=Math.sqrt(o);n.push(c),s+=c}if(!(s<=0)){this.scratch.set(this.radiance);for(let r=0;r<e;r++){let o=0,c=0,l=0;for(let u=-i;u<=i;u++){const d=Math.min(e-1,Math.max(0,r+u))*3,f=n[u+i];o+=this.scratch[d]*f,c+=this.scratch[d+1]*f,l+=this.scratch[d+2]*f}const h=r*3;this.radiance[h]=o/s,this.radiance[h+1]=c/s,this.radiance[h+2]=l/s}}}}class pa{static RADIUS=880;static RENDER_ORDER=5.5;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new $t;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array($t.BINS*4),this.texture=new $s(this.texels,$t.BINS,1,yi,Ft),this.texture.minFilter=st,this.texture.magFilter=st,this.texture.wrapS=xi,this.texture.wrapT=xi,this.texture.needsUpdate=!0,this.material=new at({uniforms:{uSource:{value:new D(0,1,0)},uStrength:{value:0},uTint:{value:new D(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:pa.GAIN}},vertexShader:`
|
|
5258
|
+
}`,i=/\b(noiseMap|sunDir|sunColor|ambientColor|hazeColor|offsetM|seedOffset|localCenter|localSize|localRotation|baseM|thicknessM|eyeM|coverage|sizeM|density|darkness|flatness|SLICE|MAX_HOLES|holeCount|holeCenter|holeSize|holeRotation|R|roots|altitude|coverageThreshold|ellipsoidRadius|clipLocal|densityAt|transmissionAt)\b/g;return(e+t).replace(i,n=>a+n)}class ol{mesh;uniforms;constructor(e,t){this.uniforms={noiseMap:{value:e},sunDir:{value:new D(0,1,0)},sunColor:{value:new se(1,1,1)},ambientColor:{value:new se(.4,.45,.5)},hazeColor:{value:new se(.5,.6,.7)},offsetM:{value:new D},seedOffset:{value:new D},localCenter:{value:new D},localSize:{value:new D},localRotation:{value:0},holeCount:{value:0},holeCenter:{value:Array.from({length:Br},()=>new D)},holeSize:{value:Array.from({length:Br},()=>new D)},holeRotation:{value:new Array(Br).fill(0)},baseM:{value:1e3},thicknessM:{value:650},eyeM:{value:1.6},coverage:{value:.5},sizeM:{value:1400},density:{value:1},darkness:{value:0},flatness:{value:0}};const i=new at({uniforms:this.uniforms,vertexShader:HS,fragmentShader:Qu,transparent:!0,depthWrite:!1,depthTest:!0,side:Ot});this.mesh=new De(new Qt(t,32,16),i),this.mesh.frustumCulled=!1}update(e,t,i,n=[]){const s=this.uniforms;s.localSize.value.set(i?.widthM??0,i?.thicknessM??0,i?.depthM??0),s.localCenter.value.set(i?.eastM??0,i?i.baseM+i.thicknessM/2:0,-(i?.northM??0)),s.localRotation.value=(i?.rotationDeg??0)*Math.PI/180,s.holeCount.value=Math.min(Br,n.length),n.slice(0,Br).forEach((o,c)=>{s.holeCenter.value[c].set(o.eastM,o.baseM+o.thicknessM/2,-o.northM),s.holeSize.value[c].set(o.widthM,o.thicknessM,o.depthM),s.holeRotation.value[c]=o.rotationDeg*Math.PI/180}),s.baseM.value=Math.max(0,e.baseM),s.thicknessM.value=Math.max(10,e.thicknessM),s.coverage.value=Math.max(0,Math.min(1,e.coverage)),s.sizeM.value=Math.max(50,e.sizeM),s.density.value=Math.max(0,Math.min(2,e.density)),s.darkness.value=Math.max(0,Math.min(1,e.darkness??0)),s.eyeM.value=Math.max(.1,t),s.flatness.value=e.type==="stratus"?1:e.type==="stratocumulus"?.45:0;const r=ju(e);s.seedOffset.value.set(r%97/97,r%61/61,r%37/37),this.mesh.visible=s.density.value>0&&(i!==void 0||s.coverage.value>0)}static thresholdFor(e){const t=Math.min(.999,Math.max(.001,e));return .564-.2516*(Math.sqrt(3)/Math.PI)*Math.log(t/(1-t))}densityAt(e){const t=this.uniforms,i=(z,N,V)=>{const k=Math.max(0,Math.min(1,(V-z)/(N-z)));return k*k*(3-2*k)},n=(z,N,V)=>z+(N-z)*V,s=t.eyeM.value+e.y,r=2*Bs*s+e.x**2+s**2+e.z**2,o=r/(Math.sqrt(Bs**2+r)+Bs),c=(o-t.baseM.value)/t.thicknessM.value,l=t.localSize.value.x>0;if(c<=0||c>=1||t.coverage.value<=0&&!l)return 0;const h=(z,N,V)=>{const k=e.x+t.offsetM.value.x-z.x,K=e.z+t.offsetM.value.z-z.z,ee=Math.cos(V),J=Math.sin(V);return Math.hypot((ee*k-J*K)/(N.x*.5),(o-z.y)/(N.y*.5),(J*k+ee*K)/(N.z*.5))},u=l?h(t.localCenter.value,t.localSize.value,t.localRotation.value):0;if(u>1.3)return 0;const d=[e.x,e.y,e.z].map((z,N)=>(z+t.offsetM.value.getComponent(N))/(t.sizeM.value*4)+t.seedOffset.value.getComponent(N)),f=t.noiseMap.value.image.data,p=(z,N,V)=>{const k=[z,N,V].map(ie=>(ie%1+1)%1*Jt-.5),K=k.map(Math.floor),ee=k.map((ie,oe)=>ie-K[oe]);let J=0;for(let ie=0;ie<2;ie++)for(let oe=0;oe<2;oe++)for(let Ve=0;Ve<2;Ve++){const Qe=(K[0]+Ve+Jt)%Jt,qe=(K[1]+oe+Jt)%Jt,Y=(K[2]+ie+Jt)%Jt;J+=f[Qe+Jt*(qe+Jt*Y)]/255*(Ve?ee[0]:1-ee[0])*(oe?ee[1]:1-ee[1])*(ie?ee[2]:1-ee[2])}return J},v=[d[0]*.173,_h,d[2]*.173];d[0]+=(p(v[0]+.13,v[1]+.27,v[2]+.41)-.5)*1.3,d[2]+=(p(v[0]+.67,v[1]+.53,v[2]+.19)-.5)*1.3;const m=(d[0]*.731+d[2]*.682)*1.371,g=(-d[0]*.682+d[2]*.731)*1.371;let _=i(.2,.8,p(d[0],_h,d[2])*.65+p(m,_h+.37,g)*.35);const w=i(8e3,4e4,Math.hypot(e.x,e.y,e.z)),M=n(p(d[0]*2,d[1]*3,d[2]*2),.5,w),S=n(p(d[0]*7,d[1]*7,d[2]*7),.5,w);let b=ol.thresholdFor(t.coverage.value),T=1,x=0;if(l){const z=u+(M-.5)*.18;x=1-i(.35,1,z),T=1-i(.85,1.15,z),_=n(_,1,x),b=Math.min(b,ol.thresholdFor(.5))}for(let z=0;z<t.holeCount.value;z++)T*=i(.85,1.15,h(t.holeCenter.value[z],t.holeSize.value[z],t.holeRotation.value[z])+(M-.5)*.18);if(T<.001)return 0;const A=(1-t.flatness.value)*.3*c*c;let I=i(b-.1+A,b+.1+A,_+(M-.5)*.12*c);if(I=n(I,1,i(.92,1,t.coverage.value)),I=n(I,Math.max(t.coverage.value,x),w),I<.001)return 0;const C=n(.45+.55*M,.96,t.flatness.value),P=i(0,.09,c)*(1-i(C-.22,C,c)),X=n(Math.max(0,I-(1-M)*.38-(1-S)*.1),I*.8,t.flatness.value);return P*X*t.density.value*T}transmissionAt(e,t=1/0){const i=this.uniforms,n=zS(e.y,i.eyeM.value,i.baseM.value,i.thicknessM.value);if(!n)return 1;let[s,r]=n;if(i.localSize.value.x>0){const h=i.localCenter.value.clone().sub(i.offsetM.value);h.y-=i.eyeM.value+(h.x**2+h.z**2)/(2*Bs);const u=i.localSize.value.length()*.5+25,d=e.x*h.x+e.y*h.y+e.z*h.z,f=d*d-h.lengthSq()+u*u;if(f<0)return 1;s=Math.max(s,d-Math.sqrt(f)),r=Math.min(r,d+Math.sqrt(f))}const o=Math.min(r,t,s+18e3);if(o<=s)return 1;const c=(o-s)/48;let l=1;for(let h=0;h<48;h++){const u=s+(h+.5)*c;if(l*=Math.exp(-this.densityAt({x:e.x*u,y:e.y*u,z:e.z*u})*c*.006),l<.015)break}return l}dispose(){this.mesh.removeFromParent(),this.mesh.geometry.dispose(),this.mesh.material.dispose()}}class ci{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=ci.build(24);static build(e){const t=[];let i=0,n=0,s=0;for(let r=0;r<e;r++){const o=ci.VIOLET_NM+(r+.5)/e*(ci.DEEP_RED_NM-ci.VIOLET_NM),[c,l,h]=ci.colourMatching(o),u={wavelengthNm:o,r:Math.max(0,3.2406*c-1.5372*l-.4986*h),g:Math.max(0,-.9689*c+1.8758*l+.0415*h),b:Math.max(0,.0557*c-.204*l+1.057*h)};i+=u.r,n+=u.g,s+=u.b,t.push(u)}for(const r of t)r.r/=i,r.g/=n,r.b/=s;return t}static tristimulus(e,t,i){let n=0,s=0,r=0;for(let c=0;c<e.length;c++){const[l,h,u]=ci.colourMatching(e[c]);n+=l*t[c],s+=h*t[c],r+=u*t[c]}const o=683*i;return[n*o,s*o,r*o]}static scotopic(e){const t=e/1e3;return .992*Math.exp(-321.9*(t-.5)**2)}static linearSrgbOf([e,t,i]){return[3.2406*e-1.5372*t-.4986*i,-.9689*e+1.8758*t+.0415*i,.0557*e-.204*t+1.057*i]}static colourMatching(e){const t=(i,n,s)=>{const r=(e-i)/(e<i?n:s);return Math.exp(-.5*r*r)};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 cl{static reflectance(e,t,i){const s=t/i*Math.sqrt(Math.max(0,1-e*e));if(s>=1)return 1;const r=Math.sqrt(Math.max(0,1-s*s)),o=(i*e-t*r)/(i*e+t*r),c=(t*e-i*r)/(t*e+i*r);return(o*o+c*c)/2}}class gi{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(gi.ANCHOR_BLUE-gi.ANCHOR_RED)/(1/(gi.BLUE_NM*gi.BLUE_NM)-1/(gi.RED_NM*gi.RED_NM));static A=gi.ANCHOR_RED-gi.B/(gi.RED_NM*gi.RED_NM);static indexAt(e){return gi.A+gi.B/(e*e)}}class lr{static MAX_CHORDS=4;index=1.333;set refractiveIndex(e){this.index=e}trace(e,t){const i=Math.min(1,Math.max(0,e)),n=Math.sqrt(Math.max(0,1-i*i)),s=i/this.index,r=Math.sqrt(Math.max(0,1-s*s)),o=Math.asin(i),c=Math.asin(s),l=cl.reflectance(n,1,this.index);let h=0;t[h].chords=0,t[h].scatteringAngle=lr.folded(Math.PI-2*o),t[h].weight=l,h++;const u=cl.reflectance(r,this.index,1);let d=1-l;for(let f=1;f<=lr.MAX_CHORDS&&h<t.length;f++){const p=2*(o-c)+(f-1)*(Math.PI-2*c);t[h].chords=f,t[h].scatteringAngle=lr.folded(p),t[h].weight=d*(1-u),h++,d*=u}return h}static folded(e){const t=2*Math.PI;let i=e%t;return i<0&&(i+=t),i>Math.PI?t-i:i}}class Zt{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new lr;previous=Zt.emergences();current=Zt.emergences();tally=new Float32Array(Zt.BINS*3);radiance=new Float32Array(Zt.BINS*3);scratch=new Float32Array(Zt.BINS*3);static emergences(){return Array.from({length:lr.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const e of ci.SAMPLES)this.sweep(e);return this.toRadiance(),this.blurBySourceDisc(),{bins:Zt.BINS,data:this.radiance,binDeg:180/Zt.BINS}}sweep(e){this.drop.refractiveIndex=gi.indexAt(e.wavelengthNm);const t=Zt.IMPACT_STEPS;let i=this.drop.trace(0,this.previous);const n=1/t;for(let s=1;s<=t;s++){const r=this.drop.trace(Math.sqrt(s/t),this.current);for(let o=0;o<Math.min(r,i);o++){const c=this.previous[o],l=this.current[o];c.chords===l.chords&&this.deposit(c.scatteringAngle,l.scatteringAngle,(c.weight+l.weight)/2*n,e)}i=r,this.copyInto(this.current,this.previous)}}copyInto(e,t){for(let i=0;i<e.length;i++)t[i].chords=e[i].chords,t[i].scatteringAngle=e[i].scatteringAngle,t[i].weight=e[i].weight}deposit(e,t,i,n){if(i<=0)return;const s=Zt.BINS,r=Math.PI/s,o=Math.min(e,t),c=Math.max(e,t),l=c-o,h=Math.min(s-1,Math.max(0,Math.floor(o/r))),u=Math.min(s-1,Math.max(0,Math.floor(c/r)));if(l<=0||h===u){this.add(h,i,n);return}for(let d=h;d<=u;d++){const f=Math.min(c,(d+1)*r)-Math.max(o,d*r);f>0&&this.add(d,i*f/l,n)}}add(e,t,i){const n=e*3,s=t*ci.SAMPLES.length;this.tally[n]+=s*i.r,this.tally[n+1]+=s*i.g,this.tally[n+2]+=s*i.b}toRadiance(){const e=Zt.BINS,t=Math.PI/e;for(let i=0;i<e;i++){const n=2*Math.PI*(Math.cos(i*t)-Math.cos((i+1)*t)),s=n>0?this.backwardShare((i+.5)*(180/e))/n:0,r=i*3;this.radiance[r]=this.tally[r]*s,this.radiance[r+1]=this.tally[r+1]*s,this.radiance[r+2]=this.tally[r+2]*s}}backwardShare(e){const t=180-e;if(t<=Zt.FULL_UNTIL_DEG)return 1;if(t>=Zt.FADED_BY_DEG)return 0;const i=(t-Zt.FULL_UNTIL_DEG)/(Zt.FADED_BY_DEG-Zt.FULL_UNTIL_DEG);return Math.cos(i*Math.PI/2)**2}blurBySourceDisc(){const e=Zt.BINS,t=Zt.SOURCE_RADIUS_DEG*e/180,i=Math.max(1,Math.ceil(t)),n=[];let s=0;for(let r=-i;r<=i;r++){const o=Math.max(0,t*t-r*r),c=Math.sqrt(o);n.push(c),s+=c}if(!(s<=0)){this.scratch.set(this.radiance);for(let r=0;r<e;r++){let o=0,c=0,l=0;for(let u=-i;u<=i;u++){const d=Math.min(e-1,Math.max(0,r+u))*3,f=n[u+i];o+=this.scratch[d]*f,c+=this.scratch[d+1]*f,l+=this.scratch[d+2]*f}const h=r*3;this.radiance[h]=o/s,this.radiance[h+1]=c/s,this.radiance[h+2]=l/s}}}}class pa{static RADIUS=880;static RENDER_ORDER=5.5;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new Zt;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(Zt.BINS*4),this.texture=new $s(this.texels,Zt.BINS,1,_i,kt),this.texture.minFilter=st,this.texture.magFilter=st,this.texture.wrapS=yi,this.texture.wrapT=yi,this.texture.needsUpdate=!0,this.material=new at({uniforms:{uSource:{value:new D(0,1,0)},uStrength:{value:0},uTint:{value:new D(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:pa.GAIN}},vertexShader:`
|
|
5259
5259
|
varying vec3 vDirection;
|
|
5260
5260
|
void main() {
|
|
5261
5261
|
vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
|
|
@@ -5283,7 +5283,7 @@ float transmissionAt(vec3 dir, float distanceM) {
|
|
|
5283
5283
|
light = mix(vec3(grey), light, uSaturation);
|
|
5284
5284
|
gl_FragColor = vec4(light * uStrength, 1.0);
|
|
5285
5285
|
}
|
|
5286
|
-
`,transparent:!0,blending:
|
|
5286
|
+
`,transparent:!0,blending:Ci,depthWrite:!1,depthTest:!0,side:Ot,fog:!1}),this.object=new De(new Qt(pa.RADIUS,64,32),this.material),this.object.renderOrder=pa.RENDER_ORDER,this.object.frustumCulled=!1,this.object.visible=!1}update(e,t,i,n){const s=this.material.uniforms;if(t<=0){s.uStrength.value=0,this.object.visible=!1;return}this.computed||this.publish(),s.uSource.value.set(e.x,e.y,e.z).normalize(),s.uStrength.value=t,s.uTint.value.set(i[0],i[1],i[2]),s.uSaturation.value=n?1:pa.MOON_SATURATION,this.object.visible=!0}publish(){const t=this.sky.compute().data;for(let i=0,n=0;n<t.length;i+=4,n+=3)this.texels[i]=Dn.toHalfFloat(t[n]),this.texels[i+1]=Dn.toHalfFloat(t[n+1]),this.texels[i+2]=Dn.toHalfFloat(t[n+2]),this.texels[i+3]=1;this.texture.needsUpdate=!0,this.computed=!0}dispose(){this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class hr{constructor(e,t,i){this.group=e,this.radius=t,this.mode=i}decks=new Map;noise;halo;update(e,t){const i=Xc(e).flatMap(r=>{const o={...r,darkness:r.darkness??e.cloudDarkness};return[{layer:o,parentId:o.id,key:JSON.stringify([o.id]),instance:void 0},...(o.instances??[]).map(c=>({parentId:o.id,key:JSON.stringify([o.id,c.id]),instance:c,layer:{...o,id:`${o.id}/${c.id}`,baseM:c.baseM,thicknessM:c.thicknessM,density:c.density,darkness:c.darkness??o.darkness,seed:c.seed??ju(o),instances:void 0}}))]}),n=new Set(i.map(r=>r.key));for(const[r,o]of this.decks)n.has(r)||(this.disposeDeck(o),this.decks.delete(r));[...i].sort((r,o)=>Math.abs(o.layer.baseM+o.layer.thicknessM/2-t)-Math.abs(r.layer.baseM+r.layer.thicknessM/2-t)).forEach(({layer:r,key:o,instance:c,parentId:l},h)=>{const u=c!==void 0||r.type!=="cirrus"&&(this.mode==="volume"||(r.instances?.length??0)>0);let d=this.decks.get(o);if(d&&!!d.volume!==u&&(this.disposeDeck(d),this.decks.delete(o),d=void 0),!d){if(d={layer:r,parentId:l,instance:c},u)this.noise??=kS(),d.volume=new ol(this.noise,this.radius),this.group.add(d.volume.mesh);else{const p=Zu(new se(1,1,1),r.coverage,Math.max(1,Math.abs(r.baseM-t)*.25*1400/Math.max(50,r.sizeM)),r.type==="cirrus"?1:0);d.uniforms=p.uniforms,d.surface=new De(Ju(this.radius),p.material),this.group.add(d.surface)}this.decks.set(o,d)}d.layer=r,d.instance=c;const f=hr.deckOrder(r.baseM<t,h,i.length);d.volume&&(d.volume.update(r,t,c,c?[]:r.instances??[]),d.volume.mesh.renderOrder=f),d.surface&&d.uniforms&&(d.surface.renderOrder=f,d.surface.scale.y=r.baseM<t?-1:1,d.surface.visible=r.coverage>0&&r.density>0,d.uniforms.coverage.value=r.coverage,d.uniforms.opticalDensity.value=r.type==="cirrus"?r.density/.35:r.density,d.uniforms.darkness.value=Math.max(0,Math.min(1,r.darkness??e.cloudDarkness)),d.uniforms.layerHeight.value=Math.max(1,Math.abs(r.baseM-t)*.25*1400/Math.max(50,r.sizeM)),d.uniforms.fibrous.value=r.type==="cirrus"?1:0)}),this.halo&&this.hostHalo(this.halo)}hostHalo(e){this.halo=e;const t=e?this.cirrusDeck:void 0;for(const i of this.decks.values())i.surface&&hr.carryHalo(i.surface.material,i===t?e:void 0);e&&(e.hosted=t!==void 0)}static carryHalo(e,t){const i=e.uniforms;if(t){if(i.uHaloShown===t.deckUniforms.uHaloShown)return;Object.assign(i,t.deckUniforms),i.uPremultiplied.value=1,e.blending=Ml,e.blendSrc=e.blendSrcAlpha=go,e.blendDst=e.blendDstAlpha=vo}else{if(i.uPremultiplied.value===0)return;i.uHaloShown={value:0},i.uPremultiplied.value=0,e.blending=Ws}}static deckOrder(e,t,i){const n=t/Math.max(1,i);return e?pa.RENDER_ORDER+.1+.3*n:4+n}setOffsets(e,t){for(const i of this.decks.values()){const n=t[i.parentId]??e;i.volume?.uniforms.offsetM.value.set(n.x,0,n.z);const s=.25*1400/Math.max(50,i.layer.sizeM),r=ju(i.layer);i.uniforms?.fieldOffset.value.set(n.x*s+r%97,0,n.z*s+r%37)}}static sunVisibility(e,t){const i=Math.acos(Bs/(Bs+Math.max(0,t)))*180/Math.PI,n=Math.min(1,Math.max(0,(e+i+.84)/1.14));return n*n*(3-2*n)}setLighting(e,t,i,n){const s=Math.asin(Math.max(-1,Math.min(1,e.y/Math.max(1e-9,e.length()))))*180/Math.PI;for(const r of this.decks.values()){const o=r.volume?.uniforms??r.uniforms;o.sunDir.value.copy(e),o.sunColor.value.copy(t),r.volume||o.sunColor.value.multiplyScalar(hr.sunVisibility(s,r.layer.baseM)),o.ambientColor.value.copy(i),r.volume?.uniforms.hazeColor.value.copy(n)}}get cirrusMask(){const e=this.cirrusDeck;return e?.uniforms?{cover:e.layer.coverage,layerHeight:e.uniforms.layerHeight.value,offset:e.uniforms.fieldOffset.value,iceCrystalAlignment:e.layer.iceCrystalAlignment}:void 0}get cirrusDeck(){return[...this.decks.values()].filter(e=>e.layer.type==="cirrus"&&e.uniforms).sort((e,t)=>t.layer.coverage-e.layer.coverage)[0]}get volumes(){return[...this.decks.values()].flatMap(e=>e.volume?.mesh.visible?[e.volume]:[])}pickInstance(e){let t=1/0,i;for(const n of this.decks.values()){if(!n.instance||!n.volume?.mesh.visible)continue;const s=n.volume.uniforms,r=s.localCenter.value.clone().sub(s.offsetM.value);r.y-=s.eyeM.value+(r.x**2+r.z**2)/(2*6371e3);const o=r.dot(e);o<=0||o>=t||n.volume.transmissionAt(e)>.98||(t=o,i={layerId:n.parentId,instanceId:n.instance.id,center:r})}return i}transmissionAt(e,t=!1){let i=1;for(const n of this.decks.values())t&&n.layer.type==="cirrus"||(n.volume?i*=n.volume.transmissionAt(e):n.uniforms&&(i*=1-(n.layer.type==="cirrus"?ht.iceAlphaAt:ht.alphaAt)(e,n.uniforms.layerHeight.value,n.layer.coverage,n.uniforms.fieldOffset.value)*(n.layer.type==="cirrus"?.2:.95)));return i}disposeDeck(e){e.volume?.dispose(),e.surface&&(e.surface.removeFromParent(),e.surface.geometry.dispose(),e.surface.material.dispose())}dispose(){this.halo&&(this.halo.hosted=!1),this.halo=void 0;for(const e of this.decks.values())this.disposeDeck(e);this.decks.clear(),this.noise?.dispose()}}class Ee{static RESPONSE_EXPONENT=.74;static DAYLIGHT_ANCHOR_CD_M2=3e3;static DAYLIGHT_ANCHOR_RESPONSE=.42;static NIGHT_ANCHOR_CD_M2=172e-6;static NIGHT_ANCHOR_RESPONSE=.006;static anchoredSemiSaturation(e,t){const i=Ee.anchorResponse(t);return e*(1/i-1)**(1/Ee.RESPONSE_EXPONENT)}static anchorResponse(e){return Ee.lightnessOf(e)}static fromLightness(e){const t=(100*e+16)/116;return t>6/29?t**3:3*(6/29)**2*(t-4/29)}static lightnessOf(e){const t=Math.max(e,0);return(t>216/24389?116*Math.cbrt(t)-16:24389/27*t)/100}static get ADAPTATION_EXPONENT(){const e=Ee.anchoredSemiSaturation(Ee.DAYLIGHT_ANCHOR_CD_M2,Ee.DAYLIGHT_ANCHOR_RESPONSE),t=Ee.anchoredSemiSaturation(Ee.NIGHT_ANCHOR_CD_M2,Ee.NIGHT_ANCHOR_RESPONSE);return Math.log(e/t)/Math.log(Ee.DAYLIGHT_ANCHOR_CD_M2/Ee.NIGHT_ANCHOR_CD_M2)}static ROD_HALF_LUMINANCE_CD_M2=.04;static SCOTOPIC_TINT=[.853,.995,1.483];static get SEMI_SATURATION_SCALE(){return Ee.anchoredSemiSaturation(Ee.DAYLIGHT_ANCHOR_CD_M2,Ee.DAYLIGHT_ANCHOR_RESPONSE)/Ee.DAYLIGHT_ANCHOR_CD_M2**Ee.ADAPTATION_EXPONENT}static rodShare(e){return Ee.ROD_HALF_LUMINANCE_CD_M2/(Ee.ROD_HALF_LUMINANCE_CD_M2+Math.max(e,0))}static MOONLIT_ANCHOR_CD_M2=.0035;static MOONLIT_ANCHOR_RESPONSE=.0075;static semiSaturation(e){const t=Ee.MOONLIT_ANCHOR_RESPONSE,i=Math.max(e,1e-9),s=[[Ee.NIGHT_ANCHOR_CD_M2,Ee.NIGHT_ANCHOR_RESPONSE],[Ee.MOONLIT_ANCHOR_CD_M2,t],[Ee.DAYLIGHT_ANCHOR_CD_M2,Ee.DAYLIGHT_ANCHOR_RESPONSE]].map(([l,h])=>[Math.log(l),Math.log(Ee.anchoredSemiSaturation(l,h))]),r=Math.log(i),[o,c]=r<s[1][0]?[s[0],s[1]]:[s[1],s[2]];return Math.exp(o[1]+(c[1]-o[1])*(r-o[0])/(c[0]-o[0]))}static response(e,t){const i=Ee.RESPONSE_EXPONENT,n=Math.max(e,0)**i;return n/(n+Ee.semiSaturation(t)**i)}static displayOf(e,t,i,n=Ee.rodShare(i)){const s=(1-n)*e[1]+n*t,r=Ee.response(s,i),[o,c,l]=ci.linearSrgbOf(e),h=Math.max(e[1],1e-12),u=Ee.SCOTOPIC_TINT,d=.2126*u[0]+.7152*u[1]+.0722*u[2],f=(p,v)=>Math.max(0,(1-n)*p/h+n*v/d)*r;return[f(o,u[0]),f(c,u[1]),f(l,u[2])]}static relativeOf(e,t,i,n=Ee.rodShare(i)){const s=(1-n)*e[1]+n*t,r=Math.max(s,0)/Ee.semiSaturation(i),[o,c,l]=ci.linearSrgbOf(e),h=Math.max(e[1],1e-12),u=Ee.SCOTOPIC_TINT,d=.2126*u[0]+.7152*u[1]+.0722*u[2],f=(p,v)=>Math.max(0,(1-n)*p/h+n*v/d)*r;return[f(o,u[0]),f(c,u[1]),f(l,u[2])]}static respond(e){const t=Math.max(e,0)**Ee.RESPONSE_EXPONENT;return t/(t+1)}static relativeOfResponse(e){const t=Math.min(Math.max(e,0),.995);return(t/(1-t))**(1/Ee.RESPONSE_EXPONENT)}static finish(e){const t=.2126*e[0]+.7152*e[1]+.0722*e[2];if(!(t>0))return[0,0,0];const i=Ee.fromLightness(Ee.respond(t)),n=i/t,s=[e[0]*n,e[1]*n,e[2]*n],r=Math.max(...s);if(r<=1)return s;const o=(1-i)/(r-i);return s.map(c=>i+(c-i)*o)}}const kg=`
|
|
5287
5287
|
vec3 encodeSrgb(vec3 linear) {
|
|
5288
5288
|
vec3 clamped = max(linear, vec3(0.0));
|
|
5289
5289
|
vec3 low = clamped * 12.92;
|
|
@@ -5365,7 +5365,7 @@ vec3 finish(vec3 relative, vec4 overlay) {
|
|
|
5365
5365
|
if (uMode < 0.5) gl_FragColor = vec4(finish(scene, overlay), 1.0);
|
|
5366
5366
|
else if (uMode < 1.5) gl_FragColor = vec4(scene, 1.0);
|
|
5367
5367
|
else gl_FragColor = overlay;
|
|
5368
|
-
`;class VS{frame;film;quadScene=new xs;quadCamera=new Cn(-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);const i=()=>new
|
|
5368
|
+
`;class VS{frame;film;quadScene=new xs;quadCamera=new Cn(-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);const i=()=>new jt(this.width,this.height,{type:kt});this.frame={scene:i(),overlay:i()},this.film={scene:i(),overlay:i()};const n=`
|
|
5369
5369
|
varying vec2 vUv;
|
|
5370
5370
|
void main() {
|
|
5371
5371
|
vUv = position.xy * 0.5 + 0.5;
|
|
@@ -5390,7 +5390,7 @@ vec3 finish(vec3 relative, vec4 overlay) {
|
|
|
5390
5390
|
void main() {
|
|
5391
5391
|
gl_FragColor = vec4(finish(texture2D(uFilm, vUv).rgb * uGain, texture2D(uOverlay, vUv) * uGain), 1.0);
|
|
5392
5392
|
}
|
|
5393
|
-
`,blending:Zn,depthTest:!1,depthWrite:!1}),this.quad=new De(new ki(2,2),this.addMaterial),this.quadScene.add(this.quad)}get instantTarget(){return this.frame}open(e){const t=e.getRenderTarget();for(const i of[this.film.scene,this.film.overlay])e.setRenderTarget(i),e.setClearColor(0,0),e.clear(!0,!0,!0);e.setRenderTarget(t)}add(e,t){this.addMaterial.uniforms.uShare.value=t,this.quad.material=this.addMaterial;const i=e.getRenderTarget(),n=e.autoClear;e.autoClear=!1;for(const[s,r]of[[this.frame.scene,this.film.scene],[this.frame.overlay,this.film.overlay]])this.addMaterial.uniforms.uSource.value=s.texture,e.setRenderTarget(r),e.render(this.quadScene,this.quadCamera);e.setRenderTarget(i),e.autoClear=n}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);for(const i of[this.frame.scene,this.frame.overlay,this.film.scene,this.film.overlay])i.setSize(this.width,this.height)}dispose(){for(const e of[this.frame.scene,this.frame.overlay,this.film.scene,this.film.overlay])e.dispose();this.addMaterial.dispose(),this.developMaterial.dispose(),this.quad.geometry.dispose(),this.quadScene.clear()}}const ed=Math.PI/180,pp=180/Math.PI;function Al(a,e,t){return Math.max(e,Math.min(t,a))}const Ps=[{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 Sh(a,e,t){return a+(e-a)*t}function ll(a,e,t){return[Sh(a[0],e[0],t),Sh(a[1],e[1],t),Sh(a[2],e[2],t)]}function td(a){const e=Math.max(Ps[0].altitudeDeg,Math.min(Ps[Ps.length-1].altitudeDeg,a));for(let i=0;i<Ps.length-1;i++){const n=Ps[i],s=Ps[i+1];if(e>=n.altitudeDeg&&e<=s.altitudeDeg){const r=(e-n.altitudeDeg)/(s.altitudeDeg-n.altitudeDeg);return{zenith:ll(n.zenith,s.zenith,r),horizon:ll(n.horizon,s.horizon,r)}}}const t=Ps[Ps.length-1];return{zenith:t.zenith,horizon:t.horizon}}const mp=-18,gp=-4,WS=1.8;function Gc(a,e=0){if(a<=mp)return Vc+e;if(a>=0)return gp+e;const t=a/mp;return Vc-(Vc-gp)*(1-t)**WS+e}const vp=-1.5,Vc=6.5,XS=1.6;function jr(a,e=Vc){const t=Math.max(e,vp+1),i=(t-a)/(t-vp);return Al(i,0,1)**XS}function
|
|
5393
|
+
`,blending:Zn,depthTest:!1,depthWrite:!1}),this.quad=new De(new ki(2,2),this.addMaterial),this.quadScene.add(this.quad)}get instantTarget(){return this.frame}open(e){const t=e.getRenderTarget();for(const i of[this.film.scene,this.film.overlay])e.setRenderTarget(i),e.setClearColor(0,0),e.clear(!0,!0,!0);e.setRenderTarget(t)}add(e,t){this.addMaterial.uniforms.uShare.value=t,this.quad.material=this.addMaterial;const i=e.getRenderTarget(),n=e.autoClear;e.autoClear=!1;for(const[s,r]of[[this.frame.scene,this.film.scene],[this.frame.overlay,this.film.overlay]])this.addMaterial.uniforms.uSource.value=s.texture,e.setRenderTarget(r),e.render(this.quadScene,this.quadCamera);e.setRenderTarget(i),e.autoClear=n}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);for(const i of[this.frame.scene,this.frame.overlay,this.film.scene,this.film.overlay])i.setSize(this.width,this.height)}dispose(){for(const e of[this.frame.scene,this.frame.overlay,this.film.scene,this.film.overlay])e.dispose();this.addMaterial.dispose(),this.developMaterial.dispose(),this.quad.geometry.dispose(),this.quadScene.clear()}}const ed=Math.PI/180,pp=180/Math.PI;function Al(a,e,t){return Math.max(e,Math.min(t,a))}const Ps=[{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 Sh(a,e,t){return a+(e-a)*t}function ll(a,e,t){return[Sh(a[0],e[0],t),Sh(a[1],e[1],t),Sh(a[2],e[2],t)]}function td(a){const e=Math.max(Ps[0].altitudeDeg,Math.min(Ps[Ps.length-1].altitudeDeg,a));for(let i=0;i<Ps.length-1;i++){const n=Ps[i],s=Ps[i+1];if(e>=n.altitudeDeg&&e<=s.altitudeDeg){const r=(e-n.altitudeDeg)/(s.altitudeDeg-n.altitudeDeg);return{zenith:ll(n.zenith,s.zenith,r),horizon:ll(n.horizon,s.horizon,r)}}}const t=Ps[Ps.length-1];return{zenith:t.zenith,horizon:t.horizon}}const mp=-18,gp=-4,WS=1.8;function Gc(a,e=0){if(a<=mp)return Vc+e;if(a>=0)return gp+e;const t=a/mp;return Vc-(Vc-gp)*(1-t)**WS+e}const vp=-1.5,Vc=6.5,XS=1.6;function jr(a,e=Vc){const t=Math.max(e,vp+1),i=(t-a)/(t-vp);return Al(i,0,1)**XS}function ni(a,e,t){const i=a*ed,n=e*ed,s=t*Math.cos(i);return{x:s*Math.sin(n),y:t*Math.sin(i),z:-s*Math.cos(n)}}function qS(a,e,t){const i=Math.sqrt(a*a+e*e+t*t),n=i===0?0:Math.asin(Al(e/i,-1,1))*pp,s=(Math.atan2(a,-t)*pp+360)%360;return{altitudeDeg:n,azimuthDeg:s}}function YS(a,e){const t=Math.abs(a-e)%360;return t>180?360-t:t}function KS(a,e,t,i){const n=Math.max(0,1-YS(a,t)/$S),s=Math.exp(-Math.max(0,e)/ZS),r=i>0?Math.max(0,1-i/JS):Math.max(0,1-Math.abs(i+jS)/QS);return n*s*r}const $S=90,ZS=12,JS=8,jS=2,QS=12;function e5(a,e,t,i){const{zenith:n,horizon:s}=td(i),r=Al((a+90)/180,0,1),o=ll(s,n,r),c=KS(e,a,t,i);if(c<=0)return o;const l=td(i+t5).horizon,h=[Math.max(s[0],l[0]),Math.max(s[1],l[1]),Math.max(s[2],l[2])];return ll(o,h,c)}const t5=6;function wh(a){return .12+.88*a}function i5(a){const e=Math.max(a,-4),t=Math.sin(e*ed)+.50572*Math.pow(e+6.07995,-1.6364);return Al(1/t,1,40)}function Mp(a){const e=i5(a)-1;return[1,Math.exp(-.022*e),Math.exp(-.062*e)]}const ro=[{maxBrightness:.35,size:1.2},{maxBrightness:.7,size:2},{maxBrightness:1/0,size:3.2}];function zg(a){return ro.findIndex(e=>a<=e.maxBrightness)}const n5=.25,xp=.3,s5=2.2;function a5(a,{phase:e,speedFactor:t},i){const s=1+n5*(xp+(1-xp)*a)*Math.sin(i*s5*t+e);return Math.min(1,Math.max(0,s))}/**
|
|
5394
5394
|
@preserve
|
|
5395
5395
|
|
|
5396
5396
|
Astronomy library for JavaScript (browser and Node.js).
|
|
@@ -5421,17 +5421,25 @@ vec3 finish(vec3 relative, vec4 overlay) {
|
|
|
5421
5421
|
* @fileoverview Astronomy calculation library for browser scripting and Node.js.
|
|
5422
5422
|
* @author Don Cross <cosinekitty@gmail.com>
|
|
5423
5423
|
* @license MIT
|
|
5424
|
-
*/const t0=173.1446326846693,la=14959787069098932e-8,Mt=.017453292519943295,yp=.26179938779914946,jn=57.29577951308232,Hg=3.819718634205488,r5=365.24217,_p=new Date("2000-01-01T12:00:00Z"),os=2*Math.PI,Ls=3600*(180/Math.PI),tr=484813681109536e-20,Bg=10800*60,o5=2*Bg,Sp=7292115e-11,c5=Bg/Math.PI,l5=-.17-5*Math.log10(c5),id=.996647180302104,h5=id*id,nd=6378.1366,u5=nd/la,Gg=81.30056,i0=.0002959122082855911,sd=2825345909524226e-22,ad=8459715185680659e-23,rd=1292024916781969e-23,od=1524358900784276e-23;function hl(a){if(a!==!0&&a!==!1)throw console.trace(),`Value is not boolean: ${a}`;return a}function vi(a){if(!Number.isFinite(a))throw console.trace(),`Value is not a finite number: ${a}`;return a}function $a(a){return a-Math.floor(a)}function d5(a,e){const t=a.x*a.x+a.y*a.y+a.z*a.z;if(Math.abs(t)<1e-8)throw"AngleBetween: first vector is too short.";const i=e.x*e.x+e.y*e.y+e.z*e.z;if(Math.abs(i)<1e-8)throw"AngleBetween: second vector is too short.";const n=(a.x*e.x+a.y*e.y+a.z*e.z)/Math.sqrt(t*i);return n<=-1?180:n>=1?0:jn*Math.acos(n)}var we;(function(a){a.Sun="Sun",a.Moon="Moon",a.Mercury="Mercury",a.Venus="Venus",a.Earth="Earth",a.Mars="Mars",a.Jupiter="Jupiter",a.Saturn="Saturn",a.Uranus="Uranus",a.Neptune="Neptune",a.Pluto="Pluto",a.SSB="SSB",a.EMB="EMB",a.Star1="Star1",a.Star2="Star2",a.Star3="Star3",a.Star4="Star4",a.Star5="Star5",a.Star6="Star6",a.Star7="Star7",a.Star8="Star8"})(we||(we={}));const f5=[we.Star1,we.Star2,we.Star3,we.Star4,we.Star5,we.Star6,we.Star7,we.Star8],p5=[{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 m5(a){const e=f5.indexOf(a);return e>=0?p5[e]:null}function n0(a){const e=m5(a);return e&&e.dist>0?e:null}var _i;(function(a){a[a.From2000=0]="From2000",a[a.Into2000=1]="Into2000"})(_i||(_i={}));const $n={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 g5(a){var e,t,i,n,s,r,o;const c=2e3+(a-14)/r5;return c<-500?(e=(c-1820)/100,-20+32*e*e):c<500?(e=c/100,t=e*e,i=e*t,n=t*t,s=t*i,r=i*i,10583.6-1014.41*e+33.78311*t-5.952053*i-.1798452*n+.022174192*s+.0090316521*r):c<1600?(e=(c-1e3)/100,t=e*e,i=e*t,n=t*t,s=t*i,r=i*i,1574.2-556.01*e+71.23472*t+.319781*i-.8503463*n-.005050998*s+.0083572073*r):c<1700?(e=c-1600,t=e*e,i=e*t,120-.9808*e-.01532*t+i/7129):c<1800?(e=c-1700,t=e*e,i=e*t,n=t*t,8.83+.1603*e-.0059285*t+13336e-8*i-n/1174e3):c<1860?(e=c-1800,t=e*e,i=e*t,n=t*t,s=t*i,r=i*i,o=i*n,13.72-.332447*e+.0068612*t+.0041116*i-37436e-8*n+121272e-10*s-1699e-10*r+875e-12*o):c<1900?(e=c-1860,t=e*e,i=e*t,n=t*t,s=t*i,7.62+.5737*e-.251754*t+.01680668*i-.0004473624*n+s/233174):c<1920?(e=c-1900,t=e*e,i=e*t,n=t*t,-2.79+1.494119*e-.0598939*t+.0061966*i-197e-6*n):c<1941?(e=c-1920,t=e*e,i=e*t,21.2+.84493*e-.0761*t+.0020936*i):c<1961?(e=c-1950,t=e*e,i=e*t,29.07+.407*e-t/233+i/2547):c<1986?(e=c-1975,t=e*e,i=e*t,45.45+1.067*e-t/260-i/718):c<2005?(e=c-2e3,t=e*e,i=e*t,n=t*t,s=t*i,63.86+.3345*e-.060374*t+.0017275*i+651814e-9*n+2373599e-11*s):c<2050?(e=c-2e3,62.92+.32217*e+.005589*e*e):c<2150?(e=(c-1820)/100,-20+32*e*e-.5628*(2150-c)):(e=(c-1820)/100,-20+32*e*e)}let v5=g5;function wp(a){return a+v5(a)/86400}class dr{constructor(e){if(e instanceof dr){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()-_p.getTime())/t,this.tt=wp(this.ut);return}if(Number.isFinite(e)){this.date=new Date(_p.getTime()+e*t),this.ut=e,this.tt=wp(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 dr(e);for(;;){const i=e-t.tt;if(Math.abs(i)<1e-12)return t;t=t.AddDays(i)}}toString(){return this.date.toISOString()}AddDays(e){return new dr(this.ut+e)}}function kt(a){return a instanceof dr?a:new dr(a)}function M5(a){function e(d){return d%o5*tr}const t=a.tt/36525,i=e(128710479305e-5+t*1295965810481e-4),n=e(335779.526232+t*17395272628478e-4),s=e(107226070369e-5+t*1602961601209e-3),r=e(450160.398036-t*69628905431e-4);let o=Math.sin(r),c=Math.cos(r),l=(-172064161-174666*t)*o+33386*c,h=(92052331+9086*t)*c+15377*o,u=2*(n-s+r);return o=Math.sin(u),c=Math.cos(u),l+=(-13170906-1675*t)*o-13696*c,h+=(5730336-3015*t)*c-4587*o,u=2*(n+r),o=Math.sin(u),c=Math.cos(u),l+=(-2276413-234*t)*o+2796*c,h+=(978459-485*t)*c+1374*o,u=2*r,o=Math.sin(u),c=Math.cos(u),l+=(2074554+207*t)*o-698*c,h+=(-897492+470*t)*c-291*o,o=Math.sin(i),c=Math.cos(i),l+=(1475877-3633*t)*o+11817*c,h+=(73871-184*t)*c-1924*o,{dpsi:-135e-6+l*1e-7,deps:388e-6+h*1e-7}}function Vg(a){var e=a.tt/36525,t=((((-434e-10*e-576e-9)*e+.0020034)*e-1831e-7)*e-46.836769)*e+84381.406;return t/3600}var gc;function Do(a){if(!gc||Math.abs(gc.tt-a.tt)>1e-6){const e=M5(a),t=Vg(a),i=t+e.deps/3600;gc={tt:a.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*Mt)/15,mobl:t,tobl:i}}return gc}function x5(a,e){const t=a*Mt,i=Math.cos(t),n=Math.sin(t);return[e[0],e[1]*i-e[2]*n,e[1]*n+e[2]*i]}function y5(a,e){return x5(Vg(a),e)}function _5(a){const e=a.tt/36525;function t(Ce,ye){const Fe=[];let ke;for(ke=0;ke<=ye-Ce;++ke)Fe.push(0);return{min:Ce,array:Fe}}function i(Ce,ye,Fe,ke){const ze=[];for(let ft=0;ft<=ye-Ce;++ft)ze.push(t(Fe,ke));return{min:Ce,array:ze}}function n(Ce,ye,Fe){const ke=Ce.array[ye-Ce.min];return ke.array[Fe-ke.min]}function s(Ce,ye,Fe,ke){const ze=Ce.array[ye-Ce.min];ze.array[Fe-ze.min]=ke}let r,o,c,l,h,u,d,f,p,v,m,g,_,w,M,S,b,T,x,A,I,C,P,X=i(-6,6,1,4),z=i(-6,6,1,4);function N(Ce,ye){return n(X,Ce,ye)}function V(Ce,ye){return n(z,Ce,ye)}function k(Ce,ye,Fe){return s(X,Ce,ye,Fe)}function K(Ce,ye,Fe){return s(z,Ce,ye,Fe)}function ee(Ce,ye,Fe,ke,ze){ze(Ce*Fe-ye*ke,ye*Fe+Ce*ke)}function J(Ce){return Math.sin(os*Ce)}d=e*e,p=0,P=0,m=0,g=3422.7;var ie=J(.19833+.05611*e),oe=J(.27869+.04508*e),Ve=J(.16827-.36903*e),Qe=J(.34734-5.37261*e),qe=J(.10498-5.37899*e),Y=J(.42681-.41855*e),re=J(.14943-5.37511*e);for(T=.84*ie+.31*oe+14.27*Ve+7.26*Qe+.28*qe+.24*Y,x=2.94*ie+.31*oe+14.27*Ve+9.34*Qe+1.12*qe+.83*Y,A=-6.4*ie-1.89*Y,I=.21*ie+.31*oe+14.27*Ve-88.7*Qe-15.3*qe+.24*Y-1.86*re,C=T-A,f=-3332e-9*J(.59734-5.37261*e)-539e-9*J(.35498-5.37899*e)-64e-9*J(.39943-5.37511*e),_=os*$a(.60643382+1336.85522467*e-313e-8*d)+T/Ls,w=os*$a(.37489701+1325.55240982*e+2565e-8*d)+x/Ls,M=os*$a(.99312619+99.99735956*e-44e-8*d)+A/Ls,S=os*$a(.25909118+1342.2278298*e-892e-8*d)+I/Ls,b=os*$a(.82736186+1236.85308708*e-397e-8*d)+C/Ls,h=1;h<=4;++h){switch(h){case 1:c=w,o=4,l=1.000002208;break;case 2:c=M,o=3,l=.997504612-.002495388*e;break;case 3:c=S,o=4,l=1.000002708+139.978*f;break;case 4:c=b,o=6,l=1;break;default:throw`Internal error: I = ${h}`}for(k(0,h,1),k(1,h,Math.cos(c)*l),K(0,h,0),K(1,h,Math.sin(c)*l),u=2;u<=o;++u)ee(N(u-1,h),V(u-1,h),N(1,h),V(1,h),(Ce,ye)=>(k(u,h,Ce),K(u,h,ye)));for(u=1;u<=o;++u)k(-u,h,N(u,h)),K(-u,h,-V(u,h))}function ne(Ce,ye,Fe,ke){for(var ze={x:1,y:0},ft=[0,Ce,ye,Fe,ke],pt=1;pt<=4;++pt)ft[pt]!==0&&ee(ze.x,ze.y,N(ft[pt],pt),V(ft[pt],pt),(zt,Lt)=>(ze.x=zt,ze.y=Lt));return ze}function H(Ce,ye,Fe,ke,ze,ft,pt,zt){var Lt=ne(ze,ft,pt,zt);p+=Ce*Lt.y,P+=ye*Lt.y,m+=Fe*Lt.x,g+=ke*Lt.x}H(13.902,14.06,-.001,.2607,0,0,0,4),H(.403,-4.01,.394,.0023,0,0,0,3),H(2369.912,2373.36,.601,28.2333,0,0,0,2),H(-125.154,-112.79,-.725,-.9781,0,0,0,1),H(1.979,6.98,-.445,.0433,1,0,0,4),H(191.953,192.72,.029,3.0861,1,0,0,2),H(-8.466,-13.51,.455,-.1093,1,0,0,1),H(22639.5,22609.07,.079,186.5398,1,0,0,0),H(18.609,3.59,-.094,.0118,1,0,0,-1),H(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),H(3.215,5.44,.192,-.0386,1,0,0,-3),H(-38.428,-38.64,.001,.6008,1,0,0,-4),H(-.393,-1.43,-.092,.0086,1,0,0,-6),H(-.289,-1.59,.123,-.0053,0,1,0,4),H(-24.42,-25.1,.04,-.3,0,1,0,2),H(18.023,17.93,.007,.1494,0,1,0,1),H(-668.146,-126.98,-1.302,-.3997,0,1,0,0),H(.56,.32,-.001,-.0037,0,1,0,-1),H(-165.145,-165.06,.054,1.9178,0,1,0,-2),H(-1.877,-6.46,-.416,.0339,0,1,0,-4),H(.213,1.02,-.074,.0054,2,0,0,4),H(14.387,14.78,-.017,.2833,2,0,0,2),H(-.586,-1.2,.054,-.01,2,0,0,1),H(769.016,767.96,.107,10.1657,2,0,0,0),H(1.75,2.01,-.018,.0155,2,0,0,-1),H(-211.656,-152.53,5.679,-.3039,2,0,0,-2),H(1.225,.91,-.03,-.0088,2,0,0,-3),H(-30.773,-34.07,-.308,.3722,2,0,0,-4),H(-.57,-1.4,-.074,.0109,2,0,0,-6),H(-2.921,-11.75,.787,-.0484,1,1,0,2),H(1.267,1.52,-.022,.0164,1,1,0,1),H(-109.673,-115.18,.461,-.949,1,1,0,0),H(-205.962,-182.36,2.056,1.4437,1,1,0,-2),H(.233,.36,.012,-.0025,1,1,0,-3),H(-4.391,-9.66,-.471,.0673,1,1,0,-4),H(.283,1.53,-.111,.006,1,-1,0,4),H(14.577,31.7,-1.54,.2302,1,-1,0,2),H(147.687,138.76,.679,1.1528,1,-1,0,0),H(-1.089,.55,.021,0,1,-1,0,-1),H(28.475,23.59,-.443,-.2257,1,-1,0,-2),H(-.276,-.38,-.006,-.0036,1,-1,0,-3),H(.636,2.27,.146,-.0102,1,-1,0,-4),H(-.189,-1.68,.131,-.0028,0,2,0,2),H(-7.486,-.66,-.037,-.0086,0,2,0,0),H(-8.096,-16.35,-.74,.0918,0,2,0,-2),H(-5.741,-.04,0,-9e-4,0,0,2,2),H(.255,0,0,0,0,0,2,1),H(-411.608,-.2,0,-.0124,0,0,2,0),H(.584,.84,0,.0071,0,0,2,-1),H(-55.173,-52.14,0,-.1052,0,0,2,-2),H(.254,.25,0,-.0017,0,0,2,-3),H(.025,-1.67,0,.0031,0,0,2,-4),H(1.06,2.96,-.166,.0243,3,0,0,2),H(36.124,50.64,-1.3,.6215,3,0,0,0),H(-13.193,-16.4,.258,-.1187,3,0,0,-2),H(-1.187,-.74,.042,.0074,3,0,0,-4),H(-.293,-.31,-.002,.0046,3,0,0,-6),H(-.29,-1.45,.116,-.0051,2,1,0,2),H(-7.649,-10.56,.259,-.1038,2,1,0,0),H(-8.627,-7.59,.078,-.0192,2,1,0,-2),H(-2.74,-2.54,.022,.0324,2,1,0,-4),H(1.181,3.32,-.212,.0213,2,-1,0,2),H(9.703,11.67,-.151,.1268,2,-1,0,0),H(-.352,-.37,.001,-.0028,2,-1,0,-1),H(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),H(.36,.2,-.012,-.0043,2,-1,0,-4),H(-1.167,-1.25,.008,-.0106,1,2,0,0),H(-7.412,-6.12,.117,.0484,1,2,0,-2),H(-.311,-.65,-.032,.0044,1,2,0,-4),H(.757,1.82,-.105,.0112,1,-2,0,2),H(2.58,2.32,.027,.0196,1,-2,0,0),H(2.533,2.4,-.014,-.0212,1,-2,0,-2),H(-.344,-.57,-.025,.0036,0,3,0,-2),H(-.992,-.02,0,0,1,0,2,2),H(-45.099,-.02,0,-.001,1,0,2,0),H(-.179,-9.52,0,-.0833,1,0,2,-2),H(-.301,-.33,0,.0014,1,0,2,-4),H(-6.382,-3.37,0,-.0481,1,0,-2,2),H(39.528,85.13,0,-.7136,1,0,-2,0),H(9.366,.71,0,-.0112,1,0,-2,-2),H(.202,.02,0,0,1,0,-2,-4),H(.415,.1,0,.0013,0,1,2,0),H(-2.152,-2.26,0,-.0066,0,1,2,-2),H(-1.44,-1.3,0,.0014,0,1,-2,2),H(.384,-.04,0,0,0,1,-2,-2),H(1.938,3.6,-.145,.0401,4,0,0,0),H(-.952,-1.58,.052,-.013,4,0,0,-2),H(-.551,-.94,.032,-.0097,3,1,0,0),H(-.482,-.57,.005,-.0045,3,1,0,-2),H(.681,.96,-.026,.0115,3,-1,0,0),H(-.297,-.27,.002,-9e-4,2,2,0,-2),H(.254,.21,-.003,0,2,-2,0,-2),H(-.25,-.22,.004,.0014,1,3,0,-2),H(-3.996,0,0,4e-4,2,0,2,0),H(.557,-.75,0,-.009,2,0,2,-2),H(-.459,-.38,0,-.0053,2,0,-2,2),H(-1.298,.74,0,4e-4,2,0,-2,0),H(.538,1.14,0,-.0141,2,0,-2,-2),H(.263,.02,0,0,1,1,2,0),H(.426,.07,0,-6e-4,1,1,-2,-2),H(-.304,.03,0,3e-4,1,-1,2,0),H(-.372,-.19,0,-.0027,1,-1,-2,2),H(.418,0,0,0,0,0,4,0),H(-.33,-.04,0,0,3,0,2,0);function Ae(Ce,ye,Fe,ke,ze){return Ce*ne(ye,Fe,ke,ze).y}v=0,v+=Ae(-526.069,0,0,1,-2),v+=Ae(-3.352,0,0,1,-4),v+=Ae(44.297,1,0,1,-2),v+=Ae(-6,1,0,1,-4),v+=Ae(20.599,-1,0,1,0),v+=Ae(-30.598,-1,0,1,-2),v+=Ae(-24.649,-2,0,1,0),v+=Ae(-2,-2,0,1,-2),v+=Ae(-22.571,0,1,1,-2),v+=Ae(10.985,0,-1,1,-2),p+=.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),r=S+P/Ls;let Ne=(1.000002708+139.978*f)*(18518.511+1.189+m)*Math.sin(r)-6.24*Math.sin(3*r)+v;return{geo_eclip_lon:os*$a((_+p/Ls)/os),geo_eclip_lat:Math.PI/(180*3600)*Ne,distance_au:Ls*u5/(.999953253*g)}}function Wg(a,e){return[a.rot[0][0]*e[0]+a.rot[1][0]*e[1]+a.rot[2][0]*e[2],a.rot[0][1]*e[0]+a.rot[1][1]*e[1]+a.rot[2][1]*e[2],a.rot[0][2]*e[0]+a.rot[1][2]*e[1]+a.rot[2][2]*e[2]]}function ul(a,e,t){const i=s0(e,t);return Wg(i,a)}function s0(a,e){const t=a.tt/36525;let i=84381.406,n=((((-951e-10*t+132851e-9)*t-.00114045)*t-1.0790069)*t+5038.481507)*t,s=((((3337e-10*t-467e-9)*t-.00772503)*t+.0512623)*t-.025754)*t+i,r=((((-56e-9*t+170663e-9)*t-.00121197)*t-2.3814292)*t+10.556403)*t;i*=tr,n*=tr,s*=tr,r*=tr;const o=Math.sin(i),c=Math.cos(i),l=Math.sin(-n),h=Math.cos(-n),u=Math.sin(-s),d=Math.cos(-s),f=Math.sin(r),p=Math.cos(r),v=p*h-l*f*d,m=p*l*c+f*d*h*c-o*f*u,g=p*l*o+f*d*h*o+c*f*u,_=-f*h-l*p*d,w=-f*l*c+p*d*h*c-o*p*u,M=-f*l*o+p*d*h*o+c*p*u,S=l*u,b=-u*h*c-o*d,T=-u*h*o+d*c;if(e===_i.Into2000)return new Ks([[v,m,g],[_,w,M],[S,b,T]]);if(e===_i.From2000)return new Ks([[v,_,S],[m,w,b],[g,M,T]]);throw"Invalid precess direction"}function S5(a){const e=.779057273264+.00273781191135448*a.ut,t=a.ut%1;let i=360*((e+t)%1);return i<0&&(i+=360),i}let vc;function Tl(a){if(!vc||vc.tt!==a.tt){const e=a.tt/36525;let t=15*Do(a).ee;const i=S5(a);let s=((t+.014506+((((-368e-10*e-29956e-9)*e-44e-8)*e+1.3915817)*e+4612.156534)*e)/3600+i)%360/15;s<0&&(s+=24),vc={tt:a.tt,st:s}}return vc.st}function w5(a){const e=kt(a);return Tl(e)}function Xg(a,e){const t=a.latitude*Mt,i=Math.sin(t),n=Math.cos(t),s=1/Math.hypot(n,id*i),r=h5*s,o=a.height/1e3,c=nd*s+o,l=nd*r+o,h=(15*e+a.longitude)*Mt,u=Math.sin(h),d=Math.cos(h);return{pos:[c*n*d/la,c*n*u/la,l*i/la],vel:[-Sp*c*n*u*86400/la,Sp*c*n*d*86400/la,0]}}function cd(a,e,t){const i=a0(e,t);return Wg(i,a)}function a0(a,e){const t=Do(a),i=t.mobl*Mt,n=t.tobl*Mt,s=t.dpsi*tr,r=Math.cos(i),o=Math.sin(i),c=Math.cos(n),l=Math.sin(n),h=Math.cos(s),u=Math.sin(s),d=h,f=-u*r,p=-u*o,v=u*c,m=h*r*c+o*l,g=h*o*c-r*l,_=u*l,w=h*r*l-o*c,M=h*o*l+r*c;if(e===_i.From2000)return new Ks([[d,v,_],[f,m,w],[p,g,M]]);if(e===_i.Into2000)return new Ks([[d,f,p],[v,m,g],[_,w,M]]);throw"Invalid precess direction"}function r0(a,e,t){return t===_i.Into2000?ul(cd(a,e,t),e,t):cd(ul(a,e,t),e,t)}function b5(a,e){const t=Tl(a),i=Xg(e,t).pos;return r0(i,a,_i.Into2000)}class Ct{constructor(e,t,i,n){this.x=e,this.y=t,this.z=i,this.t=n}Length(){return Math.hypot(this.x,this.y,this.z)}}class Gs{constructor(e,t,i,n,s,r,o){this.x=e,this.y=t,this.z=i,this.vx=n,this.vy=s,this.vz=r,this.t=o}}class Rl{constructor(e,t,i){this.lat=vi(e),this.lon=vi(t),this.dist=vi(i)}}class ld{constructor(e,t,i,n){this.ra=vi(e),this.dec=vi(t),this.dist=vi(i),this.vec=n}}class Ks{constructor(e){this.rot=e}}class E5{constructor(e,t,i,n){this.azimuth=vi(e),this.altitude=vi(t),this.ra=vi(i),this.dec=vi(n)}}class A5{constructor(e,t,i){this.vec=e,this.elat=vi(t),this.elon=vi(i)}}function qg(a,e){return new Ct(a[0],a[1],a[2],e)}function T5(a,e){const t=qg(a,e),i=t.x*t.x+t.y*t.y,n=Math.sqrt(i+t.z*t.z);if(i===0){if(t.z===0)throw"Indeterminate sky coordinates";return new ld(0,t.z<0?-90:90,n,t)}let s=Hg*Math.atan2(t.y,t.x);s<0&&(s+=24);const r=jn*Math.atan2(a[2],Math.sqrt(i));return new ld(s,r,n,t)}function bh(a,e){const t=a*Mt,i=Math.cos(t),n=Math.sin(t);return[i*e[0]+n*e[1],i*e[1]-n*e[0],e[2]]}function Yg(a,e,t,i,n){let s=kt(a);o0(e),vi(t),vi(i);const r=Math.sin(e.latitude*Mt),o=Math.cos(e.latitude*Mt),c=Math.sin(e.longitude*Mt),l=Math.cos(e.longitude*Mt),h=Math.sin(i*Mt),u=Math.cos(i*Mt),d=Math.sin(t*yp),f=Math.cos(t*yp);let p=[o*l,o*c,r],v=[-r*l,-r*c,o],m=[c,-l,0];const g=-15*Tl(s);let _=bh(g,p),w=bh(g,v),M=bh(g,m),S=[u*f,u*d,h];const b=S[0]*_[0]+S[1]*_[1]+S[2]*_[2],T=S[0]*w[0]+S[1]*w[1]+S[2]*w[2],x=S[0]*M[0]+S[1]*M[1]+S[2]*M[2];let A=Math.hypot(T,x),I;A>0?(I=-jn*Math.atan2(x,T),I<0&&(I+=360)):I=0;let C=jn*Math.atan2(A,b),P=t,X=i;if(n){let z=C,N=i1(n,90-C);if(C-=N,N>0&&C>3e-4){const V=Math.sin(C*Mt),k=Math.cos(C*Mt),K=Math.sin(z*Mt),ee=Math.cos(z*Mt),J=[];for(let ie=0;ie<3;++ie)J.push((S[ie]-ee*_[ie])/K*V+_[ie]*k);A=Math.hypot(J[0],J[1]),A>0?(P=Hg*Math.atan2(J[1],J[0]),P<0&&(P+=24)):P=0,X=jn*Math.atan2(J[2],A)}}return new E5(I,90-C,P,X)}function o0(a){if(!(a instanceof c0))throw`Not an instance of the Observer class: ${a}`;if(vi(a.latitude),vi(a.longitude),vi(a.height),a.latitude<-90||a.latitude>90)throw`Latitude ${a.latitude} is out of range. Must be -90..+90.`;return a}class c0{constructor(e,t,i){this.latitude=e,this.longitude=t,this.height=i,o0(this)}}function R5(a){const e=kt(a).AddDays(-1/t0),t=pr($n.Earth,e),i=[-t.x,-t.y,-t.z],[n,s,r]=r0(i,e,_i.From2000),o=Mt*Do(e).tobl,c=Math.cos(o),l=Math.sin(o),h=new Ct(n,s,r,e);return Kg(h,c,l)}function D5(a,e,t,i,n){o0(t),hl(i),hl(n);const s=kt(e),r=b5(s,t),o=xd(a,s,n),c=[o.x-r[0],o.y-r[1],o.z-r[2]],l=r0(c,s,_i.From2000);return T5(l,s)}function C5(a,e,t){const i=kt(a),n=Tl(i);let s=Xg(e,n).pos;return qg(s,i)}function Kg(a,e,t){const i=a.x,n=a.y*e+a.z*t,s=-a.y*t+a.z*e,r=Math.hypot(i,n);let o=0;r>0&&(o=jn*Math.atan2(n,i),o<0&&(o+=360));let c=jn*Math.atan2(s,r),l=new Ct(i,n,s,a.t);return new A5(l,c,o)}function hd(a){const e=Do(a.t),t=[a.x,a.y,a.z],i=ul(t,a.t,_i.From2000),[n,s,r]=cd(i,a.t,_i.From2000),o=new Ct(n,s,r,a.t),c=e.tobl*Mt;return Kg(o,Math.cos(c),Math.sin(c))}function yr(a){const e=kt(a),t=_5(e),i=t.distance_au*Math.cos(t.geo_eclip_lat),n=[i*Math.cos(t.geo_eclip_lon),i*Math.sin(t.geo_eclip_lon),t.distance_au*Math.sin(t.geo_eclip_lat)],s=y5(e,n),r=ul(s,e,_i.Into2000);return new Ct(r[0],r[1],r[2],e)}function $g(a){const e=kt(a),t=1e-5,i=e.AddDays(-t),n=e.AddDays(+t),s=yr(i),r=yr(n);return new Gs((s.x+r.x)/2,(s.y+r.y)/2,(s.z+r.z)/2,(r.x-s.x)/(2*t),(r.y-s.y)/(2*t),(r.z-s.z)/(2*t),e)}function I5(a){const e=kt(a),t=$g(e),i=1+Gg;return new Gs(t.x/i,t.y/i,t.z/i,t.vx/i,t.vy/i,t.vz/i,e)}function fr(a,e,t){let i=1,n=0;for(let s of a){let r=0;for(let[c,l,h]of s)r+=c*Math.cos(l+e*h);let o=i*r;t&&(o%=os),n+=o,i*=e}return n}function Eh(a,e){let t=1,i=0,n=0,s=0;for(let r of a){let o=0,c=0;for(let[l,h,u]of r){let d=h+e*u;o+=l*u*Math.sin(d),s>0&&(c+=l*Math.cos(d))}n+=s*i*c-t*o,i=t,t*=e,++s}return n}const Qr=365250,ud=0,dd=1,fd=2;function pd(a){return new Ti(a[0]+44036e-11*a[1]-190919e-12*a[2],-479966e-12*a[0]+.917482137087*a[1]-.397776982902*a[2],.397776982902*a[1]+.917482137087*a[2])}function Zg(a,e,t){const i=t*Math.cos(e),n=Math.cos(a),s=Math.sin(a);return[i*n,i*s,t*Math.sin(e)]}function pr(a,e){const t=e.tt/Qr,i=fr(a[ud],t,!0),n=fr(a[dd],t,!1),s=fr(a[fd],t,!1),r=Zg(i,n,s);return pd(r).ToAstroVector(e)}function md(a,e){const t=e/Qr,i=fr(a[ud],t,!0),n=fr(a[dd],t,!1),s=fr(a[fd],t,!1),r=Eh(a[ud],t),o=Eh(a[dd],t),c=Eh(a[fd],t),l=Math.cos(i),h=Math.sin(i),u=Math.cos(n),d=Math.sin(n),f=+(c*u*l)-s*d*l*o-s*u*h*r,p=+(c*u*h)-s*d*h*o+s*u*l*r,v=+(c*d)+s*u*o,m=Zg(i,n,s),g=[f/Qr,p/Qr,v/Qr],_=pd(m),w=pd(g);return new Sa(e,_,w)}function Mc(a,e,t,i){const n=i/(i+i0),s=pr($n[t],e);a.x+=n*s.x,a.y+=n*s.y,a.z+=n*s.z}function P5(a){const e=new Ct(0,0,0,a);return Mc(e,a,we.Jupiter,sd),Mc(e,a,we.Saturn,ad),Mc(e,a,we.Uranus,rd),Mc(e,a,we.Neptune,od),e}const gd=51,L5=29200,ir=146,cs=201,ma=[[-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 Ti{constructor(e,t,i){this.x=e,this.y=t,this.z=i}clone(){return new Ti(this.x,this.y,this.z)}ToAstroVector(e){return new Ct(this.x,this.y,this.z,e)}static zero(){return new Ti(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new Ti(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new Ti(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 Ti(e*this.x,e*this.y,e*this.z)}div(e){return new Ti(this.x/e,this.y/e,this.z/e)}mean(e){return new Ti((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new Ti(-this.x,-this.y,-this.z)}}class Sa{constructor(e,t,i){this.tt=e,this.r=t,this.v=i}clone(){return new Sa(this.tt,this.r,this.v)}sub(e){return new Sa(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function N5(a){let[e,[t,i,n],[s,r,o]]=a;return new Sa(e,new Ti(t,i,n),new Ti(s,r,o))}function xc(a,e,t,i){const n=i/(i+i0),s=md($n[t],e);return a.r.incr(s.r.mul(n)),a.v.incr(s.v.mul(n)),s}function Gr(a,e,t){const i=t.sub(a),n=i.quadrature();return i.mul(e/(n*Math.sqrt(n)))}class Dl{constructor(e){let t=new Sa(e,new Ti(0,0,0),new Ti(0,0,0));this.Jupiter=xc(t,e,we.Jupiter,sd),this.Saturn=xc(t,e,we.Saturn,ad),this.Uranus=xc(t,e,we.Uranus,rd),this.Neptune=xc(t,e,we.Neptune,od),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 Sa(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=Gr(e,i0,this.Sun.r);return t.incr(Gr(e,sd,this.Jupiter.r)),t.incr(Gr(e,ad,this.Saturn.r)),t.incr(Gr(e,rd,this.Uranus.r)),t.incr(Gr(e,od,this.Neptune.r)),t}}class Cl{constructor(e,t,i,n){this.tt=e,this.r=t,this.v=i,this.a=n}clone(){return new Cl(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class Jg{constructor(e,t){this.bary=e,this.grav=t}}function dl(a,e,t,i){return new Ti(e.x+a*(t.x+a*i.x/2),e.y+a*(t.y+a*i.y/2),e.z+a*(t.z+a*i.z/2))}function bp(a,e,t){return new Ti(e.x+a*t.x,e.y+a*t.y,e.z+a*t.z)}function vd(a,e){const t=a-e.tt,i=new Dl(a),n=dl(t,e.r,e.v,e.a),s=i.Acceleration(n).mean(e.a),r=dl(t,e.r,e.v,s),o=e.v.add(s.mul(t)),c=i.Acceleration(r),l=new Cl(a,r,o,c);return new Jg(i,l)}const O5=[];function jg(a,e){const t=Math.floor(a);return t<0?0:t>=e?e-1:t}function Md(a){const e=N5(a),t=new Dl(e.tt),i=e.r.add(t.Sun.r),n=e.v.add(t.Sun.v),s=t.Acceleration(i),r=new Cl(e.tt,i,n,s);return new Jg(t,r)}function U5(a,e){const t=ma[0][0];if(e<t||e>ma[gd-1][0])return null;const i=jg((e-t)/L5,gd-1);if(!a[i]){const s=a[i]=[];s[0]=Md(ma[i]).grav,s[cs-1]=Md(ma[i+1]).grav;let r,o=s[0].tt;for(r=1;r<cs-1;++r)s[r]=vd(o+=ir,s[r-1]).grav;o=s[cs-1].tt;var n=[];for(n[cs-1]=s[cs-1],r=cs-2;r>0;--r)n[r]=vd(o-=ir,n[r+1]).grav;for(r=cs-2;r>0;--r){const c=r/(cs-1);s[r].r=s[r].r.mul(1-c).add(n[r].r.mul(c)),s[r].v=s[r].v.mul(1-c).add(n[r].v.mul(c)),s[r].a=s[r].a.mul(1-c).add(n[r].a.mul(c))}}return a[i]}function Ep(a,e,t){let i=Md(a);const n=Math.ceil((e-i.grav.tt)/t);for(let s=0;s<n;++s)i=vd(s+1===n?e:i.grav.tt+t,i.grav);return i}function Qg(a,e){let t,i,n;const s=U5(O5,a.tt);if(s){const r=jg((a.tt-s[0].tt)/ir,cs-1),o=s[r],c=s[r+1],l=o.a.mean(c.a),h=dl(a.tt-o.tt,o.r,o.v,l),u=bp(a.tt-o.tt,o.v,l),d=dl(a.tt-c.tt,c.r,c.v,l),f=bp(a.tt-c.tt,c.v,l),p=(a.tt-o.tt)/ir;t=h.mul(1-p).add(d.mul(p)),i=u.mul(1-p).add(f.mul(p))}else{let r;a.tt<ma[0][0]?r=Ep(ma[0],a.tt,-ir):r=Ep(ma[gd-1],a.tt,+ir),t=r.grav.r,i=r.grav.v,n=r.bary}return n||(n=new Dl(a.tt)),t=t.sub(n.Sun.r),i=i.sub(n.Sun.v),new Gs(t.x,t.y,t.z,i.x,i.y,i.z,a)}function Xs(a,e){var t=kt(e);if(a in $n)return pr($n[a],t);if(a===we.Pluto){const r=Qg(t);return new Ct(r.x,r.y,r.z,t)}if(a===we.Sun)return new Ct(0,0,0,t);if(a===we.Moon){var i=pr($n.Earth,t),n=yr(t);return new Ct(i.x+n.x,i.y+n.y,i.z+n.z,t)}if(a===we.EMB){const r=pr($n.Earth,t),o=yr(t),c=1+Gg;return new Ct(r.x+o.x/c,r.y+o.y/c,r.z+o.z/c,t)}if(a===we.SSB)return P5(t);const s=n0(a);if(s){const r=new Rl(s.dec,15*s.ra,s.dist);return l0(r,t)}throw`HelioVector: Unknown body "${a}"`}function F5(a,e){let t=e,i=0;for(let n=0;n<10;++n){const s=a(t),r=s.Length()/t0;if(r>1)throw"Object is too distant for light-travel solver.";const o=e.AddDays(-r);if(i=Math.abs(o.tt-t.tt),i<1e-9)return s;t=o}throw`Light-travel time solver did not converge: dt = ${i}`}class k5{constructor(e,t,i,n){this.observerBody=e,this.targetBody=t,this.aberration=i,this.observerPos=n}Position(e){this.aberration&&(this.observerPos=Xs(this.observerBody,e));const t=Xs(this.targetBody,e);return new Ct(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function z5(a,e,t,i){hl(i);const n=kt(a);if(n0(t)){const o=Xs(t,n);if(i){const l=B5(e,n),h=new Ct(o.x-l.x,o.y-l.y,o.z-l.z,n),u=t0/h.Length();return new Ct(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,n)}const c=Xs(e,n);return new Ct(o.x-c.x,o.y-c.y,o.z-c.z,n)}let s;i?s=new Ct(0,0,0,n):s=Xs(e,n);const r=new k5(e,t,i,s);return F5(o=>r.Position(o),n)}function xd(a,e,t){hl(t);const i=kt(e);switch(a){case we.Earth:return new Ct(0,0,0,i);case we.Moon:return yr(i);default:const n=z5(i,we.Earth,a,t);return n.t=i,n}}function H5(a,e){return new Gs(a.r.x,a.r.y,a.r.z,a.v.x,a.v.y,a.v.z,e)}function B5(a,e){const t=kt(e);switch(a){case we.Sun:return new Gs(0,0,0,0,0,0,t);case we.SSB:const i=new Dl(t.tt);return new Gs(-i.Sun.r.x,-i.Sun.r.y,-i.Sun.r.z,-i.Sun.v.x,-i.Sun.v.y,-i.Sun.v.z,t);case we.Mercury:case we.Venus:case we.Earth:case we.Mars:case we.Jupiter:case we.Saturn:case we.Uranus:case we.Neptune:const n=md($n[a],t.tt);return H5(n,t);case we.Pluto:return Qg(t);case we.Moon:case we.EMB:const s=md($n.Earth,t.tt),r=a==we.Moon?$g(t):I5(t);return new Gs(r.x+s.r.x,r.y+s.r.y,r.z+s.r.z,r.vx+s.v.x,r.vy+s.v.y,r.vz+s.v.z,t);default:if(n0(a)){const o=Xs(a,t);return new Gs(o.x,o.y,o.z,0,0,0,t)}throw`HelioState: Unsupported body "${a}"`}}function G5(a){for(;a<0;)a+=360;for(;a>=360;)a-=360;return a}function V5(a,e,t){if(a===we.Earth||e===we.Earth)throw"The Earth does not have a longitude as seen from itself.";const i=kt(t),n=xd(a,i,!1),s=hd(n),r=xd(e,i,!1),o=hd(r);return G5(s.elon-o.elon)}function W5(a,e,t,i){let n,s=0,r=0,o=0;switch(a){case we.Mercury:n=-.6,s=4.98,r=-4.88,o=3.02;break;case we.Venus:e<163.6?(n=-4.47,s=1.03,r=.57,o=.13):(n=.98,s=-1.02);break;case we.Mars:n=-1.52,s=1.6;break;case we.Jupiter:n=-9.4,s=.5;break;case we.Uranus:n=-7.19,s=.25;break;case we.Neptune:n=-6.87;break;case we.Pluto:n=-1,s=4;break;default:throw`VisualMagnitude: unsupported body ${a}`}const c=e/100;let l=n+c*(s+c*(r+c*o));return l+=5*Math.log10(t*i),l}function X5(a,e,t,i,n){const s=hd(i),r=Mt*28.06,o=Mt*(169.51+382e-7*n.tt),c=Mt*s.elat,l=Mt*s.elon,h=Math.asin(Math.sin(c)*Math.cos(r)-Math.cos(c)*Math.sin(r)*Math.sin(l-o)),u=Math.sin(Math.abs(h));let d=-9+.044*a;return d+=u*(-2.6+1.2*u),d+=5*Math.log10(e*t),{mag:d,ring_tilt:jn*h}}function q5(a,e,t){let i=a*Mt,n=i*i,s=n*n,r=-12.717+1.49*Math.abs(i)+.0431*s;const o=385000.6/la;let c=t/o;return r+=5*Math.log10(e*c),r}class Y5{constructor(e,t,i,n,s,r,o,c){this.time=e,this.mag=t,this.phase_angle=i,this.helio_dist=n,this.geo_dist=s,this.gc=r,this.hc=o,this.ring_tilt=c,this.phase_fraction=(1+Math.cos(Mt*i))/2}}function e1(a,e){if(a===we.Earth)throw"The illumination of the Earth is not defined.";const t=kt(e),i=pr($n.Earth,t);let n,s,r,o;a===we.Sun?(r=new Ct(-i.x,-i.y,-i.z,t),s=new Ct(0,0,0,t),n=0):(a===we.Moon?(r=yr(t),s=new Ct(i.x+r.x,i.y+r.y,i.z+r.z,t)):(s=Xs(a,e),r=new Ct(s.x-i.x,s.y-i.y,s.z-i.z,t)),n=d5(r,s));let c=r.Length(),l=s.Length(),h;if(a===we.Sun)o=l5+5*Math.log10(c);else if(a===we.Moon)o=q5(n,l,c);else if(a===we.Saturn){const u=X5(n,l,c,r,t);o=u.mag,h=u.ring_tilt}else o=W5(a,n,l,c);return new Y5(t,o,n,l,c,r,s,h)}function K5(a){return V5(we.Moon,we.Sun,a)}var Ap;(function(a){a[a.Pericenter=0]="Pericenter",a[a.Apocenter=1]="Apocenter"})(Ap||(Ap={}));function t1(a,e){return new Ks([[e.rot[0][0]*a.rot[0][0]+e.rot[1][0]*a.rot[0][1]+e.rot[2][0]*a.rot[0][2],e.rot[0][1]*a.rot[0][0]+e.rot[1][1]*a.rot[0][1]+e.rot[2][1]*a.rot[0][2],e.rot[0][2]*a.rot[0][0]+e.rot[1][2]*a.rot[0][1]+e.rot[2][2]*a.rot[0][2]],[e.rot[0][0]*a.rot[1][0]+e.rot[1][0]*a.rot[1][1]+e.rot[2][0]*a.rot[1][2],e.rot[0][1]*a.rot[1][0]+e.rot[1][1]*a.rot[1][1]+e.rot[2][1]*a.rot[1][2],e.rot[0][2]*a.rot[1][0]+e.rot[1][2]*a.rot[1][1]+e.rot[2][2]*a.rot[1][2]],[e.rot[0][0]*a.rot[2][0]+e.rot[1][0]*a.rot[2][1]+e.rot[2][0]*a.rot[2][2],e.rot[0][1]*a.rot[2][0]+e.rot[1][1]*a.rot[2][1]+e.rot[2][1]*a.rot[2][2],e.rot[0][2]*a.rot[2][0]+e.rot[1][2]*a.rot[2][1]+e.rot[2][2]*a.rot[2][2]]])}function l0(a,e){e=kt(e);const t=a.lat*Mt,i=a.lon*Mt,n=a.dist*Math.cos(t);return new Ct(n*Math.cos(i),n*Math.sin(i),a.dist*Math.sin(t),e)}function h0(a){const e=$5(a);return new ld(e.lon/15,e.lat,e.dist,a)}function $5(a){const e=a.x*a.x+a.y*a.y,t=Math.sqrt(e+a.z*a.z);let i,n;if(e===0){if(a.z===0)throw"Zero-length vector not allowed.";n=0,i=a.z<0?-90:90}else n=jn*Math.atan2(a.y,a.x),n<0&&(n+=360),i=jn*Math.atan2(a.z,Math.sqrt(e));return new Rl(i,n,t)}function i1(a,e){let t;if(vi(e),e<-90||e>90)return 0;if(a==="normal"||a==="jplhor"){let i=e;i<-1&&(i=-1),t=1.02/Math.tan((i+10.3/(i+5.11))*Mt)/60,a==="normal"&&e<-1&&(t*=(e+90)/89)}else if(!a)t=0;else throw`Invalid refraction option: ${a}`;return t}function mr(a,e){return new Ct(a.rot[0][0]*e.x+a.rot[1][0]*e.y+a.rot[2][0]*e.z,a.rot[0][1]*e.x+a.rot[1][1]*e.y+a.rot[2][1]*e.z,a.rot[0][2]*e.x+a.rot[1][2]*e.y+a.rot[2][2]*e.z,e.t)}function Z5(){return new Ks([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function J5(){return new Ks([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function n1(a){a=kt(a);const e=s0(a,_i.From2000),t=a0(a,_i.From2000);return t1(e,t)}function j5(a){a=kt(a);const e=a0(a,_i.Into2000),t=s0(a,_i.Into2000);return t1(e,t)}function Q5(a){const t=Do(kt(a)).tobl*Mt,i=Math.cos(t),n=Math.sin(t);return new Ks([[1,0,0],[0,+i,+n],[0,-n,+i]])}var Tp;(function(a){a.Penumbral="penumbral",a.Partial="partial",a.Annular="annular",a.Total="total"})(Tp||(Tp={}));var Rp;(function(a){a[a.Invalid=0]="Invalid",a[a.Ascending=1]="Ascending",a[a.Descending=-1]="Descending"})(Rp||(Rp={}));const ew=["Venus","Mars","Jupiter","Saturn"];function s1(a){return new c0(a.lat,a.lng,a.elevationM)}function u0(a,e,t,i,n=!0){const s=Yg(t,s1(i),a,e,n?"normal":void 0);return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}class En{up;north;west;constructor(e,t){const i=kt(e),n=Math.sin(t.lat*ls),s=Math.cos(t.lat*ls),r=Math.sin(t.lng*ls),o=Math.cos(t.lng*ls),c=-15*w5(i),l=j5(i);this.up=En.rotate(l,En.spin(c,[s*o,s*r,n]),i),this.north=En.rotate(l,En.spin(c,[-n*o,-n*r,s]),i),this.west=En.rotate(l,En.spin(c,[r,-o,0]),i)}static ofJ2000(e,t,i,n,s=!0){const r=kt(i),o=l0(new Rl(t,e*15,1),r),c=h0(mr(n1(r),o));return u0(c.ra,c.dec,i,n,s)}position(e,t){const i=Math.sin(t*ls),n=Math.cos(t*ls),s=Math.sin(e*Cp),r=Math.cos(e*Cp),o=n*r,c=n*s,l=i,h=o*this.up[0]+c*this.up[1]+l*this.up[2],u=o*this.north[0]+c*this.north[1]+l*this.north[2],d=o*this.west[0]+c*this.west[1]+l*this.west[2],f=Math.hypot(u,d);let p=0;f>0&&(p=-Dp*Math.atan2(d,u),p<0&&(p+=360));let v=Dp*Math.atan2(f,h);return v-=i1("normal",90-v),{altitudeDeg:90-v,azimuthDeg:p}}static spin(e,[t,i,n]){const s=Math.cos(e*ls),r=Math.sin(e*ls);return[s*t+r*i,s*i-r*t,n]}static rotate(e,[t,i,n],s){const r=mr(e,new Ct(t,i,n,s));return[r.x,r.y,r.z]}}const ls=Math.PI/180,Dp=180/Math.PI,Cp=15*ls;function Ah(a,e,t){const i=s1(t),n=D5(we[a],e,i,!0,!0),s=Yg(e,i,n.ra,n.dec,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function Th(a,e){return e1(we[a],e).mag}function tw(a){const e=K5(a),t=e1(we.Moon,a);return{phaseFraction:e/360,illuminatedFraction:t.phase_fraction}}const iw=2e3,nw=3,sw=20;function yc(a,e,t){if(a.year===void 0&&a.month===void 0&&a.day===void 0&&a.hour===void 0)return;const i=a.year!==void 0,n=a.year??iw,s=a.month??(i?1:nw),r=a.day??(i?1:sw),o=t??Math.round(e/15);return new Date(Date.UTC(n,s-1,r,(a.hour??12)-o,a.minute??0,a.second??0))}class Bn{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static FALLOFF={core:Bn.CORE,rim:Bn.RIM};static apply(e){e.transparent=!0,e.depthWrite=!1,e.onBeforeCompile=t=>{t.fragmentShader=Bn.patch(t.fragmentShader)}}static patch(e){return e.replace(Bn.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
|
|
5424
|
+
*/const t0=173.1446326846693,la=14959787069098932e-8,Mt=.017453292519943295,yp=.26179938779914946,jn=57.29577951308232,Hg=3.819718634205488,r5=365.24217,_p=new Date("2000-01-01T12:00:00Z"),os=2*Math.PI,Ls=3600*(180/Math.PI),tr=484813681109536e-20,Bg=10800*60,o5=2*Bg,Sp=7292115e-11,c5=Bg/Math.PI,l5=-.17-5*Math.log10(c5),id=.996647180302104,h5=id*id,nd=6378.1366,u5=nd/la,Gg=81.30056,i0=.0002959122082855911,sd=2825345909524226e-22,ad=8459715185680659e-23,rd=1292024916781969e-23,od=1524358900784276e-23;function hl(a){if(a!==!0&&a!==!1)throw console.trace(),`Value is not boolean: ${a}`;return a}function Mi(a){if(!Number.isFinite(a))throw console.trace(),`Value is not a finite number: ${a}`;return a}function $a(a){return a-Math.floor(a)}function d5(a,e){const t=a.x*a.x+a.y*a.y+a.z*a.z;if(Math.abs(t)<1e-8)throw"AngleBetween: first vector is too short.";const i=e.x*e.x+e.y*e.y+e.z*e.z;if(Math.abs(i)<1e-8)throw"AngleBetween: second vector is too short.";const n=(a.x*e.x+a.y*e.y+a.z*e.z)/Math.sqrt(t*i);return n<=-1?180:n>=1?0:jn*Math.acos(n)}var we;(function(a){a.Sun="Sun",a.Moon="Moon",a.Mercury="Mercury",a.Venus="Venus",a.Earth="Earth",a.Mars="Mars",a.Jupiter="Jupiter",a.Saturn="Saturn",a.Uranus="Uranus",a.Neptune="Neptune",a.Pluto="Pluto",a.SSB="SSB",a.EMB="EMB",a.Star1="Star1",a.Star2="Star2",a.Star3="Star3",a.Star4="Star4",a.Star5="Star5",a.Star6="Star6",a.Star7="Star7",a.Star8="Star8"})(we||(we={}));const f5=[we.Star1,we.Star2,we.Star3,we.Star4,we.Star5,we.Star6,we.Star7,we.Star8],p5=[{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 m5(a){const e=f5.indexOf(a);return e>=0?p5[e]:null}function n0(a){const e=m5(a);return e&&e.dist>0?e:null}var Si;(function(a){a[a.From2000=0]="From2000",a[a.Into2000=1]="Into2000"})(Si||(Si={}));const $n={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 g5(a){var e,t,i,n,s,r,o;const c=2e3+(a-14)/r5;return c<-500?(e=(c-1820)/100,-20+32*e*e):c<500?(e=c/100,t=e*e,i=e*t,n=t*t,s=t*i,r=i*i,10583.6-1014.41*e+33.78311*t-5.952053*i-.1798452*n+.022174192*s+.0090316521*r):c<1600?(e=(c-1e3)/100,t=e*e,i=e*t,n=t*t,s=t*i,r=i*i,1574.2-556.01*e+71.23472*t+.319781*i-.8503463*n-.005050998*s+.0083572073*r):c<1700?(e=c-1600,t=e*e,i=e*t,120-.9808*e-.01532*t+i/7129):c<1800?(e=c-1700,t=e*e,i=e*t,n=t*t,8.83+.1603*e-.0059285*t+13336e-8*i-n/1174e3):c<1860?(e=c-1800,t=e*e,i=e*t,n=t*t,s=t*i,r=i*i,o=i*n,13.72-.332447*e+.0068612*t+.0041116*i-37436e-8*n+121272e-10*s-1699e-10*r+875e-12*o):c<1900?(e=c-1860,t=e*e,i=e*t,n=t*t,s=t*i,7.62+.5737*e-.251754*t+.01680668*i-.0004473624*n+s/233174):c<1920?(e=c-1900,t=e*e,i=e*t,n=t*t,-2.79+1.494119*e-.0598939*t+.0061966*i-197e-6*n):c<1941?(e=c-1920,t=e*e,i=e*t,21.2+.84493*e-.0761*t+.0020936*i):c<1961?(e=c-1950,t=e*e,i=e*t,29.07+.407*e-t/233+i/2547):c<1986?(e=c-1975,t=e*e,i=e*t,45.45+1.067*e-t/260-i/718):c<2005?(e=c-2e3,t=e*e,i=e*t,n=t*t,s=t*i,63.86+.3345*e-.060374*t+.0017275*i+651814e-9*n+2373599e-11*s):c<2050?(e=c-2e3,62.92+.32217*e+.005589*e*e):c<2150?(e=(c-1820)/100,-20+32*e*e-.5628*(2150-c)):(e=(c-1820)/100,-20+32*e*e)}let v5=g5;function wp(a){return a+v5(a)/86400}class dr{constructor(e){if(e instanceof dr){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()-_p.getTime())/t,this.tt=wp(this.ut);return}if(Number.isFinite(e)){this.date=new Date(_p.getTime()+e*t),this.ut=e,this.tt=wp(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 dr(e);for(;;){const i=e-t.tt;if(Math.abs(i)<1e-12)return t;t=t.AddDays(i)}}toString(){return this.date.toISOString()}AddDays(e){return new dr(this.ut+e)}}function zt(a){return a instanceof dr?a:new dr(a)}function M5(a){function e(d){return d%o5*tr}const t=a.tt/36525,i=e(128710479305e-5+t*1295965810481e-4),n=e(335779.526232+t*17395272628478e-4),s=e(107226070369e-5+t*1602961601209e-3),r=e(450160.398036-t*69628905431e-4);let o=Math.sin(r),c=Math.cos(r),l=(-172064161-174666*t)*o+33386*c,h=(92052331+9086*t)*c+15377*o,u=2*(n-s+r);return o=Math.sin(u),c=Math.cos(u),l+=(-13170906-1675*t)*o-13696*c,h+=(5730336-3015*t)*c-4587*o,u=2*(n+r),o=Math.sin(u),c=Math.cos(u),l+=(-2276413-234*t)*o+2796*c,h+=(978459-485*t)*c+1374*o,u=2*r,o=Math.sin(u),c=Math.cos(u),l+=(2074554+207*t)*o-698*c,h+=(-897492+470*t)*c-291*o,o=Math.sin(i),c=Math.cos(i),l+=(1475877-3633*t)*o+11817*c,h+=(73871-184*t)*c-1924*o,{dpsi:-135e-6+l*1e-7,deps:388e-6+h*1e-7}}function Vg(a){var e=a.tt/36525,t=((((-434e-10*e-576e-9)*e+.0020034)*e-1831e-7)*e-46.836769)*e+84381.406;return t/3600}var gc;function Do(a){if(!gc||Math.abs(gc.tt-a.tt)>1e-6){const e=M5(a),t=Vg(a),i=t+e.deps/3600;gc={tt:a.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*Mt)/15,mobl:t,tobl:i}}return gc}function x5(a,e){const t=a*Mt,i=Math.cos(t),n=Math.sin(t);return[e[0],e[1]*i-e[2]*n,e[1]*n+e[2]*i]}function y5(a,e){return x5(Vg(a),e)}function _5(a){const e=a.tt/36525;function t(Ce,ye){const Fe=[];let ke;for(ke=0;ke<=ye-Ce;++ke)Fe.push(0);return{min:Ce,array:Fe}}function i(Ce,ye,Fe,ke){const ze=[];for(let ft=0;ft<=ye-Ce;++ft)ze.push(t(Fe,ke));return{min:Ce,array:ze}}function n(Ce,ye,Fe){const ke=Ce.array[ye-Ce.min];return ke.array[Fe-ke.min]}function s(Ce,ye,Fe,ke){const ze=Ce.array[ye-Ce.min];ze.array[Fe-ze.min]=ke}let r,o,c,l,h,u,d,f,p,v,m,g,_,w,M,S,b,T,x,A,I,C,P,X=i(-6,6,1,4),z=i(-6,6,1,4);function N(Ce,ye){return n(X,Ce,ye)}function V(Ce,ye){return n(z,Ce,ye)}function k(Ce,ye,Fe){return s(X,Ce,ye,Fe)}function K(Ce,ye,Fe){return s(z,Ce,ye,Fe)}function ee(Ce,ye,Fe,ke,ze){ze(Ce*Fe-ye*ke,ye*Fe+Ce*ke)}function J(Ce){return Math.sin(os*Ce)}d=e*e,p=0,P=0,m=0,g=3422.7;var ie=J(.19833+.05611*e),oe=J(.27869+.04508*e),Ve=J(.16827-.36903*e),Qe=J(.34734-5.37261*e),qe=J(.10498-5.37899*e),Y=J(.42681-.41855*e),re=J(.14943-5.37511*e);for(T=.84*ie+.31*oe+14.27*Ve+7.26*Qe+.28*qe+.24*Y,x=2.94*ie+.31*oe+14.27*Ve+9.34*Qe+1.12*qe+.83*Y,A=-6.4*ie-1.89*Y,I=.21*ie+.31*oe+14.27*Ve-88.7*Qe-15.3*qe+.24*Y-1.86*re,C=T-A,f=-3332e-9*J(.59734-5.37261*e)-539e-9*J(.35498-5.37899*e)-64e-9*J(.39943-5.37511*e),_=os*$a(.60643382+1336.85522467*e-313e-8*d)+T/Ls,w=os*$a(.37489701+1325.55240982*e+2565e-8*d)+x/Ls,M=os*$a(.99312619+99.99735956*e-44e-8*d)+A/Ls,S=os*$a(.25909118+1342.2278298*e-892e-8*d)+I/Ls,b=os*$a(.82736186+1236.85308708*e-397e-8*d)+C/Ls,h=1;h<=4;++h){switch(h){case 1:c=w,o=4,l=1.000002208;break;case 2:c=M,o=3,l=.997504612-.002495388*e;break;case 3:c=S,o=4,l=1.000002708+139.978*f;break;case 4:c=b,o=6,l=1;break;default:throw`Internal error: I = ${h}`}for(k(0,h,1),k(1,h,Math.cos(c)*l),K(0,h,0),K(1,h,Math.sin(c)*l),u=2;u<=o;++u)ee(N(u-1,h),V(u-1,h),N(1,h),V(1,h),(Ce,ye)=>(k(u,h,Ce),K(u,h,ye)));for(u=1;u<=o;++u)k(-u,h,N(u,h)),K(-u,h,-V(u,h))}function ne(Ce,ye,Fe,ke){for(var ze={x:1,y:0},ft=[0,Ce,ye,Fe,ke],pt=1;pt<=4;++pt)ft[pt]!==0&&ee(ze.x,ze.y,N(ft[pt],pt),V(ft[pt],pt),(Ht,Lt)=>(ze.x=Ht,ze.y=Lt));return ze}function H(Ce,ye,Fe,ke,ze,ft,pt,Ht){var Lt=ne(ze,ft,pt,Ht);p+=Ce*Lt.y,P+=ye*Lt.y,m+=Fe*Lt.x,g+=ke*Lt.x}H(13.902,14.06,-.001,.2607,0,0,0,4),H(.403,-4.01,.394,.0023,0,0,0,3),H(2369.912,2373.36,.601,28.2333,0,0,0,2),H(-125.154,-112.79,-.725,-.9781,0,0,0,1),H(1.979,6.98,-.445,.0433,1,0,0,4),H(191.953,192.72,.029,3.0861,1,0,0,2),H(-8.466,-13.51,.455,-.1093,1,0,0,1),H(22639.5,22609.07,.079,186.5398,1,0,0,0),H(18.609,3.59,-.094,.0118,1,0,0,-1),H(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),H(3.215,5.44,.192,-.0386,1,0,0,-3),H(-38.428,-38.64,.001,.6008,1,0,0,-4),H(-.393,-1.43,-.092,.0086,1,0,0,-6),H(-.289,-1.59,.123,-.0053,0,1,0,4),H(-24.42,-25.1,.04,-.3,0,1,0,2),H(18.023,17.93,.007,.1494,0,1,0,1),H(-668.146,-126.98,-1.302,-.3997,0,1,0,0),H(.56,.32,-.001,-.0037,0,1,0,-1),H(-165.145,-165.06,.054,1.9178,0,1,0,-2),H(-1.877,-6.46,-.416,.0339,0,1,0,-4),H(.213,1.02,-.074,.0054,2,0,0,4),H(14.387,14.78,-.017,.2833,2,0,0,2),H(-.586,-1.2,.054,-.01,2,0,0,1),H(769.016,767.96,.107,10.1657,2,0,0,0),H(1.75,2.01,-.018,.0155,2,0,0,-1),H(-211.656,-152.53,5.679,-.3039,2,0,0,-2),H(1.225,.91,-.03,-.0088,2,0,0,-3),H(-30.773,-34.07,-.308,.3722,2,0,0,-4),H(-.57,-1.4,-.074,.0109,2,0,0,-6),H(-2.921,-11.75,.787,-.0484,1,1,0,2),H(1.267,1.52,-.022,.0164,1,1,0,1),H(-109.673,-115.18,.461,-.949,1,1,0,0),H(-205.962,-182.36,2.056,1.4437,1,1,0,-2),H(.233,.36,.012,-.0025,1,1,0,-3),H(-4.391,-9.66,-.471,.0673,1,1,0,-4),H(.283,1.53,-.111,.006,1,-1,0,4),H(14.577,31.7,-1.54,.2302,1,-1,0,2),H(147.687,138.76,.679,1.1528,1,-1,0,0),H(-1.089,.55,.021,0,1,-1,0,-1),H(28.475,23.59,-.443,-.2257,1,-1,0,-2),H(-.276,-.38,-.006,-.0036,1,-1,0,-3),H(.636,2.27,.146,-.0102,1,-1,0,-4),H(-.189,-1.68,.131,-.0028,0,2,0,2),H(-7.486,-.66,-.037,-.0086,0,2,0,0),H(-8.096,-16.35,-.74,.0918,0,2,0,-2),H(-5.741,-.04,0,-9e-4,0,0,2,2),H(.255,0,0,0,0,0,2,1),H(-411.608,-.2,0,-.0124,0,0,2,0),H(.584,.84,0,.0071,0,0,2,-1),H(-55.173,-52.14,0,-.1052,0,0,2,-2),H(.254,.25,0,-.0017,0,0,2,-3),H(.025,-1.67,0,.0031,0,0,2,-4),H(1.06,2.96,-.166,.0243,3,0,0,2),H(36.124,50.64,-1.3,.6215,3,0,0,0),H(-13.193,-16.4,.258,-.1187,3,0,0,-2),H(-1.187,-.74,.042,.0074,3,0,0,-4),H(-.293,-.31,-.002,.0046,3,0,0,-6),H(-.29,-1.45,.116,-.0051,2,1,0,2),H(-7.649,-10.56,.259,-.1038,2,1,0,0),H(-8.627,-7.59,.078,-.0192,2,1,0,-2),H(-2.74,-2.54,.022,.0324,2,1,0,-4),H(1.181,3.32,-.212,.0213,2,-1,0,2),H(9.703,11.67,-.151,.1268,2,-1,0,0),H(-.352,-.37,.001,-.0028,2,-1,0,-1),H(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),H(.36,.2,-.012,-.0043,2,-1,0,-4),H(-1.167,-1.25,.008,-.0106,1,2,0,0),H(-7.412,-6.12,.117,.0484,1,2,0,-2),H(-.311,-.65,-.032,.0044,1,2,0,-4),H(.757,1.82,-.105,.0112,1,-2,0,2),H(2.58,2.32,.027,.0196,1,-2,0,0),H(2.533,2.4,-.014,-.0212,1,-2,0,-2),H(-.344,-.57,-.025,.0036,0,3,0,-2),H(-.992,-.02,0,0,1,0,2,2),H(-45.099,-.02,0,-.001,1,0,2,0),H(-.179,-9.52,0,-.0833,1,0,2,-2),H(-.301,-.33,0,.0014,1,0,2,-4),H(-6.382,-3.37,0,-.0481,1,0,-2,2),H(39.528,85.13,0,-.7136,1,0,-2,0),H(9.366,.71,0,-.0112,1,0,-2,-2),H(.202,.02,0,0,1,0,-2,-4),H(.415,.1,0,.0013,0,1,2,0),H(-2.152,-2.26,0,-.0066,0,1,2,-2),H(-1.44,-1.3,0,.0014,0,1,-2,2),H(.384,-.04,0,0,0,1,-2,-2),H(1.938,3.6,-.145,.0401,4,0,0,0),H(-.952,-1.58,.052,-.013,4,0,0,-2),H(-.551,-.94,.032,-.0097,3,1,0,0),H(-.482,-.57,.005,-.0045,3,1,0,-2),H(.681,.96,-.026,.0115,3,-1,0,0),H(-.297,-.27,.002,-9e-4,2,2,0,-2),H(.254,.21,-.003,0,2,-2,0,-2),H(-.25,-.22,.004,.0014,1,3,0,-2),H(-3.996,0,0,4e-4,2,0,2,0),H(.557,-.75,0,-.009,2,0,2,-2),H(-.459,-.38,0,-.0053,2,0,-2,2),H(-1.298,.74,0,4e-4,2,0,-2,0),H(.538,1.14,0,-.0141,2,0,-2,-2),H(.263,.02,0,0,1,1,2,0),H(.426,.07,0,-6e-4,1,1,-2,-2),H(-.304,.03,0,3e-4,1,-1,2,0),H(-.372,-.19,0,-.0027,1,-1,-2,2),H(.418,0,0,0,0,0,4,0),H(-.33,-.04,0,0,3,0,2,0);function Ae(Ce,ye,Fe,ke,ze){return Ce*ne(ye,Fe,ke,ze).y}v=0,v+=Ae(-526.069,0,0,1,-2),v+=Ae(-3.352,0,0,1,-4),v+=Ae(44.297,1,0,1,-2),v+=Ae(-6,1,0,1,-4),v+=Ae(20.599,-1,0,1,0),v+=Ae(-30.598,-1,0,1,-2),v+=Ae(-24.649,-2,0,1,0),v+=Ae(-2,-2,0,1,-2),v+=Ae(-22.571,0,1,1,-2),v+=Ae(10.985,0,-1,1,-2),p+=.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),r=S+P/Ls;let Ne=(1.000002708+139.978*f)*(18518.511+1.189+m)*Math.sin(r)-6.24*Math.sin(3*r)+v;return{geo_eclip_lon:os*$a((_+p/Ls)/os),geo_eclip_lat:Math.PI/(180*3600)*Ne,distance_au:Ls*u5/(.999953253*g)}}function Wg(a,e){return[a.rot[0][0]*e[0]+a.rot[1][0]*e[1]+a.rot[2][0]*e[2],a.rot[0][1]*e[0]+a.rot[1][1]*e[1]+a.rot[2][1]*e[2],a.rot[0][2]*e[0]+a.rot[1][2]*e[1]+a.rot[2][2]*e[2]]}function ul(a,e,t){const i=s0(e,t);return Wg(i,a)}function s0(a,e){const t=a.tt/36525;let i=84381.406,n=((((-951e-10*t+132851e-9)*t-.00114045)*t-1.0790069)*t+5038.481507)*t,s=((((3337e-10*t-467e-9)*t-.00772503)*t+.0512623)*t-.025754)*t+i,r=((((-56e-9*t+170663e-9)*t-.00121197)*t-2.3814292)*t+10.556403)*t;i*=tr,n*=tr,s*=tr,r*=tr;const o=Math.sin(i),c=Math.cos(i),l=Math.sin(-n),h=Math.cos(-n),u=Math.sin(-s),d=Math.cos(-s),f=Math.sin(r),p=Math.cos(r),v=p*h-l*f*d,m=p*l*c+f*d*h*c-o*f*u,g=p*l*o+f*d*h*o+c*f*u,_=-f*h-l*p*d,w=-f*l*c+p*d*h*c-o*p*u,M=-f*l*o+p*d*h*o+c*p*u,S=l*u,b=-u*h*c-o*d,T=-u*h*o+d*c;if(e===Si.Into2000)return new Ks([[v,m,g],[_,w,M],[S,b,T]]);if(e===Si.From2000)return new Ks([[v,_,S],[m,w,b],[g,M,T]]);throw"Invalid precess direction"}function S5(a){const e=.779057273264+.00273781191135448*a.ut,t=a.ut%1;let i=360*((e+t)%1);return i<0&&(i+=360),i}let vc;function Tl(a){if(!vc||vc.tt!==a.tt){const e=a.tt/36525;let t=15*Do(a).ee;const i=S5(a);let s=((t+.014506+((((-368e-10*e-29956e-9)*e-44e-8)*e+1.3915817)*e+4612.156534)*e)/3600+i)%360/15;s<0&&(s+=24),vc={tt:a.tt,st:s}}return vc.st}function w5(a){const e=zt(a);return Tl(e)}function Xg(a,e){const t=a.latitude*Mt,i=Math.sin(t),n=Math.cos(t),s=1/Math.hypot(n,id*i),r=h5*s,o=a.height/1e3,c=nd*s+o,l=nd*r+o,h=(15*e+a.longitude)*Mt,u=Math.sin(h),d=Math.cos(h);return{pos:[c*n*d/la,c*n*u/la,l*i/la],vel:[-Sp*c*n*u*86400/la,Sp*c*n*d*86400/la,0]}}function cd(a,e,t){const i=a0(e,t);return Wg(i,a)}function a0(a,e){const t=Do(a),i=t.mobl*Mt,n=t.tobl*Mt,s=t.dpsi*tr,r=Math.cos(i),o=Math.sin(i),c=Math.cos(n),l=Math.sin(n),h=Math.cos(s),u=Math.sin(s),d=h,f=-u*r,p=-u*o,v=u*c,m=h*r*c+o*l,g=h*o*c-r*l,_=u*l,w=h*r*l-o*c,M=h*o*l+r*c;if(e===Si.From2000)return new Ks([[d,v,_],[f,m,w],[p,g,M]]);if(e===Si.Into2000)return new Ks([[d,f,p],[v,m,g],[_,w,M]]);throw"Invalid precess direction"}function r0(a,e,t){return t===Si.Into2000?ul(cd(a,e,t),e,t):cd(ul(a,e,t),e,t)}function b5(a,e){const t=Tl(a),i=Xg(e,t).pos;return r0(i,a,Si.Into2000)}class Ct{constructor(e,t,i,n){this.x=e,this.y=t,this.z=i,this.t=n}Length(){return Math.hypot(this.x,this.y,this.z)}}class Gs{constructor(e,t,i,n,s,r,o){this.x=e,this.y=t,this.z=i,this.vx=n,this.vy=s,this.vz=r,this.t=o}}class Rl{constructor(e,t,i){this.lat=Mi(e),this.lon=Mi(t),this.dist=Mi(i)}}class ld{constructor(e,t,i,n){this.ra=Mi(e),this.dec=Mi(t),this.dist=Mi(i),this.vec=n}}class Ks{constructor(e){this.rot=e}}class E5{constructor(e,t,i,n){this.azimuth=Mi(e),this.altitude=Mi(t),this.ra=Mi(i),this.dec=Mi(n)}}class A5{constructor(e,t,i){this.vec=e,this.elat=Mi(t),this.elon=Mi(i)}}function qg(a,e){return new Ct(a[0],a[1],a[2],e)}function T5(a,e){const t=qg(a,e),i=t.x*t.x+t.y*t.y,n=Math.sqrt(i+t.z*t.z);if(i===0){if(t.z===0)throw"Indeterminate sky coordinates";return new ld(0,t.z<0?-90:90,n,t)}let s=Hg*Math.atan2(t.y,t.x);s<0&&(s+=24);const r=jn*Math.atan2(a[2],Math.sqrt(i));return new ld(s,r,n,t)}function bh(a,e){const t=a*Mt,i=Math.cos(t),n=Math.sin(t);return[i*e[0]+n*e[1],i*e[1]-n*e[0],e[2]]}function Yg(a,e,t,i,n){let s=zt(a);o0(e),Mi(t),Mi(i);const r=Math.sin(e.latitude*Mt),o=Math.cos(e.latitude*Mt),c=Math.sin(e.longitude*Mt),l=Math.cos(e.longitude*Mt),h=Math.sin(i*Mt),u=Math.cos(i*Mt),d=Math.sin(t*yp),f=Math.cos(t*yp);let p=[o*l,o*c,r],v=[-r*l,-r*c,o],m=[c,-l,0];const g=-15*Tl(s);let _=bh(g,p),w=bh(g,v),M=bh(g,m),S=[u*f,u*d,h];const b=S[0]*_[0]+S[1]*_[1]+S[2]*_[2],T=S[0]*w[0]+S[1]*w[1]+S[2]*w[2],x=S[0]*M[0]+S[1]*M[1]+S[2]*M[2];let A=Math.hypot(T,x),I;A>0?(I=-jn*Math.atan2(x,T),I<0&&(I+=360)):I=0;let C=jn*Math.atan2(A,b),P=t,X=i;if(n){let z=C,N=i1(n,90-C);if(C-=N,N>0&&C>3e-4){const V=Math.sin(C*Mt),k=Math.cos(C*Mt),K=Math.sin(z*Mt),ee=Math.cos(z*Mt),J=[];for(let ie=0;ie<3;++ie)J.push((S[ie]-ee*_[ie])/K*V+_[ie]*k);A=Math.hypot(J[0],J[1]),A>0?(P=Hg*Math.atan2(J[1],J[0]),P<0&&(P+=24)):P=0,X=jn*Math.atan2(J[2],A)}}return new E5(I,90-C,P,X)}function o0(a){if(!(a instanceof c0))throw`Not an instance of the Observer class: ${a}`;if(Mi(a.latitude),Mi(a.longitude),Mi(a.height),a.latitude<-90||a.latitude>90)throw`Latitude ${a.latitude} is out of range. Must be -90..+90.`;return a}class c0{constructor(e,t,i){this.latitude=e,this.longitude=t,this.height=i,o0(this)}}function R5(a){const e=zt(a).AddDays(-1/t0),t=pr($n.Earth,e),i=[-t.x,-t.y,-t.z],[n,s,r]=r0(i,e,Si.From2000),o=Mt*Do(e).tobl,c=Math.cos(o),l=Math.sin(o),h=new Ct(n,s,r,e);return Kg(h,c,l)}function D5(a,e,t,i,n){o0(t),hl(i),hl(n);const s=zt(e),r=b5(s,t),o=xd(a,s,n),c=[o.x-r[0],o.y-r[1],o.z-r[2]],l=r0(c,s,Si.From2000);return T5(l,s)}function C5(a,e,t){const i=zt(a),n=Tl(i);let s=Xg(e,n).pos;return qg(s,i)}function Kg(a,e,t){const i=a.x,n=a.y*e+a.z*t,s=-a.y*t+a.z*e,r=Math.hypot(i,n);let o=0;r>0&&(o=jn*Math.atan2(n,i),o<0&&(o+=360));let c=jn*Math.atan2(s,r),l=new Ct(i,n,s,a.t);return new A5(l,c,o)}function hd(a){const e=Do(a.t),t=[a.x,a.y,a.z],i=ul(t,a.t,Si.From2000),[n,s,r]=cd(i,a.t,Si.From2000),o=new Ct(n,s,r,a.t),c=e.tobl*Mt;return Kg(o,Math.cos(c),Math.sin(c))}function yr(a){const e=zt(a),t=_5(e),i=t.distance_au*Math.cos(t.geo_eclip_lat),n=[i*Math.cos(t.geo_eclip_lon),i*Math.sin(t.geo_eclip_lon),t.distance_au*Math.sin(t.geo_eclip_lat)],s=y5(e,n),r=ul(s,e,Si.Into2000);return new Ct(r[0],r[1],r[2],e)}function $g(a){const e=zt(a),t=1e-5,i=e.AddDays(-t),n=e.AddDays(+t),s=yr(i),r=yr(n);return new Gs((s.x+r.x)/2,(s.y+r.y)/2,(s.z+r.z)/2,(r.x-s.x)/(2*t),(r.y-s.y)/(2*t),(r.z-s.z)/(2*t),e)}function I5(a){const e=zt(a),t=$g(e),i=1+Gg;return new Gs(t.x/i,t.y/i,t.z/i,t.vx/i,t.vy/i,t.vz/i,e)}function fr(a,e,t){let i=1,n=0;for(let s of a){let r=0;for(let[c,l,h]of s)r+=c*Math.cos(l+e*h);let o=i*r;t&&(o%=os),n+=o,i*=e}return n}function Eh(a,e){let t=1,i=0,n=0,s=0;for(let r of a){let o=0,c=0;for(let[l,h,u]of r){let d=h+e*u;o+=l*u*Math.sin(d),s>0&&(c+=l*Math.cos(d))}n+=s*i*c-t*o,i=t,t*=e,++s}return n}const Qr=365250,ud=0,dd=1,fd=2;function pd(a){return new Ri(a[0]+44036e-11*a[1]-190919e-12*a[2],-479966e-12*a[0]+.917482137087*a[1]-.397776982902*a[2],.397776982902*a[1]+.917482137087*a[2])}function Zg(a,e,t){const i=t*Math.cos(e),n=Math.cos(a),s=Math.sin(a);return[i*n,i*s,t*Math.sin(e)]}function pr(a,e){const t=e.tt/Qr,i=fr(a[ud],t,!0),n=fr(a[dd],t,!1),s=fr(a[fd],t,!1),r=Zg(i,n,s);return pd(r).ToAstroVector(e)}function md(a,e){const t=e/Qr,i=fr(a[ud],t,!0),n=fr(a[dd],t,!1),s=fr(a[fd],t,!1),r=Eh(a[ud],t),o=Eh(a[dd],t),c=Eh(a[fd],t),l=Math.cos(i),h=Math.sin(i),u=Math.cos(n),d=Math.sin(n),f=+(c*u*l)-s*d*l*o-s*u*h*r,p=+(c*u*h)-s*d*h*o+s*u*l*r,v=+(c*d)+s*u*o,m=Zg(i,n,s),g=[f/Qr,p/Qr,v/Qr],_=pd(m),w=pd(g);return new Sa(e,_,w)}function Mc(a,e,t,i){const n=i/(i+i0),s=pr($n[t],e);a.x+=n*s.x,a.y+=n*s.y,a.z+=n*s.z}function P5(a){const e=new Ct(0,0,0,a);return Mc(e,a,we.Jupiter,sd),Mc(e,a,we.Saturn,ad),Mc(e,a,we.Uranus,rd),Mc(e,a,we.Neptune,od),e}const gd=51,L5=29200,ir=146,cs=201,ma=[[-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 Ri{constructor(e,t,i){this.x=e,this.y=t,this.z=i}clone(){return new Ri(this.x,this.y,this.z)}ToAstroVector(e){return new Ct(this.x,this.y,this.z,e)}static zero(){return new Ri(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new Ri(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new Ri(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 Ri(e*this.x,e*this.y,e*this.z)}div(e){return new Ri(this.x/e,this.y/e,this.z/e)}mean(e){return new Ri((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new Ri(-this.x,-this.y,-this.z)}}class Sa{constructor(e,t,i){this.tt=e,this.r=t,this.v=i}clone(){return new Sa(this.tt,this.r,this.v)}sub(e){return new Sa(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function N5(a){let[e,[t,i,n],[s,r,o]]=a;return new Sa(e,new Ri(t,i,n),new Ri(s,r,o))}function xc(a,e,t,i){const n=i/(i+i0),s=md($n[t],e);return a.r.incr(s.r.mul(n)),a.v.incr(s.v.mul(n)),s}function Gr(a,e,t){const i=t.sub(a),n=i.quadrature();return i.mul(e/(n*Math.sqrt(n)))}class Dl{constructor(e){let t=new Sa(e,new Ri(0,0,0),new Ri(0,0,0));this.Jupiter=xc(t,e,we.Jupiter,sd),this.Saturn=xc(t,e,we.Saturn,ad),this.Uranus=xc(t,e,we.Uranus,rd),this.Neptune=xc(t,e,we.Neptune,od),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 Sa(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=Gr(e,i0,this.Sun.r);return t.incr(Gr(e,sd,this.Jupiter.r)),t.incr(Gr(e,ad,this.Saturn.r)),t.incr(Gr(e,rd,this.Uranus.r)),t.incr(Gr(e,od,this.Neptune.r)),t}}class Cl{constructor(e,t,i,n){this.tt=e,this.r=t,this.v=i,this.a=n}clone(){return new Cl(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class Jg{constructor(e,t){this.bary=e,this.grav=t}}function dl(a,e,t,i){return new Ri(e.x+a*(t.x+a*i.x/2),e.y+a*(t.y+a*i.y/2),e.z+a*(t.z+a*i.z/2))}function bp(a,e,t){return new Ri(e.x+a*t.x,e.y+a*t.y,e.z+a*t.z)}function vd(a,e){const t=a-e.tt,i=new Dl(a),n=dl(t,e.r,e.v,e.a),s=i.Acceleration(n).mean(e.a),r=dl(t,e.r,e.v,s),o=e.v.add(s.mul(t)),c=i.Acceleration(r),l=new Cl(a,r,o,c);return new Jg(i,l)}const O5=[];function jg(a,e){const t=Math.floor(a);return t<0?0:t>=e?e-1:t}function Md(a){const e=N5(a),t=new Dl(e.tt),i=e.r.add(t.Sun.r),n=e.v.add(t.Sun.v),s=t.Acceleration(i),r=new Cl(e.tt,i,n,s);return new Jg(t,r)}function U5(a,e){const t=ma[0][0];if(e<t||e>ma[gd-1][0])return null;const i=jg((e-t)/L5,gd-1);if(!a[i]){const s=a[i]=[];s[0]=Md(ma[i]).grav,s[cs-1]=Md(ma[i+1]).grav;let r,o=s[0].tt;for(r=1;r<cs-1;++r)s[r]=vd(o+=ir,s[r-1]).grav;o=s[cs-1].tt;var n=[];for(n[cs-1]=s[cs-1],r=cs-2;r>0;--r)n[r]=vd(o-=ir,n[r+1]).grav;for(r=cs-2;r>0;--r){const c=r/(cs-1);s[r].r=s[r].r.mul(1-c).add(n[r].r.mul(c)),s[r].v=s[r].v.mul(1-c).add(n[r].v.mul(c)),s[r].a=s[r].a.mul(1-c).add(n[r].a.mul(c))}}return a[i]}function Ep(a,e,t){let i=Md(a);const n=Math.ceil((e-i.grav.tt)/t);for(let s=0;s<n;++s)i=vd(s+1===n?e:i.grav.tt+t,i.grav);return i}function Qg(a,e){let t,i,n;const s=U5(O5,a.tt);if(s){const r=jg((a.tt-s[0].tt)/ir,cs-1),o=s[r],c=s[r+1],l=o.a.mean(c.a),h=dl(a.tt-o.tt,o.r,o.v,l),u=bp(a.tt-o.tt,o.v,l),d=dl(a.tt-c.tt,c.r,c.v,l),f=bp(a.tt-c.tt,c.v,l),p=(a.tt-o.tt)/ir;t=h.mul(1-p).add(d.mul(p)),i=u.mul(1-p).add(f.mul(p))}else{let r;a.tt<ma[0][0]?r=Ep(ma[0],a.tt,-ir):r=Ep(ma[gd-1],a.tt,+ir),t=r.grav.r,i=r.grav.v,n=r.bary}return n||(n=new Dl(a.tt)),t=t.sub(n.Sun.r),i=i.sub(n.Sun.v),new Gs(t.x,t.y,t.z,i.x,i.y,i.z,a)}function Xs(a,e){var t=zt(e);if(a in $n)return pr($n[a],t);if(a===we.Pluto){const r=Qg(t);return new Ct(r.x,r.y,r.z,t)}if(a===we.Sun)return new Ct(0,0,0,t);if(a===we.Moon){var i=pr($n.Earth,t),n=yr(t);return new Ct(i.x+n.x,i.y+n.y,i.z+n.z,t)}if(a===we.EMB){const r=pr($n.Earth,t),o=yr(t),c=1+Gg;return new Ct(r.x+o.x/c,r.y+o.y/c,r.z+o.z/c,t)}if(a===we.SSB)return P5(t);const s=n0(a);if(s){const r=new Rl(s.dec,15*s.ra,s.dist);return l0(r,t)}throw`HelioVector: Unknown body "${a}"`}function F5(a,e){let t=e,i=0;for(let n=0;n<10;++n){const s=a(t),r=s.Length()/t0;if(r>1)throw"Object is too distant for light-travel solver.";const o=e.AddDays(-r);if(i=Math.abs(o.tt-t.tt),i<1e-9)return s;t=o}throw`Light-travel time solver did not converge: dt = ${i}`}class k5{constructor(e,t,i,n){this.observerBody=e,this.targetBody=t,this.aberration=i,this.observerPos=n}Position(e){this.aberration&&(this.observerPos=Xs(this.observerBody,e));const t=Xs(this.targetBody,e);return new Ct(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function z5(a,e,t,i){hl(i);const n=zt(a);if(n0(t)){const o=Xs(t,n);if(i){const l=B5(e,n),h=new Ct(o.x-l.x,o.y-l.y,o.z-l.z,n),u=t0/h.Length();return new Ct(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,n)}const c=Xs(e,n);return new Ct(o.x-c.x,o.y-c.y,o.z-c.z,n)}let s;i?s=new Ct(0,0,0,n):s=Xs(e,n);const r=new k5(e,t,i,s);return F5(o=>r.Position(o),n)}function xd(a,e,t){hl(t);const i=zt(e);switch(a){case we.Earth:return new Ct(0,0,0,i);case we.Moon:return yr(i);default:const n=z5(i,we.Earth,a,t);return n.t=i,n}}function H5(a,e){return new Gs(a.r.x,a.r.y,a.r.z,a.v.x,a.v.y,a.v.z,e)}function B5(a,e){const t=zt(e);switch(a){case we.Sun:return new Gs(0,0,0,0,0,0,t);case we.SSB:const i=new Dl(t.tt);return new Gs(-i.Sun.r.x,-i.Sun.r.y,-i.Sun.r.z,-i.Sun.v.x,-i.Sun.v.y,-i.Sun.v.z,t);case we.Mercury:case we.Venus:case we.Earth:case we.Mars:case we.Jupiter:case we.Saturn:case we.Uranus:case we.Neptune:const n=md($n[a],t.tt);return H5(n,t);case we.Pluto:return Qg(t);case we.Moon:case we.EMB:const s=md($n.Earth,t.tt),r=a==we.Moon?$g(t):I5(t);return new Gs(r.x+s.r.x,r.y+s.r.y,r.z+s.r.z,r.vx+s.v.x,r.vy+s.v.y,r.vz+s.v.z,t);default:if(n0(a)){const o=Xs(a,t);return new Gs(o.x,o.y,o.z,0,0,0,t)}throw`HelioState: Unsupported body "${a}"`}}function G5(a){for(;a<0;)a+=360;for(;a>=360;)a-=360;return a}function V5(a,e,t){if(a===we.Earth||e===we.Earth)throw"The Earth does not have a longitude as seen from itself.";const i=zt(t),n=xd(a,i,!1),s=hd(n),r=xd(e,i,!1),o=hd(r);return G5(s.elon-o.elon)}function W5(a,e,t,i){let n,s=0,r=0,o=0;switch(a){case we.Mercury:n=-.6,s=4.98,r=-4.88,o=3.02;break;case we.Venus:e<163.6?(n=-4.47,s=1.03,r=.57,o=.13):(n=.98,s=-1.02);break;case we.Mars:n=-1.52,s=1.6;break;case we.Jupiter:n=-9.4,s=.5;break;case we.Uranus:n=-7.19,s=.25;break;case we.Neptune:n=-6.87;break;case we.Pluto:n=-1,s=4;break;default:throw`VisualMagnitude: unsupported body ${a}`}const c=e/100;let l=n+c*(s+c*(r+c*o));return l+=5*Math.log10(t*i),l}function X5(a,e,t,i,n){const s=hd(i),r=Mt*28.06,o=Mt*(169.51+382e-7*n.tt),c=Mt*s.elat,l=Mt*s.elon,h=Math.asin(Math.sin(c)*Math.cos(r)-Math.cos(c)*Math.sin(r)*Math.sin(l-o)),u=Math.sin(Math.abs(h));let d=-9+.044*a;return d+=u*(-2.6+1.2*u),d+=5*Math.log10(e*t),{mag:d,ring_tilt:jn*h}}function q5(a,e,t){let i=a*Mt,n=i*i,s=n*n,r=-12.717+1.49*Math.abs(i)+.0431*s;const o=385000.6/la;let c=t/o;return r+=5*Math.log10(e*c),r}class Y5{constructor(e,t,i,n,s,r,o,c){this.time=e,this.mag=t,this.phase_angle=i,this.helio_dist=n,this.geo_dist=s,this.gc=r,this.hc=o,this.ring_tilt=c,this.phase_fraction=(1+Math.cos(Mt*i))/2}}function e1(a,e){if(a===we.Earth)throw"The illumination of the Earth is not defined.";const t=zt(e),i=pr($n.Earth,t);let n,s,r,o;a===we.Sun?(r=new Ct(-i.x,-i.y,-i.z,t),s=new Ct(0,0,0,t),n=0):(a===we.Moon?(r=yr(t),s=new Ct(i.x+r.x,i.y+r.y,i.z+r.z,t)):(s=Xs(a,e),r=new Ct(s.x-i.x,s.y-i.y,s.z-i.z,t)),n=d5(r,s));let c=r.Length(),l=s.Length(),h;if(a===we.Sun)o=l5+5*Math.log10(c);else if(a===we.Moon)o=q5(n,l,c);else if(a===we.Saturn){const u=X5(n,l,c,r,t);o=u.mag,h=u.ring_tilt}else o=W5(a,n,l,c);return new Y5(t,o,n,l,c,r,s,h)}function K5(a){return V5(we.Moon,we.Sun,a)}var Ap;(function(a){a[a.Pericenter=0]="Pericenter",a[a.Apocenter=1]="Apocenter"})(Ap||(Ap={}));function t1(a,e){return new Ks([[e.rot[0][0]*a.rot[0][0]+e.rot[1][0]*a.rot[0][1]+e.rot[2][0]*a.rot[0][2],e.rot[0][1]*a.rot[0][0]+e.rot[1][1]*a.rot[0][1]+e.rot[2][1]*a.rot[0][2],e.rot[0][2]*a.rot[0][0]+e.rot[1][2]*a.rot[0][1]+e.rot[2][2]*a.rot[0][2]],[e.rot[0][0]*a.rot[1][0]+e.rot[1][0]*a.rot[1][1]+e.rot[2][0]*a.rot[1][2],e.rot[0][1]*a.rot[1][0]+e.rot[1][1]*a.rot[1][1]+e.rot[2][1]*a.rot[1][2],e.rot[0][2]*a.rot[1][0]+e.rot[1][2]*a.rot[1][1]+e.rot[2][2]*a.rot[1][2]],[e.rot[0][0]*a.rot[2][0]+e.rot[1][0]*a.rot[2][1]+e.rot[2][0]*a.rot[2][2],e.rot[0][1]*a.rot[2][0]+e.rot[1][1]*a.rot[2][1]+e.rot[2][1]*a.rot[2][2],e.rot[0][2]*a.rot[2][0]+e.rot[1][2]*a.rot[2][1]+e.rot[2][2]*a.rot[2][2]]])}function l0(a,e){e=zt(e);const t=a.lat*Mt,i=a.lon*Mt,n=a.dist*Math.cos(t);return new Ct(n*Math.cos(i),n*Math.sin(i),a.dist*Math.sin(t),e)}function h0(a){const e=$5(a);return new ld(e.lon/15,e.lat,e.dist,a)}function $5(a){const e=a.x*a.x+a.y*a.y,t=Math.sqrt(e+a.z*a.z);let i,n;if(e===0){if(a.z===0)throw"Zero-length vector not allowed.";n=0,i=a.z<0?-90:90}else n=jn*Math.atan2(a.y,a.x),n<0&&(n+=360),i=jn*Math.atan2(a.z,Math.sqrt(e));return new Rl(i,n,t)}function i1(a,e){let t;if(Mi(e),e<-90||e>90)return 0;if(a==="normal"||a==="jplhor"){let i=e;i<-1&&(i=-1),t=1.02/Math.tan((i+10.3/(i+5.11))*Mt)/60,a==="normal"&&e<-1&&(t*=(e+90)/89)}else if(!a)t=0;else throw`Invalid refraction option: ${a}`;return t}function mr(a,e){return new Ct(a.rot[0][0]*e.x+a.rot[1][0]*e.y+a.rot[2][0]*e.z,a.rot[0][1]*e.x+a.rot[1][1]*e.y+a.rot[2][1]*e.z,a.rot[0][2]*e.x+a.rot[1][2]*e.y+a.rot[2][2]*e.z,e.t)}function Z5(){return new Ks([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function J5(){return new Ks([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function n1(a){a=zt(a);const e=s0(a,Si.From2000),t=a0(a,Si.From2000);return t1(e,t)}function j5(a){a=zt(a);const e=a0(a,Si.Into2000),t=s0(a,Si.Into2000);return t1(e,t)}function Q5(a){const t=Do(zt(a)).tobl*Mt,i=Math.cos(t),n=Math.sin(t);return new Ks([[1,0,0],[0,+i,+n],[0,-n,+i]])}var Tp;(function(a){a.Penumbral="penumbral",a.Partial="partial",a.Annular="annular",a.Total="total"})(Tp||(Tp={}));var Rp;(function(a){a[a.Invalid=0]="Invalid",a[a.Ascending=1]="Ascending",a[a.Descending=-1]="Descending"})(Rp||(Rp={}));const ew=["Venus","Mars","Jupiter","Saturn"];function s1(a){return new c0(a.lat,a.lng,a.elevationM)}function u0(a,e,t,i,n=!0){const s=Yg(t,s1(i),a,e,n?"normal":void 0);return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}class En{up;north;west;constructor(e,t){const i=zt(e),n=Math.sin(t.lat*ls),s=Math.cos(t.lat*ls),r=Math.sin(t.lng*ls),o=Math.cos(t.lng*ls),c=-15*w5(i),l=j5(i);this.up=En.rotate(l,En.spin(c,[s*o,s*r,n]),i),this.north=En.rotate(l,En.spin(c,[-n*o,-n*r,s]),i),this.west=En.rotate(l,En.spin(c,[r,-o,0]),i)}static ofJ2000(e,t,i,n,s=!0){const r=zt(i),o=l0(new Rl(t,e*15,1),r),c=h0(mr(n1(r),o));return u0(c.ra,c.dec,i,n,s)}position(e,t){const i=Math.sin(t*ls),n=Math.cos(t*ls),s=Math.sin(e*Cp),r=Math.cos(e*Cp),o=n*r,c=n*s,l=i,h=o*this.up[0]+c*this.up[1]+l*this.up[2],u=o*this.north[0]+c*this.north[1]+l*this.north[2],d=o*this.west[0]+c*this.west[1]+l*this.west[2],f=Math.hypot(u,d);let p=0;f>0&&(p=-Dp*Math.atan2(d,u),p<0&&(p+=360));let v=Dp*Math.atan2(f,h);return v-=i1("normal",90-v),{altitudeDeg:90-v,azimuthDeg:p}}static spin(e,[t,i,n]){const s=Math.cos(e*ls),r=Math.sin(e*ls);return[s*t+r*i,s*i-r*t,n]}static rotate(e,[t,i,n],s){const r=mr(e,new Ct(t,i,n,s));return[r.x,r.y,r.z]}}const ls=Math.PI/180,Dp=180/Math.PI,Cp=15*ls;function Ah(a,e,t){const i=s1(t),n=D5(we[a],e,i,!0,!0),s=Yg(e,i,n.ra,n.dec,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function Th(a,e){return e1(we[a],e).mag}function tw(a){const e=K5(a),t=e1(we.Moon,a);return{phaseFraction:e/360,illuminatedFraction:t.phase_fraction}}const iw=2e3,nw=3,sw=20;function yc(a,e,t){if(a.year===void 0&&a.month===void 0&&a.day===void 0&&a.hour===void 0)return;const i=a.year!==void 0,n=a.year??iw,s=a.month??(i?1:nw),r=a.day??(i?1:sw),o=t??Math.round(e/15);return new Date(Date.UTC(n,s-1,r,(a.hour??12)-o,a.minute??0,a.second??0))}class Bn{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static FALLOFF={core:Bn.CORE,rim:Bn.RIM};static apply(e){e.transparent=!0,e.depthWrite=!1,e.onBeforeCompile=t=>{t.fragmentShader=Bn.patch(t.fragmentShader)}}static patch(e){return e.replace(Bn.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
|
|
5425
5425
|
// Outside the inscribed circle there is no star at all — this is what kills the corners.
|
|
5426
5426
|
if ( distanceFromCentre > ${Bn.RIM.toFixed(2)} ) discard;
|
|
5427
5427
|
float glare = 1.0 - smoothstep( ${Bn.CORE.toFixed(2)}, ${Bn.RIM.toFixed(2)}, distanceFromCentre );
|
|
5428
|
-
vec4 diffuseColor = vec4( diffuse, opacity * glare );`)}}class
|
|
5428
|
+
vec4 diffuseColor = vec4( diffuse, opacity * glare );`)}}class Ft{static COVERAGE=Ft.integrateCoverage();static CONE_SOLID_ANGLE=Ft.acuitySolidAngle(0);static CONE_THRESHOLD_LUX=10**((-14.18-4)/2.5);static shared={uRodSolidAngle:{value:1e-7},uConeThreshold:{value:0},uViewportHeight:{value:1}};static viewport=new it;static track(e){e.onBeforeRender=t=>{Ft.shared.uViewportHeight.value=Math.max(1,t.getCurrentViewport(Ft.viewport).w)}}static setEye(e,t){Ft.shared.uRodSolidAngle.value=Ft.acuitySolidAngle(e),Ft.shared.uConeThreshold.value=Ft.CONE_THRESHOLD_LUX*t}static material(e){const t=new vg({vertexColors:!0,size:e,sizeAttenuation:!1,fog:!1});Bn.apply(t),t.blending=Ci;const i=t.onBeforeCompile;return t.onBeforeCompile=(n,s)=>{i.call(t,n,s),n.uniforms.uRodSolidAngle=Ft.shared.uRodSolidAngle,n.uniforms.uConeThreshold=Ft.shared.uConeThreshold,n.uniforms.uViewportHeight=Ft.shared.uViewportHeight,n.vertexShader=Ft.patch(n.vertexShader)},t.customProgramCacheKey=()=>"point-sources",t}static acuitySolidAngle(e){const i=(1+9*Math.min(Math.max(e,0),1))/60*(Math.PI/180);return i*i}static patch(e){return e.replace("void main() {",`uniform float uRodSolidAngle;
|
|
5429
5429
|
uniform float uConeThreshold;
|
|
5430
|
+
uniform float uViewportHeight;
|
|
5430
5431
|
void main() {`).replace("gl_PointSize = size;",`gl_PointSize = size;
|
|
5431
5432
|
float light = max(max(vColor.r, vColor.g), vColor.b);
|
|
5432
5433
|
float foveal = smoothstep(0.25 * uConeThreshold, uConeThreshold, light);
|
|
5433
|
-
float uAcuitySolidAngle = mix(uRodSolidAngle, ${
|
|
5434
|
-
|
|
5434
|
+
float uAcuitySolidAngle = mix(uRodSolidAngle, ${Ft.CONE_SOLID_ANGLE.toExponential(6)}, foveal);
|
|
5435
|
+
float pixelAngle = 2.0 / (projectionMatrix[1][1] * uViewportHeight);
|
|
5436
|
+
float drawn = ${Ft.COVERAGE.toFixed(6)} * gl_PointSize * gl_PointSize * pixelAngle * pixelAngle;
|
|
5437
|
+
// The eye's contrast on one pixel, the light conserved over the rest of the disc: a reader
|
|
5438
|
+
// resolves a pixel as the witness resolved his acuity cell, and a disc wider than a pixel
|
|
5439
|
+
// is there to show a brighter point as a larger one, not to add light to it.
|
|
5440
|
+
float pixels = max(1.0, ${Ft.COVERAGE.toFixed(6)} * gl_PointSize * gl_PointSize);
|
|
5441
|
+
float pixel = pixelAngle * pixelAngle;
|
|
5442
|
+
vColor.rgb /= pixel >= uAcuitySolidAngle ? uAcuitySolidAngle * pixels : max(drawn, uAcuitySolidAngle);`)}static integrateCoverage(){const{core:t,rim:i}=Bn.FALLOFF;let n=0;for(let s=0;s<2e3;s++){const r=(s+.5)/2e3*i,o=Math.min(Math.max((r-t)/(i-t),0),1),c=1-o*o*(3-2*o);n+=c*2*Math.PI*r*(i/2e3)}return n}}class Ui{static K=10;static FAINTEST=.001;static MAX_RADIUS_DEG=30;mesh;constructor(e){this.mesh=new De(new ki(2,2),new at({uniforms:{uColor:{value:new se(0,0,0)},uTanRadius:{value:.1},uSourceDeg:{value:.25},uInnerDeg:{value:0}},vertexShader:Ui.VERTEX,fragmentShader:Ui.FRAGMENT,transparent:!0,depthWrite:!1,depthTest:!1,blending:Ci,fog:!1})),this.mesh.name=e,this.mesh.frustumCulled=!1,this.mesh.visible=!1}static radiusDeg(e){return Math.min(Ui.MAX_RADIUS_DEG,Math.sqrt(Math.max(e,0)/Ui.FAINTEST))}shine(e,t,i,n=0){const s=Ui.K*Math.max(t[0],t[1],t[2]),r=Ui.radiusDeg(s);if(r<=Math.max(i,n)){this.mesh.visible=!1;return}this.mesh.visible=!0,this.mesh.position.set(e.x,e.y,e.z);const o=this.mesh.material.uniforms;o.uColor.value.setRGB(Ui.K*t[0],Ui.K*t[1],Ui.K*t[2]),o.uTanRadius.value=Math.tan(r*Math.PI/180),o.uSourceDeg.value=i,o.uInnerDeg.value=n}hide(){this.mesh.visible=!1}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose()}static VERTEX=`
|
|
5435
5443
|
uniform float uTanRadius;
|
|
5436
5444
|
varying vec2 vOffset;
|
|
5437
5445
|
void main() {
|
|
@@ -5456,7 +5464,7 @@ void main() {`).replace("gl_PointSize = size;",`gl_PointSize = size;
|
|
|
5456
5464
|
if (uInnerDeg > 0.0) veil *= smoothstep(0.5 * uInnerDeg, uInnerDeg, theta);
|
|
5457
5465
|
gl_FragColor = vec4(uColor * veil, 1.0);
|
|
5458
5466
|
}
|
|
5459
|
-
`}class oo{static SAMPLES=4096;static SOURCE_CONE_DEG=1.5;target=new
|
|
5467
|
+
`}class oo{static SAMPLES=4096;static SOURCE_CONE_DEG=1.5;target=new jt(3,1,{type:Di,minFilter:wt,magFilter:wt,depthBuffer:!1});scene=new xs;camera=new Cn(-1,1,1,-1,0,1);material;reading=!1;constructor(){this.material=new at({uniforms:{uProbe:{value:null},uExcludeA:{value:new it(0,-1,0,2)},uExcludeB:{value:new it(0,-1,0,2)}},vertexShader:`
|
|
5460
5468
|
void main() { gl_Position = vec4(position.xy, 0.0, 1.0); }
|
|
5461
5469
|
`,fragmentShader:`
|
|
5462
5470
|
precision highp float;
|
|
@@ -5489,7 +5497,7 @@ void main() {`).replace("gl_PointSize = size;",`gl_PointSize = size;
|
|
|
5489
5497
|
if (which < 2) gl_FragColor = vec4(sum * 4.0 * PI / SAMPLES, 1.0);
|
|
5490
5498
|
else gl_FragColor = vec4(count > 0.0 ? logSum / count : -27.6, count, 0.0, 1.0);
|
|
5491
5499
|
}
|
|
5492
|
-
`,depthTest:!1,depthWrite:!1}),this.scene.add(new De(new ki(2,2),this.material))}measure(e,t,i,n){if(this.reading)return;const s=this.material.uniforms;s.uProbe.value=t;const r=Math.cos(oo.SOURCE_CONE_DEG*Math.PI/180);[s.uExcludeA.value,s.uExcludeB.value].forEach((h,u)=>{const d=i[u];d?h.set(d.x,d.y,d.z,r):h.set(0,-1,0,2)});const c=e.getRenderTarget();e.setRenderTarget(this.target),e.render(this.scene,this.camera),e.setRenderTarget(c),this.reading=!0;const l=new Float32Array(12);e.readRenderTargetPixelsAsync(this.target,0,0,3,1,l).then(()=>n({up:[l[0],l[1],l[2]],down:[l[4],l[5],l[6]],logAverage:l[8]})).catch(()=>{}).finally(()=>{this.reading=!1})}dispose(){this.target.dispose(),this.material.dispose(),this.scene.children[0].geometry.dispose()}}const aw=[{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}],eo=64,di=eo+1,Ip=2048,rw=900,ow=700/900,cw=0,lw=.01;function a1(a,e,t){return{north:fs(0,-t,a,e).lat,south:fs(0,t,a,e).lat,east:fs(t,0,a,e).lng,west:fs(-t,0,a,e).lng}}async function hw(a,e,t,i=rw){const n=i,s=i*ow,r=a1(a,e,n),o={width:di,height:di},[c,l]=await Promise.all([t.elevation.getElevationGrid(r,o),t.imagery.getImageryTexture(r,{width:Ip,height:Ip})]),h=Math.floor(di/2),u=c.heights[h*di+h],d=new Float32Array(di*di*3),f=new Float32Array(di*di*2),p=new Float32Array(di*di*4);for(let S=0;S<di;S++){const b=S/(di-1),T=r.north+(r.south-r.north)*b;for(let x=0;x<di;x++){const A=x/(di-1),I=r.west+(r.east-r.west)*A,{x:C,z:P}=ci(T,I,a,e),X=c.heights[S*di+x],z=Math.max(Math.abs(C),Math.abs(P)),N=1-uw((z-s)/(n-s),0,1),V=cw+lw+(X-u),k=S*di+x;d[k*3]=C,d[k*3+1]=V,d[k*3+2]=P;const K=Xm(l.bounds,I,T);f[k*2]=K.x,f[k*2+1]=K.y,p[k*4]=1,p[k*4+1]=1,p[k*4+2]=1,p[k*4+3]=N}}const v=new Uint16Array(eo*eo*6);let m=0;for(let S=0;S<eo;S++)for(let b=0;b<eo;b++){const T=S*di+b,x=T+1,A=T+di,I=A+1;v[m++]=T,v[m++]=A,v[m++]=x,v[m++]=x,v[m++]=A,v[m++]=I}const g=new ut;g.setAttribute("position",new et(d,3)),g.setAttribute("uv",new et(f,2)),g.setAttribute("color",new et(p,4)),g.setIndex(new et(v,1)),g.computeVertexNormals();const _=new Ss(l.source);_.flipY=!1,_.colorSpace=Fi,_.anisotropy=8;const w=new Sr({map:_,color:new se(1,1,1),vertexColors:!0,transparent:!0,fog:!0}),M=new De(g,w);return M.receiveShadow=!0,M.castShadow=!0,{mesh:M,attribution:t.imagery.attribution,originElevationM:Number.isFinite(u)?u:void 0}}function uw(a,e,t){return Math.max(e,Math.min(t,a))}class ln{static STEP_M=8;static LIFT_M=.06;static CONTEMPORARY_OPACITY=.45;static ALBEDO={paved:[.16,.16,.17],gravel:[.42,.38,.31],dirt:[.34,.28,.21]};group=new Dt;surveyed=new Dt;stated=new Dt;constructor(){this.group.name="roads",this.surveyed.name="roads surveyed",this.stated.name="roads stated",this.group.add(this.surveyed,this.stated)}set(e,t,i,n,s){ln.empty(this.surveyed);const r=new Map;for(const o of e){const c=r.get(o.surface)??{positions:[],indices:[]};r.set(o.surface,c),this.appendRibbon(o,t,i,n,c)}for(const[o,c]of r){const l=this.meshOf(o,c,s);l&&this.surveyed.add(l)}}setStated(e,t){ln.empty(this.stated);const i=new Map;for(const n of e){const s=i.get(n.surface)??{positions:[],indices:[]};i.set(n.surface,s),this.appendPath(n.path.map(r=>({x:r.eastM,z:-r.northM})),n.widthM,t,s)}for(const[n,s]of i){const r=this.meshOf(n,s,!1);r&&this.stated.add(r)}}clear(){ln.empty(this.surveyed)}static empty(e){for(const t of[...e.children]){e.remove(t);const i=t;i.geometry?.dispose(),i.material?.dispose()}}dispose(){ln.empty(this.surveyed),ln.empty(this.stated)}appendRibbon(e,t,i,n,s){this.appendPath(e.points.map(r=>ci(r.lat,r.lng,t,i)),e.widthM,n,s)}appendPath(e,t,i,n){const s=this.resample(e);if(s.length<2)return;const r=Math.max(.5,t/2),o=n.positions.length/3;for(let c=0;c<s.length;c++){const l=s[Math.max(0,c-1)],h=s[Math.min(s.length-1,c+1)];let u=h.x-l.x,d=h.z-l.z;const f=Math.hypot(u,d);f<1e-6?(u=1,d=0):(u/=f,d/=f);const p=-d*r,v=u*r,m={x:s[c].x+p,z:s[c].z+v},g={x:s[c].x-p,z:s[c].z-v};n.positions.push(m.x,i(m.x,m.z)+ln.LIFT_M,m.z,g.x,i(g.x,g.z)+ln.LIFT_M,g.z)}for(let c=0;c<s.length-1;c++){const l=o+c*2;n.indices.push(l,l+2,l+1,l+1,l+2,l+3)}}meshOf(e,t,i){if(t.indices.length===0)return;const n=new ut;n.setAttribute("position",new et(new Float32Array(t.positions),3)),n.setIndex(new et(new Uint32Array(t.indices),1)),n.computeVertexNormals();const s=ln.ALBEDO[e],r=new Sr({color:new se(s[0],s[1],s[2]),transparent:i,opacity:i?ln.CONTEMPORARY_OPACITY:1,fog:!0,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2}),o=new De(n,r);return o.name=`roads ${e}`,o.receiveShadow=!0,o.castShadow=!1,o}resample(e){const t=[];for(let n=0;n<e.length-1;n++){const s=e[n],r=e[n+1],o=Math.hypot(r.x-s.x,r.z-s.z),c=Math.max(1,Math.ceil(o/ln.STEP_M));for(let l=0;l<c;l++){const h=l/c;t.push({x:s.x+(r.x-s.x)*h,z:s.z+(r.z-s.z)*h})}}const i=e[e.length-1];return i&&t.push({x:i.x,z:i.z}),t}}const dw=18,fw=.55,pw=.5,mw=`
|
|
5500
|
+
`,depthTest:!1,depthWrite:!1}),this.scene.add(new De(new ki(2,2),this.material))}measure(e,t,i,n){if(this.reading)return;const s=this.material.uniforms;s.uProbe.value=t;const r=Math.cos(oo.SOURCE_CONE_DEG*Math.PI/180);[s.uExcludeA.value,s.uExcludeB.value].forEach((h,u)=>{const d=i[u];d?h.set(d.x,d.y,d.z,r):h.set(0,-1,0,2)});const c=e.getRenderTarget();e.setRenderTarget(this.target),e.render(this.scene,this.camera),e.setRenderTarget(c),this.reading=!0;const l=new Float32Array(12);e.readRenderTargetPixelsAsync(this.target,0,0,3,1,l).then(()=>n({up:[l[0],l[1],l[2]],down:[l[4],l[5],l[6]],logAverage:l[8]})).catch(()=>{}).finally(()=>{this.reading=!1})}dispose(){this.target.dispose(),this.material.dispose(),this.scene.children[0].geometry.dispose()}}const aw=[{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}],eo=64,fi=eo+1,Ip=2048,rw=900,ow=700/900,cw=0,lw=.01;function a1(a,e,t){return{north:fs(0,-t,a,e).lat,south:fs(0,t,a,e).lat,east:fs(t,0,a,e).lng,west:fs(-t,0,a,e).lng}}async function hw(a,e,t,i=rw){const n=i,s=i*ow,r=a1(a,e,n),o={width:fi,height:fi},[c,l]=await Promise.all([t.elevation.getElevationGrid(r,o),t.imagery.getImageryTexture(r,{width:Ip,height:Ip})]),h=Math.floor(fi/2),u=c.heights[h*fi+h],d=new Float32Array(fi*fi*3),f=new Float32Array(fi*fi*2),p=new Float32Array(fi*fi*4);for(let S=0;S<fi;S++){const b=S/(fi-1),T=r.north+(r.south-r.north)*b;for(let x=0;x<fi;x++){const A=x/(fi-1),I=r.west+(r.east-r.west)*A,{x:C,z:P}=li(T,I,a,e),X=c.heights[S*fi+x],z=Math.max(Math.abs(C),Math.abs(P)),N=1-uw((z-s)/(n-s),0,1),V=cw+lw+(X-u),k=S*fi+x;d[k*3]=C,d[k*3+1]=V,d[k*3+2]=P;const K=Xm(l.bounds,I,T);f[k*2]=K.x,f[k*2+1]=K.y,p[k*4]=1,p[k*4+1]=1,p[k*4+2]=1,p[k*4+3]=N}}const v=new Uint16Array(eo*eo*6);let m=0;for(let S=0;S<eo;S++)for(let b=0;b<eo;b++){const T=S*fi+b,x=T+1,A=T+fi,I=A+1;v[m++]=T,v[m++]=A,v[m++]=x,v[m++]=x,v[m++]=A,v[m++]=I}const g=new ut;g.setAttribute("position",new et(d,3)),g.setAttribute("uv",new et(f,2)),g.setAttribute("color",new et(p,4)),g.setIndex(new et(v,1)),g.computeVertexNormals();const _=new Ss(l.source);_.flipY=!1,_.colorSpace=Fi,_.anisotropy=8;const w=new Sr({map:_,color:new se(1,1,1),vertexColors:!0,transparent:!0,fog:!0}),M=new De(g,w);return M.receiveShadow=!0,M.castShadow=!0,{mesh:M,attribution:t.imagery.attribution,originElevationM:Number.isFinite(u)?u:void 0}}function uw(a,e,t){return Math.max(e,Math.min(t,a))}class ln{static STEP_M=8;static LIFT_M=.06;static CONTEMPORARY_OPACITY=.45;static ALBEDO={paved:[.16,.16,.17],gravel:[.42,.38,.31],dirt:[.34,.28,.21]};group=new Dt;surveyed=new Dt;stated=new Dt;constructor(){this.group.name="roads",this.surveyed.name="roads surveyed",this.stated.name="roads stated",this.group.add(this.surveyed,this.stated)}set(e,t,i,n,s){ln.empty(this.surveyed);const r=new Map;for(const o of e){const c=r.get(o.surface)??{positions:[],indices:[]};r.set(o.surface,c),this.appendRibbon(o,t,i,n,c)}for(const[o,c]of r){const l=this.meshOf(o,c,s);l&&this.surveyed.add(l)}}setStated(e,t){ln.empty(this.stated);const i=new Map;for(const n of e){const s=i.get(n.surface)??{positions:[],indices:[]};i.set(n.surface,s),this.appendPath(n.path.map(r=>({x:r.eastM,z:-r.northM})),n.widthM,t,s)}for(const[n,s]of i){const r=this.meshOf(n,s,!1);r&&this.stated.add(r)}}clear(){ln.empty(this.surveyed)}static empty(e){for(const t of[...e.children]){e.remove(t);const i=t;i.geometry?.dispose(),i.material?.dispose()}}dispose(){ln.empty(this.surveyed),ln.empty(this.stated)}appendRibbon(e,t,i,n,s){this.appendPath(e.points.map(r=>li(r.lat,r.lng,t,i)),e.widthM,n,s)}appendPath(e,t,i,n){const s=this.resample(e);if(s.length<2)return;const r=Math.max(.5,t/2),o=n.positions.length/3;for(let c=0;c<s.length;c++){const l=s[Math.max(0,c-1)],h=s[Math.min(s.length-1,c+1)];let u=h.x-l.x,d=h.z-l.z;const f=Math.hypot(u,d);f<1e-6?(u=1,d=0):(u/=f,d/=f);const p=-d*r,v=u*r,m={x:s[c].x+p,z:s[c].z+v},g={x:s[c].x-p,z:s[c].z-v};n.positions.push(m.x,i(m.x,m.z)+ln.LIFT_M,m.z,g.x,i(g.x,g.z)+ln.LIFT_M,g.z)}for(let c=0;c<s.length-1;c++){const l=o+c*2;n.indices.push(l,l+2,l+1,l+1,l+2,l+3)}}meshOf(e,t,i){if(t.indices.length===0)return;const n=new ut;n.setAttribute("position",new et(new Float32Array(t.positions),3)),n.setIndex(new et(new Uint32Array(t.indices),1)),n.computeVertexNormals();const s=ln.ALBEDO[e],r=new Sr({color:new se(s[0],s[1],s[2]),transparent:i,opacity:i?ln.CONTEMPORARY_OPACITY:1,fog:!0,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2}),o=new De(n,r);return o.name=`roads ${e}`,o.receiveShadow=!0,o.castShadow=!1,o}resample(e){const t=[];for(let n=0;n<e.length-1;n++){const s=e[n],r=e[n+1],o=Math.hypot(r.x-s.x,r.z-s.z),c=Math.max(1,Math.ceil(o/ln.STEP_M));for(let l=0;l<c;l++){const h=l/c;t.push({x:s.x+(r.x-s.x)*h,z:s.z+(r.z-s.z)*h})}}const i=e[e.length-1];return i&&t.push({x:i.x,z:i.z}),t}}const dw=18,fw=.55,pw=.5,mw=`
|
|
5493
5501
|
attribute float aSpeed;
|
|
5494
5502
|
uniform float uTime;
|
|
5495
5503
|
uniform float uOverallSpeed;
|
|
@@ -5589,7 +5597,7 @@ void main() {
|
|
|
5589
5597
|
float blur = max(vNearBlur, vHaze);
|
|
5590
5598
|
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${pw.toFixed(2)}));
|
|
5591
5599
|
}
|
|
5592
|
-
`;function vw(a){let e=a;return function(){e|=0,e=e+1831565813|0;let i=Math.imul(e^e>>>15,1|e);return i=i+Math.imul(i^i>>>7,61|i)^i,((i^i>>>14)>>>0)/4294967296}}const Mw=.14,Pp=4.5;let _c;function xw(){if(_c)return _c;const a=128,e=document.createElement("canvas");e.width=a,e.height=a;const t=e.getContext("2d"),i=t.createImageData(a,a),n=a/2,s=a*Mw,r=a-s;for(let o=0;o<a;o++)for(let c=0;c<a;c++){const l=c+.5-n,h=o+.5<s?o+.5-s:o+.5>r?o+.5-r:0,u=Math.hypot(l,h),d=Math.exp(-(u*u)/(2*Pp*Pp)),f=(o*a+c)*4;i.data[f]=255,i.data[f+1]=255,i.data[f+2]=255,i.data[f+3]=Math.round(255*Math.min(1,d))}return t.putImageData(i,0,0),_c=new Ss(e),_c}function yw(a){const e=vw(a.seed),t=new Float32Array(a.count*3),i=new Float32Array(a.count),n=a.radiusM;for(let l=0;l<a.count;l++){const h=e()*Math.PI*2,u=Math.sqrt(e())*a.radiusM;t[l*3]=Math.cos(h)*u,t[l*3+1]=e()*a.heightM,t[l*3+2]=Math.sin(h)*u,i[l]=.85+e()*.3}const s=new ut;s.setAttribute("position",new et(t,3)),s.setAttribute("aSpeed",new et(i,1)),s.setDrawRange(0,a.visibleCount);const r={uTime:{value:0},uOverallSpeed:{value:a.overallSpeed},uPixelSize:{value:a.pixelSize},uOpacity:{value:a.opacity},uColor:{value:a.color},uUvSquash:{value:1},uSpeedStreak:{value:a.speedStreak},uWindOffset:{value:new xe(0,0)},uDropVelocity:{value:new D(0,-1,0)},uAspect:{value:1},uHeight:{value:a.heightM},uBottomY:{value:a.bottomYM},uHalfWidth:{value:n},uTexture:{value:xw()},uNearFocusDistance:{value:a.nearFocusDistanceM},uHazeDistance:{value:a.hazeDistanceM},uHazeColor:{value:a.hazeColor}},o=new at({uniforms:r,vertexShader:mw,fragmentShader:gw,transparent:!0,depthWrite:!1,depthTest:!0}),c=new us(s,o);return c.frustumCulled=!1,{points:c,uniforms:r}}class wa{static S10_MAG_PER_ARCSEC2=10+2.5*Math.log10(3600*3600);static toMagPerArcsec2(e){return wa.S10_MAG_PER_ARCSEC2-2.5*Math.log10(Math.max(e,1e-12))}static fromMagPerArcsec2(e){return 10**(.4*(wa.S10_MAG_PER_ARCSEC2-e))}static latitudeOfRowCoord(e){const t=2*e-1;return 90*Math.sign(t)*t*t}static rowCoordOfLatitude(e){return(Math.sign(e)*Math.sqrt(Math.min(Math.abs(e),90)/90)+1)/2}static angleOfColumnCoord(e){return 180*e*e}static columnCoordOfAngle(e){return Math.sqrt(Math.min(Math.max(e,0),180)/180)}}class tt{static LONGITUDE_STEPS=256;static LATITUDE_STEPS=128;static SUN_RADIUS_KPC=8.2;static SUN_HEIGHT_KPC=.02;static DISK_SCALE_LENGTH_KPC=2.6;static DISK_SCALE_HEIGHT_KPC=.3;static BULGE_SCALE_KPC=.5;static BULGE_FLATTENING=.6;static BULGE_TO_LOCAL_DISK=20;static DUST_SCALE_LENGTH_KPC=3.5;static DUST_SCALE_HEIGHT_KPC=.1;static EXTINCTION_MAG_PER_KPC=.8;static NEAR_LIMIT_KPC=.01;static FAR_LIMIT_KPC=40;static STEPS=192;static OPAQUE_MAG=15;static PEAK_MAG_PER_ARCSEC2=21;static PEAK_RADIANCE=6.278;static PEAK_LONGITUDE_DEG=0;static PEAK_LATITUDE_DEG=4.5;surfaceBrightnessS10(e,t){return this.radianceTowards(e,t)*tt.anchor()}static anchor(){return wa.fromMagPerArcsec2(tt.PEAK_MAG_PER_ARCSEC2)/tt.PEAK_RADIANCE}radianceTowards(e,t){return this.trace(e,t).light}extinctionTowards(e,t){return this.trace(e,t).extinctionMag}trace(e,t){const i=e*Math.PI/180,n=t*Math.PI/180,s=-Math.cos(n)*Math.cos(i),r=Math.cos(n)*Math.sin(i),o=Math.sin(n);let c=0,l=0,h=0;const u=Math.log(tt.NEAR_LIMIT_KPC),d=Math.log(tt.FAR_LIMIT_KPC)-u;for(let f=0;f<tt.STEPS;f++){const p=Math.exp(u+d*f/(tt.STEPS-1)),v=p-h;h=p;const m=p-v/2,g=tt.SUN_RADIUS_KPC+m*s,_=m*r,w=tt.SUN_HEIGHT_KPC+m*o,M=Math.hypot(g,_),S=Math.exp(-(M-tt.SUN_RADIUS_KPC)/tt.DISK_SCALE_LENGTH_KPC-Math.abs(w)/tt.DISK_SCALE_HEIGHT_KPC),b=Math.hypot(M,w/tt.BULGE_FLATTENING),T=tt.BULGE_TO_LOCAL_DISK*Math.exp(-b/tt.BULGE_SCALE_KPC);if(c+=(S+T)*v*10**(-.4*l),l+=tt.EXTINCTION_MAG_PER_KPC*Math.exp(-(M-tt.SUN_RADIUS_KPC)/tt.DUST_SCALE_LENGTH_KPC-(Math.abs(w)-tt.SUN_HEIGHT_KPC)/tt.DUST_SCALE_HEIGHT_KPC)*v,l>tt.OPAQUE_MAG)break}return{light:c,extinctionMag:l}}values=new Float32Array(tt.LONGITUDE_STEPS*tt.LATITUDE_STEPS);walked=0;get done(){return this.walked>=tt.LATITUDE_STEPS}walk(e){const t=tt.LONGITUDE_STEPS,i=Math.min(tt.LATITUDE_STEPS,this.walked+e);for(;this.walked<i;this.walked++){const n=wa.latitudeOfRowCoord((this.walked+.5)/tt.LATITUDE_STEPS);for(let s=0;s<t;s++)this.values[this.walked*t+s]=this.radianceTowards(360*(s+.5)/t,n)}}harvest(){let e=Number.POSITIVE_INFINITY;for(const n of this.values)n<e&&(e=n);const t=tt.anchor(),i=new Float32Array(this.values.length);for(let n=0;n<i.length;n++)i[n]=(this.values[n]-e)*t;return{width:tt.LONGITUDE_STEPS,height:tt.LATITUDE_STEPS,data:i}}}class Ut{static LONGITUDE_STEPS=128;static LATITUDE_STEPS=96;static RADIAL_FALLOFF=1.3;static FAN_EXPONENT=2.6;static SUBLIMATION_AU=.1;static NEAR_LIMIT_AU=.004;static FAR_LIMIT_AU=8;static STEPS=224;static LOBE_ASYMMETRY=[.7,-.2,-.81];static LOBE_WEIGHT=[.665,.33,.00541];static RIGHT_ANGLE_S10=200;static POLE_S10=77;surfaceBrightnessS10(e,t){return this.radianceTowards(e,t)*this.anchor()}anchored;anchor(){return this.anchored===void 0&&(this.anchored=Ut.RIGHT_ANGLE_S10/this.radianceTowards(90,0)),this.anchored}radianceTowards(e,t){const i=e*Math.PI/180,n=t*Math.PI/180,s=-Math.cos(n)*Math.cos(i),r=-Math.cos(n)*Math.sin(i),o=Math.sin(n),c=-s;let l=0,h=0;const u=Math.log(Ut.NEAR_LIMIT_AU),d=Math.log(Ut.FAR_LIMIT_AU)-u;for(let f=0;f<Ut.STEPS;f++){const p=Math.exp(u+d*f/(Ut.STEPS-1)),v=p-h;h=p;const m=p-v/2,g=1+m*s,_=m*r,w=m*o,M=Math.hypot(g,_,w);if(M<Ut.SUBLIMATION_AU)continue;const S=w/M,b=M**-1.3*Math.exp(-2.6*Math.abs(S)),T=(c-m)/M;l+=b*this.scattering(T)*v/(M*M)}return l}scattering(e){let t=0;for(let i=0;i<Ut.LOBE_ASYMMETRY.length;i++){const n=Ut.LOBE_ASYMMETRY[i],s=1+n*n-2*n*e;t+=Ut.LOBE_WEIGHT[i]*(1-n*n)/(4*Math.PI*s**1.5)}return t}values=new Float32Array(Ut.LONGITUDE_STEPS*Ut.LATITUDE_STEPS);walked=0;get done(){return this.walked>=Ut.LATITUDE_STEPS}walk(e){const t=Ut.LONGITUDE_STEPS,i=Math.min(Ut.LATITUDE_STEPS,this.walked+e);for(;this.walked<i;this.walked++){const n=wa.latitudeOfRowCoord((this.walked+.5)/Ut.LATITUDE_STEPS);for(let s=0;s<t;s++){const r=wa.angleOfColumnCoord((s+.5)/t);this.values[this.walked*t+s]=this.radianceTowards(r,n)}}}harvest(){const e=this.anchor();let t=Number.POSITIVE_INFINITY;for(const n of this.values)n<t&&(t=n);const i=new Float32Array(this.values.length);for(let n=0;n<i.length;n++)i[n]=(this.values[n]-t)*e;return{width:Ut.LONGITUDE_STEPS,height:Ut.LATITUDE_STEPS,data:i}}}class Ye{static get NANOLAMBERTS_PER_S10(){return Ye.toNanolamberts(10+2.5*Math.log10(3600*3600))}static nanolambertsOfS10(e){return e*Ye.NANOLAMBERTS_PER_S10}static TWILIGHT=[{sunAltitudeDeg:90,magPerArcsec2:3.5},{sunAltitudeDeg:10,magPerArcsec2:4.2},{sunAltitudeDeg:0,magPerArcsec2:7.5},...Array.from({length:15},(e,t)=>{const i=-4-t;return{sunAltitudeDeg:i,magPerArcsec2:Ye.patatV(i)}}),{sunAltitudeDeg:-24,magPerArcsec2:22}];static patatV(e){const t=90-e-95;return 11.84+1.518*t-.057*t*t}static moonlessMagPerArcsec2(e){const t=Ye.TWILIGHT;for(let i=0;i<t.length-1;i++){const n=t[i],s=t[i+1];if(e<=n.sunAltitudeDeg&&e>=s.sunAltitudeDeg){const r=(n.sunAltitudeDeg-e)/(n.sunAltitudeDeg-s.sunAltitudeDeg);return n.magPerArcsec2+(s.magPerArcsec2-n.magPerArcsec2)*r}}return e>0?t[0].magPerArcsec2:t[t.length-1].magPerArcsec2}static toNanolamberts(e){return 34.08*Math.exp(Ye.NANOLAMBERT_OFFSET-Ye.PER_MAGNITUDE*e)}static fromNanolamberts(e){return(Ye.NANOLAMBERT_OFFSET-Math.log(Math.max(e,1e-6)/34.08))/Ye.PER_MAGNITUDE}static NANOLAMBERT_OFFSET=20.7233;static PER_MAGNITUDE=Math.LN10/2.5;static airMass(e){const t=Math.cos(Math.max(e,0)*Math.PI/180);return 1/Math.sqrt(Math.max(1-.96*t*t,.001))}static EXTINCTION_PER_AIR_MASS=.172;static scatteringAt(e){const t=Math.min(Math.max(e,0),180)*Math.PI/180;return 10**5.36*(1.06+Math.cos(t)**2)+10**(6.15-Math.min(e,180)/40)}static scatteredFraction(e){return 1-10**(-.4*Ye.EXTINCTION_PER_AIR_MASS*Ye.airMass(e))}static AIRGLOW_MAG_PER_ARCSEC2=22;static twilightExcessNanolamberts(e){return Math.max(0,Ye.toNanolamberts(Ye.moonlessMagPerArcsec2(e))-Ye.toNanolamberts(Ye.AIRGLOW_MAG_PER_ARCSEC2))}static twilightOutput(e){const t=Ye.scatteringAt(90-e)*Ye.scatteredFraction(90);return Ye.twilightExcessNanolamberts(e)/t}static moonNanolamberts(e,t,i,n){return Ye.scatteringAt(i)*Ye.moonOutput(e,t)*Ye.scatteredFraction(n)}static moonOutput(e,t){if(t<=0)return 0;const i=Math.min(Math.abs(e),180);return 10**(-.4*(3.84+.026*i+4e-9*i**4))*10**(-.4*Ye.EXTINCTION_PER_AIR_MASS*Ye.airMass(t))}static phaseAngleOf(e){return Math.acos(Math.min(Math.max(2*e-1,-1),1))*180/Math.PI}static magPerArcsec2(e,t,i){const n=Ye.scatteredFraction(i),s=Ye.scatteringAt(e.separationDeg)*Ye.twilightOutput(e.altitudeDeg)*n,r=Ye.scatteringAt(t.separationDeg)*Ye.moonOutput(t.phaseAngleDeg,t.altitudeDeg)*n;return Ye.fromNanolamberts(Ye.toNanolamberts(Ye.AIRGLOW_MAG_PER_ARCSEC2)+s+r)}}class Os{static RADIUS=890;static TOO_BRIGHT_MAG_PER_ARCSEC2=16;static MILKY_WAY_TINT=[.9,.94,1];static ZODIACAL_TINT=[1,.97,.9];object;material;maps=ha.shared;milkyWayTexture;zodiacalTexture;milkyWayTexels;zodiacalTexels;repaint;constructor(){this.milkyWayTexels=this.maps.milkyWayTexels,this.milkyWayTexture=Os.buildTexture(this.milkyWayTexels,tt.LONGITUDE_STEPS,tt.LATITUDE_STEPS,Mo),this.zodiacalTexels=this.maps.zodiacalTexels,this.zodiacalTexture=Os.buildTexture(this.zodiacalTexels,Ut.LONGITUDE_STEPS,Ut.LATITUDE_STEPS,
|
|
5600
|
+
`;function vw(a){let e=a;return function(){e|=0,e=e+1831565813|0;let i=Math.imul(e^e>>>15,1|e);return i=i+Math.imul(i^i>>>7,61|i)^i,((i^i>>>14)>>>0)/4294967296}}const Mw=.14,Pp=4.5;let _c;function xw(){if(_c)return _c;const a=128,e=document.createElement("canvas");e.width=a,e.height=a;const t=e.getContext("2d"),i=t.createImageData(a,a),n=a/2,s=a*Mw,r=a-s;for(let o=0;o<a;o++)for(let c=0;c<a;c++){const l=c+.5-n,h=o+.5<s?o+.5-s:o+.5>r?o+.5-r:0,u=Math.hypot(l,h),d=Math.exp(-(u*u)/(2*Pp*Pp)),f=(o*a+c)*4;i.data[f]=255,i.data[f+1]=255,i.data[f+2]=255,i.data[f+3]=Math.round(255*Math.min(1,d))}return t.putImageData(i,0,0),_c=new Ss(e),_c}function yw(a){const e=vw(a.seed),t=new Float32Array(a.count*3),i=new Float32Array(a.count),n=a.radiusM;for(let l=0;l<a.count;l++){const h=e()*Math.PI*2,u=Math.sqrt(e())*a.radiusM;t[l*3]=Math.cos(h)*u,t[l*3+1]=e()*a.heightM,t[l*3+2]=Math.sin(h)*u,i[l]=.85+e()*.3}const s=new ut;s.setAttribute("position",new et(t,3)),s.setAttribute("aSpeed",new et(i,1)),s.setDrawRange(0,a.visibleCount);const r={uTime:{value:0},uOverallSpeed:{value:a.overallSpeed},uPixelSize:{value:a.pixelSize},uOpacity:{value:a.opacity},uColor:{value:a.color},uUvSquash:{value:1},uSpeedStreak:{value:a.speedStreak},uWindOffset:{value:new xe(0,0)},uDropVelocity:{value:new D(0,-1,0)},uAspect:{value:1},uHeight:{value:a.heightM},uBottomY:{value:a.bottomYM},uHalfWidth:{value:n},uTexture:{value:xw()},uNearFocusDistance:{value:a.nearFocusDistanceM},uHazeDistance:{value:a.hazeDistanceM},uHazeColor:{value:a.hazeColor}},o=new at({uniforms:r,vertexShader:mw,fragmentShader:gw,transparent:!0,depthWrite:!1,depthTest:!0}),c=new us(s,o);return c.frustumCulled=!1,{points:c,uniforms:r}}class wa{static S10_MAG_PER_ARCSEC2=10+2.5*Math.log10(3600*3600);static toMagPerArcsec2(e){return wa.S10_MAG_PER_ARCSEC2-2.5*Math.log10(Math.max(e,1e-12))}static fromMagPerArcsec2(e){return 10**(.4*(wa.S10_MAG_PER_ARCSEC2-e))}static latitudeOfRowCoord(e){const t=2*e-1;return 90*Math.sign(t)*t*t}static rowCoordOfLatitude(e){return(Math.sign(e)*Math.sqrt(Math.min(Math.abs(e),90)/90)+1)/2}static angleOfColumnCoord(e){return 180*e*e}static columnCoordOfAngle(e){return Math.sqrt(Math.min(Math.max(e,0),180)/180)}}class tt{static LONGITUDE_STEPS=256;static LATITUDE_STEPS=128;static SUN_RADIUS_KPC=8.2;static SUN_HEIGHT_KPC=.02;static DISK_SCALE_LENGTH_KPC=2.6;static DISK_SCALE_HEIGHT_KPC=.3;static BULGE_SCALE_KPC=.5;static BULGE_FLATTENING=.6;static BULGE_TO_LOCAL_DISK=20;static DUST_SCALE_LENGTH_KPC=3.5;static DUST_SCALE_HEIGHT_KPC=.1;static EXTINCTION_MAG_PER_KPC=.8;static NEAR_LIMIT_KPC=.01;static FAR_LIMIT_KPC=40;static STEPS=192;static OPAQUE_MAG=15;static PEAK_MAG_PER_ARCSEC2=21;static PEAK_RADIANCE=6.278;static PEAK_LONGITUDE_DEG=0;static PEAK_LATITUDE_DEG=4.5;surfaceBrightnessS10(e,t){return this.radianceTowards(e,t)*tt.anchor()}static anchor(){return wa.fromMagPerArcsec2(tt.PEAK_MAG_PER_ARCSEC2)/tt.PEAK_RADIANCE}radianceTowards(e,t){return this.trace(e,t).light}extinctionTowards(e,t){return this.trace(e,t).extinctionMag}trace(e,t){const i=e*Math.PI/180,n=t*Math.PI/180,s=-Math.cos(n)*Math.cos(i),r=Math.cos(n)*Math.sin(i),o=Math.sin(n);let c=0,l=0,h=0;const u=Math.log(tt.NEAR_LIMIT_KPC),d=Math.log(tt.FAR_LIMIT_KPC)-u;for(let f=0;f<tt.STEPS;f++){const p=Math.exp(u+d*f/(tt.STEPS-1)),v=p-h;h=p;const m=p-v/2,g=tt.SUN_RADIUS_KPC+m*s,_=m*r,w=tt.SUN_HEIGHT_KPC+m*o,M=Math.hypot(g,_),S=Math.exp(-(M-tt.SUN_RADIUS_KPC)/tt.DISK_SCALE_LENGTH_KPC-Math.abs(w)/tt.DISK_SCALE_HEIGHT_KPC),b=Math.hypot(M,w/tt.BULGE_FLATTENING),T=tt.BULGE_TO_LOCAL_DISK*Math.exp(-b/tt.BULGE_SCALE_KPC);if(c+=(S+T)*v*10**(-.4*l),l+=tt.EXTINCTION_MAG_PER_KPC*Math.exp(-(M-tt.SUN_RADIUS_KPC)/tt.DUST_SCALE_LENGTH_KPC-(Math.abs(w)-tt.SUN_HEIGHT_KPC)/tt.DUST_SCALE_HEIGHT_KPC)*v,l>tt.OPAQUE_MAG)break}return{light:c,extinctionMag:l}}values=new Float32Array(tt.LONGITUDE_STEPS*tt.LATITUDE_STEPS);walked=0;get done(){return this.walked>=tt.LATITUDE_STEPS}walk(e){const t=tt.LONGITUDE_STEPS,i=Math.min(tt.LATITUDE_STEPS,this.walked+e);for(;this.walked<i;this.walked++){const n=wa.latitudeOfRowCoord((this.walked+.5)/tt.LATITUDE_STEPS);for(let s=0;s<t;s++)this.values[this.walked*t+s]=this.radianceTowards(360*(s+.5)/t,n)}}harvest(){let e=Number.POSITIVE_INFINITY;for(const n of this.values)n<e&&(e=n);const t=tt.anchor(),i=new Float32Array(this.values.length);for(let n=0;n<i.length;n++)i[n]=(this.values[n]-e)*t;return{width:tt.LONGITUDE_STEPS,height:tt.LATITUDE_STEPS,data:i}}}class Ut{static LONGITUDE_STEPS=128;static LATITUDE_STEPS=96;static RADIAL_FALLOFF=1.3;static FAN_EXPONENT=2.6;static SUBLIMATION_AU=.1;static NEAR_LIMIT_AU=.004;static FAR_LIMIT_AU=8;static STEPS=224;static LOBE_ASYMMETRY=[.7,-.2,-.81];static LOBE_WEIGHT=[.665,.33,.00541];static RIGHT_ANGLE_S10=200;static POLE_S10=77;surfaceBrightnessS10(e,t){return this.radianceTowards(e,t)*this.anchor()}anchored;anchor(){return this.anchored===void 0&&(this.anchored=Ut.RIGHT_ANGLE_S10/this.radianceTowards(90,0)),this.anchored}radianceTowards(e,t){const i=e*Math.PI/180,n=t*Math.PI/180,s=-Math.cos(n)*Math.cos(i),r=-Math.cos(n)*Math.sin(i),o=Math.sin(n),c=-s;let l=0,h=0;const u=Math.log(Ut.NEAR_LIMIT_AU),d=Math.log(Ut.FAR_LIMIT_AU)-u;for(let f=0;f<Ut.STEPS;f++){const p=Math.exp(u+d*f/(Ut.STEPS-1)),v=p-h;h=p;const m=p-v/2,g=1+m*s,_=m*r,w=m*o,M=Math.hypot(g,_,w);if(M<Ut.SUBLIMATION_AU)continue;const S=w/M,b=M**-1.3*Math.exp(-2.6*Math.abs(S)),T=(c-m)/M;l+=b*this.scattering(T)*v/(M*M)}return l}scattering(e){let t=0;for(let i=0;i<Ut.LOBE_ASYMMETRY.length;i++){const n=Ut.LOBE_ASYMMETRY[i],s=1+n*n-2*n*e;t+=Ut.LOBE_WEIGHT[i]*(1-n*n)/(4*Math.PI*s**1.5)}return t}values=new Float32Array(Ut.LONGITUDE_STEPS*Ut.LATITUDE_STEPS);walked=0;get done(){return this.walked>=Ut.LATITUDE_STEPS}walk(e){const t=Ut.LONGITUDE_STEPS,i=Math.min(Ut.LATITUDE_STEPS,this.walked+e);for(;this.walked<i;this.walked++){const n=wa.latitudeOfRowCoord((this.walked+.5)/Ut.LATITUDE_STEPS);for(let s=0;s<t;s++){const r=wa.angleOfColumnCoord((s+.5)/t);this.values[this.walked*t+s]=this.radianceTowards(r,n)}}}harvest(){const e=this.anchor();let t=Number.POSITIVE_INFINITY;for(const n of this.values)n<t&&(t=n);const i=new Float32Array(this.values.length);for(let n=0;n<i.length;n++)i[n]=(this.values[n]-t)*e;return{width:Ut.LONGITUDE_STEPS,height:Ut.LATITUDE_STEPS,data:i}}}class Ye{static get NANOLAMBERTS_PER_S10(){return Ye.toNanolamberts(10+2.5*Math.log10(3600*3600))}static nanolambertsOfS10(e){return e*Ye.NANOLAMBERTS_PER_S10}static TWILIGHT=[{sunAltitudeDeg:90,magPerArcsec2:3.5},{sunAltitudeDeg:10,magPerArcsec2:4.2},{sunAltitudeDeg:0,magPerArcsec2:7.5},...Array.from({length:15},(e,t)=>{const i=-4-t;return{sunAltitudeDeg:i,magPerArcsec2:Ye.patatV(i)}}),{sunAltitudeDeg:-24,magPerArcsec2:22}];static patatV(e){const t=90-e-95;return 11.84+1.518*t-.057*t*t}static moonlessMagPerArcsec2(e){const t=Ye.TWILIGHT;for(let i=0;i<t.length-1;i++){const n=t[i],s=t[i+1];if(e<=n.sunAltitudeDeg&&e>=s.sunAltitudeDeg){const r=(n.sunAltitudeDeg-e)/(n.sunAltitudeDeg-s.sunAltitudeDeg);return n.magPerArcsec2+(s.magPerArcsec2-n.magPerArcsec2)*r}}return e>0?t[0].magPerArcsec2:t[t.length-1].magPerArcsec2}static toNanolamberts(e){return 34.08*Math.exp(Ye.NANOLAMBERT_OFFSET-Ye.PER_MAGNITUDE*e)}static fromNanolamberts(e){return(Ye.NANOLAMBERT_OFFSET-Math.log(Math.max(e,1e-6)/34.08))/Ye.PER_MAGNITUDE}static NANOLAMBERT_OFFSET=20.7233;static PER_MAGNITUDE=Math.LN10/2.5;static airMass(e){const t=Math.cos(Math.max(e,0)*Math.PI/180);return 1/Math.sqrt(Math.max(1-.96*t*t,.001))}static EXTINCTION_PER_AIR_MASS=.172;static scatteringAt(e){const t=Math.min(Math.max(e,0),180)*Math.PI/180;return 10**5.36*(1.06+Math.cos(t)**2)+10**(6.15-Math.min(e,180)/40)}static scatteredFraction(e){return 1-10**(-.4*Ye.EXTINCTION_PER_AIR_MASS*Ye.airMass(e))}static AIRGLOW_MAG_PER_ARCSEC2=22;static twilightExcessNanolamberts(e){return Math.max(0,Ye.toNanolamberts(Ye.moonlessMagPerArcsec2(e))-Ye.toNanolamberts(Ye.AIRGLOW_MAG_PER_ARCSEC2))}static twilightOutput(e){const t=Ye.scatteringAt(90-e)*Ye.scatteredFraction(90);return Ye.twilightExcessNanolamberts(e)/t}static moonNanolamberts(e,t,i,n){return Ye.scatteringAt(i)*Ye.moonOutput(e,t)*Ye.scatteredFraction(n)}static moonOutput(e,t){if(t<=0)return 0;const i=Math.min(Math.abs(e),180);return 10**(-.4*(3.84+.026*i+4e-9*i**4))*10**(-.4*Ye.EXTINCTION_PER_AIR_MASS*Ye.airMass(t))}static phaseAngleOf(e){return Math.acos(Math.min(Math.max(2*e-1,-1),1))*180/Math.PI}static magPerArcsec2(e,t,i){const n=Ye.scatteredFraction(i),s=Ye.scatteringAt(e.separationDeg)*Ye.twilightOutput(e.altitudeDeg)*n,r=Ye.scatteringAt(t.separationDeg)*Ye.moonOutput(t.phaseAngleDeg,t.altitudeDeg)*n;return Ye.fromNanolamberts(Ye.toNanolamberts(Ye.AIRGLOW_MAG_PER_ARCSEC2)+s+r)}}class Os{static RADIUS=890;static TOO_BRIGHT_MAG_PER_ARCSEC2=16;static MILKY_WAY_TINT=[.9,.94,1];static ZODIACAL_TINT=[1,.97,.9];object;material;maps=ha.shared;milkyWayTexture;zodiacalTexture;milkyWayTexels;zodiacalTexels;repaint;constructor(){this.milkyWayTexels=this.maps.milkyWayTexels,this.milkyWayTexture=Os.buildTexture(this.milkyWayTexels,tt.LONGITUDE_STEPS,tt.LATITUDE_STEPS,Mo),this.zodiacalTexels=this.maps.zodiacalTexels,this.zodiacalTexture=Os.buildTexture(this.zodiacalTexels,Ut.LONGITUDE_STEPS,Ut.LATITUDE_STEPS,yi),this.material=new at({uniforms:{uMilkyWay:{value:this.milkyWayTexture},uZodiacal:{value:this.zodiacalTexture},uGalactic:{value:new Xe},uEclipticPole:{value:new D(0,1,0)},uSunLongitude:{value:new D(1,0,0)},uMoonDirection:{value:new D(0,-1,0)},uMoonOutput:{value:0},uSunDirection:{value:new D(0,-1,0)},uTwilightOutput:{value:0},uAirglowNanolamberts:{value:Ye.toNanolamberts(Ye.AIRGLOW_MAG_PER_ARCSEC2)},uSkyColor:{value:new D(0,0,0)},uMilkyWayTint:{value:new D(...Os.MILKY_WAY_TINT)},uZodiacalTint:{value:new D(...Os.ZODIACAL_TINT)},uReady:{value:this.maps.done?1:0},uEncodeDestination:{value:1}},vertexShader:`
|
|
5593
5601
|
varying vec3 vDirection;
|
|
5594
5602
|
void main() {
|
|
5595
5603
|
vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
|
|
@@ -5704,7 +5712,7 @@ void main() {
|
|
|
5704
5712
|
vec3 onEncoded = encodeSrgb(uSkyColor + light) - encodeSrgb(uSkyColor);
|
|
5705
5713
|
gl_FragColor = vec4(mix(light, onEncoded, uEncodeDestination), 1.0);
|
|
5706
5714
|
}
|
|
5707
|
-
`,transparent:!0,blending:
|
|
5715
|
+
`,transparent:!0,blending:Ci,depthWrite:!1,side:Ot,fog:!1}),this.object=new De(new Qt(Os.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}static buildTexture(e,t,i,n){const s=new $s(e,t,i,_i,kt);return s.minFilter=st,s.magFilter=st,s.wrapS=n,s.wrapT=yi,s.needsUpdate=!0,s}set onReady(e){this.repaint=e}update(e){if(Ye.moonlessMagPerArcsec2(e.sunAltitudeDeg)<Os.TOO_BRIGHT_MAG_PER_ARCSEC2){this.object.visible=!1,this.stopWork();return}const i=this.material.uniforms;i.uGalactic.value.copy(e.galactic),i.uEclipticPole.value.copy(e.eclipticPole).normalize(),i.uSunLongitude.value.copy(e.sunLongitude).normalize(),i.uMoonDirection.value.copy(e.moon.direction).normalize(),i.uSunDirection.value.copy(e.sunDirection).normalize(),i.uMoonOutput.value=Ye.moonOutput(e.moon.phaseAngleDeg,e.moon.altitudeDeg),i.uTwilightOutput.value=Ye.twilightOutput(e.sunAltitudeDeg),i.uSkyColor.value.copy(e.skyColor),this.object.visible=!0,i.uReady.value<.5&&this.scheduleWork()}setDestinationEncoded(e){this.material.uniforms.uEncodeDestination.value=e?1:0}hide(){this.object.visible=!1,this.stopWork()}scheduleWork(){this.maps.request(this.publish)}stopWork(){this.maps.cancel(this.publish)}publish=()=>{this.milkyWayTexture.needsUpdate=!0,this.zodiacalTexture.needsUpdate=!0,this.material.uniforms.uReady.value=1,this.repaint?.()};dispose(){this.stopWork(),this.milkyWayTexture.dispose(),this.zodiacalTexture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class ha{static instance;static get shared(){return ha.instance??=new ha}static WORK_BUDGET_MS=6;milkyWayTexels=new Uint16Array(tt.LONGITUDE_STEPS*tt.LATITUDE_STEPS*4);zodiacalTexels=new Uint16Array(Ut.LONGITUDE_STEPS*Ut.LATITUDE_STEPS*4);galaxy=new tt;dust=new Ut;waiting=new Set;workHandle;published=!1;get done(){return this.published}request(e){if(this.published){e();return}if(this.waiting.add(e),this.workHandle!==void 0)return;const t=()=>{this.workHandle=void 0;const i=performance.now()+ha.WORK_BUDGET_MS;for(;performance.now()<i&&!(this.galaxy.done&&this.dust.done);)this.galaxy.walk(1),this.dust.walk(1);if(this.galaxy.done&&this.dust.done){this.publish();return}this.workHandle=requestAnimationFrame(t)};this.workHandle=requestAnimationFrame(t)}cancel(e){this.waiting.delete(e),!(this.waiting.size>0||this.workHandle===void 0)&&(cancelAnimationFrame(this.workHandle),this.workHandle=void 0)}publish(){ha.fill(this.milkyWayTexels,this.galaxy.harvest()),ha.fill(this.zodiacalTexels,this.dust.harvest()),this.published=!0;const e=[...this.waiting];this.waiting.clear();for(const t of e)t()}static fill(e,t){for(let i=0;i<t.data.length;i++)e[i*4]=Dn.toHalfFloat(Ye.nanolambertsOfS10(t.data[i])),e[i*4+3]=Dn.toHalfFloat(1)}}class Sn{static GALACTIC_CENTRE={raHours:266.4051/15,decDeg:-28.936175};static GALACTIC_ROTATION={raHours:318.00448/15,decDeg:48.32964};static GALACTIC_POLE={raHours:192.85948/15,decDeg:27.12825};static ECLIPTIC_POLE={raHours:18,decDeg:90-23.439291};static galactic(e,t){return{centre:Sn.at(Sn.GALACTIC_CENTRE,e,t),rotation:Sn.at(Sn.GALACTIC_ROTATION,e,t),pole:Sn.at(Sn.GALACTIC_POLE,e,t)}}static eclipticPole(e,t){return Sn.at(Sn.ECLIPTIC_POLE,e,t)}static at(e,t,i){return En.ofJ2000(e.raHours,e.decDeg,t,i,!1)}}const _w=`
|
|
5708
5716
|
varying vec2 vUv;
|
|
5709
5717
|
void main() {
|
|
5710
5718
|
vUv = uv;
|
|
@@ -6148,7 +6156,7 @@ void main()
|
|
|
6148
6156
|
// stays what it always was for the optional artifacts.
|
|
6149
6157
|
gl_FragColor = vec4(dazzle + artifactsContribution * uOpacity, 1.0);
|
|
6150
6158
|
}
|
|
6151
|
-
`;let Sc;function ww(){if(Sc)return Sc;const a=256,e=document.createElement("canvas");e.width=a,e.height=a;const t=e.getContext("2d");t.fillStyle="rgba(60,60,60,1)",t.fillRect(0,0,a,a);const i=[[.3,.35,.22,.5],[.7,.6,.16,.35],[.55,.8,.3,.4],[.15,.7,.12,.3],[.85,.2,.18,.3]];for(const[n,s,r,o]of i){const c=t.createRadialGradient(n*a,s*a,0,n*a,s*a,r*a);c.addColorStop(0,`rgba(200,200,200,${o})`),c.addColorStop(1,"rgba(200,200,200,0)"),t.fillStyle=c,t.fillRect(0,0,a,a)}return Sc=new Ss(e),Sc}function bw(){const a={uTime:{value:0},uResolution:{value:new xe(1,1)},uLensPosition:{value:new xe(0,0)},uColorGain:{value:new se(55,55,51)},uOpacity:{value:.5},uFlareIntensity:{value:0},uStarPoints:{value:0},uTanHalfFov:{value:Math.tan(Math.PI/6)},uEquidistant:{value:0},uHalfFovRad:{value:Math.PI/6},uSourceRadiusDeg:{value:.265},uVeilStrength:{value:0},uDazzleColour:{value:new se(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:ww()}},e=new at({uniforms:a,vertexShader:_w,fragmentShader:Sw,transparent:!0,depthWrite:!1,depthTest:!1,blending:
|
|
6159
|
+
`;let Sc;function ww(){if(Sc)return Sc;const a=256,e=document.createElement("canvas");e.width=a,e.height=a;const t=e.getContext("2d");t.fillStyle="rgba(60,60,60,1)",t.fillRect(0,0,a,a);const i=[[.3,.35,.22,.5],[.7,.6,.16,.35],[.55,.8,.3,.4],[.15,.7,.12,.3],[.85,.2,.18,.3]];for(const[n,s,r,o]of i){const c=t.createRadialGradient(n*a,s*a,0,n*a,s*a,r*a);c.addColorStop(0,`rgba(200,200,200,${o})`),c.addColorStop(1,"rgba(200,200,200,0)"),t.fillStyle=c,t.fillRect(0,0,a,a)}return Sc=new Ss(e),Sc}function bw(){const a={uTime:{value:0},uResolution:{value:new xe(1,1)},uLensPosition:{value:new xe(0,0)},uColorGain:{value:new se(55,55,51)},uOpacity:{value:.5},uFlareIntensity:{value:0},uStarPoints:{value:0},uTanHalfFov:{value:Math.tan(Math.PI/6)},uEquidistant:{value:0},uHalfFovRad:{value:Math.PI/6},uSourceRadiusDeg:{value:.265},uVeilStrength:{value:0},uDazzleColour:{value:new se(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:ww()}},e=new at({uniforms:a,vertexShader:_w,fragmentShader:Sw,transparent:!0,depthWrite:!1,depthTest:!1,blending:Ci,fog:!1,name:"LensFlareShader"}),t=new De(new ki(2,2),e);return t.frustumCulled=!1,t.renderOrder=20,{mesh:t,uniforms:a}}class mi{static MAX_HALF_ANGLE_DEG=80;static MAX_CUBE_FACE=2048;static SAMPLES=4;cubeTarget;cubeCamera;cubeMaterial;cubeRotation=new Xe;target;overlayTarget;overlayCubeTarget;quadScene=new xs;quadCamera=new Cn(-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 jt(this.width,this.height,{type:kt,samples:mi.SAMPLES}),this.overlayTarget=new jt(this.width,this.height,{type:kt,samples:mi.SAMPLES}),this.material=new at({uniforms:{...fn,uSource:{value:this.target.texture},uHalfFovRad:{value:.5236},uAspect:{value:this.width/this.height},uSrcTanHalfFovY:{value:1},uResolution:{value:new xe(this.width,this.height)},uOverlay:{value:this.overlayTarget.texture},uMode:{value:en.Finished}},vertexShader:`
|
|
6152
6160
|
varying vec2 vNdc;
|
|
6153
6161
|
void main() {
|
|
6154
6162
|
vNdc = position.xy;
|
|
@@ -6194,7 +6202,7 @@ void main()
|
|
|
6194
6202
|
// when the frame is on its way into a longer exposure, which has to add up light.
|
|
6195
6203
|
${ao}
|
|
6196
6204
|
}
|
|
6197
|
-
`,depthTest:!1,depthWrite:!1}),this.quadScene.add(new De(new ki(2,2),this.material))}directionFor(e,t,i){const n=this.width/this.height,s=i/2*Math.PI/180,r=e*n*s,o=t*s,c=Math.hypot(r,o);if(c<1e-6)return{x:0,y:0,z:-1};const l=Math.sin(c);return{x:r/c*l,y:o/c*l,z:-Math.cos(c)}}static ndcFor(e,t,i){const n=Math.hypot(e.x,e.y,e.z);if(n===0||e.z>=n)return;const s=t/2*Math.PI/180,r=Math.acos(Math.min(1,-e.z/n)),o=Math.sin(r),c=o<1e-9?1:r/o,l=e.x/n*c,h=e.y/n*c;return{ndcX:l/(i*s),ndcY:h/s}}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.overlayTarget.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,i,n,s,r,o,c,l){const h=this.width/this.height;if(!
|
|
6205
|
+
`,depthTest:!1,depthWrite:!1}),this.quadScene.add(new De(new ki(2,2),this.material))}directionFor(e,t,i){const n=this.width/this.height,s=i/2*Math.PI/180,r=e*n*s,o=t*s,c=Math.hypot(r,o);if(c<1e-6)return{x:0,y:0,z:-1};const l=Math.sin(c);return{x:r/c*l,y:o/c*l,z:-Math.cos(c)}}static ndcFor(e,t,i){const n=Math.hypot(e.x,e.y,e.z);if(n===0||e.z>=n)return;const s=t/2*Math.PI/180,r=Math.acos(Math.min(1,-e.z/n)),o=Math.sin(r),c=o<1e-9?1:r/o,l=e.x/n*c,h=e.y/n*c;return{ndcX:l/(i*s),ndcY:h/s}}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.overlayTarget.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,i,n,s,r,o,c,l){const h=this.width/this.height;if(!mi.supports(n,h)){o?.(!0),this.renderThroughCube(e,t,i,n,r,c,l),o?.(!1);return}this.material.uniforms.uHalfFovRad.value=n/2*Math.PI/180,this.material.uniforms.uSrcTanHalfFovY.value=this.sourceTanHalfFovY(n,h);const u=i.fov;i.fov=this.sourceFovDeg(n,h),i.updateProjectionMatrix(),s?.();const d=e.getRenderTarget();e.setRenderTarget(this.target),e.render(t,i),r&&(mi.clearTransparent(e,this.overlayTarget),r(i)),e.setRenderTarget(d),i.fov=u,i.updateProjectionMatrix(),this.resample(e,this.quadScene.children[0],this.material,d,l)}resample(e,t,i,n,s){const r=t.material;t.material=i,s?(i.uniforms.uMode.value=en.Scene,e.setRenderTarget(s.scene),e.render(this.quadScene,this.quadCamera),i.uniforms.uMode.value=en.Overlay,e.setRenderTarget(s.overlay),e.render(this.quadScene,this.quadCamera),e.setRenderTarget(n)):(i.uniforms.uMode.value=en.Finished,e.setRenderTarget(n),e.render(this.quadScene,this.quadCamera)),t.material=r}static clearTransparent(e,t,i){const n=e.getClearColor(mi.clearScratch),s=e.getClearAlpha(),r=e.autoClear;e.setRenderTarget(t,i),e.setClearColor(0,0),e.clear(!0,!0,!0),e.setClearColor(n,s),t.samples>0&&(e.autoClear=!1,e.render(mi.nothing,mi.nothingCamera),e.autoClear=r)}static nothing=new xs;static nothingCamera=new Cn;static clearScratch=new se;renderThroughCube(e,t,i,n,s,r,o){const c=n*Math.PI/180,l=Math.min(mi.MAX_CUBE_FACE,e.capabilities.maxCubemapSize,Math.max(256,Math.ceil(this.height/c*Math.PI/2))),h={type:kt,minFilter:st,magFilter:st,generateMipmaps:!1};!this.cubeTarget||!this.cubeCamera||!this.cubeMaterial||!this.overlayCubeTarget?(this.cubeTarget=new wo(l,h),this.overlayCubeTarget=new wo(l,h),this.cubeCamera=new Zd(i.near,i.far,this.cubeTarget),this.cubeMaterial=this.buildCubeMaterial(this.cubeTarget,this.overlayCubeTarget)):this.cubeTarget.width!==l&&(this.cubeTarget.setSize(l,l),this.overlayCubeTarget.setSize(l,l));const u=this.cubeCamera;i.updateMatrixWorld(),u.position.setFromMatrixPosition(i.matrixWorld),u.updateMatrixWorld(),u.coordinateSystem!==e.coordinateSystem&&(u.coordinateSystem=e.coordinateSystem,u.updateCoordinateSystem());const d=e.getRenderTarget(),f=e.shadowMap.autoUpdate,p=this.forwardScratch.set(0,0,-1).applyQuaternion(i.getWorldQuaternion(this.quaternionScratch)),v=mi.cornerHalfAngleDeg(n,this.width/this.height);u.children.forEach((_,w)=>{const M=_;mi.faceSeen(M,p,v)&&((M.near!==i.near||M.far!==i.far)&&(M.near=i.near,M.far=i.far,M.updateProjectionMatrix()),e.setRenderTarget(this.cubeTarget,w),e.render(t,M),s&&(mi.clearTransparent(e,this.overlayCubeTarget,w),s(M)),e.shadowMap.autoUpdate=!1)}),e.shadowMap.autoUpdate=f;const m=this.cubeMaterial.uniforms;m.uHalfFovRad.value=c/2,m.uAspect.value=this.width/this.height,m.uCameraRotation.value.setFromMatrix4(i.matrixWorld);const g=this.quadScene.children[0];this.resample(e,g,this.cubeMaterial,d,{scene:this.target,overlay:this.overlayTarget}),e.setRenderTarget(this.target),r?.(),this.resample(e,g,this.copyMaterial(),d,o)}copy;copyMaterial(){return this.copy??=new at({uniforms:{...fn,uSource:{value:this.target.texture},uOverlay:{value:this.overlayTarget.texture},uMode:{value:en.Finished}},vertexShader:`
|
|
6198
6206
|
varying vec2 vUv;
|
|
6199
6207
|
void main() {
|
|
6200
6208
|
vUv = position.xy * 0.5 + 0.5;
|
|
@@ -6212,7 +6220,7 @@ void main()
|
|
|
6212
6220
|
vec4 overlay = texture2D(uOverlay, vUv);
|
|
6213
6221
|
${ao}
|
|
6214
6222
|
}
|
|
6215
|
-
`,depthTest:!1,depthWrite:!1}),this.copy}forwardScratch=new D;quaternionScratch=new Qn;static faceSeen(e,t,i){e.updateMatrixWorld();const n=Math.cos(Math.min(i+5,180)*Math.PI/180),s=
|
|
6223
|
+
`,depthTest:!1,depthWrite:!1}),this.copy}forwardScratch=new D;quaternionScratch=new Qn;static faceSeen(e,t,i){e.updateMatrixWorld();const n=Math.cos(Math.min(i+5,180)*Math.PI/180),s=mi.faceScratch;for(let r=0;r<=4;r++)for(let o=0;o<=4;o++)if(s.set(-1+r/2,-1+o/2,-1).normalize().transformDirection(e.matrixWorld),s.dot(t)>=n)return!0;return!1}static faceScratch=new D;buildCubeMaterial(e,t){return new at({uniforms:{...fn,uCube:{value:e.texture},uOverlayCube:{value:t.texture},uHalfFovRad:{value:.5236},uAspect:{value:1},uCameraRotation:{value:this.cubeRotation},uMode:{value:en.Finished}},vertexShader:`
|
|
6216
6224
|
varying vec2 vNdc;
|
|
6217
6225
|
void main() {
|
|
6218
6226
|
vNdc = position.xy;
|
|
@@ -6247,7 +6255,7 @@ void main()
|
|
|
6247
6255
|
}
|
|
6248
6256
|
${ao}
|
|
6249
6257
|
}
|
|
6250
|
-
`,depthTest:!1,depthWrite:!1})}sourceFovDeg(e,t){return Math.atan(this.sourceTanHalfFovY(e,t))*360/Math.PI}sourceTanHalfFovY(e,t){const i=
|
|
6258
|
+
`,depthTest:!1,depthWrite:!1})}sourceFovDeg(e,t){return Math.atan(this.sourceTanHalfFovY(e,t))*360/Math.PI}sourceTanHalfFovY(e,t){const i=mi.cornerHalfAngleDeg(e,t)*Math.PI/180;return Math.tan(i)/Math.hypot(t,1)}dispose(){this.target.dispose(),this.overlayTarget.dispose(),this.material.dispose(),this.cubeTarget?.dispose(),this.overlayCubeTarget?.dispose(),this.cubeMaterial?.dispose(),this.copy?.dispose(),this.quadScene.clear()}}class co{static MAX_RADIUS_PX=24;static TAPS=32;target;overlayTarget;quadScene=new xs;quadCamera=new Cn(-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 i=new Ys(this.width,this.height,gn);i.minFilter=wt,i.magFilter=wt,this.target=new jt(this.width,this.height,{type:kt,depthTexture:i});const n=new Ys(this.width,this.height,gn);n.minFilter=wt,n.magFilter=wt,this.overlayTarget=new jt(this.width,this.height,{type:kt,depthTexture:n}),this.material=new at({uniforms:{...fn,uColour:{value:this.target.texture},uDepth:{value:i},uResolution:{value:new xe(this.width,this.height)},uNear:{value:.1},uFar:{value:1e3},uApertureMm2:{value:0},uFocusDistance:{value:0},uFocalLengthMm:{value:50},uPixelsPerMm:{value:0},uMaxRadius:{value:co.MAX_RADIUS_PX},uOverlay:{value:this.overlayTarget.texture},uOverlayDepth:{value:n},uMode:{value:en.Finished}},vertexShader:`
|
|
6251
6259
|
varying vec2 vUv;
|
|
6252
6260
|
void main() {
|
|
6253
6261
|
vUv = position.xy * 0.5 + 0.5;
|
|
@@ -6327,7 +6335,7 @@ void main()
|
|
|
6327
6335
|
vec4 overlay = throughLens(uOverlay, uOverlayDepth);
|
|
6328
6336
|
${ao}
|
|
6329
6337
|
}
|
|
6330
|
-
`,depthTest:!1,depthWrite:!1}),this.quadScene.add(new De(new ki(2,2),this.material))}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target.setSize(this.width,this.height),this.overlayTarget.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height)}setLens(e,t,i,n){const s=this.material.uniforms;s.uApertureMm2.value=e*e/Math.max(.1,t),s.uFocusDistance.value=Math.max(0,i),s.uFocalLengthMm.value=e,s.uPixelsPerMm.value=this.height/Math.max(.1,n)}render(e,t,i,n,s){const r=this.material.uniforms;r.uNear.value=i.near,r.uFar.value=i.far;const o=e.getRenderTarget();e.setRenderTarget(this.target),e.clear(),e.render(t,i),n&&(
|
|
6338
|
+
`,depthTest:!1,depthWrite:!1}),this.quadScene.add(new De(new ki(2,2),this.material))}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target.setSize(this.width,this.height),this.overlayTarget.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height)}setLens(e,t,i,n){const s=this.material.uniforms;s.uApertureMm2.value=e*e/Math.max(.1,t),s.uFocusDistance.value=Math.max(0,i),s.uFocalLengthMm.value=e,s.uPixelsPerMm.value=this.height/Math.max(.1,n)}render(e,t,i,n,s){const r=this.material.uniforms;r.uNear.value=i.near,r.uFar.value=i.far;const o=e.getRenderTarget();e.setRenderTarget(this.target),e.clear(),e.render(t,i),n&&(mi.clearTransparent(e,this.overlayTarget),n()),s?(r.uMode.value=en.Scene,e.setRenderTarget(s.scene),e.render(this.quadScene,this.quadCamera),r.uMode.value=en.Overlay,e.setRenderTarget(s.overlay),e.render(this.quadScene,this.quadCamera)):(r.uMode.value=en.Finished,e.setRenderTarget(o),e.render(this.quadScene,this.quadCamera)),e.setRenderTarget(o)}dispose(){this.target.depthTexture?.dispose(),this.target.dispose(),this.overlayTarget.depthTexture?.dispose(),this.overlayTarget.dispose(),this.material.dispose()}}class d0{static SAMPLES=4;scene;overlay;quadScene=new xs;quadCamera=new Cn(-1,1,1,-1,0,1);material;constructor(e,t){const i={type:kt,samples:d0.SAMPLES};this.scene=new jt(Math.max(1,e),Math.max(1,t),i),this.overlay=new jt(Math.max(1,e),Math.max(1,t),i),this.material=new at({uniforms:{...fn,uSource:{value:this.scene.texture},uOverlay:{value:this.overlay.texture},uMode:{value:en.Finished}},vertexShader:`
|
|
6331
6339
|
varying vec2 vUv;
|
|
6332
6340
|
void main() {
|
|
6333
6341
|
vUv = position.xy * 0.5 + 0.5;
|
|
@@ -6345,7 +6353,7 @@ void main()
|
|
|
6345
6353
|
vec4 overlay = texture2D(uOverlay, vUv);
|
|
6346
6354
|
${ao}
|
|
6347
6355
|
}
|
|
6348
|
-
`,depthTest:!1,depthWrite:!1}),this.quadScene.add(new De(new ki(2,2),this.material))}render(e,t,i,n,s,r){const o=e.getRenderTarget(),c=r??{scene:this.scene,overlay:this.overlay};e.setRenderTarget(c.scene),e.render(t,i),s?.(),(n||r)&&(pi.clearTransparent(e,c.overlay),n?.()),e.setRenderTarget(o),!r&&(this.material.uniforms.uMode.value=en.Finished,e.render(this.quadScene,this.quadCamera))}resize(e,t){this.scene.setSize(Math.max(1,e),Math.max(1,t)),this.overlay.setSize(Math.max(1,e),Math.max(1,t))}dispose(){this.scene.dispose(),this.overlay.dispose(),this.material.dispose(),this.quadScene.children[0].geometry.dispose()}}class dt{static MIN_RATIO=1;static STEP=.25;static MIN_SHARE_OF_DISPLAY=.75;static GPU_LATE_MS=12;static GPU_ROOM_MS=6;static INTERVAL_LATE_MS=21;static LOWER_COOLDOWN_MS=750;static RAISE_COOLDOWN_MS=2e3;static PROBE_WATCH_MS=2e3;static PROBE_EVERY_MS=6e3;static PROBE_BACKOFF_MS=3e4;ratio;maxRatio;timer;intervalMs;lastChangeMs=-1/0;nextProbeMs=0;probe;constructor(e,t){this.maxRatio=dt.clamp(e),this.ratio=this.maxRatio,this.timer=t?fl.create(t):void 0}get pixelRatio(){return this.ratio}static SETTLE_MS=400;static SUSTAINED_MS=100;lastEditMs=-1/0;editStreakStartMs=-1/0;wasChanging=!1;noteChange(e){e-this.lastEditMs>dt.SETTLE_MS&&(this.editStreakStartMs=e),this.lastEditMs=e}changing(e){return e-this.lastEditMs<=dt.SETTLE_MS&&this.lastEditMs-this.editStreakStartMs>=dt.SUSTAINED_MS}ratioFor(e,t){return this.changing(e)?this.wasChanging?(this.update(e,t),this.ratio):(this.wasChanging=!0,this.reset(),this.ratio):(this.wasChanging=!1,this.maxRatio)}get timesGpu(){return this.timer!==void 0}set maximum(e){this.maxRatio=dt.clamp(e),this.ratio>this.maxRatio&&(this.ratio=this.maxRatio),this.ratio<this.minimum&&(this.ratio=Math.min(this.maxRatio,this.minimum))}get minimum(){const e=Math.floor(this.maxRatio*dt.MIN_SHARE_OF_DISPLAY/dt.STEP)*dt.STEP;return Math.max(dt.MIN_RATIO,e)}get maximum(){return this.maxRatio}beginDrawing(){this.timer?.begin()}endDrawing(){this.timer?.end()}reset(){this.intervalMs=void 0,this.probe=void 0,this.timer?.reset()}update(e,t){const i=this.timer?.poll();if(!(this.timer&&i===void 0))return i!==void 0?this.followGpu(e,i):this.followIntervals(e,t)}followGpu(e,t){if(t>dt.GPU_LATE_MS)return this.lower(e,dt.LOWER_COOLDOWN_MS);if(t<dt.GPU_ROOM_MS)return this.raise(e,dt.RAISE_COOLDOWN_MS)}followIntervals(e,t){if(!(t>0)||t>1e3)return;this.intervalMs=this.intervalMs===void 0?t:this.intervalMs*.9+t*.1;const i=this.intervalMs>dt.INTERVAL_LATE_MS;if(this.probe){if(i)return this.ratio=this.probe.ratioBefore,this.probe=void 0,this.lastChangeMs=e,this.nextProbeMs=e+dt.PROBE_BACKOFF_MS,this.ratio;e-this.probe.sinceMs>=dt.PROBE_WATCH_MS&&(this.probe=void 0,this.nextProbeMs=e+dt.PROBE_EVERY_MS);return}if(i){const n=this.lower(e,dt.LOWER_COOLDOWN_MS);return n!==void 0&&(this.nextProbeMs=e+dt.PROBE_EVERY_MS),n}if(this.ratio<this.maxRatio&&e>=this.nextProbeMs&&e-this.lastChangeMs>=dt.RAISE_COOLDOWN_MS){const n=this.ratio,s=this.raise(e,0);return s!==void 0&&(this.probe={sinceMs:e,ratioBefore:n}),s}}lower(e,t){if(!(this.ratio<=this.minimum||e-this.lastChangeMs<t))return this.ratio=Math.max(this.minimum,dt.clamp(this.ratio-dt.STEP)),this.lastChangeMs=e,this.ratio}raise(e,t){if(!(this.ratio>=this.maxRatio||e-this.lastChangeMs<t))return this.ratio=Math.min(this.maxRatio,dt.clamp(this.ratio+dt.STEP)),this.lastChangeMs=e,this.ratio}static clamp(e){return Number.isFinite(e)?Math.max(dt.MIN_RATIO,Math.round(e/dt.STEP)*dt.STEP):dt.MIN_RATIO}}class fl{constructor(e,t){this.gl=e,this.extension=t}static IN_FLIGHT_MAX=8;static create(e){if(!(e instanceof WebGL2RenderingContext))return;const t=e.getExtension("EXT_disjoint_timer_query_webgl2");return t?new fl(e,t):void 0}pending=[];active;smoothedMs;begin(){if(!(this.active||this.pending.length>=fl.IN_FLIGHT_MAX))try{const e=this.gl.createQuery();if(!e)return;this.gl.beginQuery(this.extension.TIME_ELAPSED_EXT,e),this.active=e}catch{this.active=void 0}}end(){if(this.active){try{this.gl.endQuery(this.extension.TIME_ELAPSED_EXT),this.pending.push(this.active)}catch{}this.active=void 0}}poll(){const e=this.gl;try{for(let t=0;t<this.pending.length;t++){const i=this.pending[t];if(!e.getQueryParameter(i,e.QUERY_RESULT_AVAILABLE))continue;if(!e.getParameter(this.extension.GPU_DISJOINT_EXT)){const s=e.getQueryParameter(i,e.QUERY_RESULT)/1e6;this.smoothedMs=this.smoothedMs===void 0?s:this.smoothedMs*.8+s*.2}e.deleteQuery(i),this.pending.splice(t,1),t--}}catch{this.pending.length=0}return this.smoothedMs}reset(){this.smoothedMs=void 0}}class lt{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=lt.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 i=e*Math.PI/180,n=t*Math.sin(i/2);return n>1?Number.NaN:(2*Math.asin(n)-i)*180/Math.PI}static effectiveIndex(e,t){const i=t*Math.PI/180,n=Math.cos(i);return n<=0?Number.POSITIVE_INFINITY:Math.sqrt(e*e-Math.sin(i)**2)/n}static parheliaAzimuthDeg(e,t=lt.ICE_INDEX_RED){const i=lt.minimumDeviationDeg(lt.SIDE_PRISM_ANGLE_DEG,lt.effectiveIndex(t,e));return Number.isFinite(i)?i:void 0}static parheliaDistanceDeg(e,t=lt.ICE_INDEX_RED){const i=lt.parheliaAzimuthDeg(e,t);if(i===void 0)return;const n=e*Math.PI/180,s=Math.sin(n)**2,r=Math.cos(n)**2*Math.cos(i*Math.PI/180);return Math.acos(Math.max(-1,Math.min(1,s+r)))*180/Math.PI}static get PLATE_END_FACE_LIMIT_DEG(){const e=lt.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(e*e-1)))*180/Math.PI}static circumzenithalAltitudeDeg(e,t=lt.ICE_INDEX_RED){if(e<0||e>90-lt.PLATE_END_FACE_LIMIT_DEG)return;const i=Math.cos(e*Math.PI/180),n=Math.sqrt(t*t-i*i);if(!(n>=1))return Math.asin(n)*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 lt.ringOf("halo22",lt.SIDE_PRISM_ANGLE_DEG)}static halo46(){return lt.ringOf("halo46",lt.END_PRISM_ANGLE_DEG)}static ringOf(e,t){const i=lt.minimumDeviationDeg(t,lt.ICE_INDEX_RED),n=lt.minimumDeviationDeg(t,lt.ICE_INDEX_BLUE);return{id:e,angleDeg:(i+n)/2,redAngleDeg:i,blueAngleDeg:n}}static strength(e,t,i=90,n=0){const s=Math.max(0,Math.min(1,e)),r=Math.max(0,1-Math.max(0,Math.min(1,t))),o=i>=0?1:n<=0?0:Math.max(0,1+i/n);return s*r*o}static formsAt(e,t=0){if(e<=-t)return[];const i=[lt.halo22(),lt.halo46()],n=e>0?lt.parheliaDistanceDeg(e):void 0;n!==void 0&&i.push({id:"parhelia",angleDeg:n,redAngleDeg:n,blueAngleDeg:lt.parheliaDistanceDeg(e,lt.ICE_INDEX_BLUE)}),i.push({id:"tangentArc",angleDeg:lt.halo22().angleDeg}),e>0&&i.push({id:"parhelicCircle",angleDeg:e});const s=lt.circumzenithalAltitudeDeg(e);return s!==void 0&&i.push({id:"circumzenithal",angleDeg:s}),e>lt.PLATE_END_FACE_LIMIT_DEG&&i.push({id:"circumhorizontal"}),e<lt.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&i.push({id:"pillar"}),i}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class $i{static get WATER_INDEX_RED(){return mi.indexAt(mi.RED_NM)}static get WATER_INDEX_BLUE(){return mi.indexAt(mi.BLUE_NM)}static radiusDeg(e,t){const i=(t*t-1)/(e*e-1);if(i<0||i>1)return Number.NaN;const n=Math.acos(Math.sqrt(i)),s=Math.asin(Math.sin(n)/t),r=2*(n-s)+(e-1)*(Math.PI-2*s),o=2*Math.PI;let c=r%o;return c<0&&(c+=o),c>Math.PI&&(c=o-c),180-c*180/Math.PI}static primary(){return $i.bowOf("primary",2,0)}static secondary(){return $i.bowOf("secondary",3,0)}static bowOf(e,t,i){const n=$i.radiusDeg(t,$i.WATER_INDEX_RED),s=$i.radiusDeg(t,$i.WATER_INDEX_BLUE),r=(n+s)/2;return{id:e,radiusDeg:r,redRadiusDeg:n,violetRadiusDeg:s,topAltitudeDeg:r-i}}static alexandersBandDeg(){return{fromDeg:$i.primary().redRadiusDeg,toDeg:$i.secondary().redRadiusDeg}}static formsAt(e){return e<0?[]:[$i.bowOf("primary",2,e),$i.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-$i.FULL_MOON_MAGNITUDE)))}static strength(e,t,i){if(i<=0)return 0;const n=Math.max(0,Math.min(1,e)),s=Math.max(0,1-Math.max(0,Math.min(1,t)));return n*s}}class Zi{constructor(e){this.radius=e;const t=Zi.SEGMENTS*Zi.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const i=new ut;i.setAttribute("position",new et(this.positions,3)),i.setAttribute("color",new et(this.colors,3)),i.setDrawRange(0,0),this.object=new De(i,new mn({vertexColors:!0,transparent:!0,blending:Di,depthWrite:!1,fog:!1,side:tn})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=Zi.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(Zi.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,i){this.head=e&&ii(e.altitudeDeg,e.azimuthDeg,1),this.tip=t&&ii(t.altitudeDeg,t.azimuthDeg,1),this.brightness=i,this.rebuild()}rebuild(){const e=this.object.geometry,t=this.head,i=this.tip;if(!t||!i||this.brightness<=0){e.setDrawRange(0,0);return}const n=this.angleBetween(t,i);if(n<=0){e.setDrawRange(0,0);return}const s=n*Zi.SPREAD_FRACTION*Math.PI/180,r=h=>this.scale(this.slerp(t,i,h),this.radius),o=h=>this.radius*(Zi.HEAD_HALF_WIDTH_DEG*Math.PI/180+s*h),c=h=>this.brightness*(1-h)**Zi.FADE_POWER;let l=0;for(let h=1;h<Zi.POINTS;h++){const u=(h-1)/Zi.SEGMENTS,d=h/Zi.SEGMENTS;l=this.pushBand(l,r(u),r(d),o(u),o(d),c(u),c(d))}e.setDrawRange(0,l),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}pushBand(e,t,i,n,s,r,o){const c=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(i,t))));for(let l=0;l<Zi.ACROSS-1;l++){const h=l-1,u=l,d=this.across(t,c,n,h),f=this.across(i,c,s,h),p=this.across(t,c,n,u),v=this.across(i,c,s,u),m=(g,_)=>g===0?_:0;e=this.push(e,d,m(h,r)),e=this.push(e,f,m(h,o)),e=this.push(e,p,m(u,r)),e=this.push(e,f,m(h,o)),e=this.push(e,v,m(u,o)),e=this.push(e,p,m(u,r))}return e}across(e,t,i,n){return{x:e.x+t.x*i*n,y:e.y+t.y*i*n,z:e.z+t.z*i*n}}push(e,t,i){const n=e*3;this.positions[n]=t.x,this.positions[n+1]=t.y,this.positions[n+2]=t.z;const s=Ee.relativeOfResponse(Math.max(0,Math.min(1,i)));return this.colors[n]=s*.55,this.colors[n+1]=s*.75,this.colors[n+2]=s,e+1}slerp(e,t,i){const n=this.angleBetweenRadians(e,t);if(n<1e-9)return e;const s=Math.sin(n),r=Math.sin((1-i)*n)/s,o=Math.sin(i*n)/s;return{x:e.x*r+t.x*o,y:e.y*r+t.y*o,z:e.z*r+t.z*o}}angleBetween(e,t){return this.angleBetweenRadians(e,t)*180/Math.PI}angleBetweenRadians(e,t){const i=e.x*t.x+e.y*t.y+e.z*t.z;return Math.acos(Math.min(1,Math.max(-1,i)))}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 Ew{object=new Dt;radius;tiers;drawn=[];constructor(e){this.radius=e,this.object.name="satellites",this.tiers=ro.map(t=>{const i=new us(new ut,Ni.material(t.size));return i.frustumCulled=!1,this.object.add(i),i})}set(e,t,i,n){const s=this.tiers.map(()=>[]);this.drawn=[];for(const r of e){const o=i(r.position);if(o<=0)continue;const c=r.magnitude-2.5*Math.log10(o);if(c>t)continue;const l=jr(c,t),h=zg(l),{x:u,y:d,z:f}=ii(r.position.altitudeDeg,r.position.azimuthDeg,this.radius),[p,v,m]=n(r.position,c);s[h].push({x:u,y:d,z:f,r:p,g:v,b:m}),this.drawn.push({satellite:r,direction:new D(u,d,f).normalize()})}this.tiers.forEach((r,o)=>{const c=s[o],l=new Float32Array(c.length*3),h=new Float32Array(c.length*3);c.forEach((d,f)=>{l.set([d.x,d.y,d.z],f*3),h.set([d.r,d.g,d.b],f*3)}),r.geometry.dispose();const u=new ut;u.setAttribute("position",new et(l,3)),u.setAttribute("color",new et(h,3)),r.geometry=u})}get count(){return this.drawn.length}nearest(e,t){let i,n=t;for(const s of this.drawn){const r=s.direction.dot(e);r>n&&(n=r,i=s.satellite)}return i}dispose(){for(const e of this.tiers)e.geometry.dispose(),e.material.dispose();this.object.removeFromParent(),this.drawn=[]}}class Il{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 va{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(e){const{ratePerHour:t,durationMs:i,velocityKmS:n,seed:s}=e;if(t<=0||i<=0)return[];const r=t*i/36e5,o=new Il(s),c=Math.floor(r),l=c+(o.next()<r-c?1:0),h=[];for(let u=0;u<l;u++){const d=Math.min(1,Math.max(0,(n-20)/52)),f=va.MAX_DURATION_MS-d*(va.MAX_DURATION_MS-va.MIN_DURATION_MS),p=o.between(5,70);h.push({t:o.between(0,i),durationMs:f*o.between(.7,1.3),fromRadiantDeg:p,bearingDeg:o.between(0,360),lengthDeg:Math.sin(p*Math.PI/180)*o.between(8,40)*(.6+d),brightness:o.next()**3}),h.sort((v,m)=>v.t-m.t)}return h}static aliveAt(e,t){return e.filter(i=>t>=i.t&&t<=i.t+i.durationMs).map(i=>({meteor:i,progress:(t-i.t)/i.durationMs}))}}class Us{object=new Dt;radius;core;glow;flashKey;static CORE_WIDTH_DEG=.06;static GLOW_WIDTH_DEG=.5;static SEGMENTS=28;static CORE_RELATIVE=1e3;constructor(e){this.radius=e,this.object.name="lightning-bolt",this.core=new mn({color:15659775,transparent:!0,opacity:0,blending:Di,depthWrite:!1,fog:!1}),this.glow=new mn({color:10466559,transparent:!0,opacity:0,blending:Di,depthWrite:!1,fog:!1}),this.object.visible=!1,this.object.renderOrder=5.95}set(e,t,i){if(!e||!e.cloudToGround||t<=.01){this.object.visible=!1;return}const n=`${e.channelSeed}:${Math.round(i)}`;n!==this.flashKey&&this.build(e,i,n),this.core.color.setHex(15659775).multiplyScalar(Us.CORE_RELATIVE*Math.min(1,t*1.4)),this.glow.color.setHex(10466559).multiplyScalar(.1*Us.CORE_RELATIVE*t*.35),this.core.opacity=1,this.glow.opacity=1,this.object.visible=!0}build(e,t,i){this.flashKey=i;for(const l of[...this.object.children])l.geometry.dispose(),this.object.remove(l);const n=new Il(e.channelSeed),s=Math.atan2(t,e.distanceM)*180/Math.PI,r=this.channel(n,e.azimuthDeg,s,0,1),o=[r],c=1+Math.floor(n.next()*2);for(let l=0;l<c;l++){const h=r[Math.floor(n.between(.15,.5)*r.length)];o.push(this.channel(n,h.azimuthDeg,h.altitudeDeg,h.altitudeDeg*n.between(.3,.7),.5))}for(const l of o)this.object.add(new De(this.ribbon(l,Us.GLOW_WIDTH_DEG),this.glow)),this.object.add(new De(this.ribbon(l,Us.CORE_WIDTH_DEG),this.core))}channel(e,t,i,n,s){const r=[],o=i-n;let c=t;for(let l=0;l<=Us.SEGMENTS;l++){const h=i-o*l/Us.SEGMENTS;r.push({azimuthDeg:c,altitudeDeg:h}),c+=e.between(-1,1)*o*.06*s}return r}ribbon(e,t){const i=new Float32Array(e.length*2*3),n=[],s=this.radius*Math.tan(t*Math.PI/180)/2,r=e.map(c=>{const{x:l,y:h,z:u}=ii(c.altitudeDeg,c.azimuthDeg,this.radius);return new D(l,h,u)});r.forEach((c,l)=>{const h=r[Math.min(l+1,r.length-1)],u=r[Math.max(l-1,0)],f=h.clone().sub(u).normalize().cross(c.clone().normalize()).normalize().multiplyScalar(s);if(i.set([c.x+f.x,c.y+f.y,c.z+f.z],l*6),i.set([c.x-f.x,c.y-f.y,c.z-f.z],l*6+3),l<r.length-1){const p=l*2;n.push(p,p+1,p+2,p+1,p+3,p+2)}});const o=new ut;return o.setAttribute("position",new et(i,3)),o.setIndex(n),o}dispose(){for(const e of this.object.children)e.geometry.dispose();this.core.dispose(),this.glow.dispose(),this.object.removeFromParent()}}class ri{static MIN_INTERVAL_S=8;static MAX_INTERVAL_S=25;static SEVERE_MIN_INTERVAL_S=2;static SEVERE_MAX_INTERVAL_S=8;static CLOUD_TO_GROUND_FRACTION=.25;static MIN_DISTANCE_M=1e3;static MAX_DISTANCE_M=15e3;static INTERSTROKE_MS=60;static STROKE_DECAY_MS=40;static SOUND_SPEED_M_S=343;static schedule(e){const t=new Il(e.seed),i=[],{minS:n,maxS:s}=ri.intervalFor(e.intensity??.5);let r=t.between(0,s)*1e3;for(;r<e.durationMs;){const o=t.next()<ri.CLOUD_TO_GROUND_FRACTION,c=ri.MIN_DISTANCE_M,l=ri.MAX_DISTANCE_M,h=Math.sqrt(t.between(c*c,l*l)),u=o?1+Math.floor(t.next()*4):1,d=[];let f=0;for(let p=0;p<u;p++)d.push({offsetMs:f,intensity:p===0?1:t.between(.4,.9)}),f+=ri.INTERSTROKE_MS*t.between(.5,1.6);i.push({t:r,azimuthDeg:t.between(0,360),distanceM:h,cloudToGround:o,strokes:d,channelSeed:Math.floor(t.next()*2**31)}),r+=t.between(n,s)*1e3}return i}static intervalFor(e){const t=Math.min(1,Math.max(0,(e-.5)/.5));return{minS:ri.MIN_INTERVAL_S-t*(ri.MIN_INTERVAL_S-ri.SEVERE_MIN_INTERVAL_S),maxS:ri.MAX_INTERVAL_S-t*(ri.MAX_INTERVAL_S-ri.SEVERE_MAX_INTERVAL_S)}}static brightnessAt(e,t){let i=0;for(const n of e.strokes){const s=t-e.t-n.offsetMs;s<0||s>ri.STROKE_DECAY_MS*6||(i+=n.intensity*Math.exp(-s/ri.STROKE_DECAY_MS))}return Math.min(1,i)}static endOf(e){const t=e.strokes[e.strokes.length-1];return e.t+t.offsetMs+ri.STROKE_DECAY_MS*6}static thunderDelayMs(e){return e.distanceM/ri.SOUND_SPEED_M_S*1e3}}class Bi{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(Bi.ANCHOR_BLUE-Bi.ANCHOR_RED)/(1/(Bi.BLUE_NM*Bi.BLUE_NM)-1/(Bi.RED_NM*Bi.RED_NM));static A=Bi.ANCHOR_RED-Bi.B/(Bi.RED_NM*Bi.RED_NM);static indexAt(e){return Bi.A+Bi.B/(e*e)}}class bo{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(e,t,i,n,s,r){let o=0,c=0,l=0;Math.abs(i)<.9?(o=-t,c=e,l=0):(o=0,c=-i,l=t);const h=Math.hypot(o,c,l)||1;o/=h,c/=h,l/=h;const u=t*l-i*c,d=i*o-e*l,f=e*c-t*o,p=s/2,v=r/2;for(let m=0;m<6;m++){const g=n+m*Math.PI/3,_=Math.cos(g),w=Math.sin(g);this.normals[m*3]=o*_+u*w,this.normals[m*3+1]=c*_+d*w,this.normals[m*3+2]=l*_+f*w,this.offsets[m]=p}this.normals[18]=e,this.normals[19]=t,this.normals[20]=i,this.offsets[6]=v,this.normals[21]=-e,this.normals[22]=-t,this.normals[23]=-i,this.offsets[7]=v,this.radius=Math.hypot(p,v)}get aimRadius(){return this.radius}trace(e,t,i,n,s,r,o){let c=-t,l=e,h=0,u=Math.hypot(c,l,h);u<1e-6&&(c=1,l=0,h=0,u=1),c/=u,l/=u,h/=u;const d=t*h-i*l,f=i*c-e*h,p=e*l-t*c,v=c*n+d*s-e*this.radius*2,m=l*n+f*s-t*this.radius*2,g=h*n+p*s-i*this.radius*2;let _=-1,w=-1/0,M=1/0;for(let J=0;J<8;J++){const ie=this.normals[J*3],oe=this.normals[J*3+1],Ve=this.normals[J*3+2],Qe=ie*e+oe*t+Ve*i,qe=this.offsets[J]-(ie*v+oe*m+Ve*g);if(Qe>1e-9){const Y=qe/Qe;Y<M&&(M=Y)}else if(Qe<-1e-9){const Y=qe/Qe;Y>w&&(w=Y,_=J)}else if(qe<0)return 0}if(_<0||w>=M)return 0;let S=0;const b=this.normals[_*3],T=this.normals[_*3+1],x=this.normals[_*3+2],A=-(b*e+T*t+x*i),I=cl.reflectance(A,1,r);o[S].x=e+2*A*b,o[S].y=t+2*A*T,o[S].z=i+2*A*x,o[S].weight=I,S++;const C=1/r,P=Math.sqrt(Math.max(0,1-C*C*(1-A*A)));let X=C*e+(C*A-P)*b,z=C*t+(C*A-P)*T,N=C*i+(C*A-P)*x,V=v+e*w,k=m+t*w,K=g+i*w,ee=1-I;for(let J=0;J<bo.MAX_BOUNCES&&ee>bo.MIN_WEIGHT;J++){let ie=-1,oe=1/0;for(let H=0;H<8;H++){const Ae=this.normals[H*3],Ne=this.normals[H*3+1],Ce=this.normals[H*3+2],ye=Ae*X+Ne*z+Ce*N;if(ye<=1e-9)continue;const Fe=(this.offsets[H]-(Ae*V+Ne*k+Ce*K))/ye;Fe>1e-9&&Fe<oe&&(oe=Fe,ie=H)}if(ie<0)break;const Ve=this.normals[ie*3],Qe=this.normals[ie*3+1],qe=this.normals[ie*3+2],Y=Ve*X+Qe*z+qe*N,re=r*Math.sqrt(Math.max(0,1-Y*Y));if(V+=X*oe,k+=z*oe,K+=N*oe,re<1){const H=Math.sqrt(Math.max(0,1-re*re)),Ae=cl.reflectance(Y,r,1);if(o[S].x=r*X-(r*Y-H)*Ve,o[S].y=r*z-(r*Y-H)*Qe,o[S].z=r*N-(r*Y-H)*qe,o[S].weight=ee*(1-Ae),S++,S>=o.length)return S;ee*=Ae}const ne=2*Y;X-=ne*Ve,z-=ne*Qe,N-=ne*qe}return S}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class Nt{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 bo;emergent=Array.from({length:bo.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(Nt.AZIMUTH_BINS*Nt.ALTITUDE_BINS*3);radiance=new Float32Array(Nt.AZIMUTH_BINS*Nt.ALTITUDE_BINS*3);scratch=new Float32Array(Nt.AZIMUTH_BINS*Nt.ALTITUDE_BINS*3);seed=1;spare=0;hasSpare=!1;altitude=0;tilt=0;alignment=0;traced=0;begin(e,t,i=2654435769){this.seed=i>>>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 n=Nt.WORST_TILT_DEG*(Nt.BEST_TILT_DEG/Nt.WORST_TILT_DEG)**this.alignment;this.tilt=n*Math.PI/180}trace(e){const t=Nt.AZIMUTH_BINS,i=Nt.ALTITUDE_BINS,n=this.tally,s=Nt.SOURCE_RADIUS_DEG*Math.PI/180,r=Math.cos(Nt.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let c=0;c<e;c++){const l=this.pickPopulation();this.orient(l,this.tilt);const h=this.random()*2*Math.PI,u=s*Math.sqrt(this.random()),d=o+u*Math.sin(h),f=u*Math.cos(h)/Math.max(.05,Math.cos(o)),p=-Math.cos(d)*Math.cos(f),v=-Math.cos(d)*Math.sin(f),m=-Math.sin(d),g=this.crystal.aimRadius,_=(this.random()*2-1)*g,w=(this.random()*2-1)*g,M=4*g*g,S=oi.SAMPLES[this.random()*oi.SAMPLES.length|0],b=this.crystal.trace(p,v,m,_,w,Bi.indexAt(S.wavelengthNm),this.emergent);for(let T=0;T<b;T++){const x=this.emergent[T],A=Math.hypot(x.x,x.y,x.z);if(A<1e-9||x.weight<=0)continue;const I=x.x/A,C=x.y/A,P=x.z/A;if(I*p+C*v+P*m>r)continue;const X=Math.asin(Math.max(-1,Math.min(1,-P))),z=Math.abs(Math.atan2(-C,-I)),N=Math.min(t-1,z/Math.PI*t|0),k=(Math.min(i-1,(X+Math.PI/2)/Math.PI*i|0)*t+N)*3,K=x.weight*M*oi.SAMPLES.length;n[k]+=K*S.r,n[k+1]+=K*S.g,n[k+2]+=K*S.b}}this.traced+=e}get tracedRays(){return this.traced}harvest(){const e=Nt.AZIMUTH_BINS,t=Nt.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,i,n){return this.begin(e,t,n),this.trace(i),this.harvest()}toRadiance(e,t){const i=2*Math.PI/e,n=Math.max(1,this.traced),s=4*Nt.REFERENCE_MICRONS*Nt.REFERENCE_MICRONS;for(let r=0;r<t;r++){const o=Math.sin(r/t*Math.PI-Math.PI/2),c=Math.sin((r+1)/t*Math.PI-Math.PI/2),l=1/(i*(c-o)*n*s);for(let h=0;h<e;h++){const u=(r*e+h)*3;this.radiance[u]=this.tally[u]*l,this.radiance[u+1]=this.tally[u+1]*l,this.radiance[u+2]=this.tally[u+2]*l}}}static REFERENCE_MICRONS=50;smooth(e,t){const i=this.scratch,n=this.radiance;i.set(n);for(let r=0;r<t;r++){const o=r*e*3;for(let c=0;c<3;c++){let l=i[o+c];for(let h=0;h<e;h++){const u=o+h*3+c,d=h+1<e?i[u+3]:i[u];n[u]=(l+2*i[u]+d)/4,l=i[u]}}}i.set(n);const s=e*3;for(let r=0;r<t;r++){const o=r>0?-s:0,c=r+1<t?s:0,l=r*s;for(let h=l;h<l+s;h++)n[h]=(i[h+o]+2*i[h]+i[h+c])/4}}pickPopulation(){const e=this.random();let t=0;for(const i of Nt.POPULATIONS)if(t+=i.share,e<=t)return i;return Nt.POPULATIONS[Nt.POPULATIONS.length-1]}orient(e,t){const i=this.random()*2*Math.PI;let n=this.random()*2*Math.PI,s=0,r=0,o=1;switch(e.orientation){case"tumbling":{o=this.random()*2-1;const c=Math.sqrt(Math.max(0,1-o*o));s=c*Math.cos(i),r=c*Math.sin(i);break}case"plate":{o=this.spreadAboutAnAxis(t);const c=Math.sqrt(Math.max(0,1-o*o));s=c*Math.cos(i),r=c*Math.sin(i);break}case"column":case"parry":{o=this.spreadAboutAPlane(t);const c=Math.sqrt(Math.max(0,1-o*o));s=c*Math.cos(i),r=c*Math.sin(i),e.orientation==="parry"&&(n=Math.PI/2+this.gaussian()*t);break}}this.crystal.set(s,r,o,n,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),i=Math.max(1e-12,this.random()),n=1+Math.log(i+(1-i)*Math.exp(-2*t))/t;return Math.max(-1,Math.min(1,n))}spreadAboutAPlane(e){for(let t=0;t<8;t++){const i=this.gaussian()*e;if(i>=-1&&i<=1)return i}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 Ai{static RADIUS=880;static RAYS=9e5;static RAYS_PER_BATCH=2e3;static BUDGET_MS=6;static URGENT_BUDGET_MS=40;static ALTITUDE_STEP_DEG=1;static ALIGNMENT_STEP=.05;static LEAP_ALTITUDE_DEG=5;static LEAP_ALIGNMENT=.25;static GAIN=.55;setCloudOffset(e){this.material.uniforms.uFieldOffset.value.copy(e)}object;material;sky=new Nt;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;urgent=!1;workHandle;onRepaint;constructor(){const e=Nt.AZIMUTH_BINS,t=Nt.ALTITUDE_BINS;this.texels=new Uint16Array(e*t*4),this.texture=new $s(this.texels,e,t,yi,Ft),this.texture.minFilter=st,this.texture.magFilter=st,this.texture.wrapS=xi,this.texture.wrapT=xi,this.texture.needsUpdate=!0,this.material=new at({uniforms:{uSource:{value:new D(0,1,0)},uUp:{value:new D(0,1,0)},uStrength:{value:0},uTint:{value:new D(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uFieldOffset:{value:new D},uMap:{value:this.texture},uGain:{value:Ai.GAIN}},vertexShader:`
|
|
6356
|
+
`,depthTest:!1,depthWrite:!1}),this.quadScene.add(new De(new ki(2,2),this.material))}render(e,t,i,n,s,r){const o=e.getRenderTarget(),c=r??{scene:this.scene,overlay:this.overlay};e.setRenderTarget(c.scene),e.render(t,i),s?.(),(n||r)&&(mi.clearTransparent(e,c.overlay),n?.()),e.setRenderTarget(o),!r&&(this.material.uniforms.uMode.value=en.Finished,e.render(this.quadScene,this.quadCamera))}resize(e,t){this.scene.setSize(Math.max(1,e),Math.max(1,t)),this.overlay.setSize(Math.max(1,e),Math.max(1,t))}dispose(){this.scene.dispose(),this.overlay.dispose(),this.material.dispose(),this.quadScene.children[0].geometry.dispose()}}class dt{static MIN_RATIO=1;static STEP=.25;static MIN_SHARE_OF_DISPLAY=.75;static GPU_LATE_MS=12;static GPU_ROOM_MS=6;static INTERVAL_LATE_MS=21;static LOWER_COOLDOWN_MS=750;static RAISE_COOLDOWN_MS=2e3;static PROBE_WATCH_MS=2e3;static PROBE_EVERY_MS=6e3;static PROBE_BACKOFF_MS=3e4;ratio;maxRatio;timer;intervalMs;lastChangeMs=-1/0;nextProbeMs=0;probe;constructor(e,t){this.maxRatio=dt.clamp(e),this.ratio=this.maxRatio,this.timer=t?fl.create(t):void 0}get pixelRatio(){return this.ratio}static SETTLE_MS=400;static SUSTAINED_MS=100;lastEditMs=-1/0;editStreakStartMs=-1/0;wasChanging=!1;noteChange(e){e-this.lastEditMs>dt.SETTLE_MS&&(this.editStreakStartMs=e),this.lastEditMs=e}changing(e){return e-this.lastEditMs<=dt.SETTLE_MS&&this.lastEditMs-this.editStreakStartMs>=dt.SUSTAINED_MS}ratioFor(e,t){return this.changing(e)?this.wasChanging?(this.update(e,t),this.ratio):(this.wasChanging=!0,this.reset(),this.ratio):(this.wasChanging=!1,this.maxRatio)}get timesGpu(){return this.timer!==void 0}set maximum(e){this.maxRatio=dt.clamp(e),this.ratio>this.maxRatio&&(this.ratio=this.maxRatio),this.ratio<this.minimum&&(this.ratio=Math.min(this.maxRatio,this.minimum))}get minimum(){const e=Math.floor(this.maxRatio*dt.MIN_SHARE_OF_DISPLAY/dt.STEP)*dt.STEP;return Math.max(dt.MIN_RATIO,e)}get maximum(){return this.maxRatio}beginDrawing(){this.timer?.begin()}endDrawing(){this.timer?.end()}reset(){this.intervalMs=void 0,this.probe=void 0,this.timer?.reset()}update(e,t){const i=this.timer?.poll();if(!(this.timer&&i===void 0))return i!==void 0?this.followGpu(e,i):this.followIntervals(e,t)}followGpu(e,t){if(t>dt.GPU_LATE_MS)return this.lower(e,dt.LOWER_COOLDOWN_MS);if(t<dt.GPU_ROOM_MS)return this.raise(e,dt.RAISE_COOLDOWN_MS)}followIntervals(e,t){if(!(t>0)||t>1e3)return;this.intervalMs=this.intervalMs===void 0?t:this.intervalMs*.9+t*.1;const i=this.intervalMs>dt.INTERVAL_LATE_MS;if(this.probe){if(i)return this.ratio=this.probe.ratioBefore,this.probe=void 0,this.lastChangeMs=e,this.nextProbeMs=e+dt.PROBE_BACKOFF_MS,this.ratio;e-this.probe.sinceMs>=dt.PROBE_WATCH_MS&&(this.probe=void 0,this.nextProbeMs=e+dt.PROBE_EVERY_MS);return}if(i){const n=this.lower(e,dt.LOWER_COOLDOWN_MS);return n!==void 0&&(this.nextProbeMs=e+dt.PROBE_EVERY_MS),n}if(this.ratio<this.maxRatio&&e>=this.nextProbeMs&&e-this.lastChangeMs>=dt.RAISE_COOLDOWN_MS){const n=this.ratio,s=this.raise(e,0);return s!==void 0&&(this.probe={sinceMs:e,ratioBefore:n}),s}}lower(e,t){if(!(this.ratio<=this.minimum||e-this.lastChangeMs<t))return this.ratio=Math.max(this.minimum,dt.clamp(this.ratio-dt.STEP)),this.lastChangeMs=e,this.ratio}raise(e,t){if(!(this.ratio>=this.maxRatio||e-this.lastChangeMs<t))return this.ratio=Math.min(this.maxRatio,dt.clamp(this.ratio+dt.STEP)),this.lastChangeMs=e,this.ratio}static clamp(e){return Number.isFinite(e)?Math.max(dt.MIN_RATIO,Math.round(e/dt.STEP)*dt.STEP):dt.MIN_RATIO}}class fl{constructor(e,t){this.gl=e,this.extension=t}static IN_FLIGHT_MAX=8;static create(e){if(!(e instanceof WebGL2RenderingContext))return;const t=e.getExtension("EXT_disjoint_timer_query_webgl2");return t?new fl(e,t):void 0}pending=[];active;smoothedMs;begin(){if(!(this.active||this.pending.length>=fl.IN_FLIGHT_MAX))try{const e=this.gl.createQuery();if(!e)return;this.gl.beginQuery(this.extension.TIME_ELAPSED_EXT,e),this.active=e}catch{this.active=void 0}}end(){if(this.active){try{this.gl.endQuery(this.extension.TIME_ELAPSED_EXT),this.pending.push(this.active)}catch{}this.active=void 0}}poll(){const e=this.gl;try{for(let t=0;t<this.pending.length;t++){const i=this.pending[t];if(!e.getQueryParameter(i,e.QUERY_RESULT_AVAILABLE))continue;if(!e.getParameter(this.extension.GPU_DISJOINT_EXT)){const s=e.getQueryParameter(i,e.QUERY_RESULT)/1e6;this.smoothedMs=this.smoothedMs===void 0?s:this.smoothedMs*.8+s*.2}e.deleteQuery(i),this.pending.splice(t,1),t--}}catch{this.pending.length=0}return this.smoothedMs}reset(){this.smoothedMs=void 0}}class lt{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=lt.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 i=e*Math.PI/180,n=t*Math.sin(i/2);return n>1?Number.NaN:(2*Math.asin(n)-i)*180/Math.PI}static effectiveIndex(e,t){const i=t*Math.PI/180,n=Math.cos(i);return n<=0?Number.POSITIVE_INFINITY:Math.sqrt(e*e-Math.sin(i)**2)/n}static parheliaAzimuthDeg(e,t=lt.ICE_INDEX_RED){const i=lt.minimumDeviationDeg(lt.SIDE_PRISM_ANGLE_DEG,lt.effectiveIndex(t,e));return Number.isFinite(i)?i:void 0}static parheliaDistanceDeg(e,t=lt.ICE_INDEX_RED){const i=lt.parheliaAzimuthDeg(e,t);if(i===void 0)return;const n=e*Math.PI/180,s=Math.sin(n)**2,r=Math.cos(n)**2*Math.cos(i*Math.PI/180);return Math.acos(Math.max(-1,Math.min(1,s+r)))*180/Math.PI}static get PLATE_END_FACE_LIMIT_DEG(){const e=lt.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(e*e-1)))*180/Math.PI}static circumzenithalAltitudeDeg(e,t=lt.ICE_INDEX_RED){if(e<0||e>90-lt.PLATE_END_FACE_LIMIT_DEG)return;const i=Math.cos(e*Math.PI/180),n=Math.sqrt(t*t-i*i);if(!(n>=1))return Math.asin(n)*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 lt.ringOf("halo22",lt.SIDE_PRISM_ANGLE_DEG)}static halo46(){return lt.ringOf("halo46",lt.END_PRISM_ANGLE_DEG)}static ringOf(e,t){const i=lt.minimumDeviationDeg(t,lt.ICE_INDEX_RED),n=lt.minimumDeviationDeg(t,lt.ICE_INDEX_BLUE);return{id:e,angleDeg:(i+n)/2,redAngleDeg:i,blueAngleDeg:n}}static strength(e,t,i=90,n=0){const s=Math.max(0,Math.min(1,e)),r=Math.max(0,1-Math.max(0,Math.min(1,t))),o=i>=0?1:n<=0?0:Math.max(0,1+i/n);return s*r*o}static formsAt(e,t=0){if(e<=-t)return[];const i=[lt.halo22(),lt.halo46()],n=e>0?lt.parheliaDistanceDeg(e):void 0;n!==void 0&&i.push({id:"parhelia",angleDeg:n,redAngleDeg:n,blueAngleDeg:lt.parheliaDistanceDeg(e,lt.ICE_INDEX_BLUE)}),i.push({id:"tangentArc",angleDeg:lt.halo22().angleDeg}),e>0&&i.push({id:"parhelicCircle",angleDeg:e});const s=lt.circumzenithalAltitudeDeg(e);return s!==void 0&&i.push({id:"circumzenithal",angleDeg:s}),e>lt.PLATE_END_FACE_LIMIT_DEG&&i.push({id:"circumhorizontal"}),e<lt.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&i.push({id:"pillar"}),i}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class $i{static get WATER_INDEX_RED(){return gi.indexAt(gi.RED_NM)}static get WATER_INDEX_BLUE(){return gi.indexAt(gi.BLUE_NM)}static radiusDeg(e,t){const i=(t*t-1)/(e*e-1);if(i<0||i>1)return Number.NaN;const n=Math.acos(Math.sqrt(i)),s=Math.asin(Math.sin(n)/t),r=2*(n-s)+(e-1)*(Math.PI-2*s),o=2*Math.PI;let c=r%o;return c<0&&(c+=o),c>Math.PI&&(c=o-c),180-c*180/Math.PI}static primary(){return $i.bowOf("primary",2,0)}static secondary(){return $i.bowOf("secondary",3,0)}static bowOf(e,t,i){const n=$i.radiusDeg(t,$i.WATER_INDEX_RED),s=$i.radiusDeg(t,$i.WATER_INDEX_BLUE),r=(n+s)/2;return{id:e,radiusDeg:r,redRadiusDeg:n,violetRadiusDeg:s,topAltitudeDeg:r-i}}static alexandersBandDeg(){return{fromDeg:$i.primary().redRadiusDeg,toDeg:$i.secondary().redRadiusDeg}}static formsAt(e){return e<0?[]:[$i.bowOf("primary",2,e),$i.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-$i.FULL_MOON_MAGNITUDE)))}static strength(e,t,i){if(i<=0)return 0;const n=Math.max(0,Math.min(1,e)),s=Math.max(0,1-Math.max(0,Math.min(1,t)));return n*s}}class Zi{constructor(e){this.radius=e;const t=Zi.SEGMENTS*Zi.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const i=new ut;i.setAttribute("position",new et(this.positions,3)),i.setAttribute("color",new et(this.colors,3)),i.setDrawRange(0,0),this.object=new De(i,new mn({vertexColors:!0,transparent:!0,blending:Ci,depthWrite:!1,fog:!1,side:tn})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=Zi.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(Zi.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,i){this.head=e&&ni(e.altitudeDeg,e.azimuthDeg,1),this.tip=t&&ni(t.altitudeDeg,t.azimuthDeg,1),this.brightness=i,this.rebuild()}rebuild(){const e=this.object.geometry,t=this.head,i=this.tip;if(!t||!i||this.brightness<=0){e.setDrawRange(0,0);return}const n=this.angleBetween(t,i);if(n<=0){e.setDrawRange(0,0);return}const s=n*Zi.SPREAD_FRACTION*Math.PI/180,r=h=>this.scale(this.slerp(t,i,h),this.radius),o=h=>this.radius*(Zi.HEAD_HALF_WIDTH_DEG*Math.PI/180+s*h),c=h=>this.brightness*(1-h)**Zi.FADE_POWER;let l=0;for(let h=1;h<Zi.POINTS;h++){const u=(h-1)/Zi.SEGMENTS,d=h/Zi.SEGMENTS;l=this.pushBand(l,r(u),r(d),o(u),o(d),c(u),c(d))}e.setDrawRange(0,l),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}pushBand(e,t,i,n,s,r,o){const c=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(i,t))));for(let l=0;l<Zi.ACROSS-1;l++){const h=l-1,u=l,d=this.across(t,c,n,h),f=this.across(i,c,s,h),p=this.across(t,c,n,u),v=this.across(i,c,s,u),m=(g,_)=>g===0?_:0;e=this.push(e,d,m(h,r)),e=this.push(e,f,m(h,o)),e=this.push(e,p,m(u,r)),e=this.push(e,f,m(h,o)),e=this.push(e,v,m(u,o)),e=this.push(e,p,m(u,r))}return e}across(e,t,i,n){return{x:e.x+t.x*i*n,y:e.y+t.y*i*n,z:e.z+t.z*i*n}}push(e,t,i){const n=e*3;this.positions[n]=t.x,this.positions[n+1]=t.y,this.positions[n+2]=t.z;const s=Ee.relativeOfResponse(Math.max(0,Math.min(1,i)));return this.colors[n]=s*.55,this.colors[n+1]=s*.75,this.colors[n+2]=s,e+1}slerp(e,t,i){const n=this.angleBetweenRadians(e,t);if(n<1e-9)return e;const s=Math.sin(n),r=Math.sin((1-i)*n)/s,o=Math.sin(i*n)/s;return{x:e.x*r+t.x*o,y:e.y*r+t.y*o,z:e.z*r+t.z*o}}angleBetween(e,t){return this.angleBetweenRadians(e,t)*180/Math.PI}angleBetweenRadians(e,t){const i=e.x*t.x+e.y*t.y+e.z*t.z;return Math.acos(Math.min(1,Math.max(-1,i)))}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 Ew{object=new Dt;radius;tiers;drawn=[];constructor(e){this.radius=e,this.object.name="satellites",this.tiers=ro.map(t=>{const i=new us(new ut,Ft.material(t.size));return Ft.track(i),i.frustumCulled=!1,this.object.add(i),i})}set(e,t,i,n){const s=this.tiers.map(()=>[]);this.drawn=[];for(const r of e){const o=i(r.position);if(o<=0)continue;const c=r.magnitude-2.5*Math.log10(o);if(c>t)continue;const l=jr(c,t),h=zg(l),{x:u,y:d,z:f}=ni(r.position.altitudeDeg,r.position.azimuthDeg,this.radius),[p,v,m]=n(r.position,c);s[h].push({x:u,y:d,z:f,r:p,g:v,b:m}),this.drawn.push({satellite:r,direction:new D(u,d,f).normalize()})}this.tiers.forEach((r,o)=>{const c=s[o],l=new Float32Array(c.length*3),h=new Float32Array(c.length*3);c.forEach((d,f)=>{l.set([d.x,d.y,d.z],f*3),h.set([d.r,d.g,d.b],f*3)}),r.geometry.dispose();const u=new ut;u.setAttribute("position",new et(l,3)),u.setAttribute("color",new et(h,3)),r.geometry=u})}get count(){return this.drawn.length}nearest(e,t){let i,n=t;for(const s of this.drawn){const r=s.direction.dot(e);r>n&&(n=r,i=s.satellite)}return i}dispose(){for(const e of this.tiers)e.geometry.dispose(),e.material.dispose();this.object.removeFromParent(),this.drawn=[]}}class Il{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 va{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(e){const{ratePerHour:t,durationMs:i,velocityKmS:n,seed:s}=e;if(t<=0||i<=0)return[];const r=t*i/36e5,o=new Il(s),c=Math.floor(r),l=c+(o.next()<r-c?1:0),h=[];for(let u=0;u<l;u++){const d=Math.min(1,Math.max(0,(n-20)/52)),f=va.MAX_DURATION_MS-d*(va.MAX_DURATION_MS-va.MIN_DURATION_MS),p=o.between(5,70);h.push({t:o.between(0,i),durationMs:f*o.between(.7,1.3),fromRadiantDeg:p,bearingDeg:o.between(0,360),lengthDeg:Math.sin(p*Math.PI/180)*o.between(8,40)*(.6+d),brightness:o.next()**3}),h.sort((v,m)=>v.t-m.t)}return h}static aliveAt(e,t){return e.filter(i=>t>=i.t&&t<=i.t+i.durationMs).map(i=>({meteor:i,progress:(t-i.t)/i.durationMs}))}}class Us{object=new Dt;radius;core;glow;flashKey;static CORE_WIDTH_DEG=.06;static GLOW_WIDTH_DEG=.5;static SEGMENTS=28;static CORE_RELATIVE=1e3;constructor(e){this.radius=e,this.object.name="lightning-bolt",this.core=new mn({color:15659775,transparent:!0,opacity:0,blending:Ci,depthWrite:!1,fog:!1}),this.glow=new mn({color:10466559,transparent:!0,opacity:0,blending:Ci,depthWrite:!1,fog:!1}),this.object.visible=!1,this.object.renderOrder=5.95}set(e,t,i){if(!e||!e.cloudToGround||t<=.01){this.object.visible=!1;return}const n=`${e.channelSeed}:${Math.round(i)}`;n!==this.flashKey&&this.build(e,i,n),this.core.color.setHex(15659775).multiplyScalar(Us.CORE_RELATIVE*Math.min(1,t*1.4)),this.glow.color.setHex(10466559).multiplyScalar(.1*Us.CORE_RELATIVE*t*.35),this.core.opacity=1,this.glow.opacity=1,this.object.visible=!0}build(e,t,i){this.flashKey=i;for(const l of[...this.object.children])l.geometry.dispose(),this.object.remove(l);const n=new Il(e.channelSeed),s=Math.atan2(t,e.distanceM)*180/Math.PI,r=this.channel(n,e.azimuthDeg,s,0,1),o=[r],c=1+Math.floor(n.next()*2);for(let l=0;l<c;l++){const h=r[Math.floor(n.between(.15,.5)*r.length)];o.push(this.channel(n,h.azimuthDeg,h.altitudeDeg,h.altitudeDeg*n.between(.3,.7),.5))}for(const l of o)this.object.add(new De(this.ribbon(l,Us.GLOW_WIDTH_DEG),this.glow)),this.object.add(new De(this.ribbon(l,Us.CORE_WIDTH_DEG),this.core))}channel(e,t,i,n,s){const r=[],o=i-n;let c=t;for(let l=0;l<=Us.SEGMENTS;l++){const h=i-o*l/Us.SEGMENTS;r.push({azimuthDeg:c,altitudeDeg:h}),c+=e.between(-1,1)*o*.06*s}return r}ribbon(e,t){const i=new Float32Array(e.length*2*3),n=[],s=this.radius*Math.tan(t*Math.PI/180)/2,r=e.map(c=>{const{x:l,y:h,z:u}=ni(c.altitudeDeg,c.azimuthDeg,this.radius);return new D(l,h,u)});r.forEach((c,l)=>{const h=r[Math.min(l+1,r.length-1)],u=r[Math.max(l-1,0)],f=h.clone().sub(u).normalize().cross(c.clone().normalize()).normalize().multiplyScalar(s);if(i.set([c.x+f.x,c.y+f.y,c.z+f.z],l*6),i.set([c.x-f.x,c.y-f.y,c.z-f.z],l*6+3),l<r.length-1){const p=l*2;n.push(p,p+1,p+2,p+1,p+3,p+2)}});const o=new ut;return o.setAttribute("position",new et(i,3)),o.setIndex(n),o}dispose(){for(const e of this.object.children)e.geometry.dispose();this.core.dispose(),this.glow.dispose(),this.object.removeFromParent()}}class oi{static MIN_INTERVAL_S=8;static MAX_INTERVAL_S=25;static SEVERE_MIN_INTERVAL_S=2;static SEVERE_MAX_INTERVAL_S=8;static CLOUD_TO_GROUND_FRACTION=.25;static MIN_DISTANCE_M=1e3;static MAX_DISTANCE_M=15e3;static INTERSTROKE_MS=60;static STROKE_DECAY_MS=40;static SOUND_SPEED_M_S=343;static schedule(e){const t=new Il(e.seed),i=[],{minS:n,maxS:s}=oi.intervalFor(e.intensity??.5);let r=t.between(0,s)*1e3;for(;r<e.durationMs;){const o=t.next()<oi.CLOUD_TO_GROUND_FRACTION,c=oi.MIN_DISTANCE_M,l=oi.MAX_DISTANCE_M,h=Math.sqrt(t.between(c*c,l*l)),u=o?1+Math.floor(t.next()*4):1,d=[];let f=0;for(let p=0;p<u;p++)d.push({offsetMs:f,intensity:p===0?1:t.between(.4,.9)}),f+=oi.INTERSTROKE_MS*t.between(.5,1.6);i.push({t:r,azimuthDeg:t.between(0,360),distanceM:h,cloudToGround:o,strokes:d,channelSeed:Math.floor(t.next()*2**31)}),r+=t.between(n,s)*1e3}return i}static intervalFor(e){const t=Math.min(1,Math.max(0,(e-.5)/.5));return{minS:oi.MIN_INTERVAL_S-t*(oi.MIN_INTERVAL_S-oi.SEVERE_MIN_INTERVAL_S),maxS:oi.MAX_INTERVAL_S-t*(oi.MAX_INTERVAL_S-oi.SEVERE_MAX_INTERVAL_S)}}static brightnessAt(e,t){let i=0;for(const n of e.strokes){const s=t-e.t-n.offsetMs;s<0||s>oi.STROKE_DECAY_MS*6||(i+=n.intensity*Math.exp(-s/oi.STROKE_DECAY_MS))}return Math.min(1,i)}static endOf(e){const t=e.strokes[e.strokes.length-1];return e.t+t.offsetMs+oi.STROKE_DECAY_MS*6}static thunderDelayMs(e){return e.distanceM/oi.SOUND_SPEED_M_S*1e3}}class Bi{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(Bi.ANCHOR_BLUE-Bi.ANCHOR_RED)/(1/(Bi.BLUE_NM*Bi.BLUE_NM)-1/(Bi.RED_NM*Bi.RED_NM));static A=Bi.ANCHOR_RED-Bi.B/(Bi.RED_NM*Bi.RED_NM);static indexAt(e){return Bi.A+Bi.B/(e*e)}}class bo{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(e,t,i,n,s,r){let o=0,c=0,l=0;Math.abs(i)<.9?(o=-t,c=e,l=0):(o=0,c=-i,l=t);const h=Math.hypot(o,c,l)||1;o/=h,c/=h,l/=h;const u=t*l-i*c,d=i*o-e*l,f=e*c-t*o,p=s/2,v=r/2;for(let m=0;m<6;m++){const g=n+m*Math.PI/3,_=Math.cos(g),w=Math.sin(g);this.normals[m*3]=o*_+u*w,this.normals[m*3+1]=c*_+d*w,this.normals[m*3+2]=l*_+f*w,this.offsets[m]=p}this.normals[18]=e,this.normals[19]=t,this.normals[20]=i,this.offsets[6]=v,this.normals[21]=-e,this.normals[22]=-t,this.normals[23]=-i,this.offsets[7]=v,this.radius=Math.hypot(p,v)}get aimRadius(){return this.radius}trace(e,t,i,n,s,r,o){let c=-t,l=e,h=0,u=Math.hypot(c,l,h);u<1e-6&&(c=1,l=0,h=0,u=1),c/=u,l/=u,h/=u;const d=t*h-i*l,f=i*c-e*h,p=e*l-t*c,v=c*n+d*s-e*this.radius*2,m=l*n+f*s-t*this.radius*2,g=h*n+p*s-i*this.radius*2;let _=-1,w=-1/0,M=1/0;for(let J=0;J<8;J++){const ie=this.normals[J*3],oe=this.normals[J*3+1],Ve=this.normals[J*3+2],Qe=ie*e+oe*t+Ve*i,qe=this.offsets[J]-(ie*v+oe*m+Ve*g);if(Qe>1e-9){const Y=qe/Qe;Y<M&&(M=Y)}else if(Qe<-1e-9){const Y=qe/Qe;Y>w&&(w=Y,_=J)}else if(qe<0)return 0}if(_<0||w>=M)return 0;let S=0;const b=this.normals[_*3],T=this.normals[_*3+1],x=this.normals[_*3+2],A=-(b*e+T*t+x*i),I=cl.reflectance(A,1,r);o[S].x=e+2*A*b,o[S].y=t+2*A*T,o[S].z=i+2*A*x,o[S].weight=I,S++;const C=1/r,P=Math.sqrt(Math.max(0,1-C*C*(1-A*A)));let X=C*e+(C*A-P)*b,z=C*t+(C*A-P)*T,N=C*i+(C*A-P)*x,V=v+e*w,k=m+t*w,K=g+i*w,ee=1-I;for(let J=0;J<bo.MAX_BOUNCES&&ee>bo.MIN_WEIGHT;J++){let ie=-1,oe=1/0;for(let H=0;H<8;H++){const Ae=this.normals[H*3],Ne=this.normals[H*3+1],Ce=this.normals[H*3+2],ye=Ae*X+Ne*z+Ce*N;if(ye<=1e-9)continue;const Fe=(this.offsets[H]-(Ae*V+Ne*k+Ce*K))/ye;Fe>1e-9&&Fe<oe&&(oe=Fe,ie=H)}if(ie<0)break;const Ve=this.normals[ie*3],Qe=this.normals[ie*3+1],qe=this.normals[ie*3+2],Y=Ve*X+Qe*z+qe*N,re=r*Math.sqrt(Math.max(0,1-Y*Y));if(V+=X*oe,k+=z*oe,K+=N*oe,re<1){const H=Math.sqrt(Math.max(0,1-re*re)),Ae=cl.reflectance(Y,r,1);if(o[S].x=r*X-(r*Y-H)*Ve,o[S].y=r*z-(r*Y-H)*Qe,o[S].z=r*N-(r*Y-H)*qe,o[S].weight=ee*(1-Ae),S++,S>=o.length)return S;ee*=Ae}const ne=2*Y;X-=ne*Ve,z-=ne*Qe,N-=ne*qe}return S}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class Nt{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 bo;emergent=Array.from({length:bo.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(Nt.AZIMUTH_BINS*Nt.ALTITUDE_BINS*3);radiance=new Float32Array(Nt.AZIMUTH_BINS*Nt.ALTITUDE_BINS*3);scratch=new Float32Array(Nt.AZIMUTH_BINS*Nt.ALTITUDE_BINS*3);seed=1;spare=0;hasSpare=!1;altitude=0;tilt=0;alignment=0;traced=0;begin(e,t,i=2654435769){this.seed=i>>>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 n=Nt.WORST_TILT_DEG*(Nt.BEST_TILT_DEG/Nt.WORST_TILT_DEG)**this.alignment;this.tilt=n*Math.PI/180}trace(e){const t=Nt.AZIMUTH_BINS,i=Nt.ALTITUDE_BINS,n=this.tally,s=Nt.SOURCE_RADIUS_DEG*Math.PI/180,r=Math.cos(Nt.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let c=0;c<e;c++){const l=this.pickPopulation();this.orient(l,this.tilt);const h=this.random()*2*Math.PI,u=s*Math.sqrt(this.random()),d=o+u*Math.sin(h),f=u*Math.cos(h)/Math.max(.05,Math.cos(o)),p=-Math.cos(d)*Math.cos(f),v=-Math.cos(d)*Math.sin(f),m=-Math.sin(d),g=this.crystal.aimRadius,_=(this.random()*2-1)*g,w=(this.random()*2-1)*g,M=4*g*g,S=ci.SAMPLES[this.random()*ci.SAMPLES.length|0],b=this.crystal.trace(p,v,m,_,w,Bi.indexAt(S.wavelengthNm),this.emergent);for(let T=0;T<b;T++){const x=this.emergent[T],A=Math.hypot(x.x,x.y,x.z);if(A<1e-9||x.weight<=0)continue;const I=x.x/A,C=x.y/A,P=x.z/A;if(I*p+C*v+P*m>r)continue;const X=Math.asin(Math.max(-1,Math.min(1,-P))),z=Math.abs(Math.atan2(-C,-I)),N=Math.min(t-1,z/Math.PI*t|0),k=(Math.min(i-1,(X+Math.PI/2)/Math.PI*i|0)*t+N)*3,K=x.weight*M*ci.SAMPLES.length;n[k]+=K*S.r,n[k+1]+=K*S.g,n[k+2]+=K*S.b}}this.traced+=e}get tracedRays(){return this.traced}harvest(){const e=Nt.AZIMUTH_BINS,t=Nt.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,i,n){return this.begin(e,t,n),this.trace(i),this.harvest()}toRadiance(e,t){const i=2*Math.PI/e,n=Math.max(1,this.traced),s=4*Nt.REFERENCE_MICRONS*Nt.REFERENCE_MICRONS;for(let r=0;r<t;r++){const o=Math.sin(r/t*Math.PI-Math.PI/2),c=Math.sin((r+1)/t*Math.PI-Math.PI/2),l=1/(i*(c-o)*n*s);for(let h=0;h<e;h++){const u=(r*e+h)*3;this.radiance[u]=this.tally[u]*l,this.radiance[u+1]=this.tally[u+1]*l,this.radiance[u+2]=this.tally[u+2]*l}}}static REFERENCE_MICRONS=50;smooth(e,t){const i=this.scratch,n=this.radiance;i.set(n);for(let r=0;r<t;r++){const o=r*e*3;for(let c=0;c<3;c++){let l=i[o+c];for(let h=0;h<e;h++){const u=o+h*3+c,d=h+1<e?i[u+3]:i[u];n[u]=(l+2*i[u]+d)/4,l=i[u]}}}i.set(n);const s=e*3;for(let r=0;r<t;r++){const o=r>0?-s:0,c=r+1<t?s:0,l=r*s;for(let h=l;h<l+s;h++)n[h]=(i[h+o]+2*i[h]+i[h+c])/4}}pickPopulation(){const e=this.random();let t=0;for(const i of Nt.POPULATIONS)if(t+=i.share,e<=t)return i;return Nt.POPULATIONS[Nt.POPULATIONS.length-1]}orient(e,t){const i=this.random()*2*Math.PI;let n=this.random()*2*Math.PI,s=0,r=0,o=1;switch(e.orientation){case"tumbling":{o=this.random()*2-1;const c=Math.sqrt(Math.max(0,1-o*o));s=c*Math.cos(i),r=c*Math.sin(i);break}case"plate":{o=this.spreadAboutAnAxis(t);const c=Math.sqrt(Math.max(0,1-o*o));s=c*Math.cos(i),r=c*Math.sin(i);break}case"column":case"parry":{o=this.spreadAboutAPlane(t);const c=Math.sqrt(Math.max(0,1-o*o));s=c*Math.cos(i),r=c*Math.sin(i),e.orientation==="parry"&&(n=Math.PI/2+this.gaussian()*t);break}}this.crystal.set(s,r,o,n,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),i=Math.max(1e-12,this.random()),n=1+Math.log(i+(1-i)*Math.exp(-2*t))/t;return Math.max(-1,Math.min(1,n))}spreadAboutAPlane(e){for(let t=0;t<8;t++){const i=this.gaussian()*e;if(i>=-1&&i<=1)return i}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 Ti{static RADIUS=880;static RAYS=9e5;static RAYS_PER_BATCH=2e3;static BUDGET_MS=6;static URGENT_BUDGET_MS=40;static ALTITUDE_STEP_DEG=1;static ALIGNMENT_STEP=.05;static LEAP_ALTITUDE_DEG=5;static LEAP_ALIGNMENT=.25;static GAIN=.55;setCloudOffset(e){this.material.uniforms.uFieldOffset.value.copy(e)}object;material;sky=new Nt;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;urgent=!1;workHandle;onRepaint;constructor(){const e=Nt.AZIMUTH_BINS,t=Nt.ALTITUDE_BINS;this.texels=new Uint16Array(e*t*4),this.texture=new $s(this.texels,e,t,_i,kt),this.texture.minFilter=st,this.texture.magFilter=st,this.texture.wrapS=yi,this.texture.wrapT=yi,this.texture.needsUpdate=!0,this.material=new at({uniforms:{uSource:{value:new D(0,1,0)},uUp:{value:new D(0,1,0)},uStrength:{value:0},uTint:{value:new D(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uFieldOffset:{value:new D},uMap:{value:this.texture},uGain:{value:Ti.GAIN}},vertexShader:`
|
|
6349
6357
|
varying vec3 vDirection;
|
|
6350
6358
|
void main() {
|
|
6351
6359
|
vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
|
|
@@ -6374,7 +6382,7 @@ void main()
|
|
|
6374
6382
|
if (ice <= 0.0) discard;
|
|
6375
6383
|
gl_FragColor = vec4(iceHaloLight(dir, ice), 1.0);
|
|
6376
6384
|
}
|
|
6377
|
-
`,transparent:!0,blending:Di,depthWrite:!1,side:Ot,fog:!1}),this.object=new De(new jt(Ai.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1;const i=this.material.uniforms;this.deckUniforms={uSource:i.uSource,uUp:i.uUp,uStrength:i.uStrength,uTint:i.uTint,uMap:i.uMap,uGain:i.uGain,uHaloShown:{value:0}}}deckUniforms;shown=!1;hostedByDeck=!1;set hosted(e){this.hostedByDeck=e,this.show(this.shown)}show(e){this.shown=e,this.object.visible=e&&!this.hostedByDeck,this.deckUniforms.uHaloShown.value=e?1:0}get awaitingFirstDisplay(){return this.tracing&&!this.everDisplayed}setUrgent(e){this.urgent=e}set onReady(e){this.onRepaint=e}update(e,t,i,n,s,r){const o=this.material.uniforms;if(i<=0){o.uStrength.value=0,this.show(!1),this.stopWork();return}o.uSource.value.set(e.x,e.y,e.z).normalize(),o.uStrength.value=i,o.uTint.value.set(n[0],n[1],n[2]),o.uIceCover.value=s.cover,o.uIceHeight.value=s.layerHeight,this.show(this.everDisplayed),this.requestMap(t,r)}requestMap(e,t){if(!(!(Math.abs(e-this.mappedAltitudeDeg)<Ai.ALTITUDE_STEP_DEG)||!(Math.abs(t-this.mappedAlignment)<Ai.ALIGNMENT_STEP))){this.next=void 0;return}if(this.tracing){if(this.tracingFor(e,t)){this.next=void 0;return}if(!(!(Math.abs(e-this.pendingAltitudeDeg)<Ai.LEAP_ALTITUDE_DEG)||!(Math.abs(t-this.pendingAlignment)<Ai.LEAP_ALIGNMENT))){this.next={sourceAltitudeDeg:e,alignment:t};return}}this.next=void 0,this.pendingAltitudeDeg=e,this.pendingAlignment=t,this.sky.begin(e,t),this.tracing=!0,this.scheduleWork()}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;next;tracingFor(e,t){return this.tracing&&Math.abs(e-this.pendingAltitudeDeg)<Ai.ALTITUDE_STEP_DEG&&Math.abs(t-this.pendingAlignment)<Ai.ALIGNMENT_STEP}scheduleWork(){if(this.workHandle!==void 0)return;const e=()=>{if(this.workHandle=void 0,!this.tracing)return;const t=performance.now(),i=this.urgent?Ai.URGENT_BUDGET_MS:Ai.BUDGET_MS;do this.sky.trace(Ai.RAYS_PER_BATCH);while(this.sky.tracedRays<Ai.RAYS&&performance.now()-t<i);if(this.sky.tracedRays>=Ai.RAYS){this.publish(),this.tracing=!1,this.mappedAltitudeDeg=this.pendingAltitudeDeg,this.mappedAlignment=this.pendingAlignment;const s=this.next;s&&this.requestMap(s.sourceAltitudeDeg,s.alignment);return}this.workHandle=requestAnimationFrame(e)};this.workHandle=requestAnimationFrame(e)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0,this.tracing=!1,this.next=void 0}publish(){const t=this.sky.harvest().data;for(let i=0,n=0;n<t.length;i+=4,n+=3)this.texels[i]=Dn.toHalfFloat(t[n]),this.texels[i+1]=Dn.toHalfFloat(t[n+1]),this.texels[i+2]=Dn.toHalfFloat(t[n+2]),this.texels[i+3]=1;this.texture.needsUpdate=!0,this.everDisplayed=!0,this.show(this.material.uniforms.uStrength.value>0),this.onRepaint?.()}dispose(){this.stopWork(),this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class fi{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=fi.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(fi.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=fi.MAX_CONCURRENT*fi.SEGMENTS*fi.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const t=new ut;t.setAttribute("position",new et(this.positions,3)),t.setAttribute("color",new et(this.colors,3)),t.setDrawRange(0,0),this.object=new De(t,new mn({vertexColors:!0,transparent:!0,blending:Di,depthWrite:!1,fog:!1,side:tn})),this.object.frustumCulled=!1}get schedule(){return this.meteors}setShower(e,t,i){this.meteors=e,this.radiantAltitudeDeg=t,this.radiantAzimuthDeg=i}update(e){const t=this.object.geometry;if(this.meteors.length===0){t.setDrawRange(0,0);return}const i=va.aliveAt(this.meteors,e).slice(0,fi.MAX_CONCURRENT);let n=0;for(const{meteor:s,progress:r}of i){const o=this.radiantOf(s);if(!o)continue;const c=ii(o.altitudeDeg,o.azimuthDeg,1),[l,h]=this.basisAround(c),u=s.fromRadiantDeg+r*s.lengthDeg,d=Math.max(s.fromRadiantDeg,u-s.lengthDeg*.6),f=Math.min(1,(1-r)*2.5),p=this.turn(l,h,s.bearingDeg),v=(.15+.85*s.brightness)*f,m=w=>v*w**1.6,g=w=>this.onSphere(c,p,d+(u-d)*w),_=w=>fi.RADIUS*((fi.MIN_HALF_WIDTH_DEG+fi.BRIGHT_HALF_WIDTH_DEG*s.brightness*w)*Math.PI/180);for(let w=1;w<fi.POINTS;w++){const M=(w-1)/fi.SEGMENTS,S=w/fi.SEGMENTS;n=this.pushRibbon(n,g(M),g(S),_(M),_(S),m(M),m(S))}}t.setDrawRange(0,n),t.getAttribute("position").needsUpdate=!0,t.getAttribute("color").needsUpdate=!0}midpointOf(e){const t=this.radiantOf(e);if(!t)return;const i=ii(t.altitudeDeg,t.azimuthDeg,1),[n,s]=this.basisAround(i),r=this.turn(n,s,e.bearingDeg),o=this.onSphere(i,r,e.fromRadiantDeg+e.lengthDeg/2),c=Math.hypot(o.x,o.y,o.z)||1;return{altitudeDeg:Math.asin(o.y/c)*180/Math.PI,azimuthDeg:(Math.atan2(o.x,-o.z)*180/Math.PI+360)%360}}radiantOf(e){return e.radiant?e.radiant:this.radiantAltitudeDeg>0?{altitudeDeg:this.radiantAltitudeDeg,azimuthDeg:this.radiantAzimuthDeg}:void 0}pushRibbon(e,t,i,n,s,r,o){const c=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(i,t))));for(let l=0;l<fi.ACROSS-1;l++){const h=l-1,u=l,d=this.across(t,c,n,h),f=this.across(i,c,s,h),p=this.across(t,c,n,u),v=this.across(i,c,s,u),m=(g,_)=>g===0?_:0;e=this.push(e,d,m(h,r)),e=this.push(e,f,m(h,o)),e=this.push(e,p,m(u,r)),e=this.push(e,f,m(h,o)),e=this.push(e,v,m(u,o)),e=this.push(e,p,m(u,r))}return e}across(e,t,i,n){return{x:e.x+t.x*i*n,y:e.y+t.y*i*n,z:e.z+t.z*i*n}}push(e,t,i){const n=e*3;this.positions[n]=t.x,this.positions[n+1]=t.y,this.positions[n+2]=t.z;const s=Ee.relativeOfResponse(Math.max(0,Math.min(1,i)));return this.colors[n]=s*.9,this.colors[n+1]=s*.95,this.colors[n+2]=s,e+1}turn(e,t,i){const n=i*Math.PI/180,s=Math.cos(n),r=Math.sin(n);return{x:e.x*s+t.x*r,y:e.y*s+t.y*r,z:e.z*s+t.z*r}}onSphere(e,t,i){const n=i*Math.PI/180,s=Math.cos(n),r=Math.sin(n);return{x:(e.x*s+t.x*r)*fi.RADIUS,y:(e.y*s+t.y*r)*fi.RADIUS,z:(e.z*s+t.z*r)*fi.RADIUS}}basisAround(e){const t=Math.abs(e.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},i=this.normalise(this.cross(e,t));return[i,this.normalise(this.cross(e,i))]}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 Rh=Math.PI/180;function qt(a,e,t,i,n=!1){const s=n?new mn({color:new se(...t)}):new Sr({color:new se(...t)}),r=new De(e,s);return r.position.y=i,r.userData={emissive:n},r.castShadow=!n,r.receiveShadow=!n,a.add(r),r}const Dh=.25,Aw=.002,Tw=100,Rw=1500,Dw=.25,Cw=1e3,Iw=.15;function Pw(a){const e=/^#([0-9a-f]{6})$/i.exec(a);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 Lw=[.32,.32,.3],r1=[1,.85,.5],Nw=[.25,.25,.25],o1=[1,.97,.85],Ow=[.55,.68,.72],Vn=.03,Wn=.05,c1={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 Oi(a,e){return a?.[e]}function Xn(a,e,t,i,n,s,r,o){if(o===void 0)return;const c=new Sr({color:new se(...Ow),transparent:!0,opacity:o/100}),l=new De(new sn(e,t,i),c);l.position.set(n,s,r),a.add(l)}const hn=.05,Ch=[.6,.58,.53],Lp=[.5,.5,.48];function nr(a,e,t,i,n,s,r,o){const c=new Sr({color:new se(...o),side:Ot}),l=new De(new sn(e,t,i),c);l.position.set(n,s,r),a.add(l)}function Uw(a,e,t,i,n,s,r,o,c){const l=(i-s)/2,h=(p,v,m,g)=>{p<=0||(e?nr(a,p,v,hn,m,o+g,r,c):nr(a,hn,v,p,r,o+g,m,c))};h(t,l,0,i/2-l/2),h(t,l,0,-(i/2-l/2));const u=[...n].sort((p,v)=>p.center-v.center);let d=-t/2;for(const p of u){const m=p.center-p.main/2-d;h(m,s,d+m/2,0),d=p.center+p.main/2}const f=t/2-d;h(f,s,d+f/2,0)}function l1(a,e,t,i,n,s,r,o,c,l){const h=(i+n)/2,u=n-i,d=(f,p,v,m)=>{f.length===0?p?nr(a,v,u,hn,0,h,m,Ch):nr(a,hn,u,v,m,h,0,Ch):Uw(a,p,v,u,f,s,m,h,Ch)};d(r,!0,e*2,-t+hn),d(o,!0,e*2,t-hn),d(c,!1,t*2,-e+hn),d(l,!1,t*2,e-hn),nr(a,e*2,hn,t*2,0,i+hn,0,Lp),nr(a,e*2,hn,t*2,0,n-hn,0,Lp)}function yd(a,e,t,i){switch(a){case"front":return{x:0,z:-(t-i)};case"behind":return{x:0,z:t-i};case"left":return{x:-(e-i),z:0};case"right":return{x:e-i,z:0};case"front-left":return{x:-(e-i),z:-qn};case"front-right":return{x:e-i,z:-qn};case"behind-left":return{x:-(e-i),z:qn};case"behind-right":return{x:e-i,z:qn}}}function h1(a,e,t,i,n,s,r){const o=wd();o.scale.setScalar(i),o.rotation.y=c1[e];const{x:c,z:l}=yd(e,n,s,r);o.position.set(c,t,l),a.add(o)}const _d=6,Sd=6,Fs=3,Vr=1.4,Wr=Fs*.5,u1=1.2,d1=.35,Fw=.75,kw=1.6;function Np(a,e,t,i){const n=new Dt,s=Math.max(1,a+1),r=s*Fs;qt(n,new sn(_d,r,Sd),[.55,.54,.5],r/2);const o=_d/2,c=Sd/2;for(let l=0;l<s;l++){const h=l*Fs+Fs/2;Xn(n,Vr,Wr,Wn,0,h,-c-Vn,Oi(e,"front")),Xn(n,Vr,Wr,Wn,0,h,c+Vn,Oi(e,"behind")),Xn(n,Wn,Wr,Vr,-o-Vn,h,0,Oi(e,"left")),Xn(n,Wn,Wr,Vr,o+Vn,h,0,Oi(e,"right"))}if(t){const l=Math.min(Math.max(i??0,0),s-1);h1(n,t,l*Fs,.72,o,c,u1);const h=u=>Oi(e,u)!==void 0?[{main:Vr,center:0}]:[];l1(n,o,c,l*Fs,(l+1)*Fs,Wr,h("front"),h("behind"),h("left"),h("right"))}return n}function Op(){const a=new Dt,e=[[0,0,.55,.5],[.4,.1,.35,.4],[-.35,-.2,.4,.38],[.1,-.4,.35,.36],[-.15,.4,.3,.34]];for(const[t,i,n,s]of e){const r=new jt(n,10,7);r.scale(1,.85,1),r.translate(t,0,i),qt(a,r,[.26,.28,.17],s)}return a}function Up(){const a=new Dt;return qt(a,new es(.15,.22,2,8),[.32,.22,.14],1),qt(a,new _r(1.4,3,8),[.16,.32,.14],3.5),a}const Fp=.275,zw=.35,Hw=.9,Bw=34,Gw=8,Vw=1.4;function kp(){const a=new Dt,e=new jt(Fp,7,3,0,Math.PI*2,0,Math.PI/2);e.scale(1,zw/Fp,1);const t=gi.repeatOnGrid(e,Bw,Hw,Gw,Vw),i=qt(a,t,[.26,.28,.22],0);return i.castShadow=!0,i.userData.cropBasePositions=t.getAttribute("position").array.slice(),i.userData.cropVerticesPerClump=e.getAttribute("position").count,e.dispose(),a}function zp(){const a=new Dt,e=new jt(1,7,3,0,Math.PI*2,0,Math.PI/2);return qt(a,e,[.38,.36,.32],0),a}function Hp(a){const e=new Dt;return qt(e,new es(.05,.08,5,8),[.28,.28,.3],2.5),qt(e,new jt(.25,12,8),a?r1:Lw,5.1,!0),e}const Ww=[.08,.08,.08],Ns=.8,Qa=1,zn=1.7,Ih=.6,ia=.4,wc=1.2,Za=.7,qn=.5,Xw=zn;function Bp(a,e,t){const i=new Dt;qt(i,new sn(1.8,1.4,4.2),[.45,.14,.14],.7),qt(i,new sn(Ns*2,Ih,Qa*2),[.4,.12,.12],zn);for(const s of[-1.4,1.4])for(const r of[-.95,.95]){const o=qt(i,new es(.4,.4,.3,12),Ww,.4);o.rotation.z=Math.PI/2,o.position.x=r,o.position.z=s}const n=a?o1:Nw;for(const s of[-.7,.7])qt(i,new jt(.15,8,6),n,.7,!0).position.set(s,.7,-2.1);if(Xn(i,wc,ia,Wn,0,zn,-Qa-Vn,Oi(e,"front")),Xn(i,wc,ia,Wn,0,zn,Qa+Vn,Oi(e,"behind")),Xn(i,Wn,ia,Za,-Ns-Vn,zn,-qn,Oi(e,"front-left")),Xn(i,Wn,ia,Za,-Ns-Vn,zn,qn,Oi(e,"behind-left")),Xn(i,Wn,ia,Za,Ns+Vn,zn,-qn,Oi(e,"front-right")),Xn(i,Wn,ia,Za,Ns+Vn,zn,qn,Oi(e,"behind-right")),t){h1(i,t,Fw,.5,Ns,Qa,d1);const s=(c,l)=>{const h=[];return Oi(e,c)!==void 0&&h.push({main:Za,center:-qn}),Oi(e,l)!==void 0&&h.push({main:Za,center:qn}),h},r=Oi(e,"front")!==void 0?[{main:wc,center:0}]:[],o=Oi(e,"behind")!==void 0?[{main:wc,center:0}]:[];l1(i,Ns,Qa,zn-Ih/2,zn+Ih/2,ia,r,o,s("front-left","behind-left"),s("front-right","behind-right"))}return i}const Gp=new Map;function Vp(a,e){if(!a)return;const t=[[a.lengthM,e.lengthM],[a.heightM,e.heightM],[a.widthM,e.widthM]];for(const[i,n]of t)if(i!==void 0&&n>1e-6)return i/n}function Ph(a,e){return e>1e-6?a/e:1}const f1=[.95,.9,.82],Wp=[.72,.74,.78];function Xp(){const a=new Dt;qt(a,new es(.25,.3,1.5,10),Wp,.75),qt(a,new jt(.26,10,8),Wp,1.74);const e=qt(a,new _r(.07,.16,8),f1,1.74);return e.rotation.x=-Math.PI/2,e.position.z=-.22,a}function wd(){const a=new Dt;qt(a,new es(.25,.3,1.5,10),[.3,.3,.35],.75),qt(a,new jt(.22,10,8),[.62,.52,.46],1.72);const e=qt(a,new _r(.07,.16,8),f1,1.72);return e.rotation.x=-Math.PI/2,e.position.z=-.2,a}const qw=17,qp=18.5,Lh=[.16,.16,.18];function Yp(){const a=new Dt,e=qt(a,new es(1.8,1.8,qp*2,10),Lh,0);e.rotation.x=Math.PI/2,qt(a,new sn(qw*2,.5,4.5),Lh,0);const t=qt(a,new sn(.4,5.5,4),Lh,3);return t.position.z=-qp+2,a}class gi{static groundUnderFootprint(e,t,i,n,s,r=0){const o=gi.sizeOf(e);if(r>o.heightM)return s(t,i);const c=(n??0)*Math.PI/180,l=Math.min(21,Math.max(2,Math.ceil(o.lengthM/.75)+1)),h=Math.min(21,Math.max(2,Math.ceil(o.widthM/.75)+1));let u=-1/0;for(let d=0;d<l;d++){const f=(d/(l-1)-.5)*o.lengthM;for(let p=0;p<h;p++){const v=(p/(h-1)-.5)*o.widthM,m=t+Math.sin(c)*f+Math.cos(c)*v,g=i-Math.cos(c)*f+Math.sin(c)*v;u=Math.max(u,s(m,g))}}return Number.isFinite(u)?u:s(t,i)}static occupantView(e){const t=e.witnessSide;if(!t)throw new Error("occupantView requires object.witnessSide to be set");const{x:i,z:n}=e.kind==="vehicle"?yd(t,Ns,Qa,d1):yd(t,_d/2,Sd/2,u1),s=e.kind==="vehicle"?Xw:(e.occupiedFloor??0)*Fs+kw,r=(e.headingDeg??0)-c1[t]/Rh,o=this.scaleFor(e);return{x:i*o.x,z:n*o.z,eyeY:s*o.y,headingDeg:r}}static BODY_NAME="decor-body";static bodyOf(e){return e.getObjectByName(gi.BODY_NAME)??e}static repeatOnGrid(e,t,i,n,s){const r=e.getAttribute("position"),o=e.getAttribute("normal"),c=e.getIndex();if(!c)throw new Error("repeatOnGrid needs an indexed geometry");const l=r.count,h=t*n,u=new Float32Array(l*h*3),d=new Float32Array(l*h*3),f=new Uint32Array(c.count*h),p=-((t-1)*i)/2,v=-((n-1)*s)/2;let m=0;for(let _=0;_<n;_++)for(let w=0;w<t;w++,m++){const M=v+_*s,S=p+w*i;for(let b=0;b<l;b++){const T=(m*l+b)*3;u[T]=r.getX(b)+M,u[T+1]=r.getY(b),u[T+2]=r.getZ(b)+S,d[T]=o.getX(b),d[T+1]=o.getY(b),d[T+2]=o.getZ(b)}for(let b=0;b<c.count;b++)f[m*c.count+b]=c.getX(b)+m*l}const g=new ut;return g.setAttribute("position",new xt(u,3)),g.setAttribute("normal",new xt(d,3)),g.setIndex(new Vd(f,1)),g}static fitCropToGround(e,t){e.updateMatrixWorld(!0);const i=new D;e.traverse(n=>{const s=n,r=s.userData.cropBasePositions,o=s.userData.cropVerticesPerClump;if(!s.isMesh||!r||!o)return;const c=s.geometry.getAttribute("position"),l=new Ze().copy(s.matrixWorld).invert();for(let h=0;h<c.count;h+=o){i.set(r[h*3],0,r[h*3+2]).applyMatrix4(s.matrixWorld),i.y=t(i.x,i.z),i.applyMatrix4(l);for(let u=h;u<h+o;u++)c.setY(u,r[u*3+1]+i.y)}c.needsUpdate=!0,s.geometry.computeBoundingBox(),s.geometry.computeBoundingSphere()})}static paint(e,t){e.traverse(i=>{const n=i,s=n.userData;if(!n.isMesh||s?.emissive)return;const r=n.material;r?.color&&r.color.set(t)})}static build(e,t){const i=e.kind==="building"?Np(e.floors??H0,e.windows,e.witnessSide,e.occupiedFloor):e.kind==="tree"?Up():e.kind==="shrub"?Op():e.kind==="crop"?kp():e.kind==="mound"?zp():e.kind==="streetlight"?Hp(t):e.kind==="vehicle"?Bp(t,e.windows,e.witnessSide):e.kind==="aircraft"?Yp():e.kind==="entity"?Xp():wd();e.color&&this.paint(i,e.color);const n=this.scaleFor(e),s=new Dt;return i.name=gi.BODY_NAME,i.scale.copy(n),s.add(i),e.headingDeg!==void 0&&(s.rotation.y=-e.headingDeg*Rh),this.addLights(s,e.lights),s}static scaleFor(e){const t=e.sizeM;if(!t)return new D(1,1,1);const i=this.naturalSize(e.kind,e.floors);return new D(t.widthM===void 0?1:Ph(t.widthM,i.widthM),t.heightM===void 0?1:Ph(t.heightM,i.heightM),t.lengthM===void 0?1:Ph(t.lengthM,i.lengthM))}static naturalSize(e,t){const i=e==="building"?Math.max(1,(t??H0)+1):0,n=`${e}:${i}`,s=Gp.get(n);if(s)return s;const r=e==="building"?Np(i-1,void 0,void 0,void 0):e==="tree"?Up():e==="shrub"?Op():e==="crop"?kp():e==="mound"?zp():e==="streetlight"?Hp(!1):e==="vehicle"?Bp(!1,void 0,void 0):e==="aircraft"?Yp():e==="entity"?Xp():wd(),o=new vn().setFromObject(r),c={widthM:o.max.x-o.min.x,heightM:o.max.y-o.min.y,lengthM:o.max.z-o.min.z};return this.dispose(r),Gp.set(n,c),c}static usesModel(e){return e.model!==void 0&&!(e.witnessSide!==void 0&&Um(e.kind))}static applyModel(e,t,i,n={}){const s=this.bodyOf(e),r=new Dt;r.name=gi.BODY_NAME,i.rotation.y=-(n.headingOffsetDeg??0)*Rh,i.updateMatrixWorld(!0);const o=new vn().setFromObject(i),c={lengthM:o.max.z-o.min.z,heightM:o.max.y-o.min.y,widthM:o.max.x-o.min.x},l=Vp(t.sizeM,c)??Vp(n.depictedSizeM,c)??1;i.scale.multiplyScalar(l);const h=o.getCenter(new D).multiplyScalar(l);i.position.x-=h.x,i.position.z-=h.z,i.position.y-=t.kind==="aircraft"?h.y:o.min.y*l,i.traverse(u=>{u instanceof De&&(u.castShadow=!0,u.receiveShadow=!0)}),r.add(i),s.parent?(s.parent.add(r),s.removeFromParent()):e.add(r),this.dispose(s)}static sizeOf(e){const t=this.naturalSize(e.kind,e.floors);return{widthM:e.sizeM?.widthM??t.widthM,lengthM:e.sizeM?.lengthM??t.lengthM,heightM:e.sizeM?.heightM??t.heightM}}static addLights(e,t){for(const i of t??[]){const n=Pw(i.color),s=qt(e,new jt(Dh,8,6),n,i.offsetM.y,!0);s.position.set(i.offsetM.x,i.offsetM.y,i.offsetM.z),s.userData={emissive:!0,lightId:i.id,lightColor:n},s.visible=!1}}static setLights(e,t,i,n,s=0,r=1){if(!t||t.length===0)return;const o=new Map(t.map(u=>[u.id,u])),c=Math.max(1,n*Aw/Dh),l=Dh*c,h=r/(Math.PI*l*l);for(const u of e.children){if(!(u instanceof De))continue;const d=u.userData.lightId;if(!d)continue;const f=o.get(d);if(!f)continue;const p=s>0?Fm(f,i,i+s):h2(f,i)?1:0;u.visible=p>0;const v=u.material,m=u.userData.lightColor;if(m){const g=p*Tw*(f.intensity??1)*h;v.color.setRGB(m[0]*g,m[1]*g,m[2]*g)}u.scale.setScalar(c)}}static setLit(e,t,i,n=1){const[s,r,o]=t==="streetlight"?[Rw,Dw,r1]:[Cw,Iw,o1],c=i?s*n/(Math.PI*r*r):0,l=[o[0]*c,o[1]*c,o[2]*c];e.traverse(h=>{const u=h.userData;!(h instanceof De)||!u.emissive||u.lightId||h.material.color.setRGB(...l)})}static dispose(e){e.traverse(t=>{if(!(t instanceof De))return;t.geometry.dispose();const i=t.material;for(const n of Array.isArray(i)?i:[i])n.dispose()})}}const Nh="https://ufoathome.org/models/index.json";class Yw{attribution="3D models re-hosted by UFO@home, each under its own author's licence";fetchImpl;indexUrls;loading;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.indexUrls=e.indexUrls??Kw()}async entries(e){const t=await this.load();return e?t.filter(i=>i.kind===e):t}async entry(e){return(await this.load()).find(t=>t.id===e)}load(){return this.loading??=this.fetchFirstAvailable(),this.loading}async fetchFirstAvailable(){for(const e of this.indexUrls){const t=await this.fetchIndex(e);if(t)return t}return[]}async fetchIndex(e){try{const t=await this.fetchImpl(e);if(!t.ok)return;const i=await t.json();return Array.isArray(i?.models)?i.models.map(({file:n,...s})=>({...s,url:new URL(n,e).href})):void 0}catch{return}}}function Kw(){const a=`?v=${encodeURIComponent("0.64.3")}`,e=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return(e&&e!==Nh?[e,Nh]:[Nh]).map(t=>t+a)}const $w=[{id:"ufoathome",name:"UFO@home",credit:"3D models re-hosted by UFO@home, each under its own author's licence",creditUrl:"https://ufoathome.org/models/",create:()=>new Yw}];async function Kp(a){const{GLTFLoader:e}=await Wc(async()=>{const{GLTFLoader:i}=await import("./GLTFLoader-BumifFuq.js");return{GLTFLoader:i}},[],import.meta.url),t=new e;return new Promise((i,n)=>{t.load(a,s=>i(s.scene),void 0,s=>n(new Error(`Could not load 3D model ${a}: ${s instanceof Error?s.message:String(s)}`)))})}const p1=["ellipsoid","sphere","disc","cylinder","cone","box","torus","figure"];class Qi{static MIN_ANGLE_RAD=.002;static FILL=(1-Math.exp(-4))/4;static MAX_SHARE=.3;mesh;constructor(e,t){this.mesh=new De(new ki(2,2),new at({uniforms:{uColor:{value:new se(0,0,0)},uRadius:{value:1}},vertexShader:Qi.VERTEX,fragmentShader:Qi.FRAGMENT,transparent:!0,depthWrite:!1,blending:Di,toneMapped:!1})),this.mesh.name=e,this.mesh.frustumCulled=!1,this.mesh.renderOrder=t,this.mesh.visible=!1}shine(e,t,i){this.mesh.visible=!0,this.mesh.position.set(e.x,e.y,e.z),this.mesh.material.uniforms.uRadius.value=t,this.mesh.material.uniforms.uColor.value.setRGB(i[0],i[1],i[2])}hide(){this.mesh.visible=!1}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose()}static spread(e,t,i,n){const s=Math.max(e,n*Qi.MIN_ANGLE_RAD),r=Qi.FILL*Math.PI*s*s;return{radiusM:s,luminanceCdM2:i*Math.min(Qi.MAX_SHARE,t/r)}}static conserving(e){return Math.sqrt(e/(Qi.MAX_SHARE*Qi.FILL*Math.PI))}static VERTEX=`
|
|
6385
|
+
`,transparent:!0,blending:Ci,depthWrite:!1,side:Ot,fog:!1}),this.object=new De(new Qt(Ti.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1;const i=this.material.uniforms;this.deckUniforms={uSource:i.uSource,uUp:i.uUp,uStrength:i.uStrength,uTint:i.uTint,uMap:i.uMap,uGain:i.uGain,uHaloShown:{value:0}}}deckUniforms;shown=!1;hostedByDeck=!1;set hosted(e){this.hostedByDeck=e,this.show(this.shown)}show(e){this.shown=e,this.object.visible=e&&!this.hostedByDeck,this.deckUniforms.uHaloShown.value=e?1:0}get awaitingFirstDisplay(){return this.tracing&&!this.everDisplayed}setUrgent(e){this.urgent=e}set onReady(e){this.onRepaint=e}update(e,t,i,n,s,r){const o=this.material.uniforms;if(i<=0){o.uStrength.value=0,this.show(!1),this.stopWork();return}o.uSource.value.set(e.x,e.y,e.z).normalize(),o.uStrength.value=i,o.uTint.value.set(n[0],n[1],n[2]),o.uIceCover.value=s.cover,o.uIceHeight.value=s.layerHeight,this.show(this.everDisplayed),this.requestMap(t,r)}requestMap(e,t){if(!(!(Math.abs(e-this.mappedAltitudeDeg)<Ti.ALTITUDE_STEP_DEG)||!(Math.abs(t-this.mappedAlignment)<Ti.ALIGNMENT_STEP))){this.next=void 0;return}if(this.tracing){if(this.tracingFor(e,t)){this.next=void 0;return}if(!(!(Math.abs(e-this.pendingAltitudeDeg)<Ti.LEAP_ALTITUDE_DEG)||!(Math.abs(t-this.pendingAlignment)<Ti.LEAP_ALIGNMENT))){this.next={sourceAltitudeDeg:e,alignment:t};return}}this.next=void 0,this.pendingAltitudeDeg=e,this.pendingAlignment=t,this.sky.begin(e,t),this.tracing=!0,this.scheduleWork()}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;next;tracingFor(e,t){return this.tracing&&Math.abs(e-this.pendingAltitudeDeg)<Ti.ALTITUDE_STEP_DEG&&Math.abs(t-this.pendingAlignment)<Ti.ALIGNMENT_STEP}scheduleWork(){if(this.workHandle!==void 0)return;const e=()=>{if(this.workHandle=void 0,!this.tracing)return;const t=performance.now(),i=this.urgent?Ti.URGENT_BUDGET_MS:Ti.BUDGET_MS;do this.sky.trace(Ti.RAYS_PER_BATCH);while(this.sky.tracedRays<Ti.RAYS&&performance.now()-t<i);if(this.sky.tracedRays>=Ti.RAYS){this.publish(),this.tracing=!1,this.mappedAltitudeDeg=this.pendingAltitudeDeg,this.mappedAlignment=this.pendingAlignment;const s=this.next;s&&this.requestMap(s.sourceAltitudeDeg,s.alignment);return}this.workHandle=requestAnimationFrame(e)};this.workHandle=requestAnimationFrame(e)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0,this.tracing=!1,this.next=void 0}publish(){const t=this.sky.harvest().data;for(let i=0,n=0;n<t.length;i+=4,n+=3)this.texels[i]=Dn.toHalfFloat(t[n]),this.texels[i+1]=Dn.toHalfFloat(t[n+1]),this.texels[i+2]=Dn.toHalfFloat(t[n+2]),this.texels[i+3]=1;this.texture.needsUpdate=!0,this.everDisplayed=!0,this.show(this.material.uniforms.uStrength.value>0),this.onRepaint?.()}dispose(){this.stopWork(),this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class pi{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=pi.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(pi.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=pi.MAX_CONCURRENT*pi.SEGMENTS*pi.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const t=new ut;t.setAttribute("position",new et(this.positions,3)),t.setAttribute("color",new et(this.colors,3)),t.setDrawRange(0,0),this.object=new De(t,new mn({vertexColors:!0,transparent:!0,blending:Ci,depthWrite:!1,fog:!1,side:tn})),this.object.frustumCulled=!1}get schedule(){return this.meteors}setShower(e,t,i){this.meteors=e,this.radiantAltitudeDeg=t,this.radiantAzimuthDeg=i}update(e){const t=this.object.geometry;if(this.meteors.length===0){t.setDrawRange(0,0);return}const i=va.aliveAt(this.meteors,e).slice(0,pi.MAX_CONCURRENT);let n=0;for(const{meteor:s,progress:r}of i){const o=this.radiantOf(s);if(!o)continue;const c=ni(o.altitudeDeg,o.azimuthDeg,1),[l,h]=this.basisAround(c),u=s.fromRadiantDeg+r*s.lengthDeg,d=Math.max(s.fromRadiantDeg,u-s.lengthDeg*.6),f=Math.min(1,(1-r)*2.5),p=this.turn(l,h,s.bearingDeg),v=(.15+.85*s.brightness)*f,m=w=>v*w**1.6,g=w=>this.onSphere(c,p,d+(u-d)*w),_=w=>pi.RADIUS*((pi.MIN_HALF_WIDTH_DEG+pi.BRIGHT_HALF_WIDTH_DEG*s.brightness*w)*Math.PI/180);for(let w=1;w<pi.POINTS;w++){const M=(w-1)/pi.SEGMENTS,S=w/pi.SEGMENTS;n=this.pushRibbon(n,g(M),g(S),_(M),_(S),m(M),m(S))}}t.setDrawRange(0,n),t.getAttribute("position").needsUpdate=!0,t.getAttribute("color").needsUpdate=!0}midpointOf(e){const t=this.radiantOf(e);if(!t)return;const i=ni(t.altitudeDeg,t.azimuthDeg,1),[n,s]=this.basisAround(i),r=this.turn(n,s,e.bearingDeg),o=this.onSphere(i,r,e.fromRadiantDeg+e.lengthDeg/2),c=Math.hypot(o.x,o.y,o.z)||1;return{altitudeDeg:Math.asin(o.y/c)*180/Math.PI,azimuthDeg:(Math.atan2(o.x,-o.z)*180/Math.PI+360)%360}}radiantOf(e){return e.radiant?e.radiant:this.radiantAltitudeDeg>0?{altitudeDeg:this.radiantAltitudeDeg,azimuthDeg:this.radiantAzimuthDeg}:void 0}pushRibbon(e,t,i,n,s,r,o){const c=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(i,t))));for(let l=0;l<pi.ACROSS-1;l++){const h=l-1,u=l,d=this.across(t,c,n,h),f=this.across(i,c,s,h),p=this.across(t,c,n,u),v=this.across(i,c,s,u),m=(g,_)=>g===0?_:0;e=this.push(e,d,m(h,r)),e=this.push(e,f,m(h,o)),e=this.push(e,p,m(u,r)),e=this.push(e,f,m(h,o)),e=this.push(e,v,m(u,o)),e=this.push(e,p,m(u,r))}return e}across(e,t,i,n){return{x:e.x+t.x*i*n,y:e.y+t.y*i*n,z:e.z+t.z*i*n}}push(e,t,i){const n=e*3;this.positions[n]=t.x,this.positions[n+1]=t.y,this.positions[n+2]=t.z;const s=Ee.relativeOfResponse(Math.max(0,Math.min(1,i)));return this.colors[n]=s*.9,this.colors[n+1]=s*.95,this.colors[n+2]=s,e+1}turn(e,t,i){const n=i*Math.PI/180,s=Math.cos(n),r=Math.sin(n);return{x:e.x*s+t.x*r,y:e.y*s+t.y*r,z:e.z*s+t.z*r}}onSphere(e,t,i){const n=i*Math.PI/180,s=Math.cos(n),r=Math.sin(n);return{x:(e.x*s+t.x*r)*pi.RADIUS,y:(e.y*s+t.y*r)*pi.RADIUS,z:(e.z*s+t.z*r)*pi.RADIUS}}basisAround(e){const t=Math.abs(e.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},i=this.normalise(this.cross(e,t));return[i,this.normalise(this.cross(e,i))]}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 Rh=Math.PI/180;function Yt(a,e,t,i,n=!1){const s=n?new mn({color:new se(...t)}):new Sr({color:new se(...t)}),r=new De(e,s);return r.position.y=i,r.userData={emissive:n},r.castShadow=!n,r.receiveShadow=!n,a.add(r),r}const Dh=.25,Aw=.002,Tw=100,Rw=1500,Dw=.25,Cw=1e3,Iw=.15;function Pw(a){const e=/^#([0-9a-f]{6})$/i.exec(a);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 Lw=[.32,.32,.3],r1=[1,.85,.5],Nw=[.25,.25,.25],o1=[1,.97,.85],Ow=[.55,.68,.72],Vn=.03,Wn=.05,c1={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 Oi(a,e){return a?.[e]}function Xn(a,e,t,i,n,s,r,o){if(o===void 0)return;const c=new Sr({color:new se(...Ow),transparent:!0,opacity:o/100}),l=new De(new sn(e,t,i),c);l.position.set(n,s,r),a.add(l)}const hn=.05,Ch=[.6,.58,.53],Lp=[.5,.5,.48];function nr(a,e,t,i,n,s,r,o){const c=new Sr({color:new se(...o),side:Ot}),l=new De(new sn(e,t,i),c);l.position.set(n,s,r),a.add(l)}function Uw(a,e,t,i,n,s,r,o,c){const l=(i-s)/2,h=(p,v,m,g)=>{p<=0||(e?nr(a,p,v,hn,m,o+g,r,c):nr(a,hn,v,p,r,o+g,m,c))};h(t,l,0,i/2-l/2),h(t,l,0,-(i/2-l/2));const u=[...n].sort((p,v)=>p.center-v.center);let d=-t/2;for(const p of u){const m=p.center-p.main/2-d;h(m,s,d+m/2,0),d=p.center+p.main/2}const f=t/2-d;h(f,s,d+f/2,0)}function l1(a,e,t,i,n,s,r,o,c,l){const h=(i+n)/2,u=n-i,d=(f,p,v,m)=>{f.length===0?p?nr(a,v,u,hn,0,h,m,Ch):nr(a,hn,u,v,m,h,0,Ch):Uw(a,p,v,u,f,s,m,h,Ch)};d(r,!0,e*2,-t+hn),d(o,!0,e*2,t-hn),d(c,!1,t*2,-e+hn),d(l,!1,t*2,e-hn),nr(a,e*2,hn,t*2,0,i+hn,0,Lp),nr(a,e*2,hn,t*2,0,n-hn,0,Lp)}function yd(a,e,t,i){switch(a){case"front":return{x:0,z:-(t-i)};case"behind":return{x:0,z:t-i};case"left":return{x:-(e-i),z:0};case"right":return{x:e-i,z:0};case"front-left":return{x:-(e-i),z:-qn};case"front-right":return{x:e-i,z:-qn};case"behind-left":return{x:-(e-i),z:qn};case"behind-right":return{x:e-i,z:qn}}}function h1(a,e,t,i,n,s,r){const o=wd();o.scale.setScalar(i),o.rotation.y=c1[e];const{x:c,z:l}=yd(e,n,s,r);o.position.set(c,t,l),a.add(o)}const _d=6,Sd=6,Fs=3,Vr=1.4,Wr=Fs*.5,u1=1.2,d1=.35,Fw=.75,kw=1.6;function Np(a,e,t,i){const n=new Dt,s=Math.max(1,a+1),r=s*Fs;Yt(n,new sn(_d,r,Sd),[.55,.54,.5],r/2);const o=_d/2,c=Sd/2;for(let l=0;l<s;l++){const h=l*Fs+Fs/2;Xn(n,Vr,Wr,Wn,0,h,-c-Vn,Oi(e,"front")),Xn(n,Vr,Wr,Wn,0,h,c+Vn,Oi(e,"behind")),Xn(n,Wn,Wr,Vr,-o-Vn,h,0,Oi(e,"left")),Xn(n,Wn,Wr,Vr,o+Vn,h,0,Oi(e,"right"))}if(t){const l=Math.min(Math.max(i??0,0),s-1);h1(n,t,l*Fs,.72,o,c,u1);const h=u=>Oi(e,u)!==void 0?[{main:Vr,center:0}]:[];l1(n,o,c,l*Fs,(l+1)*Fs,Wr,h("front"),h("behind"),h("left"),h("right"))}return n}function Op(){const a=new Dt,e=[[0,0,.55,.5],[.4,.1,.35,.4],[-.35,-.2,.4,.38],[.1,-.4,.35,.36],[-.15,.4,.3,.34]];for(const[t,i,n,s]of e){const r=new Qt(n,10,7);r.scale(1,.85,1),r.translate(t,0,i),Yt(a,r,[.26,.28,.17],s)}return a}function Up(){const a=new Dt;return Yt(a,new es(.15,.22,2,8),[.32,.22,.14],1),Yt(a,new _r(1.4,3,8),[.16,.32,.14],3.5),a}const Fp=.275,zw=.35,Hw=.9,Bw=34,Gw=8,Vw=1.4;function kp(){const a=new Dt,e=new Qt(Fp,7,3,0,Math.PI*2,0,Math.PI/2);e.scale(1,zw/Fp,1);const t=vi.repeatOnGrid(e,Bw,Hw,Gw,Vw),i=Yt(a,t,[.26,.28,.22],0);return i.castShadow=!0,i.userData.cropBasePositions=t.getAttribute("position").array.slice(),i.userData.cropVerticesPerClump=e.getAttribute("position").count,e.dispose(),a}function zp(){const a=new Dt,e=new Qt(1,7,3,0,Math.PI*2,0,Math.PI/2);return Yt(a,e,[.38,.36,.32],0),a}function Hp(a){const e=new Dt;return Yt(e,new es(.05,.08,5,8),[.28,.28,.3],2.5),Yt(e,new Qt(.25,12,8),a?r1:Lw,5.1,!0),e}const Ww=[.08,.08,.08],Ns=.8,Qa=1,zn=1.7,Ih=.6,ia=.4,wc=1.2,Za=.7,qn=.5,Xw=zn;function Bp(a,e,t){const i=new Dt;Yt(i,new sn(1.8,1.4,4.2),[.45,.14,.14],.7),Yt(i,new sn(Ns*2,Ih,Qa*2),[.4,.12,.12],zn);for(const s of[-1.4,1.4])for(const r of[-.95,.95]){const o=Yt(i,new es(.4,.4,.3,12),Ww,.4);o.rotation.z=Math.PI/2,o.position.x=r,o.position.z=s}const n=a?o1:Nw;for(const s of[-.7,.7])Yt(i,new Qt(.15,8,6),n,.7,!0).position.set(s,.7,-2.1);if(Xn(i,wc,ia,Wn,0,zn,-Qa-Vn,Oi(e,"front")),Xn(i,wc,ia,Wn,0,zn,Qa+Vn,Oi(e,"behind")),Xn(i,Wn,ia,Za,-Ns-Vn,zn,-qn,Oi(e,"front-left")),Xn(i,Wn,ia,Za,-Ns-Vn,zn,qn,Oi(e,"behind-left")),Xn(i,Wn,ia,Za,Ns+Vn,zn,-qn,Oi(e,"front-right")),Xn(i,Wn,ia,Za,Ns+Vn,zn,qn,Oi(e,"behind-right")),t){h1(i,t,Fw,.5,Ns,Qa,d1);const s=(c,l)=>{const h=[];return Oi(e,c)!==void 0&&h.push({main:Za,center:-qn}),Oi(e,l)!==void 0&&h.push({main:Za,center:qn}),h},r=Oi(e,"front")!==void 0?[{main:wc,center:0}]:[],o=Oi(e,"behind")!==void 0?[{main:wc,center:0}]:[];l1(i,Ns,Qa,zn-Ih/2,zn+Ih/2,ia,r,o,s("front-left","behind-left"),s("front-right","behind-right"))}return i}const Gp=new Map;function Vp(a,e){if(!a)return;const t=[[a.lengthM,e.lengthM],[a.heightM,e.heightM],[a.widthM,e.widthM]];for(const[i,n]of t)if(i!==void 0&&n>1e-6)return i/n}function Ph(a,e){return e>1e-6?a/e:1}const f1=[.95,.9,.82],Wp=[.72,.74,.78];function Xp(){const a=new Dt;Yt(a,new es(.25,.3,1.5,10),Wp,.75),Yt(a,new Qt(.26,10,8),Wp,1.74);const e=Yt(a,new _r(.07,.16,8),f1,1.74);return e.rotation.x=-Math.PI/2,e.position.z=-.22,a}function wd(){const a=new Dt;Yt(a,new es(.25,.3,1.5,10),[.3,.3,.35],.75),Yt(a,new Qt(.22,10,8),[.62,.52,.46],1.72);const e=Yt(a,new _r(.07,.16,8),f1,1.72);return e.rotation.x=-Math.PI/2,e.position.z=-.2,a}const qw=17,qp=18.5,Lh=[.16,.16,.18];function Yp(){const a=new Dt,e=Yt(a,new es(1.8,1.8,qp*2,10),Lh,0);e.rotation.x=Math.PI/2,Yt(a,new sn(qw*2,.5,4.5),Lh,0);const t=Yt(a,new sn(.4,5.5,4),Lh,3);return t.position.z=-qp+2,a}class vi{static groundUnderFootprint(e,t,i,n,s,r=0){const o=vi.sizeOf(e);if(r>o.heightM)return s(t,i);const c=(n??0)*Math.PI/180,l=Math.min(21,Math.max(2,Math.ceil(o.lengthM/.75)+1)),h=Math.min(21,Math.max(2,Math.ceil(o.widthM/.75)+1));let u=-1/0;for(let d=0;d<l;d++){const f=(d/(l-1)-.5)*o.lengthM;for(let p=0;p<h;p++){const v=(p/(h-1)-.5)*o.widthM,m=t+Math.sin(c)*f+Math.cos(c)*v,g=i-Math.cos(c)*f+Math.sin(c)*v;u=Math.max(u,s(m,g))}}return Number.isFinite(u)?u:s(t,i)}static occupantView(e){const t=e.witnessSide;if(!t)throw new Error("occupantView requires object.witnessSide to be set");const{x:i,z:n}=e.kind==="vehicle"?yd(t,Ns,Qa,d1):yd(t,_d/2,Sd/2,u1),s=e.kind==="vehicle"?Xw:(e.occupiedFloor??0)*Fs+kw,r=(e.headingDeg??0)-c1[t]/Rh,o=this.scaleFor(e);return{x:i*o.x,z:n*o.z,eyeY:s*o.y,headingDeg:r}}static BODY_NAME="decor-body";static bodyOf(e){return e.getObjectByName(vi.BODY_NAME)??e}static repeatOnGrid(e,t,i,n,s){const r=e.getAttribute("position"),o=e.getAttribute("normal"),c=e.getIndex();if(!c)throw new Error("repeatOnGrid needs an indexed geometry");const l=r.count,h=t*n,u=new Float32Array(l*h*3),d=new Float32Array(l*h*3),f=new Uint32Array(c.count*h),p=-((t-1)*i)/2,v=-((n-1)*s)/2;let m=0;for(let _=0;_<n;_++)for(let w=0;w<t;w++,m++){const M=v+_*s,S=p+w*i;for(let b=0;b<l;b++){const T=(m*l+b)*3;u[T]=r.getX(b)+M,u[T+1]=r.getY(b),u[T+2]=r.getZ(b)+S,d[T]=o.getX(b),d[T+1]=o.getY(b),d[T+2]=o.getZ(b)}for(let b=0;b<c.count;b++)f[m*c.count+b]=c.getX(b)+m*l}const g=new ut;return g.setAttribute("position",new xt(u,3)),g.setAttribute("normal",new xt(d,3)),g.setIndex(new Vd(f,1)),g}static fitCropToGround(e,t){e.updateMatrixWorld(!0);const i=new D;e.traverse(n=>{const s=n,r=s.userData.cropBasePositions,o=s.userData.cropVerticesPerClump;if(!s.isMesh||!r||!o)return;const c=s.geometry.getAttribute("position"),l=new Ze().copy(s.matrixWorld).invert();for(let h=0;h<c.count;h+=o){i.set(r[h*3],0,r[h*3+2]).applyMatrix4(s.matrixWorld),i.y=t(i.x,i.z),i.applyMatrix4(l);for(let u=h;u<h+o;u++)c.setY(u,r[u*3+1]+i.y)}c.needsUpdate=!0,s.geometry.computeBoundingBox(),s.geometry.computeBoundingSphere()})}static paint(e,t){e.traverse(i=>{const n=i,s=n.userData;if(!n.isMesh||s?.emissive)return;const r=n.material;r?.color&&r.color.set(t)})}static build(e,t){const i=e.kind==="building"?Np(e.floors??H0,e.windows,e.witnessSide,e.occupiedFloor):e.kind==="tree"?Up():e.kind==="shrub"?Op():e.kind==="crop"?kp():e.kind==="mound"?zp():e.kind==="streetlight"?Hp(t):e.kind==="vehicle"?Bp(t,e.windows,e.witnessSide):e.kind==="aircraft"?Yp():e.kind==="entity"?Xp():wd();e.color&&this.paint(i,e.color);const n=this.scaleFor(e),s=new Dt;return i.name=vi.BODY_NAME,i.scale.copy(n),s.add(i),e.headingDeg!==void 0&&(s.rotation.y=-e.headingDeg*Rh),this.addLights(s,e.lights),s}static scaleFor(e){const t=e.sizeM;if(!t)return new D(1,1,1);const i=this.naturalSize(e.kind,e.floors);return new D(t.widthM===void 0?1:Ph(t.widthM,i.widthM),t.heightM===void 0?1:Ph(t.heightM,i.heightM),t.lengthM===void 0?1:Ph(t.lengthM,i.lengthM))}static naturalSize(e,t){const i=e==="building"?Math.max(1,(t??H0)+1):0,n=`${e}:${i}`,s=Gp.get(n);if(s)return s;const r=e==="building"?Np(i-1,void 0,void 0,void 0):e==="tree"?Up():e==="shrub"?Op():e==="crop"?kp():e==="mound"?zp():e==="streetlight"?Hp(!1):e==="vehicle"?Bp(!1,void 0,void 0):e==="aircraft"?Yp():e==="entity"?Xp():wd(),o=new vn().setFromObject(r),c={widthM:o.max.x-o.min.x,heightM:o.max.y-o.min.y,lengthM:o.max.z-o.min.z};return this.dispose(r),Gp.set(n,c),c}static usesModel(e){return e.model!==void 0&&!(e.witnessSide!==void 0&&Um(e.kind))}static applyModel(e,t,i,n={}){const s=this.bodyOf(e),r=new Dt;r.name=vi.BODY_NAME,i.rotation.y=-(n.headingOffsetDeg??0)*Rh,i.updateMatrixWorld(!0);const o=new vn().setFromObject(i),c={lengthM:o.max.z-o.min.z,heightM:o.max.y-o.min.y,widthM:o.max.x-o.min.x},l=Vp(t.sizeM,c)??Vp(n.depictedSizeM,c)??1;i.scale.multiplyScalar(l);const h=o.getCenter(new D).multiplyScalar(l);i.position.x-=h.x,i.position.z-=h.z,i.position.y-=t.kind==="aircraft"?h.y:o.min.y*l,i.traverse(u=>{u instanceof De&&(u.castShadow=!0,u.receiveShadow=!0)}),r.add(i),s.parent?(s.parent.add(r),s.removeFromParent()):e.add(r),this.dispose(s)}static sizeOf(e){const t=this.naturalSize(e.kind,e.floors);return{widthM:e.sizeM?.widthM??t.widthM,lengthM:e.sizeM?.lengthM??t.lengthM,heightM:e.sizeM?.heightM??t.heightM}}static addLights(e,t){for(const i of t??[]){const n=Pw(i.color),s=Yt(e,new Qt(Dh,8,6),n,i.offsetM.y,!0);s.position.set(i.offsetM.x,i.offsetM.y,i.offsetM.z),s.userData={emissive:!0,lightId:i.id,lightColor:n},s.visible=!1}}static setLights(e,t,i,n,s=0,r=1){if(!t||t.length===0)return;const o=new Map(t.map(u=>[u.id,u])),c=Math.max(1,n*Aw/Dh),l=Dh*c,h=r/(Math.PI*l*l);for(const u of e.children){if(!(u instanceof De))continue;const d=u.userData.lightId;if(!d)continue;const f=o.get(d);if(!f)continue;const p=s>0?Fm(f,i,i+s):h2(f,i)?1:0;u.visible=p>0;const v=u.material,m=u.userData.lightColor;if(m){const g=p*Tw*(f.intensity??1)*h;v.color.setRGB(m[0]*g,m[1]*g,m[2]*g)}u.scale.setScalar(c)}}static setLit(e,t,i,n=1){const[s,r,o]=t==="streetlight"?[Rw,Dw,r1]:[Cw,Iw,o1],c=i?s*n/(Math.PI*r*r):0,l=[o[0]*c,o[1]*c,o[2]*c];e.traverse(h=>{const u=h.userData;!(h instanceof De)||!u.emissive||u.lightId||h.material.color.setRGB(...l)})}static dispose(e){e.traverse(t=>{if(!(t instanceof De))return;t.geometry.dispose();const i=t.material;for(const n of Array.isArray(i)?i:[i])n.dispose()})}}const Nh="https://ufoathome.org/models/index.json";class Yw{attribution="3D models re-hosted by UFO@home, each under its own author's licence";fetchImpl;indexUrls;loading;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.indexUrls=e.indexUrls??Kw()}async entries(e){const t=await this.load();return e?t.filter(i=>i.kind===e):t}async entry(e){return(await this.load()).find(t=>t.id===e)}load(){return this.loading??=this.fetchFirstAvailable(),this.loading}async fetchFirstAvailable(){for(const e of this.indexUrls){const t=await this.fetchIndex(e);if(t)return t}return[]}async fetchIndex(e){try{const t=await this.fetchImpl(e);if(!t.ok)return;const i=await t.json();return Array.isArray(i?.models)?i.models.map(({file:n,...s})=>({...s,url:new URL(n,e).href})):void 0}catch{return}}}function Kw(){const a=`?v=${encodeURIComponent("0.65.0")}`,e=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return(e&&e!==Nh?[e,Nh]:[Nh]).map(t=>t+a)}const $w=[{id:"ufoathome",name:"UFO@home",credit:"3D models re-hosted by UFO@home, each under its own author's licence",creditUrl:"https://ufoathome.org/models/",create:()=>new Yw}];async function Kp(a){const{GLTFLoader:e}=await Wc(async()=>{const{GLTFLoader:i}=await import("./GLTFLoader-BumifFuq.js");return{GLTFLoader:i}},[],import.meta.url),t=new e;return new Promise((i,n)=>{t.load(a,s=>i(s.scene),void 0,s=>n(new Error(`Could not load 3D model ${a}: ${s instanceof Error?s.message:String(s)}`)))})}const p1=["ellipsoid","sphere","disc","cylinder","cone","box","torus","figure"];class Qi{static MIN_ANGLE_RAD=.002;static FILL=(1-Math.exp(-4))/4;static MAX_SHARE=.3;mesh;constructor(e,t){this.mesh=new De(new ki(2,2),new at({uniforms:{uColor:{value:new se(0,0,0)},uRadius:{value:1}},vertexShader:Qi.VERTEX,fragmentShader:Qi.FRAGMENT,transparent:!0,depthWrite:!1,blending:Ci,toneMapped:!1})),this.mesh.name=e,this.mesh.frustumCulled=!1,this.mesh.renderOrder=t,this.mesh.visible=!1}shine(e,t,i){this.mesh.visible=!0,this.mesh.position.set(e.x,e.y,e.z),this.mesh.material.uniforms.uRadius.value=t,this.mesh.material.uniforms.uColor.value.setRGB(i[0],i[1],i[2])}hide(){this.mesh.visible=!1}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose()}static spread(e,t,i,n){const s=Math.max(e,n*Qi.MIN_ANGLE_RAD),r=Qi.FILL*Math.PI*s*s;return{radiusM:s,luminanceCdM2:i*Math.min(Qi.MAX_SHARE,t/r)}}static conserving(e){return Math.sqrt(e/(Qi.MAX_SHARE*Qi.FILL*Math.PI))}static VERTEX=`
|
|
6378
6386
|
uniform float uRadius;
|
|
6379
6387
|
varying vec2 vOffset;
|
|
6380
6388
|
void main() {
|
|
@@ -6392,7 +6400,7 @@ void main()
|
|
|
6392
6400
|
float weight = exp(-4.0 * d2);
|
|
6393
6401
|
gl_FragColor = vec4(uColor * weight, weight);
|
|
6394
6402
|
}
|
|
6395
|
-
`}class ga{static RENDER_ORDER=3;static LIGHT_AT=.35;static GLOW_MIN_ANGLE_RAD=Qi.MIN_ANGLE_RAD;static GLOW_FILL=Qi.FILL;static GLOW_MAX_SHARE=Qi.MAX_SHARE;mesh;light=new Eg(16777215,0,0,2);glare=new Qi("flame-glow",ga.RENDER_ORDER);scratch=new D;constructor(){const e=[];for(let s=0;s<=32;s++){const r=s/32,o=.5*(.7+.3*Math.sin(Math.min(1,r/.33)*Math.PI/2))*Math.pow(1-r,.55);e.push(new xe(Math.max(o,1e-4),-r))}const i=new _l(e,48),n=new at({uniforms:{uTime:{value:0},uColor:{value:new se(1,1,1)},uTipColor:{value:new se(1,1,1)}},vertexShader:ga.VERTEX,fragmentShader:ga.FRAGMENT,transparent:!0,depthWrite:!1,blending:
|
|
6403
|
+
`}class ga{static RENDER_ORDER=3;static LIGHT_AT=.35;static GLOW_MIN_ANGLE_RAD=Qi.MIN_ANGLE_RAD;static GLOW_FILL=Qi.FILL;static GLOW_MAX_SHARE=Qi.MAX_SHARE;mesh;light=new Eg(16777215,0,0,2);glare=new Qi("flame-glow",ga.RENDER_ORDER);scratch=new D;constructor(){const e=[];for(let s=0;s<=32;s++){const r=s/32,o=.5*(.7+.3*Math.sin(Math.min(1,r/.33)*Math.PI/2))*Math.pow(1-r,.55);e.push(new xe(Math.max(o,1e-4),-r))}const i=new _l(e,48),n=new at({uniforms:{uTime:{value:0},uColor:{value:new se(1,1,1)},uTipColor:{value:new se(1,1,1)}},vertexShader:ga.VERTEX,fragmentShader:ga.FRAGMENT,transparent:!0,depthWrite:!1,blending:Ci,side:tn,toneMapped:!1});this.mesh=new De(i,n),this.mesh.name="flame",this.mesh.frustumCulled=!1,this.mesh.renderOrder=ga.RENDER_ORDER,this.mesh.visible=!1}get glow(){return this.glare.mesh}static glowFor(e,t){return Qi.spread(e.widthM*.6,.7*e.widthM*e.lengthM,e.luminanceCdM2,t)}shine(e,t){this.scratch.set(0,-.5,0).applyMatrix4(this.mesh.matrixWorld),this.glare.shine(this.scratch,e,t)}putOut(){this.mesh.visible=!1,this.glare.hide(),this.light.intensity=0}place(e,t,i,n){this.mesh.visible=!0,this.mesh.position.set(e.x,e.y,e.z),this.mesh.quaternion.set(t.x,t.y,t.z,t.w),this.mesh.scale.set(n,i,n),this.mesh.updateMatrixWorld(),this.light.position.set(0,-.35,0).applyMatrix4(this.mesh.matrixWorld)}set(e,t,i){const n=this.mesh.material.uniforms;n.uColor.value.setRGB(e[0],e[1],e[2]),n.uTipColor.value.setRGB(t[0],t[1],t[2]),n.uTime.value=i}illuminate(e,t){this.light.intensity=e,this.light.color.setRGB(t[0],t[1],t[2])}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose(),this.glare.dispose()}static VERTEX=`
|
|
6396
6404
|
varying vec3 vLocal;
|
|
6397
6405
|
varying vec3 vViewNormal;
|
|
6398
6406
|
varying vec3 vViewPosition;
|
|
@@ -6514,11 +6522,11 @@ void main()
|
|
|
6514
6522
|
vec3 around = textureCube(uSurroundings, reflect(view, normal)).rgb;
|
|
6515
6523
|
gl_FragColor = vec4(around * wall, wall + (1.0 - wall) * uAbsorption);
|
|
6516
6524
|
}
|
|
6517
|
-
`,transparent:!0,depthWrite:!1,side:tn,fog:!1,blending:Ml,blendSrc:go,blendDst:vo})}static wallReflectance(e,t,i){const n=i(e,1,t);return 2*n/(1+n)}setSurroundings(e){this.uniforms.uSurroundings.value=e}static reflectedResponse(e,t){return Ee.respond(t*Ee.relativeOfResponse(Math.max(e,1e-5)))}}const bc=Math.PI/180;class ct{constructor(e,t,i=()=>0){this.loadModel=e,this.onModelArrived=t,this.sceneUnitsPerLux=i,this.group.name="bodies"}group=new Dt;built=new Map;token=0;credits=new Map;flames=new Map;glares=new Map;dust=new Map;smoke=[];scratch=new D;aim=new Qn;down=new D;frame;get modelCredits(){return[...this.credits.values()]}set(e,t,i=0,n,s=e.map(r=>r.id)){this.frame=t;const r=new Set;for(const c of e){r.add(c.id);const l=ct.signatureOf(c.model);let h=this.built.get(c.id);(!h||h.signature!==l)&&(h&&this.remove(c.id),h=this.build(c),this.built.set(c.id,h),this.group.add(h.holder));const{holder:u,material:d,glowing:f}=h;u.visible=!0,u.position.set(t.originX+c.eastM,t.originGroundY+c.upM,t.originZ-c.northM),u.rotation.set(c.attitude.pitchDeg*bc,-c.attitude.headingDeg*bc,-c.attitude.rollDeg*bc,"YXZ"),u.scale.set(c.sizeM.widthM,c.sizeM.heightM,c.sizeM.lengthM),d&&ct.paint(d,c,n),f&&ct.light(f,c,n),this.shine(c,u,f,n,t.eye),this.throwFlame(c,u,i,n,t.eye)}const o=new Set(s);for(const[c,{holder:l}]of[...this.built])r.has(c)||(o.has(c)?(l.visible=!1,this.flames.get(c)?.putOut(),this.glares.get(c)?.hide()):this.remove(c))}shine(e,t,i,n,s){const r=e.appearance.luminanceCdM2;let o=this.glares.get(e.id);if(!(r>0)||!s||i&&i.length>0){o?.hide();return}o||(o=new Ui(`body-veil:${e.id}`),this.glares.set(e.id,o),this.group.add(o.mesh));const c=Math.max(e.sizeM.widthM,e.sizeM.heightM)/2,l=Math.max(t.position.distanceTo(s),c*1.01),h=Math.asin(c/l),u=2*Math.PI*(1-Math.cos(h)),d=i?.find(p=>p.share>=1)?.hue??ct.rgbOf(e.appearance.color),f=this.throughAir(ct.shown(d,r,n),t.position);o.shine(t.position,[f[0]*u,f[1]*u,f[2]*u],h*180/Math.PI)}static glaze(e){e.traverse(t=>{if(!(t instanceof De))return;const i=t.material;!(i instanceof hM)||!(i.transmission>0)||(t.material=new Eo(i.ior),i.dispose(),t.castShadow=!1)})}throughAir(e,t){const i=this.frame?.transmittance?.(t.x,t.y,t.z)??[1,1,1];return[e[0]*i[0],e[1]*i[1],e[2]*i[2]]}static rgbOf(e){const t=new se(e);return[t.r,t.g,t.b]}throwFlame(e,t,i,n,s){let r=this.flames.get(e.id);if(!r&&e.throwsFlame&&(r=new ga,this.flames.set(e.id,r),this.group.add(r.mesh,r.light,r.glow)),!r)return;const o=e.flame;if(!o){r.putOut(),this.dust.get(e.id)?.set(0,0,0,i,{x:0,z:0},0);return}t.updateMatrixWorld(!0);const c=t.getObjectByName(o.node??ct.EXHAUST_NODE);c?c.getWorldPosition(this.scratch):t.localToWorld(this.scratch.set(0,-.5,0)),r.place(this.scratch,c?ct.pointing(c,this.down,this.aim):t.quaternion,o.lengthM,o.widthM);const l=d=>{const f=new se(d);return this.throughAir(ct.shown([f.r,f.g,f.b],o.luminanceCdM2,n),this.scratch)};r.set(l(o.color),l(o.tipColor??o.color),i),r.illuminate(ct.luminousIntensityCd(o)*this.sceneUnitsPerLux(),ct.lightColourOf(o));const h=ga.glowFor(o,s?r.mesh.position.distanceTo(s):0),u=new se(o.color).lerp(new se(o.tipColor??o.color),.5);r.shine(h.radiusM,this.throughAir(ct.shown([u.r,u.g,u.b],h.luminanceCdM2,n),this.scratch)),this.raiseDust(e.id,o,i)}raiseDust(e,t,i){const n=this.frame;if(!t.raisesDust||!n?.groundYAt){this.dust.get(e)?.set(0,0,0,i,{x:0,z:0},0);return}let s=this.dust.get(e);s||(s=new Yn(Yn.DUST),this.dust.set(e,s),this.group.add(s.points));const{x:r,y:o,z:c}=this.scratch,l=n.groundYAt(r,c),h=Math.max(0,Math.min(1,1-(o-l)/(t.lengthM+1)));s.set(r,l,c,i,n.wind??{x:0,z:0},h,n.light)}setSmoke(e,t){const i=this.frame;for(;this.smoke.length<e.length;){const n=new Yn(Yn.SMOKE);this.smoke.push(n),this.group.add(n.points)}this.smoke.forEach((n,s)=>{const r=e[s],o=t*1e3;if(!(r!==void 0&&i!==void 0&&o>=r.fromT&&(r.untilT===void 0||o<r.untilT))){n.set(0,0,0,t,{x:0,z:0},0);return}const l=i.originX+r.eastM,h=i.originZ-r.northM,u=(o-r.fromT)/1e3,d=Math.min(1,u/2)*(.1+.9*Math.pow(2,-u/(r.halfLifeS??20)));n.set(l,i.groundYAt?i.groundYAt(l,h):i.originGroundY,h,t,i.wind??{x:0,z:0},d,i.light)})}static luminousIntensityCd(e){return e.luminanceCdM2*.7*e.widthM*e.lengthM}static lightColourOf(e){const t=new se(e.color),i=new se(e.tipColor??e.color),n=[(t.r+i.r)/2,(t.g+i.g)/2,(t.b+i.b)/2],s=.2126*n[0]+.7152*n[1]+.0722*n[2];return s>0?[n[0]/s,n[1]/s,n[2]/s]:[1,1,1]}static pointing(e,t,i){return t.set(0,-1,0).transformDirection(e.matrixWorld).normalize(),i.setFromUnitVectors(ct.DOWN,t)}static DOWN=new D(0,-1,0);static EXHAUST_NODE="exhaust";dropGlare(e){const t=this.glares.get(e);t&&(this.group.remove(t.mesh),t.dispose(),this.glares.delete(e))}dropFlame(e){const t=this.flames.get(e);if(!t)return;t.mesh.removeFromParent(),t.light.removeFromParent(),t.glow.removeFromParent(),t.dispose(),this.flames.delete(e);const i=this.dust.get(e);i&&(i.points.removeFromParent(),i.dispose(),this.dust.delete(e))}outlineOf(e,t){const i=this.built.get(e)?.holder,n=this.frame,s=i?.getObjectByName(t);if(!i||!n||!s)return;i.updateMatrixWorld(!0);const r=[];return s.traverse(o=>{if(!(o instanceof De))return;const c=o.geometry.getAttribute("position"),l=Math.max(1,Math.floor(c.count/400));for(let h=0;h<c.count;h+=l)this.scratch.fromBufferAttribute(c,h).applyMatrix4(o.matrixWorld),r.push({eastM:this.scratch.x-n.originX,northM:n.originZ-this.scratch.z,upM:this.scratch.y-n.originGroundY})}),r.length>0?r:void 0}furthestFrom(e){let t=0;for(const{holder:i}of this.built.values())i.visible&&(t=Math.max(t,i.position.distanceTo(e)));return t}get reflectors(){return[...this.built.entries()].filter(([,{holder:e}])=>e.visible).map(([e,{holder:t}])=>({id:e,holder:t,shiny:ct.isShiny(t)}))}static isShiny(e){let t=!1;return e.traverse(i=>{const n=i.material;for(const s of Array.isArray(n)?n:[n])(s instanceof Eo||s instanceof oa&&(s.roughness<ct.SHINY_ROUGHNESS||s.metalness>ct.SHINY_METALNESS))&&(t=!0)}),t}static SHINY_ROUGHNESS=.6;static SHINY_METALNESS=.3;get any(){return[...this.built.values()].some(({holder:e})=>e.visible)}clear(){this.token++;for(const e of[...this.built.keys()])this.remove(e)}build(e){const t=new Dt;t.name=`body:${e.id}`;const i=ct.signatureOf(e.model),n=ct.primitiveOf(e.model);if(n==="figure"){const c=new oa({roughness:.7,metalness:0});ct.paint(c,e);const l=gi.build({id:e.id,kind:"entity",eastM:0,northM:0},!1);return l.traverse(h=>{h instanceof De&&(h.material=c,h.castShadow=!0,h.receiveShadow=!0)}),t.add(ct.fit(l,0)),{holder:t,signature:i,material:c}}if(n){const c=new oa({roughness:.45,metalness:0});ct.paint(c,e);const l=new De(ct.unitGeometry(n),c);return l.castShadow=!0,l.receiveShadow=!0,t.add(l),{holder:t,signature:i,material:c}}const s=new oa({roughness:.45,metalness:0});ct.paint(s,e);const r=new De(ct.unitGeometry("ellipsoid"),s);r.castShadow=!0,r.receiveShadow=!0,t.add(r);const o=this.token;return this.loadModel(e.model).then(c=>{if(!c||o!==this.token||this.built.get(e.id)?.holder!==t)return;t.remove(r),r.geometry.dispose(),s.dispose(),ct.glaze(c.scene),t.add(ct.fit(c.scene,c.headingOffsetDeg??e.model.headingOffsetDeg??0)),this.credits.set(e.id,c.credit);const l=this.built.get(e.id);l&&(l.material=void 0,l.glowing=ct.glowingOf(c.scene)),this.onModelArrived()}).catch(c=>console.warn(`Keeping the ellipsoid for body "${e.id}":`,c)),{holder:t,signature:i,material:s}}static fit(e,t){const i=new Dt;e.rotation.y=-t*bc,i.add(e),i.updateMatrixWorld(!0);const n=new vn().setFromObject(i),s=n.getSize(new D),r=n.getCenter(new D),o=new Dt;return i.position.sub(r),o.add(i),o.scale.set(1/Math.max(s.x,1e-6),1/Math.max(s.y,1e-6),1/Math.max(s.z,1e-6)),e.traverse(c=>{c instanceof De&&(c.castShadow=!0,c.receiveShadow=!0)}),o}static paint(e,t,i){const n=new se(t.appearance.color),s=.2126*n.r+.7152*n.g+.0722*n.b;s>0&&n.multiplyScalar(t.appearance.albedo/s),n.r=Math.min(1,n.r),n.g=Math.min(1,n.g),n.b=Math.min(1,n.b),e.color.equals(n)||e.color.copy(n);const r=new se(t.appearance.color),o=Math.max(r.r,r.g,r.b);ct.glow(e,o>0?[r.r/o,r.g/o,r.b/o]:[1,1,1],t.appearance.luminanceCdM2,i)}static light(e,t,i){for(const{material:n,hue:s,share:r}of e)ct.glow(n,s,t.appearance.luminanceCdM2*r,i)}static glow(e,t,i,n){if(!(i>0)){(e.emissive.r!==0||e.emissive.g!==0||e.emissive.b!==0)&&e.emissive.setRGB(0,0,0);return}const s=ct.shown(t,i,n);e.emissive.setRGB(s[0],s[1],s[2])}static shown(e,t,i){return Tn.shown(e,t,i)}static glowingOf(e){const t=[],i=new Set;e.traverse(r=>{if(r instanceof De)for(const o of Array.isArray(r.material)?r.material:[r.material])!(o instanceof oa)||i.has(o)||(i.add(o),Math.max(o.emissive.r,o.emissive.g,o.emissive.b)>0&&t.push(o))});const n=r=>Math.max(r.emissive.r,r.emissive.g,r.emissive.b),s=Math.max(...t.map(n),0);return s<=0?[]:t.map(r=>({material:r,hue:[r.emissive.r,r.emissive.g,r.emissive.b],share:n(r)/s}))}static primitiveOf(e){return e.url===void 0&&p1.includes(e.id??"")?e.id:void 0}static signatureOf(e){return`${e.id??""}|${e.url??""}`}static unitGeometry(e){let t;switch(e){case"ellipsoid":case"sphere":t=new jt(.5,48,24);break;case"disc":{const r=[];for(let c=0;c<=24;c++){const l=.5*Math.sin(c/24*Math.PI),h=.5*Math.cos(c/24*Math.PI);r.push(new xe(l,Math.sign(h)*h*h*2))}t=new _l(r.reverse(),64);break}case"cylinder":t=new es(.5,.5,1,48);break;case"cone":t=new _r(.5,1,48);break;case"box":t=new sn(1,1,1);break;case"torus":t=new qd(.35,.15,24,64),t.rotateX(Math.PI/2);break;case"figure":t=new jt(.5,24,12);break}t.computeBoundingBox();const i=t.boundingBox,n=i.getSize(new D),s=i.getCenter(new D);return t.translate(-s.x,-s.y,-s.z),t.scale(1/n.x,1/n.y,1/n.z),t.computeVertexNormals(),t}remove(e){const t=this.built.get(e);t&&(t.holder.removeFromParent(),t.holder.traverse(i=>{if(!(i instanceof De))return;i.geometry.dispose();const n=Array.isArray(i.material)?i.material:[i.material];for(const s of n)s.dispose()}),this.built.delete(e),this.credits.delete(e),this.dropFlame(e),this.dropGlare(e))}}const m1=2,Zw=5,Jw=2048;class wn{constructor(e){this.scene=e}cloudLayers=[];cloudSignature="";setCloudLayers(e){const t=e.map(i=>i.mesh.uuid).join(",");if(t!==this.cloudSignature){this.cloudSignature=t,this.cloudLayers=e;for(const i of this.meshes.values())this.configureCloudMaterial(i.material)}}configureCloudMaterial(e){const t=this.cloudLayers,i=this.cloudSignature;e.customProgramCacheKey=()=>i,e.onBeforeCompile=n=>{if(!t.length)return;n.vertexShader=`varying vec3 cloudPoint;
|
|
6525
|
+
`,transparent:!0,depthWrite:!1,side:tn,fog:!1,blending:Ml,blendSrc:go,blendDst:vo})}static wallReflectance(e,t,i){const n=i(e,1,t);return 2*n/(1+n)}setSurroundings(e){this.uniforms.uSurroundings.value=e}static reflectedResponse(e,t){return Ee.respond(t*Ee.relativeOfResponse(Math.max(e,1e-5)))}}const bc=Math.PI/180;class ct{constructor(e,t,i=()=>0){this.loadModel=e,this.onModelArrived=t,this.sceneUnitsPerLux=i,this.group.name="bodies"}group=new Dt;built=new Map;token=0;credits=new Map;flames=new Map;glares=new Map;dust=new Map;smoke=[];scratch=new D;aim=new Qn;down=new D;frame;get modelCredits(){return[...this.credits.values()]}set(e,t,i=0,n,s=e.map(r=>r.id)){this.frame=t;const r=new Set;for(const c of e){r.add(c.id);const l=ct.signatureOf(c.model);let h=this.built.get(c.id);(!h||h.signature!==l)&&(h&&this.remove(c.id),h=this.build(c),this.built.set(c.id,h),this.group.add(h.holder));const{holder:u,material:d,glowing:f}=h;u.visible=!0,u.position.set(t.originX+c.eastM,t.originGroundY+c.upM,t.originZ-c.northM),u.rotation.set(c.attitude.pitchDeg*bc,-c.attitude.headingDeg*bc,-c.attitude.rollDeg*bc,"YXZ"),u.scale.set(c.sizeM.widthM,c.sizeM.heightM,c.sizeM.lengthM),d&&ct.paint(d,c,n),f&&ct.light(f,c,n),this.shine(c,u,f,n,t.eye),this.throwFlame(c,u,i,n,t.eye)}const o=new Set(s);for(const[c,{holder:l}]of[...this.built])r.has(c)||(o.has(c)?(l.visible=!1,this.flames.get(c)?.putOut(),this.glares.get(c)?.hide()):this.remove(c))}shine(e,t,i,n,s){const r=e.appearance.luminanceCdM2;let o=this.glares.get(e.id);if(!(r>0)||!s||i&&i.length>0){o?.hide();return}o||(o=new Ui(`body-veil:${e.id}`),this.glares.set(e.id,o),this.group.add(o.mesh));const c=Math.max(e.sizeM.widthM,e.sizeM.heightM)/2,l=Math.max(t.position.distanceTo(s),c*1.01),h=Math.asin(c/l),u=2*Math.PI*(1-Math.cos(h)),d=i?.find(p=>p.share>=1)?.hue??ct.rgbOf(e.appearance.color),f=this.throughAir(ct.shown(d,r,n),t.position);o.shine(t.position,[f[0]*u,f[1]*u,f[2]*u],h*180/Math.PI)}static glaze(e){e.traverse(t=>{if(!(t instanceof De))return;const i=t.material;!(i instanceof hM)||!(i.transmission>0)||(t.material=new Eo(i.ior),i.dispose(),t.castShadow=!1)})}throughAir(e,t){const i=this.frame?.transmittance?.(t.x,t.y,t.z)??[1,1,1];return[e[0]*i[0],e[1]*i[1],e[2]*i[2]]}static rgbOf(e){const t=new se(e);return[t.r,t.g,t.b]}throwFlame(e,t,i,n,s){let r=this.flames.get(e.id);if(!r&&e.throwsFlame&&(r=new ga,this.flames.set(e.id,r),this.group.add(r.mesh,r.light,r.glow)),!r)return;const o=e.flame;if(!o){r.putOut(),this.dust.get(e.id)?.set(0,0,0,i,{x:0,z:0},0);return}t.updateMatrixWorld(!0);const c=t.getObjectByName(o.node??ct.EXHAUST_NODE);c?c.getWorldPosition(this.scratch):t.localToWorld(this.scratch.set(0,-.5,0)),r.place(this.scratch,c?ct.pointing(c,this.down,this.aim):t.quaternion,o.lengthM,o.widthM);const l=d=>{const f=new se(d);return this.throughAir(ct.shown([f.r,f.g,f.b],o.luminanceCdM2,n),this.scratch)};r.set(l(o.color),l(o.tipColor??o.color),i),r.illuminate(ct.luminousIntensityCd(o)*this.sceneUnitsPerLux(),ct.lightColourOf(o));const h=ga.glowFor(o,s?r.mesh.position.distanceTo(s):0),u=new se(o.color).lerp(new se(o.tipColor??o.color),.5);r.shine(h.radiusM,this.throughAir(ct.shown([u.r,u.g,u.b],h.luminanceCdM2,n),this.scratch)),this.raiseDust(e.id,o,i)}raiseDust(e,t,i){const n=this.frame;if(!t.raisesDust||!n?.groundYAt){this.dust.get(e)?.set(0,0,0,i,{x:0,z:0},0);return}let s=this.dust.get(e);s||(s=new Yn(Yn.DUST),this.dust.set(e,s),this.group.add(s.points));const{x:r,y:o,z:c}=this.scratch,l=n.groundYAt(r,c),h=Math.max(0,Math.min(1,1-(o-l)/(t.lengthM+1)));s.set(r,l,c,i,n.wind??{x:0,z:0},h,n.light)}setSmoke(e,t){const i=this.frame;for(;this.smoke.length<e.length;){const n=new Yn(Yn.SMOKE);this.smoke.push(n),this.group.add(n.points)}this.smoke.forEach((n,s)=>{const r=e[s],o=t*1e3;if(!(r!==void 0&&i!==void 0&&o>=r.fromT&&(r.untilT===void 0||o<r.untilT))){n.set(0,0,0,t,{x:0,z:0},0);return}const l=i.originX+r.eastM,h=i.originZ-r.northM,u=(o-r.fromT)/1e3,d=Math.min(1,u/2)*(.1+.9*Math.pow(2,-u/(r.halfLifeS??20)));n.set(l,i.groundYAt?i.groundYAt(l,h):i.originGroundY,h,t,i.wind??{x:0,z:0},d,i.light)})}static luminousIntensityCd(e){return e.luminanceCdM2*.7*e.widthM*e.lengthM}static lightColourOf(e){const t=new se(e.color),i=new se(e.tipColor??e.color),n=[(t.r+i.r)/2,(t.g+i.g)/2,(t.b+i.b)/2],s=.2126*n[0]+.7152*n[1]+.0722*n[2];return s>0?[n[0]/s,n[1]/s,n[2]/s]:[1,1,1]}static pointing(e,t,i){return t.set(0,-1,0).transformDirection(e.matrixWorld).normalize(),i.setFromUnitVectors(ct.DOWN,t)}static DOWN=new D(0,-1,0);static EXHAUST_NODE="exhaust";dropGlare(e){const t=this.glares.get(e);t&&(this.group.remove(t.mesh),t.dispose(),this.glares.delete(e))}dropFlame(e){const t=this.flames.get(e);if(!t)return;t.mesh.removeFromParent(),t.light.removeFromParent(),t.glow.removeFromParent(),t.dispose(),this.flames.delete(e);const i=this.dust.get(e);i&&(i.points.removeFromParent(),i.dispose(),this.dust.delete(e))}outlineOf(e,t){const i=this.built.get(e)?.holder,n=this.frame,s=i?.getObjectByName(t);if(!i||!n||!s)return;i.updateMatrixWorld(!0);const r=[];return s.traverse(o=>{if(!(o instanceof De))return;const c=o.geometry.getAttribute("position"),l=Math.max(1,Math.floor(c.count/400));for(let h=0;h<c.count;h+=l)this.scratch.fromBufferAttribute(c,h).applyMatrix4(o.matrixWorld),r.push({eastM:this.scratch.x-n.originX,northM:n.originZ-this.scratch.z,upM:this.scratch.y-n.originGroundY})}),r.length>0?r:void 0}furthestFrom(e){let t=0;for(const{holder:i}of this.built.values())i.visible&&(t=Math.max(t,i.position.distanceTo(e)));return t}get reflectors(){return[...this.built.entries()].filter(([,{holder:e}])=>e.visible).map(([e,{holder:t}])=>({id:e,holder:t,shiny:ct.isShiny(t)}))}static isShiny(e){let t=!1;return e.traverse(i=>{const n=i.material;for(const s of Array.isArray(n)?n:[n])(s instanceof Eo||s instanceof oa&&(s.roughness<ct.SHINY_ROUGHNESS||s.metalness>ct.SHINY_METALNESS))&&(t=!0)}),t}static SHINY_ROUGHNESS=.6;static SHINY_METALNESS=.3;get any(){return[...this.built.values()].some(({holder:e})=>e.visible)}clear(){this.token++;for(const e of[...this.built.keys()])this.remove(e)}build(e){const t=new Dt;t.name=`body:${e.id}`;const i=ct.signatureOf(e.model),n=ct.primitiveOf(e.model);if(n==="figure"){const c=new oa({roughness:.7,metalness:0});ct.paint(c,e);const l=vi.build({id:e.id,kind:"entity",eastM:0,northM:0},!1);return l.traverse(h=>{h instanceof De&&(h.material=c,h.castShadow=!0,h.receiveShadow=!0)}),t.add(ct.fit(l,0)),{holder:t,signature:i,material:c}}if(n){const c=new oa({roughness:.45,metalness:0});ct.paint(c,e);const l=new De(ct.unitGeometry(n),c);return l.castShadow=!0,l.receiveShadow=!0,t.add(l),{holder:t,signature:i,material:c}}const s=new oa({roughness:.45,metalness:0});ct.paint(s,e);const r=new De(ct.unitGeometry("ellipsoid"),s);r.castShadow=!0,r.receiveShadow=!0,t.add(r);const o=this.token;return this.loadModel(e.model).then(c=>{if(!c||o!==this.token||this.built.get(e.id)?.holder!==t)return;t.remove(r),r.geometry.dispose(),s.dispose(),ct.glaze(c.scene),t.add(ct.fit(c.scene,c.headingOffsetDeg??e.model.headingOffsetDeg??0)),this.credits.set(e.id,c.credit);const l=this.built.get(e.id);l&&(l.material=void 0,l.glowing=ct.glowingOf(c.scene)),this.onModelArrived()}).catch(c=>console.warn(`Keeping the ellipsoid for body "${e.id}":`,c)),{holder:t,signature:i,material:s}}static fit(e,t){const i=new Dt;e.rotation.y=-t*bc,i.add(e),i.updateMatrixWorld(!0);const n=new vn().setFromObject(i),s=n.getSize(new D),r=n.getCenter(new D),o=new Dt;return i.position.sub(r),o.add(i),o.scale.set(1/Math.max(s.x,1e-6),1/Math.max(s.y,1e-6),1/Math.max(s.z,1e-6)),e.traverse(c=>{c instanceof De&&(c.castShadow=!0,c.receiveShadow=!0)}),o}static paint(e,t,i){const n=new se(t.appearance.color),s=.2126*n.r+.7152*n.g+.0722*n.b;s>0&&n.multiplyScalar(t.appearance.albedo/s),n.r=Math.min(1,n.r),n.g=Math.min(1,n.g),n.b=Math.min(1,n.b),e.color.equals(n)||e.color.copy(n);const r=new se(t.appearance.color),o=Math.max(r.r,r.g,r.b);ct.glow(e,o>0?[r.r/o,r.g/o,r.b/o]:[1,1,1],t.appearance.luminanceCdM2,i)}static light(e,t,i){for(const{material:n,hue:s,share:r}of e)ct.glow(n,s,t.appearance.luminanceCdM2*r,i)}static glow(e,t,i,n){if(!(i>0)){(e.emissive.r!==0||e.emissive.g!==0||e.emissive.b!==0)&&e.emissive.setRGB(0,0,0);return}const s=ct.shown(t,i,n);e.emissive.setRGB(s[0],s[1],s[2])}static shown(e,t,i){return Tn.shown(e,t,i)}static glowingOf(e){const t=[],i=new Set;e.traverse(r=>{if(r instanceof De)for(const o of Array.isArray(r.material)?r.material:[r.material])!(o instanceof oa)||i.has(o)||(i.add(o),Math.max(o.emissive.r,o.emissive.g,o.emissive.b)>0&&t.push(o))});const n=r=>Math.max(r.emissive.r,r.emissive.g,r.emissive.b),s=Math.max(...t.map(n),0);return s<=0?[]:t.map(r=>({material:r,hue:[r.emissive.r,r.emissive.g,r.emissive.b],share:n(r)/s}))}static primitiveOf(e){return e.url===void 0&&p1.includes(e.id??"")?e.id:void 0}static signatureOf(e){return`${e.id??""}|${e.url??""}`}static unitGeometry(e){let t;switch(e){case"ellipsoid":case"sphere":t=new Qt(.5,48,24);break;case"disc":{const r=[];for(let c=0;c<=24;c++){const l=.5*Math.sin(c/24*Math.PI),h=.5*Math.cos(c/24*Math.PI);r.push(new xe(l,Math.sign(h)*h*h*2))}t=new _l(r.reverse(),64);break}case"cylinder":t=new es(.5,.5,1,48);break;case"cone":t=new _r(.5,1,48);break;case"box":t=new sn(1,1,1);break;case"torus":t=new qd(.35,.15,24,64),t.rotateX(Math.PI/2);break;case"figure":t=new Qt(.5,24,12);break}t.computeBoundingBox();const i=t.boundingBox,n=i.getSize(new D),s=i.getCenter(new D);return t.translate(-s.x,-s.y,-s.z),t.scale(1/n.x,1/n.y,1/n.z),t.computeVertexNormals(),t}remove(e){const t=this.built.get(e);t&&(t.holder.removeFromParent(),t.holder.traverse(i=>{if(!(i instanceof De))return;i.geometry.dispose();const n=Array.isArray(i.material)?i.material:[i.material];for(const s of n)s.dispose()}),this.built.delete(e),this.credits.delete(e),this.dropFlame(e),this.dropGlare(e))}}const m1=2,Zw=5,Jw=2048;class wn{constructor(e){this.scene=e}cloudLayers=[];cloudSignature="";setCloudLayers(e){const t=e.map(i=>i.mesh.uuid).join(",");if(t!==this.cloudSignature){this.cloudSignature=t,this.cloudLayers=e;for(const i of this.meshes.values())this.configureCloudMaterial(i.material)}}configureCloudMaterial(e){const t=this.cloudLayers,i=this.cloudSignature;e.customProgramCacheKey=()=>i,e.onBeforeCompile=n=>{if(!t.length)return;n.vertexShader=`varying vec3 cloudPoint;
|
|
6518
6526
|
`+n.vertexShader,n.vertexShader=n.vertexShader.replace("#include <project_vertex>",`#include <project_vertex>
|
|
6519
6527
|
cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let s=`varying vec3 cloudPoint;
|
|
6520
6528
|
`,r="";t.forEach((o,c)=>{const l=`cloud${c}_`;for(const[h,u]of Object.entries(o.uniforms))n.uniforms[l+h]=u;s+=BS(l),r+=`diffuseColor.a *= ${l}transmissionAt(normalize(cloudPoint), length(cloudPoint));
|
|
6521
|
-
`}),n.fragmentShader=s+n.fragmentShader,n.fragmentShader=n.fragmentShader.replace("#include <opaque_fragment>",r+"#include <opaque_fragment>")},e.needsUpdate=!0}meshes=new Map;signatures=new Map;extents=new Map;placed=[];frame;direction=new D;up=new D;lookAt=new Ze;vertex=new D;centre=new D;right=new D;above=new D;set(e,t){this.placed=e,this.frame=t;const i=new Set(e.map(n=>n.sourceId));for(const[n,s]of this.meshes)i.has(n)||(this.dispose(s),this.meshes.delete(n),this.signatures.delete(n),this.extents.delete(n));for(const n of e){let s=this.meshes.get(n.sourceId);s||(s=new De(new ki(1,1,wn.SEGMENTS,wn.SEGMENTS),new mn({transparent:!0,depthWrite:!1,depthTest:!0,fog:!1,toneMapped:!1})),this.configureCloudMaterial(s.material),s.frustumCulled=!1,s.layers.set(m1),this.scene.add(s),this.meshes.set(n.sourceId,s)),s.renderOrder=Zw+n.renderOrder,s.visible=!n.hidden&&n.shape.transparency<1,s.visible&&this.paint(s,n,t)}}place(e,t,i){const n=this.frame;if(n)for(const s of this.placed){const r=this.meshes.get(s.sourceId);if(!r||!r.visible)continue;const o=this.extents.get(s.sourceId);if(!o)continue;const{bounds:c}=s.shape;let l=c.x+c.width/2,h=c.y+c.height/2,u=!0;if(s.aim){const d=i(wn.directionOf(s.aim,this.direction));d&&Math.abs(d.ndcX)<wn.FURTHEST_NDC&&Math.abs(d.ndcY)<wn.FURTHEST_NDC?(l=(d.ndcX+1)/2*n.canvasWidthPx,h=(1-d.ndcY)/2*n.canvasHeightPx):u=!1}u?this.curve(r,e,t,n,o,l,h,s.distanceM):this.flat(r,e,n,o,s.distanceM)}}static FURTHEST_NDC=4;curve(e,t,i,n,s,r,o,c){const l=r-s.width/2,h=o-s.height/2,u=e.geometry.attributes.position,d=wn.SEGMENTS;let f=0;for(let p=0;p<=d;p++){const v=h+p/d*s.height;for(let m=0;m<=d;m++){const g=l+m/d*s.width;i(g/n.canvasWidthPx*2-1,-(v/n.canvasHeightPx*2-1),this.direction),this.vertex.copy(t.position).addScaledVector(this.direction,c),u.setXYZ(f++,this.vertex.x,this.vertex.y,this.vertex.z)}}u.needsUpdate=!0,e.matrixAutoUpdate=!1,e.matrix.identity(),e.matrixWorldNeedsUpdate=!0,e.scale.set(Rt.sizeMAt(c,n.projection.pxToDeg(s.width)),Rt.sizeMAt(c,n.projection.pxToDeg(s.height)),1)}flat(e,t,i,n,s){const r=e.geometry.attributes.position,o=wn.SEGMENTS,c=Rt.sizeMAt(s,i.projection.pxToDeg(n.width)),l=Rt.sizeMAt(s,i.projection.pxToDeg(n.height));this.up.set(0,1,0).applyQuaternion(t.quaternion),this.centre.copy(t.position).addScaledVector(this.direction,s),this.lookAt.lookAt(t.position,this.centre,this.up),this.right.setFromMatrixColumn(this.lookAt,0),this.above.setFromMatrixColumn(this.lookAt,1);let h=0;for(let u=0;u<=o;u++){const d=.5-u/o;for(let f=0;f<=o;f++){const p=f/o-.5;this.vertex.copy(this.centre).addScaledVector(this.right,p*c).addScaledVector(this.above,d*l),r.setXYZ(h++,this.vertex.x,this.vertex.y,this.vertex.z)}}r.needsUpdate=!0,e.matrixAutoUpdate=!1,e.matrix.identity(),e.matrixWorldNeedsUpdate=!0,e.scale.set(c,l,1)}static SEGMENTS=16;static directionOf(e,t){const i=e.azimuthDeg*Math.PI/180,n=e.altitudeDeg*Math.PI/180;return t.set(Math.sin(i)*Math.cos(n),Math.sin(n),-Math.cos(i)*Math.cos(n))}get any(){for(const e of this.meshes.values())if(e.visible)return!0;return!1}get furthestM(){return this.placed.reduce((e,t)=>Math.max(e,t.distanceM),0)}paint(e,t,i){const{shape:n}=t,s=mo.paintExtent(n),r=t.ghost?3:0,o={x:s.x-r,y:s.y-r,width:s.width+2*r,height:s.height+2*r};this.extents.set(t.sourceId,o);const c=`${wn.signatureOf(n,i)}|${t.ghost?"ghost":""}`;if(this.signatures.get(t.sourceId)===c&&e.material.map)return;this.signatures.set(t.sourceId,c);const l=Math.min(i.scale,Jw/Math.max(o.width,o.height,1)),h=Math.max(1,Math.ceil(o.width*l)),u=Math.max(1,Math.ceil(o.height*l)),d=e.material.map,f=d?.image??document.createElement("canvas"),p=f.width!==h||f.height!==u;p&&(f.width=h,f.height=u);const v=f.getContext("2d");if(!v)return;v.clearRect(0,0,h,u);const m=new mo(v);if(m.setStarPoints(i.starPoints),m.setRoll(i.rollRad),m.paintInto(n,o,l,t.ghost),d&&!p){d.needsUpdate=!0;return}d?.dispose();const g=new Ss(f);g.colorSpace=Fi,g.minFilter=st,g.generateMipmaps=!1,e.material.map=g,e.material.needsUpdate=!0}static signatureOf(e,t){const{bounds:i}=e;return JSON.stringify([e.kind,Math.round(i.width*10),Math.round(i.height*10),e.color,e.angle,e.transparency,e.haloScale,e.blur??0,e.brightness??0,e.kind==="polygon"?e.points:void 0,t.scale,t.starPoints,t.rollRad])}dispose(e){e.removeFromParent(),e.geometry.dispose(),e.material.map?.dispose(),e.material.dispose()}clear(){for(const e of this.meshes.values())this.dispose(e);this.meshes.clear(),this.signatures.clear(),this.extents.clear(),this.placed=[]}}const g1=3,Ec=800,Xr=Math.PI/180;class ua{constructor(e,t,i=ua.fetchImage){this.scene=e,this.onImageLoaded=t,this.loadImage=i}meshes=new Map;signatures=new Map;images=new Map;loading=new Map;failed=new Set;references=[];views=new Map;shown=!0;set(e,t=this.views){this.references=e,this.views=t;const i=new Set(e.map(n=>n.id));for(const[n,s]of this.meshes)i.has(n)||(this.dispose(s),this.meshes.delete(n),this.signatures.delete(n));for(const[n,s]of this.images){const r=e.find(o=>o.id===n);r&&r.src===s.texture.userData.src||(s.texture.dispose(),this.images.delete(n))}for(const n of e){const s=this.images.get(n.id);if(!s){this.load(n);continue}this.build(n,s)}}setShown(e){this.shown=e;for(const t of this.meshes.values())t.visible=e&&this.opacityOf(t.userData.id)>0}setView(e,t){this.views.set(e,t);const i=this.meshes.get(e);i&&this.applyOpacity(i,e)}get any(){for(const e of this.meshes.values())if(e.visible)return!0;return!1}place(e){for(const t of this.meshes.values())t.visible&&(t.position.copy(e.position),t.updateMatrixWorld())}get furthestM(){return this.meshes.size>0?Ec:0}directionOfPixel(e,t,i,n){const s=this.images.get(e.id),r=s?s.width/s.height:1,o=Math.tan(e.registration.fovDeg/2*Xr),c=o*r;return n.set((t*2-1)*c,(1-i*2)*o,-1).normalize(),n.applyQuaternion(ua.orientation(e))}aspectOf(e){const t=this.images.get(e);return t?t.width/t.height:void 0}failedToLoad(e){return this.failed.has(e)}load(e){const t=e.src;if(this.loading.has(e.id)||this.failed.has(t))return;const i=this.loadImage(t).then(n=>{this.loading.delete(e.id);const s=this.references.find(r=>r.id===e.id);if(!s||s.src!==t){n.texture.dispose();return}n.texture.userData.src=t,this.images.set(e.id,n),this.build(s,n),this.onImageLoaded()},()=>{this.loading.delete(e.id),this.failed.add(t)});this.loading.set(e.id,i)}static async fetchImage(e){const t=await fetch(e);if(!t.ok)throw new Error(`${e}: ${t.status}`);const i=await createImageBitmap(await t.blob(),{imageOrientation:"flipY"}),n=new Mi(i);return n.flipY=!1,n.colorSpace=Fi,n.minFilter=st,n.magFilter=st,n.generateMipmaps=!1,n.needsUpdate=!0,{texture:n,width:i.width,height:i.height}}build(e,t){const i=ua.signatureOf(e,t);let n=this.meshes.get(e.id);if(n&&this.signatures.get(e.id)===i){this.applyOpacity(n,e.id);return}n&&(this.dispose(n),this.meshes.delete(e.id)),n=new De(ua.geometryOf(e,t),new mn({map:t.texture,transparent:!0,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1})),e.kind==="panorama"&&(n.material.side=Ot),n.frustumCulled=!1,n.layers.set(g1),n.userData.id=e.id,n.quaternion.copy(ua.orientation(e)),this.scene.add(n),this.meshes.set(e.id,n),this.signatures.set(e.id,i),this.applyOpacity(n,e.id)}static geometryOf(e,t){if(e.kind==="panorama"){const r=new jt(Ec,64,32,Math.PI/2,Math.PI*2),o=r.attributes.uv;for(let c=0;c<o.count;c++)o.setX(c,1-o.getX(c));return o.needsUpdate=!0,r}const i=2*Ec*Math.tan(e.registration.fovDeg/2*Xr),n=i*(t.width/Math.max(t.height,1)),s=new ki(n,i);return s.translate(0,0,-Ec),s}static orientation(e){const{headingDeg:t,pitchDeg:i,rollDeg:n}=e.registration,s=new Pt;return s.rotation.set(i*Xr,-t*Xr,-(n??0)*Xr,"YXZ"),s.quaternion}opacityOf(e){const t=this.references.find(n=>n.id===e);return this.views.get(e)?.opacity??t?.opacity??0}applyOpacity(e,t){const i=this.opacityOf(t);e.material.opacity=i,e.visible=this.shown&&i>0}static signatureOf(e,t){const{headingDeg:i,pitchDeg:n,rollDeg:s,fovDeg:r}=e.registration;return[e.kind,e.src,t.width,t.height,i,n,s??0,r].join("|")}dispose(e){this.scene.remove(e),e.geometry.dispose(),e.material.dispose()}disposeAll(){for(const e of this.meshes.values())this.dispose(e);this.meshes.clear(),this.signatures.clear();for(const e of this.images.values())e.texture.dispose();this.images.clear()}}class Oe{static GROUND_RADIUS_M=636e4;static TOP_RADIUS_M=646e4;static WAVELENGTHS_NM=Array.from({length:15},(e,t)=>410+20*t);static WAVELENGTH_STEP_NM=20;static SOLAR_IRRADIANCE=[1.707,1.676,1.982,2.02,1.941,1.87,1.879,1.856,1.839,1.799,1.728,1.668,1.57,1.532,1.452];static OZONE_CROSS_SECTION=[.021,.069,.19,.418,.827,1.531,2.439,3.291,4.468,4.55,4.663,3.477,2.447,1.658,1.071];static RAYLEIGH_SCALE_HEIGHT_M=8e3;static AEROSOL_SCALE_HEIGHT_M=1200;static OZONE_PEAK_ALTITUDE_M=25e3;static OZONE_HALF_WIDTH_M=15e3;static DEFAULT_AEROSOL_OPTICAL_DEPTH=.1;static DEFAULT_OZONE_DOBSON=300;static AEROSOL_SINGLE_SCATTERING_ALBEDO=.9;static AEROSOL_ANGSTROM_EXPONENT=1.3;static AEROSOL_ASYMMETRY=.8;rayleighScattering;aerosolScattering;aerosolExtinction;ozoneAbsorption;constructor(e={}){const t=Oe.WAVELENGTHS_NM.length,i=e.aerosolOpticalDepth??Oe.DEFAULT_AEROSOL_OPTICAL_DEPTH,n=e.ozoneDobson??Oe.DEFAULT_OZONE_DOBSON;this.rayleighScattering=new Float64Array(t),this.aerosolScattering=new Float64Array(t),this.aerosolExtinction=new Float64Array(t),this.ozoneAbsorption=new Float64Array(t);const s=n*2687e17/Oe.OZONE_HALF_WIDTH_M;for(let r=0;r<t;r++){const o=Oe.WAVELENGTHS_NM[r];this.rayleighScattering[r]=Oe.rayleighAt(o);const c=i/Oe.AEROSOL_SCALE_HEIGHT_M*(o/550)**-1.3;this.aerosolExtinction[r]=c,this.aerosolScattering[r]=c*Oe.AEROSOL_SINGLE_SCATTERING_ALBEDO,this.ozoneAbsorption[r]=Oe.OZONE_CROSS_SECTION[r]*1e-25*s}}static rayleighAt(e){const t=e/1e3,i=1/(t*t),n=t*t;return(1.0455996-341.29061*i-.9023085*n)/(1+.0027059889*i-85.968563*n)*1e-28*1e-4*2546899e19}static rayleighDensity(e){return Math.exp(-Math.max(e,0)/Oe.RAYLEIGH_SCALE_HEIGHT_M)}static aerosolDensity(e){return Math.exp(-Math.max(e,0)/Oe.AEROSOL_SCALE_HEIGHT_M)}static ozoneDensity(e){return Math.max(0,1-Math.abs(e-Oe.OZONE_PEAK_ALTITUDE_M)/Oe.OZONE_HALF_WIDTH_M)}static rayleighPhase(e){return 3/(16*Math.PI)*(1+e*e)}static aerosolPhase(e,t=Oe.AEROSOL_ASYMMETRY){const i=t*t;return 3/(8*Math.PI)*(1-i)*(1+e*e)/((2+i)*Math.pow(Math.max(1+i-2*t*e,1e-6),1.5))}}class Ge{static TRANSMITTANCE_WIDTH=256;static TRANSMITTANCE_HEIGHT=64;static MULTIPLE_SIZE=64;static MULTIPLE_ROWS=16;static MULTIPLE_HEIGHT_POWER=2;static MULTIPLE_DIRECTIONS=16;static SKY_VIEW_WIDTH=192;static SKY_VIEW_HEIGHT=108;static STEPS=40;static MULTIPLE_STEPS=12;static GROUND_ALBEDO=.3;supported;renderer;transmittance;multiple;sunView;moonView;scene=new xs;camera=new Cn(-1,1,1,-1,0,1);quad;transmittanceMaterial;multipleMaterial;skyViewMaterial;transmittanceReady=!1;multipleRows=0;multipleColumn=0;mediumKey="";static MULTIPLE_BLOCK=16;static shared=new Map;building=!1;adopted;tableUniforms;constructor(e){this.renderer=e,this.supported=e.capabilities.isWebGL2&&e.extensions.has("EXT_color_buffer_float"),this.transmittance=new Jt(Ge.TRANSMITTANCE_WIDTH,Ge.TRANSMITTANCE_HEIGHT,{count:4,type:Ft,minFilter:st,magFilter:st,depthBuffer:!1}),this.multiple=new Jt(Ge.MULTIPLE_SIZE,Ge.MULTIPLE_ROWS,{count:4,type:Ri,minFilter:wt,magFilter:wt,depthBuffer:!1});const t=()=>new Jt(Ge.SKY_VIEW_WIDTH,Ge.SKY_VIEW_HEIGHT,{type:Ri,minFilter:wt,magFilter:wt,depthBuffer:!1});this.sunView=t(),this.moonView=t();const i=Ge.mediumUniforms(),n=this.tableUniforms={uT0:{value:this.transmittance.textures[0]},uT1:{value:this.transmittance.textures[1]},uT2:{value:this.transmittance.textures[2]},uT3:{value:this.transmittance.textures[3]},uM0:{value:this.multiple.textures[0]},uM1:{value:this.multiple.textures[1]},uM2:{value:this.multiple.textures[2]},uM3:{value:this.multiple.textures[3]}},s=(r,o={})=>new _g({glslVersion:tl,uniforms:{...i,...n,...o},vertexShader:Ge.VERTEX,fragmentShader:r,depthTest:!1,depthWrite:!1});this.transmittanceMaterial=s(Ge.TRANSMITTANCE_FRAGMENT),this.multipleMaterial=s(Ge.MULTIPLE_FRAGMENT),this.skyViewMaterial=s(Ge.SKY_VIEW_FRAGMENT,{uObserverRadius:{value:Oe.GROUND_RADIUS_M+2},uSourceMu:{value:1}}),this.quad=new De(new ki(2,2),this.transmittanceMaterial),this.quad.frustumCulled=!1,this.scene.add(this.quad)}get transmittanceTextures(){return this.transmittance.textures}get sunViewTexture(){return this.sunView.texture}get moonViewTexture(){return this.moonView.texture}get ready(){return this.supported&&(this.adopted!==void 0||this.transmittanceReady&&this.multipleRows>=Ge.MULTIPLE_ROWS)}setMedium(e){const t=[e.rayleighScattering,e.aerosolScattering,e.aerosolExtinction,e.ozoneAbsorption].map(n=>Array.from(n,s=>s.toPrecision(6)).join(",")).join("|");if(t===this.mediumKey)return;this.abandonBuilding(),this.releaseAdopted(),this.mediumKey=t;const i=(n,s)=>{const r=this.transmittanceMaterial.uniforms[n].value;for(let o=0;o<4;o++)r[o].set(s[o*4]??0,s[o*4+1]??0,s[o*4+2]??0,s[o*4+3]??0)};i("uRayleigh",e.rayleighScattering),i("uAerosolScattering",e.aerosolScattering),i("uAerosolExtinction",e.aerosolExtinction),i("uOzone",e.ozoneAbsorption),this.transmittanceReady=!1,this.multipleRows=0,this.multipleColumn=0}invalidate(){this.adopted||(this.abandonBuilding(),this.transmittanceReady=!1,this.multipleRows=0,this.multipleColumn=0)}advance(e){if(!this.supported||!this.mediumKey)return!1;if(this.ready)return!0;const t=Ge.shared.get(this.mediumKey);if(t&&t!=="building")return this.adopt(t),!0;if(t==="building"&&!this.building)return!1;t||(Ge.shared.set(this.mediumKey,"building"),this.building=!0);const i=this.renderer.getRenderTarget();let n=Math.max(1,e);this.transmittanceReady||(this.draw(this.transmittanceMaterial,this.transmittance),this.transmittanceReady=!0,n--);const s=Ge.MULTIPLE_SIZE,r=Ge.MULTIPLE_BLOCK;for(;n>0&&this.multipleRows<Ge.MULTIPLE_ROWS;n--)this.multiple.scissor.set(this.multipleColumn,this.multipleRows,r,1),this.multiple.scissorTest=!0,this.draw(this.multipleMaterial,this.multiple),this.multipleColumn+=r,this.multipleColumn>=s&&(this.multipleColumn=0,this.multipleRows++);return this.multiple.scissorTest=!1,this.renderer.setRenderTarget(i),this.ready&&this.building&&this.share(this.mediumKey),this.ready}async share(e){this.building=!1;try{const t=await Promise.all([0,1,2,3].map(n=>this.readRaw(this.transmittance,n,Uint16Array))),i=await Promise.all([0,1,2,3].map(n=>this.readRaw(this.multiple,n,Float32Array)));this.mediumKey===e?Ge.shared.set(e,{transmittance:t,multiple:i}):Ge.shared.delete(e)}catch{Ge.shared.delete(e)}}async readRaw(e,t,i){const n=new i(e.width*e.height*4);return await this.renderer.readRenderTargetPixelsAsync(e,0,0,e.width,e.height,n,void 0,t),n}adopt(e){const t=(s,r,o,c)=>{const l=new $s(s,r,o,yi,c?Ft:Ri);return l.minFilter=l.magFilter=c?st:wt,l.needsUpdate=!0,l},i=e.transmittance.map(s=>t(s,Ge.TRANSMITTANCE_WIDTH,Ge.TRANSMITTANCE_HEIGHT,!0)),n=e.multiple.map(s=>t(s,Ge.MULTIPLE_SIZE,Ge.MULTIPLE_ROWS,!1));i.forEach((s,r)=>this.tableUniforms[`uT${r}`].value=s),n.forEach((s,r)=>this.tableUniforms[`uM${r}`].value=s),this.adopted=[...i,...n]}releaseAdopted(){if(this.adopted){for(const e of this.adopted)e.dispose();this.adopted=void 0;for(let e=0;e<4;e++)this.tableUniforms[`uT${e}`].value=this.transmittance.textures[e],this.tableUniforms[`uM${e}`].value=this.multiple.textures[e]}}abandonBuilding(){this.building&&(this.building=!1,Ge.shared.get(this.mediumKey)==="building"&&Ge.shared.delete(this.mediumKey))}renderSkyViews(e,t,i){if(!this.ready)return;const n=this.renderer.getRenderTarget(),s=this.skyViewMaterial.uniforms;s.uObserverRadius.value=Oe.GROUND_RADIUS_M+Math.max(e,2),s.uSourceMu.value=Math.sin(t*Math.PI/180),this.draw(this.skyViewMaterial,this.sunView),s.uSourceMu.value=Math.sin(i*Math.PI/180),this.draw(this.skyViewMaterial,this.moonView),this.renderer.setRenderTarget(n)}static skyViewUv(e,t,i){const n=Oe.GROUND_RADIUS_M+Math.max(e,2),s=Oe.GROUND_RADIUS_M,r=Math.acos(Math.min(Math.sqrt(Math.max(n*n-s*s,0))/n,1)),o=Math.PI-r,c=t<o?.5*(1-Math.sqrt(Math.max(1-t/o,0))):.5+.5*Math.sqrt(Math.min((t-o)/r,1));return{u:Math.min(Math.max(Math.abs(i)/Math.PI,0),1),v:c}}async readTable(e,t){if(e==="multiple"){const s=new Float32Array(this.multiple.width*this.multiple.height*4);return await this.renderer.readRenderTargetPixelsAsync(this.multiple,0,0,this.multiple.width,this.multiple.height,s,void 0,t),s}const i=this.transmittance,n=new Uint16Array(i.width*i.height*4);return await this.renderer.readRenderTargetPixelsAsync(i,0,0,i.width,i.height,n,void 0,t),Float32Array.from(n,s=>Dn.fromHalfFloat(s))}readSkyViewNow(e){const t=e==="sun"?this.sunView:this.moonView,i=new Float32Array(t.width*t.height*4),n=this.renderer.getContext();return n.bindBuffer(n.PIXEL_PACK_BUFFER,null),this.renderer.readRenderTargetPixels(t,0,0,t.width,t.height,i),i}async readSkyView(e){const t=e==="sun"?this.sunView:this.moonView,i=new Float32Array(t.width*t.height*4);return await this.renderer.readRenderTargetPixelsAsync(t,0,0,t.width,t.height,i),i}dispose(){this.abandonBuilding(),this.releaseAdopted(),this.transmittance.dispose(),this.multiple.dispose(),this.sunView.dispose(),this.moonView.dispose(),this.transmittanceMaterial.dispose(),this.multipleMaterial.dispose(),this.skyViewMaterial.dispose(),this.quad.geometry.dispose()}draw(e,t){this.quad.material=e,this.renderer.setRenderTarget(t),this.renderer.render(this.scene,this.camera)}static mediumUniforms(){const e=()=>[new nt,new nt,new nt,new nt],t=(i,n)=>{const s=e();return Oe.WAVELENGTHS_NM.forEach((r,o)=>{s[Math.floor(o/4)].setComponent(o%4,i(r)*n*Oe.WAVELENGTH_STEP_NM*Oe.SOLAR_IRRADIANCE[o])}),s};return{uRayleigh:{value:e()},uAerosolScattering:{value:e()},uAerosolExtinction:{value:e()},uOzone:{value:e()},uCieX:{value:t(i=>oi.colourMatching(i)[0],683)},uCieY:{value:t(i=>oi.colourMatching(i)[1],683)},uCieZ:{value:t(i=>oi.colourMatching(i)[2],683)},uScotopic:{value:t(i=>oi.scotopic(i),1700)}}}static VERTEX=`
|
|
6529
|
+
`}),n.fragmentShader=s+n.fragmentShader,n.fragmentShader=n.fragmentShader.replace("#include <opaque_fragment>",r+"#include <opaque_fragment>")},e.needsUpdate=!0}meshes=new Map;signatures=new Map;extents=new Map;placed=[];frame;direction=new D;up=new D;lookAt=new Ze;vertex=new D;centre=new D;right=new D;above=new D;set(e,t){this.placed=e,this.frame=t;const i=new Set(e.map(n=>n.sourceId));for(const[n,s]of this.meshes)i.has(n)||(this.dispose(s),this.meshes.delete(n),this.signatures.delete(n),this.extents.delete(n));for(const n of e){let s=this.meshes.get(n.sourceId);s||(s=new De(new ki(1,1,wn.SEGMENTS,wn.SEGMENTS),new mn({transparent:!0,depthWrite:!1,depthTest:!0,fog:!1,toneMapped:!1})),this.configureCloudMaterial(s.material),s.frustumCulled=!1,s.layers.set(m1),this.scene.add(s),this.meshes.set(n.sourceId,s)),s.renderOrder=Zw+n.renderOrder,s.visible=!n.hidden&&n.shape.transparency<1,s.visible&&this.paint(s,n,t)}}place(e,t,i){const n=this.frame;if(n)for(const s of this.placed){const r=this.meshes.get(s.sourceId);if(!r||!r.visible)continue;const o=this.extents.get(s.sourceId);if(!o)continue;const{bounds:c}=s.shape;let l=c.x+c.width/2,h=c.y+c.height/2,u=!0;if(s.aim){const d=i(wn.directionOf(s.aim,this.direction));d&&Math.abs(d.ndcX)<wn.FURTHEST_NDC&&Math.abs(d.ndcY)<wn.FURTHEST_NDC?(l=(d.ndcX+1)/2*n.canvasWidthPx,h=(1-d.ndcY)/2*n.canvasHeightPx):u=!1}u?this.curve(r,e,t,n,o,l,h,s.distanceM):this.flat(r,e,n,o,s.distanceM)}}static FURTHEST_NDC=4;curve(e,t,i,n,s,r,o,c){const l=r-s.width/2,h=o-s.height/2,u=e.geometry.attributes.position,d=wn.SEGMENTS;let f=0;for(let p=0;p<=d;p++){const v=h+p/d*s.height;for(let m=0;m<=d;m++){const g=l+m/d*s.width;i(g/n.canvasWidthPx*2-1,-(v/n.canvasHeightPx*2-1),this.direction),this.vertex.copy(t.position).addScaledVector(this.direction,c),u.setXYZ(f++,this.vertex.x,this.vertex.y,this.vertex.z)}}u.needsUpdate=!0,e.matrixAutoUpdate=!1,e.matrix.identity(),e.matrixWorldNeedsUpdate=!0,e.scale.set(Rt.sizeMAt(c,n.projection.pxToDeg(s.width)),Rt.sizeMAt(c,n.projection.pxToDeg(s.height)),1)}flat(e,t,i,n,s){const r=e.geometry.attributes.position,o=wn.SEGMENTS,c=Rt.sizeMAt(s,i.projection.pxToDeg(n.width)),l=Rt.sizeMAt(s,i.projection.pxToDeg(n.height));this.up.set(0,1,0).applyQuaternion(t.quaternion),this.centre.copy(t.position).addScaledVector(this.direction,s),this.lookAt.lookAt(t.position,this.centre,this.up),this.right.setFromMatrixColumn(this.lookAt,0),this.above.setFromMatrixColumn(this.lookAt,1);let h=0;for(let u=0;u<=o;u++){const d=.5-u/o;for(let f=0;f<=o;f++){const p=f/o-.5;this.vertex.copy(this.centre).addScaledVector(this.right,p*c).addScaledVector(this.above,d*l),r.setXYZ(h++,this.vertex.x,this.vertex.y,this.vertex.z)}}r.needsUpdate=!0,e.matrixAutoUpdate=!1,e.matrix.identity(),e.matrixWorldNeedsUpdate=!0,e.scale.set(c,l,1)}static SEGMENTS=16;static directionOf(e,t){const i=e.azimuthDeg*Math.PI/180,n=e.altitudeDeg*Math.PI/180;return t.set(Math.sin(i)*Math.cos(n),Math.sin(n),-Math.cos(i)*Math.cos(n))}get any(){for(const e of this.meshes.values())if(e.visible)return!0;return!1}get furthestM(){return this.placed.reduce((e,t)=>Math.max(e,t.distanceM),0)}paint(e,t,i){const{shape:n}=t,s=mo.paintExtent(n),r=t.ghost?3:0,o={x:s.x-r,y:s.y-r,width:s.width+2*r,height:s.height+2*r};this.extents.set(t.sourceId,o);const c=`${wn.signatureOf(n,i)}|${t.ghost?"ghost":""}`;if(this.signatures.get(t.sourceId)===c&&e.material.map)return;this.signatures.set(t.sourceId,c);const l=Math.min(i.scale,Jw/Math.max(o.width,o.height,1)),h=Math.max(1,Math.ceil(o.width*l)),u=Math.max(1,Math.ceil(o.height*l)),d=e.material.map,f=d?.image??document.createElement("canvas"),p=f.width!==h||f.height!==u;p&&(f.width=h,f.height=u);const v=f.getContext("2d");if(!v)return;v.clearRect(0,0,h,u);const m=new mo(v);if(m.setStarPoints(i.starPoints),m.setRoll(i.rollRad),m.paintInto(n,o,l,t.ghost),d&&!p){d.needsUpdate=!0;return}d?.dispose();const g=new Ss(f);g.colorSpace=Fi,g.minFilter=st,g.generateMipmaps=!1,e.material.map=g,e.material.needsUpdate=!0}static signatureOf(e,t){const{bounds:i}=e;return JSON.stringify([e.kind,Math.round(i.width*10),Math.round(i.height*10),e.color,e.angle,e.transparency,e.haloScale,e.blur??0,e.brightness??0,e.kind==="polygon"?e.points:void 0,t.scale,t.starPoints,t.rollRad])}dispose(e){e.removeFromParent(),e.geometry.dispose(),e.material.map?.dispose(),e.material.dispose()}clear(){for(const e of this.meshes.values())this.dispose(e);this.meshes.clear(),this.signatures.clear(),this.extents.clear(),this.placed=[]}}const g1=3,Ec=800,Xr=Math.PI/180;class ua{constructor(e,t,i=ua.fetchImage){this.scene=e,this.onImageLoaded=t,this.loadImage=i}meshes=new Map;signatures=new Map;images=new Map;loading=new Map;failed=new Set;references=[];views=new Map;shown=!0;set(e,t=this.views){this.references=e,this.views=t;const i=new Set(e.map(n=>n.id));for(const[n,s]of this.meshes)i.has(n)||(this.dispose(s),this.meshes.delete(n),this.signatures.delete(n));for(const[n,s]of this.images){const r=e.find(o=>o.id===n);r&&r.src===s.texture.userData.src||(s.texture.dispose(),this.images.delete(n))}for(const n of e){const s=this.images.get(n.id);if(!s){this.load(n);continue}this.build(n,s)}}setShown(e){this.shown=e;for(const t of this.meshes.values())t.visible=e&&this.opacityOf(t.userData.id)>0}setView(e,t){this.views.set(e,t);const i=this.meshes.get(e);i&&this.applyOpacity(i,e)}get any(){for(const e of this.meshes.values())if(e.visible)return!0;return!1}place(e){for(const t of this.meshes.values())t.visible&&(t.position.copy(e.position),t.updateMatrixWorld())}get furthestM(){return this.meshes.size>0?Ec:0}directionOfPixel(e,t,i,n){const s=this.images.get(e.id),r=s?s.width/s.height:1,o=Math.tan(e.registration.fovDeg/2*Xr),c=o*r;return n.set((t*2-1)*c,(1-i*2)*o,-1).normalize(),n.applyQuaternion(ua.orientation(e))}aspectOf(e){const t=this.images.get(e);return t?t.width/t.height:void 0}failedToLoad(e){return this.failed.has(e)}load(e){const t=e.src;if(this.loading.has(e.id)||this.failed.has(t))return;const i=this.loadImage(t).then(n=>{this.loading.delete(e.id);const s=this.references.find(r=>r.id===e.id);if(!s||s.src!==t){n.texture.dispose();return}n.texture.userData.src=t,this.images.set(e.id,n),this.build(s,n),this.onImageLoaded()},()=>{this.loading.delete(e.id),this.failed.add(t)});this.loading.set(e.id,i)}static async fetchImage(e){const t=await fetch(e);if(!t.ok)throw new Error(`${e}: ${t.status}`);const i=await createImageBitmap(await t.blob(),{imageOrientation:"flipY"}),n=new xi(i);return n.flipY=!1,n.colorSpace=Fi,n.minFilter=st,n.magFilter=st,n.generateMipmaps=!1,n.needsUpdate=!0,{texture:n,width:i.width,height:i.height}}build(e,t){const i=ua.signatureOf(e,t);let n=this.meshes.get(e.id);if(n&&this.signatures.get(e.id)===i){this.applyOpacity(n,e.id);return}n&&(this.dispose(n),this.meshes.delete(e.id)),n=new De(ua.geometryOf(e,t),new mn({map:t.texture,transparent:!0,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1})),e.kind==="panorama"&&(n.material.side=Ot),n.frustumCulled=!1,n.layers.set(g1),n.userData.id=e.id,n.quaternion.copy(ua.orientation(e)),this.scene.add(n),this.meshes.set(e.id,n),this.signatures.set(e.id,i),this.applyOpacity(n,e.id)}static geometryOf(e,t){if(e.kind==="panorama"){const r=new Qt(Ec,64,32,Math.PI/2,Math.PI*2),o=r.attributes.uv;for(let c=0;c<o.count;c++)o.setX(c,1-o.getX(c));return o.needsUpdate=!0,r}const i=2*Ec*Math.tan(e.registration.fovDeg/2*Xr),n=i*(t.width/Math.max(t.height,1)),s=new ki(n,i);return s.translate(0,0,-Ec),s}static orientation(e){const{headingDeg:t,pitchDeg:i,rollDeg:n}=e.registration,s=new Pt;return s.rotation.set(i*Xr,-t*Xr,-(n??0)*Xr,"YXZ"),s.quaternion}opacityOf(e){const t=this.references.find(n=>n.id===e);return this.views.get(e)?.opacity??t?.opacity??0}applyOpacity(e,t){const i=this.opacityOf(t);e.material.opacity=i,e.visible=this.shown&&i>0}static signatureOf(e,t){const{headingDeg:i,pitchDeg:n,rollDeg:s,fovDeg:r}=e.registration;return[e.kind,e.src,t.width,t.height,i,n,s??0,r].join("|")}dispose(e){this.scene.remove(e),e.geometry.dispose(),e.material.dispose()}disposeAll(){for(const e of this.meshes.values())this.dispose(e);this.meshes.clear(),this.signatures.clear();for(const e of this.images.values())e.texture.dispose();this.images.clear()}}class Oe{static GROUND_RADIUS_M=636e4;static TOP_RADIUS_M=646e4;static WAVELENGTHS_NM=Array.from({length:15},(e,t)=>410+20*t);static WAVELENGTH_STEP_NM=20;static SOLAR_IRRADIANCE=[1.707,1.676,1.982,2.02,1.941,1.87,1.879,1.856,1.839,1.799,1.728,1.668,1.57,1.532,1.452];static OZONE_CROSS_SECTION=[.021,.069,.19,.418,.827,1.531,2.439,3.291,4.468,4.55,4.663,3.477,2.447,1.658,1.071];static RAYLEIGH_SCALE_HEIGHT_M=8e3;static AEROSOL_SCALE_HEIGHT_M=1200;static OZONE_PEAK_ALTITUDE_M=25e3;static OZONE_HALF_WIDTH_M=15e3;static DEFAULT_AEROSOL_OPTICAL_DEPTH=.1;static DEFAULT_OZONE_DOBSON=300;static AEROSOL_SINGLE_SCATTERING_ALBEDO=.9;static AEROSOL_ANGSTROM_EXPONENT=1.3;static AEROSOL_ASYMMETRY=.8;rayleighScattering;aerosolScattering;aerosolExtinction;ozoneAbsorption;constructor(e={}){const t=Oe.WAVELENGTHS_NM.length,i=e.aerosolOpticalDepth??Oe.DEFAULT_AEROSOL_OPTICAL_DEPTH,n=e.ozoneDobson??Oe.DEFAULT_OZONE_DOBSON;this.rayleighScattering=new Float64Array(t),this.aerosolScattering=new Float64Array(t),this.aerosolExtinction=new Float64Array(t),this.ozoneAbsorption=new Float64Array(t);const s=n*2687e17/Oe.OZONE_HALF_WIDTH_M;for(let r=0;r<t;r++){const o=Oe.WAVELENGTHS_NM[r];this.rayleighScattering[r]=Oe.rayleighAt(o);const c=i/Oe.AEROSOL_SCALE_HEIGHT_M*(o/550)**-1.3;this.aerosolExtinction[r]=c,this.aerosolScattering[r]=c*Oe.AEROSOL_SINGLE_SCATTERING_ALBEDO,this.ozoneAbsorption[r]=Oe.OZONE_CROSS_SECTION[r]*1e-25*s}}static rayleighAt(e){const t=e/1e3,i=1/(t*t),n=t*t;return(1.0455996-341.29061*i-.9023085*n)/(1+.0027059889*i-85.968563*n)*1e-28*1e-4*2546899e19}static rayleighDensity(e){return Math.exp(-Math.max(e,0)/Oe.RAYLEIGH_SCALE_HEIGHT_M)}static aerosolDensity(e){return Math.exp(-Math.max(e,0)/Oe.AEROSOL_SCALE_HEIGHT_M)}static ozoneDensity(e){return Math.max(0,1-Math.abs(e-Oe.OZONE_PEAK_ALTITUDE_M)/Oe.OZONE_HALF_WIDTH_M)}static rayleighPhase(e){return 3/(16*Math.PI)*(1+e*e)}static aerosolPhase(e,t=Oe.AEROSOL_ASYMMETRY){const i=t*t;return 3/(8*Math.PI)*(1-i)*(1+e*e)/((2+i)*Math.pow(Math.max(1+i-2*t*e,1e-6),1.5))}}class Ge{static TRANSMITTANCE_WIDTH=256;static TRANSMITTANCE_HEIGHT=64;static MULTIPLE_SIZE=64;static MULTIPLE_ROWS=16;static MULTIPLE_HEIGHT_POWER=2;static MULTIPLE_DIRECTIONS=16;static SKY_VIEW_WIDTH=192;static SKY_VIEW_HEIGHT=108;static STEPS=40;static MULTIPLE_STEPS=12;static GROUND_ALBEDO=.3;supported;renderer;transmittance;multiple;sunView;moonView;scene=new xs;camera=new Cn(-1,1,1,-1,0,1);quad;transmittanceMaterial;multipleMaterial;skyViewMaterial;transmittanceReady=!1;multipleRows=0;multipleColumn=0;mediumKey="";static MULTIPLE_BLOCK=16;static shared=new Map;building=!1;adopted;tableUniforms;constructor(e){this.renderer=e,this.supported=e.capabilities.isWebGL2&&e.extensions.has("EXT_color_buffer_float"),this.transmittance=new jt(Ge.TRANSMITTANCE_WIDTH,Ge.TRANSMITTANCE_HEIGHT,{count:4,type:kt,minFilter:st,magFilter:st,depthBuffer:!1}),this.multiple=new jt(Ge.MULTIPLE_SIZE,Ge.MULTIPLE_ROWS,{count:4,type:Di,minFilter:wt,magFilter:wt,depthBuffer:!1});const t=()=>new jt(Ge.SKY_VIEW_WIDTH,Ge.SKY_VIEW_HEIGHT,{type:Di,minFilter:wt,magFilter:wt,depthBuffer:!1});this.sunView=t(),this.moonView=t();const i=Ge.mediumUniforms(),n=this.tableUniforms={uT0:{value:this.transmittance.textures[0]},uT1:{value:this.transmittance.textures[1]},uT2:{value:this.transmittance.textures[2]},uT3:{value:this.transmittance.textures[3]},uM0:{value:this.multiple.textures[0]},uM1:{value:this.multiple.textures[1]},uM2:{value:this.multiple.textures[2]},uM3:{value:this.multiple.textures[3]}},s=(r,o={})=>new _g({glslVersion:tl,uniforms:{...i,...n,...o},vertexShader:Ge.VERTEX,fragmentShader:r,depthTest:!1,depthWrite:!1});this.transmittanceMaterial=s(Ge.TRANSMITTANCE_FRAGMENT),this.multipleMaterial=s(Ge.MULTIPLE_FRAGMENT),this.skyViewMaterial=s(Ge.SKY_VIEW_FRAGMENT,{uObserverRadius:{value:Oe.GROUND_RADIUS_M+2},uSourceMu:{value:1}}),this.quad=new De(new ki(2,2),this.transmittanceMaterial),this.quad.frustumCulled=!1,this.scene.add(this.quad)}get transmittanceTextures(){return this.transmittance.textures}get sunViewTexture(){return this.sunView.texture}get moonViewTexture(){return this.moonView.texture}get ready(){return this.supported&&(this.adopted!==void 0||this.transmittanceReady&&this.multipleRows>=Ge.MULTIPLE_ROWS)}setMedium(e){const t=[e.rayleighScattering,e.aerosolScattering,e.aerosolExtinction,e.ozoneAbsorption].map(n=>Array.from(n,s=>s.toPrecision(6)).join(",")).join("|");if(t===this.mediumKey)return;this.abandonBuilding(),this.releaseAdopted(),this.mediumKey=t;const i=(n,s)=>{const r=this.transmittanceMaterial.uniforms[n].value;for(let o=0;o<4;o++)r[o].set(s[o*4]??0,s[o*4+1]??0,s[o*4+2]??0,s[o*4+3]??0)};i("uRayleigh",e.rayleighScattering),i("uAerosolScattering",e.aerosolScattering),i("uAerosolExtinction",e.aerosolExtinction),i("uOzone",e.ozoneAbsorption),this.transmittanceReady=!1,this.multipleRows=0,this.multipleColumn=0}invalidate(){this.adopted||(this.abandonBuilding(),this.transmittanceReady=!1,this.multipleRows=0,this.multipleColumn=0)}advance(e){if(!this.supported||!this.mediumKey)return!1;if(this.ready)return!0;const t=Ge.shared.get(this.mediumKey);if(t&&t!=="building")return this.adopt(t),!0;if(t==="building"&&!this.building)return!1;t||(Ge.shared.set(this.mediumKey,"building"),this.building=!0);const i=this.renderer.getRenderTarget();let n=Math.max(1,e);this.transmittanceReady||(this.draw(this.transmittanceMaterial,this.transmittance),this.transmittanceReady=!0,n--);const s=Ge.MULTIPLE_SIZE,r=Ge.MULTIPLE_BLOCK;for(;n>0&&this.multipleRows<Ge.MULTIPLE_ROWS;n--)this.multiple.scissor.set(this.multipleColumn,this.multipleRows,r,1),this.multiple.scissorTest=!0,this.draw(this.multipleMaterial,this.multiple),this.multipleColumn+=r,this.multipleColumn>=s&&(this.multipleColumn=0,this.multipleRows++);return this.multiple.scissorTest=!1,this.renderer.setRenderTarget(i),this.ready&&this.building&&this.share(this.mediumKey),this.ready}async share(e){this.building=!1;try{const t=await Promise.all([0,1,2,3].map(n=>this.readRaw(this.transmittance,n,Uint16Array))),i=await Promise.all([0,1,2,3].map(n=>this.readRaw(this.multiple,n,Float32Array)));this.mediumKey===e?Ge.shared.set(e,{transmittance:t,multiple:i}):Ge.shared.delete(e)}catch{Ge.shared.delete(e)}}async readRaw(e,t,i){const n=new i(e.width*e.height*4);return await this.renderer.readRenderTargetPixelsAsync(e,0,0,e.width,e.height,n,void 0,t),n}adopt(e){const t=(s,r,o,c)=>{const l=new $s(s,r,o,_i,c?kt:Di);return l.minFilter=l.magFilter=c?st:wt,l.needsUpdate=!0,l},i=e.transmittance.map(s=>t(s,Ge.TRANSMITTANCE_WIDTH,Ge.TRANSMITTANCE_HEIGHT,!0)),n=e.multiple.map(s=>t(s,Ge.MULTIPLE_SIZE,Ge.MULTIPLE_ROWS,!1));i.forEach((s,r)=>this.tableUniforms[`uT${r}`].value=s),n.forEach((s,r)=>this.tableUniforms[`uM${r}`].value=s),this.adopted=[...i,...n]}releaseAdopted(){if(this.adopted){for(const e of this.adopted)e.dispose();this.adopted=void 0;for(let e=0;e<4;e++)this.tableUniforms[`uT${e}`].value=this.transmittance.textures[e],this.tableUniforms[`uM${e}`].value=this.multiple.textures[e]}}abandonBuilding(){this.building&&(this.building=!1,Ge.shared.get(this.mediumKey)==="building"&&Ge.shared.delete(this.mediumKey))}renderSkyViews(e,t,i){if(!this.ready)return;const n=this.renderer.getRenderTarget(),s=this.skyViewMaterial.uniforms;s.uObserverRadius.value=Oe.GROUND_RADIUS_M+Math.max(e,2),s.uSourceMu.value=Math.sin(t*Math.PI/180),this.draw(this.skyViewMaterial,this.sunView),s.uSourceMu.value=Math.sin(i*Math.PI/180),this.draw(this.skyViewMaterial,this.moonView),this.renderer.setRenderTarget(n)}static skyViewUv(e,t,i){const n=Oe.GROUND_RADIUS_M+Math.max(e,2),s=Oe.GROUND_RADIUS_M,r=Math.acos(Math.min(Math.sqrt(Math.max(n*n-s*s,0))/n,1)),o=Math.PI-r,c=t<o?.5*(1-Math.sqrt(Math.max(1-t/o,0))):.5+.5*Math.sqrt(Math.min((t-o)/r,1));return{u:Math.min(Math.max(Math.abs(i)/Math.PI,0),1),v:c}}async readTable(e,t){if(e==="multiple"){const s=new Float32Array(this.multiple.width*this.multiple.height*4);return await this.renderer.readRenderTargetPixelsAsync(this.multiple,0,0,this.multiple.width,this.multiple.height,s,void 0,t),s}const i=this.transmittance,n=new Uint16Array(i.width*i.height*4);return await this.renderer.readRenderTargetPixelsAsync(i,0,0,i.width,i.height,n,void 0,t),Float32Array.from(n,s=>Dn.fromHalfFloat(s))}readSkyViewNow(e){const t=e==="sun"?this.sunView:this.moonView,i=new Float32Array(t.width*t.height*4),n=this.renderer.getContext();return n.bindBuffer(n.PIXEL_PACK_BUFFER,null),this.renderer.readRenderTargetPixels(t,0,0,t.width,t.height,i),i}async readSkyView(e){const t=e==="sun"?this.sunView:this.moonView,i=new Float32Array(t.width*t.height*4);return await this.renderer.readRenderTargetPixelsAsync(t,0,0,t.width,t.height,i),i}dispose(){this.abandonBuilding(),this.releaseAdopted(),this.transmittance.dispose(),this.multiple.dispose(),this.sunView.dispose(),this.moonView.dispose(),this.transmittanceMaterial.dispose(),this.multipleMaterial.dispose(),this.skyViewMaterial.dispose(),this.quad.geometry.dispose()}draw(e,t){this.quad.material=e,this.renderer.setRenderTarget(t),this.renderer.render(this.scene,this.camera)}static mediumUniforms(){const e=()=>[new it,new it,new it,new it],t=(i,n)=>{const s=e();return Oe.WAVELENGTHS_NM.forEach((r,o)=>{s[Math.floor(o/4)].setComponent(o%4,i(r)*n*Oe.WAVELENGTH_STEP_NM*Oe.SOLAR_IRRADIANCE[o])}),s};return{uRayleigh:{value:e()},uAerosolScattering:{value:e()},uAerosolExtinction:{value:e()},uOzone:{value:e()},uCieX:{value:t(i=>ci.colourMatching(i)[0],683)},uCieY:{value:t(i=>ci.colourMatching(i)[1],683)},uCieZ:{value:t(i=>ci.colourMatching(i)[2],683)},uScotopic:{value:t(i=>ci.scotopic(i),1700)}}}static VERTEX=`
|
|
6522
6530
|
in vec3 position;
|
|
6523
6531
|
void main() {
|
|
6524
6532
|
gl_Position = vec4(position.xy, 0.0, 1.0);
|
|
@@ -6794,7 +6802,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
|
|
|
6794
6802
|
}
|
|
6795
6803
|
outColor = xyzs;
|
|
6796
6804
|
}
|
|
6797
|
-
`}class
|
|
6805
|
+
`}class ii{static AIRGLOW_LAYER_ALTITUDE_M=9e4;static SUN_MAGNITUDE=-26.74;tables;material;onChange;state;drawnKey="";hasViews=!1;adaptingLuminance=1;get adaptation(){return this.adaptingLuminance*this.exposureScale}ambientColours;reading=!1;exposureScale=1;seenByEye=!0;readAgain=!1;constructor(e,t){this.onChange=t,this.tables=new Ge(e),this.tables.setMedium(new Oe),this.material=new at({glslVersion:tl,side:Ot,depthWrite:!1,uniforms:{uSunView:{value:this.tables.sunViewTexture},uMoonView:{value:this.tables.moonViewTexture},uSunAzimuth:{value:new xe(0,-1)},uMoonAzimuth:{value:new xe(0,-1)},uMoonScale:{value:0},uObserverRadius:{value:Oe.GROUND_RADIUS_M+2},uAirglow:{value:new it(...ii.airglowXyzs())},uRodShare:{value:0},uInverseSemiSaturation:{value:1},uExposureScale:{value:1}},vertexShader:`
|
|
6798
6806
|
varying vec3 vDirection;
|
|
6799
6807
|
void main() {
|
|
6800
6808
|
vDirection = (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition;
|
|
@@ -6818,7 +6826,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
|
|
|
6818
6826
|
uniform float uExposureScale;
|
|
6819
6827
|
const float PI = 3.141592653589793;
|
|
6820
6828
|
const float GROUND = ${Oe.GROUND_RADIUS_M.toFixed(1)};
|
|
6821
|
-
const float AIRGLOW_RATIO = ${(Oe.GROUND_RADIUS_M/(Oe.GROUND_RADIUS_M+
|
|
6829
|
+
const float AIRGLOW_RATIO = ${(Oe.GROUND_RADIUS_M/(Oe.GROUND_RADIUS_M+ii.AIRGLOW_LAYER_ALTITUDE_M)).toFixed(6)};
|
|
6822
6830
|
const float EXTINCTION = ${Ye.EXTINCTION_PER_AIR_MASS.toFixed(4)};
|
|
6823
6831
|
const vec2 VIEW_SIZE = vec2(${Ge.SKY_VIEW_WIDTH}.0, ${Ge.SKY_VIEW_HEIGHT}.0);
|
|
6824
6832
|
const vec3 SCOTOPIC_TINT = vec3(${Ee.SCOTOPIC_TINT.map(i=>i.toFixed(4)).join(", ")});
|
|
@@ -6874,7 +6882,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
|
|
|
6874
6882
|
gl_FragColor = vec4(relativeOf(light.xyz, light.w), 1.0);
|
|
6875
6883
|
#include <colorspace_fragment>
|
|
6876
6884
|
}
|
|
6877
|
-
`})}get supported(){return this.tables.supported}get ready(){return this.hasViews}get ambient(){return this.ready?this.ambientColours:void 0}setInstrument(e,t){const i=e?10**(.4*t):1;i===this.exposureScale&&this.seenByEye===!e||(this.exposureScale=i,this.seenByEye=!e,this.material.uniforms.uExposureScale.value=i,this.applyAdaptation(this.adaptingLuminance),this.onChange())}setConditions(e){this.tables.setMedium(new Oe(e)),this.tables.ready||(this.drawnKey="")}advance(e){!this.supported||this.tables.ready||this.tables.advance(e)&&this.state&&this.draw(this.state)}invalidate(){this.tables.invalidate(),this.drawnKey="",this.hasViews=!1}update(e){this.state=e,this.tables.ready?this.draw(e):this.hasViews||this.applyAdaptation(
|
|
6885
|
+
`})}get supported(){return this.tables.supported}get ready(){return this.hasViews}get ambient(){return this.ready?this.ambientColours:void 0}setInstrument(e,t){const i=e?10**(.4*t):1;i===this.exposureScale&&this.seenByEye===!e||(this.exposureScale=i,this.seenByEye=!e,this.material.uniforms.uExposureScale.value=i,this.applyAdaptation(this.adaptingLuminance),this.onChange())}setConditions(e){this.tables.setMedium(new Oe(e)),this.tables.ready||(this.drawnKey="")}advance(e){!this.supported||this.tables.ready||this.tables.advance(e)&&this.state&&this.draw(this.state)}invalidate(){this.tables.invalidate(),this.drawnKey="",this.hasViews=!1}update(e){this.state=e,this.tables.ready?this.draw(e):this.hasViews||this.applyAdaptation(ii.predictedZenithLuminance(e))}dispose(){this.tables.dispose(),this.material.dispose()}draw(e){const t=[e.altitudeM.toFixed(0),e.sun.altitudeDeg.toFixed(3),e.moon.altitudeDeg.toFixed(3)].join(":"),i=this.material.uniforms;if(i.uSunAzimuth.value.copy(ii.azimuthVector(e.sun.azimuthDeg)),i.uMoonAzimuth.value.copy(ii.azimuthVector(e.moon.azimuthDeg)),i.uMoonScale.value=10**(-.4*(e.moon.magnitude-ii.SUN_MAGNITUDE)),i.uObserverRadius.value=Oe.GROUND_RADIUS_M+Math.max(e.altitudeM,2),t!==this.drawnKey){this.tables.renderSkyViews(e.altitudeM,e.sun.altitudeDeg,e.moon.altitudeDeg);const n=!this.hasViews;this.hasViews=!0,this.drawnKey=t,n&&!this.ambientColours&&this.adaptFromViews(this.tables.readSkyViewNow("sun"),this.tables.readSkyViewNow("moon"),e),this.readBack()}this.onChange()}async readBack(){if(this.reading){this.readAgain=!0;return}this.reading=!0;try{const[e,t]=await Promise.all([this.tables.readSkyView("sun"),this.tables.readSkyView("moon")]),i=this.state;i&&this.adaptFromViews(e,t,i)}finally{this.reading=!1}this.readAgain&&(this.readAgain=!1,this.readBack())}adaptToSurroundings(e){if(!(e>0)||!(this.clearAdaptation>0))return!1;const t=e/this.clearAdaptation;return Math.abs(Math.log(t/this.surroundingsFactor))<.05?!1:(this.surroundingsFactor=t,this.views&&this.state?this.adaptFromViews(this.views.sun,this.views.moon,this.state):this.applyAdaptation(this.clearAdaptation*t),!0)}resetSurroundings(){this.surroundingsFactor=1}surroundingsFactor=1;clearAdaptation=0;views;adaptFromViews(e,t,i){this.views={sun:e,moon:t};const n=10**(-.4*(i.moon.magnitude-ii.SUN_MAGNITUDE)),s=ii.airglowXyzs(),r=(m,g,_=!0)=>{const w=(90-m)*Math.PI/180,M=Ge.skyViewUv(i.altitudeM,w,ii.azimuthBetween(g,i.sun.azimuthDeg)),S=Ge.skyViewUv(i.altitudeM,w,ii.azimuthBetween(g,i.moon.azimuthDeg)),b=ii.bilinear(e,M.u,M.v),T=ii.bilinear(t,S.u,S.v),x=_&&m>0?ii.airglowFactor(m):0;return[0,1,2,3].map(A=>b[A]+n*T[A]+s[A]*x)};let o=0,c=0;for(let m=5;m<90;m+=10){const g=Math.cos(m*Math.PI/180);for(let _=0;_<360;_+=30)o+=g*Math.log(Math.max(r(m,_)[1],1e-9)),c+=g}this.clearAdaptation=Math.exp(o/c),this.applyAdaptation(this.clearAdaptation*this.surroundingsFactor);const l=([m,g,_,w])=>{const M=this.exposureScale,S=this.adaptingLuminance*M;return Ee.relativeOf([m*M,g*M,_*M],w*M,S,0)},h=(m,g,_=!0)=>l(r(m,g,_)),u=[0,0,0,0],d=5*Math.PI/180,f=20*Math.PI/180;for(let m=2.5;m<90;m+=5){const g=m*Math.PI/180,_=Math.sin(g)*Math.cos(g)*d*f;for(let w=10;w<360;w+=20){const M=r(m,w);for(let S=0;S<4;S++)u[S]+=M[S]*_}}const p=[0,0,0],v=[0,0,0];for(let m=0;m<360;m+=20){const g=h(2,m),_=h(2,m,!1);for(let w=0;w<3;w++)p[w]+=g[w]/18,v[w]+=_[w]/18}this.ambientColours={zenith:h(90,0),horizon:p,airlight:v,skyIrradiance:l(u),scale:this.relativeScale},this.onChange()}relativeOfLuminance(e,t){const[i,n,s]=e,r=.2126*i+.7152*n+.0722*s,o=r>0?t/r:0,c=[o*(.4124*i+.3576*n+.1805*s),t,o*(.0193*i+.1192*n+.9505*s)],l=this.exposureScale,h=this.adaptingLuminance*l;return Ee.relativeOf([c[0]*l,c[1]*l,c[2]*l],c[1]*l,h,0)}get rodShare(){const e=this.adaptingLuminance*this.exposureScale;return this.seenByEye?Ee.rodShare(e):0}get relativeScale(){const e=this.adaptingLuminance*this.exposureScale;return this.exposureScale/Ee.semiSaturation(e)}applyAdaptation(e){this.adaptingLuminance=e;const t=e*this.exposureScale;this.material.uniforms.uRodShare.value=0,this.material.uniforms.uInverseSemiSaturation.value=1/Ee.semiSaturation(t)}static predictedZenithLuminance(e){const t=n=>90-n.altitudeDeg,i=Ye.magPerArcsec2({altitudeDeg:e.sun.altitudeDeg,separationDeg:t(e.sun)},{phaseAngleDeg:e.moon.phaseAngleDeg,altitudeDeg:e.moon.altitudeDeg,separationDeg:t(e.moon)},90);return Ye.toNanolamberts(i)*ii.CANDELAS_PER_NANOLAMBERT}static CANDELAS_PER_NANOLAMBERT=1e-5/Math.PI;static airglowXyzs(){const e=Ye.toNanolamberts(Ye.AIRGLOW_MAG_PER_ARCSEC2)*ii.CANDELAS_PER_NANOLAMBERT;return[e*.3127/.329,e,e*(1-.3127-.329)/.329,e]}static airglowFactor(e){const t=Math.cos(e*Math.PI/180)**2,i=Oe.GROUND_RADIUS_M/(Oe.GROUND_RADIUS_M+ii.AIRGLOW_LAYER_ALTITUDE_M),n=1/Math.sqrt(Math.max(1-i*i*t,1e-4)),s=1/Math.sqrt(Math.max(1-.96*t,.001));return n*10**(-.4*Ye.EXTINCTION_PER_AIR_MASS*(s-1))}static azimuthVector(e){const t=e*Math.PI/180;return new xe(Math.sin(t),-Math.cos(t))}static azimuthBetween(e,t){const i=Math.abs(e-t)%360;return(i>180?360-i:i)*Math.PI/180}static bilinear(e,t,i){const n=Ge.SKY_VIEW_WIDTH,s=Ge.SKY_VIEW_HEIGHT,r=Math.min(Math.max(t*n-.5,0),n-1),o=Math.min(Math.max(i*s-.5,0),s-1),c=Math.floor(r),l=Math.floor(o),h=Math.min(c+1,n-1),u=Math.min(l+1,s-1),d=r-c,f=o-l,p=(v,m,g)=>e[(v*n+m)*4+g];return[0,1,2,3].map(v=>(p(l,c,v)*(1-d)+p(l,h,v)*d)*(1-f)+(p(u,c,v)*(1-d)+p(u,h,v)*d)*f)}}class Vs{static DRY_OPTICAL_DEPTH=.08;static GROWTH_EXPONENT=.3;static MAX_RELATIVE_HUMIDITY=.95;static OPTICAL_DEPTH_STEP=.02;static relativeHumidity(e,t){const i=n=>Math.exp(17.625*n/(243.04+n));return Math.min(Math.max(i(t)/i(e),0),1)}static opticalDepth(e){const t=Math.min(Math.max(e,0),Vs.MAX_RELATIVE_HUMIDITY);return Vs.DRY_OPTICAL_DEPTH*(1-t)**-.3}static steppedOpticalDepth(e){const t=Vs.OPTICAL_DEPTH_STEP;return Math.round(Vs.opticalDepth(e)/t)*t}}class dn{static CHANNEL_WAVELENGTHS_NM=[680,550,440];static KOSCHMIEDER=-Math.log(.02);static PRECIPITATION_EXTINCTION_PER_KM={rain:{a:.365,b:.63},snow:{a:1.023,b:.72},hail:{a:.365,b:.63}};static FULL_INTENSITY_MM_PER_H=8;rayleigh;aerosol;constructor(e=Oe.DEFAULT_AEROSOL_OPTICAL_DEPTH,t=0){const[i,n,s]=dn.CHANNEL_WAVELENGTHS_NM;this.rayleigh=[Oe.rayleighAt(i),Oe.rayleighAt(n),Oe.rayleighAt(s)];const r=o=>e/Oe.AEROSOL_SCALE_HEIGHT_M*(o/550)**-1.3;this.aerosol=[r(i)+t,r(n)+t,r(s)+t],this.precipitationPerM=t}precipitationPerM;static of(e){const t=e.relativeHumidity===void 0?void 0:Vs.opticalDepth(e.relativeHumidity);return new dn(t,dn.precipitationExtinction(e))}static precipitationExtinction(e){if(e.precipitationType==="none"||!(e.precipitationIntensity>0))return 0;const t=dn.PRECIPITATION_EXTINCTION_PER_KM[e.precipitationType],i=e.precipitationIntensity*dn.FULL_INTENSITY_MM_PER_H;return t.a*i**t.b/1e3}transmittance(e,t,i){const n=dn.meanDensity(e,t,Oe.RAYLEIGH_SCALE_HEIGHT_M),s=dn.meanDensity(e,t,Oe.AEROSOL_SCALE_HEIGHT_M);return[0,1,2].map(r=>Math.exp(-(this.rayleigh[r]*n+this.aerosol[r]*s)*i))}transmittanceFromSpace(e,t){const i=Math.max(t,0),n=1/(Math.sin(i*Math.PI/180)+.50572*(i+6.07995)**-1.6364),s=Oe.RAYLEIGH_SCALE_HEIGHT_M*Oe.rayleighDensity(e),r=Oe.AEROSOL_SCALE_HEIGHT_M*Oe.aerosolDensity(e);return[0,1,2].map(o=>Math.exp(-(this.rayleigh[o]*s+(this.aerosol[o]-this.precipitationPerM)*r)*n))}extinctionAt(e){return{rayleigh:this.rayleigh[1]*Oe.rayleighDensity(e),aerosol:this.aerosol[1]*Oe.aerosolDensity(e)}}visibilityM(e){const{rayleigh:t,aerosol:i}=this.extinctionAt(e);return dn.KOSCHMIEDER/(t+i)}get rayleighRatios(){return[this.rayleigh[0]/this.rayleigh[1],1,this.rayleigh[2]/this.rayleigh[1]]}static meanDensity(e,t,i){const n=Math.max(e,0),s=Math.max(t,0),r=s-n;return Math.abs(r)<.01?Math.exp(-n/i):i*(Math.exp(-n/i)-Math.exp(-s/i))/r}}class Ma extends Gd{constructor(){super(new se(0,0,0),0,0),Ma.install()}setAir(e,t,i){const{rayleigh:n,aerosol:s}=e.extinctionAt(t);this.near=n,this.far=s,this.color.setRGB(i[0],i[1],i[2])}static fadeRim(e,t,i,n){e.onBeforeCompile=s=>{s.uniforms.aerialHorizon={value:n},s.fragmentShader=s.fragmentShader.replace("#include <fog_pars_fragment>",`#include <fog_pars_fragment>
|
|
6878
6886
|
uniform vec3 aerialHorizon;`).replace("#include <fog_fragment>",`#include <fog_fragment>
|
|
6879
6887
|
#ifdef USE_FOG
|
|
6880
6888
|
float aerialRim = smoothstep(${t.toFixed(1)}, ${i.toFixed(1)}, length(vAerialWorld.xz - cameraPosition.xz));
|
|
@@ -6914,7 +6922,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
|
|
|
6914
6922
|
vec3 aerialTransmittance = exp(-aerialExtinction * aerialDistance);
|
|
6915
6923
|
gl_FragColor.rgb = gl_FragColor.rgb * aerialTransmittance + fogColor * (1.0 - aerialTransmittance);
|
|
6916
6924
|
#endif
|
|
6917
|
-
#endif`}}class ot{static HAZE_COARSE_MODE={medianRadiusUm:1.5,geometricSigma:2};static CLOUD_DROPLETS={medianRadiusUm:8,geometricSigma:1.15};static COARSE_FRACTION=.3;static DIFFRACTED_SHARE=.5;static MAX_ANGLE_RAD=30*Math.PI/180;static STEPS=512;static RADII=32;static bessel1(e){const t=Math.abs(e);if(t<8){const l=e*e,h=e*(72362614232+l*(-7895059235+l*(2423968531e-1+l*(-2972611439e-3+l*(15704.4826+l*-30.16036606))))),u=144725228442+l*(2300535178+l*(1858330474e-2+l*(99447.43394+l*(376.9991397+l))));return h/u}const i=8/t,n=i*i,s=t-2.356194491,r=1+n*(.00183105+n*(-3516396496e-14+n*(2457520174e-15+n*-240337019e-15))),o=.04687499995+n*(-.0002002690873+n*(8449199096e-15+n*(-88228987e-14+n*105787412e-15))),c=Math.sqrt(.636619772/t)*(Math.cos(s)*r-i*Math.sin(s)*o);return e<0?-c:c}static airy(e){if(Math.abs(e)<1e-6)return 1;const t=2*ot.bessel1(e)/e;return t*t}static phaseOf(e,t,i){const n=2*Math.PI*t*1e3/i;return n*n/(4*Math.PI)*ot.airy(n*Math.sin(e))}static phase(e,t,i){let n=0,s=0;for(const{radiusUm:r,weight:o}of ot.radiiOf(i))n+=o*ot.phaseOf(e,r,t),s+=o;return n/s}static profile(e){const t=`${e.medianRadiusUm}:${e.geometricSigma}`,i=ot.profiles.get(t);if(i)return i;const n=ot.STEPS,s=new Float32Array(n*3),r=ot.radiiOf(e),o=r.reduce((c,{weight:l})=>c+l,0);for(let c=0;c<n;c++){const l=c/(n-1)*ot.MAX_ANGLE_RAD;let h=0,u=0,d=0;for(const f of
|
|
6925
|
+
#endif`}}class ot{static HAZE_COARSE_MODE={medianRadiusUm:1.5,geometricSigma:2};static CLOUD_DROPLETS={medianRadiusUm:8,geometricSigma:1.15};static COARSE_FRACTION=.3;static DIFFRACTED_SHARE=.5;static MAX_ANGLE_RAD=30*Math.PI/180;static STEPS=512;static RADII=32;static bessel1(e){const t=Math.abs(e);if(t<8){const l=e*e,h=e*(72362614232+l*(-7895059235+l*(2423968531e-1+l*(-2972611439e-3+l*(15704.4826+l*-30.16036606))))),u=144725228442+l*(2300535178+l*(1858330474e-2+l*(99447.43394+l*(376.9991397+l))));return h/u}const i=8/t,n=i*i,s=t-2.356194491,r=1+n*(.00183105+n*(-3516396496e-14+n*(2457520174e-15+n*-240337019e-15))),o=.04687499995+n*(-.0002002690873+n*(8449199096e-15+n*(-88228987e-14+n*105787412e-15))),c=Math.sqrt(.636619772/t)*(Math.cos(s)*r-i*Math.sin(s)*o);return e<0?-c:c}static airy(e){if(Math.abs(e)<1e-6)return 1;const t=2*ot.bessel1(e)/e;return t*t}static phaseOf(e,t,i){const n=2*Math.PI*t*1e3/i;return n*n/(4*Math.PI)*ot.airy(n*Math.sin(e))}static phase(e,t,i){let n=0,s=0;for(const{radiusUm:r,weight:o}of ot.radiiOf(i))n+=o*ot.phaseOf(e,r,t),s+=o;return n/s}static profile(e){const t=`${e.medianRadiusUm}:${e.geometricSigma}`,i=ot.profiles.get(t);if(i)return i;const n=ot.STEPS,s=new Float32Array(n*3),r=ot.radiiOf(e),o=r.reduce((c,{weight:l})=>c+l,0);for(let c=0;c<n;c++){const l=c/(n-1)*ot.MAX_ANGLE_RAD;let h=0,u=0,d=0;for(const f of ci.SAMPLES){let p=0;for(const{radiusUm:v,weight:m}of r)p+=m*ot.phaseOf(l,v,f.wavelengthNm);p/=o,h+=p*f.r,u+=p*f.g,d+=p*f.b}s[c*3]=h,s[c*3+1]=u,s[c*3+2]=d}return ot.profiles.set(t,s),s}static profiles=new Map;static radiiOf(e){const t=ot.RADII,i=Math.log(Math.max(e.geometricSigma,1.0001)),n=[];for(let s=0;s<t;s++){const r=-3+6*(s+.5)/t;n.push({radiusUm:e.medianRadiusUm*Math.exp(r*i),weight:Math.exp(-.5*r*r)})}return n}static illuminanceOf(e){return 10**((-14.18-e)/2.5)}static aureoleScale(e,t){const i=e*t;return ot.DIFFRACTED_SHARE*ot.COARSE_FRACTION*i*Math.exp(-i)}static coronaScale(e){return ot.DIFFRACTED_SHARE*e*Math.exp(-e)}static airMass(e){const t=Math.max(e,0);return 1/(Math.sin(t*Math.PI/180)+.50572*(t+6.07995)**-1.6364)}}class f0{static RADIUS=Ti.RADIUS;object;texels;texture;up=new D(0,1,0);towards=new D;constructor(){const e=ot.STEPS;this.texels=new Uint16Array(e*4),this.texture=new $s(this.texels,e,1,_i,kt),this.texture.minFilter=st,this.texture.magFilter=st,this.texture.wrapS=yi,this.texture.wrapT=yi,this.texture.needsUpdate=!0;const t=new at({uniforms:{uSource:{value:new D(0,1,0)},uMaxAngle:{value:ot.MAX_ANGLE_RAD},uMap:{value:this.texture},uSteps:{value:e}},vertexShader:`
|
|
6918
6926
|
varying vec3 vDirection;
|
|
6919
6927
|
void main() {
|
|
6920
6928
|
vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
|
|
@@ -6935,7 +6943,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
|
|
|
6935
6943
|
vec3 light = texture2D(uMap, vec2((along * (uSteps - 1.0) + 0.5) / uSteps, 0.5)).rgb;
|
|
6936
6944
|
gl_FragColor = vec4(light, 1.0);
|
|
6937
6945
|
}
|
|
6938
|
-
`,transparent:!0,blending:Di,depthWrite:!1,side:Ot,fog:!1});this.object=new De(new jt(f0.RADIUS,128,32,0,Math.PI*2,0,ot.MAX_ANGLE_RAD),t),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}show(e,t){if(!e||!t){this.object.visible=!1;return}this.towards.set(e.x,e.y,e.z).normalize(),this.object.quaternion.setFromUnitVectors(this.up,this.towards),this.object.material.uniforms.uSource.value.copy(this.towards);for(let i=0;i<ot.STEPS;i++){for(let n=0;n<3;n++)this.texels[i*4+n]=Dn.toHalfFloat(Math.min(t[i*3+n],6e4));this.texels[i*4+3]=Dn.toHalfFloat(1)}this.texture.needsUpdate=!0,this.object.visible=!0}dispose(){this.object.geometry.dispose(),this.object.material.dispose(),this.texture.dispose()}}class pl{constructor(e){this.generator=e}static SIZE=128;target=new wo(pl.SIZE,{type:Ft,generateMipmaps:!1,minFilter:st,magFilter:st});camera=new Zd(.1,2e5,this.target);filteredTarget;capturedAtMs=-1/0;capturedVersion;get sharp(){return this.target.texture}get filtered(){return this.filteredTarget?.texture}capture(e,t,i,n=[]){const s=e.shadowMap.autoUpdate;e.shadowMap.autoUpdate=!1;const r=n.map(o=>o.visible);for(const o of n)o.visible=!1;this.camera.position.copy(i),this.camera.update(e,t),n.forEach((o,c)=>{o.visible=r[c]}),e.shadowMap.autoUpdate=s,this.filteredTarget=this.generator.fromCubemap(this.target.texture,this.filteredTarget),this.capturedAtMs=performance.now()}dispose(){this.target.dispose(),this.filteredTarget?.dispose()}}class Ji{static REFRESH_MS=250;generator;eye;probes=new Map;constructor(e){Ji.install(),this.generator=new qu(e),this.eye=new pl(this.generator)}static decor;refresh(e,t,i,n,s,r,o,c=[],l){for(const v of[...this.probes.keys()])n.some(m=>m.id===v&&m.shiny)||(this.probes.get(v).dispose(),this.probes.delete(v));const h=[{probe:this.eye}];for(const v of n){if(!v.shiny)continue;let m=this.probes.get(v.id);m||(m=new pl(this.generator),this.probes.set(v.id,m)),h.push({probe:m,reflector:v})}const u=performance.now(),d=()=>h.filter(({probe:v})=>v.capturedVersion!==o),f=d().filter(({probe:v})=>u-v.capturedAtMs>=Ji.REFRESH_MS);if(f.length>0){const v=f.reduce((m,g)=>g.probe.capturedAtMs<m.probe.capturedAtMs?g:m);if(v.reflector){const m=v.reflector.holder.getWorldPosition(this.scratch);v.probe.capture(e,t,m,[v.reflector.holder,...s]),Ji.reflectOn(v.reflector.holder,v.probe)}else{v.probe.capture(e,t,i,[...s,...c]),l?.(v.probe.sharp),Ji.decor=v.probe.filtered;for(const m of r)Ji.reflectOn(m,v.probe);for(const m of n)m.shiny||Ji.reflectOn(m.holder,v.probe)}v.probe.capturedVersion=o}const p=d();if(p.length!==0)return Math.max(16,Math.min(...p.map(({probe:v})=>Ji.REFRESH_MS-(u-v.capturedAtMs))))}scratch=new D;static reflectOn(e,t={filtered:Ji.decor}){e.traverse(i=>{const n=i.material;for(const s of Array.isArray(n)?n:n?[n]:[])s instanceof Eo?t.sharp&&s.setSurroundings(t.sharp):s instanceof oa&&t.filtered&&s.envMap!==t.filtered&&(s.envMap=t.filtered,s.needsUpdate=!0)})}dispose(){this.eye.dispose();for(const e of this.probes.values())e.dispose();this.generator.dispose()}static installed=!1;static install(){if(Ji.installed)return;Ji.installed=!0;const e="iblIrradiance += getIBLIrradiance( geometryNormal );";if(!We.lights_fragment_maps.includes(e)){console.warn("Reflections: three's lights_fragment_maps changed; the environment will light diffusely too");return}We.lights_fragment_maps=We.lights_fragment_maps.replace(e,"// The sky's diffuse light is the hemisphere light's (see Reflections).")}}function jw(a,e){return JSON.stringify(a.cloudLayers)===JSON.stringify(e.cloudLayers)&&a.cloudCover===e.cloudCover&&a.cloudDarkness===e.cloudDarkness&&a.cloudBaseM===e.cloudBaseM&&a.highCloudCover===e.highCloudCover&&a.iceCrystalAlignment===e.iceCrystalAlignment&&a.lowerCloudCover===e.lowerCloudCover&&a.relativeHumidity===e.relativeHumidity&&a.precipitationType===e.precipitationType&&a.precipitationIntensity===e.precipitationIntensity&&a.windDirectionDeg===e.windDirectionDeg&&a.windSpeed===e.windSpeed&&a.storm===e.storm}const Ac=900,Oh=1,$p=4,Zp=5,Jp=.5,to=900,Qw=6371e3,eb=3e4;function jp(a){const e=Math.sqrt(2*Qw*Math.max(a,0));return Math.max(to,Math.min(e,eb))}const Uh=.5,Fh=850,Qp=.03,cn=850,kh=300,tb=.04,qr=4,zh=1.5,em=-1,ib=6,bd=-4,nb=2,Tc=2600,sb=.97,ab=.38,Rc=bd,tm=1500,rb=400,ob=[0,45,90,135,180,225,270,315],cb={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},lb=["en","fr"],hb=2,ub=16,im=2500,nm=880,Dc=40,sm=60,db=10,fb=1,pb=150,mb=55,gb=.5,vb=17,am=.265,rm=[[0,0],...Array.from({length:8},(a,e)=>{const t=e*Math.PI/4;return[Math.cos(t)*am,Math.sin(t)*am]})],Hh=700,Bh=250/1e3,Mb=12,om=5,Gh=6,na=[.92,.92,.95],Vh=[.15,.15,.19],cm={snow:{fallSpeedMPerS:2,size:.3,color:new se(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new se(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},er=0,Wh=0,xb=150,lm=3e3,Yr=20,yb=15,hm=er,_b=40,um=1,Sb=9;function dm(a){return um+(Sb-um)*a}const fm=new se(.75,.82,.92),wb=10,bb=.5;function Eb(a){return sr(a/wb,bb,1)}const Ja=200,pm=.18,mm=.32,Ab=.35,gm=new se(.85,.9,.98),vm=5,Mm=.85,xm=.01;function Xh(a,e){return Math.round(a*(xm+(1-xm)*e))}const ym=230,_m=.7,Sm=.05,Tb=.6,Rb=.7,Db=.15,wm=.35,Cb=3,Ib=1/12,Pb=.5,kn=new se(.82,.86,1),Lb=2500,Nb=1.6,qh=15,Ob={Venus:new se(1,.96,.85),Mars:new se(1,.55,.4),Jupiter:new se(.95,.87,.72),Saturn:new se(.92,.86,.68)};class Vt{renderer;scene=new xs;phenomena=new wn(this.scene);references=new ua(this.scene,()=>this.render());camera;celestialGroup=new Dt;skyMesh;skyGradientMaterial;scatteredSky;lastAstronomy;skyColoursStale=!1;scatteredSkyFrameId=null;skyHoldUntilMs=void 0;onFirstFrameHold;firstFrameReady(){return(!this.scatteredSky||this.scatteredSky.ambient!==void 0)&&!this.iceHalos?.awaitingFirstDisplay}groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;roadSystem=new ln;roadAttribution;roadWays;statedRoads=[];decorModelProvider=$w[0].create();decorModelToken=0;decorModelCredits=new Map;bodySystem=new ct(e=>this.loadBodyModel(e),()=>this.render(),()=>this.relativeScale);bodyOrigin={x:0,z:0};starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;decorReferencePose;decorCurrentPose;decorTime=0;celestialLight=new Gf(16777215,0);celestialLightTarget=new Pt;skyLight=new AM(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;resolution;cssSize={width:1,height:1};frameDirty=!1;flushFrameId=null;framesDriven=!1;lastFrameTimeMs;raycaster=new ph;weather=Pm;observerElevationM=0;siteElevationM=0;air=new dn;groundRadius=to;terrainRadius=to;cloudRendering="volume";layeredClouds;cloudLayerOffsetsM={};cloudOffsetM=new D;cloudFieldOffset=new D;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new D;rainLastVerticalFacing=-1;rainViewportSize=new xe;lightningArmed=!1;lightningFlashes=[];lightningLevel=0;lightningBolt;lightningLight=new Gf(16777215,0);baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new D;sunVisible=!1;lensFlareScratch=new D;sunOcclusionRaycaster=new ph;sunOcclusionDirectionScratch=new D;sunOcclusionRightScratch=new D;sunOcclusionUpScratch=new D;ufoOcclusionRaycaster=new ph;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;finishPass;exposureAccumulation;exposureInstants=1;get developingExposure(){return this.exposureInstants>1&&this.exposureInstantAt!==void 0}static EXPOSURE_BUDGET_MS=12;static exposureInstantsPerFrame(e){return Math.max(3,Math.round(6e6/Math.max(1,e)))}exposureFrameId=null;exposureInstantsDone=0;exposureInstantAt;restatingExposure=!1;lensOptics;instrumentMagnitudeGain=0;meteorSystem;cometTail;satelliteField;iceHalos;lunarDiffraction;lunarDiffractionKey="";rainbow;skyGlow;cometKey;novaKeys=new Set;constructor(e,t=R2()){this.renderer=new OS({canvas:e,antialias:!0}),this.resolution=new dt(Math.min(window.devicePixelRatio||1,2),this.renderer.getContext()),this.renderer.setPixelRatio(this.resolution.pixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=io,this.camera=new Vi(60,e.width/Math.max(e.height,1),.1,Ac*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=t,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=cn-kh,this.celestialLight.shadow.camera.far=cn+kh,this.celestialLight.shadow.bias=-.03/(2*kh),this.celestialLight.shadow.normalBias=tb,this.celestialLight.target=this.celestialLightTarget,this.lightningLight.color.copy(kn),this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight,this.lightningLight),this.scene.add(this.celestialGroup),this.scene.add(this.bodySystem.group),this.scene.add(this.roadSystem.group);const i=new ti(this.renderer,()=>{this.skyColoursStale=!0,this.render()});i.supported?this.scatteredSky=i:i.dispose()}get currentTerrainAttribution(){return this.terrainAttribution}get currentRoadAttribution(){return this.roadAttribution}resize(e,t){this.cssSize.width=e,this.cssSize.height=t,this.renderer.setSize(e,t,!1),this.camera.aspect=e/Math.max(t,1),this.camera.updateProjectionMatrix(),this.render()}setCloudRendering(e){e!==this.cloudRendering&&(this.cloudTransmissionMemo.clear(),this.cloudRendering=e,this.layeredClouds?.dispose(),this.layeredClouds=void 0,this.buildClouds(),this.buildCirrus(),this.render())}setCloudOffset(e,t={}){this.cloudOffsetM.set(e.x,0,e.z),this.cloudLayerOffsetsM=t,this.layeredClouds?.setOffsets(e,t),this.cloudFieldOffset.set(e.x*Bh,0,e.z*Bh);for(const i of[this.cloudUniforms,this.cirrusUniforms])i?.fieldOffset.value.copy(this.cloudFieldOffset);this.iceHalos?.setCloudOffset(this.layeredClouds?.cirrusMask?.offset??this.cloudFieldOffset)}setObserverPose(e){const t=((e.rollDeg??0)+this.gaitOffset.rollDeg)*Hi,i=(e.pitchDeg+this.lookPitchDeg+this.gaitOffset.pitchDeg)*Hi;if(e.headingDeg!==void 0?this.camera.rotation.set(i,-(e.headingDeg+this.lookYawDeg+this.gaitOffset.yawDeg)*Hi,t,"YXZ"):this.camera.rotation.set(i,this.camera.rotation.y,t,"YXZ"),e.elevationM!==this.observerElevationM&&(this.observerElevationM=e.elevationM,this.syncCloudLayer(),Math.abs(jp(e.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/to),this.camera.far=Math.max(Ac*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.terrainMesh&&this.terrainOrigin&&e.lat!==void 0&&e.lng!==void 0){const n=ci(this.terrainOrigin.lat,this.terrainOrigin.lng,e.lat,e.lng);this.terrainMesh.position.x=n.x,this.terrainMesh.position.z=n.z}this.poseCameraY=this.groundYUnder(0,0)+1.6+e.elevationM,this.camera.position.y=this.poseCameraY,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.roadSystem.clear(),this.roadAttribution=void 0,this.roadWays=void 0,this.applyGroundDepthWrite(),this.terrainBuildToken++}setTerrainOrigin(e,t,i){if(e===void 0||t===void 0)return;const n=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-n)<n*.1){const{x:c,z:l}=ci(e,t,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(c*c+l*l)<pb*(n/to))return}const s=this.terrainOrigin,r=this.terrainRadius;(!s||s.lat!==e||s.lng!==t)&&(this.roadSystem.clear(),this.roadAttribution=void 0),this.terrainOrigin={lat:e,lng:t},this.terrainRadius=n;const o=++this.terrainBuildToken;hw(e,t,this.terrainProviders,n).then(({mesh:c,attribution:l,originElevationM:h})=>{if(o!==this.terrainBuildToken)return;this.setSiteElevation(h??0);const u=this.terrainMesh,d=s?ci(e,t,s.lat,s.lng):void 0;u&&d&&Math.hypot(d.x,d.z)<=r&&(c.position.y=u.position.y+this.groundYOfPatch(u,d.x,d.z)),this.disposeMesh(this.terrainMesh),c.renderOrder=fb,this.terrainMesh=c,this.compileNextFrameOffThread(),this.terrainAttribution=l,this.scene.add(c),this.applyGroundDepthWrite(),this.decorCurrentPose&&(this.setObserverPose(this.decorCurrentPose),this.updateDecorAnchoring(this.decorReferencePose,this.decorCurrentPose,this.decorTime)),this.buildRoads(e,t,n),this.drapeStatedRoads(),this.render(),i?.()}).catch(c=>{console.warn("Terrain build failed, keeping the flat ground fallback:",c),i?.()})}static ROADS_MAX_RADIUS_M=5e3;buildRoads(e,t,i){const n=this.terrainProviders.roads;if(!n||i>Vt.ROADS_MAX_RADIUS_M){this.roadSystem.clear(),this.roadAttribution=void 0;return}const s=this.roadWays;if(s&&s.lat===e&&s.lng===t&&s.radiusM===i){this.drapeRoads(s.ways,e,t,n.contemporary);return}n.getRoads(a1(e,t,i)).then(r=>{this.terrainOrigin?.lat!==e||this.terrainOrigin?.lng!==t||(this.roadWays={lat:e,lng:t,radiusM:i,ways:r},this.drapeRoads(r,e,t,n.contemporary))}).catch(r=>{console.warn("Roads unavailable, drawing none:",r)})}setStatedRoads(e){e!==this.statedRoads&&(this.statedRoads=e,this.drapeStatedRoads(),this.render())}drapeStatedRoads(){const e=this.terrainMesh;e&&(this.roadSystem.group.position.copy(e.position),this.roadSystem.setStated(this.statedRoads,(t,i)=>this.groundYOfPatch(e,t,i)))}drapeRoads(e,t,i,n){const s=this.terrainMesh;s&&(this.roadSystem.group.position.copy(s.position),this.roadSystem.set(e,t,i,(r,o)=>this.groundYOfPatch(s,r,o),n),this.roadAttribution=e.length>0?this.terrainProviders.roads?.attribution:void 0,this.compileNextFrameOffThread(),this.render())}setShowCompass(e){this.showCompass!==e&&(this.showCompass=e,this.disposeCompassLabels(),e&&this.buildCompassLabels(),this.render())}applyLensFlareTint(e){if(!this.lensFlare)return;const t=mb*(this.sunArriving[1]/vb);this.lensFlare.uniforms.uColorGain.value.setRGB(t*e[0],t*e[1],t*e[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const[e,t,i]=this.sunArriving,n=Math.max(t,1e-30);this.lensFlare.uniforms.uDazzleColour.value.setRGB(e/n,1,i/n),this.lensFlare.uniforms.uVeilStrength.value=Ui.K*t*this.sunUnhiddenFraction}sunArriving=[0,0,0];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;if(this.compassSprites.some(t=>t.visible!==e)){for(const t of this.compassSprites)t.visible=e;this.developingExposure?this.exposureInstantsDone>0&&this.presentExposure():this.render()}}setWeather(e){this.cloudTransmissionMemo.clear(),!jw(this.weather,e)&&(this.weather=e,this.air=dn.of(e),this.applyAir(),this.scatteredSky?.setConditions({aerosolOpticalDepth:e.relativeHumidity===void 0?void 0:Vs.steppedOpticalDepth(e.relativeHumidity)}),this.pumpScatteredSky(),this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lastAstronomy&&(this.buildIceHalos(this.lastAstronomy.sun,this.lastAstronomy.moon),this.buildRainbow(this.lastAstronomy.sun,this.lastAstronomy.moon),this.buildLunarDiffraction(this.lastAstronomy.moon)),this.lightningArmed=e.storm&&e.cloudDarkness>=Pb,this.syncAnimationLoop(),this.render())}setDecor(e){if(this.decorObjects!==e){this.decorObjects=e,this.decorModelToken++,this.decorModelCredits.clear();for(const t of this.decorGroups.values())t.removeFromParent(),gi.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear();for(const t of e){const i=gi.build(t,t.lit??!1);this.scene.add(i),this.decorGroups.set(t.id,i),t.kind==="streetlight"&&this.addStreetlightLight(t.id,i),this.loadDecorModel(t,this.decorModelToken)}this.celestialLight.castShadow=this.decorGroups.size>0||this.bodySystem.any}}setDecorModelProvider(e){this.decorModelProvider=e;const t=this.decorObjects;this.decorObjects=[],this.setDecor(t)}get currentDecorModelCredits(){return[...this.decorModelCredits.values(),...this.bodySystem.modelCredits]}get bodyGround(){const{x:e,z:t}=this.bodyOrigin,i=this.groundYUnder(e,t);return{heightAt:(n,s)=>this.groundYUnder(e+n,t-s)-i}}setBodies(e,t=0,i=e.map(r=>r.id),n=[],s){const{x:r,z:o}=this.bodyOrigin,c=this.scatteredSky;this.bodySystem.set(e,{originX:r,originZ:o,originGroundY:this.groundYUnder(r,o),eye:this.camera.position,groundYAt:(h,u)=>this.groundYUnder(h,u),wind:s,light:this.plumeLight(),transmittance:(h,u,d)=>this.transmittanceTo(h,u,d)},t,c?(h,u)=>c.relativeOfLuminance(h,u):void 0,i),this.bodySystem.setSmoke(n,t),this.bodySystem.any&&(this.celestialLight.castShadow=!0);const l=this.bodySystem.furthestFrom(this.camera.position)*1.2;l>this.camera.far&&(this.camera.far=l,this.camera.updateProjectionMatrix())}plumeLight(){const e=this.celestialLight.color,t=this.celestialLight.intensity*.5,i=this.skyLight.color,n=this.skyLight.groundColor,s=this.skyLight.intensity,r=(o,c,l)=>(o*t+(c+l)/2*s)/Math.PI;return[r(e.r,i.r,n.r),r(e.g,i.g,n.g),r(e.b,i.b,n.b)]}bodyOutline(e,t){return this.bodySystem.outlineOf(e,t)}async loadBodyModel(e){const t=e.url?void 0:e.id?await this.decorModelProvider.entry(e.id):void 0,i=e.url??t?.url,n=e.credit??t?.credit;if(!(!i||!n))return{scene:await Kp(i),credit:n,headingOffsetDeg:e.headingOffsetDeg??t?.headingOffsetDeg}}async loadDecorModel(e,t){const i=e.model;if(!(!i||!gi.usesModel(e)))try{const n=i.url?void 0:i.id?await this.decorModelProvider.entry(i.id):void 0,s=i.url??n?.url,r=i.credit??n?.credit;if(!s||!r)return;const o=await Kp(s);if(t!==this.decorModelToken)return;const c=this.decorGroups.get(e.id);if(!c)return;Ji.reflectOn(o),gi.applyModel(c,e,o,{headingOffsetDeg:i.headingOffsetDeg??n?.headingOffsetDeg,depictedSizeM:n?.sizeM}),this.decorModelCredits.set(e.id,r),this.render()}catch(n){console.warn(`Keeping the built-in shape for decor "${e.id}":`,n)}}updateDecorAnchoring(e,t,i=0){this.decorReferencePose=e,this.decorCurrentPose=t,this.decorTime=i;const n=e?.lat!==void 0&&e.lng!==void 0&&t?.lat!==void 0&&t?.lng!==void 0?ci(e.lat,e.lng,t.lat,t.lng):{x:0,z:0},s=this.decorObjects.find(l=>l.witnessSide!==void 0&&Um(l.kind));if(this.terrainMesh&&this.terrainOrigin&&t?.lat!==void 0&&t.lng!==void 0){const l=ci(this.terrainOrigin.lat,this.terrainOrigin.lng,t.lat,t.lng);this.terrainMesh.position.x=l.x-(s?0:this.gaitOffset.eastM),this.terrainMesh.position.z=l.z+(s?0:this.gaitOffset.northM),this.roadSystem.group.position.copy(this.terrainMesh.position)}s||(n.x-=this.gaitOffset.eastM,n.z+=this.gaitOffset.northM,this.camera.position.y=this.poseCameraY+this.gaitOffset.upM,this.celestialGroup.position.y=this.camera.position.y);const r={x:0,z:0};let o=0;if(s){const l=gi.occupantView(s),h=-(s.headingDeg??0)*Hi,u=l.x*Math.cos(h)+l.z*Math.sin(h),d=-l.x*Math.sin(h)+l.z*Math.cos(h),f=s.eastM+n.x,p=-s.northM+n.z;r.x=-(f+u),r.z=-(p+d),this.camera.position.y=this.groundYUnder(f,p)+l.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*Hi,-(l.headingDeg+this.indoorLookYawDeg)*Hi,0,"YXZ")}this.bodyOrigin={x:n.x+r.x,z:n.z+r.z};for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=Ad(l,i),d=u.eastM+n.x+r.x,f=-u.northM+n.z+r.z,p=this.terrainMesh,v=`${p?.geometry.uuid}:${(d-(p?.position.x??0)).toFixed(3)}:${(f-(p?.position.z??0)).toFixed(3)}:${(p?.position.y??0).toFixed(3)}:${u.headingDeg}:${u.altitudeM}`;if(h.userData.footprintKey!==v&&(h.userData.footprintGroundY=this.groundUnderFootprint(l,d,f,u.headingDeg,u.altitudeM),h.userData.footprintKey=v),h.position.set(d,h.userData.footprintGroundY+u.altitudeM,f),l.kind==="crop"){const m=Math.hypot(d,f);h.visible=m<=xb}if(u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*Hi),l.kind==="crop"&&h.visible){const m=this.terrainMesh,g=[m?.geometry.uuid,d-(m?.position.x??0),f-(m?.position.z??0),h.position.y-(m?.position.y??0),u.headingDeg,u.altitudeM].map(_=>typeof _=="number"?_.toFixed(4):_).join(":");h.userData.cropGroundKey!==g&&(gi.fitCropToGround(h,(_,w)=>this.groundYUnder(_,w)+u.altitudeM),h.userData.cropGroundKey=g)}o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(Ac*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-c)>1&&(this.camera.far=c,this.camera.updateProjectionMatrix())}groundYUnder(e,t){const i=this.terrainMesh;return i?i.position.y+this.groundYOfPatch(i,e-i.position.x,t-i.position.z):Wh}groundYOfPatch(e,t,i){const n=e.geometry.getAttribute("position"),s=Math.round(Math.sqrt(n.count));if(s<2||s*s!==n.count)return Wh;const r=n.getX(0),o=n.getX(s-1),c=n.getZ(0),l=n.getZ((s-1)*s),h=sr((t-r)/(o-r)*(s-1),0,s-1),u=sr((i-c)/(l-c)*(s-1),0,s-1);if(!Number.isFinite(h)||!Number.isFinite(u))return Wh;const d=Math.min(Math.floor(h),s-2),f=Math.min(Math.floor(u),s-2),p=h-d,v=u-f,m=(S,b)=>n.getY(S*s+b),g=m(f,d),_=m(f,d+1),w=m(f+1,d),M=m(f+1,d+1);return p+v<=1?g+(_-g)*p+(w-g)*v:M+(w-M)*(1-p)+(_-M)*(1-v)}groundUnderFootprint(e,t,i,n,s=0){return gi.groundUnderFootprint(e,t,i,n,(r,o)=>this.groundYUnder(r,o),s)}lookYawDeg=0;lookPitchDeg=0;poseCameraY=1.6;setGait(e){this.gaitOffset=e}gaitOffset={eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0};setLookOffset(e,t){this.lookYawDeg=e,this.lookPitchDeg=t}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(e,t){this.indoorLookYawDeg=e,this.indoorLookPitchDeg=t}updateDecorLitState(e,t=0){for(const i of this.decorObjects){const n=this.decorGroups.get(i.id);if(n&&i.lights?.length&&gi.setLights(n,i.lights,e,n.position.distanceTo(this.camera.position),t,this.relativeScale),i.kind!=="streetlight"&&i.kind!=="vehicle")continue;const s=this.decorGroups.get(i.id);if(!s)continue;const r=l2(i,e);gi.setLit(s,i.kind,r,this.relativeScale);const o=this.streetlightLights.get(i.id);o&&(o.visible=r)}}addStreetlightLight(e,t){const i=gi.bodyOf(t),n=i.children.find(r=>r.userData.emissive);if(!n)return;const s=new Eg(16764006,tm*this.relativeScale,rb);s.position.copy(n.position).multiply(i.scale),s.castShadow=!0,s.shadow.mapSize.set(512,512),s.shadow.bias=-.002,t.add(s),this.streetlightLights.set(e,s)}setAstronomy(e){(!this.lastAstronomy||Math.abs(this.lastAstronomy.sun.altitudeDeg-e.sun.altitudeDeg)>2)&&(this.surroundings=void 0,this.scatteredSky?.resetSurroundings()),this.lastAstronomy=e,this.scatteredSky?.update(this.scatteredSkyState(e)),this.skyHoldUntilMs===void 0&&(this.skyHoldUntilMs=performance.now()+im,this.onFirstFrameHold?.(!0),setTimeout(()=>this.render(),im+20)),this.pumpScatteredSky(),this.lastSunPosition=e.sun,this.buildSky(e.sun),this.buildGround();const t=Gc(e.sun.altitudeDeg,this.instrumentMagnitudeGain);this.buildStars(e.stars,t),this.placeBodies(e,t),this.buildIceHalos(e.sun,e.moon),this.buildRainbow(e.sun,e.moon),this.applySkyColours(e),this.syncAnimationLoop(),this.render()}static relativeSkyOf(e,t){const i=r=>{const o=Tn.luminanceOf(r);if(!(o>0))return[0,0,0];const c=Ee.relativeOfResponse(o)/o;return[r[0]*c,r[1]*c,r[2]*c]},n=i(e.zenith),s=i(e.horizon);return{zenith:n,horizon:s,airlight:s,skyIrradiance:[n[0]*Math.PI,n[1]*Math.PI,n[2]*Math.PI],scale:t}}placeBodies(e,t){this.bodiesScale=this.relativeScale,this.setBodyMesh("sun",e.sun,qr,new se(1,.96,.88),e.sun.magnitude),this.setMoonMesh(e.moon,t),this.buildPlanets(e.planets,t),this.buildComet(e.comet,t),this.buildNovae(e.novae??[],t)}bodiesScale=0;applySkyColours(e){this.skyColoursStale=!1,this.bodiesScale!==this.relativeScale&&(this.placeBodies(e,Gc(e.sun.altitudeDeg,this.instrumentMagnitudeGain)),this.applyDazzleStrength(),this.buildIceHalos(e.sun,e.moon),this.buildRainbow(e.sun,e.moon));const t=this.scatteredSky?.ambient??Vt.relativeSkyOf(td(e.sun.altitudeDeg),this.relativeScale),i=t,n=this.lightUnderClouds(e),s=r=>n?[0,1,2].map(o=>r[o]*n.through+n.radiance[o]*(1-n.through)):[r[0],r[1],r[2]];this.baseFogColor=[i.horizon[0],i.horizon[1],i.horizon[2]],this.airlight=s(i.airlight),this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.scatteredSky?.ready?this.scatteredSky.material:this.skyGradientMaterial),this.updateCelestialLight(e,t),this.updateCloudLighting(e.sun,this.baseFogColor),Ni.setEye(this.scatteredSky?.rodShare??0,this.relativeScale),this.updateTwinkle(this.twinkleSeconds);for(const r of this.streetlightLights.values())r.intensity=tm*this.relativeScale;this.buildSkyGlow(e,i.zenith),this.applyAir(),this.buildLunarDiffraction(e.moon)}reflections;sceneVersion=0;reflectionTimer;buildLunarDiffraction(e){const t=this.scatteredSky?.ready?this.scatteredSky:void 0;if(e.altitudeDeg<-.5||!t){this.lunarDiffraction?.show(void 0),this.lunarDiffractionKey="";return}const i=this.weather.relativeHumidity,n=(i===void 0?Oe.DEFAULT_AEROSOL_OPTICAL_DEPTH:Vs.opticalDepth(i))*Oe.aerosolDensity(this.siteElevationM+this.observerElevationM),s=this.cloudTransmission(e),r=-Math.log(Math.max(this.cloudTransmission(e,!0),1e-4)),o=ot.aureoleScale(n,ot.airMass(e.altitudeDeg))*s,c=ot.coronaScale(r),l=ot.illuminanceOf(e.magnitude),h=[e.altitudeDeg.toFixed(1),e.azimuthDeg.toFixed(1),e.magnitude.toFixed(2),o.toExponential(2),c.toExponential(2),Math.log10(Math.max(t.adaptation,1e-12)).toFixed(2)].join(":");if(h===this.lunarDiffractionKey)return;this.lunarDiffractionKey=h,this.lunarDiffraction||(this.lunarDiffraction=new f0,this.celestialGroup.add(this.lunarDiffraction.object));const u=ot.profile(ot.HAZE_COARSE_MODE),d=ot.profile(ot.CLOUD_DROPLETS),f=Mp(e.altitudeDeg),p=new Float32Array(ot.STEPS*3);let v=0;for(let w=0;w<ot.STEPS;w++){const M=w*3,S=[0,1,2].map(T=>l*f[T]*(o*u[M+T]+c*d[M+T])),b=Tn.shown(S,Tn.luminanceOf(S),(T,x)=>t.relativeOfLuminance(T,x));p.set(b,M),v=Math.max(v,Tn.response(b))}const{x:m,y:g,z:_}=ii(e.altitudeDeg,e.azimuthDeg,1);this.lunarDiffraction.show(v>1/200?{x:m,y:g,z:_}:void 0,p)}applyAir(){this.scene.fog instanceof Ma||(this.scene.fog=new Ma),this.scene.fog.setAir(this.air,this.siteElevationM,this.airlight),this.horizonColour.setRGB(this.baseFogColor[0],this.baseFogColor[1],this.baseFogColor[2])}airlight=[0,0,0];horizonColour=new se(0,0,0);transmittanceTo(e,t,i){const n=this.camera.position;return this.air.transmittance(this.siteElevationM+n.y,this.siteElevationM+t,Math.hypot(e-n.x,t-n.y,i-n.z))}setSiteElevation(e){Math.abs(e-this.siteElevationM)<1||(this.siteElevationM=e,this.applyAir(),this.lastAstronomy&&this.scatteredSky?.update(this.scatteredSkyState(this.lastAstronomy)))}scatteredSkyState(e){return{altitudeM:this.siteElevationM+this.observerElevationM+1.6,sun:{altitudeDeg:e.sun.altitudeDeg,azimuthDeg:e.sun.azimuthDeg,magnitude:e.sun.magnitude},moon:{altitudeDeg:e.moon.altitudeDeg,azimuthDeg:e.moon.azimuthDeg,magnitude:e.moon.magnitude,phaseAngleDeg:Ye.phaseAngleOf(e.moon.phase.illuminatedFraction)}}}pumpScatteredSky(){const e=this.scatteredSky;!e||e.tables.ready||this.scatteredSkyFrameId!==null||this.contextReleased||(this.scatteredSkyFrameId=requestAnimationFrame(()=>{this.scatteredSkyFrameId=null,!this.contextReleased&&(e.advance(this.skyHoldUntilMs?ub:hb),this.pumpScatteredSky())}))}cancelScatteredSkyPump(){this.scatteredSkyFrameId!==null&&(cancelAnimationFrame(this.scatteredSkyFrameId),this.scatteredSkyFrameId=null)}setSatellites(e){if(e.length===0&&!this.satelliteField?.count)return;this.satelliteField||(this.satelliteField=new Ew(Fh),this.celestialGroup.add(this.satelliteField.object));const t=Gc(this.lastSunPosition?.altitudeDeg??-90,this.instrumentMagnitudeGain);this.satelliteField.set(e,t,i=>this.cloudTransmission(i),(i,n)=>this.arrivingIlluminance(i,n,1)),this.render()}pickSatelliteAt(e,t){if(!this.satelliteField?.count)return;this.aimAtScreenPoint(this.raycaster,e,t);const i=Math.cos(Qp*this.camera.fov*Math.PI/180),n=this.satelliteField.nearest(this.raycaster.ray.direction,i);return n&&this.groundHides(e,t)?void 0:n}updateCelestialLight(e,t){const i=this.relativeScale,n=e.sun.altitudeDeg>=Rc,s=!n&&e.moon.altitudeDeg>=Rc,r=n?e.sun:e.moon,o=[0,0,0],c=Math.max(0,Math.sin(Math.max(r.altitudeDeg,0)*Hi)),l=n||s?this.cloudTransmission(r):1,h=-Math.log(Math.max(l,1e-6)),u=Math.max(0,1/(1+.1125*h)-l),d=[0,0,0];if(n||s){const _=ot.illuminanceOf(r.magnitude)*i,w=this.air.transmittanceFromSpace(this.siteElevationM+this.observerElevationM,r.altitudeDeg);for(let T=0;T<3;T++)o[T]=_*w[T]*l,d[T]=_*w[T]*u*c,this.cloudBeam[T]=_*w[T];const{x:M,y:S,z:b}=ii(r.altitudeDeg,r.azimuthDeg,1);this.cloudBeamDirection.set(M,S,b)}else this.cloudBeam.fill(0);const f=this.surroundings;if(f)this.skyLight.color.setRGB(f.up[0]*i,f.up[1]*i,f.up[2]*i),this.skyLight.groundColor.setRGB(f.down[0]*i,f.down[1]*i,f.down[2]*i);else{const _=this.skyCloudTransmission(),w=t.skyIrradiance,M=[0,1,2].map(b=>w[b]*_+d[b]);this.skyLight.color.setRGB(M[0],M[1],M[2]);const S=Ge.GROUND_ALBEDO;this.skyLight.groundColor.setRGB(S*(M[0]+o[0]*c),S*(M[1]+o[1]*c),S*(M[2]+o[2]*c))}if(this.skyLight.intensity=1,!n&&!s){this.celestialLight.intensity=0;return}const{x:p,y:v,z:m}=ii(r.altitudeDeg,r.azimuthDeg,cn);this.celestialLight.position.set(p,v,m);const g=Math.max(o[0],o[1],o[2],1e-30);this.celestialLight.color.setRGB(o[0]/g,o[1]/g,o[2]/g),this.celestialLight.intensity=g,this.celestialLight.castShadow=this.decorGroups.size>0||this.bodySystem.any}skyCloudTransmission(){let e=this.cloudTransmission({altitudeDeg:90,azimuthDeg:0}),t=1;for(const i of[20,45,70]){const n=i*Hi,s=Math.sin(n)*Math.cos(n)*2;for(let r=0;r<360;r+=60)e+=s*this.cloudTransmission({altitudeDeg:i,azimuthDeg:r}),t+=s}return e/t}cloudBeam=[0,0,0];cloudBeamDirection=new D(0,1,0);get relativeScale(){return this.scatteredSky?.relativeScale??1/Ee.semiSaturation(Ee.DAYLIGHT_ANCHOR_CD_M2)}setMeteorShower(e,t,i){this.meteorSystem||(this.meteorSystem=new fi,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(e,t,i)}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=ai.starPointsOf(e),i=ai.flareArtifactsOf(e);t===this.starPoints&&i===this.lensFlareArtifactIntensity||(this.starPoints=t,this.lensFlareArtifactIntensity=i,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=t,this.lensFlare.uniforms.uFlareIntensity.value=i),this.render())}setInstrumentGain(e,t=!1){this.instrumentMagnitudeGain=Number.isFinite(e)?e:0,this.scatteredSky?.setInstrument(t,this.instrumentMagnitudeGain)}render(){this.restatingExposure||(this.sceneVersion++,this.frameDirty=!0,this.resolution.noteChange(performance.now()),!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()})))}drawIfDirty(){if(!(!this.frameDirty||this.contextReleased)){if(this.skyHoldUntilMs){if(!this.firstFrameReady()&&performance.now()<this.skyHoldUntilMs)return;this.skyHoldUntilMs=null,this.iceHalos?.setUrgent(!1),this.onFirstFrameHold?.(!1)}if(this.skyColoursStale&&this.lastAstronomy&&this.applySkyColours(this.lastAstronomy),this.compileBeforeNextDraw){this.compileBeforeNextDraw=!1;const e=this.compileOffThread().then(()=>{this.compiling===e&&(this.compiling=void 0,this.render())});this.compiling=e;return}if(!this.compiling){this.frameDirty=!1,this.refreshReflections(),this.resolution.beginDrawing();try{this.renderOnce()}finally{this.resolution.endDrawing()}this.developingExposure&&this.startExposure()}}}compileBeforeNextDraw=!1;compiling;static COMPILE_WAIT_MS=1500;compileOffThread(){const e=this.renderer.compile(this.scene,this.camera);if(!this.renderer.extensions.get("KHR_parallel_shader_compile"))return Promise.resolve();const t=this.renderer.properties,i=performance.now()+Vt.COMPILE_WAIT_MS;return new Promise(n=>{const s=()=>{if(this.contextReleased)return n();for(const r of e){const o=t.get(r)?.currentProgram;(!o||o.isReady())&&e.delete(r)}e.size===0||performance.now()>i?n():setTimeout(s,10)};s()})}compileNextFrameOffThread(){this.compileBeforeNextDraw=!0}contextReleased=!1;releaseContext(){this.contextReleased||(this.contextReleased=!0,this.stopTwinkle(),this.cancelFlush(),this.cancelExposure(),this.compiling=void 0,this.cancelScatteredSkyPump(),this.renderer.forceContextLoss())}restoreContext(){this.contextReleased&&(this.contextReleased=!1,this.renderer.forceContextRestore(),this.scatteredSky?.invalidate(),this.pumpScatteredSky(),this.compileNextFrameOffThread(),this.syncAnimationLoop(),this.render())}cancelFlush(){this.flushFrameId!==null&&(cancelAnimationFrame(this.flushFrameId),this.flushFrameId=null)}frame(e){if(this.animationsRunning){const t=this.lastFrameTimeMs===void 0?0:e-this.lastFrameTimeMs;this.lastFrameTimeMs=e,this.hasAnimations()&&this.animate(e,t);const i=this.resolution.ratioFor(e,t);i!==this.renderer.getPixelRatio()&&this.applyPixelRatio(i)}this.drawIfDirty()}refreshReflections(){this.reflections??=new Ji(this.renderer);const e=[...this.compassSprites,...this.lensFlare?[this.lensFlare.mesh]:[],...[...this.glareSprites.values()].map(s=>s.mesh)],t=[...this.starTiers.map(s=>s.points),...[...this.bodyMeshes.values()].filter(s=>s instanceof us)],i=this.relativeScale,n=this.reflections.refresh(this.renderer,this.scene,this.camera.position,this.bodySystem.reflectors,e,[...this.decorGroups.values()],this.sceneVersion,t,s=>this.measureSurroundings(s,i));n===void 0||this.reflectionTimer||(this.reflectionTimer=setTimeout(()=>{this.reflectionTimer=void 0,this.frameDirty=!0,!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()}))},n))}measureSurroundings(e,t){const i=this.lastAstronomy;if(!i)return;this.probeIrradiance??=new oo;const n=[i.sun,i.moon].filter(s=>s.altitudeDeg>-2).map(s=>ii(s.altitudeDeg,s.azimuthDeg,1));this.probeIrradiance.measure(this.renderer,e,n,s=>{const r=d=>d.map(f=>f/t),o=this.surroundings,c={up:r(s.up),down:r(s.down)},l=(d,f)=>d.some((p,v)=>Math.abs(p-f[v])>.03*Math.max(Math.abs(p),Math.abs(f[v]),1e-12)),h=!o||l(o.up,c.up)||l(o.down,c.down);h&&(this.surroundings=c);const u=this.scatteredSky?.adaptToSurroundings(Math.exp(s.logAverage)/t)??!1;!h&&!u||(this.skyColoursStale=!0,this.render())})}lightUnderClouds(e){const t=this.surroundings;if(!t)return;const i=e.sun.altitudeDeg>=Rc?e.sun:e.moon.altitudeDeg>=Rc?e.moon:void 0;if(!i)return;const n=this.relativeScale/Math.PI;return{through:this.cloudTransmission(i),radiance:[t.up[0]*n,t.up[1]*n,t.up[2]*n]}}probeIrradiance;surroundings;animate(e,t){const i=Math.min(t/1e3,Ib);this.twinkleSeconds=e/1e3,this.updateTwinkle(this.twinkleSeconds),this.updatePrecipitation(e/1e3,i),this.updateRain(i),this.lensFlare&&(this.lensFlare.uniforms.uTime.value=e/1e3),this.developingExposure||(this.frameDirty=!0)}setMaxPixelRatio(e){this.resolution.maximum=e,this.renderer.getPixelRatio()>this.resolution.maximum&&this.applyPixelRatio(this.resolution.maximum)}applyPixelRatio(e){this.renderer.setPixelRatio(e),this.renderer.setSize(this.cssSize.width,this.cssSize.height,!1),this.frameDirty=!0}setExposure(e,t){const i=t?Math.max(1,Math.round(e)):1;if(i===this.exposureInstants&&(i===1||t===this.exposureInstantAt)){this.exposureInstantAt=t;return}this.exposureInstants=i,this.exposureInstantAt=t,i===1&&(this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0),this.render()}renderOnce(e){if(this.onMapSubjectBounds){const r=this.mapSubjectBounds();e?this.exposureSubjectBounds.push(...r):this.onMapSubjectBounds(r)}const t=this.usableEquidistantPass();this.phenomena.setCloudLayers(this.layeredClouds?.volumes??[]),this.phenomena.place(this.camera,(r,o,c)=>this.directionAtScreenPoint(r,o,c),r=>this.screenPointOf(r)),this.references.place(this.camera);const i=Math.max(this.phenomena.furthestM,this.references.furthestM)*1.2;i>this.camera.far&&(this.camera.far=i,this.camera.updateProjectionMatrix()),fn.uRodShare.value=this.scatteredSky?.rodShare??0,fn.uRelativeScale.value=this.relativeScale;const n=this.references.any||this.phenomena.any||this.compassSprites.some(r=>r.visible);fn.uHasOverlay.value=n?1:0;const s=n?r=>this.renderOverlayPasses(r):void 0;if(this.skyGlow?.setDestinationEncoded(!1),!t){this.updateLensFlarePosition();const r=this.usableDepthOfFieldPass();r?r.render(this.renderer,this.scene,this.camera,s,e):this.usableFinishPass().render(this.renderer,this.scene,this.camera,s,void 0,e);return}t.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition(),s,r=>{this.lensFlare&&(this.lensFlare.mesh.visible=r?!1:this.sunVisible)},()=>this.renderDazzleOnResample(),e)}renderOverlayPasses(e=this.camera){this.renderReferencesPass(e),this.renderPhenomenaPass(e),this.renderHudPass(e)}renderHudPass(e){if(!this.compassSprites.some(n=>n.visible))return;const t=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,e.layers.set(Zp),this.renderer.render(this.scene,e),e.layers.set(0),this.renderer.autoClear=t,this.renderer.shadowMap.autoUpdate=i}renderReferencesPass(e){if(!this.references.any)return;const t=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,e.layers.set(g1),this.renderer.render(this.scene,e),e.layers.set(0),this.renderer.autoClear=t,this.renderer.shadowMap.autoUpdate=i}setReferences(e){this.references.set(e)}referenceAspect(e){return this.references.aspectOf(e)}directionAt(e,t){return this.directionAtScreenPoint(e,t,new D)}referenceFailedToLoad(e){return this.references.failedToLoad(e)}setReferencesShown(e){this.references.setShown(e),this.render()}setReferenceView(e,t){this.references.setView(e,t),this.render()}renderPhenomenaPass(e){if(!this.phenomena.any)return;const t=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.renderer.clearDepth();for(const n of this.decorObjects){const s=this.decorGroups.get(n.id);s&&Vt.markDecorDepth(s,n.kind!=="crop")}e.layers.set(Oh),this.scene.overrideMaterial=this.decorDepthMaterial,this.renderer.render(this.scene,e),this.scene.overrideMaterial=null,e.layers.set(m1),this.renderer.render(this.scene,e),e.layers.set(0),this.renderer.autoClear=t,this.renderer.shadowMap.autoUpdate=i}decorDepthMaterial=new mn({colorWrite:!1});static markDecorDepth(e,t){e.traverse(i=>{if(!(i instanceof De))return;const n=Array.isArray(i.material)?i.material[0]:i.material;t&&n.depthWrite!==!1&&n.blending!==Di?i.layers.enable(Oh):i.layers.disable(Oh)})}startExposure(){this.cancelExposure(),this.exposureSubjectBounds=[];const e=this.renderer.getDrawingBufferSize(new xe),t=Math.max(1,Math.round(e.x)),i=Math.max(1,Math.round(e.y));this.exposureAccumulation||(this.exposureAccumulation=new VS(t,i)),this.exposureAccumulation.resize(t,i),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 i=1/this.exposureInstants;this.resolution.beginDrawing();const n=performance.now()+Vt.EXPOSURE_BUDGET_MS,s=Vt.exposureInstantsPerFrame(t.instantTarget.scene.width*t.instantTarget.scene.height);let r=0;do{this.restateAt(e,this.exposureInstantsDone);const o=this.compassSprites.map(c=>c.visible);for(const c of this.compassSprites)c.visible=!1;try{this.renderOnce(t.instantTarget)}finally{this.compassSprites.forEach((c,l)=>{c.visible=o[l]})}t.add(this.renderer,i),this.exposureInstantsDone++,r++}while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<n&&r<s);this.restateAt(e,0),this.presentExposure(),this.resolution.endDrawing(),this.exposureInstantsDone<this.exposureInstants&&(this.exposureFrameId=requestAnimationFrame(()=>this.developExposure()))}presentExposure(){if(fn.uRodShare.value=this.scatteredSky?.rodShare??0,fn.uHasOverlay.value=1,fn.uRelativeScale.value=this.relativeScale,this.exposureAccumulation?.develop(this.renderer,this.exposureInstants/this.exposureInstantsDone),this.onMapSubjectBounds?.(this.exposureSubjectBounds),!this.compassSprites.some(s=>s.visible))return;const e=new xs,t=new Cn(-1,1,1,-1,0,2),i=Dc/(nm*Math.tan(sm*Hi/2));for(const s of this.compassSprites){if(!s.visible)continue;const r=s.getWorldPosition(new D).sub(this.camera.position).normalize(),o=this.screenPointOf(r);if(!o)continue;const c=new Nr(s.material);c.position.set(o.ndcX,o.ndcY,-1),c.scale.set(i/this.camera.aspect,i,1),e.add(c)}const n=this.renderer.autoClear;this.renderer.autoClear=!1;try{this.renderer.render(e,t)}finally{this.renderer.autoClear=n}}onMapSubjectBounds;exposureSubjectBounds=[];static MAP_SUBJECT_NEAREST_M=8;mapSubjectBounds(){const e=[],t=new vn,i=new D,n=this.decorObjects.filter(r=>r.track?.length||r.kind==="aircraft"||r.kind==="vehicle").map(r=>this.decorGroups.get(r.id)),s=this.bodySystem.reflectors.map(r=>r.holder);for(const r of[...n,...s]){if(!r?.visible||(t.setFromObject(r),t.isEmpty())||t.distanceToPoint(this.camera.position)<Vt.MAP_SUBJECT_NEAREST_M)continue;let o=1/0,c=-1/0,l=1/0,h=-1/0;for(const u of[t.min.x,t.max.x])for(const d of[t.min.y,t.max.y])for(const f of[t.min.z,t.max.z]){i.set(u,d,f).sub(this.camera.position).normalize();const p=this.screenPointOf(i);if(!p)continue;const v=(p.ndcX+1)/2,m=(1-p.ndcY)/2;o=Math.min(o,v),c=Math.max(c,v),l=Math.min(l,m),h=Math.max(h,m)}Number.isFinite(o)&&e.push({x:o,y:l,width:c-o,height:h-l})}return e}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 xe),i=Math.max(1,Math.round(t.x)),n=Math.max(1,Math.round(t.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new co(i,n)),this.depthOfFieldPass.resize(i,n),this.depthOfFieldPass.setLens(e.focalLengthMm,e.fNumber,e.focusDistance,e.frameHeightMm),this.depthOfFieldPass}usableFinishPass(){const e=this.renderer.getDrawingBufferSize(new xe);return this.finishPass?this.finishPass.resize(e.x,e.y):this.finishPass=new d0(e.x,e.y),this.finishPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const e=this.renderer.getDrawingBufferSize(new xe);return this.equidistantPass?this.equidistantPass.resize(e.x,e.y):this.equidistantPass=new pi(e.x,e.y),this.equidistantPass}aimAtScreenPoint(e,t,i){const n=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!n){e.setFromCamera(new xe(t,i),this.camera);return}const s=n.directionFor(t,i,this.camera.fov);this.camera.updateMatrixWorld(),e.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),e.ray.direction.set(s.x,s.y,s.z).applyQuaternion(this.camera.quaternion).normalize(),e.camera=this.camera}pickCloudAt(e,t){return this.layeredClouds?.pickInstance(this.cloudDirectionAt(e,t))}cloudDirectionAt(e,t){return this.directionAtScreenPoint(e,t,new D)}directionAtScreenPoint(e,t,i){return this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),i.copy(this.ufoOcclusionRaycaster.ray.direction)}screenPointOf(e){this.camera.updateMatrixWorld();const t=this.screenPointScratch.copy(e).applyQuaternion(this.screenPointQuaternion.copy(this.camera.quaternion).invert()),i=this.renderer.getDrawingBufferSize(this.screenPointSize),n=i.x/Math.max(i.y,1);if(this.projectionKind==="equidistant"&&this.equidistantPass)return pi.ndcFor(t,this.camera.fov,n);if(t.z>=0)return;const s=Math.tan(this.camera.fov/2*Hi);return{ndcX:t.x/-t.z/(n*s),ndcY:t.y/-t.z/s}}screenPointScratch=new D;screenPointQuaternion=new Qn;screenPointSize=new xe;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 i=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);e.uniforms.uLensPosition.value.set(i.x,i.y);const n=this.renderer.domElement.width,s=this.renderer.domElement.height;e.uniforms.uResolution.value.set(n,s),e.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}renderDazzleOnResample(){const e=this.lensFlare;if(!e||!this.sunVisible)return;const t=this.sunVisibleFraction();if(t<=0)return;this.sunUnhiddenFraction=t,this.applyDazzleStrength();const i=this.screenPointOf(this.lensFlareScratch.copy(this.sunWorldPosition).sub(this.camera.position).normalize());if(!i)return;const n=this.renderer.getDrawingBufferSize(this.screenPointSize);e.uniforms.uLensPosition.value.set(i.ndcX,i.ndcY),e.uniforms.uResolution.value.set(n.x,n.y),e.uniforms.uEquidistant.value=1,e.uniforms.uHalfFovRad.value=this.camera.fov*Math.PI/360;const s=this.renderer.autoClear;this.renderer.autoClear=!1,e.mesh.visible=!0,e.mesh.layers.enable($p),this.camera.layers.set($p),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),e.mesh.visible=!1,e.uniforms.uEquidistant.value=0,this.renderer.autoClear=s}sunVisibleFraction(){this.raycastableDecor().length>0&&this.scene.updateMatrixWorld();let e=0;for(const t of rm)this.isSunOccluded(t[0],t[1])||e++;return e/rm.length}raycastableDecor(){const e=[];for(const t of this.decorObjects){if(t.kind==="crop")continue;const i=this.decorGroups.get(t.id);i&&e.push(i)}return e}isSunOccluded(e=0,t=0){const i=this.raycastableDecor();if(!this.groundMesh&&!this.terrainMesh&&i.length===0)return!1;const n=this.sunOcclusionDirectionScratch.copy(this.sunWorldPosition).sub(this.camera.position),s=n.length();if(n.normalize(),e!==0||t!==0){const o=Math.PI/180,c=this.sunOcclusionRightScratch.set(n.z,0,-n.x);c.lengthSq()<1e-9&&c.set(1,0,0),c.normalize();const l=this.sunOcclusionUpScratch.crossVectors(c,n).normalize();n.addScaledVector(c,e*o).addScaledVector(l,t*o).normalize()}if(this.groundBlocks(this.camera.position,n,s))return!0;if(i.length===0)return!1;this.sunOcclusionRaycaster.set(this.camera.position,n);const r=this.sunOcclusionRaycaster.intersectObjects(i,!0)[0];return r!==void 0&&r.distance<s}groundBlocks(e,t,i,n=0){const s=this.groundMesh;if(s&&t.y<0){const m=(s.position.y-e.y)/t.y;if(m>n&&m<i){const g=e.x+t.x*m-s.position.x,_=e.z+t.z*m-s.position.z;if(Math.hypot(g,_)<=this.groundRadius)return!0}}const r=this.terrainMesh;if(!r)return!1;const o=r.geometry.getAttribute("position"),c=Math.round(Math.sqrt(o.count));if(c<2||c*c!==o.count)return!1;const l=[r.position.x+o.getX(0),r.position.x+o.getX(c-1)],h=[r.position.z+o.getZ(0),r.position.z+o.getZ((c-1)*c)],u=Math.min(Math.abs(l[1]-l[0]),Math.abs(h[1]-h[0]))/(c-1);if(!(u>0))return!1;let d=n,f=i;for(const[m,g,_]of[[e.x,t.x,l],[e.z,t.z,h]]){const w=Math.min(_[0],_[1]),M=Math.max(_[0],_[1]);if(Math.abs(g)<1e-12){if(m<w||m>M)return!1;continue}const S=(w-m)/g,b=(M-m)/g;d=Math.max(d,Math.min(S,b)),f=Math.min(f,Math.max(S,b))}if(!(f>d))return!1;const p=Math.hypot(t.x,t.z),v=Math.min(4096,Math.max(8,Math.ceil((f-d)*p/(u/2))));for(let m=0;m<=v;m++){const g=d+(f-d)*m/v,_=e.x+t.x*g,w=e.y+t.y*g,M=e.z+t.z*g;if(w<=this.groundYUnder(_,M))return!0}return!1}setPhenomena(e,t){this.phenomena.set(e,t)}decorDistancesAt(e,t,i){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),this.ufoOcclusionRaycaster.near=Jp;let n,s;for(const r of this.decorObjects){if(r.kind==="crop")continue;const o=this.decorGroups.get(r.id);if(!o)continue;const c=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];c&&(r.occludesSourceIds?.includes(i)?n=n===void 0?c.distance:Math.max(n,c.distance):s=s===void 0?c.distance:Math.min(s,c.distance))}return{behindM:n,inFrontM:s}}pickBodyAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const i=[...this.hitAreas.entries()],n=this.raycaster.intersectObjects(i.map(([,s])=>s))[0];if(n&&!this.groundHides(e,t))return i.find(([,s])=>s===n.object)?.[0]}pickStarAt(e,t){if(this.namedStars.length===0)return;this.aimAtScreenPoint(this.raycaster,e,t);const i=this.raycaster.ray.direction,n=Math.cos(Qp*this.camera.fov*Math.PI/180);let s,r=n;for(const o of this.namedStars){const c=o.direction.dot(i);c>r&&(r=c,s={star:o.star,altitudeDeg:o.altitudeDeg})}return s&&this.groundHides(e,t)?void 0:s}groundHides(e,t){if(!this.terrainMesh&&!this.groundMesh)return!1;this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t);const i=this.ufoOcclusionRaycaster.ray;return this.groundBlocks(i.origin,i.direction,1/0,Jp)}pickDecorAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const i=[...this.decorGroups.entries()],n=this.raycaster.intersectObjects(i.map(([,r])=>r),!0)[0];if(!n)return;let s=n.object;for(;s&&!i.some(([,r])=>r===s);)s=s.parent;return i.find(([,r])=>r===s)?.[0]}dispose(){this.stopTwinkle(),this.cancelFlush(),this.phenomena.clear(),this.references.disposeAll(),this.terrainBuildToken++,this.cancelScatteredSkyPump(),this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.skyGradientMaterial),this.scatteredSky?.dispose(),this.scatteredSky=void 0,this.disposeMesh(this.skyMesh),this.disposeMesh(this.groundMesh),this.disposeMesh(this.terrainMesh),this.roadSystem.dispose(),this.disposeCloudSystem(),this.disposeCirrus(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers(),this.meteorSystem?.dispose(),this.meteorSystem=void 0,this.iceHalos?.dispose(),this.iceHalos=void 0,this.rainbow?.dispose(),this.rainbow=void 0,this.skyGlow?.dispose(),this.skyGlow=void 0,this.depthOfFieldPass?.dispose(),this.finishPass?.dispose(),this.depthOfFieldPass=void 0,this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0,this.cometTail?.dispose(),this.cometTail=void 0,this.satelliteField?.dispose(),this.satelliteField=void 0,this.lightningBolt?.dispose(),this.lightningBolt=void 0;for(const e of this.bodyMeshes.values())this.disposeMesh(e);this.bodyMeshes.clear(),this.novaKeys.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())gi.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;this.cancelFlush();const e=t=>{this.frame(t),this.animationFrameId=requestAnimationFrame(e)};this.animationFrameId=requestAnimationFrame(e)}setAnimationsRunning(e,t=!1){const i=e&&t;if(e===this.animationsRunning&&i===this.framesDriven)return;const n=this.animationsRunning;this.animationsRunning=e,this.framesDriven=i,e&&!n&&(this.lastFrameTimeMs=void 0,this.resolution.reset()),!e&&this.renderer.getPixelRatio()!==this.resolution.maximum&&this.applyPixelRatio(this.resolution.maximum),this.syncAnimationLoop(),(!e||this.frameDirty)&&this.render()}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}needsAnimationLoop(){return this.animationsRunning&&!this.framesDriven&&this.hasAnimations()}hasAnimations(){return this.starTiers.length>0||this.precipitationPoints!==void 0||this.rainSystem!==void 0||this.lensFlare!==void 0&&this.sunVisible}syncAnimationLoop(){this.needsAnimationLoop()?this.startTwinkle():this.stopTwinkle()}buildSky(e){const t=this.skyMesh?.geometry??new jt(Ac,32,16),i=t.attributes.position,n=t.getAttribute("color")??new xt(new Float32Array(i.count*3),3);for(let r=0;r<i.count;r++){const{altitudeDeg:o,azimuthDeg:c}=qS(i.getX(r),i.getY(r),i.getZ(r)),l=e5(o,c,e.azimuthDeg,e.altitudeDeg);n.setXYZ(r,l[0],l[1],l[2])}if(n.needsUpdate=!0,this.skyMesh)return;t.setAttribute("color",n);const s=new mn({vertexColors:!0,side:Ot,fog:!1,depthWrite:!1});this.skyGradientMaterial=s,this.skyMesh=new De(t,s),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){const e=jp(this.observerElevationM);if(this.groundMesh&&e===this.groundRadius)return;this.disposeMesh(this.groundMesh),this.groundRadius=e;const t=new Xd(this.groundRadius,48),i=new Sr({color:new se(Uh,Uh,Uh),fog:!0});Ma.fadeRim(i,this.groundRadius*.75,this.groundRadius,this.horizonColour),this.groundMesh=new De(t,i),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh),this.applyGroundDepthWrite()}applyGroundDepthWrite(){const e=this.groundMesh?.material;if(!e)return;const t=this.terrainMesh===void 0;e.depthWrite!==t&&(e.depthWrite=t,e.needsUpdate=!0)}cloudTransmission(e,t=!1){const i=`${e.altitudeDeg.toFixed(1)}:${e.azimuthDeg.toFixed(1)}:${Math.round(this.cloudOffsetM.x/10)}:${Math.round(this.cloudOffsetM.z/10)}:${Math.round(this.observerElevationM)}:`+Object.entries(this.cloudLayerOffsetsM).map(([r,o])=>`${r}=${Math.round(o.x/10)},${Math.round(o.z/10)}`).join(";")+(t?":water":""),n=this.cloudTransmissionMemo.get(i);if(n!==void 0)return n;this.cloudTransmissionMemo.size>256&&this.cloudTransmissionMemo.clear();const s=this.computeCloudTransmission(e,t);return this.cloudTransmissionMemo.set(i,s),s}cloudTransmissionMemo=new Map;computeCloudTransmission(e,t=!1){const i=ii(e.altitudeDeg,e.azimuthDeg,1);if(this.layeredClouds)return this.layeredClouds.transmissionAt(i,t);let n=1;const s=this.lowerCloudCover();s>0&&(n*=1-ht.alphaAt(i,Math.abs(this.cloudLayerOffset()),s,this.cloudFieldOffset)*sb);const r=t?0:this.weather.highCloudCover??0;return r>0&&(n*=1-ht.iceAlphaAt(i,Tc,r,this.cloudFieldOffset)*ab),Math.max(0,Math.min(1,n))}setBodyMesh(e,t,i,n,s){if(t.altitudeDeg<bd){this.disposeMesh(this.bodyMeshes.get(e)),this.bodyMeshes.delete(e),this.disposeHitArea(e),this.disposeGlare(e),e==="sun"&&(this.sunVisible=!1);return}const{x:r,y:o,z:c}=ii(t.altitudeDeg,t.azimuthDeg,cn),l=Mp(t.altitudeDeg),h=this.cloudTransmission(t),u=this.arrivingIlluminance(t,s,h),d=Vt.unitLuminance(n);let f=this.bodyMeshes.get(e);if(e==="sun"){const p=Math.PI*(i/cn)**2,v=[0,1,2].map(m=>Math.min(Vt.BRIGHTEST_RELATIVE,d[m]*u[m]/p));f instanceof De||(this.disposeMesh(f),f=new De(new jt(1,16,16),new mn({fog:!1})),this.celestialGroup.add(f),this.bodyMeshes.set(e,f)),f.material.color.setRGB(v[0],v[1],v[2]),f.scale.setScalar(i)}else{if(!(f instanceof us)){this.disposeMesh(f);const v=new ut;v.setAttribute("position",new et(new Float32Array(3),3)),v.setAttribute("color",new et(new Float32Array(3),3)),f=new us(v,Ni.material(ro[ro.length-1].size)),this.celestialGroup.add(f),this.bodyMeshes.set(e,f)}const p=f.geometry.getAttribute("color");p.setXYZ(0,d[0]*u[0],d[1]*u[1],d[2]*u[2]),p.needsUpdate=!0}if(f.position.set(r,o,c),this.setHitArea(e,r,o,c,i),e==="sun"&&(this.sunArriving=u),e!=="sun"&&this.setGlare(e,r,o,c,u,i/cn*(180/Math.PI),1),e==="sun"){this.sunVisible=!0;const p=this.celestialGroup.scale.x;this.sunWorldPosition.set(r*p,o*p+this.celestialGroup.position.y,c*p),this.lensFlare||(this.lensFlare=bw(),this.lensFlare.uniforms.uOpacity.value=gb,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(l)}}setMoonMesh(e,t){const i="moon";if(e.magnitude>t||e.altitudeDeg<bd){this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i);return}const{x:n,y:s,z:r}=ii(e.altitudeDeg,e.azimuthDeg,cn),o=this.cloudTransmission(e),c=this.arrivingIlluminance(e,e.magnitude,o),l=Math.max(sr(e.phase.illuminatedFraction,0,1),.01)*Math.PI*(qr/cn)**2,h=new se(...c.map(f=>Math.min(Vt.BRIGHTEST_RELATIVE,f/l))),u=`${e.phase.phaseFraction<.5}:${Math.round(sr(e.phase.illuminatedFraction,0,1)*500)}`;let d=this.bodyMeshes.get(i);if(d instanceof Nr)d.userData.phaseKey!==u&&(d.material.map?.dispose(),d.material.map=Em(e.phase),d.userData.phaseKey=u),d.material.color.copy(h);else{this.disposeMesh(d),d=new Nr(new Hc({map:Em(e.phase),color:h,fog:!1})),d.userData.phaseKey=u;const f=qr*2;d.scale.set(f,f,1),this.celestialGroup.add(d),this.bodyMeshes.set(i,d)}d.position.set(n,s,r),this.setHitArea(i,n,s,r,qr),this.setGlare(i,n,s,r,c,qr/cn*(180/Math.PI))}bentLight(e,t){const[i,n,s]=this.arrivingIlluminance(e,t,1),r=Math.max(n,1e-30);return{scale:n/nb,tint:[i/r,1,s/r]}}static litBySky(e,t){return Vt.litScratch.setRGB(e.r*t[0],e.g*t[1],e.b*t[2])}static litScratch=new se;static BRIGHTEST_RELATIVE=6e4;arrivingIlluminance(e,t,i){const n=this.air.transmittanceFromSpace(this.siteElevationM+this.observerElevationM,e.altitudeDeg),s=ot.illuminanceOf(t)*i*this.relativeScale;return[n[0]*s,n[1]*s,n[2]*s]}static unitLuminance(e){const t=Tn.luminanceOf([e.r,e.g,e.b]);return t>0?[e.r/t,e.g/t,e.b/t]:[1,1,1]}setHitArea(e,t,i,n,s){let r=this.hitAreas.get(e);if(!r){const c=new Hc({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1});r=new Nr(c),this.celestialGroup.add(r),this.hitAreas.set(e,r)}r.position.set(t,i,n);const o=s*ib;r.scale.set(o,o,1)}disposeHitArea(e){const t=this.hitAreas.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.hitAreas.delete(e))}setGlare(e,t,i,n,s,r,o=0){if(Ui.radiusDeg(Ui.K*Math.max(...s))<=Math.max(r,o)){this.disposeGlare(e);return}let c=this.glareSprites.get(e);c||(c=new Ui(`veil:${e}`),this.celestialGroup.add(c.mesh),this.glareSprites.set(e,c)),c.shine({x:t,y:i,z:n},s,r,o)}disposeGlare(e){const t=this.glareSprites.get(e);t&&(t.mesh.removeFromParent(),t.dispose(),this.glareSprites.delete(e))}buildComet(e,t){const i=e&&`comet:${e.id}`;if(!e||!i||e.magnitude>t){this.disposeComet();return}this.cometKey&&this.cometKey!==i&&this.disposeComet();const n=jr(e.magnitude,t),s=wh(n);this.cometKey=i,this.setBodyMesh(i,e.position,zh*(.5+.5*n),new se(s,s,s),e.magnitude),this.cometTail||(this.cometTail=new Zi(cn),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(e.position,e.tailEnd,n)}buildIceHalos(e,t){this.iceHalos||(this.iceHalos=new Ai,this.iceHalos.setCloudOffset(this.cloudFieldOffset),this.iceHalos.onReady=()=>this.render(),this.celestialGroup.add(this.iceHalos.object)),this.iceHalos.setUrgent(!!this.skyHoldUntilMs);const i=this.highCloudCover(),n=this.layeredClouds?.cirrusMask;if(this.iceHalos.setCloudOffset(n?.offset??this.cloudFieldOffset),this.layeredClouds?.hostHalo(this.iceHalos),i===void 0){this.iceHalos.update({x:0,y:1,z:0},-1,0,[1,1,1],{cover:0,layerHeight:Tc},0);return}const s=this.lowerCloudCover(),r=lt.deckLitUntilDeg(lt.DECK_HEIGHT_M),o=e.altitudeDeg>-r?e:t,c=this.bentLight(o,o===e?ti.SUN_MAGNITUDE:t.magnitude),l=lt.strength(i,s,o.altitudeDeg,r)*c.scale,{x:h,y:u,z:d}=ii(o.altitudeDeg,o.azimuthDeg,1);this.iceHalos.update({x:h,y:u,z:d},o.altitudeDeg,l,c.tint,{cover:n?.cover??i,layerHeight:n?.layerHeight??Tc},n?.iceCrystalAlignment??this.weather.iceCrystalAlignment??.65)}buildRainbow(e,t){this.rainbow||(this.rainbow=new pa,this.celestialGroup.add(this.rainbow.object));const i=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity:0,n=e.altitudeDeg>0,s=n?e:t,r=this.lowerCloudCover(),o=this.bentLight(s,n?ti.SUN_MAGNITUDE:t.magnitude),c=$i.strength(i,r,s.altitudeDeg)*o.scale;if(c<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:l,y:h,z:u}=ii(s.altitudeDeg,s.azimuthDeg,1);this.rainbow.update({x:l,y:h,z:u},c,o.tint,n)}buildSkyGlow(e,t){if(!e.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new Os,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:i,observer:n}=e.frame,s=Sn.galactic(i,n),r=Vt.directionOf(s.centre),o=Vt.directionOf(s.rotation),c=Vt.directionOf(s.pole),l=new Xe().set(r.x,r.y,r.z,o.x,o.y,o.z,c.x,c.y,c.z),h=Vt.directionOf(Sn.eclipticPole(i,n)),u=Vt.directionOf(e.sun),d=u.clone().addScaledVector(h,-u.dot(h)).normalize();this.skyGlow.update({galactic:l,eclipticPole:h,sunLongitude:d,sunDirection:u,sunAltitudeDeg:e.sun.altitudeDeg,moon:{direction:Vt.directionOf(e.moon),altitudeDeg:e.moon.altitudeDeg,phaseAngleDeg:Ye.phaseAngleOf(e.moon.phase.illuminatedFraction)},skyColor:new D(t[0],t[1],t[2])})}static directionOf(e){const{x:t,y:i,z:n}=ii(e.altitudeDeg,e.azimuthDeg,1);return new D(t,i,n).normalize()}buildNovae(e,t){const i=new Set;for(const n of e){if(n.magnitude>t)continue;const s=`nova:${n.id}`;i.add(s);const r=jr(n.magnitude,t),o=wh(r);this.setBodyMesh(s,n.position,zh*(.5+.5*r),new se(o,o,o),n.magnitude)}for(const n of this.novaKeys)i.has(n)||(this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n));this.novaKeys=i}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 i=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[],...this.novaKeys]);for(const n of e){if(n.magnitude>t)continue;i.add(n.body);const s=jr(n.magnitude,t),r=wh(s),o=Ob[n.body]??new se(1,1,1),c=new se(o.r*r,o.g*r,o.b*r),l=zh*(.5+.5*s);this.setBodyMesh(n.body,n.position,l,c,n.magnitude)}for(const n of[...this.bodyMeshes.keys()])i.has(n)||(this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n))}buildStars(e,t){if(this.namedStars=[],!e||e.catalog.count===0){this.disposeStarTiers(),this.syncAnimationLoop();return}const{catalog:i,date:n,observer:s}=e,r=new En(n,s),o=Yh(1337),c=[],l=this.siteElevationM+this.observerElevationM;for(let h=0;h<i.count;h++){const u=i.mag[h];if(u>t)break;const{altitudeDeg:d,azimuthDeg:f}=r.position(i.ra[h],i.dec[h]);if(d<em)continue;const{x:p,y:v,z:m}=ii(d,f,Fh);c.push({x:p,y:v,z:m,brightness:jr(u,t),illuminance:this.air.transmittanceFromSpace(l,d).map(g=>g*ot.illuminanceOf(u)),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}for(const h of aw){if(h.mag>t)continue;const{altitudeDeg:u,azimuthDeg:d}=r.position(h.raHours,h.decDeg);if(u<em)continue;const{x:f,y:p,z:v}=ii(u,d,Fh);this.namedStars.push({star:h,direction:new D(f,p,v).normalize(),altitudeDeg:u})}this.starTiers=ro.map((h,u)=>{const d=c.filter(S=>zg(S.brightness)===u),f=new Float32Array(d.length*3),p=new Float32Array(d.length),v=new Float32Array(d.length*3),m=new Float32Array(d.length),g=new Float32Array(d.length);d.forEach((S,b)=>{f[b*3]=S.x,f[b*3+1]=S.y,f[b*3+2]=S.z,p[b]=S.brightness,v.set(S.illuminance,b*3),m[b]=S.phase,g[b]=S.speedFactor});const _=new ut;_.setAttribute("position",new et(f,3));const w=new et(new Float32Array(d.length*3),3);_.setAttribute("color",w);let M=this.starTiers[u]?.points;return M?(M.geometry.dispose(),M.geometry=_):(M=new us(_,Ni.material(h.size)),this.celestialGroup.add(M)),{points:M,colorAttribute:w,brightness:p,illuminance:v,phase:m,speedFactor:g}}),this.updateTwinkle(0),this.startTwinkle()}twinkleSeconds=0;updateTwinkle(e){const t=this.relativeScale;for(const i of this.starTiers){const n=i.colorAttribute.array;for(let s=0;s<i.brightness.length;s++){const r=a5(i.brightness[s],{phase:i.phase[s],speedFactor:i.speedFactor[s]},e),o=t*r;n[s*3]=i.illuminance[s*3]*o,n[s*3+1]=i.illuminance[s*3+1]*o,n[s*3+2]=i.illuminance[s*3+2]*o}i.colorAttribute.needsUpdate=!0}}buildClouds(){if(this.cloudRendering==="volume"||this.weather.cloudLayers!==void 0){this.layeredClouds||(this.disposeCloudSystem(),this.layeredClouds=new hr(this.celestialGroup,Hh,this.cloudRendering)),this.disposeCirrus(),this.layeredClouds.hostHalo(this.iceHalos),this.layeredClouds.update(this.weather,this.observerElevationM+1.6),this.layeredClouds.setOffsets(this.cloudOffsetM,this.cloudLayerOffsetsM),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const e=this.lowerCloudCover();if(e<=0){this.disposeCloudSystem();return}const t=this.weather.cloudDarkness,i=new se(na[0]+(Vh[0]-na[0])*t,na[1]+(Vh[1]-na[1])*t,na[2]+(Vh[2]-na[2])*t);if(this.cloudMesh&&this.cloudUniforms){this.cloudUniforms.coverage.value=e,this.cloudUniforms.baseColor.value.copy(i),this.syncCloudLayer(),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}this.disposeCloudSystem();const{material:n,uniforms:s}=Zu(i,e,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=n,this.cloudUniforms=s,s.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const r=Ju(Hh);this.cloudMesh=new De(r,n),this.faceCloudDeck(this.cloudMesh,this.cloudLayerOffset()),this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(e=>e.type!=="cirrus").reduce((e,t)=>e*(1-t.coverage),1):this.weather.lowerCloudCover??this.weather.cloudCover}highCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(e=>e.type==="cirrus").reduce((e,t)=>e*(1-t.coverage),1):this.weather.highCloudCover}buildCirrus(){const e=this.weather.highCloudCover??0;if(this.layeredClouds||e<=0){this.disposeCirrus();return}if(this.cirrusMesh&&this.cirrusUniforms){this.cirrusUniforms.coverage.value=e,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const{material:t,uniforms:i}=Zu(new se(...na),e,Tc,1);this.cirrusMaterial=t,this.cirrusUniforms=i,i.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new De(Ju(Hh*1.04),t),this.cirrusMesh.renderOrder=om-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(){this.layeredClouds?.update(this.weather,this.observerElevationM+1.6);const e=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(e)),this.cloudMesh&&this.faceCloudDeck(this.cloudMesh,e)}faceCloudDeck(e,t){const i=t<0;e.scale.y=i?-1:1,e.renderOrder=i?hr.deckOrder(!0,0,1):om}cloudLayerOffset(){const t=((this.weather.cloudBaseM??1e3)-this.observerElevationM)*Bh;return Math.sign(t||1)*Math.max(Math.abs(t),Mb)}updateCloudLighting(e,t){const i=[this.cloudUniforms,this.cirrusUniforms].filter(u=>u!==void 0);if(i.length===0&&!this.layeredClouds)return;const n=this.cloudBeamDirection,[s,r,o]=this.cloudBeam.map(u=>u/Math.PI),c=this.lightningLevel*qh*this.relativeScale/Math.PI,l=new se(t[0]+kn.r*c,t[1]+kn.g*c,t[2]+kn.b*c);this.layeredClouds?.setLighting(n.clone(),new se(s,r,o),l,l);const h=Math.max(0,n.y);for(const u of i)u.sunDir.value.copy(n),u.sunColor.value.setRGB(s*h,r*h,o*h),u.ambientColor.value.copy(l)}disposeCloudSystem(){this.layeredClouds?.dispose(),this.layeredClouds=void 0,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=cm[e],i=t.poolSize,n=Yh(9001),s=new Float32Array(i*3),r=new Float32Array(i),o=new Float32Array(i),c=new Float32Array(i),l=new Float32Array(i),h=new Float32Array(i),u=new Float32Array(i),d=new Float32Array(i),f=new Float32Array(i),p=new Float32Array(i);for(let w=0;w<i;w++){const M=n()*Math.PI*2,S=n()*t.radiusM;s[w*3]=Math.cos(M)*S,s[w*3+1]=er+n()*(t.topYM-er),s[w*3+2]=Math.sin(M)*S,r[w]=n()*Math.PI*2,o[w]=.7+n()*.6,c[w]=.6+n()*.8,l[w]=.4+n()*1.2}const v=new ut;v.setAttribute("position",new et(s,3)),v.setDrawRange(0,Xh(i,this.weather.precipitationIntensity));const m={uSize:{value:t.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:t.opacity},uColor:{value:t.color.clone()},uHazeColor:{value:new se(...this.baseFogColor)},uTexture:{value:Ub(e)},uNearFocusDistance:{value:vm},uHazeDistance:{value:t.radiusM*Mm}},g=new at({uniforms:m,vertexShader:Gb,fragmentShader:Vb,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const _=new us(v,g);_.renderOrder=Gh,this.scene.add(_),this.precipitationPoints=_,this.precipitationPositions=s,this.precipitationPhase=r,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=c,this.precipitationWobbleAmpJitter=l,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=u,this.precipitationBounceDuration=d,this.precipitationBounceVelX=f,this.precipitationBounceVelZ=p}updatePrecipitation(e,t){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter)return;this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor);const i=this.weather.precipitationType;if(i==="none"||i==="rain")return;const n=cm[i];if(this.precipitationUniforms?.uColor.value.copy(Vt.litBySky(n.color,this.baseFogColor)),t<=0)return;const s=this.weather.windDirectionDeg*Hi,r=Math.sin(s)*this.weather.windSpeed*n.driftSensitivity,o=-Math.cos(s)*this.weather.windSpeed*n.driftSensitivity,c=this.precipitationPositions,l=this.precipitationPhase,h=this.precipitationSpeedJitter,u=this.precipitationWobbleFreqJitter,d=this.precipitationWobbleAmpJitter,f=this.precipitationBounceRemaining,p=this.precipitationBounceHeight,v=this.precipitationBounceDuration,m=this.precipitationBounceVelX,g=this.precipitationBounceVelZ,_=i==="snow"&&u&&d,w=i==="hail"&&f&&p&&v&&m&&g;for(let M=0,S=0;M<c.length;M+=3,S++){if(w&&f[S]>0){if(f[S]-=t,f[S]<=0){const x=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*n.radiusM;c[M]=Math.cos(x)*A,c[M+1]=n.topYM,c[M+2]=Math.sin(x)*A,f[S]=0}else{const x=1-f[S]/v[S];c[M+1]=er+Math.sin(Math.PI*x)*p[S],c[M]=Cc(c[M]+(r+m[S])*t,n.radiusM),c[M+2]=Cc(c[M+2]+(o+g[S])*t,n.radiusM)}continue}let b=0,T=0;if(_){const x=Tb*u[S],A=Rb*d[S];b=Math.sin(e*x*Math.PI*2+l[S])*A,T=Math.sin(e*x*Math.PI*2+l[S]+Math.PI/2)*A}if(c[M]+=(r+b)*t,c[M+1]-=n.fallSpeedMPerS*h[S]*t,c[M+2]+=(o+T)*t,c[M]=Cc(c[M],n.radiusM),c[M+2]=Cc(c[M+2],n.radiusM),c[M+1]<er){if(w){p[S]=wm*(.2+Math.random()*1.6),v[S]=Db*(.5+Math.random()),f[S]=v[S];const I=Math.random()*Math.PI*2,C=Cb*(p[S]/wm);m[S]=Math.cos(I)*C,g[S]=Math.sin(I)*C,c[M+1]=er;continue}const x=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*n.radiusM;c[M]=Math.cos(x)*A,c[M+1]=n.topYM,c[M+2]=Math.sin(x)*A}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const e=dm(this.weather.precipitationIntensity);this.rainSystem=yw({count:lm,radiusM:Yr,heightM:yb,bottomYM:hm,overallSpeed:_b,color:fm.clone(),opacity:.85,visibleCount:Xh(lm,this.weather.precipitationIntensity),speedStreak:Eb(e),pixelSize:ym,seed:9001,nearFocusDistanceM:vm,hazeDistanceM:Yr*Mm,hazeColor:new se(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=Gh,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const e=Yh(4242),t=new Float32Array(Ja*3),i=new Float32Array(Ja),n=new Float32Array(Ja),s=new Float32Array(Ja);for(let h=0;h<Ja;h++){const u=e()*Math.PI*2,d=Math.sqrt(e())*Yr;t[h*3]=Math.cos(u)*d,t[h*3+1]=hm,t[h*3+2]=Math.sin(u)*d,n[h]=bm(pm,mm),i[h]=e()*n[h],s[h]=i[h]/n[h]}const r=new ut;r.setAttribute("position",new et(t,3));const o=new et(s,1);r.setAttribute("aLife",o),r.setDrawRange(0,Xh(Ja,this.weather.precipitationIntensity));const c=new at({uniforms:{uMaxSize:{value:Ab},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:gm.clone()},uTexture:{value:zb()}},vertexShader:Hb,fragmentShader:Bb,transparent:!0,depthWrite:!1}),l=new us(r,c);l.renderOrder=Gh,this.scene.add(l),this.rainSplashSystem={points:l,positions:t,life:i,duration:n,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*Hi;e.uniforms.uDropVelocity.value.set(Math.sin(t)*this.weather.windSpeed,-dm(this.weather.precipitationIntensity),-Math.cos(t)*this.weather.windSpeed);const i=this.renderer.getSize(this.rainViewportSize);e.uniforms.uAspect.value=i.x/Math.max(i.y,1)}updateRain(e){const t=this.rainSystem;if(!t)return;t.uniforms.uTime.value+=e,t.uniforms.uHazeColor.value.setRGB(...this.baseFogColor),t.uniforms.uColor.value.copy(Vt.litBySky(fm,this.baseFogColor));const i=this.rainSplashSystem?.points.material?.uniforms?.uColor;i&&i.value.copy(Vt.litBySky(gm,this.baseFogColor));const n=this.weather.windDirectionDeg*Hi,s=Math.sin(n)*this.weather.windSpeed,r=-Math.cos(n)*this.weather.windSpeed,o=Yr,c=h=>(h%(o*2)+o*3)%(o*2)-o;t.uniforms.uWindOffset.value.set(c(t.uniforms.uWindOffset.value.x+s*e),c(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 h=_m+(1-_m)*(1-l),u=Sm+(1-Sm)*(1-l);t.uniforms.uUvSquash.value=u,t.uniforms.uPixelSize.value=ym*h*(.5+.5*u)}this.updateRainSplashes(e)}updateRainSplashes(e){const t=this.rainSplashSystem;if(!t||e<=0)return;const{positions:i,life:n,duration:s,lifeAttribute:r}=t,o=r.array;for(let c=0,l=0;c<i.length;c+=3,l++){if(n[l]+=e,n[l]>=s[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*Yr;i[c]=Math.cos(h)*u,i[c+2]=Math.sin(h)*u,s[l]=bm(pm,mm),n[l]=0}o[l]=n[l]/s[l]}t.points.geometry.attributes.position.needsUpdate=!0,r.needsUpdate=!0}setLightning(e){this.lightningFlashes=e}updateLightning(e){let t,i=0;if(this.lightningArmed)for(const c of this.lightningFlashes){if(c.t>e)break;const l=ri.brightnessAt(c,e);l>i&&(t=c,i=l)}const n=t?Math.min(1,Math.max(.1,(Lb/t.distanceM)**2)):0,s=i*n*(t?.cloudToGround?1:.6);if(s===this.lightningLevel&&!t?.cloudToGround)return;if(this.lightningLevel=s,this.scene.fog){const c=this.scene.fog,l=s*qh*this.relativeScale/Math.PI;c.color.setRGB(this.airlight[0]+kn.r*l,this.airlight[1]+kn.g*l,this.airlight[2]+kn.b*l)}const r=this.skyMesh?.material?.color;if(r){const c=s*Nb;r.setRGB(1+c*kn.r,1+c*kn.g,1+c*kn.b)}if(this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.lightningLight.intensity=s*qh*this.relativeScale,t){const{x:c,y:l,z:h}=ii(25,t.azimuthDeg,cn);this.lightningLight.position.set(c,l,h)}this.lightningBolt||(this.lightningBolt=new Us(cn*.95),this.celestialGroup.add(this.lightningBolt.object));const o=this.weather.cloudBaseM??1500;this.lightningBolt.set(t,i,o),this.render()}buildCompassLabels(){const e=Td(navigator.languages,lb),t=cb[e];this.compassSprites=ob.map((i,n)=>{const s=t[n],r=new Hc({map:Wb(s),depthTest:!1,fog:!1}),o=new Nr(r),{x:c,y:l,z:h}=ii(0,i,nm);return o.position.set(c,l,h),o.scale.set(Dc,Dc,1),o.renderOrder=db,o.layers.set(Zp),o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o}),this.updateCompassScale()}updateCompassScale(){const e=this.camera.fov*Math.PI/360,t=sm*Math.PI/360,i=Dc*Math.tan(e)/Math.tan(t);for(const n of this.compassSprites)n.scale.set(i,i,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 i of Array.isArray(t)?t:[t]){const n=i.map;n&&n.dispose(),i.dispose()}}}const Hi=Math.PI/180;function sr(a,e,t){return Math.max(e,Math.min(t,a))}function bm(a,e){return a+Math.random()*(e-a)}function Cc(a,e){return(a%(e*2)+e*3)%(e*2)-e}let Ic,Pc;function Ub(a){switch(a){case"snow":return Fb();case"hail":return kb()}}function Fb(){if(Ic)return Ic;const a=64,e=document.createElement("canvas");e.width=a,e.height=a;const t=e.getContext("2d"),i=t.createRadialGradient(a/2,a/2,0,a/2,a/2,a/2);return i.addColorStop(0,"rgba(255,255,255,0.95)"),i.addColorStop(.5,"rgba(255,255,255,0.55)"),i.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=i,t.fillRect(0,0,a,a),Ic=new Ss(e),Ic}function kb(){if(Pc)return Pc;const a=64,e=document.createElement("canvas");e.width=a,e.height=a;const t=e.getContext("2d"),i=t.createRadialGradient(a/2,a/2,0,a/2,a/2,a/2);return i.addColorStop(0,"rgba(255,255,255,1)"),i.addColorStop(.55,"rgba(255,255,255,0.95)"),i.addColorStop(.8,"rgba(255,255,255,0.4)"),i.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=i,t.fillRect(0,0,a,a),Pc=new Ss(e),Pc}let Lc;function zb(){if(Lc)return Lc;const a=64,e=document.createElement("canvas");e.width=a,e.height=a;const t=e.getContext("2d"),i=t.createRadialGradient(a/2,a/2,0,a/2,a/2,a/2);return i.addColorStop(0,"rgba(255,255,255,0)"),i.addColorStop(.4,"rgba(255,255,255,0)"),i.addColorStop(.6,"rgba(255,255,255,0.9)"),i.addColorStop(.8,"rgba(255,255,255,0.25)"),i.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=i,t.fillRect(0,0,a,a),Lc=new Ss(e),Lc}const Hb=`
|
|
6946
|
+
`,transparent:!0,blending:Ci,depthWrite:!1,side:Ot,fog:!1});this.object=new De(new Qt(f0.RADIUS,128,32,0,Math.PI*2,0,ot.MAX_ANGLE_RAD),t),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}show(e,t){if(!e||!t){this.object.visible=!1;return}this.towards.set(e.x,e.y,e.z).normalize(),this.object.quaternion.setFromUnitVectors(this.up,this.towards),this.object.material.uniforms.uSource.value.copy(this.towards);for(let i=0;i<ot.STEPS;i++){for(let n=0;n<3;n++)this.texels[i*4+n]=Dn.toHalfFloat(Math.min(t[i*3+n],6e4));this.texels[i*4+3]=Dn.toHalfFloat(1)}this.texture.needsUpdate=!0,this.object.visible=!0}dispose(){this.object.geometry.dispose(),this.object.material.dispose(),this.texture.dispose()}}class pl{constructor(e){this.generator=e}static SIZE=128;target=new wo(pl.SIZE,{type:kt,generateMipmaps:!1,minFilter:st,magFilter:st});camera=new Zd(.1,2e5,this.target);filteredTarget;capturedAtMs=-1/0;capturedVersion;get sharp(){return this.target.texture}get filtered(){return this.filteredTarget?.texture}capture(e,t,i,n=[]){const s=e.shadowMap.autoUpdate;e.shadowMap.autoUpdate=!1;const r=n.map(o=>o.visible);for(const o of n)o.visible=!1;this.camera.position.copy(i),this.camera.update(e,t),n.forEach((o,c)=>{o.visible=r[c]}),e.shadowMap.autoUpdate=s,this.filteredTarget=this.generator.fromCubemap(this.target.texture,this.filteredTarget),this.capturedAtMs=performance.now()}dispose(){this.target.dispose(),this.filteredTarget?.dispose()}}class Ji{static REFRESH_MS=250;generator;eye;probes=new Map;constructor(e){Ji.install(),this.generator=new qu(e),this.eye=new pl(this.generator)}static decor;refresh(e,t,i,n,s,r,o,c=[],l){for(const v of[...this.probes.keys()])n.some(m=>m.id===v&&m.shiny)||(this.probes.get(v).dispose(),this.probes.delete(v));const h=[{probe:this.eye}];for(const v of n){if(!v.shiny)continue;let m=this.probes.get(v.id);m||(m=new pl(this.generator),this.probes.set(v.id,m)),h.push({probe:m,reflector:v})}const u=performance.now(),d=()=>h.filter(({probe:v})=>v.capturedVersion!==o),f=d().filter(({probe:v})=>u-v.capturedAtMs>=Ji.REFRESH_MS);if(f.length>0){const v=f.reduce((m,g)=>g.probe.capturedAtMs<m.probe.capturedAtMs?g:m);if(v.reflector){const m=v.reflector.holder.getWorldPosition(this.scratch);v.probe.capture(e,t,m,[v.reflector.holder,...s]),Ji.reflectOn(v.reflector.holder,v.probe)}else{v.probe.capture(e,t,i,[...s,...c]),l?.(v.probe.sharp),Ji.decor=v.probe.filtered;for(const m of r)Ji.reflectOn(m,v.probe);for(const m of n)m.shiny||Ji.reflectOn(m.holder,v.probe)}v.probe.capturedVersion=o}const p=d();if(p.length!==0)return Math.max(16,Math.min(...p.map(({probe:v})=>Ji.REFRESH_MS-(u-v.capturedAtMs))))}scratch=new D;static reflectOn(e,t={filtered:Ji.decor}){e.traverse(i=>{const n=i.material;for(const s of Array.isArray(n)?n:n?[n]:[])s instanceof Eo?t.sharp&&s.setSurroundings(t.sharp):s instanceof oa&&t.filtered&&s.envMap!==t.filtered&&(s.envMap=t.filtered,s.needsUpdate=!0)})}dispose(){this.eye.dispose();for(const e of this.probes.values())e.dispose();this.generator.dispose()}static installed=!1;static install(){if(Ji.installed)return;Ji.installed=!0;const e="iblIrradiance += getIBLIrradiance( geometryNormal );";if(!We.lights_fragment_maps.includes(e)){console.warn("Reflections: three's lights_fragment_maps changed; the environment will light diffusely too");return}We.lights_fragment_maps=We.lights_fragment_maps.replace(e,"// The sky's diffuse light is the hemisphere light's (see Reflections).")}}function jw(a,e){return JSON.stringify(a.cloudLayers)===JSON.stringify(e.cloudLayers)&&a.cloudCover===e.cloudCover&&a.cloudDarkness===e.cloudDarkness&&a.cloudBaseM===e.cloudBaseM&&a.highCloudCover===e.highCloudCover&&a.iceCrystalAlignment===e.iceCrystalAlignment&&a.lowerCloudCover===e.lowerCloudCover&&a.relativeHumidity===e.relativeHumidity&&a.precipitationType===e.precipitationType&&a.precipitationIntensity===e.precipitationIntensity&&a.windDirectionDeg===e.windDirectionDeg&&a.windSpeed===e.windSpeed&&a.storm===e.storm}const Ac=900,Oh=1,$p=4,Zp=5,Jp=.5,to=900,Qw=6371e3,eb=3e4;function jp(a){const e=Math.sqrt(2*Qw*Math.max(a,0));return Math.max(to,Math.min(e,eb))}const Uh=.5,Fh=850,Qp=.03,cn=850,kh=300,tb=.04,qr=4,zh=1.5,em=-1,ib=6,bd=-4,nb=2,sb=20,Tc=2600,ab=.97,rb=.38,Rc=bd,tm=1500,ob=400,cb=[0,45,90,135,180,225,270,315],lb={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},hb=["en","fr"],ub=2,db=16,im=2500,nm=880,Dc=40,sm=60,fb=10,pb=1,mb=150,gb=55,vb=.5,Mb=17,am=.265,rm=[[0,0],...Array.from({length:8},(a,e)=>{const t=e*Math.PI/4;return[Math.cos(t)*am,Math.sin(t)*am]})],Hh=700,Bh=250/1e3,xb=12,om=5,Gh=6,na=[.92,.92,.95],Vh=[.15,.15,.19],cm={snow:{fallSpeedMPerS:2,size:.3,color:new se(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new se(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},er=0,Wh=0,yb=150,lm=3e3,Yr=20,_b=15,hm=er,Sb=40,um=1,wb=9;function dm(a){return um+(wb-um)*a}const fm=new se(.75,.82,.92),bb=10,Eb=.5;function Ab(a){return sr(a/bb,Eb,1)}const Ja=200,pm=.18,mm=.32,Tb=.35,gm=new se(.85,.9,.98),vm=5,Mm=.85,xm=.01;function Xh(a,e){return Math.round(a*(xm+(1-xm)*e))}const ym=230,_m=.7,Sm=.05,Rb=.6,Db=.7,Cb=.15,wm=.35,Ib=3,Pb=1/12,Lb=.5,kn=new se(.82,.86,1),Nb=2500,Ob=1.6,qh=15,Ub={Venus:new se(1,.96,.85),Mars:new se(1,.55,.4),Jupiter:new se(.95,.87,.72),Saturn:new se(.92,.86,.68)};class Wt{renderer;scene=new xs;phenomena=new wn(this.scene);references=new ua(this.scene,()=>this.render());camera;celestialGroup=new Dt;skyMesh;skyGradientMaterial;scatteredSky;lastAstronomy;skyColoursStale=!1;scatteredSkyFrameId=null;skyHoldUntilMs=void 0;onFirstFrameHold;firstFrameReady(){return(!this.scatteredSky||this.scatteredSky.ambient!==void 0)&&!this.iceHalos?.awaitingFirstDisplay}groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;roadSystem=new ln;roadAttribution;roadWays;statedRoads=[];decorModelProvider=$w[0].create();decorModelToken=0;decorModelCredits=new Map;bodySystem=new ct(e=>this.loadBodyModel(e),()=>this.render(),()=>this.relativeScale);bodyOrigin={x:0,z:0};starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;decorReferencePose;decorCurrentPose;decorTime=0;celestialLight=new Gf(16777215,0);celestialLightTarget=new Pt;skyLight=new AM(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;resolution;cssSize={width:1,height:1};frameDirty=!1;flushFrameId=null;framesDriven=!1;lastFrameTimeMs;raycaster=new ph;weather=Pm;observerElevationM=0;siteElevationM=0;air=new dn;groundRadius=to;terrainRadius=to;cloudRendering="volume";layeredClouds;cloudLayerOffsetsM={};cloudOffsetM=new D;cloudFieldOffset=new D;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new D;rainLastVerticalFacing=-1;rainViewportSize=new xe;lightningArmed=!1;lightningFlashes=[];lightningLevel=0;lightningBolt;lightningLight=new Gf(16777215,0);baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new D;sunVisible=!1;lensFlareScratch=new D;sunOcclusionRaycaster=new ph;sunOcclusionDirectionScratch=new D;sunOcclusionRightScratch=new D;sunOcclusionUpScratch=new D;ufoOcclusionRaycaster=new ph;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;finishPass;exposureAccumulation;exposureInstants=1;get developingExposure(){return this.exposureInstants>1&&this.exposureInstantAt!==void 0}static EXPOSURE_BUDGET_MS=12;static exposureInstantsPerFrame(e){return Math.max(3,Math.round(6e6/Math.max(1,e)))}exposureFrameId=null;exposureInstantsDone=0;exposureInstantAt;restatingExposure=!1;lensOptics;instrumentMagnitudeGain=0;meteorSystem;cometTail;satelliteField;iceHalos;lunarDiffraction;lunarDiffractionKey="";rainbow;skyGlow;cometKey;novaKeys=new Set;constructor(e,t=R2()){this.renderer=new OS({canvas:e,antialias:!0}),this.resolution=new dt(Math.min(window.devicePixelRatio||1,2),this.renderer.getContext()),this.renderer.setPixelRatio(this.resolution.pixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=io,this.camera=new Vi(60,e.width/Math.max(e.height,1),.1,Ac*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=t,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=cn-kh,this.celestialLight.shadow.camera.far=cn+kh,this.celestialLight.shadow.bias=-.03/(2*kh),this.celestialLight.shadow.normalBias=tb,this.celestialLight.target=this.celestialLightTarget,this.lightningLight.color.copy(kn),this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight,this.lightningLight),this.scene.add(this.celestialGroup),this.scene.add(this.bodySystem.group),this.scene.add(this.roadSystem.group);const i=new ii(this.renderer,()=>{this.skyColoursStale=!0,this.render()});i.supported?this.scatteredSky=i:i.dispose()}get currentTerrainAttribution(){return this.terrainAttribution}get currentRoadAttribution(){return this.roadAttribution}resize(e,t){this.cssSize.width=e,this.cssSize.height=t,this.renderer.setSize(e,t,!1),this.camera.aspect=e/Math.max(t,1),this.camera.updateProjectionMatrix(),this.render()}setCloudRendering(e){e!==this.cloudRendering&&(this.cloudTransmissionMemo.clear(),this.cloudRendering=e,this.layeredClouds?.dispose(),this.layeredClouds=void 0,this.buildClouds(),this.buildCirrus(),this.render())}setCloudOffset(e,t={}){this.cloudOffsetM.set(e.x,0,e.z),this.cloudLayerOffsetsM=t,this.layeredClouds?.setOffsets(e,t),this.cloudFieldOffset.set(e.x*Bh,0,e.z*Bh);for(const i of[this.cloudUniforms,this.cirrusUniforms])i?.fieldOffset.value.copy(this.cloudFieldOffset);this.iceHalos?.setCloudOffset(this.layeredClouds?.cirrusMask?.offset??this.cloudFieldOffset)}setObserverPose(e){const t=((e.rollDeg??0)+this.gaitOffset.rollDeg)*Hi,i=(e.pitchDeg+this.lookPitchDeg+this.gaitOffset.pitchDeg)*Hi;if(e.headingDeg!==void 0?this.camera.rotation.set(i,-(e.headingDeg+this.lookYawDeg+this.gaitOffset.yawDeg)*Hi,t,"YXZ"):this.camera.rotation.set(i,this.camera.rotation.y,t,"YXZ"),e.elevationM!==this.observerElevationM&&(this.observerElevationM=e.elevationM,this.syncCloudLayer(),Math.abs(jp(e.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/to),this.camera.far=Math.max(Ac*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.terrainMesh&&this.terrainOrigin&&e.lat!==void 0&&e.lng!==void 0){const n=li(this.terrainOrigin.lat,this.terrainOrigin.lng,e.lat,e.lng);this.terrainMesh.position.x=n.x,this.terrainMesh.position.z=n.z}this.poseCameraY=this.groundYUnder(0,0)+1.6+e.elevationM,this.camera.position.y=this.poseCameraY,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.roadSystem.clear(),this.roadAttribution=void 0,this.roadWays=void 0,this.applyGroundDepthWrite(),this.terrainBuildToken++}setTerrainOrigin(e,t,i){if(e===void 0||t===void 0)return;const n=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-n)<n*.1){const{x:c,z:l}=li(e,t,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(c*c+l*l)<mb*(n/to))return}const s=this.terrainOrigin,r=this.terrainRadius;(!s||s.lat!==e||s.lng!==t)&&(this.roadSystem.clear(),this.roadAttribution=void 0),this.terrainOrigin={lat:e,lng:t},this.terrainRadius=n;const o=++this.terrainBuildToken;hw(e,t,this.terrainProviders,n).then(({mesh:c,attribution:l,originElevationM:h})=>{if(o!==this.terrainBuildToken)return;this.setSiteElevation(h??0);const u=this.terrainMesh,d=s?li(e,t,s.lat,s.lng):void 0;u&&d&&Math.hypot(d.x,d.z)<=r&&(c.position.y=u.position.y+this.groundYOfPatch(u,d.x,d.z)),this.disposeMesh(this.terrainMesh),c.renderOrder=pb,this.terrainMesh=c,this.compileNextFrameOffThread(),this.terrainAttribution=l,this.scene.add(c),this.applyGroundDepthWrite(),this.decorCurrentPose&&(this.setObserverPose(this.decorCurrentPose),this.updateDecorAnchoring(this.decorReferencePose,this.decorCurrentPose,this.decorTime)),this.buildRoads(e,t,n),this.drapeStatedRoads(),this.render(),i?.()}).catch(c=>{console.warn("Terrain build failed, keeping the flat ground fallback:",c),i?.()})}static ROADS_MAX_RADIUS_M=5e3;buildRoads(e,t,i){const n=this.terrainProviders.roads;if(!n||i>Wt.ROADS_MAX_RADIUS_M){this.roadSystem.clear(),this.roadAttribution=void 0;return}const s=this.roadWays;if(s&&s.lat===e&&s.lng===t&&s.radiusM===i){this.drapeRoads(s.ways,e,t,n.contemporary);return}n.getRoads(a1(e,t,i)).then(r=>{this.terrainOrigin?.lat!==e||this.terrainOrigin?.lng!==t||(this.roadWays={lat:e,lng:t,radiusM:i,ways:r},this.drapeRoads(r,e,t,n.contemporary))}).catch(r=>{console.warn("Roads unavailable, drawing none:",r)})}setStatedRoads(e){e!==this.statedRoads&&(this.statedRoads=e,this.drapeStatedRoads(),this.render())}drapeStatedRoads(){const e=this.terrainMesh;e&&(this.roadSystem.group.position.copy(e.position),this.roadSystem.setStated(this.statedRoads,(t,i)=>this.groundYOfPatch(e,t,i)))}drapeRoads(e,t,i,n){const s=this.terrainMesh;s&&(this.roadSystem.group.position.copy(s.position),this.roadSystem.set(e,t,i,(r,o)=>this.groundYOfPatch(s,r,o),n),this.roadAttribution=e.length>0?this.terrainProviders.roads?.attribution:void 0,this.compileNextFrameOffThread(),this.render())}setShowCompass(e){this.showCompass!==e&&(this.showCompass=e,this.disposeCompassLabels(),e&&this.buildCompassLabels(),this.render())}applyLensFlareTint(e){if(!this.lensFlare)return;const t=gb*(this.sunArriving[1]/Mb);this.lensFlare.uniforms.uColorGain.value.setRGB(t*e[0],t*e[1],t*e[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const[e,t,i]=this.sunArriving,n=Math.max(t,1e-30);this.lensFlare.uniforms.uDazzleColour.value.setRGB(e/n,1,i/n),this.lensFlare.uniforms.uVeilStrength.value=Ui.K*t*this.sunUnhiddenFraction}sunArriving=[0,0,0];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;if(this.compassSprites.some(t=>t.visible!==e)){for(const t of this.compassSprites)t.visible=e;this.developingExposure?this.exposureInstantsDone>0&&this.presentExposure():this.render()}}setWeather(e){this.cloudTransmissionMemo.clear(),!jw(this.weather,e)&&(this.weather=e,this.air=dn.of(e),this.applyAir(),this.scatteredSky?.setConditions({aerosolOpticalDepth:e.relativeHumidity===void 0?void 0:Vs.steppedOpticalDepth(e.relativeHumidity)}),this.pumpScatteredSky(),this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lastAstronomy&&(this.buildIceHalos(this.lastAstronomy.sun,this.lastAstronomy.moon),this.buildRainbow(this.lastAstronomy.sun,this.lastAstronomy.moon),this.buildLunarDiffraction(this.lastAstronomy.moon)),this.lightningArmed=e.storm&&e.cloudDarkness>=Lb,this.syncAnimationLoop(),this.render())}setDecor(e){if(this.decorObjects!==e){this.decorObjects=e,this.decorModelToken++,this.decorModelCredits.clear();for(const t of this.decorGroups.values())t.removeFromParent(),vi.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear();for(const t of e){const i=vi.build(t,t.lit??!1);this.scene.add(i),this.decorGroups.set(t.id,i),t.kind==="streetlight"&&this.addStreetlightLight(t.id,i),this.loadDecorModel(t,this.decorModelToken)}this.celestialLight.castShadow=this.decorGroups.size>0||this.bodySystem.any}}setDecorModelProvider(e){this.decorModelProvider=e;const t=this.decorObjects;this.decorObjects=[],this.setDecor(t)}get currentDecorModelCredits(){return[...this.decorModelCredits.values(),...this.bodySystem.modelCredits]}get bodyGround(){const{x:e,z:t}=this.bodyOrigin,i=this.groundYUnder(e,t);return{heightAt:(n,s)=>this.groundYUnder(e+n,t-s)-i}}setBodies(e,t=0,i=e.map(r=>r.id),n=[],s){const{x:r,z:o}=this.bodyOrigin,c=this.scatteredSky;this.bodySystem.set(e,{originX:r,originZ:o,originGroundY:this.groundYUnder(r,o),eye:this.camera.position,groundYAt:(h,u)=>this.groundYUnder(h,u),wind:s,light:this.plumeLight(),transmittance:(h,u,d)=>this.transmittanceTo(h,u,d)},t,c?(h,u)=>c.relativeOfLuminance(h,u):void 0,i),this.bodySystem.setSmoke(n,t),this.bodySystem.any&&(this.celestialLight.castShadow=!0);const l=this.bodySystem.furthestFrom(this.camera.position)*1.2;l>this.camera.far&&(this.camera.far=l,this.camera.updateProjectionMatrix())}plumeLight(){const e=this.celestialLight.color,t=this.celestialLight.intensity*.5,i=this.skyLight.color,n=this.skyLight.groundColor,s=this.skyLight.intensity,r=(o,c,l)=>(o*t+(c+l)/2*s)/Math.PI;return[r(e.r,i.r,n.r),r(e.g,i.g,n.g),r(e.b,i.b,n.b)]}bodyOutline(e,t){return this.bodySystem.outlineOf(e,t)}async loadBodyModel(e){const t=e.url?void 0:e.id?await this.decorModelProvider.entry(e.id):void 0,i=e.url??t?.url,n=e.credit??t?.credit;if(!(!i||!n))return{scene:await Kp(i),credit:n,headingOffsetDeg:e.headingOffsetDeg??t?.headingOffsetDeg}}async loadDecorModel(e,t){const i=e.model;if(!(!i||!vi.usesModel(e)))try{const n=i.url?void 0:i.id?await this.decorModelProvider.entry(i.id):void 0,s=i.url??n?.url,r=i.credit??n?.credit;if(!s||!r)return;const o=await Kp(s);if(t!==this.decorModelToken)return;const c=this.decorGroups.get(e.id);if(!c)return;Ji.reflectOn(o),vi.applyModel(c,e,o,{headingOffsetDeg:i.headingOffsetDeg??n?.headingOffsetDeg,depictedSizeM:n?.sizeM}),this.decorModelCredits.set(e.id,r),this.render()}catch(n){console.warn(`Keeping the built-in shape for decor "${e.id}":`,n)}}updateDecorAnchoring(e,t,i=0){this.decorReferencePose=e,this.decorCurrentPose=t,this.decorTime=i;const n=e?.lat!==void 0&&e.lng!==void 0&&t?.lat!==void 0&&t?.lng!==void 0?li(e.lat,e.lng,t.lat,t.lng):{x:0,z:0},s=this.decorObjects.find(l=>l.witnessSide!==void 0&&Um(l.kind));if(this.terrainMesh&&this.terrainOrigin&&t?.lat!==void 0&&t.lng!==void 0){const l=li(this.terrainOrigin.lat,this.terrainOrigin.lng,t.lat,t.lng);this.terrainMesh.position.x=l.x-(s?0:this.gaitOffset.eastM),this.terrainMesh.position.z=l.z+(s?0:this.gaitOffset.northM),this.roadSystem.group.position.copy(this.terrainMesh.position)}s||(n.x-=this.gaitOffset.eastM,n.z+=this.gaitOffset.northM,this.camera.position.y=this.poseCameraY+this.gaitOffset.upM,this.celestialGroup.position.y=this.camera.position.y);const r={x:0,z:0};let o=0;if(s){const l=vi.occupantView(s),h=-(s.headingDeg??0)*Hi,u=l.x*Math.cos(h)+l.z*Math.sin(h),d=-l.x*Math.sin(h)+l.z*Math.cos(h),f=s.eastM+n.x,p=-s.northM+n.z;r.x=-(f+u),r.z=-(p+d),this.camera.position.y=this.groundYUnder(f,p)+l.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*Hi,-(l.headingDeg+this.indoorLookYawDeg)*Hi,0,"YXZ")}this.bodyOrigin={x:n.x+r.x,z:n.z+r.z},this.placeShadowFrustum();for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=Ad(l,i),d=u.eastM+n.x+r.x,f=-u.northM+n.z+r.z,p=this.terrainMesh,v=`${p?.geometry.uuid}:${(d-(p?.position.x??0)).toFixed(3)}:${(f-(p?.position.z??0)).toFixed(3)}:${(p?.position.y??0).toFixed(3)}:${u.headingDeg}:${u.altitudeM}`;if(h.userData.footprintKey!==v&&(h.userData.footprintGroundY=this.groundUnderFootprint(l,d,f,u.headingDeg,u.altitudeM),h.userData.footprintKey=v),h.position.set(d,h.userData.footprintGroundY+u.altitudeM,f),l.kind==="crop"){const m=Math.hypot(d,f);h.visible=m<=yb}if(u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*Hi),l.kind==="crop"&&h.visible){const m=this.terrainMesh,g=[m?.geometry.uuid,d-(m?.position.x??0),f-(m?.position.z??0),h.position.y-(m?.position.y??0),u.headingDeg,u.altitudeM].map(_=>typeof _=="number"?_.toFixed(4):_).join(":");h.userData.cropGroundKey!==g&&(vi.fitCropToGround(h,(_,w)=>this.groundYUnder(_,w)+u.altitudeM),h.userData.cropGroundKey=g)}o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(Ac*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-c)>1&&(this.camera.far=c,this.camera.updateProjectionMatrix())}groundYUnder(e,t){const i=this.terrainMesh;return i?i.position.y+this.groundYOfPatch(i,e-i.position.x,t-i.position.z):Wh}groundYOfPatch(e,t,i){const n=e.geometry.getAttribute("position"),s=Math.round(Math.sqrt(n.count));if(s<2||s*s!==n.count)return Wh;const r=n.getX(0),o=n.getX(s-1),c=n.getZ(0),l=n.getZ((s-1)*s),h=sr((t-r)/(o-r)*(s-1),0,s-1),u=sr((i-c)/(l-c)*(s-1),0,s-1);if(!Number.isFinite(h)||!Number.isFinite(u))return Wh;const d=Math.min(Math.floor(h),s-2),f=Math.min(Math.floor(u),s-2),p=h-d,v=u-f,m=(S,b)=>n.getY(S*s+b),g=m(f,d),_=m(f,d+1),w=m(f+1,d),M=m(f+1,d+1);return p+v<=1?g+(_-g)*p+(w-g)*v:M+(w-M)*(1-p)+(_-M)*(1-v)}groundUnderFootprint(e,t,i,n,s=0){return vi.groundUnderFootprint(e,t,i,n,(r,o)=>this.groundYUnder(r,o),s)}lookYawDeg=0;lookPitchDeg=0;poseCameraY=1.6;setGait(e){this.gaitOffset=e}gaitOffset={eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0};setLookOffset(e,t){this.lookYawDeg=e,this.lookPitchDeg=t}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(e,t){this.indoorLookYawDeg=e,this.indoorLookPitchDeg=t}updateDecorLitState(e,t=0){for(const i of this.decorObjects){const n=this.decorGroups.get(i.id);if(n&&i.lights?.length&&vi.setLights(n,i.lights,e,n.position.distanceTo(this.camera.position),t,this.relativeScale),i.kind!=="streetlight"&&i.kind!=="vehicle")continue;const s=this.decorGroups.get(i.id);if(!s)continue;const r=l2(i,e);vi.setLit(s,i.kind,r,this.relativeScale);const o=this.streetlightLights.get(i.id);o&&(o.visible=r)}}addStreetlightLight(e,t){const i=vi.bodyOf(t),n=i.children.find(r=>r.userData.emissive);if(!n)return;const s=new Eg(16764006,tm*this.relativeScale,ob);s.position.copy(n.position).multiply(i.scale),s.castShadow=!0,s.shadow.mapSize.set(512,512),s.shadow.bias=-.002,t.add(s),this.streetlightLights.set(e,s)}setAstronomy(e){(!this.lastAstronomy||Math.abs(this.lastAstronomy.sun.altitudeDeg-e.sun.altitudeDeg)>2)&&(this.surroundings=void 0,this.scatteredSky?.resetSurroundings()),this.lastAstronomy=e,this.scatteredSky?.update(this.scatteredSkyState(e)),this.skyHoldUntilMs===void 0&&(this.skyHoldUntilMs=performance.now()+im,this.onFirstFrameHold?.(!0),setTimeout(()=>this.render(),im+20)),this.pumpScatteredSky(),this.lastSunPosition=e.sun,this.buildSky(e.sun),this.buildGround();const t=Gc(e.sun.altitudeDeg,this.instrumentMagnitudeGain);this.buildStars(e.stars,t),this.placeBodies(e,t),this.buildIceHalos(e.sun,e.moon),this.buildRainbow(e.sun,e.moon),this.applySkyColours(e),this.syncAnimationLoop(),this.render()}static relativeSkyOf(e,t){const i=r=>{const o=Tn.luminanceOf(r);if(!(o>0))return[0,0,0];const c=Ee.relativeOfResponse(o)/o;return[r[0]*c,r[1]*c,r[2]*c]},n=i(e.zenith),s=i(e.horizon);return{zenith:n,horizon:s,airlight:s,skyIrradiance:[n[0]*Math.PI,n[1]*Math.PI,n[2]*Math.PI],scale:t}}placeBodies(e,t){this.bodiesScale=this.relativeScale,this.setBodyMesh("sun",e.sun,qr,new se(1,.96,.88),e.sun.magnitude),this.setMoonMesh(e.moon,t),this.buildPlanets(e.planets,t),this.buildComet(e.comet,t),this.buildNovae(e.novae??[],t)}bodiesScale=0;applySkyColours(e){this.skyColoursStale=!1,this.bodiesScale!==this.relativeScale&&(this.placeBodies(e,Gc(e.sun.altitudeDeg,this.instrumentMagnitudeGain)),this.applyDazzleStrength(),this.buildIceHalos(e.sun,e.moon),this.buildRainbow(e.sun,e.moon));const t=this.scatteredSky?.ambient??Wt.relativeSkyOf(td(e.sun.altitudeDeg),this.relativeScale),i=t,n=this.lightUnderClouds(e),s=r=>n?[0,1,2].map(o=>r[o]*n.through+n.radiance[o]*(1-n.through)):[r[0],r[1],r[2]];this.baseFogColor=[i.horizon[0],i.horizon[1],i.horizon[2]],this.airlight=s(i.airlight),this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.scatteredSky?.ready?this.scatteredSky.material:this.skyGradientMaterial),this.updateCelestialLight(e,t),this.updateCloudLighting(e.sun,this.baseFogColor),Ft.setEye(this.scatteredSky?.rodShare??0,this.relativeScale),this.updateTwinkle(this.twinkleSeconds);for(const r of this.streetlightLights.values())r.intensity=tm*this.relativeScale;this.buildSkyGlow(e,i.zenith),this.applyAir(),this.buildLunarDiffraction(e.moon)}reflections;sceneVersion=0;reflectionTimer;buildLunarDiffraction(e){const t=this.scatteredSky?.ready?this.scatteredSky:void 0;if(e.altitudeDeg<-.5||!t){this.lunarDiffraction?.show(void 0),this.lunarDiffractionKey="";return}const i=this.weather.relativeHumidity,n=(i===void 0?Oe.DEFAULT_AEROSOL_OPTICAL_DEPTH:Vs.opticalDepth(i))*Oe.aerosolDensity(this.siteElevationM+this.observerElevationM),s=this.cloudTransmission(e),r=-Math.log(Math.max(this.cloudTransmission(e,!0),1e-4)),o=ot.aureoleScale(n,ot.airMass(e.altitudeDeg))*s,c=ot.coronaScale(r),l=ot.illuminanceOf(e.magnitude),h=[e.altitudeDeg.toFixed(1),e.azimuthDeg.toFixed(1),e.magnitude.toFixed(2),o.toExponential(2),c.toExponential(2),Math.log10(Math.max(t.adaptation,1e-12)).toFixed(2)].join(":");if(h===this.lunarDiffractionKey)return;this.lunarDiffractionKey=h,this.lunarDiffraction||(this.lunarDiffraction=new f0,this.celestialGroup.add(this.lunarDiffraction.object));const u=ot.profile(ot.HAZE_COARSE_MODE),d=ot.profile(ot.CLOUD_DROPLETS),f=Mp(e.altitudeDeg),p=new Float32Array(ot.STEPS*3);let v=0;for(let w=0;w<ot.STEPS;w++){const M=w*3,S=[0,1,2].map(T=>l*f[T]*(o*u[M+T]+c*d[M+T])),b=Tn.shown(S,Tn.luminanceOf(S),(T,x)=>t.relativeOfLuminance(T,x));p.set(b,M),v=Math.max(v,Tn.response(b))}const{x:m,y:g,z:_}=ni(e.altitudeDeg,e.azimuthDeg,1);this.lunarDiffraction.show(v>1/200?{x:m,y:g,z:_}:void 0,p)}applyAir(){this.scene.fog instanceof Ma||(this.scene.fog=new Ma),this.scene.fog.setAir(this.air,this.siteElevationM,this.airlight),this.horizonColour.setRGB(this.baseFogColor[0],this.baseFogColor[1],this.baseFogColor[2])}airlight=[0,0,0];horizonColour=new se(0,0,0);transmittanceTo(e,t,i){const n=this.camera.position;return this.air.transmittance(this.siteElevationM+n.y,this.siteElevationM+t,Math.hypot(e-n.x,t-n.y,i-n.z))}setSiteElevation(e){Math.abs(e-this.siteElevationM)<1||(this.siteElevationM=e,this.applyAir(),this.lastAstronomy&&this.scatteredSky?.update(this.scatteredSkyState(this.lastAstronomy)))}scatteredSkyState(e){return{altitudeM:this.siteElevationM+this.observerElevationM+1.6,sun:{altitudeDeg:e.sun.altitudeDeg,azimuthDeg:e.sun.azimuthDeg,magnitude:e.sun.magnitude},moon:{altitudeDeg:e.moon.altitudeDeg,azimuthDeg:e.moon.azimuthDeg,magnitude:e.moon.magnitude,phaseAngleDeg:Ye.phaseAngleOf(e.moon.phase.illuminatedFraction)}}}pumpScatteredSky(){const e=this.scatteredSky;!e||e.tables.ready||this.scatteredSkyFrameId!==null||this.contextReleased||(this.scatteredSkyFrameId=requestAnimationFrame(()=>{this.scatteredSkyFrameId=null,!this.contextReleased&&(e.advance(this.skyHoldUntilMs?db:ub),this.pumpScatteredSky())}))}cancelScatteredSkyPump(){this.scatteredSkyFrameId!==null&&(cancelAnimationFrame(this.scatteredSkyFrameId),this.scatteredSkyFrameId=null)}setSatellites(e){if(e.length===0&&!this.satelliteField?.count)return;this.satelliteField||(this.satelliteField=new Ew(Fh),this.celestialGroup.add(this.satelliteField.object));const t=Gc(this.lastSunPosition?.altitudeDeg??-90,this.instrumentMagnitudeGain);this.satelliteField.set(e,t,i=>this.cloudTransmission(i),(i,n)=>this.arrivingIlluminance(i,n,1)),this.render()}pickSatelliteAt(e,t){if(!this.satelliteField?.count)return;this.aimAtScreenPoint(this.raycaster,e,t);const i=Math.cos(Qp*this.camera.fov*Math.PI/180),n=this.satelliteField.nearest(this.raycaster.ray.direction,i);return n&&this.groundHides(e,t)?void 0:n}updateCelestialLight(e,t){const i=this.relativeScale,n=e.sun.altitudeDeg>=Rc,s=!n&&e.moon.altitudeDeg>=Rc,r=n?e.sun:e.moon,o=[0,0,0],c=Math.max(0,Math.sin(Math.max(r.altitudeDeg,0)*Hi)),l=n||s?this.cloudTransmission(r):1,h=-Math.log(Math.max(l,1e-6)),u=Math.max(0,1/(1+.1125*h)-l),d=[0,0,0];if(n||s){const _=ot.illuminanceOf(r.magnitude)*i,w=this.air.transmittanceFromSpace(this.siteElevationM+this.observerElevationM,r.altitudeDeg);for(let T=0;T<3;T++)o[T]=_*w[T]*l,d[T]=_*w[T]*u*c,this.cloudBeam[T]=_*w[T];const{x:M,y:S,z:b}=ni(r.altitudeDeg,r.azimuthDeg,1);this.cloudBeamDirection.set(M,S,b)}else this.cloudBeam.fill(0);const f=this.surroundings;if(f)this.skyLight.color.setRGB(f.up[0]*i,f.up[1]*i,f.up[2]*i),this.skyLight.groundColor.setRGB(f.down[0]*i,f.down[1]*i,f.down[2]*i);else{const _=this.skyCloudTransmission(),w=t.skyIrradiance,M=[0,1,2].map(b=>w[b]*_+d[b]);this.skyLight.color.setRGB(M[0],M[1],M[2]);const S=Ge.GROUND_ALBEDO;this.skyLight.groundColor.setRGB(S*(M[0]+o[0]*c),S*(M[1]+o[1]*c),S*(M[2]+o[2]*c))}if(this.skyLight.intensity=1,!n&&!s){this.celestialLight.intensity=0;return}const{x:p,y:v,z:m}=ni(r.altitudeDeg,r.azimuthDeg,1);this.lightDirection.set(p,v,m),this.placeShadowFrustum();const g=Math.max(o[0],o[1],o[2],1e-30);this.celestialLight.color.setRGB(o[0]/g,o[1]/g,o[2]/g),this.celestialLight.intensity=g,this.celestialLight.castShadow=this.decorGroups.size>0||this.bodySystem.any}lightDirection=new D(0,1,0);placeShadowFrustum(){const e=this.lightDirection,t=this.celestialLight.shadow.camera,i=(t.right-t.left)/this.celestialLight.shadow.mapSize.x,n=this.shadowAxisX.crossVectors(this.shadowUp,e);n.lengthSq()<1e-8&&n.set(1,0,0),n.normalize();const s=this.shadowAxisY.crossVectors(e,n).normalize(),r=this.shadowWorld.set(this.bodyOrigin.x,0,this.bodyOrigin.z),o=l=>{const h=r.dot(l)/i;return(h-Math.round(h))*i},c=this.celestialLightTarget.position.set(0,0,0).addScaledVector(n,o(n)).addScaledVector(s,o(s));this.celestialLightTarget.updateMatrixWorld(),this.celestialLight.position.copy(c).addScaledVector(e,cn)}shadowUp=new D(0,1,0);shadowAxisX=new D;shadowAxisY=new D;shadowWorld=new D;skyCloudTransmission(){let e=this.cloudTransmission({altitudeDeg:90,azimuthDeg:0}),t=1;for(const i of[20,45,70]){const n=i*Hi,s=Math.sin(n)*Math.cos(n)*2;for(let r=0;r<360;r+=60)e+=s*this.cloudTransmission({altitudeDeg:i,azimuthDeg:r}),t+=s}return e/t}cloudBeam=[0,0,0];cloudBeamDirection=new D(0,1,0);get relativeScale(){return this.scatteredSky?.relativeScale??1/Ee.semiSaturation(Ee.DAYLIGHT_ANCHOR_CD_M2)}setMeteorShower(e,t,i){this.meteorSystem||(this.meteorSystem=new pi,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(e,t,i)}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=ri.starPointsOf(e),i=ri.flareArtifactsOf(e);t===this.starPoints&&i===this.lensFlareArtifactIntensity||(this.starPoints=t,this.lensFlareArtifactIntensity=i,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=t,this.lensFlare.uniforms.uFlareIntensity.value=i),this.render())}setInstrumentGain(e,t=!1){this.instrumentMagnitudeGain=Number.isFinite(e)?e:0,this.scatteredSky?.setInstrument(t,this.instrumentMagnitudeGain)}render(){this.restatingExposure||(this.sceneVersion++,this.frameDirty=!0,this.resolution.noteChange(performance.now()),!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()})))}drawIfDirty(){if(!(!this.frameDirty||this.contextReleased)){if(this.skyHoldUntilMs){if(!this.firstFrameReady()&&performance.now()<this.skyHoldUntilMs)return;this.skyHoldUntilMs=null,this.iceHalos?.setUrgent(!1),this.onFirstFrameHold?.(!1)}if(this.skyColoursStale&&this.lastAstronomy&&this.applySkyColours(this.lastAstronomy),this.compileBeforeNextDraw){this.compileBeforeNextDraw=!1;const e=this.compileOffThread().then(()=>{this.compiling===e&&(this.compiling=void 0,this.render())});this.compiling=e;return}if(!this.compiling){this.frameDirty=!1,this.refreshReflections(),this.resolution.beginDrawing();try{this.renderOnce()}finally{this.resolution.endDrawing()}this.developingExposure&&this.startExposure()}}}compileBeforeNextDraw=!1;compiling;static COMPILE_WAIT_MS=1500;compileOffThread(){const e=this.renderer.compile(this.scene,this.camera);if(!this.renderer.extensions.get("KHR_parallel_shader_compile"))return Promise.resolve();const t=this.renderer.properties,i=performance.now()+Wt.COMPILE_WAIT_MS;return new Promise(n=>{const s=()=>{if(this.contextReleased)return n();for(const r of e){const o=t.get(r)?.currentProgram;(!o||o.isReady())&&e.delete(r)}e.size===0||performance.now()>i?n():setTimeout(s,10)};s()})}compileNextFrameOffThread(){this.compileBeforeNextDraw=!0}contextReleased=!1;releaseContext(){this.contextReleased||(this.contextReleased=!0,this.stopTwinkle(),this.cancelFlush(),this.cancelExposure(),this.compiling=void 0,this.cancelScatteredSkyPump(),this.renderer.forceContextLoss())}restoreContext(){this.contextReleased&&(this.contextReleased=!1,this.renderer.forceContextRestore(),this.scatteredSky?.invalidate(),this.pumpScatteredSky(),this.compileNextFrameOffThread(),this.syncAnimationLoop(),this.render())}cancelFlush(){this.flushFrameId!==null&&(cancelAnimationFrame(this.flushFrameId),this.flushFrameId=null)}frame(e){if(this.animationsRunning){const t=this.lastFrameTimeMs===void 0?0:e-this.lastFrameTimeMs;this.lastFrameTimeMs=e,this.hasAnimations()&&this.animate(e,t);const i=this.resolution.ratioFor(e,t);i!==this.renderer.getPixelRatio()&&this.applyPixelRatio(i)}this.drawIfDirty()}refreshReflections(){this.reflections??=new Ji(this.renderer);const e=[...this.compassSprites,...this.lensFlare?[this.lensFlare.mesh]:[],...[...this.glareSprites.values()].map(s=>s.mesh)],t=[...this.starTiers.map(s=>s.points),...[...this.bodyMeshes.values()].filter(s=>s instanceof us),...[this.rainSystem?.points,this.precipitationPoints,this.rainSplashSystem?.points].filter(s=>s!==void 0)],i=this.relativeScale,n=this.reflections.refresh(this.renderer,this.scene,this.camera.position,this.bodySystem.reflectors,e,[...this.decorGroups.values()],this.sceneVersion,t,s=>this.measureSurroundings(s,i));n===void 0||this.reflectionTimer||(this.reflectionTimer=setTimeout(()=>{this.reflectionTimer=void 0,this.frameDirty=!0,!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()}))},n))}measureSurroundings(e,t){const i=this.lastAstronomy;if(!i)return;this.probeIrradiance??=new oo;const n=[i.sun,i.moon].filter(s=>s.altitudeDeg>-2).map(s=>ni(s.altitudeDeg,s.azimuthDeg,1));this.probeIrradiance.measure(this.renderer,e,n,s=>{const r=d=>d.map(f=>f/t),o=this.surroundings,c={up:r(s.up),down:r(s.down)},l=(d,f)=>d.some((p,v)=>Math.abs(p-f[v])>.03*Math.max(Math.abs(p),Math.abs(f[v]),1e-12)),h=!o||l(o.up,c.up)||l(o.down,c.down);h&&(this.surroundings=c);const u=this.scatteredSky?.adaptToSurroundings(Math.exp(s.logAverage)/t)??!1;!h&&!u||(this.skyColoursStale=!0,this.render())})}lightUnderClouds(e){const t=this.surroundings;if(!t)return;const i=e.sun.altitudeDeg>=Rc?e.sun:e.moon.altitudeDeg>=Rc?e.moon:void 0;if(!i)return;const n=this.relativeScale/Math.PI;return{through:this.cloudTransmission(i),radiance:[t.up[0]*n,t.up[1]*n,t.up[2]*n]}}probeIrradiance;surroundings;animate(e,t){const i=Math.min(t/1e3,Pb);this.twinkleSeconds=e/1e3,this.updateTwinkle(this.twinkleSeconds),this.updatePrecipitation(e/1e3,i),this.updateRain(i),this.lensFlare&&(this.lensFlare.uniforms.uTime.value=e/1e3),this.developingExposure||(this.frameDirty=!0)}setMaxPixelRatio(e){this.resolution.maximum=e,this.renderer.getPixelRatio()>this.resolution.maximum&&this.applyPixelRatio(this.resolution.maximum)}applyPixelRatio(e){this.renderer.setPixelRatio(e),this.renderer.setSize(this.cssSize.width,this.cssSize.height,!1),this.frameDirty=!0}setExposure(e,t){const i=t?Math.max(1,Math.round(e)):1;if(i===this.exposureInstants&&(i===1||t===this.exposureInstantAt)){this.exposureInstantAt=t;return}this.exposureInstants=i,this.exposureInstantAt=t,i===1&&(this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0),this.render()}renderOnce(e){if(this.onMapSubjectBounds){const r=this.mapSubjectBounds();e?this.exposureSubjectBounds.push(...r):this.onMapSubjectBounds(r)}const t=this.usableEquidistantPass();this.phenomena.setCloudLayers(this.layeredClouds?.volumes??[]),this.phenomena.place(this.camera,(r,o,c)=>this.directionAtScreenPoint(r,o,c),r=>this.screenPointOf(r)),this.references.place(this.camera);const i=Math.max(this.phenomena.furthestM,this.references.furthestM)*1.2;i>this.camera.far&&(this.camera.far=i,this.camera.updateProjectionMatrix()),fn.uRodShare.value=this.scatteredSky?.rodShare??0,fn.uRelativeScale.value=this.relativeScale;const n=this.references.any||this.phenomena.any||this.compassSprites.some(r=>r.visible);fn.uHasOverlay.value=n?1:0;const s=n?r=>this.renderOverlayPasses(r):void 0;if(this.skyGlow?.setDestinationEncoded(!1),!t){this.updateLensFlarePosition();const r=this.usableDepthOfFieldPass();r?r.render(this.renderer,this.scene,this.camera,s,e):this.usableFinishPass().render(this.renderer,this.scene,this.camera,s,void 0,e);return}t.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition(),s,r=>{this.lensFlare&&(this.lensFlare.mesh.visible=r?!1:this.sunVisible)},()=>this.renderDazzleOnResample(),e)}renderOverlayPasses(e=this.camera){this.renderReferencesPass(e),this.renderPhenomenaPass(e),this.renderHudPass(e)}renderHudPass(e){if(!this.compassSprites.some(n=>n.visible))return;const t=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,e.layers.set(Zp),this.renderer.render(this.scene,e),e.layers.set(0),this.renderer.autoClear=t,this.renderer.shadowMap.autoUpdate=i}renderReferencesPass(e){if(!this.references.any)return;const t=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,e.layers.set(g1),this.renderer.render(this.scene,e),e.layers.set(0),this.renderer.autoClear=t,this.renderer.shadowMap.autoUpdate=i}setReferences(e){this.references.set(e)}referenceAspect(e){return this.references.aspectOf(e)}directionAt(e,t){return this.directionAtScreenPoint(e,t,new D)}referenceFailedToLoad(e){return this.references.failedToLoad(e)}setReferencesShown(e){this.references.setShown(e),this.render()}setReferenceView(e,t){this.references.setView(e,t),this.render()}renderPhenomenaPass(e){if(!this.phenomena.any)return;const t=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.renderer.clearDepth();for(const n of this.decorObjects){const s=this.decorGroups.get(n.id);s&&Wt.markDecorDepth(s,n.kind!=="crop")}e.layers.set(Oh),this.scene.overrideMaterial=this.decorDepthMaterial,this.renderer.render(this.scene,e),this.scene.overrideMaterial=null,e.layers.set(m1),this.renderer.render(this.scene,e),e.layers.set(0),this.renderer.autoClear=t,this.renderer.shadowMap.autoUpdate=i}decorDepthMaterial=new mn({colorWrite:!1});static markDecorDepth(e,t){e.traverse(i=>{if(!(i instanceof De))return;const n=Array.isArray(i.material)?i.material[0]:i.material;t&&n.depthWrite!==!1&&n.blending!==Ci?i.layers.enable(Oh):i.layers.disable(Oh)})}startExposure(){this.cancelExposure(),this.exposureSubjectBounds=[];const e=this.renderer.getDrawingBufferSize(new xe),t=Math.max(1,Math.round(e.x)),i=Math.max(1,Math.round(e.y));this.exposureAccumulation||(this.exposureAccumulation=new VS(t,i)),this.exposureAccumulation.resize(t,i),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 i=1/this.exposureInstants;this.resolution.beginDrawing();const n=performance.now()+Wt.EXPOSURE_BUDGET_MS,s=Wt.exposureInstantsPerFrame(t.instantTarget.scene.width*t.instantTarget.scene.height);let r=0;do{this.restateAt(e,this.exposureInstantsDone);const o=this.compassSprites.map(c=>c.visible);for(const c of this.compassSprites)c.visible=!1;try{this.renderOnce(t.instantTarget)}finally{this.compassSprites.forEach((c,l)=>{c.visible=o[l]})}t.add(this.renderer,i),this.exposureInstantsDone++,r++}while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<n&&r<s);this.restateAt(e,0),this.presentExposure(),this.resolution.endDrawing(),this.exposureInstantsDone<this.exposureInstants&&(this.exposureFrameId=requestAnimationFrame(()=>this.developExposure()))}presentExposure(){if(fn.uRodShare.value=this.scatteredSky?.rodShare??0,fn.uHasOverlay.value=1,fn.uRelativeScale.value=this.relativeScale,this.exposureAccumulation?.develop(this.renderer,this.exposureInstants/this.exposureInstantsDone),this.onMapSubjectBounds?.(this.exposureSubjectBounds),!this.compassSprites.some(s=>s.visible))return;const e=new xs,t=new Cn(-1,1,1,-1,0,2),i=Dc/(nm*Math.tan(sm*Hi/2));for(const s of this.compassSprites){if(!s.visible)continue;const r=s.getWorldPosition(new D).sub(this.camera.position).normalize(),o=this.screenPointOf(r);if(!o)continue;const c=new Nr(s.material);c.position.set(o.ndcX,o.ndcY,-1),c.scale.set(i/this.camera.aspect,i,1),e.add(c)}const n=this.renderer.autoClear;this.renderer.autoClear=!1;try{this.renderer.render(e,t)}finally{this.renderer.autoClear=n}}onMapSubjectBounds;exposureSubjectBounds=[];static MAP_SUBJECT_NEAREST_M=8;mapSubjectBounds(){const e=[],t=new vn,i=new D,n=this.decorObjects.filter(r=>r.track?.length||r.kind==="aircraft"||r.kind==="vehicle").map(r=>this.decorGroups.get(r.id)),s=this.bodySystem.reflectors.map(r=>r.holder);for(const r of[...n,...s]){if(!r?.visible||(t.setFromObject(r),t.isEmpty())||t.distanceToPoint(this.camera.position)<Wt.MAP_SUBJECT_NEAREST_M)continue;let o=1/0,c=-1/0,l=1/0,h=-1/0;for(const u of[t.min.x,t.max.x])for(const d of[t.min.y,t.max.y])for(const f of[t.min.z,t.max.z]){i.set(u,d,f).sub(this.camera.position).normalize();const p=this.screenPointOf(i);if(!p)continue;const v=(p.ndcX+1)/2,m=(1-p.ndcY)/2;o=Math.min(o,v),c=Math.max(c,v),l=Math.min(l,m),h=Math.max(h,m)}Number.isFinite(o)&&e.push({x:o,y:l,width:c-o,height:h-l})}return e}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 xe),i=Math.max(1,Math.round(t.x)),n=Math.max(1,Math.round(t.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new co(i,n)),this.depthOfFieldPass.resize(i,n),this.depthOfFieldPass.setLens(e.focalLengthMm,e.fNumber,e.focusDistance,e.frameHeightMm),this.depthOfFieldPass}usableFinishPass(){const e=this.renderer.getDrawingBufferSize(new xe);return this.finishPass?this.finishPass.resize(e.x,e.y):this.finishPass=new d0(e.x,e.y),this.finishPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const e=this.renderer.getDrawingBufferSize(new xe);return this.equidistantPass?this.equidistantPass.resize(e.x,e.y):this.equidistantPass=new mi(e.x,e.y),this.equidistantPass}aimAtScreenPoint(e,t,i){const n=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!n){e.setFromCamera(new xe(t,i),this.camera);return}const s=n.directionFor(t,i,this.camera.fov);this.camera.updateMatrixWorld(),e.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),e.ray.direction.set(s.x,s.y,s.z).applyQuaternion(this.camera.quaternion).normalize(),e.camera=this.camera}pickCloudAt(e,t){return this.layeredClouds?.pickInstance(this.cloudDirectionAt(e,t))}cloudDirectionAt(e,t){return this.directionAtScreenPoint(e,t,new D)}directionAtScreenPoint(e,t,i){return this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),i.copy(this.ufoOcclusionRaycaster.ray.direction)}screenPointOf(e){this.camera.updateMatrixWorld();const t=this.screenPointScratch.copy(e).applyQuaternion(this.screenPointQuaternion.copy(this.camera.quaternion).invert()),i=this.renderer.getDrawingBufferSize(this.screenPointSize),n=i.x/Math.max(i.y,1);if(this.projectionKind==="equidistant"&&this.equidistantPass)return mi.ndcFor(t,this.camera.fov,n);if(t.z>=0)return;const s=Math.tan(this.camera.fov/2*Hi);return{ndcX:t.x/-t.z/(n*s),ndcY:t.y/-t.z/s}}screenPointScratch=new D;screenPointQuaternion=new Qn;screenPointSize=new xe;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 i=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);e.uniforms.uLensPosition.value.set(i.x,i.y);const n=this.renderer.domElement.width,s=this.renderer.domElement.height;e.uniforms.uResolution.value.set(n,s),e.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}renderDazzleOnResample(){const e=this.lensFlare;if(!e||!this.sunVisible)return;const t=this.sunVisibleFraction();if(t<=0)return;this.sunUnhiddenFraction=t,this.applyDazzleStrength();const i=this.screenPointOf(this.lensFlareScratch.copy(this.sunWorldPosition).sub(this.camera.position).normalize());if(!i)return;const n=this.renderer.getDrawingBufferSize(this.screenPointSize);e.uniforms.uLensPosition.value.set(i.ndcX,i.ndcY),e.uniforms.uResolution.value.set(n.x,n.y),e.uniforms.uEquidistant.value=1,e.uniforms.uHalfFovRad.value=this.camera.fov*Math.PI/360;const s=this.renderer.autoClear;this.renderer.autoClear=!1,e.mesh.visible=!0,e.mesh.layers.enable($p),this.camera.layers.set($p),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),e.mesh.visible=!1,e.uniforms.uEquidistant.value=0,this.renderer.autoClear=s}sunVisibleFraction(){this.raycastableDecor().length>0&&this.scene.updateMatrixWorld();let e=0;for(const t of rm)this.isSunOccluded(t[0],t[1])||e++;return e/rm.length}raycastableDecor(){const e=[];for(const t of this.decorObjects){if(t.kind==="crop")continue;const i=this.decorGroups.get(t.id);i&&e.push(i)}return e}isSunOccluded(e=0,t=0){const i=this.raycastableDecor();if(!this.groundMesh&&!this.terrainMesh&&i.length===0)return!1;const n=this.sunOcclusionDirectionScratch.copy(this.sunWorldPosition).sub(this.camera.position),s=n.length();if(n.normalize(),e!==0||t!==0){const o=Math.PI/180,c=this.sunOcclusionRightScratch.set(n.z,0,-n.x);c.lengthSq()<1e-9&&c.set(1,0,0),c.normalize();const l=this.sunOcclusionUpScratch.crossVectors(c,n).normalize();n.addScaledVector(c,e*o).addScaledVector(l,t*o).normalize()}if(this.groundBlocks(this.camera.position,n,s))return!0;if(i.length===0)return!1;this.sunOcclusionRaycaster.set(this.camera.position,n);const r=this.sunOcclusionRaycaster.intersectObjects(i,!0)[0];return r!==void 0&&r.distance<s}groundBlocks(e,t,i,n=0){const s=this.groundMesh;if(s&&t.y<0){const m=(s.position.y-e.y)/t.y;if(m>n&&m<i){const g=e.x+t.x*m-s.position.x,_=e.z+t.z*m-s.position.z;if(Math.hypot(g,_)<=this.groundRadius)return!0}}const r=this.terrainMesh;if(!r)return!1;const o=r.geometry.getAttribute("position"),c=Math.round(Math.sqrt(o.count));if(c<2||c*c!==o.count)return!1;const l=[r.position.x+o.getX(0),r.position.x+o.getX(c-1)],h=[r.position.z+o.getZ(0),r.position.z+o.getZ((c-1)*c)],u=Math.min(Math.abs(l[1]-l[0]),Math.abs(h[1]-h[0]))/(c-1);if(!(u>0))return!1;let d=n,f=i;for(const[m,g,_]of[[e.x,t.x,l],[e.z,t.z,h]]){const w=Math.min(_[0],_[1]),M=Math.max(_[0],_[1]);if(Math.abs(g)<1e-12){if(m<w||m>M)return!1;continue}const S=(w-m)/g,b=(M-m)/g;d=Math.max(d,Math.min(S,b)),f=Math.min(f,Math.max(S,b))}if(!(f>d))return!1;const p=Math.hypot(t.x,t.z),v=Math.min(4096,Math.max(8,Math.ceil((f-d)*p/(u/2))));for(let m=0;m<=v;m++){const g=d+(f-d)*m/v,_=e.x+t.x*g,w=e.y+t.y*g,M=e.z+t.z*g;if(w<=this.groundYUnder(_,M))return!0}return!1}setPhenomena(e,t){this.phenomena.set(e,t)}decorDistancesAt(e,t,i){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),this.ufoOcclusionRaycaster.near=Jp;let n,s;for(const r of this.decorObjects){if(r.kind==="crop")continue;const o=this.decorGroups.get(r.id);if(!o)continue;const c=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];c&&(r.occludesSourceIds?.includes(i)?n=n===void 0?c.distance:Math.max(n,c.distance):s=s===void 0?c.distance:Math.min(s,c.distance))}return{behindM:n,inFrontM:s}}pickBodyAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const i=[...this.hitAreas.entries()],n=this.raycaster.intersectObjects(i.map(([,s])=>s))[0];if(n&&!this.groundHides(e,t))return i.find(([,s])=>s===n.object)?.[0]}pickStarAt(e,t){if(this.namedStars.length===0)return;this.aimAtScreenPoint(this.raycaster,e,t);const i=this.raycaster.ray.direction,n=Math.cos(Qp*this.camera.fov*Math.PI/180);let s,r=n;for(const o of this.namedStars){const c=o.direction.dot(i);c>r&&(r=c,s={star:o.star,altitudeDeg:o.altitudeDeg})}return s&&this.groundHides(e,t)?void 0:s}groundHides(e,t){if(!this.terrainMesh&&!this.groundMesh)return!1;this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t);const i=this.ufoOcclusionRaycaster.ray;return this.groundBlocks(i.origin,i.direction,1/0,Jp)}pickDecorAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const i=[...this.decorGroups.entries()],n=this.raycaster.intersectObjects(i.map(([,r])=>r),!0)[0];if(!n)return;let s=n.object;for(;s&&!i.some(([,r])=>r===s);)s=s.parent;return i.find(([,r])=>r===s)?.[0]}dispose(){this.stopTwinkle(),this.cancelFlush(),this.phenomena.clear(),this.references.disposeAll(),this.terrainBuildToken++,this.cancelScatteredSkyPump(),this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.skyGradientMaterial),this.scatteredSky?.dispose(),this.scatteredSky=void 0,this.disposeMesh(this.skyMesh),this.disposeMesh(this.groundMesh),this.disposeMesh(this.terrainMesh),this.roadSystem.dispose(),this.disposeCloudSystem(),this.disposeCirrus(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers(),this.meteorSystem?.dispose(),this.meteorSystem=void 0,this.iceHalos?.dispose(),this.iceHalos=void 0,this.rainbow?.dispose(),this.rainbow=void 0,this.skyGlow?.dispose(),this.skyGlow=void 0,this.depthOfFieldPass?.dispose(),this.finishPass?.dispose(),this.depthOfFieldPass=void 0,this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0,this.cometTail?.dispose(),this.cometTail=void 0,this.satelliteField?.dispose(),this.satelliteField=void 0,this.lightningBolt?.dispose(),this.lightningBolt=void 0;for(const e of this.bodyMeshes.values())this.disposeMesh(e);this.bodyMeshes.clear(),this.novaKeys.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())vi.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;this.cancelFlush();const e=t=>{this.frame(t),this.animationFrameId=requestAnimationFrame(e)};this.animationFrameId=requestAnimationFrame(e)}setAnimationsRunning(e,t=!1){const i=e&&t;if(e===this.animationsRunning&&i===this.framesDriven)return;const n=this.animationsRunning;this.animationsRunning=e,this.framesDriven=i,e&&!n&&(this.lastFrameTimeMs=void 0,this.resolution.reset()),!e&&this.renderer.getPixelRatio()!==this.resolution.maximum&&this.applyPixelRatio(this.resolution.maximum),this.syncAnimationLoop(),(!e||this.frameDirty)&&this.render()}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}needsAnimationLoop(){return this.animationsRunning&&!this.framesDriven&&this.hasAnimations()}hasAnimations(){return this.starTiers.length>0||this.precipitationPoints!==void 0||this.rainSystem!==void 0||this.lensFlare!==void 0&&this.sunVisible}syncAnimationLoop(){this.needsAnimationLoop()?this.startTwinkle():this.stopTwinkle()}buildSky(e){const t=this.skyMesh?.geometry??new Qt(Ac,32,16),i=t.attributes.position,n=t.getAttribute("color")??new xt(new Float32Array(i.count*3),3);for(let r=0;r<i.count;r++){const{altitudeDeg:o,azimuthDeg:c}=qS(i.getX(r),i.getY(r),i.getZ(r)),l=e5(o,c,e.azimuthDeg,e.altitudeDeg);n.setXYZ(r,l[0],l[1],l[2])}if(n.needsUpdate=!0,this.skyMesh)return;t.setAttribute("color",n);const s=new mn({vertexColors:!0,side:Ot,fog:!1,depthWrite:!1});this.skyGradientMaterial=s,this.skyMesh=new De(t,s),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){const e=jp(this.observerElevationM);if(this.groundMesh&&e===this.groundRadius)return;this.disposeMesh(this.groundMesh),this.groundRadius=e;const t=new Xd(this.groundRadius,48),i=new Sr({color:new se(Uh,Uh,Uh),fog:!0});Ma.fadeRim(i,this.groundRadius*.75,this.groundRadius,this.horizonColour),this.groundMesh=new De(t,i),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh),this.applyGroundDepthWrite()}applyGroundDepthWrite(){const e=this.groundMesh?.material;if(!e)return;const t=this.terrainMesh===void 0;e.depthWrite!==t&&(e.depthWrite=t,e.needsUpdate=!0)}cloudTransmission(e,t=!1){const i=`${e.altitudeDeg.toFixed(1)}:${e.azimuthDeg.toFixed(1)}:${Math.round(this.cloudOffsetM.x/10)}:${Math.round(this.cloudOffsetM.z/10)}:${Math.round(this.observerElevationM)}:`+Object.entries(this.cloudLayerOffsetsM).map(([r,o])=>`${r}=${Math.round(o.x/10)},${Math.round(o.z/10)}`).join(";")+(t?":water":""),n=this.cloudTransmissionMemo.get(i);if(n!==void 0)return n;this.cloudTransmissionMemo.size>256&&this.cloudTransmissionMemo.clear();const s=this.computeCloudTransmission(e,t);return this.cloudTransmissionMemo.set(i,s),s}cloudTransmissionMemo=new Map;computeCloudTransmission(e,t=!1){const i=ni(e.altitudeDeg,e.azimuthDeg,1);if(this.layeredClouds)return this.layeredClouds.transmissionAt(i,t);let n=1;const s=this.lowerCloudCover();s>0&&(n*=1-ht.alphaAt(i,Math.abs(this.cloudLayerOffset()),s,this.cloudFieldOffset)*ab);const r=t?0:this.weather.highCloudCover??0;return r>0&&(n*=1-ht.iceAlphaAt(i,Tc,r,this.cloudFieldOffset)*rb),Math.max(0,Math.min(1,n))}setBodyMesh(e,t,i,n,s){if(t.altitudeDeg<bd){this.disposeMesh(this.bodyMeshes.get(e)),this.bodyMeshes.delete(e),this.disposeHitArea(e),this.disposeGlare(e),e==="sun"&&(this.sunVisible=!1);return}const{x:r,y:o,z:c}=ni(t.altitudeDeg,t.azimuthDeg,cn),l=Mp(t.altitudeDeg),h=this.cloudTransmission(t),u=this.arrivingIlluminance(t,s,h),d=Wt.unitLuminance(n);let f=this.bodyMeshes.get(e);if(e==="sun"){const p=Math.PI*(i/cn)**2,v=[0,1,2].map(m=>Math.min(Wt.BRIGHTEST_RELATIVE,d[m]*u[m]/p));f instanceof De||(this.disposeMesh(f),f=new De(new Qt(1,16,16),new mn({fog:!1})),this.celestialGroup.add(f),this.bodyMeshes.set(e,f)),f.material.color.setRGB(v[0],v[1],v[2]),f.scale.setScalar(i)}else{if(!(f instanceof us)){this.disposeMesh(f);const v=new ut;v.setAttribute("position",new et(new Float32Array(3),3)),v.setAttribute("color",new et(new Float32Array(3),3)),f=new us(v,Ft.material(ro[ro.length-1].size)),Ft.track(f),this.celestialGroup.add(f),this.bodyMeshes.set(e,f)}const p=f.geometry.getAttribute("color");p.setXYZ(0,d[0]*u[0],d[1]*u[1],d[2]*u[2]),p.needsUpdate=!0}if(f.position.set(r,o,c),this.setHitArea(e,r,o,c,i),e==="sun"&&(this.sunArriving=u),e!=="sun"&&this.setGlare(e,r,o,c,u,i/cn*(180/Math.PI),1),e==="sun"){this.sunVisible=!0;const p=this.celestialGroup.scale.x;this.sunWorldPosition.set(r*p,o*p+this.celestialGroup.position.y,c*p),this.lensFlare||(this.lensFlare=bw(),this.lensFlare.uniforms.uOpacity.value=vb,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(l)}}setMoonMesh(e,t){const i="moon";if(e.magnitude>t||e.altitudeDeg<bd){this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i);return}const{x:n,y:s,z:r}=ni(e.altitudeDeg,e.azimuthDeg,cn),o=this.cloudTransmission(e),c=this.arrivingIlluminance(e,e.magnitude,o),l=Math.max(sr(e.phase.illuminatedFraction,0,1),.01)*Math.PI*(qr/cn)**2,h=new se(...c.map(f=>Math.min(Wt.BRIGHTEST_RELATIVE,f/l))),u=`${e.phase.phaseFraction<.5}:${Math.round(sr(e.phase.illuminatedFraction,0,1)*500)}`;let d=this.bodyMeshes.get(i);if(d instanceof Nr)d.userData.phaseKey!==u&&(d.material.map?.dispose(),d.material.map=Em(e.phase),d.userData.phaseKey=u),d.material.color.copy(h);else{this.disposeMesh(d),d=new Nr(new Hc({map:Em(e.phase),color:h,fog:!1})),d.userData.phaseKey=u;const f=qr*2;d.scale.set(f,f,1),this.celestialGroup.add(d),this.bodyMeshes.set(i,d)}d.position.set(n,s,r),this.setHitArea(i,n,s,r,qr),this.setGlare(i,n,s,r,c,qr/cn*(180/Math.PI))}bentLight(e,t,i=nb){const[n,s,r]=this.arrivingIlluminance(e,t,1),o=Math.max(s,1e-30);return{scale:s/i,tint:[n/o,1,r/o]}}static litBySky(e,t){return Wt.litScratch.setRGB(e.r*t[0],e.g*t[1],e.b*t[2])}static litScratch=new se;static BRIGHTEST_RELATIVE=6e4;arrivingIlluminance(e,t,i){const n=this.air.transmittanceFromSpace(this.siteElevationM+this.observerElevationM,e.altitudeDeg),s=ot.illuminanceOf(t)*i*this.relativeScale;return[n[0]*s,n[1]*s,n[2]*s]}static unitLuminance(e){const t=Tn.luminanceOf([e.r,e.g,e.b]);return t>0?[e.r/t,e.g/t,e.b/t]:[1,1,1]}setHitArea(e,t,i,n,s){let r=this.hitAreas.get(e);if(!r){const c=new Hc({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1});r=new Nr(c),this.celestialGroup.add(r),this.hitAreas.set(e,r)}r.position.set(t,i,n);const o=s*ib;r.scale.set(o,o,1)}disposeHitArea(e){const t=this.hitAreas.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.hitAreas.delete(e))}setGlare(e,t,i,n,s,r,o=0){if(Ui.radiusDeg(Ui.K*Math.max(...s))<=Math.max(r,o)){this.disposeGlare(e);return}let c=this.glareSprites.get(e);c||(c=new Ui(`veil:${e}`),this.celestialGroup.add(c.mesh),this.glareSprites.set(e,c)),c.shine({x:t,y:i,z:n},s,r,o)}disposeGlare(e){const t=this.glareSprites.get(e);t&&(t.mesh.removeFromParent(),t.dispose(),this.glareSprites.delete(e))}buildComet(e,t){const i=e&&`comet:${e.id}`;if(!e||!i||e.magnitude>t){this.disposeComet();return}this.cometKey&&this.cometKey!==i&&this.disposeComet();const n=jr(e.magnitude,t),s=wh(n);this.cometKey=i,this.setBodyMesh(i,e.position,zh*(.5+.5*n),new se(s,s,s),e.magnitude),this.cometTail||(this.cometTail=new Zi(cn),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(e.position,e.tailEnd,n)}buildIceHalos(e,t){this.iceHalos||(this.iceHalos=new Ti,this.iceHalos.setCloudOffset(this.cloudFieldOffset),this.iceHalos.onReady=()=>this.render(),this.celestialGroup.add(this.iceHalos.object)),this.iceHalos.setUrgent(!!this.skyHoldUntilMs);const i=this.highCloudCover(),n=this.layeredClouds?.cirrusMask;if(this.iceHalos.setCloudOffset(n?.offset??this.cloudFieldOffset),this.layeredClouds?.hostHalo(this.iceHalos),i===void 0){this.iceHalos.update({x:0,y:1,z:0},-1,0,[1,1,1],{cover:0,layerHeight:Tc},0);return}const s=this.lowerCloudCover(),r=lt.deckLitUntilDeg(lt.DECK_HEIGHT_M),o=e.altitudeDeg>-r?e:t,c=this.bentLight(o,o===e?ii.SUN_MAGNITUDE:t.magnitude),l=lt.strength(i,s,o.altitudeDeg,r)*c.scale,{x:h,y:u,z:d}=ni(o.altitudeDeg,o.azimuthDeg,1);this.iceHalos.update({x:h,y:u,z:d},o.altitudeDeg,l,c.tint,{cover:n?.cover??i,layerHeight:n?.layerHeight??Tc},n?.iceCrystalAlignment??this.weather.iceCrystalAlignment??.65)}buildRainbow(e,t){this.rainbow||(this.rainbow=new pa,this.celestialGroup.add(this.rainbow.object));const i=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity:0,n=e.altitudeDeg>0,s=n?e:t,r=this.lowerCloudCover(),o=this.bentLight(s,n?ii.SUN_MAGNITUDE:t.magnitude,sb),c=$i.strength(i,r,s.altitudeDeg)*o.scale;if(c<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:l,y:h,z:u}=ni(s.altitudeDeg,s.azimuthDeg,1);this.rainbow.update({x:l,y:h,z:u},c,o.tint,n)}buildSkyGlow(e,t){if(!e.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new Os,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:i,observer:n}=e.frame,s=Sn.galactic(i,n),r=Wt.directionOf(s.centre),o=Wt.directionOf(s.rotation),c=Wt.directionOf(s.pole),l=new Xe().set(r.x,r.y,r.z,o.x,o.y,o.z,c.x,c.y,c.z),h=Wt.directionOf(Sn.eclipticPole(i,n)),u=Wt.directionOf(e.sun),d=u.clone().addScaledVector(h,-u.dot(h)).normalize();this.skyGlow.update({galactic:l,eclipticPole:h,sunLongitude:d,sunDirection:u,sunAltitudeDeg:e.sun.altitudeDeg,moon:{direction:Wt.directionOf(e.moon),altitudeDeg:e.moon.altitudeDeg,phaseAngleDeg:Ye.phaseAngleOf(e.moon.phase.illuminatedFraction)},skyColor:new D(t[0],t[1],t[2])})}static directionOf(e){const{x:t,y:i,z:n}=ni(e.altitudeDeg,e.azimuthDeg,1);return new D(t,i,n).normalize()}buildNovae(e,t){const i=new Set;for(const n of e){if(n.magnitude>t)continue;const s=`nova:${n.id}`;i.add(s);const r=jr(n.magnitude,t),o=wh(r);this.setBodyMesh(s,n.position,zh*(.5+.5*r),new se(o,o,o),n.magnitude)}for(const n of this.novaKeys)i.has(n)||(this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n));this.novaKeys=i}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 i=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[],...this.novaKeys]);for(const n of e){if(n.magnitude>t)continue;i.add(n.body);const s=jr(n.magnitude,t),r=wh(s),o=Ub[n.body]??new se(1,1,1),c=new se(o.r*r,o.g*r,o.b*r),l=zh*(.5+.5*s);this.setBodyMesh(n.body,n.position,l,c,n.magnitude)}for(const n of[...this.bodyMeshes.keys()])i.has(n)||(this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n))}buildStars(e,t){if(this.namedStars=[],!e||e.catalog.count===0){this.disposeStarTiers(),this.syncAnimationLoop();return}const{catalog:i,date:n,observer:s}=e,r=new En(n,s),o=Yh(1337),c=[],l=this.siteElevationM+this.observerElevationM;for(let h=0;h<i.count;h++){const u=i.mag[h];if(u>t)break;const{altitudeDeg:d,azimuthDeg:f}=r.position(i.ra[h],i.dec[h]);if(d<em)continue;const{x:p,y:v,z:m}=ni(d,f,Fh);c.push({x:p,y:v,z:m,brightness:jr(u,t),illuminance:this.air.transmittanceFromSpace(l,d).map(g=>g*ot.illuminanceOf(u)),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}for(const h of aw){if(h.mag>t)continue;const{altitudeDeg:u,azimuthDeg:d}=r.position(h.raHours,h.decDeg);if(u<em)continue;const{x:f,y:p,z:v}=ni(u,d,Fh);this.namedStars.push({star:h,direction:new D(f,p,v).normalize(),altitudeDeg:u})}this.starTiers=ro.map((h,u)=>{const d=c.filter(S=>zg(S.brightness)===u),f=new Float32Array(d.length*3),p=new Float32Array(d.length),v=new Float32Array(d.length*3),m=new Float32Array(d.length),g=new Float32Array(d.length);d.forEach((S,b)=>{f[b*3]=S.x,f[b*3+1]=S.y,f[b*3+2]=S.z,p[b]=S.brightness,v.set(S.illuminance,b*3),m[b]=S.phase,g[b]=S.speedFactor});const _=new ut;_.setAttribute("position",new et(f,3));const w=new et(new Float32Array(d.length*3),3);_.setAttribute("color",w);let M=this.starTiers[u]?.points;return M?(M.geometry.dispose(),M.geometry=_):(M=new us(_,Ft.material(h.size)),Ft.track(M),this.celestialGroup.add(M)),{points:M,colorAttribute:w,brightness:p,illuminance:v,phase:m,speedFactor:g}}),this.updateTwinkle(0),this.startTwinkle()}twinkleSeconds=0;updateTwinkle(e){const t=this.relativeScale;for(const i of this.starTiers){const n=i.colorAttribute.array;for(let s=0;s<i.brightness.length;s++){const r=a5(i.brightness[s],{phase:i.phase[s],speedFactor:i.speedFactor[s]},e),o=t*r;n[s*3]=i.illuminance[s*3]*o,n[s*3+1]=i.illuminance[s*3+1]*o,n[s*3+2]=i.illuminance[s*3+2]*o}i.colorAttribute.needsUpdate=!0}}buildClouds(){if(this.cloudRendering==="volume"||this.weather.cloudLayers!==void 0){this.layeredClouds||(this.disposeCloudSystem(),this.layeredClouds=new hr(this.celestialGroup,Hh,this.cloudRendering)),this.disposeCirrus(),this.layeredClouds.hostHalo(this.iceHalos),this.layeredClouds.update(this.weather,this.observerElevationM+1.6),this.layeredClouds.setOffsets(this.cloudOffsetM,this.cloudLayerOffsetsM),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const e=this.lowerCloudCover();if(e<=0){this.disposeCloudSystem();return}const t=this.weather.cloudDarkness,i=new se(na[0]+(Vh[0]-na[0])*t,na[1]+(Vh[1]-na[1])*t,na[2]+(Vh[2]-na[2])*t);if(this.cloudMesh&&this.cloudUniforms){this.cloudUniforms.coverage.value=e,this.cloudUniforms.baseColor.value.copy(i),this.syncCloudLayer(),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}this.disposeCloudSystem();const{material:n,uniforms:s}=Zu(i,e,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=n,this.cloudUniforms=s,s.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const r=Ju(Hh);this.cloudMesh=new De(r,n),this.faceCloudDeck(this.cloudMesh,this.cloudLayerOffset()),this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(e=>e.type!=="cirrus").reduce((e,t)=>e*(1-t.coverage),1):this.weather.lowerCloudCover??this.weather.cloudCover}highCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(e=>e.type==="cirrus").reduce((e,t)=>e*(1-t.coverage),1):this.weather.highCloudCover}buildCirrus(){const e=this.weather.highCloudCover??0;if(this.layeredClouds||e<=0){this.disposeCirrus();return}if(this.cirrusMesh&&this.cirrusUniforms){this.cirrusUniforms.coverage.value=e,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const{material:t,uniforms:i}=Zu(new se(...na),e,Tc,1);this.cirrusMaterial=t,this.cirrusUniforms=i,i.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new De(Ju(Hh*1.04),t),this.cirrusMesh.renderOrder=om-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(){this.layeredClouds?.update(this.weather,this.observerElevationM+1.6);const e=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(e)),this.cloudMesh&&this.faceCloudDeck(this.cloudMesh,e)}faceCloudDeck(e,t){const i=t<0;e.scale.y=i?-1:1,e.renderOrder=i?hr.deckOrder(!0,0,1):om}cloudLayerOffset(){const t=((this.weather.cloudBaseM??1e3)-this.observerElevationM)*Bh;return Math.sign(t||1)*Math.max(Math.abs(t),xb)}updateCloudLighting(e,t){const i=[this.cloudUniforms,this.cirrusUniforms].filter(u=>u!==void 0);if(i.length===0&&!this.layeredClouds)return;const n=this.cloudBeamDirection,[s,r,o]=this.cloudBeam.map(u=>u/Math.PI),c=this.lightningLevel*qh*this.relativeScale/Math.PI,l=new se(t[0]+kn.r*c,t[1]+kn.g*c,t[2]+kn.b*c);this.layeredClouds?.setLighting(n.clone(),new se(s,r,o),l,l);const h=Math.max(0,n.y);for(const u of i)u.sunDir.value.copy(n),u.sunColor.value.setRGB(s*h,r*h,o*h),u.ambientColor.value.copy(l)}disposeCloudSystem(){this.layeredClouds?.dispose(),this.layeredClouds=void 0,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=cm[e],i=t.poolSize,n=Yh(9001),s=new Float32Array(i*3),r=new Float32Array(i),o=new Float32Array(i),c=new Float32Array(i),l=new Float32Array(i),h=new Float32Array(i),u=new Float32Array(i),d=new Float32Array(i),f=new Float32Array(i),p=new Float32Array(i);for(let w=0;w<i;w++){const M=n()*Math.PI*2,S=n()*t.radiusM;s[w*3]=Math.cos(M)*S,s[w*3+1]=er+n()*(t.topYM-er),s[w*3+2]=Math.sin(M)*S,r[w]=n()*Math.PI*2,o[w]=.7+n()*.6,c[w]=.6+n()*.8,l[w]=.4+n()*1.2}const v=new ut;v.setAttribute("position",new et(s,3)),v.setDrawRange(0,Xh(i,this.weather.precipitationIntensity));const m={uSize:{value:t.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:t.opacity},uColor:{value:t.color.clone()},uHazeColor:{value:new se(...this.baseFogColor)},uTexture:{value:Fb(e)},uNearFocusDistance:{value:vm},uHazeDistance:{value:t.radiusM*Mm}},g=new at({uniforms:m,vertexShader:Vb,fragmentShader:Wb,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const _=new us(v,g);_.renderOrder=Gh,this.scene.add(_),this.precipitationPoints=_,this.precipitationPositions=s,this.precipitationPhase=r,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=c,this.precipitationWobbleAmpJitter=l,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=u,this.precipitationBounceDuration=d,this.precipitationBounceVelX=f,this.precipitationBounceVelZ=p}updatePrecipitation(e,t){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter)return;this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor);const i=this.weather.precipitationType;if(i==="none"||i==="rain")return;const n=cm[i];if(this.precipitationUniforms?.uColor.value.copy(Wt.litBySky(n.color,this.baseFogColor)),t<=0)return;const s=this.weather.windDirectionDeg*Hi,r=Math.sin(s)*this.weather.windSpeed*n.driftSensitivity,o=-Math.cos(s)*this.weather.windSpeed*n.driftSensitivity,c=this.precipitationPositions,l=this.precipitationPhase,h=this.precipitationSpeedJitter,u=this.precipitationWobbleFreqJitter,d=this.precipitationWobbleAmpJitter,f=this.precipitationBounceRemaining,p=this.precipitationBounceHeight,v=this.precipitationBounceDuration,m=this.precipitationBounceVelX,g=this.precipitationBounceVelZ,_=i==="snow"&&u&&d,w=i==="hail"&&f&&p&&v&&m&&g;for(let M=0,S=0;M<c.length;M+=3,S++){if(w&&f[S]>0){if(f[S]-=t,f[S]<=0){const x=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*n.radiusM;c[M]=Math.cos(x)*A,c[M+1]=n.topYM,c[M+2]=Math.sin(x)*A,f[S]=0}else{const x=1-f[S]/v[S];c[M+1]=er+Math.sin(Math.PI*x)*p[S],c[M]=Cc(c[M]+(r+m[S])*t,n.radiusM),c[M+2]=Cc(c[M+2]+(o+g[S])*t,n.radiusM)}continue}let b=0,T=0;if(_){const x=Rb*u[S],A=Db*d[S];b=Math.sin(e*x*Math.PI*2+l[S])*A,T=Math.sin(e*x*Math.PI*2+l[S]+Math.PI/2)*A}if(c[M]+=(r+b)*t,c[M+1]-=n.fallSpeedMPerS*h[S]*t,c[M+2]+=(o+T)*t,c[M]=Cc(c[M],n.radiusM),c[M+2]=Cc(c[M+2],n.radiusM),c[M+1]<er){if(w){p[S]=wm*(.2+Math.random()*1.6),v[S]=Cb*(.5+Math.random()),f[S]=v[S];const I=Math.random()*Math.PI*2,C=Ib*(p[S]/wm);m[S]=Math.cos(I)*C,g[S]=Math.sin(I)*C,c[M+1]=er;continue}const x=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*n.radiusM;c[M]=Math.cos(x)*A,c[M+1]=n.topYM,c[M+2]=Math.sin(x)*A}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const e=dm(this.weather.precipitationIntensity);this.rainSystem=yw({count:lm,radiusM:Yr,heightM:_b,bottomYM:hm,overallSpeed:Sb,color:fm.clone(),opacity:.85,visibleCount:Xh(lm,this.weather.precipitationIntensity),speedStreak:Ab(e),pixelSize:ym,seed:9001,nearFocusDistanceM:vm,hazeDistanceM:Yr*Mm,hazeColor:new se(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=Gh,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const e=Yh(4242),t=new Float32Array(Ja*3),i=new Float32Array(Ja),n=new Float32Array(Ja),s=new Float32Array(Ja);for(let h=0;h<Ja;h++){const u=e()*Math.PI*2,d=Math.sqrt(e())*Yr;t[h*3]=Math.cos(u)*d,t[h*3+1]=hm,t[h*3+2]=Math.sin(u)*d,n[h]=bm(pm,mm),i[h]=e()*n[h],s[h]=i[h]/n[h]}const r=new ut;r.setAttribute("position",new et(t,3));const o=new et(s,1);r.setAttribute("aLife",o),r.setDrawRange(0,Xh(Ja,this.weather.precipitationIntensity));const c=new at({uniforms:{uMaxSize:{value:Tb},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:gm.clone()},uTexture:{value:Hb()}},vertexShader:Bb,fragmentShader:Gb,transparent:!0,depthWrite:!1}),l=new us(r,c);l.renderOrder=Gh,this.scene.add(l),this.rainSplashSystem={points:l,positions:t,life:i,duration:n,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*Hi;e.uniforms.uDropVelocity.value.set(Math.sin(t)*this.weather.windSpeed,-dm(this.weather.precipitationIntensity),-Math.cos(t)*this.weather.windSpeed);const i=this.renderer.getSize(this.rainViewportSize);e.uniforms.uAspect.value=i.x/Math.max(i.y,1)}updateRain(e){const t=this.rainSystem;if(!t)return;t.uniforms.uTime.value+=e,t.uniforms.uHazeColor.value.setRGB(...this.baseFogColor),t.uniforms.uColor.value.copy(Wt.litBySky(fm,this.baseFogColor));const i=this.rainSplashSystem?.points.material?.uniforms?.uColor;i&&i.value.copy(Wt.litBySky(gm,this.baseFogColor));const n=this.weather.windDirectionDeg*Hi,s=Math.sin(n)*this.weather.windSpeed,r=-Math.cos(n)*this.weather.windSpeed,o=Yr,c=h=>(h%(o*2)+o*3)%(o*2)-o;t.uniforms.uWindOffset.value.set(c(t.uniforms.uWindOffset.value.x+s*e),c(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 h=_m+(1-_m)*(1-l),u=Sm+(1-Sm)*(1-l);t.uniforms.uUvSquash.value=u,t.uniforms.uPixelSize.value=ym*h*(.5+.5*u)}this.updateRainSplashes(e)}updateRainSplashes(e){const t=this.rainSplashSystem;if(!t||e<=0)return;const{positions:i,life:n,duration:s,lifeAttribute:r}=t,o=r.array;for(let c=0,l=0;c<i.length;c+=3,l++){if(n[l]+=e,n[l]>=s[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*Yr;i[c]=Math.cos(h)*u,i[c+2]=Math.sin(h)*u,s[l]=bm(pm,mm),n[l]=0}o[l]=n[l]/s[l]}t.points.geometry.attributes.position.needsUpdate=!0,r.needsUpdate=!0}setLightning(e){this.lightningFlashes=e}updateLightning(e){let t,i=0;if(this.lightningArmed)for(const c of this.lightningFlashes){if(c.t>e)break;const l=oi.brightnessAt(c,e);l>i&&(t=c,i=l)}const n=t?Math.min(1,Math.max(.1,(Nb/t.distanceM)**2)):0,s=i*n*(t?.cloudToGround?1:.6);if(s===this.lightningLevel&&!t?.cloudToGround)return;if(this.lightningLevel=s,this.scene.fog){const c=this.scene.fog,l=s*qh*this.relativeScale/Math.PI;c.color.setRGB(this.airlight[0]+kn.r*l,this.airlight[1]+kn.g*l,this.airlight[2]+kn.b*l)}const r=this.skyMesh?.material?.color;if(r){const c=s*Ob;r.setRGB(1+c*kn.r,1+c*kn.g,1+c*kn.b)}if(this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.lightningLight.intensity=s*qh*this.relativeScale,t){const{x:c,y:l,z:h}=ni(25,t.azimuthDeg,cn);this.lightningLight.position.set(c,l,h)}this.lightningBolt||(this.lightningBolt=new Us(cn*.95),this.celestialGroup.add(this.lightningBolt.object));const o=this.weather.cloudBaseM??1500;this.lightningBolt.set(t,i,o),this.render()}buildCompassLabels(){const e=Td(navigator.languages,hb),t=lb[e];this.compassSprites=cb.map((i,n)=>{const s=t[n],r=new Hc({map:Xb(s),depthTest:!1,fog:!1}),o=new Nr(r),{x:c,y:l,z:h}=ni(0,i,nm);return o.position.set(c,l,h),o.scale.set(Dc,Dc,1),o.renderOrder=fb,o.layers.set(Zp),o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o}),this.updateCompassScale()}updateCompassScale(){const e=this.camera.fov*Math.PI/360,t=sm*Math.PI/360,i=Dc*Math.tan(e)/Math.tan(t);for(const n of this.compassSprites)n.scale.set(i,i,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 i of Array.isArray(t)?t:[t]){const n=i.map;n&&n.dispose(),i.dispose()}}}const Hi=Math.PI/180;function sr(a,e,t){return Math.max(e,Math.min(t,a))}function bm(a,e){return a+Math.random()*(e-a)}function Cc(a,e){return(a%(e*2)+e*3)%(e*2)-e}let Ic,Pc;function Fb(a){switch(a){case"snow":return kb();case"hail":return zb()}}function kb(){if(Ic)return Ic;const a=64,e=document.createElement("canvas");e.width=a,e.height=a;const t=e.getContext("2d"),i=t.createRadialGradient(a/2,a/2,0,a/2,a/2,a/2);return i.addColorStop(0,"rgba(255,255,255,0.95)"),i.addColorStop(.5,"rgba(255,255,255,0.55)"),i.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=i,t.fillRect(0,0,a,a),Ic=new Ss(e),Ic}function zb(){if(Pc)return Pc;const a=64,e=document.createElement("canvas");e.width=a,e.height=a;const t=e.getContext("2d"),i=t.createRadialGradient(a/2,a/2,0,a/2,a/2,a/2);return i.addColorStop(0,"rgba(255,255,255,1)"),i.addColorStop(.55,"rgba(255,255,255,0.95)"),i.addColorStop(.8,"rgba(255,255,255,0.4)"),i.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=i,t.fillRect(0,0,a,a),Pc=new Ss(e),Pc}let Lc;function Hb(){if(Lc)return Lc;const a=64,e=document.createElement("canvas");e.width=a,e.height=a;const t=e.getContext("2d"),i=t.createRadialGradient(a/2,a/2,0,a/2,a/2,a/2);return i.addColorStop(0,"rgba(255,255,255,0)"),i.addColorStop(.4,"rgba(255,255,255,0)"),i.addColorStop(.6,"rgba(255,255,255,0.9)"),i.addColorStop(.8,"rgba(255,255,255,0.25)"),i.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=i,t.fillRect(0,0,a,a),Lc=new Ss(e),Lc}const Bb=`
|
|
6939
6947
|
uniform float uMaxSize;
|
|
6940
6948
|
uniform float uScale;
|
|
6941
6949
|
attribute float aLife;
|
|
@@ -6948,7 +6956,7 @@ void main() {
|
|
|
6948
6956
|
vOpacity = 1.0 - aLife;
|
|
6949
6957
|
gl_Position = projectionMatrix * mvPosition;
|
|
6950
6958
|
}
|
|
6951
|
-
`,
|
|
6959
|
+
`,Gb=`
|
|
6952
6960
|
uniform vec3 uColor;
|
|
6953
6961
|
uniform sampler2D uTexture;
|
|
6954
6962
|
varying float vOpacity;
|
|
@@ -6959,7 +6967,7 @@ void main() {
|
|
|
6959
6967
|
if (alpha < 0.01) discard;
|
|
6960
6968
|
gl_FragColor = vec4(uColor, alpha);
|
|
6961
6969
|
}
|
|
6962
|
-
`,
|
|
6970
|
+
`,Vb=`
|
|
6963
6971
|
uniform float uSize;
|
|
6964
6972
|
uniform float uScale;
|
|
6965
6973
|
uniform float uNearFocusDistance;
|
|
@@ -6985,7 +6993,7 @@ void main() {
|
|
|
6985
6993
|
gl_PointSize = max(1.0, uSize * uScale / dist + vNearBlur * 12.0);
|
|
6986
6994
|
gl_Position = projectionMatrix * mvPosition;
|
|
6987
6995
|
}
|
|
6988
|
-
`,
|
|
6996
|
+
`,Wb=`
|
|
6989
6997
|
precision mediump float;
|
|
6990
6998
|
uniform sampler2D uTexture;
|
|
6991
6999
|
uniform vec3 uColor;
|
|
@@ -7000,5 +7008,5 @@ void main() {
|
|
|
7000
7008
|
float blur = max(vNearBlur, vHaze);
|
|
7001
7009
|
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * 0.5));
|
|
7002
7010
|
}
|
|
7003
|
-
`;function Em(a){const t=document.createElement("canvas");t.width=128,t.height=128;const i=t.getContext("2d"),n=128/2-2,s=128/2,r=128/2,o="#010101",c="#f4f1e2";i.fillStyle=o,i.beginPath(),i.arc(s,r,n,0,Math.PI*2),i.fill();const l=sr(a.illuminatedFraction,0,1),h=a.phaseFraction<.5,u=n*Math.abs(1-2*l),d=l<.5;return i.save(),i.beginPath(),i.arc(s,r,n,0,Math.PI*2),i.clip(),i.fillStyle=c,i.beginPath(),h?(i.arc(s,r,n,-Math.PI/2,Math.PI/2,!1),i.ellipse(s,r,u,n,0,Math.PI/2,-Math.PI/2,d)):(i.arc(s,r,n,Math.PI/2,-Math.PI/2,!1),i.ellipse(s,r,u,n,0,-Math.PI/2,Math.PI/2,d)),i.fill(),i.restore(),new Ss(t)}function
|
|
7004
|
-
`);let s=Hn.cache.get(n);return s||(s=Promise.all(i.map(r=>Hn.load(r.url))).then(r=>r.reduce((o,c)=>Hn.concat(o,c))),Hn.cache.set(n,s)),s}static parse(e){const t=e.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),i=t*Float32Array.BYTES_PER_ELEMENT;return{count:t,ra:new Float32Array(e,0*i,t),dec:new Float32Array(e,1*i,t),mag:new Float32Array(e,2*i,t),ci:new Float32Array(e,3*i,t)}}static concat(e,t){const i=(n,s)=>{const r=new Float32Array(n.length+s.length);return r.set(n,0),r.set(s,n.length),r};return{count:e.count+t.count,ra:i(e.ra,t.ra),dec:i(e.dec,t.dec),mag:i(e.mag,t.mag),ci:i(e.ci,t.ci)}}}const Xb=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,qb=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,Yb=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,Kb=20,$b=1;class Zb{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,i){if(this.requested={type:e,intensity:t,windSpeed:i},!this.context)return;this.paused&&(e="none",t=0,i=0);const n=e==="rain"||e==="hail"?e:"none";if(this.ambientVolume=n==="hail"?Math.min(1,t*1.3+.2):n==="rain"?t:0,n!==this.ambientKey){this.ambientKey=n;const r=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,n!=="none"&&this.startLoop(Xb,this.ambientVolume).then(o=>this.applyIfCurrent(o,r,()=>this.ambientToken,c=>{this.ambientSource=c?.source,this.ambientGain=c?.gain,c&&(c.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(i/Kb,1);const s=i>$b;if(s!==this.windActive){this.windActive=s;const r=++this.windToken;this.stopSource(this.windSource,this.windGain),this.windSource=void 0,this.windGain=void 0,s&&this.startLoop(qb,this.windVolume).then(o=>this.applyIfCurrent(o,r,()=>this.windToken,c=>{this.windSource=c?.source,this.windGain=c?.gain,c&&(c.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(e){if(e===this.paused)return;this.paused=e;const{type:t,intensity:i,windSpeed:n}=this.requested;this.setAmbient(t,i,n)}playThunder(){!this.context||this.paused||this.playOneShot(Yb,.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,i,n){if(t!==i()){e?.source.stop();return}n(e)}async startLoop(e,t){const i=this.context;if(i)try{const n=await this.getBuffer(e),s=i.createBufferSource();s.buffer=n,s.loop=!0;const r=i.createGain();return r.gain.value=t,s.connect(r).connect(i.destination),s.start(),{source:s,gain:r}}catch(n){console.warn("Weather ambient sound failed to load, staying silent:",n);return}}async playOneShot(e,t){const i=this.context;if(i)try{const n=await this.getBuffer(e),s=i.createBufferSource();s.buffer=n;const r=i.createGain();r.gain.value=t,s.connect(r).connect(i.destination),s.start()}catch(n){console.warn("Thunder sound failed to load:",n)}}async getBuffer(e){const t=this.context;if(!t)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let i=this.buffers.get(e);return i||(i=fetch(e).then(n=>{if(!n.ok)throw new Error(`Audio fetch failed (${n.status}): ${e}`);return n.arrayBuffer()}).then(n=>t.decodeAudioData(n)),this.buffers.set(e,i)),i}stopSource(e,t){try{e?.stop()}catch{}e?.disconnect(),t?.disconnect()}}class hs{constructor(e){this.elements=e;const{eccentricity:t,perihelionAu:i}=e,[n,s]=this.perifocalAxes(),r=Math.sqrt(hs.SUN_GM_AU3_PER_DAY2*(1+t)/i);this.perihelionPosition=this.scale(n,i),this.perihelionVelocity=this.scale(s,r),this.inverseSemiMajorAxis=(1-t)/i}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(e){const t=e-this.elements.perihelionJd,i=this.universalAnomaly(t),n=this.inverseSemiMajorAxis*i*i,s=this.elements.perihelionAu,r=1-i*i/s*hs.stumpffC(n),o=t-i*i*i/Math.sqrt(hs.SUN_GM_AU3_PER_DAY2)*hs.stumpffS(n);return{x:r*this.perihelionPosition.x+o*this.perihelionVelocity.x,y:r*this.perihelionPosition.y+o*this.perihelionVelocity.y,z:r*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),i=Math.sqrt(hs.SUN_GM_AU3_PER_DAY2)*Math.abs(e),n=o=>{const c=this.inverseSemiMajorAxis*o*o,l=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*l)*o*o*o*hs.stumpffS(c)+l*o};let s=Math.max(1,i/this.elements.perihelionAu);for(;n(s)<i;)s*=2;let r=0;for(let o=0;o<hs.MAX_ITERATIONS&&s-r>1e-13*Math.max(1,s);o++){const c=(r+s)/2;n(c)<i?r=c:s=c}return t*(r+s)/2}perifocalAxes(){const e=this.elements.ascendingNodeDeg*Math.PI/180,t=this.elements.argumentOfPerihelionDeg*Math.PI/180,i=this.elements.inclinationDeg*Math.PI/180,n=Math.cos(e),s=Math.sin(e),r=Math.cos(t),o=Math.sin(t),c=Math.cos(i),l=Math.sin(i);return[{x:n*r-s*o*c,y:s*r+n*o*c,z:o*l},{x:-n*o-s*r*c,y:-s*o+n*r*c,z:r*l}]}scale(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}static stumpffC(e){if(Math.abs(e)<1e-6)return 1/2-e/24+e*e/720;if(e>0)return(1-Math.cos(Math.sqrt(e)))/e;const t=Math.sqrt(-e);return(Math.cosh(t)-1)/-e}static stumpffS(e){if(Math.abs(e)<1e-6)return 1/6-e/120+e*e/5040;if(e>0){const i=Math.sqrt(e);return(i-Math.sin(i))/(i*i*i)}const t=Math.sqrt(-e);return(Math.sinh(t)-t)/(t*t*t)}}const v1=[{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 Jb{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 v1.filter(i=>Math.abs(t-i.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(e,t){return this.aroundDate(e).map(i=>this.appearanceOf(i,e,t)).sort((i,n)=>i.magnitude-n.magnitude)[0]}static appearanceOf(e,t,i){const n=kt(t),s=this.earthPositionAt(n),r=this.apparentPositionOf(e,2451545+n.tt,s),o=this.subtract(r,s),c=this.length(r),l=this.length(o),h=this.tailEndAt(e,r,s,c,n,t,i),u=this.horizontalOf(o,n,t,i);return{apparition:e,position:u,...h,heliocentricDistanceAu:c,earthDistanceAu:l,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},s)),magnitude:this.magnitudeAt(e,c,l)}}static magnitudeAt(e,t,i){const n=e.absoluteMagnitude+5*Math.log10(i)+2.5*e.activityExponent*Math.log10(t);return Math.max(n,e.peakMagnitude)}static tailEndAt(e,t,i,n,s,r,o){if(e.tailLengthAu===void 0)return{};const c=1+e.tailLengthAu/n,l=this.subtract({x:t.x*c,y:t.y*c,z:t.z*c},i),h=this.subtract(t,i);return{tailEnd:this.horizontalOf(l,s,r,o),tailLengthDeg:this.angleBetween(h,l)}}static apparentPositionOf(e,t,i){const n=this.orbitOf(e);let s=n.positionAt(t);for(let r=0;r<2;r++){const o=this.length(this.subtract(s,i))/this.LIGHT_SPEED_AU_PER_DAY;s=n.positionAt(t-o)}return s}static horizontalOf(e,t,i,n){const s=mr(J5(),new Ct(e.x,e.y,e.z,t)),r=mr(n1(t),s),o=C5(t,new c0(n.lat,n.lng,n.elevationM)),c=new Ct(r.x-o.x,r.y-o.y,r.z-o.z,t),l=h0(c);return u0(l.ra,l.dec,i,n)}static earthPositionAt(e){return mr(Z5(),Xs(we.Earth,e))}static julianDayOf(e){return 2451545+kt(e).tt}static orbitOf(e){const t=this.orbits.get(e.id);if(t)return t;const i=new hs(e.orbit);return this.orbits.set(e.id,i),i}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 i=(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,i)))*180/Math.PI}}const Zh=[{id:"sn-1006",kind:"supernova",designation:"SN 1006",name:{en:"Supernova of 1006",fr:"supernova de 1006"},raHours:15.03947,decDeg:-42.09694,peakMagnitude:-7.5,peakJd:2088620,startJd:2088620,lightCurve:[[0,-7.5],[29,-5.9],[60,-4.9],[106,-3.2],[166,-1.9],[258,-1],[350,.5],[364,.7],[411,1.2],[456,1.8],[484,2.5],[785.5,7]],source:"Winkler, Gupta & Long 2003 (peak); decline borrowed from SN 1572",note:"The brightest stellar event in recorded history, seen in daylight, low in the southern sky from Europe and the Near East. The decline is modelled, not recorded, and falls below the naked eye after about two years where the chronicles speak of three."},{id:"sn-1054",kind:"supernova",designation:"SN 1054",name:{en:"Supernova of 1054",fr:"supernova de 1054"},raHours:5.5755,decDeg:22.0175,peakMagnitude:-6,peakJd:2106216,startJd:2106216,lightCurve:[[0,-6],[23,-4],[642,6]],source:"Chinese chronicles (Song huiyao), via Stephenson & Green 2002",note:"The explosion that left the Crab Nebula. Its magnitude is an estimate; the two durations are recorded."},{id:"sn-1181",kind:"supernova",designation:"SN 1181",name:{en:"Supernova of 1181",fr:"supernova de 1181"},raHours:.88645,decDeg:67.50067,peakMagnitude:0,peakJd:2152636,startJd:2152636,lightCurve:[[0,0],[185,6]],source:"Chinese and Japanese chronicles, via Stephenson & Green 2002",note:"Circumpolar from Europe and China, so never set. Its peak magnitude is uncertain by at least a magnitude."},{id:"sn-1572",kind:"supernova",designation:"SN 1572",name:{en:"Tycho's Supernova",fr:"supernova de Tycho"},raHours:.42264,decDeg:64.14083,peakMagnitude:-4,peakJd:2295551,startJd:2295546,lightCurve:[[0,-3],[5,-4],[34,-2.4],[65,-1.4],[111,.3],[171,1.6],[263,2.5],[355,4],[369,4.2],[416,4.7],[461,5.3],[489,6]],source:"Tycho Brahe and contemporaries, reduced by Ruiz-Lapuente 2004",note:"Circumpolar from northern Europe. Tycho showed it had no parallax, so it was not in the air: a new star, beyond the Moon."},{id:"sn-1604",kind:"supernova",designation:"SN 1604",name:{en:"Kepler's Supernova",fr:"supernova de Kepler"},raHours:17.51125,decDeg:-21.48733,peakMagnitude:-2.95,peakJd:2307210,startJd:2307191,lightCurve:[[0,.23],[3,-1.3],[6,-2.08],[9,-2.17],[19,-2.95],[27,-2.95],[32,-1.95],[36,-1.52],[86,.9],[96,.45],[103,1],[114,1.2],[118,1.55],[133,1.95],[137,2.3],[170,2.25],[185,2.25],[194,2.4],[197,2.9],[308,4.45],[324,4.45],[339,4.95],[364,4.7]],source:"Kepler, Fabricius, Maestlin and the Korean court astronomers, reduced by Ruiz-Lapuente 2017",note:"The last supernova in our Galaxy seen with the naked eye. It went behind the Sun from mid-November 1604 to January 1605, which is the gap in its record."},{id:"t-crb-1866",kind:"nova",designation:"T CrB",name:{en:"Nova Coronae Borealis 1866",fr:"nova de la Couronne boréale 1866"},raHours:15.99171,decDeg:25.92017,peakMagnitude:2,peakJd:2402734,startJd:2402734,lightCurve:[[0,2],[1.5,3],[2.5,3.11],[6.5,5.18],[8.5,5.75],[10.5,6.85],[11.5,6.8],[12.5,7.5],[16,8.18],[32,9.27],[38,9.2],[40,8.95],[44,9.4],[48,9.07],[54,9.4],[58,9.21],[79,9.44],[107,9.26],[111,9.01],[115,8.21],[119,7.96],[159,7.51],[179,7.57],[183,7.97],[191,7.66],[199,8.2],[207,8.31],[211,8.83],[215,8.65],[223,8.97],[297,8.9],[345,9.25],[377,9.07],[425,9.3],[537,9.3]],source:"Recorded peak (Birmingham); curve borrowed from its 1946 eruption",note:"The first eruption of the recurrent nova T CrB to be seen. The decline is its 1946 one."},{id:"t-aur-1891",kind:"nova",designation:"T Aur",name:{en:"Nova Aurigae 1891",fr:"nova du Cocher 1891"},raHours:5.53309,decDeg:30.44583,peakMagnitude:4.49,peakJd:2412083,startJd:2412079,lightCurve:[[0,5.28],[4,4.49],[24,4.58],[40,4.97],[52,4.95],[56,4.5],[60,4.9],[68,4.88],[72,5.25],[76,4.93],[84,5.44],[88,7.23],[96,8.85],[100,10.44]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"gk-per-1901",kind:"nova",designation:"GK Per",name:{en:"Nova Persei 1901",fr:"nova de Persée 1901"},raHours:3.52,decDeg:43.90431,peakMagnitude:.19,peakJd:24154395e-1,startJd:24154377e-1,lightCurve:[[0,2.7],[.8,.86],[1.8,.19],[2.3,.2],[5.8,1.78],[11.8,2.54],[12.8,2.98],[17.8,3.62],[18.8,3.35],[19.8,3.77],[20.8,3.59],[22.8,3.95],[24.8,3.82],[25.6,4.99],[25.9,4.89],[26.6,3.69],[27.6,3.94],[27.9,4.61],[28.6,5.28],[28.9,4.46],[29.9,3.8],[30.9,4.27],[31.6,5.21],[31.9,5.22],[32.9,3.88],[33.9,4.19],[34.6,4.85],[35.6,4.8],[36.6,4.23],[37.6,4.44],[38.9,4.15],[39.7,5.19],[40.6,5.39],[40.9,5.35],[41.9,4.01],[42.6,4.5],[42.9,4.49],[43.6,5.53],[44,5.23],[44.6,5.61],[44.9,5.5],[45.9,4.17],[46.9,4.69],[47.6,5.5],[48.6,5.59],[49.6,5.14],[49.9,4.48],[50.6,4.45],[50.9,4.55],[51.6,5.47],[52.6,5.74],[53.7,5.66],[55.7,4.41],[56.7,5.43],[58.7,5.81],[58.9,5.58],[59.7,5.64],[59.9,4.76],[60.9,4.26],[61.9,5.62],[62.7,5.85],[62.9,5.53],[63.7,5.8],[64.9,4.28],[65.6,5.33],[66.7,5.87],[66.9,5.56],[68.7,5.7],[68.9,5.3],[69.7,4.47],[70.7,5.65],[72.9,5.98],[73.9,5.71],[74.7,4.98],[74.9,4.46],[75.7,4.87],[76.9,6.05],[77.6,5.76],[78,6],[78.7,5.95],[80.7,4.98],[81.9,5.85],[82.7,6.02],[84.7,5.41],[84.9,5.08],[85.7,5.17],[85.9,5.6],[87,6.1],[88.8,6.2],[89.7,4.96],[89.9,4.93],[90.7,5.9],[91.9,6.32],[92.7,5.86],[93.1,6.24],[93.7,5.38],[93.9,6.2],[96.1,6.12],[97.1,6.37],[97.6,5.12],[98,5.85],[99.3,6.35],[101.3,6.12],[101.7,5.25],[102.3,4.95],[102.7,6.12],[103.2,5.83],[104.7,6.37],[105,6.13],[106,6.22],[106.7,4.88],[107.7,6.3],[108.1,6.4],[109,6],[109.7,5.16],[110,5.82],[112.1,5.89],[113.1,5.5],[115.7,5.8],[116,6.11],[118.7,5.68],[119,6.23],[119.7,5.85],[120,6.12],[121,4.62],[121.8,5.9],[123,5.48],[125,6.05],[126,5.89],[130.9,6.11],[146.1,6.02],[155.6,6.26],[180.4,6.09],[190.4,6.39],[245.5,6.87],[266.2,6.77],[301.1,7.16],[321.5,7.07],[346.5,7.87],[375.7,7.86],[385.8,8.09],[389.8,8.55],[406.1,8.33],[416.5,8.59],[445.9,8.62],[472.1,9.24],[565.9,9.74],[571,9.4],[589.8,9.76]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"Discovered on 21 February 1901 by Thomas Anderson in Edinburgh, and the brightest nova of the century until V603 Aql."},{id:"dn-gem-1912",kind:"nova",designation:"DN Gem",name:{en:"Nova Geminorum 1912",fr:"nova des Gémeaux 1912"},raHours:6.9151,decDeg:32.14108,peakMagnitude:3.58,peakJd:241947675e-2,startJd:241947275e-2,lightCurve:[[0,11.7],[1,4.5],[4,3.58],[5,4.45],[5.5,5.32],[6,5.53],[6.5,5.11],[8,5.43],[8.5,5.16],[11,5.53],[11.5,5.13],[12,5.18],[13.75,4.5],[15.75,5.3],[18.75,6],[19.75,5.55],[26.75,6],[28.75,5.9],[31.75,6.6],[32.75,6.2],[33.75,6.5],[36.75,6.55],[39.75,6.2],[40.75,6.75],[41.75,7],[44.75,6.75],[52.75,6.75],[54.75,7.23],[58.25,7.5],[62.25,7.3],[64.25,7.47],[66.25,8.1],[70.25,7.5],[72.25,8.1],[78.25,7.55],[80.25,8.2],[86.25,7.2],[90.25,7.3],[92.25,7.8],[152.25,7.2],[160.25,7.4],[166.25,8.2],[168.25,8.2],[170.25,7.3],[180.25,7.4],[182.25,8],[186.25,7.5],[190.25,7.6],[192.25,8],[211.25,7.75],[227.25,8],[275.25,7.78],[315.25,8.6],[331.25,7.79],[339.25,8.27],[363.25,8.61],[443.25,8.93],[451.25,9.2],[535.25,10.3],[567.25,9.9],[615.25,10.8],[631.25,10.63],[647.25,10.88],[679.25,10.8],[695.25,11.07],[727.25,11]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v603-aql-1918",kind:"nova",designation:"V603 Aql",name:{en:"Nova Aquilae 1918",fr:"nova de l'Aigle 1918"},raHours:18.81518,decDeg:.58414,peakMagnitude:-.5,peakJd:242175475e-2,startJd:242174875e-2,lightCurve:[[0,11.3],[2,10.5],[4,6.6],[4.5,1.04],[6,-.5],[6.5,.18],[10,1.1],[10.5,.95],[12.75,1.89],[21.75,3.07],[23.75,3.76],[29.75,3.16],[34.75,3.5],[36.75,3.86],[44.75,3.79],[48.75,4.43],[52.75,3.84],[56.75,3.95],[57.75,4.04],[58.75,4.49],[59.75,4.42],[60.75,4.69],[62.75,4.6],[63.75,4.11],[64.75,3.97],[68.75,4.18],[70.75,4.65],[71.75,4.51],[73.75,4.73],[75.75,4.44],[79.75,4.85],[83.75,4.43],[89.75,4.88],[92.75,4.86],[94.75,4.58],[96.75,4.92],[99.75,5.05],[163.25,5.45],[167.25,5.7],[179.25,5.48],[191.25,5.8],[203.25,5.5],[247.25,5.9],[251.25,6.25],[257.25,5.5],[265.25,6.13],[281.25,6.33],[345.25,6.3],[385.25,6.73],[393.25,6.43],[425.25,6.71],[433.25,6.56],[461.25,7.27],[525.25,7.6],[541.25,7.47],[637.25,8.3],[669.25,8.17],[717.25,8.55],[749.25,8.4],[765.25,8.68],[885.25,8.75],[949.25,9.4],[1013.25,9.19],[1141.25,9.57],[1269.25,9.48],[1333.25,9.95],[1653.25,9.94],[1781.25,10.28],[1909.25,10.34],[2037.25,10.1],[2101.25,10.46],[2165.25,10.51],[2357.25,10.3],[2549.25,10.77],[2741.25,10.46],[2869.25,10.83],[3125.25,10.71],[3317.25,11.22],[3381.25,10.91],[3637.25,11.42],[3829.25,10.96],[3893.25,11.65],[3957.25,11.63],[4085.25,11.14],[4213.25,11.48],[4277.25,10.7],[4341.25,11.42],[4405.25,11.47],[4469.25,11.06],[4533.25,11.08],[4597.25,11.7],[4725.25,11.45],[4789.25,10.94]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"The brightest nova of the modern era, at magnitude -0.5 on 9-10 June 1918: as bright as Vega, in a summer evening sky, in wartime."},{id:"v476-cyg-1920",kind:"nova",designation:"V476 Cyg",name:{en:"Nova Cygni 1920",fr:"nova du Cygne 1920"},raHours:19.97347,decDeg:53.61858,peakMagnitude:1.94,peakJd:242256025e-2,startJd:242255925e-2,lightCurve:[[0,2.7],[1,1.94],[3,2.07],[4.5,2.95],[8.25,4],[31.75,6.41],[35.75,7.23],[37.75,7.08],[41.75,7.33],[43.75,7.92],[45.75,8.2],[51.75,8.59],[63.75,8.82],[65.75,9.25],[71.75,8.93],[85.75,9.43],[87.75,9.05],[95.75,9.2],[97.75,8.67],[99.75,9.07],[112.75,8.78],[120.75,9.03],[128.75,8.67],[144.75,8.94],[152.75,8.73],[168.75,8.79],[176.75,9.28],[192.75,9],[216.75,9.6],[232.75,9.27],[240.75,9.5],[288.75,9.4],[296.75,9.6],[304.75,9.3],[320.75,9.73],[328.75,9.5],[336.75,9.8],[428.75,9.61],[476.75,10.01],[492.75,9.76],[508.75,9.87],[524.75,9.65],[556.75,9.87],[572.75,9.65],[620.75,10.22],[668.75,10.44],[684.75,10.23],[716.75,10.33],[756.75,10.66],[884.75,10.59],[948.75,10.96],[1108.75,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"rr-pic-1925",kind:"nova",designation:"RR Pic",name:{en:"Nova Pictoris 1925",fr:"nova du Peintre 1925"},raHours:6.59335,decDeg:-62.64008,peakMagnitude:.95,peakJd:24243085e-1,startJd:24242995e-1,lightCurve:[[0,2.43],[5,2.35],[6,2.1],[7,2.4],[9,.95],[13,1.8],[14,1.7],[16,2.15],[18,2.2],[19,1.9],[23,3.1],[27,3.05],[31.5,3.58],[43.5,3.08],[47.5,3.15],[57.5,2.3],[59.5,1.65],[63.5,3.03],[65.5,2.84],[67.5,3.16],[69.5,2.4],[71.5,2.04],[73.5,2.05],[75.5,2.55],[79.5,3],[83.5,3.15],[116.5,3.54],[120.5,3.78],[124.5,3.67],[136.5,4.18],[148.5,4.34],[154.5,4.17],[194.5,4.43],[226.5,4.93],[234.5,4.8],[242.5,5.4],[250.5,5.5],[266.5,5.15],[298.5,5.6],[362.5,5.4],[414.5,5.7],[430.5,5.5],[494.5,6.2],[718.5,6.52],[830.5,6.3],[862.5,6.6],[878.5,6.4],[910.5,6.77],[958.5,6.67],[1062.5,7.07],[1318.5,7.35],[1590.5,8.12],[1718.5,8.25],[2486.5,8.59],[2614.5,8.47],[2742.5,8.7],[3382.5,8.6],[3766.5,8.97],[4022.5,8.79],[4150.5,9.22],[6710.5,10.29],[7414.5,11.03],[8438.5,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A slow nova, and a southern one: more than two months within two magnitudes of its peak."},{id:"dq-her-1934",kind:"nova",designation:"DQ Her",name:{en:"Nova Herculis 1934",fr:"nova d'Hercule 1934"},raHours:18.12507,decDeg:45.85906,peakMagnitude:1.56,peakJd:24277935e-1,startJd:242778675e-2,lightCurve:[[0,3.4],[1.5,2.4],[3,2.67],[5.75,2.01],[6.75,1.56],[7.75,1.59],[11.75,2.97],[12.75,2.31],[14.75,3.07],[15.75,2.56],[16.75,2.51],[19.75,2.68],[23.75,2.53],[24.75,2.27],[26.75,2.58],[30.75,2.24],[31.75,2.63],[32.75,2.66],[34.75,2.11],[39.75,2.71],[41.75,2.31],[43.75,2.37],[46.75,3.64],[47.75,3.21],[50.75,3.23],[52.75,2.66],[55.75,2.56],[58.75,2.97],[60.75,2.77],[61.75,3.36],[63.75,3.43],[64.75,2.89],[65.75,3.22],[68.75,3.52],[69.75,2.95],[70.75,3.06],[71.75,2.7],[76.75,3.65],[79.75,3.74],[81.75,3.21],[83.75,3.75],[87.75,3.69],[92.75,4.04],[94.75,4.8],[97.75,4.24],[98.75,4.52],[100.75,4.08],[101.75,4.43],[105.75,4.58],[106.75,4.33],[107.75,4.73],[108.75,6.57],[109.75,8.08],[110.75,8.15],[111.75,8.56],[113.75,8.45],[114.75,9.15],[115.75,9.15],[116.75,9.59],[117.75,9.43],[118.75,9.8],[122.75,10.5],[123.75,10.28],[124.75,10.93],[127.75,10.83],[129.75,11.87],[131.75,12.42],[135.75,12.5],[137.75,12.9],[138.75,12.77],[139.75,13],[143.75,12],[144.75,12.33],[146.75,12.35],[147.75,11.64],[148.75,11.83],[150.75,10.9],[151.75,10.78],[152.75,11.17],[154.75,10.32],[155.75,10.4],[165.25,9.24],[185.25,7.74],[225.25,6.8],[273.25,6.72],[321.25,6.97],[333.25,6.79],[353.25,7],[357.25,6.82],[377.25,6.88],[401.25,7.29],[409.25,6.8],[413.25,6.8],[419.25,7.1],[435.25,7.09],[451.25,7.4],[475.25,7],[555.25,7.48],[823.25,7.83],[855.25,8.18],[1135.25,8.43],[1823.25,9.98],[1887.25,9.71],[2015.25,10.55],[2335.25,10.95]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"Lost about ten magnitudes in a few weeks from April 1935, when dust condensed around it, then came back to naked-eye brightness."},{id:"cp-lac-1936",kind:"nova",designation:"CP Lac",name:{en:"Nova Lacertae 1936",fr:"nova du Lézard 1936"},raHours:22.26142,decDeg:55.61703,peakMagnitude:2.02,peakJd:242834025e-2,startJd:242833825e-2,lightCurve:[[0,4.03],[.5,2.9],[1,2.45],[2,2.02],[2.5,2.61],[4,3],[4.5,3.35],[5,3.3],[9.25,4.59],[14.25,5.45],[22.25,6.03],[23.25,6.3],[26.25,6.23],[38.25,6.74],[41.25,6.61],[50.25,7.35],[53.25,7.27],[57.25,7.7],[58.25,7.54],[60.25,7.55],[61.25,7.79],[71.25,7.6],[74.25,7.81],[76.25,8.3],[77.25,7.79],[86.25,8.21],[87.25,8],[88.25,8.25],[92.25,8.17],[94.25,8.47],[102.25,8.27],[103.25,8.7],[104.25,8.4],[110.25,8.66],[116.75,8.55],[122.75,8.83],[126.75,8.7],[140.75,9.06],[154.75,9.01],[164.75,9.36],[170.75,9.18],[174.75,9.48],[186.75,9.42],[188.75,9.73],[192.75,9.53],[200.75,9.74],[202.75,9.5],[204.75,9.77],[208.75,9.6],[214.75,9.75],[216.75,10.05],[222.75,9.7],[232.75,10.03],[236.75,9.82],[250.75,10.1],[254.75,9.9],[260.75,10.1],[264.75,9.8],[266.75,10.15],[268.75,10],[274.75,10.2],[276.75,9.9],[292.75,10.6],[294.75,10.6],[298.75,10.1],[318.75,10.35],[320.75,10.6],[322.75,10.3],[328.75,10.65],[332.75,10.3],[338.75,10.7],[348.75,10.53],[350.75,10.7],[354.75,10.37],[358.75,10.58],[365.75,10.43],[373.75,10.85],[421.75,10.94]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"cp-pup-1942",kind:"nova",designation:"CP Pup",name:{en:"Nova Puppis 1942",fr:"nova de la Poupe 1942"},raHours:8.19613,decDeg:-35.35139,peakMagnitude:.73,peakJd:243067675e-2,startJd:243067275e-2,lightCurve:[[0,.95],[4,.73],[4.5,1.3],[5.5,1.47],[6,2.01],[7.75,2.88],[8.75,2.97],[10.75,3.5],[11.75,4.02],[13.75,4.4],[14.75,3.8],[17.75,5],[18.75,4.93],[19.75,5.48],[23.75,5.5],[25.75,5.65],[26.75,5.99],[33.25,6.28],[45.25,6.6],[57.25,6.41],[81.25,6.85],[89.25,6.5],[97.25,6.67],[101.25,7],[113.25,6.66],[125.25,7.1],[135.25,6.96],[231.25,7.86],[279.25,7.8],[327.25,8.33],[407.25,8.18],[423.25,8.59],[471.25,8.53],[503.25,8.99],[551.25,8.97],[567.25,8.7],[583.25,9.47],[615.25,8.95],[655.25,9.5],[751.25,9.55],[815.25,10.09],[847.25,10.02],[879.25,10.48],[911.25,10.34],[1023.25,10.79],[1279.25,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"One of the fastest bright novae: two magnitudes gone in four days."},{id:"t-crb-1946",kind:"nova",designation:"T CrB",name:{en:"Nova Coronae Borealis 1946",fr:"nova de la Couronne boréale 1946"},raHours:15.99171,decDeg:25.92017,peakMagnitude:2.5,peakJd:2431860,startJd:2431860,lightCurve:[[0,2.5],[1.5,3.5],[2.5,3.61],[6.5,5.68],[8.5,6.25],[10.5,7.35],[11.5,7.3],[12.5,8],[16,8.68],[32,9.77],[38,9.7],[40,9.45],[44,9.9],[48,9.57],[54,9.9],[58,9.71],[79,9.94],[107,9.76],[111,9.51],[115,8.71],[119,8.46],[159,8.01],[179,8.07],[183,8.47],[191,8.16],[199,8.7],[207,8.81],[211,9.33],[215,9.15],[223,9.47],[297,9.4],[345,9.75],[377,9.57],[425,9.8],[537,9.8]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A recurrent nova. It erupted in 1866 and in 1946, and a third eruption was expected from 2024 on."},{id:"v446-her-1960",kind:"nova",designation:"V446 Her",name:{en:"Nova Herculis 1960",fr:"nova d'Hercule 1960"},raHours:18.956,decDeg:13.24147,peakMagnitude:4.83,peakJd:24370038e-1,startJd:24370033e-1,lightCurve:[[0,5.2],[.5,4.83],[2,4.9],[2.5,5.4],[3,5.05],[3.5,5.57],[4,5.25],[5,5.5],[6.5,5.4],[7.2,5.78],[8.2,5.6],[9.2,5.98],[10.2,5.92],[11.2,6.21],[16.2,6.1],[17.2,6.23],[18.2,7.2],[19.2,6.51],[20.2,6.78],[26.2,6.97],[27.2,7.24],[28.2,7.13],[29.2,7.45],[31.2,7.2],[40.7,7.57],[44.7,8.25],[46.7,7.84],[56.7,8.15],[60.7,8.9],[70.7,8.7],[72.7,8.14],[76.7,8.71],[80.7,8.47],[82.7,8.87],[86.7,8.57],[90.7,8.93],[107.7,9.11],[111.7,8.94],[115.7,9.27],[139.7,9.38],[151.7,9.91],[155.7,9.72],[173.7,10.51],[221.7,10.95]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v533-her-1963",kind:"nova",designation:"V533 Her",name:{en:"Nova Herculis 1963",fr:"nova d'Hercule 1963"},raHours:18.23902,decDeg:41.85614,peakMagnitude:3,peakJd:24380605e-1,startJd:24380565e-1,lightCurve:[[0,8],[4,3],[4.5,3],[8,4],[13,3.95],[15,4.6],[21,4.53],[24,5.05],[27,5.15],[32,4.76],[34,4.98],[35,5.39],[37,5.43],[41,6.04],[49,6.02],[56.5,6.34],[60.5,6.11],[74.5,6.72],[102.5,6.99],[137.5,7.81],[197.5,8.31],[217.5,8.8],[225.5,8.57],[233.5,9.03],[237.5,8.78],[277.5,9.44],[301.5,9.46],[315.5,9.86],[323.5,9.73],[339.5,10.05],[355.5,10.74],[363.5,10.32],[371.5,10.6],[387.5,10.69],[427.5,10.38],[435.5,10.84],[443.5,10.74],[451.5,11.33],[459.5,10.98],[467.5,11.17],[507.5,11.16],[539.5,11.66],[603.5,11.7],[619.5,12.05],[651.5,12.03],[659.5,11.74],[667.5,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"hr-del-1967",kind:"nova",designation:"HR Del",name:{en:"Nova Delphini 1967",fr:"nova du Dauphin 1967"},raHours:20.70565,decDeg:19.16092,peakMagnitude:3.58,peakJd:2439838,startJd:2439646,lightCurve:[[0,11.9],[6,11.8],[12,8.8],[16,8.3],[20,6.7],[30,5.8],[36,5.51],[66,5.55],[78,5.35],[86,4.89],[96,5],[108,4.75],[136,5.13],[152,4.83],[182,4.93],[186,4.59],[192,3.58],[202,5],[220,5.46],[226,5.14],[230,5.45],[232,5.14],[236,5],[242,5.08],[244,4.59],[246,4.45],[254,5.3],[256,4.75],[260,5.69],[268,4.8],[274,4.94],[276,5.45],[280,5.2],[282,5.51],[286,5.58],[292,4.95],[294,5.16],[298,4.94],[311,5.09],[335,4.4],[367,5.76],[407,6.16],[423,6.55],[603,7.43],[907,8.32],[1451,9.41],[2347,10.75]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"An exceptionally slow nova: rose over months and stayed near magnitude 4 to 5 for most of 1967 and 1968."},{id:"lv-vul-1968",kind:"nova",designation:"LV Vul",name:{en:"Nova Vulpeculae 1968",fr:"nova du Petit Renard 1968"},raHours:19.80012,decDeg:27.1715,peakMagnitude:4.5,peakJd:243996425e-2,startJd:243996325e-2,lightCurve:[[0,5],[1,4.5],[2,5],[2.5,4.86],[3,5.1],[3.5,4.88],[4,5.1],[5,4.9],[7,5.4],[8,5.23],[10.5,5.42],[12,5.82],[13,5.4],[13.5,5.74],[14,5.7],[14.5,6.08],[15,5.75],[15.5,5.86],[16,5.6],[17,5.8],[18,5.6],[20.5,6.34],[21,6.2],[22.5,6.84],[23,6.57],[24,6.98],[24.5,6.3],[25,7.1],[26,6.65],[34.25,7.48],[35.25,7.23],[39.25,7.32],[44.25,7.76],[45.25,7.49],[46.25,7.78],[50.25,7.84],[51.25,8.1],[53.25,7.9],[54.25,8.13],[56.25,8],[57.75,8.24],[67.75,8.52],[75.75,8.38],[83.75,8.69],[89.75,8.59],[125.75,9.32],[127.75,9.33],[129.75,8.98],[131.75,9.29],[135.75,9.43],[212.75,9.9],[220.75,10.16],[228.75,10.03],[236.75,10.3],[244.75,10.16],[264.75,10.54],[280.75,10.45],[296.75,10.79],[328.75,10.78]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"fh-ser-1970",kind:"nova",designation:"FH Ser",name:{en:"Nova Serpentis 1970",fr:"nova du Serpent 1970"},raHours:18.51307,decDeg:2.61444,peakMagnitude:4.5,peakJd:244063425e-2,startJd:244063125e-2,lightCurve:[[0,7],[2,5],[3,4.5],[3.5,5],[4.5,4.6],[5.5,5],[6.5,4.68],[12.25,4.66],[16.25,5.3],[17.25,5.72],[18.25,5.3],[19.25,5.2],[23.25,5.84],[24.25,5.68],[27.25,5.9],[30.25,5.47],[32.25,5.9],[34.25,5.7],[43.25,6.28],[45.25,6.1],[50.25,6.62],[52.25,6.47],[57.25,6.63],[60.25,7.08],[61.25,6.87],[62.25,7.2],[63.25,6.85],[64.25,7.68],[65.25,7.3],[66.25,8.3],[67.25,7.93],[69.25,9.15],[71.25,9.2],[72.25,9.63],[74.25,9.9],[76.25,9.7],[77.25,10.25],[78.25,10.1],[79.25,10.4],[80.25,10.23],[81.25,10.57],[83.25,10.64],[85.25,10.35],[86.25,11.2],[87.25,10.1],[89.25,11.2],[96.25,11.35],[100.25,11.95],[102.25,11.1],[104.25,11.65],[106.25,11.5],[108.25,12.07],[114.75,11.32],[118.75,11.28],[122.75,10.93],[130.75,10.85],[134.75,10.52],[154.75,10.65],[162.75,10.12],[174.75,9.98],[178.75,10.34],[186.75,9.98],[214.75,10.25],[224.75,10.02],[240.75,10.2],[264.75,10],[272.75,10.2],[280.75,10.05],[288.75,10.4],[296.75,10],[348.75,10.7],[396.75,10.3],[444.75,10.73],[460.75,10.59],[540.75,10.94],[556.75,10.82]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v1500-cyg-1975",kind:"nova",designation:"V1500 Cyg",name:{en:"Nova Cygni 1975",fr:"nova du Cygne 1975"},raHours:21.19349,decDeg:48.15056,peakMagnitude:1.88,peakJd:244265525e-2,startJd:244265425e-2,lightCurve:[[0,2.44],[1,1.88],[1.5,1.88],[2.5,2.41],[3,3.38],[4,4.28],[8.25,5.81],[11.25,6.46],[22.25,7.35],[33.25,7.73],[34.25,7.97],[37.25,7.86],[40.25,8.3],[43.25,8.19],[48.25,8.6],[49.25,8.46],[66.25,9.04],[70.25,8.93],[75.25,9.23],[76.25,9.03],[80.25,9.39],[81.25,9.19],[83.25,9.35],[84.25,9.13],[86.25,9.39],[89.25,9.32],[90.25,9.54],[93.25,9.37],[105.75,9.86],[193.75,10.43],[201.75,10.7],[209.75,10.47],[257.75,10.94],[265.75,10.81]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"One of the fastest novae on record: discovered on 29 August 1975, at its peak of magnitude 1.9 within two days, and two magnitudes down again two days later."},{id:"v842-cen-1986",kind:"nova",designation:"V842 Cen",name:{en:"Nova Centauri 1986",fr:"nova du Centaure 1986"},raHours:14.59794,decDeg:-57.6265,peakMagnitude:4.9,peakJd:244675975e-2,startJd:244675725e-2,lightCurve:[[0,5.6],[2.5,4.9],[3.5,5.1],[15.5,5.1],[17.5,5.75],[18.5,5.4],[20.5,5.5],[22.5,5.95],[30.5,6.15],[31.5,6.3],[32,7.5],[34.5,7.2],[38.5,7.5],[39,7],[41.5,7.15],[42.5,6.7],[44.5,7.23],[45.5,6.6],[53,9.3]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"sn-1987a",kind:"supernova",designation:"SN 1987A",name:{en:"Supernova 1987A",fr:"supernova 1987A"},raHours:5.59111,decDeg:-69.26975,peakMagnitude:2.98,peakJd:24469425e-1,startJd:24468495e-1,lightCurve:[[0,6.36],[1,6.11],[2,4.63],[4,4.45],[32,3.97],[56,3.15],[93,2.98],[105,3.35],[118,4.11],[134,4.43],[504,8.15],[617,10.27]],source:"V photometry compiled by the Open Supernova Catalog (Sternberg catalogue, IAU circulars, CTIO)",note:"In the Large Magellanic Cloud, 160 000 light years away: the nearest supernova since Kepler's, and invisible north of about 20° N."},{id:"v1974-cyg-1992",kind:"nova",designation:"V1974 Cyg",name:{en:"Nova Cygni 1992",fr:"nova du Cygne 1992"},raHours:20.50879,decDeg:52.63078,peakMagnitude:4.27,peakJd:24486753e-1,startJd:24486718e-1,lightCurve:[[0,7.2],[1,5.23],[2,4.62],[3.5,4.27],[4.5,4.59],[6,4.5],[7,4.78],[7.5,4.52],[8,4.82],[10.7,5.25],[11.7,5.66],[16.7,5.85],[21.7,6.47],[22.7,6.3],[27.7,6.46],[29.7,6.83],[34.7,6.9],[35.7,7.25],[36.7,7],[37.7,7.16],[39.7,7.03],[43.7,7.41],[45.7,7.26],[50.7,7.45],[57.7,7.78],[58.7,8.13],[61.7,7.92],[64.7,8.19],[65.7,7.99],[71.7,8.22],[76.7,8.01],[128.2,8.72],[176.2,8.89],[192.2,9.15],[216.2,9.28],[232.2,9.07],[236.2,9.3],[390.2,10.99]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v382-vel-1999",kind:"nova",designation:"V382 Vel",name:{en:"Nova Velorum 1999",fr:"nova des Voiles 1999"},raHours:10.74678,decDeg:-52.42533,peakMagnitude:2.88,peakJd:245132225e-2,startJd:245132075e-2,lightCurve:[[0,2.99],[1.5,2.88],[2.5,3.46],[4.5,3.98],[5,4.32],[5.5,4.23],[7.5,4.85],[21.75,6.67],[30.25,7.2],[40.25,7.41],[93.25,7.95],[97.25,8.25],[101.25,8],[113.25,7.96],[129.25,8.5],[155.25,8.47],[163.25,9.1],[179.25,9],[187.25,8.7],[195.25,9.15],[211.25,9.23],[235.25,9.8],[243.25,9.71],[299.25,10.42],[383.25,10.52],[415.25,10.81]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v1494-aql-1999",kind:"nova",designation:"V1494 Aql",name:{en:"Nova Aquilae 1999",fr:"nova de l'Aigle 1999"},raHours:19.38482,decDeg:4.9555,peakMagnitude:4.11,peakJd:245151575e-2,startJd:245151425e-2,lightCurve:[[0,5.15],[.5,4.86],[1,4.27],[1.5,4.11],[2.5,4.35],[5,5.48],[10.5,6.26],[14.25,6.28],[20.25,7.43],[24.25,7.25],[25.25,7.63],[27.25,7.7],[29.25,7.42],[33.25,8.08],[35.25,8.03],[36.25,7.6],[37.25,7.6],[46.25,8.5],[54.25,8.28],[56.25,8.63],[58.25,8.4],[61.25,9.53],[62.25,9],[64.25,9.13],[69.25,8.58],[70.25,8.9],[72.25,8.88],[75.25,8.57],[77.25,9],[79.25,8.8],[81.25,9.7],[83.25,9.6],[85.25,9.8],[86.75,9.5],[88.75,9.54],[90.75,8.9],[92.75,8.85],[96.75,9.63],[102.75,9.7],[104.75,8.98],[106.75,8.73],[116.75,9.63],[118.75,9.6],[120.75,9.07],[122.75,9.26],[124.75,9.8],[128.75,9.36],[134.75,9.75],[147.75,9.92],[155.75,9.81],[259.75,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v4743-sgr-2002",kind:"nova",designation:"V4743 Sgr",name:{en:"Nova Sagittarii 2002",fr:"nova du Sagittaire 2002"},raHours:19.01926,decDeg:-22.00167,peakMagnitude:5,peakJd:245253775e-2,startJd:245253675e-2,lightCurve:[[0,5.2],[1,5],[2,5.89],[2.5,5.91],[3.5,6.43],[5,6.45],[5.5,6.86],[6,6.59],[7,6.77],[7.5,7.31],[8.5,6.99],[9,7.09],[10.5,7.86],[11,7.58],[11.5,7.89],[15.75,8.33],[17.75,8.18],[18.75,8.58],[19.75,8.44],[22.75,8.83],[23.75,8.6],[24.75,8.85],[27.75,8.83],[30.75,9.4],[31.75,9.09],[36.25,9.08],[38.25,9.34],[62.25,9.75],[66.25,10.1],[70.25,9.7],[74.25,10],[171.25,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"rs-oph-2006",kind:"nova",designation:"RS Oph",name:{en:"Nova Ophiuchi 2006",fr:"nova d'Ophiuchus 2006"},raHours:17.83699,decDeg:-6.70792,peakMagnitude:4.8,peakJd:2453779,startJd:2453779,lightCurve:[[0,4.8],[1.25,4.97],[2.75,5.78],[3.25,5.7],[3.75,6.24],[4.25,6.05],[4.75,6.38],[5.25,6.3],[8.5,7.25],[14.5,7.95],[24.5,8.55],[29.5,9.08],[48,9.87],[80,10.28],[107,11.54],[119,11.54],[139,11.98],[147,11.83],[163,12.03],[171,11.97],[175,11.65],[183,11.84],[195,11.64],[203,11.8],[207,12.13],[219,11.45],[277,11.68],[325,11],[341,11.53],[357,11.62],[373,11.3],[405,11.5],[421,11.17],[469,10.96],[501,11.22],[549,10.75],[581,11.08],[597,10.98]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A recurrent nova, erupting every twenty years or so (1898, 1907, 1933, 1945, 1958, 1967, 1985, 2006, 2021)."},{id:"v1280-sco-2007",kind:"nova",designation:"V1280 Sco",name:{en:"Nova Scorpii 2007",fr:"nova du Scorpion 2007"},raHours:16.96145,decDeg:-32.34325,peakMagnitude:3.8,peakJd:2454149,startJd:2454136,lightCurve:[[0,9.7],[13,3.8],[34,5.8],[103,15]],source:"AAVSO (discovery, peak, dust minimum); t2 from Das et al. 2008",note:"Faded from sight quickly when dust formed around it, three weeks after its peak."},{id:"v339-del-2013",kind:"nova",designation:"V339 Del",name:{en:"Nova Delphini 2013",fr:"nova du Dauphin 2013"},raHours:20.39186,decDeg:20.76772,peakMagnitude:4.4,peakJd:24565214e-1,startJd:24565214e-1,lightCurve:[[0,4.4],[11,6.4],[20,7.4]],source:"Gehrz et al. 2015 (peak, t2, t3)",note:"High in the summer evening sky of the northern hemisphere, and widely photographed."},{id:"v1369-cen-2013",kind:"nova",designation:"V1369 Cen",name:{en:"Nova Centauri 2013",fr:"nova du Centaure 2013"},raHours:13.9126,decDeg:-59.15114,peakMagnitude:3.48,peakJd:245663965e-2,startJd:24566285e-1,lightCurve:[[0,5.33],[1.57,4.08],[2.75,3.73],[4.57,4.16],[5.96,4.15],[10.26,3.77],[11.15,3.48],[12.14,3.74],[14.17,4.78],[15.46,4.97],[23.16,4.22],[26.25,4.32],[27.31,4.82],[29.56,5.11],[32.66,4.71],[33.84,4.86],[36.05,4.46],[37.15,4.99],[41.42,4.59],[42.37,4.93],[43.37,4.82],[44.54,5.09],[49.95,5.38],[51.99,5.82],[54.21,5.77]],source:"AAVSO, binned by day, as plotted by Izzo 2017 (arXiv:1704.07214, figure 1)",note:"Discovered on 2 December 2013 by John Seach at magnitude 5.5, it flared several times, reaching about 3.3 around 14 December: the brightest nova of the century so far, and a southern one."},{id:"rs-oph-2021",kind:"nova",designation:"RS Oph",name:{en:"Nova Ophiuchi 2021",fr:"nova d'Ophiuchus 2021"},raHours:17.83699,decDeg:-6.70792,peakMagnitude:4.6,peakJd:2459436,startJd:2459435,lightCurve:[[0,5],[1,4.6],[2.25,4.77],[3.75,5.58],[4.25,5.5],[4.75,6.04],[5.25,5.85],[5.75,6.18],[6.25,6.1],[9.5,7.05],[15.5,7.75],[25.5,8.35],[30.5,8.88],[49,9.67],[81,10.08],[108,11.34],[120,11.34],[140,11.78],[148,11.63],[164,11.83],[172,11.77],[176,11.45],[184,11.64],[196,11.44],[204,11.6],[208,11.93],[220,11.25],[278,11.48],[326,10.8],[342,11.33],[358,11.42],[374,11.1],[406,11.3],[422,10.97],[470,10.76],[502,11.02],[550,10.55],[582,10.88],[598,10.78]],source:"Recorded discovery and peak (8 and 9 August 2021); curve borrowed from its 2006 eruption",note:"RS Oph's latest eruption, discovered on 8 August 2021. The decline is its 2006 one."}];class Am{static UNIX_EPOCH_JD=24405875e-1;static aroundDate(e){const t=this.julianDayOf(e);return Zh.filter(i=>this.magnitudeAt(i,t)!==void 0)}static appearancesAt(e,t){const i=this.julianDayOf(e),n=[];for(const s of Zh){const r=this.magnitudeAt(s,i);r!==void 0&&n.push({outburst:s,position:En.ofJ2000(s.raHours,s.decDeg,e,t),magnitude:r})}return n.sort((s,r)=>s.magnitude-r.magnitude)}static brightestAt(e,t){return this.appearancesAt(e,t)[0]}static byId(e){return Zh.find(t=>t.id===e)}static magnitudeAt(e,t){const i=e.lightCurve,n=t-e.startJd;if(i.length===0||n<i[0][0]||n>i[i.length-1][0])return;let s=1;for(;s<i.length-1&&i[s][0]<n;)s++;const[r,o]=i[s-1]??i[0],[c,l]=i[s]??i[0];if(c===r)return o;const h=Math.min(1,Math.max(0,(n-r)/(c-r)));return o+h*(l-o)}static julianDayOf(e){return e.getTime()/864e5+this.UNIX_EPOCH_JD}}const jb=[{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}],ml=6.5;class Jh{static activeAt(e){return jb.flatMap(t=>{const i=this.nearness(t,e);return i<=0?[]:[{shower:t,zhr:t.peakZhr*i,nearness:i}]})}static nearness(e,t){const i=this.dayOfYear(t),n=this.dayOfYear(this.asDate(e.start)),s=this.dayOfYear(this.asDate(e.peak)),r=this.dayOfYear(this.asDate(e.end)),o=this.wrappedDelta(i,s),c=this.wrappedDelta(s,n),l=this.wrappedDelta(r,s);return o<0?o<-c?0:1+o/c:o>0?o>l?0:1-o/l:1}static observedRatePerHour(e,t,i,n=ml){if(t<=0)return 0;const s=ml-n;return e*Math.sin(t*Math.PI/180)/Math.pow(i,s)}static radiantPosition(e,t,i){return En.ofJ2000(e.radiantRaHours,e.radiantDecDeg,t,i)}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 i=e-t;return i>182?i-365:i<-182?i+365:i}}class Xt{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(e,t){const i=kt(e),n=new Rl(0,R5(e).elon-90,1),s=mr(Q5(i),l0(n,i)),r=h0(s);return u0(r.ra,r.dec,e,t)}static observedRatePerHour(e,t=ml){const i=Xt.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(e*Math.PI/180)),n=ml-t;return(Xt.QUIET_RATE_PER_HOUR+i)/Math.pow(Xt.POPULATION_INDEX,n)}static schedule(e){const t=new Il(e.seed^1542469173);return va.schedule(e).map(i=>{const n=Xt.toCartesian({altitudeDeg:Math.asin(t.next())*180/Math.PI,azimuthDeg:t.between(0,360)}),s=i.fromRadiantDeg*Math.PI/180,r=Xt.turnAround(n,t.between(0,360)),o={x:n.x*Math.cos(s)+r.x*Math.sin(s),y:n.y*Math.cos(s)+r.y*Math.sin(s),z:n.z*Math.cos(s)+r.z*Math.sin(s)};return{...i,radiant:Xt.toHorizontal(o),bearingDeg:Xt.bearingFrom(o,n)}})}static turnAround(e,t){const[i,n]=Xt.basisAround(e),s=t*Math.PI/180;return{x:i.x*Math.cos(s)+n.x*Math.sin(s),y:i.y*Math.cos(s)+n.y*Math.sin(s),z:i.z*Math.cos(s)+n.z*Math.sin(s)}}static bearingFrom(e,t){const[i,n]=Xt.basisAround(e),s=e.x*t.x+e.y*t.y+e.z*t.z,r=Xt.normalise({x:t.x-e.x*s,y:t.y-e.y*s,z:t.z-e.z*s});return(Math.atan2(r.x*n.x+r.y*n.y+r.z*n.z,r.x*i.x+r.y*i.y+r.z*i.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},i=Xt.normalise(Xt.cross(e,t));return[i,Xt.normalise(Xt.cross(e,i))]}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}),i=Xt.turnAround(t,e.bearingDeg),n=e.fromRadiantDeg*Math.PI/180;return Xt.toHorizontal({x:t.x*Math.cos(n)+i.x*Math.sin(n),y:t.y*Math.cos(n)+i.y*Math.sin(n),z:t.z*Math.cos(n)+i.z*Math.sin(n)})}static toCartesian(e){const t=e.altitudeDeg*Math.PI/180,i=e.azimuthDeg*Math.PI/180,n=Math.cos(t);return{x:n*Math.sin(i),y:Math.sin(t),z:-n*Math.cos(i)}}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}const Tm="https://ufoathome.org/tle/index.json";class Ei{static MAX_ELEMENT_AGE_DAYS=7;static DAY_MS=864e5;fetchImpl;indexUrls;index;files=new Map;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.indexUrls=e.indexUrls??Ei.defaultIndexUrls()}static defaultIndexUrls(){const e=[];return typeof location<"u"&&/^https?:$/.test(location.protocol)&&e.push(new URL("/tle/index.json",location.href).href),e.includes(Tm)||e.push(Tm),e}static FIRST_SNAPSHOT="2021-02-22";async covers(e){const t=Date.parse(`${Ei.FIRST_SNAPSHOT}T00:00:00Z`)-Ei.MAX_ELEMENT_AGE_DAYS*Ei.DAY_MS;if(e.getTime()<t)return!1;const i=await this.loadIndex();return i?Object.values(i.index.kinds).some(n=>e.getTime()>=Date.parse(n.from)-Ei.MAX_ELEMENT_AGE_DAYS*Ei.DAY_MS&&e.getTime()<=Date.parse(n.to)+Ei.MAX_ELEMENT_AGE_DAYS*Ei.DAY_MS):!1}async at(e){const t=await this.loadIndex();if(!t)return;const{index:i,base:n}=t,s=[],r=[];for(const o of Object.keys(i.kinds)){const c=await this.kindAt(o,e,i,n);s.push(...c),r.push(this.coverageOf(o,e,i,c.length>0))}return{objects:s,coverage:r,credit:i.credit,creditUrl:i.source}}async kindAt(e,t,i,n){const s=t.getTime(),r=i.binDays*Ei.DAY_MS,o=Math.floor(s/r),c=s-o*r<r/2?o-1:o+1,l=new Set(i.kinds[e].bins),h=[o,c].map(v=>new Date(v*r).toISOString().slice(0,10)).filter(v=>l.has(v));if(h.length===0)return[];const[u,...d]=await Promise.all([this.json(new URL(`objects-${e}.json`,n).href),...h.map(v=>this.binary(new URL(`${e}/${v}.bin`,n).href))]),f=new Map;for(const v of d)for(const m of Ei.decode(v,i.recordBytes)){const g=f.get(m.norad);(!g||Math.abs(m.epochMs-s)<Math.abs(g.epochMs-s))&&f.set(m.norad,m)}const p=[];for(const v of f.values()){const m=Math.abs(v.epochMs-s)/Ei.DAY_MS;if(m>Ei.MAX_ELEMENT_AGE_DAYS)continue;const g=u[v.norad]??{name:String(v.norad)};g.launch&&Date.parse(`${g.launch}T00:00:00Z`)>s||p.push({norad:v.norad,name:g.name,kind:e,launch:g.launch,stdMag:g.stdMag,elements:v,ageDays:m})}return p}coverageOf(e,t,i,n){const{from:s,to:r}=i.kinds[e],o=t.getTime(),c=Ei.MAX_ELEMENT_AGE_DAYS*Ei.DAY_MS,l=n?"covered":o<Date.parse(s)-c?"before":o>Date.parse(r)+c?"after":"gap";return{kind:e,status:l,from:s,to:r}}static decode(e,t){const i=new DataView(e),n=[];for(let s=0;s+t<=e.byteLength;s+=t)n.push({norad:i.getUint32(s,!0),epochMs:i.getFloat64(s+4,!0),bstar:i.getFloat32(s+12,!0),inclinationDeg:i.getFloat32(s+16,!0),raanDeg:i.getFloat32(s+20,!0),eccentricity:i.getFloat32(s+24,!0),argOfPerigeeDeg:i.getFloat32(s+28,!0),meanAnomalyDeg:i.getFloat32(s+32,!0),meanMotion:i.getFloat64(s+36,!0)});return n}loadIndex(){return this.index??=(async()=>{for(const e of this.indexUrls)try{const t=await this.fetchImpl(e);if(!t.ok)continue;return{index:await t.json(),base:e}}catch{}})(),this.index}json(e){return this.cached(e,async t=>t.json())}binary(e){return this.cached(e,async t=>t.arrayBuffer())}cached(e,t){let i=this.files.get(e);return i||(i=this.fetchImpl(e).then(n=>{if(!n.ok)throw new Error(`${e}: ${n.status}`);return t(n)}),i.catch(()=>this.files.delete(e)),this.files.set(e,i)),i}}class Qb{lowerM;upperM;add(e,t){if(!(e<=0)){if(t.behindM!==void 0){const i=Rt.sizeMAt(t.behindM,e);this.lowerM=this.lowerM===void 0?i:Math.max(this.lowerM,i)}if(t.inFrontM!==void 0){const i=Rt.sizeMAt(t.inFrontM,e);this.upperM=this.upperM===void 0?i:Math.min(this.upperM,i)}}}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:Rt.distanceMAt(this.lowerM,e),maxM:this.upperM===void 0?void 0:Rt.distanceMAt(this.upperM,e)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class xa{static DEG_PER_SECOND=360/86164.0905;static degOver(e){return Math.max(0,e)*xa.DEG_PER_SECOND}static instants(e,t){if(!(t>0))return 1;const i=xa.degOver(e)/t;return i<1?1:Math.min(xa.MAX_INSTANTS,Math.max(2,Math.ceil(i)))}static MAX_INSTANTS=64}class Li{static EYE={apertureMm:7,exposureSeconds:.1,resolutionArcsec:60};static WAVELENGTH_M=55e-8;static ARCSEC_PER_RADIAN=180*3600/Math.PI;static UNKNOWN_CAMERA_FOCAL_MM=50;static UNKNOWN_CAMERA_DETAIL_UM=20;static get skyDriftArcsecPerSecond(){return xa.DEG_PER_SECOND*3600}static graspOf(e,t={}){const i=t.exposureSeconds??e.exposureSeconds,n=t.fNumber??e.fNumber;if(i===void 0||n===void 0||!(i>0)||!(n>0))return Li.EYE;const s=t.focalLengthMm??e.frame?.focalLengthMm??Li.UNKNOWN_CAMERA_FOCAL_MM,r=s/n,o=Li.resolutionArcsec(e,s,r);return{apertureMm:r,exposureSeconds:Math.min(i,Li.trailLimitedSeconds(o)),resolutionArcsec:o}}static resolutionArcsec(e,t,i){const s=(e.detailUm??Li.UNKNOWN_CAMERA_DETAIL_UM)/1e3/t*Li.ARCSEC_PER_RADIAN,r=1.22*Li.WAVELENGTH_M/(i/1e3)*Li.ARCSEC_PER_RADIAN;return Math.max(s,r)}static trailLimitedSeconds(e){return e/Li.skyDriftArcsecPerSecond}static gainOverEye(e,t={}){const i=Li.graspOf(e,t),n=Li.EYE,s=(i.apertureMm/n.apertureMm)**2,r=i.exposureSeconds/n.exposureSeconds,o=(n.resolutionArcsec/i.resolutionArcsec)**2;return 1.25*Math.log10(s*r*o)}static gainFor(e,t){const i=t.fieldOfViewDeg===void 0?void 0:ai.focalLengthMmFor(e,t.fieldOfViewDeg);return Li.gainOverEye(e,{fNumber:t.fNumber,focalLengthMm:i,exposureSeconds:t.exposureSeconds})}}const Rm=111320,Kr=Math.PI/180,eE=1.02,tE=1;class lo{static of(e,t){const i=lo.sightings(e,t);if(i.length<2)return;const n=lo.baseline(i);if(!n)return;const{near:s,far:r,closedM:o}=n,c=Math.tan(r.widthDeg/2*Kr)===0?0:Math.tan(s.widthDeg/2*Kr)/Math.tan(r.widthDeg/2*Kr);if(c<eE)return;const l=o/(c-1),h=Rt.sizeMAt(l,s.widthDeg),u=i.map(d=>({t:d.t,m:Rt.distanceMAt(h,d.widthDeg)}));return{widthM:h,distanceM:u,nearestM:Math.min(...u.map(d=>d.m)),fromT:r.t,toT:s.t,closedM:o}}static sightings(e,t){return e.timeline.allKeyframes.flatMap(i=>{const n=i.shapes.find(o=>o.sourceId===t)?.shape,s=n?.angular?.widthDeg,r=si(e,i.t);return s===void 0||s<=0||r?.lat===void 0||r.lng===void 0?[]:[{t:i.t,widthDeg:s,lat:r.lat,lng:r.lng,sightAzimuthDeg:n?.aim?.azimuthDeg??r.headingDeg}]}).sort((i,n)=>i.t-n.t)}static baseline(e){let t;for(const i of e)for(const n of e){if(i.t>=n.t)continue;const s=lo.closedAlongSight(i,n),[r,o,c]=s>=0?[n,i,s]:[i,n,-s];c<tE||r.widthDeg<=o.widthDeg||(!t||c>t.closedM)&&(t={near:r,far:o,closedM:c})}return t}static closedAlongSight(e,t){const i=(t.lat-e.lat)*Rm,n=(t.lng-e.lng)*Rm*Math.cos(e.lat*Kr),s=(e.sightAzimuthDeg??0)*Kr;return i*Math.cos(s)+n*Math.sin(s)}}class Pi{static CONVENTIONAL_M=5;static NEAREST_M=.2;static MARGIN=1.1;static resolve(e){if(e.statedM!==void 0&&e.statedM>0)return{distanceM:Pi.atLeastNearest(e.statedM),basis:"stated"};if(e.hypothesisM!==void 0&&e.hypothesisM>0)return{distanceM:Pi.atLeastNearest(e.hypothesisM),basis:"hypothesis"};if(e.derivedM!==void 0&&e.derivedM>0)return{distanceM:Pi.atLeastNearest(e.derivedM),basis:"derived"};const t=Pi.largest(e.range?.minM,e.crossing?.behindM),i=Pi.smallest(e.range?.maxM,e.crossing?.inFrontM),n=t===void 0?void 0:t*Pi.MARGIN,s=i===void 0?void 0:i/Pi.MARGIN;return n!==void 0&&s!==void 0?{distanceM:Pi.atLeastNearest(n<=s?Math.sqrt(n*s):n),basis:"bounded"}:n!==void 0?{distanceM:Pi.atLeastNearest(n),basis:"bounded"}:s!==void 0&&s<Pi.CONVENTIONAL_M?{distanceM:Pi.atLeastNearest(s),basis:"bounded"}:{distanceM:Pi.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(e){return Math.max(Pi.NEAREST_M,e)}static largest(...e){const t=e.filter(i=>i!==void 0&&i>0);return t.length===0?void 0:Math.max(...t)}static smallest(...e){const t=e.filter(i=>i!==void 0&&i>0);return t.length===0?void 0:Math.min(...t)}}const jh=Math.PI/180;class _t{constructor(e,t,i){this.body=e,this.ground=t,this.keys=this.place([...e.track].sort((n,s)=>n.t-s.t),i)}static EYE_HEIGHT_M=1.6;static MAX_RANGE_M=3e4;static DEFAULT_SIZE={widthM:1,lengthM:1,heightM:1};static DEFAULT_APPEARANCE={color:"#c8c8c8",albedo:.5,luminanceCdM2:0};keys;static eyeOf(e,t,i){const n=si(e,0),s=si(e,t);if(n?.lat===void 0||n.lng===void 0||s?.lat===void 0||s.lng===void 0)return;const r=ci(s.lat,s.lng,n.lat,n.lng),o=r.x,c=-r.z;return{eastM:o,northM:c,upM:i.heightAt(o,c)+_t.EYE_HEIGHT_M+s.elevationM,headingDeg:s.headingDeg}}static lineOfSightMeetsGround(e,t,i,n){const s=_t.directionOf(t,i),r=l=>e.upM+s.upM*l-n.heightAt(e.eastM+s.eastM*l,e.northM+s.northM*l);let o=0,c=0;for(;c<_t.MAX_RANGE_M;){if(c=o+Math.max(.5,o*.01),r(c)<=0){for(let l=0;l<30;l++){const h=(o+c)/2;r(h)<=0?c=h:o=h}return c}o=c}}static directionOf(e,t){const i=e*jh,n=t*jh;return{eastM:Math.sin(i)*Math.cos(n),northM:Math.cos(i)*Math.cos(n),upM:Math.sin(n)}}at(e){const t=this.keys;if(t.length===0||e<t[0].t)return;let i=t.length-1;for(;i>0&&t[i].t>e;)i--;const n=t[i];if(!n.present)return;const s=t[Math.min(i+1,t.length-1)],r=s===n||s.t===n.t?0:Math.min(1,(e-n.t)/(s.t-n.t)),o=_t.lerp(n.eastM,s.eastM,r),c=_t.lerp(n.northM,s.northM,r),l={widthM:_t.lerp(n.sizeM.widthM,s.sizeM.widthM,r),lengthM:_t.lerp(n.sizeM.lengthM,s.sizeM.lengthM,r),heightM:_t.lerp(n.sizeM.heightM,s.sizeM.heightM,r)},h={headingDeg:_t.lerpAngle(n.attitude.headingDeg,s.attitude.headingDeg,r),pitchDeg:_t.lerp(n.attitude.pitchDeg,s.attitude.pitchDeg,r),rollDeg:_t.lerp(n.attitude.rollDeg,s.attitude.rollDeg,r)};let u;if("aboveGroundM"in n.vertical&&"aboveGroundM"in s.vertical){const d=_t.lerp(n.vertical.aboveGroundM,s.vertical.aboveGroundM,r);u=this.groundUnderFootprint(o,c,l,h.headingDeg)+d+l.heightM/2}else u=_t.lerp(this.centreUpOf(n),this.centreUpOf(s),r);return{id:this.body.id,model:this.body.model,explains:this.body.explains??[],outlineNode:this.body.outlineNode,eastM:o,northM:c,upM:u,sizeM:l,attitude:h,appearance:{color:(r<1?n:s).appearance.color,albedo:_t.lerp(n.appearance.albedo,s.appearance.albedo,r),luminanceCdM2:_t.lerp(n.appearance.luminanceCdM2,s.appearance.luminanceCdM2,r)},flame:_t.flameBetween(n.flame,s.flame,r),throwsFlame:this.body.track.some(d=>d.flame!==void 0&&d.flame.luminanceCdM2>0)}}static flameBetween(e,t,i){if(!e||e.luminanceCdM2<=0)return i>=1&&t&&t.luminanceCdM2>0?t:void 0;const n=e,s=t??e,r={...i<1?n:s,lengthM:_t.lerp(n.lengthM,s.lengthM,i),widthM:_t.lerp(n.widthM,s.widthM,i),luminanceCdM2:_t.lerp(n.luminanceCdM2,s.luminanceCdM2,i)};return r.luminanceCdM2>0?r:void 0}centreUpOf(e){return"upM"in e.vertical?e.vertical.upM:this.groundUnderFootprint(e.eastM,e.northM,e.sizeM,e.attitude.headingDeg)+e.vertical.aboveGroundM+e.sizeM.heightM/2}groundUnderFootprint(e,t,i,n){const s=n*jh,r={eastM:Math.cos(s),northM:-Math.sin(s)},o={eastM:Math.sin(s),northM:Math.cos(s)};let c=this.ground.heightAt(e,t);for(const[l,h]of[[-1,-1],[1,-1],[-1,1],[1,1]]){const u=l*i.widthM/2,d=h*i.lengthM/2;c=Math.max(c,this.ground.heightAt(e+r.eastM*u+o.eastM*d,t+r.northM*u+o.northM*d))}return c}place(e,t){const i=[];let n;for(const s of e){const r=s.sizeM??n?.sizeM??_t.DEFAULT_SIZE,o={headingDeg:s.attitude?.headingDeg??n?.attitude.headingDeg??0,pitchDeg:s.attitude?.pitchDeg??n?.attitude.pitchDeg??0,rollDeg:s.attitude?.rollDeg??n?.attitude.rollDeg??0},c={color:s.appearance?.color??n?.appearance.color??_t.DEFAULT_APPEARANCE.color,albedo:s.appearance?.albedo??n?.appearance.albedo??_t.DEFAULT_APPEARANCE.albedo,luminanceCdM2:s.appearance?.luminanceCdM2??n?.appearance.luminanceCdM2??_t.DEFAULT_APPEARANCE.luminanceCdM2},l=this.positionOf(s,t)??(n&&{eastM:n.eastM,northM:n.northM,vertical:this.verticalOf(s)??n.vertical});if(!l)continue;const h=s.flame??n?.flame,u=s.present??n?.present??!0;n={t:s.t,...l,sizeM:r,attitude:o,appearance:c,flame:h,present:u},i.push(n)}return i}verticalOf(e){if(e.onGround)return{aboveGroundM:0};if(e.altitudeAboveGroundM!==void 0)return{aboveGroundM:e.altitudeAboveGroundM}}positionOf(e,t){if(e.eastM!==void 0&&e.northM!==void 0)return{eastM:e.eastM,northM:e.northM,vertical:this.verticalOf(e)??{aboveGroundM:0}};if(e.azimuthDeg===void 0||e.altitudeDeg===void 0)return;const i=t(e.t);if(!i)return;const n=e.distanceM??(e.onGround?_t.lineOfSightMeetsGround(i,e.azimuthDeg,e.altitudeDeg,this.ground):void 0);if(n===void 0)return;const s=_t.directionOf(e.azimuthDeg,e.altitudeDeg),r=i.eastM+s.eastM*n,o=i.northM+s.northM*n;return{eastM:r,northM:o,vertical:this.verticalOf(e)??{upM:i.upM+s.upM*n}}}static lerp(e,t,i){return e+(t-e)*i}static lerpAngle(e,t,i){const n=((t-e)%360+540)%360-180;return((e+n*i)%360+360)%360}}const ja=Math.PI/180,$r=180/Math.PI;class Wt{constructor(e){this.timeline=e}static DIRECTION_TOLERANCE_DEG=1;static SIZE_TOLERANCE=1.5;static RINGS=12;static SEGMENTS=24;at(e,t,i,n){const s=[];for(const r of t){const o=Wt.projectionOf(r,i,n?.(r));if(o)for(const c of r.explains){const l=this.timeline.getInterpolatedShapeAt(e,c);!l||l.transparency>=1||s.push({...Wt.compare(c,r.id,{aim:l.aim,angular:l.angular},o),title:l.title})}}return s}static compare(e,t,i,n){const s=[],r=i.aim?Wt.separationDeg(i.aim,n.aim):void 0;if(r!==void 0){const l=Math.max(i.angular?.widthDeg??0,n.angular.widthDeg)/2;r>Math.max(Wt.DIRECTION_TOLERANCE_DEG,l)&&s.push("direction")}const o=i.angular&&i.angular.widthDeg>0?n.angular.widthDeg/i.angular.widthDeg:void 0,c=i.angular&&i.angular.heightDeg>0?n.angular.heightDeg/i.angular.heightDeg:void 0;return o!==void 0&&!Wt.withinSize(o)&&s.push("width"),c!==void 0&&!Wt.withinSize(c)&&s.push("height"),{sourceId:e,bodyId:t,stated:i,predicted:n,separationDeg:r,widthRatio:o,heightRatio:c,disagreements:s}}static projectionOf(e,t,i){const n=i&&i.length>0?i:Wt.outlineOf(e),s=i&&i.length>0?Wt.centreOf(i):e,r=Wt.normalized({eastM:s.eastM-t.eastM,northM:s.northM-t.northM,upM:s.upM-t.upM});if(!r)return;const o=Wt.normalized({eastM:r.northM,northM:-r.eastM,upM:0})??{eastM:1,northM:0,upM:0},c=Wt.cross(o,r);let l=1/0,h=-1/0,u=1/0,d=-1/0;for(const f of n){const p={eastM:f.eastM-t.eastM,northM:f.northM-t.northM,upM:f.upM-t.upM},v=Wt.dot(p,r);if(v<=0)return;const m=Math.atan2(Wt.dot(p,o),v),g=Math.atan2(Wt.dot(p,c),v);l=Math.min(l,m),h=Math.max(h,m),u=Math.min(u,g),d=Math.max(d,g)}return{aim:{azimuthDeg:(Math.atan2(r.eastM,r.northM)*$r+360)%360,altitudeDeg:Math.asin(Math.max(-1,Math.min(1,r.upM)))*$r},angular:{widthDeg:(h-l)*$r,heightDeg:(d-u)*$r}}}static centreOf(e){const t=i=>(Math.min(...e.map(n=>n[i]))+Math.max(...e.map(n=>n[i])))/2;return{eastM:t("eastM"),northM:t("northM"),upM:t("upM")}}static separationDeg(e,t){const i=e.altitudeDeg*ja,n=t.altitudeDeg*ja,s=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((e.azimuthDeg-t.azimuthDeg)*ja);return Math.acos(Math.max(-1,Math.min(1,s)))*$r}static withinSize(e){return e<=Wt.SIZE_TOLERANCE&&e>=1/Wt.SIZE_TOLERANCE}static outlineOf(e){const t=e.sizeM.widthM/2,i=e.sizeM.lengthM/2,n=e.sizeM.heightM/2,s=[],r=e.model.url===void 0?e.model.id:void 0;if(r!==void 0&&r!=="box"&&p1.includes(r))for(let u=0;u<=Wt.RINGS;u++){const d=u/Wt.RINGS*Math.PI;for(let f=0;f<Wt.SEGMENTS;f++){const p=f/Wt.SEGMENTS*2*Math.PI;s.push([t*Math.sin(d)*Math.cos(p),i*Math.sin(d)*Math.sin(p),n*Math.cos(d)])}}else for(const u of[-t,t])for(const d of[-i,i])for(const f of[-n,n])s.push([u,d,f]);const c=e.attitude.headingDeg*ja,l=e.attitude.pitchDeg*ja,h=e.attitude.rollDeg*ja;return s.map(([u,d,f])=>{const p=u*Math.cos(h)+f*Math.sin(h),v=-u*Math.sin(h)+f*Math.cos(h),m=d*Math.cos(l)-v*Math.sin(l),g=d*Math.sin(l)+v*Math.cos(l);return{eastM:e.eastM+p*Math.cos(c)+m*Math.sin(c),northM:e.northM-p*Math.sin(c)+m*Math.cos(c),upM:e.upM+g}})}static dot(e,t){return e.eastM*t.eastM+e.northM*t.northM+e.upM*t.upM}static cross(e,t){return{eastM:e.northM*t.upM-e.upM*t.northM,northM:e.upM*t.eastM-e.eastM*t.upM,upM:e.eastM*t.northM-e.northM*t.eastM}}static normalized(e){const t=Math.hypot(e.eastM,e.northM,e.upM);return t>1e-9?{eastM:e.eastM/t,northM:e.northM/t,upM:e.upM/t}:void 0}}Km();const iE={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"}},nE=["en","fr"],sE={en:"{name} — mag {mag}, {alt}° above the horizon",fr:"{name} — mag {mag}, {alt}° au-dessus de l'horizon"},aE={en:"{name} — satellite, mag {mag}, {height} km up",fr:"{name} — satellite, mag {mag}, à {height} km d'altitude"},rE="satellites-change",oE="rr0-confrontation",cE={en:"{name} — mag {mag}, {alt}° below the horizontal",fr:"{name} — mag {mag}, {alt}° sous l'horizontale"},Dm="comet:",Cm="nova:",lE={building:{en:"Building",fr:"Bâtiment"},tree:{en:"Tree",fr:"Arbre"},shrub:{en:"Shrub",fr:"Buisson"},crop:{en:"Crop row",fr:"Rang de culture"},mound:{en:"Stone heap",fr:"Tas de pierres"},streetlight:{en:"Streetlight",fr:"Lampadaire"},vehicle:{en:"Vehicle",fr:"Véhicule"},witness:{en:"Witness",fr:"Témoin"},aircraft:{en:"Aircraft",fr:"Aéronef"},entity:{en:"Being",fr:"Être"}},hE=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,uE=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,dE=-18,fE={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},Qh={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class p0 extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","deep-star-catalog-src","show-compass","max-pixel-ratio",ar,rr]}shadow;stageElement;frameElement;sceneCanvas;ufoElement;sceneRenderer;hoverTooltip;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;distanceHypotheses=new Map;depths=new Map;directionScratch=new D;meteorScheduleFor;lightningScheduleFor;lightningFlashes=[];lastLightningT;lastTimeMs=0;interpretationShown;confrontationReadings=[];confrontationSignature="";comparing=!1;inTheRound=!0;lastSkyKey;starCatalog;starCatalogRequest=0;static tleArchive=new Ei;satellitesFor;satelliteRequest=0;satelliteStatus="none";satellites;satellitePassesMemo;starCatalogDepth=0;weatherAudio=new Zb;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,i=t.getBoundingClientRect();if(i.width===0||i.height===0)return;const n=(e.clientX-i.left)/i.width*t.width,s=(e.clientY-i.top)/i.height*t.height;if(this.ufoElement.hasVisibleShapeAt(n,s)){this.hoverTooltip.hidden=!0;return}const r=(e.clientX-i.left)/i.width*2-1,o=-((e.clientY-i.top)/i.height*2-1),c=Td(Kc.preferencesFor(this),nE),l=this.sceneRenderer.pickBodyAt(r,o);if(l){this.showHoverTooltip(e,this.bodyName(l,c));return}const h=this.sceneRenderer.pickDecorAt(r,o),u=h?this.ufoElement.sighting.decor.find(p=>p.id===h):void 0;if(u){this.showHoverTooltip(e,this.said.read(u.title)||lE[u.kind][c]);return}const d=this.sceneRenderer.pickSatelliteAt(r,o);if(d){this.showHoverTooltip(e,aE[c].replace("{name}",d.name).replace("{mag}",d.magnitude.toLocaleString(void 0,{maximumFractionDigits:1})).replace("{height}",Math.round(d.heightKm).toLocaleString()));return}const f=this.sceneRenderer.pickStarAt(r,o);if(f){const p=f.star.mag,v=f.altitudeDeg,m=(v<0?cE:sE)[c];this.showHoverTooltip(e,m.replace("{name}",f.star.name[c]).replace("{mag}",p.toLocaleString(void 0,{maximumFractionDigits:Math.abs(p)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(v)))));return}this.hoverTooltip.hidden=!0};bodyName(e,t){const i=e.startsWith(Dm)?e.slice(Dm.length):void 0,n=i?v1.find(r=>r.id===i):void 0,s=e.startsWith(Cm)?Am.byId(e.slice(Cm.length)):void 0;return n?.name[t]??s?.name[t]??iE[e]?.[t]??e}showHoverTooltip(e,t){this.hoverTooltip.textContent=t,this.hoverTooltip.hidden=!1;const i=this.stageElement.getBoundingClientRect();this.hoverTooltip.style.left=`${e.clientX-i.left+12}px`,this.hoverTooltip.style.top=`${e.clientY-i.top+12}px`}handlePointerLeave=()=>{this.hoverTooltip.hidden=!0,this.sceneRenderer.setCompassHovered(!1)};handleLightningFlash(e){clearTimeout(this.thunderTimeoutId),this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),ri.thunderDelayMs(e))}handleFirstInteraction=()=>{this.removeEventListener("pointerdown",this.handleFirstInteraction,!0),this.removeEventListener("keydown",this.handleFirstInteraction,!0),this.weatherAudio.resume(),this.setWeather(Js(this.ufoElement.sighting,this.lastTimeMs))};handleTimeUpdate=e=>{this.lastTimeMs=e.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.playbackState==="playing"&&this.sceneRenderer.frame(performance.now())};syncAnimationsToPlayback(){const e=this.ufoElement.playbackState==="playing",t=e||this.animateWhilePaused;this.sceneRenderer.setAnimationsRunning(t,e),this.weatherAudio.setPaused(!t),t||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${R1}</style>${T1}`,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 Vt(this.sceneCanvas);const t=this.shadow.getElementById("scene-loader");this.sceneRenderer.onFirstFrameHold=i=>{t.hidden=!i},this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(iu),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.paintsShapes=!1,this.forwardPlayerAttributes(),this.ufoElement.addEventListener("lookat",i=>this.lookToward(i.detail)),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.sceneRenderer.onMapSubjectBounds=i=>this.ufoElement.setMapSubjectBounds(i),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.addEventListener("referenceview",i=>this.applyReferenceView(i.detail)),this.ufoElement.canvasElement.addEventListener("pointermove",this.handlePointerMove),this.ufoElement.canvasElement.addEventListener("pointerleave",this.handlePointerLeave),this.addEventListener("pointerdown",this.handleFirstInteraction,!0),this.addEventListener("keydown",this.handleFirstInteraction,!0)}get said(){return this.saidTexts??=new ks(Kc.preferencesFor(this))}saidTexts;connectedCallback(){this.saidTexts=void 0,this.sceneRenderer.restoreContext(),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(),queueMicrotask(()=>{this.isConnected||this.sceneRenderer.releaseContext()})}attributeChangedCallback(e,t,i){if(e==="src"&&i&&i!==t&&this.isConnected&&this.loadFromSrc(i),(e==="star-catalog-src"||e==="deep-star-catalog-src")&&i!==t&&this.isConnected&&this.loadStars(),e==="show-compass"&&i!==t&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),e==="max-pixel-ratio"&&i!==t){const n=Number(i);this.sceneRenderer.setMaxPixelRatio(Number.isFinite(n)&&n>0?n:Math.min(window.devicePixelRatio||1,2))}(e===ar||e===rr)&&i!==t&&this.forwardPlayerAttributes()}forwardPlayerAttributes(){for(const e of[ar,rr])this.ufoElement.toggleAttribute(e,this.hasAttribute(e))}setCompassForced(e){this.sceneRenderer.setCompassForced(e)}lookToward(e){const t=si(this.ufoElement.sighting,this.lastTimeMs);if(e.kind==="witness"||t?.lat===void 0||t.lng===void 0||t.headingDeg===void 0){this.setLookOffset(0,0);return}const{x:i,z:n}=ci(e.lat,e.lng,t.lat,t.lng);if(Math.hypot(i,n)<1)return this.setLookOffset(0,0);const s=(Math.atan2(i,-n)*180/Math.PI+360)%360;this.setLookOffset(((s-t.headingDeg)%360+540)%360-180,-t.pitchDeg)}setLookOffset(e,t){this.sceneRenderer.setLookOffset(e,t),this.ufoElement.setLookOffset(e,t),this.updateAstronomy(this.lastTimeMs)}setIndoorLook(e,t){this.sceneRenderer.setIndoorLook(e,t)}setCloudRendering(e){this.sceneRenderer.setCloudRendering(e)}setWeather(e){this.sceneRenderer.setWeather(e),this.weatherAudio.setAmbient(e.precipitationType,e.precipitationIntensity,e.windSpeed)}pickCloudAt(e,t){return this.sceneRenderer.pickCloudAt(e,t)}cloudDirectionAt(e,t){return this.sceneRenderer.cloudDirectionAt(e,t)}pickDecorAt(e,t){return this.sceneRenderer.pickDecorAt(e,t)}resumeWeatherAudio(){this.weatherAudio.resume()}async loadFromSrc(e){this.sightingData=await Nm.json(e)}get sightingData(){return this.ufoElement.sightingData}set sightingData(e){this.ufoElement.sightingData=e,this.interpretationShown=this.inTheRound?this.ufoElement.sighting.interpretation:void 0,this.applyFrameFormat(),this.lastTimeMs=0,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(0)}referenceAspect(e){return this.sceneRenderer.referenceAspect(e)}screenPointOf(e){return this.sceneRenderer.screenPointOf(e)}directionAt(e,t){return this.sceneRenderer.directionAt(e,t)}referenceFailedToLoad(e){return this.sceneRenderer.referenceFailedToLoad(e)}applyReferenceView(e){this.sceneRenderer.setReferencesShown(e.shown);for(const t of this.ufoElement.sighting.references)this.sceneRenderer.setReferenceView(t.id,{opacity:e.opacity})}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}get currentRoadAttribution(){return this.sceneRenderer.currentRoadAttribution}setTerrainProviders(e){this.sceneRenderer.setTerrainProviders(e)}setDecorModelProvider(e){this.sceneRenderer.setDecorModelProvider(e)}get decorModelCredits(){return this.sceneRenderer.currentDecorModelCredits}applyFrameFormat(){const e=this.ufoElement.sighting.instrument,t=Rt.CANVAS_HEIGHT_PX,i=ai.frameWidthPx(e,t);this.frameElement.style.setProperty("--frame-aspect",`${i} / ${t}`)}resizeToStage(){const e=this.frameElement.getBoundingClientRect(),t=Math.max(1,Math.round(e.width)),i=Math.max(1,Math.round(e.height));this.sceneCanvas.width=t,this.sceneCanvas.height=i,this.sceneRenderer.resize(t,i)}async loadStars(){const e=[{magnitudeLimit:Kh,url:this.getAttribute("star-catalog-src")??hE},{magnitudeLimit:$h,url:this.getAttribute("deep-star-catalog-src")??uE}],t=this.instrumentReach(),i=++this.starCatalogRequest;this.starCatalogDepth=t>Kh?$h:Kh;const n=await Hn.upTo(e,t);i===this.starCatalogRequest&&(this.starCatalog=n,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=$h||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const e=this.ufoElement.sighting,t=Li.gainFor(e.instrument,{fNumber:si(e,0)?.fNumber,fieldOfViewDeg:Wi.fovOf(e,0),exposureSeconds:e.exposure});return Gc(dE,t)}updateAstronomy(e){this.ensureStarsDeepEnough(),this.applySceneAt(e);const t=bn.windowEndingAt(e,this.exposureSeconds()),i=t.seconds,n=this.degreesPerPixelAt(e),s=xa.instants(i,n),r=Math.max(s,this.ufoElement.exposureTimes(e).length,bn.instants(this.ufoElement.sighting.decor,si(this.ufoElement.sighting,e)?.elevationM??0,t.fromMs,i,n));if(r<=1){this.sceneRenderer.setExposure(1);return}this.sceneRenderer.setExposure(r,o=>this.applySceneAt(t.fromMs+t.ms*o/(r-1),{sky:Math.floor(o*s/r)!==Math.floor((o-1)*s/r),stepMs:t.ms/r}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(e){const t=this.sceneCanvas.height;return t<=0?0:Wi.fovOf(this.ufoElement.sighting,e)/t}applySceneAt(e,t){const i=this.ufoElement.sighting;this.setWeather(Js(i,e)),this.sceneRenderer.setInstrument(i.instrument),this.updateMeteorShower(i,e),this.updateLightning(i,e,t!==void 0),this.sceneRenderer.setDecor(i.decor),this.sceneRenderer.setReferences(i.references);const n=si(i,e),s=si(i,0),r=Js(i,0),o=Object.fromEntries(Xc(Js(i,e)).map(w=>[w.id,E0(e,i.weatherTrack,r,s,n,w.id)]));this.sceneRenderer.setCloudOffset(E0(e,i.weatherTrack,r,s,n),o),this.sceneRenderer.setObserverPose(n??Qh),this.sceneRenderer.setLensOptics(this.lensOpticsAt(e)),this.sceneRenderer.setInstrumentGain(Li.gainFor(i.instrument,{fNumber:n?.fNumber,fieldOfViewDeg:Wi.fovOf(i,e),exposureSeconds:i.exposure}),i.instrument.detailUm!==void 0),this.sceneRenderer.setGait(ni.of(i)?.offsetAt(e)??ni.STILL),this.sceneRenderer.updateDecorAnchoring(si(i,0),n,e),this.placeBodiesAt(e,t===void 0),this.sceneRenderer.updateDecorLitState(e,t?.stepMs??0),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng,()=>{this.placeBodiesAt(this.lastTimeMs,!0),this.sceneRenderer.render()}),this.sceneRenderer.setStatedRoads(i.roads),this.pushPhenomenaAt(e);const c=n?.lat??Qh.lat,l=n?.lng??Qh.lng,h=yc(i.event.time??{},l,i.event.utcOffsetHours),u={lat:c,lng:l,elevationM:n?.elevationM??0};if(this.pushSatellitesAt(h,e,u),t&&!t.sky)return;if(!h){this.sceneRenderer.setAstronomy(fE);return}const d=new Date(h.getTime()+e),f=Math.max(1,Math.round(.25*this.degreesPerPixelAt(e)/xa.DEG_PER_SECOND*1e3)),p=Math.max(1e-8,this.degreesPerPixelAt(e)*.1),v=`${Math.floor(d.getTime()/f)}|${Math.round(c/p)}|${Math.round(l/p)}|${Math.round(u.elevationM)}|${this.starCatalog?this.starCatalogDepth:0}`;if(v===this.lastSkyKey){this.sceneRenderer.render();return}this.lastSkyKey=v;const m={...Ah("Sun",d,u),magnitude:Th("Sun",d)},g={...Ah("Moon",d,u),phase:tw(d),magnitude:Th("Moon",d)},_=ew.map(w=>({body:w,position:Ah(w,d,u),magnitude:Th(w,d)}));this.sceneRenderer.setAstronomy({sun:m,moon:g,planets:_,comet:this.cometAt(d,u),novae:Am.appearancesAt(d,u).map(({outburst:w,position:M,magnitude:S})=>({id:w.id,position:M,magnitude:S})),stars:this.starCatalog?{catalog:this.starCatalog,date:d,observer:u}:void 0,frame:{date:d,observer:u}}),this.ufoElement.setSunAltitude(m.altitudeDeg)}pushSatellitesAt(e,t,i){if(this.ensureSatellites(e),!e||!this.satellites){this.sceneRenderer.setSatellites([]);return}const n=new Date(e.getTime()+t),s=[];for(const r of this.satellites.passes.positionsAt(n,i,-1))r.magnitude!==void 0&&s.push({norad:r.object.norad,name:r.object.name,position:{altitudeDeg:r.altitudeDeg,azimuthDeg:r.azimuthDeg},magnitude:r.magnitude,heightKm:r.heightKm});this.sceneRenderer.setSatellites(s)}ensureSatellites(e){const t=e?String(e.getTime()):"";if(t===this.satellitesFor)return;this.satellitesFor=t,this.satellites=void 0,this.satellitePassesMemo=void 0;const i=++this.satelliteRequest;if(!e){this.satelliteStatus="none";return}this.satelliteStatus="loading";const n=r=>{i===this.satelliteRequest&&(this.satelliteStatus=r,this.dispatchEvent(new CustomEvent(rE)))},s=p0.tleArchive;(async()=>{if(!await s.covers(e))return n("outside");const[r,o]=await Promise.all([s.at(e),Wc(()=>import("./SatellitePasses-Pfro2-0Z.js"),[],import.meta.url)]);if(i===this.satelliteRequest){if(!r)return n("unavailable");this.satellites={snapshot:r,passes:new o.SatellitePasses(r.objects)},n("ready"),this.updateAstronomy(this.lastTimeMs)}})().catch(()=>n("unavailable"))}get satelliteState(){const e=this.satellites?.snapshot;return{status:this.satelliteStatus,coverage:e?.coverage,credit:e?.credit,creditUrl:e?.creditUrl}}satellitePassesDuring(e){const t=this.satellites,i=this.ufoElement.sighting,n=si(i,0),s=i.event.place?.[0],r=n?.lat??s?.lat,o=n?.lng??s?.lng;if(!t||r===void 0||o===void 0)return[];const c=yc(i.event.time??{},o,i.event.utcOffsetHours);if(!c)return[];const l=Math.min(Math.max(e,0),4*36e5),h={lat:r,lng:o,elevationM:n?.elevationM??0},u=JSON.stringify([this.satellitesFor,c.getTime(),r,o,h.elevationM,l]);if(this.satellitePassesMemo?.key===u)return this.satellitePassesMemo.passes;const d=Math.max(10,Math.ceil(l/1e3/600)),f=t.passes.passesDuring(c,new Date(c.getTime()+l),h,d);return this.satellitePassesMemo={key:u,passes:f},f}cometAt(e,t){const i=Jb.brightestAt(e,t);if(i)return{id:i.apparition.id,position:i.position,tailEnd:i.tailEnd,magnitude:i.magnitude}}pushPhenomenaAt(e){const t=this.ufoElement.sighting;t!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.distanceHypotheses.clear(),this.sizeEstimatesFor=t);const i=t.timeline,n=this.ufoElement.canvasElement,s=this.ufoElement.frameShiftPx,r=this.projectionAt(e),o=new Map,c=new Map,l=new Set;for(const p of i.sourceIds){const v=i.getInterpolatedShapeAt(e,p);if(!v)continue;const m={...v,bounds:{...v.bounds,x:v.bounds.x+s.x,y:v.bounds.y+s.y}};o.set(p,m);const g=v.aim?this.sceneRenderer.screenPointOf(wn.directionOf(v.aim,this.directionScratch)):{ndcX:(m.bounds.x+m.bounds.width/2)/n.width*2-1,ndcY:-((m.bounds.y+m.bounds.height/2)/n.height*2-1)},_=g!==void 0&&Math.abs(g.ndcX)<=1&&Math.abs(g.ndcY)<=1,w=_?this.sceneRenderer.decorDistancesAt(g.ndcX,g.ndcY,p):{};l.add(p),(_||v.aim)&&l.delete(p);const M=v.angular?.widthDeg??r.pxToDeg(v.bounds.width),S=this.sizeEstimateOf(p);S.add(M,w);const b=lo.of(t,p);c.set(p,Pi.resolve({hypothesisM:this.distanceHypotheses.get(p),derivedM:b&&M>0?Rt.distanceMAt(b.widthM,M):void 0,range:S.distanceRangeAt(M),crossing:w}))}for(const[p,v]of o)for(const[m,g]of o){if(m===p||g.transparency>=1||g.bounds.width*g.bounds.height<=v.bounds.width*v.bounds.height||!(v.bounds.x>=g.bounds.x&&v.bounds.y>=g.bounds.y&&v.bounds.x+v.bounds.width<=g.bounds.x+g.bounds.width&&v.bounds.y+v.bounds.height<=g.bounds.y+g.bounds.height))continue;const w=c.get(m);w&&c.set(p,{distanceM:w.distanceM*.999,basis:w.basis});break}this.depths=c;const h=i.sourceIds,u=[];for(const[p,v]of o)u.push({sourceId:p,shape:v,distanceM:c.get(p).distanceM,renderOrder:h.indexOf(p),aim:v.aim,hidden:l.has(p)||this.interpretationShown!==void 0&&!this.comparing,ghost:this.interpretationShown!==void 0&&this.comparing});const f=(si(t,e)?.rollDeg??0)+(ni.of(t)?.offsetAt(e)??ni.STILL).rollDeg;this.sceneRenderer.setPhenomena(u,{projection:r,canvasWidthPx:n.width,canvasHeightPx:n.height,scale:Math.max(1,this.sceneCanvas.height/Math.max(1,n.height)),starPoints:ai.starPointsOf(t.instrument),rollRad:f*Math.PI/180})}get interpretation(){return this.interpretationShown}set interpretation(e){this.interpretationShown=e,this.updateAstronomy(this.lastTimeMs)}get testimonyInTheRound(){return this.inTheRound}set testimonyInTheRound(e){this.inTheRound=e}get compareTestimony(){return this.comparing}set compareTestimony(e){this.comparing=e,this.updateAstronomy(this.lastTimeMs)}get confrontation(){return this.confrontationReadings}placeBodiesAt(e,t){const i=this.interpretationShown,n=this.ufoElement.sighting;let s=[],r=[];const o=this.sceneRenderer.bodyGround,c=p=>_t.eyeOf(n,p,o);i&&(s=i.bodies.map(p=>new _t(p,o,c).at(e)).filter(p=>p!==void 0));const l=Js(n,e),h=l.windDirectionDeg*Math.PI/180,u={x:l.windSpeed*Math.sin(h),z:-l.windSpeed*Math.cos(h)};this.sceneRenderer.setBodies(s,e/1e3,i?.bodies.map(p=>p.id)??[],i?.smoke??[],u);const d=i&&this.comparing?c(e):void 0;if(d&&(r=new Wt(n.timeline).at(e,s,d,p=>p.outlineNode?this.sceneRenderer.bodyOutline?.(p.id,p.outlineNode):void 0)),this.confrontationReadings=r,!t)return;const f=JSON.stringify(r);f!==this.confrontationSignature&&(this.confrontationSignature=f,this.dispatchEvent(new CustomEvent(oE,{detail:r})))}setDistanceHypothesis(e,t){t===void 0||!(t>0)?this.distanceHypotheses.delete(e):this.distanceHypotheses.set(e,t),this.updateAstronomy(this.lastTimeMs)}depthOf(e){return this.depths.get(e)}sizeRangeOf(e){return this.sizeEstimateOf(e).sizeRange}distanceRangeAt(e,t){const i=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(t,e);if(!i)return{};const n=i.angular?.widthDeg??this.projectionAt(t).pxToDeg(i.bounds.width);return this.sizeEstimateOf(e).distanceRangeAt(n)}sizeContradictory(e){return this.sizeEstimateOf(e).contradictory}updateMeteorShower(e,t){this.ensureMeteorSchedule(e),this.sceneRenderer.updateMeteors(t)}updateLightning(e,t,i){if(this.ensureLightningSchedule(e),this.sceneRenderer.updateLightning(t),i)return;const n=this.lastLightningT;if(this.lastLightningT=t,n===void 0||t<n||this.ufoElement.playbackState!=="playing")return;const s=this.lightningFlashes.filter(r=>r.t>n&&r.t<=t).pop();s&&Js(e,s.t).storm&&this.handleLightningFlash(s)}ensureLightningSchedule(e){const t=Js(e,0).precipitationIntensity,i=`${this.meteorInputsOf(e)}|${t}`;if(i===this.lightningScheduleFor)return;this.lightningScheduleFor=i;const n=e.event.time,s=e.event.place?.[0],r=n?.year!==void 0?yc(n,s?.lng??0,e.event.utcOffsetHours):void 0,o=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,c=Math.round((r?.getTime()??0)/1e3)+Math.round((s?.lat??0)*1e3)+7;this.lightningFlashes=ri.schedule({durationMs:o,seed:c,intensity:t}),this.sceneRenderer.setLightning(this.lightningFlashes)}ensureMeteorSchedule(e){const t=this.meteorInputsOf(e);t!==this.meteorScheduleFor&&(this.meteorScheduleFor=t,this.scheduleMeteors(e))}meteorInputsOf(e){const t=e.event.place?.[0],i=e.event.time;return JSON.stringify([t?.lat,t?.lng,i?.year,i?.month,i?.day,i?.hour,i?.minute,i?.second,e.event.utcOffsetHours,e.event.durationSeconds,e.timeline.duration])}scheduleMeteors(e){const t=e.event.place?.[0],i=e.event.time,n=t?.lat!==void 0&&t.lng!==void 0&&i?.year!==void 0?yc(i,t.lng,e.event.utcOffsetHours):void 0;if(!n||t?.lat===void 0||t.lng===void 0){this.sceneRenderer.setMeteorShower([],0,0);return}const s={lat:t.lat,lng:t.lng,elevationM:0},r=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,o=Math.round(n.getTime()/1e3)+Math.round(t.lat*1e3),c=Xt.schedule({ratePerHour:Xt.observedRatePerHour(Xt.apexPosition(n,s).altitudeDeg),durationMs:r,velocityKmS:Xt.TYPICAL_VELOCITY_KM_S,seed:o}),l=Jh.activeAt(n).map(u=>{const d=Jh.radiantPosition(u.shower,n,s);return{entry:u,position:d,rate:Jh.observedRatePerHour(u.zhr,d.altitudeDeg,u.shower.populationIndex)}}).sort((u,d)=>d.rate-u.rate)[0];if(!l||l.rate<=0){this.sceneRenderer.setMeteorShower(c,0,0);return}const h=va.schedule({ratePerHour:l.rate,durationMs:r,velocityKmS:l.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...c],l.position.altitudeDeg,l.position.azimuthDeg)}meteorByRank(e){this.ensureMeteorSchedule(this.ufoElement.sighting);const t=[...this.sceneRenderer.meteorSchedule].filter(s=>s.t+s.durationMs<=this.ufoElement.seekableDuration).sort((s,r)=>r.brightness-s.brightness);if(t.length===0)return;const i=t[e%t.length],n=this.sceneRenderer.meteorMidpoint(i);if(n)return{t:Math.round(i.t+i.durationMs*.45),...n}}lensOpticsAt(e){const t=this.ufoElement.sighting,i=t.instrument,n=i.frame,s=si(t,e),r=s?.fNumber??i.fNumber;if(!n||r===void 0)return;const o=ai.focalLengthMmFor(i,Wi.fovOf(t,e));if(o!==void 0)return{focalLengthMm:o,fNumber:r,focusDistance:s?.focusDistanceM??0,frameHeightMm:n.heightMm}}projectionAt(e){const t=this.ufoElement.sighting;return ps.of(t.instrument,Rt.CANVAS_HEIGHT_PX,Wi.fovOf(t,e))}sizeEstimateOf(e){let t=this.sizeEstimates.get(e);return t||(t=new Qb,this.sizeEstimates.set(e,t)),t}}const Im="rr0-scene";function pE(){Km(),customElements.get(Im)||customElements.define(Im,p0)}pE();export{jv as $,xE as A,et as B,se as C,Gf as D,De as E,bE as F,_E as G,gg as H,yE as I,SE as J,us as K,Ro as L,hM as M,ko as N,Pt as O,Eg as P,Qn as Q,Mo as R,Fi as S,mE as T,Dt as U,xe as V,Vi as W,ME as X,Cn as Y,mg as Z,wE as _,vE as a,Jc as a0,Gu as a1,nl as a2,Mi as a3,wg as a4,Yd as a5,Kd as a6,it as a7,qs as a8,To as a9,vn as aa,ys as ab,gE as b,TE as c,Qc as d,AE as e,Ze as f,D as g,Af as h,EE as i,RE as j,Kv as k,da as l,kl as m,Q2 as n,st as o,wt as p,uu as q,xi as r,vg as s,_s as t,sM as u,oa as v,tn as w,mn as x,St as y,ut as z};
|
|
7011
|
+
`;function Em(a){const t=document.createElement("canvas");t.width=128,t.height=128;const i=t.getContext("2d"),n=128/2-2,s=128/2,r=128/2,o="#010101",c="#f4f1e2";i.fillStyle=o,i.beginPath(),i.arc(s,r,n,0,Math.PI*2),i.fill();const l=sr(a.illuminatedFraction,0,1),h=a.phaseFraction<.5,u=n*Math.abs(1-2*l),d=l<.5;return i.save(),i.beginPath(),i.arc(s,r,n,0,Math.PI*2),i.clip(),i.fillStyle=c,i.beginPath(),h?(i.arc(s,r,n,-Math.PI/2,Math.PI/2,!1),i.ellipse(s,r,u,n,0,Math.PI/2,-Math.PI/2,d)):(i.arc(s,r,n,Math.PI/2,-Math.PI/2,!1),i.ellipse(s,r,u,n,0,-Math.PI/2,Math.PI/2,d)),i.fill(),i.restore(),new Ss(t)}function Xb(a){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(a,64,68),new Ss(e)}function Yh(a){let e=a;return function(){e|=0,e=e+1831565813|0;let i=Math.imul(e^e>>>15,1|e);return i=i+Math.imul(i^i>>>7,61|i)^i,((i^i>>>14)>>>0)/4294967296}}const Kh=7.5,$h=9;class Hn{static cache=new Map;static load(e){let t=Hn.cache.get(e);return t||(t=fetch(e).then(i=>i.arrayBuffer()).then(i=>Hn.parse(i)),Hn.cache.set(e,t)),t}static upTo(e,t){const i=e.filter((r,o)=>o===0||e[o-1].magnitudeLimit<t);if(i.length<=1)return Hn.load(e[0].url);const n=i.map(r=>r.url).join(`
|
|
7012
|
+
`);let s=Hn.cache.get(n);return s||(s=Promise.all(i.map(r=>Hn.load(r.url))).then(r=>r.reduce((o,c)=>Hn.concat(o,c))),Hn.cache.set(n,s)),s}static parse(e){const t=e.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),i=t*Float32Array.BYTES_PER_ELEMENT;return{count:t,ra:new Float32Array(e,0*i,t),dec:new Float32Array(e,1*i,t),mag:new Float32Array(e,2*i,t),ci:new Float32Array(e,3*i,t)}}static concat(e,t){const i=(n,s)=>{const r=new Float32Array(n.length+s.length);return r.set(n,0),r.set(s,n.length),r};return{count:e.count+t.count,ra:i(e.ra,t.ra),dec:i(e.dec,t.dec),mag:i(e.mag,t.mag),ci:i(e.ci,t.ci)}}}const qb=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,Yb=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,Kb=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,$b=20,Zb=1;class Jb{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,i){if(this.requested={type:e,intensity:t,windSpeed:i},!this.context)return;this.paused&&(e="none",t=0,i=0);const n=e==="rain"||e==="hail"?e:"none";if(this.ambientVolume=n==="hail"?Math.min(1,t*1.3+.2):n==="rain"?t:0,n!==this.ambientKey){this.ambientKey=n;const r=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,n!=="none"&&this.startLoop(qb,this.ambientVolume).then(o=>this.applyIfCurrent(o,r,()=>this.ambientToken,c=>{this.ambientSource=c?.source,this.ambientGain=c?.gain,c&&(c.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(i/$b,1);const s=i>Zb;if(s!==this.windActive){this.windActive=s;const r=++this.windToken;this.stopSource(this.windSource,this.windGain),this.windSource=void 0,this.windGain=void 0,s&&this.startLoop(Yb,this.windVolume).then(o=>this.applyIfCurrent(o,r,()=>this.windToken,c=>{this.windSource=c?.source,this.windGain=c?.gain,c&&(c.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(e){if(e===this.paused)return;this.paused=e;const{type:t,intensity:i,windSpeed:n}=this.requested;this.setAmbient(t,i,n)}playThunder(){!this.context||this.paused||this.playOneShot(Kb,.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,i,n){if(t!==i()){e?.source.stop();return}n(e)}async startLoop(e,t){const i=this.context;if(i)try{const n=await this.getBuffer(e),s=i.createBufferSource();s.buffer=n,s.loop=!0;const r=i.createGain();return r.gain.value=t,s.connect(r).connect(i.destination),s.start(),{source:s,gain:r}}catch(n){console.warn("Weather ambient sound failed to load, staying silent:",n);return}}async playOneShot(e,t){const i=this.context;if(i)try{const n=await this.getBuffer(e),s=i.createBufferSource();s.buffer=n;const r=i.createGain();r.gain.value=t,s.connect(r).connect(i.destination),s.start()}catch(n){console.warn("Thunder sound failed to load:",n)}}async getBuffer(e){const t=this.context;if(!t)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let i=this.buffers.get(e);return i||(i=fetch(e).then(n=>{if(!n.ok)throw new Error(`Audio fetch failed (${n.status}): ${e}`);return n.arrayBuffer()}).then(n=>t.decodeAudioData(n)),this.buffers.set(e,i)),i}stopSource(e,t){try{e?.stop()}catch{}e?.disconnect(),t?.disconnect()}}class hs{constructor(e){this.elements=e;const{eccentricity:t,perihelionAu:i}=e,[n,s]=this.perifocalAxes(),r=Math.sqrt(hs.SUN_GM_AU3_PER_DAY2*(1+t)/i);this.perihelionPosition=this.scale(n,i),this.perihelionVelocity=this.scale(s,r),this.inverseSemiMajorAxis=(1-t)/i}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(e){const t=e-this.elements.perihelionJd,i=this.universalAnomaly(t),n=this.inverseSemiMajorAxis*i*i,s=this.elements.perihelionAu,r=1-i*i/s*hs.stumpffC(n),o=t-i*i*i/Math.sqrt(hs.SUN_GM_AU3_PER_DAY2)*hs.stumpffS(n);return{x:r*this.perihelionPosition.x+o*this.perihelionVelocity.x,y:r*this.perihelionPosition.y+o*this.perihelionVelocity.y,z:r*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),i=Math.sqrt(hs.SUN_GM_AU3_PER_DAY2)*Math.abs(e),n=o=>{const c=this.inverseSemiMajorAxis*o*o,l=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*l)*o*o*o*hs.stumpffS(c)+l*o};let s=Math.max(1,i/this.elements.perihelionAu);for(;n(s)<i;)s*=2;let r=0;for(let o=0;o<hs.MAX_ITERATIONS&&s-r>1e-13*Math.max(1,s);o++){const c=(r+s)/2;n(c)<i?r=c:s=c}return t*(r+s)/2}perifocalAxes(){const e=this.elements.ascendingNodeDeg*Math.PI/180,t=this.elements.argumentOfPerihelionDeg*Math.PI/180,i=this.elements.inclinationDeg*Math.PI/180,n=Math.cos(e),s=Math.sin(e),r=Math.cos(t),o=Math.sin(t),c=Math.cos(i),l=Math.sin(i);return[{x:n*r-s*o*c,y:s*r+n*o*c,z:o*l},{x:-n*o-s*r*c,y:-s*o+n*r*c,z:r*l}]}scale(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}static stumpffC(e){if(Math.abs(e)<1e-6)return 1/2-e/24+e*e/720;if(e>0)return(1-Math.cos(Math.sqrt(e)))/e;const t=Math.sqrt(-e);return(Math.cosh(t)-1)/-e}static stumpffS(e){if(Math.abs(e)<1e-6)return 1/6-e/120+e*e/5040;if(e>0){const i=Math.sqrt(e);return(i-Math.sin(i))/(i*i*i)}const t=Math.sqrt(-e);return(Math.sinh(t)-t)/(t*t*t)}}const v1=[{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 jb{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 v1.filter(i=>Math.abs(t-i.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(e,t){return this.aroundDate(e).map(i=>this.appearanceOf(i,e,t)).sort((i,n)=>i.magnitude-n.magnitude)[0]}static appearanceOf(e,t,i){const n=zt(t),s=this.earthPositionAt(n),r=this.apparentPositionOf(e,2451545+n.tt,s),o=this.subtract(r,s),c=this.length(r),l=this.length(o),h=this.tailEndAt(e,r,s,c,n,t,i),u=this.horizontalOf(o,n,t,i);return{apparition:e,position:u,...h,heliocentricDistanceAu:c,earthDistanceAu:l,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},s)),magnitude:this.magnitudeAt(e,c,l)}}static magnitudeAt(e,t,i){const n=e.absoluteMagnitude+5*Math.log10(i)+2.5*e.activityExponent*Math.log10(t);return Math.max(n,e.peakMagnitude)}static tailEndAt(e,t,i,n,s,r,o){if(e.tailLengthAu===void 0)return{};const c=1+e.tailLengthAu/n,l=this.subtract({x:t.x*c,y:t.y*c,z:t.z*c},i),h=this.subtract(t,i);return{tailEnd:this.horizontalOf(l,s,r,o),tailLengthDeg:this.angleBetween(h,l)}}static apparentPositionOf(e,t,i){const n=this.orbitOf(e);let s=n.positionAt(t);for(let r=0;r<2;r++){const o=this.length(this.subtract(s,i))/this.LIGHT_SPEED_AU_PER_DAY;s=n.positionAt(t-o)}return s}static horizontalOf(e,t,i,n){const s=mr(J5(),new Ct(e.x,e.y,e.z,t)),r=mr(n1(t),s),o=C5(t,new c0(n.lat,n.lng,n.elevationM)),c=new Ct(r.x-o.x,r.y-o.y,r.z-o.z,t),l=h0(c);return u0(l.ra,l.dec,i,n)}static earthPositionAt(e){return mr(Z5(),Xs(we.Earth,e))}static julianDayOf(e){return 2451545+zt(e).tt}static orbitOf(e){const t=this.orbits.get(e.id);if(t)return t;const i=new hs(e.orbit);return this.orbits.set(e.id,i),i}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 i=(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,i)))*180/Math.PI}}const Zh=[{id:"sn-1006",kind:"supernova",designation:"SN 1006",name:{en:"Supernova of 1006",fr:"supernova de 1006"},raHours:15.03947,decDeg:-42.09694,peakMagnitude:-7.5,peakJd:2088620,startJd:2088620,lightCurve:[[0,-7.5],[29,-5.9],[60,-4.9],[106,-3.2],[166,-1.9],[258,-1],[350,.5],[364,.7],[411,1.2],[456,1.8],[484,2.5],[785.5,7]],source:"Winkler, Gupta & Long 2003 (peak); decline borrowed from SN 1572",note:"The brightest stellar event in recorded history, seen in daylight, low in the southern sky from Europe and the Near East. The decline is modelled, not recorded, and falls below the naked eye after about two years where the chronicles speak of three."},{id:"sn-1054",kind:"supernova",designation:"SN 1054",name:{en:"Supernova of 1054",fr:"supernova de 1054"},raHours:5.5755,decDeg:22.0175,peakMagnitude:-6,peakJd:2106216,startJd:2106216,lightCurve:[[0,-6],[23,-4],[642,6]],source:"Chinese chronicles (Song huiyao), via Stephenson & Green 2002",note:"The explosion that left the Crab Nebula. Its magnitude is an estimate; the two durations are recorded."},{id:"sn-1181",kind:"supernova",designation:"SN 1181",name:{en:"Supernova of 1181",fr:"supernova de 1181"},raHours:.88645,decDeg:67.50067,peakMagnitude:0,peakJd:2152636,startJd:2152636,lightCurve:[[0,0],[185,6]],source:"Chinese and Japanese chronicles, via Stephenson & Green 2002",note:"Circumpolar from Europe and China, so never set. Its peak magnitude is uncertain by at least a magnitude."},{id:"sn-1572",kind:"supernova",designation:"SN 1572",name:{en:"Tycho's Supernova",fr:"supernova de Tycho"},raHours:.42264,decDeg:64.14083,peakMagnitude:-4,peakJd:2295551,startJd:2295546,lightCurve:[[0,-3],[5,-4],[34,-2.4],[65,-1.4],[111,.3],[171,1.6],[263,2.5],[355,4],[369,4.2],[416,4.7],[461,5.3],[489,6]],source:"Tycho Brahe and contemporaries, reduced by Ruiz-Lapuente 2004",note:"Circumpolar from northern Europe. Tycho showed it had no parallax, so it was not in the air: a new star, beyond the Moon."},{id:"sn-1604",kind:"supernova",designation:"SN 1604",name:{en:"Kepler's Supernova",fr:"supernova de Kepler"},raHours:17.51125,decDeg:-21.48733,peakMagnitude:-2.95,peakJd:2307210,startJd:2307191,lightCurve:[[0,.23],[3,-1.3],[6,-2.08],[9,-2.17],[19,-2.95],[27,-2.95],[32,-1.95],[36,-1.52],[86,.9],[96,.45],[103,1],[114,1.2],[118,1.55],[133,1.95],[137,2.3],[170,2.25],[185,2.25],[194,2.4],[197,2.9],[308,4.45],[324,4.45],[339,4.95],[364,4.7]],source:"Kepler, Fabricius, Maestlin and the Korean court astronomers, reduced by Ruiz-Lapuente 2017",note:"The last supernova in our Galaxy seen with the naked eye. It went behind the Sun from mid-November 1604 to January 1605, which is the gap in its record."},{id:"t-crb-1866",kind:"nova",designation:"T CrB",name:{en:"Nova Coronae Borealis 1866",fr:"nova de la Couronne boréale 1866"},raHours:15.99171,decDeg:25.92017,peakMagnitude:2,peakJd:2402734,startJd:2402734,lightCurve:[[0,2],[1.5,3],[2.5,3.11],[6.5,5.18],[8.5,5.75],[10.5,6.85],[11.5,6.8],[12.5,7.5],[16,8.18],[32,9.27],[38,9.2],[40,8.95],[44,9.4],[48,9.07],[54,9.4],[58,9.21],[79,9.44],[107,9.26],[111,9.01],[115,8.21],[119,7.96],[159,7.51],[179,7.57],[183,7.97],[191,7.66],[199,8.2],[207,8.31],[211,8.83],[215,8.65],[223,8.97],[297,8.9],[345,9.25],[377,9.07],[425,9.3],[537,9.3]],source:"Recorded peak (Birmingham); curve borrowed from its 1946 eruption",note:"The first eruption of the recurrent nova T CrB to be seen. The decline is its 1946 one."},{id:"t-aur-1891",kind:"nova",designation:"T Aur",name:{en:"Nova Aurigae 1891",fr:"nova du Cocher 1891"},raHours:5.53309,decDeg:30.44583,peakMagnitude:4.49,peakJd:2412083,startJd:2412079,lightCurve:[[0,5.28],[4,4.49],[24,4.58],[40,4.97],[52,4.95],[56,4.5],[60,4.9],[68,4.88],[72,5.25],[76,4.93],[84,5.44],[88,7.23],[96,8.85],[100,10.44]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"gk-per-1901",kind:"nova",designation:"GK Per",name:{en:"Nova Persei 1901",fr:"nova de Persée 1901"},raHours:3.52,decDeg:43.90431,peakMagnitude:.19,peakJd:24154395e-1,startJd:24154377e-1,lightCurve:[[0,2.7],[.8,.86],[1.8,.19],[2.3,.2],[5.8,1.78],[11.8,2.54],[12.8,2.98],[17.8,3.62],[18.8,3.35],[19.8,3.77],[20.8,3.59],[22.8,3.95],[24.8,3.82],[25.6,4.99],[25.9,4.89],[26.6,3.69],[27.6,3.94],[27.9,4.61],[28.6,5.28],[28.9,4.46],[29.9,3.8],[30.9,4.27],[31.6,5.21],[31.9,5.22],[32.9,3.88],[33.9,4.19],[34.6,4.85],[35.6,4.8],[36.6,4.23],[37.6,4.44],[38.9,4.15],[39.7,5.19],[40.6,5.39],[40.9,5.35],[41.9,4.01],[42.6,4.5],[42.9,4.49],[43.6,5.53],[44,5.23],[44.6,5.61],[44.9,5.5],[45.9,4.17],[46.9,4.69],[47.6,5.5],[48.6,5.59],[49.6,5.14],[49.9,4.48],[50.6,4.45],[50.9,4.55],[51.6,5.47],[52.6,5.74],[53.7,5.66],[55.7,4.41],[56.7,5.43],[58.7,5.81],[58.9,5.58],[59.7,5.64],[59.9,4.76],[60.9,4.26],[61.9,5.62],[62.7,5.85],[62.9,5.53],[63.7,5.8],[64.9,4.28],[65.6,5.33],[66.7,5.87],[66.9,5.56],[68.7,5.7],[68.9,5.3],[69.7,4.47],[70.7,5.65],[72.9,5.98],[73.9,5.71],[74.7,4.98],[74.9,4.46],[75.7,4.87],[76.9,6.05],[77.6,5.76],[78,6],[78.7,5.95],[80.7,4.98],[81.9,5.85],[82.7,6.02],[84.7,5.41],[84.9,5.08],[85.7,5.17],[85.9,5.6],[87,6.1],[88.8,6.2],[89.7,4.96],[89.9,4.93],[90.7,5.9],[91.9,6.32],[92.7,5.86],[93.1,6.24],[93.7,5.38],[93.9,6.2],[96.1,6.12],[97.1,6.37],[97.6,5.12],[98,5.85],[99.3,6.35],[101.3,6.12],[101.7,5.25],[102.3,4.95],[102.7,6.12],[103.2,5.83],[104.7,6.37],[105,6.13],[106,6.22],[106.7,4.88],[107.7,6.3],[108.1,6.4],[109,6],[109.7,5.16],[110,5.82],[112.1,5.89],[113.1,5.5],[115.7,5.8],[116,6.11],[118.7,5.68],[119,6.23],[119.7,5.85],[120,6.12],[121,4.62],[121.8,5.9],[123,5.48],[125,6.05],[126,5.89],[130.9,6.11],[146.1,6.02],[155.6,6.26],[180.4,6.09],[190.4,6.39],[245.5,6.87],[266.2,6.77],[301.1,7.16],[321.5,7.07],[346.5,7.87],[375.7,7.86],[385.8,8.09],[389.8,8.55],[406.1,8.33],[416.5,8.59],[445.9,8.62],[472.1,9.24],[565.9,9.74],[571,9.4],[589.8,9.76]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"Discovered on 21 February 1901 by Thomas Anderson in Edinburgh, and the brightest nova of the century until V603 Aql."},{id:"dn-gem-1912",kind:"nova",designation:"DN Gem",name:{en:"Nova Geminorum 1912",fr:"nova des Gémeaux 1912"},raHours:6.9151,decDeg:32.14108,peakMagnitude:3.58,peakJd:241947675e-2,startJd:241947275e-2,lightCurve:[[0,11.7],[1,4.5],[4,3.58],[5,4.45],[5.5,5.32],[6,5.53],[6.5,5.11],[8,5.43],[8.5,5.16],[11,5.53],[11.5,5.13],[12,5.18],[13.75,4.5],[15.75,5.3],[18.75,6],[19.75,5.55],[26.75,6],[28.75,5.9],[31.75,6.6],[32.75,6.2],[33.75,6.5],[36.75,6.55],[39.75,6.2],[40.75,6.75],[41.75,7],[44.75,6.75],[52.75,6.75],[54.75,7.23],[58.25,7.5],[62.25,7.3],[64.25,7.47],[66.25,8.1],[70.25,7.5],[72.25,8.1],[78.25,7.55],[80.25,8.2],[86.25,7.2],[90.25,7.3],[92.25,7.8],[152.25,7.2],[160.25,7.4],[166.25,8.2],[168.25,8.2],[170.25,7.3],[180.25,7.4],[182.25,8],[186.25,7.5],[190.25,7.6],[192.25,8],[211.25,7.75],[227.25,8],[275.25,7.78],[315.25,8.6],[331.25,7.79],[339.25,8.27],[363.25,8.61],[443.25,8.93],[451.25,9.2],[535.25,10.3],[567.25,9.9],[615.25,10.8],[631.25,10.63],[647.25,10.88],[679.25,10.8],[695.25,11.07],[727.25,11]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v603-aql-1918",kind:"nova",designation:"V603 Aql",name:{en:"Nova Aquilae 1918",fr:"nova de l'Aigle 1918"},raHours:18.81518,decDeg:.58414,peakMagnitude:-.5,peakJd:242175475e-2,startJd:242174875e-2,lightCurve:[[0,11.3],[2,10.5],[4,6.6],[4.5,1.04],[6,-.5],[6.5,.18],[10,1.1],[10.5,.95],[12.75,1.89],[21.75,3.07],[23.75,3.76],[29.75,3.16],[34.75,3.5],[36.75,3.86],[44.75,3.79],[48.75,4.43],[52.75,3.84],[56.75,3.95],[57.75,4.04],[58.75,4.49],[59.75,4.42],[60.75,4.69],[62.75,4.6],[63.75,4.11],[64.75,3.97],[68.75,4.18],[70.75,4.65],[71.75,4.51],[73.75,4.73],[75.75,4.44],[79.75,4.85],[83.75,4.43],[89.75,4.88],[92.75,4.86],[94.75,4.58],[96.75,4.92],[99.75,5.05],[163.25,5.45],[167.25,5.7],[179.25,5.48],[191.25,5.8],[203.25,5.5],[247.25,5.9],[251.25,6.25],[257.25,5.5],[265.25,6.13],[281.25,6.33],[345.25,6.3],[385.25,6.73],[393.25,6.43],[425.25,6.71],[433.25,6.56],[461.25,7.27],[525.25,7.6],[541.25,7.47],[637.25,8.3],[669.25,8.17],[717.25,8.55],[749.25,8.4],[765.25,8.68],[885.25,8.75],[949.25,9.4],[1013.25,9.19],[1141.25,9.57],[1269.25,9.48],[1333.25,9.95],[1653.25,9.94],[1781.25,10.28],[1909.25,10.34],[2037.25,10.1],[2101.25,10.46],[2165.25,10.51],[2357.25,10.3],[2549.25,10.77],[2741.25,10.46],[2869.25,10.83],[3125.25,10.71],[3317.25,11.22],[3381.25,10.91],[3637.25,11.42],[3829.25,10.96],[3893.25,11.65],[3957.25,11.63],[4085.25,11.14],[4213.25,11.48],[4277.25,10.7],[4341.25,11.42],[4405.25,11.47],[4469.25,11.06],[4533.25,11.08],[4597.25,11.7],[4725.25,11.45],[4789.25,10.94]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"The brightest nova of the modern era, at magnitude -0.5 on 9-10 June 1918: as bright as Vega, in a summer evening sky, in wartime."},{id:"v476-cyg-1920",kind:"nova",designation:"V476 Cyg",name:{en:"Nova Cygni 1920",fr:"nova du Cygne 1920"},raHours:19.97347,decDeg:53.61858,peakMagnitude:1.94,peakJd:242256025e-2,startJd:242255925e-2,lightCurve:[[0,2.7],[1,1.94],[3,2.07],[4.5,2.95],[8.25,4],[31.75,6.41],[35.75,7.23],[37.75,7.08],[41.75,7.33],[43.75,7.92],[45.75,8.2],[51.75,8.59],[63.75,8.82],[65.75,9.25],[71.75,8.93],[85.75,9.43],[87.75,9.05],[95.75,9.2],[97.75,8.67],[99.75,9.07],[112.75,8.78],[120.75,9.03],[128.75,8.67],[144.75,8.94],[152.75,8.73],[168.75,8.79],[176.75,9.28],[192.75,9],[216.75,9.6],[232.75,9.27],[240.75,9.5],[288.75,9.4],[296.75,9.6],[304.75,9.3],[320.75,9.73],[328.75,9.5],[336.75,9.8],[428.75,9.61],[476.75,10.01],[492.75,9.76],[508.75,9.87],[524.75,9.65],[556.75,9.87],[572.75,9.65],[620.75,10.22],[668.75,10.44],[684.75,10.23],[716.75,10.33],[756.75,10.66],[884.75,10.59],[948.75,10.96],[1108.75,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"rr-pic-1925",kind:"nova",designation:"RR Pic",name:{en:"Nova Pictoris 1925",fr:"nova du Peintre 1925"},raHours:6.59335,decDeg:-62.64008,peakMagnitude:.95,peakJd:24243085e-1,startJd:24242995e-1,lightCurve:[[0,2.43],[5,2.35],[6,2.1],[7,2.4],[9,.95],[13,1.8],[14,1.7],[16,2.15],[18,2.2],[19,1.9],[23,3.1],[27,3.05],[31.5,3.58],[43.5,3.08],[47.5,3.15],[57.5,2.3],[59.5,1.65],[63.5,3.03],[65.5,2.84],[67.5,3.16],[69.5,2.4],[71.5,2.04],[73.5,2.05],[75.5,2.55],[79.5,3],[83.5,3.15],[116.5,3.54],[120.5,3.78],[124.5,3.67],[136.5,4.18],[148.5,4.34],[154.5,4.17],[194.5,4.43],[226.5,4.93],[234.5,4.8],[242.5,5.4],[250.5,5.5],[266.5,5.15],[298.5,5.6],[362.5,5.4],[414.5,5.7],[430.5,5.5],[494.5,6.2],[718.5,6.52],[830.5,6.3],[862.5,6.6],[878.5,6.4],[910.5,6.77],[958.5,6.67],[1062.5,7.07],[1318.5,7.35],[1590.5,8.12],[1718.5,8.25],[2486.5,8.59],[2614.5,8.47],[2742.5,8.7],[3382.5,8.6],[3766.5,8.97],[4022.5,8.79],[4150.5,9.22],[6710.5,10.29],[7414.5,11.03],[8438.5,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A slow nova, and a southern one: more than two months within two magnitudes of its peak."},{id:"dq-her-1934",kind:"nova",designation:"DQ Her",name:{en:"Nova Herculis 1934",fr:"nova d'Hercule 1934"},raHours:18.12507,decDeg:45.85906,peakMagnitude:1.56,peakJd:24277935e-1,startJd:242778675e-2,lightCurve:[[0,3.4],[1.5,2.4],[3,2.67],[5.75,2.01],[6.75,1.56],[7.75,1.59],[11.75,2.97],[12.75,2.31],[14.75,3.07],[15.75,2.56],[16.75,2.51],[19.75,2.68],[23.75,2.53],[24.75,2.27],[26.75,2.58],[30.75,2.24],[31.75,2.63],[32.75,2.66],[34.75,2.11],[39.75,2.71],[41.75,2.31],[43.75,2.37],[46.75,3.64],[47.75,3.21],[50.75,3.23],[52.75,2.66],[55.75,2.56],[58.75,2.97],[60.75,2.77],[61.75,3.36],[63.75,3.43],[64.75,2.89],[65.75,3.22],[68.75,3.52],[69.75,2.95],[70.75,3.06],[71.75,2.7],[76.75,3.65],[79.75,3.74],[81.75,3.21],[83.75,3.75],[87.75,3.69],[92.75,4.04],[94.75,4.8],[97.75,4.24],[98.75,4.52],[100.75,4.08],[101.75,4.43],[105.75,4.58],[106.75,4.33],[107.75,4.73],[108.75,6.57],[109.75,8.08],[110.75,8.15],[111.75,8.56],[113.75,8.45],[114.75,9.15],[115.75,9.15],[116.75,9.59],[117.75,9.43],[118.75,9.8],[122.75,10.5],[123.75,10.28],[124.75,10.93],[127.75,10.83],[129.75,11.87],[131.75,12.42],[135.75,12.5],[137.75,12.9],[138.75,12.77],[139.75,13],[143.75,12],[144.75,12.33],[146.75,12.35],[147.75,11.64],[148.75,11.83],[150.75,10.9],[151.75,10.78],[152.75,11.17],[154.75,10.32],[155.75,10.4],[165.25,9.24],[185.25,7.74],[225.25,6.8],[273.25,6.72],[321.25,6.97],[333.25,6.79],[353.25,7],[357.25,6.82],[377.25,6.88],[401.25,7.29],[409.25,6.8],[413.25,6.8],[419.25,7.1],[435.25,7.09],[451.25,7.4],[475.25,7],[555.25,7.48],[823.25,7.83],[855.25,8.18],[1135.25,8.43],[1823.25,9.98],[1887.25,9.71],[2015.25,10.55],[2335.25,10.95]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"Lost about ten magnitudes in a few weeks from April 1935, when dust condensed around it, then came back to naked-eye brightness."},{id:"cp-lac-1936",kind:"nova",designation:"CP Lac",name:{en:"Nova Lacertae 1936",fr:"nova du Lézard 1936"},raHours:22.26142,decDeg:55.61703,peakMagnitude:2.02,peakJd:242834025e-2,startJd:242833825e-2,lightCurve:[[0,4.03],[.5,2.9],[1,2.45],[2,2.02],[2.5,2.61],[4,3],[4.5,3.35],[5,3.3],[9.25,4.59],[14.25,5.45],[22.25,6.03],[23.25,6.3],[26.25,6.23],[38.25,6.74],[41.25,6.61],[50.25,7.35],[53.25,7.27],[57.25,7.7],[58.25,7.54],[60.25,7.55],[61.25,7.79],[71.25,7.6],[74.25,7.81],[76.25,8.3],[77.25,7.79],[86.25,8.21],[87.25,8],[88.25,8.25],[92.25,8.17],[94.25,8.47],[102.25,8.27],[103.25,8.7],[104.25,8.4],[110.25,8.66],[116.75,8.55],[122.75,8.83],[126.75,8.7],[140.75,9.06],[154.75,9.01],[164.75,9.36],[170.75,9.18],[174.75,9.48],[186.75,9.42],[188.75,9.73],[192.75,9.53],[200.75,9.74],[202.75,9.5],[204.75,9.77],[208.75,9.6],[214.75,9.75],[216.75,10.05],[222.75,9.7],[232.75,10.03],[236.75,9.82],[250.75,10.1],[254.75,9.9],[260.75,10.1],[264.75,9.8],[266.75,10.15],[268.75,10],[274.75,10.2],[276.75,9.9],[292.75,10.6],[294.75,10.6],[298.75,10.1],[318.75,10.35],[320.75,10.6],[322.75,10.3],[328.75,10.65],[332.75,10.3],[338.75,10.7],[348.75,10.53],[350.75,10.7],[354.75,10.37],[358.75,10.58],[365.75,10.43],[373.75,10.85],[421.75,10.94]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"cp-pup-1942",kind:"nova",designation:"CP Pup",name:{en:"Nova Puppis 1942",fr:"nova de la Poupe 1942"},raHours:8.19613,decDeg:-35.35139,peakMagnitude:.73,peakJd:243067675e-2,startJd:243067275e-2,lightCurve:[[0,.95],[4,.73],[4.5,1.3],[5.5,1.47],[6,2.01],[7.75,2.88],[8.75,2.97],[10.75,3.5],[11.75,4.02],[13.75,4.4],[14.75,3.8],[17.75,5],[18.75,4.93],[19.75,5.48],[23.75,5.5],[25.75,5.65],[26.75,5.99],[33.25,6.28],[45.25,6.6],[57.25,6.41],[81.25,6.85],[89.25,6.5],[97.25,6.67],[101.25,7],[113.25,6.66],[125.25,7.1],[135.25,6.96],[231.25,7.86],[279.25,7.8],[327.25,8.33],[407.25,8.18],[423.25,8.59],[471.25,8.53],[503.25,8.99],[551.25,8.97],[567.25,8.7],[583.25,9.47],[615.25,8.95],[655.25,9.5],[751.25,9.55],[815.25,10.09],[847.25,10.02],[879.25,10.48],[911.25,10.34],[1023.25,10.79],[1279.25,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"One of the fastest bright novae: two magnitudes gone in four days."},{id:"t-crb-1946",kind:"nova",designation:"T CrB",name:{en:"Nova Coronae Borealis 1946",fr:"nova de la Couronne boréale 1946"},raHours:15.99171,decDeg:25.92017,peakMagnitude:2.5,peakJd:2431860,startJd:2431860,lightCurve:[[0,2.5],[1.5,3.5],[2.5,3.61],[6.5,5.68],[8.5,6.25],[10.5,7.35],[11.5,7.3],[12.5,8],[16,8.68],[32,9.77],[38,9.7],[40,9.45],[44,9.9],[48,9.57],[54,9.9],[58,9.71],[79,9.94],[107,9.76],[111,9.51],[115,8.71],[119,8.46],[159,8.01],[179,8.07],[183,8.47],[191,8.16],[199,8.7],[207,8.81],[211,9.33],[215,9.15],[223,9.47],[297,9.4],[345,9.75],[377,9.57],[425,9.8],[537,9.8]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A recurrent nova. It erupted in 1866 and in 1946, and a third eruption was expected from 2024 on."},{id:"v446-her-1960",kind:"nova",designation:"V446 Her",name:{en:"Nova Herculis 1960",fr:"nova d'Hercule 1960"},raHours:18.956,decDeg:13.24147,peakMagnitude:4.83,peakJd:24370038e-1,startJd:24370033e-1,lightCurve:[[0,5.2],[.5,4.83],[2,4.9],[2.5,5.4],[3,5.05],[3.5,5.57],[4,5.25],[5,5.5],[6.5,5.4],[7.2,5.78],[8.2,5.6],[9.2,5.98],[10.2,5.92],[11.2,6.21],[16.2,6.1],[17.2,6.23],[18.2,7.2],[19.2,6.51],[20.2,6.78],[26.2,6.97],[27.2,7.24],[28.2,7.13],[29.2,7.45],[31.2,7.2],[40.7,7.57],[44.7,8.25],[46.7,7.84],[56.7,8.15],[60.7,8.9],[70.7,8.7],[72.7,8.14],[76.7,8.71],[80.7,8.47],[82.7,8.87],[86.7,8.57],[90.7,8.93],[107.7,9.11],[111.7,8.94],[115.7,9.27],[139.7,9.38],[151.7,9.91],[155.7,9.72],[173.7,10.51],[221.7,10.95]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v533-her-1963",kind:"nova",designation:"V533 Her",name:{en:"Nova Herculis 1963",fr:"nova d'Hercule 1963"},raHours:18.23902,decDeg:41.85614,peakMagnitude:3,peakJd:24380605e-1,startJd:24380565e-1,lightCurve:[[0,8],[4,3],[4.5,3],[8,4],[13,3.95],[15,4.6],[21,4.53],[24,5.05],[27,5.15],[32,4.76],[34,4.98],[35,5.39],[37,5.43],[41,6.04],[49,6.02],[56.5,6.34],[60.5,6.11],[74.5,6.72],[102.5,6.99],[137.5,7.81],[197.5,8.31],[217.5,8.8],[225.5,8.57],[233.5,9.03],[237.5,8.78],[277.5,9.44],[301.5,9.46],[315.5,9.86],[323.5,9.73],[339.5,10.05],[355.5,10.74],[363.5,10.32],[371.5,10.6],[387.5,10.69],[427.5,10.38],[435.5,10.84],[443.5,10.74],[451.5,11.33],[459.5,10.98],[467.5,11.17],[507.5,11.16],[539.5,11.66],[603.5,11.7],[619.5,12.05],[651.5,12.03],[659.5,11.74],[667.5,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"hr-del-1967",kind:"nova",designation:"HR Del",name:{en:"Nova Delphini 1967",fr:"nova du Dauphin 1967"},raHours:20.70565,decDeg:19.16092,peakMagnitude:3.58,peakJd:2439838,startJd:2439646,lightCurve:[[0,11.9],[6,11.8],[12,8.8],[16,8.3],[20,6.7],[30,5.8],[36,5.51],[66,5.55],[78,5.35],[86,4.89],[96,5],[108,4.75],[136,5.13],[152,4.83],[182,4.93],[186,4.59],[192,3.58],[202,5],[220,5.46],[226,5.14],[230,5.45],[232,5.14],[236,5],[242,5.08],[244,4.59],[246,4.45],[254,5.3],[256,4.75],[260,5.69],[268,4.8],[274,4.94],[276,5.45],[280,5.2],[282,5.51],[286,5.58],[292,4.95],[294,5.16],[298,4.94],[311,5.09],[335,4.4],[367,5.76],[407,6.16],[423,6.55],[603,7.43],[907,8.32],[1451,9.41],[2347,10.75]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"An exceptionally slow nova: rose over months and stayed near magnitude 4 to 5 for most of 1967 and 1968."},{id:"lv-vul-1968",kind:"nova",designation:"LV Vul",name:{en:"Nova Vulpeculae 1968",fr:"nova du Petit Renard 1968"},raHours:19.80012,decDeg:27.1715,peakMagnitude:4.5,peakJd:243996425e-2,startJd:243996325e-2,lightCurve:[[0,5],[1,4.5],[2,5],[2.5,4.86],[3,5.1],[3.5,4.88],[4,5.1],[5,4.9],[7,5.4],[8,5.23],[10.5,5.42],[12,5.82],[13,5.4],[13.5,5.74],[14,5.7],[14.5,6.08],[15,5.75],[15.5,5.86],[16,5.6],[17,5.8],[18,5.6],[20.5,6.34],[21,6.2],[22.5,6.84],[23,6.57],[24,6.98],[24.5,6.3],[25,7.1],[26,6.65],[34.25,7.48],[35.25,7.23],[39.25,7.32],[44.25,7.76],[45.25,7.49],[46.25,7.78],[50.25,7.84],[51.25,8.1],[53.25,7.9],[54.25,8.13],[56.25,8],[57.75,8.24],[67.75,8.52],[75.75,8.38],[83.75,8.69],[89.75,8.59],[125.75,9.32],[127.75,9.33],[129.75,8.98],[131.75,9.29],[135.75,9.43],[212.75,9.9],[220.75,10.16],[228.75,10.03],[236.75,10.3],[244.75,10.16],[264.75,10.54],[280.75,10.45],[296.75,10.79],[328.75,10.78]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"fh-ser-1970",kind:"nova",designation:"FH Ser",name:{en:"Nova Serpentis 1970",fr:"nova du Serpent 1970"},raHours:18.51307,decDeg:2.61444,peakMagnitude:4.5,peakJd:244063425e-2,startJd:244063125e-2,lightCurve:[[0,7],[2,5],[3,4.5],[3.5,5],[4.5,4.6],[5.5,5],[6.5,4.68],[12.25,4.66],[16.25,5.3],[17.25,5.72],[18.25,5.3],[19.25,5.2],[23.25,5.84],[24.25,5.68],[27.25,5.9],[30.25,5.47],[32.25,5.9],[34.25,5.7],[43.25,6.28],[45.25,6.1],[50.25,6.62],[52.25,6.47],[57.25,6.63],[60.25,7.08],[61.25,6.87],[62.25,7.2],[63.25,6.85],[64.25,7.68],[65.25,7.3],[66.25,8.3],[67.25,7.93],[69.25,9.15],[71.25,9.2],[72.25,9.63],[74.25,9.9],[76.25,9.7],[77.25,10.25],[78.25,10.1],[79.25,10.4],[80.25,10.23],[81.25,10.57],[83.25,10.64],[85.25,10.35],[86.25,11.2],[87.25,10.1],[89.25,11.2],[96.25,11.35],[100.25,11.95],[102.25,11.1],[104.25,11.65],[106.25,11.5],[108.25,12.07],[114.75,11.32],[118.75,11.28],[122.75,10.93],[130.75,10.85],[134.75,10.52],[154.75,10.65],[162.75,10.12],[174.75,9.98],[178.75,10.34],[186.75,9.98],[214.75,10.25],[224.75,10.02],[240.75,10.2],[264.75,10],[272.75,10.2],[280.75,10.05],[288.75,10.4],[296.75,10],[348.75,10.7],[396.75,10.3],[444.75,10.73],[460.75,10.59],[540.75,10.94],[556.75,10.82]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v1500-cyg-1975",kind:"nova",designation:"V1500 Cyg",name:{en:"Nova Cygni 1975",fr:"nova du Cygne 1975"},raHours:21.19349,decDeg:48.15056,peakMagnitude:1.88,peakJd:244265525e-2,startJd:244265425e-2,lightCurve:[[0,2.44],[1,1.88],[1.5,1.88],[2.5,2.41],[3,3.38],[4,4.28],[8.25,5.81],[11.25,6.46],[22.25,7.35],[33.25,7.73],[34.25,7.97],[37.25,7.86],[40.25,8.3],[43.25,8.19],[48.25,8.6],[49.25,8.46],[66.25,9.04],[70.25,8.93],[75.25,9.23],[76.25,9.03],[80.25,9.39],[81.25,9.19],[83.25,9.35],[84.25,9.13],[86.25,9.39],[89.25,9.32],[90.25,9.54],[93.25,9.37],[105.75,9.86],[193.75,10.43],[201.75,10.7],[209.75,10.47],[257.75,10.94],[265.75,10.81]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"One of the fastest novae on record: discovered on 29 August 1975, at its peak of magnitude 1.9 within two days, and two magnitudes down again two days later."},{id:"v842-cen-1986",kind:"nova",designation:"V842 Cen",name:{en:"Nova Centauri 1986",fr:"nova du Centaure 1986"},raHours:14.59794,decDeg:-57.6265,peakMagnitude:4.9,peakJd:244675975e-2,startJd:244675725e-2,lightCurve:[[0,5.6],[2.5,4.9],[3.5,5.1],[15.5,5.1],[17.5,5.75],[18.5,5.4],[20.5,5.5],[22.5,5.95],[30.5,6.15],[31.5,6.3],[32,7.5],[34.5,7.2],[38.5,7.5],[39,7],[41.5,7.15],[42.5,6.7],[44.5,7.23],[45.5,6.6],[53,9.3]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"sn-1987a",kind:"supernova",designation:"SN 1987A",name:{en:"Supernova 1987A",fr:"supernova 1987A"},raHours:5.59111,decDeg:-69.26975,peakMagnitude:2.98,peakJd:24469425e-1,startJd:24468495e-1,lightCurve:[[0,6.36],[1,6.11],[2,4.63],[4,4.45],[32,3.97],[56,3.15],[93,2.98],[105,3.35],[118,4.11],[134,4.43],[504,8.15],[617,10.27]],source:"V photometry compiled by the Open Supernova Catalog (Sternberg catalogue, IAU circulars, CTIO)",note:"In the Large Magellanic Cloud, 160 000 light years away: the nearest supernova since Kepler's, and invisible north of about 20° N."},{id:"v1974-cyg-1992",kind:"nova",designation:"V1974 Cyg",name:{en:"Nova Cygni 1992",fr:"nova du Cygne 1992"},raHours:20.50879,decDeg:52.63078,peakMagnitude:4.27,peakJd:24486753e-1,startJd:24486718e-1,lightCurve:[[0,7.2],[1,5.23],[2,4.62],[3.5,4.27],[4.5,4.59],[6,4.5],[7,4.78],[7.5,4.52],[8,4.82],[10.7,5.25],[11.7,5.66],[16.7,5.85],[21.7,6.47],[22.7,6.3],[27.7,6.46],[29.7,6.83],[34.7,6.9],[35.7,7.25],[36.7,7],[37.7,7.16],[39.7,7.03],[43.7,7.41],[45.7,7.26],[50.7,7.45],[57.7,7.78],[58.7,8.13],[61.7,7.92],[64.7,8.19],[65.7,7.99],[71.7,8.22],[76.7,8.01],[128.2,8.72],[176.2,8.89],[192.2,9.15],[216.2,9.28],[232.2,9.07],[236.2,9.3],[390.2,10.99]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v382-vel-1999",kind:"nova",designation:"V382 Vel",name:{en:"Nova Velorum 1999",fr:"nova des Voiles 1999"},raHours:10.74678,decDeg:-52.42533,peakMagnitude:2.88,peakJd:245132225e-2,startJd:245132075e-2,lightCurve:[[0,2.99],[1.5,2.88],[2.5,3.46],[4.5,3.98],[5,4.32],[5.5,4.23],[7.5,4.85],[21.75,6.67],[30.25,7.2],[40.25,7.41],[93.25,7.95],[97.25,8.25],[101.25,8],[113.25,7.96],[129.25,8.5],[155.25,8.47],[163.25,9.1],[179.25,9],[187.25,8.7],[195.25,9.15],[211.25,9.23],[235.25,9.8],[243.25,9.71],[299.25,10.42],[383.25,10.52],[415.25,10.81]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v1494-aql-1999",kind:"nova",designation:"V1494 Aql",name:{en:"Nova Aquilae 1999",fr:"nova de l'Aigle 1999"},raHours:19.38482,decDeg:4.9555,peakMagnitude:4.11,peakJd:245151575e-2,startJd:245151425e-2,lightCurve:[[0,5.15],[.5,4.86],[1,4.27],[1.5,4.11],[2.5,4.35],[5,5.48],[10.5,6.26],[14.25,6.28],[20.25,7.43],[24.25,7.25],[25.25,7.63],[27.25,7.7],[29.25,7.42],[33.25,8.08],[35.25,8.03],[36.25,7.6],[37.25,7.6],[46.25,8.5],[54.25,8.28],[56.25,8.63],[58.25,8.4],[61.25,9.53],[62.25,9],[64.25,9.13],[69.25,8.58],[70.25,8.9],[72.25,8.88],[75.25,8.57],[77.25,9],[79.25,8.8],[81.25,9.7],[83.25,9.6],[85.25,9.8],[86.75,9.5],[88.75,9.54],[90.75,8.9],[92.75,8.85],[96.75,9.63],[102.75,9.7],[104.75,8.98],[106.75,8.73],[116.75,9.63],[118.75,9.6],[120.75,9.07],[122.75,9.26],[124.75,9.8],[128.75,9.36],[134.75,9.75],[147.75,9.92],[155.75,9.81],[259.75,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v4743-sgr-2002",kind:"nova",designation:"V4743 Sgr",name:{en:"Nova Sagittarii 2002",fr:"nova du Sagittaire 2002"},raHours:19.01926,decDeg:-22.00167,peakMagnitude:5,peakJd:245253775e-2,startJd:245253675e-2,lightCurve:[[0,5.2],[1,5],[2,5.89],[2.5,5.91],[3.5,6.43],[5,6.45],[5.5,6.86],[6,6.59],[7,6.77],[7.5,7.31],[8.5,6.99],[9,7.09],[10.5,7.86],[11,7.58],[11.5,7.89],[15.75,8.33],[17.75,8.18],[18.75,8.58],[19.75,8.44],[22.75,8.83],[23.75,8.6],[24.75,8.85],[27.75,8.83],[30.75,9.4],[31.75,9.09],[36.25,9.08],[38.25,9.34],[62.25,9.75],[66.25,10.1],[70.25,9.7],[74.25,10],[171.25,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"rs-oph-2006",kind:"nova",designation:"RS Oph",name:{en:"Nova Ophiuchi 2006",fr:"nova d'Ophiuchus 2006"},raHours:17.83699,decDeg:-6.70792,peakMagnitude:4.8,peakJd:2453779,startJd:2453779,lightCurve:[[0,4.8],[1.25,4.97],[2.75,5.78],[3.25,5.7],[3.75,6.24],[4.25,6.05],[4.75,6.38],[5.25,6.3],[8.5,7.25],[14.5,7.95],[24.5,8.55],[29.5,9.08],[48,9.87],[80,10.28],[107,11.54],[119,11.54],[139,11.98],[147,11.83],[163,12.03],[171,11.97],[175,11.65],[183,11.84],[195,11.64],[203,11.8],[207,12.13],[219,11.45],[277,11.68],[325,11],[341,11.53],[357,11.62],[373,11.3],[405,11.5],[421,11.17],[469,10.96],[501,11.22],[549,10.75],[581,11.08],[597,10.98]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A recurrent nova, erupting every twenty years or so (1898, 1907, 1933, 1945, 1958, 1967, 1985, 2006, 2021)."},{id:"v1280-sco-2007",kind:"nova",designation:"V1280 Sco",name:{en:"Nova Scorpii 2007",fr:"nova du Scorpion 2007"},raHours:16.96145,decDeg:-32.34325,peakMagnitude:3.8,peakJd:2454149,startJd:2454136,lightCurve:[[0,9.7],[13,3.8],[34,5.8],[103,15]],source:"AAVSO (discovery, peak, dust minimum); t2 from Das et al. 2008",note:"Faded from sight quickly when dust formed around it, three weeks after its peak."},{id:"v339-del-2013",kind:"nova",designation:"V339 Del",name:{en:"Nova Delphini 2013",fr:"nova du Dauphin 2013"},raHours:20.39186,decDeg:20.76772,peakMagnitude:4.4,peakJd:24565214e-1,startJd:24565214e-1,lightCurve:[[0,4.4],[11,6.4],[20,7.4]],source:"Gehrz et al. 2015 (peak, t2, t3)",note:"High in the summer evening sky of the northern hemisphere, and widely photographed."},{id:"v1369-cen-2013",kind:"nova",designation:"V1369 Cen",name:{en:"Nova Centauri 2013",fr:"nova du Centaure 2013"},raHours:13.9126,decDeg:-59.15114,peakMagnitude:3.48,peakJd:245663965e-2,startJd:24566285e-1,lightCurve:[[0,5.33],[1.57,4.08],[2.75,3.73],[4.57,4.16],[5.96,4.15],[10.26,3.77],[11.15,3.48],[12.14,3.74],[14.17,4.78],[15.46,4.97],[23.16,4.22],[26.25,4.32],[27.31,4.82],[29.56,5.11],[32.66,4.71],[33.84,4.86],[36.05,4.46],[37.15,4.99],[41.42,4.59],[42.37,4.93],[43.37,4.82],[44.54,5.09],[49.95,5.38],[51.99,5.82],[54.21,5.77]],source:"AAVSO, binned by day, as plotted by Izzo 2017 (arXiv:1704.07214, figure 1)",note:"Discovered on 2 December 2013 by John Seach at magnitude 5.5, it flared several times, reaching about 3.3 around 14 December: the brightest nova of the century so far, and a southern one."},{id:"rs-oph-2021",kind:"nova",designation:"RS Oph",name:{en:"Nova Ophiuchi 2021",fr:"nova d'Ophiuchus 2021"},raHours:17.83699,decDeg:-6.70792,peakMagnitude:4.6,peakJd:2459436,startJd:2459435,lightCurve:[[0,5],[1,4.6],[2.25,4.77],[3.75,5.58],[4.25,5.5],[4.75,6.04],[5.25,5.85],[5.75,6.18],[6.25,6.1],[9.5,7.05],[15.5,7.75],[25.5,8.35],[30.5,8.88],[49,9.67],[81,10.08],[108,11.34],[120,11.34],[140,11.78],[148,11.63],[164,11.83],[172,11.77],[176,11.45],[184,11.64],[196,11.44],[204,11.6],[208,11.93],[220,11.25],[278,11.48],[326,10.8],[342,11.33],[358,11.42],[374,11.1],[406,11.3],[422,10.97],[470,10.76],[502,11.02],[550,10.55],[582,10.88],[598,10.78]],source:"Recorded discovery and peak (8 and 9 August 2021); curve borrowed from its 2006 eruption",note:"RS Oph's latest eruption, discovered on 8 August 2021. The decline is its 2006 one."}];class Am{static UNIX_EPOCH_JD=24405875e-1;static aroundDate(e){const t=this.julianDayOf(e);return Zh.filter(i=>this.magnitudeAt(i,t)!==void 0)}static appearancesAt(e,t){const i=this.julianDayOf(e),n=[];for(const s of Zh){const r=this.magnitudeAt(s,i);r!==void 0&&n.push({outburst:s,position:En.ofJ2000(s.raHours,s.decDeg,e,t),magnitude:r})}return n.sort((s,r)=>s.magnitude-r.magnitude)}static brightestAt(e,t){return this.appearancesAt(e,t)[0]}static byId(e){return Zh.find(t=>t.id===e)}static magnitudeAt(e,t){const i=e.lightCurve,n=t-e.startJd;if(i.length===0||n<i[0][0]||n>i[i.length-1][0])return;let s=1;for(;s<i.length-1&&i[s][0]<n;)s++;const[r,o]=i[s-1]??i[0],[c,l]=i[s]??i[0];if(c===r)return o;const h=Math.min(1,Math.max(0,(n-r)/(c-r)));return o+h*(l-o)}static julianDayOf(e){return e.getTime()/864e5+this.UNIX_EPOCH_JD}}const Qb=[{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}],ml=6.5;class Jh{static activeAt(e){return Qb.flatMap(t=>{const i=this.nearness(t,e);return i<=0?[]:[{shower:t,zhr:t.peakZhr*i,nearness:i}]})}static nearness(e,t){const i=this.dayOfYear(t),n=this.dayOfYear(this.asDate(e.start)),s=this.dayOfYear(this.asDate(e.peak)),r=this.dayOfYear(this.asDate(e.end)),o=this.wrappedDelta(i,s),c=this.wrappedDelta(s,n),l=this.wrappedDelta(r,s);return o<0?o<-c?0:1+o/c:o>0?o>l?0:1-o/l:1}static observedRatePerHour(e,t,i,n=ml){if(t<=0)return 0;const s=ml-n;return e*Math.sin(t*Math.PI/180)/Math.pow(i,s)}static radiantPosition(e,t,i){return En.ofJ2000(e.radiantRaHours,e.radiantDecDeg,t,i)}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 i=e-t;return i>182?i-365:i<-182?i+365:i}}class qt{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(e,t){const i=zt(e),n=new Rl(0,R5(e).elon-90,1),s=mr(Q5(i),l0(n,i)),r=h0(s);return u0(r.ra,r.dec,e,t)}static observedRatePerHour(e,t=ml){const i=qt.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(e*Math.PI/180)),n=ml-t;return(qt.QUIET_RATE_PER_HOUR+i)/Math.pow(qt.POPULATION_INDEX,n)}static schedule(e){const t=new Il(e.seed^1542469173);return va.schedule(e).map(i=>{const n=qt.toCartesian({altitudeDeg:Math.asin(t.next())*180/Math.PI,azimuthDeg:t.between(0,360)}),s=i.fromRadiantDeg*Math.PI/180,r=qt.turnAround(n,t.between(0,360)),o={x:n.x*Math.cos(s)+r.x*Math.sin(s),y:n.y*Math.cos(s)+r.y*Math.sin(s),z:n.z*Math.cos(s)+r.z*Math.sin(s)};return{...i,radiant:qt.toHorizontal(o),bearingDeg:qt.bearingFrom(o,n)}})}static turnAround(e,t){const[i,n]=qt.basisAround(e),s=t*Math.PI/180;return{x:i.x*Math.cos(s)+n.x*Math.sin(s),y:i.y*Math.cos(s)+n.y*Math.sin(s),z:i.z*Math.cos(s)+n.z*Math.sin(s)}}static bearingFrom(e,t){const[i,n]=qt.basisAround(e),s=e.x*t.x+e.y*t.y+e.z*t.z,r=qt.normalise({x:t.x-e.x*s,y:t.y-e.y*s,z:t.z-e.z*s});return(Math.atan2(r.x*n.x+r.y*n.y+r.z*n.z,r.x*i.x+r.y*i.y+r.z*i.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},i=qt.normalise(qt.cross(e,t));return[i,qt.normalise(qt.cross(e,i))]}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=qt.toCartesian(e.radiant??{altitudeDeg:90,azimuthDeg:0}),i=qt.turnAround(t,e.bearingDeg),n=e.fromRadiantDeg*Math.PI/180;return qt.toHorizontal({x:t.x*Math.cos(n)+i.x*Math.sin(n),y:t.y*Math.cos(n)+i.y*Math.sin(n),z:t.z*Math.cos(n)+i.z*Math.sin(n)})}static toCartesian(e){const t=e.altitudeDeg*Math.PI/180,i=e.azimuthDeg*Math.PI/180,n=Math.cos(t);return{x:n*Math.sin(i),y:Math.sin(t),z:-n*Math.cos(i)}}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}const Tm="https://ufoathome.org/tle/index.json";class Ai{static MAX_ELEMENT_AGE_DAYS=7;static DAY_MS=864e5;fetchImpl;indexUrls;index;files=new Map;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.indexUrls=e.indexUrls??Ai.defaultIndexUrls()}static defaultIndexUrls(){const e=[];return typeof location<"u"&&/^https?:$/.test(location.protocol)&&e.push(new URL("/tle/index.json",location.href).href),e.includes(Tm)||e.push(Tm),e}static FIRST_SNAPSHOT="2021-02-22";async covers(e){const t=Date.parse(`${Ai.FIRST_SNAPSHOT}T00:00:00Z`)-Ai.MAX_ELEMENT_AGE_DAYS*Ai.DAY_MS;if(e.getTime()<t)return!1;const i=await this.loadIndex();return i?Object.values(i.index.kinds).some(n=>e.getTime()>=Date.parse(n.from)-Ai.MAX_ELEMENT_AGE_DAYS*Ai.DAY_MS&&e.getTime()<=Date.parse(n.to)+Ai.MAX_ELEMENT_AGE_DAYS*Ai.DAY_MS):!1}async at(e){const t=await this.loadIndex();if(!t)return;const{index:i,base:n}=t,s=[],r=[];for(const o of Object.keys(i.kinds)){const c=await this.kindAt(o,e,i,n);s.push(...c),r.push(this.coverageOf(o,e,i,c.length>0))}return{objects:s,coverage:r,credit:i.credit,creditUrl:i.source}}async kindAt(e,t,i,n){const s=t.getTime(),r=i.binDays*Ai.DAY_MS,o=Math.floor(s/r),c=s-o*r<r/2?o-1:o+1,l=new Set(i.kinds[e].bins),h=[o,c].map(v=>new Date(v*r).toISOString().slice(0,10)).filter(v=>l.has(v));if(h.length===0)return[];const[u,...d]=await Promise.all([this.json(new URL(`objects-${e}.json`,n).href),...h.map(v=>this.binary(new URL(`${e}/${v}.bin`,n).href))]),f=new Map;for(const v of d)for(const m of Ai.decode(v,i.recordBytes)){const g=f.get(m.norad);(!g||Math.abs(m.epochMs-s)<Math.abs(g.epochMs-s))&&f.set(m.norad,m)}const p=[];for(const v of f.values()){const m=Math.abs(v.epochMs-s)/Ai.DAY_MS;if(m>Ai.MAX_ELEMENT_AGE_DAYS)continue;const g=u[v.norad]??{name:String(v.norad)};g.launch&&Date.parse(`${g.launch}T00:00:00Z`)>s||p.push({norad:v.norad,name:g.name,kind:e,launch:g.launch,stdMag:g.stdMag,elements:v,ageDays:m})}return p}coverageOf(e,t,i,n){const{from:s,to:r}=i.kinds[e],o=t.getTime(),c=Ai.MAX_ELEMENT_AGE_DAYS*Ai.DAY_MS,l=n?"covered":o<Date.parse(s)-c?"before":o>Date.parse(r)+c?"after":"gap";return{kind:e,status:l,from:s,to:r}}static decode(e,t){const i=new DataView(e),n=[];for(let s=0;s+t<=e.byteLength;s+=t)n.push({norad:i.getUint32(s,!0),epochMs:i.getFloat64(s+4,!0),bstar:i.getFloat32(s+12,!0),inclinationDeg:i.getFloat32(s+16,!0),raanDeg:i.getFloat32(s+20,!0),eccentricity:i.getFloat32(s+24,!0),argOfPerigeeDeg:i.getFloat32(s+28,!0),meanAnomalyDeg:i.getFloat32(s+32,!0),meanMotion:i.getFloat64(s+36,!0)});return n}loadIndex(){return this.index??=(async()=>{for(const e of this.indexUrls)try{const t=await this.fetchImpl(e);if(!t.ok)continue;return{index:await t.json(),base:e}}catch{}})(),this.index}json(e){return this.cached(e,async t=>t.json())}binary(e){return this.cached(e,async t=>t.arrayBuffer())}cached(e,t){let i=this.files.get(e);return i||(i=this.fetchImpl(e).then(n=>{if(!n.ok)throw new Error(`${e}: ${n.status}`);return t(n)}),i.catch(()=>this.files.delete(e)),this.files.set(e,i)),i}}class eE{lowerM;upperM;add(e,t){if(!(e<=0)){if(t.behindM!==void 0){const i=Rt.sizeMAt(t.behindM,e);this.lowerM=this.lowerM===void 0?i:Math.max(this.lowerM,i)}if(t.inFrontM!==void 0){const i=Rt.sizeMAt(t.inFrontM,e);this.upperM=this.upperM===void 0?i:Math.min(this.upperM,i)}}}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:Rt.distanceMAt(this.lowerM,e),maxM:this.upperM===void 0?void 0:Rt.distanceMAt(this.upperM,e)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class xa{static DEG_PER_SECOND=360/86164.0905;static degOver(e){return Math.max(0,e)*xa.DEG_PER_SECOND}static instants(e,t){if(!(t>0))return 1;const i=xa.degOver(e)/t;return i<1?1:Math.min(xa.MAX_INSTANTS,Math.max(2,Math.ceil(i)))}static MAX_INSTANTS=64}class Ni{static EYE={apertureMm:7,exposureSeconds:.1,resolutionArcsec:60};static WAVELENGTH_M=55e-8;static ARCSEC_PER_RADIAN=180*3600/Math.PI;static UNKNOWN_CAMERA_FOCAL_MM=50;static UNKNOWN_CAMERA_DETAIL_UM=20;static get skyDriftArcsecPerSecond(){return xa.DEG_PER_SECOND*3600}static graspOf(e,t={}){const i=t.exposureSeconds??e.exposureSeconds,n=t.fNumber??e.fNumber;if(i===void 0||n===void 0||!(i>0)||!(n>0))return Ni.EYE;const s=t.focalLengthMm??e.frame?.focalLengthMm??Ni.UNKNOWN_CAMERA_FOCAL_MM,r=s/n,o=Ni.resolutionArcsec(e,s,r);return{apertureMm:r,exposureSeconds:Math.min(i,Ni.trailLimitedSeconds(o)),resolutionArcsec:o}}static resolutionArcsec(e,t,i){const s=(e.detailUm??Ni.UNKNOWN_CAMERA_DETAIL_UM)/1e3/t*Ni.ARCSEC_PER_RADIAN,r=1.22*Ni.WAVELENGTH_M/(i/1e3)*Ni.ARCSEC_PER_RADIAN;return Math.max(s,r)}static trailLimitedSeconds(e){return e/Ni.skyDriftArcsecPerSecond}static gainOverEye(e,t={}){const i=Ni.graspOf(e,t),n=Ni.EYE,s=(i.apertureMm/n.apertureMm)**2,r=i.exposureSeconds/n.exposureSeconds,o=(n.resolutionArcsec/i.resolutionArcsec)**2;return 1.25*Math.log10(s*r*o)}static gainFor(e,t){const i=t.fieldOfViewDeg===void 0?void 0:ri.focalLengthMmFor(e,t.fieldOfViewDeg);return Ni.gainOverEye(e,{fNumber:t.fNumber,focalLengthMm:i,exposureSeconds:t.exposureSeconds})}}const Rm=111320,Kr=Math.PI/180,tE=1.02,iE=1;class lo{static of(e,t){const i=lo.sightings(e,t);if(i.length<2)return;const n=lo.baseline(i);if(!n)return;const{near:s,far:r,closedM:o}=n,c=Math.tan(r.widthDeg/2*Kr)===0?0:Math.tan(s.widthDeg/2*Kr)/Math.tan(r.widthDeg/2*Kr);if(c<tE)return;const l=o/(c-1),h=Rt.sizeMAt(l,s.widthDeg),u=i.map(d=>({t:d.t,m:Rt.distanceMAt(h,d.widthDeg)}));return{widthM:h,distanceM:u,nearestM:Math.min(...u.map(d=>d.m)),fromT:r.t,toT:s.t,closedM:o}}static sightings(e,t){return e.timeline.allKeyframes.flatMap(i=>{const n=i.shapes.find(o=>o.sourceId===t)?.shape,s=n?.angular?.widthDeg,r=ai(e,i.t);return s===void 0||s<=0||r?.lat===void 0||r.lng===void 0?[]:[{t:i.t,widthDeg:s,lat:r.lat,lng:r.lng,sightAzimuthDeg:n?.aim?.azimuthDeg??r.headingDeg}]}).sort((i,n)=>i.t-n.t)}static baseline(e){let t;for(const i of e)for(const n of e){if(i.t>=n.t)continue;const s=lo.closedAlongSight(i,n),[r,o,c]=s>=0?[n,i,s]:[i,n,-s];c<iE||r.widthDeg<=o.widthDeg||(!t||c>t.closedM)&&(t={near:r,far:o,closedM:c})}return t}static closedAlongSight(e,t){const i=(t.lat-e.lat)*Rm,n=(t.lng-e.lng)*Rm*Math.cos(e.lat*Kr),s=(e.sightAzimuthDeg??0)*Kr;return i*Math.cos(s)+n*Math.sin(s)}}class Li{static CONVENTIONAL_M=5;static NEAREST_M=.2;static MARGIN=1.1;static resolve(e){if(e.statedM!==void 0&&e.statedM>0)return{distanceM:Li.atLeastNearest(e.statedM),basis:"stated"};if(e.hypothesisM!==void 0&&e.hypothesisM>0)return{distanceM:Li.atLeastNearest(e.hypothesisM),basis:"hypothesis"};if(e.derivedM!==void 0&&e.derivedM>0)return{distanceM:Li.atLeastNearest(e.derivedM),basis:"derived"};const t=Li.largest(e.range?.minM,e.crossing?.behindM),i=Li.smallest(e.range?.maxM,e.crossing?.inFrontM),n=t===void 0?void 0:t*Li.MARGIN,s=i===void 0?void 0:i/Li.MARGIN;return n!==void 0&&s!==void 0?{distanceM:Li.atLeastNearest(n<=s?Math.sqrt(n*s):n),basis:"bounded"}:n!==void 0?{distanceM:Li.atLeastNearest(n),basis:"bounded"}:s!==void 0&&s<Li.CONVENTIONAL_M?{distanceM:Li.atLeastNearest(s),basis:"bounded"}:{distanceM:Li.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(e){return Math.max(Li.NEAREST_M,e)}static largest(...e){const t=e.filter(i=>i!==void 0&&i>0);return t.length===0?void 0:Math.max(...t)}static smallest(...e){const t=e.filter(i=>i!==void 0&&i>0);return t.length===0?void 0:Math.min(...t)}}const jh=Math.PI/180;class _t{constructor(e,t,i){this.body=e,this.ground=t,this.keys=this.place([...e.track].sort((n,s)=>n.t-s.t),i)}static EYE_HEIGHT_M=1.6;static MAX_RANGE_M=3e4;static DEFAULT_SIZE={widthM:1,lengthM:1,heightM:1};static DEFAULT_APPEARANCE={color:"#c8c8c8",albedo:.5,luminanceCdM2:0};keys;static eyeOf(e,t,i){const n=ai(e,0),s=ai(e,t);if(n?.lat===void 0||n.lng===void 0||s?.lat===void 0||s.lng===void 0)return;const r=li(s.lat,s.lng,n.lat,n.lng),o=r.x,c=-r.z;return{eastM:o,northM:c,upM:i.heightAt(o,c)+_t.EYE_HEIGHT_M+s.elevationM,headingDeg:s.headingDeg}}static lineOfSightMeetsGround(e,t,i,n){const s=_t.directionOf(t,i),r=l=>e.upM+s.upM*l-n.heightAt(e.eastM+s.eastM*l,e.northM+s.northM*l);let o=0,c=0;for(;c<_t.MAX_RANGE_M;){if(c=o+Math.max(.5,o*.01),r(c)<=0){for(let l=0;l<30;l++){const h=(o+c)/2;r(h)<=0?c=h:o=h}return c}o=c}}static directionOf(e,t){const i=e*jh,n=t*jh;return{eastM:Math.sin(i)*Math.cos(n),northM:Math.cos(i)*Math.cos(n),upM:Math.sin(n)}}at(e){const t=this.keys;if(t.length===0||e<t[0].t)return;let i=t.length-1;for(;i>0&&t[i].t>e;)i--;const n=t[i];if(!n.present)return;const s=t[Math.min(i+1,t.length-1)],r=s===n||s.t===n.t?0:Math.min(1,(e-n.t)/(s.t-n.t)),o=_t.lerp(n.eastM,s.eastM,r),c=_t.lerp(n.northM,s.northM,r),l={widthM:_t.lerp(n.sizeM.widthM,s.sizeM.widthM,r),lengthM:_t.lerp(n.sizeM.lengthM,s.sizeM.lengthM,r),heightM:_t.lerp(n.sizeM.heightM,s.sizeM.heightM,r)},h={headingDeg:_t.lerpAngle(n.attitude.headingDeg,s.attitude.headingDeg,r),pitchDeg:_t.lerp(n.attitude.pitchDeg,s.attitude.pitchDeg,r),rollDeg:_t.lerp(n.attitude.rollDeg,s.attitude.rollDeg,r)};let u;if("aboveGroundM"in n.vertical&&"aboveGroundM"in s.vertical){const d=_t.lerp(n.vertical.aboveGroundM,s.vertical.aboveGroundM,r);u=this.groundUnderFootprint(o,c,l,h.headingDeg)+d+l.heightM/2}else u=_t.lerp(this.centreUpOf(n),this.centreUpOf(s),r);return{id:this.body.id,model:this.body.model,explains:this.body.explains??[],outlineNode:this.body.outlineNode,eastM:o,northM:c,upM:u,sizeM:l,attitude:h,appearance:{color:(r<1?n:s).appearance.color,albedo:_t.lerp(n.appearance.albedo,s.appearance.albedo,r),luminanceCdM2:_t.lerp(n.appearance.luminanceCdM2,s.appearance.luminanceCdM2,r)},flame:_t.flameBetween(n.flame,s.flame,r),throwsFlame:this.body.track.some(d=>d.flame!==void 0&&d.flame.luminanceCdM2>0)}}static flameBetween(e,t,i){if(!e||e.luminanceCdM2<=0)return i>=1&&t&&t.luminanceCdM2>0?t:void 0;const n=e,s=t??e,r={...i<1?n:s,lengthM:_t.lerp(n.lengthM,s.lengthM,i),widthM:_t.lerp(n.widthM,s.widthM,i),luminanceCdM2:_t.lerp(n.luminanceCdM2,s.luminanceCdM2,i)};return r.luminanceCdM2>0?r:void 0}centreUpOf(e){return"upM"in e.vertical?e.vertical.upM:this.groundUnderFootprint(e.eastM,e.northM,e.sizeM,e.attitude.headingDeg)+e.vertical.aboveGroundM+e.sizeM.heightM/2}groundUnderFootprint(e,t,i,n){const s=n*jh,r={eastM:Math.cos(s),northM:-Math.sin(s)},o={eastM:Math.sin(s),northM:Math.cos(s)};let c=this.ground.heightAt(e,t);for(const[l,h]of[[-1,-1],[1,-1],[-1,1],[1,1]]){const u=l*i.widthM/2,d=h*i.lengthM/2;c=Math.max(c,this.ground.heightAt(e+r.eastM*u+o.eastM*d,t+r.northM*u+o.northM*d))}return c}place(e,t){const i=[];let n;for(const s of e){const r=s.sizeM??n?.sizeM??_t.DEFAULT_SIZE,o={headingDeg:s.attitude?.headingDeg??n?.attitude.headingDeg??0,pitchDeg:s.attitude?.pitchDeg??n?.attitude.pitchDeg??0,rollDeg:s.attitude?.rollDeg??n?.attitude.rollDeg??0},c={color:s.appearance?.color??n?.appearance.color??_t.DEFAULT_APPEARANCE.color,albedo:s.appearance?.albedo??n?.appearance.albedo??_t.DEFAULT_APPEARANCE.albedo,luminanceCdM2:s.appearance?.luminanceCdM2??n?.appearance.luminanceCdM2??_t.DEFAULT_APPEARANCE.luminanceCdM2},l=this.positionOf(s,t)??(n&&{eastM:n.eastM,northM:n.northM,vertical:this.verticalOf(s)??n.vertical});if(!l)continue;const h=s.flame??n?.flame,u=s.present??n?.present??!0;n={t:s.t,...l,sizeM:r,attitude:o,appearance:c,flame:h,present:u},i.push(n)}return i}verticalOf(e){if(e.onGround)return{aboveGroundM:0};if(e.altitudeAboveGroundM!==void 0)return{aboveGroundM:e.altitudeAboveGroundM}}positionOf(e,t){if(e.eastM!==void 0&&e.northM!==void 0)return{eastM:e.eastM,northM:e.northM,vertical:this.verticalOf(e)??{aboveGroundM:0}};if(e.azimuthDeg===void 0||e.altitudeDeg===void 0)return;const i=t(e.t);if(!i)return;const n=e.distanceM??(e.onGround?_t.lineOfSightMeetsGround(i,e.azimuthDeg,e.altitudeDeg,this.ground):void 0);if(n===void 0)return;const s=_t.directionOf(e.azimuthDeg,e.altitudeDeg),r=i.eastM+s.eastM*n,o=i.northM+s.northM*n;return{eastM:r,northM:o,vertical:this.verticalOf(e)??{upM:i.upM+s.upM*n}}}static lerp(e,t,i){return e+(t-e)*i}static lerpAngle(e,t,i){const n=((t-e)%360+540)%360-180;return((e+n*i)%360+360)%360}}const ja=Math.PI/180,$r=180/Math.PI;class Xt{constructor(e){this.timeline=e}static DIRECTION_TOLERANCE_DEG=1;static SIZE_TOLERANCE=1.5;static RINGS=12;static SEGMENTS=24;at(e,t,i,n){const s=[];for(const r of t){const o=Xt.projectionOf(r,i,n?.(r));if(o)for(const c of r.explains){const l=this.timeline.getInterpolatedShapeAt(e,c);!l||l.transparency>=1||s.push({...Xt.compare(c,r.id,{aim:l.aim,angular:l.angular},o),title:l.title})}}return s}static compare(e,t,i,n){const s=[],r=i.aim?Xt.separationDeg(i.aim,n.aim):void 0;if(r!==void 0){const l=Math.max(i.angular?.widthDeg??0,n.angular.widthDeg)/2;r>Math.max(Xt.DIRECTION_TOLERANCE_DEG,l)&&s.push("direction")}const o=i.angular&&i.angular.widthDeg>0?n.angular.widthDeg/i.angular.widthDeg:void 0,c=i.angular&&i.angular.heightDeg>0?n.angular.heightDeg/i.angular.heightDeg:void 0;return o!==void 0&&!Xt.withinSize(o)&&s.push("width"),c!==void 0&&!Xt.withinSize(c)&&s.push("height"),{sourceId:e,bodyId:t,stated:i,predicted:n,separationDeg:r,widthRatio:o,heightRatio:c,disagreements:s}}static projectionOf(e,t,i){const n=i&&i.length>0?i:Xt.outlineOf(e),s=i&&i.length>0?Xt.centreOf(i):e,r=Xt.normalized({eastM:s.eastM-t.eastM,northM:s.northM-t.northM,upM:s.upM-t.upM});if(!r)return;const o=Xt.normalized({eastM:r.northM,northM:-r.eastM,upM:0})??{eastM:1,northM:0,upM:0},c=Xt.cross(o,r);let l=1/0,h=-1/0,u=1/0,d=-1/0;for(const f of n){const p={eastM:f.eastM-t.eastM,northM:f.northM-t.northM,upM:f.upM-t.upM},v=Xt.dot(p,r);if(v<=0)return;const m=Math.atan2(Xt.dot(p,o),v),g=Math.atan2(Xt.dot(p,c),v);l=Math.min(l,m),h=Math.max(h,m),u=Math.min(u,g),d=Math.max(d,g)}return{aim:{azimuthDeg:(Math.atan2(r.eastM,r.northM)*$r+360)%360,altitudeDeg:Math.asin(Math.max(-1,Math.min(1,r.upM)))*$r},angular:{widthDeg:(h-l)*$r,heightDeg:(d-u)*$r}}}static centreOf(e){const t=i=>(Math.min(...e.map(n=>n[i]))+Math.max(...e.map(n=>n[i])))/2;return{eastM:t("eastM"),northM:t("northM"),upM:t("upM")}}static separationDeg(e,t){const i=e.altitudeDeg*ja,n=t.altitudeDeg*ja,s=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((e.azimuthDeg-t.azimuthDeg)*ja);return Math.acos(Math.max(-1,Math.min(1,s)))*$r}static withinSize(e){return e<=Xt.SIZE_TOLERANCE&&e>=1/Xt.SIZE_TOLERANCE}static outlineOf(e){const t=e.sizeM.widthM/2,i=e.sizeM.lengthM/2,n=e.sizeM.heightM/2,s=[],r=e.model.url===void 0?e.model.id:void 0;if(r!==void 0&&r!=="box"&&p1.includes(r))for(let u=0;u<=Xt.RINGS;u++){const d=u/Xt.RINGS*Math.PI;for(let f=0;f<Xt.SEGMENTS;f++){const p=f/Xt.SEGMENTS*2*Math.PI;s.push([t*Math.sin(d)*Math.cos(p),i*Math.sin(d)*Math.sin(p),n*Math.cos(d)])}}else for(const u of[-t,t])for(const d of[-i,i])for(const f of[-n,n])s.push([u,d,f]);const c=e.attitude.headingDeg*ja,l=e.attitude.pitchDeg*ja,h=e.attitude.rollDeg*ja;return s.map(([u,d,f])=>{const p=u*Math.cos(h)+f*Math.sin(h),v=-u*Math.sin(h)+f*Math.cos(h),m=d*Math.cos(l)-v*Math.sin(l),g=d*Math.sin(l)+v*Math.cos(l);return{eastM:e.eastM+p*Math.cos(c)+m*Math.sin(c),northM:e.northM-p*Math.sin(c)+m*Math.cos(c),upM:e.upM+g}})}static dot(e,t){return e.eastM*t.eastM+e.northM*t.northM+e.upM*t.upM}static cross(e,t){return{eastM:e.northM*t.upM-e.upM*t.northM,northM:e.upM*t.eastM-e.eastM*t.upM,upM:e.eastM*t.northM-e.northM*t.eastM}}static normalized(e){const t=Math.hypot(e.eastM,e.northM,e.upM);return t>1e-9?{eastM:e.eastM/t,northM:e.northM/t,upM:e.upM/t}:void 0}}Km();const nE={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"}},sE=["en","fr"],aE={en:"{name} — mag {mag}, {alt}° above the horizon",fr:"{name} — mag {mag}, {alt}° au-dessus de l'horizon"},rE={en:"{name} — satellite, mag {mag}, {height} km up",fr:"{name} — satellite, mag {mag}, à {height} km d'altitude"},oE="satellites-change",cE="rr0-confrontation",lE={en:"{name} — mag {mag}, {alt}° below the horizontal",fr:"{name} — mag {mag}, {alt}° sous l'horizontale"},Dm="comet:",Cm="nova:",hE={building:{en:"Building",fr:"Bâtiment"},tree:{en:"Tree",fr:"Arbre"},shrub:{en:"Shrub",fr:"Buisson"},crop:{en:"Crop row",fr:"Rang de culture"},mound:{en:"Stone heap",fr:"Tas de pierres"},streetlight:{en:"Streetlight",fr:"Lampadaire"},vehicle:{en:"Vehicle",fr:"Véhicule"},witness:{en:"Witness",fr:"Témoin"},aircraft:{en:"Aircraft",fr:"Aéronef"},entity:{en:"Being",fr:"Être"}},uE=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,dE=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,fE=-18,pE={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},Qh={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class p0 extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","deep-star-catalog-src","show-compass","max-pixel-ratio",ar,rr]}shadow;stageElement;frameElement;sceneCanvas;ufoElement;sceneRenderer;hoverTooltip;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;distanceHypotheses=new Map;depths=new Map;directionScratch=new D;meteorScheduleFor;lightningScheduleFor;lightningFlashes=[];lastLightningT;lastTimeMs=0;interpretationShown;confrontationReadings=[];confrontationSignature="";comparing=!1;inTheRound=!0;lastSkyKey;starCatalog;starCatalogRequest=0;static tleArchive=new Ai;satellitesFor;satelliteRequest=0;satelliteStatus="none";satellites;satellitePassesMemo;starCatalogDepth=0;weatherAudio=new Jb;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,i=t.getBoundingClientRect();if(i.width===0||i.height===0)return;const n=(e.clientX-i.left)/i.width*t.width,s=(e.clientY-i.top)/i.height*t.height;if(this.ufoElement.hasVisibleShapeAt(n,s)){this.hoverTooltip.hidden=!0;return}const r=(e.clientX-i.left)/i.width*2-1,o=-((e.clientY-i.top)/i.height*2-1),c=Td(Kc.preferencesFor(this),sE),l=this.sceneRenderer.pickBodyAt(r,o);if(l){this.showHoverTooltip(e,this.bodyName(l,c));return}const h=this.sceneRenderer.pickDecorAt(r,o),u=h?this.ufoElement.sighting.decor.find(p=>p.id===h):void 0;if(u){this.showHoverTooltip(e,this.said.read(u.title)||hE[u.kind][c]);return}const d=this.sceneRenderer.pickSatelliteAt(r,o);if(d){this.showHoverTooltip(e,rE[c].replace("{name}",d.name).replace("{mag}",d.magnitude.toLocaleString(void 0,{maximumFractionDigits:1})).replace("{height}",Math.round(d.heightKm).toLocaleString()));return}const f=this.sceneRenderer.pickStarAt(r,o);if(f){const p=f.star.mag,v=f.altitudeDeg,m=(v<0?lE:aE)[c];this.showHoverTooltip(e,m.replace("{name}",f.star.name[c]).replace("{mag}",p.toLocaleString(void 0,{maximumFractionDigits:Math.abs(p)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(v)))));return}this.hoverTooltip.hidden=!0};bodyName(e,t){const i=e.startsWith(Dm)?e.slice(Dm.length):void 0,n=i?v1.find(r=>r.id===i):void 0,s=e.startsWith(Cm)?Am.byId(e.slice(Cm.length)):void 0;return n?.name[t]??s?.name[t]??nE[e]?.[t]??e}showHoverTooltip(e,t){this.hoverTooltip.textContent=t,this.hoverTooltip.hidden=!1;const i=this.stageElement.getBoundingClientRect();this.hoverTooltip.style.left=`${e.clientX-i.left+12}px`,this.hoverTooltip.style.top=`${e.clientY-i.top+12}px`}handlePointerLeave=()=>{this.hoverTooltip.hidden=!0,this.sceneRenderer.setCompassHovered(!1)};handleLightningFlash(e){clearTimeout(this.thunderTimeoutId),this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),oi.thunderDelayMs(e))}handleFirstInteraction=()=>{this.removeEventListener("pointerdown",this.handleFirstInteraction,!0),this.removeEventListener("keydown",this.handleFirstInteraction,!0),this.weatherAudio.resume(),this.setWeather(Js(this.ufoElement.sighting,this.lastTimeMs))};handleTimeUpdate=e=>{this.lastTimeMs=e.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.playbackState==="playing"&&this.sceneRenderer.frame(performance.now())};syncAnimationsToPlayback(){const e=this.ufoElement.playbackState==="playing",t=e||this.animateWhilePaused;this.sceneRenderer.setAnimationsRunning(t,e),this.weatherAudio.setPaused(!t),t||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${R1}</style>${T1}`,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 Wt(this.sceneCanvas);const t=this.shadow.getElementById("scene-loader");this.sceneRenderer.onFirstFrameHold=i=>{t.hidden=!i},this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(iu),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.paintsShapes=!1,this.forwardPlayerAttributes(),this.ufoElement.addEventListener("lookat",i=>this.lookToward(i.detail)),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.sceneRenderer.onMapSubjectBounds=i=>this.ufoElement.setMapSubjectBounds(i),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.addEventListener("referenceview",i=>this.applyReferenceView(i.detail)),this.ufoElement.canvasElement.addEventListener("pointermove",this.handlePointerMove),this.ufoElement.canvasElement.addEventListener("pointerleave",this.handlePointerLeave),this.addEventListener("pointerdown",this.handleFirstInteraction,!0),this.addEventListener("keydown",this.handleFirstInteraction,!0)}get said(){return this.saidTexts??=new ks(Kc.preferencesFor(this))}saidTexts;connectedCallback(){this.saidTexts=void 0,this.sceneRenderer.restoreContext(),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(),queueMicrotask(()=>{this.isConnected||this.sceneRenderer.releaseContext()})}attributeChangedCallback(e,t,i){if(e==="src"&&i&&i!==t&&this.isConnected&&this.loadFromSrc(i),(e==="star-catalog-src"||e==="deep-star-catalog-src")&&i!==t&&this.isConnected&&this.loadStars(),e==="show-compass"&&i!==t&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),e==="max-pixel-ratio"&&i!==t){const n=Number(i);this.sceneRenderer.setMaxPixelRatio(Number.isFinite(n)&&n>0?n:Math.min(window.devicePixelRatio||1,2))}(e===ar||e===rr)&&i!==t&&this.forwardPlayerAttributes()}forwardPlayerAttributes(){for(const e of[ar,rr])this.ufoElement.toggleAttribute(e,this.hasAttribute(e))}setCompassForced(e){this.sceneRenderer.setCompassForced(e)}lookToward(e){const t=ai(this.ufoElement.sighting,this.lastTimeMs);if(e.kind==="witness"||t?.lat===void 0||t.lng===void 0||t.headingDeg===void 0){this.setLookOffset(0,0);return}const{x:i,z:n}=li(e.lat,e.lng,t.lat,t.lng);if(Math.hypot(i,n)<1)return this.setLookOffset(0,0);const s=(Math.atan2(i,-n)*180/Math.PI+360)%360;this.setLookOffset(((s-t.headingDeg)%360+540)%360-180,-t.pitchDeg)}setLookOffset(e,t){this.sceneRenderer.setLookOffset(e,t),this.ufoElement.setLookOffset(e,t),this.updateAstronomy(this.lastTimeMs)}setIndoorLook(e,t){this.sceneRenderer.setIndoorLook(e,t)}setCloudRendering(e){this.sceneRenderer.setCloudRendering(e)}setWeather(e){this.sceneRenderer.setWeather(e),this.weatherAudio.setAmbient(e.precipitationType,e.precipitationIntensity,e.windSpeed)}pickCloudAt(e,t){return this.sceneRenderer.pickCloudAt(e,t)}cloudDirectionAt(e,t){return this.sceneRenderer.cloudDirectionAt(e,t)}pickDecorAt(e,t){return this.sceneRenderer.pickDecorAt(e,t)}resumeWeatherAudio(){this.weatherAudio.resume()}async loadFromSrc(e){this.sightingData=await Nm.json(e)}get sightingData(){return this.ufoElement.sightingData}set sightingData(e){this.ufoElement.sightingData=e,this.interpretationShown=this.inTheRound?this.ufoElement.sighting.interpretation:void 0,this.applyFrameFormat(),this.lastTimeMs=0,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(0)}referenceAspect(e){return this.sceneRenderer.referenceAspect(e)}screenPointOf(e){return this.sceneRenderer.screenPointOf(e)}directionAt(e,t){return this.sceneRenderer.directionAt(e,t)}referenceFailedToLoad(e){return this.sceneRenderer.referenceFailedToLoad(e)}applyReferenceView(e){this.sceneRenderer.setReferencesShown(e.shown);for(const t of this.ufoElement.sighting.references)this.sceneRenderer.setReferenceView(t.id,{opacity:e.opacity})}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}get currentRoadAttribution(){return this.sceneRenderer.currentRoadAttribution}setTerrainProviders(e){this.sceneRenderer.setTerrainProviders(e)}setDecorModelProvider(e){this.sceneRenderer.setDecorModelProvider(e)}get decorModelCredits(){return this.sceneRenderer.currentDecorModelCredits}applyFrameFormat(){const e=this.ufoElement.sighting.instrument,t=Rt.CANVAS_HEIGHT_PX,i=ri.frameWidthPx(e,t);this.frameElement.style.setProperty("--frame-aspect",`${i} / ${t}`)}resizeToStage(){const e=this.frameElement.getBoundingClientRect(),t=Math.max(1,Math.round(e.width)),i=Math.max(1,Math.round(e.height));this.sceneCanvas.width=t,this.sceneCanvas.height=i,this.sceneRenderer.resize(t,i)}async loadStars(){const e=[{magnitudeLimit:Kh,url:this.getAttribute("star-catalog-src")??uE},{magnitudeLimit:$h,url:this.getAttribute("deep-star-catalog-src")??dE}],t=this.instrumentReach(),i=++this.starCatalogRequest;this.starCatalogDepth=t>Kh?$h:Kh;const n=await Hn.upTo(e,t);i===this.starCatalogRequest&&(this.starCatalog=n,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=$h||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const e=this.ufoElement.sighting,t=Ni.gainFor(e.instrument,{fNumber:ai(e,0)?.fNumber,fieldOfViewDeg:Wi.fovOf(e,0),exposureSeconds:e.exposure});return Gc(fE,t)}updateAstronomy(e){this.ensureStarsDeepEnough(),this.applySceneAt(e);const t=bn.windowEndingAt(e,this.exposureSeconds()),i=t.seconds,n=this.degreesPerPixelAt(e),s=xa.instants(i,n),r=Math.max(s,this.ufoElement.exposureTimes(e).length,bn.instants(this.ufoElement.sighting.decor,ai(this.ufoElement.sighting,e)?.elevationM??0,t.fromMs,i,n));if(r<=1){this.sceneRenderer.setExposure(1);return}this.sceneRenderer.setExposure(r,o=>this.applySceneAt(t.fromMs+t.ms*o/(r-1),{sky:Math.floor(o*s/r)!==Math.floor((o-1)*s/r),stepMs:t.ms/r}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(e){const t=this.sceneCanvas.height;return t<=0?0:Wi.fovOf(this.ufoElement.sighting,e)/t}applySceneAt(e,t){const i=this.ufoElement.sighting;this.setWeather(Js(i,e)),this.sceneRenderer.setInstrument(i.instrument),this.updateMeteorShower(i,e),this.updateLightning(i,e,t!==void 0),this.sceneRenderer.setDecor(i.decor),this.sceneRenderer.setReferences(i.references);const n=ai(i,e),s=ai(i,0),r=Js(i,0),o=Object.fromEntries(Xc(Js(i,e)).map(w=>[w.id,E0(e,i.weatherTrack,r,s,n,w.id)]));this.sceneRenderer.setCloudOffset(E0(e,i.weatherTrack,r,s,n),o),this.sceneRenderer.setObserverPose(n??Qh),this.sceneRenderer.setLensOptics(this.lensOpticsAt(e)),this.sceneRenderer.setInstrumentGain(Ni.gainFor(i.instrument,{fNumber:n?.fNumber,fieldOfViewDeg:Wi.fovOf(i,e),exposureSeconds:i.exposure}),i.instrument.detailUm!==void 0),this.sceneRenderer.setGait(si.of(i)?.offsetAt(e)??si.STILL),this.sceneRenderer.updateDecorAnchoring(ai(i,0),n,e),this.placeBodiesAt(e,t===void 0),this.sceneRenderer.updateDecorLitState(e,t?.stepMs??0),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng,()=>{this.placeBodiesAt(this.lastTimeMs,!0),this.sceneRenderer.render()}),this.sceneRenderer.setStatedRoads(i.roads),this.pushPhenomenaAt(e);const c=n?.lat??Qh.lat,l=n?.lng??Qh.lng,h=yc(i.event.time??{},l,i.event.utcOffsetHours),u={lat:c,lng:l,elevationM:n?.elevationM??0};if(this.pushSatellitesAt(h,e,u),t&&!t.sky)return;if(!h){this.sceneRenderer.setAstronomy(pE);return}const d=new Date(h.getTime()+e),f=Math.max(1,Math.round(.25*this.degreesPerPixelAt(e)/xa.DEG_PER_SECOND*1e3)),p=Math.max(1e-8,this.degreesPerPixelAt(e)*.1),v=`${Math.floor(d.getTime()/f)}|${Math.round(c/p)}|${Math.round(l/p)}|${Math.round(u.elevationM)}|${this.starCatalog?this.starCatalogDepth:0}`;if(v===this.lastSkyKey){this.sceneRenderer.render();return}this.lastSkyKey=v;const m={...Ah("Sun",d,u),magnitude:Th("Sun",d)},g={...Ah("Moon",d,u),phase:tw(d),magnitude:Th("Moon",d)},_=ew.map(w=>({body:w,position:Ah(w,d,u),magnitude:Th(w,d)}));this.sceneRenderer.setAstronomy({sun:m,moon:g,planets:_,comet:this.cometAt(d,u),novae:Am.appearancesAt(d,u).map(({outburst:w,position:M,magnitude:S})=>({id:w.id,position:M,magnitude:S})),stars:this.starCatalog?{catalog:this.starCatalog,date:d,observer:u}:void 0,frame:{date:d,observer:u}}),this.ufoElement.setSunAltitude(m.altitudeDeg)}pushSatellitesAt(e,t,i){if(this.ensureSatellites(e),!e||!this.satellites){this.sceneRenderer.setSatellites([]);return}const n=new Date(e.getTime()+t),s=[];for(const r of this.satellites.passes.positionsAt(n,i,-1))r.magnitude!==void 0&&s.push({norad:r.object.norad,name:r.object.name,position:{altitudeDeg:r.altitudeDeg,azimuthDeg:r.azimuthDeg},magnitude:r.magnitude,heightKm:r.heightKm});this.sceneRenderer.setSatellites(s)}ensureSatellites(e){const t=e?String(e.getTime()):"";if(t===this.satellitesFor)return;this.satellitesFor=t,this.satellites=void 0,this.satellitePassesMemo=void 0;const i=++this.satelliteRequest;if(!e){this.satelliteStatus="none";return}this.satelliteStatus="loading";const n=r=>{i===this.satelliteRequest&&(this.satelliteStatus=r,this.dispatchEvent(new CustomEvent(oE)))},s=p0.tleArchive;(async()=>{if(!await s.covers(e))return n("outside");const[r,o]=await Promise.all([s.at(e),Wc(()=>import("./SatellitePasses-Pfro2-0Z.js"),[],import.meta.url)]);if(i===this.satelliteRequest){if(!r)return n("unavailable");this.satellites={snapshot:r,passes:new o.SatellitePasses(r.objects)},n("ready"),this.updateAstronomy(this.lastTimeMs)}})().catch(()=>n("unavailable"))}get satelliteState(){const e=this.satellites?.snapshot;return{status:this.satelliteStatus,coverage:e?.coverage,credit:e?.credit,creditUrl:e?.creditUrl}}satellitePassesDuring(e){const t=this.satellites,i=this.ufoElement.sighting,n=ai(i,0),s=i.event.place?.[0],r=n?.lat??s?.lat,o=n?.lng??s?.lng;if(!t||r===void 0||o===void 0)return[];const c=yc(i.event.time??{},o,i.event.utcOffsetHours);if(!c)return[];const l=Math.min(Math.max(e,0),4*36e5),h={lat:r,lng:o,elevationM:n?.elevationM??0},u=JSON.stringify([this.satellitesFor,c.getTime(),r,o,h.elevationM,l]);if(this.satellitePassesMemo?.key===u)return this.satellitePassesMemo.passes;const d=Math.max(10,Math.ceil(l/1e3/600)),f=t.passes.passesDuring(c,new Date(c.getTime()+l),h,d);return this.satellitePassesMemo={key:u,passes:f},f}cometAt(e,t){const i=jb.brightestAt(e,t);if(i)return{id:i.apparition.id,position:i.position,tailEnd:i.tailEnd,magnitude:i.magnitude}}pushPhenomenaAt(e){const t=this.ufoElement.sighting;t!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.distanceHypotheses.clear(),this.sizeEstimatesFor=t);const i=t.timeline,n=this.ufoElement.canvasElement,s=this.ufoElement.frameShiftPx,r=this.projectionAt(e),o=new Map,c=new Map,l=new Set;for(const p of i.sourceIds){const v=i.getInterpolatedShapeAt(e,p);if(!v)continue;const m={...v,bounds:{...v.bounds,x:v.bounds.x+s.x,y:v.bounds.y+s.y}};o.set(p,m);const g=v.aim?this.sceneRenderer.screenPointOf(wn.directionOf(v.aim,this.directionScratch)):{ndcX:(m.bounds.x+m.bounds.width/2)/n.width*2-1,ndcY:-((m.bounds.y+m.bounds.height/2)/n.height*2-1)},_=g!==void 0&&Math.abs(g.ndcX)<=1&&Math.abs(g.ndcY)<=1,w=_?this.sceneRenderer.decorDistancesAt(g.ndcX,g.ndcY,p):{};l.add(p),(_||v.aim)&&l.delete(p);const M=v.angular?.widthDeg??r.pxToDeg(v.bounds.width),S=this.sizeEstimateOf(p);S.add(M,w);const b=lo.of(t,p);c.set(p,Li.resolve({hypothesisM:this.distanceHypotheses.get(p),derivedM:b&&M>0?Rt.distanceMAt(b.widthM,M):void 0,range:S.distanceRangeAt(M),crossing:w}))}for(const[p,v]of o)for(const[m,g]of o){if(m===p||g.transparency>=1||g.bounds.width*g.bounds.height<=v.bounds.width*v.bounds.height||!(v.bounds.x>=g.bounds.x&&v.bounds.y>=g.bounds.y&&v.bounds.x+v.bounds.width<=g.bounds.x+g.bounds.width&&v.bounds.y+v.bounds.height<=g.bounds.y+g.bounds.height))continue;const w=c.get(m);w&&c.set(p,{distanceM:w.distanceM*.999,basis:w.basis});break}this.depths=c;const h=i.sourceIds,u=[];for(const[p,v]of o)u.push({sourceId:p,shape:v,distanceM:c.get(p).distanceM,renderOrder:h.indexOf(p),aim:v.aim,hidden:l.has(p)||this.interpretationShown!==void 0&&!this.comparing,ghost:this.interpretationShown!==void 0&&this.comparing});const f=(ai(t,e)?.rollDeg??0)+(si.of(t)?.offsetAt(e)??si.STILL).rollDeg;this.sceneRenderer.setPhenomena(u,{projection:r,canvasWidthPx:n.width,canvasHeightPx:n.height,scale:Math.max(1,this.sceneCanvas.height/Math.max(1,n.height)),starPoints:ri.starPointsOf(t.instrument),rollRad:f*Math.PI/180})}get interpretation(){return this.interpretationShown}set interpretation(e){this.interpretationShown=e,this.updateAstronomy(this.lastTimeMs)}get testimonyInTheRound(){return this.inTheRound}set testimonyInTheRound(e){this.inTheRound=e}get compareTestimony(){return this.comparing}set compareTestimony(e){this.comparing=e,this.updateAstronomy(this.lastTimeMs)}get confrontation(){return this.confrontationReadings}placeBodiesAt(e,t){const i=this.interpretationShown,n=this.ufoElement.sighting;let s=[],r=[];const o=this.sceneRenderer.bodyGround,c=p=>_t.eyeOf(n,p,o);i&&(s=i.bodies.map(p=>new _t(p,o,c).at(e)).filter(p=>p!==void 0));const l=Js(n,e),h=l.windDirectionDeg*Math.PI/180,u={x:l.windSpeed*Math.sin(h),z:-l.windSpeed*Math.cos(h)};this.sceneRenderer.setBodies(s,e/1e3,i?.bodies.map(p=>p.id)??[],i?.smoke??[],u);const d=i&&this.comparing?c(e):void 0;if(d&&(r=new Xt(n.timeline).at(e,s,d,p=>p.outlineNode?this.sceneRenderer.bodyOutline?.(p.id,p.outlineNode):void 0)),this.confrontationReadings=r,!t)return;const f=JSON.stringify(r);f!==this.confrontationSignature&&(this.confrontationSignature=f,this.dispatchEvent(new CustomEvent(cE,{detail:r})))}setDistanceHypothesis(e,t){t===void 0||!(t>0)?this.distanceHypotheses.delete(e):this.distanceHypotheses.set(e,t),this.updateAstronomy(this.lastTimeMs)}depthOf(e){return this.depths.get(e)}sizeRangeOf(e){return this.sizeEstimateOf(e).sizeRange}distanceRangeAt(e,t){const i=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(t,e);if(!i)return{};const n=i.angular?.widthDeg??this.projectionAt(t).pxToDeg(i.bounds.width);return this.sizeEstimateOf(e).distanceRangeAt(n)}sizeContradictory(e){return this.sizeEstimateOf(e).contradictory}updateMeteorShower(e,t){this.ensureMeteorSchedule(e),this.sceneRenderer.updateMeteors(t)}updateLightning(e,t,i){if(this.ensureLightningSchedule(e),this.sceneRenderer.updateLightning(t),i)return;const n=this.lastLightningT;if(this.lastLightningT=t,n===void 0||t<n||this.ufoElement.playbackState!=="playing")return;const s=this.lightningFlashes.filter(r=>r.t>n&&r.t<=t).pop();s&&Js(e,s.t).storm&&this.handleLightningFlash(s)}ensureLightningSchedule(e){const t=Js(e,0).precipitationIntensity,i=`${this.meteorInputsOf(e)}|${t}`;if(i===this.lightningScheduleFor)return;this.lightningScheduleFor=i;const n=e.event.time,s=e.event.place?.[0],r=n?.year!==void 0?yc(n,s?.lng??0,e.event.utcOffsetHours):void 0,o=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,c=Math.round((r?.getTime()??0)/1e3)+Math.round((s?.lat??0)*1e3)+7;this.lightningFlashes=oi.schedule({durationMs:o,seed:c,intensity:t}),this.sceneRenderer.setLightning(this.lightningFlashes)}ensureMeteorSchedule(e){const t=this.meteorInputsOf(e);t!==this.meteorScheduleFor&&(this.meteorScheduleFor=t,this.scheduleMeteors(e))}meteorInputsOf(e){const t=e.event.place?.[0],i=e.event.time;return JSON.stringify([t?.lat,t?.lng,i?.year,i?.month,i?.day,i?.hour,i?.minute,i?.second,e.event.utcOffsetHours,e.event.durationSeconds,e.timeline.duration])}scheduleMeteors(e){const t=e.event.place?.[0],i=e.event.time,n=t?.lat!==void 0&&t.lng!==void 0&&i?.year!==void 0?yc(i,t.lng,e.event.utcOffsetHours):void 0;if(!n||t?.lat===void 0||t.lng===void 0){this.sceneRenderer.setMeteorShower([],0,0);return}const s={lat:t.lat,lng:t.lng,elevationM:0},r=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,o=Math.round(n.getTime()/1e3)+Math.round(t.lat*1e3),c=qt.schedule({ratePerHour:qt.observedRatePerHour(qt.apexPosition(n,s).altitudeDeg),durationMs:r,velocityKmS:qt.TYPICAL_VELOCITY_KM_S,seed:o}),l=Jh.activeAt(n).map(u=>{const d=Jh.radiantPosition(u.shower,n,s);return{entry:u,position:d,rate:Jh.observedRatePerHour(u.zhr,d.altitudeDeg,u.shower.populationIndex)}}).sort((u,d)=>d.rate-u.rate)[0];if(!l||l.rate<=0){this.sceneRenderer.setMeteorShower(c,0,0);return}const h=va.schedule({ratePerHour:l.rate,durationMs:r,velocityKmS:l.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...c],l.position.altitudeDeg,l.position.azimuthDeg)}meteorByRank(e){this.ensureMeteorSchedule(this.ufoElement.sighting);const t=[...this.sceneRenderer.meteorSchedule].filter(s=>s.t+s.durationMs<=this.ufoElement.seekableDuration).sort((s,r)=>r.brightness-s.brightness);if(t.length===0)return;const i=t[e%t.length],n=this.sceneRenderer.meteorMidpoint(i);if(n)return{t:Math.round(i.t+i.durationMs*.45),...n}}lensOpticsAt(e){const t=this.ufoElement.sighting,i=t.instrument,n=i.frame,s=ai(t,e),r=s?.fNumber??i.fNumber;if(!n||r===void 0)return;const o=ri.focalLengthMmFor(i,Wi.fovOf(t,e));if(o!==void 0)return{focalLengthMm:o,fNumber:r,focusDistance:s?.focusDistanceM??0,frameHeightMm:n.heightMm}}projectionAt(e){const t=this.ufoElement.sighting;return ps.of(t.instrument,Rt.CANVAS_HEIGHT_PX,Wi.fovOf(t,e))}sizeEstimateOf(e){let t=this.sizeEstimates.get(e);return t||(t=new eE,this.sizeEstimates.set(e,t)),t}}const Im="rr0-scene";function mE(){Km(),customElements.get(Im)||customElements.define(Im,p0)}mE();export{jv as $,yE as A,et as B,se as C,Gf as D,De as E,EE as F,SE as G,gg as H,_E as I,wE as J,us as K,Ro as L,hM as M,ko as N,Pt as O,Eg as P,Qn as Q,Mo as R,Fi as S,gE as T,Dt as U,xe as V,Vi as W,xE as X,Cn as Y,mg as Z,bE as _,ME as a,Jc as a0,Gu as a1,nl as a2,xi as a3,wg as a4,Yd as a5,Kd as a6,nt as a7,qs as a8,To as a9,vn as aa,ys as ab,vE as b,RE as c,Qc as d,TE as e,Ze as f,D as g,Af as h,AE as i,DE as j,Kv as k,da as l,kl as m,Q2 as n,st as o,wt as p,uu as q,yi as r,vg as s,_s as t,sM as u,oa as v,tn as w,mn as x,St as y,ut as z};
|