@rr0/ufoathome 0.63.6 → 0.63.7
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.
|
@@ -624,15 +624,15 @@ input[type=range] {
|
|
|
624
624
|
pointer-events: none;
|
|
625
625
|
white-space: nowrap;
|
|
626
626
|
}
|
|
627
|
-
`,oo=[{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 Yt{static get default(){return oo[0]}static byId(e){return oo.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:Yt.UNAIDED_FIELD_DEG}static aspectOf(e){const t=e.frame;return t?t.widthMm/t.heightMm:Yt.UNAIDED_ASPECT}static frameWidthPx(e,t){return Math.round(t*Yt.aspectOf(e))}static availableAt(e){return e===void 0?oo:oo.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??Yt.LENS_FLARE_ARTIFACTS}static starPointsOf(e){const t=e.apertureBlades;return t===void 0||t<3?0:t%2===0?t:t*2}}class Ha{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:r,headingDeg:a}=i.pose;n===void 0||r===void 0||t.push({t:i.t,lat:n,lng:r,headingDeg:a})}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 Ha(t)}get moved(){return this.spanM>Ha.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(hi(t,e.east,t,e.west).x),Math.abs(hi(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,r=Math.max(this.spanM*(1+t),e)/2;return{north:qn(0,-r,i,n).lat,south:qn(0,r,i,n).lat,east:qn(r,0,i,n).lng,west:qn(-r,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 qt{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=Ha.of(e);if(!t||t.points.length<2)return;const i=[];let n=0;for(let r=1;r<t.points.length;r++){const a=t.points[r-1],o=t.points[r],c=(o.t-a.t)/1e3;if(c<=0)continue;const l=hi(o.lat,o.lng,a.lat,a.lng),h=l.x,u=-l.z,d=Math.hypot(h,u),f=d/c,p=qt.stepHzFor(f);i.push({startMs:a.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 r=0;r<i.length;r++){const a=i[r-1],o=i[r+1];i[r].rampsIn=a===void 0||a.stepHz===0,i[r].rampsOut=o===void 0||o.stepHz===0}if(i.some(r=>r.stepHz>0))return new qt(i,1-(e.instrument.stabilization??0))}static stepHzFor(e){return e<qt.SLOWEST_WALK_M_PER_S||e>qt.FASTEST_WALK_M_PER_S?0:qt.REFERENCE_STEP_HZ*Math.pow(e/qt.REFERENCE_SPEED_M_PER_S,qt.CADENCE_EXPONENT)}offsetAt(e){const t=this.stretches.find(c=>e>=c.startMs&&e<=c.endMs);if(!t||t.stepHz===0)return qt.STILL;const i=t.stepsBefore+t.stepHz*(e-t.startMs)/1e3,n=2*Math.PI*i,r=this.amplitudeAt(t,e),a=qt.SWAY_M*r*Math.cos(n/2),o=r*this.rotationPassed*t.speedMPerS/qt.REFERENCE_SPEED_M_PER_S;return{eastM:a*t.northUnit,northM:-a*t.eastUnit,upM:qt.RISE_M_PER_M_PER_S*t.speedMPerS*r*Math.cos(n),rollDeg:qt.HEAD_ROLL_DEG*o*Math.cos(n/2),pitchDeg:-1.25*o*Math.cos(n),yawDeg:qt.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 r=t-e.startMs,a=e.endMs-t,o=Math.min(e.rampsIn?r/n:1,e.rampsOut?a/n:1,1);return(1-Math.cos(Math.PI*Math.max(o,0)))/2}}class yt{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/yt.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 Vg(s,e,t){if(!s||!e)return t<1?s:e;const i=((e.azimuthDeg-s.azimuthDeg)%360+540)%360-180;return{azimuthDeg:((s.azimuthDeg+i*t)%360+360)%360,altitudeDeg:s.altitudeDeg+(e.altitudeDeg-s.altitudeDeg)*t}}function Wg(s,e,t){const{bounds:i}=s;return e>=i.x&&e<=i.x+i.width&&t>=i.y&&t<=i.y+i.height}function Ci(s,e,t){return s+(e-s)*t}function Vd(s){const e=/^#([0-9a-f]{6})$/i.exec(s);if(!e)return;const t=parseInt(e[1],16);return[t>>16&255,t>>8&255,t&255]}function Xg(s){return`#${s.map(e=>Math.round(e).toString(16).padStart(2,"0")).join("")}`}function qg(s,e,t){const i=Vd(s),n=Vd(e);return!i||!n?t<1?s:e:Xg([Ci(i[0],n[0],t),Ci(i[1],n[1],t),Ci(i[2],n[2],t)])}function Yg(s,e,t){const i={x:Ci(s.bounds.x,e.bounds.x,t),y:Ci(s.bounds.y,e.bounds.y,t),width:Ci(s.bounds.width,e.bounds.width,t),height:Ci(s.bounds.height,e.bounds.height,t)},n=Ci(s.angle,e.angle,t),r=Ci(s.transparency,e.transparency,t),a=Ci(s.haloScale,e.haloScale,t),o=Ci(s.blur??0,e.blur??0,t),c=Ci(s.brightness??0,e.brightness??0,t),l=qg(s.color,e.color,t),h=yt.lerpAngular(s.angular,e.angular,t),u=Vg(s.aim,e.aim,t);return s.kind==="polygon"&&e.kind==="polygon"&&s.points.length===e.points.length?{...s,bounds:i,angle:n,transparency:r,haloScale:a,blur:o,brightness:c,color:l,angular:h,aim:u,points:s.points.map((d,f)=>({x:Ci(d.x,e.points[f].x,t),y:Ci(d.y,e.points[f].y,t)}))}:{...t<1?s:e,bounds:i,angle:n,transparency:r,haloScale:a,blur:o,brightness:c,color:l,angular:h,aim:u}}class Vc{keyframes=[];order=[];groups=[];addKeyframe(e,t){const i=this.findInsertIndex(e);if(this.keyframes[i]?.t===e){const n=new Set(t.map(r=>r.sourceId));this.keyframes[i]={t:e,shapes:[...this.keyframes[i].shapes.filter(r=>!n.has(r.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(r=>r.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?Yg(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(r=>r.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(r=>r.sourceId===t);if(n)return{t:this.keyframes[i].t,shape:n.shape}}}hitTest(e,t,i,n){const r=this.sourceIds;for(let a=r.length-1;a>=0;a--){if(n?.has(r[a]))continue;const o=this.getInterpolatedShapeAt(e,r[a]);if(o&&Wg(o,t,i))return{sourceId:r[a],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 Vc;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 Kg(s,e,t){return Math.max(e,Math.min(t,s))}function $g(s,e,t){const i=((e-s)%360+540)%360-180;return((s+i*t)%360+360)%360}function rr(s,e,t){return s+(e-s)*t}function Zg(s,e,t){return{lat:s.lat===void 0||e.lat===void 0?void 0:rr(s.lat,e.lat,t),lng:s.lng===void 0||e.lng===void 0?void 0:rr(s.lng,e.lng,t),elevationM:rr(s.elevationM,e.elevationM,t),headingDeg:s.headingDeg===void 0||e.headingDeg===void 0?void 0:$g(s.headingDeg,e.headingDeg,t),pitchDeg:rr(s.pitchDeg,e.pitchDeg,t),rollDeg:rr(s.rollDeg??0,e.rollDeg??0,t),fovDeg:rr(s.fovDeg,e.fovDeg,t),fNumber:s.fNumber,focusDistanceM:s.focusDistanceM}}class Ga{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?Zg(i.pose,n.pose,Kg((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 Ga;for(const i of e.keyframes)t.addKeyframe(i.t,i.pose);return t}}function Et(s,e,t){return s+(e-s)*t}function Xu(s,e,t){const i=((e-s)%360+540)%360-180;return((s+i*t)%360+360)%360}function Jg(s,e,t){return Math.max(e,Math.min(t,s))}function jg(s=[],e=[],t){if(!(!s.length&&!e.length))return[...new Set([...s.map(i=>i.id),...e.map(i=>i.id)])].map(i=>{const n=s.find(c=>c.id===i),r=e.find(c=>c.id===i),a=n??{...r,density:0},o=r??{...n,density:0};return{...a,eastM:Et(a.eastM,o.eastM,t),northM:Et(a.northM,o.northM,t),baseM:Et(a.baseM,o.baseM,t),thicknessM:Et(a.thicknessM,o.thicknessM,t),widthM:Et(a.widthM,o.widthM,t),depthM:Et(a.depthM,o.depthM,t),rotationDeg:Xu(a.rotationDeg,o.rotationDeg,t),density:Et(a.density,o.density,t),darkness:Et(a.darkness??0,o.darkness??0,t)}})}function Qg(s,e,t){if(s.cloudLayers===void 0&&e.cloudLayers===void 0)return;const i=vc(s),n=vc(e);return t>=1?n.map(a=>({...a})):[...new Set([...i.map(a=>a.id),...n.map(a=>a.id)])].map(a=>{const o=i.find(u=>u.id===a),c=n.find(u=>u.id===a),l=o??{...c,coverage:0},h=c??{...o,coverage:0};return{...l,instances:jg(o?.instances,c?.instances,t),baseM:Et(l.baseM,h.baseM,t),thicknessM:Et(l.thicknessM,h.thicknessM,t),coverage:Et(l.coverage,h.coverage,t),sizeM:Et(l.sizeM,h.sizeM,t),density:Et(l.density,h.density,t),darkness:Et(l.darkness??s.cloudDarkness,h.darkness??e.cloudDarkness,t),iceCrystalAlignment:l.iceCrystalAlignment===void 0||h.iceCrystalAlignment===void 0?void 0:Et(l.iceCrystalAlignment,h.iceCrystalAlignment,t),windSpeed:l.windSpeed===void 0&&h.windSpeed===void 0?void 0:Et(l.windSpeed??s.windSpeed,h.windSpeed??e.windSpeed,t),windDirectionDeg:l.windDirectionDeg===void 0&&h.windDirectionDeg===void 0?void 0:Xu(l.windDirectionDeg??s.windDirectionDeg,h.windDirectionDeg??e.windDirectionDeg,t)}})}function e1(s,e,t){return{cloudLayers:Qg(s,e,t),cloudCover:Et(s.cloudCover,e.cloudCover,t),cloudDarkness:Et(s.cloudDarkness,e.cloudDarkness,t),highCloudCover:s.highCloudCover===void 0||e.highCloudCover===void 0?void 0:Et(s.highCloudCover,e.highCloudCover,t),iceCrystalAlignment:s.iceCrystalAlignment===void 0||e.iceCrystalAlignment===void 0?void 0:Et(s.iceCrystalAlignment,e.iceCrystalAlignment,t),lowerCloudCover:s.lowerCloudCover===void 0||e.lowerCloudCover===void 0?void 0:Et(s.lowerCloudCover,e.lowerCloudCover,t),cloudBaseM:s.cloudBaseM===void 0||e.cloudBaseM===void 0?void 0:Et(s.cloudBaseM,e.cloudBaseM,t),relativeHumidity:s.relativeHumidity===void 0||e.relativeHumidity===void 0?void 0:Et(s.relativeHumidity,e.relativeHumidity,t),precipitationType:t<1?s.precipitationType:e.precipitationType,precipitationIntensity:Et(s.precipitationIntensity,e.precipitationIntensity,t),windDirectionDeg:Xu(s.windDirectionDeg,e.windDirectionDeg,t),windSpeed:Et(s.windSpeed,e.windSpeed,t),storm:t<1?s.storm:e.storm}}class Va{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?e1(i.weather,n.weather,Jg((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 Va;for(const i of e.keyframes)t.addKeyframe(i.t,i.weather);return t}}class Wa{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 r=(e-i.t)/(n.t-i.t);return this.lerp(i.sound,n.sound,Math.max(0,Math.min(1,r)))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(e){const t=new Wa;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 t1=100,i1={kind:"none",volume:0,pitchHz:t1};class Yi{constructor(e){this.entries=e}static empty(){return new Yi(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 Yi(new Map);return{recording:Yi.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 r=t.at(n),a=n.split("."),o=Yi.holderOf(i,a);if(!o)continue;const c=a[a.length-1],l=o[c];l!==void 0&&(r.of!==void 0&&JSON.stringify(r.of)!==JSON.stringify(l)||(o[c]={value:l,...r.basis==="stated"?{}:{basis:r.basis},...r.rationale===void 0?{}:{rationale:r.rationale}}))}return i}static isWrapper(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"value"in e}static stripValue(e,t,i){return Yi.isWrapper(e)?(i.set(t.join("."),{basis:e.basis??"stated",...e.rationale===void 0?{}:{rationale:e.rationale},of:e.value}),Yi.stripValue(e.value,t,i)):Array.isArray(e)?e.map((n,r)=>Yi.stripValue(n,[...t,String(r)],i)):typeof e=="object"&&e!==null?Object.fromEntries(Object.entries(e).map(([n,r])=>[n,Yi.stripValue(r,[...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 _h(s){if(s.year!==void 0)return Date.UTC(s.year,(s.month??1)-1,s.day??1,s.hour??0,s.minute??0,s.second??0)}function Wd(s){return(((s.day??0)*24+(s.hour??0))*60+(s.minute??0))*6e4+(s.second??0)*1e3}const n1=["year","month","day","hour","minute"],s1=["day","hour","minute"];function Xd(s,e){return e.filter(t=>s[t]!==void 0).join(",")}function r1(s){if(s.durationSeconds!==void 0)return s.durationSeconds*1e3;if(!s.time||!s.endTime)return;const e=s.time.year!==void 0&&s.endTime.year!==void 0,t=e?n1:s1,i=Xd(s.time,t);if(!(i===""||i!==Xd(s.endTime,t)))return e?_h(s.endTime)-_h(s.time):Wd(s.endTime)-Wd(s.time)}class Wc{constructor(e,t,i,n,r,a,o,c,l=[],h,u,d,f=[],p=[]){this.event=e,this.timeline=t,this.witnessTrack=i,this.weatherTrack=n,this.soundTrack=r,this.witness=a,this.caseId=o,this.weather=c,this.decor=l,this.weatherSource=h,this.instrumentId=u,this.exposureSeconds=d,this.milestones=f,this.references=p}provenance=Yi.empty();testimony;get witnessCount(){return 1+this.decor.filter(e=>e.kind==="witness").length}get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return Yt.byId(this.instrumentId)}static create(e,t,i){return new Wc({eventType:"sighting",time:e,place:t},new Vc,new Ga,new Va,new Wa,i)}}const a1=0,o1=0;function si(s,e){const t=s.witnessTrack.getInterpolatedPoseAt(e);if(t)return t;const i=s.event.place?.[0];if(i)return{lat:i.lat,lng:i.lng,elevationM:a1,headingDeg:void 0,pitchDeg:o1,fovDeg:Yt.fieldOfViewDeg(s.instrument)}}function ar(s,e){return s.weatherTrack.getInterpolatedWeatherAt(e)??s.weather??qp}function c1(s,e){return s.soundTrack.getInterpolatedSoundAt(e)??i1}class l1{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 $p=["nw","n","ne","e","se","s","sw","w"],h1=24,co=8,u1=3,d1=8;function lo(s,e,t){const i=s.x-e.x,n=s.y-e.y,r=Math.cos(t),a=Math.sin(t);return{x:e.x+i*r-n*a,y:e.y+i*a+n*r}}function ra(s){return{x:s.x+s.width/2,y:s.y+s.height/2}}const f1={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 zi{static handlePointsFor(e){const{x:t,y:i,width:n,height:r}=e.bounds,a={nw:{x:t,y:i},n:{x:t+n/2,y:i},ne:{x:t+n,y:i},e:{x:t+n,y:i+r/2},se:{x:t+n,y:i+r},s:{x:t+n/2,y:i+r},sw:{x:t,y:i+r},w:{x:t,y:i+r/2},rotate:{x:t+n/2,y:i-h1}},o=ra(e.bounds),c={};for(const l of Object.keys(a))c[l]=lo(a[l],o,e.angle);return c}static hitTestHandle(e,t,i=8,n=[...$p,"rotate"]){const r=zi.handlePointsFor(e);for(const a of n)if(Math.hypot(t.x-r[a].x,t.y-r[a].y)<=i)return a}static HANDLE_DIRECTION_DEG={e:0,se:45,s:90,sw:135,w:180,nw:225,n:270,ne:315};static resizeAxisFor(e,t){const n=((zi.HANDLE_DIRECTION_DEG[e]+t*180/Math.PI)%180+180)%180/45,r=["ew","nwse","ns","nesw"];return r[Math.round(n)%r.length]}static resizeBounds(e,t,i,n){const r=ra(e),a=lo(n,r,-t),{x:o,y:c,width:l,height:h}=e,u=f1[i];let d=o,f=c,p=o+l,v=c+h;return u.left&&(d=Math.min(a.x,p-co)),u.right&&(p=Math.max(a.x,d+co)),u.top&&(f=Math.min(a.y,v-co)),u.bottom&&(v=Math.max(a.y,f+co)),{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:r}=e.bounds,a=zi.resizeBounds(e.bounds,e.angle,t,i);if(e.kind==="oval")return{...e,bounds:a};const o=n===0?1:a.width/n,c=r===0?1:a.height/r;return{...e,bounds:a,points:e.points.map(l=>({x:l.x*o,y:l.y*c}))}}static rotateShape(e,t){const i=ra(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(a=>a.x)),i=Math.min(...e.map(a=>a.y)),n=Math.max(...e.map(a=>a.x+a.width)),r=Math.max(...e.map(a=>a.y+a.height));return{x:t,y:i,width:n-t,height:r-i}}static vertexPointsFor(e){const t=ra(e.bounds);return e.points.map(i=>lo({x:e.bounds.x+i.x,y:e.bounds.y+i.y},t,e.angle))}static hitTestVertex(e,t,i=d1){const n=zi.vertexPointsFor(e);let r,a=i;return n.forEach((o,c)=>{const l=Math.hypot(t.x-o.x,t.y-o.y);l<=a&&(a=l,r=c)}),r}static toLocalPoint(e,t){const i=ra(e.bounds),n=lo(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?zi.toLocalPoint(e,i):u),r=Math.min(...n.map(u=>u.x)),a=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+r,y:e.bounds.y+a,width:o-r,height:c-a},h=n.map(u=>({x:u.x-r,y:u.y-a}));return{...e,bounds:l,points:h}}static insertVertexNear(e,t){const i=zi.toLocalPoint(e,t),{points:n}=e;let r=n.length-1,a=1/0;for(let c=0;c<n.length;c++){const l=n[c],h=n[(c+1)%n.length],u=zi.distanceToSegment(i,l,h);u<a&&(a=u,r=c)}const o=[...n.slice(0,r+1),i,...n.slice(r+1)];return{...e,points:o}}static distanceToSegment(e,t,i){const n=i.x-t.x,r=i.y-t.y,a=n*n+r*r,o=a===0?0:Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/a)),c=t.x+o*n,l=t.y+o*r;return Math.hypot(e.x-c,e.y-l)}static deleteVertex(e,t){return e.points.length<=u1?e:{...e,points:e.points.filter((i,n)=>n!==t)}}}const yh=6,ho=yh/2,qd=20,Yd=24,Kd=9,$d=6,Zd=7,Jd=6,vn=4;class Xa{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:r}=e.bounds,a=t+n/2,o=i+r/2,c=e.angle%(2*Math.PI)!==0,l=Math.hypot(n,r)/2,h=c?l:n/2,u=c?l:r/2,d=Math.max(n,r)/2,f=e.brightness??0,p=f>0?Math.max(d*(1+Kd*f),Jd*f)-d:0,v=f>0?d*(1+Zd*f)-d:0,m=3*Yd*(e.blur??0)+1.5*qd*e.haloScale,g=Math.max(p,v,0)+m+2;return{x:a-h-g,y:o-u-g,width:2*(h+g),height:2*(u+g)}}paintInto(e,t,i){this.ctx.save(),this.ctx.scale(i,i),this.ctx.translate(-t.x,-t.y),this.paintShape(e.selected?{...e,selected:!1}:e),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(${(Yd*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:r,height:a}=e.bounds,o=i+r/2,c=n+a/2,l=Math.max(r,a)/2,h=Math.max(l*(1+Kd*t),Jd*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<=$d;d++){const f=d/$d,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+Zd*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),r=a=>Math.round(a+(255-a)*t);return`rgb(${r(n>>16&255)}, ${r(n>>8&255)}, ${r(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 r=Number.parseInt(n[1],16);return`rgba(${r>>16&255}, ${r>>8&255}, ${r&255}, ${i.toFixed(3)})`}paintBase(e){if(this.ctx.fillStyle=this.dazzledFill(e,e.brightness??0),this.ctx.beginPath(),e.kind==="oval"){const{x:t,y:i,width:n,height:r}=e.bounds,a=n/2,o=r/2;this.ctx.ellipse(t+a,i+o,a,o,e.angle,0,2*Math.PI)}else{const{x:t,y:i,width:n,height:r}=e.bounds;this.ctx.save(),this.ctx.translate(t+n/2,i+r/2),this.ctx.rotate(e.angle),this.ctx.translate(-n/2,-r/2),e.points.forEach((a,o)=>{o===0?this.ctx.moveTo(a.x,a.y):this.ctx.lineTo(a.x,a.y)}),this.ctx.closePath(),this.ctx.restore()}this.ctx.fill()}paintHalo(e){this.ctx.save(),this.ctx.shadowColor=e.color,this.ctx.shadowBlur=qd*e.haloScale,this.paintBase(e),this.ctx.restore()}paintSelectionHandles(e){this.paintHandleFrame(zi.handlePointsFor(e),{includeRotate:!0}),e.kind==="polygon"&&this.paintVertexHandles(e)}paintVertexHandles(e){this.ctx.fillStyle="#39f";for(const t of zi.vertexPointsFor(e))this.ctx.beginPath(),this.ctx.ellipse(t.x,t.y,vn,vn,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(e){this.paintOutline(zi.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 r of e.slice(1))n.lineTo(r.x,r.y);n.closePath(),n.stroke(),n.setLineDash([])}for(const r of t){const a=Xa.landmarkColour(r.residualDeg),o=r.selected?3:2;r.selected&&(n.strokeStyle="#fff",n.lineWidth=o+3,n.beginPath(),n.ellipse(r.picture.x,r.picture.y,vn+2,vn+2,0,0,2*Math.PI),n.stroke()),r.scene&&(n.strokeStyle=a,n.lineWidth=1,n.beginPath(),n.moveTo(r.picture.x,r.picture.y),n.lineTo(r.scene.x,r.scene.y),n.stroke(),n.fillStyle=a,n.beginPath(),n.ellipse(r.scene.x,r.scene.y,vn,vn,0,0,2*Math.PI),n.fill()),n.strokeStyle=a,n.lineWidth=o,n.beginPath(),n.ellipse(r.picture.x,r.picture.y,vn+2,vn+2,0,0,2*Math.PI),n.stroke(),this.paintLabel(r.label,r.picture.x+vn+5,r.picture.y-vn-2,a)}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,r=11){const a=this.ctx;a.save(),a.font=`${r}px system-ui, sans-serif`,a.textBaseline="top";const o=a.measureText(e).width;a.fillStyle="rgba(0, 0, 0, 0.6)",a.fillRect(t-3,i-2,o+6,r+4),a.fillStyle=n,a.fillText(e,t,i),a.restore()}paintGroupHandles(e){this.paintHandleFrame(zi.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 $p){const n=e[i];this.ctx.fillRect(n.x-ho,n.y-ho,yh,yh)}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,ho+1,ho+1,0,0,2*Math.PI),this.ctx.fill())}}const jd=.05,Qd=.08,e0=2,t0=3,p1=14,m1=.02;class g1{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,jd);for(const{param:r,ratio:a}of e.pitch)r.setTargetAtTime(Math.min(t.pitchHz*a,i.sampleRate/2-1),n,jd)}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 r=e.createBiquadFilter();r.type="lowpass",r.Q.value=1;const a=e.createGain();return a.gain.value=0,i.connect(r),n.connect(r),r.connect(a).connect(e.destination),i.start(),n.start(),{key:t,nodes:[r,a],sources:[i,n],volumeParam:a.gain,gainScale:.16,pitch:[{param:i.frequency,ratio:1},{param:n.frequency,ratio:1.006},{param:r.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 r=e.createGain(),a=e.createGain();return a.gain.value=0,n.connect(r).connect(i.frequency),i.connect(a).connect(e.destination),i.start(),n.start(),{key:t,nodes:[r,a],sources:[i,n],volumeParam:a.gain,gainScale:.22,pitch:[{param:i.frequency,ratio:1},{param:r.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 r=e.createGain();return r.gain.value=0,i.connect(n).connect(r).connect(e.destination),i.start(),{key:t,nodes:[n,r],sources:[i],volumeParam:r.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 r=e.createGain();r.gain.value=0;const a=e.createBufferSource();a.buffer=this.crackleEnvelope(e),a.loop=!0;const o=e.createGain();return o.gain.value=0,a.connect(o).connect(r.gain),i.connect(n).connect(r).connect(e.destination),i.start(),a.start(),{key:t,nodes:[n,r,o],sources:[i,a],volumeParam:o.gain,gainScale:.9,pitch:[{param:n.frequency,ratio:4}]}}async buildRecordedVoice(e,t,i){const n=this.context;if(!n)return;let r;try{r=await this.getBuffer(e)}catch(c){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",c);return}if(i!==this.voiceToken||!this.context)return;const a=n.createBufferSource();a.buffer=r,a.loop=!0;const o=n.createGain();o.gain.value=0,a.connect(o).connect(n.destination),a.start(),this.voice={key:t,nodes:[o],sources:[a],volumeParam:o.gain,gainScale:1,pitch:[]},this.requested&&this.applyTo(this.voice,this.requested)}async getBuffer(e){const t=this.context;if(!t)throw new Error("SightingAudio: AudioContext not ready — resume() must be called first");let 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*e0),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*e0),e.sampleRate),i=t.getChannelData(0);let n=0,r=0;for(let a=0;a<i.length;a++)n=(n+.02*(Math.random()*2-1))/1.02,i[a]=n,r=Math.max(r,Math.abs(n));if(r>0)for(let a=0;a<i.length;a++)i[a]/=r;return t}crackleEnvelope(e){if(!this.crackleBuffer){const t=e.createBuffer(1,Math.floor(e.sampleRate*t0),e.sampleRate),i=t.getChannelData(0),n=Math.max(1,Math.floor(m1*e.sampleRate)),r=Math.round(t0*p1);for(let a=0;a<r;a++){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,Qd/3);const n=i+Qd;for(const r of e.sources){r.onended=()=>{r.disconnect();for(const a of e.nodes)a.disconnect()};try{r.stop(n)}catch{r.disconnect();for(const a of e.nodes)a.disconnect()}}}}function xc(s){return[...s].sort((e,t)=>e.t-t.t)}function i0(s,e){let t;for(const i of xc(s)){if(i.t>e)break;t=i}return t}const sl=Math.PI/180,uo=180/Math.PI;class Yn{constructor(e,t,i){this.kind=e,this.canvasHeightPx=t,this.fovDeg=i;const n=i*sl/2;this.focalPx=e==="equidistant"?t/2/n:t/2/Math.tan(n)}focalPx;static of(e,t,i){return new Yn(e.projection,t,i)}degToPx(e){const t=e*sl;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*sl;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(yt.angularWidthDeg(e))}}class Ki{static fovOf(e,t){return si(e,t)?.fovDeg??Yt.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:r}=i.toBoundsSize(t.angular),a={x:t.bounds.x+(t.bounds.width-n)/2,y:t.bounds.y+(t.bounds.height-r)/2,width:n,height:r};if(t.kind!=="polygon")return{...t,bounds:a};const o=t.bounds.width===0?1:n/t.bounds.width,c=t.bounds.height===0?1:r/t.bounds.height;return{...t,bounds:a,points:t.points.map(l=>({x:l.x*o,y:l.y*c}))}})}static toAim(e){this.eachKeyframe(e,(t,i,n)=>{const r=this.aimFrom(e,i,n,t.bounds);return r?{...t,aim:r}:t})}static aimOf(e,t,i){const n=Yn.of(e.instrument,yt.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 r=this.frameCentre(e),a=t.radiusPxToAngleDeg(n.x+n.width/2-r.x),o=t.radiusPxToAngleDeg(r.y-(n.y+n.height/2));return{azimuthDeg:((i.headingDeg+a)%360+360)%360,altitudeDeg:i.pitchDeg+o}}static toPosition(e){this.eachKeyframe(e,(t,i,n)=>{if(!t.aim||n?.headingDeg===void 0)return t;const r=this.frameCentre(e),a=this.shortestArc(t.aim.azimuthDeg-n.headingDeg),o=t.aim.altitudeDeg-n.pitchDeg,c=r.x+this.offAxisPx(i,a)-t.bounds.width/2,l=r.y-this.offAxisPx(i,o)-t.bounds.height/2;return{...t,bounds:{...t.bounds,x:c,y:l}}})}static frameCentre(e){return{x:Yt.frameWidthPx(e.instrument,yt.CANVAS_HEIGHT_PX)/2,y:yt.CANVAS_HEIGHT_PX/2}}static shortestArc(e){return(e%360+540)%360-180}static offAxisPx(e,t){return Math.abs(t)>=Ki.OFF_CANVAS_DEG?Math.sign(t)*Ki.OFF_CANVAS_PX:e.angleDegToRadiusPx(t)}static OFF_CANVAS_DEG=89;static OFF_CANVAS_PX=1e5;static reproject(e,t,i){const n=Yt.frameWidthPx(t,yt.CANVAS_HEIGHT_PX)/2,r=Yt.frameWidthPx(e.instrument,yt.CANVAS_HEIGHT_PX)/2,a=yt.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=Yn.of(t,yt.CANVAS_HEIGHT_PX,l),u=Yn.of(e.instrument,yt.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-a,m=Math.hypot(p,v),g=m===0?1:u.angleDegToRadiusPx(h.radiusPxToAngleDeg(m))/m,b={...f,x:r+p*g-f.width/2,y:a+v*g-f.height/2};return{...d,shape:{...d.shape,bounds:b}}}))}this.toBounds(e)}static eachKeyframe(e,t){const{timeline:i}=e;for(const n of[...i.allKeyframes]){const r=si(e,n.t),a=this.fovOf(e,n.t),o=Yn.of(e.instrument,yt.CANVAS_HEIGHT_PX,a);i.addKeyframe(n.t,n.shapes.map(c=>({...c,shape:t(c.shape,o,r)})))}}}function v1(s){return Yi.restore(M1(s),s.provenance)}function M1(s){return Ki.toAngular(s),Ki.toAim(s),{version:1,time:s.event.time,endTime:s.event.endTime,durationSeconds:s.event.durationSeconds,utcOffsetHours:s.event.utcOffsetHours,timeZone:s.event.timeZone,place:s.event.place,witness:s.witness,testimony:s.testimony,caseId:s.caseId,description:s.event.description,tags:s.event.tags,timeline:s.timeline.toJSON(),witnessTrack:s.witnessTrack.toJSON(),weatherTrack:s.weatherTrack.toJSON(),soundTrack:s.soundTrack.toJSON(),weather:s.weather,decor:s.decor,milestones:s.milestones.length>0?s.milestones:void 0,references:s.references.length>0?s.references:void 0,weatherSource:s.weatherSource,instrument:s.instrumentId,exposureSeconds:s.exposureSeconds}}function x1(s){const{recording:e,provenance:t}=Yi.strip(s),i=_1(e);return i.provenance=t,i}function _1(s){const e=new Wc({eventType:"sighting",time:s.time,endTime:s.endTime,durationSeconds:s.durationSeconds,utcOffsetHours:s.utcOffsetHours,timeZone:s.timeZone,place:s.place,description:s.description,tags:s.tags},Vc.fromJSON(s.timeline),s.witnessTrack?Ga.fromJSON(s.witnessTrack):new Ga,s.weatherTrack?Va.fromJSON(s.weatherTrack):new Va,s.soundTrack?Wa.fromJSON(s.soundTrack):new Wa,s.witness,s.caseId,s.weather,s.decor??[],s.weatherSource,s.instrument,s.exposureSeconds??s.witnessTrack?.keyframes.map(t=>t.pose.exposureSeconds).find(t=>t!==void 0),xc(s.milestones??[]),s.references??[]);return e.testimony=s.testimony,Ki.toBounds(e),Ki.toPosition(e),e}const n0=2;function Zp(s){return s==="building"||s==="vehicle"}function y1(s,e){const t=s.litKeyframes;if(!t||t.length===0)return s.lit??!1;let i=t[0];for(const n of t){if(n.t>e)break;i=n}return i.lit}function S1(s,e){return s.pattern.kind==="steady"?!0:Jp(s,e,e+1)>.5}function Jp(s,e,t){if(s.pattern.kind==="steady")return 1;const{perMinute:i,dutyCycle:n,phase:r=0}=s.pattern,a=Math.min(Math.max(n,0),1);if(a===0||i<=0)return 0;const o=6e4/i,c=e/o+r,l=t/o+r;if(l<=c)return Math.min(Math.max(c-Math.floor(c),0),a)<a?1:0;const h=u=>Math.floor(u)*a+Math.min(u-Math.floor(u),a);return(h(l)-h(c))/(l-c)}function qu(s,e){const t=s.track,i={eastM:s.eastM,northM:s.northM,altitudeM:0,headingDeg:s.headingDeg};if(!t||t.length===0)return i;if(t.length===1||e<=t[0].t)return s0(t[0],s);const n=t[t.length-1];if(e>=n.t)return s0(n,s);for(let r=0;r<t.length-1;r++){const a=t[r],o=t[r+1];if(e<a.t||e>o.t)continue;const c=o.t-a.t,l=c===0?0:(e-a.t)/c;return{eastM:a.eastM+(o.eastM-a.eastM)*l,northM:a.northM+(o.northM-a.northM)*l,altitudeM:(a.altitudeM??0)+((o.altitudeM??0)-(a.altitudeM??0))*l,headingDeg:a.headingDeg??s.headingDeg}}return i}function s0(s,e){return{eastM:s.eastM,northM:s.northM,altitudeM:s.altitudeM??0,headingDeg:s.headingDeg??e.headingDeg}}class rn{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),r=Math.max(0,e-n);return{fromMs:n,toMs:e,ms:r,seconds:r/1e3}}static instants(e,t,i,n,r){if(!(n>0))return 1;const a=r>0?rn.travelDegOver(e,t,i,i+n*1e3)/r/rn.PIXELS_PER_INSTANT:0,o=rn.flashesOver(e,n)*rn.INSTANTS_PER_FLASH,c=Math.ceil(Math.max(a,o));return c<2?1:Math.min(rn.MAX_INSTANTS,c)}static travelDegOver(e,t,i,n){let r=0;for(const a of e){if(!a.track||a.track.length<2)continue;const o=rn.directionAt(a,t,i),c=rn.directionAt(a,t,n),l=Math.min(1,Math.max(-1,o.x*c.x+o.y*c.y+o.z*c.z));r=Math.max(r,Math.acos(l)*180/Math.PI)}return r}static flashesOver(e,t){let i=0;for(const n of e)for(const r of n.lights??[])r.pattern.kind==="flash"&&(i=Math.max(i,r.pattern.perMinute));return i/60*t}static directionAt(e,t,i){const n=qu(e,i),r=n.eastM,a=n.altitudeM-t,o=n.northM,c=Math.hypot(r,a,o);return c===0?{x:0,y:1,z:0}:{x:r/c,y:a/c,z:o/c}}}function Yu(s,e){for(const t of s){const i=t.toLowerCase().split("-")[0];if(e.includes(i))return i}return"en"}class _c{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 Ms{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[Ms.base(i)];if(n)return n}const t=new Set(this.preferences.map(i=>Ms.base(i)));for(const[i,n]of Object.entries(e))if(n&&t.has(Ms.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 r={...e},a=Object.keys(r).find(o=>o===i)??Object.keys(r).find(o=>Ms.base(o)===Ms.base(i))??i;return n===void 0?delete r[a]:r[a]=n,Object.keys(r).length===0?void 0:r}static base(e){return e.toLowerCase().split("-")[0]}}const b1=["en","fr"],w1={en:()=>gc(()=>Promise.resolve().then(()=>A1),void 0,import.meta.url).then(s=>s.ufoMessages_en),fr:()=>gc(()=>import("./UfoMessages_fr-CnenjNH2.js"),[],import.meta.url).then(s=>s.ufoMessages_fr)};function E1(s){return w1[s]()}const jp={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"},A1=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:jp},Symbol.toStringTag,{value:"Module"})),Qp=Math.PI/180,T1=180/Math.PI,R1=256,D1=19;function C1(s,e){return 156543.03392*Math.cos(s*Qp)/2**e}function I1(s,e){return C1(s,e)*R1}function em(s,e){let t=0;for(;t<D1&&I1(s,t+1)>=e;)t++;return t}function lc(s){const e=s*Qp;return(1-Math.log(Math.tan(e)+1/Math.cos(e))/Math.PI)/2}function tm(s,e,t){const i=2**t;return{x:(s+180)/360*i,y:lc(e)*i}}function im(s,e,t){const i=lc(s.north),n=lc(s.south);return{x:(e-s.west)/(s.east-s.west),y:(lc(t)-i)/(n-i)}}function P1(s,e,t){const{x:i,y:n}=tm(s,e,t);return{x:Math.floor(i),y:Math.floor(n),z:t}}function L1(s){const e=2**s.z,t=s.x/e*360-180,i=(s.x+1)/e*360-180,n=r0(s.y,e);return{south:r0(s.y+1,e),north:n,west:t,east:i}}function r0(s,e){const t=s/e;return Math.atan(Math.sinh(Math.PI*(1-2*t)))*T1}function nm(s,e,t,i){const n=P1(s,e,t),r=Math.floor(i/2),a=[];for(let l=-r;l<=r;l++)for(let h=-r;h<=r;h++)a.push({x:n.x+h,y:n.y+l,z:t});const o=a.map(L1),c={south:Math.min(...o.map(l=>l.south)),north:Math.max(...o.map(l=>l.north)),west:Math.min(...o.map(l=>l.west)),east:Math.max(...o.map(l=>l.east))};return{tiles:a,bounds:c}}class Us{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 r of this.targets){const a=Math.hypot(r.x-e,r.y-t);a>r.radius||a>n||(i=r,n=a)}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=im(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),r=this.toCanvas(e.bounds,i.bounds.south,i.bounds.east);t.drawImage(i.source,n.x,n.y,r.x-n.x,r.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 r=(i.headingDeg-90)*Math.PI/180;t.beginPath(),t.moveTo(n.x,n.y),t.lineTo(n.x+Math.cos(r)*10,n.y+Math.sin(r)*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:r}=this,a=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;r.save(),r.beginPath(),r.moveTo(a.x,a.y),r.arc(a.x,a.y,o,c-l,c+l),r.closePath();const h=r.createRadialGradient(a.x,a.y,0,a.x,a.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)"),r.fillStyle=h,r.fill(),r.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,r)=>Number(n.current)-Number(r.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:Us.MARKER_RADIUS_PX}),t.beginPath(),t.arc(n.x,n.y,Us.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 r=e.markers.some(a=>{if(!a.current)return!1;const o=hi(a.lat,a.lng,t.lat,t.lng);return Math.hypot(o.x,o.z)<=Us.ON_MARKER_M});i.beginPath(),i.arc(n.x,n.y,r?Us.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),r||(i.fillStyle="#ff5a3c",i.fill()),i.lineWidth=4,i.strokeStyle="rgba(0, 0, 0, 0.5)",i.stroke(),i.lineWidth=r?3:2.5,i.strokeStyle=r?"#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 r=this.height-4;i.textAlign="right";for(const f of n.slice().reverse())this.paintOutlinedText(f,this.width-6,r),r-=11;const a=(e.south+e.north)/2,c=Math.abs(hi(a,e.east,a,e.west).x)/this.width,l=Us.SCALE_STEPS_M.find(f=>f/c<=this.width/3);if(l===void 0)return;const h=l/c,u=8,d=r-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 r of e.split(" ")){const a=n?`${n} ${r}`:r;n&&this.ctx.measureText(a).width>t?(i.push(n),n=r):n=a}return n&&i.push(n),i}}const Vi=256,a0=3,N1=32768;class O1{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,r=Math.abs(hi(i,e.east,i,e.west).x),a=Math.abs(hi(e.north,n,e.south,n).z),o=em(i,Math.max(r,a)),{tiles:c}=nm(n,i,o,a0),l=a0*Vi,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 r=this.tileUrlTemplate.replace("{z}",String(e.z)).replace("{x}",String(e.x)).replace("{y}",String(e.y)),a=await this.fetchImpl(r);if(!a.ok)throw new Error(`Elevation tile fetch failed (${a.status}): ${r}`);const o=await createImageBitmap(await a.blob()),c=document.createElement("canvas");c.width=Vi,c.height=Vi;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,Vi,Vi),u=(e.x-t.x)*Vi,d=(e.y-t.y)*Vi;for(let f=0;f<Vi;f++)for(let p=0;p<Vi;p++){const v=(f*Vi+p)*4,m=h[v]*256+h[v+1]+h[v+2]/256-N1,g=u+p,b=d+f;i[b*n+g]=m}}sampleAt(e,t,i,n,r,a){const{x:o,y:c}=tm(t,e,i),l=(o-n.x)*Vi,h=(c-n.y)*Vi,u=Math.max(0,Math.min(a-1,Math.floor(l))),d=Math.max(0,Math.min(a-1,Math.floor(h))),f=Math.min(a-1,u+1),p=Math.min(a-1,d+1),v=l-u,m=h-d,g=r[d*a+u],b=r[d*a+f],y=r[p*a+u],_=r[p*a+f],w=g+(b-g)*v,E=y+(_-y)*v;return w+(E-w)*m}}const rl=256,o0=3;async function U1(s,e,t,i){const n=(s.south+s.north)/2,r=(s.west+s.east)/2,a=Math.abs(hi(n,s.east,n,s.west).x),o=Math.abs(hi(s.north,r,s.south,r).z),c=em(n,Math.max(a,o)/2),{tiles:l,bounds:h}=nm(r,n,c,o0),u=o0*rl,d=document.createElement("canvas");d.width=u,d.height=u;const f=d.getContext("2d");if(!f)throw new Error("2D canvas context unavailable");const p=l[0];await Promise.all(l.map(async g=>{const b=t(g),y=await i(b);if(!y.ok)throw new Error(`Imagery tile fetch failed (${y.status}): ${b}`);const _=await createImageBitmap(await y.blob());f.drawImage(_,(g.x-p.x)*rl,(g.y-p.y)*rl)}));const v=document.createElement("canvas");v.width=e.width,v.height=e.height;const m=v.getContext("2d");if(!m)throw new Error("2D canvas context unavailable");return m.drawImage(d,0,0,u,u,0,0,e.width,e.height),{source:v,width:e.width,height:e.height,bounds:h}}class F1{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 U1(e,t,i=>this.tileUrlTemplate.replace("{z}",String(i.z)).replace("{y}",String(i.y)).replace("{x}",String(i.x)),this.fetchImpl)}}function k1(){return{elevation:new O1,imagery:sm()}}function sm(){return new F1}const z1=new Set,zr="show-witness-map",Br="hide-milestones";class Fi extends HTMLElement{static get observedAttributes(){return["src",zr,Br]}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=Wc.create();sightingAudio=new g1;soundPreview;player;loopEnabled=!1;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;selectionShown=!0;overlayPainter;enableClickToPlay=!0;fullscreenTarget;messages=jp;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 r=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${e.clientX-r.left+12}px`,this.tooltip.style.top=`${e.clientY-r.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>${Gg}</style>${Hg}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Xa(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 Us(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===zr&&this.applyWitnessMapDefault(),e===Br&&this.setMilestonesShown(!this.hasAttribute(Br))}async loadFromSrc(e){this.sightingData=await Kp.json(e)}get sightingData(){return v1(this.currentSighting)}set sightingData(e){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=x1(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?xc(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 r=this.said.read(i.label)??"",a=this.said.read(i.note),o=a?`${r} — ${a}`:r;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=Fi.MARK_SNAP_PX/i*t;let r;for(const a of this.milestoneMarks.children){const o=Number(a.dataset.t);Math.abs(o-e)>n||(!r||Math.abs(o-e)<Math.abs(r.t-e))&&(r={t:o,name:a.title})}return r}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,r=this.markNear(n);r?this.seekInput.title=r.name:this.seekInput.removeAttribute("title")}showMilestoneAt(e){const t=this.milestonesShown&&this.sighting.milestones.length>0?i0(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),r=n?` — ${n}`:"";this.milestoneCaption.replaceChildren(i,document.createTextNode(r))}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=rn.windowEndingAt(e,this.currentSighting.exposure??0);if(t.ms<Fi.SHORTEST_VISIBLE_EXPOSURE_MS)return[e];const i=Math.min(Fi.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(t.ms/Fi.SHORTEST_VISIBLE_EXPOSURE_MS))),n=Math.ceil(this.travelPxOver(t.fromMs,t.ms)/Fi.EXPOSURE_STEP_PX),r=Math.min(Fi.MAX_TRAVEL_STEPS,Math.max(i,n)),a=[];for(let o=0;o<r;o++)a.push(t.fromMs+t.ms*o/(r-1));return a}travelPxOver(e,t){const i=this.shapesAt(e),n=this.shapesAt(e+t);let r=0;for(const[a,o]of i){const c=n.get(a);if(!c)continue;const l=c.bounds.x+c.bounds.width/2-(o.bounds.x+o.bounds.width/2),h=c.bounds.y+c.bounds.height/2-(o.bounds.y+o.bounds.height/2);r=Math.max(r,Math.hypot(l,h))}return r}shapeAt(e,t,i){for(const n of this.exposureTimes()){const r=this.currentSighting.timeline.hitTest(n,e,t,i);if(r)return r}}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=Yt.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:z1;this.canvasRenderer.setStarPoints(Yt.starPointsOf(this.sighting.instrument));const n=(si(this.sighting,e)?.rollDeg??0)+this.gaitAt(e).rollDeg;this.canvasRenderer.setRoll(n*Math.PI/180);const r=this.exposureInstants(e),a=this.frameShift;if(this.paintsShapes)for(const o of r)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,a))}for(const[o,c]of r[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,a)));if(this.selectionShown&&i.size>1){const o=zi.groupBoundsFor([...t].filter(([c])=>i.has(c)).map(([,c])=>c.bounds));this.canvasRenderer.paintGroupHandles(o)}this.overlayPainter?.(this.canvasRenderer),this.mapShapeBounds=r.flatMap(o=>[...o.shapes.values()].filter(c=>c.transparency<1).map(c=>this.shifted(c,a).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(c1(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 l1(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(zr)&&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=Ha.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(Fi.WITNESS_MAP_MIN_SPAN_M,Fi.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=sm(),t=this.witnessMapBounds;try{const i=await e.getImageryTexture(t,{width:Fi.WITNESS_MAP_IMAGERY_PX,height:Fi.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],r=[0,e.width],a=Fi.WITNESS_MAP_CLEARANCE_PX,o=i(...n,0),c=i(...r,0);if(this.witnessMapPanel.classList.toggle("subject-overlap",o&&c),this.witnessMapPanel.classList.contains("on-the-left")){!o&&(c||!i(n[0],n[1],a))&&this.witnessMapPanel.classList.remove("on-the-left");return}i(n[0],n[1],0)&&!i(r[0],r[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=[],r=this.currentSighting.milestones.length>0?i0(this.currentSighting.milestones,e):void 0;for(const a of this.milestonesShown?xc(this.currentSighting.milestones):[]){const o=si(this.currentSighting,a.t);o?.lat===void 0||o.lng===void 0||n.push({label:this.said.read(a.label)??"",note:this.said.read(a.note),t:a.t,lat:o.lat,lng:o.lng,current:a===r})}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?Yn.of(i,this.canvas.height,t.fovDeg).halfWidthAngleDeg(Yt.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=qu(i,e),{lat:r,lng:a}=qn(n.eastM,-n.northM,t.lat,t.lng);return{lat:r,lng:a,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),r=Yn.of(this.currentSighting.instrument,this.canvas.height,n?.fovDeg??60);return{x:-r.angleDegToRadiusPx(t),y:r.angleDegToRadiusPx(i)}}gaitAt(e){return qt.of(this.currentSighting)?.offsetAt(e)??qt.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 Ms(_c.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const e=Yu(_c.preferencesFor(this),b1);e!=="en"&&this.applyMessages(await E1(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=r1(e);this.realDurationMs=t!==void 0&&t>0?t:void 0,this.realStartMs=e.time?_h(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?l0(c0(this.realStartMs+i)):fo(i)}formatEndOfTimeline(){return this.realDurationMs===void 0?fo(this.currentSighting.timeline.duration):this.canShowClockTime?l0(c0(this.realStartMs+this.realDurationMs)):fo(this.realDurationMs)}}function c0(s){const e=new Date(s);return{hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds()}}function l0(s){if(s.hour===void 0)return"0:00";const e=t=>String(t).padStart(2,"0");return s.second?`${e(s.hour)}:${e(s.minute??0)}:${e(s.second)}`:`${e(s.hour)}:${e(s.minute??0)}`}function fo(s){const e=Math.round(s/1e3),t=Math.floor(e/60),i=e%60;return`${t}:${String(i).padStart(2,"0")}`}const Sh="rr0-ufo";function rm(){customElements.get(Sh)||customElements.define(Sh,Fi)}/**
|
|
627
|
+
`,oo=[{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 Yt{static get default(){return oo[0]}static byId(e){return oo.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:Yt.UNAIDED_FIELD_DEG}static aspectOf(e){const t=e.frame;return t?t.widthMm/t.heightMm:Yt.UNAIDED_ASPECT}static frameWidthPx(e,t){return Math.round(t*Yt.aspectOf(e))}static availableAt(e){return e===void 0?oo:oo.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??Yt.LENS_FLARE_ARTIFACTS}static starPointsOf(e){const t=e.apertureBlades;return t===void 0||t<3?0:t%2===0?t:t*2}}class Ha{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:r,headingDeg:a}=i.pose;n===void 0||r===void 0||t.push({t:i.t,lat:n,lng:r,headingDeg:a})}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 Ha(t)}get moved(){return this.spanM>Ha.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(hi(t,e.east,t,e.west).x),Math.abs(hi(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,r=Math.max(this.spanM*(1+t),e)/2;return{north:qn(0,-r,i,n).lat,south:qn(0,r,i,n).lat,east:qn(r,0,i,n).lng,west:qn(-r,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 qt{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=Ha.of(e);if(!t||t.points.length<2)return;const i=[];let n=0;for(let r=1;r<t.points.length;r++){const a=t.points[r-1],o=t.points[r],c=(o.t-a.t)/1e3;if(c<=0)continue;const l=hi(o.lat,o.lng,a.lat,a.lng),h=l.x,u=-l.z,d=Math.hypot(h,u),f=d/c,p=qt.stepHzFor(f);i.push({startMs:a.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 r=0;r<i.length;r++){const a=i[r-1],o=i[r+1];i[r].rampsIn=a===void 0||a.stepHz===0,i[r].rampsOut=o===void 0||o.stepHz===0}if(i.some(r=>r.stepHz>0))return new qt(i,1-(e.instrument.stabilization??0))}static stepHzFor(e){return e<qt.SLOWEST_WALK_M_PER_S||e>qt.FASTEST_WALK_M_PER_S?0:qt.REFERENCE_STEP_HZ*Math.pow(e/qt.REFERENCE_SPEED_M_PER_S,qt.CADENCE_EXPONENT)}offsetAt(e){const t=this.stretches.find(c=>e>=c.startMs&&e<=c.endMs);if(!t||t.stepHz===0)return qt.STILL;const i=t.stepsBefore+t.stepHz*(e-t.startMs)/1e3,n=2*Math.PI*i,r=this.amplitudeAt(t,e),a=qt.SWAY_M*r*Math.cos(n/2),o=r*this.rotationPassed*t.speedMPerS/qt.REFERENCE_SPEED_M_PER_S;return{eastM:a*t.northUnit,northM:-a*t.eastUnit,upM:qt.RISE_M_PER_M_PER_S*t.speedMPerS*r*Math.cos(n),rollDeg:qt.HEAD_ROLL_DEG*o*Math.cos(n/2),pitchDeg:-1.25*o*Math.cos(n),yawDeg:qt.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 r=t-e.startMs,a=e.endMs-t,o=Math.min(e.rampsIn?r/n:1,e.rampsOut?a/n:1,1);return(1-Math.cos(Math.PI*Math.max(o,0)))/2}}class yt{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/yt.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 Vg(s,e,t){if(!s||!e)return t<1?s:e;const i=((e.azimuthDeg-s.azimuthDeg)%360+540)%360-180;return{azimuthDeg:((s.azimuthDeg+i*t)%360+360)%360,altitudeDeg:s.altitudeDeg+(e.altitudeDeg-s.altitudeDeg)*t}}function Wg(s,e,t){const{bounds:i}=s;return e>=i.x&&e<=i.x+i.width&&t>=i.y&&t<=i.y+i.height}function Ii(s,e,t){return s+(e-s)*t}function Vd(s){const e=/^#([0-9a-f]{6})$/i.exec(s);if(!e)return;const t=parseInt(e[1],16);return[t>>16&255,t>>8&255,t&255]}function Xg(s){return`#${s.map(e=>Math.round(e).toString(16).padStart(2,"0")).join("")}`}function qg(s,e,t){const i=Vd(s),n=Vd(e);return!i||!n?t<1?s:e:Xg([Ii(i[0],n[0],t),Ii(i[1],n[1],t),Ii(i[2],n[2],t)])}function Yg(s,e,t){const i={x:Ii(s.bounds.x,e.bounds.x,t),y:Ii(s.bounds.y,e.bounds.y,t),width:Ii(s.bounds.width,e.bounds.width,t),height:Ii(s.bounds.height,e.bounds.height,t)},n=Ii(s.angle,e.angle,t),r=Ii(s.transparency,e.transparency,t),a=Ii(s.haloScale,e.haloScale,t),o=Ii(s.blur??0,e.blur??0,t),c=Ii(s.brightness??0,e.brightness??0,t),l=qg(s.color,e.color,t),h=yt.lerpAngular(s.angular,e.angular,t),u=Vg(s.aim,e.aim,t);return s.kind==="polygon"&&e.kind==="polygon"&&s.points.length===e.points.length?{...s,bounds:i,angle:n,transparency:r,haloScale:a,blur:o,brightness:c,color:l,angular:h,aim:u,points:s.points.map((d,f)=>({x:Ii(d.x,e.points[f].x,t),y:Ii(d.y,e.points[f].y,t)}))}:{...t<1?s:e,bounds:i,angle:n,transparency:r,haloScale:a,blur:o,brightness:c,color:l,angular:h,aim:u}}class Vc{keyframes=[];order=[];groups=[];addKeyframe(e,t){const i=this.findInsertIndex(e);if(this.keyframes[i]?.t===e){const n=new Set(t.map(r=>r.sourceId));this.keyframes[i]={t:e,shapes:[...this.keyframes[i].shapes.filter(r=>!n.has(r.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(r=>r.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?Yg(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(r=>r.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(r=>r.sourceId===t);if(n)return{t:this.keyframes[i].t,shape:n.shape}}}hitTest(e,t,i,n){const r=this.sourceIds;for(let a=r.length-1;a>=0;a--){if(n?.has(r[a]))continue;const o=this.getInterpolatedShapeAt(e,r[a]);if(o&&Wg(o,t,i))return{sourceId:r[a],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 Vc;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 Kg(s,e,t){return Math.max(e,Math.min(t,s))}function $g(s,e,t){const i=((e-s)%360+540)%360-180;return((s+i*t)%360+360)%360}function rr(s,e,t){return s+(e-s)*t}function Zg(s,e,t){return{lat:s.lat===void 0||e.lat===void 0?void 0:rr(s.lat,e.lat,t),lng:s.lng===void 0||e.lng===void 0?void 0:rr(s.lng,e.lng,t),elevationM:rr(s.elevationM,e.elevationM,t),headingDeg:s.headingDeg===void 0||e.headingDeg===void 0?void 0:$g(s.headingDeg,e.headingDeg,t),pitchDeg:rr(s.pitchDeg,e.pitchDeg,t),rollDeg:rr(s.rollDeg??0,e.rollDeg??0,t),fovDeg:rr(s.fovDeg,e.fovDeg,t),fNumber:s.fNumber,focusDistanceM:s.focusDistanceM}}class Ga{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?Zg(i.pose,n.pose,Kg((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 Ga;for(const i of e.keyframes)t.addKeyframe(i.t,i.pose);return t}}function wt(s,e,t){return s+(e-s)*t}function Xu(s,e,t){const i=((e-s)%360+540)%360-180;return((s+i*t)%360+360)%360}function Jg(s,e,t){return Math.max(e,Math.min(t,s))}function jg(s=[],e=[],t){if(!(!s.length&&!e.length))return[...new Set([...s.map(i=>i.id),...e.map(i=>i.id)])].map(i=>{const n=s.find(c=>c.id===i),r=e.find(c=>c.id===i),a=n??{...r,density:0},o=r??{...n,density:0};return{...a,eastM:wt(a.eastM,o.eastM,t),northM:wt(a.northM,o.northM,t),baseM:wt(a.baseM,o.baseM,t),thicknessM:wt(a.thicknessM,o.thicknessM,t),widthM:wt(a.widthM,o.widthM,t),depthM:wt(a.depthM,o.depthM,t),rotationDeg:Xu(a.rotationDeg,o.rotationDeg,t),density:wt(a.density,o.density,t),darkness:wt(a.darkness??0,o.darkness??0,t)}})}function Qg(s,e,t){if(s.cloudLayers===void 0&&e.cloudLayers===void 0)return;const i=vc(s),n=vc(e);return t>=1?n.map(a=>({...a})):[...new Set([...i.map(a=>a.id),...n.map(a=>a.id)])].map(a=>{const o=i.find(u=>u.id===a),c=n.find(u=>u.id===a),l=o??{...c,coverage:0},h=c??{...o,coverage:0};return{...l,instances:jg(o?.instances,c?.instances,t),baseM:wt(l.baseM,h.baseM,t),thicknessM:wt(l.thicknessM,h.thicknessM,t),coverage:wt(l.coverage,h.coverage,t),sizeM:wt(l.sizeM,h.sizeM,t),density:wt(l.density,h.density,t),darkness:wt(l.darkness??s.cloudDarkness,h.darkness??e.cloudDarkness,t),iceCrystalAlignment:l.iceCrystalAlignment===void 0||h.iceCrystalAlignment===void 0?void 0:wt(l.iceCrystalAlignment,h.iceCrystalAlignment,t),windSpeed:l.windSpeed===void 0&&h.windSpeed===void 0?void 0:wt(l.windSpeed??s.windSpeed,h.windSpeed??e.windSpeed,t),windDirectionDeg:l.windDirectionDeg===void 0&&h.windDirectionDeg===void 0?void 0:Xu(l.windDirectionDeg??s.windDirectionDeg,h.windDirectionDeg??e.windDirectionDeg,t)}})}function e1(s,e,t){return{cloudLayers:Qg(s,e,t),cloudCover:wt(s.cloudCover,e.cloudCover,t),cloudDarkness:wt(s.cloudDarkness,e.cloudDarkness,t),highCloudCover:s.highCloudCover===void 0||e.highCloudCover===void 0?void 0:wt(s.highCloudCover,e.highCloudCover,t),iceCrystalAlignment:s.iceCrystalAlignment===void 0||e.iceCrystalAlignment===void 0?void 0:wt(s.iceCrystalAlignment,e.iceCrystalAlignment,t),lowerCloudCover:s.lowerCloudCover===void 0||e.lowerCloudCover===void 0?void 0:wt(s.lowerCloudCover,e.lowerCloudCover,t),cloudBaseM:s.cloudBaseM===void 0||e.cloudBaseM===void 0?void 0:wt(s.cloudBaseM,e.cloudBaseM,t),relativeHumidity:s.relativeHumidity===void 0||e.relativeHumidity===void 0?void 0:wt(s.relativeHumidity,e.relativeHumidity,t),precipitationType:t<1?s.precipitationType:e.precipitationType,precipitationIntensity:wt(s.precipitationIntensity,e.precipitationIntensity,t),windDirectionDeg:Xu(s.windDirectionDeg,e.windDirectionDeg,t),windSpeed:wt(s.windSpeed,e.windSpeed,t),storm:t<1?s.storm:e.storm}}class Va{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?e1(i.weather,n.weather,Jg((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 Va;for(const i of e.keyframes)t.addKeyframe(i.t,i.weather);return t}}class Wa{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 r=(e-i.t)/(n.t-i.t);return this.lerp(i.sound,n.sound,Math.max(0,Math.min(1,r)))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(e){const t=new Wa;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 t1=100,i1={kind:"none",volume:0,pitchHz:t1};class Ki{constructor(e){this.entries=e}static empty(){return new Ki(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 Ki(new Map);return{recording:Ki.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 r=t.at(n),a=n.split("."),o=Ki.holderOf(i,a);if(!o)continue;const c=a[a.length-1],l=o[c];l!==void 0&&(r.of!==void 0&&JSON.stringify(r.of)!==JSON.stringify(l)||(o[c]={value:l,...r.basis==="stated"?{}:{basis:r.basis},...r.rationale===void 0?{}:{rationale:r.rationale}}))}return i}static isWrapper(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"value"in e}static stripValue(e,t,i){return Ki.isWrapper(e)?(i.set(t.join("."),{basis:e.basis??"stated",...e.rationale===void 0?{}:{rationale:e.rationale},of:e.value}),Ki.stripValue(e.value,t,i)):Array.isArray(e)?e.map((n,r)=>Ki.stripValue(n,[...t,String(r)],i)):typeof e=="object"&&e!==null?Object.fromEntries(Object.entries(e).map(([n,r])=>[n,Ki.stripValue(r,[...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 _h(s){if(s.year!==void 0)return Date.UTC(s.year,(s.month??1)-1,s.day??1,s.hour??0,s.minute??0,s.second??0)}function Wd(s){return(((s.day??0)*24+(s.hour??0))*60+(s.minute??0))*6e4+(s.second??0)*1e3}const n1=["year","month","day","hour","minute"],s1=["day","hour","minute"];function Xd(s,e){return e.filter(t=>s[t]!==void 0).join(",")}function r1(s){if(s.durationSeconds!==void 0)return s.durationSeconds*1e3;if(!s.time||!s.endTime)return;const e=s.time.year!==void 0&&s.endTime.year!==void 0,t=e?n1:s1,i=Xd(s.time,t);if(!(i===""||i!==Xd(s.endTime,t)))return e?_h(s.endTime)-_h(s.time):Wd(s.endTime)-Wd(s.time)}class Wc{constructor(e,t,i,n,r,a,o,c,l=[],h,u,d,f=[],p=[]){this.event=e,this.timeline=t,this.witnessTrack=i,this.weatherTrack=n,this.soundTrack=r,this.witness=a,this.caseId=o,this.weather=c,this.decor=l,this.weatherSource=h,this.instrumentId=u,this.exposureSeconds=d,this.milestones=f,this.references=p}provenance=Ki.empty();testimony;get witnessCount(){return 1+this.decor.filter(e=>e.kind==="witness").length}get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return Yt.byId(this.instrumentId)}static create(e,t,i){return new Wc({eventType:"sighting",time:e,place:t},new Vc,new Ga,new Va,new Wa,i)}}const a1=0,o1=0;function si(s,e){const t=s.witnessTrack.getInterpolatedPoseAt(e);if(t)return t;const i=s.event.place?.[0];if(i)return{lat:i.lat,lng:i.lng,elevationM:a1,headingDeg:void 0,pitchDeg:o1,fovDeg:Yt.fieldOfViewDeg(s.instrument)}}function ar(s,e){return s.weatherTrack.getInterpolatedWeatherAt(e)??s.weather??qp}function c1(s,e){return s.soundTrack.getInterpolatedSoundAt(e)??i1}class l1{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 $p=["nw","n","ne","e","se","s","sw","w"],h1=24,co=8,u1=3,d1=8;function lo(s,e,t){const i=s.x-e.x,n=s.y-e.y,r=Math.cos(t),a=Math.sin(t);return{x:e.x+i*r-n*a,y:e.y+i*a+n*r}}function ra(s){return{x:s.x+s.width/2,y:s.y+s.height/2}}const f1={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 Bi{static handlePointsFor(e){const{x:t,y:i,width:n,height:r}=e.bounds,a={nw:{x:t,y:i},n:{x:t+n/2,y:i},ne:{x:t+n,y:i},e:{x:t+n,y:i+r/2},se:{x:t+n,y:i+r},s:{x:t+n/2,y:i+r},sw:{x:t,y:i+r},w:{x:t,y:i+r/2},rotate:{x:t+n/2,y:i-h1}},o=ra(e.bounds),c={};for(const l of Object.keys(a))c[l]=lo(a[l],o,e.angle);return c}static hitTestHandle(e,t,i=8,n=[...$p,"rotate"]){const r=Bi.handlePointsFor(e);for(const a of n)if(Math.hypot(t.x-r[a].x,t.y-r[a].y)<=i)return a}static HANDLE_DIRECTION_DEG={e:0,se:45,s:90,sw:135,w:180,nw:225,n:270,ne:315};static resizeAxisFor(e,t){const n=((Bi.HANDLE_DIRECTION_DEG[e]+t*180/Math.PI)%180+180)%180/45,r=["ew","nwse","ns","nesw"];return r[Math.round(n)%r.length]}static resizeBounds(e,t,i,n){const r=ra(e),a=lo(n,r,-t),{x:o,y:c,width:l,height:h}=e,u=f1[i];let d=o,f=c,p=o+l,v=c+h;return u.left&&(d=Math.min(a.x,p-co)),u.right&&(p=Math.max(a.x,d+co)),u.top&&(f=Math.min(a.y,v-co)),u.bottom&&(v=Math.max(a.y,f+co)),{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:r}=e.bounds,a=Bi.resizeBounds(e.bounds,e.angle,t,i);if(e.kind==="oval")return{...e,bounds:a};const o=n===0?1:a.width/n,c=r===0?1:a.height/r;return{...e,bounds:a,points:e.points.map(l=>({x:l.x*o,y:l.y*c}))}}static rotateShape(e,t){const i=ra(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(a=>a.x)),i=Math.min(...e.map(a=>a.y)),n=Math.max(...e.map(a=>a.x+a.width)),r=Math.max(...e.map(a=>a.y+a.height));return{x:t,y:i,width:n-t,height:r-i}}static vertexPointsFor(e){const t=ra(e.bounds);return e.points.map(i=>lo({x:e.bounds.x+i.x,y:e.bounds.y+i.y},t,e.angle))}static hitTestVertex(e,t,i=d1){const n=Bi.vertexPointsFor(e);let r,a=i;return n.forEach((o,c)=>{const l=Math.hypot(t.x-o.x,t.y-o.y);l<=a&&(a=l,r=c)}),r}static toLocalPoint(e,t){const i=ra(e.bounds),n=lo(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?Bi.toLocalPoint(e,i):u),r=Math.min(...n.map(u=>u.x)),a=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+r,y:e.bounds.y+a,width:o-r,height:c-a},h=n.map(u=>({x:u.x-r,y:u.y-a}));return{...e,bounds:l,points:h}}static insertVertexNear(e,t){const i=Bi.toLocalPoint(e,t),{points:n}=e;let r=n.length-1,a=1/0;for(let c=0;c<n.length;c++){const l=n[c],h=n[(c+1)%n.length],u=Bi.distanceToSegment(i,l,h);u<a&&(a=u,r=c)}const o=[...n.slice(0,r+1),i,...n.slice(r+1)];return{...e,points:o}}static distanceToSegment(e,t,i){const n=i.x-t.x,r=i.y-t.y,a=n*n+r*r,o=a===0?0:Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/a)),c=t.x+o*n,l=t.y+o*r;return Math.hypot(e.x-c,e.y-l)}static deleteVertex(e,t){return e.points.length<=u1?e:{...e,points:e.points.filter((i,n)=>n!==t)}}}const yh=6,ho=yh/2,qd=20,Yd=24,Kd=9,$d=6,Zd=7,Jd=6,vn=4;class Xa{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:r}=e.bounds,a=t+n/2,o=i+r/2,c=e.angle%(2*Math.PI)!==0,l=Math.hypot(n,r)/2,h=c?l:n/2,u=c?l:r/2,d=Math.max(n,r)/2,f=e.brightness??0,p=f>0?Math.max(d*(1+Kd*f),Jd*f)-d:0,v=f>0?d*(1+Zd*f)-d:0,m=3*Yd*(e.blur??0)+1.5*qd*e.haloScale,g=Math.max(p,v,0)+m+2;return{x:a-h-g,y:o-u-g,width:2*(h+g),height:2*(u+g)}}paintInto(e,t,i){this.ctx.save(),this.ctx.scale(i,i),this.ctx.translate(-t.x,-t.y),this.paintShape(e.selected?{...e,selected:!1}:e),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(${(Yd*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:r,height:a}=e.bounds,o=i+r/2,c=n+a/2,l=Math.max(r,a)/2,h=Math.max(l*(1+Kd*t),Jd*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<=$d;d++){const f=d/$d,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+Zd*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),r=a=>Math.round(a+(255-a)*t);return`rgb(${r(n>>16&255)}, ${r(n>>8&255)}, ${r(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 r=Number.parseInt(n[1],16);return`rgba(${r>>16&255}, ${r>>8&255}, ${r&255}, ${i.toFixed(3)})`}paintBase(e){if(this.ctx.fillStyle=this.dazzledFill(e,e.brightness??0),this.ctx.beginPath(),e.kind==="oval"){const{x:t,y:i,width:n,height:r}=e.bounds,a=n/2,o=r/2;this.ctx.ellipse(t+a,i+o,a,o,e.angle,0,2*Math.PI)}else{const{x:t,y:i,width:n,height:r}=e.bounds;this.ctx.save(),this.ctx.translate(t+n/2,i+r/2),this.ctx.rotate(e.angle),this.ctx.translate(-n/2,-r/2),e.points.forEach((a,o)=>{o===0?this.ctx.moveTo(a.x,a.y):this.ctx.lineTo(a.x,a.y)}),this.ctx.closePath(),this.ctx.restore()}this.ctx.fill()}paintHalo(e){this.ctx.save(),this.ctx.shadowColor=e.color,this.ctx.shadowBlur=qd*e.haloScale,this.paintBase(e),this.ctx.restore()}paintSelectionHandles(e){this.paintHandleFrame(Bi.handlePointsFor(e),{includeRotate:!0}),e.kind==="polygon"&&this.paintVertexHandles(e)}paintVertexHandles(e){this.ctx.fillStyle="#39f";for(const t of Bi.vertexPointsFor(e))this.ctx.beginPath(),this.ctx.ellipse(t.x,t.y,vn,vn,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(e){this.paintOutline(Bi.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 r of e.slice(1))n.lineTo(r.x,r.y);n.closePath(),n.stroke(),n.setLineDash([])}for(const r of t){const a=Xa.landmarkColour(r.residualDeg),o=r.selected?3:2;r.selected&&(n.strokeStyle="#fff",n.lineWidth=o+3,n.beginPath(),n.ellipse(r.picture.x,r.picture.y,vn+2,vn+2,0,0,2*Math.PI),n.stroke()),r.scene&&(n.strokeStyle=a,n.lineWidth=1,n.beginPath(),n.moveTo(r.picture.x,r.picture.y),n.lineTo(r.scene.x,r.scene.y),n.stroke(),n.fillStyle=a,n.beginPath(),n.ellipse(r.scene.x,r.scene.y,vn,vn,0,0,2*Math.PI),n.fill()),n.strokeStyle=a,n.lineWidth=o,n.beginPath(),n.ellipse(r.picture.x,r.picture.y,vn+2,vn+2,0,0,2*Math.PI),n.stroke(),this.paintLabel(r.label,r.picture.x+vn+5,r.picture.y-vn-2,a)}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,r=11){const a=this.ctx;a.save(),a.font=`${r}px system-ui, sans-serif`,a.textBaseline="top";const o=a.measureText(e).width;a.fillStyle="rgba(0, 0, 0, 0.6)",a.fillRect(t-3,i-2,o+6,r+4),a.fillStyle=n,a.fillText(e,t,i),a.restore()}paintGroupHandles(e){this.paintHandleFrame(Bi.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 $p){const n=e[i];this.ctx.fillRect(n.x-ho,n.y-ho,yh,yh)}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,ho+1,ho+1,0,0,2*Math.PI),this.ctx.fill())}}const jd=.05,Qd=.08,e0=2,t0=3,p1=14,m1=.02;class g1{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,jd);for(const{param:r,ratio:a}of e.pitch)r.setTargetAtTime(Math.min(t.pitchHz*a,i.sampleRate/2-1),n,jd)}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 r=e.createBiquadFilter();r.type="lowpass",r.Q.value=1;const a=e.createGain();return a.gain.value=0,i.connect(r),n.connect(r),r.connect(a).connect(e.destination),i.start(),n.start(),{key:t,nodes:[r,a],sources:[i,n],volumeParam:a.gain,gainScale:.16,pitch:[{param:i.frequency,ratio:1},{param:n.frequency,ratio:1.006},{param:r.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 r=e.createGain(),a=e.createGain();return a.gain.value=0,n.connect(r).connect(i.frequency),i.connect(a).connect(e.destination),i.start(),n.start(),{key:t,nodes:[r,a],sources:[i,n],volumeParam:a.gain,gainScale:.22,pitch:[{param:i.frequency,ratio:1},{param:r.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 r=e.createGain();return r.gain.value=0,i.connect(n).connect(r).connect(e.destination),i.start(),{key:t,nodes:[n,r],sources:[i],volumeParam:r.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 r=e.createGain();r.gain.value=0;const a=e.createBufferSource();a.buffer=this.crackleEnvelope(e),a.loop=!0;const o=e.createGain();return o.gain.value=0,a.connect(o).connect(r.gain),i.connect(n).connect(r).connect(e.destination),i.start(),a.start(),{key:t,nodes:[n,r,o],sources:[i,a],volumeParam:o.gain,gainScale:.9,pitch:[{param:n.frequency,ratio:4}]}}async buildRecordedVoice(e,t,i){const n=this.context;if(!n)return;let r;try{r=await this.getBuffer(e)}catch(c){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",c);return}if(i!==this.voiceToken||!this.context)return;const a=n.createBufferSource();a.buffer=r,a.loop=!0;const o=n.createGain();o.gain.value=0,a.connect(o).connect(n.destination),a.start(),this.voice={key:t,nodes:[o],sources:[a],volumeParam:o.gain,gainScale:1,pitch:[]},this.requested&&this.applyTo(this.voice,this.requested)}async getBuffer(e){const t=this.context;if(!t)throw new Error("SightingAudio: AudioContext not ready — resume() must be called first");let 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*e0),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*e0),e.sampleRate),i=t.getChannelData(0);let n=0,r=0;for(let a=0;a<i.length;a++)n=(n+.02*(Math.random()*2-1))/1.02,i[a]=n,r=Math.max(r,Math.abs(n));if(r>0)for(let a=0;a<i.length;a++)i[a]/=r;return t}crackleEnvelope(e){if(!this.crackleBuffer){const t=e.createBuffer(1,Math.floor(e.sampleRate*t0),e.sampleRate),i=t.getChannelData(0),n=Math.max(1,Math.floor(m1*e.sampleRate)),r=Math.round(t0*p1);for(let a=0;a<r;a++){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,Qd/3);const n=i+Qd;for(const r of e.sources){r.onended=()=>{r.disconnect();for(const a of e.nodes)a.disconnect()};try{r.stop(n)}catch{r.disconnect();for(const a of e.nodes)a.disconnect()}}}}function xc(s){return[...s].sort((e,t)=>e.t-t.t)}function i0(s,e){let t;for(const i of xc(s)){if(i.t>e)break;t=i}return t}const sl=Math.PI/180,uo=180/Math.PI;class Yn{constructor(e,t,i){this.kind=e,this.canvasHeightPx=t,this.fovDeg=i;const n=i*sl/2;this.focalPx=e==="equidistant"?t/2/n:t/2/Math.tan(n)}focalPx;static of(e,t,i){return new Yn(e.projection,t,i)}degToPx(e){const t=e*sl;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*sl;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(yt.angularWidthDeg(e))}}class $i{static fovOf(e,t){return si(e,t)?.fovDeg??Yt.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:r}=i.toBoundsSize(t.angular),a={x:t.bounds.x+(t.bounds.width-n)/2,y:t.bounds.y+(t.bounds.height-r)/2,width:n,height:r};if(t.kind!=="polygon")return{...t,bounds:a};const o=t.bounds.width===0?1:n/t.bounds.width,c=t.bounds.height===0?1:r/t.bounds.height;return{...t,bounds:a,points:t.points.map(l=>({x:l.x*o,y:l.y*c}))}})}static toAim(e){this.eachKeyframe(e,(t,i,n)=>{const r=this.aimFrom(e,i,n,t.bounds);return r?{...t,aim:r}:t})}static aimOf(e,t,i){const n=Yn.of(e.instrument,yt.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 r=this.frameCentre(e),a=t.radiusPxToAngleDeg(n.x+n.width/2-r.x),o=t.radiusPxToAngleDeg(r.y-(n.y+n.height/2));return{azimuthDeg:((i.headingDeg+a)%360+360)%360,altitudeDeg:i.pitchDeg+o}}static toPosition(e){this.eachKeyframe(e,(t,i,n)=>{if(!t.aim||n?.headingDeg===void 0)return t;const r=this.frameCentre(e),a=this.shortestArc(t.aim.azimuthDeg-n.headingDeg),o=t.aim.altitudeDeg-n.pitchDeg,c=r.x+this.offAxisPx(i,a)-t.bounds.width/2,l=r.y-this.offAxisPx(i,o)-t.bounds.height/2;return{...t,bounds:{...t.bounds,x:c,y:l}}})}static frameCentre(e){return{x:Yt.frameWidthPx(e.instrument,yt.CANVAS_HEIGHT_PX)/2,y:yt.CANVAS_HEIGHT_PX/2}}static shortestArc(e){return(e%360+540)%360-180}static offAxisPx(e,t){return Math.abs(t)>=$i.OFF_CANVAS_DEG?Math.sign(t)*$i.OFF_CANVAS_PX:e.angleDegToRadiusPx(t)}static OFF_CANVAS_DEG=89;static OFF_CANVAS_PX=1e5;static reproject(e,t,i){const n=Yt.frameWidthPx(t,yt.CANVAS_HEIGHT_PX)/2,r=Yt.frameWidthPx(e.instrument,yt.CANVAS_HEIGHT_PX)/2,a=yt.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=Yn.of(t,yt.CANVAS_HEIGHT_PX,l),u=Yn.of(e.instrument,yt.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-a,m=Math.hypot(p,v),g=m===0?1:u.angleDegToRadiusPx(h.radiusPxToAngleDeg(m))/m,b={...f,x:r+p*g-f.width/2,y:a+v*g-f.height/2};return{...d,shape:{...d.shape,bounds:b}}}))}this.toBounds(e)}static eachKeyframe(e,t){const{timeline:i}=e;for(const n of[...i.allKeyframes]){const r=si(e,n.t),a=this.fovOf(e,n.t),o=Yn.of(e.instrument,yt.CANVAS_HEIGHT_PX,a);i.addKeyframe(n.t,n.shapes.map(c=>({...c,shape:t(c.shape,o,r)})))}}}function v1(s){return Ki.restore(M1(s),s.provenance)}function M1(s){return $i.toAngular(s),$i.toAim(s),{version:1,time:s.event.time,endTime:s.event.endTime,durationSeconds:s.event.durationSeconds,utcOffsetHours:s.event.utcOffsetHours,timeZone:s.event.timeZone,place:s.event.place,witness:s.witness,testimony:s.testimony,caseId:s.caseId,description:s.event.description,tags:s.event.tags,timeline:s.timeline.toJSON(),witnessTrack:s.witnessTrack.toJSON(),weatherTrack:s.weatherTrack.toJSON(),soundTrack:s.soundTrack.toJSON(),weather:s.weather,decor:s.decor,milestones:s.milestones.length>0?s.milestones:void 0,references:s.references.length>0?s.references:void 0,weatherSource:s.weatherSource,instrument:s.instrumentId,exposureSeconds:s.exposureSeconds}}function x1(s){const{recording:e,provenance:t}=Ki.strip(s),i=_1(e);return i.provenance=t,i}function _1(s){const e=new Wc({eventType:"sighting",time:s.time,endTime:s.endTime,durationSeconds:s.durationSeconds,utcOffsetHours:s.utcOffsetHours,timeZone:s.timeZone,place:s.place,description:s.description,tags:s.tags},Vc.fromJSON(s.timeline),s.witnessTrack?Ga.fromJSON(s.witnessTrack):new Ga,s.weatherTrack?Va.fromJSON(s.weatherTrack):new Va,s.soundTrack?Wa.fromJSON(s.soundTrack):new Wa,s.witness,s.caseId,s.weather,s.decor??[],s.weatherSource,s.instrument,s.exposureSeconds??s.witnessTrack?.keyframes.map(t=>t.pose.exposureSeconds).find(t=>t!==void 0),xc(s.milestones??[]),s.references??[]);return e.testimony=s.testimony,$i.toBounds(e),$i.toPosition(e),e}const n0=2;function Zp(s){return s==="building"||s==="vehicle"}function y1(s,e){const t=s.litKeyframes;if(!t||t.length===0)return s.lit??!1;let i=t[0];for(const n of t){if(n.t>e)break;i=n}return i.lit}function S1(s,e){return s.pattern.kind==="steady"?!0:Jp(s,e,e+1)>.5}function Jp(s,e,t){if(s.pattern.kind==="steady")return 1;const{perMinute:i,dutyCycle:n,phase:r=0}=s.pattern,a=Math.min(Math.max(n,0),1);if(a===0||i<=0)return 0;const o=6e4/i,c=e/o+r,l=t/o+r;if(l<=c)return Math.min(Math.max(c-Math.floor(c),0),a)<a?1:0;const h=u=>Math.floor(u)*a+Math.min(u-Math.floor(u),a);return(h(l)-h(c))/(l-c)}function qu(s,e){const t=s.track,i={eastM:s.eastM,northM:s.northM,altitudeM:0,headingDeg:s.headingDeg};if(!t||t.length===0)return i;if(t.length===1||e<=t[0].t)return s0(t[0],s);const n=t[t.length-1];if(e>=n.t)return s0(n,s);for(let r=0;r<t.length-1;r++){const a=t[r],o=t[r+1];if(e<a.t||e>o.t)continue;const c=o.t-a.t,l=c===0?0:(e-a.t)/c;return{eastM:a.eastM+(o.eastM-a.eastM)*l,northM:a.northM+(o.northM-a.northM)*l,altitudeM:(a.altitudeM??0)+((o.altitudeM??0)-(a.altitudeM??0))*l,headingDeg:a.headingDeg??s.headingDeg}}return i}function s0(s,e){return{eastM:s.eastM,northM:s.northM,altitudeM:s.altitudeM??0,headingDeg:s.headingDeg??e.headingDeg}}class rn{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),r=Math.max(0,e-n);return{fromMs:n,toMs:e,ms:r,seconds:r/1e3}}static instants(e,t,i,n,r){if(!(n>0))return 1;const a=r>0?rn.travelDegOver(e,t,i,i+n*1e3)/r/rn.PIXELS_PER_INSTANT:0,o=rn.flashesOver(e,n)*rn.INSTANTS_PER_FLASH,c=Math.ceil(Math.max(a,o));return c<2?1:Math.min(rn.MAX_INSTANTS,c)}static travelDegOver(e,t,i,n){let r=0;for(const a of e){if(!a.track||a.track.length<2)continue;const o=rn.directionAt(a,t,i),c=rn.directionAt(a,t,n),l=Math.min(1,Math.max(-1,o.x*c.x+o.y*c.y+o.z*c.z));r=Math.max(r,Math.acos(l)*180/Math.PI)}return r}static flashesOver(e,t){let i=0;for(const n of e)for(const r of n.lights??[])r.pattern.kind==="flash"&&(i=Math.max(i,r.pattern.perMinute));return i/60*t}static directionAt(e,t,i){const n=qu(e,i),r=n.eastM,a=n.altitudeM-t,o=n.northM,c=Math.hypot(r,a,o);return c===0?{x:0,y:1,z:0}:{x:r/c,y:a/c,z:o/c}}}function Yu(s,e){for(const t of s){const i=t.toLowerCase().split("-")[0];if(e.includes(i))return i}return"en"}class _c{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 Ms{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[Ms.base(i)];if(n)return n}const t=new Set(this.preferences.map(i=>Ms.base(i)));for(const[i,n]of Object.entries(e))if(n&&t.has(Ms.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 r={...e},a=Object.keys(r).find(o=>o===i)??Object.keys(r).find(o=>Ms.base(o)===Ms.base(i))??i;return n===void 0?delete r[a]:r[a]=n,Object.keys(r).length===0?void 0:r}static base(e){return e.toLowerCase().split("-")[0]}}const b1=["en","fr"],E1={en:()=>gc(()=>Promise.resolve().then(()=>A1),void 0,import.meta.url).then(s=>s.ufoMessages_en),fr:()=>gc(()=>import("./UfoMessages_fr-CnenjNH2.js"),[],import.meta.url).then(s=>s.ufoMessages_fr)};function w1(s){return E1[s]()}const jp={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"},A1=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:jp},Symbol.toStringTag,{value:"Module"})),Qp=Math.PI/180,T1=180/Math.PI,R1=256,D1=19;function C1(s,e){return 156543.03392*Math.cos(s*Qp)/2**e}function I1(s,e){return C1(s,e)*R1}function em(s,e){let t=0;for(;t<D1&&I1(s,t+1)>=e;)t++;return t}function lc(s){const e=s*Qp;return(1-Math.log(Math.tan(e)+1/Math.cos(e))/Math.PI)/2}function tm(s,e,t){const i=2**t;return{x:(s+180)/360*i,y:lc(e)*i}}function im(s,e,t){const i=lc(s.north),n=lc(s.south);return{x:(e-s.west)/(s.east-s.west),y:(lc(t)-i)/(n-i)}}function P1(s,e,t){const{x:i,y:n}=tm(s,e,t);return{x:Math.floor(i),y:Math.floor(n),z:t}}function L1(s){const e=2**s.z,t=s.x/e*360-180,i=(s.x+1)/e*360-180,n=r0(s.y,e);return{south:r0(s.y+1,e),north:n,west:t,east:i}}function r0(s,e){const t=s/e;return Math.atan(Math.sinh(Math.PI*(1-2*t)))*T1}function nm(s,e,t,i){const n=P1(s,e,t),r=Math.floor(i/2),a=[];for(let l=-r;l<=r;l++)for(let h=-r;h<=r;h++)a.push({x:n.x+h,y:n.y+l,z:t});const o=a.map(L1),c={south:Math.min(...o.map(l=>l.south)),north:Math.max(...o.map(l=>l.north)),west:Math.min(...o.map(l=>l.west)),east:Math.max(...o.map(l=>l.east))};return{tiles:a,bounds:c}}class Us{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 r of this.targets){const a=Math.hypot(r.x-e,r.y-t);a>r.radius||a>n||(i=r,n=a)}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=im(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),r=this.toCanvas(e.bounds,i.bounds.south,i.bounds.east);t.drawImage(i.source,n.x,n.y,r.x-n.x,r.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 r=(i.headingDeg-90)*Math.PI/180;t.beginPath(),t.moveTo(n.x,n.y),t.lineTo(n.x+Math.cos(r)*10,n.y+Math.sin(r)*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:r}=this,a=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;r.save(),r.beginPath(),r.moveTo(a.x,a.y),r.arc(a.x,a.y,o,c-l,c+l),r.closePath();const h=r.createRadialGradient(a.x,a.y,0,a.x,a.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)"),r.fillStyle=h,r.fill(),r.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,r)=>Number(n.current)-Number(r.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:Us.MARKER_RADIUS_PX}),t.beginPath(),t.arc(n.x,n.y,Us.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 r=e.markers.some(a=>{if(!a.current)return!1;const o=hi(a.lat,a.lng,t.lat,t.lng);return Math.hypot(o.x,o.z)<=Us.ON_MARKER_M});i.beginPath(),i.arc(n.x,n.y,r?Us.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),r||(i.fillStyle="#ff5a3c",i.fill()),i.lineWidth=4,i.strokeStyle="rgba(0, 0, 0, 0.5)",i.stroke(),i.lineWidth=r?3:2.5,i.strokeStyle=r?"#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 r=this.height-4;i.textAlign="right";for(const f of n.slice().reverse())this.paintOutlinedText(f,this.width-6,r),r-=11;const a=(e.south+e.north)/2,c=Math.abs(hi(a,e.east,a,e.west).x)/this.width,l=Us.SCALE_STEPS_M.find(f=>f/c<=this.width/3);if(l===void 0)return;const h=l/c,u=8,d=r-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 r of e.split(" ")){const a=n?`${n} ${r}`:r;n&&this.ctx.measureText(a).width>t?(i.push(n),n=r):n=a}return n&&i.push(n),i}}const Wi=256,a0=3,N1=32768;class O1{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,r=Math.abs(hi(i,e.east,i,e.west).x),a=Math.abs(hi(e.north,n,e.south,n).z),o=em(i,Math.max(r,a)),{tiles:c}=nm(n,i,o,a0),l=a0*Wi,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 r=this.tileUrlTemplate.replace("{z}",String(e.z)).replace("{x}",String(e.x)).replace("{y}",String(e.y)),a=await this.fetchImpl(r);if(!a.ok)throw new Error(`Elevation tile fetch failed (${a.status}): ${r}`);const o=await createImageBitmap(await a.blob()),c=document.createElement("canvas");c.width=Wi,c.height=Wi;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,Wi,Wi),u=(e.x-t.x)*Wi,d=(e.y-t.y)*Wi;for(let f=0;f<Wi;f++)for(let p=0;p<Wi;p++){const v=(f*Wi+p)*4,m=h[v]*256+h[v+1]+h[v+2]/256-N1,g=u+p,b=d+f;i[b*n+g]=m}}sampleAt(e,t,i,n,r,a){const{x:o,y:c}=tm(t,e,i),l=(o-n.x)*Wi,h=(c-n.y)*Wi,u=Math.max(0,Math.min(a-1,Math.floor(l))),d=Math.max(0,Math.min(a-1,Math.floor(h))),f=Math.min(a-1,u+1),p=Math.min(a-1,d+1),v=l-u,m=h-d,g=r[d*a+u],b=r[d*a+f],y=r[p*a+u],_=r[p*a+f],E=g+(b-g)*v,w=y+(_-y)*v;return E+(w-E)*m}}const rl=256,o0=3;async function U1(s,e,t,i){const n=(s.south+s.north)/2,r=(s.west+s.east)/2,a=Math.abs(hi(n,s.east,n,s.west).x),o=Math.abs(hi(s.north,r,s.south,r).z),c=em(n,Math.max(a,o)/2),{tiles:l,bounds:h}=nm(r,n,c,o0),u=o0*rl,d=document.createElement("canvas");d.width=u,d.height=u;const f=d.getContext("2d");if(!f)throw new Error("2D canvas context unavailable");const p=l[0];await Promise.all(l.map(async g=>{const b=t(g),y=await i(b);if(!y.ok)throw new Error(`Imagery tile fetch failed (${y.status}): ${b}`);const _=await createImageBitmap(await y.blob());f.drawImage(_,(g.x-p.x)*rl,(g.y-p.y)*rl)}));const v=document.createElement("canvas");v.width=e.width,v.height=e.height;const m=v.getContext("2d");if(!m)throw new Error("2D canvas context unavailable");return m.drawImage(d,0,0,u,u,0,0,e.width,e.height),{source:v,width:e.width,height:e.height,bounds:h}}class F1{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 U1(e,t,i=>this.tileUrlTemplate.replace("{z}",String(i.z)).replace("{y}",String(i.y)).replace("{x}",String(i.x)),this.fetchImpl)}}function k1(){return{elevation:new O1,imagery:sm()}}function sm(){return new F1}const z1=new Set,zr="show-witness-map",Br="hide-milestones";class ki extends HTMLElement{static get observedAttributes(){return["src",zr,Br]}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=Wc.create();sightingAudio=new g1;soundPreview;player;loopEnabled=!1;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;selectionShown=!0;overlayPainter;enableClickToPlay=!0;fullscreenTarget;messages=jp;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 r=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${e.clientX-r.left+12}px`,this.tooltip.style.top=`${e.clientY-r.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>${Gg}</style>${Hg}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Xa(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 Us(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===zr&&this.applyWitnessMapDefault(),e===Br&&this.setMilestonesShown(!this.hasAttribute(Br))}async loadFromSrc(e){this.sightingData=await Kp.json(e)}get sightingData(){return v1(this.currentSighting)}set sightingData(e){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=x1(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?xc(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 r=this.said.read(i.label)??"",a=this.said.read(i.note),o=a?`${r} — ${a}`:r;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 r;for(const a of this.milestoneMarks.children){const o=Number(a.dataset.t);Math.abs(o-e)>n||(!r||Math.abs(o-e)<Math.abs(r.t-e))&&(r={t:o,name:a.title})}return r}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,r=this.markNear(n);r?this.seekInput.title=r.name:this.seekInput.removeAttribute("title")}showMilestoneAt(e){const t=this.milestonesShown&&this.sighting.milestones.length>0?i0(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),r=n?` — ${n}`:"";this.milestoneCaption.replaceChildren(i,document.createTextNode(r))}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=rn.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),r=Math.min(ki.MAX_TRAVEL_STEPS,Math.max(i,n)),a=[];for(let o=0;o<r;o++)a.push(t.fromMs+t.ms*o/(r-1));return a}travelPxOver(e,t){const i=this.shapesAt(e),n=this.shapesAt(e+t);let r=0;for(const[a,o]of i){const c=n.get(a);if(!c)continue;const l=c.bounds.x+c.bounds.width/2-(o.bounds.x+o.bounds.width/2),h=c.bounds.y+c.bounds.height/2-(o.bounds.y+o.bounds.height/2);r=Math.max(r,Math.hypot(l,h))}return r}shapeAt(e,t,i){for(const n of this.exposureTimes()){const r=this.currentSighting.timeline.hitTest(n,e,t,i);if(r)return r}}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=Yt.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:z1;this.canvasRenderer.setStarPoints(Yt.starPointsOf(this.sighting.instrument));const n=(si(this.sighting,e)?.rollDeg??0)+this.gaitAt(e).rollDeg;this.canvasRenderer.setRoll(n*Math.PI/180);const r=this.exposureInstants(e),a=this.frameShift;if(this.paintsShapes)for(const o of r)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,a))}for(const[o,c]of r[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,a)));if(this.selectionShown&&i.size>1){const o=Bi.groupBoundsFor([...t].filter(([c])=>i.has(c)).map(([,c])=>c.bounds));this.canvasRenderer.paintGroupHandles(o)}this.overlayPainter?.(this.canvasRenderer),this.mapShapeBounds=r.flatMap(o=>[...o.shapes.values()].filter(c=>c.transparency<1).map(c=>this.shifted(c,a).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(c1(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 l1(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(zr)&&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=Ha.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=sm(),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],r=[0,e.width],a=ki.WITNESS_MAP_CLEARANCE_PX,o=i(...n,0),c=i(...r,0);if(this.witnessMapPanel.classList.toggle("subject-overlap",o&&c),this.witnessMapPanel.classList.contains("on-the-left")){!o&&(c||!i(n[0],n[1],a))&&this.witnessMapPanel.classList.remove("on-the-left");return}i(n[0],n[1],0)&&!i(r[0],r[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=[],r=this.currentSighting.milestones.length>0?i0(this.currentSighting.milestones,e):void 0;for(const a of this.milestonesShown?xc(this.currentSighting.milestones):[]){const o=si(this.currentSighting,a.t);o?.lat===void 0||o.lng===void 0||n.push({label:this.said.read(a.label)??"",note:this.said.read(a.note),t:a.t,lat:o.lat,lng:o.lng,current:a===r})}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?Yn.of(i,this.canvas.height,t.fovDeg).halfWidthAngleDeg(Yt.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=qu(i,e),{lat:r,lng:a}=qn(n.eastM,-n.northM,t.lat,t.lng);return{lat:r,lng:a,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),r=Yn.of(this.currentSighting.instrument,this.canvas.height,n?.fovDeg??60);return{x:-r.angleDegToRadiusPx(t),y:r.angleDegToRadiusPx(i)}}gaitAt(e){return qt.of(this.currentSighting)?.offsetAt(e)??qt.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 Ms(_c.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const e=Yu(_c.preferencesFor(this),b1);e!=="en"&&this.applyMessages(await w1(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=r1(e);this.realDurationMs=t!==void 0&&t>0?t:void 0,this.realStartMs=e.time?_h(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?l0(c0(this.realStartMs+i)):fo(i)}formatEndOfTimeline(){return this.realDurationMs===void 0?fo(this.currentSighting.timeline.duration):this.canShowClockTime?l0(c0(this.realStartMs+this.realDurationMs)):fo(this.realDurationMs)}}function c0(s){const e=new Date(s);return{hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds()}}function l0(s){if(s.hour===void 0)return"0:00";const e=t=>String(t).padStart(2,"0");return s.second?`${e(s.hour)}:${e(s.minute??0)}:${e(s.second)}`:`${e(s.hour)}:${e(s.minute??0)}`}function fo(s){const e=Math.round(s/1e3),t=Math.floor(e/60),i=e%60;return`${t}:${String(i).padStart(2,"0")}`}const Sh="rr0-ufo";function rm(){customElements.get(Sh)||customElements.define(Sh,ki)}/**
|
|
628
628
|
* @license
|
|
629
629
|
* Copyright 2010-2026 Three.js Authors
|
|
630
630
|
* SPDX-License-Identifier: MIT
|
|
631
|
-
*/const Ku="185",B1=0,h0=1,H1=2,Na=1,G1=2,Aa=3,Es=0,It=1,on=2,Cn=0,qs=1,Hi=2,u0=3,d0=4,am=5,Fs=100,V1=101,W1=102,X1=103,q1=104,Y1=200,om=201,K1=202,$1=203,bh=204,yc=205,Z1=206,J1=207,j1=208,Q1=209,e2=210,t2=211,i2=212,n2=213,s2=214,wh=0,Eh=1,Ah=2,Zr=3,Th=4,Rh=5,Dh=6,Ch=7,$u=0,r2=1,a2=2,In=0,cm=1,lm=2,hm=3,um=4,dm=5,fm=6,pm=7,f0="attached",o2="detached",mm=300,$s=301,Jr=302,al=303,ol=304,Xc=306,qa=1e3,Ei=1001,Ih=1002,Dt=1003,c2=1004,po=1005,at=1006,cl=1007,Gs=1008,Bi=1009,gm=1010,vm=1011,Ya=1012,Zu=1013,hn=1014,Ai=1015,$t=1016,Ju=1017,ju=1018,Ka=1020,Mm=35902,xm=35899,_m=1021,ym=1022,xi=1023,Jn=1026,Vs=1027,qc=1028,Qu=1029,Zs=1030,ed=1031,td=1033,hc=33776,uc=33777,dc=33778,fc=33779,Ph=35840,Lh=35841,Nh=35842,Oh=35843,Uh=36196,Fh=37492,kh=37496,zh=37488,Bh=37489,Sc=37490,Hh=37491,Gh=37808,Vh=37809,Wh=37810,Xh=37811,qh=37812,Yh=37813,Kh=37814,$h=37815,Zh=37816,Jh=37817,jh=37818,Qh=37819,eu=37820,tu=37821,iu=36492,nu=36494,su=36495,ru=36283,au=36284,bc=36285,ou=36286,wc=2300,cu=2301,ll=2302,p0=2303,m0=2400,g0=2401,v0=2402,l2=2500,Uw=0,Fw=1,kw=2,h2=3200,Ec=0,u2=1,xs="",Pi="srgb",Ac="srgb-linear",Tc="linear",ut="srgb",or=7680,M0=519,d2=512,f2=513,p2=514,id=515,m2=516,g2=517,nd=518,v2=519,lu=35044,Rc="300 es",Rn=2e3,$a=2001;function M2(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}function x2(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Za(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function _2(){const s=Za("canvas");return s.style.display="block",s}const x0={};function Dc(...s){const e="THREE."+s.shift();console.log(e,...s)}function Sm(s){const e=s[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=s[1];t&&t.isStackTrace?s[0]+=" "+t.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function Ee(...s){s=Sm(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...s)}}function ke(...s){s=Sm(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...s)}}function Hr(...s){const e=s.join(" ");e in x0||(x0[e]=!0,Ee(...s))}function y2(s,e,t){return new Promise(function(i,n){function r(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:n();break;case s.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}const S2={[wh]:Eh,[Ah]:Dh,[Th]:Ch,[Zr]:Rh,[Eh]:wh,[Dh]:Ah,[Ch]:Th,[Rh]:Zr};class er{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 r=n.indexOf(t);r!==-1&&n.splice(r,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 r=0,a=n.length;r<a;r++)n[r].call(this,e);e.target=null}}}const mi=["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 _0=1234567;const Oa=Math.PI/180,jr=180/Math.PI;function ln(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(mi[s&255]+mi[s>>8&255]+mi[s>>16&255]+mi[s>>24&255]+"-"+mi[e&255]+mi[e>>8&255]+"-"+mi[e>>16&15|64]+mi[e>>24&255]+"-"+mi[t&63|128]+mi[t>>8&255]+"-"+mi[t>>16&255]+mi[t>>24&255]+mi[i&255]+mi[i>>8&255]+mi[i>>16&255]+mi[i>>24&255]).toLowerCase()}function Je(s,e,t){return Math.max(e,Math.min(t,s))}function sd(s,e){return(s%e+e)%e}function b2(s,e,t,i,n){return i+(s-e)*(n-i)/(t-e)}function w2(s,e,t){return s!==e?(t-s)/(e-s):0}function Ua(s,e,t){return(1-t)*s+t*e}function E2(s,e,t,i){return Ua(s,e,1-Math.exp(-t*i))}function A2(s,e=1){return e-Math.abs(sd(s,e*2)-e)}function T2(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function R2(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function D2(s,e){return s+Math.floor(Math.random()*(e-s+1))}function C2(s,e){return s+Math.random()*(e-s)}function I2(s){return s*(.5-Math.random())}function P2(s){s!==void 0&&(_0=s);let e=_0+=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 L2(s){return s*Oa}function N2(s){return s*jr}function O2(s){return(s&s-1)===0&&s!==0}function U2(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function F2(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function k2(s,e,t,i,n){const r=Math.cos,a=Math.sin,o=r(t/2),c=a(t/2),l=r((e+i)/2),h=a((e+i)/2),u=r((e-i)/2),d=a((e-i)/2),f=r((i-e)/2),p=a((i-e)/2);switch(n){case"XYX":s.set(o*h,c*u,c*d,o*l);break;case"YZY":s.set(c*d,o*h,c*u,o*l);break;case"ZXZ":s.set(c*u,c*d,o*h,o*l);break;case"XZX":s.set(o*h,c*p,c*f,o*l);break;case"YXY":s.set(c*f,o*h,c*p,o*l);break;case"ZYZ":s.set(c*p,c*f,o*h,o*l);break;default:Ee("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function cn(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function dt(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const zw={DEG2RAD:Oa,RAD2DEG:jr,generateUUID:ln,clamp:Je,euclideanModulo:sd,mapLinear:b2,inverseLerp:w2,lerp:Ua,damp:E2,pingpong:A2,smoothstep:T2,smootherstep:R2,randInt:D2,randFloat:C2,randFloatSpread:I2,seededRandom:P2,degToRad:L2,radToDeg:N2,isPowerOfTwo:O2,ceilPowerOfTwo:U2,floorPowerOfTwo:F2,setQuaternionFromProperEuler:k2,normalize:dt,denormalize:cn};class Ae{static{Ae.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),r=this.x-e.x,a=this.y-e.y;return this.x=r*i-a*n+e.x,this.y=r*n+a*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,r,a,o){let c=i[n+0],l=i[n+1],h=i[n+2],u=i[n+3],d=r[a+0],f=r[a+1],p=r[a+2],v=r[a+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 b=Math.acos(m),y=Math.sin(b);g=Math.sin(g*b)/y,o=Math.sin(o*b)/y,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 b=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=b,l*=b,h*=b,u*=b}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,i,n,r,a){const o=i[n],c=i[n+1],l=i[n+2],h=i[n+3],u=r[a],d=r[a+1],f=r[a+2],p=r[a+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,r=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(i/2),h=o(n/2),u=o(r/2),d=c(i/2),f=c(n/2),p=c(r/2);switch(a){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:Ee("Quaternion: .setFromEuler() encountered an unknown order: "+a)}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],r=t[8],a=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=(r-l)*f,this._z=(a-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+a)/f,this._z=(r+l)/f}else if(o>u){const f=2*Math.sqrt(1+o-i-u);this._w=(r-l)/f,this._x=(n+a)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+u-i-o);this._w=(a-n)/f,this._x=(r+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,r=e._z,a=e._w,o=t._x,c=t._y,l=t._z,h=t._w;return this._x=i*h+a*o+n*l-r*c,this._y=n*h+a*c+r*o-i*l,this._z=r*h+a*l+i*c-n*o,this._w=a*h-i*o-n*c-r*l,this._onChangeCallback(),this}slerp(e,t){let i=e._x,n=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,n=-n,r=-r,a=-a,o=-o);let c=1-t;if(o<.9995){const l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,t=Math.sin(t*l)/h,this._x=this._x*c+i*t,this._y=this._y*c+n*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this._onChangeCallback()}else this._x=this._x*c+i*t,this._y=this._y*c+n*t,this._z=this._z*c+r*t,this._w=this._w*c+a*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),r=Math.sqrt(i);return this.set(n*Math.sin(e),n*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class 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(y0.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(y0.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*n,this.y=r[1]*t+r[4]*i+r[7]*n,this.z=r[2]*t+r[5]*i+r[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,r=e.elements,a=1/(r[3]*t+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*n+r[12])*a,this.y=(r[1]*t+r[5]*i+r[9]*n+r[13])*a,this.z=(r[2]*t+r[6]*i+r[10]*n+r[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,n=this.z,r=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*n-o*i),h=2*(o*t-r*n),u=2*(r*i-a*t);return this.x=t+c*l+a*u-o*h,this.y=i+c*h+o*l-r*u,this.z=n+c*u+r*h-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*n,this.y=r[1]*t+r[5]*i+r[9]*n,this.z=r[2]*t+r[6]*i+r[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,r=e.z,a=t.x,o=t.y,c=t.z;return this.x=n*c-r*o,this.y=r*a-i*c,this.z=i*o-n*a,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,y0=new Qn;class He{static{He.prototype.isMatrix3=!0}constructor(e,t,i,n,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,n,r,a,o,c,l)}set(e,t,i,n,r,a,o,c,l){const h=this.elements;return h[0]=e,h[1]=n,h[2]=o,h[3]=t,h[4]=r,h[5]=c,h[6]=i,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,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,r=this.elements,a=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],b=n[1],y=n[4],_=n[7],w=n[2],E=n[5],R=n[8];return r[0]=a*v+o*b+c*w,r[3]=a*m+o*y+c*E,r[6]=a*g+o*_+c*R,r[1]=l*v+h*b+u*w,r[4]=l*m+h*y+u*E,r[7]=l*g+h*_+u*R,r[2]=d*v+f*b+p*w,r[5]=d*m+f*y+p*E,r[8]=d*g+f*_+p*R,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8];return t*a*h-t*o*l-i*r*h+i*o*c+n*r*l-n*a*c}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=h*a-o*l,d=o*c-h*r,f=l*r-a*c,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*a)*v,e[3]=d*v,e[4]=(h*t-n*c)*v,e[5]=(n*r-o*t)*v,e[6]=f*v,e[7]=(i*c-l*t)*v,e[8]=(a*t-i*r)*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,r,a,o){const c=Math.cos(r),l=Math.sin(r);return this.set(i*c,i*l,-i*(c*a+l*o)+a+e,-n*l,n*c,-n*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return Hr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(ul.makeScale(e,t)),this}rotate(e){return Hr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(ul.makeRotation(-e)),this}translate(e,t){return Hr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(ul.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 ul=new He,S0=new He().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),b0=new He().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function z2(){const s={enabled:!0,workingColorSpace:Ac,spaces:{},convert:function(n,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===ut&&(n.r=$n(n.r),n.g=$n(n.g),n.b=$n(n.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(n.applyMatrix3(this.spaces[r].toXYZ),n.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ut&&(n.r=Gr(n.r),n.g=Gr(n.g),n.b=Gr(n.b))),n},workingToColorSpace:function(n,r){return this.convert(n,this.workingColorSpace,r)},colorSpaceToWorking:function(n,r){return this.convert(n,r,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===xs?Tc:this.spaces[n].transfer},getToneMappingMode:function(n){return this.spaces[n].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(n,r=this.workingColorSpace){return n.fromArray(this.spaces[r].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,r,a){return n.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(n,r){return Hr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(n,r)},toWorkingColorSpace:function(n,r){return Hr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(n,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return s.define({[Ac]:{primaries:e,whitePoint:i,transfer:Tc,toXYZ:S0,fromXYZ:b0,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Pi},outputColorSpaceConfig:{drawingBufferColorSpace:Pi}},[Pi]:{primaries:e,whitePoint:i,transfer:ut,toXYZ:S0,fromXYZ:b0,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Pi}}}),s}const et=z2();function $n(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Gr(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let cr;class B2{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{cr===void 0&&(cr=Za("canvas")),cr.width=e.width,cr.height=e.height;const n=cr.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),i=cr}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=Za("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),r=n.data;for(let a=0;a<r.length;a++)r[a]=$n(r[a]/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($n(t[i]/255)*255):t[i]=$n(t[i]);return{data:t,width:e.width,height:e.height}}else return Ee("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let H2=0;class rd{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:H2++}),this.uuid=ln(),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 r;if(Array.isArray(n)){r=[];for(let a=0,o=n.length;a<o;a++)n[a].isDataTexture?r.push(dl(n[a].image)):r.push(dl(n[a]))}else r=dl(n);i.url=r}return t||(e.images[this.uuid]=i),i}}function dl(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?B2.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(Ee("Texture: Unable to serialize Texture."),{})}let G2=0;const fl=new D;class oi extends er{constructor(e=oi.DEFAULT_IMAGE,t=oi.DEFAULT_MAPPING,i=Ei,n=Ei,r=at,a=Gs,o=xi,c=Bi,l=oi.DEFAULT_ANISOTROPY,h=xs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:G2++}),this.uuid=ln(),this.name="",this.source=new rd(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Ae(0,0),this.repeat=new Ae(1,1),this.center=new Ae(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new He,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(fl).x}get height(){return this.source.getSize(fl).y}get depth(){return this.source.getSize(fl).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){Ee(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){Ee(`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!==mm)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case qa:e.x=e.x-Math.floor(e.x);break;case Ei:e.x=e.x<0?0:1;break;case Ih:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case qa:e.y=e.y-Math.floor(e.y);break;case Ei:e.y=e.y<0?0:1;break;case Ih: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++}}oi.DEFAULT_IMAGE=null;oi.DEFAULT_MAPPING=mm;oi.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,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*n+a[12]*r,this.y=a[1]*t+a[5]*i+a[9]*n+a[13]*r,this.z=a[2]*t+a[6]*i+a[10]*n+a[14]*r,this.w=a[3]*t+a[7]*i+a[11]*n+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,n,r;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 y=(l+1)/2,_=(f+1)/2,w=(g+1)/2,E=(h+d)/4,R=(u+v)/4,x=(p+m)/4;return y>_&&y>w?y<.01?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(y),n=E/i,r=R/i):_>w?_<.01?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(_),i=E/n,r=x/n):w<.01?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(w),i=R/r,n=x/r),this.set(i,n,r,t),this}let b=Math.sqrt((m-p)*(m-p)+(u-v)*(u-v)+(d-h)*(d-h));return Math.abs(b)<.001&&(b=1),this.x=(m-p)/b,this.y=(u-v)/b,this.z=(d-h)/b,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 V2 extends er{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:at,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},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},r=new oi(n),a=i.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(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:at,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let 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,r=this.textures.length;n<r;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 rd(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 ui extends V2{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class bm extends oi{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=Dt,this.minFilter=Dt,this.wrapR=Ei,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class wm extends oi{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=Dt,this.minFilter=Dt,this.wrapR=Ei,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ye{static{Ye.prototype.isMatrix4=!0}constructor(e,t,i,n,r,a,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,r,a,o,c,l,h,u,d,f,p,v,m)}set(e,t,i,n,r,a,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]=r,g[5]=a,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 Ye().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/lr.setFromMatrixColumn(e,0).length(),r=1/lr.setFromMatrixColumn(e,1).length(),a=1/lr.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]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,n=e.y,r=e.z,a=Math.cos(i),o=Math.sin(i),c=Math.cos(n),l=Math.sin(n),h=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){const d=a*h,f=a*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]=a*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]=a*l,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=f*o-p,t[6]=v+d*o,t[10]=a*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]=-a*u,t[8]=p+f*o,t[1]=f+p*o,t[5]=a*h,t[9]=v-d*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const d=a*h,f=a*u,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]=a*c}else if(e.order==="YZX"){const d=a*c,f=a*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]=a*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=a*c,f=a*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]=a*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(W2,e,X2)}lookAt(e,t,i){const n=this.elements;return Oi.subVectors(e,t),Oi.lengthSq()===0&&(Oi.z=1),Oi.normalize(),as.crossVectors(i,Oi),as.lengthSq()===0&&(Math.abs(i.z)===1?Oi.x+=1e-4:Oi.z+=1e-4,Oi.normalize(),as.crossVectors(i,Oi)),as.normalize(),mo.crossVectors(Oi,as),n[0]=as.x,n[4]=mo.x,n[8]=Oi.x,n[1]=as.y,n[5]=mo.y,n[9]=Oi.y,n[2]=as.z,n[6]=mo.z,n[10]=Oi.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,r=this.elements,a=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],b=i[3],y=i[7],_=i[11],w=i[15],E=n[0],R=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 r[0]=a*E+o*I+c*z+l*K,r[4]=a*R+o*C+c*N+l*ee,r[8]=a*x+o*P+c*V+l*J,r[12]=a*A+o*X+c*k+l*ie,r[1]=h*E+u*I+d*z+f*K,r[5]=h*R+u*C+d*N+f*ee,r[9]=h*x+u*P+d*V+f*J,r[13]=h*A+u*X+d*k+f*ie,r[2]=p*E+v*I+m*z+g*K,r[6]=p*R+v*C+m*N+g*ee,r[10]=p*x+v*P+m*V+g*J,r[14]=p*A+v*X+m*k+g*ie,r[3]=b*E+y*I+_*z+w*K,r[7]=b*R+y*C+_*N+w*ee,r[11]=b*x+y*P+_*V+w*J,r[15]=b*A+y*X+_*k+w*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],r=e[12],a=e[1],o=e[5],c=e[9],l=e[13],h=e[2],u=e[6],d=e[10],f=e[14],p=e[3],v=e[7],m=e[11],g=e[15],b=c*f-l*d,y=o*f-l*u,_=o*d-c*u,w=a*f-l*h,E=a*d-c*h,R=a*u-o*h;return t*(v*b-m*y+g*_)-i*(p*b-m*w+g*E)+n*(p*y-v*w+g*R)-r*(p*_-v*E+m*R)}determinantAffine(){const e=this.elements,t=e[0],i=e[4],n=e[8],r=e[1],a=e[5],o=e[9],c=e[2],l=e[6],h=e[10];return t*(a*h-o*l)-i*(r*h-o*c)+n*(r*l-a*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,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],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=e[9],d=e[10],f=e[11],p=e[12],v=e[13],m=e[14],g=e[15],b=t*o-i*a,y=t*c-n*a,_=t*l-r*a,w=i*c-n*o,E=i*l-r*o,R=n*l-r*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=b*X-y*P+_*C+w*I-E*A+R*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-r*C)*N,e[2]=(v*R-m*E+g*w)*N,e[3]=(d*E-u*R-f*w)*N,e[4]=(c*I-a*X-l*A)*N,e[5]=(t*X-n*I+r*A)*N,e[6]=(m*_-p*R-g*y)*N,e[7]=(h*R-d*_+f*y)*N,e[8]=(a*P-o*I+l*x)*N,e[9]=(i*I-t*P-r*x)*N,e[10]=(p*E-v*_+g*b)*N,e[11]=(u*_-h*E-f*b)*N,e[12]=(o*A-a*C-c*x)*N,e[13]=(t*C-i*A+n*x)*N,e[14]=(v*y-p*w-m*b)*N,e[15]=(h*w-u*y+d*b)*N,this}scale(e){const t=this.elements,i=e.x,n=e.y,r=e.z;return t[0]*=i,t[4]*=n,t[8]*=r,t[1]*=i,t[5]*=n,t[9]*=r,t[2]*=i,t[6]*=n,t[10]*=r,t[3]*=i,t[7]*=n,t[11]*=r,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),r=1-i,a=e.x,o=e.y,c=e.z,l=r*a,h=r*o;return this.set(l*a+i,l*o-n*c,l*c+n*o,0,l*o+n*c,h*o+i,h*c-n*a,0,l*c-n*o,h*c+n*a,r*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,r,a){return this.set(1,i,r,0,e,1,a,0,t,n,1,0,0,0,0,1),this}compose(e,t,i){const n=this.elements,r=t._x,a=t._y,o=t._z,c=t._w,l=r+r,h=a+a,u=o+o,d=r*l,f=r*h,p=r*u,v=a*h,m=a*u,g=o*u,b=c*l,y=c*h,_=c*u,w=i.x,E=i.y,R=i.z;return n[0]=(1-(v+g))*w,n[1]=(f+_)*w,n[2]=(p-y)*w,n[3]=0,n[4]=(f-_)*E,n[5]=(1-(d+g))*E,n[6]=(m+b)*E,n[7]=0,n[8]=(p+y)*R,n[9]=(m-b)*R,n[10]=(1-(d+v))*R,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 r=this.determinantAffine();if(r===0)return i.set(1,1,1),t.identity(),this;let a=lr.set(n[0],n[1],n[2]).length();const o=lr.set(n[4],n[5],n[6]).length(),c=lr.set(n[8],n[9],n[10]).length();r<0&&(a=-a),ji.copy(this);const l=1/a,h=1/o,u=1/c;return ji.elements[0]*=l,ji.elements[1]*=l,ji.elements[2]*=l,ji.elements[4]*=h,ji.elements[5]*=h,ji.elements[6]*=h,ji.elements[8]*=u,ji.elements[9]*=u,ji.elements[10]*=u,t.setFromRotationMatrix(ji),i.x=a,i.y=o,i.z=c,this}makePerspective(e,t,i,n,r,a,o=Rn,c=!1){const l=this.elements,h=2*r/(t-e),u=2*r/(i-n),d=(t+e)/(t-e),f=(i+n)/(i-n);let p,v;if(c)p=r/(a-r),v=a*r/(a-r);else if(o===Rn)p=-(a+r)/(a-r),v=-2*a*r/(a-r);else if(o===$a)p=-a/(a-r),v=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,n,r,a,o=Rn,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/(a-r),v=a/(a-r);else if(o===Rn)p=-2/(a-r),v=-(a+r)/(a-r);else if(o===$a)p=-1/(a-r),v=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=f,l[2]=0,l[6]=0,l[10]=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 lr=new D,ji=new Ye,W2=new D(0,0,0),X2=new D(1,1,1),as=new D,mo=new D,Oi=new D,w0=new Ye,E0=new Qn;class jn{constructor(e=0,t=0,i=0,n=jn.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,r=n[0],a=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(-a,r)):(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,r),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(-a,l)):(this._y=0,this._z=Math.atan2(c,r));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,r)):(this._x=0,this._z=Math.atan2(-a,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,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Je(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,f),this._y=0);break;default:Ee("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return w0.makeRotationFromQuaternion(e),this.setFromRotationMatrix(w0,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return E0.setFromEuler(this),this.setFromQuaternion(E0,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}}jn.DEFAULT_ORDER="XYZ";class ad{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 q2=0;const A0=new D,hr=new Qn,Nn=new Ye,go=new D,aa=new D,Y2=new D,K2=new Qn,T0=new D(1,0,0),R0=new D(0,1,0),D0=new D(0,0,1),C0={type:"added"},$2={type:"removed"},ur={type:"childadded",child:null},pl={type:"childremoved",child:null};class At extends er{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:q2++}),this.uuid=ln(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=At.DEFAULT_UP.clone();const e=new D,t=new jn,i=new Qn,n=new D(1,1,1);function r(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(r),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Ye},normalMatrix:{value:new He}}),this.matrix=new Ye,this.matrixWorld=new Ye,this.matrixAutoUpdate=At.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=At.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ad,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 hr.setFromAxisAngle(e,t),this.quaternion.multiply(hr),this}rotateOnWorldAxis(e,t){return hr.setFromAxisAngle(e,t),this.quaternion.premultiply(hr),this}rotateX(e){return this.rotateOnAxis(T0,e)}rotateY(e){return this.rotateOnAxis(R0,e)}rotateZ(e){return this.rotateOnAxis(D0,e)}translateOnAxis(e,t){return A0.copy(e).applyQuaternion(this.quaternion),this.position.add(A0.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(T0,e)}translateY(e){return this.translateOnAxis(R0,e)}translateZ(e){return this.translateOnAxis(D0,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Nn.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?go.copy(e):go.set(e,t,i);const n=this.parent;this.updateWorldMatrix(!0,!1),aa.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Nn.lookAt(aa,go,this.up):Nn.lookAt(go,aa,this.up),this.quaternion.setFromRotationMatrix(Nn),n&&(Nn.extractRotation(n.matrixWorld),hr.setFromRotationMatrix(Nn),this.quaternion.premultiply(hr.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(ke("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(C0),ur.child=e,this.dispatchEvent(ur),ur.child=null):ke("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($2),pl.child=e,this.dispatchEvent(pl),pl.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),Nn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Nn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Nn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(C0),ur.child=e,this.dispatchEvent(ur),ur.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 a=this.children[i].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const n=this.children;for(let r=0,a=n.length;r<a;r++)n[r].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(aa,e,Y2),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(aa,K2,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,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*i-r[8]*n,r[13]+=i-r[1]*t-r[5]*i-r[9]*n,r[14]+=n-r[2]*t-r[6]*i-r[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 r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].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 r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?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=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const u=c[l];r(e.shapes,u)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(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(r(e.materials,this.material[c]));n.material=o}else n.material=r(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(r(e.animations,c))}}if(t){const o=a(e.geometries),c=a(e.materials),l=a(e.textures),h=a(e.images),u=a(e.shapes),d=a(e.skeletons),f=a(e.animations),p=a(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 a(o){const c=[];for(const l in o){const h=o[l];delete h.metadata,c.push(h)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const n=e.children[i];this.add(n.clone())}return this}}At.DEFAULT_UP=new D(0,1,0);At.DEFAULT_MATRIX_AUTO_UPDATE=!0;At.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class ri extends At{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Z2={type:"move"};class ml{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ri,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 ri,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 ri,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,r=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(const 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&&(r=t.getPose(e.gripSpace,i),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(n=t.getPose(e.targetRaySpace,i),n===null&&r!==null&&(n=r),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(Z2)))}return o!==null&&(o.visible=n!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new ri;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const Em={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},os={h:0,s:0,l:0},vo={h:0,s:0,l:0};function gl(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class oe{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=Pi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,et.colorSpaceToWorking(this,t),this}setRGB(e,t,i,n=et.workingColorSpace){return this.r=e,this.g=t,this.b=i,et.colorSpaceToWorking(this,n),this}setHSL(e,t,i,n=et.workingColorSpace){if(e=sd(e,1),t=Je(t,0,1),i=Je(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,a=2*i-r;this.r=gl(a,r,e+1/3),this.g=gl(a,r,e),this.b=gl(a,r,e-1/3)}return et.colorSpaceToWorking(this,n),this}setStyle(e,t=Pi){function i(r){r!==void 0&&parseFloat(r)<1&&Ee("Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=n[1],o=n[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ee("Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=n[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Ee("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Pi){const i=Em[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Ee("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=$n(e.r),this.g=$n(e.g),this.b=$n(e.b),this}copyLinearToSRGB(e){return this.r=Gr(e.r),this.g=Gr(e.g),this.b=Gr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Pi){return et.workingToColorSpace(gi.copy(this),e),Math.round(Je(gi.r*255,0,255))*65536+Math.round(Je(gi.g*255,0,255))*256+Math.round(Je(gi.b*255,0,255))}getHexString(e=Pi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=et.workingColorSpace){et.workingToColorSpace(gi.copy(this),t);const i=gi.r,n=gi.g,r=gi.b,a=Math.max(i,n,r),o=Math.min(i,n,r);let c,l;const h=(o+a)/2;if(o===a)c=0,l=0;else{const u=a-o;switch(l=h<=.5?u/(a+o):u/(2-a-o),a){case i:c=(n-r)/u+(n<r?6:0);break;case n:c=(r-i)/u+2;break;case r:c=(i-n)/u+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=et.workingColorSpace){return et.workingToColorSpace(gi.copy(this),t),e.r=gi.r,e.g=gi.g,e.b=gi.b,e}getStyle(e=Pi){et.workingToColorSpace(gi.copy(this),e);const t=gi.r,i=gi.g,n=gi.b;return e!==Pi?`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(os),this.setHSL(os.h+e,os.s+t,os.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(os),e.getHSL(vo);const i=Ua(os.h,vo.h,t),n=Ua(os.s,vo.s,t),r=Ua(os.l,vo.l,t);return this.setHSL(i,n,r),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,r=e.elements;return this.r=r[0]*t+r[3]*i+r[6]*n,this.g=r[1]*t+r[4]*i+r[7]*n,this.b=r[2]*t+r[5]*i+r[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 gi=new oe;oe.NAMES=Em;class Cc{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new oe(e),this.near=t,this.far=i}clone(){return new Cc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Qr extends At{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 jn,this.environmentIntensity=1,this.environmentRotation=new jn,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 Qi=new D,On=new D,vl=new D,Un=new D,dr=new D,fr=new D,I0=new D,Ml=new D,xl=new D,_l=new D,yl=new it,Sl=new it,bl=new it;class $i{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),Qi.subVectors(e,t),n.cross(Qi);const r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(e,t,i,n,r){Qi.subVectors(n,t),On.subVectors(i,t),vl.subVectors(e,t);const a=Qi.dot(Qi),o=Qi.dot(On),c=Qi.dot(vl),l=On.dot(On),h=On.dot(vl),u=a*l-o*o;if(u===0)return r.set(0,0,0),null;const d=1/u,f=(l*c-o*h)*d,p=(a*h-o*c)*d;return r.set(1-f-p,p,f)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,Un)===null?!1:Un.x>=0&&Un.y>=0&&Un.x+Un.y<=1}static getInterpolation(e,t,i,n,r,a,o,c){return this.getBarycoord(e,t,i,n,Un)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,Un.x),c.addScaledVector(a,Un.y),c.addScaledVector(o,Un.z),c)}static getInterpolatedAttribute(e,t,i,n,r,a){return yl.setScalar(0),Sl.setScalar(0),bl.setScalar(0),yl.fromBufferAttribute(e,t),Sl.fromBufferAttribute(e,i),bl.fromBufferAttribute(e,n),a.setScalar(0),a.addScaledVector(yl,r.x),a.addScaledVector(Sl,r.y),a.addScaledVector(bl,r.z),a}static isFrontFacing(e,t,i,n){return Qi.subVectors(i,t),On.subVectors(e,t),Qi.cross(On).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 Qi.subVectors(this.c,this.b),On.subVectors(this.a,this.b),Qi.cross(On).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return $i.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return $i.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,n,r){return $i.getInterpolation(e,this.a,this.b,this.c,t,i,n,r)}containsPoint(e){return $i.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return $i.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,n=this.b,r=this.c;let a,o;dr.subVectors(n,i),fr.subVectors(r,i),Ml.subVectors(e,i);const c=dr.dot(Ml),l=fr.dot(Ml);if(c<=0&&l<=0)return t.copy(i);xl.subVectors(e,n);const h=dr.dot(xl),u=fr.dot(xl);if(h>=0&&u<=h)return t.copy(n);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),t.copy(i).addScaledVector(dr,a);_l.subVectors(e,r);const f=dr.dot(_l),p=fr.dot(_l);if(p>=0&&f<=p)return t.copy(r);const v=f*l-c*p;if(v<=0&&l>=0&&p<=0)return o=l/(l-p),t.copy(i).addScaledVector(fr,o);const m=h*p-f*u;if(m<=0&&u-h>=0&&f-p>=0)return I0.subVectors(r,n),o=(u-h)/(u-h+(f-p)),t.copy(n).addScaledVector(I0,o);const g=1/(m+v+d);return a=v*g,o=d*g,t.copy(i).addScaledVector(dr,a).addScaledVector(fr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class un{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(en.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(en.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=en.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 r=i.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,en):en.fromBufferAttribute(r,a),en.applyMatrix4(e.matrixWorld),this.expandByPoint(en);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Mo.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Mo.copy(i.boundingBox)),Mo.applyMatrix4(e.matrixWorld),this.union(Mo)}const n=e.children;for(let r=0,a=n.length;r<a;r++)this.expandByObject(n[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,en),en.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(oa),xo.subVectors(this.max,oa),pr.subVectors(e.a,oa),mr.subVectors(e.b,oa),gr.subVectors(e.c,oa),cs.subVectors(mr,pr),ls.subVectors(gr,mr),Ds.subVectors(pr,gr);let t=[0,-cs.z,cs.y,0,-ls.z,ls.y,0,-Ds.z,Ds.y,cs.z,0,-cs.x,ls.z,0,-ls.x,Ds.z,0,-Ds.x,-cs.y,cs.x,0,-ls.y,ls.x,0,-Ds.y,Ds.x,0];return!wl(t,pr,mr,gr,xo)||(t=[1,0,0,0,1,0,0,0,1],!wl(t,pr,mr,gr,xo))?!1:(_o.crossVectors(cs,ls),t=[_o.x,_o.y,_o.z],wl(t,pr,mr,gr,xo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,en).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(en).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:(Fn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Fn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Fn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Fn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Fn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Fn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Fn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Fn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Fn),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 Fn=[new D,new D,new D,new D,new D,new D,new D,new D],en=new D,Mo=new un,pr=new D,mr=new D,gr=new D,cs=new D,ls=new D,Ds=new D,oa=new D,xo=new D,_o=new D,Cs=new D;function wl(s,e,t,i,n){for(let r=0,a=s.length-3;r<=a;r+=3){Cs.fromArray(s,r);const o=n.x*Math.abs(Cs.x)+n.y*Math.abs(Cs.y)+n.z*Math.abs(Cs.z),c=e.dot(Cs),l=t.dot(Cs),h=i.dot(Cs);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const Xn=J2();function J2(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),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 r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,r[c]=l|h}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)a[c]=c<<23;a[31]=1199570944,a[32]=2147483648;for(let c=33;c<63;++c)a[c]=2147483648+(c-32<<23);a[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:n,mantissaTable:r,exponentTable:a,offsetTable:o}}function j2(s){Math.abs(s)>65504&&Ee("DataUtils.toHalfFloat(): Value out of range."),s=Je(s,-65504,65504),Xn.floatView[0]=s;const e=Xn.uint32View[0],t=e>>23&511;return Xn.baseTable[t]+((e&8388607)>>Xn.shiftTable[t])}function Q2(s){const e=s>>10;return Xn.uint32View[0]=Xn.mantissaTable[Xn.offsetTable[e]+(s&1023)]+Xn.exponentTable[e],Xn.floatView[0]}class Zn{static toHalfFloat(e){return j2(e)}static fromHalfFloat(e){return Q2(e)}}const Xt=new D,yo=new Ae;let ev=0;class ot extends er{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:ev++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=lu,this.updateRanges=[],this.gpuType=Ai,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,r=this.itemSize;n<r;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++)yo.fromBufferAttribute(this,t),yo.applyMatrix3(e),this.setXY(t,yo.x,yo.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Xt.fromBufferAttribute(this,t),Xt.applyMatrix3(e),this.setXYZ(t,Xt.x,Xt.y,Xt.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Xt.fromBufferAttribute(this,t),Xt.applyMatrix4(e),this.setXYZ(t,Xt.x,Xt.y,Xt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Xt.fromBufferAttribute(this,t),Xt.applyNormalMatrix(e),this.setXYZ(t,Xt.x,Xt.y,Xt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Xt.fromBufferAttribute(this,t),Xt.transformDirection(e),this.setXYZ(t,Xt.x,Xt.y,Xt.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=cn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=dt(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=cn(t,this.array)),t}setX(e,t){return this.normalized&&(t=dt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=cn(t,this.array)),t}setY(e,t){return this.normalized&&(t=dt(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=cn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=dt(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=cn(t,this.array)),t}setW(e,t){return this.normalized&&(t=dt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=dt(t,this.array),i=dt(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=dt(t,this.array),i=dt(i,this.array),n=dt(n,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this}setXYZW(e,t,i,n,r){return e*=this.itemSize,this.normalized&&(t=dt(t,this.array),i=dt(i,this.array),n=dt(n,this.array),r=dt(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==lu&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class Am extends ot{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class od extends ot{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class Pt extends ot{constructor(e,t,i){super(new Float32Array(e),t,i)}}const tv=new un,ca=new D,El=new D;class es{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):tv.setFromPoints(e).getCenter(i);let n=0;for(let r=0,a=e.length;r<a;r++)n=Math.max(n,i.distanceToSquared(e[r]));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;ca.subVectors(e,this.center);const t=ca.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),n=(i-this.radius)*.5;this.center.addScaledVector(ca,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):(El.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ca.copy(e.center).add(El)),this.expandByPoint(ca.copy(e.center).sub(El))),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 iv=0;const Wi=new Ye,Al=new At,vr=new D,Ui=new un,la=new un,jt=new D;class bt extends er{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:iv++}),this.uuid=ln(),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(M2(e)?od:Am)(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 r=new He().getNormalMatrix(e);i.applyNormalMatrix(r),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 Wi.makeRotationFromQuaternion(e),this.applyMatrix4(Wi),this}rotateX(e){return Wi.makeRotationX(e),this.applyMatrix4(Wi),this}rotateY(e){return Wi.makeRotationY(e),this.applyMatrix4(Wi),this}rotateZ(e){return Wi.makeRotationZ(e),this.applyMatrix4(Wi),this}translate(e,t,i){return Wi.makeTranslation(e,t,i),this.applyMatrix4(Wi),this}scale(e,t,i){return Wi.makeScale(e,t,i),this.applyMatrix4(Wi),this}lookAt(e){return Al.lookAt(e),Al.updateMatrix(),this.applyMatrix4(Al.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(vr).negate(),this.translate(vr.x,vr.y,vr.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let n=0,r=e.length;n<r;n++){const a=e[n];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Pt(i,3))}else{const i=Math.min(e.length,t.count);for(let n=0;n<i;n++){const r=e[n];t.setXYZ(n,r.x,r.y,r.z||0)}e.length>t.count&&Ee("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 un);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ke("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 r=t[i];Ui.setFromBufferAttribute(r),this.morphTargetsRelative?(jt.addVectors(this.boundingBox.min,Ui.min),this.boundingBox.expandByPoint(jt),jt.addVectors(this.boundingBox.max,Ui.max),this.boundingBox.expandByPoint(jt)):(this.boundingBox.expandByPoint(Ui.min),this.boundingBox.expandByPoint(Ui.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ke('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 es);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ke("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(Ui.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];la.setFromBufferAttribute(o),this.morphTargetsRelative?(jt.addVectors(Ui.min,la.min),Ui.expandByPoint(jt),jt.addVectors(Ui.max,la.max),Ui.expandByPoint(jt)):(Ui.expandByPoint(la.min),Ui.expandByPoint(la.max))}Ui.getCenter(i);let n=0;for(let r=0,a=e.count;r<a;r++)jt.fromBufferAttribute(e,r),n=Math.max(n,i.distanceToSquared(jt));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)jt.fromBufferAttribute(o,l),c&&(vr.fromBufferAttribute(e,l),jt.add(vr)),n=Math.max(n,i.distanceToSquared(jt))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&ke('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){ke("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,n=t.normal,r=t.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==i.count)&&(a=new ot(new Float32Array(4*i.count),4),this.setAttribute("tangent",a));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 Ae,f=new Ae,p=new Ae,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(r,x),f.fromBufferAttribute(r,A),p.fromBufferAttribute(r,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 b=this.groups;b.length===0&&(b=[{start:0,count:e.count}]);for(let x=0,A=b.length;x<A;++x){const I=b[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 y=new D,_=new D,w=new D,E=new D;function R(x){w.fromBufferAttribute(n,x),E.copy(w);const A=o[x];y.copy(A),y.sub(w.multiplyScalar(w.dot(A))).normalize(),_.crossVectors(E,A);const C=_.dot(c[x])<0?-1:1;a.setXYZW(x,y.x,y.y,y.z,C)}for(let x=0,A=b.length;x<A;++x){const I=b[x],C=I.start,P=I.count;for(let X=C,z=C+P;X<z;X+=3)R(e.getX(X+0)),R(e.getX(X+1)),R(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 ot(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,r=new D,a=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),r.fromBufferAttribute(t,v),a.fromBufferAttribute(t,m),h.subVectors(a,r),u.subVectors(n,r),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),r.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),h.subVectors(a,r),u.subVectors(n,r),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++)jt.fromBufferAttribute(e,t),jt.normalize(),e.setXYZ(t,jt.x,jt.y,jt.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 ot(d,h,u)}if(this.index===null)return Ee("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new bt,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 r=this.morphAttributes;for(const o in r){const c=[],l=r[o];for(let h=0,u=l.length;h<u;h++){const d=l[h],f=e(d,i);c.push(f)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const c in i){const l=i[c];e.data.attributes[c]=l.toJSON(e.data)}const n={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){const f=l[u];h.push(f.toJSON(e.data))}h.length>0&&(n[c]=h,r=!0)}r&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const 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 r=e.morphAttributes;for(const l in r){const h=[],u=r[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let l=0,h=a.length;l<h;l++){const u=a[l];this.addGroup(u.start,u.count,u.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class nv{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=lu,this.updateRanges=[],this.version=0,this.uuid=ln()}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,r=this.stride;n<r;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=ln()),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=ln()),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 _i=new D;class Ic{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++)_i.fromBufferAttribute(this,t),_i.applyMatrix4(e),this.setXYZ(t,_i.x,_i.y,_i.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)_i.fromBufferAttribute(this,t),_i.applyNormalMatrix(e),this.setXYZ(t,_i.x,_i.y,_i.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)_i.fromBufferAttribute(this,t),_i.transformDirection(e),this.setXYZ(t,_i.x,_i.y,_i.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=cn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=dt(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=dt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=dt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=dt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=dt(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=cn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=cn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=cn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=cn(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=dt(t,this.array),i=dt(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=dt(t,this.array),i=dt(i,this.array),n=dt(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,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=dt(t,this.array),i=dt(i,this.array),n=dt(n,this.array),r=dt(r,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]=r,this}clone(e){if(e===void 0){Dc("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 r=0;r<this.itemSize;r++)t.push(this.data.array[n+r])}return new ot(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 Ic(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Dc("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 r=0;r<this.itemSize;r++)t.push(this.data.array[n+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let sv=0;class ts extends er{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:sv++}),this.uuid=ln(),this.name="",this.type="Material",this.blending=qs,this.side=Es,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=bh,this.blendDst=yc,this.blendEquation=Fs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new oe(0,0,0),this.blendAlpha=0,this.depthFunc=Zr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=M0,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=or,this.stencilZFail=or,this.stencilZPass=or,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){Ee(`Material: parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){Ee(`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!==qs&&(i.blending=this.blending),this.side!==Es&&(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!==bh&&(i.blendSrc=this.blendSrc),this.blendDst!==yc&&(i.blendDst=this.blendDst),this.blendEquation!==Fs&&(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!==Zr&&(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!==M0&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==or&&(i.stencilFail=this.stencilFail),this.stencilZFail!==or&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==or&&(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(r){const a=[];for(const o in r){const c=r[o];delete c.metadata,a.push(c)}return a}if(t){const r=n(e.textures),a=n(e.images);r.length>0&&(i.textures=r),a.length>0&&(i.images=a)}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 oe().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 Ae().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 Ae().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 r=0;r!==n;++r)i[r]=t[r].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 Ta extends ts{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new oe(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 Mr;const ha=new D,xr=new D,_r=new D,yr=new Ae,ua=new Ae,Tm=new Ye,So=new D,da=new D,bo=new D,P0=new Ae,Tl=new Ae,L0=new Ae;class Sr extends At{constructor(e=new Ta){if(super(),this.isSprite=!0,this.type="Sprite",Mr===void 0){Mr=new bt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new nv(t,5);Mr.setIndex([0,1,2,0,2,3]),Mr.setAttribute("position",new Ic(i,3,0,!1)),Mr.setAttribute("uv",new Ic(i,2,3,!1))}this.geometry=Mr,this.material=e,this.center=new Ae(.5,.5),this.count=1}raycast(e,t){e.camera===null&&ke('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),xr.setFromMatrixScale(this.matrixWorld),Tm.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),_r.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&xr.multiplyScalar(-_r.z);const i=this.material.rotation;let n,r;i!==0&&(r=Math.cos(i),n=Math.sin(i));const a=this.center;wo(So.set(-.5,-.5,0),_r,a,xr,n,r),wo(da.set(.5,-.5,0),_r,a,xr,n,r),wo(bo.set(.5,.5,0),_r,a,xr,n,r),P0.set(0,0),Tl.set(1,0),L0.set(1,1);let o=e.ray.intersectTriangle(So,da,bo,!1,ha);if(o===null&&(wo(da.set(-.5,.5,0),_r,a,xr,n,r),Tl.set(0,1),o=e.ray.intersectTriangle(So,bo,da,!1,ha),o===null))return;const c=e.ray.origin.distanceTo(ha);c<e.near||c>e.far||t.push({distance:c,point:ha.clone(),uv:$i.getInterpolation(ha,So,da,bo,P0,Tl,L0,new Ae),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 wo(s,e,t,i,n,r){yr.subVectors(s,t).addScalar(.5).multiply(i),n!==void 0?(ua.x=r*yr.x-n*yr.y,ua.y=n*yr.x+r*yr.y):ua.copy(yr),s.copy(e),s.x+=ua.x,s.y+=ua.y,s.applyMatrix4(Tm)}const kn=new D,Rl=new D,Eo=new D,hs=new D,Dl=new D,Ao=new D,Cl=new D;class ja{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,kn)),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=kn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(kn.copy(this.origin).addScaledVector(this.direction,t),kn.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){Rl.copy(e).add(t).multiplyScalar(.5),Eo.copy(t).sub(e).normalize(),hs.copy(this.origin).sub(Rl);const r=e.distanceTo(t)*.5,a=-this.direction.dot(Eo),o=hs.dot(this.direction),c=-hs.dot(Eo),l=hs.lengthSq(),h=Math.abs(1-a*a);let u,d,f,p;if(h>0)if(u=a*c-o,d=a*o-c,p=r*h,u>=0)if(d>=-p)if(d<=p){const v=1/h;u*=v,d*=v,f=u*(u+a*d+2*o)+d*(a*u+d+2*c)+l}else d=r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d=-r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d<=-p?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l):d<=p?(u=0,d=Math.min(Math.max(-r,-c),r),f=d*(d+2*c)+l):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,u),n&&n.copy(Rl).addScaledVector(Eo,d),f}intersectSphere(e,t){kn.subVectors(e.center,this.origin);const i=kn.dot(this.direction),n=kn.dot(kn)-i*i,r=e.radius*e.radius;if(n>r)return null;const a=Math.sqrt(r-n),o=i-a,c=i+a;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const 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,r,a,o,c;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(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?(r=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(r=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),i>a||r>n||((r>i||isNaN(i))&&(i=r),(a<n||isNaN(n))&&(n=a),u>=0?(o=(e.min.z-d.z)*u,c=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,c=(e.min.z-d.z)*u),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,kn)!==null}intersectTriangle(e,t,i,n,r){Dl.subVectors(t,e),Ao.subVectors(i,e),Cl.crossVectors(Dl,Ao);let a=this.direction.dot(Cl),o;if(a>0){if(n)return null;o=1}else if(a<0)o=-1,a=-a;else return null;hs.subVectors(this.origin,e);const c=o*this.direction.dot(Ao.crossVectors(hs,Ao));if(c<0)return null;const l=o*this.direction.dot(Dl.cross(hs));if(l<0||c+l>a)return null;const h=-o*hs.dot(Cl);return h<0?null:this.at(h/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Zi extends ts{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new oe(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 jn,this.combine=$u,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 N0=new Ye,Is=new ja,To=new es,O0=new D,Ro=new D,Do=new D,Co=new D,Il=new D,Io=new D,U0=new D,Po=new D;class We extends At{constructor(e=new bt,t=new Zi){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 r=0,a=n.length;r<a;r++){const o=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){const i=this.geometry,n=i.attributes.position,r=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(n,e);const o=this.morphTargetInfluences;if(r&&o){Io.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const h=o[c],u=r[c];h!==0&&(Il.fromBufferAttribute(u,e),a?Io.addScaledVector(Il,h):Io.addScaledVector(Il.sub(t),h))}t.add(Io)}return t}raycast(e,t){const i=this.geometry,n=this.material,r=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),To.copy(i.boundingSphere),To.applyMatrix4(r),Is.copy(e.ray).recast(e.near),!(To.containsPoint(Is.origin)===!1&&(Is.intersectSphere(To,O0)===null||Is.origin.distanceToSquared(O0)>(e.far-e.near)**2))&&(N0.copy(r).invert(),Is.copy(e.ray).applyMatrix4(N0),!(i.boundingBox!==null&&Is.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Is)))}_computeIntersections(e,t,i){let n;const r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,v=d.length;p<v;p++){const m=d[p],g=a[m.materialIndex],b=Math.max(m.start,f.start),y=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let _=b,w=y;_<w;_+=3){const E=o.getX(_),R=o.getX(_+1),x=o.getX(_+2);n=Lo(this,g,e,i,l,h,u,E,R,x),n&&(n.faceIndex=Math.floor(_/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 b=o.getX(m),y=o.getX(m+1),_=o.getX(m+2);n=Lo(this,a,e,i,l,h,u,b,y,_),n&&(n.faceIndex=Math.floor(m/3),t.push(n))}}else if(c!==void 0)if(Array.isArray(a))for(let p=0,v=d.length;p<v;p++){const m=d[p],g=a[m.materialIndex],b=Math.max(m.start,f.start),y=Math.min(c.count,Math.min(m.start+m.count,f.start+f.count));for(let _=b,w=y;_<w;_+=3){const E=_,R=_+1,x=_+2;n=Lo(this,g,e,i,l,h,u,E,R,x),n&&(n.faceIndex=Math.floor(_/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 b=m,y=m+1,_=m+2;n=Lo(this,a,e,i,l,h,u,b,y,_),n&&(n.faceIndex=Math.floor(m/3),t.push(n))}}}}function rv(s,e,t,i,n,r,a,o){let c;if(e.side===It?c=i.intersectTriangle(a,r,n,!0,o):c=i.intersectTriangle(n,r,a,e.side===Es,o),c===null)return null;Po.copy(o),Po.applyMatrix4(s.matrixWorld);const l=t.ray.origin.distanceTo(Po);return l<t.near||l>t.far?null:{distance:l,point:Po.clone(),object:s}}function Lo(s,e,t,i,n,r,a,o,c,l){s.getVertexPosition(o,Ro),s.getVertexPosition(c,Do),s.getVertexPosition(l,Co);const h=rv(s,e,t,i,Ro,Do,Co,U0);if(h){const u=new D;$i.getBarycoord(U0,Ro,Do,Co,u),n&&(h.uv=$i.getInterpolatedAttribute(n,o,c,l,u,new Ae)),r&&(h.uv1=$i.getInterpolatedAttribute(r,o,c,l,u,new Ae)),a&&(h.normal=$i.getInterpolatedAttribute(a,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};$i.getNormal(Ro,Do,Co,d.normal),h.face=d,h.barycoord=u}return h}const fa=new it,F0=new it,k0=new it,av=new it,z0=new Ye,No=new D,Pl=new es,B0=new Ye,Ll=new ja;class Bw extends We{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=f0,this.bindMatrix=new Ye,this.bindMatrixInverse=new Ye,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new un),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,No),this.boundingBox.expandByPoint(No)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new es),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,No),this.boundingSphere.expandByPoint(No)}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(),Pl.copy(this.boundingSphere),Pl.applyMatrix4(n),e.ray.intersectsSphere(Pl)!==!1&&(B0.copy(n).invert(),Ll.copy(e.ray).applyMatrix4(B0),!(this.boundingBox!==null&&Ll.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Ll)))}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 r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===f0?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===o2?this.bindMatrixInverse.copy(this.bindMatrix).invert():Ee("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,n=this.geometry;F0.fromBufferAttribute(n.attributes.skinIndex,e),k0.fromBufferAttribute(n.attributes.skinWeight,e),t.isVector4?(fa.copy(t),t.set(0,0,0,0)):(fa.set(...t,1),t.set(0,0,0)),fa.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){const a=k0.getComponent(r);if(a!==0){const o=F0.getComponent(r);z0.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(av.copy(fa).applyMatrix4(z0),a)}}return t.isVector4&&(t.w=fa.w),t.applyMatrix4(this.bindMatrixInverse)}}class ov extends At{constructor(){super(),this.isBone=!0,this.type="Bone"}}class tr extends oi{constructor(e=null,t=1,i=1,n,r,a,o,c,l=Dt,h=Dt,u,d){super(null,a,o,c,l,h,n,r,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const H0=new Ye,cv=new Ye;class Rm{constructor(e=[],t=[]){this.uuid=ln(),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){Ee("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 Ye)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new Ye;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 r=0,a=e.length;r<a;r++){const o=e[r]?e[r].matrixWorld:cv;H0.multiplyMatrices(o,t[r]),H0.toArray(i,r*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new Rm(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 tr(t,e,e,xi,Ai);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 r=e.bones[i];let a=t[r];a===void 0&&(Ee("Skeleton: No bone found with UUID:",r),a=new ov),this.bones.push(a),this.boneInverses.push(new Ye().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,r=t.length;n<r;n++){const a=t[n];e.bones.push(a.uuid);const o=i[n];e.boneInverses.push(o.toArray())}return e}}class G0 extends ot{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 br=new Ye,V0=new Ye,Oo=[],W0=new un,lv=new Ye,pa=new We,ma=new es;class Hw extends We{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new G0(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,lv)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new un),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,br),W0.copy(e.boundingBox).applyMatrix4(br),this.boundingBox.union(W0)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new es),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,br),ma.copy(e.boundingSphere).applyMatrix4(br),this.boundingSphere.union(ma)}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,r=i.length+1,a=e*r+1;for(let o=0;o<i.length;o++)i[o]=n[a+o]}raycast(e,t){const i=this.matrixWorld,n=this.count;if(pa.geometry=this.geometry,pa.material=this.material,pa.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ma.copy(this.boundingSphere),ma.applyMatrix4(i),e.ray.intersectsSphere(ma)!==!1))for(let r=0;r<n;r++){this.getMatrixAt(r,br),V0.multiplyMatrices(i,br),pa.matrixWorld=V0,pa.raycast(e,Oo);for(let a=0,o=Oo.length;a<o;a++){const c=Oo[a];c.instanceId=r,c.object=this,t.push(c)}Oo.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new G0(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 tr(new Float32Array(n*this.count),n,this.count,qc,Ai));const r=this.morphTexture.source.data.data;let a=0;for(let l=0;l<i.length;l++)a+=i[l];const o=this.geometry.morphTargetsRelative?1:1-a,c=n*e;return r[c]=o,r.set(i,c+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Nl=new D,hv=new D,uv=new He;class Os{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=Nl.subVectors(i,t).cross(hv.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(Nl),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return i===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(n,a)}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||uv.getNormalMatrix(e),n=this.coplanarPoint(Nl).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ps=new es,dv=new Ae(.5,.5),Uo=new D;class cd{constructor(e=new Os,t=new Os,i=new Os,n=new Os,r=new Os,a=new Os){this.planes=[e,t,i,n,r,a]}set(e,t,i,n,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(n),o[4].copy(r),o[5].copy(a),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=Rn,i=!1){const n=this.planes,r=e.elements,a=r[0],o=r[1],c=r[2],l=r[3],h=r[4],u=r[5],d=r[6],f=r[7],p=r[8],v=r[9],m=r[10],g=r[11],b=r[12],y=r[13],_=r[14],w=r[15];if(n[0].setComponents(l-a,f-h,g-p,w-b).normalize(),n[1].setComponents(l+a,f+h,g+p,w+b).normalize(),n[2].setComponents(l+o,f+u,g+v,w+y).normalize(),n[3].setComponents(l-o,f-u,g-v,w-y).normalize(),i)n[4].setComponents(c,d,m,_).normalize(),n[5].setComponents(l-c,f-d,g-m,w-_).normalize();else if(n[4].setComponents(l-c,f-d,g-m,w-_).normalize(),t===Rn)n[5].setComponents(l+c,f+d,g+m,w+_).normalize();else if(t===$a)n[5].setComponents(c,d,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(),Ps.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ps.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ps)}intersectsSprite(e){Ps.center.set(0,0,0);const t=dv.distanceTo(e.center);return Ps.radius=.7071067811865476+t,Ps.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ps)}intersectsSphere(e){const t=this.planes,i=e.center,n=-e.radius;for(let r=0;r<6;r++)if(t[r].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(Uo.x=n.normal.x>0?e.max.x:e.min.x,Uo.y=n.normal.y>0?e.max.y:e.min.y,Uo.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(Uo)<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 fv extends ts{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new oe(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 Pc=new D,Lc=new D,X0=new Ye,ga=new ja,Fo=new es,Ol=new D,q0=new D;class Dm extends At{constructor(e=new bt,t=new fv){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,r=t.count;n<r;n++)Pc.fromBufferAttribute(t,n-1),Lc.fromBufferAttribute(t,n),i[n]=i[n-1],i[n]+=Pc.distanceTo(Lc);e.setAttribute("lineDistance",new Pt(i,1))}else Ee("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Fo.copy(i.boundingSphere),Fo.applyMatrix4(n),Fo.radius+=r,e.ray.intersectsSphere(Fo)===!1)return;X0.copy(n).invert(),ga.copy(e.ray).applyMatrix4(X0);const o=r/((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,a.start),p=Math.min(h.count,a.start+a.count);for(let v=f,m=p-1;v<m;v+=l){const g=h.getX(v),b=h.getX(v+1),y=ko(this,e,ga,c,g,b,v);y&&t.push(y)}if(this.isLineLoop){const v=h.getX(p-1),m=h.getX(f),g=ko(this,e,ga,c,v,m,p-1);g&&t.push(g)}}else{const f=Math.max(0,a.start),p=Math.min(d.count,a.start+a.count);for(let v=f,m=p-1;v<m;v+=l){const g=ko(this,e,ga,c,v,v+1,v);g&&t.push(g)}if(this.isLineLoop){const v=ko(this,e,ga,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 r=0,a=n.length;r<a;r++){const o=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function ko(s,e,t,i,n,r,a){const o=s.geometry.attributes.position;if(Pc.fromBufferAttribute(o,n),Lc.fromBufferAttribute(o,r),t.distanceSqToSegment(Pc,Lc,Ol,q0)>i)return;Ol.applyMatrix4(s.matrixWorld);const l=e.ray.origin.distanceTo(Ol);if(!(l<e.near||l>e.far))return{distance:l,point:q0.clone().applyMatrix4(s.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:s}}const Y0=new D,K0=new D;class Gw extends Dm{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,r=t.count;n<r;n+=2)Y0.fromBufferAttribute(t,n),K0.fromBufferAttribute(t,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+Y0.distanceTo(K0);e.setAttribute("lineDistance",new Pt(i,1))}else Ee("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Vw extends Dm{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class ld extends ts{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new oe(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 $0=new Ye,hu=new ja,zo=new es,Bo=new D;class Fa extends At{constructor(e=new bt,t=new ld){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,r=e.params.Points.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),zo.copy(i.boundingSphere),zo.applyMatrix4(n),zo.radius+=r,e.ray.intersectsSphere(zo)===!1)return;$0.copy(n).invert(),hu.copy(e.ray).applyMatrix4($0);const o=r/((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,a.start),f=Math.min(l.count,a.start+a.count);for(let p=d,v=f;p<v;p++){const m=l.getX(p);Bo.fromBufferAttribute(u,m),Z0(Bo,m,c,n,e,t,this)}}else{const d=Math.max(0,a.start),f=Math.min(u.count,a.start+a.count);for(let p=d,v=f;p<v;p++)Bo.fromBufferAttribute(u,p),Z0(Bo,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 r=0,a=n.length;r<a;r++){const o=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Z0(s,e,t,i,n,r,a){const o=hu.distanceSqToPoint(s);if(o<t){const c=new D;hu.closestPointToPoint(s,c),c.applyMatrix4(i);const l=n.ray.origin.distanceTo(c);if(l<n.near||l>n.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Cm extends oi{constructor(e=[],t=$s,i,n,r,a,o,c,l,h){super(e,t,i,n,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Ln extends oi{constructor(e,t,i,n,r,a,o,c,l){super(e,t,i,n,r,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Js extends oi{constructor(e,t,i=hn,n,r,a,o=Dt,c=Dt,l,h=Jn,u=1){if(h!==Jn&&h!==Vs)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,r,a,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 rd(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 pv extends Js{constructor(e,t=hn,i=$s,n,r,a=Dt,o=Dt,c,l=Jn){const h={width:e,height:e,depth:1},u=[h,h,h,h,h,h];super(e,e,t,i,n,r,a,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Im extends oi{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Ji extends bt{constructor(e=1,t=1,i=1,n=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:n,heightSegments:r,depthSegments:a};const o=this;n=Math.floor(n),r=Math.floor(r),a=Math.floor(a);const c=[],l=[],h=[],u=[];let d=0,f=0;p("z","y","x",-1,-1,i,t,e,a,r,0),p("z","y","x",1,-1,i,t,-e,a,r,1),p("x","z","y",1,1,e,i,t,n,a,2),p("x","z","y",1,-1,e,i,-t,n,a,3),p("x","y","z",1,-1,e,t,i,n,r,4),p("x","y","z",-1,-1,e,t,-i,n,r,5),this.setIndex(c),this.setAttribute("position",new Pt(l,3)),this.setAttribute("normal",new Pt(h,3)),this.setAttribute("uv",new Pt(u,2));function p(v,m,g,b,y,_,w,E,R,x,A){const I=_/R,C=w/x,P=_/2,X=w/2,z=E/2,N=R+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 ae=0;ae<N;ae++){const Be=ae*I-P;ee[v]=Be*b,ee[m]=ie*y,ee[g]=z,l.push(ee.x,ee.y,ee.z),ee[v]=0,ee[m]=0,ee[g]=E>0?1:-1,h.push(ee.x,ee.y,ee.z),u.push(ae/R),u.push(1-J/x),k+=1}}for(let J=0;J<x;J++)for(let ie=0;ie<R;ie++){const ae=d+ie+N*J,Be=d+ie+N*(J+1),je=d+(ie+1)+N*(J+1),Ge=d+(ie+1)+N*J;c.push(ae,Be,Ge),c.push(Be,je,Ge),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 Ji(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class hd extends bt{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 r=[],a=[],o=[],c=[],l=new D,h=new Ae;a.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let u=0,d=3;u<=t;u++,d+=3){const f=i+u/t*n;l.x=e*Math.cos(f),l.y=e*Math.sin(f),a.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(a[d]/e+1)/2,h.y=(a[d+1]/e+1)/2,c.push(h.x,h.y)}for(let u=1;u<=t;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new Pt(a,3)),this.setAttribute("normal",new Pt(o,3)),this.setAttribute("uv",new Pt(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new hd(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class is extends bt{constructor(e=1,t=1,i=1,n=32,r=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:n,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:c};const l=this;n=Math.floor(n),r=Math.floor(r);const h=[],u=[],d=[],f=[];let p=0;const v=[],m=i/2;let g=0;b(),a===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new Pt(u,3)),this.setAttribute("normal",new Pt(d,3)),this.setAttribute("uv",new Pt(f,2));function b(){const _=new D,w=new D;let E=0;const R=(t-e)/i;for(let x=0;x<=r;x++){const A=[],I=x/r,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);w.x=C*N,w.y=-I*i+m,w.z=C*V,u.push(w.x,w.y,w.z),_.set(N,R,V).normalize(),d.push(_.x,_.y,_.z),f.push(X,1-I),A.push(p++)}v.push(A)}for(let x=0;x<n;x++)for(let A=0;A<r;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),E+=3),(t>0||A!==r-1)&&(h.push(C,P,X),E+=3)}l.addGroup(g,E,0),g+=E}function y(_){const w=p,E=new Ae,R=new D;let x=0;const A=_===!0?e:t,I=_===!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);R.x=A*V,R.y=m*I,R.z=A*N,u.push(R.x,R.y,R.z),d.push(0,I,0),E.x=N*.5+.5,E.y=V*.5*I+.5,f.push(E.x,E.y),p++}for(let P=0;P<n;P++){const X=w+P,z=C+P;_===!0?h.push(z,z+1,X):h.push(z+1,z,X),x+=3}l.addGroup(g,x,_===!0?1:2),g+=x}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new is(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Qa extends is{constructor(e=1,t=1,i=32,n=1,r=!1,a=0,o=Math.PI*2){super(0,e,t,i,n,r,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:n,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Qa(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class dn extends bt{constructor(e=1,t=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:n};const r=e/2,a=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 b=g*d-a;for(let y=0;y<l;y++){const _=y*u-r;p.push(_,-b,0),v.push(0,0,1),m.push(y/o),m.push(1-g/c)}}for(let g=0;g<c;g++)for(let b=0;b<o;b++){const y=b+l*g,_=b+l*(g+1),w=b+1+l*(g+1),E=b+1+l*g;f.push(y,_,E),f.push(_,w,E)}this.setIndex(f),this.setAttribute("position",new Pt(p,3)),this.setAttribute("normal",new Pt(v,3)),this.setAttribute("uv",new Pt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new dn(e.width,e.height,e.widthSegments,e.heightSegments)}}class di extends bt{constructor(e=1,t=32,i=16,n=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:n,phiLength:r,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const c=Math.min(a+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 b=[],y=g/i,_=a+y*o,w=e*Math.cos(_),E=Math.sqrt(e*e-w*w);let R=0;g===0&&a===0?R=.5/t:g===i&&c===Math.PI&&(R=-.5/t);for(let x=0;x<=t;x++){const A=x/t,I=n+A*r;u.x=-E*Math.cos(I),u.y=w,u.z=E*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+R,1-y),b.push(l++)}h.push(b)}for(let g=0;g<i;g++)for(let b=0;b<t;b++){const y=h[g][b+1],_=h[g][b],w=h[g+1][b],E=h[g+1][b+1];(g!==0||a>0)&&f.push(y,_,E),(g!==i-1||c<Math.PI)&&f.push(_,w,E)}this.setIndex(f),this.setAttribute("position",new Pt(p,3)),this.setAttribute("normal",new Pt(v,3)),this.setAttribute("uv",new Pt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new di(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}function ea(s){const e={};for(const t in s){e[t]={};for(const i in s[t]){const n=s[t][i];if(J0(n))n.isRenderTargetTexture?(Ee("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(J0(n[0])){const r=[];for(let a=0,o=n.length;a<o;a++)r[a]=n[a].clone();e[t][i]=r}else e[t][i]=n.slice();else e[t][i]=n}}return e}function yi(s){const e={};for(let t=0;t<s.length;t++){const i=ea(s[t]);for(const n in i)e[n]=i[n]}return e}function J0(s){return s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)}function mv(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function Pm(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:et.workingColorSpace}const gv={clone:ea,merge:yi};var vv=`void main() {
|
|
631
|
+
*/const Ku="185",B1=0,h0=1,H1=2,Na=1,G1=2,Aa=3,ws=0,It=1,on=2,Cn=0,qs=1,Gi=2,u0=3,d0=4,am=5,Fs=100,V1=101,W1=102,X1=103,q1=104,Y1=200,om=201,K1=202,$1=203,bh=204,yc=205,Z1=206,J1=207,j1=208,Q1=209,e2=210,t2=211,i2=212,n2=213,s2=214,Eh=0,wh=1,Ah=2,Zr=3,Th=4,Rh=5,Dh=6,Ch=7,$u=0,r2=1,a2=2,In=0,cm=1,lm=2,hm=3,um=4,dm=5,fm=6,pm=7,f0="attached",o2="detached",mm=300,$s=301,Jr=302,al=303,ol=304,Xc=306,qa=1e3,Ai=1001,Ih=1002,Dt=1003,c2=1004,po=1005,at=1006,cl=1007,Gs=1008,Hi=1009,gm=1010,vm=1011,Ya=1012,Zu=1013,hn=1014,Ti=1015,$t=1016,Ju=1017,ju=1018,Ka=1020,Mm=35902,xm=35899,_m=1021,ym=1022,xi=1023,Jn=1026,Vs=1027,qc=1028,Qu=1029,Zs=1030,ed=1031,td=1033,hc=33776,uc=33777,dc=33778,fc=33779,Ph=35840,Lh=35841,Nh=35842,Oh=35843,Uh=36196,Fh=37492,kh=37496,zh=37488,Bh=37489,Sc=37490,Hh=37491,Gh=37808,Vh=37809,Wh=37810,Xh=37811,qh=37812,Yh=37813,Kh=37814,$h=37815,Zh=37816,Jh=37817,jh=37818,Qh=37819,eu=37820,tu=37821,iu=36492,nu=36494,su=36495,ru=36283,au=36284,bc=36285,ou=36286,Ec=2300,cu=2301,ll=2302,p0=2303,m0=2400,g0=2401,v0=2402,l2=2500,UE=0,FE=1,kE=2,h2=3200,wc=0,u2=1,xs="",Li="srgb",Ac="srgb-linear",Tc="linear",ut="srgb",or=7680,M0=519,d2=512,f2=513,p2=514,id=515,m2=516,g2=517,nd=518,v2=519,lu=35044,Rc="300 es",Rn=2e3,$a=2001;function M2(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}function x2(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Za(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function _2(){const s=Za("canvas");return s.style.display="block",s}const x0={};function Dc(...s){const e="THREE."+s.shift();console.log(e,...s)}function Sm(s){const e=s[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=s[1];t&&t.isStackTrace?s[0]+=" "+t.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function we(...s){s=Sm(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...s)}}function ke(...s){s=Sm(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...s)}}function Hr(...s){const e=s.join(" ");e in x0||(x0[e]=!0,we(...s))}function y2(s,e,t){return new Promise(function(i,n){function r(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:n();break;case s.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}const S2={[Eh]:wh,[Ah]:Dh,[Th]:Ch,[Zr]:Rh,[wh]:Eh,[Dh]:Ah,[Ch]:Th,[Rh]:Zr};class er{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 r=n.indexOf(t);r!==-1&&n.splice(r,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 r=0,a=n.length;r<a;r++)n[r].call(this,e);e.target=null}}}const mi=["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 _0=1234567;const Oa=Math.PI/180,jr=180/Math.PI;function ln(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(mi[s&255]+mi[s>>8&255]+mi[s>>16&255]+mi[s>>24&255]+"-"+mi[e&255]+mi[e>>8&255]+"-"+mi[e>>16&15|64]+mi[e>>24&255]+"-"+mi[t&63|128]+mi[t>>8&255]+"-"+mi[t>>16&255]+mi[t>>24&255]+mi[i&255]+mi[i>>8&255]+mi[i>>16&255]+mi[i>>24&255]).toLowerCase()}function Je(s,e,t){return Math.max(e,Math.min(t,s))}function sd(s,e){return(s%e+e)%e}function b2(s,e,t,i,n){return i+(s-e)*(n-i)/(t-e)}function E2(s,e,t){return s!==e?(t-s)/(e-s):0}function Ua(s,e,t){return(1-t)*s+t*e}function w2(s,e,t,i){return Ua(s,e,1-Math.exp(-t*i))}function A2(s,e=1){return e-Math.abs(sd(s,e*2)-e)}function T2(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function R2(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function D2(s,e){return s+Math.floor(Math.random()*(e-s+1))}function C2(s,e){return s+Math.random()*(e-s)}function I2(s){return s*(.5-Math.random())}function P2(s){s!==void 0&&(_0=s);let e=_0+=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 L2(s){return s*Oa}function N2(s){return s*jr}function O2(s){return(s&s-1)===0&&s!==0}function U2(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function F2(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function k2(s,e,t,i,n){const r=Math.cos,a=Math.sin,o=r(t/2),c=a(t/2),l=r((e+i)/2),h=a((e+i)/2),u=r((e-i)/2),d=a((e-i)/2),f=r((i-e)/2),p=a((i-e)/2);switch(n){case"XYX":s.set(o*h,c*u,c*d,o*l);break;case"YZY":s.set(c*d,o*h,c*u,o*l);break;case"ZXZ":s.set(c*u,c*d,o*h,o*l);break;case"XZX":s.set(o*h,c*p,c*f,o*l);break;case"YXY":s.set(c*f,o*h,c*p,o*l);break;case"ZYZ":s.set(c*p,c*f,o*h,o*l);break;default:we("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function cn(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function dt(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const zE={DEG2RAD:Oa,RAD2DEG:jr,generateUUID:ln,clamp:Je,euclideanModulo:sd,mapLinear:b2,inverseLerp:E2,lerp:Ua,damp:w2,pingpong:A2,smoothstep:T2,smootherstep:R2,randInt:D2,randFloat:C2,randFloatSpread:I2,seededRandom:P2,degToRad:L2,radToDeg:N2,isPowerOfTwo:O2,ceilPowerOfTwo:U2,floorPowerOfTwo:F2,setQuaternionFromProperEuler:k2,normalize:dt,denormalize:cn};class Ae{static{Ae.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),r=this.x-e.x,a=this.y-e.y;return this.x=r*i-a*n+e.x,this.y=r*n+a*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,r,a,o){let c=i[n+0],l=i[n+1],h=i[n+2],u=i[n+3],d=r[a+0],f=r[a+1],p=r[a+2],v=r[a+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 b=Math.acos(m),y=Math.sin(b);g=Math.sin(g*b)/y,o=Math.sin(o*b)/y,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 b=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=b,l*=b,h*=b,u*=b}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,i,n,r,a){const o=i[n],c=i[n+1],l=i[n+2],h=i[n+3],u=r[a],d=r[a+1],f=r[a+2],p=r[a+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,r=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(i/2),h=o(n/2),u=o(r/2),d=c(i/2),f=c(n/2),p=c(r/2);switch(a){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:we("Quaternion: .setFromEuler() encountered an unknown order: "+a)}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],r=t[8],a=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=(r-l)*f,this._z=(a-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+a)/f,this._z=(r+l)/f}else if(o>u){const f=2*Math.sqrt(1+o-i-u);this._w=(r-l)/f,this._x=(n+a)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+u-i-o);this._w=(a-n)/f,this._x=(r+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,r=e._z,a=e._w,o=t._x,c=t._y,l=t._z,h=t._w;return this._x=i*h+a*o+n*l-r*c,this._y=n*h+a*c+r*o-i*l,this._z=r*h+a*l+i*c-n*o,this._w=a*h-i*o-n*c-r*l,this._onChangeCallback(),this}slerp(e,t){let i=e._x,n=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,n=-n,r=-r,a=-a,o=-o);let c=1-t;if(o<.9995){const l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,t=Math.sin(t*l)/h,this._x=this._x*c+i*t,this._y=this._y*c+n*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this._onChangeCallback()}else this._x=this._x*c+i*t,this._y=this._y*c+n*t,this._z=this._z*c+r*t,this._w=this._w*c+a*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),r=Math.sqrt(i);return this.set(n*Math.sin(e),n*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class 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(y0.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(y0.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*n,this.y=r[1]*t+r[4]*i+r[7]*n,this.z=r[2]*t+r[5]*i+r[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,r=e.elements,a=1/(r[3]*t+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*n+r[12])*a,this.y=(r[1]*t+r[5]*i+r[9]*n+r[13])*a,this.z=(r[2]*t+r[6]*i+r[10]*n+r[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,n=this.z,r=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*n-o*i),h=2*(o*t-r*n),u=2*(r*i-a*t);return this.x=t+c*l+a*u-o*h,this.y=i+c*h+o*l-r*u,this.z=n+c*u+r*h-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*n,this.y=r[1]*t+r[5]*i+r[9]*n,this.z=r[2]*t+r[6]*i+r[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,r=e.z,a=t.x,o=t.y,c=t.z;return this.x=n*c-r*o,this.y=r*a-i*c,this.z=i*o-n*a,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,y0=new Qn;class He{static{He.prototype.isMatrix3=!0}constructor(e,t,i,n,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,n,r,a,o,c,l)}set(e,t,i,n,r,a,o,c,l){const h=this.elements;return h[0]=e,h[1]=n,h[2]=o,h[3]=t,h[4]=r,h[5]=c,h[6]=i,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,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,r=this.elements,a=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],b=n[1],y=n[4],_=n[7],E=n[2],w=n[5],R=n[8];return r[0]=a*v+o*b+c*E,r[3]=a*m+o*y+c*w,r[6]=a*g+o*_+c*R,r[1]=l*v+h*b+u*E,r[4]=l*m+h*y+u*w,r[7]=l*g+h*_+u*R,r[2]=d*v+f*b+p*E,r[5]=d*m+f*y+p*w,r[8]=d*g+f*_+p*R,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8];return t*a*h-t*o*l-i*r*h+i*o*c+n*r*l-n*a*c}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=h*a-o*l,d=o*c-h*r,f=l*r-a*c,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*a)*v,e[3]=d*v,e[4]=(h*t-n*c)*v,e[5]=(n*r-o*t)*v,e[6]=f*v,e[7]=(i*c-l*t)*v,e[8]=(a*t-i*r)*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,r,a,o){const c=Math.cos(r),l=Math.sin(r);return this.set(i*c,i*l,-i*(c*a+l*o)+a+e,-n*l,n*c,-n*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return Hr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(ul.makeScale(e,t)),this}rotate(e){return Hr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(ul.makeRotation(-e)),this}translate(e,t){return Hr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(ul.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 ul=new He,S0=new He().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),b0=new He().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function z2(){const s={enabled:!0,workingColorSpace:Ac,spaces:{},convert:function(n,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===ut&&(n.r=$n(n.r),n.g=$n(n.g),n.b=$n(n.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(n.applyMatrix3(this.spaces[r].toXYZ),n.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ut&&(n.r=Gr(n.r),n.g=Gr(n.g),n.b=Gr(n.b))),n},workingToColorSpace:function(n,r){return this.convert(n,this.workingColorSpace,r)},colorSpaceToWorking:function(n,r){return this.convert(n,r,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===xs?Tc:this.spaces[n].transfer},getToneMappingMode:function(n){return this.spaces[n].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(n,r=this.workingColorSpace){return n.fromArray(this.spaces[r].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,r,a){return n.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(n,r){return Hr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(n,r)},toWorkingColorSpace:function(n,r){return Hr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(n,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return s.define({[Ac]:{primaries:e,whitePoint:i,transfer:Tc,toXYZ:S0,fromXYZ:b0,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Li},outputColorSpaceConfig:{drawingBufferColorSpace:Li}},[Li]:{primaries:e,whitePoint:i,transfer:ut,toXYZ:S0,fromXYZ:b0,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Li}}}),s}const et=z2();function $n(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Gr(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let cr;class B2{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{cr===void 0&&(cr=Za("canvas")),cr.width=e.width,cr.height=e.height;const n=cr.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),i=cr}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=Za("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),r=n.data;for(let a=0;a<r.length;a++)r[a]=$n(r[a]/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($n(t[i]/255)*255):t[i]=$n(t[i]);return{data:t,width:e.width,height:e.height}}else return we("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let H2=0;class rd{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:H2++}),this.uuid=ln(),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 r;if(Array.isArray(n)){r=[];for(let a=0,o=n.length;a<o;a++)n[a].isDataTexture?r.push(dl(n[a].image)):r.push(dl(n[a]))}else r=dl(n);i.url=r}return t||(e.images[this.uuid]=i),i}}function dl(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?B2.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(we("Texture: Unable to serialize Texture."),{})}let G2=0;const fl=new D;class oi extends er{constructor(e=oi.DEFAULT_IMAGE,t=oi.DEFAULT_MAPPING,i=Ai,n=Ai,r=at,a=Gs,o=xi,c=Hi,l=oi.DEFAULT_ANISOTROPY,h=xs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:G2++}),this.uuid=ln(),this.name="",this.source=new rd(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Ae(0,0),this.repeat=new Ae(1,1),this.center=new Ae(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new He,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(fl).x}get height(){return this.source.getSize(fl).y}get depth(){return this.source.getSize(fl).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){we(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){we(`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!==mm)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case qa:e.x=e.x-Math.floor(e.x);break;case Ai:e.x=e.x<0?0:1;break;case Ih:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case qa:e.y=e.y-Math.floor(e.y);break;case Ai:e.y=e.y<0?0:1;break;case Ih: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++}}oi.DEFAULT_IMAGE=null;oi.DEFAULT_MAPPING=mm;oi.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,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*n+a[12]*r,this.y=a[1]*t+a[5]*i+a[9]*n+a[13]*r,this.z=a[2]*t+a[6]*i+a[10]*n+a[14]*r,this.w=a[3]*t+a[7]*i+a[11]*n+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,n,r;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 y=(l+1)/2,_=(f+1)/2,E=(g+1)/2,w=(h+d)/4,R=(u+v)/4,x=(p+m)/4;return y>_&&y>E?y<.01?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(y),n=w/i,r=R/i):_>E?_<.01?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(_),i=w/n,r=x/n):E<.01?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(E),i=R/r,n=x/r),this.set(i,n,r,t),this}let b=Math.sqrt((m-p)*(m-p)+(u-v)*(u-v)+(d-h)*(d-h));return Math.abs(b)<.001&&(b=1),this.x=(m-p)/b,this.y=(u-v)/b,this.z=(d-h)/b,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 V2 extends er{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:at,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},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},r=new oi(n),a=i.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(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:at,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let 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,r=this.textures.length;n<r;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 rd(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 ui extends V2{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class bm extends oi{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=Dt,this.minFilter=Dt,this.wrapR=Ai,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Em extends oi{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=Dt,this.minFilter=Dt,this.wrapR=Ai,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ye{static{Ye.prototype.isMatrix4=!0}constructor(e,t,i,n,r,a,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,r,a,o,c,l,h,u,d,f,p,v,m)}set(e,t,i,n,r,a,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]=r,g[5]=a,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 Ye().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/lr.setFromMatrixColumn(e,0).length(),r=1/lr.setFromMatrixColumn(e,1).length(),a=1/lr.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]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,n=e.y,r=e.z,a=Math.cos(i),o=Math.sin(i),c=Math.cos(n),l=Math.sin(n),h=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){const d=a*h,f=a*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]=a*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]=a*l,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=f*o-p,t[6]=v+d*o,t[10]=a*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]=-a*u,t[8]=p+f*o,t[1]=f+p*o,t[5]=a*h,t[9]=v-d*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const d=a*h,f=a*u,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]=a*c}else if(e.order==="YZX"){const d=a*c,f=a*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]=a*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=a*c,f=a*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]=a*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(W2,e,X2)}lookAt(e,t,i){const n=this.elements;return Ui.subVectors(e,t),Ui.lengthSq()===0&&(Ui.z=1),Ui.normalize(),as.crossVectors(i,Ui),as.lengthSq()===0&&(Math.abs(i.z)===1?Ui.x+=1e-4:Ui.z+=1e-4,Ui.normalize(),as.crossVectors(i,Ui)),as.normalize(),mo.crossVectors(Ui,as),n[0]=as.x,n[4]=mo.x,n[8]=Ui.x,n[1]=as.y,n[5]=mo.y,n[9]=Ui.y,n[2]=as.z,n[6]=mo.z,n[10]=Ui.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,r=this.elements,a=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],b=i[3],y=i[7],_=i[11],E=i[15],w=n[0],R=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 r[0]=a*w+o*I+c*z+l*K,r[4]=a*R+o*C+c*N+l*ee,r[8]=a*x+o*P+c*V+l*J,r[12]=a*A+o*X+c*k+l*ie,r[1]=h*w+u*I+d*z+f*K,r[5]=h*R+u*C+d*N+f*ee,r[9]=h*x+u*P+d*V+f*J,r[13]=h*A+u*X+d*k+f*ie,r[2]=p*w+v*I+m*z+g*K,r[6]=p*R+v*C+m*N+g*ee,r[10]=p*x+v*P+m*V+g*J,r[14]=p*A+v*X+m*k+g*ie,r[3]=b*w+y*I+_*z+E*K,r[7]=b*R+y*C+_*N+E*ee,r[11]=b*x+y*P+_*V+E*J,r[15]=b*A+y*X+_*k+E*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],r=e[12],a=e[1],o=e[5],c=e[9],l=e[13],h=e[2],u=e[6],d=e[10],f=e[14],p=e[3],v=e[7],m=e[11],g=e[15],b=c*f-l*d,y=o*f-l*u,_=o*d-c*u,E=a*f-l*h,w=a*d-c*h,R=a*u-o*h;return t*(v*b-m*y+g*_)-i*(p*b-m*E+g*w)+n*(p*y-v*E+g*R)-r*(p*_-v*w+m*R)}determinantAffine(){const e=this.elements,t=e[0],i=e[4],n=e[8],r=e[1],a=e[5],o=e[9],c=e[2],l=e[6],h=e[10];return t*(a*h-o*l)-i*(r*h-o*c)+n*(r*l-a*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,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],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=e[9],d=e[10],f=e[11],p=e[12],v=e[13],m=e[14],g=e[15],b=t*o-i*a,y=t*c-n*a,_=t*l-r*a,E=i*c-n*o,w=i*l-r*o,R=n*l-r*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=b*X-y*P+_*C+E*I-w*A+R*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-r*C)*N,e[2]=(v*R-m*w+g*E)*N,e[3]=(d*w-u*R-f*E)*N,e[4]=(c*I-a*X-l*A)*N,e[5]=(t*X-n*I+r*A)*N,e[6]=(m*_-p*R-g*y)*N,e[7]=(h*R-d*_+f*y)*N,e[8]=(a*P-o*I+l*x)*N,e[9]=(i*I-t*P-r*x)*N,e[10]=(p*w-v*_+g*b)*N,e[11]=(u*_-h*w-f*b)*N,e[12]=(o*A-a*C-c*x)*N,e[13]=(t*C-i*A+n*x)*N,e[14]=(v*y-p*E-m*b)*N,e[15]=(h*E-u*y+d*b)*N,this}scale(e){const t=this.elements,i=e.x,n=e.y,r=e.z;return t[0]*=i,t[4]*=n,t[8]*=r,t[1]*=i,t[5]*=n,t[9]*=r,t[2]*=i,t[6]*=n,t[10]*=r,t[3]*=i,t[7]*=n,t[11]*=r,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),r=1-i,a=e.x,o=e.y,c=e.z,l=r*a,h=r*o;return this.set(l*a+i,l*o-n*c,l*c+n*o,0,l*o+n*c,h*o+i,h*c-n*a,0,l*c-n*o,h*c+n*a,r*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,r,a){return this.set(1,i,r,0,e,1,a,0,t,n,1,0,0,0,0,1),this}compose(e,t,i){const n=this.elements,r=t._x,a=t._y,o=t._z,c=t._w,l=r+r,h=a+a,u=o+o,d=r*l,f=r*h,p=r*u,v=a*h,m=a*u,g=o*u,b=c*l,y=c*h,_=c*u,E=i.x,w=i.y,R=i.z;return n[0]=(1-(v+g))*E,n[1]=(f+_)*E,n[2]=(p-y)*E,n[3]=0,n[4]=(f-_)*w,n[5]=(1-(d+g))*w,n[6]=(m+b)*w,n[7]=0,n[8]=(p+y)*R,n[9]=(m-b)*R,n[10]=(1-(d+v))*R,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 r=this.determinantAffine();if(r===0)return i.set(1,1,1),t.identity(),this;let a=lr.set(n[0],n[1],n[2]).length();const o=lr.set(n[4],n[5],n[6]).length(),c=lr.set(n[8],n[9],n[10]).length();r<0&&(a=-a),Qi.copy(this);const l=1/a,h=1/o,u=1/c;return Qi.elements[0]*=l,Qi.elements[1]*=l,Qi.elements[2]*=l,Qi.elements[4]*=h,Qi.elements[5]*=h,Qi.elements[6]*=h,Qi.elements[8]*=u,Qi.elements[9]*=u,Qi.elements[10]*=u,t.setFromRotationMatrix(Qi),i.x=a,i.y=o,i.z=c,this}makePerspective(e,t,i,n,r,a,o=Rn,c=!1){const l=this.elements,h=2*r/(t-e),u=2*r/(i-n),d=(t+e)/(t-e),f=(i+n)/(i-n);let p,v;if(c)p=r/(a-r),v=a*r/(a-r);else if(o===Rn)p=-(a+r)/(a-r),v=-2*a*r/(a-r);else if(o===$a)p=-a/(a-r),v=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,n,r,a,o=Rn,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/(a-r),v=a/(a-r);else if(o===Rn)p=-2/(a-r),v=-(a+r)/(a-r);else if(o===$a)p=-1/(a-r),v=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=f,l[2]=0,l[6]=0,l[10]=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 lr=new D,Qi=new Ye,W2=new D(0,0,0),X2=new D(1,1,1),as=new D,mo=new D,Ui=new D,E0=new Ye,w0=new Qn;class jn{constructor(e=0,t=0,i=0,n=jn.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,r=n[0],a=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(-a,r)):(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,r),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(-a,l)):(this._y=0,this._z=Math.atan2(c,r));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,r)):(this._x=0,this._z=Math.atan2(-a,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,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Je(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,f),this._y=0);break;default:we("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return E0.makeRotationFromQuaternion(e),this.setFromRotationMatrix(E0,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return w0.setFromEuler(this),this.setFromQuaternion(w0,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}}jn.DEFAULT_ORDER="XYZ";class ad{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 q2=0;const A0=new D,hr=new Qn,Nn=new Ye,go=new D,aa=new D,Y2=new D,K2=new Qn,T0=new D(1,0,0),R0=new D(0,1,0),D0=new D(0,0,1),C0={type:"added"},$2={type:"removed"},ur={type:"childadded",child:null},pl={type:"childremoved",child:null};class At extends er{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:q2++}),this.uuid=ln(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=At.DEFAULT_UP.clone();const e=new D,t=new jn,i=new Qn,n=new D(1,1,1);function r(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(r),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Ye},normalMatrix:{value:new He}}),this.matrix=new Ye,this.matrixWorld=new Ye,this.matrixAutoUpdate=At.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=At.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ad,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 hr.setFromAxisAngle(e,t),this.quaternion.multiply(hr),this}rotateOnWorldAxis(e,t){return hr.setFromAxisAngle(e,t),this.quaternion.premultiply(hr),this}rotateX(e){return this.rotateOnAxis(T0,e)}rotateY(e){return this.rotateOnAxis(R0,e)}rotateZ(e){return this.rotateOnAxis(D0,e)}translateOnAxis(e,t){return A0.copy(e).applyQuaternion(this.quaternion),this.position.add(A0.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(T0,e)}translateY(e){return this.translateOnAxis(R0,e)}translateZ(e){return this.translateOnAxis(D0,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Nn.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?go.copy(e):go.set(e,t,i);const n=this.parent;this.updateWorldMatrix(!0,!1),aa.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Nn.lookAt(aa,go,this.up):Nn.lookAt(go,aa,this.up),this.quaternion.setFromRotationMatrix(Nn),n&&(Nn.extractRotation(n.matrixWorld),hr.setFromRotationMatrix(Nn),this.quaternion.premultiply(hr.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(ke("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(C0),ur.child=e,this.dispatchEvent(ur),ur.child=null):ke("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($2),pl.child=e,this.dispatchEvent(pl),pl.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),Nn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Nn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Nn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(C0),ur.child=e,this.dispatchEvent(ur),ur.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 a=this.children[i].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const n=this.children;for(let r=0,a=n.length;r<a;r++)n[r].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(aa,e,Y2),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(aa,K2,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,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*i-r[8]*n,r[13]+=i-r[1]*t-r[5]*i-r[9]*n,r[14]+=n-r[2]*t-r[6]*i-r[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 r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].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 r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?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=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const u=c[l];r(e.shapes,u)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(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(r(e.materials,this.material[c]));n.material=o}else n.material=r(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(r(e.animations,c))}}if(t){const o=a(e.geometries),c=a(e.materials),l=a(e.textures),h=a(e.images),u=a(e.shapes),d=a(e.skeletons),f=a(e.animations),p=a(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 a(o){const c=[];for(const l in o){const h=o[l];delete h.metadata,c.push(h)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const n=e.children[i];this.add(n.clone())}return this}}At.DEFAULT_UP=new D(0,1,0);At.DEFAULT_MATRIX_AUTO_UPDATE=!0;At.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class ri extends At{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Z2={type:"move"};class ml{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ri,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 ri,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 ri,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,r=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(const 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&&(r=t.getPose(e.gripSpace,i),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(n=t.getPose(e.targetRaySpace,i),n===null&&r!==null&&(n=r),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(Z2)))}return o!==null&&(o.visible=n!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new ri;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const wm={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},os={h:0,s:0,l:0},vo={h:0,s:0,l:0};function gl(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class oe{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=Li){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,et.colorSpaceToWorking(this,t),this}setRGB(e,t,i,n=et.workingColorSpace){return this.r=e,this.g=t,this.b=i,et.colorSpaceToWorking(this,n),this}setHSL(e,t,i,n=et.workingColorSpace){if(e=sd(e,1),t=Je(t,0,1),i=Je(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,a=2*i-r;this.r=gl(a,r,e+1/3),this.g=gl(a,r,e),this.b=gl(a,r,e-1/3)}return et.colorSpaceToWorking(this,n),this}setStyle(e,t=Li){function i(r){r!==void 0&&parseFloat(r)<1&&we("Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=n[1],o=n[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:we("Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=n[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);we("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Li){const i=wm[e.toLowerCase()];return i!==void 0?this.setHex(i,t):we("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=$n(e.r),this.g=$n(e.g),this.b=$n(e.b),this}copyLinearToSRGB(e){return this.r=Gr(e.r),this.g=Gr(e.g),this.b=Gr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Li){return et.workingToColorSpace(gi.copy(this),e),Math.round(Je(gi.r*255,0,255))*65536+Math.round(Je(gi.g*255,0,255))*256+Math.round(Je(gi.b*255,0,255))}getHexString(e=Li){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=et.workingColorSpace){et.workingToColorSpace(gi.copy(this),t);const i=gi.r,n=gi.g,r=gi.b,a=Math.max(i,n,r),o=Math.min(i,n,r);let c,l;const h=(o+a)/2;if(o===a)c=0,l=0;else{const u=a-o;switch(l=h<=.5?u/(a+o):u/(2-a-o),a){case i:c=(n-r)/u+(n<r?6:0);break;case n:c=(r-i)/u+2;break;case r:c=(i-n)/u+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=et.workingColorSpace){return et.workingToColorSpace(gi.copy(this),t),e.r=gi.r,e.g=gi.g,e.b=gi.b,e}getStyle(e=Li){et.workingToColorSpace(gi.copy(this),e);const t=gi.r,i=gi.g,n=gi.b;return e!==Li?`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(os),this.setHSL(os.h+e,os.s+t,os.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(os),e.getHSL(vo);const i=Ua(os.h,vo.h,t),n=Ua(os.s,vo.s,t),r=Ua(os.l,vo.l,t);return this.setHSL(i,n,r),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,r=e.elements;return this.r=r[0]*t+r[3]*i+r[6]*n,this.g=r[1]*t+r[4]*i+r[7]*n,this.b=r[2]*t+r[5]*i+r[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 gi=new oe;oe.NAMES=wm;class Cc{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new oe(e),this.near=t,this.far=i}clone(){return new Cc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Qr extends At{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 jn,this.environmentIntensity=1,this.environmentRotation=new jn,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 en=new D,On=new D,vl=new D,Un=new D,dr=new D,fr=new D,I0=new D,Ml=new D,xl=new D,_l=new D,yl=new it,Sl=new it,bl=new it;class Zi{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),en.subVectors(e,t),n.cross(en);const r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(e,t,i,n,r){en.subVectors(n,t),On.subVectors(i,t),vl.subVectors(e,t);const a=en.dot(en),o=en.dot(On),c=en.dot(vl),l=On.dot(On),h=On.dot(vl),u=a*l-o*o;if(u===0)return r.set(0,0,0),null;const d=1/u,f=(l*c-o*h)*d,p=(a*h-o*c)*d;return r.set(1-f-p,p,f)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,Un)===null?!1:Un.x>=0&&Un.y>=0&&Un.x+Un.y<=1}static getInterpolation(e,t,i,n,r,a,o,c){return this.getBarycoord(e,t,i,n,Un)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,Un.x),c.addScaledVector(a,Un.y),c.addScaledVector(o,Un.z),c)}static getInterpolatedAttribute(e,t,i,n,r,a){return yl.setScalar(0),Sl.setScalar(0),bl.setScalar(0),yl.fromBufferAttribute(e,t),Sl.fromBufferAttribute(e,i),bl.fromBufferAttribute(e,n),a.setScalar(0),a.addScaledVector(yl,r.x),a.addScaledVector(Sl,r.y),a.addScaledVector(bl,r.z),a}static isFrontFacing(e,t,i,n){return en.subVectors(i,t),On.subVectors(e,t),en.cross(On).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 en.subVectors(this.c,this.b),On.subVectors(this.a,this.b),en.cross(On).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Zi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Zi.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,n,r){return Zi.getInterpolation(e,this.a,this.b,this.c,t,i,n,r)}containsPoint(e){return Zi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Zi.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,n=this.b,r=this.c;let a,o;dr.subVectors(n,i),fr.subVectors(r,i),Ml.subVectors(e,i);const c=dr.dot(Ml),l=fr.dot(Ml);if(c<=0&&l<=0)return t.copy(i);xl.subVectors(e,n);const h=dr.dot(xl),u=fr.dot(xl);if(h>=0&&u<=h)return t.copy(n);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),t.copy(i).addScaledVector(dr,a);_l.subVectors(e,r);const f=dr.dot(_l),p=fr.dot(_l);if(p>=0&&f<=p)return t.copy(r);const v=f*l-c*p;if(v<=0&&l>=0&&p<=0)return o=l/(l-p),t.copy(i).addScaledVector(fr,o);const m=h*p-f*u;if(m<=0&&u-h>=0&&f-p>=0)return I0.subVectors(r,n),o=(u-h)/(u-h+(f-p)),t.copy(n).addScaledVector(I0,o);const g=1/(m+v+d);return a=v*g,o=d*g,t.copy(i).addScaledVector(dr,a).addScaledVector(fr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class un{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(tn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(tn.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=tn.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 r=i.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,tn):tn.fromBufferAttribute(r,a),tn.applyMatrix4(e.matrixWorld),this.expandByPoint(tn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Mo.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Mo.copy(i.boundingBox)),Mo.applyMatrix4(e.matrixWorld),this.union(Mo)}const n=e.children;for(let r=0,a=n.length;r<a;r++)this.expandByObject(n[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,tn),tn.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(oa),xo.subVectors(this.max,oa),pr.subVectors(e.a,oa),mr.subVectors(e.b,oa),gr.subVectors(e.c,oa),cs.subVectors(mr,pr),ls.subVectors(gr,mr),Ds.subVectors(pr,gr);let t=[0,-cs.z,cs.y,0,-ls.z,ls.y,0,-Ds.z,Ds.y,cs.z,0,-cs.x,ls.z,0,-ls.x,Ds.z,0,-Ds.x,-cs.y,cs.x,0,-ls.y,ls.x,0,-Ds.y,Ds.x,0];return!El(t,pr,mr,gr,xo)||(t=[1,0,0,0,1,0,0,0,1],!El(t,pr,mr,gr,xo))?!1:(_o.crossVectors(cs,ls),t=[_o.x,_o.y,_o.z],El(t,pr,mr,gr,xo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,tn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(tn).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:(Fn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Fn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Fn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Fn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Fn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Fn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Fn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Fn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Fn),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 Fn=[new D,new D,new D,new D,new D,new D,new D,new D],tn=new D,Mo=new un,pr=new D,mr=new D,gr=new D,cs=new D,ls=new D,Ds=new D,oa=new D,xo=new D,_o=new D,Cs=new D;function El(s,e,t,i,n){for(let r=0,a=s.length-3;r<=a;r+=3){Cs.fromArray(s,r);const o=n.x*Math.abs(Cs.x)+n.y*Math.abs(Cs.y)+n.z*Math.abs(Cs.z),c=e.dot(Cs),l=t.dot(Cs),h=i.dot(Cs);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const Xn=J2();function J2(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),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 r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,r[c]=l|h}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)a[c]=c<<23;a[31]=1199570944,a[32]=2147483648;for(let c=33;c<63;++c)a[c]=2147483648+(c-32<<23);a[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:n,mantissaTable:r,exponentTable:a,offsetTable:o}}function j2(s){Math.abs(s)>65504&&we("DataUtils.toHalfFloat(): Value out of range."),s=Je(s,-65504,65504),Xn.floatView[0]=s;const e=Xn.uint32View[0],t=e>>23&511;return Xn.baseTable[t]+((e&8388607)>>Xn.shiftTable[t])}function Q2(s){const e=s>>10;return Xn.uint32View[0]=Xn.mantissaTable[Xn.offsetTable[e]+(s&1023)]+Xn.exponentTable[e],Xn.floatView[0]}class Zn{static toHalfFloat(e){return j2(e)}static fromHalfFloat(e){return Q2(e)}}const Xt=new D,yo=new Ae;let ev=0;class ot extends er{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:ev++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=lu,this.updateRanges=[],this.gpuType=Ti,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,r=this.itemSize;n<r;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++)yo.fromBufferAttribute(this,t),yo.applyMatrix3(e),this.setXY(t,yo.x,yo.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Xt.fromBufferAttribute(this,t),Xt.applyMatrix3(e),this.setXYZ(t,Xt.x,Xt.y,Xt.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Xt.fromBufferAttribute(this,t),Xt.applyMatrix4(e),this.setXYZ(t,Xt.x,Xt.y,Xt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Xt.fromBufferAttribute(this,t),Xt.applyNormalMatrix(e),this.setXYZ(t,Xt.x,Xt.y,Xt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Xt.fromBufferAttribute(this,t),Xt.transformDirection(e),this.setXYZ(t,Xt.x,Xt.y,Xt.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=cn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=dt(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=cn(t,this.array)),t}setX(e,t){return this.normalized&&(t=dt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=cn(t,this.array)),t}setY(e,t){return this.normalized&&(t=dt(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=cn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=dt(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=cn(t,this.array)),t}setW(e,t){return this.normalized&&(t=dt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=dt(t,this.array),i=dt(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=dt(t,this.array),i=dt(i,this.array),n=dt(n,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this}setXYZW(e,t,i,n,r){return e*=this.itemSize,this.normalized&&(t=dt(t,this.array),i=dt(i,this.array),n=dt(n,this.array),r=dt(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==lu&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class Am extends ot{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class od extends ot{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class Pt extends ot{constructor(e,t,i){super(new Float32Array(e),t,i)}}const tv=new un,ca=new D,wl=new D;class es{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):tv.setFromPoints(e).getCenter(i);let n=0;for(let r=0,a=e.length;r<a;r++)n=Math.max(n,i.distanceToSquared(e[r]));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;ca.subVectors(e,this.center);const t=ca.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),n=(i-this.radius)*.5;this.center.addScaledVector(ca,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):(wl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ca.copy(e.center).add(wl)),this.expandByPoint(ca.copy(e.center).sub(wl))),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 iv=0;const Xi=new Ye,Al=new At,vr=new D,Fi=new un,la=new un,jt=new D;class bt extends er{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:iv++}),this.uuid=ln(),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(M2(e)?od:Am)(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 r=new He().getNormalMatrix(e);i.applyNormalMatrix(r),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 Xi.makeRotationFromQuaternion(e),this.applyMatrix4(Xi),this}rotateX(e){return Xi.makeRotationX(e),this.applyMatrix4(Xi),this}rotateY(e){return Xi.makeRotationY(e),this.applyMatrix4(Xi),this}rotateZ(e){return Xi.makeRotationZ(e),this.applyMatrix4(Xi),this}translate(e,t,i){return Xi.makeTranslation(e,t,i),this.applyMatrix4(Xi),this}scale(e,t,i){return Xi.makeScale(e,t,i),this.applyMatrix4(Xi),this}lookAt(e){return Al.lookAt(e),Al.updateMatrix(),this.applyMatrix4(Al.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(vr).negate(),this.translate(vr.x,vr.y,vr.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let n=0,r=e.length;n<r;n++){const a=e[n];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Pt(i,3))}else{const i=Math.min(e.length,t.count);for(let n=0;n<i;n++){const r=e[n];t.setXYZ(n,r.x,r.y,r.z||0)}e.length>t.count&&we("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 un);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ke("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 r=t[i];Fi.setFromBufferAttribute(r),this.morphTargetsRelative?(jt.addVectors(this.boundingBox.min,Fi.min),this.boundingBox.expandByPoint(jt),jt.addVectors(this.boundingBox.max,Fi.max),this.boundingBox.expandByPoint(jt)):(this.boundingBox.expandByPoint(Fi.min),this.boundingBox.expandByPoint(Fi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ke('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 es);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ke("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(Fi.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];la.setFromBufferAttribute(o),this.morphTargetsRelative?(jt.addVectors(Fi.min,la.min),Fi.expandByPoint(jt),jt.addVectors(Fi.max,la.max),Fi.expandByPoint(jt)):(Fi.expandByPoint(la.min),Fi.expandByPoint(la.max))}Fi.getCenter(i);let n=0;for(let r=0,a=e.count;r<a;r++)jt.fromBufferAttribute(e,r),n=Math.max(n,i.distanceToSquared(jt));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)jt.fromBufferAttribute(o,l),c&&(vr.fromBufferAttribute(e,l),jt.add(vr)),n=Math.max(n,i.distanceToSquared(jt))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&ke('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){ke("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,n=t.normal,r=t.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==i.count)&&(a=new ot(new Float32Array(4*i.count),4),this.setAttribute("tangent",a));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 Ae,f=new Ae,p=new Ae,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(r,x),f.fromBufferAttribute(r,A),p.fromBufferAttribute(r,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 b=this.groups;b.length===0&&(b=[{start:0,count:e.count}]);for(let x=0,A=b.length;x<A;++x){const I=b[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 y=new D,_=new D,E=new D,w=new D;function R(x){E.fromBufferAttribute(n,x),w.copy(E);const A=o[x];y.copy(A),y.sub(E.multiplyScalar(E.dot(A))).normalize(),_.crossVectors(w,A);const C=_.dot(c[x])<0?-1:1;a.setXYZW(x,y.x,y.y,y.z,C)}for(let x=0,A=b.length;x<A;++x){const I=b[x],C=I.start,P=I.count;for(let X=C,z=C+P;X<z;X+=3)R(e.getX(X+0)),R(e.getX(X+1)),R(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 ot(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,r=new D,a=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),r.fromBufferAttribute(t,v),a.fromBufferAttribute(t,m),h.subVectors(a,r),u.subVectors(n,r),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),r.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),h.subVectors(a,r),u.subVectors(n,r),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++)jt.fromBufferAttribute(e,t),jt.normalize(),e.setXYZ(t,jt.x,jt.y,jt.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 ot(d,h,u)}if(this.index===null)return we("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new bt,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 r=this.morphAttributes;for(const o in r){const c=[],l=r[o];for(let h=0,u=l.length;h<u;h++){const d=l[h],f=e(d,i);c.push(f)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const c in i){const l=i[c];e.data.attributes[c]=l.toJSON(e.data)}const n={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){const f=l[u];h.push(f.toJSON(e.data))}h.length>0&&(n[c]=h,r=!0)}r&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const 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 r=e.morphAttributes;for(const l in r){const h=[],u=r[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let l=0,h=a.length;l<h;l++){const u=a[l];this.addGroup(u.start,u.count,u.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class nv{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=lu,this.updateRanges=[],this.version=0,this.uuid=ln()}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,r=this.stride;n<r;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=ln()),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=ln()),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 _i=new D;class Ic{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++)_i.fromBufferAttribute(this,t),_i.applyMatrix4(e),this.setXYZ(t,_i.x,_i.y,_i.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)_i.fromBufferAttribute(this,t),_i.applyNormalMatrix(e),this.setXYZ(t,_i.x,_i.y,_i.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)_i.fromBufferAttribute(this,t),_i.transformDirection(e),this.setXYZ(t,_i.x,_i.y,_i.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=cn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=dt(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=dt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=dt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=dt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=dt(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=cn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=cn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=cn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=cn(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=dt(t,this.array),i=dt(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=dt(t,this.array),i=dt(i,this.array),n=dt(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,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=dt(t,this.array),i=dt(i,this.array),n=dt(n,this.array),r=dt(r,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]=r,this}clone(e){if(e===void 0){Dc("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 r=0;r<this.itemSize;r++)t.push(this.data.array[n+r])}return new ot(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 Ic(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Dc("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 r=0;r<this.itemSize;r++)t.push(this.data.array[n+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let sv=0;class ts extends er{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:sv++}),this.uuid=ln(),this.name="",this.type="Material",this.blending=qs,this.side=ws,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=bh,this.blendDst=yc,this.blendEquation=Fs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new oe(0,0,0),this.blendAlpha=0,this.depthFunc=Zr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=M0,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=or,this.stencilZFail=or,this.stencilZPass=or,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){we(`Material: parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){we(`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!==qs&&(i.blending=this.blending),this.side!==ws&&(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!==bh&&(i.blendSrc=this.blendSrc),this.blendDst!==yc&&(i.blendDst=this.blendDst),this.blendEquation!==Fs&&(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!==Zr&&(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!==M0&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==or&&(i.stencilFail=this.stencilFail),this.stencilZFail!==or&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==or&&(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(r){const a=[];for(const o in r){const c=r[o];delete c.metadata,a.push(c)}return a}if(t){const r=n(e.textures),a=n(e.images);r.length>0&&(i.textures=r),a.length>0&&(i.images=a)}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 oe().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 Ae().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 Ae().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 r=0;r!==n;++r)i[r]=t[r].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 Ta extends ts{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new oe(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 Mr;const ha=new D,xr=new D,_r=new D,yr=new Ae,ua=new Ae,Tm=new Ye,So=new D,da=new D,bo=new D,P0=new Ae,Tl=new Ae,L0=new Ae;class Sr extends At{constructor(e=new Ta){if(super(),this.isSprite=!0,this.type="Sprite",Mr===void 0){Mr=new bt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new nv(t,5);Mr.setIndex([0,1,2,0,2,3]),Mr.setAttribute("position",new Ic(i,3,0,!1)),Mr.setAttribute("uv",new Ic(i,2,3,!1))}this.geometry=Mr,this.material=e,this.center=new Ae(.5,.5),this.count=1}raycast(e,t){e.camera===null&&ke('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),xr.setFromMatrixScale(this.matrixWorld),Tm.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),_r.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&xr.multiplyScalar(-_r.z);const i=this.material.rotation;let n,r;i!==0&&(r=Math.cos(i),n=Math.sin(i));const a=this.center;Eo(So.set(-.5,-.5,0),_r,a,xr,n,r),Eo(da.set(.5,-.5,0),_r,a,xr,n,r),Eo(bo.set(.5,.5,0),_r,a,xr,n,r),P0.set(0,0),Tl.set(1,0),L0.set(1,1);let o=e.ray.intersectTriangle(So,da,bo,!1,ha);if(o===null&&(Eo(da.set(-.5,.5,0),_r,a,xr,n,r),Tl.set(0,1),o=e.ray.intersectTriangle(So,bo,da,!1,ha),o===null))return;const c=e.ray.origin.distanceTo(ha);c<e.near||c>e.far||t.push({distance:c,point:ha.clone(),uv:Zi.getInterpolation(ha,So,da,bo,P0,Tl,L0,new Ae),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 Eo(s,e,t,i,n,r){yr.subVectors(s,t).addScalar(.5).multiply(i),n!==void 0?(ua.x=r*yr.x-n*yr.y,ua.y=n*yr.x+r*yr.y):ua.copy(yr),s.copy(e),s.x+=ua.x,s.y+=ua.y,s.applyMatrix4(Tm)}const kn=new D,Rl=new D,wo=new D,hs=new D,Dl=new D,Ao=new D,Cl=new D;class ja{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,kn)),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=kn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(kn.copy(this.origin).addScaledVector(this.direction,t),kn.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){Rl.copy(e).add(t).multiplyScalar(.5),wo.copy(t).sub(e).normalize(),hs.copy(this.origin).sub(Rl);const r=e.distanceTo(t)*.5,a=-this.direction.dot(wo),o=hs.dot(this.direction),c=-hs.dot(wo),l=hs.lengthSq(),h=Math.abs(1-a*a);let u,d,f,p;if(h>0)if(u=a*c-o,d=a*o-c,p=r*h,u>=0)if(d>=-p)if(d<=p){const v=1/h;u*=v,d*=v,f=u*(u+a*d+2*o)+d*(a*u+d+2*c)+l}else d=r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d=-r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d<=-p?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l):d<=p?(u=0,d=Math.min(Math.max(-r,-c),r),f=d*(d+2*c)+l):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,u),n&&n.copy(Rl).addScaledVector(wo,d),f}intersectSphere(e,t){kn.subVectors(e.center,this.origin);const i=kn.dot(this.direction),n=kn.dot(kn)-i*i,r=e.radius*e.radius;if(n>r)return null;const a=Math.sqrt(r-n),o=i-a,c=i+a;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const 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,r,a,o,c;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(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?(r=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(r=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),i>a||r>n||((r>i||isNaN(i))&&(i=r),(a<n||isNaN(n))&&(n=a),u>=0?(o=(e.min.z-d.z)*u,c=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,c=(e.min.z-d.z)*u),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,kn)!==null}intersectTriangle(e,t,i,n,r){Dl.subVectors(t,e),Ao.subVectors(i,e),Cl.crossVectors(Dl,Ao);let a=this.direction.dot(Cl),o;if(a>0){if(n)return null;o=1}else if(a<0)o=-1,a=-a;else return null;hs.subVectors(this.origin,e);const c=o*this.direction.dot(Ao.crossVectors(hs,Ao));if(c<0)return null;const l=o*this.direction.dot(Dl.cross(hs));if(l<0||c+l>a)return null;const h=-o*hs.dot(Cl);return h<0?null:this.at(h/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Ji extends ts{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new oe(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 jn,this.combine=$u,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 N0=new Ye,Is=new ja,To=new es,O0=new D,Ro=new D,Do=new D,Co=new D,Il=new D,Io=new D,U0=new D,Po=new D;class We extends At{constructor(e=new bt,t=new Ji){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 r=0,a=n.length;r<a;r++){const o=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){const i=this.geometry,n=i.attributes.position,r=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(n,e);const o=this.morphTargetInfluences;if(r&&o){Io.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const h=o[c],u=r[c];h!==0&&(Il.fromBufferAttribute(u,e),a?Io.addScaledVector(Il,h):Io.addScaledVector(Il.sub(t),h))}t.add(Io)}return t}raycast(e,t){const i=this.geometry,n=this.material,r=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),To.copy(i.boundingSphere),To.applyMatrix4(r),Is.copy(e.ray).recast(e.near),!(To.containsPoint(Is.origin)===!1&&(Is.intersectSphere(To,O0)===null||Is.origin.distanceToSquared(O0)>(e.far-e.near)**2))&&(N0.copy(r).invert(),Is.copy(e.ray).applyMatrix4(N0),!(i.boundingBox!==null&&Is.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Is)))}_computeIntersections(e,t,i){let n;const r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,v=d.length;p<v;p++){const m=d[p],g=a[m.materialIndex],b=Math.max(m.start,f.start),y=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let _=b,E=y;_<E;_+=3){const w=o.getX(_),R=o.getX(_+1),x=o.getX(_+2);n=Lo(this,g,e,i,l,h,u,w,R,x),n&&(n.faceIndex=Math.floor(_/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 b=o.getX(m),y=o.getX(m+1),_=o.getX(m+2);n=Lo(this,a,e,i,l,h,u,b,y,_),n&&(n.faceIndex=Math.floor(m/3),t.push(n))}}else if(c!==void 0)if(Array.isArray(a))for(let p=0,v=d.length;p<v;p++){const m=d[p],g=a[m.materialIndex],b=Math.max(m.start,f.start),y=Math.min(c.count,Math.min(m.start+m.count,f.start+f.count));for(let _=b,E=y;_<E;_+=3){const w=_,R=_+1,x=_+2;n=Lo(this,g,e,i,l,h,u,w,R,x),n&&(n.faceIndex=Math.floor(_/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 b=m,y=m+1,_=m+2;n=Lo(this,a,e,i,l,h,u,b,y,_),n&&(n.faceIndex=Math.floor(m/3),t.push(n))}}}}function rv(s,e,t,i,n,r,a,o){let c;if(e.side===It?c=i.intersectTriangle(a,r,n,!0,o):c=i.intersectTriangle(n,r,a,e.side===ws,o),c===null)return null;Po.copy(o),Po.applyMatrix4(s.matrixWorld);const l=t.ray.origin.distanceTo(Po);return l<t.near||l>t.far?null:{distance:l,point:Po.clone(),object:s}}function Lo(s,e,t,i,n,r,a,o,c,l){s.getVertexPosition(o,Ro),s.getVertexPosition(c,Do),s.getVertexPosition(l,Co);const h=rv(s,e,t,i,Ro,Do,Co,U0);if(h){const u=new D;Zi.getBarycoord(U0,Ro,Do,Co,u),n&&(h.uv=Zi.getInterpolatedAttribute(n,o,c,l,u,new Ae)),r&&(h.uv1=Zi.getInterpolatedAttribute(r,o,c,l,u,new Ae)),a&&(h.normal=Zi.getInterpolatedAttribute(a,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};Zi.getNormal(Ro,Do,Co,d.normal),h.face=d,h.barycoord=u}return h}const fa=new it,F0=new it,k0=new it,av=new it,z0=new Ye,No=new D,Pl=new es,B0=new Ye,Ll=new ja;class BE extends We{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=f0,this.bindMatrix=new Ye,this.bindMatrixInverse=new Ye,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new un),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,No),this.boundingBox.expandByPoint(No)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new es),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,No),this.boundingSphere.expandByPoint(No)}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(),Pl.copy(this.boundingSphere),Pl.applyMatrix4(n),e.ray.intersectsSphere(Pl)!==!1&&(B0.copy(n).invert(),Ll.copy(e.ray).applyMatrix4(B0),!(this.boundingBox!==null&&Ll.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Ll)))}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 r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===f0?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===o2?this.bindMatrixInverse.copy(this.bindMatrix).invert():we("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,n=this.geometry;F0.fromBufferAttribute(n.attributes.skinIndex,e),k0.fromBufferAttribute(n.attributes.skinWeight,e),t.isVector4?(fa.copy(t),t.set(0,0,0,0)):(fa.set(...t,1),t.set(0,0,0)),fa.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){const a=k0.getComponent(r);if(a!==0){const o=F0.getComponent(r);z0.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(av.copy(fa).applyMatrix4(z0),a)}}return t.isVector4&&(t.w=fa.w),t.applyMatrix4(this.bindMatrixInverse)}}class ov extends At{constructor(){super(),this.isBone=!0,this.type="Bone"}}class tr extends oi{constructor(e=null,t=1,i=1,n,r,a,o,c,l=Dt,h=Dt,u,d){super(null,a,o,c,l,h,n,r,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const H0=new Ye,cv=new Ye;class Rm{constructor(e=[],t=[]){this.uuid=ln(),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){we("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 Ye)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new Ye;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 r=0,a=e.length;r<a;r++){const o=e[r]?e[r].matrixWorld:cv;H0.multiplyMatrices(o,t[r]),H0.toArray(i,r*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new Rm(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 tr(t,e,e,xi,Ti);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 r=e.bones[i];let a=t[r];a===void 0&&(we("Skeleton: No bone found with UUID:",r),a=new ov),this.bones.push(a),this.boneInverses.push(new Ye().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,r=t.length;n<r;n++){const a=t[n];e.bones.push(a.uuid);const o=i[n];e.boneInverses.push(o.toArray())}return e}}class G0 extends ot{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 br=new Ye,V0=new Ye,Oo=[],W0=new un,lv=new Ye,pa=new We,ma=new es;class HE extends We{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new G0(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,lv)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new un),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,br),W0.copy(e.boundingBox).applyMatrix4(br),this.boundingBox.union(W0)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new es),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,br),ma.copy(e.boundingSphere).applyMatrix4(br),this.boundingSphere.union(ma)}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,r=i.length+1,a=e*r+1;for(let o=0;o<i.length;o++)i[o]=n[a+o]}raycast(e,t){const i=this.matrixWorld,n=this.count;if(pa.geometry=this.geometry,pa.material=this.material,pa.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ma.copy(this.boundingSphere),ma.applyMatrix4(i),e.ray.intersectsSphere(ma)!==!1))for(let r=0;r<n;r++){this.getMatrixAt(r,br),V0.multiplyMatrices(i,br),pa.matrixWorld=V0,pa.raycast(e,Oo);for(let a=0,o=Oo.length;a<o;a++){const c=Oo[a];c.instanceId=r,c.object=this,t.push(c)}Oo.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new G0(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 tr(new Float32Array(n*this.count),n,this.count,qc,Ti));const r=this.morphTexture.source.data.data;let a=0;for(let l=0;l<i.length;l++)a+=i[l];const o=this.geometry.morphTargetsRelative?1:1-a,c=n*e;return r[c]=o,r.set(i,c+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Nl=new D,hv=new D,uv=new He;class Os{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=Nl.subVectors(i,t).cross(hv.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(Nl),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return i===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(n,a)}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||uv.getNormalMatrix(e),n=this.coplanarPoint(Nl).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ps=new es,dv=new Ae(.5,.5),Uo=new D;class cd{constructor(e=new Os,t=new Os,i=new Os,n=new Os,r=new Os,a=new Os){this.planes=[e,t,i,n,r,a]}set(e,t,i,n,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(n),o[4].copy(r),o[5].copy(a),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=Rn,i=!1){const n=this.planes,r=e.elements,a=r[0],o=r[1],c=r[2],l=r[3],h=r[4],u=r[5],d=r[6],f=r[7],p=r[8],v=r[9],m=r[10],g=r[11],b=r[12],y=r[13],_=r[14],E=r[15];if(n[0].setComponents(l-a,f-h,g-p,E-b).normalize(),n[1].setComponents(l+a,f+h,g+p,E+b).normalize(),n[2].setComponents(l+o,f+u,g+v,E+y).normalize(),n[3].setComponents(l-o,f-u,g-v,E-y).normalize(),i)n[4].setComponents(c,d,m,_).normalize(),n[5].setComponents(l-c,f-d,g-m,E-_).normalize();else if(n[4].setComponents(l-c,f-d,g-m,E-_).normalize(),t===Rn)n[5].setComponents(l+c,f+d,g+m,E+_).normalize();else if(t===$a)n[5].setComponents(c,d,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(),Ps.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ps.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ps)}intersectsSprite(e){Ps.center.set(0,0,0);const t=dv.distanceTo(e.center);return Ps.radius=.7071067811865476+t,Ps.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ps)}intersectsSphere(e){const t=this.planes,i=e.center,n=-e.radius;for(let r=0;r<6;r++)if(t[r].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(Uo.x=n.normal.x>0?e.max.x:e.min.x,Uo.y=n.normal.y>0?e.max.y:e.min.y,Uo.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(Uo)<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 fv extends ts{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new oe(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 Pc=new D,Lc=new D,X0=new Ye,ga=new ja,Fo=new es,Ol=new D,q0=new D;class Dm extends At{constructor(e=new bt,t=new fv){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,r=t.count;n<r;n++)Pc.fromBufferAttribute(t,n-1),Lc.fromBufferAttribute(t,n),i[n]=i[n-1],i[n]+=Pc.distanceTo(Lc);e.setAttribute("lineDistance",new Pt(i,1))}else we("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Fo.copy(i.boundingSphere),Fo.applyMatrix4(n),Fo.radius+=r,e.ray.intersectsSphere(Fo)===!1)return;X0.copy(n).invert(),ga.copy(e.ray).applyMatrix4(X0);const o=r/((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,a.start),p=Math.min(h.count,a.start+a.count);for(let v=f,m=p-1;v<m;v+=l){const g=h.getX(v),b=h.getX(v+1),y=ko(this,e,ga,c,g,b,v);y&&t.push(y)}if(this.isLineLoop){const v=h.getX(p-1),m=h.getX(f),g=ko(this,e,ga,c,v,m,p-1);g&&t.push(g)}}else{const f=Math.max(0,a.start),p=Math.min(d.count,a.start+a.count);for(let v=f,m=p-1;v<m;v+=l){const g=ko(this,e,ga,c,v,v+1,v);g&&t.push(g)}if(this.isLineLoop){const v=ko(this,e,ga,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 r=0,a=n.length;r<a;r++){const o=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function ko(s,e,t,i,n,r,a){const o=s.geometry.attributes.position;if(Pc.fromBufferAttribute(o,n),Lc.fromBufferAttribute(o,r),t.distanceSqToSegment(Pc,Lc,Ol,q0)>i)return;Ol.applyMatrix4(s.matrixWorld);const l=e.ray.origin.distanceTo(Ol);if(!(l<e.near||l>e.far))return{distance:l,point:q0.clone().applyMatrix4(s.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:s}}const Y0=new D,K0=new D;class GE extends Dm{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,r=t.count;n<r;n+=2)Y0.fromBufferAttribute(t,n),K0.fromBufferAttribute(t,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+Y0.distanceTo(K0);e.setAttribute("lineDistance",new Pt(i,1))}else we("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class VE extends Dm{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class ld extends ts{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new oe(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 $0=new Ye,hu=new ja,zo=new es,Bo=new D;class Fa extends At{constructor(e=new bt,t=new ld){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,r=e.params.Points.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),zo.copy(i.boundingSphere),zo.applyMatrix4(n),zo.radius+=r,e.ray.intersectsSphere(zo)===!1)return;$0.copy(n).invert(),hu.copy(e.ray).applyMatrix4($0);const o=r/((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,a.start),f=Math.min(l.count,a.start+a.count);for(let p=d,v=f;p<v;p++){const m=l.getX(p);Bo.fromBufferAttribute(u,m),Z0(Bo,m,c,n,e,t,this)}}else{const d=Math.max(0,a.start),f=Math.min(u.count,a.start+a.count);for(let p=d,v=f;p<v;p++)Bo.fromBufferAttribute(u,p),Z0(Bo,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 r=0,a=n.length;r<a;r++){const o=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Z0(s,e,t,i,n,r,a){const o=hu.distanceSqToPoint(s);if(o<t){const c=new D;hu.closestPointToPoint(s,c),c.applyMatrix4(i);const l=n.ray.origin.distanceTo(c);if(l<n.near||l>n.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Cm extends oi{constructor(e=[],t=$s,i,n,r,a,o,c,l,h){super(e,t,i,n,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Ln extends oi{constructor(e,t,i,n,r,a,o,c,l){super(e,t,i,n,r,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Js extends oi{constructor(e,t,i=hn,n,r,a,o=Dt,c=Dt,l,h=Jn,u=1){if(h!==Jn&&h!==Vs)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,r,a,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 rd(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 pv extends Js{constructor(e,t=hn,i=$s,n,r,a=Dt,o=Dt,c,l=Jn){const h={width:e,height:e,depth:1},u=[h,h,h,h,h,h];super(e,e,t,i,n,r,a,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Im extends oi{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class ji extends bt{constructor(e=1,t=1,i=1,n=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:n,heightSegments:r,depthSegments:a};const o=this;n=Math.floor(n),r=Math.floor(r),a=Math.floor(a);const c=[],l=[],h=[],u=[];let d=0,f=0;p("z","y","x",-1,-1,i,t,e,a,r,0),p("z","y","x",1,-1,i,t,-e,a,r,1),p("x","z","y",1,1,e,i,t,n,a,2),p("x","z","y",1,-1,e,i,-t,n,a,3),p("x","y","z",1,-1,e,t,i,n,r,4),p("x","y","z",-1,-1,e,t,-i,n,r,5),this.setIndex(c),this.setAttribute("position",new Pt(l,3)),this.setAttribute("normal",new Pt(h,3)),this.setAttribute("uv",new Pt(u,2));function p(v,m,g,b,y,_,E,w,R,x,A){const I=_/R,C=E/x,P=_/2,X=E/2,z=w/2,N=R+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 ae=0;ae<N;ae++){const Be=ae*I-P;ee[v]=Be*b,ee[m]=ie*y,ee[g]=z,l.push(ee.x,ee.y,ee.z),ee[v]=0,ee[m]=0,ee[g]=w>0?1:-1,h.push(ee.x,ee.y,ee.z),u.push(ae/R),u.push(1-J/x),k+=1}}for(let J=0;J<x;J++)for(let ie=0;ie<R;ie++){const ae=d+ie+N*J,Be=d+ie+N*(J+1),je=d+(ie+1)+N*(J+1),Ge=d+(ie+1)+N*J;c.push(ae,Be,Ge),c.push(Be,je,Ge),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 ji(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class hd extends bt{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 r=[],a=[],o=[],c=[],l=new D,h=new Ae;a.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let u=0,d=3;u<=t;u++,d+=3){const f=i+u/t*n;l.x=e*Math.cos(f),l.y=e*Math.sin(f),a.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(a[d]/e+1)/2,h.y=(a[d+1]/e+1)/2,c.push(h.x,h.y)}for(let u=1;u<=t;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new Pt(a,3)),this.setAttribute("normal",new Pt(o,3)),this.setAttribute("uv",new Pt(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new hd(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class is extends bt{constructor(e=1,t=1,i=1,n=32,r=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:n,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:c};const l=this;n=Math.floor(n),r=Math.floor(r);const h=[],u=[],d=[],f=[];let p=0;const v=[],m=i/2;let g=0;b(),a===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new Pt(u,3)),this.setAttribute("normal",new Pt(d,3)),this.setAttribute("uv",new Pt(f,2));function b(){const _=new D,E=new D;let w=0;const R=(t-e)/i;for(let x=0;x<=r;x++){const A=[],I=x/r,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);E.x=C*N,E.y=-I*i+m,E.z=C*V,u.push(E.x,E.y,E.z),_.set(N,R,V).normalize(),d.push(_.x,_.y,_.z),f.push(X,1-I),A.push(p++)}v.push(A)}for(let x=0;x<n;x++)for(let A=0;A<r;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),w+=3),(t>0||A!==r-1)&&(h.push(C,P,X),w+=3)}l.addGroup(g,w,0),g+=w}function y(_){const E=p,w=new Ae,R=new D;let x=0;const A=_===!0?e:t,I=_===!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);R.x=A*V,R.y=m*I,R.z=A*N,u.push(R.x,R.y,R.z),d.push(0,I,0),w.x=N*.5+.5,w.y=V*.5*I+.5,f.push(w.x,w.y),p++}for(let P=0;P<n;P++){const X=E+P,z=C+P;_===!0?h.push(z,z+1,X):h.push(z+1,z,X),x+=3}l.addGroup(g,x,_===!0?1:2),g+=x}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new is(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Qa extends is{constructor(e=1,t=1,i=32,n=1,r=!1,a=0,o=Math.PI*2){super(0,e,t,i,n,r,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:n,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Qa(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class dn extends bt{constructor(e=1,t=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:n};const r=e/2,a=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 b=g*d-a;for(let y=0;y<l;y++){const _=y*u-r;p.push(_,-b,0),v.push(0,0,1),m.push(y/o),m.push(1-g/c)}}for(let g=0;g<c;g++)for(let b=0;b<o;b++){const y=b+l*g,_=b+l*(g+1),E=b+1+l*(g+1),w=b+1+l*g;f.push(y,_,w),f.push(_,E,w)}this.setIndex(f),this.setAttribute("position",new Pt(p,3)),this.setAttribute("normal",new Pt(v,3)),this.setAttribute("uv",new Pt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new dn(e.width,e.height,e.widthSegments,e.heightSegments)}}class di extends bt{constructor(e=1,t=32,i=16,n=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:n,phiLength:r,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const c=Math.min(a+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 b=[],y=g/i,_=a+y*o,E=e*Math.cos(_),w=Math.sqrt(e*e-E*E);let R=0;g===0&&a===0?R=.5/t:g===i&&c===Math.PI&&(R=-.5/t);for(let x=0;x<=t;x++){const A=x/t,I=n+A*r;u.x=-w*Math.cos(I),u.y=E,u.z=w*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+R,1-y),b.push(l++)}h.push(b)}for(let g=0;g<i;g++)for(let b=0;b<t;b++){const y=h[g][b+1],_=h[g][b],E=h[g+1][b],w=h[g+1][b+1];(g!==0||a>0)&&f.push(y,_,w),(g!==i-1||c<Math.PI)&&f.push(_,E,w)}this.setIndex(f),this.setAttribute("position",new Pt(p,3)),this.setAttribute("normal",new Pt(v,3)),this.setAttribute("uv",new Pt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new di(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}function ea(s){const e={};for(const t in s){e[t]={};for(const i in s[t]){const n=s[t][i];if(J0(n))n.isRenderTargetTexture?(we("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(J0(n[0])){const r=[];for(let a=0,o=n.length;a<o;a++)r[a]=n[a].clone();e[t][i]=r}else e[t][i]=n.slice();else e[t][i]=n}}return e}function yi(s){const e={};for(let t=0;t<s.length;t++){const i=ea(s[t]);for(const n in i)e[n]=i[n]}return e}function J0(s){return s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)}function mv(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function Pm(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:et.workingColorSpace}const gv={clone:ea,merge:yi};var vv=`void main() {
|
|
632
632
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
633
633
|
}`,Mv=`void main() {
|
|
634
634
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
635
|
-
}`;class wt extends ts{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=vv,this.fragmentShader=Mv,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=ea(e.uniforms),this.uniformsGroups=mv(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 a=this.uniforms[n].value;a&&a.isTexture?t.uniforms[n]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[n]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[n]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[n]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[n]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[n]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[n]={type:"m4",value:a.toArray()}:t.uniforms[n]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const 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 oe().setHex(n.value);break;case"v2":this.uniforms[i].value=new Ae().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 He().fromArray(n.value);break;case"m4":this.uniforms[i].value=new Ye().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 Lm extends wt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class xv extends ts{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new oe(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 oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ec,this.normalScale=new Ae(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 jn,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 Ww extends xv{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 Ae(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 oe(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 oe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new oe(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 eo extends ts{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ec,this.normalScale=new Ae(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new jn,this.combine=$u,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 _v extends ts{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=h2,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 yv extends ts{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 Ho(s,e){return!s||s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function Sv(s){function e(n,r){return s[n]-s[r]}const t=s.length,i=new Array(t);for(let n=0;n!==t;++n)i[n]=n;return i.sort(e),i}function j0(s,e,t){const i=s.length,n=new s.constructor(i);for(let r=0,a=0;a!==i;++r){const o=t[r]*e;for(let c=0;c!==e;++c)n[a++]=s[o+c]}return n}function bv(s,e,t,i){let n=1,r=s[0];for(;r!==void 0&&r[i]===void 0;)r=s[n++];if(r===void 0)return;let a=r[i];if(a!==void 0)if(Array.isArray(a))do a=r[i],a!==void 0&&(e.push(r.time),t.push(...a)),r=s[n++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[i],a!==void 0&&(e.push(r.time),a.toArray(t,t.length)),r=s[n++];while(r!==void 0);else do a=r[i],a!==void 0&&(e.push(r.time),t.push(a)),r=s[n++];while(r!==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],r=t[i-1];i:{e:{let a;t:{n:if(!(e<n)){for(let o=i+2;;){if(n===void 0){if(e<r)break n;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(r=n,n=t[++i],e<n)break e}a=t.length;break t}if(!(e>=r)){const o=t[1];e<o&&(i=2,r=o);for(let c=i-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===c)break;if(n=r,r=t[--i-1],e>=r)break e}a=i,i=0;break t}break i}for(;i<a;){const o=i+a>>>1;e<t[o]?a=o:i=o+1}if(n=t[i],r=t[i-1],r===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,r,n)}return this.interpolate_(i,r,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n;for(let a=0;a!==n;++a)t[a]=i[r+a];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class wv 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:m0,endingEnd:m0}}intervalChanged_(e,t,i){const n=this.parameterPositions;let r=e-2,a=e+1,o=n[r],c=n[a];if(o===void 0)switch(this.getSettings_().endingStart){case g0:r=e,o=2*t-i;break;case v0:r=n.length-2,o=t+n[r]-n[r+1];break;default:r=e,o=i}if(c===void 0)switch(this.getSettings_().endingEnd){case g0:a=e,c=2*i-t;break;case v0:a=1,c=i+n[1]-n[0];break;default:a=e-1,c=t}const l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(c-i),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(e,t,i,n){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(i-t)/(n-t),v=p*p,m=v*p,g=-d*m+2*d*v-d*p,b=(1+d)*m+(-1.5-2*d)*v+(-.5+d)*p+1,y=(-1-f)*m+(1.5+f)*v+.5*p,_=f*m-f*v;for(let w=0;w!==o;++w)r[w]=g*a[h+w]+b*a[l+w]+y*a[c+w]+_*a[u+w];return r}}class Ev extends to{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,a=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)r[d]=a[l+d]*u+a[c+d]*h;return r}}class Av extends to{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class Tv extends to{interpolate_(e,t,i,n){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this.inTangents,u=this.outTangents;if(!h||!u){const p=(i-t)/(n-t),v=1-p;for(let m=0;m!==o;++m)r[m]=a[l+m]*v+a[c+m]*p;return r}const d=o*2,f=e-1;for(let p=0;p!==o;++p){const v=a[l+p],m=a[c+p],g=f*d+p*2,b=u[g],y=u[g+1],_=e*d+p*2,w=h[_],E=h[_+1];let R=(i-t)/(n-t),x,A,I,C,P;for(let X=0;X<8;X++){x=R*R,A=x*R,I=1-R,C=I*I,P=C*I;const N=P*t+3*C*R*b+3*I*x*w+A*n-i;if(Math.abs(N)<1e-10)break;const V=3*C*(b-t)+6*I*R*(w-b)+3*x*(n-w);if(Math.abs(V)<1e-10)break;R=R-N/V,R=Math.max(0,Math.min(1,R))}r[p]=P*v+3*C*R*y+3*I*x*E+A*m}return r}}class fn{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=Ho(t,this.TimeBufferType),this.values=Ho(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:Ho(e.times,Array),values:Ho(e.values,Array)};const n=e.getInterpolation();n!==e.DefaultInterpolation&&(i.interpolation=n)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new Av(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Ev(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new wv(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){const t=new Tv(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 wc:t=this.InterpolantFactoryMethodDiscrete;break;case cu:t=this.InterpolantFactoryMethodLinear;break;case ll:t=this.InterpolantFactoryMethodSmooth;break;case p0: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 Ee("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return wc;case this.InterpolantFactoryMethodLinear:return cu;case this.InterpolantFactoryMethodSmooth:return ll;case this.InterpolantFactoryMethodBezier:return p0}}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 r=0,a=n-1;for(;r!==n&&i[r]<e;)++r;for(;a!==-1&&i[a]>t;)--a;if(++a,r!==0||a!==n){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=i.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(ke("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,n=this.values,r=i.length;r===0&&(ke("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){const c=i[o];if(typeof c=="number"&&isNaN(c)){ke("KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(a!==null&&a>c){ke("KeyframeTrack: Out of order keys.",this,o,c,a),e=!1;break}a=c}if(n!==void 0&&x2(n))for(let o=0,c=n.length;o!==c;++o){const l=n[o];if(isNaN(l)){ke("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()===ll,r=e.length-1;let a=1;for(let o=1;o<r;++o){let c=!1;const l=e[o],h=e[o+1];if(l!==h&&(o!==1||l!==e[0]))if(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!==a){e[a]=e[o];const u=o*i,d=a*i;for(let f=0;f!==i;++f)t[d+f]=t[u+f]}++a}}if(r>0){e[a]=e[r];for(let o=r*i,c=a*i,l=0;l!==i;++l)t[c+l]=t[o+l];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*i)):(this.times=e,this.values=t),this}clone(){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}}fn.prototype.ValueTypeName="";fn.prototype.TimeBufferType=Float32Array;fn.prototype.ValueBufferType=Float32Array;fn.prototype.DefaultInterpolation=cu;class ia extends fn{constructor(e,t,i){super(e,t,i)}}ia.prototype.ValueTypeName="bool";ia.prototype.ValueBufferType=Array;ia.prototype.DefaultInterpolation=wc;ia.prototype.InterpolantFactoryMethodLinear=void 0;ia.prototype.InterpolantFactoryMethodSmooth=void 0;class Nm extends fn{constructor(e,t,i,n){super(e,t,i,n)}}Nm.prototype.ValueTypeName="color";class ud extends fn{constructor(e,t,i,n){super(e,t,i,n)}}ud.prototype.ValueTypeName="number";class Rv extends to{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,a=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(r,0,a,l-o,a,l,c);return r}}class dd extends fn{constructor(e,t,i,n){super(e,t,i,n)}InterpolantFactoryMethodLinear(e){return new Rv(this.times,this.values,this.getValueSize(),e)}}dd.prototype.ValueTypeName="quaternion";dd.prototype.InterpolantFactoryMethodSmooth=void 0;class na extends fn{constructor(e,t,i){super(e,t,i)}}na.prototype.ValueTypeName="string";na.prototype.ValueBufferType=Array;na.prototype.DefaultInterpolation=wc;na.prototype.InterpolantFactoryMethodLinear=void 0;na.prototype.InterpolantFactoryMethodSmooth=void 0;class Om extends fn{constructor(e,t,i,n){super(e,t,i,n)}}Om.prototype.ValueTypeName="vector";class Xw{constructor(e="",t=-1,i=[],n=l2){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=ln(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,n=1/(e.fps||1);for(let a=0,o=i.length;a!==o;++a)t.push(Cv(i[a]).scale(n));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){const t=[],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 r=0,a=i.length;r!==a;++r)t.push(fn.toJSON(i[r]));return n}static CreateFromMorphTargetSequence(e,t,i,n){const r=t.length,a=[];for(let o=0;o<r;o++){let c=[],l=[];c.push((o+r-1)%r,o,(o+1)%r),l.push(0,1,0);const h=Sv(c);c=j0(c,1,h),l=j0(l,1,h),!n&&c[0]===0&&(c.push(r),l.push(l[0])),a.push(new ud(".morphTargetInfluences["+t[o].name+"]",c,l).scale(1/i))}return new this(e,-1,a)}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={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,c=e.length;o<c;o++){const l=e[o],h=l.name.match(r);if(h&&h.length>1){const u=h[1];let d=n[u];d||(n[u]=d=[]),d.push(l)}}const a=[];for(const o in n)a.push(this.CreateFromMorphTargetSequence(o,n[o],t,i));return a}resetDuration(){const e=this.tracks;let t=0;for(let i=0,n=e.length;i!==n;++i){const r=this.tracks[i];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let 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 Dv(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ud;case"vector":case"vector2":case"vector3":case"vector4":return Om;case"color":return Nm;case"quaternion":return dd;case"bool":case"boolean":return ia;case"string":return na}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function Cv(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=Dv(s.type);if(s.times===void 0){const t=[],i=[];bv(s.keys,t,i,"value"),s.times=t,s.values=i}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const Kn={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(Q0(s)||(this.files[s]=e))},get:function(s){if(this.enabled!==!1&&!Q0(s))return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};function Q0(s){try{const e=s.slice(s.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}class Iv{constructor(e,t,i){const n=this;let r=!1,a=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++,r===!1&&n.onStart!==void 0&&n.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,n.onProgress!==void 0&&n.onProgress(h,a,o),a===o&&(r=!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 Pv=new Iv;class io{constructor(e){this.manager=e!==void 0?e:Pv,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,r){i.load(e,n,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}io.DEFAULT_MATERIAL_NAME="__DEFAULT";const zn={};class Lv extends Error{constructor(e,t){super(e),this.response=t}}class qw extends io{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 r=Kn.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0);return}if(zn[e]!==void 0){zn[e].push({onLoad:t,onProgress:i,onError:n});return}zn[e]=[],zn[e].push({onLoad:t,onProgress:i,onError:n});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,c=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&Ee("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const h=zn[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){b();function b(){u.read().then(({done:y,value:_})=>{if(y)g.close();else{v+=_.byteLength;const w=new ProgressEvent("progress",{lengthComputable:p,loaded:v,total:f});for(let E=0,R=h.length;E<R;E++){const x=h[E];x.onProgress&&x.onProgress(w)}g.enqueue(_),b()}},y=>{g.error(y)})}}});return new Response(m)}else throw new Lv(`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=>{Kn.add(`file:${e}`,l);const h=zn[e];delete zn[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(l)}}).catch(l=>{const h=zn[e];if(h===void 0)throw this.manager.itemError(e),l;delete zn[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 wr=new WeakMap;class Nv extends io{constructor(e){super(e)}load(e,t,i,n){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Kn.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)r.manager.itemStart(e),setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);else{let u=wr.get(a);u===void 0&&(u=[],wr.set(a,u)),u.push({onLoad:t,onError:n})}return a}const o=Za("img");function c(){h(),t&&t(this);const u=wr.get(this)||[];for(let d=0;d<u.length;d++){const f=u[d];f.onLoad&&f.onLoad(this)}wr.delete(this),r.manager.itemEnd(e)}function l(u){h(),n&&n(u),Kn.remove(`image:${e}`);const d=wr.get(this)||[];for(let f=0;f<d.length;f++){const p=d[f];p.onError&&p.onError(u)}wr.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function h(){o.removeEventListener("load",c,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),Kn.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class Yw extends io{constructor(e){super(e)}load(e,t,i,n){const r=new oi,a=new Nv(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){r.image=o,r.needsUpdate=!0,t!==void 0&&t(r)},i,n),r}}class Yc extends At{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new oe(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 Ov extends Yc{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(At.DEFAULT_UP),this.updateMatrix(),this.groundColor=new oe(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 Ul=new Ye,ef=new D,tf=new D;class fd{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 Ae(512,512),this.mapType=Bi,this.map=null,this.mapPass=null,this.matrix=new Ye,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new cd,this._frameExtents=new Ae(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;ef.setFromMatrixPosition(e.matrixWorld),t.position.copy(ef),tf.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(tf),t.updateMatrixWorld(),Ul.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ul,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===$a||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(Ul)}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 Go=new D,Vo=new Qn,Mn=new D;class Um extends At{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ye,this.projectionMatrix=new Ye,this.projectionMatrixInverse=new Ye,this.coordinateSystem=Rn,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(Go,Vo,Mn),Mn.x===1&&Mn.y===1&&Mn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Go,Vo,Mn.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(Go,Vo,Mn),Mn.x===1&&Mn.y===1&&Mn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Go,Vo,Mn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const us=new D,nf=new Ae,sf=new Ae;class Li extends Um{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=jr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Oa*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return jr*2*Math.atan(Math.tan(Oa*.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){us.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(us.x,us.y).multiplyScalar(-e/us.z),us.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(us.x,us.y).multiplyScalar(-e/us.z)}getViewSize(e,t){return this.getViewBounds(e,nf,sf),t.subVectors(sf,nf)}setViewOffset(e,t,i,n,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Oa*.5*this.fov)/this.zoom,i=2*t,n=this.aspect*i,r=-.5*n;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*n/c,t-=a.offsetY*i/l,n*=a.width/c,i*=a.height/l}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+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 Uv extends fd{constructor(){super(new Li(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,i=jr*2*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;(i!==t.fov||n!==t.aspect||r!==t.far)&&(t.fov=i,t.aspect=n,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Kw extends Yc{constructor(e,t,i=0,n=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(At.DEFAULT_UP),this.updateMatrix(),this.target=new At,this.distance=i,this.angle=n,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new Uv}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 Fv extends fd{constructor(){super(new Li(90,1,.5,500)),this.isPointLightShadow=!0}}class kv extends Yc{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 Fv}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 Ts extends Um{constructor(e=-1,t=1,i=1,n=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,n,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-e,a=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;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class zv extends fd{constructor(){super(new Ts(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class rf extends Yc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(At.DEFAULT_UP),this.updateMatrix(),this.target=new At,this.shadow=new zv}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 $w{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 Fl=new WeakMap;class Zw extends io{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&Ee("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Ee("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 r=this,a=Kn.get(`image-bitmap:${e}`);if(a!==void 0){if(r.manager.itemStart(e),a.then){a.then(l=>{Fl.has(a)===!0?(n&&n(Fl.get(a)),r.manager.itemError(e),r.manager.itemEnd(e)):(t&&t(l),r.manager.itemEnd(e))});return}setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);return}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const c=fetch(e,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){Kn.add(`image-bitmap:${e}`,l),t&&t(l),r.manager.itemEnd(e)}).catch(function(l){n&&n(l),Fl.set(c,l),Kn.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});Kn.add(`image-bitmap:${e}`,c),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const Er=-90,Ar=1;class Fm extends At{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new Li(Er,Ar,e,t);n.layers=this.layers,this.add(n);const r=new Li(Er,Ar,e,t);r.layers=this.layers,this.add(r);const a=new Li(Er,Ar,e,t);a.layers=this.layers,this.add(a);const o=new Li(Er,Ar,e,t);o.layers=this.layers,this.add(o);const c=new Li(Er,Ar,e,t);c.layers=this.layers,this.add(c);const l=new Li(Er,Ar,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,n,r,a,o,c]=t;for(const l of t)this.remove(l);if(e===Rn)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===$a)i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:n}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,c,l,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),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,r),e.setRenderTarget(i,1,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),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 Bv extends Li{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const pd="\\[\\]\\.:\\/",Hv=new RegExp("["+pd+"]","g"),md="[^"+pd+"]",Gv="[^"+pd.replace("\\.","")+"]",Vv=/((?:WC+[\/:])*)/.source.replace("WC",md),Wv=/(WCOD+)?/.source.replace("WCOD",Gv),Xv=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",md),qv=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",md),Yv=new RegExp("^"+Vv+Wv+Xv+qv+"$"),Kv=["material","materials","bones","map"];class $v{constructor(e,t,i){const n=i||mt.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_,r=i.length;n!==r;++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 mt{constructor(e,t,i){this.path=t,this.parsedPath=i||mt.parseTrackName(t),this.node=mt.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 mt.Composite(e,t,i):new mt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Hv,"")}static parseTrackName(e){const t=Yv.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 r=i.nodeName.substring(n+1);Kv.indexOf(r)!==-1&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=r)}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(r){for(let a=0;a<r.length;a++){const o=r[a];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,r=i.length;n!==r;++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,r=i.length;n!==r;++n)i[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++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 r=t.propertyIndex;if(e||(e=mt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ee("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){ke("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){ke("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){ke("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){ke("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){ke("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){ke("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){ke("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}const a=e[n];if(a===void 0){const l=t.nodeName;ke("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(r!==void 0){if(n==="morphTargetInfluences"){if(!e.geometry){ke("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){ke("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(c=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=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}}mt.Composite=$v;mt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};mt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};mt.prototype.GetterByBindingType=[mt.prototype._getValue_direct,mt.prototype._getValue_array,mt.prototype._getValue_arrayElement,mt.prototype._getValue_toArray];mt.prototype.SetterByBindingTypeAndVersioning=[[mt.prototype._setValue_direct,mt.prototype._setValue_direct_setNeedsUpdate,mt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[mt.prototype._setValue_array,mt.prototype._setValue_array_setNeedsUpdate,mt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[mt.prototype._setValue_arrayElement,mt.prototype._setValue_arrayElement_setNeedsUpdate,mt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[mt.prototype._setValue_fromArray,mt.prototype._setValue_fromArray_setNeedsUpdate,mt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const af=new Ye;class kl{constructor(e,t,i=0,n=1/0){this.ray=new ja(e,t),this.near=i,this.far=n,this.camera=null,this.layers=new ad,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):ke("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return af.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(af),this}intersectObject(e,t=!0,i=[]){return uu(e,this,i,t),i.sort(of),i}intersectObjects(e,t=!0,i=[]){for(let n=0,r=e.length;n<r;n++)uu(e[n],this,i,t);return i.sort(of),i}}function of(s,e){return s.distance-e.distance}function uu(s,e,t,i){let n=!0;if(s.layers.test(e.layers)&&s.raycast(e,t)===!1&&(n=!1),n===!0&&i===!0){const r=s.children;for(let a=0,o=r.length;a<o;a++)uu(r[a],e,t,!0)}}class km{static{km.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 r=this.elements;return r[0]=e,r[2]=t,r[1]=i,r[3]=n,this}}function cf(s,e,t,i){const n=Zv(i);switch(t){case _m:return s*e;case qc:return s*e/n.components*n.byteLength;case Qu:return s*e/n.components*n.byteLength;case Zs:return s*e*2/n.components*n.byteLength;case ed:return s*e*2/n.components*n.byteLength;case ym:return s*e*3/n.components*n.byteLength;case xi:return s*e*4/n.components*n.byteLength;case td:return s*e*4/n.components*n.byteLength;case hc:case uc:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case dc:case fc:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Lh:case Oh:return Math.max(s,16)*Math.max(e,8)/4;case Ph:case Nh:return Math.max(s,8)*Math.max(e,8)/2;case Uh:case Fh:case zh:case Bh:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case kh:case Sc:case Hh:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Gh:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Vh:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case Wh:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case Xh:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case qh:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case Yh:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case Kh:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case $h:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case Zh:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case Jh:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case jh:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case Qh:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case eu:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case tu:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case iu:case nu:case su:return Math.ceil(s/4)*Math.ceil(e/4)*16;case ru:case au:return Math.ceil(s/4)*Math.ceil(e/4)*8;case bc:case ou:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Zv(s){switch(s){case Bi:case gm:return{byteLength:1,components:1};case Ya:case vm:case $t:return{byteLength:2,components:1};case Ju:case ju:return{byteLength:2,components:4};case hn:case Zu:case Ai:return{byteLength:4,components:1};case Mm:case xm:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${s}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ku}}));typeof window<"u"&&(window.__THREE__?Ee("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ku);/**
|
|
635
|
+
}`;class Et extends ts{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=vv,this.fragmentShader=Mv,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=ea(e.uniforms),this.uniformsGroups=mv(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 a=this.uniforms[n].value;a&&a.isTexture?t.uniforms[n]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[n]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[n]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[n]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[n]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[n]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[n]={type:"m4",value:a.toArray()}:t.uniforms[n]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const 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 oe().setHex(n.value);break;case"v2":this.uniforms[i].value=new Ae().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 He().fromArray(n.value);break;case"m4":this.uniforms[i].value=new Ye().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 Lm extends Et{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class xv extends ts{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new oe(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 oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=wc,this.normalScale=new Ae(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 jn,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 WE extends xv{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 Ae(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 oe(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 oe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new oe(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 eo extends ts{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=wc,this.normalScale=new Ae(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new jn,this.combine=$u,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 _v extends ts{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=h2,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 yv extends ts{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 Ho(s,e){return!s||s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function Sv(s){function e(n,r){return s[n]-s[r]}const t=s.length,i=new Array(t);for(let n=0;n!==t;++n)i[n]=n;return i.sort(e),i}function j0(s,e,t){const i=s.length,n=new s.constructor(i);for(let r=0,a=0;a!==i;++r){const o=t[r]*e;for(let c=0;c!==e;++c)n[a++]=s[o+c]}return n}function bv(s,e,t,i){let n=1,r=s[0];for(;r!==void 0&&r[i]===void 0;)r=s[n++];if(r===void 0)return;let a=r[i];if(a!==void 0)if(Array.isArray(a))do a=r[i],a!==void 0&&(e.push(r.time),t.push(...a)),r=s[n++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[i],a!==void 0&&(e.push(r.time),a.toArray(t,t.length)),r=s[n++];while(r!==void 0);else do a=r[i],a!==void 0&&(e.push(r.time),t.push(a)),r=s[n++];while(r!==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],r=t[i-1];i:{e:{let a;t:{n:if(!(e<n)){for(let o=i+2;;){if(n===void 0){if(e<r)break n;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(r=n,n=t[++i],e<n)break e}a=t.length;break t}if(!(e>=r)){const o=t[1];e<o&&(i=2,r=o);for(let c=i-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===c)break;if(n=r,r=t[--i-1],e>=r)break e}a=i,i=0;break t}break i}for(;i<a;){const o=i+a>>>1;e<t[o]?a=o:i=o+1}if(n=t[i],r=t[i-1],r===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,r,n)}return this.interpolate_(i,r,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n;for(let a=0;a!==n;++a)t[a]=i[r+a];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class Ev 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:m0,endingEnd:m0}}intervalChanged_(e,t,i){const n=this.parameterPositions;let r=e-2,a=e+1,o=n[r],c=n[a];if(o===void 0)switch(this.getSettings_().endingStart){case g0:r=e,o=2*t-i;break;case v0:r=n.length-2,o=t+n[r]-n[r+1];break;default:r=e,o=i}if(c===void 0)switch(this.getSettings_().endingEnd){case g0:a=e,c=2*i-t;break;case v0:a=1,c=i+n[1]-n[0];break;default:a=e-1,c=t}const l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(c-i),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(e,t,i,n){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(i-t)/(n-t),v=p*p,m=v*p,g=-d*m+2*d*v-d*p,b=(1+d)*m+(-1.5-2*d)*v+(-.5+d)*p+1,y=(-1-f)*m+(1.5+f)*v+.5*p,_=f*m-f*v;for(let E=0;E!==o;++E)r[E]=g*a[h+E]+b*a[l+E]+y*a[c+E]+_*a[u+E];return r}}class wv extends to{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,a=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)r[d]=a[l+d]*u+a[c+d]*h;return r}}class Av extends to{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class Tv extends to{interpolate_(e,t,i,n){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this.inTangents,u=this.outTangents;if(!h||!u){const p=(i-t)/(n-t),v=1-p;for(let m=0;m!==o;++m)r[m]=a[l+m]*v+a[c+m]*p;return r}const d=o*2,f=e-1;for(let p=0;p!==o;++p){const v=a[l+p],m=a[c+p],g=f*d+p*2,b=u[g],y=u[g+1],_=e*d+p*2,E=h[_],w=h[_+1];let R=(i-t)/(n-t),x,A,I,C,P;for(let X=0;X<8;X++){x=R*R,A=x*R,I=1-R,C=I*I,P=C*I;const N=P*t+3*C*R*b+3*I*x*E+A*n-i;if(Math.abs(N)<1e-10)break;const V=3*C*(b-t)+6*I*R*(E-b)+3*x*(n-E);if(Math.abs(V)<1e-10)break;R=R-N/V,R=Math.max(0,Math.min(1,R))}r[p]=P*v+3*C*R*y+3*I*x*w+A*m}return r}}class fn{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=Ho(t,this.TimeBufferType),this.values=Ho(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:Ho(e.times,Array),values:Ho(e.values,Array)};const n=e.getInterpolation();n!==e.DefaultInterpolation&&(i.interpolation=n)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new Av(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new wv(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Ev(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){const t=new Tv(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 Ec:t=this.InterpolantFactoryMethodDiscrete;break;case cu:t=this.InterpolantFactoryMethodLinear;break;case ll:t=this.InterpolantFactoryMethodSmooth;break;case p0: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 we("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ec;case this.InterpolantFactoryMethodLinear:return cu;case this.InterpolantFactoryMethodSmooth:return ll;case this.InterpolantFactoryMethodBezier:return p0}}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 r=0,a=n-1;for(;r!==n&&i[r]<e;)++r;for(;a!==-1&&i[a]>t;)--a;if(++a,r!==0||a!==n){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=i.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(ke("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,n=this.values,r=i.length;r===0&&(ke("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){const c=i[o];if(typeof c=="number"&&isNaN(c)){ke("KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(a!==null&&a>c){ke("KeyframeTrack: Out of order keys.",this,o,c,a),e=!1;break}a=c}if(n!==void 0&&x2(n))for(let o=0,c=n.length;o!==c;++o){const l=n[o];if(isNaN(l)){ke("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()===ll,r=e.length-1;let a=1;for(let o=1;o<r;++o){let c=!1;const l=e[o],h=e[o+1];if(l!==h&&(o!==1||l!==e[0]))if(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!==a){e[a]=e[o];const u=o*i,d=a*i;for(let f=0;f!==i;++f)t[d+f]=t[u+f]}++a}}if(r>0){e[a]=e[r];for(let o=r*i,c=a*i,l=0;l!==i;++l)t[c+l]=t[o+l];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*i)):(this.times=e,this.values=t),this}clone(){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}}fn.prototype.ValueTypeName="";fn.prototype.TimeBufferType=Float32Array;fn.prototype.ValueBufferType=Float32Array;fn.prototype.DefaultInterpolation=cu;class ia extends fn{constructor(e,t,i){super(e,t,i)}}ia.prototype.ValueTypeName="bool";ia.prototype.ValueBufferType=Array;ia.prototype.DefaultInterpolation=Ec;ia.prototype.InterpolantFactoryMethodLinear=void 0;ia.prototype.InterpolantFactoryMethodSmooth=void 0;class Nm extends fn{constructor(e,t,i,n){super(e,t,i,n)}}Nm.prototype.ValueTypeName="color";class ud extends fn{constructor(e,t,i,n){super(e,t,i,n)}}ud.prototype.ValueTypeName="number";class Rv extends to{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,a=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(r,0,a,l-o,a,l,c);return r}}class dd extends fn{constructor(e,t,i,n){super(e,t,i,n)}InterpolantFactoryMethodLinear(e){return new Rv(this.times,this.values,this.getValueSize(),e)}}dd.prototype.ValueTypeName="quaternion";dd.prototype.InterpolantFactoryMethodSmooth=void 0;class na extends fn{constructor(e,t,i){super(e,t,i)}}na.prototype.ValueTypeName="string";na.prototype.ValueBufferType=Array;na.prototype.DefaultInterpolation=Ec;na.prototype.InterpolantFactoryMethodLinear=void 0;na.prototype.InterpolantFactoryMethodSmooth=void 0;class Om extends fn{constructor(e,t,i,n){super(e,t,i,n)}}Om.prototype.ValueTypeName="vector";class XE{constructor(e="",t=-1,i=[],n=l2){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=ln(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,n=1/(e.fps||1);for(let a=0,o=i.length;a!==o;++a)t.push(Cv(i[a]).scale(n));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){const t=[],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 r=0,a=i.length;r!==a;++r)t.push(fn.toJSON(i[r]));return n}static CreateFromMorphTargetSequence(e,t,i,n){const r=t.length,a=[];for(let o=0;o<r;o++){let c=[],l=[];c.push((o+r-1)%r,o,(o+1)%r),l.push(0,1,0);const h=Sv(c);c=j0(c,1,h),l=j0(l,1,h),!n&&c[0]===0&&(c.push(r),l.push(l[0])),a.push(new ud(".morphTargetInfluences["+t[o].name+"]",c,l).scale(1/i))}return new this(e,-1,a)}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={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,c=e.length;o<c;o++){const l=e[o],h=l.name.match(r);if(h&&h.length>1){const u=h[1];let d=n[u];d||(n[u]=d=[]),d.push(l)}}const a=[];for(const o in n)a.push(this.CreateFromMorphTargetSequence(o,n[o],t,i));return a}resetDuration(){const e=this.tracks;let t=0;for(let i=0,n=e.length;i!==n;++i){const r=this.tracks[i];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let 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 Dv(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ud;case"vector":case"vector2":case"vector3":case"vector4":return Om;case"color":return Nm;case"quaternion":return dd;case"bool":case"boolean":return ia;case"string":return na}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function Cv(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=Dv(s.type);if(s.times===void 0){const t=[],i=[];bv(s.keys,t,i,"value"),s.times=t,s.values=i}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const Kn={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(Q0(s)||(this.files[s]=e))},get:function(s){if(this.enabled!==!1&&!Q0(s))return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};function Q0(s){try{const e=s.slice(s.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}class Iv{constructor(e,t,i){const n=this;let r=!1,a=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++,r===!1&&n.onStart!==void 0&&n.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,n.onProgress!==void 0&&n.onProgress(h,a,o),a===o&&(r=!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 Pv=new Iv;class io{constructor(e){this.manager=e!==void 0?e:Pv,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,r){i.load(e,n,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}io.DEFAULT_MATERIAL_NAME="__DEFAULT";const zn={};class Lv extends Error{constructor(e,t){super(e),this.response=t}}class qE extends io{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 r=Kn.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0);return}if(zn[e]!==void 0){zn[e].push({onLoad:t,onProgress:i,onError:n});return}zn[e]=[],zn[e].push({onLoad:t,onProgress:i,onError:n});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,c=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&we("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const h=zn[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){b();function b(){u.read().then(({done:y,value:_})=>{if(y)g.close();else{v+=_.byteLength;const E=new ProgressEvent("progress",{lengthComputable:p,loaded:v,total:f});for(let w=0,R=h.length;w<R;w++){const x=h[w];x.onProgress&&x.onProgress(E)}g.enqueue(_),b()}},y=>{g.error(y)})}}});return new Response(m)}else throw new Lv(`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=>{Kn.add(`file:${e}`,l);const h=zn[e];delete zn[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(l)}}).catch(l=>{const h=zn[e];if(h===void 0)throw this.manager.itemError(e),l;delete zn[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 Er=new WeakMap;class Nv extends io{constructor(e){super(e)}load(e,t,i,n){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Kn.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)r.manager.itemStart(e),setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);else{let u=Er.get(a);u===void 0&&(u=[],Er.set(a,u)),u.push({onLoad:t,onError:n})}return a}const o=Za("img");function c(){h(),t&&t(this);const u=Er.get(this)||[];for(let d=0;d<u.length;d++){const f=u[d];f.onLoad&&f.onLoad(this)}Er.delete(this),r.manager.itemEnd(e)}function l(u){h(),n&&n(u),Kn.remove(`image:${e}`);const d=Er.get(this)||[];for(let f=0;f<d.length;f++){const p=d[f];p.onError&&p.onError(u)}Er.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function h(){o.removeEventListener("load",c,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),Kn.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class YE extends io{constructor(e){super(e)}load(e,t,i,n){const r=new oi,a=new Nv(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){r.image=o,r.needsUpdate=!0,t!==void 0&&t(r)},i,n),r}}class Yc extends At{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new oe(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 Ov extends Yc{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(At.DEFAULT_UP),this.updateMatrix(),this.groundColor=new oe(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 Ul=new Ye,ef=new D,tf=new D;class fd{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 Ae(512,512),this.mapType=Hi,this.map=null,this.mapPass=null,this.matrix=new Ye,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new cd,this._frameExtents=new Ae(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;ef.setFromMatrixPosition(e.matrixWorld),t.position.copy(ef),tf.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(tf),t.updateMatrixWorld(),Ul.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ul,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===$a||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(Ul)}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 Go=new D,Vo=new Qn,Mn=new D;class Um extends At{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ye,this.projectionMatrix=new Ye,this.projectionMatrixInverse=new Ye,this.coordinateSystem=Rn,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(Go,Vo,Mn),Mn.x===1&&Mn.y===1&&Mn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Go,Vo,Mn.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(Go,Vo,Mn),Mn.x===1&&Mn.y===1&&Mn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Go,Vo,Mn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const us=new D,nf=new Ae,sf=new Ae;class Ni extends Um{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=jr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Oa*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return jr*2*Math.atan(Math.tan(Oa*.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){us.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(us.x,us.y).multiplyScalar(-e/us.z),us.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(us.x,us.y).multiplyScalar(-e/us.z)}getViewSize(e,t){return this.getViewBounds(e,nf,sf),t.subVectors(sf,nf)}setViewOffset(e,t,i,n,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Oa*.5*this.fov)/this.zoom,i=2*t,n=this.aspect*i,r=-.5*n;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*n/c,t-=a.offsetY*i/l,n*=a.width/c,i*=a.height/l}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+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 Uv extends fd{constructor(){super(new Ni(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,i=jr*2*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;(i!==t.fov||n!==t.aspect||r!==t.far)&&(t.fov=i,t.aspect=n,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class KE extends Yc{constructor(e,t,i=0,n=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(At.DEFAULT_UP),this.updateMatrix(),this.target=new At,this.distance=i,this.angle=n,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new Uv}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 Fv extends fd{constructor(){super(new Ni(90,1,.5,500)),this.isPointLightShadow=!0}}class kv extends Yc{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 Fv}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 Ts extends Um{constructor(e=-1,t=1,i=1,n=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,n,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-e,a=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;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class zv extends fd{constructor(){super(new Ts(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class rf extends Yc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(At.DEFAULT_UP),this.updateMatrix(),this.target=new At,this.shadow=new zv}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 $E{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 Fl=new WeakMap;class ZE extends io{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&we("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&we("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 r=this,a=Kn.get(`image-bitmap:${e}`);if(a!==void 0){if(r.manager.itemStart(e),a.then){a.then(l=>{Fl.has(a)===!0?(n&&n(Fl.get(a)),r.manager.itemError(e),r.manager.itemEnd(e)):(t&&t(l),r.manager.itemEnd(e))});return}setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);return}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const c=fetch(e,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){Kn.add(`image-bitmap:${e}`,l),t&&t(l),r.manager.itemEnd(e)}).catch(function(l){n&&n(l),Fl.set(c,l),Kn.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});Kn.add(`image-bitmap:${e}`,c),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const wr=-90,Ar=1;class Fm extends At{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new Ni(wr,Ar,e,t);n.layers=this.layers,this.add(n);const r=new Ni(wr,Ar,e,t);r.layers=this.layers,this.add(r);const a=new Ni(wr,Ar,e,t);a.layers=this.layers,this.add(a);const o=new Ni(wr,Ar,e,t);o.layers=this.layers,this.add(o);const c=new Ni(wr,Ar,e,t);c.layers=this.layers,this.add(c);const l=new Ni(wr,Ar,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,n,r,a,o,c]=t;for(const l of t)this.remove(l);if(e===Rn)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===$a)i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:n}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,c,l,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),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,r),e.setRenderTarget(i,1,n),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),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 Bv extends Ni{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const pd="\\[\\]\\.:\\/",Hv=new RegExp("["+pd+"]","g"),md="[^"+pd+"]",Gv="[^"+pd.replace("\\.","")+"]",Vv=/((?:WC+[\/:])*)/.source.replace("WC",md),Wv=/(WCOD+)?/.source.replace("WCOD",Gv),Xv=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",md),qv=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",md),Yv=new RegExp("^"+Vv+Wv+Xv+qv+"$"),Kv=["material","materials","bones","map"];class $v{constructor(e,t,i){const n=i||mt.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_,r=i.length;n!==r;++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 mt{constructor(e,t,i){this.path=t,this.parsedPath=i||mt.parseTrackName(t),this.node=mt.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 mt.Composite(e,t,i):new mt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Hv,"")}static parseTrackName(e){const t=Yv.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 r=i.nodeName.substring(n+1);Kv.indexOf(r)!==-1&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=r)}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(r){for(let a=0;a<r.length;a++){const o=r[a];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,r=i.length;n!==r;++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,r=i.length;n!==r;++n)i[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++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 r=t.propertyIndex;if(e||(e=mt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){we("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){ke("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){ke("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){ke("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){ke("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){ke("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){ke("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){ke("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}const a=e[n];if(a===void 0){const l=t.nodeName;ke("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(r!==void 0){if(n==="morphTargetInfluences"){if(!e.geometry){ke("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){ke("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(c=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=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}}mt.Composite=$v;mt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};mt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};mt.prototype.GetterByBindingType=[mt.prototype._getValue_direct,mt.prototype._getValue_array,mt.prototype._getValue_arrayElement,mt.prototype._getValue_toArray];mt.prototype.SetterByBindingTypeAndVersioning=[[mt.prototype._setValue_direct,mt.prototype._setValue_direct_setNeedsUpdate,mt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[mt.prototype._setValue_array,mt.prototype._setValue_array_setNeedsUpdate,mt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[mt.prototype._setValue_arrayElement,mt.prototype._setValue_arrayElement_setNeedsUpdate,mt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[mt.prototype._setValue_fromArray,mt.prototype._setValue_fromArray_setNeedsUpdate,mt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const af=new Ye;class kl{constructor(e,t,i=0,n=1/0){this.ray=new ja(e,t),this.near=i,this.far=n,this.camera=null,this.layers=new ad,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):ke("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return af.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(af),this}intersectObject(e,t=!0,i=[]){return uu(e,this,i,t),i.sort(of),i}intersectObjects(e,t=!0,i=[]){for(let n=0,r=e.length;n<r;n++)uu(e[n],this,i,t);return i.sort(of),i}}function of(s,e){return s.distance-e.distance}function uu(s,e,t,i){let n=!0;if(s.layers.test(e.layers)&&s.raycast(e,t)===!1&&(n=!1),n===!0&&i===!0){const r=s.children;for(let a=0,o=r.length;a<o;a++)uu(r[a],e,t,!0)}}class km{static{km.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 r=this.elements;return r[0]=e,r[2]=t,r[1]=i,r[3]=n,this}}function cf(s,e,t,i){const n=Zv(i);switch(t){case _m:return s*e;case qc:return s*e/n.components*n.byteLength;case Qu:return s*e/n.components*n.byteLength;case Zs:return s*e*2/n.components*n.byteLength;case ed:return s*e*2/n.components*n.byteLength;case ym:return s*e*3/n.components*n.byteLength;case xi:return s*e*4/n.components*n.byteLength;case td:return s*e*4/n.components*n.byteLength;case hc:case uc:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case dc:case fc:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Lh:case Oh:return Math.max(s,16)*Math.max(e,8)/4;case Ph:case Nh:return Math.max(s,8)*Math.max(e,8)/2;case Uh:case Fh:case zh:case Bh:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case kh:case Sc:case Hh:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Gh:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Vh:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case Wh:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case Xh:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case qh:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case Yh:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case Kh:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case $h:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case Zh:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case Jh:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case jh:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case Qh:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case eu:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case tu:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case iu:case nu:case su:return Math.ceil(s/4)*Math.ceil(e/4)*16;case ru:case au:return Math.ceil(s/4)*Math.ceil(e/4)*8;case bc:case ou:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Zv(s){switch(s){case Hi:case gm:return{byteLength:1,components:1};case Ya:case vm:case $t:return{byteLength:2,components:1};case Ju:case ju:return{byteLength:2,components:4};case hn:case Zu:case Ti:return{byteLength:4,components:1};case Mm:case xm:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${s}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ku}}));typeof window<"u"&&(window.__THREE__?we("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ku);/**
|
|
636
636
|
* @license
|
|
637
637
|
* Copyright 2010-2026 Three.js Authors
|
|
638
638
|
* SPDX-License-Identifier: MIT
|
|
@@ -1104,11 +1104,11 @@ transformedNormal = normalMatrix * transformedNormal;
|
|
|
1104
1104
|
#endif
|
|
1105
1105
|
#ifdef USE_TANGENT
|
|
1106
1106
|
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
|
1107
|
-
#endif`,
|
|
1107
|
+
#endif`,EM=`#ifdef USE_DISPLACEMENTMAP
|
|
1108
1108
|
uniform sampler2D displacementMap;
|
|
1109
1109
|
uniform float displacementScale;
|
|
1110
1110
|
uniform float displacementBias;
|
|
1111
|
-
#endif`,
|
|
1111
|
+
#endif`,wM=`#ifdef USE_DISPLACEMENTMAP
|
|
1112
1112
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
1113
1113
|
#endif`,AM=`#ifdef USE_EMISSIVEMAP
|
|
1114
1114
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
@@ -2278,7 +2278,7 @@ vec3 nonPerturbedNormal = normal;`,vx=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
2278
2278
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
2279
2279
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
2280
2280
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
2281
|
-
#endif`,
|
|
2281
|
+
#endif`,Ex=`#ifdef USE_CLEARCOATMAP
|
|
2282
2282
|
uniform sampler2D clearcoatMap;
|
|
2283
2283
|
#endif
|
|
2284
2284
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
@@ -2287,7 +2287,7 @@ vec3 nonPerturbedNormal = normal;`,vx=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
2287
2287
|
#endif
|
|
2288
2288
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
2289
2289
|
uniform sampler2D clearcoatRoughnessMap;
|
|
2290
|
-
#endif`,
|
|
2290
|
+
#endif`,wx=`#ifdef USE_IRIDESCENCEMAP
|
|
2291
2291
|
uniform sampler2D iridescenceMap;
|
|
2292
2292
|
#endif
|
|
2293
2293
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
@@ -4069,7 +4069,7 @@ void main() {
|
|
|
4069
4069
|
#include <fog_fragment>
|
|
4070
4070
|
#include <premultiplied_alpha_fragment>
|
|
4071
4071
|
#include <dithering_fragment>
|
|
4072
|
-
}`,
|
|
4072
|
+
}`,E3=`#define TOON
|
|
4073
4073
|
varying vec3 vViewPosition;
|
|
4074
4074
|
#include <common>
|
|
4075
4075
|
#include <batching_pars_vertex>
|
|
@@ -4106,7 +4106,7 @@ void main() {
|
|
|
4106
4106
|
#include <worldpos_vertex>
|
|
4107
4107
|
#include <shadowmap_vertex>
|
|
4108
4108
|
#include <fog_vertex>
|
|
4109
|
-
}`,
|
|
4109
|
+
}`,w3=`#define TOON
|
|
4110
4110
|
uniform vec3 diffuse;
|
|
4111
4111
|
uniform vec3 emissive;
|
|
4112
4112
|
uniform float opacity;
|
|
@@ -4302,7 +4302,7 @@ void main() {
|
|
|
4302
4302
|
#include <tonemapping_fragment>
|
|
4303
4303
|
#include <colorspace_fragment>
|
|
4304
4304
|
#include <fog_fragment>
|
|
4305
|
-
}`,Ke={alphahash_fragment:jv,alphahash_pars_fragment:Qv,alphamap_fragment:eM,alphamap_pars_fragment:tM,alphatest_fragment:iM,alphatest_pars_fragment:nM,aomap_fragment:sM,aomap_pars_fragment:rM,batching_pars_vertex:aM,batching_vertex:oM,begin_vertex:cM,beginnormal_vertex:lM,bsdfs:hM,iridescence_fragment:uM,bumpmap_pars_fragment:dM,clipping_planes_fragment:fM,clipping_planes_pars_fragment:pM,clipping_planes_pars_vertex:mM,clipping_planes_vertex:gM,color_fragment:vM,color_pars_fragment:MM,color_pars_vertex:xM,color_vertex:_M,common:yM,cube_uv_reflection_fragment:SM,defaultnormal_vertex:bM,displacementmap_pars_vertex:wM,displacementmap_vertex:EM,emissivemap_fragment:AM,emissivemap_pars_fragment:TM,colorspace_fragment:RM,colorspace_pars_fragment:DM,envmap_fragment:CM,envmap_common_pars_fragment:IM,envmap_pars_fragment:PM,envmap_pars_vertex:LM,envmap_physical_pars_fragment:WM,envmap_vertex:NM,fog_vertex:OM,fog_pars_vertex:UM,fog_fragment:FM,fog_pars_fragment:kM,gradientmap_pars_fragment:zM,lightmap_pars_fragment:BM,lights_lambert_fragment:HM,lights_lambert_pars_fragment:GM,lights_pars_begin:VM,lights_toon_fragment:XM,lights_toon_pars_fragment:qM,lights_phong_fragment:YM,lights_phong_pars_fragment:KM,lights_physical_fragment:$M,lights_physical_pars_fragment:ZM,lights_fragment_begin:JM,lights_fragment_maps:jM,lights_fragment_end:QM,lightprobes_pars_fragment:ex,logdepthbuf_fragment:tx,logdepthbuf_pars_fragment:ix,logdepthbuf_pars_vertex:nx,logdepthbuf_vertex:sx,map_fragment:rx,map_pars_fragment:ax,map_particle_fragment:ox,map_particle_pars_fragment:cx,metalnessmap_fragment:lx,metalnessmap_pars_fragment:hx,morphinstance_vertex:ux,morphcolor_vertex:dx,morphnormal_vertex:fx,morphtarget_pars_vertex:px,morphtarget_vertex:mx,normal_fragment_begin:gx,normal_fragment_maps:vx,normal_pars_fragment:Mx,normal_pars_vertex:xx,normal_vertex:_x,normalmap_pars_fragment:yx,clearcoat_normal_fragment_begin:Sx,clearcoat_normal_fragment_maps:bx,clearcoat_pars_fragment:wx,iridescence_pars_fragment:Ex,opaque_fragment:Ax,packing:Tx,premultiplied_alpha_fragment:Rx,project_vertex:Dx,dithering_fragment:Cx,dithering_pars_fragment:Ix,roughnessmap_fragment:Px,roughnessmap_pars_fragment:Lx,shadowmap_pars_fragment:Nx,shadowmap_pars_vertex:Ox,shadowmap_vertex:Ux,shadowmask_pars_fragment:Fx,skinbase_vertex:kx,skinning_pars_vertex:zx,skinning_vertex:Bx,skinnormal_vertex:Hx,specularmap_fragment:Gx,specularmap_pars_fragment:Vx,tonemapping_fragment:Wx,tonemapping_pars_fragment:Xx,transmission_fragment:qx,transmission_pars_fragment:Yx,uv_pars_fragment:Kx,uv_pars_vertex:$x,uv_vertex:Zx,worldpos_vertex:Jx,background_vert:jx,background_frag:Qx,backgroundCube_vert:e3,backgroundCube_frag:t3,cube_vert:i3,cube_frag:n3,depth_vert:s3,depth_frag:r3,distance_vert:a3,distance_frag:o3,equirect_vert:c3,equirect_frag:l3,linedashed_vert:h3,linedashed_frag:u3,meshbasic_vert:d3,meshbasic_frag:f3,meshlambert_vert:p3,meshlambert_frag:m3,meshmatcap_vert:g3,meshmatcap_frag:v3,meshnormal_vert:M3,meshnormal_frag:x3,meshphong_vert:_3,meshphong_frag:y3,meshphysical_vert:S3,meshphysical_frag:b3,meshtoon_vert:w3,meshtoon_frag:E3,points_vert:A3,points_frag:T3,shadow_vert:R3,shadow_frag:D3,sprite_vert:C3,sprite_frag:I3},pe={common:{diffuse:{value:new oe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new He},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new He}},envmap:{envMap:{value:null},envMapRotation:{value:new He},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new He}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new He}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new He},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new He},normalScale:{value:new Ae(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new He},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new He}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new He}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new He}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new oe(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 oe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0},uvTransform:{value:new He}},sprite:{diffuse:{value:new oe(16777215)},opacity:{value:1},center:{value:new Ae(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new He},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0}}},bn={basic:{uniforms:yi([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.fog]),vertexShader:Ke.meshbasic_vert,fragmentShader:Ke.meshbasic_frag},lambert:{uniforms:yi([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 oe(0)},envMapIntensity:{value:1}}]),vertexShader:Ke.meshlambert_vert,fragmentShader:Ke.meshlambert_frag},phong:{uniforms:yi([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 oe(0)},specular:{value:new oe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ke.meshphong_vert,fragmentShader:Ke.meshphong_frag},standard:{uniforms:yi([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 oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag},toon:{uniforms:yi([pe.common,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.gradientmap,pe.fog,pe.lights,{emissive:{value:new oe(0)}}]),vertexShader:Ke.meshtoon_vert,fragmentShader:Ke.meshtoon_frag},matcap:{uniforms:yi([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,{matcap:{value:null}}]),vertexShader:Ke.meshmatcap_vert,fragmentShader:Ke.meshmatcap_frag},points:{uniforms:yi([pe.points,pe.fog]),vertexShader:Ke.points_vert,fragmentShader:Ke.points_frag},dashed:{uniforms:yi([pe.common,pe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ke.linedashed_vert,fragmentShader:Ke.linedashed_frag},depth:{uniforms:yi([pe.common,pe.displacementmap]),vertexShader:Ke.depth_vert,fragmentShader:Ke.depth_frag},normal:{uniforms:yi([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,{opacity:{value:1}}]),vertexShader:Ke.meshnormal_vert,fragmentShader:Ke.meshnormal_frag},sprite:{uniforms:yi([pe.sprite,pe.fog]),vertexShader:Ke.sprite_vert,fragmentShader:Ke.sprite_frag},background:{uniforms:{uvTransform:{value:new He},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ke.background_vert,fragmentShader:Ke.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new He}},vertexShader:Ke.backgroundCube_vert,fragmentShader:Ke.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ke.cube_vert,fragmentShader:Ke.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ke.equirect_vert,fragmentShader:Ke.equirect_frag},distance:{uniforms:yi([pe.common,pe.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ke.distance_vert,fragmentShader:Ke.distance_frag},shadow:{uniforms:yi([pe.lights,pe.fog,{color:{value:new oe(0)},opacity:{value:1}}]),vertexShader:Ke.shadow_vert,fragmentShader:Ke.shadow_frag}};bn.physical={uniforms:yi([bn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new He},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new He},clearcoatNormalScale:{value:new Ae(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new He},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new He},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new He},sheen:{value:0},sheenColor:{value:new oe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new He},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new He},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new He},transmissionSamplerSize:{value:new Ae},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new He},attenuationDistance:{value:0},attenuationColor:{value:new oe(0)},specularColor:{value:new oe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new He},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new He},anisotropyVector:{value:new Ae},anisotropyMap:{value:null},anisotropyMapTransform:{value:new He}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag};const Wo={r:0,b:0,g:0},P3=new Ye,Bm=new He;Bm.set(-1,0,0,0,1,0,0,0,1);function L3(s,e,t,i,n,r){const a=new oe(0);let o=n===!0?0:1,c,l,h=null,u=0,d=null;function f(b){let y=b.isScene===!0?b.background:null;if(y&&y.isTexture){const _=b.backgroundBlurriness>0;y=e.get(y,_)}return y}function p(b){let y=!1;const _=f(b);_===null?m(a,o):_&&_.isColor&&(m(_,1),y=!0);const w=s.xr.getEnvironmentBlendMode();w==="additive"?t.buffers.color.setClear(0,0,0,1,r):w==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(s.autoClear||y)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function v(b,y){const _=f(y);_&&(_.isCubeTexture||_.mapping===Xc)?(l===void 0&&(l=new We(new Ji(1,1,1),new wt({name:"BackgroundCubeMaterial",uniforms:ea(bn.backgroundCube.uniforms),vertexShader:bn.backgroundCube.vertexShader,fragmentShader:bn.backgroundCube.fragmentShader,side:It,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(w,E,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),l.material.uniforms.envMap.value=_,l.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(P3.makeRotationFromEuler(y.backgroundRotation)).transpose(),_.isCubeTexture&&_.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Bm),l.material.toneMapped=et.getTransfer(_.colorSpace)!==ut,(h!==_||u!==_.version||d!==s.toneMapping)&&(l.material.needsUpdate=!0,h=_,u=_.version,d=s.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null)):_&&_.isTexture&&(c===void 0&&(c=new We(new dn(2,2),new wt({name:"BackgroundMaterial",uniforms:ea(bn.background.uniforms),vertexShader:bn.background.vertexShader,fragmentShader:bn.background.fragmentShader,side:Es,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=_,c.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,c.material.toneMapped=et.getTransfer(_.colorSpace)!==ut,_.matrixAutoUpdate===!0&&_.updateMatrix(),c.material.uniforms.uvTransform.value.copy(_.matrix),(h!==_||u!==_.version||d!==s.toneMapping)&&(c.material.needsUpdate=!0,h=_,u=_.version,d=s.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null))}function m(b,y){b.getRGB(Wo,Pm(s)),t.buffers.color.setClear(Wo.r,Wo.g,Wo.b,y,r)}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 a},setClearColor:function(b,y=1){a.set(b),o=y,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(b){o=b,m(a,o)},render:p,addToRenderList:v,dispose:g}}function N3(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),i={},n=d(null);let r=n,a=!1;function o(C,P,X,z,N){let V=!1;const k=u(C,z,X,P);r!==k&&(r=k,l(r.object)),V=f(C,z,X,N),V&&p(C,z,X,N),N!==null&&e.update(N,s.ELEMENT_ARRAY_BUFFER),(V||a)&&(a=!1,_(C,P,X,z),N!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(N).buffer))}function c(){return s.createVertexArray()}function l(C){return s.bindVertexArray(C)}function h(C){return s.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=r.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 ae=V[ee];if(ae===void 0&&(ee==="instanceMatrix"&&C.instanceMatrix&&(ae=C.instanceMatrix),ee==="instanceColor"&&C.instanceColor&&(ae=C.instanceColor)),ie===void 0||ie.attribute!==ae||ae&&ie.data!==ae.data)return!0;k++}return r.attributesNum!==k||r.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 ae={};ae.attribute=ie,ie&&ie.data&&(ae.data=ie.data),N[ee]=ae,k++}r.attributes=N,r.attributesNum=k,r.index=z}function v(){const C=r.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=r.newAttributes,z=r.enabledAttributes,N=r.attributeDivisors;X[C]=1,z[C]===0&&(s.enableVertexAttribArray(C),z[C]=1),N[C]!==P&&(s.vertexAttribDivisor(C,P),N[C]=P)}function b(){const C=r.newAttributes,P=r.enabledAttributes;for(let X=0,z=P.length;X<z;X++)P[X]!==C[X]&&(s.disableVertexAttribArray(X),P[X]=0)}function y(C,P,X,z,N,V,k){k===!0?s.vertexAttribIPointer(C,P,X,N,V):s.vertexAttribPointer(C,P,X,z,N,V)}function _(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,ae=J.itemSize,Be=e.get(J);if(Be===void 0)continue;const je=Be.buffer,Ge=Be.type,Y=Be.bytesPerElement,re=Ge===s.INT||Ge===s.UNSIGNED_INT||J.gpuType===Zu;if(J.isInterleavedBufferAttribute){const ne=J.data,B=ne.stride,we=J.offset;if(ne.isInstancedInterleavedBuffer){for(let Pe=0;Pe<ee.locationSize;Pe++)g(ee.location+Pe,ne.meshPerAttribute);C.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let Pe=0;Pe<ee.locationSize;Pe++)m(ee.location+Pe);s.bindBuffer(s.ARRAY_BUFFER,je);for(let Pe=0;Pe<ee.locationSize;Pe++)y(ee.location+Pe,ae/ee.locationSize,Ge,ie,B*Y,(we+ae/ee.locationSize*Pe)*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);s.bindBuffer(s.ARRAY_BUFFER,je);for(let ne=0;ne<ee.locationSize;ne++)y(ee.location+ne,ae/ee.locationSize,Ge,ie,ae*Y,ae/ee.locationSize*ne*Y,re)}}else if(k!==void 0){const ie=k[K];if(ie!==void 0)switch(ie.length){case 2:s.vertexAttrib2fv(ee.location,ie);break;case 3:s.vertexAttrib3fv(ee.location,ie);break;case 4:s.vertexAttrib4fv(ee.location,ie);break;default:s.vertexAttrib1fv(ee.location,ie)}}}}b()}function w(){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 E(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 R(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(),a=!0,r!==n&&(r=n,l(r.object))}function I(){n.geometry=null,n.program=null,n.wireframe=!1}return{setup:o,reset:A,resetDefaultState:I,dispose:w,releaseStatesOfGeometry:E,releaseStatesOfObject:x,releaseStatesOfProgram:R,initAttributes:v,enableAttribute:m,disableUnusedAttributes:b}}function O3(s,e,t){let i;function n(c){i=c}function r(c,l){s.drawArrays(i,c,l),t.update(l,i,1)}function a(c,l,h){h!==0&&(s.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=r,this.renderInstances=a,this.renderMultiDraw=o}function U3(s,e,t,i){let n;function r(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const R=e.get("EXT_texture_filter_anisotropic");n=s.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function a(R){return!(R!==xi&&i.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const x=R===$t&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(R!==Bi&&i.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==Ai&&!x)}function c(R){if(R==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp";const h=c(l);h!==l&&(Ee("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&&Ee("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),p=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=s.getParameter(s.MAX_TEXTURE_SIZE),m=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),g=s.getParameter(s.MAX_VERTEX_ATTRIBS),b=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),y=s.getParameter(s.MAX_VARYING_VECTORS),_=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),w=s.getParameter(s.MAX_SAMPLES),E=s.getParameter(s.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:v,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:b,maxVaryings:y,maxFragmentUniforms:_,maxSamples:w,samples:E}}function F3(s){const e=this;let t=null,i=0,n=!1,r=!1;const a=new Os,o=new He,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(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){t=h(u,d,0)},this.setState=function(u,d,f){const p=u.clippingPlanes,v=u.clipIntersection,m=u.clipShadows,g=s.get(u);if(!n||p===null||p.length===0||r&&!m)r?h(null):l();else{const b=r?0:i,y=b*4;let _=g.clippingState||null;c.value=_,_=h(p,d,y,f);for(let w=0;w!==y;++w)_[w]=t[w];g.clippingState=_,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=b}};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,b=d.matrixWorldInverse;o.getNormalMatrix(b),(m===null||m.length<g)&&(m=new Float32Array(g));for(let y=0,_=f;y!==v;++y,_+=4)a.copy(u[y]).applyMatrix4(b,o),a.normal.toArray(m,_),m[_+3]=a.constant}c.value=m,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,m}}const ys=4,lf=[.125,.215,.35,.446,.526,.582],ks=20,k3=256,va=new Ts,hf=new oe;let zl=null,Bl=0,Hl=0,Gl=!1;const z3=new D;class uf{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,r={}){const{size:a=256,position:o=z3}=r;zl=this._renderer.getRenderTarget(),Bl=this._renderer.getActiveCubeFace(),Hl=this._renderer.getActiveMipmapLevel(),Gl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);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=pf(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ff(),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(zl,Bl,Hl),this._renderer.xr.enabled=Gl,e.scissorTest=!1,Tr(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===$s||e.mapping===Jr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),zl=this._renderer.getRenderTarget(),Bl=this._renderer.getActiveCubeFace(),Hl=this._renderer.getActiveMipmapLevel(),Gl=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:at,minFilter:at,generateMipmaps:!1,type:$t,format:xi,colorSpace:Ac,depthBuffer:!1},n=df(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=df(e,t,i);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=B3(r)),this._blurMaterial=G3(r,e,t),this._ggxMaterial=H3(r,e,t)}return n}_compileMaterial(e){const t=new We(new bt,e);this._renderer.compile(t,va)}_sceneToCubeUV(e,t,i,n,r){const c=new Li(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(hf),u.toneMapping=In,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(n),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new We(new Ji,new Zi({name:"PMREM.Background",side:It,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,m=v.material;let g=!1;const b=e.background;b?b.isColor&&(m.color.copy(b),e.background=null,g=!0):(m.color.copy(hf),g=!0);for(let y=0;y<6;y++){const _=y%3;_===0?(c.up.set(0,l[y],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+h[y],r.y,r.z)):_===1?(c.up.set(0,0,l[y]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+h[y],r.z)):(c.up.set(0,l[y],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+h[y]));const w=this._cubeSize;Tr(n,_*w,y>2?w:0,w,w),u.setRenderTarget(n),g&&u.render(v,c),u.render(e,c)}u.toneMapping=f,u.autoClear=d,e.background=b}_textureToCubeUV(e,t){const i=this._renderer,n=e.mapping===$s||e.mapping===Jr;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=pf()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=ff());const r=n?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const c=this._cubeSize;Tr(t,0,0,3*c,2*c),i.setRenderTarget(t),i.render(a,va)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const n=this._lodMeshes.length;for(let r=1;r<n;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=i}_applyGGXFilter(e,t,i){const n=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[i];o.material=a;const c=a.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-ys?i-p+ys:0),g=4*(this._cubeSize-v);c.envMap.value=e.texture,c.roughness.value=f,c.mipInt.value=p-t,Tr(r,m,g,3*v,2*v),n.setRenderTarget(r),n.render(o,va),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=p-i,Tr(e,m,g,3*v,2*v),n.setRenderTarget(e),n.render(o,va)}_blur(e,t,i,n,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,n,"latitudinal",r),this._halfBlur(a,e,i,i,n,"longitudinal",r)}_halfBlur(e,t,i,n,r,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&ke("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(r)?Math.PI/(2*f):2*Math.PI/(2*ks-1),v=r/p,m=isFinite(r)?1+Math.floor(h*v):ks;m>ks&&Ee(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${ks}`);const g=[];let b=0;for(let R=0;R<ks;++R){const x=R/v,A=Math.exp(-x*x/2);g.push(A),R===0?b+=A:R<m&&(b+=2*A)}for(let R=0;R<g.length;R++)g[R]=g[R]/b;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=g,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:y}=this;d.dTheta.value=p,d.mipInt.value=y-i;const _=this._sizeLods[n],w=3*_*(n>y-ys?n-y+ys:0),E=4*(this._cubeSize-_);Tr(t,w,E,3*_,2*_),c.setRenderTarget(t),c.render(u,va)}}function B3(s){const e=[],t=[],i=[];let n=s;const r=s-ys+1+lf.length;for(let a=0;a<r;a++){const o=Math.pow(2,n);e.push(o);let c=1/o;a>s-ys?c=lf[a-s+ys-1]:a===0&&(c=0),t.push(c);const l=1/(o-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,p=6,v=3,m=2,g=1,b=new Float32Array(v*p*f),y=new Float32Array(m*p*f),_=new Float32Array(g*p*f);for(let E=0;E<f;E++){const R=E%3*2/3-1,x=E>2?0:-1,A=[R,x,0,R+2/3,x,0,R+2/3,x+1,0,R,x,0,R+2/3,x+1,0,R,x+1,0];b.set(A,v*p*E),y.set(d,m*p*E);const I=[E,E,E,E,E,E];_.set(I,g*p*E)}const w=new bt;w.setAttribute("position",new ot(b,v)),w.setAttribute("uv",new ot(y,m)),w.setAttribute("faceIndex",new ot(_,g)),i.push(new We(w,null)),n>ys&&n--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function df(s,e,t){const i=new ui(s,e,t);return i.texture.mapping=Xc,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Tr(s,e,t,i,n){s.viewport.set(e,t,i,n),s.scissor.set(e,t,i,n)}function H3(s,e,t){return new wt({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:k3,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Kc(),fragmentShader:`
|
|
4305
|
+
}`,Ke={alphahash_fragment:jv,alphahash_pars_fragment:Qv,alphamap_fragment:eM,alphamap_pars_fragment:tM,alphatest_fragment:iM,alphatest_pars_fragment:nM,aomap_fragment:sM,aomap_pars_fragment:rM,batching_pars_vertex:aM,batching_vertex:oM,begin_vertex:cM,beginnormal_vertex:lM,bsdfs:hM,iridescence_fragment:uM,bumpmap_pars_fragment:dM,clipping_planes_fragment:fM,clipping_planes_pars_fragment:pM,clipping_planes_pars_vertex:mM,clipping_planes_vertex:gM,color_fragment:vM,color_pars_fragment:MM,color_pars_vertex:xM,color_vertex:_M,common:yM,cube_uv_reflection_fragment:SM,defaultnormal_vertex:bM,displacementmap_pars_vertex:EM,displacementmap_vertex:wM,emissivemap_fragment:AM,emissivemap_pars_fragment:TM,colorspace_fragment:RM,colorspace_pars_fragment:DM,envmap_fragment:CM,envmap_common_pars_fragment:IM,envmap_pars_fragment:PM,envmap_pars_vertex:LM,envmap_physical_pars_fragment:WM,envmap_vertex:NM,fog_vertex:OM,fog_pars_vertex:UM,fog_fragment:FM,fog_pars_fragment:kM,gradientmap_pars_fragment:zM,lightmap_pars_fragment:BM,lights_lambert_fragment:HM,lights_lambert_pars_fragment:GM,lights_pars_begin:VM,lights_toon_fragment:XM,lights_toon_pars_fragment:qM,lights_phong_fragment:YM,lights_phong_pars_fragment:KM,lights_physical_fragment:$M,lights_physical_pars_fragment:ZM,lights_fragment_begin:JM,lights_fragment_maps:jM,lights_fragment_end:QM,lightprobes_pars_fragment:ex,logdepthbuf_fragment:tx,logdepthbuf_pars_fragment:ix,logdepthbuf_pars_vertex:nx,logdepthbuf_vertex:sx,map_fragment:rx,map_pars_fragment:ax,map_particle_fragment:ox,map_particle_pars_fragment:cx,metalnessmap_fragment:lx,metalnessmap_pars_fragment:hx,morphinstance_vertex:ux,morphcolor_vertex:dx,morphnormal_vertex:fx,morphtarget_pars_vertex:px,morphtarget_vertex:mx,normal_fragment_begin:gx,normal_fragment_maps:vx,normal_pars_fragment:Mx,normal_pars_vertex:xx,normal_vertex:_x,normalmap_pars_fragment:yx,clearcoat_normal_fragment_begin:Sx,clearcoat_normal_fragment_maps:bx,clearcoat_pars_fragment:Ex,iridescence_pars_fragment:wx,opaque_fragment:Ax,packing:Tx,premultiplied_alpha_fragment:Rx,project_vertex:Dx,dithering_fragment:Cx,dithering_pars_fragment:Ix,roughnessmap_fragment:Px,roughnessmap_pars_fragment:Lx,shadowmap_pars_fragment:Nx,shadowmap_pars_vertex:Ox,shadowmap_vertex:Ux,shadowmask_pars_fragment:Fx,skinbase_vertex:kx,skinning_pars_vertex:zx,skinning_vertex:Bx,skinnormal_vertex:Hx,specularmap_fragment:Gx,specularmap_pars_fragment:Vx,tonemapping_fragment:Wx,tonemapping_pars_fragment:Xx,transmission_fragment:qx,transmission_pars_fragment:Yx,uv_pars_fragment:Kx,uv_pars_vertex:$x,uv_vertex:Zx,worldpos_vertex:Jx,background_vert:jx,background_frag:Qx,backgroundCube_vert:e3,backgroundCube_frag:t3,cube_vert:i3,cube_frag:n3,depth_vert:s3,depth_frag:r3,distance_vert:a3,distance_frag:o3,equirect_vert:c3,equirect_frag:l3,linedashed_vert:h3,linedashed_frag:u3,meshbasic_vert:d3,meshbasic_frag:f3,meshlambert_vert:p3,meshlambert_frag:m3,meshmatcap_vert:g3,meshmatcap_frag:v3,meshnormal_vert:M3,meshnormal_frag:x3,meshphong_vert:_3,meshphong_frag:y3,meshphysical_vert:S3,meshphysical_frag:b3,meshtoon_vert:E3,meshtoon_frag:w3,points_vert:A3,points_frag:T3,shadow_vert:R3,shadow_frag:D3,sprite_vert:C3,sprite_frag:I3},pe={common:{diffuse:{value:new oe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new He},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new He}},envmap:{envMap:{value:null},envMapRotation:{value:new He},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new He}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new He}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new He},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new He},normalScale:{value:new Ae(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new He},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new He}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new He}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new He}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new oe(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 oe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0},uvTransform:{value:new He}},sprite:{diffuse:{value:new oe(16777215)},opacity:{value:1},center:{value:new Ae(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new He},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0}}},bn={basic:{uniforms:yi([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.fog]),vertexShader:Ke.meshbasic_vert,fragmentShader:Ke.meshbasic_frag},lambert:{uniforms:yi([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 oe(0)},envMapIntensity:{value:1}}]),vertexShader:Ke.meshlambert_vert,fragmentShader:Ke.meshlambert_frag},phong:{uniforms:yi([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 oe(0)},specular:{value:new oe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ke.meshphong_vert,fragmentShader:Ke.meshphong_frag},standard:{uniforms:yi([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 oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag},toon:{uniforms:yi([pe.common,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.gradientmap,pe.fog,pe.lights,{emissive:{value:new oe(0)}}]),vertexShader:Ke.meshtoon_vert,fragmentShader:Ke.meshtoon_frag},matcap:{uniforms:yi([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,{matcap:{value:null}}]),vertexShader:Ke.meshmatcap_vert,fragmentShader:Ke.meshmatcap_frag},points:{uniforms:yi([pe.points,pe.fog]),vertexShader:Ke.points_vert,fragmentShader:Ke.points_frag},dashed:{uniforms:yi([pe.common,pe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ke.linedashed_vert,fragmentShader:Ke.linedashed_frag},depth:{uniforms:yi([pe.common,pe.displacementmap]),vertexShader:Ke.depth_vert,fragmentShader:Ke.depth_frag},normal:{uniforms:yi([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,{opacity:{value:1}}]),vertexShader:Ke.meshnormal_vert,fragmentShader:Ke.meshnormal_frag},sprite:{uniforms:yi([pe.sprite,pe.fog]),vertexShader:Ke.sprite_vert,fragmentShader:Ke.sprite_frag},background:{uniforms:{uvTransform:{value:new He},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ke.background_vert,fragmentShader:Ke.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new He}},vertexShader:Ke.backgroundCube_vert,fragmentShader:Ke.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ke.cube_vert,fragmentShader:Ke.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ke.equirect_vert,fragmentShader:Ke.equirect_frag},distance:{uniforms:yi([pe.common,pe.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ke.distance_vert,fragmentShader:Ke.distance_frag},shadow:{uniforms:yi([pe.lights,pe.fog,{color:{value:new oe(0)},opacity:{value:1}}]),vertexShader:Ke.shadow_vert,fragmentShader:Ke.shadow_frag}};bn.physical={uniforms:yi([bn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new He},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new He},clearcoatNormalScale:{value:new Ae(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new He},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new He},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new He},sheen:{value:0},sheenColor:{value:new oe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new He},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new He},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new He},transmissionSamplerSize:{value:new Ae},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new He},attenuationDistance:{value:0},attenuationColor:{value:new oe(0)},specularColor:{value:new oe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new He},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new He},anisotropyVector:{value:new Ae},anisotropyMap:{value:null},anisotropyMapTransform:{value:new He}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag};const Wo={r:0,b:0,g:0},P3=new Ye,Bm=new He;Bm.set(-1,0,0,0,1,0,0,0,1);function L3(s,e,t,i,n,r){const a=new oe(0);let o=n===!0?0:1,c,l,h=null,u=0,d=null;function f(b){let y=b.isScene===!0?b.background:null;if(y&&y.isTexture){const _=b.backgroundBlurriness>0;y=e.get(y,_)}return y}function p(b){let y=!1;const _=f(b);_===null?m(a,o):_&&_.isColor&&(m(_,1),y=!0);const E=s.xr.getEnvironmentBlendMode();E==="additive"?t.buffers.color.setClear(0,0,0,1,r):E==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(s.autoClear||y)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function v(b,y){const _=f(y);_&&(_.isCubeTexture||_.mapping===Xc)?(l===void 0&&(l=new We(new ji(1,1,1),new Et({name:"BackgroundCubeMaterial",uniforms:ea(bn.backgroundCube.uniforms),vertexShader:bn.backgroundCube.vertexShader,fragmentShader:bn.backgroundCube.fragmentShader,side:It,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(E,w,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),l.material.uniforms.envMap.value=_,l.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(P3.makeRotationFromEuler(y.backgroundRotation)).transpose(),_.isCubeTexture&&_.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Bm),l.material.toneMapped=et.getTransfer(_.colorSpace)!==ut,(h!==_||u!==_.version||d!==s.toneMapping)&&(l.material.needsUpdate=!0,h=_,u=_.version,d=s.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null)):_&&_.isTexture&&(c===void 0&&(c=new We(new dn(2,2),new Et({name:"BackgroundMaterial",uniforms:ea(bn.background.uniforms),vertexShader:bn.background.vertexShader,fragmentShader:bn.background.fragmentShader,side:ws,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=_,c.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,c.material.toneMapped=et.getTransfer(_.colorSpace)!==ut,_.matrixAutoUpdate===!0&&_.updateMatrix(),c.material.uniforms.uvTransform.value.copy(_.matrix),(h!==_||u!==_.version||d!==s.toneMapping)&&(c.material.needsUpdate=!0,h=_,u=_.version,d=s.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null))}function m(b,y){b.getRGB(Wo,Pm(s)),t.buffers.color.setClear(Wo.r,Wo.g,Wo.b,y,r)}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 a},setClearColor:function(b,y=1){a.set(b),o=y,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(b){o=b,m(a,o)},render:p,addToRenderList:v,dispose:g}}function N3(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),i={},n=d(null);let r=n,a=!1;function o(C,P,X,z,N){let V=!1;const k=u(C,z,X,P);r!==k&&(r=k,l(r.object)),V=f(C,z,X,N),V&&p(C,z,X,N),N!==null&&e.update(N,s.ELEMENT_ARRAY_BUFFER),(V||a)&&(a=!1,_(C,P,X,z),N!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(N).buffer))}function c(){return s.createVertexArray()}function l(C){return s.bindVertexArray(C)}function h(C){return s.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=r.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 ae=V[ee];if(ae===void 0&&(ee==="instanceMatrix"&&C.instanceMatrix&&(ae=C.instanceMatrix),ee==="instanceColor"&&C.instanceColor&&(ae=C.instanceColor)),ie===void 0||ie.attribute!==ae||ae&&ie.data!==ae.data)return!0;k++}return r.attributesNum!==k||r.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 ae={};ae.attribute=ie,ie&&ie.data&&(ae.data=ie.data),N[ee]=ae,k++}r.attributes=N,r.attributesNum=k,r.index=z}function v(){const C=r.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=r.newAttributes,z=r.enabledAttributes,N=r.attributeDivisors;X[C]=1,z[C]===0&&(s.enableVertexAttribArray(C),z[C]=1),N[C]!==P&&(s.vertexAttribDivisor(C,P),N[C]=P)}function b(){const C=r.newAttributes,P=r.enabledAttributes;for(let X=0,z=P.length;X<z;X++)P[X]!==C[X]&&(s.disableVertexAttribArray(X),P[X]=0)}function y(C,P,X,z,N,V,k){k===!0?s.vertexAttribIPointer(C,P,X,N,V):s.vertexAttribPointer(C,P,X,z,N,V)}function _(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,ae=J.itemSize,Be=e.get(J);if(Be===void 0)continue;const je=Be.buffer,Ge=Be.type,Y=Be.bytesPerElement,re=Ge===s.INT||Ge===s.UNSIGNED_INT||J.gpuType===Zu;if(J.isInterleavedBufferAttribute){const ne=J.data,B=ne.stride,Ee=J.offset;if(ne.isInstancedInterleavedBuffer){for(let Pe=0;Pe<ee.locationSize;Pe++)g(ee.location+Pe,ne.meshPerAttribute);C.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let Pe=0;Pe<ee.locationSize;Pe++)m(ee.location+Pe);s.bindBuffer(s.ARRAY_BUFFER,je);for(let Pe=0;Pe<ee.locationSize;Pe++)y(ee.location+Pe,ae/ee.locationSize,Ge,ie,B*Y,(Ee+ae/ee.locationSize*Pe)*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);s.bindBuffer(s.ARRAY_BUFFER,je);for(let ne=0;ne<ee.locationSize;ne++)y(ee.location+ne,ae/ee.locationSize,Ge,ie,ae*Y,ae/ee.locationSize*ne*Y,re)}}else if(k!==void 0){const ie=k[K];if(ie!==void 0)switch(ie.length){case 2:s.vertexAttrib2fv(ee.location,ie);break;case 3:s.vertexAttrib3fv(ee.location,ie);break;case 4:s.vertexAttrib4fv(ee.location,ie);break;default:s.vertexAttrib1fv(ee.location,ie)}}}}b()}function E(){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 w(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 R(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(),a=!0,r!==n&&(r=n,l(r.object))}function I(){n.geometry=null,n.program=null,n.wireframe=!1}return{setup:o,reset:A,resetDefaultState:I,dispose:E,releaseStatesOfGeometry:w,releaseStatesOfObject:x,releaseStatesOfProgram:R,initAttributes:v,enableAttribute:m,disableUnusedAttributes:b}}function O3(s,e,t){let i;function n(c){i=c}function r(c,l){s.drawArrays(i,c,l),t.update(l,i,1)}function a(c,l,h){h!==0&&(s.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=r,this.renderInstances=a,this.renderMultiDraw=o}function U3(s,e,t,i){let n;function r(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const R=e.get("EXT_texture_filter_anisotropic");n=s.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function a(R){return!(R!==xi&&i.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const x=R===$t&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(R!==Hi&&i.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==Ti&&!x)}function c(R){if(R==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp";const h=c(l);h!==l&&(we("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&&we("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),p=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=s.getParameter(s.MAX_TEXTURE_SIZE),m=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),g=s.getParameter(s.MAX_VERTEX_ATTRIBS),b=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),y=s.getParameter(s.MAX_VARYING_VECTORS),_=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),E=s.getParameter(s.MAX_SAMPLES),w=s.getParameter(s.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:v,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:b,maxVaryings:y,maxFragmentUniforms:_,maxSamples:E,samples:w}}function F3(s){const e=this;let t=null,i=0,n=!1,r=!1;const a=new Os,o=new He,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(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){t=h(u,d,0)},this.setState=function(u,d,f){const p=u.clippingPlanes,v=u.clipIntersection,m=u.clipShadows,g=s.get(u);if(!n||p===null||p.length===0||r&&!m)r?h(null):l();else{const b=r?0:i,y=b*4;let _=g.clippingState||null;c.value=_,_=h(p,d,y,f);for(let E=0;E!==y;++E)_[E]=t[E];g.clippingState=_,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=b}};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,b=d.matrixWorldInverse;o.getNormalMatrix(b),(m===null||m.length<g)&&(m=new Float32Array(g));for(let y=0,_=f;y!==v;++y,_+=4)a.copy(u[y]).applyMatrix4(b,o),a.normal.toArray(m,_),m[_+3]=a.constant}c.value=m,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,m}}const ys=4,lf=[.125,.215,.35,.446,.526,.582],ks=20,k3=256,va=new Ts,hf=new oe;let zl=null,Bl=0,Hl=0,Gl=!1;const z3=new D;class uf{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,r={}){const{size:a=256,position:o=z3}=r;zl=this._renderer.getRenderTarget(),Bl=this._renderer.getActiveCubeFace(),Hl=this._renderer.getActiveMipmapLevel(),Gl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);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=pf(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ff(),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(zl,Bl,Hl),this._renderer.xr.enabled=Gl,e.scissorTest=!1,Tr(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===$s||e.mapping===Jr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),zl=this._renderer.getRenderTarget(),Bl=this._renderer.getActiveCubeFace(),Hl=this._renderer.getActiveMipmapLevel(),Gl=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:at,minFilter:at,generateMipmaps:!1,type:$t,format:xi,colorSpace:Ac,depthBuffer:!1},n=df(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=df(e,t,i);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=B3(r)),this._blurMaterial=G3(r,e,t),this._ggxMaterial=H3(r,e,t)}return n}_compileMaterial(e){const t=new We(new bt,e);this._renderer.compile(t,va)}_sceneToCubeUV(e,t,i,n,r){const c=new Ni(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(hf),u.toneMapping=In,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(n),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new We(new ji,new Ji({name:"PMREM.Background",side:It,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,m=v.material;let g=!1;const b=e.background;b?b.isColor&&(m.color.copy(b),e.background=null,g=!0):(m.color.copy(hf),g=!0);for(let y=0;y<6;y++){const _=y%3;_===0?(c.up.set(0,l[y],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+h[y],r.y,r.z)):_===1?(c.up.set(0,0,l[y]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+h[y],r.z)):(c.up.set(0,l[y],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+h[y]));const E=this._cubeSize;Tr(n,_*E,y>2?E:0,E,E),u.setRenderTarget(n),g&&u.render(v,c),u.render(e,c)}u.toneMapping=f,u.autoClear=d,e.background=b}_textureToCubeUV(e,t){const i=this._renderer,n=e.mapping===$s||e.mapping===Jr;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=pf()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=ff());const r=n?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const c=this._cubeSize;Tr(t,0,0,3*c,2*c),i.setRenderTarget(t),i.render(a,va)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const n=this._lodMeshes.length;for(let r=1;r<n;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=i}_applyGGXFilter(e,t,i){const n=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[i];o.material=a;const c=a.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-ys?i-p+ys:0),g=4*(this._cubeSize-v);c.envMap.value=e.texture,c.roughness.value=f,c.mipInt.value=p-t,Tr(r,m,g,3*v,2*v),n.setRenderTarget(r),n.render(o,va),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=p-i,Tr(e,m,g,3*v,2*v),n.setRenderTarget(e),n.render(o,va)}_blur(e,t,i,n,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,n,"latitudinal",r),this._halfBlur(a,e,i,i,n,"longitudinal",r)}_halfBlur(e,t,i,n,r,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&ke("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(r)?Math.PI/(2*f):2*Math.PI/(2*ks-1),v=r/p,m=isFinite(r)?1+Math.floor(h*v):ks;m>ks&&we(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${ks}`);const g=[];let b=0;for(let R=0;R<ks;++R){const x=R/v,A=Math.exp(-x*x/2);g.push(A),R===0?b+=A:R<m&&(b+=2*A)}for(let R=0;R<g.length;R++)g[R]=g[R]/b;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=g,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:y}=this;d.dTheta.value=p,d.mipInt.value=y-i;const _=this._sizeLods[n],E=3*_*(n>y-ys?n-y+ys:0),w=4*(this._cubeSize-_);Tr(t,E,w,3*_,2*_),c.setRenderTarget(t),c.render(u,va)}}function B3(s){const e=[],t=[],i=[];let n=s;const r=s-ys+1+lf.length;for(let a=0;a<r;a++){const o=Math.pow(2,n);e.push(o);let c=1/o;a>s-ys?c=lf[a-s+ys-1]:a===0&&(c=0),t.push(c);const l=1/(o-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,p=6,v=3,m=2,g=1,b=new Float32Array(v*p*f),y=new Float32Array(m*p*f),_=new Float32Array(g*p*f);for(let w=0;w<f;w++){const R=w%3*2/3-1,x=w>2?0:-1,A=[R,x,0,R+2/3,x,0,R+2/3,x+1,0,R,x,0,R+2/3,x+1,0,R,x+1,0];b.set(A,v*p*w),y.set(d,m*p*w);const I=[w,w,w,w,w,w];_.set(I,g*p*w)}const E=new bt;E.setAttribute("position",new ot(b,v)),E.setAttribute("uv",new ot(y,m)),E.setAttribute("faceIndex",new ot(_,g)),i.push(new We(E,null)),n>ys&&n--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function df(s,e,t){const i=new ui(s,e,t);return i.texture.mapping=Xc,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Tr(s,e,t,i,n){s.viewport.set(e,t,i,n),s.scissor.set(e,t,i,n)}function H3(s,e,t){return new Et({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:k3,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Kc(),fragmentShader:`
|
|
4306
4306
|
|
|
4307
4307
|
precision highp float;
|
|
4308
4308
|
precision highp int;
|
|
@@ -4406,7 +4406,7 @@ void main() {
|
|
|
4406
4406
|
|
|
4407
4407
|
gl_FragColor = vec4(prefilteredColor, 1.0);
|
|
4408
4408
|
}
|
|
4409
|
-
`,blending:Cn,depthTest:!1,depthWrite:!1})}function G3(s,e,t){const i=new Float32Array(ks),n=new D(0,1,0);return new
|
|
4409
|
+
`,blending:Cn,depthTest:!1,depthWrite:!1})}function G3(s,e,t){const i=new Float32Array(ks),n=new D(0,1,0);return new Et({name:"SphericalGaussianBlur",defines:{n:ks,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:n}},vertexShader:Kc(),fragmentShader:`
|
|
4410
4410
|
|
|
4411
4411
|
precision mediump float;
|
|
4412
4412
|
precision mediump int;
|
|
@@ -4466,7 +4466,7 @@ void main() {
|
|
|
4466
4466
|
}
|
|
4467
4467
|
|
|
4468
4468
|
}
|
|
4469
|
-
`,blending:Cn,depthTest:!1,depthWrite:!1})}function ff(){return new
|
|
4469
|
+
`,blending:Cn,depthTest:!1,depthWrite:!1})}function ff(){return new Et({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Kc(),fragmentShader:`
|
|
4470
4470
|
|
|
4471
4471
|
precision mediump float;
|
|
4472
4472
|
precision mediump int;
|
|
@@ -4485,7 +4485,7 @@ void main() {
|
|
|
4485
4485
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
4486
4486
|
|
|
4487
4487
|
}
|
|
4488
|
-
`,blending:Cn,depthTest:!1,depthWrite:!1})}function pf(){return new
|
|
4488
|
+
`,blending:Cn,depthTest:!1,depthWrite:!1})}function pf(){return new Et({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Kc(),fragmentShader:`
|
|
4489
4489
|
|
|
4490
4490
|
precision mediump float;
|
|
4491
4491
|
precision mediump int;
|
|
@@ -4591,7 +4591,7 @@ void main() {
|
|
|
4591
4591
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
4592
4592
|
|
|
4593
4593
|
}
|
|
4594
|
-
`},n=new
|
|
4594
|
+
`},n=new ji(5,5,5),r=new Et({name:"CubemapFromEquirect",uniforms:ea(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:It,blending:Cn});r.uniforms.tEquirect.value=t;const a=new We(n,r),o=t.minFilter;return t.minFilter===Gs&&(t.minFilter=at),new Fm(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,n=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,n);e.setRenderTarget(r)}}function V3(s){let e=new WeakMap,t=new WeakMap,i=null;function n(d,f=!1){return d==null?null:f?a(d):r(d)}function r(d){if(d&&d.isTexture){const f=d.mapping;if(f===al||f===ol)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 gd(p.height);return v.fromEquirectangularTexture(s,d),e.set(d,v),d.addEventListener("dispose",l),o(v.texture,d.mapping)}else return null}}return d}function a(d){if(d&&d.isTexture){const f=d.mapping,p=f===al||f===ol,v=f===$s||f===Jr;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 uf(s)),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 b=d.image;return p&&b&&b.height>0||v&&b&&c(b)?(i===null&&(i=new uf(s)),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===al?d.mapping=$s:f===ol&&(d.mapping=Jr),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 W3(s){const e={};function t(i){if(e[i]!==void 0)return e[i];const n=s.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&&Hr("WebGLRenderer: "+i+" extension not supported."),n}}}function X3(s,e,t,i){const n={},r=new WeakMap;function a(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",a),delete n[d.id];const f=r.get(d);f&&(e.remove(f),r.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",a),n[d.id]=!0,t.memory.geometries++),d}function c(u){const d=u.attributes;for(const f in d)e.update(d[f],s.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 b=f.array;v=f.version;for(let y=0,_=b.length;y<_;y+=3){const E=b[y+0],w=b[y+1],R=b[y+2];d.push(E,w,w,R,R,E)}}else{const b=p.array;v=p.version;for(let y=0,_=b.length/3-1;y<_;y+=3){const E=y+0,w=y+1,R=y+2;d.push(E,w,w,R,R,E)}}const m=new(p.count>=65535?od:Am)(d,1);m.version=v;const g=r.get(u);g&&e.remove(g),r.set(u,m)}function h(u){const d=r.get(u);if(d){const f=u.index;f!==null&&d.version<f.version&&l(u)}else l(u);return r.get(u)}return{get:o,update:c,getWireframeAttribute:h}}function q3(s,e,t){let i;function n(u){i=u}let r,a;function o(u){r=u.type,a=u.bytesPerElement}function c(u,d){s.drawElements(i,d,r,u*a),t.update(d,i,1)}function l(u,d,f){f!==0&&(s.drawElementsInstanced(i,d,r,u*a,f),t.update(d,i,f))}function h(u,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,d,0,r,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 Y3(s){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(r,a,o){switch(t.calls++,a){case s.TRIANGLES:t.triangles+=o*(r/3);break;case s.LINES:t.lines+=o*(r/2);break;case s.LINE_STRIP:t.lines+=o*(r-1);break;case s.LINE_LOOP:t.lines+=o*r;break;case s.POINTS:t.points+=o*r;break;default:ke("WebGLInfo: Unknown draw mode:",a);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 K3(s,e,t){const i=new WeakMap,n=new it;function r(a,o,c){const l=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=i.get(o);if(d===void 0||d.count!==u){let A=function(){R.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||[],b=o.morphAttributes.color||[];let y=0;f===!0&&(y=1),p===!0&&(y=2),v===!0&&(y=3);let _=o.attributes.position.count*y,E=1;_>e.maxTextureSize&&(E=Math.ceil(_/e.maxTextureSize),_=e.maxTextureSize);const w=new Float32Array(_*E*4*u),R=new bm(w,_,E,u);R.type=Ti,R.needsUpdate=!0;const x=y*4;for(let I=0;I<u;I++){const C=m[I],P=g[I],X=b[I],z=_*E*4*I;for(let N=0;N<C.count;N++){const V=N*x;f===!0&&(n.fromBufferAttribute(C,N),w[z+V+0]=n.x,w[z+V+1]=n.y,w[z+V+2]=n.z,w[z+V+3]=0),p===!0&&(n.fromBufferAttribute(P,N),w[z+V+4]=n.x,w[z+V+5]=n.y,w[z+V+6]=n.z,w[z+V+7]=0),v===!0&&(n.fromBufferAttribute(X,N),w[z+V+8]=n.x,w[z+V+9]=n.y,w[z+V+10]=n.z,w[z+V+11]=X.itemSize===4?n.w:1)}}d={count:u,texture:R,size:new Ae(_,E)},i.set(o,d),o.addEventListener("dispose",A)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(s,"morphTexture",a.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(s,"morphTargetBaseInfluence",p),c.getUniforms().setValue(s,"morphTargetInfluences",l)}c.getUniforms().setValue(s,"morphTargetsTexture",d.texture,t),c.getUniforms().setValue(s,"morphTargetsTextureSize",d.size)}return{update:r}}function $3(s,e,t,i,n){let r=new WeakMap;function a(l){const h=n.render.frame,u=l.geometry,d=e.get(l,u);if(r.get(d)!==h&&(e.update(d),r.set(d,h)),l.isInstancedMesh&&(l.hasEventListener("dispose",c)===!1&&l.addEventListener("dispose",c),r.get(l)!==h&&(t.update(l.instanceMatrix,s.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,s.ARRAY_BUFFER),r.set(l,h))),l.isSkinnedMesh){const f=l.skeleton;r.get(f)!==h&&(f.update(),r.set(f,h))}return d}function o(){r=new WeakMap}function c(l){const h=l.target;h.removeEventListener("dispose",c),i.releaseStatesOfObject(h),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:a,dispose:o}}const Z3={[cm]:"LINEAR_TONE_MAPPING",[lm]:"REINHARD_TONE_MAPPING",[hm]:"CINEON_TONE_MAPPING",[um]:"ACES_FILMIC_TONE_MAPPING",[fm]:"AGX_TONE_MAPPING",[pm]:"NEUTRAL_TONE_MAPPING",[dm]:"CUSTOM_TONE_MAPPING"};function J3(s,e,t,i,n,r){const a=new ui(e,t,{type:s,depthBuffer:n,stencilBuffer:r,samples:i?4:0,depthTexture:n?new Js(e,t):void 0}),o=new ui(e,t,{type:$t,depthBuffer:!1,stencilBuffer:!1}),c=new bt;c.setAttribute("position",new Pt([-1,3,0,-1,-1,0,3,-1,0],3)),c.setAttribute("uv",new Pt([0,2,0,0,2,0],2));const l=new Lm({uniforms:{tDiffuse:{value:null}},vertexShader:`
|
|
4595
4595
|
precision highp float;
|
|
4596
4596
|
|
|
4597
4597
|
uniform mat4 modelViewMatrix;
|
|
@@ -4637,17 +4637,17 @@ void main() {
|
|
|
4637
4637
|
#ifdef SRGB_TRANSFER
|
|
4638
4638
|
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
|
4639
4639
|
#endif
|
|
4640
|
-
}`,depthTest:!1,depthWrite:!1}),h=new We(c,l),u=new Ts(-1,1,1,-1,0,1);let d=null,f=null,p=!1,v,m=null,g=[],b=!1;this.setSize=function(y,_){a.setSize(y,_),o.setSize(y,_);for(let
|
|
4640
|
+
}`,depthTest:!1,depthWrite:!1}),h=new We(c,l),u=new Ts(-1,1,1,-1,0,1);let d=null,f=null,p=!1,v,m=null,g=[],b=!1;this.setSize=function(y,_){a.setSize(y,_),o.setSize(y,_);for(let E=0;E<g.length;E++){const w=g[E];w.setSize&&w.setSize(y,_)}},this.setEffects=function(y){g=y,b=g.length>0&&g[0].isRenderPass===!0;const _=a.width,E=a.height;for(let w=0;w<g.length;w++){const R=g[w];R.setSize&&R.setSize(_,E)}},this.begin=function(y,_){if(p||y.toneMapping===In&&g.length===0)return!1;if(m=_,_!==null){const E=_.width,w=_.height;(a.width!==E||a.height!==w)&&this.setSize(E,w)}return b===!1&&y.setRenderTarget(a),v=y.toneMapping,y.toneMapping=In,!0},this.hasRenderPass=function(){return b},this.end=function(y,_){y.toneMapping=v,p=!0;let E=a,w=o;for(let R=0;R<g.length;R++){const x=g[R];if(x.enabled!==!1&&(x.render(y,w,E,_),x.needsSwap!==!1)){const A=E;E=w,w=A}}if(d!==y.outputColorSpace||f!==y.toneMapping){d=y.outputColorSpace,f=y.toneMapping,l.defines={},et.getTransfer(d)===ut&&(l.defines.SRGB_TRANSFER="");const R=Z3[f];R&&(l.defines[R]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=E.texture,y.setRenderTarget(m),y.render(h,u),m=null,p=!1},this.isCompositing=function(){return p},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),c.dispose(),l.dispose()}}const Hm=new oi,du=new Js(1,1),Gm=new bm,Vm=new Em,Wm=new Cm,mf=[],gf=[],vf=new Float32Array(16),Mf=new Float32Array(9),xf=new Float32Array(4);function sa(s,e,t){const i=s[0];if(i<=0||i>0)return s;const n=e*t;let r=mf[n];if(r===void 0&&(r=new Float32Array(n),mf[n]=r),e!==0){i.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,s[a].toArray(r,o)}return r}function Zt(s,e){if(s.length!==e.length)return!1;for(let t=0,i=s.length;t<i;t++)if(s[t]!==e[t])return!1;return!0}function Jt(s,e){for(let t=0,i=e.length;t<i;t++)s[t]=e[t]}function $c(s,e){let t=gf[e];t===void 0&&(t=new Int32Array(e),gf[e]=t);for(let i=0;i!==e;++i)t[i]=s.allocateTextureUnit();return t}function j3(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function Q3(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Zt(t,e))return;s.uniform2fv(this.addr,e),Jt(t,e)}}function e_(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.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)&&(s.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Zt(t,e))return;s.uniform3fv(this.addr,e),Jt(t,e)}}function t_(s,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)&&(s.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(Zt(t,e))return;s.uniform4fv(this.addr,e),Jt(t,e)}}function i_(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(Zt(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),Jt(t,e)}else{if(Zt(t,i))return;xf.set(i),s.uniformMatrix2fv(this.addr,!1,xf),Jt(t,i)}}function n_(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(Zt(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),Jt(t,e)}else{if(Zt(t,i))return;Mf.set(i),s.uniformMatrix3fv(this.addr,!1,Mf),Jt(t,i)}}function s_(s,e){const t=this.cache,i=e.elements;if(i===void 0){if(Zt(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),Jt(t,e)}else{if(Zt(t,i))return;vf.set(i),s.uniformMatrix4fv(this.addr,!1,vf),Jt(t,i)}}function r_(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function a_(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Zt(t,e))return;s.uniform2iv(this.addr,e),Jt(t,e)}}function o_(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Zt(t,e))return;s.uniform3iv(this.addr,e),Jt(t,e)}}function c_(s,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)&&(s.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(Zt(t,e))return;s.uniform4iv(this.addr,e),Jt(t,e)}}function l_(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function h_(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Zt(t,e))return;s.uniform2uiv(this.addr,e),Jt(t,e)}}function u_(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Zt(t,e))return;s.uniform3uiv(this.addr,e),Jt(t,e)}}function d_(s,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)&&(s.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(Zt(t,e))return;s.uniform4uiv(this.addr,e),Jt(t,e)}}function f_(s,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(s.uniform1i(this.addr,n),i[0]=n);let r;this.type===s.SAMPLER_2D_SHADOW?(du.compareFunction=t.isReversedDepthBuffer()?nd:id,r=du):r=Hm,t.setTexture2D(e||r,n)}function p_(s,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(s.uniform1i(this.addr,n),i[0]=n),t.setTexture3D(e||Vm,n)}function m_(s,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(s.uniform1i(this.addr,n),i[0]=n),t.setTextureCube(e||Wm,n)}function g_(s,e,t){const i=this.cache,n=t.allocateTextureUnit();i[0]!==n&&(s.uniform1i(this.addr,n),i[0]=n),t.setTexture2DArray(e||Gm,n)}function v_(s){switch(s){case 5126:return j3;case 35664:return Q3;case 35665:return e_;case 35666:return t_;case 35674:return i_;case 35675:return n_;case 35676:return s_;case 5124:case 35670:return r_;case 35667:case 35671:return a_;case 35668:case 35672:return o_;case 35669:case 35673:return c_;case 5125:return l_;case 36294:return h_;case 36295:return u_;case 36296:return d_;case 35678:case 36198:case 36298:case 36306:case 35682:return f_;case 35679:case 36299:case 36307:return p_;case 35680:case 36300:case 36308:case 36293:return m_;case 36289:case 36303:case 36311:case 36292:return g_}}function M_(s,e){s.uniform1fv(this.addr,e)}function x_(s,e){const t=sa(e,this.size,2);s.uniform2fv(this.addr,t)}function __(s,e){const t=sa(e,this.size,3);s.uniform3fv(this.addr,t)}function y_(s,e){const t=sa(e,this.size,4);s.uniform4fv(this.addr,t)}function S_(s,e){const t=sa(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function b_(s,e){const t=sa(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function E_(s,e){const t=sa(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function w_(s,e){s.uniform1iv(this.addr,e)}function A_(s,e){s.uniform2iv(this.addr,e)}function T_(s,e){s.uniform3iv(this.addr,e)}function R_(s,e){s.uniform4iv(this.addr,e)}function D_(s,e){s.uniform1uiv(this.addr,e)}function C_(s,e){s.uniform2uiv(this.addr,e)}function I_(s,e){s.uniform3uiv(this.addr,e)}function P_(s,e){s.uniform4uiv(this.addr,e)}function L_(s,e,t){const i=this.cache,n=e.length,r=$c(t,n);Zt(i,r)||(s.uniform1iv(this.addr,r),Jt(i,r));let a;this.type===s.SAMPLER_2D_SHADOW?a=du:a=Hm;for(let o=0;o!==n;++o)t.setTexture2D(e[o]||a,r[o])}function N_(s,e,t){const i=this.cache,n=e.length,r=$c(t,n);Zt(i,r)||(s.uniform1iv(this.addr,r),Jt(i,r));for(let a=0;a!==n;++a)t.setTexture3D(e[a]||Vm,r[a])}function O_(s,e,t){const i=this.cache,n=e.length,r=$c(t,n);Zt(i,r)||(s.uniform1iv(this.addr,r),Jt(i,r));for(let a=0;a!==n;++a)t.setTextureCube(e[a]||Wm,r[a])}function U_(s,e,t){const i=this.cache,n=e.length,r=$c(t,n);Zt(i,r)||(s.uniform1iv(this.addr,r),Jt(i,r));for(let a=0;a!==n;++a)t.setTexture2DArray(e[a]||Gm,r[a])}function F_(s){switch(s){case 5126:return M_;case 35664:return x_;case 35665:return __;case 35666:return y_;case 35674:return S_;case 35675:return b_;case 35676:return E_;case 5124:case 35670:return w_;case 35667:case 35671:return A_;case 35668:case 35672:return T_;case 35669:case 35673:return R_;case 5125:return D_;case 36294:return C_;case 36295:return I_;case 36296:return P_;case 35678:case 36198:case 36298:case 36306:case 35682:return L_;case 35679:case 36299:case 36307:return N_;case 35680:case 36300:case 36308:case 36293:return O_;case 36289:case 36303:case 36311:case 36292:return U_}}class k_{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=v_(t.type)}}class z_{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=F_(t.type)}}class B_{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const n=this.seq;for(let r=0,a=n.length;r!==a;++r){const o=n[r];o.setValue(e,t[o.id],i)}}}const Vl=/(\w+)(\])?(\[|\.)?/g;function _f(s,e){s.seq.push(e),s.map[e.id]=e}function H_(s,e,t){const i=s.name,n=i.length;for(Vl.lastIndex=0;;){const r=Vl.exec(i),a=Vl.lastIndex;let o=r[1];const c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===n){_f(t,l===void 0?new k_(o,s,e):new z_(o,s,e));break}else{let u=t.map[o];u===void 0&&(u=new B_(o),_f(t,u)),t=u}}}class pc{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<i;++a){const o=e.getActiveUniform(t,a),c=e.getUniformLocation(t,o.name);H_(o,c,this)}const n=[],r=[];for(const a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?n.push(a):r.push(a);n.length>0&&(this.seq=n.concat(r))}setValue(e,t,i,n){const r=this.map[t];r!==void 0&&r.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 r=0,a=t.length;r!==a;++r){const o=t[r],c=i[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,n)}}static seqWithValue(e,t){const i=[];for(let n=0,r=e.length;n!==r;++n){const a=e[n];a.id in t&&i.push(a)}return i}}function yf(s,e,t){const i=s.createShader(e);return s.shaderSource(i,t),s.compileShader(i),i}const G_=37297;let V_=0;function W_(s,e){const t=s.split(`
|
|
4641
4641
|
`),i=[],n=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=n;a<r;a++){const o=a+1;i.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return i.join(`
|
|
4642
|
-
`)}const Sf=new He;function X_(s){et._getMatrix(Sf,et.workingColorSpace,s);const e=`mat3( ${Sf.elements.map(t=>t.toFixed(4))} )`;switch(et.getTransfer(s)){case Tc:return[e,"LinearTransferOETF"];case ut:return[e,"sRGBTransferOETF"];default:return
|
|
4642
|
+
`)}const Sf=new He;function X_(s){et._getMatrix(Sf,et.workingColorSpace,s);const e=`mat3( ${Sf.elements.map(t=>t.toFixed(4))} )`;switch(et.getTransfer(s)){case Tc:return[e,"LinearTransferOETF"];case ut:return[e,"sRGBTransferOETF"];default:return we("WebGLProgram: Unsupported color space: ",s),[e,"LinearTransferOETF"]}}function bf(s,e,t){const i=s.getShaderParameter(e,s.COMPILE_STATUS),r=(s.getShaderInfoLog(e)||"").trim();if(i&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
|
|
4643
4643
|
|
|
4644
4644
|
`+r+`
|
|
4645
4645
|
|
|
4646
4646
|
`+W_(s.getShaderSource(e),o)}else return r}function q_(s,e){const t=X_(e);return[`vec4 ${s}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
|
4647
|
-
`)}const Y_={[cm]:"Linear",[lm]:"Reinhard",[hm]:"Cineon",[um]:"ACESFilmic",[fm]:"AgX",[pm]:"Neutral",[dm]:"Custom"};function K_(s,e){const t=Y_[e];return t===void 0?(
|
|
4647
|
+
`)}const Y_={[cm]:"Linear",[lm]:"Reinhard",[hm]:"Cineon",[um]:"ACESFilmic",[fm]:"AgX",[pm]:"Neutral",[dm]:"Custom"};function K_(s,e){const t=Y_[e];return t===void 0?(we("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+s+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+s+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Xo=new D;function $_(){et.getLuminanceCoefficients(Xo);const s=Xo.x.toFixed(4),e=Xo.y.toFixed(4),t=Xo.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${s}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
|
4648
4648
|
`)}function Z_(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ra).join(`
|
|
4649
4649
|
`)}function J_(s){const e=[];for(const t in s){const i=s[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
|
|
4650
|
-
`)}function j_(s,e){const t={},i=s.getProgramParameter(e,s.ACTIVE_ATTRIBUTES);for(let n=0;n<i;n++){const r=s.getActiveAttrib(e,n),a=r.name;let o=1;r.type===s.FLOAT_MAT2&&(o=2),r.type===s.FLOAT_MAT3&&(o=3),r.type===s.FLOAT_MAT4&&(o=4),t[a]={type:r.type,location:s.getAttribLocation(e,a),locationSize:o}}return t}function Ra(s){return s!==""}function
|
|
4650
|
+
`)}function j_(s,e){const t={},i=s.getProgramParameter(e,s.ACTIVE_ATTRIBUTES);for(let n=0;n<i;n++){const r=s.getActiveAttrib(e,n),a=r.name;let o=1;r.type===s.FLOAT_MAT2&&(o=2),r.type===s.FLOAT_MAT3&&(o=3),r.type===s.FLOAT_MAT4&&(o=4),t[a]={type:r.type,location:s.getAttribLocation(e,a),locationSize:o}}return t}function Ra(s){return s!==""}function Ef(s,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return s.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 wf(s,e){return s.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Q_=/^[ \t]*#include +<([\w\d./]+)>/gm;function fu(s){return s.replace(Q_,ty)}const ey=new Map;function ty(s,e){let t=Ke[e];if(t===void 0){const i=ey.get(e);if(i!==void 0)t=Ke[i],we('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return fu(t)}const iy=/#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 Af(s){return s.replace(iy,ny)}function ny(s,e,t,i){let n="";for(let r=parseInt(e);r<parseInt(t);r++)n+=i.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return n}function Tf(s){let e=`precision ${s.precision} float;
|
|
4651
4651
|
precision ${s.precision} int;
|
|
4652
4652
|
precision ${s.precision} sampler2D;
|
|
4653
4653
|
precision ${s.precision} samplerCube;
|
|
@@ -4676,19 +4676,19 @@ void main() {
|
|
|
4676
4676
|
`].filter(Ra).join(`
|
|
4677
4677
|
`),g=[Tf(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==In?"#define TONE_MAPPING":"",t.toneMapping!==In?Ke.tonemapping_pars_fragment:"",t.toneMapping!==In?K_("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ke.colorspace_pars_fragment,q_("linearToOutputTexel",t.outputColorSpace),$_(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
4678
4678
|
`].filter(Ra).join(`
|
|
4679
|
-
`)),a=fu(a),a=
|
|
4679
|
+
`)),a=fu(a),a=Ef(a,t),a=wf(a,t),o=fu(o),o=Ef(o,t),o=wf(o,t),a=Af(a),o=Af(o),t.isRawShaderMaterial!==!0&&(b=`#version 300 es
|
|
4680
4680
|
`,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
4681
4681
|
`)+`
|
|
4682
4682
|
`+m,g=["#define varying in",t.glslVersion===Rc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Rc?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
|
|
4683
4683
|
`)+`
|
|
4684
|
-
`+g);const y=b+m+a,_=b+g+o,
|
|
4684
|
+
`+g);const y=b+m+a,_=b+g+o,E=yf(n,n.VERTEX_SHADER,y),w=yf(n,n.FRAGMENT_SHADER,_);n.attachShader(v,E),n.attachShader(v,w),t.index0AttributeName!==void 0?n.bindAttribLocation(v,0,t.index0AttributeName):t.hasPositionAttribute===!0&&n.bindAttribLocation(v,0,"position"),n.linkProgram(v);function R(C){if(s.debug.checkShaderErrors){const P=n.getProgramInfoLog(v)||"",X=n.getShaderInfoLog(E)||"",z=n.getShaderInfoLog(w)||"",N=P.trim(),V=X.trim(),k=z.trim();let K=!0,ee=!0;if(n.getProgramParameter(v,n.LINK_STATUS)===!1)if(K=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(n,v,E,w);else{const J=bf(n,E,"vertex"),ie=bf(n,w,"fragment");ke("WebGLProgram: Shader Error "+n.getError()+" - VALIDATE_STATUS "+n.getProgramParameter(v,n.VALIDATE_STATUS)+`
|
|
4685
4685
|
|
|
4686
4686
|
Material Name: `+C.name+`
|
|
4687
4687
|
Material Type: `+C.type+`
|
|
4688
4688
|
|
|
4689
4689
|
Program Info Log: `+N+`
|
|
4690
4690
|
`+J+`
|
|
4691
|
-
`+ie)}else N!==""?Ee("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(w),n.deleteShader(E),x=new pc(n,v),A=j_(n,v)}let x;this.getUniforms=function(){return x===void 0&&R(this),x};let A;this.getAttributes=function(){return A===void 0&&R(this),A};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=n.getProgramParameter(v,G_)),I},this.destroy=function(){i.releaseStatesOfProgram(this),n.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=V_++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=w,this.fragmentShader=E,this}let py=0;class my{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 gy(e),t.set(e,i)),i}}class gy{constructor(e){this.id=py++,this.code=e,this.usedTimes=0}}function vy(s){return s===Zs||s===Sc||s===bc}function My(s,e,t,i,n,r){const a=new ad,o=new my,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===Xc?K.image.height:null,J=f[x.type];x.precision!==null&&(d=i.getMaxPrecision(x.precision),d!==x.precision&&Ee("WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead."));const ie=N.morphAttributes.position||N.morphAttributes.normal||N.morphAttributes.color,ae=ie!==void 0?ie.length:0;let Be=0;N.morphAttributes.position!==void 0&&(Be=1),N.morphAttributes.normal!==void 0&&(Be=2),N.morphAttributes.color!==void 0&&(Be=3);let je,Ge,Y,re;if(J){const ye=bn[J];je=ye.vertexShader,Ge=ye.fragmentShader}else{je=x.vertexShader,Ge=x.fragmentShader;const ye=o.getVertexShaderStage(x),Ut=o.getFragmentShaderStage(x);o.update(x,ye,Ut),Y=ye.id,re=Ut.id}const ne=s.getRenderTarget(),B=s.state.buffers.depth.getReversed(),we=P.isInstancedMesh===!0,Pe=P.isBatchedMesh===!0,Re=!!x.map,xe=!!x.matcap,Ne=!!K,Oe=!!x.aoMap,Ue=!!x.lightMap,ct=!!x.bumpMap&&x.wireframe===!1,lt=!!x.normalMap,Nt=!!x.displacementMap,Tt=!!x.emissiveMap,Ot=!!x.metalnessMap,Wt=!!x.roughnessMap,O=x.anisotropy>0,Ti=x.clearcoat>0,ht=x.dispersion>0,T=x.iridescence>0,M=x.sheen>0,F=x.transmission>0,W=O&&!!x.anisotropyMap,$=Ti&&!!x.clearcoatMap,se=Ti&&!!x.clearcoatNormalMap,le=Ti&&!!x.clearcoatRoughnessMap,Z=T&&!!x.iridescenceMap,Q=T&&!!x.iridescenceThicknessMap,he=M&&!!x.sheenColorMap,De=M&&!!x.sheenRoughnessMap,fe=!!x.specularMap,ue=!!x.specularColorMap,Le=!!x.specularIntensityMap,Fe=F&&!!x.transmissionMap,Xe=F&&!!x.thicknessMap,L=!!x.gradientMap,ce=!!x.alphaMap,j=x.alphaTest>0,de=!!x.alphaHash,ve=!!x.extensions;let te=In;x.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(te=s.toneMapping);const Te={shaderID:J,shaderType:x.type,shaderName:x.name,vertexShader:je,fragmentShader:Ge,defines:x.defines,customVertexShaderID:Y,customFragmentShaderID:re,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,batching:Pe,batchingColor:Pe&&P._colorsTexture!==null,instancing:we,instancingColor:we&&P.instanceColor!==null,instancingMorph:we&&P.morphTexture!==null,outputColorSpace:ne===null?s.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:et.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Re,matcap:xe,envMap:Ne,envMapMode:Ne&&K.mapping,envMapCubeUVHeight:ee,aoMap:Oe,lightMap:Ue,bumpMap:ct,normalMap:lt,displacementMap:Nt,emissiveMap:Tt,normalMapObjectSpace:lt&&x.normalMapType===u2,normalMapTangentSpace:lt&&x.normalMapType===Ec,packedNormalMap:lt&&x.normalMapType===Ec&&vy(x.normalMap.format),metalnessMap:Ot,roughnessMap:Wt,anisotropy:O,anisotropyMap:W,clearcoat:Ti,clearcoatMap:$,clearcoatNormalMap:se,clearcoatRoughnessMap:le,dispersion:ht,iridescence:T,iridescenceMap:Z,iridescenceThicknessMap:Q,sheen:M,sheenColorMap:he,sheenRoughnessMap:De,specularMap:fe,specularColorMap:ue,specularIntensityMap:Le,transmission:F,transmissionMap:Fe,thicknessMap:Xe,gradientMap:L,opaque:x.transparent===!1&&x.blending===qs&&x.alphaToCoverage===!1,alphaMap:ce,alphaTest:j,alphaHash:de,combine:x.combine,mapUv:Re&&p(x.map.channel),aoMapUv:Oe&&p(x.aoMap.channel),lightMapUv:Ue&&p(x.lightMap.channel),bumpMapUv:ct&&p(x.bumpMap.channel),normalMapUv:lt&&p(x.normalMap.channel),displacementMapUv:Nt&&p(x.displacementMap.channel),emissiveMapUv:Tt&&p(x.emissiveMap.channel),metalnessMapUv:Ot&&p(x.metalnessMap.channel),roughnessMapUv:Wt&&p(x.roughnessMap.channel),anisotropyMapUv:W&&p(x.anisotropyMap.channel),clearcoatMapUv:$&&p(x.clearcoatMap.channel),clearcoatNormalMapUv:se&&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:De&&p(x.sheenRoughnessMap.channel),specularMapUv:fe&&p(x.specularMap.channel),specularColorMapUv:ue&&p(x.specularColorMap.channel),specularIntensityMapUv:Le&&p(x.specularIntensityMap.channel),transmissionMapUv:Fe&&p(x.transmissionMap.channel),thicknessMapUv:Xe&&p(x.thicknessMap.channel),alphaMapUv:ce&&p(x.alphaMap.channel),vertexTangents:!!N.attributes.tangent&&(lt||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&&(Re||ce),fog:!!z,useFog:x.fog===!0,fogExp2:!!z&&z.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||N.attributes.normal===void 0&<===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:B,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:ae,morphTextureStride:Be,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:r.numPlanes,numClipIntersection:r.numIntersection,dithering:x.dithering,shadowMapEnabled:s.shadowMap.enabled&&I.length>0,shadowMapType:s.shadowMap.type,toneMapping:te,decodeVideoTexture:Re&&x.map.isVideoTexture===!0&&et.getTransfer(x.map.colorSpace)===ut,decodeVideoTextureEmissive:Tt&&x.emissiveMap.isVideoTexture===!0&&et.getTransfer(x.emissiveMap.colorSpace)===ut,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===on,flipSided:x.side===It,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||Pe)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return Te.vertexUv1s=c.has(1),Te.vertexUv2s=c.has(2),Te.vertexUv3s=c.has(3),c.clear(),Te}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),b(A,x),A.push(s.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 b(x,A){a.disableAll(),A.instancing&&a.enable(0),A.instancingColor&&a.enable(1),A.instancingMorph&&a.enable(2),A.matcap&&a.enable(3),A.envMap&&a.enable(4),A.normalMapObjectSpace&&a.enable(5),A.normalMapTangentSpace&&a.enable(6),A.clearcoat&&a.enable(7),A.iridescence&&a.enable(8),A.alphaTest&&a.enable(9),A.vertexColors&&a.enable(10),A.vertexAlphas&&a.enable(11),A.vertexUv1s&&a.enable(12),A.vertexUv2s&&a.enable(13),A.vertexUv3s&&a.enable(14),A.vertexTangents&&a.enable(15),A.anisotropy&&a.enable(16),A.alphaHash&&a.enable(17),A.batching&&a.enable(18),A.dispersion&&a.enable(19),A.batchingColor&&a.enable(20),A.gradientMap&&a.enable(21),A.packedNormalMap&&a.enable(22),A.vertexNormals&&a.enable(23),x.push(a.mask),a.disableAll(),A.fog&&a.enable(0),A.useFog&&a.enable(1),A.flatShading&&a.enable(2),A.logarithmicDepthBuffer&&a.enable(3),A.reversedDepthBuffer&&a.enable(4),A.skinning&&a.enable(5),A.morphTargets&&a.enable(6),A.morphNormals&&a.enable(7),A.morphColors&&a.enable(8),A.premultipliedAlpha&&a.enable(9),A.shadowMapEnabled&&a.enable(10),A.doubleSided&&a.enable(11),A.flipSided&&a.enable(12),A.useDepthPacking&&a.enable(13),A.dithering&&a.enable(14),A.transmission&&a.enable(15),A.sheen&&a.enable(16),A.opaque&&a.enable(17),A.pointsUvs&&a.enable(18),A.decodeVideoTexture&&a.enable(19),A.decodeVideoTextureEmissive&&a.enable(20),A.alphaToCoverage&&a.enable(21),A.numLightProbeGrids>0&&a.enable(22),A.hasPositionAttribute&&a.enable(23),x.push(a.mask)}function y(x){const A=f[x.type];let I;if(A){const C=bn[A];I=gv.clone(C.uniforms)}else I=x.uniforms;return I}function _(x,A){let I=h.get(A);return I!==void 0?++I.usedTimes:(I=new fy(s,A,x,n),l.push(I),h.set(A,I)),I}function w(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 E(x){o.remove(x)}function R(){o.dispose()}return{getParameters:v,getProgramCacheKey:m,getUniforms:y,acquireProgram:_,releaseProgram:w,releaseShaderCache:E,programs:l,dispose:R}}function xy(){let s=new WeakMap;function e(a){return s.has(a)}function t(a){let o=s.get(a);return o===void 0&&(o={},s.set(a,o)),o}function i(a){s.delete(a)}function n(a,o,c){s.get(a)[o]=c}function r(){s=new WeakMap}return{has:e,get:t,remove:i,update:n,dispose:r}}function _y(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.materialVariant!==e.materialVariant?s.materialVariant-e.materialVariant:s.z!==e.z?s.z-e.z:s.id-e.id}function Rf(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function Df(){const s=[];let e=0;const t=[],i=[],n=[];function r(){e=0,t.length=0,i.length=0,n.length=0}function a(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function o(d,f,p,v,m,g){let b=s[e];return b===void 0?(b={id:d.id,object:d,geometry:f,material:p,materialVariant:a(d),groupOrder:v,renderOrder:d.renderOrder,z:m,group:g},s[e]=b):(b.id=d.id,b.object=d,b.geometry=f,b.material=p,b.materialVariant=a(d),b.groupOrder=v,b.renderOrder=d.renderOrder,b.z=m,b.group=g),e++,b}function c(d,f,p,v,m,g){const b=o(d,f,p,v,m,g);p.transmission>0?i.push(b):p.transparent===!0?n.push(b):t.push(b)}function l(d,f,p,v,m,g){const b=o(d,f,p,v,m,g);p.transmission>0?i.unshift(b):p.transparent===!0?n.unshift(b):t.unshift(b)}function h(d,f,p){t.length>1&&t.sort(d||_y),i.length>1&&i.sort(f||Rf),n.length>1&&n.sort(f||Rf),p&&(t.reverse(),i.reverse(),n.reverse())}function u(){for(let d=e,f=s.length;d<f;d++){const p=s[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:r,push:c,unshift:l,finish:u,sort:h}}function yy(){let s=new WeakMap;function e(i,n){const r=s.get(i);let a;return r===void 0?(a=new Df,s.set(i,[a])):n>=r.length?(a=new Df,r.push(a)):a=r[n],a}function t(){s=new WeakMap}return{get:e,dispose:t}}function Sy(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new D,color:new oe};break;case"SpotLight":t={position:new D,direction:new D,color:new oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new D,color:new oe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new D,skyColor:new oe,groundColor:new oe};break;case"RectAreaLight":t={color:new oe,position:new D,halfWidth:new D,halfHeight:new D};break}return s[e.id]=t,t}}}function by(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let wy=0;function Ey(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function Ay(s){const e=new Sy,t=by(),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,r=new Ye,a=new Ye;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,b=0,y=0,_=0,w=0,E=0,R=0;l.sort(Ey);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===Zs?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);R++}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,b++}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[w]=C.map,w++,k.updateMatrices(C),C.castShadow&&E++),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,_++}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,y++}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&&(s.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!==b||x.numPointShadows!==y||x.numSpotShadows!==_||x.numSpotMaps!==w||x.numLightProbes!==R)&&(i.directional.length=f,i.spot.length=v,i.rectArea.length=m,i.point.length=p,i.hemi.length=g,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.pointShadow.length=y,i.pointShadowMap.length=y,i.spotShadow.length=_,i.spotShadowMap.length=_,i.directionalShadowMatrix.length=b,i.pointShadowMatrix.length=y,i.spotLightMatrix.length=_+w-E,i.spotLightMap.length=w,i.numSpotLightShadowsWithMaps=E,i.numLightProbes=R,x.directionalLength=f,x.pointLength=p,x.spotLength=v,x.rectAreaLength=m,x.hemiLength=g,x.numDirectionalShadows=b,x.numPointShadows=y,x.numSpotShadows=_,x.numSpotMaps=w,x.numLightProbes=R,i.version=wy++)}function c(l,h){let u=0,d=0,f=0,p=0,v=0;const m=h.matrixWorldInverse;for(let g=0,b=l.length;g<b;g++){const y=l[g];if(y.isDirectionalLight){const _=i.directional[u];_.direction.setFromMatrixPosition(y.matrixWorld),n.setFromMatrixPosition(y.target.matrixWorld),_.direction.sub(n),_.direction.transformDirection(m),u++}else if(y.isSpotLight){const _=i.spot[f];_.position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(m),_.direction.setFromMatrixPosition(y.matrixWorld),n.setFromMatrixPosition(y.target.matrixWorld),_.direction.sub(n),_.direction.transformDirection(m),f++}else if(y.isRectAreaLight){const _=i.rectArea[p];_.position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(m),a.identity(),r.copy(y.matrixWorld),r.premultiply(m),a.extractRotation(r),_.halfWidth.set(y.width*.5,0,0),_.halfHeight.set(0,y.height*.5,0),_.halfWidth.applyMatrix4(a),_.halfHeight.applyMatrix4(a),p++}else if(y.isPointLight){const _=i.point[d];_.position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(m),d++}else if(y.isHemisphereLight){const _=i.hemi[v];_.direction.setFromMatrixPosition(y.matrixWorld),_.direction.transformDirection(m),v++}}}return{setup:o,setupView:c,state:i}}function Cf(s){const e=new Ay(s),t=[],i=[],n=[];function r(d){u.camera=d,t.length=0,i.length=0,n.length=0}function a(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:r,state:u,setupLights:l,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function Ty(s){let e=new WeakMap;function t(n,r=0){const a=e.get(n);let o;return a===void 0?(o=new Cf(s),e.set(n,[o])):r>=a.length?(o=new Cf(s),a.push(o)):o=a[r],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const Ry=`void main() {
|
|
4691
|
+
`+ie)}else N!==""?we("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(E),n.deleteShader(w),x=new pc(n,v),A=j_(n,v)}let x;this.getUniforms=function(){return x===void 0&&R(this),x};let A;this.getAttributes=function(){return A===void 0&&R(this),A};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=n.getProgramParameter(v,G_)),I},this.destroy=function(){i.releaseStatesOfProgram(this),n.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=V_++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=E,this.fragmentShader=w,this}let py=0;class my{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 gy(e),t.set(e,i)),i}}class gy{constructor(e){this.id=py++,this.code=e,this.usedTimes=0}}function vy(s){return s===Zs||s===Sc||s===bc}function My(s,e,t,i,n,r){const a=new ad,o=new my,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===Xc?K.image.height:null,J=f[x.type];x.precision!==null&&(d=i.getMaxPrecision(x.precision),d!==x.precision&&we("WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead."));const ie=N.morphAttributes.position||N.morphAttributes.normal||N.morphAttributes.color,ae=ie!==void 0?ie.length:0;let Be=0;N.morphAttributes.position!==void 0&&(Be=1),N.morphAttributes.normal!==void 0&&(Be=2),N.morphAttributes.color!==void 0&&(Be=3);let je,Ge,Y,re;if(J){const ye=bn[J];je=ye.vertexShader,Ge=ye.fragmentShader}else{je=x.vertexShader,Ge=x.fragmentShader;const ye=o.getVertexShaderStage(x),Ut=o.getFragmentShaderStage(x);o.update(x,ye,Ut),Y=ye.id,re=Ut.id}const ne=s.getRenderTarget(),B=s.state.buffers.depth.getReversed(),Ee=P.isInstancedMesh===!0,Pe=P.isBatchedMesh===!0,Re=!!x.map,xe=!!x.matcap,Ne=!!K,Oe=!!x.aoMap,Ue=!!x.lightMap,ct=!!x.bumpMap&&x.wireframe===!1,lt=!!x.normalMap,Nt=!!x.displacementMap,Tt=!!x.emissiveMap,Ot=!!x.metalnessMap,Wt=!!x.roughnessMap,O=x.anisotropy>0,Ri=x.clearcoat>0,ht=x.dispersion>0,T=x.iridescence>0,M=x.sheen>0,F=x.transmission>0,W=O&&!!x.anisotropyMap,$=Ri&&!!x.clearcoatMap,se=Ri&&!!x.clearcoatNormalMap,le=Ri&&!!x.clearcoatRoughnessMap,Z=T&&!!x.iridescenceMap,Q=T&&!!x.iridescenceThicknessMap,he=M&&!!x.sheenColorMap,De=M&&!!x.sheenRoughnessMap,fe=!!x.specularMap,ue=!!x.specularColorMap,Le=!!x.specularIntensityMap,Fe=F&&!!x.transmissionMap,Xe=F&&!!x.thicknessMap,L=!!x.gradientMap,ce=!!x.alphaMap,j=x.alphaTest>0,de=!!x.alphaHash,ve=!!x.extensions;let te=In;x.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(te=s.toneMapping);const Te={shaderID:J,shaderType:x.type,shaderName:x.name,vertexShader:je,fragmentShader:Ge,defines:x.defines,customVertexShaderID:Y,customFragmentShaderID:re,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,batching:Pe,batchingColor:Pe&&P._colorsTexture!==null,instancing:Ee,instancingColor:Ee&&P.instanceColor!==null,instancingMorph:Ee&&P.morphTexture!==null,outputColorSpace:ne===null?s.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:et.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Re,matcap:xe,envMap:Ne,envMapMode:Ne&&K.mapping,envMapCubeUVHeight:ee,aoMap:Oe,lightMap:Ue,bumpMap:ct,normalMap:lt,displacementMap:Nt,emissiveMap:Tt,normalMapObjectSpace:lt&&x.normalMapType===u2,normalMapTangentSpace:lt&&x.normalMapType===wc,packedNormalMap:lt&&x.normalMapType===wc&&vy(x.normalMap.format),metalnessMap:Ot,roughnessMap:Wt,anisotropy:O,anisotropyMap:W,clearcoat:Ri,clearcoatMap:$,clearcoatNormalMap:se,clearcoatRoughnessMap:le,dispersion:ht,iridescence:T,iridescenceMap:Z,iridescenceThicknessMap:Q,sheen:M,sheenColorMap:he,sheenRoughnessMap:De,specularMap:fe,specularColorMap:ue,specularIntensityMap:Le,transmission:F,transmissionMap:Fe,thicknessMap:Xe,gradientMap:L,opaque:x.transparent===!1&&x.blending===qs&&x.alphaToCoverage===!1,alphaMap:ce,alphaTest:j,alphaHash:de,combine:x.combine,mapUv:Re&&p(x.map.channel),aoMapUv:Oe&&p(x.aoMap.channel),lightMapUv:Ue&&p(x.lightMap.channel),bumpMapUv:ct&&p(x.bumpMap.channel),normalMapUv:lt&&p(x.normalMap.channel),displacementMapUv:Nt&&p(x.displacementMap.channel),emissiveMapUv:Tt&&p(x.emissiveMap.channel),metalnessMapUv:Ot&&p(x.metalnessMap.channel),roughnessMapUv:Wt&&p(x.roughnessMap.channel),anisotropyMapUv:W&&p(x.anisotropyMap.channel),clearcoatMapUv:$&&p(x.clearcoatMap.channel),clearcoatNormalMapUv:se&&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:De&&p(x.sheenRoughnessMap.channel),specularMapUv:fe&&p(x.specularMap.channel),specularColorMapUv:ue&&p(x.specularColorMap.channel),specularIntensityMapUv:Le&&p(x.specularIntensityMap.channel),transmissionMapUv:Fe&&p(x.transmissionMap.channel),thicknessMapUv:Xe&&p(x.thicknessMap.channel),alphaMapUv:ce&&p(x.alphaMap.channel),vertexTangents:!!N.attributes.tangent&&(lt||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&&(Re||ce),fog:!!z,useFog:x.fog===!0,fogExp2:!!z&&z.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||N.attributes.normal===void 0&<===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:B,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:ae,morphTextureStride:Be,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:r.numPlanes,numClipIntersection:r.numIntersection,dithering:x.dithering,shadowMapEnabled:s.shadowMap.enabled&&I.length>0,shadowMapType:s.shadowMap.type,toneMapping:te,decodeVideoTexture:Re&&x.map.isVideoTexture===!0&&et.getTransfer(x.map.colorSpace)===ut,decodeVideoTextureEmissive:Tt&&x.emissiveMap.isVideoTexture===!0&&et.getTransfer(x.emissiveMap.colorSpace)===ut,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===on,flipSided:x.side===It,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||Pe)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return Te.vertexUv1s=c.has(1),Te.vertexUv2s=c.has(2),Te.vertexUv3s=c.has(3),c.clear(),Te}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),b(A,x),A.push(s.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 b(x,A){a.disableAll(),A.instancing&&a.enable(0),A.instancingColor&&a.enable(1),A.instancingMorph&&a.enable(2),A.matcap&&a.enable(3),A.envMap&&a.enable(4),A.normalMapObjectSpace&&a.enable(5),A.normalMapTangentSpace&&a.enable(6),A.clearcoat&&a.enable(7),A.iridescence&&a.enable(8),A.alphaTest&&a.enable(9),A.vertexColors&&a.enable(10),A.vertexAlphas&&a.enable(11),A.vertexUv1s&&a.enable(12),A.vertexUv2s&&a.enable(13),A.vertexUv3s&&a.enable(14),A.vertexTangents&&a.enable(15),A.anisotropy&&a.enable(16),A.alphaHash&&a.enable(17),A.batching&&a.enable(18),A.dispersion&&a.enable(19),A.batchingColor&&a.enable(20),A.gradientMap&&a.enable(21),A.packedNormalMap&&a.enable(22),A.vertexNormals&&a.enable(23),x.push(a.mask),a.disableAll(),A.fog&&a.enable(0),A.useFog&&a.enable(1),A.flatShading&&a.enable(2),A.logarithmicDepthBuffer&&a.enable(3),A.reversedDepthBuffer&&a.enable(4),A.skinning&&a.enable(5),A.morphTargets&&a.enable(6),A.morphNormals&&a.enable(7),A.morphColors&&a.enable(8),A.premultipliedAlpha&&a.enable(9),A.shadowMapEnabled&&a.enable(10),A.doubleSided&&a.enable(11),A.flipSided&&a.enable(12),A.useDepthPacking&&a.enable(13),A.dithering&&a.enable(14),A.transmission&&a.enable(15),A.sheen&&a.enable(16),A.opaque&&a.enable(17),A.pointsUvs&&a.enable(18),A.decodeVideoTexture&&a.enable(19),A.decodeVideoTextureEmissive&&a.enable(20),A.alphaToCoverage&&a.enable(21),A.numLightProbeGrids>0&&a.enable(22),A.hasPositionAttribute&&a.enable(23),x.push(a.mask)}function y(x){const A=f[x.type];let I;if(A){const C=bn[A];I=gv.clone(C.uniforms)}else I=x.uniforms;return I}function _(x,A){let I=h.get(A);return I!==void 0?++I.usedTimes:(I=new fy(s,A,x,n),l.push(I),h.set(A,I)),I}function E(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 w(x){o.remove(x)}function R(){o.dispose()}return{getParameters:v,getProgramCacheKey:m,getUniforms:y,acquireProgram:_,releaseProgram:E,releaseShaderCache:w,programs:l,dispose:R}}function xy(){let s=new WeakMap;function e(a){return s.has(a)}function t(a){let o=s.get(a);return o===void 0&&(o={},s.set(a,o)),o}function i(a){s.delete(a)}function n(a,o,c){s.get(a)[o]=c}function r(){s=new WeakMap}return{has:e,get:t,remove:i,update:n,dispose:r}}function _y(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.materialVariant!==e.materialVariant?s.materialVariant-e.materialVariant:s.z!==e.z?s.z-e.z:s.id-e.id}function Rf(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function Df(){const s=[];let e=0;const t=[],i=[],n=[];function r(){e=0,t.length=0,i.length=0,n.length=0}function a(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function o(d,f,p,v,m,g){let b=s[e];return b===void 0?(b={id:d.id,object:d,geometry:f,material:p,materialVariant:a(d),groupOrder:v,renderOrder:d.renderOrder,z:m,group:g},s[e]=b):(b.id=d.id,b.object=d,b.geometry=f,b.material=p,b.materialVariant=a(d),b.groupOrder=v,b.renderOrder=d.renderOrder,b.z=m,b.group=g),e++,b}function c(d,f,p,v,m,g){const b=o(d,f,p,v,m,g);p.transmission>0?i.push(b):p.transparent===!0?n.push(b):t.push(b)}function l(d,f,p,v,m,g){const b=o(d,f,p,v,m,g);p.transmission>0?i.unshift(b):p.transparent===!0?n.unshift(b):t.unshift(b)}function h(d,f,p){t.length>1&&t.sort(d||_y),i.length>1&&i.sort(f||Rf),n.length>1&&n.sort(f||Rf),p&&(t.reverse(),i.reverse(),n.reverse())}function u(){for(let d=e,f=s.length;d<f;d++){const p=s[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:r,push:c,unshift:l,finish:u,sort:h}}function yy(){let s=new WeakMap;function e(i,n){const r=s.get(i);let a;return r===void 0?(a=new Df,s.set(i,[a])):n>=r.length?(a=new Df,r.push(a)):a=r[n],a}function t(){s=new WeakMap}return{get:e,dispose:t}}function Sy(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new D,color:new oe};break;case"SpotLight":t={position:new D,direction:new D,color:new oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new D,color:new oe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new D,skyColor:new oe,groundColor:new oe};break;case"RectAreaLight":t={color:new oe,position:new D,halfWidth:new D,halfHeight:new D};break}return s[e.id]=t,t}}}function by(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let Ey=0;function wy(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function Ay(s){const e=new Sy,t=by(),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,r=new Ye,a=new Ye;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,b=0,y=0,_=0,E=0,w=0,R=0;l.sort(wy);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===Zs?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);R++}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,b++}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[E]=C.map,E++,k.updateMatrices(C),C.castShadow&&w++),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,_++}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,y++}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&&(s.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!==b||x.numPointShadows!==y||x.numSpotShadows!==_||x.numSpotMaps!==E||x.numLightProbes!==R)&&(i.directional.length=f,i.spot.length=v,i.rectArea.length=m,i.point.length=p,i.hemi.length=g,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.pointShadow.length=y,i.pointShadowMap.length=y,i.spotShadow.length=_,i.spotShadowMap.length=_,i.directionalShadowMatrix.length=b,i.pointShadowMatrix.length=y,i.spotLightMatrix.length=_+E-w,i.spotLightMap.length=E,i.numSpotLightShadowsWithMaps=w,i.numLightProbes=R,x.directionalLength=f,x.pointLength=p,x.spotLength=v,x.rectAreaLength=m,x.hemiLength=g,x.numDirectionalShadows=b,x.numPointShadows=y,x.numSpotShadows=_,x.numSpotMaps=E,x.numLightProbes=R,i.version=Ey++)}function c(l,h){let u=0,d=0,f=0,p=0,v=0;const m=h.matrixWorldInverse;for(let g=0,b=l.length;g<b;g++){const y=l[g];if(y.isDirectionalLight){const _=i.directional[u];_.direction.setFromMatrixPosition(y.matrixWorld),n.setFromMatrixPosition(y.target.matrixWorld),_.direction.sub(n),_.direction.transformDirection(m),u++}else if(y.isSpotLight){const _=i.spot[f];_.position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(m),_.direction.setFromMatrixPosition(y.matrixWorld),n.setFromMatrixPosition(y.target.matrixWorld),_.direction.sub(n),_.direction.transformDirection(m),f++}else if(y.isRectAreaLight){const _=i.rectArea[p];_.position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(m),a.identity(),r.copy(y.matrixWorld),r.premultiply(m),a.extractRotation(r),_.halfWidth.set(y.width*.5,0,0),_.halfHeight.set(0,y.height*.5,0),_.halfWidth.applyMatrix4(a),_.halfHeight.applyMatrix4(a),p++}else if(y.isPointLight){const _=i.point[d];_.position.setFromMatrixPosition(y.matrixWorld),_.position.applyMatrix4(m),d++}else if(y.isHemisphereLight){const _=i.hemi[v];_.direction.setFromMatrixPosition(y.matrixWorld),_.direction.transformDirection(m),v++}}}return{setup:o,setupView:c,state:i}}function Cf(s){const e=new Ay(s),t=[],i=[],n=[];function r(d){u.camera=d,t.length=0,i.length=0,n.length=0}function a(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:r,state:u,setupLights:l,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function Ty(s){let e=new WeakMap;function t(n,r=0){const a=e.get(n);let o;return a===void 0?(o=new Cf(s),e.set(n,[o])):r>=a.length?(o=new Cf(s),a.push(o)):o=a[r],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const Ry=`void main() {
|
|
4692
4692
|
gl_Position = vec4( position, 1.0 );
|
|
4693
4693
|
}`,Dy=`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
|
-
}`,Cy=[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)],Iy=[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)],If=new Ye,Ma=new D,Wl=new D;function Py(s,e,t){let i=new cd;const n=new Ae,r=new Ae,a=new it,o=new _v,c=new yv,l={},h=t.maxTextureSize,u={[Es]:It,[It]:Es,[on]:on},d=new wt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ae},radius:{value:4}},vertexShader:Ry,fragmentShader:Dy}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const p=new bt;p.setAttribute("position",new ot(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new We(p,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Na;let g=this.type;this.render=function(E,R,x){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||E.length===0)return;this.type===G1&&(Ee("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Na);const A=s.getRenderTarget(),I=s.getActiveCubeFace(),C=s.getActiveMipmapLevel(),P=s.state;P.setBlending(Cn),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&&R.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=E.length;z<N;z++){const V=E[z],k=V.shadow;if(k===void 0){Ee("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),r.copy(k.mapSize),(n.x>h||n.y>h)&&(n.x>h&&(r.x=Math.floor(h/K.x),n.x=r.x*K.x,k.mapSize.x=r.x),n.y>h&&(r.y=Math.floor(h/K.y),n.y=r.y*K.y,k.mapSize.y=r.y));const ee=s.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===Aa){if(V.isPointLight){Ee("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}k.map=new ui(n.x,n.y,{format:Zs,type:$t,minFilter:at,magFilter:at,generateMipmaps:!1}),k.map.texture.name=V.name+".shadowMap",k.map.depthTexture=new Js(n.x,n.y,Ai),k.map.depthTexture.name=V.name+".shadowMapDepth",k.map.depthTexture.format=Jn,k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=Dt,k.map.depthTexture.magFilter=Dt}else V.isPointLight?(k.map=new gd(n.x),k.map.depthTexture=new pv(n.x,hn)):(k.map=new ui(n.x,n.y),k.map.depthTexture=new Js(n.x,n.y,hn)),k.map.depthTexture.name=V.name+".shadowMap",k.map.depthTexture.format=Jn,this.type===Na?(k.map.depthTexture.compareFunction=ee?nd:id,k.map.depthTexture.minFilter=at,k.map.depthTexture.magFilter=at):(k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=Dt,k.map.depthTexture.magFilter=Dt);k.camera.updateProjectionMatrix()}const J=k.map.isWebGLCubeRenderTarget?6:1;for(let ie=0;ie<J;ie++){if(k.map.isWebGLCubeRenderTarget)s.setRenderTarget(k.map,ie),s.clear();else{ie===0&&(s.setRenderTarget(k.map),s.clear());const ae=k.getViewport(ie);a.set(r.x*ae.x,r.y*ae.y,r.x*ae.z,r.y*ae.w),P.viewport(a)}if(V.isPointLight){const ae=k.camera,Be=k.matrix,je=V.distance||ae.far;je!==ae.far&&(ae.far=je,ae.updateProjectionMatrix()),Ma.setFromMatrixPosition(V.matrixWorld),ae.position.copy(Ma),Wl.copy(ae.position),Wl.add(Cy[ie]),ae.up.copy(Iy[ie]),ae.lookAt(Wl),ae.updateMatrixWorld(),Be.makeTranslation(-Ma.x,-Ma.y,-Ma.z),If.multiplyMatrices(ae.projectionMatrix,ae.matrixWorldInverse),k._frustum.setFromProjectionMatrix(If,ae.coordinateSystem,ae.reversedDepth)}else k.updateMatrices(V);i=k.getFrustum(),_(R,x,k.camera,V,this.type)}k.isPointLightShadow!==!0&&this.type===Aa&&b(k,x),k.needsUpdate=!1}g=this.type,m.needsUpdate=!1,s.setRenderTarget(A,I,C)};function b(E,R){const x=e.update(v);d.defines.VSM_SAMPLES!==E.blurSamples&&(d.defines.VSM_SAMPLES=E.blurSamples,f.defines.VSM_SAMPLES=E.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),E.mapPass===null&&(E.mapPass=new ui(n.x,n.y,{format:Zs,type:$t})),d.uniforms.shadow_pass.value=E.map.depthTexture,d.uniforms.resolution.value=E.mapSize,d.uniforms.radius.value=E.radius,s.setRenderTarget(E.mapPass),s.clear(),s.renderBufferDirect(R,null,x,d,v,null),f.uniforms.shadow_pass.value=E.mapPass.texture,f.uniforms.resolution.value=E.mapSize,f.uniforms.radius.value=E.radius,s.setRenderTarget(E.map),s.clear(),s.renderBufferDirect(R,null,x,f,v,null)}function y(E,R,x,A){let I=null;const C=x.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(C!==void 0)I=C;else if(I=x.isPointLight===!0?c:o,s.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){const P=I.uuid,X=R.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,R.addEventListener("dispose",w)),I=N}if(I.visible=R.visible,I.wireframe=R.wireframe,A===Aa?I.side=R.shadowSide!==null?R.shadowSide:R.side:I.side=R.shadowSide!==null?R.shadowSide:u[R.side],I.alphaMap=R.alphaMap,I.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,I.map=R.map,I.clipShadows=R.clipShadows,I.clippingPlanes=R.clippingPlanes,I.clipIntersection=R.clipIntersection,I.displacementMap=R.displacementMap,I.displacementScale=R.displacementScale,I.displacementBias=R.displacementBias,I.wireframeLinewidth=R.wireframeLinewidth,I.linewidth=R.linewidth,x.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const P=s.properties.get(I);P.light=x}return I}function _(E,R,x,A,I){if(E.visible===!1)return;if(E.layers.test(R.layers)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&I===Aa)&&(!E.frustumCulled||i.intersectsObject(E))){E.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,E.matrixWorld);const X=e.update(E),z=E.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=y(E,ee,A,I);E.onBeforeShadow(s,E,R,x,X,J,K),s.renderBufferDirect(x,null,X,J,E,K),E.onAfterShadow(s,E,R,x,X,J,K)}}}else if(z.visible){const N=y(E,z,A,I);E.onBeforeShadow(s,E,R,x,X,N,null),s.renderBufferDirect(x,null,X,N,E,null),E.onAfterShadow(s,E,R,x,X,N,null)}}const P=E.children;for(let X=0,z=P.length;X<z;X++)_(P[X],R,x,A,I)}function w(E){E.target.removeEventListener("dispose",w);for(const x in l){const A=l[x],I=E.target.uuid;I in A&&(A[I].dispose(),delete A[I])}}}function Ly(s,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&&(s.colorMask(ve,ve,ve,ve),j=ve)},setLocked:function(ve){L=ve},setClear:function(ve,te,Te,ye,Ut){Ut===!0&&(ve*=ye,te*=ye,Te*=ye),ce.set(ve,te,Te,ye),de.equals(ce)===!1&&(s.clearColor(ve,te,Te,ye),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 Te=e.get("EXT_clip_control");te?Te.clipControlEXT(Te.LOWER_LEFT_EXT,Te.ZERO_TO_ONE_EXT):Te.clipControlEXT(Te.LOWER_LEFT_EXT,Te.NEGATIVE_ONE_TO_ONE_EXT),ce=te;const ye=ve;ve=null,this.setClear(ye)}},getReversed:function(){return ce},setTest:function(te){te?ne(s.DEPTH_TEST):B(s.DEPTH_TEST)},setMask:function(te){j!==te&&!L&&(s.depthMask(te),j=te)},setFunc:function(te){if(ce&&(te=S2[te]),de!==te){switch(te){case wh:s.depthFunc(s.NEVER);break;case Eh:s.depthFunc(s.ALWAYS);break;case Ah:s.depthFunc(s.LESS);break;case Zr:s.depthFunc(s.LEQUAL);break;case Th:s.depthFunc(s.EQUAL);break;case Rh:s.depthFunc(s.GEQUAL);break;case Dh:s.depthFunc(s.GREATER);break;case Ch:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}de=te}},setLocked:function(te){L=te},setClear:function(te){ve!==te&&(ve=te,ce&&(te=1-te),s.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,Te=null,ye=null,Ut=null;return{setTest:function(xt){L||(xt?ne(s.STENCIL_TEST):B(s.STENCIL_TEST))},setMask:function(xt){ce!==xt&&!L&&(s.stencilMask(xt),ce=xt)},setFunc:function(xt,pn,mn){(j!==xt||de!==pn||ve!==mn)&&(s.stencilFunc(xt,pn,mn),j=xt,de=pn,ve=mn)},setOp:function(xt,pn,mn){(te!==xt||Te!==pn||ye!==mn)&&(s.stencilOp(xt,pn,mn),te=xt,Te=pn,ye=mn)},setLocked:function(xt){L=xt},setClear:function(xt){Ut!==xt&&(s.clearStencil(xt),Ut=xt)},reset:function(){L=!1,ce=null,j=null,de=null,ve=null,te=null,Te=null,ye=null,Ut=null}}}const r=new t,a=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,b=null,y=null,_=null,w=null,E=null,R=null,x=new oe(0,0,0),A=0,I=!1,C=null,P=null,X=null,z=null,N=null;const V=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let k=!1,K=0;const ee=s.getParameter(s.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 ae=s.getParameter(s.SCISSOR_BOX),Be=s.getParameter(s.VIEWPORT),je=new it().fromArray(ae),Ge=new it().fromArray(Be);function Y(L,ce,j,de){const ve=new Uint8Array(4),te=s.createTexture();s.bindTexture(L,te),s.texParameteri(L,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(L,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let Te=0;Te<j;Te++)L===s.TEXTURE_3D||L===s.TEXTURE_2D_ARRAY?s.texImage3D(ce,0,s.RGBA,1,1,de,0,s.RGBA,s.UNSIGNED_BYTE,ve):s.texImage2D(ce+Te,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,ve);return te}const re={};re[s.TEXTURE_2D]=Y(s.TEXTURE_2D,s.TEXTURE_2D,1),re[s.TEXTURE_CUBE_MAP]=Y(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[s.TEXTURE_2D_ARRAY]=Y(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),re[s.TEXTURE_3D]=Y(s.TEXTURE_3D,s.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ne(s.DEPTH_TEST),a.setFunc(Zr),ct(!1),lt(h0),ne(s.CULL_FACE),Oe(Cn);function ne(L){h[L]!==!0&&(s.enable(L),h[L]=!0)}function B(L){h[L]!==!1&&(s.disable(L),h[L]=!1)}function we(L,ce){return d[L]!==ce?(s.bindFramebuffer(L,ce),d[L]=ce,L===s.DRAW_FRAMEBUFFER&&(d[s.FRAMEBUFFER]=ce),L===s.FRAMEBUFFER&&(d[s.DRAW_FRAMEBUFFER]=ce),!0):!1}function Pe(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]!==s.COLOR_ATTACHMENT0){for(let te=0,Te=ve.length;te<Te;te++)j[te]=s.COLOR_ATTACHMENT0+te;j.length=ve.length,de=!0}}else j[0]!==s.BACK&&(j[0]=s.BACK,de=!0);de&&s.drawBuffers(j)}function Re(L){return v!==L?(s.useProgram(L),v=L,!0):!1}const xe={[Fs]:s.FUNC_ADD,[V1]:s.FUNC_SUBTRACT,[W1]:s.FUNC_REVERSE_SUBTRACT};xe[X1]=s.MIN,xe[q1]=s.MAX;const Ne={[Y1]:s.ZERO,[om]:s.ONE,[K1]:s.SRC_COLOR,[bh]:s.SRC_ALPHA,[e2]:s.SRC_ALPHA_SATURATE,[j1]:s.DST_COLOR,[Z1]:s.DST_ALPHA,[$1]:s.ONE_MINUS_SRC_COLOR,[yc]:s.ONE_MINUS_SRC_ALPHA,[Q1]:s.ONE_MINUS_DST_COLOR,[J1]:s.ONE_MINUS_DST_ALPHA,[t2]:s.CONSTANT_COLOR,[i2]:s.ONE_MINUS_CONSTANT_COLOR,[n2]:s.CONSTANT_ALPHA,[s2]:s.ONE_MINUS_CONSTANT_ALPHA};function Oe(L,ce,j,de,ve,te,Te,ye,Ut,xt){if(L===Cn){m===!0&&(B(s.BLEND),m=!1);return}if(m===!1&&(ne(s.BLEND),m=!0),L!==am){if(L!==g||xt!==I){if((b!==Fs||w!==Fs)&&(s.blendEquation(s.FUNC_ADD),b=Fs,w=Fs),xt)switch(L){case qs:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Hi:s.blendFunc(s.ONE,s.ONE);break;case u0:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case d0:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:ke("WebGLState: Invalid blending: ",L);break}else switch(L){case qs:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Hi:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case u0:ke("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case d0:ke("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ke("WebGLState: Invalid blending: ",L);break}y=null,_=null,E=null,R=null,x.set(0,0,0),A=0,g=L,I=xt}return}ve=ve||ce,te=te||j,Te=Te||de,(ce!==b||ve!==w)&&(s.blendEquationSeparate(xe[ce],xe[ve]),b=ce,w=ve),(j!==y||de!==_||te!==E||Te!==R)&&(s.blendFuncSeparate(Ne[j],Ne[de],Ne[te],Ne[Te]),y=j,_=de,E=te,R=Te),(ye.equals(x)===!1||Ut!==A)&&(s.blendColor(ye.r,ye.g,ye.b,Ut),x.copy(ye),A=Ut),g=L,I=!1}function Ue(L,ce){L.side===on?B(s.CULL_FACE):ne(s.CULL_FACE);let j=L.side===It;ce&&(j=!j),ct(j),L.blending===qs&&L.transparent===!1?Oe(Cn):Oe(L.blending,L.blendEquation,L.blendSrc,L.blendDst,L.blendEquationAlpha,L.blendSrcAlpha,L.blendDstAlpha,L.blendColor,L.blendAlpha,L.premultipliedAlpha),a.setFunc(L.depthFunc),a.setTest(L.depthTest),a.setMask(L.depthWrite),r.setMask(L.colorWrite);const 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)),Tt(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?ne(s.SAMPLE_ALPHA_TO_COVERAGE):B(s.SAMPLE_ALPHA_TO_COVERAGE)}function ct(L){C!==L&&(L?s.frontFace(s.CW):s.frontFace(s.CCW),C=L)}function lt(L){L!==B1?(ne(s.CULL_FACE),L!==P&&(L===h0?s.cullFace(s.BACK):L===H1?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):B(s.CULL_FACE),P=L}function Nt(L){L!==X&&(k&&s.lineWidth(L),X=L)}function Tt(L,ce,j){L?(ne(s.POLYGON_OFFSET_FILL),(z!==ce||N!==j)&&(z=ce,N=j,a.getReversed()&&(ce=-ce),s.polygonOffset(ce,j))):B(s.POLYGON_OFFSET_FILL)}function Ot(L){L?ne(s.SCISSOR_TEST):B(s.SCISSOR_TEST)}function Wt(L){L===void 0&&(L=s.TEXTURE0+V-1),J!==L&&(s.activeTexture(L),J=L)}function O(L,ce,j){j===void 0&&(J===null?j=s.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&&(s.activeTexture(j),J=j),s.bindTexture(L,ce||re[L]),de.type=L,de.texture=ce)}function Ti(){const L=ie[J];L!==void 0&&L.type!==void 0&&(s.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function ht(){try{s.compressedTexImage2D(...arguments)}catch(L){ke("WebGLState:",L)}}function T(){try{s.compressedTexImage3D(...arguments)}catch(L){ke("WebGLState:",L)}}function M(){try{s.texSubImage2D(...arguments)}catch(L){ke("WebGLState:",L)}}function F(){try{s.texSubImage3D(...arguments)}catch(L){ke("WebGLState:",L)}}function W(){try{s.compressedTexSubImage2D(...arguments)}catch(L){ke("WebGLState:",L)}}function $(){try{s.compressedTexSubImage3D(...arguments)}catch(L){ke("WebGLState:",L)}}function se(){try{s.texStorage2D(...arguments)}catch(L){ke("WebGLState:",L)}}function le(){try{s.texStorage3D(...arguments)}catch(L){ke("WebGLState:",L)}}function Z(){try{s.texImage2D(...arguments)}catch(L){ke("WebGLState:",L)}}function Q(){try{s.texImage3D(...arguments)}catch(L){ke("WebGLState:",L)}}function he(L){return u[L]!==void 0?u[L]:s.getParameter(L)}function De(L,ce){u[L]!==ce&&(s.pixelStorei(L,ce),u[L]=ce)}function fe(L){je.equals(L)===!1&&(s.scissor(L.x,L.y,L.z,L.w),je.copy(L))}function ue(L){Ge.equals(L)===!1&&(s.viewport(L.x,L.y,L.z,L.w),Ge.copy(L))}function Le(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=s.getUniformBlockIndex(ce,L.name),j.set(L,de))}function Fe(L,ce){const de=l.get(ce).get(L);c.get(ce)!==de&&(s.uniformBlockBinding(ce,de,L.__bindingPointIndex),c.set(ce,de))}function Xe(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),a.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),s.pixelStorei(s.PACK_ALIGNMENT,4),s.pixelStorei(s.UNPACK_ALIGNMENT,4),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!1),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.BROWSER_DEFAULT_WEBGL),s.pixelStorei(s.PACK_ROW_LENGTH,0),s.pixelStorei(s.PACK_SKIP_PIXELS,0),s.pixelStorei(s.PACK_SKIP_ROWS,0),s.pixelStorei(s.UNPACK_ROW_LENGTH,0),s.pixelStorei(s.UNPACK_IMAGE_HEIGHT,0),s.pixelStorei(s.UNPACK_SKIP_PIXELS,0),s.pixelStorei(s.UNPACK_SKIP_ROWS,0),s.pixelStorei(s.UNPACK_SKIP_IMAGES,0),h={},u={},J=null,ie={},d={},f=new WeakMap,p=[],v=null,m=!1,g=null,b=null,y=null,_=null,w=null,E=null,R=null,x=new oe(0,0,0),A=0,I=!1,C=null,P=null,X=null,z=null,N=null,je.set(0,0,s.canvas.width,s.canvas.height),Ge.set(0,0,s.canvas.width,s.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:ne,disable:B,bindFramebuffer:we,drawBuffers:Pe,useProgram:Re,setBlending:Oe,setMaterial:Ue,setFlipSided:ct,setCullFace:lt,setLineWidth:Nt,setPolygonOffset:Tt,setScissorTest:Ot,activeTexture:Wt,bindTexture:O,unbindTexture:Ti,compressedTexImage2D:ht,compressedTexImage3D:T,texImage2D:Z,texImage3D:Q,pixelStorei:De,getParameter:he,updateUBOMapping:Le,uniformBlockBinding:Fe,texStorage2D:se,texStorage3D:le,texSubImage2D:M,texSubImage3D:F,compressedTexSubImage2D:W,compressedTexSubImage3D:$,scissor:fe,viewport:ue,reset:Xe}}function Ny(s,e,t,i,n,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ae,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(T,M){return p?new OffscreenCanvas(T,M):Za("canvas")}function m(T,M,F){let W=1;const $=ht(T);if(($.width>F||$.height>F)&&(W=F/Math.max($.width,$.height)),W<1)if(typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&T instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&T instanceof ImageBitmap||typeof VideoFrame<"u"&&T instanceof VideoFrame){const se=Math.floor(W*$.width),le=Math.floor(W*$.height);d===void 0&&(d=v(se,le));const Z=M?v(se,le):d;return Z.width=se,Z.height=le,Z.getContext("2d").drawImage(T,0,0,se,le),Ee("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+se+"x"+le+")."),Z}else return"data"in T&&Ee("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),T;return T}function g(T){return T.generateMipmaps}function b(T){s.generateMipmap(T)}function y(T){return T.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?s.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function _(T,M,F,W,$,se=!1){if(T!==null){if(s[T]!==void 0)return s[T];Ee("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let le;W&&(le=e.get("EXT_texture_norm16"),le||Ee("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Z=M;if(M===s.RED&&(F===s.FLOAT&&(Z=s.R32F),F===s.HALF_FLOAT&&(Z=s.R16F),F===s.UNSIGNED_BYTE&&(Z=s.R8),F===s.UNSIGNED_SHORT&&le&&(Z=le.R16_EXT),F===s.SHORT&&le&&(Z=le.R16_SNORM_EXT)),M===s.RED_INTEGER&&(F===s.UNSIGNED_BYTE&&(Z=s.R8UI),F===s.UNSIGNED_SHORT&&(Z=s.R16UI),F===s.UNSIGNED_INT&&(Z=s.R32UI),F===s.BYTE&&(Z=s.R8I),F===s.SHORT&&(Z=s.R16I),F===s.INT&&(Z=s.R32I)),M===s.RG&&(F===s.FLOAT&&(Z=s.RG32F),F===s.HALF_FLOAT&&(Z=s.RG16F),F===s.UNSIGNED_BYTE&&(Z=s.RG8),F===s.UNSIGNED_SHORT&&le&&(Z=le.RG16_EXT),F===s.SHORT&&le&&(Z=le.RG16_SNORM_EXT)),M===s.RG_INTEGER&&(F===s.UNSIGNED_BYTE&&(Z=s.RG8UI),F===s.UNSIGNED_SHORT&&(Z=s.RG16UI),F===s.UNSIGNED_INT&&(Z=s.RG32UI),F===s.BYTE&&(Z=s.RG8I),F===s.SHORT&&(Z=s.RG16I),F===s.INT&&(Z=s.RG32I)),M===s.RGB_INTEGER&&(F===s.UNSIGNED_BYTE&&(Z=s.RGB8UI),F===s.UNSIGNED_SHORT&&(Z=s.RGB16UI),F===s.UNSIGNED_INT&&(Z=s.RGB32UI),F===s.BYTE&&(Z=s.RGB8I),F===s.SHORT&&(Z=s.RGB16I),F===s.INT&&(Z=s.RGB32I)),M===s.RGBA_INTEGER&&(F===s.UNSIGNED_BYTE&&(Z=s.RGBA8UI),F===s.UNSIGNED_SHORT&&(Z=s.RGBA16UI),F===s.UNSIGNED_INT&&(Z=s.RGBA32UI),F===s.BYTE&&(Z=s.RGBA8I),F===s.SHORT&&(Z=s.RGBA16I),F===s.INT&&(Z=s.RGBA32I)),M===s.RGB&&(F===s.UNSIGNED_SHORT&&le&&(Z=le.RGB16_EXT),F===s.SHORT&&le&&(Z=le.RGB16_SNORM_EXT),F===s.UNSIGNED_INT_5_9_9_9_REV&&(Z=s.RGB9_E5),F===s.UNSIGNED_INT_10F_11F_11F_REV&&(Z=s.R11F_G11F_B10F)),M===s.RGBA){const Q=se?Tc:et.getTransfer($);F===s.FLOAT&&(Z=s.RGBA32F),F===s.HALF_FLOAT&&(Z=s.RGBA16F),F===s.UNSIGNED_BYTE&&(Z=Q===ut?s.SRGB8_ALPHA8:s.RGBA8),F===s.UNSIGNED_SHORT&&le&&(Z=le.RGBA16_EXT),F===s.SHORT&&le&&(Z=le.RGBA16_SNORM_EXT),F===s.UNSIGNED_SHORT_4_4_4_4&&(Z=s.RGBA4),F===s.UNSIGNED_SHORT_5_5_5_1&&(Z=s.RGB5_A1)}return(Z===s.R16F||Z===s.R32F||Z===s.RG16F||Z===s.RG32F||Z===s.RGBA16F||Z===s.RGBA32F)&&e.get("EXT_color_buffer_float"),Z}function w(T,M){let F;return T?M===null||M===hn||M===Ka?F=s.DEPTH24_STENCIL8:M===Ai?F=s.DEPTH32F_STENCIL8:M===Ya&&(F=s.DEPTH24_STENCIL8,Ee("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):M===null||M===hn||M===Ka?F=s.DEPTH_COMPONENT24:M===Ai?F=s.DEPTH_COMPONENT32F:M===Ya&&(F=s.DEPTH_COMPONENT16),F}function E(T,M){return g(T)===!0||T.isFramebufferTexture&&T.minFilter!==Dt&&T.minFilter!==at?Math.log2(Math.max(M.width,M.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?M.mipmaps.length:1}function R(T){const M=T.target;M.removeEventListener("dispose",R),A(M),M.isVideoTexture&&h.delete(M),M.isHTMLTexture&&u.delete(M)}function x(T){const M=T.target;M.removeEventListener("dispose",x),C(M)}function A(T){const M=i.get(T);if(M.__webglInit===void 0)return;const F=T.source,W=f.get(F);if(W){const $=W[M.__cacheKey];$.usedTimes--,$.usedTimes===0&&I(T),Object.keys(W).length===0&&f.delete(F)}i.remove(T)}function I(T){const M=i.get(T);s.deleteTexture(M.__webglTexture);const F=T.source,W=f.get(F);delete W[M.__cacheKey],a.memory.textures--}function C(T){const M=i.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),i.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let W=0;W<6;W++){if(Array.isArray(M.__webglFramebuffer[W]))for(let $=0;$<M.__webglFramebuffer[W].length;$++)s.deleteFramebuffer(M.__webglFramebuffer[W][$]);else s.deleteFramebuffer(M.__webglFramebuffer[W]);M.__webglDepthbuffer&&s.deleteRenderbuffer(M.__webglDepthbuffer[W])}else{if(Array.isArray(M.__webglFramebuffer))for(let W=0;W<M.__webglFramebuffer.length;W++)s.deleteFramebuffer(M.__webglFramebuffer[W]);else s.deleteFramebuffer(M.__webglFramebuffer);if(M.__webglDepthbuffer&&s.deleteRenderbuffer(M.__webglDepthbuffer),M.__webglMultisampledFramebuffer&&s.deleteFramebuffer(M.__webglMultisampledFramebuffer),M.__webglColorRenderbuffer)for(let W=0;W<M.__webglColorRenderbuffer.length;W++)M.__webglColorRenderbuffer[W]&&s.deleteRenderbuffer(M.__webglColorRenderbuffer[W]);M.__webglDepthRenderbuffer&&s.deleteRenderbuffer(M.__webglDepthRenderbuffer)}const F=T.textures;for(let W=0,$=F.length;W<$;W++){const se=i.get(F[W]);se.__webglTexture&&(s.deleteTexture(se.__webglTexture),a.memory.textures--),i.remove(F[W])}i.remove(T)}let P=0;function X(){P=0}function z(){return P}function N(T){P=T}function V(){const T=P;return T>=n.maxTextures&&Ee("WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+n.maxTextures),P+=1,T}function k(T){const M=[];return M.push(T.wrapS),M.push(T.wrapT),M.push(T.wrapR||0),M.push(T.magFilter),M.push(T.minFilter),M.push(T.anisotropy),M.push(T.internalFormat),M.push(T.format),M.push(T.type),M.push(T.generateMipmaps),M.push(T.premultiplyAlpha),M.push(T.flipY),M.push(T.unpackAlignment),M.push(T.colorSpace),M.join()}function K(T,M){const F=i.get(T);if(T.isVideoTexture&&O(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&F.__version!==T.version){const W=T.image;if(W===null)Ee("WebGLRenderer: Texture marked for update but no image data found.");else if(W.complete===!1)Ee("WebGLRenderer: Texture marked for update but image is incomplete");else{B(F,T,M);return}}else T.isExternalTexture&&(F.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(s.TEXTURE_2D,F.__webglTexture,s.TEXTURE0+M)}function ee(T,M){const F=i.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&F.__version!==T.version){B(F,T,M);return}else T.isExternalTexture&&(F.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(s.TEXTURE_2D_ARRAY,F.__webglTexture,s.TEXTURE0+M)}function J(T,M){const F=i.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&F.__version!==T.version){B(F,T,M);return}t.bindTexture(s.TEXTURE_3D,F.__webglTexture,s.TEXTURE0+M)}function ie(T,M){const F=i.get(T);if(T.isCubeDepthTexture!==!0&&T.version>0&&F.__version!==T.version){we(F,T,M);return}t.bindTexture(s.TEXTURE_CUBE_MAP,F.__webglTexture,s.TEXTURE0+M)}const ae={[qa]:s.REPEAT,[Ei]:s.CLAMP_TO_EDGE,[Ih]:s.MIRRORED_REPEAT},Be={[Dt]:s.NEAREST,[c2]:s.NEAREST_MIPMAP_NEAREST,[po]:s.NEAREST_MIPMAP_LINEAR,[at]:s.LINEAR,[cl]:s.LINEAR_MIPMAP_NEAREST,[Gs]:s.LINEAR_MIPMAP_LINEAR},je={[d2]:s.NEVER,[v2]:s.ALWAYS,[f2]:s.LESS,[id]:s.LEQUAL,[p2]:s.EQUAL,[nd]:s.GEQUAL,[m2]:s.GREATER,[g2]:s.NOTEQUAL};function Ge(T,M){if(M.type===Ai&&e.has("OES_texture_float_linear")===!1&&(M.magFilter===at||M.magFilter===cl||M.magFilter===po||M.magFilter===Gs||M.minFilter===at||M.minFilter===cl||M.minFilter===po||M.minFilter===Gs)&&Ee("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(T,s.TEXTURE_WRAP_S,ae[M.wrapS]),s.texParameteri(T,s.TEXTURE_WRAP_T,ae[M.wrapT]),(T===s.TEXTURE_3D||T===s.TEXTURE_2D_ARRAY)&&s.texParameteri(T,s.TEXTURE_WRAP_R,ae[M.wrapR]),s.texParameteri(T,s.TEXTURE_MAG_FILTER,Be[M.magFilter]),s.texParameteri(T,s.TEXTURE_MIN_FILTER,Be[M.minFilter]),M.compareFunction&&(s.texParameteri(T,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(T,s.TEXTURE_COMPARE_FUNC,je[M.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(M.magFilter===Dt||M.minFilter!==po&&M.minFilter!==Gs||M.type===Ai&&e.has("OES_texture_float_linear")===!1)return;if(M.anisotropy>1||i.get(M).__currentAnisotropy){const F=e.get("EXT_texture_filter_anisotropic");s.texParameterf(T,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,n.getMaxAnisotropy())),i.get(M).__currentAnisotropy=M.anisotropy}}}function Y(T,M){let F=!1;T.__webglInit===void 0&&(T.__webglInit=!0,M.addEventListener("dispose",R));const W=M.source;let $=f.get(W);$===void 0&&($={},f.set(W,$));const se=k(M);if(se!==T.__cacheKey){$[se]===void 0&&($[se]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,F=!0),$[se].usedTimes++;const le=$[T.__cacheKey];le!==void 0&&($[T.__cacheKey].usedTimes--,le.usedTimes===0&&I(M)),T.__cacheKey=se,T.__webglTexture=$[se].texture}return F}function re(T,M,F){return Math.floor(Math.floor(T/F)/M)}function ne(T,M,F,W){const se=T.updateRanges;if(se.length===0)t.texSubImage2D(s.TEXTURE_2D,0,0,0,M.width,M.height,F,W,M.data);else{se.sort((De,fe)=>De.start-fe.start);let le=0;for(let De=1;De<se.length;De++){const fe=se[le],ue=se[De],Le=fe.start+fe.count,Fe=re(ue.start,M.width,4),Xe=re(fe.start,M.width,4);ue.start<=Le+1&&Fe===Xe&&re(ue.start+ue.count-1,M.width,4)===Fe?fe.count=Math.max(fe.count,ue.start+ue.count-fe.start):(++le,se[le]=ue)}se.length=le+1;const Z=t.getParameter(s.UNPACK_ROW_LENGTH),Q=t.getParameter(s.UNPACK_SKIP_PIXELS),he=t.getParameter(s.UNPACK_SKIP_ROWS);t.pixelStorei(s.UNPACK_ROW_LENGTH,M.width);for(let De=0,fe=se.length;De<fe;De++){const ue=se[De],Le=Math.floor(ue.start/4),Fe=Math.ceil(ue.count/4),Xe=Le%M.width,L=Math.floor(Le/M.width),ce=Fe,j=1;t.pixelStorei(s.UNPACK_SKIP_PIXELS,Xe),t.pixelStorei(s.UNPACK_SKIP_ROWS,L),t.texSubImage2D(s.TEXTURE_2D,0,Xe,L,ce,j,F,W,M.data)}T.clearUpdateRanges(),t.pixelStorei(s.UNPACK_ROW_LENGTH,Z),t.pixelStorei(s.UNPACK_SKIP_PIXELS,Q),t.pixelStorei(s.UNPACK_SKIP_ROWS,he)}}function B(T,M,F){let W=s.TEXTURE_2D;(M.isDataArrayTexture||M.isCompressedArrayTexture)&&(W=s.TEXTURE_2D_ARRAY),M.isData3DTexture&&(W=s.TEXTURE_3D);const $=Y(T,M),se=M.source;t.bindTexture(W,T.__webglTexture,s.TEXTURE0+F);const le=i.get(se);if(se.version!==le.__version||$===!0){if(t.activeTexture(s.TEXTURE0+F),(typeof ImageBitmap<"u"&&M.image instanceof ImageBitmap)===!1){const j=et.getPrimaries(et.workingColorSpace),de=M.colorSpace===xs?null:et.getPrimaries(M.colorSpace),ve=M.colorSpace===xs||j===de?s.NONE:s.BROWSER_DEFAULT_WEBGL;t.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,M.flipY),t.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),t.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,ve)}t.pixelStorei(s.UNPACK_ALIGNMENT,M.unpackAlignment);let Q=m(M.image,!1,n.maxTextureSize);Q=Ti(M,Q);const he=r.convert(M.format,M.colorSpace),De=r.convert(M.type);let fe=_(M.internalFormat,he,De,M.normalized,M.colorSpace,M.isVideoTexture);Ge(W,M);let ue;const Le=M.mipmaps,Fe=M.isVideoTexture!==!0,Xe=le.__version===void 0||$===!0,L=se.dataReady,ce=E(M,Q);if(M.isDepthTexture)fe=w(M.format===Vs,M.type),Xe&&(Fe?t.texStorage2D(s.TEXTURE_2D,1,fe,Q.width,Q.height):t.texImage2D(s.TEXTURE_2D,0,fe,Q.width,Q.height,0,he,De,null));else if(M.isDataTexture)if(Le.length>0){Fe&&Xe&&t.texStorage2D(s.TEXTURE_2D,ce,fe,Le[0].width,Le[0].height);for(let j=0,de=Le.length;j<de;j++)ue=Le[j],Fe?L&&t.texSubImage2D(s.TEXTURE_2D,j,0,0,ue.width,ue.height,he,De,ue.data):t.texImage2D(s.TEXTURE_2D,j,fe,ue.width,ue.height,0,he,De,ue.data);M.generateMipmaps=!1}else Fe?(Xe&&t.texStorage2D(s.TEXTURE_2D,ce,fe,Q.width,Q.height),L&&ne(M,Q,he,De)):t.texImage2D(s.TEXTURE_2D,0,fe,Q.width,Q.height,0,he,De,Q.data);else if(M.isCompressedTexture)if(M.isCompressedArrayTexture){Fe&&Xe&&t.texStorage3D(s.TEXTURE_2D_ARRAY,ce,fe,Le[0].width,Le[0].height,Q.depth);for(let j=0,de=Le.length;j<de;j++)if(ue=Le[j],M.format!==xi)if(he!==null)if(Fe){if(L)if(M.layerUpdates.size>0){const ve=cf(ue.width,ue.height,M.format,M.type);for(const te of M.layerUpdates){const Te=ue.data.subarray(te*ve/ue.data.BYTES_PER_ELEMENT,(te+1)*ve/ue.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,j,0,0,te,ue.width,ue.height,1,he,Te)}M.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,j,0,0,0,ue.width,ue.height,Q.depth,he,ue.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,j,fe,ue.width,ue.height,Q.depth,0,ue.data,0,0);else Ee("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Fe?L&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,j,0,0,0,ue.width,ue.height,Q.depth,he,De,ue.data):t.texImage3D(s.TEXTURE_2D_ARRAY,j,fe,ue.width,ue.height,Q.depth,0,he,De,ue.data)}else{Fe&&Xe&&t.texStorage2D(s.TEXTURE_2D,ce,fe,Le[0].width,Le[0].height);for(let j=0,de=Le.length;j<de;j++)ue=Le[j],M.format!==xi?he!==null?Fe?L&&t.compressedTexSubImage2D(s.TEXTURE_2D,j,0,0,ue.width,ue.height,he,ue.data):t.compressedTexImage2D(s.TEXTURE_2D,j,fe,ue.width,ue.height,0,ue.data):Ee("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Fe?L&&t.texSubImage2D(s.TEXTURE_2D,j,0,0,ue.width,ue.height,he,De,ue.data):t.texImage2D(s.TEXTURE_2D,j,fe,ue.width,ue.height,0,he,De,ue.data)}else if(M.isDataArrayTexture)if(Fe){if(Xe&&t.texStorage3D(s.TEXTURE_2D_ARRAY,ce,fe,Q.width,Q.height,Q.depth),L)if(M.layerUpdates.size>0){const j=cf(Q.width,Q.height,M.format,M.type);for(const de of M.layerUpdates){const ve=Q.data.subarray(de*j/Q.data.BYTES_PER_ELEMENT,(de+1)*j/Q.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,de,Q.width,Q.height,1,he,De,ve)}M.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,he,De,Q.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,fe,Q.width,Q.height,Q.depth,0,he,De,Q.data);else if(M.isData3DTexture)Fe?(Xe&&t.texStorage3D(s.TEXTURE_3D,ce,fe,Q.width,Q.height,Q.depth),L&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,he,De,Q.data)):t.texImage3D(s.TEXTURE_3D,0,fe,Q.width,Q.height,Q.depth,0,he,De,Q.data);else if(M.isFramebufferTexture){if(Xe)if(Fe)t.texStorage2D(s.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(s.TEXTURE_2D,ve,fe,j,de,0,he,De,null),j>>=1,de>>=1}}else if(M.isHTMLTexture){if("texElementImage2D"in s){const j=s.canvas;if(j.hasAttribute("layoutsubtree")||j.setAttribute("layoutsubtree","true"),Q.parentNode!==j){j.appendChild(Q),u.add(M),j.onpaint=de=>{const ve=de.changedElements;for(const te of u)ve.includes(te.image)&&(te.needsUpdate=!0)},j.requestPaint();return}if(s.texElementImage2D.length===3)s.texElementImage2D(s.TEXTURE_2D,s.RGBA8,Q);else{const ve=s.RGBA,te=s.RGBA,Te=s.UNSIGNED_BYTE;s.texElementImage2D(s.TEXTURE_2D,0,ve,te,Te,Q)}s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE)}}else if(Le.length>0){if(Fe&&Xe){const j=ht(Le[0]);t.texStorage2D(s.TEXTURE_2D,ce,fe,j.width,j.height)}for(let j=0,de=Le.length;j<de;j++)ue=Le[j],Fe?L&&t.texSubImage2D(s.TEXTURE_2D,j,0,0,he,De,ue):t.texImage2D(s.TEXTURE_2D,j,fe,he,De,ue);M.generateMipmaps=!1}else if(Fe){if(Xe){const j=ht(Q);t.texStorage2D(s.TEXTURE_2D,ce,fe,j.width,j.height)}L&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,he,De,Q)}else t.texImage2D(s.TEXTURE_2D,0,fe,he,De,Q);g(M)&&b(W),le.__version=se.version,M.onUpdate&&M.onUpdate(M)}T.__version=M.version}function we(T,M,F){if(M.image.length!==6)return;const W=Y(T,M),$=M.source;t.bindTexture(s.TEXTURE_CUBE_MAP,T.__webglTexture,s.TEXTURE0+F);const se=i.get($);if($.version!==se.__version||W===!0){t.activeTexture(s.TEXTURE0+F);const le=et.getPrimaries(et.workingColorSpace),Z=M.colorSpace===xs?null:et.getPrimaries(M.colorSpace),Q=M.colorSpace===xs||le===Z?s.NONE:s.BROWSER_DEFAULT_WEBGL;t.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,M.flipY),t.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),t.pixelStorei(s.UNPACK_ALIGNMENT,M.unpackAlignment),t.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);const he=M.isCompressedTexture||M.image[0].isCompressedTexture,De=M.image[0]&&M.image[0].isDataTexture,fe=[];for(let te=0;te<6;te++)!he&&!De?fe[te]=m(M.image[te],!0,n.maxCubemapSize):fe[te]=De?M.image[te].image:M.image[te],fe[te]=Ti(M,fe[te]);const ue=fe[0],Le=r.convert(M.format,M.colorSpace),Fe=r.convert(M.type),Xe=_(M.internalFormat,Le,Fe,M.normalized,M.colorSpace),L=M.isVideoTexture!==!0,ce=se.__version===void 0||W===!0,j=$.dataReady;let de=E(M,ue);Ge(s.TEXTURE_CUBE_MAP,M);let ve;if(he){L&&ce&&t.texStorage2D(s.TEXTURE_CUBE_MAP,de,Xe,ue.width,ue.height);for(let te=0;te<6;te++){ve=fe[te].mipmaps;for(let Te=0;Te<ve.length;Te++){const ye=ve[Te];M.format!==xi?Le!==null?L?j&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te,0,0,ye.width,ye.height,Le,ye.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te,Xe,ye.width,ye.height,0,ye.data):Ee("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?j&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te,0,0,ye.width,ye.height,Le,Fe,ye.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te,Xe,ye.width,ye.height,0,Le,Fe,ye.data)}}}else{if(ve=M.mipmaps,L&&ce){ve.length>0&&de++;const te=ht(fe[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,de,Xe,te.width,te.height)}for(let te=0;te<6;te++)if(De){L?j&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,fe[te].width,fe[te].height,Le,Fe,fe[te].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,Xe,fe[te].width,fe[te].height,0,Le,Fe,fe[te].data);for(let Te=0;Te<ve.length;Te++){const Ut=ve[Te].image[te].image;L?j&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te+1,0,0,Ut.width,Ut.height,Le,Fe,Ut.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te+1,Xe,Ut.width,Ut.height,0,Le,Fe,Ut.data)}}else{L?j&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,Le,Fe,fe[te]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,Xe,Le,Fe,fe[te]);for(let Te=0;Te<ve.length;Te++){const ye=ve[Te];L?j&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te+1,0,0,Le,Fe,ye.image[te]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te+1,Xe,Le,Fe,ye.image[te])}}}g(M)&&b(s.TEXTURE_CUBE_MAP),se.__version=$.version,M.onUpdate&&M.onUpdate(M)}T.__version=M.version}function Pe(T,M,F,W,$,se){const le=r.convert(F.format,F.colorSpace),Z=r.convert(F.type),Q=_(F.internalFormat,le,Z,F.normalized,F.colorSpace),he=i.get(M),De=i.get(F);if(De.__renderTarget=M,!he.__hasExternalTextures){const fe=Math.max(1,M.width>>se),ue=Math.max(1,M.height>>se);$===s.TEXTURE_3D||$===s.TEXTURE_2D_ARRAY?t.texImage3D($,se,Q,fe,ue,M.depth,0,le,Z,null):t.texImage2D($,se,Q,fe,ue,0,le,Z,null)}t.bindFramebuffer(s.FRAMEBUFFER,T),Wt(M)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,W,$,De.__webglTexture,0,Ot(M)):($===s.TEXTURE_2D||$>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,W,$,De.__webglTexture,se),t.bindFramebuffer(s.FRAMEBUFFER,null)}function Re(T,M,F){if(s.bindRenderbuffer(s.RENDERBUFFER,T),M.depthBuffer){const W=M.depthTexture,$=W&&W.isDepthTexture?W.type:null,se=w(M.stencilBuffer,$),le=M.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;Wt(M)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Ot(M),se,M.width,M.height):F?s.renderbufferStorageMultisample(s.RENDERBUFFER,Ot(M),se,M.width,M.height):s.renderbufferStorage(s.RENDERBUFFER,se,M.width,M.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,le,s.RENDERBUFFER,T)}else{const W=M.textures;for(let $=0;$<W.length;$++){const se=W[$],le=r.convert(se.format,se.colorSpace),Z=r.convert(se.type),Q=_(se.internalFormat,le,Z,se.normalized,se.colorSpace);Wt(M)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Ot(M),Q,M.width,M.height):F?s.renderbufferStorageMultisample(s.RENDERBUFFER,Ot(M),Q,M.width,M.height):s.renderbufferStorage(s.RENDERBUFFER,Q,M.width,M.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function xe(T,M,F){const W=M.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(s.FRAMEBUFFER,T),!(M.depthTexture&&M.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const $=i.get(M.depthTexture);if($.__renderTarget=M,(!$.__webglTexture||M.depthTexture.image.width!==M.width||M.depthTexture.image.height!==M.height)&&(M.depthTexture.image.width=M.width,M.depthTexture.image.height=M.height,M.depthTexture.needsUpdate=!0),W){if($.__webglInit===void 0&&($.__webglInit=!0,M.depthTexture.addEventListener("dispose",R)),$.__webglTexture===void 0){$.__webglTexture=s.createTexture(),t.bindTexture(s.TEXTURE_CUBE_MAP,$.__webglTexture),Ge(s.TEXTURE_CUBE_MAP,M.depthTexture);const he=r.convert(M.depthTexture.format),De=r.convert(M.depthTexture.type);let fe;M.depthTexture.format===Jn?fe=s.DEPTH_COMPONENT24:M.depthTexture.format===Vs&&(fe=s.DEPTH24_STENCIL8);for(let ue=0;ue<6;ue++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ue,0,fe,M.width,M.height,0,he,De,null)}}else K(M.depthTexture,0);const se=$.__webglTexture,le=Ot(M),Z=W?s.TEXTURE_CUBE_MAP_POSITIVE_X+F:s.TEXTURE_2D,Q=M.depthTexture.format===Vs?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;if(M.depthTexture.format===Jn)Wt(M)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Q,Z,se,0,le):s.framebufferTexture2D(s.FRAMEBUFFER,Q,Z,se,0);else if(M.depthTexture.format===Vs)Wt(M)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Q,Z,se,0,le):s.framebufferTexture2D(s.FRAMEBUFFER,Q,Z,se,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ne(T){const M=i.get(T),F=T.isWebGLCubeRenderTarget===!0;if(M.__boundDepthTexture!==T.depthTexture){const W=T.depthTexture;if(M.__depthDisposeCallback&&M.__depthDisposeCallback(),W){const $=()=>{delete M.__boundDepthTexture,delete M.__depthDisposeCallback,W.removeEventListener("dispose",$)};W.addEventListener("dispose",$),M.__depthDisposeCallback=$}M.__boundDepthTexture=W}if(T.depthTexture&&!M.__autoAllocateDepthBuffer)if(F)for(let W=0;W<6;W++)xe(M.__webglFramebuffer[W],T,W);else{const W=T.texture.mipmaps;W&&W.length>0?xe(M.__webglFramebuffer[0],T,0):xe(M.__webglFramebuffer,T,0)}else if(F){M.__webglDepthbuffer=[];for(let W=0;W<6;W++)if(t.bindFramebuffer(s.FRAMEBUFFER,M.__webglFramebuffer[W]),M.__webglDepthbuffer[W]===void 0)M.__webglDepthbuffer[W]=s.createRenderbuffer(),Re(M.__webglDepthbuffer[W],T,!1);else{const $=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,se=M.__webglDepthbuffer[W];s.bindRenderbuffer(s.RENDERBUFFER,se),s.framebufferRenderbuffer(s.FRAMEBUFFER,$,s.RENDERBUFFER,se)}}else{const W=T.texture.mipmaps;if(W&&W.length>0?t.bindFramebuffer(s.FRAMEBUFFER,M.__webglFramebuffer[0]):t.bindFramebuffer(s.FRAMEBUFFER,M.__webglFramebuffer),M.__webglDepthbuffer===void 0)M.__webglDepthbuffer=s.createRenderbuffer(),Re(M.__webglDepthbuffer,T,!1);else{const $=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,se=M.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,se),s.framebufferRenderbuffer(s.FRAMEBUFFER,$,s.RENDERBUFFER,se)}}t.bindFramebuffer(s.FRAMEBUFFER,null)}function Oe(T,M,F){const W=i.get(T);M!==void 0&&Pe(W.__webglFramebuffer,T,T.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),F!==void 0&&Ne(T)}function Ue(T){const M=T.texture,F=i.get(T),W=i.get(M);T.addEventListener("dispose",x);const $=T.textures,se=T.isWebGLCubeRenderTarget===!0,le=$.length>1;if(le||(W.__webglTexture===void 0&&(W.__webglTexture=s.createTexture()),W.__version=M.version,a.memory.textures++),se){F.__webglFramebuffer=[];for(let Z=0;Z<6;Z++)if(M.mipmaps&&M.mipmaps.length>0){F.__webglFramebuffer[Z]=[];for(let Q=0;Q<M.mipmaps.length;Q++)F.__webglFramebuffer[Z][Q]=s.createFramebuffer()}else F.__webglFramebuffer[Z]=s.createFramebuffer()}else{if(M.mipmaps&&M.mipmaps.length>0){F.__webglFramebuffer=[];for(let Z=0;Z<M.mipmaps.length;Z++)F.__webglFramebuffer[Z]=s.createFramebuffer()}else F.__webglFramebuffer=s.createFramebuffer();if(le)for(let Z=0,Q=$.length;Z<Q;Z++){const he=i.get($[Z]);he.__webglTexture===void 0&&(he.__webglTexture=s.createTexture(),a.memory.textures++)}if(T.samples>0&&Wt(T)===!1){F.__webglMultisampledFramebuffer=s.createFramebuffer(),F.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let Z=0;Z<$.length;Z++){const Q=$[Z];F.__webglColorRenderbuffer[Z]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,F.__webglColorRenderbuffer[Z]);const he=r.convert(Q.format,Q.colorSpace),De=r.convert(Q.type),fe=_(Q.internalFormat,he,De,Q.normalized,Q.colorSpace,T.isXRRenderTarget===!0),ue=Ot(T);s.renderbufferStorageMultisample(s.RENDERBUFFER,ue,fe,T.width,T.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Z,s.RENDERBUFFER,F.__webglColorRenderbuffer[Z])}s.bindRenderbuffer(s.RENDERBUFFER,null),T.depthBuffer&&(F.__webglDepthRenderbuffer=s.createRenderbuffer(),Re(F.__webglDepthRenderbuffer,T,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(se){t.bindTexture(s.TEXTURE_CUBE_MAP,W.__webglTexture),Ge(s.TEXTURE_CUBE_MAP,M);for(let Z=0;Z<6;Z++)if(M.mipmaps&&M.mipmaps.length>0)for(let Q=0;Q<M.mipmaps.length;Q++)Pe(F.__webglFramebuffer[Z][Q],T,M,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Q);else Pe(F.__webglFramebuffer[Z],T,M,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0);g(M)&&b(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(le){for(let Z=0,Q=$.length;Z<Q;Z++){const he=$[Z],De=i.get(he);let fe=s.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(fe=T.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(fe,De.__webglTexture),Ge(fe,he),Pe(F.__webglFramebuffer,T,he,s.COLOR_ATTACHMENT0+Z,fe,0),g(he)&&b(fe)}t.unbindTexture()}else{let Z=s.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(Z=T.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(Z,W.__webglTexture),Ge(Z,M),M.mipmaps&&M.mipmaps.length>0)for(let Q=0;Q<M.mipmaps.length;Q++)Pe(F.__webglFramebuffer[Q],T,M,s.COLOR_ATTACHMENT0,Z,Q);else Pe(F.__webglFramebuffer,T,M,s.COLOR_ATTACHMENT0,Z,0);g(M)&&b(Z),t.unbindTexture()}T.depthBuffer&&Ne(T)}function ct(T){const M=T.textures;for(let F=0,W=M.length;F<W;F++){const $=M[F];if(g($)){const se=y(T),le=i.get($).__webglTexture;t.bindTexture(se,le),b(se),t.unbindTexture()}}}const lt=[],Nt=[];function Tt(T){if(T.samples>0){if(Wt(T)===!1){const M=T.textures,F=T.width,W=T.height;let $=s.COLOR_BUFFER_BIT;const se=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,le=i.get(T),Z=M.length>1;if(Z)for(let he=0;he<M.length;he++)t.bindFramebuffer(s.FRAMEBUFFER,le.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+he,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,le.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+he,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,le.__webglMultisampledFramebuffer);const Q=T.texture.mipmaps;Q&&Q.length>0?t.bindFramebuffer(s.DRAW_FRAMEBUFFER,le.__webglFramebuffer[0]):t.bindFramebuffer(s.DRAW_FRAMEBUFFER,le.__webglFramebuffer);for(let he=0;he<M.length;he++){if(T.resolveDepthBuffer&&(T.depthBuffer&&($|=s.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&($|=s.STENCIL_BUFFER_BIT)),Z){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,le.__webglColorRenderbuffer[he]);const De=i.get(M[he]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,De,0)}s.blitFramebuffer(0,0,F,W,0,0,F,W,$,s.NEAREST),c===!0&&(lt.length=0,Nt.length=0,lt.push(s.COLOR_ATTACHMENT0+he),T.depthBuffer&&T.resolveDepthBuffer===!1&&(lt.push(se),Nt.push(se),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,Nt)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,lt))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),Z)for(let he=0;he<M.length;he++){t.bindFramebuffer(s.FRAMEBUFFER,le.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+he,s.RENDERBUFFER,le.__webglColorRenderbuffer[he]);const De=i.get(M[he]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,le.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+he,s.TEXTURE_2D,De,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,le.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&c){const M=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[M])}}}function Ot(T){return Math.min(n.maxSamples,T.samples)}function Wt(T){const M=i.get(T);return T.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function O(T){const M=a.render.frame;h.get(T)!==M&&(h.set(T,M),T.update())}function Ti(T,M){const F=T.colorSpace,W=T.format,$=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||F!==Ac&&F!==xs&&(et.getTransfer(F)===ut?(W!==xi||$!==Bi)&&Ee("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ke("WebGLTextures: Unsupported texture color space:",F)),M}function ht(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(l.width=T.naturalWidth||T.width,l.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(l.width=T.displayWidth,l.height=T.displayHeight):(l.width=T.width,l.height=T.height),l}this.allocateTextureUnit=V,this.resetTextureUnits=X,this.getTextureUnits=z,this.setTextureUnits=N,this.setTexture2D=K,this.setTexture2DArray=ee,this.setTexture3D=J,this.setTextureCube=ie,this.rebindTextures=Oe,this.setupRenderTarget=Ue,this.updateRenderTargetMipmap=ct,this.updateMultisampleRenderTarget=Tt,this.setupDepthRenderbuffer=Ne,this.setupFrameBufferTexture=Pe,this.useMultisampledRTT=Wt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Oy(s,e){function t(i,n=xs){let r;const a=et.getTransfer(n);if(i===Bi)return s.UNSIGNED_BYTE;if(i===Ju)return s.UNSIGNED_SHORT_4_4_4_4;if(i===ju)return s.UNSIGNED_SHORT_5_5_5_1;if(i===Mm)return s.UNSIGNED_INT_5_9_9_9_REV;if(i===xm)return s.UNSIGNED_INT_10F_11F_11F_REV;if(i===gm)return s.BYTE;if(i===vm)return s.SHORT;if(i===Ya)return s.UNSIGNED_SHORT;if(i===Zu)return s.INT;if(i===hn)return s.UNSIGNED_INT;if(i===Ai)return s.FLOAT;if(i===$t)return s.HALF_FLOAT;if(i===_m)return s.ALPHA;if(i===ym)return s.RGB;if(i===xi)return s.RGBA;if(i===Jn)return s.DEPTH_COMPONENT;if(i===Vs)return s.DEPTH_STENCIL;if(i===qc)return s.RED;if(i===Qu)return s.RED_INTEGER;if(i===Zs)return s.RG;if(i===ed)return s.RG_INTEGER;if(i===td)return s.RGBA_INTEGER;if(i===hc||i===uc||i===dc||i===fc)if(a===ut)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===hc)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===uc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===dc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===fc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===hc)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===uc)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===dc)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===fc)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Ph||i===Lh||i===Nh||i===Oh)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===Ph)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Lh)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Nh)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Oh)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Uh||i===Fh||i===kh||i===zh||i===Bh||i===Sc||i===Hh)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===Uh||i===Fh)return a===ut?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===kh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===zh)return r.COMPRESSED_R11_EAC;if(i===Bh)return r.COMPRESSED_SIGNED_R11_EAC;if(i===Sc)return r.COMPRESSED_RG11_EAC;if(i===Hh)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Gh||i===Vh||i===Wh||i===Xh||i===qh||i===Yh||i===Kh||i===$h||i===Zh||i===Jh||i===jh||i===Qh||i===eu||i===tu)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===Gh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Vh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Wh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Xh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===qh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Yh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Kh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===$h)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Zh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Jh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===jh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Qh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===eu)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===tu)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===iu||i===nu||i===su)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===iu)return a===ut?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===nu)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===su)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===ru||i===au||i===bc||i===ou)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===ru)return r.COMPRESSED_RED_RGTC1_EXT;if(i===au)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===bc)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===ou)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Ka?s.UNSIGNED_INT_24_8:s[i]!==void 0?s[i]:null}return{convert:t}}const Uy=`
|
|
4718
|
+
}`,Cy=[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)],Iy=[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)],If=new Ye,Ma=new D,Wl=new D;function Py(s,e,t){let i=new cd;const n=new Ae,r=new Ae,a=new it,o=new _v,c=new yv,l={},h=t.maxTextureSize,u={[ws]:It,[It]:ws,[on]:on},d=new Et({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ae},radius:{value:4}},vertexShader:Ry,fragmentShader:Dy}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const p=new bt;p.setAttribute("position",new ot(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new We(p,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Na;let g=this.type;this.render=function(w,R,x){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||w.length===0)return;this.type===G1&&(we("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Na);const A=s.getRenderTarget(),I=s.getActiveCubeFace(),C=s.getActiveMipmapLevel(),P=s.state;P.setBlending(Cn),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&&R.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=w.length;z<N;z++){const V=w[z],k=V.shadow;if(k===void 0){we("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),r.copy(k.mapSize),(n.x>h||n.y>h)&&(n.x>h&&(r.x=Math.floor(h/K.x),n.x=r.x*K.x,k.mapSize.x=r.x),n.y>h&&(r.y=Math.floor(h/K.y),n.y=r.y*K.y,k.mapSize.y=r.y));const ee=s.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===Aa){if(V.isPointLight){we("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}k.map=new ui(n.x,n.y,{format:Zs,type:$t,minFilter:at,magFilter:at,generateMipmaps:!1}),k.map.texture.name=V.name+".shadowMap",k.map.depthTexture=new Js(n.x,n.y,Ti),k.map.depthTexture.name=V.name+".shadowMapDepth",k.map.depthTexture.format=Jn,k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=Dt,k.map.depthTexture.magFilter=Dt}else V.isPointLight?(k.map=new gd(n.x),k.map.depthTexture=new pv(n.x,hn)):(k.map=new ui(n.x,n.y),k.map.depthTexture=new Js(n.x,n.y,hn)),k.map.depthTexture.name=V.name+".shadowMap",k.map.depthTexture.format=Jn,this.type===Na?(k.map.depthTexture.compareFunction=ee?nd:id,k.map.depthTexture.minFilter=at,k.map.depthTexture.magFilter=at):(k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=Dt,k.map.depthTexture.magFilter=Dt);k.camera.updateProjectionMatrix()}const J=k.map.isWebGLCubeRenderTarget?6:1;for(let ie=0;ie<J;ie++){if(k.map.isWebGLCubeRenderTarget)s.setRenderTarget(k.map,ie),s.clear();else{ie===0&&(s.setRenderTarget(k.map),s.clear());const ae=k.getViewport(ie);a.set(r.x*ae.x,r.y*ae.y,r.x*ae.z,r.y*ae.w),P.viewport(a)}if(V.isPointLight){const ae=k.camera,Be=k.matrix,je=V.distance||ae.far;je!==ae.far&&(ae.far=je,ae.updateProjectionMatrix()),Ma.setFromMatrixPosition(V.matrixWorld),ae.position.copy(Ma),Wl.copy(ae.position),Wl.add(Cy[ie]),ae.up.copy(Iy[ie]),ae.lookAt(Wl),ae.updateMatrixWorld(),Be.makeTranslation(-Ma.x,-Ma.y,-Ma.z),If.multiplyMatrices(ae.projectionMatrix,ae.matrixWorldInverse),k._frustum.setFromProjectionMatrix(If,ae.coordinateSystem,ae.reversedDepth)}else k.updateMatrices(V);i=k.getFrustum(),_(R,x,k.camera,V,this.type)}k.isPointLightShadow!==!0&&this.type===Aa&&b(k,x),k.needsUpdate=!1}g=this.type,m.needsUpdate=!1,s.setRenderTarget(A,I,C)};function b(w,R){const x=e.update(v);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new ui(n.x,n.y,{format:Zs,type:$t})),d.uniforms.shadow_pass.value=w.map.depthTexture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,s.setRenderTarget(w.mapPass),s.clear(),s.renderBufferDirect(R,null,x,d,v,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,s.setRenderTarget(w.map),s.clear(),s.renderBufferDirect(R,null,x,f,v,null)}function y(w,R,x,A){let I=null;const C=x.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(C!==void 0)I=C;else if(I=x.isPointLight===!0?c:o,s.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){const P=I.uuid,X=R.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,R.addEventListener("dispose",E)),I=N}if(I.visible=R.visible,I.wireframe=R.wireframe,A===Aa?I.side=R.shadowSide!==null?R.shadowSide:R.side:I.side=R.shadowSide!==null?R.shadowSide:u[R.side],I.alphaMap=R.alphaMap,I.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,I.map=R.map,I.clipShadows=R.clipShadows,I.clippingPlanes=R.clippingPlanes,I.clipIntersection=R.clipIntersection,I.displacementMap=R.displacementMap,I.displacementScale=R.displacementScale,I.displacementBias=R.displacementBias,I.wireframeLinewidth=R.wireframeLinewidth,I.linewidth=R.linewidth,x.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const P=s.properties.get(I);P.light=x}return I}function _(w,R,x,A,I){if(w.visible===!1)return;if(w.layers.test(R.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&I===Aa)&&(!w.frustumCulled||i.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,w.matrixWorld);const X=e.update(w),z=w.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=y(w,ee,A,I);w.onBeforeShadow(s,w,R,x,X,J,K),s.renderBufferDirect(x,null,X,J,w,K),w.onAfterShadow(s,w,R,x,X,J,K)}}}else if(z.visible){const N=y(w,z,A,I);w.onBeforeShadow(s,w,R,x,X,N,null),s.renderBufferDirect(x,null,X,N,w,null),w.onAfterShadow(s,w,R,x,X,N,null)}}const P=w.children;for(let X=0,z=P.length;X<z;X++)_(P[X],R,x,A,I)}function E(w){w.target.removeEventListener("dispose",E);for(const x in l){const A=l[x],I=w.target.uuid;I in A&&(A[I].dispose(),delete A[I])}}}function Ly(s,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&&(s.colorMask(ve,ve,ve,ve),j=ve)},setLocked:function(ve){L=ve},setClear:function(ve,te,Te,ye,Ut){Ut===!0&&(ve*=ye,te*=ye,Te*=ye),ce.set(ve,te,Te,ye),de.equals(ce)===!1&&(s.clearColor(ve,te,Te,ye),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 Te=e.get("EXT_clip_control");te?Te.clipControlEXT(Te.LOWER_LEFT_EXT,Te.ZERO_TO_ONE_EXT):Te.clipControlEXT(Te.LOWER_LEFT_EXT,Te.NEGATIVE_ONE_TO_ONE_EXT),ce=te;const ye=ve;ve=null,this.setClear(ye)}},getReversed:function(){return ce},setTest:function(te){te?ne(s.DEPTH_TEST):B(s.DEPTH_TEST)},setMask:function(te){j!==te&&!L&&(s.depthMask(te),j=te)},setFunc:function(te){if(ce&&(te=S2[te]),de!==te){switch(te){case Eh:s.depthFunc(s.NEVER);break;case wh:s.depthFunc(s.ALWAYS);break;case Ah:s.depthFunc(s.LESS);break;case Zr:s.depthFunc(s.LEQUAL);break;case Th:s.depthFunc(s.EQUAL);break;case Rh:s.depthFunc(s.GEQUAL);break;case Dh:s.depthFunc(s.GREATER);break;case Ch:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}de=te}},setLocked:function(te){L=te},setClear:function(te){ve!==te&&(ve=te,ce&&(te=1-te),s.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,Te=null,ye=null,Ut=null;return{setTest:function(xt){L||(xt?ne(s.STENCIL_TEST):B(s.STENCIL_TEST))},setMask:function(xt){ce!==xt&&!L&&(s.stencilMask(xt),ce=xt)},setFunc:function(xt,pn,mn){(j!==xt||de!==pn||ve!==mn)&&(s.stencilFunc(xt,pn,mn),j=xt,de=pn,ve=mn)},setOp:function(xt,pn,mn){(te!==xt||Te!==pn||ye!==mn)&&(s.stencilOp(xt,pn,mn),te=xt,Te=pn,ye=mn)},setLocked:function(xt){L=xt},setClear:function(xt){Ut!==xt&&(s.clearStencil(xt),Ut=xt)},reset:function(){L=!1,ce=null,j=null,de=null,ve=null,te=null,Te=null,ye=null,Ut=null}}}const r=new t,a=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,b=null,y=null,_=null,E=null,w=null,R=null,x=new oe(0,0,0),A=0,I=!1,C=null,P=null,X=null,z=null,N=null;const V=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let k=!1,K=0;const ee=s.getParameter(s.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 ae=s.getParameter(s.SCISSOR_BOX),Be=s.getParameter(s.VIEWPORT),je=new it().fromArray(ae),Ge=new it().fromArray(Be);function Y(L,ce,j,de){const ve=new Uint8Array(4),te=s.createTexture();s.bindTexture(L,te),s.texParameteri(L,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(L,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let Te=0;Te<j;Te++)L===s.TEXTURE_3D||L===s.TEXTURE_2D_ARRAY?s.texImage3D(ce,0,s.RGBA,1,1,de,0,s.RGBA,s.UNSIGNED_BYTE,ve):s.texImage2D(ce+Te,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,ve);return te}const re={};re[s.TEXTURE_2D]=Y(s.TEXTURE_2D,s.TEXTURE_2D,1),re[s.TEXTURE_CUBE_MAP]=Y(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[s.TEXTURE_2D_ARRAY]=Y(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),re[s.TEXTURE_3D]=Y(s.TEXTURE_3D,s.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ne(s.DEPTH_TEST),a.setFunc(Zr),ct(!1),lt(h0),ne(s.CULL_FACE),Oe(Cn);function ne(L){h[L]!==!0&&(s.enable(L),h[L]=!0)}function B(L){h[L]!==!1&&(s.disable(L),h[L]=!1)}function Ee(L,ce){return d[L]!==ce?(s.bindFramebuffer(L,ce),d[L]=ce,L===s.DRAW_FRAMEBUFFER&&(d[s.FRAMEBUFFER]=ce),L===s.FRAMEBUFFER&&(d[s.DRAW_FRAMEBUFFER]=ce),!0):!1}function Pe(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]!==s.COLOR_ATTACHMENT0){for(let te=0,Te=ve.length;te<Te;te++)j[te]=s.COLOR_ATTACHMENT0+te;j.length=ve.length,de=!0}}else j[0]!==s.BACK&&(j[0]=s.BACK,de=!0);de&&s.drawBuffers(j)}function Re(L){return v!==L?(s.useProgram(L),v=L,!0):!1}const xe={[Fs]:s.FUNC_ADD,[V1]:s.FUNC_SUBTRACT,[W1]:s.FUNC_REVERSE_SUBTRACT};xe[X1]=s.MIN,xe[q1]=s.MAX;const Ne={[Y1]:s.ZERO,[om]:s.ONE,[K1]:s.SRC_COLOR,[bh]:s.SRC_ALPHA,[e2]:s.SRC_ALPHA_SATURATE,[j1]:s.DST_COLOR,[Z1]:s.DST_ALPHA,[$1]:s.ONE_MINUS_SRC_COLOR,[yc]:s.ONE_MINUS_SRC_ALPHA,[Q1]:s.ONE_MINUS_DST_COLOR,[J1]:s.ONE_MINUS_DST_ALPHA,[t2]:s.CONSTANT_COLOR,[i2]:s.ONE_MINUS_CONSTANT_COLOR,[n2]:s.CONSTANT_ALPHA,[s2]:s.ONE_MINUS_CONSTANT_ALPHA};function Oe(L,ce,j,de,ve,te,Te,ye,Ut,xt){if(L===Cn){m===!0&&(B(s.BLEND),m=!1);return}if(m===!1&&(ne(s.BLEND),m=!0),L!==am){if(L!==g||xt!==I){if((b!==Fs||E!==Fs)&&(s.blendEquation(s.FUNC_ADD),b=Fs,E=Fs),xt)switch(L){case qs:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Gi:s.blendFunc(s.ONE,s.ONE);break;case u0:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case d0:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:ke("WebGLState: Invalid blending: ",L);break}else switch(L){case qs:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Gi:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case u0:ke("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case d0:ke("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ke("WebGLState: Invalid blending: ",L);break}y=null,_=null,w=null,R=null,x.set(0,0,0),A=0,g=L,I=xt}return}ve=ve||ce,te=te||j,Te=Te||de,(ce!==b||ve!==E)&&(s.blendEquationSeparate(xe[ce],xe[ve]),b=ce,E=ve),(j!==y||de!==_||te!==w||Te!==R)&&(s.blendFuncSeparate(Ne[j],Ne[de],Ne[te],Ne[Te]),y=j,_=de,w=te,R=Te),(ye.equals(x)===!1||Ut!==A)&&(s.blendColor(ye.r,ye.g,ye.b,Ut),x.copy(ye),A=Ut),g=L,I=!1}function Ue(L,ce){L.side===on?B(s.CULL_FACE):ne(s.CULL_FACE);let j=L.side===It;ce&&(j=!j),ct(j),L.blending===qs&&L.transparent===!1?Oe(Cn):Oe(L.blending,L.blendEquation,L.blendSrc,L.blendDst,L.blendEquationAlpha,L.blendSrcAlpha,L.blendDstAlpha,L.blendColor,L.blendAlpha,L.premultipliedAlpha),a.setFunc(L.depthFunc),a.setTest(L.depthTest),a.setMask(L.depthWrite),r.setMask(L.colorWrite);const 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)),Tt(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?ne(s.SAMPLE_ALPHA_TO_COVERAGE):B(s.SAMPLE_ALPHA_TO_COVERAGE)}function ct(L){C!==L&&(L?s.frontFace(s.CW):s.frontFace(s.CCW),C=L)}function lt(L){L!==B1?(ne(s.CULL_FACE),L!==P&&(L===h0?s.cullFace(s.BACK):L===H1?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):B(s.CULL_FACE),P=L}function Nt(L){L!==X&&(k&&s.lineWidth(L),X=L)}function Tt(L,ce,j){L?(ne(s.POLYGON_OFFSET_FILL),(z!==ce||N!==j)&&(z=ce,N=j,a.getReversed()&&(ce=-ce),s.polygonOffset(ce,j))):B(s.POLYGON_OFFSET_FILL)}function Ot(L){L?ne(s.SCISSOR_TEST):B(s.SCISSOR_TEST)}function Wt(L){L===void 0&&(L=s.TEXTURE0+V-1),J!==L&&(s.activeTexture(L),J=L)}function O(L,ce,j){j===void 0&&(J===null?j=s.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&&(s.activeTexture(j),J=j),s.bindTexture(L,ce||re[L]),de.type=L,de.texture=ce)}function Ri(){const L=ie[J];L!==void 0&&L.type!==void 0&&(s.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function ht(){try{s.compressedTexImage2D(...arguments)}catch(L){ke("WebGLState:",L)}}function T(){try{s.compressedTexImage3D(...arguments)}catch(L){ke("WebGLState:",L)}}function M(){try{s.texSubImage2D(...arguments)}catch(L){ke("WebGLState:",L)}}function F(){try{s.texSubImage3D(...arguments)}catch(L){ke("WebGLState:",L)}}function W(){try{s.compressedTexSubImage2D(...arguments)}catch(L){ke("WebGLState:",L)}}function $(){try{s.compressedTexSubImage3D(...arguments)}catch(L){ke("WebGLState:",L)}}function se(){try{s.texStorage2D(...arguments)}catch(L){ke("WebGLState:",L)}}function le(){try{s.texStorage3D(...arguments)}catch(L){ke("WebGLState:",L)}}function Z(){try{s.texImage2D(...arguments)}catch(L){ke("WebGLState:",L)}}function Q(){try{s.texImage3D(...arguments)}catch(L){ke("WebGLState:",L)}}function he(L){return u[L]!==void 0?u[L]:s.getParameter(L)}function De(L,ce){u[L]!==ce&&(s.pixelStorei(L,ce),u[L]=ce)}function fe(L){je.equals(L)===!1&&(s.scissor(L.x,L.y,L.z,L.w),je.copy(L))}function ue(L){Ge.equals(L)===!1&&(s.viewport(L.x,L.y,L.z,L.w),Ge.copy(L))}function Le(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=s.getUniformBlockIndex(ce,L.name),j.set(L,de))}function Fe(L,ce){const de=l.get(ce).get(L);c.get(ce)!==de&&(s.uniformBlockBinding(ce,de,L.__bindingPointIndex),c.set(ce,de))}function Xe(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),a.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),s.pixelStorei(s.PACK_ALIGNMENT,4),s.pixelStorei(s.UNPACK_ALIGNMENT,4),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!1),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.BROWSER_DEFAULT_WEBGL),s.pixelStorei(s.PACK_ROW_LENGTH,0),s.pixelStorei(s.PACK_SKIP_PIXELS,0),s.pixelStorei(s.PACK_SKIP_ROWS,0),s.pixelStorei(s.UNPACK_ROW_LENGTH,0),s.pixelStorei(s.UNPACK_IMAGE_HEIGHT,0),s.pixelStorei(s.UNPACK_SKIP_PIXELS,0),s.pixelStorei(s.UNPACK_SKIP_ROWS,0),s.pixelStorei(s.UNPACK_SKIP_IMAGES,0),h={},u={},J=null,ie={},d={},f=new WeakMap,p=[],v=null,m=!1,g=null,b=null,y=null,_=null,E=null,w=null,R=null,x=new oe(0,0,0),A=0,I=!1,C=null,P=null,X=null,z=null,N=null,je.set(0,0,s.canvas.width,s.canvas.height),Ge.set(0,0,s.canvas.width,s.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:ne,disable:B,bindFramebuffer:Ee,drawBuffers:Pe,useProgram:Re,setBlending:Oe,setMaterial:Ue,setFlipSided:ct,setCullFace:lt,setLineWidth:Nt,setPolygonOffset:Tt,setScissorTest:Ot,activeTexture:Wt,bindTexture:O,unbindTexture:Ri,compressedTexImage2D:ht,compressedTexImage3D:T,texImage2D:Z,texImage3D:Q,pixelStorei:De,getParameter:he,updateUBOMapping:Le,uniformBlockBinding:Fe,texStorage2D:se,texStorage3D:le,texSubImage2D:M,texSubImage3D:F,compressedTexSubImage2D:W,compressedTexSubImage3D:$,scissor:fe,viewport:ue,reset:Xe}}function Ny(s,e,t,i,n,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ae,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(T,M){return p?new OffscreenCanvas(T,M):Za("canvas")}function m(T,M,F){let W=1;const $=ht(T);if(($.width>F||$.height>F)&&(W=F/Math.max($.width,$.height)),W<1)if(typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&T instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&T instanceof ImageBitmap||typeof VideoFrame<"u"&&T instanceof VideoFrame){const se=Math.floor(W*$.width),le=Math.floor(W*$.height);d===void 0&&(d=v(se,le));const Z=M?v(se,le):d;return Z.width=se,Z.height=le,Z.getContext("2d").drawImage(T,0,0,se,le),we("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+se+"x"+le+")."),Z}else return"data"in T&&we("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),T;return T}function g(T){return T.generateMipmaps}function b(T){s.generateMipmap(T)}function y(T){return T.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?s.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function _(T,M,F,W,$,se=!1){if(T!==null){if(s[T]!==void 0)return s[T];we("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let le;W&&(le=e.get("EXT_texture_norm16"),le||we("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Z=M;if(M===s.RED&&(F===s.FLOAT&&(Z=s.R32F),F===s.HALF_FLOAT&&(Z=s.R16F),F===s.UNSIGNED_BYTE&&(Z=s.R8),F===s.UNSIGNED_SHORT&&le&&(Z=le.R16_EXT),F===s.SHORT&&le&&(Z=le.R16_SNORM_EXT)),M===s.RED_INTEGER&&(F===s.UNSIGNED_BYTE&&(Z=s.R8UI),F===s.UNSIGNED_SHORT&&(Z=s.R16UI),F===s.UNSIGNED_INT&&(Z=s.R32UI),F===s.BYTE&&(Z=s.R8I),F===s.SHORT&&(Z=s.R16I),F===s.INT&&(Z=s.R32I)),M===s.RG&&(F===s.FLOAT&&(Z=s.RG32F),F===s.HALF_FLOAT&&(Z=s.RG16F),F===s.UNSIGNED_BYTE&&(Z=s.RG8),F===s.UNSIGNED_SHORT&&le&&(Z=le.RG16_EXT),F===s.SHORT&&le&&(Z=le.RG16_SNORM_EXT)),M===s.RG_INTEGER&&(F===s.UNSIGNED_BYTE&&(Z=s.RG8UI),F===s.UNSIGNED_SHORT&&(Z=s.RG16UI),F===s.UNSIGNED_INT&&(Z=s.RG32UI),F===s.BYTE&&(Z=s.RG8I),F===s.SHORT&&(Z=s.RG16I),F===s.INT&&(Z=s.RG32I)),M===s.RGB_INTEGER&&(F===s.UNSIGNED_BYTE&&(Z=s.RGB8UI),F===s.UNSIGNED_SHORT&&(Z=s.RGB16UI),F===s.UNSIGNED_INT&&(Z=s.RGB32UI),F===s.BYTE&&(Z=s.RGB8I),F===s.SHORT&&(Z=s.RGB16I),F===s.INT&&(Z=s.RGB32I)),M===s.RGBA_INTEGER&&(F===s.UNSIGNED_BYTE&&(Z=s.RGBA8UI),F===s.UNSIGNED_SHORT&&(Z=s.RGBA16UI),F===s.UNSIGNED_INT&&(Z=s.RGBA32UI),F===s.BYTE&&(Z=s.RGBA8I),F===s.SHORT&&(Z=s.RGBA16I),F===s.INT&&(Z=s.RGBA32I)),M===s.RGB&&(F===s.UNSIGNED_SHORT&&le&&(Z=le.RGB16_EXT),F===s.SHORT&&le&&(Z=le.RGB16_SNORM_EXT),F===s.UNSIGNED_INT_5_9_9_9_REV&&(Z=s.RGB9_E5),F===s.UNSIGNED_INT_10F_11F_11F_REV&&(Z=s.R11F_G11F_B10F)),M===s.RGBA){const Q=se?Tc:et.getTransfer($);F===s.FLOAT&&(Z=s.RGBA32F),F===s.HALF_FLOAT&&(Z=s.RGBA16F),F===s.UNSIGNED_BYTE&&(Z=Q===ut?s.SRGB8_ALPHA8:s.RGBA8),F===s.UNSIGNED_SHORT&&le&&(Z=le.RGBA16_EXT),F===s.SHORT&&le&&(Z=le.RGBA16_SNORM_EXT),F===s.UNSIGNED_SHORT_4_4_4_4&&(Z=s.RGBA4),F===s.UNSIGNED_SHORT_5_5_5_1&&(Z=s.RGB5_A1)}return(Z===s.R16F||Z===s.R32F||Z===s.RG16F||Z===s.RG32F||Z===s.RGBA16F||Z===s.RGBA32F)&&e.get("EXT_color_buffer_float"),Z}function E(T,M){let F;return T?M===null||M===hn||M===Ka?F=s.DEPTH24_STENCIL8:M===Ti?F=s.DEPTH32F_STENCIL8:M===Ya&&(F=s.DEPTH24_STENCIL8,we("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):M===null||M===hn||M===Ka?F=s.DEPTH_COMPONENT24:M===Ti?F=s.DEPTH_COMPONENT32F:M===Ya&&(F=s.DEPTH_COMPONENT16),F}function w(T,M){return g(T)===!0||T.isFramebufferTexture&&T.minFilter!==Dt&&T.minFilter!==at?Math.log2(Math.max(M.width,M.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?M.mipmaps.length:1}function R(T){const M=T.target;M.removeEventListener("dispose",R),A(M),M.isVideoTexture&&h.delete(M),M.isHTMLTexture&&u.delete(M)}function x(T){const M=T.target;M.removeEventListener("dispose",x),C(M)}function A(T){const M=i.get(T);if(M.__webglInit===void 0)return;const F=T.source,W=f.get(F);if(W){const $=W[M.__cacheKey];$.usedTimes--,$.usedTimes===0&&I(T),Object.keys(W).length===0&&f.delete(F)}i.remove(T)}function I(T){const M=i.get(T);s.deleteTexture(M.__webglTexture);const F=T.source,W=f.get(F);delete W[M.__cacheKey],a.memory.textures--}function C(T){const M=i.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),i.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let W=0;W<6;W++){if(Array.isArray(M.__webglFramebuffer[W]))for(let $=0;$<M.__webglFramebuffer[W].length;$++)s.deleteFramebuffer(M.__webglFramebuffer[W][$]);else s.deleteFramebuffer(M.__webglFramebuffer[W]);M.__webglDepthbuffer&&s.deleteRenderbuffer(M.__webglDepthbuffer[W])}else{if(Array.isArray(M.__webglFramebuffer))for(let W=0;W<M.__webglFramebuffer.length;W++)s.deleteFramebuffer(M.__webglFramebuffer[W]);else s.deleteFramebuffer(M.__webglFramebuffer);if(M.__webglDepthbuffer&&s.deleteRenderbuffer(M.__webglDepthbuffer),M.__webglMultisampledFramebuffer&&s.deleteFramebuffer(M.__webglMultisampledFramebuffer),M.__webglColorRenderbuffer)for(let W=0;W<M.__webglColorRenderbuffer.length;W++)M.__webglColorRenderbuffer[W]&&s.deleteRenderbuffer(M.__webglColorRenderbuffer[W]);M.__webglDepthRenderbuffer&&s.deleteRenderbuffer(M.__webglDepthRenderbuffer)}const F=T.textures;for(let W=0,$=F.length;W<$;W++){const se=i.get(F[W]);se.__webglTexture&&(s.deleteTexture(se.__webglTexture),a.memory.textures--),i.remove(F[W])}i.remove(T)}let P=0;function X(){P=0}function z(){return P}function N(T){P=T}function V(){const T=P;return T>=n.maxTextures&&we("WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+n.maxTextures),P+=1,T}function k(T){const M=[];return M.push(T.wrapS),M.push(T.wrapT),M.push(T.wrapR||0),M.push(T.magFilter),M.push(T.minFilter),M.push(T.anisotropy),M.push(T.internalFormat),M.push(T.format),M.push(T.type),M.push(T.generateMipmaps),M.push(T.premultiplyAlpha),M.push(T.flipY),M.push(T.unpackAlignment),M.push(T.colorSpace),M.join()}function K(T,M){const F=i.get(T);if(T.isVideoTexture&&O(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&F.__version!==T.version){const W=T.image;if(W===null)we("WebGLRenderer: Texture marked for update but no image data found.");else if(W.complete===!1)we("WebGLRenderer: Texture marked for update but image is incomplete");else{B(F,T,M);return}}else T.isExternalTexture&&(F.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(s.TEXTURE_2D,F.__webglTexture,s.TEXTURE0+M)}function ee(T,M){const F=i.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&F.__version!==T.version){B(F,T,M);return}else T.isExternalTexture&&(F.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(s.TEXTURE_2D_ARRAY,F.__webglTexture,s.TEXTURE0+M)}function J(T,M){const F=i.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&F.__version!==T.version){B(F,T,M);return}t.bindTexture(s.TEXTURE_3D,F.__webglTexture,s.TEXTURE0+M)}function ie(T,M){const F=i.get(T);if(T.isCubeDepthTexture!==!0&&T.version>0&&F.__version!==T.version){Ee(F,T,M);return}t.bindTexture(s.TEXTURE_CUBE_MAP,F.__webglTexture,s.TEXTURE0+M)}const ae={[qa]:s.REPEAT,[Ai]:s.CLAMP_TO_EDGE,[Ih]:s.MIRRORED_REPEAT},Be={[Dt]:s.NEAREST,[c2]:s.NEAREST_MIPMAP_NEAREST,[po]:s.NEAREST_MIPMAP_LINEAR,[at]:s.LINEAR,[cl]:s.LINEAR_MIPMAP_NEAREST,[Gs]:s.LINEAR_MIPMAP_LINEAR},je={[d2]:s.NEVER,[v2]:s.ALWAYS,[f2]:s.LESS,[id]:s.LEQUAL,[p2]:s.EQUAL,[nd]:s.GEQUAL,[m2]:s.GREATER,[g2]:s.NOTEQUAL};function Ge(T,M){if(M.type===Ti&&e.has("OES_texture_float_linear")===!1&&(M.magFilter===at||M.magFilter===cl||M.magFilter===po||M.magFilter===Gs||M.minFilter===at||M.minFilter===cl||M.minFilter===po||M.minFilter===Gs)&&we("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(T,s.TEXTURE_WRAP_S,ae[M.wrapS]),s.texParameteri(T,s.TEXTURE_WRAP_T,ae[M.wrapT]),(T===s.TEXTURE_3D||T===s.TEXTURE_2D_ARRAY)&&s.texParameteri(T,s.TEXTURE_WRAP_R,ae[M.wrapR]),s.texParameteri(T,s.TEXTURE_MAG_FILTER,Be[M.magFilter]),s.texParameteri(T,s.TEXTURE_MIN_FILTER,Be[M.minFilter]),M.compareFunction&&(s.texParameteri(T,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(T,s.TEXTURE_COMPARE_FUNC,je[M.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(M.magFilter===Dt||M.minFilter!==po&&M.minFilter!==Gs||M.type===Ti&&e.has("OES_texture_float_linear")===!1)return;if(M.anisotropy>1||i.get(M).__currentAnisotropy){const F=e.get("EXT_texture_filter_anisotropic");s.texParameterf(T,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,n.getMaxAnisotropy())),i.get(M).__currentAnisotropy=M.anisotropy}}}function Y(T,M){let F=!1;T.__webglInit===void 0&&(T.__webglInit=!0,M.addEventListener("dispose",R));const W=M.source;let $=f.get(W);$===void 0&&($={},f.set(W,$));const se=k(M);if(se!==T.__cacheKey){$[se]===void 0&&($[se]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,F=!0),$[se].usedTimes++;const le=$[T.__cacheKey];le!==void 0&&($[T.__cacheKey].usedTimes--,le.usedTimes===0&&I(M)),T.__cacheKey=se,T.__webglTexture=$[se].texture}return F}function re(T,M,F){return Math.floor(Math.floor(T/F)/M)}function ne(T,M,F,W){const se=T.updateRanges;if(se.length===0)t.texSubImage2D(s.TEXTURE_2D,0,0,0,M.width,M.height,F,W,M.data);else{se.sort((De,fe)=>De.start-fe.start);let le=0;for(let De=1;De<se.length;De++){const fe=se[le],ue=se[De],Le=fe.start+fe.count,Fe=re(ue.start,M.width,4),Xe=re(fe.start,M.width,4);ue.start<=Le+1&&Fe===Xe&&re(ue.start+ue.count-1,M.width,4)===Fe?fe.count=Math.max(fe.count,ue.start+ue.count-fe.start):(++le,se[le]=ue)}se.length=le+1;const Z=t.getParameter(s.UNPACK_ROW_LENGTH),Q=t.getParameter(s.UNPACK_SKIP_PIXELS),he=t.getParameter(s.UNPACK_SKIP_ROWS);t.pixelStorei(s.UNPACK_ROW_LENGTH,M.width);for(let De=0,fe=se.length;De<fe;De++){const ue=se[De],Le=Math.floor(ue.start/4),Fe=Math.ceil(ue.count/4),Xe=Le%M.width,L=Math.floor(Le/M.width),ce=Fe,j=1;t.pixelStorei(s.UNPACK_SKIP_PIXELS,Xe),t.pixelStorei(s.UNPACK_SKIP_ROWS,L),t.texSubImage2D(s.TEXTURE_2D,0,Xe,L,ce,j,F,W,M.data)}T.clearUpdateRanges(),t.pixelStorei(s.UNPACK_ROW_LENGTH,Z),t.pixelStorei(s.UNPACK_SKIP_PIXELS,Q),t.pixelStorei(s.UNPACK_SKIP_ROWS,he)}}function B(T,M,F){let W=s.TEXTURE_2D;(M.isDataArrayTexture||M.isCompressedArrayTexture)&&(W=s.TEXTURE_2D_ARRAY),M.isData3DTexture&&(W=s.TEXTURE_3D);const $=Y(T,M),se=M.source;t.bindTexture(W,T.__webglTexture,s.TEXTURE0+F);const le=i.get(se);if(se.version!==le.__version||$===!0){if(t.activeTexture(s.TEXTURE0+F),(typeof ImageBitmap<"u"&&M.image instanceof ImageBitmap)===!1){const j=et.getPrimaries(et.workingColorSpace),de=M.colorSpace===xs?null:et.getPrimaries(M.colorSpace),ve=M.colorSpace===xs||j===de?s.NONE:s.BROWSER_DEFAULT_WEBGL;t.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,M.flipY),t.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),t.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,ve)}t.pixelStorei(s.UNPACK_ALIGNMENT,M.unpackAlignment);let Q=m(M.image,!1,n.maxTextureSize);Q=Ri(M,Q);const he=r.convert(M.format,M.colorSpace),De=r.convert(M.type);let fe=_(M.internalFormat,he,De,M.normalized,M.colorSpace,M.isVideoTexture);Ge(W,M);let ue;const Le=M.mipmaps,Fe=M.isVideoTexture!==!0,Xe=le.__version===void 0||$===!0,L=se.dataReady,ce=w(M,Q);if(M.isDepthTexture)fe=E(M.format===Vs,M.type),Xe&&(Fe?t.texStorage2D(s.TEXTURE_2D,1,fe,Q.width,Q.height):t.texImage2D(s.TEXTURE_2D,0,fe,Q.width,Q.height,0,he,De,null));else if(M.isDataTexture)if(Le.length>0){Fe&&Xe&&t.texStorage2D(s.TEXTURE_2D,ce,fe,Le[0].width,Le[0].height);for(let j=0,de=Le.length;j<de;j++)ue=Le[j],Fe?L&&t.texSubImage2D(s.TEXTURE_2D,j,0,0,ue.width,ue.height,he,De,ue.data):t.texImage2D(s.TEXTURE_2D,j,fe,ue.width,ue.height,0,he,De,ue.data);M.generateMipmaps=!1}else Fe?(Xe&&t.texStorage2D(s.TEXTURE_2D,ce,fe,Q.width,Q.height),L&&ne(M,Q,he,De)):t.texImage2D(s.TEXTURE_2D,0,fe,Q.width,Q.height,0,he,De,Q.data);else if(M.isCompressedTexture)if(M.isCompressedArrayTexture){Fe&&Xe&&t.texStorage3D(s.TEXTURE_2D_ARRAY,ce,fe,Le[0].width,Le[0].height,Q.depth);for(let j=0,de=Le.length;j<de;j++)if(ue=Le[j],M.format!==xi)if(he!==null)if(Fe){if(L)if(M.layerUpdates.size>0){const ve=cf(ue.width,ue.height,M.format,M.type);for(const te of M.layerUpdates){const Te=ue.data.subarray(te*ve/ue.data.BYTES_PER_ELEMENT,(te+1)*ve/ue.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,j,0,0,te,ue.width,ue.height,1,he,Te)}M.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,j,0,0,0,ue.width,ue.height,Q.depth,he,ue.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,j,fe,ue.width,ue.height,Q.depth,0,ue.data,0,0);else we("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Fe?L&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,j,0,0,0,ue.width,ue.height,Q.depth,he,De,ue.data):t.texImage3D(s.TEXTURE_2D_ARRAY,j,fe,ue.width,ue.height,Q.depth,0,he,De,ue.data)}else{Fe&&Xe&&t.texStorage2D(s.TEXTURE_2D,ce,fe,Le[0].width,Le[0].height);for(let j=0,de=Le.length;j<de;j++)ue=Le[j],M.format!==xi?he!==null?Fe?L&&t.compressedTexSubImage2D(s.TEXTURE_2D,j,0,0,ue.width,ue.height,he,ue.data):t.compressedTexImage2D(s.TEXTURE_2D,j,fe,ue.width,ue.height,0,ue.data):we("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Fe?L&&t.texSubImage2D(s.TEXTURE_2D,j,0,0,ue.width,ue.height,he,De,ue.data):t.texImage2D(s.TEXTURE_2D,j,fe,ue.width,ue.height,0,he,De,ue.data)}else if(M.isDataArrayTexture)if(Fe){if(Xe&&t.texStorage3D(s.TEXTURE_2D_ARRAY,ce,fe,Q.width,Q.height,Q.depth),L)if(M.layerUpdates.size>0){const j=cf(Q.width,Q.height,M.format,M.type);for(const de of M.layerUpdates){const ve=Q.data.subarray(de*j/Q.data.BYTES_PER_ELEMENT,(de+1)*j/Q.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,de,Q.width,Q.height,1,he,De,ve)}M.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,he,De,Q.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,fe,Q.width,Q.height,Q.depth,0,he,De,Q.data);else if(M.isData3DTexture)Fe?(Xe&&t.texStorage3D(s.TEXTURE_3D,ce,fe,Q.width,Q.height,Q.depth),L&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,he,De,Q.data)):t.texImage3D(s.TEXTURE_3D,0,fe,Q.width,Q.height,Q.depth,0,he,De,Q.data);else if(M.isFramebufferTexture){if(Xe)if(Fe)t.texStorage2D(s.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(s.TEXTURE_2D,ve,fe,j,de,0,he,De,null),j>>=1,de>>=1}}else if(M.isHTMLTexture){if("texElementImage2D"in s){const j=s.canvas;if(j.hasAttribute("layoutsubtree")||j.setAttribute("layoutsubtree","true"),Q.parentNode!==j){j.appendChild(Q),u.add(M),j.onpaint=de=>{const ve=de.changedElements;for(const te of u)ve.includes(te.image)&&(te.needsUpdate=!0)},j.requestPaint();return}if(s.texElementImage2D.length===3)s.texElementImage2D(s.TEXTURE_2D,s.RGBA8,Q);else{const ve=s.RGBA,te=s.RGBA,Te=s.UNSIGNED_BYTE;s.texElementImage2D(s.TEXTURE_2D,0,ve,te,Te,Q)}s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE)}}else if(Le.length>0){if(Fe&&Xe){const j=ht(Le[0]);t.texStorage2D(s.TEXTURE_2D,ce,fe,j.width,j.height)}for(let j=0,de=Le.length;j<de;j++)ue=Le[j],Fe?L&&t.texSubImage2D(s.TEXTURE_2D,j,0,0,he,De,ue):t.texImage2D(s.TEXTURE_2D,j,fe,he,De,ue);M.generateMipmaps=!1}else if(Fe){if(Xe){const j=ht(Q);t.texStorage2D(s.TEXTURE_2D,ce,fe,j.width,j.height)}L&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,he,De,Q)}else t.texImage2D(s.TEXTURE_2D,0,fe,he,De,Q);g(M)&&b(W),le.__version=se.version,M.onUpdate&&M.onUpdate(M)}T.__version=M.version}function Ee(T,M,F){if(M.image.length!==6)return;const W=Y(T,M),$=M.source;t.bindTexture(s.TEXTURE_CUBE_MAP,T.__webglTexture,s.TEXTURE0+F);const se=i.get($);if($.version!==se.__version||W===!0){t.activeTexture(s.TEXTURE0+F);const le=et.getPrimaries(et.workingColorSpace),Z=M.colorSpace===xs?null:et.getPrimaries(M.colorSpace),Q=M.colorSpace===xs||le===Z?s.NONE:s.BROWSER_DEFAULT_WEBGL;t.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,M.flipY),t.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),t.pixelStorei(s.UNPACK_ALIGNMENT,M.unpackAlignment),t.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);const he=M.isCompressedTexture||M.image[0].isCompressedTexture,De=M.image[0]&&M.image[0].isDataTexture,fe=[];for(let te=0;te<6;te++)!he&&!De?fe[te]=m(M.image[te],!0,n.maxCubemapSize):fe[te]=De?M.image[te].image:M.image[te],fe[te]=Ri(M,fe[te]);const ue=fe[0],Le=r.convert(M.format,M.colorSpace),Fe=r.convert(M.type),Xe=_(M.internalFormat,Le,Fe,M.normalized,M.colorSpace),L=M.isVideoTexture!==!0,ce=se.__version===void 0||W===!0,j=$.dataReady;let de=w(M,ue);Ge(s.TEXTURE_CUBE_MAP,M);let ve;if(he){L&&ce&&t.texStorage2D(s.TEXTURE_CUBE_MAP,de,Xe,ue.width,ue.height);for(let te=0;te<6;te++){ve=fe[te].mipmaps;for(let Te=0;Te<ve.length;Te++){const ye=ve[Te];M.format!==xi?Le!==null?L?j&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te,0,0,ye.width,ye.height,Le,ye.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te,Xe,ye.width,ye.height,0,ye.data):we("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?j&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te,0,0,ye.width,ye.height,Le,Fe,ye.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te,Xe,ye.width,ye.height,0,Le,Fe,ye.data)}}}else{if(ve=M.mipmaps,L&&ce){ve.length>0&&de++;const te=ht(fe[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,de,Xe,te.width,te.height)}for(let te=0;te<6;te++)if(De){L?j&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,fe[te].width,fe[te].height,Le,Fe,fe[te].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,Xe,fe[te].width,fe[te].height,0,Le,Fe,fe[te].data);for(let Te=0;Te<ve.length;Te++){const Ut=ve[Te].image[te].image;L?j&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te+1,0,0,Ut.width,Ut.height,Le,Fe,Ut.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te+1,Xe,Ut.width,Ut.height,0,Le,Fe,Ut.data)}}else{L?j&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,Le,Fe,fe[te]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,Xe,Le,Fe,fe[te]);for(let Te=0;Te<ve.length;Te++){const ye=ve[Te];L?j&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te+1,0,0,Le,Fe,ye.image[te]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te+1,Xe,Le,Fe,ye.image[te])}}}g(M)&&b(s.TEXTURE_CUBE_MAP),se.__version=$.version,M.onUpdate&&M.onUpdate(M)}T.__version=M.version}function Pe(T,M,F,W,$,se){const le=r.convert(F.format,F.colorSpace),Z=r.convert(F.type),Q=_(F.internalFormat,le,Z,F.normalized,F.colorSpace),he=i.get(M),De=i.get(F);if(De.__renderTarget=M,!he.__hasExternalTextures){const fe=Math.max(1,M.width>>se),ue=Math.max(1,M.height>>se);$===s.TEXTURE_3D||$===s.TEXTURE_2D_ARRAY?t.texImage3D($,se,Q,fe,ue,M.depth,0,le,Z,null):t.texImage2D($,se,Q,fe,ue,0,le,Z,null)}t.bindFramebuffer(s.FRAMEBUFFER,T),Wt(M)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,W,$,De.__webglTexture,0,Ot(M)):($===s.TEXTURE_2D||$>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,W,$,De.__webglTexture,se),t.bindFramebuffer(s.FRAMEBUFFER,null)}function Re(T,M,F){if(s.bindRenderbuffer(s.RENDERBUFFER,T),M.depthBuffer){const W=M.depthTexture,$=W&&W.isDepthTexture?W.type:null,se=E(M.stencilBuffer,$),le=M.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;Wt(M)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Ot(M),se,M.width,M.height):F?s.renderbufferStorageMultisample(s.RENDERBUFFER,Ot(M),se,M.width,M.height):s.renderbufferStorage(s.RENDERBUFFER,se,M.width,M.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,le,s.RENDERBUFFER,T)}else{const W=M.textures;for(let $=0;$<W.length;$++){const se=W[$],le=r.convert(se.format,se.colorSpace),Z=r.convert(se.type),Q=_(se.internalFormat,le,Z,se.normalized,se.colorSpace);Wt(M)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Ot(M),Q,M.width,M.height):F?s.renderbufferStorageMultisample(s.RENDERBUFFER,Ot(M),Q,M.width,M.height):s.renderbufferStorage(s.RENDERBUFFER,Q,M.width,M.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function xe(T,M,F){const W=M.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(s.FRAMEBUFFER,T),!(M.depthTexture&&M.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const $=i.get(M.depthTexture);if($.__renderTarget=M,(!$.__webglTexture||M.depthTexture.image.width!==M.width||M.depthTexture.image.height!==M.height)&&(M.depthTexture.image.width=M.width,M.depthTexture.image.height=M.height,M.depthTexture.needsUpdate=!0),W){if($.__webglInit===void 0&&($.__webglInit=!0,M.depthTexture.addEventListener("dispose",R)),$.__webglTexture===void 0){$.__webglTexture=s.createTexture(),t.bindTexture(s.TEXTURE_CUBE_MAP,$.__webglTexture),Ge(s.TEXTURE_CUBE_MAP,M.depthTexture);const he=r.convert(M.depthTexture.format),De=r.convert(M.depthTexture.type);let fe;M.depthTexture.format===Jn?fe=s.DEPTH_COMPONENT24:M.depthTexture.format===Vs&&(fe=s.DEPTH24_STENCIL8);for(let ue=0;ue<6;ue++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ue,0,fe,M.width,M.height,0,he,De,null)}}else K(M.depthTexture,0);const se=$.__webglTexture,le=Ot(M),Z=W?s.TEXTURE_CUBE_MAP_POSITIVE_X+F:s.TEXTURE_2D,Q=M.depthTexture.format===Vs?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;if(M.depthTexture.format===Jn)Wt(M)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Q,Z,se,0,le):s.framebufferTexture2D(s.FRAMEBUFFER,Q,Z,se,0);else if(M.depthTexture.format===Vs)Wt(M)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Q,Z,se,0,le):s.framebufferTexture2D(s.FRAMEBUFFER,Q,Z,se,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ne(T){const M=i.get(T),F=T.isWebGLCubeRenderTarget===!0;if(M.__boundDepthTexture!==T.depthTexture){const W=T.depthTexture;if(M.__depthDisposeCallback&&M.__depthDisposeCallback(),W){const $=()=>{delete M.__boundDepthTexture,delete M.__depthDisposeCallback,W.removeEventListener("dispose",$)};W.addEventListener("dispose",$),M.__depthDisposeCallback=$}M.__boundDepthTexture=W}if(T.depthTexture&&!M.__autoAllocateDepthBuffer)if(F)for(let W=0;W<6;W++)xe(M.__webglFramebuffer[W],T,W);else{const W=T.texture.mipmaps;W&&W.length>0?xe(M.__webglFramebuffer[0],T,0):xe(M.__webglFramebuffer,T,0)}else if(F){M.__webglDepthbuffer=[];for(let W=0;W<6;W++)if(t.bindFramebuffer(s.FRAMEBUFFER,M.__webglFramebuffer[W]),M.__webglDepthbuffer[W]===void 0)M.__webglDepthbuffer[W]=s.createRenderbuffer(),Re(M.__webglDepthbuffer[W],T,!1);else{const $=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,se=M.__webglDepthbuffer[W];s.bindRenderbuffer(s.RENDERBUFFER,se),s.framebufferRenderbuffer(s.FRAMEBUFFER,$,s.RENDERBUFFER,se)}}else{const W=T.texture.mipmaps;if(W&&W.length>0?t.bindFramebuffer(s.FRAMEBUFFER,M.__webglFramebuffer[0]):t.bindFramebuffer(s.FRAMEBUFFER,M.__webglFramebuffer),M.__webglDepthbuffer===void 0)M.__webglDepthbuffer=s.createRenderbuffer(),Re(M.__webglDepthbuffer,T,!1);else{const $=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,se=M.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,se),s.framebufferRenderbuffer(s.FRAMEBUFFER,$,s.RENDERBUFFER,se)}}t.bindFramebuffer(s.FRAMEBUFFER,null)}function Oe(T,M,F){const W=i.get(T);M!==void 0&&Pe(W.__webglFramebuffer,T,T.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),F!==void 0&&Ne(T)}function Ue(T){const M=T.texture,F=i.get(T),W=i.get(M);T.addEventListener("dispose",x);const $=T.textures,se=T.isWebGLCubeRenderTarget===!0,le=$.length>1;if(le||(W.__webglTexture===void 0&&(W.__webglTexture=s.createTexture()),W.__version=M.version,a.memory.textures++),se){F.__webglFramebuffer=[];for(let Z=0;Z<6;Z++)if(M.mipmaps&&M.mipmaps.length>0){F.__webglFramebuffer[Z]=[];for(let Q=0;Q<M.mipmaps.length;Q++)F.__webglFramebuffer[Z][Q]=s.createFramebuffer()}else F.__webglFramebuffer[Z]=s.createFramebuffer()}else{if(M.mipmaps&&M.mipmaps.length>0){F.__webglFramebuffer=[];for(let Z=0;Z<M.mipmaps.length;Z++)F.__webglFramebuffer[Z]=s.createFramebuffer()}else F.__webglFramebuffer=s.createFramebuffer();if(le)for(let Z=0,Q=$.length;Z<Q;Z++){const he=i.get($[Z]);he.__webglTexture===void 0&&(he.__webglTexture=s.createTexture(),a.memory.textures++)}if(T.samples>0&&Wt(T)===!1){F.__webglMultisampledFramebuffer=s.createFramebuffer(),F.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let Z=0;Z<$.length;Z++){const Q=$[Z];F.__webglColorRenderbuffer[Z]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,F.__webglColorRenderbuffer[Z]);const he=r.convert(Q.format,Q.colorSpace),De=r.convert(Q.type),fe=_(Q.internalFormat,he,De,Q.normalized,Q.colorSpace,T.isXRRenderTarget===!0),ue=Ot(T);s.renderbufferStorageMultisample(s.RENDERBUFFER,ue,fe,T.width,T.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Z,s.RENDERBUFFER,F.__webglColorRenderbuffer[Z])}s.bindRenderbuffer(s.RENDERBUFFER,null),T.depthBuffer&&(F.__webglDepthRenderbuffer=s.createRenderbuffer(),Re(F.__webglDepthRenderbuffer,T,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(se){t.bindTexture(s.TEXTURE_CUBE_MAP,W.__webglTexture),Ge(s.TEXTURE_CUBE_MAP,M);for(let Z=0;Z<6;Z++)if(M.mipmaps&&M.mipmaps.length>0)for(let Q=0;Q<M.mipmaps.length;Q++)Pe(F.__webglFramebuffer[Z][Q],T,M,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Q);else Pe(F.__webglFramebuffer[Z],T,M,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0);g(M)&&b(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(le){for(let Z=0,Q=$.length;Z<Q;Z++){const he=$[Z],De=i.get(he);let fe=s.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(fe=T.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(fe,De.__webglTexture),Ge(fe,he),Pe(F.__webglFramebuffer,T,he,s.COLOR_ATTACHMENT0+Z,fe,0),g(he)&&b(fe)}t.unbindTexture()}else{let Z=s.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(Z=T.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(Z,W.__webglTexture),Ge(Z,M),M.mipmaps&&M.mipmaps.length>0)for(let Q=0;Q<M.mipmaps.length;Q++)Pe(F.__webglFramebuffer[Q],T,M,s.COLOR_ATTACHMENT0,Z,Q);else Pe(F.__webglFramebuffer,T,M,s.COLOR_ATTACHMENT0,Z,0);g(M)&&b(Z),t.unbindTexture()}T.depthBuffer&&Ne(T)}function ct(T){const M=T.textures;for(let F=0,W=M.length;F<W;F++){const $=M[F];if(g($)){const se=y(T),le=i.get($).__webglTexture;t.bindTexture(se,le),b(se),t.unbindTexture()}}}const lt=[],Nt=[];function Tt(T){if(T.samples>0){if(Wt(T)===!1){const M=T.textures,F=T.width,W=T.height;let $=s.COLOR_BUFFER_BIT;const se=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,le=i.get(T),Z=M.length>1;if(Z)for(let he=0;he<M.length;he++)t.bindFramebuffer(s.FRAMEBUFFER,le.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+he,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,le.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+he,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,le.__webglMultisampledFramebuffer);const Q=T.texture.mipmaps;Q&&Q.length>0?t.bindFramebuffer(s.DRAW_FRAMEBUFFER,le.__webglFramebuffer[0]):t.bindFramebuffer(s.DRAW_FRAMEBUFFER,le.__webglFramebuffer);for(let he=0;he<M.length;he++){if(T.resolveDepthBuffer&&(T.depthBuffer&&($|=s.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&($|=s.STENCIL_BUFFER_BIT)),Z){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,le.__webglColorRenderbuffer[he]);const De=i.get(M[he]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,De,0)}s.blitFramebuffer(0,0,F,W,0,0,F,W,$,s.NEAREST),c===!0&&(lt.length=0,Nt.length=0,lt.push(s.COLOR_ATTACHMENT0+he),T.depthBuffer&&T.resolveDepthBuffer===!1&&(lt.push(se),Nt.push(se),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,Nt)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,lt))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),Z)for(let he=0;he<M.length;he++){t.bindFramebuffer(s.FRAMEBUFFER,le.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+he,s.RENDERBUFFER,le.__webglColorRenderbuffer[he]);const De=i.get(M[he]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,le.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+he,s.TEXTURE_2D,De,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,le.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&c){const M=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[M])}}}function Ot(T){return Math.min(n.maxSamples,T.samples)}function Wt(T){const M=i.get(T);return T.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function O(T){const M=a.render.frame;h.get(T)!==M&&(h.set(T,M),T.update())}function Ri(T,M){const F=T.colorSpace,W=T.format,$=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||F!==Ac&&F!==xs&&(et.getTransfer(F)===ut?(W!==xi||$!==Hi)&&we("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ke("WebGLTextures: Unsupported texture color space:",F)),M}function ht(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(l.width=T.naturalWidth||T.width,l.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(l.width=T.displayWidth,l.height=T.displayHeight):(l.width=T.width,l.height=T.height),l}this.allocateTextureUnit=V,this.resetTextureUnits=X,this.getTextureUnits=z,this.setTextureUnits=N,this.setTexture2D=K,this.setTexture2DArray=ee,this.setTexture3D=J,this.setTextureCube=ie,this.rebindTextures=Oe,this.setupRenderTarget=Ue,this.updateRenderTargetMipmap=ct,this.updateMultisampleRenderTarget=Tt,this.setupDepthRenderbuffer=Ne,this.setupFrameBufferTexture=Pe,this.useMultisampledRTT=Wt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Oy(s,e){function t(i,n=xs){let r;const a=et.getTransfer(n);if(i===Hi)return s.UNSIGNED_BYTE;if(i===Ju)return s.UNSIGNED_SHORT_4_4_4_4;if(i===ju)return s.UNSIGNED_SHORT_5_5_5_1;if(i===Mm)return s.UNSIGNED_INT_5_9_9_9_REV;if(i===xm)return s.UNSIGNED_INT_10F_11F_11F_REV;if(i===gm)return s.BYTE;if(i===vm)return s.SHORT;if(i===Ya)return s.UNSIGNED_SHORT;if(i===Zu)return s.INT;if(i===hn)return s.UNSIGNED_INT;if(i===Ti)return s.FLOAT;if(i===$t)return s.HALF_FLOAT;if(i===_m)return s.ALPHA;if(i===ym)return s.RGB;if(i===xi)return s.RGBA;if(i===Jn)return s.DEPTH_COMPONENT;if(i===Vs)return s.DEPTH_STENCIL;if(i===qc)return s.RED;if(i===Qu)return s.RED_INTEGER;if(i===Zs)return s.RG;if(i===ed)return s.RG_INTEGER;if(i===td)return s.RGBA_INTEGER;if(i===hc||i===uc||i===dc||i===fc)if(a===ut)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===hc)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===uc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===dc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===fc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===hc)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===uc)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===dc)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===fc)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Ph||i===Lh||i===Nh||i===Oh)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===Ph)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Lh)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Nh)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Oh)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Uh||i===Fh||i===kh||i===zh||i===Bh||i===Sc||i===Hh)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===Uh||i===Fh)return a===ut?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===kh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===zh)return r.COMPRESSED_R11_EAC;if(i===Bh)return r.COMPRESSED_SIGNED_R11_EAC;if(i===Sc)return r.COMPRESSED_RG11_EAC;if(i===Hh)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Gh||i===Vh||i===Wh||i===Xh||i===qh||i===Yh||i===Kh||i===$h||i===Zh||i===Jh||i===jh||i===Qh||i===eu||i===tu)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===Gh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Vh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Wh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Xh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===qh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Yh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Kh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===$h)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Zh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Jh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===jh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Qh)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===eu)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===tu)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===iu||i===nu||i===su)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===iu)return a===ut?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===nu)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===su)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===ru||i===au||i===bc||i===ou)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===ru)return r.COMPRESSED_RED_RGTC1_EXT;if(i===au)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===bc)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===ou)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Ka?s.UNSIGNED_INT_24_8:s[i]!==void 0?s[i]:null}return{convert:t}}const Uy=`
|
|
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 ky{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new Im(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 wt({vertexShader:Uy,fragmentShader:Fy,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new We(new dn(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class zy extends er{constructor(e,t){super();const i=this;let n=null,r=1,a=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 ky,g={},b=t.getContextAttributes();let y=null,_=null;const w=[],E=[],R=new Ae;let x=null;const A=new Li;A.viewport=new it;const I=new Li;I.viewport=new it;const C=[A,I],P=new Bv;let X=null,z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let re=w[Y];return re===void 0&&(re=new ml,w[Y]=re),re.getTargetRaySpace()},this.getControllerGrip=function(Y){let re=w[Y];return re===void 0&&(re=new ml,w[Y]=re),re.getGripSpace()},this.getHand=function(Y){let re=w[Y];return re===void 0&&(re=new ml,w[Y]=re),re.getHandSpace()};function N(Y){const re=E.indexOf(Y.inputSource);if(re===-1)return;const ne=w[re];ne!==void 0&&(ne.update(Y.inputSource,Y.frame,l||a),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<w.length;Y++){const re=E[Y];re!==null&&(E[Y]=null,w[Y].disconnect(re))}X=null,z=null,m.reset();for(const Y in g)delete g[Y];e.setRenderTarget(y),f=null,d=null,u=null,n=null,_=null,Ge.stop(),i.isPresenting=!1,e.setPixelRatio(x),e.setSize(R.width,R.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){r=Y,i.isPresenting===!0&&Ee("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,i.isPresenting===!0&&Ee("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&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(y=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),b.xrCompatible!==!0&&await t.makeXRCompatible(),x=e.getPixelRatio(),e.getSize(R),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let ne=null,B=null,we=null;b.depth&&(we=b.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ne=b.stencil?Vs:Jn,B=b.stencil?Ka:hn);const Pe={colorFormat:t.RGBA8,depthFormat:we,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(Pe),n.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),_=new ui(d.textureWidth,d.textureHeight,{format:xi,type:Bi,depthTexture:new Js(d.textureWidth,d.textureHeight,B,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:b.stencil,colorSpace:e.outputColorSpace,samples:b.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const ne={antialias:b.antialias,alpha:!0,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(n,t,ne),n.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),_=new ui(f.framebufferWidth,f.framebufferHeight,{format:xi,type:Bi,colorSpace:e.outputColorSpace,stencilBuffer:b.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await n.requestReferenceSpace(o),Ge.setContext(n),Ge.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],B=E.indexOf(ne);B>=0&&(E[B]=null,w[B].disconnect(ne))}for(let re=0;re<Y.added.length;re++){const ne=Y.added[re];let B=E.indexOf(ne);if(B===-1){for(let Pe=0;Pe<w.length;Pe++)if(Pe>=E.length){E.push(ne),B=Pe;break}else if(E[Pe]===null){E[Pe]=ne,B=Pe;break}if(B===-1)break}const we=w[B];we&&we.connect(ne)}}const K=new D,ee=new D;function J(Y,re,ne){K.setFromMatrixPosition(re.matrixWorld),ee.setFromMatrixPosition(ne.matrixWorld);const B=K.distanceTo(ee),we=re.projectionMatrix.elements,Pe=ne.projectionMatrix.elements,Re=we[14]/(we[10]-1),xe=we[14]/(we[10]+1),Ne=(we[9]+1)/we[5],Oe=(we[9]-1)/we[5],Ue=(we[8]-1)/we[0],ct=(Pe[8]+1)/Pe[0],lt=Re*Ue,Nt=Re*ct,Tt=B/(-Ue+ct),Ot=Tt*-Ue;if(re.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(Ot),Y.translateZ(Tt),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),we[10]===-1)Y.projectionMatrix.copy(re.projectionMatrix),Y.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{const Wt=Re+Tt,O=xe+Tt,Ti=lt-Ot,ht=Nt+(B-Ot),T=Ne*xe/O*Wt,M=Oe*xe/O*Wt;Y.projectionMatrix.makePerspective(Ti,ht,T,M,Wt,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 B=Y.parent,we=P.cameras;ie(P,B);for(let Pe=0;Pe<we.length;Pe++)ie(we[Pe],B);we.length===2?J(P,A,I):P.projectionMatrix.copy(A.projectionMatrix),ae(Y,P,B)};function ae(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=jr*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 Be=null;function je(Y,re){if(h=re.getViewerPose(l||a),p=re,h!==null){const ne=h.views;f!==null&&(e.setRenderTargetFramebuffer(_,f.framebuffer),e.setRenderTarget(_));let B=!1;ne.length!==P.cameras.length&&(P.cameras.length=0,B=!0);for(let xe=0;xe<ne.length;xe++){const Ne=ne[xe];let Oe=null;if(f!==null)Oe=f.getViewport(Ne);else{const ct=u.getViewSubImage(d,Ne);Oe=ct.viewport,xe===0&&(e.setRenderTargetTextures(_,ct.colorTexture,ct.depthStencilTexture),e.setRenderTarget(_))}let Ue=C[xe];Ue===void 0&&(Ue=new Li,Ue.layers.enable(xe),Ue.viewport=new it,C[xe]=Ue),Ue.matrix.fromArray(Ne.transform.matrix),Ue.matrix.decompose(Ue.position,Ue.quaternion,Ue.scale),Ue.projectionMatrix.fromArray(Ne.projectionMatrix),Ue.projectionMatrixInverse.copy(Ue.projectionMatrix).invert(),Ue.viewport.set(Oe.x,Oe.y,Oe.width,Oe.height),xe===0&&(P.matrix.copy(Ue.matrix),P.matrix.decompose(P.position,P.quaternion,P.scale)),B===!0&&P.cameras.push(Ue)}const we=n.enabledFeatures;if(we&&we.includes("depth-sensing")&&n.depthUsage=="gpu-optimized"&&v){u=i.getBinding();const xe=u.getDepthInformation(ne[0]);xe&&xe.isValid&&xe.texture&&m.init(xe,n.renderState)}if(we&&we.includes("camera-access")&&v){e.state.unbindTexture(),u=i.getBinding();for(let xe=0;xe<ne.length;xe++){const Ne=ne[xe].camera;if(Ne){let Oe=g[Ne];Oe||(Oe=new Im,g[Ne]=Oe);const Ue=u.getCameraImage(Ne);Oe.sourceTexture=Ue}}}}for(let ne=0;ne<w.length;ne++){const B=E[ne],we=w[ne];B!==null&&we!==void 0&&we.update(B,re,l||a)}Be&&Be(Y,re),re.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:re}),p=null}const Ge=new zm;Ge.setAnimationLoop(je),this.setAnimationLoop=function(Y){Be=Y},this.dispose=function(){}}}const By=new Ye,Xm=new He;Xm.set(-1,0,0,0,1,0,0,0,1);function Hy(s,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,Pm(s)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function n(m,g,b,y,_){g.isNodeMaterial?g.uniformsNeedUpdate=!1:g.isMeshBasicMaterial?r(m,g):g.isMeshLambertMaterial?(r(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshToonMaterial?(r(m,g),u(m,g)):g.isMeshPhongMaterial?(r(m,g),h(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshStandardMaterial?(r(m,g),d(m,g),g.isMeshPhysicalMaterial&&f(m,g,_)):g.isMeshMatcapMaterial?(r(m,g),p(m,g)):g.isMeshDepthMaterial?r(m,g):g.isMeshDistanceMaterial?(r(m,g),v(m,g)):g.isMeshNormalMaterial?r(m,g):g.isLineBasicMaterial?(a(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?c(m,g,b,y):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function r(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===It&&(m.bumpScale.value*=-1)),g.normalMap&&(m.normalMap.value=g.normalMap,t(g.normalMap,m.normalMapTransform),m.normalScale.value.copy(g.normalScale),g.side===It&&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 b=e.get(g),y=b.envMap,_=b.envMapRotation;y&&(m.envMap.value=y,m.envMapRotation.value.setFromMatrix4(By.makeRotationFromEuler(_)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Xm),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 a(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,b,y){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*b,m.scale.value=y*.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,b){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===It&&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=b.texture,m.transmissionSamplerSize.value.set(b.width,b.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 b=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function Gy(s,e,t,i){let n={},r={},a=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function c(_,w){const E=w.program;i.uniformBlockBinding(_,E)}function l(_,w){let E=n[_.id];E===void 0&&(m(_),E=h(_),n[_.id]=E,_.addEventListener("dispose",b));const R=w.program;i.updateUBOMapping(_,R);const x=e.render.frame;r[_.id]!==x&&(d(_),r[_.id]=x)}function h(_){const w=u();_.__bindingPointIndex=w;const E=s.createBuffer(),R=_.__size,x=_.usage;return s.bindBuffer(s.UNIFORM_BUFFER,E),s.bufferData(s.UNIFORM_BUFFER,R,x),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,w,E),E}function u(){for(let _=0;_<o;_++)if(a.indexOf(_)===-1)return a.push(_),_;return ke("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(_){const w=n[_.id],E=_.uniforms,R=_.__cache;s.bindBuffer(s.UNIFORM_BUFFER,w);for(let x=0,A=E.length;x<A;x++){const I=E[x];if(Array.isArray(I))for(let C=0,P=I.length;C<P;C++)f(I[C],x,C,R);else f(I,x,0,R)}s.bindBuffer(s.UNIFORM_BUFFER,null)}function f(_,w,E,R){if(v(_,w,E,R)===!0){const x=_.__offset,A=_.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,_.__data,I),typeof P!="number"&&typeof P!="boolean"&&!P.isMatrix3&&!ArrayBuffer.isView(P)&&(I+=X.storage/Float32Array.BYTES_PER_ELEMENT)}}else p(A,_.__data,0);s.bufferSubData(s.UNIFORM_BUFFER,x,_.__data)}}function p(_,w,E){typeof _=="number"||typeof _=="boolean"?w[0]=_:_.isMatrix3?(w[0]=_.elements[0],w[1]=_.elements[1],w[2]=_.elements[2],w[3]=0,w[4]=_.elements[3],w[5]=_.elements[4],w[6]=_.elements[5],w[7]=0,w[8]=_.elements[6],w[9]=_.elements[7],w[10]=_.elements[8],w[11]=0):ArrayBuffer.isView(_)?w.set(new _.constructor(_.buffer,_.byteOffset,w.length)):_.toArray(w,E)}function v(_,w,E,R){const x=_.value,A=w+"_"+E;if(R[A]===void 0)return typeof x=="number"||typeof x=="boolean"?R[A]=x:ArrayBuffer.isView(x)?R[A]=x.slice():R[A]=x.clone(),!0;{const I=R[A];if(typeof x=="number"||typeof x=="boolean"){if(I!==x)return R[A]=x,!0}else{if(ArrayBuffer.isView(x))return!0;if(I.equals(x)===!1)return I.copy(x),!0}}return!1}function m(_){const w=_.uniforms;let E=0;const R=16;for(let A=0,I=w.length;A<I;A++){const C=Array.isArray(w[A])?w[A]:[w[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=E%R,ie=J%ee.boundary,ae=J+ie;E+=ie,ae!==0&&R-ae<ee.storage&&(E+=R-ae),z.__data=new Float32Array(ee.storage/Float32Array.BYTES_PER_ELEMENT),z.__offset=E,E+=ee.storage}}}const x=E%R;return x>0&&(E+=R-x),_.__size=E,_.__cache={},this}function g(_){const w={boundary:0,storage:0};return typeof _=="number"||typeof _=="boolean"?(w.boundary=4,w.storage=4):_.isVector2?(w.boundary=8,w.storage=8):_.isVector3||_.isColor?(w.boundary=16,w.storage=12):_.isVector4?(w.boundary=16,w.storage=16):_.isMatrix3?(w.boundary=48,w.storage=48):_.isMatrix4?(w.boundary=64,w.storage=64):_.isTexture?Ee("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(_)?(w.boundary=16,w.storage=_.byteLength):Ee("WebGLRenderer: Unsupported uniform value type.",_),w}function b(_){const w=_.target;w.removeEventListener("dispose",b);const E=a.indexOf(w.__bindingPointIndex);a.splice(E,1),s.deleteBuffer(n[w.id]),delete n[w.id],delete r[w.id]}function y(){for(const _ in n)s.deleteBuffer(n[_]);a=[],n={},r={}}return{bind:c,update:l,dispose:y}}const Vy=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 xn=null;function Wy(){return xn===null&&(xn=new tr(Vy,16,16,Zs,$t),xn.name="DFG_LUT",xn.minFilter=at,xn.magFilter=at,xn.wrapS=Ei,xn.wrapT=Ei,xn.generateMipmaps=!1,xn.needsUpdate=!0),xn}class Xy{constructor(e={}){const{canvas:t=_2(),context:i=null,depth:n=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=Bi}=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=a;const v=f,m=new Set([td,ed,Qu]),g=new Set([Bi,hn,Ya,Ka,Ju,ju]),b=new Uint32Array(4),y=new Int32Array(4),_=new D;let w=null,E=null;const R=[],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=In,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let C=!1,P=null,X=null,z=null,N=null;this._outputColorSpace=Pi;let V=0,k=0,K=null,ee=-1,J=null;const ie=new it,ae=new it;let Be=null;const je=new oe(0);let Ge=0,Y=t.width,re=t.height,ne=1,B=null,we=null;const Pe=new it(0,0,Y,re),Re=new it(0,0,Y,re);let xe=!1;const Ne=new cd;let Oe=!1,Ue=!1;const ct=new Ye,lt=new D,Nt=new it,Tt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ot=!1;function Wt(){return K===null?ne:1}let O=i;function Ti(S,U){return t.getContext(S,U)}try{const S={alpha:!0,depth:n,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ku}`),t.addEventListener("webglcontextlost",Ut,!1),t.addEventListener("webglcontextrestored",xt,!1),t.addEventListener("webglcontextcreationerror",pn,!1),O===null){const U="webgl2";if(O=Ti(U,S),O===null)throw Ti(U)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(S){throw ke("WebGLRenderer: "+S.message),S}let ht,T,M,F,W,$,se,le,Z,Q,he,De,fe,ue,Le,Fe,Xe,L,ce,j,de,ve,te;function Te(){ht=new W3(O),ht.init(),de=new Oy(O,ht),T=new U3(O,ht,e,de),M=new Ly(O,ht),T.reversedDepthBuffer&&d&&M.buffers.depth.setReversed(!0),X=O.createFramebuffer(),z=O.createFramebuffer(),N=O.createFramebuffer(),F=new Y3(O),W=new xy,$=new Ny(O,ht,M,W,T,de,F),se=new V3(I),le=new Jv(O),ve=new N3(O,le),Z=new X3(O,le,F,ve),Q=new $3(O,Z,le,ve,F),L=new K3(O,T,$),Le=new F3(W),he=new My(I,se,ht,T,ve,Le),De=new Hy(I,W),fe=new yy,ue=new Ty(ht),Xe=new L3(I,se,M,Q,p,c),Fe=new Py(I,Q,T),te=new Gy(O,F,T,M),ce=new O3(O,ht,F),j=new q3(O,ht,F),F.programs=he.programs,I.capabilities=T,I.extensions=ht,I.properties=W,I.renderLists=fe,I.shadowMap=Fe,I.state=M,I.info=F}Te(),v!==Bi&&(A=new J3(v,t.width,t.height,o,n,r));const ye=new zy(I,O);this.xr=ye,this.getContext=function(){return O},this.getContextAttributes=function(){return O.getContextAttributes()},this.forceContextLoss=function(){const S=ht.get("WEBGL_lose_context");S&&S.loseContext()},this.forceContextRestore=function(){const S=ht.get("WEBGL_lose_context");S&&S.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(S){S!==void 0&&(ne=S,this.setSize(Y,re,!1))},this.getSize=function(S){return S.set(Y,re)},this.setSize=function(S,U,q=!0){if(ye.isPresenting){Ee("WebGLRenderer: Can't change size while VR device is presenting.");return}Y=S,re=U,t.width=Math.floor(S*ne),t.height=Math.floor(U*ne),q===!0&&(t.style.width=S+"px",t.style.height=U+"px"),A!==null&&A.setSize(t.width,t.height),this.setViewport(0,0,S,U)},this.getDrawingBufferSize=function(S){return S.set(Y*ne,re*ne).floor()},this.setDrawingBufferSize=function(S,U,q){Y=S,re=U,ne=q,t.width=Math.floor(S*q),t.height=Math.floor(U*q),this.setViewport(0,0,S,U)},this.setEffects=function(S){if(v===Bi){ke("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(S){for(let U=0;U<S.length;U++)if(S[U].isOutputPass===!0){Ee("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(S||[])},this.getCurrentViewport=function(S){return S.copy(ie)},this.getViewport=function(S){return S.copy(Pe)},this.setViewport=function(S,U,q,H){S.isVector4?Pe.set(S.x,S.y,S.z,S.w):Pe.set(S,U,q,H),M.viewport(ie.copy(Pe).multiplyScalar(ne).round())},this.getScissor=function(S){return S.copy(Re)},this.setScissor=function(S,U,q,H){S.isVector4?Re.set(S.x,S.y,S.z,S.w):Re.set(S,U,q,H),M.scissor(ae.copy(Re).multiplyScalar(ne).round())},this.getScissorTest=function(){return xe},this.setScissorTest=function(S){M.setScissorTest(xe=S)},this.setOpaqueSort=function(S){B=S},this.setTransparentSort=function(S){we=S},this.getClearColor=function(S){return S.copy(Xe.getClearColor())},this.setClearColor=function(){Xe.setClearColor(...arguments)},this.getClearAlpha=function(){return Xe.getClearAlpha()},this.setClearAlpha=function(){Xe.setClearAlpha(...arguments)},this.clear=function(S=!0,U=!0,q=!0){let H=0;if(S){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=Xe.getClearColor(),be=Xe.getClearAlpha(),Ce=me.r,qe=me.g,$e=me.b;_e?(b[0]=Ce,b[1]=qe,b[2]=$e,b[3]=be,O.clearBufferuiv(O.COLOR,0,b)):(y[0]=Ce,y[1]=qe,y[2]=$e,y[3]=be,O.clearBufferiv(O.COLOR,0,y))}else H|=O.COLOR_BUFFER_BIT}U&&(H|=O.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),q&&(H|=O.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H!==0&&O.clear(H)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(S){S.setRenderer(this),P=S},this.dispose=function(){t.removeEventListener("webglcontextlost",Ut,!1),t.removeEventListener("webglcontextrestored",xt,!1),t.removeEventListener("webglcontextcreationerror",pn,!1),Xe.dispose(),fe.dispose(),ue.dispose(),W.dispose(),se.dispose(),Q.dispose(),ve.dispose(),te.dispose(),he.dispose(),ye.dispose(),ye.removeEventListener("sessionstart",Ld),ye.removeEventListener("sessionend",Nd),Rs.stop()};function Ut(S){S.preventDefault(),Dc("WebGLRenderer: Context Lost."),C=!0}function xt(){Dc("WebGLRenderer: Context Restored."),C=!1;const S=F.autoReset,U=Fe.enabled,q=Fe.autoUpdate,H=Fe.needsUpdate,G=Fe.type;Te(),F.autoReset=S,Fe.enabled=U,Fe.autoUpdate=q,Fe.needsUpdate=H,Fe.type=G}function pn(S){ke("WebGLRenderer: A WebGL context could not be created. Reason: ",S.statusMessage)}function mn(S){const U=S.target;U.removeEventListener("dispose",mn),Cg(U)}function Cg(S){Ig(S),W.remove(S)}function Ig(S){const U=W.get(S).programs;U!==void 0&&(U.forEach(function(q){he.releaseProgram(q)}),S.isShaderMaterial&&he.releaseShaderCache(S))}this.renderBufferDirect=function(S,U,q,H,G,ge){U===null&&(U=Tt);const _e=G.isMesh&&G.matrixWorld.determinantAffine()<0,me=Ng(S,U,q,H,G);M.setMaterial(H,_e);let be=q.index,Ce=1;if(H.wireframe===!0){if(be=Z.getWireframeAttribute(q),be===void 0)return;Ce=2}const qe=q.drawRange,$e=q.attributes.position;let Ie=qe.start*Ce,pt=(qe.start+qe.count)*Ce;ge!==null&&(Ie=Math.max(Ie,ge.start*Ce),pt=Math.min(pt,(ge.start+ge.count)*Ce)),be!==null?(Ie=Math.max(Ie,0),pt=Math.min(pt,be.count)):$e!=null&&(Ie=Math.max(Ie,0),pt=Math.min(pt,$e.count));const zt=pt-Ie;if(zt<0||zt===1/0)return;ve.setup(G,H,me,q,be);let Ft,gt=ce;if(be!==null&&(Ft=le.get(be),gt=j,gt.setIndex(Ft)),G.isMesh)H.wireframe===!0?(M.setLineWidth(H.wireframeLinewidth*Wt()),gt.setMode(O.LINES)):gt.setMode(O.TRIANGLES);else if(G.isLine){let pi=H.linewidth;pi===void 0&&(pi=1),M.setLineWidth(pi*Wt()),G.isLineSegments?gt.setMode(O.LINES):G.isLineLoop?gt.setMode(O.LINE_LOOP):gt.setMode(O.LINE_STRIP)}else G.isPoints?gt.setMode(O.POINTS):G.isSprite&>.setMode(O.TRIANGLES);if(G.isBatchedMesh)if(ht.get("WEBGL_multi_draw"))gt.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else{const pi=G._multiDrawStarts,Me=G._multiDrawCounts,Ni=G._multiDrawCount,tt=be?le.get(be).bytesPerElement:1,Gi=W.get(H).currentProgram.getUniforms();for(let gn=0;gn<Ni;gn++)Gi.setValue(O,"_gl_DrawID",gn),gt.render(pi[gn]/tt,Me[gn])}else if(G.isInstancedMesh)gt.renderInstances(Ie,zt,G.count);else if(q.isInstancedBufferGeometry){const pi=q._maxInstanceCount!==void 0?q._maxInstanceCount:1/0,Me=Math.min(q.instanceCount,pi);gt.renderInstances(Ie,zt,Me)}else gt.render(Ie,zt)};function Pd(S,U,q){S.transparent===!0&&S.side===on&&S.forceSinglePass===!1?(S.side=It,S.needsUpdate=!0,ao(S,U,q),S.side=Es,S.needsUpdate=!0,ao(S,U,q),S.side=on):ao(S,U,q)}this.compile=function(S,U,q=null){q===null&&(q=S),E=ue.get(q),E.init(U),x.push(E),q.traverseVisible(function(G){G.isLight&&G.layers.test(U.layers)&&(E.pushLight(G),G.castShadow&&E.pushShadow(G))}),S!==q&&S.traverseVisible(function(G){G.isLight&&G.layers.test(U.layers)&&(E.pushLight(G),G.castShadow&&E.pushShadow(G))}),E.setupLights();const H=new Set;return S.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];Pd(me,q,G),H.add(me)}else Pd(ge,q,G),H.add(ge)}),E=x.pop(),H},this.compileAsync=function(S,U,q=null){const H=this.compile(S,U,q);return new Promise(G=>{function ge(){if(H.forEach(function(_e){W.get(_e).currentProgram.isReady()&&H.delete(_e)}),H.size===0){G(S);return}setTimeout(ge,10)}ht.get("KHR_parallel_shader_compile")!==null?ge():setTimeout(ge,10)})};let il=null;function Pg(S){il&&il(S)}function Ld(){Rs.stop()}function Nd(){Rs.start()}const Rs=new zm;Rs.setAnimationLoop(Pg),typeof self<"u"&&Rs.setContext(self),this.setAnimationLoop=function(S){il=S,ye.setAnimationLoop(S),S===null?Rs.stop():Rs.start()},ye.addEventListener("sessionstart",Ld),ye.addEventListener("sessionend",Nd),this.render=function(S,U){if(U!==void 0&&U.isCamera!==!0){ke("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;P!==null&&P.renderStart(S,U);const q=ye.enabled===!0&&ye.isPresenting===!0,H=A!==null&&(K===null||q)&&A.begin(I,K);if(S.matrixWorldAutoUpdate===!0&&S.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),ye.enabled===!0&&ye.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(ye.cameraAutoUpdate===!0&&ye.updateCamera(U),U=ye.getCamera()),S.isScene===!0&&S.onBeforeRender(I,S,U,K),E=ue.get(S,x.length),E.init(U),E.state.textureUnits=$.getTextureUnits(),x.push(E),ct.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Ne.setFromProjectionMatrix(ct,Rn,U.reversedDepth),Ue=this.localClippingEnabled,Oe=Le.init(this.clippingPlanes,Ue),w=fe.get(S,R.length),w.init(),R.push(w),ye.enabled===!0&&ye.isPresenting===!0){const _e=I.xr.getDepthSensingMesh();_e!==null&&nl(_e,U,-1/0,I.sortObjects)}nl(S,U,0,I.sortObjects),w.finish(),I.sortObjects===!0&&w.sort(B,we,U.reversedDepth),Ot=ye.enabled===!1||ye.isPresenting===!1||ye.hasDepthSensing()===!1,Ot&&Xe.addToRenderList(w,S),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Oe===!0&&Le.beginShadows();const G=E.state.shadowsArray;if(Fe.render(G,S,U),Oe===!0&&Le.endShadows(),(H&&A.hasRenderPass())===!1){const _e=w.opaque,me=w.transmissive;if(E.setupLights(),U.isArrayCamera){const be=U.cameras;if(me.length>0)for(let Ce=0,qe=be.length;Ce<qe;Ce++){const $e=be[Ce];Ud(_e,me,S,$e)}Ot&&Xe.render(S);for(let Ce=0,qe=be.length;Ce<qe;Ce++){const $e=be[Ce];Od(w,S,$e,$e.viewport)}}else me.length>0&&Ud(_e,me,S,U),Ot&&Xe.render(S),Od(w,S,U)}K!==null&&k===0&&($.updateMultisampleRenderTarget(K),$.updateRenderTargetMipmap(K)),H&&A.end(I),S.isScene===!0&&S.onAfterRender(I,S,U),ve.resetDefaultState(),ee=-1,J=null,x.pop(),x.length>0?(E=x[x.length-1],$.setTextureUnits(E.state.textureUnits),Oe===!0&&Le.setGlobalState(I.clippingPlanes,E.state.camera)):E=null,R.pop(),R.length>0?w=R[R.length-1]:w=null,P!==null&&P.renderEnd()};function nl(S,U,q,H){if(S.visible===!1)return;if(S.layers.test(U.layers)){if(S.isGroup)q=S.renderOrder;else if(S.isLOD)S.autoUpdate===!0&&S.update(U);else if(S.isLightProbeGrid)E.pushLightProbeGrid(S);else if(S.isLight)E.pushLight(S),S.castShadow&&E.pushShadow(S);else if(S.isSprite){if(!S.frustumCulled||Ne.intersectsSprite(S)){H&&Nt.setFromMatrixPosition(S.matrixWorld).applyMatrix4(ct);const _e=Q.update(S),me=S.material;me.visible&&w.push(S,_e,me,q,Nt.z,null)}}else if((S.isMesh||S.isLine||S.isPoints)&&(!S.frustumCulled||Ne.intersectsObject(S))){const _e=Q.update(S),me=S.material;if(H&&(S.boundingSphere!==void 0?(S.boundingSphere===null&&S.computeBoundingSphere(),Nt.copy(S.boundingSphere.center)):(_e.boundingSphere===null&&_e.computeBoundingSphere(),Nt.copy(_e.boundingSphere.center)),Nt.applyMatrix4(S.matrixWorld).applyMatrix4(ct)),Array.isArray(me)){const be=_e.groups;for(let Ce=0,qe=be.length;Ce<qe;Ce++){const $e=be[Ce],Ie=me[$e.materialIndex];Ie&&Ie.visible&&w.push(S,_e,Ie,q,Nt.z,$e)}}else me.visible&&w.push(S,_e,me,q,Nt.z,null)}}const ge=S.children;for(let _e=0,me=ge.length;_e<me;_e++)nl(ge[_e],U,q,H)}function Od(S,U,q,H){const{opaque:G,transmissive:ge,transparent:_e}=S;E.setupLightsView(q),Oe===!0&&Le.setGlobalState(I.clippingPlanes,q),H&&M.viewport(ie.copy(H)),G.length>0&&ro(G,U,q),ge.length>0&&ro(ge,U,q),_e.length>0&&ro(_e,U,q),M.buffers.depth.setTest(!0),M.buffers.depth.setMask(!0),M.buffers.color.setMask(!0),M.setPolygonOffset(!1)}function Ud(S,U,q,H){if((q.isScene===!0?q.overrideMaterial:null)!==null)return;if(E.state.transmissionRenderTarget[H.id]===void 0){const Ie=ht.has("EXT_color_buffer_half_float")||ht.has("EXT_color_buffer_float");E.state.transmissionRenderTarget[H.id]=new ui(1,1,{generateMipmaps:!0,type:Ie?$t:Bi,minFilter:Gs,samples:Math.max(4,T.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:et.workingColorSpace})}const ge=E.state.transmissionRenderTarget[H.id],_e=H.viewport||ie;ge.setSize(_e.z*I.transmissionResolutionScale,_e.w*I.transmissionResolutionScale);const me=I.getRenderTarget(),be=I.getActiveCubeFace(),Ce=I.getActiveMipmapLevel();I.setRenderTarget(ge),I.getClearColor(je),Ge=I.getClearAlpha(),Ge<1&&I.setClearColor(16777215,.5),I.clear(),Ot&&Xe.render(q);const qe=I.toneMapping;I.toneMapping=In;const $e=H.viewport;if(H.viewport!==void 0&&(H.viewport=void 0),E.setupLightsView(H),Oe===!0&&Le.setGlobalState(I.clippingPlanes,H),ro(S,q,H),$.updateMultisampleRenderTarget(ge),$.updateRenderTargetMipmap(ge),ht.has("WEBGL_multisampled_render_to_texture")===!1){let Ie=!1;for(let pt=0,zt=U.length;pt<zt;pt++){const Ft=U[pt],{object:gt,geometry:pi,material:Me,group:Ni}=Ft;if(Me.side===on&>.layers.test(H.layers)){const tt=Me.side;Me.side=It,Me.needsUpdate=!0,Fd(gt,q,H,pi,Me,Ni),Me.side=tt,Me.needsUpdate=!0,Ie=!0}}Ie===!0&&($.updateMultisampleRenderTarget(ge),$.updateRenderTargetMipmap(ge))}I.setRenderTarget(me,be,Ce),I.setClearColor(je,Ge),$e!==void 0&&(H.viewport=$e),I.toneMapping=qe}function ro(S,U,q){const H=U.isScene===!0?U.overrideMaterial:null;for(let G=0,ge=S.length;G<ge;G++){const _e=S[G],{object:me,geometry:be,group:Ce}=_e;let qe=_e.material;qe.allowOverride===!0&&H!==null&&(qe=H),me.layers.test(q.layers)&&Fd(me,U,q,be,qe,Ce)}}function Fd(S,U,q,H,G,ge){S.onBeforeRender(I,U,q,H,G,ge),S.modelViewMatrix.multiplyMatrices(q.matrixWorldInverse,S.matrixWorld),S.normalMatrix.getNormalMatrix(S.modelViewMatrix),G.onBeforeRender(I,U,q,H,S,ge),G.transparent===!0&&G.side===on&&G.forceSinglePass===!1?(G.side=It,G.needsUpdate=!0,I.renderBufferDirect(q,U,H,G,S,ge),G.side=Es,G.needsUpdate=!0,I.renderBufferDirect(q,U,H,G,S,ge),G.side=on):I.renderBufferDirect(q,U,H,G,S,ge),S.onAfterRender(I,U,q,H,G,ge)}function ao(S,U,q){U.isScene!==!0&&(U=Tt);const H=W.get(S),G=E.state.lights,ge=E.state.shadowsArray,_e=G.state.version,me=he.getParameters(S,G.state,ge,U,q,E.state.lightProbeGridArray),be=he.getProgramCacheKey(me);let Ce=H.programs;H.environment=S.isMeshStandardMaterial||S.isMeshLambertMaterial||S.isMeshPhongMaterial?U.environment:null,H.fog=U.fog;const qe=S.isMeshStandardMaterial||S.isMeshLambertMaterial&&!S.envMap||S.isMeshPhongMaterial&&!S.envMap;H.envMap=se.get(S.envMap||H.environment,qe),H.envMapRotation=H.environment!==null&&S.envMap===null?U.environmentRotation:S.envMapRotation,Ce===void 0&&(S.addEventListener("dispose",mn),Ce=new Map,H.programs=Ce);let $e=Ce.get(be);if($e!==void 0){if(H.currentProgram===$e&&H.lightsStateVersion===_e)return zd(S,me),$e}else me.uniforms=he.getUniforms(S),P!==null&&S.isNodeMaterial&&P.build(S,q,me),S.onBeforeCompile(me,I),$e=he.acquireProgram(me,be),Ce.set(be,$e),H.uniforms=me.uniforms;const Ie=H.uniforms;return(!S.isShaderMaterial&&!S.isRawShaderMaterial||S.clipping===!0)&&(Ie.clippingPlanes=Le.uniform),zd(S,me),H.needsLights=Ug(S),H.lightsStateVersion=_e,H.needsLights&&(Ie.ambientLightColor.value=G.state.ambient,Ie.lightProbe.value=G.state.probe,Ie.directionalLights.value=G.state.directional,Ie.directionalLightShadows.value=G.state.directionalShadow,Ie.spotLights.value=G.state.spot,Ie.spotLightShadows.value=G.state.spotShadow,Ie.rectAreaLights.value=G.state.rectArea,Ie.ltc_1.value=G.state.rectAreaLTC1,Ie.ltc_2.value=G.state.rectAreaLTC2,Ie.pointLights.value=G.state.point,Ie.pointLightShadows.value=G.state.pointShadow,Ie.hemisphereLights.value=G.state.hemi,Ie.directionalShadowMatrix.value=G.state.directionalShadowMatrix,Ie.spotLightMatrix.value=G.state.spotLightMatrix,Ie.spotLightMap.value=G.state.spotLightMap,Ie.pointShadowMatrix.value=G.state.pointShadowMatrix),H.lightProbeGrid=E.state.lightProbeGridArray.length>0,H.currentProgram=$e,H.uniformsList=null,$e}function kd(S){if(S.uniformsList===null){const U=S.currentProgram.getUniforms();S.uniformsList=pc.seqWithValue(U.seq,S.uniforms)}return S.uniformsList}function zd(S,U){const q=W.get(S);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 Lg(S,U){if(S.length===0)return null;if(S.length===1)return S[0].texture!==null?S[0]:null;_.setFromMatrixPosition(U.matrixWorld);for(let q=0,H=S.length;q<H;q++){const G=S[q];if(G.texture!==null&&G.boundingBox.containsPoint(_))return G}return null}function Ng(S,U,q,H,G){U.isScene!==!0&&(U=Tt),$.resetTextureUnits();const ge=U.fog,_e=H.isMeshStandardMaterial||H.isMeshLambertMaterial||H.isMeshPhongMaterial?U.environment:null,me=K===null?I.outputColorSpace:K.isXRRenderTarget===!0?K.texture.colorSpace:et.workingColorSpace,be=H.isMeshStandardMaterial||H.isMeshLambertMaterial&&!H.envMap||H.isMeshPhongMaterial&&!H.envMap,Ce=se.get(H.envMap||_e,be),qe=H.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,$e=!!q.attributes.tangent&&(!!H.normalMap||H.anisotropy>0),Ie=!!q.morphAttributes.position,pt=!!q.morphAttributes.normal,zt=!!q.morphAttributes.color;let Ft=In;H.toneMapped&&(K===null||K.isXRRenderTarget===!0)&&(Ft=I.toneMapping);const gt=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,pi=gt!==void 0?gt.length:0,Me=W.get(H),Ni=E.state.lights;if(Oe===!0&&(Ue===!0||S!==J)){const _t=S===J&&H.id===ee;Le.setState(H,S,_t)}let tt=!1;H.version===Me.__version?(Me.needsLights&&Me.lightsStateVersion!==Ni.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!==Ce||H.fog===!0&&Me.fog!==ge||Me.numClippingPlanes!==void 0&&(Me.numClippingPlanes!==Le.numPlanes||Me.numIntersection!==Le.numIntersection)||Me.vertexAlphas!==qe||Me.vertexTangents!==$e||Me.morphTargets!==Ie||Me.morphNormals!==pt||Me.morphColors!==zt||Me.toneMapping!==Ft||Me.morphTargetsCount!==pi||!!Me.lightProbeGrid!=E.state.lightProbeGridArray.length>0)&&(tt=!0):(tt=!0,Me.__version=H.version);let Gi=Me.currentProgram;tt===!0&&(Gi=ao(H,U,G),P&&H.isNodeMaterial&&P.onUpdateProgram(H,Gi,Me));let gn=!1,ns=!1,ir=!1;const vt=Gi.getUniforms(),Bt=Me.uniforms;if(M.useProgram(Gi.program)&&(gn=!0,ns=!0,ir=!0),H.id!==ee&&(ee=H.id,ns=!0),Me.needsLights){const _t=Lg(E.state.lightProbeGridArray,G);Me.lightProbeGrid!==_t&&(Me.lightProbeGrid=_t,ns=!0)}if(gn||J!==S){M.buffers.depth.getReversed()&&S.reversedDepth!==!0&&(S._reversedDepth=!0,S.updateProjectionMatrix()),vt.setValue(O,"projectionMatrix",S.projectionMatrix),vt.setValue(O,"viewMatrix",S.matrixWorldInverse);const rs=vt.map.cameraPosition;rs!==void 0&&rs.setValue(O,lt.setFromMatrixPosition(S.matrixWorld)),T.logarithmicDepthBuffer&&vt.setValue(O,"logDepthBufFC",2/(Math.log(S.far+1)/Math.LN2)),(H.isMeshPhongMaterial||H.isMeshToonMaterial||H.isMeshLambertMaterial||H.isMeshBasicMaterial||H.isMeshStandardMaterial||H.isShaderMaterial)&&vt.setValue(O,"isOrthographic",S.isOrthographicCamera===!0),J!==S&&(J=S,ns=!0,ir=!0)}if(Me.needsLights&&(Ni.state.directionalShadowMap.length>0&&vt.setValue(O,"directionalShadowMap",Ni.state.directionalShadowMap,$),Ni.state.spotShadowMap.length>0&&vt.setValue(O,"spotShadowMap",Ni.state.spotShadowMap,$),Ni.state.pointShadowMap.length>0&&vt.setValue(O,"pointShadowMap",Ni.state.pointShadowMap,$)),G.isSkinnedMesh){vt.setOptional(O,G,"bindMatrix"),vt.setOptional(O,G,"bindMatrixInverse");const _t=G.skeleton;_t&&(_t.boneTexture===null&&_t.computeBoneTexture(),vt.setValue(O,"boneTexture",_t.boneTexture,$))}G.isBatchedMesh&&(vt.setOptional(O,G,"batchingTexture"),vt.setValue(O,"batchingTexture",G._matricesTexture,$),vt.setOptional(O,G,"batchingIdTexture"),vt.setValue(O,"batchingIdTexture",G._indirectTexture,$),vt.setOptional(O,G,"batchingColorTexture"),G._colorsTexture!==null&&vt.setValue(O,"batchingColorTexture",G._colorsTexture,$));const ss=q.morphAttributes;if((ss.position!==void 0||ss.normal!==void 0||ss.color!==void 0)&&L.update(G,q,Gi),(ns||Me.receiveShadow!==G.receiveShadow)&&(Me.receiveShadow=G.receiveShadow,vt.setValue(O,"receiveShadow",G.receiveShadow)),(H.isMeshStandardMaterial||H.isMeshLambertMaterial||H.isMeshPhongMaterial)&&H.envMap===null&&U.environment!==null&&(Bt.envMapIntensity.value=U.environmentIntensity),Bt.dfgLUT!==void 0&&(Bt.dfgLUT.value=Wy()),ns){if(vt.setValue(O,"toneMappingExposure",I.toneMappingExposure),Me.needsLights&&Og(Bt,ir),ge&&H.fog===!0&&De.refreshFogUniforms(Bt,ge),De.refreshMaterialUniforms(Bt,H,ne,re,E.state.transmissionRenderTarget[S.id]),Me.needsLights&&Me.lightProbeGrid){const _t=Me.lightProbeGrid;Bt.probesSH.value=_t.texture,Bt.probesMin.value.copy(_t.boundingBox.min),Bt.probesMax.value.copy(_t.boundingBox.max),Bt.probesResolution.value.copy(_t.resolution)}pc.upload(O,kd(Me),Bt,$)}if(H.isShaderMaterial&&H.uniformsNeedUpdate===!0&&(pc.upload(O,kd(Me),Bt,$),H.uniformsNeedUpdate=!1),H.isSpriteMaterial&&vt.setValue(O,"center",G.center),vt.setValue(O,"modelViewMatrix",G.modelViewMatrix),vt.setValue(O,"normalMatrix",G.normalMatrix),vt.setValue(O,"modelMatrix",G.matrixWorld),H.uniformsGroups!==void 0){const _t=H.uniformsGroups;for(let rs=0,nr=_t.length;rs<nr;rs++){const Bd=_t[rs];te.update(Bd,Gi),te.bind(Bd,Gi)}}return Gi}function Og(S,U){S.ambientLightColor.needsUpdate=U,S.lightProbe.needsUpdate=U,S.directionalLights.needsUpdate=U,S.directionalLightShadows.needsUpdate=U,S.pointLights.needsUpdate=U,S.pointLightShadows.needsUpdate=U,S.spotLights.needsUpdate=U,S.spotLightShadows.needsUpdate=U,S.rectAreaLights.needsUpdate=U,S.hemisphereLights.needsUpdate=U}function Ug(S){return S.isMeshLambertMaterial||S.isMeshToonMaterial||S.isMeshPhongMaterial||S.isMeshStandardMaterial||S.isShadowMaterial||S.isShaderMaterial&&S.lights===!0}this.getActiveCubeFace=function(){return V},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return K},this.setRenderTargetTextures=function(S,U,q){const H=W.get(S);H.__autoAllocateDepthBuffer=S.resolveDepthBuffer===!1,H.__autoAllocateDepthBuffer===!1&&(H.__useRenderToTexture=!1),W.get(S.texture).__webglTexture=U,W.get(S.depthTexture).__webglTexture=H.__autoAllocateDepthBuffer?void 0:q,H.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(S,U){const q=W.get(S);q.__webglFramebuffer=U,q.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(S,U=0,q=0){K=S,V=U,k=q;let H=null,G=!1,ge=!1;if(S){const me=W.get(S);if(me.__useDefaultFramebuffer!==void 0){M.bindFramebuffer(O.FRAMEBUFFER,me.__webglFramebuffer),ie.copy(S.viewport),ae.copy(S.scissor),Be=S.scissorTest,M.viewport(ie),M.scissor(ae),M.setScissorTest(Be),ee=-1;return}else if(me.__webglFramebuffer===void 0)$.setupRenderTarget(S);else if(me.__hasExternalTextures)$.rebindTextures(S,W.get(S.texture).__webglTexture,W.get(S.depthTexture).__webglTexture);else if(S.depthBuffer){const qe=S.depthTexture;if(me.__boundDepthTexture!==qe){if(qe!==null&&W.has(qe)&&(S.width!==qe.image.width||S.height!==qe.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");$.setupDepthRenderbuffer(S)}}const be=S.texture;(be.isData3DTexture||be.isDataArrayTexture||be.isCompressedArrayTexture)&&(ge=!0);const Ce=W.get(S).__webglFramebuffer;S.isWebGLCubeRenderTarget?(Array.isArray(Ce[U])?H=Ce[U][q]:H=Ce[U],G=!0):S.samples>0&&$.useMultisampledRTT(S)===!1?H=W.get(S).__webglMultisampledFramebuffer:Array.isArray(Ce)?H=Ce[q]:H=Ce,ie.copy(S.viewport),ae.copy(S.scissor),Be=S.scissorTest}else ie.copy(Pe).multiplyScalar(ne).floor(),ae.copy(Re).multiplyScalar(ne).floor(),Be=xe;if(q!==0&&(H=X),M.bindFramebuffer(O.FRAMEBUFFER,H)&&M.drawBuffers(S,H),M.viewport(ie),M.scissor(ae),M.setScissorTest(Be),G){const me=W.get(S.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<S.textures.length;be++){const Ce=W.get(S.textures[be]);O.framebufferTextureLayer(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0+be,Ce.__webglTexture,q,me)}}else if(S!==null&&q!==0){const me=W.get(S.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,me.__webglTexture,q)}ee=-1},this.readRenderTargetPixels=function(S,U,q,H,G,ge,_e,me=0){if(!(S&&S.isWebGLRenderTarget)){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let be=W.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&_e!==void 0&&(be=be[_e]),be){M.bindFramebuffer(O.FRAMEBUFFER,be);try{const Ce=S.textures[me],qe=Ce.format,$e=Ce.type;if(S.textures.length>1&&O.readBuffer(O.COLOR_ATTACHMENT0+me),!T.textureFormatReadable(qe)){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!T.textureTypeReadable($e)){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=S.width-H&&q>=0&&q<=S.height-G&&O.readPixels(U,q,H,G,de.convert(qe),de.convert($e),ge)}finally{const Ce=K!==null?W.get(K).__webglFramebuffer:null;M.bindFramebuffer(O.FRAMEBUFFER,Ce)}}},this.readRenderTargetPixelsAsync=async function(S,U,q,H,G,ge,_e,me=0){if(!(S&&S.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let be=W.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&_e!==void 0&&(be=be[_e]),be)if(U>=0&&U<=S.width-H&&q>=0&&q<=S.height-G){M.bindFramebuffer(O.FRAMEBUFFER,be);const Ce=S.textures[me],qe=Ce.format,$e=Ce.type;if(S.textures.length>1&&O.readBuffer(O.COLOR_ATTACHMENT0+me),!T.textureFormatReadable(qe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!T.textureTypeReadable($e))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ie=O.createBuffer();O.bindBuffer(O.PIXEL_PACK_BUFFER,Ie),O.bufferData(O.PIXEL_PACK_BUFFER,ge.byteLength,O.STREAM_READ),O.readPixels(U,q,H,G,de.convert(qe),de.convert($e),0);const pt=K!==null?W.get(K).__webglFramebuffer:null;M.bindFramebuffer(O.FRAMEBUFFER,pt);const zt=O.fenceSync(O.SYNC_GPU_COMMANDS_COMPLETE,0);return O.flush(),await y2(O,zt,4),O.bindBuffer(O.PIXEL_PACK_BUFFER,Ie),O.getBufferSubData(O.PIXEL_PACK_BUFFER,0,ge),O.deleteBuffer(Ie),O.deleteSync(zt),ge}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(S,U=null,q=0){const H=Math.pow(2,-q),G=Math.floor(S.image.width*H),ge=Math.floor(S.image.height*H),_e=U!==null?U.x:0,me=U!==null?U.y:0;$.setTexture2D(S,0),O.copyTexSubImage2D(O.TEXTURE_2D,q,0,0,_e,me,G,ge),M.unbindTexture()},this.copyTextureToTexture=function(S,U,q=null,H=null,G=0,ge=0){let _e,me,be,Ce,qe,$e,Ie,pt,zt;const Ft=S.isCompressedTexture?S.mipmaps[ge]:S.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,Ce=q.min.x,qe=q.min.y,$e=q.isBox3?q.min.z:0;else{const Bt=Math.pow(2,-G);_e=Math.floor(Ft.width*Bt),me=Math.floor(Ft.height*Bt),S.isDataArrayTexture?be=Ft.depth:S.isData3DTexture?be=Math.floor(Ft.depth*Bt):be=1,Ce=0,qe=0,$e=0}H!==null?(Ie=H.x,pt=H.y,zt=H.z):(Ie=0,pt=0,zt=0);const gt=de.convert(U.format),pi=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),M.activeTexture(O.TEXTURE0),M.pixelStorei(O.UNPACK_FLIP_Y_WEBGL,U.flipY),M.pixelStorei(O.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),M.pixelStorei(O.UNPACK_ALIGNMENT,U.unpackAlignment);const Ni=M.getParameter(O.UNPACK_ROW_LENGTH),tt=M.getParameter(O.UNPACK_IMAGE_HEIGHT),Gi=M.getParameter(O.UNPACK_SKIP_PIXELS),gn=M.getParameter(O.UNPACK_SKIP_ROWS),ns=M.getParameter(O.UNPACK_SKIP_IMAGES);M.pixelStorei(O.UNPACK_ROW_LENGTH,Ft.width),M.pixelStorei(O.UNPACK_IMAGE_HEIGHT,Ft.height),M.pixelStorei(O.UNPACK_SKIP_PIXELS,Ce),M.pixelStorei(O.UNPACK_SKIP_ROWS,qe),M.pixelStorei(O.UNPACK_SKIP_IMAGES,$e);const ir=S.isDataArrayTexture||S.isData3DTexture,vt=U.isDataArrayTexture||U.isData3DTexture;if(S.isDepthTexture){const Bt=W.get(S),ss=W.get(U),_t=W.get(Bt.__renderTarget),rs=W.get(ss.__renderTarget);M.bindFramebuffer(O.READ_FRAMEBUFFER,_t.__webglFramebuffer),M.bindFramebuffer(O.DRAW_FRAMEBUFFER,rs.__webglFramebuffer);for(let nr=0;nr<be;nr++)ir&&(O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,W.get(S).__webglTexture,G,$e+nr),O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,W.get(U).__webglTexture,ge,zt+nr)),O.blitFramebuffer(Ce,qe,_e,me,Ie,pt,_e,me,O.DEPTH_BUFFER_BIT,O.NEAREST);M.bindFramebuffer(O.READ_FRAMEBUFFER,null),M.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else if(G!==0||S.isRenderTargetTexture||W.has(S)){const Bt=W.get(S),ss=W.get(U);M.bindFramebuffer(O.READ_FRAMEBUFFER,z),M.bindFramebuffer(O.DRAW_FRAMEBUFFER,N);for(let _t=0;_t<be;_t++)ir?O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,Bt.__webglTexture,G,$e+_t):O.framebufferTexture2D(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,Bt.__webglTexture,G),vt?O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,ss.__webglTexture,ge,zt+_t):O.framebufferTexture2D(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,ss.__webglTexture,ge),G!==0?O.blitFramebuffer(Ce,qe,_e,me,Ie,pt,_e,me,O.COLOR_BUFFER_BIT,O.NEAREST):vt?O.copyTexSubImage3D(Me,ge,Ie,pt,zt+_t,Ce,qe,_e,me):O.copyTexSubImage2D(Me,ge,Ie,pt,Ce,qe,_e,me);M.bindFramebuffer(O.READ_FRAMEBUFFER,null),M.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else vt?S.isDataTexture||S.isData3DTexture?O.texSubImage3D(Me,ge,Ie,pt,zt,_e,me,be,gt,pi,Ft.data):U.isCompressedArrayTexture?O.compressedTexSubImage3D(Me,ge,Ie,pt,zt,_e,me,be,gt,Ft.data):O.texSubImage3D(Me,ge,Ie,pt,zt,_e,me,be,gt,pi,Ft):S.isDataTexture?O.texSubImage2D(O.TEXTURE_2D,ge,Ie,pt,_e,me,gt,pi,Ft.data):S.isCompressedTexture?O.compressedTexSubImage2D(O.TEXTURE_2D,ge,Ie,pt,Ft.width,Ft.height,gt,Ft.data):O.texSubImage2D(O.TEXTURE_2D,ge,Ie,pt,_e,me,gt,pi,Ft);M.pixelStorei(O.UNPACK_ROW_LENGTH,Ni),M.pixelStorei(O.UNPACK_IMAGE_HEIGHT,tt),M.pixelStorei(O.UNPACK_SKIP_PIXELS,Gi),M.pixelStorei(O.UNPACK_SKIP_ROWS,gn),M.pixelStorei(O.UNPACK_SKIP_IMAGES,ns),ge===0&&U.generateMipmaps&&O.generateMipmap(Me),M.unbindTexture()},this.initRenderTarget=function(S){W.get(S).__webglFramebuffer===void 0&&$.setupRenderTarget(S)},this.initTexture=function(S){S.isCubeTexture?$.setTextureCube(S,0):S.isData3DTexture?$.setTexture3D(S,0):S.isDataArrayTexture||S.isCompressedArrayTexture?$.setTexture2DArray(S,0):$.setTexture2D(S,0),M.unbindTexture()},this.resetState=function(){V=0,k=0,K=null,M.reset(),ve.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Rn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=et._getDrawingBufferColorSpace(e),t.unpackColorSpace=et._getUnpackColorSpace()}}const qy=`
|
|
4742
|
+
}`;class ky{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new Im(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 Et({vertexShader:Uy,fragmentShader:Fy,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new We(new dn(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class zy extends er{constructor(e,t){super();const i=this;let n=null,r=1,a=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 ky,g={},b=t.getContextAttributes();let y=null,_=null;const E=[],w=[],R=new Ae;let x=null;const A=new Ni;A.viewport=new it;const I=new Ni;I.viewport=new it;const C=[A,I],P=new Bv;let X=null,z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let re=E[Y];return re===void 0&&(re=new ml,E[Y]=re),re.getTargetRaySpace()},this.getControllerGrip=function(Y){let re=E[Y];return re===void 0&&(re=new ml,E[Y]=re),re.getGripSpace()},this.getHand=function(Y){let re=E[Y];return re===void 0&&(re=new ml,E[Y]=re),re.getHandSpace()};function N(Y){const re=w.indexOf(Y.inputSource);if(re===-1)return;const ne=E[re];ne!==void 0&&(ne.update(Y.inputSource,Y.frame,l||a),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<E.length;Y++){const re=w[Y];re!==null&&(w[Y]=null,E[Y].disconnect(re))}X=null,z=null,m.reset();for(const Y in g)delete g[Y];e.setRenderTarget(y),f=null,d=null,u=null,n=null,_=null,Ge.stop(),i.isPresenting=!1,e.setPixelRatio(x),e.setSize(R.width,R.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){r=Y,i.isPresenting===!0&&we("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,i.isPresenting===!0&&we("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&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(y=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),b.xrCompatible!==!0&&await t.makeXRCompatible(),x=e.getPixelRatio(),e.getSize(R),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let ne=null,B=null,Ee=null;b.depth&&(Ee=b.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ne=b.stencil?Vs:Jn,B=b.stencil?Ka:hn);const Pe={colorFormat:t.RGBA8,depthFormat:Ee,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(Pe),n.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),_=new ui(d.textureWidth,d.textureHeight,{format:xi,type:Hi,depthTexture:new Js(d.textureWidth,d.textureHeight,B,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:b.stencil,colorSpace:e.outputColorSpace,samples:b.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const ne={antialias:b.antialias,alpha:!0,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(n,t,ne),n.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),_=new ui(f.framebufferWidth,f.framebufferHeight,{format:xi,type:Hi,colorSpace:e.outputColorSpace,stencilBuffer:b.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await n.requestReferenceSpace(o),Ge.setContext(n),Ge.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],B=w.indexOf(ne);B>=0&&(w[B]=null,E[B].disconnect(ne))}for(let re=0;re<Y.added.length;re++){const ne=Y.added[re];let B=w.indexOf(ne);if(B===-1){for(let Pe=0;Pe<E.length;Pe++)if(Pe>=w.length){w.push(ne),B=Pe;break}else if(w[Pe]===null){w[Pe]=ne,B=Pe;break}if(B===-1)break}const Ee=E[B];Ee&&Ee.connect(ne)}}const K=new D,ee=new D;function J(Y,re,ne){K.setFromMatrixPosition(re.matrixWorld),ee.setFromMatrixPosition(ne.matrixWorld);const B=K.distanceTo(ee),Ee=re.projectionMatrix.elements,Pe=ne.projectionMatrix.elements,Re=Ee[14]/(Ee[10]-1),xe=Ee[14]/(Ee[10]+1),Ne=(Ee[9]+1)/Ee[5],Oe=(Ee[9]-1)/Ee[5],Ue=(Ee[8]-1)/Ee[0],ct=(Pe[8]+1)/Pe[0],lt=Re*Ue,Nt=Re*ct,Tt=B/(-Ue+ct),Ot=Tt*-Ue;if(re.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(Ot),Y.translateZ(Tt),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),Ee[10]===-1)Y.projectionMatrix.copy(re.projectionMatrix),Y.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{const Wt=Re+Tt,O=xe+Tt,Ri=lt-Ot,ht=Nt+(B-Ot),T=Ne*xe/O*Wt,M=Oe*xe/O*Wt;Y.projectionMatrix.makePerspective(Ri,ht,T,M,Wt,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 B=Y.parent,Ee=P.cameras;ie(P,B);for(let Pe=0;Pe<Ee.length;Pe++)ie(Ee[Pe],B);Ee.length===2?J(P,A,I):P.projectionMatrix.copy(A.projectionMatrix),ae(Y,P,B)};function ae(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=jr*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 Be=null;function je(Y,re){if(h=re.getViewerPose(l||a),p=re,h!==null){const ne=h.views;f!==null&&(e.setRenderTargetFramebuffer(_,f.framebuffer),e.setRenderTarget(_));let B=!1;ne.length!==P.cameras.length&&(P.cameras.length=0,B=!0);for(let xe=0;xe<ne.length;xe++){const Ne=ne[xe];let Oe=null;if(f!==null)Oe=f.getViewport(Ne);else{const ct=u.getViewSubImage(d,Ne);Oe=ct.viewport,xe===0&&(e.setRenderTargetTextures(_,ct.colorTexture,ct.depthStencilTexture),e.setRenderTarget(_))}let Ue=C[xe];Ue===void 0&&(Ue=new Ni,Ue.layers.enable(xe),Ue.viewport=new it,C[xe]=Ue),Ue.matrix.fromArray(Ne.transform.matrix),Ue.matrix.decompose(Ue.position,Ue.quaternion,Ue.scale),Ue.projectionMatrix.fromArray(Ne.projectionMatrix),Ue.projectionMatrixInverse.copy(Ue.projectionMatrix).invert(),Ue.viewport.set(Oe.x,Oe.y,Oe.width,Oe.height),xe===0&&(P.matrix.copy(Ue.matrix),P.matrix.decompose(P.position,P.quaternion,P.scale)),B===!0&&P.cameras.push(Ue)}const Ee=n.enabledFeatures;if(Ee&&Ee.includes("depth-sensing")&&n.depthUsage=="gpu-optimized"&&v){u=i.getBinding();const xe=u.getDepthInformation(ne[0]);xe&&xe.isValid&&xe.texture&&m.init(xe,n.renderState)}if(Ee&&Ee.includes("camera-access")&&v){e.state.unbindTexture(),u=i.getBinding();for(let xe=0;xe<ne.length;xe++){const Ne=ne[xe].camera;if(Ne){let Oe=g[Ne];Oe||(Oe=new Im,g[Ne]=Oe);const Ue=u.getCameraImage(Ne);Oe.sourceTexture=Ue}}}}for(let ne=0;ne<E.length;ne++){const B=w[ne],Ee=E[ne];B!==null&&Ee!==void 0&&Ee.update(B,re,l||a)}Be&&Be(Y,re),re.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:re}),p=null}const Ge=new zm;Ge.setAnimationLoop(je),this.setAnimationLoop=function(Y){Be=Y},this.dispose=function(){}}}const By=new Ye,Xm=new He;Xm.set(-1,0,0,0,1,0,0,0,1);function Hy(s,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,Pm(s)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function n(m,g,b,y,_){g.isNodeMaterial?g.uniformsNeedUpdate=!1:g.isMeshBasicMaterial?r(m,g):g.isMeshLambertMaterial?(r(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshToonMaterial?(r(m,g),u(m,g)):g.isMeshPhongMaterial?(r(m,g),h(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshStandardMaterial?(r(m,g),d(m,g),g.isMeshPhysicalMaterial&&f(m,g,_)):g.isMeshMatcapMaterial?(r(m,g),p(m,g)):g.isMeshDepthMaterial?r(m,g):g.isMeshDistanceMaterial?(r(m,g),v(m,g)):g.isMeshNormalMaterial?r(m,g):g.isLineBasicMaterial?(a(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?c(m,g,b,y):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function r(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===It&&(m.bumpScale.value*=-1)),g.normalMap&&(m.normalMap.value=g.normalMap,t(g.normalMap,m.normalMapTransform),m.normalScale.value.copy(g.normalScale),g.side===It&&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 b=e.get(g),y=b.envMap,_=b.envMapRotation;y&&(m.envMap.value=y,m.envMapRotation.value.setFromMatrix4(By.makeRotationFromEuler(_)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Xm),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 a(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,b,y){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*b,m.scale.value=y*.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,b){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===It&&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=b.texture,m.transmissionSamplerSize.value.set(b.width,b.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 b=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function Gy(s,e,t,i){let n={},r={},a=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function c(_,E){const w=E.program;i.uniformBlockBinding(_,w)}function l(_,E){let w=n[_.id];w===void 0&&(m(_),w=h(_),n[_.id]=w,_.addEventListener("dispose",b));const R=E.program;i.updateUBOMapping(_,R);const x=e.render.frame;r[_.id]!==x&&(d(_),r[_.id]=x)}function h(_){const E=u();_.__bindingPointIndex=E;const w=s.createBuffer(),R=_.__size,x=_.usage;return s.bindBuffer(s.UNIFORM_BUFFER,w),s.bufferData(s.UNIFORM_BUFFER,R,x),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,E,w),w}function u(){for(let _=0;_<o;_++)if(a.indexOf(_)===-1)return a.push(_),_;return ke("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(_){const E=n[_.id],w=_.uniforms,R=_.__cache;s.bindBuffer(s.UNIFORM_BUFFER,E);for(let x=0,A=w.length;x<A;x++){const I=w[x];if(Array.isArray(I))for(let C=0,P=I.length;C<P;C++)f(I[C],x,C,R);else f(I,x,0,R)}s.bindBuffer(s.UNIFORM_BUFFER,null)}function f(_,E,w,R){if(v(_,E,w,R)===!0){const x=_.__offset,A=_.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,_.__data,I),typeof P!="number"&&typeof P!="boolean"&&!P.isMatrix3&&!ArrayBuffer.isView(P)&&(I+=X.storage/Float32Array.BYTES_PER_ELEMENT)}}else p(A,_.__data,0);s.bufferSubData(s.UNIFORM_BUFFER,x,_.__data)}}function p(_,E,w){typeof _=="number"||typeof _=="boolean"?E[0]=_:_.isMatrix3?(E[0]=_.elements[0],E[1]=_.elements[1],E[2]=_.elements[2],E[3]=0,E[4]=_.elements[3],E[5]=_.elements[4],E[6]=_.elements[5],E[7]=0,E[8]=_.elements[6],E[9]=_.elements[7],E[10]=_.elements[8],E[11]=0):ArrayBuffer.isView(_)?E.set(new _.constructor(_.buffer,_.byteOffset,E.length)):_.toArray(E,w)}function v(_,E,w,R){const x=_.value,A=E+"_"+w;if(R[A]===void 0)return typeof x=="number"||typeof x=="boolean"?R[A]=x:ArrayBuffer.isView(x)?R[A]=x.slice():R[A]=x.clone(),!0;{const I=R[A];if(typeof x=="number"||typeof x=="boolean"){if(I!==x)return R[A]=x,!0}else{if(ArrayBuffer.isView(x))return!0;if(I.equals(x)===!1)return I.copy(x),!0}}return!1}function m(_){const E=_.uniforms;let w=0;const R=16;for(let A=0,I=E.length;A<I;A++){const C=Array.isArray(E[A])?E[A]:[E[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=w%R,ie=J%ee.boundary,ae=J+ie;w+=ie,ae!==0&&R-ae<ee.storage&&(w+=R-ae),z.__data=new Float32Array(ee.storage/Float32Array.BYTES_PER_ELEMENT),z.__offset=w,w+=ee.storage}}}const x=w%R;return x>0&&(w+=R-x),_.__size=w,_.__cache={},this}function g(_){const E={boundary:0,storage:0};return typeof _=="number"||typeof _=="boolean"?(E.boundary=4,E.storage=4):_.isVector2?(E.boundary=8,E.storage=8):_.isVector3||_.isColor?(E.boundary=16,E.storage=12):_.isVector4?(E.boundary=16,E.storage=16):_.isMatrix3?(E.boundary=48,E.storage=48):_.isMatrix4?(E.boundary=64,E.storage=64):_.isTexture?we("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(_)?(E.boundary=16,E.storage=_.byteLength):we("WebGLRenderer: Unsupported uniform value type.",_),E}function b(_){const E=_.target;E.removeEventListener("dispose",b);const w=a.indexOf(E.__bindingPointIndex);a.splice(w,1),s.deleteBuffer(n[E.id]),delete n[E.id],delete r[E.id]}function y(){for(const _ in n)s.deleteBuffer(n[_]);a=[],n={},r={}}return{bind:c,update:l,dispose:y}}const Vy=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 xn=null;function Wy(){return xn===null&&(xn=new tr(Vy,16,16,Zs,$t),xn.name="DFG_LUT",xn.minFilter=at,xn.magFilter=at,xn.wrapS=Ai,xn.wrapT=Ai,xn.generateMipmaps=!1,xn.needsUpdate=!0),xn}class Xy{constructor(e={}){const{canvas:t=_2(),context:i=null,depth:n=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=Hi}=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=a;const v=f,m=new Set([td,ed,Qu]),g=new Set([Hi,hn,Ya,Ka,Ju,ju]),b=new Uint32Array(4),y=new Int32Array(4),_=new D;let E=null,w=null;const R=[],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=In,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let C=!1,P=null,X=null,z=null,N=null;this._outputColorSpace=Li;let V=0,k=0,K=null,ee=-1,J=null;const ie=new it,ae=new it;let Be=null;const je=new oe(0);let Ge=0,Y=t.width,re=t.height,ne=1,B=null,Ee=null;const Pe=new it(0,0,Y,re),Re=new it(0,0,Y,re);let xe=!1;const Ne=new cd;let Oe=!1,Ue=!1;const ct=new Ye,lt=new D,Nt=new it,Tt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ot=!1;function Wt(){return K===null?ne:1}let O=i;function Ri(S,U){return t.getContext(S,U)}try{const S={alpha:!0,depth:n,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ku}`),t.addEventListener("webglcontextlost",Ut,!1),t.addEventListener("webglcontextrestored",xt,!1),t.addEventListener("webglcontextcreationerror",pn,!1),O===null){const U="webgl2";if(O=Ri(U,S),O===null)throw Ri(U)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(S){throw ke("WebGLRenderer: "+S.message),S}let ht,T,M,F,W,$,se,le,Z,Q,he,De,fe,ue,Le,Fe,Xe,L,ce,j,de,ve,te;function Te(){ht=new W3(O),ht.init(),de=new Oy(O,ht),T=new U3(O,ht,e,de),M=new Ly(O,ht),T.reversedDepthBuffer&&d&&M.buffers.depth.setReversed(!0),X=O.createFramebuffer(),z=O.createFramebuffer(),N=O.createFramebuffer(),F=new Y3(O),W=new xy,$=new Ny(O,ht,M,W,T,de,F),se=new V3(I),le=new Jv(O),ve=new N3(O,le),Z=new X3(O,le,F,ve),Q=new $3(O,Z,le,ve,F),L=new K3(O,T,$),Le=new F3(W),he=new My(I,se,ht,T,ve,Le),De=new Hy(I,W),fe=new yy,ue=new Ty(ht),Xe=new L3(I,se,M,Q,p,c),Fe=new Py(I,Q,T),te=new Gy(O,F,T,M),ce=new O3(O,ht,F),j=new q3(O,ht,F),F.programs=he.programs,I.capabilities=T,I.extensions=ht,I.properties=W,I.renderLists=fe,I.shadowMap=Fe,I.state=M,I.info=F}Te(),v!==Hi&&(A=new J3(v,t.width,t.height,o,n,r));const ye=new zy(I,O);this.xr=ye,this.getContext=function(){return O},this.getContextAttributes=function(){return O.getContextAttributes()},this.forceContextLoss=function(){const S=ht.get("WEBGL_lose_context");S&&S.loseContext()},this.forceContextRestore=function(){const S=ht.get("WEBGL_lose_context");S&&S.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(S){S!==void 0&&(ne=S,this.setSize(Y,re,!1))},this.getSize=function(S){return S.set(Y,re)},this.setSize=function(S,U,q=!0){if(ye.isPresenting){we("WebGLRenderer: Can't change size while VR device is presenting.");return}Y=S,re=U,t.width=Math.floor(S*ne),t.height=Math.floor(U*ne),q===!0&&(t.style.width=S+"px",t.style.height=U+"px"),A!==null&&A.setSize(t.width,t.height),this.setViewport(0,0,S,U)},this.getDrawingBufferSize=function(S){return S.set(Y*ne,re*ne).floor()},this.setDrawingBufferSize=function(S,U,q){Y=S,re=U,ne=q,t.width=Math.floor(S*q),t.height=Math.floor(U*q),this.setViewport(0,0,S,U)},this.setEffects=function(S){if(v===Hi){ke("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(S){for(let U=0;U<S.length;U++)if(S[U].isOutputPass===!0){we("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(S||[])},this.getCurrentViewport=function(S){return S.copy(ie)},this.getViewport=function(S){return S.copy(Pe)},this.setViewport=function(S,U,q,H){S.isVector4?Pe.set(S.x,S.y,S.z,S.w):Pe.set(S,U,q,H),M.viewport(ie.copy(Pe).multiplyScalar(ne).round())},this.getScissor=function(S){return S.copy(Re)},this.setScissor=function(S,U,q,H){S.isVector4?Re.set(S.x,S.y,S.z,S.w):Re.set(S,U,q,H),M.scissor(ae.copy(Re).multiplyScalar(ne).round())},this.getScissorTest=function(){return xe},this.setScissorTest=function(S){M.setScissorTest(xe=S)},this.setOpaqueSort=function(S){B=S},this.setTransparentSort=function(S){Ee=S},this.getClearColor=function(S){return S.copy(Xe.getClearColor())},this.setClearColor=function(){Xe.setClearColor(...arguments)},this.getClearAlpha=function(){return Xe.getClearAlpha()},this.setClearAlpha=function(){Xe.setClearAlpha(...arguments)},this.clear=function(S=!0,U=!0,q=!0){let H=0;if(S){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=Xe.getClearColor(),be=Xe.getClearAlpha(),Ce=me.r,qe=me.g,$e=me.b;_e?(b[0]=Ce,b[1]=qe,b[2]=$e,b[3]=be,O.clearBufferuiv(O.COLOR,0,b)):(y[0]=Ce,y[1]=qe,y[2]=$e,y[3]=be,O.clearBufferiv(O.COLOR,0,y))}else H|=O.COLOR_BUFFER_BIT}U&&(H|=O.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),q&&(H|=O.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H!==0&&O.clear(H)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(S){S.setRenderer(this),P=S},this.dispose=function(){t.removeEventListener("webglcontextlost",Ut,!1),t.removeEventListener("webglcontextrestored",xt,!1),t.removeEventListener("webglcontextcreationerror",pn,!1),Xe.dispose(),fe.dispose(),ue.dispose(),W.dispose(),se.dispose(),Q.dispose(),ve.dispose(),te.dispose(),he.dispose(),ye.dispose(),ye.removeEventListener("sessionstart",Ld),ye.removeEventListener("sessionend",Nd),Rs.stop()};function Ut(S){S.preventDefault(),Dc("WebGLRenderer: Context Lost."),C=!0}function xt(){Dc("WebGLRenderer: Context Restored."),C=!1;const S=F.autoReset,U=Fe.enabled,q=Fe.autoUpdate,H=Fe.needsUpdate,G=Fe.type;Te(),F.autoReset=S,Fe.enabled=U,Fe.autoUpdate=q,Fe.needsUpdate=H,Fe.type=G}function pn(S){ke("WebGLRenderer: A WebGL context could not be created. Reason: ",S.statusMessage)}function mn(S){const U=S.target;U.removeEventListener("dispose",mn),Cg(U)}function Cg(S){Ig(S),W.remove(S)}function Ig(S){const U=W.get(S).programs;U!==void 0&&(U.forEach(function(q){he.releaseProgram(q)}),S.isShaderMaterial&&he.releaseShaderCache(S))}this.renderBufferDirect=function(S,U,q,H,G,ge){U===null&&(U=Tt);const _e=G.isMesh&&G.matrixWorld.determinantAffine()<0,me=Ng(S,U,q,H,G);M.setMaterial(H,_e);let be=q.index,Ce=1;if(H.wireframe===!0){if(be=Z.getWireframeAttribute(q),be===void 0)return;Ce=2}const qe=q.drawRange,$e=q.attributes.position;let Ie=qe.start*Ce,pt=(qe.start+qe.count)*Ce;ge!==null&&(Ie=Math.max(Ie,ge.start*Ce),pt=Math.min(pt,(ge.start+ge.count)*Ce)),be!==null?(Ie=Math.max(Ie,0),pt=Math.min(pt,be.count)):$e!=null&&(Ie=Math.max(Ie,0),pt=Math.min(pt,$e.count));const zt=pt-Ie;if(zt<0||zt===1/0)return;ve.setup(G,H,me,q,be);let Ft,gt=ce;if(be!==null&&(Ft=le.get(be),gt=j,gt.setIndex(Ft)),G.isMesh)H.wireframe===!0?(M.setLineWidth(H.wireframeLinewidth*Wt()),gt.setMode(O.LINES)):gt.setMode(O.TRIANGLES);else if(G.isLine){let pi=H.linewidth;pi===void 0&&(pi=1),M.setLineWidth(pi*Wt()),G.isLineSegments?gt.setMode(O.LINES):G.isLineLoop?gt.setMode(O.LINE_LOOP):gt.setMode(O.LINE_STRIP)}else G.isPoints?gt.setMode(O.POINTS):G.isSprite&>.setMode(O.TRIANGLES);if(G.isBatchedMesh)if(ht.get("WEBGL_multi_draw"))gt.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else{const pi=G._multiDrawStarts,Me=G._multiDrawCounts,Oi=G._multiDrawCount,tt=be?le.get(be).bytesPerElement:1,Vi=W.get(H).currentProgram.getUniforms();for(let gn=0;gn<Oi;gn++)Vi.setValue(O,"_gl_DrawID",gn),gt.render(pi[gn]/tt,Me[gn])}else if(G.isInstancedMesh)gt.renderInstances(Ie,zt,G.count);else if(q.isInstancedBufferGeometry){const pi=q._maxInstanceCount!==void 0?q._maxInstanceCount:1/0,Me=Math.min(q.instanceCount,pi);gt.renderInstances(Ie,zt,Me)}else gt.render(Ie,zt)};function Pd(S,U,q){S.transparent===!0&&S.side===on&&S.forceSinglePass===!1?(S.side=It,S.needsUpdate=!0,ao(S,U,q),S.side=ws,S.needsUpdate=!0,ao(S,U,q),S.side=on):ao(S,U,q)}this.compile=function(S,U,q=null){q===null&&(q=S),w=ue.get(q),w.init(U),x.push(w),q.traverseVisible(function(G){G.isLight&&G.layers.test(U.layers)&&(w.pushLight(G),G.castShadow&&w.pushShadow(G))}),S!==q&&S.traverseVisible(function(G){G.isLight&&G.layers.test(U.layers)&&(w.pushLight(G),G.castShadow&&w.pushShadow(G))}),w.setupLights();const H=new Set;return S.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];Pd(me,q,G),H.add(me)}else Pd(ge,q,G),H.add(ge)}),w=x.pop(),H},this.compileAsync=function(S,U,q=null){const H=this.compile(S,U,q);return new Promise(G=>{function ge(){if(H.forEach(function(_e){W.get(_e).currentProgram.isReady()&&H.delete(_e)}),H.size===0){G(S);return}setTimeout(ge,10)}ht.get("KHR_parallel_shader_compile")!==null?ge():setTimeout(ge,10)})};let il=null;function Pg(S){il&&il(S)}function Ld(){Rs.stop()}function Nd(){Rs.start()}const Rs=new zm;Rs.setAnimationLoop(Pg),typeof self<"u"&&Rs.setContext(self),this.setAnimationLoop=function(S){il=S,ye.setAnimationLoop(S),S===null?Rs.stop():Rs.start()},ye.addEventListener("sessionstart",Ld),ye.addEventListener("sessionend",Nd),this.render=function(S,U){if(U!==void 0&&U.isCamera!==!0){ke("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;P!==null&&P.renderStart(S,U);const q=ye.enabled===!0&&ye.isPresenting===!0,H=A!==null&&(K===null||q)&&A.begin(I,K);if(S.matrixWorldAutoUpdate===!0&&S.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),ye.enabled===!0&&ye.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(ye.cameraAutoUpdate===!0&&ye.updateCamera(U),U=ye.getCamera()),S.isScene===!0&&S.onBeforeRender(I,S,U,K),w=ue.get(S,x.length),w.init(U),w.state.textureUnits=$.getTextureUnits(),x.push(w),ct.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Ne.setFromProjectionMatrix(ct,Rn,U.reversedDepth),Ue=this.localClippingEnabled,Oe=Le.init(this.clippingPlanes,Ue),E=fe.get(S,R.length),E.init(),R.push(E),ye.enabled===!0&&ye.isPresenting===!0){const _e=I.xr.getDepthSensingMesh();_e!==null&&nl(_e,U,-1/0,I.sortObjects)}nl(S,U,0,I.sortObjects),E.finish(),I.sortObjects===!0&&E.sort(B,Ee,U.reversedDepth),Ot=ye.enabled===!1||ye.isPresenting===!1||ye.hasDepthSensing()===!1,Ot&&Xe.addToRenderList(E,S),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Oe===!0&&Le.beginShadows();const G=w.state.shadowsArray;if(Fe.render(G,S,U),Oe===!0&&Le.endShadows(),(H&&A.hasRenderPass())===!1){const _e=E.opaque,me=E.transmissive;if(w.setupLights(),U.isArrayCamera){const be=U.cameras;if(me.length>0)for(let Ce=0,qe=be.length;Ce<qe;Ce++){const $e=be[Ce];Ud(_e,me,S,$e)}Ot&&Xe.render(S);for(let Ce=0,qe=be.length;Ce<qe;Ce++){const $e=be[Ce];Od(E,S,$e,$e.viewport)}}else me.length>0&&Ud(_e,me,S,U),Ot&&Xe.render(S),Od(E,S,U)}K!==null&&k===0&&($.updateMultisampleRenderTarget(K),$.updateRenderTargetMipmap(K)),H&&A.end(I),S.isScene===!0&&S.onAfterRender(I,S,U),ve.resetDefaultState(),ee=-1,J=null,x.pop(),x.length>0?(w=x[x.length-1],$.setTextureUnits(w.state.textureUnits),Oe===!0&&Le.setGlobalState(I.clippingPlanes,w.state.camera)):w=null,R.pop(),R.length>0?E=R[R.length-1]:E=null,P!==null&&P.renderEnd()};function nl(S,U,q,H){if(S.visible===!1)return;if(S.layers.test(U.layers)){if(S.isGroup)q=S.renderOrder;else if(S.isLOD)S.autoUpdate===!0&&S.update(U);else if(S.isLightProbeGrid)w.pushLightProbeGrid(S);else if(S.isLight)w.pushLight(S),S.castShadow&&w.pushShadow(S);else if(S.isSprite){if(!S.frustumCulled||Ne.intersectsSprite(S)){H&&Nt.setFromMatrixPosition(S.matrixWorld).applyMatrix4(ct);const _e=Q.update(S),me=S.material;me.visible&&E.push(S,_e,me,q,Nt.z,null)}}else if((S.isMesh||S.isLine||S.isPoints)&&(!S.frustumCulled||Ne.intersectsObject(S))){const _e=Q.update(S),me=S.material;if(H&&(S.boundingSphere!==void 0?(S.boundingSphere===null&&S.computeBoundingSphere(),Nt.copy(S.boundingSphere.center)):(_e.boundingSphere===null&&_e.computeBoundingSphere(),Nt.copy(_e.boundingSphere.center)),Nt.applyMatrix4(S.matrixWorld).applyMatrix4(ct)),Array.isArray(me)){const be=_e.groups;for(let Ce=0,qe=be.length;Ce<qe;Ce++){const $e=be[Ce],Ie=me[$e.materialIndex];Ie&&Ie.visible&&E.push(S,_e,Ie,q,Nt.z,$e)}}else me.visible&&E.push(S,_e,me,q,Nt.z,null)}}const ge=S.children;for(let _e=0,me=ge.length;_e<me;_e++)nl(ge[_e],U,q,H)}function Od(S,U,q,H){const{opaque:G,transmissive:ge,transparent:_e}=S;w.setupLightsView(q),Oe===!0&&Le.setGlobalState(I.clippingPlanes,q),H&&M.viewport(ie.copy(H)),G.length>0&&ro(G,U,q),ge.length>0&&ro(ge,U,q),_e.length>0&&ro(_e,U,q),M.buffers.depth.setTest(!0),M.buffers.depth.setMask(!0),M.buffers.color.setMask(!0),M.setPolygonOffset(!1)}function Ud(S,U,q,H){if((q.isScene===!0?q.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[H.id]===void 0){const Ie=ht.has("EXT_color_buffer_half_float")||ht.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[H.id]=new ui(1,1,{generateMipmaps:!0,type:Ie?$t:Hi,minFilter:Gs,samples:Math.max(4,T.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:et.workingColorSpace})}const ge=w.state.transmissionRenderTarget[H.id],_e=H.viewport||ie;ge.setSize(_e.z*I.transmissionResolutionScale,_e.w*I.transmissionResolutionScale);const me=I.getRenderTarget(),be=I.getActiveCubeFace(),Ce=I.getActiveMipmapLevel();I.setRenderTarget(ge),I.getClearColor(je),Ge=I.getClearAlpha(),Ge<1&&I.setClearColor(16777215,.5),I.clear(),Ot&&Xe.render(q);const qe=I.toneMapping;I.toneMapping=In;const $e=H.viewport;if(H.viewport!==void 0&&(H.viewport=void 0),w.setupLightsView(H),Oe===!0&&Le.setGlobalState(I.clippingPlanes,H),ro(S,q,H),$.updateMultisampleRenderTarget(ge),$.updateRenderTargetMipmap(ge),ht.has("WEBGL_multisampled_render_to_texture")===!1){let Ie=!1;for(let pt=0,zt=U.length;pt<zt;pt++){const Ft=U[pt],{object:gt,geometry:pi,material:Me,group:Oi}=Ft;if(Me.side===on&>.layers.test(H.layers)){const tt=Me.side;Me.side=It,Me.needsUpdate=!0,Fd(gt,q,H,pi,Me,Oi),Me.side=tt,Me.needsUpdate=!0,Ie=!0}}Ie===!0&&($.updateMultisampleRenderTarget(ge),$.updateRenderTargetMipmap(ge))}I.setRenderTarget(me,be,Ce),I.setClearColor(je,Ge),$e!==void 0&&(H.viewport=$e),I.toneMapping=qe}function ro(S,U,q){const H=U.isScene===!0?U.overrideMaterial:null;for(let G=0,ge=S.length;G<ge;G++){const _e=S[G],{object:me,geometry:be,group:Ce}=_e;let qe=_e.material;qe.allowOverride===!0&&H!==null&&(qe=H),me.layers.test(q.layers)&&Fd(me,U,q,be,qe,Ce)}}function Fd(S,U,q,H,G,ge){S.onBeforeRender(I,U,q,H,G,ge),S.modelViewMatrix.multiplyMatrices(q.matrixWorldInverse,S.matrixWorld),S.normalMatrix.getNormalMatrix(S.modelViewMatrix),G.onBeforeRender(I,U,q,H,S,ge),G.transparent===!0&&G.side===on&&G.forceSinglePass===!1?(G.side=It,G.needsUpdate=!0,I.renderBufferDirect(q,U,H,G,S,ge),G.side=ws,G.needsUpdate=!0,I.renderBufferDirect(q,U,H,G,S,ge),G.side=on):I.renderBufferDirect(q,U,H,G,S,ge),S.onAfterRender(I,U,q,H,G,ge)}function ao(S,U,q){U.isScene!==!0&&(U=Tt);const H=W.get(S),G=w.state.lights,ge=w.state.shadowsArray,_e=G.state.version,me=he.getParameters(S,G.state,ge,U,q,w.state.lightProbeGridArray),be=he.getProgramCacheKey(me);let Ce=H.programs;H.environment=S.isMeshStandardMaterial||S.isMeshLambertMaterial||S.isMeshPhongMaterial?U.environment:null,H.fog=U.fog;const qe=S.isMeshStandardMaterial||S.isMeshLambertMaterial&&!S.envMap||S.isMeshPhongMaterial&&!S.envMap;H.envMap=se.get(S.envMap||H.environment,qe),H.envMapRotation=H.environment!==null&&S.envMap===null?U.environmentRotation:S.envMapRotation,Ce===void 0&&(S.addEventListener("dispose",mn),Ce=new Map,H.programs=Ce);let $e=Ce.get(be);if($e!==void 0){if(H.currentProgram===$e&&H.lightsStateVersion===_e)return zd(S,me),$e}else me.uniforms=he.getUniforms(S),P!==null&&S.isNodeMaterial&&P.build(S,q,me),S.onBeforeCompile(me,I),$e=he.acquireProgram(me,be),Ce.set(be,$e),H.uniforms=me.uniforms;const Ie=H.uniforms;return(!S.isShaderMaterial&&!S.isRawShaderMaterial||S.clipping===!0)&&(Ie.clippingPlanes=Le.uniform),zd(S,me),H.needsLights=Ug(S),H.lightsStateVersion=_e,H.needsLights&&(Ie.ambientLightColor.value=G.state.ambient,Ie.lightProbe.value=G.state.probe,Ie.directionalLights.value=G.state.directional,Ie.directionalLightShadows.value=G.state.directionalShadow,Ie.spotLights.value=G.state.spot,Ie.spotLightShadows.value=G.state.spotShadow,Ie.rectAreaLights.value=G.state.rectArea,Ie.ltc_1.value=G.state.rectAreaLTC1,Ie.ltc_2.value=G.state.rectAreaLTC2,Ie.pointLights.value=G.state.point,Ie.pointLightShadows.value=G.state.pointShadow,Ie.hemisphereLights.value=G.state.hemi,Ie.directionalShadowMatrix.value=G.state.directionalShadowMatrix,Ie.spotLightMatrix.value=G.state.spotLightMatrix,Ie.spotLightMap.value=G.state.spotLightMap,Ie.pointShadowMatrix.value=G.state.pointShadowMatrix),H.lightProbeGrid=w.state.lightProbeGridArray.length>0,H.currentProgram=$e,H.uniformsList=null,$e}function kd(S){if(S.uniformsList===null){const U=S.currentProgram.getUniforms();S.uniformsList=pc.seqWithValue(U.seq,S.uniforms)}return S.uniformsList}function zd(S,U){const q=W.get(S);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 Lg(S,U){if(S.length===0)return null;if(S.length===1)return S[0].texture!==null?S[0]:null;_.setFromMatrixPosition(U.matrixWorld);for(let q=0,H=S.length;q<H;q++){const G=S[q];if(G.texture!==null&&G.boundingBox.containsPoint(_))return G}return null}function Ng(S,U,q,H,G){U.isScene!==!0&&(U=Tt),$.resetTextureUnits();const ge=U.fog,_e=H.isMeshStandardMaterial||H.isMeshLambertMaterial||H.isMeshPhongMaterial?U.environment:null,me=K===null?I.outputColorSpace:K.isXRRenderTarget===!0?K.texture.colorSpace:et.workingColorSpace,be=H.isMeshStandardMaterial||H.isMeshLambertMaterial&&!H.envMap||H.isMeshPhongMaterial&&!H.envMap,Ce=se.get(H.envMap||_e,be),qe=H.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,$e=!!q.attributes.tangent&&(!!H.normalMap||H.anisotropy>0),Ie=!!q.morphAttributes.position,pt=!!q.morphAttributes.normal,zt=!!q.morphAttributes.color;let Ft=In;H.toneMapped&&(K===null||K.isXRRenderTarget===!0)&&(Ft=I.toneMapping);const gt=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,pi=gt!==void 0?gt.length:0,Me=W.get(H),Oi=w.state.lights;if(Oe===!0&&(Ue===!0||S!==J)){const _t=S===J&&H.id===ee;Le.setState(H,S,_t)}let tt=!1;H.version===Me.__version?(Me.needsLights&&Me.lightsStateVersion!==Oi.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!==Ce||H.fog===!0&&Me.fog!==ge||Me.numClippingPlanes!==void 0&&(Me.numClippingPlanes!==Le.numPlanes||Me.numIntersection!==Le.numIntersection)||Me.vertexAlphas!==qe||Me.vertexTangents!==$e||Me.morphTargets!==Ie||Me.morphNormals!==pt||Me.morphColors!==zt||Me.toneMapping!==Ft||Me.morphTargetsCount!==pi||!!Me.lightProbeGrid!=w.state.lightProbeGridArray.length>0)&&(tt=!0):(tt=!0,Me.__version=H.version);let Vi=Me.currentProgram;tt===!0&&(Vi=ao(H,U,G),P&&H.isNodeMaterial&&P.onUpdateProgram(H,Vi,Me));let gn=!1,ns=!1,ir=!1;const vt=Vi.getUniforms(),Bt=Me.uniforms;if(M.useProgram(Vi.program)&&(gn=!0,ns=!0,ir=!0),H.id!==ee&&(ee=H.id,ns=!0),Me.needsLights){const _t=Lg(w.state.lightProbeGridArray,G);Me.lightProbeGrid!==_t&&(Me.lightProbeGrid=_t,ns=!0)}if(gn||J!==S){M.buffers.depth.getReversed()&&S.reversedDepth!==!0&&(S._reversedDepth=!0,S.updateProjectionMatrix()),vt.setValue(O,"projectionMatrix",S.projectionMatrix),vt.setValue(O,"viewMatrix",S.matrixWorldInverse);const rs=vt.map.cameraPosition;rs!==void 0&&rs.setValue(O,lt.setFromMatrixPosition(S.matrixWorld)),T.logarithmicDepthBuffer&&vt.setValue(O,"logDepthBufFC",2/(Math.log(S.far+1)/Math.LN2)),(H.isMeshPhongMaterial||H.isMeshToonMaterial||H.isMeshLambertMaterial||H.isMeshBasicMaterial||H.isMeshStandardMaterial||H.isShaderMaterial)&&vt.setValue(O,"isOrthographic",S.isOrthographicCamera===!0),J!==S&&(J=S,ns=!0,ir=!0)}if(Me.needsLights&&(Oi.state.directionalShadowMap.length>0&&vt.setValue(O,"directionalShadowMap",Oi.state.directionalShadowMap,$),Oi.state.spotShadowMap.length>0&&vt.setValue(O,"spotShadowMap",Oi.state.spotShadowMap,$),Oi.state.pointShadowMap.length>0&&vt.setValue(O,"pointShadowMap",Oi.state.pointShadowMap,$)),G.isSkinnedMesh){vt.setOptional(O,G,"bindMatrix"),vt.setOptional(O,G,"bindMatrixInverse");const _t=G.skeleton;_t&&(_t.boneTexture===null&&_t.computeBoneTexture(),vt.setValue(O,"boneTexture",_t.boneTexture,$))}G.isBatchedMesh&&(vt.setOptional(O,G,"batchingTexture"),vt.setValue(O,"batchingTexture",G._matricesTexture,$),vt.setOptional(O,G,"batchingIdTexture"),vt.setValue(O,"batchingIdTexture",G._indirectTexture,$),vt.setOptional(O,G,"batchingColorTexture"),G._colorsTexture!==null&&vt.setValue(O,"batchingColorTexture",G._colorsTexture,$));const ss=q.morphAttributes;if((ss.position!==void 0||ss.normal!==void 0||ss.color!==void 0)&&L.update(G,q,Vi),(ns||Me.receiveShadow!==G.receiveShadow)&&(Me.receiveShadow=G.receiveShadow,vt.setValue(O,"receiveShadow",G.receiveShadow)),(H.isMeshStandardMaterial||H.isMeshLambertMaterial||H.isMeshPhongMaterial)&&H.envMap===null&&U.environment!==null&&(Bt.envMapIntensity.value=U.environmentIntensity),Bt.dfgLUT!==void 0&&(Bt.dfgLUT.value=Wy()),ns){if(vt.setValue(O,"toneMappingExposure",I.toneMappingExposure),Me.needsLights&&Og(Bt,ir),ge&&H.fog===!0&&De.refreshFogUniforms(Bt,ge),De.refreshMaterialUniforms(Bt,H,ne,re,w.state.transmissionRenderTarget[S.id]),Me.needsLights&&Me.lightProbeGrid){const _t=Me.lightProbeGrid;Bt.probesSH.value=_t.texture,Bt.probesMin.value.copy(_t.boundingBox.min),Bt.probesMax.value.copy(_t.boundingBox.max),Bt.probesResolution.value.copy(_t.resolution)}pc.upload(O,kd(Me),Bt,$)}if(H.isShaderMaterial&&H.uniformsNeedUpdate===!0&&(pc.upload(O,kd(Me),Bt,$),H.uniformsNeedUpdate=!1),H.isSpriteMaterial&&vt.setValue(O,"center",G.center),vt.setValue(O,"modelViewMatrix",G.modelViewMatrix),vt.setValue(O,"normalMatrix",G.normalMatrix),vt.setValue(O,"modelMatrix",G.matrixWorld),H.uniformsGroups!==void 0){const _t=H.uniformsGroups;for(let rs=0,nr=_t.length;rs<nr;rs++){const Bd=_t[rs];te.update(Bd,Vi),te.bind(Bd,Vi)}}return Vi}function Og(S,U){S.ambientLightColor.needsUpdate=U,S.lightProbe.needsUpdate=U,S.directionalLights.needsUpdate=U,S.directionalLightShadows.needsUpdate=U,S.pointLights.needsUpdate=U,S.pointLightShadows.needsUpdate=U,S.spotLights.needsUpdate=U,S.spotLightShadows.needsUpdate=U,S.rectAreaLights.needsUpdate=U,S.hemisphereLights.needsUpdate=U}function Ug(S){return S.isMeshLambertMaterial||S.isMeshToonMaterial||S.isMeshPhongMaterial||S.isMeshStandardMaterial||S.isShadowMaterial||S.isShaderMaterial&&S.lights===!0}this.getActiveCubeFace=function(){return V},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return K},this.setRenderTargetTextures=function(S,U,q){const H=W.get(S);H.__autoAllocateDepthBuffer=S.resolveDepthBuffer===!1,H.__autoAllocateDepthBuffer===!1&&(H.__useRenderToTexture=!1),W.get(S.texture).__webglTexture=U,W.get(S.depthTexture).__webglTexture=H.__autoAllocateDepthBuffer?void 0:q,H.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(S,U){const q=W.get(S);q.__webglFramebuffer=U,q.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(S,U=0,q=0){K=S,V=U,k=q;let H=null,G=!1,ge=!1;if(S){const me=W.get(S);if(me.__useDefaultFramebuffer!==void 0){M.bindFramebuffer(O.FRAMEBUFFER,me.__webglFramebuffer),ie.copy(S.viewport),ae.copy(S.scissor),Be=S.scissorTest,M.viewport(ie),M.scissor(ae),M.setScissorTest(Be),ee=-1;return}else if(me.__webglFramebuffer===void 0)$.setupRenderTarget(S);else if(me.__hasExternalTextures)$.rebindTextures(S,W.get(S.texture).__webglTexture,W.get(S.depthTexture).__webglTexture);else if(S.depthBuffer){const qe=S.depthTexture;if(me.__boundDepthTexture!==qe){if(qe!==null&&W.has(qe)&&(S.width!==qe.image.width||S.height!==qe.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");$.setupDepthRenderbuffer(S)}}const be=S.texture;(be.isData3DTexture||be.isDataArrayTexture||be.isCompressedArrayTexture)&&(ge=!0);const Ce=W.get(S).__webglFramebuffer;S.isWebGLCubeRenderTarget?(Array.isArray(Ce[U])?H=Ce[U][q]:H=Ce[U],G=!0):S.samples>0&&$.useMultisampledRTT(S)===!1?H=W.get(S).__webglMultisampledFramebuffer:Array.isArray(Ce)?H=Ce[q]:H=Ce,ie.copy(S.viewport),ae.copy(S.scissor),Be=S.scissorTest}else ie.copy(Pe).multiplyScalar(ne).floor(),ae.copy(Re).multiplyScalar(ne).floor(),Be=xe;if(q!==0&&(H=X),M.bindFramebuffer(O.FRAMEBUFFER,H)&&M.drawBuffers(S,H),M.viewport(ie),M.scissor(ae),M.setScissorTest(Be),G){const me=W.get(S.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<S.textures.length;be++){const Ce=W.get(S.textures[be]);O.framebufferTextureLayer(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0+be,Ce.__webglTexture,q,me)}}else if(S!==null&&q!==0){const me=W.get(S.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,me.__webglTexture,q)}ee=-1},this.readRenderTargetPixels=function(S,U,q,H,G,ge,_e,me=0){if(!(S&&S.isWebGLRenderTarget)){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let be=W.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&_e!==void 0&&(be=be[_e]),be){M.bindFramebuffer(O.FRAMEBUFFER,be);try{const Ce=S.textures[me],qe=Ce.format,$e=Ce.type;if(S.textures.length>1&&O.readBuffer(O.COLOR_ATTACHMENT0+me),!T.textureFormatReadable(qe)){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!T.textureTypeReadable($e)){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=S.width-H&&q>=0&&q<=S.height-G&&O.readPixels(U,q,H,G,de.convert(qe),de.convert($e),ge)}finally{const Ce=K!==null?W.get(K).__webglFramebuffer:null;M.bindFramebuffer(O.FRAMEBUFFER,Ce)}}},this.readRenderTargetPixelsAsync=async function(S,U,q,H,G,ge,_e,me=0){if(!(S&&S.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let be=W.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&_e!==void 0&&(be=be[_e]),be)if(U>=0&&U<=S.width-H&&q>=0&&q<=S.height-G){M.bindFramebuffer(O.FRAMEBUFFER,be);const Ce=S.textures[me],qe=Ce.format,$e=Ce.type;if(S.textures.length>1&&O.readBuffer(O.COLOR_ATTACHMENT0+me),!T.textureFormatReadable(qe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!T.textureTypeReadable($e))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ie=O.createBuffer();O.bindBuffer(O.PIXEL_PACK_BUFFER,Ie),O.bufferData(O.PIXEL_PACK_BUFFER,ge.byteLength,O.STREAM_READ),O.readPixels(U,q,H,G,de.convert(qe),de.convert($e),0);const pt=K!==null?W.get(K).__webglFramebuffer:null;M.bindFramebuffer(O.FRAMEBUFFER,pt);const zt=O.fenceSync(O.SYNC_GPU_COMMANDS_COMPLETE,0);return O.flush(),await y2(O,zt,4),O.bindBuffer(O.PIXEL_PACK_BUFFER,Ie),O.getBufferSubData(O.PIXEL_PACK_BUFFER,0,ge),O.deleteBuffer(Ie),O.deleteSync(zt),ge}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(S,U=null,q=0){const H=Math.pow(2,-q),G=Math.floor(S.image.width*H),ge=Math.floor(S.image.height*H),_e=U!==null?U.x:0,me=U!==null?U.y:0;$.setTexture2D(S,0),O.copyTexSubImage2D(O.TEXTURE_2D,q,0,0,_e,me,G,ge),M.unbindTexture()},this.copyTextureToTexture=function(S,U,q=null,H=null,G=0,ge=0){let _e,me,be,Ce,qe,$e,Ie,pt,zt;const Ft=S.isCompressedTexture?S.mipmaps[ge]:S.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,Ce=q.min.x,qe=q.min.y,$e=q.isBox3?q.min.z:0;else{const Bt=Math.pow(2,-G);_e=Math.floor(Ft.width*Bt),me=Math.floor(Ft.height*Bt),S.isDataArrayTexture?be=Ft.depth:S.isData3DTexture?be=Math.floor(Ft.depth*Bt):be=1,Ce=0,qe=0,$e=0}H!==null?(Ie=H.x,pt=H.y,zt=H.z):(Ie=0,pt=0,zt=0);const gt=de.convert(U.format),pi=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),M.activeTexture(O.TEXTURE0),M.pixelStorei(O.UNPACK_FLIP_Y_WEBGL,U.flipY),M.pixelStorei(O.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),M.pixelStorei(O.UNPACK_ALIGNMENT,U.unpackAlignment);const Oi=M.getParameter(O.UNPACK_ROW_LENGTH),tt=M.getParameter(O.UNPACK_IMAGE_HEIGHT),Vi=M.getParameter(O.UNPACK_SKIP_PIXELS),gn=M.getParameter(O.UNPACK_SKIP_ROWS),ns=M.getParameter(O.UNPACK_SKIP_IMAGES);M.pixelStorei(O.UNPACK_ROW_LENGTH,Ft.width),M.pixelStorei(O.UNPACK_IMAGE_HEIGHT,Ft.height),M.pixelStorei(O.UNPACK_SKIP_PIXELS,Ce),M.pixelStorei(O.UNPACK_SKIP_ROWS,qe),M.pixelStorei(O.UNPACK_SKIP_IMAGES,$e);const ir=S.isDataArrayTexture||S.isData3DTexture,vt=U.isDataArrayTexture||U.isData3DTexture;if(S.isDepthTexture){const Bt=W.get(S),ss=W.get(U),_t=W.get(Bt.__renderTarget),rs=W.get(ss.__renderTarget);M.bindFramebuffer(O.READ_FRAMEBUFFER,_t.__webglFramebuffer),M.bindFramebuffer(O.DRAW_FRAMEBUFFER,rs.__webglFramebuffer);for(let nr=0;nr<be;nr++)ir&&(O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,W.get(S).__webglTexture,G,$e+nr),O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,W.get(U).__webglTexture,ge,zt+nr)),O.blitFramebuffer(Ce,qe,_e,me,Ie,pt,_e,me,O.DEPTH_BUFFER_BIT,O.NEAREST);M.bindFramebuffer(O.READ_FRAMEBUFFER,null),M.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else if(G!==0||S.isRenderTargetTexture||W.has(S)){const Bt=W.get(S),ss=W.get(U);M.bindFramebuffer(O.READ_FRAMEBUFFER,z),M.bindFramebuffer(O.DRAW_FRAMEBUFFER,N);for(let _t=0;_t<be;_t++)ir?O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,Bt.__webglTexture,G,$e+_t):O.framebufferTexture2D(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,Bt.__webglTexture,G),vt?O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,ss.__webglTexture,ge,zt+_t):O.framebufferTexture2D(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,ss.__webglTexture,ge),G!==0?O.blitFramebuffer(Ce,qe,_e,me,Ie,pt,_e,me,O.COLOR_BUFFER_BIT,O.NEAREST):vt?O.copyTexSubImage3D(Me,ge,Ie,pt,zt+_t,Ce,qe,_e,me):O.copyTexSubImage2D(Me,ge,Ie,pt,Ce,qe,_e,me);M.bindFramebuffer(O.READ_FRAMEBUFFER,null),M.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else vt?S.isDataTexture||S.isData3DTexture?O.texSubImage3D(Me,ge,Ie,pt,zt,_e,me,be,gt,pi,Ft.data):U.isCompressedArrayTexture?O.compressedTexSubImage3D(Me,ge,Ie,pt,zt,_e,me,be,gt,Ft.data):O.texSubImage3D(Me,ge,Ie,pt,zt,_e,me,be,gt,pi,Ft):S.isDataTexture?O.texSubImage2D(O.TEXTURE_2D,ge,Ie,pt,_e,me,gt,pi,Ft.data):S.isCompressedTexture?O.compressedTexSubImage2D(O.TEXTURE_2D,ge,Ie,pt,Ft.width,Ft.height,gt,Ft.data):O.texSubImage2D(O.TEXTURE_2D,ge,Ie,pt,_e,me,gt,pi,Ft);M.pixelStorei(O.UNPACK_ROW_LENGTH,Oi),M.pixelStorei(O.UNPACK_IMAGE_HEIGHT,tt),M.pixelStorei(O.UNPACK_SKIP_PIXELS,Vi),M.pixelStorei(O.UNPACK_SKIP_ROWS,gn),M.pixelStorei(O.UNPACK_SKIP_IMAGES,ns),ge===0&&U.generateMipmaps&&O.generateMipmap(Me),M.unbindTexture()},this.initRenderTarget=function(S){W.get(S).__webglFramebuffer===void 0&&$.setupRenderTarget(S)},this.initTexture=function(S){S.isCubeTexture?$.setTextureCube(S,0):S.isData3DTexture?$.setTexture3D(S,0):S.isDataArrayTexture||S.isCompressedArrayTexture?$.setTexture2DArray(S,0):$.setTexture2D(S,0),M.unbindTexture()},this.resetState=function(){V=0,k=0,K=null,M.reset(),ve.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Rn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=et._getDrawingBufferColorSpace(e),t.unpackColorSpace=et._getUnpackColorSpace()}}const qy=`
|
|
4743
4743
|
varying vec3 vDir;
|
|
4744
4744
|
varying vec3 vWorldDir;
|
|
4745
4745
|
|
|
@@ -5004,7 +5004,7 @@ void main() {
|
|
|
5004
5004
|
// what is behind: exactly what the display drawn first and the deck laid over it gave.
|
|
5005
5005
|
gl_FragColor = uPremultiplied > 0.5 ? vec4(color * alpha + halo * (1.0 - alpha), alpha) : vec4(color, alpha);
|
|
5006
5006
|
}
|
|
5007
|
-
`;function mu(s,e,t,i=0){const n={sunDir:{value:new D(0,1,0)},sunColor:{value:new oe(1,1,1)},ambientColor:{value:new oe(.5,.5,.5)},baseColor:{value:s},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
|
|
5007
|
+
`;function mu(s,e,t,i=0){const n={sunDir:{value:new D(0,1,0)},sunColor:{value:new oe(1,1,1)},ambientColor:{value:new oe(.5,.5,.5)},baseColor:{value:s},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 Et({uniforms:n,vertexShader:qy,fragmentShader:Yy,transparent:!0,depthWrite:!1,depthTest:!0,side:It}),uniforms:n}}function gu(s){return new di(s,48,24,0,Math.PI*2,0,Math.PI/2)}class st{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,r=e*269.5+t*183.3+i*246.1,a=e*113.5+t*271.9+i*124.6;return[st.fract(Math.sin(n)*43758.5453)*2-1,st.fract(Math.sin(r)*43758.5453)*2-1,st.fract(Math.sin(a)*43758.5453)*2-1]}static noise3D(e,t,i){const n=Math.floor(e),r=Math.floor(t),a=Math.floor(i),o=e-n,c=t-r,l=i-a,h=o*o*(3-2*o),u=c*c*(3-2*c),d=l*l*(3-2*l),f=(v,m,g)=>{const[b,y,_]=st.hash3(n+v,r+m,a+g);return b*(o-v)+y*(c-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,r=st.GAIN;for(let a=0;a<st.OCTAVES;a++)n+=st.noise3D(e,t,i)*r,e*=st.LACUNARITY,t*=st.LACUNARITY,i*=st.LACUNARITY,r*=st.GAIN;return n}static worley(e,t,i){const n=Math.floor(e),r=Math.floor(t),a=Math.floor(i),o=e-n,c=t-r,l=i-a;let h=1/0;for(let u=-1;u<=1;u++)for(let d=-1;d<=1;d++)for(let f=-1;f<=1;f++){const[p,v,m]=st.hash3(n+u,r+d,a+f),g=u+(p*.5+.5)-o,b=d+(v*.5+.5)-c,y=f+(m*.5+.5)-l;h=Math.min(h,g*g+b*b+y*y)}return Math.sqrt(h)}static alphaAt(e,t,i,n={x:0,z:0}){if(i<=0)return 0;const[r,a,o]=st.warpedAt(e,t,n),c=st.fbm(r*.014,a*.014,o*.014)*.5+.5,l=1-st.worley(r*.011,a*.011,o*.011),h=c+(l-c)*.4,u=st.thresholdFor(i,Ym,vd),d=st.smoothstep(u-Nc,u+Nc,h);return d+(1-d)*st.smoothstep(.82,1,i)}static iceAlphaAt(e,t,i,n={x:0,z:0}){if(i<=0)return 0;const[r,a,o]=st.warpedAt(e,t,n),c=r*.0016,l=a*.02,h=o*.045,u=st.fbm(c,l,h)*.5+.5,d=st.fbm(c*3.1+7,l*3.1+7,h*3.1+7)*.5+.5,f=st.thresholdFor(i,Md,Zc);return st.smoothstep(f-pu,f+pu,u*.72+d*.28)}static warpedAt(e,t,i){const n=Math.abs(e.y),r=t/Math.max(n,.04),a=e.x*r+i.x,o=e.y*r,c=e.z*r+i.z,l=a*.006,h=o*.006,u=c*.006;return[a+st.fbm(l+12.3,h+12.3,u+12.3)*40,o+st.fbm(l+47.1,h+47.1,u+47.1)*40,c+st.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 Ss=6371e3,Gt=64,xa=8,Xl=.2787;function vu(s){if(s.seed!==void 0)return s.seed;let e=2166136261;for(const t of s.id)e=Math.imul(e^t.charCodeAt(0),16777619);return e>>>0}function Ky(){const s=new Uint8Array(Gt**3),e=(n,r,a,o)=>{let c=Math.imul(n%o+1,374761393)^Math.imul(r%o+1,668265263)^Math.imul(a%o+1,1274126177);return c=Math.imul(c^c>>>13,1274126177),((c^c>>>16)>>>0)/4294967295},t=(n,r,a,o)=>{const c=Math.floor(n),l=Math.floor(r),h=Math.floor(a),u=m=>m*m*(3-2*m),d=u(n-c),f=u(r-l),p=u(a-h);let v=0;for(let m=0;m<2;m++)for(let g=0;g<2;g++)for(let b=0;b<2;b++)v+=e(c+b,l+g,h+m,o)*(b?d:1-d)*(g?f:1-f)*(m?p:1-p);return v};for(let n=0;n<Gt;n++)for(let r=0;r<Gt;r++)for(let a=0;a<Gt;a++){let o=0;for(const[c,l]of[[4,.65],[8,.25],[16,.1]])o+=t(a/Gt*c,r/Gt*c,n/Gt*c,c)*l;s[a+Gt*(r+Gt*n)]=Math.round(o*255)}const i=new Em(s,Gt,Gt,Gt);return i.format=qc,i.minFilter=i.magFilter=at,i.wrapS=i.wrapT=i.wrapR=qa,i.needsUpdate=!0,i}function $y(s,e,t,i){const n=h=>{const u=(Ss+e)*s,d=(e-h)*(2*Ss+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)]},r=n(t+i);if(!r||r[1]<=0)return;let a=Math.max(0,r[0]),o=r[1];const c=n(t);c&&(a>=c[0]&&a<c[1]?a=c[1]:c[0]>a&&(o=Math.min(o,c[0])));const l=n(0);return l&&l[0]>=0&&(o=Math.min(o,l[0])),o>a?[a,o]:void 0}const Zy=`varying vec3 vCloudDirection;
|
|
5008
5008
|
void main() {
|
|
5009
5009
|
vCloudDirection = position;
|
|
5010
5010
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
@@ -5211,7 +5211,7 @@ float transmissionAt(vec3 dir, float distanceM) {
|
|
|
5211
5211
|
if (transmission < 0.015) break;
|
|
5212
5212
|
}
|
|
5213
5213
|
return transmission;
|
|
5214
|
-
}`,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=>s+n)}class Oc{mesh;uniforms;constructor(e,t){this.uniforms={noiseMap:{value:e},sunDir:{value:new D(0,1,0)},sunColor:{value:new oe(1,1,1)},ambientColor:{value:new oe(.4,.45,.5)},hazeColor:{value:new oe(.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:xa},()=>new D)},holeSize:{value:Array.from({length:xa},()=>new D)},holeRotation:{value:new Array(xa).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 wt({uniforms:this.uniforms,vertexShader:Zy,fragmentShader:Mu,transparent:!0,depthWrite:!1,depthTest:!0,side:It});this.mesh=new We(new di(t,32,16),i),this.mesh.frustumCulled=!1}update(e,t,i,n=[]){const r=this.uniforms;r.localSize.value.set(i?.widthM??0,i?.thicknessM??0,i?.depthM??0),r.localCenter.value.set(i?.eastM??0,i?i.baseM+i.thicknessM/2:0,-(i?.northM??0)),r.localRotation.value=(i?.rotationDeg??0)*Math.PI/180,r.holeCount.value=Math.min(xa,n.length),n.slice(0,xa).forEach((o,c)=>{r.holeCenter.value[c].set(o.eastM,o.baseM+o.thicknessM/2,-o.northM),r.holeSize.value[c].set(o.widthM,o.thicknessM,o.depthM),r.holeRotation.value[c]=o.rotationDeg*Math.PI/180}),r.baseM.value=Math.max(0,e.baseM),r.thicknessM.value=Math.max(10,e.thicknessM),r.coverage.value=Math.max(0,Math.min(1,e.coverage)),r.sizeM.value=Math.max(50,e.sizeM),r.density.value=Math.max(0,Math.min(2,e.density)),r.darkness.value=Math.max(0,Math.min(1,e.darkness??0)),r.eyeM.value=Math.max(.1,t),r.flatness.value=e.type==="stratus"?1:e.type==="stratocumulus"?.45:0;const a=vu(e);r.seedOffset.value.set(a%97/97,a%61/61,a%37/37),this.mesh.visible=r.density.value>0&&(i!==void 0||r.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,r=t.eyeM.value+e.y,a=2*Ss*r+e.x**2+r**2+e.z**2,o=a/(Math.sqrt(Ss**2+a)+Ss),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*Gt-.5),K=k.map(Math.floor),ee=k.map((ie,ae)=>ie-K[ae]);let J=0;for(let ie=0;ie<2;ie++)for(let ae=0;ae<2;ae++)for(let Be=0;Be<2;Be++){const je=(K[0]+Be+Gt)%Gt,Ge=(K[1]+ae+Gt)%Gt,Y=(K[2]+ie+Gt)%Gt;J+=f[je+Gt*(Ge+Gt*Y)]/255*(Be?ee[0]:1-ee[0])*(ae?ee[1]:1-ee[1])*(ie?ee[2]:1-ee[2])}return J},v=[d[0]*.173,Xl,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 b=i(.2,.8,p(d[0],Xl,d[2])*.65+p(m,Xl+.37,g)*.35);const y=i(8e3,4e4,Math.hypot(e.x,e.y,e.z)),_=n(p(d[0]*2,d[1]*3,d[2]*2),.5,y),w=n(p(d[0]*7,d[1]*7,d[2]*7),.5,y);let E=Oc.thresholdFor(t.coverage.value),R=1,x=0;if(l){const z=u+(_-.5)*.18;x=1-i(.35,1,z),R=1-i(.85,1.15,z),b=n(b,1,x),E=Math.min(E,Oc.thresholdFor(.5))}for(let z=0;z<t.holeCount.value;z++)R*=i(.85,1.15,h(t.holeCenter.value[z],t.holeSize.value[z],t.holeRotation.value[z])+(_-.5)*.18);if(R<.001)return 0;const A=(1-t.flatness.value)*.3*c*c;let I=i(E-.1+A,E+.1+A,b+(_-.5)*.12*c);if(I=n(I,1,i(.92,1,t.coverage.value)),I=n(I,Math.max(t.coverage.value,x),y),I<.001)return 0;const C=n(.45+.55*_,.96,t.flatness.value),P=i(0,.09,c)*(1-i(C-.22,C,c)),X=n(Math.max(0,I-(1-_)*.38-(1-w)*.1),I*.8,t.flatness.value);return P*X*t.density.value*R}transmissionAt(e,t=1/0){const i=this.uniforms,n=$y(e.y,i.eyeM.value,i.baseM.value,i.thicknessM.value);if(!n)return 1;let[r,a]=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*Ss);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;r=Math.max(r,d-Math.sqrt(f)),a=Math.min(a,d+Math.sqrt(f))}const o=Math.min(a,t,r+18e3);if(o<=r)return 1;const c=(o-r)/48;let l=1;for(let h=0;h<48;h++){const u=r+(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 li{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=li.build(24);static build(e){const t=[];let i=0,n=0,r=0;for(let a=0;a<e;a++){const o=li.VIOLET_NM+(a+.5)/e*(li.DEEP_RED_NM-li.VIOLET_NM),[c,l,h]=li.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,r+=u.b,t.push(u)}for(const a of t)a.r/=i,a.g/=n,a.b/=r;return t}static tristimulus(e,t,i){let n=0,r=0,a=0;for(let c=0;c<e.length;c++){const[l,h,u]=li.colourMatching(e[c]);n+=l*t[c],r+=h*t[c],a+=u*t[c]}const o=683*i;return[n*o,r*o,a*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,r)=>{const a=(e-i)/(e<i?n:r);return Math.exp(-.5*a*a)};return[1.056*t(599.8,37.9,31)+.362*t(442,16,26.7)-.065*t(501.1,20.4,26.2),.821*t(568.8,46.9,40.5)+.286*t(530.9,16.3,31.1),1.217*t(437,11.8,36)+.681*t(459,26,13.8)]}}class Uc{static reflectance(e,t,i){const r=t/i*Math.sqrt(Math.max(0,1-e*e));if(r>=1)return 1;const a=Math.sqrt(Math.max(0,1-r*r)),o=(i*e-t*a)/(i*e+t*a),c=(t*e-i*a)/(t*e+i*a);return(o*o+c*c)/2}}class ii{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(ii.ANCHOR_BLUE-ii.ANCHOR_RED)/(1/(ii.BLUE_NM*ii.BLUE_NM)-1/(ii.RED_NM*ii.RED_NM));static A=ii.ANCHOR_RED-ii.B/(ii.RED_NM*ii.RED_NM);static indexAt(e){return ii.A+ii.B/(e*e)}}class Vr{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)),r=i/this.index,a=Math.sqrt(Math.max(0,1-r*r)),o=Math.asin(i),c=Math.asin(r),l=Uc.reflectance(n,1,this.index);let h=0;t[h].chords=0,t[h].scatteringAngle=Vr.folded(Math.PI-2*o),t[h].weight=l,h++;const u=Uc.reflectance(a,this.index,1);let d=1-l;for(let f=1;f<=Vr.MAX_CHORDS&&h<t.length;f++){const p=2*(o-c)+(f-1)*(Math.PI-2*c);t[h].chords=f,t[h].scatteringAngle=Vr.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 Ht{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new Vr;previous=Ht.emergences();current=Ht.emergences();tally=new Float32Array(Ht.BINS*3);radiance=new Float32Array(Ht.BINS*3);scratch=new Float32Array(Ht.BINS*3);static emergences(){return Array.from({length:Vr.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const e of li.SAMPLES)this.sweep(e);return this.toRadiance(),this.blurBySourceDisc(),{bins:Ht.BINS,data:this.radiance,binDeg:180/Ht.BINS}}sweep(e){this.drop.refractiveIndex=ii.indexAt(e.wavelengthNm);const t=Ht.IMPACT_STEPS;let i=this.drop.trace(0,this.previous);const n=1/t;for(let r=1;r<=t;r++){const a=this.drop.trace(Math.sqrt(r/t),this.current);for(let o=0;o<Math.min(a,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=a,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 r=Ht.BINS,a=Math.PI/r,o=Math.min(e,t),c=Math.max(e,t),l=c-o,h=Math.min(r-1,Math.max(0,Math.floor(o/a))),u=Math.min(r-1,Math.max(0,Math.floor(c/a)));if(l<=0||h===u){this.add(h,i,n);return}for(let d=h;d<=u;d++){const f=Math.min(c,(d+1)*a)-Math.max(o,d*a);f>0&&this.add(d,i*f/l,n)}}add(e,t,i){const n=e*3,r=t*li.SAMPLES.length;this.tally[n]+=r*i.r,this.tally[n+1]+=r*i.g,this.tally[n+2]+=r*i.b}toRadiance(){const e=Ht.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)),r=n>0?this.backwardShare((i+.5)*(180/e))/n:0,a=i*3;this.radiance[a]=this.tally[a]*r,this.radiance[a+1]=this.tally[a+1]*r,this.radiance[a+2]=this.tally[a+2]*r}}backwardShare(e){const t=180-e;if(t<=Ht.FULL_UNTIL_DEG)return 1;if(t>=Ht.FADED_BY_DEG)return 0;const i=(t-Ht.FULL_UNTIL_DEG)/(Ht.FADED_BY_DEG-Ht.FULL_UNTIL_DEG);return Math.cos(i*Math.PI/2)**2}blurBySourceDisc(){const e=Ht.BINS,t=Ht.SOURCE_RADIUS_DEG*e/180,i=Math.max(1,Math.ceil(t)),n=[];let r=0;for(let a=-i;a<=i;a++){const o=Math.max(0,t*t-a*a),c=Math.sqrt(o);n.push(c),r+=c}if(!(r<=0)){this.scratch.set(this.radiance);for(let a=0;a<e;a++){let o=0,c=0,l=0;for(let u=-i;u<=i;u++){const d=Math.min(e-1,Math.max(0,a+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=a*3;this.radiance[h]=o/r,this.radiance[h+1]=c/r,this.radiance[h+2]=l/r}}}}class Ws{static RADIUS=880;static RENDER_ORDER=5.5;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new Ht;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(Ht.BINS*4),this.texture=new tr(this.texels,Ht.BINS,1,xi,$t),this.texture.minFilter=at,this.texture.magFilter=at,this.texture.wrapS=Ei,this.texture.wrapT=Ei,this.texture.needsUpdate=!0,this.material=new wt({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:Ws.GAIN}},vertexShader:`
|
|
5214
|
+
}`,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=>s+n)}class Oc{mesh;uniforms;constructor(e,t){this.uniforms={noiseMap:{value:e},sunDir:{value:new D(0,1,0)},sunColor:{value:new oe(1,1,1)},ambientColor:{value:new oe(.4,.45,.5)},hazeColor:{value:new oe(.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:xa},()=>new D)},holeSize:{value:Array.from({length:xa},()=>new D)},holeRotation:{value:new Array(xa).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 Et({uniforms:this.uniforms,vertexShader:Zy,fragmentShader:Mu,transparent:!0,depthWrite:!1,depthTest:!0,side:It});this.mesh=new We(new di(t,32,16),i),this.mesh.frustumCulled=!1}update(e,t,i,n=[]){const r=this.uniforms;r.localSize.value.set(i?.widthM??0,i?.thicknessM??0,i?.depthM??0),r.localCenter.value.set(i?.eastM??0,i?i.baseM+i.thicknessM/2:0,-(i?.northM??0)),r.localRotation.value=(i?.rotationDeg??0)*Math.PI/180,r.holeCount.value=Math.min(xa,n.length),n.slice(0,xa).forEach((o,c)=>{r.holeCenter.value[c].set(o.eastM,o.baseM+o.thicknessM/2,-o.northM),r.holeSize.value[c].set(o.widthM,o.thicknessM,o.depthM),r.holeRotation.value[c]=o.rotationDeg*Math.PI/180}),r.baseM.value=Math.max(0,e.baseM),r.thicknessM.value=Math.max(10,e.thicknessM),r.coverage.value=Math.max(0,Math.min(1,e.coverage)),r.sizeM.value=Math.max(50,e.sizeM),r.density.value=Math.max(0,Math.min(2,e.density)),r.darkness.value=Math.max(0,Math.min(1,e.darkness??0)),r.eyeM.value=Math.max(.1,t),r.flatness.value=e.type==="stratus"?1:e.type==="stratocumulus"?.45:0;const a=vu(e);r.seedOffset.value.set(a%97/97,a%61/61,a%37/37),this.mesh.visible=r.density.value>0&&(i!==void 0||r.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,r=t.eyeM.value+e.y,a=2*Ss*r+e.x**2+r**2+e.z**2,o=a/(Math.sqrt(Ss**2+a)+Ss),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*Gt-.5),K=k.map(Math.floor),ee=k.map((ie,ae)=>ie-K[ae]);let J=0;for(let ie=0;ie<2;ie++)for(let ae=0;ae<2;ae++)for(let Be=0;Be<2;Be++){const je=(K[0]+Be+Gt)%Gt,Ge=(K[1]+ae+Gt)%Gt,Y=(K[2]+ie+Gt)%Gt;J+=f[je+Gt*(Ge+Gt*Y)]/255*(Be?ee[0]:1-ee[0])*(ae?ee[1]:1-ee[1])*(ie?ee[2]:1-ee[2])}return J},v=[d[0]*.173,Xl,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 b=i(.2,.8,p(d[0],Xl,d[2])*.65+p(m,Xl+.37,g)*.35);const y=i(8e3,4e4,Math.hypot(e.x,e.y,e.z)),_=n(p(d[0]*2,d[1]*3,d[2]*2),.5,y),E=n(p(d[0]*7,d[1]*7,d[2]*7),.5,y);let w=Oc.thresholdFor(t.coverage.value),R=1,x=0;if(l){const z=u+(_-.5)*.18;x=1-i(.35,1,z),R=1-i(.85,1.15,z),b=n(b,1,x),w=Math.min(w,Oc.thresholdFor(.5))}for(let z=0;z<t.holeCount.value;z++)R*=i(.85,1.15,h(t.holeCenter.value[z],t.holeSize.value[z],t.holeRotation.value[z])+(_-.5)*.18);if(R<.001)return 0;const A=(1-t.flatness.value)*.3*c*c;let I=i(w-.1+A,w+.1+A,b+(_-.5)*.12*c);if(I=n(I,1,i(.92,1,t.coverage.value)),I=n(I,Math.max(t.coverage.value,x),y),I<.001)return 0;const C=n(.45+.55*_,.96,t.flatness.value),P=i(0,.09,c)*(1-i(C-.22,C,c)),X=n(Math.max(0,I-(1-_)*.38-(1-E)*.1),I*.8,t.flatness.value);return P*X*t.density.value*R}transmissionAt(e,t=1/0){const i=this.uniforms,n=$y(e.y,i.eyeM.value,i.baseM.value,i.thicknessM.value);if(!n)return 1;let[r,a]=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*Ss);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;r=Math.max(r,d-Math.sqrt(f)),a=Math.min(a,d+Math.sqrt(f))}const o=Math.min(a,t,r+18e3);if(o<=r)return 1;const c=(o-r)/48;let l=1;for(let h=0;h<48;h++){const u=r+(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 li{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=li.build(24);static build(e){const t=[];let i=0,n=0,r=0;for(let a=0;a<e;a++){const o=li.VIOLET_NM+(a+.5)/e*(li.DEEP_RED_NM-li.VIOLET_NM),[c,l,h]=li.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,r+=u.b,t.push(u)}for(const a of t)a.r/=i,a.g/=n,a.b/=r;return t}static tristimulus(e,t,i){let n=0,r=0,a=0;for(let c=0;c<e.length;c++){const[l,h,u]=li.colourMatching(e[c]);n+=l*t[c],r+=h*t[c],a+=u*t[c]}const o=683*i;return[n*o,r*o,a*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,r)=>{const a=(e-i)/(e<i?n:r);return Math.exp(-.5*a*a)};return[1.056*t(599.8,37.9,31)+.362*t(442,16,26.7)-.065*t(501.1,20.4,26.2),.821*t(568.8,46.9,40.5)+.286*t(530.9,16.3,31.1),1.217*t(437,11.8,36)+.681*t(459,26,13.8)]}}class Uc{static reflectance(e,t,i){const r=t/i*Math.sqrt(Math.max(0,1-e*e));if(r>=1)return 1;const a=Math.sqrt(Math.max(0,1-r*r)),o=(i*e-t*a)/(i*e+t*a),c=(t*e-i*a)/(t*e+i*a);return(o*o+c*c)/2}}class ii{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(ii.ANCHOR_BLUE-ii.ANCHOR_RED)/(1/(ii.BLUE_NM*ii.BLUE_NM)-1/(ii.RED_NM*ii.RED_NM));static A=ii.ANCHOR_RED-ii.B/(ii.RED_NM*ii.RED_NM);static indexAt(e){return ii.A+ii.B/(e*e)}}class Vr{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)),r=i/this.index,a=Math.sqrt(Math.max(0,1-r*r)),o=Math.asin(i),c=Math.asin(r),l=Uc.reflectance(n,1,this.index);let h=0;t[h].chords=0,t[h].scatteringAngle=Vr.folded(Math.PI-2*o),t[h].weight=l,h++;const u=Uc.reflectance(a,this.index,1);let d=1-l;for(let f=1;f<=Vr.MAX_CHORDS&&h<t.length;f++){const p=2*(o-c)+(f-1)*(Math.PI-2*c);t[h].chords=f,t[h].scatteringAngle=Vr.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 Ht{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new Vr;previous=Ht.emergences();current=Ht.emergences();tally=new Float32Array(Ht.BINS*3);radiance=new Float32Array(Ht.BINS*3);scratch=new Float32Array(Ht.BINS*3);static emergences(){return Array.from({length:Vr.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const e of li.SAMPLES)this.sweep(e);return this.toRadiance(),this.blurBySourceDisc(),{bins:Ht.BINS,data:this.radiance,binDeg:180/Ht.BINS}}sweep(e){this.drop.refractiveIndex=ii.indexAt(e.wavelengthNm);const t=Ht.IMPACT_STEPS;let i=this.drop.trace(0,this.previous);const n=1/t;for(let r=1;r<=t;r++){const a=this.drop.trace(Math.sqrt(r/t),this.current);for(let o=0;o<Math.min(a,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=a,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 r=Ht.BINS,a=Math.PI/r,o=Math.min(e,t),c=Math.max(e,t),l=c-o,h=Math.min(r-1,Math.max(0,Math.floor(o/a))),u=Math.min(r-1,Math.max(0,Math.floor(c/a)));if(l<=0||h===u){this.add(h,i,n);return}for(let d=h;d<=u;d++){const f=Math.min(c,(d+1)*a)-Math.max(o,d*a);f>0&&this.add(d,i*f/l,n)}}add(e,t,i){const n=e*3,r=t*li.SAMPLES.length;this.tally[n]+=r*i.r,this.tally[n+1]+=r*i.g,this.tally[n+2]+=r*i.b}toRadiance(){const e=Ht.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)),r=n>0?this.backwardShare((i+.5)*(180/e))/n:0,a=i*3;this.radiance[a]=this.tally[a]*r,this.radiance[a+1]=this.tally[a+1]*r,this.radiance[a+2]=this.tally[a+2]*r}}backwardShare(e){const t=180-e;if(t<=Ht.FULL_UNTIL_DEG)return 1;if(t>=Ht.FADED_BY_DEG)return 0;const i=(t-Ht.FULL_UNTIL_DEG)/(Ht.FADED_BY_DEG-Ht.FULL_UNTIL_DEG);return Math.cos(i*Math.PI/2)**2}blurBySourceDisc(){const e=Ht.BINS,t=Ht.SOURCE_RADIUS_DEG*e/180,i=Math.max(1,Math.ceil(t)),n=[];let r=0;for(let a=-i;a<=i;a++){const o=Math.max(0,t*t-a*a),c=Math.sqrt(o);n.push(c),r+=c}if(!(r<=0)){this.scratch.set(this.radiance);for(let a=0;a<e;a++){let o=0,c=0,l=0;for(let u=-i;u<=i;u++){const d=Math.min(e-1,Math.max(0,a+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=a*3;this.radiance[h]=o/r,this.radiance[h+1]=c/r,this.radiance[h+2]=l/r}}}}class Ws{static RADIUS=880;static RENDER_ORDER=5.5;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new Ht;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(Ht.BINS*4),this.texture=new tr(this.texels,Ht.BINS,1,xi,$t),this.texture.minFilter=at,this.texture.magFilter=at,this.texture.wrapS=Ai,this.texture.wrapT=Ai,this.texture.needsUpdate=!0,this.material=new Et({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:Ws.GAIN}},vertexShader:`
|
|
5215
5215
|
varying vec3 vDirection;
|
|
5216
5216
|
void main() {
|
|
5217
5217
|
vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
|
|
@@ -5239,7 +5239,7 @@ float transmissionAt(vec3 dir, float distanceM) {
|
|
|
5239
5239
|
light = mix(vec3(grey), light, uSaturation);
|
|
5240
5240
|
gl_FragColor = vec4(light * uStrength, 1.0);
|
|
5241
5241
|
}
|
|
5242
|
-
`,transparent:!0,blending:
|
|
5242
|
+
`,transparent:!0,blending:Gi,depthWrite:!1,depthTest:!0,side:It,fog:!1}),this.object=new We(new di(Ws.RADIUS,64,32),this.material),this.object.renderOrder=Ws.RENDER_ORDER,this.object.frustumCulled=!1,this.object.visible=!1}update(e,t,i,n){const r=this.material.uniforms;if(t<=0){r.uStrength.value=0,this.object.visible=!1;return}this.computed||this.publish(),r.uSource.value.set(e.x,e.y,e.z).normalize(),r.uStrength.value=t,r.uTint.value.set(i[0],i[1],i[2]),r.uSaturation.value=n?1:Ws.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]=Zn.toHalfFloat(t[n]),this.texels[i+1]=Zn.toHalfFloat(t[n+1]),this.texels[i+2]=Zn.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 Wr{constructor(e,t,i){this.group=e,this.radius=t,this.mode=i}decks=new Map;noise;halo;update(e,t){const i=vc(e).flatMap(a=>{const o={...a,darkness:a.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??vu(o),instances:void 0}}))]}),n=new Set(i.map(a=>a.key));for(const[a,o]of this.decks)n.has(a)||(this.disposeDeck(o),this.decks.delete(a));[...i].sort((a,o)=>Math.abs(o.layer.baseM+o.layer.thicknessM/2-t)-Math.abs(a.layer.baseM+a.layer.thicknessM/2-t)).forEach(({layer:a,key:o,instance:c,parentId:l},h)=>{const u=c!==void 0||a.type!=="cirrus"&&(this.mode==="volume"||(a.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:a,parentId:l,instance:c},u)this.noise??=Ky(),d.volume=new Oc(this.noise,this.radius),this.group.add(d.volume.mesh);else{const p=mu(new oe(1,1,1),a.coverage,Math.max(1,Math.abs(a.baseM-t)*.25*1400/Math.max(50,a.sizeM)),a.type==="cirrus"?1:0);d.uniforms=p.uniforms,d.surface=new We(gu(this.radius),p.material),this.group.add(d.surface)}this.decks.set(o,d)}d.layer=a,d.instance=c;const f=Wr.deckOrder(a.baseM<t,h,i.length);d.volume&&(d.volume.update(a,t,c,c?[]:a.instances??[]),d.volume.mesh.renderOrder=f),d.surface&&d.uniforms&&(d.surface.renderOrder=f,d.surface.scale.y=a.baseM<t?-1:1,d.surface.visible=a.coverage>0&&a.density>0,d.uniforms.coverage.value=a.coverage,d.uniforms.opticalDensity.value=a.type==="cirrus"?a.density/.35:a.density,d.uniforms.darkness.value=Math.max(0,Math.min(1,a.darkness??e.cloudDarkness)),d.uniforms.layerHeight.value=Math.max(1,Math.abs(a.baseM-t)*.25*1400/Math.max(50,a.sizeM)),d.uniforms.fibrous.value=a.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&&Wr.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=am,e.blendSrc=e.blendSrcAlpha=om,e.blendDst=e.blendDstAlpha=yc}else{if(i.uPremultiplied.value===0)return;i.uHaloShown={value:0},i.uPremultiplied.value=0,e.blending=qs}}static deckOrder(e,t,i){const n=t/Math.max(1,i);return e?Ws.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 r=.25*1400/Math.max(50,i.layer.sizeM),a=vu(i.layer);i.uniforms?.fieldOffset.value.set(n.x*r+a%97,0,n.z*r+a%37)}}static sunVisibility(e,t){const i=Math.acos(Ss/(Ss+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 r=Math.asin(Math.max(-1,Math.min(1,e.y/Math.max(1e-9,e.length()))))*180/Math.PI;for(const a of this.decks.values()){const o=a.volume?.uniforms??a.uniforms;o.sunDir.value.copy(e),o.sunColor.value.copy(t),a.volume||o.sunColor.value.multiplyScalar(Wr.sunVisibility(r,a.layer.baseM)),o.ambientColor.value.copy(i),a.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 r=n.volume.uniforms,a=r.localCenter.value.clone().sub(r.offsetM.value);a.y-=r.eyeM.value+(a.x**2+a.z**2)/(2*6371e3);const o=a.dot(e);o<=0||o>=t||n.volume.transmissionAt(e)>.98||(t=o,i={layerId:n.parentId,instanceId:n.instance.id,center:a})}return i}transmissionAt(e){let t=1;for(const i of this.decks.values())i.volume?t*=i.volume.transmissionAt(e):i.uniforms&&(t*=1-(i.layer.type==="cirrus"?st.iceAlphaAt:st.alphaAt)(e,i.uniforms.layerHeight.value,i.layer.coverage,i.uniforms.fieldOffset.value)*(i.layer.type==="cirrus"?.2:.95));return t}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()}}const Xr=`
|
|
5243
5243
|
vec3 encodeSrgb(vec3 linear) {
|
|
5244
5244
|
vec3 clamped = max(linear, vec3(0.0));
|
|
5245
5245
|
vec3 low = clamped * 12.92;
|
|
@@ -5252,7 +5252,7 @@ vec3 encodeSrgb(vec3 linear) {
|
|
|
5252
5252
|
vUv = position.xy * 0.5 + 0.5;
|
|
5253
5253
|
gl_Position = vec4(position.xy, 0.0, 1.0);
|
|
5254
5254
|
}
|
|
5255
|
-
`;this.addMaterial=new
|
|
5255
|
+
`;this.addMaterial=new Et({uniforms:{uSource:{value:this.frameTarget.texture},uShare:{value:1}},vertexShader:i,fragmentShader:`
|
|
5256
5256
|
precision highp float;
|
|
5257
5257
|
varying vec2 vUv;
|
|
5258
5258
|
uniform sampler2D uSource;
|
|
@@ -5260,7 +5260,7 @@ vec3 encodeSrgb(vec3 linear) {
|
|
|
5260
5260
|
void main() {
|
|
5261
5261
|
gl_FragColor = vec4(texture2D(uSource, vUv).rgb * uShare, 1.0);
|
|
5262
5262
|
}
|
|
5263
|
-
`,blending:
|
|
5263
|
+
`,blending:Gi,depthTest:!1,depthWrite:!1}),this.developMaterial=new Et({uniforms:{uFilm:{value:this.filmTarget.texture},uGain:{value:1}},vertexShader:i,fragmentShader:`
|
|
5264
5264
|
precision highp float;
|
|
5265
5265
|
${Xr}
|
|
5266
5266
|
varying vec2 vUv;
|
|
@@ -5269,7 +5269,7 @@ vec3 encodeSrgb(vec3 linear) {
|
|
|
5269
5269
|
void main() {
|
|
5270
5270
|
gl_FragColor = vec4(encodeSrgb(texture2D(uFilm, vUv).rgb * uGain), 1.0);
|
|
5271
5271
|
}
|
|
5272
|
-
`,blending:Cn,depthTest:!1,depthWrite:!1}),this.quad=new We(new dn(2,2),this.addMaterial),this.quadScene.add(this.quad)}get instantTarget(){return this.frameTarget}open(e){const t=e.getRenderTarget();e.setRenderTarget(this.filmTarget),e.setClearColor(0,1),e.clear(!0,!0,!0),e.setRenderTarget(t)}add(e,t){this.addMaterial.uniforms.uShare.value=t,this.quad.material=this.addMaterial;const i=e.getRenderTarget(),n=e.autoClear;e.autoClear=!1,e.setRenderTarget(this.filmTarget),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),this.frameTarget.setSize(this.width,this.height),this.filmTarget.setSize(this.width,this.height)}dispose(){this.frameTarget.dispose(),this.filmTarget.dispose(),this.addMaterial.dispose(),this.developMaterial.dispose(),this.quad.geometry.dispose(),this.quadScene.clear()}}const xu=Math.PI/180,Pf=180/Math.PI;function no(s,e,t){return Math.max(e,Math.min(t,s))}const ds=[{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 ql(s,e,t){return s+(e-s)*t}function Fc(s,e,t){return[ql(s[0],e[0],t),ql(s[1],e[1],t),ql(s[2],e[2],t)]}function _u(s){const e=Math.max(ds[0].altitudeDeg,Math.min(ds[ds.length-1].altitudeDeg,s));for(let i=0;i<ds.length-1;i++){const n=ds[i],r=ds[i+1];if(e>=n.altitudeDeg&&e<=r.altitudeDeg){const a=(e-n.altitudeDeg)/(r.altitudeDeg-n.altitudeDeg);return{zenith:Fc(n.zenith,r.zenith,a),horizon:Fc(n.horizon,r.horizon,a)}}}const t=ds[ds.length-1];return{zenith:t.zenith,horizon:t.horizon}}const Lf=-18,Nf=-4,Qy=1.8;function yu(s,e=0){if(s<=Lf)return mc+e;if(s>=0)return Nf+e;const t=s/Lf;return mc-(mc-Nf)*(1-t)**Qy+e}const Of=-1.5,mc=6.5,eS=1.6;function Da(s,e=mc){const t=Math.max(e,Of+1),i=(t-s)/(t-Of);return no(i,0,1)**eS}function ni(s,e,t){const i=s*xu,n=e*xu,r=t*Math.cos(i);return{x:r*Math.sin(n),y:t*Math.sin(i),z:-r*Math.cos(n)}}function tS(s,e,t){const i=Math.sqrt(s*s+e*e+t*t),n=i===0?0:Math.asin(no(e/i,-1,1))*Pf,r=(Math.atan2(s,-t)*Pf+360)%360;return{altitudeDeg:n,azimuthDeg:r}}function iS(s,e){const t=Math.abs(s-e)%360;return t>180?360-t:t}function nS(s,e,t,i){const n=Math.max(0,1-iS(s,t)/sS),r=Math.exp(-Math.max(0,e)/rS),a=i>0?Math.max(0,1-i/aS):Math.max(0,1-Math.abs(i+oS)/cS);return n*r*a}const sS=90,rS=12,aS=8,oS=2,cS=12;function lS(s,e,t,i){const{zenith:n,horizon:r}=_u(i),a=no((s+90)/180,0,1),o=Fc(r,n,a),c=nS(e,s,t,i);if(c<=0)return o;const l=_u(i+hS).horizon,h=[Math.max(r[0],l[0]),Math.max(r[1],l[1]),Math.max(r[2],l[2])];return Fc(o,h,c)}const hS=6;function Ca(s){return .12+.88*s}const uS=-4;function dS(s){return Math.max(0,uS-s)}const fS=6,pS=60;function mS(s){return Math.min(pS,fS*Math.sqrt(s))}const gS=3,vS=.55;function MS(s){return vS*no(s/gS,0,1)}function Zm(s){const e=Math.max(s,-4),t=Math.sin(e*xu)+.50572*Math.pow(e+6.07995,-1.6364);return no(1/t,1,40)}function ps(s){const e=Zm(s)-1;return[1,Math.exp(-.022*e),Math.exp(-.062*e)]}function xS(s){return yS*(Zm(Math.max(s,0))-1)}function _S(s){return Math.pow(10,-.4*xS(s))}const yS=5/37,xd=[{maxBrightness:.35,size:1.2},{maxBrightness:.7,size:2},{maxBrightness:1/0,size:3.2}];function Jm(s){return xd.findIndex(e=>s<=e.maxBrightness)}const SS=.25,Uf=.3,bS=2.2;function
|
|
5272
|
+
`,blending:Cn,depthTest:!1,depthWrite:!1}),this.quad=new We(new dn(2,2),this.addMaterial),this.quadScene.add(this.quad)}get instantTarget(){return this.frameTarget}open(e){const t=e.getRenderTarget();e.setRenderTarget(this.filmTarget),e.setClearColor(0,1),e.clear(!0,!0,!0),e.setRenderTarget(t)}add(e,t){this.addMaterial.uniforms.uShare.value=t,this.quad.material=this.addMaterial;const i=e.getRenderTarget(),n=e.autoClear;e.autoClear=!1,e.setRenderTarget(this.filmTarget),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),this.frameTarget.setSize(this.width,this.height),this.filmTarget.setSize(this.width,this.height)}dispose(){this.frameTarget.dispose(),this.filmTarget.dispose(),this.addMaterial.dispose(),this.developMaterial.dispose(),this.quad.geometry.dispose(),this.quadScene.clear()}}const xu=Math.PI/180,Pf=180/Math.PI;function no(s,e,t){return Math.max(e,Math.min(t,s))}const ds=[{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 ql(s,e,t){return s+(e-s)*t}function Fc(s,e,t){return[ql(s[0],e[0],t),ql(s[1],e[1],t),ql(s[2],e[2],t)]}function _u(s){const e=Math.max(ds[0].altitudeDeg,Math.min(ds[ds.length-1].altitudeDeg,s));for(let i=0;i<ds.length-1;i++){const n=ds[i],r=ds[i+1];if(e>=n.altitudeDeg&&e<=r.altitudeDeg){const a=(e-n.altitudeDeg)/(r.altitudeDeg-n.altitudeDeg);return{zenith:Fc(n.zenith,r.zenith,a),horizon:Fc(n.horizon,r.horizon,a)}}}const t=ds[ds.length-1];return{zenith:t.zenith,horizon:t.horizon}}const Lf=-18,Nf=-4,Qy=1.8;function yu(s,e=0){if(s<=Lf)return mc+e;if(s>=0)return Nf+e;const t=s/Lf;return mc-(mc-Nf)*(1-t)**Qy+e}const Of=-1.5,mc=6.5,eS=1.6;function Da(s,e=mc){const t=Math.max(e,Of+1),i=(t-s)/(t-Of);return no(i,0,1)**eS}function ni(s,e,t){const i=s*xu,n=e*xu,r=t*Math.cos(i);return{x:r*Math.sin(n),y:t*Math.sin(i),z:-r*Math.cos(n)}}function tS(s,e,t){const i=Math.sqrt(s*s+e*e+t*t),n=i===0?0:Math.asin(no(e/i,-1,1))*Pf,r=(Math.atan2(s,-t)*Pf+360)%360;return{altitudeDeg:n,azimuthDeg:r}}function iS(s,e){const t=Math.abs(s-e)%360;return t>180?360-t:t}function nS(s,e,t,i){const n=Math.max(0,1-iS(s,t)/sS),r=Math.exp(-Math.max(0,e)/rS),a=i>0?Math.max(0,1-i/aS):Math.max(0,1-Math.abs(i+oS)/cS);return n*r*a}const sS=90,rS=12,aS=8,oS=2,cS=12;function lS(s,e,t,i){const{zenith:n,horizon:r}=_u(i),a=no((s+90)/180,0,1),o=Fc(r,n,a),c=nS(e,s,t,i);if(c<=0)return o;const l=_u(i+hS).horizon,h=[Math.max(r[0],l[0]),Math.max(r[1],l[1]),Math.max(r[2],l[2])];return Fc(o,h,c)}const hS=6;function Ca(s){return .12+.88*s}const uS=-4;function dS(s){return Math.max(0,uS-s)}const fS=6,pS=60;function mS(s){return Math.min(pS,fS*Math.sqrt(s))}const gS=3,vS=.55;function MS(s){return vS*no(s/gS,0,1)}function Zm(s){const e=Math.max(s,-4),t=Math.sin(e*xu)+.50572*Math.pow(e+6.07995,-1.6364);return no(1/t,1,40)}function ps(s){const e=Zm(s)-1;return[1,Math.exp(-.022*e),Math.exp(-.062*e)]}function xS(s){return yS*(Zm(Math.max(s,0))-1)}function _S(s){return Math.pow(10,-.4*xS(s))}const yS=5/37,xd=[{maxBrightness:.35,size:1.2},{maxBrightness:.7,size:2},{maxBrightness:1/0,size:3.2}];function Jm(s){return xd.findIndex(e=>s<=e.maxBrightness)}const SS=.25,Uf=.3,bS=2.2;function ES(s,{phase:e,speedFactor:t},i){const r=1+SS*(Uf+(1-Uf)*s)*Math.sin(i*bS*t+e);return Math.min(1,Math.max(0,r))}/**
|
|
5273
5273
|
@preserve
|
|
5274
5274
|
|
|
5275
5275
|
Astronomy library for JavaScript (browser and Node.js).
|
|
@@ -5300,11 +5300,11 @@ vec3 encodeSrgb(vec3 linear) {
|
|
|
5300
5300
|
* @fileoverview Astronomy calculation library for browser scripting and Node.js.
|
|
5301
5301
|
* @author Don Cross <cosinekitty@gmail.com>
|
|
5302
5302
|
* @license MIT
|
|
5303
|
-
*/const _d=173.1446326846693,zs=14959787069098932e-8,ft=.017453292519943295,Ff=.26179938779914946,Pn=57.29577951308232,jm=3.819718634205488,ES=365.24217,kf=new Date("2000-01-01T12:00:00Z"),Bn=2*Math.PI,fs=3600*(180/Math.PI),Nr=484813681109536e-20,Qm=10800*60,AS=2*Qm,zf=7292115e-11,TS=Qm/Math.PI,RS=-.17-5*Math.log10(TS),Su=.996647180302104,DS=Su*Su,bu=6378.1366,CS=bu/zs,eg=81.30056,yd=.0002959122082855911,wu=2825345909524226e-22,Eu=8459715185680659e-23,Au=1292024916781969e-23,Tu=1524358900784276e-23;function kc(s){if(s!==!0&&s!==!1)throw console.trace(),`Value is not boolean: ${s}`;return s}function ai(s){if(!Number.isFinite(s))throw console.trace(),`Value is not a finite number: ${s}`;return s}function Rr(s){return s-Math.floor(s)}function IS(s,e){const t=s.x*s.x+s.y*s.y+s.z*s.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=(s.x*e.x+s.y*e.y+s.z*e.z)/Math.sqrt(t*i);return n<=-1?180:n>=1?0:Pn*Math.acos(n)}var Se;(function(s){s.Sun="Sun",s.Moon="Moon",s.Mercury="Mercury",s.Venus="Venus",s.Earth="Earth",s.Mars="Mars",s.Jupiter="Jupiter",s.Saturn="Saturn",s.Uranus="Uranus",s.Neptune="Neptune",s.Pluto="Pluto",s.SSB="SSB",s.EMB="EMB",s.Star1="Star1",s.Star2="Star2",s.Star3="Star3",s.Star4="Star4",s.Star5="Star5",s.Star6="Star6",s.Star7="Star7",s.Star8="Star8"})(Se||(Se={}));const PS=[Se.Star1,Se.Star2,Se.Star3,Se.Star4,Se.Star5,Se.Star6,Se.Star7,Se.Star8],LS=[{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 NS(s){const e=PS.indexOf(s);return e>=0?LS[e]:null}function Sd(s){const e=NS(s);return e&&e.dist>0?e:null}var fi;(function(s){s[s.From2000=0]="From2000",s[s.Into2000=1]="Into2000"})(fi||(fi={}));const Dn={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 OS(s){var e,t,i,n,r,a,o;const c=2e3+(s-14)/ES;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,r=t*i,a=i*i,10583.6-1014.41*e+33.78311*t-5.952053*i-.1798452*n+.022174192*r+.0090316521*a):c<1600?(e=(c-1e3)/100,t=e*e,i=e*t,n=t*t,r=t*i,a=i*i,1574.2-556.01*e+71.23472*t+.319781*i-.8503463*n-.005050998*r+.0083572073*a):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,r=t*i,a=i*i,o=i*n,13.72-.332447*e+.0068612*t+.0041116*i-37436e-8*n+121272e-10*r-1699e-10*a+875e-12*o):c<1900?(e=c-1860,t=e*e,i=e*t,n=t*t,r=t*i,7.62+.5737*e-.251754*t+.01680668*i-.0004473624*n+r/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,r=t*i,63.86+.3345*e-.060374*t+.0017275*i+651814e-9*n+2373599e-11*r):c<2050?(e=c-2e3,62.92+.32217*e+.005589*e*e):c<2150?(e=(c-1820)/100,-20+32*e*e-.5628*(2150-c)):(e=(c-1820)/100,-20+32*e*e)}let US=OS;function Bf(s){return s+US(s)/86400}class qr{constructor(e){if(e instanceof qr){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()-kf.getTime())/t,this.tt=Bf(this.ut);return}if(Number.isFinite(e)){this.date=new Date(kf.getTime()+e*t),this.ut=e,this.tt=Bf(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 qr(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 qr(this.ut+e)}}function Lt(s){return s instanceof qr?s:new qr(s)}function FS(s){function e(d){return d%AS*Nr}const t=s.tt/36525,i=e(128710479305e-5+t*1295965810481e-4),n=e(335779.526232+t*17395272628478e-4),r=e(107226070369e-5+t*1602961601209e-3),a=e(450160.398036-t*69628905431e-4);let o=Math.sin(a),c=Math.cos(a),l=(-172064161-174666*t)*o+33386*c,h=(92052331+9086*t)*c+15377*o,u=2*(n-r+a);return o=Math.sin(u),c=Math.cos(u),l+=(-13170906-1675*t)*o-13696*c,h+=(5730336-3015*t)*c-4587*o,u=2*(n+a),o=Math.sin(u),c=Math.cos(u),l+=(-2276413-234*t)*o+2796*c,h+=(978459-485*t)*c+1374*o,u=2*a,o=Math.sin(u),c=Math.cos(u),l+=(2074554+207*t)*o-698*c,h+=(-897492+470*t)*c-291*o,o=Math.sin(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 tg(s){var e=s.tt/36525,t=((((-434e-10*e-576e-9)*e+.0020034)*e-1831e-7)*e-46.836769)*e+84381.406;return t/3600}var qo;function so(s){if(!qo||Math.abs(qo.tt-s.tt)>1e-6){const e=FS(s),t=tg(s),i=t+e.deps/3600;qo={tt:s.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*ft)/15,mobl:t,tobl:i}}return qo}function kS(s,e){const t=s*ft,i=Math.cos(t),n=Math.sin(t);return[e[0],e[1]*i-e[2]*n,e[1]*n+e[2]*i]}function zS(s,e){return kS(tg(s),e)}function BS(s){const e=s.tt/36525;function t(Re,xe){const Ne=[];let Oe;for(Oe=0;Oe<=xe-Re;++Oe)Ne.push(0);return{min:Re,array:Ne}}function i(Re,xe,Ne,Oe){const Ue=[];for(let ct=0;ct<=xe-Re;++ct)Ue.push(t(Ne,Oe));return{min:Re,array:Ue}}function n(Re,xe,Ne){const Oe=Re.array[xe-Re.min];return Oe.array[Ne-Oe.min]}function r(Re,xe,Ne,Oe){const Ue=Re.array[xe-Re.min];Ue.array[Ne-Ue.min]=Oe}let a,o,c,l,h,u,d,f,p,v,m,g,b,y,_,w,E,R,x,A,I,C,P,X=i(-6,6,1,4),z=i(-6,6,1,4);function N(Re,xe){return n(X,Re,xe)}function V(Re,xe){return n(z,Re,xe)}function k(Re,xe,Ne){return r(X,Re,xe,Ne)}function K(Re,xe,Ne){return r(z,Re,xe,Ne)}function ee(Re,xe,Ne,Oe,Ue){Ue(Re*Ne-xe*Oe,xe*Ne+Re*Oe)}function J(Re){return Math.sin(Bn*Re)}d=e*e,p=0,P=0,m=0,g=3422.7;var ie=J(.19833+.05611*e),ae=J(.27869+.04508*e),Be=J(.16827-.36903*e),je=J(.34734-5.37261*e),Ge=J(.10498-5.37899*e),Y=J(.42681-.41855*e),re=J(.14943-5.37511*e);for(R=.84*ie+.31*ae+14.27*Be+7.26*je+.28*Ge+.24*Y,x=2.94*ie+.31*ae+14.27*Be+9.34*je+1.12*Ge+.83*Y,A=-6.4*ie-1.89*Y,I=.21*ie+.31*ae+14.27*Be-88.7*je-15.3*Ge+.24*Y-1.86*re,C=R-A,f=-3332e-9*J(.59734-5.37261*e)-539e-9*J(.35498-5.37899*e)-64e-9*J(.39943-5.37511*e),b=Bn*Rr(.60643382+1336.85522467*e-313e-8*d)+R/fs,y=Bn*Rr(.37489701+1325.55240982*e+2565e-8*d)+x/fs,_=Bn*Rr(.99312619+99.99735956*e-44e-8*d)+A/fs,w=Bn*Rr(.25909118+1342.2278298*e-892e-8*d)+I/fs,E=Bn*Rr(.82736186+1236.85308708*e-397e-8*d)+C/fs,h=1;h<=4;++h){switch(h){case 1:c=y,o=4,l=1.000002208;break;case 2:c=_,o=3,l=.997504612-.002495388*e;break;case 3:c=w,o=4,l=1.000002708+139.978*f;break;case 4:c=E,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),(Re,xe)=>(k(u,h,Re),K(u,h,xe)));for(u=1;u<=o;++u)k(-u,h,N(u,h)),K(-u,h,-V(u,h))}function ne(Re,xe,Ne,Oe){for(var Ue={x:1,y:0},ct=[0,Re,xe,Ne,Oe],lt=1;lt<=4;++lt)ct[lt]!==0&&ee(Ue.x,Ue.y,N(ct[lt],lt),V(ct[lt],lt),(Nt,Tt)=>(Ue.x=Nt,Ue.y=Tt));return Ue}function B(Re,xe,Ne,Oe,Ue,ct,lt,Nt){var Tt=ne(Ue,ct,lt,Nt);p+=Re*Tt.y,P+=xe*Tt.y,m+=Ne*Tt.x,g+=Oe*Tt.x}B(13.902,14.06,-.001,.2607,0,0,0,4),B(.403,-4.01,.394,.0023,0,0,0,3),B(2369.912,2373.36,.601,28.2333,0,0,0,2),B(-125.154,-112.79,-.725,-.9781,0,0,0,1),B(1.979,6.98,-.445,.0433,1,0,0,4),B(191.953,192.72,.029,3.0861,1,0,0,2),B(-8.466,-13.51,.455,-.1093,1,0,0,1),B(22639.5,22609.07,.079,186.5398,1,0,0,0),B(18.609,3.59,-.094,.0118,1,0,0,-1),B(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),B(3.215,5.44,.192,-.0386,1,0,0,-3),B(-38.428,-38.64,.001,.6008,1,0,0,-4),B(-.393,-1.43,-.092,.0086,1,0,0,-6),B(-.289,-1.59,.123,-.0053,0,1,0,4),B(-24.42,-25.1,.04,-.3,0,1,0,2),B(18.023,17.93,.007,.1494,0,1,0,1),B(-668.146,-126.98,-1.302,-.3997,0,1,0,0),B(.56,.32,-.001,-.0037,0,1,0,-1),B(-165.145,-165.06,.054,1.9178,0,1,0,-2),B(-1.877,-6.46,-.416,.0339,0,1,0,-4),B(.213,1.02,-.074,.0054,2,0,0,4),B(14.387,14.78,-.017,.2833,2,0,0,2),B(-.586,-1.2,.054,-.01,2,0,0,1),B(769.016,767.96,.107,10.1657,2,0,0,0),B(1.75,2.01,-.018,.0155,2,0,0,-1),B(-211.656,-152.53,5.679,-.3039,2,0,0,-2),B(1.225,.91,-.03,-.0088,2,0,0,-3),B(-30.773,-34.07,-.308,.3722,2,0,0,-4),B(-.57,-1.4,-.074,.0109,2,0,0,-6),B(-2.921,-11.75,.787,-.0484,1,1,0,2),B(1.267,1.52,-.022,.0164,1,1,0,1),B(-109.673,-115.18,.461,-.949,1,1,0,0),B(-205.962,-182.36,2.056,1.4437,1,1,0,-2),B(.233,.36,.012,-.0025,1,1,0,-3),B(-4.391,-9.66,-.471,.0673,1,1,0,-4),B(.283,1.53,-.111,.006,1,-1,0,4),B(14.577,31.7,-1.54,.2302,1,-1,0,2),B(147.687,138.76,.679,1.1528,1,-1,0,0),B(-1.089,.55,.021,0,1,-1,0,-1),B(28.475,23.59,-.443,-.2257,1,-1,0,-2),B(-.276,-.38,-.006,-.0036,1,-1,0,-3),B(.636,2.27,.146,-.0102,1,-1,0,-4),B(-.189,-1.68,.131,-.0028,0,2,0,2),B(-7.486,-.66,-.037,-.0086,0,2,0,0),B(-8.096,-16.35,-.74,.0918,0,2,0,-2),B(-5.741,-.04,0,-9e-4,0,0,2,2),B(.255,0,0,0,0,0,2,1),B(-411.608,-.2,0,-.0124,0,0,2,0),B(.584,.84,0,.0071,0,0,2,-1),B(-55.173,-52.14,0,-.1052,0,0,2,-2),B(.254,.25,0,-.0017,0,0,2,-3),B(.025,-1.67,0,.0031,0,0,2,-4),B(1.06,2.96,-.166,.0243,3,0,0,2),B(36.124,50.64,-1.3,.6215,3,0,0,0),B(-13.193,-16.4,.258,-.1187,3,0,0,-2),B(-1.187,-.74,.042,.0074,3,0,0,-4),B(-.293,-.31,-.002,.0046,3,0,0,-6),B(-.29,-1.45,.116,-.0051,2,1,0,2),B(-7.649,-10.56,.259,-.1038,2,1,0,0),B(-8.627,-7.59,.078,-.0192,2,1,0,-2),B(-2.74,-2.54,.022,.0324,2,1,0,-4),B(1.181,3.32,-.212,.0213,2,-1,0,2),B(9.703,11.67,-.151,.1268,2,-1,0,0),B(-.352,-.37,.001,-.0028,2,-1,0,-1),B(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),B(.36,.2,-.012,-.0043,2,-1,0,-4),B(-1.167,-1.25,.008,-.0106,1,2,0,0),B(-7.412,-6.12,.117,.0484,1,2,0,-2),B(-.311,-.65,-.032,.0044,1,2,0,-4),B(.757,1.82,-.105,.0112,1,-2,0,2),B(2.58,2.32,.027,.0196,1,-2,0,0),B(2.533,2.4,-.014,-.0212,1,-2,0,-2),B(-.344,-.57,-.025,.0036,0,3,0,-2),B(-.992,-.02,0,0,1,0,2,2),B(-45.099,-.02,0,-.001,1,0,2,0),B(-.179,-9.52,0,-.0833,1,0,2,-2),B(-.301,-.33,0,.0014,1,0,2,-4),B(-6.382,-3.37,0,-.0481,1,0,-2,2),B(39.528,85.13,0,-.7136,1,0,-2,0),B(9.366,.71,0,-.0112,1,0,-2,-2),B(.202,.02,0,0,1,0,-2,-4),B(.415,.1,0,.0013,0,1,2,0),B(-2.152,-2.26,0,-.0066,0,1,2,-2),B(-1.44,-1.3,0,.0014,0,1,-2,2),B(.384,-.04,0,0,0,1,-2,-2),B(1.938,3.6,-.145,.0401,4,0,0,0),B(-.952,-1.58,.052,-.013,4,0,0,-2),B(-.551,-.94,.032,-.0097,3,1,0,0),B(-.482,-.57,.005,-.0045,3,1,0,-2),B(.681,.96,-.026,.0115,3,-1,0,0),B(-.297,-.27,.002,-9e-4,2,2,0,-2),B(.254,.21,-.003,0,2,-2,0,-2),B(-.25,-.22,.004,.0014,1,3,0,-2),B(-3.996,0,0,4e-4,2,0,2,0),B(.557,-.75,0,-.009,2,0,2,-2),B(-.459,-.38,0,-.0053,2,0,-2,2),B(-1.298,.74,0,4e-4,2,0,-2,0),B(.538,1.14,0,-.0141,2,0,-2,-2),B(.263,.02,0,0,1,1,2,0),B(.426,.07,0,-6e-4,1,1,-2,-2),B(-.304,.03,0,3e-4,1,-1,2,0),B(-.372,-.19,0,-.0027,1,-1,-2,2),B(.418,0,0,0,0,0,4,0),B(-.33,-.04,0,0,3,0,2,0);function we(Re,xe,Ne,Oe,Ue){return Re*ne(xe,Ne,Oe,Ue).y}v=0,v+=we(-526.069,0,0,1,-2),v+=we(-3.352,0,0,1,-4),v+=we(44.297,1,0,1,-2),v+=we(-6,1,0,1,-4),v+=we(20.599,-1,0,1,0),v+=we(-30.598,-1,0,1,-2),v+=we(-24.649,-2,0,1,0),v+=we(-2,-2,0,1,-2),v+=we(-22.571,0,1,1,-2),v+=we(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),a=w+P/fs;let Pe=(1.000002708+139.978*f)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+v;return{geo_eclip_lon:Bn*Rr((b+p/fs)/Bn),geo_eclip_lat:Math.PI/(180*3600)*Pe,distance_au:fs*CS/(.999953253*g)}}function ig(s,e){return[s.rot[0][0]*e[0]+s.rot[1][0]*e[1]+s.rot[2][0]*e[2],s.rot[0][1]*e[0]+s.rot[1][1]*e[1]+s.rot[2][1]*e[2],s.rot[0][2]*e[0]+s.rot[1][2]*e[1]+s.rot[2][2]*e[2]]}function zc(s,e,t){const i=bd(e,t);return ig(i,s)}function bd(s,e){const t=s.tt/36525;let i=84381.406,n=((((-951e-10*t+132851e-9)*t-.00114045)*t-1.0790069)*t+5038.481507)*t,r=((((3337e-10*t-467e-9)*t-.00772503)*t+.0512623)*t-.025754)*t+i,a=((((-56e-9*t+170663e-9)*t-.00121197)*t-2.3814292)*t+10.556403)*t;i*=Nr,n*=Nr,r*=Nr,a*=Nr;const o=Math.sin(i),c=Math.cos(i),l=Math.sin(-n),h=Math.cos(-n),u=Math.sin(-r),d=Math.cos(-r),f=Math.sin(a),p=Math.cos(a),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,b=-f*h-l*p*d,y=-f*l*c+p*d*h*c-o*p*u,_=-f*l*o+p*d*h*o+c*p*u,w=l*u,E=-u*h*c-o*d,R=-u*h*o+d*c;if(e===fi.Into2000)return new As([[v,m,g],[b,y,_],[w,E,R]]);if(e===fi.From2000)return new As([[v,b,w],[m,y,E],[g,_,R]]);throw"Invalid precess direction"}function HS(s){const e=.779057273264+.00273781191135448*s.ut,t=s.ut%1;let i=360*((e+t)%1);return i<0&&(i+=360),i}let Yo;function Jc(s){if(!Yo||Yo.tt!==s.tt){const e=s.tt/36525;let t=15*so(s).ee;const i=HS(s);let r=((t+.014506+((((-368e-10*e-29956e-9)*e-44e-8)*e+1.3915817)*e+4612.156534)*e)/3600+i)%360/15;r<0&&(r+=24),Yo={tt:s.tt,st:r}}return Yo.st}function GS(s){const e=Lt(s);return Jc(e)}function ng(s,e){const t=s.latitude*ft,i=Math.sin(t),n=Math.cos(t),r=1/Math.hypot(n,Su*i),a=DS*r,o=s.height/1e3,c=bu*r+o,l=bu*a+o,h=(15*e+s.longitude)*ft,u=Math.sin(h),d=Math.cos(h);return{pos:[c*n*d/zs,c*n*u/zs,l*i/zs],vel:[-zf*c*n*u*86400/zs,zf*c*n*d*86400/zs,0]}}function Ru(s,e,t){const i=wd(e,t);return ig(i,s)}function wd(s,e){const t=so(s),i=t.mobl*ft,n=t.tobl*ft,r=t.dpsi*Nr,a=Math.cos(i),o=Math.sin(i),c=Math.cos(n),l=Math.sin(n),h=Math.cos(r),u=Math.sin(r),d=h,f=-u*a,p=-u*o,v=u*c,m=h*a*c+o*l,g=h*o*c-a*l,b=u*l,y=h*a*l-o*c,_=h*o*l+a*c;if(e===fi.From2000)return new As([[d,v,b],[f,m,y],[p,g,_]]);if(e===fi.Into2000)return new As([[d,f,p],[v,m,g],[b,y,_]]);throw"Invalid precess direction"}function Ed(s,e,t){return t===fi.Into2000?zc(Ru(s,e,t),e,t):Ru(zc(s,e,t),e,t)}function VS(s,e){const t=Jc(s),i=ng(e,t).pos;return Ed(i,s,fi.Into2000)}class St{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 bs{constructor(e,t,i,n,r,a,o){this.x=e,this.y=t,this.z=i,this.vx=n,this.vy=r,this.vz=a,this.t=o}}class jc{constructor(e,t,i){this.lat=ai(e),this.lon=ai(t),this.dist=ai(i)}}class Du{constructor(e,t,i,n){this.ra=ai(e),this.dec=ai(t),this.dist=ai(i),this.vec=n}}class As{constructor(e){this.rot=e}}class WS{constructor(e,t,i,n){this.azimuth=ai(e),this.altitude=ai(t),this.ra=ai(i),this.dec=ai(n)}}class XS{constructor(e,t,i){this.vec=e,this.elat=ai(t),this.elon=ai(i)}}function sg(s,e){return new St(s[0],s[1],s[2],e)}function qS(s,e){const t=sg(s,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 Du(0,t.z<0?-90:90,n,t)}let r=jm*Math.atan2(t.y,t.x);r<0&&(r+=24);const a=Pn*Math.atan2(s[2],Math.sqrt(i));return new Du(r,a,n,t)}function Yl(s,e){const t=s*ft,i=Math.cos(t),n=Math.sin(t);return[i*e[0]+n*e[1],i*e[1]-n*e[0],e[2]]}function rg(s,e,t,i,n){let r=Lt(s);Ad(e),ai(t),ai(i);const a=Math.sin(e.latitude*ft),o=Math.cos(e.latitude*ft),c=Math.sin(e.longitude*ft),l=Math.cos(e.longitude*ft),h=Math.sin(i*ft),u=Math.cos(i*ft),d=Math.sin(t*Ff),f=Math.cos(t*Ff);let p=[o*l,o*c,a],v=[-a*l,-a*c,o],m=[c,-l,0];const g=-15*Jc(r);let b=Yl(g,p),y=Yl(g,v),_=Yl(g,m),w=[u*f,u*d,h];const E=w[0]*b[0]+w[1]*b[1]+w[2]*b[2],R=w[0]*y[0]+w[1]*y[1]+w[2]*y[2],x=w[0]*_[0]+w[1]*_[1]+w[2]*_[2];let A=Math.hypot(R,x),I;A>0?(I=-Pn*Math.atan2(x,R),I<0&&(I+=360)):I=0;let C=Pn*Math.atan2(A,E),P=t,X=i;if(n){let z=C,N=pg(n,90-C);if(C-=N,N>0&&C>3e-4){const V=Math.sin(C*ft),k=Math.cos(C*ft),K=Math.sin(z*ft),ee=Math.cos(z*ft),J=[];for(let ie=0;ie<3;++ie)J.push((w[ie]-ee*b[ie])/K*V+b[ie]*k);A=Math.hypot(J[0],J[1]),A>0?(P=jm*Math.atan2(J[1],J[0]),P<0&&(P+=24)):P=0,X=Pn*Math.atan2(J[2],A)}}return new WS(I,90-C,P,X)}function Ad(s){if(!(s instanceof Td))throw`Not an instance of the Observer class: ${s}`;if(ai(s.latitude),ai(s.longitude),ai(s.height),s.latitude<-90||s.latitude>90)throw`Latitude ${s.latitude} is out of range. Must be -90..+90.`;return s}class Td{constructor(e,t,i){this.latitude=e,this.longitude=t,this.height=i,Ad(this)}}function YS(s){const e=Lt(s).AddDays(-1/_d),t=Kr(Dn.Earth,e),i=[-t.x,-t.y,-t.z],[n,r,a]=Ed(i,e,fi.From2000),o=ft*so(e).tobl,c=Math.cos(o),l=Math.sin(o),h=new St(n,r,a,e);return ag(h,c,l)}function KS(s,e,t,i,n){Ad(t),kc(i),kc(n);const r=Lt(e),a=VS(r,t),o=zu(s,r,n),c=[o.x-a[0],o.y-a[1],o.z-a[2]],l=Ed(c,r,fi.From2000);return qS(l,r)}function $S(s,e,t){const i=Lt(s),n=Jc(i);let r=ng(e,n).pos;return sg(r,i)}function ag(s,e,t){const i=s.x,n=s.y*e+s.z*t,r=-s.y*t+s.z*e,a=Math.hypot(i,n);let o=0;a>0&&(o=Pn*Math.atan2(n,i),o<0&&(o+=360));let c=Pn*Math.atan2(r,a),l=new St(i,n,r,s.t);return new XS(l,c,o)}function Cu(s){const e=so(s.t),t=[s.x,s.y,s.z],i=zc(t,s.t,fi.From2000),[n,r,a]=Ru(i,s.t,fi.From2000),o=new St(n,r,a,s.t),c=e.tobl*ft;return ag(o,Math.cos(c),Math.sin(c))}function ta(s){const e=Lt(s),t=BS(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)],r=zS(e,n),a=zc(r,e,fi.Into2000);return new St(a[0],a[1],a[2],e)}function og(s){const e=Lt(s),t=1e-5,i=e.AddDays(-t),n=e.AddDays(+t),r=ta(i),a=ta(n);return new bs((r.x+a.x)/2,(r.y+a.y)/2,(r.z+a.z)/2,(a.x-r.x)/(2*t),(a.y-r.y)/(2*t),(a.z-r.z)/(2*t),e)}function ZS(s){const e=Lt(s),t=og(e),i=1+eg;return new bs(t.x/i,t.y/i,t.z/i,t.vx/i,t.vy/i,t.vz/i,e)}function Yr(s,e,t){let i=1,n=0;for(let r of s){let a=0;for(let[c,l,h]of r)a+=c*Math.cos(l+e*h);let o=i*a;t&&(o%=Bn),n+=o,i*=e}return n}function Kl(s,e){let t=1,i=0,n=0,r=0;for(let a of s){let o=0,c=0;for(let[l,h,u]of a){let d=h+e*u;o+=l*u*Math.sin(d),r>0&&(c+=l*Math.cos(d))}n+=r*i*c-t*o,i=t,t*=e,++r}return n}const Ia=365250,Iu=0,Pu=1,Lu=2;function Nu(s){return new Mi(s[0]+44036e-11*s[1]-190919e-12*s[2],-479966e-12*s[0]+.917482137087*s[1]-.397776982902*s[2],.397776982902*s[1]+.917482137087*s[2])}function cg(s,e,t){const i=t*Math.cos(e),n=Math.cos(s),r=Math.sin(s);return[i*n,i*r,t*Math.sin(e)]}function Kr(s,e){const t=e.tt/Ia,i=Yr(s[Iu],t,!0),n=Yr(s[Pu],t,!1),r=Yr(s[Lu],t,!1),a=cg(i,n,r);return Nu(a).ToAstroVector(e)}function Ou(s,e){const t=e/Ia,i=Yr(s[Iu],t,!0),n=Yr(s[Pu],t,!1),r=Yr(s[Lu],t,!1),a=Kl(s[Iu],t),o=Kl(s[Pu],t),c=Kl(s[Lu],t),l=Math.cos(i),h=Math.sin(i),u=Math.cos(n),d=Math.sin(n),f=+(c*u*l)-r*d*l*o-r*u*h*a,p=+(c*u*h)-r*d*h*o+r*u*l*a,v=+(c*d)+r*u*o,m=cg(i,n,r),g=[f/Ia,p/Ia,v/Ia],b=Nu(m),y=Nu(g);return new js(e,b,y)}function Ko(s,e,t,i){const n=i/(i+yd),r=Kr(Dn[t],e);s.x+=n*r.x,s.y+=n*r.y,s.z+=n*r.z}function JS(s){const e=new St(0,0,0,s);return Ko(e,s,Se.Jupiter,wu),Ko(e,s,Se.Saturn,Eu),Ko(e,s,Se.Uranus,Au),Ko(e,s,Se.Neptune,Tu),e}const Uu=51,jS=29200,Or=146,Hn=201,Xs=[[-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 Mi{constructor(e,t,i){this.x=e,this.y=t,this.z=i}clone(){return new Mi(this.x,this.y,this.z)}ToAstroVector(e){return new St(this.x,this.y,this.z,e)}static zero(){return new Mi(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new Mi(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new Mi(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 Mi(e*this.x,e*this.y,e*this.z)}div(e){return new Mi(this.x/e,this.y/e,this.z/e)}mean(e){return new Mi((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new Mi(-this.x,-this.y,-this.z)}}class js{constructor(e,t,i){this.tt=e,this.r=t,this.v=i}clone(){return new js(this.tt,this.r,this.v)}sub(e){return new js(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function QS(s){let[e,[t,i,n],[r,a,o]]=s;return new js(e,new Mi(t,i,n),new Mi(r,a,o))}function $o(s,e,t,i){const n=i/(i+yd),r=Ou(Dn[t],e);return s.r.incr(r.r.mul(n)),s.v.incr(r.v.mul(n)),r}function _a(s,e,t){const i=t.sub(s),n=i.quadrature();return i.mul(e/(n*Math.sqrt(n)))}class Qc{constructor(e){let t=new js(e,new Mi(0,0,0),new Mi(0,0,0));this.Jupiter=$o(t,e,Se.Jupiter,wu),this.Saturn=$o(t,e,Se.Saturn,Eu),this.Uranus=$o(t,e,Se.Uranus,Au),this.Neptune=$o(t,e,Se.Neptune,Tu),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 js(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=_a(e,yd,this.Sun.r);return t.incr(_a(e,wu,this.Jupiter.r)),t.incr(_a(e,Eu,this.Saturn.r)),t.incr(_a(e,Au,this.Uranus.r)),t.incr(_a(e,Tu,this.Neptune.r)),t}}class el{constructor(e,t,i,n){this.tt=e,this.r=t,this.v=i,this.a=n}clone(){return new el(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class lg{constructor(e,t){this.bary=e,this.grav=t}}function Bc(s,e,t,i){return new Mi(e.x+s*(t.x+s*i.x/2),e.y+s*(t.y+s*i.y/2),e.z+s*(t.z+s*i.z/2))}function Hf(s,e,t){return new Mi(e.x+s*t.x,e.y+s*t.y,e.z+s*t.z)}function Fu(s,e){const t=s-e.tt,i=new Qc(s),n=Bc(t,e.r,e.v,e.a),r=i.Acceleration(n).mean(e.a),a=Bc(t,e.r,e.v,r),o=e.v.add(r.mul(t)),c=i.Acceleration(a),l=new el(s,a,o,c);return new lg(i,l)}const e5=[];function hg(s,e){const t=Math.floor(s);return t<0?0:t>=e?e-1:t}function ku(s){const e=QS(s),t=new Qc(e.tt),i=e.r.add(t.Sun.r),n=e.v.add(t.Sun.v),r=t.Acceleration(i),a=new el(e.tt,i,n,r);return new lg(t,a)}function t5(s,e){const t=Xs[0][0];if(e<t||e>Xs[Uu-1][0])return null;const i=hg((e-t)/jS,Uu-1);if(!s[i]){const r=s[i]=[];r[0]=ku(Xs[i]).grav,r[Hn-1]=ku(Xs[i+1]).grav;let a,o=r[0].tt;for(a=1;a<Hn-1;++a)r[a]=Fu(o+=Or,r[a-1]).grav;o=r[Hn-1].tt;var n=[];for(n[Hn-1]=r[Hn-1],a=Hn-2;a>0;--a)n[a]=Fu(o-=Or,n[a+1]).grav;for(a=Hn-2;a>0;--a){const c=a/(Hn-1);r[a].r=r[a].r.mul(1-c).add(n[a].r.mul(c)),r[a].v=r[a].v.mul(1-c).add(n[a].v.mul(c)),r[a].a=r[a].a.mul(1-c).add(n[a].a.mul(c))}}return s[i]}function Gf(s,e,t){let i=ku(s);const n=Math.ceil((e-i.grav.tt)/t);for(let r=0;r<n;++r)i=Fu(r+1===n?e:i.grav.tt+t,i.grav);return i}function ug(s,e){let t,i,n;const r=t5(e5,s.tt);if(r){const a=hg((s.tt-r[0].tt)/Or,Hn-1),o=r[a],c=r[a+1],l=o.a.mean(c.a),h=Bc(s.tt-o.tt,o.r,o.v,l),u=Hf(s.tt-o.tt,o.v,l),d=Bc(s.tt-c.tt,c.r,c.v,l),f=Hf(s.tt-c.tt,c.v,l),p=(s.tt-o.tt)/Or;t=h.mul(1-p).add(d.mul(p)),i=u.mul(1-p).add(f.mul(p))}else{let a;s.tt<Xs[0][0]?a=Gf(Xs[0],s.tt,-Or):a=Gf(Xs[Uu-1],s.tt,+Or),t=a.grav.r,i=a.grav.v,n=a.bary}return n||(n=new Qc(s.tt)),t=t.sub(n.Sun.r),i=i.sub(n.Sun.v),new bs(t.x,t.y,t.z,i.x,i.y,i.z,s)}function ws(s,e){var t=Lt(e);if(s in Dn)return Kr(Dn[s],t);if(s===Se.Pluto){const a=ug(t);return new St(a.x,a.y,a.z,t)}if(s===Se.Sun)return new St(0,0,0,t);if(s===Se.Moon){var i=Kr(Dn.Earth,t),n=ta(t);return new St(i.x+n.x,i.y+n.y,i.z+n.z,t)}if(s===Se.EMB){const a=Kr(Dn.Earth,t),o=ta(t),c=1+eg;return new St(a.x+o.x/c,a.y+o.y/c,a.z+o.z/c,t)}if(s===Se.SSB)return JS(t);const r=Sd(s);if(r){const a=new jc(r.dec,15*r.ra,r.dist);return Rd(a,t)}throw`HelioVector: Unknown body "${s}"`}function i5(s,e){let t=e,i=0;for(let n=0;n<10;++n){const r=s(t),a=r.Length()/_d;if(a>1)throw"Object is too distant for light-travel solver.";const o=e.AddDays(-a);if(i=Math.abs(o.tt-t.tt),i<1e-9)return r;t=o}throw`Light-travel time solver did not converge: dt = ${i}`}class n5{constructor(e,t,i,n){this.observerBody=e,this.targetBody=t,this.aberration=i,this.observerPos=n}Position(e){this.aberration&&(this.observerPos=ws(this.observerBody,e));const t=ws(this.targetBody,e);return new St(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function s5(s,e,t,i){kc(i);const n=Lt(s);if(Sd(t)){const o=ws(t,n);if(i){const l=a5(e,n),h=new St(o.x-l.x,o.y-l.y,o.z-l.z,n),u=_d/h.Length();return new St(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,n)}const c=ws(e,n);return new St(o.x-c.x,o.y-c.y,o.z-c.z,n)}let r;i?r=new St(0,0,0,n):r=ws(e,n);const a=new n5(e,t,i,r);return i5(o=>a.Position(o),n)}function zu(s,e,t){kc(t);const i=Lt(e);switch(s){case Se.Earth:return new St(0,0,0,i);case Se.Moon:return ta(i);default:const n=s5(i,Se.Earth,s,t);return n.t=i,n}}function r5(s,e){return new bs(s.r.x,s.r.y,s.r.z,s.v.x,s.v.y,s.v.z,e)}function a5(s,e){const t=Lt(e);switch(s){case Se.Sun:return new bs(0,0,0,0,0,0,t);case Se.SSB:const i=new Qc(t.tt);return new bs(-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 Se.Mercury:case Se.Venus:case Se.Earth:case Se.Mars:case Se.Jupiter:case Se.Saturn:case Se.Uranus:case Se.Neptune:const n=Ou(Dn[s],t.tt);return r5(n,t);case Se.Pluto:return ug(t);case Se.Moon:case Se.EMB:const r=Ou(Dn.Earth,t.tt),a=s==Se.Moon?og(t):ZS(t);return new bs(a.x+r.r.x,a.y+r.r.y,a.z+r.r.z,a.vx+r.v.x,a.vy+r.v.y,a.vz+r.v.z,t);default:if(Sd(s)){const o=ws(s,t);return new bs(o.x,o.y,o.z,0,0,0,t)}throw`HelioState: Unsupported body "${s}"`}}function o5(s){for(;s<0;)s+=360;for(;s>=360;)s-=360;return s}function c5(s,e,t){if(s===Se.Earth||e===Se.Earth)throw"The Earth does not have a longitude as seen from itself.";const i=Lt(t),n=zu(s,i,!1),r=Cu(n),a=zu(e,i,!1),o=Cu(a);return o5(r.elon-o.elon)}function l5(s,e,t,i){let n,r=0,a=0,o=0;switch(s){case Se.Mercury:n=-.6,r=4.98,a=-4.88,o=3.02;break;case Se.Venus:e<163.6?(n=-4.47,r=1.03,a=.57,o=.13):(n=.98,r=-1.02);break;case Se.Mars:n=-1.52,r=1.6;break;case Se.Jupiter:n=-9.4,r=.5;break;case Se.Uranus:n=-7.19,r=.25;break;case Se.Neptune:n=-6.87;break;case Se.Pluto:n=-1,r=4;break;default:throw`VisualMagnitude: unsupported body ${s}`}const c=e/100;let l=n+c*(r+c*(a+c*o));return l+=5*Math.log10(t*i),l}function h5(s,e,t,i,n){const r=Cu(i),a=ft*28.06,o=ft*(169.51+382e-7*n.tt),c=ft*r.elat,l=ft*r.elon,h=Math.asin(Math.sin(c)*Math.cos(a)-Math.cos(c)*Math.sin(a)*Math.sin(l-o)),u=Math.sin(Math.abs(h));let d=-9+.044*s;return d+=u*(-2.6+1.2*u),d+=5*Math.log10(e*t),{mag:d,ring_tilt:Pn*h}}function u5(s,e,t){let i=s*ft,n=i*i,r=n*n,a=-12.717+1.49*Math.abs(i)+.0431*r;const o=385000.6/zs;let c=t/o;return a+=5*Math.log10(e*c),a}class d5{constructor(e,t,i,n,r,a,o,c){this.time=e,this.mag=t,this.phase_angle=i,this.helio_dist=n,this.geo_dist=r,this.gc=a,this.hc=o,this.ring_tilt=c,this.phase_fraction=(1+Math.cos(ft*i))/2}}function dg(s,e){if(s===Se.Earth)throw"The illumination of the Earth is not defined.";const t=Lt(e),i=Kr(Dn.Earth,t);let n,r,a,o;s===Se.Sun?(a=new St(-i.x,-i.y,-i.z,t),r=new St(0,0,0,t),n=0):(s===Se.Moon?(a=ta(t),r=new St(i.x+a.x,i.y+a.y,i.z+a.z,t)):(r=ws(s,e),a=new St(r.x-i.x,r.y-i.y,r.z-i.z,t)),n=IS(a,r));let c=a.Length(),l=r.Length(),h;if(s===Se.Sun)o=RS+5*Math.log10(c);else if(s===Se.Moon)o=u5(n,l,c);else if(s===Se.Saturn){const u=h5(n,l,c,a,t);o=u.mag,h=u.ring_tilt}else o=l5(s,n,l,c);return new d5(t,o,n,l,c,a,r,h)}function f5(s){return c5(Se.Moon,Se.Sun,s)}var Vf;(function(s){s[s.Pericenter=0]="Pericenter",s[s.Apocenter=1]="Apocenter"})(Vf||(Vf={}));function fg(s,e){return new As([[e.rot[0][0]*s.rot[0][0]+e.rot[1][0]*s.rot[0][1]+e.rot[2][0]*s.rot[0][2],e.rot[0][1]*s.rot[0][0]+e.rot[1][1]*s.rot[0][1]+e.rot[2][1]*s.rot[0][2],e.rot[0][2]*s.rot[0][0]+e.rot[1][2]*s.rot[0][1]+e.rot[2][2]*s.rot[0][2]],[e.rot[0][0]*s.rot[1][0]+e.rot[1][0]*s.rot[1][1]+e.rot[2][0]*s.rot[1][2],e.rot[0][1]*s.rot[1][0]+e.rot[1][1]*s.rot[1][1]+e.rot[2][1]*s.rot[1][2],e.rot[0][2]*s.rot[1][0]+e.rot[1][2]*s.rot[1][1]+e.rot[2][2]*s.rot[1][2]],[e.rot[0][0]*s.rot[2][0]+e.rot[1][0]*s.rot[2][1]+e.rot[2][0]*s.rot[2][2],e.rot[0][1]*s.rot[2][0]+e.rot[1][1]*s.rot[2][1]+e.rot[2][1]*s.rot[2][2],e.rot[0][2]*s.rot[2][0]+e.rot[1][2]*s.rot[2][1]+e.rot[2][2]*s.rot[2][2]]])}function Rd(s,e){e=Lt(e);const t=s.lat*ft,i=s.lon*ft,n=s.dist*Math.cos(t);return new St(n*Math.cos(i),n*Math.sin(i),s.dist*Math.sin(t),e)}function Dd(s){const e=p5(s);return new Du(e.lon/15,e.lat,e.dist,s)}function p5(s){const e=s.x*s.x+s.y*s.y,t=Math.sqrt(e+s.z*s.z);let i,n;if(e===0){if(s.z===0)throw"Zero-length vector not allowed.";n=0,i=s.z<0?-90:90}else n=Pn*Math.atan2(s.y,s.x),n<0&&(n+=360),i=Pn*Math.atan2(s.z,Math.sqrt(e));return new jc(i,n,t)}function pg(s,e){let t;if(ai(e),e<-90||e>90)return 0;if(s==="normal"||s==="jplhor"){let i=e;i<-1&&(i=-1),t=1.02/Math.tan((i+10.3/(i+5.11))*ft)/60,s==="normal"&&e<-1&&(t*=(e+90)/89)}else if(!s)t=0;else throw`Invalid refraction option: ${s}`;return t}function $r(s,e){return new St(s.rot[0][0]*e.x+s.rot[1][0]*e.y+s.rot[2][0]*e.z,s.rot[0][1]*e.x+s.rot[1][1]*e.y+s.rot[2][1]*e.z,s.rot[0][2]*e.x+s.rot[1][2]*e.y+s.rot[2][2]*e.z,e.t)}function m5(){return new As([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function g5(){return new As([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function mg(s){s=Lt(s);const e=bd(s,fi.From2000),t=wd(s,fi.From2000);return fg(e,t)}function v5(s){s=Lt(s);const e=wd(s,fi.Into2000),t=bd(s,fi.Into2000);return fg(e,t)}function M5(s){const t=so(Lt(s)).tobl*ft,i=Math.cos(t),n=Math.sin(t);return new As([[1,0,0],[0,+i,+n],[0,-n,+i]])}var Wf;(function(s){s.Penumbral="penumbral",s.Partial="partial",s.Annular="annular",s.Total="total"})(Wf||(Wf={}));var Xf;(function(s){s[s.Invalid=0]="Invalid",s[s.Ascending=1]="Ascending",s[s.Descending=-1]="Descending"})(Xf||(Xf={}));const x5=["Venus","Mars","Jupiter","Saturn"];function gg(s){return new Td(s.lat,s.lng,s.elevationM)}function Cd(s,e,t,i,n=!0){const r=rg(t,gg(i),s,e,n?"normal":void 0);return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}class an{up;north;west;constructor(e,t){const i=Lt(e),n=Math.sin(t.lat*Gn),r=Math.cos(t.lat*Gn),a=Math.sin(t.lng*Gn),o=Math.cos(t.lng*Gn),c=-15*GS(i),l=v5(i);this.up=an.rotate(l,an.spin(c,[r*o,r*a,n]),i),this.north=an.rotate(l,an.spin(c,[-n*o,-n*a,r]),i),this.west=an.rotate(l,an.spin(c,[a,-o,0]),i)}static ofJ2000(e,t,i,n,r=!0){const a=Lt(i),o=Rd(new jc(t,e*15,1),a),c=Dd($r(mg(a),o));return Cd(c.ra,c.dec,i,n,r)}position(e,t){const i=Math.sin(t*Gn),n=Math.cos(t*Gn),r=Math.sin(e*Yf),a=Math.cos(e*Yf),o=n*a,c=n*r,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=-qf*Math.atan2(d,u),p<0&&(p+=360));let v=qf*Math.atan2(f,h);return v-=pg("normal",90-v),{altitudeDeg:90-v,azimuthDeg:p}}static spin(e,[t,i,n]){const r=Math.cos(e*Gn),a=Math.sin(e*Gn);return[r*t+a*i,r*i-a*t,n]}static rotate(e,[t,i,n],r){const a=$r(e,new St(t,i,n,r));return[a.x,a.y,a.z]}}const Gn=Math.PI/180,qf=180/Math.PI,Yf=15*Gn;function $l(s,e,t){const i=gg(t),n=KS(Se[s],e,i,!0,!0),r=rg(e,i,n.ra,n.dec,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function Zl(s,e){return dg(Se[s],e).mag}function _5(s){const e=f5(s),t=dg(Se.Moon,s);return{phaseFraction:e/360,illuminatedFraction:t.phase_fraction}}const y5=2e3,S5=3,b5=20;function Zo(s,e,t){if(s.year===void 0&&s.month===void 0&&s.day===void 0&&s.hour===void 0)return;const i=s.year!==void 0,n=s.year??y5,r=s.month??(i?1:S5),a=s.day??(i?1:b5),o=t??Math.round(e/15);return new Date(Date.UTC(n,r-1,a,(s.hour??12)-o,s.minute??0,s.second??0))}class _s{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static apply(e){e.transparent=!0,e.depthWrite=!1,e.onBeforeCompile=t=>{t.fragmentShader=_s.patch(t.fragmentShader)}}static patch(e){return e.replace(_s.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
|
|
5303
|
+
*/const _d=173.1446326846693,zs=14959787069098932e-8,ft=.017453292519943295,Ff=.26179938779914946,Pn=57.29577951308232,jm=3.819718634205488,wS=365.24217,kf=new Date("2000-01-01T12:00:00Z"),Bn=2*Math.PI,fs=3600*(180/Math.PI),Nr=484813681109536e-20,Qm=10800*60,AS=2*Qm,zf=7292115e-11,TS=Qm/Math.PI,RS=-.17-5*Math.log10(TS),Su=.996647180302104,DS=Su*Su,bu=6378.1366,CS=bu/zs,eg=81.30056,yd=.0002959122082855911,Eu=2825345909524226e-22,wu=8459715185680659e-23,Au=1292024916781969e-23,Tu=1524358900784276e-23;function kc(s){if(s!==!0&&s!==!1)throw console.trace(),`Value is not boolean: ${s}`;return s}function ai(s){if(!Number.isFinite(s))throw console.trace(),`Value is not a finite number: ${s}`;return s}function Rr(s){return s-Math.floor(s)}function IS(s,e){const t=s.x*s.x+s.y*s.y+s.z*s.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=(s.x*e.x+s.y*e.y+s.z*e.z)/Math.sqrt(t*i);return n<=-1?180:n>=1?0:Pn*Math.acos(n)}var Se;(function(s){s.Sun="Sun",s.Moon="Moon",s.Mercury="Mercury",s.Venus="Venus",s.Earth="Earth",s.Mars="Mars",s.Jupiter="Jupiter",s.Saturn="Saturn",s.Uranus="Uranus",s.Neptune="Neptune",s.Pluto="Pluto",s.SSB="SSB",s.EMB="EMB",s.Star1="Star1",s.Star2="Star2",s.Star3="Star3",s.Star4="Star4",s.Star5="Star5",s.Star6="Star6",s.Star7="Star7",s.Star8="Star8"})(Se||(Se={}));const PS=[Se.Star1,Se.Star2,Se.Star3,Se.Star4,Se.Star5,Se.Star6,Se.Star7,Se.Star8],LS=[{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 NS(s){const e=PS.indexOf(s);return e>=0?LS[e]:null}function Sd(s){const e=NS(s);return e&&e.dist>0?e:null}var fi;(function(s){s[s.From2000=0]="From2000",s[s.Into2000=1]="Into2000"})(fi||(fi={}));const Dn={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 OS(s){var e,t,i,n,r,a,o;const c=2e3+(s-14)/wS;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,r=t*i,a=i*i,10583.6-1014.41*e+33.78311*t-5.952053*i-.1798452*n+.022174192*r+.0090316521*a):c<1600?(e=(c-1e3)/100,t=e*e,i=e*t,n=t*t,r=t*i,a=i*i,1574.2-556.01*e+71.23472*t+.319781*i-.8503463*n-.005050998*r+.0083572073*a):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,r=t*i,a=i*i,o=i*n,13.72-.332447*e+.0068612*t+.0041116*i-37436e-8*n+121272e-10*r-1699e-10*a+875e-12*o):c<1900?(e=c-1860,t=e*e,i=e*t,n=t*t,r=t*i,7.62+.5737*e-.251754*t+.01680668*i-.0004473624*n+r/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,r=t*i,63.86+.3345*e-.060374*t+.0017275*i+651814e-9*n+2373599e-11*r):c<2050?(e=c-2e3,62.92+.32217*e+.005589*e*e):c<2150?(e=(c-1820)/100,-20+32*e*e-.5628*(2150-c)):(e=(c-1820)/100,-20+32*e*e)}let US=OS;function Bf(s){return s+US(s)/86400}class qr{constructor(e){if(e instanceof qr){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()-kf.getTime())/t,this.tt=Bf(this.ut);return}if(Number.isFinite(e)){this.date=new Date(kf.getTime()+e*t),this.ut=e,this.tt=Bf(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 qr(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 qr(this.ut+e)}}function Lt(s){return s instanceof qr?s:new qr(s)}function FS(s){function e(d){return d%AS*Nr}const t=s.tt/36525,i=e(128710479305e-5+t*1295965810481e-4),n=e(335779.526232+t*17395272628478e-4),r=e(107226070369e-5+t*1602961601209e-3),a=e(450160.398036-t*69628905431e-4);let o=Math.sin(a),c=Math.cos(a),l=(-172064161-174666*t)*o+33386*c,h=(92052331+9086*t)*c+15377*o,u=2*(n-r+a);return o=Math.sin(u),c=Math.cos(u),l+=(-13170906-1675*t)*o-13696*c,h+=(5730336-3015*t)*c-4587*o,u=2*(n+a),o=Math.sin(u),c=Math.cos(u),l+=(-2276413-234*t)*o+2796*c,h+=(978459-485*t)*c+1374*o,u=2*a,o=Math.sin(u),c=Math.cos(u),l+=(2074554+207*t)*o-698*c,h+=(-897492+470*t)*c-291*o,o=Math.sin(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 tg(s){var e=s.tt/36525,t=((((-434e-10*e-576e-9)*e+.0020034)*e-1831e-7)*e-46.836769)*e+84381.406;return t/3600}var qo;function so(s){if(!qo||Math.abs(qo.tt-s.tt)>1e-6){const e=FS(s),t=tg(s),i=t+e.deps/3600;qo={tt:s.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*ft)/15,mobl:t,tobl:i}}return qo}function kS(s,e){const t=s*ft,i=Math.cos(t),n=Math.sin(t);return[e[0],e[1]*i-e[2]*n,e[1]*n+e[2]*i]}function zS(s,e){return kS(tg(s),e)}function BS(s){const e=s.tt/36525;function t(Re,xe){const Ne=[];let Oe;for(Oe=0;Oe<=xe-Re;++Oe)Ne.push(0);return{min:Re,array:Ne}}function i(Re,xe,Ne,Oe){const Ue=[];for(let ct=0;ct<=xe-Re;++ct)Ue.push(t(Ne,Oe));return{min:Re,array:Ue}}function n(Re,xe,Ne){const Oe=Re.array[xe-Re.min];return Oe.array[Ne-Oe.min]}function r(Re,xe,Ne,Oe){const Ue=Re.array[xe-Re.min];Ue.array[Ne-Ue.min]=Oe}let a,o,c,l,h,u,d,f,p,v,m,g,b,y,_,E,w,R,x,A,I,C,P,X=i(-6,6,1,4),z=i(-6,6,1,4);function N(Re,xe){return n(X,Re,xe)}function V(Re,xe){return n(z,Re,xe)}function k(Re,xe,Ne){return r(X,Re,xe,Ne)}function K(Re,xe,Ne){return r(z,Re,xe,Ne)}function ee(Re,xe,Ne,Oe,Ue){Ue(Re*Ne-xe*Oe,xe*Ne+Re*Oe)}function J(Re){return Math.sin(Bn*Re)}d=e*e,p=0,P=0,m=0,g=3422.7;var ie=J(.19833+.05611*e),ae=J(.27869+.04508*e),Be=J(.16827-.36903*e),je=J(.34734-5.37261*e),Ge=J(.10498-5.37899*e),Y=J(.42681-.41855*e),re=J(.14943-5.37511*e);for(R=.84*ie+.31*ae+14.27*Be+7.26*je+.28*Ge+.24*Y,x=2.94*ie+.31*ae+14.27*Be+9.34*je+1.12*Ge+.83*Y,A=-6.4*ie-1.89*Y,I=.21*ie+.31*ae+14.27*Be-88.7*je-15.3*Ge+.24*Y-1.86*re,C=R-A,f=-3332e-9*J(.59734-5.37261*e)-539e-9*J(.35498-5.37899*e)-64e-9*J(.39943-5.37511*e),b=Bn*Rr(.60643382+1336.85522467*e-313e-8*d)+R/fs,y=Bn*Rr(.37489701+1325.55240982*e+2565e-8*d)+x/fs,_=Bn*Rr(.99312619+99.99735956*e-44e-8*d)+A/fs,E=Bn*Rr(.25909118+1342.2278298*e-892e-8*d)+I/fs,w=Bn*Rr(.82736186+1236.85308708*e-397e-8*d)+C/fs,h=1;h<=4;++h){switch(h){case 1:c=y,o=4,l=1.000002208;break;case 2:c=_,o=3,l=.997504612-.002495388*e;break;case 3:c=E,o=4,l=1.000002708+139.978*f;break;case 4:c=w,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),(Re,xe)=>(k(u,h,Re),K(u,h,xe)));for(u=1;u<=o;++u)k(-u,h,N(u,h)),K(-u,h,-V(u,h))}function ne(Re,xe,Ne,Oe){for(var Ue={x:1,y:0},ct=[0,Re,xe,Ne,Oe],lt=1;lt<=4;++lt)ct[lt]!==0&&ee(Ue.x,Ue.y,N(ct[lt],lt),V(ct[lt],lt),(Nt,Tt)=>(Ue.x=Nt,Ue.y=Tt));return Ue}function B(Re,xe,Ne,Oe,Ue,ct,lt,Nt){var Tt=ne(Ue,ct,lt,Nt);p+=Re*Tt.y,P+=xe*Tt.y,m+=Ne*Tt.x,g+=Oe*Tt.x}B(13.902,14.06,-.001,.2607,0,0,0,4),B(.403,-4.01,.394,.0023,0,0,0,3),B(2369.912,2373.36,.601,28.2333,0,0,0,2),B(-125.154,-112.79,-.725,-.9781,0,0,0,1),B(1.979,6.98,-.445,.0433,1,0,0,4),B(191.953,192.72,.029,3.0861,1,0,0,2),B(-8.466,-13.51,.455,-.1093,1,0,0,1),B(22639.5,22609.07,.079,186.5398,1,0,0,0),B(18.609,3.59,-.094,.0118,1,0,0,-1),B(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),B(3.215,5.44,.192,-.0386,1,0,0,-3),B(-38.428,-38.64,.001,.6008,1,0,0,-4),B(-.393,-1.43,-.092,.0086,1,0,0,-6),B(-.289,-1.59,.123,-.0053,0,1,0,4),B(-24.42,-25.1,.04,-.3,0,1,0,2),B(18.023,17.93,.007,.1494,0,1,0,1),B(-668.146,-126.98,-1.302,-.3997,0,1,0,0),B(.56,.32,-.001,-.0037,0,1,0,-1),B(-165.145,-165.06,.054,1.9178,0,1,0,-2),B(-1.877,-6.46,-.416,.0339,0,1,0,-4),B(.213,1.02,-.074,.0054,2,0,0,4),B(14.387,14.78,-.017,.2833,2,0,0,2),B(-.586,-1.2,.054,-.01,2,0,0,1),B(769.016,767.96,.107,10.1657,2,0,0,0),B(1.75,2.01,-.018,.0155,2,0,0,-1),B(-211.656,-152.53,5.679,-.3039,2,0,0,-2),B(1.225,.91,-.03,-.0088,2,0,0,-3),B(-30.773,-34.07,-.308,.3722,2,0,0,-4),B(-.57,-1.4,-.074,.0109,2,0,0,-6),B(-2.921,-11.75,.787,-.0484,1,1,0,2),B(1.267,1.52,-.022,.0164,1,1,0,1),B(-109.673,-115.18,.461,-.949,1,1,0,0),B(-205.962,-182.36,2.056,1.4437,1,1,0,-2),B(.233,.36,.012,-.0025,1,1,0,-3),B(-4.391,-9.66,-.471,.0673,1,1,0,-4),B(.283,1.53,-.111,.006,1,-1,0,4),B(14.577,31.7,-1.54,.2302,1,-1,0,2),B(147.687,138.76,.679,1.1528,1,-1,0,0),B(-1.089,.55,.021,0,1,-1,0,-1),B(28.475,23.59,-.443,-.2257,1,-1,0,-2),B(-.276,-.38,-.006,-.0036,1,-1,0,-3),B(.636,2.27,.146,-.0102,1,-1,0,-4),B(-.189,-1.68,.131,-.0028,0,2,0,2),B(-7.486,-.66,-.037,-.0086,0,2,0,0),B(-8.096,-16.35,-.74,.0918,0,2,0,-2),B(-5.741,-.04,0,-9e-4,0,0,2,2),B(.255,0,0,0,0,0,2,1),B(-411.608,-.2,0,-.0124,0,0,2,0),B(.584,.84,0,.0071,0,0,2,-1),B(-55.173,-52.14,0,-.1052,0,0,2,-2),B(.254,.25,0,-.0017,0,0,2,-3),B(.025,-1.67,0,.0031,0,0,2,-4),B(1.06,2.96,-.166,.0243,3,0,0,2),B(36.124,50.64,-1.3,.6215,3,0,0,0),B(-13.193,-16.4,.258,-.1187,3,0,0,-2),B(-1.187,-.74,.042,.0074,3,0,0,-4),B(-.293,-.31,-.002,.0046,3,0,0,-6),B(-.29,-1.45,.116,-.0051,2,1,0,2),B(-7.649,-10.56,.259,-.1038,2,1,0,0),B(-8.627,-7.59,.078,-.0192,2,1,0,-2),B(-2.74,-2.54,.022,.0324,2,1,0,-4),B(1.181,3.32,-.212,.0213,2,-1,0,2),B(9.703,11.67,-.151,.1268,2,-1,0,0),B(-.352,-.37,.001,-.0028,2,-1,0,-1),B(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),B(.36,.2,-.012,-.0043,2,-1,0,-4),B(-1.167,-1.25,.008,-.0106,1,2,0,0),B(-7.412,-6.12,.117,.0484,1,2,0,-2),B(-.311,-.65,-.032,.0044,1,2,0,-4),B(.757,1.82,-.105,.0112,1,-2,0,2),B(2.58,2.32,.027,.0196,1,-2,0,0),B(2.533,2.4,-.014,-.0212,1,-2,0,-2),B(-.344,-.57,-.025,.0036,0,3,0,-2),B(-.992,-.02,0,0,1,0,2,2),B(-45.099,-.02,0,-.001,1,0,2,0),B(-.179,-9.52,0,-.0833,1,0,2,-2),B(-.301,-.33,0,.0014,1,0,2,-4),B(-6.382,-3.37,0,-.0481,1,0,-2,2),B(39.528,85.13,0,-.7136,1,0,-2,0),B(9.366,.71,0,-.0112,1,0,-2,-2),B(.202,.02,0,0,1,0,-2,-4),B(.415,.1,0,.0013,0,1,2,0),B(-2.152,-2.26,0,-.0066,0,1,2,-2),B(-1.44,-1.3,0,.0014,0,1,-2,2),B(.384,-.04,0,0,0,1,-2,-2),B(1.938,3.6,-.145,.0401,4,0,0,0),B(-.952,-1.58,.052,-.013,4,0,0,-2),B(-.551,-.94,.032,-.0097,3,1,0,0),B(-.482,-.57,.005,-.0045,3,1,0,-2),B(.681,.96,-.026,.0115,3,-1,0,0),B(-.297,-.27,.002,-9e-4,2,2,0,-2),B(.254,.21,-.003,0,2,-2,0,-2),B(-.25,-.22,.004,.0014,1,3,0,-2),B(-3.996,0,0,4e-4,2,0,2,0),B(.557,-.75,0,-.009,2,0,2,-2),B(-.459,-.38,0,-.0053,2,0,-2,2),B(-1.298,.74,0,4e-4,2,0,-2,0),B(.538,1.14,0,-.0141,2,0,-2,-2),B(.263,.02,0,0,1,1,2,0),B(.426,.07,0,-6e-4,1,1,-2,-2),B(-.304,.03,0,3e-4,1,-1,2,0),B(-.372,-.19,0,-.0027,1,-1,-2,2),B(.418,0,0,0,0,0,4,0),B(-.33,-.04,0,0,3,0,2,0);function Ee(Re,xe,Ne,Oe,Ue){return Re*ne(xe,Ne,Oe,Ue).y}v=0,v+=Ee(-526.069,0,0,1,-2),v+=Ee(-3.352,0,0,1,-4),v+=Ee(44.297,1,0,1,-2),v+=Ee(-6,1,0,1,-4),v+=Ee(20.599,-1,0,1,0),v+=Ee(-30.598,-1,0,1,-2),v+=Ee(-24.649,-2,0,1,0),v+=Ee(-2,-2,0,1,-2),v+=Ee(-22.571,0,1,1,-2),v+=Ee(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),a=E+P/fs;let Pe=(1.000002708+139.978*f)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+v;return{geo_eclip_lon:Bn*Rr((b+p/fs)/Bn),geo_eclip_lat:Math.PI/(180*3600)*Pe,distance_au:fs*CS/(.999953253*g)}}function ig(s,e){return[s.rot[0][0]*e[0]+s.rot[1][0]*e[1]+s.rot[2][0]*e[2],s.rot[0][1]*e[0]+s.rot[1][1]*e[1]+s.rot[2][1]*e[2],s.rot[0][2]*e[0]+s.rot[1][2]*e[1]+s.rot[2][2]*e[2]]}function zc(s,e,t){const i=bd(e,t);return ig(i,s)}function bd(s,e){const t=s.tt/36525;let i=84381.406,n=((((-951e-10*t+132851e-9)*t-.00114045)*t-1.0790069)*t+5038.481507)*t,r=((((3337e-10*t-467e-9)*t-.00772503)*t+.0512623)*t-.025754)*t+i,a=((((-56e-9*t+170663e-9)*t-.00121197)*t-2.3814292)*t+10.556403)*t;i*=Nr,n*=Nr,r*=Nr,a*=Nr;const o=Math.sin(i),c=Math.cos(i),l=Math.sin(-n),h=Math.cos(-n),u=Math.sin(-r),d=Math.cos(-r),f=Math.sin(a),p=Math.cos(a),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,b=-f*h-l*p*d,y=-f*l*c+p*d*h*c-o*p*u,_=-f*l*o+p*d*h*o+c*p*u,E=l*u,w=-u*h*c-o*d,R=-u*h*o+d*c;if(e===fi.Into2000)return new As([[v,m,g],[b,y,_],[E,w,R]]);if(e===fi.From2000)return new As([[v,b,E],[m,y,w],[g,_,R]]);throw"Invalid precess direction"}function HS(s){const e=.779057273264+.00273781191135448*s.ut,t=s.ut%1;let i=360*((e+t)%1);return i<0&&(i+=360),i}let Yo;function Jc(s){if(!Yo||Yo.tt!==s.tt){const e=s.tt/36525;let t=15*so(s).ee;const i=HS(s);let r=((t+.014506+((((-368e-10*e-29956e-9)*e-44e-8)*e+1.3915817)*e+4612.156534)*e)/3600+i)%360/15;r<0&&(r+=24),Yo={tt:s.tt,st:r}}return Yo.st}function GS(s){const e=Lt(s);return Jc(e)}function ng(s,e){const t=s.latitude*ft,i=Math.sin(t),n=Math.cos(t),r=1/Math.hypot(n,Su*i),a=DS*r,o=s.height/1e3,c=bu*r+o,l=bu*a+o,h=(15*e+s.longitude)*ft,u=Math.sin(h),d=Math.cos(h);return{pos:[c*n*d/zs,c*n*u/zs,l*i/zs],vel:[-zf*c*n*u*86400/zs,zf*c*n*d*86400/zs,0]}}function Ru(s,e,t){const i=Ed(e,t);return ig(i,s)}function Ed(s,e){const t=so(s),i=t.mobl*ft,n=t.tobl*ft,r=t.dpsi*Nr,a=Math.cos(i),o=Math.sin(i),c=Math.cos(n),l=Math.sin(n),h=Math.cos(r),u=Math.sin(r),d=h,f=-u*a,p=-u*o,v=u*c,m=h*a*c+o*l,g=h*o*c-a*l,b=u*l,y=h*a*l-o*c,_=h*o*l+a*c;if(e===fi.From2000)return new As([[d,v,b],[f,m,y],[p,g,_]]);if(e===fi.Into2000)return new As([[d,f,p],[v,m,g],[b,y,_]]);throw"Invalid precess direction"}function wd(s,e,t){return t===fi.Into2000?zc(Ru(s,e,t),e,t):Ru(zc(s,e,t),e,t)}function VS(s,e){const t=Jc(s),i=ng(e,t).pos;return wd(i,s,fi.Into2000)}class St{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 bs{constructor(e,t,i,n,r,a,o){this.x=e,this.y=t,this.z=i,this.vx=n,this.vy=r,this.vz=a,this.t=o}}class jc{constructor(e,t,i){this.lat=ai(e),this.lon=ai(t),this.dist=ai(i)}}class Du{constructor(e,t,i,n){this.ra=ai(e),this.dec=ai(t),this.dist=ai(i),this.vec=n}}class As{constructor(e){this.rot=e}}class WS{constructor(e,t,i,n){this.azimuth=ai(e),this.altitude=ai(t),this.ra=ai(i),this.dec=ai(n)}}class XS{constructor(e,t,i){this.vec=e,this.elat=ai(t),this.elon=ai(i)}}function sg(s,e){return new St(s[0],s[1],s[2],e)}function qS(s,e){const t=sg(s,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 Du(0,t.z<0?-90:90,n,t)}let r=jm*Math.atan2(t.y,t.x);r<0&&(r+=24);const a=Pn*Math.atan2(s[2],Math.sqrt(i));return new Du(r,a,n,t)}function Yl(s,e){const t=s*ft,i=Math.cos(t),n=Math.sin(t);return[i*e[0]+n*e[1],i*e[1]-n*e[0],e[2]]}function rg(s,e,t,i,n){let r=Lt(s);Ad(e),ai(t),ai(i);const a=Math.sin(e.latitude*ft),o=Math.cos(e.latitude*ft),c=Math.sin(e.longitude*ft),l=Math.cos(e.longitude*ft),h=Math.sin(i*ft),u=Math.cos(i*ft),d=Math.sin(t*Ff),f=Math.cos(t*Ff);let p=[o*l,o*c,a],v=[-a*l,-a*c,o],m=[c,-l,0];const g=-15*Jc(r);let b=Yl(g,p),y=Yl(g,v),_=Yl(g,m),E=[u*f,u*d,h];const w=E[0]*b[0]+E[1]*b[1]+E[2]*b[2],R=E[0]*y[0]+E[1]*y[1]+E[2]*y[2],x=E[0]*_[0]+E[1]*_[1]+E[2]*_[2];let A=Math.hypot(R,x),I;A>0?(I=-Pn*Math.atan2(x,R),I<0&&(I+=360)):I=0;let C=Pn*Math.atan2(A,w),P=t,X=i;if(n){let z=C,N=pg(n,90-C);if(C-=N,N>0&&C>3e-4){const V=Math.sin(C*ft),k=Math.cos(C*ft),K=Math.sin(z*ft),ee=Math.cos(z*ft),J=[];for(let ie=0;ie<3;++ie)J.push((E[ie]-ee*b[ie])/K*V+b[ie]*k);A=Math.hypot(J[0],J[1]),A>0?(P=jm*Math.atan2(J[1],J[0]),P<0&&(P+=24)):P=0,X=Pn*Math.atan2(J[2],A)}}return new WS(I,90-C,P,X)}function Ad(s){if(!(s instanceof Td))throw`Not an instance of the Observer class: ${s}`;if(ai(s.latitude),ai(s.longitude),ai(s.height),s.latitude<-90||s.latitude>90)throw`Latitude ${s.latitude} is out of range. Must be -90..+90.`;return s}class Td{constructor(e,t,i){this.latitude=e,this.longitude=t,this.height=i,Ad(this)}}function YS(s){const e=Lt(s).AddDays(-1/_d),t=Kr(Dn.Earth,e),i=[-t.x,-t.y,-t.z],[n,r,a]=wd(i,e,fi.From2000),o=ft*so(e).tobl,c=Math.cos(o),l=Math.sin(o),h=new St(n,r,a,e);return ag(h,c,l)}function KS(s,e,t,i,n){Ad(t),kc(i),kc(n);const r=Lt(e),a=VS(r,t),o=zu(s,r,n),c=[o.x-a[0],o.y-a[1],o.z-a[2]],l=wd(c,r,fi.From2000);return qS(l,r)}function $S(s,e,t){const i=Lt(s),n=Jc(i);let r=ng(e,n).pos;return sg(r,i)}function ag(s,e,t){const i=s.x,n=s.y*e+s.z*t,r=-s.y*t+s.z*e,a=Math.hypot(i,n);let o=0;a>0&&(o=Pn*Math.atan2(n,i),o<0&&(o+=360));let c=Pn*Math.atan2(r,a),l=new St(i,n,r,s.t);return new XS(l,c,o)}function Cu(s){const e=so(s.t),t=[s.x,s.y,s.z],i=zc(t,s.t,fi.From2000),[n,r,a]=Ru(i,s.t,fi.From2000),o=new St(n,r,a,s.t),c=e.tobl*ft;return ag(o,Math.cos(c),Math.sin(c))}function ta(s){const e=Lt(s),t=BS(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)],r=zS(e,n),a=zc(r,e,fi.Into2000);return new St(a[0],a[1],a[2],e)}function og(s){const e=Lt(s),t=1e-5,i=e.AddDays(-t),n=e.AddDays(+t),r=ta(i),a=ta(n);return new bs((r.x+a.x)/2,(r.y+a.y)/2,(r.z+a.z)/2,(a.x-r.x)/(2*t),(a.y-r.y)/(2*t),(a.z-r.z)/(2*t),e)}function ZS(s){const e=Lt(s),t=og(e),i=1+eg;return new bs(t.x/i,t.y/i,t.z/i,t.vx/i,t.vy/i,t.vz/i,e)}function Yr(s,e,t){let i=1,n=0;for(let r of s){let a=0;for(let[c,l,h]of r)a+=c*Math.cos(l+e*h);let o=i*a;t&&(o%=Bn),n+=o,i*=e}return n}function Kl(s,e){let t=1,i=0,n=0,r=0;for(let a of s){let o=0,c=0;for(let[l,h,u]of a){let d=h+e*u;o+=l*u*Math.sin(d),r>0&&(c+=l*Math.cos(d))}n+=r*i*c-t*o,i=t,t*=e,++r}return n}const Ia=365250,Iu=0,Pu=1,Lu=2;function Nu(s){return new Mi(s[0]+44036e-11*s[1]-190919e-12*s[2],-479966e-12*s[0]+.917482137087*s[1]-.397776982902*s[2],.397776982902*s[1]+.917482137087*s[2])}function cg(s,e,t){const i=t*Math.cos(e),n=Math.cos(s),r=Math.sin(s);return[i*n,i*r,t*Math.sin(e)]}function Kr(s,e){const t=e.tt/Ia,i=Yr(s[Iu],t,!0),n=Yr(s[Pu],t,!1),r=Yr(s[Lu],t,!1),a=cg(i,n,r);return Nu(a).ToAstroVector(e)}function Ou(s,e){const t=e/Ia,i=Yr(s[Iu],t,!0),n=Yr(s[Pu],t,!1),r=Yr(s[Lu],t,!1),a=Kl(s[Iu],t),o=Kl(s[Pu],t),c=Kl(s[Lu],t),l=Math.cos(i),h=Math.sin(i),u=Math.cos(n),d=Math.sin(n),f=+(c*u*l)-r*d*l*o-r*u*h*a,p=+(c*u*h)-r*d*h*o+r*u*l*a,v=+(c*d)+r*u*o,m=cg(i,n,r),g=[f/Ia,p/Ia,v/Ia],b=Nu(m),y=Nu(g);return new js(e,b,y)}function Ko(s,e,t,i){const n=i/(i+yd),r=Kr(Dn[t],e);s.x+=n*r.x,s.y+=n*r.y,s.z+=n*r.z}function JS(s){const e=new St(0,0,0,s);return Ko(e,s,Se.Jupiter,Eu),Ko(e,s,Se.Saturn,wu),Ko(e,s,Se.Uranus,Au),Ko(e,s,Se.Neptune,Tu),e}const Uu=51,jS=29200,Or=146,Hn=201,Xs=[[-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 Mi{constructor(e,t,i){this.x=e,this.y=t,this.z=i}clone(){return new Mi(this.x,this.y,this.z)}ToAstroVector(e){return new St(this.x,this.y,this.z,e)}static zero(){return new Mi(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new Mi(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new Mi(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 Mi(e*this.x,e*this.y,e*this.z)}div(e){return new Mi(this.x/e,this.y/e,this.z/e)}mean(e){return new Mi((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new Mi(-this.x,-this.y,-this.z)}}class js{constructor(e,t,i){this.tt=e,this.r=t,this.v=i}clone(){return new js(this.tt,this.r,this.v)}sub(e){return new js(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function QS(s){let[e,[t,i,n],[r,a,o]]=s;return new js(e,new Mi(t,i,n),new Mi(r,a,o))}function $o(s,e,t,i){const n=i/(i+yd),r=Ou(Dn[t],e);return s.r.incr(r.r.mul(n)),s.v.incr(r.v.mul(n)),r}function _a(s,e,t){const i=t.sub(s),n=i.quadrature();return i.mul(e/(n*Math.sqrt(n)))}class Qc{constructor(e){let t=new js(e,new Mi(0,0,0),new Mi(0,0,0));this.Jupiter=$o(t,e,Se.Jupiter,Eu),this.Saturn=$o(t,e,Se.Saturn,wu),this.Uranus=$o(t,e,Se.Uranus,Au),this.Neptune=$o(t,e,Se.Neptune,Tu),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 js(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=_a(e,yd,this.Sun.r);return t.incr(_a(e,Eu,this.Jupiter.r)),t.incr(_a(e,wu,this.Saturn.r)),t.incr(_a(e,Au,this.Uranus.r)),t.incr(_a(e,Tu,this.Neptune.r)),t}}class el{constructor(e,t,i,n){this.tt=e,this.r=t,this.v=i,this.a=n}clone(){return new el(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class lg{constructor(e,t){this.bary=e,this.grav=t}}function Bc(s,e,t,i){return new Mi(e.x+s*(t.x+s*i.x/2),e.y+s*(t.y+s*i.y/2),e.z+s*(t.z+s*i.z/2))}function Hf(s,e,t){return new Mi(e.x+s*t.x,e.y+s*t.y,e.z+s*t.z)}function Fu(s,e){const t=s-e.tt,i=new Qc(s),n=Bc(t,e.r,e.v,e.a),r=i.Acceleration(n).mean(e.a),a=Bc(t,e.r,e.v,r),o=e.v.add(r.mul(t)),c=i.Acceleration(a),l=new el(s,a,o,c);return new lg(i,l)}const e5=[];function hg(s,e){const t=Math.floor(s);return t<0?0:t>=e?e-1:t}function ku(s){const e=QS(s),t=new Qc(e.tt),i=e.r.add(t.Sun.r),n=e.v.add(t.Sun.v),r=t.Acceleration(i),a=new el(e.tt,i,n,r);return new lg(t,a)}function t5(s,e){const t=Xs[0][0];if(e<t||e>Xs[Uu-1][0])return null;const i=hg((e-t)/jS,Uu-1);if(!s[i]){const r=s[i]=[];r[0]=ku(Xs[i]).grav,r[Hn-1]=ku(Xs[i+1]).grav;let a,o=r[0].tt;for(a=1;a<Hn-1;++a)r[a]=Fu(o+=Or,r[a-1]).grav;o=r[Hn-1].tt;var n=[];for(n[Hn-1]=r[Hn-1],a=Hn-2;a>0;--a)n[a]=Fu(o-=Or,n[a+1]).grav;for(a=Hn-2;a>0;--a){const c=a/(Hn-1);r[a].r=r[a].r.mul(1-c).add(n[a].r.mul(c)),r[a].v=r[a].v.mul(1-c).add(n[a].v.mul(c)),r[a].a=r[a].a.mul(1-c).add(n[a].a.mul(c))}}return s[i]}function Gf(s,e,t){let i=ku(s);const n=Math.ceil((e-i.grav.tt)/t);for(let r=0;r<n;++r)i=Fu(r+1===n?e:i.grav.tt+t,i.grav);return i}function ug(s,e){let t,i,n;const r=t5(e5,s.tt);if(r){const a=hg((s.tt-r[0].tt)/Or,Hn-1),o=r[a],c=r[a+1],l=o.a.mean(c.a),h=Bc(s.tt-o.tt,o.r,o.v,l),u=Hf(s.tt-o.tt,o.v,l),d=Bc(s.tt-c.tt,c.r,c.v,l),f=Hf(s.tt-c.tt,c.v,l),p=(s.tt-o.tt)/Or;t=h.mul(1-p).add(d.mul(p)),i=u.mul(1-p).add(f.mul(p))}else{let a;s.tt<Xs[0][0]?a=Gf(Xs[0],s.tt,-Or):a=Gf(Xs[Uu-1],s.tt,+Or),t=a.grav.r,i=a.grav.v,n=a.bary}return n||(n=new Qc(s.tt)),t=t.sub(n.Sun.r),i=i.sub(n.Sun.v),new bs(t.x,t.y,t.z,i.x,i.y,i.z,s)}function Es(s,e){var t=Lt(e);if(s in Dn)return Kr(Dn[s],t);if(s===Se.Pluto){const a=ug(t);return new St(a.x,a.y,a.z,t)}if(s===Se.Sun)return new St(0,0,0,t);if(s===Se.Moon){var i=Kr(Dn.Earth,t),n=ta(t);return new St(i.x+n.x,i.y+n.y,i.z+n.z,t)}if(s===Se.EMB){const a=Kr(Dn.Earth,t),o=ta(t),c=1+eg;return new St(a.x+o.x/c,a.y+o.y/c,a.z+o.z/c,t)}if(s===Se.SSB)return JS(t);const r=Sd(s);if(r){const a=new jc(r.dec,15*r.ra,r.dist);return Rd(a,t)}throw`HelioVector: Unknown body "${s}"`}function i5(s,e){let t=e,i=0;for(let n=0;n<10;++n){const r=s(t),a=r.Length()/_d;if(a>1)throw"Object is too distant for light-travel solver.";const o=e.AddDays(-a);if(i=Math.abs(o.tt-t.tt),i<1e-9)return r;t=o}throw`Light-travel time solver did not converge: dt = ${i}`}class n5{constructor(e,t,i,n){this.observerBody=e,this.targetBody=t,this.aberration=i,this.observerPos=n}Position(e){this.aberration&&(this.observerPos=Es(this.observerBody,e));const t=Es(this.targetBody,e);return new St(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function s5(s,e,t,i){kc(i);const n=Lt(s);if(Sd(t)){const o=Es(t,n);if(i){const l=a5(e,n),h=new St(o.x-l.x,o.y-l.y,o.z-l.z,n),u=_d/h.Length();return new St(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,n)}const c=Es(e,n);return new St(o.x-c.x,o.y-c.y,o.z-c.z,n)}let r;i?r=new St(0,0,0,n):r=Es(e,n);const a=new n5(e,t,i,r);return i5(o=>a.Position(o),n)}function zu(s,e,t){kc(t);const i=Lt(e);switch(s){case Se.Earth:return new St(0,0,0,i);case Se.Moon:return ta(i);default:const n=s5(i,Se.Earth,s,t);return n.t=i,n}}function r5(s,e){return new bs(s.r.x,s.r.y,s.r.z,s.v.x,s.v.y,s.v.z,e)}function a5(s,e){const t=Lt(e);switch(s){case Se.Sun:return new bs(0,0,0,0,0,0,t);case Se.SSB:const i=new Qc(t.tt);return new bs(-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 Se.Mercury:case Se.Venus:case Se.Earth:case Se.Mars:case Se.Jupiter:case Se.Saturn:case Se.Uranus:case Se.Neptune:const n=Ou(Dn[s],t.tt);return r5(n,t);case Se.Pluto:return ug(t);case Se.Moon:case Se.EMB:const r=Ou(Dn.Earth,t.tt),a=s==Se.Moon?og(t):ZS(t);return new bs(a.x+r.r.x,a.y+r.r.y,a.z+r.r.z,a.vx+r.v.x,a.vy+r.v.y,a.vz+r.v.z,t);default:if(Sd(s)){const o=Es(s,t);return new bs(o.x,o.y,o.z,0,0,0,t)}throw`HelioState: Unsupported body "${s}"`}}function o5(s){for(;s<0;)s+=360;for(;s>=360;)s-=360;return s}function c5(s,e,t){if(s===Se.Earth||e===Se.Earth)throw"The Earth does not have a longitude as seen from itself.";const i=Lt(t),n=zu(s,i,!1),r=Cu(n),a=zu(e,i,!1),o=Cu(a);return o5(r.elon-o.elon)}function l5(s,e,t,i){let n,r=0,a=0,o=0;switch(s){case Se.Mercury:n=-.6,r=4.98,a=-4.88,o=3.02;break;case Se.Venus:e<163.6?(n=-4.47,r=1.03,a=.57,o=.13):(n=.98,r=-1.02);break;case Se.Mars:n=-1.52,r=1.6;break;case Se.Jupiter:n=-9.4,r=.5;break;case Se.Uranus:n=-7.19,r=.25;break;case Se.Neptune:n=-6.87;break;case Se.Pluto:n=-1,r=4;break;default:throw`VisualMagnitude: unsupported body ${s}`}const c=e/100;let l=n+c*(r+c*(a+c*o));return l+=5*Math.log10(t*i),l}function h5(s,e,t,i,n){const r=Cu(i),a=ft*28.06,o=ft*(169.51+382e-7*n.tt),c=ft*r.elat,l=ft*r.elon,h=Math.asin(Math.sin(c)*Math.cos(a)-Math.cos(c)*Math.sin(a)*Math.sin(l-o)),u=Math.sin(Math.abs(h));let d=-9+.044*s;return d+=u*(-2.6+1.2*u),d+=5*Math.log10(e*t),{mag:d,ring_tilt:Pn*h}}function u5(s,e,t){let i=s*ft,n=i*i,r=n*n,a=-12.717+1.49*Math.abs(i)+.0431*r;const o=385000.6/zs;let c=t/o;return a+=5*Math.log10(e*c),a}class d5{constructor(e,t,i,n,r,a,o,c){this.time=e,this.mag=t,this.phase_angle=i,this.helio_dist=n,this.geo_dist=r,this.gc=a,this.hc=o,this.ring_tilt=c,this.phase_fraction=(1+Math.cos(ft*i))/2}}function dg(s,e){if(s===Se.Earth)throw"The illumination of the Earth is not defined.";const t=Lt(e),i=Kr(Dn.Earth,t);let n,r,a,o;s===Se.Sun?(a=new St(-i.x,-i.y,-i.z,t),r=new St(0,0,0,t),n=0):(s===Se.Moon?(a=ta(t),r=new St(i.x+a.x,i.y+a.y,i.z+a.z,t)):(r=Es(s,e),a=new St(r.x-i.x,r.y-i.y,r.z-i.z,t)),n=IS(a,r));let c=a.Length(),l=r.Length(),h;if(s===Se.Sun)o=RS+5*Math.log10(c);else if(s===Se.Moon)o=u5(n,l,c);else if(s===Se.Saturn){const u=h5(n,l,c,a,t);o=u.mag,h=u.ring_tilt}else o=l5(s,n,l,c);return new d5(t,o,n,l,c,a,r,h)}function f5(s){return c5(Se.Moon,Se.Sun,s)}var Vf;(function(s){s[s.Pericenter=0]="Pericenter",s[s.Apocenter=1]="Apocenter"})(Vf||(Vf={}));function fg(s,e){return new As([[e.rot[0][0]*s.rot[0][0]+e.rot[1][0]*s.rot[0][1]+e.rot[2][0]*s.rot[0][2],e.rot[0][1]*s.rot[0][0]+e.rot[1][1]*s.rot[0][1]+e.rot[2][1]*s.rot[0][2],e.rot[0][2]*s.rot[0][0]+e.rot[1][2]*s.rot[0][1]+e.rot[2][2]*s.rot[0][2]],[e.rot[0][0]*s.rot[1][0]+e.rot[1][0]*s.rot[1][1]+e.rot[2][0]*s.rot[1][2],e.rot[0][1]*s.rot[1][0]+e.rot[1][1]*s.rot[1][1]+e.rot[2][1]*s.rot[1][2],e.rot[0][2]*s.rot[1][0]+e.rot[1][2]*s.rot[1][1]+e.rot[2][2]*s.rot[1][2]],[e.rot[0][0]*s.rot[2][0]+e.rot[1][0]*s.rot[2][1]+e.rot[2][0]*s.rot[2][2],e.rot[0][1]*s.rot[2][0]+e.rot[1][1]*s.rot[2][1]+e.rot[2][1]*s.rot[2][2],e.rot[0][2]*s.rot[2][0]+e.rot[1][2]*s.rot[2][1]+e.rot[2][2]*s.rot[2][2]]])}function Rd(s,e){e=Lt(e);const t=s.lat*ft,i=s.lon*ft,n=s.dist*Math.cos(t);return new St(n*Math.cos(i),n*Math.sin(i),s.dist*Math.sin(t),e)}function Dd(s){const e=p5(s);return new Du(e.lon/15,e.lat,e.dist,s)}function p5(s){const e=s.x*s.x+s.y*s.y,t=Math.sqrt(e+s.z*s.z);let i,n;if(e===0){if(s.z===0)throw"Zero-length vector not allowed.";n=0,i=s.z<0?-90:90}else n=Pn*Math.atan2(s.y,s.x),n<0&&(n+=360),i=Pn*Math.atan2(s.z,Math.sqrt(e));return new jc(i,n,t)}function pg(s,e){let t;if(ai(e),e<-90||e>90)return 0;if(s==="normal"||s==="jplhor"){let i=e;i<-1&&(i=-1),t=1.02/Math.tan((i+10.3/(i+5.11))*ft)/60,s==="normal"&&e<-1&&(t*=(e+90)/89)}else if(!s)t=0;else throw`Invalid refraction option: ${s}`;return t}function $r(s,e){return new St(s.rot[0][0]*e.x+s.rot[1][0]*e.y+s.rot[2][0]*e.z,s.rot[0][1]*e.x+s.rot[1][1]*e.y+s.rot[2][1]*e.z,s.rot[0][2]*e.x+s.rot[1][2]*e.y+s.rot[2][2]*e.z,e.t)}function m5(){return new As([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function g5(){return new As([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function mg(s){s=Lt(s);const e=bd(s,fi.From2000),t=Ed(s,fi.From2000);return fg(e,t)}function v5(s){s=Lt(s);const e=Ed(s,fi.Into2000),t=bd(s,fi.Into2000);return fg(e,t)}function M5(s){const t=so(Lt(s)).tobl*ft,i=Math.cos(t),n=Math.sin(t);return new As([[1,0,0],[0,+i,+n],[0,-n,+i]])}var Wf;(function(s){s.Penumbral="penumbral",s.Partial="partial",s.Annular="annular",s.Total="total"})(Wf||(Wf={}));var Xf;(function(s){s[s.Invalid=0]="Invalid",s[s.Ascending=1]="Ascending",s[s.Descending=-1]="Descending"})(Xf||(Xf={}));const x5=["Venus","Mars","Jupiter","Saturn"];function gg(s){return new Td(s.lat,s.lng,s.elevationM)}function Cd(s,e,t,i,n=!0){const r=rg(t,gg(i),s,e,n?"normal":void 0);return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}class an{up;north;west;constructor(e,t){const i=Lt(e),n=Math.sin(t.lat*Gn),r=Math.cos(t.lat*Gn),a=Math.sin(t.lng*Gn),o=Math.cos(t.lng*Gn),c=-15*GS(i),l=v5(i);this.up=an.rotate(l,an.spin(c,[r*o,r*a,n]),i),this.north=an.rotate(l,an.spin(c,[-n*o,-n*a,r]),i),this.west=an.rotate(l,an.spin(c,[a,-o,0]),i)}static ofJ2000(e,t,i,n,r=!0){const a=Lt(i),o=Rd(new jc(t,e*15,1),a),c=Dd($r(mg(a),o));return Cd(c.ra,c.dec,i,n,r)}position(e,t){const i=Math.sin(t*Gn),n=Math.cos(t*Gn),r=Math.sin(e*Yf),a=Math.cos(e*Yf),o=n*a,c=n*r,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=-qf*Math.atan2(d,u),p<0&&(p+=360));let v=qf*Math.atan2(f,h);return v-=pg("normal",90-v),{altitudeDeg:90-v,azimuthDeg:p}}static spin(e,[t,i,n]){const r=Math.cos(e*Gn),a=Math.sin(e*Gn);return[r*t+a*i,r*i-a*t,n]}static rotate(e,[t,i,n],r){const a=$r(e,new St(t,i,n,r));return[a.x,a.y,a.z]}}const Gn=Math.PI/180,qf=180/Math.PI,Yf=15*Gn;function $l(s,e,t){const i=gg(t),n=KS(Se[s],e,i,!0,!0),r=rg(e,i,n.ra,n.dec,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function Zl(s,e){return dg(Se[s],e).mag}function _5(s){const e=f5(s),t=dg(Se.Moon,s);return{phaseFraction:e/360,illuminatedFraction:t.phase_fraction}}const y5=2e3,S5=3,b5=20;function Zo(s,e,t){if(s.year===void 0&&s.month===void 0&&s.day===void 0&&s.hour===void 0)return;const i=s.year!==void 0,n=s.year??y5,r=s.month??(i?1:S5),a=s.day??(i?1:b5),o=t??Math.round(e/15);return new Date(Date.UTC(n,r-1,a,(s.hour??12)-o,s.minute??0,s.second??0))}class _s{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static apply(e){e.transparent=!0,e.depthWrite=!1,e.onBeforeCompile=t=>{t.fragmentShader=_s.patch(t.fragmentShader)}}static patch(e){return e.replace(_s.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
|
|
5304
5304
|
// Outside the inscribed circle there is no star at all — this is what kills the corners.
|
|
5305
5305
|
if ( distanceFromCentre > ${_s.RIM.toFixed(2)} ) discard;
|
|
5306
5306
|
float glare = 1.0 - smoothstep( ${_s.CORE.toFixed(2)}, ${_s.RIM.toFixed(2)}, distanceFromCentre );
|
|
5307
|
-
vec4 diffuseColor = vec4( diffuse, opacity * glare );`)}}const w5=[{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}],Pa=64,Qt=Pa+1,Kf=512,E5=900,A5=700/900,T5=0,R5=.01;function D5(s,e,t){return{north:qn(0,-t,s,e).lat,south:qn(0,t,s,e).lat,east:qn(t,0,s,e).lng,west:qn(-t,0,s,e).lng}}async function C5(s,e,t,i=E5){const n=i,r=i*A5,a=D5(s,e,n),o={width:Qt,height:Qt},[c,l]=await Promise.all([t.elevation.getElevationGrid(a,o),t.imagery.getImageryTexture(a,{width:Kf,height:Kf})]),h=Math.floor(Qt/2),u=c.heights[h*Qt+h],d=new Float32Array(Qt*Qt*3),f=new Float32Array(Qt*Qt*2),p=new Float32Array(Qt*Qt*4);for(let w=0;w<Qt;w++){const E=w/(Qt-1),R=a.north+(a.south-a.north)*E;for(let x=0;x<Qt;x++){const A=x/(Qt-1),I=a.west+(a.east-a.west)*A,{x:C,z:P}=hi(R,I,s,e),X=c.heights[w*Qt+x],z=Math.max(Math.abs(C),Math.abs(P)),N=1-I5((z-r)/(n-r),0,1),V=T5+R5+(X-u),k=w*Qt+x;d[k*3]=C,d[k*3+1]=V,d[k*3+2]=P;const K=im(l.bounds,I,R);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(Pa*Pa*6);let m=0;for(let w=0;w<Pa;w++)for(let E=0;E<Pa;E++){const R=w*Qt+E,x=R+1,A=R+Qt,I=A+1;v[m++]=R,v[m++]=A,v[m++]=x,v[m++]=x,v[m++]=A,v[m++]=I}const g=new bt;g.setAttribute("position",new ot(d,3)),g.setAttribute("uv",new ot(f,2)),g.setAttribute("color",new ot(p,4)),g.setIndex(new ot(v,1)),g.computeVertexNormals();const b=new Ln(l.source);b.flipY=!1;const y=new eo({map:b,color:new oe(1,1,1),vertexColors:!0,transparent:!0,fog:!0}),_=new We(g,y);return _.receiveShadow=!0,_.castShadow=!0,{mesh:_,attribution:t.imagery.attribution,originElevationM:Number.isFinite(u)?u:void 0}}function I5(s,e,t){return Math.max(e,Math.min(t,s))}const P5=18,L5=.55,N5=.5,O5=`
|
|
5307
|
+
vec4 diffuseColor = vec4( diffuse, opacity * glare );`)}}const E5=[{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}],Pa=64,Qt=Pa+1,Kf=512,w5=900,A5=700/900,T5=0,R5=.01;function D5(s,e,t){return{north:qn(0,-t,s,e).lat,south:qn(0,t,s,e).lat,east:qn(t,0,s,e).lng,west:qn(-t,0,s,e).lng}}async function C5(s,e,t,i=w5){const n=i,r=i*A5,a=D5(s,e,n),o={width:Qt,height:Qt},[c,l]=await Promise.all([t.elevation.getElevationGrid(a,o),t.imagery.getImageryTexture(a,{width:Kf,height:Kf})]),h=Math.floor(Qt/2),u=c.heights[h*Qt+h],d=new Float32Array(Qt*Qt*3),f=new Float32Array(Qt*Qt*2),p=new Float32Array(Qt*Qt*4);for(let E=0;E<Qt;E++){const w=E/(Qt-1),R=a.north+(a.south-a.north)*w;for(let x=0;x<Qt;x++){const A=x/(Qt-1),I=a.west+(a.east-a.west)*A,{x:C,z:P}=hi(R,I,s,e),X=c.heights[E*Qt+x],z=Math.max(Math.abs(C),Math.abs(P)),N=1-I5((z-r)/(n-r),0,1),V=T5+R5+(X-u),k=E*Qt+x;d[k*3]=C,d[k*3+1]=V,d[k*3+2]=P;const K=im(l.bounds,I,R);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(Pa*Pa*6);let m=0;for(let E=0;E<Pa;E++)for(let w=0;w<Pa;w++){const R=E*Qt+w,x=R+1,A=R+Qt,I=A+1;v[m++]=R,v[m++]=A,v[m++]=x,v[m++]=x,v[m++]=A,v[m++]=I}const g=new bt;g.setAttribute("position",new ot(d,3)),g.setAttribute("uv",new ot(f,2)),g.setAttribute("color",new ot(p,4)),g.setIndex(new ot(v,1)),g.computeVertexNormals();const b=new Ln(l.source);b.flipY=!1;const y=new eo({map:b,color:new oe(1,1,1),vertexColors:!0,transparent:!0,fog:!0}),_=new We(g,y);return _.receiveShadow=!0,_.castShadow=!0,{mesh:_,attribution:t.imagery.attribution,originElevationM:Number.isFinite(u)?u:void 0}}function I5(s,e,t){return Math.max(e,Math.min(t,s))}const P5=18,L5=.55,N5=.5,O5=`
|
|
5308
5308
|
attribute float aSpeed;
|
|
5309
5309
|
uniform float uTime;
|
|
5310
5310
|
uniform float uOverallSpeed;
|
|
@@ -5404,7 +5404,7 @@ void main() {
|
|
|
5404
5404
|
float blur = max(vNearBlur, vHaze);
|
|
5405
5405
|
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${N5.toFixed(2)}));
|
|
5406
5406
|
}
|
|
5407
|
-
`;function F5(s){let e=s;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 k5=.14,$f=4.5;let Jo;function z5(){if(Jo)return Jo;const s=128,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),i=t.createImageData(s,s),n=s/2,r=s*k5,a=s-r;for(let o=0;o<s;o++)for(let c=0;c<s;c++){const l=c+.5-n,h=o+.5<r?o+.5-r:o+.5>a?o+.5-a:0,u=Math.hypot(l,h),d=Math.exp(-(u*u)/(2*$f*$f)),f=(o*s+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),Jo=new Ln(e),Jo}function B5(s){const e=F5(s.seed),t=new Float32Array(s.count*3),i=new Float32Array(s.count),n=s.radiusM;for(let l=0;l<s.count;l++){const h=e()*Math.PI*2,u=Math.sqrt(e())*s.radiusM;t[l*3]=Math.cos(h)*u,t[l*3+1]=e()*s.heightM,t[l*3+2]=Math.sin(h)*u,i[l]=.85+e()*.3}const r=new bt;r.setAttribute("position",new ot(t,3)),r.setAttribute("aSpeed",new ot(i,1)),r.setDrawRange(0,s.visibleCount);const a={uTime:{value:0},uOverallSpeed:{value:s.overallSpeed},uPixelSize:{value:s.pixelSize},uOpacity:{value:s.opacity},uColor:{value:s.color},uUvSquash:{value:1},uSpeedStreak:{value:s.speedStreak},uWindOffset:{value:new Ae(0,0)},uDropVelocity:{value:new D(0,-1,0)},uAspect:{value:1},uHeight:{value:s.heightM},uBottomY:{value:s.bottomYM},uHalfWidth:{value:n},uTexture:{value:z5()},uNearFocusDistance:{value:s.nearFocusDistanceM},uHazeDistance:{value:s.hazeDistanceM},uHazeColor:{value:s.hazeColor}},o=new
|
|
5407
|
+
`;function F5(s){let e=s;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 k5=.14,$f=4.5;let Jo;function z5(){if(Jo)return Jo;const s=128,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),i=t.createImageData(s,s),n=s/2,r=s*k5,a=s-r;for(let o=0;o<s;o++)for(let c=0;c<s;c++){const l=c+.5-n,h=o+.5<r?o+.5-r:o+.5>a?o+.5-a:0,u=Math.hypot(l,h),d=Math.exp(-(u*u)/(2*$f*$f)),f=(o*s+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),Jo=new Ln(e),Jo}function B5(s){const e=F5(s.seed),t=new Float32Array(s.count*3),i=new Float32Array(s.count),n=s.radiusM;for(let l=0;l<s.count;l++){const h=e()*Math.PI*2,u=Math.sqrt(e())*s.radiusM;t[l*3]=Math.cos(h)*u,t[l*3+1]=e()*s.heightM,t[l*3+2]=Math.sin(h)*u,i[l]=.85+e()*.3}const r=new bt;r.setAttribute("position",new ot(t,3)),r.setAttribute("aSpeed",new ot(i,1)),r.setDrawRange(0,s.visibleCount);const a={uTime:{value:0},uOverallSpeed:{value:s.overallSpeed},uPixelSize:{value:s.pixelSize},uOpacity:{value:s.opacity},uColor:{value:s.color},uUvSquash:{value:1},uSpeedStreak:{value:s.speedStreak},uWindOffset:{value:new Ae(0,0)},uDropVelocity:{value:new D(0,-1,0)},uAspect:{value:1},uHeight:{value:s.heightM},uBottomY:{value:s.bottomYM},uHalfWidth:{value:n},uTexture:{value:z5()},uNearFocusDistance:{value:s.nearFocusDistanceM},uHazeDistance:{value:s.hazeDistanceM},uHazeColor:{value:s.hazeColor}},o=new Et({uniforms:a,vertexShader:O5,fragmentShader:U5,transparent:!0,depthWrite:!1,depthTest:!0}),c=new Fa(r,o);return c.frustumCulled=!1,{points:c,uniforms:a}}class Qs{static S10_MAG_PER_ARCSEC2=10+2.5*Math.log10(3600*3600);static toMagPerArcsec2(e){return Qs.S10_MAG_PER_ARCSEC2-2.5*Math.log10(Math.max(e,1e-12))}static fromMagPerArcsec2(e){return 10**(.4*(Qs.S10_MAG_PER_ARCSEC2-e))}static latitudeOfRowCoord(e){const t=2*e-1;return 90*Math.sign(t)*t*t}static rowCoordOfLatitude(e){return(Math.sign(e)*Math.sqrt(Math.min(Math.abs(e),90)/90)+1)/2}static angleOfColumnCoord(e){return 180*e*e}static columnCoordOfAngle(e){return Math.sqrt(Math.min(Math.max(e,0),180)/180)}}class Qe{static LONGITUDE_STEPS=256;static LATITUDE_STEPS=128;static SUN_RADIUS_KPC=8.2;static SUN_HEIGHT_KPC=.02;static DISK_SCALE_LENGTH_KPC=2.6;static DISK_SCALE_HEIGHT_KPC=.3;static BULGE_SCALE_KPC=.5;static BULGE_FLATTENING=.6;static BULGE_TO_LOCAL_DISK=20;static DUST_SCALE_LENGTH_KPC=3.5;static DUST_SCALE_HEIGHT_KPC=.1;static EXTINCTION_MAG_PER_KPC=.8;static NEAR_LIMIT_KPC=.01;static FAR_LIMIT_KPC=40;static STEPS=192;static OPAQUE_MAG=15;static PEAK_MAG_PER_ARCSEC2=21;static PEAK_RADIANCE=6.278;static PEAK_LONGITUDE_DEG=0;static PEAK_LATITUDE_DEG=4.5;surfaceBrightnessS10(e,t){return this.radianceTowards(e,t)*Qe.anchor()}static anchor(){return Qs.fromMagPerArcsec2(Qe.PEAK_MAG_PER_ARCSEC2)/Qe.PEAK_RADIANCE}radianceTowards(e,t){return this.trace(e,t).light}extinctionTowards(e,t){return this.trace(e,t).extinctionMag}trace(e,t){const i=e*Math.PI/180,n=t*Math.PI/180,r=-Math.cos(n)*Math.cos(i),a=Math.cos(n)*Math.sin(i),o=Math.sin(n);let c=0,l=0,h=0;const u=Math.log(Qe.NEAR_LIMIT_KPC),d=Math.log(Qe.FAR_LIMIT_KPC)-u;for(let f=0;f<Qe.STEPS;f++){const p=Math.exp(u+d*f/(Qe.STEPS-1)),v=p-h;h=p;const m=p-v/2,g=Qe.SUN_RADIUS_KPC+m*r,b=m*a,y=Qe.SUN_HEIGHT_KPC+m*o,_=Math.hypot(g,b),E=Math.exp(-(_-Qe.SUN_RADIUS_KPC)/Qe.DISK_SCALE_LENGTH_KPC-Math.abs(y)/Qe.DISK_SCALE_HEIGHT_KPC),w=Math.hypot(_,y/Qe.BULGE_FLATTENING),R=Qe.BULGE_TO_LOCAL_DISK*Math.exp(-w/Qe.BULGE_SCALE_KPC);if(c+=(E+R)*v*10**(-.4*l),l+=Qe.EXTINCTION_MAG_PER_KPC*Math.exp(-(_-Qe.SUN_RADIUS_KPC)/Qe.DUST_SCALE_LENGTH_KPC-(Math.abs(y)-Qe.SUN_HEIGHT_KPC)/Qe.DUST_SCALE_HEIGHT_KPC)*v,l>Qe.OPAQUE_MAG)break}return{light:c,extinctionMag:l}}values=new Float32Array(Qe.LONGITUDE_STEPS*Qe.LATITUDE_STEPS);walked=0;get done(){return this.walked>=Qe.LATITUDE_STEPS}walk(e){const t=Qe.LONGITUDE_STEPS,i=Math.min(Qe.LATITUDE_STEPS,this.walked+e);for(;this.walked<i;this.walked++){const n=Qs.latitudeOfRowCoord((this.walked+.5)/Qe.LATITUDE_STEPS);for(let r=0;r<t;r++)this.values[this.walked*t+r]=this.radianceTowards(360*(r+.5)/t,n)}}harvest(){let e=Number.POSITIVE_INFINITY;for(const n of this.values)n<e&&(e=n);const t=Qe.anchor(),i=new Float32Array(this.values.length);for(let n=0;n<i.length;n++)i[n]=(this.values[n]-e)*t;return{width:Qe.LONGITUDE_STEPS,height:Qe.LATITUDE_STEPS,data:i}}}class Ct{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=Ct.RIGHT_ANGLE_S10/this.radianceTowards(90,0)),this.anchored}radianceTowards(e,t){const i=e*Math.PI/180,n=t*Math.PI/180,r=-Math.cos(n)*Math.cos(i),a=-Math.cos(n)*Math.sin(i),o=Math.sin(n),c=-r;let l=0,h=0;const u=Math.log(Ct.NEAR_LIMIT_AU),d=Math.log(Ct.FAR_LIMIT_AU)-u;for(let f=0;f<Ct.STEPS;f++){const p=Math.exp(u+d*f/(Ct.STEPS-1)),v=p-h;h=p;const m=p-v/2,g=1+m*r,b=m*a,y=m*o,_=Math.hypot(g,b,y);if(_<Ct.SUBLIMATION_AU)continue;const E=y/_,w=_**-1.3*Math.exp(-2.6*Math.abs(E)),R=(c-m)/_;l+=w*this.scattering(R)*v/(_*_)}return l}scattering(e){let t=0;for(let i=0;i<Ct.LOBE_ASYMMETRY.length;i++){const n=Ct.LOBE_ASYMMETRY[i],r=1+n*n-2*n*e;t+=Ct.LOBE_WEIGHT[i]*(1-n*n)/(4*Math.PI*r**1.5)}return t}values=new Float32Array(Ct.LONGITUDE_STEPS*Ct.LATITUDE_STEPS);walked=0;get done(){return this.walked>=Ct.LATITUDE_STEPS}walk(e){const t=Ct.LONGITUDE_STEPS,i=Math.min(Ct.LATITUDE_STEPS,this.walked+e);for(;this.walked<i;this.walked++){const n=Qs.latitudeOfRowCoord((this.walked+.5)/Ct.LATITUDE_STEPS);for(let r=0;r<t;r++){const a=Qs.angleOfColumnCoord((r+.5)/t);this.values[this.walked*t+r]=this.radianceTowards(a,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:Ct.LONGITUDE_STEPS,height:Ct.LATITUDE_STEPS,data:i}}}class Ve{static get NANOLAMBERTS_PER_S10(){return Ve.toNanolamberts(10+2.5*Math.log10(3600*3600))}static nanolambertsOfS10(e){return e*Ve.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:Ve.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=Ve.TWILIGHT;for(let i=0;i<t.length-1;i++){const n=t[i],r=t[i+1];if(e<=n.sunAltitudeDeg&&e>=r.sunAltitudeDeg){const a=(n.sunAltitudeDeg-e)/(n.sunAltitudeDeg-r.sunAltitudeDeg);return n.magPerArcsec2+(r.magPerArcsec2-n.magPerArcsec2)*a}}return e>0?t[0].magPerArcsec2:t[t.length-1].magPerArcsec2}static toNanolamberts(e){return 34.08*Math.exp(Ve.NANOLAMBERT_OFFSET-Ve.PER_MAGNITUDE*e)}static fromNanolamberts(e){return(Ve.NANOLAMBERT_OFFSET-Math.log(Math.max(e,1e-6)/34.08))/Ve.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*Ve.EXTINCTION_PER_AIR_MASS*Ve.airMass(e))}static AIRGLOW_MAG_PER_ARCSEC2=22;static twilightExcessNanolamberts(e){return Math.max(0,Ve.toNanolamberts(Ve.moonlessMagPerArcsec2(e))-Ve.toNanolamberts(Ve.AIRGLOW_MAG_PER_ARCSEC2))}static twilightOutput(e){const t=Ve.scatteringAt(90-e)*Ve.scatteredFraction(90);return Ve.twilightExcessNanolamberts(e)/t}static moonNanolamberts(e,t,i,n){return Ve.scatteringAt(i)*Ve.moonOutput(e,t)*Ve.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*Ve.EXTINCTION_PER_AIR_MASS*Ve.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=Ve.scatteredFraction(i),r=Ve.scatteringAt(e.separationDeg)*Ve.twilightOutput(e.altitudeDeg)*n,a=Ve.scatteringAt(t.separationDeg)*Ve.moonOutput(t.phaseAngleDeg,t.altitudeDeg)*n;return Ve.fromNanolamberts(Ve.toNanolamberts(Ve.AIRGLOW_MAG_PER_ARCSEC2)+r+a)}}class gs{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=Bs.shared;milkyWayTexture;zodiacalTexture;milkyWayTexels;zodiacalTexels;repaint;constructor(){this.milkyWayTexels=this.maps.milkyWayTexels,this.milkyWayTexture=gs.buildTexture(this.milkyWayTexels,Qe.LONGITUDE_STEPS,Qe.LATITUDE_STEPS,qa),this.zodiacalTexels=this.maps.zodiacalTexels,this.zodiacalTexture=gs.buildTexture(this.zodiacalTexels,Ct.LONGITUDE_STEPS,Ct.LATITUDE_STEPS,Ai),this.material=new Et({uniforms:{uMilkyWay:{value:this.milkyWayTexture},uZodiacal:{value:this.zodiacalTexture},uGalactic:{value:new He},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:Ve.toNanolamberts(Ve.AIRGLOW_MAG_PER_ARCSEC2)},uSkyColor:{value:new D(0,0,0)},uMilkyWayTint:{value:new D(...gs.MILKY_WAY_TINT)},uZodiacalTint:{value:new D(...gs.ZODIACAL_TINT)},uReady:{value:this.maps.done?1:0},uEncodeDestination:{value:1}},vertexShader:`
|
|
5408
5408
|
varying vec3 vDirection;
|
|
5409
5409
|
void main() {
|
|
5410
5410
|
vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
|
|
@@ -5519,7 +5519,7 @@ void main() {
|
|
|
5519
5519
|
vec3 onEncoded = encodeSrgb(uSkyColor + light) - encodeSrgb(uSkyColor);
|
|
5520
5520
|
gl_FragColor = vec4(mix(light, onEncoded, uEncodeDestination), 1.0);
|
|
5521
5521
|
}
|
|
5522
|
-
`,transparent:!0,blending:
|
|
5522
|
+
`,transparent:!0,blending:Gi,depthWrite:!1,side:It,fog:!1}),this.object=new We(new di(gs.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}static buildTexture(e,t,i,n){const r=new tr(e,t,i,xi,$t);return r.minFilter=at,r.magFilter=at,r.wrapS=n,r.wrapT=Ai,r.needsUpdate=!0,r}set onReady(e){this.repaint=e}update(e){if(Ve.moonlessMagPerArcsec2(e.sunAltitudeDeg)<gs.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=Ve.moonOutput(e.moon.phaseAngleDeg,e.moon.altitudeDeg),i.uTwilightOutput.value=Ve.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 Bs{static instance;static get shared(){return Bs.instance??=new Bs}static WORK_BUDGET_MS=6;milkyWayTexels=new Uint16Array(Qe.LONGITUDE_STEPS*Qe.LATITUDE_STEPS*4);zodiacalTexels=new Uint16Array(Ct.LONGITUDE_STEPS*Ct.LATITUDE_STEPS*4);galaxy=new Qe;dust=new Ct;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()+Bs.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(){Bs.fill(this.milkyWayTexels,this.galaxy.harvest()),Bs.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]=Zn.toHalfFloat(Ve.nanolambertsOfS10(t.data[i])),e[i*4+3]=Zn.toHalfFloat(1)}}class nn{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:nn.at(nn.GALACTIC_CENTRE,e,t),rotation:nn.at(nn.GALACTIC_ROTATION,e,t),pole:nn.at(nn.GALACTIC_POLE,e,t)}}static eclipticPole(e,t){return nn.at(nn.ECLIPTIC_POLE,e,t)}static at(e,t,i){return an.ofJ2000(e.raHours,e.decDeg,t,i,!1)}}const H5=`
|
|
5523
5523
|
varying vec2 vUv;
|
|
5524
5524
|
void main() {
|
|
5525
5525
|
vUv = uv;
|
|
@@ -5963,7 +5963,7 @@ void main()
|
|
|
5963
5963
|
// stays what it always was for the optional artifacts.
|
|
5964
5964
|
gl_FragColor = vec4(dazzle + artifactsContribution * uOpacity, 1.0);
|
|
5965
5965
|
}
|
|
5966
|
-
`;let jo;function V5(){if(jo)return jo;const s=256,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d");t.fillStyle="rgba(60,60,60,1)",t.fillRect(0,0,s,s);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,r,a,o]of i){const c=t.createRadialGradient(n*s,r*s,0,n*s,r*s,a*s);c.addColorStop(0,`rgba(200,200,200,${o})`),c.addColorStop(1,"rgba(200,200,200,0)"),t.fillStyle=c,t.fillRect(0,0,s,s)}return jo=new Ln(e),jo}function W5(){const s={uTime:{value:0},uResolution:{value:new Ae(1,1)},uLensPosition:{value:new Ae(0,0)},uColorGain:{value:new oe(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 oe(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:V5()}},e=new
|
|
5966
|
+
`;let jo;function V5(){if(jo)return jo;const s=256,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d");t.fillStyle="rgba(60,60,60,1)",t.fillRect(0,0,s,s);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,r,a,o]of i){const c=t.createRadialGradient(n*s,r*s,0,n*s,r*s,a*s);c.addColorStop(0,`rgba(200,200,200,${o})`),c.addColorStop(1,"rgba(200,200,200,0)"),t.fillStyle=c,t.fillRect(0,0,s,s)}return jo=new Ln(e),jo}function W5(){const s={uTime:{value:0},uResolution:{value:new Ae(1,1)},uLensPosition:{value:new Ae(0,0)},uColorGain:{value:new oe(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 oe(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:V5()}},e=new Et({uniforms:s,vertexShader:H5,fragmentShader:G5,transparent:!0,depthWrite:!1,depthTest:!1,blending:Gi,fog:!1,name:"LensFlareShader"}),t=new We(new dn(2,2),e);return t.frustumCulled=!1,t.renderOrder=20,{mesh:t,uniforms:s}}class Wn{static MAX_HALF_ANGLE_DEG=80;static MAX_CUBE_FACE=2048;cubeTarget;cubeCamera;cubeMaterial;cubeRotation=new He;target;quadScene=new Qr;quadCamera=new Ts(-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 ui(this.width,this.height,{type:$t}),this.material=new Et({uniforms:{uSource:{value:this.target.texture},uHalfFovRad:{value:.5236},uAspect:{value:this.width/this.height},uSrcTanHalfFovY:{value:1},uResolution:{value:new Ae(this.width,this.height)},uEncodeOutput:{value:1}},vertexShader:`
|
|
5967
5967
|
varying vec2 vNdc;
|
|
5968
5968
|
void main() {
|
|
5969
5969
|
vNdc = position.xy;
|
|
@@ -6003,7 +6003,7 @@ void main()
|
|
|
6003
6003
|
vec3 colour = texture2D(uSource, src * 0.5 + 0.5).rgb;
|
|
6004
6004
|
gl_FragColor = vec4(uEncodeOutput > 0.5 ? encodeSrgb(colour) : colour, 1.0);
|
|
6005
6005
|
}
|
|
6006
|
-
`,depthTest:!1,depthWrite:!1}),this.quadScene.add(new We(new dn(2,2),this.material))}directionFor(e,t,i){const n=this.width/this.height,r=i/2*Math.PI/180,a=e*n*r,o=t*r,c=Math.hypot(a,o);if(c<1e-6)return{x:0,y:0,z:-1};const l=Math.sin(c);return{x:a/c*l,y:o/c*l,z:-Math.cos(c)}}static ndcFor(e,t,i){const n=Math.hypot(e.x,e.y,e.z);if(n===0||e.z>=n)return;const r=t/2*Math.PI/180,a=Math.acos(Math.min(1,-e.z/n)),o=Math.sin(a),c=o<1e-9?1:a/o,l=e.x/n*c,h=e.y/n*c;return{ndcX:l/(i*r),ndcY:h/r}}static cornerHalfAngleDeg(e,t){return e/2*Math.hypot(t,1)}static supports(e,t){return this.cornerHalfAngleDeg(e,t)<=this.MAX_HALF_ANGLE_DEG}setEncodesOutput(e){this.material.uniforms.uEncodeOutput.value=e?1:0}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height),this.material.uniforms.uAspect.value=this.width/this.height}render(e,t,i,n,r,a,o,c){const l=this.width/this.height;if(!Wn.supports(n,l)){o?.(!0),this.renderThroughCube(e,t,i,n,a,c),o?.(!1);return}this.material.uniforms.uHalfFovRad.value=n/2*Math.PI/180,this.material.uniforms.uSrcTanHalfFovY.value=this.sourceTanHalfFovY(n,l);const h=i.fov;i.fov=this.sourceFovDeg(n,l),i.updateProjectionMatrix(),r?.();const u=e.getRenderTarget();e.setRenderTarget(this.target),e.render(t,i),a?.(i),e.setRenderTarget(u),i.fov=h,i.updateProjectionMatrix(),e.render(this.quadScene,this.quadCamera)}renderThroughCube(e,t,i,n,r,a){const o=n*Math.PI/180,c=Math.min(Wn.MAX_CUBE_FACE,e.capabilities.maxCubemapSize,Math.max(256,Math.ceil(this.height/o*Math.PI/2)));!this.cubeTarget||!this.cubeCamera||!this.cubeMaterial?(this.cubeTarget=new gd(c,{type:$t,minFilter:at,magFilter:at,generateMipmaps:!1}),this.cubeCamera=new Fm(i.near,i.far,this.cubeTarget),this.cubeMaterial=this.buildCubeMaterial(this.cubeTarget)):this.cubeTarget.width!==c&&this.cubeTarget.setSize(c,c);const l=this.cubeCamera;i.updateMatrixWorld(),l.position.setFromMatrixPosition(i.matrixWorld),l.updateMatrixWorld(),l.coordinateSystem!==e.coordinateSystem&&(l.coordinateSystem=e.coordinateSystem,l.updateCoordinateSystem());const h=e.getRenderTarget(),u=e.shadowMap.autoUpdate,d=this.forwardScratch.set(0,0,-1).applyQuaternion(i.getWorldQuaternion(this.quaternionScratch)),f=Wn.cornerHalfAngleDeg(n,this.width/this.height);l.children.forEach((g,b)=>{const y=g;Wn.faceSeen(y,d,f)&&((y.near!==i.near||y.far!==i.far)&&(y.near=i.near,y.far=i.far,y.updateProjectionMatrix()),e.setRenderTarget(this.cubeTarget,b),e.render(t,y),r?.(y),e.shadowMap.autoUpdate=!1)}),e.shadowMap.autoUpdate=u,e.setRenderTarget(h);const p=this.cubeMaterial.uniforms;p.uHalfFovRad.value=o/2,p.uAspect.value=this.width/this.height,p.uCameraRotation.value.setFromMatrix4(i.matrixWorld);const v=this.quadScene.children[0];p.uEncodeOutput.value=0,e.setRenderTarget(this.target),v.material=this.cubeMaterial,e.render(this.quadScene,this.quadCamera),a?.(),e.setRenderTarget(h);const m=this.copyMaterial();m.uniforms.uEncodeOutput.value=this.material.uniforms.uEncodeOutput.value,v.material=m,e.render(this.quadScene,this.quadCamera),v.material=this.material}copy;copyMaterial(){return this.copy??=new
|
|
6006
|
+
`,depthTest:!1,depthWrite:!1}),this.quadScene.add(new We(new dn(2,2),this.material))}directionFor(e,t,i){const n=this.width/this.height,r=i/2*Math.PI/180,a=e*n*r,o=t*r,c=Math.hypot(a,o);if(c<1e-6)return{x:0,y:0,z:-1};const l=Math.sin(c);return{x:a/c*l,y:o/c*l,z:-Math.cos(c)}}static ndcFor(e,t,i){const n=Math.hypot(e.x,e.y,e.z);if(n===0||e.z>=n)return;const r=t/2*Math.PI/180,a=Math.acos(Math.min(1,-e.z/n)),o=Math.sin(a),c=o<1e-9?1:a/o,l=e.x/n*c,h=e.y/n*c;return{ndcX:l/(i*r),ndcY:h/r}}static cornerHalfAngleDeg(e,t){return e/2*Math.hypot(t,1)}static supports(e,t){return this.cornerHalfAngleDeg(e,t)<=this.MAX_HALF_ANGLE_DEG}setEncodesOutput(e){this.material.uniforms.uEncodeOutput.value=e?1:0}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height),this.material.uniforms.uAspect.value=this.width/this.height}render(e,t,i,n,r,a,o,c){const l=this.width/this.height;if(!Wn.supports(n,l)){o?.(!0),this.renderThroughCube(e,t,i,n,a,c),o?.(!1);return}this.material.uniforms.uHalfFovRad.value=n/2*Math.PI/180,this.material.uniforms.uSrcTanHalfFovY.value=this.sourceTanHalfFovY(n,l);const h=i.fov;i.fov=this.sourceFovDeg(n,l),i.updateProjectionMatrix(),r?.();const u=e.getRenderTarget();e.setRenderTarget(this.target),e.render(t,i),a?.(i),e.setRenderTarget(u),i.fov=h,i.updateProjectionMatrix(),e.render(this.quadScene,this.quadCamera)}renderThroughCube(e,t,i,n,r,a){const o=n*Math.PI/180,c=Math.min(Wn.MAX_CUBE_FACE,e.capabilities.maxCubemapSize,Math.max(256,Math.ceil(this.height/o*Math.PI/2)));!this.cubeTarget||!this.cubeCamera||!this.cubeMaterial?(this.cubeTarget=new gd(c,{type:$t,minFilter:at,magFilter:at,generateMipmaps:!1}),this.cubeCamera=new Fm(i.near,i.far,this.cubeTarget),this.cubeMaterial=this.buildCubeMaterial(this.cubeTarget)):this.cubeTarget.width!==c&&this.cubeTarget.setSize(c,c);const l=this.cubeCamera;i.updateMatrixWorld(),l.position.setFromMatrixPosition(i.matrixWorld),l.updateMatrixWorld(),l.coordinateSystem!==e.coordinateSystem&&(l.coordinateSystem=e.coordinateSystem,l.updateCoordinateSystem());const h=e.getRenderTarget(),u=e.shadowMap.autoUpdate,d=this.forwardScratch.set(0,0,-1).applyQuaternion(i.getWorldQuaternion(this.quaternionScratch)),f=Wn.cornerHalfAngleDeg(n,this.width/this.height);l.children.forEach((g,b)=>{const y=g;Wn.faceSeen(y,d,f)&&((y.near!==i.near||y.far!==i.far)&&(y.near=i.near,y.far=i.far,y.updateProjectionMatrix()),e.setRenderTarget(this.cubeTarget,b),e.render(t,y),r?.(y),e.shadowMap.autoUpdate=!1)}),e.shadowMap.autoUpdate=u,e.setRenderTarget(h);const p=this.cubeMaterial.uniforms;p.uHalfFovRad.value=o/2,p.uAspect.value=this.width/this.height,p.uCameraRotation.value.setFromMatrix4(i.matrixWorld);const v=this.quadScene.children[0];p.uEncodeOutput.value=0,e.setRenderTarget(this.target),v.material=this.cubeMaterial,e.render(this.quadScene,this.quadCamera),a?.(),e.setRenderTarget(h);const m=this.copyMaterial();m.uniforms.uEncodeOutput.value=this.material.uniforms.uEncodeOutput.value,v.material=m,e.render(this.quadScene,this.quadCamera),v.material=this.material}copy;copyMaterial(){return this.copy??=new Et({uniforms:{uSource:{value:this.target.texture},uEncodeOutput:{value:1}},vertexShader:`
|
|
6007
6007
|
varying vec2 vUv;
|
|
6008
6008
|
void main() {
|
|
6009
6009
|
vUv = position.xy * 0.5 + 0.5;
|
|
@@ -6019,7 +6019,7 @@ void main()
|
|
|
6019
6019
|
vec3 colour = texture2D(uSource, vUv).rgb;
|
|
6020
6020
|
gl_FragColor = vec4(uEncodeOutput > 0.5 ? encodeSrgb(colour) : colour, 1.0);
|
|
6021
6021
|
}
|
|
6022
|
-
`,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),r=Wn.faceScratch;for(let a=0;a<=4;a++)for(let o=0;o<=4;o++)if(r.set(-1+a/2,-1+o/2,-1).normalize().transformDirection(e.matrixWorld),r.dot(t)>=n)return!0;return!1}static faceScratch=new D;buildCubeMaterial(e){return new
|
|
6022
|
+
`,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),r=Wn.faceScratch;for(let a=0;a<=4;a++)for(let o=0;o<=4;o++)if(r.set(-1+a/2,-1+o/2,-1).normalize().transformDirection(e.matrixWorld),r.dot(t)>=n)return!0;return!1}static faceScratch=new D;buildCubeMaterial(e){return new Et({uniforms:{uCube:{value:e.texture},uHalfFovRad:{value:.5236},uAspect:{value:1},uCameraRotation:{value:this.cubeRotation},uEncodeOutput:{value:1}},vertexShader:`
|
|
6023
6023
|
varying vec2 vNdc;
|
|
6024
6024
|
void main() {
|
|
6025
6025
|
vNdc = position.xy;
|
|
@@ -6049,7 +6049,7 @@ void main()
|
|
|
6049
6049
|
vec3 colour = textureCube(uCube, uCameraRotation * dir).rgb;
|
|
6050
6050
|
gl_FragColor = vec4(uEncodeOutput > 0.5 ? encodeSrgb(colour) : colour, 1.0);
|
|
6051
6051
|
}
|
|
6052
|
-
`,depthTest:!1,depthWrite:!1})}sourceFovDeg(e,t){return Math.atan(this.sourceTanHalfFovY(e,t))*360/Math.PI}sourceTanHalfFovY(e,t){const i=Wn.cornerHalfAngleDeg(e,t)*Math.PI/180;return Math.tan(i)/Math.hypot(t,1)}dispose(){this.target.dispose(),this.material.dispose(),this.cubeTarget?.dispose(),this.cubeMaterial?.dispose(),this.copy?.dispose(),this.quadScene.clear()}}class ka{static MAX_RADIUS_PX=24;static TAPS=32;target;quadScene=new Qr;quadCamera=new Ts(-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 Js(this.width,this.height,hn);i.minFilter=Dt,i.magFilter=Dt,this.target=new ui(this.width,this.height,{type:$t,depthTexture:i}),this.material=new
|
|
6052
|
+
`,depthTest:!1,depthWrite:!1})}sourceFovDeg(e,t){return Math.atan(this.sourceTanHalfFovY(e,t))*360/Math.PI}sourceTanHalfFovY(e,t){const i=Wn.cornerHalfAngleDeg(e,t)*Math.PI/180;return Math.tan(i)/Math.hypot(t,1)}dispose(){this.target.dispose(),this.material.dispose(),this.cubeTarget?.dispose(),this.cubeMaterial?.dispose(),this.copy?.dispose(),this.quadScene.clear()}}class ka{static MAX_RADIUS_PX=24;static TAPS=32;target;quadScene=new Qr;quadCamera=new Ts(-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 Js(this.width,this.height,hn);i.minFilter=Dt,i.magFilter=Dt,this.target=new ui(this.width,this.height,{type:$t,depthTexture:i}),this.material=new Et({uniforms:{uColour:{value:this.target.texture},uDepth:{value:i},uResolution:{value:new Ae(this.width,this.height)},uNear:{value:.1},uFar:{value:1e3},uApertureMm2:{value:0},uFocusDistance:{value:0},uFocalLengthMm:{value:50},uPixelsPerMm:{value:0},uMaxRadius:{value:ka.MAX_RADIUS_PX},uEncodeOutput:{value:1}},vertexShader:`
|
|
6053
6053
|
varying vec2 vUv;
|
|
6054
6054
|
void main() {
|
|
6055
6055
|
vUv = position.xy * 0.5 + 0.5;
|
|
@@ -6126,7 +6126,7 @@ void main()
|
|
|
6126
6126
|
// values — and encoded only at the very end. See colorSpace.ts.
|
|
6127
6127
|
gl_FragColor = vec4(forDestination(total / weight), colour.a);
|
|
6128
6128
|
}
|
|
6129
|
-
`,depthTest:!1,depthWrite:!1}),this.quadScene.add(new We(new dn(2,2),this.material))}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height)}setLens(e,t,i,n){const r=this.material.uniforms;r.uApertureMm2.value=e*e/Math.max(.1,t),r.uFocusDistance.value=Math.max(0,i),r.uFocalLengthMm.value=e,r.uPixelsPerMm.value=this.height/Math.max(.1,n)}setEncodesOutput(e){this.material.uniforms.uEncodeOutput.value=e?1:0}render(e,t,i,n){const r=this.material.uniforms;r.uNear.value=i.near,r.uFar.value=i.far;const a=e.getRenderTarget();e.setRenderTarget(this.target),e.clear(),e.render(t,i),n?.(),e.setRenderTarget(a),e.render(this.quadScene,this.quadCamera)}dispose(){this.target.depthTexture?.dispose(),this.target.dispose(),this.material.dispose()}}class Mt{static MIN_RATIO=1;static STEP=.25;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=Mt.clamp(e),this.ratio=this.maxRatio,this.timer=t?Hc.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>Mt.SETTLE_MS&&(this.editStreakStartMs=e),this.lastEditMs=e}changing(e){return e-this.lastEditMs<=Mt.SETTLE_MS&&this.lastEditMs-this.editStreakStartMs>=Mt.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=Mt.clamp(e),this.ratio>this.maxRatio&&(this.ratio=this.maxRatio)}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>Mt.GPU_LATE_MS)return this.lower(e,Mt.LOWER_COOLDOWN_MS);if(t<Mt.GPU_ROOM_MS)return this.raise(e,Mt.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>Mt.INTERVAL_LATE_MS;if(this.probe){if(i)return this.ratio=this.probe.ratioBefore,this.probe=void 0,this.lastChangeMs=e,this.nextProbeMs=e+Mt.PROBE_BACKOFF_MS,this.ratio;e-this.probe.sinceMs>=Mt.PROBE_WATCH_MS&&(this.probe=void 0,this.nextProbeMs=e+Mt.PROBE_EVERY_MS);return}if(i){const n=this.lower(e,Mt.LOWER_COOLDOWN_MS);return n!==void 0&&(this.nextProbeMs=e+Mt.PROBE_EVERY_MS),n}if(this.ratio<this.maxRatio&&e>=this.nextProbeMs&&e-this.lastChangeMs>=Mt.RAISE_COOLDOWN_MS){const n=this.ratio,r=this.raise(e,0);return r!==void 0&&(this.probe={sinceMs:e,ratioBefore:n}),r}}lower(e,t){if(!(this.ratio<=Mt.MIN_RATIO||e-this.lastChangeMs<t))return this.ratio=Mt.clamp(this.ratio-Mt.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,Mt.clamp(this.ratio+Mt.STEP)),this.lastChangeMs=e,this.ratio}static clamp(e){return Number.isFinite(e)?Math.max(Mt.MIN_RATIO,Math.round(e/Mt.STEP)*Mt.STEP):Mt.MIN_RATIO}}class Hc{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 Hc(e,t):void 0}pending=[];active;smoothedMs;begin(){if(!(this.active||this.pending.length>=Hc.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 r=e.getQueryParameter(i,e.QUERY_RESULT)/1e6;this.smoothedMs=this.smoothedMs===void 0?r:this.smoothedMs*.8+r*.2}e.deleteQuery(i),this.pending.splice(t,1),t--}}catch{this.pending.length=0}return this.smoothedMs}reset(){this.smoothedMs=void 0}}class nt{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=nt.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=nt.ICE_INDEX_RED){const i=nt.minimumDeviationDeg(nt.SIDE_PRISM_ANGLE_DEG,nt.effectiveIndex(t,e));return Number.isFinite(i)?i:void 0}static parheliaDistanceDeg(e,t=nt.ICE_INDEX_RED){const i=nt.parheliaAzimuthDeg(e,t);if(i===void 0)return;const n=e*Math.PI/180,r=Math.sin(n)**2,a=Math.cos(n)**2*Math.cos(i*Math.PI/180);return Math.acos(Math.max(-1,Math.min(1,r+a)))*180/Math.PI}static get PLATE_END_FACE_LIMIT_DEG(){const e=nt.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(e*e-1)))*180/Math.PI}static circumzenithalAltitudeDeg(e,t=nt.ICE_INDEX_RED){if(e<0||e>90-nt.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 nt.ringOf("halo22",nt.SIDE_PRISM_ANGLE_DEG)}static halo46(){return nt.ringOf("halo46",nt.END_PRISM_ANGLE_DEG)}static ringOf(e,t){const i=nt.minimumDeviationDeg(t,nt.ICE_INDEX_RED),n=nt.minimumDeviationDeg(t,nt.ICE_INDEX_BLUE);return{id:e,angleDeg:(i+n)/2,redAngleDeg:i,blueAngleDeg:n}}static strength(e,t,i=90,n=0){const r=Math.max(0,Math.min(1,e)),a=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 r*a*o}static formsAt(e,t=0){if(e<=-t)return[];const i=[nt.halo22(),nt.halo46()],n=e>0?nt.parheliaDistanceDeg(e):void 0;n!==void 0&&i.push({id:"parhelia",angleDeg:n,redAngleDeg:n,blueAngleDeg:nt.parheliaDistanceDeg(e,nt.ICE_INDEX_BLUE)}),i.push({id:"tangentArc",angleDeg:nt.halo22().angleDeg}),e>0&&i.push({id:"parhelicCircle",angleDeg:e});const r=nt.circumzenithalAltitudeDeg(e);return r!==void 0&&i.push({id:"circumzenithal",angleDeg:r}),e>nt.PLATE_END_FACE_LIMIT_DEG&&i.push({id:"circumhorizontal"}),e<nt.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&i.push({id:"pillar"}),i}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class Ii{static get WATER_INDEX_RED(){return ii.indexAt(ii.RED_NM)}static get WATER_INDEX_BLUE(){return ii.indexAt(ii.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)),r=Math.asin(Math.sin(n)/t),a=2*(n-r)+(e-1)*(Math.PI-2*r),o=2*Math.PI;let c=a%o;return c<0&&(c+=o),c>Math.PI&&(c=o-c),180-c*180/Math.PI}static primary(){return Ii.bowOf("primary",2,0)}static secondary(){return Ii.bowOf("secondary",3,0)}static bowOf(e,t,i){const n=Ii.radiusDeg(t,Ii.WATER_INDEX_RED),r=Ii.radiusDeg(t,Ii.WATER_INDEX_BLUE),a=(n+r)/2;return{id:e,radiusDeg:a,redRadiusDeg:n,violetRadiusDeg:r,topAltitudeDeg:a-i}}static alexandersBandDeg(){return{fromDeg:Ii.primary().redRadiusDeg,toDeg:Ii.secondary().redRadiusDeg}}static formsAt(e){return e<0?[]:[Ii.bowOf("primary",2,e),Ii.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-Ii.FULL_MOON_MAGNITUDE)))}static strength(e,t,i){if(i<=0)return 0;const n=Math.max(0,Math.min(1,e)),r=Math.max(0,1-Math.max(0,Math.min(1,t)));return n*r}}class ki{constructor(e){this.radius=e;const t=ki.SEGMENTS*ki.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const i=new bt;i.setAttribute("position",new ot(this.positions,3)),i.setAttribute("color",new ot(this.colors,3)),i.setDrawRange(0,0),this.object=new We(i,new Zi({vertexColors:!0,transparent:!0,blending:Hi,depthWrite:!1,fog:!1,side:on})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=ki.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(ki.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 r=n*ki.SPREAD_FRACTION*Math.PI/180,a=h=>this.scale(this.slerp(t,i,h),this.radius),o=h=>this.radius*(ki.HEAD_HALF_WIDTH_DEG*Math.PI/180+r*h),c=h=>this.brightness*(1-h)**ki.FADE_POWER;let l=0;for(let h=1;h<ki.POINTS;h++){const u=(h-1)/ki.SEGMENTS,d=h/ki.SEGMENTS;l=this.pushBand(l,a(u),a(d),o(u),o(d),c(u),c(d))}e.setDrawRange(0,l),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}pushBand(e,t,i,n,r,a,o){const c=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(i,t))));for(let l=0;l<ki.ACROSS-1;l++){const h=l-1,u=l,d=this.across(t,c,n,h),f=this.across(i,c,r,h),p=this.across(t,c,n,u),v=this.across(i,c,r,u),m=(g,b)=>g===0?b:0;e=this.push(e,d,m(h,a)),e=this.push(e,f,m(h,o)),e=this.push(e,p,m(u,a)),e=this.push(e,f,m(h,o)),e=this.push(e,v,m(u,o)),e=this.push(e,p,m(u,a))}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 r=Math.max(0,Math.min(1,i));return this.colors[n]=r*.55,this.colors[n+1]=r*.75,this.colors[n+2]=r,e+1}slerp(e,t,i){const n=this.angleBetweenRadians(e,t);if(n<1e-9)return e;const r=Math.sin(n),a=Math.sin((1-i)*n)/r,o=Math.sin(i*n)/r;return{x:e.x*a+t.x*o,y:e.y*a+t.y*o,z:e.z*a+t.z*o}}angleBetween(e,t){return this.angleBetweenRadians(e,t)*180/Math.PI}angleBetweenRadians(e,t){const 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 X5{object=new ri;radius;tiers;drawn=[];constructor(e){this.radius=e,this.object.name="satellites",this.tiers=xd.map(t=>{const i=new ld({vertexColors:!0,size:t.size,sizeAttenuation:!1,fog:!1});_s.apply(i);const n=new Fa(new bt,i);return n.frustumCulled=!1,this.object.add(n),n})}set(e,t,i){const n=this.tiers.map(()=>[]);this.drawn=[];for(const r of e){const a=i(r.position);if(a<=0)continue;const o=r.magnitude-2.5*Math.log10(a);if(o>t)continue;const c=Da(o,t),l=Jm(c),{x:h,y:u,z:d}=ni(r.position.altitudeDeg,r.position.azimuthDeg,this.radius),f=ps(r.position.altitudeDeg),p=Ca(c);n[l].push({x:h,y:u,z:d,r:p*f[0],g:p*f[1],b:p*f[2]}),this.drawn.push({satellite:r,direction:new D(h,u,d).normalize()})}this.tiers.forEach((r,a)=>{const o=n[a],c=new Float32Array(o.length*3),l=new Float32Array(o.length*3);o.forEach((u,d)=>{c.set([u.x,u.y,u.z],d*3),l.set([u.r,u.g,u.b],d*3)}),r.geometry.dispose();const h=new bt;h.setAttribute("position",new ot(c,3)),h.setAttribute("color",new ot(l,3)),r.geometry=h})}get count(){return this.drawn.length}nearest(e,t){let i,n=t;for(const r of this.drawn){const a=r.direction.dot(e);a>n&&(n=a,i=r.satellite)}return i}dispose(){for(const e of this.tiers)e.geometry.dispose(),e.material.dispose();this.object.removeFromParent(),this.drawn=[]}}class tl{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 Ys{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(e){const{ratePerHour:t,durationMs:i,velocityKmS:n,seed:r}=e;if(t<=0||i<=0)return[];const a=t*i/36e5,o=new tl(r),c=Math.floor(a),l=c+(o.next()<a-c?1:0),h=[];for(let u=0;u<l;u++){const d=Math.min(1,Math.max(0,(n-20)/52)),f=Ys.MAX_DURATION_MS-d*(Ys.MAX_DURATION_MS-Ys.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 Ur{object=new ri;radius;core;glow;flashKey;static CORE_WIDTH_DEG=.06;static GLOW_WIDTH_DEG=.5;static SEGMENTS=28;constructor(e){this.radius=e,this.object.name="lightning-bolt",this.core=new Zi({color:15659775,transparent:!0,opacity:0,blending:Hi,depthWrite:!1,fog:!1}),this.glow=new Zi({color:10466559,transparent:!0,opacity:0,blending:Hi,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.opacity=Math.min(1,t*1.4),this.glow.opacity=t*.35,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 tl(e.channelSeed),r=Math.atan2(t,e.distanceM)*180/Math.PI,a=this.channel(n,e.azimuthDeg,r,0,1),o=[a],c=1+Math.floor(n.next()*2);for(let l=0;l<c;l++){const h=a[Math.floor(n.between(.15,.5)*a.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 We(this.ribbon(l,Ur.GLOW_WIDTH_DEG),this.glow)),this.object.add(new We(this.ribbon(l,Ur.CORE_WIDTH_DEG),this.core))}channel(e,t,i,n,r){const a=[],o=i-n;let c=t;for(let l=0;l<=Ur.SEGMENTS;l++){const h=i-o*l/Ur.SEGMENTS;a.push({azimuthDeg:c,altitudeDeg:h}),c+=e.between(-1,1)*o*.06*r}return a}ribbon(e,t){const i=new Float32Array(e.length*2*3),n=[],r=this.radius*Math.tan(t*Math.PI/180)/2,a=e.map(c=>{const{x:l,y:h,z:u}=ni(c.altitudeDeg,c.azimuthDeg,this.radius);return new D(l,h,u)});a.forEach((c,l)=>{const h=a[Math.min(l+1,a.length-1)],u=a[Math.max(l-1,0)],f=h.clone().sub(u).normalize().cross(c.clone().normalize()).normalize().multiplyScalar(r);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<a.length-1){const p=l*2;n.push(p,p+1,p+2,p+1,p+3,p+2)}});const o=new bt;return o.setAttribute("position",new ot(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 Kt{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 tl(e.seed),i=[],{minS:n,maxS:r}=Kt.intervalFor(e.intensity??.5);let a=t.between(0,r)*1e3;for(;a<e.durationMs;){const o=t.next()<Kt.CLOUD_TO_GROUND_FRACTION,c=Kt.MIN_DISTANCE_M,l=Kt.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+=Kt.INTERSTROKE_MS*t.between(.5,1.6);i.push({t:a,azimuthDeg:t.between(0,360),distanceM:h,cloudToGround:o,strokes:d,channelSeed:Math.floor(t.next()*2**31)}),a+=t.between(n,r)*1e3}return i}static intervalFor(e){const t=Math.min(1,Math.max(0,(e-.5)/.5));return{minS:Kt.MIN_INTERVAL_S-t*(Kt.MIN_INTERVAL_S-Kt.SEVERE_MIN_INTERVAL_S),maxS:Kt.MAX_INTERVAL_S-t*(Kt.MAX_INTERVAL_S-Kt.SEVERE_MAX_INTERVAL_S)}}static brightnessAt(e,t){let i=0;for(const n of e.strokes){const r=t-e.t-n.offsetMs;r<0||r>Kt.STROKE_DECAY_MS*6||(i+=n.intensity*Math.exp(-r/Kt.STROKE_DECAY_MS))}return Math.min(1,i)}static endOf(e){const t=e.strokes[e.strokes.length-1];return e.t+t.offsetMs+Kt.STROKE_DECAY_MS*6}static thunderDelayMs(e){return e.distanceM/Kt.SOUND_SPEED_M_S*1e3}}class Di{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(Di.ANCHOR_BLUE-Di.ANCHOR_RED)/(1/(Di.BLUE_NM*Di.BLUE_NM)-1/(Di.RED_NM*Di.RED_NM));static A=Di.ANCHOR_RED-Di.B/(Di.RED_NM*Di.RED_NM);static indexAt(e){return Di.A+Di.B/(e*e)}}class Ja{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(e,t,i,n,r,a){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=r/2,v=a/2;for(let m=0;m<6;m++){const g=n+m*Math.PI/3,b=Math.cos(g),y=Math.sin(g);this.normals[m*3]=o*b+u*y,this.normals[m*3+1]=c*b+d*y,this.normals[m*3+2]=l*b+f*y,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,r,a,o){let c=-t,l=e,h=0,u=Math.hypot(c,l,h);u<1e-6&&(c=1,l=0,h=0,u=1),c/=u,l/=u,h/=u;const d=t*h-i*l,f=i*c-e*h,p=e*l-t*c,v=c*n+d*r-e*this.radius*2,m=l*n+f*r-t*this.radius*2,g=h*n+p*r-i*this.radius*2;let b=-1,y=-1/0,_=1/0;for(let J=0;J<8;J++){const ie=this.normals[J*3],ae=this.normals[J*3+1],Be=this.normals[J*3+2],je=ie*e+ae*t+Be*i,Ge=this.offsets[J]-(ie*v+ae*m+Be*g);if(je>1e-9){const Y=Ge/je;Y<_&&(_=Y)}else if(je<-1e-9){const Y=Ge/je;Y>y&&(y=Y,b=J)}else if(Ge<0)return 0}if(b<0||y>=_)return 0;let w=0;const E=this.normals[b*3],R=this.normals[b*3+1],x=this.normals[b*3+2],A=-(E*e+R*t+x*i),I=Uc.reflectance(A,1,a);o[w].x=e+2*A*E,o[w].y=t+2*A*R,o[w].z=i+2*A*x,o[w].weight=I,w++;const C=1/a,P=Math.sqrt(Math.max(0,1-C*C*(1-A*A)));let X=C*e+(C*A-P)*E,z=C*t+(C*A-P)*R,N=C*i+(C*A-P)*x,V=v+e*y,k=m+t*y,K=g+i*y,ee=1-I;for(let J=0;J<Ja.MAX_BOUNCES&&ee>Ja.MIN_WEIGHT;J++){let ie=-1,ae=1/0;for(let B=0;B<8;B++){const we=this.normals[B*3],Pe=this.normals[B*3+1],Re=this.normals[B*3+2],xe=we*X+Pe*z+Re*N;if(xe<=1e-9)continue;const Ne=(this.offsets[B]-(we*V+Pe*k+Re*K))/xe;Ne>1e-9&&Ne<ae&&(ae=Ne,ie=B)}if(ie<0)break;const Be=this.normals[ie*3],je=this.normals[ie*3+1],Ge=this.normals[ie*3+2],Y=Be*X+je*z+Ge*N,re=a*Math.sqrt(Math.max(0,1-Y*Y));if(V+=X*ae,k+=z*ae,K+=N*ae,re<1){const B=Math.sqrt(Math.max(0,1-re*re)),we=Uc.reflectance(Y,a,1);if(o[w].x=a*X-(a*Y-B)*Be,o[w].y=a*z-(a*Y-B)*je,o[w].z=a*N-(a*Y-B)*Ge,o[w].weight=ee*(1-we),w++,w>=o.length)return w;ee*=we}const ne=2*Y;X-=ne*Be,z-=ne*je,N-=ne*Ge}return w}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class Rt{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 Ja;emergent=Array.from({length:Ja.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(Rt.AZIMUTH_BINS*Rt.ALTITUDE_BINS*3);radiance=new Float32Array(Rt.AZIMUTH_BINS*Rt.ALTITUDE_BINS*3);scratch=new Float32Array(Rt.AZIMUTH_BINS*Rt.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=Rt.WORST_TILT_DEG*(Rt.BEST_TILT_DEG/Rt.WORST_TILT_DEG)**this.alignment;this.tilt=n*Math.PI/180}trace(e){const t=Rt.AZIMUTH_BINS,i=Rt.ALTITUDE_BINS,n=this.tally,r=Rt.SOURCE_RADIUS_DEG*Math.PI/180,a=Math.cos(Rt.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let c=0;c<e;c++){const l=this.pickPopulation();this.orient(l,this.tilt);const h=this.random()*2*Math.PI,u=r*Math.sqrt(this.random()),d=o+u*Math.sin(h),f=u*Math.cos(h)/Math.max(.05,Math.cos(o)),p=-Math.cos(d)*Math.cos(f),v=-Math.cos(d)*Math.sin(f),m=-Math.sin(d),g=this.crystal.aimRadius,b=(this.random()*2-1)*g,y=(this.random()*2-1)*g,_=4*g*g,w=li.SAMPLES[this.random()*li.SAMPLES.length|0],E=this.crystal.trace(p,v,m,b,y,Di.indexAt(w.wavelengthNm),this.emergent);for(let R=0;R<E;R++){const x=this.emergent[R],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>a)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*_*li.SAMPLES.length;n[k]+=K*w.r,n[k+1]+=K*w.g,n[k+2]+=K*w.b}}this.traced+=e}get tracedRays(){return this.traced}harvest(){const e=Rt.AZIMUTH_BINS,t=Rt.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),r=4*Rt.REFERENCE_MICRONS*Rt.REFERENCE_MICRONS;for(let a=0;a<t;a++){const o=Math.sin(a/t*Math.PI-Math.PI/2),c=Math.sin((a+1)/t*Math.PI-Math.PI/2),l=1/(i*(c-o)*n*r);for(let h=0;h<e;h++){const u=(a*e+h)*3;this.radiance[u]=this.tally[u]*l,this.radiance[u+1]=this.tally[u+1]*l,this.radiance[u+2]=this.tally[u+2]*l}}}static REFERENCE_MICRONS=50;smooth(e,t){const i=this.scratch,n=this.radiance;i.set(n);for(let a=0;a<t;a++){const o=a*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 r=e*3;for(let a=0;a<t;a++){const o=a>0?-r:0,c=a+1<t?r:0,l=a*r;for(let h=l;h<l+r;h++)n[h]=(i[h+o]+2*i[h]+i[h+c])/4}}pickPopulation(){const e=this.random();let t=0;for(const i of Rt.POPULATIONS)if(t+=i.share,e<=t)return i;return Rt.POPULATIONS[Rt.POPULATIONS.length-1]}orient(e,t){const i=this.random()*2*Math.PI;let n=this.random()*2*Math.PI,r=0,a=0,o=1;switch(e.orientation){case"tumbling":{o=this.random()*2-1;const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(i),a=c*Math.sin(i);break}case"plate":{o=this.spreadAboutAnAxis(t);const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(i),a=c*Math.sin(i);break}case"column":case"parry":{o=this.spreadAboutAPlane(t);const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(i),a=c*Math.sin(i),e.orientation==="parry"&&(n=Math.PI/2+this.gaussian()*t);break}}this.crystal.set(r,a,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 tn{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 GAIN=.55;setCloudOffset(e){this.material.uniforms.uFieldOffset.value.copy(e)}object;material;sky=new Rt;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;urgent=!1;workHandle;onRepaint;constructor(){const e=Rt.AZIMUTH_BINS,t=Rt.ALTITUDE_BINS;this.texels=new Uint16Array(e*t*4),this.texture=new tr(this.texels,e,t,xi,$t),this.texture.minFilter=at,this.texture.magFilter=at,this.texture.wrapS=Ei,this.texture.wrapT=Ei,this.texture.needsUpdate=!0,this.material=new wt({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:tn.GAIN}},vertexShader:`
|
|
6129
|
+
`,depthTest:!1,depthWrite:!1}),this.quadScene.add(new We(new dn(2,2),this.material))}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height)}setLens(e,t,i,n){const r=this.material.uniforms;r.uApertureMm2.value=e*e/Math.max(.1,t),r.uFocusDistance.value=Math.max(0,i),r.uFocalLengthMm.value=e,r.uPixelsPerMm.value=this.height/Math.max(.1,n)}setEncodesOutput(e){this.material.uniforms.uEncodeOutput.value=e?1:0}render(e,t,i,n){const r=this.material.uniforms;r.uNear.value=i.near,r.uFar.value=i.far;const a=e.getRenderTarget();e.setRenderTarget(this.target),e.clear(),e.render(t,i),n?.(),e.setRenderTarget(a),e.render(this.quadScene,this.quadCamera)}dispose(){this.target.depthTexture?.dispose(),this.target.dispose(),this.material.dispose()}}class Mt{static MIN_RATIO=1;static STEP=.25;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=Mt.clamp(e),this.ratio=this.maxRatio,this.timer=t?Hc.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>Mt.SETTLE_MS&&(this.editStreakStartMs=e),this.lastEditMs=e}changing(e){return e-this.lastEditMs<=Mt.SETTLE_MS&&this.lastEditMs-this.editStreakStartMs>=Mt.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=Mt.clamp(e),this.ratio>this.maxRatio&&(this.ratio=this.maxRatio)}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>Mt.GPU_LATE_MS)return this.lower(e,Mt.LOWER_COOLDOWN_MS);if(t<Mt.GPU_ROOM_MS)return this.raise(e,Mt.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>Mt.INTERVAL_LATE_MS;if(this.probe){if(i)return this.ratio=this.probe.ratioBefore,this.probe=void 0,this.lastChangeMs=e,this.nextProbeMs=e+Mt.PROBE_BACKOFF_MS,this.ratio;e-this.probe.sinceMs>=Mt.PROBE_WATCH_MS&&(this.probe=void 0,this.nextProbeMs=e+Mt.PROBE_EVERY_MS);return}if(i){const n=this.lower(e,Mt.LOWER_COOLDOWN_MS);return n!==void 0&&(this.nextProbeMs=e+Mt.PROBE_EVERY_MS),n}if(this.ratio<this.maxRatio&&e>=this.nextProbeMs&&e-this.lastChangeMs>=Mt.RAISE_COOLDOWN_MS){const n=this.ratio,r=this.raise(e,0);return r!==void 0&&(this.probe={sinceMs:e,ratioBefore:n}),r}}lower(e,t){if(!(this.ratio<=Mt.MIN_RATIO||e-this.lastChangeMs<t))return this.ratio=Mt.clamp(this.ratio-Mt.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,Mt.clamp(this.ratio+Mt.STEP)),this.lastChangeMs=e,this.ratio}static clamp(e){return Number.isFinite(e)?Math.max(Mt.MIN_RATIO,Math.round(e/Mt.STEP)*Mt.STEP):Mt.MIN_RATIO}}class Hc{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 Hc(e,t):void 0}pending=[];active;smoothedMs;begin(){if(!(this.active||this.pending.length>=Hc.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 r=e.getQueryParameter(i,e.QUERY_RESULT)/1e6;this.smoothedMs=this.smoothedMs===void 0?r:this.smoothedMs*.8+r*.2}e.deleteQuery(i),this.pending.splice(t,1),t--}}catch{this.pending.length=0}return this.smoothedMs}reset(){this.smoothedMs=void 0}}class nt{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=nt.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=nt.ICE_INDEX_RED){const i=nt.minimumDeviationDeg(nt.SIDE_PRISM_ANGLE_DEG,nt.effectiveIndex(t,e));return Number.isFinite(i)?i:void 0}static parheliaDistanceDeg(e,t=nt.ICE_INDEX_RED){const i=nt.parheliaAzimuthDeg(e,t);if(i===void 0)return;const n=e*Math.PI/180,r=Math.sin(n)**2,a=Math.cos(n)**2*Math.cos(i*Math.PI/180);return Math.acos(Math.max(-1,Math.min(1,r+a)))*180/Math.PI}static get PLATE_END_FACE_LIMIT_DEG(){const e=nt.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(e*e-1)))*180/Math.PI}static circumzenithalAltitudeDeg(e,t=nt.ICE_INDEX_RED){if(e<0||e>90-nt.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 nt.ringOf("halo22",nt.SIDE_PRISM_ANGLE_DEG)}static halo46(){return nt.ringOf("halo46",nt.END_PRISM_ANGLE_DEG)}static ringOf(e,t){const i=nt.minimumDeviationDeg(t,nt.ICE_INDEX_RED),n=nt.minimumDeviationDeg(t,nt.ICE_INDEX_BLUE);return{id:e,angleDeg:(i+n)/2,redAngleDeg:i,blueAngleDeg:n}}static strength(e,t,i=90,n=0){const r=Math.max(0,Math.min(1,e)),a=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 r*a*o}static formsAt(e,t=0){if(e<=-t)return[];const i=[nt.halo22(),nt.halo46()],n=e>0?nt.parheliaDistanceDeg(e):void 0;n!==void 0&&i.push({id:"parhelia",angleDeg:n,redAngleDeg:n,blueAngleDeg:nt.parheliaDistanceDeg(e,nt.ICE_INDEX_BLUE)}),i.push({id:"tangentArc",angleDeg:nt.halo22().angleDeg}),e>0&&i.push({id:"parhelicCircle",angleDeg:e});const r=nt.circumzenithalAltitudeDeg(e);return r!==void 0&&i.push({id:"circumzenithal",angleDeg:r}),e>nt.PLATE_END_FACE_LIMIT_DEG&&i.push({id:"circumhorizontal"}),e<nt.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&i.push({id:"pillar"}),i}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class Pi{static get WATER_INDEX_RED(){return ii.indexAt(ii.RED_NM)}static get WATER_INDEX_BLUE(){return ii.indexAt(ii.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)),r=Math.asin(Math.sin(n)/t),a=2*(n-r)+(e-1)*(Math.PI-2*r),o=2*Math.PI;let c=a%o;return c<0&&(c+=o),c>Math.PI&&(c=o-c),180-c*180/Math.PI}static primary(){return Pi.bowOf("primary",2,0)}static secondary(){return Pi.bowOf("secondary",3,0)}static bowOf(e,t,i){const n=Pi.radiusDeg(t,Pi.WATER_INDEX_RED),r=Pi.radiusDeg(t,Pi.WATER_INDEX_BLUE),a=(n+r)/2;return{id:e,radiusDeg:a,redRadiusDeg:n,violetRadiusDeg:r,topAltitudeDeg:a-i}}static alexandersBandDeg(){return{fromDeg:Pi.primary().redRadiusDeg,toDeg:Pi.secondary().redRadiusDeg}}static formsAt(e){return e<0?[]:[Pi.bowOf("primary",2,e),Pi.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-Pi.FULL_MOON_MAGNITUDE)))}static strength(e,t,i){if(i<=0)return 0;const n=Math.max(0,Math.min(1,e)),r=Math.max(0,1-Math.max(0,Math.min(1,t)));return n*r}}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 bt;i.setAttribute("position",new ot(this.positions,3)),i.setAttribute("color",new ot(this.colors,3)),i.setDrawRange(0,0),this.object=new We(i,new Ji({vertexColors:!0,transparent:!0,blending:Gi,depthWrite:!1,fog:!1,side:on})),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 r=n*zi.SPREAD_FRACTION*Math.PI/180,a=h=>this.scale(this.slerp(t,i,h),this.radius),o=h=>this.radius*(zi.HEAD_HALF_WIDTH_DEG*Math.PI/180+r*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,a(u),a(d),o(u),o(d),c(u),c(d))}e.setDrawRange(0,l),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}pushBand(e,t,i,n,r,a,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,r,h),p=this.across(t,c,n,u),v=this.across(i,c,r,u),m=(g,b)=>g===0?b:0;e=this.push(e,d,m(h,a)),e=this.push(e,f,m(h,o)),e=this.push(e,p,m(u,a)),e=this.push(e,f,m(h,o)),e=this.push(e,v,m(u,o)),e=this.push(e,p,m(u,a))}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 r=Math.max(0,Math.min(1,i));return this.colors[n]=r*.55,this.colors[n+1]=r*.75,this.colors[n+2]=r,e+1}slerp(e,t,i){const n=this.angleBetweenRadians(e,t);if(n<1e-9)return e;const r=Math.sin(n),a=Math.sin((1-i)*n)/r,o=Math.sin(i*n)/r;return{x:e.x*a+t.x*o,y:e.y*a+t.y*o,z:e.z*a+t.z*o}}angleBetween(e,t){return this.angleBetweenRadians(e,t)*180/Math.PI}angleBetweenRadians(e,t){const 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 X5{object=new ri;radius;tiers;drawn=[];constructor(e){this.radius=e,this.object.name="satellites",this.tiers=xd.map(t=>{const i=new ld({vertexColors:!0,size:t.size,sizeAttenuation:!1,fog:!1});_s.apply(i);const n=new Fa(new bt,i);return n.frustumCulled=!1,this.object.add(n),n})}set(e,t,i){const n=this.tiers.map(()=>[]);this.drawn=[];for(const r of e){const a=i(r.position);if(a<=0)continue;const o=r.magnitude-2.5*Math.log10(a);if(o>t)continue;const c=Da(o,t),l=Jm(c),{x:h,y:u,z:d}=ni(r.position.altitudeDeg,r.position.azimuthDeg,this.radius),f=ps(r.position.altitudeDeg),p=Ca(c);n[l].push({x:h,y:u,z:d,r:p*f[0],g:p*f[1],b:p*f[2]}),this.drawn.push({satellite:r,direction:new D(h,u,d).normalize()})}this.tiers.forEach((r,a)=>{const o=n[a],c=new Float32Array(o.length*3),l=new Float32Array(o.length*3);o.forEach((u,d)=>{c.set([u.x,u.y,u.z],d*3),l.set([u.r,u.g,u.b],d*3)}),r.geometry.dispose();const h=new bt;h.setAttribute("position",new ot(c,3)),h.setAttribute("color",new ot(l,3)),r.geometry=h})}get count(){return this.drawn.length}nearest(e,t){let i,n=t;for(const r of this.drawn){const a=r.direction.dot(e);a>n&&(n=a,i=r.satellite)}return i}dispose(){for(const e of this.tiers)e.geometry.dispose(),e.material.dispose();this.object.removeFromParent(),this.drawn=[]}}class tl{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 Ys{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(e){const{ratePerHour:t,durationMs:i,velocityKmS:n,seed:r}=e;if(t<=0||i<=0)return[];const a=t*i/36e5,o=new tl(r),c=Math.floor(a),l=c+(o.next()<a-c?1:0),h=[];for(let u=0;u<l;u++){const d=Math.min(1,Math.max(0,(n-20)/52)),f=Ys.MAX_DURATION_MS-d*(Ys.MAX_DURATION_MS-Ys.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 Ur{object=new ri;radius;core;glow;flashKey;static CORE_WIDTH_DEG=.06;static GLOW_WIDTH_DEG=.5;static SEGMENTS=28;constructor(e){this.radius=e,this.object.name="lightning-bolt",this.core=new Ji({color:15659775,transparent:!0,opacity:0,blending:Gi,depthWrite:!1,fog:!1}),this.glow=new Ji({color:10466559,transparent:!0,opacity:0,blending:Gi,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.opacity=Math.min(1,t*1.4),this.glow.opacity=t*.35,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 tl(e.channelSeed),r=Math.atan2(t,e.distanceM)*180/Math.PI,a=this.channel(n,e.azimuthDeg,r,0,1),o=[a],c=1+Math.floor(n.next()*2);for(let l=0;l<c;l++){const h=a[Math.floor(n.between(.15,.5)*a.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 We(this.ribbon(l,Ur.GLOW_WIDTH_DEG),this.glow)),this.object.add(new We(this.ribbon(l,Ur.CORE_WIDTH_DEG),this.core))}channel(e,t,i,n,r){const a=[],o=i-n;let c=t;for(let l=0;l<=Ur.SEGMENTS;l++){const h=i-o*l/Ur.SEGMENTS;a.push({azimuthDeg:c,altitudeDeg:h}),c+=e.between(-1,1)*o*.06*r}return a}ribbon(e,t){const i=new Float32Array(e.length*2*3),n=[],r=this.radius*Math.tan(t*Math.PI/180)/2,a=e.map(c=>{const{x:l,y:h,z:u}=ni(c.altitudeDeg,c.azimuthDeg,this.radius);return new D(l,h,u)});a.forEach((c,l)=>{const h=a[Math.min(l+1,a.length-1)],u=a[Math.max(l-1,0)],f=h.clone().sub(u).normalize().cross(c.clone().normalize()).normalize().multiplyScalar(r);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<a.length-1){const p=l*2;n.push(p,p+1,p+2,p+1,p+3,p+2)}});const o=new bt;return o.setAttribute("position",new ot(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 Kt{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 tl(e.seed),i=[],{minS:n,maxS:r}=Kt.intervalFor(e.intensity??.5);let a=t.between(0,r)*1e3;for(;a<e.durationMs;){const o=t.next()<Kt.CLOUD_TO_GROUND_FRACTION,c=Kt.MIN_DISTANCE_M,l=Kt.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+=Kt.INTERSTROKE_MS*t.between(.5,1.6);i.push({t:a,azimuthDeg:t.between(0,360),distanceM:h,cloudToGround:o,strokes:d,channelSeed:Math.floor(t.next()*2**31)}),a+=t.between(n,r)*1e3}return i}static intervalFor(e){const t=Math.min(1,Math.max(0,(e-.5)/.5));return{minS:Kt.MIN_INTERVAL_S-t*(Kt.MIN_INTERVAL_S-Kt.SEVERE_MIN_INTERVAL_S),maxS:Kt.MAX_INTERVAL_S-t*(Kt.MAX_INTERVAL_S-Kt.SEVERE_MAX_INTERVAL_S)}}static brightnessAt(e,t){let i=0;for(const n of e.strokes){const r=t-e.t-n.offsetMs;r<0||r>Kt.STROKE_DECAY_MS*6||(i+=n.intensity*Math.exp(-r/Kt.STROKE_DECAY_MS))}return Math.min(1,i)}static endOf(e){const t=e.strokes[e.strokes.length-1];return e.t+t.offsetMs+Kt.STROKE_DECAY_MS*6}static thunderDelayMs(e){return e.distanceM/Kt.SOUND_SPEED_M_S*1e3}}class Ci{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(Ci.ANCHOR_BLUE-Ci.ANCHOR_RED)/(1/(Ci.BLUE_NM*Ci.BLUE_NM)-1/(Ci.RED_NM*Ci.RED_NM));static A=Ci.ANCHOR_RED-Ci.B/(Ci.RED_NM*Ci.RED_NM);static indexAt(e){return Ci.A+Ci.B/(e*e)}}class Ja{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(e,t,i,n,r,a){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=r/2,v=a/2;for(let m=0;m<6;m++){const g=n+m*Math.PI/3,b=Math.cos(g),y=Math.sin(g);this.normals[m*3]=o*b+u*y,this.normals[m*3+1]=c*b+d*y,this.normals[m*3+2]=l*b+f*y,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,r,a,o){let c=-t,l=e,h=0,u=Math.hypot(c,l,h);u<1e-6&&(c=1,l=0,h=0,u=1),c/=u,l/=u,h/=u;const d=t*h-i*l,f=i*c-e*h,p=e*l-t*c,v=c*n+d*r-e*this.radius*2,m=l*n+f*r-t*this.radius*2,g=h*n+p*r-i*this.radius*2;let b=-1,y=-1/0,_=1/0;for(let J=0;J<8;J++){const ie=this.normals[J*3],ae=this.normals[J*3+1],Be=this.normals[J*3+2],je=ie*e+ae*t+Be*i,Ge=this.offsets[J]-(ie*v+ae*m+Be*g);if(je>1e-9){const Y=Ge/je;Y<_&&(_=Y)}else if(je<-1e-9){const Y=Ge/je;Y>y&&(y=Y,b=J)}else if(Ge<0)return 0}if(b<0||y>=_)return 0;let E=0;const w=this.normals[b*3],R=this.normals[b*3+1],x=this.normals[b*3+2],A=-(w*e+R*t+x*i),I=Uc.reflectance(A,1,a);o[E].x=e+2*A*w,o[E].y=t+2*A*R,o[E].z=i+2*A*x,o[E].weight=I,E++;const C=1/a,P=Math.sqrt(Math.max(0,1-C*C*(1-A*A)));let X=C*e+(C*A-P)*w,z=C*t+(C*A-P)*R,N=C*i+(C*A-P)*x,V=v+e*y,k=m+t*y,K=g+i*y,ee=1-I;for(let J=0;J<Ja.MAX_BOUNCES&&ee>Ja.MIN_WEIGHT;J++){let ie=-1,ae=1/0;for(let B=0;B<8;B++){const Ee=this.normals[B*3],Pe=this.normals[B*3+1],Re=this.normals[B*3+2],xe=Ee*X+Pe*z+Re*N;if(xe<=1e-9)continue;const Ne=(this.offsets[B]-(Ee*V+Pe*k+Re*K))/xe;Ne>1e-9&&Ne<ae&&(ae=Ne,ie=B)}if(ie<0)break;const Be=this.normals[ie*3],je=this.normals[ie*3+1],Ge=this.normals[ie*3+2],Y=Be*X+je*z+Ge*N,re=a*Math.sqrt(Math.max(0,1-Y*Y));if(V+=X*ae,k+=z*ae,K+=N*ae,re<1){const B=Math.sqrt(Math.max(0,1-re*re)),Ee=Uc.reflectance(Y,a,1);if(o[E].x=a*X-(a*Y-B)*Be,o[E].y=a*z-(a*Y-B)*je,o[E].z=a*N-(a*Y-B)*Ge,o[E].weight=ee*(1-Ee),E++,E>=o.length)return E;ee*=Ee}const ne=2*Y;X-=ne*Be,z-=ne*je,N-=ne*Ge}return E}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class Rt{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 Ja;emergent=Array.from({length:Ja.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(Rt.AZIMUTH_BINS*Rt.ALTITUDE_BINS*3);radiance=new Float32Array(Rt.AZIMUTH_BINS*Rt.ALTITUDE_BINS*3);scratch=new Float32Array(Rt.AZIMUTH_BINS*Rt.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=Rt.WORST_TILT_DEG*(Rt.BEST_TILT_DEG/Rt.WORST_TILT_DEG)**this.alignment;this.tilt=n*Math.PI/180}trace(e){const t=Rt.AZIMUTH_BINS,i=Rt.ALTITUDE_BINS,n=this.tally,r=Rt.SOURCE_RADIUS_DEG*Math.PI/180,a=Math.cos(Rt.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let c=0;c<e;c++){const l=this.pickPopulation();this.orient(l,this.tilt);const h=this.random()*2*Math.PI,u=r*Math.sqrt(this.random()),d=o+u*Math.sin(h),f=u*Math.cos(h)/Math.max(.05,Math.cos(o)),p=-Math.cos(d)*Math.cos(f),v=-Math.cos(d)*Math.sin(f),m=-Math.sin(d),g=this.crystal.aimRadius,b=(this.random()*2-1)*g,y=(this.random()*2-1)*g,_=4*g*g,E=li.SAMPLES[this.random()*li.SAMPLES.length|0],w=this.crystal.trace(p,v,m,b,y,Ci.indexAt(E.wavelengthNm),this.emergent);for(let R=0;R<w;R++){const x=this.emergent[R],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>a)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*_*li.SAMPLES.length;n[k]+=K*E.r,n[k+1]+=K*E.g,n[k+2]+=K*E.b}}this.traced+=e}get tracedRays(){return this.traced}harvest(){const e=Rt.AZIMUTH_BINS,t=Rt.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),r=4*Rt.REFERENCE_MICRONS*Rt.REFERENCE_MICRONS;for(let a=0;a<t;a++){const o=Math.sin(a/t*Math.PI-Math.PI/2),c=Math.sin((a+1)/t*Math.PI-Math.PI/2),l=1/(i*(c-o)*n*r);for(let h=0;h<e;h++){const u=(a*e+h)*3;this.radiance[u]=this.tally[u]*l,this.radiance[u+1]=this.tally[u+1]*l,this.radiance[u+2]=this.tally[u+2]*l}}}static REFERENCE_MICRONS=50;smooth(e,t){const i=this.scratch,n=this.radiance;i.set(n);for(let a=0;a<t;a++){const o=a*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 r=e*3;for(let a=0;a<t;a++){const o=a>0?-r:0,c=a+1<t?r:0,l=a*r;for(let h=l;h<l+r;h++)n[h]=(i[h+o]+2*i[h]+i[h+c])/4}}pickPopulation(){const e=this.random();let t=0;for(const i of Rt.POPULATIONS)if(t+=i.share,e<=t)return i;return Rt.POPULATIONS[Rt.POPULATIONS.length-1]}orient(e,t){const i=this.random()*2*Math.PI;let n=this.random()*2*Math.PI,r=0,a=0,o=1;switch(e.orientation){case"tumbling":{o=this.random()*2-1;const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(i),a=c*Math.sin(i);break}case"plate":{o=this.spreadAboutAnAxis(t);const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(i),a=c*Math.sin(i);break}case"column":case"parry":{o=this.spreadAboutAPlane(t);const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(i),a=c*Math.sin(i),e.orientation==="parry"&&(n=Math.PI/2+this.gaussian()*t);break}}this.crystal.set(r,a,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 Si{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 Rt;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;urgent=!1;workHandle;onRepaint;constructor(){const e=Rt.AZIMUTH_BINS,t=Rt.ALTITUDE_BINS;this.texels=new Uint16Array(e*t*4),this.texture=new tr(this.texels,e,t,xi,$t),this.texture.minFilter=at,this.texture.magFilter=at,this.texture.wrapS=Ai,this.texture.wrapT=Ai,this.texture.needsUpdate=!0,this.material=new Et({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:Si.GAIN}},vertexShader:`
|
|
6130
6130
|
varying vec3 vDirection;
|
|
6131
6131
|
void main() {
|
|
6132
6132
|
vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
|
|
@@ -6155,11 +6155,11 @@ void main()
|
|
|
6155
6155
|
if (ice <= 0.0) discard;
|
|
6156
6156
|
gl_FragColor = vec4(iceHaloLight(dir, ice), 1.0);
|
|
6157
6157
|
}
|
|
6158
|
-
`,transparent:!0,blending:Hi,depthWrite:!1,side:It,fog:!1}),this.object=new We(new di(tn.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,r,a){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=r.cover,o.uIceHeight.value=r.layerHeight,this.show(this.everDisplayed),this.requestMap(t,a)}requestMap(e,t){!(!(Math.abs(e-this.mappedAltitudeDeg)<tn.ALTITUDE_STEP_DEG)||t!==this.mappedAlignment)||this.tracingFor(e,t)||(this.pendingAltitudeDeg=e,this.pendingAlignment=t,this.sky.begin(e,t),this.tracing=!0,this.scheduleWork())}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;tracingFor(e,t){return this.tracing&&Math.abs(e-this.pendingAltitudeDeg)<tn.ALTITUDE_STEP_DEG&&t===this.pendingAlignment}scheduleWork(){if(this.workHandle!==void 0)return;const e=()=>{if(this.workHandle=void 0,!this.tracing)return;const t=performance.now(),i=this.urgent?tn.URGENT_BUDGET_MS:tn.BUDGET_MS;do this.sky.trace(tn.RAYS_PER_BATCH);while(this.sky.tracedRays<tn.RAYS&&performance.now()-t<i);if(this.sky.tracedRays>=tn.RAYS){this.publish(),this.tracing=!1,this.mappedAltitudeDeg=this.pendingAltitudeDeg,this.mappedAlignment=this.pendingAlignment;return}this.workHandle=requestAnimationFrame(e)};this.workHandle=requestAnimationFrame(e)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0,this.tracing=!1}publish(){const t=this.sky.harvest().data;for(let i=0,n=0;n<t.length;i+=4,n+=3)this.texels[i]=Zn.toHalfFloat(t[n]),this.texels[i+1]=Zn.toHalfFloat(t[n+1]),this.texels[i+2]=Zn.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 ei{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=ei.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(ei.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=ei.MAX_CONCURRENT*ei.SEGMENTS*ei.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const t=new bt;t.setAttribute("position",new ot(this.positions,3)),t.setAttribute("color",new ot(this.colors,3)),t.setDrawRange(0,0),this.object=new We(t,new Zi({vertexColors:!0,transparent:!0,blending:Hi,depthWrite:!1,fog:!1,side:on})),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=Ys.aliveAt(this.meteors,e).slice(0,ei.MAX_CONCURRENT);let n=0;for(const{meteor:r,progress:a}of i){const o=this.radiantOf(r);if(!o)continue;const c=ni(o.altitudeDeg,o.azimuthDeg,1),[l,h]=this.basisAround(c),u=r.fromRadiantDeg+a*r.lengthDeg,d=Math.max(r.fromRadiantDeg,u-r.lengthDeg*.6),f=Math.min(1,(1-a)*2.5),p=this.turn(l,h,r.bearingDeg),v=(.15+.85*r.brightness)*f,m=y=>v*y**1.6,g=y=>this.onSphere(c,p,d+(u-d)*y),b=y=>ei.RADIUS*((ei.MIN_HALF_WIDTH_DEG+ei.BRIGHT_HALF_WIDTH_DEG*r.brightness*y)*Math.PI/180);for(let y=1;y<ei.POINTS;y++){const _=(y-1)/ei.SEGMENTS,w=y/ei.SEGMENTS;n=this.pushRibbon(n,g(_),g(w),b(_),b(w),m(_),m(w))}}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,r]=this.basisAround(i),a=this.turn(n,r,e.bearingDeg),o=this.onSphere(i,a,e.fromRadiantDeg+e.lengthDeg/2),c=Math.hypot(o.x,o.y,o.z)||1;return{altitudeDeg:Math.asin(o.y/c)*180/Math.PI,azimuthDeg:(Math.atan2(o.x,-o.z)*180/Math.PI+360)%360}}radiantOf(e){return e.radiant?e.radiant:this.radiantAltitudeDeg>0?{altitudeDeg:this.radiantAltitudeDeg,azimuthDeg:this.radiantAzimuthDeg}:void 0}pushRibbon(e,t,i,n,r,a,o){const c=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(i,t))));for(let l=0;l<ei.ACROSS-1;l++){const h=l-1,u=l,d=this.across(t,c,n,h),f=this.across(i,c,r,h),p=this.across(t,c,n,u),v=this.across(i,c,r,u),m=(g,b)=>g===0?b:0;e=this.push(e,d,m(h,a)),e=this.push(e,f,m(h,o)),e=this.push(e,p,m(u,a)),e=this.push(e,f,m(h,o)),e=this.push(e,v,m(u,o)),e=this.push(e,p,m(u,a))}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 r=Math.max(0,Math.min(1,i));return this.colors[n]=r*.9,this.colors[n+1]=r*.95,this.colors[n+2]=r,e+1}turn(e,t,i){const n=i*Math.PI/180,r=Math.cos(n),a=Math.sin(n);return{x:e.x*r+t.x*a,y:e.y*r+t.y*a,z:e.z*r+t.z*a}}onSphere(e,t,i){const n=i*Math.PI/180,r=Math.cos(n),a=Math.sin(n);return{x:(e.x*r+t.x*a)*ei.RADIUS,y:(e.y*r+t.y*a)*ei.RADIUS,z:(e.z*r+t.z*a)*ei.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 Jl=Math.PI/180;function Vt(s,e,t,i,n=!1){const r=n?new Zi({color:new oe(...t)}):new eo({color:new oe(...t)}),a=new We(e,r);return a.position.y=i,a.userData={emissive:n},a.castShadow=!n,a.receiveShadow=!n,s.add(a),a}const Zf=.25,q5=.002,Y5=20;function K5(s){const e=/^#([0-9a-f]{6})$/i.exec(s);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 vg=[.32,.32,.3],Mg=[1,.85,.5],xg=[.25,.25,.25],_g=[1,.97,.85],$5=[.55,.68,.72],wn=.03,En=.05,yg={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 wi(s,e){return s?.[e]}function An(s,e,t,i,n,r,a,o){if(o===void 0)return;const c=new eo({color:new oe(...$5),transparent:!0,opacity:o/100}),l=new We(new Ji(e,t,i),c);l.position.set(n,r,a),s.add(l)}const Xi=.05,jl=[.6,.58,.53],Jf=[.5,.5,.48];function Fr(s,e,t,i,n,r,a,o){const c=new eo({color:new oe(...o),side:It}),l=new We(new Ji(e,t,i),c);l.position.set(n,r,a),s.add(l)}function Z5(s,e,t,i,n,r,a,o,c){const l=(i-r)/2,h=(p,v,m,g)=>{p<=0||(e?Fr(s,p,v,Xi,m,o+g,a,c):Fr(s,Xi,v,p,a,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,r,d+m/2,0),d=p.center+p.main/2}const f=t/2-d;h(f,r,d+f/2,0)}function Sg(s,e,t,i,n,r,a,o,c,l){const h=(i+n)/2,u=n-i,d=(f,p,v,m)=>{f.length===0?p?Fr(s,v,u,Xi,0,h,m,jl):Fr(s,Xi,u,v,m,h,0,jl):Z5(s,p,v,u,f,r,m,h,jl)};d(a,!0,e*2,-t+Xi),d(o,!0,e*2,t-Xi),d(c,!1,t*2,-e+Xi),d(l,!1,t*2,e-Xi),Fr(s,e*2,Xi,t*2,0,i+Xi,0,Jf),Fr(s,e*2,Xi,t*2,0,n-Xi,0,Jf)}function Bu(s,e,t,i){switch(s){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:-Tn};case"front-right":return{x:e-i,z:-Tn};case"behind-left":return{x:-(e-i),z:Tn};case"behind-right":return{x:e-i,z:Tn}}}function bg(s,e,t,i,n,r,a){const o=Vu();o.scale.setScalar(i),o.rotation.y=yg[e];const{x:c,z:l}=Bu(e,n,r,a);o.position.set(c,t,l),s.add(o)}const Hu=6,Gu=6,vs=3,ya=1.4,Sa=vs*.5,wg=1.2,Eg=.35,J5=.75,j5=1.6;function jf(s,e,t,i){const n=new ri,r=Math.max(1,s+1),a=r*vs;Vt(n,new Ji(Hu,a,Gu),[.55,.54,.5],a/2);const o=Hu/2,c=Gu/2;for(let l=0;l<r;l++){const h=l*vs+vs/2;An(n,ya,Sa,En,0,h,-c-wn,wi(e,"front")),An(n,ya,Sa,En,0,h,c+wn,wi(e,"behind")),An(n,En,Sa,ya,-o-wn,h,0,wi(e,"left")),An(n,En,Sa,ya,o+wn,h,0,wi(e,"right"))}if(t){const l=Math.min(Math.max(i??0,0),r-1);bg(n,t,l*vs,.72,o,c,wg);const h=u=>wi(e,u)!==void 0?[{main:ya,center:0}]:[];Sg(n,o,c,l*vs,(l+1)*vs,Sa,h("front"),h("behind"),h("left"),h("right"))}return n}function Qf(){const s=new ri;return Vt(s,new is(.15,.22,2,8),[.32,.22,.14],1),Vt(s,new Qa(1.4,3,8),[.16,.32,.14],3.5),s}const ep=.275,Q5=.35,eb=.9,tb=34,ib=8,nb=1.4;function tp(){const s=new ri,e=new di(ep,7,3,0,Math.PI*2,0,Math.PI/2);e.scale(1,Q5/ep,1);const t=ci.repeatOnGrid(e,tb,eb,ib,nb),i=Vt(s,t,[.26,.28,.22],0);return i.castShadow=!1,i.userData.cropBasePositions=t.getAttribute("position").array.slice(),i.userData.cropVerticesPerClump=e.getAttribute("position").count,e.dispose(),s}function ip(){const s=new ri,e=new di(1,7,3,0,Math.PI*2,0,Math.PI/2);return Vt(s,e,[.38,.36,.32],0),s}function np(s){const e=new ri;return Vt(e,new is(.05,.08,5,8),[.28,.28,.3],2.5),Vt(e,new di(.25,12,8),s?Mg:vg,5.1,!0),e}const sb=[.08,.08,.08],ms=.8,Pr=1,yn=1.7,Ql=.6,Ls=.4,Qo=1.2,Dr=.7,Tn=.5,rb=yn;function sp(s,e,t){const i=new ri;Vt(i,new Ji(1.8,1.4,4.2),[.45,.14,.14],.7),Vt(i,new Ji(ms*2,Ql,Pr*2),[.4,.12,.12],yn);for(const r of[-1.4,1.4])for(const a of[-.95,.95]){const o=Vt(i,new is(.4,.4,.3,12),sb,.4);o.rotation.z=Math.PI/2,o.position.x=a,o.position.z=r}const n=s?_g:xg;for(const r of[-.7,.7])Vt(i,new di(.15,8,6),n,.7,!0).position.set(r,.7,-2.1);if(An(i,Qo,Ls,En,0,yn,-Pr-wn,wi(e,"front")),An(i,Qo,Ls,En,0,yn,Pr+wn,wi(e,"behind")),An(i,En,Ls,Dr,-ms-wn,yn,-Tn,wi(e,"front-left")),An(i,En,Ls,Dr,-ms-wn,yn,Tn,wi(e,"behind-left")),An(i,En,Ls,Dr,ms+wn,yn,-Tn,wi(e,"front-right")),An(i,En,Ls,Dr,ms+wn,yn,Tn,wi(e,"behind-right")),t){bg(i,t,J5,.5,ms,Pr,Eg);const r=(c,l)=>{const h=[];return wi(e,c)!==void 0&&h.push({main:Dr,center:-Tn}),wi(e,l)!==void 0&&h.push({main:Dr,center:Tn}),h},a=wi(e,"front")!==void 0?[{main:Qo,center:0}]:[],o=wi(e,"behind")!==void 0?[{main:Qo,center:0}]:[];Sg(i,ms,Pr,yn-Ql/2,yn+Ql/2,Ls,a,o,r("front-left","behind-left"),r("front-right","behind-right"))}return i}const rp=new Map;function ap(s,e){if(!s)return;const t=[[s.lengthM,e.lengthM],[s.heightM,e.heightM],[s.widthM,e.widthM]];for(const[i,n]of t)if(i!==void 0&&n>1e-6)return i/n}function eh(s,e){return e>1e-6?s/e:1}const Ag=[.95,.9,.82],op=[.72,.74,.78];function cp(){const s=new ri;Vt(s,new is(.25,.3,1.5,10),op,.75),Vt(s,new di(.26,10,8),op,1.74);const e=Vt(s,new Qa(.07,.16,8),Ag,1.74);return e.rotation.x=-Math.PI/2,e.position.z=-.22,s}function Vu(){const s=new ri;Vt(s,new is(.25,.3,1.5,10),[.3,.3,.35],.75),Vt(s,new di(.22,10,8),[.62,.52,.46],1.72);const e=Vt(s,new Qa(.07,.16,8),Ag,1.72);return e.rotation.x=-Math.PI/2,e.position.z=-.2,s}const ab=17,lp=18.5,th=[.16,.16,.18];function hp(){const s=new ri,e=Vt(s,new is(1.8,1.8,lp*2,10),th,0);e.rotation.x=Math.PI/2,Vt(s,new Ji(ab*2,.5,4.5),th,0);const t=Vt(s,new Ji(.4,5.5,4),th,3);return t.position.z=-lp+2,s}class ci{static groundUnderFootprint(e,t,i,n,r,a=0){const o=ci.sizeOf(e);if(a>o.heightM)return r(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,r(m,g))}}return Number.isFinite(u)?u:r(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"?Bu(t,ms,Pr,Eg):Bu(t,Hu/2,Gu/2,wg),r=e.kind==="vehicle"?rb:(e.occupiedFloor??0)*vs+j5,a=(e.headingDeg??0)-yg[t]/Jl,o=this.scaleFor(e);return{x:i*o.x,z:n*o.z,eyeY:r*o.y,headingDeg:a}}static BODY_NAME="decor-body";static bodyOf(e){return e.getObjectByName(ci.BODY_NAME)??e}static repeatOnGrid(e,t,i,n,r){const a=e.getAttribute("position"),o=e.getAttribute("normal"),c=e.getIndex();if(!c)throw new Error("repeatOnGrid needs an indexed geometry");const l=a.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)*r)/2;let m=0;for(let b=0;b<n;b++)for(let y=0;y<t;y++,m++){const _=v+b*r,w=p+y*i;for(let E=0;E<l;E++){const R=(m*l+E)*3;u[R]=a.getX(E)+_,u[R+1]=a.getY(E),u[R+2]=a.getZ(E)+w,d[R]=o.getX(E),d[R+1]=o.getY(E),d[R+2]=o.getZ(E)}for(let E=0;E<c.count;E++)f[m*c.count+E]=c.getX(E)+m*l}const g=new bt;return g.setAttribute("position",new Pt(u,3)),g.setAttribute("normal",new Pt(d,3)),g.setIndex(new od(f,1)),g}static fitCropToGround(e,t){e.updateMatrixWorld(!0);const i=new D;e.traverse(n=>{const r=n,a=r.userData.cropBasePositions,o=r.userData.cropVerticesPerClump;if(!r.isMesh||!a||!o)return;const c=r.geometry.getAttribute("position"),l=new Ye().copy(r.matrixWorld).invert();for(let h=0;h<c.count;h+=o){i.set(a[h*3],0,a[h*3+2]).applyMatrix4(r.matrixWorld),i.y=t(i.x,i.z),i.applyMatrix4(l);for(let u=h;u<h+o;u++)c.setY(u,a[u*3+1]+i.y)}c.needsUpdate=!0,r.geometry.computeBoundingBox(),r.geometry.computeBoundingSphere()})}static paint(e,t){e.traverse(i=>{const n=i,r=n.userData;if(!n.isMesh||r?.emissive)return;const a=n.material;a?.color&&a.color.set(t)})}static build(e,t){const i=e.kind==="building"?jf(e.floors??n0,e.windows,e.witnessSide,e.occupiedFloor):e.kind==="tree"?Qf():e.kind==="crop"?tp():e.kind==="mound"?ip():e.kind==="streetlight"?np(t):e.kind==="vehicle"?sp(t,e.windows,e.witnessSide):e.kind==="aircraft"?hp():e.kind==="entity"?cp():Vu();e.color&&this.paint(i,e.color);const n=this.scaleFor(e),r=new ri;return i.name=ci.BODY_NAME,i.scale.copy(n),r.add(i),e.headingDeg!==void 0&&(r.rotation.y=-e.headingDeg*Jl),this.addLights(r,e.lights),e.kind==="aircraft"&&this.exemptFromFog(r),r}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:eh(t.widthM,i.widthM),t.heightM===void 0?1:eh(t.heightM,i.heightM),t.lengthM===void 0?1:eh(t.lengthM,i.lengthM))}static naturalSize(e,t){const i=e==="building"?Math.max(1,(t??n0)+1):0,n=`${e}:${i}`,r=rp.get(n);if(r)return r;const a=e==="building"?jf(i-1,void 0,void 0,void 0):e==="tree"?Qf():e==="crop"?tp():e==="mound"?ip():e==="streetlight"?np(!1):e==="vehicle"?sp(!1,void 0,void 0):e==="aircraft"?hp():e==="entity"?cp():Vu(),o=new un().setFromObject(a),c={widthM:o.max.x-o.min.x,heightM:o.max.y-o.min.y,lengthM:o.max.z-o.min.z};return this.dispose(a),rp.set(n,c),c}static usesModel(e){return e.model!==void 0&&!(e.witnessSide!==void 0&&Zp(e.kind))}static applyModel(e,t,i,n={}){const r=this.bodyOf(e),a=new ri;a.name=ci.BODY_NAME,i.rotation.y=-(n.headingOffsetDeg??0)*Jl,i.updateMatrixWorld(!0);const o=new un().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=ap(t.sizeM,c)??ap(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 We&&(u.castShadow=!0,u.receiveShadow=!0)}),a.add(i),r.parent?(r.parent.add(a),r.removeFromParent()):e.add(a),this.dispose(r)}static sizeOf(e){const t=this.naturalSize(e.kind,e.floors);return{widthM:e.sizeM?.widthM??t.widthM,lengthM:e.sizeM?.lengthM??t.lengthM,heightM:e.sizeM?.heightM??t.heightM}}static exemptFromFog(e){e.traverse(t=>{if(!(t instanceof We))return;const i=t.material;i.fog=!1,i.needsUpdate=!0})}static addLights(e,t){for(const i of t??[]){const n=K5(i.color),r=Vt(e,new di(Zf,8,6),n,i.offsetM.y,!0);r.position.set(i.offsetM.x,i.offsetM.y,i.offsetM.z),r.userData={emissive:!0,lightId:i.id,lightColor:n},r.visible=!1}}static setLights(e,t,i,n,r=0){if(!t||t.length===0)return;const a=new Map(t.map(c=>[c.id,c])),o=Math.max(1,n*q5/Zf);for(const c of e.children){if(!(c instanceof We))continue;const l=c.userData.lightId;if(!l)continue;const h=a.get(l);if(!h)continue;const u=r>0?Jp(h,i,i+r):S1(h,i)?1:0;c.visible=u>0;const d=c.material,f=c.userData.lightColor;if(f){const p=r>0?u*Y5*(h.intensity??1):u;d.color.setRGB(f[0]*p,f[1]*p,f[2]*p)}c.scale.setScalar(o)}}static setLit(e,t,i){const n=t==="streetlight"?i?Mg:vg:i?_g:xg;e.traverse(r=>{const a=r.userData;!(r instanceof We)||!a.emissive||a.lightId||r.material.color.setRGB(...n)})}static dispose(e){e.traverse(t=>{if(!(t instanceof We))return;t.geometry.dispose();const i=t.material;for(const n of Array.isArray(i)?i:[i])n.dispose()})}}const ih="https://ufoathome.org/models/index.json";class ob{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??cb()}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,...r})=>({...r,url:new URL(n,e).href})):void 0}catch{return}}}function cb(){const s=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return s&&s!==ih?[s,ih]:[ih]}const lb=[{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 ob}];async function hb(s){const{GLTFLoader:e}=await gc(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(s,r=>i(r.scene),void 0,r=>n(new Error(`Could not load 3D model ${s}: ${r instanceof Error?r.message:String(r)}`)))})}const Tg=2,ub=5,db=2048;class sn{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;
|
|
6158
|
+
`,transparent:!0,blending:Gi,depthWrite:!1,side:It,fog:!1}),this.object=new We(new di(Si.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,r,a){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=r.cover,o.uIceHeight.value=r.layerHeight,this.show(this.everDisplayed),this.requestMap(t,a)}requestMap(e,t){if(!(!(Math.abs(e-this.mappedAltitudeDeg)<Si.ALTITUDE_STEP_DEG)||!(Math.abs(t-this.mappedAlignment)<Si.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)<Si.LEAP_ALTITUDE_DEG)||!(Math.abs(t-this.pendingAlignment)<Si.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)<Si.ALTITUDE_STEP_DEG&&Math.abs(t-this.pendingAlignment)<Si.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?Si.URGENT_BUDGET_MS:Si.BUDGET_MS;do this.sky.trace(Si.RAYS_PER_BATCH);while(this.sky.tracedRays<Si.RAYS&&performance.now()-t<i);if(this.sky.tracedRays>=Si.RAYS){this.publish(),this.tracing=!1,this.mappedAltitudeDeg=this.pendingAltitudeDeg,this.mappedAlignment=this.pendingAlignment;const r=this.next;r&&this.requestMap(r.sourceAltitudeDeg,r.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]=Zn.toHalfFloat(t[n]),this.texels[i+1]=Zn.toHalfFloat(t[n+1]),this.texels[i+2]=Zn.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 ei{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=ei.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(ei.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=ei.MAX_CONCURRENT*ei.SEGMENTS*ei.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const t=new bt;t.setAttribute("position",new ot(this.positions,3)),t.setAttribute("color",new ot(this.colors,3)),t.setDrawRange(0,0),this.object=new We(t,new Ji({vertexColors:!0,transparent:!0,blending:Gi,depthWrite:!1,fog:!1,side:on})),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=Ys.aliveAt(this.meteors,e).slice(0,ei.MAX_CONCURRENT);let n=0;for(const{meteor:r,progress:a}of i){const o=this.radiantOf(r);if(!o)continue;const c=ni(o.altitudeDeg,o.azimuthDeg,1),[l,h]=this.basisAround(c),u=r.fromRadiantDeg+a*r.lengthDeg,d=Math.max(r.fromRadiantDeg,u-r.lengthDeg*.6),f=Math.min(1,(1-a)*2.5),p=this.turn(l,h,r.bearingDeg),v=(.15+.85*r.brightness)*f,m=y=>v*y**1.6,g=y=>this.onSphere(c,p,d+(u-d)*y),b=y=>ei.RADIUS*((ei.MIN_HALF_WIDTH_DEG+ei.BRIGHT_HALF_WIDTH_DEG*r.brightness*y)*Math.PI/180);for(let y=1;y<ei.POINTS;y++){const _=(y-1)/ei.SEGMENTS,E=y/ei.SEGMENTS;n=this.pushRibbon(n,g(_),g(E),b(_),b(E),m(_),m(E))}}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,r]=this.basisAround(i),a=this.turn(n,r,e.bearingDeg),o=this.onSphere(i,a,e.fromRadiantDeg+e.lengthDeg/2),c=Math.hypot(o.x,o.y,o.z)||1;return{altitudeDeg:Math.asin(o.y/c)*180/Math.PI,azimuthDeg:(Math.atan2(o.x,-o.z)*180/Math.PI+360)%360}}radiantOf(e){return e.radiant?e.radiant:this.radiantAltitudeDeg>0?{altitudeDeg:this.radiantAltitudeDeg,azimuthDeg:this.radiantAzimuthDeg}:void 0}pushRibbon(e,t,i,n,r,a,o){const c=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(i,t))));for(let l=0;l<ei.ACROSS-1;l++){const h=l-1,u=l,d=this.across(t,c,n,h),f=this.across(i,c,r,h),p=this.across(t,c,n,u),v=this.across(i,c,r,u),m=(g,b)=>g===0?b:0;e=this.push(e,d,m(h,a)),e=this.push(e,f,m(h,o)),e=this.push(e,p,m(u,a)),e=this.push(e,f,m(h,o)),e=this.push(e,v,m(u,o)),e=this.push(e,p,m(u,a))}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 r=Math.max(0,Math.min(1,i));return this.colors[n]=r*.9,this.colors[n+1]=r*.95,this.colors[n+2]=r,e+1}turn(e,t,i){const n=i*Math.PI/180,r=Math.cos(n),a=Math.sin(n);return{x:e.x*r+t.x*a,y:e.y*r+t.y*a,z:e.z*r+t.z*a}}onSphere(e,t,i){const n=i*Math.PI/180,r=Math.cos(n),a=Math.sin(n);return{x:(e.x*r+t.x*a)*ei.RADIUS,y:(e.y*r+t.y*a)*ei.RADIUS,z:(e.z*r+t.z*a)*ei.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 Jl=Math.PI/180;function Vt(s,e,t,i,n=!1){const r=n?new Ji({color:new oe(...t)}):new eo({color:new oe(...t)}),a=new We(e,r);return a.position.y=i,a.userData={emissive:n},a.castShadow=!n,a.receiveShadow=!n,s.add(a),a}const Zf=.25,q5=.002,Y5=20;function K5(s){const e=/^#([0-9a-f]{6})$/i.exec(s);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 vg=[.32,.32,.3],Mg=[1,.85,.5],xg=[.25,.25,.25],_g=[1,.97,.85],$5=[.55,.68,.72],En=.03,wn=.05,yg={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 wi(s,e){return s?.[e]}function An(s,e,t,i,n,r,a,o){if(o===void 0)return;const c=new eo({color:new oe(...$5),transparent:!0,opacity:o/100}),l=new We(new ji(e,t,i),c);l.position.set(n,r,a),s.add(l)}const qi=.05,jl=[.6,.58,.53],Jf=[.5,.5,.48];function Fr(s,e,t,i,n,r,a,o){const c=new eo({color:new oe(...o),side:It}),l=new We(new ji(e,t,i),c);l.position.set(n,r,a),s.add(l)}function Z5(s,e,t,i,n,r,a,o,c){const l=(i-r)/2,h=(p,v,m,g)=>{p<=0||(e?Fr(s,p,v,qi,m,o+g,a,c):Fr(s,qi,v,p,a,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,r,d+m/2,0),d=p.center+p.main/2}const f=t/2-d;h(f,r,d+f/2,0)}function Sg(s,e,t,i,n,r,a,o,c,l){const h=(i+n)/2,u=n-i,d=(f,p,v,m)=>{f.length===0?p?Fr(s,v,u,qi,0,h,m,jl):Fr(s,qi,u,v,m,h,0,jl):Z5(s,p,v,u,f,r,m,h,jl)};d(a,!0,e*2,-t+qi),d(o,!0,e*2,t-qi),d(c,!1,t*2,-e+qi),d(l,!1,t*2,e-qi),Fr(s,e*2,qi,t*2,0,i+qi,0,Jf),Fr(s,e*2,qi,t*2,0,n-qi,0,Jf)}function Bu(s,e,t,i){switch(s){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:-Tn};case"front-right":return{x:e-i,z:-Tn};case"behind-left":return{x:-(e-i),z:Tn};case"behind-right":return{x:e-i,z:Tn}}}function bg(s,e,t,i,n,r,a){const o=Vu();o.scale.setScalar(i),o.rotation.y=yg[e];const{x:c,z:l}=Bu(e,n,r,a);o.position.set(c,t,l),s.add(o)}const Hu=6,Gu=6,vs=3,ya=1.4,Sa=vs*.5,Eg=1.2,wg=.35,J5=.75,j5=1.6;function jf(s,e,t,i){const n=new ri,r=Math.max(1,s+1),a=r*vs;Vt(n,new ji(Hu,a,Gu),[.55,.54,.5],a/2);const o=Hu/2,c=Gu/2;for(let l=0;l<r;l++){const h=l*vs+vs/2;An(n,ya,Sa,wn,0,h,-c-En,wi(e,"front")),An(n,ya,Sa,wn,0,h,c+En,wi(e,"behind")),An(n,wn,Sa,ya,-o-En,h,0,wi(e,"left")),An(n,wn,Sa,ya,o+En,h,0,wi(e,"right"))}if(t){const l=Math.min(Math.max(i??0,0),r-1);bg(n,t,l*vs,.72,o,c,Eg);const h=u=>wi(e,u)!==void 0?[{main:ya,center:0}]:[];Sg(n,o,c,l*vs,(l+1)*vs,Sa,h("front"),h("behind"),h("left"),h("right"))}return n}function Qf(){const s=new ri;return Vt(s,new is(.15,.22,2,8),[.32,.22,.14],1),Vt(s,new Qa(1.4,3,8),[.16,.32,.14],3.5),s}const ep=.275,Q5=.35,eb=.9,tb=34,ib=8,nb=1.4;function tp(){const s=new ri,e=new di(ep,7,3,0,Math.PI*2,0,Math.PI/2);e.scale(1,Q5/ep,1);const t=ci.repeatOnGrid(e,tb,eb,ib,nb),i=Vt(s,t,[.26,.28,.22],0);return i.castShadow=!1,i.userData.cropBasePositions=t.getAttribute("position").array.slice(),i.userData.cropVerticesPerClump=e.getAttribute("position").count,e.dispose(),s}function ip(){const s=new ri,e=new di(1,7,3,0,Math.PI*2,0,Math.PI/2);return Vt(s,e,[.38,.36,.32],0),s}function np(s){const e=new ri;return Vt(e,new is(.05,.08,5,8),[.28,.28,.3],2.5),Vt(e,new di(.25,12,8),s?Mg:vg,5.1,!0),e}const sb=[.08,.08,.08],ms=.8,Pr=1,yn=1.7,Ql=.6,Ls=.4,Qo=1.2,Dr=.7,Tn=.5,rb=yn;function sp(s,e,t){const i=new ri;Vt(i,new ji(1.8,1.4,4.2),[.45,.14,.14],.7),Vt(i,new ji(ms*2,Ql,Pr*2),[.4,.12,.12],yn);for(const r of[-1.4,1.4])for(const a of[-.95,.95]){const o=Vt(i,new is(.4,.4,.3,12),sb,.4);o.rotation.z=Math.PI/2,o.position.x=a,o.position.z=r}const n=s?_g:xg;for(const r of[-.7,.7])Vt(i,new di(.15,8,6),n,.7,!0).position.set(r,.7,-2.1);if(An(i,Qo,Ls,wn,0,yn,-Pr-En,wi(e,"front")),An(i,Qo,Ls,wn,0,yn,Pr+En,wi(e,"behind")),An(i,wn,Ls,Dr,-ms-En,yn,-Tn,wi(e,"front-left")),An(i,wn,Ls,Dr,-ms-En,yn,Tn,wi(e,"behind-left")),An(i,wn,Ls,Dr,ms+En,yn,-Tn,wi(e,"front-right")),An(i,wn,Ls,Dr,ms+En,yn,Tn,wi(e,"behind-right")),t){bg(i,t,J5,.5,ms,Pr,wg);const r=(c,l)=>{const h=[];return wi(e,c)!==void 0&&h.push({main:Dr,center:-Tn}),wi(e,l)!==void 0&&h.push({main:Dr,center:Tn}),h},a=wi(e,"front")!==void 0?[{main:Qo,center:0}]:[],o=wi(e,"behind")!==void 0?[{main:Qo,center:0}]:[];Sg(i,ms,Pr,yn-Ql/2,yn+Ql/2,Ls,a,o,r("front-left","behind-left"),r("front-right","behind-right"))}return i}const rp=new Map;function ap(s,e){if(!s)return;const t=[[s.lengthM,e.lengthM],[s.heightM,e.heightM],[s.widthM,e.widthM]];for(const[i,n]of t)if(i!==void 0&&n>1e-6)return i/n}function eh(s,e){return e>1e-6?s/e:1}const Ag=[.95,.9,.82],op=[.72,.74,.78];function cp(){const s=new ri;Vt(s,new is(.25,.3,1.5,10),op,.75),Vt(s,new di(.26,10,8),op,1.74);const e=Vt(s,new Qa(.07,.16,8),Ag,1.74);return e.rotation.x=-Math.PI/2,e.position.z=-.22,s}function Vu(){const s=new ri;Vt(s,new is(.25,.3,1.5,10),[.3,.3,.35],.75),Vt(s,new di(.22,10,8),[.62,.52,.46],1.72);const e=Vt(s,new Qa(.07,.16,8),Ag,1.72);return e.rotation.x=-Math.PI/2,e.position.z=-.2,s}const ab=17,lp=18.5,th=[.16,.16,.18];function hp(){const s=new ri,e=Vt(s,new is(1.8,1.8,lp*2,10),th,0);e.rotation.x=Math.PI/2,Vt(s,new ji(ab*2,.5,4.5),th,0);const t=Vt(s,new ji(.4,5.5,4),th,3);return t.position.z=-lp+2,s}class ci{static groundUnderFootprint(e,t,i,n,r,a=0){const o=ci.sizeOf(e);if(a>o.heightM)return r(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,r(m,g))}}return Number.isFinite(u)?u:r(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"?Bu(t,ms,Pr,wg):Bu(t,Hu/2,Gu/2,Eg),r=e.kind==="vehicle"?rb:(e.occupiedFloor??0)*vs+j5,a=(e.headingDeg??0)-yg[t]/Jl,o=this.scaleFor(e);return{x:i*o.x,z:n*o.z,eyeY:r*o.y,headingDeg:a}}static BODY_NAME="decor-body";static bodyOf(e){return e.getObjectByName(ci.BODY_NAME)??e}static repeatOnGrid(e,t,i,n,r){const a=e.getAttribute("position"),o=e.getAttribute("normal"),c=e.getIndex();if(!c)throw new Error("repeatOnGrid needs an indexed geometry");const l=a.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)*r)/2;let m=0;for(let b=0;b<n;b++)for(let y=0;y<t;y++,m++){const _=v+b*r,E=p+y*i;for(let w=0;w<l;w++){const R=(m*l+w)*3;u[R]=a.getX(w)+_,u[R+1]=a.getY(w),u[R+2]=a.getZ(w)+E,d[R]=o.getX(w),d[R+1]=o.getY(w),d[R+2]=o.getZ(w)}for(let w=0;w<c.count;w++)f[m*c.count+w]=c.getX(w)+m*l}const g=new bt;return g.setAttribute("position",new Pt(u,3)),g.setAttribute("normal",new Pt(d,3)),g.setIndex(new od(f,1)),g}static fitCropToGround(e,t){e.updateMatrixWorld(!0);const i=new D;e.traverse(n=>{const r=n,a=r.userData.cropBasePositions,o=r.userData.cropVerticesPerClump;if(!r.isMesh||!a||!o)return;const c=r.geometry.getAttribute("position"),l=new Ye().copy(r.matrixWorld).invert();for(let h=0;h<c.count;h+=o){i.set(a[h*3],0,a[h*3+2]).applyMatrix4(r.matrixWorld),i.y=t(i.x,i.z),i.applyMatrix4(l);for(let u=h;u<h+o;u++)c.setY(u,a[u*3+1]+i.y)}c.needsUpdate=!0,r.geometry.computeBoundingBox(),r.geometry.computeBoundingSphere()})}static paint(e,t){e.traverse(i=>{const n=i,r=n.userData;if(!n.isMesh||r?.emissive)return;const a=n.material;a?.color&&a.color.set(t)})}static build(e,t){const i=e.kind==="building"?jf(e.floors??n0,e.windows,e.witnessSide,e.occupiedFloor):e.kind==="tree"?Qf():e.kind==="crop"?tp():e.kind==="mound"?ip():e.kind==="streetlight"?np(t):e.kind==="vehicle"?sp(t,e.windows,e.witnessSide):e.kind==="aircraft"?hp():e.kind==="entity"?cp():Vu();e.color&&this.paint(i,e.color);const n=this.scaleFor(e),r=new ri;return i.name=ci.BODY_NAME,i.scale.copy(n),r.add(i),e.headingDeg!==void 0&&(r.rotation.y=-e.headingDeg*Jl),this.addLights(r,e.lights),e.kind==="aircraft"&&this.exemptFromFog(r),r}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:eh(t.widthM,i.widthM),t.heightM===void 0?1:eh(t.heightM,i.heightM),t.lengthM===void 0?1:eh(t.lengthM,i.lengthM))}static naturalSize(e,t){const i=e==="building"?Math.max(1,(t??n0)+1):0,n=`${e}:${i}`,r=rp.get(n);if(r)return r;const a=e==="building"?jf(i-1,void 0,void 0,void 0):e==="tree"?Qf():e==="crop"?tp():e==="mound"?ip():e==="streetlight"?np(!1):e==="vehicle"?sp(!1,void 0,void 0):e==="aircraft"?hp():e==="entity"?cp():Vu(),o=new un().setFromObject(a),c={widthM:o.max.x-o.min.x,heightM:o.max.y-o.min.y,lengthM:o.max.z-o.min.z};return this.dispose(a),rp.set(n,c),c}static usesModel(e){return e.model!==void 0&&!(e.witnessSide!==void 0&&Zp(e.kind))}static applyModel(e,t,i,n={}){const r=this.bodyOf(e),a=new ri;a.name=ci.BODY_NAME,i.rotation.y=-(n.headingOffsetDeg??0)*Jl,i.updateMatrixWorld(!0);const o=new un().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=ap(t.sizeM,c)??ap(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 We&&(u.castShadow=!0,u.receiveShadow=!0)}),a.add(i),r.parent?(r.parent.add(a),r.removeFromParent()):e.add(a),this.dispose(r)}static sizeOf(e){const t=this.naturalSize(e.kind,e.floors);return{widthM:e.sizeM?.widthM??t.widthM,lengthM:e.sizeM?.lengthM??t.lengthM,heightM:e.sizeM?.heightM??t.heightM}}static exemptFromFog(e){e.traverse(t=>{if(!(t instanceof We))return;const i=t.material;i.fog=!1,i.needsUpdate=!0})}static addLights(e,t){for(const i of t??[]){const n=K5(i.color),r=Vt(e,new di(Zf,8,6),n,i.offsetM.y,!0);r.position.set(i.offsetM.x,i.offsetM.y,i.offsetM.z),r.userData={emissive:!0,lightId:i.id,lightColor:n},r.visible=!1}}static setLights(e,t,i,n,r=0){if(!t||t.length===0)return;const a=new Map(t.map(c=>[c.id,c])),o=Math.max(1,n*q5/Zf);for(const c of e.children){if(!(c instanceof We))continue;const l=c.userData.lightId;if(!l)continue;const h=a.get(l);if(!h)continue;const u=r>0?Jp(h,i,i+r):S1(h,i)?1:0;c.visible=u>0;const d=c.material,f=c.userData.lightColor;if(f){const p=r>0?u*Y5*(h.intensity??1):u;d.color.setRGB(f[0]*p,f[1]*p,f[2]*p)}c.scale.setScalar(o)}}static setLit(e,t,i){const n=t==="streetlight"?i?Mg:vg:i?_g:xg;e.traverse(r=>{const a=r.userData;!(r instanceof We)||!a.emissive||a.lightId||r.material.color.setRGB(...n)})}static dispose(e){e.traverse(t=>{if(!(t instanceof We))return;t.geometry.dispose();const i=t.material;for(const n of Array.isArray(i)?i:[i])n.dispose()})}}const ih="https://ufoathome.org/models/index.json";class ob{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??cb()}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,...r})=>({...r,url:new URL(n,e).href})):void 0}catch{return}}}function cb(){const s=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return s&&s!==ih?[s,ih]:[ih]}const lb=[{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 ob}];async function hb(s){const{GLTFLoader:e}=await gc(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(s,r=>i(r.scene),void 0,r=>n(new Error(`Could not load 3D model ${s}: ${r instanceof Error?r.message:String(r)}`)))})}const Tg=2,ub=5,db=2048;class sn{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;
|
|
6159
6159
|
`+n.vertexShader,n.vertexShader=n.vertexShader.replace("#include <project_vertex>",`#include <project_vertex>
|
|
6160
6160
|
cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let r=`varying vec3 cloudPoint;
|
|
6161
6161
|
`,a="";t.forEach((o,c)=>{const l=`cloud${c}_`;for(const[h,u]of Object.entries(o.uniforms))n.uniforms[l+h]=u;r+=Jy(l),a+=`diffuseColor.a *= ${l}transmissionAt(normalize(cloudPoint), length(cloudPoint));
|
|
6162
|
-
`}),n.fragmentShader=r+n.fragmentShader,n.fragmentShader=n.fragmentShader.replace("#include <opaque_fragment>",a+"#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 Ye;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,r]of this.meshes)i.has(n)||(this.dispose(r),this.meshes.delete(n),this.signatures.delete(n),this.extents.delete(n));for(const n of e){let r=this.meshes.get(n.sourceId);r||(r=new We(new dn(1,1,sn.SEGMENTS,sn.SEGMENTS),new Zi({transparent:!0,depthWrite:!1,depthTest:!0,fog:!1,toneMapped:!1})),this.configureCloudMaterial(r.material),r.frustumCulled=!1,r.layers.set(Tg),this.scene.add(r),this.meshes.set(n.sourceId,r)),r.renderOrder=ub+n.renderOrder,r.visible=!n.hidden&&n.shape.transparency<1,r.visible&&this.paint(r,n,t)}}place(e,t,i){const n=this.frame;if(n)for(const r of this.placed){const a=this.meshes.get(r.sourceId);if(!a||!a.visible)continue;const o=this.extents.get(r.sourceId);if(!o)continue;const{bounds:c}=r.shape;let l=c.x+c.width/2,h=c.y+c.height/2,u=!0;if(r.aim){const d=i(sn.directionOf(r.aim,this.direction));d&&Math.abs(d.ndcX)<sn.FURTHEST_NDC&&Math.abs(d.ndcY)<sn.FURTHEST_NDC?(l=(d.ndcX+1)/2*n.canvasWidthPx,h=(1-d.ndcY)/2*n.canvasHeightPx):u=!1}u?this.curve(a,e,t,n,o,l,h,r.distanceM):this.flat(a,e,n,o,r.distanceM)}}static FURTHEST_NDC=4;curve(e,t,i,n,r,a,o,c){const l=a-r.width/2,h=o-r.height/2,u=e.geometry.attributes.position,d=sn.SEGMENTS;let f=0;for(let p=0;p<=d;p++){const v=h+p/d*r.height;for(let m=0;m<=d;m++){const g=l+m/d*r.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(yt.sizeMAt(c,n.projection.pxToDeg(r.width)),yt.sizeMAt(c,n.projection.pxToDeg(r.height)),1)}flat(e,t,i,n,r){const a=e.geometry.attributes.position,o=sn.SEGMENTS,c=yt.sizeMAt(r,i.projection.pxToDeg(n.width)),l=yt.sizeMAt(r,i.projection.pxToDeg(n.height));this.up.set(0,1,0).applyQuaternion(t.quaternion),this.centre.copy(t.position).addScaledVector(this.direction,r),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),a.setXYZ(h++,this.vertex.x,this.vertex.y,this.vertex.z)}}a.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,r=Xa.paintExtent(n);this.extents.set(t.sourceId,r);const a=sn.signatureOf(n,i);if(this.signatures.get(t.sourceId)===a&&e.material.map)return;this.signatures.set(t.sourceId,a);const o=Math.min(i.scale,db/Math.max(r.width,r.height,1)),c=Math.max(1,Math.ceil(r.width*o)),l=Math.max(1,Math.ceil(r.height*o)),h=e.material.map,u=h?.image??document.createElement("canvas"),d=u.width!==c||u.height!==l;d&&(u.width=c,u.height=l);const f=u.getContext("2d");if(!f)return;f.clearRect(0,0,c,l);const p=new Xa(f);if(p.setStarPoints(i.starPoints),p.setRoll(i.rollRad),p.paintInto(n,r,o),h&&!d){h.needsUpdate=!0;return}h?.dispose();const v=new Ln(u);v.colorSpace=Pi,v.minFilter=at,v.generateMipmaps=!1,e.material.map=v,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 Rg=3,ec=800,ba=Math.PI/180;class Hs{constructor(e,t,i=Hs.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,r]of this.meshes)i.has(n)||(this.dispose(r),this.meshes.delete(n),this.signatures.delete(n));for(const[n,r]of this.images){const a=e.find(o=>o.id===n);a&&a.src===r.texture.userData.src||(r.texture.dispose(),this.images.delete(n))}for(const n of e){const r=this.images.get(n.id);if(!r){this.load(n);continue}this.build(n,r)}}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 r=this.images.get(e.id),a=r?r.width/r.height:1,o=Math.tan(e.registration.fovDeg/2*ba),c=o*a;return n.set((t*2-1)*c,(1-i*2)*o,-1).normalize(),n.applyQuaternion(Hs.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 r=this.references.find(a=>a.id===e.id);if(!r||r.src!==t){n.texture.dispose();return}n.texture.userData.src=t,this.images.set(e.id,n),this.build(r,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 oi(i);return n.flipY=!1,n.colorSpace=Pi,n.minFilter=at,n.magFilter=at,n.generateMipmaps=!1,n.needsUpdate=!0,{texture:n,width:i.width,height:i.height}}build(e,t){const i=Hs.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 We(Hs.geometryOf(e,t),new Zi({map:t.texture,transparent:!0,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1})),e.kind==="panorama"&&(n.material.side=It),n.frustumCulled=!1,n.layers.set(Rg),n.userData.id=e.id,n.quaternion.copy(Hs.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 a=new di(ec,64,32,Math.PI/2,Math.PI*2),o=a.attributes.uv;for(let c=0;c<o.count;c++)o.setX(c,1-o.getX(c));return o.needsUpdate=!0,a}const i=2*ec*Math.tan(e.registration.fovDeg/2*ba),n=i*(t.width/Math.max(t.height,1)),r=new dn(n,i);return r.translate(0,0,-ec),r}static orientation(e){const{headingDeg:t,pitchDeg:i,rollDeg:n}=e.registration,r=new At;return r.rotation.set(i*ba,-t*ba,-(n??0)*ba,"YXZ"),r.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:r,fovDeg:a}=e.registration;return[e.kind,e.src,t.width,t.height,i,n,r??0,a].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 Ze{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=Ze.WAVELENGTHS_NM.length,i=e.aerosolOpticalDepth??Ze.DEFAULT_AEROSOL_OPTICAL_DEPTH,n=e.ozoneDobson??Ze.DEFAULT_OZONE_DOBSON;this.rayleighScattering=new Float64Array(t),this.aerosolScattering=new Float64Array(t),this.aerosolExtinction=new Float64Array(t),this.ozoneAbsorption=new Float64Array(t);const r=n*2687e17/Ze.OZONE_HALF_WIDTH_M;for(let a=0;a<t;a++){const o=Ze.WAVELENGTHS_NM[a];this.rayleighScattering[a]=Ze.rayleighAt(o);const c=i/Ze.AEROSOL_SCALE_HEIGHT_M*(o/550)**-1.3;this.aerosolExtinction[a]=c,this.aerosolScattering[a]=c*Ze.AEROSOL_SINGLE_SCATTERING_ALBEDO,this.ozoneAbsorption[a]=Ze.OZONE_CROSS_SECTION[a]*1e-25*r}}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)/Ze.RAYLEIGH_SCALE_HEIGHT_M)}static aerosolDensity(e){return Math.exp(-Math.max(e,0)/Ze.AEROSOL_SCALE_HEIGHT_M)}static ozoneDensity(e){return Math.max(0,1-Math.abs(e-Ze.OZONE_PEAK_ALTITUDE_M)/Ze.OZONE_HALF_WIDTH_M)}static rayleighPhase(e){return 3/(16*Math.PI)*(1+e*e)}static aerosolPhase(e,t=Ze.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 rt{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){return e*(1/t-1)**(1/rt.RESPONSE_EXPONENT)}static get ADAPTATION_EXPONENT(){const e=rt.anchoredSemiSaturation(rt.DAYLIGHT_ANCHOR_CD_M2,rt.DAYLIGHT_ANCHOR_RESPONSE),t=rt.anchoredSemiSaturation(rt.NIGHT_ANCHOR_CD_M2,rt.NIGHT_ANCHOR_RESPONSE);return Math.log(e/t)/Math.log(rt.DAYLIGHT_ANCHOR_CD_M2/rt.NIGHT_ANCHOR_CD_M2)}static ROD_HALF_LUMINANCE_CD_M2=.04;static SCOTOPIC_TINT=[.853,.995,1.483];static get SEMI_SATURATION_SCALE(){return rt.anchoredSemiSaturation(rt.DAYLIGHT_ANCHOR_CD_M2,rt.DAYLIGHT_ANCHOR_RESPONSE)/rt.DAYLIGHT_ANCHOR_CD_M2**rt.ADAPTATION_EXPONENT}static rodShare(e){return rt.ROD_HALF_LUMINANCE_CD_M2/(rt.ROD_HALF_LUMINANCE_CD_M2+Math.max(e,0))}static semiSaturation(e){return rt.SEMI_SATURATION_SCALE*Math.max(e,1e-9)**rt.ADAPTATION_EXPONENT}static response(e,t){const i=rt.RESPONSE_EXPONENT,n=Math.max(e,0)**i;return n/(n+rt.semiSaturation(t)**i)}static displayOf(e,t,i,n=rt.rodShare(i)){const r=(1-n)*e[1]+n*t,a=rt.response(r,i),[o,c,l]=li.linearSrgbOf(e),h=Math.max(e[1],1e-12),u=rt.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)*a;return[f(o,u[0]),f(c,u[1]),f(l,u[2])]}}class ze{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 Qr;camera=new Ts(-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 ui(ze.TRANSMITTANCE_WIDTH,ze.TRANSMITTANCE_HEIGHT,{count:4,type:$t,minFilter:at,magFilter:at,depthBuffer:!1}),this.multiple=new ui(ze.MULTIPLE_SIZE,ze.MULTIPLE_ROWS,{count:4,type:Ai,minFilter:Dt,magFilter:Dt,depthBuffer:!1});const t=()=>new ui(ze.SKY_VIEW_WIDTH,ze.SKY_VIEW_HEIGHT,{type:Ai,minFilter:Dt,magFilter:Dt,depthBuffer:!1});this.sunView=t(),this.moonView=t();const i=ze.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]}},r=(a,o={})=>new Lm({glslVersion:Rc,uniforms:{...i,...n,...o},vertexShader:ze.VERTEX,fragmentShader:a,depthTest:!1,depthWrite:!1});this.transmittanceMaterial=r(ze.TRANSMITTANCE_FRAGMENT),this.multipleMaterial=r(ze.MULTIPLE_FRAGMENT),this.skyViewMaterial=r(ze.SKY_VIEW_FRAGMENT,{uObserverRadius:{value:Ze.GROUND_RADIUS_M+2},uSourceMu:{value:1}}),this.quad=new We(new dn(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>=ze.MULTIPLE_ROWS)}setMedium(e){const t=[e.rayleighScattering,e.aerosolScattering,e.aerosolExtinction,e.ozoneAbsorption].map(n=>Array.from(n,r=>r.toPrecision(6)).join(",")).join("|");if(t===this.mediumKey)return;this.abandonBuilding(),this.releaseAdopted(),this.mediumKey=t;const i=(n,r)=>{const a=this.transmittanceMaterial.uniforms[n].value;for(let o=0;o<4;o++)a[o].set(r[o*4]??0,r[o*4+1]??0,r[o*4+2]??0,r[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=ze.shared.get(this.mediumKey);if(t&&t!=="building")return this.adopt(t),!0;if(t==="building"&&!this.building)return!1;t||(ze.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 r=ze.MULTIPLE_SIZE,a=ze.MULTIPLE_BLOCK;for(;n>0&&this.multipleRows<ze.MULTIPLE_ROWS;n--)this.multiple.scissor.set(this.multipleColumn,this.multipleRows,a,1),this.multiple.scissorTest=!0,this.draw(this.multipleMaterial,this.multiple),this.multipleColumn+=a,this.multipleColumn>=r&&(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?ze.shared.set(e,{transmittance:t,multiple:i}):ze.shared.delete(e)}catch{ze.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=(r,a,o,c)=>{const l=new tr(r,a,o,xi,c?$t:Ai);return l.minFilter=l.magFilter=c?at:Dt,l.needsUpdate=!0,l},i=e.transmittance.map(r=>t(r,ze.TRANSMITTANCE_WIDTH,ze.TRANSMITTANCE_HEIGHT,!0)),n=e.multiple.map(r=>t(r,ze.MULTIPLE_SIZE,ze.MULTIPLE_ROWS,!1));i.forEach((r,a)=>this.tableUniforms[`uT${a}`].value=r),n.forEach((r,a)=>this.tableUniforms[`uM${a}`].value=r),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,ze.shared.get(this.mediumKey)==="building"&&ze.shared.delete(this.mediumKey))}renderSkyViews(e,t,i){if(!this.ready)return;const n=this.renderer.getRenderTarget(),r=this.skyViewMaterial.uniforms;r.uObserverRadius.value=Ze.GROUND_RADIUS_M+Math.max(e,2),r.uSourceMu.value=Math.sin(t*Math.PI/180),this.draw(this.skyViewMaterial,this.sunView),r.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=Ze.GROUND_RADIUS_M+Math.max(e,2),r=Ze.GROUND_RADIUS_M,a=Math.acos(Math.min(Math.sqrt(Math.max(n*n-r*r,0))/n,1)),o=Math.PI-a,c=t<o?.5*(1-Math.sqrt(Math.max(1-t/o,0))):.5+.5*Math.sqrt(Math.min((t-o)/a,1));return{u:Math.min(Math.max(Math.abs(i)/Math.PI,0),1),v:c}}async readTable(e,t){if(e==="multiple"){const r=new Float32Array(this.multiple.width*this.multiple.height*4);return await this.renderer.readRenderTargetPixelsAsync(this.multiple,0,0,this.multiple.width,this.multiple.height,r,void 0,t),r}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,r=>Zn.fromHalfFloat(r))}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 r=e();return Ze.WAVELENGTHS_NM.forEach((a,o)=>{r[Math.floor(o/4)].setComponent(o%4,i(a)*n*Ze.WAVELENGTH_STEP_NM*Ze.SOLAR_IRRADIANCE[o])}),r};return{uRayleigh:{value:e()},uAerosolScattering:{value:e()},uAerosolExtinction:{value:e()},uOzone:{value:e()},uCieX:{value:t(i=>li.colourMatching(i)[0],683)},uCieY:{value:t(i=>li.colourMatching(i)[1],683)},uCieZ:{value:t(i=>li.colourMatching(i)[2],683)},uScotopic:{value:t(i=>li.scotopic(i),1700)}}}static VERTEX=`
|
|
6162
|
+
`}),n.fragmentShader=r+n.fragmentShader,n.fragmentShader=n.fragmentShader.replace("#include <opaque_fragment>",a+"#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 Ye;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,r]of this.meshes)i.has(n)||(this.dispose(r),this.meshes.delete(n),this.signatures.delete(n),this.extents.delete(n));for(const n of e){let r=this.meshes.get(n.sourceId);r||(r=new We(new dn(1,1,sn.SEGMENTS,sn.SEGMENTS),new Ji({transparent:!0,depthWrite:!1,depthTest:!0,fog:!1,toneMapped:!1})),this.configureCloudMaterial(r.material),r.frustumCulled=!1,r.layers.set(Tg),this.scene.add(r),this.meshes.set(n.sourceId,r)),r.renderOrder=ub+n.renderOrder,r.visible=!n.hidden&&n.shape.transparency<1,r.visible&&this.paint(r,n,t)}}place(e,t,i){const n=this.frame;if(n)for(const r of this.placed){const a=this.meshes.get(r.sourceId);if(!a||!a.visible)continue;const o=this.extents.get(r.sourceId);if(!o)continue;const{bounds:c}=r.shape;let l=c.x+c.width/2,h=c.y+c.height/2,u=!0;if(r.aim){const d=i(sn.directionOf(r.aim,this.direction));d&&Math.abs(d.ndcX)<sn.FURTHEST_NDC&&Math.abs(d.ndcY)<sn.FURTHEST_NDC?(l=(d.ndcX+1)/2*n.canvasWidthPx,h=(1-d.ndcY)/2*n.canvasHeightPx):u=!1}u?this.curve(a,e,t,n,o,l,h,r.distanceM):this.flat(a,e,n,o,r.distanceM)}}static FURTHEST_NDC=4;curve(e,t,i,n,r,a,o,c){const l=a-r.width/2,h=o-r.height/2,u=e.geometry.attributes.position,d=sn.SEGMENTS;let f=0;for(let p=0;p<=d;p++){const v=h+p/d*r.height;for(let m=0;m<=d;m++){const g=l+m/d*r.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(yt.sizeMAt(c,n.projection.pxToDeg(r.width)),yt.sizeMAt(c,n.projection.pxToDeg(r.height)),1)}flat(e,t,i,n,r){const a=e.geometry.attributes.position,o=sn.SEGMENTS,c=yt.sizeMAt(r,i.projection.pxToDeg(n.width)),l=yt.sizeMAt(r,i.projection.pxToDeg(n.height));this.up.set(0,1,0).applyQuaternion(t.quaternion),this.centre.copy(t.position).addScaledVector(this.direction,r),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),a.setXYZ(h++,this.vertex.x,this.vertex.y,this.vertex.z)}}a.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,r=Xa.paintExtent(n);this.extents.set(t.sourceId,r);const a=sn.signatureOf(n,i);if(this.signatures.get(t.sourceId)===a&&e.material.map)return;this.signatures.set(t.sourceId,a);const o=Math.min(i.scale,db/Math.max(r.width,r.height,1)),c=Math.max(1,Math.ceil(r.width*o)),l=Math.max(1,Math.ceil(r.height*o)),h=e.material.map,u=h?.image??document.createElement("canvas"),d=u.width!==c||u.height!==l;d&&(u.width=c,u.height=l);const f=u.getContext("2d");if(!f)return;f.clearRect(0,0,c,l);const p=new Xa(f);if(p.setStarPoints(i.starPoints),p.setRoll(i.rollRad),p.paintInto(n,r,o),h&&!d){h.needsUpdate=!0;return}h?.dispose();const v=new Ln(u);v.colorSpace=Li,v.minFilter=at,v.generateMipmaps=!1,e.material.map=v,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 Rg=3,ec=800,ba=Math.PI/180;class Hs{constructor(e,t,i=Hs.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,r]of this.meshes)i.has(n)||(this.dispose(r),this.meshes.delete(n),this.signatures.delete(n));for(const[n,r]of this.images){const a=e.find(o=>o.id===n);a&&a.src===r.texture.userData.src||(r.texture.dispose(),this.images.delete(n))}for(const n of e){const r=this.images.get(n.id);if(!r){this.load(n);continue}this.build(n,r)}}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 r=this.images.get(e.id),a=r?r.width/r.height:1,o=Math.tan(e.registration.fovDeg/2*ba),c=o*a;return n.set((t*2-1)*c,(1-i*2)*o,-1).normalize(),n.applyQuaternion(Hs.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 r=this.references.find(a=>a.id===e.id);if(!r||r.src!==t){n.texture.dispose();return}n.texture.userData.src=t,this.images.set(e.id,n),this.build(r,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 oi(i);return n.flipY=!1,n.colorSpace=Li,n.minFilter=at,n.magFilter=at,n.generateMipmaps=!1,n.needsUpdate=!0,{texture:n,width:i.width,height:i.height}}build(e,t){const i=Hs.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 We(Hs.geometryOf(e,t),new Ji({map:t.texture,transparent:!0,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1})),e.kind==="panorama"&&(n.material.side=It),n.frustumCulled=!1,n.layers.set(Rg),n.userData.id=e.id,n.quaternion.copy(Hs.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 a=new di(ec,64,32,Math.PI/2,Math.PI*2),o=a.attributes.uv;for(let c=0;c<o.count;c++)o.setX(c,1-o.getX(c));return o.needsUpdate=!0,a}const i=2*ec*Math.tan(e.registration.fovDeg/2*ba),n=i*(t.width/Math.max(t.height,1)),r=new dn(n,i);return r.translate(0,0,-ec),r}static orientation(e){const{headingDeg:t,pitchDeg:i,rollDeg:n}=e.registration,r=new At;return r.rotation.set(i*ba,-t*ba,-(n??0)*ba,"YXZ"),r.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:r,fovDeg:a}=e.registration;return[e.kind,e.src,t.width,t.height,i,n,r??0,a].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 Ze{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=Ze.WAVELENGTHS_NM.length,i=e.aerosolOpticalDepth??Ze.DEFAULT_AEROSOL_OPTICAL_DEPTH,n=e.ozoneDobson??Ze.DEFAULT_OZONE_DOBSON;this.rayleighScattering=new Float64Array(t),this.aerosolScattering=new Float64Array(t),this.aerosolExtinction=new Float64Array(t),this.ozoneAbsorption=new Float64Array(t);const r=n*2687e17/Ze.OZONE_HALF_WIDTH_M;for(let a=0;a<t;a++){const o=Ze.WAVELENGTHS_NM[a];this.rayleighScattering[a]=Ze.rayleighAt(o);const c=i/Ze.AEROSOL_SCALE_HEIGHT_M*(o/550)**-1.3;this.aerosolExtinction[a]=c,this.aerosolScattering[a]=c*Ze.AEROSOL_SINGLE_SCATTERING_ALBEDO,this.ozoneAbsorption[a]=Ze.OZONE_CROSS_SECTION[a]*1e-25*r}}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)/Ze.RAYLEIGH_SCALE_HEIGHT_M)}static aerosolDensity(e){return Math.exp(-Math.max(e,0)/Ze.AEROSOL_SCALE_HEIGHT_M)}static ozoneDensity(e){return Math.max(0,1-Math.abs(e-Ze.OZONE_PEAK_ALTITUDE_M)/Ze.OZONE_HALF_WIDTH_M)}static rayleighPhase(e){return 3/(16*Math.PI)*(1+e*e)}static aerosolPhase(e,t=Ze.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 rt{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){return e*(1/t-1)**(1/rt.RESPONSE_EXPONENT)}static get ADAPTATION_EXPONENT(){const e=rt.anchoredSemiSaturation(rt.DAYLIGHT_ANCHOR_CD_M2,rt.DAYLIGHT_ANCHOR_RESPONSE),t=rt.anchoredSemiSaturation(rt.NIGHT_ANCHOR_CD_M2,rt.NIGHT_ANCHOR_RESPONSE);return Math.log(e/t)/Math.log(rt.DAYLIGHT_ANCHOR_CD_M2/rt.NIGHT_ANCHOR_CD_M2)}static ROD_HALF_LUMINANCE_CD_M2=.04;static SCOTOPIC_TINT=[.853,.995,1.483];static get SEMI_SATURATION_SCALE(){return rt.anchoredSemiSaturation(rt.DAYLIGHT_ANCHOR_CD_M2,rt.DAYLIGHT_ANCHOR_RESPONSE)/rt.DAYLIGHT_ANCHOR_CD_M2**rt.ADAPTATION_EXPONENT}static rodShare(e){return rt.ROD_HALF_LUMINANCE_CD_M2/(rt.ROD_HALF_LUMINANCE_CD_M2+Math.max(e,0))}static semiSaturation(e){return rt.SEMI_SATURATION_SCALE*Math.max(e,1e-9)**rt.ADAPTATION_EXPONENT}static response(e,t){const i=rt.RESPONSE_EXPONENT,n=Math.max(e,0)**i;return n/(n+rt.semiSaturation(t)**i)}static displayOf(e,t,i,n=rt.rodShare(i)){const r=(1-n)*e[1]+n*t,a=rt.response(r,i),[o,c,l]=li.linearSrgbOf(e),h=Math.max(e[1],1e-12),u=rt.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)*a;return[f(o,u[0]),f(c,u[1]),f(l,u[2])]}}class ze{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 Qr;camera=new Ts(-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 ui(ze.TRANSMITTANCE_WIDTH,ze.TRANSMITTANCE_HEIGHT,{count:4,type:$t,minFilter:at,magFilter:at,depthBuffer:!1}),this.multiple=new ui(ze.MULTIPLE_SIZE,ze.MULTIPLE_ROWS,{count:4,type:Ti,minFilter:Dt,magFilter:Dt,depthBuffer:!1});const t=()=>new ui(ze.SKY_VIEW_WIDTH,ze.SKY_VIEW_HEIGHT,{type:Ti,minFilter:Dt,magFilter:Dt,depthBuffer:!1});this.sunView=t(),this.moonView=t();const i=ze.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]}},r=(a,o={})=>new Lm({glslVersion:Rc,uniforms:{...i,...n,...o},vertexShader:ze.VERTEX,fragmentShader:a,depthTest:!1,depthWrite:!1});this.transmittanceMaterial=r(ze.TRANSMITTANCE_FRAGMENT),this.multipleMaterial=r(ze.MULTIPLE_FRAGMENT),this.skyViewMaterial=r(ze.SKY_VIEW_FRAGMENT,{uObserverRadius:{value:Ze.GROUND_RADIUS_M+2},uSourceMu:{value:1}}),this.quad=new We(new dn(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>=ze.MULTIPLE_ROWS)}setMedium(e){const t=[e.rayleighScattering,e.aerosolScattering,e.aerosolExtinction,e.ozoneAbsorption].map(n=>Array.from(n,r=>r.toPrecision(6)).join(",")).join("|");if(t===this.mediumKey)return;this.abandonBuilding(),this.releaseAdopted(),this.mediumKey=t;const i=(n,r)=>{const a=this.transmittanceMaterial.uniforms[n].value;for(let o=0;o<4;o++)a[o].set(r[o*4]??0,r[o*4+1]??0,r[o*4+2]??0,r[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=ze.shared.get(this.mediumKey);if(t&&t!=="building")return this.adopt(t),!0;if(t==="building"&&!this.building)return!1;t||(ze.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 r=ze.MULTIPLE_SIZE,a=ze.MULTIPLE_BLOCK;for(;n>0&&this.multipleRows<ze.MULTIPLE_ROWS;n--)this.multiple.scissor.set(this.multipleColumn,this.multipleRows,a,1),this.multiple.scissorTest=!0,this.draw(this.multipleMaterial,this.multiple),this.multipleColumn+=a,this.multipleColumn>=r&&(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?ze.shared.set(e,{transmittance:t,multiple:i}):ze.shared.delete(e)}catch{ze.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=(r,a,o,c)=>{const l=new tr(r,a,o,xi,c?$t:Ti);return l.minFilter=l.magFilter=c?at:Dt,l.needsUpdate=!0,l},i=e.transmittance.map(r=>t(r,ze.TRANSMITTANCE_WIDTH,ze.TRANSMITTANCE_HEIGHT,!0)),n=e.multiple.map(r=>t(r,ze.MULTIPLE_SIZE,ze.MULTIPLE_ROWS,!1));i.forEach((r,a)=>this.tableUniforms[`uT${a}`].value=r),n.forEach((r,a)=>this.tableUniforms[`uM${a}`].value=r),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,ze.shared.get(this.mediumKey)==="building"&&ze.shared.delete(this.mediumKey))}renderSkyViews(e,t,i){if(!this.ready)return;const n=this.renderer.getRenderTarget(),r=this.skyViewMaterial.uniforms;r.uObserverRadius.value=Ze.GROUND_RADIUS_M+Math.max(e,2),r.uSourceMu.value=Math.sin(t*Math.PI/180),this.draw(this.skyViewMaterial,this.sunView),r.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=Ze.GROUND_RADIUS_M+Math.max(e,2),r=Ze.GROUND_RADIUS_M,a=Math.acos(Math.min(Math.sqrt(Math.max(n*n-r*r,0))/n,1)),o=Math.PI-a,c=t<o?.5*(1-Math.sqrt(Math.max(1-t/o,0))):.5+.5*Math.sqrt(Math.min((t-o)/a,1));return{u:Math.min(Math.max(Math.abs(i)/Math.PI,0),1),v:c}}async readTable(e,t){if(e==="multiple"){const r=new Float32Array(this.multiple.width*this.multiple.height*4);return await this.renderer.readRenderTargetPixelsAsync(this.multiple,0,0,this.multiple.width,this.multiple.height,r,void 0,t),r}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,r=>Zn.fromHalfFloat(r))}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 r=e();return Ze.WAVELENGTHS_NM.forEach((a,o)=>{r[Math.floor(o/4)].setComponent(o%4,i(a)*n*Ze.WAVELENGTH_STEP_NM*Ze.SOLAR_IRRADIANCE[o])}),r};return{uRayleigh:{value:e()},uAerosolScattering:{value:e()},uAerosolExtinction:{value:e()},uOzone:{value:e()},uCieX:{value:t(i=>li.colourMatching(i)[0],683)},uCieY:{value:t(i=>li.colourMatching(i)[1],683)},uCieZ:{value:t(i=>li.colourMatching(i)[2],683)},uScotopic:{value:t(i=>li.scotopic(i),1700)}}}static VERTEX=`
|
|
6163
6163
|
in vec3 position;
|
|
6164
6164
|
void main() {
|
|
6165
6165
|
gl_Position = vec4(position.xy, 0.0, 1.0);
|
|
@@ -6435,7 +6435,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
|
|
|
6435
6435
|
}
|
|
6436
6436
|
outColor = xyzs;
|
|
6437
6437
|
}
|
|
6438
|
-
`}class ti{static AIRGLOW_LAYER_ALTITUDE_M=9e4;static SUN_MAGNITUDE=-26.74;tables;material;onChange;state;drawnKey="";hasViews=!1;adaptingLuminance=1;ambientColours;reading=!1;exposureScale=1;seenByEye=!0;readAgain=!1;constructor(e,t){this.onChange=t,this.tables=new ze(e),this.tables.setMedium(new Ze),this.material=new
|
|
6438
|
+
`}class ti{static AIRGLOW_LAYER_ALTITUDE_M=9e4;static SUN_MAGNITUDE=-26.74;tables;material;onChange;state;drawnKey="";hasViews=!1;adaptingLuminance=1;ambientColours;reading=!1;exposureScale=1;seenByEye=!0;readAgain=!1;constructor(e,t){this.onChange=t,this.tables=new ze(e),this.tables.setMedium(new Ze),this.material=new Et({glslVersion:Rc,side:It,depthWrite:!1,uniforms:{uSunView:{value:this.tables.sunViewTexture},uMoonView:{value:this.tables.moonViewTexture},uSunAzimuth:{value:new Ae(0,-1)},uMoonAzimuth:{value:new Ae(0,-1)},uMoonScale:{value:0},uObserverRadius:{value:Ze.GROUND_RADIUS_M+2},uAirglow:{value:new it(...ti.airglowXyzs())},uRodShare:{value:0},uSemiSaturationN:{value:1},uExposureScale:{value:1}},vertexShader:`
|
|
6439
6439
|
varying vec3 vDirection;
|
|
6440
6440
|
void main() {
|
|
6441
6441
|
vDirection = (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition;
|
|
@@ -6517,7 +6517,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
|
|
|
6517
6517
|
gl_FragColor = vec4(displayOf(light.xyz, light.w), 1.0);
|
|
6518
6518
|
#include <colorspace_fragment>
|
|
6519
6519
|
}
|
|
6520
|
-
`})}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 Ze(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(ti.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(ti.azimuthVector(e.sun.azimuthDeg)),i.uMoonAzimuth.value.copy(ti.azimuthVector(e.moon.azimuthDeg)),i.uMoonScale.value=10**(-.4*(e.moon.magnitude-ti.SUN_MAGNITUDE)),i.uObserverRadius.value=Ze.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())}adaptFromViews(e,t,i){const n=10**(-.4*(i.moon.magnitude-ti.SUN_MAGNITUDE)),r=ti.airglowXyzs(),a=(u,d)=>{const f=(90-u)*Math.PI/180,p=ze.skyViewUv(i.altitudeM,f,ti.azimuthBetween(d,i.sun.azimuthDeg)),v=ze.skyViewUv(i.altitudeM,f,ti.azimuthBetween(d,i.moon.azimuthDeg)),m=ti.bilinear(e,p.u,p.v),g=ti.bilinear(t,v.u,v.v),b=u>0?ti.airglowFactor(u):0;return[0,1,2,3].map(y=>m[y]+n*g[y]+r[y]*b)};let o=0,c=0;for(let u=5;u<90;u+=10){const d=Math.cos(u*Math.PI/180);for(let f=0;f<360;f+=30)o+=d*Math.log(Math.max(a(u,f)[1],1e-9)),c+=d}this.applyAdaptation(Math.exp(o/c));const l=(u,d)=>{const f=this.exposureScale,[p,v,m,g]=a(u,d),b=this.adaptingLuminance*f;return rt.displayOf([p*f,v*f,m*f],g*f,b,this.seenByEye?rt.rodShare(b):0)},h=[0,0,0];for(let u=0;u<360;u+=20){const d=l(2,u);for(let f=0;f<3;f++)h[f]+=d[f]/18}this.ambientColours={zenith:l(90,0),horizon:h},this.onChange()}applyAdaptation(e){this.adaptingLuminance=e;const t=e*this.exposureScale;this.material.uniforms.uRodShare.value=this.seenByEye?rt.rodShare(t):0,this.material.uniforms.uSemiSaturationN.value=rt.semiSaturation(t)**rt.RESPONSE_EXPONENT}static predictedZenithLuminance(e){const t=n=>90-n.altitudeDeg,i=Ve.magPerArcsec2({altitudeDeg:e.sun.altitudeDeg,separationDeg:t(e.sun)},{phaseAngleDeg:e.moon.phaseAngleDeg,altitudeDeg:e.moon.altitudeDeg,separationDeg:t(e.moon)},90);return Ve.toNanolamberts(i)*ti.CANDELAS_PER_NANOLAMBERT}static CANDELAS_PER_NANOLAMBERT=1e-5/Math.PI;static airglowXyzs(){const e=Ve.toNanolamberts(Ve.AIRGLOW_MAG_PER_ARCSEC2)*ti.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=Ze.GROUND_RADIUS_M/(Ze.GROUND_RADIUS_M+ti.AIRGLOW_LAYER_ALTITUDE_M),n=1/Math.sqrt(Math.max(1-i*i*t,1e-4)),r=1/Math.sqrt(Math.max(1-.96*t,.001));return n*10**(-.4*Ve.EXTINCTION_PER_AIR_MASS*(r-1))}static azimuthVector(e){const t=e*Math.PI/180;return new Ae(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=ze.SKY_VIEW_WIDTH,r=ze.SKY_VIEW_HEIGHT,a=Math.min(Math.max(t*n-.5,0),n-1),o=Math.min(Math.max(i*r-.5,0),r-1),c=Math.floor(a),l=Math.floor(o),h=Math.min(c+1,n-1),u=Math.min(l+1,r-1),d=a-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 kr{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),kr.MAX_RELATIVE_HUMIDITY);return kr.DRY_OPTICAL_DEPTH*(1-t)**-.3}static steppedOpticalDepth(e){const t=kr.OPTICAL_DEPTH_STEP;return Math.round(kr.opticalDepth(e)/t)*t}}function fb(s,e){return JSON.stringify(s.cloudLayers)===JSON.stringify(e.cloudLayers)&&s.cloudCover===e.cloudCover&&s.cloudDarkness===e.cloudDarkness&&s.cloudBaseM===e.cloudBaseM&&s.highCloudCover===e.highCloudCover&&s.iceCrystalAlignment===e.iceCrystalAlignment&&s.lowerCloudCover===e.lowerCloudCover&&s.relativeHumidity===e.relativeHumidity&&s.precipitationType===e.precipitationType&&s.precipitationIntensity===e.precipitationIntensity&&s.windDirectionDeg===e.windDirectionDeg&&s.windSpeed===e.windSpeed&&s.storm===e.storm}const tc=900,nh=1,up=4,dp=.5,La=900,pb=6371e3,mb=3e4;function fp(s){const e=Math.sqrt(2*pb*Math.max(s,0));return Math.max(La,Math.min(e,mb))}const sh=.5,rh=850,pp=.03,Cr=850,ah=4,oh=1.5,mp=-1,gb=6,Wu=-4,gp=.2,ic=2600,vb=.97,Mb=.38,vp=Wu,xb=3,_b=.15,yb=.6,Sb=40,bb=30,wb=[0,45,90,135,180,225,270,315],Eb={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},Ab=["en","fr"],Tb=2,Rb=16,Mp=2500,xp=880,nc=40,_p=60,Db=10,Cb=1,Ib=150,Pb=55,Lb=.5,Nb=2.05,yp=.265,Sp=[[0,0],...Array.from({length:8},(s,e)=>{const t=e*Math.PI/4;return[Math.cos(t)*yp,Math.sin(t)*yp]})],ch=700,lh=250/1e3,Ob=12,bp=5,hh=6,Ns=[.92,.92,.95],uh=[.15,.15,.19],wp={snow:{fallSpeedMPerS:2,size:.3,color:new oe(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new oe(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},Lr=0,dh=0,Ub=150,Ep=3e3,wa=20,Fb=15,Ap=Lr,kb=40,Tp=1,zb=9;function Rp(s){return Tp+(zb-Tp)*s}const Bb=new oe(.75,.82,.92),Hb=10,Gb=.5;function Vb(s){return za(s/Hb,Gb,1)}const Ir=200,Dp=.18,Cp=.32,Wb=.35,Xb=new oe(.85,.9,.98),Ip=5,Pp=.85,Lp=.01;function fh(s,e){return Math.round(s*(Lp+(1-Lp)*e))}const Np=230,Op=.7,Up=.05,qb=.6,Yb=.7,Kb=.15,Fp=.35,$b=3,Zb=1/12,Jb=.5,_n=new oe(.82,.86,1),jb=2500,Qb=1.6,ew=1.2,tw=2.2,iw={Venus:new oe(1,.96,.85),Mars:new oe(1,.55,.4),Jupiter:new oe(.95,.87,.72),Saturn:new oe(.92,.86,.68)};class qi{renderer;scene=new Qr;phenomena=new sn(this.scene);references=new Hs(this.scene,()=>this.render());camera;celestialGroup=new ri;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;decorModelProvider=lb[0].create();decorModelToken=0;decorModelCredits=new Map;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;decorReferencePose;decorCurrentPose;decorTime=0;celestialLight=new rf(16777215,0);celestialLightTarget=new At;skyLight=new Ov(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 kl;weather=qp;observerElevationM=0;siteElevationM=0;groundRadius=La;terrainRadius=La;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 Ae;lightningArmed=!1;lightningFlashes=[];lightningLevel=0;lightningBolt;lightningLight=new rf(16777215,0);baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunCloudTransmission=1;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new D;sunVisible=!1;lensFlareScratch=new D;sunOcclusionRaycaster=new kl;sunOcclusionDirectionScratch=new D;sunOcclusionRightScratch=new D;sunOcclusionUpScratch=new D;ufoOcclusionRaycaster=new kl;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;exposureAccumulation;exposureInstants=1;get developingExposure(){return this.exposureInstants>1&&this.exposureInstantAt!==void 0}static EXPOSURE_BUDGET_MS=12;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;rainbow;skyGlow;cometKey;novaKeys=new Set;constructor(e,t=k1()){this.renderer=new Xy({canvas:e,antialias:!0}),this.resolution=new Mt(Math.min(window.devicePixelRatio||1,2),this.renderer.getContext()),this.renderer.setPixelRatio(this.resolution.pixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=Na,this.camera=new Li(60,e.width/Math.max(e.height,1),.1,tc*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=1,this.celestialLight.shadow.camera.far=1e3,this.celestialLight.shadow.bias=-.0015,this.celestialLight.target=this.celestialLightTarget,this.lightningLight.color.copy(_n),this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight,this.lightningLight),this.scene.add(this.celestialGroup);const i=new ti(this.renderer,()=>{this.skyColoursStale=!0,this.render()});i.supported?this.scatteredSky=i:i.dispose()}get currentTerrainAttribution(){return this.terrainAttribution}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*lh,0,e.z*lh);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)*Ri,i=(e.pitchDeg+this.lookPitchDeg+this.gaitOffset.pitchDeg)*Ri;if(e.headingDeg!==void 0?this.camera.rotation.set(i,-(e.headingDeg+this.lookYawDeg+this.gaitOffset.yawDeg)*Ri,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(fp(e.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/La),this.camera.far=Math.max(tc*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.terrainMesh&&this.terrainOrigin&&e.lat!==void 0&&e.lng!==void 0){const n=hi(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.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}=hi(e,t,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(c*c+l*l)<Ib*(n/La))return}const r=this.terrainOrigin,a=this.terrainRadius;this.terrainOrigin={lat:e,lng:t},this.terrainRadius=n;const o=++this.terrainBuildToken;C5(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=r?hi(e,t,r.lat,r.lng):void 0;u&&d&&Math.hypot(d.x,d.z)<=a&&(c.position.y=u.position.y+this.groundYOfPatch(u,d.x,d.z)),this.disposeMesh(this.terrainMesh),c.renderOrder=Cb,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.render(),i?.()}).catch(c=>{console.warn("Terrain build failed, keeping the flat ground fallback:",c),i?.()})}setShowCompass(e){this.showCompass!==e&&(this.showCompass=e,this.disposeCompassLabels(),e&&this.buildCompassLabels(),this.render())}applyLensFlareTint(e){if(!this.lensFlare)return;const t=Pb*this.sunCloudTransmission;this.lensFlare.uniforms.uColorGain.value.setRGB(t*e[0],t*e[1],t*e[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const e=this.lastSunPosition?.altitudeDeg??-90,t=_S(e)*this.sunCloudTransmission*this.sunUnhiddenFraction,i=ps(e);this.lensFlare.uniforms.uDazzleColour.value.setRGB(i[0],i[1],i[2]),this.lensFlare.uniforms.uVeilStrength.value=Nb**2*Math.max(0,t)}setCompassHovered(e){this.compassHovered!==e&&(this.compassHovered=e,this.updateCompassVisibility())}setCompassForced(e){this.compassForced!==e&&(this.compassForced=e,this.updateCompassVisibility())}updateCompassVisibility(){const e=this.compassHovered||this.compassForced;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(),!fb(this.weather,e)&&(this.weather=e,this.scatteredSky?.setConditions({aerosolOpticalDepth:e.relativeHumidity===void 0?void 0:kr.steppedOpticalDepth(e.relativeHumidity)}),this.pumpScatteredSky(),this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lightningArmed=e.storm&&e.cloudDarkness>=Jb,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(),ci.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear();for(const t of e){const i=ci.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}}setDecorModelProvider(e){this.decorModelProvider=e;const t=this.decorObjects;this.decorObjects=[],this.setDecor(t)}get currentDecorModelCredits(){return[...this.decorModelCredits.values()]}async loadDecorModel(e,t){const i=e.model;if(!(!i||!ci.usesModel(e)))try{const n=i.url?void 0:i.id?await this.decorModelProvider.entry(i.id):void 0,r=i.url??n?.url,a=i.credit??n?.credit;if(!r||!a)return;const o=await hb(r);if(t!==this.decorModelToken)return;const c=this.decorGroups.get(e.id);if(!c)return;ci.applyModel(c,e,o,{headingOffsetDeg:i.headingOffsetDeg??n?.headingOffsetDeg,depictedSizeM:n?.sizeM}),this.decorModelCredits.set(e.id,a),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?hi(e.lat,e.lng,t.lat,t.lng):{x:0,z:0},r=this.decorObjects.find(l=>l.witnessSide!==void 0&&Zp(l.kind));if(this.terrainMesh&&this.terrainOrigin&&t?.lat!==void 0&&t.lng!==void 0){const l=hi(this.terrainOrigin.lat,this.terrainOrigin.lng,t.lat,t.lng);this.terrainMesh.position.x=l.x-(r?0:this.gaitOffset.eastM),this.terrainMesh.position.z=l.z+(r?0:this.gaitOffset.northM)}r||(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 a={x:0,z:0};let o=0;if(r){const l=ci.occupantView(r),h=-(r.headingDeg??0)*Ri,u=l.x*Math.cos(h)+l.z*Math.sin(h),d=-l.x*Math.sin(h)+l.z*Math.cos(h),f=r.eastM+n.x,p=-r.northM+n.z;a.x=-(f+u),a.z=-(p+d),this.camera.position.y=this.groundYUnder(f,p)+l.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*Ri,-(l.headingDeg+this.indoorLookYawDeg)*Ri,0,"YXZ")}for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=qu(l,i),d=u.eastM+n.x+a.x,f=-u.northM+n.z+a.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<=Ub}if(u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*Ri),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(b=>typeof b=="number"?b.toFixed(4):b).join(":");h.userData.cropGroundKey!==g&&(ci.fitCropToGround(h,(b,y)=>this.groundYUnder(b,y)+u.altitudeM),h.userData.cropGroundKey=g)}o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(tc*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):dh}groundYOfPatch(e,t,i){const n=e.geometry.getAttribute("position"),r=Math.round(Math.sqrt(n.count));if(r<2||r*r!==n.count)return dh;const a=n.getX(0),o=n.getX(r-1),c=n.getZ(0),l=n.getZ((r-1)*r),h=za((t-a)/(o-a)*(r-1),0,r-1),u=za((i-c)/(l-c)*(r-1),0,r-1);if(!Number.isFinite(h)||!Number.isFinite(u))return dh;const d=Math.min(Math.floor(h),r-2),f=Math.min(Math.floor(u),r-2),p=h-d,v=u-f,m=(w,E)=>n.getY(w*r+E),g=m(f,d),b=m(f,d+1),y=m(f+1,d),_=m(f+1,d+1);return p+v<=1?g+(b-g)*p+(y-g)*v:_+(y-_)*(1-p)+(b-_)*(1-v)}groundUnderFootprint(e,t,i,n,r=0){return ci.groundUnderFootprint(e,t,i,n,(a,o)=>this.groundYUnder(a,o),r)}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&&ci.setLights(n,i.lights,e,n.position.distanceTo(this.camera.position),t),i.kind!=="streetlight"&&i.kind!=="vehicle")continue;const r=this.decorGroups.get(i.id);if(!r)continue;const a=y1(i,e);ci.setLit(r,i.kind,a);const o=this.streetlightLights.get(i.id);o&&(o.visible=a)}}addStreetlightLight(e,t){const i=ci.bodyOf(t),n=i.children.find(a=>a.userData.emissive);if(!n)return;const r=new kv(16764006,Sb,bb);r.position.copy(n.position).multiply(i.scale),r.castShadow=!0,r.shadow.mapSize.set(512,512),r.shadow.bias=-.002,t.add(r),this.streetlightLights.set(e,r)}setAstronomy(e){this.lastAstronomy=e,this.scatteredSky?.update(this.scatteredSkyState(e)),this.skyHoldUntilMs===void 0&&(this.skyHoldUntilMs=performance.now()+Mp,this.onFirstFrameHold?.(!0),setTimeout(()=>this.render(),Mp+20)),this.pumpScatteredSky(),this.lastSunPosition=e.sun,this.buildSky(e.sun),this.buildGround();const t=yu(e.sun.altitudeDeg,this.instrumentMagnitudeGain);this.buildStars(e.stars,t),this.setBodyMesh("sun",e.sun,ah,new oe(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),this.buildIceHalos(e.sun,e.moon),this.buildRainbow(e.sun,e.moon),this.applySkyColours(e),this.syncAnimationLoop(),this.render()}applySkyColours(e){this.skyColoursStale=!1;const t=this.scatteredSky?.ambient??_u(e.sun.altitudeDeg),i=t.horizon;this.baseFogColor=[i[0],i[1],i[2]],this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.scatteredSky?.ready?this.scatteredSky.material:this.skyGradientMaterial),this.updateCloudLighting(e.sun,this.baseFogColor),this.updateCelestialLight(e,t.zenith,i),this.buildSkyGlow(e,t.zenith),this.scene.fog instanceof Cc?(this.scene.fog.color.setRGB(...this.baseFogColor),this.scene.fog.near=this.groundRadius*.2,this.scene.fog.far=this.groundRadius):this.scene.fog=new Cc(new oe(...this.baseFogColor),this.groundRadius*.2,this.groundRadius)}setSiteElevation(e){Math.abs(e-this.siteElevationM)<1||(this.siteElevationM=e,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:Ve.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?Rb:Tb),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 X5(rh),this.celestialGroup.add(this.satelliteField.object));const t=yu(this.lastSunPosition?.altitudeDeg??-90,this.instrumentMagnitudeGain);this.satelliteField.set(e,t,i=>this.cloudTransmission(i)),this.render()}pickSatelliteAt(e,t){if(!this.satelliteField?.count)return;this.aimAtScreenPoint(this.raycaster,e,t);const i=Math.cos(pp*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,i){this.skyLight.color.setRGB(t[0],t[1],t[2]),this.skyLight.groundColor.setRGB(i[0],i[1],i[2]),this.skyLight.intensity=yb;const n=e.sun.altitudeDeg>=vp,r=!n&&e.moon.altitudeDeg>=vp;if(!n&&!r){this.celestialLight.intensity=0;return}const a=n?e.sun:e.moon,{x:o,y:c,z:l}=ni(a.altitudeDeg,a.azimuthDeg,Cr);this.celestialLight.position.set(o,c,l);const h=ps(a.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const u=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*Ri));this.celestialLight.intensity=(n?xb:_b)*u,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(e,t,i){this.meteorSystem||(this.meteorSystem=new ei,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=Yt.starPointsOf(e),i=Yt.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.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.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()+qi.COMPILE_WAIT_MS;return new Promise(n=>{const r=()=>{if(this.contextReleased)return n();for(const a of e){const o=t.get(a)?.currentProgram;(!o||o.isReady())&&e.delete(a)}e.size===0||performance.now()>i?n():setTimeout(r,10)};r()})}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()}animate(e,t){const i=Math.min(t/1e3,Zb);this.updateTwinkle(e/1e3),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,a,o)=>this.directionAtScreenPoint(r,a,o),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());const n=this.renderer.getRenderTarget();if(!t){this.updateLensFlarePosition();const r=this.usableDepthOfFieldPass();r?.setEncodesOutput(e===void 0),this.skyGlow?.setDestinationEncoded(e===void 0&&!r),e&&this.renderer.setRenderTarget(e),r?r.render(this.renderer,this.scene,this.camera,()=>this.renderOverlayPasses()):(this.renderer.render(this.scene,this.camera),this.renderOverlayPasses()),e&&this.renderer.setRenderTarget(n);return}t.setEncodesOutput(e===void 0),this.skyGlow?.setDestinationEncoded(!1),e&&this.renderer.setRenderTarget(e),t.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition(),r=>this.renderOverlayPasses(r),r=>{this.lensFlare&&(this.lensFlare.mesh.visible=r?!1:this.sunVisible)},()=>this.renderDazzleOnResample()),e&&this.renderer.setRenderTarget(n)}renderOverlayPasses(e=this.camera){this.renderReferencesPass(e),this.renderPhenomenaPass(e)}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(Rg),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 r=this.decorGroups.get(n.id);r&&qi.markDecorDepth(r,n.kind!=="crop")}e.layers.set(nh),this.scene.overrideMaterial=this.decorDepthMaterial,this.renderer.render(this.scene,e),this.scene.overrideMaterial=null,e.layers.set(Tg),this.renderer.render(this.scene,e),e.layers.set(0),this.renderer.autoClear=t,this.renderer.shadowMap.autoUpdate=i}decorDepthMaterial=new Zi({colorWrite:!1});static markDecorDepth(e,t){e.traverse(i=>{if(!(i instanceof We))return;const n=Array.isArray(i.material)?i.material[0]:i.material;t&&n.depthWrite!==!1&&n.blending!==Hi?i.layers.enable(nh):i.layers.disable(nh)})}startExposure(){this.cancelExposure(),this.exposureSubjectBounds=[];const e=this.renderer.getDrawingBufferSize(new Ae),t=Math.max(1,Math.round(e.x)),i=Math.max(1,Math.round(e.y));this.exposureAccumulation||(this.exposureAccumulation=new jy(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()+qi.EXPOSURE_BUDGET_MS,r=qi.exposureInstantsPerFrame(t.instantTarget.width*t.instantTarget.height);let a=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++,a++}while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<n&&a<r);this.restateAt(e,0),this.presentExposure(),this.resolution.endDrawing(),this.exposureInstantsDone<this.exposureInstants&&(this.exposureFrameId=requestAnimationFrame(()=>this.developExposure()))}presentExposure(){if(this.exposureAccumulation?.develop(this.renderer,this.exposureInstants/this.exposureInstantsDone),this.onMapSubjectBounds?.(this.exposureSubjectBounds),!this.compassSprites.some(r=>r.visible))return;const e=new Qr,t=new Ts(-1,1,1,-1,0,2),i=nc/(xp*Math.tan(_p*Ri/2));for(const r of this.compassSprites){if(!r.visible)continue;const a=r.getWorldPosition(new D).sub(this.camera.position).normalize(),o=this.screenPointOf(a);if(!o)continue;const c=new Sr(r.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=[];mapSubjectBounds(){const e=[],t=new un,i=new D;for(const n of this.decorObjects){if(!n.track?.length&&n.kind!=="aircraft"&&n.kind!=="vehicle")continue;const r=this.decorGroups.get(n.id);if(!r?.visible||(t.setFromObject(r),t.isEmpty()))continue;let a=1/0,o=-1/0,c=1/0,l=-1/0;for(const h of[t.min.x,t.max.x])for(const u of[t.min.y,t.max.y])for(const d of[t.min.z,t.max.z]){i.set(h,u,d).sub(this.camera.position).normalize();const f=this.screenPointOf(i);if(!f)continue;const p=(f.ndcX+1)/2,v=(1-f.ndcY)/2;a=Math.min(a,p),o=Math.max(o,p),c=Math.min(c,v),l=Math.max(l,v)}Number.isFinite(a)&&e.push({x:a,y:c,width:o-a,height:l-c})}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 Ae),i=Math.max(1,Math.round(t.x)),n=Math.max(1,Math.round(t.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new ka(i,n)),this.depthOfFieldPass.resize(i,n),this.depthOfFieldPass.setLens(e.focalLengthMm,e.fNumber,e.focusDistance,e.frameHeightMm),this.depthOfFieldPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const e=this.renderer.getDrawingBufferSize(new Ae);return this.equidistantPass?this.equidistantPass.resize(e.x,e.y):this.equidistantPass=new Wn(e.x,e.y),this.equidistantPass}aimAtScreenPoint(e,t,i){const n=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!n){e.setFromCamera(new Ae(t,i),this.camera);return}const r=n.directionFor(t,i,this.camera.fov);this.camera.updateMatrixWorld(),e.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),e.ray.direction.set(r.x,r.y,r.z).applyQuaternion(this.camera.quaternion).normalize(),e.camera=this.camera}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 Wn.ndcFor(t,this.camera.fov,n);if(t.z>=0)return;const r=Math.tan(this.camera.fov/2*Ri);return{ndcX:t.x/-t.z/(n*r),ndcY:t.y/-t.z/r}}screenPointScratch=new D;screenPointQuaternion=new Qn;screenPointSize=new Ae;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,r=this.renderer.domElement.height;e.uniforms.uResolution.value.set(n,r),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 r=this.renderer.autoClear;this.renderer.autoClear=!1,e.mesh.visible=!0,e.mesh.layers.enable(up),this.camera.layers.set(up),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),e.mesh.visible=!1,e.uniforms.uEquidistant.value=0,this.renderer.autoClear=r}sunVisibleFraction(){this.raycastableDecor().length>0&&this.scene.updateMatrixWorld();let e=0;for(const t of Sp)this.isSunOccluded(t[0],t[1])||e++;return e/Sp.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),r=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,r))return!0;if(i.length===0)return!1;this.sunOcclusionRaycaster.set(this.camera.position,n);const a=this.sunOcclusionRaycaster.intersectObjects(i,!0)[0];return a!==void 0&&a.distance<r}groundBlocks(e,t,i,n=0){const r=this.groundMesh;if(r&&t.y<0){const m=(r.position.y-e.y)/t.y;if(m>n&&m<i){const g=e.x+t.x*m-r.position.x,b=e.z+t.z*m-r.position.z;if(Math.hypot(g,b)<=this.groundRadius)return!0}}const a=this.terrainMesh;if(!a)return!1;const o=a.geometry.getAttribute("position"),c=Math.round(Math.sqrt(o.count));if(c<2||c*c!==o.count)return!1;const l=[a.position.x+o.getX(0),a.position.x+o.getX(c-1)],h=[a.position.z+o.getZ(0),a.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,b]of[[e.x,t.x,l],[e.z,t.z,h]]){const y=Math.min(b[0],b[1]),_=Math.max(b[0],b[1]);if(Math.abs(g)<1e-12){if(m<y||m>_)return!1;continue}const w=(y-m)/g,E=(_-m)/g;d=Math.max(d,Math.min(w,E)),f=Math.min(f,Math.max(w,E))}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,b=e.x+t.x*g,y=e.y+t.y*g,_=e.z+t.z*g;if(y<=this.groundYUnder(b,_))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=dp;let n,r;for(const a of this.decorObjects){if(a.kind==="crop")continue;const o=this.decorGroups.get(a.id);if(!o)continue;const c=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];c&&(a.occludesSourceIds?.includes(i)?n=n===void 0?c.distance:Math.max(n,c.distance):r=r===void 0?c.distance:Math.min(r,c.distance))}return{behindM:n,inFrontM:r}}pickBodyAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const i=[...this.hitAreas.entries()],n=this.raycaster.intersectObjects(i.map(([,r])=>r))[0];if(n&&!this.groundHides(e,t))return i.find(([,r])=>r===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(pp*this.camera.fov*Math.PI/180);let r,a=n;for(const o of this.namedStars){const c=o.direction.dot(i);c>a&&(a=c,r={star:o.star,altitudeDeg:o.altitudeDeg})}return r&&this.groundHides(e,t)?void 0:r}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,dp)}pickDecorAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const i=[...this.decorGroups.entries()],n=this.raycaster.intersectObjects(i.map(([,a])=>a),!0)[0];if(!n)return;let r=n.object;for(;r&&!i.some(([,a])=>a===r);)r=r.parent;return i.find(([,a])=>a===r)?.[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.disposeCloudSystem(),this.disposeCirrus(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers(),this.meteorSystem?.dispose(),this.meteorSystem=void 0,this.iceHalos?.dispose(),this.iceHalos=void 0,this.rainbow?.dispose(),this.rainbow=void 0,this.skyGlow?.dispose(),this.skyGlow=void 0,this.depthOfFieldPass?.dispose(),this.depthOfFieldPass=void 0,this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0,this.cometTail?.dispose(),this.cometTail=void 0,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())ci.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 di(tc,32,16),i=t.attributes.position,n=t.getAttribute("color")??new Pt(new Float32Array(i.count*3),3);for(let a=0;a<i.count;a++){const{altitudeDeg:o,azimuthDeg:c}=tS(i.getX(a),i.getY(a),i.getZ(a)),l=lS(o,c,e.azimuthDeg,e.altitudeDeg);n.setXYZ(a,l[0],l[1],l[2])}if(n.needsUpdate=!0,this.skyMesh)return;t.setAttribute("color",n);const r=new Zi({vertexColors:!0,side:It,fog:!1,depthWrite:!1});this.skyGradientMaterial=r,this.skyMesh=new We(t,r),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){const e=fp(this.observerElevationM);if(this.groundMesh&&e===this.groundRadius)return;this.disposeMesh(this.groundMesh),this.groundRadius=e;const t=new hd(this.groundRadius,48),i=new eo({color:new oe(sh,sh,sh),fog:!0});this.groundMesh=new We(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){const t=`${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,a])=>`${r}=${Math.round(a.x/10)},${Math.round(a.z/10)}`).join(";"),i=this.cloudTransmissionMemo.get(t);if(i!==void 0)return i;this.cloudTransmissionMemo.size>256&&this.cloudTransmissionMemo.clear();const n=this.computeCloudTransmission(e);return this.cloudTransmissionMemo.set(t,n),n}cloudTransmissionMemo=new Map;computeCloudTransmission(e){const t=ni(e.altitudeDeg,e.azimuthDeg,1);if(this.layeredClouds)return this.layeredClouds.transmissionAt(t);let i=1;const n=this.lowerCloudCover();n>0&&(i*=1-st.alphaAt(t,Math.abs(this.cloudLayerOffset()),n,this.cloudFieldOffset)*vb);const r=this.weather.highCloudCover??0;return r>0&&(i*=1-st.iceAlphaAt(t,ic,r,this.cloudFieldOffset)*Mb),Math.max(0,Math.min(1,i))}setBodyMesh(e,t,i,n,r){if(t.altitudeDeg<Wu){this.disposeMesh(this.bodyMeshes.get(e)),this.bodyMeshes.delete(e),this.disposeHitArea(e),this.disposeGlare(e),e==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:c}=ni(t.altitudeDeg,t.azimuthDeg,Cr),l=ps(t.altitudeDeg),h=this.cloudTransmission(t),u=new oe(n.r*l[0]*h,n.g*l[1]*h,n.b*l[2]*h);let d=this.bodyMeshes.get(e);d instanceof We?d.material.color.copy(u):(this.disposeMesh(d),d=new We(new di(1,16,16),new Zi({color:u,fog:!1})),this.celestialGroup.add(d),this.bodyMeshes.set(e,d)),d.scale.setScalar(i),d.position.set(a,o,c),this.setHitArea(e,a,o,c,i);const f=r-2.5*Math.log10(Math.max(h,.001));if(e==="sun"&&(this.sunCloudTransmission=h),e!=="sun"&&this.setGlare(e,a,o,c,f,u),e==="sun"){this.sunVisible=!0;const p=this.celestialGroup.scale.x;this.sunWorldPosition.set(a*p,o*p+this.celestialGroup.position.y,c*p),this.lensFlare||(this.lensFlare=W5(),this.lensFlare.uniforms.uOpacity.value=Lb,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<Wu){this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i);return}const{x:n,y:r,z:a}=ni(e.altitudeDeg,e.azimuthDeg,Cr),o=ps(e.altitudeDeg),c=new oe(o[0],o[1],o[2]),l=`${e.phase.phaseFraction<.5}:${Math.round(za(e.phase.illuminatedFraction,0,1)*500)}`;let h=this.bodyMeshes.get(i);if(h instanceof Sr)h.userData.phaseKey!==l&&(h.material.map?.dispose(),h.material.map=zp(e.phase),h.userData.phaseKey=l),h.material.color.copy(c);else{this.disposeMesh(h),h=new Sr(new Ta({map:zp(e.phase),color:c,fog:!1})),h.userData.phaseKey=l;const u=ah*2;h.scale.set(u,u,1),this.celestialGroup.add(h),this.bodyMeshes.set(i,h)}h.position.set(n,r,a),this.setHitArea(i,n,r,a,ah),this.setGlare(i,n,r,a,e.magnitude,c)}setHitArea(e,t,i,n,r){let a=this.hitAreas.get(e);if(!a){const c=new Ta({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1});a=new Sr(c),this.celestialGroup.add(a),this.hitAreas.set(e,a)}a.position.set(t,i,n);const o=r*gb;a.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,r,a){const o=dS(r);if(o<=0){this.disposeGlare(e);return}const c=mS(o),l=this.glareSprites.get(e),h=l??new Sr(new Ta({map:uw(),transparent:!0,blending:Hi,depthWrite:!1,fog:!1}));h.material.color.copy(a),h.material.opacity=MS(o),h.position.set(t,i,n),h.scale.set(c*2,c*2,1),l||(this.celestialGroup.add(h),this.glareSprites.set(e,h))}disposeGlare(e){const t=this.glareSprites.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.glareSprites.delete(e))}buildComet(e,t){const i=e&&`comet:${e.id}`;if(!e||!i||e.magnitude>t){this.disposeComet();return}this.cometKey&&this.cometKey!==i&&this.disposeComet();const n=Da(e.magnitude,t),r=Ca(n);this.cometKey=i,this.setBodyMesh(i,e.position,oh*(.5+.5*n),new oe(r,r,r),e.magnitude),this.cometTail||(this.cometTail=new ki(Cr),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(e.position,e.tailEnd,n)}buildIceHalos(e,t){this.iceHalos||(this.iceHalos=new tn,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:ic},0);return}const r=this.lowerCloudCover(),a=nt.deckLitUntilDeg(nt.DECK_HEIGHT_M),o=e.altitudeDeg>-a?e:t,c=nt.strength(i,r,o.altitudeDeg,a)*(o===e?1:gp),{x:l,y:h,z:u}=ni(o.altitudeDeg,o.azimuthDeg,1),d=ps(o.altitudeDeg);this.iceHalos.update({x:l,y:h,z:u},o.altitudeDeg,c,[d[0],d[1],d[2]],{cover:n?.cover??i,layerHeight:n?.layerHeight??ic},n?.iceCrystalAlignment??this.weather.iceCrystalAlignment??.65)}buildRainbow(e,t){this.rainbow||(this.rainbow=new Ws,this.celestialGroup.add(this.rainbow.object));const i=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity:0,n=e.altitudeDeg>0,r=n?e:t,a=this.lowerCloudCover(),o=gp*Ii.moonlightShare(t.magnitude),c=Ii.strength(i,a,r.altitudeDeg)*(n?1:o);if(c<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:l,y:h,z:u}=ni(r.altitudeDeg,r.azimuthDeg,1),d=ps(r.altitudeDeg);this.rainbow.update({x:l,y:h,z:u},c,[d[0],d[1],d[2]],n)}buildSkyGlow(e,t){if(!e.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new gs,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:i,observer:n}=e.frame,r=nn.galactic(i,n),a=qi.directionOf(r.centre),o=qi.directionOf(r.rotation),c=qi.directionOf(r.pole),l=new He().set(a.x,a.y,a.z,o.x,o.y,o.z,c.x,c.y,c.z),h=qi.directionOf(nn.eclipticPole(i,n)),u=qi.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:qi.directionOf(e.moon),altitudeDeg:e.moon.altitudeDeg,phaseAngleDeg:Ve.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 r=`nova:${n.id}`;i.add(r);const a=Da(n.magnitude,t),o=Ca(a);this.setBodyMesh(r,n.position,oh*(.5+.5*a),new oe(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 r=Da(n.magnitude,t),a=Ca(r),o=iw[n.body]??new oe(1,1,1),c=new oe(o.r*a,o.g*a,o.b*a),l=oh*(.5+.5*r);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:r}=e,a=new an(n,r),o=ph(1337),c=[];for(let l=0;l<i.count;l++){const h=i.mag[l];if(h>t)break;const{altitudeDeg:u,azimuthDeg:d}=a.position(i.ra[l],i.dec[l]);if(u<mp)continue;const{x:f,y:p,z:v}=ni(u,d,rh);c.push({x:f,y:p,z:v,brightness:Da(h,t),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}for(const l of w5){if(l.mag>t)continue;const{altitudeDeg:h,azimuthDeg:u}=a.position(l.raHours,l.decDeg);if(h<mp)continue;const{x:d,y:f,z:p}=ni(h,u,rh);this.namedStars.push({star:l,direction:new D(d,f,p).normalize(),altitudeDeg:h})}this.starTiers=xd.map((l,h)=>{const u=c.filter(y=>Jm(y.brightness)===h),d=new Float32Array(u.length*3),f=new Float32Array(u.length),p=new Float32Array(u.length),v=new Float32Array(u.length);u.forEach((y,_)=>{d[_*3]=y.x,d[_*3+1]=y.y,d[_*3+2]=y.z,f[_]=y.brightness,p[_]=y.phase,v[_]=y.speedFactor});const m=new bt;m.setAttribute("position",new ot(d,3));const g=new ot(new Float32Array(u.length*3),3);m.setAttribute("color",g);let b=this.starTiers[h]?.points;if(b)b.geometry.dispose(),b.geometry=m;else{const y=new ld({vertexColors:!0,size:l.size,sizeAttenuation:!1,fog:!1});_s.apply(y),b=new Fa(m,y),this.celestialGroup.add(b)}return{points:b,colorAttribute:g,brightness:f,phase:p,speedFactor:v}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(e){for(const t of this.starTiers){const i=t.colorAttribute.array;for(let n=0;n<t.brightness.length;n++){const r=wS(t.brightness[n],{phase:t.phase[n],speedFactor:t.speedFactor[n]},e),a=Ca(t.brightness[n])*r;i[n*3]=a,i[n*3+1]=a,i[n*3+2]=a}t.colorAttribute.needsUpdate=!0}}buildClouds(){if(this.cloudRendering==="volume"||this.weather.cloudLayers!==void 0){this.layeredClouds||(this.disposeCloudSystem(),this.layeredClouds=new Wr(this.celestialGroup,ch,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 oe(Ns[0]+(uh[0]-Ns[0])*t,Ns[1]+(uh[1]-Ns[1])*t,Ns[2]+(uh[2]-Ns[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:r}=mu(i,e,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=n,this.cloudUniforms=r,r.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const a=gu(ch);this.cloudMesh=new We(a,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}=mu(new oe(...Ns),e,ic,1);this.cirrusMaterial=t,this.cirrusUniforms=i,i.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new We(gu(ch*1.04),t),this.cirrusMesh.renderOrder=bp-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?Wr.deckOrder(!0,0,1):bp}cloudLayerOffset(){const t=((this.weather.cloudBaseM??1e3)-this.observerElevationM)*lh;return Math.sign(t||1)*Math.max(Math.abs(t),Ob)}updateCloudLighting(e,t){const i=[this.cloudUniforms,this.cirrusUniforms].filter(u=>u!==void 0);if(i.length===0&&!this.layeredClouds)return;const{x:n,y:r,z:a}=ni(e.altitudeDeg,e.azimuthDeg,1),o=ps(e.altitudeDeg),c=Math.max(0,Math.sin(Math.max(e.altitudeDeg,0)*Ri)),l=this.lightningLevel*ew,h=new oe(t[0]+_n.r*l,t[1]+_n.g*l,t[2]+_n.b*l);this.layeredClouds?.setLighting(new D(n,r,a),new oe(o[0],.96*o[1],.88*o[2]),h,h);for(const u of i)u.sunDir.value.set(n,r,a),u.sunColor.value.setRGB(o[0]*c,.96*o[1]*c,.88*o[2]*c),u.ambientColor.value.copy(h)}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=wp[e],i=t.poolSize,n=ph(9001),r=new Float32Array(i*3),a=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 y=0;y<i;y++){const _=n()*Math.PI*2,w=n()*t.radiusM;r[y*3]=Math.cos(_)*w,r[y*3+1]=Lr+n()*(t.topYM-Lr),r[y*3+2]=Math.sin(_)*w,a[y]=n()*Math.PI*2,o[y]=.7+n()*.6,c[y]=.6+n()*.8,l[y]=.4+n()*1.2}const v=new bt;v.setAttribute("position",new ot(r,3)),v.setDrawRange(0,fh(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},uHazeColor:{value:new oe(...this.baseFogColor)},uTexture:{value:nw(e)},uNearFocusDistance:{value:Ip},uHazeDistance:{value:t.radiusM*Pp}},g=new wt({uniforms:m,vertexShader:lw,fragmentShader:hw,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const b=new Fa(v,g);b.renderOrder=hh,this.scene.add(b),this.precipitationPoints=b,this.precipitationPositions=r,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=c,this.precipitationWobbleAmpJitter=l,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=u,this.precipitationBounceDuration=d,this.precipitationBounceVelX=f,this.precipitationBounceVelZ=p}updatePrecipitation(e,t){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter||(this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor),t<=0))return;const i=this.weather.precipitationType;if(i==="none"||i==="rain")return;const n=wp[i],r=this.weather.windDirectionDeg*Ri,a=Math.sin(r)*this.weather.windSpeed*n.driftSensitivity,o=-Math.cos(r)*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,b=i==="snow"&&u&&d,y=i==="hail"&&f&&p&&v&&m&&g;for(let _=0,w=0;_<c.length;_+=3,w++){if(y&&f[w]>0){if(f[w]-=t,f[w]<=0){const x=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*n.radiusM;c[_]=Math.cos(x)*A,c[_+1]=n.topYM,c[_+2]=Math.sin(x)*A,f[w]=0}else{const x=1-f[w]/v[w];c[_+1]=Lr+Math.sin(Math.PI*x)*p[w],c[_]=sc(c[_]+(a+m[w])*t,n.radiusM),c[_+2]=sc(c[_+2]+(o+g[w])*t,n.radiusM)}continue}let E=0,R=0;if(b){const x=qb*u[w],A=Yb*d[w];E=Math.sin(e*x*Math.PI*2+l[w])*A,R=Math.sin(e*x*Math.PI*2+l[w]+Math.PI/2)*A}if(c[_]+=(a+E)*t,c[_+1]-=n.fallSpeedMPerS*h[w]*t,c[_+2]+=(o+R)*t,c[_]=sc(c[_],n.radiusM),c[_+2]=sc(c[_+2],n.radiusM),c[_+1]<Lr){if(y){p[w]=Fp*(.2+Math.random()*1.6),v[w]=Kb*(.5+Math.random()),f[w]=v[w];const I=Math.random()*Math.PI*2,C=$b*(p[w]/Fp);m[w]=Math.cos(I)*C,g[w]=Math.sin(I)*C,c[_+1]=Lr;continue}const x=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*n.radiusM;c[_]=Math.cos(x)*A,c[_+1]=n.topYM,c[_+2]=Math.sin(x)*A}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const e=Rp(this.weather.precipitationIntensity);this.rainSystem=B5({count:Ep,radiusM:wa,heightM:Fb,bottomYM:Ap,overallSpeed:kb,color:Bb,opacity:.85,visibleCount:fh(Ep,this.weather.precipitationIntensity),speedStreak:Vb(e),pixelSize:Np,seed:9001,nearFocusDistanceM:Ip,hazeDistanceM:wa*Pp,hazeColor:new oe(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=hh,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const e=ph(4242),t=new Float32Array(Ir*3),i=new Float32Array(Ir),n=new Float32Array(Ir),r=new Float32Array(Ir);for(let h=0;h<Ir;h++){const u=e()*Math.PI*2,d=Math.sqrt(e())*wa;t[h*3]=Math.cos(u)*d,t[h*3+1]=Ap,t[h*3+2]=Math.sin(u)*d,n[h]=kp(Dp,Cp),i[h]=e()*n[h],r[h]=i[h]/n[h]}const a=new bt;a.setAttribute("position",new ot(t,3));const o=new ot(r,1);a.setAttribute("aLife",o),a.setDrawRange(0,fh(Ir,this.weather.precipitationIntensity));const c=new wt({uniforms:{uMaxSize:{value:Wb},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:Xb},uTexture:{value:aw()}},vertexShader:ow,fragmentShader:cw,transparent:!0,depthWrite:!1}),l=new Fa(a,c);l.renderOrder=hh,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*Ri;e.uniforms.uDropVelocity.value.set(Math.sin(t)*this.weather.windSpeed,-Rp(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);const i=this.weather.windDirectionDeg*Ri,n=Math.sin(i)*this.weather.windSpeed,r=-Math.cos(i)*this.weather.windSpeed,a=wa,o=l=>(l%(a*2)+a*3)%(a*2)-a;t.uniforms.uWindOffset.value.set(o(t.uniforms.uWindOffset.value.x+n*e),o(t.uniforms.uWindOffset.value.y+r*e)),this.syncRainSlant(),this.camera.getWorldDirection(this.rainCameraDirection);const c=Math.abs(this.rainCameraDirection.y);if(Math.abs(c-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=c;const l=Op+(1-Op)*(1-c),h=Up+(1-Up)*(1-c);t.uniforms.uUvSquash.value=h,t.uniforms.uPixelSize.value=Np*l*(.5+.5*h)}this.updateRainSplashes(e)}updateRainSplashes(e){const t=this.rainSplashSystem;if(!t||e<=0)return;const{positions:i,life:n,duration:r,lifeAttribute:a}=t,o=a.array;for(let c=0,l=0;c<i.length;c+=3,l++){if(n[l]+=e,n[l]>=r[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*wa;i[c]=Math.cos(h)*u,i[c+2]=Math.sin(h)*u,r[l]=kp(Dp,Cp),n[l]=0}o[l]=n[l]/r[l]}t.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}setLightning(e){this.lightningFlashes=e}updateLightning(e){let t,i=0;if(this.lightningArmed)for(const o of this.lightningFlashes){if(o.t>e)break;const c=Kt.brightnessAt(o,e);c>i&&(t=o,i=c)}const n=t?Math.min(1,Math.max(.1,(jb/t.distanceM)**2)):0,r=i*n*(t?.cloudToGround?1:.6);if(r===this.lightningLevel&&!t?.cloudToGround)return;if(this.lightningLevel=r,this.scene.fog){const o=this.scene.fog,c=Math.min(1,r);o.color.setRGB(this.baseFogColor[0]+(_n.r-this.baseFogColor[0])*c,this.baseFogColor[1]+(_n.g-this.baseFogColor[1])*c,this.baseFogColor[2]+(_n.b-this.baseFogColor[2])*c)}if(this.skyMesh){const o=r*Qb;this.skyMesh.material.color.setRGB(1+o*_n.r,1+o*_n.g,1+o*_n.b)}if(this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.lightningLight.intensity=r*tw,t){const{x:o,y:c,z:l}=ni(25,t.azimuthDeg,Cr);this.lightningLight.position.set(o,c,l)}this.lightningBolt||(this.lightningBolt=new Ur(Cr*.95),this.celestialGroup.add(this.lightningBolt.object));const a=this.weather.cloudBaseM??1500;this.lightningBolt.set(t,i,a),this.render()}buildCompassLabels(){const e=Yu(navigator.languages,Ab),t=Eb[e];this.compassSprites=wb.map((i,n)=>{const r=t[n],a=new Ta({map:dw(r),depthTest:!1,fog:!1}),o=new Sr(a),{x:c,y:l,z:h}=ni(0,i,xp);return o.position.set(c,l,h),o.scale.set(nc,nc,1),o.renderOrder=Db,o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o}),this.updateCompassScale()}updateCompassScale(){const e=this.camera.fov*Math.PI/360,t=_p*Math.PI/360,i=nc*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 Ri=Math.PI/180;function za(s,e,t){return Math.max(e,Math.min(t,s))}function kp(s,e){return s+Math.random()*(e-s)}function sc(s,e){return(s%(e*2)+e*3)%(e*2)-e}let rc,ac;function nw(s){switch(s){case"snow":return sw();case"hail":return rw()}}function sw(){if(rc)return rc;const s=64,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),i=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/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,s,s),rc=new Ln(e),rc}function rw(){if(ac)return ac;const s=64,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),i=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/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,s,s),ac=new Ln(e),ac}let oc;function aw(){if(oc)return oc;const s=64,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),i=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/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,s,s),oc=new Ln(e),oc}const ow=`
|
|
6520
|
+
`})}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 Ze(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(ti.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(ti.azimuthVector(e.sun.azimuthDeg)),i.uMoonAzimuth.value.copy(ti.azimuthVector(e.moon.azimuthDeg)),i.uMoonScale.value=10**(-.4*(e.moon.magnitude-ti.SUN_MAGNITUDE)),i.uObserverRadius.value=Ze.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())}adaptFromViews(e,t,i){const n=10**(-.4*(i.moon.magnitude-ti.SUN_MAGNITUDE)),r=ti.airglowXyzs(),a=(u,d)=>{const f=(90-u)*Math.PI/180,p=ze.skyViewUv(i.altitudeM,f,ti.azimuthBetween(d,i.sun.azimuthDeg)),v=ze.skyViewUv(i.altitudeM,f,ti.azimuthBetween(d,i.moon.azimuthDeg)),m=ti.bilinear(e,p.u,p.v),g=ti.bilinear(t,v.u,v.v),b=u>0?ti.airglowFactor(u):0;return[0,1,2,3].map(y=>m[y]+n*g[y]+r[y]*b)};let o=0,c=0;for(let u=5;u<90;u+=10){const d=Math.cos(u*Math.PI/180);for(let f=0;f<360;f+=30)o+=d*Math.log(Math.max(a(u,f)[1],1e-9)),c+=d}this.applyAdaptation(Math.exp(o/c));const l=(u,d)=>{const f=this.exposureScale,[p,v,m,g]=a(u,d),b=this.adaptingLuminance*f;return rt.displayOf([p*f,v*f,m*f],g*f,b,this.seenByEye?rt.rodShare(b):0)},h=[0,0,0];for(let u=0;u<360;u+=20){const d=l(2,u);for(let f=0;f<3;f++)h[f]+=d[f]/18}this.ambientColours={zenith:l(90,0),horizon:h},this.onChange()}applyAdaptation(e){this.adaptingLuminance=e;const t=e*this.exposureScale;this.material.uniforms.uRodShare.value=this.seenByEye?rt.rodShare(t):0,this.material.uniforms.uSemiSaturationN.value=rt.semiSaturation(t)**rt.RESPONSE_EXPONENT}static predictedZenithLuminance(e){const t=n=>90-n.altitudeDeg,i=Ve.magPerArcsec2({altitudeDeg:e.sun.altitudeDeg,separationDeg:t(e.sun)},{phaseAngleDeg:e.moon.phaseAngleDeg,altitudeDeg:e.moon.altitudeDeg,separationDeg:t(e.moon)},90);return Ve.toNanolamberts(i)*ti.CANDELAS_PER_NANOLAMBERT}static CANDELAS_PER_NANOLAMBERT=1e-5/Math.PI;static airglowXyzs(){const e=Ve.toNanolamberts(Ve.AIRGLOW_MAG_PER_ARCSEC2)*ti.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=Ze.GROUND_RADIUS_M/(Ze.GROUND_RADIUS_M+ti.AIRGLOW_LAYER_ALTITUDE_M),n=1/Math.sqrt(Math.max(1-i*i*t,1e-4)),r=1/Math.sqrt(Math.max(1-.96*t,.001));return n*10**(-.4*Ve.EXTINCTION_PER_AIR_MASS*(r-1))}static azimuthVector(e){const t=e*Math.PI/180;return new Ae(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=ze.SKY_VIEW_WIDTH,r=ze.SKY_VIEW_HEIGHT,a=Math.min(Math.max(t*n-.5,0),n-1),o=Math.min(Math.max(i*r-.5,0),r-1),c=Math.floor(a),l=Math.floor(o),h=Math.min(c+1,n-1),u=Math.min(l+1,r-1),d=a-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 kr{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),kr.MAX_RELATIVE_HUMIDITY);return kr.DRY_OPTICAL_DEPTH*(1-t)**-.3}static steppedOpticalDepth(e){const t=kr.OPTICAL_DEPTH_STEP;return Math.round(kr.opticalDepth(e)/t)*t}}function fb(s,e){return JSON.stringify(s.cloudLayers)===JSON.stringify(e.cloudLayers)&&s.cloudCover===e.cloudCover&&s.cloudDarkness===e.cloudDarkness&&s.cloudBaseM===e.cloudBaseM&&s.highCloudCover===e.highCloudCover&&s.iceCrystalAlignment===e.iceCrystalAlignment&&s.lowerCloudCover===e.lowerCloudCover&&s.relativeHumidity===e.relativeHumidity&&s.precipitationType===e.precipitationType&&s.precipitationIntensity===e.precipitationIntensity&&s.windDirectionDeg===e.windDirectionDeg&&s.windSpeed===e.windSpeed&&s.storm===e.storm}const tc=900,nh=1,up=4,dp=.5,La=900,pb=6371e3,mb=3e4;function fp(s){const e=Math.sqrt(2*pb*Math.max(s,0));return Math.max(La,Math.min(e,mb))}const sh=.5,rh=850,pp=.03,Cr=850,ah=4,oh=1.5,mp=-1,gb=6,Wu=-4,gp=.2,ic=2600,vb=.97,Mb=.38,vp=Wu,xb=3,_b=.15,yb=.6,Sb=40,bb=30,Eb=[0,45,90,135,180,225,270,315],wb={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},Ab=["en","fr"],Tb=2,Rb=16,Mp=2500,xp=880,nc=40,_p=60,Db=10,Cb=1,Ib=150,Pb=55,Lb=.5,Nb=2.05,yp=.265,Sp=[[0,0],...Array.from({length:8},(s,e)=>{const t=e*Math.PI/4;return[Math.cos(t)*yp,Math.sin(t)*yp]})],ch=700,lh=250/1e3,Ob=12,bp=5,hh=6,Ns=[.92,.92,.95],uh=[.15,.15,.19],Ep={snow:{fallSpeedMPerS:2,size:.3,color:new oe(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new oe(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},Lr=0,dh=0,Ub=150,wp=3e3,Ea=20,Fb=15,Ap=Lr,kb=40,Tp=1,zb=9;function Rp(s){return Tp+(zb-Tp)*s}const Bb=new oe(.75,.82,.92),Hb=10,Gb=.5;function Vb(s){return za(s/Hb,Gb,1)}const Ir=200,Dp=.18,Cp=.32,Wb=.35,Xb=new oe(.85,.9,.98),Ip=5,Pp=.85,Lp=.01;function fh(s,e){return Math.round(s*(Lp+(1-Lp)*e))}const Np=230,Op=.7,Up=.05,qb=.6,Yb=.7,Kb=.15,Fp=.35,$b=3,Zb=1/12,Jb=.5,_n=new oe(.82,.86,1),jb=2500,Qb=1.6,eE=1.2,tE=2.2,iE={Venus:new oe(1,.96,.85),Mars:new oe(1,.55,.4),Jupiter:new oe(.95,.87,.72),Saturn:new oe(.92,.86,.68)};class Yi{renderer;scene=new Qr;phenomena=new sn(this.scene);references=new Hs(this.scene,()=>this.render());camera;celestialGroup=new ri;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;decorModelProvider=lb[0].create();decorModelToken=0;decorModelCredits=new Map;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;decorReferencePose;decorCurrentPose;decorTime=0;celestialLight=new rf(16777215,0);celestialLightTarget=new At;skyLight=new Ov(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 kl;weather=qp;observerElevationM=0;siteElevationM=0;groundRadius=La;terrainRadius=La;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 Ae;lightningArmed=!1;lightningFlashes=[];lightningLevel=0;lightningBolt;lightningLight=new rf(16777215,0);baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunCloudTransmission=1;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new D;sunVisible=!1;lensFlareScratch=new D;sunOcclusionRaycaster=new kl;sunOcclusionDirectionScratch=new D;sunOcclusionRightScratch=new D;sunOcclusionUpScratch=new D;ufoOcclusionRaycaster=new kl;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;exposureAccumulation;exposureInstants=1;get developingExposure(){return this.exposureInstants>1&&this.exposureInstantAt!==void 0}static EXPOSURE_BUDGET_MS=12;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;rainbow;skyGlow;cometKey;novaKeys=new Set;constructor(e,t=k1()){this.renderer=new Xy({canvas:e,antialias:!0}),this.resolution=new Mt(Math.min(window.devicePixelRatio||1,2),this.renderer.getContext()),this.renderer.setPixelRatio(this.resolution.pixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=Na,this.camera=new Ni(60,e.width/Math.max(e.height,1),.1,tc*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=1,this.celestialLight.shadow.camera.far=1e3,this.celestialLight.shadow.bias=-.0015,this.celestialLight.target=this.celestialLightTarget,this.lightningLight.color.copy(_n),this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight,this.lightningLight),this.scene.add(this.celestialGroup);const i=new ti(this.renderer,()=>{this.skyColoursStale=!0,this.render()});i.supported?this.scatteredSky=i:i.dispose()}get currentTerrainAttribution(){return this.terrainAttribution}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*lh,0,e.z*lh);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)*Di,i=(e.pitchDeg+this.lookPitchDeg+this.gaitOffset.pitchDeg)*Di;if(e.headingDeg!==void 0?this.camera.rotation.set(i,-(e.headingDeg+this.lookYawDeg+this.gaitOffset.yawDeg)*Di,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(fp(e.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/La),this.camera.far=Math.max(tc*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.terrainMesh&&this.terrainOrigin&&e.lat!==void 0&&e.lng!==void 0){const n=hi(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.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}=hi(e,t,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(c*c+l*l)<Ib*(n/La))return}const r=this.terrainOrigin,a=this.terrainRadius;this.terrainOrigin={lat:e,lng:t},this.terrainRadius=n;const o=++this.terrainBuildToken;C5(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=r?hi(e,t,r.lat,r.lng):void 0;u&&d&&Math.hypot(d.x,d.z)<=a&&(c.position.y=u.position.y+this.groundYOfPatch(u,d.x,d.z)),this.disposeMesh(this.terrainMesh),c.renderOrder=Cb,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.render(),i?.()}).catch(c=>{console.warn("Terrain build failed, keeping the flat ground fallback:",c),i?.()})}setShowCompass(e){this.showCompass!==e&&(this.showCompass=e,this.disposeCompassLabels(),e&&this.buildCompassLabels(),this.render())}applyLensFlareTint(e){if(!this.lensFlare)return;const t=Pb*this.sunCloudTransmission;this.lensFlare.uniforms.uColorGain.value.setRGB(t*e[0],t*e[1],t*e[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const e=this.lastSunPosition?.altitudeDeg??-90,t=_S(e)*this.sunCloudTransmission*this.sunUnhiddenFraction,i=ps(e);this.lensFlare.uniforms.uDazzleColour.value.setRGB(i[0],i[1],i[2]),this.lensFlare.uniforms.uVeilStrength.value=Nb**2*Math.max(0,t)}setCompassHovered(e){this.compassHovered!==e&&(this.compassHovered=e,this.updateCompassVisibility())}setCompassForced(e){this.compassForced!==e&&(this.compassForced=e,this.updateCompassVisibility())}updateCompassVisibility(){const e=this.compassHovered||this.compassForced;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(),!fb(this.weather,e)&&(this.weather=e,this.scatteredSky?.setConditions({aerosolOpticalDepth:e.relativeHumidity===void 0?void 0:kr.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.lightningArmed=e.storm&&e.cloudDarkness>=Jb,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(),ci.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear();for(const t of e){const i=ci.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}}setDecorModelProvider(e){this.decorModelProvider=e;const t=this.decorObjects;this.decorObjects=[],this.setDecor(t)}get currentDecorModelCredits(){return[...this.decorModelCredits.values()]}async loadDecorModel(e,t){const i=e.model;if(!(!i||!ci.usesModel(e)))try{const n=i.url?void 0:i.id?await this.decorModelProvider.entry(i.id):void 0,r=i.url??n?.url,a=i.credit??n?.credit;if(!r||!a)return;const o=await hb(r);if(t!==this.decorModelToken)return;const c=this.decorGroups.get(e.id);if(!c)return;ci.applyModel(c,e,o,{headingOffsetDeg:i.headingOffsetDeg??n?.headingOffsetDeg,depictedSizeM:n?.sizeM}),this.decorModelCredits.set(e.id,a),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?hi(e.lat,e.lng,t.lat,t.lng):{x:0,z:0},r=this.decorObjects.find(l=>l.witnessSide!==void 0&&Zp(l.kind));if(this.terrainMesh&&this.terrainOrigin&&t?.lat!==void 0&&t.lng!==void 0){const l=hi(this.terrainOrigin.lat,this.terrainOrigin.lng,t.lat,t.lng);this.terrainMesh.position.x=l.x-(r?0:this.gaitOffset.eastM),this.terrainMesh.position.z=l.z+(r?0:this.gaitOffset.northM)}r||(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 a={x:0,z:0};let o=0;if(r){const l=ci.occupantView(r),h=-(r.headingDeg??0)*Di,u=l.x*Math.cos(h)+l.z*Math.sin(h),d=-l.x*Math.sin(h)+l.z*Math.cos(h),f=r.eastM+n.x,p=-r.northM+n.z;a.x=-(f+u),a.z=-(p+d),this.camera.position.y=this.groundYUnder(f,p)+l.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*Di,-(l.headingDeg+this.indoorLookYawDeg)*Di,0,"YXZ")}for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=qu(l,i),d=u.eastM+n.x+a.x,f=-u.northM+n.z+a.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<=Ub}if(u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*Di),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(b=>typeof b=="number"?b.toFixed(4):b).join(":");h.userData.cropGroundKey!==g&&(ci.fitCropToGround(h,(b,y)=>this.groundYUnder(b,y)+u.altitudeM),h.userData.cropGroundKey=g)}o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(tc*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):dh}groundYOfPatch(e,t,i){const n=e.geometry.getAttribute("position"),r=Math.round(Math.sqrt(n.count));if(r<2||r*r!==n.count)return dh;const a=n.getX(0),o=n.getX(r-1),c=n.getZ(0),l=n.getZ((r-1)*r),h=za((t-a)/(o-a)*(r-1),0,r-1),u=za((i-c)/(l-c)*(r-1),0,r-1);if(!Number.isFinite(h)||!Number.isFinite(u))return dh;const d=Math.min(Math.floor(h),r-2),f=Math.min(Math.floor(u),r-2),p=h-d,v=u-f,m=(E,w)=>n.getY(E*r+w),g=m(f,d),b=m(f,d+1),y=m(f+1,d),_=m(f+1,d+1);return p+v<=1?g+(b-g)*p+(y-g)*v:_+(y-_)*(1-p)+(b-_)*(1-v)}groundUnderFootprint(e,t,i,n,r=0){return ci.groundUnderFootprint(e,t,i,n,(a,o)=>this.groundYUnder(a,o),r)}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&&ci.setLights(n,i.lights,e,n.position.distanceTo(this.camera.position),t),i.kind!=="streetlight"&&i.kind!=="vehicle")continue;const r=this.decorGroups.get(i.id);if(!r)continue;const a=y1(i,e);ci.setLit(r,i.kind,a);const o=this.streetlightLights.get(i.id);o&&(o.visible=a)}}addStreetlightLight(e,t){const i=ci.bodyOf(t),n=i.children.find(a=>a.userData.emissive);if(!n)return;const r=new kv(16764006,Sb,bb);r.position.copy(n.position).multiply(i.scale),r.castShadow=!0,r.shadow.mapSize.set(512,512),r.shadow.bias=-.002,t.add(r),this.streetlightLights.set(e,r)}setAstronomy(e){this.lastAstronomy=e,this.scatteredSky?.update(this.scatteredSkyState(e)),this.skyHoldUntilMs===void 0&&(this.skyHoldUntilMs=performance.now()+Mp,this.onFirstFrameHold?.(!0),setTimeout(()=>this.render(),Mp+20)),this.pumpScatteredSky(),this.lastSunPosition=e.sun,this.buildSky(e.sun),this.buildGround();const t=yu(e.sun.altitudeDeg,this.instrumentMagnitudeGain);this.buildStars(e.stars,t),this.setBodyMesh("sun",e.sun,ah,new oe(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),this.buildIceHalos(e.sun,e.moon),this.buildRainbow(e.sun,e.moon),this.applySkyColours(e),this.syncAnimationLoop(),this.render()}applySkyColours(e){this.skyColoursStale=!1;const t=this.scatteredSky?.ambient??_u(e.sun.altitudeDeg),i=t.horizon;this.baseFogColor=[i[0],i[1],i[2]],this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.scatteredSky?.ready?this.scatteredSky.material:this.skyGradientMaterial),this.updateCloudLighting(e.sun,this.baseFogColor),this.updateCelestialLight(e,t.zenith,i),this.buildSkyGlow(e,t.zenith),this.scene.fog instanceof Cc?(this.scene.fog.color.setRGB(...this.baseFogColor),this.scene.fog.near=this.groundRadius*.2,this.scene.fog.far=this.groundRadius):this.scene.fog=new Cc(new oe(...this.baseFogColor),this.groundRadius*.2,this.groundRadius)}setSiteElevation(e){Math.abs(e-this.siteElevationM)<1||(this.siteElevationM=e,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:Ve.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?Rb:Tb),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 X5(rh),this.celestialGroup.add(this.satelliteField.object));const t=yu(this.lastSunPosition?.altitudeDeg??-90,this.instrumentMagnitudeGain);this.satelliteField.set(e,t,i=>this.cloudTransmission(i)),this.render()}pickSatelliteAt(e,t){if(!this.satelliteField?.count)return;this.aimAtScreenPoint(this.raycaster,e,t);const i=Math.cos(pp*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,i){this.skyLight.color.setRGB(t[0],t[1],t[2]),this.skyLight.groundColor.setRGB(i[0],i[1],i[2]),this.skyLight.intensity=yb;const n=e.sun.altitudeDeg>=vp,r=!n&&e.moon.altitudeDeg>=vp;if(!n&&!r){this.celestialLight.intensity=0;return}const a=n?e.sun:e.moon,{x:o,y:c,z:l}=ni(a.altitudeDeg,a.azimuthDeg,Cr);this.celestialLight.position.set(o,c,l);const h=ps(a.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const u=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*Di));this.celestialLight.intensity=(n?xb:_b)*u,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(e,t,i){this.meteorSystem||(this.meteorSystem=new ei,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=Yt.starPointsOf(e),i=Yt.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.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.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()+Yi.COMPILE_WAIT_MS;return new Promise(n=>{const r=()=>{if(this.contextReleased)return n();for(const a of e){const o=t.get(a)?.currentProgram;(!o||o.isReady())&&e.delete(a)}e.size===0||performance.now()>i?n():setTimeout(r,10)};r()})}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()}animate(e,t){const i=Math.min(t/1e3,Zb);this.updateTwinkle(e/1e3),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,a,o)=>this.directionAtScreenPoint(r,a,o),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());const n=this.renderer.getRenderTarget();if(!t){this.updateLensFlarePosition();const r=this.usableDepthOfFieldPass();r?.setEncodesOutput(e===void 0),this.skyGlow?.setDestinationEncoded(e===void 0&&!r),e&&this.renderer.setRenderTarget(e),r?r.render(this.renderer,this.scene,this.camera,()=>this.renderOverlayPasses()):(this.renderer.render(this.scene,this.camera),this.renderOverlayPasses()),e&&this.renderer.setRenderTarget(n);return}t.setEncodesOutput(e===void 0),this.skyGlow?.setDestinationEncoded(!1),e&&this.renderer.setRenderTarget(e),t.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition(),r=>this.renderOverlayPasses(r),r=>{this.lensFlare&&(this.lensFlare.mesh.visible=r?!1:this.sunVisible)},()=>this.renderDazzleOnResample()),e&&this.renderer.setRenderTarget(n)}renderOverlayPasses(e=this.camera){this.renderReferencesPass(e),this.renderPhenomenaPass(e)}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(Rg),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 r=this.decorGroups.get(n.id);r&&Yi.markDecorDepth(r,n.kind!=="crop")}e.layers.set(nh),this.scene.overrideMaterial=this.decorDepthMaterial,this.renderer.render(this.scene,e),this.scene.overrideMaterial=null,e.layers.set(Tg),this.renderer.render(this.scene,e),e.layers.set(0),this.renderer.autoClear=t,this.renderer.shadowMap.autoUpdate=i}decorDepthMaterial=new Ji({colorWrite:!1});static markDecorDepth(e,t){e.traverse(i=>{if(!(i instanceof We))return;const n=Array.isArray(i.material)?i.material[0]:i.material;t&&n.depthWrite!==!1&&n.blending!==Gi?i.layers.enable(nh):i.layers.disable(nh)})}startExposure(){this.cancelExposure(),this.exposureSubjectBounds=[];const e=this.renderer.getDrawingBufferSize(new Ae),t=Math.max(1,Math.round(e.x)),i=Math.max(1,Math.round(e.y));this.exposureAccumulation||(this.exposureAccumulation=new jy(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()+Yi.EXPOSURE_BUDGET_MS,r=Yi.exposureInstantsPerFrame(t.instantTarget.width*t.instantTarget.height);let a=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++,a++}while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<n&&a<r);this.restateAt(e,0),this.presentExposure(),this.resolution.endDrawing(),this.exposureInstantsDone<this.exposureInstants&&(this.exposureFrameId=requestAnimationFrame(()=>this.developExposure()))}presentExposure(){if(this.exposureAccumulation?.develop(this.renderer,this.exposureInstants/this.exposureInstantsDone),this.onMapSubjectBounds?.(this.exposureSubjectBounds),!this.compassSprites.some(r=>r.visible))return;const e=new Qr,t=new Ts(-1,1,1,-1,0,2),i=nc/(xp*Math.tan(_p*Di/2));for(const r of this.compassSprites){if(!r.visible)continue;const a=r.getWorldPosition(new D).sub(this.camera.position).normalize(),o=this.screenPointOf(a);if(!o)continue;const c=new Sr(r.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=[];mapSubjectBounds(){const e=[],t=new un,i=new D;for(const n of this.decorObjects){if(!n.track?.length&&n.kind!=="aircraft"&&n.kind!=="vehicle")continue;const r=this.decorGroups.get(n.id);if(!r?.visible||(t.setFromObject(r),t.isEmpty()))continue;let a=1/0,o=-1/0,c=1/0,l=-1/0;for(const h of[t.min.x,t.max.x])for(const u of[t.min.y,t.max.y])for(const d of[t.min.z,t.max.z]){i.set(h,u,d).sub(this.camera.position).normalize();const f=this.screenPointOf(i);if(!f)continue;const p=(f.ndcX+1)/2,v=(1-f.ndcY)/2;a=Math.min(a,p),o=Math.max(o,p),c=Math.min(c,v),l=Math.max(l,v)}Number.isFinite(a)&&e.push({x:a,y:c,width:o-a,height:l-c})}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 Ae),i=Math.max(1,Math.round(t.x)),n=Math.max(1,Math.round(t.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new ka(i,n)),this.depthOfFieldPass.resize(i,n),this.depthOfFieldPass.setLens(e.focalLengthMm,e.fNumber,e.focusDistance,e.frameHeightMm),this.depthOfFieldPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const e=this.renderer.getDrawingBufferSize(new Ae);return this.equidistantPass?this.equidistantPass.resize(e.x,e.y):this.equidistantPass=new Wn(e.x,e.y),this.equidistantPass}aimAtScreenPoint(e,t,i){const n=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!n){e.setFromCamera(new Ae(t,i),this.camera);return}const r=n.directionFor(t,i,this.camera.fov);this.camera.updateMatrixWorld(),e.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),e.ray.direction.set(r.x,r.y,r.z).applyQuaternion(this.camera.quaternion).normalize(),e.camera=this.camera}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 Wn.ndcFor(t,this.camera.fov,n);if(t.z>=0)return;const r=Math.tan(this.camera.fov/2*Di);return{ndcX:t.x/-t.z/(n*r),ndcY:t.y/-t.z/r}}screenPointScratch=new D;screenPointQuaternion=new Qn;screenPointSize=new Ae;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,r=this.renderer.domElement.height;e.uniforms.uResolution.value.set(n,r),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 r=this.renderer.autoClear;this.renderer.autoClear=!1,e.mesh.visible=!0,e.mesh.layers.enable(up),this.camera.layers.set(up),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),e.mesh.visible=!1,e.uniforms.uEquidistant.value=0,this.renderer.autoClear=r}sunVisibleFraction(){this.raycastableDecor().length>0&&this.scene.updateMatrixWorld();let e=0;for(const t of Sp)this.isSunOccluded(t[0],t[1])||e++;return e/Sp.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),r=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,r))return!0;if(i.length===0)return!1;this.sunOcclusionRaycaster.set(this.camera.position,n);const a=this.sunOcclusionRaycaster.intersectObjects(i,!0)[0];return a!==void 0&&a.distance<r}groundBlocks(e,t,i,n=0){const r=this.groundMesh;if(r&&t.y<0){const m=(r.position.y-e.y)/t.y;if(m>n&&m<i){const g=e.x+t.x*m-r.position.x,b=e.z+t.z*m-r.position.z;if(Math.hypot(g,b)<=this.groundRadius)return!0}}const a=this.terrainMesh;if(!a)return!1;const o=a.geometry.getAttribute("position"),c=Math.round(Math.sqrt(o.count));if(c<2||c*c!==o.count)return!1;const l=[a.position.x+o.getX(0),a.position.x+o.getX(c-1)],h=[a.position.z+o.getZ(0),a.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,b]of[[e.x,t.x,l],[e.z,t.z,h]]){const y=Math.min(b[0],b[1]),_=Math.max(b[0],b[1]);if(Math.abs(g)<1e-12){if(m<y||m>_)return!1;continue}const E=(y-m)/g,w=(_-m)/g;d=Math.max(d,Math.min(E,w)),f=Math.min(f,Math.max(E,w))}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,b=e.x+t.x*g,y=e.y+t.y*g,_=e.z+t.z*g;if(y<=this.groundYUnder(b,_))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=dp;let n,r;for(const a of this.decorObjects){if(a.kind==="crop")continue;const o=this.decorGroups.get(a.id);if(!o)continue;const c=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];c&&(a.occludesSourceIds?.includes(i)?n=n===void 0?c.distance:Math.max(n,c.distance):r=r===void 0?c.distance:Math.min(r,c.distance))}return{behindM:n,inFrontM:r}}pickBodyAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const i=[...this.hitAreas.entries()],n=this.raycaster.intersectObjects(i.map(([,r])=>r))[0];if(n&&!this.groundHides(e,t))return i.find(([,r])=>r===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(pp*this.camera.fov*Math.PI/180);let r,a=n;for(const o of this.namedStars){const c=o.direction.dot(i);c>a&&(a=c,r={star:o.star,altitudeDeg:o.altitudeDeg})}return r&&this.groundHides(e,t)?void 0:r}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,dp)}pickDecorAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const i=[...this.decorGroups.entries()],n=this.raycaster.intersectObjects(i.map(([,a])=>a),!0)[0];if(!n)return;let r=n.object;for(;r&&!i.some(([,a])=>a===r);)r=r.parent;return i.find(([,a])=>a===r)?.[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.disposeCloudSystem(),this.disposeCirrus(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers(),this.meteorSystem?.dispose(),this.meteorSystem=void 0,this.iceHalos?.dispose(),this.iceHalos=void 0,this.rainbow?.dispose(),this.rainbow=void 0,this.skyGlow?.dispose(),this.skyGlow=void 0,this.depthOfFieldPass?.dispose(),this.depthOfFieldPass=void 0,this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0,this.cometTail?.dispose(),this.cometTail=void 0,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())ci.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 di(tc,32,16),i=t.attributes.position,n=t.getAttribute("color")??new Pt(new Float32Array(i.count*3),3);for(let a=0;a<i.count;a++){const{altitudeDeg:o,azimuthDeg:c}=tS(i.getX(a),i.getY(a),i.getZ(a)),l=lS(o,c,e.azimuthDeg,e.altitudeDeg);n.setXYZ(a,l[0],l[1],l[2])}if(n.needsUpdate=!0,this.skyMesh)return;t.setAttribute("color",n);const r=new Ji({vertexColors:!0,side:It,fog:!1,depthWrite:!1});this.skyGradientMaterial=r,this.skyMesh=new We(t,r),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){const e=fp(this.observerElevationM);if(this.groundMesh&&e===this.groundRadius)return;this.disposeMesh(this.groundMesh),this.groundRadius=e;const t=new hd(this.groundRadius,48),i=new eo({color:new oe(sh,sh,sh),fog:!0});this.groundMesh=new We(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){const t=`${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,a])=>`${r}=${Math.round(a.x/10)},${Math.round(a.z/10)}`).join(";"),i=this.cloudTransmissionMemo.get(t);if(i!==void 0)return i;this.cloudTransmissionMemo.size>256&&this.cloudTransmissionMemo.clear();const n=this.computeCloudTransmission(e);return this.cloudTransmissionMemo.set(t,n),n}cloudTransmissionMemo=new Map;computeCloudTransmission(e){const t=ni(e.altitudeDeg,e.azimuthDeg,1);if(this.layeredClouds)return this.layeredClouds.transmissionAt(t);let i=1;const n=this.lowerCloudCover();n>0&&(i*=1-st.alphaAt(t,Math.abs(this.cloudLayerOffset()),n,this.cloudFieldOffset)*vb);const r=this.weather.highCloudCover??0;return r>0&&(i*=1-st.iceAlphaAt(t,ic,r,this.cloudFieldOffset)*Mb),Math.max(0,Math.min(1,i))}setBodyMesh(e,t,i,n,r){if(t.altitudeDeg<Wu){this.disposeMesh(this.bodyMeshes.get(e)),this.bodyMeshes.delete(e),this.disposeHitArea(e),this.disposeGlare(e),e==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:c}=ni(t.altitudeDeg,t.azimuthDeg,Cr),l=ps(t.altitudeDeg),h=this.cloudTransmission(t),u=new oe(n.r*l[0]*h,n.g*l[1]*h,n.b*l[2]*h);let d=this.bodyMeshes.get(e);d instanceof We?d.material.color.copy(u):(this.disposeMesh(d),d=new We(new di(1,16,16),new Ji({color:u,fog:!1})),this.celestialGroup.add(d),this.bodyMeshes.set(e,d)),d.scale.setScalar(i),d.position.set(a,o,c),this.setHitArea(e,a,o,c,i);const f=r-2.5*Math.log10(Math.max(h,.001));if(e==="sun"&&(this.sunCloudTransmission=h),e!=="sun"&&this.setGlare(e,a,o,c,f,u),e==="sun"){this.sunVisible=!0;const p=this.celestialGroup.scale.x;this.sunWorldPosition.set(a*p,o*p+this.celestialGroup.position.y,c*p),this.lensFlare||(this.lensFlare=W5(),this.lensFlare.uniforms.uOpacity.value=Lb,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<Wu){this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i);return}const{x:n,y:r,z:a}=ni(e.altitudeDeg,e.azimuthDeg,Cr),o=ps(e.altitudeDeg),c=new oe(o[0],o[1],o[2]),l=`${e.phase.phaseFraction<.5}:${Math.round(za(e.phase.illuminatedFraction,0,1)*500)}`;let h=this.bodyMeshes.get(i);if(h instanceof Sr)h.userData.phaseKey!==l&&(h.material.map?.dispose(),h.material.map=zp(e.phase),h.userData.phaseKey=l),h.material.color.copy(c);else{this.disposeMesh(h),h=new Sr(new Ta({map:zp(e.phase),color:c,fog:!1})),h.userData.phaseKey=l;const u=ah*2;h.scale.set(u,u,1),this.celestialGroup.add(h),this.bodyMeshes.set(i,h)}h.position.set(n,r,a),this.setHitArea(i,n,r,a,ah),this.setGlare(i,n,r,a,e.magnitude,c)}setHitArea(e,t,i,n,r){let a=this.hitAreas.get(e);if(!a){const c=new Ta({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1});a=new Sr(c),this.celestialGroup.add(a),this.hitAreas.set(e,a)}a.position.set(t,i,n);const o=r*gb;a.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,r,a){const o=dS(r);if(o<=0){this.disposeGlare(e);return}const c=mS(o),l=this.glareSprites.get(e),h=l??new Sr(new Ta({map:uE(),transparent:!0,blending:Gi,depthWrite:!1,fog:!1}));h.material.color.copy(a),h.material.opacity=MS(o),h.position.set(t,i,n),h.scale.set(c*2,c*2,1),l||(this.celestialGroup.add(h),this.glareSprites.set(e,h))}disposeGlare(e){const t=this.glareSprites.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.glareSprites.delete(e))}buildComet(e,t){const i=e&&`comet:${e.id}`;if(!e||!i||e.magnitude>t){this.disposeComet();return}this.cometKey&&this.cometKey!==i&&this.disposeComet();const n=Da(e.magnitude,t),r=Ca(n);this.cometKey=i,this.setBodyMesh(i,e.position,oh*(.5+.5*n),new oe(r,r,r),e.magnitude),this.cometTail||(this.cometTail=new zi(Cr),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(e.position,e.tailEnd,n)}buildIceHalos(e,t){this.iceHalos||(this.iceHalos=new Si,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:ic},0);return}const r=this.lowerCloudCover(),a=nt.deckLitUntilDeg(nt.DECK_HEIGHT_M),o=e.altitudeDeg>-a?e:t,c=nt.strength(i,r,o.altitudeDeg,a)*(o===e?1:gp),{x:l,y:h,z:u}=ni(o.altitudeDeg,o.azimuthDeg,1),d=ps(o.altitudeDeg);this.iceHalos.update({x:l,y:h,z:u},o.altitudeDeg,c,[d[0],d[1],d[2]],{cover:n?.cover??i,layerHeight:n?.layerHeight??ic},n?.iceCrystalAlignment??this.weather.iceCrystalAlignment??.65)}buildRainbow(e,t){this.rainbow||(this.rainbow=new Ws,this.celestialGroup.add(this.rainbow.object));const i=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity:0,n=e.altitudeDeg>0,r=n?e:t,a=this.lowerCloudCover(),o=gp*Pi.moonlightShare(t.magnitude),c=Pi.strength(i,a,r.altitudeDeg)*(n?1:o);if(c<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:l,y:h,z:u}=ni(r.altitudeDeg,r.azimuthDeg,1),d=ps(r.altitudeDeg);this.rainbow.update({x:l,y:h,z:u},c,[d[0],d[1],d[2]],n)}buildSkyGlow(e,t){if(!e.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new gs,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:i,observer:n}=e.frame,r=nn.galactic(i,n),a=Yi.directionOf(r.centre),o=Yi.directionOf(r.rotation),c=Yi.directionOf(r.pole),l=new He().set(a.x,a.y,a.z,o.x,o.y,o.z,c.x,c.y,c.z),h=Yi.directionOf(nn.eclipticPole(i,n)),u=Yi.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:Yi.directionOf(e.moon),altitudeDeg:e.moon.altitudeDeg,phaseAngleDeg:Ve.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 r=`nova:${n.id}`;i.add(r);const a=Da(n.magnitude,t),o=Ca(a);this.setBodyMesh(r,n.position,oh*(.5+.5*a),new oe(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 r=Da(n.magnitude,t),a=Ca(r),o=iE[n.body]??new oe(1,1,1),c=new oe(o.r*a,o.g*a,o.b*a),l=oh*(.5+.5*r);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:r}=e,a=new an(n,r),o=ph(1337),c=[];for(let l=0;l<i.count;l++){const h=i.mag[l];if(h>t)break;const{altitudeDeg:u,azimuthDeg:d}=a.position(i.ra[l],i.dec[l]);if(u<mp)continue;const{x:f,y:p,z:v}=ni(u,d,rh);c.push({x:f,y:p,z:v,brightness:Da(h,t),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}for(const l of E5){if(l.mag>t)continue;const{altitudeDeg:h,azimuthDeg:u}=a.position(l.raHours,l.decDeg);if(h<mp)continue;const{x:d,y:f,z:p}=ni(h,u,rh);this.namedStars.push({star:l,direction:new D(d,f,p).normalize(),altitudeDeg:h})}this.starTiers=xd.map((l,h)=>{const u=c.filter(y=>Jm(y.brightness)===h),d=new Float32Array(u.length*3),f=new Float32Array(u.length),p=new Float32Array(u.length),v=new Float32Array(u.length);u.forEach((y,_)=>{d[_*3]=y.x,d[_*3+1]=y.y,d[_*3+2]=y.z,f[_]=y.brightness,p[_]=y.phase,v[_]=y.speedFactor});const m=new bt;m.setAttribute("position",new ot(d,3));const g=new ot(new Float32Array(u.length*3),3);m.setAttribute("color",g);let b=this.starTiers[h]?.points;if(b)b.geometry.dispose(),b.geometry=m;else{const y=new ld({vertexColors:!0,size:l.size,sizeAttenuation:!1,fog:!1});_s.apply(y),b=new Fa(m,y),this.celestialGroup.add(b)}return{points:b,colorAttribute:g,brightness:f,phase:p,speedFactor:v}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(e){for(const t of this.starTiers){const i=t.colorAttribute.array;for(let n=0;n<t.brightness.length;n++){const r=ES(t.brightness[n],{phase:t.phase[n],speedFactor:t.speedFactor[n]},e),a=Ca(t.brightness[n])*r;i[n*3]=a,i[n*3+1]=a,i[n*3+2]=a}t.colorAttribute.needsUpdate=!0}}buildClouds(){if(this.cloudRendering==="volume"||this.weather.cloudLayers!==void 0){this.layeredClouds||(this.disposeCloudSystem(),this.layeredClouds=new Wr(this.celestialGroup,ch,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 oe(Ns[0]+(uh[0]-Ns[0])*t,Ns[1]+(uh[1]-Ns[1])*t,Ns[2]+(uh[2]-Ns[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:r}=mu(i,e,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=n,this.cloudUniforms=r,r.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const a=gu(ch);this.cloudMesh=new We(a,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}=mu(new oe(...Ns),e,ic,1);this.cirrusMaterial=t,this.cirrusUniforms=i,i.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new We(gu(ch*1.04),t),this.cirrusMesh.renderOrder=bp-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?Wr.deckOrder(!0,0,1):bp}cloudLayerOffset(){const t=((this.weather.cloudBaseM??1e3)-this.observerElevationM)*lh;return Math.sign(t||1)*Math.max(Math.abs(t),Ob)}updateCloudLighting(e,t){const i=[this.cloudUniforms,this.cirrusUniforms].filter(u=>u!==void 0);if(i.length===0&&!this.layeredClouds)return;const{x:n,y:r,z:a}=ni(e.altitudeDeg,e.azimuthDeg,1),o=ps(e.altitudeDeg),c=Math.max(0,Math.sin(Math.max(e.altitudeDeg,0)*Di)),l=this.lightningLevel*eE,h=new oe(t[0]+_n.r*l,t[1]+_n.g*l,t[2]+_n.b*l);this.layeredClouds?.setLighting(new D(n,r,a),new oe(o[0],.96*o[1],.88*o[2]),h,h);for(const u of i)u.sunDir.value.set(n,r,a),u.sunColor.value.setRGB(o[0]*c,.96*o[1]*c,.88*o[2]*c),u.ambientColor.value.copy(h)}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=Ep[e],i=t.poolSize,n=ph(9001),r=new Float32Array(i*3),a=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 y=0;y<i;y++){const _=n()*Math.PI*2,E=n()*t.radiusM;r[y*3]=Math.cos(_)*E,r[y*3+1]=Lr+n()*(t.topYM-Lr),r[y*3+2]=Math.sin(_)*E,a[y]=n()*Math.PI*2,o[y]=.7+n()*.6,c[y]=.6+n()*.8,l[y]=.4+n()*1.2}const v=new bt;v.setAttribute("position",new ot(r,3)),v.setDrawRange(0,fh(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},uHazeColor:{value:new oe(...this.baseFogColor)},uTexture:{value:nE(e)},uNearFocusDistance:{value:Ip},uHazeDistance:{value:t.radiusM*Pp}},g=new Et({uniforms:m,vertexShader:lE,fragmentShader:hE,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const b=new Fa(v,g);b.renderOrder=hh,this.scene.add(b),this.precipitationPoints=b,this.precipitationPositions=r,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=c,this.precipitationWobbleAmpJitter=l,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=u,this.precipitationBounceDuration=d,this.precipitationBounceVelX=f,this.precipitationBounceVelZ=p}updatePrecipitation(e,t){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter||(this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor),t<=0))return;const i=this.weather.precipitationType;if(i==="none"||i==="rain")return;const n=Ep[i],r=this.weather.windDirectionDeg*Di,a=Math.sin(r)*this.weather.windSpeed*n.driftSensitivity,o=-Math.cos(r)*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,b=i==="snow"&&u&&d,y=i==="hail"&&f&&p&&v&&m&&g;for(let _=0,E=0;_<c.length;_+=3,E++){if(y&&f[E]>0){if(f[E]-=t,f[E]<=0){const x=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*n.radiusM;c[_]=Math.cos(x)*A,c[_+1]=n.topYM,c[_+2]=Math.sin(x)*A,f[E]=0}else{const x=1-f[E]/v[E];c[_+1]=Lr+Math.sin(Math.PI*x)*p[E],c[_]=sc(c[_]+(a+m[E])*t,n.radiusM),c[_+2]=sc(c[_+2]+(o+g[E])*t,n.radiusM)}continue}let w=0,R=0;if(b){const x=qb*u[E],A=Yb*d[E];w=Math.sin(e*x*Math.PI*2+l[E])*A,R=Math.sin(e*x*Math.PI*2+l[E]+Math.PI/2)*A}if(c[_]+=(a+w)*t,c[_+1]-=n.fallSpeedMPerS*h[E]*t,c[_+2]+=(o+R)*t,c[_]=sc(c[_],n.radiusM),c[_+2]=sc(c[_+2],n.radiusM),c[_+1]<Lr){if(y){p[E]=Fp*(.2+Math.random()*1.6),v[E]=Kb*(.5+Math.random()),f[E]=v[E];const I=Math.random()*Math.PI*2,C=$b*(p[E]/Fp);m[E]=Math.cos(I)*C,g[E]=Math.sin(I)*C,c[_+1]=Lr;continue}const x=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*n.radiusM;c[_]=Math.cos(x)*A,c[_+1]=n.topYM,c[_+2]=Math.sin(x)*A}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const e=Rp(this.weather.precipitationIntensity);this.rainSystem=B5({count:wp,radiusM:Ea,heightM:Fb,bottomYM:Ap,overallSpeed:kb,color:Bb,opacity:.85,visibleCount:fh(wp,this.weather.precipitationIntensity),speedStreak:Vb(e),pixelSize:Np,seed:9001,nearFocusDistanceM:Ip,hazeDistanceM:Ea*Pp,hazeColor:new oe(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=hh,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const e=ph(4242),t=new Float32Array(Ir*3),i=new Float32Array(Ir),n=new Float32Array(Ir),r=new Float32Array(Ir);for(let h=0;h<Ir;h++){const u=e()*Math.PI*2,d=Math.sqrt(e())*Ea;t[h*3]=Math.cos(u)*d,t[h*3+1]=Ap,t[h*3+2]=Math.sin(u)*d,n[h]=kp(Dp,Cp),i[h]=e()*n[h],r[h]=i[h]/n[h]}const a=new bt;a.setAttribute("position",new ot(t,3));const o=new ot(r,1);a.setAttribute("aLife",o),a.setDrawRange(0,fh(Ir,this.weather.precipitationIntensity));const c=new Et({uniforms:{uMaxSize:{value:Wb},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:Xb},uTexture:{value:aE()}},vertexShader:oE,fragmentShader:cE,transparent:!0,depthWrite:!1}),l=new Fa(a,c);l.renderOrder=hh,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*Di;e.uniforms.uDropVelocity.value.set(Math.sin(t)*this.weather.windSpeed,-Rp(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);const i=this.weather.windDirectionDeg*Di,n=Math.sin(i)*this.weather.windSpeed,r=-Math.cos(i)*this.weather.windSpeed,a=Ea,o=l=>(l%(a*2)+a*3)%(a*2)-a;t.uniforms.uWindOffset.value.set(o(t.uniforms.uWindOffset.value.x+n*e),o(t.uniforms.uWindOffset.value.y+r*e)),this.syncRainSlant(),this.camera.getWorldDirection(this.rainCameraDirection);const c=Math.abs(this.rainCameraDirection.y);if(Math.abs(c-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=c;const l=Op+(1-Op)*(1-c),h=Up+(1-Up)*(1-c);t.uniforms.uUvSquash.value=h,t.uniforms.uPixelSize.value=Np*l*(.5+.5*h)}this.updateRainSplashes(e)}updateRainSplashes(e){const t=this.rainSplashSystem;if(!t||e<=0)return;const{positions:i,life:n,duration:r,lifeAttribute:a}=t,o=a.array;for(let c=0,l=0;c<i.length;c+=3,l++){if(n[l]+=e,n[l]>=r[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*Ea;i[c]=Math.cos(h)*u,i[c+2]=Math.sin(h)*u,r[l]=kp(Dp,Cp),n[l]=0}o[l]=n[l]/r[l]}t.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}setLightning(e){this.lightningFlashes=e}updateLightning(e){let t,i=0;if(this.lightningArmed)for(const o of this.lightningFlashes){if(o.t>e)break;const c=Kt.brightnessAt(o,e);c>i&&(t=o,i=c)}const n=t?Math.min(1,Math.max(.1,(jb/t.distanceM)**2)):0,r=i*n*(t?.cloudToGround?1:.6);if(r===this.lightningLevel&&!t?.cloudToGround)return;if(this.lightningLevel=r,this.scene.fog){const o=this.scene.fog,c=Math.min(1,r);o.color.setRGB(this.baseFogColor[0]+(_n.r-this.baseFogColor[0])*c,this.baseFogColor[1]+(_n.g-this.baseFogColor[1])*c,this.baseFogColor[2]+(_n.b-this.baseFogColor[2])*c)}if(this.skyMesh){const o=r*Qb;this.skyMesh.material.color.setRGB(1+o*_n.r,1+o*_n.g,1+o*_n.b)}if(this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.lightningLight.intensity=r*tE,t){const{x:o,y:c,z:l}=ni(25,t.azimuthDeg,Cr);this.lightningLight.position.set(o,c,l)}this.lightningBolt||(this.lightningBolt=new Ur(Cr*.95),this.celestialGroup.add(this.lightningBolt.object));const a=this.weather.cloudBaseM??1500;this.lightningBolt.set(t,i,a),this.render()}buildCompassLabels(){const e=Yu(navigator.languages,Ab),t=wb[e];this.compassSprites=Eb.map((i,n)=>{const r=t[n],a=new Ta({map:dE(r),depthTest:!1,fog:!1}),o=new Sr(a),{x:c,y:l,z:h}=ni(0,i,xp);return o.position.set(c,l,h),o.scale.set(nc,nc,1),o.renderOrder=Db,o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o}),this.updateCompassScale()}updateCompassScale(){const e=this.camera.fov*Math.PI/360,t=_p*Math.PI/360,i=nc*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 Di=Math.PI/180;function za(s,e,t){return Math.max(e,Math.min(t,s))}function kp(s,e){return s+Math.random()*(e-s)}function sc(s,e){return(s%(e*2)+e*3)%(e*2)-e}let rc,ac;function nE(s){switch(s){case"snow":return sE();case"hail":return rE()}}function sE(){if(rc)return rc;const s=64,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),i=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/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,s,s),rc=new Ln(e),rc}function rE(){if(ac)return ac;const s=64,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),i=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/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,s,s),ac=new Ln(e),ac}let oc;function aE(){if(oc)return oc;const s=64,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),i=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/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,s,s),oc=new Ln(e),oc}const oE=`
|
|
6521
6521
|
uniform float uMaxSize;
|
|
6522
6522
|
uniform float uScale;
|
|
6523
6523
|
attribute float aLife;
|
|
@@ -6530,7 +6530,7 @@ void main() {
|
|
|
6530
6530
|
vOpacity = 1.0 - aLife;
|
|
6531
6531
|
gl_Position = projectionMatrix * mvPosition;
|
|
6532
6532
|
}
|
|
6533
|
-
`,
|
|
6533
|
+
`,cE=`
|
|
6534
6534
|
uniform vec3 uColor;
|
|
6535
6535
|
uniform sampler2D uTexture;
|
|
6536
6536
|
varying float vOpacity;
|
|
@@ -6541,7 +6541,7 @@ void main() {
|
|
|
6541
6541
|
if (alpha < 0.01) discard;
|
|
6542
6542
|
gl_FragColor = vec4(uColor, alpha);
|
|
6543
6543
|
}
|
|
6544
|
-
`,
|
|
6544
|
+
`,lE=`
|
|
6545
6545
|
uniform float uSize;
|
|
6546
6546
|
uniform float uScale;
|
|
6547
6547
|
uniform float uNearFocusDistance;
|
|
@@ -6567,7 +6567,7 @@ void main() {
|
|
|
6567
6567
|
gl_PointSize = max(1.0, uSize * uScale / dist + vNearBlur * 12.0);
|
|
6568
6568
|
gl_Position = projectionMatrix * mvPosition;
|
|
6569
6569
|
}
|
|
6570
|
-
`,
|
|
6570
|
+
`,hE=`
|
|
6571
6571
|
precision mediump float;
|
|
6572
6572
|
uniform sampler2D uTexture;
|
|
6573
6573
|
uniform vec3 uColor;
|
|
@@ -6582,5 +6582,5 @@ void main() {
|
|
|
6582
6582
|
float blur = max(vNearBlur, vHaze);
|
|
6583
6583
|
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * 0.5));
|
|
6584
6584
|
}
|
|
6585
|
-
`;let cc;function
|
|
6586
|
-
`);let r=Sn.cache.get(n);return r||(r=Promise.all(i.map(a=>Sn.load(a.url))).then(a=>a.reduce((o,c)=>Sn.concat(o,c))),Sn.cache.set(n,r)),r}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,r)=>{const a=new Float32Array(n.length+r.length);return a.set(n,0),a.set(r,n.length),a};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 fw=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,pw=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,mw=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,gw=20,vw=1;class Mw{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 a=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,n!=="none"&&this.startLoop(fw,this.ambientVolume).then(o=>this.applyIfCurrent(o,a,()=>this.ambientToken,c=>{this.ambientSource=c?.source,this.ambientGain=c?.gain,c&&(c.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(i/gw,1);const r=i>vw;if(r!==this.windActive){this.windActive=r;const a=++this.windToken;this.stopSource(this.windSource,this.windGain),this.windSource=void 0,this.windGain=void 0,r&&this.startLoop(pw,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,c=>{this.windSource=c?.source,this.windGain=c?.gain,c&&(c.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(e){if(e===this.paused)return;this.paused=e;const{type:t,intensity:i,windSpeed:n}=this.requested;this.setAmbient(t,i,n)}playThunder(){!this.context||this.paused||this.playOneShot(mw,.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),r=i.createBufferSource();r.buffer=n,r.loop=!0;const a=i.createGain();return a.gain.value=t,r.connect(a).connect(i.destination),r.start(),{source:r,gain:a}}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),r=i.createBufferSource();r.buffer=n;const a=i.createGain();a.gain.value=t,r.connect(a).connect(i.destination),r.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 Vn{constructor(e){this.elements=e;const{eccentricity:t,perihelionAu:i}=e,[n,r]=this.perifocalAxes(),a=Math.sqrt(Vn.SUN_GM_AU3_PER_DAY2*(1+t)/i);this.perihelionPosition=this.scale(n,i),this.perihelionVelocity=this.scale(r,a),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,r=this.elements.perihelionAu,a=1-i*i/r*Vn.stumpffC(n),o=t-i*i*i/Math.sqrt(Vn.SUN_GM_AU3_PER_DAY2)*Vn.stumpffS(n);return{x:a*this.perihelionPosition.x+o*this.perihelionVelocity.x,y:a*this.perihelionPosition.y+o*this.perihelionVelocity.y,z:a*this.perihelionPosition.z+o*this.perihelionVelocity.z}}heliocentricDistanceAt(e){const t=this.positionAt(e);return Math.hypot(t.x,t.y,t.z)}universalAnomaly(e){if(e===0)return 0;const t=Math.sign(e),i=Math.sqrt(Vn.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*Vn.stumpffS(c)+l*o};let r=Math.max(1,i/this.elements.perihelionAu);for(;n(r)<i;)r*=2;let a=0;for(let o=0;o<Vn.MAX_ITERATIONS&&r-a>1e-13*Math.max(1,r);o++){const c=(a+r)/2;n(c)<i?a=c:r=c}return t*(a+r)/2}perifocalAxes(){const e=this.elements.ascendingNodeDeg*Math.PI/180,t=this.elements.argumentOfPerihelionDeg*Math.PI/180,i=this.elements.inclinationDeg*Math.PI/180,n=Math.cos(e),r=Math.sin(e),a=Math.cos(t),o=Math.sin(t),c=Math.cos(i),l=Math.sin(i);return[{x:n*a-r*o*c,y:r*a+n*o*c,z:o*l},{x:-n*o-r*a*c,y:-r*o+n*a*c,z:a*l}]}scale(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}static stumpffC(e){if(Math.abs(e)<1e-6)return 1/2-e/24+e*e/720;if(e>0)return(1-Math.cos(Math.sqrt(e)))/e;const t=Math.sqrt(-e);return(Math.cosh(t)-1)/-e}static stumpffS(e){if(Math.abs(e)<1e-6)return 1/6-e/120+e*e/5040;if(e>0){const 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 Dg=[{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 xw{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 Dg.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=Lt(t),r=this.earthPositionAt(n),a=this.apparentPositionOf(e,2451545+n.tt,r),o=this.subtract(a,r),c=this.length(a),l=this.length(o),h=this.tailEndAt(e,a,r,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},r)),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,r,a,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,r,a,o),tailLengthDeg:this.angleBetween(h,l)}}static apparentPositionOf(e,t,i){const n=this.orbitOf(e);let r=n.positionAt(t);for(let a=0;a<2;a++){const o=this.length(this.subtract(r,i))/this.LIGHT_SPEED_AU_PER_DAY;r=n.positionAt(t-o)}return r}static horizontalOf(e,t,i,n){const r=$r(g5(),new St(e.x,e.y,e.z,t)),a=$r(mg(t),r),o=$S(t,new Td(n.lat,n.lng,n.elevationM)),c=new St(a.x-o.x,a.y-o.y,a.z-o.z,t),l=Dd(c);return Cd(l.ra,l.dec,i,n)}static earthPositionAt(e){return $r(m5(),ws(Se.Earth,e))}static julianDayOf(e){return 2451545+Lt(e).tt}static orbitOf(e){const t=this.orbits.get(e.id);if(t)return t;const i=new Vn(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 vh=[{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 Bp{static UNIX_EPOCH_JD=24405875e-1;static aroundDate(e){const t=this.julianDayOf(e);return vh.filter(i=>this.magnitudeAt(i,t)!==void 0)}static appearancesAt(e,t){const i=this.julianDayOf(e),n=[];for(const r of vh){const a=this.magnitudeAt(r,i);a!==void 0&&n.push({outburst:r,position:an.ofJ2000(r.raHours,r.decDeg,e,t),magnitude:a})}return n.sort((r,a)=>r.magnitude-a.magnitude)}static brightestAt(e,t){return this.appearancesAt(e,t)[0]}static byId(e){return vh.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 r=1;for(;r<i.length-1&&i[r][0]<n;)r++;const[a,o]=i[r-1]??i[0],[c,l]=i[r]??i[0];if(c===a)return o;const h=Math.min(1,Math.max(0,(n-a)/(c-a)));return o+h*(l-o)}static julianDayOf(e){return e.getTime()/864e5+this.UNIX_EPOCH_JD}}const _w=[{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}],Gc=6.5;class Mh{static activeAt(e){return _w.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)),r=this.dayOfYear(this.asDate(e.peak)),a=this.dayOfYear(this.asDate(e.end)),o=this.wrappedDelta(i,r),c=this.wrappedDelta(r,n),l=this.wrappedDelta(a,r);return o<0?o<-c?0:1+o/c:o>0?o>l?0:1-o/l:1}static observedRatePerHour(e,t,i,n=Gc){if(t<=0)return 0;const r=Gc-n;return e*Math.sin(t*Math.PI/180)/Math.pow(i,r)}static radiantPosition(e,t,i){return an.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 kt{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(e,t){const i=Lt(e),n=new jc(0,YS(e).elon-90,1),r=$r(M5(i),Rd(n,i)),a=Dd(r);return Cd(a.ra,a.dec,e,t)}static observedRatePerHour(e,t=Gc){const i=kt.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(e*Math.PI/180)),n=Gc-t;return(kt.QUIET_RATE_PER_HOUR+i)/Math.pow(kt.POPULATION_INDEX,n)}static schedule(e){const t=new tl(e.seed^1542469173);return Ys.schedule(e).map(i=>{const n=kt.toCartesian({altitudeDeg:Math.asin(t.next())*180/Math.PI,azimuthDeg:t.between(0,360)}),r=i.fromRadiantDeg*Math.PI/180,a=kt.turnAround(n,t.between(0,360)),o={x:n.x*Math.cos(r)+a.x*Math.sin(r),y:n.y*Math.cos(r)+a.y*Math.sin(r),z:n.z*Math.cos(r)+a.z*Math.sin(r)};return{...i,radiant:kt.toHorizontal(o),bearingDeg:kt.bearingFrom(o,n)}})}static turnAround(e,t){const[i,n]=kt.basisAround(e),r=t*Math.PI/180;return{x:i.x*Math.cos(r)+n.x*Math.sin(r),y:i.y*Math.cos(r)+n.y*Math.sin(r),z:i.z*Math.cos(r)+n.z*Math.sin(r)}}static bearingFrom(e,t){const[i,n]=kt.basisAround(e),r=e.x*t.x+e.y*t.y+e.z*t.z,a=kt.normalise({x:t.x-e.x*r,y:t.y-e.y*r,z:t.z-e.z*r});return(Math.atan2(a.x*n.x+a.y*n.y+a.z*n.z,a.x*i.x+a.y*i.y+a.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=kt.normalise(kt.cross(e,t));return[i,kt.normalise(kt.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=kt.toCartesian(e.radiant??{altitudeDeg:90,azimuthDeg:0}),i=kt.turnAround(t,e.bearingDeg),n=e.fromRadiantDeg*Math.PI/180;return kt.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 Hp="https://ufoathome.org/tle/index.json";class vi{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??vi.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(Hp)||e.push(Hp),e}static FIRST_SNAPSHOT="2021-02-22";async covers(e){const t=Date.parse(`${vi.FIRST_SNAPSHOT}T00:00:00Z`)-vi.MAX_ELEMENT_AGE_DAYS*vi.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)-vi.MAX_ELEMENT_AGE_DAYS*vi.DAY_MS&&e.getTime()<=Date.parse(n.to)+vi.MAX_ELEMENT_AGE_DAYS*vi.DAY_MS):!1}async at(e){const t=await this.loadIndex();if(!t)return;const{index:i,base:n}=t,r=[],a=[];for(const o of Object.keys(i.kinds)){const c=await this.kindAt(o,e,i,n);r.push(...c),a.push(this.coverageOf(o,e,i,c.length>0))}return{objects:r,coverage:a,credit:i.credit,creditUrl:i.source}}async kindAt(e,t,i,n){const r=t.getTime(),a=i.binDays*vi.DAY_MS,o=Math.floor(r/a),c=r-o*a<a/2?o-1:o+1,l=new Set(i.kinds[e].bins),h=[o,c].map(v=>new Date(v*a).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 vi.decode(v,i.recordBytes)){const g=f.get(m.norad);(!g||Math.abs(m.epochMs-r)<Math.abs(g.epochMs-r))&&f.set(m.norad,m)}const p=[];for(const v of f.values()){const m=Math.abs(v.epochMs-r)/vi.DAY_MS;if(m>vi.MAX_ELEMENT_AGE_DAYS)continue;const g=u[v.norad]??{name:String(v.norad)};g.launch&&Date.parse(`${g.launch}T00:00:00Z`)>r||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:r,to:a}=i.kinds[e],o=t.getTime(),c=vi.MAX_ELEMENT_AGE_DAYS*vi.DAY_MS,l=n?"covered":o<Date.parse(r)-c?"before":o>Date.parse(a)+c?"after":"gap";return{kind:e,status:l,from:r,to:a}}static decode(e,t){const i=new DataView(e),n=[];for(let r=0;r+t<=e.byteLength;r+=t)n.push({norad:i.getUint32(r,!0),epochMs:i.getFloat64(r+4,!0),bstar:i.getFloat32(r+12,!0),inclinationDeg:i.getFloat32(r+16,!0),raanDeg:i.getFloat32(r+20,!0),eccentricity:i.getFloat32(r+24,!0),argOfPerigeeDeg:i.getFloat32(r+28,!0),meanAnomalyDeg:i.getFloat32(r+32,!0),meanMotion:i.getFloat64(r+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 yw{lowerM;upperM;add(e,t){if(!(e<=0)){if(t.behindM!==void 0){const i=yt.sizeMAt(t.behindM,e);this.lowerM=this.lowerM===void 0?i:Math.max(this.lowerM,i)}if(t.inFrontM!==void 0){const i=yt.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:yt.distanceMAt(this.lowerM,e),maxM:this.upperM===void 0?void 0:yt.distanceMAt(this.upperM,e)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class Ks{static DEG_PER_SECOND=360/86164.0905;static degOver(e){return Math.max(0,e)*Ks.DEG_PER_SECOND}static instants(e,t){if(!(t>0))return 1;const i=Ks.degOver(e)/t;return i<1?1:Math.min(Ks.MAX_INSTANTS,Math.max(2,Math.ceil(i)))}static MAX_INSTANTS=64}class bi{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 Ks.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 bi.EYE;const r=t.focalLengthMm??e.frame?.focalLengthMm??bi.UNKNOWN_CAMERA_FOCAL_MM,a=r/n,o=bi.resolutionArcsec(e,r,a);return{apertureMm:a,exposureSeconds:Math.min(i,bi.trailLimitedSeconds(o)),resolutionArcsec:o}}static resolutionArcsec(e,t,i){const r=(e.detailUm??bi.UNKNOWN_CAMERA_DETAIL_UM)/1e3/t*bi.ARCSEC_PER_RADIAN,a=1.22*bi.WAVELENGTH_M/(i/1e3)*bi.ARCSEC_PER_RADIAN;return Math.max(r,a)}static trailLimitedSeconds(e){return e/bi.skyDriftArcsecPerSecond}static gainOverEye(e,t={}){const i=bi.graspOf(e,t),n=bi.EYE,r=(i.apertureMm/n.apertureMm)**2,a=i.exposureSeconds/n.exposureSeconds,o=(n.resolutionArcsec/i.resolutionArcsec)**2;return 1.25*Math.log10(r*a*o)}static gainFor(e,t){const i=t.fieldOfViewDeg===void 0?void 0:Yt.focalLengthMmFor(e,t.fieldOfViewDeg);return bi.gainOverEye(e,{fNumber:t.fNumber,focalLengthMm:i,exposureSeconds:t.exposureSeconds})}}const Gp=111320,Ea=Math.PI/180,Sw=1.02,bw=1;class Ba{static of(e,t){const i=Ba.sightings(e,t);if(i.length<2)return;const n=Ba.baseline(i);if(!n)return;const{near:r,far:a,closedM:o}=n,c=Math.tan(a.widthDeg/2*Ea)===0?0:Math.tan(r.widthDeg/2*Ea)/Math.tan(a.widthDeg/2*Ea);if(c<Sw)return;const l=o/(c-1),h=yt.sizeMAt(l,r.widthDeg),u=i.map(d=>({t:d.t,m:yt.distanceMAt(h,d.widthDeg)}));return{widthM:h,distanceM:u,nearestM:Math.min(...u.map(d=>d.m)),fromT:a.t,toT:r.t,closedM:o}}static sightings(e,t){return e.timeline.allKeyframes.flatMap(i=>{const n=i.shapes.find(o=>o.sourceId===t)?.shape,r=n?.angular?.widthDeg,a=si(e,i.t);return r===void 0||r<=0||a?.lat===void 0||a.lng===void 0?[]:[{t:i.t,widthDeg:r,lat:a.lat,lng:a.lng,sightAzimuthDeg:n?.aim?.azimuthDeg??a.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 r=Ba.closedAlongSight(i,n),[a,o,c]=r>=0?[n,i,r]:[i,n,-r];c<bw||a.widthDeg<=o.widthDeg||(!t||c>t.closedM)&&(t={near:a,far:o,closedM:c})}return t}static closedAlongSight(e,t){const i=(t.lat-e.lat)*Gp,n=(t.lng-e.lng)*Gp*Math.cos(e.lat*Ea),r=(e.sightAzimuthDeg??0)*Ea;return i*Math.cos(r)+n*Math.sin(r)}}class Si{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:Si.atLeastNearest(e.statedM),basis:"stated"};if(e.hypothesisM!==void 0&&e.hypothesisM>0)return{distanceM:Si.atLeastNearest(e.hypothesisM),basis:"hypothesis"};if(e.derivedM!==void 0&&e.derivedM>0)return{distanceM:Si.atLeastNearest(e.derivedM),basis:"derived"};const t=Si.largest(e.range?.minM,e.crossing?.behindM),i=Si.smallest(e.range?.maxM,e.crossing?.inFrontM),n=t===void 0?void 0:t*Si.MARGIN,r=i===void 0?void 0:i/Si.MARGIN;return n!==void 0&&r!==void 0?{distanceM:Si.atLeastNearest(n<=r?Math.sqrt(n*r):n),basis:"bounded"}:n!==void 0?{distanceM:Si.atLeastNearest(n),basis:"bounded"}:r!==void 0&&r<Si.CONVENTIONAL_M?{distanceM:Si.atLeastNearest(r),basis:"bounded"}:{distanceM:Si.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(e){return Math.max(Si.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)}}rm();const ww={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"}},Ew=["en","fr"],Aw={en:"{name} — mag {mag}, {alt}° above the horizon",fr:"{name} — mag {mag}, {alt}° au-dessus de l'horizon"},Tw={en:"{name} — satellite, mag {mag}, {height} km up",fr:"{name} — satellite, mag {mag}, à {height} km d'altitude"},Rw="satellites-change",Dw={en:"{name} — mag {mag}, {alt}° below the horizontal",fr:"{name} — mag {mag}, {alt}° sous l'horizontale"},Vp="comet:",Wp="nova:",Cw={building:{en:"Building",fr:"Bâtiment"},tree:{en:"Tree",fr:"Arbre"},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"}},Iw=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,Pw=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,Lw=-18,Nw={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},xh={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class Id extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","deep-star-catalog-src","show-compass","max-pixel-ratio",zr,Br]}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;lastSkyKey;starCatalog;starCatalogRequest=0;static tleArchive=new vi;satellitesFor;satelliteRequest=0;satelliteStatus="none";satellites;satellitePassesMemo;starCatalogDepth=0;weatherAudio=new Mw;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,r=(e.clientY-i.top)/i.height*t.height;if(this.ufoElement.hasVisibleShapeAt(n,r)){this.hoverTooltip.hidden=!0;return}const a=(e.clientX-i.left)/i.width*2-1,o=-((e.clientY-i.top)/i.height*2-1),c=Yu(_c.preferencesFor(this),Ew),l=this.sceneRenderer.pickBodyAt(a,o);if(l){this.showHoverTooltip(e,this.bodyName(l,c));return}const h=this.sceneRenderer.pickDecorAt(a,o),u=h?this.ufoElement.sighting.decor.find(p=>p.id===h):void 0;if(u){this.showHoverTooltip(e,this.said.read(u.title)||Cw[u.kind][c]);return}const d=this.sceneRenderer.pickSatelliteAt(a,o);if(d){this.showHoverTooltip(e,Tw[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(a,o);if(f){const p=f.star.mag,v=f.altitudeDeg,m=(v<0?Dw:Aw)[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(Vp)?e.slice(Vp.length):void 0,n=i?Dg.find(a=>a.id===i):void 0,r=e.startsWith(Wp)?Bp.byId(e.slice(Wp.length)):void 0;return n?.name[t]??r?.name[t]??ww[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(),Kt.thunderDelayMs(e))}handleFirstInteraction=()=>{this.removeEventListener("pointerdown",this.handleFirstInteraction,!0),this.removeEventListener("keydown",this.handleFirstInteraction,!0),this.weatherAudio.resume(),this.setWeather(ar(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>${Bg}</style>${zg}`,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 qi(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(Sh),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 Ms(_c.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===zr||e===Br)&&i!==t&&this.forwardPlayerAttributes()}forwardPlayerAttributes(){for(const e of[zr,Br])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}=hi(e.lat,e.lng,t.lat,t.lng);if(Math.hypot(i,n)<1)return this.setLookOffset(0,0);const r=(Math.atan2(i,-n)*180/Math.PI+360)%360;this.setLookOffset(((r-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 Kp.json(e)}get sightingData(){return this.ufoElement.sightingData}set sightingData(e){this.ufoElement.sightingData=e,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}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=yt.CANVAS_HEIGHT_PX,i=Yt.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:mh,url:this.getAttribute("star-catalog-src")??Iw},{magnitudeLimit:gh,url:this.getAttribute("deep-star-catalog-src")??Pw}],t=this.instrumentReach(),i=++this.starCatalogRequest;this.starCatalogDepth=t>mh?gh:mh;const n=await Sn.upTo(e,t);i===this.starCatalogRequest&&(this.starCatalog=n,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=gh||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const e=this.ufoElement.sighting,t=bi.gainFor(e.instrument,{fNumber:si(e,0)?.fNumber,fieldOfViewDeg:Ki.fovOf(e,0),exposureSeconds:e.exposure});return yu(Lw,t)}updateAstronomy(e){this.ensureStarsDeepEnough(),this.applySceneAt(e);const t=rn.windowEndingAt(e,this.exposureSeconds()),i=t.seconds,n=this.degreesPerPixelAt(e),r=Ks.instants(i,n),a=Math.max(r,this.ufoElement.exposureTimes(e).length,rn.instants(this.ufoElement.sighting.decor,si(this.ufoElement.sighting,e)?.elevationM??0,t.fromMs,i,n));if(a<=1){this.sceneRenderer.setExposure(1);return}this.sceneRenderer.setExposure(a,o=>this.applySceneAt(t.fromMs+t.ms*o/(a-1),{sky:Math.floor(o*r/a)!==Math.floor((o-1)*r/a),stepMs:t.ms/a}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(e){const t=this.sceneCanvas.height;return t<=0?0:Ki.fovOf(this.ufoElement.sighting,e)/t}applySceneAt(e,t){const i=this.ufoElement.sighting;this.setWeather(ar(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),r=si(i,0),a=ar(i,0),o=Object.fromEntries(vc(ar(i,e)).map(y=>[y.id,Gd(e,i.weatherTrack,a,r,n,y.id)]));this.sceneRenderer.setCloudOffset(Gd(e,i.weatherTrack,a,r,n),o),this.sceneRenderer.setObserverPose(n??xh),this.sceneRenderer.setLensOptics(this.lensOpticsAt(e)),this.sceneRenderer.setInstrumentGain(bi.gainFor(i.instrument,{fNumber:n?.fNumber,fieldOfViewDeg:Ki.fovOf(i,e),exposureSeconds:i.exposure}),i.instrument.detailUm!==void 0),this.sceneRenderer.setGait(qt.of(i)?.offsetAt(e)??qt.STILL),this.sceneRenderer.updateDecorAnchoring(si(i,0),n,e),this.sceneRenderer.updateDecorLitState(e,t?.stepMs??0),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng),this.pushPhenomenaAt(e);const c=n?.lat??xh.lat,l=n?.lng??xh.lng,h=Zo(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(Nw);return}const d=new Date(h.getTime()+e),f=Math.max(1,Math.round(.25*this.degreesPerPixelAt(e)/Ks.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={...$l("Sun",d,u),magnitude:Zl("Sun",d)},g={...$l("Moon",d,u),phase:_5(d),magnitude:Zl("Moon",d)},b=x5.map(y=>({body:y,position:$l(y,d,u),magnitude:Zl(y,d)}));this.sceneRenderer.setAstronomy({sun:m,moon:g,planets:b,comet:this.cometAt(d,u),novae:Bp.appearancesAt(d,u).map(({outburst:y,position:_,magnitude:w})=>({id:y.id,position:_,magnitude:w})),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),r=[];for(const a of this.satellites.passes.positionsAt(n,i,-1))a.magnitude!==void 0&&r.push({norad:a.object.norad,name:a.object.name,position:{altitudeDeg:a.altitudeDeg,azimuthDeg:a.azimuthDeg},magnitude:a.magnitude,heightKm:a.heightKm});this.sceneRenderer.setSatellites(r)}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=a=>{i===this.satelliteRequest&&(this.satelliteStatus=a,this.dispatchEvent(new CustomEvent(Rw)))},r=Id.tleArchive;(async()=>{if(!await r.covers(e))return n("outside");const[a,o]=await Promise.all([r.at(e),gc(()=>import("./SatellitePasses-Pfro2-0Z.js"),[],import.meta.url)]);if(i===this.satelliteRequest){if(!a)return n("unavailable");this.satellites={snapshot:a,passes:new o.SatellitePasses(a.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),r=i.event.place?.[0],a=n?.lat??r?.lat,o=n?.lng??r?.lng;if(!t||a===void 0||o===void 0)return[];const c=Zo(i.event.time??{},o,i.event.utcOffsetHours);if(!c)return[];const l=Math.min(Math.max(e,0),4*36e5),h={lat:a,lng:o,elevationM:n?.elevationM??0},u=JSON.stringify([this.satellitesFor,c.getTime(),a,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=xw.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,r=this.ufoElement.frameShiftPx,a=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+r.x,y:v.bounds.y+r.y}};o.set(p,m);const g=v.aim?this.sceneRenderer.screenPointOf(sn.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)},b=g!==void 0&&Math.abs(g.ndcX)<=1&&Math.abs(g.ndcY)<=1,y=b?this.sceneRenderer.decorDistancesAt(g.ndcX,g.ndcY,p):{};l.add(p),(b||v.aim)&&l.delete(p);const _=v.angular?.widthDeg??a.pxToDeg(v.bounds.width),w=this.sizeEstimateOf(p);w.add(_,y);const E=Ba.of(t,p);c.set(p,Si.resolve({hypothesisM:this.distanceHypotheses.get(p),derivedM:E&&_>0?yt.distanceMAt(E.widthM,_):void 0,range:w.distanceRangeAt(_),crossing:y}))}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 y=c.get(m);y&&c.set(p,{distanceM:y.distanceM*.999,basis:y.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)});const f=(si(t,e)?.rollDeg??0)+(qt.of(t)?.offsetAt(e)??qt.STILL).rollDeg;this.sceneRenderer.setPhenomena(u,{projection:a,canvasWidthPx:n.width,canvasHeightPx:n.height,scale:Math.max(1,this.sceneCanvas.height/Math.max(1,n.height)),starPoints:Yt.starPointsOf(t.instrument),rollRad:f*Math.PI/180})}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 r=this.lightningFlashes.filter(a=>a.t>n&&a.t<=t).pop();r&&ar(e,r.t).storm&&this.handleLightningFlash(r)}ensureLightningSchedule(e){const t=ar(e,0).precipitationIntensity,i=`${this.meteorInputsOf(e)}|${t}`;if(i===this.lightningScheduleFor)return;this.lightningScheduleFor=i;const n=e.event.time,r=e.event.place?.[0],a=n?.year!==void 0?Zo(n,r?.lng??0,e.event.utcOffsetHours):void 0,o=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,c=Math.round((a?.getTime()??0)/1e3)+Math.round((r?.lat??0)*1e3)+7;this.lightningFlashes=Kt.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?Zo(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 r={lat:t.lat,lng:t.lng,elevationM:0},a=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,o=Math.round(n.getTime()/1e3)+Math.round(t.lat*1e3),c=kt.schedule({ratePerHour:kt.observedRatePerHour(kt.apexPosition(n,r).altitudeDeg),durationMs:a,velocityKmS:kt.TYPICAL_VELOCITY_KM_S,seed:o}),l=Mh.activeAt(n).map(u=>{const d=Mh.radiantPosition(u.shower,n,r);return{entry:u,position:d,rate:Mh.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=Ys.schedule({ratePerHour:l.rate,durationMs:a,velocityKmS:l.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...c],l.position.altitudeDeg,l.position.azimuthDeg)}meteorByRank(e){this.ensureMeteorSchedule(this.ufoElement.sighting);const t=[...this.sceneRenderer.meteorSchedule].filter(r=>r.t+r.durationMs<=this.ufoElement.seekableDuration).sort((r,a)=>a.brightness-r.brightness);if(t.length===0)return;const 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,r=si(t,e),a=r?.fNumber??i.fNumber;if(!n||a===void 0)return;const o=Yt.focalLengthMmFor(i,Ki.fovOf(t,e));if(o!==void 0)return{focalLengthMm:o,fNumber:a,focusDistance:r?.focusDistanceM??0,frameHeightMm:n.heightMm}}projectionAt(e){const t=this.ufoElement.sighting;return Yn.of(t.instrument,yt.CANVAS_HEIGHT_PX,Ki.fovOf(t,e))}sizeEstimateOf(e){let t=this.sizeEstimates.get(e);return t||(t=new yw,this.sizeEstimates.set(e,t)),t}}const Xp="rr0-scene";function Ow(){rm(),customElements.get(Xp)||customElements.define(Xp,Id)}Ow();export{ov as $,Bw as A,ot as B,oe as C,rf as D,We as E,qw as F,Gw as G,Dm as H,Hw as I,Vw as J,Fa as K,io as L,Ww as M,po as N,At as O,kv as P,Qn as Q,qa as R,Pi as S,Uw as T,ri as U,Ae as V,Li as W,zw as X,Ts as Y,Rm as Z,Xw as _,kw as a,wc as a0,cu as a1,Ic as a2,oi as a3,Om as a4,ud as a5,dd as a6,et as a7,Es as a8,to as a9,un as aa,es as ab,Fw as b,$w as c,Ac as d,Kw as e,Ye as f,D as g,G0 as h,Yw as i,Zw as j,nv as k,Gs as l,cl as m,c2 as n,at as o,Dt as p,Ih as q,Ei as r,ld as s,ts as t,fv as u,xv as v,on as w,Zi as x,mt as y,bt as z};
|
|
6585
|
+
`;let cc;function uE(){if(cc)return cc;const s=128,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),i=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return i.addColorStop(0,"rgba(255,255,255,1)"),i.addColorStop(.4,"rgba(255,255,255,0.35)"),i.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=i,t.fillRect(0,0,s,s),cc=new Ln(e),cc}function zp(s){const t=document.createElement("canvas");t.width=128,t.height=128;const i=t.getContext("2d"),n=128/2-2,r=128/2,a=128/2,o="#2e2b26",c="#f4f1e2";i.fillStyle=o,i.beginPath(),i.arc(r,a,n,0,Math.PI*2),i.fill();const l=za(s.illuminatedFraction,0,1),h=s.phaseFraction<.5,u=n*Math.abs(1-2*l),d=l<.5;return i.save(),i.beginPath(),i.arc(r,a,n,0,Math.PI*2),i.clip(),i.fillStyle=c,i.beginPath(),h?(i.arc(r,a,n,-Math.PI/2,Math.PI/2,!1),i.ellipse(r,a,u,n,0,Math.PI/2,-Math.PI/2,d)):(i.arc(r,a,n,Math.PI/2,-Math.PI/2,!1),i.ellipse(r,a,u,n,0,-Math.PI/2,Math.PI/2,d)),i.fill(),i.restore(),new Ln(t)}function dE(s){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(s,64,68),new Ln(e)}function ph(s){let e=s;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 mh=7.5,gh=9;class Sn{static cache=new Map;static load(e){let t=Sn.cache.get(e);return t||(t=fetch(e).then(i=>i.arrayBuffer()).then(i=>Sn.parse(i)),Sn.cache.set(e,t)),t}static upTo(e,t){const i=e.filter((a,o)=>o===0||e[o-1].magnitudeLimit<t);if(i.length<=1)return Sn.load(e[0].url);const n=i.map(a=>a.url).join(`
|
|
6586
|
+
`);let r=Sn.cache.get(n);return r||(r=Promise.all(i.map(a=>Sn.load(a.url))).then(a=>a.reduce((o,c)=>Sn.concat(o,c))),Sn.cache.set(n,r)),r}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,r)=>{const a=new Float32Array(n.length+r.length);return a.set(n,0),a.set(r,n.length),a};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 fE=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,pE=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,mE=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,gE=20,vE=1;class ME{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 a=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,n!=="none"&&this.startLoop(fE,this.ambientVolume).then(o=>this.applyIfCurrent(o,a,()=>this.ambientToken,c=>{this.ambientSource=c?.source,this.ambientGain=c?.gain,c&&(c.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(i/gE,1);const r=i>vE;if(r!==this.windActive){this.windActive=r;const a=++this.windToken;this.stopSource(this.windSource,this.windGain),this.windSource=void 0,this.windGain=void 0,r&&this.startLoop(pE,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,c=>{this.windSource=c?.source,this.windGain=c?.gain,c&&(c.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(e){if(e===this.paused)return;this.paused=e;const{type:t,intensity:i,windSpeed:n}=this.requested;this.setAmbient(t,i,n)}playThunder(){!this.context||this.paused||this.playOneShot(mE,.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),r=i.createBufferSource();r.buffer=n,r.loop=!0;const a=i.createGain();return a.gain.value=t,r.connect(a).connect(i.destination),r.start(),{source:r,gain:a}}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),r=i.createBufferSource();r.buffer=n;const a=i.createGain();a.gain.value=t,r.connect(a).connect(i.destination),r.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 Vn{constructor(e){this.elements=e;const{eccentricity:t,perihelionAu:i}=e,[n,r]=this.perifocalAxes(),a=Math.sqrt(Vn.SUN_GM_AU3_PER_DAY2*(1+t)/i);this.perihelionPosition=this.scale(n,i),this.perihelionVelocity=this.scale(r,a),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,r=this.elements.perihelionAu,a=1-i*i/r*Vn.stumpffC(n),o=t-i*i*i/Math.sqrt(Vn.SUN_GM_AU3_PER_DAY2)*Vn.stumpffS(n);return{x:a*this.perihelionPosition.x+o*this.perihelionVelocity.x,y:a*this.perihelionPosition.y+o*this.perihelionVelocity.y,z:a*this.perihelionPosition.z+o*this.perihelionVelocity.z}}heliocentricDistanceAt(e){const t=this.positionAt(e);return Math.hypot(t.x,t.y,t.z)}universalAnomaly(e){if(e===0)return 0;const t=Math.sign(e),i=Math.sqrt(Vn.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*Vn.stumpffS(c)+l*o};let r=Math.max(1,i/this.elements.perihelionAu);for(;n(r)<i;)r*=2;let a=0;for(let o=0;o<Vn.MAX_ITERATIONS&&r-a>1e-13*Math.max(1,r);o++){const c=(a+r)/2;n(c)<i?a=c:r=c}return t*(a+r)/2}perifocalAxes(){const e=this.elements.ascendingNodeDeg*Math.PI/180,t=this.elements.argumentOfPerihelionDeg*Math.PI/180,i=this.elements.inclinationDeg*Math.PI/180,n=Math.cos(e),r=Math.sin(e),a=Math.cos(t),o=Math.sin(t),c=Math.cos(i),l=Math.sin(i);return[{x:n*a-r*o*c,y:r*a+n*o*c,z:o*l},{x:-n*o-r*a*c,y:-r*o+n*a*c,z:a*l}]}scale(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}static stumpffC(e){if(Math.abs(e)<1e-6)return 1/2-e/24+e*e/720;if(e>0)return(1-Math.cos(Math.sqrt(e)))/e;const t=Math.sqrt(-e);return(Math.cosh(t)-1)/-e}static stumpffS(e){if(Math.abs(e)<1e-6)return 1/6-e/120+e*e/5040;if(e>0){const 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 Dg=[{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 xE{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 Dg.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=Lt(t),r=this.earthPositionAt(n),a=this.apparentPositionOf(e,2451545+n.tt,r),o=this.subtract(a,r),c=this.length(a),l=this.length(o),h=this.tailEndAt(e,a,r,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},r)),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,r,a,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,r,a,o),tailLengthDeg:this.angleBetween(h,l)}}static apparentPositionOf(e,t,i){const n=this.orbitOf(e);let r=n.positionAt(t);for(let a=0;a<2;a++){const o=this.length(this.subtract(r,i))/this.LIGHT_SPEED_AU_PER_DAY;r=n.positionAt(t-o)}return r}static horizontalOf(e,t,i,n){const r=$r(g5(),new St(e.x,e.y,e.z,t)),a=$r(mg(t),r),o=$S(t,new Td(n.lat,n.lng,n.elevationM)),c=new St(a.x-o.x,a.y-o.y,a.z-o.z,t),l=Dd(c);return Cd(l.ra,l.dec,i,n)}static earthPositionAt(e){return $r(m5(),Es(Se.Earth,e))}static julianDayOf(e){return 2451545+Lt(e).tt}static orbitOf(e){const t=this.orbits.get(e.id);if(t)return t;const i=new Vn(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 vh=[{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 Bp{static UNIX_EPOCH_JD=24405875e-1;static aroundDate(e){const t=this.julianDayOf(e);return vh.filter(i=>this.magnitudeAt(i,t)!==void 0)}static appearancesAt(e,t){const i=this.julianDayOf(e),n=[];for(const r of vh){const a=this.magnitudeAt(r,i);a!==void 0&&n.push({outburst:r,position:an.ofJ2000(r.raHours,r.decDeg,e,t),magnitude:a})}return n.sort((r,a)=>r.magnitude-a.magnitude)}static brightestAt(e,t){return this.appearancesAt(e,t)[0]}static byId(e){return vh.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 r=1;for(;r<i.length-1&&i[r][0]<n;)r++;const[a,o]=i[r-1]??i[0],[c,l]=i[r]??i[0];if(c===a)return o;const h=Math.min(1,Math.max(0,(n-a)/(c-a)));return o+h*(l-o)}static julianDayOf(e){return e.getTime()/864e5+this.UNIX_EPOCH_JD}}const _E=[{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}],Gc=6.5;class Mh{static activeAt(e){return _E.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)),r=this.dayOfYear(this.asDate(e.peak)),a=this.dayOfYear(this.asDate(e.end)),o=this.wrappedDelta(i,r),c=this.wrappedDelta(r,n),l=this.wrappedDelta(a,r);return o<0?o<-c?0:1+o/c:o>0?o>l?0:1-o/l:1}static observedRatePerHour(e,t,i,n=Gc){if(t<=0)return 0;const r=Gc-n;return e*Math.sin(t*Math.PI/180)/Math.pow(i,r)}static radiantPosition(e,t,i){return an.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 kt{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(e,t){const i=Lt(e),n=new jc(0,YS(e).elon-90,1),r=$r(M5(i),Rd(n,i)),a=Dd(r);return Cd(a.ra,a.dec,e,t)}static observedRatePerHour(e,t=Gc){const i=kt.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(e*Math.PI/180)),n=Gc-t;return(kt.QUIET_RATE_PER_HOUR+i)/Math.pow(kt.POPULATION_INDEX,n)}static schedule(e){const t=new tl(e.seed^1542469173);return Ys.schedule(e).map(i=>{const n=kt.toCartesian({altitudeDeg:Math.asin(t.next())*180/Math.PI,azimuthDeg:t.between(0,360)}),r=i.fromRadiantDeg*Math.PI/180,a=kt.turnAround(n,t.between(0,360)),o={x:n.x*Math.cos(r)+a.x*Math.sin(r),y:n.y*Math.cos(r)+a.y*Math.sin(r),z:n.z*Math.cos(r)+a.z*Math.sin(r)};return{...i,radiant:kt.toHorizontal(o),bearingDeg:kt.bearingFrom(o,n)}})}static turnAround(e,t){const[i,n]=kt.basisAround(e),r=t*Math.PI/180;return{x:i.x*Math.cos(r)+n.x*Math.sin(r),y:i.y*Math.cos(r)+n.y*Math.sin(r),z:i.z*Math.cos(r)+n.z*Math.sin(r)}}static bearingFrom(e,t){const[i,n]=kt.basisAround(e),r=e.x*t.x+e.y*t.y+e.z*t.z,a=kt.normalise({x:t.x-e.x*r,y:t.y-e.y*r,z:t.z-e.z*r});return(Math.atan2(a.x*n.x+a.y*n.y+a.z*n.z,a.x*i.x+a.y*i.y+a.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=kt.normalise(kt.cross(e,t));return[i,kt.normalise(kt.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=kt.toCartesian(e.radiant??{altitudeDeg:90,azimuthDeg:0}),i=kt.turnAround(t,e.bearingDeg),n=e.fromRadiantDeg*Math.PI/180;return kt.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 Hp="https://ufoathome.org/tle/index.json";class vi{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??vi.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(Hp)||e.push(Hp),e}static FIRST_SNAPSHOT="2021-02-22";async covers(e){const t=Date.parse(`${vi.FIRST_SNAPSHOT}T00:00:00Z`)-vi.MAX_ELEMENT_AGE_DAYS*vi.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)-vi.MAX_ELEMENT_AGE_DAYS*vi.DAY_MS&&e.getTime()<=Date.parse(n.to)+vi.MAX_ELEMENT_AGE_DAYS*vi.DAY_MS):!1}async at(e){const t=await this.loadIndex();if(!t)return;const{index:i,base:n}=t,r=[],a=[];for(const o of Object.keys(i.kinds)){const c=await this.kindAt(o,e,i,n);r.push(...c),a.push(this.coverageOf(o,e,i,c.length>0))}return{objects:r,coverage:a,credit:i.credit,creditUrl:i.source}}async kindAt(e,t,i,n){const r=t.getTime(),a=i.binDays*vi.DAY_MS,o=Math.floor(r/a),c=r-o*a<a/2?o-1:o+1,l=new Set(i.kinds[e].bins),h=[o,c].map(v=>new Date(v*a).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 vi.decode(v,i.recordBytes)){const g=f.get(m.norad);(!g||Math.abs(m.epochMs-r)<Math.abs(g.epochMs-r))&&f.set(m.norad,m)}const p=[];for(const v of f.values()){const m=Math.abs(v.epochMs-r)/vi.DAY_MS;if(m>vi.MAX_ELEMENT_AGE_DAYS)continue;const g=u[v.norad]??{name:String(v.norad)};g.launch&&Date.parse(`${g.launch}T00:00:00Z`)>r||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:r,to:a}=i.kinds[e],o=t.getTime(),c=vi.MAX_ELEMENT_AGE_DAYS*vi.DAY_MS,l=n?"covered":o<Date.parse(r)-c?"before":o>Date.parse(a)+c?"after":"gap";return{kind:e,status:l,from:r,to:a}}static decode(e,t){const i=new DataView(e),n=[];for(let r=0;r+t<=e.byteLength;r+=t)n.push({norad:i.getUint32(r,!0),epochMs:i.getFloat64(r+4,!0),bstar:i.getFloat32(r+12,!0),inclinationDeg:i.getFloat32(r+16,!0),raanDeg:i.getFloat32(r+20,!0),eccentricity:i.getFloat32(r+24,!0),argOfPerigeeDeg:i.getFloat32(r+28,!0),meanAnomalyDeg:i.getFloat32(r+32,!0),meanMotion:i.getFloat64(r+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 yE{lowerM;upperM;add(e,t){if(!(e<=0)){if(t.behindM!==void 0){const i=yt.sizeMAt(t.behindM,e);this.lowerM=this.lowerM===void 0?i:Math.max(this.lowerM,i)}if(t.inFrontM!==void 0){const i=yt.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:yt.distanceMAt(this.lowerM,e),maxM:this.upperM===void 0?void 0:yt.distanceMAt(this.upperM,e)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class Ks{static DEG_PER_SECOND=360/86164.0905;static degOver(e){return Math.max(0,e)*Ks.DEG_PER_SECOND}static instants(e,t){if(!(t>0))return 1;const i=Ks.degOver(e)/t;return i<1?1:Math.min(Ks.MAX_INSTANTS,Math.max(2,Math.ceil(i)))}static MAX_INSTANTS=64}class Ei{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 Ks.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 Ei.EYE;const r=t.focalLengthMm??e.frame?.focalLengthMm??Ei.UNKNOWN_CAMERA_FOCAL_MM,a=r/n,o=Ei.resolutionArcsec(e,r,a);return{apertureMm:a,exposureSeconds:Math.min(i,Ei.trailLimitedSeconds(o)),resolutionArcsec:o}}static resolutionArcsec(e,t,i){const r=(e.detailUm??Ei.UNKNOWN_CAMERA_DETAIL_UM)/1e3/t*Ei.ARCSEC_PER_RADIAN,a=1.22*Ei.WAVELENGTH_M/(i/1e3)*Ei.ARCSEC_PER_RADIAN;return Math.max(r,a)}static trailLimitedSeconds(e){return e/Ei.skyDriftArcsecPerSecond}static gainOverEye(e,t={}){const i=Ei.graspOf(e,t),n=Ei.EYE,r=(i.apertureMm/n.apertureMm)**2,a=i.exposureSeconds/n.exposureSeconds,o=(n.resolutionArcsec/i.resolutionArcsec)**2;return 1.25*Math.log10(r*a*o)}static gainFor(e,t){const i=t.fieldOfViewDeg===void 0?void 0:Yt.focalLengthMmFor(e,t.fieldOfViewDeg);return Ei.gainOverEye(e,{fNumber:t.fNumber,focalLengthMm:i,exposureSeconds:t.exposureSeconds})}}const Gp=111320,wa=Math.PI/180,SE=1.02,bE=1;class Ba{static of(e,t){const i=Ba.sightings(e,t);if(i.length<2)return;const n=Ba.baseline(i);if(!n)return;const{near:r,far:a,closedM:o}=n,c=Math.tan(a.widthDeg/2*wa)===0?0:Math.tan(r.widthDeg/2*wa)/Math.tan(a.widthDeg/2*wa);if(c<SE)return;const l=o/(c-1),h=yt.sizeMAt(l,r.widthDeg),u=i.map(d=>({t:d.t,m:yt.distanceMAt(h,d.widthDeg)}));return{widthM:h,distanceM:u,nearestM:Math.min(...u.map(d=>d.m)),fromT:a.t,toT:r.t,closedM:o}}static sightings(e,t){return e.timeline.allKeyframes.flatMap(i=>{const n=i.shapes.find(o=>o.sourceId===t)?.shape,r=n?.angular?.widthDeg,a=si(e,i.t);return r===void 0||r<=0||a?.lat===void 0||a.lng===void 0?[]:[{t:i.t,widthDeg:r,lat:a.lat,lng:a.lng,sightAzimuthDeg:n?.aim?.azimuthDeg??a.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 r=Ba.closedAlongSight(i,n),[a,o,c]=r>=0?[n,i,r]:[i,n,-r];c<bE||a.widthDeg<=o.widthDeg||(!t||c>t.closedM)&&(t={near:a,far:o,closedM:c})}return t}static closedAlongSight(e,t){const i=(t.lat-e.lat)*Gp,n=(t.lng-e.lng)*Gp*Math.cos(e.lat*wa),r=(e.sightAzimuthDeg??0)*wa;return i*Math.cos(r)+n*Math.sin(r)}}class bi{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:bi.atLeastNearest(e.statedM),basis:"stated"};if(e.hypothesisM!==void 0&&e.hypothesisM>0)return{distanceM:bi.atLeastNearest(e.hypothesisM),basis:"hypothesis"};if(e.derivedM!==void 0&&e.derivedM>0)return{distanceM:bi.atLeastNearest(e.derivedM),basis:"derived"};const t=bi.largest(e.range?.minM,e.crossing?.behindM),i=bi.smallest(e.range?.maxM,e.crossing?.inFrontM),n=t===void 0?void 0:t*bi.MARGIN,r=i===void 0?void 0:i/bi.MARGIN;return n!==void 0&&r!==void 0?{distanceM:bi.atLeastNearest(n<=r?Math.sqrt(n*r):n),basis:"bounded"}:n!==void 0?{distanceM:bi.atLeastNearest(n),basis:"bounded"}:r!==void 0&&r<bi.CONVENTIONAL_M?{distanceM:bi.atLeastNearest(r),basis:"bounded"}:{distanceM:bi.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(e){return Math.max(bi.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)}}rm();const EE={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"}},wE=["en","fr"],AE={en:"{name} — mag {mag}, {alt}° above the horizon",fr:"{name} — mag {mag}, {alt}° au-dessus de l'horizon"},TE={en:"{name} — satellite, mag {mag}, {height} km up",fr:"{name} — satellite, mag {mag}, à {height} km d'altitude"},RE="satellites-change",DE={en:"{name} — mag {mag}, {alt}° below the horizontal",fr:"{name} — mag {mag}, {alt}° sous l'horizontale"},Vp="comet:",Wp="nova:",CE={building:{en:"Building",fr:"Bâtiment"},tree:{en:"Tree",fr:"Arbre"},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"}},IE=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,PE=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,LE=-18,NE={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},xh={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class Id extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","deep-star-catalog-src","show-compass","max-pixel-ratio",zr,Br]}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;lastSkyKey;starCatalog;starCatalogRequest=0;static tleArchive=new vi;satellitesFor;satelliteRequest=0;satelliteStatus="none";satellites;satellitePassesMemo;starCatalogDepth=0;weatherAudio=new ME;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,r=(e.clientY-i.top)/i.height*t.height;if(this.ufoElement.hasVisibleShapeAt(n,r)){this.hoverTooltip.hidden=!0;return}const a=(e.clientX-i.left)/i.width*2-1,o=-((e.clientY-i.top)/i.height*2-1),c=Yu(_c.preferencesFor(this),wE),l=this.sceneRenderer.pickBodyAt(a,o);if(l){this.showHoverTooltip(e,this.bodyName(l,c));return}const h=this.sceneRenderer.pickDecorAt(a,o),u=h?this.ufoElement.sighting.decor.find(p=>p.id===h):void 0;if(u){this.showHoverTooltip(e,this.said.read(u.title)||CE[u.kind][c]);return}const d=this.sceneRenderer.pickSatelliteAt(a,o);if(d){this.showHoverTooltip(e,TE[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(a,o);if(f){const p=f.star.mag,v=f.altitudeDeg,m=(v<0?DE: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(Vp)?e.slice(Vp.length):void 0,n=i?Dg.find(a=>a.id===i):void 0,r=e.startsWith(Wp)?Bp.byId(e.slice(Wp.length)):void 0;return n?.name[t]??r?.name[t]??EE[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(),Kt.thunderDelayMs(e))}handleFirstInteraction=()=>{this.removeEventListener("pointerdown",this.handleFirstInteraction,!0),this.removeEventListener("keydown",this.handleFirstInteraction,!0),this.weatherAudio.resume(),this.setWeather(ar(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>${Bg}</style>${zg}`,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 Yi(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(Sh),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 Ms(_c.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===zr||e===Br)&&i!==t&&this.forwardPlayerAttributes()}forwardPlayerAttributes(){for(const e of[zr,Br])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}=hi(e.lat,e.lng,t.lat,t.lng);if(Math.hypot(i,n)<1)return this.setLookOffset(0,0);const r=(Math.atan2(i,-n)*180/Math.PI+360)%360;this.setLookOffset(((r-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 Kp.json(e)}get sightingData(){return this.ufoElement.sightingData}set sightingData(e){this.ufoElement.sightingData=e,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}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=yt.CANVAS_HEIGHT_PX,i=Yt.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:mh,url:this.getAttribute("star-catalog-src")??IE},{magnitudeLimit:gh,url:this.getAttribute("deep-star-catalog-src")??PE}],t=this.instrumentReach(),i=++this.starCatalogRequest;this.starCatalogDepth=t>mh?gh:mh;const n=await Sn.upTo(e,t);i===this.starCatalogRequest&&(this.starCatalog=n,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=gh||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const e=this.ufoElement.sighting,t=Ei.gainFor(e.instrument,{fNumber:si(e,0)?.fNumber,fieldOfViewDeg:$i.fovOf(e,0),exposureSeconds:e.exposure});return yu(LE,t)}updateAstronomy(e){this.ensureStarsDeepEnough(),this.applySceneAt(e);const t=rn.windowEndingAt(e,this.exposureSeconds()),i=t.seconds,n=this.degreesPerPixelAt(e),r=Ks.instants(i,n),a=Math.max(r,this.ufoElement.exposureTimes(e).length,rn.instants(this.ufoElement.sighting.decor,si(this.ufoElement.sighting,e)?.elevationM??0,t.fromMs,i,n));if(a<=1){this.sceneRenderer.setExposure(1);return}this.sceneRenderer.setExposure(a,o=>this.applySceneAt(t.fromMs+t.ms*o/(a-1),{sky:Math.floor(o*r/a)!==Math.floor((o-1)*r/a),stepMs:t.ms/a}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(e){const t=this.sceneCanvas.height;return t<=0?0:$i.fovOf(this.ufoElement.sighting,e)/t}applySceneAt(e,t){const i=this.ufoElement.sighting;this.setWeather(ar(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),r=si(i,0),a=ar(i,0),o=Object.fromEntries(vc(ar(i,e)).map(y=>[y.id,Gd(e,i.weatherTrack,a,r,n,y.id)]));this.sceneRenderer.setCloudOffset(Gd(e,i.weatherTrack,a,r,n),o),this.sceneRenderer.setObserverPose(n??xh),this.sceneRenderer.setLensOptics(this.lensOpticsAt(e)),this.sceneRenderer.setInstrumentGain(Ei.gainFor(i.instrument,{fNumber:n?.fNumber,fieldOfViewDeg:$i.fovOf(i,e),exposureSeconds:i.exposure}),i.instrument.detailUm!==void 0),this.sceneRenderer.setGait(qt.of(i)?.offsetAt(e)??qt.STILL),this.sceneRenderer.updateDecorAnchoring(si(i,0),n,e),this.sceneRenderer.updateDecorLitState(e,t?.stepMs??0),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng),this.pushPhenomenaAt(e);const c=n?.lat??xh.lat,l=n?.lng??xh.lng,h=Zo(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(NE);return}const d=new Date(h.getTime()+e),f=Math.max(1,Math.round(.25*this.degreesPerPixelAt(e)/Ks.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={...$l("Sun",d,u),magnitude:Zl("Sun",d)},g={...$l("Moon",d,u),phase:_5(d),magnitude:Zl("Moon",d)},b=x5.map(y=>({body:y,position:$l(y,d,u),magnitude:Zl(y,d)}));this.sceneRenderer.setAstronomy({sun:m,moon:g,planets:b,comet:this.cometAt(d,u),novae:Bp.appearancesAt(d,u).map(({outburst:y,position:_,magnitude:E})=>({id:y.id,position:_,magnitude:E})),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),r=[];for(const a of this.satellites.passes.positionsAt(n,i,-1))a.magnitude!==void 0&&r.push({norad:a.object.norad,name:a.object.name,position:{altitudeDeg:a.altitudeDeg,azimuthDeg:a.azimuthDeg},magnitude:a.magnitude,heightKm:a.heightKm});this.sceneRenderer.setSatellites(r)}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=a=>{i===this.satelliteRequest&&(this.satelliteStatus=a,this.dispatchEvent(new CustomEvent(RE)))},r=Id.tleArchive;(async()=>{if(!await r.covers(e))return n("outside");const[a,o]=await Promise.all([r.at(e),gc(()=>import("./SatellitePasses-Pfro2-0Z.js"),[],import.meta.url)]);if(i===this.satelliteRequest){if(!a)return n("unavailable");this.satellites={snapshot:a,passes:new o.SatellitePasses(a.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),r=i.event.place?.[0],a=n?.lat??r?.lat,o=n?.lng??r?.lng;if(!t||a===void 0||o===void 0)return[];const c=Zo(i.event.time??{},o,i.event.utcOffsetHours);if(!c)return[];const l=Math.min(Math.max(e,0),4*36e5),h={lat:a,lng:o,elevationM:n?.elevationM??0},u=JSON.stringify([this.satellitesFor,c.getTime(),a,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=xE.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,r=this.ufoElement.frameShiftPx,a=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+r.x,y:v.bounds.y+r.y}};o.set(p,m);const g=v.aim?this.sceneRenderer.screenPointOf(sn.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)},b=g!==void 0&&Math.abs(g.ndcX)<=1&&Math.abs(g.ndcY)<=1,y=b?this.sceneRenderer.decorDistancesAt(g.ndcX,g.ndcY,p):{};l.add(p),(b||v.aim)&&l.delete(p);const _=v.angular?.widthDeg??a.pxToDeg(v.bounds.width),E=this.sizeEstimateOf(p);E.add(_,y);const w=Ba.of(t,p);c.set(p,bi.resolve({hypothesisM:this.distanceHypotheses.get(p),derivedM:w&&_>0?yt.distanceMAt(w.widthM,_):void 0,range:E.distanceRangeAt(_),crossing:y}))}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 y=c.get(m);y&&c.set(p,{distanceM:y.distanceM*.999,basis:y.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)});const f=(si(t,e)?.rollDeg??0)+(qt.of(t)?.offsetAt(e)??qt.STILL).rollDeg;this.sceneRenderer.setPhenomena(u,{projection:a,canvasWidthPx:n.width,canvasHeightPx:n.height,scale:Math.max(1,this.sceneCanvas.height/Math.max(1,n.height)),starPoints:Yt.starPointsOf(t.instrument),rollRad:f*Math.PI/180})}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 r=this.lightningFlashes.filter(a=>a.t>n&&a.t<=t).pop();r&&ar(e,r.t).storm&&this.handleLightningFlash(r)}ensureLightningSchedule(e){const t=ar(e,0).precipitationIntensity,i=`${this.meteorInputsOf(e)}|${t}`;if(i===this.lightningScheduleFor)return;this.lightningScheduleFor=i;const n=e.event.time,r=e.event.place?.[0],a=n?.year!==void 0?Zo(n,r?.lng??0,e.event.utcOffsetHours):void 0,o=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,c=Math.round((a?.getTime()??0)/1e3)+Math.round((r?.lat??0)*1e3)+7;this.lightningFlashes=Kt.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?Zo(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 r={lat:t.lat,lng:t.lng,elevationM:0},a=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,o=Math.round(n.getTime()/1e3)+Math.round(t.lat*1e3),c=kt.schedule({ratePerHour:kt.observedRatePerHour(kt.apexPosition(n,r).altitudeDeg),durationMs:a,velocityKmS:kt.TYPICAL_VELOCITY_KM_S,seed:o}),l=Mh.activeAt(n).map(u=>{const d=Mh.radiantPosition(u.shower,n,r);return{entry:u,position:d,rate:Mh.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=Ys.schedule({ratePerHour:l.rate,durationMs:a,velocityKmS:l.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...c],l.position.altitudeDeg,l.position.azimuthDeg)}meteorByRank(e){this.ensureMeteorSchedule(this.ufoElement.sighting);const t=[...this.sceneRenderer.meteorSchedule].filter(r=>r.t+r.durationMs<=this.ufoElement.seekableDuration).sort((r,a)=>a.brightness-r.brightness);if(t.length===0)return;const 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,r=si(t,e),a=r?.fNumber??i.fNumber;if(!n||a===void 0)return;const o=Yt.focalLengthMmFor(i,$i.fovOf(t,e));if(o!==void 0)return{focalLengthMm:o,fNumber:a,focusDistance:r?.focusDistanceM??0,frameHeightMm:n.heightMm}}projectionAt(e){const t=this.ufoElement.sighting;return Yn.of(t.instrument,yt.CANVAS_HEIGHT_PX,$i.fovOf(t,e))}sizeEstimateOf(e){let t=this.sizeEstimates.get(e);return t||(t=new yE,this.sizeEstimates.set(e,t)),t}}const Xp="rr0-scene";function OE(){rm(),customElements.get(Xp)||customElements.define(Xp,Id)}OE();export{ov as $,BE as A,ot as B,oe as C,rf as D,We as E,qE as F,GE as G,Dm as H,HE as I,VE as J,Fa as K,io as L,WE as M,po as N,At as O,kv as P,Qn as Q,qa as R,Li as S,UE as T,ri as U,Ae as V,Ni as W,zE as X,Ts as Y,Rm as Z,XE as _,kE as a,Ec as a0,cu as a1,Ic as a2,oi as a3,Om as a4,ud as a5,dd as a6,et as a7,ws as a8,to as a9,un as aa,es as ab,FE as b,$E as c,Ac as d,KE as e,Ye as f,D as g,G0 as h,YE as i,ZE as j,nv as k,Gs as l,cl as m,c2 as n,at as o,Dt as p,Ih as q,Ai as r,ld as s,ts as t,fv as u,xv as v,on as w,Ji as x,mt as y,bt as z};
|